@hearsay-tools/squawk 0.18.0-pr4068.7762.2 → 0.18.0-pr4069.7765
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/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 +2 -1
- package/dist/runners/antigravity/antigravity-runner.js.map +1 -1
- package/dist/runners/antigravity/antigravity-session.d.ts +19 -2
- package/dist/runners/antigravity/antigravity-session.js +167 -95
- 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 +92 -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 +7 -4
- 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 +20 -0
- package/dist/runners/antigravity/executable.js +97 -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 +34 -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 +20 -13
- package/dist/runners/antigravity/mock.js +17 -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 +7 -7
- 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/models-routes.d.ts +13 -13
- package/dist/server/provider-sign-in-routes.js +1 -1
- package/dist/server/provider-sign-in-routes.js.map +1 -1
- package/dist/server/runners-routes.d.ts +10 -10
- 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.mjs +120 -80
- 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';
|
|
@@ -13,7 +14,14 @@ import { waitForRelease } from './mock-lifecycle.mjs';
|
|
|
13
14
|
import { answerNudge } from './mock-nudge.mjs';
|
|
14
15
|
import { PI_FAILURES } from './mock-provider-failures.mjs';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
// The Antigravity CLI's identity: a bare version and a help text that lists its acp command.
|
|
18
|
+
if (process.argv.includes('--version')) { console.log('1.5.14'); process.exit(0); }
|
|
19
|
+
if (process.argv.includes('--help')) { console.log('Usage of antigravity:\n acp Start the Agent Client Protocol (ACP) stdio server'); process.exit(0); }
|
|
20
|
+
const flag = name => { const index = process.argv.indexOf(name); return index < 0 ? undefined : process.argv[index + 1]; };
|
|
21
|
+
if (process.argv.includes('--login')) {
|
|
22
|
+
const { mockLogin } = await import('./mock-acp-login.mjs');
|
|
23
|
+
process.exit(await mockLogin(flag('--gemini-dir')));
|
|
24
|
+
}
|
|
17
25
|
let antigravity = false;
|
|
18
26
|
const { failureControl, delivery } = await loadControls({ failure: ['provider', 'unread'], delivery: ['reject', 'hold-ack', 'hold-response'] });
|
|
19
27
|
const write = frame => process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', ...frame })}\n`);
|
|
@@ -22,8 +30,8 @@ let sessionId = 'mock-acp-session';
|
|
|
22
30
|
let active;
|
|
23
31
|
let sessionParams = {};
|
|
24
32
|
const steers = [];
|
|
25
|
-
const latePrompts = [];
|
|
26
33
|
let mcpTurns = 0;
|
|
34
|
+
let pendingAsk;
|
|
27
35
|
if (process.env.CEZ_MOCK_ARGS_FILE) appendFileSync(process.env.CEZ_MOCK_ARGS_FILE, `${JSON.stringify(process.argv.slice(2))}\n`);
|
|
28
36
|
let serverId = 0;
|
|
29
37
|
const pending = new Map();
|
|
@@ -50,8 +58,9 @@ function encoder(turn) {
|
|
|
50
58
|
toolStart: ({ call }) => send({ sessionUpdate: 'tool_call', toolCallId: call.id, title: call.name, kind: 'other', status: 'in_progress', rawInput: call.input }),
|
|
51
59
|
toolEnd: ({ call }) => send({ sessionUpdate: 'tool_call_update', toolCallId: call.id, status: call.isError ? 'failed' : 'completed', rawOutput: call.output }),
|
|
52
60
|
progress: () => send({ sessionUpdate: 'usage_update', used: 7, size: 1048576 }),
|
|
53
|
-
end: ({ error } = {}) => { if (error) text('agent_message_chunk',
|
|
54
|
-
|
|
61
|
+
end: ({ error } = {}) => { if (error) text('agent_message_chunk', `\n⚠ agent executor error: ${PI_FAILURES[error] ?? error}`); },
|
|
62
|
+
// The CLI reads a steer in the running turn, early or late.
|
|
63
|
+
readSteers: () => { echoSteers(turn); return []; },
|
|
55
64
|
closeInput: () => closeSync(0),
|
|
56
65
|
child: (_step, playChild) => playChild(encoder(turn)),
|
|
57
66
|
reply: ({ prompt }) => text('agent_message_chunk', `Investigating: ${prompt}`),
|
|
@@ -64,45 +73,48 @@ function acknowledge(frame, result, text) {
|
|
|
64
73
|
}
|
|
65
74
|
async function prompt(frame) {
|
|
66
75
|
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
|
-
}
|
|
76
|
+
if (text === 'mock:account-homes') { accountHomes(frame); return; }
|
|
71
77
|
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
|
-
}
|
|
78
|
+
if (active) { steer(frame, text); return; }
|
|
89
79
|
let cancel;
|
|
90
80
|
const turn = { cancelled: false, cancelledPromise: new Promise(resolve => { cancel = resolve; }), cancel: () => { turn.cancelled = true; cancel(); } };
|
|
91
81
|
turn.frameId = frame.id;
|
|
92
82
|
active = turn;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
83
|
+
if (pendingAsk) { await answerAsk(text); finishAnswer(frame, text); return; }
|
|
84
|
+
try { await playTurn(frame, text, turn); }
|
|
85
|
+
catch (error) { write({ id: (turn.carrier ?? frame).id, error: { code: -32603, message: error.message } }); }
|
|
86
|
+
finally { active = undefined; await turn.afterTurn?.(); }
|
|
87
|
+
}
|
|
88
|
+
function finishAnswer(frame, text) {
|
|
89
|
+
update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
90
|
+
active = undefined;
|
|
91
|
+
acknowledge(frame, { stopReason: 'end_turn', usage: { inputTokens: 3, outputTokens: 4, totalTokens: 7 } }, text);
|
|
92
|
+
}
|
|
93
|
+
async function playTurn(frame, text, turn) {
|
|
94
|
+
// An unread crash stops before the first yield can accept a concurrent steer.
|
|
95
|
+
if (failureControl?.failure === 'unread' && failureControl.failureFor(text) === 'unread') process.exit(1);
|
|
96
|
+
await delivery?.holdResponse(text);
|
|
97
|
+
const failure = await failureControl?.failureFor(text);
|
|
98
|
+
if (failure) { content('agent_message_chunk', `\n⚠ agent executor error: ${PI_FAILURES[failure]}`); steers.length = 0; }
|
|
99
|
+
else { await runPrompt(answerNudge(text), turn); echoSteers(turn); }
|
|
100
|
+
if (!turn.cancelled) update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
101
|
+
acknowledge(turn.carrier ?? frame, { stopReason: turn.cancelled ? 'cancelled' : 'end_turn', usage: { inputTokens: 3, outputTokens: 4, totalTokens: 7 } }, turn.carrierText ?? text);
|
|
102
|
+
}
|
|
103
|
+
/** A steer ends the running prompt at once; the steer's own response ends the turn. */
|
|
104
|
+
function steer(frame, text) {
|
|
105
|
+
steers.push(text);
|
|
106
|
+
if (!active.carrier) reply(active.frameId, { stopReason: 'end_turn' });
|
|
107
|
+
else acknowledge(active.carrier, { stopReason: 'end_turn' }, active.carrierText);
|
|
108
|
+
active.carrier = frame; active.carrierText = text;
|
|
109
|
+
}
|
|
110
|
+
function accountHomes(frame) {
|
|
111
|
+
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 }));
|
|
112
|
+
update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
113
|
+
reply(frame.id, { stopReason: 'end_turn' });
|
|
114
|
+
}
|
|
115
|
+
function authenticate(frame) {
|
|
116
|
+
if (frame.params.methodId !== 'oauth-personal' || existsSync(join(flag('--gemini-dir') ?? '.', 'antigravity-cli', 'mock-login.json'))) { reply(frame.id, {}); return; }
|
|
117
|
+
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
118
|
}
|
|
107
119
|
function echoSteers(turn) {
|
|
108
120
|
if (turn.cancelled) return;
|
|
@@ -111,13 +123,13 @@ function echoSteers(turn) {
|
|
|
111
123
|
async function runtimeProbe(text, turn) {
|
|
112
124
|
if (text === 'mock:acp-mcp-name-limit') {
|
|
113
125
|
const server = sessionParams.mcpServers[0];
|
|
114
|
-
if (!sessionParams._meta?.antigravity?.eagerMcpServers?.includes(server.name)) throw new Error('Squawk MCP server is not eager');
|
|
115
126
|
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
127
|
const { result } = await response.json();
|
|
128
|
+
// The CLI drops a tool whose qualified name breaks its 64-character limit.
|
|
117
129
|
if (++mcpTurns > 1 && result.tools.some(tool => !/^[a-zA-Z0-9_-]{1,64}$/.test(`mcp_${server.name}_${tool.name}`))) {
|
|
118
|
-
content('agent_message_chunk', '
|
|
130
|
+
content('agent_message_chunk', 'MISSING'); return true;
|
|
119
131
|
}
|
|
120
|
-
const toolCall = { toolCallId: `mcp-${mcpTurns}`,
|
|
132
|
+
const toolCall = { toolCallId: `mcp-${mcpTurns}`, name: `mcp_${server.name}_cezar_ask`, title: `Run mcp_${server.name}_cezar_ask`, kind: 'other', rawInput: {} };
|
|
121
133
|
update({ sessionUpdate: 'tool_call', ...toolCall, status: 'pending' });
|
|
122
134
|
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
135
|
if (answer.outcome?.optionId !== 'allow') throw new Error('Squawk MCP permission was not trusted');
|
|
@@ -139,28 +151,22 @@ async function runtimeProbe(text, turn) {
|
|
|
139
151
|
return true;
|
|
140
152
|
}
|
|
141
153
|
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
154
|
content('agent_message_chunk', `Done${await context.lifecycle(['cezar_done', {}])}`); return true;
|
|
145
155
|
}
|
|
146
156
|
return false;
|
|
147
157
|
}
|
|
148
158
|
async function runPrompt(text, turn) {
|
|
149
159
|
if (await runtimeProbe(text, turn)) return;
|
|
150
|
-
|
|
151
|
-
if (
|
|
152
|
-
if (text.includes('mock:acp-late-steer')) {
|
|
153
|
-
turn.late = true;
|
|
154
|
-
const released = new Promise(resolve => { turn.releaseLate = resolve; });
|
|
155
|
-
update({ sessionUpdate: 'tool_call', toolCallId: 'steer-now', title: 'Read', status: 'completed', rawOutput: 'ready' });
|
|
156
|
-
await released; return;
|
|
157
|
-
}
|
|
160
|
+
if (text.includes('mock:permission-late')) return latePermission(turn);
|
|
161
|
+
if (scheduleWakeup(text)) return;
|
|
158
162
|
if (process.env.CEZ_MOCK_PERMISSION_PROBE === '1') await policyProbe();
|
|
159
163
|
if (text.includes('mock:acp-extended-updates')) extendedUpdates();
|
|
160
|
-
if (/mock:(?:
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
if (/mock:(?:ask-native|ask-bad)/.test(text)) return askQuestion(text);
|
|
165
|
+
// A resumed process holds no open question: the answer arrives as the opening prompt.
|
|
166
|
+
if (context.session.resumeAfterAsk && /^Question:\s*(?:Vitest|Node test)\s*$/m.test(text)) {
|
|
167
|
+
content('agent_message_chunk', `Answer received: ${text.trim()}${await context.lifecycle(['cezar_done', {}])}`); return;
|
|
163
168
|
}
|
|
169
|
+
if (/mock:(?:acp-permission|acp-ask|approval|permission-default)/.test(text)) return permissionPrompt(text, turn);
|
|
164
170
|
if (text.startsWith('/probe-')) { content('agent_message_chunk', `TRIGGER-FIXTURE ${text}`); return; }
|
|
165
171
|
if (process.env.CEZ_MOCK_CI_PR) await probeCiTool('acp', sessionParams);
|
|
166
172
|
const scenario = scenarioFor(text, context);
|
|
@@ -177,14 +183,12 @@ async function runPrompt(text, turn) {
|
|
|
177
183
|
}
|
|
178
184
|
}
|
|
179
185
|
async function permissionPrompt(text, turn) {
|
|
180
|
-
const nativeAsk = text.includes('mock:ask-native');
|
|
181
186
|
const defaultPermission = text.includes('mock:permission-default');
|
|
182
|
-
const malformed = text.includes('mock:approval-malformed')
|
|
183
|
-
const toolCall = { toolCallId:
|
|
184
|
-
title:
|
|
187
|
+
const malformed = text.includes('mock:approval-malformed');
|
|
188
|
+
const toolCall = { toolCallId: 'permission-tool', name: defaultPermission ? 'run_command' : 'generate_image',
|
|
189
|
+
title: defaultPermission ? 'pwd' : 'Run generate_image',
|
|
185
190
|
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' }];
|
|
191
|
+
let options = [{ optionId: 'allow-once', name: 'Allow once', kind: 'allow_once' }, { optionId: 'reject-once', name: 'Deny', kind: 'reject_once' }];
|
|
188
192
|
if (text.includes('one-option')) options = options.slice(0, 1);
|
|
189
193
|
const responsePromise = request('session/request_permission', { sessionId, toolCall, options: malformed ? [] : options }, text.includes('long-id') ? 'native-id-'.repeat(64) : undefined);
|
|
190
194
|
if (text.includes('mock:approval-turn-end')) {
|
|
@@ -195,10 +199,51 @@ async function permissionPrompt(text, turn) {
|
|
|
195
199
|
const response = await responsePromise;
|
|
196
200
|
if (turn.cancelled) return;
|
|
197
201
|
if (malformed) content('agent_message_chunk', `Malformed permission refused${await context.lifecycle(['cezar_done', {}])}`);
|
|
198
|
-
else if (
|
|
202
|
+
else if (text.includes('mock:acp-')) content('agent_message_chunk', JSON.stringify(response));
|
|
199
203
|
else content('agent_message_chunk', `Approval response: ${response.outcome.optionId === 'allow-once' ? 'allow' : 'deny'}${await context.lifecycle(['cezar_done', {}])}`);
|
|
200
204
|
}
|
|
201
205
|
|
|
206
|
+
/** The native timer stays open until it fires; this turn ends at once. */
|
|
207
|
+
function scheduleWakeup(text) {
|
|
208
|
+
const wakeup = /mock:schedule-wakeup:(\d+)/.exec(text);
|
|
209
|
+
if (!wakeup) return false;
|
|
210
|
+
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' } });
|
|
211
|
+
content('agent_message_chunk', 'Scheduled.');
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
/** ask_question ends the prompt with the question as text; the next prompt is the answer. */
|
|
215
|
+
async function askQuestion(text) {
|
|
216
|
+
const questions = text.includes('mock:ask-bad') ? [] : [{ question: 'Which test library?', options: ['(Recommended) Vitest', 'Node test'] }];
|
|
217
|
+
pendingAsk = { id: 'call_ask_question', done: text.includes('mock:resume-cezar-done') };
|
|
218
|
+
update({ sessionUpdate: 'tool_call', toolCallId: pendingAsk.id, name: 'ask_question', title: 'Run ask_question', kind: 'other', status: 'in_progress', rawInput: { questions } });
|
|
219
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: pendingAsk.id, name: 'ask_question', status: 'pending' });
|
|
220
|
+
if (!questions.length) {
|
|
221
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: pendingAsk.id, status: 'failed', rawOutput: { output: 'questions must not be empty' } });
|
|
222
|
+
pendingAsk = undefined;
|
|
223
|
+
content('agent_message_chunk', `Malformed permission refused${await context.lifecycle(['cezar_done', {}])}`); return;
|
|
224
|
+
}
|
|
225
|
+
content('agent_message_chunk', '\nWhich test library?\n- [1] (Recommended) Vitest\n- [2] Node test\n');
|
|
226
|
+
}
|
|
227
|
+
async function answerAsk(text) {
|
|
228
|
+
const ask = pendingAsk; pendingAsk = undefined;
|
|
229
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: ask.id, status: 'completed', rawOutput: { output: text } });
|
|
230
|
+
content('agent_message_chunk', `Answer received: ${text}${ask.done || context.session.resumeAfterAsk ? await context.lifecycle(['cezar_done', {}]) : ''}`);
|
|
231
|
+
}
|
|
232
|
+
/** P8: the turn ends after cezar_done; a background command then wakes the idle session, which asks. */
|
|
233
|
+
async function latePermission(turn) {
|
|
234
|
+
content('agent_message_chunk', `The turn finished before the late request.${await context.lifecycle(['cezar_done', {}])}`);
|
|
235
|
+
turn.afterTurn = async () => {
|
|
236
|
+
const toolCall = { toolCallId: 'call_late', name: 'generate_image', title: 'Run generate_image', kind: 'other', rawInput: {} };
|
|
237
|
+
update({ sessionUpdate: 'tool_call', ...toolCall, status: 'in_progress' });
|
|
238
|
+
const response = await request('session/request_permission', { sessionId, toolCall,
|
|
239
|
+
options: [{ optionId: 'allow-once', name: 'Allow once', kind: 'allow_once' }, { optionId: 'reject-once', name: 'Deny', kind: 'reject_once' }] });
|
|
240
|
+
const allowed = response?.outcome?.optionId === 'allow-once';
|
|
241
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: toolCall.toolCallId, status: allowed ? 'completed' : 'failed', rawOutput: { output: '' } });
|
|
242
|
+
content('agent_message_chunk', `Approval response: ${allowed ? '{"reply":"once"}' : '{"reply":"reject"}'}${await context.lifecycle(['cezar_done', {}])}`);
|
|
243
|
+
update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
202
247
|
function extendedUpdates() {
|
|
203
248
|
content('agent_message_chunk', 'before extensions');
|
|
204
249
|
update({ sessionUpdate: 'tool_call', toolCallId: 'extended-tool', title: 'Vendor tool', kind: 'vendor_extension', status: 'in_progress' });
|
|
@@ -225,6 +270,7 @@ async function policyProbe() {
|
|
|
225
270
|
}, `policy-${index}`);
|
|
226
271
|
}
|
|
227
272
|
}
|
|
273
|
+
let mintedId;
|
|
228
274
|
function recorded(frame) {
|
|
229
275
|
// Connection credentials stay in memory; recordings retain only their structure.
|
|
230
276
|
const copy = structuredClone(frame);
|
|
@@ -232,16 +278,12 @@ function recorded(frame) {
|
|
|
232
278
|
if (server.type !== 'http') continue;
|
|
233
279
|
server.url = 'http://127.0.0.1:0/mcp'; server.headers = [{ name: 'Authorization', value: '<session-token>' }];
|
|
234
280
|
}
|
|
281
|
+
// This process's session/new id differs per process; two recordings of the same requests compare
|
|
282
|
+
// equal. A resumed id is the caller's and stays as it is.
|
|
283
|
+
if (mintedId && copy.params?.sessionId === mintedId) copy.params.sessionId = 'mock-acp-session';
|
|
235
284
|
return JSON.stringify(copy);
|
|
236
285
|
}
|
|
237
286
|
|
|
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
287
|
function setConfig(frame) {
|
|
246
288
|
if (antigravity && frame.params.configId === 'model' && frame.params.value.startsWith('mock-')) {
|
|
247
289
|
console.error('/archive/google/genai/types.py:18270: SyntaxWarning: invalid escape sequence');
|
|
@@ -250,29 +292,27 @@ function setConfig(frame) {
|
|
|
250
292
|
}
|
|
251
293
|
if (frame.params.value === 'mock-no-thinking') { reply(frame.id, { configOptions: [] }); return; }
|
|
252
294
|
if (frame.params.value === 'mock-low-thinking') {
|
|
253
|
-
reply(frame.id, { configOptions: [{ id: '
|
|
295
|
+
reply(frame.id, { configOptions: [{ id: 'thought_level', category: 'thought_level', options: [{ value: 'low', name: 'Low' }] }] }); return;
|
|
254
296
|
}
|
|
255
297
|
}
|
|
256
|
-
reply(frame.id, { configOptions: antigravity ? [{ id: '
|
|
298
|
+
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
299
|
}
|
|
258
300
|
|
|
259
301
|
async function handle(frame) {
|
|
260
302
|
if (process.env.CEZ_MOCK_STDIN_FILE) appendFileSync(process.env.CEZ_MOCK_STDIN_FILE, `${recorded(frame)}\n`);
|
|
261
303
|
if (process.env.CEZ_MOCK_ARGS_FILE) appendFileSync(process.env.CEZ_MOCK_ARGS_FILE, `${recorded(frame)}\n`);
|
|
262
304
|
if (['session/new', 'session/resume', 'session/load'].includes(frame.method)) {
|
|
263
|
-
antigravity = Boolean(frame.params._meta?.antigravity);
|
|
264
|
-
mountBuiltinSkills(frame.params);
|
|
305
|
+
antigravity = Boolean(frame.params._meta?.antigravity) || process.argv.includes('acp');
|
|
265
306
|
}
|
|
266
307
|
if (!frame.method) { pending.get(frame.id)?.(frame.result); pending.delete(frame.id); return; }
|
|
267
308
|
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':
|
|
309
|
+
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;
|
|
310
|
+
case 'authenticate': authenticate(frame); break;
|
|
270
311
|
case 'session/new':
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
case 'session/resume': case 'session/load': context.session.resumeAfterAsk = true; sessionParams = frame.params; sessionId = frame.params.sessionId; reply(frame.id, { configOptions: [{ id: 'thinking_level', category: 'thought_level', currentValue: 'medium' }] }); break;
|
|
312
|
+
// Like the CLI, each session gets its own id; recordings show it as mock-acp-session.
|
|
313
|
+
sessionParams = frame.params; sessionId = mintedId = `mock-acp-${randomUUID()}`;
|
|
314
|
+
reply(frame.id, { sessionId, configOptions: [{ id: 'thought_level', category: 'thought_level', currentValue: 'medium' }] }); break;
|
|
315
|
+
case 'session/resume': case 'session/load': 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
316
|
case 'session/set_config_option': setConfig(frame); break;
|
|
277
317
|
case 'session/prompt': await prompt(frame); break;
|
|
278
318
|
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));
|