zcode-acp-server 0.66.0 → 0.67.0
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 +27 -2
- package/dist/backend/resolve.js +3 -3
- package/dist/backend/resolve.js.map +1 -1
- package/dist/code-fingerprint.json +2 -2
- package/dist/config/settings.d.ts +2 -0
- package/dist/config/settings.d.ts.map +1 -1
- package/dist/config/settings.js +7 -0
- package/dist/config/settings.js.map +1 -1
- package/dist/config/user-config.d.ts +3 -1
- package/dist/config/user-config.d.ts.map +1 -1
- package/dist/config/user-config.js +7 -0
- package/dist/config/user-config.js.map +1 -1
- package/dist/handlers/dispatch.d.ts.map +1 -1
- package/dist/handlers/dispatch.js +5 -0
- package/dist/handlers/dispatch.js.map +1 -1
- package/dist/handlers/prompt-content.d.ts +22 -0
- package/dist/handlers/prompt-content.d.ts.map +1 -0
- package/dist/handlers/prompt-content.js +193 -0
- package/dist/handlers/prompt-content.js.map +1 -0
- package/dist/handlers/session.d.ts +3 -2
- package/dist/handlers/session.d.ts.map +1 -1
- package/dist/handlers/session.js +50 -17
- package/dist/handlers/session.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/PROTOCOL.md +9 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* notifications.
|
|
12
12
|
*/
|
|
13
13
|
import type * as acp from "@agentclientprotocol/sdk";
|
|
14
|
+
import { type NativePromptAttachment } from "./prompt-content.js";
|
|
14
15
|
import type { ZcodeBackend } from "../backend/client.js";
|
|
15
16
|
import { EventStreamListener, TurnMonitor } from "../backend/listener.js";
|
|
16
17
|
import type { ZcodeMessage } from "../backend/types.js";
|
|
@@ -140,7 +141,7 @@ export interface RunOneTurnOptions {
|
|
|
140
141
|
preempted: boolean;
|
|
141
142
|
/** Wire text for the backend send (slash-neutralized on the prompt path). */
|
|
142
143
|
sendText: string;
|
|
143
|
-
attachments?:
|
|
144
|
+
attachments?: NativePromptAttachment[];
|
|
144
145
|
/** Sandbox allow-restart continuation round (emits the resumed status line). */
|
|
145
146
|
continuationRound?: boolean;
|
|
146
147
|
/** Run the env-gated maybeAutoCompact after an end_turn. Default true. */
|
|
@@ -268,7 +269,7 @@ export declare function withPreemptLock(server: ZcodeAcpServer, zcodeSid: string
|
|
|
268
269
|
*/
|
|
269
270
|
export declare function preemptInFlightTurn(server: ZcodeAcpServer, zcodeSid: string, selfRequestId: number | string): boolean;
|
|
270
271
|
/** Concatenate text from ACP ContentBlock[] into a prompt string.
|
|
271
|
-
*
|
|
272
|
+
* Legacy compatibility helper; runtime prompts use convertPromptContent instead. */
|
|
272
273
|
export declare function extractPromptText(blocks: acp.ContentBlock[] | undefined): string;
|
|
273
274
|
/**
|
|
274
275
|
* ACP `ContentBlock::Image` → zcode `session/send` attachment.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/handlers/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/handlers/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAGrD,OAAO,EAAwB,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAGV,YAAY,EAGb,MAAM,qBAAqB,CAAC;AAoC7B,OAAO,EAEL,eAAe,EAKf,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA0DhE;;;;;;;;;GASG;AACH,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ACzC,MAAM,EAAE,cAAc,EACtB,EAAE,EAAE,GAAG,CAAC,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,UAAO,GACb,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
package/dist/handlers/session.js
CHANGED
|
@@ -14,7 +14,9 @@ import process from "node:process";
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { randomUUID } from "node:crypto";
|
|
16
16
|
import { realpathSync } from "node:fs";
|
|
17
|
+
import { unlink } from "node:fs/promises";
|
|
17
18
|
import { RequestError } from "@agentclientprotocol/sdk";
|
|
19
|
+
import { convertPromptContent } from "./prompt-content.js";
|
|
18
20
|
import { backendCapabilities } from "../backend/adapter.js";
|
|
19
21
|
import { EventStreamListener, TurnMonitor } from "../backend/listener.js";
|
|
20
22
|
import { resolveReal } from "../backend/sandbox.js";
|
|
@@ -31,7 +33,7 @@ import { messages } from "../i18n.js";
|
|
|
31
33
|
import { lookupLazySession, lookupModelChoiceByZcodeSid, recordMaterializedSession, rememberLazySession, } from "../lazy-sessions.js";
|
|
32
34
|
import { refreshTerminalTabTitle } from "../terminal-title.js";
|
|
33
35
|
import { buildDiffContent, EventTranslator, extractLocations, formatTurnError, isBackendLostError, isTransientTurnError, ProjectionDiffer, } from "../translators/index.js";
|
|
34
|
-
import { clientConnectionRoot, log, warn } from "../utils.js";
|
|
36
|
+
import { clientConnectionRoot, log, warn, zcodeHomeDir } from "../utils.js";
|
|
35
37
|
import { dispatchEvent } from "./dispatch.js";
|
|
36
38
|
import { emitSessionTurnState, sendAvailableCommandsDeferred, sendSessionUpdate, sendTextChunk, withReplayBatch, } from "./io.js";
|
|
37
39
|
import { EDIT_DIFF_READ_LIMIT, fetchMessages, fetchMessagesSinceAnchor, fullSlice, readTailLimit, REPLY_READ_LIMIT, replayMessages, sliceTail, TURN_READ, } from "./replay.js";
|
|
@@ -1830,13 +1832,23 @@ async function runPrompt(server, params, cx, requestId, continuationRound = fals
|
|
|
1830
1832
|
// session. No-op unless the config appeared mid-run.
|
|
1831
1833
|
await server.applySandboxFlip();
|
|
1832
1834
|
const backend = await server.ensureBackend();
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
//
|
|
1837
|
-
//
|
|
1838
|
-
|
|
1839
|
-
|
|
1835
|
+
const { text, attachments } = await convertPromptContent(params.prompt, path.join(zcodeHomeDir(), "v2", "acp-attachments"));
|
|
1836
|
+
// Staged attachments (file-kind) are referenced by nothing until the turn
|
|
1837
|
+
// commits. Every path below that abandons the prompt BEFORE the send —
|
|
1838
|
+
// boot-resume ack, slash interception, a thrown gate (evicted session,
|
|
1839
|
+
// listener re-arm), goal-loop rejection, compact-busy — must unlink them or
|
|
1840
|
+
// they orphan in ~/.zcode/v2/acp-attachments, which has no GC (found in
|
|
1841
|
+
// review of #315).
|
|
1842
|
+
let stagedDiscarded = false;
|
|
1843
|
+
const discardStagedFiles = () => {
|
|
1844
|
+
if (stagedDiscarded)
|
|
1845
|
+
return;
|
|
1846
|
+
stagedDiscarded = true;
|
|
1847
|
+
for (const a of attachments) {
|
|
1848
|
+
if (a.localPath)
|
|
1849
|
+
void unlink(a.localPath).catch(() => undefined);
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1840
1852
|
// Boot-resume banner handshake (see BOOT_RESUME_TRIGGER): martty queues the
|
|
1841
1853
|
// auto-submitted trigger until its boot bind, so it arrives as the FIRST
|
|
1842
1854
|
// prompt OF THAT CONNECTION — ack with one chunk and end the turn without
|
|
@@ -1849,6 +1861,7 @@ async function runPrompt(server, params, cx, requestId, continuationRound = fals
|
|
|
1849
1861
|
// prompt.
|
|
1850
1862
|
const promptRoot = clientConnectionRoot(client);
|
|
1851
1863
|
const ackBootResumeTrigger = async () => {
|
|
1864
|
+
discardStagedFiles();
|
|
1852
1865
|
await sendTextChunk(cx, params.sessionId, messages().bootResumeAck, randomUUID());
|
|
1853
1866
|
log("session/prompt: boot-resume banner handshake acknowledged");
|
|
1854
1867
|
await emitSessionTurnState(server, params.sessionId, false, cx);
|
|
@@ -1883,12 +1896,21 @@ async function runPrompt(server, params, cx, requestId, continuationRound = fals
|
|
|
1883
1896
|
server.connectionPromptSeen.add(promptRoot);
|
|
1884
1897
|
// Materialize a lazy session/new placeholder on first use. Placed after the
|
|
1885
1898
|
// empty-prompt check so an invalid request doesn't create a backend session.
|
|
1886
|
-
|
|
1887
|
-
//
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1899
|
+
// A failure here (evicted session, dead backend) abandons the prompt before
|
|
1900
|
+
// the send — staged files must go with it.
|
|
1901
|
+
let zcodeSid;
|
|
1902
|
+
try {
|
|
1903
|
+
zcodeSid = await ensureRealSession(server, params.sessionId);
|
|
1904
|
+
// Re-arm the session's out-of-band listeners (background tasks, backend
|
|
1905
|
+
// titles): a mid-session backend respawn (sandbox flip, dynamic allow
|
|
1906
|
+
// batches, dead-reader recovery) replaces the instance the listeners were
|
|
1907
|
+
// registered on — ensureBackgroundListener re-registers on the current one.
|
|
1908
|
+
await server.ensureBackgroundListener(zcodeSid);
|
|
1909
|
+
}
|
|
1910
|
+
catch (error) {
|
|
1911
|
+
discardStagedFiles();
|
|
1912
|
+
throw error;
|
|
1913
|
+
}
|
|
1892
1914
|
// Slash-command interception: dispatches directly to ZCode methods and
|
|
1893
1915
|
// returns end_turn without entering the turn loop. Known passthrough
|
|
1894
1916
|
// commands and unknown /x both return null for the normal turn loop.
|
|
@@ -1896,8 +1918,14 @@ async function runPrompt(server, params, cx, requestId, continuationRound = fals
|
|
|
1896
1918
|
// `client` (the requesting connection) rides along so replay-shaped slash
|
|
1897
1919
|
// dispatch — /resume's history replay above all — targets that connection
|
|
1898
1920
|
// instead of the broadcast cx (see resumeIntoSession).
|
|
1899
|
-
const intercepted =
|
|
1921
|
+
const intercepted = !params.prompt.every((block) => block.type === "text")
|
|
1922
|
+
? null
|
|
1923
|
+
: await handleSlashCommand(server, cx, params.sessionId, zcodeSid, text, client).catch((error) => {
|
|
1924
|
+
discardStagedFiles();
|
|
1925
|
+
throw error;
|
|
1926
|
+
});
|
|
1900
1927
|
if (intercepted) {
|
|
1928
|
+
discardStagedFiles();
|
|
1901
1929
|
await emitSessionTurnState(server, params.sessionId, false, cx);
|
|
1902
1930
|
return intercepted;
|
|
1903
1931
|
}
|
|
@@ -1977,6 +2005,10 @@ async function runPrompt(server, params, cx, requestId, continuationRound = fals
|
|
|
1977
2005
|
await withPreemptLock(server, zcodeSid, async () => {
|
|
1978
2006
|
const goalLoop = server.goalLoops?.get(zcodeSid);
|
|
1979
2007
|
if (goalLoop) {
|
|
2008
|
+
if (attachments.length) {
|
|
2009
|
+
discardStagedFiles();
|
|
2010
|
+
throw new RequestError(-32602, "Pause the goal loop before sending attachments");
|
|
2011
|
+
}
|
|
1980
2012
|
parked = goalLoop.parkPrompt(sendText);
|
|
1981
2013
|
return;
|
|
1982
2014
|
}
|
|
@@ -1989,6 +2021,7 @@ async function runPrompt(server, params, cx, requestId, continuationRound = fals
|
|
|
1989
2021
|
// Only reachable when the compaction outlived AUTO_COMPACT_SETTLE_MS: the
|
|
1990
2022
|
// hold above refused to wait indefinitely. The message was never queued, so
|
|
1991
2023
|
// the user resends against a session the compaction has (by now) settled.
|
|
2024
|
+
discardStagedFiles();
|
|
1992
2025
|
await sendTextChunk(cx, params.sessionId, messages().autoCompactBusy, randomUUID());
|
|
1993
2026
|
log("session/prompt: rejected — a detached auto-compact outlived its settle cap");
|
|
1994
2027
|
await emitSessionTurnState(server, params.sessionId, false, cx);
|
|
@@ -2481,7 +2514,7 @@ export function preemptInFlightTurn(server, zcodeSid, selfRequestId) {
|
|
|
2481
2514
|
}
|
|
2482
2515
|
// ---------- internals ----------
|
|
2483
2516
|
/** Concatenate text from ACP ContentBlock[] into a prompt string.
|
|
2484
|
-
*
|
|
2517
|
+
* Legacy compatibility helper; runtime prompts use convertPromptContent instead. */
|
|
2485
2518
|
export function extractPromptText(blocks) {
|
|
2486
2519
|
const parts = [];
|
|
2487
2520
|
for (const block of blocks ?? []) {
|
|
@@ -2504,7 +2537,7 @@ export function extractPromptText(blocks) {
|
|
|
2504
2537
|
parts.push(`[related resource: ${label}](${path})`);
|
|
2505
2538
|
}
|
|
2506
2539
|
else if (b.type === "resource" && b.resource) {
|
|
2507
|
-
//
|
|
2540
|
+
// Legacy extraction only (not the runtime converter): accept text
|
|
2508
2541
|
// payloads defensively in case a client sends them anyway. Binary
|
|
2509
2542
|
// payloads (BlobResourceContents) are never decoded — the base64 blob is
|
|
2510
2543
|
// useless to the model — so rewrite the resource uri into a readable
|