@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.
- package/docs/ARCHITECTURE.md +11 -4
- package/package.json +1 -1
- package/src/acp/agentCatalog.js +34 -1
- package/src/acp/agentCatalog.ts +35 -1
- package/src/acp/client.js +2 -2
- package/src/acp/client.ts +2 -2
- package/src/agentLoop.js +13 -0
- package/src/cliMode.js +4 -1
- package/src/commands.js +200 -16
- package/src/config.js +73 -0
- package/src/dynamicCatalogue.js +240 -3
- package/src/dynamicCatalogue.ts +276 -3
- package/src/modelCatalogue.d.ts +1 -0
- package/src/modelCatalogue.js +51 -1
- package/src/providers/acp.js +328 -0
- package/src/providers/antigravity.d.ts +9 -0
- package/src/providers/antigravity.js +313 -0
- package/src/providers/factory.js +4 -0
- package/src/reporting.js +3 -1
- package/src/tokenTracker.js +19 -4
- package/src/tools/peerAgent.js +35 -0
- package/src/tools/peerAgent.ts +34 -0
- package/src/tui/banner.js +7 -1
- package/src/tui/banner.ts +7 -1
- package/src/tui/chatRenderer.js +9 -4
- package/src/tui/home.js +29 -13
- package/src/tui/setup.js +34 -2
- package/src/tui/setup.ts +36 -3
- package/src/tui/theme.js +4 -0
package/src/tokenTracker.js
CHANGED
|
@@ -144,6 +144,14 @@ export class TokenTracker {
|
|
|
144
144
|
if (provider === 'ollama') {
|
|
145
145
|
return [0.00, 0.00];
|
|
146
146
|
}
|
|
147
|
+
|
|
148
|
+
// Peer agents (ACP) and Antigravity bill through the user's own CLI login —
|
|
149
|
+
// a subscription or a free quota Causyne never sees an invoice for. Showing
|
|
150
|
+
// a BYOK rate here would invent a cost the user does not owe, and the cost
|
|
151
|
+
// counter is read as a bill.
|
|
152
|
+
if (provider === 'acp' || provider.startsWith('acp/') || provider === 'antigravity' || provider === 'agy') {
|
|
153
|
+
return [0.00, 0.00];
|
|
154
|
+
}
|
|
147
155
|
|
|
148
156
|
return [5.00, 15.00]; // Unknown BYOK provider fallback
|
|
149
157
|
}
|
|
@@ -242,6 +250,9 @@ export class TokenTracker {
|
|
|
242
250
|
if (p === 'pollinations' || p === 'local') {
|
|
243
251
|
return 0.00; // Free Mode D / Mode A
|
|
244
252
|
}
|
|
253
|
+
if (p === 'acp' || p.startsWith('acp/') || p === 'antigravity' || p === 'agy') {
|
|
254
|
+
return 0.00; // billed by the peer's own subscription, not by Causyne
|
|
255
|
+
}
|
|
245
256
|
return 0.03; // Default generic media cost
|
|
246
257
|
}
|
|
247
258
|
|
|
@@ -258,15 +269,16 @@ export class TokenTracker {
|
|
|
258
269
|
this.taskTokens += equivalentTokens;
|
|
259
270
|
this.taskCostUsd += cost;
|
|
260
271
|
|
|
261
|
-
|
|
262
|
-
|
|
272
|
+
// Read the cumulative total before writing today's file. getCumulativeUsage()
|
|
273
|
+
// backfills from the daily files when its own file is missing, so loading it
|
|
274
|
+
// after the daily increment counted this same call twice.
|
|
275
|
+
const cumulative = await this.getCumulativeUsage();
|
|
263
276
|
const daily = await this.getDailyUsage();
|
|
264
277
|
daily.totalTokens += equivalentTokens;
|
|
265
278
|
daily.totalCalls += 1;
|
|
266
279
|
daily.totalCostUsd = (daily.totalCostUsd || 0) + cost;
|
|
267
280
|
await this.saveDailyUsage(daily);
|
|
268
281
|
|
|
269
|
-
const cumulative = await this.getCumulativeUsage();
|
|
270
282
|
cumulative.totalTokens += equivalentTokens;
|
|
271
283
|
cumulative.totalCalls += 1;
|
|
272
284
|
cumulative.totalCostUsd = (cumulative.totalCostUsd || 0) + cost;
|
|
@@ -500,13 +512,16 @@ export class TokenTracker {
|
|
|
500
512
|
// pass firing concurrently with the loop silently subtracts its own tokens
|
|
501
513
|
// from the day's total.
|
|
502
514
|
const { daily, cumulative } = await withUsageLock(async () => {
|
|
515
|
+
// getCumulativeUsage() backfills from the daily files when its own file is
|
|
516
|
+
// missing, so it must be read before today's increment is written or the
|
|
517
|
+
// very first call of a fresh install is counted twice.
|
|
518
|
+
const cumulative = await this.getCumulativeUsage();
|
|
503
519
|
const daily = await this.getDailyUsage();
|
|
504
520
|
daily.totalTokens += total;
|
|
505
521
|
daily.totalCalls += 1;
|
|
506
522
|
daily.totalCostUsd = (daily.totalCostUsd || 0) + cost;
|
|
507
523
|
await this.saveDailyUsage(daily);
|
|
508
524
|
|
|
509
|
-
const cumulative = await this.getCumulativeUsage();
|
|
510
525
|
cumulative.totalTokens += total;
|
|
511
526
|
cumulative.totalCalls += 1;
|
|
512
527
|
cumulative.totalCostUsd = (cumulative.totalCostUsd || 0) + cost;
|
package/src/tools/peerAgent.js
CHANGED
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
* Those come from the catalog presets or the user's `~/.causyne/peers.json`.
|
|
8
8
|
*/
|
|
9
9
|
import path from 'node:path';
|
|
10
|
+
import { execFile } from 'node:child_process';
|
|
11
|
+
import { promisify } from 'node:util';
|
|
10
12
|
import { AcpClient } from '../acp/client.js';
|
|
11
13
|
import { getPeerProfile, listAllPeers, peerEnvironment } from '../acp/peerProfiles.js';
|
|
12
14
|
import { BUILTIN_PEER_PRESETS } from '../acp/agentCatalog.js';
|
|
15
|
+
const execFileAsync = promisify(execFile);
|
|
13
16
|
const MAX_PROMPT_CHARS = 100_000;
|
|
14
17
|
const READ_ONLY_KINDS = new Set(['read', 'search', 'fetch', 'think']);
|
|
15
18
|
function selectPermission(profile, request, workspaceRoot) {
|
|
@@ -123,6 +126,38 @@ export const peerAgentTool = {
|
|
|
123
126
|
: profile.timeoutSeconds;
|
|
124
127
|
const timeoutSeconds = Math.max(5, Math.min(Math.min(profile.timeoutSeconds, requestedTimeout), 1800));
|
|
125
128
|
const workspaceRoot = profile.cwd || process.cwd();
|
|
129
|
+
if (peerId.toLowerCase() === 'antigravity') {
|
|
130
|
+
try {
|
|
131
|
+
const agyModel = args.model || 'Gemini 3.8 Flash (Low)';
|
|
132
|
+
const { stdout } = await execFileAsync(profile.command, [
|
|
133
|
+
'--output-format',
|
|
134
|
+
'json',
|
|
135
|
+
`--model=${agyModel}`,
|
|
136
|
+
`-p=${prompt}`
|
|
137
|
+
], {
|
|
138
|
+
cwd: workspaceRoot,
|
|
139
|
+
timeout: timeoutSeconds * 1000
|
|
140
|
+
});
|
|
141
|
+
let outputText = stdout.trim();
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(outputText);
|
|
144
|
+
if (parsed.response)
|
|
145
|
+
outputText = parsed.response.trim();
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// keep raw stdout
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
success: true,
|
|
152
|
+
agent: 'Google Antigravity',
|
|
153
|
+
output: outputText
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
158
|
+
return { success: false, agent: 'Google Antigravity', error: msg };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
126
161
|
const client = new AcpClient({
|
|
127
162
|
command: profile.command,
|
|
128
163
|
args: profile.args,
|
package/src/tools/peerAgent.ts
CHANGED
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import path from 'node:path';
|
|
11
|
+
import { execFile } from 'node:child_process';
|
|
12
|
+
import { promisify } from 'node:util';
|
|
11
13
|
import { AcpClient } from '../acp/client.js';
|
|
12
14
|
import type { RequestPermissionRequest, RequestPermissionResponse } from '../acp/protocol.js';
|
|
13
15
|
import { getPeerProfile, listAllPeers, peerEnvironment } from '../acp/peerProfiles.js';
|
|
14
16
|
import type { PeerProfile } from '../acp/peerProfiles.js';
|
|
15
17
|
import { BUILTIN_PEER_PRESETS } from '../acp/agentCatalog.js';
|
|
16
18
|
|
|
19
|
+
const execFileAsync = promisify(execFile);
|
|
20
|
+
|
|
17
21
|
export interface PeerAgentArgs {
|
|
18
22
|
action?: 'delegate' | 'list' | 'status';
|
|
19
23
|
peer?: string;
|
|
@@ -162,6 +166,36 @@ export const peerAgentTool = {
|
|
|
162
166
|
|
|
163
167
|
const workspaceRoot = profile.cwd || process.cwd();
|
|
164
168
|
|
|
169
|
+
if (peerId.toLowerCase() === 'antigravity') {
|
|
170
|
+
try {
|
|
171
|
+
const agyModel = args.model || 'Gemini 3.8 Flash (Low)';
|
|
172
|
+
const { stdout } = await execFileAsync(profile.command, [
|
|
173
|
+
'--output-format',
|
|
174
|
+
'json',
|
|
175
|
+
`--model=${agyModel}`,
|
|
176
|
+
`-p=${prompt}`
|
|
177
|
+
], {
|
|
178
|
+
cwd: workspaceRoot,
|
|
179
|
+
timeout: timeoutSeconds * 1000
|
|
180
|
+
});
|
|
181
|
+
let outputText = stdout.trim();
|
|
182
|
+
try {
|
|
183
|
+
const parsed = JSON.parse(outputText);
|
|
184
|
+
if (parsed.response) outputText = parsed.response.trim();
|
|
185
|
+
} catch {
|
|
186
|
+
// keep raw stdout
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
success: true,
|
|
190
|
+
agent: 'Google Antigravity',
|
|
191
|
+
output: outputText
|
|
192
|
+
};
|
|
193
|
+
} catch (err: unknown) {
|
|
194
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
195
|
+
return { success: false, agent: 'Google Antigravity', error: msg };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
165
199
|
const client = new AcpClient({
|
|
166
200
|
command: profile.command,
|
|
167
201
|
args: profile.args,
|
package/src/tui/banner.js
CHANGED
|
@@ -315,7 +315,13 @@ export function providerLabel(provider) {
|
|
|
315
315
|
openai: 'OpenAI', anthropic: 'Anthropic', gemini: 'Gemini', ollama: 'Ollama',
|
|
316
316
|
deepseek: 'DeepSeek', dashscope: 'DashScope', 'dashscope-byok': 'DashScope',
|
|
317
317
|
qwen: 'Qwen', xai: 'xAI', grok: 'xAI', moonshot: 'Moonshot', kimi: 'Moonshot',
|
|
318
|
-
muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible'
|
|
318
|
+
muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible',
|
|
319
|
+
acp: 'ACP', antigravity: 'Antigravity', agy: 'Antigravity',
|
|
320
|
+
'acp/opencode': 'OpenCode (ACP)', 'acp/claude': 'Claude Code (ACP)',
|
|
321
|
+
'acp/codex': 'Codex (ACP)', 'acp/gemini': 'Gemini CLI (ACP)',
|
|
322
|
+
'acp/cursor': 'Cursor (ACP)', 'acp/qwen': 'Qwen Code (ACP)',
|
|
323
|
+
'acp/copilot': 'Copilot (ACP)', 'acp/kimi': 'Kimi (ACP)',
|
|
324
|
+
'acp/goose': 'Goose (ACP)', 'acp/hermes': 'Hermes (ACP)'
|
|
319
325
|
};
|
|
320
326
|
return known[raw.toLowerCase()] ?? raw;
|
|
321
327
|
}
|
package/src/tui/banner.ts
CHANGED
|
@@ -313,7 +313,13 @@ export function providerLabel(provider: unknown): string {
|
|
|
313
313
|
openai: 'OpenAI', anthropic: 'Anthropic', gemini: 'Gemini', ollama: 'Ollama',
|
|
314
314
|
deepseek: 'DeepSeek', dashscope: 'DashScope', 'dashscope-byok': 'DashScope',
|
|
315
315
|
qwen: 'Qwen', xai: 'xAI', grok: 'xAI', moonshot: 'Moonshot', kimi: 'Moonshot',
|
|
316
|
-
muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible'
|
|
316
|
+
muse: 'Meta', meta: 'Meta', 'openai-compatible': 'OpenAI-compatible',
|
|
317
|
+
acp: 'ACP', antigravity: 'Antigravity', agy: 'Antigravity',
|
|
318
|
+
'acp/opencode': 'OpenCode (ACP)', 'acp/claude': 'Claude Code (ACP)',
|
|
319
|
+
'acp/codex': 'Codex (ACP)', 'acp/gemini': 'Gemini CLI (ACP)',
|
|
320
|
+
'acp/cursor': 'Cursor (ACP)', 'acp/qwen': 'Qwen Code (ACP)',
|
|
321
|
+
'acp/copilot': 'Copilot (ACP)', 'acp/kimi': 'Kimi (ACP)',
|
|
322
|
+
'acp/goose': 'Goose (ACP)', 'acp/hermes': 'Hermes (ACP)'
|
|
317
323
|
};
|
|
318
324
|
return known[raw.toLowerCase()] ?? raw;
|
|
319
325
|
}
|
package/src/tui/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
|
@@ -4,14 +4,18 @@ import { SelectLayer, InputLayer } from './dialogs.js';
|
|
|
4
4
|
import { paint, dim, bold, badge, GLYPHS } from './theme.js';
|
|
5
5
|
import { runSetup } from './setup.js';
|
|
6
6
|
import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
7
|
+
import { isAcpProvider } from '../providers/acp.js';
|
|
8
|
+
import { isAntigravityProvider, resolveAgyBinary } from '../providers/antigravity.js';
|
|
9
|
+
import { isBinaryOnPath } from '../acp/agentCatalog.js';
|
|
7
10
|
|
|
8
11
|
/** Local runtime and provider summary. */
|
|
9
|
-
export function homeStatusLine(
|
|
12
|
+
export function homeStatusLine(arg = {}) {
|
|
13
|
+
const config = arg?.config || arg || {};
|
|
10
14
|
const hasProvider = Boolean(config.provider && config.provider !== 'unconfigured');
|
|
11
15
|
const model = hasProvider
|
|
12
16
|
? (config.model ? `${config.provider}/${config.model}` : config.provider)
|
|
13
17
|
: 'no provider configured';
|
|
14
|
-
const configured = Boolean((hasProvider && config.apiKey) || config.provider === 'ollama');
|
|
18
|
+
const configured = Boolean((hasProvider && config.apiKey) || config.provider === 'ollama' || isAcpProvider(config.provider) || isAntigravityProvider(config.provider));
|
|
15
19
|
return ' ' + [
|
|
16
20
|
paint('success', `${GLYPHS.bullet} local desktop`),
|
|
17
21
|
configured
|
|
@@ -132,17 +136,29 @@ export { badge };
|
|
|
132
136
|
|
|
133
137
|
// stale values again. Labels and hints stay local because they are terminal UI.
|
|
134
138
|
export const PROVIDERS = [
|
|
135
|
-
{ id: 'deepseek', label: 'DeepSeek', hint: 'recommended for STEM' },
|
|
136
|
-
{ id: 'qwen', label: 'Qwen / Alibaba Cloud', hint: 'fastest' },
|
|
137
|
-
{ id: 'dashscope-byok', label: 'Alibaba DashScope', hint: 'multi-model gateway' },
|
|
138
|
-
{ id: 'muse', label: 'Meta Model API', hint: 'Muse Spark · 1M context' },
|
|
139
|
-
{ id: 'anthropic', label: 'Anthropic', hint: 'Claude' },
|
|
140
|
-
{ id: 'openai', label: 'OpenAI', hint: 'GPT' },
|
|
141
|
-
{ id: 'gemini', label: 'Gemini', hint: 'Google' },
|
|
142
|
-
{ id: 'moonshot', label: 'Moonshot', hint: 'Kimi' },
|
|
143
|
-
{ id: 'xai', label: 'xAI', hint: 'Grok' },
|
|
144
|
-
{ id: 'openai-compatible', label: 'OpenAI-compatible endpoint', hint: 'custom base URL' },
|
|
145
|
-
{ id: 'ollama', label: 'Ollama', hint: 'local / offline' }
|
|
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)' }
|
|
146
162
|
].map((entry) => ({ ...entry, model: DEFAULT_MODEL_BY_PROVIDER[entry.id] ?? '' }));
|
|
147
163
|
|
|
148
164
|
/** Run the shared setup transaction inside the existing prompt. */
|
package/src/tui/setup.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
/** Shared setup transaction for the home panel and standalone CLI. */
|
|
2
|
+
import { resolveAvailableModels } from '../dynamicCatalogue.js';
|
|
1
3
|
const string = (value) => typeof value === 'string' ? value : '';
|
|
2
4
|
const customProviders = new Set(['openai-compatible', 'dashscope-byok', 'ollama']);
|
|
5
|
+
/** Peers and Antigravity authenticate through their own CLI, not a stored key. */
|
|
6
|
+
function isLocalAgent(providerId) {
|
|
7
|
+
return providerId === 'acp' || providerId.startsWith('acp/')
|
|
8
|
+
|| providerId === 'antigravity' || providerId === 'agy';
|
|
9
|
+
}
|
|
3
10
|
const defaults = {
|
|
4
11
|
ollama: 'http://localhost:11434/api/chat',
|
|
5
12
|
'dashscope-byok': 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions'
|
|
@@ -52,14 +59,39 @@ export async function runSetup(ui, providers, store, workspace = process.cwd())
|
|
|
52
59
|
return null;
|
|
53
60
|
baseUrl = answer;
|
|
54
61
|
}
|
|
55
|
-
const
|
|
62
|
+
const suggestedModel = (sameProvider ? string(draft.model) : '') || provider.model;
|
|
63
|
+
let model;
|
|
64
|
+
if (isLocalAgent(provider.id)) {
|
|
65
|
+
// The peer already knows which models its account can reach. Listing them
|
|
66
|
+
// is the whole point of treating it as a provider; a blank text box would
|
|
67
|
+
// make the user guess ids the CLI could have told us for free.
|
|
68
|
+
const known = (await resolveAvailableModels(provider.id, {}, false)).models;
|
|
69
|
+
if (known.length === 0) {
|
|
70
|
+
model = await text('Setup 3/5 · model', ['Enter a model ID published by the installed CLI.',
|
|
71
|
+
'Leave the default to let the peer choose its own model.'], suggestedModel, false, value => value ? null : 'A model ID is required.');
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const picked = await ui.select({ title: 'Setup 3/5 · model', items: [
|
|
75
|
+
...known.map((id) => ({ id, label: id, description: provider.label })),
|
|
76
|
+
{ id: '__custom__', label: 'Other model ID…', description: 'enter one manually' }
|
|
77
|
+
] });
|
|
78
|
+
if (!picked)
|
|
79
|
+
return null;
|
|
80
|
+
model = picked.id === '__custom__'
|
|
81
|
+
? await text('Setup 3/5 · model', ['Enter the model ID published by the installed CLI.'], suggestedModel, false, value => value ? null : 'A model ID is required.')
|
|
82
|
+
: picked.id;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'], suggestedModel, false, value => value ? null : 'A model ID is required.');
|
|
87
|
+
}
|
|
56
88
|
if (model === null)
|
|
57
89
|
return null;
|
|
58
90
|
const unchangedEndpoint = sameProvider && (string(draft.baseUrl) || defaults[provider.id] || '') === baseUrl;
|
|
59
91
|
// Fixed endpoints have no editable URL. A changed endpoint never inherits a key.
|
|
60
92
|
const keepKey = sameProvider && (!customProviders.has(provider.id) || unchangedEndpoint);
|
|
61
93
|
let apiKey = '';
|
|
62
|
-
if (provider.id !== 'ollama') {
|
|
94
|
+
if (provider.id !== 'ollama' && !isLocalAgent(provider.id)) {
|
|
63
95
|
const oldKey = keepKey ? string(draft.apiKey) : '';
|
|
64
96
|
const answer = await text('Setup 3/5 · credentials', ['Stored encrypted locally; used to authenticate with your selected provider.',
|
|
65
97
|
oldKey ? 'Blank keeps the key for this same provider and endpoint.' : 'Enter a key for this provider.',
|
package/src/tui/setup.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/** Shared setup transaction for the home panel and standalone CLI. */
|
|
2
|
+
import { resolveAvailableModels } from '../dynamicCatalogue.js';
|
|
3
|
+
|
|
2
4
|
export interface SetupChoice { id: string; label: string; description?: string }
|
|
3
5
|
export interface SetupProvider { id: string; label: string; hint: string; model: string }
|
|
4
6
|
export interface SetupUI {
|
|
@@ -8,6 +10,12 @@ export interface SetupUI {
|
|
|
8
10
|
type Config = Record<string, unknown>;
|
|
9
11
|
const string = (value: unknown): string => typeof value === 'string' ? value : '';
|
|
10
12
|
const customProviders = new Set(['openai-compatible', 'dashscope-byok', 'ollama']);
|
|
13
|
+
|
|
14
|
+
/** Peers and Antigravity authenticate through their own CLI, not a stored key. */
|
|
15
|
+
function isLocalAgent(providerId: string): boolean {
|
|
16
|
+
return providerId === 'acp' || providerId.startsWith('acp/')
|
|
17
|
+
|| providerId === 'antigravity' || providerId === 'agy';
|
|
18
|
+
}
|
|
11
19
|
const defaults: Record<string, string> = {
|
|
12
20
|
ollama: 'http://localhost:11434/api/chat',
|
|
13
21
|
'dashscope-byok': 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions'
|
|
@@ -56,14 +64,39 @@ export async function runSetup(ui: SetupUI, providers: SetupProvider[], store: {
|
|
|
56
64
|
if (answer === null) return null;
|
|
57
65
|
baseUrl = answer;
|
|
58
66
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
67
|
+
const suggestedModel = (sameProvider ? string(draft.model) : '') || provider.model;
|
|
68
|
+
let model: string | null;
|
|
69
|
+
if (isLocalAgent(provider.id)) {
|
|
70
|
+
// The peer already knows which models its account can reach. Listing them
|
|
71
|
+
// is the whole point of treating it as a provider; a blank text box would
|
|
72
|
+
// make the user guess ids the CLI could have told us for free.
|
|
73
|
+
const known = (await resolveAvailableModels(provider.id, {}, false)).models;
|
|
74
|
+
if (known.length === 0) {
|
|
75
|
+
model = await text('Setup 3/5 · model',
|
|
76
|
+
['Enter a model ID published by the installed CLI.',
|
|
77
|
+
'Leave the default to let the peer choose its own model.'],
|
|
78
|
+
suggestedModel, false, value => value ? null : 'A model ID is required.');
|
|
79
|
+
} else {
|
|
80
|
+
const picked = await ui.select({ title: 'Setup 3/5 · model', items: [
|
|
81
|
+
...known.map((id) => ({ id, label: id, description: provider.label })),
|
|
82
|
+
{ id: '__custom__', label: 'Other model ID…', description: 'enter one manually' }
|
|
83
|
+
] });
|
|
84
|
+
if (!picked) return null;
|
|
85
|
+
model = picked.id === '__custom__'
|
|
86
|
+
? await text('Setup 3/5 · model', ['Enter the model ID published by the installed CLI.'], suggestedModel, false,
|
|
87
|
+
value => value ? null : 'A model ID is required.')
|
|
88
|
+
: picked.id;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
model = await text('Setup 3/5 · model', ['Enter the model ID supported by your provider.'],
|
|
92
|
+
suggestedModel, false, value => value ? null : 'A model ID is required.');
|
|
93
|
+
}
|
|
61
94
|
if (model === null) return null;
|
|
62
95
|
const unchangedEndpoint = sameProvider && (string(draft.baseUrl) || defaults[provider.id] || '') === baseUrl;
|
|
63
96
|
// Fixed endpoints have no editable URL. A changed endpoint never inherits a key.
|
|
64
97
|
const keepKey = sameProvider && (!customProviders.has(provider.id) || unchangedEndpoint);
|
|
65
98
|
let apiKey = '';
|
|
66
|
-
if (provider.id !== 'ollama') {
|
|
99
|
+
if (provider.id !== 'ollama' && !isLocalAgent(provider.id)) {
|
|
67
100
|
const oldKey = keepKey ? string(draft.apiKey) : '';
|
|
68
101
|
const answer = await text('Setup 3/5 · credentials', ['Stored encrypted locally; used to authenticate with your selected provider.',
|
|
69
102
|
oldKey ? 'Blank keeps the key for this same provider and endpoint.' : 'Enter a key for this provider.',
|
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
|
|