@andorra-labs/code 0.1.8 → 0.1.9
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/THIRD_PARTY_NOTICES.md +2 -1
- package/dist/src/account-presentation.d.ts +11 -0
- package/dist/src/account-presentation.js +29 -2
- package/dist/src/agent-execution.js +37 -4
- package/dist/src/agent-mcp.d.ts +12 -0
- package/dist/src/agent-mcp.js +81 -2
- package/dist/src/app-server/protocol.d.ts +12 -0
- package/dist/src/app-server/reasoning.d.ts +0 -8
- package/dist/src/app-server/reasoning.js +15 -28
- package/dist/src/app-server.d.ts +7 -0
- package/dist/src/app-server.js +59 -11
- package/dist/src/auth/AuthManager.d.ts +15 -0
- package/dist/src/auth/AuthManager.js +66 -7
- package/dist/src/browser-runner.js +1 -2
- package/dist/src/browser-server.js +10 -2
- package/dist/src/browser-session.js +6 -2
- package/dist/src/browser-stealth.d.ts +29 -0
- package/dist/src/browser-stealth.js +166 -0
- package/dist/src/browser-ui/app.js +108 -13
- package/dist/src/browser-ui/icons/chevron-right.svg +8 -0
- package/dist/src/browser-ui/index.html +8 -8
- package/dist/src/browser-ui/style.css +199 -171
- package/dist/src/browser-ui/tokens.css +198 -0
- package/dist/src/browser-view.d.ts +57 -9
- package/dist/src/browser-view.js +187 -36
- package/dist/src/cli.js +21 -4
- package/dist/src/coding-tools.js +9 -5
- package/dist/src/command-screens.js +4 -4
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +2 -1
- package/dist/src/completion-gates.d.ts +35 -0
- package/dist/src/completion-gates.js +25 -0
- package/dist/src/completion.d.ts +6 -0
- package/dist/src/completion.js +36 -3
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +2 -2
- package/dist/src/context-budget.d.ts +11 -0
- package/dist/src/context-budget.js +13 -0
- package/dist/src/decision/DecisionEngine.d.ts +5 -1
- package/dist/src/decision/DecisionManager.d.ts +1 -0
- package/dist/src/decision/DecisionManager.js +14 -3
- package/dist/src/decision/FactContinuations.d.ts +6 -0
- package/dist/src/decision/FactContinuations.js +9 -1
- package/dist/src/decision/FactServiceGate.js +1 -1
- package/dist/src/decision/hostedSkills.d.ts +37 -0
- package/dist/src/decision/hostedSkills.js +64 -0
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +10 -2
- package/dist/src/decision/providers/AndorraDecisionProvider.js +121 -10
- package/dist/src/default-graph.d.ts +11 -0
- package/dist/src/default-graph.js +20 -0
- package/dist/src/duration.d.ts +13 -2
- package/dist/src/duration.js +27 -3
- package/dist/src/graph-manager-chat.d.ts +302 -0
- package/dist/src/graph-manager-chat.js +940 -0
- package/dist/src/graph-runner.js +6 -0
- package/dist/src/graph-server.d.ts +9 -0
- package/dist/src/graph-server.js +167 -16
- package/dist/src/graph-studio-features.js +2 -2
- package/dist/src/graph-sync.js +5 -2
- package/dist/src/graph-ui/app.js +252 -71
- package/dist/src/graph-ui/controls.css +55 -32
- package/dist/src/graph-ui/controls.js +85 -9
- package/dist/src/graph-ui/edge-router.js +114 -13
- package/dist/src/graph-ui/embed.js +23 -8
- package/dist/src/graph-ui/index.html +3 -3
- package/dist/src/graph-ui/library.css +4 -10
- package/dist/src/graph-ui/manager-markdown.js +155 -0
- package/dist/src/graph-ui/manager-state.js +191 -0
- package/dist/src/graph-ui/manager.css +161 -0
- package/dist/src/graph-ui/manager.js +700 -0
- package/dist/src/graph-ui/studio-canvas.js +2 -0
- package/dist/src/graph-ui/studio.css +24 -23
- package/dist/src/graph-ui/studio.js +29 -8
- package/dist/src/graph-ui/style.css +125 -92
- package/dist/src/graph-ui/tokens.css +217 -151
- package/dist/src/graphs.d.ts +69 -1
- package/dist/src/graphs.js +160 -7
- package/dist/src/hardened-runtime.js +8 -2
- package/dist/src/membership-errors.d.ts +14 -0
- package/dist/src/membership-errors.js +24 -1
- package/dist/src/membership.d.ts +20 -0
- package/dist/src/membership.js +45 -16
- package/dist/src/palette.d.ts +25 -8
- package/dist/src/palette.js +26 -8
- package/dist/src/provider-engine.d.ts +4 -4
- package/dist/src/provider-engine.js +39 -22
- package/dist/src/providers.d.ts +24 -0
- package/dist/src/providers.js +47 -2
- package/dist/src/qa/guidance.d.ts +26 -0
- package/dist/src/qa/guidance.js +59 -0
- package/dist/src/qa/index.d.ts +1 -6
- package/dist/src/qa/index.js +1 -14
- package/dist/src/qa/runtime/ProcessManager.d.ts +20 -2
- package/dist/src/qa/runtime/ProcessManager.js +69 -13
- package/dist/src/react-runtime.d.ts +11 -0
- package/dist/src/react-runtime.js +190 -51
- package/dist/src/remote/engine-pool.js +4 -1
- package/dist/src/run-progress.d.ts +6 -0
- package/dist/src/run-progress.js +7 -0
- package/dist/src/runtime.d.ts +8 -0
- package/dist/src/session-skills.d.ts +75 -0
- package/dist/src/session-skills.js +151 -0
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +6 -12
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/control-browser/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +8 -0
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/skills/bundled/web-gui-tester/SKILL.md +1 -1
- package/dist/src/stall-recovery.d.ts +22 -0
- package/dist/src/stall-recovery.js +71 -0
- package/dist/src/subagent-run.js +1 -2
- package/dist/src/terminal-ui.d.ts +2 -2
- package/dist/src/terminal-ui.js +18 -13
- package/dist/src/transcript.js +9 -1
- package/dist/src/types.d.ts +18 -4
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +55 -15
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/limits.md +9 -0
- package/docs/guides/desktop-app.md +1 -1
- package/docs/guides/graph-builder.md +16 -1
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +203 -0
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +79 -0
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +182 -0
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +156 -0
- package/package.json +1 -1
- package/tests/chat-side-panel-test-plan.md +1 -1
|
@@ -12,12 +12,12 @@ export function isEngineContextOverflow(errorMessage) {
|
|
|
12
12
|
model: '', timestamp: 0, usage: emptyUsage(), stopReason: 'error', errorMessage });
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Move the serializer's conversation breakpoint off the trailing
|
|
15
|
+
* Move the serializer's conversation breakpoint off the trailing messages a later request rewrites.
|
|
16
16
|
*
|
|
17
17
|
* Anthropic writes a cache entry only at a marked block, and the vendored serializer marks the
|
|
18
|
-
* final message.
|
|
19
|
-
* request
|
|
20
|
-
*
|
|
18
|
+
* final message. When that message is transient guidance, the entry would end at a message the
|
|
19
|
+
* next request replaces, so no prefix of the next request ever matches it and the whole history
|
|
20
|
+
* is re-written every turn. Marking the last committed message instead lets
|
|
21
21
|
* the next request find that entry by looking back from its own breakpoint.
|
|
22
22
|
*/
|
|
23
23
|
export function relocateConversationBreakpoint(body, mutableTail) {
|
|
@@ -269,27 +269,35 @@ export async function generateEngineResponse(request, host) {
|
|
|
269
269
|
ledger(message.usage);
|
|
270
270
|
};
|
|
271
271
|
// No provider SDK authentication/environment discovery: Andorra's send() owns credentials.
|
|
272
|
+
const sendWithFallbacks = async (body) => {
|
|
273
|
+
try {
|
|
274
|
+
return await host.send(body);
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
const status = error.status;
|
|
278
|
+
if (status !== 400 && status !== 422)
|
|
279
|
+
throw error;
|
|
280
|
+
// A required tool choice is a recovery hint, never a reason to fail the request: a server
|
|
281
|
+
// that does not support it (no guided decoding, an older API) gets the same request without it.
|
|
282
|
+
if (body.tool_choice !== undefined) {
|
|
283
|
+
const { tool_choice: _choice, ...unforced } = body;
|
|
284
|
+
return sendWithFallbacks(unforced);
|
|
285
|
+
}
|
|
286
|
+
// Only replay when the failed request was actually streamed. Once the host has
|
|
287
|
+
// already forced whole-body mode, a 400/422 is a real provider rejection and a
|
|
288
|
+
// second identical request would only double-count the failure.
|
|
289
|
+
if (host.streamingDisabled?.())
|
|
290
|
+
throw error;
|
|
291
|
+
// A compatibility endpoint may reject streaming. Retry only this inference,
|
|
292
|
+
// never any completed tools, and account for both requests in the host.
|
|
293
|
+
const { stream_options: _options, ...plain } = body;
|
|
294
|
+
return host.send({ ...plain, stream: false });
|
|
295
|
+
}
|
|
296
|
+
};
|
|
272
297
|
const nativeFetch = async (_url, init) => {
|
|
273
298
|
try {
|
|
274
299
|
const body = JSON.parse(String(init?.body));
|
|
275
|
-
|
|
276
|
-
try {
|
|
277
|
-
response = await host.send(body);
|
|
278
|
-
}
|
|
279
|
-
catch (error) {
|
|
280
|
-
const status = error.status;
|
|
281
|
-
if (status !== 400 && status !== 422)
|
|
282
|
-
throw error;
|
|
283
|
-
// Only replay when the failed request was actually streamed. Once the host has
|
|
284
|
-
// already forced whole-body mode, a 400/422 is a real provider rejection and a
|
|
285
|
-
// second identical request would only double-count the failure.
|
|
286
|
-
if (host.streamingDisabled?.())
|
|
287
|
-
throw error;
|
|
288
|
-
// A compatibility endpoint may reject streaming. Retry only this inference,
|
|
289
|
-
// never any completed tools, and account for both requests in the host.
|
|
290
|
-
const { stream_options: _options, ...plain } = body;
|
|
291
|
-
response = await host.send({ ...plain, stream: false });
|
|
292
|
-
}
|
|
300
|
+
const response = await sendWithFallbacks(body);
|
|
293
301
|
if (/text\/event-stream/i.test(response.headers.get('content-type') ?? '')) {
|
|
294
302
|
if (!response.body)
|
|
295
303
|
throw new Error('Provider returned a malformed response.');
|
|
@@ -437,6 +445,15 @@ export async function generateEngineResponse(request, host) {
|
|
|
437
445
|
}
|
|
438
446
|
}
|
|
439
447
|
}
|
|
448
|
+
if (request.toolChoice === 'required' && Array.isArray(body.tools) && body.tools.length) {
|
|
449
|
+
// Anthropic refuses a forced tool choice while extended thinking is on; that request goes
|
|
450
|
+
// out unforced rather than failing.
|
|
451
|
+
const thinking = body.thinking;
|
|
452
|
+
if (!host.anthropic)
|
|
453
|
+
body.tool_choice = 'required';
|
|
454
|
+
else if (thinking === undefined || thinking.type === 'disabled')
|
|
455
|
+
body.tool_choice = { type: 'any' };
|
|
456
|
+
}
|
|
440
457
|
return body;
|
|
441
458
|
},
|
|
442
459
|
});
|
package/dist/src/providers.d.ts
CHANGED
|
@@ -227,6 +227,30 @@ export declare class ProviderRequestError extends Error {
|
|
|
227
227
|
*/
|
|
228
228
|
constructor(message: string, contextOverflow?: boolean);
|
|
229
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* How much blank tool-call output a stream may carry in a row before it is abandoned: whitespace
|
|
232
|
+
* characters in a call's arguments, plus one for every tool-call fragment that adds nothing.
|
|
233
|
+
*
|
|
234
|
+
* A model sometimes opens a tool call and then generates whitespace until the provider's output
|
|
235
|
+
* cap stops it. On DeepSeek V4.1 Flash that was 131,072 completion tokens over eight minutes for a
|
|
236
|
+
* call whose arguments arrived empty, about once in three thousand requests, and it was 16% of
|
|
237
|
+
* all output in a 90-task SWE-bench run. Real arguments never hold this much consecutive
|
|
238
|
+
* whitespace: line breaks inside a JSON string are escaped, and indentation between tokens is a
|
|
239
|
+
* few characters. The stream is cut here and the request replayed, which is safe because no tool
|
|
240
|
+
* from the abandoned response ran.
|
|
241
|
+
*/
|
|
242
|
+
export declare const BLANK_TOOL_CALL_LIMIT = 4096;
|
|
243
|
+
/**
|
|
244
|
+
* Counts consecutive blank tool-call output across a stream and throws once it passes
|
|
245
|
+
* {@link BLANK_TOOL_CALL_LIMIT}. Anything the model visibly produces (argument text, a tool
|
|
246
|
+
* name, answer text, reasoning) ends the run of blanks.
|
|
247
|
+
*/
|
|
248
|
+
export declare function createBlankToolCallGuard(limit?: number): {
|
|
249
|
+
/** One tool-call fragment's text: its name and argument pieces joined. */
|
|
250
|
+
fragment(text: string): void;
|
|
251
|
+
/** The model produced something other than a tool-call fragment. */
|
|
252
|
+
progress(): void;
|
|
253
|
+
};
|
|
230
254
|
/**
|
|
231
255
|
* Measure a streamed response's decode time from when its fragments arrive.
|
|
232
256
|
*
|
package/dist/src/providers.js
CHANGED
|
@@ -330,6 +330,45 @@ class RetryableProviderError extends ProviderRequestError {
|
|
|
330
330
|
class MalformedStreamProviderError extends RetryableProviderError {
|
|
331
331
|
constructor() { super('Provider returned a malformed response.', 0, MALFORMED_STREAM_RETRY_DELAYS_MS); }
|
|
332
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* How much blank tool-call output a stream may carry in a row before it is abandoned: whitespace
|
|
335
|
+
* characters in a call's arguments, plus one for every tool-call fragment that adds nothing.
|
|
336
|
+
*
|
|
337
|
+
* A model sometimes opens a tool call and then generates whitespace until the provider's output
|
|
338
|
+
* cap stops it. On DeepSeek V4.1 Flash that was 131,072 completion tokens over eight minutes for a
|
|
339
|
+
* call whose arguments arrived empty, about once in three thousand requests, and it was 16% of
|
|
340
|
+
* all output in a 90-task SWE-bench run. Real arguments never hold this much consecutive
|
|
341
|
+
* whitespace: line breaks inside a JSON string are escaped, and indentation between tokens is a
|
|
342
|
+
* few characters. The stream is cut here and the request replayed, which is safe because no tool
|
|
343
|
+
* from the abandoned response ran.
|
|
344
|
+
*/
|
|
345
|
+
export const BLANK_TOOL_CALL_LIMIT = 4096;
|
|
346
|
+
/** A stream abandoned because a tool call kept generating blank output; replayed like a malformed one. */
|
|
347
|
+
class BlankToolCallProviderError extends RetryableProviderError {
|
|
348
|
+
constructor() { super('Provider streamed a tool call that kept generating blank output.', 0, MALFORMED_STREAM_RETRY_DELAYS_MS); }
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Counts consecutive blank tool-call output across a stream and throws once it passes
|
|
352
|
+
* {@link BLANK_TOOL_CALL_LIMIT}. Anything the model visibly produces (argument text, a tool
|
|
353
|
+
* name, answer text, reasoning) ends the run of blanks.
|
|
354
|
+
*/
|
|
355
|
+
export function createBlankToolCallGuard(limit = BLANK_TOOL_CALL_LIMIT) {
|
|
356
|
+
let blank = 0;
|
|
357
|
+
return {
|
|
358
|
+
/** One tool-call fragment's text: its name and argument pieces joined. */
|
|
359
|
+
fragment(text) {
|
|
360
|
+
if (/\S/.test(text)) {
|
|
361
|
+
blank = 0;
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
blank += Math.max(1, text.length);
|
|
365
|
+
if (blank > limit)
|
|
366
|
+
throw new BlankToolCallProviderError();
|
|
367
|
+
},
|
|
368
|
+
/** The model produced something other than a tool-call fragment. */
|
|
369
|
+
progress() { blank = 0; },
|
|
370
|
+
};
|
|
371
|
+
}
|
|
333
372
|
/** A completed HTTP exchange the provider refused outright; `status` drives compatibility fallbacks. */
|
|
334
373
|
class HttpProviderError extends ProviderRequestError {
|
|
335
374
|
status;
|
|
@@ -626,6 +665,7 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
|
|
|
626
665
|
let content = '', refusal, reasoning = '', finishReason, chunkUsage;
|
|
627
666
|
let sawChoice = false, sawText = false;
|
|
628
667
|
const decode = createDecodeWindow(now);
|
|
668
|
+
const blankCalls = createBlankToolCallGuard();
|
|
629
669
|
const fragments = [];
|
|
630
670
|
const text = (value) => {
|
|
631
671
|
if (value == null)
|
|
@@ -689,8 +729,10 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
|
|
|
689
729
|
// reasoning_text, so a model that answers its reasoning through the other fields is still
|
|
690
730
|
// generating, and its window must open at that first fragment rather than at the answer.
|
|
691
731
|
const thinking = reasoningDelta || text(delta.reasoning) || text(delta.reasoning_text);
|
|
692
|
-
if (thinking)
|
|
732
|
+
if (thinking) {
|
|
693
733
|
stampOutput(thinking);
|
|
734
|
+
blankCalls.progress();
|
|
735
|
+
}
|
|
694
736
|
const contentDelta = text(delta.content);
|
|
695
737
|
// An empty content string still records the field's presence: the whole-body path
|
|
696
738
|
// distinguishes `content: ""` from `null`, and the streamed answer must keep that
|
|
@@ -701,6 +743,7 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
|
|
|
701
743
|
if (contentDelta) {
|
|
702
744
|
content += contentDelta;
|
|
703
745
|
stampOutput(contentDelta);
|
|
746
|
+
blankCalls.progress();
|
|
704
747
|
}
|
|
705
748
|
}
|
|
706
749
|
const refusalDelta = text(delta.refusal);
|
|
@@ -743,8 +786,10 @@ function createStreamAccumulator(onReasoning, now = Date.now) {
|
|
|
743
786
|
callText += fn.arguments;
|
|
744
787
|
}
|
|
745
788
|
}
|
|
746
|
-
if (delta.tool_calls.length > 0)
|
|
789
|
+
if (delta.tool_calls.length > 0) {
|
|
747
790
|
stampOutput(callText);
|
|
791
|
+
blankCalls.fragment(callText);
|
|
792
|
+
}
|
|
748
793
|
},
|
|
749
794
|
finish(requests, completionAdvertised) {
|
|
750
795
|
if (!sawChoice)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The QA section of an agent node's workspace guidance.
|
|
3
|
+
*
|
|
4
|
+
* It is written per node rather than once per run: a line naming a qa.* tool the node was not
|
|
5
|
+
* granted is an instruction it cannot follow, and a node that hands its change to a testing node
|
|
6
|
+
* must not be told to test the running app itself. Before this was per node, an implementation
|
|
7
|
+
* node with a QA node after it read "Frontend/UI changes additionally need qa.browser against a
|
|
8
|
+
* running app" and spent most of its turns scripting clicks and screenshots into the user's own
|
|
9
|
+
* window — the QA node's job, done without the QA node's tools.
|
|
10
|
+
*
|
|
11
|
+
* A leaf module, so the agent runtime can import it without loading the QA orchestrator.
|
|
12
|
+
*/
|
|
13
|
+
export interface QaGuidanceOptions {
|
|
14
|
+
/** The names of the tools this node holds; lines about a qa.* tool it lacks are left out. */
|
|
15
|
+
tools: Iterable<string>;
|
|
16
|
+
/**
|
|
17
|
+
* The name of a later node in the graph that tests the change in the running app. When set, the
|
|
18
|
+
* node is told to leave that testing to it instead of being told to drive the app itself.
|
|
19
|
+
*/
|
|
20
|
+
laterTester?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The QA guidance for one node, or the empty string for a node that holds
|
|
24
|
+
* no qa.* tool (an intake node, for example), which has nothing in it to follow.
|
|
25
|
+
*/
|
|
26
|
+
export declare function qaGuidance(options: QaGuidanceOptions): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The QA section of an agent node's workspace guidance.
|
|
3
|
+
*
|
|
4
|
+
* It is written per node rather than once per run: a line naming a qa.* tool the node was not
|
|
5
|
+
* granted is an instruction it cannot follow, and a node that hands its change to a testing node
|
|
6
|
+
* must not be told to test the running app itself. Before this was per node, an implementation
|
|
7
|
+
* node with a QA node after it read "Frontend/UI changes additionally need qa.browser against a
|
|
8
|
+
* running app" and spent most of its turns scripting clicks and screenshots into the user's own
|
|
9
|
+
* window — the QA node's job, done without the QA node's tools.
|
|
10
|
+
*
|
|
11
|
+
* A leaf module, so the agent runtime can import it without loading the QA orchestrator.
|
|
12
|
+
*/
|
|
13
|
+
/** The qa.* tools the guidance can name, in the order it names them. */
|
|
14
|
+
const QA_TOOLS = [
|
|
15
|
+
['qa.fast', 'lint + typecheck + related tests + diff/secret review'],
|
|
16
|
+
['qa.test', 'scoped unit runs: related/file/pattern/all'],
|
|
17
|
+
['qa.terminal', 'persistent PTY/ConPTY CLI/TUI interaction'],
|
|
18
|
+
['qa.browser', ''],
|
|
19
|
+
['qa.security', ''],
|
|
20
|
+
['qa.deep', 'merge gate'],
|
|
21
|
+
['qa.status', ''],
|
|
22
|
+
['qa.inspect_project', ''],
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* The QA guidance for one node, or the empty string for a node that holds
|
|
26
|
+
* no qa.* tool (an intake node, for example), which has nothing in it to follow.
|
|
27
|
+
*/
|
|
28
|
+
export function qaGuidance(options) {
|
|
29
|
+
const held = new Set(options.tools);
|
|
30
|
+
const tools = QA_TOOLS.filter(([name]) => held.has(name));
|
|
31
|
+
if (tools.length === 0)
|
|
32
|
+
return '';
|
|
33
|
+
const has = (name) => held.has(name);
|
|
34
|
+
const tester = options.laterTester;
|
|
35
|
+
const lines = [
|
|
36
|
+
`- Use the qa.* tools for quality checks instead of ad-hoc shell when they fit: ${tools.map(([name, description]) => description ? `${name} (${description})` : name).join(', ')}.`,
|
|
37
|
+
];
|
|
38
|
+
if (has('qa.fast'))
|
|
39
|
+
lines.push(`- After you edit code, run qa.fast before claiming the change works; when a check fails, fix it and re-run the narrowest check${has('qa.test') ? ' (qa.test related/file/pattern)' : ''} before the full qa.fast.`);
|
|
40
|
+
if (tester !== undefined) {
|
|
41
|
+
lines.push(`- ${JSON.stringify(tester)} runs after this node and tests the change in the running app. Do not launch, click through, type into or screenshot the app yourself, and do not script keyboard or mouse input into any window: build the change, run the checks that cover it, and hand ${JSON.stringify(tester)} what it needs to test.`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (has('qa.terminal'))
|
|
45
|
+
lines.push('- CLI/TUI behavior should be smoke-tested with qa.terminal: spawn the app once, drive it with write/key, and use event-driven wait with short 5-15 second expectations. Do not emulate interactive testing with Start-Process plus redirected logs and Start-Sleep polling.');
|
|
46
|
+
if (has('qa.browser'))
|
|
47
|
+
lines.push('- Frontend/UI changes additionally need qa.browser against a running app.');
|
|
48
|
+
}
|
|
49
|
+
if (has('qa.security'))
|
|
50
|
+
lines.push('- Security-sensitive or dependency changes need qa.security. Treat a secret-scan finding as a hard blocker: rotate and remove the secret, never commit it.');
|
|
51
|
+
// The merge gate adds browser checks and runtime smoke runs for the change it classifies, which
|
|
52
|
+
// is the testing a later tester owns.
|
|
53
|
+
if (has('qa.deep') && tester === undefined)
|
|
54
|
+
lines.push('- Before declaring feature work complete, run qa.deep; report the gate verdict. If a required check is blocked, say so plainly instead of calling the work verified.');
|
|
55
|
+
if (has('qa.status'))
|
|
56
|
+
lines.push('- Checks are remembered per session: qa.status shows stale results after later edits.');
|
|
57
|
+
lines.push('- Commands classified destructive (e.g. recursive deletes of system paths) are denied in every mode, including yolo.', '- On Windows, run foreground child commands directly with PowerShell\'s invocation operator (for example `& $exe @args`) instead of wrapping them in `Start-Job` just to impose a timeout; the shell tool already owns timeout and process-tree cleanup. Avoid `Start-Process -ArgumentList @(…)` for multi-word arguments unless you quote them explicitly, because Windows PowerShell flattens the array before launching the child.', '- Full logs live under .andorra/runtime/qa/<run-id>/ (referenced by logRef); read them with Read when the summary is not enough.');
|
|
58
|
+
return `QA tooling:\n${lines.join('\n')}`;
|
|
59
|
+
}
|
package/dist/src/qa/index.d.ts
CHANGED
|
@@ -4,9 +4,4 @@ export { disposeAllQaProcesses, getQaProcessManager, listQaProcesses, stopQaProc
|
|
|
4
4
|
export { disposeAllQaPtys, getQaPtyManager, listQaPtys, stopQaPty } from './runtime/PtyManager.js';
|
|
5
5
|
export { onBackgroundChange } from './runtime/changes.js';
|
|
6
6
|
export { detectRuntimeCapabilities } from './runtime-detect.js';
|
|
7
|
-
|
|
8
|
-
* The QA section appended to workspace guidance. Keeps the model's QA loop
|
|
9
|
-
* (verify after every edit, targeted re-runs, merge gate) explicit without
|
|
10
|
-
* pulling tool JSON schemas into the prompt.
|
|
11
|
-
*/
|
|
12
|
-
export declare const QA_SYSTEM_GUIDANCE = "\nQA tooling:\n- Use the qa.* tools for quality checks instead of ad-hoc shell when they fit: qa.fast (lint + typecheck + related tests + diff/secret review), qa.test (scoped unit runs: related/file/pattern/all), qa.terminal (persistent PTY/ConPTY CLI/TUI interaction), qa.browser, qa.security, qa.deep (merge gate), qa.status, qa.inspect_project.\n- After you edit code, run qa.fast before claiming the change works; when a check fails, fix it and re-run the narrowest check (qa.test related/file/pattern) before the full qa.fast.\n- CLI/TUI behavior should be smoke-tested with qa.terminal: spawn the app once, drive it with write/key, and use event-driven wait with short 5-15 second expectations. Do not emulate interactive testing with Start-Process plus redirected logs and Start-Sleep polling.\n- Frontend/UI changes additionally need qa.browser against a running app; security-sensitive or dependency changes need qa.security. Treat a secret-scan finding as a hard blocker: rotate and remove the secret, never commit it.\n- Before declaring feature work complete, run qa.deep; report the gate verdict. If a required check is blocked, say so plainly instead of calling the work verified.\n- Checks are remembered per session: qa.status shows stale results after later edits. Commands classified destructive (e.g. recursive deletes of system paths) are denied in every mode, including yolo.\n- On Windows, run foreground child commands directly with PowerShell's invocation operator (for example `& $exe @args`) instead of wrapping them in `Start-Job` just to impose a timeout; the shell tool already owns timeout and process-tree cleanup. Avoid `Start-Process -ArgumentList @(\u2026)` for multi-word arguments unless you quote them explicitly, because Windows PowerShell flattens the array before launching the child.\n- Full logs live under .andorra/runtime/qa/<run-id>/ (referenced by logRef); read them with Read when the summary is not enough.";
|
|
7
|
+
export { qaGuidance, type QaGuidanceOptions } from './guidance.js';
|
package/dist/src/qa/index.js
CHANGED
|
@@ -4,17 +4,4 @@ export { disposeAllQaProcesses, getQaProcessManager, listQaProcesses, stopQaProc
|
|
|
4
4
|
export { disposeAllQaPtys, getQaPtyManager, listQaPtys, stopQaPty } from './runtime/PtyManager.js';
|
|
5
5
|
export { onBackgroundChange } from './runtime/changes.js';
|
|
6
6
|
export { detectRuntimeCapabilities } from './runtime-detect.js';
|
|
7
|
-
|
|
8
|
-
* The QA section appended to workspace guidance. Keeps the model's QA loop
|
|
9
|
-
* (verify after every edit, targeted re-runs, merge gate) explicit without
|
|
10
|
-
* pulling tool JSON schemas into the prompt.
|
|
11
|
-
*/
|
|
12
|
-
export const QA_SYSTEM_GUIDANCE = `
|
|
13
|
-
QA tooling:
|
|
14
|
-
- Use the qa.* tools for quality checks instead of ad-hoc shell when they fit: qa.fast (lint + typecheck + related tests + diff/secret review), qa.test (scoped unit runs: related/file/pattern/all), qa.terminal (persistent PTY/ConPTY CLI/TUI interaction), qa.browser, qa.security, qa.deep (merge gate), qa.status, qa.inspect_project.
|
|
15
|
-
- After you edit code, run qa.fast before claiming the change works; when a check fails, fix it and re-run the narrowest check (qa.test related/file/pattern) before the full qa.fast.
|
|
16
|
-
- CLI/TUI behavior should be smoke-tested with qa.terminal: spawn the app once, drive it with write/key, and use event-driven wait with short 5-15 second expectations. Do not emulate interactive testing with Start-Process plus redirected logs and Start-Sleep polling.\n- Frontend/UI changes additionally need qa.browser against a running app; security-sensitive or dependency changes need qa.security. Treat a secret-scan finding as a hard blocker: rotate and remove the secret, never commit it.
|
|
17
|
-
- Before declaring feature work complete, run qa.deep; report the gate verdict. If a required check is blocked, say so plainly instead of calling the work verified.
|
|
18
|
-
- Checks are remembered per session: qa.status shows stale results after later edits. Commands classified destructive (e.g. recursive deletes of system paths) are denied in every mode, including yolo.
|
|
19
|
-
- On Windows, run foreground child commands directly with PowerShell's invocation operator (for example \`& $exe @args\`) instead of wrapping them in \`Start-Job\` just to impose a timeout; the shell tool already owns timeout and process-tree cleanup. Avoid \`Start-Process -ArgumentList @(…)\` for multi-word arguments unless you quote them explicitly, because Windows PowerShell flattens the array before launching the child.
|
|
20
|
-
- Full logs live under .andorra/runtime/qa/<run-id>/ (referenced by logRef); read them with Read when the summary is not enough.`;
|
|
7
|
+
export { qaGuidance } from './guidance.js';
|
|
@@ -10,12 +10,26 @@ export interface ManagedProcessInfo {
|
|
|
10
10
|
/** Epoch milliseconds the process was spawned and, once it has, exited; lets a surface show how long it ran. */
|
|
11
11
|
startedAt: number;
|
|
12
12
|
endedAt?: number;
|
|
13
|
+
/** Started to outlive the CLI: shutdown leaves it running. */
|
|
14
|
+
persistent?: boolean;
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Whether a job can be started to outlive the CLI. Not on Windows: there the PowerShell wrapper
|
|
18
|
+
* carries the command's output through its own pipeline, so the command dies with the wrapper, and
|
|
19
|
+
* a detached PowerShell exits before running the command at all.
|
|
20
|
+
*/
|
|
21
|
+
export declare const PERSISTENT_JOBS_SUPPORTED: boolean;
|
|
14
22
|
/**
|
|
15
23
|
* Long-lived QA processes (dev servers) owned by the CLI session. Logs stay on
|
|
16
24
|
* disk plus a bounded in-memory tail; every process inherits the shell
|
|
17
25
|
* credential-allowlist environment and is tree-killed on stop, including when
|
|
18
26
|
* the CLI exits.
|
|
27
|
+
*
|
|
28
|
+
* A persistent process is the exception at exit: it is a service the user asked to have left
|
|
29
|
+
* running (a web server the task sets up), so CLI shutdown leaves it alone. It writes straight to
|
|
30
|
+
* its log file rather than through pipes, because a pipe to a CLI that has exited would end it on
|
|
31
|
+
* its next write, and it is unreferenced (and, like every job, in its own process group) so the CLI
|
|
32
|
+
* can exit while it runs. An explicit stop and the removal of its workspace still end it.
|
|
19
33
|
*/
|
|
20
34
|
export declare class QaProcessManager {
|
|
21
35
|
private readonly workspace;
|
|
@@ -28,6 +42,7 @@ export declare class QaProcessManager {
|
|
|
28
42
|
logDir?: string;
|
|
29
43
|
launchPolicy?: () => ShellSandbox | undefined;
|
|
30
44
|
signal?: AbortSignal;
|
|
45
|
+
persist?: boolean;
|
|
31
46
|
}): Promise<ManagedProcessInfo>;
|
|
32
47
|
private validateStart;
|
|
33
48
|
private info;
|
|
@@ -47,7 +62,10 @@ export declare class QaProcessManager {
|
|
|
47
62
|
/** Event-driven completion wait; an unfinished job returns running instead of polling. */
|
|
48
63
|
wait(id: string, timeoutMs: number, signal: AbortSignal): Promise<ManagedProcessInfo>;
|
|
49
64
|
stop(id: string): Promise<void>;
|
|
50
|
-
|
|
65
|
+
/** `keepPersistent` is CLI shutdown: a job started to outlive the CLI is left running and forgotten. */
|
|
66
|
+
stopAll(options?: {
|
|
67
|
+
keepPersistent?: boolean;
|
|
68
|
+
}): Promise<void>;
|
|
51
69
|
}
|
|
52
70
|
export declare function defaultQaProcessesDir(workspace: string): string;
|
|
53
71
|
/** One process manager per workspace, retained for the life of the CLI. */
|
|
@@ -65,5 +83,5 @@ export declare function stopQaProcess(workspace: string, id: string): Promise<bo
|
|
|
65
83
|
* keeps its listeners, and on Windows keeps the folder from being removed. Never throws.
|
|
66
84
|
*/
|
|
67
85
|
export declare function stopQaProcessesUnder(root: string): Promise<void>;
|
|
68
|
-
/** CLI shutdown hook: kill every QA-owned background process. */
|
|
86
|
+
/** CLI shutdown hook: kill every QA-owned background process except those started to persist. */
|
|
69
87
|
export declare function disposeAllQaProcesses(): Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import net from 'node:net';
|
|
4
|
+
import { closeSync, openSync, readSync, fstatSync } from 'node:fs';
|
|
4
5
|
import { mkdir, appendFile } from 'node:fs/promises';
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
import { defaultShellKind, shellBaseEnv, shellInvocation, stopProcessTree } from '../../shell.js';
|
|
@@ -8,11 +9,23 @@ import { recordCommandTiming } from '../../command-metrics.js';
|
|
|
8
9
|
import { notifyBackgroundChange } from './changes.js';
|
|
9
10
|
const LOG_CAP_BYTES = 262_144;
|
|
10
11
|
const POLL_INTERVAL_MS = 500;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a job can be started to outlive the CLI. Not on Windows: there the PowerShell wrapper
|
|
14
|
+
* carries the command's output through its own pipeline, so the command dies with the wrapper, and
|
|
15
|
+
* a detached PowerShell exits before running the command at all.
|
|
16
|
+
*/
|
|
17
|
+
export const PERSISTENT_JOBS_SUPPORTED = process.platform !== 'win32';
|
|
11
18
|
/**
|
|
12
19
|
* Long-lived QA processes (dev servers) owned by the CLI session. Logs stay on
|
|
13
20
|
* disk plus a bounded in-memory tail; every process inherits the shell
|
|
14
21
|
* credential-allowlist environment and is tree-killed on stop, including when
|
|
15
22
|
* the CLI exits.
|
|
23
|
+
*
|
|
24
|
+
* A persistent process is the exception at exit: it is a service the user asked to have left
|
|
25
|
+
* running (a web server the task sets up), so CLI shutdown leaves it alone. It writes straight to
|
|
26
|
+
* its log file rather than through pipes, because a pipe to a CLI that has exited would end it on
|
|
27
|
+
* its next write, and it is unreferenced (and, like every job, in its own process group) so the CLI
|
|
28
|
+
* can exit while it runs. An explicit stop and the removal of its workspace still end it.
|
|
16
29
|
*/
|
|
17
30
|
export class QaProcessManager {
|
|
18
31
|
workspace;
|
|
@@ -25,6 +38,8 @@ export class QaProcessManager {
|
|
|
25
38
|
async start(options) {
|
|
26
39
|
options.signal?.throwIfAborted();
|
|
27
40
|
this.validateStart(options);
|
|
41
|
+
if (options.persist && !PERSISTENT_JOBS_SUPPORTED)
|
|
42
|
+
throw new Error('persist is not supported on Windows: a background job ends when the CLI exits.');
|
|
28
43
|
await this.stop(options.id);
|
|
29
44
|
options.signal?.throwIfAborted();
|
|
30
45
|
const runId = randomUUID();
|
|
@@ -38,15 +53,29 @@ export class QaProcessManager {
|
|
|
38
53
|
options.signal?.throwIfAborted();
|
|
39
54
|
if (options.launchPolicy?.())
|
|
40
55
|
throw new Error('Background command requires Full Access or explicit escalation; restricted execution is unavailable.');
|
|
56
|
+
const persistent = options.persist === true;
|
|
57
|
+
// Synchronous, so nothing yields between the guards above and the spawn below.
|
|
58
|
+
const logFd = persistent ? openSync(logPath, 'a') : undefined;
|
|
41
59
|
const spawnedAt = Date.now();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
let child;
|
|
61
|
+
try {
|
|
62
|
+
child = spawn(invocation.executable, invocation.args, {
|
|
63
|
+
cwd: this.workspace,
|
|
64
|
+
env: shellBaseEnv(runId),
|
|
65
|
+
windowsHide: true,
|
|
66
|
+
detached: process.platform !== 'win32',
|
|
67
|
+
stdio: logFd === undefined ? ['ignore', 'pipe', 'pipe'] : ['ignore', logFd, logFd],
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
// The child holds its own copy of the descriptor.
|
|
72
|
+
if (logFd !== undefined)
|
|
73
|
+
closeSync(logFd);
|
|
74
|
+
}
|
|
75
|
+
// Nothing of the CLI's keeps a persistent job alive or waits for it.
|
|
76
|
+
if (persistent)
|
|
77
|
+
child.unref();
|
|
78
|
+
const record = { id: options.id, command: options.command, child, runId, logPath, chunks: [], bytes: 0, exited: undefined, startedAt: spawnedAt, persistent };
|
|
50
79
|
this.processes.set(options.id, record);
|
|
51
80
|
for (const stream of [child.stdout, child.stderr]) {
|
|
52
81
|
stream?.on('data', (chunk) => {
|
|
@@ -88,6 +117,7 @@ export class QaProcessManager {
|
|
|
88
117
|
logRef: path.relative(this.workspace, record.logPath).split(path.sep).join('/'),
|
|
89
118
|
startedAt: record.startedAt,
|
|
90
119
|
...(record.endedAt === undefined ? {} : { endedAt: record.endedAt }),
|
|
120
|
+
...(record.persistent ? { persistent: true } : {}),
|
|
91
121
|
};
|
|
92
122
|
}
|
|
93
123
|
get(id) {
|
|
@@ -102,7 +132,8 @@ export class QaProcessManager {
|
|
|
102
132
|
const record = this.processes.get(id);
|
|
103
133
|
if (!record)
|
|
104
134
|
throw new Error(`no QA process named "${id}"`);
|
|
105
|
-
|
|
135
|
+
// A persistent job writes to its log file directly, so the tail comes from there.
|
|
136
|
+
const text = record.persistent ? readTail(record.logPath, tailBytes) : Buffer.concat(record.chunks).toString('utf8');
|
|
106
137
|
const tail = text.length > tailBytes ? text.slice(-tailBytes) : text;
|
|
107
138
|
const status = record.exited ? `\n[process exited code=${record.exited.code ?? record.exited.signal}${record.spawnError ? ` error=${record.spawnError}` : ''}]` : '';
|
|
108
139
|
return `${tail}${status}`;
|
|
@@ -193,9 +224,34 @@ export class QaProcessManager {
|
|
|
193
224
|
}
|
|
194
225
|
catch { /* already gone */ }
|
|
195
226
|
}
|
|
196
|
-
|
|
197
|
-
|
|
227
|
+
/** `keepPersistent` is CLI shutdown: a job started to outlive the CLI is left running and forgotten. */
|
|
228
|
+
async stopAll(options = {}) {
|
|
229
|
+
for (const [id, record] of [...this.processes]) {
|
|
230
|
+
if (options.keepPersistent && record.persistent) {
|
|
231
|
+
this.processes.delete(id);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
198
234
|
await this.stop(id);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** The last `bytes` of a log file, read without loading the rest; empty when it cannot be read. */
|
|
239
|
+
function readTail(file, bytes) {
|
|
240
|
+
let fd;
|
|
241
|
+
try {
|
|
242
|
+
fd = openSync(file, 'r');
|
|
243
|
+
const size = fstatSync(fd).size;
|
|
244
|
+
const length = Math.min(size, bytes);
|
|
245
|
+
const buffer = Buffer.alloc(length);
|
|
246
|
+
readSync(fd, buffer, 0, length, size - length);
|
|
247
|
+
return buffer.toString('utf8');
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return '';
|
|
251
|
+
}
|
|
252
|
+
finally {
|
|
253
|
+
if (fd !== undefined)
|
|
254
|
+
closeSync(fd);
|
|
199
255
|
}
|
|
200
256
|
}
|
|
201
257
|
function sleep(ms) {
|
|
@@ -252,9 +308,9 @@ export async function stopQaProcessesUnder(root) {
|
|
|
252
308
|
managers.delete(workspace);
|
|
253
309
|
await Promise.all(owned.map(([, manager]) => manager.stopAll().catch(() => { })));
|
|
254
310
|
}
|
|
255
|
-
/** CLI shutdown hook: kill every QA-owned background process. */
|
|
311
|
+
/** CLI shutdown hook: kill every QA-owned background process except those started to persist. */
|
|
256
312
|
export async function disposeAllQaProcesses() {
|
|
257
313
|
const managersSnapshot = [...managers.values()];
|
|
258
314
|
managers.clear();
|
|
259
|
-
await Promise.all(managersSnapshot.map(manager => manager.stopAll()));
|
|
315
|
+
await Promise.all(managersSnapshot.map(manager => manager.stopAll({ keepPersistent: true })));
|
|
260
316
|
}
|
|
@@ -40,6 +40,17 @@ export interface HardenedRunOptions extends RunOptions {
|
|
|
40
40
|
beforeToolCall?: (context: BeforeToolCallContext, signal: AbortSignal) => Promise<BeforeToolCallResult | undefined>;
|
|
41
41
|
afterToolCall?: (context: AfterToolCallContext, signal: AbortSignal) => Promise<AfterToolCallResult | undefined>;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Told to every agent that holds the todo list: a plan update rides in a batch that does work.
|
|
45
|
+
*
|
|
46
|
+
* A request that carries only update_todos re-reads the whole conversation and thinks again to
|
|
47
|
+
* move a status. On Andorra Code 0.1.8 (DeepSeek V4.1 Flash, Jev off) 116 of 303 plan updates in
|
|
48
|
+
* 90 SWE-bench runs and 110 of 229 in 62 Terminal-Bench runs were sent alone, 95 of them as the
|
|
49
|
+
* last request before complete_agent, and none beside it: 4.5% and 7.9% of all output tokens. The
|
|
50
|
+
* host has accepted update_todos beside complete_agent since the final-answer gates; nothing told
|
|
51
|
+
* the model so.
|
|
52
|
+
*/
|
|
53
|
+
export declare const TODO_BATCHING_GUIDANCE = "A plan update never needs a turn of its own: send update_todos in the same batch as the tool calls that do the next work, and send the last one, with the true final statuses, in the same batch as complete_agent, which is the one call allowed beside it.";
|
|
43
54
|
/**
|
|
44
55
|
* One engine for all reasoning nodes. The copied agent owns turn scheduling, tool
|
|
45
56
|
* batches and session state; these hooks enforce Andorra's graph contracts.
|