@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
package/dist/src/side-panel.js
CHANGED
|
@@ -111,10 +111,44 @@ function planSection(data, width, rows) {
|
|
|
111
111
|
if (rows < 2 || !data.todos.length)
|
|
112
112
|
return [];
|
|
113
113
|
const done = data.todos.filter(todo => todo.status === 'completed').length;
|
|
114
|
+
const budget = rows - 1;
|
|
115
|
+
const title = heading('Plan', width, [{ text: `${done}/${data.todos.length}`, color: GRAY }]);
|
|
116
|
+
if (data.todos.some(todo => todo.parentId !== undefined)) {
|
|
117
|
+
const overflows = data.todos.length > budget;
|
|
118
|
+
const room = overflows && budget > 1 ? budget - 1 : budget;
|
|
119
|
+
const selected = new Set();
|
|
120
|
+
if (overflows) {
|
|
121
|
+
for (const status of ['in_progress', 'pending', 'completed']) {
|
|
122
|
+
const limit = status === 'in_progress' ? budget : room;
|
|
123
|
+
for (const todo of data.todos) {
|
|
124
|
+
if (selected.size >= limit)
|
|
125
|
+
break;
|
|
126
|
+
if (todo.status !== status)
|
|
127
|
+
continue;
|
|
128
|
+
if (todo.parentId !== undefined)
|
|
129
|
+
selected.add(todo.parentId);
|
|
130
|
+
if (selected.size < limit)
|
|
131
|
+
selected.add(todo.id);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Preserve the phase and sibling order in the snapshot once the priority pass selects the rows.
|
|
136
|
+
const visible = overflows ? data.todos.filter(todo => selected.has(todo.id)) : data.todos;
|
|
137
|
+
const body = visible.map(todo => {
|
|
138
|
+
const indent = todo.parentId === undefined ? '' : ' ';
|
|
139
|
+
const mark = todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '●' : '○';
|
|
140
|
+
const markerColor = todo.status === 'in_progress' ? accentSgr() : SUBTLE;
|
|
141
|
+
const textColor = todo.status === 'in_progress' ? WHITE : GRAY;
|
|
142
|
+
return row({ text: `${indent}${mark} `, color: markerColor }, { text: clip(todo.text, width - indent.length - 2), color: textColor });
|
|
143
|
+
});
|
|
144
|
+
if (body.length < budget && visible.length < data.todos.length) {
|
|
145
|
+
body.push(row({ text: clip(`… ${data.todos.length - visible.length} more`, width), color: FAINT }));
|
|
146
|
+
}
|
|
147
|
+
return [title, ...body];
|
|
148
|
+
}
|
|
114
149
|
const body = [];
|
|
115
150
|
const active = data.todos.filter(todo => todo.status === 'in_progress');
|
|
116
151
|
const pending = data.todos.filter(todo => todo.status === 'pending');
|
|
117
|
-
const budget = rows - 1;
|
|
118
152
|
const doneRow = done ? 1 : 0;
|
|
119
153
|
const fits = active.length + doneRow + pending.length <= budget;
|
|
120
154
|
const room = fits ? budget : Math.max(1, budget - 1);
|
|
@@ -135,7 +169,7 @@ function planSection(data, width, rows) {
|
|
|
135
169
|
body.push(row({ text: clip(`… ${omitted.join(' · ')}`, width), color: FAINT }));
|
|
136
170
|
if (!body.length)
|
|
137
171
|
body.push(row({ text: `${done}/${data.todos.length} done`, color: GRAY }));
|
|
138
|
-
return [
|
|
172
|
+
return [title, ...body.slice(0, budget)];
|
|
139
173
|
}
|
|
140
174
|
export function panelDuration(milliseconds) {
|
|
141
175
|
return formatHms(milliseconds / 1000);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from './config.js';
|
|
2
2
|
import type { ProviderConfig } from './providers.js';
|
|
3
|
-
export declare const DETECTABLE_SIGN_IN_TYPES: readonly ["claude", "codex", "grok", "opencode"
|
|
3
|
+
export declare const DETECTABLE_SIGN_IN_TYPES: readonly ["claude", "codex", "grok", "opencode"];
|
|
4
4
|
export type DetectableSignInType = typeof DETECTABLE_SIGN_IN_TYPES[number];
|
|
5
5
|
export declare function isDetectableSignInType(value: unknown): value is DetectableSignInType;
|
|
6
6
|
export interface DetectedSignIn {
|
|
@@ -4,20 +4,20 @@ import { resolveCliExecutable } from './cli-executable.js';
|
|
|
4
4
|
import { readCodexModels } from './codex-auth.js';
|
|
5
5
|
import { resolveCodexExecutable } from './codex-executable.js';
|
|
6
6
|
import { connectCodex } from './codex-rpc.js';
|
|
7
|
-
import { GOOGLE_BASE_URL, GOOGLE_EXECUTABLE, readGoogleCatalog } from './google-provider.js';
|
|
8
7
|
import { GROK_BASE_URL, GROK_EXECUTABLE, readGrokCatalog } from './grok-provider.js';
|
|
9
8
|
import { OPENCODE_BASE_URL, OPENCODE_EXECUTABLE, readOpenCodeCatalog, sharedOpenCodeServer } from './opencode-cli-provider.js';
|
|
10
9
|
import { uniqueProviderId } from './provider-import.js';
|
|
11
|
-
|
|
10
|
+
// A Google subscription starts a dedicated Antigravity session.
|
|
11
|
+
export const DETECTABLE_SIGN_IN_TYPES = ['claude', 'codex', 'grok', 'opencode'];
|
|
12
12
|
export function isDetectableSignInType(value) {
|
|
13
13
|
return DETECTABLE_SIGN_IN_TYPES.includes(value);
|
|
14
14
|
}
|
|
15
15
|
const SIGNED_OUT = { signedIn: false, models: [] };
|
|
16
16
|
const MAX_MODELS = 5000;
|
|
17
17
|
const FIXED_BASE_URL = {
|
|
18
|
-
claude: 'https://api.anthropic.com', codex: 'https://chatgpt.com/backend-api/codex', grok: GROK_BASE_URL, opencode: OPENCODE_BASE_URL,
|
|
18
|
+
claude: 'https://api.anthropic.com', codex: 'https://chatgpt.com/backend-api/codex', grok: GROK_BASE_URL, opencode: OPENCODE_BASE_URL,
|
|
19
19
|
};
|
|
20
|
-
const DISPLAY_NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode'
|
|
20
|
+
const DISPLAY_NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
|
|
21
21
|
export function defaultSignInProbes() {
|
|
22
22
|
const present = async (resolve) => { try {
|
|
23
23
|
await resolve();
|
|
@@ -60,12 +60,6 @@ export function defaultSignInProbes() {
|
|
|
60
60
|
const catalog = await readGrokCatalog(signal);
|
|
61
61
|
return { signedIn: catalog.signedIn, models: catalog.models, ...(catalog.email ? { email: catalog.email } : {}) };
|
|
62
62
|
},
|
|
63
|
-
google: async (signal) => {
|
|
64
|
-
if (!await present(() => resolveCliExecutable(GOOGLE_EXECUTABLE)))
|
|
65
|
-
return SIGNED_OUT;
|
|
66
|
-
const catalog = await readGoogleCatalog(signal);
|
|
67
|
-
return { signedIn: catalog.signedIn, models: catalog.models };
|
|
68
|
-
},
|
|
69
63
|
opencode: async (signal) => {
|
|
70
64
|
if (!await present(() => resolveCliExecutable(OPENCODE_EXECUTABLE)))
|
|
71
65
|
return SIGNED_OUT;
|
|
@@ -5,7 +5,7 @@ import { changeConfigFile, configDirectory, loadConfig } from './config.js';
|
|
|
5
5
|
import { applySignInImports, detectSignIns } from './sign-in-detection.js';
|
|
6
6
|
const DETECT_TIMEOUT_MS = 8_000;
|
|
7
7
|
const MAX_ATTEMPTS = 3;
|
|
8
|
-
const NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode'
|
|
8
|
+
const NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
|
|
9
9
|
const statePath = (home) => join(home, 'sign-in-offer.json');
|
|
10
10
|
export async function readSignInOfferState(home = configDirectory()) {
|
|
11
11
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const BUILTIN_COMMANDS = new Set([
|
|
2
|
-
'browser', 'session', 'resume', 'login', 'auth', 'model', 'providers', 'subagent', 'reasoning',
|
|
2
|
+
'browser', 'session', 'resume', 'login', 'auth', 'model', 'providers', 'antigravity', 'subagent', 'reasoning',
|
|
3
3
|
'graph', 'codegraph', 'dashboard', 'attach', 'usage', 'permissions', 'jev',
|
|
4
4
|
'feedback', 'yolo', 'tools', 'skill', 'skills', 'plugins', 'mcp', 'logout', 'status',
|
|
5
5
|
'clear', 'compact', 'goal', 'help', 'exit', 'quit',
|
|
@@ -9,7 +9,7 @@ This sends a bug report about **Andorra Code itself** (the terminal app, the des
|
|
|
9
9
|
models, tools) to the Andorra team. It is not for bugs in the user's own project: if that is what they
|
|
10
10
|
describe, say so and help with the project instead.
|
|
11
11
|
|
|
12
|
-
You send the report with the `submit_bug_report` tool. The tool shows the user the exact
|
|
12
|
+
You send the report with the `submit_bug_report` tool. The tool shows the user the exact report and sends it
|
|
13
13
|
only when they choose **Send report**, so you never send anything they have not read.
|
|
14
14
|
|
|
15
15
|
## Before you ask anything
|
|
@@ -23,6 +23,29 @@ only when they choose **Send report**, so you never send anything they have not
|
|
|
23
23
|
- Use what the user already told you, in this message and earlier in the conversation. Do not ask again
|
|
24
24
|
for something they have said.
|
|
25
25
|
|
|
26
|
+
## Which session has the problem
|
|
27
|
+
|
|
28
|
+
A report about something that went wrong in a session carries that session's graph and a compressed
|
|
29
|
+
trajectory, so the team can see what ran. Find out which session it is before you write anything:
|
|
30
|
+
|
|
31
|
+
1. Call `list_bug_report_sessions`. It returns the session this conversation is in (`current`, with its
|
|
32
|
+
name) and the most recent other sessions, each with an id, a name and a date. It only reads this
|
|
33
|
+
machine; nothing is sent.
|
|
34
|
+
2. Ask the user one question, with these three answers:
|
|
35
|
+
- **This session**, named by the name the tool gave ("This session: Fix the login redirect").
|
|
36
|
+
- **Another session**. Then ask which one, offering the names from `others`. If theirs is not listed,
|
|
37
|
+
ask for something to recognise it by and pick the match; if none matches, say so and ask whether to
|
|
38
|
+
send without a session.
|
|
39
|
+
- **Not a session problem**: a bug in the program itself, such as the app not starting, sign-in,
|
|
40
|
+
settings, an update or a window that will not open.
|
|
41
|
+
3. Remember the answer as the `session` you pass to `submit_bug_report`: `current`, the other session's
|
|
42
|
+
`id`, or `none`.
|
|
43
|
+
|
|
44
|
+
Ask even when the answer looks obvious: the user may be reporting from a fresh conversation about a
|
|
45
|
+
session that broke earlier. Skip the question only when they have already said which session it is. If
|
|
46
|
+
`current` is `null`, this conversation is not saved as a session yet, so offer only another session or
|
|
47
|
+
"not a session problem".
|
|
48
|
+
|
|
26
49
|
## The interview
|
|
27
50
|
|
|
28
51
|
Ask one question at a time, in plain words, and wait for each answer. Use `ask_user` when you have it;
|
|
@@ -35,12 +58,12 @@ otherwise ask in your reply and continue when they answer. Skip a question whose
|
|
|
35
58
|
3. **What they expected** to happen instead.
|
|
36
59
|
4. **How often and since when**, if it is not already clear: every time or sometimes, and whether it
|
|
37
60
|
worked before (an update, a new setting, a different model).
|
|
38
|
-
5. **Anything else that helps**: which model
|
|
61
|
+
5. **Anything else that helps**: which model, the terminal app or the desktop app, a screenshot
|
|
39
62
|
described in words.
|
|
40
63
|
|
|
41
64
|
Stop asking once you can write a report someone else could act on. Three or four questions is usual; do
|
|
42
|
-
not go through the list for its own sake, and do not ask for the app version
|
|
43
|
-
tool attaches those).
|
|
65
|
+
not go through the list for its own sake, and do not ask for the app version, the operating system or
|
|
66
|
+
which graph ran (the tool attaches those).
|
|
44
67
|
|
|
45
68
|
## Write the report
|
|
46
69
|
|
|
@@ -50,6 +73,19 @@ tool attaches those).
|
|
|
50
73
|
"Happened once", and what changed recently if they said.
|
|
51
74
|
- `steps`: numbered steps. Leave it out if the user does not know them.
|
|
52
75
|
- `expected` and `actual`: one or two sentences each.
|
|
76
|
+
- `session`: `current`, another session's id, or `none`, from the answer above.
|
|
77
|
+
|
|
78
|
+
The graph and the trajectory are not yours to write. When `session` names a session, the tool reads them
|
|
79
|
+
from that session's own record and attaches:
|
|
80
|
+
|
|
81
|
+
- **The affected graph**: the graph the session last ran, as its nodes, settings, tools and routes. The
|
|
82
|
+
text of each instruction and prompt is replaced by its length.
|
|
83
|
+
- **A compressed trajectory**: each run as a short list of steps (which node ran, which tools, how long,
|
|
84
|
+
retries, refused completions, how the run stopped) with the first 200 characters of each error. It
|
|
85
|
+
holds no prompt, no model reply, no tool arguments and no output of a tool that succeeded.
|
|
86
|
+
|
|
87
|
+
Do not paste a graph, a trajectory, a log or a transcript into `description` yourself: the attachments
|
|
88
|
+
are bounded and cleaned, and what you paste is not.
|
|
53
89
|
|
|
54
90
|
Rules for the text:
|
|
55
91
|
|
|
@@ -65,16 +101,24 @@ Rules for the text:
|
|
|
65
101
|
|
|
66
102
|
## Send it
|
|
67
103
|
|
|
68
|
-
Call `submit_bug_report` once with the fields above.
|
|
104
|
+
Call `submit_bug_report` once with the fields above. The tool then asks the user the final question
|
|
105
|
+
itself: it shows the whole report, the graph and the trajectory in full when a session is attached, and
|
|
106
|
+
closes with how the report is used: only to debug the problem, kept in the Andorra team's private bug
|
|
107
|
+
tracker, and never used to train models. That confirmation is the user's decision to send or not. Do not
|
|
108
|
+
ask "shall I send it?" yourself before calling the tool, and do not restate or reword the assurance: the
|
|
109
|
+
tool's wording is the one the team stands behind. If the user asks about it, tell them exactly that and
|
|
110
|
+
no more; do not promise that the report is deleted, or anything else the confirmation does not say.
|
|
111
|
+
|
|
112
|
+
Then:
|
|
69
113
|
|
|
70
114
|
- `sent: true`: give the user the `reference` (for example `BR-1234`) and thank them. There is no page to
|
|
71
115
|
open: the tracker is private, so do not offer a link or promise a reply.
|
|
72
116
|
- `sent: false` with a `userReply`: they want a change. Make it and call the tool again so they confirm
|
|
73
|
-
the new text.
|
|
117
|
+
the new text. If they do not want the graph or trajectory sent, call again with `session` set to `none`.
|
|
74
118
|
- `sent: false` without one: they chose not to send. Say nothing was sent and stop.
|
|
75
119
|
- An error: tell the user what it said in plain words. Signed out: they sign in and run `/bug-report`
|
|
76
120
|
again. Daily limit reached: say when they can send it. Service unavailable: say so; do not retry in a
|
|
77
|
-
loop.
|
|
121
|
+
loop. No such session: call `list_bug_report_sessions` again and ask which one they meant.
|
|
78
122
|
|
|
79
123
|
Send one report per problem. If the user describes two separate bugs, finish the first, then ask whether
|
|
80
124
|
to report the second.
|
|
@@ -55,8 +55,8 @@ What you need to know:
|
|
|
55
55
|
- What each agent may touch (read only, write files, run shell, open pull requests).
|
|
56
56
|
- What input a run needs beyond the task text.
|
|
57
57
|
- When the workflow opens, reviews or fixes pull requests: which agent owns the PR and its review comments.
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
Use the "Pull request with review fixes" pattern in `patterns.md`. The owner decides when to monitor the
|
|
59
|
+
PR with `await_review` and how to act on review comments and reaction changes. The graph's entry stays where it is.
|
|
60
60
|
|
|
61
61
|
Then sketch the nodes and routes. To show the user a graph, call the `andorra_graph_show` action: with
|
|
62
62
|
`draftId` for a draft you are building, or with `id` (and `revision`, if not the latest) for a published graph.
|
|
@@ -67,7 +67,7 @@ check (loop modifier) --pass--> done
|
|
|
67
67
|
`pass` or runs out of attempts. It exposes only the `pass` port; use it when the same agent fixes and
|
|
68
68
|
rechecks its own work.
|
|
69
69
|
|
|
70
|
-
## Pull request with review fixes
|
|
70
|
+
## Pull request with review fixes
|
|
71
71
|
|
|
72
72
|
```
|
|
73
73
|
orchestrator --completed--> pr-owner --completed--> done
|
|
@@ -75,24 +75,18 @@ orchestrator --completed--> pr-owner --completed--> done
|
|
|
75
75
|
|
|
76
76
|
Use this whenever the workflow opens a pull request, reviews one, or answers its review comments.
|
|
77
77
|
|
|
78
|
-
- One agent owns the PR
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- Never wait with `sleep`, a shell polling loop, or `set_timer` (timers are for reminders the user asked for).
|
|
91
|
-
Waiting inside a tool call is the only wait that does not hold the model.
|
|
92
|
-
- Give the owner shell, file-write and network access (it runs `git` and `gh`), and a `limits.wallTimeMs` with
|
|
93
|
-
room for several fix rounds: a 15-minute ceiling stops it in the middle of a fix.
|
|
94
|
-
- Put the exit rule in its instruction: stop when the PR is merged or closed (Auto-fix then switches itself
|
|
95
|
-
off), when the reviewer signs off, or after a fixed number of rounds the user chose.
|
|
78
|
+
- One agent owns the PR from opening or attaching it through answering review comments. Keep the
|
|
79
|
+
graph's entry where it is and put the review instructions on the PR owner's node.
|
|
80
|
+
- When the workflow calls for PR monitoring, the owner can use `pull_request` with
|
|
81
|
+
`action: "await_review"`. This holds the current run and preserves its conversation. Use the returned
|
|
82
|
+
comment classifications as hints. Verify findings in the review and check reaction changes for context.
|
|
83
|
+
The owner fixes findings it agrees with, pushes, replies and resolves the threads it fixed, and replies
|
|
84
|
+
to disputed findings. The owner decides whether to wait again based on the task and the review status.
|
|
85
|
+
- Give the owner shell, file-write and network access for `git` and `gh`. Set `limits.wallTimeMs`
|
|
86
|
+
with room for any review rounds the user requests. Use the review tool for waits on surfaces that
|
|
87
|
+
support it.
|
|
88
|
+
- Have the owner stop when the reviewer signs off, the PR closes or merges, or the requested round
|
|
89
|
+
limit is reached. Merge only when authorized.
|
|
96
90
|
|
|
97
91
|
## Single agent with a human approval
|
|
98
92
|
|
|
@@ -714,7 +714,7 @@
|
|
|
714
714
|
{
|
|
715
715
|
"source": "src/skills/bundled/graph-manager/SKILL.md",
|
|
716
716
|
"asset": "graph-manager/SKILL.md",
|
|
717
|
-
"sha256": "
|
|
717
|
+
"sha256": "a64da6d3b2a8f47ac8fa9012f4eb4fa44ac188b75a94f4872cbfebd6096035f1"
|
|
718
718
|
},
|
|
719
719
|
{
|
|
720
720
|
"source": "src/skills/bundled/graph-manager/errors.md",
|
|
@@ -724,12 +724,12 @@
|
|
|
724
724
|
{
|
|
725
725
|
"source": "src/skills/bundled/graph-manager/patterns.md",
|
|
726
726
|
"asset": "graph-manager/patterns.md",
|
|
727
|
-
"sha256": "
|
|
727
|
+
"sha256": "fc585892e2010e1f8c828b4d28ed14341ff35ec7f0b276ade2aff3e781a379f1"
|
|
728
728
|
},
|
|
729
729
|
{
|
|
730
730
|
"source": "src/skills/bundled/bug-report/SKILL.md",
|
|
731
731
|
"asset": "bug-report/SKILL.md",
|
|
732
|
-
"sha256": "
|
|
732
|
+
"sha256": "f5899f2bcb3e4c2f809673e4f2f40a138da3de4d3e7fa20cf33638003d521e01"
|
|
733
733
|
},
|
|
734
734
|
{
|
|
735
735
|
"source": "src/skills/bundled/diagram/SKILL.md",
|
package/dist/src/subagent-run.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { requireLegalAcceptance } from './legal/gate.js';
|
|
2
3
|
import { homedir } from 'node:os';
|
|
3
4
|
import { realpath, stat } from 'node:fs/promises';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { configDirectory, resolveCodeIntelConfig, resolveConfiguredLimits, resolveMemoryConfig } from './config.js';
|
|
6
|
+
import { beginTelemetryRun, runTelemetryMetadata, drainTelemetry, reportRunFinished, reportRunStarted } from './telemetry/surface.js';
|
|
7
|
+
import { loadCliConfig, cliTelemetryResult } from './telemetry/permission-command.js';
|
|
7
8
|
import { configuredContextWindow, createAdapter, providerModels } from './providers.js';
|
|
8
|
-
import { getMembership, loadAccessibleGraph } from './membership.js';
|
|
9
|
+
import { getMembership, loadAccessibleGraph, withAnonymousJev } from './membership.js';
|
|
9
10
|
import { currentGraphSubject } from './graph-selection.js';
|
|
10
|
-
import { createRunTelemetry, recordModelUse } from './telemetry/capture.js';
|
|
11
|
+
import { createRunTelemetry, recordModelUse, mergeRunTelemetry, hasRunTelemetry } from './telemetry/capture.js';
|
|
11
12
|
import { hostedGate } from './andorra/hosted.js';
|
|
12
13
|
import { checkGraphModelHealth, plainHealthFailure } from './graph-health.js';
|
|
13
14
|
import { validateGraph } from './graphs.js';
|
|
@@ -23,8 +24,8 @@ import { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceMan
|
|
|
23
24
|
import { DecisionManager } from './decision/DecisionManager.js';
|
|
24
25
|
import { permissionMode } from './permissions.js';
|
|
25
26
|
import { TodoStore } from './todos.js';
|
|
26
|
-
import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY,
|
|
27
|
-
import { SessionStore, projectIdentity,
|
|
27
|
+
import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, summaryForStoppedRecord, writeFinalRunRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
|
|
28
|
+
import { SessionStore, projectIdentity, randomSessionName } from './sessions.js';
|
|
28
29
|
export const SUBAGENT_GRAPH_ID = 'default';
|
|
29
30
|
export const MAX_SUBAGENT_TASK_CHARS = 100_000;
|
|
30
31
|
export const MAX_SUBAGENT_MODEL_CHARS = 500;
|
|
@@ -127,7 +128,10 @@ export async function subagentDecisionConfig(config, membership) {
|
|
|
127
128
|
const decisions = config.decisions;
|
|
128
129
|
if (config.jevEnabled === false || !decisions || decisions.provider === 'none' || decisions.mode === 'off')
|
|
129
130
|
return { mode: 'off', provider: 'none' };
|
|
130
|
-
|
|
131
|
+
const access = await withAnonymousJev(await membership());
|
|
132
|
+
if (access.subject)
|
|
133
|
+
return decisions;
|
|
134
|
+
return access.anonymousJev ? { ...decisions, anonymous: true } : { mode: 'off', provider: 'none' };
|
|
131
135
|
}
|
|
132
136
|
export class SubagentRunner {
|
|
133
137
|
defaults;
|
|
@@ -170,60 +174,63 @@ export class SubagentRunner {
|
|
|
170
174
|
}
|
|
171
175
|
async begin(options, permissions) {
|
|
172
176
|
const directory = options.directory ?? this.defaults.directory ?? configDirectory();
|
|
177
|
+
await requireLegalAcceptance(directory);
|
|
178
|
+
const startedAt = new Date().toISOString();
|
|
179
|
+
const telemetryHandle = await beginTelemetryRun({ home: directory, surface: 'subagent' }, startedAt, {
|
|
180
|
+
graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: permissions,
|
|
181
|
+
}, options.workspace).catch(() => undefined);
|
|
182
|
+
const telemetryAccess = { home: directory, lease: telemetryHandle?.lease };
|
|
173
183
|
const workspace = await canonicalWorkspace(options.workspace);
|
|
174
|
-
const config = await (this.defaults.loadConfig ??
|
|
184
|
+
const config = await (this.defaults.loadConfig ?? loadCliConfig)(directory);
|
|
175
185
|
const { provider, model } = resolveSubagentProvider(config, options);
|
|
176
186
|
if (!claimProcessWorkspace(workspace, this.reservationId))
|
|
177
187
|
throw new SubagentRunInProgressError();
|
|
178
188
|
this.reservedWorkspace = workspace;
|
|
179
|
-
const telemetryRunId = randomUUID();
|
|
180
189
|
const accountSubject = await currentGraphSubject().catch(() => undefined);
|
|
181
190
|
const runId = randomUUID();
|
|
182
191
|
const run = {
|
|
183
|
-
runId, sessionId: randomUUID(), task: options.task, workspace, directory,
|
|
192
|
+
runId, sessionId: randomUUID(), name: randomSessionName(), task: options.task, workspace, directory, telemetryHandle,
|
|
184
193
|
...(accountSubject === undefined ? {} : { accountSubject }),
|
|
185
194
|
jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off',
|
|
186
|
-
providerId: provider.id, model, permissions, controller: new AbortController(), startedAt
|
|
195
|
+
providerId: provider.id, model, permissions, controller: new AbortController(), startedAt,
|
|
187
196
|
events: [], notices: [], journal: Promise.resolve(), finished: Promise.resolve(),
|
|
188
197
|
journalWriter: createRunJournalWriter(directory, runId), checkpoints: createCheckpointFailureTracker(directory, runId),
|
|
189
|
-
probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 },
|
|
198
|
+
probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeTelemetry: createRunTelemetry(telemetryAccess),
|
|
190
199
|
providerType: provider.type, baseUrl: provider.baseUrl,
|
|
191
200
|
};
|
|
201
|
+
if (telemetryHandle)
|
|
202
|
+
Object.assign(telemetryHandle.dimensions, { jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off' });
|
|
192
203
|
const openRecord = {
|
|
193
204
|
id: run.runId, status: 'running', sessionId: run.sessionId, startedAt: run.startedAt, pid: process.pid,
|
|
194
205
|
graphSelection: SUBAGENT_GRAPH_ID, graph: { id: SUBAGENT_GRAPH_ID }, provider: provider.id, model,
|
|
195
206
|
...(accountSubject === undefined ? {} : { accountSubject }),
|
|
196
207
|
surface: 'subagent',
|
|
197
|
-
telemetry: {
|
|
208
|
+
telemetry: runTelemetryMetadata({ home: directory, surface: 'subagent' }, telemetryHandle),
|
|
198
209
|
subagent: true,
|
|
199
210
|
permissions: run.permissions,
|
|
200
211
|
};
|
|
201
212
|
try {
|
|
202
|
-
await writeOpenRunRecord(directory, openRecord);
|
|
213
|
+
await writeOpenRunRecord(directory, openRecord, telemetryAccess);
|
|
203
214
|
}
|
|
204
215
|
catch (error) {
|
|
205
216
|
await removeOpenRunRecord(directory, run.runId).catch(() => { });
|
|
206
217
|
const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
|
|
207
218
|
throw Object.assign(new Error(`Could not write the subagent run record: ${error instanceof Error ? error.message : String(error)}`), typeof code === 'string' ? { code } : {}, error instanceof Error ? { cause: error } : {});
|
|
208
219
|
}
|
|
209
|
-
run.
|
|
210
|
-
graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
|
|
211
|
-
jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
|
|
212
|
-
}, workspace);
|
|
213
|
-
run.telemetryStart = reportRunStarted({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle).catch(() => { });
|
|
220
|
+
run.telemetryStart = telemetryHandle ? reportRunStarted({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, telemetryHandle).catch(() => { }) : Promise.resolve();
|
|
214
221
|
await run.telemetryStart;
|
|
215
222
|
await writeOpenRunRecord(directory, {
|
|
216
223
|
...openRecord,
|
|
217
|
-
telemetry: {
|
|
218
|
-
}).catch(() => { });
|
|
224
|
+
telemetry: runTelemetryMetadata({ home: directory, surface: 'subagent' }, telemetryHandle),
|
|
225
|
+
}, telemetryAccess).catch(() => { });
|
|
219
226
|
try {
|
|
220
227
|
await this.saveSession(run, { summary: RUNNING_TURN_SUMMARY, tests: [], status: 'running' });
|
|
221
228
|
}
|
|
222
229
|
catch (error) {
|
|
223
230
|
await removeOpenRunRecord(directory, run.runId).catch(() => { });
|
|
224
231
|
await run.telemetryStart;
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
if (telemetryHandle)
|
|
233
|
+
await reportRunFinished({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, telemetryHandle, { status: 'infrastructure_error', reason: 'The subagent session record could not be saved.' }).catch(() => { });
|
|
227
234
|
throw error;
|
|
228
235
|
}
|
|
229
236
|
this.active = run;
|
|
@@ -255,7 +262,7 @@ export class SubagentRunner {
|
|
|
255
262
|
if (!run.outcome)
|
|
256
263
|
return { state: 'running' };
|
|
257
264
|
return { state: 'finished', status: run.outcome.status,
|
|
258
|
-
...(run.outcome.result !== undefined ? { result: run.outcome.result } : {}),
|
|
265
|
+
...(run.outcome.result !== undefined ? { result: cliTelemetryResult(run.directory, run.outcome.result, run.telemetryHandle?.lease) } : {}),
|
|
259
266
|
...(run.outcome.reason !== undefined ? { reason: run.outcome.reason } : {}) };
|
|
260
267
|
}
|
|
261
268
|
cancel() {
|
|
@@ -342,14 +349,8 @@ export class SubagentRunner {
|
|
|
342
349
|
onUsage: (delta, reference) => {
|
|
343
350
|
foldUsage(run.probeUsage, delta);
|
|
344
351
|
options.healthDependencies?.onUsage?.(delta, reference);
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
for (const field of ['requests', 'inputTokens', 'outputTokens', 'cacheRead', 'cacheWrite']) {
|
|
348
|
-
const value = delta[field];
|
|
349
|
-
if (typeof value === 'number')
|
|
350
|
-
entry.usage[field] = (entry.usage[field] ?? 0) + value;
|
|
351
|
-
}
|
|
352
|
-
run.probeModels.set(key, entry);
|
|
352
|
+
if (hasRunTelemetry(run.probeTelemetry))
|
|
353
|
+
recordModelUse(run.probeTelemetry, { providerType: run.providerType, baseUrl: run.baseUrl, model: reference.model, role: 'other', usage: delta });
|
|
353
354
|
},
|
|
354
355
|
});
|
|
355
356
|
if (!health.healthy) {
|
|
@@ -387,12 +388,13 @@ export class SubagentRunner {
|
|
|
387
388
|
...(meta?.generation === undefined ? {} : { generation: meta.generation }),
|
|
388
389
|
...(meta?.provider === undefined ? {} : { provider: meta.provider }),
|
|
389
390
|
...(meta?.model === undefined ? {} : { model: meta.model }),
|
|
390
|
-
}))
|
|
391
|
+
}, { lease: run.telemetryHandle?.lease }))
|
|
391
392
|
.then(() => run.checkpoints.succeeded({ nodeId, generation: meta?.generation }), error => run.checkpoints.failed({ nodeId, generation: meta?.generation }, error));
|
|
392
393
|
return checkpointWrites;
|
|
393
394
|
};
|
|
394
395
|
const { createTools } = await import('./tools.js');
|
|
395
396
|
const graphOptions = {
|
|
397
|
+
telemetry: { home: run.directory, lease: run.telemetryHandle?.lease },
|
|
396
398
|
task: run.task, runId: run.runId, provider: run.providerId, model: run.model,
|
|
397
399
|
adapter: adapterFor(resolvedProvider),
|
|
398
400
|
...(resolvedProvider.contextWindow === undefined ? {} : { contextWindow: resolvedProvider.contextWindow }),
|
|
@@ -442,7 +444,7 @@ export class SubagentRunner {
|
|
|
442
444
|
}
|
|
443
445
|
async saveSession(run, completion, usage = { requests: 0, inputTokens: 0, outputTokens: 0 }, updatedAt = new Date().toISOString()) {
|
|
444
446
|
await new SessionStore(run.directory).save({
|
|
445
|
-
version: 1, id: run.sessionId, name:
|
|
447
|
+
version: 1, id: run.sessionId, name: run.name, workspace: run.workspace, updatedAt,
|
|
446
448
|
history: [{ task: run.task, completion, runId: run.runId }], usage, projectId: projectIdentity(run.workspace),
|
|
447
449
|
});
|
|
448
450
|
}
|
|
@@ -450,25 +452,21 @@ export class SubagentRunner {
|
|
|
450
452
|
const status = result?.status ?? (run.controller.signal.aborted ? 'cancelled' : 'infrastructure_error');
|
|
451
453
|
const reason = result?.reason ?? (failure !== undefined ? (failure instanceof Error ? failure.message : String(failure)) : undefined);
|
|
452
454
|
const telemetrySurface = { home: run.directory, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) };
|
|
453
|
-
const telemetryHandle = run.telemetryHandle
|
|
454
|
-
|
|
455
|
-
jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
|
|
456
|
-
}, run.workspace);
|
|
455
|
+
const telemetryHandle = run.telemetryHandle;
|
|
456
|
+
const telemetryAccess = { home: run.directory, lease: telemetryHandle?.lease };
|
|
457
457
|
let telemetryFinished = false;
|
|
458
458
|
const settleTelemetry = (settled, why) => {
|
|
459
|
-
if (telemetryFinished)
|
|
459
|
+
if (telemetryFinished || !telemetryHandle)
|
|
460
460
|
return Promise.resolve();
|
|
461
461
|
telemetryFinished = true;
|
|
462
|
-
const finishedTelemetry = result?.telemetry ?? createRunTelemetry();
|
|
463
|
-
|
|
464
|
-
recordModelUse(finishedTelemetry, { providerType: run.providerType, baseUrl: run.baseUrl, model: probe.model, role: 'other', usage: probe.usage });
|
|
465
|
-
}
|
|
462
|
+
const finishedTelemetry = result?.telemetry ?? createRunTelemetry(telemetryAccess);
|
|
463
|
+
mergeRunTelemetry(finishedTelemetry, run.probeTelemetry);
|
|
466
464
|
return (run.telemetryStart ?? Promise.resolve()).then(() => reportRunFinished(telemetrySurface, telemetryHandle, {
|
|
467
465
|
status: settled, ...(why === undefined ? {} : { reason: why }),
|
|
468
466
|
...(result?.providerRequestFailed || run.healthProviderFailed ? { providerRequestFailed: true } : {}),
|
|
469
467
|
...(result?.providerOverflow ? { providerOverflow: true } : {}),
|
|
470
468
|
...(result?.failureCode === undefined ? {} : { errorCode: result.failureCode }),
|
|
471
|
-
...(result?.telemetry !== undefined || run.
|
|
469
|
+
...(result?.telemetry !== undefined || (hasRunTelemetry(run.probeTelemetry) && run.probeTelemetry.models.length > 0) ? { telemetry: finishedTelemetry } : {}),
|
|
472
470
|
...(result?.toolCalls === undefined ? {} : { toolCalls: result.toolCalls }),
|
|
473
471
|
})).catch(() => { });
|
|
474
472
|
};
|
|
@@ -491,14 +489,14 @@ export class SubagentRunner {
|
|
|
491
489
|
record.checkpointFailures = run.checkpoints.failures;
|
|
492
490
|
}
|
|
493
491
|
try {
|
|
494
|
-
await
|
|
492
|
+
await writeFinalRunRecord(run.directory, record, telemetryAccess);
|
|
495
493
|
}
|
|
496
494
|
catch (error) {
|
|
497
495
|
process.stderr.write(`Could not record the stopped subagent run: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
498
496
|
const detail = error instanceof Error ? error.message : String(error);
|
|
499
|
-
const terminalized = await
|
|
497
|
+
const terminalized = await writeFinalRunRecord(run.directory, {
|
|
500
498
|
...record, status: 'infrastructure_error', reason: `The run record could not be written: ${detail}`, endedAt,
|
|
501
|
-
},
|
|
499
|
+
}, telemetryAccess).then(() => true, () => false);
|
|
502
500
|
if (terminalized) {
|
|
503
501
|
await writeStudioRunSummary(run.directory, {
|
|
504
502
|
id: run.runId, status: 'infrastructure_error', startedAt: run.startedAt, graphSelection: SUBAGENT_GRAPH_ID,
|
|
@@ -517,7 +515,8 @@ export class SubagentRunner {
|
|
|
517
515
|
this.releaseWorkspace();
|
|
518
516
|
this.release(run);
|
|
519
517
|
await settleTelemetry('infrastructure_error', `The run record could not be written: ${detail}`);
|
|
520
|
-
|
|
518
|
+
if (telemetryHandle)
|
|
519
|
+
await drainTelemetry({ ...telemetrySurface, lease: telemetryHandle.lease }).catch(() => { });
|
|
521
520
|
run.outcome = { status: 'infrastructure_error', reason: `The run record could not be written: ${detail}` };
|
|
522
521
|
return;
|
|
523
522
|
}
|
|
@@ -544,7 +543,8 @@ export class SubagentRunner {
|
|
|
544
543
|
this.releaseWorkspace();
|
|
545
544
|
this.release(run);
|
|
546
545
|
await settleTelemetry(status, reason);
|
|
547
|
-
|
|
546
|
+
if (telemetryHandle)
|
|
547
|
+
await drainTelemetry({ ...telemetrySurface, lease: telemetryHandle.lease }).catch(() => { });
|
|
548
548
|
run.outcome = { status, ...(result !== undefined ? { result } : {}), ...(reason !== undefined ? { reason } : {}) };
|
|
549
549
|
}
|
|
550
550
|
runSignal() {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type CodexConnect } from './codex-rpc.js';
|
|
2
|
+
import type { EfficiencyConfig } from './efficiency.js';
|
|
3
|
+
import type { QuotaReadings, QuotaWindow } from './model-pool.js';
|
|
4
|
+
import type { ProviderConfig } from './providers.js';
|
|
5
|
+
/**
|
|
6
|
+
* Subscription usage for pool routing, read from each provider's own client. Nothing here reads another tool's
|
|
7
|
+
* files: a provider with no built-in source simply has no reading, and pool routing treats that as no known limit.
|
|
8
|
+
*/
|
|
9
|
+
/** How long one reading is reused before the provider is asked again. */
|
|
10
|
+
export declare const USAGE_READING_TTL_MS = 60000;
|
|
11
|
+
export type UsageProvider = Pick<ProviderConfig, 'id' | 'type' | 'codexAccount'>;
|
|
12
|
+
export type UsageSource = (provider: UsageProvider, signal: AbortSignal) => Promise<QuotaWindow[] | undefined>;
|
|
13
|
+
/** The hosted allowance as the hosted monitor reports it. */
|
|
14
|
+
export type HostedUsageReading = {
|
|
15
|
+
kind: string;
|
|
16
|
+
usedPercent?: number;
|
|
17
|
+
resetsAt?: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
/** The usage windows in a Codex `account/rateLimits/read` answer. */
|
|
20
|
+
export declare function codexWindows(rateLimits: unknown): QuotaWindow[];
|
|
21
|
+
/** Ask the signed-in Codex client for its account's usage windows. */
|
|
22
|
+
export declare function readCodexUsage(provider: UsageProvider, signal: AbortSignal, connect?: CodexConnect): Promise<QuotaWindow[] | undefined>;
|
|
23
|
+
/** The hosted weekly allowance as one usage window. */
|
|
24
|
+
export declare function hostedWindows(usage: HostedUsageReading): QuotaWindow[] | undefined;
|
|
25
|
+
/** The provider types whose client can report usage. */
|
|
26
|
+
export declare const USAGE_SOURCES: Readonly<Partial<Record<string, UsageSource>>>;
|
|
27
|
+
type UsageCache = Map<string, {
|
|
28
|
+
at: number;
|
|
29
|
+
windows: Promise<QuotaWindow[] | undefined>;
|
|
30
|
+
}>;
|
|
31
|
+
export interface UsageReaderOptions {
|
|
32
|
+
/** Read only these provider ids. */
|
|
33
|
+
only?: readonly string[];
|
|
34
|
+
sources?: Readonly<Partial<Record<string, UsageSource>>>;
|
|
35
|
+
hosted?: () => HostedUsageReading;
|
|
36
|
+
now?: () => number;
|
|
37
|
+
ttlMs?: number;
|
|
38
|
+
cache?: UsageCache;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A reader of usage by provider id. Each provider is asked at most once per `ttlMs`; a read that fails or times out
|
|
42
|
+
* gives no reading for that provider and never fails the caller.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createUsageReader(providers: () => readonly UsageProvider[], options?: UsageReaderOptions): (signal: AbortSignal) => Promise<QuotaReadings>;
|
|
45
|
+
/** The usage reader for a configuration's pool: it asks only the providers the pool names. */
|
|
46
|
+
export declare function poolUsageReader(config: {
|
|
47
|
+
providers: readonly UsageProvider[];
|
|
48
|
+
efficiency?: EfficiencyConfig;
|
|
49
|
+
}, hosted?: () => HostedUsageReading): (signal: AbortSignal) => Promise<QuotaReadings>;
|
|
50
|
+
export {};
|