@andorra-labs/code 0.1.10 → 0.1.11
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/README.md +28 -208
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/agent-execution.js +36 -0
- package/dist/src/app-server/protocol.d.ts +1 -0
- package/dist/src/app-server.d.ts +34 -1
- package/dist/src/app-server.js +264 -54
- package/dist/src/automation-service.js +1 -1
- package/dist/src/browser-session.d.ts +8 -0
- package/dist/src/browser-session.js +27 -1
- package/dist/src/browser-ui/app.js +237 -15
- package/dist/src/browser-ui/index.html +5 -5
- package/dist/src/browser-ui/style.css +110 -65
- package/dist/src/browser-ui/tokens.css +27 -26
- package/dist/src/coding-tools.d.ts +24 -0
- package/dist/src/coding-tools.js +71 -8
- package/dist/src/command-screens.js +1 -1
- package/dist/src/commands.js +1 -1
- package/dist/src/completion-gates.d.ts +42 -7
- package/dist/src/completion-gates.js +55 -9
- package/dist/src/completion.d.ts +8 -0
- package/dist/src/completion.js +19 -1
- package/dist/src/dashboard-view.js +2 -2
- package/dist/src/deadline.js +4 -0
- package/dist/src/graph-manager-chat.js +13 -13
- package/dist/src/graph-runner.js +39 -2
- package/dist/src/graph-server.js +9 -9
- package/dist/src/graph-sync.d.ts +8 -0
- package/dist/src/graph-sync.js +54 -3
- package/dist/src/graph-tool.js +1 -1
- package/dist/src/graph-ui/app.js +262 -93
- package/dist/src/graph-ui/controls.css +43 -22
- package/dist/src/graph-ui/controls.js +31 -1
- package/dist/src/graph-ui/embed.js +62 -13
- package/dist/src/graph-ui/icons.js +4 -0
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/manager-state.js +2 -2
- package/dist/src/graph-ui/manager.css +19 -18
- package/dist/src/graph-ui/manager.js +11 -11
- package/dist/src/graph-ui/skill-picker.js +1 -1
- package/dist/src/graph-ui/studio-canvas.js +8 -8
- package/dist/src/graph-ui/studio.css +18 -15
- package/dist/src/graph-ui/studio.js +92 -35
- package/dist/src/graph-ui/style.css +122 -79
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +33 -29
- package/dist/src/graphs.d.ts +3 -2
- package/dist/src/graphs.js +3 -2
- package/dist/src/membership-errors.d.ts +7 -1
- package/dist/src/membership-errors.js +9 -3
- package/dist/src/pull-requests.d.ts +42 -6
- package/dist/src/pull-requests.js +11 -3
- package/dist/src/react-runtime.js +121 -14
- package/dist/src/read-document-doc.d.ts +20 -0
- package/dist/src/read-document-doc.js +524 -0
- package/dist/src/read-document-docx.d.ts +21 -0
- package/dist/src/read-document-docx.js +584 -0
- package/dist/src/read-document-text.d.ts +29 -0
- package/dist/src/read-document-text.js +67 -0
- package/dist/src/read-document-tool.d.ts +48 -0
- package/dist/src/read-document-tool.js +162 -0
- package/dist/src/read-document.d.ts +78 -0
- package/dist/src/read-document.js +353 -0
- package/dist/src/read-image.d.ts +29 -2
- package/dist/src/read-image.js +42 -17
- package/dist/src/runtime.d.ts +19 -0
- package/dist/src/runtime.js +10 -1
- package/dist/src/session-changes.d.ts +6 -1
- package/dist/src/session-changes.js +13 -5
- package/dist/src/side-panel.d.ts +6 -1
- package/dist/src/side-panel.js +12 -10
- package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
- package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
- package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
- package/dist/src/skills/bundled/provenance.json +4 -4
- package/dist/src/skills/runtime-skills.js +3 -3
- package/dist/src/stall-recovery.d.ts +6 -2
- package/dist/src/stall-recovery.js +7 -2
- package/dist/src/terminal-ui.js +2 -2
- package/dist/src/time-limit.d.ts +53 -0
- package/dist/src/time-limit.js +79 -0
- package/dist/src/tools.js +92 -7
- package/dist/src/transcript.js +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/usage-analytics.d.ts +3 -1
- package/dist/src/usage-analytics.js +16 -2
- package/package.json +6 -26
- package/docs/README.md +0 -36
- package/docs/agents/README.md +0 -62
- package/docs/agents/install-for-agents.md +0 -56
- package/docs/agents/mcp-server.md +0 -212
- package/docs/agents/subagent-mode.md +0 -149
- package/docs/concepts/README.md +0 -47
- package/docs/concepts/jev-actionable-routing.md +0 -113
- package/docs/concepts/jev-decision-thresholds.md +0 -412
- package/docs/concepts/jev-efficiency.md +0 -217
- package/docs/concepts/jev-eval-2026-11-01.md +0 -78
- package/docs/concepts/limits.md +0 -52
- package/docs/concepts/memory.md +0 -10
- package/docs/concepts/security.md +0 -50
- package/docs/concepts/workspace-instructions.md +0 -29
- package/docs/getting-started/README.md +0 -82
- package/docs/getting-started/accounts.md +0 -78
- package/docs/getting-started/configure-providers.md +0 -132
- package/docs/guides/README.md +0 -13
- package/docs/guides/browser.md +0 -39
- package/docs/guides/desktop-app.md +0 -414
- package/docs/guides/extensions.md +0 -102
- package/docs/guides/graph-builder.md +0 -116
- package/docs/guides/headless.md +0 -46
- package/docs/guides/tui.md +0 -75
- package/docs/guides/update.md +0 -70
- package/docs/guides/web-search.md +0 -51
- package/docs/guides/windows-code-signing.md +0 -319
- package/docs/llms.txt +0 -45
- package/docs/reference/README.md +0 -7
- package/docs/reference/cli.md +0 -76
- package/docs/reference/config.md +0 -91
- package/docs/reference/slash-commands.md +0 -59
- package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
- package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
- package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
- package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
- package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
- package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
- package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
- package/scripts/jev-efficiency-eval.mjs +0 -187
- package/scripts/jev-efficiency-live.mjs +0 -193
- package/scripts/zcode-engine-replay.mjs +0 -223
- package/tests/agent-centric-mcp-test-plan.md +0 -208
- package/tests/analytics-settings-test-plan.md +0 -165
- package/tests/browser-cli-smoke.mjs +0 -276
- package/tests/browser-test-plan.md +0 -280
- package/tests/chat-side-panel-test-plan.md +0 -309
- package/tests/decision-engine-test-plan.md +0 -163
- package/tests/default-active-jev-test-plan.md +0 -85
- package/tests/harness-extensions-test-plan.md +0 -113
- package/tests/jev-all-decisions-test-plan.md +0 -156
- package/tests/jev-efficiency/criteria.json +0 -158
- package/tests/jev-efficiency/workloads.mjs +0 -242
- package/tests/jev-efficiency-test-plan.md +0 -198
- package/tests/permissions-sandbox-probe.mjs +0 -74
- package/tests/permissions-test-plan.md +0 -191
- package/tests/product-telemetry-test-plan.md +0 -536
- package/tests/thinking-stream-preview-test-plan.md +0 -136
- package/tests/zcode-react-engine-test-plan.md +0 -396
|
@@ -9,7 +9,7 @@ import { andorraIsContextOverflow } from '../vendor/engine/runtime/ai/utils/over
|
|
|
9
9
|
import { toEngineResponse, engineModel } from './engine/protocol.js';
|
|
10
10
|
import { ProviderRequestError } from './providers.js';
|
|
11
11
|
import { COMPLETION_ALONE_ERROR, COMPLETION_TOOL, COMPLETION_GUIDANCE, FINAL_RESPONSE_GUIDANCE, OUTPUT_STOOD_IN_NOTE, RESPONSE_STRUCTURE_GUIDANCE, completionTool, completionResponse, parseCompletion } from './completion.js';
|
|
12
|
-
import { MAX_GATE_ASKS, finalAnswerGate } from './completion-gates.js';
|
|
12
|
+
import { MAX_GATE_ASKS, MAX_IDLE_UNFINISHED_ASKS, finalAnswerGate } from './completion-gates.js';
|
|
13
13
|
import { HistoryCompactor, CompactionRecoveryError, pinnedContextChars, PINNED_CONTEXT_GUIDANCE } from './context-compaction.js';
|
|
14
14
|
import { createHash, randomUUID } from 'node:crypto';
|
|
15
15
|
import { ToolFailureTracker } from './tool-failure-tracker.js';
|
|
@@ -36,6 +36,7 @@ import { commandLine, isCheckCall, isReplaySafeCheck } from './decision/checks.j
|
|
|
36
36
|
import { stalledTurnGuidance, suspectedDroppedToolCall, unavailableHistoryTools, unavailableToolsSentence } from './stall-recovery.js';
|
|
37
37
|
import { ClarificationRequiredError, DEFAULT_GRAPH, hasToolBudget, generateWithUsage, resolveLimits, withinToolBudget, turnModelTask, } from './runtime.js';
|
|
38
38
|
import { bindUserWaits, createRuntimeBudget } from './deadline.js';
|
|
39
|
+
import { createTimeLimitNotices, timeLimitPrompt, withTimeLimitPrompt } from './time-limit.js';
|
|
39
40
|
import { createCommandOutputTap } from './command-output-tap.js';
|
|
40
41
|
import { advertisable } from './tool-availability.js';
|
|
41
42
|
const DEFAULT_AGENT_INSTRUCTIONS = `You are the Andorra Agent in Andorra Code's default graph.
|
|
@@ -46,6 +47,8 @@ Issue independent read-only calls together in one turn, and combine related shel
|
|
|
46
47
|
Do mechanical or repetitive work by executing code (a shell one-liner or script), not through repeated model-driven edits.
|
|
47
48
|
Keep tool output small: filter, count, select, or tail instead of feeding whole files or long listings back into context.
|
|
48
49
|
Reuse unchanged evidence and known interfaces rather than rereading files. For runnable software, build the smallest integrated vertical slice first: entry point, initialization and one real interaction. Run a boot/syntax smoke check as soon as that slice exists, before broad subsystem inventories or polishing. Use observed failures to choose the next targeted inspection, and verify with the smallest check that can actually fail. Then complete every requested behavior and verification.
|
|
50
|
+
When the task says what a file must contain (an answer, a flag, a value, output in a stated format), write exactly that into the file and nothing else: no explanation, heading, label, notes or report. Whatever reads the file compares it with what was asked for, so added text turns a correct answer into a wrong one; explanations belong in your summary.
|
|
51
|
+
Before finishing, read the task statement again and check the result against each thing it states: file paths and names, formats, exact values, constraints, and what must stay unchanged. A check written from your own reading of the task only repeats that reading, so where the task names its own check, command or example, run that one.
|
|
49
52
|
When browser.panel is available, use it for browsing: it drives the same tabs the session's Browser panel shows the user, so they can watch every step, and it shares that browser's cookies and login state, which persist in the project's browser profile. qa.browser_session is a separate headless browser the user cannot see; use it alongside browser.panel only for an operation the panel lacks (hold, move) or when the user asks for an isolated browser. When a check needs a fresh, signed-out browser (first-visit flows, sign-up, logged-out pages), call browser.incognito start first, then end it when done. When only qa.browser_session is available, use it directly for website navigation, tab management, screenshots and page interactions. Inspect the repository only when the requested work needs project context; do not inventory shell browser tooling or generate browser probes before trying the granted browser tool.
|
|
50
53
|
If execution is blocked, report why and use focused static checks. Intake, research and non-runnable tasks follow their assigned scope.`;
|
|
51
54
|
const SYSTEM = `Follow the configured Agent instruction and completion contract using only the granted capabilities.
|
|
@@ -70,6 +73,19 @@ function refusedRequest(error) {
|
|
|
70
73
|
const status = typeof direct === 'number' ? direct : Number(/\(HTTP (\d{3})\)/.exec(error instanceof Error ? error.message : '')?.[1]);
|
|
71
74
|
return [400, 404, 415, 422].includes(status);
|
|
72
75
|
}
|
|
76
|
+
/** How much of a stopped command's output its observation keeps. */
|
|
77
|
+
const STEERED_OUTPUT_TAIL = 4_000;
|
|
78
|
+
/** The tools whose call a user steer stops: each waits on a process the user may be waiting out. */
|
|
79
|
+
const STEER_STOPPABLE = new Set(['Bash', 'PowerShell', 'PowerShellFast', 'NativeExec', 'bash', 'powershell', 'shell']);
|
|
80
|
+
function steerStoppable(name, args) {
|
|
81
|
+
return STEER_STOPPABLE.has(name) || (name === 'AsyncProcess' && args.action === 'wait');
|
|
82
|
+
}
|
|
83
|
+
/** The observation for a call a steer stopped: why it ended, and what it printed before. */
|
|
84
|
+
function steeredOutput(elapsedMs, printed) {
|
|
85
|
+
const seconds = Math.max(0, Math.round(elapsedMs / 100) / 10);
|
|
86
|
+
const tail = printed.trim();
|
|
87
|
+
return `Stopped after ${seconds}s: the user sent a new message while this call ran, so it was ended before it finished. Read the message before running it again.${tail ? `\nOutput before it stopped:\n${tail}` : '\nIt printed nothing before it stopped.'}`;
|
|
88
|
+
}
|
|
73
89
|
/** Canonical arguments prevent object-key order from disguising an identical side effect. */
|
|
74
90
|
function actionFingerprint(name, args) {
|
|
75
91
|
const canonical = (value) => Array.isArray(value) ? value.map(canonical)
|
|
@@ -383,6 +399,11 @@ export class AndorraAgentEngine {
|
|
|
383
399
|
? `\nWritten outcome criteria: ${JSON.stringify(outcomeCriteria)}. Evaluate these written criteria against the evidence gathered during this node and use them to select exactly one declared outcome. Explain the selected outcome and supporting evidence in your summary. These are criteria for your judgment, not automatically executed checks. Do not claim a criterion is satisfied without evidence. If criteria overlap or none are satisfied, report that uncertainty honestly and select an appropriate declared fallback outcome when available; never invent an outcome. Outcomes without written criteria retain their meaning from the node instructions and confirmed task.`
|
|
384
400
|
: '';
|
|
385
401
|
messages[0].content += completionContract + criteriaContract;
|
|
402
|
+
// A bounded attempt is told so, and told again as the time runs down (time-limit.ts). The
|
|
403
|
+
// default is no wall clock, in which case nothing is added.
|
|
404
|
+
const timeNotices = limits.wallTimeMs ? createTimeLimitNotices(limits.wallTimeMs) : undefined;
|
|
405
|
+
if (limits.wallTimeMs)
|
|
406
|
+
messages[0].content += `\n${timeLimitPrompt(limits.wallTimeMs)}`;
|
|
386
407
|
// Retained turns render through the one shared renderer: a continued turn's stored task is the
|
|
387
408
|
// stopped attempt's, the direction the user sent with the continuation is the message this turn
|
|
388
409
|
// actually answers — dropped here, the CLI's next request would omit what they said — and a
|
|
@@ -422,6 +443,9 @@ export class AndorraAgentEngine {
|
|
|
422
443
|
if (start >= 0 && end >= 0) {
|
|
423
444
|
system.content = system.content.slice(0, start) + (options.instructions ? `${guidanceMarker}${options.instructions}` : '') + system.content.slice(end);
|
|
424
445
|
}
|
|
446
|
+
// The restored prompt states the limit the stopped attempt began with; this one has what
|
|
447
|
+
// was left of it, or a limit configured since, or none.
|
|
448
|
+
system.content = withTimeLimitPrompt(system.content, limits.wallTimeMs);
|
|
425
449
|
}
|
|
426
450
|
}
|
|
427
451
|
else if (!options.subagentId && options.previousConversation?.provider === options.provider && options.previousConversation.model === options.model) {
|
|
@@ -831,11 +855,35 @@ export class AndorraAgentEngine {
|
|
|
831
855
|
};
|
|
832
856
|
let prepared = [];
|
|
833
857
|
let finalized = [];
|
|
858
|
+
// A user steer that lands while this turn's tools run. The model request is already cut off by
|
|
859
|
+
// its own watch (below); a tool batch had none, so a steer sent during `Start-Sleep 60` waited
|
|
860
|
+
// the whole minute before the model read it. While a batch runs, a steer stops the command in
|
|
861
|
+
// flight and skips the calls that have not started, and the next turn reads the message. Only a
|
|
862
|
+
// runtime that reads the shared steering queue listens: a delegated child never reads it.
|
|
863
|
+
let batchSteer;
|
|
864
|
+
const watchBatchSteer = () => {
|
|
865
|
+
if (batchSteer || !control || !options.getSteeringMessages || options.subagentId)
|
|
866
|
+
return;
|
|
867
|
+
const watch = { arrived: false, cut: new AbortController(), stop: () => { } };
|
|
868
|
+
watch.stop = control.onSteer(() => {
|
|
869
|
+
watch.arrived = true;
|
|
870
|
+
watch.cut.abort(new Error('Stopped to read a new message from the user.'));
|
|
871
|
+
});
|
|
872
|
+
batchSteer = watch;
|
|
873
|
+
};
|
|
874
|
+
const endBatchSteer = () => { batchSteer?.stop(); batchSteer = undefined; };
|
|
834
875
|
let fatalError;
|
|
835
876
|
let modelResponseReady = false;
|
|
836
877
|
let completionRejectionEmitted = false;
|
|
837
878
|
/** Times each final-answer gate has sent a handoff back in this run. */
|
|
838
879
|
const gateAsks = {};
|
|
880
|
+
/**
|
|
881
|
+
* The unfinished gate has no ask limit while the agent works between its completions. What is
|
|
882
|
+
* counted is the opposite: send-backs in a row that it answered with no tool call at all,
|
|
883
|
+
* measured against the tool-call count at the last send-back.
|
|
884
|
+
*/
|
|
885
|
+
let unfinishedIdleAsks = 0;
|
|
886
|
+
let unfinishedAskedAtToolCalls;
|
|
839
887
|
const engineState = { stopHookContinuationCount: continuationState?.engineState?.stopHookContinuationCount ?? continuationState?.zcodeState?.stopHookContinuationCount ?? 0, outputTokenContinuationCount: continuationState?.engineState?.outputTokenContinuationCount ?? continuationState?.zcodeState?.outputTokenContinuationCount ?? 0 };
|
|
840
888
|
let outputPartials = [...(continuationState?.outputPartials ?? [])];
|
|
841
889
|
let overflowRecoveries = 0;
|
|
@@ -880,6 +928,7 @@ export class AndorraAgentEngine {
|
|
|
880
928
|
prepared = [];
|
|
881
929
|
finalized = [];
|
|
882
930
|
executionCalls = 0;
|
|
931
|
+
endBatchSteer();
|
|
883
932
|
response = { text: '', toolCalls: [], completionSource: 'final_text' };
|
|
884
933
|
if (limits.maxIterations !== undefined && iteration > limits.maxIterations) {
|
|
885
934
|
result.reason = 'maxIterations';
|
|
@@ -943,6 +992,12 @@ export class AndorraAgentEngine {
|
|
|
943
992
|
replacePostflightGuidance(arrivedPostflight.guidance);
|
|
944
993
|
arrivedPostflight = undefined;
|
|
945
994
|
}
|
|
995
|
+
// Asked from the budget itself, so time the run spent waiting on a person is not counted.
|
|
996
|
+
const timeNotice = timeNotices?.next(budget.remainingMs());
|
|
997
|
+
if (timeNotice) {
|
|
998
|
+
messages.push({ role: 'user', content: timeNotice.text });
|
|
999
|
+
await emit('agent.time_limit.notice', { stage: timeNotice.stage, remainingMs: budget.remainingMs(), limitMs: limits.wallTimeMs });
|
|
1000
|
+
}
|
|
946
1001
|
refreshTodoContext();
|
|
947
1002
|
const prunedImages = pruneHistoricalImages(messages);
|
|
948
1003
|
if (prunedImages)
|
|
@@ -1278,6 +1333,21 @@ export class AndorraAgentEngine {
|
|
|
1278
1333
|
await emit('node.tool.skipped', { name: entry.call.name, toolCallId: entry.call.id, output });
|
|
1279
1334
|
return { call: entry.call, output, isError: false };
|
|
1280
1335
|
}
|
|
1336
|
+
if (batchSteer?.arrived) {
|
|
1337
|
+
if (isTodoCall(entry.call))
|
|
1338
|
+
todoCalls--;
|
|
1339
|
+
else if (isPreparedPlanCall(entry.call))
|
|
1340
|
+
preparedPlanCalls--;
|
|
1341
|
+
else if (isRestorationCall(entry.call))
|
|
1342
|
+
restorationCalls--;
|
|
1343
|
+
else if (isWidgetCall(entry.call))
|
|
1344
|
+
widgetCalls--;
|
|
1345
|
+
else if (options.budget)
|
|
1346
|
+
options.budget.toolCalls--;
|
|
1347
|
+
const output = 'Not executed: the user sent a new message before this call started. Read it, then decide whether this call is still needed.';
|
|
1348
|
+
await emit('node.tool.skipped', { name: entry.call.name, toolCallId: entry.call.id, output, reason: 'steer' });
|
|
1349
|
+
return { call: entry.call, output, isError: false, steered: true };
|
|
1350
|
+
}
|
|
1281
1351
|
if (!isMetadataCall(entry.call)) {
|
|
1282
1352
|
result.toolCalls++;
|
|
1283
1353
|
recordToolUse(result.telemetry, entry.call.name, false);
|
|
@@ -1340,13 +1410,25 @@ export class AndorraAgentEngine {
|
|
|
1340
1410
|
const commandTap = createCommandOutputTap(chunk => {
|
|
1341
1411
|
void emit('node.tool.output', { name: entry.call.name, toolCallId: entry.call.id, output: chunk }).catch(() => { });
|
|
1342
1412
|
});
|
|
1413
|
+
// Only a call that waits on a process is stopped by a steer: a shell command, a native
|
|
1414
|
+
// executable, or a wait on a background job (the job itself keeps running). A file edit
|
|
1415
|
+
// or a delegated subagent runs to its end, so a steer never leaves half-applied work.
|
|
1416
|
+
const steerCut = batchSteer !== undefined && steerStoppable(entry.call.name, args) ? batchSteer.cut.signal : undefined;
|
|
1417
|
+
const steerStartedAt = monotonicNow();
|
|
1418
|
+
let printed = '';
|
|
1419
|
+
const onCommandOutput = (chunk) => {
|
|
1420
|
+
if (steerCut)
|
|
1421
|
+
printed = (printed + chunk).slice(-STEERED_OUTPUT_TAIL);
|
|
1422
|
+
commandTap.push(chunk);
|
|
1423
|
+
};
|
|
1424
|
+
let steered = false;
|
|
1343
1425
|
try {
|
|
1344
1426
|
output = await tool.execute(args, {
|
|
1345
1427
|
...context,
|
|
1346
1428
|
// A child invocation retains its lifetime; its own operations subscribe
|
|
1347
1429
|
// to the same control and pause without discarding the child history.
|
|
1348
1430
|
...(entry.call.name === 'spawn_subagent' ? {} : {
|
|
1349
|
-
signal: operationSignal,
|
|
1431
|
+
signal: steerCut ? AbortSignal.any([operationSignal, steerCut]) : operationSignal,
|
|
1350
1432
|
userSignal: control ? AbortSignal.any([context.userSignal ?? signal, operationSignal]) : context.userSignal,
|
|
1351
1433
|
}),
|
|
1352
1434
|
onApprovalEvent: (type, data) => {
|
|
@@ -1377,7 +1459,7 @@ export class AndorraAgentEngine {
|
|
|
1377
1459
|
beforeSnapshot = await readFileSnapshot(target);
|
|
1378
1460
|
},
|
|
1379
1461
|
} : {}),
|
|
1380
|
-
onCommandOutput
|
|
1462
|
+
onCommandOutput,
|
|
1381
1463
|
});
|
|
1382
1464
|
// Claim invocation-owned image bytes before any hook or event sink
|
|
1383
1465
|
// can suspend us. Only the original execution output can claim them.
|
|
@@ -1393,9 +1475,12 @@ export class AndorraAgentEngine {
|
|
|
1393
1475
|
isError = true;
|
|
1394
1476
|
if (error instanceof FileReadRequiredError)
|
|
1395
1477
|
refusal = error.refusal;
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1478
|
+
steered = steerCut?.aborted === true && !operationSignal.aborted;
|
|
1479
|
+
output = steered
|
|
1480
|
+
? steeredOutput(monotonicNow() - steerStartedAt, printed)
|
|
1481
|
+
: operationSignal.aborted
|
|
1482
|
+
? `Interrupted by user. This tool may have partially completed; inspect its effects before retrying. It was not automatically replayed.\n${error instanceof Error ? error.message : 'Tool interrupted'}`
|
|
1483
|
+
: `Tool error: ${error instanceof Error ? error.message : 'unknown error'}`;
|
|
1399
1484
|
}
|
|
1400
1485
|
commandTap.stop();
|
|
1401
1486
|
signal.throwIfAborted();
|
|
@@ -1460,7 +1545,7 @@ export class AndorraAgentEngine {
|
|
|
1460
1545
|
? undefined : callFileDiff(beforeSnapshot, afterSnapshot);
|
|
1461
1546
|
// A stop that interrupted the call is not a reliability failure: the capture contract
|
|
1462
1547
|
// excludes it, and counting it would blame the tool for the user's pause.
|
|
1463
|
-
if (isError && !operationSignal.aborted)
|
|
1548
|
+
if (isError && !operationSignal.aborted && !steered)
|
|
1464
1549
|
recordToolFailure(result.telemetry, entry.call.name);
|
|
1465
1550
|
if (!isError && mutation !== undefined) {
|
|
1466
1551
|
recordEdit(result.telemetry, mutation, !editExisted);
|
|
@@ -1469,7 +1554,7 @@ export class AndorraAgentEngine {
|
|
|
1469
1554
|
}
|
|
1470
1555
|
// A suite that ran and failed is still a test run: the category answers what the work was,
|
|
1471
1556
|
// not whether it passed. Only a user interruption leaves the command unfinished.
|
|
1472
|
-
if (!operationSignal.aborted && command !== undefined && isTestCommandLine(command))
|
|
1557
|
+
if (!operationSignal.aborted && !steered && command !== undefined && isTestCommandLine(command))
|
|
1473
1558
|
recordTestCommand(result.telemetry);
|
|
1474
1559
|
const workedMs = elapsedMs(startedAt);
|
|
1475
1560
|
const waitedMs = closeUserWait();
|
|
@@ -1483,7 +1568,7 @@ export class AndorraAgentEngine {
|
|
|
1483
1568
|
});
|
|
1484
1569
|
// A filtered observation is partial evidence by construction, so it is reported truncated:
|
|
1485
1570
|
// no completion shortcut may rest on it, and the decision snapshot sees the real output.
|
|
1486
|
-
return { call: entry.call, output: normalized, isError, executionSucceeded, ...(refusal ? { refusal } : {}), truncated: filtered !== undefined || rawOutput.length > 24_000 || publicOutput.length > 24_000 || publicOutput !== rawOutput, decisionOutput: boundedPublicOutput, ...(!isError && images?.length ? { images } : {}) };
|
|
1571
|
+
return { call: entry.call, output: normalized, isError, executionSucceeded, ...(steered ? { steered } : {}), ...(refusal ? { refusal } : {}), truncated: filtered !== undefined || rawOutput.length > 24_000 || publicOutput.length > 24_000 || publicOutput !== rawOutput, decisionOutput: boundedPublicOutput, ...(!isError && images?.length ? { images } : {}) };
|
|
1487
1572
|
};
|
|
1488
1573
|
const finishTurn = async () => {
|
|
1489
1574
|
if (fatalError || result.status === 'succeeded' || result.reason)
|
|
@@ -1779,18 +1864,38 @@ export class AndorraAgentEngine {
|
|
|
1779
1864
|
// would end the run on `maxIterations` with no answer at all. Every gate is waived there.
|
|
1780
1865
|
const lastIteration = limits.maxIterations !== undefined && iteration >= limits.maxIterations;
|
|
1781
1866
|
const asked = lastIteration ? { summary: MAX_GATE_ASKS, todos: MAX_GATE_ASKS } : gateAsks;
|
|
1867
|
+
// Idle only if nothing ran since the last send-back for unfinished work; any tool call in
|
|
1868
|
+
// between is the agent still working, and the count starts again.
|
|
1869
|
+
const idleUnfinishedAsks = unfinishedAskedAtToolCalls === result.toolCalls ? unfinishedIdleAsks : 0;
|
|
1782
1870
|
const gate = acted && parsedCompletion?.outcome !== undefined && options.finalAnswerOutcomes?.includes(parsedCompletion.outcome)
|
|
1783
|
-
? finalAnswerGate({
|
|
1871
|
+
? finalAnswerGate({
|
|
1872
|
+
summaryStoodIn: coercionNotes.includes(OUTPUT_STOOD_IN_NOTE), summary: parsedCompletion.summary, todos: todoStore.snapshot(), asked,
|
|
1873
|
+
...(parsedCompletion.remaining ? { remaining: parsedCompletion.remaining } : {}),
|
|
1874
|
+
idleUnfinishedAsks: lastIteration ? MAX_IDLE_UNFINISHED_ASKS : idleUnfinishedAsks,
|
|
1875
|
+
timeLeftMs: budget.remainingMs(),
|
|
1876
|
+
}) : undefined;
|
|
1784
1877
|
if (gate?.gates.length) {
|
|
1785
1878
|
for (const id of gate.gates)
|
|
1786
|
-
|
|
1879
|
+
if (id !== 'unfinished')
|
|
1880
|
+
gateAsks[id] = (gateAsks[id] ?? 0) + 1;
|
|
1881
|
+
if (gate.gates.includes('unfinished')) {
|
|
1882
|
+
unfinishedIdleAsks = idleUnfinishedAsks + 1;
|
|
1883
|
+
unfinishedAskedAtToolCalls = result.toolCalls;
|
|
1884
|
+
}
|
|
1787
1885
|
messages.push({ role: 'user', content: gate.message });
|
|
1788
1886
|
await emit('agent.completion.rejected', { reason: gate.message, source: response.completionSource, gates: gate.gates });
|
|
1789
1887
|
await emit('agent.turn.completed', { iteration, toolCalls: 0, continued: true });
|
|
1790
1888
|
return { continue: true, guidanceInjected: true };
|
|
1791
1889
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1890
|
+
// A run that ends with work it reported as unfinished says so in its record, with why the
|
|
1891
|
+
// host let it end: nothing more it could do without the user, no time left, or no turn left.
|
|
1892
|
+
if (gate?.waived.length) {
|
|
1893
|
+
await emit('agent.completion.gate.waived', {
|
|
1894
|
+
gates: gate.waived, source: response.completionSource,
|
|
1895
|
+
reason: lastIteration ? 'maxIterations' : gate.unfinishedWaiver ?? 'asksSpent',
|
|
1896
|
+
...(gate.waived.includes('unfinished') ? { remaining: parsedCompletion?.remaining?.length ?? 0, openTodos: todoStore.snapshot().filter(todo => todo.status !== 'completed').length } : {}),
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1794
1899
|
if (parsedCompletion && coercionNotes.length)
|
|
1795
1900
|
await emit('agent.completion.coerced', { notes: coercionNotes, source: response.completionSource });
|
|
1796
1901
|
const candidateText = !explicit ? [...outputPartials, response.text].join('') : response.text;
|
|
@@ -1911,9 +2016,10 @@ export class AndorraAgentEngine {
|
|
|
1911
2016
|
}
|
|
1912
2017
|
}
|
|
1913
2018
|
try {
|
|
2019
|
+
watchBatchSteer();
|
|
1914
2020
|
const item = await runPrepared(entry);
|
|
1915
2021
|
finalized.push(item);
|
|
1916
|
-
if (!operationSignal.aborted)
|
|
2022
|
+
if (!operationSignal.aborted && !item.steered)
|
|
1917
2023
|
recordFailure(item);
|
|
1918
2024
|
return { id: call.id, content: item.output, success: !item.isError, progress: item.executionSucceeded === true && !isMetadataCall(item.call) };
|
|
1919
2025
|
}
|
|
@@ -1923,6 +2029,7 @@ export class AndorraAgentEngine {
|
|
|
1923
2029
|
}
|
|
1924
2030
|
},
|
|
1925
2031
|
commitToolResults: async () => {
|
|
2032
|
+
endBatchSteer();
|
|
1926
2033
|
finalized.sort((a, b) => response.toolCalls.indexOf(a.call) - response.toolCalls.indexOf(b.call));
|
|
1927
2034
|
return finishTurn();
|
|
1928
2035
|
},
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface CompoundEntry {
|
|
2
|
+
start: number;
|
|
3
|
+
size: number;
|
|
4
|
+
}
|
|
5
|
+
export interface CompoundFile {
|
|
6
|
+
/** Streams directly under the root storage, by name. */
|
|
7
|
+
streams: Map<string, CompoundEntry>;
|
|
8
|
+
read(entry: CompoundEntry): Buffer;
|
|
9
|
+
}
|
|
10
|
+
/** Open a Compound File Binary container. Throws when its structure cannot be followed. */
|
|
11
|
+
export declare function openCompoundFile(bytes: Buffer): CompoundFile;
|
|
12
|
+
/**
|
|
13
|
+
* Text of a legacy Word document, or undefined when the compound file holds something else
|
|
14
|
+
* (an `.xls`, a `.ppt`, an `.msi`), so the caller can report it as the binary file it is.
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractDoc(bytes: Buffer): {
|
|
17
|
+
text: string;
|
|
18
|
+
notes: string[];
|
|
19
|
+
} | undefined;
|
|
20
|
+
export {};
|