UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

59 lines (58 loc) • 3.19 kB
import { carriesNamespaceSeparator, protocolOf } from "./protocol-table.js"; export const RETIRED_TOOL_NAMES = new Map([ ["read_file", 'renamed "Read"'], ["edit_file", 'renamed "Edit"'], ["write_file", 'renamed "Write"'], ["bash", 'renamed "Bash"'], ["bash_readonly", 'folded into "Bash" (read-only posture rides handsReadOnly/shellGate, not a tool name)'], ["glob", 'renamed "Glob"'], ["grep", 'renamed "Grep"'], ["web_fetch", 'renamed "WebFetch"'], ["tool_search", 'renamed "ToolSearch"'], ["skill", 'renamed "Skill"'], ["present_plan", 'renamed "ExitPlanMode"'], ["enter_plan_mode", 'renamed "EnterPlanMode"'], ["spawn_subagent", 'renamed "Agent"'], ["CronCancel", 'renamed "CronDelete"'], ["lsp", 'renamed "LSP"'], ["submit_output", 'renamed "StructuredOutput"'], ["repo_map", 'renamed "RepoMap"'], ["read_tool_result", 'renamed "ReadToolResult"'], ["report_blocked", 'renamed "ReportBlocked"'], ["declare_done", 'renamed "DeclareDone"'], ["run_workflow", 'renamed "Workflow"'], ["RunWorkflow", 'renamed "Workflow"'], ["Task", 'renamed "Agent" (a deployment-defined tool named "Task" is fine — this fires only when the name matches nothing in the roster)'], ["BashOutput", 'renamed "TaskOutput"'], ["AgentOutputTool", 'renamed "TaskOutput"'], ["BashOutputTool", 'renamed "TaskOutput"'], ["AgentOutput", 'renamed "TaskOutput"'], ["WorkflowStatus", 'folded into "TaskOutput" (poll by runId)'], ["KillShell", 'renamed "TaskStop"'], ["KillBash", 'renamed "TaskStop"'], ["ListMcpResources", 'renamed "ListMcpResourcesTool"'], ["ReadMcpResource", 'renamed "ReadMcpResourceTool"'], ["ReadMcpResourceDir", 'renamed "ReadMcpResourceDirTool"'], ["MultiEdit", 'removed — "Edit" accepts the edits[] shape'], ["Fork", 'removed — use Agent with subagent_type: "fork"'], ["Sleep", "removed — schedule a re-wake with CronCreate({schedule:{kind:\"delay\"}}) or wait with Monitor"], ["Remember", "removed — memory is file-based; write the memory directory with the ordinary file tools"], ["remember", "removed — memory is file-based; write the memory directory with the ordinary file tools"], ["Recall", "removed — memory is file-based; read the memory directory with the ordinary file tools"], ["recall", "removed — memory is file-based; read the memory directory with the ordinary file tools"], ]); export const RULE_TOOL_NAME_VERDICTS = Object.freeze(["current", "retired", "unprefixed_namespace"]); const CURRENT = Object.freeze({ kind: "current" }); const UNPREFIXED = Object.freeze({ kind: "unprefixed_namespace" }); export function judgeRuleToolName(name, roster) { if (roster.has(name)) return CURRENT; const guidance = RETIRED_TOOL_NAMES.get(name); if (guidance !== undefined) { const currentName = /^renamed "([^"]+)"/.exec(guidance)?.[1]; return currentName !== undefined ? { kind: "retired", guidance, currentName } : { kind: "retired", guidance }; } if (carriesNamespaceSeparator(name) && protocolOf(name) === undefined) return UNPREFIXED; return CURRENT; }