@foldkit/devtools-mcp 0.25.0-canary.fbc0bbd6fde6 → 0.26.0-canary.54f8bcd443b4

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/server.js CHANGED
@@ -12,7 +12,7 @@ import * as Path from "node:path";
12
12
  import { dirname, join, win32 } from "node:path";
13
13
  import * as NodeUrl from "node:url";
14
14
  import process$1 from "node:process";
15
- import { isIPv6 } from "node:net";
15
+ import { connect, isIPv6 } from "node:net";
16
16
  import { lstat, realpath } from "node:fs/promises";
17
17
  //#region \0rolldown/runtime.js
18
18
  var __create = Object.create;
@@ -3029,7 +3029,7 @@ const String$6 = /*#__PURE__*/ make$26((self, that) => self < that ? -1 : 1);
3029
3029
  * @category instances
3030
3030
  * @since 4.0.0
3031
3031
  */
3032
- const Number$4 = /*#__PURE__*/ make$26((self, that) => {
3032
+ const Number$5 = /*#__PURE__*/ make$26((self, that) => {
3033
3033
  if (globalThis.Number.isNaN(self) && globalThis.Number.isNaN(that)) return 0;
3034
3034
  if (globalThis.Number.isNaN(self)) return -1;
3035
3035
  if (globalThis.Number.isNaN(that)) return 1;
@@ -8012,7 +8012,7 @@ const exitPrimitive = /*#__PURE__*/ makePrimitive({
8012
8012
  }
8013
8013
  });
8014
8014
  /** @internal */
8015
- const timeoutOrElse$1 = /*#__PURE__*/ dual(2, (self, options) => flatMap$1(timeoutOption(self, options.duration), (option) => isNone(option) ? options.orElse() : succeed$5(option.value)));
8015
+ const timeoutOrElse$1 = /*#__PURE__*/ dual(2, (self, options) => flatMap$1(timeoutOption$1(self, options.duration), (option) => isNone(option) ? options.orElse() : succeed$5(option.value)));
8016
8016
  /** @internal */
8017
8017
  const timeoutErrorFromDuration = (duration) => new TimeoutError(`Operation timed out after '${format$1(duration)}'`);
8018
8018
  /** @internal */
@@ -8024,7 +8024,7 @@ const timeout$1 = /*#__PURE__*/ dual(2, (self, duration) => {
8024
8024
  });
8025
8025
  });
8026
8026
  /** @internal */
8027
- const timeoutOption = /*#__PURE__*/ dual(2, (self, duration) => raceFirst$1(asSome(self), as$1(sleep(duration), none())));
8027
+ const timeoutOption$1 = /*#__PURE__*/ dual(2, (self, duration) => raceFirst$1(asSome(self), as$1(sleep(duration), none())));
8028
8028
  /** @internal */
8029
8029
  const ScopeTypeId = "~effect/Scope";
8030
8030
  /** @internal */
@@ -8701,7 +8701,7 @@ const logLevelToOrder = (level) => {
8701
8701
  }
8702
8702
  };
8703
8703
  /** @internal */
8704
- const isLogLevelGreaterThan = /*#__PURE__*/ isGreaterThan$1(/* @__PURE__ */ mapInput(Number$4, logLevelToOrder));
8704
+ const isLogLevelGreaterThan = /*#__PURE__*/ isGreaterThan$1(/* @__PURE__ */ mapInput(Number$5, logLevelToOrder));
8705
8705
  /** @internal */
8706
8706
  const CurrentLoggers = /*#__PURE__*/ Reference("effect/Logger/CurrentLoggers", { defaultValue: () => /* @__PURE__ */ new Set([defaultLogger, tracerLogger]) });
8707
8707
  /** @internal */
@@ -10606,6 +10606,72 @@ const ProtoTimeZone = {
10606
10606
  ({ ...ProtoTimeZone });
10607
10607
  /** @internal */
10608
10608
  const toDateUtc$1 = (self) => new Date(self.epochMilliseconds);
10609
+ //#endregion
10610
+ //#region ../../node_modules/.pnpm/effect@4.1.0/node_modules/effect/dist/Number.js
10611
+ /**
10612
+ * Exposes the global number constructor.
10613
+ *
10614
+ * **When to use**
10615
+ *
10616
+ * Use to access native JavaScript numeric coercion from the Effect module
10617
+ * namespace.
10618
+ *
10619
+ * **Gotchas**
10620
+ *
10621
+ * This follows native `Number` coercion rules, including empty strings
10622
+ * becoming `0` and invalid numeric strings becoming `NaN`.
10623
+ *
10624
+ * @see {@link parse} for parsing strings into an `Option`
10625
+ *
10626
+ * **Example** (Coercing values to numbers)
10627
+ *
10628
+ * ```ts import.meta.vitest
10629
+ * import { Number as N } from "effect"
10630
+ *
10631
+ * N.Number("42") // => 42
10632
+ * N.Number("3.14") // => 3.14
10633
+ * ```
10634
+ *
10635
+ * @stability stable
10636
+ * @category constructors
10637
+ * @since 4.0.0
10638
+ */
10639
+ const Number$4 = globalThis.Number;
10640
+ /**
10641
+ * Parses a `number` from a `string` safely using the `Number()` function.
10642
+ * The following special string values are supported: "NaN", "Infinity", "-Infinity".
10643
+ *
10644
+ * **When to use**
10645
+ *
10646
+ * Use to parse numeric text without throwing on invalid input.
10647
+ *
10648
+ * **Example** (Parsing numbers from strings)
10649
+ *
10650
+ * ```ts import.meta.vitest
10651
+ * import { Number, Option } from "effect"
10652
+ *
10653
+ * Number.parse("42") // => Option.some(42)
10654
+ * Number.parse("3.14") // => Option.some(3.14)
10655
+ * Number.parse("NaN") // => Option.some(NaN)
10656
+ * Number.parse("Infinity") // => Option.some(Infinity)
10657
+ * Number.parse("-Infinity") // => Option.some(-Infinity)
10658
+ * Number.parse("not a number") // => Option.none()
10659
+ * ```
10660
+ *
10661
+ * @see {@link Number} for native constructor coercion
10662
+ *
10663
+ * @stability stable
10664
+ * @category constructors
10665
+ * @since 2.0.0
10666
+ */
10667
+ const parse$1 = (s) => {
10668
+ if (s === "NaN") return some$1(NaN);
10669
+ if (s === "Infinity") return some$1(Infinity);
10670
+ if (s === "-Infinity") return some$1(-Infinity);
10671
+ if (s.trim() === "") return none();
10672
+ const n = Number$4(s);
10673
+ return Number$4.isNaN(n) ? none() : some$1(n);
10674
+ };
10609
10675
  globalThis.String;
10610
10676
  /**
10611
10677
  * Removes whitespace from both ends of a string.
@@ -12658,6 +12724,38 @@ const orElseSucceed = orElseSucceed$1;
12658
12724
  */
12659
12725
  const timeout = timeout$1;
12660
12726
  /**
12727
+ * Runs an effect with a time limit and represents only the timeout case as
12728
+ * `Option.none`.
12729
+ *
12730
+ * **When to use**
12731
+ *
12732
+ * Use when a timeout of an `Effect` should be handled as `Option.none`.
12733
+ *
12734
+ * **Details**
12735
+ *
12736
+ * If the source effect succeeds before the timeout, the returned effect
12737
+ * succeeds with `Option.some(value)`. If the timeout wins, the source effect is
12738
+ * interrupted and the returned effect succeeds with `Option.none`. If the
12739
+ * source effect fails before the timeout, that failure is preserved.
12740
+ *
12741
+ * **Example** (Returning None on timeout)
12742
+ *
12743
+ * ```ts import.meta.vitest
12744
+ * import { Effect, Option } from "effect"
12745
+ *
12746
+ * const timedOutEffect = Effect.never.pipe(Effect.timeoutOption(0))
12747
+ * await Effect.runPromise(timedOutEffect) // => Option.none()
12748
+ * ```
12749
+ *
12750
+ * @see {@link timeout} for a version that raises a `TimeoutError`.
12751
+ * @see {@link timeoutOrElse} for a version that allows specifying both success and timeout handlers.
12752
+ *
12753
+ * @stability stable
12754
+ * @category delays & timeouts
12755
+ * @since 3.1.0
12756
+ */
12757
+ const timeoutOption = timeoutOption$1;
12758
+ /**
12661
12759
  * Applies a timeout to an effect, lazily evaluating `orElse` after interrupting
12662
12760
  * the source if the timeout is reached.
12663
12761
  *
@@ -19662,13 +19760,13 @@ function annotateKey(ast, annotations) {
19662
19760
  }) : new Context(false, false, void 0, annotations));
19663
19761
  }
19664
19762
  /** @internal */
19665
- const optionalKey = /*#__PURE__*/ memoizeIdempotent((ast) => {
19763
+ const optionalKey$1 = /*#__PURE__*/ memoizeIdempotent((ast) => {
19666
19764
  const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.constructorDefault, ast.context.annotations) : ast.context : new Context(true, false);
19667
19765
  return optionalKeyLastLink(replaceContext(ast, context));
19668
19766
  });
19669
- const optionalKeyLastLink = /*#__PURE__*/ applyToLastLink(optionalKey);
19767
+ const optionalKeyLastLink = /*#__PURE__*/ applyToLastLink(optionalKey$1);
19670
19768
  /** @internal */
19671
- const optional$2 = /*#__PURE__*/ memoize((ast) => optionalKey(new Union$1([ast, undefined_])));
19769
+ const optional$2 = /*#__PURE__*/ memoize((ast) => optionalKey$1(new Union$1([ast, undefined_])));
19672
19770
  /** @internal */
19673
19771
  function withConstructorDefault$1(ast, defaultValue) {
19674
19772
  return replaceContext(ast, ast.context ? new Context(ast.context.isOptional, ast.context.isMutable, defaultValue, ast.context.annotations) : new Context(false, false, defaultValue));
@@ -22257,6 +22355,30 @@ function isSchema(u) {
22257
22355
  return hasProperty(u, TypeId$11) && u[TypeId$11] === TypeId$11;
22258
22356
  }
22259
22357
  /**
22358
+ * Creates an exact optional key schema for struct fields. Unlike `optional`,
22359
+ * this creates exact optional properties (not `| undefined`) that can be
22360
+ * completely omitted from the object.
22361
+ *
22362
+ * **Example** (Creating a struct with optional key)
22363
+ *
22364
+ * ```ts import.meta.vitest
22365
+ * import { Schema } from "effect"
22366
+ *
22367
+ * const schema = Schema.Struct({
22368
+ * name: Schema.String,
22369
+ * age: Schema.optionalKey(Schema.Number)
22370
+ * })
22371
+ *
22372
+ * // Type: { readonly name: string; readonly age?: number }
22373
+ * type Person = typeof schema["Type"]
22374
+ * ```
22375
+ *
22376
+ * @stability stable
22377
+ * @category combinators
22378
+ * @since 4.0.0
22379
+ */
22380
+ const optionalKey = /*#__PURE__*/ lambda((schema) => make$10(optionalKey$1(schema.ast), { schema }));
22381
+ /**
22260
22382
  * Marks a struct field as optional, allowing the key to be absent or
22261
22383
  * `undefined`.
22262
22384
  *
@@ -23011,7 +23133,7 @@ function encodeNumberPayload(number) {
23011
23133
  * @since 4.0.0
23012
23134
  */
23013
23135
  const isBetween = /*#__PURE__*/ makeIsBetween({
23014
- order: Number$4,
23136
+ order: Number$5,
23015
23137
  annotate: (options) => {
23016
23138
  const exclusiveMinimum = options.exclusiveMinimum ? true : void 0;
23017
23139
  const exclusiveMaximum = options.exclusiveMaximum ? true : void 0;
@@ -29574,7 +29696,7 @@ const runMain = /* @__PURE__ */ makeRunMain(({ fiber, teardown }) => {
29574
29696
  process.on("SIGTERM", onSigint);
29575
29697
  });
29576
29698
  //#endregion
29577
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js
29699
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/util.js
29578
29700
  function getEnumValues(entries) {
29579
29701
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
29580
29702
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
@@ -29881,6 +30003,17 @@ function prefixIssues(path, issues) {
29881
30003
  function unwrapMessage(message) {
29882
30004
  return typeof message === "string" ? message : message?.message;
29883
30005
  }
30006
+ /** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
30007
+ function sizeCaps(defChecks) {
30008
+ const caps = [];
30009
+ for (const ch of defChecks ?? []) {
30010
+ const d = ch._zod.def;
30011
+ if (!/_(length|size)$|_equals$/.test(d.check)) break;
30012
+ const max = d.maximum ?? d.length ?? d.size;
30013
+ if (max >= 0) caps.push([max, ch]);
30014
+ }
30015
+ return caps;
30016
+ }
29884
30017
  function attachSchema(issues, start, inst) {
29885
30018
  var _a;
29886
30019
  for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
@@ -30097,7 +30230,7 @@ function constantCatch(value) {
30097
30230
  return fn;
30098
30231
  }
30099
30232
  //#endregion
30100
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/core.js
30233
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/core.js
30101
30234
  var _a$1;
30102
30235
  const _zodDesc = {
30103
30236
  value: void 0,
@@ -30203,7 +30336,7 @@ function config(newConfig) {
30203
30336
  return globalConfig;
30204
30337
  }
30205
30338
  //#endregion
30206
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/errors.js
30339
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/errors.js
30207
30340
  function _getMessage() {
30208
30341
  const internals = this._zod;
30209
30342
  internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
@@ -30319,7 +30452,7 @@ function formatError$1(error, mapper = (issue) => issue.message) {
30319
30452
  return fieldErrors;
30320
30453
  }
30321
30454
  //#endregion
30322
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/parse.js
30455
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/parse.js
30323
30456
  function finalizeParams(callee, params) {
30324
30457
  return {
30325
30458
  callee: params?.callee ?? callee,
@@ -30523,7 +30656,7 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
30523
30656
  return _safeParseAsync(_Err)(schema, value, _ctx);
30524
30657
  };
30525
30658
  //#endregion
30526
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js
30659
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/regexes.js
30527
30660
  /**
30528
30661
  * @deprecated CUID v1 is deprecated by its authors due to information leakage
30529
30662
  * (timestamps embedded in the id). Use {@link cuid2} instead.
@@ -30596,7 +30729,7 @@ const _null$2 = /^null$/i;
30596
30729
  const lowercase = /^[^A-Z]*$/;
30597
30730
  const uppercase = /^[^a-z]*$/;
30598
30731
  //#endregion
30599
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/checks.js
30732
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/checks.js
30600
30733
  const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
30601
30734
  var _a;
30602
30735
  inst._zod ?? (inst._zod = {});
@@ -30892,7 +31025,7 @@ const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (ins
30892
31025
  };
30893
31026
  });
30894
31027
  //#endregion
30895
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/doc.js
31028
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/doc.js
30896
31029
  var Doc = class {
30897
31030
  constructor(args = [], closed = {}) {
30898
31031
  this.content = [];
@@ -30926,14 +31059,14 @@ var Doc = class {
30926
31059
  }
30927
31060
  };
30928
31061
  //#endregion
30929
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/versions.js
31062
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/versions.js
30930
31063
  const version = {
30931
31064
  major: 4,
30932
31065
  minor: 6,
30933
- patch: 5
31066
+ patch: 6
30934
31067
  };
30935
31068
  //#endregion
30936
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/schemas.js
31069
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/schemas.js
30937
31070
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
30938
31071
  var _a;
30939
31072
  inst ?? (inst = {});
@@ -31446,6 +31579,26 @@ const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
31446
31579
  return payload;
31447
31580
  };
31448
31581
  });
31582
+ function capSize(inst, size) {
31583
+ const caps = sizeCaps(inst._zod.def.checks);
31584
+ if (!caps.length) return;
31585
+ const cap = Math.min(...caps.map((c) => c[0]));
31586
+ const parse = inst._zod.parse;
31587
+ inst._zod.parse = (payload, ctx) => {
31588
+ const n = size(payload.value);
31589
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
31590
+ for (const [max, ch] of sizeCaps(inst._zod.def.checks)) if (n > max && ch._zod.def.when(payload)) {
31591
+ const start = payload.issues.length;
31592
+ ch._zod.check(payload);
31593
+ payload.issues[start].continue = false;
31594
+ attachSchema(payload.issues, start, inst);
31595
+ return payload;
31596
+ }
31597
+ }
31598
+ return parse(payload, ctx);
31599
+ };
31600
+ }
31601
+ const arraySize = (input) => Array.isArray(input) ? input.length : -1;
31449
31602
  function handleArrayResult(result, final, index) {
31450
31603
  if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
31451
31604
  final.value[index] = result.value;
@@ -31483,6 +31636,7 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
31483
31636
  if (proms.length) return Promise.all(proms).then(() => payload);
31484
31637
  return payload;
31485
31638
  };
31639
+ capSize(inst, arraySize);
31486
31640
  });
31487
31641
  function handlePropertyResult(result, final, key, input, optin, optout) {
31488
31642
  const isPresent = key in input;
@@ -31591,7 +31745,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
31591
31745
  }
31592
31746
  return propValues;
31593
31747
  });
31594
- const isObject$3 = isObject;
31748
+ const isObject$2 = isObject;
31595
31749
  const catchall = def.catchall;
31596
31750
  let value;
31597
31751
  const memo = globalConfig.memoizer;
@@ -31599,7 +31753,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
31599
31753
  inst._zod.parse = (payload, ctx) => {
31600
31754
  value ?? (value = _normalized.value);
31601
31755
  const input = payload.value;
31602
- if (!isObject$3(input)) {
31756
+ if (!isObject$2(input)) {
31603
31757
  payload.issues.push({
31604
31758
  expected: "object",
31605
31759
  code: "invalid_type",
@@ -31729,7 +31883,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
31729
31883
  return doc.compile();
31730
31884
  };
31731
31885
  let fastpass;
31732
- const isObject$2 = isObject;
31886
+ const isObject$3 = isObject;
31733
31887
  const jit = !globalConfig.jitless;
31734
31888
  const fastEnabled = jit && allowsEval.value;
31735
31889
  const catchall = def.catchall;
@@ -31737,7 +31891,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
31737
31891
  inst._zod.parse = (payload, ctx) => {
31738
31892
  value ?? (value = _normalized.value);
31739
31893
  const input = payload.value;
31740
- if (!isObject$2(input)) {
31894
+ if (!isObject$3(input)) {
31741
31895
  payload.issues.push({
31742
31896
  expected: "object",
31743
31897
  code: "invalid_type",
@@ -32386,7 +32540,7 @@ function handleRefineResult(result, payload, input, inst) {
32386
32540
  }
32387
32541
  }
32388
32542
  //#endregion
32389
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/memoizer.js
32543
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/memoizer.js
32390
32544
  var $ZodCyclicError = class extends Error {
32391
32545
  constructor() {
32392
32546
  super(`Cannot parse a reference cycle that closes through a transform`);
@@ -32639,7 +32793,7 @@ function isBackEdge(ctx, value) {
32639
32793
  return backEdges !== void 0 && isRef(value) && backEdges.has(value);
32640
32794
  }
32641
32795
  //#endregion
32642
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/en.js
32796
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/locales/en.js
32643
32797
  const error = () => {
32644
32798
  const Sizable = {
32645
32799
  string: {
@@ -32747,7 +32901,7 @@ function en_default() {
32747
32901
  return { localeError: error() };
32748
32902
  }
32749
32903
  //#endregion
32750
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/registries.js
32904
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/registries.js
32751
32905
  var _a;
32752
32906
  var $ZodRegistry = class {
32753
32907
  constructor() {
@@ -32794,7 +32948,7 @@ function registry() {
32794
32948
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
32795
32949
  const globalRegistry = globalThis.__zod_globalRegistry;
32796
32950
  //#endregion
32797
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/api.js
32951
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/api.js
32798
32952
  function snapshotChecks(def) {
32799
32953
  if (def.checks) def.checks = [...def.checks];
32800
32954
  return def;
@@ -33321,7 +33475,7 @@ function _check(fn, params) {
33321
33475
  return ch;
33322
33476
  }
33323
33477
  //#endregion
33324
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/to-json-schema.js
33478
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/to-json-schema.js
33325
33479
  function assignProps(target, ...sources) {
33326
33480
  for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
33327
33481
  return target;
@@ -33765,7 +33919,7 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
33765
33919
  return finalize(ctx, schema);
33766
33920
  };
33767
33921
  //#endregion
33768
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/json-schema-processors.js
33922
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/core/json-schema-processors.js
33769
33923
  const narrowMin = (agg, key, value) => {
33770
33924
  if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
33771
33925
  };
@@ -34220,7 +34374,7 @@ const optionalProcessor = (schema, ctx, _json, params) => {
34220
34374
  seen.ref = def.innerType;
34221
34375
  };
34222
34376
  //#endregion
34223
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
34377
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
34224
34378
  function isZ4Schema(s) {
34225
34379
  return !!s._zod;
34226
34380
  }
@@ -34263,7 +34417,7 @@ function getLiteralValue(schema) {
34263
34417
  if (directValue !== void 0) return directValue;
34264
34418
  }
34265
34419
  //#endregion
34266
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/errors.js
34420
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/errors.js
34267
34421
  const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
34268
34422
  function _lazyMethod(proto, key, make) {
34269
34423
  Object.defineProperty(proto, key, {
@@ -34313,7 +34467,7 @@ const initializer = (inst, issues) => {
34313
34467
  };
34314
34468
  const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
34315
34469
  //#endregion
34316
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/parse.js
34470
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/parse.js
34317
34471
  const parse = /* @__PURE__ */ _parse(ZodRealError);
34318
34472
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
34319
34473
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -34327,7 +34481,7 @@ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
34327
34481
  const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
34328
34482
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
34329
34483
  //#endregion
34330
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/schemas.js
34484
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/schemas.js
34331
34485
  function _ensureDefaultLocale() {
34332
34486
  if (!globalConfig.localeError) config(en_default());
34333
34487
  }
@@ -35239,12 +35393,12 @@ function preprocess(fn, schema) {
35239
35393
  });
35240
35394
  }
35241
35395
  //#endregion
35242
- //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/iso.js
35396
+ //#region ../../node_modules/.pnpm/zod@4.6.6/node_modules/zod/v4/classic/iso.js
35243
35397
  function datetime(params) {
35244
35398
  return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
35245
35399
  }
35246
35400
  //#endregion
35247
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
35401
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
35248
35402
  const LATEST_PROTOCOL_VERSION = "2025-11-25";
35249
35403
  const SUPPORTED_PROTOCOL_VERSIONS = [
35250
35404
  LATEST_PROTOCOL_VERSION,
@@ -37139,7 +37293,7 @@ var UrlElicitationRequiredError = class extends McpError {
37139
37293
  }
37140
37294
  };
37141
37295
  //#endregion
37142
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
37296
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
37143
37297
  /**
37144
37298
  * Experimental task interfaces for MCP SDK.
37145
37299
  * WARNING: These APIs are experimental and may change without notice.
@@ -37156,7 +37310,7 @@ function isTerminal(status) {
37156
37310
  return status === "completed" || status === "failed" || status === "cancelled";
37157
37311
  }
37158
37312
  //#endregion
37159
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
37313
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
37160
37314
  function getMethodLiteral(schema) {
37161
37315
  const methodSchema = getObjectShape(schema)?.method;
37162
37316
  if (!methodSchema) throw new Error("Schema is missing a method literal");
@@ -37204,6 +37358,7 @@ var Protocol = class {
37204
37358
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
37205
37359
  const handleTaskResult = async () => {
37206
37360
  const taskId = request.params.taskId;
37361
+ if (!await this._taskStore.getTask(taskId, extra.sessionId)) throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
37207
37362
  if (this._taskMessageQueue) {
37208
37363
  let queuedMessage;
37209
37364
  while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
@@ -37230,12 +37385,12 @@ var Protocol = class {
37230
37385
  const task = await this._taskStore.getTask(taskId, extra.sessionId);
37231
37386
  if (!task) throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
37232
37387
  if (!isTerminal(task.status)) {
37233
- await this._waitForTaskUpdate(taskId, extra.signal);
37388
+ await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
37234
37389
  return await handleTaskResult();
37235
37390
  }
37236
37391
  if (isTerminal(task.status)) {
37237
37392
  const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
37238
- this._clearTaskQueue(taskId);
37393
+ this._clearTaskQueue(taskId, extra.sessionId);
37239
37394
  return {
37240
37395
  ...result,
37241
37396
  _meta: {
@@ -37266,7 +37421,7 @@ var Protocol = class {
37266
37421
  if (!task) throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request.params.taskId}`);
37267
37422
  if (isTerminal(task.status)) throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
37268
37423
  await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
37269
- this._clearTaskQueue(request.params.taskId);
37424
+ this._clearTaskQueue(request.params.taskId, extra.sessionId);
37270
37425
  const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
37271
37426
  if (!cancelledTask) throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
37272
37427
  return {
@@ -37371,6 +37526,17 @@ var Protocol = class {
37371
37526
  const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
37372
37527
  const capturedTransport = this._transport;
37373
37528
  const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
37529
+ const sessionId = capturedTransport?.sessionId;
37530
+ const store = this._taskStore;
37531
+ let relatedTaskFound = true;
37532
+ let relatedTaskLookup;
37533
+ if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
37534
+ relatedTaskFound = false;
37535
+ relatedTaskLookup = (async () => {
37536
+ if (!await store.getTask(relatedTaskId, sessionId)) throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
37537
+ relatedTaskFound = true;
37538
+ })();
37539
+ }
37374
37540
  if (handler === void 0) {
37375
37541
  const errorResponse = {
37376
37542
  jsonrpc: "2.0",
@@ -37380,7 +37546,14 @@ var Protocol = class {
37380
37546
  message: "Method not found"
37381
37547
  }
37382
37548
  };
37383
- if (relatedTaskId && this._taskMessageQueue) this._enqueueTaskMessage(relatedTaskId, {
37549
+ if (relatedTaskId && relatedTaskLookup) {
37550
+ const queuedError = {
37551
+ type: "error",
37552
+ message: errorResponse,
37553
+ timestamp: Date.now()
37554
+ };
37555
+ relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send an error response: ${error}`)));
37556
+ } else if (relatedTaskId && this._taskMessageQueue) this._enqueueTaskMessage(relatedTaskId, {
37384
37557
  type: "error",
37385
37558
  message: errorResponse,
37386
37559
  timestamp: Date.now()
@@ -37422,7 +37595,8 @@ var Protocol = class {
37422
37595
  closeSSEStream: extra?.closeSSEStream,
37423
37596
  closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
37424
37597
  };
37425
- Promise.resolve().then(() => {
37598
+ (relatedTaskLookup ?? Promise.resolve()).then(() => {
37599
+ if (relatedTaskLookup && abortController.signal.aborted) throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
37426
37600
  if (taskCreationParams) this.assertTaskHandlerCapability(request.method);
37427
37601
  }).then(() => handler(request, fullExtra)).then(async (result) => {
37428
37602
  if (abortController.signal.aborted) return;
@@ -37448,7 +37622,7 @@ var Protocol = class {
37448
37622
  ...error["data"] !== void 0 && { data: error["data"] }
37449
37623
  }
37450
37624
  };
37451
- if (relatedTaskId && this._taskMessageQueue) await this._enqueueTaskMessage(relatedTaskId, {
37625
+ if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) await this._enqueueTaskMessage(relatedTaskId, {
37452
37626
  type: "error",
37453
37627
  message: errorResponse,
37454
37628
  timestamp: Date.now()
@@ -37900,7 +38074,7 @@ var Protocol = class {
37900
38074
  async _enqueueTaskMessage(taskId, message, sessionId) {
37901
38075
  if (!this._taskStore || !this._taskMessageQueue) throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
37902
38076
  const maxQueueSize = this._options?.maxTaskQueueSize;
37903
- await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
38077
+ await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
37904
38078
  }
37905
38079
  /**
37906
38080
  * Clears the message queue for a task and rejects any pending request resolvers.
@@ -37925,12 +38099,13 @@ var Protocol = class {
37925
38099
  * Uses polling to check for updates at the task's configured poll interval.
37926
38100
  * @param taskId The task ID to wait for
37927
38101
  * @param signal Abort signal to cancel the wait
38102
+ * @param sessionId Session of the request that waits, passed to the task store
37928
38103
  * @returns Promise that resolves when an update occurs or rejects if aborted
37929
38104
  */
37930
- async _waitForTaskUpdate(taskId, signal) {
38105
+ async _waitForTaskUpdate(taskId, signal, sessionId) {
37931
38106
  let interval = this._options?.defaultTaskPollInterval ?? 1e3;
37932
38107
  try {
37933
- const task = await this._taskStore?.getTask(taskId);
38108
+ const task = await this._taskStore?.getTask(taskId, sessionId);
37934
38109
  if (task?.pollInterval) interval = task.pollInterval;
37935
38110
  } catch {}
37936
38111
  return new Promise((resolve, reject) => {
@@ -40734,7 +40909,7 @@ var require_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40734
40909
  };
40735
40910
  }));
40736
40911
  //#endregion
40737
- //#region ../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/lib/utils.js
40912
+ //#region ../../node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/lib/utils.js
40738
40913
  var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40739
40914
  /** @type {(value: string) => boolean} */
40740
40915
  const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
@@ -41028,6 +41203,38 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41028
41203
  return output.join("");
41029
41204
  }
41030
41205
  /**
41206
+ * Removes dot segments from the path of a relative reference (a path that does
41207
+ * not start with "/") without changing what it resolves to against any base.
41208
+ * Unlike `removeDotSegments`, leading ".." segments that cannot be collapsed
41209
+ * are kept, the result never becomes root-relative, and a result that would be
41210
+ * empty or start with an empty segment is prefixed with "." (an empty path
41211
+ * means "same document" and a leading "//" would introduce an authority).
41212
+ *
41213
+ * @param {string} path
41214
+ * @returns {string}
41215
+ */
41216
+ function removeDotSegmentsRelative(path) {
41217
+ if (path === "" || path[0] === "/") return removeDotSegments(path);
41218
+ const segments = path.split("/");
41219
+ const last = segments.length - 1;
41220
+ /** @type {string[]} */
41221
+ const output = [];
41222
+ let trailingDirectory = false;
41223
+ for (let i = 0; i <= last; i++) {
41224
+ const segment = segments[i];
41225
+ if (segment === "." || segment === "..") {
41226
+ if (segment === "..") {
41227
+ if (output.length !== 0 && output[output.length - 1] !== "..") output.pop();
41228
+ else output.push("..");
41229
+ }
41230
+ trailingDirectory = i === last;
41231
+ } else output.push(segment);
41232
+ }
41233
+ if (trailingDirectory && output[output.length - 1] !== "..") output.push("");
41234
+ if (output.length === 0 || output[0] === "" || output[0].includes(":")) output.unshift(".");
41235
+ return output.join("/");
41236
+ }
41237
+ /**
41031
41238
  * Re-escape RFC 3986 gen-delims that must not appear literally in the host.
41032
41239
  * After the URI regex parses, these characters cannot be literal in the host
41033
41240
  * field, so any that appear after decoding came from percent-encoding and
@@ -41331,6 +41538,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41331
41538
  encodeFragment,
41332
41539
  escapePreservingEscapes,
41333
41540
  removeDotSegments,
41541
+ removeDotSegmentsRelative,
41334
41542
  isIPv4,
41335
41543
  isUUID,
41336
41544
  normalizeIPv6,
@@ -41338,7 +41546,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41338
41546
  };
41339
41547
  }));
41340
41548
  //#endregion
41341
- //#region ../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/lib/schemes.js
41549
+ //#region ../../node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/lib/schemes.js
41342
41550
  var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41343
41551
  const { isUUID } = require_utils();
41344
41552
  const URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
@@ -41522,20 +41730,26 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41522
41730
  };
41523
41731
  }));
41524
41732
  //#endregion
41525
- //#region ../../node_modules/.pnpm/fast-uri@3.1.8/node_modules/fast-uri/index.js
41733
+ //#region ../../node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/index.js
41526
41734
  var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41527
- const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
41735
+ const { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
41528
41736
  const { SCHEMES, getSchemeHandler } = require_schemes();
41529
41737
  const VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
41530
41738
  const MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
41739
+ const MALFORMED_HOST_ERROR = "URI host is malformed.";
41740
+ const FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
41531
41741
  /**
41742
+ * RFC 3986 section 3.1 does not allow percent-encoding in a scheme, so the
41743
+ * scheme is validated as-is and never decoded. Decoding would let inert input
41744
+ * such as `%6Aavascript:` become a live `javascript:` scheme.
41745
+ *
41532
41746
  * @param {string} scheme
41533
41747
  * @returns {string}
41534
41748
  */
41535
- function decodeValidScheme(scheme) {
41536
- const decodedScheme = unescape(String(scheme));
41537
- if (!VALID_SCHEME.test(decodedScheme)) throw new TypeError(MALFORMED_SCHEME_ERROR);
41538
- return decodedScheme;
41749
+ function validateScheme(scheme) {
41750
+ const stringScheme = String(scheme);
41751
+ if (!VALID_SCHEME.test(stringScheme)) throw new TypeError(MALFORMED_SCHEME_ERROR);
41752
+ return stringScheme;
41539
41753
  }
41540
41754
  /**
41541
41755
  * @template {import('./types/index').URIComponent|string} T
@@ -41563,6 +41777,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41563
41777
  const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
41564
41778
  const resolvedHost = resolved.host;
41565
41779
  const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
41780
+ if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) throw new Error(MALFORMED_HOST_ERROR);
41566
41781
  canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
41567
41782
  const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
41568
41783
  if (resolved.error && !encodedASCIIHost) throw new Error(resolved.error);
@@ -41606,10 +41821,11 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41606
41821
  } else {
41607
41822
  if (relative.path[0] === "/") target.path = removeDotSegments(relative.path);
41608
41823
  else {
41609
- if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" + relative.path;
41824
+ const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
41825
+ if (baseHasAuthority && !base.path) target.path = "/" + relative.path;
41610
41826
  else if (!base.path) target.path = relative.path;
41611
41827
  else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
41612
- target.path = removeDotSegments(target.path);
41828
+ target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
41613
41829
  }
41614
41830
  target.query = relative.query;
41615
41831
  }
@@ -41657,17 +41873,18 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41657
41873
  };
41658
41874
  const options = Object.assign({}, opts);
41659
41875
  const uriTokens = [];
41660
- if (component.scheme) component.scheme = decodeValidScheme(component.scheme);
41876
+ if (component.scheme) component.scheme = validateScheme(component.scheme);
41661
41877
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
41662
41878
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
41663
41879
  const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
41664
- const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
41880
+ const schemelessReference = (component.scheme === void 0 || options.reference === "suffix") && !hasAuthority;
41881
+ const pathNoScheme = !options.skipEscape && schemelessReference;
41665
41882
  if (component.path !== void 0) {
41666
41883
  if (!options.skipEscape) component.path = serializePathEncoding(component.path, pathNoScheme);
41667
41884
  else component.path = normalizePercentEncoding(component.path);
41668
41885
  }
41669
41886
  if (options.reference !== "suffix" && component.scheme) {
41670
- component.scheme = decodeValidScheme(component.scheme);
41887
+ component.scheme = validateScheme(component.scheme);
41671
41888
  uriTokens.push(component.scheme, ":");
41672
41889
  }
41673
41890
  const authority = recomposeAuthority(component);
@@ -41678,8 +41895,8 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41678
41895
  }
41679
41896
  if (component.path !== void 0) {
41680
41897
  let s = component.path;
41681
- if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) s = removeDotSegments(s);
41682
- if (pathNoScheme) s = serializePathEncoding(s, true);
41898
+ if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) s = schemelessReference && s[0] !== "/" ? removeDotSegmentsRelative(s) : removeDotSegments(s);
41899
+ if (schemelessReference) s = serializePathEncoding(s, true);
41683
41900
  if (authority === void 0 && s[0] === "/" && s[1] === "/") s = "/%2F" + s.slice(2);
41684
41901
  uriTokens.push(s);
41685
41902
  }
@@ -41743,15 +41960,50 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41743
41960
  * @returns {boolean} whether host conversion failed
41744
41961
  */
41745
41962
  function canonicalizeHost(parsed, options, schemeHandler, isIP) {
41746
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) try {
41747
- parsed.host = new URL("http://" + parsed.host).hostname;
41748
- } catch (e) {
41749
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
41963
+ if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
41964
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
41750
41965
  return true;
41751
41966
  }
41967
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
41968
+ let url;
41969
+ try {
41970
+ url = new URL("http://" + parsed.host);
41971
+ } catch (e) {
41972
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
41973
+ return true;
41974
+ }
41975
+ if (!isHostOnlyURL(url)) {
41976
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
41977
+ return true;
41978
+ }
41979
+ parsed.host = url.hostname;
41980
+ }
41752
41981
  return false;
41753
41982
  }
41754
41983
  /**
41984
+ * Whether a domain host contains an ASCII character that RFC 3986 does not
41985
+ * allow in a reg-name (unreserved, sub-delims, or pct-encoded). Such a host is
41986
+ * rejected instead of being handed to the WHATWG URL parser, which would treat
41987
+ * "@" as a userinfo delimiter (silently dropping the data before it) and strip
41988
+ * TAB, LF, and CR. Non-ASCII characters remain allowed for IDNs.
41989
+ *
41990
+ * @param {import('./types/index').URIComponent} parsed
41991
+ * @param {import('./types/index').Options} options
41992
+ * @param {{ domainHost?: boolean }|undefined} schemeHandler
41993
+ * @param {boolean} isIP
41994
+ * @returns {boolean}
41995
+ */
41996
+ function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP) {
41997
+ return Boolean(parsed.host && isIP === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host));
41998
+ }
41999
+ /**
42000
+ * @param {URL} url
42001
+ * @returns {boolean}
42002
+ */
42003
+ function isHostOnlyURL(url) {
42004
+ return url.username === "" && url.password === "" && url.port === "" && url.pathname === "/" && url.search === "" && url.hash === "" && url.hostname !== "";
42005
+ }
42006
+ /**
41755
42007
  * @param {string} uri
41756
42008
  * @param {import('./types/index').Options} [opts]
41757
42009
  * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}
@@ -41808,8 +42060,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41808
42060
  parsed.query = matches[7];
41809
42061
  parsed.fragment = matches[8];
41810
42062
  if (parsed.scheme !== void 0) {
41811
- const decodedScheme = unescape(parsed.scheme);
41812
- if (VALID_SCHEME.test(decodedScheme)) parsed.scheme = decodedScheme.toLowerCase();
42063
+ if (VALID_SCHEME.test(parsed.scheme)) parsed.scheme = parsed.scheme.toLowerCase();
41813
42064
  else {
41814
42065
  parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
41815
42066
  malformedScheme = true;
@@ -41832,7 +42083,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41832
42083
  malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
41833
42084
  parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
41834
42085
  if (malformedIPLiteral) {
41835
- parsed.error = parsed.error || "URI host is malformed.";
42086
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
41836
42087
  malformedAuthorityOrPort = true;
41837
42088
  }
41838
42089
  } else isIP = true;
@@ -41847,7 +42098,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
41847
42098
  if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
41848
42099
  let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
41849
42100
  if (!isIP) host = normalizePercentEncoding(host.toLowerCase());
41850
- parsed.host = reescapeHostDelimiters(host, isIP);
42101
+ parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
41851
42102
  }
41852
42103
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
41853
42104
  if (parsed.path) parsed.path = normalizePathEncoding(parsed.path);
@@ -44595,7 +44846,7 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
44595
44846
  exports.default = formatsPlugin;
44596
44847
  }));
44597
44848
  //#endregion
44598
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
44849
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
44599
44850
  var import_ajv = /* @__PURE__ */ __toESM(require_ajv(), 1);
44600
44851
  var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
44601
44852
  function createDefaultAjvInstance() {
@@ -44671,7 +44922,7 @@ var AjvJsonSchemaValidator = class {
44671
44922
  }
44672
44923
  };
44673
44924
  //#endregion
44674
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
44925
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
44675
44926
  /**
44676
44927
  * Experimental server task features for MCP SDK.
44677
44928
  * WARNING: These APIs are experimental and may change without notice.
@@ -44889,7 +45140,7 @@ var ExperimentalServerTasks = class {
44889
45140
  }
44890
45141
  };
44891
45142
  //#endregion
44892
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
45143
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
44893
45144
  /**
44894
45145
  * Experimental task capability assertion helpers.
44895
45146
  * WARNING: These APIs are experimental and may change without notice.
@@ -44934,7 +45185,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
44934
45185
  }
44935
45186
  }
44936
45187
  //#endregion
44937
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
45188
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
44938
45189
  /**
44939
45190
  * An MCP server on top of a pluggable transport.
44940
45191
  *
@@ -45013,14 +45264,7 @@ var Server = class extends Protocol {
45013
45264
  setRequestHandler(requestSchema, handler) {
45014
45265
  const methodSchema = getObjectShape(requestSchema)?.method;
45015
45266
  if (!methodSchema) throw new Error("Schema is missing a method literal");
45016
- let methodValue;
45017
- if (isZ4Schema(methodSchema)) {
45018
- const v4Schema = methodSchema;
45019
- methodValue = (v4Schema._zod?.def)?.value ?? v4Schema.value;
45020
- } else {
45021
- const v3Schema = methodSchema;
45022
- methodValue = v3Schema._def?.value ?? v3Schema.value;
45023
- }
45267
+ const methodValue = getLiteralValue(methodSchema);
45024
45268
  if (typeof methodValue !== "string") throw new Error("Schema method literal must be a string");
45025
45269
  if (methodValue === "tools/call") {
45026
45270
  const wrappedHandler = async (request, extra) => {
@@ -45263,13 +45507,18 @@ var Server = class extends Protocol {
45263
45507
  return this.notification({ method: "notifications/prompts/list_changed" });
45264
45508
  }
45265
45509
  };
45266
- //#endregion
45267
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
45268
45510
  /**
45269
45511
  * Buffers a continuous stdio stream into discrete JSON-RPC messages.
45270
45512
  */
45271
45513
  var ReadBuffer = class {
45514
+ constructor(options) {
45515
+ this._maxBufferSize = options?.maxBufferSize ?? 10485760;
45516
+ }
45272
45517
  append(chunk) {
45518
+ if ((this._buffer?.length ?? 0) + chunk.length > this._maxBufferSize) {
45519
+ this.clear();
45520
+ throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
45521
+ }
45273
45522
  this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
45274
45523
  }
45275
45524
  readMessage() {
@@ -45291,25 +45540,30 @@ function serializeMessage(message) {
45291
45540
  return JSON.stringify(message) + "\n";
45292
45541
  }
45293
45542
  //#endregion
45294
- //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
45543
+ //#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_zod@4.6.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
45295
45544
  /**
45296
45545
  * Server transport for stdio: this communicates with an MCP client by reading from the current process' stdin and writing to stdout.
45297
45546
  *
45298
45547
  * This transport is only available in Node.js environments.
45299
45548
  */
45300
45549
  var StdioServerTransport = class {
45301
- constructor(_stdin = process$1.stdin, _stdout = process$1.stdout) {
45550
+ constructor(_stdin = process$1.stdin, _stdout = process$1.stdout, options) {
45302
45551
  this._stdin = _stdin;
45303
45552
  this._stdout = _stdout;
45304
- this._readBuffer = new ReadBuffer();
45305
45553
  this._started = false;
45306
45554
  this._ondata = (chunk) => {
45307
- this._readBuffer.append(chunk);
45308
- this.processReadBuffer();
45555
+ try {
45556
+ this._readBuffer.append(chunk);
45557
+ this.processReadBuffer();
45558
+ } catch (error) {
45559
+ this.onerror?.(error);
45560
+ this.close().catch(() => {});
45561
+ }
45309
45562
  };
45310
45563
  this._onerror = (error) => {
45311
45564
  this.onerror?.(error);
45312
45565
  };
45566
+ this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
45313
45567
  }
45314
45568
  /**
45315
45569
  * Starts listening for messages on stdin.
@@ -45373,9 +45627,9 @@ const printNextSteps = (alreadyRegistered) => {
45373
45627
  console.log("");
45374
45628
  console.log("Next steps:");
45375
45629
  console.log("");
45376
- console.log(" 1. Pass your Message Schema to Runtime.makeApplication (enables dispatch):");
45630
+ console.log(" 1. Enable Message dispatch in Program.make or Program.makeElement:");
45377
45631
  console.log("");
45378
- console.log(" devTools: { Message }");
45632
+ console.log(" devTools: { dispatch: true }");
45379
45633
  console.log("");
45380
45634
  console.log(" 2. Start your dev server, then restart your AI agent (Claude Code, Cursor, etc.).");
45381
45635
  console.log("");
@@ -45457,6 +45711,7 @@ const getDirectPropertyNames = (propertySignatures) => {
45457
45711
  }
45458
45712
  return names;
45459
45713
  };
45714
+ const callableTaggedStructs = /* @__PURE__ */ new WeakSet();
45460
45715
  const makeCallable = (tag, fields) => {
45461
45716
  const schema = TaggedStruct(tag, fields);
45462
45717
  const propertyNames = Object.hasOwn(fields, "_tag") ? void 0 : getDirectPropertyNames(schema.ast.propertySignatures);
@@ -45476,7 +45731,7 @@ const makeCallable = (tag, fields) => {
45476
45731
  }
45477
45732
  return output;
45478
45733
  } : make;
45479
- return new Proxy(function() {}, {
45734
+ const callable = new Proxy(function() {}, {
45480
45735
  apply(_target, _thisArg, argumentsList) {
45481
45736
  return construct(argumentsList[0]);
45482
45737
  },
@@ -45490,6 +45745,8 @@ const makeCallable = (tag, fields) => {
45490
45745
  return Reflect.getPrototypeOf(schema);
45491
45746
  }
45492
45747
  });
45748
+ callableTaggedStructs.add(callable);
45749
+ return callable;
45493
45750
  };
45494
45751
  const reservedUnionPropertyNames = /* @__PURE__ */ new Set(["members", "subset"]);
45495
45752
  const taggedUnionTypeOnlyPropertyNames = /* @__PURE__ */ new Set([
@@ -45568,18 +45825,18 @@ function defineTaggedUnion(casesByTag) {
45568
45825
  }
45569
45826
  //#endregion
45570
45827
  //#region ../foldkit/src/devTools/protocol.ts
45571
- /** A serialized Command produced during a Message dispatch (or `init`). `args` is `Some` when the Command declared an args record. `maybeSubmodelPath` is `None` until the result Message resolves, `Some([])` for a top-level result, and `Some(tags)` for a Submodel-routed result. */
45828
+ /** A serialized Command produced during a Message dispatch (or `init`). `args` is `Some` when the Command declared an args record. `maybeBlockPath` is `None` until the result Message resolves, `Some([])` for a top-level result, and `Some(tags)` for a Block-routed result. */
45572
45829
  const SerializedCommand = Struct({
45573
45830
  name: String$2,
45574
45831
  args: OptionFromNullOr(Record(String$2, Unknown)),
45575
- maybeSubmodelPath: OptionFromNullOr(ArraySchema(String$2))
45832
+ maybeBlockPath: OptionFromNullOr(ArraySchema(String$2))
45576
45833
  });
45577
45834
  /** A serialized Mount lifecycle event (start or end). `args` is `Some` when the Mount's definition declared an args record, and carries the runtime values used to construct the MountAction instance. */
45578
45835
  const SerializedMount = Struct({
45579
45836
  name: String$2,
45580
45837
  args: OptionFromNullOr(Record(String$2, Unknown))
45581
45838
  });
45582
- /** A serialized history entry as it appears on the wire. `submodelPath` lists `Got<Child>Message` wrapper tags from outer to inner when the entry came up through a Submodel chain; `maybeLeafTag` is `Some` with the innermost child Message tag when one exists. `mountStarts` lists Mounts that fired during the render after this Message; `mountEnds` lists Mounts whose elements were unmounted during that render. The Messages dispatched by mount Effects appear as their own entries elsewhere in history. */
45839
+ /** A serialized history entry as it appears on the wire. `blockPath` lists `Got<Child>Message` wrapper tags from outer to inner when the entry came up through a Block chain; `maybeLeafTag` is `Some` with the innermost child Message tag when one exists. `mountStarts` lists Mounts that fired during the render after this Message; `mountEnds` lists Mounts whose elements were unmounted during that render. The Messages dispatched by mount Effects appear as their own entries elsewhere in history. */
45583
45840
  const SerializedEntry = Struct({
45584
45841
  index: Number$1,
45585
45842
  tag: String$2,
@@ -45591,7 +45848,7 @@ const SerializedEntry = Struct({
45591
45848
  isModelChanged: Boolean$1,
45592
45849
  changedPaths: ArraySchema(String$2),
45593
45850
  affectedPaths: ArraySchema(String$2),
45594
- submodelPath: ArraySchema(String$2),
45851
+ blockPath: ArraySchema(String$2),
45595
45852
  maybeLeafTag: OptionFromNullOr(String$2)
45596
45853
  });
45597
45854
  /** Metadata about a single keyframe. The index identifies the point in history where the runtime can replay back to. */
@@ -45739,8 +45996,18 @@ const RELAY_REGISTRY_DIRECTORY_NAME = "foldkit-devtools-relays";
45739
45996
  /** Environment variable that sets the relay registry directory. */
45740
45997
  const RELAY_REGISTRY_DIRECTORY_VARIABLE = "FOLDKIT_DEVTOOLS_RELAY_DIRECTORY";
45741
45998
  /**
45999
+ * Linux PID and network namespaces of the process that published a relay
46000
+ * record, as `/proc/self/ns` links name them.
46001
+ */
46002
+ const RelayNamespaces = Struct({
46003
+ pid: String$2,
46004
+ network: String$2
46005
+ });
46006
+ /**
45742
46007
  * Record published while a Vite relay listens. `root` selects the project;
45743
- * `id` distinguishes a restarted relay from the one it replaced.
46008
+ * `id` distinguishes a restarted relay from the one it replaced. `pid` is
46009
+ * meaningful only inside the PID namespace in `namespaces`, which is absent
46010
+ * on platforms without namespaces and in records from older plugins.
45744
46011
  */
45745
46012
  const RelayRecord = Struct({
45746
46013
  version: Literal(1),
@@ -45748,7 +46015,8 @@ const RelayRecord = Struct({
45748
46015
  root: String$2,
45749
46016
  url: String$2,
45750
46017
  pid: Number$1,
45751
- startedAt: Number$1
46018
+ startedAt: Number$1,
46019
+ namespaces: optionalKey(RelayNamespaces)
45752
46020
  });
45753
46021
  //#endregion
45754
46022
  //#region ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/constants.js
@@ -49586,6 +49854,74 @@ const handleIncomingMessage = (raw, pendingResponsesRef) => {
49586
49854
  });
49587
49855
  };
49588
49856
  //#endregion
49857
+ //#region src/relayLiveness.ts
49858
+ const NAMESPACE_DIRECTORY = "/proc/self/ns";
49859
+ const PROBE_TIMEOUT$1 = seconds(1);
49860
+ const WEBSOCKET_PORT = 80;
49861
+ const SECURE_WEBSOCKET_PORT = 443;
49862
+ const IPV6_BRACKETS = /^\[|\]$/g;
49863
+ const readProcessNamespaces = gen(function* () {
49864
+ const fileSystem = yield* FileSystem;
49865
+ const pid = yield* fileSystem.readLink(`${NAMESPACE_DIRECTORY}/pid`);
49866
+ const network = yield* fileSystem.readLink(`${NAMESPACE_DIRECTORY}/net`);
49867
+ return some$1({
49868
+ pid,
49869
+ network
49870
+ });
49871
+ }).pipe(orElseSucceed(() => none()));
49872
+ const isProcessAlive = (pid) => {
49873
+ try {
49874
+ process.kill(pid, 0);
49875
+ return true;
49876
+ } catch (error) {
49877
+ return error instanceof Error && "code" in error && error.code === "EPERM";
49878
+ }
49879
+ };
49880
+ const relayAddress = (url) => flatMap$4(fromNullishOr(URL.parse(url)), (parsed) => {
49881
+ const host = parsed.hostname.replace(IPV6_BRACKETS, "");
49882
+ if (isNonEmpty$1(parsed.port)) return map$7(parse$1(parsed.port), (port) => ({
49883
+ host,
49884
+ port
49885
+ }));
49886
+ else if (parsed.protocol === "wss:") return some$1({
49887
+ host,
49888
+ port: SECURE_WEBSOCKET_PORT
49889
+ });
49890
+ else return some$1({
49891
+ host,
49892
+ port: WEBSOCKET_PORT
49893
+ });
49894
+ });
49895
+ const refusesConnections = ({ host, port }) => callback$1((resume) => {
49896
+ const socket = connect({
49897
+ host,
49898
+ port
49899
+ });
49900
+ const settle = (isRefused) => {
49901
+ socket.destroy();
49902
+ resume(succeed$1(isRefused));
49903
+ };
49904
+ socket.once("connect", () => settle(false));
49905
+ socket.once("error", (error) => settle("code" in error && error.code === "ECONNREFUSED"));
49906
+ return sync(() => socket.destroy());
49907
+ }).pipe(timeoutOption(PROBE_TIMEOUT$1), map$1(getOrElse(() => false)));
49908
+ const statusFromPort = (url) => match$5(relayAddress(url), {
49909
+ onNone: () => succeed$1("Running"),
49910
+ onSome: (address) => map$1(refusesConnections(address), (isRefused) => isRefused ? "Gone" : "Running")
49911
+ });
49912
+ const checkRelay = (record, maybeOwnNamespaces) => {
49913
+ const maybeRecordNamespaces = fromNullishOr(record.namespaces);
49914
+ const maybeBothNamespaces = all$2([maybeOwnNamespaces, maybeRecordNamespaces]);
49915
+ const hasNoNamespaces = isNone(maybeOwnNamespaces) && isNone(maybeRecordNamespaces);
49916
+ const isSamePidNamespace = exists(maybeBothNamespaces, ([own, recorded]) => own.pid === recorded.pid);
49917
+ const isOtherNetworkNamespace = exists(maybeBothNamespaces, ([own, recorded]) => own.network !== recorded.network);
49918
+ if (isSome(maybeRecordNamespaces) && isNone(maybeOwnNamespaces)) return succeed$1("Unreachable");
49919
+ else if (isOtherNetworkNamespace) return succeed$1("Unreachable");
49920
+ else if (isSamePidNamespace || hasNoNamespaces && process.platform !== "linux") return succeed$1(isProcessAlive(record.pid) ? "Running" : "Gone");
49921
+ else if (isNone(maybeRecordNamespaces) && isProcessAlive(record.pid)) return succeed$1("Running");
49922
+ else return statusFromPort(record.url);
49923
+ };
49924
+ //#endregion
49589
49925
  //#region src/relayRegistryTrust.ts
49590
49926
  const PERMISSIONS_BEYOND_OWNER = 63;
49591
49927
  const PARENT_WRITE_PERMISSIONS = 18;
@@ -49928,6 +50264,20 @@ const relayRegistryTrust = { inspect: (directory) => gen(function* () {
49928
50264
  const RUNTIME_DIRECTORY_VARIABLE = "XDG_RUNTIME_DIR";
49929
50265
  const RECORD_FILE_EXTENSION = ".json";
49930
50266
  const RETIRING_RECORD_SUFFIX = ".retiring";
50267
+ const AUTOMATIC_RELAY_HOST = "127.0.0.1";
50268
+ const AUTOMATIC_RELAY_PATH = "/__foldkit/devtools-mcp";
50269
+ const RELAY_TOKEN_PARAMETER = "token";
50270
+ const RELAY_TOKEN_PATTERN = /^[0-9a-f]{64}$/;
50271
+ const parseUrl = liftThrowable((url) => new URL(url));
50272
+ const hasValidPort = (url) => {
50273
+ const port = globalThis.Number(url.port);
50274
+ return url.port !== "" && globalThis.Number.isInteger(port) && port > 0 && port <= 65535;
50275
+ };
50276
+ const isPublishedRelayUrl = (value) => exists(parseUrl(value), (url) => {
50277
+ if (url.protocol !== "ws:" || url.username !== "" || url.password !== "" || url.hash !== "" || !hasValidPort(url)) return false;
50278
+ const parameters = fromIterable$5(url.searchParams);
50279
+ return url.hostname === AUTOMATIC_RELAY_HOST && url.pathname === AUTOMATIC_RELAY_PATH && length(parameters) === 1 && exists(head(parameters), ([name, token]) => name === RELAY_TOKEN_PARAMETER && RELAY_TOKEN_PATTERN.test(token));
50280
+ });
49931
50281
  const decodeRelayRecord = decodeUnknownOption(fromJsonString(RelayRecord));
49932
50282
  const relayRegistryDirectory = gen(function* () {
49933
50283
  const path = yield* Path$1;
@@ -49938,14 +50288,6 @@ const relayRegistryDirectory = gen(function* () {
49938
50288
  return path.join(getOrElse(maybeRuntimeDirectory, () => defaultParent), RELAY_REGISTRY_DIRECTORY_NAME);
49939
50289
  });
49940
50290
  }).pipe(orDie);
49941
- const isProcessAlive = (pid) => {
49942
- try {
49943
- process.kill(pid, 0);
49944
- return true;
49945
- } catch (error) {
49946
- return error instanceof Error && "code" in error && error.code === "EPERM";
49947
- }
49948
- };
49949
50291
  const readRecordFile = (filePath) => gen(function* () {
49950
50292
  const raw = yield* (yield* FileSystem).readFileString(filePath);
49951
50293
  return decodeRelayRecord(raw);
@@ -49958,15 +50300,19 @@ const retireStaleRecord = (filePath, record) => gen(function* () {
49958
50300
  if (!exists(maybeRetiringRecord, (retiringRecord) => retiringRecord.id === record.id)) yield* fileSystem.link(retiringPath, filePath).pipe(ignore);
49959
50301
  yield* fileSystem.remove(retiringPath, { force: true }).pipe(ignore);
49960
50302
  });
49961
- const readLiveRecordFile = (filePath) => gen(function* () {
50303
+ const readLiveRecordFile = (filePath, maybeOwnNamespaces) => gen(function* () {
49962
50304
  const maybeRecord = yield* readRecordFile(filePath);
49963
- if (isSome(maybeRecord) && !isProcessAlive(maybeRecord.value.pid)) {
49964
- yield* retireStaleRecord(filePath, maybeRecord.value);
50305
+ if (isNone(maybeRecord)) return maybeRecord;
50306
+ const record = maybeRecord.value;
50307
+ if (!isPublishedRelayUrl(record.url)) return none();
50308
+ const status = yield* checkRelay(record, maybeOwnNamespaces);
50309
+ if (status === "Gone") {
50310
+ yield* retireStaleRecord(filePath, record);
49965
50311
  return none();
49966
- }
49967
- return maybeRecord;
50312
+ } else if (status === "Unreachable") return none();
50313
+ else return maybeRecord;
49968
50314
  });
49969
- const newestFirst = mapInput(flip$1(Number$4), (record) => record.startedAt);
50315
+ const newestFirst = mapInput(flip$1(Number$5), (record) => record.startedAt);
49970
50316
  const isWithinRoot = (root, candidate, pathApi) => {
49971
50317
  const relativePath = pathApi.relative(root, candidate);
49972
50318
  return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${pathApi.sep}`) && !pathApi.isAbsolute(relativePath);
@@ -50007,7 +50353,8 @@ const discoverRelays = (projectRoot, registryReader) => gen(function* () {
50007
50353
  const directory = maybeDirectory.value;
50008
50354
  const fileNames = yield* fileSystem.readDirectory(directory).pipe(orElseSucceed(() => []));
50009
50355
  const recordFileNames = filter$2(fileNames, endsWith(RECORD_FILE_EXTENSION));
50010
- const records = getSomes(yield* forEach$1(recordFileNames, (recordFileName) => readLiveRecordFile(path.join(directory, recordFileName))));
50356
+ const maybeOwnNamespaces = yield* readProcessNamespaces;
50357
+ const records = getSomes(yield* forEach$1(recordFileNames, (recordFileName) => readLiveRecordFile(path.join(directory, recordFileName), maybeOwnNamespaces)));
50011
50358
  const realProjectRoot = yield* realRoot(projectRoot);
50012
50359
  const rootedRecords = yield* forEach$1(records, (record) => map$1(realRoot(record.root), (root) => ({
50013
50360
  record,
@@ -50025,10 +50372,6 @@ const discoverRelays = (projectRoot, registryReader) => gen(function* () {
50025
50372
  //#region src/relayLocation.ts
50026
50373
  const LEGACY_DEFAULT_PORT = 9988;
50027
50374
  const DEFAULT_HOST = "localhost";
50028
- const AUTOMATIC_RELAY_HOST = "127.0.0.1";
50029
- const AUTOMATIC_RELAY_PATH = "/__foldkit/devtools-mcp";
50030
- const RELAY_TOKEN_PARAMETER = "token";
50031
- const RELAY_TOKEN_PATTERN = /^[0-9a-f]{64}$/;
50032
50375
  const loadSettings = gen(function* () {
50033
50376
  const maybeConfiguredPort = yield* option(String$1("FOLDKIT_DEVTOOLS_MCP_PORT"));
50034
50377
  const maybeConfiguredHost = yield* option(String$1("FOLDKIT_DEVTOOLS_MCP_HOST"));
@@ -50046,16 +50389,6 @@ const fixedTarget = (url) => ({
50046
50389
  url,
50047
50390
  maybeProjectRoot: none()
50048
50391
  });
50049
- const parseUrl = liftThrowable((url) => new URL(url));
50050
- const hasValidPort = (url) => {
50051
- const port = globalThis.Number(url.port);
50052
- return url.port !== "" && globalThis.Number.isInteger(port) && port > 0 && port <= 65535;
50053
- };
50054
- const isPublishedRelayUrl = (value) => exists(parseUrl(value), (url) => {
50055
- if (url.protocol !== "ws:" || url.username !== "" || url.password !== "" || url.hash !== "" || !hasValidPort(url)) return false;
50056
- const parameters = fromIterable$5(url.searchParams);
50057
- return url.hostname === AUTOMATIC_RELAY_HOST && url.pathname === AUTOMATIC_RELAY_PATH && length(parameters) === 1 && exists(head(parameters), ([name, token]) => name === RELAY_TOKEN_PARAMETER && RELAY_TOKEN_PATTERN.test(token));
50058
- });
50059
50392
  const configuredRelayUrl = (settings) => {
50060
50393
  const { maybeConfiguredHost, maybeConfiguredPort } = settings;
50061
50394
  if (isSome(maybeConfiguredHost) || isSome(maybeConfiguredPort)) {
@@ -50066,14 +50399,11 @@ const configuredRelayUrl = (settings) => {
50066
50399
  };
50067
50400
  const resolveRelayTargets = (settings, registryReader) => match$5(configuredRelayUrl(settings), {
50068
50401
  onSome: (url) => succeed$1([fixedTarget(url)]),
50069
- onNone: () => map$1(discoverRelays(settings.projectRoot, registryReader), (records) => {
50070
- const trustedRecords = filter$2(records, (record) => isPublishedRelayUrl(record.url));
50071
- return map$4(trustedRecords, (record) => ({
50072
- key: record.id,
50073
- url: record.url,
50074
- maybeProjectRoot: some$1(record.root)
50075
- }));
50076
- })
50402
+ onNone: () => map$1(discoverRelays(settings.projectRoot, registryReader), map$4((record) => ({
50403
+ key: record.id,
50404
+ url: record.url,
50405
+ maybeProjectRoot: some$1(record.root)
50406
+ })))
50077
50407
  });
50078
50408
  //#endregion
50079
50409
  //#region src/tools.ts
@@ -50146,7 +50476,7 @@ const DispatchMessagesInput = Struct({
50146
50476
  });
50147
50477
  const GetMessageSchemaInput = Struct({
50148
50478
  runtime_id: RuntimeIdField,
50149
- variant_tag: optional$1(String$2.annotate({ description: "Optional dot-separated path of variant `_tag` values. When omitted, the tool returns a small variant index (tag names plus payload field names plus a tagged-union indicator) so agents can enumerate the top-level union cheaply. When provided, the tool walks the path through each variant's single tagged-union payload field, narrows the schema along the chain, and collapses any union deeper than the path to a `{ \"_summary\": \"union\", \"variants\": [...] }` placeholder. Extend the path to drill further. Examples: `\"ScrolledSidebar\"` (one top-level variant), `\"GotMobileMenuDialogMessage.GotAnimationMessage\"` (two levels of a Submodel chain)." }))
50479
+ variant_tag: optional$1(String$2.annotate({ description: "Optional dot-separated path of variant `_tag` values. When omitted, the tool returns a small variant index (tag names plus payload field names plus a tagged-union indicator) so agents can enumerate the top-level union cheaply. When provided, the tool walks the path through each variant's single tagged-union payload field, narrows the schema along the chain, and collapses any union deeper than the path to a `{ \"_summary\": \"union\", \"variants\": [...] }` placeholder. Extend the path to drill further. Examples: `\"ScrolledSidebar\"` (one top-level variant), `\"GotMobileMenuDialogMessage.GotAnimationMessage\"` (two levels of a Block chain)." }))
50150
50480
  });
50151
50481
  /**
50152
50482
  * Extract the inner JSON Schema from Effect's `JsonSchema.Document` wrapper.
@@ -50255,13 +50585,13 @@ const buildTools = (relayClient) => [
50255
50585
  },
50256
50586
  {
50257
50587
  name: "foldkit_get_message",
50258
- description: "Read a single Message history entry by absolute index. The response carries the SerializedEntry (tag, message body, commands, mountStarts, mountEnds, timestamp, `isModelChanged`, `changedPaths` for leaf-level mutations, `affectedPaths` adding their ancestor paths). Each entry in `commands` carries the Command name, `args` (`Some(record)` when the Command declared an args schema, `None` otherwise), and `maybeSubmodelPath` (`None` before the result resolves, `Some([])` for a resolved top-level Command, or `Some(tags)` for a resolved Submodel Command). `mountStarts` lists Mounts that fired during the render after this Message; `mountEnds` lists Mounts whose elements were unmounted during that render. Each Mount carries its `name` and `args` (`Some(record)` when the Mount declared an args schema, `None` otherwise). For Submodel-routed entries (tag matches `Got*Message`), the entry also carries `submodelPath` listing wrapper tags from outer to inner and `maybeLeafTag` naming the innermost child Message. Model snapshots are not included; call foldkit_get_model_at with `index - 1` (before) and `index` (after) to inspect Model state around the entry.",
50588
+ description: "Read a single Message history entry by absolute index. The response carries the SerializedEntry (tag, message body, commands, mountStarts, mountEnds, timestamp, `isModelChanged`, `changedPaths` for leaf-level mutations, `affectedPaths` adding their ancestor paths). Each entry in `commands` carries the Command name, `args` (`Some(record)` when the Command declared an args schema, `None` otherwise), and `maybeBlockPath` (`None` before the result resolves, `Some([])` for a resolved top-level Command, or `Some(tags)` for a resolved Block Command). `mountStarts` lists Mounts that fired during the render after this Message; `mountEnds` lists Mounts whose elements were unmounted during that render. Each Mount carries its `name` and `args` (`Some(record)` when the Mount declared an args schema, `None` otherwise). For Block-routed entries (tag matches `Got*Message`), the entry also carries `blockPath` listing wrapper tags from outer to inner and `maybeLeafTag` naming the innermost child Message. Model snapshots are not included; call foldkit_get_model_at with `index - 1` (before) and `index` (after) to inspect Model state around the entry.",
50259
50589
  inputSchema: toInputSchema(GetMessageInput),
50260
50590
  handle: runRuntimeTool(GetMessageInput, ({ index }) => Request.RequestGetMessage({ index }), relayClient)
50261
50591
  },
50262
50592
  {
50263
50593
  name: "foldkit_get_init",
50264
- description: "Read the runtime's initial Model, the Commands returned from the application's `init` function, and the Mounts that fired during the first render. The init entry is the synthetic row at index -1 in the DevTools panel; this tool exposes the same data without time-travelling the runtime. `maybeModel` is `None` until the runtime has finished its first render and recorded init, then stays `Some` for the rest of the runtime's life. `commands` lists init-time Commands in the order they were produced, each with its name, `args` (`Some(record)` when the Command declared an args schema, `None` otherwise), and `maybeSubmodelPath` (`None` before the result resolves, `Some([])` for a resolved top-level Command, or `Some(tags)` for a resolved Submodel Command); `mountStarts` lists Mounts whose elements appeared in the initial render, each with its name and `args` (`Some(record)` when the Mount declared an args schema, `None` otherwise).",
50594
+ description: "Read the runtime's initial Model, the Commands returned from the application's `init` function, and the Mounts that fired during the first render. The init entry is the synthetic row at index -1 in the DevTools panel; this tool exposes the same data without time-travelling the runtime. `maybeModel` is `None` until the runtime has finished its first render and recorded init, then stays `Some` for the rest of the runtime's life. `commands` lists init-time Commands in the order they were produced, each with its name, `args` (`Some(record)` when the Command declared an args schema, `None` otherwise), and `maybeBlockPath` (`None` before the result resolves, `Some([])` for a resolved top-level Command, or `Some(tags)` for a resolved Block Command); `mountStarts` lists Mounts whose elements appeared in the initial render, each with its name and `args` (`Some(record)` when the Mount declared an args schema, `None` otherwise).",
50265
50595
  inputSchema: toInputSchema(GetInitInput),
50266
50596
  handle: runRuntimeTool(GetInitInput, () => Request.RequestGetInit(), relayClient)
50267
50597
  },
@@ -50291,19 +50621,19 @@ const buildTools = (relayClient) => [
50291
50621
  },
50292
50622
  {
50293
50623
  name: "foldkit_get_message_schema",
50294
- description: "Describe the Message Schema for a Foldkit runtime so agents can construct valid payloads for `foldkit_dispatch_message`. Call with no arguments to receive a small variant index (every top-level variant's `_tag`, its payload field names, and which payload fields are themselves tagged-union shapes). Then call with `variant_tag: \"ChosenVariant\"` to drill in. The argument is a dot-separated path of variant `_tag` values: each segment names a variant, and the walker steps through the variant's single tagged-union payload field to reach the next. So `\"GotMobileMenuDialogMessage\"` narrows one level; `\"GotMobileMenuDialogMessage.GotAnimationMessage\"` narrows two levels of a Submodel chain. Discriminated unions deeper than the supplied path collapse to `{ \"_summary\": \"union\", \"variants\": [...] }` placeholders so the response stays compact even for deeply-nested apps; extend the path to drill further. `Schema.Option` fields render as `anyOf: [{_tag: \"Some\", value}, {_tag: \"None\"}]`. The full document follows the JSON Schema draft-2020-12 shape from `Schema.toJsonSchemaDocument`: `{ dialect, schema, definitions }`. Returns `maybeResult: None` when the runtime hasn't configured `DevToolsConfig.Message` (dispatch is also unavailable). Fields with no JSON representation, notably `Schema.instanceOf(File)` for user-uploaded files, render as `{type: \"null\"}`; those variants can't be dispatched via MCP because their values live in browser memory.",
50624
+ description: "Describe the Message Schema for a Foldkit runtime so agents can construct valid payloads for `foldkit_dispatch_message`. Call with no arguments to receive a small variant index (every top-level variant's `_tag`, its payload field names, and which payload fields are themselves tagged-union shapes). Then call with `variant_tag: \"ChosenVariant\"` to drill in. The argument is a dot-separated path of variant `_tag` values: each segment names a variant, and the walker steps through the variant's single tagged-union payload field to reach the next. So `\"GotMobileMenuDialogMessage\"` narrows one level; `\"GotMobileMenuDialogMessage.GotAnimationMessage\"` narrows two levels of a Block chain. Discriminated unions deeper than the supplied path collapse to `{ \"_summary\": \"union\", \"variants\": [...] }` placeholders so the response stays compact even for deeply-nested apps; extend the path to drill further. `Schema.Option` fields render as `anyOf: [{_tag: \"Some\", value}, {_tag: \"None\"}]`. The full document follows the JSON Schema draft-2020-12 shape from `Schema.toJsonSchemaDocument`: `{ dialect, schema, definitions }`. Returns `maybeResult: None` when the Program has not enabled `devTools.dispatch` (dispatch is also unavailable). Fields with no JSON representation, notably `Schema.instanceOf(File)` for user-uploaded files, render as `{type: \"null\"}`; those variants can't be dispatched via MCP because their values live in browser memory.",
50295
50625
  inputSchema: toInputSchema(GetMessageSchemaInput),
50296
50626
  handle: runRuntimeTool(GetMessageSchemaInput, ({ variant_tag }) => Request.RequestGetMessageSchema({ maybeVariantTag: fromNullishOr(variant_tag) }), relayClient)
50297
50627
  },
50298
50628
  {
50299
50629
  name: "foldkit_dispatch_message",
50300
- description: "Dispatch a Message into a Foldkit runtime, as if the application itself produced it. Requires the runtime to have configured DevToolsConfig.Message; without it, dispatch is rejected. Call `foldkit_get_message_schema` with no arguments to enumerate the variants, then with `variant_tag` to learn one variant's exact payload shape, before constructing the Message object. The runtime decodes the payload and returns a clean error if it doesn't match. To dispatch several Messages in order with one call, use foldkit_dispatch_messages.",
50630
+ description: "Dispatch a Message into a Foldkit runtime, as if the application itself produced it. Requires `devTools: { dispatch: true }` on the Program; without it, dispatch is rejected. Call `foldkit_get_message_schema` with no arguments to enumerate the variants, then with `variant_tag` to learn one variant's exact payload shape, before constructing the Message object. The runtime decodes the payload and returns a clean error if it doesn't match. Messages configured with excludeFromHistory are rejected before execution. A successful response identifies the confirmed recorded history entry. A child Message that becomes stale before queued execution is discarded and returns an error. To dispatch several Messages in order with one call, use foldkit_dispatch_messages.",
50301
50631
  inputSchema: toInputSchema(DispatchMessageInput),
50302
50632
  handle: runRuntimeTool(DispatchMessageInput, ({ message }) => Request.RequestDispatchMessage({ message }), relayClient)
50303
50633
  },
50304
50634
  {
50305
50635
  name: "foldkit_dispatch_messages",
50306
- description: `Dispatch an ordered batch of Messages into a Foldkit runtime in one call, first to last, as if the application produced them in quick succession. Prefer this over repeated foldkit_dispatch_message calls when staging state that takes several Messages: reproducing a bug, filling a form, or building a history fixture. Takes 1 to 100 Messages. Validation is all-or-nothing: the runtime decodes every payload against the Message Schema before dispatching any of them, and one invalid entry rejects the whole batch with an error naming its zero-based position, so there is never a partially applied prefix to clean up. On success the response carries acceptedAtIndices, the predicted history index for each Message in request order; the runtime may still record its own Messages between entries (for example a Command completing mid-burst), exactly as with rapid user input, and Messages excluded from history via excludeFromHistory are dispatched but never recorded, so entries after one land below their predicted index. Requires DevToolsConfig.Message, like foldkit_dispatch_message.`,
50636
+ description: `Dispatch an ordered batch of Messages into a Foldkit runtime in one call, first to last, as if the application produced them in quick succession. Prefer this over repeated foldkit_dispatch_message calls when staging state that takes several Messages: reproducing a bug, filling a form, or building a history fixture. Takes 1 to 100 Messages. Validation is all-or-nothing: the runtime decodes every payload against the Message Schema before dispatching any of them, and one invalid entry rejects the whole batch with an error naming its zero-based position, so there is never a partially applied prefix to clean up. Messages excluded from history are rejected before dispatch. On success, acceptedAtIndices contains the exact recorded history indices in request order. A Message whose captured child occurrence becomes stale before queued execution is omitted, while unrelated Messages recorded between batch entries keep their own indices. Requires devTools: { dispatch: true }, like foldkit_dispatch_message.`,
50307
50637
  inputSchema: toInputSchema(DispatchMessagesInput),
50308
50638
  handle: runRuntimeTool(DispatchMessagesInput, ({ messages }) => Request.RequestDispatchMessages({ messages }), relayClient)
50309
50639
  },