@voltro/protocol 0.75.0 → 0.77.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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as ee, K as te, L as ne, M as re, N as ie, O as ae, P as oe, Q as se, R as ce, S as le, T as ue, U as de, V as fe, W as pe, X as me, Y as he, Z as ge, _ as u, a as _e, b as d, c as ve, d as ye, f as be, g as xe, h as Se, i as Ce, j as we, k as Te, l as Ee, m as De, n as Oe, o as f, p as ke, q as Ae, r as je, s as Me, t as Ne, u as Pe, v as Fe, w as Ie, x as Le, y as Re, z as ze } from "./scopes-Dj7KCJab.js";
1
+ import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as ee, K as te, L as ne, M as re, N as ie, O as ae, P as oe, Q as se, R as ce, S as le, T as ue, U as de, V as fe, W as pe, X as me, Y as he, Z as ge, _ as u, a as _e, b as d, c as ve, d as ye, f as be, g as xe, h as Se, i as Ce, j as we, k as Te, l as Ee, m as De, n as Oe, o as f, p as ke, q as Ae, r as je, s as Me, t as Ne, u as Pe, v as Fe, w as Ie, x as Le, y as Re, z as ze } from "./scopes-D2dnEr4U.js";
2
2
  import { C as Be, D as Ve, E as He, S as Ue, T as We, _ as Ge, a as Ke, b as qe, c as Je, d as Ye, f as Xe, g as Ze, h as Qe, i as $e, l as et, m as tt, n as nt, o as rt, p as it, r as at, s as ot, t as st, u as ct, v as lt, w as ut, x as dt, y as ft } from "./restFormat-ChSVyufA.js";
3
3
  import { Context as pt, Layer as mt, Schema as p } from "effect";
4
4
  import { Rpc as m } from "@effect/rpc";
@@ -252,14 +252,14 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
252
252
  toString: () => n
253
253
  });
254
254
  return T.set(e, r), r;
255
- }, Ut = (e) => typeof e == "object" && !!e && e.kind === "reactivity-channel", Wt = (e) => e.startsWith(w), Gt = () => new Set([...T.values()].map((e) => e.key)), E = (e) => Ut(e) ? e.key : e, D = (e) => e === void 0 ? [] : Array.isArray(e) ? e.map(E) : [E(e)], O = (e) => e === void 0 ? void 0 : Array.isArray(e) ? e.map(E) : E(e), Kt = (e) => {
255
+ }, Ut = (e) => typeof e == "object" && !!e && e.kind === "reactivity-channel", Wt = (e) => e.startsWith(w), Gt = () => new Set([...T.values()].map((e) => e.key)), E = (e) => Ut(e) ? e.key : e, Kt = (e) => e === void 0 ? [] : Array.isArray(e) ? e.map(E) : [E(e)], qt = (e) => e === void 0 ? void 0 : Array.isArray(e) ? e.map(E) : E(e), Jt = (e) => {
256
256
  let t = Gt(), n = [];
257
- for (let r of e) for (let e of D(r.source)) Wt(e) && !t.has(e) && n.push({
257
+ for (let r of e) for (let e of Kt(r.source)) Wt(e) && !t.has(e) && n.push({
258
258
  procedure: r.name,
259
259
  key: e
260
260
  });
261
261
  return n;
262
- }, qt = (e, t) => {
262
+ }, Yt = (e, t) => {
263
263
  let n = e?.injectExternalChange;
264
264
  return n !== void 0 && (n.call(e, {
265
265
  table: t.key,
@@ -268,8 +268,8 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
268
268
  old: {},
269
269
  origin: "inline"
270
270
  }), !0);
271
- }, Jt = (e) => e.internal !== !0, k = (e) => {
272
- if (Yt(e), e.idempotencyScope !== void 0 && e.idempotencyScope !== "subject" && e.idempotencyScope !== "connection") throw Error(`${e.name}: idempotencyScope must be 'subject' or 'connection'`);
271
+ }, Xt = (e) => e.internal !== !0, D = (e) => {
272
+ if (Zt(e), e.idempotencyScope !== void 0 && e.idempotencyScope !== "subject" && e.idempotencyScope !== "connection") throw Error(`${e.name}: idempotencyScope must be 'subject' or 'connection'`);
273
273
  let t = e.serialize;
274
274
  if (t !== void 0) {
275
275
  if (typeof t.key != "function") throw Error(`${e.name}: serialize.key must be a function of the input`);
@@ -293,7 +293,7 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
293
293
  let r = [e.publicApi === void 0 ? void 0 : "publicApi", e.exposeAsTool === void 0 ? void 0 : "exposeAsTool"].filter((e) => e !== void 0);
294
294
  if (r.length === 0) return e;
295
295
  throw Error(`${e.name}: \`internal: true\` cannot be combined with ${r.map((e) => `\`${e}\``).join(" or ")}. \`internal\` takes the procedure OFF the wire; those put it back ON a different one (${r.includes("publicApi") ? "a REST route" : "an agent tool"}), and that surface is projected without consulting the flag — so the procedure would be unreachable from your client and reachable from the internet. Drop \`internal: true\` if the wider surface is intended, or remove the ${r.join(" / ")} annotation if it is not.`);
296
- }, Yt = (e) => {
296
+ }, Zt = (e) => {
297
297
  let t = e.requiresApproval;
298
298
  if (t !== void 0) {
299
299
  if (!Array.isArray(t.approvers) || t.approvers.length === 0) throw Error(`${e.name}: \`requiresApproval.approvers\` is empty, so NOBODY can approve this\n procedure and every call would park forever. Name the scope(s) an approver must hold
@@ -303,28 +303,28 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
303
303
  human from every other, and the second-pair-of-eyes control would enforce nothing.
304
304
  Give the procedure a \`guards:\` decision, or drop \`requiresApproval\`.`);
305
305
  }
306
- }, Xt = (e) => e.action !== void 0 && e.resourceType !== void 0, Zt = (e) => e.authenticated === !0, Qt = (e) => e.openAccess !== void 0 || e.guards !== void 0 && e.guards.length > 0, A = (e, t, n) => {
306
+ }, Qt = (e) => e.action !== void 0 && e.resourceType !== void 0, $t = (e) => e.authenticated === !0, en = (e) => e.openAccess !== void 0 || e.guards !== void 0 && e.guards.length > 0, O = (e, t, n) => {
307
307
  if (n === void 0) return t;
308
308
  if (n.trim() === "") throw Error(`${e}: \`openAccess\` needs a REASON, not an empty string. It is the sentence a\n reviewer reads to decide whether this procedure should really be callable
309
309
  without an authorization check — e.g. \`openAccess: 'public pricing, no caller data'\`.`);
310
310
  if (t !== void 0 && t.length > 0) throw Error(`${e}: \`openAccess\` and \`guards\` are two different access decisions, so\n declaring both says the procedure is protected AND open. Keep the guards if a
311
311
  caller must hold a scope; drop them if anyone may call it.`);
312
312
  return [d(n.trim())];
313
- }, j = (e) => k({
313
+ }, k = (e) => D({
314
314
  kind: "query",
315
315
  name: e.name,
316
316
  input: e.input,
317
317
  output: e.output,
318
318
  error: e.error ?? p.Never,
319
- source: O(e.source),
319
+ source: qt(e.source),
320
320
  cache: e.cache,
321
- guards: A(e.name, e.guards, e.openAccess),
321
+ guards: O(e.name, e.guards, e.openAccess),
322
322
  openAccess: e.openAccess,
323
323
  publicApi: e.publicApi,
324
324
  exposeAsTool: e.exposeAsTool,
325
325
  internal: e.internal,
326
326
  overridesPlugin: e.overridesPlugin
327
- }), M = (e) => k({
327
+ }), A = (e) => D({
328
328
  kind: "mutation",
329
329
  name: e.name,
330
330
  input: e.input,
@@ -333,20 +333,20 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
333
333
  ...e.idempotencyScope === void 0 ? {} : { idempotencyScope: e.idempotencyScope },
334
334
  ...e.serialize === void 0 ? {} : { serialize: e.serialize },
335
335
  target: e.target,
336
- guards: A(e.name, e.guards, e.openAccess),
336
+ guards: O(e.name, e.guards, e.openAccess),
337
337
  openAccess: e.openAccess,
338
338
  publicApi: e.publicApi,
339
339
  exposeAsTool: e.exposeAsTool,
340
340
  requiresApproval: e.requiresApproval,
341
341
  internal: e.internal,
342
342
  overridesPlugin: e.overridesPlugin
343
- }), N = (e) => k({
343
+ }), j = (e) => D({
344
344
  kind: "action",
345
345
  name: e.name,
346
346
  input: e.input,
347
347
  output: e.output,
348
348
  error: e.error ?? p.Never,
349
- guards: A(e.name, e.guards, e.openAccess),
349
+ guards: O(e.name, e.guards, e.openAccess),
350
350
  openAccess: e.openAccess,
351
351
  source: e.source,
352
352
  target: e.target,
@@ -355,7 +355,7 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
355
355
  requiresApproval: e.requiresApproval,
356
356
  internal: e.internal,
357
357
  overridesPlugin: e.overridesPlugin
358
- }), $t = (e) => k({
358
+ }), tn = (e) => D({
359
359
  kind: "stream",
360
360
  name: e.name,
361
361
  input: e.input,
@@ -363,47 +363,47 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
363
363
  error: e.error ?? p.Never,
364
364
  internal: e.internal,
365
365
  overridesPlugin: e.overridesPlugin,
366
- guards: A(e.name, e.guards, e.openAccess),
366
+ guards: O(e.name, e.guards, e.openAccess),
367
367
  openAccess: e.openAccess
368
- }), P = (e, t) => t && t.length > 0 ? p.Union(e, ...t) : e, F = (e) => e !== void 0 && e.some((e) => !u(e)), en = (e, t) => F(t) ? p.Union(e, f, l) : e, tn = (e) => p.Union(e, Tt), nn = (e) => p.Union(e, Dt, Ot), rn = (e, t) => t === void 0 ? e : p.Union(e, It), I = (e, t) => {
368
+ }), M = (e, t) => t && t.length > 0 ? p.Union(e, ...t) : e, N = (e) => e !== void 0 && e.some((e) => !u(e)), nn = (e, t) => N(t) ? p.Union(e, f, l) : e, rn = (e) => p.Union(e, Tt), an = (e) => p.Union(e, Dt, Ot), on = (e, t) => t === void 0 ? e : p.Union(e, It), P = (e, t) => {
369
369
  if (t === "stream") return e.error;
370
- let n = en(e.error, e.guards);
370
+ let n = nn(e.error, e.guards);
371
371
  if (t === "query") return n;
372
- let r = t === "mutation" ? p.Union(tn(n), dt, ht) : n;
373
- return rn(nn(t === "mutation" && e.idempotencyScope === "connection" ? p.Union(r, qe) : r), e.requiresApproval);
374
- }, an = (e, t) => P(en(e.errorSchema, e.guards), t), on = (e, t) => ({
372
+ let r = t === "mutation" ? p.Union(rn(n), dt, ht) : n;
373
+ return on(an(t === "mutation" && e.idempotencyScope === "connection" ? p.Union(r, qe) : r), e.requiresApproval);
374
+ }, sn = (e, t) => M(nn(e.errorSchema, e.guards), t), cn = (e, t) => ({
375
375
  ...e,
376
376
  name: t
377
- }), sn = (e, t) => m.make(e.name, {
378
- payload: x(e.input, e.name, F(e.guards)),
377
+ }), ln = (e, t) => m.make(e.name, {
378
+ payload: x(e.input, e.name, N(e.guards)),
379
379
  success: y(e.output),
380
- error: P(I(e, "query"), t),
380
+ error: M(P(e, "query"), t),
381
381
  stream: !0
382
- }), cn = (e, t) => m.make(e.name, {
383
- payload: x(e.input, e.name, F(e.guards)),
382
+ }), un = (e, t) => m.make(e.name, {
383
+ payload: x(e.input, e.name, N(e.guards)),
384
384
  success: e.output,
385
- error: P(I(e, "mutation"), t)
386
- }), ln = (e, t) => m.make(e.name, {
387
- payload: x(e.input, e.name, F(e.guards)),
385
+ error: M(P(e, "mutation"), t)
386
+ }), dn = (e, t) => m.make(e.name, {
387
+ payload: x(e.input, e.name, N(e.guards)),
388
388
  success: e.output,
389
- error: P(I(e, "action"), t)
390
- }), un = (e, t) => m.make(e.name, {
391
- payload: x(e.input, e.name, F(e.guards)),
389
+ error: M(P(e, "action"), t)
390
+ }), fn = (e, t) => m.make(e.name, {
391
+ payload: x(e.input, e.name, N(e.guards)),
392
392
  success: e.element,
393
- error: P(e.error, t),
393
+ error: M(e.error, t),
394
394
  stream: !0
395
- }), dn = (e) => {
395
+ }), pn = (e) => {
396
396
  if (typeof e != "object" || !e) return;
397
397
  let t = e._tag;
398
398
  return typeof t == "string" ? t : void 0;
399
- }, fn = (e) => {
399
+ }, mn = (e) => {
400
400
  switch (e.kind) {
401
- case "query": return sn(e);
402
- case "mutation": return cn(e);
403
- case "action": return ln(e);
404
- case "stream": return un(e);
401
+ case "query": return ln(e);
402
+ case "mutation": return un(e);
403
+ case "action": return dn(e);
404
+ case "stream": return fn(e);
405
405
  }
406
- }, pn = (e) => {
406
+ }, hn = (e) => {
407
407
  let t = e.input, n = t === void 0 ? {} : { input: t }, r = e.output, i = r === void 0 ? {} : { output: r };
408
408
  if (e.kind === "query") return {
409
409
  kind: "query",
@@ -449,7 +449,7 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
449
449
  ..."relations" in e && e.relations !== void 0 ? { relations: e.relations } : {}
450
450
  }))
451
451
  };
452
- }, mn = 7500, hn = (e) => typeof e == "object" && !!e && e.kind === "event", gn = (e) => {
452
+ }, gn = 7500, _n = (e) => typeof e == "object" && !!e && e.kind === "event", vn = (e) => {
453
453
  if (e.name.length === 0) throw Error("defineEvent: `name` must not be empty");
454
454
  if (/\s/.test(e.name)) throw Error(`defineEvent("${e.name}"): \`name\` must not contain whitespace.\n The name is used as a broker subject segment. NATS refuses a subject with
455
455
  whitespace and delivers nothing — silently, and only on that broker, so an
@@ -484,62 +484,62 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
484
484
  webhook: e.webhook,
485
485
  delivery: e.delivery
486
486
  };
487
- }, _n = (e) => p.Struct({
487
+ }, yn = (e) => p.Struct({
488
488
  _tag: p.Literal("event"),
489
489
  origin: p.String,
490
490
  n: p.Number,
491
491
  emittedAt: p.Number,
492
492
  payload: e
493
- }), vn = p.Struct({
493
+ }), bn = p.Struct({
494
494
  _tag: p.Literal("gap"),
495
495
  missed: p.Number,
496
496
  reason: p.Literal("buffer", "resume")
497
- }), yn = p.Struct({ _tag: p.Literal("attached") }), bn = (e) => p.Union(yn, _n(e), vn), xn = p.Struct({
497
+ }), xn = p.Struct({ _tag: p.Literal("attached") }), Sn = (e) => p.Union(xn, yn(e), bn), Cn = p.Struct({
498
498
  origin: p.String,
499
499
  n: p.Number
500
- }), Sn = (e) => p.Struct({
500
+ }), wn = (e) => p.Struct({
501
501
  key: e,
502
- resume: p.optional(p.Array(xn))
503
- }), Cn = (e, t) => {
502
+ resume: p.optional(p.Array(Cn))
503
+ }), Tn = (e, t) => {
504
504
  let n = e.guards !== void 0 && e.guards.some((e) => !u(e)) ? p.Union(f, l) : p.Never, r = t && t.length > 0 ? p.Union(n, ...t) : n;
505
505
  return m.make(e.name, {
506
- payload: x(Sn(e.key), e.name, F(e.guards)),
507
- success: bn(e.payload),
506
+ payload: x(wn(e.key), e.name, N(e.guards)),
507
+ success: Sn(e.payload),
508
508
  error: r,
509
509
  stream: !0
510
510
  });
511
- }, wn = class extends p.TaggedError()("EventPayloadInvalid", {
511
+ }, En = class extends p.TaggedError()("EventPayloadInvalid", {
512
512
  event: p.String,
513
513
  message: p.String
514
- }) {}, Tn = class extends p.TaggedError()("EventKeyInvalid", {
514
+ }) {}, Dn = class extends p.TaggedError()("EventKeyInvalid", {
515
515
  event: p.String,
516
516
  message: p.String
517
- }) {}, En = class extends p.TaggedError()("EventPayloadTooLarge", {
517
+ }) {}, On = class extends p.TaggedError()("EventPayloadTooLarge", {
518
518
  event: p.String,
519
519
  bytes: p.Number,
520
520
  limit: p.Number
521
- }) {}, Dn = (e) => {
521
+ }) {}, kn = (e) => {
522
522
  if (typeof e != "object" || !e) return JSON.stringify(e) ?? "null";
523
523
  let t = Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t));
524
524
  return JSON.stringify(t);
525
- }, On = "\0", kn = (e, t, n) => [
525
+ }, An = "\0", jn = (e, t, n) => [
526
526
  e ?? "~",
527
527
  t,
528
- Dn(n)
529
- ].join("\0"), An = (e) => {
528
+ kn(n)
529
+ ].join("\0"), Mn = (e) => {
530
530
  let [t = "~", n = "", r = ""] = e.split("\0");
531
531
  return {
532
532
  tenantId: t === "~" ? null : t,
533
533
  event: n,
534
534
  key: r
535
535
  };
536
- }, jn = (e) => e.split("\0").join(" · "), L = Symbol.for("@voltro/protocol/workflow-access"), Mn = {
536
+ }, Nn = (e) => e.split("\0").join(" · "), F = Symbol.for("@voltro/protocol/workflow-access"), Pn = {
537
537
  guards: void 0,
538
538
  openAccess: void 0,
539
539
  internal: !1,
540
540
  controls: void 0,
541
541
  controlsOpenAccess: void 0
542
- }, Nn = (e, t) => {
542
+ }, Fn = (e, t) => {
543
543
  let n = t.guards;
544
544
  if (n !== void 0 && n.length === 0) throw Error(`workflow("${e}"): \`guards: []\` is empty, so it enforces nothing —\n but it reads at the call site as if the start were protected. Omit the field
545
545
  and decide with \`openAccess\` or \`internal\`, or list the scopes that may start it.`);
@@ -571,17 +571,17 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
571
571
  controls: i === void 0 ? r : [d(i.trim())],
572
572
  controlsOpenAccess: i?.trim()
573
573
  };
574
- }, Pn = (e, t) => {
575
- Object.defineProperty(e, L, {
574
+ }, In = (e, t) => {
575
+ Object.defineProperty(e, F, {
576
576
  value: t,
577
577
  enumerable: !1
578
578
  });
579
- }, R = (e) => {
580
- if (typeof e != "object" || !e) return Mn;
581
- let t = e[L];
582
- return t === void 0 ? Mn : t;
583
- }, Fn = (e) => {
584
- let t = R(e);
579
+ }, I = (e) => {
580
+ if (typeof e != "object" || !e) return Pn;
581
+ let t = e[F];
582
+ return t === void 0 ? Pn : t;
583
+ }, Ln = (e) => {
584
+ let t = I(e);
585
585
  return {
586
586
  name: e.name,
587
587
  internal: t.internal,
@@ -589,20 +589,20 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
589
589
  openAccess: t.openAccess,
590
590
  controls: t.controls
591
591
  };
592
- }, In = (e) => e, Ln = (e) => e, Rn = (e) => {
592
+ }, Rn = (e) => e, zn = (e) => e, Bn = (e) => {
593
593
  let t = e.alias?.trim(), n = e.instance?.trim(), r = t !== void 0 && t !== "" ? t : e.base;
594
594
  return n !== void 0 && n !== "" ? `${r}#${n}` : r;
595
- }, zn = (e) => {
595
+ }, Vn = (e) => {
596
596
  if (e.length !== 0) return (t, n) => e.reduceRight((e, t) => t(e, n), t);
597
- }, Bn = (e, t) => {
597
+ }, Hn = (e, t) => {
598
598
  let n = pt.GenericTag(e);
599
599
  return {
600
600
  Tag: n,
601
601
  Live: mt.succeed(n, t)
602
602
  };
603
- }, Vn = (e, t, n) => {
603
+ }, Un = (e, t, n) => {
604
604
  if (!t) return { ok: !0 };
605
- let r = n === void 0 ? null : z(n);
605
+ let r = n === void 0 ? null : L(n);
606
606
  if (!r) return {
607
607
  ok: !0,
608
608
  unverified: `plugin "${e}" requires framework ${t}, but the running framework version is ${n === void 0 ? "unknown" : `unreadable ("${n}")`} — not checked.`
@@ -610,12 +610,12 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
610
610
  let i = t.trim();
611
611
  if (i === "*" || i === "") return { ok: !0 };
612
612
  let a = i.split(/\s+/).filter((e) => e.length > 0);
613
- for (let i of a) if (!Hn(i, r)) return {
613
+ for (let i of a) if (!Wn(i, r)) return {
614
614
  ok: !1,
615
615
  reason: `plugin "${e}" requires framework ${t}, running ${n}`
616
616
  };
617
617
  return { ok: !0 };
618
- }, z = (e) => {
618
+ }, L = (e) => {
619
619
  let t = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9a-zA-Z.-]+))?$/.exec(e.trim());
620
620
  return t ? {
621
621
  major: Number(t[1]),
@@ -623,56 +623,56 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
623
623
  patch: Number(t[3]),
624
624
  pre: t[4] ?? ""
625
625
  } : null;
626
- }, B = (e, t) => e.major === t.major ? e.minor === t.minor ? e.patch === t.patch ? e.pre && !t.pre ? -1 : !e.pre && t.pre ? 1 : e.pre && t.pre ? e.pre < t.pre ? -1 : +(e.pre > t.pre) : 0 : e.patch - t.patch : e.minor - t.minor : e.major - t.major, Hn = (e, t) => {
626
+ }, R = (e, t) => e.major === t.major ? e.minor === t.minor ? e.patch === t.patch ? e.pre && !t.pre ? -1 : !e.pre && t.pre ? 1 : e.pre && t.pre ? e.pre < t.pre ? -1 : +(e.pre > t.pre) : 0 : e.patch - t.patch : e.minor - t.minor : e.major - t.major, Wn = (e, t) => {
627
627
  if (e === "*") return !0;
628
628
  if (e.startsWith("^")) {
629
- let n = z(e.slice(1));
630
- return !n || t.major !== n.major ? !1 : B(t, n) >= 0;
629
+ let n = L(e.slice(1));
630
+ return !n || t.major !== n.major ? !1 : R(t, n) >= 0;
631
631
  }
632
632
  if (e.startsWith("~")) {
633
- let n = z(e.slice(1));
634
- return !n || t.major !== n.major || t.minor !== n.minor ? !1 : B(t, n) >= 0;
633
+ let n = L(e.slice(1));
634
+ return !n || t.major !== n.major || t.minor !== n.minor ? !1 : R(t, n) >= 0;
635
635
  }
636
636
  let n = /^(>=|<=|>|<)(.+)$/.exec(e);
637
637
  if (n) {
638
- let e = n[1], r = z(n[2]);
638
+ let e = n[1], r = L(n[2]);
639
639
  if (!r) return !1;
640
- let i = B(t, r);
640
+ let i = R(t, r);
641
641
  if (e === ">=") return i >= 0;
642
642
  if (e === "<=") return i <= 0;
643
643
  if (e === ">") return i > 0;
644
644
  if (e === "<") return i < 0;
645
645
  }
646
- let r = z(e);
647
- return r ? B(t, r) === 0 : !1;
648
- }, Un = (e) => {
646
+ let r = L(e);
647
+ return r ? R(t, r) === 0 : !1;
648
+ }, Gn = (e) => {
649
649
  let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
650
650
  return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/-([a-zA-Z0-9])/g, (e, t) => t.toUpperCase());
651
- }, Wn = (e) => {
651
+ }, Kn = (e) => {
652
652
  let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
653
653
  return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/#/g, "--").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
654
- }, Gn = Symbol.for("@voltro/protocol/pluginAliases"), V = () => {
655
- let e = globalThis, t = e[Gn];
654
+ }, qn = Symbol.for("@voltro/protocol/pluginAliases"), z = () => {
655
+ let e = globalThis, t = e[qn];
656
656
  if (t instanceof Map) return t;
657
657
  let n = /* @__PURE__ */ new Map();
658
- return e[Gn] = n, n;
659
- }, Kn = (e) => {
660
- let t = V();
658
+ return e[qn] = n, n;
659
+ }, Jn = (e) => {
660
+ let t = z();
661
661
  for (let [n, r] of Object.entries(e)) {
662
662
  if (r === "") continue;
663
663
  let e = t.get(n);
664
664
  e === void 0 ? t.set(n, /* @__PURE__ */ new Set([r])) : e.add(r);
665
665
  }
666
- }, qn = () => {
667
- V().clear();
668
- }, Jn = (e, t) => {
669
- let n = V().get(e);
670
- if (n === void 0 || n.size === 0) return `${Un(e)}.${t}`;
666
+ }, Yn = () => {
667
+ z().clear();
668
+ }, Xn = (e, t) => {
669
+ let n = z().get(e);
670
+ if (n === void 0 || n.size === 0) return `${Gn(e)}.${t}`;
671
671
  if (n.size === 1) return `${[...n][0]}.${t}`;
672
672
  let r = [...n].filter((e) => !e.includes("#"));
673
673
  if (r.length === 1) return `${r[0]}.${t}`;
674
674
  throw Error(`[voltro] ${e} is installed more than once (${[...n].sort().join(", ")}) and no single install is the primary one, so a plugin hook cannot tell which of them it addresses. Call the route by its full tag instead — e.g. useSubscription(api, '${[...n].sort()[0]}.${t}').`);
675
- }, Yn = p.Union(p.Struct({
675
+ }, B = p.Union(p.Struct({
676
676
  kind: p.Literal("dropped"),
677
677
  at: p.Number,
678
678
  retryAfterMs: p.Number
@@ -691,22 +691,22 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
691
691
  kind: p.Literal("abandoned"),
692
692
  at: p.Number,
693
693
  failureId: p.NonEmptyString
694
- })), H = p.Literal("running", "succeeded", "failed", "cancelled", "suspended"), U = p.Struct({
694
+ })), V = p.Literal("running", "succeeded", "failed", "cancelled", "suspended"), H = p.Struct({
695
695
  id: p.String,
696
696
  workflowName: p.String,
697
697
  executionId: p.String,
698
- status: p.Union(H, p.Literal("unknown")),
698
+ status: p.Union(V, p.Literal("unknown")),
699
699
  output: p.optional(p.Unknown),
700
700
  error: p.optional(p.Struct({
701
701
  tag: p.NullOr(p.String),
702
702
  message: p.String
703
703
  }))
704
- }), W = p.Struct({
704
+ }), U = p.Struct({
705
705
  operation: p.Literal("cancel", "resume"),
706
706
  kind: p.Literal("accepted", "confirmed", "unknown", "already-terminal"),
707
707
  requestId: p.NullOr(p.NonEmptyString),
708
- snapshot: U
709
- }).pipe(p.filter((e) => e.kind === "unknown" ? !0 : e.kind === "accepted" ? e.requestId !== null && (e.snapshot.status === "running" || e.snapshot.status === "suspended") : e.kind === "already-terminal" ? e.snapshot.status === "succeeded" || e.snapshot.status === "failed" || e.snapshot.status === "cancelled" : e.operation === "cancel" ? e.snapshot.status === "cancelled" : e.requestId !== null && e.snapshot.status === "running", { message: () => "Workflow control acknowledgement contradicts its observed state or receipt identity" })), G = p.Struct({
708
+ snapshot: H
709
+ }).pipe(p.filter((e) => e.kind === "unknown" ? !0 : e.kind === "accepted" ? e.requestId !== null && (e.snapshot.status === "running" || e.snapshot.status === "suspended") : e.kind === "already-terminal" ? e.snapshot.status === "succeeded" || e.snapshot.status === "failed" || e.snapshot.status === "cancelled" : e.operation === "cancel" ? e.snapshot.status === "cancelled" : e.requestId !== null && e.snapshot.status === "running", { message: () => "Workflow control acknowledgement contradicts its observed state or receipt identity" })), W = p.Struct({
710
710
  operation: p.Literal("cancel"),
711
711
  workflowName: p.NonEmptyString,
712
712
  receiptId: p.NonEmptyString,
@@ -714,13 +714,13 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
714
714
  kind: p.Literal("accepted", "confirmed", "unknown", "already-terminal"),
715
715
  observation: p.Union(p.Struct({ kind: p.Literal("pending") }), p.Struct({
716
716
  kind: p.Literal("admission"),
717
- outcome: p.Union(Yn, p.Struct({
717
+ outcome: p.Union(B, p.Struct({
718
718
  kind: p.Literal("rejected"),
719
719
  failureId: p.NonEmptyString
720
720
  }))
721
721
  }), p.Struct({
722
722
  kind: p.Literal("execution"),
723
- snapshot: U
723
+ snapshot: H
724
724
  }), p.Struct({
725
725
  kind: p.Literal("unavailable"),
726
726
  reason: p.Literal("missing-request", "missing-run", "unconfirmed-generation", "unbound-submission")
@@ -733,32 +733,32 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
733
733
  if (t.kind === "admission") return e.kind === (t.outcome.kind === "cancelled" ? "confirmed" : "already-terminal");
734
734
  let n = t.snapshot;
735
735
  return n.workflowName !== e.workflowName || n.id.length === 0 || n.executionId.length === 0 ? !1 : e.kind === "accepted" ? n.status === "running" || n.status === "suspended" : e.kind === "confirmed" ? n.status === "cancelled" : e.kind === "already-terminal" && (n.status === "succeeded" || n.status === "failed" || n.status === "cancelled");
736
- }, { message: () => "Queued cancellation acknowledgement contradicts its receipt or observation" })), Xn = p.Literal("cancel", "terminate", "abandon"), Zn = p.Struct({
736
+ }, { message: () => "Queued cancellation acknowledgement contradicts its receipt or observation" })), Zn = p.Literal("cancel", "terminate", "abandon"), Qn = p.Struct({
737
737
  mode: p.String,
738
738
  dueAt: p.NullOr(p.Number),
739
739
  retryAfterMs: p.NullOr(p.Number),
740
740
  intentId: p.NullOr(p.String)
741
- }), Qn = p.Struct({
741
+ }), $n = p.Struct({
742
742
  id: p.String,
743
743
  workflowName: p.String,
744
744
  executionId: p.NullOr(p.String),
745
745
  status: p.Literal("running", "succeeded", "queued", "dropped", "skipped", "replayed"),
746
- deferral: p.optional(Zn)
747
- }), $n = (e, t) => {
748
- let n = R(e);
746
+ deferral: p.optional(Qn)
747
+ }), er = (e, t) => {
748
+ let n = I(e);
749
749
  return m.make(e.name, {
750
- payload: x(e.payloadSchema, e.name, F(n.guards)),
751
- success: Qn,
752
- error: an({
750
+ payload: x(e.payloadSchema, e.name, N(n.guards)),
751
+ success: $n,
752
+ error: sn({
753
753
  errorSchema: e.errorSchema,
754
754
  guards: n.guards
755
755
  }, t)
756
756
  });
757
- }, K = p.Struct({
757
+ }, G = p.Struct({
758
758
  id: p.String,
759
759
  tag: p.String,
760
760
  executionId: p.String,
761
- status: H,
761
+ status: V,
762
762
  payload: p.Unknown,
763
763
  workflowVersion: p.NullOr(p.String),
764
764
  workflowPatches: p.NullOr(p.Unknown),
@@ -773,12 +773,12 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
773
773
  durationMs: p.NullOr(p.Number),
774
774
  traceId: p.NullOr(p.String),
775
775
  parentExecutionId: p.NullOr(p.String),
776
- parentClosePolicy: p.NullOr(Xn)
777
- }), er = p.Struct({
776
+ parentClosePolicy: p.NullOr(Zn)
777
+ }), tr = p.Struct({
778
778
  tag: p.optional(p.String),
779
- status: p.optional(H),
779
+ status: p.optional(V),
780
780
  limit: p.optional(p.Number)
781
- }), tr = p.Struct({
781
+ }), nr = p.Struct({
782
782
  id: p.String,
783
783
  runId: p.String,
784
784
  stepName: p.String,
@@ -793,7 +793,7 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
793
793
  startedAt: p.Date,
794
794
  completedAt: p.NullOr(p.Date),
795
795
  durationMs: p.NullOr(p.Number)
796
- }), nr = p.Struct({
796
+ }), rr = p.Struct({
797
797
  id: p.String,
798
798
  runId: p.String,
799
799
  eventType: p.String,
@@ -801,7 +801,7 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
801
801
  occurredAt: p.Date,
802
802
  stepName: p.NullOr(p.String),
803
803
  attempt: p.NullOr(p.Number)
804
- }), rr = p.Struct({
804
+ }), ir = p.Struct({
805
805
  id: p.String,
806
806
  name: p.String,
807
807
  payload: p.Unknown,
@@ -809,7 +809,7 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
809
809
  subject: p.NullOr(p.Unknown),
810
810
  traceId: p.NullOr(p.String),
811
811
  occurredAt: p.Date
812
- }), ir = p.Struct({
812
+ }), ar = p.Struct({
813
813
  id: p.String,
814
814
  eventId: p.String,
815
815
  eventName: p.String,
@@ -822,10 +822,10 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
822
822
  errorMessage: p.NullOr(p.String),
823
823
  createdAt: p.Date,
824
824
  completedAt: p.NullOr(p.Date)
825
- }), ar = p.Struct({ id: p.String }), q = p.Struct({ runId: p.String }), or = p.Struct({
825
+ }), or = p.Struct({ id: p.String }), K = p.Struct({ runId: p.String }), sr = p.Struct({
826
826
  name: p.optional(p.String),
827
827
  limit: p.optional(p.Number)
828
- }), sr = p.Struct({ eventId: p.String }), J = p.Struct({
828
+ }), cr = p.Struct({ eventId: p.String }), q = p.Struct({
829
829
  requestId: p.NonEmptyString,
830
830
  cause: p.optionalWith(p.Struct({
831
831
  reason: p.NonEmptyString,
@@ -834,164 +834,200 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
834
834
  value: p.Unknown
835
835
  }))
836
836
  }), { exact: !0 })
837
- }), Y = p.Struct({
837
+ }), J = p.Struct({
838
838
  workflowName: p.String,
839
839
  executionId: p.String,
840
- control: p.optional(J)
841
- }), cr = p.Struct({
840
+ control: p.optional(q)
841
+ }), lr = p.Struct({
842
842
  workflowName: p.NonEmptyString,
843
843
  executionId: p.NonEmptyString,
844
844
  operation: p.Literal("cancel", "resume"),
845
845
  requestId: p.NonEmptyString
846
- }), X = p.Struct({
846
+ }), Y = p.Struct({
847
847
  workflowName: p.NonEmptyString,
848
848
  receiptId: p.NonEmptyString,
849
849
  requestId: p.NonEmptyString
850
- }), lr = p.Struct({
851
- ...X.fields,
852
- cause: J.fields.cause
853
- }), ur = N({
850
+ }), ur = p.Struct({
851
+ ...Y.fields,
852
+ cause: q.fields.cause
853
+ }), dr = j({
854
854
  name: "__voltro.workflow.queued.cancel",
855
- input: lr,
856
- output: G,
855
+ input: ur,
856
+ output: W,
857
857
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
858
- }), dr = j({
858
+ }), fr = k({
859
859
  name: "__voltro.workflow.queued.control",
860
- input: X,
861
- output: G,
860
+ input: Y,
861
+ output: W,
862
862
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
863
- }), fr = j({
863
+ }), pr = k({
864
864
  name: "__voltro.workflow.control",
865
- input: cr,
866
- output: W,
865
+ input: lr,
866
+ output: U,
867
867
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
868
- }), pr = p.Struct({
868
+ }), mr = p.Struct({
869
869
  id: p.String,
870
870
  signalName: p.String,
871
871
  payload: p.optional(p.Unknown)
872
- }), mr = p.Struct({
872
+ }), hr = p.Struct({
873
873
  id: p.String,
874
874
  updateName: p.String,
875
875
  payload: p.optional(p.Unknown),
876
876
  timeoutMs: p.optional(p.Number)
877
- }), hr = p.Struct({
877
+ }), gr = p.Struct({
878
878
  eventId: p.String,
879
879
  updateId: p.String,
880
880
  completedEventId: p.String,
881
881
  result: p.Unknown
882
- }), gr = j({
882
+ }), _r = k({
883
883
  name: "__voltro.workflow.run",
884
884
  source: "_voltro_workflow_runs",
885
- input: ar,
886
- output: p.Array(K),
885
+ input: or,
886
+ output: p.Array(G),
887
887
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
888
- }), _r = j({
888
+ }), vr = k({
889
889
  name: "__voltro.workflow.runs",
890
890
  source: "_voltro_workflow_runs",
891
- input: er,
892
- output: p.Array(K),
891
+ input: tr,
892
+ output: p.Array(G),
893
893
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
894
- }), vr = j({
894
+ }), yr = k({
895
895
  name: "__voltro.workflow.run.steps",
896
896
  source: "_voltro_workflow_run_steps",
897
- input: q,
898
- output: p.Array(tr),
897
+ input: K,
898
+ output: p.Array(nr),
899
899
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
900
- }), yr = j({
900
+ }), br = k({
901
901
  name: "__voltro.workflow.run.events",
902
902
  source: "_voltro_workflow_run_events",
903
- input: q,
904
- output: p.Array(nr),
903
+ input: K,
904
+ output: p.Array(rr),
905
905
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
906
- }), br = j({
906
+ }), xr = k({
907
907
  name: "__voltro.workflow.domainEvents",
908
908
  source: "_voltro_workflow_events",
909
- input: or,
910
- output: p.Array(rr),
909
+ input: sr,
910
+ output: p.Array(ir),
911
911
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
912
- }), xr = j({
912
+ }), Sr = k({
913
913
  name: "__voltro.workflow.event.deliveries",
914
914
  source: "_voltro_workflow_event_deliveries",
915
- input: sr,
916
- output: p.Array(ir),
915
+ input: cr,
916
+ output: p.Array(ar),
917
917
  openAccess: "the answer is scoped to the caller in the executor — a system or admin:full subject sees every row, an authenticated subject the rows of its own tenant, an anonymous caller none"
918
- }), Sr = N({
918
+ }), Cr = j({
919
919
  name: "__voltro.workflow.cancel",
920
- input: Y,
921
- output: W,
920
+ input: J,
921
+ output: U,
922
922
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
923
- }), Cr = N({
923
+ }), wr = j({
924
924
  name: "__voltro.workflow.resume",
925
- input: Y,
926
- output: W,
925
+ input: J,
926
+ output: U,
927
927
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
928
- }), wr = N({
928
+ }), Tr = j({
929
929
  name: "__voltro.workflow.signal",
930
- input: pr,
930
+ input: mr,
931
931
  output: p.Struct({ eventId: p.String }),
932
932
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
933
- }), Tr = N({
933
+ }), Er = j({
934
934
  name: "__voltro.workflow.update",
935
- input: mr,
936
- output: hr,
935
+ input: hr,
936
+ output: gr,
937
937
  openAccess: "authorization happens in the executor against the target run — the caller must be authenticated and belong to the run's tenant, and a missing run answers exactly like a foreign one"
938
- }), Er = "__voltro.undo.log", Dr = "__voltro.undo.apply", Or = "__voltro.undo.redo", kr = p.Struct({
938
+ }), Dr = p.NonEmptyString.pipe(p.filter((e) => e.trim().length > 0, { message: () => "A workflow retry identity must not be blank" })), Or = p.Struct({
939
+ runId: Dr,
940
+ requestId: Dr
941
+ }), kr = p.Struct({
942
+ ...Or.fields,
943
+ payloadOverride: p.optional(p.Unknown)
944
+ }), X = {
945
+ requestId: p.NonEmptyString,
946
+ originalRunId: p.NonEmptyString,
947
+ originalExecutionId: p.NonEmptyString,
948
+ workflowName: p.NonEmptyString
949
+ }, Ar = p.Union(p.Struct({
950
+ ...X,
951
+ kind: p.Literal("queued"),
952
+ nextAttemptAt: p.NullOr(p.Number)
953
+ }), p.Struct({
954
+ ...X,
955
+ kind: p.Literal("accepted"),
956
+ executionId: p.NonEmptyString
957
+ }).pipe(p.filter((e) => e.executionId !== e.originalExecutionId, { message: () => "A retry cannot accept its original execution identity" })), p.Struct({
958
+ ...X,
959
+ kind: p.Literal("unconfirmed"),
960
+ automaticRetryStopped: p.Boolean,
961
+ nextAttemptAt: p.NullOr(p.Number)
962
+ }).pipe(p.filter((e) => !e.automaticRetryStopped || e.nextAttemptAt === null, { message: () => "Stopped automatic retries cannot have a next attempt" })), p.Struct({
963
+ ...X,
964
+ kind: p.Literal("not-started"),
965
+ outcome: B
966
+ }), p.Struct({
967
+ ...X,
968
+ kind: p.Literal("rejected"),
969
+ failureId: p.NonEmptyString
970
+ })), jr = "__voltro.undo.log", Mr = "__voltro.undo.apply", Nr = "__voltro.undo.redo", Pr = p.Struct({
939
971
  id: p.String,
940
972
  tag: p.String,
941
973
  label: p.NullOr(p.String),
942
974
  undone: p.Boolean,
943
975
  crossesAction: p.Boolean,
944
976
  createdAt: p.String
945
- }), Ar = class extends p.TaggedError()("UndoNotFound", { invocationId: p.String }) {}, jr = class extends p.TaggedError()("UndoForbidden", { invocationId: p.String }) {}, Mr = class extends p.TaggedError()("UndoConflict", {
977
+ }), Fr = class extends p.TaggedError()("UndoNotFound", { invocationId: p.String }) {}, Ir = class extends p.TaggedError()("UndoForbidden", { invocationId: p.String }) {}, Lr = class extends p.TaggedError()("UndoConflict", {
946
978
  invocationId: p.String,
947
979
  reason: p.Literal("conflict", "action")
948
- }) {}, Nr = p.Union(Ar, jr, Mr), Pr = j({
949
- name: Er,
980
+ }) {}, Rr = p.Union(Fr, Ir, Lr), zr = k({
981
+ name: jr,
950
982
  source: "_voltro_undo_log",
951
983
  input: p.Struct({ limit: p.optional(p.Number) }),
952
- output: p.Array(kr),
984
+ output: p.Array(Pr),
953
985
  openAccess: "subject-scoped by construction: lists only the calling subject's own undoable actions"
954
- }), Fr = M({
955
- name: Dr,
986
+ }), Br = A({
987
+ name: Mr,
956
988
  input: p.Struct({ invocationId: p.String }),
957
989
  output: p.Struct({ ok: p.Boolean }),
958
- error: Nr,
990
+ error: Rr,
959
991
  openAccess: "subject-scoped by construction: undo is per-actor — another subject's invocation fails typed with UndoForbidden"
960
- }), Ir = M({
961
- name: Or,
992
+ }), Vr = A({
993
+ name: Nr,
962
994
  input: p.Struct({ invocationId: p.String }),
963
995
  output: p.Struct({ ok: p.Boolean }),
964
- error: Nr,
996
+ error: Rr,
965
997
  openAccess: "subject-scoped by construction: redo is per-actor — another subject's invocation fails typed with UndoForbidden"
966
- }), Lr = class extends p.TaggedError()("TenantScopeViolation", {
998
+ }), Hr = class extends p.TaggedError()("TenantScopeViolation", {
967
999
  table: p.String,
968
1000
  reason: p.String
969
- }) {}, Rr = class extends p.TaggedError()("StoreOperationFailed", {
1001
+ }) {}, Ur = class extends p.TaggedError()("StoreOperationFailed", {
970
1002
  operation: p.String,
971
1003
  table: p.String,
972
1004
  cause: p.String
973
- }) {}, zr = class extends p.TaggedError()("NoRowFound", {
1005
+ }) {
1006
+ get message() {
1007
+ return `${this.operation} on '${this.table}' failed: ${this.cause}`;
1008
+ }
1009
+ }, Wr = class extends p.TaggedError()("NoRowFound", {
974
1010
  table: p.String,
975
1011
  found: p.Number
976
1012
  }) {
977
1013
  get message() {
978
1014
  return this.found === 0 ? `expected exactly one row in '${this.table}', found none` : `expected exactly one row in '${this.table}', found more than one`;
979
1015
  }
980
- }, Br = class extends p.TaggedError()("TableValidationFailed", {
1016
+ }, Gr = class extends p.TaggedError()("TableValidationFailed", {
981
1017
  table: p.String,
982
1018
  summary: p.String,
983
1019
  issues: p.Array(p.Struct({
984
1020
  path: p.String,
985
1021
  message: p.String
986
1022
  }))
987
- }) {}, Vr = class extends p.TaggedError()("TenantRowNotFound", {
1023
+ }) {}, Kr = class extends p.TaggedError()("TenantRowNotFound", {
988
1024
  table: p.String,
989
1025
  id: p.String,
990
1026
  reason: p.String
991
- }) {}, Hr = class extends p.TaggedError()("ServerOnlyColumnWrite", {
1027
+ }) {}, qr = class extends p.TaggedError()("ServerOnlyColumnWrite", {
992
1028
  table: p.String,
993
1029
  columns: p.Array(p.String)
994
- }) {}, Ur = class extends p.TaggedError()("ConstraintViolation", {
1030
+ }) {}, Jr = class extends p.TaggedError()("ConstraintViolation", {
995
1031
  kind: p.Literal("foreignKey", "foreignKeyInUse", "unique", "notNull", "check"),
996
1032
  table: p.String,
997
1033
  operation: p.String,
@@ -1010,14 +1046,14 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
1010
1046
  case "check": return `check constraint ${t}: the row does not satisfy it`;
1011
1047
  }
1012
1048
  }
1013
- }, Wr = "__voltro.approvals.pending", Gr = "__voltro.approvals.decide", Kr = j({
1014
- name: Wr,
1049
+ }, Yr = "__voltro.approvals.pending", Xr = "__voltro.approvals.decide", Zr = k({
1050
+ name: Yr,
1015
1051
  source: "_voltro_approvals",
1016
1052
  input: p.Struct({ limit: p.optional(p.Number) }),
1017
1053
  output: p.Array(Rt),
1018
1054
  openAccess: "the answer is scoped to the caller — a row appears only if they requested it or hold its recorded approver scopes, so an anonymous caller sees nothing"
1019
- }), qr = M({
1020
- name: Gr,
1055
+ }), Qr = A({
1056
+ name: Xr,
1021
1057
  input: p.Struct({
1022
1058
  approvalId: p.String,
1023
1059
  decision: p.Literal("approve", "reject"),
@@ -1029,33 +1065,33 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
1029
1065
  }),
1030
1066
  error: Lt,
1031
1067
  openAccess: "the approver authority is the PENDING ROW's own recorded scopes (plus an unconditional self-approval refusal), checked in-handler — a descriptor-level scope would have to be the union of every approval-requiring procedure in the app"
1032
- }), Jr = "__voltro.connections.list", Yr = "__voltro.connections.start", Xr = "__voltro.connections.submitToken", Z = "__voltro.connections.disconnect", Q = p.Literal("oauth2", "pat"), Zr = p.Literal("disconnected", "connected", "expired", "revoked", "error"), Qr = p.Struct({
1068
+ }), Z = "__voltro.connections.list", $r = "__voltro.connections.start", ei = "__voltro.connections.submitToken", ti = "__voltro.connections.disconnect", Q = p.Literal("oauth2", "pat"), ni = p.Literal("disconnected", "connected", "expired", "revoked", "error"), ri = p.Struct({
1033
1069
  connectionId: p.String,
1034
1070
  kind: Q,
1035
1071
  label: p.String,
1036
- status: Zr,
1072
+ status: ni,
1037
1073
  accountId: p.NullOr(p.String),
1038
1074
  accountLabel: p.NullOr(p.String),
1039
1075
  scopes: p.Array(p.String),
1040
1076
  expiresAt: p.NullOr(p.String),
1041
1077
  lastError: p.NullOr(p.String),
1042
1078
  connectedAt: p.NullOr(p.String)
1043
- }), $r = class extends p.TaggedError()("ConnectionNotDeclared", { connectionId: p.String }) {}, ei = class extends p.TaggedError()("ConnectionSubjectRequired", { connectionId: p.String }) {}, ti = class extends p.TaggedError()("ConnectionKindMismatch", {
1079
+ }), ii = class extends p.TaggedError()("ConnectionNotDeclared", { connectionId: p.String }) {}, ai = class extends p.TaggedError()("ConnectionSubjectRequired", { connectionId: p.String }) {}, oi = class extends p.TaggedError()("ConnectionKindMismatch", {
1044
1080
  connectionId: p.String,
1045
1081
  expected: Q,
1046
1082
  actual: Q
1047
- }) {}, ni = class extends p.TaggedError()("ConnectionHandshakeFailed", {
1083
+ }) {}, si = class extends p.TaggedError()("ConnectionHandshakeFailed", {
1048
1084
  connectionId: p.String,
1049
1085
  reason: p.String,
1050
1086
  transient: p.Boolean
1051
- }) {}, $ = p.Union($r, ei, ti, ni), ri = j({
1052
- name: Jr,
1087
+ }) {}, $ = p.Union(ii, ai, oi, si), ci = k({
1088
+ name: Z,
1053
1089
  source: "_voltro_connections",
1054
1090
  input: p.Struct({}),
1055
- output: p.Array(Qr),
1091
+ output: p.Array(ri),
1056
1092
  openAccess: "self-scoped read: projects the declared connections for the calling subject only (its own connect/disconnect state)"
1057
- }), ii = N({
1058
- name: Yr,
1093
+ }), li = j({
1094
+ name: $r,
1059
1095
  input: p.Struct({
1060
1096
  connectionId: p.String,
1061
1097
  redirectTo: p.optional(p.String)
@@ -1066,8 +1102,8 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
1066
1102
  }),
1067
1103
  error: $,
1068
1104
  openAccess: "self-service: begins an oauth handshake that stores a credential for the calling subject only; anonymous callers fail typed with ConnectionSubjectRequired"
1069
- }), ai = M({
1070
- name: Xr,
1105
+ }), ui = A({
1106
+ name: ei,
1071
1107
  input: p.Struct({
1072
1108
  connectionId: p.String,
1073
1109
  token: p.String
@@ -1075,20 +1111,21 @@ var gt = p.Union(p.String, p.Number), h = p.Record({
1075
1111
  output: p.Struct({ ok: p.Boolean }),
1076
1112
  error: $,
1077
1113
  openAccess: "self-service: stores a pasted token as the calling subject's own credential; anonymous callers fail typed with ConnectionSubjectRequired"
1078
- }), oi = M({
1079
- name: Z,
1114
+ }), di = A({
1115
+ name: ti,
1080
1116
  input: p.Struct({ connectionId: p.String }),
1081
1117
  output: p.Struct({ ok: p.Boolean }),
1082
1118
  error: $,
1083
1119
  openAccess: "self-service: deletes only the calling subject's own credential row for this connection"
1084
- }), si = (e) => {
1120
+ }), fi = (e) => {
1085
1121
  let t = e instanceof Date ? e.getTime() : typeof e == "number" ? e : typeof e == "string" ? new Date(e).getTime() : 0;
1086
1122
  return Number.isNaN(t) ? 0 : t;
1087
- }, ci = 4001, li = /* @__PURE__ */ new Set(["/rpc", "/ws"]), ui = (e) => {
1123
+ }, pi = 4001, mi = /* @__PURE__ */ new Set(["/rpc", "/ws"]), hi = (e) => {
1124
+ for (let [t, n] of Object.entries(e.limits ?? {})) if (n !== void 0 && (!Number.isSafeInteger(n) || n <= 0)) throw Error(`defineWebSocket: limits.${t} must be a positive safe integer`);
1088
1125
  if (!e.path.startsWith("/")) throw Error(`defineWebSocket: path must be absolute, got '${e.path}'`);
1089
- if (li.has(e.path)) throw Error(`defineWebSocket: '${e.path}' is the framework's own socket surface — mount the gateway elsewhere`);
1126
+ if (mi.has(e.path)) throw Error(`defineWebSocket: '${e.path}' is the framework's own socket surface — mount the gateway elsewhere`);
1090
1127
  if (e.auth !== "subject" && e.auth !== "public") throw Error(`defineWebSocket: auth must be 'subject' or 'public' (explicitly — an unauthenticated socket has to be a decision somebody wrote down), got '${String(e.auth)}'`);
1091
1128
  return e;
1092
- }, di = 1;
1129
+ }, gi = 1;
1093
1130
  //#endregion
1094
- export { Ne as ADMIN_SCOPE, Oe as APIKEY_ISSUE_ORG_SCOPE, je as APIKEY_ISSUE_OTHER_SCOPE, Ce as APIKEY_ISSUE_SELF_SCOPE, Gr as APPROVALS_DECIDE_TAG, Wr as APPROVALS_PENDING_TAG, Lt as ApprovalDecisionErrors, It as ApprovalErrors, S as ApprovalExpired, Ft as ApprovalForbidden, jt as ApprovalNotFound, Pt as ApprovalNotPending, Nt as ApprovalRejected, At as ApprovalRequired, Mt as ApprovalSelfApproval, C as ApprovalUnavailable, i as AuthMiddleware, Tt as BusinessRuleViolation, Jr as CONNECTIONS_LIST_TAG, Z as CONNECTION_DISCONNECT_TAG, Yr as CONNECTION_START_TAG, Xr as CONNECTION_SUBMIT_TOKEN_TAG, ni as ConnectionHandshakeFailed, ae as ConnectionInfo, Te as ConnectionInfoMiddleware, Q as ConnectionKind, ti as ConnectionKindMismatch, $r as ConnectionNotDeclared, Qr as ConnectionState, Zr as ConnectionStatus, ei as ConnectionSubjectRequired, Ur as ConstraintViolation, t as DEFAULT_SCOPE_CACHE_MAX_ENTRIES, we as DEFAULT_SCOPE_CACHE_TTL_MS, _e as DEVICES_MANAGE_SCOPE, On as EVENT_ROUTE_SEP, Tn as EventKeyInvalid, wn as EventPayloadInvalid, En as EventPayloadTooLarge, ci as GATEWAY_CREDENTIAL_EXPIRED_CLOSE_CODE, re as IMPERSONATION_METADATA_KEY, st as JSONAPI_MEDIA_TYPE, mn as MAX_EVENT_ENVELOPE_BYTES, ft as MUTATION_IN_FLIGHT_RETRY_AFTER_MS, qe as MutationConnectionRequired, dt as MutationInFlight, zr as NoRowFound, nt as PROBLEM_JSON, di as PROTOCOL_VERSION, Rt as PendingApproval, w as REACTIVITY_CHANNEL_PREFIX, at as REST_PROFILE_NAMES, f as ScopeError, Hr as ServerOnlyColumnWrite, Rr as StoreOperationFailed, ie as Subject, oe as SubjectIdentity, o as SubjectService, Br as TableValidationFailed, Vr as TenantRowNotFound, Lr as TenantScopeViolation, ge as TenantSelectionRefused, Dr as UNDO_APPLY_TAG, Er as UNDO_LOG_TAG, Or as UNDO_REDO_TAG, l as Unauthenticated, Mr as UndoConflict, jr as UndoForbidden, kr as UndoLogEntry, Ar as UndoNotFound, Dt as ValidationError, Ot as ValidationErrors, Et as ValidationIssue, L as WorkflowAccessProperty, Y as WorkflowControlInputSchema, J as WorkflowControlIntentSchema, cr as WorkflowControlReadInputSchema, W as WorkflowControlResultSchema, rr as WorkflowDomainEventRowSchema, or as WorkflowDomainEventsInputSchema, sr as WorkflowEventDeliveriesInputSchema, ir as WorkflowEventDeliveryRowSchema, Xn as WorkflowParentClosePolicySchema, lr as WorkflowQueuedCancelInputSchema, G as WorkflowQueuedCancellationResultSchema, X as WorkflowQueuedControlTargetSchema, nr as WorkflowRunEventRowSchema, Qn as WorkflowRunHandleSchema, ar as WorkflowRunRefSchema, K as WorkflowRunRowSchema, U as WorkflowRunSnapshotSchema, H as WorkflowRunStatusSchema, tr as WorkflowRunStepRowSchema, q as WorkflowRunTableRefSchema, er as WorkflowRunsInputSchema, pr as WorkflowSignalInputSchema, Zn as WorkflowStartDeferralSchema, Yn as WorkflowStartTerminalOutcomeSchema, mr as WorkflowUpdateInputSchema, hr as WorkflowUpdateResultSchema, ln as actionToRpc, Me as advisoryResourceGuardWarning, ne as anonymousSubject, Ct as applyRowPatch, ce as applyScopeDecision, qr as approvalsDecideDescriptor, Kr as approvalsPendingQueryDescriptor, ze as assertAuthenticated, Pn as attachWorkflowAccess, Ue as beginIdempotent, Vn as checkFrameworkCompat, ve as checkGuards, Ee as checkGuardsEffect, tt as compareSurfaces, n as composeAuthStrategies, zn as composeRpcInterceptors, oi as connectionDisconnectDescriptor, ii as connectionStartDescriptor, ai as connectionSubmitTokenDescriptor, ri as connectionsListQueryDescriptor, Gt as declaredReactivityChannelKeys, N as defineAction, gn as defineEvent, M as defineMutation, In as definePlugin, Ln as definePluginRoute, Bn as definePluginService, j as defineQuery, $t as defineStream, ui as defineWebSocket, xt as diffRows, Pe as effectiveScopes, Dn as encodeEventKey, $e as encodeRestError, Ke as encodeRestSuccess, dn as errorTag, yn as eventAttached, _n as eventEnvelope, vn as eventGap, xn as eventResumePoint, kn as eventRoute, bn as eventStreamEvent, Sn as eventSubscribeInput, Cn as eventToRpc, Be as failIdempotent, kt as fieldIssuesOf, ye as findAdvisoryResourceGuards, ut as finishIdempotent, jn as formatEventRoute, be as getPolicyGuardResolver, ke as getResourceScopeResolver, R as getWorkflowAccess, Qe as groupShapeDigests, Qt as hasAccessDecision, fe as hasCallbackRoutes, De as hasEffectiveScope, F as hasEnforcedGuard, Se as hasScope, g as idToPath, We as idempotencyScope, b as inputLabel, xe as isAuthenticatedCheck, Zt as isAuthenticatedGuard, hn as isEventDescriptor, St as isIdKeyed, u as isOpenAccess, Fe as isPolicyCheck, Xt as isPolicyGuard, Ut as isReactivityChannel, Wt as isReactivityChannelKey, c as isSystemSubject, se as isTenantSelectable, Jt as isWireReachable, de as makeScopeCache, He as memoryIdempotencyStore, Re as missingAccessDecision, cn as mutationToRpc, rt as nextLink, pn as normalizeDescriptor, O as normalizeSource, d as openAccessSpec, pe as orderByBearerPrefix, An as parseEventRoute, yt as pathToId, Un as pluginAlias, Rn as pluginInstanceName, Wn as pluginSlug, Jn as pluginTag, ot as problemDetails, Je as problemTypeOf, Ze as procedureShapeDigest, qt as publishReactivity, Xe as publishServerError, sn as queryToRpc, s as rawImpersonationMark, Ht as reactivityChannel, Kn as registerPluginAliases, Le as requireScope, qn as resetPluginAliases, le as resolvePolicyAction, et as resolveRestFormat, Nn as resolveWorkflowAccess, ct as restViewSchema, _t as rowPatchOpSchema, vt as rowPatchSchema, Ge as schemaShape, te as scopeCacheKey, e as selectSubjectTenant, r as setEffectiveScopes, Ie as setPolicyGuardResolver, ue as setResourceScopeResolver, lt as shapeDigest, D as sourceKeys, un as streamToRpc, x as strictInput, Ae as subjectAuditActorId, ee as subjectIdentity, a as subjectScopes, it as subscribeServerErrors, y as subscriptionEvent, he as systemSubject, me as tenantScopedSubject, fn as toRpc, Ye as toSnakeCase, si as tsMs, Kt as undeclaredChannelKeys, Fr as undoApplyDescriptor, Pr as undoLogQueryDescriptor, Ir as undoRedoDescriptor, I as wireErrorUnion, on as withRpcTag, Fn as workflowAccessDescriptor, Sr as workflowCancelDescriptor, fr as workflowControlQueryDescriptor, br as workflowDomainEventsQueryDescriptor, xr as workflowEventDeliveriesQueryDescriptor, ur as workflowQueuedCancelDescriptor, dr as workflowQueuedControlQueryDescriptor, Cr as workflowResumeDescriptor, yr as workflowRunEventsQueryDescriptor, gr as workflowRunQueryDescriptor, vr as workflowRunStepsQueryDescriptor, _r as workflowRunsQueryDescriptor, wr as workflowSignalDescriptor, $n as workflowToRpc, Tr as workflowUpdateDescriptor, an as workflowWireErrorUnion, Ve as wsMutationIdempotencyScope };
1131
+ export { Ne as ADMIN_SCOPE, Oe as APIKEY_ISSUE_ORG_SCOPE, je as APIKEY_ISSUE_OTHER_SCOPE, Ce as APIKEY_ISSUE_SELF_SCOPE, Xr as APPROVALS_DECIDE_TAG, Yr as APPROVALS_PENDING_TAG, Lt as ApprovalDecisionErrors, It as ApprovalErrors, S as ApprovalExpired, Ft as ApprovalForbidden, jt as ApprovalNotFound, Pt as ApprovalNotPending, Nt as ApprovalRejected, At as ApprovalRequired, Mt as ApprovalSelfApproval, C as ApprovalUnavailable, i as AuthMiddleware, Tt as BusinessRuleViolation, Z as CONNECTIONS_LIST_TAG, ti as CONNECTION_DISCONNECT_TAG, $r as CONNECTION_START_TAG, ei as CONNECTION_SUBMIT_TOKEN_TAG, si as ConnectionHandshakeFailed, ae as ConnectionInfo, Te as ConnectionInfoMiddleware, Q as ConnectionKind, oi as ConnectionKindMismatch, ii as ConnectionNotDeclared, ri as ConnectionState, ni as ConnectionStatus, ai as ConnectionSubjectRequired, Jr as ConstraintViolation, t as DEFAULT_SCOPE_CACHE_MAX_ENTRIES, we as DEFAULT_SCOPE_CACHE_TTL_MS, _e as DEVICES_MANAGE_SCOPE, An as EVENT_ROUTE_SEP, Dn as EventKeyInvalid, En as EventPayloadInvalid, On as EventPayloadTooLarge, pi as GATEWAY_CREDENTIAL_EXPIRED_CLOSE_CODE, re as IMPERSONATION_METADATA_KEY, st as JSONAPI_MEDIA_TYPE, gn as MAX_EVENT_ENVELOPE_BYTES, ft as MUTATION_IN_FLIGHT_RETRY_AFTER_MS, qe as MutationConnectionRequired, dt as MutationInFlight, Wr as NoRowFound, nt as PROBLEM_JSON, gi as PROTOCOL_VERSION, Rt as PendingApproval, w as REACTIVITY_CHANNEL_PREFIX, at as REST_PROFILE_NAMES, f as ScopeError, qr as ServerOnlyColumnWrite, Ur as StoreOperationFailed, ie as Subject, oe as SubjectIdentity, o as SubjectService, Gr as TableValidationFailed, Kr as TenantRowNotFound, Hr as TenantScopeViolation, ge as TenantSelectionRefused, Mr as UNDO_APPLY_TAG, jr as UNDO_LOG_TAG, Nr as UNDO_REDO_TAG, l as Unauthenticated, Lr as UndoConflict, Ir as UndoForbidden, Pr as UndoLogEntry, Fr as UndoNotFound, Dt as ValidationError, Ot as ValidationErrors, Et as ValidationIssue, F as WorkflowAccessProperty, J as WorkflowControlInputSchema, q as WorkflowControlIntentSchema, lr as WorkflowControlReadInputSchema, U as WorkflowControlResultSchema, ir as WorkflowDomainEventRowSchema, sr as WorkflowDomainEventsInputSchema, cr as WorkflowEventDeliveriesInputSchema, ar as WorkflowEventDeliveryRowSchema, Zn as WorkflowParentClosePolicySchema, ur as WorkflowQueuedCancelInputSchema, W as WorkflowQueuedCancellationResultSchema, Y as WorkflowQueuedControlTargetSchema, kr as WorkflowRetryCommandSchema, Ar as WorkflowRetryObservationSchema, Or as WorkflowRetryTargetSchema, rr as WorkflowRunEventRowSchema, $n as WorkflowRunHandleSchema, or as WorkflowRunRefSchema, G as WorkflowRunRowSchema, H as WorkflowRunSnapshotSchema, V as WorkflowRunStatusSchema, nr as WorkflowRunStepRowSchema, K as WorkflowRunTableRefSchema, tr as WorkflowRunsInputSchema, mr as WorkflowSignalInputSchema, Qn as WorkflowStartDeferralSchema, B as WorkflowStartTerminalOutcomeSchema, hr as WorkflowUpdateInputSchema, gr as WorkflowUpdateResultSchema, dn as actionToRpc, Me as advisoryResourceGuardWarning, ne as anonymousSubject, Ct as applyRowPatch, ce as applyScopeDecision, Qr as approvalsDecideDescriptor, Zr as approvalsPendingQueryDescriptor, ze as assertAuthenticated, In as attachWorkflowAccess, Ue as beginIdempotent, Un as checkFrameworkCompat, ve as checkGuards, Ee as checkGuardsEffect, tt as compareSurfaces, n as composeAuthStrategies, Vn as composeRpcInterceptors, di as connectionDisconnectDescriptor, li as connectionStartDescriptor, ui as connectionSubmitTokenDescriptor, ci as connectionsListQueryDescriptor, Gt as declaredReactivityChannelKeys, j as defineAction, vn as defineEvent, A as defineMutation, Rn as definePlugin, zn as definePluginRoute, Hn as definePluginService, k as defineQuery, tn as defineStream, hi as defineWebSocket, xt as diffRows, Pe as effectiveScopes, kn as encodeEventKey, $e as encodeRestError, Ke as encodeRestSuccess, pn as errorTag, xn as eventAttached, yn as eventEnvelope, bn as eventGap, Cn as eventResumePoint, jn as eventRoute, Sn as eventStreamEvent, wn as eventSubscribeInput, Tn as eventToRpc, Be as failIdempotent, kt as fieldIssuesOf, ye as findAdvisoryResourceGuards, ut as finishIdempotent, Nn as formatEventRoute, be as getPolicyGuardResolver, ke as getResourceScopeResolver, I as getWorkflowAccess, Qe as groupShapeDigests, en as hasAccessDecision, fe as hasCallbackRoutes, De as hasEffectiveScope, N as hasEnforcedGuard, Se as hasScope, g as idToPath, We as idempotencyScope, b as inputLabel, xe as isAuthenticatedCheck, $t as isAuthenticatedGuard, _n as isEventDescriptor, St as isIdKeyed, u as isOpenAccess, Fe as isPolicyCheck, Qt as isPolicyGuard, Ut as isReactivityChannel, Wt as isReactivityChannelKey, c as isSystemSubject, se as isTenantSelectable, Xt as isWireReachable, de as makeScopeCache, He as memoryIdempotencyStore, Re as missingAccessDecision, un as mutationToRpc, rt as nextLink, hn as normalizeDescriptor, qt as normalizeSource, d as openAccessSpec, pe as orderByBearerPrefix, Mn as parseEventRoute, yt as pathToId, Gn as pluginAlias, Bn as pluginInstanceName, Kn as pluginSlug, Xn as pluginTag, ot as problemDetails, Je as problemTypeOf, Ze as procedureShapeDigest, Yt as publishReactivity, Xe as publishServerError, ln as queryToRpc, s as rawImpersonationMark, Ht as reactivityChannel, Jn as registerPluginAliases, Le as requireScope, Yn as resetPluginAliases, le as resolvePolicyAction, et as resolveRestFormat, Fn as resolveWorkflowAccess, ct as restViewSchema, _t as rowPatchOpSchema, vt as rowPatchSchema, Ge as schemaShape, te as scopeCacheKey, e as selectSubjectTenant, r as setEffectiveScopes, Ie as setPolicyGuardResolver, ue as setResourceScopeResolver, lt as shapeDigest, Kt as sourceKeys, fn as streamToRpc, x as strictInput, Ae as subjectAuditActorId, ee as subjectIdentity, a as subjectScopes, it as subscribeServerErrors, y as subscriptionEvent, he as systemSubject, me as tenantScopedSubject, mn as toRpc, Ye as toSnakeCase, fi as tsMs, Jt as undeclaredChannelKeys, Br as undoApplyDescriptor, zr as undoLogQueryDescriptor, Vr as undoRedoDescriptor, P as wireErrorUnion, cn as withRpcTag, Ln as workflowAccessDescriptor, Cr as workflowCancelDescriptor, pr as workflowControlQueryDescriptor, xr as workflowDomainEventsQueryDescriptor, Sr as workflowEventDeliveriesQueryDescriptor, dr as workflowQueuedCancelDescriptor, fr as workflowQueuedControlQueryDescriptor, wr as workflowResumeDescriptor, br as workflowRunEventsQueryDescriptor, _r as workflowRunQueryDescriptor, yr as workflowRunStepsQueryDescriptor, vr as workflowRunsQueryDescriptor, Tr as workflowSignalDescriptor, er as workflowToRpc, Er as workflowUpdateDescriptor, sn as workflowWireErrorUnion, Ve as wsMutationIdempotencyScope };