@blue-labs/document-processor 3.0.0 → 3.2.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 (76) hide show
  1. package/dist/engine/channel-runner.d.ts +3 -6
  2. package/dist/engine/channel-runner.d.ts.map +1 -1
  3. package/dist/engine/composite-channel-validation.d.ts +14 -0
  4. package/dist/engine/composite-channel-validation.d.ts.map +1 -0
  5. package/dist/engine/contract-bundle.d.ts +7 -15
  6. package/dist/engine/contract-bundle.d.ts.map +1 -1
  7. package/dist/engine/contract-loader.d.ts +2 -1
  8. package/dist/engine/contract-loader.d.ts.map +1 -1
  9. package/dist/engine/processor-engine.d.ts.map +1 -1
  10. package/dist/index.js +1399 -1176
  11. package/dist/model/channels/composite-timeline-channel.d.ts +47 -0
  12. package/dist/model/channels/composite-timeline-channel.d.ts.map +1 -0
  13. package/dist/model/channels/document-update-channel.d.ts +4 -4
  14. package/dist/model/channels/embedded-node-channel.d.ts +4 -4
  15. package/dist/model/channels/index.d.ts +1 -0
  16. package/dist/model/channels/index.d.ts.map +1 -1
  17. package/dist/model/channels/lifecycle-channel.d.ts +4 -4
  18. package/dist/model/channels/myos-timeline-channel.d.ts +4 -4
  19. package/dist/model/channels/timeline-channel.d.ts +4 -4
  20. package/dist/model/channels/triggered-event-channel.d.ts +4 -4
  21. package/dist/model/handlers/sequential-workflow-operation.d.ts +6 -6
  22. package/dist/model/handlers/sequential-workflow.d.ts +6 -6
  23. package/dist/model/markers/channel-event-checkpoint.d.ts +2 -2
  24. package/dist/model/markers/document-anchors.d.ts +2 -2
  25. package/dist/model/markers/document-links.d.ts +2 -2
  26. package/dist/model/markers/initialization-marker.d.ts +2 -2
  27. package/dist/model/markers/myos-participants-orchestration.d.ts +2 -2
  28. package/dist/model/markers/myos-session-interaction.d.ts +2 -2
  29. package/dist/model/markers/myos-worker-agency.d.ts +2 -2
  30. package/dist/model/markers/operation.d.ts +2 -2
  31. package/dist/model/markers/process-embedded.d.ts +2 -2
  32. package/dist/model/markers/processing-terminated-marker.d.ts +2 -2
  33. package/dist/model/shared/channel-contract-base.d.ts +4 -4
  34. package/dist/model/shared/handler-contract-base.d.ts +4 -4
  35. package/dist/model/shared/marker-contract-base.d.ts +2 -2
  36. package/dist/model/types.d.ts +2 -2
  37. package/dist/model/types.d.ts.map +1 -1
  38. package/dist/registry/contract-processor-registry-builder.d.ts.map +1 -1
  39. package/dist/registry/processors/composite-timeline-channel-processor.d.ts +81 -0
  40. package/dist/registry/processors/composite-timeline-channel-processor.d.ts.map +1 -0
  41. package/dist/registry/processors/myos-timeline-channel-processor.d.ts +4 -4
  42. package/dist/registry/processors/myos-timeline-channel-processor.d.ts.map +1 -1
  43. package/dist/registry/processors/operation-marker-processor.d.ts +2 -2
  44. package/dist/registry/processors/operation-marker-processor.d.ts.map +1 -1
  45. package/dist/registry/processors/sequential-workflow-operation-processor.d.ts +6 -6
  46. package/dist/registry/processors/sequential-workflow-operation-processor.d.ts.map +1 -1
  47. package/dist/registry/processors/sequential-workflow-processor.d.ts +6 -6
  48. package/dist/registry/processors/sequential-workflow-processor.d.ts.map +1 -1
  49. package/dist/registry/processors/steps/javascript-code-step-executor.d.ts +6 -0
  50. package/dist/registry/processors/steps/javascript-code-step-executor.d.ts.map +1 -1
  51. package/dist/registry/processors/steps/trigger-event-step-executor.d.ts.map +1 -1
  52. package/dist/registry/processors/steps/update-document-step-executor.d.ts.map +1 -1
  53. package/dist/registry/processors/timeline-channel-processor.d.ts +4 -4
  54. package/dist/registry/processors/timeline-channel-processor.d.ts.map +1 -1
  55. package/dist/registry/types.d.ts +26 -0
  56. package/dist/registry/types.d.ts.map +1 -1
  57. package/dist/runtime/gas-helpers.d.ts +0 -3
  58. package/dist/runtime/gas-helpers.d.ts.map +1 -1
  59. package/dist/runtime/gas-meter.d.ts +1 -3
  60. package/dist/runtime/gas-meter.d.ts.map +1 -1
  61. package/dist/runtime/gas-schedule.d.ts +8 -0
  62. package/dist/runtime/gas-schedule.d.ts.map +1 -0
  63. package/dist/test-support/blue.d.ts.map +1 -1
  64. package/dist/types/channel-contract-entry.d.ts +7 -0
  65. package/dist/types/channel-contract-entry.d.ts.map +1 -0
  66. package/dist/types/handler-contract-entry.d.ts +7 -0
  67. package/dist/types/handler-contract-entry.d.ts.map +1 -0
  68. package/dist/types/marker-contract-entry.d.ts +7 -0
  69. package/dist/types/marker-contract-entry.d.ts.map +1 -0
  70. package/dist/util/expression/quickjs-config.d.ts +2 -0
  71. package/dist/util/expression/quickjs-config.d.ts.map +1 -0
  72. package/dist/util/expression/quickjs-evaluator.d.ts +23 -22
  73. package/dist/util/expression/quickjs-evaluator.d.ts.map +1 -1
  74. package/dist/util/expression/quickjs-expression-utils.d.ts +3 -3
  75. package/dist/util/expression/quickjs-expression-utils.d.ts.map +1 -1
  76. package/package.json +9 -7
package/dist/index.js CHANGED
@@ -1,40 +1,42 @@
1
- import { getQuickJS as ht } from "quickjs-emscripten";
2
- import { BlueNode as h, withTypeBlueId as f, blueNodeField as v, Properties as Ee, BlueIdCalculator as pt, Blue as ft, MergingProcessors as O } from "@blue-labs/language";
3
- import we from "picomatch";
4
- import { z as l, ZodError as xe } from "zod";
5
- import { isNullable as ae } from "@blue-labs/shared-utils";
6
- import { repository as mt } from "@blue-repository/types";
7
- function gt(i) {
1
+ import { evaluate as wt } from "@blue-quickjs/quickjs-runtime";
2
+ import { validateDv as kt, DV_LIMIT_DEFAULTS as bt } from "@blue-quickjs/dv";
3
+ import { HOST_V1_MANIFEST as It, HOST_V1_HASH as Tt } from "@blue-quickjs/abi-manifest";
4
+ import { BlueNode as p, withTypeBlueId as g, blueNodeField as b, Properties as Ie, BlueIdCalculator as Rt, Blue as Pt, MergingProcessors as L } from "@blue-labs/language";
5
+ import Te from "picomatch";
6
+ import { z as l, ZodError as ge } from "zod";
7
+ import { isNullable as he } from "@blue-labs/shared-utils";
8
+ import { repository as Mt } from "@blue-repository/types";
9
+ function Nt(i) {
8
10
  return { ok: !0, value: i };
9
11
  }
10
- function yt(i) {
12
+ function Ot(i) {
11
13
  return { ok: !1, error: i };
12
14
  }
13
- function Ci(i) {
15
+ function ji(i) {
14
16
  return i.ok;
15
17
  }
16
- function Si(i) {
18
+ function Ji(i) {
17
19
  return !i.ok;
18
20
  }
19
- function vi(i, e) {
20
- return i.ok ? gt(e(i.value)) : i;
21
+ function Qi(i, e) {
22
+ return i.ok ? Nt(e(i.value)) : i;
21
23
  }
22
- function bi(i, e) {
23
- return i.ok ? i : yt(e(i.error));
24
+ function Xi(i, e) {
25
+ return i.ok ? i : Ot(e(i.error));
24
26
  }
25
- function ki(i, e) {
27
+ function Yi(i, e) {
26
28
  return i.ok ? e(i.value) : i;
27
29
  }
28
- function Ti(i, e) {
30
+ function Zi(i, e) {
29
31
  return i.ok ? i.value : e;
30
32
  }
31
- function Ii(i, e) {
33
+ function eo(i, e) {
32
34
  return i.ok ? i.value : e(i.error);
33
35
  }
34
- function Ri(i, e) {
36
+ function to(i, e) {
35
37
  return i.ok ? e.ok(i.value) : e.err(i.error);
36
38
  }
37
- const w = {
39
+ const v = {
38
40
  capabilityFailure(i, e, t) {
39
41
  return { kind: "CapabilityFailure", capability: i, reason: e, details: t };
40
42
  },
@@ -54,14 +56,14 @@ const w = {
54
56
  return { kind: "UnsupportedOp", operation: i, reason: e };
55
57
  }
56
58
  };
57
- function Et(i) {
59
+ function At(i) {
58
60
  return Object.freeze([...i]);
59
61
  }
60
- const wt = {
62
+ const Dt = {
61
63
  of(i, e, t) {
62
64
  return {
63
65
  document: i,
64
- triggeredEvents: Et(e),
66
+ triggeredEvents: At(e),
65
67
  totalGas: t,
66
68
  capabilityFailure: !1,
67
69
  failureReason: null
@@ -76,7 +78,7 @@ const wt = {
76
78
  failureReason: e ?? null
77
79
  };
78
80
  }
79
- }, _e = wt, p = {
81
+ }, Ke = Dt, f = {
80
82
  "Core/Channel": "DcoJyCh7XXxy1nR5xjy7qfkUgQ1GiZnKKSxh8DJusBSr",
81
83
  "Core/Channel Event Checkpoint": "B7YQeYdQzUNuzaDQ4tNTd2iJqgd4YnVQkgz4QgymDWWU",
82
84
  "Core/Contract": "AERp8BWnuUsjoPciAeNXuUWS9fmqPNMdWbxmKn3tcitx",
@@ -93,68 +95,68 @@ const wt = {
93
95
  "Core/Processing Initialized Marker": "EVguxFmq5iFtMZaBQgHfjWDojaoesQ1vEXCQFZ59yL28",
94
96
  "Core/Processing Terminated Marker": "5NiEhupJ6uF54Q3vs4GwQX4UX4ExtwHpKRVvjKEHtvjR",
95
97
  "Core/Triggered Event Channel": "C77W4kVGcxL7Mkx9WL9QESPEFFL2GzWAe647s1Efprt"
96
- }, Ct = [
98
+ }, Bt = [
97
99
  "embedded",
98
100
  "initialized",
99
101
  "terminated",
100
102
  "checkpoint"
101
- ], St = [
102
- p["Core/Document Update Channel"],
103
- p["Core/Triggered Event Channel"],
104
- p["Core/Lifecycle Event Channel"],
105
- p["Core/Embedded Node Channel"]
106
- ], Fe = "embedded", Ue = "initialized", ze = "terminated", N = "checkpoint", de = new Set(
107
- Ct
108
- ), $e = new Set(St);
109
- function vt(i) {
110
- return i != null && de.has(i);
111
- }
112
- function he(i) {
113
- return i != null && $e.has(
103
+ ], xt = [
104
+ f["Core/Document Update Channel"],
105
+ f["Core/Triggered Event Channel"],
106
+ f["Core/Lifecycle Event Channel"],
107
+ f["Core/Embedded Node Channel"]
108
+ ], We = "embedded", Ge = "initialized", qe = "terminated", A = "checkpoint", Ee = new Set(
109
+ Bt
110
+ ), je = new Set(xt);
111
+ function _t(i) {
112
+ return i != null && Ee.has(i);
113
+ }
114
+ function ye(i) {
115
+ return i != null && je.has(
114
116
  i
115
117
  );
116
118
  }
117
- const Pi = {
118
- KEY_EMBEDDED: Fe,
119
- KEY_INITIALIZED: Ue,
120
- KEY_TERMINATED: ze,
121
- KEY_CHECKPOINT: N,
122
- RESERVED_CONTRACT_KEYS: de,
123
- PROCESSOR_MANAGED_CHANNEL_BLUE_IDS: $e,
124
- isReservedContractKey: vt,
125
- isProcessorManagedChannelBlueId: he
126
- }, x = "/contracts", ce = `${x}/${Ue}`, He = `${x}/${ze}`, bt = `${x}/${Fe}`, Ve = `${x}/${N}`, We = "/lastEvents", Ke = "/lastSignatures";
127
- function Z(i) {
128
- return `${x}/${i}`;
129
- }
130
- function qe(i, e) {
131
- return `${Z(i)}${We}/${e}`;
132
- }
133
- function je(i, e) {
134
- return `${Z(i)}${Ke}/${e}`;
135
- }
136
- const Mi = {
137
- RELATIVE_CONTRACTS: x,
138
- RELATIVE_INITIALIZED: ce,
139
- RELATIVE_TERMINATED: He,
140
- RELATIVE_EMBEDDED: bt,
141
- RELATIVE_CHECKPOINT: Ve,
142
- LAST_EVENTS_SUFFIX: We,
143
- LAST_SIGNATURES_SUFFIX: Ke,
144
- relativeContractsEntry: Z,
145
- relativeCheckpointLastEvent: qe,
146
- relativeCheckpointLastSignature: je
119
+ const no = {
120
+ KEY_EMBEDDED: We,
121
+ KEY_INITIALIZED: Ge,
122
+ KEY_TERMINATED: qe,
123
+ KEY_CHECKPOINT: A,
124
+ RESERVED_CONTRACT_KEYS: Ee,
125
+ PROCESSOR_MANAGED_CHANNEL_BLUE_IDS: je,
126
+ isReservedContractKey: _t,
127
+ isProcessorManagedChannelBlueId: ye
128
+ }, H = "/contracts", de = `${H}/${Ge}`, Je = `${H}/${qe}`, Lt = `${H}/${We}`, Qe = `${H}/${A}`, Xe = "/lastEvents", Ye = "/lastSignatures";
129
+ function ne(i) {
130
+ return `${H}/${i}`;
131
+ }
132
+ function Ze(i, e) {
133
+ return `${ne(i)}${Xe}/${e}`;
134
+ }
135
+ function et(i, e) {
136
+ return `${ne(i)}${Ye}/${e}`;
137
+ }
138
+ const ro = {
139
+ RELATIVE_CONTRACTS: H,
140
+ RELATIVE_INITIALIZED: de,
141
+ RELATIVE_TERMINATED: Je,
142
+ RELATIVE_EMBEDDED: Lt,
143
+ RELATIVE_CHECKPOINT: Qe,
144
+ LAST_EVENTS_SUFFIX: Xe,
145
+ LAST_SIGNATURES_SUFFIX: Ye,
146
+ relativeContractsEntry: ne,
147
+ relativeCheckpointLastEvent: Ze,
148
+ relativeCheckpointLastSignature: et
147
149
  };
148
- function Je(i) {
150
+ function tt(i) {
149
151
  return i == null || i.length === 0;
150
152
  }
151
- function C(i) {
152
- return Je(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
153
+ function k(i) {
154
+ return tt(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
153
155
  }
154
- function T(i) {
155
- return Je(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
156
+ function R(i) {
157
+ return tt(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
156
158
  }
157
- function Ce(i) {
159
+ function Re(i) {
158
160
  if (i == null)
159
161
  return "";
160
162
  let e = i.trim();
@@ -166,16 +168,16 @@ function Ce(i) {
166
168
  e = e.substring(0, e.length - 1);
167
169
  return e;
168
170
  }
169
- function Ni(i, e) {
170
- const t = Ce(i), n = Ce(e);
171
+ function io(i, e) {
172
+ const t = Re(i), n = Re(e);
171
173
  return t.length === 0 && n.length === 0 ? "/" : t.length === 0 ? `/${n}` : n.length === 0 ? `/${t}` : `/${t}/${n}`;
172
174
  }
173
- function k(i, e) {
174
- const t = C(i), n = T(e);
175
+ function T(i, e) {
176
+ const t = k(i), n = R(e);
175
177
  return t === "/" ? n : n === "/" || n.length === 1 ? t : `${t}${n}`;
176
178
  }
177
- function kt(i, e) {
178
- const t = C(i), n = T(e);
179
+ function Ft(i, e) {
180
+ const t = k(i), n = R(e);
179
181
  if (t === "/" || !n.startsWith(t))
180
182
  return n;
181
183
  if (n.length === t.length)
@@ -183,12 +185,12 @@ function kt(i, e) {
183
185
  const r = n.substring(t.length);
184
186
  return r.length === 0 ? "/" : r.startsWith("/") ? r : `/${r}`;
185
187
  }
186
- function Tt(i) {
188
+ function Ut(i) {
187
189
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
188
190
  }
189
- var ie, Se;
190
- function It() {
191
- return Se || (Se = 1, ie = function i(e) {
191
+ var se, Pe;
192
+ function $t() {
193
+ return Pe || (Pe = 1, se = function i(e) {
192
194
  if (typeof e == "number" && isNaN(e))
193
195
  throw new Error("NaN is not allowed");
194
196
  if (typeof e == "number" && !isFinite(e))
@@ -199,372 +201,305 @@ function It() {
199
201
  const o = n.length === 0 ? "" : ",";
200
202
  return `${n}${o}${i(r)}:${i(e[r])}`;
201
203
  }, "")}}`;
202
- }), ie;
204
+ }), se;
203
205
  }
204
- var Rt = It();
205
- const Pt = /* @__PURE__ */ Tt(Rt);
206
- function Mt(i, e) {
206
+ var zt = $t();
207
+ const Vt = /* @__PURE__ */ Ut(zt);
208
+ function Ht(i, e) {
207
209
  return i.nodeToJson(e, "official");
208
210
  }
209
- function Nt(i, e) {
210
- const t = Mt(i, e);
211
- return Pt(t);
211
+ function Kt(i, e) {
212
+ const t = Ht(i, e);
213
+ return Vt(t);
212
214
  }
213
- function Ge(i, e) {
214
- return e ? Nt(i, e) : null;
215
+ function nt(i, e) {
216
+ return e ? Kt(i, e) : null;
215
217
  }
216
- function ve(i, e) {
217
- const t = Ge(i, e);
218
+ function Me(i, e) {
219
+ const t = nt(i, e);
218
220
  return t == null ? 0 : new TextEncoder().encode(t).length;
219
221
  }
220
- function Qe(i) {
221
- return typeof i == "object" && i !== null && !Array.isArray(i);
222
- }
223
- function Ot(i) {
224
- return i.replace(/~1/g, "/").replace(/~0/g, "~");
225
- }
226
- function At(i) {
227
- if (i.length === 0 || !/^\d+$/.test(i))
228
- return !1;
229
- const e = Number(i);
230
- return Number.isSafeInteger(e);
231
- }
232
- function H(i, e = !0) {
233
- if (Array.isArray(i))
234
- return e ? i.map((r) => H(r, !0)) : i.slice();
235
- if (!Qe(i))
236
- return i;
237
- if (Object.prototype.hasOwnProperty.call(i, "value")) {
238
- const r = i.value;
239
- return e ? H(r, !0) : r;
240
- }
241
- const t = i.items;
242
- if (Array.isArray(t))
243
- return e ? t.map((r) => H(r, !0)) : t.slice();
244
- const n = {};
245
- for (const [r, o] of Object.entries(i))
246
- n[r] = e ? H(o, !0) : o;
247
- return n;
248
- }
249
- function Dt(i, e) {
250
- if (e === "")
251
- return i;
252
- if (!e.startsWith("/"))
253
- throw new TypeError('JSON pointer must start with "/"');
254
- const t = e.split("/").slice(1).map((r) => Ot(r));
255
- let n = i;
256
- for (const r of t) {
257
- if (n == null)
258
- return;
259
- if (Array.isArray(n)) {
260
- if (!At(r))
261
- return;
262
- const o = Number(r);
263
- n = n[o];
264
- continue;
265
- }
266
- if (Qe(n)) {
267
- n = n[r];
268
- continue;
269
- }
270
- return;
222
+ const Wt = 1700, pe = BigInt(
223
+ Wt
224
+ ), Gt = BigInt(Number.MAX_SAFE_INTEGER), qt = 4e4, jt = 4e4;
225
+ function Jt(i) {
226
+ let e;
227
+ if (typeof i == "bigint")
228
+ e = i;
229
+ else {
230
+ if (!Number.isFinite(i) || i <= 0)
231
+ return 0;
232
+ e = BigInt(Math.trunc(i));
233
+ }
234
+ if (e <= 0n)
235
+ return 0;
236
+ const t = (e + pe - 1n) / pe;
237
+ return t > Gt ? Number.MAX_SAFE_INTEGER : Number(t);
238
+ }
239
+ function rt(i) {
240
+ const e = BigInt(Math.max(0, Math.trunc(i)));
241
+ return e <= 0n ? 0n : e * pe;
242
+ }
243
+ const it = rt(
244
+ qt
245
+ ), Qt = rt(
246
+ jt
247
+ ), O = 1, Xt = /* @__PURE__ */ new Set([
248
+ "event",
249
+ "eventCanonical",
250
+ "steps",
251
+ "document",
252
+ "emit"
253
+ ]);
254
+ class Ce {
255
+ // Serialize evaluations to avoid races when updating host handler bindings.
256
+ evaluationQueue = Promise.resolve();
257
+ handlerState = {
258
+ documentGet: () => ({ ok: null, units: O }),
259
+ documentGetCanonical: () => ({ ok: null, units: O }),
260
+ emit: () => ({ ok: null, units: O })
261
+ };
262
+ handlers = {
263
+ document: {
264
+ get: (e) => this.handlerState.documentGet(e),
265
+ getCanonical: (e) => this.handlerState.documentGetCanonical(e)
266
+ },
267
+ emit: (e) => this.handlerState.emit(e)
268
+ };
269
+ async evaluate(e) {
270
+ const t = this.evaluationQueue.then(() => this.evaluateOnce(e));
271
+ return this.evaluationQueue = t.then(
272
+ () => {
273
+ },
274
+ () => {
275
+ }
276
+ ), t;
271
277
  }
272
- return n;
273
- }
274
- const Bt = 500, Lt = 32 * 1024 * 1024;
275
- class pe {
276
- modulePromise;
277
- moduleInstance;
278
- async evaluate({
278
+ async evaluateOnce({
279
279
  code: e,
280
280
  bindings: t,
281
- timeout: n = Bt,
282
- memoryLimit: r = Lt
281
+ wasmGasLimit: n,
282
+ onWasmGasUsed: r
283
283
  }) {
284
- const s = (await this.ensureModule()).newRuntime();
285
- s.setMemoryLimit(r);
286
- const a = Number.isFinite(n) ? Date.now() + Math.max(n, 0) : void 0;
287
- a !== void 0 && s.setInterruptHandler(() => Date.now() > a);
288
- const c = s.newContext();
284
+ const o = this.prepareBindings(t), s = n ?? it, a = {
285
+ code: this.wrapCode(e),
286
+ abiId: "Host.v1",
287
+ abiVersion: 1,
288
+ abiManifestHash: Tt
289
+ };
289
290
  try {
290
- this.installConsole(c), this.installDeterministicGlobals(c), this.installCanonNamespace(c), this.installBindings(c, t);
291
- const u = this.wrapCode(e), d = c.evalCode(u), g = c.unwrapResult(d);
292
- let m = null;
293
- try {
294
- return m = await this.resolveHandle(
295
- c,
296
- s,
297
- g,
298
- a
299
- ), c.dump(m);
300
- } finally {
301
- m ? m.dispose() : g.dispose();
302
- }
303
- } finally {
304
- c.dispose(), s.removeInterruptHandler?.(), s.dispose();
291
+ const c = await wt({
292
+ program: a,
293
+ input: o,
294
+ gasLimit: s,
295
+ manifest: It,
296
+ handlers: this.handlers
297
+ });
298
+ if (n !== void 0 && r && r({
299
+ used: c.gasUsed,
300
+ remaining: c.gasRemaining
301
+ }), !c.ok)
302
+ throw en(c);
303
+ return X(c.value);
304
+ } catch (c) {
305
+ throw tn(c);
305
306
  }
306
307
  }
307
- async ensureModule() {
308
- return this.moduleInstance ? this.moduleInstance : (this.modulePromise || (this.modulePromise = ht().then((e) => (this.moduleInstance = e, e))), this.modulePromise);
308
+ prepareBindings(e) {
309
+ const t = e ?? {};
310
+ Yt(t);
311
+ const n = ae(t.event, null, "event"), r = ae(
312
+ t.eventCanonical ?? n,
313
+ n,
314
+ "eventCanonical"
315
+ ), o = ae(t.steps, [], "steps"), s = {
316
+ event: n,
317
+ eventCanonical: r,
318
+ steps: o
319
+ }, a = this.extractDocumentBinding(t), c = typeof a?.canonical == "function" ? a.canonical : void 0;
320
+ this.handlerState.documentGet = Ne(a), this.handlerState.documentGetCanonical = Ne(
321
+ c ?? a
322
+ );
323
+ const u = this.extractEmitBinding(t);
324
+ return this.handlerState.emit = Zt(u), s;
325
+ }
326
+ extractDocumentBinding(e) {
327
+ if (!Object.prototype.hasOwnProperty.call(e, "document"))
328
+ return;
329
+ const t = e.document;
330
+ if (t != null) {
331
+ if (typeof t != "function")
332
+ throw new TypeError("QuickJS document binding must be a function");
333
+ return t;
334
+ }
335
+ }
336
+ extractEmitBinding(e) {
337
+ if (!Object.prototype.hasOwnProperty.call(e, "emit"))
338
+ return;
339
+ const t = e.emit;
340
+ if (t != null) {
341
+ if (typeof t != "function")
342
+ throw new TypeError("QuickJS emit binding must be a function");
343
+ return t;
344
+ }
309
345
  }
310
346
  wrapCode(e) {
311
- return `(async () => {
347
+ return `(() => {
348
+ return (() => {
312
349
  ${e}
350
+ })()
313
351
  })()`;
314
352
  }
315
- installConsole(e) {
316
- e.newObject().consume((t) => {
317
- const n = ["log", "info", "warn", "error"];
318
- for (const r of n) {
319
- const o = console[r] ?? console.log;
320
- e.newFunction(r, (...s) => {
321
- const a = s.map((c) => e.dump(c));
322
- return o.apply(console, a), e.undefined;
323
- }).consume((s) => e.setProp(t, r, s));
324
- }
325
- e.setProp(e.global, "console", t);
326
- });
327
- }
328
- installDeterministicGlobals(e) {
329
- e.setProp(e.global, "Date", e.undefined.dup());
330
- }
331
- installCanonNamespace(e) {
332
- e.newObject().consume((t) => {
333
- e.newFunction("unwrap", (...n) => {
334
- try {
335
- const [r, o] = n, s = r !== void 0 ? e.dump(r) : void 0, a = o === void 0 ? !0 : !!e.dump(o), c = H(s, a);
336
- return this.createReturnHandle(e, c);
337
- } catch (r) {
338
- const o = r instanceof Error ? r.message : String(r);
339
- return e.newError(o);
340
- }
341
- }).consume((n) => e.setProp(t, "unwrap", n)), e.newFunction("at", (...n) => {
342
- try {
343
- const [r, o] = n, s = r !== void 0 ? e.dump(r) : void 0;
344
- if (o === void 0)
345
- throw new TypeError(
346
- "canon.at(target, pointer) requires a pointer argument"
347
- );
348
- const a = e.dump(o);
349
- if (typeof a != "string")
350
- throw new TypeError("canon.at pointer must be a string");
351
- const c = Dt(s, a);
352
- return this.createReturnHandle(e, c);
353
- } catch (r) {
354
- const o = r instanceof Error ? r.message : String(r);
355
- return e.newError(o);
356
- }
357
- }).consume((n) => e.setProp(t, "at", n)), e.setProp(e.global, "canon", t);
358
- });
359
- }
360
- installBindings(e, t) {
361
- if (t)
362
- for (const [n, r] of Object.entries(t))
363
- typeof r == "function" ? this.createFunctionHandle(
364
- e,
365
- n,
366
- r
367
- ).consume(
368
- (s) => e.setProp(e.global, n, s)
369
- ) : r !== void 0 && this.createOwnedHandle(e, r).consume(
370
- (s) => e.setProp(e.global, n, s)
371
- );
372
- }
373
- createFunctionHandle(e, t, n) {
374
- const r = e.newFunction(
375
- t,
376
- (...o) => {
377
- try {
378
- const s = o.map((c) => e.dump(c)), a = n(...s);
379
- if (a instanceof Promise)
380
- throw new TypeError("Async bindings are not supported");
381
- return this.createReturnHandle(e, a);
382
- } catch (s) {
383
- const a = s instanceof Error ? s.message : String(s);
384
- return e.newError(a);
385
- }
386
- }
387
- );
388
- return this.applyFunctionProperties(e, r, n), r;
389
- }
390
- /**
391
- * Copies enumerable properties from a host function onto the QuickJS handle.
392
- * Nested functions (e.g. `document.canonical = () => {}`) are recursively wrapped
393
- * so they stay callable inside QuickJS; plain values are serialized via
394
- * `createOwnedHandle`. This preserves helper namespaces on binding functions.
395
- */
396
- applyFunctionProperties(e, t, n) {
397
- if (!(n === null || typeof n != "object" && typeof n != "function"))
398
- for (const [r, o] of Object.entries(
399
- n
400
- )) {
401
- if (o === void 0)
402
- continue;
403
- if (typeof o == "function") {
404
- this.createFunctionHandle(
405
- e,
406
- r,
407
- o
408
- ).consume(
409
- (c) => e.setProp(t, r, c)
410
- );
411
- continue;
412
- }
413
- this.createOwnedHandle(e, o).consume(
414
- (a) => e.setProp(t, r, a)
415
- );
416
- }
417
- }
418
- createOwnedHandle(e, t) {
419
- if (t === void 0)
420
- return e.undefined.dup();
421
- if (t === null)
422
- return e.null.dup();
423
- if (typeof t == "boolean")
424
- return (t ? e.true : e.false).dup();
425
- if (typeof t == "number")
426
- return e.newNumber(t);
427
- if (typeof t == "string")
428
- return e.newString(t);
429
- if (typeof t == "bigint")
430
- return e.newBigInt(t);
431
- if (Array.isArray(t) || typeof t == "object") {
432
- const n = JSON.stringify(t);
433
- if (n === void 0)
434
- return e.undefined.dup();
435
- const r = e.evalCode(`(${n})`);
436
- return e.unwrapResult(r);
437
- }
353
+ }
354
+ function Yt(i) {
355
+ for (const e of Object.keys(i))
356
+ if (!Xt.has(e))
357
+ throw new TypeError(`Unsupported QuickJS binding: "${e}"`);
358
+ }
359
+ function ae(i, e, t) {
360
+ const n = i === void 0 ? e : i;
361
+ try {
362
+ kt(n, { limits: bt });
363
+ } catch (r) {
364
+ const o = r instanceof Error ? r.message : String(r);
438
365
  throw new TypeError(
439
- `Unsupported binding value type: ${typeof t}`
366
+ `QuickJS ${t} binding must be valid DV: ${o}`
440
367
  );
441
368
  }
442
- createReturnHandle(e, t) {
443
- if (t === void 0)
444
- return e.undefined;
445
- if (t === null)
446
- return e.null;
447
- if (typeof t == "boolean")
448
- return t ? e.true : e.false;
449
- if (typeof t == "number")
450
- return e.newNumber(t);
451
- if (typeof t == "string")
452
- return e.newString(t);
453
- if (typeof t == "bigint")
454
- return e.newBigInt(t);
455
- if (Array.isArray(t) || typeof t == "object") {
456
- const n = JSON.stringify(t);
457
- if (n === void 0)
458
- return e.undefined;
459
- const r = e.evalCode(`(${n})`);
460
- return e.unwrapResult(r);
369
+ return n;
370
+ }
371
+ function Ne(i) {
372
+ return i ? (e) => {
373
+ try {
374
+ const t = i(e);
375
+ return {
376
+ ok: t === void 0 ? null : t,
377
+ units: O
378
+ };
379
+ } catch {
380
+ return {
381
+ err: { code: "INVALID_PATH", tag: "host/invalid_path" },
382
+ units: O
383
+ };
461
384
  }
462
- throw new TypeError(
463
- `Unsupported binding return type: ${typeof t}`
464
- );
465
- }
466
- async resolveHandle(e, t, n, r) {
467
- let o = n;
468
- for (; ; ) {
469
- const s = e.getPromiseState(o);
470
- if (s.type === "pending") {
471
- if (r !== void 0 && Date.now() > r)
472
- throw o.dispose(), new Error("QuickJS execution timed out while awaiting Promise");
473
- const a = t.executePendingJobs();
474
- let c = 0;
475
- try {
476
- c = e.unwrapResult(a);
477
- } finally {
478
- a.dispose();
479
- }
480
- if (c === 0) {
481
- if (r !== void 0 && Date.now() > r)
482
- throw o.dispose(), new Error(
483
- "QuickJS execution timed out while awaiting Promise"
484
- );
485
- await new Promise((u) => setTimeout(u, 0));
486
- }
487
- continue;
488
- }
489
- if (s.type === "fulfilled") {
490
- if (s.notAPromise)
491
- return o;
492
- o.dispose(), o = s.value;
493
- continue;
494
- }
495
- if (s.type === "rejected")
496
- try {
497
- const a = e.dump(s.error);
498
- throw a instanceof Error ? a : a && typeof a == "object" && "message" in a ? new Error(
499
- String(a.message)
500
- ) : new Error(
501
- typeof a == "string" ? a : JSON.stringify(a)
502
- );
503
- } finally {
504
- s.error.dispose(), o.dispose();
505
- }
385
+ } : () => ({ ok: null, units: O });
386
+ }
387
+ function Zt(i) {
388
+ return i ? (e) => {
389
+ try {
390
+ if (i(X(e)) instanceof Promise)
391
+ throw new Error("Async emit handlers are not supported");
392
+ return { ok: null, units: O };
393
+ } catch {
394
+ return {
395
+ err: { code: "LIMIT_EXCEEDED", tag: "host/limit" },
396
+ units: O
397
+ };
506
398
  }
399
+ } : () => ({ ok: null, units: O });
400
+ }
401
+ function X(i) {
402
+ if (i == null)
403
+ return i;
404
+ if (Array.isArray(i))
405
+ return i.map((e) => X(e));
406
+ if (typeof i == "object") {
407
+ const e = Object.getPrototypeOf(i);
408
+ if (e !== Object.prototype && e !== null)
409
+ return i;
410
+ const t = {};
411
+ for (const [n, r] of Object.entries(i))
412
+ t[n] = X(r);
413
+ return t;
507
414
  }
415
+ return i;
508
416
  }
509
- const be = 120;
510
- function xt(i) {
511
- return i.length <= be ? i : `${i.slice(0, be - 3)}...`;
417
+ function en(i) {
418
+ if (i.ok)
419
+ return new Error("Unexpected evaluation result");
420
+ if (i.type === "invalid-output") {
421
+ const r = new Error(i.message);
422
+ return r.name = "InvalidOutputError", r;
423
+ }
424
+ const e = i.error;
425
+ if (e.kind === "out-of-gas") {
426
+ const r = new Error(
427
+ `OutOfGas: ${e.message || "out of gas"}`
428
+ );
429
+ return r.name = "OutOfGasError", r;
430
+ }
431
+ const t = e.message || i.message, n = new Error(t);
432
+ return e.kind === "js-exception" ? (n.name = e.name || "Error", n) : e.kind === "host-error" ? (n.name = "HostError", n) : e.kind === "manifest-error" ? (n.name = "ManifestError", n) : (e.kind === "unknown" && e.name && (n.name = e.name), n);
512
433
  }
513
- class Ye extends Error {
434
+ function tn(i) {
435
+ return i instanceof Error ? i : new Error(String(i ?? "Unknown error"));
436
+ }
437
+ const Oe = 120;
438
+ function nn(i) {
439
+ return i.length <= Oe ? i : `${i.slice(0, Oe - 3)}...`;
440
+ }
441
+ class ot extends Error {
514
442
  constructor(e, t) {
515
- super(`Failed to evaluate code block: ${xt(e)}`, { cause: t }), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
443
+ super(`Failed to evaluate code block: ${nn(e)}`, { cause: t }), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
516
444
  }
517
445
  }
518
- const Xe = /^\$\{([\s\S]*)\}$/, _t = /\$\{([\s\S]+?)\}/, Ze = /\$\{([\s\S]+?)\}/g;
519
- function G(i) {
520
- if (typeof i != "string" || !Xe.test(i))
446
+ const st = /^\$\{([\s\S]*)\}$/, rn = /\$\{([\s\S]+?)\}/, on = /\$\{([\s\S]+?)\}/g;
447
+ function Y(i) {
448
+ if (typeof i != "string" || !st.test(i))
521
449
  return !1;
522
450
  const e = i.indexOf("${"), t = i.lastIndexOf("${");
523
451
  return e === t;
524
452
  }
525
- function Ft(i) {
526
- return typeof i != "string" ? !1 : Xe.test(i) ? !0 : _t.test(i);
453
+ function sn(i) {
454
+ return typeof i != "string" ? !1 : st.test(i) ? !0 : rn.test(i);
527
455
  }
528
- function Ut(i) {
529
- if (!G(i))
456
+ function an(i) {
457
+ if (!Y(i))
530
458
  throw new Error(`Invalid expression: ${i}`);
531
459
  return i.slice(2, -1);
532
460
  }
533
- async function et(i, e, t) {
534
- const n = `return await (${e});`;
461
+ async function at(i, e, t, n, r) {
462
+ const o = `return (${e});`;
535
463
  try {
536
- return await i.evaluate({ code: n, bindings: t });
537
- } catch (r) {
538
- throw new Ye(e, r);
464
+ return await i.evaluate({
465
+ code: o,
466
+ bindings: t,
467
+ wasmGasLimit: n,
468
+ onWasmGasUsed: r
469
+ });
470
+ } catch (s) {
471
+ throw new ot(e, s);
539
472
  }
540
473
  }
541
- async function zt(i, e, t) {
542
- let n = "", r = 0;
543
- for (const o of e.matchAll(Ze)) {
544
- const s = o[0], a = o[1], c = o.index ?? 0;
545
- n += e.slice(r, c);
546
- const u = await et(
474
+ async function cn(i, e, t, n, r) {
475
+ let o = "", s = 0;
476
+ for (const a of e.matchAll(on)) {
477
+ const c = a[0], u = a[1], h = a.index ?? 0;
478
+ o += e.slice(s, h);
479
+ const d = await at(
547
480
  i,
548
- a,
549
- t
481
+ u,
482
+ t,
483
+ n,
484
+ r
550
485
  );
551
- n += u == null ? "" : String(u), r = c + s.length;
486
+ o += d == null ? "" : String(d), s = h + c.length;
552
487
  }
553
- return n += e.slice(r), n;
488
+ return o += e.slice(s), o;
554
489
  }
555
- function tt({
490
+ function ct({
556
491
  include: i,
557
492
  exclude: e = [],
558
493
  options: t
559
494
  }) {
560
495
  const n = { dot: !0, ...t ?? {} }, r = i.map(
561
- (s) => we(s, n)
496
+ (s) => Te(s, n)
562
497
  ), o = e.map(
563
- (s) => we(s, n)
498
+ (s) => Te(s, n)
564
499
  );
565
500
  return (s) => r.some((a) => a(s)) && !o.some((a) => a(s));
566
501
  }
567
- async function Q(i) {
502
+ async function Z(i) {
568
503
  const {
569
504
  evaluator: e,
570
505
  node: t,
@@ -573,92 +508,93 @@ async function Q(i) {
573
508
  shouldDescend: o = () => !0,
574
509
  context: s,
575
510
  pointer: a = "/"
576
- } = i, c = t.clone();
577
- if (!o(a, c))
578
- return c;
579
- const u = c.getValue();
580
- if (u !== void 0) {
581
- if (typeof u == "string" && r(a)) {
582
- if (G(u)) {
583
- const m = Ut(u);
584
- s.gasMeter().chargeExpression(m);
585
- const y = await et(
511
+ } = i, c = Qt, u = ({
512
+ used: E
513
+ }) => {
514
+ s.gasMeter().chargeWasmGas(E);
515
+ }, h = t.clone();
516
+ if (!o(a, h))
517
+ return h;
518
+ const d = h.getValue();
519
+ if (d !== void 0) {
520
+ if (typeof d == "string" && r(a)) {
521
+ if (Y(d)) {
522
+ const E = an(d), C = await at(
586
523
  e,
587
- m,
588
- n
524
+ E,
525
+ n,
526
+ c,
527
+ u
589
528
  );
590
- return s.blue.jsonValueToNode(y ?? null);
591
- } else if (Ft(u)) {
592
- const m = new RegExp(Ze);
593
- let y = 0;
594
- for (m.lastIndex = 0; m.exec(u); )
595
- y += 1;
596
- s.gasMeter().chargeTemplate(y, u);
597
- const P = await zt(
529
+ return s.blue.jsonValueToNode(C ?? null);
530
+ } else if (sn(d)) {
531
+ const E = await cn(
598
532
  e,
599
- u,
600
- n
533
+ d,
534
+ n,
535
+ c,
536
+ u
601
537
  );
602
- return new h().setValue(P);
538
+ return new p().setValue(E);
603
539
  }
604
540
  }
605
- return c;
541
+ return h;
606
542
  }
607
- const d = c.getItems?.();
608
- if (Array.isArray(d)) {
609
- const m = await Promise.all(
610
- d.map(
611
- (y, P) => Q({
543
+ const S = h.getItems?.();
544
+ if (Array.isArray(S)) {
545
+ const E = await Promise.all(
546
+ S.map(
547
+ (C, P) => Z({
612
548
  ...i,
613
- node: y,
549
+ node: C,
614
550
  pointer: `${a}/${P}`
615
551
  })
616
552
  )
617
553
  );
618
- return c.setItems(m), c;
619
- }
620
- const g = c.getProperties?.();
621
- if (g) {
622
- const m = {};
623
- for (const [y, P] of Object.entries(g)) {
624
- const re = a === "/" ? `/${y}` : `${a}/${y}`;
625
- m[y] = await Q({
554
+ return h.setItems(E), h;
555
+ }
556
+ const m = h.getProperties?.();
557
+ if (m) {
558
+ const E = {};
559
+ for (const [C, P] of Object.entries(m)) {
560
+ const D = a === "/" ? `/${C}` : `${a}/${C}`;
561
+ E[C] = await Z({
626
562
  ...i,
627
563
  node: P,
628
- pointer: re
564
+ pointer: D
629
565
  });
630
566
  }
631
- c.setProperties(m);
567
+ h.setProperties(E);
632
568
  }
633
- return c;
569
+ return h;
634
570
  }
635
- const ee = f(p["Core/Contract"])(l.object({
571
+ const re = g(f["Core/Contract"])(l.object({
636
572
  description: l.string().optional(),
637
573
  name: l.string().optional(),
638
574
  order: l.number().optional()
639
- })), fe = ee, _ = f(p["Core/Channel"])(ee.extend({
575
+ })), Se = re, x = g(f["Core/Channel"])(re.extend({
640
576
  description: l.string().optional(),
641
- event: v().optional(),
577
+ event: b().optional(),
642
578
  name: l.string().optional()
643
- })), F = _.merge(
644
- fe
579
+ })), _ = x.merge(
580
+ Se
645
581
  ).extend({
646
582
  path: l.string().optional(),
647
- definition: v().optional()
648
- }), nt = f(p["Core/Handler"])(ee.extend({
583
+ definition: b().optional()
584
+ }), lt = g(f["Core/Handler"])(re.extend({
649
585
  channel: l.string().optional(),
650
586
  description: l.string().optional(),
651
- event: v().optional(),
587
+ event: b().optional(),
652
588
  name: l.string().optional()
653
- })), rt = nt.merge(fe), U = f(p["Core/Marker"])(ee.extend({
589
+ })), ut = lt.merge(Se), K = g(f["Core/Marker"])(re.extend({
654
590
  description: l.string().optional(),
655
591
  name: l.string().optional()
656
- })), R = U.merge(fe), $t = l.object({
592
+ })), N = K.merge(Se), ln = l.object({
657
593
  op: l.enum(["ADD", "REPLACE", "REMOVE"]),
658
594
  path: l.string(),
659
- val: v().optional()
660
- }), Oi = f("JsonPatch")(
661
- $t
595
+ val: b().optional()
596
+ }), oo = g("JsonPatch")(
597
+ ln
662
598
  ).superRefine((i, e) => {
663
599
  i.op === "REMOVE" && i.val !== void 0 && e.addIssue({
664
600
  code: l.ZodIssueCode.custom,
@@ -669,28 +605,29 @@ const ee = f(p["Core/Contract"])(l.object({
669
605
  message: `${i.op} operations must include a value`,
670
606
  path: ["val"]
671
607
  });
672
- }), Ht = f(p["Core/Document Update Channel"])(_.extend({
608
+ }), un = g(f["Core/Document Update Channel"])(x.extend({
673
609
  description: l.string().optional(),
674
610
  name: l.string().optional(),
675
611
  path: l.string().optional()
676
- })), Vt = Ht.merge(
677
- F
678
- ), Wt = f(p["Core/Embedded Node Channel"])(_.extend({
612
+ })), hn = un.merge(
613
+ _
614
+ ), dn = g(f["Core/Embedded Node Channel"])(x.extend({
679
615
  childPath: l.string().optional(),
680
616
  description: l.string().optional(),
681
617
  name: l.string().optional()
682
- })), Kt = Wt.merge(
683
- F
684
- ), qt = f(p["Core/Lifecycle Event Channel"])(_.extend({
618
+ })), pn = dn.merge(
619
+ _
620
+ ), mn = g(f["Core/Lifecycle Event Channel"])(x.extend({
685
621
  description: l.string().optional(),
686
622
  name: l.string().optional()
687
- })), jt = qt.merge(
688
- F
689
- ), Jt = f(p["Core/Triggered Event Channel"])(_.extend({
623
+ })), fn = mn.merge(
624
+ _
625
+ ), gn = g(f["Core/Triggered Event Channel"])(x.extend({
690
626
  description: l.string().optional(),
691
627
  name: l.string().optional()
692
- })), Gt = Jt.merge(F), S = {
628
+ })), En = gn.merge(_), w = {
693
629
  "Conversation/Actor": "CN5efWVizJbRsMCw8YWRfT2q9vM9XfeGDN9wFvYcvMnQ",
630
+ "Conversation/Composite Timeline Channel": "HsNatiPt2YvmkWQoqtfrFCbdp75ZUBLBUkWeq84WTfnr",
694
631
  "Conversation/JavaScript Code": "3hYcmWMtMUPAzXBLFLb7BpuG9537tuTJPCr7pxWXvTZK",
695
632
  "Conversation/Operation": "BoAiqVUZv9Fum3wFqaX2JnQMBHJLxJSo2V9U2UBmCfsC",
696
633
  "Conversation/Operation Request": "HM4Ku4LFcjC5MxnhPMRwQ8w3BbHmJKKZfHTTzsd4jbJq",
@@ -702,13 +639,13 @@ const ee = f(p["Core/Contract"])(l.object({
702
639
  "Conversation/Timeline Entry": "EzDiC9Frs8V5yQBMtDYh1DobVnWtWpFemXDX5fGUULBn",
703
640
  "Conversation/Trigger Event": "GxUtWr3eH9a6YQeioQkujEnsPjD5s9RU8ZhEfmsV1vuU",
704
641
  "Conversation/Update Document": "BnnNLCnKF49TUJ1bRfZ5rSMaFw8SVfUNfnE4kJFG7HtM"
705
- }, it = f(S["Conversation/Timeline Channel"])(_.extend({
642
+ }, ht = g(w["Conversation/Timeline Channel"])(x.extend({
706
643
  description: l.string().optional(),
707
644
  name: l.string().optional(),
708
645
  timelineId: l.string().optional()
709
- })), Qt = it.merge(
710
- F
711
- ), b = {
646
+ })), yn = ht.merge(
647
+ _
648
+ ), I = {
712
649
  "MyOS/Document Anchor": "HS9yo34TGEAM2LGcNbLh7XPN4goPRhqdGZQkiyh473Wb",
713
650
  "MyOS/Document Anchors": "7Usvk6dZMVqas3yqs23ZEXn1zu1YDPjgYiZFNYaw3puH",
714
651
  "MyOS/Document Links": "4cmrbevB6K23ZenjqwmNxpnaw6RF4VB3wkP7XB59V7W5",
@@ -719,100 +656,104 @@ const ee = f(p["Core/Contract"])(l.object({
719
656
  "MyOS/MyOS Timeline Channel": "HCF8mXnX3dFjQ8osjxb4Wzm2Nm1DoXnTYuA5sPnV7NTs",
720
657
  "MyOS/MyOS Timeline Entry": "Furgmg5xcJVMDmaQXZRfZ1XehSf7PWctrioo8etRYJHQ",
721
658
  "MyOS/MyOS Worker Agency": "4Lix4AKXvBDvrwxw2htSdYFKxL4wugEQzqoSEYet5Dh1"
722
- }, Yt = f(b["MyOS/MyOS Timeline Channel"])(it.extend({
659
+ }, Cn = g(I["MyOS/MyOS Timeline Channel"])(ht.extend({
723
660
  accountId: l.string().optional(),
724
661
  description: l.string().optional(),
725
662
  email: l.string().optional(),
726
663
  name: l.string().optional()
727
- })), Xt = Yt.merge(F), Zt = f(p["Core/Channel Event Checkpoint"])(U.extend({
664
+ })), Sn = Cn.merge(_), vn = g(w["Conversation/Composite Timeline Channel"])(x.extend({
665
+ channels: l.array(l.string()).optional(),
728
666
  description: l.string().optional(),
729
- lastEvents: l.record(l.string(), v()).optional(),
730
667
  name: l.string().optional()
731
- })), en = Zt.merge(R).extend({
668
+ })), dt = vn.merge(_), wn = g(f["Core/Channel Event Checkpoint"])(K.extend({
669
+ description: l.string().optional(),
670
+ lastEvents: l.record(l.string(), b()).optional(),
671
+ name: l.string().optional()
672
+ })), kn = wn.merge(N).extend({
732
673
  lastSignatures: l.record(l.string()).optional()
733
- }), tn = f(p["Core/Processing Initialized Marker"])(U.extend({
674
+ }), bn = g(f["Core/Processing Initialized Marker"])(K.extend({
734
675
  description: l.string().optional(),
735
676
  documentId: l.string().optional(),
736
677
  name: l.string().optional()
737
- })), nn = tn.merge(R), rn = f(p["Core/Process Embedded"])(U.extend({
678
+ })), In = bn.merge(N), Tn = g(f["Core/Process Embedded"])(K.extend({
738
679
  description: l.string().optional(),
739
680
  name: l.string().optional(),
740
681
  paths: l.array(l.string()).optional()
741
- })), on = rn.merge(
742
- R
743
- ), sn = f(p["Core/Processing Terminated Marker"])(U.extend({
682
+ })), Rn = Tn.merge(
683
+ N
684
+ ), Pn = g(f["Core/Processing Terminated Marker"])(K.extend({
744
685
  cause: l.string().optional(),
745
686
  description: l.string().optional(),
746
687
  name: l.string().optional(),
747
688
  reason: l.string().optional()
748
- })), an = sn.merge(R), W = f(S["Conversation/Operation"])(U.extend({
689
+ })), Mn = Pn.merge(N), j = g(w["Conversation/Operation"])(K.extend({
749
690
  channel: l.string().optional(),
750
691
  description: l.string().optional(),
751
692
  name: l.string().optional(),
752
- request: v().optional()
753
- })), cn = W.merge(
754
- R
755
- ), ln = f(b["MyOS/Document Anchor"])(l.object({
693
+ request: b().optional()
694
+ })), Nn = j.merge(
695
+ N
696
+ ), On = g(I["MyOS/Document Anchor"])(l.object({
756
697
  description: l.string().optional(),
757
698
  name: l.string().optional(),
758
- template: v().optional()
759
- })), un = f(b["MyOS/Document Anchors"])(l.object({}).catchall(ln)), dn = un.merge(R), hn = f(b["MyOS/Link"])(l.object({
699
+ template: b().optional()
700
+ })), An = g(I["MyOS/Document Anchors"])(l.object({}).catchall(On)), Dn = An.merge(N), Bn = g(I["MyOS/Link"])(l.object({
760
701
  anchor: l.string().optional(),
761
702
  description: l.string().optional(),
762
703
  name: l.string().optional()
763
- })), pn = f(b["MyOS/Document Links"])(l.object({}).catchall(hn)), fn = pn.merge(
764
- R
765
- ), mn = f(b["MyOS/MyOS Participants Orchestration"])(l.object({
704
+ })), xn = g(I["MyOS/Document Links"])(l.object({}).catchall(Bn)), _n = xn.merge(
705
+ N
706
+ ), Ln = g(I["MyOS/MyOS Participants Orchestration"])(l.object({
766
707
  name: l.string().optional()
767
- })), gn = mn.merge(R), yn = f(b["MyOS/MyOS Session Interaction"])(l.object({
708
+ })), Fn = Ln.merge(N), Un = g(I["MyOS/MyOS Session Interaction"])(l.object({
768
709
  name: l.string().optional()
769
- })), En = yn.merge(R), wn = f(b["MyOS/MyOS Worker Agency"])(l.object({
710
+ })), $n = Un.merge(N), zn = g(I["MyOS/MyOS Worker Agency"])(l.object({
770
711
  name: l.string().optional()
771
- })), Cn = wn.merge(
772
- R
773
- ), te = f(S["Conversation/Sequential Workflow Step"])(l.object({
712
+ })), Vn = zn.merge(
713
+ N
714
+ ), ie = g(w["Conversation/Sequential Workflow Step"])(l.object({
774
715
  description: l.string().optional(),
775
716
  name: l.string().optional()
776
- })), ot = f(S["Conversation/Sequential Workflow"])(nt.extend({
717
+ })), pt = g(w["Conversation/Sequential Workflow"])(lt.extend({
777
718
  description: l.string().optional(),
778
719
  name: l.string().optional(),
779
- steps: l.array(te).optional()
780
- })), Ai = v(), Sn = ot.merge(rt).extend({
781
- steps: l.array(v()).optional()
782
- }), vn = f(S["Conversation/Sequential Workflow Operation"])(ot.extend({
720
+ steps: l.array(ie).optional()
721
+ })), so = b(), Hn = pt.merge(ut).extend({
722
+ steps: l.array(b()).optional()
723
+ }), Kn = g(w["Conversation/Sequential Workflow Operation"])(pt.extend({
783
724
  description: l.string().optional(),
784
725
  name: l.string().optional(),
785
726
  operation: l.string().optional()
786
- })), bn = vn.merge(
787
- rt
727
+ })), Wn = Kn.merge(
728
+ ut
788
729
  ).extend({
789
- steps: l.array(v()).optional()
730
+ steps: l.array(b()).optional()
790
731
  });
791
- function kn(i) {
732
+ function Gn(i) {
792
733
  if (!Array.isArray(i.blueIds) || i.blueIds.length === 0)
793
734
  throw new Error("Contract processors must declare at least one BlueId");
794
735
  for (const e of i.blueIds)
795
736
  if (typeof e != "string" || e.trim().length === 0)
796
737
  throw new Error("Contract processor BlueIds must be non-empty strings");
797
738
  }
798
- function j(i, e) {
799
- kn(i);
739
+ function J(i, e) {
740
+ Gn(i);
800
741
  for (const t of i.blueIds)
801
742
  e.set(t, i);
802
743
  }
803
- class Tn {
744
+ class qn {
804
745
  processorsByBlueId = /* @__PURE__ */ new Map();
805
746
  handlerProcessors = /* @__PURE__ */ new Map();
806
747
  channelProcessors = /* @__PURE__ */ new Map();
807
748
  markerProcessors = /* @__PURE__ */ new Map();
808
749
  registerHandler(e) {
809
- j(e, this.handlerProcessors), this.registerProcessorMap(e);
750
+ J(e, this.handlerProcessors), this.registerProcessorMap(e);
810
751
  }
811
752
  registerChannel(e) {
812
- j(e, this.channelProcessors), this.registerProcessorMap(e);
753
+ J(e, this.channelProcessors), this.registerProcessorMap(e);
813
754
  }
814
755
  registerMarker(e) {
815
- j(e, this.markerProcessors), this.registerProcessorMap(e);
756
+ J(e, this.markerProcessors), this.registerProcessorMap(e);
816
757
  }
817
758
  register(e) {
818
759
  switch (e.kind) {
@@ -846,55 +787,176 @@ class Tn {
846
787
  return new Map(this.processorsByBlueId);
847
788
  }
848
789
  registerProcessorMap(e) {
849
- j(e, this.processorsByBlueId);
790
+ J(e, this.processorsByBlueId);
850
791
  }
851
792
  }
852
- const In = f(S["Conversation/Actor"])(l.object({
793
+ const jn = "compositeSourceChannelKey";
794
+ function Jn(i, e) {
795
+ return `${i}::${e}`;
796
+ }
797
+ function Qn(i) {
798
+ return i != null && Object.prototype.hasOwnProperty.call(i, "lastEvents") && Object.prototype.hasOwnProperty.call(i, "lastSignatures");
799
+ }
800
+ class Xn {
801
+ kind = "channel";
802
+ blueIds = [
803
+ w["Conversation/Composite Timeline Channel"]
804
+ ];
805
+ schema = dt;
806
+ /**
807
+ * Fallback match hook that delegates to {@link evaluate} for consistent behavior.
808
+ */
809
+ matches(e, t) {
810
+ return this.evaluate(e, t).then((n) => n.matches);
811
+ }
812
+ /**
813
+ * Resolve child channels and return a delivery per matching child, enriching
814
+ * each delivered event with the source channel key.
815
+ */
816
+ async evaluate(e, t) {
817
+ const n = t.event;
818
+ if (!n)
819
+ return { matches: !1 };
820
+ const r = e.channels?.filter((u) => u.trim().length > 0) ?? [];
821
+ if (r.length === 0)
822
+ return { matches: !1 };
823
+ const o = t.resolveChannel, s = t.channelProcessorFor;
824
+ if (!o || !s)
825
+ throw new Error(
826
+ "Composite timeline channel evaluation requires channel resolution helpers"
827
+ );
828
+ const a = t.blue.calculateBlueIdSync(n), c = [];
829
+ for (const u of r) {
830
+ const h = o(u);
831
+ if (!h)
832
+ throw new Error(
833
+ `Composite timeline channel '${t.bindingKey}' references missing channel '${u}'`
834
+ );
835
+ const d = s(h.blueId);
836
+ if (!d)
837
+ throw new Error(
838
+ `No processor registered for child channel '${u}' (${h.blueId})`
839
+ );
840
+ const S = n.clone(), m = {
841
+ ...t,
842
+ event: S,
843
+ bindingKey: u
844
+ }, E = h.contract, C = E.event;
845
+ if (C && !t.blue.isTypeOfNode(S, C) || !await d.matches(E, m))
846
+ continue;
847
+ const D = d.channelize, ke = (D ? D.call(d, E, m) : void 0) ?? S.clone();
848
+ this.enrichEvent(ke, u);
849
+ const be = Jn(
850
+ t.bindingKey,
851
+ u
852
+ ), vt = await this.shouldProcessChild({
853
+ childProcessor: d,
854
+ childContract: E,
855
+ context: {
856
+ ...m,
857
+ event: n.clone()
858
+ },
859
+ checkpointKey: be,
860
+ markers: t.markers
861
+ });
862
+ c.push({
863
+ eventNode: ke,
864
+ eventId: a,
865
+ checkpointKey: be,
866
+ shouldProcess: vt
867
+ });
868
+ }
869
+ return {
870
+ matches: c.length > 0,
871
+ deliveries: c
872
+ };
873
+ }
874
+ /**
875
+ * Determine recency by checking whether any child delivery should process.
876
+ */
877
+ async isNewerEvent(e, t, n) {
878
+ const r = await this.evaluate(e, t), o = r.deliveries ?? [];
879
+ return !r.matches || o.length === 0 ? !1 : o.some((s) => s.shouldProcess !== !1);
880
+ }
881
+ /**
882
+ * Attach the source child channel key to event metadata for handler logic.
883
+ */
884
+ enrichEvent(e, t) {
885
+ const n = e.getProperties() ?? {}, r = n.meta instanceof p ? n.meta.clone() : new p(), o = r.getProperties() ?? {};
886
+ r.setProperties({
887
+ ...o,
888
+ [jn]: new p().setValue(t)
889
+ }), e.setProperties({ ...n, meta: r });
890
+ }
891
+ /**
892
+ * Apply child-level recency rules using the composite-scoped checkpoint entry.
893
+ */
894
+ async shouldProcessChild(e) {
895
+ const t = e.childProcessor.isNewerEvent;
896
+ if (typeof t != "function")
897
+ return !0;
898
+ const r = this.resolveCheckpoint(e.markers)?.lastEvents?.[e.checkpointKey] ?? null;
899
+ return !r || typeof r.clone != "function" ? !0 : await t.call(
900
+ e.childProcessor,
901
+ e.childContract,
902
+ e.context,
903
+ r.clone()
904
+ );
905
+ }
906
+ /**
907
+ * Resolve the checkpoint marker for the current scope, if present.
908
+ */
909
+ resolveCheckpoint(e) {
910
+ const t = e.get(A);
911
+ return Qn(t) ? t : null;
912
+ }
913
+ }
914
+ const Yn = g(w["Conversation/Actor"])(l.object({
853
915
  description: l.string().optional(),
854
916
  name: l.string().optional()
855
- })), st = f(S["Conversation/Timeline"])(l.object({
917
+ })), mt = g(w["Conversation/Timeline"])(l.object({
856
918
  description: l.string().optional(),
857
919
  name: l.string().optional(),
858
920
  timelineId: l.string().optional()
859
- })), I = f(S["Conversation/Timeline Entry"])(l.object({
860
- actor: In.optional(),
921
+ })), M = g(w["Conversation/Timeline Entry"])(l.object({
922
+ actor: Yn.optional(),
861
923
  description: l.string().optional(),
862
- message: v().optional(),
924
+ message: b().optional(),
863
925
  name: l.string().optional(),
864
- prevEntry: v().optional(),
865
- timeline: st.optional(),
926
+ prevEntry: b().optional(),
927
+ timeline: mt.optional(),
866
928
  timestamp: l.number().optional()
867
- })), Rn = f(b["MyOS/MyOS Timeline"])(st.extend({
929
+ })), Zn = g(I["MyOS/MyOS Timeline"])(mt.extend({
868
930
  accountId: l.string().optional(),
869
931
  description: l.string().optional(),
870
932
  name: l.string().optional()
871
- })), ke = f(b["MyOS/MyOS Timeline Entry"])(I.extend({
933
+ })), Ae = g(I["MyOS/MyOS Timeline Entry"])(M.extend({
872
934
  description: l.string().optional(),
873
935
  name: l.string().optional(),
874
- timeline: Rn.optional()
936
+ timeline: Zn.optional()
875
937
  }));
876
- function Te(i, e) {
877
- return e && i.isTypeOf(e, I, { checkSchemaExtensions: !0 }) ? i.nodeToSchemaOutput(e, I) : null;
938
+ function De(i, e) {
939
+ return e && i.isTypeOf(e, M, { checkSchemaExtensions: !0 }) ? i.nodeToSchemaOutput(e, M) : null;
878
940
  }
879
- function at(i, e, t) {
880
- const n = Te(i, e), r = Te(i, t);
941
+ function ft(i, e, t) {
942
+ const n = De(i, e), r = De(i, t);
881
943
  if (!n || !r)
882
944
  return !0;
883
945
  const o = n.timestamp, s = r.timestamp;
884
946
  return typeof o != "number" || typeof s != "number" ? !0 : o >= s;
885
947
  }
886
- function Ie(i, e) {
887
- return i.isTypeOf(e, ke) ? i.nodeToSchemaOutput(e, ke) : i.isTypeOf(e, I) ? i.nodeToSchemaOutput(e, I) : null;
948
+ function Be(i, e) {
949
+ return i.isTypeOf(e, Ae) ? i.nodeToSchemaOutput(e, Ae) : i.isTypeOf(e, M) ? i.nodeToSchemaOutput(e, M) : null;
888
950
  }
889
- class Pn {
951
+ class er {
890
952
  kind = "channel";
891
- blueIds = [b["MyOS/MyOS Timeline Channel"]];
892
- schema = Xt;
953
+ blueIds = [I["MyOS/MyOS Timeline Channel"]];
954
+ schema = Sn;
893
955
  matches(e, t) {
894
956
  const { event: n, blue: r } = t;
895
957
  if (!n)
896
958
  return !1;
897
- const o = Ie(r, n);
959
+ const o = Be(r, n);
898
960
  if (!o)
899
961
  return !1;
900
962
  const s = o.timeline?.timelineId;
@@ -902,40 +964,40 @@ class Pn {
902
964
  }
903
965
  channelize(e, t) {
904
966
  const { event: n, blue: r } = t;
905
- return !n || !Ie(r, n) ? null : n.clone();
967
+ return !n || !Be(r, n) ? null : n.clone();
906
968
  }
907
969
  isNewerEvent(e, t, n) {
908
970
  const { event: r, blue: o } = t;
909
- return r ? at(o, r, n) : !0;
971
+ return r ? ft(o, r, n) : !0;
910
972
  }
911
973
  }
912
- class Mn {
974
+ class tr {
913
975
  kind = "channel";
914
- blueIds = [S["Conversation/Timeline Channel"]];
915
- schema = Qt;
976
+ blueIds = [w["Conversation/Timeline Channel"]];
977
+ schema = yn;
916
978
  matches(e, t) {
917
979
  const { event: n, blue: r } = t;
918
- if (!n || !r.isTypeOf(n, I))
980
+ if (!n || !r.isTypeOf(n, M))
919
981
  return !1;
920
- const s = r.nodeToSchemaOutput(n, I).timeline?.timelineId;
982
+ const s = r.nodeToSchemaOutput(n, M).timeline?.timelineId;
921
983
  return !(!s || !e.timelineId || s !== e.timelineId);
922
984
  }
923
985
  channelize(e, t) {
924
986
  const { event: n, blue: r } = t;
925
- return !n || !r.isTypeOf(n, I) ? null : n.clone();
987
+ return !n || !r.isTypeOf(n, M) ? null : n.clone();
926
988
  }
927
989
  isNewerEvent(e, t, n) {
928
990
  const { event: r, blue: o } = t;
929
- return r ? at(o, r, n) : !0;
991
+ return r ? ft(o, r, n) : !0;
930
992
  }
931
993
  }
932
- const Re = f(S["Conversation/Trigger Event"])(te.extend({
994
+ const xe = g(w["Conversation/Trigger Event"])(ie.extend({
933
995
  description: l.string().optional(),
934
- event: v().optional(),
996
+ event: b().optional(),
935
997
  name: l.string().optional()
936
998
  }));
937
- function me(i) {
938
- const { context: e, eventNode: t, stepResults: n } = i, r = On(e);
999
+ function ve(i) {
1000
+ const { context: e, eventNode: t, stepResults: n } = i, r = rr(e);
939
1001
  return {
940
1002
  event: e.blue.nodeToJson(t, "simple"),
941
1003
  eventCanonical: e.blue.nodeToJson(t, "official"),
@@ -943,94 +1005,99 @@ function me(i) {
943
1005
  document: r
944
1006
  };
945
1007
  }
946
- const Nn = /* @__PURE__ */ new Set(["blueId", "name", "description", "value"]);
947
- function On(i) {
1008
+ const nr = /* @__PURE__ */ new Set(["blueId", "name", "description", "value"]);
1009
+ function rr(i) {
948
1010
  const e = (o) => {
949
1011
  if (o === "/")
950
1012
  return !1;
951
1013
  const s = o.lastIndexOf("/"), a = o.substring(s + 1);
952
- return Nn.has(a);
1014
+ return nr.has(a);
953
1015
  }, t = (o) => {
954
1016
  const s = o == null ? "/" : typeof o == "string" ? o : (() => {
955
1017
  throw new TypeError("document() expects a string pointer");
956
- })(), a = s.startsWith("/") ? s : i.resolvePointer(s), c = T(a), u = i.documentAt(c);
1018
+ })(), a = s.startsWith("/") ? s : i.resolvePointer(s), c = R(a), u = i.documentAt(c);
957
1019
  return i.gasMeter().chargeDocumentSnapshot(c, u), { snapshot: u, normalizedPointer: c };
958
1020
  }, n = (o, s) => {
959
1021
  const { snapshot: a, normalizedPointer: c } = t(o);
960
1022
  if (a)
961
1023
  return e(c) ? i.blue.nodeToJson(a, "simple") : i.blue.nodeToJson(a, s);
962
- }, r = (o) => n(o, "simple");
1024
+ }, r = ((o) => n(o, "simple"));
963
1025
  return r.canonical = (o) => n(o, "official"), r;
964
1026
  }
965
- class An {
1027
+ class ir {
966
1028
  supportedBlueIds = [
967
- S["Conversation/Trigger Event"]
1029
+ w["Conversation/Trigger Event"]
968
1030
  ];
969
- evaluator = new pe();
1031
+ evaluator = new Ce();
970
1032
  async execute(e) {
971
1033
  const { stepNode: t, context: n } = e;
972
- if (!n.blue.isTypeOf(t, Re))
1034
+ if (!n.blue.isTypeOf(t, xe))
973
1035
  return n.throwFatal("Trigger Event step payload is invalid");
974
1036
  n.gasMeter().chargeTriggerEventBase();
975
- const r = await Q({
1037
+ const r = await Z({
976
1038
  evaluator: this.evaluator,
977
1039
  node: t,
978
- bindings: me(e),
979
- shouldResolve: tt({
1040
+ bindings: ve(e),
1041
+ shouldResolve: ct({
980
1042
  include: ["/event", "/event/**"]
981
1043
  }),
982
- shouldDescend: Dn(),
1044
+ shouldDescend: or(),
983
1045
  context: n
984
1046
  }), s = n.blue.nodeToSchemaOutput(
985
1047
  r,
986
- Re
1048
+ xe
987
1049
  ).event;
988
- if (ae(s))
1050
+ if (he(s))
989
1051
  return n.throwFatal(
990
1052
  "Trigger Event step must declare event payload"
991
1053
  );
992
1054
  n.emitEvent(s.clone());
993
1055
  }
994
1056
  }
995
- function Dn() {
996
- return (i, e) => i === "/event" || !i.startsWith("/event/") ? !0 : !Bn(e);
1057
+ function or() {
1058
+ return (i, e) => i === "/event" || !i.startsWith("/event/") ? !0 : !sr(e);
997
1059
  }
998
- function Bn(i) {
1060
+ function sr(i) {
999
1061
  const e = i.getProperties?.();
1000
1062
  return e ? !!e.contracts : !1;
1001
1063
  }
1002
- const Pe = f(S["Conversation/JavaScript Code"])(te.extend({
1064
+ const _e = g(w["Conversation/JavaScript Code"])(ie.extend({
1003
1065
  code: l.string().optional(),
1004
1066
  description: l.string().optional(),
1005
1067
  name: l.string().optional()
1006
1068
  }));
1007
- class Ln {
1069
+ class ar {
1008
1070
  supportedBlueIds = [
1009
- S["Conversation/JavaScript Code"]
1071
+ w["Conversation/JavaScript Code"]
1010
1072
  ];
1011
- evaluator = new pe();
1073
+ evaluator = new Ce();
1074
+ wasmGasLimit;
1075
+ constructor(e = {}) {
1076
+ this.wasmGasLimit = e.wasmGasLimit ?? it;
1077
+ }
1012
1078
  async execute(e) {
1013
1079
  const { context: t, stepNode: n } = e, { blue: r } = t;
1014
- if (!r.isTypeOf(n, Pe))
1080
+ if (!r.isTypeOf(n, _e))
1015
1081
  return t.throwFatal("JavaScript Code step payload is invalid");
1016
1082
  const s = r.nodeToSchemaOutput(
1017
1083
  n,
1018
- Pe
1084
+ _e
1019
1085
  ).code;
1020
1086
  if (!s)
1021
1087
  return t.throwFatal(
1022
1088
  "JavaScript Code step must include code to execute"
1023
1089
  );
1024
- t.gasMeter().chargeJavaScriptCodeBase(s);
1025
- const a = me(e);
1090
+ const a = ve(e);
1026
1091
  try {
1027
1092
  const c = await this.evaluator.evaluate({
1028
1093
  code: s,
1029
- bindings: a
1094
+ bindings: a,
1095
+ wasmGasLimit: this.wasmGasLimit,
1096
+ onWasmGasUsed: ({ used: u }) => t.gasMeter().chargeWasmGas(u)
1030
1097
  });
1031
1098
  return this.handleEvents(c, t), c;
1032
1099
  } catch (c) {
1033
- throw new Ye(s, c);
1100
+ throw new ot(s, c);
1034
1101
  }
1035
1102
  }
1036
1103
  handleEvents(e, t) {
@@ -1044,31 +1111,31 @@ class Ln {
1044
1111
  }
1045
1112
  }
1046
1113
  }
1047
- const xn = f(p["Core/Json Patch Entry"])(l.object({
1114
+ const cr = g(f["Core/Json Patch Entry"])(l.object({
1048
1115
  description: l.string().optional(),
1049
1116
  name: l.string().optional(),
1050
1117
  op: l.string().optional(),
1051
1118
  path: l.string().optional(),
1052
- val: v().optional()
1053
- })), Me = f(S["Conversation/Update Document"])(te.extend({
1054
- changeset: l.array(xn).optional(),
1119
+ val: b().optional()
1120
+ })), Le = g(w["Conversation/Update Document"])(ie.extend({
1121
+ changeset: l.array(cr).optional(),
1055
1122
  description: l.string().optional(),
1056
1123
  name: l.string().optional()
1057
1124
  }));
1058
- class _n {
1125
+ class lr {
1059
1126
  supportedBlueIds = [
1060
- S["Conversation/Update Document"]
1127
+ w["Conversation/Update Document"]
1061
1128
  ];
1062
- evaluator = new pe();
1129
+ evaluator = new Ce();
1063
1130
  async execute(e) {
1064
1131
  const { context: t, stepNode: n } = e, { blue: r } = t;
1065
- if (!r.isTypeOf(n, Me))
1132
+ if (!r.isTypeOf(n, Le))
1066
1133
  return t.throwFatal("Update Document step payload is invalid");
1067
- const o = await Q({
1134
+ const o = await Z({
1068
1135
  evaluator: this.evaluator,
1069
1136
  node: n,
1070
- bindings: me(e),
1071
- shouldResolve: tt({
1137
+ bindings: ve(e),
1138
+ shouldResolve: ct({
1072
1139
  include: ["/changeset", "/changeset/**"]
1073
1140
  }),
1074
1141
  context: t
@@ -1082,7 +1149,7 @@ class _n {
1082
1149
  extractChanges(e, t) {
1083
1150
  return t.blue.nodeToSchemaOutput(
1084
1151
  e,
1085
- Me
1152
+ Le
1086
1153
  ).changeset ?? [];
1087
1154
  }
1088
1155
  createPatch(e, t) {
@@ -1102,14 +1169,14 @@ class _n {
1102
1169
  return n.length === 0 ? t.throwFatal("Update Document path cannot be empty") : n;
1103
1170
  }
1104
1171
  }
1105
- const ge = [
1106
- new An(),
1107
- new Ln(),
1108
- new _n()
1172
+ const we = [
1173
+ new ir(),
1174
+ new ar(),
1175
+ new lr()
1109
1176
  ];
1110
- class ct {
1177
+ class gt {
1111
1178
  executorIndex;
1112
- constructor(e = ge) {
1179
+ constructor(e = we) {
1113
1180
  const t = /* @__PURE__ */ new Map();
1114
1181
  for (const n of e)
1115
1182
  for (const r of n.supportedBlueIds)
@@ -1123,28 +1190,28 @@ class ct {
1123
1190
  const s = {};
1124
1191
  for (const [a, c] of o.entries()) {
1125
1192
  const u = c.getType?.()?.getBlueId();
1126
- if (ae(u))
1193
+ if (he(u))
1127
1194
  return r.throwFatal(
1128
1195
  "Sequential workflow step is missing type metadata"
1129
1196
  );
1130
- const d = this.executorIndex.get(u);
1131
- if (ae(d)) {
1132
- const y = c.getType?.()?.getName?.() ?? u;
1197
+ const h = this.executorIndex.get(u);
1198
+ if (he(h)) {
1199
+ const m = c.getType?.()?.getName?.() ?? u;
1133
1200
  return r.throwFatal(
1134
- `Unsupported workflow step type "${y}"`
1201
+ `Unsupported workflow step type "${m}"`
1135
1202
  );
1136
1203
  }
1137
- const g = {
1204
+ const d = {
1138
1205
  workflow: t,
1139
1206
  stepNode: c,
1140
1207
  eventNode: n,
1141
1208
  context: r,
1142
1209
  stepResults: s,
1143
1210
  stepIndex: a
1144
- }, m = await d.execute(g);
1145
- if (m !== void 0) {
1146
- const y = this.stepResultKey(c, a);
1147
- s[y] = m;
1211
+ }, S = await h.execute(d);
1212
+ if (S !== void 0) {
1213
+ const m = this.stepResultKey(c, a);
1214
+ s[m] = S;
1148
1215
  }
1149
1216
  }
1150
1217
  return s;
@@ -1154,15 +1221,15 @@ class ct {
1154
1221
  return n && typeof n == "string" && n.length > 0 ? n : `Step${t + 1}`;
1155
1222
  }
1156
1223
  }
1157
- class Fn {
1224
+ class ur {
1158
1225
  kind = "handler";
1159
1226
  blueIds = [
1160
- S["Conversation/Sequential Workflow"]
1227
+ w["Conversation/Sequential Workflow"]
1161
1228
  ];
1162
- schema = Sn;
1229
+ schema = Hn;
1163
1230
  runner;
1164
- constructor(e = ge) {
1165
- this.runner = new ct(e);
1231
+ constructor(e = we) {
1232
+ this.runner = new gt(e);
1166
1233
  }
1167
1234
  async matches(e, t) {
1168
1235
  const n = t.event();
@@ -1173,20 +1240,20 @@ class Fn {
1173
1240
  n && await this.runner.run({ workflow: e, eventNode: n, context: t });
1174
1241
  }
1175
1242
  }
1176
- class Un {
1243
+ class hr {
1177
1244
  kind = "marker";
1178
- blueIds = [S["Conversation/Operation"]];
1179
- schema = cn;
1245
+ blueIds = [w["Conversation/Operation"]];
1246
+ schema = Nn;
1180
1247
  }
1181
- const le = f(S["Conversation/Operation Request"])(l.object({
1248
+ const me = g(w["Conversation/Operation Request"])(l.object({
1182
1249
  allowNewerVersion: l.boolean().optional(),
1183
1250
  description: l.string().optional(),
1184
- document: v().optional(),
1251
+ document: b().optional(),
1185
1252
  name: l.string().optional(),
1186
1253
  operation: l.string().optional(),
1187
- request: v().optional()
1254
+ request: b().optional()
1188
1255
  }));
1189
- function lt(i) {
1256
+ function Et(i) {
1190
1257
  const e = i.channel;
1191
1258
  if (typeof e == "string") {
1192
1259
  const t = e.trim();
@@ -1195,49 +1262,49 @@ function lt(i) {
1195
1262
  }
1196
1263
  return null;
1197
1264
  }
1198
- function zn(i, e) {
1265
+ function dr(i, e) {
1199
1266
  const t = i.getProperties()?.document;
1200
- return t instanceof h ? e.blue.calculateBlueIdSync(t) : null;
1267
+ return t instanceof p ? e.blue.calculateBlueIdSync(t) : null;
1201
1268
  }
1202
- function $n(i, e) {
1203
- if (e.isTypeOf(i, le, {
1269
+ function pr(i, e) {
1270
+ if (e.isTypeOf(i, me, {
1204
1271
  checkSchemaExtensions: !0
1205
1272
  }))
1206
1273
  return i;
1207
- if (e.isTypeOf(i, I, {
1274
+ if (e.isTypeOf(i, M, {
1208
1275
  checkSchemaExtensions: !0
1209
1276
  })) {
1210
- const n = e.nodeToSchemaOutput(i, I).message;
1211
- if (n && e.isTypeOf(n, le, {
1277
+ const n = e.nodeToSchemaOutput(i, M).message;
1278
+ if (n && e.isTypeOf(n, me, {
1212
1279
  checkSchemaExtensions: !0
1213
1280
  }))
1214
1281
  return n;
1215
1282
  }
1216
1283
  return null;
1217
1284
  }
1218
- function Hn(i, e, t, n) {
1285
+ function mr(i, e, t, n) {
1219
1286
  const { blue: r } = n, o = i.operation;
1220
1287
  return !(!o || t.operation !== o || i.event && !r.isTypeOfNode(e, i.event));
1221
1288
  }
1222
- function Vn(i, e) {
1289
+ function fr(i, e) {
1223
1290
  const t = i.operation;
1224
1291
  if (!t)
1225
1292
  return null;
1226
1293
  const n = e.resolvePointer(`/contracts/${t}`), r = e.documentAt(n);
1227
- if (!r || !e.blue.isTypeOf(r, W))
1294
+ if (!r || !e.blue.isTypeOf(r, j))
1228
1295
  return null;
1229
1296
  const o = e.blue.nodeToSchemaOutput(
1230
1297
  r,
1231
- W
1232
- ), s = lt(o);
1298
+ j
1299
+ ), s = Et(o);
1233
1300
  return { operationNode: r, operation: o, channelKey: s };
1234
1301
  }
1235
- function Wn(i, e) {
1302
+ function gr(i, e) {
1236
1303
  return !(i && e && i !== e);
1237
1304
  }
1238
- function Kn(i, e, t) {
1305
+ function Er(i, e, t) {
1239
1306
  const n = i.getProperties()?.request, r = e.getProperties()?.request;
1240
- if (!(n instanceof h) || !(r instanceof h))
1307
+ if (!(n instanceof p) || !(r instanceof p))
1241
1308
  return !1;
1242
1309
  try {
1243
1310
  if (!t.isTypeOfNode(n, r))
@@ -1247,10 +1314,10 @@ function Kn(i, e, t) {
1247
1314
  }
1248
1315
  return !0;
1249
1316
  }
1250
- function qn(i, e, t) {
1317
+ function yr(i, e, t) {
1251
1318
  if (!i || i.allowNewerVersion !== !1)
1252
1319
  return !0;
1253
- const n = zn(e, t);
1320
+ const n = dr(e, t);
1254
1321
  if (!n)
1255
1322
  return !0;
1256
1323
  const r = t.resolvePointer("/"), o = t.documentAt(r);
@@ -1259,33 +1326,33 @@ function qn(i, e, t) {
1259
1326
  const c = (o.getContracts()?.initialized ?? null)?.get("/documentId") ?? null, u = typeof c == "string" && c.length > 0 ? c : t.blue.calculateBlueIdSync(o);
1260
1327
  return n === u;
1261
1328
  }
1262
- class jn {
1329
+ class Cr {
1263
1330
  kind = "handler";
1264
1331
  blueIds = [
1265
- S["Conversation/Sequential Workflow Operation"]
1332
+ w["Conversation/Sequential Workflow Operation"]
1266
1333
  ];
1267
- schema = bn;
1334
+ schema = Wn;
1268
1335
  runner;
1269
- constructor(e = ge) {
1270
- this.runner = new ct(e);
1336
+ constructor(e = we) {
1337
+ this.runner = new gt(e);
1271
1338
  }
1272
1339
  deriveChannel(e, t) {
1273
1340
  const n = e.operation;
1274
1341
  if (!n)
1275
1342
  return null;
1276
1343
  const r = t.scopeContracts.get(n);
1277
- if (!r || !t.blue.isTypeOf(r.node, W, {
1344
+ if (!r || !t.blue.isTypeOf(r.node, j, {
1278
1345
  checkSchemaExtensions: !0
1279
1346
  }))
1280
1347
  return null;
1281
- const o = t.blue.nodeToSchemaOutput(r.node, W);
1282
- return o ? lt(o) : null;
1348
+ const o = t.blue.nodeToSchemaOutput(r.node, j);
1349
+ return o ? Et(o) : null;
1283
1350
  }
1284
1351
  async matches(e, t) {
1285
1352
  const n = t.event();
1286
1353
  if (!n)
1287
1354
  return !1;
1288
- const r = $n(
1355
+ const r = pr(
1289
1356
  n,
1290
1357
  t.blue
1291
1358
  );
@@ -1293,19 +1360,19 @@ class jn {
1293
1360
  return !1;
1294
1361
  const o = t.blue.nodeToSchemaOutput(
1295
1362
  r,
1296
- le
1363
+ me
1297
1364
  );
1298
- if (!o || !Hn(e, n, o, t))
1365
+ if (!o || !mr(e, n, o, t))
1299
1366
  return !1;
1300
- const s = Vn(e, t);
1367
+ const s = fr(e, t);
1301
1368
  if (!s)
1302
1369
  return !1;
1303
1370
  const a = typeof e.channel == "string" ? e.channel.trim() : "", c = a.length > 0 ? a : null;
1304
- return !(!Wn(s.channelKey, c) || !Kn(
1371
+ return !(!gr(s.channelKey, c) || !Er(
1305
1372
  r,
1306
1373
  s.operationNode,
1307
1374
  t.blue
1308
- ) || o?.allowNewerVersion === !1 && !qn(o, r, t));
1375
+ ) || o?.allowNewerVersion === !1 && !yr(o, r, t));
1309
1376
  }
1310
1377
  async execute(e, t) {
1311
1378
  const n = t.event();
@@ -1316,17 +1383,17 @@ class jn {
1316
1383
  });
1317
1384
  }
1318
1385
  }
1319
- class ne {
1386
+ class oe {
1320
1387
  constructor(e) {
1321
1388
  this.registry = e;
1322
1389
  }
1323
1390
  static create() {
1324
- return new ne(
1325
- new Tn()
1391
+ return new oe(
1392
+ new qn()
1326
1393
  );
1327
1394
  }
1328
1395
  registerDefaults() {
1329
- return this.registry.register(new Pn()), this.registry.register(new Mn()), this.registry.register(new Fn()), this.registry.register(new Un()), this.registry.register(new jn()), this;
1396
+ return this.registry.register(new Xn()), this.registry.register(new er()), this.registry.register(new tr()), this.registry.register(new ur()), this.registry.register(new hr()), this.registry.register(new Cr()), this;
1330
1397
  }
1331
1398
  register(e) {
1332
1399
  return this.registry.register(e), this;
@@ -1335,11 +1402,11 @@ class ne {
1335
1402
  return this.registry;
1336
1403
  }
1337
1404
  }
1338
- const ue = p["Core/Channel Event Checkpoint"];
1339
- function ut(i) {
1405
+ const fe = f["Core/Channel Event Checkpoint"];
1406
+ function yt(i) {
1340
1407
  return typeof i.order == "number" ? i.order : 0;
1341
1408
  }
1342
- class Jn {
1409
+ class Sr {
1343
1410
  constructor(e, t, n) {
1344
1411
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1345
1412
  }
@@ -1353,10 +1420,10 @@ class Jn {
1353
1420
  return this.bindingBlueId;
1354
1421
  }
1355
1422
  order() {
1356
- return ut(this.bindingContract);
1423
+ return yt(this.bindingContract);
1357
1424
  }
1358
1425
  }
1359
- class Gn {
1426
+ class vr {
1360
1427
  constructor(e, t, n) {
1361
1428
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1362
1429
  }
@@ -1370,16 +1437,16 @@ class Gn {
1370
1437
  return this.bindingBlueId;
1371
1438
  }
1372
1439
  order() {
1373
- return ut(this.bindingContract);
1440
+ return yt(this.bindingContract);
1374
1441
  }
1375
1442
  }
1376
- class L {
1443
+ class V {
1377
1444
  constructor(e, t, n, r, o) {
1378
1445
  this.channels = e, this.handlersByChannel = t, this.markerStore = n, this.embeddedPathsInternal = r, this.checkpointDeclared = o;
1379
1446
  }
1380
1447
  checkpointDeclared;
1381
1448
  static fromComponents(e, t, n, r, o) {
1382
- return new L(
1449
+ return new V(
1383
1450
  e,
1384
1451
  t,
1385
1452
  n,
@@ -1388,10 +1455,10 @@ class L {
1388
1455
  );
1389
1456
  }
1390
1457
  static builder() {
1391
- return new Qn();
1458
+ return new wr();
1392
1459
  }
1393
1460
  static empty() {
1394
- return L.builder().build();
1461
+ return V.builder().build();
1395
1462
  }
1396
1463
  markers() {
1397
1464
  return new Map(
@@ -1421,24 +1488,28 @@ class L {
1421
1488
  throw new Error(
1422
1489
  "Duplicate Channel Event Checkpoint markers detected in same contracts map"
1423
1490
  );
1424
- this.markerStore.set(N, {
1425
- key: N,
1491
+ this.markerStore.set(A, {
1492
+ key: A,
1426
1493
  contract: e,
1427
- blueId: ue
1494
+ blueId: fe
1428
1495
  }), this.checkpointDeclared = !0;
1429
1496
  }
1430
1497
  handlersFor(e) {
1431
1498
  const t = this.handlersByChannel.get(e);
1432
1499
  return !t || t.length === 0 ? [] : [...t].map(
1433
- (n) => new Gn(n.key, n.contract, n.blueId)
1500
+ (n) => new vr(n.key, n.contract, n.blueId)
1434
1501
  ).sort((n, r) => {
1435
1502
  const o = n.order() - r.order();
1436
1503
  return o !== 0 ? o : n.key().localeCompare(r.key());
1437
1504
  });
1438
1505
  }
1506
+ channelEntry(e) {
1507
+ const t = this.channels.get(e);
1508
+ return t ? { key: t.key, contract: t.contract, blueId: t.blueId } : null;
1509
+ }
1439
1510
  channelsOfType(...e) {
1440
1511
  const t = e.length > 0 ? new Set(e) : null, n = Array.from(this.channels.values()).filter((r) => !t || t.has(r.blueId)).map(
1441
- (r) => new Jn(r.key, r.contract, r.blueId)
1512
+ (r) => new Sr(r.key, r.contract, r.blueId)
1442
1513
  );
1443
1514
  return n.sort((r, o) => {
1444
1515
  const s = r.order() - o.order();
@@ -1446,7 +1517,7 @@ class L {
1446
1517
  }), n;
1447
1518
  }
1448
1519
  }
1449
- class Qn {
1520
+ class wr {
1450
1521
  channels = /* @__PURE__ */ new Map();
1451
1522
  handlersByChannel = /* @__PURE__ */ new Map();
1452
1523
  markerStore = /* @__PURE__ */ new Map();
@@ -1471,12 +1542,12 @@ class Qn {
1471
1542
  return this.embeddedDeclared = !0, this.embeddedPaths = e.paths ? [...e.paths] : [], this;
1472
1543
  }
1473
1544
  addMarker(e, t, n) {
1474
- if (e === N && n !== ue)
1545
+ if (e === A && n !== fe)
1475
1546
  throw new Error(
1476
1547
  "Reserved key 'checkpoint' must contain a Channel Event Checkpoint"
1477
1548
  );
1478
- if (n === ue) {
1479
- if (e !== N)
1549
+ if (n === fe) {
1550
+ if (e !== A)
1480
1551
  throw new Error(
1481
1552
  `Channel Event Checkpoint must use reserved key 'checkpoint' at key '${e}'`
1482
1553
  );
@@ -1489,7 +1560,7 @@ class Qn {
1489
1560
  return this.markerStore.set(e, { key: e, contract: t, blueId: n }), this;
1490
1561
  }
1491
1562
  build() {
1492
- return L.fromComponents(
1563
+ return V.fromComponents(
1493
1564
  new Map(this.channels),
1494
1565
  new Map(
1495
1566
  Array.from(this.handlersByChannel.entries(), ([e, t]) => [
@@ -1503,12 +1574,12 @@ class Qn {
1503
1574
  );
1504
1575
  }
1505
1576
  }
1506
- class E extends Error {
1577
+ class y extends Error {
1507
1578
  constructor(e, t) {
1508
1579
  super(e || "Processor fatal error"), this.processorError = t, this.name = "ProcessorFatalError";
1509
1580
  }
1510
1581
  }
1511
- class Yn {
1582
+ class kr {
1512
1583
  constructor(e, t, n) {
1513
1584
  this.blue = e, this.registry = t, this.builtinChannelSchemas = n;
1514
1585
  }
@@ -1529,21 +1600,21 @@ class Yn {
1529
1600
  processor: r,
1530
1601
  scopeContracts: s,
1531
1602
  handlerKey: t
1532
- }), d = s.get(u);
1533
- if (!d)
1534
- throw new E(
1603
+ }), h = s.get(u);
1604
+ if (!h)
1605
+ throw new y(
1535
1606
  `Handler ${t} references unknown channel '${u}'`,
1536
- w.invalidContract(
1607
+ v.invalidContract(
1537
1608
  o,
1538
1609
  `Channel '${u}' is not declared in this scope`,
1539
1610
  `/contracts/${u}`
1540
1611
  )
1541
1612
  );
1542
- if (!this.isRegisteredChannel(d.nodeTypeBlueId))
1543
- throw new E(
1613
+ if (!this.isRegisteredChannel(h.nodeTypeBlueId))
1614
+ throw new y(
1544
1615
  `Contract '${u}' is not a channel`,
1545
- w.invalidContract(
1546
- d.nodeTypeBlueId,
1616
+ v.invalidContract(
1617
+ h.nodeTypeBlueId,
1547
1618
  `Contract '${u}' is not a channel`,
1548
1619
  `/contracts/${u}`
1549
1620
  )
@@ -1551,9 +1622,9 @@ class Yn {
1551
1622
  e.addHandler(t, { ...c, channel: u }, o);
1552
1623
  } catch (a) {
1553
1624
  if (this.isZodError(a))
1554
- throw new E(
1625
+ throw new y(
1555
1626
  "Failed to parse handler contract",
1556
- w.invalidContract(
1627
+ v.invalidContract(
1557
1628
  o,
1558
1629
  "Failed to parse handler contract",
1559
1630
  t,
@@ -1561,9 +1632,9 @@ class Yn {
1561
1632
  )
1562
1633
  );
1563
1634
  const c = a?.message ?? "Failed to register handler contract";
1564
- throw new E(
1635
+ throw new y(
1565
1636
  c,
1566
- w.illegalState(c)
1637
+ v.illegalState(c)
1567
1638
  );
1568
1639
  }
1569
1640
  }
@@ -1585,9 +1656,9 @@ class Yn {
1585
1656
  }
1586
1657
  }
1587
1658
  if (!o)
1588
- throw new E(
1659
+ throw new y(
1589
1660
  `Handler ${r} must declare channel (missing explicit channel and derivation failed)`,
1590
- w.illegalState(
1661
+ v.illegalState(
1591
1662
  `Handler ${r} must declare channel (missing explicit channel and derivation failed)`
1592
1663
  )
1593
1664
  );
@@ -1597,77 +1668,144 @@ class Yn {
1597
1668
  return this.builtinChannelSchemas.has(e) ? !0 : this.registry.lookupChannel(e) != null;
1598
1669
  }
1599
1670
  isZodError(e) {
1600
- return e instanceof xe;
1671
+ return e instanceof ge;
1601
1672
  }
1602
1673
  }
1603
- class K extends Error {
1674
+ class z extends Error {
1604
1675
  constructor(e) {
1605
1676
  super(e ?? "MustUnderstand failure"), this.name = "MustUnderstandFailure";
1606
1677
  }
1607
1678
  }
1608
- const Xn = p["Core/Document Update Channel"], Zn = p["Core/Embedded Node Channel"], er = p["Core/Lifecycle Event Channel"], tr = p["Core/Triggered Event Channel"], Ne = p["Core/Process Embedded"], nr = p["Core/Processing Initialized Marker"], rr = p["Core/Processing Terminated Marker"], ir = p["Core/Channel Event Checkpoint"], or = b["MyOS/Document Anchors"], sr = b["MyOS/Document Links"], ar = b["MyOS/MyOS Participants Orchestration"], cr = b["MyOS/MyOS Session Interaction"], lr = b["MyOS/MyOS Worker Agency"], Oe = /* @__PURE__ */ new Map([
1679
+ function br(i) {
1680
+ const {
1681
+ compositeKey: e,
1682
+ contract: t,
1683
+ scopeContracts: n,
1684
+ blueId: r,
1685
+ blue: o,
1686
+ compositeChannelBlueId: s
1687
+ } = i, a = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), u = [], h = /* @__PURE__ */ new Map([
1688
+ [e, t]
1689
+ ]), d = (m) => {
1690
+ if (h.has(m))
1691
+ return h.get(m) ?? null;
1692
+ const E = n.get(m);
1693
+ if (!E || E.nodeTypeBlueId !== s)
1694
+ return h.set(m, null), null;
1695
+ try {
1696
+ const C = o.nodeToSchemaOutput(
1697
+ E.node,
1698
+ dt
1699
+ );
1700
+ return h.set(m, C), C;
1701
+ } catch (C) {
1702
+ if (Ir(C))
1703
+ throw new y(
1704
+ "Failed to parse channel contract",
1705
+ v.invalidContract(
1706
+ E.nodeTypeBlueId,
1707
+ "Failed to parse channel contract",
1708
+ `/contracts/${m}`,
1709
+ C
1710
+ )
1711
+ );
1712
+ const P = C?.message ?? "Failed to parse channel contract";
1713
+ throw new y(
1714
+ P,
1715
+ v.illegalState(P)
1716
+ );
1717
+ }
1718
+ }, S = (m) => {
1719
+ if (c.has(m)) {
1720
+ const C = u.indexOf(m), D = [...u.slice(C), m].join(" -> ");
1721
+ throw new y(
1722
+ `Composite channel ${e} has a cyclic reference: ${D}`,
1723
+ v.invalidContract(
1724
+ r,
1725
+ `Composite channel '${e}' has a cyclic reference: ${D}`,
1726
+ `/contracts/${e}`
1727
+ )
1728
+ );
1729
+ }
1730
+ if (a.has(m))
1731
+ return;
1732
+ c.add(m), u.push(m);
1733
+ const E = d(m);
1734
+ if (E)
1735
+ for (const C of E.channels ?? []) {
1736
+ const P = n.get(C);
1737
+ P && P.nodeTypeBlueId === s && S(C);
1738
+ }
1739
+ u.pop(), c.delete(m), a.add(m);
1740
+ };
1741
+ S(e);
1742
+ }
1743
+ function Ir(i) {
1744
+ return i instanceof ge;
1745
+ }
1746
+ const Tr = f["Core/Document Update Channel"], Rr = f["Core/Embedded Node Channel"], Pr = f["Core/Lifecycle Event Channel"], Mr = f["Core/Triggered Event Channel"], Fe = f["Core/Process Embedded"], Nr = f["Core/Processing Initialized Marker"], Or = f["Core/Processing Terminated Marker"], Ar = f["Core/Channel Event Checkpoint"], Dr = I["MyOS/Document Anchors"], Br = I["MyOS/Document Links"], xr = I["MyOS/MyOS Participants Orchestration"], _r = I["MyOS/MyOS Session Interaction"], Lr = I["MyOS/MyOS Worker Agency"], Ue = w["Conversation/Composite Timeline Channel"], ce = /* @__PURE__ */ new Map([
1609
1747
  [
1610
- Xn,
1611
- Vt
1748
+ Tr,
1749
+ hn
1612
1750
  ],
1613
1751
  [
1614
- Zn,
1615
- Kt
1752
+ Rr,
1753
+ pn
1616
1754
  ],
1617
1755
  [
1618
- er,
1619
- jt
1756
+ Pr,
1757
+ fn
1620
1758
  ],
1621
1759
  [
1622
- tr,
1623
- Gt
1760
+ Mr,
1761
+ En
1624
1762
  ]
1625
- ]), ur = /* @__PURE__ */ new Map([
1763
+ ]), Fr = /* @__PURE__ */ new Map([
1626
1764
  [
1627
- nr,
1628
- nn
1765
+ Nr,
1766
+ In
1629
1767
  ],
1630
1768
  [
1631
- rr,
1632
- an
1769
+ Or,
1770
+ Mn
1633
1771
  ],
1634
1772
  [
1635
- ir,
1636
- en
1773
+ Ar,
1774
+ kn
1637
1775
  ],
1638
1776
  [
1639
- or,
1640
- dn
1777
+ Dr,
1778
+ Dn
1641
1779
  ],
1642
1780
  [
1643
- sr,
1644
- fn
1781
+ Br,
1782
+ _n
1645
1783
  ],
1646
1784
  [
1647
- ar,
1648
- gn
1785
+ xr,
1786
+ Fn
1649
1787
  ],
1650
1788
  [
1651
- cr,
1652
- En
1789
+ _r,
1790
+ $n
1653
1791
  ],
1654
1792
  [
1655
- lr,
1656
- Cn
1793
+ Lr,
1794
+ Vn
1657
1795
  ]
1658
1796
  ]);
1659
- class dr {
1797
+ class Ur {
1660
1798
  constructor(e, t) {
1661
- this.registry = e, this.blue = t, this.handlerRegistration = new Yn(
1799
+ this.registry = e, this.blue = t, this.handlerRegistration = new kr(
1662
1800
  this.blue,
1663
1801
  this.registry,
1664
- Oe
1802
+ ce
1665
1803
  );
1666
1804
  }
1667
1805
  handlerRegistration;
1668
1806
  load(e, t) {
1669
1807
  try {
1670
- const n = L.builder(), r = e.getContracts();
1808
+ const n = V.builder(), r = e.getContracts();
1671
1809
  if (!r)
1672
1810
  return n.build();
1673
1811
  const o = this.buildScopeContractsIndex(r);
@@ -1675,12 +1813,12 @@ class dr {
1675
1813
  a && this.processContract(n, s, a, o);
1676
1814
  return n.build();
1677
1815
  } catch (n) {
1678
- if (n instanceof K || n instanceof E)
1816
+ if (n instanceof z || n instanceof y)
1679
1817
  throw n;
1680
1818
  const r = n?.message ?? "Failed to load contracts";
1681
- throw new E(
1819
+ throw new y(
1682
1820
  `Failed to load contracts for scope ${t}: ${r}`,
1683
- w.runtimeFatal(
1821
+ v.runtimeFatal(
1684
1822
  `Failed to load contracts for scope ${t}`,
1685
1823
  n
1686
1824
  )
@@ -1691,18 +1829,25 @@ class dr {
1691
1829
  const o = n.getType()?.getBlueId();
1692
1830
  if (!o)
1693
1831
  return;
1694
- if (o === Ne) {
1832
+ if (o === Fe) {
1695
1833
  this.handleProcessEmbedded(e, t, n);
1696
1834
  return;
1697
1835
  }
1698
- const s = ur.get(o);
1836
+ const s = Fr.get(o);
1699
1837
  if (s) {
1700
1838
  this.handleMarker(e, t, n, s, o);
1701
1839
  return;
1702
1840
  }
1703
- const a = Oe.get(o);
1841
+ const a = ce.get(o);
1704
1842
  if (a) {
1705
- this.handleChannel(e, t, n, a, o);
1843
+ this.handleChannel(
1844
+ e,
1845
+ t,
1846
+ n,
1847
+ a,
1848
+ o,
1849
+ r
1850
+ );
1706
1851
  return;
1707
1852
  }
1708
1853
  const c = this.registry.lookupChannel(o);
@@ -1712,7 +1857,8 @@ class dr {
1712
1857
  t,
1713
1858
  n,
1714
1859
  c.schema,
1715
- o
1860
+ o,
1861
+ r
1716
1862
  );
1717
1863
  return;
1718
1864
  }
@@ -1728,81 +1874,131 @@ class dr {
1728
1874
  });
1729
1875
  return;
1730
1876
  }
1731
- const d = this.registry.lookupMarker(o);
1732
- if (d) {
1877
+ const h = this.registry.lookupMarker(o);
1878
+ if (h) {
1733
1879
  this.handleMarker(
1734
1880
  e,
1735
1881
  t,
1736
1882
  n,
1737
- d.schema,
1883
+ h.schema,
1738
1884
  o
1739
1885
  );
1740
1886
  return;
1741
1887
  }
1742
- throw he(o) ? new E(
1888
+ throw ye(o) ? new y(
1743
1889
  "Built-in processor-managed channel is missing schema registration",
1744
- w.invalidContract(
1890
+ v.invalidContract(
1745
1891
  o,
1746
1892
  "Built-in processor-managed channel is missing schema registration",
1747
1893
  t
1748
1894
  )
1749
- ) : new K(`Unsupported contract type: ${o}`);
1895
+ ) : new z(`Unsupported contract type: ${o}`);
1750
1896
  }
1751
1897
  handleProcessEmbedded(e, t, n) {
1752
1898
  try {
1753
- const r = this.convert(
1899
+ const r = this.blue.nodeToSchemaOutput(
1754
1900
  n,
1755
- on
1901
+ Rn
1756
1902
  );
1757
1903
  e.setEmbedded(r);
1758
1904
  } catch (r) {
1759
- throw oe(r) ? new E(
1905
+ throw le(r) ? new y(
1760
1906
  "Failed to parse ProcessEmbedded marker",
1761
- w.invalidContract(
1762
- Ne,
1907
+ v.invalidContract(
1908
+ Fe,
1763
1909
  "Failed to parse ProcessEmbedded marker",
1764
1910
  t,
1765
1911
  r
1766
1912
  )
1767
- ) : new E(
1913
+ ) : new y(
1768
1914
  r?.message ?? "Failed to register ProcessEmbedded marker",
1769
- w.illegalState(
1915
+ v.illegalState(
1770
1916
  r?.message ?? "Failed to register ProcessEmbedded marker"
1771
1917
  )
1772
1918
  );
1773
1919
  }
1774
1920
  }
1775
- handleChannel(e, t, n, r, o) {
1921
+ handleChannel(e, t, n, r, o, s) {
1776
1922
  try {
1777
- const s = this.convert(n, r);
1778
- e.addChannel(t, s, o);
1779
- } catch (s) {
1780
- if (oe(s))
1781
- throw new E(
1923
+ const a = this.blue.nodeToSchemaOutput(
1924
+ n,
1925
+ r
1926
+ );
1927
+ o === Ue && this.validateCompositeChannel(
1928
+ t,
1929
+ a,
1930
+ s,
1931
+ o
1932
+ ), e.addChannel(t, a, o);
1933
+ } catch (a) {
1934
+ if (a instanceof y || a instanceof z)
1935
+ throw a;
1936
+ if (le(a))
1937
+ throw new y(
1782
1938
  "Failed to parse channel contract",
1783
- w.invalidContract(
1939
+ v.invalidContract(
1784
1940
  o,
1785
1941
  "Failed to parse channel contract",
1786
1942
  t,
1787
- s
1943
+ a
1788
1944
  )
1789
1945
  );
1790
- const a = s?.message ?? "Failed to register channel contract";
1791
- throw new E(
1792
- a,
1793
- w.illegalState(a)
1946
+ const c = a?.message ?? "Failed to register channel contract";
1947
+ throw new y(
1948
+ c,
1949
+ v.illegalState(c)
1794
1950
  );
1795
1951
  }
1796
1952
  }
1953
+ validateCompositeChannel(e, t, n, r) {
1954
+ const o = t.channels ?? [];
1955
+ if (o.length !== 0) {
1956
+ for (const s of o) {
1957
+ const a = n.get(s);
1958
+ if (!a)
1959
+ throw new y(
1960
+ `Composite channel ${e} references unknown channel '${s}'`,
1961
+ v.invalidContract(
1962
+ r,
1963
+ `Channel '${s}' is not declared in this scope`,
1964
+ `/contracts/${s}`
1965
+ )
1966
+ );
1967
+ if (!this.isRegisteredChannel(a.nodeTypeBlueId))
1968
+ throw new y(
1969
+ `Contract '${s}' is not a channel`,
1970
+ v.invalidContract(
1971
+ a.nodeTypeBlueId,
1972
+ `Contract '${s}' is not a channel`,
1973
+ `/contracts/${s}`
1974
+ )
1975
+ );
1976
+ }
1977
+ br({
1978
+ compositeKey: e,
1979
+ contract: t,
1980
+ scopeContracts: n,
1981
+ blueId: r,
1982
+ blue: this.blue,
1983
+ compositeChannelBlueId: Ue
1984
+ });
1985
+ }
1986
+ }
1987
+ isRegisteredChannel(e) {
1988
+ return ce.has(e) ? !0 : this.registry.lookupChannel(e) != null;
1989
+ }
1797
1990
  handleMarker(e, t, n, r, o) {
1798
1991
  try {
1799
- const s = this.convert(n, r);
1992
+ const s = this.blue.nodeToSchemaOutput(
1993
+ n,
1994
+ r
1995
+ );
1800
1996
  e.addMarker(t, s, o);
1801
1997
  } catch (s) {
1802
- if (oe(s))
1803
- throw new E(
1998
+ if (le(s))
1999
+ throw new y(
1804
2000
  "Failed to parse marker contract",
1805
- w.invalidContract(
2001
+ v.invalidContract(
1806
2002
  o,
1807
2003
  "Failed to parse marker contract",
1808
2004
  t,
@@ -1810,9 +2006,9 @@ class dr {
1810
2006
  )
1811
2007
  );
1812
2008
  const a = s?.message ?? "Failed to register marker contract";
1813
- throw new E(
2009
+ throw new y(
1814
2010
  a,
1815
- w.illegalState(a)
2011
+ v.illegalState(a)
1816
2012
  );
1817
2013
  }
1818
2014
  }
@@ -1826,31 +2022,28 @@ class dr {
1826
2022
  }
1827
2023
  return t;
1828
2024
  }
1829
- convert(e, t) {
1830
- return this.blue.nodeToSchemaOutput(e, t);
1831
- }
1832
2025
  }
1833
- function oe(i) {
1834
- return i instanceof xe;
2026
+ function le(i) {
2027
+ return i instanceof ge;
1835
2028
  }
1836
- const hr = p["Core/Channel Event Checkpoint"];
1837
- function pr(i) {
2029
+ const $r = f["Core/Channel Event Checkpoint"];
2030
+ function zr(i) {
1838
2031
  return i.jsonValueToNode({
1839
- type: { blueId: hr },
2032
+ type: { blueId: $r },
1840
2033
  lastEvents: {},
1841
2034
  lastSignatures: {}
1842
2035
  });
1843
2036
  }
1844
- function fr() {
2037
+ function Vr() {
1845
2038
  return {
1846
2039
  lastEvents: {},
1847
2040
  lastSignatures: {}
1848
2041
  };
1849
2042
  }
1850
- function Ae(i) {
2043
+ function $e(i) {
1851
2044
  return i != null && Object.prototype.hasOwnProperty.call(i, "lastEvents") && Object.prototype.hasOwnProperty.call(i, "lastSignatures");
1852
2045
  }
1853
- class mr {
2046
+ class Hr {
1854
2047
  constructor(e, t, n, r, o) {
1855
2048
  this.markerKey = e, this.checkpoint = t, this.channelKey = n, this.lastEventNode = r, this.lastEventSignature = o;
1856
2049
  }
@@ -1860,28 +2053,28 @@ class mr {
1860
2053
  return e != null && e === this.lastEventSignature;
1861
2054
  }
1862
2055
  }
1863
- class gr {
2056
+ class Kr {
1864
2057
  constructor(e, t) {
1865
2058
  this.runtime = e, this.signatureFn = t;
1866
2059
  }
1867
2060
  ensureCheckpointMarker(e, t) {
1868
- const n = t.marker(N), r = k(e, Ve);
2061
+ const n = t.marker(A), r = T(e, Qe);
1869
2062
  if (!n) {
1870
- const o = pr(this.runtime.blue());
1871
- this.runtime.directWrite(r, o), t.registerCheckpointMarker(fr());
2063
+ const o = zr(this.runtime.blue());
2064
+ this.runtime.directWrite(r, o), t.registerCheckpointMarker(Vr());
1872
2065
  return;
1873
2066
  }
1874
- if (!Ae(n))
2067
+ if (!$e(n))
1875
2068
  throw new Error(
1876
2069
  `Reserved key 'checkpoint' must contain a Channel Event Checkpoint at ${r}`
1877
2070
  );
1878
2071
  }
1879
2072
  findCheckpoint(e, t) {
1880
2073
  for (const [n, r] of e.markerEntries()) {
1881
- if (!Ae(r))
2074
+ if (!$e(r))
1882
2075
  continue;
1883
2076
  const s = (r.lastEvents?.[t] ?? null)?.clone() ?? null, c = r.lastSignatures?.[t] ?? null ?? this.signatureFn(s);
1884
- return new mr(
2077
+ return new Hr(
1885
2078
  n,
1886
2079
  r,
1887
2080
  t,
@@ -1897,19 +2090,19 @@ class gr {
1897
2090
  persist(e, t, n, r, o) {
1898
2091
  if (!n)
1899
2092
  return;
1900
- const s = k(
2093
+ const s = T(
1901
2094
  e,
1902
- qe(n.markerKey, n.channelKey)
2095
+ Ze(n.markerKey, n.channelKey)
1903
2096
  ), a = o?.clone() ?? null;
1904
2097
  this.runtime.gasMeter().chargeCheckpointUpdate(), this.runtime.directWrite(s, a), n.checkpoint.lastEvents || (n.checkpoint.lastEvents = {}), a ? n.checkpoint.lastEvents[n.channelKey] = a.clone() ?? null : delete n.checkpoint.lastEvents[n.channelKey], n.lastEventNode = a?.clone() ?? null;
1905
- const c = k(
2098
+ const c = T(
1906
2099
  e,
1907
- je(n.markerKey, n.channelKey)
1908
- ), u = r == null ? null : new h().setValue(r);
2100
+ et(n.markerKey, n.channelKey)
2101
+ ), u = r == null ? null : new p().setValue(r);
1909
2102
  this.runtime.directWrite(c, u), n.checkpoint.lastSignatures || (n.checkpoint.lastSignatures = {}), r == null ? delete n.checkpoint.lastSignatures[n.channelKey] : n.checkpoint.lastSignatures[n.channelKey] = r, n.lastEventSignature = r ?? null;
1910
2103
  }
1911
2104
  }
1912
- class yr {
2105
+ class Wr {
1913
2106
  constructor(e, t, n) {
1914
2107
  this.runtime = e, this.checkpointManager = t, this.deps = n;
1915
2108
  }
@@ -1925,6 +2118,10 @@ class yr {
1925
2118
  );
1926
2119
  if (!s.matches)
1927
2120
  return;
2121
+ if (s.deliveries && s.deliveries.length > 0) {
2122
+ await this.runDeliveries(e, t, n, r, s);
2123
+ return;
2124
+ }
1928
2125
  const a = s.eventNode ?? r;
1929
2126
  this.checkpointManager.ensureCheckpointMarker(e, t);
1930
2127
  const c = this.checkpointManager.findCheckpoint(
@@ -1951,6 +2148,44 @@ class yr {
1951
2148
  o
1952
2149
  ));
1953
2150
  }
2151
+ async runDeliveries(e, t, n, r, o) {
2152
+ const s = o.deliveries ?? [];
2153
+ if (s.length === 0)
2154
+ return;
2155
+ this.checkpointManager.ensureCheckpointMarker(e, t);
2156
+ const a = this.deps.canonicalSignature(r);
2157
+ for (const c of s) {
2158
+ if (this.deps.isScopeInactive(e))
2159
+ return;
2160
+ const u = c.checkpointKey ?? n.key(), h = this.checkpointManager.findCheckpoint(
2161
+ t,
2162
+ u
2163
+ ), d = c.eventId ?? a;
2164
+ if (!(this.checkpointManager.isDuplicate(h, d) || !(typeof c.shouldProcess == "boolean" ? c.shouldProcess : await this.shouldProcessRelativeToCheckpoint(
2165
+ e,
2166
+ t,
2167
+ n,
2168
+ r,
2169
+ h
2170
+ )))) {
2171
+ if (await this.runHandlers(
2172
+ e,
2173
+ t,
2174
+ n.key(),
2175
+ c.eventNode,
2176
+ !1
2177
+ ), this.deps.isScopeInactive(e))
2178
+ return;
2179
+ this.checkpointManager.persist(
2180
+ e,
2181
+ t,
2182
+ h,
2183
+ d ?? null,
2184
+ r
2185
+ );
2186
+ }
2187
+ }
2188
+ }
1954
2189
  async runHandlers(e, t, n, r, o) {
1955
2190
  const s = t.handlersFor(n);
1956
2191
  if (s.length !== 0)
@@ -1994,21 +2229,21 @@ class yr {
1994
2229
  );
1995
2230
  }
1996
2231
  }
1997
- function Er(i, e) {
2232
+ function Gr(i, e) {
1998
2233
  return e.isResolved() ? i.createResolvedNode(e) : i.resolve(e);
1999
2234
  }
2000
- class B extends E {
2235
+ class $ extends y {
2001
2236
  constructor(e) {
2002
- super(e, w.illegalState(e)), this.name = "IllegalStateException";
2237
+ super(e, v.illegalState(e)), this.name = "IllegalStateException";
2003
2238
  }
2004
2239
  }
2005
- class A extends Error {
2240
+ class F extends Error {
2006
2241
  constructor(e) {
2007
2242
  super(e), this.name = "BoundaryViolationException";
2008
2243
  }
2009
2244
  }
2010
- const wr = p["Core/Document Update Channel"], Cr = p["Core/Embedded Node Channel"], Sr = p["Core/Triggered Event Channel"], vr = p["Core/Lifecycle Event Channel"], De = p["Core/Processing Initialized Marker"], br = p["Core/Document Processing Initiated"];
2011
- class kr {
2245
+ const qr = f["Core/Document Update Channel"], jr = f["Core/Embedded Node Channel"], Jr = f["Core/Triggered Event Channel"], Qr = f["Core/Lifecycle Event Channel"], ze = f["Core/Processing Initialized Marker"], Xr = f["Core/Document Processing Initiated"];
2246
+ class Yr {
2012
2247
  runtime;
2013
2248
  contractLoader;
2014
2249
  channelRunner;
@@ -2022,56 +2257,56 @@ class kr {
2022
2257
  this.runtime = e.runtime, this.contractLoader = e.contractLoader, this.channelRunner = e.channelRunner, this.bundles = e.bundles, this.hooks = e.hooks, this.blueId = e.blueId, this.nodeAt = e.nodeAt, this.createDocumentUpdateEvent = e.createDocumentUpdateEvent, this.matchesDocumentUpdate = e.matchesDocumentUpdate;
2023
2258
  }
2024
2259
  async initializeScope(e, t) {
2025
- const n = C(e), r = /* @__PURE__ */ new Set();
2260
+ const n = k(e), r = /* @__PURE__ */ new Set();
2026
2261
  let o = null, s = null;
2027
2262
  for (t && this.runtime.gasMeter().chargeScopeEntry(n); ; ) {
2028
- const g = this.nodeAt(n);
2029
- if (!g)
2263
+ const d = this.nodeAt(n);
2264
+ if (!d)
2030
2265
  return;
2031
- s || (s = g.clone()), o = this.loadBundle(g, n), this.bundles.set(n, o);
2032
- const m = o.embeddedPaths().find((re) => !r.has(re)) ?? null;
2033
- if (!m)
2266
+ s || (s = d.clone()), o = this.loadBundle(d, n), this.bundles.set(n, o);
2267
+ const S = o.embeddedPaths().find((C) => !r.has(C)) ?? null;
2268
+ if (!S)
2034
2269
  break;
2035
- r.add(m);
2036
- const y = k(n, m);
2037
- this.nodeAt(y) && await this.initializeScope(y, !0);
2270
+ r.add(S);
2271
+ const m = T(n, S);
2272
+ this.nodeAt(m) && await this.initializeScope(m, !0);
2038
2273
  }
2039
2274
  if (!o)
2040
2275
  return;
2041
2276
  const a = this.hasInitializationMarker(n);
2042
2277
  if (!a && o.hasCheckpoint())
2043
- throw new B(
2278
+ throw new $(
2044
2279
  `Reserved key 'checkpoint' must not appear before initialization at scope ${n}`
2045
2280
  );
2046
2281
  if (a)
2047
2282
  return;
2048
2283
  this.runtime.gasMeter().chargeInitialization();
2049
- const c = this.blueId(s ?? new h()), u = this.createLifecycleEvent(c), d = this.hooks.createContext(
2284
+ const c = this.blueId(s ?? new p()), u = this.createLifecycleEvent(c), h = this.hooks.createContext(
2050
2285
  n,
2051
2286
  o,
2052
2287
  u,
2053
2288
  !1,
2054
2289
  !0
2055
2290
  );
2056
- await this.deliverLifecycle(n, o, u, !0), await this.addInitializationMarker(d, c);
2291
+ await this.deliverLifecycle(n, o, u, !0), await this.addInitializationMarker(h, c);
2057
2292
  }
2058
2293
  loadBundles(e) {
2059
- const t = C(e);
2294
+ const t = k(e);
2060
2295
  if (this.bundles.has(t))
2061
2296
  return;
2062
- const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : L.empty();
2297
+ const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : V.empty();
2063
2298
  this.bundles.set(t, r);
2064
2299
  for (const o of r.embeddedPaths()) {
2065
- const s = k(t, o);
2300
+ const s = T(t, o);
2066
2301
  this.loadBundles(s);
2067
2302
  }
2068
2303
  }
2069
2304
  async processExternalEvent(e, t) {
2070
- const n = Er(this.runtime.blue(), t);
2305
+ const n = Gr(this.runtime.blue(), t);
2071
2306
  await this.processPreparedExternalEvent(e, n);
2072
2307
  }
2073
2308
  async processPreparedExternalEvent(e, t) {
2074
- const n = C(e);
2309
+ const n = k(e);
2075
2310
  if (this.hooks.isScopeInactive(n))
2076
2311
  return;
2077
2312
  this.runtime.gasMeter().chargeScopeEntry(n);
@@ -2086,7 +2321,7 @@ class kr {
2086
2321
  for (const s of o) {
2087
2322
  if (this.hooks.isScopeInactive(n))
2088
2323
  break;
2089
- he(s.blueId()) || await this.channelRunner.runExternalChannel(
2324
+ ye(s.blueId()) || await this.channelRunner.runExternalChannel(
2090
2325
  n,
2091
2326
  r,
2092
2327
  s,
@@ -2105,7 +2340,7 @@ class kr {
2105
2340
  r
2106
2341
  );
2107
2342
  } catch (o) {
2108
- if (o instanceof A) {
2343
+ if (o instanceof F) {
2109
2344
  const s = this.hooks.fatalReason(o, "Boundary violation");
2110
2345
  await this.hooks.enterFatalTermination(e, t, s);
2111
2346
  return;
@@ -2133,18 +2368,18 @@ class kr {
2133
2368
  if (!a || this.hooks.isScopeInactive(s))
2134
2369
  continue;
2135
2370
  const c = this.createDocumentUpdateEvent(o, s), u = a.channelsOfType(
2136
- wr
2371
+ qr
2137
2372
  );
2138
- for (const d of u) {
2139
- const g = d.contract();
2373
+ for (const h of u) {
2374
+ const d = h.contract();
2140
2375
  if (this.matchesDocumentUpdate(
2141
2376
  s,
2142
- g.path ?? null,
2377
+ d.path ?? null,
2143
2378
  o.path
2144
2379
  ) && (await this.channelRunner.runHandlers(
2145
2380
  s,
2146
2381
  a,
2147
- d.key(),
2382
+ h.key(),
2148
2383
  c,
2149
2384
  !1
2150
2385
  ), this.hooks.isScopeInactive(s)))
@@ -2152,12 +2387,12 @@ class kr {
2152
2387
  }
2153
2388
  }
2154
2389
  } catch (o) {
2155
- if (o instanceof A) {
2390
+ if (o instanceof F) {
2156
2391
  const s = this.hooks.fatalReason(o, "Boundary violation");
2157
2392
  await this.hooks.enterFatalTermination(e, t, s);
2158
2393
  return;
2159
2394
  }
2160
- if (o instanceof B || o instanceof Error && !(o instanceof E)) {
2395
+ if (o instanceof $ || o instanceof Error && !(o instanceof y)) {
2161
2396
  const s = this.hooks.fatalReason(o, "Runtime fatal");
2162
2397
  await this.hooks.enterFatalTermination(e, t, s);
2163
2398
  return;
@@ -2170,7 +2405,7 @@ class kr {
2170
2405
  if (this.runtime.gasMeter().chargeLifecycleDelivery(), await this.hooks.recordLifecycleForBridging(e, n), !t)
2171
2406
  return;
2172
2407
  const o = t.channelsOfType(
2173
- vr
2408
+ Qr
2174
2409
  );
2175
2410
  for (const s of o)
2176
2411
  if (await this.channelRunner.runHandlers(
@@ -2184,14 +2419,14 @@ class kr {
2184
2419
  r && await this.finalizeScope(e, t);
2185
2420
  }
2186
2421
  async processEmbeddedChildren(e, t) {
2187
- const n = C(e), r = /* @__PURE__ */ new Set();
2422
+ const n = k(e), r = /* @__PURE__ */ new Set();
2188
2423
  let o = this.refreshBundle(n);
2189
2424
  for (; o; ) {
2190
2425
  const s = this.nextEmbeddedPath(o, r);
2191
2426
  if (!s)
2192
2427
  return o;
2193
2428
  r.add(s);
2194
- const a = k(n, s);
2429
+ const a = T(n, s);
2195
2430
  if (a === n || this.hooks.isScopeInactive(a)) {
2196
2431
  o = this.refreshBundle(n);
2197
2432
  continue;
@@ -2201,7 +2436,7 @@ class kr {
2201
2436
  return null;
2202
2437
  }
2203
2438
  refreshBundle(e) {
2204
- const t = C(e), n = this.nodeAt(t);
2439
+ const t = k(e), n = this.nodeAt(t);
2205
2440
  if (!n)
2206
2441
  return this.bundles.delete(t), null;
2207
2442
  const r = this.loadBundle(n, t);
@@ -2219,12 +2454,12 @@ class kr {
2219
2454
  try {
2220
2455
  return this.contractLoader.load(e, t);
2221
2456
  } catch (n) {
2222
- if (n instanceof E || n instanceof K)
2457
+ if (n instanceof y || n instanceof z)
2223
2458
  throw n;
2224
2459
  const r = n?.message ?? "Failed to load contracts";
2225
- throw new E(
2460
+ throw new y(
2226
2461
  r,
2227
- w.runtimeFatal(
2462
+ v.runtimeFatal(
2228
2463
  `Failed to load contracts for scope ${t}`,
2229
2464
  n
2230
2465
  )
@@ -2232,7 +2467,7 @@ class kr {
2232
2467
  }
2233
2468
  }
2234
2469
  async addInitializationMarker(e, t) {
2235
- const n = new h().setType(new h().setBlueId(De)).addProperty("documentId", new h().setValue(t)), r = e.resolvePointer(ce);
2470
+ const n = new p().setType(new p().setBlueId(ze)).addProperty("documentId", new p().setValue(t)), r = e.resolvePointer(de);
2236
2471
  await e.applyPatch({
2237
2472
  op: "ADD",
2238
2473
  path: r,
@@ -2246,20 +2481,20 @@ class kr {
2246
2481
  if (this.hooks.isScopeInactive(e) || t.embeddedPaths().length === 0)
2247
2482
  return;
2248
2483
  const n = t.channelsOfType(
2249
- Cr
2484
+ jr
2250
2485
  );
2251
2486
  if (n.length !== 0)
2252
2487
  for (const r of t.embeddedPaths()) {
2253
- const o = k(e, r), a = this.runtime.scope(o).drainBridgeableEvents();
2488
+ const o = T(e, r), a = this.runtime.scope(o).drainBridgeableEvents();
2254
2489
  if (a.length !== 0)
2255
2490
  for (const c of a) {
2256
2491
  let u = !1;
2257
- for (const d of n) {
2258
- const m = d.contract().childPath ?? "/";
2259
- k(e, m) === o && (u || (this.runtime.gasMeter().chargeBridge(), u = !0), await this.channelRunner.runHandlers(
2492
+ for (const h of n) {
2493
+ const S = h.contract().childPath ?? "/";
2494
+ T(e, S) === o && (u || (this.runtime.gasMeter().chargeBridge(), u = !0), await this.channelRunner.runHandlers(
2260
2495
  e,
2261
2496
  t,
2262
- d.key(),
2497
+ h.key(),
2263
2498
  c.clone(),
2264
2499
  !1
2265
2500
  ));
@@ -2271,7 +2506,7 @@ class kr {
2271
2506
  if (this.hooks.isScopeInactive(e))
2272
2507
  return;
2273
2508
  const n = this.runtime.scope(e), r = t.channelsOfType(
2274
- Sr
2509
+ Jr
2275
2510
  );
2276
2511
  if (r.length === 0) {
2277
2512
  n.clearTriggered();
@@ -2301,19 +2536,19 @@ class kr {
2301
2536
  }
2302
2537
  }
2303
2538
  validatePatchBoundary(e, t, n) {
2304
- const r = C(e), o = T(n.path);
2539
+ const r = k(e), o = R(n.path);
2305
2540
  if (o === r)
2306
- throw new A(
2541
+ throw new F(
2307
2542
  `Self-root mutation is forbidden at scope ${r}`
2308
2543
  );
2309
2544
  if (r !== "/" && !o.startsWith(`${r}/`))
2310
- throw new A(
2545
+ throw new F(
2311
2546
  `Patch path ${o} is outside scope ${r}`
2312
2547
  );
2313
2548
  for (const s of t.embeddedPaths()) {
2314
- const a = k(r, s);
2549
+ const a = T(r, s);
2315
2550
  if (o.startsWith(`${a}/`))
2316
- throw new A(
2551
+ throw new F(
2317
2552
  `Boundary violation: patch ${o} enters embedded scope ${a}`
2318
2553
  );
2319
2554
  }
@@ -2321,14 +2556,14 @@ class kr {
2321
2556
  enforceReservedKeyWriteProtection(e, t, n) {
2322
2557
  if (n)
2323
2558
  return;
2324
- const r = C(e), o = T(t.path);
2325
- for (const s of de) {
2326
- const a = k(
2559
+ const r = k(e), o = R(t.path);
2560
+ for (const s of Ee) {
2561
+ const a = T(
2327
2562
  r,
2328
- Z(s)
2563
+ ne(s)
2329
2564
  );
2330
2565
  if (o === a || o.startsWith(`${a}/`))
2331
- throw new A(
2566
+ throw new F(
2332
2567
  `Reserved key '${s}' is write-protected at ${a}`
2333
2568
  );
2334
2569
  }
@@ -2336,90 +2571,90 @@ class kr {
2336
2571
  async markCutOffChildrenIfNeeded(e, t, n) {
2337
2572
  if (t.embeddedPaths().length === 0)
2338
2573
  return;
2339
- const r = T(n.path);
2574
+ const r = R(n.path);
2340
2575
  for (const o of t.embeddedPaths()) {
2341
- const s = k(e, o);
2576
+ const s = T(e, o);
2342
2577
  r === s && (n.op === "remove" || n.op === "replace") && await this.hooks.markCutOff(s);
2343
2578
  }
2344
2579
  }
2345
2580
  hasInitializationMarker(e) {
2346
- const t = k(e, ce), n = this.nodeAt(t);
2581
+ const t = T(e, de), n = this.nodeAt(t);
2347
2582
  if (!n)
2348
2583
  return !1;
2349
- if (!(n instanceof h)) {
2584
+ if (!(n instanceof p)) {
2350
2585
  const o = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2351
- throw new B(o);
2586
+ throw new $(o);
2352
2587
  }
2353
- if (n.getType()?.getBlueId() !== De) {
2588
+ if (n.getType()?.getBlueId() !== ze) {
2354
2589
  const o = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2355
- throw new B(o);
2590
+ throw new $(o);
2356
2591
  }
2357
2592
  return !0;
2358
2593
  }
2359
2594
  createLifecycleEvent(e) {
2360
- return new h().setType(new h().setBlueId(br)).setProperties({
2361
- type: new h().setValue("Core/Document Processing Initiated"),
2362
- documentId: new h().setValue(e)
2595
+ return new p().setType(new p().setBlueId(Xr)).setProperties({
2596
+ type: new p().setValue("Core/Document Processing Initiated"),
2597
+ documentId: new p().setValue(e)
2363
2598
  });
2364
2599
  }
2365
2600
  }
2366
- class Y extends Error {
2601
+ class ee extends Error {
2367
2602
  constructor(e) {
2368
2603
  super(
2369
2604
  e ? "Processing terminated due to fatal error" : "Processing terminated"
2370
2605
  ), this.fatal = e, this.name = "RunTerminationError";
2371
2606
  }
2372
2607
  }
2373
- const Tr = p["Core/Processing Terminated Marker"], Ir = p["Core/Document Processing Terminated"];
2374
- class Rr {
2608
+ const Zr = f["Core/Processing Terminated Marker"], ei = f["Core/Document Processing Terminated"];
2609
+ class ti {
2375
2610
  constructor(e) {
2376
2611
  this.runtime = e;
2377
2612
  }
2378
2613
  async terminateScope(e, t, n, r, o) {
2379
2614
  e.recordPendingTermination(t, r, o ?? null);
2380
- const s = e.normalizeScope(t), a = k(s, He);
2615
+ const s = e.normalizeScope(t), a = T(s, Je);
2381
2616
  this.runtime.directWrite(
2382
2617
  a,
2383
- Pr(this.runtime.blue(), r, o)
2618
+ ni(this.runtime.blue(), r, o)
2384
2619
  ), this.runtime.gasMeter().chargeTerminationMarker();
2385
- const c = n ?? e.bundleForScope(s) ?? null, u = Mr(r, o);
2620
+ const c = n ?? e.bundleForScope(s) ?? null, u = ri(r, o);
2386
2621
  if (await e.deliverLifecycle(
2387
2622
  s,
2388
2623
  c,
2389
2624
  u,
2390
2625
  !1
2391
2626
  ), this.runtime.scope(s).finalizeTermination(r, o ?? null), e.clearPendingTermination(t), r === "FATAL" && this.runtime.gasMeter().chargeFatalTerminationOverhead(), r === "FATAL" && s === "/")
2392
- throw this.runtime.markRunTerminated(), new Y(!0);
2627
+ throw this.runtime.markRunTerminated(), new ee(!0);
2393
2628
  if (r === "GRACEFUL" && s === "/")
2394
- throw this.runtime.markRunTerminated(), new Y(!1);
2629
+ throw this.runtime.markRunTerminated(), new ee(!1);
2395
2630
  }
2396
2631
  }
2397
- function Pr(i, e, t) {
2398
- return Nr(i, {
2399
- type: { blueId: Tr },
2632
+ function ni(i, e, t) {
2633
+ return ii(i, {
2634
+ type: { blueId: Zr },
2400
2635
  cause: e === "GRACEFUL" ? "graceful" : "fatal",
2401
2636
  ...t ? { reason: t } : {}
2402
2637
  });
2403
2638
  }
2404
- function Mr(i, e) {
2405
- const t = new h().setType(
2406
- new h().setBlueId(Ir)
2639
+ function ri(i, e) {
2640
+ const t = new p().setType(
2641
+ new p().setBlueId(ei)
2407
2642
  );
2408
2643
  return t.addProperty(
2409
2644
  "cause",
2410
- new h().setValue(i === "GRACEFUL" ? "graceful" : "fatal")
2411
- ), e && t.addProperty("reason", new h().setValue(e)), t;
2645
+ new p().setValue(i === "GRACEFUL" ? "graceful" : "fatal")
2646
+ ), e && t.addProperty("reason", new p().setValue(e)), t;
2412
2647
  }
2413
- function Nr(i, e) {
2648
+ function ii(i, e) {
2414
2649
  return i.jsonValueToNode(e);
2415
2650
  }
2416
- const V = "-";
2417
- class Or {
2651
+ const q = "-";
2652
+ class oi {
2418
2653
  constructor(e) {
2419
2654
  this.document = e;
2420
2655
  }
2421
2656
  applyPatch(e, t) {
2422
- const n = C(e), r = T(t.path), o = Le(r), s = Be(this.document, o, "before", r);
2657
+ const n = k(e), r = R(t.path), o = He(r), s = Ve(this.document, o, "before", r);
2423
2658
  switch (t.op) {
2424
2659
  case "ADD":
2425
2660
  this.applyAdd(o, r, t.val ?? null);
@@ -2431,34 +2666,34 @@ class Or {
2431
2666
  this.applyRemove(o, r);
2432
2667
  break;
2433
2668
  }
2434
- const a = t.op === "REMOVE" ? null : Be(this.document, o, "after", r);
2669
+ const a = t.op === "REMOVE" ? null : Ve(this.document, o, "after", r);
2435
2670
  return {
2436
2671
  path: r,
2437
2672
  before: s,
2438
2673
  after: a,
2439
2674
  op: t.op.toLowerCase(),
2440
2675
  originScope: n,
2441
- cascadeScopes: Ar(n)
2676
+ cascadeScopes: si(n)
2442
2677
  };
2443
2678
  }
2444
2679
  directWrite(e, t) {
2445
- const n = T(e);
2680
+ const n = R(e);
2446
2681
  if (n === "/")
2447
2682
  throw new Error("Direct write cannot target root document");
2448
- const r = Le(n), { parent: o, leaf: s } = this.resolveParent(r);
2449
- if (s === V)
2683
+ const r = He(n), { parent: o, leaf: s } = this.resolveParent(r);
2684
+ if (s === q)
2450
2685
  throw new Error(
2451
2686
  `Direct write does not support append token '-' for path ${n}`
2452
2687
  );
2453
2688
  const a = o.getItems();
2454
- if (a && D(s)) {
2689
+ if (a && U(s)) {
2455
2690
  this.directWriteArray(o, a, s, t, n);
2456
2691
  return;
2457
2692
  }
2458
2693
  this.directWriteObject(o, s, t);
2459
2694
  }
2460
2695
  directWriteArray(e, t, n, r, o) {
2461
- const s = se(e, t), a = M(n, o);
2696
+ const s = ue(e, t), a = B(n, o);
2462
2697
  if (r == null) {
2463
2698
  if (a < 0 || a >= s.length)
2464
2699
  return;
@@ -2479,7 +2714,7 @@ class Or {
2479
2714
  );
2480
2715
  }
2481
2716
  directWriteObject(e, t, n) {
2482
- const r = J(e);
2717
+ const r = Q(e);
2483
2718
  if (n == null) {
2484
2719
  delete r[t], e.setProperties(
2485
2720
  Object.keys(r).length > 0 ? r : void 0
@@ -2499,27 +2734,27 @@ class Or {
2499
2734
  return { parent: t, leaf: e[e.length - 1] };
2500
2735
  }
2501
2736
  getOrCreateChild(e, t, n, r) {
2502
- if (t === V)
2737
+ if (t === q)
2503
2738
  throw new Error(
2504
- `Append token '-' must be final segment: ${z(n, r)}`
2739
+ `Append token '-' must be final segment: ${W(n, r)}`
2505
2740
  );
2506
2741
  const o = e.getItems();
2507
- if (o && D(t)) {
2508
- const c = M(t, z(n, r));
2742
+ if (o && U(t)) {
2743
+ const c = B(t, W(n, r));
2509
2744
  if (c < 0 || c >= o.length)
2510
2745
  throw new Error(
2511
- `Array index out of bounds: ${z(n, r)}`
2746
+ `Array index out of bounds: ${W(n, r)}`
2512
2747
  );
2513
2748
  const u = o[c];
2514
2749
  if (!u)
2515
2750
  throw new Error(
2516
- `Path does not exist: ${z(n, r)}`
2751
+ `Path does not exist: ${W(n, r)}`
2517
2752
  );
2518
2753
  return u;
2519
2754
  }
2520
- const s = J(e);
2755
+ const s = Q(e);
2521
2756
  let a = s[t];
2522
- return a || (a = new h(), s[t] = a, e.setProperties(s)), a;
2757
+ return a || (a = new p(), s[t] = a, e.setProperties(s)), a;
2523
2758
  }
2524
2759
  applyAdd(e, t, n) {
2525
2760
  if (t === "/" || t.length === 0)
@@ -2530,24 +2765,24 @@ class Or {
2530
2765
  "ADD"
2531
2766
  );
2532
2767
  try {
2533
- if (D(o)) {
2534
- const u = r.getItems(), d = o === V;
2768
+ if (U(o)) {
2769
+ const u = r.getItems(), h = o === q;
2535
2770
  if (!u)
2536
2771
  throw new Error(
2537
- d ? `Append token '-' requires array at ${s}` : `Array index segment requires array at ${s}`
2772
+ h ? `Append token '-' requires array at ${s}` : `Array index segment requires array at ${s}`
2538
2773
  );
2539
- if (d) {
2540
- se(r, u).push($(n));
2774
+ if (h) {
2775
+ ue(r, u).push(G(n));
2541
2776
  return;
2542
2777
  }
2543
- const g = M(o, t);
2544
- if (g < 0 || g > u.length)
2778
+ const d = B(o, t);
2779
+ if (d < 0 || d > u.length)
2545
2780
  throw new Error(`Array index out of bounds in path: ${t}`);
2546
- se(r, u).splice(g, 0, $(n));
2781
+ ue(r, u).splice(d, 0, G(n));
2547
2782
  return;
2548
2783
  }
2549
- const c = J(r);
2550
- c[o] = $(n), r.setProperties(c);
2784
+ const c = Q(r);
2785
+ c[o] = G(n), r.setProperties(c);
2551
2786
  } catch (c) {
2552
2787
  throw this.rollbackCreated(a), c;
2553
2788
  }
@@ -2561,18 +2796,18 @@ class Or {
2561
2796
  "REPLACE"
2562
2797
  );
2563
2798
  try {
2564
- if (D(o)) {
2799
+ if (U(o)) {
2565
2800
  const c = r.getItems();
2566
2801
  if (!c)
2567
2802
  throw new Error(`Array index segment requires array at ${t}`);
2568
- const u = M(o, t);
2803
+ const u = B(o, t);
2569
2804
  if (u < 0 || u >= c.length)
2570
2805
  throw new Error(`Array index out of bounds in path: ${t}`);
2571
- c[u] = $(n), r.setItems(c);
2806
+ c[u] = G(n), r.setItems(c);
2572
2807
  return;
2573
2808
  }
2574
- const a = J(r);
2575
- a[o] = $(n), r.setProperties(a);
2809
+ const a = Q(r);
2810
+ a[o] = G(n), r.setProperties(a);
2576
2811
  } catch (a) {
2577
2812
  throw this.rollbackCreated(s), a;
2578
2813
  }
@@ -2585,11 +2820,11 @@ class Or {
2585
2820
  t,
2586
2821
  "REMOVE"
2587
2822
  );
2588
- if (D(r)) {
2823
+ if (U(r)) {
2589
2824
  const a = n.getItems();
2590
2825
  if (!a)
2591
2826
  throw new Error(`Array index segment requires array at ${t}`);
2592
- const c = M(r, t);
2827
+ const c = B(r, t);
2593
2828
  if (c < 0 || c >= a.length)
2594
2829
  throw new Error(`Array index out of bounds in path: ${t}`);
2595
2830
  a.splice(c, 1), n.setItems(a);
@@ -2607,27 +2842,27 @@ class Or {
2607
2842
  let r = this.document;
2608
2843
  const o = [];
2609
2844
  for (let a = 0; a < e.length - 1; a += 1) {
2610
- const c = e[a], u = z(e, a + 1);
2611
- if (D(c)) {
2612
- const m = r.getItems();
2613
- if (!m)
2845
+ const c = e[a], u = W(e, a + 1);
2846
+ if (U(c)) {
2847
+ const S = r.getItems();
2848
+ if (!S)
2614
2849
  throw new Error(`Array index segment requires array at ${u}`);
2615
- const y = M(c, u);
2616
- if (y < 0 || y >= m.length)
2850
+ const m = B(c, u);
2851
+ if (m < 0 || m >= S.length)
2617
2852
  throw new Error(`Array index out of bounds in path: ${u}`);
2618
- const P = m[y];
2619
- if (!(P instanceof h))
2853
+ const E = S[m];
2854
+ if (!(E instanceof p))
2620
2855
  throw new Error(`Array index out of bounds in path: ${u}`);
2621
- r = P;
2856
+ r = E;
2622
2857
  continue;
2623
2858
  }
2624
- let d = r.getProperties(), g = d?.[c] ?? null;
2625
- if (!(g instanceof h)) {
2859
+ let h = r.getProperties(), d = h?.[c] ?? null;
2860
+ if (!(d instanceof p)) {
2626
2861
  if (n === "REMOVE")
2627
2862
  throw new Error(`Path does not exist: ${u}`);
2628
- g = new h(), d || (d = {}), d[c] = g, r.setProperties(d), o.push({ owner: r, key: c });
2863
+ d = new p(), h || (h = {}), h[c] = d, r.setProperties(h), o.push({ owner: r, key: c });
2629
2864
  }
2630
- r = g;
2865
+ r = d;
2631
2866
  }
2632
2867
  const s = e[e.length - 1];
2633
2868
  return { parent: r, key: s, pointer: t, created: o };
@@ -2639,7 +2874,7 @@ class Or {
2639
2874
  }
2640
2875
  }
2641
2876
  }
2642
- function Ar(i) {
2877
+ function si(i) {
2643
2878
  const e = [];
2644
2879
  let t = i;
2645
2880
  for (; e.push(t), t !== "/"; ) {
@@ -2648,51 +2883,51 @@ function Ar(i) {
2648
2883
  }
2649
2884
  return e;
2650
2885
  }
2651
- function Be(i, e, t, n) {
2886
+ function Ve(i, e, t, n) {
2652
2887
  try {
2653
2888
  if (e.length === 0)
2654
2889
  return i.clone();
2655
- const r = Dr(i, e, t, n);
2890
+ const r = ai(i, e, t, n);
2656
2891
  return r ? r.clone() : null;
2657
2892
  } catch {
2658
2893
  return null;
2659
2894
  }
2660
2895
  }
2661
- function Dr(i, e, t, n) {
2896
+ function ai(i, e, t, n) {
2662
2897
  let r = i;
2663
2898
  for (let o = 0; o < e.length; o += 1) {
2664
2899
  const s = e[o] ?? "", a = o === e.length - 1;
2665
- if (r = Br(r, s, a, t, n), !r)
2900
+ if (r = ci(r, s, a, t, n), !r)
2666
2901
  return null;
2667
2902
  }
2668
2903
  return r;
2669
2904
  }
2670
- function Br(i, e, t, n, r) {
2905
+ function ci(i, e, t, n, r) {
2671
2906
  if (!i)
2672
2907
  return null;
2673
2908
  const o = i.getItems();
2674
2909
  if (o) {
2675
- if (e === V) {
2910
+ if (e === q) {
2676
2911
  if (!t)
2677
2912
  throw new Error(`Append token '-' must be final segment: ${r}`);
2678
2913
  return n === "before" || o.length === 0 ? null : o[o.length - 1] ?? null;
2679
2914
  }
2680
- const c = M(e, r);
2915
+ const c = B(e, r);
2681
2916
  return c < 0 || c >= o.length ? null : o[c] ?? null;
2682
2917
  }
2683
2918
  const s = i.getProperties();
2684
2919
  if (!s)
2685
2920
  return null;
2686
2921
  const a = s[e];
2687
- return a instanceof h ? a : null;
2922
+ return a instanceof p ? a : null;
2688
2923
  }
2689
- function Le(i) {
2924
+ function He(i) {
2690
2925
  if (i === "/" || i === "")
2691
2926
  return [];
2692
2927
  const e = i.startsWith("/") ? i.slice(1) : i;
2693
2928
  return e.length === 0 ? [] : e.split("/");
2694
2929
  }
2695
- function M(i, e) {
2930
+ function B(i, e) {
2696
2931
  const t = Number.parseInt(i, 10);
2697
2932
  if (Number.isNaN(t))
2698
2933
  throw new Error(`Expected numeric array index in path: ${e}`);
@@ -2700,7 +2935,7 @@ function M(i, e) {
2700
2935
  throw new Error(`Negative array index in path: ${e}`);
2701
2936
  return t;
2702
2937
  }
2703
- function z(i, e) {
2938
+ function W(i, e) {
2704
2939
  if (e <= 0)
2705
2940
  return "/";
2706
2941
  const t = Math.min(e, i.length);
@@ -2709,11 +2944,11 @@ function z(i, e) {
2709
2944
  n += `/${i[r] ?? ""}`;
2710
2945
  return n === "" ? "/" : n;
2711
2946
  }
2712
- function se(i, e) {
2947
+ function ue(i, e) {
2713
2948
  const t = [...e];
2714
2949
  return i.setItems(t), t;
2715
2950
  }
2716
- function J(i) {
2951
+ function Q(i) {
2717
2952
  const e = i.getProperties();
2718
2953
  if (!e) {
2719
2954
  const n = {};
@@ -2722,13 +2957,13 @@ function J(i) {
2722
2957
  const t = { ...e };
2723
2958
  return i.setProperties(t), t;
2724
2959
  }
2725
- function D(i) {
2726
- return i === V || /^\d+$/.test(i);
2960
+ function U(i) {
2961
+ return i === q || /^\d+$/.test(i);
2727
2962
  }
2728
- function $(i) {
2729
- return i == null ? new h().setValue(null) : i.clone();
2963
+ function G(i) {
2964
+ return i == null ? new p().setValue(null) : i.clone();
2730
2965
  }
2731
- class Lr {
2966
+ class li {
2732
2967
  constructor(e) {
2733
2968
  this.path = e;
2734
2969
  }
@@ -2790,7 +3025,7 @@ class Lr {
2790
3025
  return this.cutOff;
2791
3026
  }
2792
3027
  }
2793
- class xr {
3028
+ class ui {
2794
3029
  scopesMap = /* @__PURE__ */ new Map();
2795
3030
  rootEmissionList = [];
2796
3031
  scopes() {
@@ -2798,7 +3033,7 @@ class xr {
2798
3033
  }
2799
3034
  scope(e) {
2800
3035
  let t = this.scopesMap.get(e);
2801
- return t || (t = new Lr(e), this.scopesMap.set(e, t)), t;
3036
+ return t || (t = new li(e), this.scopesMap.set(e, t)), t;
2802
3037
  }
2803
3038
  existingScope(e) {
2804
3039
  return this.scopesMap.get(e);
@@ -2816,45 +3051,33 @@ class xr {
2816
3051
  this.scopesMap.delete(e);
2817
3052
  }
2818
3053
  }
2819
- function q(i) {
3054
+ function Ct(i) {
2820
3055
  return Math.floor((i + 99) / 100);
2821
3056
  }
2822
- function ye(i) {
2823
- return new TextEncoder().encode(i).length;
2824
- }
2825
- function _r(i) {
2826
- const e = T(i);
3057
+ function hi(i) {
3058
+ const e = R(i);
2827
3059
  return e === "/" ? 0 : e.split("/").length - 1;
2828
3060
  }
2829
- function Fr(i) {
2830
- return 100 + q(ye(i));
2831
- }
2832
- function Ur(i) {
3061
+ function di(i) {
2833
3062
  return 40 + 5 * Math.max(0, i);
2834
3063
  }
2835
- function zr(i) {
2836
- return 5 + q(ye(i));
3064
+ function pi(i, e) {
3065
+ return 8 + hi(i) + Ct(e);
2837
3066
  }
2838
- function $r(i, e) {
2839
- return 3 * Math.max(0, i) + q(ye(e));
2840
- }
2841
- function Hr(i, e) {
2842
- return 8 + _r(i) + q(e);
2843
- }
2844
- const Vr = 1e3, Wr = 5, Kr = 50, qr = 2, jr = 10, Jr = 10, Gr = 10, Qr = 20, Yr = 20, Xr = 30, Zr = 30, ei = 100;
2845
- function ti(i) {
3067
+ const mi = 1e3, fi = 5, gi = 50, Ei = 2, yi = 10, Ci = 10, Si = 10, vi = 20, wi = 20, ki = 30, bi = 30, Ii = 100;
3068
+ function Ti(i) {
2846
3069
  return 50 + 10 * i;
2847
3070
  }
2848
- function ni(i) {
3071
+ function Ri(i) {
2849
3072
  return 20 + i;
2850
3073
  }
2851
- function ri(i) {
3074
+ function Pi(i) {
2852
3075
  return 10 * i;
2853
3076
  }
2854
- function ii(i) {
3077
+ function Mi(i) {
2855
3078
  return 20 + i;
2856
3079
  }
2857
- class oi {
3080
+ class Ni {
2858
3081
  constructor(e) {
2859
3082
  this.blue = e;
2860
3083
  }
@@ -2866,77 +3089,72 @@ class oi {
2866
3089
  this.total += e;
2867
3090
  }
2868
3091
  chargeScopeEntry(e) {
2869
- this.add(ti(this.scopeDepth(e)));
3092
+ this.add(Ti(this.scopeDepth(e)));
2870
3093
  }
2871
3094
  chargeInitialization() {
2872
- this.add(Vr);
3095
+ this.add(mi);
2873
3096
  }
2874
3097
  chargeChannelMatchAttempt() {
2875
- this.add(Wr);
3098
+ this.add(fi);
2876
3099
  }
2877
3100
  chargeHandlerOverhead() {
2878
- this.add(Kr);
3101
+ this.add(gi);
2879
3102
  }
2880
3103
  chargeBoundaryCheck() {
2881
- this.add(qr);
3104
+ this.add(Ei);
2882
3105
  }
2883
3106
  chargePatchAddOrReplace(e) {
2884
- this.add(ni(this.payloadSizeCharge(e)));
3107
+ this.add(Ri(this.payloadSizeCharge(e)));
2885
3108
  }
2886
3109
  chargePatchRemove() {
2887
- this.add(jr);
3110
+ this.add(yi);
2888
3111
  }
2889
3112
  chargeCascadeRouting(e) {
2890
- e > 0 && this.add(ri(e));
3113
+ e > 0 && this.add(Pi(e));
2891
3114
  }
2892
3115
  chargeEmitEvent(e) {
2893
- this.add(ii(this.payloadSizeCharge(e)));
3116
+ this.add(Mi(this.payloadSizeCharge(e)));
2894
3117
  }
2895
3118
  chargeBridge() {
2896
- this.add(Jr);
3119
+ this.add(Ci);
2897
3120
  }
2898
3121
  chargeDrainEvent() {
2899
- this.add(Gr);
3122
+ this.add(Si);
2900
3123
  }
2901
3124
  chargeCheckpointUpdate() {
2902
- this.add(Qr);
3125
+ this.add(vi);
2903
3126
  }
2904
3127
  chargeTerminationMarker() {
2905
- this.add(Yr);
3128
+ this.add(wi);
2906
3129
  }
2907
3130
  chargeLifecycleDelivery() {
2908
- this.add(Xr);
3131
+ this.add(ki);
2909
3132
  }
2910
3133
  chargeFatalTerminationOverhead() {
2911
- this.add(ei);
2912
- }
2913
- chargeJavaScriptCodeBase(e) {
2914
- this.add(Fr(e));
3134
+ this.add(Ii);
2915
3135
  }
2916
3136
  chargeTriggerEventBase() {
2917
- this.add(Zr);
3137
+ this.add(bi);
2918
3138
  }
2919
3139
  chargeUpdateDocumentBase(e) {
2920
- this.add(Ur(e));
2921
- }
2922
- chargeExpression(e) {
2923
- this.add(zr(e));
2924
- }
2925
- chargeTemplate(e, t) {
2926
- this.add($r(e, t));
3140
+ this.add(di(e));
2927
3141
  }
2928
3142
  chargeDocumentSnapshot(e, t) {
2929
- const n = t ? ve(this.blue, t) : 0;
2930
- this.add(Hr(e, n));
3143
+ const n = t ? Me(this.blue, t) : 0;
3144
+ this.add(pi(e, n));
3145
+ }
3146
+ chargeWasmGas(e) {
3147
+ const t = Jt(e);
3148
+ t > 0 && this.add(t);
2931
3149
  }
2932
3150
  payloadSizeCharge(e) {
2933
3151
  if (!e)
2934
3152
  return 0;
2935
- const t = ve(this.blue, e);
2936
- return q(t);
3153
+ const t = Me(this.blue, e);
3154
+ return Ct(t);
2937
3155
  }
2938
3156
  scopeDepth(e) {
2939
- const t = C(e);
3157
+ const t = k(e);
2940
3158
  if (t === "/" || t.length <= 1)
2941
3159
  return 0;
2942
3160
  let n = 1;
@@ -2945,12 +3163,12 @@ class oi {
2945
3163
  return n;
2946
3164
  }
2947
3165
  }
2948
- class si {
3166
+ class Oi {
2949
3167
  constructor(e, t) {
2950
- this.documentRef = e, this.blueRef = t, this.patchEngine = new Or(this.documentRef), this.meter = new oi(this.blueRef);
3168
+ this.documentRef = e, this.blueRef = t, this.patchEngine = new oi(this.documentRef), this.meter = new Ni(this.blueRef);
2951
3169
  }
2952
3170
  patchEngine;
2953
- emissionRegistry = new xr();
3171
+ emissionRegistry = new ui();
2954
3172
  meter;
2955
3173
  runTerminated = !1;
2956
3174
  document() {
@@ -2999,15 +3217,15 @@ class si {
2999
3217
  return this.patchEngine.applyPatch(e, t);
3000
3218
  }
3001
3219
  }
3002
- const ai = p["Core/Processing Initialized Marker"], ci = p["Core/Document Update"];
3003
- class li {
3220
+ const Ai = f["Core/Processing Initialized Marker"], Di = f["Core/Document Update"];
3221
+ class Bi {
3004
3222
  constructor(e, t, n, r) {
3005
- this.contractLoader = e, this.registry = t, this.runtimeRef = new si(r, n);
3006
- const o = (s) => Ge(this.runtimeRef.blue(), s);
3007
- this.checkpointManager = new gr(
3223
+ this.contractLoader = e, this.registry = t, this.runtimeRef = new Oi(r, n);
3224
+ const o = (s) => nt(this.runtimeRef.blue(), s);
3225
+ this.checkpointManager = new Kr(
3008
3226
  this.runtimeRef,
3009
3227
  o
3010
- ), this.terminationService = new Rr(this.runtimeRef), this.channelRunner = new yr(
3228
+ ), this.terminationService = new ti(this.runtimeRef), this.channelRunner = new Wr(
3011
3229
  this.runtimeRef,
3012
3230
  this.checkpointManager,
3013
3231
  {
@@ -3023,10 +3241,10 @@ class li {
3023
3241
  shouldRunHandler: async (s, a) => {
3024
3242
  const c = this.registry.lookupHandler(s.blueId());
3025
3243
  if (!c) {
3026
- const d = `No processor registered for handler contract ${s.blueId()}`;
3027
- throw new E(
3028
- d,
3029
- w.illegalState(d)
3244
+ const h = `No processor registered for handler contract ${s.blueId()}`;
3245
+ throw new y(
3246
+ h,
3247
+ v.illegalState(h)
3030
3248
  );
3031
3249
  }
3032
3250
  const u = c.matches;
@@ -3037,19 +3255,19 @@ class li {
3037
3255
  canonicalSignature: o,
3038
3256
  channelProcessorFor: (s) => this.registry.lookupChannel(s) ?? null
3039
3257
  }
3040
- ), this.scopeExecutor = new kr({
3258
+ ), this.scopeExecutor = new Yr({
3041
3259
  runtime: this.runtimeRef,
3042
3260
  contractLoader: this.contractLoader,
3043
3261
  channelRunner: this.channelRunner,
3044
3262
  bundles: this.bundles,
3045
3263
  hooks: {
3046
3264
  isScopeInactive: (s) => this.isScopeInactive(s),
3047
- createContext: (s, a, c, u, d) => this.createContext(
3265
+ createContext: (s, a, c, u, h) => this.createContext(
3048
3266
  s,
3049
3267
  a,
3050
3268
  c,
3051
3269
  u,
3052
- d ?? !1
3270
+ h ?? !1
3053
3271
  ),
3054
3272
  recordLifecycleForBridging: (s, a) => this.recordLifecycleForBridging(s, a),
3055
3273
  enterFatalTermination: (s, a, c) => this.enterFatalTermination(s, a, c ?? null),
@@ -3088,7 +3306,7 @@ class li {
3088
3306
  );
3089
3307
  }
3090
3308
  createContext(e, t, n, r = !1, o = !1) {
3091
- return new ui(
3309
+ return new xi(
3092
3310
  this,
3093
3311
  t,
3094
3312
  e,
@@ -3099,7 +3317,7 @@ class li {
3099
3317
  }
3100
3318
  result() {
3101
3319
  const e = this.runtimeRef.document().clone(), t = this.runtimeRef.rootEmissions().map((n) => n.clone());
3102
- return _e.of(
3320
+ return Ke.of(
3103
3321
  e,
3104
3322
  t,
3105
3323
  this.runtimeRef.totalGas()
@@ -3109,10 +3327,10 @@ class li {
3109
3327
  return this.runtimeRef;
3110
3328
  }
3111
3329
  bundleForScope(e) {
3112
- return this.bundles.get(C(e));
3330
+ return this.bundles.get(k(e));
3113
3331
  }
3114
3332
  isScopeInactive(e) {
3115
- const t = C(e);
3333
+ const t = k(e);
3116
3334
  return this.cutOffScopes.has(t) || this.pendingTerminations.has(t) || this.runtimeRef.isScopeTerminated(t);
3117
3335
  }
3118
3336
  async enterGracefulTermination(e, t, n) {
@@ -3122,13 +3340,13 @@ class li {
3122
3340
  await this.terminate(e, t, "FATAL", n);
3123
3341
  }
3124
3342
  recordPendingTermination(e, t, n) {
3125
- this.pendingTerminations.set(C(e), { kind: t, reason: n });
3343
+ this.pendingTerminations.set(k(e), { kind: t, reason: n });
3126
3344
  }
3127
3345
  clearPendingTermination(e) {
3128
- this.pendingTerminations.delete(C(e));
3346
+ this.pendingTerminations.delete(k(e));
3129
3347
  }
3130
3348
  async markCutOff(e) {
3131
- const t = C(e);
3349
+ const t = k(e);
3132
3350
  this.cutOffScopes.add(t) && this.runtimeRef.existingScope(t)?.markCutOff();
3133
3351
  }
3134
3352
  async deliverLifecycle(e, t, n, r) {
@@ -3143,13 +3361,13 @@ class li {
3143
3361
  this.runtimeRef.scope(e).recordBridgeable(t.clone()), e === "/" && this.runtimeRef.recordRootEmission(t.clone());
3144
3362
  }
3145
3363
  normalizeScope(e) {
3146
- return C(e);
3364
+ return k(e);
3147
3365
  }
3148
3366
  resolvePointer(e, t) {
3149
- return k(e, t);
3367
+ return T(e, t);
3150
3368
  }
3151
3369
  async terminate(e, t, n, r) {
3152
- const o = C(e);
3370
+ const o = k(e);
3153
3371
  this.pendingTerminations.has(o) || this.runtimeRef.isScopeTerminated(o) || (this.pendingTerminations.set(o, { kind: n, reason: r }), await this.terminationService.terminateScope(
3154
3372
  this,
3155
3373
  e,
@@ -3159,8 +3377,8 @@ class li {
3159
3377
  ));
3160
3378
  }
3161
3379
  nodeAt(e) {
3162
- const t = C(e);
3163
- return X.nodeAt(this.runtimeRef.document(), t, {
3380
+ const t = k(e);
3381
+ return te.nodeAt(this.runtimeRef.document(), t, {
3164
3382
  calculateBlueId: (n) => this.runtimeRef.blue().calculateBlueIdSync(n)
3165
3383
  });
3166
3384
  }
@@ -3171,29 +3389,33 @@ class li {
3171
3389
  const s = this.runtimeRef.blue().calculateBlueIdSync(r), a = r.clone(), c = e.contract(), u = c.event;
3172
3390
  if (u && !this.runtimeRef.blue().isTypeOfNode(a, u))
3173
3391
  return { matches: !1 };
3174
- const d = {
3392
+ const h = {
3175
3393
  scopePath: n,
3176
3394
  blue: this.runtimeRef.blue(),
3177
3395
  event: a,
3178
3396
  markers: t.markers(),
3179
- bindingKey: e.key()
3180
- };
3181
- if (!await o.matches(c, d))
3397
+ bindingKey: e.key(),
3398
+ resolveChannel: (C) => t.channelEntry(C),
3399
+ channelProcessorFor: (C) => this.registry.lookupChannel(C) ?? null
3400
+ }, d = o.evaluate;
3401
+ if (typeof d == "function")
3402
+ return await d.call(o, c, h);
3403
+ if (!await o.matches(c, h))
3182
3404
  return { matches: !1 };
3183
- const m = o.channelize, y = m ? m.call(o, c, d) : void 0;
3405
+ const m = o.channelize, E = m ? m.call(o, c, h) : void 0;
3184
3406
  return {
3185
3407
  matches: !0,
3186
3408
  eventId: s,
3187
- eventNode: y ?? a.clone()
3409
+ eventNode: E ?? a.clone()
3188
3410
  };
3189
3411
  }
3190
3412
  async executeHandler(e, t) {
3191
3413
  const n = this.registry.lookupHandler(e.blueId());
3192
3414
  if (!n) {
3193
3415
  const r = `No processor registered for handler contract ${e.blueId()}`;
3194
- throw new E(
3416
+ throw new y(
3195
3417
  r,
3196
- w.illegalState(r)
3418
+ v.illegalState(r)
3197
3419
  );
3198
3420
  }
3199
3421
  await n.execute(e.contract(), t);
@@ -3204,7 +3426,7 @@ class li {
3204
3426
  * the outer run logic can react according to spec (§22).
3205
3427
  */
3206
3428
  async handleHandlerError(e, t, n) {
3207
- if (n instanceof Y || n instanceof K)
3429
+ if (n instanceof ee || n instanceof z)
3208
3430
  throw n;
3209
3431
  const r = this.fatalReason(n, "Runtime fatal");
3210
3432
  await this.enterFatalTermination(e, t, r);
@@ -3213,12 +3435,12 @@ class li {
3213
3435
  return e instanceof Error && typeof e.message == "string" ? e.message : t;
3214
3436
  }
3215
3437
  createDocumentUpdateEvent(e, t) {
3216
- const n = kt(t, e.path), r = e.before != null ? e.before.clone() : new h().setValue(null), o = e.after != null ? e.after.clone() : new h().setValue(null), s = new h().setType(
3217
- new h().setBlueId(ci)
3438
+ const n = Ft(t, e.path), r = e.before != null ? e.before.clone() : new p().setValue(null), o = e.after != null ? e.after.clone() : new p().setValue(null), s = new p().setType(
3439
+ new p().setBlueId(Di)
3218
3440
  );
3219
3441
  return s.setProperties({
3220
- op: new h().setValue(e.op),
3221
- path: new h().setValue(n),
3442
+ op: new p().setValue(e.op),
3443
+ path: new p().setValue(n),
3222
3444
  before: r,
3223
3445
  after: o
3224
3446
  }), s;
@@ -3226,17 +3448,17 @@ class li {
3226
3448
  matchesDocumentUpdate(e, t, n) {
3227
3449
  if (!t || t.length === 0)
3228
3450
  return !1;
3229
- const r = T(k(e, t)), o = T(n);
3451
+ const r = R(T(e, t)), o = R(n);
3230
3452
  return r === "/" || o === r ? !0 : o.startsWith(`${r}/`);
3231
3453
  }
3232
3454
  }
3233
- class X {
3455
+ class te {
3234
3456
  constructor(e, t, n) {
3235
3457
  this.contractLoader = e, this.registry = t, this.blue = n;
3236
3458
  }
3237
3459
  async initializeDocument(e) {
3238
3460
  if (this.isInitialized(e))
3239
- throw new B("Document already initialized");
3461
+ throw new $("Document already initialized");
3240
3462
  const t = this.createExecution(e.clone());
3241
3463
  return this.run(e, t, async () => {
3242
3464
  await t.initializeScope("/", !0);
@@ -3244,7 +3466,7 @@ class X {
3244
3466
  }
3245
3467
  async processDocument(e, t) {
3246
3468
  if (!this.isInitialized(e))
3247
- throw new B("Document not initialized");
3469
+ throw new $("Document not initialized");
3248
3470
  const n = this.createExecution(e.clone()), r = t.clone();
3249
3471
  return this.run(e, n, async () => {
3250
3472
  n.loadBundles("/"), await n.processExternalEvent("/", r);
@@ -3254,7 +3476,7 @@ class X {
3254
3476
  return this.initializationMarker(e) != null;
3255
3477
  }
3256
3478
  createExecution(e) {
3257
- return new li(
3479
+ return new Bi(
3258
3480
  this.contractLoader,
3259
3481
  this.registry,
3260
3482
  this.blue,
@@ -3265,11 +3487,11 @@ class X {
3265
3487
  try {
3266
3488
  await n();
3267
3489
  } catch (r) {
3268
- if (r instanceof Y)
3490
+ if (r instanceof ee)
3269
3491
  return t.result();
3270
- if (r instanceof K) {
3492
+ if (r instanceof z) {
3271
3493
  const o = e.clone();
3272
- return _e.capabilityFailure(
3494
+ return Ke.capabilityFailure(
3273
3495
  o,
3274
3496
  r.message ?? null
3275
3497
  );
@@ -3279,29 +3501,29 @@ class X {
3279
3501
  return t.result();
3280
3502
  }
3281
3503
  initializationMarker(e) {
3282
- const n = e.getProperties()?.[Ee.OBJECT_CONTRACTS]?.getProperties()?.initialized ?? null;
3504
+ const n = e.getProperties()?.[Ie.OBJECT_CONTRACTS]?.getProperties()?.initialized ?? null;
3283
3505
  if (!n)
3284
3506
  return null;
3285
- if (!(n instanceof h))
3286
- throw new E(
3507
+ if (!(n instanceof p))
3508
+ throw new y(
3287
3509
  "Initialization Marker must be a BlueNode",
3288
- w.illegalState(
3510
+ v.illegalState(
3289
3511
  "Initialization Marker must be a BlueNode"
3290
3512
  )
3291
3513
  );
3292
- if (n.getType()?.getBlueId() !== ai)
3293
- throw new E(
3514
+ if (n.getType()?.getBlueId() !== Ai)
3515
+ throw new y(
3294
3516
  "Initialization Marker must declare type 'Processing Initialized Marker'",
3295
- w.illegalState(
3517
+ v.illegalState(
3296
3518
  "Initialization Marker must declare type 'Processing Initialized Marker'"
3297
3519
  )
3298
3520
  );
3299
3521
  return n;
3300
3522
  }
3301
3523
  static nodeAt(e, t, n) {
3302
- if (!(e instanceof h))
3524
+ if (!(e instanceof p))
3303
3525
  return null;
3304
- const r = T(t);
3526
+ const r = R(t);
3305
3527
  if (r === "/")
3306
3528
  return e;
3307
3529
  const o = r.slice(1).split("/");
@@ -3313,21 +3535,21 @@ class X {
3313
3535
  continue;
3314
3536
  const c = s.getItems();
3315
3537
  if (c && /^\d+$/.test(a)) {
3316
- const g = Number.parseInt(a, 10);
3317
- s = c[g] ?? null;
3538
+ const d = Number.parseInt(a, 10);
3539
+ s = c[d] ?? null;
3318
3540
  continue;
3319
3541
  }
3320
3542
  const u = s.getProperties();
3321
3543
  if (u && a in u) {
3322
- const g = u[a];
3323
- if (!(g instanceof h))
3544
+ const d = u[a];
3545
+ if (!(d instanceof p))
3324
3546
  return null;
3325
- s = g;
3547
+ s = d;
3326
3548
  continue;
3327
3549
  }
3328
- const d = this.specialSegmentNode(s, a, n);
3329
- if (d !== void 0) {
3330
- s = d;
3550
+ const h = this.specialSegmentNode(s, a, n);
3551
+ if (h !== void 0) {
3552
+ s = h;
3331
3553
  continue;
3332
3554
  }
3333
3555
  return null;
@@ -3337,9 +3559,9 @@ class X {
3337
3559
  static specialSegmentNode(e, t, n) {
3338
3560
  switch (t) {
3339
3561
  case "name":
3340
- return new h().setValue(e.getName() ?? null);
3562
+ return new p().setValue(e.getName() ?? null);
3341
3563
  case "description":
3342
- return new h().setValue(e.getDescription() ?? null);
3564
+ return new p().setValue(e.getDescription() ?? null);
3343
3565
  case "type":
3344
3566
  return e.getType() ?? null;
3345
3567
  case "itemType":
@@ -3349,21 +3571,21 @@ class X {
3349
3571
  case "valueType":
3350
3572
  return e.getValueType() ?? null;
3351
3573
  case "value":
3352
- return new h().setValue(e.getValue() ?? null);
3574
+ return new p().setValue(e.getValue() ?? null);
3353
3575
  case "blue":
3354
3576
  return e.getBlue() ?? null;
3355
- case Ee.OBJECT_CONTRACTS:
3356
- return new h().setContracts(e.getContracts());
3577
+ case Ie.OBJECT_CONTRACTS:
3578
+ return new p().setContracts(e.getContracts());
3357
3579
  case "blueId": {
3358
- const r = e.getBlueId() ?? n?.calculateBlueId?.(e) ?? pt.calculateBlueIdSync(e);
3359
- return new h().setValue(r ?? null);
3580
+ const r = e.getBlueId() ?? n?.calculateBlueId?.(e) ?? Rt.calculateBlueIdSync(e);
3581
+ return new p().setValue(r ?? null);
3360
3582
  }
3361
3583
  default:
3362
3584
  return;
3363
3585
  }
3364
3586
  }
3365
3587
  }
3366
- class ui {
3588
+ class xi {
3367
3589
  constructor(e, t, n, r, o, s) {
3368
3590
  this.execution = e, this.bundle = t, this.scopePathValue = n, this.eventNode = r, this.allowTerminatedWork = o, this.allowReservedMutation = s;
3369
3591
  }
@@ -3399,7 +3621,7 @@ class ui {
3399
3621
  this.shouldSkipTerminatedWork() || this.execution.runtime().addGas(e);
3400
3622
  }
3401
3623
  throwFatal(e) {
3402
- throw new E(e, w.runtimeFatal(e));
3624
+ throw new y(e, v.runtimeFatal(e));
3403
3625
  }
3404
3626
  resolvePointer(e) {
3405
3627
  return this.execution.resolvePointer(this.scopePathValue, e);
@@ -3418,7 +3640,7 @@ class ui {
3418
3640
  if (!e)
3419
3641
  return !1;
3420
3642
  try {
3421
- return X.nodeAt(
3643
+ return te.nodeAt(
3422
3644
  this.execution.runtime().document(),
3423
3645
  e,
3424
3646
  {
@@ -3430,14 +3652,14 @@ class ui {
3430
3652
  }
3431
3653
  }
3432
3654
  documentNodeAt(e) {
3433
- const t = X.nodeAt(
3655
+ const t = te.nodeAt(
3434
3656
  this.execution.runtime().document(),
3435
3657
  e,
3436
3658
  {
3437
3659
  calculateBlueId: (n) => this.execution.runtime().blue().calculateBlueIdSync(n)
3438
3660
  }
3439
3661
  );
3440
- return t instanceof h ? t : null;
3662
+ return t instanceof p ? t : null;
3441
3663
  }
3442
3664
  async terminateGracefully(e) {
3443
3665
  await this.execution.enterGracefulTermination(
@@ -3457,16 +3679,16 @@ class ui {
3457
3679
  return !this.allowTerminatedWork && this.execution.isScopeInactive(this.scopePathValue);
3458
3680
  }
3459
3681
  }
3460
- const di = new ft({
3461
- repositories: [mt]
3682
+ const _i = new Pt({
3683
+ repositories: [Mt]
3462
3684
  });
3463
- class hi {
3685
+ class Li {
3464
3686
  blue;
3465
3687
  registryRef;
3466
3688
  contractLoaderRef;
3467
3689
  engine;
3468
3690
  constructor(e) {
3469
- this.registryRef = e?.registry ?? ne.create().registerDefaults().build(), this.blue = e?.blue ?? di, this.contractLoaderRef = new dr(this.registryRef, this.blue), this.engine = new X(
3691
+ this.registryRef = e?.registry ?? oe.create().registerDefaults().build(), this.blue = e?.blue ?? _i, this.contractLoaderRef = new Ur(this.registryRef, this.blue), this.engine = new te(
3470
3692
  this.contractLoaderRef,
3471
3693
  this.registryRef,
3472
3694
  this.blue
@@ -3499,14 +3721,14 @@ class hi {
3499
3721
  return this.contractLoaderRef;
3500
3722
  }
3501
3723
  static builder() {
3502
- return new pi();
3724
+ return new Fi();
3503
3725
  }
3504
3726
  }
3505
- class pi {
3727
+ class Fi {
3506
3728
  contractRegistry;
3507
3729
  blueInstance;
3508
3730
  constructor() {
3509
- this.contractRegistry = ne.create().registerDefaults().build();
3731
+ this.contractRegistry = oe.create().registerDefaults().build();
3510
3732
  }
3511
3733
  withRegistry(e) {
3512
3734
  return this.contractRegistry = e, this;
@@ -3518,16 +3740,16 @@ class pi {
3518
3740
  return this.blueInstance = e, this;
3519
3741
  }
3520
3742
  build() {
3521
- return new hi({
3743
+ return new Li({
3522
3744
  registry: this.contractRegistry,
3523
3745
  blue: this.blueInstance
3524
3746
  });
3525
3747
  }
3526
3748
  }
3527
- class dt {
3749
+ class St {
3528
3750
  process(e, t) {
3529
3751
  const n = t.getValue();
3530
- if (G(n)) {
3752
+ if (Y(n)) {
3531
3753
  const r = t.clone();
3532
3754
  return r.setValue(n), r.setProperties(void 0), r.setItems(void 0), r.setType(void 0), r;
3533
3755
  }
@@ -3538,123 +3760,124 @@ class dt {
3538
3760
  */
3539
3761
  postProcess(e, t) {
3540
3762
  const n = t.getValue();
3541
- if (G(n) && e.getValue() !== n && n !== void 0) {
3763
+ if (Y(n) && e.getValue() !== n && n !== void 0) {
3542
3764
  const r = e.clone();
3543
3765
  return r.setValue(n), r;
3544
3766
  }
3545
3767
  return e;
3546
3768
  }
3547
3769
  }
3548
- const Di = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3770
+ const ao = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3549
3771
  __proto__: null,
3550
- ExpressionPreserver: dt
3772
+ ExpressionPreserver: St
3551
3773
  }, Symbol.toStringTag, { value: "Module" }));
3552
- function Bi() {
3553
- return new O.SequentialMergingProcessor([
3554
- new O.ValuePropagator(),
3555
- new dt(),
3556
- new O.TypeAssigner(),
3557
- new O.ListProcessor(),
3558
- new O.DictionaryProcessor(),
3559
- new O.BasicTypesVerifier()
3774
+ function co() {
3775
+ return new L.SequentialMergingProcessor([
3776
+ new L.ValuePropagator(),
3777
+ new St(),
3778
+ new L.TypeAssigner(),
3779
+ new L.ListProcessor(),
3780
+ new L.DictionaryProcessor(),
3781
+ new L.BasicTypesVerifier()
3560
3782
  ]);
3561
3783
  }
3562
3784
  export {
3563
- Jn as ChannelBinding,
3564
- yr as ChannelRunner,
3565
- gr as CheckpointManager,
3566
- mr as CheckpointRecord,
3567
- Ye as CodeBlockEvaluationError,
3568
- L as ContractBundle,
3569
- Qn as ContractBundleBuilder,
3570
- dr as ContractLoader,
3571
- Tn as ContractProcessorRegistry,
3572
- ne as ContractProcessorRegistryBuilder,
3573
- _e as DocumentProcessingResult,
3574
- si as DocumentProcessingRuntime,
3575
- hi as DocumentProcessor,
3576
- pi as DocumentProcessorBuilder,
3577
- xr as EmissionRegistry,
3578
- oi as GasMeter,
3579
- Gn as HandlerBinding,
3580
- N as KEY_CHECKPOINT,
3581
- Fe as KEY_EMBEDDED,
3582
- Ue as KEY_INITIALIZED,
3583
- ze as KEY_TERMINATED,
3584
- Di as MergingProcessors,
3585
- $e as PROCESSOR_MANAGED_CHANNEL_BLUE_IDS,
3586
- Or as PatchEngine,
3587
- Pi as ProcessorContractConstants,
3588
- X as ProcessorEngine,
3589
- w as ProcessorErrors,
3590
- li as ProcessorExecution,
3591
- ui as ProcessorExecutionContext,
3592
- E as ProcessorFatalError,
3593
- Mi as ProcessorPointerConstants,
3594
- pe as QuickJSEvaluator,
3595
- Ve as RELATIVE_CHECKPOINT,
3596
- x as RELATIVE_CONTRACTS,
3597
- bt as RELATIVE_EMBEDDED,
3598
- ce as RELATIVE_INITIALIZED,
3599
- He as RELATIVE_TERMINATED,
3600
- de as RESERVED_CONTRACT_KEYS,
3601
- Y as RunTerminationError,
3602
- kr as ScopeExecutor,
3603
- Lr as ScopeRuntimeContext,
3604
- Rr as TerminationService,
3605
- ki as andThen,
3606
- Ge as canonicalSignature,
3607
- ve as canonicalSize,
3608
- F as channelContractBaseSchema,
3609
- en as channelEventCheckpointSchema,
3610
- Ft as containsExpression,
3611
- fe as contractBaseSchema,
3612
- Bi as createDefaultMergingProcessor,
3613
- tt as createPicomatchShouldResolve,
3614
- dn as documentAnchorsMarkerSchema,
3615
- fn as documentLinksMarkerSchema,
3616
- Vt as documentUpdateChannelSchema,
3617
- Kt as embeddedNodeChannelSchema,
3618
- yt as err,
3619
- et as evaluateQuickJSExpression,
3620
- Ut as extractExpressionContent,
3621
- rt as handlerContractBaseSchema,
3622
- nn as initializationMarkerSchema,
3623
- Si as isErr,
3624
- G as isExpression,
3625
- Ci as isOk,
3626
- he as isProcessorManagedChannelBlueId,
3627
- vt as isReservedContractKey,
3628
- Ni as joinRelativePointers,
3629
- Oi as jsonPatchSchema,
3630
- jt as lifecycleChannelSchema,
3631
- vi as map,
3632
- bi as mapErr,
3633
- R as markerContractBaseSchema,
3634
- Ri as match,
3635
- gn as myosParticipantsOrchestrationMarkerSchema,
3636
- En as myosSessionInteractionMarkerSchema,
3637
- Xt as myosTimelineChannelSchema,
3638
- Cn as myosWorkerAgencyMarkerSchema,
3639
- T as normalizePointer,
3640
- C as normalizeScope,
3641
- gt as ok,
3642
- cn as operationMarkerSchema,
3643
- on as processEmbeddedMarkerSchema,
3644
- an as processingTerminatedMarkerSchema,
3645
- qe as relativeCheckpointLastEvent,
3646
- je as relativeCheckpointLastSignature,
3647
- Z as relativeContractsEntry,
3648
- kt as relativizePointer,
3649
- Q as resolveNodeExpressions,
3650
- k as resolvePointer,
3651
- zt as resolveTemplateString,
3652
- bn as sequentialWorkflowOperationSchema,
3653
- Sn as sequentialWorkflowSchema,
3654
- Ai as sequentialWorkflowStepSchema,
3655
- Ce as stripSlashes,
3656
- Qt as timelineChannelSchema,
3657
- Gt as triggeredEventChannelSchema,
3658
- Ti as unwrapOr,
3659
- Ii as unwrapOrElse
3785
+ Sr as ChannelBinding,
3786
+ Wr as ChannelRunner,
3787
+ Kr as CheckpointManager,
3788
+ Hr as CheckpointRecord,
3789
+ ot as CodeBlockEvaluationError,
3790
+ V as ContractBundle,
3791
+ wr as ContractBundleBuilder,
3792
+ Ur as ContractLoader,
3793
+ qn as ContractProcessorRegistry,
3794
+ oe as ContractProcessorRegistryBuilder,
3795
+ Ke as DocumentProcessingResult,
3796
+ Oi as DocumentProcessingRuntime,
3797
+ Li as DocumentProcessor,
3798
+ Fi as DocumentProcessorBuilder,
3799
+ ui as EmissionRegistry,
3800
+ Ni as GasMeter,
3801
+ vr as HandlerBinding,
3802
+ A as KEY_CHECKPOINT,
3803
+ We as KEY_EMBEDDED,
3804
+ Ge as KEY_INITIALIZED,
3805
+ qe as KEY_TERMINATED,
3806
+ ao as MergingProcessors,
3807
+ je as PROCESSOR_MANAGED_CHANNEL_BLUE_IDS,
3808
+ oi as PatchEngine,
3809
+ no as ProcessorContractConstants,
3810
+ te as ProcessorEngine,
3811
+ v as ProcessorErrors,
3812
+ Bi as ProcessorExecution,
3813
+ xi as ProcessorExecutionContext,
3814
+ y as ProcessorFatalError,
3815
+ ro as ProcessorPointerConstants,
3816
+ Ce as QuickJSEvaluator,
3817
+ Qe as RELATIVE_CHECKPOINT,
3818
+ H as RELATIVE_CONTRACTS,
3819
+ Lt as RELATIVE_EMBEDDED,
3820
+ de as RELATIVE_INITIALIZED,
3821
+ Je as RELATIVE_TERMINATED,
3822
+ Ee as RESERVED_CONTRACT_KEYS,
3823
+ ee as RunTerminationError,
3824
+ Yr as ScopeExecutor,
3825
+ li as ScopeRuntimeContext,
3826
+ ti as TerminationService,
3827
+ Yi as andThen,
3828
+ nt as canonicalSignature,
3829
+ Me as canonicalSize,
3830
+ _ as channelContractBaseSchema,
3831
+ kn as channelEventCheckpointSchema,
3832
+ dt as compositeTimelineChannelSchema,
3833
+ sn as containsExpression,
3834
+ Se as contractBaseSchema,
3835
+ co as createDefaultMergingProcessor,
3836
+ ct as createPicomatchShouldResolve,
3837
+ Dn as documentAnchorsMarkerSchema,
3838
+ _n as documentLinksMarkerSchema,
3839
+ hn as documentUpdateChannelSchema,
3840
+ pn as embeddedNodeChannelSchema,
3841
+ Ot as err,
3842
+ at as evaluateQuickJSExpression,
3843
+ an as extractExpressionContent,
3844
+ ut as handlerContractBaseSchema,
3845
+ In as initializationMarkerSchema,
3846
+ Ji as isErr,
3847
+ Y as isExpression,
3848
+ ji as isOk,
3849
+ ye as isProcessorManagedChannelBlueId,
3850
+ _t as isReservedContractKey,
3851
+ io as joinRelativePointers,
3852
+ oo as jsonPatchSchema,
3853
+ fn as lifecycleChannelSchema,
3854
+ Qi as map,
3855
+ Xi as mapErr,
3856
+ N as markerContractBaseSchema,
3857
+ to as match,
3858
+ Fn as myosParticipantsOrchestrationMarkerSchema,
3859
+ $n as myosSessionInteractionMarkerSchema,
3860
+ Sn as myosTimelineChannelSchema,
3861
+ Vn as myosWorkerAgencyMarkerSchema,
3862
+ R as normalizePointer,
3863
+ k as normalizeScope,
3864
+ Nt as ok,
3865
+ Nn as operationMarkerSchema,
3866
+ Rn as processEmbeddedMarkerSchema,
3867
+ Mn as processingTerminatedMarkerSchema,
3868
+ Ze as relativeCheckpointLastEvent,
3869
+ et as relativeCheckpointLastSignature,
3870
+ ne as relativeContractsEntry,
3871
+ Ft as relativizePointer,
3872
+ Z as resolveNodeExpressions,
3873
+ T as resolvePointer,
3874
+ cn as resolveTemplateString,
3875
+ Wn as sequentialWorkflowOperationSchema,
3876
+ Hn as sequentialWorkflowSchema,
3877
+ so as sequentialWorkflowStepSchema,
3878
+ Re as stripSlashes,
3879
+ yn as timelineChannelSchema,
3880
+ En as triggeredEventChannelSchema,
3881
+ Zi as unwrapOr,
3882
+ eo as unwrapOrElse
3660
3883
  };