@adhd/apigen-engine-runtime 0.3.2 → 0.3.3

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/index.mjs CHANGED
@@ -72,16 +72,16 @@ function p(e, t, n) {
72
72
  let i = t.$ref;
73
73
  if (typeof i == "string") return p(e, n.resolve(i), n);
74
74
  let a = t.oneOf;
75
- if (Array.isArray(a)) return p(e, ee(e, a, t, n), n);
75
+ if (Array.isArray(a)) return p(e, h(e, a, t, n), n);
76
76
  let o = t.type;
77
77
  if (o === "array") {
78
- if (!Array.isArray(e)) return _(e, t, n);
78
+ if (!Array.isArray(e)) return v(e, t, n);
79
79
  let r = t.items;
80
- if (!r) return e.map((e) => b(e));
80
+ if (!r) return e.map((e) => x(e));
81
81
  let i = n.path;
82
82
  return Array.isArray(r) ? e.map((e, t) => {
83
83
  let a = r[t];
84
- return a === void 0 ? b(e) : p(e, a, {
84
+ return a === void 0 ? x(e) : p(e, a, {
85
85
  ...n,
86
86
  path: `${i}/${t}`
87
87
  });
@@ -91,9 +91,9 @@ function p(e, t, n) {
91
91
  }));
92
92
  }
93
93
  if (o === "object") {
94
- if (typeof e != "object" || !e || Array.isArray(e)) return _(e, t, n);
94
+ if (typeof e != "object" || !e || Array.isArray(e)) return v(e, t, n);
95
95
  let r = t.properties;
96
- if (!r) return b(e);
96
+ if (!r) return x(e);
97
97
  let i = n.path, a = {};
98
98
  for (let [t, o] of Object.entries(r)) {
99
99
  let r = e[t];
@@ -104,7 +104,7 @@ function p(e, t, n) {
104
104
  }
105
105
  return a;
106
106
  }
107
- return o == null ? _(e, t, n) : b(e);
107
+ return o == null ? v(e, t, n) : x(e);
108
108
  }
109
109
  function m(e, t, n) {
110
110
  let r = n.registry.resolve(t);
@@ -112,7 +112,7 @@ function m(e, t, n) {
112
112
  let i = t.$ref;
113
113
  if (typeof i == "string") return m(e, n.resolve(i), n);
114
114
  let a = t.oneOf;
115
- if (Array.isArray(a)) return m(e, ee(e, a, t, n), n);
115
+ if (Array.isArray(a)) return m(e, h(e, a, t, n), n);
116
116
  let o = t.type;
117
117
  if (o === "array") {
118
118
  if (!Array.isArray(e)) return e;
@@ -145,9 +145,9 @@ function m(e, t, n) {
145
145
  for (let [t, n] of Object.entries(e)) !(t in r) && n !== void 0 && (a[t] = n);
146
146
  return a;
147
147
  }
148
- return o == null ? y(e, n) : e;
148
+ return o == null ? b(e, n) : e;
149
149
  }
150
- function ee(e, t, n, r) {
150
+ function h(e, t, n, r) {
151
151
  let i = n.discriminator;
152
152
  if (i?.propertyName) {
153
153
  let n = i.propertyName, a = typeof e == "object" && e ? e[n] : void 0;
@@ -160,67 +160,67 @@ function ee(e, t, n, r) {
160
160
  }
161
161
  }
162
162
  for (let e of t) {
163
- let t = h(e, r).properties?.[n];
163
+ let t = g(e, r).properties?.[n];
164
164
  if (!t) continue;
165
165
  let i = t.enum;
166
166
  if (t.const === a || Array.isArray(i) && i.includes(a)) return e;
167
167
  }
168
168
  }
169
169
  }
170
- let a = ne(e, t, r);
170
+ let a = te(e, t, r);
171
171
  if (a) return a;
172
172
  let o, s = -1;
173
173
  for (let n of t) {
174
- let t = g(e, h(n, r), r);
174
+ let t = _(e, g(n, r), r);
175
175
  t !== null && t > s && (s = t, o = n);
176
176
  }
177
177
  return o === void 0 ? t[0] ?? {} : o;
178
178
  }
179
- function h(e, t) {
179
+ function g(e, t) {
180
180
  let n = e.$ref;
181
181
  return typeof n == "string" ? t.resolve(n) : e;
182
182
  }
183
- function te(e) {
183
+ function ee(e) {
184
184
  if ("const" in e) return e.const;
185
185
  let t = e.enum;
186
186
  if (Array.isArray(t) && t.length === 1) return t[0];
187
187
  }
188
- function ne(e, t, n) {
188
+ function te(e, t, n) {
189
189
  if (typeof e != "object" || !e || Array.isArray(e)) return;
190
- let r = e, i = t.map((e) => h(e, n)), a = /* @__PURE__ */ new Set();
190
+ let r = e, i = t.map((e) => g(e, n)), a = /* @__PURE__ */ new Set();
191
191
  for (let e of i) {
192
192
  let t = e.properties;
193
- if (t) for (let [e, n] of Object.entries(t)) te(n) !== void 0 && a.add(e);
193
+ if (t) for (let [e, n] of Object.entries(t)) ee(n) !== void 0 && a.add(e);
194
194
  }
195
195
  for (let o of a) {
196
196
  let a = i.map((e) => {
197
197
  let t = e.properties?.[o];
198
- return t ? te(t) : void 0;
198
+ return t ? ee(t) : void 0;
199
199
  }), s = a.filter((e) => e !== void 0), c = new Set(s);
200
200
  if (s.length < 2 || c.size !== s.length) continue;
201
201
  let l = r[o];
202
202
  if (l === void 0) continue;
203
203
  let u = a.findIndex((e) => e === l);
204
- if (u !== -1 && g(e, i[u], n) !== null) return t[u];
204
+ if (u !== -1 && _(e, i[u], n) !== null) return t[u];
205
205
  }
206
206
  }
207
- function re(e) {
207
+ function ne(e) {
208
208
  if (e === null) return "null";
209
209
  if (Array.isArray(e)) return "array";
210
210
  let t = typeof e;
211
211
  return t === "number" ? Number.isInteger(e) ? "integer" : "number" : t;
212
212
  }
213
- function g(e, t, n) {
213
+ function _(e, t, n) {
214
214
  let r = t.oneOf;
215
215
  if (Array.isArray(r)) {
216
216
  let t = null;
217
217
  for (let i of r) {
218
- let r = g(e, h(i, n), n);
218
+ let r = _(e, g(i, n), n);
219
219
  r !== null && (t === null || r > t) && (t = r);
220
220
  }
221
221
  return t;
222
222
  }
223
- let i = t.type, a = re(e);
223
+ let i = t.type, a = ne(e);
224
224
  if (typeof i == "string") {
225
225
  if (!(i === a || i === "number" && a === "integer")) return null;
226
226
  } else if (Array.isArray(i) && !i.some((e) => e === a || e === "number" && a === "integer")) return null;
@@ -239,7 +239,7 @@ function g(e, t, n) {
239
239
  }
240
240
  return c;
241
241
  }
242
- function _(e, t, n) {
242
+ function v(e, t, n) {
243
243
  for (let t of n.registry.ids()) {
244
244
  let r = n.registry.get(t);
245
245
  if (r?.ownsValue?.(e)) return {
@@ -247,43 +247,43 @@ function _(e, t, n) {
247
247
  v: r.encode(e, r.schema, n)
248
248
  };
249
249
  }
250
- if (Array.isArray(e)) return e.map((e) => _(e, {}, n));
251
- if (v(e)) {
250
+ if (Array.isArray(e)) return e.map((e) => v(e, {}, n));
251
+ if (y(e)) {
252
252
  let t = {};
253
- for (let [r, i] of Object.entries(e)) i !== void 0 && (t[r] = _(i, {}, n));
253
+ for (let [r, i] of Object.entries(e)) i !== void 0 && (t[r] = v(i, {}, n));
254
254
  return t;
255
255
  }
256
- return b(e);
256
+ return x(e);
257
257
  }
258
- function v(e) {
258
+ function y(e) {
259
259
  if (typeof e != "object" || !e || Array.isArray(e)) return !1;
260
260
  let t = Object.getPrototypeOf(e);
261
261
  return t === Object.prototype || t === null;
262
262
  }
263
- function y(e, t) {
263
+ function b(e, t) {
264
264
  if (typeof e == "object" && e && !Array.isArray(e) && "$apigen" in e) {
265
265
  let n = e, r = n[i], a = t.registry.get(r);
266
266
  if (a) return a.decode(n.v, a.schema, t);
267
267
  }
268
- if (Array.isArray(e)) return e.map((e) => y(e, t));
269
- if (v(e)) {
268
+ if (Array.isArray(e)) return e.map((e) => b(e, t));
269
+ if (y(e)) {
270
270
  let n = {};
271
- for (let [r, i] of Object.entries(e)) n[r] = y(i, t);
271
+ for (let [r, i] of Object.entries(e)) n[r] = b(i, t);
272
272
  return n;
273
273
  }
274
274
  return e;
275
275
  }
276
- function b(e) {
276
+ function x(e) {
277
277
  if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean") return e;
278
- if (Array.isArray(e)) return e.map(b);
278
+ if (Array.isArray(e)) return e.map(x);
279
279
  if (typeof e == "object") {
280
280
  let t = {};
281
- for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = b(r));
281
+ for (let [n, r] of Object.entries(e)) r !== void 0 && (t[n] = x(r));
282
282
  return t;
283
283
  }
284
284
  return null;
285
285
  }
286
- function ie(e, t) {
286
+ function re(e, t) {
287
287
  let n = /* @__PURE__ */ new Set(), r = [e];
288
288
  for (; r.length > 0;) {
289
289
  let e = r.pop();
@@ -314,7 +314,7 @@ function ie(e, t) {
314
314
  typeof l == "object" && l && r.push(l);
315
315
  }
316
316
  }
317
- function ae(e) {
317
+ function ie(e) {
318
318
  return {
319
319
  encode(t, n, r) {
320
320
  return p(t, n, f(e, r));
@@ -326,7 +326,7 @@ function ae(e) {
326
326
  }
327
327
  //#endregion
328
328
  //#region ../apigen-base-logical/src/lib/codecs/date-time.ts
329
- var x = {
329
+ var S = {
330
330
  id: "date-time",
331
331
  kind: "scalar",
332
332
  schema: {
@@ -350,7 +350,7 @@ var x = {
350
350
  if (n.mode === "strict" && Number.isNaN(new Date(e).getTime())) throw TypeError(`[date-time] invalid date-time string at "${n.path}": ${JSON.stringify(e)}`);
351
351
  return new Date(e);
352
352
  }
353
- }, S = {
353
+ }, C = {
354
354
  id: "int64",
355
355
  kind: "scalar",
356
356
  schema: {
@@ -386,10 +386,10 @@ var x = {
386
386
  };
387
387
  //#endregion
388
388
  //#region ../apigen-base-logical/src/lib/codecs/decimal.ts
389
- function oe(e) {
389
+ function ae(e) {
390
390
  return e;
391
391
  }
392
- var C = {
392
+ var w = {
393
393
  id: "decimal",
394
394
  kind: "scalar",
395
395
  schema: {
@@ -405,12 +405,12 @@ var C = {
405
405
  decode(e, t, n) {
406
406
  if (typeof e != "string") {
407
407
  if (n.mode === "strict") throw TypeError(`[decimal] expected a string on the wire at "${n.path}", got ${typeof e}`);
408
- return oe(String(e));
408
+ return ae(String(e));
409
409
  }
410
410
  if (n.mode === "strict" && !/^-?\d+(\.\d+)?$/.test(e)) throw TypeError(`[decimal] wire value "${e}" at "${n.path}" is not a valid decimal string`);
411
- return oe(e);
411
+ return ae(e);
412
412
  }
413
- }, w = {
413
+ }, T = {
414
414
  id: "byte",
415
415
  kind: "scalar",
416
416
  schema: {
@@ -434,7 +434,7 @@ var C = {
434
434
  if (n.mode === "strict" && !/^[A-Za-z0-9+/]*={0,2}$/.test(e)) throw TypeError(`[byte] wire value at "${n.path}" is not standard base64 (format:byte): "${e}"`);
435
435
  return new Uint8Array(Buffer.from(e, "base64"));
436
436
  }
437
- }, se = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, T = {
437
+ }, oe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, E = {
438
438
  id: "uuid",
439
439
  kind: "scalar",
440
440
  schema: {
@@ -452,14 +452,14 @@ var C = {
452
452
  if (n.mode === "strict") throw TypeError(`[uuid] expected a string on the wire at "${n.path}", got ${typeof e}`);
453
453
  return String(e).toLowerCase();
454
454
  }
455
- if (n.mode === "strict" && !se.test(e)) throw TypeError(`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);
455
+ if (n.mode === "strict" && !oe.test(e)) throw TypeError(`[uuid] wire value "${e}" at "${n.path}" is not a lowercase-hyphenated RFC 4122 UUID`);
456
456
  return e;
457
457
  }
458
- }, E = "NaN", D = "Infinity", O = "-Infinity", ce = /* @__PURE__ */ new Set([
459
- E,
458
+ }, D = "NaN", O = "Infinity", k = "-Infinity", se = /* @__PURE__ */ new Set([
460
459
  D,
461
- O
462
- ]), k = {
460
+ O,
461
+ k
462
+ ]), A = {
463
463
  id: "number-special",
464
464
  kind: "scalar",
465
465
  schema: { type: "number" },
@@ -470,49 +470,49 @@ var C = {
470
470
  return typeof e == "number" && !Number.isFinite(e);
471
471
  },
472
472
  encode(e, t, n) {
473
- return Number.isNaN(e) ? E : e === Infinity ? D : e === -Infinity ? O : e;
473
+ return Number.isNaN(e) ? D : e === Infinity ? O : e === -Infinity ? k : e;
474
474
  },
475
475
  decode(e, t, n) {
476
476
  if (typeof e == "number") return e;
477
477
  if (typeof e == "string") {
478
- if (e === E) return NaN;
479
- if (e === D) return Infinity;
480
- if (e === O) return -Infinity;
478
+ if (e === D) return NaN;
479
+ if (e === O) return Infinity;
480
+ if (e === k) return -Infinity;
481
481
  let t = Number(e);
482
482
  if (!Number.isNaN(t)) return t;
483
483
  }
484
- if (n.mode === "strict") throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...ce].join(", ")}.`);
484
+ if (n.mode === "strict") throw TypeError(`[number-special] unrecognized wire value at "${n.path}": ${JSON.stringify(e)}. Expected a number or one of ${[...se].join(", ")}.`);
485
485
  return NaN;
486
486
  }
487
- }, le = [
488
- x,
487
+ }, ce = [
489
488
  S,
490
489
  C,
491
490
  w,
492
491
  T,
493
- k
492
+ E,
493
+ A
494
494
  ];
495
- function ue(e, t = {}) {
496
- for (let n of le) e.register(n, { override: t.override ?? !1 });
495
+ function le(e, t = {}) {
496
+ for (let n of ce) e.register(n, { override: t.override ?? !1 });
497
497
  }
498
498
  //#endregion
499
499
  //#region ../apigen-base-logical/src/lib/example.ts
500
- var de = 12;
501
- function fe(e, t) {
500
+ var ue = 12;
501
+ function de(e, t) {
502
502
  let n = /^#\/(definitions|\$defs)\/(.+)$/.exec(e);
503
503
  if (!n) return;
504
504
  let [, r, i] = n;
505
505
  return (r === "$defs" ? t.$defs : t.definitions)?.[decodeURIComponent(i)];
506
506
  }
507
- function pe(e) {
507
+ function j(e) {
508
508
  return Array.isArray(e) && e.length > 0 ? e[0] : void 0;
509
509
  }
510
- function me(e) {
510
+ function fe(e) {
511
511
  if (Array.isArray(e.type)) return e.type.find((e) => e !== "null") ?? e.type[0];
512
512
  if (typeof e.type == "string") return e.type;
513
513
  if (e.properties) return "object";
514
514
  }
515
- function he(e) {
515
+ function pe(e) {
516
516
  switch (e.format) {
517
517
  case "date-time": return "1970-01-01T00:00:00.000Z";
518
518
  case "date": return "1970-01-01";
@@ -531,23 +531,23 @@ function he(e) {
531
531
  default: return "<string>";
532
532
  }
533
533
  }
534
- function A(e, t, n) {
534
+ function me(e, t, n) {
535
535
  let r = e.properties ?? {}, i = e.required ?? [], a = {};
536
536
  for (let e of i) {
537
537
  let i = r[e];
538
- a[e] = i === void 0 ? `<${e}>` : j(i, t, n + 1);
538
+ a[e] = i === void 0 ? `<${e}>` : M(i, t, n + 1);
539
539
  }
540
540
  return a;
541
541
  }
542
- function ge(e, t, n) {
542
+ function he(e, t, n) {
543
543
  let r = Array.isArray(e.items) ? e.items[0] : e.items;
544
- return r ? [j(r, t, n + 1)] : [];
544
+ return r ? [M(r, t, n + 1)] : [];
545
545
  }
546
- function j(e, t = e ?? {}, n = 0) {
547
- if (!e || n > de) return null;
546
+ function M(e, t = e ?? {}, n = 0) {
547
+ if (!e || n > ue) return null;
548
548
  if (typeof e.$ref == "string") {
549
- let r = fe(e.$ref, t);
550
- return r === void 0 ? null : j(r, t, n + 1);
549
+ let r = de(e.$ref, t);
550
+ return r === void 0 ? null : M(r, t, n + 1);
551
551
  }
552
552
  if (e.const !== void 0) return e.const;
553
553
  if (Array.isArray(e.enum) && e.enum.length > 0) return e.enum[0];
@@ -557,18 +557,18 @@ function j(e, t = e ?? {}, n = 0) {
557
557
  Object.assign(r, t.properties ?? {});
558
558
  for (let e of t.required ?? []) i.includes(e) || i.push(e);
559
559
  }
560
- return A({
560
+ return me({
561
561
  ...e,
562
562
  properties: r,
563
563
  required: i
564
564
  }, t, n);
565
565
  }
566
- let r = pe(e.oneOf) ?? pe(e.anyOf);
567
- if (r) return j(r, t, n + 1);
568
- switch (me(e)) {
569
- case "object": return A(e, t, n);
570
- case "array": return ge(e, t, n);
571
- case "string": return he(e);
566
+ let r = j(e.oneOf) ?? j(e.anyOf);
567
+ if (r) return M(r, t, n + 1);
568
+ switch (fe(e)) {
569
+ case "object": return me(e, t, n);
570
+ case "array": return he(e, t, n);
571
+ case "string": return pe(e);
572
572
  case "integer":
573
573
  case "number": return 0;
574
574
  case "boolean": return !1;
@@ -576,12 +576,12 @@ function j(e, t = e ?? {}, n = 0) {
576
576
  default: return null;
577
577
  }
578
578
  }
579
- function _e(e) {
579
+ function ge(e) {
580
580
  if (!e) return;
581
- let t = j(e);
581
+ let t = M(e);
582
582
  return `Example: ${JSON.stringify(t)}`;
583
583
  }
584
- x.id, S.id, C.id, w.id, T.id, k.id, Object.freeze({
584
+ S.id, C.id, w.id, T.id, E.id, A.id, Object.freeze({
585
585
  typescript: {
586
586
  "date-time": {
587
587
  encode: "$.toISOString()",
@@ -805,42 +805,42 @@ x.id, S.id, C.id, w.id, T.id, k.id, Object.freeze({
805
805
  });
806
806
  //#endregion
807
807
  //#region src/lib/dispatch.ts
808
- var M = o();
809
- ue(M);
810
- var N = ae(M.freeze());
811
- function P(e, t) {
808
+ var _e = o();
809
+ le(_e);
810
+ var ve = ie(_e.freeze());
811
+ function ye(e, t) {
812
812
  return t in (e.input?.properties ?? {});
813
813
  }
814
- function F(e) {
814
+ function be(e) {
815
815
  let t = e.input?.properties?.data;
816
816
  return Object.keys(t?.properties ?? {});
817
817
  }
818
- function ve(e, t) {
818
+ function xe(e, t) {
819
819
  let n = e.input?.properties?.data?.properties?.[t];
820
820
  return n === void 0 ? void 0 : n;
821
821
  }
822
- function ye(e, t) {
823
- return t === void 0 || e === void 0 ? e : N.decode(e, t);
822
+ function Se(e, t) {
823
+ return t === void 0 || e === void 0 ? e : ve.decode(e, t);
824
824
  }
825
- function I(e, t) {
825
+ function N(e, t) {
826
826
  let n = t.output;
827
- return !n || Object.keys(n).length === 0 ? e : N.encode(e, n);
827
+ return !n || Object.keys(n).length === 0 ? e : ve.encode(e, n);
828
828
  }
829
- async function L(e, t, n, r, i, a) {
830
- let o = F(n).map((e) => ye(a[e], ve(n, e)));
831
- if (P(n, "session") && t) {
829
+ async function Ce(e, t, n, r, i, a) {
830
+ let o = be(n).map((e) => Se(a[e], xe(n, e)));
831
+ if (ye(n, "session") && t) {
832
832
  let a = await t({ session: i.session });
833
- return I(await e[r](a, ...o), n);
833
+ return N(await e[r](a, ...o), n);
834
834
  }
835
835
  if (n.hasCtx) {
836
836
  let a = t ? await t(i) : void 0;
837
- return I(await e[r](a, ...o), n);
837
+ return N(await e[r](a, ...o), n);
838
838
  }
839
- return I(await e[r](...o), n);
839
+ return N(await e[r](...o), n);
840
840
  }
841
841
  //#endregion
842
842
  //#region src/lib/invoke.ts
843
- var R = class {
843
+ var we = class {
844
844
  constructor() {
845
845
  this._map = /* @__PURE__ */ new Map();
846
846
  }
@@ -854,21 +854,21 @@ var R = class {
854
854
  return this._map.has(e);
855
855
  }
856
856
  };
857
- function z(e = []) {
857
+ function Te(e = []) {
858
858
  return async function(t, n, r) {
859
859
  let i = r.schemas[t];
860
860
  if (!i) throw Error(`apigen/invoke: no schema found for operation "${t}"`);
861
- return e.reduceRight((e, t) => () => t(n, e), () => L(r.fns, r.createClient, i, t, n.envelope, n.domainArgs))();
861
+ return e.reduceRight((e, t) => () => t(n, e), () => Ce(r.fns, r.createClient, i, t, n.envelope, n.domainArgs))();
862
862
  };
863
863
  }
864
864
  //#endregion
865
865
  //#region src/lib/define-middleware.ts
866
- function be(e) {
866
+ function Ee(e) {
867
867
  return e;
868
868
  }
869
869
  //#endregion
870
870
  //#region src/lib/event-bus.ts
871
- var xe = class {
871
+ var De = class {
872
872
  constructor() {
873
873
  this.handlers = /* @__PURE__ */ new Map();
874
874
  }
@@ -886,19 +886,19 @@ var xe = class {
886
886
  this.handlers.clear();
887
887
  }
888
888
  async emit(e) {
889
- for (let [t, n] of this.handlers) if (Se(t, e)) for (let t of n) await t(e);
889
+ for (let [t, n] of this.handlers) if (Oe(t, e)) for (let t of n) await t(e);
890
890
  }
891
891
  };
892
- function Se(e, t) {
892
+ function Oe(e, t) {
893
893
  let [n, r, i] = e.split(":");
894
894
  return !(n !== "*" && n !== t.module || r && r !== "*" && r !== t.method || i && i !== "*" && i !== t.lifecycle);
895
895
  }
896
- function Ce(e, t) {
896
+ function ke(e, t) {
897
897
  for (let n of e) if (n.eventMapping) for (let [e, r] of Object.entries(n.eventMapping)) t.on(e, r);
898
898
  }
899
899
  //#endregion
900
900
  //#region src/lib/build-context.ts
901
- async function we(e, t, n) {
901
+ async function P(e, t, n) {
902
902
  let r = { ...t };
903
903
  for (let t of e) if (t.createContext) {
904
904
  await n.emit({
@@ -933,31 +933,31 @@ async function we(e, t, n) {
933
933
  e(import.meta.url);
934
934
  //#endregion
935
935
  //#region ../apigen-core-client/src/lib/get-safety.ts
936
- var Te = /* @__PURE__ */ new Set([
936
+ var F = /* @__PURE__ */ new Set([
937
937
  "string",
938
938
  "number",
939
939
  "boolean",
940
940
  "integer"
941
941
  ]);
942
- function Ee(e) {
942
+ function Ae(e) {
943
943
  if (typeof e != "object" || !e) return !1;
944
944
  let t = e;
945
945
  if (t.$ref !== void 0 || t.oneOf || t.anyOf || t.allOf) return !1;
946
946
  let { type: n } = t;
947
- return typeof n == "string" ? Te.has(n) : Array.isArray(n) ? n.every((e) => Te.has(e) || e === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((e) => [
947
+ return typeof n == "string" ? F.has(n) : Array.isArray(n) ? n.every((e) => F.has(e) || e === "null") : Array.isArray(t.enum) && t.enum.length > 0 ? t.enum.every((e) => [
948
948
  "string",
949
949
  "number",
950
950
  "boolean"
951
951
  ].includes(typeof e)) : !1;
952
952
  }
953
- function De(e) {
953
+ function I(e) {
954
954
  if (!e || typeof e != "object") return !1;
955
955
  let t = e.properties;
956
- return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(Ee);
956
+ return t === void 0 || typeof t != "object" || !t ? !1 : Object.values(t).every(Ae);
957
957
  }
958
958
  //#endregion
959
959
  //#region ../apigen-core-client/src/lib/compose-schemas.ts
960
- function Oe(e) {
960
+ function je(e) {
961
961
  let t = {}, n = (e) => {
962
962
  for (let n of ["definitions", "$defs"]) {
963
963
  let r = e[n];
@@ -969,17 +969,17 @@ function Oe(e) {
969
969
  };
970
970
  for (let t of Object.values(e.schemas)) n(t.input), n(t.output);
971
971
  if (Object.keys(t).length !== 0) for (let [n, r] of Object.entries(e.schemas)) try {
972
- ie(r.input, t), ie(r.output, t);
972
+ re(r.input, t), re(r.output, t);
973
973
  } catch (e) {
974
974
  throw Error(`[apigen-core-client] Schema validation failed for function "${n}": ${e.message}`);
975
975
  }
976
976
  }
977
- function ke(e, t) {
977
+ function Me(e, t) {
978
978
  let n = ["apigen calling convention: all domain parameters go inside a \"data\" envelope — e.g. { \"data\": { ... } }" + (t ? "." : " (an empty object for this zero-parameter tool).")];
979
979
  return e.length > 0 && n.push(`Field(s) ${e.map((e) => `"${e}"`).join(", ")} are transport-level envelope metadata, NOT domain data — do not nest them under "data". Over MCP they are read from arguments._meta["x-<pluginId>-<field>"] (default pluginId "adhd"); see @adhd/apigen-engine-naming's envelopeMetaKey/envelopeCliFlag/envelopeEnvVar for the HTTP-header / CLI-flag / env-var equivalents.`), n.join(" ");
980
980
  }
981
- function Ae(e, t, n) {
982
- Oe(e);
981
+ function Ne(e, t, n) {
982
+ je(e);
983
983
  let r = {};
984
984
  for (let [i, a] of Object.entries(e.schemas)) {
985
985
  let e = n?.[i] ?? {}, o = a.input.properties ?? {}, s = a.input.required ?? [], c = {}, l = [], u = {};
@@ -989,7 +989,7 @@ function Ae(e, t, n) {
989
989
  properties: o,
990
990
  additionalProperties: !1,
991
991
  ...s.length > 0 ? { required: s } : {}
992
- }, f = a.safe === !0 || De(a.input), p = a.input.definitions, m = a.input.$defs;
992
+ }, f = a.safe === !0 || I(a.input), p = a.input.definitions, m = a.input.$defs;
993
993
  r[i] = {
994
994
  input: {
995
995
  type: "object",
@@ -999,7 +999,7 @@ function Ae(e, t, n) {
999
999
  },
1000
1000
  required: [...l, ...s.length > 0 ? ["data"] : []],
1001
1001
  additionalProperties: !1,
1002
- description: ke(Object.keys(c), Object.keys(o).length > 0),
1002
+ description: Me(Object.keys(c), Object.keys(o).length > 0),
1003
1003
  ...p ? { definitions: p } : {},
1004
1004
  ...m ? { $defs: m } : {}
1005
1005
  },
@@ -1013,53 +1013,53 @@ function Ae(e, t, n) {
1013
1013
  }
1014
1014
  //#endregion
1015
1015
  //#region ../apigen-core-client/src/lib/schema-builders/ts-json-schema.ts
1016
- var je = { "decimal.js": "Decimal" };
1017
- function Me(e) {
1016
+ var Pe = { "decimal.js": "Decimal" };
1017
+ function Fe(e) {
1018
1018
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1019
1019
  }
1020
- Object.entries(je).map(([e, t]) => ({
1021
- pattern: RegExp(`import\\(["'][^"']*${Me(e)}[^"']*["']\\)\\.\\w+`, "g"),
1020
+ Object.entries(Pe).map(([e, t]) => ({
1021
+ pattern: RegExp(`import\\(["'][^"']*${Fe(e)}[^"']*["']\\)\\.\\w+`, "g"),
1022
1022
  key: t
1023
1023
  }));
1024
1024
  //#endregion
1025
1025
  //#region src/lib/types.ts
1026
- var B = class extends Error {
1026
+ var L = class extends Error {
1027
1027
  constructor(e) {
1028
1028
  super(e), this.name = "ConfigurationError";
1029
1029
  }
1030
1030
  };
1031
1031
  //#endregion
1032
1032
  //#region src/lib/api-package.ts
1033
- function Ne(e) {
1033
+ function R(e) {
1034
1034
  for (let t of e) for (let e of Object.keys(t.eventMapping ?? {})) {
1035
1035
  let [n] = e.split(":");
1036
- if (n !== "*" && n === t.id) throw new B(`Middleware "${t.id}" subscribes to its own events via "${e}". This would cause infinite recursion.`);
1036
+ if (n !== "*" && n === t.id) throw new L(`Middleware "${t.id}" subscribes to its own events via "${e}". This would cause infinite recursion.`);
1037
1037
  }
1038
1038
  }
1039
- function Pe(e) {
1039
+ function Ie(e) {
1040
1040
  let { domainSchemas: t, middlewares: n, overrides: r = {}, strict: i = !1 } = e;
1041
- Ne(n);
1041
+ R(n);
1042
1042
  for (let e of Object.keys(r)) if (!(e in t.schemas)) {
1043
1043
  let t = `Override key "${e}" not found in domain schemas.`;
1044
- if (i) throw new B(t);
1044
+ if (i) throw new L(t);
1045
1045
  console.warn("[apigen-runtime]", t);
1046
1046
  }
1047
1047
  let a = new Set(n.map((e) => e.id));
1048
1048
  for (let [e, t] of Object.entries(r)) for (let n of Object.keys(t ?? {})) if (!a.has(n)) {
1049
1049
  let t = `Override key "${e}.${n}" does not match any declared middleware id.`;
1050
- if (i) throw new B(t);
1050
+ if (i) throw new L(t);
1051
1051
  console.warn("[apigen-runtime]", t);
1052
1052
  }
1053
- let o = Ae(t, n, r), s = new xe();
1054
- return Ce(n, s), {
1053
+ let o = Ne(t, n, r), s = new De();
1054
+ return ke(n, s), {
1055
1055
  schemas: o,
1056
- createClient: async (e) => we(n, e, s),
1056
+ createClient: async (e) => P(n, e, s),
1057
1057
  dispose: () => s.clear()
1058
1058
  };
1059
1059
  }
1060
1060
  //#endregion
1061
1061
  //#region src/lib/logger.ts
1062
- function Fe(e = {}) {
1062
+ function Le(e = {}) {
1063
1063
  let n = e.level ?? "info", r = typeof e.destination == "string" && e.destination.length > 0, i = !r && !!process.stderr.isTTY, a = e.format ?? (i ? "pretty" : "json"), o = { level: n };
1064
1064
  if (a === "pretty") return o.transport = {
1065
1065
  target: "pino-pretty",
@@ -1082,35 +1082,35 @@ function Fe(e = {}) {
1082
1082
  }
1083
1083
  //#endregion
1084
1084
  //#region src/lib/describe-params.ts
1085
- function Ie(e) {
1085
+ function Re(e) {
1086
1086
  if (e?.type !== "object" || !e.properties) return;
1087
1087
  let t = Object.entries(e.properties);
1088
1088
  if (t.length === 0) return;
1089
1089
  let n = new Set(e.required ?? []);
1090
- return `{ ${t.map(([e, t]) => `${e}${n.has(e) ? "" : "?"}: ${V(t)}`).join(", ")} }`;
1090
+ return `{ ${t.map(([e, t]) => `${e}${n.has(e) ? "" : "?"}: ${z(t)}`).join(", ")} }`;
1091
1091
  }
1092
- function Le(e) {
1092
+ function ze(e) {
1093
1093
  return typeof e == "string" ? `'${e}'` : JSON.stringify(e);
1094
1094
  }
1095
- function Re(e) {
1095
+ function Be(e) {
1096
1096
  let t = e.enum ?? [];
1097
- return t.length === 0 ? "unknown" : t.map(Le).join("|");
1097
+ return t.length === 0 ? "unknown" : t.map(ze).join("|");
1098
1098
  }
1099
- function ze(e, t) {
1100
- return e.map((e) => V(e, t)).join(" | ");
1099
+ function Ve(e, t) {
1100
+ return e.map((e) => z(e, t)).join(" | ");
1101
1101
  }
1102
- function V(e, t = 0) {
1102
+ function z(e, t = 0) {
1103
1103
  if (!e) return "unknown";
1104
- if (e.type === "array") return `${V(e.items, 0)}[]`;
1105
- if (e.enum) return Re(e);
1104
+ if (e.type === "array") return `${z(e.items, 0)}[]`;
1105
+ if (e.enum) return Be(e);
1106
1106
  if (e.$ref) return String(e.$ref).split("/").pop() || "object";
1107
1107
  let n = e.anyOf ?? e.oneOf;
1108
- return n ? n.length === 0 ? "unknown" : t >= 2 ? ze(n, t - 1) : "union" : t >= 1 && e.type === "object" ? Ie(e) ?? "object" : e.type ?? "object";
1108
+ return n ? n.length === 0 ? "unknown" : t >= 2 ? Ve(n, t - 1) : "union" : t >= 1 && e.type === "object" ? Re(e) ?? "object" : e.type ?? "object";
1109
1109
  }
1110
- function Be(e) {
1110
+ function B(e) {
1111
1111
  let t = (e?.input ?? {}).properties?.data, n = t?.properties ?? {}, r = new Set(t?.required ?? []), i = Object.entries(n).map(([e, t]) => ({
1112
1112
  name: e,
1113
- type: V(t, 2),
1113
+ type: z(t, 2),
1114
1114
  required: r.has(e)
1115
1115
  }));
1116
1116
  return {
@@ -1120,16 +1120,16 @@ function Be(e) {
1120
1120
  }
1121
1121
  //#endregion
1122
1122
  //#region src/lib/coerce-query.ts
1123
- function Ve(e) {
1123
+ function He(e) {
1124
1124
  let t;
1125
1125
  return t = Array.isArray(e) ? e : e ? [e] : [], t.find((e) => e === "number" || e === "integer" || e === "boolean");
1126
1126
  }
1127
- function He(e, t) {
1127
+ function Ue(e, t) {
1128
1128
  let n = (t?.input ?? {}).properties?.data?.properties ?? {}, r = { ...e };
1129
1129
  for (let [e, t] of Object.entries(n)) {
1130
1130
  let n = r[e];
1131
1131
  if (typeof n != "string") continue;
1132
- let i = Ve(t?.type);
1132
+ let i = He(t?.type);
1133
1133
  if (i === "number" || i === "integer") {
1134
1134
  let t = Number(n);
1135
1135
  !Number.isNaN(t) && n.trim() !== "" && (r[e] = t);
@@ -1139,7 +1139,7 @@ function He(e, t) {
1139
1139
  }
1140
1140
  //#endregion
1141
1141
  //#region src/lib/fn-table.ts
1142
- var Ue = /* @__PURE__ */ new Set([
1142
+ var V = /* @__PURE__ */ new Set([
1143
1143
  "default",
1144
1144
  "module.exports",
1145
1145
  "__esModule"
@@ -1147,10 +1147,10 @@ var Ue = /* @__PURE__ */ new Set([
1147
1147
  function We(e) {
1148
1148
  let t = {}, n = (e, r) => {
1149
1149
  for (let [i, a] of Object.entries(e)) if (typeof a == "function") {
1150
- !Ue.has(i) && !(i in t) && (t[i] = a);
1150
+ !V.has(i) && !(i in t) && (t[i] = a);
1151
1151
  let e = a.name;
1152
1152
  e && !(e in t) && (t[e] = a);
1153
- } else a && typeof a == "object" && r < 2 && Ue.has(i) && n(a, r + 1);
1153
+ } else a && typeof a == "object" && r < 2 && V.has(i) && n(a, r + 1);
1154
1154
  };
1155
1155
  return n(e, 0), t;
1156
1156
  }
@@ -1270,7 +1270,7 @@ function G(e) {
1270
1270
  return e === null ? !1 : Array.isArray(e) ? e.some(G) : typeof e != "object" || Object.values(e).some(G);
1271
1271
  }
1272
1272
  function tt(e, t) {
1273
- let n = [`Validation failed: ${et(e)}`], r = j(t);
1273
+ let n = [`Validation failed: ${et(e)}`], r = M(t);
1274
1274
  return G(r) && n.push(`Example: ${JSON.stringify(r)}`), n.join(" — ");
1275
1275
  }
1276
1276
  var nt = async (e, t) => {
@@ -1585,20 +1585,20 @@ function yt(e) {
1585
1585
  //#endregion
1586
1586
  //#region src/lib/logical/host-ts.ts
1587
1587
  var bt = [
1588
- x,
1589
1588
  S,
1590
1589
  C,
1591
1590
  w,
1592
1591
  T,
1593
- k
1594
- ], xt = yt({
1592
+ E,
1593
+ A
1594
+ ], X = yt({
1595
1595
  id: "ts.NominalSentinel",
1596
1596
  schema: {
1597
1597
  type: "object",
1598
1598
  "x-apigen-logical": "nominal",
1599
1599
  "x-apigen-codec": "ts.NominalSentinel"
1600
1600
  }
1601
- }), St = mt({
1601
+ }), xt = mt({
1602
1602
  id: "ts.UnionSentinel",
1603
1603
  schema: {
1604
1604
  oneOf: [],
@@ -1610,32 +1610,32 @@ var bt = [
1610
1610
  "x-apigen-codec": "ts.UnionSentinel"
1611
1611
  }
1612
1612
  });
1613
- function Ct() {
1613
+ function St() {
1614
1614
  let e = [
1615
1615
  ...bt.map((e) => [e.id, e]),
1616
- [xt.id, xt],
1617
- [St.id, St]
1616
+ [X.id, X],
1617
+ [xt.id, xt]
1618
1618
  ];
1619
1619
  return Object.freeze(new Map(e));
1620
1620
  }
1621
- var wt = Object.freeze({
1621
+ var Ct = Object.freeze({
1622
1622
  host: "ts",
1623
1623
  logicalTypeVersion: d,
1624
- codecs: Ct()
1624
+ codecs: St()
1625
1625
  });
1626
1626
  //#endregion
1627
1627
  //#region src/lib/tool-description.ts
1628
- function Tt(e, t, n) {
1628
+ function wt(e, t, n) {
1629
1629
  let r = [
1630
1630
  n,
1631
1631
  typeof t?.input?.description == "string" ? t.input.description : void 0,
1632
- _e(t?.input)
1632
+ ge(t?.input)
1633
1633
  ].filter((e) => typeof e == "string" && e.length > 0);
1634
1634
  return r.length > 0 ? r.join(" — ") : e;
1635
1635
  }
1636
1636
  //#endregion
1637
1637
  //#region src/lib/mcp-output-schema.ts
1638
- function Et(e) {
1638
+ function Tt(e) {
1639
1639
  if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).length === 0) return {
1640
1640
  outputSchema: void 0,
1641
1641
  wrapped: !1
@@ -1649,25 +1649,25 @@ function Et(e) {
1649
1649
  wrapped: !1
1650
1650
  };
1651
1651
  }
1652
- function Dt(e, t) {
1652
+ function Et(e, t) {
1653
1653
  if (e) return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
1654
1654
  }
1655
1655
  //#endregion
1656
1656
  //#region src/lib/batch.ts
1657
- var Ot = 4, kt = 32;
1658
- function X(e) {
1657
+ var Dt = 4, Ot = 32;
1658
+ function Z(e) {
1659
1659
  return Ke(e) ? e : e instanceof Error ? new H("internal", e.message) : e;
1660
1660
  }
1661
- function At(e, t) {
1661
+ function kt(e, t) {
1662
1662
  if (e === "serial" || e === "chained") return 1;
1663
1663
  let n = t ?? 4;
1664
1664
  return !Number.isFinite(n) || n < 1 ? 1 : Math.min(Math.floor(n), 32);
1665
1665
  }
1666
- function jt() {}
1667
- function Mt(e, t) {
1666
+ function At() {}
1667
+ function jt(e, t) {
1668
1668
  if (!e && !t) return {
1669
1669
  signal: void 0,
1670
- dispose: jt
1670
+ dispose: At
1671
1671
  };
1672
1672
  let n = new AbortController(), r = () => {
1673
1673
  n.abort(e?.reason);
@@ -1683,8 +1683,8 @@ function Mt(e, t) {
1683
1683
  }
1684
1684
  };
1685
1685
  }
1686
- async function Nt(e, t, n, r, i, a) {
1687
- let o = Mt(r.signal, a);
1686
+ async function Mt(e, t, n, r, i, a) {
1687
+ let o = jt(r.signal, a);
1688
1688
  try {
1689
1689
  let a = await e(t, o.signal ? {
1690
1690
  ...r,
@@ -1697,7 +1697,7 @@ async function Nt(e, t, n, r, i, a) {
1697
1697
  return {
1698
1698
  index: n,
1699
1699
  status: "rejected",
1700
- reason: X(t.error),
1700
+ reason: Z(t.error),
1701
1701
  ...t.phase === "after-first-chunk" ? { chunksDelivered: t.chunksDelivered } : {}
1702
1702
  };
1703
1703
  }
@@ -1716,17 +1716,17 @@ async function Nt(e, t, n, r, i, a) {
1716
1716
  return {
1717
1717
  index: n,
1718
1718
  status: "rejected",
1719
- reason: X(e)
1719
+ reason: Z(e)
1720
1720
  };
1721
1721
  } finally {
1722
1722
  o.dispose();
1723
1723
  }
1724
1724
  }
1725
- async function Pt(e, t, n, r, i = {}) {
1726
- let a = i.mode ?? "parallel", o = i.onItemError ?? "continue", s = At(a, i.concurrency), c = Array(n.length), l = (e) => ({
1725
+ async function Nt(e, t, n, r, i = {}) {
1726
+ let a = i.mode ?? "parallel", o = i.onItemError ?? "continue", s = kt(a, i.concurrency), c = Array(n.length), l = (e) => ({
1727
1727
  index: e,
1728
1728
  status: "rejected",
1729
- reason: X(/* @__PURE__ */ Error("apigen/invokeBatch: not attempted — an earlier item failed and " + (a === "chained" ? "mode is \"chained\"" : "onItemError is \"abort\"")))
1729
+ reason: Z(/* @__PURE__ */ Error("apigen/invokeBatch: not attempted — an earlier item failed and " + (a === "chained" ? "mode is \"chained\"" : "onItemError is \"abort\"")))
1730
1730
  });
1731
1731
  if (a === "serial" || a === "chained") {
1732
1732
  let s = !1;
@@ -1735,7 +1735,7 @@ async function Pt(e, t, n, r, i = {}) {
1735
1735
  c[u] = l(u);
1736
1736
  continue;
1737
1737
  }
1738
- let d = await Nt(e, t, u, n[u], r, i.itemTimeoutMs);
1738
+ let d = await Mt(e, t, u, n[u], r, i.itemTimeoutMs);
1739
1739
  c[u] = d, d.status === "rejected" && (a === "chained" || o === "abort") && (s = !0);
1740
1740
  }
1741
1741
  return c;
@@ -1748,7 +1748,7 @@ async function Pt(e, t, n, r, i = {}) {
1748
1748
  c[a] = l(a);
1749
1749
  continue;
1750
1750
  }
1751
- let s = await Nt(e, t, a, n[a], r, i.itemTimeoutMs);
1751
+ let s = await Mt(e, t, a, n[a], r, i.itemTimeoutMs);
1752
1752
  c[a] = s, s.status === "rejected" && o === "abort" && (d = !0);
1753
1753
  }
1754
1754
  });
@@ -1756,17 +1756,17 @@ async function Pt(e, t, n, r, i = {}) {
1756
1756
  }
1757
1757
  //#endregion
1758
1758
  //#region ../apigen-engine-naming/src/lib/naming.ts
1759
- function Ft(e) {
1759
+ function Pt(e) {
1760
1760
  return e.words.join("-");
1761
1761
  }
1762
- function It(e) {
1763
- return e.words.map(Ht).join("");
1762
+ function Ft(e) {
1763
+ return e.words.map(Vt).join("");
1764
1764
  }
1765
- function Lt(e) {
1765
+ function It(e) {
1766
1766
  return e.words.join("_");
1767
1767
  }
1768
- function Rt(e, t = {}) {
1769
- let n = [e.namespace, ...e.path], r = e.safe || De(e.input) ? "GET" : "POST", i = t.http?.verb?.[e.id] ?? r, a = "/" + n.map((e) => Ft(e)).join("/"), o = n.map((e) => Lt(e)).join("_"), s = n.map((e) => Lt(e)).slice(0, -1).join("."), c = It(n[n.length - 2] ?? n[0]), l = It(n[n.length - 1]), u = n.map((e) => Ft(e));
1768
+ function Lt(e, t = {}) {
1769
+ let n = [e.namespace, ...e.path], r = e.safe || I(e.input) ? "GET" : "POST", i = t.http?.verb?.[e.id] ?? r, a = "/" + n.map((e) => Pt(e)).join("/"), o = n.map((e) => It(e)).join("_"), s = n.map((e) => It(e)).slice(0, -1).join("."), c = Ft(n[n.length - 2] ?? n[0]), l = Ft(n[n.length - 1]), u = n.map((e) => Pt(e));
1770
1770
  return {
1771
1771
  http: {
1772
1772
  verb: i,
@@ -1781,79 +1781,79 @@ function Rt(e, t = {}) {
1781
1781
  cli: { path: u }
1782
1782
  };
1783
1783
  }
1784
- function zt(e, t) {
1784
+ function Rt(e, t) {
1785
1785
  return `x-${e}-${t}`;
1786
1786
  }
1787
- function Bt(e, t) {
1787
+ function zt(e, t) {
1788
1788
  return `--${e}-${t}`;
1789
1789
  }
1790
- function Vt(e, t) {
1790
+ function Bt(e, t) {
1791
1791
  let n = (e) => e.toUpperCase().replace(/-/g, "_");
1792
1792
  return e === "adhd" ? `APIGEN_${n(t)}` : `APIGEN_${n(e)}_${n(t)}`;
1793
1793
  }
1794
- function Ht(e) {
1794
+ function Vt(e) {
1795
1795
  return e.length === 0 ? e : e[0].toUpperCase() + e.slice(1);
1796
1796
  }
1797
1797
  //#endregion
1798
1798
  //#region src/lib/op-plan.ts
1799
- function Z(e) {
1799
+ function Q(e) {
1800
1800
  return e.anyOf ?? e.oneOf;
1801
1801
  }
1802
- function Ut(e) {
1802
+ function Ht(e) {
1803
1803
  if (!e) return !1;
1804
1804
  if (e.type === "array" || e.type === "object") return !0;
1805
- let t = Z(e);
1805
+ let t = Q(e);
1806
1806
  if (t) {
1807
1807
  let e = t.filter((e) => e.type !== "null");
1808
1808
  return e.length > 0 && e.every((e) => e.type === "array" || e.type === "object");
1809
1809
  }
1810
1810
  return !1;
1811
1811
  }
1812
- function Wt(e) {
1812
+ function Ut(e) {
1813
1813
  if (!e) return !1;
1814
1814
  if (e.type === "boolean") return !0;
1815
- let t = Z(e);
1815
+ let t = Q(e);
1816
1816
  if (t) {
1817
1817
  let e = t.filter((e) => e.type !== "null");
1818
1818
  return e.length > 0 && e.every((e) => e.type === "boolean");
1819
1819
  }
1820
1820
  return !1;
1821
1821
  }
1822
- function Gt(e) {
1822
+ function Wt(e) {
1823
1823
  if (!e) return !1;
1824
1824
  if (e.type === "number" || e.type === "integer") return !0;
1825
- let t = Z(e);
1825
+ let t = Q(e);
1826
1826
  if (t) {
1827
1827
  let e = t.filter((e) => e.type !== "null");
1828
1828
  return e.length > 0 && e.every((e) => e.type === "number" || e.type === "integer");
1829
1829
  }
1830
1830
  return !1;
1831
1831
  }
1832
- function Kt(e) {
1832
+ function Gt(e) {
1833
1833
  return e.replace(/[A-Z]/g, (e) => "-" + e.toLowerCase());
1834
1834
  }
1835
- function qt(e) {
1835
+ function Kt(e) {
1836
1836
  let t = e.input?.properties?.data;
1837
1837
  return {
1838
1838
  props: t?.properties ?? {},
1839
1839
  required: t?.required ?? []
1840
1840
  };
1841
1841
  }
1842
- function Q(e) {
1842
+ function qt(e) {
1843
1843
  return typeof e.handler == "function";
1844
1844
  }
1845
1845
  function Jt(e) {
1846
1846
  let t = e.input?.properties ?? {}, n = e["x-apigen-envelope"], r = [];
1847
1847
  for (let e of Object.keys(t)) {
1848
1848
  if (e === "data") continue;
1849
- let t = n?.[e] ?? "adhd", i = zt(t, e);
1849
+ let t = n?.[e] ?? "adhd", i = Rt(t, e);
1850
1850
  r.push({
1851
1851
  field: e,
1852
1852
  pluginId: t,
1853
1853
  httpHeader: i,
1854
1854
  mcpMetaKey: i,
1855
- cliFlag: Bt(t, e),
1856
- envVar: Vt(t, e)
1855
+ cliFlag: zt(t, e),
1856
+ envVar: Bt(t, e)
1857
1857
  });
1858
1858
  }
1859
1859
  return r;
@@ -1865,11 +1865,11 @@ function Yt(e, t, n, r) {
1865
1865
  });
1866
1866
  }
1867
1867
  function Xt(e, t) {
1868
- let n = /* @__PURE__ */ new Map(), { props: r } = qt(e);
1868
+ let n = /* @__PURE__ */ new Map(), { props: r } = Kt(e);
1869
1869
  for (let [e, t] of Object.entries(r)) {
1870
1870
  let r = "string";
1871
- Wt(t) ? r = "boolean" : (Ut(t) || Gt(t)) && (r = "json");
1872
- let i = Kt(e), a = {
1871
+ Ut(t) ? r = "boolean" : (Ht(t) || Wt(t)) && (r = "json");
1872
+ let i = Gt(e), a = {
1873
1873
  camelKey: e,
1874
1874
  kind: "domain",
1875
1875
  valueKind: r
@@ -1888,7 +1888,7 @@ function Xt(e, t) {
1888
1888
  return n;
1889
1889
  }
1890
1890
  function Zt(e) {
1891
- let { op: t, schema: n, transport: r, projection: i } = e, a = Rt(t, i), o = n ? Jt(n) : [], s = n ? Xt(n, o) : /* @__PURE__ */ new Map(), c = n ? Be(n).params : void 0, l = {
1891
+ let { op: t, schema: n, transport: r, projection: i } = e, a = Lt(t, i), o = n ? Jt(n) : [], s = n ? Xt(n, o) : /* @__PURE__ */ new Map(), c = n ? B(n).params : void 0, l = {
1892
1892
  op: t,
1893
1893
  transport: r,
1894
1894
  http: a.http,
@@ -1899,9 +1899,9 @@ function Zt(e) {
1899
1899
  envelope: o,
1900
1900
  cliFlags: s,
1901
1901
  streaming: t.streaming,
1902
- isMount: Q(t)
1902
+ isMount: qt(t)
1903
1903
  };
1904
- if (Q(t)) {
1904
+ if (qt(t)) {
1905
1905
  let e = t.handler;
1906
1906
  l.mountHandler = async (t) => e(t);
1907
1907
  }
@@ -1921,23 +1921,23 @@ function en(e) {
1921
1921
  let t = e.useOptions;
1922
1922
  return t && typeof t == "object" ? t : {};
1923
1923
  }
1924
- function $(e) {
1924
+ function tn(e) {
1925
1925
  return async function(t, n) {
1926
1926
  let r = Object.assign(t, { data: t.domainArgs });
1927
1927
  return await e.layer(r, n);
1928
1928
  };
1929
1929
  }
1930
- function tn(e, t) {
1930
+ function nn(e, t) {
1931
1931
  let n = [];
1932
1932
  for (let e of t) {
1933
1933
  let t = e.capabilities?.layer;
1934
- t && n.push($(t));
1934
+ t && n.push(tn(t));
1935
1935
  }
1936
- return n.push(it(e)), z(n);
1936
+ return n.push(it(e)), Te(n);
1937
1937
  }
1938
1938
  //#endregion
1939
1939
  //#region src/lib/dispatch-for-plan.ts
1940
- function nn() {
1940
+ function rn() {
1941
1941
  let e = /* @__PURE__ */ new Map();
1942
1942
  return {
1943
1943
  get: (t) => e.get(t),
@@ -1946,7 +1946,7 @@ function nn() {
1946
1946
  }
1947
1947
  };
1948
1948
  }
1949
- var rn = {
1949
+ var an = {
1950
1950
  input: {
1951
1951
  type: "object",
1952
1952
  properties: { data: {
@@ -1956,11 +1956,11 @@ var rn = {
1956
1956
  },
1957
1957
  output: {}
1958
1958
  };
1959
- async function an(e, t, n, r) {
1959
+ async function on(e, t, n, r) {
1960
1960
  let i = {
1961
1961
  ...n,
1962
1962
  operation: { id: e.op.id },
1963
- ctx: new R(),
1963
+ ctx: new we(),
1964
1964
  transport: e.transport
1965
1965
  };
1966
1966
  if (e.isMount) {
@@ -1970,17 +1970,37 @@ async function an(e, t, n, r) {
1970
1970
  operation: e.op,
1971
1971
  data: n.domainArgs,
1972
1972
  envelope: n.envelope,
1973
- ctx: nn(),
1973
+ ctx: rn(),
1974
1974
  transport: e.transport,
1975
1975
  signal: n.signal ?? new AbortController().signal
1976
1976
  }, s = {
1977
1977
  ...r,
1978
1978
  fns: { [e.op.id]: () => a(o) },
1979
- schemas: { [e.op.id]: rn }
1979
+ schemas: { [e.op.id]: an }
1980
1980
  };
1981
1981
  return t(e.op.id, i, s);
1982
1982
  }
1983
1983
  return t(e.op.id, i, r);
1984
1984
  }
1985
1985
  //#endregion
1986
- export { Ot as BATCH_DEFAULT_CONCURRENCY, kt as BATCH_MAX_CONCURRENCY, xe as EventBus, ot as InstanceRegistry, R as LayerContext, q as UnionCodecError, rt as ValidateSchemasToken, bt as WELL_KNOWN_TS_CODECS, $ as adaptCoreLayer, Ne as assertNoSelfSubscription, we as buildContext, We as buildFnTable, Et as buildMcpOutputSchema, Zt as buildOpPlan, Tt as buildToolDescription, He as coerceQueryParams, lt as collectWithPhase, Pe as createApiPackage, z as createInvoker, Fe as createLogger, tn as createPackageInvoker, st as createStream, mt as createUnionCodec, F as dataParamNames, be as defineMiddleware, Be as describeParams, L as dispatch, an as dispatchForPlan, ct as drainStream, Pt as invokeBatch, ut as isApiStream, it as makeValidateLayer, P as needsEnvelopeField, $t as readExitCodeHook, en as readUseOptions, Qt as readUsePlugins, wt as tsHostBinding, nt as validateLayer, Ce as wireObservers, Dt as wrapMcpStructuredContent };
1986
+ //#region src/lib/bind-host.ts
1987
+ var $ = "127.0.0.1";
1988
+ function sn(e) {
1989
+ let t = e.trim().toLowerCase().replace(/^\[|\]$/g, "");
1990
+ if (t === "localhost" || t === "::1") return !0;
1991
+ let n = t.startsWith("::ffff:") ? t.slice(7) : t;
1992
+ return /^127(\.\d{1,3}){3}$/.test(n);
1993
+ }
1994
+ function cn(e) {
1995
+ if (typeof e != "string") return $;
1996
+ let t = e.trim();
1997
+ return t === "" ? $ : t;
1998
+ }
1999
+ function ln(e, t, n) {
2000
+ return !sn(e) && (n?.warn({
2001
+ host: e,
2002
+ host_kind: t
2003
+ }, `${t} binding non-loopback host "${e}": the server will be reachable from the network. Omit the host option to bind ${$}.`), !0);
2004
+ }
2005
+ //#endregion
2006
+ export { Dt as BATCH_DEFAULT_CONCURRENCY, Ot as BATCH_MAX_CONCURRENCY, $ as DEFAULT_LISTEN_HOST, De as EventBus, ot as InstanceRegistry, we as LayerContext, q as UnionCodecError, rt as ValidateSchemasToken, bt as WELL_KNOWN_TS_CODECS, tn as adaptCoreLayer, R as assertNoSelfSubscription, P as buildContext, We as buildFnTable, Tt as buildMcpOutputSchema, Zt as buildOpPlan, wt as buildToolDescription, Ue as coerceQueryParams, lt as collectWithPhase, Ie as createApiPackage, Te as createInvoker, Le as createLogger, nn as createPackageInvoker, st as createStream, mt as createUnionCodec, be as dataParamNames, Ee as defineMiddleware, B as describeParams, Ce as dispatch, on as dispatchForPlan, ct as drainStream, Nt as invokeBatch, ut as isApiStream, sn as isLoopbackListenHost, it as makeValidateLayer, ye as needsEnvelopeField, $t as readExitCodeHook, en as readUseOptions, Qt as readUsePlugins, cn as resolveListenHost, Ct as tsHostBinding, nt as validateLayer, ln as warnIfNonLoopbackListen, ke as wireObservers, Et as wrapMcpStructuredContent };