@andorra-labs/code 0.1.13 → 0.1.15
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/dist/src/account-presentation.js +4 -1
- package/dist/src/acp-agent.d.ts +54 -0
- package/dist/src/acp-agent.js +991 -0
- package/dist/src/agent-execution.js +304 -140
- package/dist/src/agent-mcp-catalog.js +2 -0
- package/dist/src/agent-mcp.d.ts +2 -0
- package/dist/src/agent-mcp.js +86 -4
- package/dist/src/andorra/endpoint.d.ts +7 -0
- package/dist/src/andorra/endpoint.js +46 -0
- package/dist/src/andorra/entry.d.ts +21 -0
- package/dist/src/andorra/entry.js +118 -0
- package/dist/src/andorra/errors.d.ts +2 -0
- package/dist/src/andorra/errors.js +39 -0
- package/dist/src/andorra/hosted.d.ts +55 -0
- package/dist/src/andorra/hosted.js +130 -0
- package/dist/src/andorra/monitor.d.ts +151 -0
- package/dist/src/andorra/monitor.js +393 -0
- package/dist/src/andorra/notices.d.ts +16 -0
- package/dist/src/andorra/notices.js +38 -0
- package/dist/src/andorra/opt-in.d.ts +58 -0
- package/dist/src/andorra/opt-in.js +112 -0
- package/dist/src/andorra/request-watch.d.ts +6 -0
- package/dist/src/andorra/request-watch.js +10 -0
- package/dist/src/andorra/state.d.ts +86 -0
- package/dist/src/andorra/state.js +238 -0
- package/dist/src/andorra/terminal.d.ts +70 -0
- package/dist/src/andorra/terminal.js +125 -0
- package/dist/src/andorra/usage-format.d.ts +9 -0
- package/dist/src/andorra/usage-format.js +19 -0
- package/dist/src/anthropic-credentials.js +9 -1
- package/dist/src/app-server/protocol.d.ts +10 -2
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server/workspace.d.ts +1 -0
- package/dist/src/app-server/workspace.js +141 -10
- package/dist/src/app-server.d.ts +35 -0
- package/dist/src/app-server.js +377 -124
- package/dist/src/auth/AuthManager.d.ts +9 -0
- package/dist/src/auth/AuthManager.js +164 -24
- package/dist/src/auth/deployment.d.ts +1 -0
- package/dist/src/auth/deployment.js +1 -0
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +26 -0
- package/dist/src/auth/store.js +34 -1
- package/dist/src/browser-bridge.d.ts +1 -0
- package/dist/src/browser-bridge.js +5 -2
- package/dist/src/browser-external-app.d.ts +27 -0
- package/dist/src/browser-external-app.js +60 -0
- package/dist/src/browser-panel-tool.d.ts +6 -0
- package/dist/src/browser-panel-tool.js +36 -0
- package/dist/src/browser-runner.js +1 -1
- package/dist/src/browser-server.d.ts +5 -0
- package/dist/src/browser-server.js +27 -3
- package/dist/src/browser-stealth.d.ts +19 -1
- package/dist/src/browser-stealth.js +23 -3
- package/dist/src/browser-ui/tokens.css +4 -4
- package/dist/src/browser-view.d.ts +81 -0
- package/dist/src/browser-view.js +289 -18
- package/dist/src/bug-report.d.ts +81 -0
- package/dist/src/bug-report.js +235 -0
- package/dist/src/claude-provider.d.ts +2 -1
- package/dist/src/claude-provider.js +10 -8
- package/dist/src/cli-sign-in.d.ts +3 -1
- package/dist/src/cli-sign-in.js +4 -1
- package/dist/src/cli.js +205 -58
- package/dist/src/coding-tools.js +7 -7
- package/dist/src/command-screens.d.ts +26 -3
- package/dist/src/command-screens.js +323 -85
- package/dist/src/commands.d.ts +7 -1
- package/dist/src/commands.js +79 -27
- package/dist/src/completion-gates.d.ts +22 -0
- package/dist/src/completion-gates.js +11 -0
- package/dist/src/config.d.ts +11 -1
- package/dist/src/config.js +134 -3
- package/dist/src/dashboard-view.d.ts +2 -0
- package/dist/src/dashboard-view.js +11 -2
- package/dist/src/decision/PreparedSteps.js +1 -1
- package/dist/src/decision/applyToolMenu.js +1 -1
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +1 -0
- package/dist/src/google-provider.d.ts +31 -0
- package/dist/src/google-provider.js +153 -0
- package/dist/src/graph-health.d.ts +11 -0
- package/dist/src/graph-health.js +36 -4
- package/dist/src/graph-manager-chat.d.ts +33 -0
- package/dist/src/graph-manager-chat.js +165 -6
- package/dist/src/graph-runner.js +27 -0
- package/dist/src/graph-selection.js +2 -1
- package/dist/src/graph-sync.d.ts +1 -0
- package/dist/src/graph-sync.js +93 -34
- package/dist/src/graph-tool.d.ts +2 -0
- package/dist/src/graph-tool.js +2 -2
- package/dist/src/graph-ui/app.js +92 -10
- package/dist/src/graph-ui/edge-router.js +121 -53
- package/dist/src/graph-ui/manager.js +40 -5
- package/dist/src/graph-ui/style.css +5 -2
- package/dist/src/graph-ui/tokens.css +4 -4
- package/dist/src/graph-visibility.d.ts +31 -0
- package/dist/src/graph-visibility.js +102 -0
- package/dist/src/graphs.js +1 -3
- package/dist/src/hardened-runtime.js +1 -1
- package/dist/src/live-model.d.ts +24 -0
- package/dist/src/live-model.js +37 -0
- package/dist/src/managed-sign-in.d.ts +1 -0
- package/dist/src/managed-sign-in.js +13 -0
- package/dist/src/membership-errors.d.ts +2 -0
- package/dist/src/membership-errors.js +6 -2
- package/dist/src/membership.d.ts +13 -2
- package/dist/src/membership.js +39 -8
- package/dist/src/model-context-windows.d.ts +2 -0
- package/dist/src/model-context-windows.js +24 -0
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.d.ts +1 -0
- package/dist/src/model-metadata.js +47 -3
- package/dist/src/paged-transcript.d.ts +2 -0
- package/dist/src/paged-transcript.js +16 -0
- package/dist/src/palette.d.ts +1 -0
- package/dist/src/palette.js +1 -1
- package/dist/src/permissions.js +17 -4
- package/dist/src/provider-connection.js +32 -0
- package/dist/src/provider-engine.d.ts +5 -0
- package/dist/src/provider-engine.js +3 -3
- package/dist/src/provider-import.js +3 -1
- package/dist/src/provider-settings.d.ts +16 -1
- package/dist/src/provider-settings.js +50 -22
- package/dist/src/providers.d.ts +29 -3
- package/dist/src/providers.js +100 -18
- package/dist/src/react-runtime.js +33 -12
- package/dist/src/read-document-tool.d.ts +2 -0
- package/dist/src/read-document-tool.js +6 -6
- package/dist/src/remote/engine-pool.js +31 -6
- package/dist/src/run-control.d.ts +2 -2
- package/dist/src/run-control.js +9 -6
- package/dist/src/runtime-environment.d.ts +1 -0
- package/dist/src/runtime-environment.js +13 -0
- package/dist/src/runtime.d.ts +2 -0
- package/dist/src/runtime.js +2 -1
- package/dist/src/save-lock.js +14 -7
- package/dist/src/session-title.d.ts +3 -0
- package/dist/src/session-title.js +5 -2
- package/dist/src/sessions.d.ts +1 -0
- package/dist/src/sessions.js +4 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +10 -3
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/bug-report/SKILL.md +80 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/errors.md +2 -1
- package/dist/src/skills/bundled/provenance.json +743 -738
- package/dist/src/skills/runtime-skills.js +1 -0
- package/dist/src/subagent-run.d.ts +2 -0
- package/dist/src/subagent-run.js +14 -3
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +2 -2
- package/dist/src/telemetry/uploader.d.ts +7 -1
- package/dist/src/telemetry/uploader.js +11 -2
- package/dist/src/terminal-links.d.ts +16 -0
- package/dist/src/terminal-links.js +113 -0
- package/dist/src/terminal-ui.d.ts +29 -1
- package/dist/src/terminal-ui.js +113 -24
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/trajectory.js +6 -1
- package/dist/src/transcript.d.ts +2 -0
- package/dist/src/transcript.js +5 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/src/workspace-instructions.js +1 -1
- package/package.json +13 -1
package/dist/src/commands.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ import type { Completion, RunResult } from './runtime.js';
|
|
|
8
8
|
import type { Usage } from './types.js';
|
|
9
9
|
import type { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
|
|
10
10
|
import { logoutCodex } from './codex-auth.js';
|
|
11
|
-
|
|
11
|
+
import type { TerminalAndorraHooks } from './andorra/terminal.js';
|
|
12
|
+
export declare const HELP = "Commands:\n /browser Open the browser workspace (CLI stays available)\n /session Browse and resume saved sessions (newest first)\n /resume Same as /session\n /login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)\n /auth logout Remove this machine's saved Andorra account session\n /auth status Show Andorra account session status\n /model [model-id] Open the provider/model tree (\u2192 expands, \u2190 collapses) or select a model directly; with a graph that pins node models, asks whether to override them\n /model list Discover models from the active provider\n /providers [id] Choose providers; Right/e edits; Add provider configures\n /subagent [id [model]] Set the provider/model external hosts (Claude/Codex CLI) must use for Andorra subagent runs; off clears it\n /reasoning <level> Set default|none|minimal|low|medium|high|xhigh|max\n /graph [id] Select a graph or open the web graph builder\n /codegraph <action> Code intelligence: status|enable|disable|rebuild; enable|disable --global sets the default for every project\n /dashboard Toggle live dashboard and transcript (TTY only)\n /attach <path> Attach a file or folder to your next task (large pastes and dropped files attach automatically)\n /usage Open session usage (Escape to return)\n /permissions [mode] Choose and remember workspace permissions\n /jev <on|off|status> Turn Jev on or off for this session, or show its setting\n /jev global <on|off> Turn the Global Jev switch on or off; off stops Jev in every session and agent\n /feedback <on|off|status> Show the anonymous-feedback setting; Paid accounts can turn it off\n /yolo <on|off> Turn session-wide Full Access on or off (host files and network)\n /tools List available coding tools\n /skills List, install, enable, disable or remove skills\n /<skillname> [args] Apply an enabled imported skill to this and every later message; qualify duplicate names by catalog ID\n /skill [on|off|remove] Show, pause, resume or end the session's active skill\n /plugins List, install, enable, disable or remove plugins\n /mcp Add, edit, enable, disable or delete MCP servers\n /logout Sign out of your Andorra account (then /login to switch accounts)\n /logout --all Sign out, and delete every other Andorra sign-in saved on this machine\n /logout codex Sign out of every configured Codex (ChatGPT) account\n /status Show workspace and current settings\n /clear Clear the conversation on screen and the retained context (session usage is retained)\n /compact Compact retained conversation history to free context\n /goal [text|clear] Set, show or clear the session goal; a run keeps working until a completion check agrees the goal is met\n /help Show commands\n /exit Quit\nSelection screens: Up/Down to browse, Enter or Space to select, Escape to return.\nCtrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model statistics (display only).\nCtrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.\nShift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Drag selects and copies transcript text; double-click copies a word.\nCtrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.";
|
|
12
13
|
export interface CommandState {
|
|
13
14
|
config: Config;
|
|
14
15
|
yolo: boolean;
|
|
@@ -29,7 +30,11 @@ export interface CommandState {
|
|
|
29
30
|
confirmModelOverride?: (question: string) => Promise<boolean>;
|
|
30
31
|
history?: ConversationTurn[];
|
|
31
32
|
goal?: SessionGoal;
|
|
33
|
+
jev?: boolean;
|
|
34
|
+
andorra?: TerminalAndorraHooks;
|
|
32
35
|
}
|
|
36
|
+
/** The message refusing a switch to this provider, or undefined when it may be selected. An absent `state.andorra` counts as available. */
|
|
37
|
+
export declare function andorraRefusal(state: Pick<CommandState, 'andorra' | 'config'>, providerId: string): string | undefined;
|
|
33
38
|
export interface CommandResult {
|
|
34
39
|
text: string;
|
|
35
40
|
goalChanged?: boolean;
|
|
@@ -52,6 +57,7 @@ export interface ConversationTurn {
|
|
|
52
57
|
text: string;
|
|
53
58
|
attachments?: import('./attachments.js').UserAttachmentRef[];
|
|
54
59
|
wake?: TurnWake;
|
|
60
|
+
subagentId?: string;
|
|
55
61
|
}[];
|
|
56
62
|
}
|
|
57
63
|
export type TurnWake = 'timer' | 'auto-fix';
|
package/dist/src/commands.js
CHANGED
|
@@ -6,12 +6,12 @@ export function permissionChoices(current) {
|
|
|
6
6
|
}
|
|
7
7
|
import { graphStorageDirectory } from './graph-account.js';
|
|
8
8
|
import { configuredGraphSelection, currentGraphSubject, saveGraphSelection } from './graph-selection.js';
|
|
9
|
-
import { loadAccessibleGraph, requireGraphMembership } from './membership.js';
|
|
9
|
+
import { currentGraphSelection, loadAccessibleGraph, requireGraphMembership } from './membership.js';
|
|
10
10
|
import { GraphProviderUnavailableError } from './graph-provider-portability.js';
|
|
11
11
|
import { confirmAndApplyModelOverride } from './model-override.js';
|
|
12
12
|
import { applyGoalCommand } from './session-goal.js';
|
|
13
13
|
import { changeConfigFile, configDirectory, loadConfig, loadSavedAnalytics } from './config.js';
|
|
14
|
-
import { applyModelContextWindow, providerLabel, recordProviderModel, REASONING_EFFORTS } from './providers.js';
|
|
14
|
+
import { applyModelContextWindow, modelDisplayName, modelIdForDisplayName, providerLabel, recordProviderModel, REASONING_EFFORTS } from './providers.js';
|
|
15
15
|
import { resolveRepositoryId } from './code-intelligence/repository.js';
|
|
16
16
|
import { logoutCodex } from './codex-auth.js';
|
|
17
17
|
import { codexAccountHome } from './codex-rpc.js';
|
|
@@ -21,11 +21,13 @@ import { telemetryDirectory } from './telemetry/identity.js';
|
|
|
21
21
|
import { purgeOutbox } from './telemetry/outbox.js';
|
|
22
22
|
import { recordPreference } from './telemetry/state.js';
|
|
23
23
|
import { telemetryGate } from './telemetry/gate.js';
|
|
24
|
+
import { formatWeekReset } from './andorra/usage-format.js';
|
|
24
25
|
const MAX_CODEINTEL_REPO_OVERRIDES = 100;
|
|
25
26
|
const REASONING_USAGE = 'Usage: /reasoning default|none|minimal|low|medium|high|xhigh|max';
|
|
26
27
|
export const HELP = `Commands:
|
|
27
28
|
/browser Open the browser workspace (CLI stays available)
|
|
28
29
|
/session Browse and resume saved sessions (newest first)
|
|
30
|
+
/resume Same as /session
|
|
29
31
|
/login [--no-browser] Sign in or create an Andorra account (prints the address over SSH)
|
|
30
32
|
/auth logout Remove this machine's saved Andorra account session
|
|
31
33
|
/auth status Show Andorra account session status
|
|
@@ -40,7 +42,8 @@ export const HELP = `Commands:
|
|
|
40
42
|
/attach <path> Attach a file or folder to your next task (large pastes and dropped files attach automatically)
|
|
41
43
|
/usage Open session usage (Escape to return)
|
|
42
44
|
/permissions [mode] Choose and remember workspace permissions
|
|
43
|
-
/jev <on|off|status> Turn Jev on or off for
|
|
45
|
+
/jev <on|off|status> Turn Jev on or off for this session, or show its setting
|
|
46
|
+
/jev global <on|off> Turn the Global Jev switch on or off; off stops Jev in every session and agent
|
|
44
47
|
/feedback <on|off|status> Show the anonymous-feedback setting; Paid accounts can turn it off
|
|
45
48
|
/yolo <on|off> Turn session-wide Full Access on or off (host files and network)
|
|
46
49
|
/tools List available coding tools
|
|
@@ -63,6 +66,28 @@ Ctrl+B toggles dashboard; Ctrl+G pages its graph; Ctrl+N cycles dashboard model
|
|
|
63
66
|
Ctrl+T expands/collapses todos; Ctrl+O expands/collapses tool details; Ctrl+Y collapses/expands live thinking.
|
|
64
67
|
Shift+Arrow/Home/End selects prompt text; Ctrl+C copies and Ctrl+X cuts a selection. The wheel scrolls; Up/Down recall prompts. Drag selects and copies transcript text; double-click copies a word.
|
|
65
68
|
Ctrl+C stops an interactive run; send direction to resume, or press Ctrl+C again to exit (idle Ctrl+C exits too). /yolo on|off applies immediately, including at approvals. /exit quits. Headless Ctrl+C cancels the run; a second press exits.`;
|
|
69
|
+
/** `name (id)` when the model has a display name, else the id. */
|
|
70
|
+
function modelWithName(provider, id) {
|
|
71
|
+
const name = modelDisplayName(provider, id);
|
|
72
|
+
return name === id ? id : `${name} (${id})`;
|
|
73
|
+
}
|
|
74
|
+
/** The /status line for Andorra's hosted models, with its leading line break; empty while there is nothing to show. */
|
|
75
|
+
function andorraUsageLine(state) {
|
|
76
|
+
const usage = state.andorra?.usage?.();
|
|
77
|
+
if (!usage)
|
|
78
|
+
return '';
|
|
79
|
+
if (usage.kind === 'not-available')
|
|
80
|
+
return '\nAndorra models: Not available at the moment.';
|
|
81
|
+
const resets = formatWeekReset(usage.resetsAt);
|
|
82
|
+
return `\nAndorra models, this week: ${usage.usedPercent}% used${resets ? `, resets ${resets}` : ''}`;
|
|
83
|
+
}
|
|
84
|
+
/** The message refusing a switch to this provider, or undefined when it may be selected. An absent `state.andorra` counts as available. */
|
|
85
|
+
export function andorraRefusal(state, providerId) {
|
|
86
|
+
if (state.config.providers.find(item => item.id === providerId)?.type !== 'andorra')
|
|
87
|
+
return undefined;
|
|
88
|
+
const availability = state.andorra?.availability();
|
|
89
|
+
return availability && !availability.available ? availability.message : undefined;
|
|
90
|
+
}
|
|
66
91
|
export function compactHistory(turns) {
|
|
67
92
|
const clip = (text, limit) => { const flat = text.replace(/\s+/g, ' ').trim(); return flat.length > limit ? flat.slice(0, limit - 1) + '…' : flat; };
|
|
68
93
|
const lines = turns.map((turn, index) => `${index + 1}. ${clip(turn.task, 160)}${turn.direction === undefined ? '' : ` (continued with: ${clip(turn.direction, 160)})`} → ${clip(turn.completion.summary, 240)}`);
|
|
@@ -211,13 +236,14 @@ export async function executeCommand(line, state, persist, signal, graphAccess =
|
|
|
211
236
|
if (action === 'logout' || action === 'login') {
|
|
212
237
|
delete draft.graph;
|
|
213
238
|
result.clear = true;
|
|
239
|
+
state.andorra?.accountChanged?.();
|
|
214
240
|
}
|
|
215
241
|
}
|
|
216
242
|
else if (codegraph) {
|
|
217
243
|
result = codegraphScope ? await codegraphCommand(codegraph[1] ?? 'status', codegraphScope, draft, signal) : { text: CODEGRAPH_USAGE };
|
|
218
244
|
}
|
|
219
245
|
else if (graphCommand) {
|
|
220
|
-
const id = graphCommand[1];
|
|
246
|
+
const id = currentGraphSelection(graphCommand[1]);
|
|
221
247
|
try {
|
|
222
248
|
signal?.throwIfAborted();
|
|
223
249
|
const subject = await graphSubject();
|
|
@@ -303,6 +329,8 @@ export async function executeCommand(line, state, persist, signal, graphAccess =
|
|
|
303
329
|
state.permissions = draft.permissions;
|
|
304
330
|
if (result.goalChanged)
|
|
305
331
|
state.goal = draft.goal;
|
|
332
|
+
if (draft.jev !== undefined)
|
|
333
|
+
state.jev = draft.jev;
|
|
306
334
|
if (permissionsChanged && draft.permissions !== 'read-only' && draft.permissions !== 'plan')
|
|
307
335
|
await state.codeIntel?.setPermissions(draft.permissions);
|
|
308
336
|
if (draft.graph === undefined)
|
|
@@ -341,23 +369,35 @@ export function handleCommand(line, state) {
|
|
|
341
369
|
if (arg === 'list')
|
|
342
370
|
return { text: '', discover: true };
|
|
343
371
|
if (!arg)
|
|
344
|
-
return { text: `${provider.id}: ${provider.model}` };
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
372
|
+
return { text: `${provider.id}: ${modelWithName(provider, provider.model)}` };
|
|
373
|
+
{ // An Andorra model may also be named by its exact display name; the id is what is saved.
|
|
374
|
+
const chosen = modelIdForDisplayName(provider, arg) ?? (args.length === 1 ? arg : undefined);
|
|
375
|
+
if (chosen === undefined)
|
|
376
|
+
return { text: 'Usage: /model <model-id>' };
|
|
377
|
+
if (provider.model !== chosen) {
|
|
378
|
+
applyModelContextWindow(provider, chosen);
|
|
379
|
+
delete provider.reasoningEffort;
|
|
380
|
+
}
|
|
381
|
+
recordProviderModel(provider, chosen);
|
|
382
|
+
provider.model = chosen;
|
|
383
|
+
return { text: `Model: ${provider.id}/${modelWithName(provider, chosen)}`, save: true, clear: true };
|
|
350
384
|
}
|
|
351
|
-
recordProviderModel(provider, arg);
|
|
352
|
-
provider.model = arg;
|
|
353
|
-
return { text: `Model: ${provider.id}/${arg}`, save: true, clear: true };
|
|
354
385
|
case '/providers':
|
|
355
386
|
if (!arg && !provider)
|
|
356
387
|
return { text: 'No providers configured. Open /providers and choose Add provider.' };
|
|
357
|
-
if (!arg)
|
|
358
|
-
|
|
388
|
+
if (!arg) {
|
|
389
|
+
// Andorra listed by default and not saved yet reads like any provider, first. Naming it here saves nothing.
|
|
390
|
+
const listed = state.andorra?.listed?.();
|
|
391
|
+
const shown = listed ? [listed, ...state.config.providers] : state.config.providers;
|
|
392
|
+
return { text: shown.map(p => `${p !== listed && p.id === provider.id ? '*' : ' '} ${providerLabel(p, shown)} (${p.type}) — ${modelDisplayName(p, p.model)}`).join('\n') };
|
|
393
|
+
}
|
|
359
394
|
if (!state.config.providers.some(p => p.id === arg))
|
|
360
395
|
return { text: `Unknown provider: ${arg}. Use /providers to browse configured providers.` };
|
|
396
|
+
{
|
|
397
|
+
const refusal = andorraRefusal(state, arg);
|
|
398
|
+
if (refusal)
|
|
399
|
+
return { text: refusal };
|
|
400
|
+
}
|
|
361
401
|
state.config.provider = arg;
|
|
362
402
|
return { text: `Provider: ${arg}. Conversation cleared for the new provider.`, save: true, clear: true };
|
|
363
403
|
case '/subagent': {
|
|
@@ -405,7 +445,7 @@ export function handleCommand(line, state) {
|
|
|
405
445
|
if (changed)
|
|
406
446
|
return { text: 'Graph: Default (Andorra Agent)', clear: true };
|
|
407
447
|
}
|
|
408
|
-
return { text: 'Graph: Default - Andorra Agent only. Use the graph selector for
|
|
448
|
+
return { text: 'Graph: Default - Andorra Agent only. Use the graph selector for custom graphs.' };
|
|
409
449
|
case '/permissions':
|
|
410
450
|
if (!arg)
|
|
411
451
|
return { text: permissionChoices(state.permissions ?? (state.yolo ? 'full-access' : 'ask-for-approval')) };
|
|
@@ -426,18 +466,30 @@ export function handleCommand(line, state) {
|
|
|
426
466
|
? 'YOLO on: session-wide Full Access. Host files, shell, Git, QA, MCP and network operations are automatically approved.'
|
|
427
467
|
: 'YOLO off: session permissions restored to Ask for approval.' };
|
|
428
468
|
case '/jev': {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const
|
|
469
|
+
const jevUsage = 'Usage: /jev on|off|status, or /jev global on|off';
|
|
470
|
+
const global = args[0] === 'global';
|
|
471
|
+
const globalArg = global ? args[1] : undefined;
|
|
472
|
+
if (global ? args.length !== 2 || !['on', 'off'].includes(globalArg ?? '') : args.length > 1 || (arg && !['on', 'off', 'status'].includes(arg)))
|
|
473
|
+
return { text: jevUsage };
|
|
474
|
+
const jevStatus = () => {
|
|
475
|
+
const globalOn = state.config.jevEnabled !== false;
|
|
476
|
+
const sessionOn = state.jev !== false;
|
|
477
|
+
return `Jev: ${globalOn && sessionOn ? 'on' : 'off'} for this session (session ${sessionOn ? 'on' : 'off'}, Global Jev switch ${globalOn ? 'on' : 'off'}).`
|
|
478
|
+
+ (globalOn ? ' Applies to Agent nodes with Jev turned on. Requires sign-in and available quota.' : ' The Global Jev switch is off, so no session and no Agent node uses Jev. Turn it on with /jev global on.');
|
|
479
|
+
};
|
|
432
480
|
if (arg === 'status')
|
|
433
|
-
return { text: jevStatus };
|
|
481
|
+
return { text: jevStatus() };
|
|
434
482
|
if (!arg)
|
|
435
|
-
return { text: `${jevStatus}\
|
|
436
|
-
state.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return { text:
|
|
440
|
-
|
|
483
|
+
return { text: `${jevStatus()}\n${jevUsage}` };
|
|
484
|
+
const kept = state.running ? ' The current run keeps its setting; the change applies after it ends or you interrupt it.' : '';
|
|
485
|
+
if (global) {
|
|
486
|
+
state.config.jevEnabled = globalArg === 'on';
|
|
487
|
+
return { text: `Global Jev switch ${state.config.jevEnabled ? 'on' : 'off'}. Setting saved for this machine.${kept}${state.config.jevEnabled ? ` Each session keeps its own setting; this session is ${state.jev === false ? 'off' : 'on'}.` : ' No session and no Agent node uses Jev until it is turned back on.'}`, save: true };
|
|
488
|
+
}
|
|
489
|
+
state.jev = arg === 'on';
|
|
490
|
+
if (state.config.jevEnabled === false)
|
|
491
|
+
return { text: `Jev ${state.jev ? 'on' : 'off'} for this session, but the Global Jev switch is off, so Jev stays off. Turn it on with /jev global on.` };
|
|
492
|
+
return { text: `Jev ${state.jev ? 'on' : 'off'} for this session.${kept}${state.jev && !state.running ? ' It applies to Agent nodes with Jev turned on and requires sign-in and available quota.' : ''}` };
|
|
441
493
|
}
|
|
442
494
|
case '/feedback': {
|
|
443
495
|
if (args.length > 1 || (arg && !['on', 'off', 'status'].includes(arg)))
|
|
@@ -465,7 +517,7 @@ export function handleCommand(line, state) {
|
|
|
465
517
|
: '';
|
|
466
518
|
return { text: `Session: ${state.usage.requests} model requests, ${state.usage.inputTokens} input + ${state.usage.outputTokens} output tokens${cache} (provider-reported; missing usage is not estimated).\nCost: unavailable; no pricing assumptions.${state.lastRun ? `\nLast run: ${state.lastRun.id} — ${state.lastRun.status}, ${state.lastRun.toolCalls} tool calls` : ''}` };
|
|
467
519
|
}
|
|
468
|
-
case '/status': return { text: `Workspace: ${state.workspace}\nProvider/model: ${provider.id}/${provider.model}\nThinking: ${provider.reasoningEffort ?? 'provider default'}\nContext window: ${provider.contextWindow?.toLocaleString() ?? 'unknown'}\nGraph: ${state.graph ?? 'Default'}\nPermissions: ${permissionLabel(state.permissions ?? (state.yolo ? 'full-access' : 'ask-for-approval'))}\nYOLO: ${state.yolo ? 'on' : 'off'}` };
|
|
520
|
+
case '/status': return { text: `Workspace: ${state.workspace}\nProvider/model: ${provider.id}/${modelWithName(provider, provider.model)}\nThinking: ${provider.reasoningEffort ?? 'provider default'}\nContext window: ${provider.contextWindow?.toLocaleString() ?? 'unknown'}\nGraph: ${state.graph ?? 'Default'}\nPermissions: ${permissionLabel(state.permissions ?? (state.yolo ? 'full-access' : 'ask-for-approval'))}\nYOLO: ${state.yolo ? 'on' : 'off'}${andorraUsageLine(state)}` };
|
|
469
521
|
case '/tools': return { text: 'Read, Write, Edit, Glob, Grep, Bash, PowerShell; repo_explore (when CodeGraph is enabled), git_read, qa.*, memory_search and artifact/control tools as permitted.\nEnabled skills add read_skill_resource. Enabled MCP servers and plugins discover namespaced tools at each task start; connection status reports availability. External tools require an agent with shell permission.\nWrites and shell commands obey /permissions; unsupported strict sandboxes fail closed. Host/network escalation and MCP connections/calls require approval unless Full Access is selected. Existing graph configs using retired read_file/search_files/Pi lowercase names are translated internally and are not advertised to models.' };
|
|
470
522
|
default: return { text: `Unknown command: ${command}. Use /help.` };
|
|
471
523
|
}
|
|
@@ -21,3 +21,25 @@ export interface FinalAnswerGateResult {
|
|
|
21
21
|
}
|
|
22
22
|
export declare function declaresUnfinishedWork(summary: string | undefined): boolean;
|
|
23
23
|
export declare function finalAnswerGate(input: FinalAnswerGateInput): FinalAnswerGateResult | undefined;
|
|
24
|
+
export interface ProseFinalAnswerInput {
|
|
25
|
+
text: string;
|
|
26
|
+
stopReason?: string;
|
|
27
|
+
/** The node declares exactly one outcome and that outcome ends the run. */
|
|
28
|
+
endsRun: boolean;
|
|
29
|
+
hasOutputSchema: boolean;
|
|
30
|
+
/** Someone is there to read the answer and reply to it. */
|
|
31
|
+
userPresent: boolean;
|
|
32
|
+
/** The run called a tool or wrote todos, or resumes an earlier invocation whose tool calls are not counted here. */
|
|
33
|
+
acted: boolean;
|
|
34
|
+
openTodos: number;
|
|
35
|
+
/** The response looks like a tool call the provider discarded. */
|
|
36
|
+
toolCallDropped: boolean;
|
|
37
|
+
/** The text carries a completion envelope written out as JSON. */
|
|
38
|
+
carriesEnvelope: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Whether a plain reply from a graph node is its final answer, so the node ends without a second
|
|
42
|
+
* request that only restates it through complete_agent. True only where nothing can be left undone
|
|
43
|
+
* or unrouted: no work was started, one outcome exists, it ends the run, and a user reads the reply.
|
|
44
|
+
*/
|
|
45
|
+
export declare function proseIsFinalAnswer(input: ProseFinalAnswerInput): boolean;
|
|
@@ -55,3 +55,14 @@ export function finalAnswerGate(input) {
|
|
|
55
55
|
}
|
|
56
56
|
return { gates, waived, message: `Completion not accepted yet. ${parts.join(' ')}${gates.includes('unfinished') ? '' : ' Then call complete_agent again.'}`, ...waiver };
|
|
57
57
|
}
|
|
58
|
+
const NATURAL_STOPS = [undefined, 'stop', 'end_turn'];
|
|
59
|
+
/**
|
|
60
|
+
* Whether a plain reply from a graph node is its final answer, so the node ends without a second
|
|
61
|
+
* request that only restates it through complete_agent. True only where nothing can be left undone
|
|
62
|
+
* or unrouted: no work was started, one outcome exists, it ends the run, and a user reads the reply.
|
|
63
|
+
*/
|
|
64
|
+
export function proseIsFinalAnswer(input) {
|
|
65
|
+
return input.endsRun && input.userPresent && !input.hasOutputSchema && !input.acted && input.openTodos === 0
|
|
66
|
+
&& !input.toolCallDropped && !input.carriesEnvelope && NATURAL_STOPS.includes(input.stopReason)
|
|
67
|
+
&& !!input.text.trim() && !declaresUnfinishedWork(input.text);
|
|
68
|
+
}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export interface Config {
|
|
|
41
41
|
providers: ProviderConfig[];
|
|
42
42
|
graph?: string;
|
|
43
43
|
graphSelections?: Record<string, string>;
|
|
44
|
+
graphVisibility?: Record<string, Record<string, string[]>>;
|
|
45
|
+
graphVisibilityChosen?: Record<string, string[]>;
|
|
44
46
|
codeIntel?: CodeIntelConfig;
|
|
45
47
|
memory?: MemoryConfig;
|
|
46
48
|
analytics?: AnalyticsConfig;
|
|
@@ -107,6 +109,9 @@ export declare const MAX_SYSTEM_PROMPT_OVERRIDE = 16000;
|
|
|
107
109
|
export declare const AUTO_ARCHIVE_MIN_DAYS = 1;
|
|
108
110
|
export declare const AUTO_ARCHIVE_MAX_DAYS = 30;
|
|
109
111
|
export declare function configDirectory(environment?: NodeJS.ProcessEnv): string;
|
|
112
|
+
export declare const MAX_GRAPH_VISIBILITY_PROJECTS = 500;
|
|
113
|
+
/** Per account (subject), per graph id: the project paths the graph is listed in. A graph with no entry is listed everywhere. */
|
|
114
|
+
export declare function validGraphVisibility(value: unknown): value is Record<string, Record<string, string[]>>;
|
|
110
115
|
export declare function validateConfig(value: unknown): Config;
|
|
111
116
|
export declare function reconcileSubagentPair(config: Config): Config;
|
|
112
117
|
export declare function validateMcpServer(value: unknown): McpServerConfig;
|
|
@@ -117,11 +122,16 @@ export declare function validateMemoryConfig(memory: unknown): void;
|
|
|
117
122
|
export declare function resolveMemoryConfig(config: Config, env?: NodeJS.ProcessEnv, warn?: (message: string) => void): MemoryConfig;
|
|
118
123
|
export declare function loadConfig(directory?: string): Promise<Config>;
|
|
119
124
|
export declare function loadSavedAnalytics(directory?: string): Promise<AnalyticsConfig | undefined>;
|
|
125
|
+
/** Saves a whole config. When an Andorra entry the user removed is dropped (see above), `config` itself is updated to match what was saved. */
|
|
120
126
|
export declare function saveConfig(config: Config, directory?: string): Promise<void>;
|
|
121
127
|
export declare class ConfigConflictError extends Error {
|
|
122
128
|
constructor();
|
|
123
129
|
}
|
|
124
|
-
|
|
130
|
+
/**
|
|
131
|
+
* `prepare`, when given, runs once inside the cross-process config lock before the config is read, and its
|
|
132
|
+
* result is handed to `change`: for a change that depends on other saved state, which must be read under the lock.
|
|
133
|
+
*/
|
|
134
|
+
export declare function changeConfigFile<T = undefined>(directory: string, change: (current: Config, prepared: T) => Config, attempts?: number, prepare?: () => Promise<T>): Promise<Config>;
|
|
125
135
|
export declare function validateCodeIntelConfig(codeIntel: unknown): void;
|
|
126
136
|
export declare function resolveCodeIntelConfig(config: Config): Required<Pick<CodeIntelConfig, 'enabled'>> & CodeIntelConfig;
|
|
127
137
|
export declare function validateRemoteConfig(remote: unknown): void;
|
package/dist/src/config.js
CHANGED
|
@@ -4,8 +4,13 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { randomUUID } from 'node:crypto';
|
|
6
6
|
import { isIP } from 'node:net';
|
|
7
|
+
import { cleanModelName, fallbackProviderId } from './andorra/entry.js';
|
|
8
|
+
import { readHostedState } from './andorra/state.js';
|
|
9
|
+
import { isModelParameters } from './providers.js';
|
|
7
10
|
import { assertProviderCredentials, assertRequestTimeout, assertStreamIdleTimeout, MAX_CODEX_ACCOUNT_KEY_LENGTH, MAX_PROVIDER_NAME_LENGTH, PROVIDER_TYPES, REASONING_EFFORTS } from './providers.js';
|
|
11
|
+
import { GOOGLE_BASE_URL } from './google-provider.js';
|
|
8
12
|
import { GROK_BASE_URL } from './grok-provider.js';
|
|
13
|
+
import { ANDORRA_PROVIDER_BASE_URL } from './andorra/endpoint.js';
|
|
9
14
|
import { OPENCODE_BASE_URL } from './opencode-cli-provider.js';
|
|
10
15
|
import { validateAnalyticsConfig } from './analytics.js';
|
|
11
16
|
import { isPermissionMode } from './permissions.js';
|
|
@@ -119,6 +124,65 @@ function privateHttpHost(host) {
|
|
|
119
124
|
}
|
|
120
125
|
return isIP(address) === 6 && (/^f[cd]/.test(address) || /^fe[89ab]/.test(address));
|
|
121
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Brings a saved Andorra entry in line with this build instead of refusing it, so a config saved by another
|
|
129
|
+
* build always loads: the address is informational (requests never use it) and becomes today's, and the display
|
|
130
|
+
* names are cleaned by today's rule, dropping any that cannot be shown.
|
|
131
|
+
*/
|
|
132
|
+
function normaliseAndorraEntry(provider) {
|
|
133
|
+
provider.baseUrl = ANDORRA_PROVIDER_BASE_URL;
|
|
134
|
+
const usable = (model) => typeof model === 'string' && !!model.trim() && model.length <= 500 && !['__proto__', 'constructor', 'prototype'].includes(model);
|
|
135
|
+
// The sizes and the free list are descriptive, like the names: what cannot be shown is dropped, never refused.
|
|
136
|
+
if (provider.modelParameters !== undefined) {
|
|
137
|
+
const saved = provider.modelParameters;
|
|
138
|
+
const sizes = {};
|
|
139
|
+
if (saved && typeof saved === 'object' && !Array.isArray(saved)) {
|
|
140
|
+
for (const [model, size] of Object.entries(saved))
|
|
141
|
+
if (usable(model) && isModelParameters(size))
|
|
142
|
+
sizes[model] = size;
|
|
143
|
+
}
|
|
144
|
+
if (Object.keys(sizes).length > 0)
|
|
145
|
+
provider.modelParameters = sizes;
|
|
146
|
+
else
|
|
147
|
+
delete provider.modelParameters;
|
|
148
|
+
}
|
|
149
|
+
if (provider.freeModels !== undefined) {
|
|
150
|
+
const saved = provider.freeModels;
|
|
151
|
+
const free = Array.isArray(saved) ? [...new Set(saved.filter(usable))] : [];
|
|
152
|
+
if (free.length > 0)
|
|
153
|
+
provider.freeModels = free;
|
|
154
|
+
else
|
|
155
|
+
delete provider.freeModels;
|
|
156
|
+
}
|
|
157
|
+
if (provider.modelNames === undefined)
|
|
158
|
+
return;
|
|
159
|
+
const saved = provider.modelNames;
|
|
160
|
+
const names = {};
|
|
161
|
+
if (saved && typeof saved === 'object' && !Array.isArray(saved)) {
|
|
162
|
+
for (const [model, name] of Object.entries(saved)) {
|
|
163
|
+
if (!model.trim() || model.length > 500 || ['__proto__', 'constructor', 'prototype'].includes(model) || typeof name !== 'string')
|
|
164
|
+
continue;
|
|
165
|
+
const cleaned = cleanModelName(name);
|
|
166
|
+
if (cleaned !== undefined)
|
|
167
|
+
names[model] = cleaned;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (Object.keys(names).length > 0)
|
|
171
|
+
provider.modelNames = names;
|
|
172
|
+
else
|
|
173
|
+
delete provider.modelNames;
|
|
174
|
+
}
|
|
175
|
+
export const MAX_GRAPH_VISIBILITY_PROJECTS = 500;
|
|
176
|
+
const isPlainRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
177
|
+
/** Per account (subject), per graph id: the project paths the graph is listed in. A graph with no entry is listed everywhere. */
|
|
178
|
+
export function validGraphVisibility(value) {
|
|
179
|
+
if (!isPlainRecord(value))
|
|
180
|
+
return false;
|
|
181
|
+
return Object.entries(value).every(([subject, graphs]) => /^[A-Za-z0-9-]{1,128}$/.test(subject) && isPlainRecord(graphs)
|
|
182
|
+
&& Object.entries(graphs).every(([graph, paths]) => /^[\w-]{1,128}$/.test(graph) && graph !== 'default' && Array.isArray(paths)
|
|
183
|
+
&& paths.length <= MAX_GRAPH_VISIBILITY_PROJECTS
|
|
184
|
+
&& paths.every(path => typeof path === 'string' && path.length > 0 && path.length <= 4096 && !path.includes('\0'))));
|
|
185
|
+
}
|
|
122
186
|
export function validateConfig(value) {
|
|
123
187
|
const c = value;
|
|
124
188
|
if (!c || c.version !== 1 || typeof c.provider !== 'string' || !Array.isArray(c.providers)) {
|
|
@@ -133,6 +197,11 @@ export function validateConfig(value) {
|
|
|
133
197
|
if (c.graphSelections !== undefined && (!c.graphSelections || typeof c.graphSelections !== 'object' || Array.isArray(c.graphSelections)
|
|
134
198
|
|| Object.entries(c.graphSelections).some(([subject, graph]) => !/^[A-Za-z0-9-]{1,128}$/.test(subject) || typeof graph !== 'string' || !/^[\w-]{1,128}$/.test(graph))))
|
|
135
199
|
throw new Error('Invalid account graph selections');
|
|
200
|
+
if (c.graphVisibility !== undefined && !validGraphVisibility(c.graphVisibility))
|
|
201
|
+
throw new Error('Invalid account graph visibility');
|
|
202
|
+
if (c.graphVisibilityChosen !== undefined && (!isPlainRecord(c.graphVisibilityChosen) || Object.entries(c.graphVisibilityChosen).some(([subject, graphs]) => !/^[A-Za-z0-9-]{1,128}$/.test(subject)
|
|
203
|
+
|| !Array.isArray(graphs) || graphs.some(graph => typeof graph !== 'string' || !/^[\w-]{1,128}$/.test(graph)))))
|
|
204
|
+
throw new Error('Invalid account graph visibility choices');
|
|
136
205
|
if (c.externalSubagent !== undefined && (!c.externalSubagent || typeof c.externalSubagent !== 'object' || Array.isArray(c.externalSubagent)
|
|
137
206
|
|| typeof c.externalSubagent.provider !== 'string' || !/^[\w-]+$/.test(c.externalSubagent.provider)
|
|
138
207
|
|| typeof c.externalSubagent.model !== 'string' || !c.externalSubagent.model.trim() || c.externalSubagent.model.length > 500)) {
|
|
@@ -200,7 +269,10 @@ export function validateConfig(value) {
|
|
|
200
269
|
return c;
|
|
201
270
|
}
|
|
202
271
|
const ids = new Set();
|
|
272
|
+
let andorraSeen = false;
|
|
203
273
|
for (const p of c.providers) {
|
|
274
|
+
if (p && typeof p === 'object' && p.type === 'andorra')
|
|
275
|
+
normaliseAndorraEntry(p);
|
|
204
276
|
if (!p || typeof p.id !== 'string' || !/^[\w-]+$/.test(p.id) || ids.has(p.id)
|
|
205
277
|
|| !PROVIDER_TYPES.includes(p.type)
|
|
206
278
|
|| typeof p.model !== 'string' || !p.model.trim() || p.model.length > 500 || typeof p.baseUrl !== 'string'
|
|
@@ -233,6 +305,17 @@ export function validateConfig(value) {
|
|
|
233
305
|
}
|
|
234
306
|
}
|
|
235
307
|
}
|
|
308
|
+
if (p.modelNames !== undefined) {
|
|
309
|
+
const names = p.modelNames;
|
|
310
|
+
// An Andorra entry's names were normalised above; on any other provider the key has no meaning.
|
|
311
|
+
if (p.type !== 'andorra' || !names || typeof names !== 'object' || Array.isArray(names)) {
|
|
312
|
+
throw new Error('Provider modelNames is an Andorra-only map of model ids to one-line display names of up to 80 characters');
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// An Andorra entry's were normalised above; on any other provider the keys have no meaning.
|
|
316
|
+
if (p.type !== 'andorra' && (p.modelParameters !== undefined || p.freeModels !== undefined)) {
|
|
317
|
+
throw new Error('Provider modelParameters and freeModels are Andorra-only and maintained by Andorra Code');
|
|
318
|
+
}
|
|
236
319
|
if (p.reasoningEffort !== undefined && (!['openai-compatible', 'opencode-go', 'anthropic'].includes(p.type) || !REASONING_EFFORTS.includes(p.reasoningEffort))) {
|
|
237
320
|
throw new Error('Invalid reasoningEffort: use an OpenAI-compatible, OpenCode Go or Anthropic provider and none, minimal, low, medium, high, xhigh, or max');
|
|
238
321
|
}
|
|
@@ -261,9 +344,17 @@ export function validateConfig(value) {
|
|
|
261
344
|
if (p.type === 'grok' && p.baseUrl !== GROK_BASE_URL) {
|
|
262
345
|
throw new Error('Grok providers use the installed Grok CLI sign-in; custom endpoints are not supported');
|
|
263
346
|
}
|
|
347
|
+
if (p.type === 'google' && p.baseUrl !== GOOGLE_BASE_URL) {
|
|
348
|
+
throw new Error('Google providers use the installed Antigravity CLI sign-in; custom endpoints are not supported');
|
|
349
|
+
}
|
|
264
350
|
if (p.type === 'opencode' && p.baseUrl !== OPENCODE_BASE_URL) {
|
|
265
351
|
throw new Error('OpenCode providers use the installed OpenCode CLI; custom endpoints are not supported');
|
|
266
352
|
}
|
|
353
|
+
if (p.type === 'andorra') {
|
|
354
|
+
if (andorraSeen)
|
|
355
|
+
throw new Error('Only one Andorra provider can be configured');
|
|
356
|
+
andorraSeen = true;
|
|
357
|
+
}
|
|
267
358
|
if (p.type === 'opencode' && [p.model, ...(p.models ?? [])].some(model => !/^[^/\s]+\/\S/.test(model))) {
|
|
268
359
|
throw new Error('OpenCode models are named provider/model, for example opencode/big-pickle');
|
|
269
360
|
}
|
|
@@ -615,19 +706,59 @@ async function withConfigLock(directory, run) {
|
|
|
615
706
|
}
|
|
616
707
|
}
|
|
617
708
|
}
|
|
709
|
+
/**
|
|
710
|
+
* Called by every config write, inside the save lock, on the config about to be written: when the user removed the
|
|
711
|
+
* Andorra provider (the decision in `andorra-hosted.json` says `removed`) an Andorra entry in it is dropped, with
|
|
712
|
+
* the selection moved off it and a pair that named it cleared. The decision is read here, under the lock the
|
|
713
|
+
* removal's own save takes, so a writer holding a copy of the config from before the removal (the terminal app
|
|
714
|
+
* saves the config it has in memory) cannot bring the entry back, and an entry left behind by an interrupted
|
|
715
|
+
* removal goes with the next save. The state file is only read here, never updated (see the lock rule in
|
|
716
|
+
* `src/andorra/state.ts`). A state that cannot be read leaves the config as it is.
|
|
717
|
+
*/
|
|
718
|
+
async function withoutRemovedAndorra(config, directory) {
|
|
719
|
+
const entry = config.providers.find(provider => provider.type === 'andorra');
|
|
720
|
+
if (entry === undefined)
|
|
721
|
+
return config;
|
|
722
|
+
let decision;
|
|
723
|
+
try {
|
|
724
|
+
decision = (await readHostedState(directory)).entry;
|
|
725
|
+
}
|
|
726
|
+
catch {
|
|
727
|
+
return config;
|
|
728
|
+
}
|
|
729
|
+
if (decision !== 'removed')
|
|
730
|
+
return config;
|
|
731
|
+
const providers = config.providers.filter(provider => provider !== entry);
|
|
732
|
+
return reconcileSubagentPair({ ...config, providers, provider: config.provider === entry.id ? fallbackProviderId(providers) : config.provider });
|
|
733
|
+
}
|
|
734
|
+
/** Saves a whole config. When an Andorra entry the user removed is dropped (see above), `config` itself is updated to match what was saved. */
|
|
618
735
|
export async function saveConfig(config, directory = configDirectory()) {
|
|
619
|
-
await withConfigLock(directory, () =>
|
|
736
|
+
await withConfigLock(directory, async () => {
|
|
737
|
+
const saved = await withoutRemovedAndorra(config, directory);
|
|
738
|
+
if (saved !== config) {
|
|
739
|
+
config.providers = saved.providers;
|
|
740
|
+
config.provider = saved.provider;
|
|
741
|
+
if (saved.externalSubagent === undefined)
|
|
742
|
+
delete config.externalSubagent;
|
|
743
|
+
}
|
|
744
|
+
await writeConfig(config, directory);
|
|
745
|
+
});
|
|
620
746
|
}
|
|
621
747
|
export class ConfigConflictError extends Error {
|
|
622
748
|
constructor() { super('The configuration changed while this change was being applied. Try again.'); this.name = 'ConfigConflictError'; }
|
|
623
749
|
}
|
|
624
|
-
|
|
750
|
+
/**
|
|
751
|
+
* `prepare`, when given, runs once inside the cross-process config lock before the config is read, and its
|
|
752
|
+
* result is handed to `change`: for a change that depends on other saved state, which must be read under the lock.
|
|
753
|
+
*/
|
|
754
|
+
export async function changeConfigFile(directory, change, attempts = 3, prepare) {
|
|
625
755
|
const stored = join(directory, 'config.json');
|
|
626
756
|
const read = async () => await readFile(stored, 'utf8').catch(() => undefined);
|
|
627
757
|
return await withConfigLock(directory, async () => {
|
|
758
|
+
const prepared = (prepare === undefined ? undefined : await prepare());
|
|
628
759
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
629
760
|
const before = await read();
|
|
630
|
-
const next = change((await readStoredConfig(directory)).config);
|
|
761
|
+
const next = await withoutRemovedAndorra(change((await readStoredConfig(directory)).config, prepared), directory);
|
|
631
762
|
if (await read() !== before)
|
|
632
763
|
continue;
|
|
633
764
|
await writeConfig(next, directory);
|
|
@@ -22,6 +22,8 @@ export interface DashboardView {
|
|
|
22
22
|
model: string;
|
|
23
23
|
graph?: Graph;
|
|
24
24
|
providerModels?: Readonly<Record<string, string>>;
|
|
25
|
+
/** Provider id → model id → display name; a model without one shows its id. */
|
|
26
|
+
modelNames?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
25
27
|
activeNodes: readonly string[];
|
|
26
28
|
nodeModels: ReadonlyMap<string, string>;
|
|
27
29
|
todos: readonly TodoItem[];
|
|
@@ -104,6 +104,11 @@ function beside(left, right, leftWidth, rightWidth) {
|
|
|
104
104
|
segments: [...fitRow(left[index] ?? empty, leftWidth).segments, seg(' '), ...fitRow(right[index] ?? empty, rightWidth).segments],
|
|
105
105
|
}));
|
|
106
106
|
}
|
|
107
|
+
function named(view, provider, model) {
|
|
108
|
+
const own = view.modelNames && Object.hasOwn(view.modelNames, provider) ? view.modelNames[provider] : undefined;
|
|
109
|
+
const name = own && Object.hasOwn(own, model) ? own[model] : undefined;
|
|
110
|
+
return typeof name === 'string' && name ? name : model;
|
|
111
|
+
}
|
|
107
112
|
function graphRows(view) {
|
|
108
113
|
const graph = view.graph;
|
|
109
114
|
if (!graph)
|
|
@@ -127,7 +132,11 @@ function graphRows(view) {
|
|
|
127
132
|
}
|
|
128
133
|
const current = active.has(id);
|
|
129
134
|
const model = view.nodeModels.get(id) ?? (node.type === 'agent'
|
|
130
|
-
?
|
|
135
|
+
? (() => {
|
|
136
|
+
const provider = node.provider ?? view.provider;
|
|
137
|
+
const model = node.model ?? (node.provider && node.provider !== view.provider ? view.providerModels?.[node.provider] : view.model);
|
|
138
|
+
return `${provider}/${model === undefined ? 'Unavailable' : named(view, provider, model)}`;
|
|
139
|
+
})() : node.type);
|
|
131
140
|
rows.push(row(seg(current ? '● ' : '○ ', current ? focus : FAINT), seg(node.name, current ? WHITE : GRAY)));
|
|
132
141
|
rows.push(row(seg(` ${model}`, FAINT)));
|
|
133
142
|
}
|
|
@@ -150,7 +159,7 @@ export function dashboardRows(view, width, height) {
|
|
|
150
159
|
const value = (reading) => seg(reading, DIM);
|
|
151
160
|
const count = (reading) => reading === undefined ? unavailable : value(number.format(reading));
|
|
152
161
|
const speed = model?.tokensPerSecond !== undefined ? value(`${model.tokensPerSecond.toFixed(1)} tok/s`) : unavailable;
|
|
153
|
-
const identity = model ? row(seg(`${model.provider}/${model.model}`, WHITE)) : row(seg(`${view.provider}/${view.model}`, WHITE), seg(' · no requests', FAINT));
|
|
162
|
+
const identity = model ? row(seg(`${model.provider}/${named(view, model.provider, model.model)}`, WHITE)) : row(seg(`${view.provider}/${named(view, view.provider, view.model)}`, WHITE), seg(' · no requests', FAINT));
|
|
154
163
|
const tokenHint = `${selected + 1}/${models} · Ctrl+N`;
|
|
155
164
|
const tokenCard = (cardWidth) => card('Session tokens', tokenHint, [
|
|
156
165
|
identity,
|
|
@@ -5,7 +5,7 @@ export const PREPARE_STEPS = 'prepare_steps';
|
|
|
5
5
|
export const PREPARED_TRIGGERS = ['success', 'failure', 'always'];
|
|
6
6
|
const kinds = ['investigate', 'retry', 'change_strategy', 'verify', 'complete'];
|
|
7
7
|
const triggerKinds = new Set(['investigate', 'verify']);
|
|
8
|
-
const forbidden = new Set([PREPARE_STEPS, 'complete_agent', 'update_todos', 'ask_user', 'spawn_subagent', 'accept_change', 'discard_change', 'remove_untracked_file']);
|
|
8
|
+
const forbidden = new Set([PREPARE_STEPS, 'complete_agent', 'update_todos', 'ask_user', 'spawn_subagent', 'wait_subagent', 'message_subagent', 'cancel_subagent', 'accept_change', 'discard_change', 'remove_untracked_file']);
|
|
9
9
|
const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
10
10
|
export function boundedDecisionText(text, bytes) {
|
|
11
11
|
const value = redactSecrets(text).text;
|
|
@@ -17,7 +17,7 @@ export async function applyToolMenu(options) {
|
|
|
17
17
|
const signal = pause ? AbortSignal.any([options.context.signal, pause]) : options.context.signal;
|
|
18
18
|
const previous = options.resumeMessages ?? options.previousConversation?.messages ?? [];
|
|
19
19
|
const historical = [...new Set([...previous.flatMap(message => (message.toolCalls ?? []).map(call => call.name)), ...(options.efficiency?.toolMenuRouting?.pinnedTools ?? [])])];
|
|
20
|
-
const identity = { runId: options.runId ?? randomUUID(), nodeId: options.nodeId ?? 'engineer', invocationId: randomUUID() };
|
|
20
|
+
const identity = { runId: options.runId ?? randomUUID(), nodeId: options.nodeId ?? 'engineer', invocationId: randomUUID(), ...(options.subagentId ? { subagentId: options.subagentId } : {}) };
|
|
21
21
|
const emit = async (data) => {
|
|
22
22
|
try {
|
|
23
23
|
await options.onEvent?.({ type: 'efficiency.tool_menu', time: new Date().toISOString(), data: { ...identity, mode, ...data } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DecisionPolicy } from './DecisionPolicy.js';
|
|
2
2
|
import { hasFactGuidance } from './guidancePolicy.js';
|
|
3
|
-
const families = { Read: 'filesystem-read', Glob: 'code-search', Grep: 'code-search', Write: 'filesystem-write', Edit: 'filesystem-write', Bash: 'shell', PowerShell: 'shell', NativeExec: 'shell', AsyncProcess: 'shell', PowerShellFast: 'shell', ShellMetrics: 'shell', read: 'filesystem-read', ls: 'filesystem-read', find: 'code-search', grep: 'code-search', write: 'filesystem-write', edit: 'filesystem-write', powershell: 'shell', bash: 'shell', read_file: 'filesystem-read', list_files: 'filesystem-read', write_file: 'filesystem-write', edit_file: 'filesystem-write', apply_patch: 'filesystem-write', search_files: 'code-search', repo_explore: 'codegraph', git_read: 'git', pull_request: 'git', shell: 'shell', memory_search: 'memory', spawn_subagent: 'subagents', read_artifact: 'artifact', write_artifact: 'artifact' };
|
|
3
|
+
const families = { Read: 'filesystem-read', Glob: 'code-search', Grep: 'code-search', Write: 'filesystem-write', Edit: 'filesystem-write', Bash: 'shell', PowerShell: 'shell', NativeExec: 'shell', AsyncProcess: 'shell', PowerShellFast: 'shell', ShellMetrics: 'shell', read: 'filesystem-read', ls: 'filesystem-read', find: 'code-search', grep: 'code-search', write: 'filesystem-write', edit: 'filesystem-write', powershell: 'shell', bash: 'shell', read_file: 'filesystem-read', list_files: 'filesystem-read', write_file: 'filesystem-write', edit_file: 'filesystem-write', apply_patch: 'filesystem-write', search_files: 'code-search', repo_explore: 'codegraph', git_read: 'git', pull_request: 'git', shell: 'shell', memory_search: 'memory', spawn_subagent: 'subagents', wait_subagent: 'subagents', message_subagent: 'subagents', cancel_subagent: 'subagents', read_artifact: 'artifact', write_artifact: 'artifact' };
|
|
4
4
|
const protectedTools = new Set(['complete_agent', 'complete', 'complete_task', 'submit_completion', 'update_todos', 'ask_user', 'load_project_skill', 'restore_tools', 'prepare_steps', 'prepare_finish']);
|
|
5
5
|
export function toolFamily(tool) { return tool.family ?? families[tool.name]; }
|
|
6
6
|
export function toolFamilies(tools) { return [...new Set(tools.map(toolFamily).filter((family) => family !== undefined))]; }
|