@hearsay-tools/squawk 0.18.0-pr4352.8504 → 0.18.0-pr4355.8519
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-wait/controller.d.ts +7 -7
- package/dist/delegation/provision.d.ts +1 -2
- package/dist/delegation/provision.js +26 -45
- package/dist/delegation/provision.js.map +1 -1
- package/dist/delegation/routes.d.ts +65 -65
- package/dist/delegation/transport.d.ts +65 -65
- package/dist/runners/antigravity/acp/events.d.ts +1 -9
- package/dist/runners/antigravity/acp/events.js +11 -52
- package/dist/runners/antigravity/acp/events.js.map +1 -1
- package/dist/runners/antigravity/acp/protocol.d.ts +1 -12
- package/dist/runners/antigravity/acp/protocol.js.map +1 -1
- package/dist/runners/antigravity/acp/session.d.ts +0 -3
- package/dist/runners/antigravity/acp/session.js +0 -9
- package/dist/runners/antigravity/acp/session.js.map +1 -1
- package/dist/runners/antigravity/antigravity-runner.d.ts +2 -2
- package/dist/runners/antigravity/antigravity-session.d.ts +4 -4
- package/dist/runners/antigravity/antigravity-session.js +20 -48
- package/dist/runners/antigravity/antigravity-session.js.map +1 -1
- package/dist/runners/antigravity/antigravity-ui-mapper.d.ts +0 -2
- package/dist/runners/antigravity/antigravity-ui-mapper.js +3 -11
- package/dist/runners/antigravity/antigravity-ui-mapper.js.map +1 -1
- package/dist/runners/antigravity/facts.d.ts +2 -2
- package/dist/runners/antigravity/facts.js +5 -7
- package/dist/runners/antigravity/facts.js.map +1 -1
- package/dist/runners/antigravity/mock.d.ts +2 -4
- package/dist/runners/antigravity/mock.js +2 -3
- package/dist/runners/antigravity/mock.js.map +1 -1
- package/dist/runners/antigravity/spec-support.js +1 -1
- package/dist/runners/antigravity/spec-support.js.map +1 -1
- package/dist/runners/antigravity/subagent-guard.d.ts +17 -0
- package/dist/runners/antigravity/subagent-guard.js +38 -0
- package/dist/runners/antigravity/subagent-guard.js.map +1 -0
- package/dist/runners/antigravity/tool-normalization.d.ts +0 -2
- package/dist/runners/antigravity/tool-normalization.js +2 -44
- package/dist/runners/antigravity/tool-normalization.js.map +1 -1
- package/dist/runners/antigravity/tool-transcript.d.ts +50 -24
- package/dist/runners/antigravity/tool-transcript.js +192 -88
- package/dist/runners/antigravity/tool-transcript.js.map +1 -1
- package/dist/runners/antigravity/wire-updates.d.ts +6 -4
- package/dist/runners/antigravity/wire-updates.js +3 -25
- package/dist/runners/antigravity/wire-updates.js.map +1 -1
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/automations-routes.d.ts +150 -150
- package/dist/server/models-routes.d.ts +12 -12
- package/dist/server/project-settings-routes.d.ts +107 -107
- package/dist/server/projects-routes.d.ts +45 -45
- package/dist/server/provider-sign-in-routes.d.ts +2 -2
- package/dist/server/providers-routes.d.ts +57 -57
- package/dist/server/repo-routes.d.ts +34 -34
- package/dist/server/reports-api.d.ts +2 -2
- package/dist/server/runner-install-routes.d.ts +10 -10
- package/dist/server/runners-routes.d.ts +10 -10
- package/dist/server/runs-routes.d.ts +304 -304
- package/dist/server/server.d.ts +1618 -1618
- package/dist/server/workspace-routes.d.ts +84 -84
- package/dist/workflows/run/continuation-session.js +1 -1
- package/dist/workflows/run/continuation-session.js.map +1 -1
- package/dist/workflows/run/launch-context.d.ts +1 -1
- package/dist/workflows/run/launch-context.js +2 -2
- package/dist/workflows/run/launch-context.js.map +1 -1
- package/dist/workflows/run/session-events.d.ts +2 -2
- package/dist/workflows/run/session-events.js +2 -2
- package/dist/workflows/run/session-events.js.map +1 -1
- package/dist/workflows/run/step-session.js +1 -1
- package/dist/workflows/run/step-session.js.map +1 -1
- package/dist/workflows/run-states.js +1 -1
- package/dist/workflows/run-states.js.map +1 -1
- package/package.json +4 -4
- package/scripts/mock-acp.mjs +15 -128
- package/web/dist/assets/{accounts-section-CuihHvuE.js → accounts-section-CCwiE2JK.js} +1 -1
- package/web/dist/assets/{activity-motion-bKmIl_Ai.js → activity-motion-Cg-COgbE.js} +1 -1
- package/web/dist/assets/{activity-route-Bnz_NdUs.js → activity-route-lIT_UVnM.js} +1 -1
- package/web/dist/assets/{agent-config-section-uQrQrvBR.js → agent-config-section-BKlHWNwW.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-1UTSo5HV.js → agent-defaults-section-BTlpdhU_.js} +1 -1
- package/web/dist/assets/{appearance-CZ0kce28.js → appearance-Dl76GTxK.js} +1 -1
- package/web/dist/assets/{automations-route-Dq90emTh.js → automations-route-BgS-3Z_m.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-Btc38N2Q.js → commit-diff-panel-Cp6sHj_0.js} +1 -1
- package/web/dist/assets/{diff-C3-63Zgu.js → diff-Dud7aqS-.js} +2 -2
- package/web/dist/assets/{diff-view-D2O2Nm5P.js → diff-view-D6CJhIxn.js} +1 -1
- package/web/dist/assets/{file-preview-Bnq2OKGK.js → file-preview-CgpgPd0B.js} +1 -1
- package/web/dist/assets/{git-toolbar-RA8rF90D.js → git-toolbar-Bk8dA6g0.js} +1 -1
- package/web/dist/assets/{github-BRAMTLRU.js → github-DfDrbDmt.js} +1 -1
- package/web/dist/assets/{global-activity-route-Ii_-Fqqo.js → global-activity-route-jm07Cb6r.js} +1 -1
- package/web/dist/assets/{index-DCw_bX8I.js → index-BofxUFzT.js} +4 -4
- package/web/dist/assets/{markdown-G8tjpJd_.js → markdown-Bw1armEd.js} +1 -1
- package/web/dist/assets/{notifications-section-Fk_ebhy_.js → notifications-section-B0ED_Mhm.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-8HkdMxOW.js → preview-pane-connected--wS7owyd.js} +1 -1
- package/web/dist/assets/{projects-section-Dmj4JFoi.js → projects-section-Co5Svq65.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-DzfD2GES.js → prompt-templates-section-D1FaocRX.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-CYiMrnys.js → remote-settings-notice-D7NLgaAV.js} +1 -1
- package/web/dist/assets/{repo-git-B3tTtvIQ.js → repo-git-B5ls2-l_.js} +1 -1
- package/web/dist/assets/{report-reader-DBGA_8LA.js → report-reader-CFgD92rW.js} +1 -1
- package/web/dist/assets/{reports-B-Q6u2X6.js → reports-_tK92sKK.js} +1 -1
- package/web/dist/assets/{resources-section-C5ndEonC.js → resources-section-gUcumxof.js} +1 -1
- package/web/dist/assets/{run-header-DK4CZ3hY.js → run-header-CH4wXjDy.js} +1 -1
- package/web/dist/assets/{session-context-section-BAw6x6P2.js → session-context-section-BEapVsGl.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-fkaIrncp.js → settings-agent-picker-EREf7w-5.js} +1 -1
- package/web/dist/assets/{settings-shell-dzuuT5tw.js → settings-shell-CYdHCugT.js} +1 -1
- package/web/dist/assets/{sidebar-section-BIQilcgt.js → sidebar-section-dglDftim.js} +1 -1
- package/web/dist/assets/{skills-C-jo20DK.js → skills-D5WuMAgz.js} +1 -1
- package/web/dist/assets/{task-changes-DnG-9vJh.js → task-changes-Bawz4jPr.js} +1 -1
- package/web/dist/assets/{task-commits-mqs3nfjk.js → task-commits-iiaKY02_.js} +1 -1
- package/web/dist/assets/{task-files-DKB3Xp3N.js → task-files-DO8zl6O9.js} +1 -1
- package/web/dist/assets/{task-github-item-BA7W64bU.js → task-github-item-DchCJCHN.js} +1 -1
- package/web/dist/assets/{task-thread-B8zgMgtO.js → task-thread-Dnckjm3r.js} +1 -1
- package/web/dist/assets/{thread-state-8okW1FLM.js → thread-state-C4rdpFWw.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-Cgi2aScF.js +1 -0
- package/web/dist/assets/{workflows-BhQJM4JW.js → workflows-BxUyrGkZ.js} +1 -1
- package/web/dist/assets/{workspace-tools-BZs10pQZ.js → workspace-tools-C8rgWoTL.js} +1 -1
- package/web/dist/assets/{worktrees-section-BTNZUVnW.js → worktrees-section-D42ZNYv_.js} +1 -1
- package/web/dist/index.html +1 -1
- package/dist/runners/antigravity/subagent-tracker.d.ts +0 -50
- package/dist/runners/antigravity/subagent-tracker.js +0 -152
- package/dist/runners/antigravity/subagent-tracker.js.map +0 -1
- package/dist/runners/antigravity/subagent-transcript.d.ts +0 -41
- package/dist/runners/antigravity/subagent-transcript.js +0 -185
- package/dist/runners/antigravity/subagent-transcript.js.map +0 -1
- package/dist/runners/antigravity/transcript-tailer.d.ts +0 -56
- package/dist/runners/antigravity/transcript-tailer.js +0 -175
- package/dist/runners/antigravity/transcript-tailer.js.map +0 -1
- package/web/dist/assets/use-hand-to-agent-state-BwLk3gNd.js +0 -1
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { z } from '@hearsay-tools/squawk/plugin';
|
|
2
|
-
import { toolDisplay } from '@hearsay-tools/squawk/plugin/runtime';
|
|
3
2
|
import { ANTIGRAVITY_MCP_NAME } from './mcp-name.js';
|
|
4
3
|
const fields = z.record(z.string(), z.unknown());
|
|
5
4
|
const toolNames = {
|
|
6
5
|
run_command: 'Bash', read_file: 'Read', edit_file: 'Edit', write_file: 'Write',
|
|
7
6
|
invoke_subagent: 'Task', search_web: 'WebSearch',
|
|
8
7
|
};
|
|
9
|
-
const nonEmpty = (value) => typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
10
8
|
/** The native tool name: the CLI sends it as `name`; a title decorates it with Run/Running. */
|
|
11
9
|
export function antigravityNativeToolName(update) {
|
|
12
10
|
if (typeof update.name === 'string')
|
|
@@ -26,18 +24,6 @@ export function antigravityMcpTool(update) {
|
|
|
26
24
|
const match = /^mcp_(cezar_ci_[0-9a-f]{32}|[A-Za-z0-9-]+)_(.+)$/.exec(name);
|
|
27
25
|
return match ? { server: match[1], tool: match[2] } : undefined;
|
|
28
26
|
}
|
|
29
|
-
function normalizeTaskInput(input) {
|
|
30
|
-
const role = nonEmpty(input.Role);
|
|
31
|
-
const prompt = nonEmpty(input.Prompt);
|
|
32
|
-
const typeName = nonEmpty(input.TypeName);
|
|
33
|
-
const normalized = {
|
|
34
|
-
...input,
|
|
35
|
-
...(typeName && input.subagent_type === undefined ? { subagent_type: typeName } : {}),
|
|
36
|
-
...(role && input.description === undefined ? { description: role } : {}),
|
|
37
|
-
...(prompt && input.prompt === undefined ? { prompt } : {}),
|
|
38
|
-
};
|
|
39
|
-
return { input: normalized, title: toolDisplay('Task', normalized).title };
|
|
40
|
-
}
|
|
41
27
|
export function antigravityTool(update, previous) {
|
|
42
28
|
const input = fields.safeParse(update.rawInput).data;
|
|
43
29
|
const title = typeof update.title === 'string' ? update.title : previous?.title ?? '';
|
|
@@ -60,39 +46,11 @@ export function antigravityTool(update, previous) {
|
|
|
60
46
|
Object.assign(result, toolOutput(update.rawOutput));
|
|
61
47
|
if (name === 'Task') {
|
|
62
48
|
result.toolKind = 'task';
|
|
63
|
-
if (input && Object.keys(input).length)
|
|
64
|
-
|
|
65
|
-
else if (previous) {
|
|
66
|
-
if (input)
|
|
67
|
-
result.input = previous.input;
|
|
68
|
-
if (previous.title)
|
|
69
|
-
result.title = previous.title;
|
|
70
|
-
}
|
|
49
|
+
if (input && !Object.keys(input).length)
|
|
50
|
+
result.input = previous?.input;
|
|
71
51
|
}
|
|
72
52
|
return result;
|
|
73
53
|
}
|
|
74
|
-
/** Normalizes a child transcript tool call (`name`, `args`) into display fields for a nested `UiToolItem`. */
|
|
75
|
-
export function antigravityTranscriptTool(nativeName, rawArgs) {
|
|
76
|
-
const args = fields.safeParse(rawArgs).data;
|
|
77
|
-
const mcp = antigravityMcpTool({ name: nativeName });
|
|
78
|
-
if (mcp)
|
|
79
|
-
return { name: mcp.tool, toolKind: 'other', title: mcp.tool, ...(args ? { input: args } : {}) };
|
|
80
|
-
const name = toolNames[nativeName] ?? nativeName;
|
|
81
|
-
const normalized = transcriptToolInput(name, args);
|
|
82
|
-
const display = toolDisplay(name, normalized);
|
|
83
|
-
return { name, toolKind: display.toolKind, title: display.title, ...(normalized ? { input: normalized } : {}) };
|
|
84
|
-
}
|
|
85
|
-
function transcriptToolInput(name, args) {
|
|
86
|
-
if (!args)
|
|
87
|
-
return undefined;
|
|
88
|
-
if (name === 'Bash' && args.CommandLine !== undefined)
|
|
89
|
-
return { command: args.CommandLine, ...(args.Cwd === undefined ? {} : { cwd: args.Cwd }) };
|
|
90
|
-
if ((name === 'Read' || name === 'Edit' || name === 'Write') && typeof args.Path === 'string')
|
|
91
|
-
return { ...args, path: args.Path };
|
|
92
|
-
if (name === 'Task')
|
|
93
|
-
return normalizeTaskInput(args).input;
|
|
94
|
-
return args;
|
|
95
|
-
}
|
|
96
54
|
function toolOutput(value) {
|
|
97
55
|
const output = fields.safeParse(value).data;
|
|
98
56
|
if (!output)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-normalization.js","sourceRoot":"","sources":["../../../src/runners/antigravity/tool-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAmB,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tool-normalization.js","sourceRoot":"","sources":["../../../src/runners/antigravity/tool-normalization.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
-
import { type UiHookItem, type UiToolItem } from '../../plugin/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { z, type UiHookItem, type UiToolItem } from '../../plugin/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The CLI 1.5.14 ACP wire sends no result for a read, an MCP call or a subagent tool (the completed
|
|
4
|
+
* update has no `content`, `rawOutput` or `_meta`, hearsay-tools/squawk#4099) and carries no hook
|
|
5
|
+
* lifecycle frame. The CLI's own transcript keeps both tool results and injected hook messages
|
|
6
|
+
* (`SYSTEM_MESSAGE` rows with `source: "SYSTEM_SDK"`). It is a private format: every read is
|
|
7
|
+
* bounded, and a missing file or a changed format leaves no output (docs/runners/antigravity-wire.md).
|
|
8
|
+
*/
|
|
9
|
+
export declare const TRANSCRIPT_OUTPUT_CHARS: number;
|
|
4
10
|
/** How long after a tool completes the runner looks for its row. */
|
|
5
11
|
export declare const TRANSCRIPT_WAIT_MS = 10000;
|
|
12
|
+
declare const rowSchema: z.ZodObject<{
|
|
13
|
+
step_index: z.ZodNumber;
|
|
14
|
+
type: z.ZodString;
|
|
15
|
+
source: z.ZodOptional<z.ZodString>;
|
|
16
|
+
status: z.ZodOptional<z.ZodString>;
|
|
17
|
+
content: z.ZodOptional<z.ZodString>;
|
|
18
|
+
error: z.ZodOptional<z.ZodString>;
|
|
19
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
args: z.ZodOptional<z.ZodUnknown>;
|
|
22
|
+
}, z.core.$strip>>>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare function antigravityTranscriptPath(geminiDir: string, sessionId: string): string;
|
|
25
|
+
/** The text the agent received, without the CLI's `Created At:`/`Completed At:` lines, bounded. */
|
|
26
|
+
export declare function transcriptResultText(row: z.infer<typeof rowSchema>): string;
|
|
27
|
+
/** A `SYSTEM_SDK` `SYSTEM_MESSAGE` row injected by a native Antigravity hook, mapped to a hook item. */
|
|
28
|
+
export declare function transcriptHookItem(row: z.infer<typeof rowSchema>): UiHookItem | undefined;
|
|
6
29
|
export interface TranscriptCall {
|
|
7
30
|
id: string;
|
|
8
31
|
name: string;
|
|
9
32
|
args: unknown;
|
|
10
33
|
}
|
|
11
|
-
export interface SubagentTranscriptHooks {
|
|
12
|
-
onSpawn?(parentItemId: string, childId: string): void;
|
|
13
|
-
onMessage?(childId: string, body: string): void;
|
|
14
|
-
}
|
|
15
34
|
/**
|
|
16
|
-
* Matches tool calls to their result rows, extracts injected hook `SYSTEM_MESSAGE` rows
|
|
17
|
-
*
|
|
35
|
+
* Matches tool calls to their result rows, and extracts injected hook `SYSTEM_MESSAGE` rows.
|
|
36
|
+
* A planner row lists the step's calls with the same `name` and `args` the wire sends, and the k-th
|
|
37
|
+
* call's result is the row `step_index + 1 + k`. Each call takes its slot when it starts, so the
|
|
38
|
+
* n-th started call with a name and arguments gets the n-th planned one: neither the order calls
|
|
39
|
+
* complete in nor a call that stopped waiting moves another call's result. Only results a waiting
|
|
40
|
+
* call can still take are held.
|
|
18
41
|
*/
|
|
19
42
|
export declare class AntigravityTranscript {
|
|
20
43
|
/** Per call key: planned result steps, and started calls, that have no partner yet. */
|
|
@@ -25,8 +48,6 @@ export declare class AntigravityTranscript {
|
|
|
25
48
|
private readonly results;
|
|
26
49
|
private readonly hooks;
|
|
27
50
|
private readonly seenHooks;
|
|
28
|
-
private readonly childMessages;
|
|
29
|
-
private readonly seenMessages;
|
|
30
51
|
/** A call started on the wire: it takes the next planned slot of its name and arguments. */
|
|
31
52
|
start(call: TranscriptCall): void;
|
|
32
53
|
/** The call no longer waits (it had wire output, or its wait ended): it keeps its slot and its
|
|
@@ -35,14 +56,8 @@ export declare class AntigravityTranscript {
|
|
|
35
56
|
addRow(value: unknown): void;
|
|
36
57
|
/** Injected hook items read since the last drain. */
|
|
37
58
|
drainHooks(): UiHookItem[];
|
|
38
|
-
/** Subagent reply notices read since the last drain. */
|
|
39
|
-
drainChildMessages(): Array<{
|
|
40
|
-
childId: string;
|
|
41
|
-
body: string;
|
|
42
|
-
}>;
|
|
43
59
|
/** The call's result text once its row is read; reading it consumes it. */
|
|
44
60
|
output(id: string): string | undefined;
|
|
45
|
-
private addSystemRow;
|
|
46
61
|
private pair;
|
|
47
62
|
/** A row a call holds, or one a started call has yet to pair with. */
|
|
48
63
|
private wanted;
|
|
@@ -51,22 +66,29 @@ export declare class AntigravityTranscript {
|
|
|
51
66
|
/** A terminal tool update that carries no result: its output can come only from the transcript. */
|
|
52
67
|
export declare function transcriptCall(update: Record<string, unknown>): TranscriptCall | undefined;
|
|
53
68
|
/**
|
|
54
|
-
* Reads the session's transcript while a completed tool waits for its output,
|
|
55
|
-
*
|
|
69
|
+
* Reads the session's transcript while a completed tool waits for its output, and amends the tool
|
|
70
|
+
* card when the row appears. The row can land after the wire's completed update, so the read polls
|
|
71
|
+
* up to `TRANSCRIPT_WAIT_MS`. It reads only bytes appended since the session opened.
|
|
56
72
|
*/
|
|
57
73
|
export declare class AntigravityToolOutputs {
|
|
58
74
|
private readonly amend;
|
|
59
75
|
private readonly now;
|
|
60
76
|
private readonly onHook?;
|
|
61
77
|
private readonly readBytes;
|
|
62
|
-
private
|
|
63
|
-
private
|
|
78
|
+
private path;
|
|
79
|
+
private offset;
|
|
80
|
+
private tail;
|
|
81
|
+
private readonly decoder;
|
|
82
|
+
private skippingLine;
|
|
64
83
|
private broken;
|
|
84
|
+
private closed;
|
|
85
|
+
private hasMore;
|
|
86
|
+
private timer;
|
|
87
|
+
private reading;
|
|
65
88
|
private readonly transcript;
|
|
66
89
|
private readonly pending;
|
|
67
90
|
private readonly seen;
|
|
68
|
-
|
|
69
|
-
constructor(amend: (item: UiToolItem) => void, now?: () => number, onHook?: ((item: UiHookItem) => void) | undefined, readBytes?: number, subagents?: SubagentTranscriptHooks | undefined);
|
|
91
|
+
constructor(amend: (item: UiToolItem) => void, now?: () => number, onHook?: ((item: UiHookItem) => void) | undefined, readBytes?: number);
|
|
70
92
|
/** The session is open: read its transcript from its current end. */
|
|
71
93
|
open(path: string): void;
|
|
72
94
|
/** A wire update. A call takes its transcript slot when it first appears; a terminal update with
|
|
@@ -79,7 +101,11 @@ export declare class AntigravityToolOutputs {
|
|
|
79
101
|
poll(): Promise<void>;
|
|
80
102
|
/** Wait for any in-flight read, then drain unread exit bytes in bounded chunks. */
|
|
81
103
|
flush(): Promise<void>;
|
|
104
|
+
private schedule;
|
|
105
|
+
private next;
|
|
82
106
|
private expire;
|
|
83
107
|
private read;
|
|
84
|
-
private
|
|
108
|
+
private readAppended;
|
|
109
|
+
private lines;
|
|
85
110
|
}
|
|
111
|
+
export {};
|
|
@@ -1,23 +1,84 @@
|
|
|
1
|
+
import { statSync } from 'node:fs';
|
|
2
|
+
import { open } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
5
|
+
import { hookEventName, isVisibleHookItem } from '@hearsay-tools/squawk/plugin/runtime';
|
|
1
6
|
import { z } from '@hearsay-tools/squawk/plugin';
|
|
2
|
-
import {
|
|
3
|
-
import { BoundedJsonlTailer, NOT_RESULT_ROW_TYPES, TRANSCRIPT_MAX_FLUSH_CHUNKS, TRANSCRIPT_OUTPUT_CHARS, TRANSCRIPT_READ_BYTES, TranscriptPoller, antigravityTranscriptPath, transcriptCallKey, transcriptHookItem, transcriptResultText, transcriptRowSchema, } from './transcript-tailer.js';
|
|
4
|
-
export { TRANSCRIPT_OUTPUT_CHARS, antigravityTranscriptPath, transcriptHookItem, transcriptResultText };
|
|
7
|
+
import { ANTIGRAVITY_APP_DATA_DIR } from './launch-args.js';
|
|
5
8
|
/**
|
|
6
|
-
* The CLI 1.5.14
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* output (docs/runners/antigravity-wire.md).
|
|
9
|
+
* The CLI 1.5.14 ACP wire sends no result for a read, an MCP call or a subagent tool (the completed
|
|
10
|
+
* update has no `content`, `rawOutput` or `_meta`, hearsay-tools/squawk#4099) and carries no hook
|
|
11
|
+
* lifecycle frame. The CLI's own transcript keeps both tool results and injected hook messages
|
|
12
|
+
* (`SYSTEM_MESSAGE` rows with `source: "SYSTEM_SDK"`). It is a private format: every read is
|
|
13
|
+
* bounded, and a missing file or a changed format leaves no output (docs/runners/antigravity-wire.md).
|
|
12
14
|
*/
|
|
15
|
+
export const TRANSCRIPT_OUTPUT_CHARS = 64 * 1024;
|
|
16
|
+
const READ_BYTES = 4 * 1024 * 1024;
|
|
17
|
+
const MAX_FLUSH_CHUNKS = 8;
|
|
18
|
+
const LINE_BYTES = 8 * 1024 * 1024;
|
|
13
19
|
const POLL_MS = 250;
|
|
14
20
|
/** How long after a tool completes the runner looks for its row. */
|
|
15
21
|
export const TRANSCRIPT_WAIT_MS = 10_000;
|
|
22
|
+
/** Rows that never hold a tool's result. */
|
|
23
|
+
const NOT_RESULTS = new Set(['PLANNER_RESPONSE', 'USER_INPUT', 'SYSTEM_MESSAGE', 'CHECKPOINT']);
|
|
24
|
+
const HEADER = /^(?:Created|Completed) At: .*$/;
|
|
25
|
+
const SYSTEM_BLOCK = /(?:^|\n)<SYSTEM_MESSAGE>\r?\n([\s\S]*)\r?\n<\/SYSTEM_MESSAGE>\s*$/;
|
|
26
|
+
const HOOK_HEADER = /^The following system message was injected by an? ([A-Za-z][A-Za-z0-9_-]*) hook:\r?\n?([\s\S]*)$/;
|
|
27
|
+
const rowSchema = z.object({
|
|
28
|
+
step_index: z.number().int().nonnegative(), type: z.string(), source: z.string().optional(),
|
|
29
|
+
status: z.string().optional(), content: z.string().optional(), error: z.string().optional(),
|
|
30
|
+
tool_calls: z.array(z.object({ name: z.string(), args: z.unknown().optional() })).optional(),
|
|
31
|
+
});
|
|
32
|
+
export function antigravityTranscriptPath(geminiDir, sessionId) {
|
|
33
|
+
return join(geminiDir, ANTIGRAVITY_APP_DATA_DIR, 'brain', sessionId, '.system_generated', 'logs', 'transcript_full.jsonl');
|
|
34
|
+
}
|
|
35
|
+
/** A JSON value with object keys sorted, so two equal argument objects compare equal as text. */
|
|
36
|
+
function canonical(value) {
|
|
37
|
+
if (Array.isArray(value))
|
|
38
|
+
return `[${value.map(canonical).join(',')}]`;
|
|
39
|
+
if (value && typeof value === 'object') {
|
|
40
|
+
return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical(value[key])}`).join(',')}}`;
|
|
41
|
+
}
|
|
42
|
+
return JSON.stringify(value ?? null);
|
|
43
|
+
}
|
|
44
|
+
function boundOutput(text) {
|
|
45
|
+
return text.length > TRANSCRIPT_OUTPUT_CHARS ? `${text.slice(0, TRANSCRIPT_OUTPUT_CHARS)}\n… (output truncated by Squawk)` : text;
|
|
46
|
+
}
|
|
47
|
+
/** The text the agent received, without the CLI's `Created At:`/`Completed At:` lines, bounded. */
|
|
48
|
+
export function transcriptResultText(row) {
|
|
49
|
+
const lines = (row.content ?? '').split('\n');
|
|
50
|
+
let first = 0;
|
|
51
|
+
while (first < lines.length && HEADER.test(lines[first]))
|
|
52
|
+
first++;
|
|
53
|
+
const text = lines.slice(first).join('\n') || (row.error ?? '');
|
|
54
|
+
return boundOutput(text);
|
|
55
|
+
}
|
|
56
|
+
/** A `SYSTEM_SDK` `SYSTEM_MESSAGE` row injected by a native Antigravity hook, mapped to a hook item. */
|
|
57
|
+
export function transcriptHookItem(row) {
|
|
58
|
+
if (row.type !== 'SYSTEM_MESSAGE' || row.source !== 'SYSTEM_SDK')
|
|
59
|
+
return undefined;
|
|
60
|
+
const content = row.content ?? '';
|
|
61
|
+
const body = (SYSTEM_BLOCK.exec(content)?.[1] ?? content).trim();
|
|
62
|
+
const header = HOOK_HEADER.exec(body);
|
|
63
|
+
if (!header)
|
|
64
|
+
return undefined;
|
|
65
|
+
const status = row.status === 'ERROR' ? 'failed' : 'completed';
|
|
66
|
+
const text = header[2].trim();
|
|
67
|
+
const entries = text
|
|
68
|
+
? [{ kind: status === 'failed' ? 'error' : 'context', text: boundOutput(text) }]
|
|
69
|
+
: row.error?.trim() ? [{ kind: 'error', text: boundOutput(row.error.trim()) }] : [];
|
|
70
|
+
const item = { kind: 'hook', id: `hook_step_${row.step_index}`, event: hookEventName(header[1]), status, entries };
|
|
71
|
+
return isVisibleHookItem(item) ? item : undefined;
|
|
72
|
+
}
|
|
16
73
|
/** Result texts held at once; the oldest goes first. */
|
|
17
74
|
const HELD_RESULTS = 64;
|
|
18
75
|
/**
|
|
19
|
-
* Matches tool calls to their result rows, extracts injected hook `SYSTEM_MESSAGE` rows
|
|
20
|
-
*
|
|
76
|
+
* Matches tool calls to their result rows, and extracts injected hook `SYSTEM_MESSAGE` rows.
|
|
77
|
+
* A planner row lists the step's calls with the same `name` and `args` the wire sends, and the k-th
|
|
78
|
+
* call's result is the row `step_index + 1 + k`. Each call takes its slot when it starts, so the
|
|
79
|
+
* n-th started call with a name and arguments gets the n-th planned one: neither the order calls
|
|
80
|
+
* complete in nor a call that stopped waiting moves another call's result. Only results a waiting
|
|
81
|
+
* call can still take are held.
|
|
21
82
|
*/
|
|
22
83
|
export class AntigravityTranscript {
|
|
23
84
|
/** Per call key: planned result steps, and started calls, that have no partner yet. */
|
|
@@ -28,11 +89,9 @@ export class AntigravityTranscript {
|
|
|
28
89
|
results = new Map();
|
|
29
90
|
hooks = [];
|
|
30
91
|
seenHooks = new Set();
|
|
31
|
-
childMessages = [];
|
|
32
|
-
seenMessages = new Set();
|
|
33
92
|
/** A call started on the wire: it takes the next planned slot of its name and arguments. */
|
|
34
93
|
start(call) {
|
|
35
|
-
const key =
|
|
94
|
+
const key = callKey(call.name, call.args);
|
|
36
95
|
this.started.set(key, [...this.started.get(key) ?? [], call.id]);
|
|
37
96
|
this.pair(key);
|
|
38
97
|
}
|
|
@@ -48,27 +107,31 @@ export class AntigravityTranscript {
|
|
|
48
107
|
this.results.delete(step);
|
|
49
108
|
}
|
|
50
109
|
addRow(value) {
|
|
51
|
-
const row =
|
|
110
|
+
const row = rowSchema.safeParse(value);
|
|
52
111
|
if (!row.success)
|
|
53
112
|
return;
|
|
54
113
|
const { step_index: step, type, tool_calls: calls } = row.data;
|
|
55
114
|
if (type === 'PLANNER_RESPONSE') {
|
|
56
115
|
calls?.forEach((call, index) => {
|
|
57
|
-
const key =
|
|
116
|
+
const key = callKey(call.name, call.args);
|
|
58
117
|
this.planned.set(key, [...this.planned.get(key) ?? [], step + 1 + index]);
|
|
59
118
|
this.pair(key);
|
|
60
119
|
});
|
|
61
120
|
}
|
|
62
121
|
else if (type === 'SYSTEM_MESSAGE') {
|
|
63
|
-
|
|
122
|
+
const hook = transcriptHookItem(row.data);
|
|
123
|
+
if (hook && !this.seenHooks.has(step)) {
|
|
124
|
+
this.seenHooks.add(step);
|
|
125
|
+
this.hooks.push(hook);
|
|
126
|
+
}
|
|
64
127
|
}
|
|
65
|
-
else if (!
|
|
128
|
+
else if (!NOT_RESULTS.has(type) && this.wanted(step))
|
|
66
129
|
this.hold(step, transcriptResultText(row.data));
|
|
67
130
|
}
|
|
68
131
|
/** Injected hook items read since the last drain. */
|
|
69
|
-
drainHooks() {
|
|
70
|
-
|
|
71
|
-
|
|
132
|
+
drainHooks() {
|
|
133
|
+
return this.hooks.splice(0);
|
|
134
|
+
}
|
|
72
135
|
/** The call's result text once its row is read; reading it consumes it. */
|
|
73
136
|
output(id) {
|
|
74
137
|
const step = this.steps.get(id);
|
|
@@ -79,21 +142,6 @@ export class AntigravityTranscript {
|
|
|
79
142
|
this.results.delete(step);
|
|
80
143
|
return text;
|
|
81
144
|
}
|
|
82
|
-
addSystemRow(row) {
|
|
83
|
-
const hook = transcriptHookItem(row);
|
|
84
|
-
if (hook && !this.seenHooks.has(row.step_index)) {
|
|
85
|
-
this.seenHooks.add(row.step_index);
|
|
86
|
-
this.hooks.push(hook);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (row.source !== 'SYSTEM' || !row.content || this.seenMessages.has(row.step_index))
|
|
90
|
-
return;
|
|
91
|
-
const delivery = parseChildMessageDelivery(row.content);
|
|
92
|
-
if (delivery) {
|
|
93
|
-
this.seenMessages.add(row.step_index);
|
|
94
|
-
this.childMessages.push(delivery);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
145
|
pair(key) {
|
|
98
146
|
const planned = this.planned.get(key) ?? [];
|
|
99
147
|
const started = this.started.get(key) ?? [];
|
|
@@ -131,6 +179,7 @@ export class AntigravityTranscript {
|
|
|
131
179
|
}
|
|
132
180
|
}
|
|
133
181
|
}
|
|
182
|
+
function callKey(name, args) { return `${name}\u0000${canonical(args ?? {})}`; }
|
|
134
183
|
const wireSchema = z.object({
|
|
135
184
|
sessionUpdate: z.enum(['tool_call', 'tool_call_update']), toolCallId: z.string(), name: z.string(),
|
|
136
185
|
args: z.unknown().optional(), rawInput: z.unknown().optional(),
|
|
@@ -149,42 +198,50 @@ export function transcriptCall(update) {
|
|
|
149
198
|
return wireCall(update);
|
|
150
199
|
}
|
|
151
200
|
/**
|
|
152
|
-
* Reads the session's transcript while a completed tool waits for its output,
|
|
153
|
-
*
|
|
201
|
+
* Reads the session's transcript while a completed tool waits for its output, and amends the tool
|
|
202
|
+
* card when the row appears. The row can land after the wire's completed update, so the read polls
|
|
203
|
+
* up to `TRANSCRIPT_WAIT_MS`. It reads only bytes appended since the session opened.
|
|
154
204
|
*/
|
|
155
205
|
export class AntigravityToolOutputs {
|
|
156
206
|
amend;
|
|
157
207
|
now;
|
|
158
208
|
onHook;
|
|
159
209
|
readBytes;
|
|
160
|
-
|
|
161
|
-
|
|
210
|
+
path;
|
|
211
|
+
offset = 0;
|
|
212
|
+
tail = '';
|
|
213
|
+
decoder = new StringDecoder('utf8');
|
|
214
|
+
skippingLine = false;
|
|
162
215
|
broken = false;
|
|
216
|
+
closed = false;
|
|
217
|
+
hasMore = false;
|
|
218
|
+
timer;
|
|
219
|
+
reading;
|
|
163
220
|
transcript = new AntigravityTranscript();
|
|
164
221
|
pending = new Map();
|
|
165
222
|
seen = new Set();
|
|
166
|
-
|
|
167
|
-
constructor(amend, now = Date.now, onHook, readBytes = TRANSCRIPT_READ_BYTES, subagents) {
|
|
223
|
+
constructor(amend, now = Date.now, onHook, readBytes = READ_BYTES) {
|
|
168
224
|
this.amend = amend;
|
|
169
225
|
this.now = now;
|
|
170
226
|
this.onHook = onHook;
|
|
171
227
|
this.readBytes = readBytes;
|
|
172
|
-
this.subagents = subagents;
|
|
173
|
-
this.poller = new TranscriptPoller(() => this.read(), () => {
|
|
174
|
-
this.expire();
|
|
175
|
-
return Boolean(this.onHook || this.subagents || [...this.pending.values()].some(pending => pending.item || pending.spawn));
|
|
176
|
-
}, POLL_MS, () => { this.broken = true; this.pending.clear(); });
|
|
177
228
|
}
|
|
178
229
|
/** The session is open: read its transcript from its current end. */
|
|
179
230
|
open(path) {
|
|
180
|
-
this.
|
|
181
|
-
|
|
182
|
-
this.
|
|
231
|
+
this.path = path;
|
|
232
|
+
try {
|
|
233
|
+
this.offset = statSync(path).size;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
this.offset = 0;
|
|
237
|
+
}
|
|
238
|
+
if (this.onHook)
|
|
239
|
+
this.schedule(POLL_MS);
|
|
183
240
|
}
|
|
184
241
|
/** A wire update. A call takes its transcript slot when it first appears; a terminal update with
|
|
185
242
|
* no result starts the wait for its row, and one with a result gives the slot up. */
|
|
186
243
|
observe(update) {
|
|
187
|
-
if (this.
|
|
244
|
+
if (this.closed || this.broken || !this.path)
|
|
188
245
|
return;
|
|
189
246
|
const call = wireCall(update);
|
|
190
247
|
if (!call)
|
|
@@ -195,40 +252,54 @@ export class AntigravityToolOutputs {
|
|
|
195
252
|
}
|
|
196
253
|
if (!TERMINAL.has(update.status))
|
|
197
254
|
return;
|
|
198
|
-
if (
|
|
199
|
-
this.
|
|
200
|
-
|
|
255
|
+
if (transcriptCall(update)) {
|
|
256
|
+
if (!this.pending.has(call.id))
|
|
257
|
+
this.pending.set(call.id, { call, deadline: this.now() + TRANSCRIPT_WAIT_MS });
|
|
201
258
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.pending.set(call.id, { call, spawn, deadline: this.now() + TRANSCRIPT_WAIT_MS });
|
|
205
|
-
if (spawn)
|
|
206
|
-
this.poller.schedule(0);
|
|
259
|
+
else
|
|
260
|
+
this.transcript.drop(call.id);
|
|
207
261
|
}
|
|
208
262
|
/** The mapped tool item closed with no output: amend it once its row is read. */
|
|
209
263
|
completed(item) {
|
|
210
264
|
const pending = this.pending.get(item.id);
|
|
211
|
-
if (!pending
|
|
265
|
+
if (!pending)
|
|
212
266
|
return;
|
|
213
267
|
if (item.output) {
|
|
214
268
|
this.pending.delete(item.id);
|
|
215
269
|
return;
|
|
216
270
|
}
|
|
217
271
|
pending.item = item;
|
|
218
|
-
this.
|
|
272
|
+
this.schedule(0);
|
|
219
273
|
}
|
|
220
|
-
close() { this.
|
|
274
|
+
close() { this.closed = true; clearTimeout(this.timer); this.pending.clear(); }
|
|
221
275
|
/** One read of appended rows, then amend what resolved. Tests call it directly. */
|
|
222
|
-
poll() {
|
|
276
|
+
poll() {
|
|
277
|
+
this.reading ??= this.read().catch(() => { this.broken = true; this.pending.clear(); }).finally(() => { this.reading = undefined; });
|
|
278
|
+
return this.reading;
|
|
279
|
+
}
|
|
223
280
|
/** Wait for any in-flight read, then drain unread exit bytes in bounded chunks. */
|
|
224
281
|
async flush() {
|
|
225
|
-
|
|
226
|
-
|
|
282
|
+
clearTimeout(this.timer);
|
|
283
|
+
this.timer = undefined;
|
|
284
|
+
while (this.reading)
|
|
285
|
+
await this.reading;
|
|
286
|
+
for (let chunk = 0; chunk < MAX_FLUSH_CHUNKS && !this.closed && !this.broken && this.path; chunk++) {
|
|
227
287
|
await this.poll();
|
|
228
|
-
if (!this.
|
|
288
|
+
if (!this.hasMore)
|
|
229
289
|
break;
|
|
230
290
|
}
|
|
231
291
|
}
|
|
292
|
+
schedule(delay) {
|
|
293
|
+
if (this.closed || this.timer)
|
|
294
|
+
return;
|
|
295
|
+
this.timer = setTimeout(() => { this.timer = undefined; void this.poll().then(() => this.next()); }, delay);
|
|
296
|
+
this.timer.unref?.();
|
|
297
|
+
}
|
|
298
|
+
next() {
|
|
299
|
+
this.expire();
|
|
300
|
+
if (this.onHook || [...this.pending.values()].some(pending => pending.item))
|
|
301
|
+
this.schedule(POLL_MS);
|
|
302
|
+
}
|
|
232
303
|
expire() {
|
|
233
304
|
const now = this.now();
|
|
234
305
|
for (const [id, pending] of this.pending)
|
|
@@ -238,36 +309,69 @@ export class AntigravityToolOutputs {
|
|
|
238
309
|
}
|
|
239
310
|
}
|
|
240
311
|
async read() {
|
|
241
|
-
if (this.
|
|
312
|
+
if (this.closed || this.broken || !this.path)
|
|
242
313
|
return;
|
|
243
314
|
this.expire();
|
|
244
|
-
await this.
|
|
315
|
+
await this.readAppended(this.path);
|
|
245
316
|
for (const hook of this.transcript.drainHooks())
|
|
246
|
-
if (!this.
|
|
317
|
+
if (!this.closed)
|
|
247
318
|
this.onHook?.(hook);
|
|
248
|
-
for (const [id, pending] of this.pending)
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
319
|
+
for (const [id, pending] of this.pending) {
|
|
320
|
+
if (!pending.item)
|
|
321
|
+
continue;
|
|
322
|
+
const output = this.transcript.output(id);
|
|
323
|
+
if (output === undefined)
|
|
324
|
+
continue;
|
|
325
|
+
this.pending.delete(id);
|
|
326
|
+
if (output && !this.closed)
|
|
327
|
+
this.amend({ ...pending.item, output });
|
|
253
328
|
}
|
|
254
329
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (this.poller.closed)
|
|
330
|
+
async readAppended(path) {
|
|
331
|
+
let file;
|
|
332
|
+
try {
|
|
333
|
+
file = await open(path, 'r');
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
this.hasMore = false;
|
|
263
337
|
return;
|
|
264
|
-
if (pending.spawn) {
|
|
265
|
-
const childId = parseSpawnedSubagentId(output);
|
|
266
|
-
if (childId)
|
|
267
|
-
this.subagents?.onSpawn?.(id, childId);
|
|
268
338
|
}
|
|
269
|
-
|
|
270
|
-
|
|
339
|
+
try {
|
|
340
|
+
const { size } = await file.stat();
|
|
341
|
+
if (size <= this.offset) {
|
|
342
|
+
this.hasMore = false;
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const length = Math.min(size - this.offset, this.readBytes);
|
|
346
|
+
const buffer = Buffer.alloc(length);
|
|
347
|
+
const { bytesRead } = await file.read(buffer, 0, length, this.offset);
|
|
348
|
+
this.offset += bytesRead;
|
|
349
|
+
this.hasMore = bytesRead > 0 && this.offset < size;
|
|
350
|
+
this.lines(this.decoder.write(buffer.subarray(0, bytesRead)));
|
|
351
|
+
}
|
|
352
|
+
finally {
|
|
353
|
+
await file.close();
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
lines(chunk) {
|
|
357
|
+
const lines = (this.tail + chunk).split('\n');
|
|
358
|
+
this.tail = lines.pop() ?? '';
|
|
359
|
+
for (const line of lines) {
|
|
360
|
+
if (this.skippingLine) {
|
|
361
|
+
this.skippingLine = false;
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (!line.trim())
|
|
365
|
+
continue;
|
|
366
|
+
try {
|
|
367
|
+
this.transcript.addRow(JSON.parse(line));
|
|
368
|
+
}
|
|
369
|
+
catch { /* A row the format no longer matches has no output. */ }
|
|
370
|
+
}
|
|
371
|
+
// A row past the bound is dropped; reading resumes at the next line.
|
|
372
|
+
if (this.tail.length > LINE_BYTES) {
|
|
373
|
+
this.tail = '';
|
|
374
|
+
this.skippingLine = true;
|
|
271
375
|
}
|
|
272
376
|
}
|
|
273
377
|
}
|