28 lines
692 B
TypeScript
28 lines
692 B
TypeScript
import type { AgentDefinition } from "./types";
|
|
|
|
// Built-in tools whose approval tier is "read" (see tool classes' `approval`).
|
|
// An agent is read-only iff its declared tools are a non-empty subset of this set.
|
|
// Fail-safe: any unknown tool makes the agent not read-only.
|
|
export const READ_ONLY_TOOL_NAMES: ReadonlySet<string> = new Set([
|
|
"read",
|
|
"grep",
|
|
"glob",
|
|
"web_search",
|
|
"ast_grep",
|
|
"yield",
|
|
"hub",
|
|
"ask",
|
|
"todo",
|
|
"recall",
|
|
"reflect",
|
|
"retain",
|
|
"memory_edit",
|
|
"inspect_image",
|
|
"checkpoint",
|
|
"rewind",
|
|
]);
|
|
|
|
export function isReadOnlyAgent(agent: AgentDefinition): boolean {
|
|
return !!agent.tools?.length && agent.tools.every(tool => READ_ONLY_TOOL_NAMES.has(tool));
|
|
}
|