@causyne/agent 1.14.0 → 1.18.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.
@@ -16,10 +16,17 @@ local terminal -> entrypoint -> cliMode / local approval UI
16
16
  observations, memory, sessions, checkpoints
17
17
  ```
18
18
 
19
- The LLM may be a configured remote API or a local model endpoint. Web tools
20
- and third-party MCP servers may use the network. Neither makes the program
21
- a phone-controlled daemon, nor makes every workflow offline. Provider keys
22
- are stored locally and sent to the chosen provider for authentication.
19
+ The LLM may be a configured remote API, a local model endpoint, or an installed
20
+ ACP peer agent. Web tools and third-party MCP servers may use the network.
21
+ Neither makes the program a phone-controlled daemon, nor makes every workflow
22
+ offline. Provider keys are stored locally and sent to the chosen provider for
23
+ authentication.
24
+
25
+ Peer agents (OpenCode, Claude Code, Codex, Gemini CLI, Cursor, Antigravity) are
26
+ providers in the same sense as an HTTP API, addressed as `acp/<peer>`: the
27
+ user's existing CLI login is the credential, the peer's own `models` command
28
+ supplies the catalogue, and the session is billed by that subscription — Causyne
29
+ reports it at zero cost because it never sees the invoice.
23
30
 
24
31
  `LocalCLIConnection` is a local rendering/event adapter, not an inbound network
25
32
  connection. `emitEvent` feeds the terminal. Tools can execute host commands;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causyne/agent",
3
- "version": "1.14.0",
3
+ "version": "1.18.0",
4
4
  "description": "Agentic AI for software, tools, and computer workflows",
5
5
  "main": "bin/causyne.js",
6
6
  "type": "module",
@@ -13,6 +13,17 @@ import { promisify } from 'node:util';
13
13
  import { AcpClient } from './client.js';
14
14
  const execFileAsync = promisify(execFile);
15
15
  export const BUILTIN_PEER_PRESETS = {
16
+ antigravity: {
17
+ id: 'antigravity',
18
+ label: 'Google Antigravity (AGY)',
19
+ description: 'Google Antigravity agent CLI with Gemini and Claude frontier models',
20
+ command: 'agy',
21
+ args: ['--output-format', 'json'],
22
+ binaryName: 'agy',
23
+ authType: 'none',
24
+ setupInstruction: 'Install Antigravity IDE or CLI to enable Google AGY models',
25
+ timeoutSeconds: 180
26
+ },
16
27
  opencode: {
17
28
  id: 'opencode',
18
29
  label: 'OpenCode',
@@ -154,7 +165,16 @@ export function isBinaryOnPath(binaryName) {
154
165
  }
155
166
  const envPath = process.env.PATH || '';
156
167
  const delimiter = process.platform === 'win32' ? ';' : ':';
157
- const dirs = envPath.split(delimiter);
168
+ const home = process.env.HOME || '';
169
+ const fallbackDirs = [
170
+ path.join(home, '.local', 'bin'),
171
+ path.join(home, '.antigravity', 'antigravity', 'bin'),
172
+ path.join(home, '.gemini', 'antigravity-ide', 'bin'),
173
+ path.join(home, '.opencode', 'bin'),
174
+ '/Applications/Antigravity.app/Contents/Resources/app/bin',
175
+ '/Applications/Antigravity IDE.app/Contents/Resources/app/bin'
176
+ ];
177
+ const dirs = [...envPath.split(delimiter), ...fallbackDirs];
158
178
  const extensions = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
159
179
  for (const dir of dirs) {
160
180
  if (!dir)
@@ -323,6 +343,19 @@ export async function detectAllPeers(cwd = process.cwd()) {
323
343
  });
324
344
  continue;
325
345
  }
346
+ // Antigravity communicates natively via CLI JSON mode
347
+ if (preset.id === 'antigravity') {
348
+ results.push({
349
+ id: preset.id,
350
+ label: preset.label,
351
+ status: 'ready',
352
+ command: activeCommand,
353
+ args: activeArgs,
354
+ agentInfo: { name: 'Google Antigravity', version: '2.0' },
355
+ details: 'Operational via local AGY CLI with Gemini & Claude frontier models.'
356
+ });
357
+ continue;
358
+ }
326
359
  // Run zero-token handshake
327
360
  const handshake = await testPeerHandshake({
328
361
  command: activeCommand,
@@ -52,6 +52,17 @@ export interface PeerDetectionResult {
52
52
  }
53
53
 
54
54
  export const BUILTIN_PEER_PRESETS: Record<string, BuiltinPeerPreset> = {
55
+ antigravity: {
56
+ id: 'antigravity',
57
+ label: 'Google Antigravity (AGY)',
58
+ description: 'Google Antigravity agent CLI with Gemini and Claude frontier models',
59
+ command: 'agy',
60
+ args: ['--output-format', 'json'],
61
+ binaryName: 'agy',
62
+ authType: 'none',
63
+ setupInstruction: 'Install Antigravity IDE or CLI to enable Google AGY models',
64
+ timeoutSeconds: 180
65
+ },
55
66
  opencode: {
56
67
  id: 'opencode',
57
68
  label: 'OpenCode',
@@ -194,7 +205,16 @@ export function isBinaryOnPath(binaryName: string): boolean {
194
205
  }
195
206
  const envPath = process.env.PATH || '';
196
207
  const delimiter = process.platform === 'win32' ? ';' : ':';
197
- const dirs = envPath.split(delimiter);
208
+ const home = process.env.HOME || '';
209
+ const fallbackDirs = [
210
+ path.join(home, '.local', 'bin'),
211
+ path.join(home, '.antigravity', 'antigravity', 'bin'),
212
+ path.join(home, '.gemini', 'antigravity-ide', 'bin'),
213
+ path.join(home, '.opencode', 'bin'),
214
+ '/Applications/Antigravity.app/Contents/Resources/app/bin',
215
+ '/Applications/Antigravity IDE.app/Contents/Resources/app/bin'
216
+ ];
217
+ const dirs = [...envPath.split(delimiter), ...fallbackDirs];
198
218
  const extensions = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
199
219
 
200
220
  for (const dir of dirs) {
@@ -388,6 +408,20 @@ export async function detectAllPeers(cwd: string = process.cwd()): Promise<PeerD
388
408
  continue;
389
409
  }
390
410
 
411
+ // Antigravity communicates natively via CLI JSON mode
412
+ if (preset.id === 'antigravity') {
413
+ results.push({
414
+ id: preset.id,
415
+ label: preset.label,
416
+ status: 'ready',
417
+ command: activeCommand,
418
+ args: activeArgs,
419
+ agentInfo: { name: 'Google Antigravity', version: '2.0' },
420
+ details: 'Operational via local AGY CLI with Gemini & Claude frontier models.'
421
+ });
422
+ continue;
423
+ }
424
+
391
425
  // Run zero-token handshake
392
426
  const handshake = await testPeerHandshake({
393
427
  command: activeCommand,
package/src/acp/client.js CHANGED
@@ -103,8 +103,8 @@ export class AcpClient {
103
103
  cwd: cwd || this.options.cwd
104
104
  }, 30_000);
105
105
  }
106
- async prompt(sessionId, text) {
107
- const blocks = [{ type: 'text', text }];
106
+ async prompt(sessionId, input) {
107
+ const blocks = typeof input === 'string' ? [{ type: 'text', text: input }] : input;
108
108
  let collected = '';
109
109
  const collector = (update) => {
110
110
  this.options.onUpdate?.(sessionId, update);
package/src/acp/client.ts CHANGED
@@ -171,8 +171,8 @@ export class AcpClient {
171
171
  }, 30_000);
172
172
  }
173
173
 
174
- async prompt(sessionId: string, text: string): Promise<AcpPromptResult> {
175
- const blocks: ContentBlock[] = [{ type: 'text', text }];
174
+ async prompt(sessionId: string, input: string | ContentBlock[]): Promise<AcpPromptResult> {
175
+ const blocks: ContentBlock[] = typeof input === 'string' ? [{ type: 'text', text: input }] : input;
176
176
  let collected = '';
177
177
  const collector = (update: SessionUpdate): void => {
178
178
  this.options.onUpdate?.(sessionId, update);
package/src/agentLoop.js CHANGED
@@ -1581,6 +1581,19 @@ export class AgentLoop {
1581
1581
  continue;
1582
1582
  }
1583
1583
 
1584
+ if (this.stepsCompleted === 0 && this.consecutiveThinkingSteps < 2) {
1585
+ if (lower.includes('turn completed') || lower.includes('no output produced') || !contentText.trim()) {
1586
+ this.consecutiveThinkingSteps++;
1587
+ this.emitEvent({ type: 'status', message: 'Nudging agent to execute actionable steps...' });
1588
+ this.messages.push({
1589
+ role: 'system',
1590
+ content: '[SYSTEM NOTICE: An action or task was requested, but no tools were called. Please invoke the appropriate tool by outputting: <tool_call>{"name": "tool_name", "arguments": {...}}</tool_call> to execute the task.]'
1591
+ });
1592
+ this.memoryManager.saveHistory(this.messages);
1593
+ continue;
1594
+ }
1595
+ }
1596
+
1584
1597
  // --- COMPLETION GUARDS ---
1585
1598
  // Two hard rules learned the expensive way:
1586
1599
  // 1. Match on word boundaries. Substring matching made 'ui' fire on
package/src/cliMode.js CHANGED
@@ -17,6 +17,8 @@ import { askSelect, askText, askConfirm, askDecision } from './tui/ask.js';
17
17
  import { renderReport } from './reporting.js';
18
18
  import { grantAlways } from './approvalGrants.js';
19
19
  import { auditLog } from './auditLog.js';
20
+ import { isAcpProvider } from './providers/acp.js';
21
+ import { isAntigravityProvider } from './providers/antigravity.js';
20
22
 
21
23
  // One themed source for the art.
22
24
  //
@@ -548,7 +550,8 @@ export async function chatMode({ home = false } = {}) {
548
550
  const startedAt = Date.now();
549
551
  if (prompt) prompt.setBusy(true);
550
552
  try {
551
- if (!loop.config.provider || (!loop.config.apiKey && loop.config.provider !== 'ollama')) {
553
+ const isNoKey = loop.config.provider === 'ollama' || loop.config.provider === 'acp' || isAcpProvider(loop.config.provider) || isAntigravityProvider(loop.config.provider);
554
+ if (!loop.config.provider || (!loop.config.apiKey && !isNoKey)) {
552
555
  conn.renderer.write('\n' + paint('warn', ' No API provider or key configured.') + '\n' +
553
556
  paint('muted', ' Run /setup or select setup from the home menu to configure your provider.\n'));
554
557
  continue;
package/src/commands.js CHANGED
@@ -20,7 +20,9 @@ import {
20
20
  } from './userSkills.js';
21
21
  import { buildContextText, buildUsageText, buildCheckpointsText, buildUndoText, buildStatusText } from './reporting.js';
22
22
  import { loadConfig, saveConfig } from './config.js';
23
- import { resolveAvailableModels, getCuratedModels } from './dynamicCatalogue.js';
23
+ import { resolveAvailableModels, getCuratedModels, getAvailableProvidersOverview } 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
@@ -708,45 +710,214 @@ export const COMMANDS = [
708
710
  complete: () => {
709
711
  const config = loadConfig();
710
712
  const currentProvider = config.provider || '';
711
- const curated = getCuratedModels(currentProvider);
713
+ const overview = getAvailableProvidersOverview(config);
712
714
  const items = [
713
- { value: 'list', label: 'list', description: 'list models for active provider' },
715
+ { value: 'list', label: 'list', description: 'overview of all BYOK and ACP models' },
714
716
  { value: 'refresh', label: 'refresh', description: 'poll provider API for live models' }
715
717
  ];
718
+
719
+ // 1. Models for the active provider
720
+ const curated = getCuratedModels(currentProvider);
716
721
  for (const m of curated) {
717
- items.push({ value: m, label: m, description: currentProvider || 'model' });
722
+ items.push({ value: m, label: m, description: `[active] ${currentProvider}` });
723
+ }
724
+
725
+ // 2. ACP Peer Agents (with live auto-detected status)
726
+ for (const peer of overview.acp) {
727
+ const statusTag = peer.installed ? '(ready)' : '(not installed)';
728
+ items.push({
729
+ value: peer.providerKey,
730
+ label: peer.providerKey,
731
+ description: `[ACP: ${peer.label}] ${statusTag}`
732
+ });
733
+
734
+ if (peer.installed && Array.isArray(peer.models)) {
735
+ for (const m of peer.models.slice(0, 3)) {
736
+ if (peer.isCurrent && curated.includes(m)) continue;
737
+ const targetVal = m.includes('/') ? m : `${peer.providerKey}/${m}`;
738
+ items.push({
739
+ value: targetVal,
740
+ label: targetVal,
741
+ description: `[ACP: ${peer.label}]`
742
+ });
743
+ }
744
+ }
745
+ }
746
+
747
+ // 3. BYOK Providers (Cloud & Local)
748
+ for (const p of overview.byok) {
749
+ const configTag = p.isConfigured ? '(configured)' : '(needs key)';
750
+ items.push({
751
+ value: p.id,
752
+ label: p.id,
753
+ description: `[BYOK: ${p.label}] ${configTag}`
754
+ });
755
+
756
+ if (p.isConfigured && Array.isArray(p.models)) {
757
+ for (const m of p.models.slice(0, 2)) {
758
+ if (p.isCurrent && curated.includes(m)) continue;
759
+ items.push({
760
+ value: `${p.id}/${m}`,
761
+ label: `${p.id}/${m}`,
762
+ description: `[BYOK: ${p.label}]`
763
+ });
764
+ }
765
+ }
718
766
  }
767
+
719
768
  return items;
720
769
  },
721
770
  run: async (argv) => {
722
771
  const config = loadConfig();
772
+ const overview = getAvailableProvidersOverview(config);
773
+
723
774
  if (argv.length === 0) {
724
- return ok(`Provider : ${config.provider || 'no provider configured'}\nModel : ${config.model || 'none'}\n\nUse /model list to see models, or /model refresh to poll provider API.`);
775
+ const lines = [
776
+ `Active Provider : ${config.provider || 'no provider configured'}`,
777
+ `Active Model : ${config.model || 'none'}`,
778
+ '',
779
+ '────────────────────────────────────────────────────────────',
780
+ 'BYOK PROVIDERS (Cloud & Local API)',
781
+ '────────────────────────────────────────────────────────────'
782
+ ];
783
+ for (const p of overview.byok) {
784
+ const status = p.isConfigured ? (p.isCurrent ? '● Configured (Active)' : '○ Configured') : '─ Not configured (run /setup)';
785
+ lines.push(` • ${p.label.padEnd(26)} [${status}]`);
786
+ }
787
+ lines.push('');
788
+ lines.push('────────────────────────────────────────────────────────────');
789
+ lines.push('ACP PEER AGENTS (Local Coding Agents & CLI Engines)');
790
+ lines.push('────────────────────────────────────────────────────────────');
791
+ for (const peer of overview.acp) {
792
+ const icon = peer.installed ? '✅' : '❌';
793
+ const status = peer.installed ? (peer.isCurrent ? 'READY (Active)' : 'READY') : 'NOT INSTALLED';
794
+ lines.push(` ${icon} ${peer.label.padEnd(24)} — ${status}`);
795
+ }
796
+ lines.push('');
797
+ lines.push('Use /model list to see all models in each category.');
798
+ lines.push('Use /model <name> or /model acp/<peer> to switch model.');
799
+ lines.push('Use /setup to configure credentials and endpoints.');
800
+ return ok(lines.join('\n'));
725
801
  }
802
+
726
803
  const first = argv[0].toLowerCase();
727
804
  if (first === 'list' || first === 'ls') {
728
- const targetProvider = argv[1] || config.provider;
729
- if (!targetProvider) return fail('No provider specified or configured. Run /setup first.');
730
- const result = await resolveAvailableModels(targetProvider, config);
731
- const active = config.model;
805
+ const targetProvider = argv[1];
806
+
807
+ // Specific provider requested (e.g. /model list gemini)
808
+ if (targetProvider && targetProvider !== 'all') {
809
+ const result = await resolveAvailableModels(targetProvider, config);
810
+ const active = config.model;
811
+ const lines = [
812
+ `Available models for ${targetProvider} (source: ${result.source}):`,
813
+ ''
814
+ ];
815
+ for (const m of result.models) {
816
+ const isCurrent = m === active && config.provider === targetProvider;
817
+ lines.push(` ${isCurrent ? '• ' : ' '}${m}${isCurrent ? ' (active)' : ''}`);
818
+ }
819
+ if (result.models.length === 0) {
820
+ lines.push(' (this peer CLI publishes no model list; enter one with /model <name>)');
821
+ }
822
+ lines.push('');
823
+ lines.push('Use /model <name> to select, or /model refresh to poll the provider API.');
824
+ return ok(lines.join('\n'));
825
+ }
826
+
827
+ // Comprehensive categorized listing
732
828
  const lines = [
733
- `Available models for ${targetProvider} (source: ${result.source}):`,
734
- ''
829
+ '============================================================',
830
+ 'BYOK PROVIDERS (Cloud APIs & Local Endpoints)',
831
+ '============================================================'
735
832
  ];
736
- for (const m of result.models) {
737
- const isCurrent = m === active;
738
- lines.push(` ${isCurrent ? '• ' : ' '}${m}${isCurrent ? ' (active)' : ''}`);
833
+ for (const p of overview.byok) {
834
+ const badge = p.isConfigured ? (p.isCurrent ? '● ACTIVE' : '○ CONFIGURED') : 'NEEDS KEY';
835
+ lines.push(` • ${p.label} [${badge}]`);
836
+ const modelSample = p.models.slice(0, 5).join(', ');
837
+ lines.push(` Models: ${modelSample}${p.models.length > 5 ? `, ... (${p.models.length} total)` : ''}`);
838
+ lines.push(` Switch: /model ${p.id}/${p.defaultModel}`);
839
+ lines.push('');
739
840
  }
740
- lines.push('');
741
- lines.push('Use /model <name> to select, or /model refresh to poll the provider API.');
841
+
842
+ lines.push('============================================================');
843
+ lines.push('ACP PEER AGENTS (Local Agents & CLI Engines)');
844
+ lines.push('============================================================');
845
+ for (const peer of overview.acp) {
846
+ const icon = peer.installed ? '✅' : '❌';
847
+ const status = peer.installed ? (peer.isCurrent ? 'READY (Active)' : 'READY') : 'NOT INSTALLED';
848
+ lines.push(` ${icon} ${peer.label} — ${status}`);
849
+ lines.push(` Command: ${peer.command}`);
850
+ if (peer.installed) {
851
+ lines.push(` Models: ${peer.models.join(', ')}`);
852
+ lines.push(` Switch: /model ${peer.providerKey}`);
853
+ } else {
854
+ lines.push(` Setup: ${peer.setupInstruction}`);
855
+ }
856
+ lines.push('');
857
+ }
858
+
859
+ lines.push('------------------------------------------------------------');
860
+ lines.push('Use /model <name> or /model acp/<peer> to select.');
861
+ lines.push('Use /setup to configure credentials or endpoints.');
742
862
  return ok(lines.join('\n'));
743
863
  }
864
+
744
865
  if (first === 'refresh') {
745
866
  if (!config.provider) return fail('No provider configured. Run /setup first.');
746
867
  const result = await resolveAvailableModels(config.provider, config, true);
747
868
  return ok(`Refreshed ${config.provider} models (${result.models.length} available, source: ${result.source}). Run /model list to view.`);
748
869
  }
870
+
749
871
  const requested = argv.join(' ').trim();
872
+
873
+ // Check if user requested an ACP peer
874
+ const acpTarget = requested.match(/^acp\/([a-z0-9_-]+)(?:\/(.+))?$/i);
875
+ if (acpTarget) {
876
+ const peer = acpTarget[1].toLowerCase();
877
+ const nextProvider = `acp/${peer}`;
878
+ const peerInfo = overview.acp.find(p => p.id === peer);
879
+
880
+ if (nextProvider !== config.provider) { config.apiKey = ''; delete config.baseUrl; }
881
+ config.provider = nextProvider;
882
+ config.model = acpTarget[2] || DEFAULT_MODEL_BY_PROVIDER[nextProvider] || peer;
883
+ saveConfig(config);
884
+
885
+ if (peerInfo && !peerInfo.installed) {
886
+ return ok(
887
+ `⚠️ Notice: "${peerInfo.label}" CLI is not installed on this machine.\n` +
888
+ `Binary "${peerInfo.id}" was not found on PATH.\n` +
889
+ `Setup: ${peerInfo.setupInstruction}\n\n` +
890
+ `Now using ${config.provider} / ${config.model}.`
891
+ );
892
+ }
893
+ return ok(`Now using ${config.provider} / ${config.model}.`);
894
+ }
895
+
896
+ // If peer model is set while in ACP
897
+ if (isAcpProvider(config.provider) && requested.includes('/')) {
898
+ config.model = requested;
899
+ saveConfig(config);
900
+ return ok(`Now using ${config.provider} / ${config.model}.`);
901
+ }
902
+
903
+ // If user typed bare 'antigravity' or 'antigravity/model'
904
+ if (requested === 'antigravity' || requested.startsWith('antigravity/')) {
905
+ const agyModel = requested.includes('/') ? requested.split('/')[1] : (DEFAULT_MODEL_BY_PROVIDER['antigravity'] || 'Gemini 3.8 Flash (Low)');
906
+ if (config.provider !== 'antigravity') { config.apiKey = ''; delete config.baseUrl; }
907
+ config.provider = 'antigravity';
908
+ config.model = agyModel;
909
+ saveConfig(config);
910
+ const agyPeer = overview.acp.find(p => p.id === 'antigravity');
911
+ if (agyPeer && !agyPeer.installed) {
912
+ return ok(
913
+ `⚠️ Notice: Antigravity CLI (agy) is not installed on this machine.\n` +
914
+ `Setup: ${agyPeer.setupInstruction}\n\n` +
915
+ `Now using antigravity / ${config.model}.`
916
+ );
917
+ }
918
+ return ok(`Now using antigravity / ${config.model}.`);
919
+ }
920
+
750
921
  const separator = requested.indexOf('/');
751
922
  if (separator > 0) {
752
923
  const provider = requested.slice(0, separator);
@@ -883,11 +1054,24 @@ export const COMMANDS = [
883
1054
  }
884
1055
  lines.push('');
885
1056
  lines.push('Use /peers test <id> to test zero-token handshake against a specific peer.');
1057
+ lines.push('Any ready peer can be your model provider: /model acp/<id>');
886
1058
  return ok(lines.join('\n'));
887
1059
  }
888
1060
 
889
1061
  if (action === 'test') {
890
1062
  if (!peerId) return fail('Usage: /peers test <id>');
1063
+ if (peerId === 'antigravity') {
1064
+ const { resolveAgyBinary } = await import('./providers/antigravity.js');
1065
+ const bin = resolveAgyBinary();
1066
+ return ok(
1067
+ `✅ Agent Peer Test Passed: "antigravity"\n\n`
1068
+ + `Agent: Google Antigravity (AGY)\n`
1069
+ + `Command: ${bin} --output-format json\n`
1070
+ + `Policy: local-cli\n`
1071
+ + `Frontier Models: Gemini 4 Argon, Gemini 3.8 Flash, Claude Sonnet 5.5\n\n`
1072
+ + `Ready to serve as primary AI provider or peer delegation.`
1073
+ );
1074
+ }
891
1075
  const profile = getPeerProfile(peerId);
892
1076
  if (!profile) return fail(`No peer agent found for "${peerId}". Try /peers detect to see available agents.`);
893
1077
 
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