@kodycodes/cli 3.48.5 → 3.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/app-commands-RPH5UBWX.js +126 -0
  2. package/dist/app-commands-RPH5UBWX.js.map +6 -0
  3. package/dist/app-commands.d.ts +38 -0
  4. package/dist/{auth-W7ECUQVD.js → auth-FKYKA3YB.js} +3 -3
  5. package/dist/bin.js +6 -6
  6. package/dist/{chunk-FSTMCOCL.js → chunk-3DACU42N.js} +141 -43
  7. package/dist/chunk-3DACU42N.js.map +6 -0
  8. package/dist/{chunk-QX4333G2.js → chunk-4CGJMK4J.js} +2 -2
  9. package/dist/{chunk-5NVIDK5Q.js → chunk-7B2UIV4D.js} +2 -2
  10. package/dist/{chunk-S2YB7K22.js → chunk-ASA2IEBG.js} +2 -2
  11. package/dist/{chunk-TCMGDX6G.js → chunk-CJKDXPBG.js} +20 -1
  12. package/dist/chunk-CJKDXPBG.js.map +6 -0
  13. package/dist/{chunk-MENESZ2Z.js → chunk-K3LCMRYU.js} +4 -4
  14. package/dist/{chunk-MENESZ2Z.js.map → chunk-K3LCMRYU.js.map} +1 -1
  15. package/dist/{chunk-DGIO6LJS.js → chunk-NXLZQZVP.js} +13 -7
  16. package/dist/chunk-NXLZQZVP.js.map +6 -0
  17. package/dist/{chunk-DPYJDB32.js → chunk-RFUU2YCN.js} +3 -3
  18. package/dist/cli.d.ts +2 -0
  19. package/dist/cli.js +6 -6
  20. package/dist/{commands-KAHKDW4W.js → commands-CNG5TDFP.js} +8 -24
  21. package/dist/commands-CNG5TDFP.js.map +6 -0
  22. package/dist/{dev-command-RUSL5PCT.js → dev-command-RGO5P3I5.js} +3 -3
  23. package/dist/{execute-local-package-35V5NTEB.js → execute-local-package-HVMQPKUV.js} +7 -7
  24. package/dist/execution-context/client.d.ts +4 -0
  25. package/dist/{git-credential-JILTRBMU.js → git-credential-6LLKWPNF.js} +4 -4
  26. package/dist/{local-package-run-NXXRW2IW.js → local-package-run-TGIL47SF.js} +3 -3
  27. package/dist/{local-secrets-I6PVOLRH.js → local-secrets-6HSPPA6G.js} +2 -2
  28. package/dist/{mock-dep-resolve-RNBN2QD4.js → mock-dep-resolve-EDH7SHO3.js} +2 -2
  29. package/dist/{open-api-client-IT5K6DBQ.js → open-api-client-U5USMYOX.js} +2 -2
  30. package/dist/{package-run-FRSZAKP3.js → package-run-Z3I3YH5I.js} +2 -2
  31. package/dist/publish-builder.js +460 -415
  32. package/dist/{remote-execute-52M2NDU2.js → remote-execute-KCKI73BC.js} +3 -3
  33. package/dist/{run-app-check-OZ5RH57M.js → run-app-check-6TKMAIED.js} +5 -5
  34. package/dist/{setup-git-PKPPPUWA.js → setup-git-WO3JVBA5.js} +3 -3
  35. package/dist/{whoami-BUNOT4HQ.js → whoami-ZH27YBEJ.js} +3 -3
  36. package/package.json +1 -1
  37. package/dist/chunk-DGIO6LJS.js.map +0 -6
  38. package/dist/chunk-FSTMCOCL.js.map +0 -6
  39. package/dist/chunk-TCMGDX6G.js.map +0 -6
  40. package/dist/commands-KAHKDW4W.js.map +0 -6
  41. /package/dist/{auth-W7ECUQVD.js.map → auth-FKYKA3YB.js.map} +0 -0
  42. /package/dist/{chunk-QX4333G2.js.map → chunk-4CGJMK4J.js.map} +0 -0
  43. /package/dist/{chunk-5NVIDK5Q.js.map → chunk-7B2UIV4D.js.map} +0 -0
  44. /package/dist/{chunk-S2YB7K22.js.map → chunk-ASA2IEBG.js.map} +0 -0
  45. /package/dist/{chunk-DPYJDB32.js.map → chunk-RFUU2YCN.js.map} +0 -0
  46. /package/dist/{dev-command-RUSL5PCT.js.map → dev-command-RGO5P3I5.js.map} +0 -0
  47. /package/dist/{execute-local-package-35V5NTEB.js.map → execute-local-package-HVMQPKUV.js.map} +0 -0
  48. /package/dist/{git-credential-JILTRBMU.js.map → git-credential-6LLKWPNF.js.map} +0 -0
  49. /package/dist/{local-package-run-NXXRW2IW.js.map → local-package-run-TGIL47SF.js.map} +0 -0
  50. /package/dist/{local-secrets-I6PVOLRH.js.map → local-secrets-6HSPPA6G.js.map} +0 -0
  51. /package/dist/{mock-dep-resolve-RNBN2QD4.js.map → mock-dep-resolve-EDH7SHO3.js.map} +0 -0
  52. /package/dist/{open-api-client-IT5K6DBQ.js.map → open-api-client-U5USMYOX.js.map} +0 -0
  53. /package/dist/{package-run-FRSZAKP3.js.map → package-run-Z3I3YH5I.js.map} +0 -0
  54. /package/dist/{remote-execute-52M2NDU2.js.map → remote-execute-KCKI73BC.js.map} +0 -0
  55. /package/dist/{run-app-check-OZ5RH57M.js.map → run-app-check-6TKMAIED.js.map} +0 -0
  56. /package/dist/{setup-git-PKPPPUWA.js.map → setup-git-WO3JVBA5.js.map} +0 -0
  57. /package/dist/{whoami-BUNOT4HQ.js.map → whoami-ZH27YBEJ.js.map} +0 -0
@@ -4245,8 +4245,8 @@ var init_schemas = __esm({
4245
4245
  setSize = (input3) => input3 instanceof Set ? input3.size : -1;
4246
4246
  $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
4247
4247
  $ZodType.init(inst, def);
4248
- const memo3 = globalConfig.memoizer;
4249
- memo3?.attach(inst);
4248
+ const memo2 = globalConfig.memoizer;
4249
+ memo2?.attach(inst);
4250
4250
  inst._zod.parse = (payload, ctx) => {
4251
4251
  const input3 = payload.value;
4252
4252
  if (!Array.isArray(input3)) {
@@ -4258,7 +4258,7 @@ var init_schemas = __esm({
4258
4258
  });
4259
4259
  return payload;
4260
4260
  }
4261
- payload.value = memo3 ? memo3.alloc(inst, payload, Array(input3.length), ctx) : Array(input3.length);
4261
+ payload.value = memo2 ? memo2.alloc(inst, payload, Array(input3.length), ctx) : Array(input3.length);
4262
4262
  const proms = [];
4263
4263
  const abortEarly = ctx?.abortEarly;
4264
4264
  for (let i4 = 0; i4 < input3.length; i4++) {
@@ -4318,8 +4318,8 @@ var init_schemas = __esm({
4318
4318
  const isObject2 = isObject;
4319
4319
  const catchall = def.catchall;
4320
4320
  let value;
4321
- const memo3 = globalConfig.memoizer;
4322
- memo3?.attach(inst);
4321
+ const memo2 = globalConfig.memoizer;
4322
+ memo2?.attach(inst);
4323
4323
  inst._zod.parse = (payload, ctx) => {
4324
4324
  value ?? (value = _normalized.value);
4325
4325
  const input3 = payload.value;
@@ -4332,7 +4332,7 @@ var init_schemas = __esm({
4332
4332
  });
4333
4333
  return payload;
4334
4334
  }
4335
- payload.value = memo3 ? memo3.alloc(inst, payload, {}, ctx) : {};
4335
+ payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
4336
4336
  const proms = [];
4337
4337
  const shape = value.shape;
4338
4338
  const abortEarly = ctx?.abortEarly;
@@ -4365,11 +4365,11 @@ var init_schemas = __esm({
4365
4365
  $ZodObject.init(inst, def);
4366
4366
  const superParse = inst._zod.parse;
4367
4367
  const _normalized = cached(() => normalizeDef(def));
4368
- const memo3 = globalConfig.memoizer;
4368
+ const memo2 = globalConfig.memoizer;
4369
4369
  const generateFastpass = (shape) => {
4370
4370
  const normalized = _normalized.value;
4371
4371
  const syms = normalized.symbolKeys;
4372
- const doc = new Doc(["payload", "ctx"], { shape, inst, memo: memo3, syms });
4372
+ const doc = new Doc(["payload", "ctx"], { shape, inst, memo: memo2, syms });
4373
4373
  const parseStr = (k2) => `shape[${k2}]._zod.run({ value: input[${k2}], issues: [] }, ctx)`;
4374
4374
  const prefixStr = (id, k2) => `
4375
4375
  let ${id}_ab = false;
@@ -4389,7 +4389,7 @@ var init_schemas = __esm({
4389
4389
  for (const key of normalized.allKeys) {
4390
4390
  ids[key] = `key_${counter++}`;
4391
4391
  }
4392
- doc.write(memo3 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
4392
+ doc.write(memo2 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
4393
4393
  for (const key of normalized.allKeys) {
4394
4394
  if (key === "__proto__")
4395
4395
  continue;
@@ -4645,8 +4645,8 @@ var init_schemas = __esm({
4645
4645
  $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
4646
4646
  $ZodType.init(inst, def);
4647
4647
  const items = def.items;
4648
- const memo3 = globalConfig.memoizer;
4649
- memo3?.attach(inst);
4648
+ const memo2 = globalConfig.memoizer;
4649
+ memo2?.attach(inst);
4650
4650
  inst._zod.parse = (payload, ctx) => {
4651
4651
  const input3 = payload.value;
4652
4652
  if (!Array.isArray(input3)) {
@@ -4658,7 +4658,7 @@ var init_schemas = __esm({
4658
4658
  });
4659
4659
  return payload;
4660
4660
  }
4661
- payload.value = memo3 ? memo3.alloc(inst, payload, [], ctx) : [];
4661
+ payload.value = memo2 ? memo2.alloc(inst, payload, [], ctx) : [];
4662
4662
  const proms = [];
4663
4663
  const optinStart = getTupleOptStart(items, "optin");
4664
4664
  const optoutStart = getTupleOptStart(items, "optout");
@@ -4727,8 +4727,8 @@ var init_schemas = __esm({
4727
4727
  });
4728
4728
  $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
4729
4729
  $ZodType.init(inst, def);
4730
- const memo3 = globalConfig.memoizer;
4731
- memo3?.attach(inst);
4730
+ const memo2 = globalConfig.memoizer;
4731
+ memo2?.attach(inst);
4732
4732
  inst._zod.parse = (payload, ctx) => {
4733
4733
  const input3 = payload.value;
4734
4734
  if (!isPlainObject(input3)) {
@@ -4743,7 +4743,7 @@ var init_schemas = __esm({
4743
4743
  const proms = [];
4744
4744
  const values = def.keyType._zod.values;
4745
4745
  if (values && !def.partial) {
4746
- payload.value = memo3 ? memo3.alloc(inst, payload, {}, ctx) : {};
4746
+ payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
4747
4747
  const recordKeys = /* @__PURE__ */ new Set();
4748
4748
  for (const key of values) {
4749
4749
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
@@ -4807,7 +4807,7 @@ var init_schemas = __esm({
4807
4807
  });
4808
4808
  }
4809
4809
  } else {
4810
- payload.value = memo3 ? memo3.alloc(inst, payload, {}, ctx) : {};
4810
+ payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
4811
4811
  let unrecognized;
4812
4812
  for (const key of Reflect.ownKeys(input3)) {
4813
4813
  if (key === "__proto__")
@@ -4882,8 +4882,8 @@ var init_schemas = __esm({
4882
4882
  });
4883
4883
  $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
4884
4884
  $ZodType.init(inst, def);
4885
- const memo3 = globalConfig.memoizer;
4886
- memo3?.attach(inst);
4885
+ const memo2 = globalConfig.memoizer;
4886
+ memo2?.attach(inst);
4887
4887
  inst._zod.parse = (payload, ctx) => {
4888
4888
  const input3 = payload.value;
4889
4889
  if (!(input3 instanceof Map)) {
@@ -4896,7 +4896,7 @@ var init_schemas = __esm({
4896
4896
  return payload;
4897
4897
  }
4898
4898
  const proms = [];
4899
- payload.value = memo3 ? memo3.alloc(inst, payload, /* @__PURE__ */ new Map(), ctx) : /* @__PURE__ */ new Map();
4899
+ payload.value = memo2 ? memo2.alloc(inst, payload, /* @__PURE__ */ new Map(), ctx) : /* @__PURE__ */ new Map();
4900
4900
  const abortEarly = ctx?.abortEarly;
4901
4901
  let seen = payload.issues.length;
4902
4902
  for (const [key, value] of input3) {
@@ -4923,8 +4923,8 @@ var init_schemas = __esm({
4923
4923
  });
4924
4924
  $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
4925
4925
  $ZodType.init(inst, def);
4926
- const memo3 = globalConfig.memoizer;
4927
- memo3?.attach(inst);
4926
+ const memo2 = globalConfig.memoizer;
4927
+ memo2?.attach(inst);
4928
4928
  inst._zod.parse = (payload, ctx) => {
4929
4929
  const input3 = payload.value;
4930
4930
  if (!(input3 instanceof Set)) {
@@ -4937,7 +4937,7 @@ var init_schemas = __esm({
4937
4937
  return payload;
4938
4938
  }
4939
4939
  const proms = [];
4940
- payload.value = memo3 ? memo3.alloc(inst, payload, /* @__PURE__ */ new Set(), ctx) : /* @__PURE__ */ new Set();
4940
+ payload.value = memo2 ? memo2.alloc(inst, payload, /* @__PURE__ */ new Set(), ctx) : /* @__PURE__ */ new Set();
4941
4941
  const abortEarly = ctx?.abortEarly;
4942
4942
  let seen = payload.issues.length;
4943
4943
  for (const item of input3) {
@@ -10921,7 +10921,7 @@ var init_frames = __esm({
10921
10921
  init_replay();
10922
10922
  ecpMaxFrameBytes = 6 * 1024 * 1024;
10923
10923
  ecpMaxConcurrentRunsCap = 8;
10924
- ecpMaxChainContexts = 3;
10924
+ ecpMaxChainContexts = 8;
10925
10925
  ecpDefaultGrant = {
10926
10926
  fs: [],
10927
10927
  egress: { mode: "public" },
@@ -11008,7 +11008,7 @@ function runChainShapeError(refs) {
11008
11008
  if (contexts.length > ecpMaxChainContexts) {
11009
11009
  return {
11010
11010
  code: "chain_too_long",
11011
- message: `chain can list at most ${ecpMaxChainContexts} contexts, plus "cloud" last.`
11011
+ message: `A chain holds at most ${ecpMaxChainContexts} contexts plus Kody cloud. Remove one from this chain, then try again.`
11012
11012
  };
11013
11013
  }
11014
11014
  if (trimmed.length === 0) {
@@ -11046,7 +11046,7 @@ var init_automation_execution_schema = __esm({
11046
11046
  '"chain" lets a named context that cannot take the run fall back to the chain.'
11047
11047
  ),
11048
11048
  chain: external_exports.array(external_exports.string().trim().min(1)).min(1).max(ecpMaxChainContexts + 1).optional().describe(
11049
- `This automation's own ordered chain, replacing the default chain: up to 3 context names or ids, with "cloud" allowed only last.`
11049
+ `This automation's own ordered chain, replacing the default chain: up to ${ecpMaxChainContexts} context names or ids, with "cloud" allowed only last.`
11050
11050
  ),
11051
11051
  requires: external_exports.array(external_exports.enum(executeRequirements)).max(executeRequirements.length).optional().describe('Local access the run needs ("fs", "lan"). Skips Kody cloud.'),
11052
11052
  whenOffline: external_exports.enum(["fail", "queue"]).optional().describe(
@@ -12363,6 +12363,378 @@ var init_published_source_dependencies = __esm({
12363
12363
  }
12364
12364
  });
12365
12365
 
12366
+ // ../shared/src/isolate-state.ts
12367
+ function isolateStateRegistry() {
12368
+ const scope = globalThis;
12369
+ scope[registryKey] ??= /* @__PURE__ */ new Set();
12370
+ return scope[registryKey];
12371
+ }
12372
+ function isolateState(create, options) {
12373
+ const state2 = { current: create() };
12374
+ isolateStateRegistry().add({
12375
+ reset() {
12376
+ state2.current = create();
12377
+ },
12378
+ pending() {
12379
+ return options?.pending?.(state2.current) ?? [];
12380
+ }
12381
+ });
12382
+ return state2;
12383
+ }
12384
+ function isolateCollection(collection, options) {
12385
+ isolateStateRegistry().add({
12386
+ reset() {
12387
+ collection.clear();
12388
+ },
12389
+ pending() {
12390
+ return options?.pending?.(collection) ?? [];
12391
+ }
12392
+ });
12393
+ return collection;
12394
+ }
12395
+ var registryKey;
12396
+ var init_isolate_state = __esm({
12397
+ "../shared/src/isolate-state.ts"() {
12398
+ "use strict";
12399
+ registryKey = /* @__PURE__ */ Symbol.for("kody.isolate-state");
12400
+ }
12401
+ });
12402
+
12403
+ // ../worker/src/package-registry/published-package-cache.ts
12404
+ function createPublishedPackageCacheKey(input3) {
12405
+ if (!input3.source.published_commit) {
12406
+ return null;
12407
+ }
12408
+ return JSON.stringify([
12409
+ input3.userId,
12410
+ input3.source.id,
12411
+ input3.source.published_commit,
12412
+ input3.source.manifest_path,
12413
+ input3.source.source_root,
12414
+ input3.entryPoint?.trim() || null
12415
+ ]);
12416
+ }
12417
+ function estimateRetainedBytes(value) {
12418
+ const seen = /* @__PURE__ */ new Set();
12419
+ const stack = [value];
12420
+ let bytes = 0;
12421
+ while (stack.length > 0) {
12422
+ const next2 = stack.pop();
12423
+ if (typeof next2 === "string") {
12424
+ bytes += next2.length;
12425
+ continue;
12426
+ }
12427
+ if (next2 === null || typeof next2 !== "object" || seen.has(next2)) {
12428
+ continue;
12429
+ }
12430
+ seen.add(next2);
12431
+ if (ArrayBuffer.isView(next2) || next2 instanceof ArrayBuffer) {
12432
+ bytes += next2.byteLength;
12433
+ continue;
12434
+ }
12435
+ if (Array.isArray(next2)) {
12436
+ stack.push(...next2);
12437
+ continue;
12438
+ }
12439
+ const prototype = Object.getPrototypeOf(next2);
12440
+ if (prototype !== Object.prototype && prototype !== null) {
12441
+ continue;
12442
+ }
12443
+ for (const [key, child] of Object.entries(next2)) {
12444
+ bytes += key.length;
12445
+ stack.push(child);
12446
+ }
12447
+ }
12448
+ return bytes;
12449
+ }
12450
+ function createPromiseLruCacheByBinding(options) {
12451
+ const caches = /* @__PURE__ */ new WeakMap();
12452
+ return {
12453
+ for(binding) {
12454
+ let cache = caches.get(binding);
12455
+ if (!cache) {
12456
+ cache = new PromiseLruCache(options);
12457
+ caches.set(binding, cache);
12458
+ }
12459
+ return cache;
12460
+ },
12461
+ clear(binding) {
12462
+ caches.get(binding)?.clear();
12463
+ }
12464
+ };
12465
+ }
12466
+ function createPublishedPackagePromiseCache() {
12467
+ return new PromiseLruCache({ byteBudget: packageArtifactCacheBudget });
12468
+ }
12469
+ var publishedPackageCacheLimit, publishedPackageCacheTtlMs, promiseLruCacheInFlightWaitMs, RetainedByteBudget, packageArtifactCacheMaxBytes, packageArtifactCacheBudget, PromiseLruCache;
12470
+ var init_published_package_cache = __esm({
12471
+ "../worker/src/package-registry/published-package-cache.ts"() {
12472
+ "use strict";
12473
+ publishedPackageCacheLimit = 50;
12474
+ publishedPackageCacheTtlMs = 5 * 60 * 1e3;
12475
+ promiseLruCacheInFlightWaitMs = 5e3;
12476
+ RetainedByteBudget = class {
12477
+ constructor(maxBytes) {
12478
+ this.maxBytes = maxBytes;
12479
+ }
12480
+ maxBytes;
12481
+ caches = /* @__PURE__ */ new Set();
12482
+ usedBytes = 0;
12483
+ clock = 0;
12484
+ get retainedBytes() {
12485
+ return this.usedBytes;
12486
+ }
12487
+ /** @internal */
12488
+ tick() {
12489
+ this.clock += 1;
12490
+ return this.clock;
12491
+ }
12492
+ /** @internal */
12493
+ register(cache) {
12494
+ this.caches.add(cache);
12495
+ }
12496
+ /** @internal */
12497
+ adjust(delta) {
12498
+ this.usedBytes += delta;
12499
+ }
12500
+ /** @internal */
12501
+ enforce() {
12502
+ while (this.usedBytes > this.maxBytes) {
12503
+ let oldest = null;
12504
+ let oldestUsed = Number.POSITIVE_INFINITY;
12505
+ for (const cache of this.caches) {
12506
+ const candidate = cache.oldestSizedEntry();
12507
+ if (candidate && candidate.lastUsed < oldestUsed) {
12508
+ oldestUsed = candidate.lastUsed;
12509
+ oldest = { cache, key: candidate.key };
12510
+ }
12511
+ }
12512
+ if (!oldest) {
12513
+ break;
12514
+ }
12515
+ oldest.cache.delete(oldest.key);
12516
+ }
12517
+ }
12518
+ };
12519
+ packageArtifactCacheMaxBytes = 24 * 1024 * 1024;
12520
+ packageArtifactCacheBudget = new RetainedByteBudget(
12521
+ packageArtifactCacheMaxBytes
12522
+ );
12523
+ PromiseLruCache = class {
12524
+ cache = /* @__PURE__ */ new Map();
12525
+ constructor(input3) {
12526
+ this.ttlMs = input3?.ttlMs ?? publishedPackageCacheTtlMs;
12527
+ this.limit = input3?.limit ?? publishedPackageCacheLimit;
12528
+ this.inFlightWaitMs = input3?.inFlightWaitMs ?? promiseLruCacheInFlightWaitMs;
12529
+ this.byteBudget = input3?.byteBudget ?? null;
12530
+ this.sizeOf = input3?.sizeOf ?? estimateRetainedBytes;
12531
+ this.retainSettled = input3?.retainSettled ?? true;
12532
+ this.byteBudget?.register(this);
12533
+ }
12534
+ ttlMs;
12535
+ limit;
12536
+ inFlightWaitMs;
12537
+ byteBudget;
12538
+ sizeOf;
12539
+ retainSettled;
12540
+ /** @internal Least recently used settled entry that holds sized bytes. */
12541
+ oldestSizedEntry() {
12542
+ for (const [key, entry] of this.cache) {
12543
+ if (entry.bytes > 0) {
12544
+ return { key, lastUsed: entry.lastUsed };
12545
+ }
12546
+ }
12547
+ return null;
12548
+ }
12549
+ touch(entry) {
12550
+ if (this.byteBudget) {
12551
+ entry.lastUsed = this.byteBudget.tick();
12552
+ }
12553
+ }
12554
+ getEntry(key) {
12555
+ const cached2 = this.cache.get(key);
12556
+ if (!cached2) {
12557
+ return null;
12558
+ }
12559
+ if (cached2.expiresAt <= Date.now()) {
12560
+ this.delete(key);
12561
+ return null;
12562
+ }
12563
+ this.cache.delete(key);
12564
+ this.cache.set(key, cached2);
12565
+ this.touch(cached2);
12566
+ return cached2;
12567
+ }
12568
+ /**
12569
+ * A settled value, as a promise owned by the caller's request. Never
12570
+ * another request's in-flight promise: use `getOrCreate` to wait on one.
12571
+ */
12572
+ get(key) {
12573
+ const settled = this.getEntry(key)?.settled;
12574
+ return settled ? Promise.resolve(settled.value) : null;
12575
+ }
12576
+ set(key, pending) {
12577
+ const entry = {
12578
+ expiresAt: Date.now() + this.ttlMs,
12579
+ pending,
12580
+ settled: null,
12581
+ bytes: 0,
12582
+ lastUsed: 0
12583
+ };
12584
+ this.delete(key);
12585
+ this.cache.set(key, entry);
12586
+ this.touch(entry);
12587
+ void pending.then(
12588
+ (value) => {
12589
+ if (!this.retainSettled) {
12590
+ if (this.cache.get(key) === entry) this.delete(key);
12591
+ return;
12592
+ }
12593
+ entry.settled = { value };
12594
+ this.recordSize(key, entry, value);
12595
+ },
12596
+ () => {
12597
+ }
12598
+ );
12599
+ this.enforceLimit();
12600
+ return pending;
12601
+ }
12602
+ getOrCreate(input3) {
12603
+ const cached2 = this.getEntry(input3.cacheKey);
12604
+ if (cached2?.settled) {
12605
+ return Promise.resolve(cached2.settled.value);
12606
+ }
12607
+ if (cached2) {
12608
+ return this.waitForInFlight(cached2, input3, { retried: false });
12609
+ }
12610
+ return this.createEntry(input3);
12611
+ }
12612
+ delete(key) {
12613
+ const entry = this.cache.get(key);
12614
+ if (!entry) {
12615
+ return;
12616
+ }
12617
+ this.cache.delete(key);
12618
+ if (entry.bytes > 0) {
12619
+ this.byteBudget?.adjust(-entry.bytes);
12620
+ entry.bytes = 0;
12621
+ }
12622
+ }
12623
+ /** Drop every entry whose key matches, e.g. one owner's prefix. */
12624
+ deleteWhere(matches) {
12625
+ for (const key of [...this.cache.keys()]) {
12626
+ if (matches(key)) this.delete(key);
12627
+ }
12628
+ }
12629
+ clear() {
12630
+ this.deleteWhere(() => true);
12631
+ }
12632
+ recordSize(key, entry, value) {
12633
+ const budget = this.byteBudget;
12634
+ if (!budget || this.cache.get(key) !== entry) {
12635
+ return;
12636
+ }
12637
+ const bytes = Math.max(1, this.sizeOf(value));
12638
+ if (bytes > budget.maxBytes) {
12639
+ this.delete(key);
12640
+ return;
12641
+ }
12642
+ entry.bytes = bytes;
12643
+ budget.adjust(bytes);
12644
+ budget.enforce();
12645
+ }
12646
+ createEntry(input3) {
12647
+ let pending;
12648
+ pending = input3.create().catch((error2) => {
12649
+ if (this.cache.get(input3.cacheKey)?.pending === pending) {
12650
+ this.delete(input3.cacheKey);
12651
+ }
12652
+ throw error2;
12653
+ });
12654
+ this.set(input3.cacheKey, pending);
12655
+ return pending;
12656
+ }
12657
+ /**
12658
+ * Await an entry another request may own. If it has not settled within
12659
+ * `inFlightWaitMs`, or it rejects, treat it as orphaned: replace it (when
12660
+ * it is still the cached entry) and run `create()` in this request. The
12661
+ * owner may have ended, and its failure is not this request's. A waiter
12662
+ * shares at most one other rebuild; if that one also fails or stalls, it
12663
+ * runs its own `create()`, so the only rejection a caller sees is one
12664
+ * from a `create()` it ran.
12665
+ */
12666
+ waitForInFlight(entry, input3, options) {
12667
+ return new Promise((resolve, reject) => {
12668
+ let done = false;
12669
+ const takeOver = () => {
12670
+ if (this.cache.get(input3.cacheKey) === entry) {
12671
+ this.delete(input3.cacheKey);
12672
+ }
12673
+ const current = this.getEntry(input3.cacheKey);
12674
+ const next2 = current?.settled ? Promise.resolve(current.settled.value) : !current || options.retried ? this.createEntry(input3) : this.waitForInFlight(current, input3, { retried: true });
12675
+ next2.then(resolve, reject);
12676
+ };
12677
+ const timer = Number.isFinite(this.inFlightWaitMs) ? setTimeout(() => {
12678
+ if (done) return;
12679
+ done = true;
12680
+ takeOver();
12681
+ }, this.inFlightWaitMs) : void 0;
12682
+ entry.pending.then(
12683
+ (value) => {
12684
+ if (done) return;
12685
+ done = true;
12686
+ clearTimeout(timer);
12687
+ resolve(value);
12688
+ },
12689
+ () => {
12690
+ if (done) return;
12691
+ done = true;
12692
+ clearTimeout(timer);
12693
+ takeOver();
12694
+ }
12695
+ );
12696
+ });
12697
+ }
12698
+ enforceLimit() {
12699
+ while (this.cache.size > this.limit) {
12700
+ const oldestKey = this.cache.keys().next().value;
12701
+ if (oldestKey === void 0) {
12702
+ break;
12703
+ }
12704
+ this.delete(oldestKey);
12705
+ }
12706
+ }
12707
+ };
12708
+ }
12709
+ });
12710
+
12711
+ // ../worker/src/isolate-memo.ts
12712
+ function isolateMemo(load) {
12713
+ const cache = isolateCollection(
12714
+ new PromiseLruCache({ ttlMs: Number.POSITIVE_INFINITY, limit: 1 })
12715
+ );
12716
+ return () => cache.getOrCreate({ cacheKey: "value", create: load });
12717
+ }
12718
+ function isolateMemoByKey(load, options) {
12719
+ const cache = isolateCollection(
12720
+ new PromiseLruCache({
12721
+ ttlMs: Number.POSITIVE_INFINITY,
12722
+ limit: options?.limit ?? 64
12723
+ })
12724
+ );
12725
+ return Object.assign(
12726
+ (key) => cache.getOrCreate({ cacheKey: key, create: () => load(key) }),
12727
+ { clear: () => cache.clear() }
12728
+ );
12729
+ }
12730
+ var init_isolate_memo = __esm({
12731
+ "../worker/src/isolate-memo.ts"() {
12732
+ "use strict";
12733
+ init_isolate_state();
12734
+ init_published_package_cache();
12735
+ }
12736
+ });
12737
+
12366
12738
  // ../../node_modules/@babel/parser/lib/index.js
12367
12739
  function createPositionWithColumnOffset(position, columnOffset) {
12368
12740
  const {
@@ -26668,16 +27040,6 @@ var init_module_source_parser_module = __esm({
26668
27040
  });
26669
27041
 
26670
27042
  // ../worker/src/module-source.ts
26671
- function loadModuleSourceParser() {
26672
- parserMemo ??= Promise.resolve().then(() => (init_module_source_parser_module(), module_source_parser_module_exports)).then(
26673
- (module) => createModuleSourceParser(module.parse),
26674
- (error2) => {
26675
- parserMemo = null;
26676
- throw error2;
26677
- }
26678
- );
26679
- return parserMemo;
26680
- }
26681
27043
  function moduleSourceParserPlugins(filePath) {
26682
27044
  const extension = /\.([cm]?[jt]sx?)$/i.exec(filePath ?? "")?.[1]?.toLowerCase();
26683
27045
  switch (extension) {
@@ -26738,11 +27100,16 @@ function createModuleSourceParser(parse10) {
26738
27100
  }
26739
27101
  return { parseModuleSource: parseModuleSource2, parseModuleSourceAllowingTypeAssertions: parseModuleSourceAllowingTypeAssertions2 };
26740
27102
  }
26741
- var parserMemo, typeScriptPlugins, typeScriptJsxPlugins, jsxPlugins, plainJavaScriptPlugins, fallbackParserPlugins;
27103
+ var loadModuleSourceParser, typeScriptPlugins, typeScriptJsxPlugins, jsxPlugins, plainJavaScriptPlugins, fallbackParserPlugins;
26742
27104
  var init_module_source = __esm({
26743
27105
  "../worker/src/module-source.ts"() {
26744
27106
  "use strict";
26745
- parserMemo = null;
27107
+ init_isolate_memo();
27108
+ loadModuleSourceParser = isolateMemo(
27109
+ () => Promise.resolve().then(() => (init_module_source_parser_module(), module_source_parser_module_exports)).then(
27110
+ (module) => createModuleSourceParser(module.parse)
27111
+ )
27112
+ );
26746
27113
  typeScriptPlugins = ["typescript"];
26747
27114
  typeScriptJsxPlugins = ["typescript", "jsx"];
26748
27115
  jsxPlugins = ["jsx"];
@@ -28134,314 +28501,6 @@ var init_reserved_usernames2 = __esm({
28134
28501
  }
28135
28502
  });
28136
28503
 
28137
- // ../worker/src/package-registry/published-package-cache.ts
28138
- function createPublishedPackageCacheKey(input3) {
28139
- if (!input3.source.published_commit) {
28140
- return null;
28141
- }
28142
- return JSON.stringify([
28143
- input3.userId,
28144
- input3.source.id,
28145
- input3.source.published_commit,
28146
- input3.source.manifest_path,
28147
- input3.source.source_root,
28148
- input3.entryPoint?.trim() || null
28149
- ]);
28150
- }
28151
- function estimateRetainedBytes(value) {
28152
- const seen = /* @__PURE__ */ new Set();
28153
- const stack = [value];
28154
- let bytes = 0;
28155
- while (stack.length > 0) {
28156
- const next2 = stack.pop();
28157
- if (typeof next2 === "string") {
28158
- bytes += next2.length;
28159
- continue;
28160
- }
28161
- if (next2 === null || typeof next2 !== "object" || seen.has(next2)) {
28162
- continue;
28163
- }
28164
- seen.add(next2);
28165
- if (ArrayBuffer.isView(next2) || next2 instanceof ArrayBuffer) {
28166
- bytes += next2.byteLength;
28167
- continue;
28168
- }
28169
- if (Array.isArray(next2)) {
28170
- stack.push(...next2);
28171
- continue;
28172
- }
28173
- const prototype = Object.getPrototypeOf(next2);
28174
- if (prototype !== Object.prototype && prototype !== null) {
28175
- continue;
28176
- }
28177
- for (const [key, child] of Object.entries(next2)) {
28178
- bytes += key.length;
28179
- stack.push(child);
28180
- }
28181
- }
28182
- return bytes;
28183
- }
28184
- function createPromiseLruCacheByBinding(options) {
28185
- const caches = /* @__PURE__ */ new WeakMap();
28186
- return {
28187
- for(binding) {
28188
- let cache = caches.get(binding);
28189
- if (!cache) {
28190
- cache = new PromiseLruCache(options);
28191
- caches.set(binding, cache);
28192
- }
28193
- return cache;
28194
- },
28195
- clear(binding) {
28196
- caches.get(binding)?.clear();
28197
- }
28198
- };
28199
- }
28200
- function createPublishedPackagePromiseCache() {
28201
- return new PromiseLruCache({ byteBudget: packageArtifactCacheBudget });
28202
- }
28203
- var publishedPackageCacheLimit, publishedPackageCacheTtlMs, promiseLruCacheInFlightWaitMs, RetainedByteBudget, packageArtifactCacheMaxBytes, packageArtifactCacheBudget, PromiseLruCache;
28204
- var init_published_package_cache = __esm({
28205
- "../worker/src/package-registry/published-package-cache.ts"() {
28206
- "use strict";
28207
- publishedPackageCacheLimit = 50;
28208
- publishedPackageCacheTtlMs = 5 * 60 * 1e3;
28209
- promiseLruCacheInFlightWaitMs = 5e3;
28210
- RetainedByteBudget = class {
28211
- constructor(maxBytes) {
28212
- this.maxBytes = maxBytes;
28213
- }
28214
- maxBytes;
28215
- caches = /* @__PURE__ */ new Set();
28216
- usedBytes = 0;
28217
- clock = 0;
28218
- get retainedBytes() {
28219
- return this.usedBytes;
28220
- }
28221
- /** @internal */
28222
- tick() {
28223
- this.clock += 1;
28224
- return this.clock;
28225
- }
28226
- /** @internal */
28227
- register(cache) {
28228
- this.caches.add(cache);
28229
- }
28230
- /** @internal */
28231
- adjust(delta) {
28232
- this.usedBytes += delta;
28233
- }
28234
- /** @internal */
28235
- enforce() {
28236
- while (this.usedBytes > this.maxBytes) {
28237
- let oldest = null;
28238
- let oldestUsed = Number.POSITIVE_INFINITY;
28239
- for (const cache of this.caches) {
28240
- const candidate = cache.oldestSizedEntry();
28241
- if (candidate && candidate.lastUsed < oldestUsed) {
28242
- oldestUsed = candidate.lastUsed;
28243
- oldest = { cache, key: candidate.key };
28244
- }
28245
- }
28246
- if (!oldest) {
28247
- break;
28248
- }
28249
- oldest.cache.delete(oldest.key);
28250
- }
28251
- }
28252
- };
28253
- packageArtifactCacheMaxBytes = 24 * 1024 * 1024;
28254
- packageArtifactCacheBudget = new RetainedByteBudget(
28255
- packageArtifactCacheMaxBytes
28256
- );
28257
- PromiseLruCache = class {
28258
- cache = /* @__PURE__ */ new Map();
28259
- constructor(input3) {
28260
- this.ttlMs = input3?.ttlMs ?? publishedPackageCacheTtlMs;
28261
- this.limit = input3?.limit ?? publishedPackageCacheLimit;
28262
- this.inFlightWaitMs = input3?.inFlightWaitMs ?? promiseLruCacheInFlightWaitMs;
28263
- this.byteBudget = input3?.byteBudget ?? null;
28264
- this.sizeOf = input3?.sizeOf ?? estimateRetainedBytes;
28265
- this.retainSettled = input3?.retainSettled ?? true;
28266
- this.byteBudget?.register(this);
28267
- }
28268
- ttlMs;
28269
- limit;
28270
- inFlightWaitMs;
28271
- byteBudget;
28272
- sizeOf;
28273
- retainSettled;
28274
- /** @internal Least recently used settled entry that holds sized bytes. */
28275
- oldestSizedEntry() {
28276
- for (const [key, entry] of this.cache) {
28277
- if (entry.bytes > 0) {
28278
- return { key, lastUsed: entry.lastUsed };
28279
- }
28280
- }
28281
- return null;
28282
- }
28283
- touch(entry) {
28284
- if (this.byteBudget) {
28285
- entry.lastUsed = this.byteBudget.tick();
28286
- }
28287
- }
28288
- getEntry(key) {
28289
- const cached2 = this.cache.get(key);
28290
- if (!cached2) {
28291
- return null;
28292
- }
28293
- if (cached2.expiresAt <= Date.now()) {
28294
- this.delete(key);
28295
- return null;
28296
- }
28297
- this.cache.delete(key);
28298
- this.cache.set(key, cached2);
28299
- this.touch(cached2);
28300
- return cached2;
28301
- }
28302
- /**
28303
- * A settled value, as a promise owned by the caller's request. Never
28304
- * another request's in-flight promise: use `getOrCreate` to wait on one.
28305
- */
28306
- get(key) {
28307
- const settled = this.getEntry(key)?.settled;
28308
- return settled ? Promise.resolve(settled.value) : null;
28309
- }
28310
- set(key, pending) {
28311
- const entry = {
28312
- expiresAt: Date.now() + this.ttlMs,
28313
- pending,
28314
- settled: null,
28315
- bytes: 0,
28316
- lastUsed: 0
28317
- };
28318
- this.delete(key);
28319
- this.cache.set(key, entry);
28320
- this.touch(entry);
28321
- void pending.then(
28322
- (value) => {
28323
- if (!this.retainSettled) {
28324
- if (this.cache.get(key) === entry) this.delete(key);
28325
- return;
28326
- }
28327
- entry.settled = { value };
28328
- this.recordSize(key, entry, value);
28329
- },
28330
- () => {
28331
- }
28332
- );
28333
- this.enforceLimit();
28334
- return pending;
28335
- }
28336
- getOrCreate(input3) {
28337
- const cached2 = this.getEntry(input3.cacheKey);
28338
- if (cached2?.settled) {
28339
- return Promise.resolve(cached2.settled.value);
28340
- }
28341
- if (cached2) {
28342
- return this.waitForInFlight(cached2, input3, { retried: false });
28343
- }
28344
- return this.createEntry(input3);
28345
- }
28346
- delete(key) {
28347
- const entry = this.cache.get(key);
28348
- if (!entry) {
28349
- return;
28350
- }
28351
- this.cache.delete(key);
28352
- if (entry.bytes > 0) {
28353
- this.byteBudget?.adjust(-entry.bytes);
28354
- entry.bytes = 0;
28355
- }
28356
- }
28357
- /** Drop every entry whose key matches, e.g. one owner's prefix. */
28358
- deleteWhere(matches) {
28359
- for (const key of [...this.cache.keys()]) {
28360
- if (matches(key)) this.delete(key);
28361
- }
28362
- }
28363
- clear() {
28364
- this.deleteWhere(() => true);
28365
- }
28366
- recordSize(key, entry, value) {
28367
- const budget = this.byteBudget;
28368
- if (!budget || this.cache.get(key) !== entry) {
28369
- return;
28370
- }
28371
- const bytes = Math.max(1, this.sizeOf(value));
28372
- if (bytes > budget.maxBytes) {
28373
- this.delete(key);
28374
- return;
28375
- }
28376
- entry.bytes = bytes;
28377
- budget.adjust(bytes);
28378
- budget.enforce();
28379
- }
28380
- createEntry(input3) {
28381
- let pending;
28382
- pending = input3.create().catch((error2) => {
28383
- if (this.cache.get(input3.cacheKey)?.pending === pending) {
28384
- this.delete(input3.cacheKey);
28385
- }
28386
- throw error2;
28387
- });
28388
- this.set(input3.cacheKey, pending);
28389
- return pending;
28390
- }
28391
- /**
28392
- * Await an entry another request may own. If it has not settled within
28393
- * `inFlightWaitMs`, or it rejects, treat it as orphaned: replace it (when
28394
- * it is still the cached entry) and run `create()` in this request. The
28395
- * owner may have ended, and its failure is not this request's. A waiter
28396
- * shares at most one other rebuild; if that one also fails or stalls, it
28397
- * runs its own `create()`, so the only rejection a caller sees is one
28398
- * from a `create()` it ran.
28399
- */
28400
- waitForInFlight(entry, input3, options) {
28401
- return new Promise((resolve, reject) => {
28402
- let done = false;
28403
- const takeOver = () => {
28404
- if (this.cache.get(input3.cacheKey) === entry) {
28405
- this.delete(input3.cacheKey);
28406
- }
28407
- const current = this.getEntry(input3.cacheKey);
28408
- const next2 = current?.settled ? Promise.resolve(current.settled.value) : !current || options.retried ? this.createEntry(input3) : this.waitForInFlight(current, input3, { retried: true });
28409
- next2.then(resolve, reject);
28410
- };
28411
- const timer = Number.isFinite(this.inFlightWaitMs) ? setTimeout(() => {
28412
- if (done) return;
28413
- done = true;
28414
- takeOver();
28415
- }, this.inFlightWaitMs) : void 0;
28416
- entry.pending.then(
28417
- (value) => {
28418
- if (done) return;
28419
- done = true;
28420
- clearTimeout(timer);
28421
- resolve(value);
28422
- },
28423
- () => {
28424
- if (done) return;
28425
- done = true;
28426
- clearTimeout(timer);
28427
- takeOver();
28428
- }
28429
- );
28430
- });
28431
- }
28432
- enforceLimit() {
28433
- while (this.cache.size > this.limit) {
28434
- const oldestKey = this.cache.keys().next().value;
28435
- if (oldestKey === void 0) {
28436
- break;
28437
- }
28438
- this.delete(oldestKey);
28439
- }
28440
- }
28441
- };
28442
- }
28443
- });
28444
-
28445
28504
  // ../worker/src/identity/reserved-username-settings.ts
28446
28505
  var reservedUsernamesCacheTtlMs, reservedUsernameRecords;
28447
28506
  var init_reserved_username_settings = __esm({
@@ -29031,11 +29090,11 @@ function memoizeReadPerRequest(input3) {
29031
29090
  if (method !== "GET" && method !== "HEAD") return input3.load();
29032
29091
  return memoizePerRequest(input3);
29033
29092
  }
29034
- function reloadMemo(memo3, key, load) {
29093
+ function reloadMemo(memo2, key, load) {
29035
29094
  const loading = load();
29036
- memo3.set(key, loading);
29095
+ memo2.set(key, loading);
29037
29096
  loading.catch(() => {
29038
- if (memo3.get(key) === loading) memo3.delete(key);
29097
+ if (memo2.get(key) === loading) memo2.delete(key);
29039
29098
  });
29040
29099
  return loading;
29041
29100
  }
@@ -29210,43 +29269,6 @@ var init_store = __esm({
29210
29269
  }
29211
29270
  });
29212
29271
 
29213
- // ../shared/src/isolate-state.ts
29214
- function isolateStateRegistry() {
29215
- const scope = globalThis;
29216
- scope[registryKey] ??= /* @__PURE__ */ new Set();
29217
- return scope[registryKey];
29218
- }
29219
- function isolateState(create, options) {
29220
- const state2 = { current: create() };
29221
- isolateStateRegistry().add({
29222
- reset() {
29223
- state2.current = create();
29224
- },
29225
- pending() {
29226
- return options?.pending?.(state2.current) ?? [];
29227
- }
29228
- });
29229
- return state2;
29230
- }
29231
- function isolateCollection(collection, options) {
29232
- isolateStateRegistry().add({
29233
- reset() {
29234
- collection.clear();
29235
- },
29236
- pending() {
29237
- return options?.pending?.(collection) ?? [];
29238
- }
29239
- });
29240
- return collection;
29241
- }
29242
- var registryKey;
29243
- var init_isolate_state = __esm({
29244
- "../shared/src/isolate-state.ts"() {
29245
- "use strict";
29246
- registryKey = /* @__PURE__ */ Symbol.for("kody.isolate-state");
29247
- }
29248
- });
29249
-
29250
29272
  // ../worker/src/feature-flags/execution-scope.ts
29251
29273
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
29252
29274
  var executionIdleTtlMs, callReadsStorage;
@@ -31841,18 +31863,10 @@ function linkedArtifactGroupPrefix(modulePath) {
31841
31863
  return modulePath.slice(0, start) + segments.slice(0, consumed).join("/");
31842
31864
  }
31843
31865
  async function putOnce(kv, key, value) {
31844
- const now = Date.now();
31845
- const recent = recentWrites.get(key);
31846
- if (recent && recent.expiresAt > now) return await recent.pending;
31847
- if (recentWrites.size >= writtenKeyLimit) recentWrites.clear();
31848
- const pending = kv.put(key, value);
31849
- recentWrites.set(key, { expiresAt: now + writtenKeyTtlMs, pending });
31850
- try {
31851
- await pending;
31852
- } catch (error2) {
31853
- if (recentWrites.get(key)?.pending === pending) recentWrites.delete(key);
31854
- throw error2;
31855
- }
31866
+ await recentWrites.getOrCreate({
31867
+ cacheKey: key,
31868
+ create: () => kv.put(key, value)
31869
+ });
31856
31870
  }
31857
31871
  async function storeLinkedArtifactGroups(input3) {
31858
31872
  const groups = /* @__PURE__ */ new Map();
@@ -31931,13 +31945,15 @@ async function restoreLinkedArtifactGroups(input3) {
31931
31945
  const { linkedArtifacts: _linkedArtifacts, ...rest } = artifact;
31932
31946
  return { ...rest, modules: restored };
31933
31947
  }
31934
- var linkedArtifactStorePrefix, linkedArtifactStoreVersion, linkedArtifactsMarker, fullPathChunk, lastPathChunk, writtenKeyTtlMs, writtenKeyLimit, recentWrites;
31948
+ var linkedArtifactStorePrefix, linkedArtifactStoreVersion, linkedArtifactsMarker, fullPathChunk, lastPathChunk, writtenKeyTtlMs, writtenKeyLimit, writtenKeyInFlightWaitMs, recentWrites;
31935
31949
  var init_linked_artifact_store = __esm({
31936
31950
  "../worker/src/package-runtime/linked-artifact-store.ts"() {
31937
31951
  "use strict";
31938
31952
  init_sha256();
31939
31953
  init_kv_delete();
31940
31954
  init_module_graph_paths();
31955
+ init_isolate_state();
31956
+ init_published_package_cache();
31941
31957
  linkedArtifactStorePrefix = "linked-artifact";
31942
31958
  linkedArtifactStoreVersion = 1;
31943
31959
  linkedArtifactsMarker = `${linkedPackageImportPrefix}/artifacts/`;
@@ -31945,7 +31961,16 @@ var init_linked_artifact_store = __esm({
31945
31961
  lastPathChunk = /^[0-9a-f]{1,95}$/;
31946
31962
  writtenKeyTtlMs = 5 * 6e4;
31947
31963
  writtenKeyLimit = 5e3;
31948
- recentWrites = /* @__PURE__ */ new Map();
31964
+ writtenKeyInFlightWaitMs = 6e4;
31965
+ recentWrites = isolateCollection(
31966
+ new PromiseLruCache({
31967
+ ttlMs: writtenKeyTtlMs,
31968
+ limit: writtenKeyLimit,
31969
+ // A second put of the same key while the first runs hits KV's per-key
31970
+ // write limit; a rejected (orphaned) write is still replaced at once.
31971
+ inFlightWaitMs: writtenKeyInFlightWaitMs
31972
+ })
31973
+ );
31949
31974
  }
31950
31975
  });
31951
31976
 
@@ -40295,7 +40320,7 @@ var require_machineSchemas_88d01821_cjs = __commonJS({
40295
40320
  const descriptor = Object.keys(schemas).find((key) => createActor2.matchesEventDescriptor(eventType, key));
40296
40321
  return descriptor === void 0 ? void 0 : schemas[descriptor];
40297
40322
  }
40298
- function memo3(cache2, key, create) {
40323
+ function memo2(cache2, key, create) {
40299
40324
  let value = cache2.get(key);
40300
40325
  if (!value) {
40301
40326
  cache2.set(key, value = create());
@@ -40306,7 +40331,7 @@ var require_machineSchemas_88d01821_cjs = __commonJS({
40306
40331
  var historicalEventSchemas = /* @__PURE__ */ new WeakMap();
40307
40332
  var eventSchemas = /* @__PURE__ */ new WeakMap();
40308
40333
  function snapshotSchema(machine) {
40309
- return memo3(snapshotSchemas, machine, () => ({
40334
+ return memo2(snapshotSchemas, machine, () => ({
40310
40335
  "~standard": {
40311
40336
  version: 1,
40312
40337
  vendor: "xstate",
@@ -40379,7 +40404,7 @@ var require_machineSchemas_88d01821_cjs = __commonJS({
40379
40404
  }));
40380
40405
  }
40381
40406
  function historicalEventSchema(machine) {
40382
- return memo3(historicalEventSchemas, machine, () => ({
40407
+ return memo2(historicalEventSchemas, machine, () => ({
40383
40408
  "~standard": {
40384
40409
  version: 1,
40385
40410
  vendor: "xstate",
@@ -40434,7 +40459,7 @@ var require_machineSchemas_88d01821_cjs = __commonJS({
40434
40459
  }));
40435
40460
  }
40436
40461
  function eventSchema2(machine) {
40437
- return memo3(eventSchemas, machine, () => ({
40462
+ return memo2(eventSchemas, machine, () => ({
40438
40463
  "~standard": {
40439
40464
  version: 1,
40440
40465
  vendor: "xstate",
@@ -43683,18 +43708,14 @@ var init_artifacts_git_retry = __esm({
43683
43708
  });
43684
43709
 
43685
43710
  // ../worker/src/isomorphic-git-load.ts
43686
- function loadIsomorphicGit() {
43687
- memo2 ??= import("./node_modules/.kody-generated/isomorphic-git.mjs").catch((error2) => {
43688
- memo2 = null;
43689
- throw error2;
43690
- });
43691
- return memo2;
43692
- }
43693
- var memo2;
43711
+ var loadIsomorphicGit;
43694
43712
  var init_isomorphic_git_load = __esm({
43695
43713
  "../worker/src/isomorphic-git-load.ts"() {
43696
43714
  "use strict";
43697
- memo2 = null;
43715
+ init_isolate_memo();
43716
+ loadIsomorphicGit = isolateMemo(
43717
+ () => import("./node_modules/.kody-generated/isomorphic-git.mjs")
43718
+ );
43698
43719
  }
43699
43720
  });
43700
43721
 
@@ -198993,13 +199014,22 @@ var init_allowed_packages = __esm({
198993
199014
  });
198994
199015
 
198995
199016
  // ../worker/src/mcp/secrets/crypto.ts
198996
- var textEncoder2, textDecoder;
199017
+ var textEncoder2, textDecoder, derivedEncryptionKeys;
198997
199018
  var init_crypto = __esm({
198998
199019
  "../worker/src/mcp/secrets/crypto.ts"() {
198999
199020
  "use strict";
199000
199021
  init_base64();
199022
+ init_isolate_memo();
199001
199023
  textEncoder2 = new TextEncoder();
199002
199024
  textDecoder = new TextDecoder();
199025
+ derivedEncryptionKeys = isolateMemoByKey(
199026
+ (cacheKey) => crypto.subtle.digest("SHA-256", textEncoder2.encode(cacheKey)).then(
199027
+ (digest) => crypto.subtle.importKey("raw", digest, "AES-GCM", false, [
199028
+ "encrypt",
199029
+ "decrypt"
199030
+ ])
199031
+ )
199032
+ );
199003
199033
  }
199004
199034
  });
199005
199035
 
@@ -199361,6 +199391,7 @@ var init_plans = __esm({
199361
199391
  // Concurrent active runs (not lifetime or daily). One at a time on
199362
199392
  // free; a second deferred workflow is the upgrade nudge.
199363
199393
  maxConcurrentWorkflows: 1,
199394
+ maxExecutionContextsPerSeat: 10,
199364
199395
  // Unique execute workers are the Dynamic Worker bill. Daily headroom
199365
199396
  // covers a bursty agent morning; the weekly total keeps a free account
199366
199397
  // from spending a full week of that headroom every day.
@@ -199389,6 +199420,7 @@ var init_plans = __esm({
199389
199420
  maxSecrets: 100,
199390
199421
  maxStorageBytes: 1024 * 1024 * 1024,
199391
199422
  maxConcurrentWorkflows: 10,
199423
+ maxExecutionContextsPerSeat: 20,
199392
199424
  // Public Standard execute is a try-paid rung with bursty daily
199393
199425
  // headroom and a weekly total. Continuous pre-cut subscribers keep
199394
199426
  // {@link legacyPlanLimits} (daily-only, no weekly window).
@@ -199417,6 +199449,7 @@ var init_plans = __esm({
199417
199449
  maxSecrets: 200,
199418
199450
  maxStorageBytes: 5 * 1024 * 1024 * 1024,
199419
199451
  maxConcurrentWorkflows: 50,
199452
+ maxExecutionContextsPerSeat: 20,
199420
199453
  // Retired $49 Pro. Execute is a hard daily + weekly cap.
199421
199454
  maxExecuteUniqueWorkersPerDay: 1500,
199422
199455
  maxExecuteUniqueWorkersPerWeek: 4e3,
@@ -199451,6 +199484,7 @@ var init_plans = __esm({
199451
199484
  maxStorageBytes: 100 * 1024 * 1024 * 1024,
199452
199485
  // 2× pro (100). Observed concurrent ~35.
199453
199486
  maxConcurrentWorkflows: 200,
199487
+ maxExecutionContextsPerSeat: 50,
199454
199488
  // Operator runaway cap. kentcdodds August 2026 rollup avg ~3,800
199455
199489
  // execute/day (116k/month); entitlement meter today ~1,810. Daily
199456
199490
  // peak is not stored; 25,000 is at least 2× a ~12,500 peak (~3×
@@ -199489,6 +199523,7 @@ var init_plans = __esm({
199489
199523
  maxSecrets: 100,
199490
199524
  maxStorageBytes: 1024 * 1024 * 1024,
199491
199525
  maxConcurrentWorkflows: 50,
199526
+ maxExecutionContextsPerSeat: 20,
199492
199527
  maxExecuteUniqueWorkersPerDay: 500,
199493
199528
  maxExecuteUniqueWorkersPerWeek: null,
199494
199529
  maxOutboundFetchesPerDay: 2e4,
@@ -199513,6 +199548,7 @@ var init_plans = __esm({
199513
199548
  maxSecrets: 200,
199514
199549
  maxStorageBytes: 5 * 1024 * 1024 * 1024,
199515
199550
  maxConcurrentWorkflows: 100,
199551
+ maxExecutionContextsPerSeat: 20,
199516
199552
  maxExecuteUniqueWorkersPerDay: 800,
199517
199553
  maxExecuteUniqueWorkersPerWeek: null,
199518
199554
  maxOutboundFetchesPerDay: 4e4,
@@ -199900,7 +199936,9 @@ var init_errors4 = __esm({
199900
199936
  "use strict";
199901
199937
  init_compute_overage();
199902
199938
  init_date_keys();
199939
+ init_org_pages();
199903
199940
  init_prefer_local_cli_execute();
199941
+ init_routes();
199904
199942
  init_plans();
199905
199943
  minuteMs = 60 * 1e3;
199906
199944
  }
@@ -203303,9 +203341,16 @@ var init_rejecting_providers = __esm({
203303
203341
  });
203304
203342
 
203305
203343
  // ../worker/src/disposable-email-domains-load.ts
203344
+ var loadDisposableEmailDomains;
203306
203345
  var init_disposable_email_domains_load = __esm({
203307
203346
  "../worker/src/disposable-email-domains-load.ts"() {
203308
203347
  "use strict";
203348
+ init_isolate_memo();
203349
+ loadDisposableEmailDomains = isolateMemo(
203350
+ () => import("./node_modules/.kody-generated/disposable-email-domains.mjs").then(
203351
+ (module) => new Set(module.disposableEmailDomainList)
203352
+ )
203353
+ );
203309
203354
  }
203310
203355
  });
203311
203356
 
@@ -203477,9 +203522,9 @@ var init_d1_storage_reconciliation = __esm({
203477
203522
  "use strict";
203478
203523
  init_isolate_state();
203479
203524
  init_service5();
203525
+ init_published_package_cache();
203480
203526
  inFlightOwnerReconciles = isolateCollection(
203481
- /* @__PURE__ */ new Map(),
203482
- { pending: (tasks) => tasks.values() }
203527
+ new PromiseLruCache({ retainSettled: false })
203483
203528
  );
203484
203529
  }
203485
203530
  });