@causyne/agent 1.17.0 → 1.19.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 (70) hide show
  1. package/package.json +1 -1
  2. package/src/agentLoop.js +2348 -2518
  3. package/src/agentLoop.ts +2865 -0
  4. package/src/checkpoints.d.ts +4 -0
  5. package/src/cliMode.js +10 -3
  6. package/src/commands.js +274 -25
  7. package/src/config.js +22 -0
  8. package/src/contextManager.d.ts +10 -0
  9. package/src/continuum/adapters/antigravity.js +193 -0
  10. package/src/continuum/adapters/antigravity.ts +204 -0
  11. package/src/continuum/adapters/base.js +48 -0
  12. package/src/continuum/adapters/base.ts +57 -0
  13. package/src/continuum/adapters/causyne.js +66 -0
  14. package/src/continuum/adapters/causyne.ts +72 -0
  15. package/src/continuum/adapters/claudeCode.js +171 -0
  16. package/src/continuum/adapters/claudeCode.ts +179 -0
  17. package/src/continuum/adapters/codex.js +181 -0
  18. package/src/continuum/adapters/codex.ts +193 -0
  19. package/src/continuum/adapters/opencode.js +134 -0
  20. package/src/continuum/adapters/opencode.ts +153 -0
  21. package/src/continuum/compactor.js +54 -0
  22. package/src/continuum/compactor.ts +83 -0
  23. package/src/continuum/index.js +8 -0
  24. package/src/continuum/index.ts +9 -0
  25. package/src/continuum/ingest.js +63 -0
  26. package/src/continuum/ingest.ts +89 -0
  27. package/src/continuum/sanitizer.js +55 -0
  28. package/src/continuum/sanitizer.ts +59 -0
  29. package/src/continuum/scanner.js +86 -0
  30. package/src/continuum/scanner.ts +106 -0
  31. package/src/continuum/types.js +3 -0
  32. package/src/continuum/types.ts +51 -0
  33. package/src/continuum/ui/continuumPicker.js +111 -0
  34. package/src/continuum/ui/continuumPicker.ts +145 -0
  35. package/src/cortex/autoCondenser.d.ts +2 -0
  36. package/src/cortex/vectorDb.d.ts +1 -0
  37. package/src/designPalettes.d.ts +2 -0
  38. package/src/devMode.d.ts +1 -0
  39. package/src/dynamicCatalogue.js +140 -1
  40. package/src/dynamicCatalogue.ts +179 -1
  41. package/src/embodimentSession.d.ts +2 -0
  42. package/src/entrypoint.js +12 -0
  43. package/src/memory.d.ts +1 -0
  44. package/src/memoryManager.d.ts +1 -0
  45. package/src/modelIds.d.ts +2 -0
  46. package/src/outputStore.d.ts +4 -0
  47. package/src/providers/acp.js +321 -267
  48. package/src/providers/acp.ts +360 -0
  49. package/src/providers/antigravity.js +389 -239
  50. package/src/providers/antigravity.ts +450 -0
  51. package/src/providers/base.d.ts +68 -0
  52. package/src/providers/factory.d.ts +1 -0
  53. package/src/provisioning/capabilityProvisioner.d.ts +2 -0
  54. package/src/sandbox.d.ts +1 -0
  55. package/src/skillsManager.d.ts +3 -0
  56. package/src/slopDetector.d.ts +3 -0
  57. package/src/taskBuffer.d.ts +1 -0
  58. package/src/tokenTracker.d.ts +1 -0
  59. package/src/toolPacks.d.ts +8 -0
  60. package/src/tools/registry.d.ts +4 -0
  61. package/src/tui/chatRenderer.js +71 -12
  62. package/src/tui/clipboardSync.js +36 -0
  63. package/src/tui/clipboardSync.ts +36 -0
  64. package/src/tui/dialogs.js +15 -2
  65. package/src/tui/home.js +27 -25
  66. package/src/tui/modelPicker.js +221 -0
  67. package/src/tui/modelPicker.ts +290 -0
  68. package/src/tui/prompt.js +17 -6
  69. package/src/tui/selectList.js +20 -0
  70. package/src/tui/theme.js +4 -0
@@ -0,0 +1,106 @@
1
+ // Continuum Scanner: orchestrates dynamic discovery across all peer agent adapters.
2
+ // Authorship: Strict TypeScript (Causyne Agent).
3
+
4
+ import type { ContinuumAdapter, ContinuumSessionSummary, ContinuumSessionDetail, ContinuumFilterOptions } from './types.js';
5
+ import { AntigravityAdapter } from './adapters/antigravity.js';
6
+ import { OpenCodeAdapter } from './adapters/opencode.js';
7
+ import { CodexAdapter } from './adapters/codex.js';
8
+ import { ClaudeCodeAdapter } from './adapters/claudeCode.js';
9
+ import { CausyneAdapter } from './adapters/causyne.js';
10
+
11
+ export class ContinuumScanner {
12
+ private readonly adapters: ContinuumAdapter[];
13
+
14
+ constructor(customAdapters?: ContinuumAdapter[]) {
15
+ this.adapters = customAdapters || [
16
+ new AntigravityAdapter(),
17
+ new OpenCodeAdapter(),
18
+ new CodexAdapter(),
19
+ new ClaudeCodeAdapter(),
20
+ new CausyneAdapter()
21
+ ];
22
+ }
23
+
24
+ getAllAdapters(): readonly ContinuumAdapter[] {
25
+ return this.adapters;
26
+ }
27
+
28
+ getAvailableAdapters(): ContinuumAdapter[] {
29
+ return this.adapters.filter(a => a.isAvailable());
30
+ }
31
+
32
+ async scanAll(options: ContinuumFilterOptions = {}): Promise<ContinuumSessionSummary[]> {
33
+ return this.scanAllSessions(options);
34
+ }
35
+
36
+ async scanAllSessions(options: ContinuumFilterOptions = {}): Promise<ContinuumSessionSummary[]> {
37
+ const activeAdapters = this.getAvailableAdapters().filter(a => {
38
+ if (!options.platform || options.platform === 'all') return true;
39
+ return a.platform === options.platform;
40
+ });
41
+
42
+ const results = await Promise.allSettled(
43
+ activeAdapters.map(adapter => adapter.listSessions(options.limit ?? 50))
44
+ );
45
+
46
+ let all: ContinuumSessionSummary[] = [];
47
+ for (const res of results) {
48
+ if (res.status === 'fulfilled' && Array.isArray(res.value)) {
49
+ all.push(...res.value);
50
+ }
51
+ }
52
+
53
+ // Filter by text query if provided
54
+ if (options.query && options.query.trim()) {
55
+ const q = options.query.toLowerCase().trim();
56
+ all = all.filter(s =>
57
+ s.title.toLowerCase().includes(q) ||
58
+ s.snippet.toLowerCase().includes(q) ||
59
+ s.workspacePath.toLowerCase().includes(q) ||
60
+ s.sourceLabel.toLowerCase().includes(q)
61
+ );
62
+ }
63
+
64
+ // Filter by workspace if specified
65
+ if (options.workspaceFilter && options.workspaceFilter.trim()) {
66
+ const wf = options.workspaceFilter.toLowerCase().trim();
67
+ all = all.filter(s => s.workspacePath.toLowerCase().includes(wf));
68
+ }
69
+
70
+ // Sort by most recently updated
71
+ all.sort((a, b) => b.updatedAt - a.updatedAt);
72
+
73
+ if (options.limit && options.limit > 0) {
74
+ return all.slice(0, options.limit);
75
+ }
76
+ return all;
77
+ }
78
+
79
+ async fetchSession(id: string): Promise<ContinuumSessionDetail | null> {
80
+ const colonIndex = id.indexOf(':');
81
+ if (colonIndex === -1) {
82
+ // Try all adapters sequentially
83
+ for (const adapter of this.getAvailableAdapters()) {
84
+ const detail = await adapter.getSession(id);
85
+ if (detail) return detail;
86
+ }
87
+ return null;
88
+ }
89
+
90
+ const platformPrefix = id.slice(0, colonIndex).toLowerCase();
91
+ const adapter = this.adapters.find(a =>
92
+ a.platform === platformPrefix ||
93
+ (platformPrefix === 'claude' && a.platform === 'claude_code') ||
94
+ (platformPrefix === 'agy' && a.platform === 'antigravity')
95
+ );
96
+ if (adapter) {
97
+ return adapter.getSession(id);
98
+ }
99
+
100
+ for (const a of this.getAvailableAdapters()) {
101
+ const detail = await a.getSession(id);
102
+ if (detail) return detail;
103
+ }
104
+ return null;
105
+ }
106
+ }
@@ -0,0 +1,3 @@
1
+ // Sovereign Cross-Agent Continuum Engine: Unified Session Types & Contracts.
2
+ // Authorship: Strict TypeScript (Causyne Agent).
3
+ export {};
@@ -0,0 +1,51 @@
1
+ // Sovereign Cross-Agent Continuum Engine: Unified Session Types & Contracts.
2
+ // Authorship: Strict TypeScript (Causyne Agent).
3
+
4
+ export type AgentPlatform = 'antigravity' | 'opencode' | 'codex' | 'claude_code' | 'causyne' | 'cursor';
5
+
6
+ export interface ContinuumMessage {
7
+ role: 'user' | 'assistant' | 'system';
8
+ content: string;
9
+ timestamp?: number;
10
+ metadata?: Record<string, unknown>;
11
+ }
12
+
13
+ export interface ContinuumSessionSummary {
14
+ id: string;
15
+ sourcePlatform: AgentPlatform;
16
+ sourceLabel: string;
17
+ title: string;
18
+ workspacePath: string;
19
+ updatedAt: number;
20
+ messageCount: number;
21
+ snippet: string;
22
+ }
23
+
24
+ export interface ContinuumSessionDetail extends ContinuumSessionSummary {
25
+ messages: ContinuumMessage[];
26
+ }
27
+
28
+ export interface ContinuumAdapter {
29
+ readonly platform: AgentPlatform;
30
+ readonly label: string;
31
+ isAvailable(): boolean;
32
+ listSessions(limit?: number): Promise<ContinuumSessionSummary[]>;
33
+ getSession(id: string): Promise<ContinuumSessionDetail | null>;
34
+ }
35
+
36
+ export interface ContinuumFilterOptions {
37
+ platform?: AgentPlatform | 'all';
38
+ query?: string;
39
+ limit?: number;
40
+ workspaceFilter?: string;
41
+ }
42
+
43
+ export interface ContinuumAdoptResult {
44
+ ok: boolean;
45
+ sessionId: string;
46
+ title: string;
47
+ sourcePlatform: AgentPlatform;
48
+ messageCount: number;
49
+ preservedActiveSessionId?: string | null;
50
+ error?: string;
51
+ }
@@ -0,0 +1,111 @@
1
+ // Continuum TUI Picker: interactive modal dialog for browsing and adopting peer agent sessions.
2
+ // Authorship: Strict TypeScript (Causyne Agent).
3
+ // @ts-expect-error untyped local TUI dialogs
4
+ import { SelectLayer, TextLayer } from '../../tui/dialogs.js';
5
+ // @ts-expect-error untyped local TUI theme
6
+ import { GLYPHS } from '../../tui/theme.js';
7
+ import { ContinuumScanner } from '../scanner.js';
8
+ import { adoptContinuumSession } from '../ingest.js';
9
+ function formatTimeAgo(timestamp) {
10
+ const diffMs = Date.now() - timestamp;
11
+ const minutes = Math.floor(diffMs / (60 * 1000));
12
+ if (minutes < 60)
13
+ return `${Math.max(1, minutes)}m ago`;
14
+ const hours = Math.floor(minutes / 60);
15
+ if (hours < 24)
16
+ return `${hours}h ago`;
17
+ const days = Math.floor(hours / 24);
18
+ return `${days}d ago`;
19
+ }
20
+ export function buildContinuumItems(sessions) {
21
+ return sessions.map(s => {
22
+ const timeAgo = formatTimeAgo(s.updatedAt);
23
+ const ws = s.workspacePath ? s.workspacePath.split('/').pop() || s.workspacePath : '';
24
+ const desc = `${s.messageCount} msg${s.messageCount === 1 ? '' : 's'} ${GLYPHS.dot} ${timeAgo}${ws ? ` ${GLYPHS.dot} ${ws}` : ''}`;
25
+ return {
26
+ label: s.title,
27
+ description: desc,
28
+ category: s.sourceLabel,
29
+ hint: s.sourceLabel,
30
+ searchText: `${s.sourceLabel} ${s.title} ${s.workspacePath} ${s.snippet}`,
31
+ value: s
32
+ };
33
+ });
34
+ }
35
+ /**
36
+ * Launch the interactive Continuum session picker.
37
+ */
38
+ export async function runInteractiveContinuum(prompt, options = {}) {
39
+ const scanner = options.scanner || new ContinuumScanner();
40
+ const sessions = await scanner.scanAllSessions({ limit: 80 });
41
+ if (sessions.length === 0) {
42
+ return 'No peer agent sessions found across Antigravity, OpenCode, Codex, or Claude Code on this machine.';
43
+ }
44
+ const items = buildContinuumItems(sessions);
45
+ const pickedSession = await new Promise((resolve) => {
46
+ const layer = new SelectLayer({
47
+ title: `Continuum · Cross-Agent Sessions (${sessions.length})`,
48
+ placeholder: 'search past agent conversations (antigravity, opencode, codex, claude)...',
49
+ emptyText: 'no matching sessions found',
50
+ width: 78,
51
+ height: 20,
52
+ footer: `enter adopt session ${GLYPHS.dot} esc cancel`,
53
+ items,
54
+ onPick: (item) => {
55
+ resolve(item ? item.value : null);
56
+ }
57
+ });
58
+ prompt.openLayer(layer);
59
+ });
60
+ if (!pickedSession) {
61
+ return 'Cancelled. Session was not changed.';
62
+ }
63
+ // Ingest the chosen session
64
+ const adoptRes = await adoptContinuumSession(pickedSession.id, {
65
+ scanner,
66
+ currentLoopMessages: options.loop?.messages
67
+ });
68
+ if (!adoptRes.ok) {
69
+ return `Failed to adopt session: ${adoptRes.error}`;
70
+ }
71
+ if (options.loop) {
72
+ if (options.loop.memoryManager) {
73
+ options.loop.memoryManager.useSession(adoptRes.sessionId);
74
+ if (typeof options.loop.memoryManager.loadHistory === 'function') {
75
+ options.loop.messages = options.loop.memoryManager.loadHistory();
76
+ }
77
+ }
78
+ }
79
+ return `✓ Successfully adopted session "${adoptRes.title}" from ${adoptRes.sourcePlatform.toUpperCase()} (${adoptRes.messageCount} messages compacted).\n New active Causyne session: ${adoptRes.sessionId}. Continue working seamlessly.`;
80
+ }
81
+ /**
82
+ * Open a preview text modal showing the full conversation transcript for a session.
83
+ */
84
+ export async function openContinuumPreview(sessionId, prompt, scanner) {
85
+ const sc = scanner || new ContinuumScanner();
86
+ const detail = await sc.fetchSession(sessionId);
87
+ if (!detail || !detail.messages) {
88
+ return false;
89
+ }
90
+ const lines = [
91
+ `Source: ${detail.sourceLabel} · Messages: ${detail.messages.length} · Workspace: ${detail.workspacePath || '(default)'}`,
92
+ '─'.repeat(70),
93
+ ''
94
+ ];
95
+ for (const msg of detail.messages) {
96
+ const rolePrefix = msg.role === 'user' ? '👤 USER' : '🤖 ASSISTANT';
97
+ lines.push(`${rolePrefix}:`);
98
+ for (const textLine of msg.content.split('\n')) {
99
+ lines.push(` ${textLine}`);
100
+ }
101
+ lines.push('');
102
+ }
103
+ const layer = new TextLayer({
104
+ title: `Preview: ${detail.title}`,
105
+ lines,
106
+ width: 76,
107
+ height: 22
108
+ });
109
+ prompt.openLayer(layer);
110
+ return true;
111
+ }
@@ -0,0 +1,145 @@
1
+ // Continuum TUI Picker: interactive modal dialog for browsing and adopting peer agent sessions.
2
+ // Authorship: Strict TypeScript (Causyne Agent).
3
+
4
+ // @ts-expect-error untyped local TUI dialogs
5
+ import { SelectLayer, TextLayer } from '../../tui/dialogs.js';
6
+ // @ts-expect-error untyped local TUI theme
7
+ import { GLYPHS } from '../../tui/theme.js';
8
+ import type { ContinuumSessionSummary } from '../types.js';
9
+ import { ContinuumScanner } from '../scanner.js';
10
+ import { adoptContinuumSession } from '../ingest.js';
11
+
12
+ function formatTimeAgo(timestamp: number): string {
13
+ const diffMs = Date.now() - timestamp;
14
+ const minutes = Math.floor(diffMs / (60 * 1000));
15
+ if (minutes < 60) return `${Math.max(1, minutes)}m ago`;
16
+ const hours = Math.floor(minutes / 60);
17
+ if (hours < 24) return `${hours}h ago`;
18
+ const days = Math.floor(hours / 24);
19
+ return `${days}d ago`;
20
+ }
21
+
22
+ export function buildContinuumItems(sessions: ContinuumSessionSummary[]) {
23
+ return sessions.map(s => {
24
+ const timeAgo = formatTimeAgo(s.updatedAt);
25
+ const ws = s.workspacePath ? s.workspacePath.split('/').pop() || s.workspacePath : '';
26
+ const desc = `${s.messageCount} msg${s.messageCount === 1 ? '' : 's'} ${GLYPHS.dot} ${timeAgo}${ws ? ` ${GLYPHS.dot} ${ws}` : ''}`;
27
+
28
+ return {
29
+ label: s.title,
30
+ description: desc,
31
+ category: s.sourceLabel,
32
+ hint: s.sourceLabel,
33
+ searchText: `${s.sourceLabel} ${s.title} ${s.workspacePath} ${s.snippet}`,
34
+ value: s
35
+ };
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Launch the interactive Continuum session picker.
41
+ */
42
+ export async function runInteractiveContinuum(
43
+ prompt: { openLayer: (layer: unknown) => void; closeLayer?: () => void },
44
+ options: {
45
+ scanner?: ContinuumScanner;
46
+ loop?: {
47
+ messages: Array<{ role: string; content?: unknown }>;
48
+ memoryManager?: {
49
+ useSession: (id: string) => unknown;
50
+ loadHistory?: () => Array<{ role: string; content?: unknown }>;
51
+ };
52
+ };
53
+ } = {}
54
+ ): Promise<string> {
55
+ const scanner = options.scanner || new ContinuumScanner();
56
+ const sessions = await scanner.scanAllSessions({ limit: 80 });
57
+
58
+ if (sessions.length === 0) {
59
+ return 'No peer agent sessions found across Antigravity, OpenCode, Codex, or Claude Code on this machine.';
60
+ }
61
+
62
+ const items = buildContinuumItems(sessions);
63
+
64
+ const pickedSession = await new Promise<ContinuumSessionSummary | null>((resolve) => {
65
+ const layer = new SelectLayer({
66
+ title: `Continuum · Cross-Agent Sessions (${sessions.length})`,
67
+ placeholder: 'search past agent conversations (antigravity, opencode, codex, claude)...',
68
+ emptyText: 'no matching sessions found',
69
+ width: 78,
70
+ height: 20,
71
+ footer: `enter adopt session ${GLYPHS.dot} esc cancel`,
72
+ items,
73
+ onPick: (item: { value: ContinuumSessionSummary } | null) => {
74
+ resolve(item ? item.value : null);
75
+ }
76
+ });
77
+ prompt.openLayer(layer);
78
+ });
79
+
80
+ if (!pickedSession) {
81
+ return 'Cancelled. Session was not changed.';
82
+ }
83
+
84
+ // Ingest the chosen session
85
+ const adoptRes = await adoptContinuumSession(pickedSession.id, {
86
+ scanner,
87
+ currentLoopMessages: options.loop?.messages
88
+ });
89
+
90
+ if (!adoptRes.ok) {
91
+ return `Failed to adopt session: ${adoptRes.error}`;
92
+ }
93
+
94
+ if (options.loop) {
95
+ if (options.loop.memoryManager) {
96
+ options.loop.memoryManager.useSession(adoptRes.sessionId);
97
+ if (typeof options.loop.memoryManager.loadHistory === 'function') {
98
+ options.loop.messages = options.loop.memoryManager.loadHistory();
99
+ }
100
+ }
101
+ }
102
+
103
+ return `✓ Successfully adopted session "${adoptRes.title}" from ${adoptRes.sourcePlatform.toUpperCase()} (${adoptRes.messageCount} messages compacted).\n New active Causyne session: ${adoptRes.sessionId}. Continue working seamlessly.`;
104
+ }
105
+
106
+ /**
107
+ * Open a preview text modal showing the full conversation transcript for a session.
108
+ */
109
+ export async function openContinuumPreview(
110
+ sessionId: string,
111
+ prompt: { openLayer: (layer: unknown) => void },
112
+ scanner?: ContinuumScanner
113
+ ): Promise<boolean> {
114
+ const sc = scanner || new ContinuumScanner();
115
+ const detail = await sc.fetchSession(sessionId);
116
+
117
+ if (!detail || !detail.messages) {
118
+ return false;
119
+ }
120
+
121
+ const lines: string[] = [
122
+ `Source: ${detail.sourceLabel} · Messages: ${detail.messages.length} · Workspace: ${detail.workspacePath || '(default)'}`,
123
+ '─'.repeat(70),
124
+ ''
125
+ ];
126
+
127
+ for (const msg of detail.messages) {
128
+ const rolePrefix = msg.role === 'user' ? '👤 USER' : '🤖 ASSISTANT';
129
+ lines.push(`${rolePrefix}:`);
130
+ for (const textLine of msg.content.split('\n')) {
131
+ lines.push(` ${textLine}`);
132
+ }
133
+ lines.push('');
134
+ }
135
+
136
+ const layer = new TextLayer({
137
+ title: `Preview: ${detail.title}`,
138
+ lines,
139
+ width: 76,
140
+ height: 22
141
+ });
142
+
143
+ prompt.openLayer(layer);
144
+ return true;
145
+ }
@@ -0,0 +1,2 @@
1
+ export function buildStructuralSummary(...args: any[]): any;
2
+ export function condenseAndSave(...args: any[]): any;
@@ -0,0 +1 @@
1
+ export const cortexDb: any;
@@ -0,0 +1,2 @@
1
+ export function suggestMovements(...args: any[]): any;
2
+ export function formatMovementBrief(...args: any[]): any;
@@ -0,0 +1 @@
1
+ export function isDevEmulator(...args: any[]): any;
@@ -14,8 +14,9 @@ import path from 'node:path';
14
14
  import { execFile } from 'node:child_process';
15
15
  import { promisify } from 'node:util';
16
16
  import { causyneHome } from './utils/paths.js';
17
- import { MODEL_CATALOGUE, PEER_MODEL_CATALOGUE } from './modelCatalogue.js';
17
+ import { MODEL_CATALOGUE, PEER_MODEL_CATALOGUE, DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
18
18
  import { ANTIGRAVITY_MODELS, ANTIGRAVITY_LABEL_BY_ID, resolveAgyBinary } from './providers/antigravity.js';
19
+ import { isBinaryOnPath, BUILTIN_PEER_PRESETS } from './acp/agentCatalog.js';
19
20
  const execFileAsync = promisify(execFile);
20
21
  const CACHE_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
21
22
  const REQUEST_TIMEOUT_MS = 3500; // Fast timeout to never block user interaction
@@ -98,6 +99,144 @@ export function getCuratedModels(provider) {
98
99
  }
99
100
  return [];
100
101
  }
102
+ /**
103
+ * Categorize available providers into BYOK and ACP peer agents,
104
+ * checking configured state for BYOK and installation status for ACP agents.
105
+ */
106
+ export function getAvailableProvidersOverview(config = {}) {
107
+ const currentProvider = config.provider || '';
108
+ const currentModel = config.model || '';
109
+ const byokDefs = [
110
+ {
111
+ id: 'anthropic',
112
+ label: 'Anthropic',
113
+ envVar: 'ANTHROPIC_API_KEY',
114
+ defaultModel: DEFAULT_MODEL_BY_PROVIDER['anthropic'] || 'claude-3-7-sonnet',
115
+ models: MODEL_CATALOGUE['Anthropic'] ? [...MODEL_CATALOGUE['Anthropic']] : []
116
+ },
117
+ {
118
+ id: 'openai',
119
+ label: 'OpenAI',
120
+ envVar: 'OPENAI_API_KEY',
121
+ defaultModel: DEFAULT_MODEL_BY_PROVIDER['openai'] || 'gpt-4o',
122
+ models: MODEL_CATALOGUE['OpenAI'] ? [...MODEL_CATALOGUE['OpenAI']] : []
123
+ },
124
+ {
125
+ id: 'gemini',
126
+ label: 'Google Gemini',
127
+ envVar: 'GEMINI_API_KEY',
128
+ defaultModel: DEFAULT_MODEL_BY_PROVIDER['gemini'] || 'gemini-2.5-pro',
129
+ models: MODEL_CATALOGUE['Gemini'] ? [...MODEL_CATALOGUE['Gemini']] : []
130
+ },
131
+ {
132
+ id: 'deepseek',
133
+ label: 'DeepSeek',
134
+ envVar: 'DEEPSEEK_API_KEY',
135
+ defaultModel: DEFAULT_MODEL_BY_PROVIDER['deepseek'] || 'deepseek-chat',
136
+ models: MODEL_CATALOGUE['DeepSeek'] ? [...MODEL_CATALOGUE['DeepSeek']] : []
137
+ },
138
+ {
139
+ id: 'qwen',
140
+ label: 'Qwen / DashScope',
141
+ envVar: 'DASHSCOPE_API_KEY',
142
+ defaultModel: DEFAULT_MODEL_BY_PROVIDER['qwen'] || 'qwen2.5-coder-32b-instruct',
143
+ models: MODEL_CATALOGUE['Qwen'] ? [...MODEL_CATALOGUE['Qwen']] : []
144
+ },
145
+ {
146
+ id: 'ollama',
147
+ label: 'Ollama (Local Server)',
148
+ defaultModel: DEFAULT_MODEL_BY_PROVIDER['ollama'] || 'llama3.3',
149
+ models: MODEL_CATALOGUE['Ollama (Local)'] ? [...MODEL_CATALOGUE['Ollama (Local)']] : []
150
+ },
151
+ {
152
+ id: 'xai',
153
+ label: 'xAI (Grok)',
154
+ envVar: 'XAI_API_KEY',
155
+ defaultModel: DEFAULT_MODEL_BY_PROVIDER['xai'] || 'grok-3',
156
+ models: MODEL_CATALOGUE['xAI (Grok)'] ? [...MODEL_CATALOGUE['xAI (Grok)']] : []
157
+ },
158
+ {
159
+ id: 'moonshot',
160
+ label: 'Moonshot (Kimi)',
161
+ envVar: 'MOONSHOT_API_KEY',
162
+ defaultModel: DEFAULT_MODEL_BY_PROVIDER['moonshot'] || 'kimi-k3',
163
+ models: MODEL_CATALOGUE['Moonshot (Kimi)'] ? [...MODEL_CATALOGUE['Moonshot (Kimi)']] : []
164
+ }
165
+ ];
166
+ const byok = byokDefs.map((def) => {
167
+ const isCurrent = currentProvider === def.id || (def.id === 'qwen' && currentProvider === 'dashscope-byok');
168
+ const hasStoredKey = Boolean(isCurrent && config.apiKey)
169
+ || Boolean(config.providerKeys && (config.providerKeys[def.id] || (def.id === 'qwen' && config.providerKeys['dashscope-byok'])))
170
+ || Boolean(def.envVar && process.env[def.envVar]);
171
+ const isConfigured = def.id === 'ollama' || hasStoredKey;
172
+ return {
173
+ id: def.id,
174
+ label: def.label,
175
+ isConfigured,
176
+ isCurrent,
177
+ models: def.models,
178
+ defaultModel: def.defaultModel,
179
+ envVar: def.envVar
180
+ };
181
+ });
182
+ const acpPeers = [];
183
+ // Antigravity (special native local provider)
184
+ const hasAgy = Boolean(resolveAgyBinary());
185
+ acpPeers.push({
186
+ id: 'antigravity',
187
+ providerKey: 'antigravity',
188
+ label: 'Google Antigravity (AGY)',
189
+ installed: hasAgy,
190
+ status: hasAgy ? 'ready' : 'not_installed',
191
+ isCurrent: currentProvider === 'antigravity',
192
+ command: 'agy --output-format json',
193
+ models: [...ANTIGRAVITY_MODELS],
194
+ setupInstruction: 'Install Antigravity IDE or agy CLI to enable Google AGY models.'
195
+ });
196
+ // Standard ACP presets
197
+ const presetOrder = ['opencode', 'claude', 'codex', 'gemini', 'cursor', 'hermes', 'qwen', 'copilot', 'kimi', 'goose'];
198
+ for (const presetId of presetOrder) {
199
+ const preset = BUILTIN_PEER_PRESETS[presetId];
200
+ if (!preset)
201
+ continue;
202
+ let installed = false;
203
+ if (preset.id === 'cursor') {
204
+ installed = isBinaryOnPath('cursor-agent') || isBinaryOnPath('cursor');
205
+ }
206
+ else {
207
+ installed = isBinaryOnPath(preset.binaryName);
208
+ }
209
+ const providerKey = `acp/${preset.id}`;
210
+ const isCurrent = currentProvider === providerKey;
211
+ let models = [];
212
+ if (PEER_MODEL_CATALOGUE[preset.id]) {
213
+ models = [...(PEER_MODEL_CATALOGUE[preset.id] || [])];
214
+ }
215
+ else if (DEFAULT_MODEL_BY_PROVIDER[providerKey]) {
216
+ models = [DEFAULT_MODEL_BY_PROVIDER[providerKey]];
217
+ }
218
+ else {
219
+ models = [preset.id];
220
+ }
221
+ acpPeers.push({
222
+ id: preset.id,
223
+ providerKey,
224
+ label: preset.label,
225
+ installed,
226
+ status: installed ? 'ready' : 'not_installed',
227
+ isCurrent,
228
+ command: `${preset.command} ${preset.args.join(' ')}`,
229
+ models,
230
+ setupInstruction: preset.setupInstruction || `Install ${preset.label} CLI on your system.`
231
+ });
232
+ }
233
+ return {
234
+ activeProvider: currentProvider,
235
+ activeModel: currentModel,
236
+ byok,
237
+ acp: acpPeers
238
+ };
239
+ }
101
240
  const MODEL_LIST_TIMEOUT_MS = 8000;
102
241
  const ANSI_ESCAPE = /\u001b\[[0-9;]*[A-Za-z]/g;
103
242
  const PEER_MODEL_COMMANDS = {