@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
package/src/tui/banner.js CHANGED
@@ -315,7 +315,13 @@ export function providerLabel(provider) {
315
315
  openai: 'OpenAI', anthropic: 'Anthropic', gemini: 'Gemini', ollama: 'Ollama',
316
316
  deepseek: 'DeepSeek', dashscope: 'DashScope', 'dashscope-byok': 'DashScope',
317
317
  qwen: 'Qwen', xai: 'xAI', grok: 'xAI', moonshot: 'Moonshot', kimi: 'Moonshot',
318
- muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible'
318
+ muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible',
319
+ acp: 'ACP', antigravity: 'Antigravity', agy: 'Antigravity',
320
+ 'acp/opencode': 'OpenCode (ACP)', 'acp/claude': 'Claude Code (ACP)',
321
+ 'acp/codex': 'Codex (ACP)', 'acp/gemini': 'Gemini CLI (ACP)',
322
+ 'acp/cursor': 'Cursor (ACP)', 'acp/qwen': 'Qwen Code (ACP)',
323
+ 'acp/copilot': 'Copilot (ACP)', 'acp/kimi': 'Kimi (ACP)',
324
+ 'acp/goose': 'Goose (ACP)', 'acp/hermes': 'Hermes (ACP)'
319
325
  };
320
326
  return known[raw.toLowerCase()] ?? raw;
321
327
  }
package/src/tui/banner.ts CHANGED
@@ -313,7 +313,13 @@ export function providerLabel(provider: unknown): string {
313
313
  openai: 'OpenAI', anthropic: 'Anthropic', gemini: 'Gemini', ollama: 'Ollama',
314
314
  deepseek: 'DeepSeek', dashscope: 'DashScope', 'dashscope-byok': 'DashScope',
315
315
  qwen: 'Qwen', xai: 'xAI', grok: 'xAI', moonshot: 'Moonshot', kimi: 'Moonshot',
316
- muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible'
316
+ muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible',
317
+ acp: 'ACP', antigravity: 'Antigravity', agy: 'Antigravity',
318
+ 'acp/opencode': 'OpenCode (ACP)', 'acp/claude': 'Claude Code (ACP)',
319
+ 'acp/codex': 'Codex (ACP)', 'acp/gemini': 'Gemini CLI (ACP)',
320
+ 'acp/cursor': 'Cursor (ACP)', 'acp/qwen': 'Qwen Code (ACP)',
321
+ 'acp/copilot': 'Copilot (ACP)', 'acp/kimi': 'Kimi (ACP)',
322
+ 'acp/goose': 'Goose (ACP)', 'acp/hermes': 'Hermes (ACP)'
317
323
  };
318
324
  return known[raw.toLowerCase()] ?? raw;
319
325
  }
package/src/tui/home.js CHANGED
@@ -4,14 +4,17 @@ import { SelectLayer, InputLayer } from './dialogs.js';
4
4
  import { paint, dim, bold, badge, GLYPHS } from './theme.js';
5
5
  import { runSetup } from './setup.js';
6
6
  import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
7
+ import { isAcpProvider } from '../providers/acp.js';
8
+ import { isAntigravityProvider } from '../providers/antigravity.js';
7
9
 
8
10
  /** Local runtime and provider summary. */
9
- export function homeStatusLine({ config = {} } = {}) {
11
+ export function homeStatusLine(arg = {}) {
12
+ const config = arg?.config || arg || {};
10
13
  const hasProvider = Boolean(config.provider && config.provider !== 'unconfigured');
11
14
  const model = hasProvider
12
15
  ? (config.model ? `${config.provider}/${config.model}` : config.provider)
13
16
  : 'no provider configured';
14
- const configured = Boolean((hasProvider && config.apiKey) || config.provider === 'ollama');
17
+ const configured = Boolean((hasProvider && config.apiKey) || config.provider === 'ollama' || isAcpProvider(config.provider) || isAntigravityProvider(config.provider));
15
18
  return ' ' + [
16
19
  paint('success', `${GLYPHS.bullet} local desktop`),
17
20
  configured
@@ -142,7 +145,19 @@ export const PROVIDERS = [
142
145
  { id: 'moonshot', label: 'Moonshot', hint: 'Kimi' },
143
146
  { id: 'xai', label: 'xAI', hint: 'Grok' },
144
147
  { id: 'openai-compatible', label: 'OpenAI-compatible endpoint', hint: 'custom base URL' },
145
- { id: 'ollama', label: 'Ollama', hint: 'local / offline' }
148
+ { id: 'ollama', label: 'Ollama', hint: 'local / offline' },
149
+ { id: 'antigravity', label: 'Google Antigravity (AGY)', hint: 'local AGY · Gemini & Claude models' },
150
+ { id: 'acp/opencode', label: 'OpenCode', hint: 'ACP · free models available' },
151
+ { id: 'acp/claude', label: 'Claude Code', hint: 'ACP · your Anthropic subscription' },
152
+ { id: 'acp/codex', label: 'Codex CLI', hint: 'ACP · your OpenAI login' },
153
+ { id: 'acp/gemini', label: 'Gemini CLI', hint: 'ACP · free tier / Google login' },
154
+ { id: 'acp/cursor', label: 'Cursor CLI', hint: 'ACP · your Cursor subscription' },
155
+ { id: 'acp/qwen', label: 'Qwen Code', hint: 'ACP · DashScope login' },
156
+ { id: 'acp/copilot', label: 'GitHub Copilot CLI', hint: 'ACP · your Copilot subscription' },
157
+ { id: 'acp/kimi', label: 'Kimi CLI', hint: 'ACP · Moonshot login' },
158
+ { id: 'acp/goose', label: 'Goose', hint: 'ACP · your configured providers' },
159
+ { id: 'acp/hermes', label: 'Hermes Agent', hint: 'ACP · Nous Research' },
160
+ { id: 'acp', label: 'ACP peer agent (custom)', hint: 'any ACP-compatible CLI' }
146
161
  ].map((entry) => ({ ...entry, model: DEFAULT_MODEL_BY_PROVIDER[entry.id] ?? '' }));
147
162
 
148
163
  /** Run the shared setup transaction inside the existing prompt. */
package/src/tui/setup.js CHANGED
@@ -1,5 +1,12 @@
1
+ /** Shared setup transaction for the home panel and standalone CLI. */
2
+ import { resolveAvailableModels } from '../dynamicCatalogue.js';
1
3
  const string = (value) => typeof value === 'string' ? value : '';
2
4
  const customProviders = new Set(['openai-compatible', 'dashscope-byok', 'ollama']);
5
+ /** Peers and Antigravity authenticate through their own CLI, not a stored key. */
6
+ function isLocalAgent(providerId) {
7
+ return providerId === 'acp' || providerId.startsWith('acp/')
8
+ || providerId === 'antigravity' || providerId === 'agy';
9
+ }
3
10
  const defaults = {
4
11
  ollama: 'http://localhost:11434/api/chat',
5
12
  'dashscope-byok': 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions'
@@ -52,14 +59,39 @@ export async function runSetup(ui, providers, store, workspace = process.cwd())
52
59
  return null;
53
60
  baseUrl = answer;
54
61
  }
55
- const model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'], (sameProvider ? string(draft.model) : '') || provider.model, false, value => value ? null : 'A model ID is required.');
62
+ const suggestedModel = (sameProvider ? string(draft.model) : '') || provider.model;
63
+ let model;
64
+ if (isLocalAgent(provider.id)) {
65
+ // The peer already knows which models its account can reach. Listing them
66
+ // is the whole point of treating it as a provider; a blank text box would
67
+ // make the user guess ids the CLI could have told us for free.
68
+ const known = (await resolveAvailableModels(provider.id, {}, false)).models;
69
+ if (known.length === 0) {
70
+ model = await text('Setup 3/5 · model', ['Enter a model ID published by the installed CLI.',
71
+ 'Leave the default to let the peer choose its own model.'], suggestedModel, false, value => value ? null : 'A model ID is required.');
72
+ }
73
+ else {
74
+ const picked = await ui.select({ title: 'Setup 3/5 · model', items: [
75
+ ...known.map((id) => ({ id, label: id, description: provider.label })),
76
+ { id: '__custom__', label: 'Other model ID…', description: 'enter one manually' }
77
+ ] });
78
+ if (!picked)
79
+ return null;
80
+ model = picked.id === '__custom__'
81
+ ? await text('Setup 3/5 · model', ['Enter the model ID published by the installed CLI.'], suggestedModel, false, value => value ? null : 'A model ID is required.')
82
+ : picked.id;
83
+ }
84
+ }
85
+ else {
86
+ model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'], suggestedModel, false, value => value ? null : 'A model ID is required.');
87
+ }
56
88
  if (model === null)
57
89
  return null;
58
90
  const unchangedEndpoint = sameProvider && (string(draft.baseUrl) || defaults[provider.id] || '') === baseUrl;
59
91
  // Fixed endpoints have no editable URL. A changed endpoint never inherits a key.
60
92
  const keepKey = sameProvider && (!customProviders.has(provider.id) || unchangedEndpoint);
61
93
  let apiKey = '';
62
- if (provider.id !== 'ollama') {
94
+ if (provider.id !== 'ollama' && !isLocalAgent(provider.id)) {
63
95
  const oldKey = keepKey ? string(draft.apiKey) : '';
64
96
  const answer = await text('Setup 3/5 · credentials', ['Stored encrypted locally; used to authenticate with your selected provider.',
65
97
  oldKey ? 'Blank keeps the key for this same provider and endpoint.' : 'Enter a key for this provider.',
package/src/tui/setup.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  /** Shared setup transaction for the home panel and standalone CLI. */
2
+ import { resolveAvailableModels } from '../dynamicCatalogue.js';
3
+
2
4
  export interface SetupChoice { id: string; label: string; description?: string }
3
5
  export interface SetupProvider { id: string; label: string; hint: string; model: string }
4
6
  export interface SetupUI {
@@ -8,6 +10,12 @@ export interface SetupUI {
8
10
  type Config = Record<string, unknown>;
9
11
  const string = (value: unknown): string => typeof value === 'string' ? value : '';
10
12
  const customProviders = new Set(['openai-compatible', 'dashscope-byok', 'ollama']);
13
+
14
+ /** Peers and Antigravity authenticate through their own CLI, not a stored key. */
15
+ function isLocalAgent(providerId: string): boolean {
16
+ return providerId === 'acp' || providerId.startsWith('acp/')
17
+ || providerId === 'antigravity' || providerId === 'agy';
18
+ }
11
19
  const defaults: Record<string, string> = {
12
20
  ollama: 'http://localhost:11434/api/chat',
13
21
  'dashscope-byok': 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions'
@@ -56,14 +64,39 @@ export async function runSetup(ui: SetupUI, providers: SetupProvider[], store: {
56
64
  if (answer === null) return null;
57
65
  baseUrl = answer;
58
66
  }
59
- const model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'],
60
- (sameProvider ? string(draft.model) : '') || provider.model, false, value => value ? null : 'A model ID is required.');
67
+ const suggestedModel = (sameProvider ? string(draft.model) : '') || provider.model;
68
+ let model: string | null;
69
+ if (isLocalAgent(provider.id)) {
70
+ // The peer already knows which models its account can reach. Listing them
71
+ // is the whole point of treating it as a provider; a blank text box would
72
+ // make the user guess ids the CLI could have told us for free.
73
+ const known = (await resolveAvailableModels(provider.id, {}, false)).models;
74
+ if (known.length === 0) {
75
+ model = await text('Setup 3/5 · model',
76
+ ['Enter a model ID published by the installed CLI.',
77
+ 'Leave the default to let the peer choose its own model.'],
78
+ suggestedModel, false, value => value ? null : 'A model ID is required.');
79
+ } else {
80
+ const picked = await ui.select({ title: 'Setup 3/5 · model', items: [
81
+ ...known.map((id) => ({ id, label: id, description: provider.label })),
82
+ { id: '__custom__', label: 'Other model ID…', description: 'enter one manually' }
83
+ ] });
84
+ if (!picked) return null;
85
+ model = picked.id === '__custom__'
86
+ ? await text('Setup 3/5 · model', ['Enter the model ID published by the installed CLI.'], suggestedModel, false,
87
+ value => value ? null : 'A model ID is required.')
88
+ : picked.id;
89
+ }
90
+ } else {
91
+ model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'],
92
+ suggestedModel, false, value => value ? null : 'A model ID is required.');
93
+ }
61
94
  if (model === null) return null;
62
95
  const unchangedEndpoint = sameProvider && (string(draft.baseUrl) || defaults[provider.id] || '') === baseUrl;
63
96
  // Fixed endpoints have no editable URL. A changed endpoint never inherits a key.
64
97
  const keepKey = sameProvider && (!customProviders.has(provider.id) || unchangedEndpoint);
65
98
  let apiKey = '';
66
- if (provider.id !== 'ollama') {
99
+ if (provider.id !== 'ollama' && !isLocalAgent(provider.id)) {
67
100
  const oldKey = keepKey ? string(draft.apiKey) : '';
68
101
  const answer = await text('Setup 3/5 · credentials', ['Stored encrypted locally; used to authenticate with your selected provider.',
69
102
  oldKey ? 'Blank keeps the key for this same provider and endpoint.' : 'Enter a key for this provider.',