zcode-acp-server 0.47.10 → 0.48.1
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/README.md +1 -1
- package/dist/backend/adapter.d.ts +129 -0
- package/dist/backend/adapter.d.ts.map +1 -0
- package/dist/backend/adapter.js +71 -0
- package/dist/backend/adapter.js.map +1 -0
- package/dist/backend/client.d.ts +14 -103
- package/dist/backend/client.d.ts.map +1 -1
- package/dist/backend/client.js +63 -413
- package/dist/backend/client.js.map +1 -1
- package/dist/backend/index.d.ts +3 -1
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +2 -0
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/jsonrpc-child.d.ts +128 -0
- package/dist/backend/jsonrpc-child.d.ts.map +1 -0
- package/dist/backend/jsonrpc-child.js +397 -0
- package/dist/backend/jsonrpc-child.js.map +1 -0
- package/dist/code-fingerprint.json +2 -2
- package/dist/config/options.d.ts.map +1 -1
- package/dist/config/options.js +14 -4
- package/dist/config/options.js.map +1 -1
- package/dist/config/workflow-gate.d.ts +97 -0
- package/dist/config/workflow-gate.d.ts.map +1 -0
- package/dist/config/workflow-gate.js +159 -0
- package/dist/config/workflow-gate.js.map +1 -0
- package/dist/handlers/background-tasks.d.ts.map +1 -1
- package/dist/handlers/background-tasks.js +56 -0
- package/dist/handlers/background-tasks.js.map +1 -1
- package/dist/handlers/dispatch.js +4 -0
- package/dist/handlers/dispatch.js.map +1 -1
- package/dist/handlers/session.d.ts +11 -0
- package/dist/handlers/session.d.ts.map +1 -1
- package/dist/handlers/session.js +80 -32
- package/dist/handlers/session.js.map +1 -1
- package/dist/handlers/slash.d.ts +7 -2
- package/dist/handlers/slash.d.ts.map +1 -1
- package/dist/handlers/slash.js +115 -4
- package/dist/handlers/slash.js.map +1 -1
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +6 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/remote/session-close-endpoint.d.ts.map +1 -1
- package/dist/remote/session-close-endpoint.js +6 -0
- package/dist/remote/session-close-endpoint.js.map +1 -1
- package/dist/remote/settings-endpoint.d.ts.map +1 -1
- package/dist/remote/settings-endpoint.js +380 -3
- package/dist/remote/settings-endpoint.js.map +1 -1
- package/dist/server.d.ts +49 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +80 -0
- package/dist/server.js.map +1 -1
- package/dist/settings/workflow.d.ts +139 -0
- package/dist/settings/workflow.d.ts.map +1 -0
- package/dist/settings/workflow.js +443 -0
- package/dist/settings/workflow.js.map +1 -0
- package/dist/translators/tool-helpers.d.ts.map +1 -1
- package/dist/translators/tool-helpers.js +4 -0
- package/dist/translators/tool-helpers.js.map +1 -1
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -1
- package/dist/workflow/poller.d.ts +68 -0
- package/dist/workflow/poller.d.ts.map +1 -0
- package/dist/workflow/poller.js +290 -0
- package/dist/workflow/poller.js.map +1 -0
- package/docs/ARCHITECTURE.md +8 -6
- package/docs/BACKLOG.md +20 -2
- package/package.json +1 -1
package/dist/backend/client.js
CHANGED
|
@@ -1,37 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ZCode subprocess client:
|
|
2
|
+
* ZCode subprocess client: the zcode dialect over the shared JSON-RPC transport.
|
|
3
3
|
*
|
|
4
4
|
* The ZCode app-server is launched as a subprocess (`zcode app-server --stdio`)
|
|
5
|
-
* speaking line-delimited JSON over stdio.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* - server→client requests (id + method, id not pending) → server-request queue
|
|
9
|
-
* - notifications (no id):
|
|
10
|
-
* - `session/event` → routed to the registered session listener
|
|
11
|
-
* - anything else → general notification queue
|
|
5
|
+
* speaking line-delimited JSON over stdio. It deliberately omits the `jsonrpc`
|
|
6
|
+
* field (its strict validator rejects it — see AGENTS.md), and pushes events
|
|
7
|
+
* via the `session/event` notification plus `state.updated` settings patches.
|
|
12
8
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* The generic transport (read-loop multiplexer, pending-request map, watchdog,
|
|
10
|
+
* process-group lifecycle) lives in {@link JsonRpcChild}; this class only
|
|
11
|
+
* supplies the zcode dialect.
|
|
16
12
|
*/
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
proc;
|
|
23
|
-
pending = new Map();
|
|
24
|
-
serverRequests = [];
|
|
25
|
-
// Per-session listener SET so a long-lived session listener (e.g. background
|
|
26
|
-
// task monitor) can coexist with a per-turn EventStreamListener. Each event
|
|
27
|
-
// is delivered to every registered listener for the session.
|
|
28
|
-
listeners = new Map();
|
|
29
|
-
readerDead = false;
|
|
30
|
-
/** Monotonic id for fire-and-forget sends (send()). Uses a high range to
|
|
31
|
-
* avoid collisions with the server's request ids (low range). */
|
|
32
|
-
sendIdCounter = 1_000_000_000;
|
|
33
|
-
/** Watchdog process that kills the zcode group if this bridge dies (SIGKILL). */
|
|
34
|
-
watchdog = null;
|
|
13
|
+
import { log } from "../utils.js";
|
|
14
|
+
import { backendCapabilities } from "./adapter.js";
|
|
15
|
+
import { JsonRpcChild } from "./jsonrpc-child.js";
|
|
16
|
+
export class ZcodeBackend extends JsonRpcChild {
|
|
17
|
+
capabilities = backendCapabilities("zcode");
|
|
35
18
|
/**
|
|
36
19
|
* Arrival-time responder for `interaction/requestProviderRuntimeHeaders`.
|
|
37
20
|
* The backend asks before EVERY model request on a zhipu-account provider,
|
|
@@ -55,402 +38,69 @@ export class ZcodeBackend {
|
|
|
55
38
|
*/
|
|
56
39
|
onCompactOutcome;
|
|
57
40
|
constructor(argv, env) {
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
super({
|
|
42
|
+
argv,
|
|
60
43
|
env,
|
|
61
|
-
|
|
44
|
+
name: "zcode",
|
|
45
|
+
logLabel: "zcode app-server",
|
|
46
|
+
cliLabel: "zcode CLI",
|
|
47
|
+
binEnvVar: "ZCODE_BIN",
|
|
62
48
|
});
|
|
63
|
-
// Spawn failures (ENOENT when the CLI can't be resolved) arrive here
|
|
64
|
-
// asynchronously — without a listener the bridge dies on an unhandled
|
|
65
|
-
// 'error' event. Mark the backend dead so requests fail with a JSON-RPC
|
|
66
|
-
// error instead of crashing the whole process.
|
|
67
|
-
this.proc.on("error", (err) => {
|
|
68
|
-
const hint = err.code === "ENOENT"
|
|
69
|
-
? `${this.proc.spawnfile} not found — install the zcode CLI, put it on PATH, or set ZCODE_BIN`
|
|
70
|
-
: err.message;
|
|
71
|
-
this.markReaderDead(`spawn failed: ${hint}`);
|
|
72
|
-
});
|
|
73
|
-
// Node stream write errors (EPIPE on a closed stdin) are emitted as async
|
|
74
|
-
// 'error' events, NOT thrown synchronously — without a listener the process
|
|
75
|
-
// crashes with an unhandled 'error' event. Catch them here and mark the
|
|
76
|
-
// reader dead so the rest of the bridge stops talking to a gone backend.
|
|
77
|
-
this.proc.stdin?.on("error", (err) => {
|
|
78
|
-
this.readerDead = true;
|
|
79
|
-
warn(`backend: stdin error: ${err.message}`);
|
|
80
|
-
});
|
|
81
|
-
this.startReader();
|
|
82
|
-
this.startWatchdog();
|
|
83
|
-
log(`backend: started zcode app-server (pid=${this.proc.pid})`);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Spawn a tiny detached watchdog that kills the zcode process group if this
|
|
87
|
-
* bridge process disappears.
|
|
88
|
-
*
|
|
89
|
-
* The detached/kill(-pid) cleanup in `close()` only runs when the bridge
|
|
90
|
-
* exits cleanly enough for the signal handlers to fire (SIGTERM/SIGINT/etc).
|
|
91
|
-
* If the bridge is SIGKILLed (Zed force-kill on reconnect, crash, OOM), the
|
|
92
|
-
* handler never runs and the zcode subprocess group is orphaned. The
|
|
93
|
-
* watchdog closes that gap: it polls the bridge pid every 2s and, once the
|
|
94
|
-
* bridge is gone, sends SIGKILL to the zcode process group, then exits.
|
|
95
|
-
*
|
|
96
|
-
* The watchdog is its own process-group leader (detached) and `unref`'d, so
|
|
97
|
-
* it never holds the event loop open and is not part of the zcode group it
|
|
98
|
-
* kills. It self-terminates as soon as the zcode process exits, so a normal
|
|
99
|
-
* shutdown leaves no lingering watchdog.
|
|
100
|
-
*/
|
|
101
|
-
startWatchdog() {
|
|
102
|
-
const bridgePid = process.pid;
|
|
103
|
-
const zcodePid = this.proc.pid;
|
|
104
|
-
if (!bridgePid || !zcodePid)
|
|
105
|
-
return;
|
|
106
|
-
// Inline script: poll bridge liveness, kill zcode group on bridge death.
|
|
107
|
-
const script = `
|
|
108
|
-
const bridgePid = ${bridgePid};
|
|
109
|
-
const zcodePid = ${zcodePid};
|
|
110
|
-
const tick = () => {
|
|
111
|
-
// Bridge gone? → reap the whole zcode process group, then exit.
|
|
112
|
-
try { process.kill(bridgePid, 0); }
|
|
113
|
-
catch {
|
|
114
|
-
try { process.kill(-zcodePid, 'SIGKILL'); } catch {}
|
|
115
|
-
process.exit(0);
|
|
116
|
-
}
|
|
117
|
-
// zcode already exited? → watchdog has no job left.
|
|
118
|
-
try { process.kill(-zcodePid, 0); }
|
|
119
|
-
catch { process.exit(0); }
|
|
120
|
-
};
|
|
121
|
-
setInterval(tick, 2000);
|
|
122
|
-
tick();
|
|
123
|
-
`;
|
|
124
|
-
this.watchdog = spawn(process.execPath, ["-e", script], {
|
|
125
|
-
stdio: "ignore",
|
|
126
|
-
detached: true, // own process group, not part of the zcode group
|
|
127
|
-
});
|
|
128
|
-
this.watchdog.unref();
|
|
129
|
-
}
|
|
130
|
-
// ---------- read loop ----------
|
|
131
|
-
startReader() {
|
|
132
|
-
const stdout = this.proc.stdout;
|
|
133
|
-
if (!stdout) {
|
|
134
|
-
this.markReaderDead("no stdout");
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const rl = createInterface({ input: stdout });
|
|
138
|
-
rl.on("line", (line) => {
|
|
139
|
-
const trimmed = line.trim();
|
|
140
|
-
if (!trimmed)
|
|
141
|
-
return;
|
|
142
|
-
let msg;
|
|
143
|
-
try {
|
|
144
|
-
msg = JSON.parse(trimmed);
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
return; // unparseable line: ignore
|
|
148
|
-
}
|
|
149
|
-
this.route(msg);
|
|
150
|
-
});
|
|
151
|
-
rl.on("close", () => this.markReaderDead("stdout closed"));
|
|
152
|
-
}
|
|
153
|
-
route(msg) {
|
|
154
|
-
const method = msg.method;
|
|
155
|
-
const id = msg.id;
|
|
156
|
-
if (id !== undefined && method === undefined) {
|
|
157
|
-
// Response (id, no method) → resolve pending request.
|
|
158
|
-
this.resolvePending(id, msg);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if (id !== undefined && method !== undefined) {
|
|
162
|
-
// id + method: our pending response wins the race; else it's a server→client request.
|
|
163
|
-
if (this.pending.has(id)) {
|
|
164
|
-
this.resolvePending(id, msg);
|
|
165
|
-
}
|
|
166
|
-
else if (method === "session/requestRuntimePreferences") {
|
|
167
|
-
// Newer app-servers block `session/create` until this handshake is
|
|
168
|
-
// answered. Reply with defaults — no editor interaction needed.
|
|
169
|
-
// Keep askUserQuestionAutoResolutionEnabled false so AskUserQuestion
|
|
170
|
-
// still flows through the bridge's interaction path instead of being
|
|
171
|
-
// auto-resolved server-side. Without this reply, create hangs.
|
|
172
|
-
log(`backend: auto-replying ${method} (id=${String(id)}) with default preferences`);
|
|
173
|
-
this.sendReply(id, {
|
|
174
|
-
nativeSearchEnhancementsEnabled: false,
|
|
175
|
-
memoryEnabled: false,
|
|
176
|
-
askUserQuestionAutoResolutionEnabled: false,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
else if (method === "interaction/requestProviderRuntimeHeaders" &&
|
|
180
|
-
this.providerRuntimeHeadersResponder?.(id, (msg.params ?? {}))) {
|
|
181
|
-
// Answered at arrival — see providerRuntimeHeadersResponder. This is
|
|
182
|
-
// what keeps compact's internal model turn alive outside any turn loop.
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
this.serverRequests.push({
|
|
186
|
-
id,
|
|
187
|
-
method,
|
|
188
|
-
params: (msg.params ?? {}),
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (method !== undefined) {
|
|
194
|
-
// Notification.
|
|
195
|
-
if (method === "session/event") {
|
|
196
|
-
const ev = (msg.params ?? {});
|
|
197
|
-
this.dispatchEvent(ev);
|
|
198
|
-
}
|
|
199
|
-
else if (method === "state.updated") {
|
|
200
|
-
// Session settings changed (model/mode/thoughtLevel switch, incl.
|
|
201
|
-
// mid-turn). The params carry the authoritative full settings patch:
|
|
202
|
-
// { patch: {mode, model, thoughtLevel, …}, reason, revision, sessionId }
|
|
203
|
-
// Wrap as a ZcodeEvent so it flows through the same listener pipeline.
|
|
204
|
-
const params = (msg.params ?? {});
|
|
205
|
-
const reason = typeof params["reason"] === "string" ? params["reason"] : "";
|
|
206
|
-
if (reason.startsWith("session_compact_") && params["sessionId"] !== undefined) {
|
|
207
|
-
this.onCompactOutcome?.(String(params["sessionId"]), reason);
|
|
208
|
-
}
|
|
209
|
-
const ev = {
|
|
210
|
-
sessionId: String(params.sessionId ?? ""),
|
|
211
|
-
seq: 0,
|
|
212
|
-
type: "state.updated",
|
|
213
|
-
payload: params,
|
|
214
|
-
};
|
|
215
|
-
this.dispatchEvent(ev);
|
|
216
|
-
}
|
|
217
|
-
else if (method === "interaction/providerRuntimeHeadersCancelled") {
|
|
218
|
-
// The backend aborted a pending runtime-headers refresh (turn cancel,
|
|
219
|
-
// 180s cap). Our responder answers at frame arrival, so the reply is
|
|
220
|
-
// already out and there is nothing to un-answer — acknowledge only.
|
|
221
|
-
log(`provider runtime headers ask cancelled by backend: ${JSON.stringify(msg.params ?? {})}`);
|
|
222
|
-
}
|
|
223
|
-
// Other notifications are currently ignored (process/resourceSample, …).
|
|
224
|
-
}
|
|
225
49
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const set = sid ? this.listeners.get(sid) : undefined;
|
|
230
|
-
if (set) {
|
|
231
|
-
// Iterate a snapshot so a listener that (un)registers during dispatch
|
|
232
|
-
// doesn't mutate the set under us.
|
|
233
|
-
for (const listener of [...set]) {
|
|
234
|
-
try {
|
|
235
|
-
listener.handleEvent(ev);
|
|
236
|
-
}
|
|
237
|
-
catch (e) {
|
|
238
|
-
warn(`backend: listener.handleEvent threw: ${e instanceof Error ? e.message : String(e)}`);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
resolvePending(id, resp) {
|
|
244
|
-
const p = this.pending.get(id);
|
|
245
|
-
if (!p)
|
|
246
|
-
return;
|
|
247
|
-
clearTimeout(p.timer);
|
|
248
|
-
this.pending.delete(id);
|
|
249
|
-
p.resolve(resp);
|
|
250
|
-
}
|
|
251
|
-
markReaderDead(reason) {
|
|
252
|
-
if (this.readerDead)
|
|
50
|
+
handleNotification(method, params) {
|
|
51
|
+
if (method === "session/event") {
|
|
52
|
+
this.dispatchEvent(params);
|
|
253
53
|
return;
|
|
254
|
-
this.readerDead = true;
|
|
255
|
-
warn(`backend: reader exited (${reason})`);
|
|
256
|
-
for (const [, p] of this.pending) {
|
|
257
|
-
clearTimeout(p.timer);
|
|
258
|
-
p.resolve({
|
|
259
|
-
id: 0,
|
|
260
|
-
error: { message: "zcode backend reader exited (backend dead)" },
|
|
261
|
-
});
|
|
262
54
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (set.size === 0)
|
|
280
|
-
this.listeners.delete(zcodeSid);
|
|
281
|
-
}
|
|
282
|
-
/** Non-blocking drain of pending server→client requests. */
|
|
283
|
-
pollServerRequests() {
|
|
284
|
-
if (this.serverRequests.length === 0)
|
|
285
|
-
return [];
|
|
286
|
-
return this.serverRequests.splice(0, this.serverRequests.length);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Re-queue server→client requests that belong to a different session (prepended
|
|
290
|
-
* to preserve arrival order). Used by `handleServerRequests` to put back
|
|
291
|
-
* requests it popped but doesn't own.
|
|
292
|
-
*/
|
|
293
|
-
requeueServerRequests(reqs) {
|
|
294
|
-
if (reqs.length === 0)
|
|
295
|
-
return;
|
|
296
|
-
this.serverRequests.unshift(...reqs);
|
|
297
|
-
}
|
|
298
|
-
/** Reply to a zcode server→client request with a result (id + result). */
|
|
299
|
-
sendReply(id, result) {
|
|
300
|
-
const stdin = this.proc.stdin;
|
|
301
|
-
if (!stdin || stdin.destroyed) {
|
|
302
|
-
warn("backend: sendReply dropped (stdin closed)");
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
// Write errors (EPIPE) are delivered via the stdin 'error' listener
|
|
306
|
-
// installed in the constructor (synchronous try/catch cannot catch them);
|
|
307
|
-
// no try/catch needed here.
|
|
308
|
-
stdin.write(JSON.stringify({ id, result }) + "\n");
|
|
309
|
-
}
|
|
310
|
-
/** Reply to a zcode server→client request with an error. */
|
|
311
|
-
sendError(id, code, message) {
|
|
312
|
-
const stdin = this.proc.stdin;
|
|
313
|
-
if (!stdin || stdin.destroyed) {
|
|
314
|
-
warn("backend: sendError dropped (stdin closed)");
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
stdin.write(JSON.stringify({ id, error: { code, message } }) + "\n");
|
|
318
|
-
}
|
|
319
|
-
// ---------- send / request ----------
|
|
320
|
-
/** Fire-and-forget notification to ZCode (no id, no response). */
|
|
321
|
-
notify(method, params) {
|
|
322
|
-
const stdin = this.proc.stdin;
|
|
323
|
-
if (!stdin || stdin.destroyed) {
|
|
324
|
-
warn("backend: notify dropped (stdin closed)");
|
|
55
|
+
if (method === "state.updated") {
|
|
56
|
+
// Session settings changed (model/mode/thoughtLevel switch, incl.
|
|
57
|
+
// mid-turn). The params carry the authoritative full settings patch:
|
|
58
|
+
// { patch: {mode, model, thoughtLevel, …}, reason, revision, sessionId }
|
|
59
|
+
// Wrap as a ZcodeEvent so it flows through the same listener pipeline.
|
|
60
|
+
const reason = typeof params["reason"] === "string" ? params["reason"] : "";
|
|
61
|
+
if (reason.startsWith("session_compact_") && params["sessionId"] !== undefined) {
|
|
62
|
+
this.onCompactOutcome?.(String(params["sessionId"]), reason);
|
|
63
|
+
}
|
|
64
|
+
const ev = {
|
|
65
|
+
sessionId: String(params.sessionId ?? ""),
|
|
66
|
+
seq: 0,
|
|
67
|
+
type: "state.updated",
|
|
68
|
+
payload: params,
|
|
69
|
+
};
|
|
70
|
+
this.dispatchEvent(ev);
|
|
325
71
|
return;
|
|
326
72
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
* `session/stop`: some backends route by id presence, so carrying an id is
|
|
333
|
-
* more robust than a bare notify. If the backend replies, the reader's
|
|
334
|
-
* `resolvePending` finds no pending entry and safely discards it.
|
|
335
|
-
*/
|
|
336
|
-
send(method, params) {
|
|
337
|
-
const stdin = this.proc.stdin;
|
|
338
|
-
if (!stdin || stdin.destroyed) {
|
|
339
|
-
warn("backend: send dropped (stdin closed)");
|
|
73
|
+
if (method === "interaction/providerRuntimeHeadersCancelled") {
|
|
74
|
+
// The backend aborted a pending runtime-headers refresh (turn cancel,
|
|
75
|
+
// 180s cap). Our responder answers at frame arrival, so the reply is
|
|
76
|
+
// already out and there is nothing to un-answer — acknowledge only.
|
|
77
|
+
log(`provider runtime headers ask cancelled by backend: ${JSON.stringify(params)}`);
|
|
340
78
|
return;
|
|
341
79
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
const promise = new Promise((resolve) => {
|
|
357
|
-
const timer = setTimeout(() => {
|
|
358
|
-
if (this.pending.delete(id)) {
|
|
359
|
-
resolve({ id, error: { message: "timeout" } });
|
|
360
|
-
}
|
|
361
|
-
}, timeoutMs);
|
|
362
|
-
this.pending.set(id, { resolve, timer });
|
|
363
|
-
});
|
|
364
|
-
try {
|
|
365
|
-
const stdin = this.proc.stdin;
|
|
366
|
-
if (!stdin || stdin.destroyed)
|
|
367
|
-
throw new Error("stdin closed");
|
|
368
|
-
stdin.write(JSON.stringify({ id, method, params: params ?? {} }) + "\n");
|
|
369
|
-
}
|
|
370
|
-
catch (e) {
|
|
371
|
-
this.pending.delete(id);
|
|
372
|
-
this.readerDead = true;
|
|
373
|
-
return {
|
|
374
|
-
id,
|
|
375
|
-
error: {
|
|
376
|
-
message: `zcode backend pipe broken: ${e instanceof Error ? e.message : String(e)}`,
|
|
377
|
-
},
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
return promise;
|
|
381
|
-
}
|
|
382
|
-
// ---------- lifecycle ----------
|
|
383
|
-
/**
|
|
384
|
-
* Kill the whole zcode process group and wait for it to die.
|
|
385
|
-
*
|
|
386
|
-
* SIGTERM → wait up to 3s → SIGKILL if still alive. Mirrors the Python
|
|
387
|
-
* `os.killpg` + `proc.wait(3)` + SIGKILL escalation. Note `proc.killed` is
|
|
388
|
-
* NOT set by `process.kill(-pid)` (group signal), so we track liveness via
|
|
389
|
-
* `exitCode === null` instead. Async so the caller can `await` a full reap
|
|
390
|
-
* before the parent exits (an unref'd timer could be skipped on fast exit,
|
|
391
|
-
* leaving orphans).
|
|
392
|
-
*/
|
|
393
|
-
async close() {
|
|
394
|
-
const proc = this.proc;
|
|
395
|
-
if (!proc.pid)
|
|
396
|
-
return;
|
|
397
|
-
try {
|
|
398
|
-
// Already exited?
|
|
399
|
-
if (proc.exitCode !== null || proc.signalCode)
|
|
400
|
-
return;
|
|
401
|
-
try {
|
|
402
|
-
process.kill(-proc.pid, "SIGTERM");
|
|
403
|
-
}
|
|
404
|
-
catch {
|
|
405
|
-
return; // group already gone
|
|
406
|
-
}
|
|
407
|
-
// Wait up to 3s for a clean exit.
|
|
408
|
-
const exited = await new Promise((resolve) => {
|
|
409
|
-
let timer;
|
|
410
|
-
const done = () => {
|
|
411
|
-
clearTimeout(timer); // don't let the timeout keep the event loop alive
|
|
412
|
-
resolve(true);
|
|
413
|
-
};
|
|
414
|
-
proc.once("exit", done);
|
|
415
|
-
timer = setTimeout(() => {
|
|
416
|
-
proc.removeListener("exit", done);
|
|
417
|
-
resolve(false);
|
|
418
|
-
}, 3000);
|
|
80
|
+
// Other notifications are currently ignored (process/resourceSample, …).
|
|
81
|
+
}
|
|
82
|
+
handleServerRequest(req) {
|
|
83
|
+
if (req.method === "session/requestRuntimePreferences") {
|
|
84
|
+
// Newer app-servers block `session/create` until this handshake is
|
|
85
|
+
// answered. Reply with defaults — no editor interaction needed.
|
|
86
|
+
// Keep askUserQuestionAutoResolutionEnabled false so AskUserQuestion
|
|
87
|
+
// still flows through the bridge's interaction path instead of being
|
|
88
|
+
// auto-resolved server-side. Without this reply, create hangs.
|
|
89
|
+
log(`backend: auto-replying ${req.method} (id=${String(req.id)}) with default preferences`);
|
|
90
|
+
this.sendReply(req.id, {
|
|
91
|
+
nativeSearchEnhancementsEnabled: false,
|
|
92
|
+
memoryEnabled: false,
|
|
93
|
+
askUserQuestionAutoResolutionEnabled: false,
|
|
419
94
|
});
|
|
420
|
-
|
|
421
|
-
return;
|
|
422
|
-
// Still alive → SIGKILL the whole group.
|
|
423
|
-
try {
|
|
424
|
-
if (proc.pid && proc.exitCode === null)
|
|
425
|
-
process.kill(-proc.pid, "SIGKILL");
|
|
426
|
-
}
|
|
427
|
-
catch {
|
|
428
|
-
// already gone
|
|
429
|
-
}
|
|
95
|
+
return true;
|
|
430
96
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
//
|
|
434
|
-
|
|
97
|
+
if (req.method === "interaction/requestProviderRuntimeHeaders" &&
|
|
98
|
+
this.providerRuntimeHeadersResponder?.(req.id, req.params)) {
|
|
99
|
+
// Answered at arrival — see providerRuntimeHeadersResponder. This is
|
|
100
|
+
// what keeps compact's internal model turn alive outside any turn loop.
|
|
101
|
+
return true;
|
|
435
102
|
}
|
|
436
|
-
|
|
437
|
-
/** Terminate the watchdog process if it is still running. */
|
|
438
|
-
killWatchdog() {
|
|
439
|
-
const wd = this.watchdog;
|
|
440
|
-
if (!wd)
|
|
441
|
-
return;
|
|
442
|
-
this.watchdog = null;
|
|
443
|
-
if (wd.pid && wd.exitCode === null) {
|
|
444
|
-
try {
|
|
445
|
-
process.kill(wd.pid, "SIGTERM");
|
|
446
|
-
}
|
|
447
|
-
catch {
|
|
448
|
-
// already gone
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
get isDead() {
|
|
453
|
-
return this.readerDead;
|
|
103
|
+
return false;
|
|
454
104
|
}
|
|
455
105
|
}
|
|
456
106
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/backend/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AA4BxC,MAAM,OAAO,YAAY;IACd,IAAI,CAAe;IACX,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC5C,cAAc,GAAoB,EAAE,CAAC;IACtD,6EA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I,CAAC;QACd,CAAC;QACD,IACE,GAAG,CAAC,MAAM,KAAK,2CAA2C;YAC1D,IAAI,CAAC,+BAA+B,EAAE,CACpC,GAAG,CAAC,EAAY,EAChB,GAAG,CAAC,MAAiC,CACtC,EACD,CAAC;YACD,qEAAqE;YACrE,wEAAwE;YACxE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
package/dist/backend/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Backend layer barrel: ZCode subprocess client + listener + resolve + credentials. */
|
|
2
|
-
export {
|
|
2
|
+
export { backendCapabilities, type BackendAdapter, type BackendCapabilities, type BackendKind, type EventListener, parseBackendKind, type ServerRequest, } from "./adapter.js";
|
|
3
|
+
export { ZcodeBackend } from "./client.js";
|
|
4
|
+
export { JsonRpcChild, type JsonRpcChildOptions } from "./jsonrpc-child.js";
|
|
3
5
|
export { EventStreamListener, TurnMonitor, type NextId } from "./listener.js";
|
|
4
6
|
export { resolveZcodeCommand, builtinProviderEnv, zcodeDataBaseDirEnv } from "./resolve.js";
|
|
5
7
|
export { loadZcodeCredentials, mergeEnvWithCreds, type ZcodeCredentials } from "./credentials.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,gBAAgB,EAChB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,EAC3B,aAAa,EACb,iBAAiB,EACjB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,gCAAgC,EAChC,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/backend/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Backend layer barrel: ZCode subprocess client + listener + resolve + credentials. */
|
|
2
|
+
export { backendCapabilities, parseBackendKind, } from "./adapter.js";
|
|
2
3
|
export { ZcodeBackend } from "./client.js";
|
|
4
|
+
export { JsonRpcChild } from "./jsonrpc-child.js";
|
|
3
5
|
export { EventStreamListener, TurnMonitor } from "./listener.js";
|
|
4
6
|
export { resolveZcodeCommand, builtinProviderEnv, zcodeDataBaseDirEnv } from "./resolve.js";
|
|
5
7
|
export { loadZcodeCredentials, mergeEnvWithCreds } from "./credentials.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,EACL,mBAAmB,EAKnB,gBAAgB,GAEjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAA4B,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAe,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAyB,MAAM,kBAAkB,CAAC;AAClG,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,EAC3B,aAAa,EACb,iBAAiB,GAElB,MAAM,cAAc,CAAC"}
|