@hearsay-tools/squawk 0.18.0-dev.7764 → 0.18.0-dev.7777
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 +4 -4
- 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/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/server/live-routes.d.ts +6 -6
- package/dist/server/provider-sign-in-routes.js +1 -1
- package/dist/server/provider-sign-in-routes.js.map +1 -1
- package/dist/server/server.d.ts +238 -238
- 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
package/scripts/mock-acp.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// ACP v1 encoder. Shared scenarios own content; this module owns native framing and timing.
|
|
3
3
|
import readline from 'node:readline';
|
|
4
|
-
import { appendFileSync, closeSync,
|
|
4
|
+
import { appendFileSync, closeSync, existsSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
5
6
|
import { spawn } from 'node:child_process';
|
|
6
7
|
import { once } from 'node:events';
|
|
7
8
|
import { join } from 'node:path';
|
|
@@ -12,8 +13,16 @@ import { loadControls } from './mock-controls.mjs';
|
|
|
12
13
|
import { waitForRelease } from './mock-lifecycle.mjs';
|
|
13
14
|
import { answerNudge } from './mock-nudge.mjs';
|
|
14
15
|
import { PI_FAILURES } from './mock-provider-failures.mjs';
|
|
16
|
+
import { knownSession, saveSession } from './mock-acp-sessions.mjs';
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
// The Antigravity CLI's identity: a bare version and a help text that lists its acp command.
|
|
19
|
+
if (process.argv.includes('--version')) { console.log('1.5.14'); process.exit(0); }
|
|
20
|
+
if (process.argv.includes('--help')) { console.log('Usage of antigravity:\n acp Start the Agent Client Protocol (ACP) stdio server'); process.exit(0); }
|
|
21
|
+
const flag = name => { const index = process.argv.indexOf(name); return index < 0 ? undefined : process.argv[index + 1]; };
|
|
22
|
+
if (process.argv.includes('--login')) {
|
|
23
|
+
const { mockLogin } = await import('./mock-acp-login.mjs');
|
|
24
|
+
process.exit(await mockLogin(flag('--gemini-dir')));
|
|
25
|
+
}
|
|
17
26
|
let antigravity = false;
|
|
18
27
|
const { failureControl, delivery } = await loadControls({ failure: ['provider', 'unread'], delivery: ['reject', 'hold-ack', 'hold-response'] });
|
|
19
28
|
const write = frame => process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', ...frame })}\n`);
|
|
@@ -22,8 +31,8 @@ let sessionId = 'mock-acp-session';
|
|
|
22
31
|
let active;
|
|
23
32
|
let sessionParams = {};
|
|
24
33
|
const steers = [];
|
|
25
|
-
const latePrompts = [];
|
|
26
34
|
let mcpTurns = 0;
|
|
35
|
+
let pendingAsk;
|
|
27
36
|
if (process.env.CEZ_MOCK_ARGS_FILE) appendFileSync(process.env.CEZ_MOCK_ARGS_FILE, `${JSON.stringify(process.argv.slice(2))}\n`);
|
|
28
37
|
let serverId = 0;
|
|
29
38
|
const pending = new Map();
|
|
@@ -50,8 +59,9 @@ function encoder(turn) {
|
|
|
50
59
|
toolStart: ({ call }) => send({ sessionUpdate: 'tool_call', toolCallId: call.id, title: call.name, kind: 'other', status: 'in_progress', rawInput: call.input }),
|
|
51
60
|
toolEnd: ({ call }) => send({ sessionUpdate: 'tool_call_update', toolCallId: call.id, status: call.isError ? 'failed' : 'completed', rawOutput: call.output }),
|
|
52
61
|
progress: () => send({ sessionUpdate: 'usage_update', used: 7, size: 1048576 }),
|
|
53
|
-
end: ({ error } = {}) => { if (error) text('agent_message_chunk',
|
|
54
|
-
|
|
62
|
+
end: ({ error } = {}) => { if (error) text('agent_message_chunk', `\n⚠ agent executor error: ${PI_FAILURES[error] ?? error}`); },
|
|
63
|
+
// The CLI reads a steer in the running turn, early or late.
|
|
64
|
+
readSteers: () => { echoSteers(turn); return []; },
|
|
55
65
|
closeInput: () => closeSync(0),
|
|
56
66
|
child: (_step, playChild) => playChild(encoder(turn)),
|
|
57
67
|
reply: ({ prompt }) => text('agent_message_chunk', `Investigating: ${prompt}`),
|
|
@@ -64,45 +74,48 @@ function acknowledge(frame, result, text) {
|
|
|
64
74
|
}
|
|
65
75
|
async function prompt(frame) {
|
|
66
76
|
const text = promptText(frame);
|
|
67
|
-
if (text === 'mock:account-homes') {
|
|
68
|
-
content('agent_message_chunk', JSON.stringify({ gemini: process.env.GEMINI_HOME, home: process.env.HOME, config: process.env.XDG_CONFIG_HOME }));
|
|
69
|
-
reply(frame.id, { stopReason: 'end_turn' }); return;
|
|
70
|
-
}
|
|
77
|
+
if (text === 'mock:account-homes') { accountHomes(frame); return; }
|
|
71
78
|
if (delivery?.rejects(text)) { write({ id: frame.id, error: { code: -32000, message: 'owned turn rejected' } }); return; }
|
|
72
|
-
if (active
|
|
73
|
-
const turn = active;
|
|
74
|
-
reply(turn.frameId, { stopReason: 'end_turn', usage: { inputTokens: 3, outputTokens: 4, totalTokens: 7 } });
|
|
75
|
-
turn.mainReplied = true;
|
|
76
|
-
content('agent_message_chunk', 'late successor');
|
|
77
|
-
await request('session/request_permission', { sessionId,
|
|
78
|
-
toolCall: { toolCallId: 'late-tool', title: 'Run generate_image?', kind: 'other' },
|
|
79
|
-
options: [{ optionId: 'allow-once', name: 'Allow', kind: 'allow_once' }] });
|
|
80
|
-
reply(frame.id, { stopReason: 'end_turn', usage: { inputTokens: 5, outputTokens: 6, totalTokens: 11 } });
|
|
81
|
-
turn.releaseLate(); return;
|
|
82
|
-
}
|
|
83
|
-
if (active) {
|
|
84
|
-
if (active.lateWindow) { latePrompts.push(frame); return; }
|
|
85
|
-
steers.push(text);
|
|
86
|
-
content('agent_message_chunk', 'Agent connection was lost and could not be re-established: Concurrent receive_steps() calls are not supported on this connection.');
|
|
87
|
-
acknowledge(frame, { stopReason: 'end_turn' }, text); return;
|
|
88
|
-
}
|
|
79
|
+
if (active) { steer(frame, text); return; }
|
|
89
80
|
let cancel;
|
|
90
81
|
const turn = { cancelled: false, cancelledPromise: new Promise(resolve => { cancel = resolve; }), cancel: () => { turn.cancelled = true; cancel(); } };
|
|
91
82
|
turn.frameId = frame.id;
|
|
92
83
|
active = turn;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
84
|
+
if (pendingAsk) { await answerAsk(text); finishAnswer(frame, text); return; }
|
|
85
|
+
try { await playTurn(frame, text, turn); }
|
|
86
|
+
catch (error) { write({ id: (turn.carrier ?? frame).id, error: { code: -32603, message: error.message } }); }
|
|
87
|
+
finally { active = undefined; await turn.afterTurn?.(); }
|
|
88
|
+
}
|
|
89
|
+
function finishAnswer(frame, text) {
|
|
90
|
+
update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
91
|
+
active = undefined;
|
|
92
|
+
acknowledge(frame, { stopReason: 'end_turn', usage: { inputTokens: 3, outputTokens: 4, totalTokens: 7 } }, text);
|
|
93
|
+
}
|
|
94
|
+
async function playTurn(frame, text, turn) {
|
|
95
|
+
// An unread crash stops before the first yield can accept a concurrent steer.
|
|
96
|
+
if (failureControl?.failure === 'unread' && failureControl.failureFor(text) === 'unread') process.exit(1);
|
|
97
|
+
await delivery?.holdResponse(text);
|
|
98
|
+
const failure = await failureControl?.failureFor(text);
|
|
99
|
+
if (failure) { content('agent_message_chunk', `\n⚠ agent executor error: ${PI_FAILURES[failure]}`); steers.length = 0; }
|
|
100
|
+
else { await runPrompt(answerNudge(text), turn); echoSteers(turn); }
|
|
101
|
+
if (!turn.cancelled) update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
102
|
+
acknowledge(turn.carrier ?? frame, { stopReason: turn.cancelled ? 'cancelled' : 'end_turn', usage: { inputTokens: 3, outputTokens: 4, totalTokens: 7 } }, turn.carrierText ?? text);
|
|
103
|
+
}
|
|
104
|
+
/** A steer ends the running prompt at once; the steer's own response ends the turn. */
|
|
105
|
+
function steer(frame, text) {
|
|
106
|
+
steers.push(text);
|
|
107
|
+
if (!active.carrier) reply(active.frameId, { stopReason: 'end_turn' });
|
|
108
|
+
else acknowledge(active.carrier, { stopReason: 'end_turn' }, active.carrierText);
|
|
109
|
+
active.carrier = frame; active.carrierText = text;
|
|
110
|
+
}
|
|
111
|
+
function accountHomes(frame) {
|
|
112
|
+
content('agent_message_chunk', JSON.stringify({ gemini: flag('--gemini-dir'), appData: flag('--app-data-dir'), geminiHome: process.env.GEMINI_HOME, home: process.env.HOME, config: process.env.XDG_CONFIG_HOME, ssh: process.env.SSH_CONNECTION }));
|
|
113
|
+
update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
114
|
+
reply(frame.id, { stopReason: 'end_turn' });
|
|
115
|
+
}
|
|
116
|
+
function authenticate(frame) {
|
|
117
|
+
if (frame.params.methodId !== 'oauth-personal' || existsSync(join(flag('--gemini-dir') ?? '.', 'antigravity-cli', 'mock-login.json'))) { reply(frame.id, {}); return; }
|
|
118
|
+
write({ id: frame.id, error: { code: -32603, message: 'No browser is available here (this is a remote (SSH) session, so the browser\'s sign-in redirect can\'t reach this machine). Run `agy acp --login` in a terminal on this machine, then retry; or use a Gemini API key.' } });
|
|
106
119
|
}
|
|
107
120
|
function echoSteers(turn) {
|
|
108
121
|
if (turn.cancelled) return;
|
|
@@ -111,13 +124,13 @@ function echoSteers(turn) {
|
|
|
111
124
|
async function runtimeProbe(text, turn) {
|
|
112
125
|
if (text === 'mock:acp-mcp-name-limit') {
|
|
113
126
|
const server = sessionParams.mcpServers[0];
|
|
114
|
-
if (!sessionParams._meta?.antigravity?.eagerMcpServers?.includes(server.name)) throw new Error('Squawk MCP server is not eager');
|
|
115
127
|
const response = await fetch(server.url, { method: 'POST', headers: Object.fromEntries(server.headers.map(header => [header.name, header.value])), body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/list' }) });
|
|
116
128
|
const { result } = await response.json();
|
|
129
|
+
// The CLI drops a tool whose qualified name breaks its 64-character limit.
|
|
117
130
|
if (++mcpTurns > 1 && result.tools.some(tool => !/^[a-zA-Z0-9_-]{1,64}$/.test(`mcp_${server.name}_${tool.name}`))) {
|
|
118
|
-
content('agent_message_chunk', '
|
|
131
|
+
content('agent_message_chunk', 'MISSING'); return true;
|
|
119
132
|
}
|
|
120
|
-
const toolCall = { toolCallId: `mcp-${mcpTurns}`,
|
|
133
|
+
const toolCall = { toolCallId: `mcp-${mcpTurns}`, name: `mcp_${server.name}_cezar_ask`, title: `Run mcp_${server.name}_cezar_ask`, kind: 'other', rawInput: {} };
|
|
121
134
|
update({ sessionUpdate: 'tool_call', ...toolCall, status: 'pending' });
|
|
122
135
|
const answer = await request('session/request_permission', { sessionId, toolCall, options: [{ optionId: 'allow', name: 'Allow', kind: 'allow_once' }, { optionId: 'deny', name: 'Deny', kind: 'reject_once' }] });
|
|
123
136
|
if (answer.outcome?.optionId !== 'allow') throw new Error('Squawk MCP permission was not trusted');
|
|
@@ -139,28 +152,28 @@ async function runtimeProbe(text, turn) {
|
|
|
139
152
|
return true;
|
|
140
153
|
}
|
|
141
154
|
if (text === 'mock:acp-eager-done') {
|
|
142
|
-
const server = sessionParams.mcpServers[0];
|
|
143
|
-
if (!sessionParams._meta?.antigravity?.eagerMcpServers?.includes(server.name)) throw new Error('Lifecycle server is lazy');
|
|
144
155
|
content('agent_message_chunk', `Done${await context.lifecycle(['cezar_done', {}])}`); return true;
|
|
145
156
|
}
|
|
146
157
|
return false;
|
|
147
158
|
}
|
|
148
159
|
async function runPrompt(text, turn) {
|
|
149
160
|
if (await runtimeProbe(text, turn)) return;
|
|
150
|
-
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
await released; return;
|
|
161
|
+
if (text.includes('mock:permission-late')) return latePermission(turn);
|
|
162
|
+
if (text.includes('mock:late-error')) {
|
|
163
|
+
// A background command wakes the idle session, and that model step fails.
|
|
164
|
+
content('agent_message_chunk', 'Started in the background.');
|
|
165
|
+
turn.afterTurn = async () => { content('agent_message_chunk', '\n⚠ agent executor error: 503 Service Unavailable'); update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 }); };
|
|
166
|
+
return;
|
|
157
167
|
}
|
|
168
|
+
if (scheduleWakeup(text)) return;
|
|
158
169
|
if (process.env.CEZ_MOCK_PERMISSION_PROBE === '1') await policyProbe();
|
|
159
170
|
if (text.includes('mock:acp-extended-updates')) extendedUpdates();
|
|
160
|
-
if (/mock:(?:
|
|
161
|
-
|
|
162
|
-
|
|
171
|
+
if (/mock:(?:ask-native|ask-bad)/.test(text)) return askQuestion(text);
|
|
172
|
+
// A resumed process holds no open question: the answer arrives as the opening prompt.
|
|
173
|
+
if (context.session.resumeAfterAsk && /^Question:\s*(?:Vitest|Node test)\s*$/m.test(text)) {
|
|
174
|
+
content('agent_message_chunk', `Answer received: ${text.trim()}${await context.lifecycle(['cezar_done', {}])}`); return;
|
|
163
175
|
}
|
|
176
|
+
if (/mock:(?:acp-permission|acp-ask|approval|permission-default)/.test(text)) return permissionPrompt(text, turn);
|
|
164
177
|
if (text.startsWith('/probe-')) { content('agent_message_chunk', `TRIGGER-FIXTURE ${text}`); return; }
|
|
165
178
|
if (process.env.CEZ_MOCK_CI_PR) await probeCiTool('acp', sessionParams);
|
|
166
179
|
const scenario = scenarioFor(text, context);
|
|
@@ -177,14 +190,12 @@ async function runPrompt(text, turn) {
|
|
|
177
190
|
}
|
|
178
191
|
}
|
|
179
192
|
async function permissionPrompt(text, turn) {
|
|
180
|
-
const nativeAsk = text.includes('mock:ask-native');
|
|
181
193
|
const defaultPermission = text.includes('mock:permission-default');
|
|
182
|
-
const malformed = text.includes('mock:approval-malformed')
|
|
183
|
-
const toolCall = { toolCallId:
|
|
184
|
-
title:
|
|
194
|
+
const malformed = text.includes('mock:approval-malformed');
|
|
195
|
+
const toolCall = { toolCallId: 'permission-tool', name: defaultPermission ? 'run_command' : 'generate_image',
|
|
196
|
+
title: defaultPermission ? 'pwd' : 'Run generate_image',
|
|
185
197
|
kind: defaultPermission ? 'execute' : 'other', rawInput: defaultPermission ? { CommandLine: 'pwd' } : {} };
|
|
186
|
-
let options =
|
|
187
|
-
: [{ optionId: 'allow-once', name: 'Allow once', kind: 'allow_once' }, { optionId: 'reject-once', name: 'Deny', kind: 'reject_once' }];
|
|
198
|
+
let options = [{ optionId: 'allow-once', name: 'Allow once', kind: 'allow_once' }, { optionId: 'reject-once', name: 'Deny', kind: 'reject_once' }];
|
|
188
199
|
if (text.includes('one-option')) options = options.slice(0, 1);
|
|
189
200
|
const responsePromise = request('session/request_permission', { sessionId, toolCall, options: malformed ? [] : options }, text.includes('long-id') ? 'native-id-'.repeat(64) : undefined);
|
|
190
201
|
if (text.includes('mock:approval-turn-end')) {
|
|
@@ -195,10 +206,51 @@ async function permissionPrompt(text, turn) {
|
|
|
195
206
|
const response = await responsePromise;
|
|
196
207
|
if (turn.cancelled) return;
|
|
197
208
|
if (malformed) content('agent_message_chunk', `Malformed permission refused${await context.lifecycle(['cezar_done', {}])}`);
|
|
198
|
-
else if (
|
|
209
|
+
else if (text.includes('mock:acp-')) content('agent_message_chunk', JSON.stringify(response));
|
|
199
210
|
else content('agent_message_chunk', `Approval response: ${response.outcome.optionId === 'allow-once' ? 'allow' : 'deny'}${await context.lifecycle(['cezar_done', {}])}`);
|
|
200
211
|
}
|
|
201
212
|
|
|
213
|
+
/** The native timer stays open until it fires; this turn ends at once. */
|
|
214
|
+
function scheduleWakeup(text) {
|
|
215
|
+
const wakeup = /mock:schedule-wakeup:(\d+)/.exec(text);
|
|
216
|
+
if (!wakeup) return false;
|
|
217
|
+
update({ sessionUpdate: 'tool_call', toolCallId: 'call_schedule', name: 'schedule', title: 'Run schedule', kind: 'other', status: 'in_progress', rawInput: { DurationSeconds: Number(wakeup[1]), Prompt: 'wake up' } });
|
|
218
|
+
content('agent_message_chunk', 'Scheduled.');
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
/** ask_question ends the prompt with the question as text; the next prompt is the answer. */
|
|
222
|
+
async function askQuestion(text) {
|
|
223
|
+
const questions = text.includes('mock:ask-bad') ? [] : [{ question: 'Which test library?', options: ['(Recommended) Vitest', 'Node test'] }];
|
|
224
|
+
pendingAsk = { id: 'call_ask_question', done: text.includes('mock:resume-cezar-done') };
|
|
225
|
+
update({ sessionUpdate: 'tool_call', toolCallId: pendingAsk.id, name: 'ask_question', title: 'Run ask_question', kind: 'other', status: 'in_progress', rawInput: { questions } });
|
|
226
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: pendingAsk.id, name: 'ask_question', status: 'pending' });
|
|
227
|
+
if (!questions.length) {
|
|
228
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: pendingAsk.id, status: 'failed', rawOutput: { output: 'questions must not be empty' } });
|
|
229
|
+
pendingAsk = undefined;
|
|
230
|
+
content('agent_message_chunk', `Malformed permission refused${await context.lifecycle(['cezar_done', {}])}`); return;
|
|
231
|
+
}
|
|
232
|
+
content('agent_message_chunk', '\nWhich test library?\n- [1] (Recommended) Vitest\n- [2] Node test\n');
|
|
233
|
+
}
|
|
234
|
+
async function answerAsk(text) {
|
|
235
|
+
const ask = pendingAsk; pendingAsk = undefined;
|
|
236
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: ask.id, status: 'completed', rawOutput: { output: text } });
|
|
237
|
+
content('agent_message_chunk', `Answer received: ${text}${ask.done || context.session.resumeAfterAsk ? await context.lifecycle(['cezar_done', {}]) : ''}`);
|
|
238
|
+
}
|
|
239
|
+
/** P8: the turn ends after cezar_done; a background command then wakes the idle session, which asks. */
|
|
240
|
+
async function latePermission(turn) {
|
|
241
|
+
content('agent_message_chunk', `The turn finished before the late request.${await context.lifecycle(['cezar_done', {}])}`);
|
|
242
|
+
turn.afterTurn = async () => {
|
|
243
|
+
const toolCall = { toolCallId: 'call_late', name: 'generate_image', title: 'Run generate_image', kind: 'other', rawInput: {} };
|
|
244
|
+
update({ sessionUpdate: 'tool_call', ...toolCall, status: 'in_progress' });
|
|
245
|
+
const response = await request('session/request_permission', { sessionId, toolCall,
|
|
246
|
+
options: [{ optionId: 'allow-once', name: 'Allow once', kind: 'allow_once' }, { optionId: 'reject-once', name: 'Deny', kind: 'reject_once' }] });
|
|
247
|
+
const allowed = response?.outcome?.optionId === 'allow-once';
|
|
248
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: toolCall.toolCallId, status: allowed ? 'completed' : 'failed', rawOutput: { output: '' } });
|
|
249
|
+
content('agent_message_chunk', `Approval response: ${allowed ? '{"reply":"once"}' : '{"reply":"reject"}'}${await context.lifecycle(['cezar_done', {}])}`);
|
|
250
|
+
update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
202
254
|
function extendedUpdates() {
|
|
203
255
|
content('agent_message_chunk', 'before extensions');
|
|
204
256
|
update({ sessionUpdate: 'tool_call', toolCallId: 'extended-tool', title: 'Vendor tool', kind: 'vendor_extension', status: 'in_progress' });
|
|
@@ -225,6 +277,7 @@ async function policyProbe() {
|
|
|
225
277
|
}, `policy-${index}`);
|
|
226
278
|
}
|
|
227
279
|
}
|
|
280
|
+
let mintedId;
|
|
228
281
|
function recorded(frame) {
|
|
229
282
|
// Connection credentials stay in memory; recordings retain only their structure.
|
|
230
283
|
const copy = structuredClone(frame);
|
|
@@ -232,16 +285,12 @@ function recorded(frame) {
|
|
|
232
285
|
if (server.type !== 'http') continue;
|
|
233
286
|
server.url = 'http://127.0.0.1:0/mcp'; server.headers = [{ name: 'Authorization', value: '<session-token>' }];
|
|
234
287
|
}
|
|
288
|
+
// This process's session/new id differs per process; two recordings of the same requests compare
|
|
289
|
+
// equal. A resumed id is the caller's and stays as it is.
|
|
290
|
+
if (mintedId && copy.params?.sessionId === mintedId) copy.params.sessionId = 'mock-acp-session';
|
|
235
291
|
return JSON.stringify(copy);
|
|
236
292
|
}
|
|
237
293
|
|
|
238
|
-
function mountBuiltinSkills(params) {
|
|
239
|
-
if (!antigravity || params._meta?.antigravity?.disabledTools?.includes('run_workflow')) return;
|
|
240
|
-
// The real harness mounts this built-in skill in ACP cwd when its tool is enabled.
|
|
241
|
-
const folder = join(params.cwd, 'skills/system/run-workflow');
|
|
242
|
-
mkdirSync(folder, { recursive: true }); writeFileSync(join(folder, 'SKILL.md'), 'Native generated skill');
|
|
243
|
-
}
|
|
244
|
-
|
|
245
294
|
function setConfig(frame) {
|
|
246
295
|
if (antigravity && frame.params.configId === 'model' && frame.params.value.startsWith('mock-')) {
|
|
247
296
|
console.error('/archive/google/genai/types.py:18270: SyntaxWarning: invalid escape sequence');
|
|
@@ -250,29 +299,29 @@ function setConfig(frame) {
|
|
|
250
299
|
}
|
|
251
300
|
if (frame.params.value === 'mock-no-thinking') { reply(frame.id, { configOptions: [] }); return; }
|
|
252
301
|
if (frame.params.value === 'mock-low-thinking') {
|
|
253
|
-
reply(frame.id, { configOptions: [{ id: '
|
|
302
|
+
reply(frame.id, { configOptions: [{ id: 'thought_level', category: 'thought_level', options: [{ value: 'low', name: 'Low' }] }] }); return;
|
|
254
303
|
}
|
|
255
304
|
}
|
|
256
|
-
reply(frame.id, { configOptions: antigravity ? [{ id: '
|
|
305
|
+
reply(frame.id, { configOptions: antigravity ? [{ id: 'thought_level', category: 'thought_level', currentValue: frame.params.configId === 'thought_level' ? frame.params.value : 'medium' }] : [{ id: frame.params.configId, currentValue: frame.params.value }] });
|
|
257
306
|
}
|
|
258
307
|
|
|
259
308
|
async function handle(frame) {
|
|
260
309
|
if (process.env.CEZ_MOCK_STDIN_FILE) appendFileSync(process.env.CEZ_MOCK_STDIN_FILE, `${recorded(frame)}\n`);
|
|
261
310
|
if (process.env.CEZ_MOCK_ARGS_FILE) appendFileSync(process.env.CEZ_MOCK_ARGS_FILE, `${recorded(frame)}\n`);
|
|
262
311
|
if (['session/new', 'session/resume', 'session/load'].includes(frame.method)) {
|
|
263
|
-
antigravity = Boolean(frame.params._meta?.antigravity);
|
|
264
|
-
mountBuiltinSkills(frame.params);
|
|
312
|
+
antigravity = Boolean(frame.params._meta?.antigravity) || process.argv.includes('acp');
|
|
265
313
|
}
|
|
266
314
|
if (!frame.method) { pending.get(frame.id)?.(frame.result); pending.delete(frame.id); return; }
|
|
267
315
|
switch (frame.method) {
|
|
268
|
-
case 'initialize': reply(frame.id, { protocolVersion: 1, agentCapabilities: { loadSession: true, sessionCapabilities: { resume: {} }, mcpCapabilities: { http: true, sse: true } }, authMethods: [{ id: '
|
|
269
|
-
case 'authenticate':
|
|
316
|
+
case 'initialize': reply(frame.id, { protocolVersion: 1, agentCapabilities: { loadSession: true, sessionCapabilities: { resume: {} }, mcpCapabilities: { http: true, sse: true } }, authMethods: [{ id: 'gemini-api-key', name: 'Gemini API key' }, { id: 'oauth-personal', name: 'Google' }], agentInfo: { name: 'Antigravity ACP Server', version: '1.5.14' } }); break;
|
|
317
|
+
case 'authenticate': authenticate(frame); break;
|
|
270
318
|
case 'session/new':
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
case 'session/resume': case 'session/load':
|
|
319
|
+
// Like the CLI, each session gets its own id; recordings show it as mock-acp-session.
|
|
320
|
+
sessionParams = frame.params; sessionId = mintedId = `mock-acp-${randomUUID()}`; saveSession(sessionId);
|
|
321
|
+
reply(frame.id, { sessionId, configOptions: [{ id: 'thought_level', category: 'thought_level', currentValue: 'medium' }] }); break;
|
|
322
|
+
// A conversation the CLI does not hold (one the retired registry server saved) is refused.
|
|
323
|
+
case 'session/resume': case 'session/load': if (!knownSession(frame.params.sessionId)) { write({ id: frame.id, error: { code: -32603, message: 'conversation not found' } }); break; }
|
|
324
|
+
context.session.resumeAfterAsk = true; sessionParams = frame.params; sessionId = frame.params.sessionId; reply(frame.id, { configOptions: [{ id: 'thought_level', category: 'thought_level', currentValue: 'medium' }] }); break;
|
|
276
325
|
case 'session/set_config_option': setConfig(frame); break;
|
|
277
326
|
case 'session/prompt': await prompt(frame); break;
|
|
278
327
|
case 'session/cancel': active?.cancel(); break;
|
|
@@ -1,40 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
2
|
+
// The Antigravity CLI's sign-in, version and configOptions surface; no model/provider calls.
|
|
3
|
+
// Self-contained: tests copy it to a temporary `agy`.
|
|
3
4
|
import { createInterface } from 'node:readline';
|
|
4
|
-
import {
|
|
5
|
-
import { spawn } from 'node:child_process';
|
|
6
|
-
import { mkdirSync, readFileSync, writeFileSync, appendFileSync } from 'node:fs';
|
|
5
|
+
import { mkdirSync, existsSync, writeFileSync, appendFileSync } from 'node:fs';
|
|
7
6
|
import { join } from 'node:path';
|
|
8
7
|
if (process.argv.includes('--version')) {
|
|
9
8
|
if (process.env.AGY_MOCK_VERSION_LOG) appendFileSync(process.env.AGY_MOCK_VERSION_LOG, 'version\n');
|
|
10
|
-
console.log(
|
|
9
|
+
console.log(process.env.AGY_MOCK_VERSION || '1.5.14');
|
|
10
|
+
process.exit(0);
|
|
11
|
+
}
|
|
12
|
+
if (process.argv.includes('--help')) { console.log('Usage of antigravity:\n acp Start the Agent Client Protocol (ACP) stdio server'); process.exit(0); }
|
|
13
|
+
const flag = name => { const index = process.argv.indexOf(name); return index < 0 ? undefined : process.argv[index + 1]; };
|
|
14
|
+
const geminiDir = flag('--gemini-dir');
|
|
15
|
+
const appData = join(geminiDir, flag('--app-data-dir'));
|
|
16
|
+
const signedIn = join(appData, 'mock-login.json');
|
|
17
|
+
if (process.argv.includes('--login')) {
|
|
18
|
+
const redirect = encodeURIComponent('https://antigravity.google/oauth-callback');
|
|
19
|
+
console.log('Open this link in a browser to log in with Google:\n');
|
|
20
|
+
console.log(` https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=mock&prompt=consent&redirect_uri=${redirect}&response_type=code&scope=openid&state=fixture-state\n`);
|
|
21
|
+
console.log('Then paste the authorization code, or the full URL of the page you land on, and press Enter:');
|
|
22
|
+
const lines = createInterface({ input: process.stdin });
|
|
23
|
+
const line = await new Promise(resolve => { lines.once('line', resolve); lines.once('close', () => resolve('')); });
|
|
24
|
+
lines.close();
|
|
25
|
+
if (process.env.AGY_MOCK_LOGIN_LOG) appendFileSync(process.env.AGY_MOCK_LOGIN_LOG, `${line}\n`);
|
|
26
|
+
if (!line.trim()) { console.error('login cancelled: no authorization code was entered'); process.exit(1); }
|
|
27
|
+
if (line.includes('mock-refused')) { console.error('login failed: invalid_grant'); process.exit(1); }
|
|
28
|
+
mkdirSync(appData, { recursive: true }); writeFileSync(signedIn, '{"mock":"signed-in"}');
|
|
11
29
|
process.exit(0);
|
|
12
30
|
}
|
|
13
31
|
const write = (id, result) => console.log(JSON.stringify({ jsonrpc: '2.0', id, result }));
|
|
14
|
-
const
|
|
15
|
-
const dir = join(process.env.GEMINI_HOME, 'antigravity-acp');
|
|
16
|
-
mkdirSync(dir, { recursive: true }); writeFileSync(join(dir, 'settings.json'), JSON.stringify({ auth: { type: method } }));
|
|
17
|
-
};
|
|
32
|
+
const fail = (id, message) => console.log(JSON.stringify({ jsonrpc: '2.0', id, error: { code: -32603, message } }));
|
|
18
33
|
const configs = model => [{ id: 'model', category: 'model', options: [
|
|
19
34
|
{ value: 'opaque/flash', name: 'Flash' }, { value: 'opaque/pro', name: 'Pro' },
|
|
20
|
-
] }, { id: '
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
settings('oauth-personal'); writeFileSync(join(process.env.GEMINI_HOME, 'antigravity-acp/acp_token.json'), '{"mock":"oauth-fixture"}');
|
|
30
|
-
res.end('Signed in'); listener.close(); write(frame.id, {});
|
|
31
|
-
});
|
|
32
|
-
await new Promise(resolve => listener.listen(0, '127.0.0.1', resolve));
|
|
33
|
-
const url = new URL('https://accounts.google.com/o/oauth2/auth');
|
|
34
|
-
url.searchParams.set('redirect_uri', `http://127.0.0.1:${listener.address().port}/`); url.searchParams.set('state', 'fixture-state');
|
|
35
|
-
const quoted = `'${url.href.replaceAll("'", "'\\''")}'`;
|
|
36
|
-
const helper = spawn('/bin/sh', ['-c', process.env.BROWSER.replace('%s', quoted)], { stdio: 'ignore' });
|
|
37
|
-
helper.on('error', () => {});
|
|
35
|
+
] }, { id: 'thought_level', category: 'thought_level', options: (model === 'opaque/pro' ? ['low', 'high'] : ['low', 'medium', 'high']).map(value => ({ value, name: value })) }];
|
|
36
|
+
function authenticate(frame) {
|
|
37
|
+
if (frame.params.methodId === 'oauth-personal' && !existsSync(signedIn)) {
|
|
38
|
+
fail(frame.id, 'No browser is available here (this is a remote (SSH) session, so the browser\'s sign-in redirect can\'t reach this machine). Run `agy acp --login` in a terminal on this machine, then retry; or use a Gemini API key.');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
mkdirSync(join(appData, 'cache'), { recursive: true });
|
|
42
|
+
writeFileSync(join(appData, 'cache', 'acp-auth-state.json'), JSON.stringify({ methodId: frame.params.methodId }));
|
|
43
|
+
write(frame.id, {});
|
|
38
44
|
}
|
|
39
45
|
const lines = createInterface({ input: process.stdin });
|
|
40
46
|
lines.on('line', line => {
|
|
@@ -43,18 +49,14 @@ lines.on('line', line => {
|
|
|
43
49
|
if (frame.method === 'initialize') write(frame.id, { protocolVersion: 1, agentCapabilities: {}, authMethods: [
|
|
44
50
|
{ id: 'oauth-personal', name: 'Personal' }, { id: 'gemini-api-key', name: 'API key' },
|
|
45
51
|
] });
|
|
46
|
-
else if (frame.method === 'authenticate')
|
|
52
|
+
else if (frame.method === 'authenticate') authenticate(frame);
|
|
47
53
|
else if (frame.method === 'session/new') {
|
|
48
|
-
if (!process.env.GEMINI_API_KEY) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
const folder = join(process.env.GEMINI_HOME, 'antigravity-acp/conversations');
|
|
54
|
-
mkdirSync(folder, { recursive: true }); writeFileSync(join(folder, 'catalog-fixture.json'), '{}');
|
|
55
|
-
if (process.env.AGY_MOCK_HOME_LOG) appendFileSync(process.env.AGY_MOCK_HOME_LOG, `${process.env.GEMINI_HOME}\n`);
|
|
54
|
+
if (!process.env.GEMINI_API_KEY && !existsSync(signedIn)) { fail(frame.id, 'Authentication required'); return; }
|
|
55
|
+
const folder = join(appData, 'conversations');
|
|
56
|
+
mkdirSync(folder, { recursive: true }); writeFileSync(join(folder, 'catalog-fixture.db'), '{}');
|
|
57
|
+
if (process.env.AGY_MOCK_HOME_LOG) appendFileSync(process.env.AGY_MOCK_HOME_LOG, `${geminiDir}\n`);
|
|
56
58
|
write(frame.id, { sessionId: 'catalog-fixture', configOptions: process.env.AGY_MOCK_BAD_MODELS ? [] : configs('opaque/flash') });
|
|
57
59
|
}
|
|
58
60
|
else if (frame.method === 'session/set_config_option') write(frame.id, { configOptions: configs(frame.params.value) });
|
|
59
61
|
});
|
|
60
|
-
lines.on('close', () =>
|
|
62
|
+
lines.on('close', () => process.exit(0));
|