@hearsay-tools/squawk 0.18.0-dev.7764 → 0.18.0-dev.7779
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 +46 -46
- package/dist/cli-dispatch.js +2 -1
- package/dist/cli-dispatch.js.map +1 -1
- package/dist/contract/index.js +2 -1
- package/dist/core/backend-detect.js +3 -3
- package/dist/core/backend-detect.js.map +1 -1
- package/dist/core/runner-definition.d.ts +8 -1
- package/dist/core/runner-definition.js.map +1 -1
- package/dist/delegation/routes.d.ts +80 -80
- package/dist/delegation/transport.d.ts +65 -65
- package/dist/managed-install/runtime-home.d.ts +8 -0
- package/dist/managed-install/runtime-home.js +14 -0
- package/dist/managed-install/runtime-home.js.map +1 -0
- package/dist/runners/acp/events.d.ts +15 -0
- package/dist/runners/acp/events.js +58 -2
- package/dist/runners/acp/events.js.map +1 -1
- package/dist/runners/acp/protocol.d.ts +10 -2
- package/dist/runners/acp/session.d.ts +11 -3
- package/dist/runners/acp/session.js +48 -16
- package/dist/runners/acp/session.js.map +1 -1
- package/dist/runners/acp/usage.d.ts +3 -0
- package/dist/runners/acp/usage.js +12 -0
- package/dist/runners/acp/usage.js.map +1 -0
- package/dist/runners/antigravity/account-home.js +1 -1
- package/dist/runners/antigravity/account-home.js.map +1 -1
- package/dist/runners/antigravity/accounts.d.ts +1 -1
- package/dist/runners/antigravity/accounts.js +1 -1
- package/dist/runners/antigravity/accounts.js.map +1 -1
- package/dist/runners/antigravity/antigravity-model-catalog.d.ts +4 -2
- package/dist/runners/antigravity/antigravity-model-catalog.js +25 -20
- package/dist/runners/antigravity/antigravity-model-catalog.js.map +1 -1
- package/dist/runners/antigravity/antigravity-runner.d.ts +6 -6
- package/dist/runners/antigravity/antigravity-runner.js +3 -2
- package/dist/runners/antigravity/antigravity-runner.js.map +1 -1
- package/dist/runners/antigravity/antigravity-session.d.ts +27 -2
- package/dist/runners/antigravity/antigravity-session.js +204 -96
- package/dist/runners/antigravity/antigravity-session.js.map +1 -1
- package/dist/runners/antigravity/antigravity-skill-catalog.d.ts +2 -2
- package/dist/runners/antigravity/antigravity-skill-catalog.js +6 -4
- package/dist/runners/antigravity/antigravity-skill-catalog.js.map +1 -1
- package/dist/runners/antigravity/antigravity-ui-mapper.d.ts +5 -3
- package/dist/runners/antigravity/antigravity-ui-mapper.js +27 -12
- package/dist/runners/antigravity/antigravity-ui-mapper.js.map +1 -1
- package/dist/runners/antigravity/ask-question.d.ts +9 -0
- package/dist/runners/antigravity/ask-question.js +37 -0
- package/dist/runners/antigravity/ask-question.js.map +1 -0
- package/dist/runners/antigravity/browser-sign-in.d.ts +8 -2
- package/dist/runners/antigravity/browser-sign-in.js +100 -122
- package/dist/runners/antigravity/browser-sign-in.js.map +1 -1
- package/dist/runners/antigravity/definition.js +3 -2
- package/dist/runners/antigravity/definition.js.map +1 -1
- package/dist/runners/antigravity/detection.d.ts +6 -4
- package/dist/runners/antigravity/detection.js +8 -5
- package/dist/runners/antigravity/detection.js.map +1 -1
- package/dist/runners/antigravity/display.d.ts +3 -3
- package/dist/runners/antigravity/display.js +2 -2
- package/dist/runners/antigravity/display.js.map +1 -1
- package/dist/runners/antigravity/executable.d.ts +45 -0
- package/dist/runners/antigravity/executable.js +184 -0
- package/dist/runners/antigravity/executable.js.map +1 -0
- package/dist/runners/antigravity/facts.d.ts +4 -4
- package/dist/runners/antigravity/facts.js +10 -5
- package/dist/runners/antigravity/facts.js.map +1 -1
- package/dist/runners/antigravity/launch-args.d.ts +4 -2
- package/dist/runners/antigravity/launch-args.js +5 -4
- package/dist/runners/antigravity/launch-args.js.map +1 -1
- package/dist/runners/antigravity/login-probe.d.ts +6 -1
- package/dist/runners/antigravity/login-probe.js +41 -19
- package/dist/runners/antigravity/login-probe.js.map +1 -1
- package/dist/runners/antigravity/login.d.ts +1 -1
- package/dist/runners/antigravity/login.js +1 -1
- package/dist/runners/antigravity/login.js.map +1 -1
- package/dist/runners/antigravity/mock.d.ts +24 -13
- package/dist/runners/antigravity/mock.js +19 -15
- package/dist/runners/antigravity/mock.js.map +1 -1
- package/dist/runners/antigravity/native-diagnostics.d.ts +3 -2
- package/dist/runners/antigravity/native-diagnostics.js +9 -6
- package/dist/runners/antigravity/native-diagnostics.js.map +1 -1
- package/dist/runners/antigravity/permissions.d.ts +2 -3
- package/dist/runners/antigravity/permissions.js +1 -32
- package/dist/runners/antigravity/permissions.js.map +1 -1
- package/dist/runners/antigravity/probe-process.d.ts +4 -1
- package/dist/runners/antigravity/probe-process.js +21 -5
- package/dist/runners/antigravity/probe-process.js.map +1 -1
- package/dist/runners/antigravity/runtime-env.d.ts +4 -3
- package/dist/runners/antigravity/runtime-env.js +14 -26
- package/dist/runners/antigravity/runtime-env.js.map +1 -1
- package/dist/runners/antigravity/spec-support.js +8 -8
- package/dist/runners/antigravity/spec-support.js.map +1 -1
- package/dist/runners/antigravity/tool-normalization.d.ts +6 -2
- package/dist/runners/antigravity/tool-normalization.js +23 -12
- package/dist/runners/antigravity/tool-normalization.js.map +1 -1
- package/dist/runners/antigravity/wire-updates.d.ts +14 -1
- package/dist/runners/antigravity/wire-updates.js +21 -6
- package/dist/runners/antigravity/wire-updates.js.map +1 -1
- package/dist/runs/lifecycle.d.ts +1 -1
- package/dist/runs/ports.d.ts +0 -11
- package/dist/runs/store.d.ts +2 -3
- package/dist/runs/store.js +5 -22
- package/dist/runs/store.js.map +1 -1
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/project-context.js +3 -3
- package/dist/server/project-context.js.map +1 -1
- package/dist/server/provider-sign-in-routes.d.ts +2 -2
- package/dist/server/provider-sign-in-routes.js +1 -1
- package/dist/server/provider-sign-in-routes.js.map +1 -1
- package/dist/server/runner-install-routes.d.ts +10 -10
- package/dist/server/server.d.ts +1652 -1652
- package/package.json +4 -4
- package/scripts/mock-acp-login.mjs +20 -0
- package/scripts/mock-acp-sessions.mjs +30 -0
- package/scripts/mock-acp.mjs +128 -79
- package/scripts/mock-antigravity-auth.mjs +39 -37
- package/web/dist/assets/{activity-motion-BSsgWgJe.js → activity-motion-CMaQA87f.js} +1 -1
- package/web/dist/assets/{activity-route-q9sOR4Wb.js → activity-route-CTJT4zv2.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-Btiebm6D.js → commit-diff-panel-BoK-qLXZ.js} +1 -1
- package/web/dist/assets/{diff-DNIkChMc.js → diff-BHFOGiZQ.js} +2 -2
- package/web/dist/assets/{diff-view-jhjgH27W.js → diff-view-BcEpsdxN.js} +1 -1
- package/web/dist/assets/{file-preview-De5UjJTG.js → file-preview-DQmUdQku.js} +1 -1
- package/web/dist/assets/{git-toolbar-Ol1142ti.js → git-toolbar-CIMGnrx-.js} +1 -1
- package/web/dist/assets/{github-BylUlaAL.js → github-DNt7fatG.js} +1 -1
- package/web/dist/assets/{global-activity-route-DI3QqvQL.js → global-activity-route-DvJfgzVz.js} +1 -1
- package/web/dist/assets/{index-Dbb0-RtK.js → index-Bcs60T3F.js} +4 -4
- package/web/dist/assets/{markdown-D3aDM4O5.js → markdown-C78nwKGh.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-C-f5rJGZ.js → preview-pane-connected-DAkxP33O.js} +1 -1
- package/web/dist/assets/{repo-git-D-j1tyQj.js → repo-git-DTINuV7R.js} +1 -1
- package/web/dist/assets/{report-reader-0-k8FTCM.js → report-reader-TsL5jS1q.js} +1 -1
- package/web/dist/assets/{reports--2BDXGSj.js → reports-MBONm90i.js} +1 -1
- package/web/dist/assets/{run-header-B69_lBSt.js → run-header-BbuegkrJ.js} +1 -1
- package/web/dist/assets/{skills-CzyYKL6l.js → skills-Cc2FsHZq.js} +1 -1
- package/web/dist/assets/{task-changes-D1Oi0yoX.js → task-changes-Bis3iY6D.js} +1 -1
- package/web/dist/assets/{task-commits-DV91fVHF.js → task-commits-CELN07IE.js} +1 -1
- package/web/dist/assets/{task-files-_ap-MUjL.js → task-files-Xj9SbIQY.js} +1 -1
- package/web/dist/assets/{task-github-item-9oibIBa8.js → task-github-item-8Wi29msX.js} +1 -1
- package/web/dist/assets/{task-thread-D8IfseH4.js → task-thread-BpprgiEm.js} +1 -1
- package/web/dist/assets/{thread-state-BLS3a1XA.js → thread-state-DjdzGdTP.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-DaPTyzCV.js → use-hand-to-agent-state-BrTzbU6r.js} +1 -1
- package/web/dist/assets/{workflows-BAIP3wxi.js → workflows-BgbhcFeb.js} +1 -1
- package/web/dist/index.html +1 -1
- package/dist/runners/antigravity/build-label.d.ts +0 -2
- package/dist/runners/antigravity/build-label.js +0 -32
- package/dist/runners/antigravity/build-label.js.map +0 -1
- package/dist/runners/antigravity/catalog-home.d.ts +0 -2
- package/dist/runners/antigravity/catalog-home.js +0 -23
- package/dist/runners/antigravity/catalog-home.js.map +0 -1
- package/dist/runners/antigravity/stderr.d.ts +0 -2
- package/dist/runners/antigravity/stderr.js +0 -15
- package/dist/runners/antigravity/stderr.js.map +0 -1
|
@@ -6,6 +6,7 @@ export declare class AntigravitySession implements AgentSession {
|
|
|
6
6
|
private readonly options;
|
|
7
7
|
readonly result: Promise<AgentRunResult>;
|
|
8
8
|
private readonly runtime;
|
|
9
|
+
private readonly launch;
|
|
9
10
|
private readonly child;
|
|
10
11
|
private readonly descendants;
|
|
11
12
|
private readonly acp;
|
|
@@ -15,35 +16,55 @@ export declare class AntigravitySession implements AgentSession {
|
|
|
15
16
|
private readonly queue;
|
|
16
17
|
private bridge;
|
|
17
18
|
private ready;
|
|
19
|
+
/** session/resume failed and a fresh session continues the task. */
|
|
20
|
+
private lostSession;
|
|
18
21
|
private inflight;
|
|
19
22
|
private get busy();
|
|
20
23
|
private providerError;
|
|
21
24
|
private accepting;
|
|
22
25
|
private requestedClose;
|
|
26
|
+
private quiet;
|
|
27
|
+
private quietTimer;
|
|
23
28
|
private interrupted;
|
|
24
29
|
private timedOut;
|
|
25
30
|
private failure;
|
|
31
|
+
/** The open ask_question call: its card's request id and question. The next prompt answers it. */
|
|
26
32
|
private pendingAsk;
|
|
27
33
|
private humanAcks;
|
|
28
34
|
private agentAcks;
|
|
29
35
|
private reportedFailure;
|
|
30
36
|
private failedTurn;
|
|
31
37
|
private readonly humanHolds;
|
|
32
|
-
private readonly steers;
|
|
33
38
|
private configOptions;
|
|
34
39
|
private autoEnd;
|
|
35
40
|
private term;
|
|
36
41
|
private kill;
|
|
37
42
|
private deadline;
|
|
38
43
|
private readonly limit;
|
|
39
|
-
constructor(bin: string, spec: AgentRunSpec, onEvent: ((event: AgentEvent) => void) | undefined, options: SessionOptions, timeoutMs?: number);
|
|
44
|
+
constructor(bin: string | undefined, spec: AgentRunSpec, onEvent: ((event: AgentEvent) => void) | undefined, options: SessionOptions, timeoutMs?: number);
|
|
40
45
|
get pid(): number | undefined;
|
|
41
46
|
get open(): boolean;
|
|
47
|
+
get closingQuietly(): boolean;
|
|
42
48
|
private emit;
|
|
43
49
|
private createAcp;
|
|
50
|
+
private uiEvent;
|
|
51
|
+
/** A failed turn is held until the session reports the failure. One the agent started on its
|
|
52
|
+
* own has no prompt that rejects, so it fails the session here, as a failed prompt does. */
|
|
53
|
+
private failedTurnEnded;
|
|
54
|
+
/** ask_question ends the prompt with the question as text; the next prompt is the answer. */
|
|
55
|
+
private openAsk;
|
|
44
56
|
private boot;
|
|
57
|
+
/** A session the CLI cannot reopen (one the retired registry server saved, or a removed
|
|
58
|
+
* conversation) continues in a fresh session, with the full system prompt and the skill. */
|
|
59
|
+
private openSession;
|
|
60
|
+
/** `onAcknowledged` runs when the CLI takes the input: a steer when the running prompt answers
|
|
61
|
+
* for it, any prompt at its own response. */
|
|
62
|
+
/** A resumed session carries spec.systemPrompt in its opening turn, as the other in-thread
|
|
63
|
+
* runners do: the CLI keeps the session/new prompt, and a resent _meta prompt would be appended. */
|
|
64
|
+
private opening;
|
|
45
65
|
private submit;
|
|
46
66
|
sendMessage(content: ContentBlock[]): boolean;
|
|
67
|
+
/** The card's answer becomes the next prompt, in the words the CLI's own question offered. */
|
|
47
68
|
private answerAsk;
|
|
48
69
|
private releaseHuman;
|
|
49
70
|
sendAgentMessage(content: ContentBlock[]): false | Promise<void>;
|
|
@@ -51,6 +72,10 @@ export declare class AntigravitySession implements AgentSession {
|
|
|
51
72
|
discardQueuedMessages(): void;
|
|
52
73
|
holdsHumanInput(): boolean;
|
|
53
74
|
heldHumanInputCount(): number;
|
|
75
|
+
/** A background command or timer can wake the idle session and ask after a done: stay up
|
|
76
|
+
* AUTO_END_DELAY_MS for that, and end once no turn it opened still runs. */
|
|
77
|
+
endWhenQuiet(): void;
|
|
78
|
+
private armQuietEnd;
|
|
54
79
|
end(): void;
|
|
55
80
|
private beginClose;
|
|
56
81
|
private closeInput;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { filterAntigravityUpdate, antigravityUpdateError } from './wire-updates.js';
|
|
2
|
-
import { askPayloadOf } from '../../contract/index.js';
|
|
3
1
|
import { rm } from 'node:fs/promises';
|
|
4
2
|
import { z } from 'zod';
|
|
5
|
-
import { SessionEndedBeforeAcknowledgement } from '../../core/agent-runner-values.js';
|
|
3
|
+
import { prependSystemPrompt, SessionEndedBeforeAcknowledgement } from '../../core/agent-runner-values.js';
|
|
6
4
|
import { openingContent, validSkillMessage } from '../../core/skill-trigger.js';
|
|
7
5
|
import { spawnSessionLeader, signalSession } from '../../core/session-process.js';
|
|
8
6
|
import { SessionDescendants } from '../../core/session-descendants.js';
|
|
9
7
|
import { AUTO_END_DELAY_MS, boundOutputDrainAfterExit, DEFAULT_RUNNER_TIMINGS } from '../../core/runner-runtime.js';
|
|
10
8
|
import { AcpSession } from '../acp/session.js';
|
|
9
|
+
import { AcpRpcError } from '../acp/transport.js';
|
|
11
10
|
import { antigravityEnv } from './runtime-env.js';
|
|
12
11
|
import { antigravityMcp } from './http-mcp.js';
|
|
13
12
|
import { ANTIGRAVITY_MCP_NAME } from './mcp-name.js';
|
|
14
|
-
import {
|
|
15
|
-
import { antigravityAsk, permissionPolicy } from './permissions.js';
|
|
13
|
+
import { permissionPolicy } from './permissions.js';
|
|
16
14
|
import { squawkToolNames } from '../../ci-wait/tool-catalog.js';
|
|
17
15
|
import { productEnv } from '../../core/product-env.js';
|
|
18
16
|
import { antigravityReadFile } from './client-files.js';
|
|
19
17
|
import { antigravityUsage } from './usage.js';
|
|
20
18
|
import { summarizeRunnerStderr } from '../../core/runner-stderr.js';
|
|
21
|
-
import { antigravityStderr } from './stderr.js';
|
|
22
19
|
import { antigravityLaunchArgs } from './launch-args.js';
|
|
23
20
|
import { logAntigravityFailure, redactAntigravityDiagnostics } from './native-diagnostics.js';
|
|
21
|
+
import { ANTIGRAVITY_WIRE_HOOKS, antigravityUpdateError } from './wire-updates.js';
|
|
22
|
+
import { ANTIGRAVITY_MISSING, launchAntigravity, missingAntigravity } from './executable.js';
|
|
23
|
+
import { antigravityQuestion, antigravityAnswer } from './ask-question.js';
|
|
24
24
|
const configSchema = z.array(z.object({ id: z.string(), category: z.string().optional() }).passthrough());
|
|
25
25
|
function contentBlocks(content) {
|
|
26
26
|
return content.filter(block => !(content[0]?.type === 'skill' && block.type === 'text' && !block.text)).map(block => {
|
|
@@ -38,6 +38,7 @@ export class AntigravitySession {
|
|
|
38
38
|
options;
|
|
39
39
|
result;
|
|
40
40
|
runtime;
|
|
41
|
+
launch;
|
|
41
42
|
child;
|
|
42
43
|
descendants;
|
|
43
44
|
acp;
|
|
@@ -47,21 +48,25 @@ export class AntigravitySession {
|
|
|
47
48
|
queue = [];
|
|
48
49
|
bridge;
|
|
49
50
|
ready = false;
|
|
51
|
+
/** session/resume failed and a fresh session continues the task. */
|
|
52
|
+
lostSession = false;
|
|
50
53
|
inflight = 0;
|
|
51
54
|
get busy() { return this.inflight > 0; }
|
|
52
55
|
providerError;
|
|
53
56
|
accepting = true;
|
|
54
57
|
requestedClose = false;
|
|
58
|
+
quiet = false;
|
|
59
|
+
quietTimer;
|
|
55
60
|
interrupted = false;
|
|
56
61
|
timedOut = false;
|
|
57
62
|
failure;
|
|
63
|
+
/** The open ask_question call: its card's request id and question. The next prompt answers it. */
|
|
58
64
|
pendingAsk;
|
|
59
65
|
humanAcks = 0;
|
|
60
66
|
agentAcks = 0;
|
|
61
67
|
reportedFailure = false;
|
|
62
68
|
failedTurn;
|
|
63
69
|
humanHolds = new Set();
|
|
64
|
-
steers = new Map();
|
|
65
70
|
configOptions;
|
|
66
71
|
autoEnd;
|
|
67
72
|
term;
|
|
@@ -72,23 +77,35 @@ export class AntigravitySession {
|
|
|
72
77
|
this.spec = spec;
|
|
73
78
|
this.onEvent = onEvent;
|
|
74
79
|
this.options = options;
|
|
75
|
-
this.runtime = antigravityEnv(
|
|
76
|
-
this.
|
|
80
|
+
this.runtime = antigravityEnv(spec);
|
|
81
|
+
this.launch = launchAntigravity(bin) ?? missingAntigravity(this.runtime.temp);
|
|
82
|
+
this.child = spawnSessionLeader(this.launch.executable, antigravityLaunchArgs(this.runtime.geminiDir), { cwd: spec.cwd, env: this.runtime.env, scope: spec.scope, timings: spec.timings });
|
|
83
|
+
try {
|
|
84
|
+
if (this.child.pid)
|
|
85
|
+
this.launch.bindProcess(this.child.pid);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
this.failure = error instanceof Error ? error : new Error(String(error));
|
|
89
|
+
}
|
|
77
90
|
this.descendants = new SessionDescendants(this.child);
|
|
78
91
|
boundOutputDrainAfterExit(this.child);
|
|
79
92
|
this.acp = this.createAcp();
|
|
80
93
|
this.child.stderr.setEncoding('utf8');
|
|
81
94
|
this.child.stderr.on('data', (chunk) => { this.stderr = (this.stderr + chunk).slice(-32_768); });
|
|
82
|
-
this.child.on('error', error => {
|
|
95
|
+
this.child.on('error', error => {
|
|
96
|
+
this.failure = new Error(error.code === 'ENOENT' ? ANTIGRAVITY_MISSING : error.message);
|
|
97
|
+
this.acp.transport.close(error);
|
|
98
|
+
});
|
|
83
99
|
this.exited = new Promise(resolve => this.child.once('close', resolve));
|
|
84
100
|
this.limit = spec.timeoutMs ?? timeoutMs ?? spec.timings?.runTimeoutMs ?? DEFAULT_RUNNER_TIMINGS.runTimeoutMs;
|
|
85
101
|
if (this.limit > 0)
|
|
86
102
|
this.deadline = setTimeout(() => { this.timedOut = true; this.emit({ type: 'error', message: `Antigravity timed out after ${this.limit}ms` }); this.interrupt(); }, this.limit);
|
|
87
|
-
const boot = this.boot().catch(error => this.fail(error));
|
|
103
|
+
const boot = this.failure ? Promise.resolve().then(() => this.fail(this.failure)) : this.boot().catch(error => this.fail(error));
|
|
88
104
|
this.result = this.settle(boot);
|
|
89
105
|
}
|
|
90
106
|
get pid() { return this.child.pid; }
|
|
91
107
|
get open() { return this.accepting; }
|
|
108
|
+
get closingQuietly() { return this.quiet && !this.requestedClose; }
|
|
92
109
|
emit(event) {
|
|
93
110
|
if (event.type === 'turn-end' && this.failedTurn)
|
|
94
111
|
return;
|
|
@@ -107,61 +124,82 @@ export class AntigravitySession {
|
|
|
107
124
|
event: event => { if (event.type !== 'token-usage')
|
|
108
125
|
this.emit(event); },
|
|
109
126
|
onActivity: () => this.options.onActivity?.(),
|
|
110
|
-
uiEvent: event =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
for (const hold of this.humanHolds)
|
|
114
|
-
if (!this.steers.has(hold))
|
|
115
|
-
this.humanHolds.delete(hold);
|
|
116
|
-
}
|
|
117
|
-
for (const [hold, acknowledged] of this.steers) {
|
|
118
|
-
if (event.type === 'turn.started' || acknowledged) {
|
|
119
|
-
this.humanHolds.delete(hold);
|
|
120
|
-
this.steers.delete(hold);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (event.type === 'turn.completed' && event.stopReason === 'error' && !this.reportedFailure) {
|
|
125
|
-
this.failedTurn = event;
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (event.type === 'turn.completed' && event.usage) {
|
|
129
|
-
this.output.tokensUsed += event.usage.total;
|
|
130
|
-
this.emit({ type: 'token-usage', tokensUsed: this.output.tokensUsed });
|
|
131
|
-
}
|
|
132
|
-
const ask = askPayloadOf(event);
|
|
133
|
-
if (ask)
|
|
134
|
-
this.pendingAsk = ask.requestId;
|
|
135
|
-
this.options.onUiEvent?.(event);
|
|
136
|
-
}, hooks: {
|
|
127
|
+
uiEvent: event => this.uiEvent(event),
|
|
128
|
+
hooks: {
|
|
129
|
+
...ANTIGRAVITY_WIRE_HOOKS,
|
|
137
130
|
selectAuthMethod: hello => this.runtime.env.GEMINI_API_KEY && hello.authMethods.some(method => method.id === 'gemini-api-key') ? 'gemini-api-key' : undefined,
|
|
138
|
-
|
|
131
|
+
normalizeUsage: antigravityUsage,
|
|
139
132
|
normalizeOptions: value => { this.configOptions = value; },
|
|
140
|
-
|
|
133
|
+
permissionPolicy: request => permissionPolicy(spec.toolGrant, request, productEnv('APPROVAL_GATE', this.runtime.env) === '1', spec.squawkTools ? squawkToolNames(spec.env ?? {}).map(name => `${ANTIGRAVITY_MCP_NAME}_${name}`) : []),
|
|
141
134
|
readTextFile: params => antigravityReadFile(params, spec.cwd, spec.toolGrant),
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
sessionParams:
|
|
145
|
-
// Squawk owns workflows. The native tool also writes a built-in skill into cwd.
|
|
146
|
-
disabledTools: ['run_workflow'], eagerMcpServers: spec.squawkTools ? [ANTIGRAVITY_MCP_NAME] : [] } } }),
|
|
135
|
+
// The CLI saves the session/new system prompt with the session and appends a resent one,
|
|
136
|
+
// so a resume prepends it to the opening turn instead (systemPromptOnResume 'in-thread').
|
|
137
|
+
sessionParams: method => method === 'new' ? { _meta: { antigravity: { systemPrompt: { append: (this.lostSession ? spec.resumeFallbackSystemPrompt : undefined) ?? spec.systemPrompt ?? '' } } } } : {},
|
|
147
138
|
filterUpdate: update => {
|
|
148
139
|
const failure = antigravityUpdateError(update);
|
|
149
140
|
this.providerError = failure ?? this.providerError;
|
|
150
141
|
if (failure)
|
|
151
142
|
this.reportFailure(failure);
|
|
152
|
-
return
|
|
143
|
+
return true;
|
|
153
144
|
},
|
|
154
|
-
promptError: () => { const error = this.providerError; this.providerError = undefined; return error; },
|
|
155
145
|
},
|
|
156
146
|
});
|
|
157
147
|
}
|
|
148
|
+
uiEvent(event) {
|
|
149
|
+
if (event.type === 'turn.started') {
|
|
150
|
+
clearTimeout(this.quietTimer);
|
|
151
|
+
this.clearAutoEnd();
|
|
152
|
+
}
|
|
153
|
+
// The response that ends a turn carries every prompt sent into it: none is held after it.
|
|
154
|
+
if (event.type === 'turn.completed')
|
|
155
|
+
this.humanHolds.clear();
|
|
156
|
+
if (event.type === 'turn.completed' && event.stopReason === 'error' && this.failedTurnEnded(event))
|
|
157
|
+
return;
|
|
158
|
+
if (event.type === 'turn.completed' && event.usage) {
|
|
159
|
+
this.output.tokensUsed += event.usage.total;
|
|
160
|
+
this.emit({ type: 'token-usage', tokensUsed: this.output.tokensUsed });
|
|
161
|
+
}
|
|
162
|
+
this.options.onUiEvent?.(event);
|
|
163
|
+
if (event.type === 'item.started' && event.item.kind === 'tool' && event.item.name === 'ask_question')
|
|
164
|
+
this.openAsk(event.item.id, event.item.input);
|
|
165
|
+
if (event.type === 'item.completed' && event.item.id === this.pendingAsk?.toolCallId)
|
|
166
|
+
this.pendingAsk = undefined;
|
|
167
|
+
// Work the agent started on its own ended: input and auto-end resume as after a prompt.
|
|
168
|
+
if (event.type === 'turn.completed' && !this.busy) {
|
|
169
|
+
this.armQuietEnd();
|
|
170
|
+
if (this.open) {
|
|
171
|
+
this.options.onAgentInputReady?.();
|
|
172
|
+
this.scheduleAutoEnd();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** A failed turn is held until the session reports the failure. One the agent started on its
|
|
177
|
+
* own has no prompt that rejects, so it fails the session here, as a failed prompt does. */
|
|
178
|
+
failedTurnEnded(event) {
|
|
179
|
+
if (!this.reportedFailure) {
|
|
180
|
+
this.failedTurn = event;
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
if (!this.busy)
|
|
184
|
+
queueMicrotask(() => this.fail(new Error(this.providerError ?? 'Antigravity reported an agent execution error')));
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
/** ask_question ends the prompt with the question as text; the next prompt is the answer. */
|
|
188
|
+
openAsk(toolCallId, input) {
|
|
189
|
+
const question = antigravityQuestion(input);
|
|
190
|
+
if (!question)
|
|
191
|
+
return;
|
|
192
|
+
const ask = { requestId: `antigravity-ask-${toolCallId}`, toolCallId, question };
|
|
193
|
+
this.pendingAsk = ask;
|
|
194
|
+
this.options.onUiEvent?.({ type: 'ask.requested', requestId: ask.requestId, questions: [question] });
|
|
195
|
+
}
|
|
158
196
|
async boot() {
|
|
159
197
|
this.bridge = await antigravityMcp(this.spec, this.runtime.env);
|
|
160
198
|
if (!this.open)
|
|
161
199
|
return;
|
|
162
200
|
await this.acp.initialize();
|
|
163
|
-
await this.
|
|
164
|
-
// A saved
|
|
201
|
+
await this.openSession(this.bridge ? [this.bridge.descriptor] : []);
|
|
202
|
+
// A saved accept-edits or plan mode must never bypass the permission policy on Continue.
|
|
165
203
|
await this.acp.setConfigOption('mode', 'default');
|
|
166
204
|
if (this.spec.model)
|
|
167
205
|
await this.acp.setConfigOption('model', this.spec.model);
|
|
@@ -175,69 +213,99 @@ export class AntigravitySession {
|
|
|
175
213
|
}
|
|
176
214
|
if (!this.open)
|
|
177
215
|
return;
|
|
216
|
+
// The CLI runs read_file with no permission request, so the policy cannot withhold reads.
|
|
217
|
+
const grant = this.spec.toolGrant;
|
|
218
|
+
if (grant.kind !== 'unset' && !grant.tools.includes('Read'))
|
|
219
|
+
this.emit({ type: 'note', message: 'Antigravity reads files without asking for permission; this step\'s tool grant does not include Read, but it cannot stop native file reads.' });
|
|
178
220
|
this.ready = true;
|
|
179
|
-
void this.submit(
|
|
221
|
+
void this.submit(this.opening()).catch(error => this.fail(error));
|
|
180
222
|
this.options.onAgentInputReady?.();
|
|
181
223
|
}
|
|
182
|
-
|
|
224
|
+
/** A session the CLI cannot reopen (one the retired registry server saved, or a removed
|
|
225
|
+
* conversation) continues in a fresh session, with the full system prompt and the skill. */
|
|
226
|
+
async openSession(mcpServers) {
|
|
227
|
+
const sessionId = this.spec.resume ? this.spec.sessionId : undefined;
|
|
228
|
+
if (!sessionId) {
|
|
229
|
+
await this.acp.open({ cwd: this.spec.cwd, mcpServers });
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
await this.acp.open({ cwd: this.spec.cwd, sessionId, mcpServers });
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
if (!(error instanceof AcpRpcError))
|
|
237
|
+
throw error;
|
|
238
|
+
this.lostSession = true;
|
|
239
|
+
this.emit({ type: 'note', message: `Antigravity could not resume session ${sessionId} (${error.message}); continuing in a new session.` });
|
|
240
|
+
await this.acp.open({ cwd: this.spec.cwd, mcpServers });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/** `onAcknowledged` runs when the CLI takes the input: a steer when the running prompt answers
|
|
244
|
+
* for it, any prompt at its own response. */
|
|
245
|
+
/** A resumed session carries spec.systemPrompt in its opening turn, as the other in-thread
|
|
246
|
+
* runners do: the CLI keeps the session/new prompt, and a resent _meta prompt would be appended. */
|
|
247
|
+
opening() {
|
|
248
|
+
const resumed = !!this.spec.resume && !this.lostSession;
|
|
249
|
+
const content = openingContent(this.spec, resumed);
|
|
250
|
+
if (!(resumed && this.spec.sessionId && this.spec.systemPrompt))
|
|
251
|
+
return content;
|
|
252
|
+
const last = content.at(-1);
|
|
253
|
+
if (last?.type !== 'text')
|
|
254
|
+
return content;
|
|
255
|
+
return [...content.slice(0, -1), { ...last, text: prependSystemPrompt(this.spec.systemPrompt, last.text) }];
|
|
256
|
+
}
|
|
257
|
+
submit(content, onAcknowledged) {
|
|
183
258
|
this.clearAutoEnd();
|
|
184
|
-
|
|
259
|
+
// The ACP prompt state decides, not `busy`: a turn's response closes the prompt before the
|
|
260
|
+
// submission that carried it settles here, and input sent at that turn end opens a new one.
|
|
261
|
+
const steered = this.acp.promptOpen;
|
|
185
262
|
this.inflight++;
|
|
186
|
-
const operation = steered ? this.acp.steer(contentBlocks(content)) : this.acp.prompt(contentBlocks(content));
|
|
187
|
-
return operation.then(() => { }).finally(() => {
|
|
263
|
+
const operation = steered ? this.acp.steer(contentBlocks(content), onAcknowledged) : this.acp.prompt(contentBlocks(content));
|
|
264
|
+
return operation.then(() => { onAcknowledged?.(); }).finally(() => {
|
|
188
265
|
this.inflight--;
|
|
189
266
|
if (this.busy)
|
|
190
267
|
return;
|
|
191
268
|
if (this.interrupted)
|
|
192
269
|
this.closeInput();
|
|
193
|
-
this.pendingAsk = undefined;
|
|
194
270
|
if (this.open && this.queue.length)
|
|
195
271
|
void this.submit(this.queue.shift()).catch(error => this.fail(error));
|
|
196
272
|
else if (this.open) {
|
|
197
273
|
this.options.onAgentInputReady?.();
|
|
198
274
|
this.scheduleAutoEnd();
|
|
199
275
|
}
|
|
276
|
+
this.armQuietEnd();
|
|
200
277
|
});
|
|
201
278
|
}
|
|
202
279
|
sendMessage(content) {
|
|
203
280
|
if (!this.open || !validSkillMessage(content))
|
|
204
281
|
return false;
|
|
205
282
|
if (this.pendingAsk)
|
|
206
|
-
|
|
283
|
+
content = this.answerAsk(content);
|
|
207
284
|
if (!this.ready) {
|
|
208
285
|
this.queue.push(content);
|
|
209
286
|
return true;
|
|
210
287
|
}
|
|
211
|
-
const steered = this.busy;
|
|
212
288
|
const hold = Symbol('human input');
|
|
213
289
|
this.humanHolds.add(hold);
|
|
214
290
|
this.humanAcks++;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
291
|
+
let released = false;
|
|
292
|
+
const release = () => { if (!released) {
|
|
293
|
+
released = true;
|
|
294
|
+
this.releaseHuman(hold);
|
|
295
|
+
} };
|
|
296
|
+
void this.submit(content, release).then(release, error => { release(); this.fail(error); });
|
|
218
297
|
return true;
|
|
219
298
|
}
|
|
299
|
+
/** The card's answer becomes the next prompt, in the words the CLI's own question offered. */
|
|
220
300
|
answerAsk(content) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
this.pendingAsk = undefined;
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
catch (error) {
|
|
229
|
-
this.emit({ type: 'note', message: String(error) });
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
301
|
+
const ask = this.pendingAsk;
|
|
302
|
+
this.pendingAsk = undefined;
|
|
303
|
+
const text = content.filter(block => block.type === 'text').map(block => block.text).join('\n');
|
|
304
|
+
return [{ type: 'text', text: antigravityAnswer(ask.question, text) }];
|
|
232
305
|
}
|
|
233
|
-
releaseHuman(hold
|
|
306
|
+
releaseHuman(hold) {
|
|
234
307
|
this.humanAcks = Math.max(0, this.humanAcks - 1);
|
|
235
|
-
|
|
236
|
-
this.humanHolds.delete(hold);
|
|
237
|
-
else
|
|
238
|
-
this.steers.set(hold, true);
|
|
239
|
-
if (rejected)
|
|
240
|
-
this.steers.delete(hold);
|
|
308
|
+
this.humanHolds.delete(hold);
|
|
241
309
|
this.options.onAgentInputReady?.();
|
|
242
310
|
if (!this.busy)
|
|
243
311
|
this.scheduleAutoEnd();
|
|
@@ -246,24 +314,58 @@ export class AntigravitySession {
|
|
|
246
314
|
if (!this.open || !this.ready || this.humanAcks || this.agentAcks || this.pendingAsk || !validSkillMessage(content))
|
|
247
315
|
return false;
|
|
248
316
|
this.agentAcks++;
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
317
|
+
return new Promise((resolve, reject) => {
|
|
318
|
+
let settled = false;
|
|
319
|
+
const settle = (error) => {
|
|
320
|
+
if (settled) {
|
|
321
|
+
if (error !== undefined)
|
|
322
|
+
this.fail(error);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
settled = true;
|
|
326
|
+
this.agentAcks--;
|
|
327
|
+
this.options.onAgentInputReady?.();
|
|
328
|
+
if (!this.busy)
|
|
329
|
+
this.scheduleAutoEnd();
|
|
330
|
+
if (error === undefined)
|
|
331
|
+
resolve();
|
|
332
|
+
else
|
|
333
|
+
reject(!this.open && this.requestedClose ? new SessionEndedBeforeAcknowledgement() : error);
|
|
334
|
+
};
|
|
335
|
+
this.submit(content, () => settle()).then(() => settle(), error => settle(error ?? new Error('Antigravity input failed')));
|
|
255
336
|
});
|
|
256
337
|
}
|
|
257
338
|
respondPermission(id, option) { return this.acp.respondPermission(id, option); }
|
|
258
|
-
discardQueuedMessages() { this.queue.length = 0; this.humanHolds.clear();
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
// close and discard also release.
|
|
339
|
+
discardQueuedMessages() { this.queue.length = 0; this.humanHolds.clear(); }
|
|
340
|
+
// A prompt is held from sendMessage until the turn it opens starts, or until its response: a
|
|
341
|
+
// steered prompt's response ends the turn that read it. ACP has no consumption signal.
|
|
342
|
+
// Rejection, close and discard also release.
|
|
262
343
|
holdsHumanInput() { return this.heldHumanInputCount() > 0; }
|
|
263
344
|
heldHumanInputCount() { return this.queue.length + this.humanHolds.size; }
|
|
264
|
-
|
|
345
|
+
/** A background command or timer can wake the idle session and ask after a done: stay up
|
|
346
|
+
* AUTO_END_DELAY_MS for that, and end once no turn it opened still runs. */
|
|
347
|
+
endWhenQuiet() {
|
|
265
348
|
if (!this.open)
|
|
266
349
|
return;
|
|
350
|
+
this.quiet = true;
|
|
351
|
+
this.accepting = false;
|
|
352
|
+
this.clearAutoEnd();
|
|
353
|
+
this.discardQueuedMessages();
|
|
354
|
+
this.pendingAsk = undefined;
|
|
355
|
+
this.armQuietEnd();
|
|
356
|
+
}
|
|
357
|
+
armQuietEnd() {
|
|
358
|
+
if (!this.quiet || this.requestedClose)
|
|
359
|
+
return;
|
|
360
|
+
clearTimeout(this.quietTimer);
|
|
361
|
+
if (this.busy || this.acp.agentWorking)
|
|
362
|
+
return;
|
|
363
|
+
this.quietTimer = setTimeout(() => { if (!this.busy && !this.acp.agentWorking)
|
|
364
|
+
this.end(); }, AUTO_END_DELAY_MS);
|
|
365
|
+
}
|
|
366
|
+
end() {
|
|
367
|
+
if (this.requestedClose)
|
|
368
|
+
return;
|
|
267
369
|
this.beginClose();
|
|
268
370
|
this.closeInput();
|
|
269
371
|
this.term = setTimeout(() => this.terminate(), this.spec.timings?.eofTermGraceMs ?? DEFAULT_RUNNER_TIMINGS.eofTermGraceMs);
|
|
@@ -273,6 +375,7 @@ export class AntigravitySession {
|
|
|
273
375
|
this.requestedClose = true;
|
|
274
376
|
this.accepting = false;
|
|
275
377
|
this.clearAutoEnd();
|
|
378
|
+
clearTimeout(this.quietTimer);
|
|
276
379
|
this.discardQueuedMessages();
|
|
277
380
|
this.pendingAsk = undefined;
|
|
278
381
|
}
|
|
@@ -283,16 +386,16 @@ export class AntigravitySession {
|
|
|
283
386
|
this.kill = setTimeout(() => signalSession(this.child, 'SIGKILL'), this.spec.timings?.eofKillGraceMs ?? DEFAULT_RUNNER_TIMINGS.eofKillGraceMs);
|
|
284
387
|
}
|
|
285
388
|
interrupt() {
|
|
286
|
-
if (
|
|
389
|
+
if (this.requestedClose)
|
|
287
390
|
return;
|
|
288
391
|
this.interrupted = true;
|
|
289
392
|
this.beginClose();
|
|
290
|
-
if (this.ready && this.busy) {
|
|
393
|
+
if (this.ready && (this.busy || this.acp.agentWorking)) {
|
|
291
394
|
try {
|
|
292
395
|
this.acp.cancel();
|
|
293
396
|
}
|
|
294
397
|
catch { /* The shutdown deadline still owns cleanup. */ }
|
|
295
|
-
//
|
|
398
|
+
// The CLI answers cancelled before the open command closes; keep the transport for that.
|
|
296
399
|
this.term = setTimeout(() => { this.closeInput(); this.terminate(); }, this.spec.timings?.eofTermGraceMs ?? DEFAULT_RUNNER_TIMINGS.eofTermGraceMs);
|
|
297
400
|
}
|
|
298
401
|
else {
|
|
@@ -301,7 +404,7 @@ export class AntigravitySession {
|
|
|
301
404
|
}
|
|
302
405
|
}
|
|
303
406
|
fail(error) {
|
|
304
|
-
if (
|
|
407
|
+
if (this.requestedClose)
|
|
305
408
|
return;
|
|
306
409
|
this.failure ??= error instanceof Error ? error : new Error(String(error));
|
|
307
410
|
this.end();
|
|
@@ -312,7 +415,7 @@ export class AntigravitySession {
|
|
|
312
415
|
return;
|
|
313
416
|
this.autoEnd = setTimeout(() => {
|
|
314
417
|
this.autoEnd = undefined;
|
|
315
|
-
if (this.open && !this.busy && !this.humanAcks && !this.queue.length && this.options.shouldAutoEnd?.() !== false)
|
|
418
|
+
if (this.open && !this.busy && !this.acp.agentWorking && !this.humanAcks && !this.queue.length && this.options.shouldAutoEnd?.() !== false)
|
|
316
419
|
this.end();
|
|
317
420
|
}, AUTO_END_DELAY_MS);
|
|
318
421
|
}
|
|
@@ -328,20 +431,25 @@ export class AntigravitySession {
|
|
|
328
431
|
this.accepting = false;
|
|
329
432
|
this.acp.close();
|
|
330
433
|
this.clearAutoEnd();
|
|
434
|
+
clearTimeout(this.quietTimer);
|
|
331
435
|
clearTimeout(this.term);
|
|
332
436
|
clearTimeout(this.kill);
|
|
333
437
|
clearTimeout(this.deadline);
|
|
334
438
|
this.descendants.terminate(this.spec.timings?.eofKillGraceMs ?? DEFAULT_RUNNER_TIMINGS.eofKillGraceMs);
|
|
439
|
+
try {
|
|
440
|
+
this.launch.release();
|
|
441
|
+
}
|
|
442
|
+
catch { /* Pruning drops a lease whose owner process has exited. */ }
|
|
335
443
|
await boot;
|
|
336
444
|
await this.bridge?.close();
|
|
337
445
|
const unexpected = !this.requestedClose && (code !== 0 || this.busy);
|
|
338
446
|
if (this.timedOut || this.failure || unexpected || this.reportedFailure) {
|
|
339
|
-
await logAntigravityFailure(this.runtime.
|
|
447
|
+
await logAntigravityFailure(this.runtime.geminiDir, this.child.pid, 'session', this.failure ?? this.providerError ?? `Agent exited code ${code}`, this.runtime.env, this.stderr);
|
|
340
448
|
}
|
|
341
449
|
await rm(this.runtime.temp, { recursive: true, force: true });
|
|
342
450
|
if (this.timedOut)
|
|
343
451
|
throw new Error(`Antigravity timed out after ${this.limit}ms`);
|
|
344
|
-
const stderr =
|
|
452
|
+
const stderr = redactAntigravityDiagnostics(this.stderr, this.runtime.env).trim();
|
|
345
453
|
if (this.failure || unexpected) {
|
|
346
454
|
const message = [this.failure?.message, `Antigravity exited code ${code}`, summarizeRunnerStderr(stderr)].filter(Boolean).join(': ');
|
|
347
455
|
const error = new Error(message);
|