@kodycodes/cli 3.48.4 → 3.48.6

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.
@@ -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(
@@ -11179,7 +11179,7 @@ function packageMachineNeedsFor(needs, name) {
11179
11179
  const entry = needs && Object.hasOwn(needs, name) ? needs[name] : void 0;
11180
11180
  return entry === void 0 ? [] : Array.isArray(entry) ? entry : [entry];
11181
11181
  }
11182
- var kodyPackageIdPattern, packageJobScheduleSchema, packageJobDefinitionSchema, packageAppClientExternalSchema, packageAppClientDefinitionSchema, packageCredentialSlotNamePattern, packageAppCapabilityNamePattern, mcpToolCapabilitySegment, packageMcpToolCapabilityNamePattern, packageCapabilityDeclarationsSchema, packageAppVisitorNeedKeyPattern, packageAppVisitorNeedSchema, packageAppAnonymousRealtimeModes, packageAppDefinitionSchema, packageSecretMountDefinitionSchema, packageSecretProviderIdPattern, packageSecretProviderSchema, packageCredentialKindValues, secretProviderSlotKind, packageCredentialSlotKindValues, ownerCredentialForVisitorsValueMessage, packageCredentialSlotSchema, packageCredentialsSchema, secretProviderSlotPackagePattern, secretProviderSlotOnlyFields, packageSubscriptionDefinitionSchema, httpFieldNamePattern2, webhookSignedPayloadValues, webhookTimestampFormatValues, packageWebhookHmacVerificationSchema, packageWebhookUrlSecretVerificationSchema, packageWebhookVerificationSchema, webhookChallengeParamKeySchema, webhookChallengeWhenValueSchema, packageWebhookSubscriptionChallengeSchema, packageWebhookChallengeSchema, webhookTimestampFormatSchema, packageWebhookReplaySchema, webhookInputModeValues, webhookMaxRateLimitPerMinute, packageWebhookDefinitionSchema, packageWebhooksSchema, packageEmittedEventDefinitionSchema, packageExportConditionSchema, packageExportTargetSchema, scopedPackageNamePattern, kodyPackageDependencySchema, kodyPackageDependencyWildcard, kodyPackageDependenciesSchema, KODY_DESCRIPTION_MAX_LENGTH, kodyDescriptionTooLongPhrase, packagePublishDefinitionSchema, packageMachineNeedNamePattern, maxPackageMachineNeeds, machineNeedDescription, packageMachineNeedSchema, packageMachineNeedListSchema, packageMachineNeedEntrySchema, packageMachineNeedsSchema, authoredPackageKodySchema, authoredPackageJsonSchema;
11182
+ var kodyPackageIdPattern, packageJobScheduleSchema, packageJobDefinitionSchema, packageAppClientExternalSchema, packageAppClientDefinitionSchema, packageCredentialSlotNamePattern, packageAppCapabilityNamePattern, mcpToolCapabilitySegment, packageMcpToolCapabilityNamePattern, packageCapabilityDeclarationsSchema, packageAppVisitorNeedKeyPattern, packageAppVisitorNeedSchema, packageAppAnonymousRealtimeModes, packageAppPathSchema, packageAppDefinitionSchema, packageSecretMountDefinitionSchema, packageSecretProviderIdPattern, packageSecretProviderSchema, packageCredentialKindValues, secretProviderSlotKind, packageCredentialSlotKindValues, ownerCredentialForVisitorsValueMessage, packageCredentialSlotSchema, packageCredentialsSchema, secretProviderSlotPackagePattern, secretProviderSlotOnlyFields, packageSubscriptionDefinitionSchema, httpFieldNamePattern2, webhookSignedPayloadValues, webhookTimestampFormatValues, packageWebhookHmacVerificationSchema, packageWebhookUrlSecretVerificationSchema, packageWebhookVerificationSchema, webhookChallengeParamKeySchema, webhookChallengeWhenValueSchema, packageWebhookSubscriptionChallengeSchema, packageWebhookChallengeSchema, webhookTimestampFormatSchema, packageWebhookReplaySchema, webhookInputModeValues, webhookMaxRateLimitPerMinute, packageWebhookDefinitionSchema, packageWebhooksSchema, packageEmittedEventDefinitionSchema, packageExportConditionSchema, packageExportTargetSchema, scopedPackageNamePattern, kodyPackageDependencySchema, kodyPackageDependencyWildcard, kodyPackageDependenciesSchema, KODY_DESCRIPTION_MAX_LENGTH, kodyDescriptionTooLongPhrase, packagePublishDefinitionSchema, packageMachineNeedNamePattern, maxPackageMachineNeeds, machineNeedDescription, packageMachineNeedSchema, packageMachineNeedListSchema, packageMachineNeedEntrySchema, packageMachineNeedsSchema, authoredPackageKodySchema, authoredPackageJsonSchema;
11183
11183
  var init_types = __esm({
11184
11184
  "../worker/src/package-registry/types.ts"() {
11185
11185
  "use strict";
@@ -11255,6 +11255,7 @@ var init_types = __esm({
11255
11255
  }
11256
11256
  );
11257
11257
  packageAppAnonymousRealtimeModes = ["receive", "two-way"];
11258
+ packageAppPathSchema = external_exports.string().trim().max(512).regex(/^\/(?!\/)[^\s\\]*$/, "Use a path inside the app, like /menubar.");
11258
11259
  packageAppDefinitionSchema = external_exports.object({
11259
11260
  /**
11260
11261
  * Server entry bundled for the package-app isolate. The default export
@@ -11309,6 +11310,19 @@ var init_types = __esm({
11309
11310
  */
11310
11311
  realtime: external_exports.strictObject({
11311
11312
  anonymous: external_exports.enum(packageAppAnonymousRealtimeModes).optional()
11313
+ }).optional(),
11314
+ /**
11315
+ * Kody desktop app install settings. `icon` is a path the app serves (like
11316
+ * `/icons/icon-512.png`) used for the launcher instead of `.kody/icon`.
11317
+ * `menuBar` is a page the desktop app offers as a menu-bar popover after
11318
+ * install, once the person grants the menu bar permission.
11319
+ */
11320
+ desktop: external_exports.strictObject({
11321
+ icon: packageAppPathSchema.optional(),
11322
+ menuBar: external_exports.strictObject({
11323
+ path: packageAppPathSchema,
11324
+ tooltip: external_exports.string().trim().min(1).max(120).optional()
11325
+ }).optional()
11312
11326
  }).optional()
11313
11327
  });
11314
11328
  packageSecretMountDefinitionSchema = external_exports.object({
@@ -12349,6 +12363,378 @@ var init_published_source_dependencies = __esm({
12349
12363
  }
12350
12364
  });
12351
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
+
12352
12738
  // ../../node_modules/@babel/parser/lib/index.js
12353
12739
  function createPositionWithColumnOffset(position, columnOffset) {
12354
12740
  const {
@@ -26654,16 +27040,6 @@ var init_module_source_parser_module = __esm({
26654
27040
  });
26655
27041
 
26656
27042
  // ../worker/src/module-source.ts
26657
- function loadModuleSourceParser() {
26658
- parserMemo ??= Promise.resolve().then(() => (init_module_source_parser_module(), module_source_parser_module_exports)).then(
26659
- (module) => createModuleSourceParser(module.parse),
26660
- (error2) => {
26661
- parserMemo = null;
26662
- throw error2;
26663
- }
26664
- );
26665
- return parserMemo;
26666
- }
26667
27043
  function moduleSourceParserPlugins(filePath) {
26668
27044
  const extension = /\.([cm]?[jt]sx?)$/i.exec(filePath ?? "")?.[1]?.toLowerCase();
26669
27045
  switch (extension) {
@@ -26724,11 +27100,16 @@ function createModuleSourceParser(parse10) {
26724
27100
  }
26725
27101
  return { parseModuleSource: parseModuleSource2, parseModuleSourceAllowingTypeAssertions: parseModuleSourceAllowingTypeAssertions2 };
26726
27102
  }
26727
- var parserMemo, typeScriptPlugins, typeScriptJsxPlugins, jsxPlugins, plainJavaScriptPlugins, fallbackParserPlugins;
27103
+ var loadModuleSourceParser, typeScriptPlugins, typeScriptJsxPlugins, jsxPlugins, plainJavaScriptPlugins, fallbackParserPlugins;
26728
27104
  var init_module_source = __esm({
26729
27105
  "../worker/src/module-source.ts"() {
26730
27106
  "use strict";
26731
- 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
+ );
26732
27113
  typeScriptPlugins = ["typescript"];
26733
27114
  typeScriptJsxPlugins = ["typescript", "jsx"];
26734
27115
  jsxPlugins = ["jsx"];
@@ -28120,314 +28501,6 @@ var init_reserved_usernames2 = __esm({
28120
28501
  }
28121
28502
  });
28122
28503
 
28123
- // ../worker/src/package-registry/published-package-cache.ts
28124
- function createPublishedPackageCacheKey(input3) {
28125
- if (!input3.source.published_commit) {
28126
- return null;
28127
- }
28128
- return JSON.stringify([
28129
- input3.userId,
28130
- input3.source.id,
28131
- input3.source.published_commit,
28132
- input3.source.manifest_path,
28133
- input3.source.source_root,
28134
- input3.entryPoint?.trim() || null
28135
- ]);
28136
- }
28137
- function estimateRetainedBytes(value) {
28138
- const seen = /* @__PURE__ */ new Set();
28139
- const stack = [value];
28140
- let bytes = 0;
28141
- while (stack.length > 0) {
28142
- const next2 = stack.pop();
28143
- if (typeof next2 === "string") {
28144
- bytes += next2.length;
28145
- continue;
28146
- }
28147
- if (next2 === null || typeof next2 !== "object" || seen.has(next2)) {
28148
- continue;
28149
- }
28150
- seen.add(next2);
28151
- if (ArrayBuffer.isView(next2) || next2 instanceof ArrayBuffer) {
28152
- bytes += next2.byteLength;
28153
- continue;
28154
- }
28155
- if (Array.isArray(next2)) {
28156
- stack.push(...next2);
28157
- continue;
28158
- }
28159
- const prototype = Object.getPrototypeOf(next2);
28160
- if (prototype !== Object.prototype && prototype !== null) {
28161
- continue;
28162
- }
28163
- for (const [key, child] of Object.entries(next2)) {
28164
- bytes += key.length;
28165
- stack.push(child);
28166
- }
28167
- }
28168
- return bytes;
28169
- }
28170
- function createPromiseLruCacheByBinding(options) {
28171
- const caches = /* @__PURE__ */ new WeakMap();
28172
- return {
28173
- for(binding) {
28174
- let cache = caches.get(binding);
28175
- if (!cache) {
28176
- cache = new PromiseLruCache(options);
28177
- caches.set(binding, cache);
28178
- }
28179
- return cache;
28180
- },
28181
- clear(binding) {
28182
- caches.get(binding)?.clear();
28183
- }
28184
- };
28185
- }
28186
- function createPublishedPackagePromiseCache() {
28187
- return new PromiseLruCache({ byteBudget: packageArtifactCacheBudget });
28188
- }
28189
- var publishedPackageCacheLimit, publishedPackageCacheTtlMs, promiseLruCacheInFlightWaitMs, RetainedByteBudget, packageArtifactCacheMaxBytes, packageArtifactCacheBudget, PromiseLruCache;
28190
- var init_published_package_cache = __esm({
28191
- "../worker/src/package-registry/published-package-cache.ts"() {
28192
- "use strict";
28193
- publishedPackageCacheLimit = 50;
28194
- publishedPackageCacheTtlMs = 5 * 60 * 1e3;
28195
- promiseLruCacheInFlightWaitMs = 5e3;
28196
- RetainedByteBudget = class {
28197
- constructor(maxBytes) {
28198
- this.maxBytes = maxBytes;
28199
- }
28200
- maxBytes;
28201
- caches = /* @__PURE__ */ new Set();
28202
- usedBytes = 0;
28203
- clock = 0;
28204
- get retainedBytes() {
28205
- return this.usedBytes;
28206
- }
28207
- /** @internal */
28208
- tick() {
28209
- this.clock += 1;
28210
- return this.clock;
28211
- }
28212
- /** @internal */
28213
- register(cache) {
28214
- this.caches.add(cache);
28215
- }
28216
- /** @internal */
28217
- adjust(delta) {
28218
- this.usedBytes += delta;
28219
- }
28220
- /** @internal */
28221
- enforce() {
28222
- while (this.usedBytes > this.maxBytes) {
28223
- let oldest = null;
28224
- let oldestUsed = Number.POSITIVE_INFINITY;
28225
- for (const cache of this.caches) {
28226
- const candidate = cache.oldestSizedEntry();
28227
- if (candidate && candidate.lastUsed < oldestUsed) {
28228
- oldestUsed = candidate.lastUsed;
28229
- oldest = { cache, key: candidate.key };
28230
- }
28231
- }
28232
- if (!oldest) {
28233
- break;
28234
- }
28235
- oldest.cache.delete(oldest.key);
28236
- }
28237
- }
28238
- };
28239
- packageArtifactCacheMaxBytes = 24 * 1024 * 1024;
28240
- packageArtifactCacheBudget = new RetainedByteBudget(
28241
- packageArtifactCacheMaxBytes
28242
- );
28243
- PromiseLruCache = class {
28244
- cache = /* @__PURE__ */ new Map();
28245
- constructor(input3) {
28246
- this.ttlMs = input3?.ttlMs ?? publishedPackageCacheTtlMs;
28247
- this.limit = input3?.limit ?? publishedPackageCacheLimit;
28248
- this.inFlightWaitMs = input3?.inFlightWaitMs ?? promiseLruCacheInFlightWaitMs;
28249
- this.byteBudget = input3?.byteBudget ?? null;
28250
- this.sizeOf = input3?.sizeOf ?? estimateRetainedBytes;
28251
- this.retainSettled = input3?.retainSettled ?? true;
28252
- this.byteBudget?.register(this);
28253
- }
28254
- ttlMs;
28255
- limit;
28256
- inFlightWaitMs;
28257
- byteBudget;
28258
- sizeOf;
28259
- retainSettled;
28260
- /** @internal Least recently used settled entry that holds sized bytes. */
28261
- oldestSizedEntry() {
28262
- for (const [key, entry] of this.cache) {
28263
- if (entry.bytes > 0) {
28264
- return { key, lastUsed: entry.lastUsed };
28265
- }
28266
- }
28267
- return null;
28268
- }
28269
- touch(entry) {
28270
- if (this.byteBudget) {
28271
- entry.lastUsed = this.byteBudget.tick();
28272
- }
28273
- }
28274
- getEntry(key) {
28275
- const cached2 = this.cache.get(key);
28276
- if (!cached2) {
28277
- return null;
28278
- }
28279
- if (cached2.expiresAt <= Date.now()) {
28280
- this.delete(key);
28281
- return null;
28282
- }
28283
- this.cache.delete(key);
28284
- this.cache.set(key, cached2);
28285
- this.touch(cached2);
28286
- return cached2;
28287
- }
28288
- /**
28289
- * A settled value, as a promise owned by the caller's request. Never
28290
- * another request's in-flight promise: use `getOrCreate` to wait on one.
28291
- */
28292
- get(key) {
28293
- const settled = this.getEntry(key)?.settled;
28294
- return settled ? Promise.resolve(settled.value) : null;
28295
- }
28296
- set(key, pending) {
28297
- const entry = {
28298
- expiresAt: Date.now() + this.ttlMs,
28299
- pending,
28300
- settled: null,
28301
- bytes: 0,
28302
- lastUsed: 0
28303
- };
28304
- this.delete(key);
28305
- this.cache.set(key, entry);
28306
- this.touch(entry);
28307
- void pending.then(
28308
- (value) => {
28309
- if (!this.retainSettled) {
28310
- if (this.cache.get(key) === entry) this.delete(key);
28311
- return;
28312
- }
28313
- entry.settled = { value };
28314
- this.recordSize(key, entry, value);
28315
- },
28316
- () => {
28317
- }
28318
- );
28319
- this.enforceLimit();
28320
- return pending;
28321
- }
28322
- getOrCreate(input3) {
28323
- const cached2 = this.getEntry(input3.cacheKey);
28324
- if (cached2?.settled) {
28325
- return Promise.resolve(cached2.settled.value);
28326
- }
28327
- if (cached2) {
28328
- return this.waitForInFlight(cached2, input3, { retried: false });
28329
- }
28330
- return this.createEntry(input3);
28331
- }
28332
- delete(key) {
28333
- const entry = this.cache.get(key);
28334
- if (!entry) {
28335
- return;
28336
- }
28337
- this.cache.delete(key);
28338
- if (entry.bytes > 0) {
28339
- this.byteBudget?.adjust(-entry.bytes);
28340
- entry.bytes = 0;
28341
- }
28342
- }
28343
- /** Drop every entry whose key matches, e.g. one owner's prefix. */
28344
- deleteWhere(matches) {
28345
- for (const key of [...this.cache.keys()]) {
28346
- if (matches(key)) this.delete(key);
28347
- }
28348
- }
28349
- clear() {
28350
- this.deleteWhere(() => true);
28351
- }
28352
- recordSize(key, entry, value) {
28353
- const budget = this.byteBudget;
28354
- if (!budget || this.cache.get(key) !== entry) {
28355
- return;
28356
- }
28357
- const bytes = Math.max(1, this.sizeOf(value));
28358
- if (bytes > budget.maxBytes) {
28359
- this.delete(key);
28360
- return;
28361
- }
28362
- entry.bytes = bytes;
28363
- budget.adjust(bytes);
28364
- budget.enforce();
28365
- }
28366
- createEntry(input3) {
28367
- let pending;
28368
- pending = input3.create().catch((error2) => {
28369
- if (this.cache.get(input3.cacheKey)?.pending === pending) {
28370
- this.delete(input3.cacheKey);
28371
- }
28372
- throw error2;
28373
- });
28374
- this.set(input3.cacheKey, pending);
28375
- return pending;
28376
- }
28377
- /**
28378
- * Await an entry another request may own. If it has not settled within
28379
- * `inFlightWaitMs`, or it rejects, treat it as orphaned: replace it (when
28380
- * it is still the cached entry) and run `create()` in this request. The
28381
- * owner may have ended, and its failure is not this request's. A waiter
28382
- * shares at most one other rebuild; if that one also fails or stalls, it
28383
- * runs its own `create()`, so the only rejection a caller sees is one
28384
- * from a `create()` it ran.
28385
- */
28386
- waitForInFlight(entry, input3, options) {
28387
- return new Promise((resolve, reject) => {
28388
- let done = false;
28389
- const takeOver = () => {
28390
- if (this.cache.get(input3.cacheKey) === entry) {
28391
- this.delete(input3.cacheKey);
28392
- }
28393
- const current = this.getEntry(input3.cacheKey);
28394
- const next2 = current?.settled ? Promise.resolve(current.settled.value) : !current || options.retried ? this.createEntry(input3) : this.waitForInFlight(current, input3, { retried: true });
28395
- next2.then(resolve, reject);
28396
- };
28397
- const timer = Number.isFinite(this.inFlightWaitMs) ? setTimeout(() => {
28398
- if (done) return;
28399
- done = true;
28400
- takeOver();
28401
- }, this.inFlightWaitMs) : void 0;
28402
- entry.pending.then(
28403
- (value) => {
28404
- if (done) return;
28405
- done = true;
28406
- clearTimeout(timer);
28407
- resolve(value);
28408
- },
28409
- () => {
28410
- if (done) return;
28411
- done = true;
28412
- clearTimeout(timer);
28413
- takeOver();
28414
- }
28415
- );
28416
- });
28417
- }
28418
- enforceLimit() {
28419
- while (this.cache.size > this.limit) {
28420
- const oldestKey = this.cache.keys().next().value;
28421
- if (oldestKey === void 0) {
28422
- break;
28423
- }
28424
- this.delete(oldestKey);
28425
- }
28426
- }
28427
- };
28428
- }
28429
- });
28430
-
28431
28504
  // ../worker/src/identity/reserved-username-settings.ts
28432
28505
  var reservedUsernamesCacheTtlMs, reservedUsernameRecords;
28433
28506
  var init_reserved_username_settings = __esm({
@@ -29017,11 +29090,11 @@ function memoizeReadPerRequest(input3) {
29017
29090
  if (method !== "GET" && method !== "HEAD") return input3.load();
29018
29091
  return memoizePerRequest(input3);
29019
29092
  }
29020
- function reloadMemo(memo3, key, load) {
29093
+ function reloadMemo(memo2, key, load) {
29021
29094
  const loading = load();
29022
- memo3.set(key, loading);
29095
+ memo2.set(key, loading);
29023
29096
  loading.catch(() => {
29024
- if (memo3.get(key) === loading) memo3.delete(key);
29097
+ if (memo2.get(key) === loading) memo2.delete(key);
29025
29098
  });
29026
29099
  return loading;
29027
29100
  }
@@ -29196,43 +29269,6 @@ var init_store = __esm({
29196
29269
  }
29197
29270
  });
29198
29271
 
29199
- // ../shared/src/isolate-state.ts
29200
- function isolateStateRegistry() {
29201
- const scope = globalThis;
29202
- scope[registryKey] ??= /* @__PURE__ */ new Set();
29203
- return scope[registryKey];
29204
- }
29205
- function isolateState(create, options) {
29206
- const state2 = { current: create() };
29207
- isolateStateRegistry().add({
29208
- reset() {
29209
- state2.current = create();
29210
- },
29211
- pending() {
29212
- return options?.pending?.(state2.current) ?? [];
29213
- }
29214
- });
29215
- return state2;
29216
- }
29217
- function isolateCollection(collection, options) {
29218
- isolateStateRegistry().add({
29219
- reset() {
29220
- collection.clear();
29221
- },
29222
- pending() {
29223
- return options?.pending?.(collection) ?? [];
29224
- }
29225
- });
29226
- return collection;
29227
- }
29228
- var registryKey;
29229
- var init_isolate_state = __esm({
29230
- "../shared/src/isolate-state.ts"() {
29231
- "use strict";
29232
- registryKey = /* @__PURE__ */ Symbol.for("kody.isolate-state");
29233
- }
29234
- });
29235
-
29236
29272
  // ../worker/src/feature-flags/execution-scope.ts
29237
29273
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
29238
29274
  var executionIdleTtlMs, callReadsStorage;
@@ -29388,6 +29424,15 @@ var init_registry = __esm({
29388
29424
  description: "Global switch (audience and rollout are ignored) for the issue #4129 30-day safety window before allowed-packages enforcement cutover. While on and inside the window, nothing is refused for a self-authored or adopted package that a user credential's non-empty allowed-packages list leaves out. The use is allowed with a log line (credential_allowed_packages_safety_window_allow) and keeps its would-block marker; the allowed-packages list is never written, so an owner's removal sticks. The owner is never notified. From cutover the rule is strict whether or not this flag is on. Delete the flag and gate sites once the window has closed."
29389
29425
  // Intentionally no successMetric: a credential authority boundary, not
29390
29426
  // a product experiment; the readout is the safety_window_allow log lines and would-block markers.
29427
+ },
29428
+ {
29429
+ key: "desktop-install-package-apps",
29430
+ removeWhen: "Installing package apps as desktop apps is on for everyone, or we drop it; delete the flag and every gate site.",
29431
+ reviewBy: "2027-02-25",
29432
+ defaultEnabled: false,
29433
+ description: "Install package apps as desktop apps: the Install control on package pages and hosted apps, per-app windows and OS launchers in the Kody desktop shell, kody://app links, and the permissioned app desktop bridge. Off by default; dogfood with org overrides. Anonymous visitors always see it off. When off, Install is hidden, kody://app install links are ignored, and installed app windows get no desktop bridge."
29434
+ // Intentionally no successMetric yet: no usage event records installs.
29435
+ // Add one when install is instrumented.
29391
29436
  }
29392
29437
  ];
29393
29438
  featureFlagKeys = featureFlagDefinitions.map((definition) => definition.key);
@@ -31764,6 +31809,37 @@ var init_published_source_files = __esm({
31764
31809
  }
31765
31810
  });
31766
31811
 
31812
+ // ../worker/src/concurrency.ts
31813
+ async function mapWithConcurrency(items, concurrency, mapper) {
31814
+ if (items.length === 0) return [];
31815
+ const limit = Math.max(1, Math.min(Math.floor(concurrency), items.length));
31816
+ const results = Array.from({ length: items.length });
31817
+ let nextIndex = 0;
31818
+ await Promise.all(
31819
+ Array.from({ length: limit }, async () => {
31820
+ while (nextIndex < items.length) {
31821
+ const index = nextIndex;
31822
+ nextIndex += 1;
31823
+ results[index] = await mapper(items[index]);
31824
+ }
31825
+ })
31826
+ );
31827
+ return results;
31828
+ }
31829
+ var init_concurrency = __esm({
31830
+ "../worker/src/concurrency.ts"() {
31831
+ "use strict";
31832
+ }
31833
+ });
31834
+
31835
+ // ../worker/src/kv-delete.ts
31836
+ var init_kv_delete = __esm({
31837
+ "../worker/src/kv-delete.ts"() {
31838
+ "use strict";
31839
+ init_concurrency();
31840
+ }
31841
+ });
31842
+
31767
31843
  // ../worker/src/package-runtime/linked-artifact-store.ts
31768
31844
  function linkedArtifactSourceKvPrefix(sourceId) {
31769
31845
  return `${linkedArtifactStorePrefix}:v${linkedArtifactStoreVersion}:${sourceId}:`;
@@ -31787,18 +31863,10 @@ function linkedArtifactGroupPrefix(modulePath) {
31787
31863
  return modulePath.slice(0, start) + segments.slice(0, consumed).join("/");
31788
31864
  }
31789
31865
  async function putOnce(kv, key, value) {
31790
- const now = Date.now();
31791
- const recent = recentWrites.get(key);
31792
- if (recent && recent.expiresAt > now) return await recent.pending;
31793
- if (recentWrites.size >= writtenKeyLimit) recentWrites.clear();
31794
- const pending = kv.put(key, value);
31795
- recentWrites.set(key, { expiresAt: now + writtenKeyTtlMs, pending });
31796
- try {
31797
- await pending;
31798
- } catch (error2) {
31799
- if (recentWrites.get(key)?.pending === pending) recentWrites.delete(key);
31800
- throw error2;
31801
- }
31866
+ await recentWrites.getOrCreate({
31867
+ cacheKey: key,
31868
+ create: () => kv.put(key, value)
31869
+ });
31802
31870
  }
31803
31871
  async function storeLinkedArtifactGroups(input3) {
31804
31872
  const groups = /* @__PURE__ */ new Map();
@@ -31877,12 +31945,15 @@ async function restoreLinkedArtifactGroups(input3) {
31877
31945
  const { linkedArtifacts: _linkedArtifacts, ...rest } = artifact;
31878
31946
  return { ...rest, modules: restored };
31879
31947
  }
31880
- var linkedArtifactStorePrefix, linkedArtifactStoreVersion, linkedArtifactsMarker, fullPathChunk, lastPathChunk, writtenKeyTtlMs, writtenKeyLimit, recentWrites;
31948
+ var linkedArtifactStorePrefix, linkedArtifactStoreVersion, linkedArtifactsMarker, fullPathChunk, lastPathChunk, writtenKeyTtlMs, writtenKeyLimit, writtenKeyInFlightWaitMs, recentWrites;
31881
31949
  var init_linked_artifact_store = __esm({
31882
31950
  "../worker/src/package-runtime/linked-artifact-store.ts"() {
31883
31951
  "use strict";
31884
31952
  init_sha256();
31953
+ init_kv_delete();
31885
31954
  init_module_graph_paths();
31955
+ init_isolate_state();
31956
+ init_published_package_cache();
31886
31957
  linkedArtifactStorePrefix = "linked-artifact";
31887
31958
  linkedArtifactStoreVersion = 1;
31888
31959
  linkedArtifactsMarker = `${linkedPackageImportPrefix}/artifacts/`;
@@ -31890,7 +31961,16 @@ var init_linked_artifact_store = __esm({
31890
31961
  lastPathChunk = /^[0-9a-f]{1,95}$/;
31891
31962
  writtenKeyTtlMs = 5 * 6e4;
31892
31963
  writtenKeyLimit = 5e3;
31893
- 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
+ );
31894
31974
  }
31895
31975
  });
31896
31976
 
@@ -40240,7 +40320,7 @@ var require_machineSchemas_88d01821_cjs = __commonJS({
40240
40320
  const descriptor = Object.keys(schemas).find((key) => createActor2.matchesEventDescriptor(eventType, key));
40241
40321
  return descriptor === void 0 ? void 0 : schemas[descriptor];
40242
40322
  }
40243
- function memo3(cache2, key, create) {
40323
+ function memo2(cache2, key, create) {
40244
40324
  let value = cache2.get(key);
40245
40325
  if (!value) {
40246
40326
  cache2.set(key, value = create());
@@ -40251,7 +40331,7 @@ var require_machineSchemas_88d01821_cjs = __commonJS({
40251
40331
  var historicalEventSchemas = /* @__PURE__ */ new WeakMap();
40252
40332
  var eventSchemas = /* @__PURE__ */ new WeakMap();
40253
40333
  function snapshotSchema(machine) {
40254
- return memo3(snapshotSchemas, machine, () => ({
40334
+ return memo2(snapshotSchemas, machine, () => ({
40255
40335
  "~standard": {
40256
40336
  version: 1,
40257
40337
  vendor: "xstate",
@@ -40324,7 +40404,7 @@ var require_machineSchemas_88d01821_cjs = __commonJS({
40324
40404
  }));
40325
40405
  }
40326
40406
  function historicalEventSchema(machine) {
40327
- return memo3(historicalEventSchemas, machine, () => ({
40407
+ return memo2(historicalEventSchemas, machine, () => ({
40328
40408
  "~standard": {
40329
40409
  version: 1,
40330
40410
  vendor: "xstate",
@@ -40379,7 +40459,7 @@ var require_machineSchemas_88d01821_cjs = __commonJS({
40379
40459
  }));
40380
40460
  }
40381
40461
  function eventSchema2(machine) {
40382
- return memo3(eventSchemas, machine, () => ({
40462
+ return memo2(eventSchemas, machine, () => ({
40383
40463
  "~standard": {
40384
40464
  version: 1,
40385
40465
  vendor: "xstate",
@@ -43628,18 +43708,14 @@ var init_artifacts_git_retry = __esm({
43628
43708
  });
43629
43709
 
43630
43710
  // ../worker/src/isomorphic-git-load.ts
43631
- function loadIsomorphicGit() {
43632
- memo2 ??= import("./node_modules/.kody-generated/isomorphic-git.mjs").catch((error2) => {
43633
- memo2 = null;
43634
- throw error2;
43635
- });
43636
- return memo2;
43637
- }
43638
- var memo2;
43711
+ var loadIsomorphicGit;
43639
43712
  var init_isomorphic_git_load = __esm({
43640
43713
  "../worker/src/isomorphic-git-load.ts"() {
43641
43714
  "use strict";
43642
- memo2 = null;
43715
+ init_isolate_memo();
43716
+ loadIsomorphicGit = isolateMemo(
43717
+ () => import("./node_modules/.kody-generated/isomorphic-git.mjs")
43718
+ );
43643
43719
  }
43644
43720
  });
43645
43721
 
@@ -198938,13 +199014,22 @@ var init_allowed_packages = __esm({
198938
199014
  });
198939
199015
 
198940
199016
  // ../worker/src/mcp/secrets/crypto.ts
198941
- var textEncoder2, textDecoder;
199017
+ var textEncoder2, textDecoder, derivedEncryptionKeys;
198942
199018
  var init_crypto = __esm({
198943
199019
  "../worker/src/mcp/secrets/crypto.ts"() {
198944
199020
  "use strict";
198945
199021
  init_base64();
199022
+ init_isolate_memo();
198946
199023
  textEncoder2 = new TextEncoder();
198947
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
+ );
198948
199033
  }
198949
199034
  });
198950
199035
 
@@ -199306,6 +199391,7 @@ var init_plans = __esm({
199306
199391
  // Concurrent active runs (not lifetime or daily). One at a time on
199307
199392
  // free; a second deferred workflow is the upgrade nudge.
199308
199393
  maxConcurrentWorkflows: 1,
199394
+ maxExecutionContextsPerSeat: 10,
199309
199395
  // Unique execute workers are the Dynamic Worker bill. Daily headroom
199310
199396
  // covers a bursty agent morning; the weekly total keeps a free account
199311
199397
  // from spending a full week of that headroom every day.
@@ -199334,6 +199420,7 @@ var init_plans = __esm({
199334
199420
  maxSecrets: 100,
199335
199421
  maxStorageBytes: 1024 * 1024 * 1024,
199336
199422
  maxConcurrentWorkflows: 10,
199423
+ maxExecutionContextsPerSeat: 20,
199337
199424
  // Public Standard execute is a try-paid rung with bursty daily
199338
199425
  // headroom and a weekly total. Continuous pre-cut subscribers keep
199339
199426
  // {@link legacyPlanLimits} (daily-only, no weekly window).
@@ -199362,6 +199449,7 @@ var init_plans = __esm({
199362
199449
  maxSecrets: 200,
199363
199450
  maxStorageBytes: 5 * 1024 * 1024 * 1024,
199364
199451
  maxConcurrentWorkflows: 50,
199452
+ maxExecutionContextsPerSeat: 20,
199365
199453
  // Retired $49 Pro. Execute is a hard daily + weekly cap.
199366
199454
  maxExecuteUniqueWorkersPerDay: 1500,
199367
199455
  maxExecuteUniqueWorkersPerWeek: 4e3,
@@ -199396,6 +199484,7 @@ var init_plans = __esm({
199396
199484
  maxStorageBytes: 100 * 1024 * 1024 * 1024,
199397
199485
  // 2× pro (100). Observed concurrent ~35.
199398
199486
  maxConcurrentWorkflows: 200,
199487
+ maxExecutionContextsPerSeat: 50,
199399
199488
  // Operator runaway cap. kentcdodds August 2026 rollup avg ~3,800
199400
199489
  // execute/day (116k/month); entitlement meter today ~1,810. Daily
199401
199490
  // peak is not stored; 25,000 is at least 2× a ~12,500 peak (~3×
@@ -199434,6 +199523,7 @@ var init_plans = __esm({
199434
199523
  maxSecrets: 100,
199435
199524
  maxStorageBytes: 1024 * 1024 * 1024,
199436
199525
  maxConcurrentWorkflows: 50,
199526
+ maxExecutionContextsPerSeat: 20,
199437
199527
  maxExecuteUniqueWorkersPerDay: 500,
199438
199528
  maxExecuteUniqueWorkersPerWeek: null,
199439
199529
  maxOutboundFetchesPerDay: 2e4,
@@ -199458,6 +199548,7 @@ var init_plans = __esm({
199458
199548
  maxSecrets: 200,
199459
199549
  maxStorageBytes: 5 * 1024 * 1024 * 1024,
199460
199550
  maxConcurrentWorkflows: 100,
199551
+ maxExecutionContextsPerSeat: 20,
199461
199552
  maxExecuteUniqueWorkersPerDay: 800,
199462
199553
  maxExecuteUniqueWorkersPerWeek: null,
199463
199554
  maxOutboundFetchesPerDay: 4e4,
@@ -199845,7 +199936,9 @@ var init_errors4 = __esm({
199845
199936
  "use strict";
199846
199937
  init_compute_overage();
199847
199938
  init_date_keys();
199939
+ init_org_pages();
199848
199940
  init_prefer_local_cli_execute();
199941
+ init_routes();
199849
199942
  init_plans();
199850
199943
  minuteMs = 60 * 1e3;
199851
199944
  }
@@ -202449,6 +202542,7 @@ var init_community_icon = __esm({
202449
202542
  init_data_cache();
202450
202543
  init_deletion_state();
202451
202544
  init_kv_cachified();
202545
+ init_kv_delete();
202452
202546
  init_artifact_file();
202453
202547
  init_entity_sources();
202454
202548
  init_icon_fit();
@@ -203247,9 +203341,16 @@ var init_rejecting_providers = __esm({
203247
203341
  });
203248
203342
 
203249
203343
  // ../worker/src/disposable-email-domains-load.ts
203344
+ var loadDisposableEmailDomains;
203250
203345
  var init_disposable_email_domains_load = __esm({
203251
203346
  "../worker/src/disposable-email-domains-load.ts"() {
203252
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
+ );
203253
203354
  }
203254
203355
  });
203255
203356
 
@@ -203421,9 +203522,9 @@ var init_d1_storage_reconciliation = __esm({
203421
203522
  "use strict";
203422
203523
  init_isolate_state();
203423
203524
  init_service5();
203525
+ init_published_package_cache();
203424
203526
  inFlightOwnerReconciles = isolateCollection(
203425
- /* @__PURE__ */ new Map(),
203426
- { pending: (tasks) => tasks.values() }
203527
+ new PromiseLruCache({ retainSettled: false })
203427
203528
  );
203428
203529
  }
203429
203530
  });
@@ -203819,21 +203920,6 @@ var init_published_bundle_artifact_inputs = __esm({
203819
203920
  });
203820
203921
 
203821
203922
  // ../worker/src/package-runtime/published-bundle-artifacts.ts
203822
- async function mapWithConcurrency(items, concurrency, mapper) {
203823
- if (items.length === 0) return;
203824
- const limit = Math.max(1, Math.min(concurrency, items.length));
203825
- let nextIndex = 0;
203826
- async function worker() {
203827
- while (nextIndex < items.length) {
203828
- const index = nextIndex;
203829
- nextIndex += 1;
203830
- const item = items[index];
203831
- if (item === void 0) return;
203832
- await mapper(item);
203833
- }
203834
- }
203835
- await Promise.all(Array.from({ length: limit }, () => worker()));
203836
- }
203837
203923
  function publishedBundleLoadIdentityKey(input3) {
203838
203924
  return publishedBundleArtifactIdentityKey({
203839
203925
  sourceId: input3.sourceId,
@@ -203965,6 +204051,7 @@ var publishedPackageArtifactRebuildConcurrency;
203965
204051
  var init_published_bundle_artifacts = __esm({
203966
204052
  "../worker/src/package-runtime/published-bundle-artifacts.ts"() {
203967
204053
  "use strict";
204054
+ init_concurrency();
203968
204055
  init_linked_artifact_store();
203969
204056
  init_pre_binding_artifact_repair();
203970
204057
  init_published_runtime_artifacts();