@firfi/huly-mcp 0.38.0 → 0.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -2
  2. package/dist/index.cjs +464 -253
  3. package/package.json +4 -5
package/dist/index.cjs CHANGED
@@ -73778,7 +73778,7 @@ var require_index_cjs4 = __commonJS({
73778
73778
  let canOpen = true;
73779
73779
  let canClose = true;
73780
73780
  pos = t.index + 1;
73781
- const isSingle2 = t[0] === "'";
73781
+ const isSingle3 = t[0] === "'";
73782
73782
  let lastChar = 32;
73783
73783
  if (t.index - 1 >= 0) {
73784
73784
  lastChar = text2.charCodeAt(t.index - 1);
@@ -73829,7 +73829,7 @@ var require_index_cjs4 = __commonJS({
73829
73829
  canClose = isNextPunctChar;
73830
73830
  }
73831
73831
  if (!canOpen && !canClose) {
73832
- if (isSingle2) {
73832
+ if (isSingle3) {
73833
73833
  token.content = replaceAt(token.content, t.index, APOSTROPHE);
73834
73834
  }
73835
73835
  continue;
@@ -73840,11 +73840,11 @@ var require_index_cjs4 = __commonJS({
73840
73840
  if (stack[j].level < thisLevel) {
73841
73841
  break;
73842
73842
  }
73843
- if (item.single === isSingle2 && stack[j].level === thisLevel) {
73843
+ if (item.single === isSingle3 && stack[j].level === thisLevel) {
73844
73844
  item = stack[j];
73845
73845
  let openQuote;
73846
73846
  let closeQuote;
73847
- if (isSingle2) {
73847
+ if (isSingle3) {
73848
73848
  openQuote = state.md.options.quotes[2];
73849
73849
  closeQuote = state.md.options.quotes[3];
73850
73850
  } else {
@@ -73868,10 +73868,10 @@ var require_index_cjs4 = __commonJS({
73868
73868
  stack.push({
73869
73869
  token: i,
73870
73870
  pos: t.index,
73871
- single: isSingle2,
73871
+ single: isSingle3,
73872
73872
  level: thisLevel
73873
73873
  });
73874
- } else if (canClose && isSingle2) {
73874
+ } else if (canClose && isSingle3) {
73875
73875
  token.content = replaceAt(token.content, t.index, APOSTROPHE);
73876
73876
  }
73877
73877
  }
@@ -78315,9 +78315,9 @@ var require_utils9 = __commonJS({
78315
78315
  });
78316
78316
  module2.exports = __toCommonJS2(utils_exports);
78317
78317
  var import_account_client2 = require_lib6();
78318
- var import_config9 = require_config();
78318
+ var import_config10 = require_config();
78319
78319
  async function getWorkspaceToken2(url4, options, config3) {
78320
- config3 ??= await (0, import_config9.loadServerConfig)(url4);
78320
+ config3 ??= await (0, import_config10.loadServerConfig)(url4);
78321
78321
  let token;
78322
78322
  if ("token" in options) {
78323
78323
  token = options.token;
@@ -83709,11 +83709,11 @@ var require_client6 = __commonJS({
83709
83709
  var import_client82 = __toESM2(require_lib7());
83710
83710
  var import_core99 = require_lib5();
83711
83711
  var import_platform4 = require_lib();
83712
- var import_config9 = require_config();
83712
+ var import_config10 = require_config();
83713
83713
  var import_markup21 = require_markup();
83714
83714
  var import_utils14 = require_utils9();
83715
83715
  async function connect(url4, options) {
83716
- const config3 = await (0, import_config9.loadServerConfig)(url4);
83716
+ const config3 = await (0, import_config10.loadServerConfig)(url4);
83717
83717
  const { endpoint, token } = await (0, import_utils14.getWorkspaceToken)(url4, options, config3);
83718
83718
  const accountClient = (0, import_account_client2.getClient)(config3.ACCOUNTS_URL, token);
83719
83719
  const socialIds = await accountClient.getSocialIds(true);
@@ -84644,7 +84644,7 @@ var require_client7 = __commonJS({
84644
84644
  module2.exports = __toCommonJS2(client_exports);
84645
84645
  var import_core99 = __toESM2(require_lib5());
84646
84646
  var import_stream2 = require("stream");
84647
- var import_config9 = require_config();
84647
+ var import_config10 = require_config();
84648
84648
  var import_error = require_error3();
84649
84649
  var import_utils14 = require_utils9();
84650
84650
  var StorageClientImpl = class {
@@ -84796,7 +84796,7 @@ var require_client7 = __commonJS({
84796
84796
  }
84797
84797
  __name(createStorageClient2, "createStorageClient");
84798
84798
  async function connectStorage(url4, options, config3) {
84799
- config3 ??= await (0, import_config9.loadServerConfig)(url4);
84799
+ config3 ??= await (0, import_config10.loadServerConfig)(url4);
84800
84800
  const token = await (0, import_utils14.getWorkspaceToken)(url4, options, config3);
84801
84801
  const filesUrl = (config3.FILES_URL.startsWith("/") ? (0, import_core99.concatLink)(url4, config3.FILES_URL) : config3.FILES_URL).replace(
84802
84802
  ":workspace",
@@ -117051,7 +117051,7 @@ var require_validate = __commonJS({
117051
117051
  const { schema, gen: gen6, opts } = it;
117052
117052
  if (opts.$comment && schema.$comment)
117053
117053
  commentKeyword(it);
117054
- updateContext3(it);
117054
+ updateContext5(it);
117055
117055
  checkAsyncSchema(it);
117056
117056
  const errsCount = gen6.const("_errs", names_1.default.errors);
117057
117057
  typeAndKeywords(it, errsCount);
@@ -117080,7 +117080,7 @@ var require_validate = __commonJS({
117080
117080
  (0, util_1.checkStrictMode)(it, "default is ignored in the schema root");
117081
117081
  }
117082
117082
  }
117083
- function updateContext3(it) {
117083
+ function updateContext5(it) {
117084
117084
  const schId = it.schema[it.opts.schemaId];
117085
117085
  if (schId)
117086
117086
  it.baseId = (0, resolve_1.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
@@ -128967,7 +128967,7 @@ __export(Effect_exports, {
128967
128967
  patchRuntimeFlags: () => patchRuntimeFlags,
128968
128968
  promise: () => promise2,
128969
128969
  provide: () => provide2,
128970
- provideService: () => provideService3,
128970
+ provideService: () => provideService4,
128971
128971
  provideServiceEffect: () => provideServiceEffect2,
128972
128972
  race: () => race2,
128973
128973
  raceAll: () => raceAll2,
@@ -129056,7 +129056,7 @@ __export(Effect_exports, {
129056
129056
  unsafeMakeLatch: () => unsafeMakeLatch2,
129057
129057
  unsafeMakeSemaphore: () => unsafeMakeSemaphore2,
129058
129058
  unsandbox: () => unsandbox2,
129059
- updateFiberRefs: () => updateFiberRefs2,
129059
+ updateFiberRefs: () => updateFiberRefs3,
129060
129060
  updateService: () => updateService2,
129061
129061
  useSpan: () => useSpan2,
129062
129062
  using: () => using2,
@@ -130438,6 +130438,7 @@ var updateManyAs = /* @__PURE__ */ dual(2, (self, {
130438
130438
  });
130439
130439
 
130440
130440
  // node_modules/.pnpm/effect@3.21.3/node_modules/effect/dist/esm/FiberRefs.js
130441
+ var delete_2 = delete_;
130441
130442
  var get9 = get8;
130442
130443
  var getOrDefault2 = getOrDefault;
130443
130444
  var joinAs2 = joinAs;
@@ -137436,6 +137437,7 @@ var asyncFiberException = (fiber) => {
137436
137437
  Error.stackTraceLimit = limit;
137437
137438
  return error2;
137438
137439
  };
137440
+ var isAsyncFiberException = (u) => isTagged(u, "AsyncFiberException") && "fiber" in u;
137439
137441
  var FiberFailureId = /* @__PURE__ */ Symbol.for("effect/Runtime/FiberFailure");
137440
137442
  var FiberFailureCauseId = /* @__PURE__ */ Symbol.for("effect/Runtime/FiberFailure/Cause");
137441
137443
  var FiberFailureImpl = class extends Error {
@@ -137473,6 +137475,7 @@ var fiberFailure = (cause3) => {
137473
137475
  Error.stackTraceLimit = limit;
137474
137476
  return error2;
137475
137477
  };
137478
+ var isFiberFailure = (u) => hasProperty(u, FiberFailureId);
137476
137479
  var fastPath = (effect2) => {
137477
137480
  const op = effect2;
137478
137481
  switch (op._op) {
@@ -137562,6 +137565,30 @@ var defaultRuntime = /* @__PURE__ */ make39({
137562
137565
  runtimeFlags: defaultRuntimeFlags,
137563
137566
  fiberRefs: /* @__PURE__ */ empty21()
137564
137567
  });
137568
+ var updateRuntimeFlags2 = /* @__PURE__ */ dual(2, (self, f) => make39({
137569
+ context: self.context,
137570
+ runtimeFlags: f(self.runtimeFlags),
137571
+ fiberRefs: self.fiberRefs
137572
+ }));
137573
+ var disableRuntimeFlag = /* @__PURE__ */ dual(2, (self, flag) => updateRuntimeFlags2(self, disable2(flag)));
137574
+ var enableRuntimeFlag = /* @__PURE__ */ dual(2, (self, flag) => updateRuntimeFlags2(self, enable2(flag)));
137575
+ var updateContext2 = /* @__PURE__ */ dual(2, (self, f) => make39({
137576
+ context: f(self.context),
137577
+ runtimeFlags: self.runtimeFlags,
137578
+ fiberRefs: self.fiberRefs
137579
+ }));
137580
+ var provideService2 = /* @__PURE__ */ dual(3, (self, tag2, service3) => updateContext2(self, add4(tag2, service3)));
137581
+ var updateFiberRefs2 = /* @__PURE__ */ dual(2, (self, f) => make39({
137582
+ context: self.context,
137583
+ runtimeFlags: self.runtimeFlags,
137584
+ fiberRefs: f(self.fiberRefs)
137585
+ }));
137586
+ var setFiberRef = /* @__PURE__ */ dual(3, (self, fiberRef, value3) => updateFiberRefs2(self, updateAs2({
137587
+ fiberId: none4,
137588
+ fiberRef,
137589
+ value: value3
137590
+ })));
137591
+ var deleteFiberRef = /* @__PURE__ */ dual(2, (self, fiberRef) => updateFiberRefs2(self, delete_2(fiberRef)));
137565
137592
  var unsafeRunEffect = /* @__PURE__ */ unsafeRunCallback(defaultRuntime);
137566
137593
  var unsafeForkEffect = /* @__PURE__ */ unsafeFork3(defaultRuntime);
137567
137594
  var unsafeRunPromiseEffect = /* @__PURE__ */ unsafeRunPromise(defaultRuntime);
@@ -139298,7 +139325,7 @@ var modifyDelayEffect = /* @__PURE__ */ dual(2, (self, f) => makeWithState(self.
139298
139325
  var onDecision = /* @__PURE__ */ dual(2, (self, f) => makeWithState(self.initial, (now2, input, state) => flatMap9(self.step(now2, input, state), ([state2, out, decision]) => as3(f(out, decision), [state2, out, decision]))));
139299
139326
  var passthrough2 = (self) => makeWithState(self.initial, (now2, input, state) => pipe(self.step(now2, input, state), map10(([state2, _, decision]) => [state2, input, decision])));
139300
139327
  var provideContext3 = /* @__PURE__ */ dual(2, (self, context6) => makeWithState(self.initial, (now2, input, state) => provideContext(self.step(now2, input, state), context6)));
139301
- var provideService2 = /* @__PURE__ */ dual(3, (self, tag2, service3) => makeWithState(self.initial, (now2, input, state) => contextWithEffect((env) => provideContext(
139328
+ var provideService3 = /* @__PURE__ */ dual(3, (self, tag2, service3) => makeWithState(self.initial, (now2, input, state) => contextWithEffect((env) => provideContext(
139302
139329
  // @ts-expect-error
139303
139330
  self.step(now2, input, state),
139304
139331
  add4(env, tag2, service3)
@@ -140472,7 +140499,7 @@ var contextWith2 = contextWith;
140472
140499
  var contextWithEffect2 = contextWithEffect;
140473
140500
  var mapInputContext3 = mapInputContext;
140474
140501
  var provide2 = effect_provide;
140475
- var provideService3 = provideService;
140502
+ var provideService4 = provideService;
140476
140503
  var provideServiceEffect2 = provideServiceEffect;
140477
140504
  var serviceFunction2 = serviceFunction;
140478
140505
  var serviceFunctionEffect2 = serviceFunctionEffect;
@@ -140536,7 +140563,7 @@ var locallyScoped = fiberRefLocallyScoped;
140536
140563
  var locallyScopedWith = fiberRefLocallyScopedWith;
140537
140564
  var patchFiberRefs2 = patchFiberRefs;
140538
140565
  var setFiberRefs2 = setFiberRefs;
140539
- var updateFiberRefs2 = updateFiberRefs;
140566
+ var updateFiberRefs3 = updateFiberRefs;
140540
140567
  var isFailure5 = isFailure3;
140541
140568
  var isSuccess3 = isSuccess;
140542
140569
  var match13 = match9;
@@ -141157,7 +141184,7 @@ __export(Schedule_exports, {
141157
141184
  once: () => once4,
141158
141185
  passthrough: () => passthrough4,
141159
141186
  provideContext: () => provideContext4,
141160
- provideService: () => provideService4,
141187
+ provideService: () => provideService5,
141161
141188
  recurUntil: () => recurUntil2,
141162
141189
  recurUntilEffect: () => recurUntilEffect2,
141163
141190
  recurUntilOption: () => recurUntilOption2,
@@ -141259,7 +141286,7 @@ var modifyDelayEffect2 = modifyDelayEffect;
141259
141286
  var onDecision2 = onDecision;
141260
141287
  var once4 = once2;
141261
141288
  var provideContext4 = provideContext3;
141262
- var provideService4 = provideService2;
141289
+ var provideService5 = provideService3;
141263
141290
  var recurUntil2 = recurUntil;
141264
141291
  var recurUntilEffect2 = recurUntilEffect;
141265
141292
  var recurUntilOption2 = recurUntilOption;
@@ -141298,6 +141325,55 @@ var zipRight6 = zipRight4;
141298
141325
  var zipWith11 = zipWith8;
141299
141326
  var CurrentIterationMetadata2 = CurrentIterationMetadata;
141300
141327
 
141328
+ // node_modules/.pnpm/effect@3.21.3/node_modules/effect/dist/esm/Runtime.js
141329
+ var Runtime_exports = {};
141330
+ __export(Runtime_exports, {
141331
+ FiberFailureCauseId: () => FiberFailureCauseId2,
141332
+ FiberFailureId: () => FiberFailureId2,
141333
+ defaultRuntime: () => defaultRuntime2,
141334
+ defaultRuntimeFlags: () => defaultRuntimeFlags2,
141335
+ deleteFiberRef: () => deleteFiberRef2,
141336
+ disableRuntimeFlag: () => disableRuntimeFlag2,
141337
+ enableRuntimeFlag: () => enableRuntimeFlag2,
141338
+ isAsyncFiberException: () => isAsyncFiberException2,
141339
+ isFiberFailure: () => isFiberFailure2,
141340
+ make: () => make42,
141341
+ makeFiberFailure: () => makeFiberFailure,
141342
+ provideService: () => provideService6,
141343
+ runCallback: () => runCallback2,
141344
+ runFork: () => runFork3,
141345
+ runPromise: () => runPromise2,
141346
+ runPromiseExit: () => runPromiseExit2,
141347
+ runSync: () => runSync2,
141348
+ runSyncExit: () => runSyncExit2,
141349
+ setFiberRef: () => setFiberRef2,
141350
+ updateContext: () => updateContext3,
141351
+ updateFiberRefs: () => updateFiberRefs4,
141352
+ updateRuntimeFlags: () => updateRuntimeFlags3
141353
+ });
141354
+ var runFork3 = unsafeFork3;
141355
+ var runSyncExit2 = unsafeRunSyncExit;
141356
+ var runSync2 = unsafeRunSync;
141357
+ var runCallback2 = unsafeRunCallback;
141358
+ var runPromise2 = unsafeRunPromise;
141359
+ var runPromiseExit2 = unsafeRunPromiseExit;
141360
+ var defaultRuntime2 = defaultRuntime;
141361
+ var defaultRuntimeFlags2 = defaultRuntimeFlags;
141362
+ var make42 = make39;
141363
+ var FiberFailureId2 = /* @__PURE__ */ Symbol.for("effect/Runtime/FiberFailure");
141364
+ var FiberFailureCauseId2 = FiberFailureCauseId;
141365
+ var isAsyncFiberException2 = isAsyncFiberException;
141366
+ var isFiberFailure2 = isFiberFailure;
141367
+ var makeFiberFailure = fiberFailure;
141368
+ var updateRuntimeFlags3 = updateRuntimeFlags2;
141369
+ var enableRuntimeFlag2 = enableRuntimeFlag;
141370
+ var disableRuntimeFlag2 = disableRuntimeFlag;
141371
+ var updateContext3 = updateContext2;
141372
+ var provideService6 = provideService2;
141373
+ var updateFiberRefs4 = updateFiberRefs2;
141374
+ var setFiberRef2 = setFiberRef;
141375
+ var deleteFiberRef2 = deleteFiberRef;
141376
+
141301
141377
  // node_modules/.pnpm/effect@3.21.3/node_modules/effect/dist/esm/Schema.js
141302
141378
  var Schema_exports = {};
141303
141379
  __export(Schema_exports, {
@@ -141613,7 +141689,7 @@ __export(Schema_exports, {
141613
141689
  lessThanOrEqualToDate: () => lessThanOrEqualToDate,
141614
141690
  lessThanOrEqualToDuration: () => lessThanOrEqualToDuration,
141615
141691
  lowercased: () => lowercased,
141616
- make: () => make47,
141692
+ make: () => make48,
141617
141693
  makePropertySignature: () => makePropertySignature,
141618
141694
  maxItems: () => maxItems,
141619
141695
  maxLength: () => maxLength,
@@ -141715,7 +141791,7 @@ var BigDecimalProto = {
141715
141791
  }
141716
141792
  };
141717
141793
  var isBigDecimal = (u) => hasProperty(u, TypeId20);
141718
- var make42 = (value3, scale2) => {
141794
+ var make43 = (value3, scale2) => {
141719
141795
  const o = Object.create(BigDecimalProto);
141720
141796
  o.value = value3;
141721
141797
  o.scale = scale2;
@@ -141725,7 +141801,7 @@ var unsafeMakeNormalized = (value3, scale2) => {
141725
141801
  if (value3 !== bigint04 && value3 % bigint10 === bigint04) {
141726
141802
  throw new RangeError("Value must be normalized");
141727
141803
  }
141728
- const o = make42(value3, scale2);
141804
+ const o = make43(value3, scale2);
141729
141805
  o.normalized = o;
141730
141806
  return o;
141731
141807
  };
@@ -141758,10 +141834,10 @@ var normalize = (self) => {
141758
141834
  };
141759
141835
  var scale = /* @__PURE__ */ dual(2, (self, scale2) => {
141760
141836
  if (scale2 > self.scale) {
141761
- return make42(self.value * bigint10 ** BigInt(scale2 - self.scale), scale2);
141837
+ return make43(self.value * bigint10 ** BigInt(scale2 - self.scale), scale2);
141762
141838
  }
141763
141839
  if (scale2 < self.scale) {
141764
- return make42(self.value / bigint10 ** BigInt(self.scale - scale2), scale2);
141840
+ return make43(self.value / bigint10 ** BigInt(self.scale - scale2), scale2);
141765
141841
  }
141766
141842
  return self;
141767
141843
  });
@@ -141785,7 +141861,7 @@ var greaterThanOrEqualTo3 = /* @__PURE__ */ greaterThanOrEqualTo(Order4);
141785
141861
  var between3 = /* @__PURE__ */ between(Order4);
141786
141862
  var clamp5 = /* @__PURE__ */ clamp(Order4);
141787
141863
  var sign = (n) => n.value === bigint04 ? 0 : n.value < bigint04 ? -1 : 1;
141788
- var abs = (n) => n.value < bigint04 ? make42(-n.value, n.scale) : n;
141864
+ var abs = (n) => n.value < bigint04 ? make43(-n.value, n.scale) : n;
141789
141865
  var Equivalence4 = /* @__PURE__ */ make((self, that) => {
141790
141866
  if (self.scale > that.scale) {
141791
141867
  return scale(that, self.scale).value === self.value;
@@ -141806,7 +141882,7 @@ var safeFromNumber = (n) => {
141806
141882
  return fromString(string7);
141807
141883
  }
141808
141884
  const [lead, trail = ""] = string7.split(".");
141809
- return some3(make42(BigInt(`${lead}${trail}`), trail.length));
141885
+ return some3(make43(BigInt(`${lead}${trail}`), trail.length));
141810
141886
  };
141811
141887
  var fromString = (s) => {
141812
141888
  if (s === "") {
@@ -141845,7 +141921,7 @@ var fromString = (s) => {
141845
141921
  if (!Number.isSafeInteger(scale2)) {
141846
141922
  return none2();
141847
141923
  }
141848
- return some3(make42(BigInt(digits), scale2));
141924
+ return some3(make43(BigInt(digits), scale2));
141849
141925
  };
141850
141926
  var format4 = (n) => {
141851
141927
  const normalized = normalize(n);
@@ -141997,7 +142073,7 @@ var proto4 = {
141997
142073
  }
141998
142074
  };
141999
142075
  var isRedacted = (u) => hasProperty(u, RedactedTypeId);
142000
- var make43 = (value3) => {
142076
+ var make44 = (value3) => {
142001
142077
  const redacted3 = Object.create(proto4);
142002
142078
  redactedRegistry.set(redacted3, value3);
142003
142079
  return redacted3;
@@ -142018,7 +142094,7 @@ var SecretProto = {
142018
142094
  ...proto4,
142019
142095
  [SecretTypeId]: SecretTypeId
142020
142096
  };
142021
- var make44 = (bytes) => {
142097
+ var make45 = (bytes) => {
142022
142098
  const secret3 = Object.create(SecretProto);
142023
142099
  Object.defineProperty(secret3, "toString", {
142024
142100
  enumerable: false,
@@ -142040,7 +142116,7 @@ var make44 = (bytes) => {
142040
142116
  return secret3;
142041
142117
  };
142042
142118
  var fromString3 = (text) => {
142043
- return make44(text.split("").map((char2) => char2.charCodeAt(0)));
142119
+ return make45(text.split("").map((char2) => char2.charCodeAt(0)));
142044
142120
  };
142045
142121
 
142046
142122
  // node_modules/.pnpm/effect@3.21.3/node_modules/effect/dist/esm/internal/config.js
@@ -142229,7 +142305,7 @@ var secret = (name) => {
142229
142305
  };
142230
142306
  var redacted = (nameOrConfig) => {
142231
142307
  const config3 = isConfig(nameOrConfig) ? nameOrConfig : string2(nameOrConfig);
142232
- return map19(config3, make43);
142308
+ return map19(config3, make44);
142233
142309
  };
142234
142310
  var branded = /* @__PURE__ */ dual(2, (nameOrConfig, constructor) => {
142235
142311
  const config3 = isConfig(nameOrConfig) ? nameOrConfig : string2(nameOrConfig);
@@ -148625,13 +148701,13 @@ __export(Redacted_exports, {
148625
148701
  RedactedTypeId: () => RedactedTypeId2,
148626
148702
  getEquivalence: () => getEquivalence7,
148627
148703
  isRedacted: () => isRedacted2,
148628
- make: () => make46,
148704
+ make: () => make47,
148629
148705
  unsafeWipe: () => unsafeWipe2,
148630
148706
  value: () => value2
148631
148707
  });
148632
148708
  var RedactedTypeId2 = RedactedTypeId;
148633
148709
  var isRedacted2 = isRedacted;
148634
- var make46 = make43;
148710
+ var make47 = make44;
148635
148711
  var value2 = value;
148636
148712
  var unsafeWipe2 = unsafeWipe;
148637
148713
  var getEquivalence7 = (isEquivalent) => make((x, y) => isEquivalent(value2(x), value2(y)));
@@ -148658,12 +148734,12 @@ var omit4 = /* @__PURE__ */ dual((args2) => isObject(args2[0]), (s, ...keys6) =>
148658
148734
 
148659
148735
  // node_modules/.pnpm/effect@3.21.3/node_modules/effect/dist/esm/Schema.js
148660
148736
  var TypeId21 = /* @__PURE__ */ Symbol.for("effect/Schema");
148661
- function make47(ast) {
148737
+ function make48(ast) {
148662
148738
  return class SchemaClass {
148663
148739
  [TypeId21] = variance5;
148664
148740
  static ast = ast;
148665
148741
  static annotations(annotations3) {
148666
- return make47(mergeSchemaAnnotations(this.ast, annotations3));
148742
+ return make48(mergeSchemaAnnotations(this.ast, annotations3));
148667
148743
  }
148668
148744
  static pipe() {
148669
148745
  return pipeArguments(this, arguments);
@@ -148701,7 +148777,7 @@ var standardSchemaV1 = (schema, overrideOptions) => {
148701
148777
  const decodeUnknown4 = decodeUnknown2(schema, {
148702
148778
  errors: "all"
148703
148779
  });
148704
- return class StandardSchemaV1Class extends make47(schema.ast) {
148780
+ return class StandardSchemaV1Class extends make48(schema.ast) {
148705
148781
  static "~standard" = {
148706
148782
  version: 1,
148707
148783
  vendor: "effect",
@@ -148771,9 +148847,9 @@ function asSchema(schema) {
148771
148847
  return schema;
148772
148848
  }
148773
148849
  var format6 = (schema) => String(schema.ast);
148774
- var encodedSchema = (schema) => make47(encodedAST(schema.ast));
148775
- var encodedBoundSchema = (schema) => make47(encodedBoundAST(schema.ast));
148776
- var typeSchema = (schema) => make47(typeAST(schema.ast));
148850
+ var encodedSchema = (schema) => make48(encodedAST(schema.ast));
148851
+ var encodedBoundSchema = (schema) => make48(encodedBoundAST(schema.ast));
148852
+ var typeSchema = (schema) => make48(typeAST(schema.ast));
148777
148853
  var encodeUnknown2 = (schema, options) => {
148778
148854
  const encodeUnknown3 = encodeUnknown(schema, options);
148779
148855
  return (u, overrideOptions) => mapError6(encodeUnknown3(u, overrideOptions), parseError);
@@ -148821,7 +148897,7 @@ function getDefaultLiteralAST(literals) {
148821
148897
  return isMembers(literals) ? Union.make(mapMembers(literals, (literal4) => new Literal(literal4))) : new Literal(literals[0]);
148822
148898
  }
148823
148899
  function makeLiteralClass(literals, ast = getDefaultLiteralAST(literals)) {
148824
- return class LiteralClass extends make47(ast) {
148900
+ return class LiteralClass extends make48(ast) {
148825
148901
  static annotations(annotations3) {
148826
148902
  return makeLiteralClass(this.literals, mergeSchemaAnnotations(this.ast, annotations3));
148827
148903
  }
@@ -148832,9 +148908,9 @@ function Literal2(...literals) {
148832
148908
  return isNonEmptyReadonlyArray(literals) ? makeLiteralClass(literals) : Never;
148833
148909
  }
148834
148910
  var pickLiteral = (...literals) => (_schema) => Literal2(...literals);
148835
- var UniqueSymbolFromSelf = (symbol4) => make47(new UniqueSymbol(symbol4));
148911
+ var UniqueSymbolFromSelf = (symbol4) => make48(new UniqueSymbol(symbol4));
148836
148912
  var getDefaultEnumsAST = (enums) => new Enums(Object.keys(enums).filter((key) => typeof enums[enums[key]] !== "number").map((key) => [key, enums[key]]));
148837
- var makeEnumsClass = (enums, ast = getDefaultEnumsAST(enums)) => class EnumsClass extends make47(ast) {
148913
+ var makeEnumsClass = (enums, ast = getDefaultEnumsAST(enums)) => class EnumsClass extends make48(ast) {
148838
148914
  static annotations(annotations3) {
148839
148915
  return makeEnumsClass(this.enums, mergeSchemaAnnotations(this.ast, annotations3));
148840
148916
  }
@@ -148879,9 +148955,9 @@ var TemplateLiteral2 = (...[head6, ...tail3]) => {
148879
148955
  }
148880
148956
  }
148881
148957
  if (isNonEmptyArray2(spans)) {
148882
- return make47(new TemplateLiteral(h, spans));
148958
+ return make48(new TemplateLiteral(h, spans));
148883
148959
  } else {
148884
- return make47(new TemplateLiteral("", [new TemplateLiteralSpan(new Literal(h), "")]));
148960
+ return make48(new TemplateLiteral("", [new TemplateLiteralSpan(new Literal(h), "")]));
148885
148961
  }
148886
148962
  };
148887
148963
  function getTemplateLiteralParserCoercedElement(encoded, schema) {
@@ -148905,7 +148981,7 @@ function getTemplateLiteralParserCoercedElement(encoded, schema) {
148905
148981
  const members = [];
148906
148982
  let hasCoercions = false;
148907
148983
  for (const member of ast.types) {
148908
- const schema2 = make47(member);
148984
+ const schema2 = make48(member);
148909
148985
  const encoded2 = encodedSchema(schema2);
148910
148986
  const coerced = getTemplateLiteralParserCoercedElement(encoded2, schema2);
148911
148987
  if (coerced) {
@@ -148955,14 +149031,14 @@ var TemplateLiteralParser = (...params) => {
148955
149031
  static params = params.slice();
148956
149032
  };
148957
149033
  };
148958
- var declareConstructor = (typeParameters, options, annotations3) => makeDeclareClass(typeParameters, new Declaration(typeParameters.map((tp) => tp.ast), (...typeParameters2) => options.decode(...typeParameters2.map(make47)), (...typeParameters2) => options.encode(...typeParameters2.map(make47)), toASTAnnotations(annotations3)));
149034
+ var declareConstructor = (typeParameters, options, annotations3) => makeDeclareClass(typeParameters, new Declaration(typeParameters.map((tp) => tp.ast), (...typeParameters2) => options.decode(...typeParameters2.map(make48)), (...typeParameters2) => options.encode(...typeParameters2.map(make48)), toASTAnnotations(annotations3)));
148959
149035
  var declarePrimitive = (is2, annotations3) => {
148960
149036
  const decodeUnknown4 = () => (input, _, ast) => is2(input) ? succeed12(input) : fail11(new Type2(ast, input));
148961
149037
  const encodeUnknown3 = decodeUnknown4;
148962
149038
  return makeDeclareClass([], new Declaration([], decodeUnknown4, encodeUnknown3, toASTAnnotations(annotations3)));
148963
149039
  };
148964
149040
  function makeDeclareClass(typeParameters, ast) {
148965
- return class DeclareClass extends make47(ast) {
149041
+ return class DeclareClass extends make48(ast) {
148966
149042
  static annotations(annotations3) {
148967
149043
  return makeDeclareClass(this.typeParameters, mergeSchemaAnnotations(this.ast, annotations3));
148968
149044
  }
@@ -149005,33 +149081,33 @@ var instanceOf = (constructor, annotations3) => declare((u) => u instanceof cons
149005
149081
  },
149006
149082
  ...annotations3
149007
149083
  });
149008
- var Undefined = class extends (/* @__PURE__ */ make47(undefinedKeyword)) {
149084
+ var Undefined = class extends (/* @__PURE__ */ make48(undefinedKeyword)) {
149009
149085
  };
149010
- var Void = class extends (/* @__PURE__ */ make47(voidKeyword)) {
149086
+ var Void = class extends (/* @__PURE__ */ make48(voidKeyword)) {
149011
149087
  };
149012
- var Null = class extends (/* @__PURE__ */ make47($null)) {
149088
+ var Null = class extends (/* @__PURE__ */ make48($null)) {
149013
149089
  };
149014
- var Never = class extends (/* @__PURE__ */ make47(neverKeyword)) {
149090
+ var Never = class extends (/* @__PURE__ */ make48(neverKeyword)) {
149015
149091
  };
149016
- var Unknown = class extends (/* @__PURE__ */ make47(unknownKeyword)) {
149092
+ var Unknown = class extends (/* @__PURE__ */ make48(unknownKeyword)) {
149017
149093
  };
149018
- var Any = class extends (/* @__PURE__ */ make47(anyKeyword)) {
149094
+ var Any = class extends (/* @__PURE__ */ make48(anyKeyword)) {
149019
149095
  };
149020
- var BigIntFromSelf = class extends (/* @__PURE__ */ make47(bigIntKeyword)) {
149096
+ var BigIntFromSelf = class extends (/* @__PURE__ */ make48(bigIntKeyword)) {
149021
149097
  };
149022
- var SymbolFromSelf = class extends (/* @__PURE__ */ make47(symbolKeyword)) {
149098
+ var SymbolFromSelf = class extends (/* @__PURE__ */ make48(symbolKeyword)) {
149023
149099
  };
149024
- var String$ = class extends (/* @__PURE__ */ make47(stringKeyword)) {
149100
+ var String$ = class extends (/* @__PURE__ */ make48(stringKeyword)) {
149025
149101
  };
149026
- var Number$ = class extends (/* @__PURE__ */ make47(numberKeyword)) {
149102
+ var Number$ = class extends (/* @__PURE__ */ make48(numberKeyword)) {
149027
149103
  };
149028
- var Boolean$ = class extends (/* @__PURE__ */ make47(booleanKeyword)) {
149104
+ var Boolean$ = class extends (/* @__PURE__ */ make48(booleanKeyword)) {
149029
149105
  };
149030
- var Object$ = class extends (/* @__PURE__ */ make47(objectKeyword)) {
149106
+ var Object$ = class extends (/* @__PURE__ */ make48(objectKeyword)) {
149031
149107
  };
149032
149108
  var getDefaultUnionAST = (members) => Union.make(members.map((m) => m.ast));
149033
149109
  function makeUnionClass(members, ast = getDefaultUnionAST(members)) {
149034
- return class UnionClass extends make47(ast) {
149110
+ return class UnionClass extends make48(ast) {
149035
149111
  static annotations(annotations3) {
149036
149112
  return makeUnionClass(this.members, mergeSchemaAnnotations(this.ast, annotations3));
149037
149113
  }
@@ -149044,7 +149120,7 @@ function Union2(...members) {
149044
149120
  var NullOr = (self) => Union2(self, Null);
149045
149121
  var UndefinedOr = (self) => Union2(self, Undefined);
149046
149122
  var NullishOr = (self) => Union2(self, Null, Undefined);
149047
- var keyof2 = (self) => make47(keyof(self.ast));
149123
+ var keyof2 = (self) => make48(keyof(self.ast));
149048
149124
  var element = (self) => new ElementImpl(new OptionalType(self.ast, false), self);
149049
149125
  var optionalElement = (self) => new ElementImpl(new OptionalType(self.ast, true), self);
149050
149126
  var ElementImpl = class _ElementImpl {
@@ -149068,7 +149144,7 @@ var ElementImpl = class _ElementImpl {
149068
149144
  };
149069
149145
  var getDefaultTupleTypeAST = (elements, rest) => new TupleType(elements.map((el) => isSchema(el) ? new OptionalType(el.ast, false) : el.ast), rest.map((el) => isSchema(el) ? new Type(el.ast) : el.ast), true);
149070
149146
  function makeTupleTypeClass(elements, rest, ast = getDefaultTupleTypeAST(elements, rest)) {
149071
- return class TupleTypeClass extends make47(ast) {
149147
+ return class TupleTypeClass extends make48(ast) {
149072
149148
  static annotations(annotations3) {
149073
149149
  return makeTupleTypeClass(this.elements, this.rest, mergeSchemaAnnotations(this.ast, annotations3));
149074
149150
  }
@@ -149465,7 +149541,7 @@ var lazilyMergeDefaults = (fields, out) => {
149465
149541
  return out;
149466
149542
  };
149467
149543
  function makeTypeLiteralClass(fields, records, ast = getDefaultTypeLiteralAST(fields, records)) {
149468
- return class TypeLiteralClass extends make47(ast) {
149544
+ return class TypeLiteralClass extends make48(ast) {
149469
149545
  static annotations(annotations3) {
149470
149546
  return makeTypeLiteralClass(this.fields, this.records, mergeSchemaAnnotations(this.ast, annotations3));
149471
149547
  }
@@ -149508,11 +149584,11 @@ function makeRecordClass(key, value3, ast) {
149508
149584
  };
149509
149585
  }
149510
149586
  var Record = (options) => makeRecordClass(options.key, options.value);
149511
- var pick5 = (...keys6) => (self) => make47(pick3(self.ast, keys6));
149512
- var omit5 = (...keys6) => (self) => make47(omit3(self.ast, keys6));
149587
+ var pick5 = (...keys6) => (self) => make48(pick3(self.ast, keys6));
149588
+ var omit5 = (...keys6) => (self) => make48(omit3(self.ast, keys6));
149513
149589
  var pluck = /* @__PURE__ */ dual(2, (schema, key) => {
149514
149590
  const ps = getPropertyKeyIndexedAccess(typeAST(schema.ast), key);
149515
- const value3 = make47(ps.isOptional ? orUndefined(ps.type) : ps.type);
149591
+ const value3 = make48(ps.isOptional ? orUndefined(ps.type) : ps.type);
149516
149592
  const out = transform2(schema.pipe(pick5(key)), value3, {
149517
149593
  strict: true,
149518
149594
  decode: (i) => i[key],
@@ -149523,7 +149599,7 @@ var pluck = /* @__PURE__ */ dual(2, (schema, key) => {
149523
149599
  return out;
149524
149600
  });
149525
149601
  function makeBrandClass(from, ast) {
149526
- return class BrandClass extends make47(ast) {
149602
+ return class BrandClass extends make48(ast) {
149527
149603
  static annotations(annotations3) {
149528
149604
  return makeBrandClass(this.from, mergeSchemaAnnotations(this.ast, annotations3));
149529
149605
  }
@@ -149544,10 +149620,10 @@ var brand = (brand2, annotations3) => (self) => {
149544
149620
  }));
149545
149621
  return makeBrandClass(self, ast);
149546
149622
  };
149547
- var partial2 = (self) => make47(partial(self.ast));
149548
- var partialWith = /* @__PURE__ */ dual((args2) => isSchema(args2[0]), (self, options) => make47(partial(self.ast, options)));
149549
- var required2 = (self) => make47(required(self.ast));
149550
- var mutable2 = (schema) => make47(mutable(schema.ast));
149623
+ var partial2 = (self) => make48(partial(self.ast));
149624
+ var partialWith = /* @__PURE__ */ dual((args2) => isSchema(args2[0]), (self, options) => make48(partial(self.ast, options)));
149625
+ var required2 = (self) => make48(required(self.ast));
149626
+ var mutable2 = (schema) => make48(mutable(schema.ast));
149551
149627
  var intersectTypeLiterals = (x, y, path2) => {
149552
149628
  if (isTypeLiteral(x) && isTypeLiteral(y)) {
149553
149629
  const propertySignatures = [...x.propertySignatures];
@@ -149667,12 +149743,12 @@ var intersectUnionMembers = (xs, ys, path2) => flatMap3(xs, (x) => flatMap3(ys,
149667
149743
  }
149668
149744
  throw new Error(getSchemaExtendErrorMessage(x, y, path2));
149669
149745
  }));
149670
- var extend4 = /* @__PURE__ */ dual(2, (self, that) => make47(extendAST(self.ast, that.ast, [])));
149746
+ var extend4 = /* @__PURE__ */ dual(2, (self, that) => make48(extendAST(self.ast, that.ast, [])));
149671
149747
  var compose5 = /* @__PURE__ */ dual((args2) => isSchema(args2[1]), (from, to) => makeTransformationClass(from, to, compose4(from.ast, to.ast)));
149672
- var suspend8 = (f) => make47(new Suspend(() => f().ast));
149748
+ var suspend8 = (f) => make48(new Suspend(() => f().ast));
149673
149749
  var RefineSchemaId = /* @__PURE__ */ Symbol.for("effect/SchemaId/Refine");
149674
149750
  function makeRefineClass(from, filter11, ast) {
149675
- return class RefineClass extends make47(ast) {
149751
+ return class RefineClass extends make48(ast) {
149676
149752
  static annotations(annotations3) {
149677
149753
  return makeRefineClass(this.from, this.filter, mergeSchemaAnnotations(this.ast, annotations3));
149678
149754
  }
@@ -149730,7 +149806,7 @@ var filterEffect = /* @__PURE__ */ dual(2, (self, f) => transformOrFail(self, ty
149730
149806
  encode: (a) => succeed12(a)
149731
149807
  }));
149732
149808
  function makeTransformationClass(from, to, ast) {
149733
- return class TransformationClass extends make47(ast) {
149809
+ return class TransformationClass extends make48(ast) {
149734
149810
  static annotations(annotations3) {
149735
149811
  return makeTransformationClass(this.from, this.to, mergeSchemaAnnotations(this.ast, annotations3));
149736
149812
  }
@@ -149758,10 +149834,10 @@ var attachPropertySignature = /* @__PURE__ */ dual((args2) => isSchema(args2[0])
149758
149834
  const ast = extend4(typeSchema(schema), Struct({
149759
149835
  [key]: isSymbol(value3) ? UniqueSymbolFromSelf(value3) : Literal2(value3)
149760
149836
  })).ast;
149761
- return make47(new Transformation(schema.ast, annotations3 ? mergeSchemaAnnotations(ast, annotations3) : ast, new TypeLiteralTransformation([new PropertySignatureTransformation(key, key, () => some3(value3), () => none2())])));
149837
+ return make48(new Transformation(schema.ast, annotations3 ? mergeSchemaAnnotations(ast, annotations3) : ast, new TypeLiteralTransformation([new PropertySignatureTransformation(key, key, () => some3(value3), () => none2())])));
149762
149838
  });
149763
149839
  var annotations2 = /* @__PURE__ */ dual(2, (self, annotations3) => self.annotations(annotations3));
149764
- var rename2 = /* @__PURE__ */ dual(2, (self, mapping) => make47(rename(self.ast, mapping)));
149840
+ var rename2 = /* @__PURE__ */ dual(2, (self, mapping) => make48(rename(self.ast, mapping)));
149765
149841
  var TrimmedSchemaId = /* @__PURE__ */ Symbol.for("effect/SchemaId/Trimmed");
149766
149842
  var trimmed = (annotations3) => (self) => self.pipe(filter10((a) => a === a.trim(), {
149767
149843
  schemaId: TrimmedSchemaId,
@@ -150387,12 +150463,12 @@ var BigIntFromNumber = class extends (/* @__PURE__ */ transformOrFail(Number$.an
150387
150463
  identifier: "BigIntFromNumber"
150388
150464
  })) {
150389
150465
  };
150390
- var redactedArbitrary = (value3) => (fc) => value3(fc).map(make46);
150466
+ var redactedArbitrary = (value3) => (fc) => value3(fc).map(make47);
150391
150467
  var toComposite = (eff, onSuccess, ast, actual) => mapBoth7(eff, {
150392
150468
  onFailure: (e) => new Composite2(ast, actual, e),
150393
150469
  onSuccess
150394
150470
  });
150395
- var redactedParse = (decodeUnknown4) => (u, options, ast) => isRedacted2(u) ? toComposite(decodeUnknown4(value2(u), options), make46, ast, u) : fail11(new Type2(ast, u));
150471
+ var redactedParse = (decodeUnknown4) => (u, options, ast) => isRedacted2(u) ? toComposite(decodeUnknown4(value2(u), options), make47, ast, u) : fail11(new Type2(ast, u));
150396
150472
  var RedactedFromSelf = (value3) => declare([value3], {
150397
150473
  decode: (value4) => redactedParse(decodeUnknown2(value4)),
150398
150474
  encode: (value4) => redactedParse(encodeUnknown(value4))
@@ -150408,7 +150484,7 @@ var RedactedFromSelf = (value3) => declare([value3], {
150408
150484
  function Redacted(value3) {
150409
150485
  return transform2(value3, RedactedFromSelf(typeSchema(asSchema(value3))), {
150410
150486
  strict: true,
150411
- decode: (i) => make46(i),
150487
+ decode: (i) => make47(i),
150412
150488
  encode: (a) => value2(a)
150413
150489
  });
150414
150490
  }
@@ -150685,7 +150761,7 @@ var itemsCount = (n, annotations3) => (self) => {
150685
150761
  ...annotations3
150686
150762
  }));
150687
150763
  };
150688
- var getNumberIndexedAccess2 = (self) => make47(getNumberIndexedAccess(self.ast));
150764
+ var getNumberIndexedAccess2 = (self) => make48(getNumberIndexedAccess(self.ast));
150689
150765
  function head5(self) {
150690
150766
  return transform2(self, OptionFromSelf(getNumberIndexedAccess2(typeSchema(self))), {
150691
150767
  strict: false,
@@ -151288,7 +151364,7 @@ var bigDecimalPretty = () => (val) => `BigDecimal(${format4(normalize(val))})`;
151288
151364
  var bigDecimalArbitrary = () => (fc) => fc.tuple(fc.bigInt(), fc.integer({
151289
151365
  min: -18,
151290
151366
  max: 18
151291
- })).map(([value3, scale2]) => make42(value3, scale2));
151367
+ })).map(([value3, scale2]) => make43(value3, scale2));
151292
151368
  var BigDecimalFromSelf = class extends (/* @__PURE__ */ declare(isBigDecimal, {
151293
151369
  typeConstructor: {
151294
151370
  _tag: "effect/BigDecimal"
@@ -151690,7 +151766,7 @@ var makeClass = ({
151690
151766
  return pipeArguments(this, arguments);
151691
151767
  }
151692
151768
  static annotations(annotations4) {
151693
- return make47(this.ast).annotations(annotations4);
151769
+ return make48(this.ast).annotations(annotations4);
151694
151770
  }
151695
151771
  static toString() {
151696
151772
  return `(${String(encodedSide)} <-> ${identifier2})`;
@@ -152550,9 +152626,9 @@ var JSONSchema_exports = {};
152550
152626
  __export(JSONSchema_exports, {
152551
152627
  fromAST: () => fromAST,
152552
152628
  getMetaSchemaUri: () => getMetaSchemaUri,
152553
- make: () => make48
152629
+ make: () => make49
152554
152630
  });
152555
- var make48 = (schema, options) => {
152631
+ var make49 = (schema, options) => {
152556
152632
  const definitions = {};
152557
152633
  const target = options?.target ?? "jsonSchema7";
152558
152634
  const ast = isTransformation(schema.ast) && isParseJsonTransformation(schema.ast.from) ? schema.ast.to : schema.ast;
@@ -153189,7 +153265,7 @@ __export(ConfigProvider_exports, {
153189
153265
  fromMap: () => fromMap2,
153190
153266
  kebabCase: () => kebabCase3,
153191
153267
  lowerCase: () => lowerCase3,
153192
- make: () => make49,
153268
+ make: () => make50,
153193
153269
  makeFlat: () => makeFlat2,
153194
153270
  mapInputPath: () => mapInputPath2,
153195
153271
  nested: () => nested5,
@@ -153202,7 +153278,7 @@ __export(ConfigProvider_exports, {
153202
153278
  var ConfigProviderTypeId2 = ConfigProviderTypeId;
153203
153279
  var FlatConfigProviderTypeId2 = FlatConfigProviderTypeId;
153204
153280
  var ConfigProvider = configProviderTag;
153205
- var make49 = make20;
153281
+ var make50 = make20;
153206
153282
  var makeFlat2 = makeFlat;
153207
153283
  var fromEnv2 = fromEnv;
153208
153284
  var fromFlat2 = fromFlat;
@@ -158094,6 +158170,30 @@ var validatePersonUuid = (uuid5) => {
158094
158170
  var import_promises = require("node:dns/promises");
158095
158171
  var http = __toESM(require("node:http"), 1);
158096
158172
  var https = __toESM(require("node:https"), 1);
158173
+
158174
+ // src/utils/assertions.ts
158175
+ var AssertionError = class extends Error {
158176
+ _tag = "AssertionError";
158177
+ constructor(message) {
158178
+ super(message);
158179
+ this.name = "AssertionError";
158180
+ }
158181
+ };
158182
+ var assertExists = (value3, message) => {
158183
+ if (value3 === null || value3 === void 0) {
158184
+ throw new AssertionError(message ?? "Expected value to exist");
158185
+ }
158186
+ return value3;
158187
+ };
158188
+ var isExistent = (value3) => value3 !== null && value3 !== void 0;
158189
+ var assertAt = (arr, index, message) => {
158190
+ return assertExists(arr[index], message ?? `Expected array item at index ${index}`);
158191
+ };
158192
+ var isNonEmpty7 = (arr) => arr.length > 0;
158193
+ var isSingle2 = (arr) => arr.length === 1;
158194
+ var isPair = (arr) => arr.length === 2;
158195
+
158196
+ // src/huly/url-fetch.ts
158097
158197
  var FETCH_TIMEOUT_MS = 3e4;
158098
158198
  var HTTP_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
158099
158199
  var IPV4_OCTET_COUNT = 4;
@@ -158150,10 +158250,14 @@ var parseIpv4Address = (hostname3) => {
158150
158250
  return null;
158151
158251
  }
158152
158252
  const octets = parts2.map(Number);
158253
+ const a = assertAt(octets, 0);
158254
+ const b = assertAt(octets, 1);
158255
+ const c = assertAt(octets, 2);
158256
+ const d = assertAt(octets, 3);
158153
158257
  if (octets.some((octet) => !Number.isInteger(octet) || octet < 0 || octet > IPV4_MAX_OCTET)) {
158154
158258
  return null;
158155
158259
  }
158156
- return [octets[0], octets[1], octets[2], octets[3]];
158260
+ return [a, b, c, d];
158157
158261
  };
158158
158262
  var isBlockedIpv4Address = ([a, b, c]) => {
158159
158263
  if (a === 0) return true;
@@ -158178,8 +158282,10 @@ var ipv4FromMappedIpv6Hextets = (hostname3) => {
158178
158282
  if (match16 === null) {
158179
158283
  return null;
158180
158284
  }
158181
- const high = Number.parseInt(match16[1], 16);
158182
- const low = Number.parseInt(match16[2], 16);
158285
+ const highText = assertAt(match16, 1);
158286
+ const lowText = assertAt(match16, 2);
158287
+ const high = Number.parseInt(highText, 16);
158288
+ const low = Number.parseInt(lowText, 16);
158183
158289
  return [
158184
158290
  Math.floor(high / BYTE_BASE),
158185
158291
  high % BYTE_BASE,
@@ -158204,6 +158310,17 @@ var parseIpv6Side = (value3) => {
158204
158310
  });
158205
158311
  return hextets.length === parts2.length ? hextets : null;
158206
158312
  };
158313
+ var isIpv6Hextets = (hextets) => hextets.length === IPV6_HEXTET_COUNT;
158314
+ var toIpv6Hextets = (hextets) => [
158315
+ assertAt(hextets, 0),
158316
+ assertAt(hextets, 1),
158317
+ assertAt(hextets, 2),
158318
+ assertAt(hextets, 3),
158319
+ assertAt(hextets, 4),
158320
+ assertAt(hextets, 5),
158321
+ assertAt(hextets, 6),
158322
+ assertAt(hextets, 7)
158323
+ ];
158207
158324
  var parseIpv6Hextets = (hostname3) => {
158208
158325
  if (hostname3.includes(".")) {
158209
158326
  return null;
@@ -158212,26 +158329,29 @@ var parseIpv6Hextets = (hostname3) => {
158212
158329
  if (compressedParts.length > 2) {
158213
158330
  return null;
158214
158331
  }
158215
- const left3 = parseIpv6Side(compressedParts[0]);
158216
- const right3 = compressedParts.length === 2 ? parseIpv6Side(compressedParts[1]) : [];
158332
+ const leftText = assertAt(compressedParts, 0);
158333
+ const left3 = parseIpv6Side(leftText);
158334
+ const right3 = compressedParts.length === 2 ? parseIpv6Side(assertAt(compressedParts, 1)) : [];
158217
158335
  if (left3 === null || right3 === null) {
158218
158336
  return null;
158219
158337
  }
158220
158338
  if (compressedParts.length === 1) {
158221
- return left3.length === IPV6_HEXTET_COUNT ? left3 : null;
158339
+ return isIpv6Hextets(left3) ? left3 : null;
158222
158340
  }
158223
158341
  const zeroCount = IPV6_HEXTET_COUNT - left3.length - right3.length;
158224
158342
  if (zeroCount < 1) {
158225
158343
  return null;
158226
158344
  }
158227
- return [...left3, ...Array.from({ length: zeroCount }, () => 0), ...right3];
158345
+ const hextets = [...left3, ...Array.from({ length: zeroCount }, () => 0), ...right3];
158346
+ return toIpv6Hextets(hextets);
158228
158347
  };
158229
158348
  var isIpv6InPrefix = (hextets, prefix) => {
158230
158349
  const fullHextetCount = Math.floor(prefix.prefixLength / IPV6_HEXTET_BITS);
158231
158350
  const remainingBits = prefix.prefixLength % IPV6_HEXTET_BITS;
158232
158351
  let index = 0;
158233
158352
  for (const prefixHextet2 of prefix.hextets.slice(0, fullHextetCount)) {
158234
- if (hextets[index] !== prefixHextet2) {
158353
+ const addressHextet2 = assertAt(hextets, index);
158354
+ if (addressHextet2 !== prefixHextet2) {
158235
158355
  return false;
158236
158356
  }
158237
158357
  index += 1;
@@ -158239,8 +158359,8 @@ var isIpv6InPrefix = (hextets, prefix) => {
158239
158359
  if (remainingBits === 0) {
158240
158360
  return true;
158241
158361
  }
158242
- const prefixHextet = prefix.hextets[fullHextetCount];
158243
- const addressHextet = hextets[fullHextetCount];
158362
+ const prefixHextet = assertAt(prefix.hextets, fullHextetCount);
158363
+ const addressHextet = assertAt(hextets, fullHextetCount);
158244
158364
  const mask = IPV6_HEXTET_MAX << IPV6_HEXTET_BITS - remainingBits & IPV6_HEXTET_MAX;
158245
158365
  return (addressHextet & mask) === (prefixHextet & mask);
158246
158366
  };
@@ -158248,7 +158368,7 @@ var requestFirstSuccessfulAddress = async (url4, dependencies, addresses, index
158248
158368
  if (index >= addresses.length) {
158249
158369
  throw new Error(`Request failed for all resolved addresses: ${failures3.join("; ")}`);
158250
158370
  }
158251
- const address = addresses[index];
158371
+ const address = assertAt(addresses, index);
158252
158372
  try {
158253
158373
  return await dependencies.requestUrl(url4, address);
158254
158374
  } catch (error2) {
@@ -168592,8 +168712,9 @@ var mapParseCauseToMcp = (cause3, toolName) => {
168592
168712
  return mapParseErrorToMcp(cause3.error, toolName);
168593
168713
  }
168594
168714
  const failures3 = Chunk_exports.toArray(Cause_exports.failures(cause3));
168595
- if (failures3.length > 0) {
168596
- return mapParseErrorToMcp(failures3[0], toolName);
168715
+ const firstFailure = failures3[0];
168716
+ if (firstFailure !== void 0) {
168717
+ return mapParseErrorToMcp(firstFailure, toolName);
168597
168718
  }
168598
168719
  return createErrorResponse("An unexpected error occurred", McpErrorCode.InternalError);
168599
168720
  };
@@ -168605,8 +168726,9 @@ var mapDomainCauseToMcp = (cause3, warnings = []) => {
168605
168726
  return createErrorResponse("An unexpected error occurred", McpErrorCode.InternalError, "UnexpectedError", warnings);
168606
168727
  }
168607
168728
  const failures3 = Chunk_exports.toArray(Cause_exports.failures(cause3));
168608
- if (failures3.length > 0) {
168609
- return mapDomainErrorToMcp(failures3[0], warnings);
168729
+ const firstFailure = failures3[0];
168730
+ if (firstFailure !== void 0) {
168731
+ return mapDomainErrorToMcp(firstFailure, warnings);
168610
168732
  }
168611
168733
  return createErrorResponse("An unexpected error occurred", McpErrorCode.InternalError, void 0, warnings);
168612
168734
  };
@@ -168688,7 +168810,7 @@ var httpStatusForErrorCode = (code) => {
168688
168810
  var acceptsModernResponseTypes = (req) => {
168689
168811
  const accept = firstHeader(req.headers.accept);
168690
168812
  if (accept === void 0) return false;
168691
- const parts2 = accept.split(",").map((part) => part.split(";")[0].trim().toLowerCase());
168813
+ const parts2 = accept.split(",").map((part) => (part.split(";")[0] ?? "").trim().toLowerCase());
168692
168814
  return parts2.includes("application/json") && parts2.includes("text/event-stream");
168693
168815
  };
168694
168816
  var validateJsonRpcRequest = (body) => {
@@ -178446,10 +178568,44 @@ var makeDiagnosticsScope = Effect_exports.gen(function* () {
178446
178568
  });
178447
178569
 
178448
178570
  // src/version.ts
178449
- var VERSION = true ? "0.38.0" : "0.0.0-dev";
178571
+ var VERSION = true ? "0.39.1" : "0.0.0-dev";
178572
+
178573
+ // src/mcp/json-schema-refs.ts
178574
+ var isJsonObject = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
178575
+ var mergeDefinitionRecords = (definitions) => {
178576
+ const merged = definitions.reduce(
178577
+ (acc, definition) => definition === void 0 ? acc : { ...acc, ...definition },
178578
+ {}
178579
+ );
178580
+ return Object.keys(merged).length > 0 ? merged : void 0;
178581
+ };
178582
+ var collectJsonSchemaDefinitions = (value3) => {
178583
+ if (Array.isArray(value3)) {
178584
+ return mergeDefinitionRecords(value3.map(collectJsonSchemaDefinitions));
178585
+ }
178586
+ if (!isJsonObject(value3)) return void 0;
178587
+ const ownDefinitions = isJsonObject(value3.$defs) ? value3.$defs : void 0;
178588
+ const nestedDefinitions = Object.entries(value3).filter(([key]) => key !== "$defs").map(([, nested6]) => collectJsonSchemaDefinitions(nested6));
178589
+ return mergeDefinitionRecords([...nestedDefinitions, ownDefinitions]);
178590
+ };
178591
+ var omitJsonSchemaDocumentMetadata = (schema) => Object.fromEntries(Object.entries(schema).filter(([key]) => key !== "$defs" && key !== "$schema"));
178450
178592
 
178451
178593
  // src/mcp/tool-output-schema.ts
178452
178594
  var toolWarningCodeEnum = [...ToolWarningCodeSchema.literals];
178595
+ var wrapResultOutputSchema = (resultSchema) => {
178596
+ const resultDefs = collectJsonSchemaDefinitions(resultSchema);
178597
+ const resultJsonSchemaDialect = "$schema" in resultSchema ? resultSchema["$schema"] : void 0;
178598
+ const embeddedResultSchema = omitJsonSchemaDocumentMetadata(resultSchema);
178599
+ return {
178600
+ ...resultJsonSchemaDialect === void 0 ? {} : { $schema: resultJsonSchemaDialect },
178601
+ ...resultDefs === void 0 ? {} : { $defs: resultDefs },
178602
+ type: "object",
178603
+ properties: {
178604
+ result: embeddedResultSchema
178605
+ },
178606
+ required: ["result"]
178607
+ };
178608
+ };
178453
178609
  var defaultToolOutputSchema = {
178454
178610
  type: "object",
178455
178611
  properties: {
@@ -178478,27 +178634,15 @@ var defaultToolOutputSchema = {
178478
178634
  },
178479
178635
  required: ["result"]
178480
178636
  };
178481
- var versionToolOutputSchema = {
178637
+ var versionToolOutputSchema = wrapResultOutputSchema({
178482
178638
  type: "object",
178483
178639
  properties: {
178484
- result: {
178485
- type: "object",
178486
- properties: {
178487
- current: { type: "string", minLength: 1 },
178488
- latest: { type: "string", minLength: 1 }
178489
- },
178490
- required: ["current", "latest"]
178491
- }
178492
- },
178493
- required: ["result"]
178494
- };
178495
- var hulyContextToolOutputSchema = {
178496
- type: "object",
178497
- properties: {
178498
- result: getHulyContextResultJsonSchema
178640
+ current: { type: "string", minLength: 1 },
178641
+ latest: { type: "string", minLength: 1 }
178499
178642
  },
178500
- required: ["result"]
178501
- };
178643
+ required: ["current", "latest"]
178644
+ });
178645
+ var hulyContextToolOutputSchema = wrapResultOutputSchema(getHulyContextResultJsonSchema);
178502
178646
 
178503
178647
  // src/huly/operations/activity-messages.ts
178504
178648
  var import_core11 = __toESM(require_lib5(), 1);
@@ -178799,7 +178943,7 @@ var findPersonByEmail = (client, email3) => Effect_exports.gen(function* () {
178799
178943
  provider: contact.channelProvider.Email
178800
178944
  }
178801
178945
  );
178802
- if (channels.length === 0) {
178946
+ if (!isNonEmpty7(channels)) {
178803
178947
  return void 0;
178804
178948
  }
178805
178949
  const channel = channels[0];
@@ -179089,7 +179233,7 @@ var findSpace = (client, params) => Effect_exports.gen(function* () {
179089
179233
  }))
179090
179234
  });
179091
179235
  }
179092
- return matches[0];
179236
+ return assertAt(matches, 0);
179093
179237
  });
179094
179238
  var updateSpaceDoc = (client, space, operations) => client.updateDoc(
179095
179239
  toClassRef(space._class),
@@ -179299,7 +179443,8 @@ var findDirectMessage = (identifier2) => Effect_exports.gen(function* () {
179299
179443
  if (matches.length > 1) {
179300
179444
  return yield* new DirectMessageIdentifierAmbiguousError({ identifier: identifier2, matches: Count.make(matches.length) });
179301
179445
  }
179302
- return { client, dm: matches[0] };
179446
+ if (isSingle2(matches)) return { client, dm: matches[0] };
179447
+ return yield* new DirectMessageNotFoundError({ identifier: identifier2 });
179303
179448
  });
179304
179449
  var createDirectMessageSpace = (client, members) => Effect_exports.gen(function* () {
179305
179450
  const dmId = (0, import_core14.generateId)();
@@ -179387,7 +179532,7 @@ var createConversationContext = (client, conversation) => Effect_exports.gen(fun
179387
179532
  );
179388
179533
  return { id: contextId, space: contextSpace };
179389
179534
  });
179390
- var updateContext2 = (client, context6, operations) => client.updateDoc(
179535
+ var updateContext4 = (client, context6, operations) => client.updateDoc(
179391
179536
  notification.class.DocNotifyContext,
179392
179537
  context6.space,
179393
179538
  context6._id,
@@ -179427,7 +179572,7 @@ var setConversationState = (params, target) => Effect_exports.gen(function* () {
179427
179572
  if (currentValue === target.value) {
179428
179573
  return stateResult(conversation, context6._id, context6.isPinned, context6.hidden, false);
179429
179574
  }
179430
- yield* updateContext2(client, context6, { [target.field]: target.value });
179575
+ yield* updateContext4(client, context6, { [target.field]: target.value });
179431
179576
  return stateResult(
179432
179577
  conversation,
179433
179578
  context6._id,
@@ -180346,9 +180491,13 @@ var parseIssueIdentifier = (identifier2, projectIdentifier) => {
180346
180491
  const idStr = String(identifier2).trim();
180347
180492
  const match16 = idStr.match(/^([A-Z]+)-(\d+)$/i);
180348
180493
  if (match16) {
180494
+ const [, projectPrefix, issueNumber] = match16;
180495
+ if (projectPrefix === void 0 || issueNumber === void 0) {
180496
+ return { fullIdentifier: `${projectIdentifier}-${idStr}`, number: null };
180497
+ }
180349
180498
  return {
180350
- fullIdentifier: `${match16[1].toUpperCase()}-${match16[2]}`,
180351
- number: parseInt(match16[2], 10)
180499
+ fullIdentifier: `${projectPrefix.toUpperCase()}-${issueNumber}`,
180500
+ number: parseInt(issueNumber, 10)
180352
180501
  };
180353
180502
  }
180354
180503
  const numMatch = idStr.match(/^\d+$/);
@@ -181566,12 +181715,12 @@ var resolveBoard = (client, identifier2, options = {}) => Effect_exports.gen(fun
181566
181715
  board.class.Board,
181567
181716
  hulyQuery({ ...baseQuery, _id: toRef(identifier2) })
181568
181717
  );
181569
- if (idMatches.length > 0) return idMatches[0];
181718
+ if (isNonEmpty7(idMatches)) return idMatches[0];
181570
181719
  const nameMatches = yield* client.findAll(
181571
181720
  board.class.Board,
181572
181721
  hulyQuery({ ...baseQuery, name: identifier2 })
181573
181722
  );
181574
- if (nameMatches.length === 1) return nameMatches[0];
181723
+ if (isSingle2(nameMatches)) return nameMatches[0];
181575
181724
  if (nameMatches.length > 1) {
181576
181725
  return yield* new BoardIdentifierAmbiguousError({ identifier: identifier2, matches: nameMatches.length });
181577
181726
  }
@@ -181587,7 +181736,7 @@ var resolveBoardProjectType = (client, projectTypeRef) => Effect_exports.gen(fun
181587
181736
  const matches = projectTypeRef === void 0 ? projectTypes.filter(isBoardProjectType) : projectTypes.filter(
181588
181737
  (projectType) => isBoardProjectType(projectType) && (projectType._id === projectTypeRef || projectType.name === projectTypeRef)
181589
181738
  );
181590
- if (matches.length === 1) return matches[0];
181739
+ if (isSingle2(matches)) return matches[0];
181591
181740
  const identifier2 = projectTypeRef ?? String(board.descriptors.BoardType);
181592
181741
  if (matches.length === 0) return yield* new BoardProjectTypeNotFoundError({ identifier: identifier2 });
181593
181742
  return yield* new BoardProjectTypeIdentifierAmbiguousError({ identifier: identifier2, matches: matches.length });
@@ -181617,7 +181766,7 @@ var resolveBoardTaskType = (client, resolvedBoard, projectType, taskTypeRef) =>
181617
181766
  const taskTypes = yield* getBoardTaskTypes(client, projectType);
181618
181767
  const matches = taskTypeRef === void 0 ? taskTypes.filter(isBoardCardTaskType) : taskTypes.filter((taskType) => taskType._id === taskTypeRef || taskType.name === taskTypeRef);
181619
181768
  const fallbackMatches = taskTypeRef === void 0 && matches.length === 0 && taskTypes.length === 1 ? taskTypes : matches;
181620
- if (fallbackMatches.length === 1) return fallbackMatches[0];
181769
+ if (isSingle2(fallbackMatches)) return fallbackMatches[0];
181621
181770
  const identifier2 = taskTypeRef ?? "default board card task type";
181622
181771
  if (fallbackMatches.length === 0) {
181623
181772
  return yield* new BoardTaskTypeNotFoundError({ identifier: identifier2, board: resolvedBoard.name });
@@ -181646,7 +181795,7 @@ var getBoardWorkflowStatuses = (client, projectType, taskType) => Effect_exports
181646
181795
  var resolveBoardStatus = (client, resolvedBoard, projectType, taskType, statusRef) => Effect_exports.gen(function* () {
181647
181796
  const statuses = yield* getBoardWorkflowStatuses(client, projectType, taskType);
181648
181797
  const matches = statusRef === void 0 ? statuses.slice(0, 1) : statuses.filter((status) => status.id === statusRef || status.name === statusRef);
181649
- if (matches.length === 1) return matches[0];
181798
+ if (isSingle2(matches)) return matches[0];
181650
181799
  const identifier2 = statusRef ?? "default board card status";
181651
181800
  if (matches.length === 0) return yield* new BoardStatusNotFoundError({ identifier: identifier2, board: resolvedBoard.name });
181652
181801
  return yield* new BoardStatusIdentifierAmbiguousError({
@@ -181726,14 +181875,14 @@ var resolveBoardCard = (client, resolvedBoard, identifier2) => Effect_exports.ge
181726
181875
  board.class.Card,
181727
181876
  hulyQuery({ space, _id: toRef(identifier2) })
181728
181877
  );
181729
- if (idMatches.length > 0) return idMatches[0];
181878
+ if (isNonEmpty7(idMatches)) return idMatches[0];
181730
181879
  const number8 = boardCardNumber(identifier2);
181731
181880
  if (number8 !== void 0) {
181732
181881
  const numberMatches = yield* client.findAll(
181733
181882
  board.class.Card,
181734
181883
  hulyQuery({ space, number: number8 })
181735
181884
  );
181736
- if (numberMatches.length === 1) return numberMatches[0];
181885
+ if (isSingle2(numberMatches)) return numberMatches[0];
181737
181886
  if (numberMatches.length > 1) {
181738
181887
  return yield* new BoardCardIdentifierAmbiguousError({
181739
181888
  identifier: identifier2,
@@ -181746,7 +181895,7 @@ var resolveBoardCard = (client, resolvedBoard, identifier2) => Effect_exports.ge
181746
181895
  board.class.Card,
181747
181896
  hulyQuery({ space, title: identifier2 })
181748
181897
  );
181749
- if (titleMatches.length === 1) return titleMatches[0];
181898
+ if (isSingle2(titleMatches)) return titleMatches[0];
181750
181899
  if (titleMatches.length > 1) {
181751
181900
  return yield* new BoardCardIdentifierAmbiguousError({
181752
181901
  identifier: identifier2,
@@ -181867,8 +182016,9 @@ var createBoard = (params) => Effect_exports.gen(function* () {
181867
182016
  board.class.Board,
181868
182017
  hulyQuery({ name: params.name, archived: false })
181869
182018
  );
181870
- if (existing.length === 1) {
181871
- return { id: BoardId.make(existing[0]._id), name: BoardName.make(existing[0].name), created: false };
182019
+ if (isSingle2(existing)) {
182020
+ const boardDoc = existing[0];
182021
+ return { id: BoardId.make(boardDoc._id), name: BoardName.make(boardDoc.name), created: false };
181872
182022
  }
181873
182023
  if (existing.length > 1) {
181874
182024
  return yield* new BoardIdentifierAmbiguousError({ identifier: params.name, matches: existing.length });
@@ -182508,24 +182658,6 @@ var import_core29 = __toESM(require_lib5(), 1);
182508
182658
  var import_core28 = __toESM(require_lib5(), 1);
182509
182659
  var import_rank3 = __toESM(require_lib35(), 1);
182510
182660
  var import_time2 = __toESM(require_lib38(), 1);
182511
-
182512
- // src/utils/assertions.ts
182513
- var AssertionError = class extends Error {
182514
- _tag = "AssertionError";
182515
- constructor(message) {
182516
- super(message);
182517
- this.name = "AssertionError";
182518
- }
182519
- };
182520
- var assertExists = (value3, message) => {
182521
- if (value3 === null || value3 === void 0) {
182522
- throw new AssertionError(message ?? "Expected value to exist");
182523
- }
182524
- return value3;
182525
- };
182526
- var isExistent = (value3) => value3 !== null && value3 !== void 0;
182527
-
182528
- // src/huly/operations/planner-shared.ts
182529
182661
  var todoLookup = {
182530
182662
  user: contact.class.Person,
182531
182663
  attachedTo: tracker.class.Issue
@@ -182684,7 +182816,7 @@ var findTodo = (client, locator, defaultCompletionState = "open") => Effect_expo
182684
182816
  if (todos.length > 1) {
182685
182817
  return yield* new TodoIdentifierAmbiguousError({ locator: describeLocator(locator), matches: todos.length });
182686
182818
  }
182687
- return todos[0];
182819
+ return assertAt(todos, 0);
182688
182820
  });
182689
182821
  var todoOwnerSummary = (todo, emailByPersonId) => {
182690
182822
  const ownerId = toRef(todo.user);
@@ -182700,11 +182832,14 @@ var todoAttachmentSummary = (todo) => {
182700
182832
  if (todo.attachedTo === time.ids.NotAttached) return { type: "none" };
182701
182833
  const issue2 = todo.$lookup?.attachedTo;
182702
182834
  if (todo.attachedToClass === tracker.class.Issue && issue2 !== void 0) {
182835
+ const identifier2 = IssueIdentifier.make(issue2.identifier);
182836
+ const segments = identifier2.split("-");
182837
+ const project3 = assertAt(segments, 0);
182703
182838
  return {
182704
182839
  type: "issue",
182705
182840
  id: IssueId.make(issue2._id),
182706
- project: ProjectIdentifier.make(IssueIdentifier.make(issue2.identifier).split("-")[0]),
182707
- identifier: IssueIdentifier.make(issue2.identifier),
182841
+ project: ProjectIdentifier.make(project3),
182842
+ identifier: identifier2,
182708
182843
  title: attachmentTitleOrFallback(issue2.title, issue2.identifier)
182709
182844
  };
182710
182845
  }
@@ -183381,7 +183516,7 @@ var HULY_MODEL_ID_SEPARATOR = ":";
183381
183516
  var FINAL_SEGMENT_OFFSET = 1;
183382
183517
  var hulyModelLabelTail = (value3) => {
183383
183518
  const segments = value3.split(HULY_MODEL_ID_SEPARATOR);
183384
- return segments[segments.length - FINAL_SEGMENT_OFFSET];
183519
+ return assertAt(segments, segments.length - FINAL_SEGMENT_OFFSET);
183385
183520
  };
183386
183521
  var decodeHulyModelLabelTail = (value3) => Either_exports.flatMap(
183387
183522
  Schema_exports.decodeUnknownEither(Schema_exports.String)(value3),
@@ -183827,6 +183962,9 @@ var collectDescendants = (rootIds, descendantsByAncestor) => {
183827
183962
  let nextIndex = 0;
183828
183963
  while (nextIndex < pending3.length) {
183829
183964
  const current = pending3[nextIndex];
183965
+ if (current === void 0) {
183966
+ break;
183967
+ }
183830
183968
  const unvisitedChildren = [...descendantsByAncestor.get(current) ?? []].filter((childId) => !visited.has(childId));
183831
183969
  unvisitedChildren.forEach((childId) => {
183832
183970
  visited.add(childId);
@@ -185357,6 +185495,28 @@ var commentTools = [
185357
185495
  }
185358
185496
  ];
185359
185497
 
185498
+ // src/huly/operations/contact-channel-locators.ts
185499
+ var channelIdentifier = (locator) => locator._tag === "channelId" ? locator.channelId : `${locator.provider}:${locator.value}`;
185500
+ var INVALID_CHANNEL_LOCATOR_REASON = "provide exactly one channel locator: channelId, or provider plus value";
185501
+ var validateProviderValue = (provider, value3) => value3.length === 0 || provider === "email" && !Schema_exports.is(Email)(value3) ? Effect_exports.fail(new InvalidContactChannelValueError({ provider, value: value3 })) : Effect_exports.void;
185502
+ var validateChannelLocator2 = (ownerIdentifier, locator) => Effect_exports.gen(function* () {
185503
+ const hasChannelId = locator.channelId !== void 0;
185504
+ const hasProvider = locator.provider !== void 0;
185505
+ const hasValue = locator.value !== void 0;
185506
+ if (hasChannelId && !hasProvider && !hasValue) {
185507
+ return { _tag: "channelId", channelId: ChannelId.make(locator.channelId) };
185508
+ }
185509
+ if (!hasChannelId && hasProvider && hasValue) {
185510
+ yield* validateProviderValue(locator.provider, locator.value);
185511
+ return { _tag: "providerValue", provider: locator.provider, value: locator.value };
185512
+ }
185513
+ return yield* new InvalidContactChannelLocatorError({
185514
+ ownerIdentifier,
185515
+ reason: INVALID_CHANNEL_LOCATOR_REASON
185516
+ });
185517
+ });
185518
+ var requireChannelUpdateFields = (params) => params.newProvider === void 0 && params.newValue === void 0 ? Effect_exports.fail(new NoUpdateFieldsError({ operation: "update_contact_channel", fields: ["newProvider", "newValue"] })) : Effect_exports.void;
185519
+
185360
185520
  // src/huly/operations/contact-channel-providers.ts
185361
185521
  var CONTACT_CHANNEL_PROVIDER_SDK_KEYS = ContactChannelProviderSdkKeys;
185362
185522
  var exactChannelProviderSdkKeys = (value3) => value3;
@@ -185401,13 +185561,11 @@ var channelSummaryWithValue = (channel, provider, value3) => ({
185401
185561
 
185402
185562
  // src/huly/operations/organization-resolvers.ts
185403
185563
  var findOrganizationByIdentifier = (client, identifier2) => Effect_exports.gen(function* () {
185404
- const byId = Option_exports.fromNullable(
185405
- yield* client.findOne(
185406
- contact.class.Organization,
185407
- hulyQuery({ _id: toRef(identifier2) })
185408
- )
185564
+ const byId = yield* client.findOne(
185565
+ contact.class.Organization,
185566
+ hulyQuery({ _id: toRef(identifier2) })
185409
185567
  );
185410
- if (Option_exports.isSome(byId)) return byId;
185568
+ if (byId !== void 0) return Option_exports.some(byId);
185411
185569
  const byName = yield* client.findAll(
185412
185570
  contact.class.Organization,
185413
185571
  hulyQuery({ name: identifier2 })
@@ -185419,7 +185577,8 @@ var findOrganizationByIdentifier = (client, identifier2) => Effect_exports.gen(f
185419
185577
  matches: Count.make(byName.length)
185420
185578
  });
185421
185579
  }
185422
- return Option_exports.some(byName[0]);
185580
+ if (isSingle2(byName)) return Option_exports.some(byName[0]);
185581
+ return Option_exports.none();
185423
185582
  });
185424
185583
  var resolveOrganizationByIdentifier = (client, identifier2) => Effect_exports.flatMap(findOrganizationByIdentifier(client, identifier2), (organization) => Option_exports.match(organization, {
185425
185584
  onNone: () => Effect_exports.fail(new OrganizationNotFoundError({ identifier: identifier2 })),
@@ -185456,28 +185615,7 @@ var resolveOrganizationOwner = (client, identifier2) => Effect_exports.gen(funct
185456
185615
  return { id: org._id, ownerClass: contact.class.Organization, identifier: identifier2 };
185457
185616
  });
185458
185617
 
185459
- // src/huly/operations/contact-channels.ts
185460
- var listContactChannelProviders = () => Effect_exports.succeed(listContactChannelProviderLabels());
185461
- var channelIdentifier = (locator) => locator._tag === "channelId" ? locator.channelId : `${locator.provider}:${locator.value}`;
185462
- var INVALID_CHANNEL_LOCATOR_REASON = "provide exactly one channel locator: channelId, or provider plus value";
185463
- var validateProviderValue = (provider, value3) => value3.length === 0 || provider === "email" && !Schema_exports.is(Email)(value3) ? Effect_exports.fail(new InvalidContactChannelValueError({ provider, value: value3 })) : Effect_exports.void;
185464
- var validateChannelLocator2 = (ownerIdentifier, locator) => Effect_exports.gen(function* () {
185465
- const hasChannelId = locator.channelId !== void 0;
185466
- const hasProvider = locator.provider !== void 0;
185467
- const hasValue = locator.value !== void 0;
185468
- if (hasChannelId && !hasProvider && !hasValue) {
185469
- return { _tag: "channelId", channelId: ChannelId.make(locator.channelId) };
185470
- }
185471
- if (!hasChannelId && hasProvider && hasValue) {
185472
- yield* validateProviderValue(locator.provider, locator.value);
185473
- return { _tag: "providerValue", provider: locator.provider, value: locator.value };
185474
- }
185475
- return yield* new InvalidContactChannelLocatorError({
185476
- ownerIdentifier,
185477
- reason: INVALID_CHANNEL_LOCATOR_REASON
185478
- });
185479
- });
185480
- var requireChannelUpdateFields = (params) => params.newProvider === void 0 && params.newValue === void 0 ? Effect_exports.fail(new NoUpdateFieldsError({ operation: "update_contact_channel", fields: ["newProvider", "newValue"] })) : Effect_exports.void;
185618
+ // src/huly/operations/contact-channel-queries.ts
185481
185619
  var findChannelsForOwner = (client, owner) => client.findAll(
185482
185620
  contact.class.Channel,
185483
185621
  hulyQuery({
@@ -185505,6 +185643,9 @@ var findChannelByIdForOwner = (client, owner, channelId) => Effect_exports.map(
185505
185643
  ),
185506
185644
  Option_exports.fromNullable
185507
185645
  );
185646
+
185647
+ // src/huly/operations/contact-channels.ts
185648
+ var listContactChannelProviders = () => Effect_exports.succeed(listContactChannelProviderLabels());
185508
185649
  var resolveChannelByLocator = (client, owner, locator) => Effect_exports.gen(function* () {
185509
185650
  if (locator._tag === "channelId") {
185510
185651
  return yield* Effect_exports.flatMap(findChannelByIdForOwner(client, owner, locator.channelId), (channel) => Option_exports.match(channel, {
@@ -185531,7 +185672,7 @@ var resolveChannelByLocator = (client, owner, locator) => Effect_exports.gen(fun
185531
185672
  matches: Count.make(matches.length)
185532
185673
  });
185533
185674
  }
185534
- return matches[0];
185675
+ return assertAt(matches, 0);
185535
185676
  });
185536
185677
  var findRemovableChannel = (client, owner, locator) => Effect_exports.gen(function* () {
185537
185678
  if (locator._tag === "channelId") {
@@ -185565,7 +185706,7 @@ var listOwnerChannels = (client, owner) => Effect_exports.gen(function* () {
185565
185706
  var addOwnerChannel = (client, owner, params) => Effect_exports.gen(function* () {
185566
185707
  yield* validateProviderValue(params.provider, params.value);
185567
185708
  const existing = yield* findExactChannels(client, owner, params.provider, params.value);
185568
- if (existing.length > 0) {
185709
+ if (isNonEmpty7(existing)) {
185569
185710
  return { added: false, channel: yield* channelSummary(existing[0]) };
185570
185711
  }
185571
185712
  const channelId = yield* client.addCollection(
@@ -185932,8 +186073,9 @@ var formatName = (firstName, lastName) => `${lastName},${firstName}`;
185932
186073
  var parseName = (name) => {
185933
186074
  const parts2 = name.split(",");
185934
186075
  const FIRST_LAST_PARTS = 2;
185935
- if (parts2.length >= FIRST_LAST_PARTS) {
185936
- return { lastName: parts2[0], firstName: parts2.slice(1).join(",") };
186076
+ const [lastName, ...firstNameParts] = parts2;
186077
+ if (lastName !== void 0 && parts2.length >= FIRST_LAST_PARTS) {
186078
+ return { lastName, firstName: firstNameParts.join(",") };
185937
186079
  }
185938
186080
  return { firstName: name, lastName: "" };
185939
186081
  };
@@ -187056,7 +187198,7 @@ var findSnapshotByIdentifier = (client, doc, identifier2) => Effect_exports.gen(
187056
187198
  hulyQuery({ attachedTo: doc._id, title: identifier2 }),
187057
187199
  { limit: 2 }
187058
187200
  );
187059
- if (titleMatches.length === 1) return titleMatches[0];
187201
+ if (isSingle2(titleMatches)) return titleMatches[0];
187060
187202
  if (titleMatches.length > 1) {
187061
187203
  return yield* new HulyError({
187062
187204
  message: `Multiple snapshots on document '${doc.title}' have title '${identifier2}'. Use the snapshotId from list_document_snapshots.`
@@ -187068,7 +187210,7 @@ var findSnapshotByIdentifier = (client, doc, identifier2) => Effect_exports.gen(
187068
187210
  hulyQuery({ attachedTo: doc._id, createdOn }),
187069
187211
  { limit: 2 }
187070
187212
  ) : [];
187071
- if (dateMatches.length === 1) return dateMatches[0];
187213
+ if (isSingle2(dateMatches)) return dateMatches[0];
187072
187214
  if (dateMatches.length > 1) {
187073
187215
  return yield* new HulyError({
187074
187216
  message: `Multiple snapshots on document '${doc.title}' have createdOn '${identifier2}'. Use the snapshotId from list_document_snapshots.`
@@ -187389,7 +187531,7 @@ var resolveDrive = (client, identifier2) => Effect_exports.gen(function* () {
187389
187531
  );
187390
187532
  if (byId !== void 0) return byId;
187391
187533
  const byName = yield* client.findAll(drive.class.Drive, hulyQuery({ name: identifier2 }));
187392
- if (byName.length === 1) return byName[0];
187534
+ if (isSingle2(byName)) return byName[0];
187393
187535
  if (byName.length > 1) {
187394
187536
  return yield* Effect_exports.fail(
187395
187537
  new DriveIdentifierAmbiguousError({
@@ -187426,10 +187568,16 @@ var resolvePath = (client, driveSpace, path2) => Effect_exports.gen(function* ()
187426
187568
  })
187427
187569
  );
187428
187570
  }
187429
- current = candidates[0];
187430
- currentPath = childPath(currentPath, current.title);
187571
+ if (!isSingle2(candidates)) {
187572
+ return yield* Effect_exports.fail(
187573
+ new DrivePathNotFoundError({ drive: driveSpace.name, path: childPath(currentPath, segment) })
187574
+ );
187575
+ }
187576
+ const currentItem = candidates[0];
187577
+ current = currentItem;
187578
+ currentPath = childPath(currentPath, currentItem.title);
187431
187579
  if (segment !== lastSegment) {
187432
- if (!isFolder(current)) {
187580
+ if (!isFolder(currentItem)) {
187433
187581
  return yield* Effect_exports.fail(
187434
187582
  new DriveParentNotFolderError({
187435
187583
  drive: driveSpace.name,
@@ -187438,7 +187586,7 @@ var resolvePath = (client, driveSpace, path2) => Effect_exports.gen(function* ()
187438
187586
  })
187439
187587
  );
187440
187588
  }
187441
- parent = current._id;
187589
+ parent = currentItem._id;
187442
187590
  }
187443
187591
  }
187444
187592
  return { item: current, path: currentPath };
@@ -187524,7 +187672,7 @@ var ensureFolderPath = (client, driveSpace, driveIdentifier, path2) => Effect_ex
187524
187672
  })
187525
187673
  );
187526
187674
  }
187527
- if (matches.length === 1) {
187675
+ if (isSingle2(matches)) {
187528
187676
  const existing = matches[0];
187529
187677
  if (!isFolder(existing)) {
187530
187678
  return yield* Effect_exports.fail(
@@ -188224,17 +188372,22 @@ var uploadDriveFile = (params) => Effect_exports.gen(function* () {
188224
188372
  const storage = yield* HulyStorageClient;
188225
188373
  const driveSpace = yield* resolveDrive(client, params.drive);
188226
188374
  const normalized = normalizeDrivePath(params.path);
188227
- if (normalized.segments.length === 0) {
188375
+ if (!isNonEmpty7(normalized.segments)) {
188376
+ return yield* Effect_exports.fail(
188377
+ new DrivePathConflictError({ drive: params.drive, path: normalized.path, existingKind: "folder" })
188378
+ );
188379
+ }
188380
+ const title = normalized.segments.at(-1);
188381
+ if (title === void 0) {
188228
188382
  return yield* Effect_exports.fail(
188229
188383
  new DrivePathConflictError({ drive: params.drive, path: normalized.path, existingKind: "folder" })
188230
188384
  );
188231
188385
  }
188232
- const title = normalized.segments[normalized.segments.length - 1];
188233
188386
  const parentPath = parentPathOf(normalized);
188234
188387
  const createParents = params.createParents ?? DEFAULT_DRIVE_CREATE_PARENTS;
188235
188388
  const parent = createParents ? yield* ensureFolderPath(client, driveSpace, params.drive, parentPath) : yield* resolveExistingParentFolder(client, driveSpace, params.drive, normalized, parentPath);
188236
188389
  const existing = yield* findChildrenByTitle(client, driveSpace, parent.folder?._id ?? drive.ids.Root, title);
188237
- if (existing.length > 0) {
188390
+ if (isNonEmpty7(existing)) {
188238
188391
  const existingItem = existing[0];
188239
188392
  return yield* Effect_exports.fail(
188240
188393
  new DrivePathConflictError({
@@ -188782,14 +188935,15 @@ var resolveAssociation = (client, identifier2, filters) => Effect_exports.gen(fu
188782
188935
  )
188783
188936
  );
188784
188937
  const rolePair = identifier2.split(" -> ");
188785
- if (rolePair.length === 2) {
188938
+ if (isPair(rolePair)) {
188939
+ const [nameA, nameB] = rolePair;
188786
188940
  addCandidates(
188787
188941
  yield* client.findAll(
188788
188942
  core.class.Association,
188789
188943
  hulyQuery({
188790
188944
  ...associationClassFilterQuery(filters),
188791
- nameA: rolePair[0],
188792
- nameB: rolePair[1]
188945
+ nameA,
188946
+ nameB
188793
188947
  }),
188794
188948
  { limit: ASSOCIATION_LOOKUP_AMBIGUITY_LIMIT }
188795
188949
  )
@@ -188805,7 +188959,7 @@ var resolveAssociation = (client, identifier2, filters) => Effect_exports.gen(fu
188805
188959
  candidates: candidates.map(toCandidate)
188806
188960
  });
188807
188961
  }
188808
- return candidates[0];
188962
+ return assertAt(candidates, 0);
188809
188963
  });
188810
188964
  var rejectSystemClass = (className, operation) => isSystemClassName(String(className)) ? Effect_exports.fail(new AssociationSystemClassUnsupportedError({ className, operation })) : Effect_exports.void;
188811
188965
  var systemClassInAssociation = (association) => {
@@ -189084,7 +189238,8 @@ var resolveIssueLocator = (locator, field) => Effect_exports.gen(function* () {
189084
189238
  }
189085
189239
  const match16 = String(locator.issue).match(/^([A-Z]+)-\d+$/i);
189086
189240
  if (match16 !== null) {
189087
- const { client, project: project3 } = yield* findProject(match16[1].toUpperCase());
189241
+ const projectIdentifier = assertAt(match16, 1);
189242
+ const { client, project: project3 } = yield* findProject(projectIdentifier.toUpperCase());
189088
189243
  const issue2 = yield* findIssueInProject(client, project3, locator.issue);
189089
189244
  return resolvedSummary(issue2, "issue");
189090
189245
  }
@@ -189124,7 +189279,7 @@ var resolveDocumentWithoutTeamspace = (client, identifier2, field) => Effect_exp
189124
189279
  }))
189125
189280
  });
189126
189281
  }
189127
- return resolvedSummary(byTitle[0], "document");
189282
+ return resolvedSummary(assertAt(byTitle, 0), "document");
189128
189283
  });
189129
189284
  var findCardById = (client, identifier2) => client.findOne(
189130
189285
  cardPlugin.class.Card,
@@ -189161,7 +189316,7 @@ var findCardSpace2 = (client, identifier2, field) => Effect_exports.gen(function
189161
189316
  }))
189162
189317
  });
189163
189318
  }
189164
- return byName[0];
189319
+ return assertAt(byName, 0);
189165
189320
  });
189166
189321
  var resolveCardInSpace = (client, identifier2, cardSpace, field) => Effect_exports.gen(function* () {
189167
189322
  const byId = yield* client.findOne(
@@ -189194,7 +189349,7 @@ var resolveCardInSpace = (client, identifier2, cardSpace, field) => Effect_expor
189194
189349
  }))
189195
189350
  });
189196
189351
  }
189197
- return resolvedSummary(byTitle[0], "card");
189352
+ return resolvedSummary(assertAt(byTitle, 0), "card");
189198
189353
  });
189199
189354
  var resolveCardLocator = (client, locator, field) => Effect_exports.gen(function* () {
189200
189355
  if (locator.cardSpace !== void 0) {
@@ -189673,12 +189828,20 @@ var deleteRelation = (params) => Effect_exports.gen(function* () {
189673
189828
  if (matches.length > 1) {
189674
189829
  return yield* new RelationIdentifierAmbiguousError({
189675
189830
  identifier: `${params.association}/${endpoints.docA.id}/${endpoints.docB.id}`,
189676
- relationIds: matches.map((relation) => RelationId.make(relation._id))
189831
+ relationIds: matches.map((relation2) => RelationId.make(relation2._id))
189677
189832
  });
189678
189833
  }
189679
- yield* client.removeDoc(core.class.Relation, matches[0].space, matches[0]._id);
189834
+ if (!isSingle2(matches)) {
189835
+ return {
189836
+ associationId: AssociationId.make(association._id),
189837
+ deleted: false,
189838
+ reason: "not_found"
189839
+ };
189840
+ }
189841
+ const relation = matches[0];
189842
+ yield* client.removeDoc(core.class.Relation, relation.space, relation._id);
189680
189843
  return {
189681
- relationId: RelationId.make(matches[0]._id),
189844
+ relationId: RelationId.make(relation._id),
189682
189845
  associationId: AssociationId.make(association._id),
189683
189846
  deleted: true,
189684
189847
  reason: "deleted"
@@ -190543,7 +190706,7 @@ var resolveCategory = (client, identifier2, parentIdentifier) => Effect_exports.
190543
190706
  (parent) => ({ name: identifier2, attachedTo: parent.id })
190544
190707
  );
190545
190708
  const matches = yield* findAllCategories(client, query);
190546
- if (matches.length === 1) return matches[0];
190709
+ if (isSingle2(matches)) return matches[0];
190547
190710
  if (matches.length > 1) {
190548
190711
  return yield* new InventoryCategoryIdentifierAmbiguousError({ identifier: identifier2, matches: matches.length });
190549
190712
  }
@@ -190560,7 +190723,7 @@ var resolveProduct = (client, identifier2, categoryIdentifier) => Effect_exports
190560
190723
  (category) => ({ name: identifier2, attachedTo: category._id })
190561
190724
  );
190562
190725
  const matches = yield* findAllProducts(client, query);
190563
- if (matches.length === 1) return matches[0];
190726
+ if (isSingle2(matches)) return matches[0];
190564
190727
  if (matches.length > 1) {
190565
190728
  return yield* new InventoryProductIdentifierAmbiguousError({ identifier: identifier2, matches: matches.length });
190566
190729
  }
@@ -190578,7 +190741,7 @@ var resolveVariant = (client, identifier2, productIdentifier, categoryIdentifier
190578
190741
  );
190579
190742
  const candidates = yield* findAllVariants(client, query);
190580
190743
  const matches = candidates.filter((variant) => variant.name === identifier2 || variant.sku === identifier2);
190581
- if (matches.length === 1) return matches[0];
190744
+ if (isSingle2(matches)) return matches[0];
190582
190745
  if (matches.length > 1) {
190583
190746
  return yield* new InventoryVariantIdentifierAmbiguousError({ identifier: identifier2, matches: matches.length });
190584
190747
  }
@@ -191616,7 +191779,7 @@ var blockingIssueFindOptions = {
191616
191779
  var resolveTargetIssue = (client, sourceProject, targetIssueStr) => Effect_exports.gen(function* () {
191617
191780
  const { fullIdentifier } = parseIssueIdentifier(targetIssueStr, sourceProject.identifier);
191618
191781
  const match16 = fullIdentifier.match(/^([A-Z]+)-\d+$/i);
191619
- const prefix = match16 ? match16[1].toUpperCase() : null;
191782
+ const prefix = match16?.[1]?.toUpperCase() ?? null;
191620
191783
  if (prefix !== null && prefix !== sourceProject.identifier.toUpperCase()) {
191621
191784
  const { client: c, project: targetProject } = yield* findProject(prefix);
191622
191785
  const issue3 = yield* findIssueInProject(c, targetProject, targetIssueStr);
@@ -193004,7 +193167,7 @@ var removeTemplateChild = (params) => Effect_exports.gen(function* () {
193004
193167
  project: params.project
193005
193168
  });
193006
193169
  }
193007
- const removedChild = template.children[childIndex];
193170
+ const removedChild = assertAt(template.children, childIndex);
193008
193171
  const newChildren = template.children.filter((_, i) => i !== childIndex);
193009
193172
  yield* client.updateDoc(
193010
193173
  tracker.class.IssueTemplate,
@@ -193865,7 +194028,10 @@ var categorySummaryFor = (category) => ({
193865
194028
  });
193866
194029
  var placeholderFieldIds = (markdown) => {
193867
194030
  const regexp = new RegExp(import_templates.templateFieldRegexp.source, import_templates.templateFieldRegexp.flags);
193868
- const ids3 = [...markdown.matchAll(regexp)].map((match16) => match16[1]).filter((id, index, allIds) => id.length > 0 && allIds.indexOf(id) === index);
194031
+ const ids3 = [...markdown.matchAll(regexp)].flatMap((match16) => {
194032
+ const id = assertAt(match16, 1);
194033
+ return [id];
194034
+ }).filter((id, index, allIds) => id.length > 0 && allIds.indexOf(id) === index);
193869
194035
  return ids3.map((id) => TemplateFieldId.make(id));
193870
194036
  };
193871
194037
  var markdownForTemplate = (template, client) => MessageTemplateMarkdown.make(markupToMarkdownString(template.message, client.markupUrlConfig));
@@ -193913,7 +194079,7 @@ var resolveCategory2 = (client, identifier2) => Effect_exports.gen(function* ()
193913
194079
  matches: Count.make(matches.length)
193914
194080
  });
193915
194081
  }
193916
- return matches[0];
194082
+ return assertAt(matches, 0);
193917
194083
  });
193918
194084
  var categoryMapFor = (client, categoryIds) => Effect_exports.gen(function* () {
193919
194085
  const diagnostics = yield* Diagnostics;
@@ -193986,7 +194152,7 @@ var resolveTemplate = (client, params) => Effect_exports.gen(function* () {
193986
194152
  matches: Count.make(matches.length)
193987
194153
  });
193988
194154
  }
193989
- return matches[0];
194155
+ return assertAt(matches, 0);
193990
194156
  });
193991
194157
  var resolveFieldCategory = (client, identifier2) => Effect_exports.gen(function* () {
193992
194158
  const byId = yield* client.findOne(
@@ -194008,7 +194174,7 @@ var resolveFieldCategory = (client, identifier2) => Effect_exports.gen(function*
194008
194174
  matches: Count.make(matches.length)
194009
194175
  });
194010
194176
  }
194011
- return matches[0];
194177
+ return assertAt(matches, 0);
194012
194178
  });
194013
194179
  var fieldCategoryMapFor = (client, categoryIds) => Effect_exports.gen(function* () {
194014
194180
  const diagnostics = yield* Diagnostics;
@@ -195257,14 +195423,17 @@ var getTimeReport = (params) => Effect_exports.gen(function* () {
195257
195423
  { _id: { $in: employeeIds } }
195258
195424
  ) : [];
195259
195425
  const personMap = new Map(persons.map((p) => [p._id, p.name]));
195260
- const timeReports = reports.map((r) => ({
195261
- id: TimeSpendReportId.make(r._id),
195262
- identifier: IssueIdentifier.make(issue2.identifier),
195263
- employee: r.employee && personMap.has(r.employee) ? PersonName.make(personMap.get(r.employee)) : void 0,
195264
- date: r.date,
195265
- value: r.value,
195266
- description: r.description
195267
- }));
195426
+ const timeReports = reports.map((r) => {
195427
+ const employeeName = r.employee == null ? void 0 : personMap.get(r.employee);
195428
+ return {
195429
+ id: TimeSpendReportId.make(r._id),
195430
+ identifier: IssueIdentifier.make(issue2.identifier),
195431
+ employee: employeeName === void 0 ? void 0 : PersonName.make(employeeName),
195432
+ date: r.date,
195433
+ value: r.value,
195434
+ description: r.description
195435
+ };
195436
+ });
195268
195437
  return {
195269
195438
  identifier: IssueIdentifier.make(issue2.identifier),
195270
195439
  totalTime: issue2.reportedTime,
@@ -195386,7 +195555,7 @@ var listWorkSlots = (params) => Effect_exports.gen(function* () {
195386
195555
  contact.class.Channel,
195387
195556
  { value: params.employeeId }
195388
195557
  );
195389
- if (channels.length > 0) {
195558
+ if (isNonEmpty7(channels)) {
195390
195559
  const channel = channels[0];
195391
195560
  query.user = refAsPersonId(channel.attachedTo);
195392
195561
  }
@@ -195895,7 +196064,7 @@ var resolveProcess = (client, identifier2) => Effect_exports.gen(function* () {
195895
196064
  const matches = [...allProcesses].filter(
195896
196065
  (process4) => normalizeForComparison(process4.name) === normalizeForComparison(identifier2)
195897
196066
  );
195898
- if (matches.length === 1) return matches[0];
196067
+ if (isSingle2(matches)) return matches[0];
195899
196068
  const data = yield* loadProcessDefinitionData(client, matches.length === 0 ? [...allProcesses] : matches);
195900
196069
  const candidates = data.map(processCandidate);
195901
196070
  return yield* matches.length === 0 ? Effect_exports.fail(new ProcessNotFoundError({ identifier: identifier2, candidates })) : Effect_exports.fail(new ProcessIdentifierAmbiguousError({ identifier: identifier2, candidates }));
@@ -195911,7 +196080,7 @@ var resolveMasterTag = (client, identifier2) => Effect_exports.gen(function* ()
195911
196080
  const matches = allTags.filter(
195912
196081
  (tag2) => normalizeForComparison(masterTagLabel(tag2) ?? "") === normalizeForComparison(identifier2)
195913
196082
  );
195914
- if (matches.length === 1) return matches[0]._id;
196083
+ if (isSingle2(matches)) return matches[0]._id;
195915
196084
  if (matches.length === 0) {
195916
196085
  return yield* looksLikeMasterTagId(identifier2) ? Effect_exports.succeed(toRef(identifier2)) : Effect_exports.fail(new ProcessMasterTagNotFoundError({ identifier: identifier2 }));
195917
196086
  }
@@ -195929,7 +196098,7 @@ var resolveCardFilter = (client, identifier2) => Effect_exports.gen(function* ()
195929
196098
  const byId = yield* client.findOne(cardPlugin.class.Card, { _id: toRef(identifier2) });
195930
196099
  if (byId !== void 0) return byId._id;
195931
196100
  const byTitle = yield* client.findAll(cardPlugin.class.Card, { title: identifier2 });
195932
- if (byTitle.length === 1) return byTitle[0]._id;
196101
+ if (isSingle2(byTitle)) return byTitle[0]._id;
195933
196102
  if (byTitle.length > 1) {
195934
196103
  return yield* Effect_exports.fail(
195935
196104
  new ProcessCardIdentifierAmbiguousError({
@@ -196006,8 +196175,8 @@ var listProcesses = (params) => Effect_exports.gen(function* () {
196006
196175
  var getProcess = (params) => Effect_exports.gen(function* () {
196007
196176
  const client = yield* HulyClient;
196008
196177
  const process4 = yield* resolveProcess(client, params.process);
196009
- const [data] = yield* loadProcessDefinitionData(client, [process4]);
196010
- const [states, transitions] = yield* Effect_exports.all([
196178
+ const [masterTags, states, transitions] = yield* Effect_exports.all([
196179
+ findMasterTagsByIds(client, [process4.masterTag]),
196011
196180
  client.findAll(
196012
196181
  processPlugin.class.State,
196013
196182
  { process: process4._id },
@@ -196019,7 +196188,14 @@ var getProcess = (params) => Effect_exports.gen(function* () {
196019
196188
  { sort: { rank: import_core66.SortingOrder.Ascending } }
196020
196189
  )
196021
196190
  ]);
196022
- const result = processDetail({ ...data, states: [...states], transitions: [...transitions] });
196191
+ const result = processDetail({
196192
+ process: process4,
196193
+ masterTagName: masterTags.get(process4.masterTag)?.name,
196194
+ stateCount: states.length,
196195
+ transitionCount: transitions.length,
196196
+ states: [...states],
196197
+ transitions: [...transitions]
196198
+ });
196023
196199
  return yield* encodeOrConnectionError(ProcessDetailSchema, result, "getProcess");
196024
196200
  });
196025
196201
  var listExecutions = (params) => Effect_exports.gen(function* () {
@@ -196794,7 +196970,7 @@ var resolveVacancy = (client, identifier2) => Effect_exports.gen(function* () {
196794
196970
  matches: Count.make(byName.length)
196795
196971
  });
196796
196972
  }
196797
- return byName[0];
196973
+ return assertAt(byName, 0);
196798
196974
  });
196799
196975
  var findApplicant = (client, applicantIdentifier, vacancy, candidate) => Effect_exports.gen(function* () {
196800
196976
  const byId = yield* client.findOne(
@@ -196823,7 +196999,7 @@ var findApplicant = (client, applicantIdentifier, vacancy, candidate) => Effect_
196823
196999
  matches: Count.make(applicants.length)
196824
197000
  });
196825
197001
  }
196826
- return applicants[0];
197002
+ return assertAt(applicants, 0);
196827
197003
  });
196828
197004
  var applicantRefFromDoc = (client, applicant) => Effect_exports.gen(function* () {
196829
197005
  const vacancy = yield* client.findOne(recruitIds.class.Vacancy, { _id: applicant.space });
@@ -197520,7 +197696,7 @@ var findReview = (client, identifier2, candidate, application) => Effect_exports
197520
197696
  if (reviews.length > 1) {
197521
197697
  return yield* new RecruitingReviewIdentifierAmbiguousError({ identifier: identifier2, matches: Count.make(reviews.length) });
197522
197698
  }
197523
- return reviews[0];
197699
+ return assertAt(reviews, 0);
197524
197700
  });
197525
197701
  var resolveReviewLocator = (client, params) => Effect_exports.gen(function* () {
197526
197702
  const candidate = yield* optionalCandidate(client, params.candidate);
@@ -197700,7 +197876,7 @@ var findOpinion = (client, identifier2, review) => Effect_exports.gen(function*
197700
197876
  if (opinions.length > 1) {
197701
197877
  return yield* new RecruitingOpinionIdentifierAmbiguousError({ identifier: identifier2, matches: Count.make(opinions.length) });
197702
197878
  }
197703
- return opinions[0];
197879
+ return assertAt(opinions, 0);
197704
197880
  });
197705
197881
  var resolveReview = (client, review) => review === void 0 ? Effect_exports.succeed(void 0) : findReview(client, review);
197706
197882
  var parentReviewFromOpinion = (client, opinion) => findReview(client, ReviewIdentifier.make(String(opinion.attachedTo)));
@@ -198253,7 +198429,14 @@ var resolveRelatedIssue = (params) => Effect_exports.gen(function* () {
198253
198429
  reason: "issue locator without project must use a full project-prefixed identifier like HULY-123"
198254
198430
  });
198255
198431
  }
198256
- const { client, project: project3 } = yield* findProject(match16[1].toUpperCase());
198432
+ const [, projectIdentifier] = match16;
198433
+ if (projectIdentifier === void 0) {
198434
+ return yield* new RecruitingIssueLocatorInvalidError({
198435
+ issue: params.issue,
198436
+ reason: "issue locator without project must use a full project-prefixed identifier like HULY-123"
198437
+ });
198438
+ }
198439
+ const { client, project: project3 } = yield* findProject(projectIdentifier.toUpperCase());
198257
198440
  const issue2 = yield* findIssueInProject(client, project3, params.issue);
198258
198441
  return { client, issue: issue2, project: project3 };
198259
198442
  });
@@ -199026,7 +199209,8 @@ var findSpaceType = (client, identifier2) => Effect_exports.gen(function* () {
199026
199209
  }))
199027
199210
  });
199028
199211
  }
199029
- return byName[0];
199212
+ if (isSingle2(byName)) return byName[0];
199213
+ return yield* new SpaceTypeNotFoundError({ identifier: NonEmptyString2.make(identifier2) });
199030
199214
  });
199031
199215
  var permissionsByIds = (client, permissionIds) => Effect_exports.gen(function* () {
199032
199216
  const uniqueIds = sortStrings([...new Set(permissionIds)]);
@@ -199650,7 +199834,7 @@ var resolveSpaceRole = (client, spaceType, role) => Effect_exports.gen(function*
199650
199834
  }))
199651
199835
  });
199652
199836
  }
199653
- return matches[0];
199837
+ return assertAt(matches, 0);
199654
199838
  });
199655
199839
  var findSpaceTypeRoles = (client, spaceType) => client.findAll(
199656
199840
  roleClass,
@@ -200239,7 +200423,7 @@ var resolveProjectType = (client, projectTypeRef) => Effect_exports.gen(function
200239
200423
  const selected = projectTypeRef === void 0 ? projectTypes.filter(isDefaultClassicProjectType) : projectTypes.filter(
200240
200424
  (projectType) => projectType._id === projectTypeRef || normalizeForComparison(projectType.name) === normalizeForComparison(projectTypeRef)
200241
200425
  );
200242
- if (selected.length === 1) {
200426
+ if (isSingle2(selected)) {
200243
200427
  return selected[0];
200244
200428
  }
200245
200429
  const message = projectTypeRef === void 0 ? "Could not select a default Classic project type unambiguously; pass projectType by ID or name." : `Project type '${projectTypeRef}' did not resolve to exactly one project type.`;
@@ -200249,7 +200433,7 @@ var resolveTaskType = (taskTypes, taskTypeRef) => {
200249
200433
  const selected = taskTypes.filter(
200250
200434
  (taskType) => taskType._id === taskTypeRef || normalizeForComparison(taskType.name) === normalizeForComparison(taskTypeRef)
200251
200435
  );
200252
- return selected.length === 1 ? Effect_exports.succeed(selected[0]) : Effect_exports.fail(new HulyError({ message: `Task type '${taskTypeRef}' did not resolve to exactly one task type.` }));
200436
+ return isSingle2(selected) ? Effect_exports.succeed(selected[0]) : Effect_exports.fail(new HulyError({ message: `Task type '${taskTypeRef}' did not resolve to exactly one task type.` }));
200253
200437
  };
200254
200438
  var existingTaskTypeByName = (taskTypes, name) => taskTypes.find((taskType) => normalizeForComparison(taskType.name) === normalizeForComparison(name));
200255
200439
  var existingStatusByName = (statuses, name) => statuses.find((status) => normalizeForComparison(status.name) === normalizeForComparison(name));
@@ -200270,6 +200454,7 @@ var replaceOrAppendProjectStatus = (statuses, statusId, taskTypeId) => statuses.
200270
200454
  var sameStatusRefList = (left3, right3) => left3.length === right3.length && left3.every((value3, index) => value3 === right3[index]);
200271
200455
  var sameProjectStatusList = (left3, right3) => left3.length === right3.length && left3.every((value3, index) => {
200272
200456
  const rightValue = right3[index];
200457
+ if (rightValue === void 0) return false;
200273
200458
  return sameProjectStatus(value3, rightValue);
200274
200459
  });
200275
200460
  var listProjectTypes = (_params) => Effect_exports.gen(function* () {
@@ -202637,7 +202822,7 @@ var toClientCompatibleInputSchema = (schema) => {
202637
202822
  Object.entries(schema).filter(([key]) => key !== "type" && !ROOT_COMPOSITION_KEYS.has(key))
202638
202823
  );
202639
202824
  const properties = mergedSchemaField(schema, "properties");
202640
- const defs = mergedSchemaField(schema, "$defs");
202825
+ const defs = collectJsonSchemaDefinitions(schema);
202641
202826
  return {
202642
202827
  ...rootFields,
202643
202828
  type: "object",
@@ -202987,6 +203172,26 @@ var createResourceListClientResolutionError = (_error) => new McpError(
202987
203172
  ErrorCode.InternalError,
202988
203173
  "Failed to initialize Huly clients while listing resources. Verify Huly URL, workspace, and authentication configuration."
202989
203174
  );
203175
+ var hasAnyHulyConfigSource = (context6) => {
203176
+ const env = context6.configSources.env;
203177
+ const headersPresent = context6.configSources.headers?.present === true;
203178
+ return headersPresent || env.hulyUrl || env.hulyWorkspace || env.hulyToken || env.hulyEmail || env.hulyPassword || env.hulyConnectionTimeout;
203179
+ };
203180
+ var isConfigValidationFailure = (error2) => {
203181
+ if (error2 instanceof ConfigValidationError) return true;
203182
+ if (!Runtime_exports.isFiberFailure(error2)) return false;
203183
+ return Chunk_exports.toArray(Cause_exports.failures(error2[Runtime_exports.FiberFailureCauseId])).some(
203184
+ (failure) => failure instanceof ConfigValidationError
203185
+ );
203186
+ };
203187
+ var shouldReturnEmptyResourceListOnClientResolutionFailure = (error2, getHulyContext) => {
203188
+ if (!isConfigValidationFailure(error2)) return false;
203189
+ try {
203190
+ return !hasAnyHulyConfigSource(validateHulyContextResult(getHulyContext()));
203191
+ } catch {
203192
+ return false;
203193
+ }
203194
+ };
202990
203195
  var resolveResourceClientsOrThrow = async (resolveClients, mapError7) => {
202991
203196
  try {
202992
203197
  return await resolveClients();
@@ -203131,7 +203336,13 @@ var createMcpProtocolHandlers = (resolveClients, telemetry, registry2, getHulyCo
203131
203336
  const listResourcesHandler = async () => {
203132
203337
  enter();
203133
203338
  try {
203134
- const clients = await resolveResourceClientsOrThrow(resolveClients, createResourceListClientResolutionError);
203339
+ let clients;
203340
+ try {
203341
+ clients = await resolveClients();
203342
+ } catch (e) {
203343
+ if (shouldReturnEmptyResourceListOnClientResolutionFailure(e, getHulyContext)) return { resources: [] };
203344
+ throw createResourceListClientResolutionError(e);
203345
+ }
203135
203346
  const resourceList = await Effect_exports.runPromiseExit(
203136
203347
  listResources().pipe(
203137
203348
  Effect_exports.provideService(HulyClient, clients.hulyClient)