@earendil-works/chord 1.2.0 → 1.3.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 (86) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +14 -13
  3. package/dist/cell.d.ts +30 -9
  4. package/dist/cell.d.ts.map +1 -1
  5. package/dist/cell.js +52 -12
  6. package/dist/cell.js.map +1 -1
  7. package/dist/cluster.d.ts +4 -3
  8. package/dist/cluster.d.ts.map +1 -1
  9. package/dist/cluster.js +58 -42
  10. package/dist/cluster.js.map +1 -1
  11. package/dist/connection.d.ts +171 -58
  12. package/dist/connection.d.ts.map +1 -1
  13. package/dist/connection.js +676 -217
  14. package/dist/connection.js.map +1 -1
  15. package/dist/contract.d.ts +120 -45
  16. package/dist/contract.d.ts.map +1 -1
  17. package/dist/contract.js +104 -15
  18. package/dist/contract.js.map +1 -1
  19. package/dist/declare.d.ts +11 -48
  20. package/dist/declare.d.ts.map +1 -1
  21. package/dist/declare.js +1 -21
  22. package/dist/declare.js.map +1 -1
  23. package/dist/delta/index.d.ts +2 -1
  24. package/dist/delta/index.d.ts.map +1 -1
  25. package/dist/delta/index.js +4 -0
  26. package/dist/delta/index.js.map +1 -1
  27. package/dist/errors.d.ts +4 -3
  28. package/dist/errors.d.ts.map +1 -1
  29. package/dist/errors.js +15 -0
  30. package/dist/errors.js.map +1 -1
  31. package/dist/host.d.ts +214 -120
  32. package/dist/host.d.ts.map +1 -1
  33. package/dist/host.js +446 -241
  34. package/dist/host.js.map +1 -1
  35. package/dist/index.d.ts +8 -8
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +4 -4
  38. package/dist/index.js.map +1 -1
  39. package/dist/link.d.ts +47 -12
  40. package/dist/link.d.ts.map +1 -1
  41. package/dist/link.js +200 -14
  42. package/dist/link.js.map +1 -1
  43. package/dist/loader.d.ts.map +1 -1
  44. package/dist/loader.js +7 -2
  45. package/dist/loader.js.map +1 -1
  46. package/dist/manager.d.ts.map +1 -1
  47. package/dist/manager.js +35 -9
  48. package/dist/manager.js.map +1 -1
  49. package/dist/object.d.ts +438 -0
  50. package/dist/object.d.ts.map +1 -0
  51. package/dist/{record.js → object.js} +614 -335
  52. package/dist/object.js.map +1 -0
  53. package/dist/output.d.ts +85 -0
  54. package/dist/output.d.ts.map +1 -0
  55. package/dist/output.js +350 -0
  56. package/dist/output.js.map +1 -0
  57. package/dist/registry.d.ts +3 -3
  58. package/dist/registry.d.ts.map +1 -1
  59. package/dist/registry.js +1 -1
  60. package/dist/registry.js.map +1 -1
  61. package/dist/reload.d.ts +35 -27
  62. package/dist/reload.d.ts.map +1 -1
  63. package/dist/reload.js +256 -192
  64. package/dist/reload.js.map +1 -1
  65. package/dist/remote.d.ts +130 -35
  66. package/dist/remote.d.ts.map +1 -1
  67. package/dist/remote.js +493 -189
  68. package/dist/remote.js.map +1 -1
  69. package/dist/types.d.ts +39 -28
  70. package/dist/types.d.ts.map +1 -1
  71. package/dist/types.js.map +1 -1
  72. package/dist/websocket.d.ts +4 -5
  73. package/dist/websocket.d.ts.map +1 -1
  74. package/dist/websocket.js +3 -2
  75. package/dist/websocket.js.map +1 -1
  76. package/dist/wire.d.ts +210 -129
  77. package/dist/wire.d.ts.map +1 -1
  78. package/dist/wire.js +108 -55
  79. package/dist/wire.js.map +1 -1
  80. package/docs/guide.md +267 -203
  81. package/docs/spec.md +141 -114
  82. package/docs/tutorial.md +257 -235
  83. package/package.json +6 -1
  84. package/dist/record.d.ts +0 -320
  85. package/dist/record.d.ts.map +0 -1
  86. package/dist/record.js.map +0 -1
package/dist/output.js ADDED
@@ -0,0 +1,350 @@
1
+ /**
2
+ * Bounded output streams and adaptive progress commits: `OutputBuffer` keeps a head or tail window of a stream at a cost
3
+ * proportional to each chunk, and `Progress` paces commits of a changing value by their size.
4
+ */
5
+ const NEWLINE = 0x0a;
6
+ const INVALID_OUTPUT = /[\x00-\x08\x0b-\x1f\ufff9-\ufffb]/g;
7
+ const encoder = new TextEncoder();
8
+ /** Slices decode exactly: a U+FEFF at a slice's start is text, not a byte-order mark. */
9
+ const decoder = new TextDecoder("utf-8", { ignoreBOM: true });
10
+ /** Remove control characters that break display and transcripts; tabs and newlines stay. */
11
+ export function sanitizeOutput(text) {
12
+ return text.replace(INVALID_OUTPUT, "");
13
+ }
14
+ /**
15
+ * Bound `text` to whole lines within the limits: the first lines for `head`, the last lines for `tail`. The result is an
16
+ * exact slice, trailing newline included. A single line longer than `maxBytes` is cut at the byte limit on a character
17
+ * boundary.
18
+ */
19
+ export function boundOutput(text, limits) {
20
+ const bytes = encoder.encode(text);
21
+ const [from, to] = limits.retain === "head" ? headRange(bytes, limits) : tailRange(bytes, limits);
22
+ const kept = bytes.subarray(from, to);
23
+ return {
24
+ text: kept.length === bytes.length ? text : decoder.decode(kept),
25
+ bytes: kept.length,
26
+ droppedBytes: bytes.length - kept.length,
27
+ droppedLines: lineCount(bytes) - lineCount(kept),
28
+ };
29
+ }
30
+ function headRange(bytes, limits) {
31
+ if (limits.maxLines === 0 || limits.maxBytes === 0)
32
+ return [0, 0];
33
+ let end = bytes.length;
34
+ let lines = 0;
35
+ for (let index = bytes.indexOf(NEWLINE); index !== -1; index = bytes.indexOf(NEWLINE, index + 1)) {
36
+ if (++lines === limits.maxLines) {
37
+ end = index + 1;
38
+ break;
39
+ }
40
+ }
41
+ if (end > limits.maxBytes) {
42
+ const newline = bytes.lastIndexOf(NEWLINE, limits.maxBytes - 1);
43
+ end = newline === -1 ? characterEnd(bytes, limits.maxBytes) : newline + 1;
44
+ }
45
+ return [0, end];
46
+ }
47
+ function tailRange(bytes, limits) {
48
+ if (limits.maxLines === 0 || limits.maxBytes === 0)
49
+ return [bytes.length, bytes.length];
50
+ // A trailing newline ends the last line rather than starting another.
51
+ const last = bytes[bytes.length - 1] === NEWLINE ? bytes.length - 2 : bytes.length - 1;
52
+ let start = 0;
53
+ let lines = 1;
54
+ for (let index = last < 0 ? -1 : bytes.lastIndexOf(NEWLINE, last); index !== -1;) {
55
+ if (lines === limits.maxLines) {
56
+ start = index + 1;
57
+ break;
58
+ }
59
+ lines++;
60
+ index = index === 0 ? -1 : bytes.lastIndexOf(NEWLINE, index - 1);
61
+ }
62
+ if (bytes.length - start > limits.maxBytes) {
63
+ const from = bytes.length - limits.maxBytes;
64
+ const newline = bytes.indexOf(NEWLINE, from - 1);
65
+ // The first line starting inside the byte window, or a cut of the last line when it alone is too long.
66
+ start = newline !== -1 && newline + 1 < bytes.length ? newline + 1 : characterStart(bytes, from);
67
+ }
68
+ return [start, bytes.length];
69
+ }
70
+ /** The last character boundary at or before `index`. */
71
+ export function characterEnd(bytes, index) {
72
+ let end = index;
73
+ while (end > 0 && ((bytes[end] ?? 0) & 0xc0) === 0x80)
74
+ end--;
75
+ return end;
76
+ }
77
+ /** The first character boundary at or after `index`. */
78
+ function characterStart(bytes, index) {
79
+ let start = index;
80
+ while (start < bytes.length && ((bytes[start] ?? 0) & 0xc0) === 0x80)
81
+ start++;
82
+ return start;
83
+ }
84
+ function lineCount(bytes) {
85
+ if (bytes.length === 0)
86
+ return 0;
87
+ let newlines = 0;
88
+ for (let index = bytes.indexOf(NEWLINE); index !== -1; index = bytes.indexOf(NEWLINE, index + 1))
89
+ newlines++;
90
+ return newlines + (bytes[bytes.length - 1] === NEWLINE ? 0 : 1);
91
+ }
92
+ /**
93
+ * Bounded running output of one stream, such as a tool call's or a process's. Accepting a chunk costs time proportional to the chunk: head retention stops
94
+ * storing once the window is full, and tail retention drops stored text the window no longer needs when it snapshots.
95
+ * Counts of the whole stream are kept so the dropped totals stay exact.
96
+ */
97
+ export class OutputBuffer {
98
+ #limits;
99
+ /**
100
+ * Decoder of byte chunks. A string chunk or a skip ends an incomplete character of earlier bytes (it becomes U+FFFD);
101
+ * the next byte chunk then starts a new character. As in `StreamDecoder`, only a byte-order mark at the very start of
102
+ * the output is dropped, never a U+FEFF later in it.
103
+ */
104
+ #decoder = new TextDecoder("utf-8", { ignoreBOM: true });
105
+ #started = false;
106
+ /** Stored chunks: for head the start of the stream, for tail a suffix that still contains the next window. */
107
+ #chunks = [];
108
+ #storedBytes = 0;
109
+ #storedNewlines = 0;
110
+ #full = false;
111
+ #totalBytes = 0;
112
+ #totalNewlines = 0;
113
+ #endsWithNewline = true;
114
+ constructor(limits) {
115
+ this.#limits = limits;
116
+ }
117
+ /** Bytes currently held; bounded by the limits plus one chunk. */
118
+ get storedBytes() {
119
+ return this.#storedBytes;
120
+ }
121
+ /**
122
+ * Accept a chunk; returns whether anything was accepted. `skipped` is output omitted right before the chunk, which
123
+ * must be more than the tail window by at least one byte or line; only tail retention accepts it.
124
+ */
125
+ push(chunk, skipped) {
126
+ // Bytes of an incomplete character from an earlier byte chunk come first.
127
+ const pending = typeof chunk === "string" || skipped !== undefined ? this.#decoder.decode() : "";
128
+ let text = typeof chunk === "string" ? chunk : this.#decoder.decode(chunk, { stream: true });
129
+ const first = !this.#started && pending === "" && skipped === undefined;
130
+ if (pending !== "" || text !== "" || skipped !== undefined)
131
+ this.#started = true;
132
+ if (first && typeof chunk !== "string" && text.startsWith("\ufeff"))
133
+ text = text.slice(1);
134
+ if (skipped === undefined)
135
+ return this.#accept(pending + text);
136
+ if (this.#limits.retain !== "tail")
137
+ throw new Error("Skipped output requires tail retention");
138
+ this.#accept(pending);
139
+ this.#skip(skipped);
140
+ this.#accept(text);
141
+ return true;
142
+ }
143
+ /** Count omitted output; nothing stored before it can be in the window once the text after it arrives. */
144
+ #skip(skipped) {
145
+ if (skipped.bytes === 0)
146
+ return;
147
+ this.#totalBytes += skipped.bytes;
148
+ this.#totalNewlines += skipped.newlines;
149
+ this.#endsWithNewline = skipped.endsWithNewline;
150
+ this.#chunks = [];
151
+ this.#storedBytes = 0;
152
+ this.#storedNewlines = 0;
153
+ }
154
+ /** Flush an incomplete trailing character as a replacement character; call when the stream ends. */
155
+ end() {
156
+ this.#accept(this.#decoder.decode());
157
+ }
158
+ #accept(text) {
159
+ if (text.length === 0)
160
+ return false;
161
+ const bytes = utf8ByteLength(text);
162
+ const newlines = countNewlines(text);
163
+ this.#totalBytes += bytes;
164
+ this.#totalNewlines += newlines;
165
+ this.#endsWithNewline = text.endsWith("\n");
166
+ if (this.#full)
167
+ return true;
168
+ this.#chunks.push({ text, bytes, newlines });
169
+ this.#storedBytes += bytes;
170
+ this.#storedNewlines += newlines;
171
+ if (this.#limits.retain === "head") {
172
+ // Nothing past a full window is ever needed.
173
+ this.#full = this.#storedBytes > this.#limits.maxBytes || this.#storedNewlines >= this.#limits.maxLines;
174
+ return true;
175
+ }
176
+ // Drop leading chunks while the rest still holds more than a window: more than `maxBytes` bytes or `maxLines`
177
+ // newlines, plus one, so the window's line start can still be found. Each chunk is dropped once.
178
+ while (this.#chunks.length > 1) {
179
+ const first = this.#chunks[0];
180
+ const bytesAfter = this.#storedBytes - first.bytes;
181
+ const newlinesAfter = this.#storedNewlines - first.newlines;
182
+ if (bytesAfter <= this.#limits.maxBytes + 1 && newlinesAfter <= this.#limits.maxLines + 1)
183
+ break;
184
+ this.#chunks.shift();
185
+ this.#storedBytes = bytesAfter;
186
+ this.#storedNewlines = newlinesAfter;
187
+ }
188
+ return true;
189
+ }
190
+ /** Retained, sanitized output and what the limits dropped from the whole stream. */
191
+ snapshot() {
192
+ const stored = this.#chunks.length === 1 ? this.#chunks[0].text : this.#chunks.map((chunk) => chunk.text).join("");
193
+ const kept = boundOutput(stored, this.#limits);
194
+ const storedLines = lines(this.#storedNewlines, stored === "" || stored.endsWith("\n"));
195
+ const keptLines = storedLines - kept.droppedLines;
196
+ // Tail windows never reach back before this one, but finding a later window's first line needs what precedes it:
197
+ // keep the shortest suffix longer than the window by a byte or a line, as `#accept` does.
198
+ if (this.#limits.retain === "tail" || this.#chunks.length > 1) {
199
+ const text = this.#limits.retain === "tail" ? tailMargin(stored, this.#limits) : stored;
200
+ const bytes = this.#limits.retain === "tail" ? utf8ByteLength(text) : this.#storedBytes;
201
+ this.#chunks = text === "" ? [] : [{ text, bytes, newlines: countNewlines(text) }];
202
+ this.#storedBytes = bytes;
203
+ this.#storedNewlines = this.#chunks[0]?.newlines ?? 0;
204
+ }
205
+ return {
206
+ text: sanitizeOutput(kept.text),
207
+ droppedBytes: this.#totalBytes - kept.bytes,
208
+ droppedLines: lines(this.#totalNewlines, this.#endsWithNewline) - keptLines,
209
+ };
210
+ }
211
+ }
212
+ /**
213
+ * The shortest suffix of `text` with more than `maxBytes` bytes or more than `maxLines` newlines, or all of it. The
214
+ * tail window of any text that ends with this suffix, followed by anything, is the same as of `text` followed by it.
215
+ */
216
+ function tailMargin(text, limits) {
217
+ const bytes = encoder.encode(text);
218
+ const byteStart = bytes.length > limits.maxBytes ? characterEnd(bytes, bytes.length - limits.maxBytes - 1) : 0;
219
+ let lineStart = 0;
220
+ let newlines = 0;
221
+ for (let index = bytes.lastIndexOf(NEWLINE); index !== -1; index = bytes.lastIndexOf(NEWLINE, index - 1)) {
222
+ if (++newlines > limits.maxLines) {
223
+ lineStart = index;
224
+ break;
225
+ }
226
+ if (index === 0)
227
+ break;
228
+ }
229
+ const start = Math.max(byteStart, lineStart);
230
+ return start === 0 ? text : decoder.decode(bytes.subarray(start));
231
+ }
232
+ /** Lines of text with `newlines` newlines; a final unterminated line counts. */
233
+ function lines(newlines, terminated) {
234
+ return newlines + (terminated ? 0 : 1);
235
+ }
236
+ const runtimeBuffer = globalThis.Buffer;
237
+ const nonAsciiPattern = /[^\x00-\x7f]/;
238
+ /** UTF-8 byte length of `content`; a lone surrogate counts as U+FFFD, three bytes. */
239
+ export function utf8ByteLength(content) {
240
+ if (runtimeBuffer)
241
+ return runtimeBuffer.byteLength(content, "utf8");
242
+ const firstNonAscii = content.search(nonAsciiPattern);
243
+ if (firstNonAscii === -1)
244
+ return content.length;
245
+ let bytes = firstNonAscii;
246
+ for (let i = firstNonAscii; i < content.length; i++) {
247
+ const code = content.charCodeAt(i);
248
+ if (code <= 0x7f)
249
+ bytes += 1;
250
+ else if (code <= 0x7ff)
251
+ bytes += 2;
252
+ else if (code >= 0xd800 && code <= 0xdbff && i + 1 < content.length) {
253
+ const next = content.charCodeAt(i + 1);
254
+ if (next >= 0xdc00 && next <= 0xdfff) {
255
+ bytes += 4;
256
+ i++;
257
+ }
258
+ else
259
+ bytes += 3;
260
+ }
261
+ else
262
+ bytes += 3;
263
+ }
264
+ return bytes;
265
+ }
266
+ function countNewlines(text) {
267
+ let count = 0;
268
+ for (let index = text.indexOf("\n"); index !== -1; index = text.indexOf("\n", index + 1))
269
+ count++;
270
+ return count;
271
+ }
272
+ /** Each progress commit also buys a pause proportional to what it wrote. */
273
+ export const PROGRESS_BYTES_PER_SECOND = 100 * 1024;
274
+ /**
275
+ * Adaptive progress commits: the first change after an idle period commits at once; each commit then delays the next
276
+ * by at least `minIntervalMs` and by its written size at 100 KiB/s. At most one commit is in flight; changes made
277
+ * meanwhile coalesce into the next one.
278
+ */
279
+ export class Progress {
280
+ #write;
281
+ #onError;
282
+ #minIntervalMs;
283
+ #waiters = [];
284
+ #timer;
285
+ #inFlight;
286
+ #nextAt = 0;
287
+ #dirty = false;
288
+ #stopped = false;
289
+ constructor(write, onError, minIntervalMs) {
290
+ this.#write = write;
291
+ this.#onError = onError;
292
+ this.#minIntervalMs = minIntervalMs;
293
+ }
294
+ /** Schedule a commit. */
295
+ mark() {
296
+ this.#dirty = true;
297
+ this.#schedule();
298
+ }
299
+ /** Schedule a commit; the promise settles with the commit that includes this change. */
300
+ markAndWait() {
301
+ const waiter = Promise.withResolvers();
302
+ this.#waiters.push(waiter);
303
+ this.mark();
304
+ return waiter.promise;
305
+ }
306
+ /** Stop committing and wait for the commit in flight; returns the waiters the final commit must settle. */
307
+ async stop() {
308
+ this.#stopped = true;
309
+ clearTimeout(this.#timer);
310
+ this.#timer = undefined;
311
+ await this.#inFlight;
312
+ return this.#waiters.splice(0);
313
+ }
314
+ #schedule() {
315
+ if (this.#stopped || this.#timer !== undefined || this.#inFlight !== undefined)
316
+ return;
317
+ const wait = this.#nextAt - Date.now();
318
+ if (wait <= 0)
319
+ this.#flush();
320
+ else
321
+ this.#timer = setTimeout(() => {
322
+ this.#timer = undefined;
323
+ this.#flush();
324
+ }, wait);
325
+ }
326
+ #flush() {
327
+ if (this.#stopped || !this.#dirty)
328
+ return;
329
+ this.#dirty = false;
330
+ const waiters = this.#waiters.splice(0);
331
+ const started = Date.now();
332
+ this.#inFlight = this.#write()
333
+ .then((bytes) => {
334
+ this.#nextAt = started + Math.max(this.#minIntervalMs, (bytes * 1000) / PROGRESS_BYTES_PER_SECOND);
335
+ for (const waiter of waiters)
336
+ waiter.resolve();
337
+ }, (error) => {
338
+ this.#nextAt = started + this.#minIntervalMs;
339
+ for (const waiter of waiters)
340
+ waiter.reject(error);
341
+ this.#onError(error);
342
+ })
343
+ .finally(() => {
344
+ this.#inFlight = undefined;
345
+ if (this.#dirty)
346
+ this.#schedule();
347
+ });
348
+ }
349
+ }
350
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6BH,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,cAAc,GAAG,oCAAoC,CAAC;AAC5D,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,yFAAyF;AACzF,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAE9D,4FAA4F;AAC5F,MAAM,UAAU,cAAc,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,MAAoB;IAC7D,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,M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AAC;gBACxB,IAAI,CAAC,MAAM,EAAE,CAAC;YACf,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC;IAED,MAAM;QACL,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO;QAC1C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE;aAC5B,IAAI,CACJ,CAAC,KAAK,EAAE,EAAE;YACT,IAAI,CAAC,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,yBAAyB,CAAC,CAAC;YACnG,KAAK,MAAM,MAAM,IAAI,OAAO;gBAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QAChD,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;YAClB,IAAI,CAAC,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC;YAC7C,KAAK,MAAM,MAAM,IAAI,OAAO;gBAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CACD;aACA,OAAO,CAAC,GAAG,EAAE;YACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3B,IAAI,IAAI,CAAC,MAAM;gBAAE,IAAI,CAAC,SAAS,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC;CACD","sourcesContent":["/**\n * Bounded output streams and adaptive progress commits: `OutputBuffer` keeps a head or tail window of a stream at a cost\n * proportional to each chunk, and `Progress` paces commits of a changing value by their size.\n */\n\n/** Retention limits of one output stream. */\nexport type OutputLimits = { readonly maxBytes: number; readonly maxLines: number; readonly retain: \"head\" | \"tail\" };\n\n/** Retained output and what the limits dropped. */\nexport type BoundedOutput = { readonly text: string; readonly droppedBytes: number; readonly droppedLines: number };\n\n/** An exact slice of the input within the limits, and what it left out. */\nexport type OutputSlice = {\n\treadonly text: string;\n\treadonly bytes: number;\n\treadonly droppedBytes: number;\n\treadonly droppedLines: number;\n};\n\n/**\n * Output a producer omitted before a chunk, measured on the decoded text: every U+FFFD counts as three bytes, and no\n * sanitizing is applied.\n */\nexport interface OutputSkip {\n\t/** UTF-8 byte length of the omitted text. */\n\treadonly bytes: number;\n\t/** Newlines (U+000A) in the omitted text. */\n\treadonly newlines: number;\n\t/** Whether the omitted text ends with a newline. */\n\treadonly endsWithNewline: boolean;\n}\n\nconst NEWLINE = 0x0a;\nconst INVALID_OUTPUT = /[\\x00-\\x08\\x0b-\\x1f\\ufff9-\\ufffb]/g;\nconst encoder = new TextEncoder();\n/** Slices decode exactly: a U+FEFF at a slice's start is text, not a byte-order mark. */\nconst decoder = new TextDecoder(\"utf-8\", { ignoreBOM: true });\n\n/** Remove control characters that break display and transcripts; tabs and newlines stay. */\nexport function sanitizeOutput(text: string): string {\n\treturn text.replace(INVALID_OUTPUT, \"\");\n}\n\n/**\n * Bound `text` to whole lines within the limits: the first lines for `head`, the last lines for `tail`. The result is an\n * exact slice, trailing newline included. A single line longer than `maxBytes` is cut at the byte limit on a character\n * boundary.\n */\nexport function boundOutput(text: string, limits: OutputLimits): OutputSlice {\n\tconst bytes = encoder.encode(text);\n\tconst [from, to] = limits.retain === \"head\" ? headRange(bytes, limits) : tailRange(bytes, limits);\n\tconst kept = bytes.subarray(from, to);\n\treturn {\n\t\ttext: kept.length === bytes.length ? text : decoder.decode(kept),\n\t\tbytes: kept.length,\n\t\tdroppedBytes: bytes.length - kept.length,\n\t\tdroppedLines: lineCount(bytes) - lineCount(kept),\n\t};\n}\n\nfunction headRange(bytes: Uint8Array, limits: OutputLimits): [number, number] {\n\tif (limits.maxLines === 0 || limits.maxBytes === 0) return [0, 0];\n\tlet end = bytes.length;\n\tlet lines = 0;\n\tfor (let index = bytes.indexOf(NEWLINE); index !== -1; index = bytes.indexOf(NEWLINE, index + 1)) {\n\t\tif (++lines === limits.maxLines) {\n\t\t\tend = index + 1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (end > limits.maxBytes) {\n\t\tconst newline = bytes.lastIndexOf(NEWLINE, limits.maxBytes - 1);\n\t\tend = newline === -1 ? characterEnd(bytes, limits.maxBytes) : newline + 1;\n\t}\n\treturn [0, end];\n}\n\nfunction tailRange(bytes: Uint8Array, limits: OutputLimits): [number, number] {\n\tif (limits.maxLines === 0 || limits.maxBytes === 0) return [bytes.length, bytes.length];\n\t// A trailing newline ends the last line rather than starting another.\n\tconst last = bytes[bytes.length - 1] === NEWLINE ? bytes.length - 2 : bytes.length - 1;\n\tlet start = 0;\n\tlet lines = 1;\n\tfor (let index = last < 0 ? -1 : bytes.lastIndexOf(NEWLINE, last); index !== -1; ) {\n\t\tif (lines === limits.maxLines) {\n\t\t\tstart = index + 1;\n\t\t\tbreak;\n\t\t}\n\t\tlines++;\n\t\tindex = index === 0 ? -1 : bytes.lastIndexOf(NEWLINE, index - 1);\n\t}\n\tif (bytes.length - start > limits.maxBytes) {\n\t\tconst from = bytes.length - limits.maxBytes;\n\t\tconst newline = bytes.indexOf(NEWLINE, from - 1);\n\t\t// The first line starting inside the byte window, or a cut of the last line when it alone is too long.\n\t\tstart = newline !== -1 && newline + 1 < bytes.length ? newline + 1 : characterStart(bytes, from);\n\t}\n\treturn [start, bytes.length];\n}\n\n/** The last character boundary at or before `index`. */\nexport function characterEnd(bytes: Uint8Array, index: number): number {\n\tlet end = index;\n\twhile (end > 0 && ((bytes[end] ?? 0) & 0xc0) === 0x80) end--;\n\treturn end;\n}\n\n/** The first character boundary at or after `index`. */\nfunction characterStart(bytes: Uint8Array, index: number): number {\n\tlet start = index;\n\twhile (start < bytes.length && ((bytes[start] ?? 0) & 0xc0) === 0x80) start++;\n\treturn start;\n}\n\nfunction lineCount(bytes: Uint8Array): number {\n\tif (bytes.length === 0) return 0;\n\tlet newlines = 0;\n\tfor (let index = bytes.indexOf(NEWLINE); index !== -1; index = bytes.indexOf(NEWLINE, index + 1)) newlines++;\n\treturn newlines + (bytes[bytes.length - 1] === NEWLINE ? 0 : 1);\n}\n\n/**\n * Bounded running output of one stream, such as a tool call's or a process's. Accepting a chunk costs time proportional to the chunk: head retention stops\n * storing once the window is full, and tail retention drops stored text the window no longer needs when it snapshots.\n * Counts of the whole stream are kept so the dropped totals stay exact.\n */\nexport class OutputBuffer {\n\treadonly #limits: OutputLimits;\n\t/**\n\t * Decoder of byte chunks. A string chunk or a skip ends an incomplete character of earlier bytes (it becomes U+FFFD);\n\t * the next byte chunk then starts a new character. As in `StreamDecoder`, only a byte-order mark at the very start of\n\t * the output is dropped, never a U+FEFF later in it.\n\t */\n\treadonly #decoder = new TextDecoder(\"utf-8\", { ignoreBOM: true });\n\t#started = false;\n\t/** Stored chunks: for head the start of the stream, for tail a suffix that still contains the next window. */\n\t#chunks: { readonly text: string; readonly bytes: number; readonly newlines: number }[] = [];\n\t#storedBytes = 0;\n\t#storedNewlines = 0;\n\t#full = false;\n\t#totalBytes = 0;\n\t#totalNewlines = 0;\n\t#endsWithNewline = true;\n\n\tconstructor(limits: OutputLimits) {\n\t\tthis.#limits = limits;\n\t}\n\n\t/** Bytes currently held; bounded by the limits plus one chunk. */\n\tget storedBytes(): number {\n\t\treturn this.#storedBytes;\n\t}\n\n\t/**\n\t * Accept a chunk; returns whether anything was accepted. `skipped` is output omitted right before the chunk, which\n\t * must be more than the tail window by at least one byte or line; only tail retention accepts it.\n\t */\n\tpush(chunk: string | Uint8Array, skipped?: OutputSkip): boolean {\n\t\t// Bytes of an incomplete character from an earlier byte chunk come first.\n\t\tconst pending = typeof chunk === \"string\" || skipped !== undefined ? this.#decoder.decode() : \"\";\n\t\tlet text = typeof chunk === \"string\" ? chunk : this.#decoder.decode(chunk, { stream: true });\n\t\tconst first = !this.#started && pending === \"\" && skipped === undefined;\n\t\tif (pending !== \"\" || text !== \"\" || skipped !== undefined) this.#started = true;\n\t\tif (first && typeof chunk !== \"string\" && text.startsWith(\"\\ufeff\")) text = text.slice(1);\n\t\tif (skipped === undefined) return this.#accept(pending + text);\n\t\tif (this.#limits.retain !== \"tail\") throw new Error(\"Skipped output requires tail retention\");\n\t\tthis.#accept(pending);\n\t\tthis.#skip(skipped);\n\t\tthis.#accept(text);\n\t\treturn true;\n\t}\n\n\t/** Count omitted output; nothing stored before it can be in the window once the text after it arrives. */\n\t#skip(skipped: OutputSkip): void {\n\t\tif (skipped.bytes === 0) return;\n\t\tthis.#totalBytes += skipped.bytes;\n\t\tthis.#totalNewlines += skipped.newlines;\n\t\tthis.#endsWithNewline = skipped.endsWithNewline;\n\t\tthis.#chunks = [];\n\t\tthis.#storedBytes = 0;\n\t\tthis.#storedNewlines = 0;\n\t}\n\n\t/** Flush an incomplete trailing character as a replacement character; call when the stream ends. */\n\tend(): void {\n\t\tthis.#accept(this.#decoder.decode());\n\t}\n\n\t#accept(text: string): boolean {\n\t\tif (text.length === 0) return false;\n\t\tconst bytes = utf8ByteLength(text);\n\t\tconst newlines = countNewlines(text);\n\t\tthis.#totalBytes += bytes;\n\t\tthis.#totalNewlines += newlines;\n\t\tthis.#endsWithNewline = text.endsWith(\"\\n\");\n\t\tif (this.#full) return true;\n\t\tthis.#chunks.push({ text, bytes, newlines });\n\t\tthis.#storedBytes += bytes;\n\t\tthis.#storedNewlines += newlines;\n\t\tif (this.#limits.retain === \"head\") {\n\t\t\t// Nothing past a full window is ever needed.\n\t\t\tthis.#full = this.#storedBytes > this.#limits.maxBytes || this.#storedNewlines >= this.#limits.maxLines;\n\t\t\treturn true;\n\t\t}\n\t\t// Drop leading chunks while the rest still holds more than a window: more than `maxBytes` bytes or `maxLines`\n\t\t// newlines, plus one, so the window's line start can still be found. Each chunk is dropped once.\n\t\twhile (this.#chunks.length > 1) {\n\t\t\tconst first = this.#chunks[0]!;\n\t\t\tconst bytesAfter = this.#storedBytes - first.bytes;\n\t\t\tconst newlinesAfter = this.#storedNewlines - first.newlines;\n\t\t\tif (bytesAfter <= this.#limits.maxBytes + 1 && newlinesAfter <= this.#limits.maxLines + 1) break;\n\t\t\tthis.#chunks.shift();\n\t\t\tthis.#storedBytes = bytesAfter;\n\t\t\tthis.#storedNewlines = newlinesAfter;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Retained, sanitized output and what the limits dropped from the whole stream. */\n\tsnapshot(): BoundedOutput {\n\t\tconst stored =\n\t\t\tthis.#chunks.length === 1 ? this.#chunks[0]!.text : this.#chunks.map((chunk) => chunk.text).join(\"\");\n\t\tconst kept = boundOutput(stored, this.#limits);\n\t\tconst storedLines = lines(this.#storedNewlines, stored === \"\" || stored.endsWith(\"\\n\"));\n\t\tconst keptLines = storedLines - kept.droppedLines;\n\t\t// Tail windows never reach back before this one, but finding a later window's first line needs what precedes it:\n\t\t// keep the shortest suffix longer than the window by a byte or a line, as `#accept` does.\n\t\tif (this.#limits.retain === \"tail\" || this.#chunks.length > 1) {\n\t\t\tconst text = this.#limits.retain === \"tail\" ? tailMargin(stored, this.#limits) : stored;\n\t\t\tconst bytes = this.#limits.retain === \"tail\" ? utf8ByteLength(text) : this.#storedBytes;\n\t\t\tthis.#chunks = text === \"\" ? [] : [{ text, bytes, newlines: countNewlines(text) }];\n\t\t\tthis.#storedBytes = bytes;\n\t\t\tthis.#storedNewlines = this.#chunks[0]?.newlines ?? 0;\n\t\t}\n\t\treturn {\n\t\t\ttext: sanitizeOutput(kept.text),\n\t\t\tdroppedBytes: this.#totalBytes - kept.bytes,\n\t\t\tdroppedLines: lines(this.#totalNewlines, this.#endsWithNewline) - keptLines,\n\t\t};\n\t}\n}\n\n/**\n * The shortest suffix of `text` with more than `maxBytes` bytes or more than `maxLines` newlines, or all of it. The\n * tail window of any text that ends with this suffix, followed by anything, is the same as of `text` followed by it.\n */\nfunction tailMargin(text: string, limits: OutputLimits): string {\n\tconst bytes = encoder.encode(text);\n\tconst byteStart = bytes.length > limits.maxBytes ? characterEnd(bytes, bytes.length - limits.maxBytes - 1) : 0;\n\tlet lineStart = 0;\n\tlet newlines = 0;\n\tfor (let index = bytes.lastIndexOf(NEWLINE); index !== -1; index = bytes.lastIndexOf(NEWLINE, index - 1)) {\n\t\tif (++newlines > limits.maxLines) {\n\t\t\tlineStart = index;\n\t\t\tbreak;\n\t\t}\n\t\tif (index === 0) break;\n\t}\n\tconst start = Math.max(byteStart, lineStart);\n\treturn start === 0 ? text : decoder.decode(bytes.subarray(start));\n}\n\n/** Lines of text with `newlines` newlines; a final unterminated line counts. */\nfunction lines(newlines: number, terminated: boolean): number {\n\treturn newlines + (terminated ? 0 : 1);\n}\n\ninterface RuntimeBuffer {\n\tbyteLength(content: string, encoding: \"utf8\"): number;\n}\n\nconst runtimeBuffer = (globalThis as { Buffer?: RuntimeBuffer }).Buffer;\nconst nonAsciiPattern = /[^\\x00-\\x7f]/;\n\n/** UTF-8 byte length of `content`; a lone surrogate counts as U+FFFD, three bytes. */\nexport function utf8ByteLength(content: string): number {\n\tif (runtimeBuffer) return runtimeBuffer.byteLength(content, \"utf8\");\n\tconst firstNonAscii = content.search(nonAsciiPattern);\n\tif (firstNonAscii === -1) return content.length;\n\tlet bytes = firstNonAscii;\n\tfor (let i = firstNonAscii; i < content.length; i++) {\n\t\tconst code = content.charCodeAt(i);\n\t\tif (code <= 0x7f) bytes += 1;\n\t\telse if (code <= 0x7ff) bytes += 2;\n\t\telse if (code >= 0xd800 && code <= 0xdbff && i + 1 < content.length) {\n\t\t\tconst next = content.charCodeAt(i + 1);\n\t\t\tif (next >= 0xdc00 && next <= 0xdfff) {\n\t\t\t\tbytes += 4;\n\t\t\t\ti++;\n\t\t\t} else bytes += 3;\n\t\t} else bytes += 3;\n\t}\n\treturn bytes;\n}\n\nfunction countNewlines(text: string): number {\n\tlet count = 0;\n\tfor (let index = text.indexOf(\"\\n\"); index !== -1; index = text.indexOf(\"\\n\", index + 1)) count++;\n\treturn count;\n}\n\n/** Each progress commit also buys a pause proportional to what it wrote. */\nexport const PROGRESS_BYTES_PER_SECOND = 100 * 1024;\n\n/**\n * Adaptive progress commits: the first change after an idle period commits at once; each commit then delays the next\n * by at least `minIntervalMs` and by its written size at 100 KiB/s. At most one commit is in flight; changes made\n * meanwhile coalesce into the next one.\n */\nexport class Progress {\n\treadonly #write: () => Promise<number>;\n\treadonly #onError: (error: unknown) => void;\n\treadonly #minIntervalMs: number;\n\t#waiters: PromiseWithResolvers<void>[] = [];\n\t#timer: ReturnType<typeof setTimeout> | undefined;\n\t#inFlight: Promise<void> | undefined;\n\t#nextAt = 0;\n\t#dirty = false;\n\t#stopped = false;\n\n\tconstructor(write: () => Promise<number>, onError: (error: unknown) => void, minIntervalMs: number) {\n\t\tthis.#write = write;\n\t\tthis.#onError = onError;\n\t\tthis.#minIntervalMs = minIntervalMs;\n\t}\n\n\t/** Schedule a commit. */\n\tmark(): void {\n\t\tthis.#dirty = true;\n\t\tthis.#schedule();\n\t}\n\n\t/** Schedule a commit; the promise settles with the commit that includes this change. */\n\tmarkAndWait(): Promise<void> {\n\t\tconst waiter = Promise.withResolvers<void>();\n\t\tthis.#waiters.push(waiter);\n\t\tthis.mark();\n\t\treturn waiter.promise;\n\t}\n\n\t/** Stop committing and wait for the commit in flight; returns the waiters the final commit must settle. */\n\tasync stop(): Promise<PromiseWithResolvers<void>[]> {\n\t\tthis.#stopped = true;\n\t\tclearTimeout(this.#timer);\n\t\tthis.#timer = undefined;\n\t\tawait this.#inFlight;\n\t\treturn this.#waiters.splice(0);\n\t}\n\n\t#schedule(): void {\n\t\tif (this.#stopped || this.#timer !== undefined || this.#inFlight !== undefined) return;\n\t\tconst wait = this.#nextAt - Date.now();\n\t\tif (wait <= 0) this.#flush();\n\t\telse\n\t\t\tthis.#timer = setTimeout(() => {\n\t\t\t\tthis.#timer = undefined;\n\t\t\t\tthis.#flush();\n\t\t\t}, wait);\n\t}\n\n\t#flush(): void {\n\t\tif (this.#stopped || !this.#dirty) return;\n\t\tthis.#dirty = false;\n\t\tconst waiters = this.#waiters.splice(0);\n\t\tconst started = Date.now();\n\t\tthis.#inFlight = this.#write()\n\t\t\t.then(\n\t\t\t\t(bytes) => {\n\t\t\t\t\tthis.#nextAt = started + Math.max(this.#minIntervalMs, (bytes * 1000) / PROGRESS_BYTES_PER_SECOND);\n\t\t\t\t\tfor (const waiter of waiters) waiter.resolve();\n\t\t\t\t},\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tthis.#nextAt = started + this.#minIntervalMs;\n\t\t\t\t\tfor (const waiter of waiters) waiter.reject(error);\n\t\t\t\t\tthis.#onError(error);\n\t\t\t\t},\n\t\t\t)\n\t\t\t.finally(() => {\n\t\t\t\tthis.#inFlight = undefined;\n\t\t\t\tif (this.#dirty) this.#schedule();\n\t\t\t});\n\t}\n}\n"]}
@@ -5,17 +5,17 @@ export interface Registry<V> {
5
5
  /** Type carrier only; never set. */
6
6
  readonly value?: V;
7
7
  }
8
- /** `conflict: "error"` rejects two records registering one key; `"last"` keeps the later registration. */
8
+ /** `conflict: "error"` rejects two objects registering one key; `"last"` keeps the later registration. */
9
9
  export declare const defineRegistry: <V>(name: string, options?: {
10
10
  conflict?: "error" | "last";
11
11
  }) => Registry<V>;
12
12
  export type RegistryTable<V> = ReadonlyMap<string, V>;
13
13
  export interface RegistryView<V> {
14
- /** Table of `ctx.epoch`, or of the current epoch without ctx. */
14
+ /** Table of `ctx.codeVersion`, or of the current code version without ctx. */
15
15
  table(ctx?: Ctx): RegistryTable<V>;
16
16
  get(key: string, ctx?: Ctx): V | undefined;
17
17
  /** Called with the current table immediately and whenever a new table is installed. */
18
- subscribe(listener: (table: RegistryTable<V>, epoch: number) => void): () => void;
18
+ subscribe(listener: (table: RegistryTable<V>, codeVersion: number) => void): () => void;
19
19
  }
20
20
  export interface Registration {
21
21
  readonly registry: Registry<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,QAAQ,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IACpC,oCAAoC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;CACnB;AAED,0GAA0G;AAC1G,eAAO,MAAM,cAAc,GAAI,CAAC,QAAQ,MAAM,YAAW;IAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAAE,KAAQ,QAAQ,CAAC,CAAC,CAGxG,CAAC;AAEH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtD,MAAM,WAAW,YAAY,CAAC,CAAC;IAC9B,iEAAiE;IACjE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3C,uFAAuF;IACvF,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAClF;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,QAAQ,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IACpC,oCAAoC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;CACnB;AAED,0GAA0G;AAC1G,eAAO,MAAM,cAAc,GAAI,CAAC,QAAQ,MAAM,YAAW;IAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAAE,KAAQ,QAAQ,CAAC,CAAC,CAGxG,CAAC;AAEH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEtD,MAAM,WAAW,YAAY,CAAC,CAAC;IAC9B,8EAA8E;IAC9E,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3C,uFAAuF;IACvF,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACxF;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB"}
package/dist/registry.js CHANGED
@@ -1,4 +1,4 @@
1
- /** `conflict: "error"` rejects two records registering one key; `"last"` keeps the later registration. */
1
+ /** `conflict: "error"` rejects two objects registering one key; `"last"` keeps the later registration. */
2
2
  export const defineRegistry = (name, options = {}) => ({
3
3
  name,
4
4
  conflict: options.conflict ?? "error",
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AASA,0GAA0G;AAC1G,MAAM,CAAC,MAAM,cAAc,GAAG,CAAI,IAAY,EAAE,OAAO,GAAoC,EAAE,EAAe,EAAE,CAAC,CAAC;IAC/G,IAAI;IACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO;CACrC,CAAC,CAAC","sourcesContent":["import type { Ctx } from \"./types.ts\";\n\nexport interface Registry<V> {\n\treadonly name: string;\n\treadonly conflict: \"error\" | \"last\";\n\t/** Type carrier only; never set. */\n\treadonly value?: V;\n}\n\n/** `conflict: \"error\"` rejects two records registering one key; `\"last\"` keeps the later registration. */\nexport const defineRegistry = <V>(name: string, options: { conflict?: \"error\" | \"last\" } = {}): Registry<V> => ({\n\tname,\n\tconflict: options.conflict ?? \"error\",\n});\n\nexport type RegistryTable<V> = ReadonlyMap<string, V>;\n\nexport interface RegistryView<V> {\n\t/** Table of `ctx.epoch`, or of the current epoch without ctx. */\n\ttable(ctx?: Ctx): RegistryTable<V>;\n\tget(key: string, ctx?: Ctx): V | undefined;\n\t/** Called with the current table immediately and whenever a new table is installed. */\n\tsubscribe(listener: (table: RegistryTable<V>, epoch: number) => void): () => void;\n}\n\nexport interface Registration {\n\treadonly registry: Registry<unknown>;\n\treadonly key: string;\n\treadonly value: unknown;\n}\n"]}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AASA,0GAA0G;AAC1G,MAAM,CAAC,MAAM,cAAc,GAAG,CAAI,IAAY,EAAE,OAAO,GAAoC,EAAE,EAAe,EAAE,CAAC,CAAC;IAC/G,IAAI;IACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO;CACrC,CAAC,CAAC","sourcesContent":["import type { Ctx } from \"./types.ts\";\n\nexport interface Registry<V> {\n\treadonly name: string;\n\treadonly conflict: \"error\" | \"last\";\n\t/** Type carrier only; never set. */\n\treadonly value?: V;\n}\n\n/** `conflict: \"error\"` rejects two objects registering one key; `\"last\"` keeps the later registration. */\nexport const defineRegistry = <V>(name: string, options: { conflict?: \"error\" | \"last\" } = {}): Registry<V> => ({\n\tname,\n\tconflict: options.conflict ?? \"error\",\n});\n\nexport type RegistryTable<V> = ReadonlyMap<string, V>;\n\nexport interface RegistryView<V> {\n\t/** Table of `ctx.codeVersion`, or of the current code version without ctx. */\n\ttable(ctx?: Ctx): RegistryTable<V>;\n\tget(key: string, ctx?: Ctx): V | undefined;\n\t/** Called with the current table immediately and whenever a new table is installed. */\n\tsubscribe(listener: (table: RegistryTable<V>, codeVersion: number) => void): () => void;\n}\n\nexport interface Registration {\n\treadonly registry: Registry<unknown>;\n\treadonly key: string;\n\treadonly value: unknown;\n}\n"]}
package/dist/reload.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import type { Cell } from "./cell.ts";
2
2
  import { ChordError } from "./errors.ts";
3
3
  import type { Facet, HostImpl, PluginRef } from "./host.ts";
4
- import { type RecordImpl, type ResourceImpl, type Run, type Service, type StagedListeners } from "./record.ts";
4
+ import { type ObjectImpl, type ResourceImpl, type Run, type Service, type StagedListeners } from "./object.ts";
5
5
  import type { RegistryTable } from "./registry.ts";
6
6
  export interface ReloadOptions {
7
7
  /** Facet names to remove. */
8
8
  readonly remove?: readonly string[];
9
9
  /** Milliseconds the gate waits for grandfathered roots (default 5000). Missed: the reload aborts. */
10
10
  readonly gateDeadline?: number;
11
- /** Milliseconds to wait for the previous epoch to retire first (default 5000). Missed: it is retired anyway. */
11
+ /** Milliseconds to wait for the previous code version to retire first (default 5000). Missed: it is retired anyway. */
12
12
  readonly retireDeadline?: number;
13
13
  /** Server: facet modules for child hosts by host-name prefix (longest wins). Every connected host participates. */
14
14
  readonly remote?: Readonly<Record<string, readonly string[]>>;
@@ -18,13 +18,13 @@ export interface ReloadOptions {
18
18
  readonly voteDeadline?: number;
19
19
  }
20
20
  export interface ReloadReport {
21
- readonly epoch: number;
21
+ readonly codeVersion: number;
22
22
  readonly previous: number;
23
23
  readonly changed: readonly string[];
24
24
  readonly removed: readonly string[];
25
- /** Addresses of records whose new factory was installed. */
25
+ /** Addresses of objects whose new factory was installed. */
26
26
  readonly prepared: readonly string[];
27
- /** Addresses of records that went through the gate. */
27
+ /** Addresses of objects that went through the gate. */
28
28
  readonly gated: readonly string[];
29
29
  /**
30
30
  * Cluster reloads: what each participating child host prepared, by host name (its vote; the child commits it after
@@ -33,10 +33,10 @@ export interface ReloadReport {
33
33
  readonly children?: Readonly<Record<string, ReloadReport>>;
34
34
  }
35
35
  interface Candidate {
36
- readonly record: RecordImpl;
36
+ readonly object: ObjectImpl;
37
37
  readonly service: Service;
38
38
  readonly run: Run;
39
- /** Why the record needs the gate (empty: compatible). */
39
+ /** Why the object needs the gate (empty: compatible). */
40
40
  readonly reasons: string[];
41
41
  /** New exclusive resources and their new dependents, opened at the gate. */
42
42
  readonly atGate: ResourceImpl[];
@@ -53,7 +53,7 @@ export declare function reloadError(error: unknown): ChordError;
53
53
  /** Serialized: a second reload while one runs is rejected. */
54
54
  export declare function runReload(host: HostImpl, plugins: readonly PluginRef[], options: ReloadOptions): Promise<ReloadReport>;
55
55
  /** Takes the host's reload slot and loads the plugin modules. Pair with `endReload`. */
56
- export declare function beginReload(host: HostImpl, plugins: readonly PluginRef[], options: ReloadOptions, epoch?: number): Promise<Reload>;
56
+ export declare function beginReload(host: HostImpl, plugins: readonly PluginRef[], options: ReloadOptions, codeVersion?: number): Promise<Reload>;
57
57
  export declare function endReload(host: HostImpl): void;
58
58
  /** One reload on one host: `prepare` (load, prepare, gate), then `commit` or `rollback`. */
59
59
  export declare class Reload {
@@ -61,24 +61,32 @@ export declare class Reload {
61
61
  readonly host: HostImpl;
62
62
  readonly facets: readonly Facet[];
63
63
  readonly options: ReloadOptions;
64
- /** Epoch id to commit (issued by the coordinating server); a local reload allocates one. */
65
- readonly epoch: number | undefined;
66
- readonly candidates: Map<RecordImpl, Candidate>;
64
+ /** Code version id to commit (issued by the coordinating server); a local reload allocates one. */
65
+ readonly codeVersion: number | undefined;
66
+ readonly candidates: Map<ObjectImpl, Candidate>;
67
67
  readonly abort: AbortController;
68
- readonly closed: [RecordImpl, ResourceImpl][];
68
+ readonly closed: [ObjectImpl, ResourceImpl][];
69
69
  services: Map<string, Service>;
70
70
  changed: Set<string>;
71
71
  removed: Set<string>;
72
72
  tables: Map<string, RegistryTable<unknown>>;
73
73
  gated: Candidate[];
74
74
  rolledBack: boolean;
75
- /** Records of types this reload adds, with their staged listeners: their runtime starts at commit. */
76
- readonly deferred: Map<RecordImpl, StagedListeners>;
77
- constructor(host: HostImpl, facets: readonly Facet[], options: ReloadOptions, epoch?: number);
75
+ /** Objects of types this reload adds, with their staged listeners: their runtime starts at commit. */
76
+ readonly deferred: Map<ObjectImpl, StagedListeners>;
77
+ /** This reload's run of each facet it loads (`FacetApi.signal`): installed at commit, aborted at rollback. */
78
+ readonly facetRuns: Map<string, AbortController>;
79
+ constructor(host: HostImpl, facets: readonly Facet[], options: ReloadOptions, codeVersion?: number);
78
80
  /** Everything up to the commit. On failure the host is rolled back and the underlying error is thrown. */
79
81
  prepare(): Promise<void>;
80
82
  /** What a successful prepare will commit (a child sends it with its vote). */
81
83
  summary(): ReloadReport;
84
+ /**
85
+ * Retires the previous code version before loading the next one (a host keeps two). Waits until its roots ended and,
86
+ * on a child host, its parent retired it too (`retire` frame), at most `retireDeadline`. Past the deadline it is
87
+ * retired anyway: its remaining roots are aborted first and get a short grace to stop, so they see cancellation
88
+ * before the resources only that code version used are closed; their next call is `superseded`.
89
+ */
82
90
  waitForRetirement(): Promise<void>;
83
91
  /** Builds the candidate service table: unchanged services plus everything the given facets serve. */
84
92
  load(): void;
@@ -86,33 +94,33 @@ export declare class Reload {
86
94
  /** Same contract version must cover the old description (forgotten bump); facets' `uses` must bind. */
87
95
  checkProviders(): void;
88
96
  /**
89
- * Prepares every live record of a changed type, including records that activate meanwhile, to a fixpoint. Records
97
+ * Prepares every live object of a changed type, including objects that activate meanwhile, to a fixpoint. Objects
90
98
  * already running the new code (types this reload adds) are skipped.
91
99
  */
92
100
  prepareAll(): Promise<void>;
93
101
  /** Runs the new factory in recording mode and opens what can be opened without the gate. */
94
- prepareRecord(record: RecordImpl): Promise<void>;
102
+ prepareObject(object: ObjectImpl): Promise<void>;
95
103
  /**
96
- * Every hold that survives into the new epoch must bind to the new provider. Browser holds don't block a reload:
97
- * after the commit they get `upgrade_required` instead.
104
+ * Every reference that survives into the new code version must bind to the new provider. Browser references don't block a
105
+ * reload: after the commit they get `upgrade_required` instead.
98
106
  */
99
- checkHolds(): void;
100
- entries(): [RecordImpl, Run["decls"]][];
107
+ checkRefs(): void;
108
+ entries(): [ObjectImpl, Run["decls"]][];
101
109
  /**
102
110
  * Admission cut, wait for grandfathered roots (deadline), replace exclusive resources, migrate into private
103
- * copies. Old tasks of gated records are stopped at the cut; listener events are queued until commit or abort.
111
+ * copies. Old tasks of gated objects are stopped at the cut; listener events are queued until commit or abort.
104
112
  */
105
113
  gate(): Promise<void>;
106
114
  migrate(candidate: Candidate): void;
107
115
  rollback(): Promise<void>;
108
116
  /**
109
- * Publishes the new epoch in one synchronous step. Everything fallible ran in prepare (factories, opens, migration
110
- * and derivation checks against the prospective schemas, listener subscriptions), so this only installs. Observers
111
- * (state, shapes, registries, listener roots) are notified after the whole step. If an install still throws, the
112
- * epoch is half-published: the host fails terminally and admits no more work.
117
+ * Publishes the new code version in one synchronous step. Everything fallible ran in prepare (factories, opens,
118
+ * migration and derivation checks against the prospective schemas, listener subscriptions), so this only installs.
119
+ * Observers (state, shapes, registries, listener roots) are notified after the whole step. If an install still
120
+ * throws, the code version is half-published: the host fails terminally and admits no more work.
113
121
  */
114
122
  commit(beforeStart?: () => void): ReloadReport;
115
- install(candidate: Candidate, epoch: number): void;
123
+ install(candidate: Candidate, codeVersion: number): void;
116
124
  }
117
125
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