@causyne/agent 1.17.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.
- package/package.json +1 -1
- package/src/agentLoop.js +13 -0
- package/src/commands.js +167 -21
- package/src/dynamicCatalogue.js +138 -1
- package/src/dynamicCatalogue.ts +176 -1
- package/src/providers/acp.js +40 -7
- package/src/providers/antigravity.js +48 -7
- package/src/tui/chatRenderer.js +9 -4
- package/src/tui/home.js +25 -24
- package/src/tui/theme.js +4 -0
package/package.json
CHANGED
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/commands.js
CHANGED
|
@@ -20,7 +20,7 @@ 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
24
|
import { DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
|
|
25
25
|
import { isAcpProvider } from './providers/acp.js';
|
|
26
26
|
import {
|
|
@@ -710,68 +710,214 @@ export const COMMANDS = [
|
|
|
710
710
|
complete: () => {
|
|
711
711
|
const config = loadConfig();
|
|
712
712
|
const currentProvider = config.provider || '';
|
|
713
|
-
const
|
|
713
|
+
const overview = getAvailableProvidersOverview(config);
|
|
714
714
|
const items = [
|
|
715
|
-
{ value: 'list', label: 'list', description: '
|
|
715
|
+
{ value: 'list', label: 'list', description: 'overview of all BYOK and ACP models' },
|
|
716
716
|
{ value: 'refresh', label: 'refresh', description: 'poll provider API for live models' }
|
|
717
717
|
];
|
|
718
|
+
|
|
719
|
+
// 1. Models for the active provider
|
|
720
|
+
const curated = getCuratedModels(currentProvider);
|
|
718
721
|
for (const m of curated) {
|
|
719
|
-
items.push({ value: m, label: m, description: currentProvider
|
|
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
|
+
}
|
|
720
766
|
}
|
|
767
|
+
|
|
721
768
|
return items;
|
|
722
769
|
},
|
|
723
770
|
run: async (argv) => {
|
|
724
771
|
const config = loadConfig();
|
|
772
|
+
const overview = getAvailableProvidersOverview(config);
|
|
773
|
+
|
|
725
774
|
if (argv.length === 0) {
|
|
726
|
-
|
|
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'));
|
|
727
801
|
}
|
|
802
|
+
|
|
728
803
|
const first = argv[0].toLowerCase();
|
|
729
804
|
if (first === 'list' || first === 'ls') {
|
|
730
|
-
const targetProvider = argv[1]
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
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
|
|
734
828
|
const lines = [
|
|
735
|
-
|
|
736
|
-
''
|
|
829
|
+
'============================================================',
|
|
830
|
+
'BYOK PROVIDERS (Cloud APIs & Local Endpoints)',
|
|
831
|
+
'============================================================'
|
|
737
832
|
];
|
|
738
|
-
for (const
|
|
739
|
-
const
|
|
740
|
-
lines.push(`
|
|
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('');
|
|
741
840
|
}
|
|
742
|
-
|
|
743
|
-
|
|
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('');
|
|
744
857
|
}
|
|
745
|
-
|
|
746
|
-
lines.push('
|
|
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.');
|
|
747
862
|
return ok(lines.join('\n'));
|
|
748
863
|
}
|
|
864
|
+
|
|
749
865
|
if (first === 'refresh') {
|
|
750
866
|
if (!config.provider) return fail('No provider configured. Run /setup first.');
|
|
751
867
|
const result = await resolveAvailableModels(config.provider, config, true);
|
|
752
868
|
return ok(`Refreshed ${config.provider} models (${result.models.length} available, source: ${result.source}). Run /model list to view.`);
|
|
753
869
|
}
|
|
870
|
+
|
|
754
871
|
const requested = argv.join(' ').trim();
|
|
755
872
|
|
|
756
|
-
//
|
|
757
|
-
// `<peer>/<model>` while an ACP provider is active is a model id, because
|
|
758
|
-
// peer models are namespaced too (opencode/beam-free).
|
|
873
|
+
// Check if user requested an ACP peer
|
|
759
874
|
const acpTarget = requested.match(/^acp\/([a-z0-9_-]+)(?:\/(.+))?$/i);
|
|
760
875
|
if (acpTarget) {
|
|
761
876
|
const peer = acpTarget[1].toLowerCase();
|
|
762
877
|
const nextProvider = `acp/${peer}`;
|
|
878
|
+
const peerInfo = overview.acp.find(p => p.id === peer);
|
|
879
|
+
|
|
763
880
|
if (nextProvider !== config.provider) { config.apiKey = ''; delete config.baseUrl; }
|
|
764
881
|
config.provider = nextProvider;
|
|
765
882
|
config.model = acpTarget[2] || DEFAULT_MODEL_BY_PROVIDER[nextProvider] || peer;
|
|
766
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
|
+
}
|
|
767
893
|
return ok(`Now using ${config.provider} / ${config.model}.`);
|
|
768
894
|
}
|
|
895
|
+
|
|
896
|
+
// If peer model is set while in ACP
|
|
769
897
|
if (isAcpProvider(config.provider) && requested.includes('/')) {
|
|
770
898
|
config.model = requested;
|
|
771
899
|
saveConfig(config);
|
|
772
900
|
return ok(`Now using ${config.provider} / ${config.model}.`);
|
|
773
901
|
}
|
|
774
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
|
+
|
|
775
921
|
const separator = requested.indexOf('/');
|
|
776
922
|
if (separator > 0) {
|
|
777
923
|
const provider = requested.slice(0, separator);
|
package/src/dynamicCatalogue.js
CHANGED
|
@@ -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,142 @@ 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 isConfigured = def.id === 'ollama'
|
|
169
|
+
|| Boolean(isCurrent && config.apiKey)
|
|
170
|
+
|| Boolean(def.envVar && process.env[def.envVar]);
|
|
171
|
+
return {
|
|
172
|
+
id: def.id,
|
|
173
|
+
label: def.label,
|
|
174
|
+
isConfigured,
|
|
175
|
+
isCurrent,
|
|
176
|
+
models: def.models,
|
|
177
|
+
defaultModel: def.defaultModel
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
const acpPeers = [];
|
|
181
|
+
// Antigravity (special native local provider)
|
|
182
|
+
const hasAgy = Boolean(resolveAgyBinary());
|
|
183
|
+
acpPeers.push({
|
|
184
|
+
id: 'antigravity',
|
|
185
|
+
providerKey: 'antigravity',
|
|
186
|
+
label: 'Google Antigravity (AGY)',
|
|
187
|
+
installed: hasAgy,
|
|
188
|
+
status: hasAgy ? 'ready' : 'not_installed',
|
|
189
|
+
isCurrent: currentProvider === 'antigravity',
|
|
190
|
+
command: 'agy --output-format json',
|
|
191
|
+
models: [...ANTIGRAVITY_MODELS],
|
|
192
|
+
setupInstruction: 'Install Antigravity IDE or agy CLI to enable Google AGY models.'
|
|
193
|
+
});
|
|
194
|
+
// Standard ACP presets
|
|
195
|
+
const presetOrder = ['opencode', 'claude', 'codex', 'gemini', 'cursor', 'hermes', 'qwen', 'copilot', 'kimi', 'goose'];
|
|
196
|
+
for (const presetId of presetOrder) {
|
|
197
|
+
const preset = BUILTIN_PEER_PRESETS[presetId];
|
|
198
|
+
if (!preset)
|
|
199
|
+
continue;
|
|
200
|
+
let installed = false;
|
|
201
|
+
if (preset.id === 'cursor') {
|
|
202
|
+
installed = isBinaryOnPath('cursor-agent') || isBinaryOnPath('cursor');
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
installed = isBinaryOnPath(preset.binaryName);
|
|
206
|
+
}
|
|
207
|
+
const providerKey = `acp/${preset.id}`;
|
|
208
|
+
const isCurrent = currentProvider === providerKey;
|
|
209
|
+
let models = [];
|
|
210
|
+
if (PEER_MODEL_CATALOGUE[preset.id]) {
|
|
211
|
+
models = [...(PEER_MODEL_CATALOGUE[preset.id] || [])];
|
|
212
|
+
}
|
|
213
|
+
else if (DEFAULT_MODEL_BY_PROVIDER[providerKey]) {
|
|
214
|
+
models = [DEFAULT_MODEL_BY_PROVIDER[providerKey]];
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
models = [preset.id];
|
|
218
|
+
}
|
|
219
|
+
acpPeers.push({
|
|
220
|
+
id: preset.id,
|
|
221
|
+
providerKey,
|
|
222
|
+
label: preset.label,
|
|
223
|
+
installed,
|
|
224
|
+
status: installed ? 'ready' : 'not_installed',
|
|
225
|
+
isCurrent,
|
|
226
|
+
command: `${preset.command} ${preset.args.join(' ')}`,
|
|
227
|
+
models,
|
|
228
|
+
setupInstruction: preset.setupInstruction || `Install ${preset.label} CLI on your system.`
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
activeProvider: currentProvider,
|
|
233
|
+
activeModel: currentModel,
|
|
234
|
+
byok,
|
|
235
|
+
acp: acpPeers
|
|
236
|
+
};
|
|
237
|
+
}
|
|
101
238
|
const MODEL_LIST_TIMEOUT_MS = 8000;
|
|
102
239
|
const ANSI_ESCAPE = /\u001b\[[0-9;]*[A-Za-z]/g;
|
|
103
240
|
const PEER_MODEL_COMMANDS = {
|
package/src/dynamicCatalogue.ts
CHANGED
|
@@ -15,12 +15,13 @@ import path from 'node:path';
|
|
|
15
15
|
import { execFile } from 'node:child_process';
|
|
16
16
|
import { promisify } from 'node:util';
|
|
17
17
|
import { causyneHome } from './utils/paths.js';
|
|
18
|
-
import { MODEL_CATALOGUE, PEER_MODEL_CATALOGUE } from './modelCatalogue.js';
|
|
18
|
+
import { MODEL_CATALOGUE, PEER_MODEL_CATALOGUE, DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
|
|
19
19
|
import {
|
|
20
20
|
ANTIGRAVITY_MODELS,
|
|
21
21
|
ANTIGRAVITY_LABEL_BY_ID,
|
|
22
22
|
resolveAgyBinary
|
|
23
23
|
} from './providers/antigravity.js';
|
|
24
|
+
import { isBinaryOnPath, BUILTIN_PEER_PRESETS } from './acp/agentCatalog.js';
|
|
24
25
|
|
|
25
26
|
const execFileAsync = promisify(execFile);
|
|
26
27
|
|
|
@@ -103,6 +104,180 @@ export function getCuratedModels(provider: string): string[] {
|
|
|
103
104
|
return [];
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
export interface ByokProviderInfo {
|
|
108
|
+
id: string;
|
|
109
|
+
label: string;
|
|
110
|
+
isConfigured: boolean;
|
|
111
|
+
isCurrent: boolean;
|
|
112
|
+
models: string[];
|
|
113
|
+
defaultModel: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface AcpPeerInfo {
|
|
117
|
+
id: string;
|
|
118
|
+
providerKey: string;
|
|
119
|
+
label: string;
|
|
120
|
+
installed: boolean;
|
|
121
|
+
status: 'ready' | 'not_installed';
|
|
122
|
+
isCurrent: boolean;
|
|
123
|
+
command: string;
|
|
124
|
+
models: string[];
|
|
125
|
+
setupInstruction: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface ProviderOverview {
|
|
129
|
+
activeProvider: string;
|
|
130
|
+
activeModel: string;
|
|
131
|
+
byok: ByokProviderInfo[];
|
|
132
|
+
acp: AcpPeerInfo[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Categorize available providers into BYOK and ACP peer agents,
|
|
137
|
+
* checking configured state for BYOK and installation status for ACP agents.
|
|
138
|
+
*/
|
|
139
|
+
export function getAvailableProvidersOverview(
|
|
140
|
+
config: { provider?: string; apiKey?: string; model?: string } = {}
|
|
141
|
+
): ProviderOverview {
|
|
142
|
+
const currentProvider = config.provider || '';
|
|
143
|
+
const currentModel = config.model || '';
|
|
144
|
+
|
|
145
|
+
const byokDefs: Array<{ id: string; label: string; envVar?: string; defaultModel: string; models: string[] }> = [
|
|
146
|
+
{
|
|
147
|
+
id: 'anthropic',
|
|
148
|
+
label: 'Anthropic',
|
|
149
|
+
envVar: 'ANTHROPIC_API_KEY',
|
|
150
|
+
defaultModel: DEFAULT_MODEL_BY_PROVIDER['anthropic'] || 'claude-3-7-sonnet',
|
|
151
|
+
models: MODEL_CATALOGUE['Anthropic'] ? [...MODEL_CATALOGUE['Anthropic']] : []
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: 'openai',
|
|
155
|
+
label: 'OpenAI',
|
|
156
|
+
envVar: 'OPENAI_API_KEY',
|
|
157
|
+
defaultModel: DEFAULT_MODEL_BY_PROVIDER['openai'] || 'gpt-4o',
|
|
158
|
+
models: MODEL_CATALOGUE['OpenAI'] ? [...MODEL_CATALOGUE['OpenAI']] : []
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: 'gemini',
|
|
162
|
+
label: 'Google Gemini',
|
|
163
|
+
envVar: 'GEMINI_API_KEY',
|
|
164
|
+
defaultModel: DEFAULT_MODEL_BY_PROVIDER['gemini'] || 'gemini-2.5-pro',
|
|
165
|
+
models: MODEL_CATALOGUE['Gemini'] ? [...MODEL_CATALOGUE['Gemini']] : []
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: 'deepseek',
|
|
169
|
+
label: 'DeepSeek',
|
|
170
|
+
envVar: 'DEEPSEEK_API_KEY',
|
|
171
|
+
defaultModel: DEFAULT_MODEL_BY_PROVIDER['deepseek'] || 'deepseek-chat',
|
|
172
|
+
models: MODEL_CATALOGUE['DeepSeek'] ? [...MODEL_CATALOGUE['DeepSeek']] : []
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: 'qwen',
|
|
176
|
+
label: 'Qwen / DashScope',
|
|
177
|
+
envVar: 'DASHSCOPE_API_KEY',
|
|
178
|
+
defaultModel: DEFAULT_MODEL_BY_PROVIDER['qwen'] || 'qwen2.5-coder-32b-instruct',
|
|
179
|
+
models: MODEL_CATALOGUE['Qwen'] ? [...MODEL_CATALOGUE['Qwen']] : []
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: 'ollama',
|
|
183
|
+
label: 'Ollama (Local Server)',
|
|
184
|
+
defaultModel: DEFAULT_MODEL_BY_PROVIDER['ollama'] || 'llama3.3',
|
|
185
|
+
models: MODEL_CATALOGUE['Ollama (Local)'] ? [...MODEL_CATALOGUE['Ollama (Local)']] : []
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: 'xai',
|
|
189
|
+
label: 'xAI (Grok)',
|
|
190
|
+
envVar: 'XAI_API_KEY',
|
|
191
|
+
defaultModel: DEFAULT_MODEL_BY_PROVIDER['xai'] || 'grok-3',
|
|
192
|
+
models: MODEL_CATALOGUE['xAI (Grok)'] ? [...MODEL_CATALOGUE['xAI (Grok)']] : []
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'moonshot',
|
|
196
|
+
label: 'Moonshot (Kimi)',
|
|
197
|
+
envVar: 'MOONSHOT_API_KEY',
|
|
198
|
+
defaultModel: DEFAULT_MODEL_BY_PROVIDER['moonshot'] || 'kimi-k3',
|
|
199
|
+
models: MODEL_CATALOGUE['Moonshot (Kimi)'] ? [...MODEL_CATALOGUE['Moonshot (Kimi)']] : []
|
|
200
|
+
}
|
|
201
|
+
];
|
|
202
|
+
|
|
203
|
+
const byok: ByokProviderInfo[] = byokDefs.map((def) => {
|
|
204
|
+
const isCurrent = currentProvider === def.id || (def.id === 'qwen' && currentProvider === 'dashscope-byok');
|
|
205
|
+
const isConfigured = def.id === 'ollama'
|
|
206
|
+
|| Boolean(isCurrent && config.apiKey)
|
|
207
|
+
|| Boolean(def.envVar && process.env[def.envVar]);
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
id: def.id,
|
|
211
|
+
label: def.label,
|
|
212
|
+
isConfigured,
|
|
213
|
+
isCurrent,
|
|
214
|
+
models: def.models,
|
|
215
|
+
defaultModel: def.defaultModel
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const acpPeers: AcpPeerInfo[] = [];
|
|
220
|
+
|
|
221
|
+
// Antigravity (special native local provider)
|
|
222
|
+
const hasAgy = Boolean(resolveAgyBinary());
|
|
223
|
+
acpPeers.push({
|
|
224
|
+
id: 'antigravity',
|
|
225
|
+
providerKey: 'antigravity',
|
|
226
|
+
label: 'Google Antigravity (AGY)',
|
|
227
|
+
installed: hasAgy,
|
|
228
|
+
status: hasAgy ? 'ready' : 'not_installed',
|
|
229
|
+
isCurrent: currentProvider === 'antigravity',
|
|
230
|
+
command: 'agy --output-format json',
|
|
231
|
+
models: [...ANTIGRAVITY_MODELS],
|
|
232
|
+
setupInstruction: 'Install Antigravity IDE or agy CLI to enable Google AGY models.'
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Standard ACP presets
|
|
236
|
+
const presetOrder = ['opencode', 'claude', 'codex', 'gemini', 'cursor', 'hermes', 'qwen', 'copilot', 'kimi', 'goose'];
|
|
237
|
+
for (const presetId of presetOrder) {
|
|
238
|
+
const preset = BUILTIN_PEER_PRESETS[presetId];
|
|
239
|
+
if (!preset) continue;
|
|
240
|
+
|
|
241
|
+
let installed = false;
|
|
242
|
+
if (preset.id === 'cursor') {
|
|
243
|
+
installed = isBinaryOnPath('cursor-agent') || isBinaryOnPath('cursor');
|
|
244
|
+
} else {
|
|
245
|
+
installed = isBinaryOnPath(preset.binaryName);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const providerKey = `acp/${preset.id}`;
|
|
249
|
+
const isCurrent = currentProvider === providerKey;
|
|
250
|
+
|
|
251
|
+
let models: string[] = [];
|
|
252
|
+
if (PEER_MODEL_CATALOGUE[preset.id]) {
|
|
253
|
+
models = [...(PEER_MODEL_CATALOGUE[preset.id] || [])];
|
|
254
|
+
} else if (DEFAULT_MODEL_BY_PROVIDER[providerKey]) {
|
|
255
|
+
models = [DEFAULT_MODEL_BY_PROVIDER[providerKey]];
|
|
256
|
+
} else {
|
|
257
|
+
models = [preset.id];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
acpPeers.push({
|
|
261
|
+
id: preset.id,
|
|
262
|
+
providerKey,
|
|
263
|
+
label: preset.label,
|
|
264
|
+
installed,
|
|
265
|
+
status: installed ? 'ready' : 'not_installed',
|
|
266
|
+
isCurrent,
|
|
267
|
+
command: `${preset.command} ${preset.args.join(' ')}`,
|
|
268
|
+
models,
|
|
269
|
+
setupInstruction: preset.setupInstruction || `Install ${preset.label} CLI on your system.`
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return {
|
|
274
|
+
activeProvider: currentProvider,
|
|
275
|
+
activeModel: currentModel,
|
|
276
|
+
byok,
|
|
277
|
+
acp: acpPeers
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
106
281
|
const MODEL_LIST_TIMEOUT_MS = 8000;
|
|
107
282
|
const ANSI_ESCAPE = /\u001b\[[0-9;]*[A-Za-z]/g;
|
|
108
283
|
|
package/src/providers/acp.js
CHANGED
|
@@ -62,6 +62,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
62
62
|
|
|
63
63
|
formatConversation(messages, tools = []) {
|
|
64
64
|
const lines = [];
|
|
65
|
+
lines.push(`[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.`);
|
|
66
|
+
|
|
65
67
|
if (tools && tools.length > 0) {
|
|
66
68
|
const toolSummaries = tools.map(t => {
|
|
67
69
|
const name = t.name || t.function?.name || 'unknown';
|
|
@@ -121,6 +123,8 @@ export class AcpProvider extends LLMProvider {
|
|
|
121
123
|
pending = [];
|
|
122
124
|
};
|
|
123
125
|
|
|
126
|
+
pending.push(`[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.`);
|
|
127
|
+
|
|
124
128
|
if (tools && tools.length > 0) {
|
|
125
129
|
const toolSummaries = tools.map(t => {
|
|
126
130
|
const name = t.name || t.function?.name || 'unknown';
|
|
@@ -200,13 +204,15 @@ export class AcpProvider extends LLMProvider {
|
|
|
200
204
|
while ((match = regex.exec(text)) !== null) {
|
|
201
205
|
try {
|
|
202
206
|
const parsed = JSON.parse(match[1].trim());
|
|
203
|
-
|
|
207
|
+
const name = parsed.name || parsed.tool || parsed.function?.name;
|
|
208
|
+
if (name) {
|
|
209
|
+
const rawArgs = parsed.arguments !== undefined ? parsed.arguments : (parsed.parameters !== undefined ? parsed.parameters : (parsed.input !== undefined ? parsed.input : (parsed.function?.arguments || {})));
|
|
204
210
|
calls.push({
|
|
205
211
|
id: `acp_call_${Date.now()}_${index++}`,
|
|
206
212
|
type: 'function',
|
|
207
213
|
function: {
|
|
208
|
-
name
|
|
209
|
-
arguments: typeof
|
|
214
|
+
name,
|
|
215
|
+
arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs || {})
|
|
210
216
|
}
|
|
211
217
|
});
|
|
212
218
|
}
|
|
@@ -214,6 +220,30 @@ export class AcpProvider extends LLMProvider {
|
|
|
214
220
|
// ignore malformed tool_call blocks
|
|
215
221
|
}
|
|
216
222
|
}
|
|
223
|
+
|
|
224
|
+
if (calls.length === 0) {
|
|
225
|
+
const fenceRegex = /```(?:tool_call|json)?\s*(\{[\s\S]*?"name"\s*:\s*[\s\S]*?\})\s*```/g;
|
|
226
|
+
while ((match = fenceRegex.exec(text)) !== null) {
|
|
227
|
+
try {
|
|
228
|
+
const parsed = JSON.parse(match[1].trim());
|
|
229
|
+
const name = parsed.name || parsed.tool || parsed.function?.name;
|
|
230
|
+
if (name) {
|
|
231
|
+
const rawArgs = parsed.arguments !== undefined ? parsed.arguments : (parsed.parameters !== undefined ? parsed.parameters : (parsed.input !== undefined ? parsed.input : (parsed.function?.arguments || {})));
|
|
232
|
+
calls.push({
|
|
233
|
+
id: `acp_call_${Date.now()}_${index++}`,
|
|
234
|
+
type: 'function',
|
|
235
|
+
function: {
|
|
236
|
+
name,
|
|
237
|
+
arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs || {})
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
} catch {
|
|
242
|
+
// ignore
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
217
247
|
return calls;
|
|
218
248
|
}
|
|
219
249
|
|
|
@@ -270,14 +300,17 @@ export class AcpProvider extends LLMProvider {
|
|
|
270
300
|
}
|
|
271
301
|
}
|
|
272
302
|
|
|
273
|
-
|
|
274
|
-
const toolCalls = this.extractToolCalls(
|
|
303
|
+
let rawContent = (result?.text || '').trim();
|
|
304
|
+
const toolCalls = this.extractToolCalls(rawContent);
|
|
305
|
+
|
|
306
|
+
// Strip tool call XML from chat content display
|
|
307
|
+
let content = rawContent.replace(/<tool_call>[\s\S]*?<\/tool_call>/g, '').trim();
|
|
275
308
|
|
|
276
309
|
const response = {
|
|
277
|
-
content: content || `Turn completed by ${this.peerId} over ACP
|
|
310
|
+
content: content || (toolCalls.length > 0 ? '' : `Turn completed by ${this.peerId} over ACP.`),
|
|
278
311
|
usage: {
|
|
279
312
|
promptTokens: Math.ceil(promptText.length / 4),
|
|
280
|
-
completionTokens: Math.ceil(
|
|
313
|
+
completionTokens: Math.ceil(rawContent.length / 4),
|
|
281
314
|
cachedPromptTokens: 0
|
|
282
315
|
}
|
|
283
316
|
};
|
|
@@ -85,6 +85,8 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
85
85
|
|
|
86
86
|
formatConversation(messages, tools = []) {
|
|
87
87
|
const lines = [];
|
|
88
|
+
lines.push(`[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.`);
|
|
89
|
+
|
|
88
90
|
if (tools && tools.length > 0) {
|
|
89
91
|
const toolSummaries = tools.map(t => {
|
|
90
92
|
const name = t.name || t.function?.name || 'unknown';
|
|
@@ -137,13 +139,15 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
137
139
|
while ((match = regex.exec(text)) !== null) {
|
|
138
140
|
try {
|
|
139
141
|
const parsed = JSON.parse(match[1].trim());
|
|
140
|
-
|
|
142
|
+
const name = parsed.name || parsed.tool || parsed.function?.name;
|
|
143
|
+
if (name) {
|
|
144
|
+
const rawArgs = parsed.arguments !== undefined ? parsed.arguments : (parsed.parameters !== undefined ? parsed.parameters : (parsed.input !== undefined ? parsed.input : (parsed.function?.arguments || {})));
|
|
141
145
|
calls.push({
|
|
142
146
|
id: `agy_call_${Date.now()}_${index++}`,
|
|
143
147
|
type: 'function',
|
|
144
148
|
function: {
|
|
145
|
-
name
|
|
146
|
-
arguments: typeof
|
|
149
|
+
name,
|
|
150
|
+
arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs || {})
|
|
147
151
|
}
|
|
148
152
|
});
|
|
149
153
|
}
|
|
@@ -151,6 +155,30 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
151
155
|
// ignore malformed tool_call blocks
|
|
152
156
|
}
|
|
153
157
|
}
|
|
158
|
+
|
|
159
|
+
if (calls.length === 0) {
|
|
160
|
+
const fenceRegex = /```(?:tool_call|json)?\s*(\{[\s\S]*?"name"\s*:\s*[\s\S]*?\})\s*```/g;
|
|
161
|
+
while ((match = fenceRegex.exec(text)) !== null) {
|
|
162
|
+
try {
|
|
163
|
+
const parsed = JSON.parse(match[1].trim());
|
|
164
|
+
const name = parsed.name || parsed.tool || parsed.function?.name;
|
|
165
|
+
if (name) {
|
|
166
|
+
const rawArgs = parsed.arguments !== undefined ? parsed.arguments : (parsed.parameters !== undefined ? parsed.parameters : (parsed.input !== undefined ? parsed.input : (parsed.function?.arguments || {})));
|
|
167
|
+
calls.push({
|
|
168
|
+
id: `agy_call_${Date.now()}_${index++}`,
|
|
169
|
+
type: 'function',
|
|
170
|
+
function: {
|
|
171
|
+
name,
|
|
172
|
+
arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs || {})
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
} catch {
|
|
177
|
+
// ignore
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
154
182
|
return calls;
|
|
155
183
|
}
|
|
156
184
|
|
|
@@ -175,6 +203,7 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
175
203
|
const args = [
|
|
176
204
|
'--output-format',
|
|
177
205
|
'json',
|
|
206
|
+
'--dangerously-skip-permissions',
|
|
178
207
|
'--model',
|
|
179
208
|
resolveAgyModelId(this.model),
|
|
180
209
|
`-p=${promptText}`
|
|
@@ -215,15 +244,27 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
215
244
|
return;
|
|
216
245
|
}
|
|
217
246
|
|
|
218
|
-
|
|
219
|
-
const toolCalls = this.extractToolCalls(
|
|
247
|
+
let rawContent = (parsed.response || '').trim();
|
|
248
|
+
const toolCalls = this.extractToolCalls(rawContent);
|
|
249
|
+
|
|
250
|
+
// Strip tool call tags from prose so raw XML does not leak into chat display
|
|
251
|
+
let content = rawContent.replace(/<tool_call>[\s\S]*?<\/tool_call>/g, '').trim();
|
|
252
|
+
|
|
253
|
+
// If content is empty and denied_actions is present, describe it
|
|
254
|
+
if (!content && Array.isArray(parsed.denied_actions) && parsed.denied_actions.length > 0) {
|
|
255
|
+
content = `Antigravity attempted action: ${parsed.denied_actions.map(a => a.display_name || a.action).join(', ')}`;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (!content && toolCalls.length === 0) {
|
|
259
|
+
content = 'Turn completed by Antigravity Agent.';
|
|
260
|
+
}
|
|
220
261
|
|
|
221
262
|
const promptTokens = Number(parsed.usage?.input_tokens) || Math.ceil(promptText.length / 4);
|
|
222
|
-
const completionTokens = Number(parsed.usage?.output_tokens) || Math.ceil(
|
|
263
|
+
const completionTokens = Number(parsed.usage?.output_tokens) || Math.ceil(rawContent.length / 4);
|
|
223
264
|
const thinkingTokens = Number(parsed.usage?.thinking_tokens) || 0;
|
|
224
265
|
|
|
225
266
|
const response = {
|
|
226
|
-
content: content || 'Turn completed by Antigravity Agent.',
|
|
267
|
+
content: content || (toolCalls.length > 0 ? '' : 'Turn completed by Antigravity Agent.'),
|
|
227
268
|
usage: {
|
|
228
269
|
promptTokens,
|
|
229
270
|
completionTokens: completionTokens + thinkingTokens,
|
package/src/tui/chatRenderer.js
CHANGED
|
@@ -95,7 +95,9 @@ function renderMarkdown(text, width) {
|
|
|
95
95
|
continue;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
const trimmed = line.trim();
|
|
99
|
+
if (trimmed === '') { lines.push(''); continue; }
|
|
100
|
+
if (trimmed === '[' || trimmed === ']') continue;
|
|
99
101
|
for (const part of wrap(inline(line), width)) lines.push(part);
|
|
100
102
|
}
|
|
101
103
|
|
|
@@ -121,7 +123,7 @@ function renderMarkdown(text, width) {
|
|
|
121
123
|
// A bare URL, allowing one level of balanced parentheses so a link to
|
|
122
124
|
// `.../URL_(disambiguation)` is not cut at the first `)`.
|
|
123
125
|
const BARE_URL = /https?:\/\/[^\s<>()\[\]"'`]+(?:\([^\s<>()"'`]*\)[^\s<>()\[\]"'`]*)*/g;
|
|
124
|
-
const MD_LINK = /\[([^\]\n]{1,80})\]\((https
|
|
126
|
+
const MD_LINK = /\[([^\]\n]{1,80})\]\(((?:https?|file):\/\/[^\s)]+(?:\([^\s)]*\)[^\s)]*)*)\)/g;
|
|
125
127
|
|
|
126
128
|
// The longest label a link may show. Anything longer would reach wrap()'s
|
|
127
129
|
// hard-split branch, which cuts a long unbroken token by column — and cutting
|
|
@@ -144,7 +146,7 @@ function trimUrlPunctuation(url) {
|
|
|
144
146
|
|
|
145
147
|
/** `https://docs.example.com/a/very/long/path?x=1` → `docs.example.com/a/…`. */
|
|
146
148
|
function compactUrlLabel(url) {
|
|
147
|
-
let label = url.replace(/^https
|
|
149
|
+
let label = url.replace(/^(?:https?|file):\/\//, '').replace(/\/$/, '');
|
|
148
150
|
if (label.length > MAX_LINK_LABEL) label = label.slice(0, MAX_LINK_LABEL - 1) + GLYPHS.ellipsis;
|
|
149
151
|
return label;
|
|
150
152
|
}
|
|
@@ -186,7 +188,10 @@ function inline(text) {
|
|
|
186
188
|
});
|
|
187
189
|
} else {
|
|
188
190
|
// No OSC 8 here, so a markdown link must still show where it points.
|
|
189
|
-
out = out.replace(MD_LINK, (whole, label, url) =>
|
|
191
|
+
out = out.replace(MD_LINK, (whole, label, url) => {
|
|
192
|
+
if (url.startsWith('file:')) return label;
|
|
193
|
+
return `${label} (${url})`;
|
|
194
|
+
});
|
|
190
195
|
}
|
|
191
196
|
|
|
192
197
|
out = HAS_COLOR
|
package/src/tui/home.js
CHANGED
|
@@ -5,7 +5,8 @@ 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
7
|
import { isAcpProvider } from '../providers/acp.js';
|
|
8
|
-
import { isAntigravityProvider } from '../providers/antigravity.js';
|
|
8
|
+
import { isAntigravityProvider, resolveAgyBinary } from '../providers/antigravity.js';
|
|
9
|
+
import { isBinaryOnPath } from '../acp/agentCatalog.js';
|
|
9
10
|
|
|
10
11
|
/** Local runtime and provider summary. */
|
|
11
12
|
export function homeStatusLine(arg = {}) {
|
|
@@ -135,29 +136,29 @@ export { badge };
|
|
|
135
136
|
|
|
136
137
|
// stale values again. Labels and hints stay local because they are terminal UI.
|
|
137
138
|
export const PROVIDERS = [
|
|
138
|
-
{ id: 'deepseek', label: 'DeepSeek', hint: 'recommended for STEM' },
|
|
139
|
-
{ id: 'qwen', label: 'Qwen / Alibaba Cloud', hint: 'fastest' },
|
|
140
|
-
{ id: 'dashscope-byok', label: 'Alibaba DashScope', hint: 'multi-model gateway' },
|
|
141
|
-
{ id: 'muse', label: 'Meta Model API', hint: 'Muse Spark · 1M context' },
|
|
142
|
-
{ id: 'anthropic', label: 'Anthropic', hint: 'Claude' },
|
|
143
|
-
{ id: 'openai', label: 'OpenAI', hint: 'GPT' },
|
|
144
|
-
{ id: 'gemini', label: 'Gemini', hint: 'Google' },
|
|
145
|
-
{ id: 'moonshot', label: 'Moonshot', hint: 'Kimi' },
|
|
146
|
-
{ id: 'xai', label: 'xAI', hint: 'Grok' },
|
|
147
|
-
{ id: 'openai-compatible', label: 'OpenAI-compatible endpoint', hint: 'custom base URL' },
|
|
148
|
-
{ id: 'ollama', label: 'Ollama', hint: 'local / offline' },
|
|
149
|
-
{ id: 'antigravity', label: 'Google Antigravity (AGY)', hint: 'local AGY · Gemini & Claude
|
|
150
|
-
{ id: 'acp/opencode', label: 'OpenCode', hint: 'ACP · free models
|
|
151
|
-
{ id: 'acp/claude', label: 'Claude Code', hint: 'ACP ·
|
|
152
|
-
{ id: 'acp/codex', label: 'Codex CLI', hint: 'ACP ·
|
|
153
|
-
{ id: 'acp/gemini', label: 'Gemini CLI', hint: 'ACP ·
|
|
154
|
-
{ id: 'acp/cursor', label: 'Cursor CLI', hint: 'ACP ·
|
|
155
|
-
{ id: 'acp/qwen', label: 'Qwen Code', hint: 'ACP · DashScope login' },
|
|
156
|
-
{ id: 'acp/copilot', label: 'GitHub Copilot CLI', hint: 'ACP ·
|
|
157
|
-
{ id: 'acp/kimi', label: 'Kimi CLI', hint: 'ACP · Moonshot login' },
|
|
158
|
-
{ id: 'acp/goose', label: 'Goose', hint: 'ACP ·
|
|
159
|
-
{ id: 'acp/hermes', label: 'Hermes Agent', hint: 'ACP · Nous Research' },
|
|
160
|
-
{ id: 'acp', label: 'ACP peer agent (custom)', hint: 'any ACP-compatible CLI' }
|
|
139
|
+
{ id: 'deepseek', label: 'DeepSeek', hint: 'recommended for STEM', category: 'BYOK (Cloud API)' },
|
|
140
|
+
{ id: 'qwen', label: 'Qwen / Alibaba Cloud', hint: 'fastest', category: 'BYOK (Cloud API)' },
|
|
141
|
+
{ id: 'dashscope-byok', label: 'Alibaba DashScope', hint: 'multi-model gateway', category: 'BYOK (Cloud API)' },
|
|
142
|
+
{ id: 'muse', label: 'Meta Model API', hint: 'Muse Spark · 1M context', category: 'BYOK (Cloud API)' },
|
|
143
|
+
{ id: 'anthropic', label: 'Anthropic', hint: 'Claude', category: 'BYOK (Cloud API)' },
|
|
144
|
+
{ id: 'openai', label: 'OpenAI', hint: 'GPT', category: 'BYOK (Cloud API)' },
|
|
145
|
+
{ id: 'gemini', label: 'Gemini', hint: 'Google', category: 'BYOK (Cloud API)' },
|
|
146
|
+
{ id: 'moonshot', label: 'Moonshot', hint: 'Kimi', category: 'BYOK (Cloud API)' },
|
|
147
|
+
{ id: 'xai', label: 'xAI', hint: 'Grok', category: 'BYOK (Cloud API)' },
|
|
148
|
+
{ id: 'openai-compatible', label: 'OpenAI-compatible endpoint', hint: 'custom base URL', category: 'BYOK (Custom)' },
|
|
149
|
+
{ id: 'ollama', label: 'Ollama', hint: 'local / offline', category: 'BYOK (Local Server)' },
|
|
150
|
+
{ id: 'antigravity', label: 'Google Antigravity (AGY)', hint: resolveAgyBinary() ? 'local AGY · Gemini & Claude (ready)' : 'local AGY · (not installed)', category: 'ACP (Peer Agent)' },
|
|
151
|
+
{ id: 'acp/opencode', label: 'OpenCode', hint: isBinaryOnPath('opencode') ? 'ACP · free models (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
152
|
+
{ id: 'acp/claude', label: 'Claude Code', hint: isBinaryOnPath('claude') ? 'ACP · Anthropic subscription (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
153
|
+
{ id: 'acp/codex', label: 'Codex CLI', hint: isBinaryOnPath('codex') ? 'ACP · OpenAI login (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
154
|
+
{ id: 'acp/gemini', label: 'Gemini CLI', hint: isBinaryOnPath('gemini') ? 'ACP · Google login (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
155
|
+
{ id: 'acp/cursor', label: 'Cursor CLI', hint: (isBinaryOnPath('cursor-agent') || isBinaryOnPath('cursor')) ? 'ACP · Cursor subscription (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
156
|
+
{ id: 'acp/qwen', label: 'Qwen Code', hint: isBinaryOnPath('qwen') ? 'ACP · DashScope login (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
157
|
+
{ id: 'acp/copilot', label: 'GitHub Copilot CLI', hint: isBinaryOnPath('copilot') ? 'ACP · Copilot subscription (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
158
|
+
{ id: 'acp/kimi', label: 'Kimi CLI', hint: isBinaryOnPath('kimi') ? 'ACP · Moonshot login (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
159
|
+
{ id: 'acp/goose', label: 'Goose', hint: isBinaryOnPath('goose') ? 'ACP · configured providers (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
160
|
+
{ id: 'acp/hermes', label: 'Hermes Agent', hint: isBinaryOnPath('hermes') ? 'ACP · Nous Research (ready)' : 'ACP · (not installed)', category: 'ACP (Peer Agent)' },
|
|
161
|
+
{ id: 'acp', label: 'ACP peer agent (custom)', hint: 'any ACP-compatible CLI', category: 'ACP (Custom)' }
|
|
161
162
|
].map((entry) => ({ ...entry, model: DEFAULT_MODEL_BY_PROVIDER[entry.id] ?? '' }));
|
|
162
163
|
|
|
163
164
|
/** Run the shared setup transaction inside the existing prompt. */
|
package/src/tui/theme.js
CHANGED
|
@@ -347,6 +347,10 @@ export function safeLink(text, url) {
|
|
|
347
347
|
} catch (e) {
|
|
348
348
|
return String(text);
|
|
349
349
|
}
|
|
350
|
+
if (parsed.protocol === 'file:') {
|
|
351
|
+
const safeUrl = encodeURI(parsed.href).replace(/[\x00-\x1f\x7f]/g, '');
|
|
352
|
+
return `\x1b]8;;${safeUrl}\x1b\\${text}\x1b]8;;\x1b\\`;
|
|
353
|
+
}
|
|
350
354
|
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return String(text);
|
|
351
355
|
if (!parsed.hostname) return String(text);
|
|
352
356
|
|