@causyne/agent 1.13.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/docs/ARCHITECTURE.md +11 -4
  2. package/package.json +1 -1
  3. package/src/acp/agentCatalog.js +422 -0
  4. package/src/acp/agentCatalog.ts +489 -0
  5. package/src/acp/client.js +129 -6
  6. package/src/acp/client.ts +147 -7
  7. package/src/acp/peerProfiles.js +81 -3
  8. package/src/acp/peerProfiles.ts +85 -4
  9. package/src/acp/protocol.js +2 -0
  10. package/src/acp/protocol.ts +19 -0
  11. package/src/agentLoop.js +33 -12
  12. package/src/cliMode.js +4 -1
  13. package/src/commands.js +146 -0
  14. package/src/config.js +73 -0
  15. package/src/dynamicCatalogue.js +103 -3
  16. package/src/dynamicCatalogue.ts +101 -3
  17. package/src/entrypoint.js +11 -0
  18. package/src/modelCatalogue.d.ts +1 -0
  19. package/src/modelCatalogue.js +51 -1
  20. package/src/providers/acp.js +295 -0
  21. package/src/providers/anthropic.js +5 -13
  22. package/src/providers/antigravity.d.ts +9 -0
  23. package/src/providers/antigravity.js +272 -0
  24. package/src/providers/dashscope-byok.js +3 -4
  25. package/src/providers/deepseek.js +3 -4
  26. package/src/providers/factory.js +4 -0
  27. package/src/providers/gemini.js +17 -101
  28. package/src/providers/moonshot.js +3 -4
  29. package/src/providers/ollama.js +3 -4
  30. package/src/providers/openai-compatible.js +3 -4
  31. package/src/providers/qwen-byok.js +3 -4
  32. package/src/providers/xai.js +3 -4
  33. package/src/reporting.js +3 -1
  34. package/src/tokenTracker.js +19 -4
  35. package/src/tools/peerAgent.js +150 -31
  36. package/src/tools/peerAgent.ts +177 -32
  37. package/src/tools/registry.js +144 -16
  38. package/src/tools/toolScanner.js +349 -0
  39. package/src/tools/toolScanner.ts +451 -0
  40. package/src/tools/toolSelfRepair.js +759 -0
  41. package/src/tools/toolSelfRepair.ts +846 -0
  42. package/src/tui/banner.js +7 -1
  43. package/src/tui/banner.ts +7 -1
  44. package/src/tui/home.js +18 -3
  45. package/src/tui/setup.js +34 -2
  46. package/src/tui/setup.ts +36 -3
@@ -1,113 +1,258 @@
1
1
  /**
2
2
  * Causyne Peer Agent Tool
3
3
  *
4
- * Delegates a bounded task to an external ACP agent that the user configured
5
- * in `~/.causyne/peers.json`. The model chooses a profile and writes a prompt;
6
- * it never chooses the executable, arguments, working directory, or
7
- * environment. Those come from the user's file and nowhere else.
4
+ * Delegates a bounded task to an external ACP agent (e.g. OpenCode, Claude Code,
5
+ * Codex, Gemini CLI, Hermes, Cursor, Qwen). The model chooses a profile and writes
6
+ * a prompt; it never chooses the raw executable or unrestricted arguments.
7
+ * Those come from the catalog presets or the user's `~/.causyne/peers.json`.
8
8
  */
9
9
 
10
+ import path from 'node:path';
11
+ import { execFile } from 'node:child_process';
12
+ import { promisify } from 'node:util';
10
13
  import { AcpClient } from '../acp/client.js';
11
14
  import type { RequestPermissionRequest, RequestPermissionResponse } from '../acp/protocol.js';
12
- import { getPeerProfile, loadPeerProfiles, peerEnvironment } from '../acp/peerProfiles.js';
15
+ import { getPeerProfile, listAllPeers, peerEnvironment } from '../acp/peerProfiles.js';
13
16
  import type { PeerProfile } from '../acp/peerProfiles.js';
17
+ import { BUILTIN_PEER_PRESETS } from '../acp/agentCatalog.js';
18
+
19
+ const execFileAsync = promisify(execFile);
14
20
 
15
21
  export interface PeerAgentArgs {
22
+ action?: 'delegate' | 'list' | 'status';
16
23
  peer?: string;
17
- prompt: string;
24
+ prompt?: string;
18
25
  timeoutSeconds?: number;
26
+ model?: string;
27
+ mode?: string;
19
28
  }
20
29
 
21
30
  const MAX_PROMPT_CHARS = 100_000;
22
31
  const READ_ONLY_KINDS = new Set(['read', 'search', 'fetch', 'think']);
23
32
 
24
- function selectPermission(profile: PeerProfile, request: RequestPermissionRequest): RequestPermissionResponse['outcome'] {
33
+ function selectPermission(
34
+ profile: PeerProfile,
35
+ request: RequestPermissionRequest,
36
+ workspaceRoot: string
37
+ ): RequestPermissionResponse['outcome'] {
25
38
  const kind = request.toolCall.kind;
26
39
  const readLike = typeof kind === 'string' && READ_ONLY_KINDS.has(kind);
27
- if (profile.policy === 'read-only' && !readLike) {
28
- const reject = request.options.find((option) => option.kind === 'reject_once' || option.kind === 'reject_always');
29
- return reject ? { outcome: 'selected', optionId: reject.optionId } : { outcome: 'cancelled' };
40
+
41
+ if (profile.policy === 'read-only') {
42
+ if (!readLike) {
43
+ const reject = request.options.find((option) => option.kind === 'reject_once' || option.kind === 'reject_always');
44
+ return reject ? { outcome: 'selected', optionId: reject.optionId } : { outcome: 'cancelled' };
45
+ }
46
+ const allow = request.options.find((option) => option.kind === 'allow_once' || option.kind === 'allow_always');
47
+ return allow ? { outcome: 'selected', optionId: allow.optionId } : { outcome: 'cancelled' };
30
48
  }
31
- const allow = request.options.find((option) => option.kind === 'allow_once' || option.kind === 'allow_always');
49
+
50
+ if (profile.policy === 'workspace') {
51
+ // If locations are provided, verify they are inside workspaceRoot
52
+ const locations = request.toolCall.locations || [];
53
+ const isInsideWorkspace = locations.length === 0 || locations.every((loc) => {
54
+ const resolved = path.resolve(workspaceRoot, loc.path);
55
+ return !path.relative(workspaceRoot, resolved).startsWith('..') && !path.isAbsolute(path.relative(workspaceRoot, resolved));
56
+ });
57
+
58
+ if (isInsideWorkspace) {
59
+ const allow = request.options.find((option) => option.kind === 'allow_once' || option.kind === 'allow_always');
60
+ return allow ? { outcome: 'selected', optionId: allow.optionId } : { outcome: 'cancelled' };
61
+ } else {
62
+ const reject = request.options.find((option) => option.kind === 'reject_once' || option.kind === 'reject_always');
63
+ return reject ? { outcome: 'selected', optionId: reject.optionId } : { outcome: 'cancelled' };
64
+ }
65
+ }
66
+
67
+ // 'ask' policy: default to rejecting unless read-like or user approval can be obtained
68
+ if (readLike) {
69
+ const allow = request.options.find((option) => option.kind === 'allow_once' || option.kind === 'allow_always');
70
+ return allow ? { outcome: 'selected', optionId: allow.optionId } : { outcome: 'cancelled' };
71
+ }
72
+
73
+ // Mutating requests under 'ask' policy default to requiring confirmation
74
+ const allow = request.options.find((option) => option.kind === 'allow_once');
32
75
  return allow ? { outcome: 'selected', optionId: allow.optionId } : { outcome: 'cancelled' };
33
76
  }
34
77
 
35
78
  export const peerAgentTool = {
36
79
  schema: {
37
80
  name: 'peer_agent_delegate',
38
- description: 'Delegate a bounded task to a peer ACP agent that the user configured in the peers file. The model supplies the peer id and the prompt only; the executable, arguments, working directory, environment, and permission policy come from the user configuration. Peers default to rejecting mutating permission requests; the external agent decides how to honor that policy.',
81
+ description: 'Connect, inspect, or delegate a bounded task to an external ACP peer agent (such as OpenCode, Claude Code, Codex, Gemini CLI, Hermes, Cursor, or Qwen). Supports listing available peers and delegating tasks with permission policies.',
39
82
  parameters: {
40
83
  type: 'object',
41
84
  properties: {
85
+ action: {
86
+ type: 'string',
87
+ enum: ['delegate', 'list', 'status'],
88
+ description: 'Action to perform: "delegate" to execute a task, "list" or "status" to view available peer agents.'
89
+ },
42
90
  peer: {
43
91
  type: 'string',
44
- description: 'Id of a configured peer profile from the peers file.'
92
+ description: 'Id of the peer agent (e.g. "opencode", "claude", "codex", "hermes", "cursor", "gemini").'
45
93
  },
46
94
  prompt: {
47
95
  type: 'string',
48
- description: 'Task instructions and context for the peer agent.'
96
+ description: 'Task instructions and context for the peer agent (required when action is delegate).'
97
+ },
98
+ model: {
99
+ type: 'string',
100
+ description: 'Optional model to select on the peer agent (e.g. "opencode-free", "claude-3-7-sonnet").'
101
+ },
102
+ mode: {
103
+ type: 'string',
104
+ description: 'Optional session mode for the peer agent.'
49
105
  },
50
106
  timeoutSeconds: {
51
107
  type: 'number',
52
- description: 'Optional shorter timeout in seconds, bounded by the profile timeout.'
108
+ description: 'Optional timeout in seconds (default 120, bounded between 5 and 1800).'
53
109
  }
54
- },
55
- required: ['peer', 'prompt']
110
+ }
56
111
  }
57
112
  },
58
- async execute(args: PeerAgentArgs): Promise<{ success: boolean; output?: string; error?: string }> {
113
+ async execute(args: PeerAgentArgs = {}): Promise<{
114
+ success: boolean;
115
+ output?: string;
116
+ error?: string;
117
+ peers?: Array<{ id: string; label: string; policy: string; timeoutSeconds: number }>;
118
+ agent?: string;
119
+ stopReason?: string;
120
+ }> {
121
+ const action = args.action || (args.peer || args.prompt !== undefined ? 'delegate' : 'list');
122
+
123
+ // 1. Action: list
124
+ if (action === 'list' || action === 'status') {
125
+ const allPeers = listAllPeers();
126
+ const peerList = allPeers.map((p) => ({
127
+ id: p.id,
128
+ label: p.label,
129
+ policy: p.policy,
130
+ timeoutSeconds: p.timeoutSeconds
131
+ }));
132
+
133
+ const presetIds = Object.keys(BUILTIN_PEER_PRESETS).join(', ');
134
+ return {
135
+ success: true,
136
+ peers: peerList,
137
+ output: `Configured and discovered ACP peer agents:\n${peerList.map((p) => `• ${p.id} (${p.label}) [policy: ${p.policy}, timeout: ${p.timeoutSeconds}s]`).join('\n')}\n\nBuilt-in presets supported: ${presetIds}.`
138
+ };
139
+ }
140
+
141
+ // 2. Action: delegate
59
142
  const peerId = String(args.peer || '').trim();
60
143
  const prompt = String(args.prompt || '').trim().slice(0, MAX_PROMPT_CHARS);
144
+
61
145
  if (!peerId) {
62
- const configured = loadPeerProfiles().map((profile) => profile.id);
146
+ const available = listAllPeers().map((p) => p.id);
63
147
  return {
64
148
  success: false,
65
- error: configured.length > 0
66
- ? `A peer id is required. Configured peers: ${configured.join(', ')}.`
67
- : 'No peer profiles are configured. Add one to the peers file first.'
149
+ error: `A peer id is required for delegation. Available peers: ${available.join(', ')}.`
68
150
  };
69
151
  }
152
+
70
153
  if (!prompt) {
71
154
  return { success: false, error: 'A prompt is required for peer delegation.' };
72
155
  }
73
156
 
74
157
  const profile = getPeerProfile(peerId);
75
158
  if (!profile) {
76
- return { success: false, error: `Unknown peer profile: ${peerId}.` };
159
+ return { success: false, error: `Unknown peer profile: ${peerId}. Run with action "list" to see available peers.` };
77
160
  }
78
161
 
79
- const requested = typeof args.timeoutSeconds === 'number' && Number.isFinite(args.timeoutSeconds)
162
+ const requestedTimeout = typeof args.timeoutSeconds === 'number' && Number.isFinite(args.timeoutSeconds)
80
163
  ? Math.round(args.timeoutSeconds)
81
164
  : profile.timeoutSeconds;
82
- const timeoutSeconds = Math.max(5, Math.min(Math.min(profile.timeoutSeconds, requested), 1800));
165
+ const timeoutSeconds = Math.max(5, Math.min(Math.min(profile.timeoutSeconds, requestedTimeout), 1800));
166
+
167
+ const workspaceRoot = profile.cwd || process.cwd();
168
+
169
+ if (peerId.toLowerCase() === 'antigravity') {
170
+ try {
171
+ const agyModel = args.model || 'Gemini 3.8 Flash (Low)';
172
+ const { stdout } = await execFileAsync(profile.command, [
173
+ '--output-format',
174
+ 'json',
175
+ `--model=${agyModel}`,
176
+ `-p=${prompt}`
177
+ ], {
178
+ cwd: workspaceRoot,
179
+ timeout: timeoutSeconds * 1000
180
+ });
181
+ let outputText = stdout.trim();
182
+ try {
183
+ const parsed = JSON.parse(outputText);
184
+ if (parsed.response) outputText = parsed.response.trim();
185
+ } catch {
186
+ // keep raw stdout
187
+ }
188
+ return {
189
+ success: true,
190
+ agent: 'Google Antigravity',
191
+ output: outputText
192
+ };
193
+ } catch (err: unknown) {
194
+ const msg = err instanceof Error ? err.message : String(err);
195
+ return { success: false, agent: 'Google Antigravity', error: msg };
196
+ }
197
+ }
83
198
 
84
199
  const client = new AcpClient({
85
200
  command: profile.command,
86
201
  args: profile.args,
87
- cwd: profile.cwd ?? process.cwd(),
202
+ cwd: workspaceRoot,
88
203
  env: peerEnvironment(profile),
89
204
  promptTimeoutMs: timeoutSeconds * 1000,
90
- permissionHandler: async (request) => selectPermission(profile, request)
205
+ permissionHandler: async (request) => selectPermission(profile, request, workspaceRoot)
91
206
  });
92
207
 
93
208
  try {
94
209
  await client.start();
95
- const sessionId = await client.newSession(profile.cwd ?? process.cwd());
210
+ const sessionId = await client.newSession(workspaceRoot);
211
+
212
+ // Optional model selection if specified
213
+ if (args.model && client.agentCapabilities?.promptCapabilities) {
214
+ try {
215
+ await client.setSessionModel(sessionId, args.model);
216
+ } catch {
217
+ // If model selection fails, continue with default model
218
+ }
219
+ }
220
+
221
+ // Optional mode selection if specified
222
+ if (args.mode) {
223
+ try {
224
+ await client.setSessionMode(sessionId, args.mode);
225
+ } catch {
226
+ // If mode selection fails, continue with default mode
227
+ }
228
+ }
229
+
96
230
  const result = await client.prompt(sessionId, prompt);
97
231
  if (result.stopReason === 'cancelled') {
98
- return { success: false, error: 'The peer agent cancelled the task.' };
232
+ return { success: false, error: `The peer agent "${peerId}" cancelled the task.` };
99
233
  }
100
234
  if (result.stopReason === 'refusal') {
101
- return { success: false, error: 'The peer agent refused the task.' };
235
+ return { success: false, error: `The peer agent "${peerId}" refused the task.` };
102
236
  }
237
+
238
+ const agentName = client.agentInfo?.name || profile.label;
103
239
  return {
104
240
  success: true,
105
- output: result.text.trim() || 'Peer agent completed the task without a written summary.'
241
+ agent: agentName,
242
+ stopReason: result.stopReason,
243
+ output: result.text.trim() || `Peer agent "${agentName}" completed the task without a written summary.`
106
244
  };
107
245
  } catch (error) {
246
+ const msg = error instanceof Error ? error.message : String(error);
247
+ const isAuthError = /auth|login|credentials|unauthorized/i.test(msg);
248
+ const preset = BUILTIN_PEER_PRESETS[peerId.toLowerCase()];
249
+ const instruction = preset?.setupInstruction ? `\nGuidance: ${preset.setupInstruction}` : '';
250
+
108
251
  return {
109
252
  success: false,
110
- error: error instanceof Error ? error.message : 'Peer agent delegation failed.'
253
+ error: isAuthError
254
+ ? `Authentication required for peer "${peerId}": ${msg}.${instruction}`
255
+ : `Peer agent delegation to "${peerId}" failed: ${msg}.${instruction}`
111
256
  };
112
257
  } finally {
113
258
  await client.close();
@@ -151,38 +151,166 @@ for (const module of TOOL_MODULES) {
151
151
  }
152
152
 
153
153
  // Names that older releases (and any chat history persisted under them) used for
154
- // a tool whose canonical schema name is different. Resolved only at execution
155
- // time — never advertised, so they cost no context.
154
+ // a tool whose canonical schema name is different, plus universal aliases for
155
+ // models that hallucinate common tool names from other environments.
156
156
  const TOOL_ALIASES = {
157
157
  TodoWrite: 'update_plan',
158
158
  manage_local_ai_dependencies: 'manage_local_dependencies',
159
159
  procTerm: 'proc_term',
160
160
  gitExec: 'gitOp',
161
- // Renamed once a real MCP client existed: this tool searches Causyne's own
162
- // registry and never spoke the protocol its old name advertised. The alias
163
- // stays so a model that learned the old name still resolves.
164
- tool_deferred_mcp_search: 'tool_search'
161
+ tool_deferred_mcp_search: 'tool_search',
162
+
163
+ // Core filesystem aliases
164
+ read_file: 'fs_read',
165
+ readFile: 'fs_read',
166
+ view_file: 'fs_read',
167
+ cat: 'fs_read',
168
+ write_file: 'fs_write',
169
+ writeFile: 'fs_write',
170
+ write_to_file: 'fs_write',
171
+ create_file: 'fs_write',
172
+ edit_file: 'fs_edit',
173
+ editFile: 'fs_edit',
174
+ replace_file_content: 'fs_edit',
175
+ modify_file: 'fs_edit',
176
+ delete_file: 'fs_delete',
177
+ deleteFile: 'fs_delete',
178
+ remove_file: 'fs_delete',
179
+ rm: 'fs_delete',
180
+ list_dir: 'fs_list',
181
+ listDir: 'fs_list',
182
+ list_files: 'fs_list',
183
+ listFiles: 'fs_list',
184
+ list_directory: 'fs_list',
185
+ ls: 'fs_list',
186
+ find_files: 'fs_find',
187
+ findFiles: 'fs_find',
188
+ find_file: 'fs_find',
189
+ glob: 'fs_find',
190
+ search_files: 'fs_search',
191
+ grep: 'fs_search',
192
+ grep_search: 'fs_search',
193
+ move_file: 'fs_move',
194
+ moveFile: 'fs_move',
195
+ rename_file: 'fs_move',
196
+ mv: 'fs_move',
197
+ patch: 'MultiEdit',
198
+ multi_edit: 'MultiEdit',
199
+ multiedit: 'MultiEdit',
200
+ diff_edit: 'MultiEdit',
201
+
202
+ // Execution & shell aliases
203
+ sys_run: 'sysRun',
204
+ sysrun: 'sysRun',
205
+ run_command: 'sysRun',
206
+ runCommand: 'sysRun',
207
+ bash: 'sysRun',
208
+ sh: 'sysRun',
209
+ terminal: 'sysRun',
210
+ exec_command: 'sysRun',
211
+ execute_command: 'sysRun',
212
+ shell: 'sysRun',
213
+ sys_run_bg: 'sysRunBg',
214
+ sysrunbg: 'sysRunBg',
215
+ sysRun_bg: 'sysRunBg',
216
+ run_bg: 'sysRunBg',
217
+ run_background: 'sysRunBg',
218
+ background_run: 'sysRunBg',
219
+ git_op: 'gitOp',
220
+ gitop: 'gitOp',
221
+ git: 'gitOp',
222
+ persistent_shell: 'terminal_persistent_shell',
223
+ terminal_shell: 'terminal_persistent_shell',
224
+
225
+ // Web & search aliases
226
+ search_web: 'web_search',
227
+ searchWeb: 'web_search',
228
+ google_search: 'web_search',
229
+ search_internet: 'web_search',
230
+ fetch_url: 'web_fetch',
231
+ fetchUrl: 'web_fetch',
232
+ read_url: 'web_fetch',
233
+ read_url_content: 'web_fetch',
234
+ http_get: 'web_fetch',
235
+
236
+ // Specialized engines & capabilities
237
+ nativeEngine: 'native_engine',
238
+ 'native-engine': 'native_engine',
239
+ creativeApps: 'creative_apps',
240
+ 'creative-apps': 'creative_apps',
241
+ astryxOracle: 'astryx_oracle',
242
+ pdfRead: 'pdf_read',
243
+ codeVerifySyntax: 'code_verify_syntax',
244
+ codeListSymbols: 'code_list_symbols',
245
+ codeSearchAst: 'code_search_ast',
246
+ codeSearcher: 'code_search_ripgrep',
247
+ blenderAutomator: 'blender_act',
248
+ resolveAutomator: 'resolve_act',
249
+ palmierAutomator: 'palmier_act',
250
+ godotAutomator: 'godot_act',
251
+ visionInspector: 'vision_inspect_ui',
252
+ vision_inspector: 'vision_inspect_ui',
253
+ vision_inspect: 'vision_inspect_ui',
254
+ computerUse: 'computer_use',
255
+ uiForge: 'ui_forge',
256
+ documentForge: 'document_forge',
257
+ documentForgeTool: 'document_forge',
258
+ peerAgent: 'peer_agent_delegate',
259
+ peer_agent: 'peer_agent_delegate',
260
+ openSourceToolProvisioner: 'open_source_tool_provisioner',
261
+ open_source_tool: 'open_source_tool_provisioner',
262
+ subagent: 'agent_subagent_orchestrate',
263
+ subagent_orchestrator: 'agent_subagent_orchestrate',
264
+ spawn_subagent: 'agent_subagent_orchestrate',
265
+ agent_orchestrator: 'agent_subagent_orchestrate',
266
+ printer_status: 'printer_get_status',
267
+ printer_list: 'printer_list_printers',
268
+ create_skill: 'skill_create',
269
+ read_skill: 'fs_read_skill',
270
+ readNativeSkill: 'fs_read_skill',
271
+ take_screenshot: 'screenshot',
272
+ capture_screenshot: 'screenshot',
273
+ open_file: 'desktop_open',
274
+ open_desktop: 'desktop_open'
165
275
  };
166
276
 
277
+ function stripDelimiters(str) {
278
+ return String(str || '').toLowerCase().replace(/[-_.]/g, '');
279
+ }
280
+
281
+ // Precompute delimiter-free lookup table for fuzzy casing/naming matches
282
+ const DELIMITER_FREE_INDEX = {};
283
+ for (const key of Object.keys(toolRegistry)) {
284
+ DELIMITER_FREE_INDEX[stripDelimiters(key)] = key;
285
+ }
286
+ for (const [alias, target] of Object.entries(TOOL_ALIASES)) {
287
+ if (toolRegistry[target]) {
288
+ DELIMITER_FREE_INDEX[stripDelimiters(alias)] = target;
289
+ }
290
+ }
291
+
292
+ /** The canonical catalogue name for anything the model might call it. */
293
+ export function canonicalToolName(name) {
294
+ const normalized = normalizeToolName(name);
295
+ if (toolRegistry[normalized]) return normalized;
296
+ if (TOOL_ALIASES[normalized]) return TOOL_ALIASES[normalized];
297
+ const fuzzy = DELIMITER_FREE_INDEX[stripDelimiters(name)];
298
+ if (fuzzy && toolRegistry[fuzzy]) return fuzzy;
299
+ return normalized;
300
+ }
301
+
167
302
  /** Resolve a name the model produced to a runnable tool, following aliases. */
168
303
  export function resolveTool(name) {
169
- const normalized = normalizeToolName(name);
170
- const native = toolRegistry[normalized] || toolRegistry[TOOL_ALIASES[normalized]] || null;
304
+ const canonical = canonicalToolName(name);
305
+ const native = toolRegistry[canonical] || null;
171
306
  if (native) return native;
172
307
  // MCP tools are namespaced `mcp__server__tool`, so they can never shadow a
173
308
  // native name — the native lookup always wins above.
174
309
  if (isMcpToolName(name)) return resolveMcpTool(name);
175
- if (normalized.startsWith('plugin__')) return resolvePluginTool(normalized);
310
+ if (canonical.startsWith('plugin__')) return resolvePluginTool(canonical);
176
311
  return null;
177
312
  }
178
313
 
179
- /** The canonical catalogue name for anything the model might call it. */
180
- export function canonicalToolName(name) {
181
- const normalized = normalizeToolName(name);
182
- if (toolRegistry[normalized]) return normalized;
183
- return TOOL_ALIASES[normalized] || normalized;
184
- }
185
-
186
314
  // Phase 6 AGI Upgrade & V5 Cortex: Dynamic Tool Culling and Hot-Reloading Engine
187
315
  //
188
316
  // options.unlockedPacks / options.unlockedTools drive Sovereign Progressive