@hearsay-tools/squawk 0.18.0-pr4005.7626 → 0.18.0-pr4006.7633
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/runners/acp/events.d.ts +28 -0
- package/dist/runners/acp/events.js +182 -0
- package/dist/runners/acp/events.js.map +1 -0
- package/dist/runners/acp/protocol.d.ts +58 -0
- package/dist/runners/acp/protocol.js +14 -0
- package/dist/runners/acp/protocol.js.map +1 -0
- package/dist/runners/acp/session.d.ts +65 -0
- package/dist/runners/acp/session.js +195 -0
- package/dist/runners/acp/session.js.map +1 -0
- package/dist/runners/acp/transport.d.ts +37 -0
- package/dist/runners/acp/transport.js +133 -0
- package/dist/runners/acp/transport.js.map +1 -0
- package/dist/server/reports-api.d.ts +2 -2
- package/dist/server/server.d.ts +1371 -1371
- package/package.json +4 -4
- package/scripts/mock-acp.mjs +107 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hearsay-tools/squawk",
|
|
3
|
-
"version": "0.18.0-
|
|
3
|
+
"version": "0.18.0-pr4006.7633",
|
|
4
4
|
"description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@babel/parser": "^8.0.8",
|
|
65
65
|
"@babel/types": "^8.0.8",
|
|
66
|
-
"@open-mercato/cezar-api-client": "0.18.0-
|
|
67
|
-
"@open-mercato/cezar-contract": "0.18.0-
|
|
66
|
+
"@open-mercato/cezar-api-client": "0.18.0-pr4006.7633",
|
|
67
|
+
"@open-mercato/cezar-contract": "0.18.0-pr4006.7633",
|
|
68
68
|
"@types/node": "^24.19.1",
|
|
69
69
|
"@types/ws": "^8.18.1",
|
|
70
70
|
"esbuild": "^0.28.1",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "59070a2bc7defd04e03e6cfbf6f86ba7aed053e9"
|
|
85
85
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ACP v1 stdio encoder. Scenarios stay in mock-scenario.mjs; this file owns only the wire.
|
|
3
|
+
import readline from 'node:readline';
|
|
4
|
+
import { appendFileSync } from 'node:fs';
|
|
5
|
+
import { scenarioFor, play } from './mock-scenario.mjs';
|
|
6
|
+
|
|
7
|
+
const write = frame => process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', ...frame })}\n`);
|
|
8
|
+
const reply = (id, result) => write({ id, result });
|
|
9
|
+
let sessionId = 'mock-acp-session';
|
|
10
|
+
let active;
|
|
11
|
+
let serverId = 0;
|
|
12
|
+
const pending = new Map();
|
|
13
|
+
const update = value => write({ method: 'session/update', params: { sessionId, update: value } });
|
|
14
|
+
const content = (sessionUpdate, text) => update({ sessionUpdate, content: { type: 'text', text } });
|
|
15
|
+
const request = (method, params, nativeId) => new Promise(resolve => {
|
|
16
|
+
const id = nativeId ?? `agent-${++serverId}`;
|
|
17
|
+
pending.set(id, resolve);
|
|
18
|
+
write({ id, method, params });
|
|
19
|
+
});
|
|
20
|
+
const context = {
|
|
21
|
+
runner: 'acp', session: {},
|
|
22
|
+
// The shared layer has no provider MCP bridge. Its consumer supplies one.
|
|
23
|
+
unsupported: ['cezar-done', 'cezar-ask', 'cezar-wait', 'hold-cezar-done', 'hold-cezar-ask', 'busy-progress', 'multi-pr-refs', 'autonomous', 'silent-tail', 'cezar-tool', 'ci-wait', 'crash-stderr'],
|
|
24
|
+
};
|
|
25
|
+
function encoder(turn) {
|
|
26
|
+
const send = value => { if (active === turn && !turn.cancelled) update(value); };
|
|
27
|
+
const text = (sessionUpdate, value) => send({ sessionUpdate, content: { type: 'text', text: value } });
|
|
28
|
+
return {
|
|
29
|
+
open() {},
|
|
30
|
+
text: ({ parts }) => { for (const part of parts) text('agent_message_chunk', part); },
|
|
31
|
+
reasoning: step => text('agent_thought_chunk', step.text),
|
|
32
|
+
toolStart: ({ call }) => send({ sessionUpdate: 'tool_call', toolCallId: call.id, title: call.name, kind: 'other', status: 'in_progress', rawInput: call.input }),
|
|
33
|
+
toolEnd: ({ call }) => send({ sessionUpdate: 'tool_call_update', toolCallId: call.id, status: call.isError ? 'failed' : 'completed', rawOutput: call.output }),
|
|
34
|
+
progress: () => send({ sessionUpdate: 'usage_update', used: 7, size: 1048576 }),
|
|
35
|
+
end: ({ error } = {}) => { if (error) throw new Error(`mock provider ${error}`); },
|
|
36
|
+
readSteers: () => [],
|
|
37
|
+
hold: () => turn.cancelledPromise,
|
|
38
|
+
closeInput: () => process.stdin.destroy(),
|
|
39
|
+
child: () => { throw new Error('ACP mock has no subagent extension'); },
|
|
40
|
+
reply: ({ prompt }) => text('agent_message_chunk', `Investigating: ${prompt}`),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function prompt(frame) {
|
|
45
|
+
if (active) { write({ id: frame.id, error: { code: -32000, message: 'Prompt already active' } }); return; }
|
|
46
|
+
let cancel;
|
|
47
|
+
const turn = { cancelled: false, cancelledPromise: new Promise(resolve => { cancel = resolve; }), cancel: () => { turn.cancelled = true; cancel(); } };
|
|
48
|
+
active = turn;
|
|
49
|
+
const text = frame.params.prompt.filter(block => block.type === 'text').map(block => block.text).join('\n');
|
|
50
|
+
try {
|
|
51
|
+
if (text.includes('mock:acp-extended-updates')) extendedUpdates();
|
|
52
|
+
if (text.includes('mock:acp-permission') || text.includes('mock:acp-ask')) {
|
|
53
|
+
const result = await request('session/request_permission', { sessionId,
|
|
54
|
+
toolCall: { toolCallId: 'permission-tool', title: text.includes('mock:acp-ask') ? 'Question' : 'Execute command', rawInput: { command: 'pwd' } },
|
|
55
|
+
options: [{ optionId: 'allow-once', name: 'Allow once', kind: 'allow_once' }, { optionId: 'reject-once', name: 'Reject once', kind: 'reject_once' }],
|
|
56
|
+
}, text.includes('long-id') ? 'native-id-'.repeat(64) : undefined);
|
|
57
|
+
if (!turn.cancelled) content('agent_message_chunk', JSON.stringify(result));
|
|
58
|
+
} else {
|
|
59
|
+
const scenario = scenarioFor(text, context);
|
|
60
|
+
const wire = encoder(turn);
|
|
61
|
+
if (scenario) await Promise.race([play(scenario, wire), turn.cancelledPromise]);
|
|
62
|
+
else {
|
|
63
|
+
wire.text({ parts: ['Investigating: ', text] });
|
|
64
|
+
const call = { id: 'read-1', name: 'read', input: { path: 'README.md' }, output: 'mock file' };
|
|
65
|
+
wire.toolStart({ call }); wire.toolEnd({ call });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!turn.cancelled) update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
69
|
+
reply(frame.id, { stopReason: turn.cancelled ? 'cancelled' : 'end_turn' });
|
|
70
|
+
} catch (error) { write({ id: frame.id, error: { code: -32603, message: error.message } }); }
|
|
71
|
+
finally { active = undefined; }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function extendedUpdates() {
|
|
75
|
+
content('agent_message_chunk', 'before extensions');
|
|
76
|
+
update({ sessionUpdate: 'tool_call', toolCallId: 'extended-tool', title: 'Vendor tool', kind: 'vendor_extension', status: 'in_progress' });
|
|
77
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: 'extended-tool', status: 'vendor_waiting' });
|
|
78
|
+
update({ sessionUpdate: 'plan', entries: [{ content: 'Vendor plan', status: 'cancelled', priority: 'high' }] });
|
|
79
|
+
update({ sessionUpdate: 'usage_update', used: 3 });
|
|
80
|
+
update({ sessionUpdate: 'agent_message_chunk', content: { type: 'resource_link', uri: 'file:///repo/a' } });
|
|
81
|
+
update({ sessionUpdate: 123 });
|
|
82
|
+
update({ sessionUpdate: 'vendor_update', value: {} });
|
|
83
|
+
update({ sessionUpdate: 'tool_call', toolCallId: 'bad-tool', title: 42 });
|
|
84
|
+
write({ method: 'session/update', params: { update: null } });
|
|
85
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: 'extended-tool', status: 'completed', rawOutput: 'extension survived' });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function handle(frame) {
|
|
89
|
+
if (process.env.CEZ_MOCK_STDIN_FILE) appendFileSync(process.env.CEZ_MOCK_STDIN_FILE, `${JSON.stringify(frame)}\n`);
|
|
90
|
+
if (!frame.method) { pending.get(frame.id)?.(frame.result); pending.delete(frame.id); return; }
|
|
91
|
+
switch (frame.method) {
|
|
92
|
+
case 'initialize': reply(frame.id, { protocolVersion: 1, agentCapabilities: { loadSession: true, sessionCapabilities: { resume: {} }, mcpCapabilities: { http: true, sse: true } }, authMethods: [{ id: 'mock-key', name: 'Mock key' }], agentInfo: { name: 'mock-acp', version: '1.0.0' } }); break;
|
|
93
|
+
case 'authenticate': reply(frame.id, {}); break;
|
|
94
|
+
case 'session/new':
|
|
95
|
+
update({ sessionUpdate: 'usage_update', used: 0, size: 1048576 });
|
|
96
|
+
reply(frame.id, { sessionId, configOptions: [] }); break;
|
|
97
|
+
case 'session/resume': case 'session/load': sessionId = frame.params.sessionId; reply(frame.id, { configOptions: [] }); break;
|
|
98
|
+
case 'session/set_config_option': reply(frame.id, { configOptions: [{ id: frame.params.configId, currentValue: frame.params.value }] }); break;
|
|
99
|
+
case 'session/prompt': await prompt(frame); break;
|
|
100
|
+
case 'session/cancel': active?.cancel(); break;
|
|
101
|
+
default: if (frame.id !== undefined) write({ id: frame.id, error: { code: -32601, message: `Unknown method: ${frame.method}` } });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const lines = readline.createInterface({ input: process.stdin });
|
|
106
|
+
lines.on('line', line => { void handle(JSON.parse(line)); });
|
|
107
|
+
lines.on('close', () => { active?.cancel(); for (const resolve of pending.values()) resolve({ outcome: { outcome: 'cancelled' } }); });
|