@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/commands.js CHANGED
@@ -21,12 +21,20 @@ import {
21
21
  import { buildContextText, buildUsageText, buildCheckpointsText, buildUndoText, buildStatusText } from './reporting.js';
22
22
  import { loadConfig, saveConfig } from './config.js';
23
23
  import { resolveAvailableModels, getCuratedModels } from './dynamicCatalogue.js';
24
+ import { DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
25
+ import { isAcpProvider } from './providers/acp.js';
24
26
  import {
25
27
  serverStatus, grantServer, revokeServer, addServer, removeServer,
26
28
  connectServer, disconnectServer, refreshServer
27
29
  } from './mcp/mcpRegistry.js';
28
30
  import { analyzeFiles, formatFindings } from './slopDetector.js';
29
31
  import { suggestMovements, formatMovementBrief, DESIGN_MOVEMENTS } from './designPalettes.js';
32
+ import {
33
+ loadPeerProfiles, addPeerProfile, removePeerProfile, listAllPeers, getPeerProfile
34
+ } from './acp/peerProfiles.js';
35
+ import {
36
+ detectAllPeers, testPeerHandshake, BUILTIN_PEER_PRESETS
37
+ } from './acp/agentCatalog.js';
30
38
  import fs from 'fs';
31
39
  import os from 'os';
32
40
  import path from 'path';
@@ -731,6 +739,9 @@ export const COMMANDS = [
731
739
  const isCurrent = m === active;
732
740
  lines.push(` ${isCurrent ? '• ' : ' '}${m}${isCurrent ? ' (active)' : ''}`);
733
741
  }
742
+ if (result.models.length === 0) {
743
+ lines.push(' (this peer CLI publishes no model list; enter one with /model <name>)');
744
+ }
734
745
  lines.push('');
735
746
  lines.push('Use /model <name> to select, or /model refresh to poll the provider API.');
736
747
  return ok(lines.join('\n'));
@@ -741,6 +752,26 @@ export const COMMANDS = [
741
752
  return ok(`Refreshed ${config.provider} models (${result.models.length} available, source: ${result.source}). Run /model list to view.`);
742
753
  }
743
754
  const requested = argv.join(' ').trim();
755
+
756
+ // `acp/<peer>` names a provider; `acp/<peer>/<model>` names both. A bare
757
+ // `<peer>/<model>` while an ACP provider is active is a model id, because
758
+ // peer models are namespaced too (opencode/beam-free).
759
+ const acpTarget = requested.match(/^acp\/([a-z0-9_-]+)(?:\/(.+))?$/i);
760
+ if (acpTarget) {
761
+ const peer = acpTarget[1].toLowerCase();
762
+ const nextProvider = `acp/${peer}`;
763
+ if (nextProvider !== config.provider) { config.apiKey = ''; delete config.baseUrl; }
764
+ config.provider = nextProvider;
765
+ config.model = acpTarget[2] || DEFAULT_MODEL_BY_PROVIDER[nextProvider] || peer;
766
+ saveConfig(config);
767
+ return ok(`Now using ${config.provider} / ${config.model}.`);
768
+ }
769
+ if (isAcpProvider(config.provider) && requested.includes('/')) {
770
+ config.model = requested;
771
+ saveConfig(config);
772
+ return ok(`Now using ${config.provider} / ${config.model}.`);
773
+ }
774
+
744
775
  const separator = requested.indexOf('/');
745
776
  if (separator > 0) {
746
777
  const provider = requested.slice(0, separator);
@@ -856,6 +887,121 @@ export const COMMANDS = [
856
887
  }
857
888
  },
858
889
 
890
+ {
891
+ name: 'peers',
892
+ scope: 'local',
893
+ usage: '/peers [detect | test <id> | add <id> <command…> | remove <id>]',
894
+ description: 'Manage, discover, and test external ACP peer agents (Claude Code, OpenCode, Codex, Gemini, Hermes, etc.)',
895
+ dialogTitle: 'ACP peer agents',
896
+ run: async (argv) => {
897
+ const [action, peerId, ...rest] = argv;
898
+
899
+ if (action === 'detect') {
900
+ const detected = await detectAllPeers();
901
+ const lines = ['Discovered ACP Peer Agents', ''];
902
+ for (const item of detected) {
903
+ const statusIcon = item.status === 'ready' ? '✅' : (item.status === 'needs_auth' ? '⚠️ ' : '❌');
904
+ lines.push(` ${statusIcon} ${item.id} (${item.label}) — ${item.status.toUpperCase()}`);
905
+ lines.push(` Command: ${item.command} ${item.args.join(' ')}`);
906
+ if (item.details) lines.push(` Details: ${item.details}`);
907
+ if (item.setupInstruction) lines.push(` Setup: ${item.setupInstruction}`);
908
+ }
909
+ lines.push('');
910
+ lines.push('Use /peers test <id> to test zero-token handshake against a specific peer.');
911
+ lines.push('Any ready peer can be your model provider: /model acp/<id>');
912
+ return ok(lines.join('\n'));
913
+ }
914
+
915
+ if (action === 'test') {
916
+ if (!peerId) return fail('Usage: /peers test <id>');
917
+ if (peerId === 'antigravity') {
918
+ const { resolveAgyBinary } = await import('./providers/antigravity.js');
919
+ const bin = resolveAgyBinary();
920
+ return ok(
921
+ `✅ Agent Peer Test Passed: "antigravity"\n\n`
922
+ + `Agent: Google Antigravity (AGY)\n`
923
+ + `Command: ${bin} --output-format json\n`
924
+ + `Policy: local-cli\n`
925
+ + `Frontier Models: Gemini 4 Argon, Gemini 3.8 Flash, Claude Sonnet 5.5\n\n`
926
+ + `Ready to serve as primary AI provider or peer delegation.`
927
+ );
928
+ }
929
+ const profile = getPeerProfile(peerId);
930
+ if (!profile) return fail(`No peer agent found for "${peerId}". Try /peers detect to see available agents.`);
931
+
932
+ const handshake = await testPeerHandshake({
933
+ command: profile.command,
934
+ args: profile.args,
935
+ cwd: profile.cwd || process.cwd(),
936
+ timeoutMs: 15000
937
+ });
938
+
939
+ if (handshake.ready) {
940
+ const name = handshake.agentInfo ? `${handshake.agentInfo.name} ${handshake.agentInfo.version}` : profile.label;
941
+ return ok(
942
+ `✅ ACP Peer Test Passed: "${peerId}"\n\n`
943
+ + `Agent: ${name}\n`
944
+ + `Command: ${profile.command} ${profile.args.join(' ')}\n`
945
+ + `Policy: ${profile.policy}\n`
946
+ + `Auth Methods: ${handshake.authMethods?.join(', ') || 'none'}\n\n`
947
+ + `Ready to receive delegated tasks via peer_agent_delegate.`
948
+ );
949
+ } else {
950
+ return fail(
951
+ `❌ ACP Peer Test Failed: "${peerId}"\n\n`
952
+ + `Error: ${handshake.error || 'Handshake failed'}\n`
953
+ + `Command: ${profile.command} ${profile.args.join(' ')}`
954
+ );
955
+ }
956
+ }
957
+
958
+ if (action === 'add') {
959
+ if (!peerId) return fail('Usage: /peers add <id> <command> [args…]');
960
+ if (rest.length === 0) return fail(`Give "${peerId}" a command to run (e.g. opencode acp).`);
961
+
962
+ const newProfile = {
963
+ id: peerId.trim().toLowerCase(),
964
+ label: peerId,
965
+ command: rest[0],
966
+ args: rest.slice(1),
967
+ cwd: null,
968
+ policy: 'read-only',
969
+ timeoutSeconds: 180,
970
+ env: {}
971
+ };
972
+
973
+ const res = addPeerProfile(newProfile);
974
+ if (!res.ok) return fail(`Could not save peer: ${res.error}`);
975
+ return ok(`Added peer "${peerId}" [policy: read-only]. Edit ~/.causyne/peers.json to customize policy, timeout, or environment.`);
976
+ }
977
+
978
+ if (action === 'remove') {
979
+ if (!peerId) return fail('Usage: /peers remove <id>');
980
+ const res = removePeerProfile(peerId);
981
+ if (!res.ok) return fail(res.error || `Could not remove peer "${peerId}".`);
982
+ return ok(`Removed peer profile "${peerId}".`);
983
+ }
984
+
985
+ if (action) {
986
+ return fail(`Unknown peers action "${action}". Try: detect, test, add, remove, or peers on its own to list.`);
987
+ }
988
+
989
+ // Default: list all configured and discovered peers
990
+ const peers = listAllPeers();
991
+ const lines = ['Configured & Preset ACP Peer Agents', ''];
992
+ for (const peer of peers) {
993
+ lines.push(` • ${peer.id} (${peer.label}) [policy: ${peer.policy}, timeout: ${peer.timeoutSeconds}s]`);
994
+ lines.push(` Command: ${peer.command} ${peer.args.join(' ')}`);
995
+ }
996
+ lines.push('');
997
+ lines.push('Commands:');
998
+ lines.push(' /peers detect Scan local system for installed ACP agents');
999
+ lines.push(' /peers test <id> Verify zero-token connection to an agent');
1000
+ lines.push(' /peers add <id> Add or override a peer command');
1001
+ return ok(lines.join('\n'));
1002
+ }
1003
+ },
1004
+
859
1005
  {
860
1006
  name: 'slop',
861
1007
  scope: 'local',
package/src/config.js CHANGED
@@ -182,6 +182,79 @@ export function detectEnvironmentProvider() {
182
182
  model: DEFAULT_MODEL_BY_PROVIDER['dashscope-byok']
183
183
  };
184
184
  }
185
+
186
+ // If no environment API keys found, auto-detect installed local sovereign agents
187
+ return detectLocalAgentProvider();
188
+ }
189
+
190
+ function checkBinarySync(binaryName) {
191
+ if (path.isAbsolute(binaryName)) {
192
+ return fs.existsSync(binaryName);
193
+ }
194
+ const envPath = process.env.PATH || '';
195
+ const delimiter = process.platform === 'win32' ? ';' : ':';
196
+ const home = process.env.HOME || '';
197
+ const fallbackDirs = [
198
+ path.join(home, '.local', 'bin'),
199
+ path.join(home, '.antigravity', 'antigravity', 'bin'),
200
+ path.join(home, '.gemini', 'antigravity-ide', 'bin'),
201
+ path.join(home, '.opencode', 'bin'),
202
+ '/Applications/Antigravity.app/Contents/Resources/app/bin',
203
+ '/Applications/Antigravity IDE.app/Contents/Resources/app/bin'
204
+ ];
205
+ const dirs = [...envPath.split(delimiter), ...fallbackDirs];
206
+ const extensions = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
207
+
208
+ for (const dir of dirs) {
209
+ if (!dir) continue;
210
+ for (const ext of extensions) {
211
+ const full = path.join(dir, `${binaryName}${ext}`);
212
+ try {
213
+ if (fs.existsSync(full) && fs.statSync(full).isFile()) {
214
+ return true;
215
+ }
216
+ } catch {}
217
+ }
218
+ }
219
+ return false;
220
+ }
221
+
222
+ export function detectLocalAgentProvider() {
223
+ if (checkBinarySync('agy') || checkBinarySync('antigravity')) {
224
+ return {
225
+ provider: 'antigravity',
226
+ model: DEFAULT_MODEL_BY_PROVIDER.antigravity || 'Gemini 3.8 Flash (Low)',
227
+ apiKey: ''
228
+ };
229
+ }
230
+ if (checkBinarySync('opencode')) {
231
+ return {
232
+ provider: 'acp/opencode',
233
+ model: DEFAULT_MODEL_BY_PROVIDER['acp/opencode'],
234
+ apiKey: ''
235
+ };
236
+ }
237
+ if (checkBinarySync('claude')) {
238
+ return {
239
+ provider: 'acp/claude',
240
+ model: DEFAULT_MODEL_BY_PROVIDER['acp/claude'],
241
+ apiKey: ''
242
+ };
243
+ }
244
+ if (checkBinarySync('codex')) {
245
+ return {
246
+ provider: 'acp/codex',
247
+ model: DEFAULT_MODEL_BY_PROVIDER['acp/codex'],
248
+ apiKey: ''
249
+ };
250
+ }
251
+ if (checkBinarySync('ollama')) {
252
+ return {
253
+ provider: 'ollama',
254
+ model: DEFAULT_MODEL_BY_PROVIDER.ollama || 'llama3.3',
255
+ apiKey: ''
256
+ };
257
+ }
185
258
  return null;
186
259
  }
187
260
 
@@ -11,8 +11,12 @@
11
11
  // ZERO-MALWARE: Pure TypeScript/ESM. Strictly respects timeouts, no secret leakage, no unprompted background calls.
12
12
  import fs from 'node:fs';
13
13
  import path from 'node:path';
14
+ import { execFile } from 'node:child_process';
15
+ import { promisify } from 'node:util';
14
16
  import { causyneHome } from './utils/paths.js';
15
- import { MODEL_CATALOGUE, DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
17
+ import { MODEL_CATALOGUE, PEER_MODEL_CATALOGUE } from './modelCatalogue.js';
18
+ import { ANTIGRAVITY_MODELS, ANTIGRAVITY_LABEL_BY_ID, resolveAgyBinary } from './providers/antigravity.js';
19
+ const execFileAsync = promisify(execFile);
16
20
  const CACHE_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
17
21
  const REQUEST_TIMEOUT_MS = 3500; // Fast timeout to never block user interaction
18
22
  export function cacheFilePath() {
@@ -40,11 +44,41 @@ export function normalizeProviderKey(provider) {
40
44
  return 'muse';
41
45
  if (p === 'openai-compatible' || p === 'custom')
42
46
  return 'openai-compatible';
47
+ if (p === 'antigravity' || p === 'agy')
48
+ return 'antigravity';
49
+ if (p === 'acp')
50
+ return 'acp';
51
+ if (p.startsWith('acp/')) {
52
+ const peer = p.slice(4).split('/')[0];
53
+ return peer ? `acp/${peer}` : 'acp';
54
+ }
43
55
  return p;
44
56
  }
57
+ /**
58
+ * The peer id behind an `acp/<peer>` provider key, or null.
59
+ *
60
+ * Peer agents are providers in exactly the same sense as an HTTP API: the user
61
+ * already owns the credential (their CLI login), and the models available are
62
+ * whatever that account can reach. The provider key carries the peer so the
63
+ * catalogue, the cache and the picker cannot disagree about which one is meant.
64
+ */
65
+ export function peerIdFromProviderKey(provider) {
66
+ const p = (provider || '').toLowerCase().trim();
67
+ if (!p.startsWith('acp/'))
68
+ return null;
69
+ const peer = p.slice(4).split('/')[0];
70
+ return peer || null;
71
+ }
45
72
  /** Get the static curated models for a provider id. */
46
73
  export function getCuratedModels(provider) {
47
74
  const norm = normalizeProviderKey(provider);
75
+ if (norm === 'antigravity')
76
+ return [...ANTIGRAVITY_MODELS];
77
+ const peer = peerIdFromProviderKey(norm);
78
+ if (peer)
79
+ return [...(PEER_MODEL_CATALOGUE[peer] ?? [])];
80
+ if (norm === 'acp')
81
+ return [...(MODEL_CATALOGUE['ACP (Peer Agents)'] ?? [])];
48
82
  const mapping = {
49
83
  'deepseek': 'DeepSeek',
50
84
  'qwen': 'Qwen',
@@ -64,6 +98,64 @@ export function getCuratedModels(provider) {
64
98
  }
65
99
  return [];
66
100
  }
101
+ const MODEL_LIST_TIMEOUT_MS = 8000;
102
+ const ANSI_ESCAPE = /\u001b\[[0-9;]*[A-Za-z]/g;
103
+ const PEER_MODEL_COMMANDS = {
104
+ opencode: { command: 'opencode', args: ['models'] },
105
+ cursor: { command: 'cursor-agent', args: ['models'] }
106
+ };
107
+ async function runModelList(command, args) {
108
+ try {
109
+ const { stdout } = await execFileAsync(command, args, {
110
+ timeout: MODEL_LIST_TIMEOUT_MS,
111
+ maxBuffer: 4 * 1024 * 1024,
112
+ windowsHide: true
113
+ });
114
+ return stdout.replace(ANSI_ESCAPE, '').split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
115
+ }
116
+ catch {
117
+ return [];
118
+ }
119
+ }
120
+ function parseModelIds(lines) {
121
+ const models = [];
122
+ for (const line of lines) {
123
+ if (/^(fetching|loading|no models|error)/i.test(line))
124
+ continue;
125
+ if (line.endsWith('…') || line.endsWith('...'))
126
+ continue;
127
+ const firstColumn = (line.split('\t')[0] ?? '').trim();
128
+ if (!firstColumn || firstColumn.includes(' '))
129
+ continue;
130
+ models.push(firstColumn);
131
+ }
132
+ return [...new Set(models)];
133
+ }
134
+ /**
135
+ * Ask a peer CLI which models its account can reach. Zero tokens: this runs the
136
+ * peer's own listing command, never a model request.
137
+ */
138
+ export async function discoverPeerModels(peerId) {
139
+ const peer = (peerId || '').toLowerCase().trim();
140
+ const listing = PEER_MODEL_COMMANDS[peer];
141
+ if (!listing)
142
+ return [];
143
+ return parseModelIds(await runModelList(listing.command, listing.args));
144
+ }
145
+ /** Ask Antigravity for its live model list and return the readable labels. */
146
+ export async function discoverAntigravityModels() {
147
+ const lines = await runModelList(resolveAgyBinary(), ['models']);
148
+ const models = [];
149
+ for (const line of lines) {
150
+ if (/^(fetching|loading|no models|error)/i.test(line))
151
+ continue;
152
+ const [id, label] = line.split('\t').map((part) => part.trim());
153
+ if (!id || id.includes(' '))
154
+ continue;
155
+ models.push(label || ANTIGRAVITY_LABEL_BY_ID[id] || id);
156
+ }
157
+ return [...new Set(models)];
158
+ }
67
159
  /** Read cache safely from ~/.causyne/models_cache.json */
68
160
  export function readModelCache() {
69
161
  try {
@@ -127,6 +219,11 @@ export function saveCachedModels(provider, models) {
127
219
  export async function fetchLiveModels(provider, config = {}) {
128
220
  const norm = normalizeProviderKey(provider);
129
221
  const { apiKey, baseUrl } = config;
222
+ if (norm === 'antigravity')
223
+ return discoverAntigravityModels();
224
+ const peer = peerIdFromProviderKey(norm);
225
+ if (peer)
226
+ return discoverPeerModels(peer);
130
227
  try {
131
228
  if (norm === 'ollama') {
132
229
  const host = (baseUrl || 'http://127.0.0.1:11434').replace(/\/+$/, '');
@@ -257,8 +354,11 @@ export async function resolveAvailableModels(provider, config = {}, forceRefresh
257
354
  const combined = [...new Set([...cached, ...curated])];
258
355
  return { models: combined, source: 'cache' };
259
356
  }
260
- // Attempt lazy background discovery if credentials exist
261
- if (config.apiKey || norm === 'ollama') {
357
+ // Attempt lazy background discovery if credentials exist. Peer agents and
358
+ // Antigravity are credentialed by their own CLI login, so they qualify even
359
+ // with no apiKey in Causyne's vault.
360
+ const localAgent = norm === 'antigravity' || peerIdFromProviderKey(norm) !== null;
361
+ if (config.apiKey || norm === 'ollama' || localAgent) {
262
362
  const live = await fetchLiveModels(norm, config);
263
363
  if (live.length > 0) {
264
364
  const combined = [...new Set([...live, ...curated])];
@@ -12,8 +12,17 @@
12
12
 
13
13
  import fs from 'node:fs';
14
14
  import path from 'node:path';
15
+ import { execFile } from 'node:child_process';
16
+ import { promisify } from 'node:util';
15
17
  import { causyneHome } from './utils/paths.js';
16
- import { MODEL_CATALOGUE, DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
18
+ import { MODEL_CATALOGUE, PEER_MODEL_CATALOGUE } from './modelCatalogue.js';
19
+ import {
20
+ ANTIGRAVITY_MODELS,
21
+ ANTIGRAVITY_LABEL_BY_ID,
22
+ resolveAgyBinary
23
+ } from './providers/antigravity.js';
24
+
25
+ const execFileAsync = promisify(execFile);
17
26
 
18
27
  export interface DynamicCatalogueCache {
19
28
  version: 1;
@@ -43,12 +52,37 @@ export function normalizeProviderKey(provider: string): string {
43
52
  if (p === 'moonshot' || p === 'kimi') return 'moonshot';
44
53
  if (p === 'muse' || p === 'meta') return 'muse';
45
54
  if (p === 'openai-compatible' || p === 'custom') return 'openai-compatible';
55
+ if (p === 'antigravity' || p === 'agy') return 'antigravity';
56
+ if (p === 'acp') return 'acp';
57
+ if (p.startsWith('acp/')) {
58
+ const peer = p.slice(4).split('/')[0];
59
+ return peer ? `acp/${peer}` : 'acp';
60
+ }
46
61
  return p;
47
62
  }
48
63
 
64
+ /**
65
+ * The peer id behind an `acp/<peer>` provider key, or null.
66
+ *
67
+ * Peer agents are providers in exactly the same sense as an HTTP API: the user
68
+ * already owns the credential (their CLI login), and the models available are
69
+ * whatever that account can reach. The provider key carries the peer so the
70
+ * catalogue, the cache and the picker cannot disagree about which one is meant.
71
+ */
72
+ export function peerIdFromProviderKey(provider: string): string | null {
73
+ const p = (provider || '').toLowerCase().trim();
74
+ if (!p.startsWith('acp/')) return null;
75
+ const peer = p.slice(4).split('/')[0];
76
+ return peer || null;
77
+ }
78
+
49
79
  /** Get the static curated models for a provider id. */
50
80
  export function getCuratedModels(provider: string): string[] {
51
81
  const norm = normalizeProviderKey(provider);
82
+ if (norm === 'antigravity') return [...ANTIGRAVITY_MODELS];
83
+ const peer = peerIdFromProviderKey(norm);
84
+ if (peer) return [...(PEER_MODEL_CATALOGUE[peer] ?? [])];
85
+ if (norm === 'acp') return [...(MODEL_CATALOGUE['ACP (Peer Agents)'] ?? [])];
52
86
  const mapping: Record<string, keyof typeof MODEL_CATALOGUE> = {
53
87
  'deepseek': 'DeepSeek',
54
88
  'qwen': 'Qwen',
@@ -69,6 +103,63 @@ export function getCuratedModels(provider: string): string[] {
69
103
  return [];
70
104
  }
71
105
 
106
+ const MODEL_LIST_TIMEOUT_MS = 8000;
107
+ const ANSI_ESCAPE = /\u001b\[[0-9;]*[A-Za-z]/g;
108
+
109
+ const PEER_MODEL_COMMANDS: Record<string, { command: string; args: string[] }> = {
110
+ opencode: { command: 'opencode', args: ['models'] },
111
+ cursor: { command: 'cursor-agent', args: ['models'] }
112
+ };
113
+
114
+ async function runModelList(command: string, args: string[]): Promise<string[]> {
115
+ try {
116
+ const { stdout } = await execFileAsync(command, args, {
117
+ timeout: MODEL_LIST_TIMEOUT_MS,
118
+ maxBuffer: 4 * 1024 * 1024,
119
+ windowsHide: true
120
+ });
121
+ return stdout.replace(ANSI_ESCAPE, '').split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
122
+ } catch {
123
+ return [];
124
+ }
125
+ }
126
+
127
+ function parseModelIds(lines: string[]): string[] {
128
+ const models: string[] = [];
129
+ for (const line of lines) {
130
+ if (/^(fetching|loading|no models|error)/i.test(line)) continue;
131
+ if (line.endsWith('…') || line.endsWith('...')) continue;
132
+ const firstColumn = (line.split('\t')[0] ?? '').trim();
133
+ if (!firstColumn || firstColumn.includes(' ')) continue;
134
+ models.push(firstColumn);
135
+ }
136
+ return [...new Set(models)];
137
+ }
138
+
139
+ /**
140
+ * Ask a peer CLI which models its account can reach. Zero tokens: this runs the
141
+ * peer's own listing command, never a model request.
142
+ */
143
+ export async function discoverPeerModels(peerId: string): Promise<string[]> {
144
+ const peer = (peerId || '').toLowerCase().trim();
145
+ const listing = PEER_MODEL_COMMANDS[peer];
146
+ if (!listing) return [];
147
+ return parseModelIds(await runModelList(listing.command, listing.args));
148
+ }
149
+
150
+ /** Ask Antigravity for its live model list and return the readable labels. */
151
+ export async function discoverAntigravityModels(): Promise<string[]> {
152
+ const lines = await runModelList(resolveAgyBinary(), ['models']);
153
+ const models: string[] = [];
154
+ for (const line of lines) {
155
+ if (/^(fetching|loading|no models|error)/i.test(line)) continue;
156
+ const [id, label] = line.split('\t').map((part) => part.trim());
157
+ if (!id || id.includes(' ')) continue;
158
+ models.push(label || ANTIGRAVITY_LABEL_BY_ID[id] || id);
159
+ }
160
+ return [...new Set(models)];
161
+ }
162
+
72
163
  /** Read cache safely from ~/.causyne/models_cache.json */
73
164
  export function readModelCache(): DynamicCatalogueCache | null {
74
165
  try {
@@ -134,6 +225,10 @@ export async function fetchLiveModels(
134
225
  const norm = normalizeProviderKey(provider);
135
226
  const { apiKey, baseUrl } = config;
136
227
 
228
+ if (norm === 'antigravity') return discoverAntigravityModels();
229
+ const peer = peerIdFromProviderKey(norm);
230
+ if (peer) return discoverPeerModels(peer);
231
+
137
232
  try {
138
233
  if (norm === 'ollama') {
139
234
  const host = (baseUrl || 'http://127.0.0.1:11434').replace(/\/+$/, '');
@@ -269,8 +364,11 @@ export async function resolveAvailableModels(
269
364
  return { models: combined, source: 'cache' };
270
365
  }
271
366
 
272
- // Attempt lazy background discovery if credentials exist
273
- if (config.apiKey || norm === 'ollama') {
367
+ // Attempt lazy background discovery if credentials exist. Peer agents and
368
+ // Antigravity are credentialed by their own CLI login, so they qualify even
369
+ // with no apiKey in Causyne's vault.
370
+ const localAgent = norm === 'antigravity' || peerIdFromProviderKey(norm) !== null;
371
+ if (config.apiKey || norm === 'ollama' || localAgent) {
274
372
  const live = await fetchLiveModels(norm, config);
275
373
  if (live.length > 0) {
276
374
  const combined = [...new Set([...live, ...curated])];
package/src/entrypoint.js CHANGED
@@ -187,6 +187,17 @@ program
187
187
  process.exit(result.ok ? 0 : 1);
188
188
  });
189
189
 
190
+ program
191
+ .command('peers [action] [args...]')
192
+ .description('Manage external ACP peer agents: detect, list, test, add, remove')
193
+ .allowUnknownOption()
194
+ .action(async (action, args) => {
195
+ const argv = action ? [action, ...(args || [])] : [];
196
+ const result = await runCommand('peers', argv, { surface: 'terminal' });
197
+ console.log('\n' + result.output + '\n');
198
+ process.exit(result.ok ? 0 : 1);
199
+ });
200
+
190
201
  program
191
202
  .command('exec <command>')
192
203
  .description('Quick execute a command using the agent terminal')
@@ -1,4 +1,5 @@
1
1
  export const MODEL_CATALOGUE: Record<string, string[]>;
2
+ export const PEER_MODEL_CATALOGUE: Record<string, string[]>;
2
3
  export const PROVIDER_LABELS: string[];
3
4
  export const DEFAULT_MODEL_BY_PROVIDER: Record<string, string>;
4
5
  export const UTILITY_MODEL_BY_PROVIDER: Record<string, string>;
@@ -28,6 +28,26 @@
28
28
  // WHEN A PROVIDER SHIPS A NEW MODEL: add it here, run `npm test`, and the test
29
29
  // will name every other file that must be updated to match.
30
30
 
31
+ /**
32
+ * Models published by a peer CLI's own `models` command. Only ids verified
33
+ * against the installed binary live here; a peer with no published list is
34
+ * absent and uses its own default rather than an invented id.
35
+ */
36
+ export const PEER_MODEL_CATALOGUE = {
37
+ opencode: [
38
+ 'opencode/beam-free',
39
+ 'opencode/big-pickle',
40
+ 'opencode/deepseek-v4.1-flash-free',
41
+ 'opencode/flint-40b-free',
42
+ 'opencode/glm-5.3-flash-free',
43
+ 'opencode/mimo-v2.6-flash-free',
44
+ 'opencode/nemotron-3-ultra-free',
45
+ 'opencode/nemotron-3.5-lightning-free',
46
+ 'opencode/nemotron-3.5-super-vl-free'
47
+ ],
48
+ claude: ['sonnet', 'opus', 'haiku']
49
+ };
50
+
31
51
  /**
32
52
  * Selectable models per provider, newest first.
33
53
  *
@@ -98,7 +118,25 @@ export const MODEL_CATALOGUE = {
98
118
  'deepseek-v4-flash', 'deepseek-v4-pro'
99
119
  ],
100
120
  'Moonshot (Kimi)': ['kimi-k3', 'kimi-k2.7-code', 'kimi-k2.6'],
101
- 'xAI (Grok)': ['grok-3', 'grok-3-mini', 'grok-2-1212', 'grok-4.5', 'grok-latest']
121
+ 'xAI (Grok)': ['grok-3', 'grok-3-mini', 'grok-2-1212', 'grok-4.5', 'grok-latest'],
122
+ 'Google Antigravity': [
123
+ 'Gemini 3.8 Flash (Low)',
124
+ 'Gemini 3.8 Flash (Medium)',
125
+ 'Gemini 3.8 Flash (High)',
126
+ 'Gemini 4 Argon (Low)',
127
+ 'Gemini 4 Argon (Medium)',
128
+ 'Gemini 4 Argon (High)',
129
+ 'Claude Sonnet 5.5 (Low)',
130
+ 'Claude Sonnet 5.5 (Medium)',
131
+ 'Claude Sonnet 5.5 (High)',
132
+ 'Claude Opus 5.5 (Low)',
133
+ 'Claude Opus 5.5 (Medium)',
134
+ 'Claude Opus 5.5 (High)',
135
+ 'GPT-OSS 120B (Medium)'
136
+ ],
137
+ 'ACP (Peer Agents)': ['opencode', 'claude', 'codex', 'gemini', 'cursor', 'hermes', 'qwen', 'copilot', 'kimi', 'goose'],
138
+ 'OpenCode (ACP)': PEER_MODEL_CATALOGUE.opencode,
139
+ 'Claude Code (ACP)': PEER_MODEL_CATALOGUE.claude
102
140
  };
103
141
 
104
142
  /** Provider labels in picker order. */
@@ -117,6 +155,18 @@ export const DEFAULT_MODEL_BY_PROVIDER = {
117
155
  moonshot: 'kimi-k3',
118
156
  xai: 'grok-3',
119
157
  ollama: 'llama3.3',
158
+ acp: 'opencode',
159
+ 'acp/opencode': 'opencode/beam-free',
160
+ 'acp/claude': 'sonnet',
161
+ 'acp/codex': 'codex',
162
+ 'acp/gemini': 'gemini',
163
+ 'acp/cursor': 'cursor',
164
+ 'acp/qwen': 'qwen',
165
+ 'acp/copilot': 'copilot',
166
+ 'acp/kimi': 'kimi',
167
+ 'acp/goose': 'goose',
168
+ 'acp/hermes': 'hermes',
169
+ antigravity: 'Gemini 3.8 Flash (Low)',
120
170
  'openai-compatible': ''
121
171
  };
122
172