@blue-labs/document-processor 3.1.0 → 3.3.0

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