@andorra-labs/code 0.1.17 → 0.1.19
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-jev-savings.d.ts +4 -0
- package/dist/src/account-jev-savings.js +92 -0
- package/dist/src/acp-agent.js +2 -2
- package/dist/src/agent-execution.js +441 -53
- package/dist/src/agent-mcp.js +7 -1
- package/dist/src/agent-modifiers.js +5 -7
- package/dist/src/analytics.d.ts +19 -1
- package/dist/src/analytics.js +9 -1
- package/dist/src/andorra/entry.js +15 -6
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/andorra/hosted.d.ts +8 -0
- package/dist/src/andorra/hosted.js +22 -3
- package/dist/src/andorra/streams.d.ts +49 -0
- package/dist/src/andorra/streams.js +98 -0
- package/dist/src/antigravity-acp.d.ts +28 -0
- package/dist/src/antigravity-acp.js +150 -0
- package/dist/src/antigravity-terminal.d.ts +2 -0
- package/dist/src/antigravity-terminal.js +214 -0
- package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
- package/dist/src/app-server/adaptive-routing-settings.js +69 -0
- package/dist/src/app-server/artifact.d.ts +14 -0
- package/dist/src/app-server/artifact.js +46 -0
- package/dist/src/app-server/legal-protocol.d.ts +33 -0
- package/dist/src/app-server/legal-protocol.js +16 -0
- package/dist/src/app-server/protocol.d.ts +34 -3
- package/dist/src/app-server/protocol.js +3 -1
- package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
- package/dist/src/app-server/telemetry-protocol.js +2 -0
- package/dist/src/app-server/telemetry.d.ts +38 -0
- package/dist/src/app-server/telemetry.js +163 -0
- package/dist/src/app-server/workspace.d.ts +21 -0
- package/dist/src/app-server/workspace.js +192 -10
- package/dist/src/app-server.d.ts +82 -26
- package/dist/src/app-server.js +1573 -417
- package/dist/src/attachments.d.ts +10 -0
- package/dist/src/attachments.js +102 -7
- package/dist/src/auth/AuthManager.d.ts +11 -2
- package/dist/src/auth/AuthManager.js +56 -13
- package/dist/src/auth/index.d.ts +5 -1
- package/dist/src/auth/index.js +8 -1
- package/dist/src/auth/lifecycle.d.ts +13 -0
- package/dist/src/auth/lifecycle.js +109 -0
- package/dist/src/auth/store.d.ts +1 -0
- package/dist/src/auth/store.js +12 -0
- package/dist/src/auth/types.d.ts +12 -0
- package/dist/src/automation-runner.js +2 -0
- package/dist/src/automation-service.js +7 -2
- package/dist/src/automation-tool.js +2 -1
- package/dist/src/benchmark-scores.d.ts +88 -0
- package/dist/src/benchmark-scores.js +302 -0
- package/dist/src/bridge/command.js +16 -1
- package/dist/src/bridge/control.d.ts +3 -1
- package/dist/src/bridge/control.js +9 -3
- package/dist/src/bridge/engines.d.ts +2 -0
- package/dist/src/bridge/engines.js +9 -0
- package/dist/src/bridge/github.d.ts +108 -0
- package/dist/src/bridge/github.js +378 -0
- package/dist/src/bridge/host-ops.d.ts +3 -3
- package/dist/src/bridge/host-ops.js +14 -2
- package/dist/src/bridge/host.d.ts +2 -0
- package/dist/src/bridge/host.js +70 -16
- package/dist/src/bridge/protocol.d.ts +1 -0
- package/dist/src/bridge/protocol.js +1 -0
- package/dist/src/browser-panel-tool.d.ts +12 -0
- package/dist/src/browser-panel-tool.js +30 -3
- package/dist/src/browser-runner.js +53 -62
- package/dist/src/browser-server.js +10 -4
- package/dist/src/browser-session.d.ts +14 -0
- package/dist/src/browser-session.js +57 -12
- package/dist/src/browser-view.d.ts +40 -1
- package/dist/src/browser-view.js +163 -9
- package/dist/src/browser-window-style.d.ts +27 -0
- package/dist/src/browser-window-style.js +244 -0
- package/dist/src/bug-report-attachments.d.ts +48 -0
- package/dist/src/bug-report-attachments.js +327 -0
- package/dist/src/bug-report.d.ts +23 -3
- package/dist/src/bug-report.js +72 -9
- package/dist/src/claude-provider.d.ts +1 -0
- package/dist/src/claude-provider.js +77 -36
- package/dist/src/cli.d.ts +1 -3
- package/dist/src/cli.js +245 -62
- package/dist/src/codex-provider.d.ts +1 -0
- package/dist/src/codex-provider.js +44 -8
- package/dist/src/coding-tools.d.ts +1 -0
- package/dist/src/coding-tools.js +28 -7
- package/dist/src/command-screens.d.ts +1 -1
- package/dist/src/command-screens.js +2 -2
- package/dist/src/commands.d.ts +9 -2
- package/dist/src/commands.js +69 -64
- package/dist/src/completion.js +13 -7
- package/dist/src/config.d.ts +14 -3
- package/dist/src/config.js +57 -17
- package/dist/src/context-budget.d.ts +11 -2
- package/dist/src/context-budget.js +38 -4
- package/dist/src/context-compaction.d.ts +10 -8
- package/dist/src/context-compaction.js +23 -24
- package/dist/src/deadline.js +1 -1
- package/dist/src/decision/DecisionEngine.d.ts +2 -0
- package/dist/src/decision/DecisionManager.d.ts +16 -0
- package/dist/src/decision/DecisionManager.js +75 -2
- package/dist/src/decision/applyTaskKind.d.ts +8 -0
- package/dist/src/decision/applyTaskKind.js +53 -0
- package/dist/src/decision/applyToolMenu.js +6 -2
- package/dist/src/decision/hostedPolicy.js +6 -3
- package/dist/src/decision/optimizationPolicy.d.ts +10 -0
- package/dist/src/decision/optimizationPolicy.js +23 -3
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
- package/dist/src/decision/providers/index.js +1 -1
- package/dist/src/decision/taskKind.d.ts +52 -0
- package/dist/src/decision/taskKind.js +76 -0
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +3 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/efficiency.d.ts +80 -1
- package/dist/src/efficiency.js +119 -4
- package/dist/src/effort-routing.d.ts +27 -0
- package/dist/src/effort-routing.js +34 -0
- package/dist/src/evidence.d.ts +110 -0
- package/dist/src/evidence.js +195 -0
- package/dist/src/extensions.d.ts +2 -0
- package/dist/src/extensions.js +30 -20
- package/dist/src/github-app/agent-writes.d.ts +1 -1
- package/dist/src/github-app/agent-writes.js +1 -1
- package/dist/src/github-app/client.d.ts +19 -0
- package/dist/src/github-app/client.js +21 -1
- package/dist/src/github-app/event-source.d.ts +0 -5
- package/dist/src/github-app/event-source.js +1 -31
- package/dist/src/github-app/metrics.d.ts +2 -5
- package/dist/src/github-app/metrics.js +2 -14
- package/dist/src/github-app/review-loop.d.ts +5 -5
- package/dist/src/github-app/review-loop.js +1 -1
- package/dist/src/github-app/review-node.d.ts +2 -2
- package/dist/src/github-app/triggers.d.ts +3 -3
- package/dist/src/github-names.d.ts +7 -0
- package/dist/src/github-names.js +7 -0
- package/dist/src/glob-search.d.ts +1 -0
- package/dist/src/glob-search.js +3 -0
- package/dist/src/google-provider.d.ts +5 -28
- package/dist/src/google-provider.js +6 -141
- package/dist/src/graph-editor-session.d.ts +1 -0
- package/dist/src/graph-editor-session.js +2 -0
- package/dist/src/graph-health.js +3 -1
- package/dist/src/graph-preview.d.ts +2 -0
- package/dist/src/graph-preview.js +1 -0
- package/dist/src/graph-runner.js +20 -14
- package/dist/src/graph-selection.d.ts +3 -1
- package/dist/src/graph-selection.js +2 -2
- package/dist/src/graph-server.d.ts +8 -1
- package/dist/src/graph-server.js +49 -12
- package/dist/src/graph-sync.d.ts +2 -1
- package/dist/src/graph-sync.js +13 -0
- package/dist/src/graph-ui/app.js +49 -8
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graphs.d.ts +23 -1
- package/dist/src/graphs.js +58 -7
- package/dist/src/grok-provider.js +17 -14
- package/dist/src/hardened-runtime.js +39 -25
- package/dist/src/jev-savings.d.ts +4 -0
- package/dist/src/jev-savings.js +13 -0
- package/dist/src/legal/client.d.ts +25 -0
- package/dist/src/legal/client.js +47 -0
- package/dist/src/legal/command.d.ts +13 -0
- package/dist/src/legal/command.js +98 -0
- package/dist/src/legal/documents.d.ts +2 -0
- package/dist/src/legal/documents.js +14 -0
- package/dist/src/legal/gate.d.ts +13 -0
- package/dist/src/legal/gate.js +96 -0
- package/dist/src/legal/manifest.d.ts +21 -0
- package/dist/src/legal/manifest.js +23 -0
- package/dist/src/legal/receipt.d.ts +13 -0
- package/dist/src/legal/receipt.js +137 -0
- package/dist/src/legal/release.d.ts +27 -0
- package/dist/src/legal/release.js +28 -0
- package/dist/src/managed-sign-in.d.ts +0 -1
- package/dist/src/managed-sign-in.js +0 -13
- package/dist/src/membership.d.ts +27 -1
- package/dist/src/membership.js +139 -7
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.js +3 -7
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-pool.d.ts +99 -0
- package/dist/src/model-pool.js +136 -0
- package/dist/src/model-relay/local.js +5 -0
- package/dist/src/model-relay/remote.d.ts +2 -0
- package/dist/src/model-relay/remote.js +4 -0
- package/dist/src/model-tiers.d.ts +16 -1
- package/dist/src/model-tiers.js +31 -7
- package/dist/src/opencode-cli-provider.js +59 -56
- package/dist/src/opencode-provider.js +16 -13
- package/dist/src/permissions.d.ts +5 -0
- package/dist/src/permissions.js +7 -0
- package/dist/src/plan-pass.js +2 -1
- package/dist/src/pool-scores.d.ts +45 -0
- package/dist/src/pool-scores.js +40 -0
- package/dist/src/provider-connection.js +3 -17
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +116 -12
- package/dist/src/provider-request-error.d.ts +8 -0
- package/dist/src/provider-request-error.js +12 -0
- package/dist/src/provider-settings.d.ts +1 -1
- package/dist/src/provider-settings.js +36 -18
- package/dist/src/provider-turn-deadline.d.ts +39 -0
- package/dist/src/provider-turn-deadline.js +139 -0
- package/dist/src/providers.d.ts +8 -9
- package/dist/src/providers.js +211 -150
- package/dist/src/pull-request-merge.d.ts +1 -8
- package/dist/src/pull-request-merge.js +0 -4
- package/dist/src/pull-requests.d.ts +83 -57
- package/dist/src/pull-requests.js +266 -225
- package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
- package/dist/src/qa/runtime/ProcessManager.js +9 -3
- package/dist/src/react-runtime.js +245 -71
- package/dist/src/reasoning-probe-cloud.d.ts +10 -0
- package/dist/src/reasoning-probe-cloud.js +209 -0
- package/dist/src/remote/engine-pool.d.ts +3 -0
- package/dist/src/remote/engine-pool.js +88 -21
- package/dist/src/remote/recovery.d.ts +6 -0
- package/dist/src/remote/recovery.js +37 -0
- package/dist/src/run-records.d.ts +13 -3
- package/dist/src/run-records.js +59 -34
- package/dist/src/runtime.d.ts +47 -2
- package/dist/src/runtime.js +33 -7
- package/dist/src/session-summary.d.ts +8 -0
- package/dist/src/session-summary.js +34 -0
- package/dist/src/sessions.d.ts +32 -0
- package/dist/src/sessions.js +65 -3
- package/dist/src/shell.js +6 -0
- package/dist/src/side-panel.js +36 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +4 -10
- 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 +51 -7
- package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
- package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/subagent-run.js +50 -50
- package/dist/src/subscription-usage.d.ts +50 -0
- package/dist/src/subscription-usage.js +92 -0
- package/dist/src/task-checkout.d.ts +157 -0
- package/dist/src/task-checkout.js +628 -0
- package/dist/src/telemetry/access.d.ts +18 -0
- package/dist/src/telemetry/access.js +43 -0
- package/dist/src/telemetry/aggregate.d.ts +18 -2
- package/dist/src/telemetry/aggregate.js +22 -9
- package/dist/src/telemetry/capture-core.d.ts +33 -14
- package/dist/src/telemetry/capture-core.js +124 -25
- package/dist/src/telemetry/capture.d.ts +3 -2
- package/dist/src/telemetry/capture.js +21 -1
- package/dist/src/telemetry/decision-capture.js +4 -0
- package/dist/src/telemetry/emitter.d.ts +6 -7
- package/dist/src/telemetry/emitter.js +124 -29
- package/dist/src/telemetry/gate.d.ts +41 -2
- package/dist/src/telemetry/gate.js +89 -4
- package/dist/src/telemetry/home.d.ts +1 -0
- package/dist/src/telemetry/home.js +20 -0
- package/dist/src/telemetry/identity.d.ts +6 -3
- package/dist/src/telemetry/identity.js +19 -6
- package/dist/src/telemetry/lifecycle.d.ts +8 -0
- package/dist/src/telemetry/lifecycle.js +76 -0
- package/dist/src/telemetry/outbox.d.ts +13 -8
- package/dist/src/telemetry/outbox.js +68 -12
- package/dist/src/telemetry/permission-command.d.ts +38 -0
- package/dist/src/telemetry/permission-command.js +208 -0
- package/dist/src/telemetry/permission.d.ts +168 -0
- package/dist/src/telemetry/permission.js +662 -0
- package/dist/src/telemetry/record-installation.d.ts +1 -0
- package/dist/src/telemetry/record-installation.js +9 -0
- package/dist/src/telemetry/region-data.d.ts +12 -0
- package/dist/src/telemetry/region-data.js +1314 -0
- package/dist/src/telemetry/region.d.ts +34 -0
- package/dist/src/telemetry/region.js +87 -0
- package/dist/src/telemetry/run-privacy.d.ts +11 -0
- package/dist/src/telemetry/run-privacy.js +165 -0
- package/dist/src/telemetry/schema.d.ts +27 -6
- package/dist/src/telemetry/schema.js +109 -14
- package/dist/src/telemetry/state.d.ts +11 -7
- package/dist/src/telemetry/state.js +39 -6
- package/dist/src/telemetry/surface.d.ts +20 -3
- package/dist/src/telemetry/surface.js +71 -15
- package/dist/src/telemetry/uploader.d.ts +6 -11
- package/dist/src/telemetry/uploader.js +72 -46
- package/dist/src/telemetry/uploads.d.ts +5 -1
- package/dist/src/telemetry/uploads.js +25 -6
- package/dist/src/telemetry/version.d.ts +5 -0
- package/dist/src/telemetry/version.js +34 -0
- package/dist/src/telemetry/workspace.d.ts +4 -1
- package/dist/src/telemetry/workspace.js +18 -3
- package/dist/src/terminal-ui.d.ts +3 -0
- package/dist/src/terminal-ui.js +48 -6
- package/dist/src/test-edit-guard.d.ts +30 -0
- package/dist/src/test-edit-guard.js +167 -2
- package/dist/src/thinking-level-detect.d.ts +13 -0
- package/dist/src/thinking-level-detect.js +52 -0
- package/dist/src/thinking-levels.d.ts +30 -0
- package/dist/src/thinking-levels.js +131 -0
- package/dist/src/timers.d.ts +3 -0
- package/dist/src/todos.d.ts +2 -1
- package/dist/src/todos.js +24 -4
- package/dist/src/tool-argument-coercion.d.ts +7 -0
- package/dist/src/tool-argument-coercion.js +49 -0
- package/dist/src/tool-catalog.d.ts +2 -2
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/tools.js +67 -22
- package/dist/src/transcript.js +3 -2
- package/dist/src/types.d.ts +48 -1
- package/dist/src/update.js +4 -0
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +85 -13
- package/dist/telemetry-consent-v1 +1 -0
- package/package.json +97 -96
|
@@ -6,6 +6,7 @@ import { codexConnectFor, connectCodex } from './codex-rpc.js';
|
|
|
6
6
|
import { readCodexModels } from './codex-auth.js';
|
|
7
7
|
import { codexTurnFailure } from './codex-errors.js';
|
|
8
8
|
import { ProviderRequestError } from './providers.js';
|
|
9
|
+
import { createProviderTurnDeadline, ProviderTurnTimeoutError } from './provider-turn-deadline.js';
|
|
9
10
|
export const codexInferenceConfig = {
|
|
10
11
|
web_search: 'disabled',
|
|
11
12
|
'features.shell_tool': false, 'features.unified_exec': false,
|
|
@@ -60,6 +61,9 @@ export async function readCodexCatalog(signal, connect = connectCodex) {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
export function createCodexAdapter(config, connect = codexConnectFor(config)) {
|
|
64
|
+
const savedModel = config.model;
|
|
65
|
+
// Codex has no `max` level; its highest is `xhigh`.
|
|
66
|
+
const savedEffort = config.reasoningEffort === 'max' ? 'xhigh' : config.reasoningEffort;
|
|
63
67
|
return {
|
|
64
68
|
async listModels(signal) {
|
|
65
69
|
const rpc = await connect(AbortSignal.any([signal, AbortSignal.timeout(30_000)]));
|
|
@@ -71,13 +75,16 @@ export function createCodexAdapter(config, connect = codexConnectFor(config)) {
|
|
|
71
75
|
}
|
|
72
76
|
},
|
|
73
77
|
async generate(request) {
|
|
74
|
-
const
|
|
75
|
-
signal
|
|
76
|
-
|
|
78
|
+
const deadline = createProviderTurnDeadline(request.signal);
|
|
79
|
+
const { signal } = deadline;
|
|
80
|
+
let close = () => { };
|
|
77
81
|
let cwd;
|
|
78
82
|
let unsubscribe = () => { };
|
|
79
83
|
let abortTurn = () => { };
|
|
80
84
|
try {
|
|
85
|
+
signal.throwIfAborted();
|
|
86
|
+
const rpc = await connect(signal);
|
|
87
|
+
close = () => rpc.close();
|
|
81
88
|
const account = await rpc.request('account/read', { refreshToken: false });
|
|
82
89
|
if (account?.account?.type !== 'chatgpt')
|
|
83
90
|
throw new ProviderRequestError('Run andorra and open /providers to sign in with ChatGPT first.');
|
|
@@ -90,6 +97,10 @@ export function createCodexAdapter(config, connect = codexConnectFor(config)) {
|
|
|
90
97
|
throw new Error('Invalid auxiliary output allowance.');
|
|
91
98
|
config.model_reasoning_effort = 'low';
|
|
92
99
|
}
|
|
100
|
+
else if (savedEffort !== undefined && request.model === savedModel) {
|
|
101
|
+
// The saved or routed thinking level applies only to the model it was chosen for.
|
|
102
|
+
config.model_reasoning_effort = savedEffort;
|
|
103
|
+
}
|
|
93
104
|
const started = await rpc.request('thread/start', {
|
|
94
105
|
model: request.model, modelProvider: 'openai', ephemeral: true, cwd,
|
|
95
106
|
environments: [], runtimeWorkspaceRoots: [], selectedCapabilityRoots: [], dynamicTools: [],
|
|
@@ -109,14 +120,19 @@ export function createCodexAdapter(config, connect = codexConnectFor(config)) {
|
|
|
109
120
|
let connectionError;
|
|
110
121
|
let resolveTurn;
|
|
111
122
|
let rejectTurn;
|
|
123
|
+
const progressMethods = new Set(['item/agentMessage/delta', 'item/reasoning/textDelta', 'item/reasoning/summaryTextDelta', 'item/plan/delta']);
|
|
124
|
+
const earlyProgress = new Set();
|
|
112
125
|
const receiveTurn = (method, params) => {
|
|
113
126
|
const notificationTurnId = method === 'turn/completed' ? params.turn?.id : params.turnId;
|
|
114
127
|
if (notificationTurnId !== turnId)
|
|
115
128
|
return;
|
|
116
129
|
if (method === 'error' && params.willRetry === false)
|
|
117
130
|
turnError = params.error;
|
|
118
|
-
if (method === 'item/completed' && params.item?.type === 'agentMessage')
|
|
131
|
+
if (method === 'item/completed' && params.item?.type === 'agentMessage') {
|
|
119
132
|
finalText = params.item.text;
|
|
133
|
+
if (typeof finalText === 'string' && finalText.length)
|
|
134
|
+
deadline.progress();
|
|
135
|
+
}
|
|
120
136
|
if (method === 'turn/completed') {
|
|
121
137
|
completed = params.turn;
|
|
122
138
|
resolveTurn?.(completed);
|
|
@@ -132,8 +148,18 @@ export function createCodexAdapter(config, connect = codexConnectFor(config)) {
|
|
|
132
148
|
return;
|
|
133
149
|
if (method === 'thread/tokenUsage/updated') {
|
|
134
150
|
const last = params.tokenUsage?.last;
|
|
151
|
+
// Codex counts cached input inside inputTokens, as the engine does.
|
|
135
152
|
if (last)
|
|
136
|
-
usage = { inputTokens: last.inputTokens, outputTokens: last.outputTokens, requests: 1 };
|
|
153
|
+
usage = { inputTokens: last.inputTokens, outputTokens: last.outputTokens, requests: 1, ...(Number.isSafeInteger(last.cachedInputTokens) && last.cachedInputTokens >= 0 ? { cacheRead: last.cachedInputTokens } : {}) };
|
|
154
|
+
}
|
|
155
|
+
if (progressMethods.has(method)) {
|
|
156
|
+
if (typeof params.turnId === 'string' && typeof params.delta === 'string' && params.delta.length) {
|
|
157
|
+
if (turnId === params.turnId)
|
|
158
|
+
deadline.progress();
|
|
159
|
+
else if (turnId === undefined && earlyProgress.size < 32)
|
|
160
|
+
earlyProgress.add(params.turnId);
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
137
163
|
}
|
|
138
164
|
if (!['error', 'item/completed', 'turn/completed'].includes(method))
|
|
139
165
|
return;
|
|
@@ -155,13 +181,17 @@ export function createCodexAdapter(config, connect = codexConnectFor(config)) {
|
|
|
155
181
|
request.onRequest?.();
|
|
156
182
|
const startedTurn = await rpc.request('turn/start', {
|
|
157
183
|
threadId, environments: [], outputSchema,
|
|
158
|
-
input: [{ type: 'text', text: JSON.stringify({ conversation: request.messages.map(({ images, ...message }) => ({ ...message,
|
|
184
|
+
input: [{ type: 'text', text: JSON.stringify({ conversation: request.messages.map(({ images, providerContinuation, ...message }) => ({ ...message,
|
|
159
185
|
...(images?.length ? { imageCount: images.length } : {}) })), availableTools: request.tools }), text_elements: [] },
|
|
160
186
|
...request.messages.flatMap(message => (message.images ?? []).map(image => ({ type: 'image', url: `data:${image.mimeType};base64,${image.data}` })))],
|
|
161
187
|
});
|
|
162
188
|
turnId = startedTurn?.turn?.id;
|
|
163
189
|
if (typeof turnId !== 'string' || !turnId)
|
|
164
190
|
throw new ProviderRequestError('Codex did not start an inference turn');
|
|
191
|
+
deadline.waitForResponse();
|
|
192
|
+
if (earlyProgress.has(turnId))
|
|
193
|
+
deadline.progress();
|
|
194
|
+
earlyProgress.clear();
|
|
165
195
|
for (const notification of earlyNotifications)
|
|
166
196
|
receiveTurn(notification.method, notification.params);
|
|
167
197
|
earlyNotifications.length = 0;
|
|
@@ -184,12 +214,18 @@ export function createCodexAdapter(config, connect = codexConnectFor(config)) {
|
|
|
184
214
|
const response = parseCodexResponse(item?.text ?? finalText);
|
|
185
215
|
if (usage)
|
|
186
216
|
response.usage = usage;
|
|
187
|
-
return response;
|
|
217
|
+
return { ...response, authMode: 'linked-account' };
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
if (signal.reason instanceof ProviderTurnTimeoutError)
|
|
221
|
+
throw signal.reason;
|
|
222
|
+
throw error;
|
|
188
223
|
}
|
|
189
224
|
finally {
|
|
190
225
|
signal.removeEventListener('abort', abortTurn);
|
|
226
|
+
deadline.dispose();
|
|
191
227
|
unsubscribe();
|
|
192
|
-
|
|
228
|
+
close();
|
|
193
229
|
if (cwd)
|
|
194
230
|
await rm(cwd, { recursive: true, force: true });
|
|
195
231
|
}
|
package/dist/src/coding-tools.js
CHANGED
|
@@ -784,11 +784,12 @@ export function createCodingTools(policy) {
|
|
|
784
784
|
rows.push(`${relative}:${matches}`);
|
|
785
785
|
return true;
|
|
786
786
|
};
|
|
787
|
+
const walkBudget = { entries: 0, limit: GREP_FALLBACK_ENTRY_LIMIT };
|
|
787
788
|
if (info.isFile())
|
|
788
789
|
await searchFile(resolved);
|
|
789
790
|
else {
|
|
790
791
|
try {
|
|
791
|
-
for await (const candidate of policy.files(searchContext, resolved, 0,
|
|
792
|
+
for await (const candidate of policy.files(searchContext, resolved, 0, walkBudget)) {
|
|
792
793
|
searchSignal.throwIfAborted();
|
|
793
794
|
progress();
|
|
794
795
|
if (rows.length >= offset + limit) {
|
|
@@ -806,6 +807,11 @@ export function createCodingTools(policy) {
|
|
|
806
807
|
incomplete = `stopped at the ${GREP_FALLBACK_ENTRY_LIMIT.toLocaleString('en-US')}-entry directory scan limit with ${scanned()}`;
|
|
807
808
|
}
|
|
808
809
|
}
|
|
810
|
+
// The walker skips folders it may not open; say so, or a miss would read as a plain "No matches".
|
|
811
|
+
if (walkBudget.unreadable) {
|
|
812
|
+
const skipped = `${walkBudget.unreadable.toLocaleString('en-US')} folder${walkBudget.unreadable === 1 ? '' : 's'} could not be opened (permission denied) and ${walkBudget.unreadable === 1 ? 'was' : 'were'} skipped`;
|
|
813
|
+
incomplete = incomplete ? `${incomplete}; ${skipped}` : skipped;
|
|
814
|
+
}
|
|
809
815
|
const selected = rows.slice(offset, offset + limit);
|
|
810
816
|
const more = moreRows || rows.length > offset + limit;
|
|
811
817
|
const narrow = `Narrow the search with path (a subdirectory or one file) or glob (for example "*.py")${restricted ? '' : `, or run ${process.platform === 'win32' ? 'Select-String' : 'grep -rn'} through the shell`}.`;
|
|
@@ -924,15 +930,22 @@ export function createCodingTools(policy) {
|
|
|
924
930
|
const current = kind === 'powershell'
|
|
925
931
|
? andorraCreatePowerShellTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false })
|
|
926
932
|
: andorraCreateBashTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false });
|
|
933
|
+
// The turn's evidence cites what ran: the runtime records it before it starts and when it ends.
|
|
934
|
+
const observed = await context.observeCommand?.({ command, directory: cwd, signal: context.signal }).catch(() => undefined);
|
|
927
935
|
return auditedCommand(cwd, command, launchPolicy, async () => {
|
|
928
936
|
try {
|
|
929
937
|
const result = await current.execute(randomUUID(), { command, timeout: timeout / 1000 }, context.signal);
|
|
930
|
-
|
|
938
|
+
const text = result.content.filter(part => part.type === 'text').map(part => part.text).join('\n');
|
|
939
|
+
observed?.({ exitCode: 0, output: text });
|
|
940
|
+
return nativeObservation(text, true);
|
|
931
941
|
}
|
|
932
942
|
catch (error) {
|
|
933
|
-
if (!(error instanceof Error))
|
|
943
|
+
if (!(error instanceof Error)) {
|
|
944
|
+
observed?.({ output: String(error) });
|
|
934
945
|
throw error;
|
|
946
|
+
}
|
|
935
947
|
const exited = /(?:^|\n\n)Command exited with code (\d+)$/.exec(error.message);
|
|
948
|
+
observed?.({ ...(exited ? { exitCode: Number(exited[1]) } : {}), output: error.message });
|
|
936
949
|
if (exited)
|
|
937
950
|
throw new CommandExitError(nativeObservation(error.message, true), Number(exited[1]));
|
|
938
951
|
const message = shellTimeoutGuidance(error.message, timeout);
|
|
@@ -1071,14 +1084,15 @@ export function createCodingTools(policy) {
|
|
|
1071
1084
|
}
|
|
1072
1085
|
});
|
|
1073
1086
|
});
|
|
1074
|
-
const
|
|
1087
|
+
const processWaitCheckpointMs = 30_000;
|
|
1088
|
+
const AsyncProcess = zTool('AsyncProcess', `Start a shell command in the background and return immediately; inspect status/logs, wait for completion, or stop it. Use for independent builds, test suites, and dev servers so other agent work can continue. A wait returns by ${processWaitCheckpointMs / 1000}s with recent output if completion is still pending. At that checkpoint, check for progress, a missed readiness signal, or a hang before waiting again. Each job has a generated ID. ${PERSISTENT_JOBS_SUPPORTED
|
|
1075
1089
|
? 'Jobs are killed when the owning CLI exits unless started with persist: true. When the task is to leave a service running for the user (a web server, daemon or listener they will use after you finish), start it with persist: true and do not stop it before you finish.'
|
|
1076
1090
|
: 'Jobs are killed when the owning CLI exits.'} Full Access or explicit escalation is required to start; sandbox restrictions are never bypassed.`, { type: 'object', properties: {
|
|
1077
1091
|
action: { type: 'string', enum: ['start', 'status', 'logs', 'wait', 'stop'] },
|
|
1078
1092
|
command: { type: 'string', description: 'Shell command; only for start' },
|
|
1079
1093
|
...(PERSISTENT_JOBS_SUPPORTED ? { persist: { type: 'boolean', description: 'Only for start. Keep the job running after this session ends, for a service the user needs left running. Default false: the job is stopped when the CLI exits.' } } : {}),
|
|
1080
1094
|
id: { type: 'string', description: 'Job ID returned by start; required otherwise' },
|
|
1081
|
-
timeout: { type: 'integer', minimum: 1, maximum: 600000, description:
|
|
1095
|
+
timeout: { type: 'integer', minimum: 1, maximum: 600000, description: `Requested wait in milliseconds (default 10000, capped at ${processWaitCheckpointMs}). Reaching this checkpoint leaves the job running.` },
|
|
1082
1096
|
...sandboxFields,
|
|
1083
1097
|
}, required: ['action'], additionalProperties: false }, 'sequential', async (args, context) => {
|
|
1084
1098
|
const action = stringArg(args, 'action');
|
|
@@ -1109,8 +1123,15 @@ export function createCodingTools(policy) {
|
|
|
1109
1123
|
if (action === 'logs')
|
|
1110
1124
|
return JSON.stringify({ ...job, tail: manager.logs(id) });
|
|
1111
1125
|
if (action === 'wait') {
|
|
1112
|
-
const timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ??
|
|
1113
|
-
|
|
1126
|
+
const timeout = Math.min(intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 10_000, processWaitCheckpointMs);
|
|
1127
|
+
const result = await manager.wait(id, timeout, context.signal);
|
|
1128
|
+
if (!result.waitExpired)
|
|
1129
|
+
return JSON.stringify(result);
|
|
1130
|
+
return JSON.stringify({
|
|
1131
|
+
...result,
|
|
1132
|
+
waitedMs: timeout,
|
|
1133
|
+
nextStep: 'Completion is still pending. Inspect the output and check for progress, a missed readiness signal, or a hang before waiting again.',
|
|
1134
|
+
});
|
|
1114
1135
|
}
|
|
1115
1136
|
if (action === 'stop') {
|
|
1116
1137
|
await manager.stop(id);
|
|
@@ -64,7 +64,7 @@ export declare function runCommandScreen(line: string, state: CommandState, ui:
|
|
|
64
64
|
load: typeof loadAccessibleGraph;
|
|
65
65
|
requirePaid: (signal?: AbortSignal) => Promise<void>;
|
|
66
66
|
membership?: (signal?: AbortSignal) => Promise<Membership>;
|
|
67
|
-
}, openGraphBuilder?: (signal: AbortSignal, mode?: 'new' | 'edit') => Promise<void>, graphSubject?: typeof currentGraphSubject): Promise<{
|
|
67
|
+
}, openGraphBuilder?: (signal: AbortSignal, mode?: 'new' | 'edit') => Promise<void>, graphSubject?: typeof currentGraphSubject, openAntigravity?: (signal: AbortSignal) => Promise<void>): Promise<{
|
|
68
68
|
clear: boolean;
|
|
69
69
|
}>;
|
|
70
70
|
export declare const MODEL_TREE_EXPAND = ":expand:";
|
|
@@ -51,7 +51,7 @@ export async function retireDroppedAccounts(previous, next, signal) {
|
|
|
51
51
|
/** Thrown by a live persist when the change it carried was refused, so the enclosing save keeps the old config. */
|
|
52
52
|
export class SelectionReverted extends Error {
|
|
53
53
|
}
|
|
54
|
-
export async function runCommandScreen(line, state, ui, persist, signal, adapterFactory = createAdapter, graphAccess = { load: loadAccessibleGraph, requirePaid: requireGraphMembership, membership: getMembership }, openGraphBuilder, graphSubject = currentGraphSubject) {
|
|
54
|
+
export async function runCommandScreen(line, state, ui, persist, signal, adapterFactory = createAdapter, graphAccess = { load: loadAccessibleGraph, requirePaid: requireGraphMembership, membership: getMembership }, openGraphBuilder, graphSubject = currentGraphSubject, openAntigravity) {
|
|
55
55
|
const unchanged = { clear: false };
|
|
56
56
|
if (!isScreenCommand(line) || signal.aborted)
|
|
57
57
|
return unchanged;
|
|
@@ -291,7 +291,7 @@ export async function runCommandScreen(line, state, ui, persist, signal, adapter
|
|
|
291
291
|
const id = selected === ':add' ? undefined : selected.slice(6);
|
|
292
292
|
if (id && !state.config.providers.some(item => item.id === id))
|
|
293
293
|
throw new Error('Invalid provider selection');
|
|
294
|
-
const draft = await editProviderSettings(state.config, id, ui, signal, undefined, undefined, undefined, undefined, id === undefined && state.andorra?.add ? { description: () => andorraOffer(state), add: async () => { await addAndorra(); }, refresh: rows => andorraRefresh(state, rows).refresh } : undefined);
|
|
294
|
+
const draft = await editProviderSettings(state.config, id, ui, signal, undefined, undefined, undefined, undefined, id === undefined && state.andorra?.add ? { description: () => andorraOffer(state), add: async () => { await addAndorra(); }, refresh: rows => andorraRefresh(state, rows).refresh } : undefined, openAntigravity);
|
|
295
295
|
if (draft)
|
|
296
296
|
return await save(draft);
|
|
297
297
|
continue;
|
package/dist/src/commands.d.ts
CHANGED
|
@@ -4,21 +4,28 @@ import { currentGraphSubject } from './graph-selection.js';
|
|
|
4
4
|
import { loadAccessibleGraph, requireGraphMembership } from './membership.js';
|
|
5
5
|
import type { Config } from './config.js';
|
|
6
6
|
import { type SessionGoal } from './session-goal.js';
|
|
7
|
-
import type
|
|
7
|
+
import { type TelemetryCommandInput, type TelemetryChoiceIO } from './telemetry/permission-command.js';
|
|
8
|
+
import { type Completion, type RunResult } from './runtime.js';
|
|
8
9
|
import type { Usage } from './types.js';
|
|
9
10
|
import type { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
|
|
10
11
|
import { logoutCodex } from './codex-auth.js';
|
|
11
12
|
import type { TerminalAndorraHooks } from './andorra/terminal.js';
|
|
12
|
-
|
|
13
|
+
import { type LegalChoiceIO } from './legal/command.js';
|
|
14
|
+
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 /antigravity Start a Gemini subscription session using Antigravity ACP\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 /routing [refresh] Show model routing, or re-score every configured model from published benchmarks\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> Product usage reports; optional on every plan in the EEA, UK and Switzerland\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.";
|
|
13
15
|
export interface CommandState {
|
|
14
16
|
config: Config;
|
|
15
17
|
yolo: boolean;
|
|
16
18
|
workspace: string;
|
|
17
19
|
usage: Usage;
|
|
20
|
+
/** Legacy caller metadata only. Privacy/preference authority is always read by executeCommand. */
|
|
18
21
|
analytics?: {
|
|
19
22
|
plan: 'free' | 'legacy' | 'paid' | 'unknown';
|
|
20
23
|
canOptOut: boolean;
|
|
21
24
|
};
|
|
25
|
+
/** Execution-home privacy authority and a human terminal choice, never remote stdin. */
|
|
26
|
+
telemetry?: TelemetryCommandInput & TelemetryChoiceIO;
|
|
27
|
+
/** Human-only legal action. Never derived from headless/protocol readLine. */
|
|
28
|
+
legal?: LegalChoiceIO;
|
|
22
29
|
permissions?: PermissionMode;
|
|
23
30
|
lastRun?: RunResult;
|
|
24
31
|
graph?: string;
|
package/dist/src/commands.js
CHANGED
|
@@ -10,18 +10,19 @@ import { currentGraphSelection, loadAccessibleGraph, requireGraphMembership } fr
|
|
|
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
|
-
import {
|
|
13
|
+
import { changeFunctionalConfigFile, configDirectory } from './config.js';
|
|
14
|
+
import { executeTelemetryCommand } from './telemetry/permission-command.js';
|
|
15
|
+
import { turnModelCompletion } from './runtime.js';
|
|
14
16
|
import { applyModelContextWindow, modelDisplayName, modelIdForDisplayName, providerLabel, recordProviderModel, REASONING_EFFORTS } from './providers.js';
|
|
17
|
+
import { MAX_POOL_SCORES } from './efficiency.js';
|
|
18
|
+
import { refreshPoolScores, scoreSubjects } from './pool-scores.js';
|
|
19
|
+
import { enabledLevels } from './thinking-levels.js';
|
|
15
20
|
import { resolveRepositoryId } from './code-intelligence/repository.js';
|
|
16
21
|
import { logoutCodex } from './codex-auth.js';
|
|
17
22
|
import { codexAccountHome } from './codex-rpc.js';
|
|
18
23
|
import { executeAuthCommand } from './auth-commands.js';
|
|
19
|
-
import { analyticsGenerationFor, resolveAnalyticsConfig } from './analytics.js';
|
|
20
|
-
import { telemetryDirectory } from './telemetry/identity.js';
|
|
21
|
-
import { purgeOutbox } from './telemetry/outbox.js';
|
|
22
|
-
import { recordPreference } from './telemetry/state.js';
|
|
23
|
-
import { telemetryGate } from './telemetry/gate.js';
|
|
24
24
|
import { formatWeekReset } from './andorra/usage-format.js';
|
|
25
|
+
import { executeLegalCommand } from './legal/command.js';
|
|
25
26
|
const MAX_CODEINTEL_REPO_OVERRIDES = 100;
|
|
26
27
|
const REASONING_USAGE = 'Usage: /reasoning default|none|minimal|low|medium|high|xhigh|max';
|
|
27
28
|
export const HELP = `Commands:
|
|
@@ -34,8 +35,10 @@ export const HELP = `Commands:
|
|
|
34
35
|
/model [model-id] Open the provider/model tree (→ expands, ← collapses) or select a model directly; with a graph that pins node models, asks whether to override them
|
|
35
36
|
/model list Discover models from the active provider
|
|
36
37
|
/providers [id] Choose providers; Right/e edits; Add provider configures
|
|
38
|
+
/antigravity Start a Gemini subscription session using Antigravity ACP
|
|
37
39
|
/subagent [id [model]] Set the provider/model external hosts (Claude/Codex CLI) must use for Andorra subagent runs; off clears it
|
|
38
40
|
/reasoning <level> Set default|none|minimal|low|medium|high|xhigh|max
|
|
41
|
+
/routing [refresh] Show model routing, or re-score every configured model from published benchmarks
|
|
39
42
|
/graph [id] Select a graph or open the web graph builder
|
|
40
43
|
/codegraph <action> Code intelligence: status|enable|disable|rebuild; enable|disable --global sets the default for every project
|
|
41
44
|
/dashboard Toggle live dashboard and transcript (TTY only)
|
|
@@ -44,7 +47,7 @@ export const HELP = `Commands:
|
|
|
44
47
|
/permissions [mode] Choose and remember workspace permissions
|
|
45
48
|
/jev <on|off|status> Turn Jev on or off for this session, or show its setting
|
|
46
49
|
/jev global <on|off> Turn the Global Jev switch on or off; off stops Jev in every session and agent
|
|
47
|
-
/feedback <on|off|status>
|
|
50
|
+
/feedback <on|off|status> Product usage reports; optional on every plan in the EEA, UK and Switzerland
|
|
48
51
|
/yolo <on|off> Turn session-wide Full Access on or off (host files and network)
|
|
49
52
|
/tools List available coding tools
|
|
50
53
|
/skills List, install, enable, disable or remove skills
|
|
@@ -97,7 +100,7 @@ export function compactHistory(turns) {
|
|
|
97
100
|
}];
|
|
98
101
|
}
|
|
99
102
|
export function compactedContextEstimate(turns) {
|
|
100
|
-
return Math.ceil(JSON.stringify(turns).length / 4);
|
|
103
|
+
return Math.ceil(JSON.stringify(turns.map(turn => ({ ...turn, completion: turnModelCompletion(turn.completion) }))).length / 4);
|
|
101
104
|
}
|
|
102
105
|
const CODEGRAPH_USAGE = 'Usage: /codegraph status|enable|disable|rebuild. Add --global to enable|disable to set the saved default for every project (this clears per-repository overrides).';
|
|
103
106
|
async function codegraphCommand(action, scope, state, signal) {
|
|
@@ -172,23 +175,48 @@ function syncConfig(target, source) {
|
|
|
172
175
|
}
|
|
173
176
|
Object.assign(target, source);
|
|
174
177
|
}
|
|
175
|
-
function feedbackChangedText(enabled) {
|
|
176
|
-
return `Anonymous feedback ${enabled ? 'on' : 'off'}. Setting saved for this machine.${enabled ? ' It never includes your code, prompts, or API keys.' : ' No anonymous product data will be reported from this installation.'}`;
|
|
177
|
-
}
|
|
178
|
-
function includedWithPlanText(plan) {
|
|
179
|
-
if (plan === 'legacy')
|
|
180
|
-
return 'on (included with the Legacy plan)';
|
|
181
|
-
if (plan === 'free')
|
|
182
|
-
return 'on (included with the Free plan)';
|
|
183
|
-
return 'on (included with your plan until this account\'s plan is confirmed)';
|
|
184
|
-
}
|
|
185
|
-
function optOutRefusedText(plan) {
|
|
186
|
-
const named = plan === 'free' ? 'Free' : plan === 'legacy' ? 'Legacy' : 'current';
|
|
187
|
-
return `Anonymous feedback stays on: collection is included with the ${named} plan. Upgrade to Paid to turn it off.`;
|
|
188
|
-
}
|
|
189
178
|
export function subagentClearRequested(line, providers) {
|
|
190
179
|
return /^\/subagent\s+off\s*$/.test(line.trim()) && !providers.some(provider => provider.id === 'off');
|
|
191
180
|
}
|
|
181
|
+
const ROUTING_USAGE = 'Usage: /routing [status] | /routing refresh';
|
|
182
|
+
/** `/routing`: show how routing is set, or score every configured model from published benchmarks and save the scores. */
|
|
183
|
+
async function routingCommand(arg, state, signal) {
|
|
184
|
+
const words = arg ? arg.split(/\s+/) : [];
|
|
185
|
+
const routing = state.config.efficiency?.adaptiveRouting;
|
|
186
|
+
if (words.length === 0 || (words.length === 1 && words[0] === 'status')) {
|
|
187
|
+
const scored = Object.keys(routing?.scores ?? {}).length;
|
|
188
|
+
const mode = routing?.enabled !== true ? 'off'
|
|
189
|
+
: routing.strategy === 'pool' ? `pool (${routing.candidates === 'all' ? 'every scored model' : 'listed pairs'}${routing.mode === 'shadow' ? ', shadow' : ''})` : 'tiers';
|
|
190
|
+
return { text: `Routing: ${mode}\nScores: ${scored ? `${scored} models, ${routing?.scoresUpdatedAt ? `refreshed ${routing.scoresUpdatedAt}` : 'written by hand'}` : 'none'}\n${ROUTING_USAGE}` };
|
|
191
|
+
}
|
|
192
|
+
if (words.length !== 1 || words[0] !== 'refresh')
|
|
193
|
+
return { text: ROUTING_USAGE };
|
|
194
|
+
const subjects = scoreSubjects(state.config.providers, (id, name) => enabledLevels(state.config.providers.find(item => item.id === id), name)).slice(0, MAX_POOL_SCORES);
|
|
195
|
+
if (!subjects.length)
|
|
196
|
+
return { text: 'No models are configured to score.' };
|
|
197
|
+
state.notify?.(`Reading benchmark scores for ${subjects.length} models.`);
|
|
198
|
+
const bounded = AbortSignal.any([...(signal ? [signal] : []), AbortSignal.timeout(240_000)]);
|
|
199
|
+
let result;
|
|
200
|
+
try {
|
|
201
|
+
result = await refreshPoolScores({ subjects, signal: bounded, ...(routing?.scores ? { previous: routing.scores } : {}) });
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
return { text: `Routing scores unchanged: ${error instanceof Error ? error.message : String(error)}` };
|
|
205
|
+
}
|
|
206
|
+
const scoresUpdatedAt = new Date().toISOString();
|
|
207
|
+
// A functional write: the saved analytics choice is left exactly as it is stored.
|
|
208
|
+
const saved = await changeFunctionalConfigFile(configDirectory(), current => ({ ...current, efficiency: { ...current.efficiency, adaptiveRouting: { ...current.efficiency?.adaptiveRouting, scores: result.scores, scoresUpdatedAt } } }));
|
|
209
|
+
// The session's own copy is saved again by later commands, so it takes the new scores too.
|
|
210
|
+
state.config.efficiency = saved.efficiency;
|
|
211
|
+
const used = saved.efficiency?.adaptiveRouting;
|
|
212
|
+
const hint = used?.enabled === true && (used.strategy !== 'pool' || used.candidates === 'all') ? ''
|
|
213
|
+
: '\nPool routing chooses among every scored model when efficiency.adaptiveRouting has enabled true, strategy "pool" and candidates "all".';
|
|
214
|
+
const read = result.benchmarks.filter(item => item.used).map(item => item.name).join(', ');
|
|
215
|
+
const skipped = result.benchmarks.filter(item => !item.used).map(item => `${item.name} (${item.reason ?? 'not used'})`);
|
|
216
|
+
return { text: `Routing scores refreshed from ${read}: ${result.rated.length} of ${subjects.length} models scored`
|
|
217
|
+
+ `${result.kept.length ? `, ${result.kept.length} kept an earlier score` : ''}${result.unrated.length ? `, ${result.unrated.length} not listed (${result.unrated.slice(0, 5).join(', ')}${result.unrated.length > 5 ? ', …' : ''})` : ''}.`
|
|
218
|
+
+ `${skipped.length ? `\nNot used: ${skipped.join('; ')}.` : ''}${hint}` };
|
|
219
|
+
}
|
|
192
220
|
export async function executeCommand(line, state, persist, signal, graphAccess = { load: loadAccessibleGraph, requirePaid: requireGraphMembership }, graphSubject = currentGraphSubject, logout = logoutCodex) {
|
|
193
221
|
if (/^\/logout\s+\S/.test(line.trim()) && !/^\/logout\s+--all$/.test(line.trim())) {
|
|
194
222
|
if (!/^\/logout\s+codex$/.test(line.trim()))
|
|
@@ -217,14 +245,22 @@ export async function executeCommand(line, state, persist, signal, graphAccess =
|
|
|
217
245
|
return { text: `Sign-out failed for ${failures.length} Codex account${failures.length === 1 ? '' : 's'}: ${failures.join('; ')}` };
|
|
218
246
|
return { text: 'Signed out of every configured Codex account. Provider settings are retained; use /providers to sign in again.', exit: true, clear: true };
|
|
219
247
|
}
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
248
|
+
const routingLine = /^\/routing(?:\s+(.*))?$/.exec(line.trim());
|
|
249
|
+
if (routingLine)
|
|
250
|
+
return routingCommand((routingLine[1] ?? '').trim(), state, signal);
|
|
251
|
+
if (/^\/legal(?:\s|$)/.test(line.trim()))
|
|
252
|
+
return { text: (await executeLegalCommand(line.trim().split(/\s+/).slice(1), undefined, state.legal)).text };
|
|
253
|
+
if (/^\/feedback(?:\s|$)/.test(line.trim())) {
|
|
254
|
+
const args = line.trim().split(/\s+/).slice(1);
|
|
255
|
+
if (args.length > 1 || (args[0] && !['on', 'off', 'status'].includes(args[0])))
|
|
256
|
+
return { text: 'Usage: /feedback on|off|status' };
|
|
257
|
+
const input = state.telemetry ?? { home: configDirectory(), subject: graphSubject };
|
|
258
|
+
const reply = await executeTelemetryCommand([args[0] === 'on' ? 'allow' : args[0] === 'off' ? 'deny' : 'status'], input, { ...state.telemetry, surface: 'feedback' });
|
|
259
|
+
if (reply.config)
|
|
260
|
+
syncConfig(state.config, reply.config);
|
|
261
|
+
return { text: reply.text + (args.length === 0 ? '\nUsage: /feedback on|off|status' : ''), ...(reply.saved ? { save: true } : {}) };
|
|
227
262
|
}
|
|
263
|
+
const draft = { ...state, config: structuredClone(state.config) };
|
|
228
264
|
const graphCommand = /^\/graph\s+(\S+)\s*$/.exec(line.trim());
|
|
229
265
|
const codegraph = /^\/codegraph(?:\s+(\S+))?(?:\s+(\S+))?\s*$/.exec(line.trim());
|
|
230
266
|
const codegraphScope = codegraph?.[2] === undefined ? 'repository' : codegraph[2] === '--global' ? 'global' : undefined;
|
|
@@ -304,21 +340,7 @@ export async function executeCommand(line, state, persist, signal, graphAccess =
|
|
|
304
340
|
const permissionsChanged = draft.permissions !== state.permissions;
|
|
305
341
|
if (permissionsChanged && (draft.permissions === 'read-only' || draft.permissions === 'plan'))
|
|
306
342
|
await state.codeIntel?.setPermissions(draft.permissions);
|
|
307
|
-
if (result.save
|
|
308
|
-
let preferenceTurnedOff = false;
|
|
309
|
-
const saved = await changeConfigFile(configDirectory(), current => {
|
|
310
|
-
const enabled = draft.config.analytics?.enabled !== false;
|
|
311
|
-
preferenceTurnedOff = resolveAnalyticsConfig(current).enabled && !enabled;
|
|
312
|
-
return { ...current, analytics: { ...draft.config.analytics, generation: analyticsGenerationFor(current.analytics, enabled) } };
|
|
313
|
-
});
|
|
314
|
-
if (preferenceTurnedOff)
|
|
315
|
-
await purgeOutbox(telemetryDirectory());
|
|
316
|
-
if (saved.analytics !== undefined) {
|
|
317
|
-
await recordPreference({ subject: await graphSubject().catch(() => undefined), preference: saved.analytics.enabled === false ? 'off' : 'on' }).catch(() => { });
|
|
318
|
-
}
|
|
319
|
-
draft.config = saved;
|
|
320
|
-
}
|
|
321
|
-
else if (result.save)
|
|
343
|
+
if (result.save)
|
|
322
344
|
await persist(draft.config);
|
|
323
345
|
syncConfig(state.config, draft.config);
|
|
324
346
|
if (graphCommand && result.save)
|
|
@@ -431,8 +453,8 @@ export function handleCommand(line, state) {
|
|
|
431
453
|
if (arg === 'default')
|
|
432
454
|
delete provider.reasoningEffort;
|
|
433
455
|
else {
|
|
434
|
-
if (!['openai-compatible', 'opencode-go', 'anthropic'].includes(provider.type))
|
|
435
|
-
return { text: 'Reasoning effort overrides are currently supported only for OpenAI-compatible, OpenCode Go or
|
|
456
|
+
if (!['openai-compatible', 'opencode-go', 'anthropic', 'codex', 'claude'].includes(provider.type))
|
|
457
|
+
return { text: 'Reasoning effort overrides are currently supported only for OpenAI-compatible, OpenCode Go, Anthropic, Codex or Claude providers.' };
|
|
436
458
|
provider.reasoningEffort = arg;
|
|
437
459
|
}
|
|
438
460
|
return { text: `Thinking: ${provider.reasoningEffort ?? 'provider default'}. Effort support depends on the selected model and server.`, save: true };
|
|
@@ -491,24 +513,7 @@ export function handleCommand(line, state) {
|
|
|
491
513
|
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
514
|
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.' : ''}` };
|
|
493
515
|
}
|
|
494
|
-
case '/feedback': {
|
|
495
|
-
if (args.length > 1 || (arg && !['on', 'off', 'status'].includes(arg)))
|
|
496
|
-
return { text: 'Usage: /feedback on|off|status' };
|
|
497
|
-
const enabled = resolveAnalyticsConfig(state.config).enabled;
|
|
498
|
-
const plan = state.analytics?.plan ?? 'unknown';
|
|
499
|
-
const canOptOut = state.analytics?.canOptOut ?? true;
|
|
500
|
-
if (arg === 'status' || !arg) {
|
|
501
|
-
const usage = arg ? '' : '\nUsage: /feedback on|off|status';
|
|
502
|
-
if (!canOptOut)
|
|
503
|
-
return { text: `Anonymous feedback: ${includedWithPlanText(plan)}. It never includes your code, prompts, or API keys.${usage}` };
|
|
504
|
-
return { text: `Anonymous feedback: ${enabled ? 'on' : 'off'} (saved preference). It never includes your code, prompts, or API keys.${usage}` };
|
|
505
|
-
}
|
|
506
|
-
const next = arg === 'on';
|
|
507
|
-
if (!next && !canOptOut)
|
|
508
|
-
return { text: optOutRefusedText(plan) };
|
|
509
|
-
state.config.analytics = { ...state.config.analytics, enabled: next };
|
|
510
|
-
return { text: feedbackChangedText(next), save: true };
|
|
511
|
-
}
|
|
516
|
+
case '/feedback': return { text: 'Use the asynchronous command handler for product usage permission.' };
|
|
512
517
|
case '/usage': {
|
|
513
518
|
const read = state.usage.cacheRead ?? 0, write = state.usage.cacheWrite ?? 0;
|
|
514
519
|
const cache = read > 0 || write > 0
|
package/dist/src/completion.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateJsonSchemaValue } from '../vendor/zcode/source/tool/json-schema.js';
|
|
2
2
|
import { interruptsParagraph } from './markdown.js';
|
|
3
|
+
import { OUTCOMES_SCHEMA, parseOutcomes } from './evidence.js';
|
|
3
4
|
export const COMPLETION_TOOL = 'complete_agent';
|
|
4
5
|
export const FINAL_RESPONSE_GUIDANCE = "Only when this node is responsible for producing the final user answer, its summary must satisfy the user's response requirements: include complete requested files and exact formatting, including requested code fences, without abbreviation, path substitution, or offers to provide content later. Each fence opens and closes on its own line; a file written to the workspace that the user did not ask to see in the answer is named by path, not reproduced. Intermediate intake, research, and delegation nodes must instead keep a concise handoff and preserve these final-answer acceptance requirements in the downstream task instruction or output; do not implement or reproduce the final deliverable before handing off.";
|
|
5
6
|
export const RESPONSE_STRUCTURE_GUIDANCE = `Write user-facing text, including the final summary, as structured markdown rather than one unbroken paragraph. Lead with the outcome in one or two sentences. Match the length to the work: a small change or a short answer is a few sentences or bullets with no headings; larger work uses short headings (## What changed, ## Not done) and bullet lists for parallel items. Do not list the checks again in the summary, because the tests array is shown beside it. Throughout, put every command, file content, and code sample in a fenced code block whose fences sit on their own lines; keep sentences short and omit filler. Inside a JSON string the line breaks are written as \\n escapes, and they are expected: never flatten the summary into one line to keep the JSON valid. In the tests array, write one short line per check: the check that ran, then its outcome.`;
|
|
@@ -66,6 +67,7 @@ export function completionTool(options) {
|
|
|
66
67
|
type: 'object',
|
|
67
68
|
properties: {
|
|
68
69
|
summary: { type: 'string', description: SUMMARY_DESCRIPTION }, tests: { type: 'array', items: { type: 'string', description: 'One short line: the check that ran, then its outcome.' } },
|
|
70
|
+
outcomes: OUTCOMES_SCHEMA,
|
|
69
71
|
...(options.finalAnswerOutcomes?.length ? { remaining: { type: 'array', maxItems: REMAINING_LIMIT, items: { type: 'string' }, description: REMAINING_DESCRIPTION } } : {}),
|
|
70
72
|
...(outcomes ? { artifacts: { type: 'array', maxItems: 50, items: { type: 'object', properties: { type: { type: 'string' }, ref: { type: 'string' } }, required: ['type', 'ref'], additionalProperties: false } } } : {}),
|
|
71
73
|
...(outcomes ? { outcome: { type: 'string', enum: outcomes }, output: providerOutputSchema(options.outputSchema ?? { type: 'object' }) } : {}),
|
|
@@ -193,11 +195,12 @@ function parseCompletionJson(text, stopReason, notes) {
|
|
|
193
195
|
}
|
|
194
196
|
export function decodeDoubleEscapedSummary(summary, notes) {
|
|
195
197
|
if (!summary.includes('\n')) {
|
|
196
|
-
|
|
198
|
+
// A summary with no real newline at all escaped every line break it has away, so the first escaped break outside
|
|
199
|
+
// code is a lost line break however few there are: leaving it in renders the summary as one run-on line.
|
|
200
|
+
if (escapedStructureCount(summary) === 0)
|
|
197
201
|
return summary;
|
|
198
202
|
notes?.push('completion summary arrived with its newlines escaped twice and was decoded');
|
|
199
|
-
|
|
200
|
-
return summary.replace(/\\(["\\nrt])/g, (_, char) => decoded[char]);
|
|
203
|
+
return mapOutsideCode(summary, prose => prose.replace(/\\(["\\nrt])/g, (_, char) => ESCAPE_DECODES[char]));
|
|
201
204
|
}
|
|
202
205
|
if (!summary.includes('\\n'))
|
|
203
206
|
return summary;
|
|
@@ -215,6 +218,7 @@ export function decodeDoubleEscapedSummary(summary, notes) {
|
|
|
215
218
|
notes?.push('completion summary arrived with some of its newlines escaped twice and was decoded');
|
|
216
219
|
return mapOutsideCode(summary, (prose, line) => prose.replace(/\\(\\|n|")/g, (escape, char) => char === '"' ? '"' : char === 'n' && structuralLines.has(line) ? '\n' : escape));
|
|
217
220
|
}
|
|
221
|
+
const ESCAPE_DECODES = { n: '\n', r: '\r', t: '\t', '"': '"', '\\': '\\' };
|
|
218
222
|
function escapedStructureCount(summary) {
|
|
219
223
|
let count = 0;
|
|
220
224
|
mapOutsideCode(summary, (prose, _line, beforeCode) => {
|
|
@@ -394,8 +398,8 @@ function splitFusedArguments(envelope, notes) {
|
|
|
394
398
|
notes?.push(`completion fields ${fields.map(([name]) => name).join(', ')} arrived fused into one key by leaked argument markup and were split apart`);
|
|
395
399
|
}
|
|
396
400
|
}
|
|
397
|
-
const EMBEDDED_ENVELOPE_FIELD = /"\s*,\s*"(tests|outcome|output|artifacts)"\s*:/;
|
|
398
|
-
const EMBEDDED_FIELDS = ['tests', 'outcome', 'output', 'artifacts', 'remaining'];
|
|
401
|
+
const EMBEDDED_ENVELOPE_FIELD = /"\s*,\s*"(tests|outcome|output|artifacts|outcomes)"\s*:/;
|
|
402
|
+
const EMBEDDED_FIELDS = ['tests', 'outcome', 'output', 'artifacts', 'remaining', 'outcomes'];
|
|
399
403
|
const RAW_CONTROL = { '\n': '\\n', '\r': '\\r', '\t': '\\t' };
|
|
400
404
|
function emptyField(value) {
|
|
401
405
|
if (value === undefined || value === null)
|
|
@@ -623,13 +627,15 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
|
|
|
623
627
|
if (written === undefined)
|
|
624
628
|
notes?.push(OUTPUT_STOOD_IN_NOTE);
|
|
625
629
|
const summary = written === undefined ? decodeDoubleEscapedSummary(JSON.stringify(output).slice(0, 2000), notes) : stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(written, notes)), outcome, notes);
|
|
626
|
-
|
|
630
|
+
const outcomes = parseOutcomes(value.outcomes, notes);
|
|
631
|
+
return { summary, ...(outcomes ? { outcomes } : {}),
|
|
627
632
|
tests: Array.isArray(value.tests) && value.tests.every((item) => typeof item === 'string') ? value.tests : [], outcome, output,
|
|
628
633
|
artifacts: value.artifacts ?? [], ...(remainingItems(value.remaining) ? { remaining: remainingItems(value.remaining) } : {}) };
|
|
629
634
|
}
|
|
630
635
|
if (value && typeof value.summary === 'string' && value.summary.trim()
|
|
631
636
|
&& Array.isArray(value.tests) && value.tests.every((x) => typeof x === 'string')) {
|
|
632
|
-
|
|
637
|
+
const outcomes = parseOutcomes(value.outcomes, notes);
|
|
638
|
+
return { summary: stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(value.summary, notes)), typeof value.outcome === "string" ? value.outcome : undefined, notes), tests: value.tests, ...(outcomes ? { outcomes } : {}) };
|
|
633
639
|
}
|
|
634
640
|
throw new Error("Completion needs a nonempty summary and a tests array of strings");
|
|
635
641
|
}
|