zcode-acp-server 0.31.1 → 0.33.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.
Files changed (45) hide show
  1. package/README.md +3 -1
  2. package/dist/code-fingerprint.json +2 -2
  3. package/dist/goal-loop/driver.d.ts +112 -0
  4. package/dist/goal-loop/driver.d.ts.map +1 -0
  5. package/dist/goal-loop/driver.js +556 -0
  6. package/dist/goal-loop/driver.js.map +1 -0
  7. package/dist/goal-loop/state.d.ts +53 -0
  8. package/dist/goal-loop/state.d.ts.map +1 -0
  9. package/dist/goal-loop/state.js +80 -0
  10. package/dist/goal-loop/state.js.map +1 -0
  11. package/dist/goal-loop/templates.d.ts +79 -0
  12. package/dist/goal-loop/templates.d.ts.map +1 -0
  13. package/dist/goal-loop/templates.js +187 -0
  14. package/dist/goal-loop/templates.js.map +1 -0
  15. package/dist/handlers/sandbox-allow.d.ts +3 -0
  16. package/dist/handlers/sandbox-allow.d.ts.map +1 -1
  17. package/dist/handlers/sandbox-allow.js +21 -6
  18. package/dist/handlers/sandbox-allow.js.map +1 -1
  19. package/dist/handlers/session.d.ts +68 -1
  20. package/dist/handlers/session.d.ts.map +1 -1
  21. package/dist/handlers/session.js +291 -149
  22. package/dist/handlers/session.js.map +1 -1
  23. package/dist/handlers/slash.d.ts.map +1 -1
  24. package/dist/handlers/slash.js +58 -0
  25. package/dist/handlers/slash.js.map +1 -1
  26. package/dist/i18n.d.ts +18 -0
  27. package/dist/i18n.d.ts.map +1 -1
  28. package/dist/i18n.js +34 -0
  29. package/dist/i18n.js.map +1 -1
  30. package/dist/server.d.ts +25 -0
  31. package/dist/server.d.ts.map +1 -1
  32. package/dist/server.js +12 -0
  33. package/dist/server.js.map +1 -1
  34. package/dist/translators/event-translator.d.ts +23 -1
  35. package/dist/translators/event-translator.d.ts.map +1 -1
  36. package/dist/translators/event-translator.js +34 -4
  37. package/dist/translators/event-translator.js.map +1 -1
  38. package/dist/utils.d.ts +6 -0
  39. package/dist/utils.d.ts.map +1 -1
  40. package/dist/utils.js +5 -0
  41. package/dist/utils.js.map +1 -1
  42. package/docs/BACKLOG.md +2 -2
  43. package/docs/PROTOCOL.md +17 -1
  44. package/docs/RELEASING.md +2 -1
  45. package/package.json +1 -1
package/README.md CHANGED
@@ -237,7 +237,9 @@ Thanks to everyone who has contributed (updated automatically from the
237
237
  [contributors graph](https://github.com/william0wang/zcode-acp/graphs/contributors)):
238
238
 
239
239
  <a href="https://github.com/william0wang/zcode-acp/graphs/contributors">
240
- <img src="https://contrib.rocks/image?repo=william0wang/zcode-acp" alt="Contributors" />
240
+ <!-- release-please re-stamps &v= on every release: the new URL busts the
241
+ contrib.rocks and GitHub camo image caches. -->
242
+ <img src="https://contrib.rocks/image?repo=william0wang/zcode-acp&v=0.33.0" alt="Contributors" /> <!-- x-release-please-version -->
241
243
  </a>
242
244
 
243
245
  ## Related Projects
@@ -1,4 +1,4 @@
1
1
  {
2
- "fingerprint": "e6dadb69fa6f9cfd7e0da8827d2c0ee439aa10042e127a91a059bf95db436c8a",
3
- "fileCount": 72
2
+ "fingerprint": "7a587b589239abea7088f51681879c929f0c30580112c1aa9dfa93f8e1f69fce",
3
+ "fileCount": 75
4
4
  }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Goal-loop driver (ADR-0022): the bridge-driven autonomous turn chain.
3
+ *
4
+ * Round shape: one ticket per `session/send` turn via the shared
5
+ * {@link runOneTurn} machinery, a worker self-report VERDICT, and — only on a
6
+ * claimed `met` — one verification turn that re-runs the acceptance criteria
7
+ * (never trust the worker's report). Compaction runs at round boundaries
8
+ * (handoff turn → session/compact → the next dispatch reads the handoff doc).
9
+ *
10
+ * User interaction: rounds register in `pendingTurns` with `goalLoop: true`
11
+ * INSIDE withPreemptLock — `preemptInFlightTurn` skips them and the prompt
12
+ * path parks the incoming prompt on the driver instead (merge at the next
13
+ * boundary). ESC/cancel still cancels the in-flight round (pause follows).
14
+ * While prompts are parked, a 60s keepalive keeps clients from hitting their
15
+ * idle deadlines during the quiet judge/compaction windows.
16
+ */
17
+ import type * as acp from "@agentclientprotocol/sdk";
18
+ import type { ZcodeAcpServer } from "../server.js";
19
+ /** ENV: ZCODE_ACP_GOAL_MAX_TURNS — hard round budget before a pause. */
20
+ export declare function goalMaxTurns(): number;
21
+ /** Goal-loop compaction threshold: the shared env var, else 80% of window. */
22
+ export declare function goalCompactThreshold(contextWindow: number): number;
23
+ export declare class GoalLoopDriver {
24
+ readonly zcodeSid: string;
25
+ private readonly server;
26
+ private readonly acpSid;
27
+ private state;
28
+ private pauseFlag;
29
+ private stopFlag;
30
+ private parked;
31
+ private parkSeq;
32
+ private keepalive;
33
+ private runId;
34
+ /** Set when the last goal turn was cancelled by the sandbox allow-restart. */
35
+ private lastSandboxRestart;
36
+ private constructor();
37
+ /** Live driver for a session, when a loop is running. */
38
+ static live(server: ZcodeAcpServer, zcodeSid: string): GoalLoopDriver | undefined;
39
+ /**
40
+ * Start (or resume) the loop for a session. Resuming adopts the persisted
41
+ * state (round count, tickets, parked text); a fresh start decomposes the
42
+ * objective into tickets first.
43
+ */
44
+ static start(server: ZcodeAcpServer, acpSid: string, zcodeSid: string, objective: string, opts?: {
45
+ resume?: boolean;
46
+ }): GoalLoopDriver;
47
+ /** Pause at the next round boundary (the in-flight round keeps running). */
48
+ pause(): void;
49
+ /**
50
+ * External pause request — session/cancel during a quiet window with no
51
+ * registered turn (e.g. compact()'s internal wait): same flag as pause(),
52
+ * consumed at the next boundary.
53
+ */
54
+ requestPause(): void;
55
+ /** Clear a pending pause/stop (/auto resume before the boundary takes it). */
56
+ resume(): void;
57
+ /** Stop at the next boundary and clear persisted state. */
58
+ stop(): void;
59
+ /** One-line status for /auto status. */
60
+ statusText(): string;
61
+ /**
62
+ * Park an incoming user prompt (called by the prompt path when a goalLoop
63
+ * turn is in flight). Resolves when the merged round completes — or
64
+ * `cancelled` if the loop pauses/stops first (text preserved in state).
65
+ */
66
+ parkPrompt(text: string): Promise<acp.PromptResponse>;
67
+ private armKeepalive;
68
+ private disarmKeepalive;
69
+ /**
70
+ * Resolve parked prompts. Without a `snapshot`, everything currently parked
71
+ * settles (pause/stop/end-of-loop paths). With one, ONLY the snapshot's
72
+ * entries resolve — prompts parked DURING a round (the common steering
73
+ * window) stay parked and their text merges into the NEXT round instead of
74
+ * being silently resolved-and-dropped (ADR-0022 §3).
75
+ */
76
+ private settleParked;
77
+ /** One goal-loop turn through the shared runOneTurn (goalLoop-marked). */
78
+ private runGoalTurn;
79
+ /** Consume the sandbox-restart mark set by the last runGoalTurn. */
80
+ private consumeSandboxRestart;
81
+ /**
82
+ * Wait out in-flight NON-goal turns for this session before the first
83
+ * round: a send landing mid-generation is accepted as steer input and its
84
+ * text silently dropped when the old turn finishes (see AGENTS.md) — the
85
+ * decompose prompt would be injected into the foreign conversation and the
86
+ * tickets parsed from its reply. Real agent turns run minutes, so on timeout
87
+ * the wait PRE-EMPTS the editor turn with the same semantics a normal
88
+ * prompt uses (cancel flag + stop pair via preemptInFlightTurn) — proceeding
89
+ * would land the decompose send as steer input into the live conversation.
90
+ * runOneTurn's drain gate, armed by the pre-empt's lastCancelledAt mark,
91
+ * settles the backend before the decompose send.
92
+ */
93
+ private waitForEditorTurnsIdle;
94
+ /** Text of the last assistant reply at or after `since` (verdict parsing input). */
95
+ private lastAssistantText;
96
+ /** Tool-part count in the messages appended since `before` (stall signal). */
97
+ private toolActivitySince;
98
+ private messageCount;
99
+ private contextUsed;
100
+ private announce;
101
+ private persist;
102
+ private endLoop;
103
+ private run;
104
+ private runRounds;
105
+ private contextWindowFromRead;
106
+ /**
107
+ * Handoff turn → session/compact → mark handoffFresh for the next round.
108
+ * Returns true when the handoff turn was cancelled (ESC / restart).
109
+ */
110
+ private compactBoundary;
111
+ }
112
+ //# sourceMappingURL=driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/goal-loop/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;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