@koda-sl/baker-bridge 0.154.0-dev.eb1bb1bf7 → 0.154.0
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 +1 -13
- package/dist/hono/agent.d.ts.map +1 -1
- package/dist/hono/agent.js +1 -3
- package/dist/hono/agent.js.map +1 -1
- package/dist/hono/agent.test.js +0 -24
- package/dist/hono/agent.test.js.map +1 -1
- package/dist/hono/bridge-job.d.ts +1 -5
- package/dist/hono/bridge-job.d.ts.map +1 -1
- package/dist/hono/bridge-job.js +1 -2
- package/dist/hono/bridge-job.js.map +1 -1
- package/dist/hono/publish-handoff.d.ts +1 -12
- package/dist/hono/publish-handoff.d.ts.map +1 -1
- package/dist/hono/publish-handoff.js +0 -86
- package/dist/hono/publish-handoff.js.map +1 -1
- package/dist/hono/publish-handoff.test.js +1 -76
- package/dist/hono/publish-handoff.test.js.map +1 -1
- package/dist/hono/types.d.ts +0 -26
- package/dist/hono/types.d.ts.map +1 -1
- package/dist/review/digest.d.ts +10 -1
- package/dist/review/digest.d.ts.map +1 -1
- package/dist/review/digest.js +223 -36
- package/dist/review/digest.js.map +1 -1
- package/dist/review/digest.test.js +109 -0
- package/dist/review/digest.test.js.map +1 -1
- package/dist/review/evidence.d.ts.map +1 -1
- package/dist/review/evidence.js +1 -1
- package/dist/review/evidence.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { publishLanguageReminder, publishRunReminder
|
|
2
|
+
import { publishLanguageReminder, publishRunReminder } from "./publish-handoff.js";
|
|
3
3
|
function history(entries) {
|
|
4
4
|
return {
|
|
5
5
|
entries: entries.map((entry, index) => ({ ...entry, createdAt: index })),
|
|
@@ -55,79 +55,4 @@ describe("publishRunReminder", () => {
|
|
|
55
55
|
expect(reminder).toContain("`git status` and `git diff`");
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
|
-
describe("publishStandingReminder", () => {
|
|
59
|
-
it("tells the turn after a failed publish that nothing is live, and why Baker recorded it failed", () => {
|
|
60
|
-
const reminder = publishStandingReminder({
|
|
61
|
-
publishStanding: {
|
|
62
|
-
status: "publish_failed",
|
|
63
|
-
publishFailureReason: "Verify failed (exit 1). Verify-gate token NOT written.",
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
expect(reminder).toContain("this chat's last publish failed");
|
|
67
|
-
expect(reminder).toContain('"Verify failed (exit 1). Verify-gate token NOT written."');
|
|
68
|
-
expect(reminder).toContain("Nothing from this chat is live");
|
|
69
|
-
});
|
|
70
|
-
it("tells a continued chat that the chat it continues was published after its conversation ended", () => {
|
|
71
|
-
const reminder = publishStandingReminder({
|
|
72
|
-
publishStanding: { status: "in_progress" },
|
|
73
|
-
sourcePublishStanding: {
|
|
74
|
-
status: "completed",
|
|
75
|
-
chatId: "chat_source",
|
|
76
|
-
publishedAt: Date.UTC(2026, 9, 22, 10, 0),
|
|
77
|
-
deployedAt: Date.UTC(2026, 9, 22, 10, 4),
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
expect(reminder).toContain("Baker: how the chat this one continues ended.");
|
|
81
|
-
expect(reminder).toContain("It was published at 2026-10-22T10:00:00.000Z, so what it made is live now.");
|
|
82
|
-
expect(reminder).not.toContain("this chat's last publish failed");
|
|
83
|
-
});
|
|
84
|
-
it("does not say a continued chat's source is live while its deploy has not finished", () => {
|
|
85
|
-
const reminder = publishStandingReminder({
|
|
86
|
-
publishStanding: { status: "in_progress" },
|
|
87
|
-
sourcePublishStanding: {
|
|
88
|
-
status: "completed",
|
|
89
|
-
chatId: "chat_source",
|
|
90
|
-
publishedAt: Date.UTC(2026, 9, 22, 10, 0),
|
|
91
|
-
externalChanges: { applying: true, notApplied: 0, failures: [] },
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
expect(reminder).not.toContain("live now");
|
|
95
|
-
expect(reminder).toContain("Baker has no record yet that the site update finished");
|
|
96
|
-
expect(reminder).toContain("still being applied");
|
|
97
|
-
expect(reminder).toContain("`baker chats view chat_source`");
|
|
98
|
-
});
|
|
99
|
-
it("names what of a continued chat's source did not go through", () => {
|
|
100
|
-
const reminder = publishStandingReminder({
|
|
101
|
-
publishStanding: { status: "in_progress" },
|
|
102
|
-
sourcePublishStanding: {
|
|
103
|
-
status: "completed",
|
|
104
|
-
chatId: "chat_source",
|
|
105
|
-
publishedAt: Date.UTC(2026, 9, 22, 10, 0),
|
|
106
|
-
deployedAt: Date.UTC(2026, 9, 22, 10, 4),
|
|
107
|
-
externalChanges: {
|
|
108
|
-
applying: false,
|
|
109
|
-
notApplied: 2,
|
|
110
|
-
failures: ["Meta Ads: Create ad 1", "Meta Ads: Create ad 2"],
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
expect(reminder).not.toContain("live now");
|
|
115
|
-
expect(reminder).toContain("2 of its changes outside the site did not go through and are not live");
|
|
116
|
-
expect(reminder).toContain('"Meta Ads: Create ad 1"');
|
|
117
|
-
});
|
|
118
|
-
it("does not deny a publish whose failure is only a missing callback", () => {
|
|
119
|
-
const reminder = publishStandingReminder({
|
|
120
|
-
publishStanding: {
|
|
121
|
-
status: "publish_failed",
|
|
122
|
-
publishFailureReason: "Publish ended before Baker received a completion callback from the publish command.",
|
|
123
|
-
outcomeUnknown: true,
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
expect(reminder).not.toContain("Nothing from this chat is live");
|
|
127
|
-
expect(reminder).toContain("whether it reached the live site is not known");
|
|
128
|
-
});
|
|
129
|
-
it("says nothing on a turn whose chat has no publish to report", () => {
|
|
130
|
-
expect(publishStandingReminder({ publishStanding: { status: "in_progress" } })).toBeUndefined();
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
58
|
//# sourceMappingURL=publish-handoff.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-handoff.test.js","sourceRoot":"","sources":["../../src/hono/publish-handoff.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"publish-handoff.test.js","sourceRoot":"","sources":["../../src/hono/publish-handoff.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGnF,SAAS,OAAO,CAAC,OAAuD;IACtE,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QACxE,iBAAiB,EAAE,CAAC;QACpB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,MAAM;QACpB,eAAe,EAAE,EAAE;KACpB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,kFAAkF,EAAE,GAAG,EAAE;QAC1F,MAAM,QAAQ,GAAG,uBAAuB,CACtC,OAAO,CAAC;YACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,+CAA+C,EAAE;YACvE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,sBAAsB,EAAE;YACnD;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,qFAAqF;gBAC3F,YAAY,EAAE,IAAI;aACnB;SACF,CAAC,CACH,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,+CAA+C,CAAC,CAAC;QAC5E,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC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AAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QACxD,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/hono/types.d.ts
CHANGED
|
@@ -42,28 +42,6 @@ export interface DispatchHistorySnapshot {
|
|
|
42
42
|
maxTextChars: number;
|
|
43
43
|
renderedContext: string;
|
|
44
44
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Where a chat's publishing stands, as Convex recorded it at dispatch — the
|
|
47
|
-
* authority on whether its work is live. A rebuilt history never carries a
|
|
48
|
-
* publish outcome, and a failed publish leaves its squash commit on the branch.
|
|
49
|
-
*/
|
|
50
|
-
export interface PublishStanding {
|
|
51
|
-
status: string;
|
|
52
|
-
publishedAt?: number;
|
|
53
|
-
publishFailureReason?: string;
|
|
54
|
-
/** The recorded failure is a callback that never came, which can follow a push that landed. */
|
|
55
|
-
outcomeUnknown?: true;
|
|
56
|
-
/** A continuation source's own id, for `baker chats view`. */
|
|
57
|
-
chatId?: string;
|
|
58
|
-
/** When the site's deploy of the source's Publish finished; absent while it has not. */
|
|
59
|
-
deployedAt?: number;
|
|
60
|
-
/** A continuation source's changes outside the site still applying or that did not go through. */
|
|
61
|
-
externalChanges?: {
|
|
62
|
-
applying: boolean;
|
|
63
|
-
notApplied: number;
|
|
64
|
-
failures: string[];
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
45
|
/**
|
|
68
46
|
* The output the user is currently viewing in the dashboard preview pane when
|
|
69
47
|
* they send a turn. A lightweight pointer (no content) — the agent reads the
|
|
@@ -99,10 +77,6 @@ export interface AsyncMessageRequest {
|
|
|
99
77
|
/** The saved credentials the message names as `{{credential:NAME}}`: metadata only, never a value. */
|
|
100
78
|
credentials?: PromptCredential[];
|
|
101
79
|
currentSender?: DispatchSender;
|
|
102
|
-
/** This chat's publishing, sent on every ordinary turn. */
|
|
103
|
-
publishStanding?: PublishStanding;
|
|
104
|
-
/** The publishing of the chat a "Continue" chat continues, sent on the turn its conversation is folded into. */
|
|
105
|
-
sourcePublishStanding?: PublishStanding;
|
|
106
80
|
planMode?: boolean;
|
|
107
81
|
/**
|
|
108
82
|
* Nobody is watching this turn — it was started by a schedule, not a person.
|
package/dist/hono/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hono/types.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,8GAA8G;IAC9G,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,yBAAyB;IACjC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yGAAyG;IACzG,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,iHAAiH;IACjH,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,oBAAoB,EAAE,CAA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OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE;QACT,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC;QACnC,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC"}
|
package/dist/review/digest.d.ts
CHANGED
|
@@ -318,6 +318,8 @@ export type TranscriptDigest = {
|
|
|
318
318
|
slowest: ToolCall[];
|
|
319
319
|
/** Failures by class and tool: the evidence lens J is built on. */
|
|
320
320
|
failures: FailureAggregate[];
|
|
321
|
+
/** Failed `baker` calls the CLI recorded that no one running Bash call in the transcript ran. */
|
|
322
|
+
unplacedCliFailures: string[];
|
|
321
323
|
/** The same call, run twice, answering differently. Computed, never judged. */
|
|
322
324
|
flaky: FlakyCall[];
|
|
323
325
|
introspectionCalls: ToolCall[];
|
|
@@ -403,7 +405,7 @@ export declare function flagPlumbing(text: string): string[];
|
|
|
403
405
|
* hook file tells you which rule to go and read, "blocked" tells you nothing.
|
|
404
406
|
*/
|
|
405
407
|
export declare function namedGuard(message: string): string | undefined;
|
|
406
|
-
export declare function buildTranscriptDigest(lines: readonly TranscriptLine[]): TranscriptDigest;
|
|
408
|
+
export declare function buildTranscriptDigest(lines: readonly TranscriptLine[], cli?: readonly CliInvocation[]): TranscriptDigest;
|
|
407
409
|
export type DebugLogLine = {
|
|
408
410
|
ts?: string;
|
|
409
411
|
session?: string;
|
|
@@ -424,7 +426,14 @@ export type CliInvocation = {
|
|
|
424
426
|
session: string;
|
|
425
427
|
argv: string[];
|
|
426
428
|
verb?: string;
|
|
429
|
+
/** When it started, by the sandbox clock the transcript is stamped with too. */
|
|
430
|
+
startedAt?: string;
|
|
427
431
|
exitCode?: number;
|
|
432
|
+
/** The `ok: false` envelope it printed, when it printed one. */
|
|
433
|
+
error?: {
|
|
434
|
+
code: string;
|
|
435
|
+
message: string;
|
|
436
|
+
};
|
|
428
437
|
durationMs?: number;
|
|
429
438
|
httpCalls: {
|
|
430
439
|
method: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../src/review/digest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../src/review/digest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAWH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAA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AED,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,MAAM,CAyBlE"}
|
package/dist/review/digest.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { createHash } from "node:crypto";
|
|
19
19
|
import { imageSize } from "image-size";
|
|
20
|
+
import { parse } from "unbash";
|
|
20
21
|
import { languageMismatch, marketerWords, messageLanguage } from "./reply-language.js";
|
|
21
22
|
/** Parse a `.jsonl` body, dropping lines that are not JSON rather than failing. */
|
|
22
23
|
export function parseTranscript(body) {
|
|
@@ -465,15 +466,21 @@ export function namedGuard(message) {
|
|
|
465
466
|
}
|
|
466
467
|
return undefined;
|
|
467
468
|
}
|
|
468
|
-
/**
|
|
469
|
-
|
|
469
|
+
/**
|
|
470
|
+
* Ledger a failure: its class, the guard row, and the turn's denial count when a
|
|
471
|
+
* guard refused it. A call can fail more than once — each `baker` call one
|
|
472
|
+
* command line ran — and its own class and message are its first failure's.
|
|
473
|
+
*/
|
|
474
|
+
function absorbFailure(acc, call, message, failureClass = classifyFailure(message)) {
|
|
470
475
|
const turn = acc.turns[call.turn];
|
|
471
|
-
|
|
472
|
-
call.failureClass
|
|
473
|
-
if (turn &&
|
|
476
|
+
call.isError = true;
|
|
477
|
+
call.failureClass ??= failureClass;
|
|
478
|
+
if (turn && failureClass === "refused") {
|
|
474
479
|
turn.denials += 1;
|
|
475
480
|
}
|
|
476
|
-
acc.failureMessages.
|
|
481
|
+
if (!acc.failureMessages.has(call.toolUseId)) {
|
|
482
|
+
acc.failureMessages.set(call.toolUseId, clip(message, 400));
|
|
483
|
+
}
|
|
477
484
|
const guard = namedGuard(message);
|
|
478
485
|
// A subagent's words, never the turn's: the turn's are its parent's.
|
|
479
486
|
const intent = call.isSidechain
|
|
@@ -487,7 +494,7 @@ function absorbFailure(acc, call, block) {
|
|
|
487
494
|
attempted: call.summary,
|
|
488
495
|
inputKey: call.inputKey,
|
|
489
496
|
message: clip(message, 400),
|
|
490
|
-
refusal:
|
|
497
|
+
refusal: failureClass === "refused",
|
|
491
498
|
...(guard === undefined ? {} : { guard }),
|
|
492
499
|
...(intent ? { intent: clip(intent, 300) } : {}),
|
|
493
500
|
...(call.isSidechain && call.agentId !== undefined ? { agentId: call.agentId } : {}),
|
|
@@ -508,12 +515,11 @@ function absorbToolResults(acc, line) {
|
|
|
508
515
|
const seen = measureToolResult(block.content);
|
|
509
516
|
call.resultBytes = seen.bytes;
|
|
510
517
|
call.resultTokens = seen.tokens;
|
|
511
|
-
call.isError = block.is_error === true;
|
|
512
518
|
if (line.timestamp !== undefined) {
|
|
513
519
|
acc.answeredAt.set(call.toolUseId, line.timestamp);
|
|
514
520
|
}
|
|
515
|
-
if (
|
|
516
|
-
absorbFailure(acc, call, block);
|
|
521
|
+
if (block.is_error === true) {
|
|
522
|
+
absorbFailure(acc, call, typeof block.content === "string" ? block.content : String(block.content ?? ""));
|
|
517
523
|
}
|
|
518
524
|
}
|
|
519
525
|
}
|
|
@@ -646,6 +652,12 @@ function userFacingMessage(turn, text, marketerLanguage) {
|
|
|
646
652
|
...(mismatch === undefined ? {} : { languageMismatch: mismatch }),
|
|
647
653
|
};
|
|
648
654
|
}
|
|
655
|
+
/** A Bash call's whole command, which placing a failed `baker` call on it reads. */
|
|
656
|
+
function rememberCommand(acc, call, use) {
|
|
657
|
+
if (call.tool === "Bash" && typeof use.input?.command === "string") {
|
|
658
|
+
acc.commands.set(call.toolUseId, use.input.command);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
649
661
|
/** Ledger each tool call a response asked for, under the response it came in. */
|
|
650
662
|
function absorbToolUses(acc, line, turnAt, isSidechain) {
|
|
651
663
|
const uses = blocks(line).filter((block) => block.type === "tool_use");
|
|
@@ -662,6 +674,7 @@ function absorbToolUses(acc, line, turnAt, isSidechain) {
|
|
|
662
674
|
});
|
|
663
675
|
acc.toolCalls.push(call);
|
|
664
676
|
acc.pending.set(call.toolUseId, call);
|
|
677
|
+
rememberCommand(acc, call, use);
|
|
665
678
|
if (requestId !== undefined) {
|
|
666
679
|
acc.batches.set(requestId, [...(acc.batches.get(requestId) ?? []), call]);
|
|
667
680
|
}
|
|
@@ -736,6 +749,131 @@ function timeCalls(acc) {
|
|
|
736
749
|
call.durationMs = took;
|
|
737
750
|
}
|
|
738
751
|
}
|
|
752
|
+
return startOf;
|
|
753
|
+
}
|
|
754
|
+
/** Whether the CLI says an invocation failed: a non-zero exit, or an `ok: false` envelope it printed. */
|
|
755
|
+
function cliFailed(invocation) {
|
|
756
|
+
return (invocation.exitCode !== undefined && invocation.exitCode !== 0) || invocation.error !== undefined;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* What the CLI said about a failed invocation, and nothing the agent typed: the
|
|
760
|
+
* class is read from this, so `--title "Fix checkout timeout"` is not a timeout.
|
|
761
|
+
*/
|
|
762
|
+
function cliErrorOf(invocation) {
|
|
763
|
+
const exit = invocation.exitCode === undefined ? "failed" : `exited ${invocation.exitCode}`;
|
|
764
|
+
return invocation.error === undefined ? exit : `${invocation.error.code}: ${invocation.error.message} — ${exit}`;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Its class, from the error code when the code names one: the CLI's message
|
|
768
|
+
* often echoes what the agent passed (`Invalid ID format: "zz-timeout-check"`),
|
|
769
|
+
* and read whole that `VALIDATION_ERROR` is a timeout.
|
|
770
|
+
*/
|
|
771
|
+
function classifyCliFailure(invocation) {
|
|
772
|
+
const byCode = invocation.error === undefined ? "other" : classifyFailure(invocation.error.code);
|
|
773
|
+
return byCode === "other" ? classifyFailure(cliErrorOf(invocation)) : byCode;
|
|
774
|
+
}
|
|
775
|
+
/** The error first, so clipping a long command never takes the code with it. */
|
|
776
|
+
function describeCliFailure(invocation) {
|
|
777
|
+
return invocation.error === undefined
|
|
778
|
+
? `\`baker ${invocation.argv.join(" ")}\` ${cliErrorOf(invocation)}`
|
|
779
|
+
: `${cliErrorOf(invocation)} — \`baker ${invocation.argv.join(" ")}\``;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* The arguments of every `baker` command a shell command line runs, read the way
|
|
783
|
+
* the shell reads it: dequoted, inside pipes, lists, loops and substitutions,
|
|
784
|
+
* never inside a heredoc body or a quoted string.
|
|
785
|
+
*/
|
|
786
|
+
function bakerArgvsOf(command) {
|
|
787
|
+
const script = parse(command);
|
|
788
|
+
if (script.errors && script.errors.length > 0) {
|
|
789
|
+
return [];
|
|
790
|
+
}
|
|
791
|
+
const argvs = [];
|
|
792
|
+
// Serialised because unbash materialises a word's parts only in `toJSON`.
|
|
793
|
+
JSON.stringify(script, (_key, value) => {
|
|
794
|
+
const node = value;
|
|
795
|
+
if (node?.type === "Command" && typeof node.name?.value === "string" && /(?:^|\/)baker$/.test(node.name.value)) {
|
|
796
|
+
argvs.push((node.suffix ?? []).map((word) => String(word.value ?? "")));
|
|
797
|
+
}
|
|
798
|
+
return value;
|
|
799
|
+
});
|
|
800
|
+
return argvs;
|
|
801
|
+
}
|
|
802
|
+
/** A word the shell expands before `baker` sees it, and so matches whatever argument it became. */
|
|
803
|
+
const EXPANDED_WORD = /[$*?[`]/;
|
|
804
|
+
/** Whether a command's own `baker` words are the ones an invocation received. */
|
|
805
|
+
function ranInvocation(words, argv) {
|
|
806
|
+
return words.length === argv.length && words.every((word, index) => word === argv[index] || EXPANDED_WORD.test(word));
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* The Bash call a `baker` invocation ran inside: the one running when it
|
|
810
|
+
* started whose command runs exactly that `baker` call.
|
|
811
|
+
*
|
|
812
|
+
* Nothing else places it. Subagents run side by side, so two running calls can
|
|
813
|
+
* share a platform (`baker ads meta campaigns`, `baker ads meta ads pause`), and
|
|
814
|
+
* a watcher or a hook calls `baker` while an unrelated command runs; a failure
|
|
815
|
+
* pinned on whichever call was running reports a success as failed and the
|
|
816
|
+
* failed call as a success. When no running call ran it, or more than one did,
|
|
817
|
+
* it is left unplaced.
|
|
818
|
+
*/
|
|
819
|
+
function callRunning(invocation, acc, startOf, argvsOf) {
|
|
820
|
+
const at = stampOf(invocation.startedAt);
|
|
821
|
+
if (at === undefined) {
|
|
822
|
+
return undefined;
|
|
823
|
+
}
|
|
824
|
+
const ran = acc.toolCalls.filter((call) => {
|
|
825
|
+
const from = stampOf(startOf.get(call.toolUseId));
|
|
826
|
+
const to = stampOf(acc.answeredAt.get(call.toolUseId));
|
|
827
|
+
return (call.tool === "Bash" &&
|
|
828
|
+
from !== undefined &&
|
|
829
|
+
to !== undefined &&
|
|
830
|
+
from <= at &&
|
|
831
|
+
at <= to &&
|
|
832
|
+
argvsOf(call).some((words) => ranInvocation(words, invocation.argv)));
|
|
833
|
+
});
|
|
834
|
+
return ran.length === 1 ? ran[0] : undefined;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Count a `baker` call that failed as a failure, whatever its shell returned.
|
|
838
|
+
*
|
|
839
|
+
* A Bash result is an error only when the whole command line exited non-zero,
|
|
840
|
+
* and `| head`, `> file` or a later `; echo` make that zero. Read from the tool
|
|
841
|
+
* result alone, a Session whose every refused or timed-out `baker` call was
|
|
842
|
+
* piped reported "none of them failed" — while the CLI's own record said why
|
|
843
|
+
* each one did. A failure no call can be placed on is returned, never dropped.
|
|
844
|
+
*/
|
|
845
|
+
function absorbCliFailures(acc, cli, startOf) {
|
|
846
|
+
const unplaced = [];
|
|
847
|
+
const failedIn = new Map();
|
|
848
|
+
const argvs = new Map();
|
|
849
|
+
const argvsOf = (call) => {
|
|
850
|
+
const known = argvs.get(call.toolUseId) ?? bakerArgvsOf(acc.commands.get(call.toolUseId) ?? "");
|
|
851
|
+
argvs.set(call.toolUseId, known);
|
|
852
|
+
return known;
|
|
853
|
+
};
|
|
854
|
+
for (const invocation of cli.filter(cliFailed)) {
|
|
855
|
+
const call = callRunning(invocation, acc, startOf, argvsOf);
|
|
856
|
+
if (call === undefined) {
|
|
857
|
+
unplaced.push(invocation);
|
|
858
|
+
}
|
|
859
|
+
else if (!call.isError) {
|
|
860
|
+
failedIn.set(call, [...(failedIn.get(call) ?? []), invocation]);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
for (const [call, invocations] of failedIn) {
|
|
864
|
+
const failures = invocations.map((invocation) => ({
|
|
865
|
+
failureClass: classifyCliFailure(invocation),
|
|
866
|
+
message: clip(describeCliFailure(invocation), 400),
|
|
867
|
+
durationMs: invocation.durationMs ?? 0,
|
|
868
|
+
}));
|
|
869
|
+
for (const failure of failures) {
|
|
870
|
+
absorbFailure(acc, call, failure.message, failure.failureClass);
|
|
871
|
+
}
|
|
872
|
+
acc.cliFailures.set(call.toolUseId, failures);
|
|
873
|
+
}
|
|
874
|
+
const order = new Map(acc.toolCalls.map((call, index) => [call.toolUseId, index]));
|
|
875
|
+
acc.guards.sort((a, b) => (order.get(a.toolUseId) ?? 0) - (order.get(b.toolUseId) ?? 0));
|
|
876
|
+
return unplaced;
|
|
739
877
|
}
|
|
740
878
|
/** The latest of some ISO timestamps, or nothing when none is given. */
|
|
741
879
|
function latest(stamps) {
|
|
@@ -792,7 +930,7 @@ function countGuardRepeats(guards) {
|
|
|
792
930
|
guard.repeats = counts.get(key) ?? 1;
|
|
793
931
|
}
|
|
794
932
|
}
|
|
795
|
-
export function buildTranscriptDigest(lines) {
|
|
933
|
+
export function buildTranscriptDigest(lines, cli = []) {
|
|
796
934
|
const acc = {
|
|
797
935
|
turns: [],
|
|
798
936
|
toolCalls: [],
|
|
@@ -810,6 +948,8 @@ export function buildTranscriptDigest(lines) {
|
|
|
810
948
|
answeredAt: new Map(),
|
|
811
949
|
subagentTurns: new Map(),
|
|
812
950
|
subagentWords: new Map(),
|
|
951
|
+
commands: new Map(),
|
|
952
|
+
cliFailures: new Map(),
|
|
813
953
|
};
|
|
814
954
|
for (const line of lines) {
|
|
815
955
|
const openTurns = acc.turns.length;
|
|
@@ -841,7 +981,8 @@ export function buildTranscriptDigest(lines) {
|
|
|
841
981
|
call.failureClass = "timeout";
|
|
842
982
|
acc.failureMessages.set(call.toolUseId, "No result was ever recorded for this call.");
|
|
843
983
|
}
|
|
844
|
-
timeCalls(acc);
|
|
984
|
+
const startOf = timeCalls(acc);
|
|
985
|
+
const unplacedCliFailures = absorbCliFailures(acc, cli, startOf);
|
|
845
986
|
attributeGuardFollowUps(acc.guards, acc.toolCalls);
|
|
846
987
|
countGuardRepeats(acc.guards);
|
|
847
988
|
const threadStamps = stampsByThread(lines);
|
|
@@ -860,7 +1001,8 @@ export function buildTranscriptDigest(lines) {
|
|
|
860
1001
|
.filter((call) => call.durationMs !== undefined)
|
|
861
1002
|
.sort((a, b) => (b.durationMs ?? 0) - (a.durationMs ?? 0))
|
|
862
1003
|
.slice(0, 15),
|
|
863
|
-
failures: aggregateFailures(acc.toolCalls, acc.failureMessages),
|
|
1004
|
+
failures: aggregateFailures(acc.toolCalls, acc.failureMessages, acc.cliFailures),
|
|
1005
|
+
unplacedCliFailures: unplacedCliFailures.map(describeCliFailure),
|
|
864
1006
|
flaky: findFlakyCalls(acc.toolCalls),
|
|
865
1007
|
introspectionCalls: acc.toolCalls.filter((call) => call.bakerVerb?.startsWith("baker schema") || /--help\b/.test(call.summary)),
|
|
866
1008
|
hooks: [...acc.hooks.values()].sort((a, b) => b.fired - a.fired),
|
|
@@ -880,30 +1022,37 @@ export function buildTranscriptDigest(lines) {
|
|
|
880
1022
|
* a bad moment, eleven of them at the same bound is a default set for a network
|
|
881
1023
|
* this sandbox does not have.
|
|
882
1024
|
*/
|
|
883
|
-
function
|
|
1025
|
+
function ownFailure(call, failureClass, messages) {
|
|
1026
|
+
return { failureClass, message: messages.get(call.toolUseId) ?? "", durationMs: call.durationMs ?? 0 };
|
|
1027
|
+
}
|
|
1028
|
+
function aggregateFailures(calls, messages, cliFailures) {
|
|
884
1029
|
const map = new Map();
|
|
885
1030
|
for (const call of calls) {
|
|
886
1031
|
if (!call.isError || call.failureClass === undefined) {
|
|
887
1032
|
continue;
|
|
888
1033
|
}
|
|
889
|
-
|
|
890
|
-
const
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
entry.
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
1034
|
+
// A command line that ran several failed `baker` calls counts each of them.
|
|
1035
|
+
const failures = cliFailures.get(call.toolUseId) ?? [ownFailure(call, call.failureClass, messages)];
|
|
1036
|
+
for (const failure of failures) {
|
|
1037
|
+
const key = `${failure.failureClass}::${call.tool}`;
|
|
1038
|
+
const entry = map.get(key) ?? {
|
|
1039
|
+
failureClass: failure.failureClass,
|
|
1040
|
+
tool: call.tool,
|
|
1041
|
+
calls: 0,
|
|
1042
|
+
totalMs: 0,
|
|
1043
|
+
example: failure.message,
|
|
1044
|
+
turns: [],
|
|
1045
|
+
};
|
|
1046
|
+
entry.calls += 1;
|
|
1047
|
+
entry.totalMs += failure.durationMs;
|
|
1048
|
+
if (entry.example.length === 0) {
|
|
1049
|
+
entry.example = failure.message;
|
|
1050
|
+
}
|
|
1051
|
+
if (!entry.turns.includes(call.turn)) {
|
|
1052
|
+
entry.turns.push(call.turn);
|
|
1053
|
+
}
|
|
1054
|
+
map.set(key, entry);
|
|
905
1055
|
}
|
|
906
|
-
map.set(key, entry);
|
|
907
1056
|
}
|
|
908
1057
|
return [...map.values()].sort((a, b) => b.calls - a.calls);
|
|
909
1058
|
}
|
|
@@ -1117,6 +1266,9 @@ function absorbInvocation(entry, line) {
|
|
|
1117
1266
|
return;
|
|
1118
1267
|
}
|
|
1119
1268
|
entry.argv = line.argv;
|
|
1269
|
+
if (line.ts !== undefined) {
|
|
1270
|
+
entry.startedAt = line.ts;
|
|
1271
|
+
}
|
|
1120
1272
|
const verb = bakerVerbOf(`baker ${line.argv.join(" ")}`);
|
|
1121
1273
|
if (verb) {
|
|
1122
1274
|
entry.verb = verb;
|
|
@@ -1141,14 +1293,38 @@ function absorbExit(entry, line) {
|
|
|
1141
1293
|
entry.durationMs = line.durationMs;
|
|
1142
1294
|
}
|
|
1143
1295
|
}
|
|
1296
|
+
/** What it printed, and the error it reported when the text is an `ok: false` envelope. */
|
|
1297
|
+
function absorbOutput(entry, line) {
|
|
1298
|
+
if (typeof line.text !== "string") {
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
entry.printedBytes += Buffer.byteLength(line.text);
|
|
1302
|
+
const error = printedError(line.text);
|
|
1303
|
+
if (error !== undefined && entry.error === undefined) {
|
|
1304
|
+
entry.error = error;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
function printedError(text) {
|
|
1308
|
+
let parsed;
|
|
1309
|
+
try {
|
|
1310
|
+
parsed = JSON.parse(text);
|
|
1311
|
+
}
|
|
1312
|
+
catch {
|
|
1313
|
+
return undefined;
|
|
1314
|
+
}
|
|
1315
|
+
if (typeof parsed !== "object" || parsed === null || parsed.ok !== false) {
|
|
1316
|
+
return undefined;
|
|
1317
|
+
}
|
|
1318
|
+
const error = parsed.error;
|
|
1319
|
+
return {
|
|
1320
|
+
code: typeof error?.code === "string" ? error.code : "ERROR",
|
|
1321
|
+
message: typeof error?.message === "string" ? error.message : "",
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1144
1324
|
const DEBUG_LINE_HANDLERS = {
|
|
1145
1325
|
invocation: absorbInvocation,
|
|
1146
1326
|
http: absorbHttpCall,
|
|
1147
|
-
output:
|
|
1148
|
-
if (typeof line.text === "string") {
|
|
1149
|
-
entry.printedBytes += Buffer.byteLength(line.text);
|
|
1150
|
-
}
|
|
1151
|
-
},
|
|
1327
|
+
output: absorbOutput,
|
|
1152
1328
|
exit: absorbExit,
|
|
1153
1329
|
};
|
|
1154
1330
|
/**
|
|
@@ -1397,6 +1573,17 @@ export function renderFailures(digest) {
|
|
|
1397
1573
|
clip(entry.example, 160),
|
|
1398
1574
|
])),
|
|
1399
1575
|
"",
|
|
1576
|
+
...(digest.unplacedCliFailures.length === 0
|
|
1577
|
+
? []
|
|
1578
|
+
: [
|
|
1579
|
+
"## Failed `baker` calls no tool call can be placed on",
|
|
1580
|
+
"",
|
|
1581
|
+
"The CLI recorded these as failed, and when each started no loaded transcript",
|
|
1582
|
+
"had exactly one running Bash call whose command ran that `baker` call.",
|
|
1583
|
+
"",
|
|
1584
|
+
...digest.unplacedCliFailures.map((failure) => `- ${clip(failure, 300)}`),
|
|
1585
|
+
"",
|
|
1586
|
+
]),
|
|
1400
1587
|
"## The same call, two answers",
|
|
1401
1588
|
"",
|
|
1402
1589
|
"Identical tool and input, one attempt failing and another succeeding, with",
|