2026-04-15 10:46:41 +09:00
|
|
|
import { stripInvisibleAgentCharacters } from "./agent-display-names"
|
|
|
|
|
|
2026-01-16 17:11:34 +09:00
|
|
|
/**
|
|
|
|
|
* Agent tool restrictions for session.prompt calls.
|
2026-01-16 18:29:39 +09:00
|
|
|
* OpenCode SDK's session.prompt `tools` parameter expects boolean values.
|
|
|
|
|
* true = tool allowed, false = tool denied.
|
2026-01-16 17:11:34 +09:00
|
|
|
*/
|
|
|
|
|
|
2026-05-09 16:30:40 +09:00
|
|
|
const TEAM_TOOL_DENYLIST: Record<string, boolean> = {
|
|
|
|
|
team_create: false,
|
|
|
|
|
team_delete: false,
|
|
|
|
|
team_shutdown_request: false,
|
|
|
|
|
team_approve_shutdown: false,
|
|
|
|
|
team_reject_shutdown: false,
|
|
|
|
|
team_send_message: false,
|
|
|
|
|
team_task_create: false,
|
|
|
|
|
team_task_list: false,
|
|
|
|
|
team_task_update: false,
|
|
|
|
|
team_task_get: false,
|
|
|
|
|
team_status: false,
|
|
|
|
|
team_list: false,
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 18:29:39 +09:00
|
|
|
const EXPLORATION_AGENT_DENYLIST: Record<string, boolean> = {
|
|
|
|
|
write: false,
|
|
|
|
|
edit: false,
|
|
|
|
|
task: false,
|
|
|
|
|
call_omo_agent: false,
|
2026-01-16 17:11:34 +09:00
|
|
|
}
|
|
|
|
|
|
2026-01-16 18:29:39 +09:00
|
|
|
const AGENT_RESTRICTIONS: Record<string, Record<string, boolean>> = {
|
2026-01-16 17:11:34 +09:00
|
|
|
explore: EXPLORATION_AGENT_DENYLIST,
|
|
|
|
|
|
|
|
|
|
librarian: EXPLORATION_AGENT_DENYLIST,
|
|
|
|
|
|
|
|
|
|
oracle: {
|
2026-01-16 18:29:39 +09:00
|
|
|
write: false,
|
|
|
|
|
edit: false,
|
|
|
|
|
task: false,
|
2026-02-04 16:00:16 +09:00
|
|
|
call_omo_agent: false,
|
2026-01-16 17:11:34 +09:00
|
|
|
},
|
|
|
|
|
|
2026-02-04 11:35:02 +09:00
|
|
|
metis: {
|
|
|
|
|
write: false,
|
|
|
|
|
edit: false,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
momus: {
|
|
|
|
|
write: false,
|
|
|
|
|
edit: false,
|
|
|
|
|
},
|
|
|
|
|
|
2026-01-16 17:11:34 +09:00
|
|
|
"multimodal-looker": {
|
2026-01-16 18:29:39 +09:00
|
|
|
read: true,
|
2026-01-16 17:11:34 +09:00
|
|
|
},
|
|
|
|
|
|
2026-01-24 03:00:01 +09:00
|
|
|
"sisyphus-junior": {
|
2026-01-16 18:29:39 +09:00
|
|
|
task: false,
|
2026-01-16 17:11:34 +09:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-10 12:54:16 +09:00
|
|
|
type AgentToolRestrictionsOptions = {
|
|
|
|
|
includeTeamToolDenylist?: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getAgentToolRestrictions(agentName: string, options: AgentToolRestrictionsOptions = {}): Record<string, boolean> {
|
2026-04-15 10:46:41 +09:00
|
|
|
const stripped = stripInvisibleAgentCharacters(agentName)
|
2026-05-09 16:30:40 +09:00
|
|
|
const agentRestrictions = AGENT_RESTRICTIONS[stripped]
|
2026-04-15 10:46:41 +09:00
|
|
|
?? Object.entries(AGENT_RESTRICTIONS).find(([key]) => key.toLowerCase() === stripped.toLowerCase())?.[1]
|
2026-01-31 15:46:14 +09:00
|
|
|
?? {}
|
2026-05-09 16:30:40 +09:00
|
|
|
|
|
|
|
|
return {
|
2026-05-10 12:54:16 +09:00
|
|
|
...(options.includeTeamToolDenylist === false ? {} : TEAM_TOOL_DENYLIST),
|
2026-05-09 16:30:40 +09:00
|
|
|
...agentRestrictions,
|
|
|
|
|
}
|
2026-01-16 17:11:34 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function hasAgentToolRestrictions(agentName: string): boolean {
|
2026-03-26 10:42:14 -04:00
|
|
|
const restrictions = getAgentToolRestrictions(agentName)
|
|
|
|
|
return Object.keys(restrictions).length > 0
|
2026-01-16 17:11:34 +09:00
|
|
|
}
|