@skillstate/opencode 3.0.0 → 3.0.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.
Files changed (49) hide show
  1. package/README.md +196 -131
  2. package/dist/feedback.d.ts +178 -0
  3. package/dist/feedback.d.ts.map +1 -0
  4. package/dist/feedback.js +235 -0
  5. package/dist/feedback.js.map +1 -0
  6. package/dist/index.d.ts +33 -3
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +27 -3
  9. package/dist/index.js.map +1 -1
  10. package/dist/mode.d.ts +97 -0
  11. package/dist/mode.d.ts.map +1 -0
  12. package/dist/mode.js +111 -0
  13. package/dist/mode.js.map +1 -0
  14. package/dist/opencode-adapter.d.ts +4 -3
  15. package/dist/opencode-adapter.d.ts.map +1 -1
  16. package/dist/opencode-adapter.js.map +1 -1
  17. package/dist/paper-mode.d.ts +421 -0
  18. package/dist/paper-mode.d.ts.map +1 -0
  19. package/dist/paper-mode.js +445 -0
  20. package/dist/paper-mode.js.map +1 -0
  21. package/dist/plugin.d.ts +158 -8
  22. package/dist/plugin.d.ts.map +1 -1
  23. package/dist/plugin.js +788 -21
  24. package/dist/plugin.js.map +1 -1
  25. package/dist/response-sink.d.ts +208 -0
  26. package/dist/response-sink.d.ts.map +1 -0
  27. package/dist/response-sink.js +243 -0
  28. package/dist/response-sink.js.map +1 -0
  29. package/dist/runtime.d.ts +203 -0
  30. package/dist/runtime.d.ts.map +1 -0
  31. package/dist/runtime.js +332 -0
  32. package/dist/runtime.js.map +1 -0
  33. package/dist/spec-loader.d.ts +81 -0
  34. package/dist/spec-loader.d.ts.map +1 -0
  35. package/dist/spec-loader.js +163 -0
  36. package/dist/spec-loader.js.map +1 -0
  37. package/dist/step-boundary.d.ts +91 -0
  38. package/dist/step-boundary.d.ts.map +1 -0
  39. package/dist/step-boundary.js +109 -0
  40. package/dist/step-boundary.js.map +1 -0
  41. package/dist/system-hint.d.ts +70 -3
  42. package/dist/system-hint.d.ts.map +1 -1
  43. package/dist/system-hint.js +90 -11
  44. package/dist/system-hint.js.map +1 -1
  45. package/dist/tools.d.ts +35 -1
  46. package/dist/tools.d.ts.map +1 -1
  47. package/dist/tools.js +16 -0
  48. package/dist/tools.js.map +1 -1
  49. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,mFAAmF;AACnF,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,EAAE,EAAE,SAAS;IACb,KAAK,CAAC,KAAK,CAAC,GAAG;QACb,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAEnF,qEAAqE;QACrE,qEAAqE;QACrE,8DAA8D;QAC9D,MAAM,KAAK,GAAG,IAAI,iBAAiB,CAAC;YAClC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS;SAC1C,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,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AK;gBACL,cAAc;gBACd,oEAAoE;gBACpE,0DAA0D;gBAC1D,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;gBAChC,eAAe,EAAE,UAAU;aAC5B,CAAC,CAAC;YACH,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO;YAC9B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAChD,uEAAuE;YACvE,uEAAuE;YACvE,qEAAqE;YACrE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE;gBAC/C,KAAK;gBACL,KAAK,EAAE,UAAU;gBACjB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;gBAC9C,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;aACpC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * The write side of the paper transition, for the OpenCode host.
3
+ *
4
+ * ── The problem this solves ───────────────────────────────────────────────
5
+ *
6
+ * A.4 ends the prompt with a directive the model must obey:
7
+ *
8
+ * > 2. A JSON block fenced with json … containing both your State Patch and
9
+ * > your Action. The JSON block MUST have exactly these two keys:
10
+ * > `{ "state_patch": { … }, "action": "…" }`
11
+ *
12
+ * If nothing reads that block, Σₜ is frozen at whatever it held when paper
13
+ * mode was switched on, and every later step re-reads a state that stopped
14
+ * moving. On a long-horizon task — the entire reason the paper exists — that
15
+ * is silent, total failure that looks like the model "refusing to work".
16
+ *
17
+ * The v2 session API has no response hook: `SessionHooks` offers `prompt`,
18
+ * `context`, `compaction`, `generate`, `title`, the request/response HTTP
19
+ * hooks, the WebSocket hooks and `retry` — all of which run BEFORE or AROUND
20
+ * the model call. None of them see the completed assistant text.
21
+ *
22
+ * ── The surface that does carry it ────────────────────────────────────────
23
+ *
24
+ * The server's durable event stream does. `session.text.ended` publishes one
25
+ * finished assistant text block:
26
+ *
27
+ * ```ts
28
+ * { type: "session.text.ended",
29
+ * data: { sessionID, assistantMessageID, ordinal, text } }
30
+ * ```
31
+ *
32
+ * That is a public, documented, durable event — the same stream the plugin
33
+ * already subscribes to for the session tree. Parsing it with the core's own
34
+ * {@link PromptTransformer.parseResponse} means the A.4 prompt, the parser
35
+ * and the merge are the SAME code the benchmark measures, rather than a
36
+ * second implementation that can drift from the paper.
37
+ *
38
+ * ── What the sink guarantees ──────────────────────────────────────────────
39
+ *
40
+ * - **A rejected response never touches Σₜ** (the paper's Limitations). A
41
+ * missing block, malformed JSON, a missing `state_patch` or a missing
42
+ * `action` returns a result and changes nothing on disk.
43
+ * - **The patch is validated against P's schema** (§3.2) before it is
44
+ * merged, so a hallucinated key or a wrong-typed value is rejected rather
45
+ * than written.
46
+ * - **At most once per block.** Durable events can be replayed after a
47
+ * reconnect, and a replayed block must not apply its patch twice. Blocks
48
+ * are keyed by `assistantMessageID:ordinal` and remembered in a bounded
49
+ * set.
50
+ * - **Failures are values.** Every rejection is a typed
51
+ * {@link SinkOutcome}; nothing here throws into the event loop, and a
52
+ * state-write failure is reported rather than becoming an unhandled
53
+ * rejection that would take the plugin's subscription down.
54
+ */
55
+ import type { ProceduralSpec, StatePatch } from '@skillstate/core';
56
+ import type { StateChanges } from './state-store.js';
57
+ /** Why a text block did not become a state update. */
58
+ export type SinkRejection =
59
+ /** Not a `session.text.ended` payload, or it had no text. */
60
+ 'not_a_text_block'
61
+ /** This exact block was already processed (durable-event replay). */
62
+ | 'duplicate'
63
+ /** The text carried no ```json fence. */
64
+ | 'no_block'
65
+ /** The fence did not contain valid JSON. */
66
+ | 'malformed_json'
67
+ /** Valid JSON, but no `state_patch` object. */
68
+ | 'missing_state_patch'
69
+ /** Valid JSON, but `action` was not a string. */
70
+ | 'missing_action'
71
+ /** The patch failed P's schema (§3.2). */
72
+ | 'schema_invalid'
73
+ /** `state_patch` was an empty object — nothing to write. */
74
+ | 'empty_patch'
75
+ /** The write itself failed; Σₜ is unchanged. */
76
+ | 'write_failed';
77
+ /** The result of feeding one event to the sink. */
78
+ export interface SinkOutcome {
79
+ /** True when Σₜ was updated. */
80
+ readonly applied: boolean;
81
+ /** Set when nothing was written. */
82
+ readonly rejection?: SinkRejection;
83
+ /** The parser's or validator's message, for diagnostics. */
84
+ readonly detail?: string;
85
+ /** The keys the merge changed. Present only when `applied`. */
86
+ readonly changes?: StateChanges;
87
+ /** The action the model asked for. Present only when `applied`. */
88
+ readonly action?: string;
89
+ }
90
+ /** The `{ sessionID, assistantMessageID, ordinal, text }` payload. */
91
+ interface TextEndedEvent {
92
+ readonly type: 'session.text.ended';
93
+ readonly data: {
94
+ readonly sessionID: string;
95
+ readonly assistantMessageID: string;
96
+ readonly ordinal: number;
97
+ readonly text: string;
98
+ };
99
+ }
100
+ /**
101
+ * Whether an event is a completed assistant text block.
102
+ *
103
+ * Exported so a consumer that needs the session id from the same event does
104
+ * not re-implement this shape check — a second copy of the guard would be a
105
+ * second thing to keep in step with the event's actual fields.
106
+ */
107
+ export declare function isTextEnded(event: unknown): event is TextEndedEvent;
108
+ /**
109
+ * How many processed blocks are remembered for replay suppression.
110
+ *
111
+ * Bounded on purpose: the set lives for the process's lifetime, and an
112
+ * unbounded one would grow with every step of every session a long-lived
113
+ * OpenCode server ever runs. 4096 blocks is far more than the replay window
114
+ * a reconnect can produce, and eviction only costs a redundant write in the
115
+ * pathological case.
116
+ */
117
+ export declare const DEFAULT_DEDUPE_CAPACITY = 4096;
118
+ /** Dependencies for {@link PaperStateSink}. */
119
+ export interface PaperStateSinkOptions {
120
+ /** Where the patch is written. Runs its own lock + atomic write. */
121
+ readonly store: {
122
+ patch(scope: string, patch: StatePatch): Promise<{
123
+ state: Record<string, unknown>;
124
+ changes: StateChanges;
125
+ }>;
126
+ };
127
+ /** The spec P, for §3.2 validation. */
128
+ readonly spec: ProceduralSpec;
129
+ /** Maps a host session id to its on-disk scope. */
130
+ readonly scopeFor: (sessionID: string) => string;
131
+ /** How many block keys to remember. Defaults to 4096. */
132
+ readonly dedupeCapacity?: number;
133
+ }
134
+ /**
135
+ * Applies A.4 state patches emitted by the model to a session's Σₜ.
136
+ *
137
+ * One instance per plugin setup. The transformer is the core's, so the parse
138
+ * that runs here is the parse the paper's benchmark measures.
139
+ */
140
+ export declare class PaperStateSink {
141
+ private readonly store;
142
+ private readonly spec;
143
+ private readonly scopeFor;
144
+ private readonly capacity;
145
+ private readonly transformer;
146
+ private readonly seen;
147
+ constructor(options: PaperStateSinkOptions);
148
+ /**
149
+ * Fold one server event into Σₜ. Returns what happened.
150
+ *
151
+ * Never throws. Events that are not completed assistant text blocks, and
152
+ * every rejected block, come back as an outcome; only a state write that
153
+ * itself fails is reported as `write_failed`, still without throwing.
154
+ */
155
+ /**
156
+ * Apply a patch the transcript is already carrying, before the next request.
157
+ *
158
+ * ── Why this exists: a read-after-write race with the host ──────────────
159
+ *
160
+ * {@link ingest} learns of a patch from `session.text.ended`, delivered on
161
+ * an async iterator. The host does not wait for this plugin's loop: it
162
+ * starts the next model request as soon as its own agent loop turns, and
163
+ * that request re-enters the `context` hook — which reads Σ — before the
164
+ * event has been processed.
165
+ *
166
+ * Measured on a four-file task: the patch reached disk, and the very next
167
+ * request was served `{"total": 0}` while the file said 11. The model, shown
168
+ * a state that had not moved, re-read files it had already read and
169
+ * overwrote its own total. That reads exactly like a model that cannot
170
+ * accumulate, and it took a diagnostic to tell the two apart.
171
+ *
172
+ * The transcript handed to the context hook already contains the assistant
173
+ * text the model just emitted, so the patch is available here and now, with
174
+ * no dependence on event timing. The durable path is unchanged: the event
175
+ * still arrives and {@link ingest} still applies it — it simply finds the
176
+ * message already marked and declines, so the same patch is never applied
177
+ * twice.
178
+ */
179
+ recover(sessionID: string, messages: ReadonlyArray<{
180
+ id: string;
181
+ role: string;
182
+ content: unknown;
183
+ }>): Promise<SinkOutcome>;
184
+ ingest(event: unknown): Promise<SinkOutcome>;
185
+ /**
186
+ * Parse, validate and merge one response. Shared by both entry points so the
187
+ * durable path and the recovery path cannot drift on what counts as a valid
188
+ * patch — a second copy of this is a second set of rules to keep in step.
189
+ */
190
+ private apply;
191
+ /** Forget every remembered block (test isolation, and a clean reload). */
192
+ reset(): void;
193
+ /** How many block keys are currently remembered. */
194
+ get size(): number;
195
+ /**
196
+ * Record a processed block, evicting the oldest while over capacity.
197
+ *
198
+ * `Set` preserves insertion order, so the first key is the oldest. The
199
+ * iterator cannot report exhaustion here: the loop condition requires
200
+ * `size > capacity` and `capacity` is never negative, so the set always
201
+ * holds at least one key and the deletion always makes progress. A
202
+ * `capacity` of 0 is therefore legal and means "remember nothing", which
203
+ * degrades replay suppression to a no-op rather than to an error.
204
+ */
205
+ private remember;
206
+ }
207
+ export {};
208
+ //# sourceMappingURL=response-sink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-sink.d.ts","sourceRoot":"","sources":["../src/response-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,sDAAsD;AACtD,MAAM,MAAM,aAAa;AACvB,6DAA6D;AAC3D,kBAAkB;AACpB,qEAAqE;GACnE,WAAW;AACb,yCAAyC;GACvC,UAAU;AACZ,4CAA4C;GAC1C,gBAAgB;AAClB,+CAA+C;GAC7C,qBAAqB;AACvB,iDAAiD;GAC/C,gBAAgB;AAClB,0CAA0C;GACxC,gBAAgB;AAClB,4DAA4D;GAC1D,aAAa;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,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IACjD,yDAAyD;IACzD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAqCD;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgC;IACzD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2B;IACvD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAE1C,YAAY,OAAO,EAAE,qBAAqB,EAKzC;IAED;;;;;;OAMG;IACH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAO9H;IAEK,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAcjD;IAED;;;;OAIG;YACW,KAAK;IAsBnB,0EAA0E;IAC1E,KAAK,IAAI,IAAI,CAEZ;IAED,oDAAoD;IACpD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,QAAQ;CAOjB"}
@@ -0,0 +1,243 @@
1
+ /**
2
+ * The write side of the paper transition, for the OpenCode host.
3
+ *
4
+ * ── The problem this solves ───────────────────────────────────────────────
5
+ *
6
+ * A.4 ends the prompt with a directive the model must obey:
7
+ *
8
+ * > 2. A JSON block fenced with json … containing both your State Patch and
9
+ * > your Action. The JSON block MUST have exactly these two keys:
10
+ * > `{ "state_patch": { … }, "action": "…" }`
11
+ *
12
+ * If nothing reads that block, Σₜ is frozen at whatever it held when paper
13
+ * mode was switched on, and every later step re-reads a state that stopped
14
+ * moving. On a long-horizon task — the entire reason the paper exists — that
15
+ * is silent, total failure that looks like the model "refusing to work".
16
+ *
17
+ * The v2 session API has no response hook: `SessionHooks` offers `prompt`,
18
+ * `context`, `compaction`, `generate`, `title`, the request/response HTTP
19
+ * hooks, the WebSocket hooks and `retry` — all of which run BEFORE or AROUND
20
+ * the model call. None of them see the completed assistant text.
21
+ *
22
+ * ── The surface that does carry it ────────────────────────────────────────
23
+ *
24
+ * The server's durable event stream does. `session.text.ended` publishes one
25
+ * finished assistant text block:
26
+ *
27
+ * ```ts
28
+ * { type: "session.text.ended",
29
+ * data: { sessionID, assistantMessageID, ordinal, text } }
30
+ * ```
31
+ *
32
+ * That is a public, documented, durable event — the same stream the plugin
33
+ * already subscribes to for the session tree. Parsing it with the core's own
34
+ * {@link PromptTransformer.parseResponse} means the A.4 prompt, the parser
35
+ * and the merge are the SAME code the benchmark measures, rather than a
36
+ * second implementation that can drift from the paper.
37
+ *
38
+ * ── What the sink guarantees ──────────────────────────────────────────────
39
+ *
40
+ * - **A rejected response never touches Σₜ** (the paper's Limitations). A
41
+ * missing block, malformed JSON, a missing `state_patch` or a missing
42
+ * `action` returns a result and changes nothing on disk.
43
+ * - **The patch is validated against P's schema** (§3.2) before it is
44
+ * merged, so a hallucinated key or a wrong-typed value is rejected rather
45
+ * than written.
46
+ * - **At most once per block.** Durable events can be replayed after a
47
+ * reconnect, and a replayed block must not apply its patch twice. Blocks
48
+ * are keyed by `assistantMessageID:ordinal` and remembered in a bounded
49
+ * set.
50
+ * - **Failures are values.** Every rejection is a typed
51
+ * {@link SinkOutcome}; nothing here throws into the event loop, and a
52
+ * state-write failure is reported rather than becoming an unhandled
53
+ * rejection that would take the plugin's subscription down.
54
+ */
55
+ import { PromptTransformer, validatePatch } from '@skillstate/core';
56
+ /**
57
+ * Whether an event is a completed assistant text block.
58
+ *
59
+ * Exported so a consumer that needs the session id from the same event does
60
+ * not re-implement this shape check — a second copy of the guard would be a
61
+ * second thing to keep in step with the event's actual fields.
62
+ */
63
+ export function isTextEnded(event) {
64
+ if (typeof event !== 'object' || event === null)
65
+ return false;
66
+ const type = event.type;
67
+ if (type !== 'session.text.ended')
68
+ return false;
69
+ const data = event.data;
70
+ if (typeof data !== 'object' || data === null)
71
+ return false;
72
+ const record = data;
73
+ return (typeof record['sessionID'] === 'string' &&
74
+ typeof record['assistantMessageID'] === 'string' &&
75
+ typeof record['ordinal'] === 'number' &&
76
+ typeof record['text'] === 'string');
77
+ }
78
+ /**
79
+ * How many processed blocks are remembered for replay suppression.
80
+ *
81
+ * Bounded on purpose: the set lives for the process's lifetime, and an
82
+ * unbounded one would grow with every step of every session a long-lived
83
+ * OpenCode server ever runs. 4096 blocks is far more than the replay window
84
+ * a reconnect can produce, and eviction only costs a redundant write in the
85
+ * pathological case.
86
+ */
87
+ export const DEFAULT_DEDUPE_CAPACITY = 4096;
88
+ const NOT_A_TEXT_BLOCK = { applied: false, rejection: 'not_a_text_block' };
89
+ /** The key the recovery path claims a message under, shared with `ingest`. */
90
+ function recoveredKey(messageID) {
91
+ return `${messageID}:recovered`;
92
+ }
93
+ /**
94
+ * The most recent assistant text in a transcript, or `undefined`.
95
+ *
96
+ * Scans backwards because the newest is the one being recovered, and because
97
+ * a transcript can hold several assistant messages whose earlier patches are
98
+ * long since applied. Only text parts count: a reasoning or tool-call part
99
+ * carries no patch, and treating one as a response would reject a message that
100
+ * was never a rejection.
101
+ */
102
+ function lastAssistantText(messages) {
103
+ for (let i = messages.length - 1; i >= 0; i -= 1) {
104
+ const message = messages[i];
105
+ if (message.role !== 'assistant' || !Array.isArray(message.content))
106
+ continue;
107
+ for (const part of message.content) {
108
+ if (part?.type === 'text' && typeof part.text === 'string' && part.text.length > 0) {
109
+ return { id: message.id, text: part.text };
110
+ }
111
+ }
112
+ }
113
+ return undefined;
114
+ }
115
+ function reject(rejection, detail) {
116
+ return detail === undefined ? { applied: false, rejection } : { applied: false, rejection, detail };
117
+ }
118
+ /**
119
+ * Applies A.4 state patches emitted by the model to a session's Σₜ.
120
+ *
121
+ * One instance per plugin setup. The transformer is the core's, so the parse
122
+ * that runs here is the parse the paper's benchmark measures.
123
+ */
124
+ export class PaperStateSink {
125
+ store;
126
+ spec;
127
+ scopeFor;
128
+ capacity;
129
+ transformer = new PromptTransformer();
130
+ seen = new Set();
131
+ constructor(options) {
132
+ this.store = options.store;
133
+ this.spec = options.spec;
134
+ this.scopeFor = options.scopeFor;
135
+ this.capacity = options.dedupeCapacity ?? DEFAULT_DEDUPE_CAPACITY;
136
+ }
137
+ /**
138
+ * Fold one server event into Σₜ. Returns what happened.
139
+ *
140
+ * Never throws. Events that are not completed assistant text blocks, and
141
+ * every rejected block, come back as an outcome; only a state write that
142
+ * itself fails is reported as `write_failed`, still without throwing.
143
+ */
144
+ /**
145
+ * Apply a patch the transcript is already carrying, before the next request.
146
+ *
147
+ * ── Why this exists: a read-after-write race with the host ──────────────
148
+ *
149
+ * {@link ingest} learns of a patch from `session.text.ended`, delivered on
150
+ * an async iterator. The host does not wait for this plugin's loop: it
151
+ * starts the next model request as soon as its own agent loop turns, and
152
+ * that request re-enters the `context` hook — which reads Σ — before the
153
+ * event has been processed.
154
+ *
155
+ * Measured on a four-file task: the patch reached disk, and the very next
156
+ * request was served `{"total": 0}` while the file said 11. The model, shown
157
+ * a state that had not moved, re-read files it had already read and
158
+ * overwrote its own total. That reads exactly like a model that cannot
159
+ * accumulate, and it took a diagnostic to tell the two apart.
160
+ *
161
+ * The transcript handed to the context hook already contains the assistant
162
+ * text the model just emitted, so the patch is available here and now, with
163
+ * no dependence on event timing. The durable path is unchanged: the event
164
+ * still arrives and {@link ingest} still applies it — it simply finds the
165
+ * message already marked and declines, so the same patch is never applied
166
+ * twice.
167
+ */
168
+ async recover(sessionID, messages) {
169
+ const latest = lastAssistantText(messages);
170
+ if (latest === undefined)
171
+ return NOT_A_TEXT_BLOCK;
172
+ const key = recoveredKey(latest.id);
173
+ if (this.seen.has(key))
174
+ return reject('duplicate');
175
+ return this.apply(key, sessionID, latest.text);
176
+ }
177
+ async ingest(event) {
178
+ if (!isTextEnded(event))
179
+ return NOT_A_TEXT_BLOCK;
180
+ const { sessionID, assistantMessageID, ordinal, text } = event.data;
181
+ const key = `${assistantMessageID}:${ordinal}`;
182
+ // The recovery path marks the same message under a different suffix, and
183
+ // it runs first. Without this check the patch would be merged twice, which
184
+ // is worse than the race it fixes: an accumulator would double its own
185
+ // total.
186
+ if (this.seen.has(key) || this.seen.has(recoveredKey(assistantMessageID))) {
187
+ return reject('duplicate');
188
+ }
189
+ return this.apply(key, sessionID, text);
190
+ }
191
+ /**
192
+ * Parse, validate and merge one response. Shared by both entry points so the
193
+ * durable path and the recovery path cannot drift on what counts as a valid
194
+ * patch — a second copy of this is a second set of rules to keep in step.
195
+ */
196
+ async apply(key, sessionID, text) {
197
+ this.remember(key);
198
+ const parsed = this.transformer.parseResponse(text);
199
+ if (!parsed.ok)
200
+ return reject(parsed.reason, parsed.detail);
201
+ const patch = parsed.patch;
202
+ if (Object.keys(patch).length === 0)
203
+ return reject('empty_patch');
204
+ // §3.2 — an unknown key or a wrong type is rejected before the merge,
205
+ // so a malformed patch can never reach disk.
206
+ const validation = validatePatch(this.spec.schema, patch);
207
+ if (!validation.valid)
208
+ return reject('schema_invalid', validation.error);
209
+ try {
210
+ const { changes } = await this.store.patch(this.scopeFor(sessionID), patch);
211
+ return { applied: true, changes, action: parsed.action };
212
+ }
213
+ catch (error) {
214
+ return reject('write_failed', String(error));
215
+ }
216
+ }
217
+ /** Forget every remembered block (test isolation, and a clean reload). */
218
+ reset() {
219
+ this.seen.clear();
220
+ }
221
+ /** How many block keys are currently remembered. */
222
+ get size() {
223
+ return this.seen.size;
224
+ }
225
+ /**
226
+ * Record a processed block, evicting the oldest while over capacity.
227
+ *
228
+ * `Set` preserves insertion order, so the first key is the oldest. The
229
+ * iterator cannot report exhaustion here: the loop condition requires
230
+ * `size > capacity` and `capacity` is never negative, so the set always
231
+ * holds at least one key and the deletion always makes progress. A
232
+ * `capacity` of 0 is therefore legal and means "remember nothing", which
233
+ * degrades replay suppression to a no-op rather than to an error.
234
+ */
235
+ remember(key) {
236
+ this.seen.add(key);
237
+ while (this.seen.size > this.capacity) {
238
+ const [oldest] = this.seen;
239
+ this.seen.delete(oldest);
240
+ }
241
+ }
242
+ }
243
+ //# sourceMappingURL=response-sink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-sink.js","sourceRoot":"","sources":["../src/response-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAkDpE;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,IAAI,GAAI,KAA4B,CAAC,IAAI,CAAC;IAChD,IAAI,IAAI,KAAK,oBAAoB;QAAE,OAAO,KAAK,CAAC;IAChD,MAAM,IAAI,GAAI,KAA4B,CAAC,IAAI,CAAC;IAChD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC5D,MAAM,MAAM,GAAG,IAA+B,CAAC;IAC/C,OAAO,CACL,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,QAAQ;QACvC,OAAO,MAAM,CAAC,oBAAoB,CAAC,KAAK,QAAQ;QAChD,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,QAAQ;QACrC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,QAAQ,CACnC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,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