@fungi.computer/oyster 0.13.0 → 0.14.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 (52) hide show
  1. package/README.md +30 -15
  2. package/dist/agents.js +2 -1
  3. package/dist/approval-home.js +4 -2
  4. package/dist/boot-host-script.js +1 -1
  5. package/dist/browser/cdp-client.d.ts +1 -1
  6. package/dist/browser/cdp-client.js +73 -37
  7. package/dist/browser/errors.d.ts +2 -0
  8. package/dist/browser/lease-registry.d.ts +5 -1
  9. package/dist/browser/lease-registry.js +2 -6
  10. package/dist/build/candidate-cli.mjs +267 -246
  11. package/dist/build/definition-emission.js +17 -3
  12. package/dist/build/local-build.d.ts +6 -0
  13. package/dist/build/local-build.js +104 -91
  14. package/dist/build/process-group.d.ts +6 -0
  15. package/dist/build/process-group.js +92 -0
  16. package/dist/build.d.ts +1 -1
  17. package/dist/build.js +1 -1
  18. package/dist/embed-metafiles.js +2 -2
  19. package/dist/embed-scripts.js +1 -1
  20. package/dist/git-journal.js +12 -9
  21. package/dist/hello-app-script.js +1 -1
  22. package/dist/host-page-assets.js +1 -1
  23. package/dist/host-page.d.ts +6 -1
  24. package/dist/host-page.js +40 -0
  25. package/dist/host.js +24 -9
  26. package/dist/installation-operations.js +1 -1
  27. package/dist/machine-link/host.js +18 -13
  28. package/dist/pack.d.ts +3 -1
  29. package/dist/pack.js +28 -7
  30. package/dist/page/app-permissions.js +3 -13
  31. package/dist/page-script.js +2 -2
  32. package/dist/standalone/agent-mail.d.ts +38 -11
  33. package/dist/standalone/agent-mail.js +8 -22
  34. package/dist/standalone/agents.d.ts +1 -0
  35. package/dist/standalone/agents.js +30 -5
  36. package/dist/standalone/hello-app.d.ts +4 -1
  37. package/dist/standalone/hello-app.js +67 -22
  38. package/dist/standalone/hello-lesson.d.ts +2 -0
  39. package/dist/standalone/hello-lesson.js +36 -0
  40. package/dist/standalone/local-desktop.d.ts +6 -4
  41. package/dist/standalone/local-desktop.js +39 -20
  42. package/dist/standalone/sign-in-link.d.ts +2 -1
  43. package/dist/standalone/sign-in-link.js +58 -17
  44. package/dist/standalone/try-cli.d.ts +12 -9
  45. package/dist/standalone/try-cli.js +490 -138
  46. package/docs/api/browser.md +24 -7
  47. package/docs/api/pack.md +3 -2
  48. package/docs/api/workers-git.md +2 -2
  49. package/docs/api/workers.md +2 -2
  50. package/docs/site/agent-quickstart.mdx +109 -354
  51. package/examples/standalone/wrangler.jsonc +1 -1
  52. package/package.json +24 -24
@@ -494,7 +494,7 @@ var require_react_development = __commonJS({
494
494
  * @param {?string} callerName name of the calling function in the public API.
495
495
  * @internal
496
496
  */
497
- enqueueForceUpdate: function(publicInstance, callback2, callerName) {
497
+ enqueueForceUpdate: function(publicInstance, callback3, callerName) {
498
498
  warnNoop(publicInstance, "forceUpdate");
499
499
  },
500
500
  /**
@@ -510,7 +510,7 @@ var require_react_development = __commonJS({
510
510
  * @param {?string} callerName name of the calling function in the public API.
511
511
  * @internal
512
512
  */
513
- enqueueReplaceState: function(publicInstance, completeState, callback2, callerName) {
513
+ enqueueReplaceState: function(publicInstance, completeState, callback3, callerName) {
514
514
  warnNoop(publicInstance, "replaceState");
515
515
  },
516
516
  /**
@@ -525,7 +525,7 @@ var require_react_development = __commonJS({
525
525
  * @param {?string} Name of the calling function in the public API.
526
526
  * @internal
527
527
  */
528
- enqueueSetState: function(publicInstance, partialState, callback2, callerName) {
528
+ enqueueSetState: function(publicInstance, partialState, callback3, callerName) {
529
529
  warnNoop(publicInstance, "setState");
530
530
  }
531
531
  };
@@ -541,14 +541,14 @@ var require_react_development = __commonJS({
541
541
  this.updater = updater || ReactNoopUpdateQueue;
542
542
  }
543
543
  Component.prototype.isReactComponent = {};
544
- Component.prototype.setState = function(partialState, callback2) {
544
+ Component.prototype.setState = function(partialState, callback3) {
545
545
  if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null) {
546
546
  throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
547
547
  }
548
- this.updater.enqueueSetState(this, partialState, callback2, "setState");
548
+ this.updater.enqueueSetState(this, partialState, callback3, "setState");
549
549
  };
550
- Component.prototype.forceUpdate = function(callback2) {
551
- this.updater.enqueueForceUpdate(this, callback2, "forceUpdate");
550
+ Component.prototype.forceUpdate = function(callback3) {
551
+ this.updater.enqueueForceUpdate(this, callback3, "forceUpdate");
552
552
  };
553
553
  {
554
554
  var deprecatedAPIs = {
@@ -952,7 +952,7 @@ var require_react_development = __commonJS({
952
952
  }
953
953
  return index.toString(36);
954
954
  }
955
- function mapIntoArray(children, array3, escapedPrefix, nameSoFar, callback2) {
955
+ function mapIntoArray(children, array3, escapedPrefix, nameSoFar, callback3) {
956
956
  var type2 = typeof children;
957
957
  if (type2 === "undefined" || type2 === "boolean") {
958
958
  children = null;
@@ -976,7 +976,7 @@ var require_react_development = __commonJS({
976
976
  }
977
977
  if (invokeCallback) {
978
978
  var _child = children;
979
- var mappedChild = callback2(_child);
979
+ var mappedChild = callback3(_child);
980
980
  var childKey = nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
981
981
  if (isArray2(mappedChild)) {
982
982
  var escapedChildKey = "";
@@ -1017,7 +1017,7 @@ var require_react_development = __commonJS({
1017
1017
  for (var i2 = 0; i2 < children.length; i2++) {
1018
1018
  child = children[i2];
1019
1019
  nextName = nextNamePrefix + getElementKey(child, i2);
1020
- subtreeCount += mapIntoArray(child, array3, escapedPrefix, nextName, callback2);
1020
+ subtreeCount += mapIntoArray(child, array3, escapedPrefix, nextName, callback3);
1021
1021
  }
1022
1022
  } else {
1023
1023
  var iteratorFn = getIteratorFn(children);
@@ -1037,7 +1037,7 @@ var require_react_development = __commonJS({
1037
1037
  while (!(step = iterator.next()).done) {
1038
1038
  child = step.value;
1039
1039
  nextName = nextNamePrefix + getElementKey(child, ii++);
1040
- subtreeCount += mapIntoArray(child, array3, escapedPrefix, nextName, callback2);
1040
+ subtreeCount += mapIntoArray(child, array3, escapedPrefix, nextName, callback3);
1041
1041
  }
1042
1042
  } else if (type2 === "object") {
1043
1043
  var childrenString = String(children);
@@ -1404,9 +1404,9 @@ var require_react_development = __commonJS({
1404
1404
  var dispatcher = resolveDispatcher();
1405
1405
  return dispatcher.useLayoutEffect(create, deps);
1406
1406
  }
1407
- function useCallback(callback2, deps) {
1407
+ function useCallback(callback3, deps) {
1408
1408
  var dispatcher = resolveDispatcher();
1409
- return dispatcher.useCallback(callback2, deps);
1409
+ return dispatcher.useCallback(callback3, deps);
1410
1410
  }
1411
1411
  function useMemo(create, deps) {
1412
1412
  var dispatcher = resolveDispatcher();
@@ -1982,7 +1982,7 @@ var require_react_development = __commonJS({
1982
1982
  var nodeRequire = module && module[requireString];
1983
1983
  enqueueTaskImpl = nodeRequire.call(module, "timers").setImmediate;
1984
1984
  } catch (_err) {
1985
- enqueueTaskImpl = function(callback2) {
1985
+ enqueueTaskImpl = function(callback3) {
1986
1986
  {
1987
1987
  if (didWarnAboutMessageChannel === false) {
1988
1988
  didWarnAboutMessageChannel = true;
@@ -1992,7 +1992,7 @@ var require_react_development = __commonJS({
1992
1992
  }
1993
1993
  }
1994
1994
  var channel = new MessageChannel();
1995
- channel.port1.onmessage = callback2;
1995
+ channel.port1.onmessage = callback3;
1996
1996
  channel.port2.postMessage(void 0);
1997
1997
  };
1998
1998
  }
@@ -2001,7 +2001,7 @@ var require_react_development = __commonJS({
2001
2001
  }
2002
2002
  var actScopeDepth = 0;
2003
2003
  var didWarnNoAwaitAct = false;
2004
- function act(callback2) {
2004
+ function act(callback3) {
2005
2005
  {
2006
2006
  var prevActScopeDepth = actScopeDepth;
2007
2007
  actScopeDepth++;
@@ -2012,7 +2012,7 @@ var require_react_development = __commonJS({
2012
2012
  var result2;
2013
2013
  try {
2014
2014
  ReactCurrentActQueue.isBatchingLegacy = true;
2015
- result2 = callback2();
2015
+ result2 = callback3();
2016
2016
  if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
2017
2017
  var queue = ReactCurrentActQueue.current;
2018
2018
  if (queue !== null) {
@@ -2126,10 +2126,10 @@ var require_react_development = __commonJS({
2126
2126
  var i2 = 0;
2127
2127
  try {
2128
2128
  for (; i2 < queue.length; i2++) {
2129
- var callback2 = queue[i2];
2129
+ var callback3 = queue[i2];
2130
2130
  do {
2131
- callback2 = callback2(true);
2132
- } while (callback2 !== null);
2131
+ callback3 = callback3(true);
2132
+ } while (callback3 !== null);
2133
2133
  }
2134
2134
  queue.length = 0;
2135
2135
  } catch (error3) {
@@ -7207,18 +7207,18 @@ var require_polyfills = __commonJS({
7207
7207
  }
7208
7208
  fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
7209
7209
  function read(fd, buffer, offset, length, position, callback_) {
7210
- var callback2;
7210
+ var callback3;
7211
7211
  if (callback_ && typeof callback_ === "function") {
7212
7212
  var eagCounter = 0;
7213
- callback2 = function(er, _, __) {
7213
+ callback3 = function(er, _, __) {
7214
7214
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
7215
7215
  eagCounter++;
7216
- return fs$read.call(fs, fd, buffer, offset, length, position, callback2);
7216
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback3);
7217
7217
  }
7218
7218
  callback_.apply(this, arguments);
7219
7219
  };
7220
7220
  }
7221
- return fs$read.call(fs, fd, buffer, offset, length, position, callback2);
7221
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback3);
7222
7222
  }
7223
7223
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
7224
7224
  return read;
@@ -7240,19 +7240,19 @@ var require_polyfills = __commonJS({
7240
7240
  };
7241
7241
  })(fs.readSync);
7242
7242
  function patchLchmod(fs2) {
7243
- fs2.lchmod = function(path, mode, callback2) {
7243
+ fs2.lchmod = function(path, mode, callback3) {
7244
7244
  fs2.open(
7245
7245
  path,
7246
7246
  constants.O_WRONLY | constants.O_SYMLINK,
7247
7247
  mode,
7248
7248
  function(err, fd) {
7249
7249
  if (err) {
7250
- if (callback2) callback2(err);
7250
+ if (callback3) callback3(err);
7251
7251
  return;
7252
7252
  }
7253
7253
  fs2.fchmod(fd, mode, function(err2) {
7254
7254
  fs2.close(fd, function(err22) {
7255
- if (callback2) callback2(err2 || err22);
7255
+ if (callback3) callback3(err2 || err22);
7256
7256
  });
7257
7257
  });
7258
7258
  }
@@ -7365,14 +7365,14 @@ var require_polyfills = __commonJS({
7365
7365
  cb = options;
7366
7366
  options = null;
7367
7367
  }
7368
- function callback2(er, stats) {
7368
+ function callback3(er, stats) {
7369
7369
  if (stats) {
7370
7370
  if (stats.uid < 0) stats.uid += 4294967296;
7371
7371
  if (stats.gid < 0) stats.gid += 4294967296;
7372
7372
  }
7373
7373
  if (cb) cb.apply(this, arguments);
7374
7374
  }
7375
- return options ? orig.call(fs, target, options, callback2) : orig.call(fs, target, callback2);
7375
+ return options ? orig.call(fs, target, options, callback3) : orig.call(fs, target, callback3);
7376
7376
  };
7377
7377
  }
7378
7378
  function statFixSync(orig) {
@@ -8286,18 +8286,18 @@ var require_lib2 = __commonJS({
8286
8286
  }
8287
8287
  }
8288
8288
  }
8289
- async function writeFile4(filename, data, options, callback2) {
8289
+ async function writeFile4(filename, data, options, callback3) {
8290
8290
  if (options instanceof Function) {
8291
- callback2 = options;
8291
+ callback3 = options;
8292
8292
  options = {};
8293
8293
  }
8294
8294
  const promise3 = writeFileAsync(filename, data, options);
8295
- if (callback2) {
8295
+ if (callback3) {
8296
8296
  try {
8297
8297
  const result2 = await promise3;
8298
- return callback2(result2);
8298
+ return callback3(result2);
8299
8299
  } catch (err) {
8300
- return callback2(err);
8300
+ return callback3(err);
8301
8301
  }
8302
8302
  }
8303
8303
  return promise3;
@@ -11365,9 +11365,9 @@ var iterateConcurrentImpl = (options) => {
11365
11365
  };
11366
11366
  var iterateConcurrent = () => (options) => iterateConcurrentImpl(options);
11367
11367
  var filterOrElse = /* @__PURE__ */ dual(3, (self, predicate, orElse) => flatMap(self, (a) => predicate(a) ? succeed3(a) : orElse(a)));
11368
- var forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterruptible2 = false) => {
11368
+ var forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterruptible3 = false) => {
11369
11369
  const parentRuntime = parent;
11370
- const interruptible2 = uninterruptible2 === "inherit" ? parentRuntime.interruptible : !uninterruptible2;
11370
+ const interruptible2 = uninterruptible3 === "inherit" ? parentRuntime.interruptible : !uninterruptible3;
11371
11371
  const child = new FiberImpl(parentRuntime.context, interruptible2);
11372
11372
  if (!daemon) {
11373
11373
  parentRuntime.children().add(child);
@@ -11532,7 +11532,7 @@ var tryPromise2 = tryPromise;
11532
11532
  var succeed5 = succeed3;
11533
11533
  var suspend2 = suspend;
11534
11534
  var sync2 = sync;
11535
- var void_3 = void_;
11535
+ var callback2 = callback;
11536
11536
  var gen2 = gen;
11537
11537
  var fail5 = fail3;
11538
11538
  var failCauseSync2 = failCauseSync;
@@ -11542,13 +11542,13 @@ var fromResult2 = fromResult;
11542
11542
  var flatMap2 = flatMap;
11543
11543
  var exit2 = exit;
11544
11544
  var map4 = map2;
11545
- var catch_2 = catch_;
11546
11545
  var catchCause2 = catchCause;
11547
11546
  var mapError3 = mapError2;
11548
11547
  var filterOrFail2 = filterOrFail;
11549
11548
  var scoped2 = scoped;
11550
11549
  var acquireRelease2 = acquireRelease;
11551
11550
  var acquireUseRelease2 = acquireUseRelease;
11551
+ var uninterruptible2 = uninterruptible;
11552
11552
  var runPromise2 = runPromise;
11553
11553
  var runSyncExit2 = runSyncExit;
11554
11554
  var mapEager2 = mapEager;
@@ -14544,21 +14544,6 @@ function makeIsGreaterThanOrEqualTo(options) {
14544
14544
  });
14545
14545
  };
14546
14546
  }
14547
- function makeIsLessThanOrEqualTo(options) {
14548
- const lte = isLessThanOrEqualTo(options.order);
14549
- const formatter = options.formatter ?? format;
14550
- return (maximum, annotations) => {
14551
- return makeFilter2((input) => lte(input, maximum), {
14552
- expected: `a value less than or equal to ${formatter(maximum)}`,
14553
- arbitraryConstraint: {
14554
- order: options.order,
14555
- maximum
14556
- },
14557
- ...options.annotate?.(maximum),
14558
- ...annotations
14559
- });
14560
- };
14561
- }
14562
14547
  function makeIsBetween(deriveOptions) {
14563
14548
  const greaterThanOrEqualTo = isGreaterThanOrEqualTo(deriveOptions.order);
14564
14549
  const greaterThan = isGreaterThan(deriveOptions.order);
@@ -14626,23 +14611,6 @@ var isGreaterThanOrEqualTo2 = /* @__PURE__ */ makeIsGreaterThanOrEqualTo({
14626
14611
  })
14627
14612
  })
14628
14613
  });
14629
- var isLessThanOrEqualTo2 = /* @__PURE__ */ makeIsLessThanOrEqualTo({
14630
- order: Number2,
14631
- annotate: (maximum) => ({
14632
- representation: {
14633
- id: "effect/schema/isLessThanOrEqualTo",
14634
- payload: {
14635
- maximum: encodeNumberPayload(maximum)
14636
- }
14637
- },
14638
- toJsonSchema: () => ({
14639
- maximum
14640
- }),
14641
- toCode: () => ({
14642
- runtime: `Schema.isLessThanOrEqualTo(${format(maximum)})`
14643
- })
14644
- })
14645
- });
14646
14614
  var isBetween = /* @__PURE__ */ makeIsBetween({
14647
14615
  order: Number2,
14648
14616
  annotate: (options) => {
@@ -16838,14 +16806,14 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
16838
16806
  return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
16839
16807
  };
16840
16808
  doc.write(`const input = payload.value;`);
16841
- const ids2 = /* @__PURE__ */ Object.create(null);
16809
+ const ids = /* @__PURE__ */ Object.create(null);
16842
16810
  let counter = 0;
16843
16811
  for (const key of normalized.keys) {
16844
- ids2[key] = `key_${counter++}`;
16812
+ ids[key] = `key_${counter++}`;
16845
16813
  }
16846
16814
  doc.write(`const newResult = {};`);
16847
16815
  for (const key of normalized.keys) {
16848
- const id = ids2[key];
16816
+ const id = ids[key];
16849
16817
  const k = esc(key);
16850
16818
  const schema2 = shape[key];
16851
16819
  const isOptionalIn = schema2?._zod?.optin === "optional";
@@ -19938,7 +19906,11 @@ var gillResponseSchema = Union2([
19938
19906
  state: Literal2("error"),
19939
19907
  rows: Tuple([]),
19940
19908
  /** Host-owned permanent execution refusal; an ordinary error may still be refreshed. */
19941
- reason: optional2(Literals(["exec_isolation_required", "params_required"])),
19909
+ reason: optional2(Literals([
19910
+ "exec_isolation_required",
19911
+ "params_required",
19912
+ "disabled"
19913
+ ])),
19942
19914
  error: String4.pipe(check(isMinLength(1)), check(isMaxLength(512))),
19943
19915
  /** The host supplies the same-placement picker and this App's launch. */
19944
19916
  recovery: optional2(Union2([
@@ -21689,73 +21661,6 @@ var publicRouteConfigurationSchema = Struct({
21689
21661
  // src/build/candidate-cli.ts
21690
21662
  import { readFile as readFile6 } from "node:fs/promises";
21691
21663
 
21692
- // ../carrier/dist/internal/post-contract.js
21693
- var CursorResultSchema = Struct({
21694
- status: Literals(["accepted", "duplicate"]),
21695
- cursor: Int.check(isGreaterThanOrEqualTo2(0))
21696
- });
21697
- var PostDeliveryResultSchema = Union2([
21698
- Literals(["accepted", "duplicate", "refused"]),
21699
- CursorResultSchema,
21700
- Struct({
21701
- status: Literals(["accepted", "duplicate", "refused"]),
21702
- receipt: Json2
21703
- })
21704
- ]);
21705
- var PostError = class extends TaggedError2("PostError") {
21706
- constructor(message, reason) {
21707
- super(reason === void 0 ? { message } : { message, reason });
21708
- }
21709
- };
21710
-
21711
- // ../carrier/dist/post.js
21712
- var Key = String4.check(isMinLength(1), isMaxLength(256));
21713
- var JobPayload = Struct({ postKey: Key });
21714
- var PageLimit = Int.check(isGreaterThanOrEqualTo2(1), isLessThanOrEqualTo2(64));
21715
- var maxRouteDeadlineMs = 7 * 24 * 60 * 60 * 1e3;
21716
- var ids = defineIdFamily({
21717
- family: "post",
21718
- version: 1,
21719
- kinds: { work: { prefix: "post_work" } }
21720
- });
21721
- var PostEnvelopeSchema = Struct({
21722
- key: Key,
21723
- kind: Key,
21724
- address: Unknown2,
21725
- event: Unknown2
21726
- });
21727
- var PostRowSchema = fromJsonString2(Union2([
21728
- Struct({
21729
- state: Literal2("pending"),
21730
- envelope: PostEnvelopeSchema,
21731
- attempts: Int.check(isGreaterThanOrEqualTo2(0)),
21732
- nextAttemptAt: Number5.check(isGreaterThanOrEqualTo2(0)),
21733
- deadlineAt: optional2(Number5.check(isGreaterThanOrEqualTo2(0))),
21734
- jobId: optional2(Key),
21735
- delivery: optional2(PostEnvelopeSchema),
21736
- nextKey: optional2(Key)
21737
- }),
21738
- Struct({
21739
- state: Literal2("delivered"),
21740
- receipt: optional2(Json2),
21741
- nextKey: optional2(Key)
21742
- }),
21743
- Struct({
21744
- state: Literal2("dead"),
21745
- envelope: PostEnvelopeSchema,
21746
- attempts: Int.check(isGreaterThanOrEqualTo2(0)),
21747
- reason: Literals(["refused", "exhausted", "expired"]),
21748
- deadlineAt: optional2(Number5.check(isGreaterThanOrEqualTo2(0))),
21749
- receipt: optional2(Json2),
21750
- delivery: optional2(PostEnvelopeSchema),
21751
- nextKey: optional2(Key)
21752
- })
21753
- ]));
21754
- var StoredRow = Struct({ key: String4, value: String4 });
21755
- var DueRow = Struct({
21756
- due: NullOr(Number5.check(isGreaterThanOrEqualTo2(0)))
21757
- });
21758
-
21759
21664
  // ../bird-dog/dist/effect.js
21760
21665
  var Identifier = String4.check(isMinLength(1), isMaxLength(256));
21761
21666
  var BIRD_DOG_MAIL_CONTENT_MAX_BYTES = 256 * 1024;
@@ -21862,7 +21767,8 @@ var BirdDogAgentWorkSchema = Struct({
21862
21767
  sessionId: Identifier,
21863
21768
  commandFactId: Identifier,
21864
21769
  recovery: optional2(Struct({
21865
- maxRecoveries: Int.check(isGreaterThanOrEqualTo2(0))
21770
+ maxRecoveries: Int.check(isGreaterThanOrEqualTo2(0)),
21771
+ windowMs: optionalKey2(Int.check(isGreaterThan2(0)))
21866
21772
  }))
21867
21773
  });
21868
21774
  var BirdDogAgentJobPayloadSchema = Struct({
@@ -22578,7 +22484,76 @@ import { join as join6 } from "node:path";
22578
22484
  // src/build.ts
22579
22485
  init_snapshot_program_scripts();
22580
22486
 
22487
+ // src/build/process-group.ts
22488
+ import { setTimeout as delay2 } from "node:timers/promises";
22489
+ var CleanupError = class extends Error {
22490
+ };
22491
+ function processGroupExists(child) {
22492
+ if (child.pid === void 0) return false;
22493
+ try {
22494
+ process.kill(-child.pid, 0);
22495
+ return true;
22496
+ } catch (error2) {
22497
+ if (error2 instanceof Error && "code" in error2 && error2.code === "ESRCH")
22498
+ return false;
22499
+ throw error2;
22500
+ }
22501
+ }
22502
+ async function stopProcessGroup(child) {
22503
+ try {
22504
+ if (process.platform === "win32") await stopChild(child);
22505
+ else await stopGroup(child);
22506
+ } catch (cause) {
22507
+ throw new CleanupError("Owned process cleanup did not complete.", {
22508
+ cause
22509
+ });
22510
+ }
22511
+ }
22512
+ async function stopGroup(child) {
22513
+ if (!processGroupExists(child)) return;
22514
+ const deadline = Date.now() + 5e3;
22515
+ for (const [signal, until] of [
22516
+ ["SIGTERM", deadline - 1e3],
22517
+ ["SIGKILL", deadline]
22518
+ ]) {
22519
+ try {
22520
+ if (child.pid !== void 0) process.kill(-child.pid, signal);
22521
+ } catch (error2) {
22522
+ if (!(error2 instanceof Error && "code" in error2 && error2.code === "ESRCH"))
22523
+ throw error2;
22524
+ }
22525
+ while (processGroupExists(child) && Date.now() < until) await delay2(25);
22526
+ if (!processGroupExists(child)) return;
22527
+ }
22528
+ throw new Error("Owned process group survived its five-second cleanup bound");
22529
+ }
22530
+ async function stopChild(child) {
22531
+ if (child.pid === void 0 || child.exitCode !== null || child.signalCode !== null)
22532
+ return;
22533
+ let closed;
22534
+ let force;
22535
+ let deadline;
22536
+ try {
22537
+ await new Promise((resolve6, reject) => {
22538
+ closed = resolve6;
22539
+ child.once("close", closed);
22540
+ child.kill("SIGTERM");
22541
+ force = setTimeout(() => {
22542
+ child.kill("SIGKILL");
22543
+ }, 4e3);
22544
+ deadline = setTimeout(() => {
22545
+ reject(new Error("Owned child survived its five-second cleanup bound"));
22546
+ }, 5e3);
22547
+ });
22548
+ } finally {
22549
+ clearTimeout(force);
22550
+ clearTimeout(deadline);
22551
+ if (closed !== void 0) child.off("close", closed);
22552
+ }
22553
+ }
22554
+
22581
22555
  // src/build/local-build.ts
22556
+ import { addAbortListener } from "node:events";
22582
22557
  import { Buffer as Buffer2 } from "node:buffer";
22583
22558
 
22584
22559
  // src/build/definition-emission.ts
@@ -22781,7 +22756,8 @@ async function createDefinitionEmission(source, recipe) {
22781
22756
  );
22782
22757
  const file = join(source.snapshotPath, ".fungi-built-definition.mjs");
22783
22758
  await writeFile(file, declarationCode, { flag: "wx", mode: 384 });
22784
- const result2 = await promisify(execFile)(
22759
+ signal.throwIfAborted();
22760
+ const evaluation = promisify(execFile)(
22785
22761
  process.execPath,
22786
22762
  [
22787
22763
  "--input-type=module",
@@ -22796,9 +22772,21 @@ async function createDefinitionEmission(source, recipe) {
22796
22772
  timeout: 3e4,
22797
22773
  signal
22798
22774
  }
22799
- ).catch((cause) => {
22800
- throw evaluationFailure(cause);
22775
+ );
22776
+ const closed = new Promise((resolve6) => {
22777
+ evaluation.child.once("close", () => {
22778
+ resolve6();
22779
+ });
22801
22780
  });
22781
+ let result2;
22782
+ try {
22783
+ result2 = await evaluation.catch((cause) => {
22784
+ signal.throwIfAborted();
22785
+ throw evaluationFailure(cause);
22786
+ });
22787
+ } finally {
22788
+ await closed;
22789
+ }
22802
22790
  return decodeUnknownSync(
22803
22791
  fromJsonString2(appDeclarationSchema),
22804
22792
  { onExcessProperty: "error" }
@@ -32339,7 +32327,7 @@ async function readBundledHtml(snapshot, recipe) {
32339
32327
  // src/build/local-build.ts
32340
32328
  import { createHash as createHash3, randomBytes } from "node:crypto";
32341
32329
  import { spawn } from "node:child_process";
32342
- import { createReadStream, mkdtempSync, realpathSync } from "node:fs";
32330
+ import { createReadStream, mkdtempSync, realpathSync, rmSync } from "node:fs";
32343
32331
  import {
32344
32332
  access as access3,
32345
32333
  cp,
@@ -32361,7 +32349,6 @@ import {
32361
32349
  sep as sep4
32362
32350
  } from "node:path";
32363
32351
  import { pipeline } from "node:stream/promises";
32364
- import { setTimeout as delay2 } from "node:timers/promises";
32365
32352
  import * as esbuild from "esbuild";
32366
32353
 
32367
32354
  // ../../node_modules/.pnpm/@pnpm+crypto.hash@1100.0.8/node_modules/@pnpm/crypto.hash/lib/index.js
@@ -35430,15 +35417,6 @@ function repositoryEnvironment() {
35430
35417
  }
35431
35418
 
35432
35419
  // src/build/local-build.ts
35433
- function logEvent(operation, cause) {
35434
- console.error(
35435
- JSON.stringify({
35436
- source: "app-publisher",
35437
- operation,
35438
- failureKind: cause instanceof Error ? "Error" : "NonErrorThrown"
35439
- })
35440
- );
35441
- }
35442
35420
  var localConfigSchema = Struct({
35443
35421
  appId: appIdSchema,
35444
35422
  source: Struct({
@@ -35456,15 +35434,27 @@ async function sha256File(path, signal) {
35456
35434
  await pipeline(createReadStream(path), hash2, { signal });
35457
35435
  return parseSha256Digest(`sha256:${hash2.digest("hex")}`);
35458
35436
  }
35459
- function runGit(args2, cwd, signal, environment = repositoryEnvironment()) {
35460
- return new Promise((resolve6, reject) => {
35461
- const child = spawn("git", [...args2], {
35462
- cwd,
35463
- env: environment,
35464
- shell: false,
35465
- signal,
35466
- stdio: ["ignore", "pipe", "pipe"]
35467
- });
35437
+ var GitCommandError = class extends Error {
35438
+ constructor(message, exitCode) {
35439
+ super(message);
35440
+ this.exitCode = exitCode;
35441
+ }
35442
+ exitCode;
35443
+ };
35444
+ async function runGit(args2, cwd, signal, environment = repositoryEnvironment()) {
35445
+ signal.throwIfAborted();
35446
+ const child = spawn("git", [...args2], {
35447
+ cwd,
35448
+ env: environment,
35449
+ shell: false,
35450
+ detached: process.platform !== "win32",
35451
+ signal,
35452
+ stdio: ["ignore", "pipe", "pipe"]
35453
+ });
35454
+ let stopping;
35455
+ const stop = () => stopping ??= stopProcessGroup(child);
35456
+ let listener;
35457
+ const completion = new Promise((resolve6, reject) => {
35468
35458
  const stdout = [];
35469
35459
  const stderr = [];
35470
35460
  let spawnError;
@@ -35480,12 +35470,22 @@ function runGit(args2, cwd, signal, environment = repositoryEnvironment()) {
35480
35470
  }
35481
35471
  const detail = Buffer2.concat(stderr).toString("utf8").trim();
35482
35472
  reject(
35483
- spawnError ?? new Error(
35484
- detail.length > 0 ? `git exited unsuccessfully: ${detail}` : `git exited unsuccessfully (${String(code)} ${String(terminationSignal)})`
35473
+ spawnError ?? new GitCommandError(
35474
+ detail.length > 0 ? `git exited unsuccessfully: ${detail}` : `git exited unsuccessfully (${String(code)} ${String(terminationSignal)})`,
35475
+ code
35485
35476
  )
35486
35477
  );
35487
35478
  });
35479
+ listener = addAbortListener(signal, () => {
35480
+ void stop().catch(reject);
35481
+ });
35488
35482
  });
35483
+ try {
35484
+ return await completion;
35485
+ } finally {
35486
+ listener?.[Symbol.dispose]();
35487
+ await stop();
35488
+ }
35489
35489
  }
35490
35490
  function extractTar(archivePath, destination, signal) {
35491
35491
  return new Promise((resolve6, reject) => {
@@ -35606,27 +35606,52 @@ async function captureCommit(workdir, repositoryPath2, sourceRevision, signal) {
35606
35606
  function scopedSourceCapture(capture, failureMessage) {
35607
35607
  return {
35608
35608
  capture: () => acquireRelease2(
35609
- sync2(
35610
- () => (
35611
- // Canonical, so every path derived from the scratch matches the
35612
- // realpaths pnpm reports (macOS tmpdir is a symlink).
35613
- realpathSync(mkdtempSync(join5(tmpdir(), "app-publisher-")))
35614
- )
35615
- ),
35616
- (workdir) => tryPromise2({
35617
- try: () => rm(workdir, { recursive: true, force: true }),
35618
- catch: () => new Error("Local source cleanup failed")
35619
- }).pipe(
35620
- catch_2((cause) => {
35621
- logEvent("services/app-publisher/src/local.ts:289", cause);
35622
- return void_3;
35623
- })
35624
- )
35609
+ sync2(() => {
35610
+ const scratch = mkdtempSync(join5(tmpdir(), "app-publisher-"));
35611
+ try {
35612
+ return realpathSync(scratch);
35613
+ } catch (cause) {
35614
+ try {
35615
+ rmSync(scratch, { recursive: true, force: true });
35616
+ } catch (cleanupCause) {
35617
+ throw new CleanupError("Source snapshot cleanup failed", {
35618
+ cause: cleanupCause
35619
+ });
35620
+ }
35621
+ throw cause;
35622
+ }
35623
+ }),
35624
+ (workdir) => promise2(async () => {
35625
+ try {
35626
+ await rm(workdir, { recursive: true, force: true });
35627
+ } catch (cause) {
35628
+ throw new CleanupError("Source snapshot cleanup failed", {
35629
+ cause
35630
+ });
35631
+ }
35632
+ })
35625
35633
  ).pipe(
35626
35634
  flatMap2(
35627
- (workdir) => tryPromise2({
35628
- try: (signal) => capture(workdir, signal),
35629
- catch: () => new Error(failureMessage)
35635
+ (workdir) => callback2((resume, signal) => {
35636
+ const pending = capture(workdir, signal);
35637
+ pending.then(
35638
+ (source) => {
35639
+ resume(succeed5(source));
35640
+ },
35641
+ (cause) => {
35642
+ resume(
35643
+ cause instanceof CleanupError ? die3(cause) : fail5(new Error(failureMessage))
35644
+ );
35645
+ }
35646
+ );
35647
+ return promise2(
35648
+ () => pending.then(
35649
+ () => void 0,
35650
+ (cause) => {
35651
+ if (cause instanceof CleanupError) throw cause;
35652
+ }
35653
+ )
35654
+ );
35630
35655
  })
35631
35656
  )
35632
35657
  )
@@ -35661,35 +35686,6 @@ function capturedWorkspaceBuild(snapshot, entry, run2, backendEntry) {
35661
35686
  })
35662
35687
  );
35663
35688
  }
35664
- function htmlGroupExists(child) {
35665
- if (child.pid === void 0) return false;
35666
- try {
35667
- process.kill(-child.pid, 0);
35668
- return true;
35669
- } catch (error2) {
35670
- if (error2 instanceof Error && "code" in error2 && error2.code === "ESRCH")
35671
- return false;
35672
- throw error2;
35673
- }
35674
- }
35675
- async function stopHtmlGroup(child) {
35676
- if (!htmlGroupExists(child)) return;
35677
- const deadline = Date.now() + 5e3;
35678
- for (const [signal, until] of [
35679
- ["SIGTERM", deadline - 1e3],
35680
- ["SIGKILL", deadline]
35681
- ]) {
35682
- try {
35683
- if (child.pid !== void 0) process.kill(-child.pid, signal);
35684
- } catch (error2) {
35685
- if (!(error2 instanceof Error && "code" in error2 && error2.code === "ESRCH"))
35686
- throw error2;
35687
- }
35688
- while (htmlGroupExists(child) && Date.now() < until) await delay2(25);
35689
- if (!htmlGroupExists(child)) return;
35690
- }
35691
- throw new Error("HTML process group survived its five-second cleanup bound");
35692
- }
35693
35689
  function runHtmlCommand(args2, cwd, env, command = "pnpm", onOutput) {
35694
35690
  return acquireUseRelease2(
35695
35691
  sync2(() => {
@@ -35730,7 +35726,7 @@ function runHtmlCommand(args2, cwd, env, command = "pnpm", onOutput) {
35730
35726
  return { child, completion };
35731
35727
  }),
35732
35728
  ({ completion }) => tryPromise2({ try: () => completion, catch: (error2) => error2 }),
35733
- ({ child }) => promise2(() => stopHtmlGroup(child))
35729
+ ({ child }) => promise2(() => stopProcessGroup(child))
35734
35730
  );
35735
35731
  }
35736
35732
  function snapshotPrograms() {
@@ -35788,14 +35784,16 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
35788
35784
  const appDirectory = join5(sourceSnapshotPath, html.directory);
35789
35785
  const dependencies = join5(appDirectory, ".publisher-dependencies.mjs");
35790
35786
  const program = join5(appDirectory, ".publisher-build.mjs");
35791
- yield* tryPromise2({
35792
- try: async () => {
35793
- const { dependencyBuildProgram: dependencyBuildProgram2, htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
35794
- await writeFile2(dependencies, dependencyBuildProgram2, { flag: "wx" });
35795
- await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
35796
- },
35797
- catch: (error2) => error2
35798
- });
35787
+ yield* uninterruptible2(
35788
+ tryPromise2({
35789
+ try: async () => {
35790
+ const { dependencyBuildProgram: dependencyBuildProgram2, htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
35791
+ await writeFile2(dependencies, dependencyBuildProgram2, { flag: "wx" });
35792
+ await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
35793
+ },
35794
+ catch: (error2) => error2
35795
+ })
35796
+ );
35799
35797
  const groups = [];
35800
35798
  for (const step of html.steps) {
35801
35799
  const last = groups.at(-1);
@@ -35981,11 +35979,13 @@ function rebuildNpmSnapshot(sourceSnapshotPath, recipe, options) {
35981
35979
  const globalConfig2 = join5(home, "global.npmrc");
35982
35980
  env.npm_config_userconfig = userConfig;
35983
35981
  env.npm_config_globalconfig = globalConfig2;
35984
- yield* tryPromise2(async () => {
35985
- await mkdir(home, { recursive: true });
35986
- await writeFile2(userConfig, "", { flag: "wx" });
35987
- await writeFile2(globalConfig2, "", { flag: "wx" });
35988
- });
35982
+ yield* uninterruptible2(
35983
+ tryPromise2(async () => {
35984
+ await mkdir(home, { recursive: true });
35985
+ await writeFile2(userConfig, "", { flag: "wx" });
35986
+ await writeFile2(globalConfig2, "", { flag: "wx" });
35987
+ })
35988
+ );
35989
35989
  if ((yield* runHtmlCommand(
35990
35990
  ["--version"],
35991
35991
  sourceSnapshotPath,
@@ -36004,10 +36004,12 @@ function rebuildNpmSnapshot(sourceSnapshotPath, recipe, options) {
36004
36004
  options.onOutput
36005
36005
  );
36006
36006
  const program = join5(sourceSnapshotPath, ".publisher-build.mjs");
36007
- yield* tryPromise2(async () => {
36008
- const { htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
36009
- await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
36010
- });
36007
+ yield* uninterruptible2(
36008
+ tryPromise2(async () => {
36009
+ const { htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
36010
+ await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
36011
+ })
36012
+ );
36011
36013
  yield* runHtmlCommand(
36012
36014
  [
36013
36015
  program,
@@ -36234,15 +36236,15 @@ function createLocalBuildExecutor(options = {}) {
36234
36236
  ),
36235
36237
  catch: (error2) => error2 instanceof Error ? error2 : new Error("Local snapshot build failed")
36236
36238
  }),
36237
- ({ context: context3 }) => tryPromise2({
36238
- try: () => context3.dispose(),
36239
- catch: () => new Error("Local build cleanup failed")
36240
- }).pipe(
36241
- catch_2((cause) => {
36242
- logEvent("services/app-publisher/src/local.ts:1262", cause);
36243
- return void_3;
36244
- })
36245
- )
36239
+ ({ context: context3 }) => promise2(async () => {
36240
+ try {
36241
+ await context3.dispose();
36242
+ } catch (cause) {
36243
+ throw new CleanupError("Local compiler cleanup failed", {
36244
+ cause
36245
+ });
36246
+ }
36247
+ })
36246
36248
  );
36247
36249
  }
36248
36250
  };
@@ -36259,10 +36261,29 @@ function createLocalBuildExecutor(options = {}) {
36259
36261
  });
36260
36262
  emissions.set(source, emission);
36261
36263
  const output = yield* compiler2.build(source, recipe);
36262
- const declaration3 = yield* tryPromise2({
36263
- try: (signal) => emission.declare(signal),
36264
- catch: (cause) => cause instanceof Error ? cause : new Error("App declaration emission failed", { cause })
36265
- });
36264
+ const declaration3 = yield* callback2(
36265
+ (resume, signal) => {
36266
+ const pending = emission.declare(signal);
36267
+ pending.then(
36268
+ (value) => {
36269
+ resume(succeed5(value));
36270
+ },
36271
+ (cause) => {
36272
+ resume(
36273
+ fail5(
36274
+ cause instanceof Error ? cause : new Error("App declaration emission failed", { cause })
36275
+ )
36276
+ );
36277
+ }
36278
+ );
36279
+ return promise2(
36280
+ () => pending.then(
36281
+ () => void 0,
36282
+ () => void 0
36283
+ )
36284
+ );
36285
+ }
36286
+ );
36266
36287
  declarations.set(source, declaration3);
36267
36288
  return output;
36268
36289
  }),