@fungi.computer/computer 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,13 +75,19 @@ from the repository root:
75
75
  pnpm turbo:run run build --filter=@fungi.computer/computer
76
76
  pnpm --filter @fungi.computer/computer typecheck
77
77
  pnpm --filter @fungi.computer/computer lint
78
- pnpm --filter @fungi.computer/computer test
78
+ pnpm turbo:run run test --filter=@fungi.computer/computer
79
79
  ```
80
80
 
81
- The build emits the runtime and copies its daemon/build assets. The test suite
82
- uses disposable Workers and proof containers, so container proofs require a
83
- working local Docker/Workers environment. These commands do not deploy a Hub,
84
- publish an App or replace a production Computer image.
81
+ The build emits the runtime and copies its daemon/build assets. The test graph
82
+ assembles and builds the local container image before starting native Worker
83
+ checks. Docker owns its layer cache; the image build has a separate bounded
84
+ proof lifetime, so cold compilation does not consume the Worker response
85
+ deadline. Before invoking a native test file directly, run
86
+ `pnpm turbo:run run build:container --filter=@fungi.computer/computer`.
87
+
88
+ The test suite uses disposable Workers and proof containers, so container proofs
89
+ require a working local Docker/Workers environment. These commands do not deploy
90
+ a Hub, publish an App or replace a production Computer image.
85
91
 
86
92
  ## Files and operation results
87
93
 
@@ -11207,7 +11207,7 @@ var WebSocketTransport = class {
11207
11207
  let reasonBytes = new TextEncoder().encode(message);
11208
11208
  if (reasonBytes.length > 123) message = new TextDecoder().decode(reasonBytes.subarray(0, 123), { stream: true });
11209
11209
  this.#webSocket.close(3e3, message);
11210
- if (!this.#error) this.#error = reason;
11210
+ this.#receivedError(reason);
11211
11211
  }
11212
11212
  #receivedError(reason) {
11213
11213
  if (!this.#error) {
@@ -98,9 +98,11 @@ export declare class FleetLifecycle {
98
98
  private observeRuntime;
99
99
  /** Whether the runtime still runs, and when it stopped if it does not. */
100
100
  private readRuntime;
101
- awaitRecycle(): Promise<void>;
101
+ /** Native execution and host slot decisions wait until an idle stop is accounted for. */
102
+ awaitRuntimeMaintenance(): Promise<void>;
102
103
  /** Reconcile durable observations before the host delivers usage facts. */
103
104
  observe(): Promise<HostedBacking[]>;
105
+ private observeRuntimes;
104
106
  /** The host supplies current permission; this owner chooses quiet runtime candidates. */
105
107
  recycle(grant: ComputerGrant | null): Promise<void>;
106
108
  watch(delivered: boolean, running: number): Promise<void>;
@@ -31,6 +31,7 @@ export class FleetLifecycle {
31
31
  #startingHosted = 0;
32
32
  #lastHostedActivity = Date.now();
33
33
  #recycling;
34
+ #observing;
34
35
  #recycleRuntimeId;
35
36
  #facts = [];
36
37
  constructor(ports) {
@@ -124,7 +125,7 @@ export class FleetLifecycle {
124
125
  }
125
126
  /** Native execution remains the callback; policy has already become a grant. */
126
127
  async run(grant, backing, run) {
127
- await this.awaitRecycle();
128
+ await this.awaitRuntimeMaintenance();
128
129
  if (checkComputerGrant(grant, {
129
130
  computerId: this.ports.computerId ?? "",
130
131
  action: "start",
@@ -374,14 +375,30 @@ export class FleetLifecycle {
374
375
  exitedAt: Math.min(now, state.exit?.exitedAt ?? now),
375
376
  };
376
377
  }
377
- async awaitRecycle() {
378
- const error = await this.#recycling;
379
- if (error !== undefined)
380
- throw error;
378
+ /** Native execution and host slot decisions wait until an idle stop is accounted for. */
379
+ async awaitRuntimeMaintenance() {
380
+ while (this.#recycling !== undefined || this.#observing !== undefined) {
381
+ const error = await this.#recycling;
382
+ if (error !== undefined)
383
+ throw error;
384
+ await this.#observing;
385
+ }
381
386
  }
382
387
  /** Reconcile durable observations before the host delivers usage facts. */
383
388
  async observe() {
384
389
  await this.#recycling;
390
+ if (this.#observing !== undefined)
391
+ return this.#observing;
392
+ const observing = this.observeRuntimes();
393
+ this.#observing = observing;
394
+ try {
395
+ return await observing;
396
+ }
397
+ finally {
398
+ this.#observing = undefined;
399
+ }
400
+ }
401
+ async observeRuntimes() {
385
402
  this.usage.ensure();
386
403
  await this.finishVmRecycle();
387
404
  return this.observeOpenRuntimes();
package/dist/on-box-vm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import * as Data from "effect/Data";
3
- import { SeamReplayGuard, importSeamSigner, importSeamVerifiers, seamBodyDigest, seamHeader, signSeamRequest, unsignedPayload, verifySeamRequest, } from "@fungi.computer/seam";
3
+ import { SeamReplayPartitions, importSeamSigner, importSeamVerifiers, seamBodyDigest, seamHeader, signSeamRequest, unsignedPayload, verifySeamRequest, } from "@fungi.computer/seam";
4
4
  function accessHeaders(env) {
5
5
  const id = env.COMPUTER_VM_ACCESS_CLIENT_ID;
6
6
  const secret = env.COMPUTER_VM_ACCESS_CLIENT_SECRET;
@@ -241,7 +241,24 @@ export class OnBoxVmContainerHost {
241
241
  }
242
242
  const ingressPath = /^\/__computer-vm\/([0-9a-f]{64})(\/.*)$/;
243
243
  const egressUrlSchema = z.url({ protocol: /^https?$/ });
244
- const ingressReplay = new SeamReplayGuard();
244
+ /** Slots one host's vmd can place (`maxSlots` in the celld VM instances). */
245
+ const vmSlotsPerHost = 16_000;
246
+ const ingressReplays = new Map();
247
+ /**
248
+ * Ingress replay history, one bounded partition per VM id. The id is part of
249
+ * the signed path, so one guest's request rate fills only its own VM's
250
+ * history and never refuses another VM on the same or another host. The
251
+ * partition ceiling is every VM the registered hosts can place.
252
+ */
253
+ function ingressReplay(env, vmId) {
254
+ const raw = env.COMPUTER_VM_HOSTS ?? "{}";
255
+ let replays = ingressReplays.get(raw);
256
+ if (replays === undefined) {
257
+ replays = new SeamReplayPartitions(Math.max(1, Object.keys(hostRegistry(env)).length) * vmSlotsPerHost);
258
+ ingressReplays.set(raw, replays);
259
+ }
260
+ return replays.partition(vmId);
261
+ }
245
262
  /**
246
263
  * The host service's door into this Worker: a VM's intercepted request
247
264
  * reaches its Computer exactly as the platform container's interception
@@ -258,9 +275,9 @@ export function onBoxVmIngress(request, env, computers) {
258
275
  return verifiedVmIngress(request, env, computers, id, rest, url.search);
259
276
  }
260
277
  /** The verified host id of a signed ingress request, or undefined. */
261
- async function ingressHost(request, env) {
278
+ async function ingressHost(request, env, vmId) {
262
279
  try {
263
- return await verifySeamRequest(await hostVerifiers(env), vmIngressAudience, request.method, request.url, request.headers.get(seamHeader), null, ingressReplay);
280
+ return await verifySeamRequest(await hostVerifiers(env), vmIngressAudience, request.method, request.url, request.headers.get(seamHeader), null, ingressReplay(env, vmId));
264
281
  }
265
282
  catch (cause) {
266
283
  console.error("VM seam verification refused", cause);
@@ -296,7 +313,7 @@ function vmEgressTarget(target, headers, token, url) {
296
313
  target.search = "";
297
314
  }
298
315
  async function verifiedVmIngress(request, env, computers, id, rest, search) {
299
- const hostId = await ingressHost(request, env);
316
+ const hostId = await ingressHost(request, env, id);
300
317
  if (hostId === undefined)
301
318
  return new Response(null, { status: 404 });
302
319
  const headers = new Headers(request.headers);
@@ -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({
@@ -22548,15 +22454,15 @@ function encodeTeamAppCandidateManifest(manifest) {
22548
22454
  function candidateManifestObjects(output) {
22549
22455
  const objects = [];
22550
22456
  const add2 = (object3, mediaType) => {
22551
- const seen = objects.find(({ digest }) => digest === object3.digest);
22552
- if (seen === void 0)
22457
+ const named = objects.filter(({ digest }) => digest === object3.digest);
22458
+ if (named.some(({ byteLength }) => byteLength !== object3.byteLength))
22459
+ throw new Error("One object digest names two sizes");
22460
+ if (!named.some((seen) => seen.mediaType === mediaType))
22553
22461
  objects.push({
22554
22462
  digest: object3.digest,
22555
22463
  byteLength: object3.byteLength,
22556
22464
  mediaType
22557
22465
  });
22558
- else if (seen.byteLength !== object3.byteLength)
22559
- throw new Error("One object digest names two sizes");
22560
22466
  };
22561
22467
  if (output.kind !== "backend") {
22562
22468
  const { content } = output.ui;
@@ -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" }
@@ -24034,26 +24022,24 @@ function sha256(bytes) {
24034
24022
  `sha256:${createHash2("sha256").update(bytes).digest("hex")}`
24035
24023
  );
24036
24024
  }
24037
- function contentArtifactRef(digest) {
24038
- return parseArtifactRef(`artifact:sha256-${digest.slice("sha256:".length)}`);
24039
- }
24040
24025
  var fallbackRootBytes = 1024 * 1024;
24041
24026
  function stageBuildOutput(output) {
24042
24027
  const objects = [];
24043
- const stage = (bytes) => {
24028
+ const stage = (bytes, mediaType) => {
24044
24029
  const digest = sha256(bytes);
24045
- if (!objects.some((object3) => object3.digest === digest))
24046
- objects.push({
24047
- artifactRef: contentArtifactRef(digest),
24048
- bytes: bytes.slice(),
24049
- digest
24050
- });
24030
+ if (!objects.some(
24031
+ (object3) => object3.digest === digest && object3.mediaType === mediaType
24032
+ ))
24033
+ objects.push({ bytes: bytes.slice(), digest, mediaType });
24051
24034
  return { digest, byteLength: bytes.byteLength };
24052
24035
  };
24053
24036
  const declared = output.declaration === void 0 ? {} : { declaration: output.declaration };
24054
24037
  const ui = (prepared) => prepared.content.kind === "html" ? {
24055
24038
  mediaType: "text/html; charset=utf-8",
24056
- content: { kind: "html", ...stage(prepared.content.bytes) }
24039
+ content: {
24040
+ kind: "html",
24041
+ ...stage(prepared.content.bytes, "text/html; charset=utf-8")
24042
+ }
24057
24043
  } : {
24058
24044
  mediaType: "application/vnd.fungi.app-assets+json",
24059
24045
  content: {
@@ -24061,14 +24047,24 @@ function stageBuildOutput(output) {
24061
24047
  base: prepared.content.base,
24062
24048
  assets: prepared.content.assets.map((asset) => ({
24063
24049
  path: asset.path,
24064
- ...stage(asset.bytes)
24050
+ ...stage(asset.bytes, "application/octet-stream")
24065
24051
  }))
24066
24052
  }
24067
24053
  };
24068
- const manifest = output.kind === "ui" ? { kind: "ui", ui: ui(output.ui), ...declared } : output.kind === "backend" ? { kind: "backend", backend: stage(output.backend), ...declared } : {
24054
+ const manifest = output.kind === "ui" ? { kind: "ui", ui: ui(output.ui), ...declared } : output.kind === "backend" ? {
24055
+ kind: "backend",
24056
+ backend: stage(
24057
+ output.backend,
24058
+ "application/vnd.fungi.app-backend+json"
24059
+ ),
24060
+ ...declared
24061
+ } : {
24069
24062
  kind: "app",
24070
24063
  ui: ui(output.ui),
24071
- backend: stage(output.backend),
24064
+ backend: stage(
24065
+ output.backend,
24066
+ "application/vnd.fungi.app-backend+json"
24067
+ ),
24072
24068
  ...declared
24073
24069
  };
24074
24070
  return { manifest, objects };
@@ -32331,7 +32327,7 @@ async function readBundledHtml(snapshot, recipe) {
32331
32327
  // src/build/local-build.ts
32332
32328
  import { createHash as createHash3, randomBytes } from "node:crypto";
32333
32329
  import { spawn } from "node:child_process";
32334
- import { createReadStream, mkdtempSync, realpathSync } from "node:fs";
32330
+ import { createReadStream, mkdtempSync, realpathSync, rmSync } from "node:fs";
32335
32331
  import {
32336
32332
  access as access3,
32337
32333
  cp,
@@ -32353,7 +32349,6 @@ import {
32353
32349
  sep as sep4
32354
32350
  } from "node:path";
32355
32351
  import { pipeline } from "node:stream/promises";
32356
- import { setTimeout as delay2 } from "node:timers/promises";
32357
32352
  import * as esbuild from "esbuild";
32358
32353
 
32359
32354
  // ../../node_modules/.pnpm/@pnpm+crypto.hash@1100.0.8/node_modules/@pnpm/crypto.hash/lib/index.js
@@ -35422,15 +35417,6 @@ function repositoryEnvironment() {
35422
35417
  }
35423
35418
 
35424
35419
  // src/build/local-build.ts
35425
- function logEvent(operation, cause) {
35426
- console.error(
35427
- JSON.stringify({
35428
- source: "app-publisher",
35429
- operation,
35430
- failureKind: cause instanceof Error ? "Error" : "NonErrorThrown"
35431
- })
35432
- );
35433
- }
35434
35420
  var localConfigSchema = Struct({
35435
35421
  appId: appIdSchema,
35436
35422
  source: Struct({
@@ -35448,15 +35434,27 @@ async function sha256File(path, signal) {
35448
35434
  await pipeline(createReadStream(path), hash2, { signal });
35449
35435
  return parseSha256Digest(`sha256:${hash2.digest("hex")}`);
35450
35436
  }
35451
- function runGit(args2, cwd, signal, environment = repositoryEnvironment()) {
35452
- return new Promise((resolve6, reject) => {
35453
- const child = spawn("git", [...args2], {
35454
- cwd,
35455
- env: environment,
35456
- shell: false,
35457
- signal,
35458
- stdio: ["ignore", "pipe", "pipe"]
35459
- });
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) => {
35460
35458
  const stdout = [];
35461
35459
  const stderr = [];
35462
35460
  let spawnError;
@@ -35472,12 +35470,22 @@ function runGit(args2, cwd, signal, environment = repositoryEnvironment()) {
35472
35470
  }
35473
35471
  const detail = Buffer2.concat(stderr).toString("utf8").trim();
35474
35472
  reject(
35475
- spawnError ?? new Error(
35476
- 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
35477
35476
  )
35478
35477
  );
35479
35478
  });
35479
+ listener = addAbortListener(signal, () => {
35480
+ void stop().catch(reject);
35481
+ });
35480
35482
  });
35483
+ try {
35484
+ return await completion;
35485
+ } finally {
35486
+ listener?.[Symbol.dispose]();
35487
+ await stop();
35488
+ }
35481
35489
  }
35482
35490
  function extractTar(archivePath, destination, signal) {
35483
35491
  return new Promise((resolve6, reject) => {
@@ -35598,21 +35606,52 @@ async function captureCommit(workdir, repositoryPath2, sourceRevision, signal) {
35598
35606
  function scopedSourceCapture(capture, failureMessage) {
35599
35607
  return {
35600
35608
  capture: () => acquireRelease2(
35601
- sync2(() => mkdtempSync(join5(tmpdir(), "app-publisher-"))),
35602
- (workdir) => tryPromise2({
35603
- try: () => rm(workdir, { recursive: true, force: true }),
35604
- catch: () => new Error("Local source cleanup failed")
35605
- }).pipe(
35606
- catch_2((cause) => {
35607
- logEvent("services/app-publisher/src/local.ts:289", cause);
35608
- return void_3;
35609
- })
35610
- )
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
+ })
35611
35633
  ).pipe(
35612
35634
  flatMap2(
35613
- (workdir) => tryPromise2({
35614
- try: (signal) => capture(workdir, signal),
35615
- 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
+ );
35616
35655
  })
35617
35656
  )
35618
35657
  )
@@ -35647,35 +35686,6 @@ function capturedWorkspaceBuild(snapshot, entry, run2, backendEntry) {
35647
35686
  })
35648
35687
  );
35649
35688
  }
35650
- function htmlGroupExists(child) {
35651
- if (child.pid === void 0) return false;
35652
- try {
35653
- process.kill(-child.pid, 0);
35654
- return true;
35655
- } catch (error2) {
35656
- if (error2 instanceof Error && "code" in error2 && error2.code === "ESRCH")
35657
- return false;
35658
- throw error2;
35659
- }
35660
- }
35661
- async function stopHtmlGroup(child) {
35662
- if (!htmlGroupExists(child)) return;
35663
- const deadline = Date.now() + 5e3;
35664
- for (const [signal, until] of [
35665
- ["SIGTERM", deadline - 1e3],
35666
- ["SIGKILL", deadline]
35667
- ]) {
35668
- try {
35669
- if (child.pid !== void 0) process.kill(-child.pid, signal);
35670
- } catch (error2) {
35671
- if (!(error2 instanceof Error && "code" in error2 && error2.code === "ESRCH"))
35672
- throw error2;
35673
- }
35674
- while (htmlGroupExists(child) && Date.now() < until) await delay2(25);
35675
- if (!htmlGroupExists(child)) return;
35676
- }
35677
- throw new Error("HTML process group survived its five-second cleanup bound");
35678
- }
35679
35689
  function runHtmlCommand(args2, cwd, env, command = "pnpm", onOutput) {
35680
35690
  return acquireUseRelease2(
35681
35691
  sync2(() => {
@@ -35716,7 +35726,7 @@ function runHtmlCommand(args2, cwd, env, command = "pnpm", onOutput) {
35716
35726
  return { child, completion };
35717
35727
  }),
35718
35728
  ({ completion }) => tryPromise2({ try: () => completion, catch: (error2) => error2 }),
35719
- ({ child }) => promise2(() => stopHtmlGroup(child))
35729
+ ({ child }) => promise2(() => stopProcessGroup(child))
35720
35730
  );
35721
35731
  }
35722
35732
  function snapshotPrograms() {
@@ -35774,14 +35784,16 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
35774
35784
  const appDirectory = join5(sourceSnapshotPath, html.directory);
35775
35785
  const dependencies = join5(appDirectory, ".publisher-dependencies.mjs");
35776
35786
  const program = join5(appDirectory, ".publisher-build.mjs");
35777
- yield* tryPromise2({
35778
- try: async () => {
35779
- const { dependencyBuildProgram: dependencyBuildProgram2, htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
35780
- await writeFile2(dependencies, dependencyBuildProgram2, { flag: "wx" });
35781
- await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
35782
- },
35783
- catch: (error2) => error2
35784
- });
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
+ );
35785
35797
  const groups = [];
35786
35798
  for (const step of html.steps) {
35787
35799
  const last = groups.at(-1);
@@ -35967,11 +35979,13 @@ function rebuildNpmSnapshot(sourceSnapshotPath, recipe, options) {
35967
35979
  const globalConfig2 = join5(home, "global.npmrc");
35968
35980
  env.npm_config_userconfig = userConfig;
35969
35981
  env.npm_config_globalconfig = globalConfig2;
35970
- yield* tryPromise2(async () => {
35971
- await mkdir(home, { recursive: true });
35972
- await writeFile2(userConfig, "", { flag: "wx" });
35973
- await writeFile2(globalConfig2, "", { flag: "wx" });
35974
- });
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
+ );
35975
35989
  if ((yield* runHtmlCommand(
35976
35990
  ["--version"],
35977
35991
  sourceSnapshotPath,
@@ -35990,10 +36004,12 @@ function rebuildNpmSnapshot(sourceSnapshotPath, recipe, options) {
35990
36004
  options.onOutput
35991
36005
  );
35992
36006
  const program = join5(sourceSnapshotPath, ".publisher-build.mjs");
35993
- yield* tryPromise2(async () => {
35994
- const { htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
35995
- await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
35996
- });
36007
+ yield* uninterruptible2(
36008
+ tryPromise2(async () => {
36009
+ const { htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
36010
+ await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
36011
+ })
36012
+ );
35997
36013
  yield* runHtmlCommand(
35998
36014
  [
35999
36015
  program,
@@ -36220,15 +36236,15 @@ function createLocalBuildExecutor(options = {}) {
36220
36236
  ),
36221
36237
  catch: (error2) => error2 instanceof Error ? error2 : new Error("Local snapshot build failed")
36222
36238
  }),
36223
- ({ context: context3 }) => tryPromise2({
36224
- try: () => context3.dispose(),
36225
- catch: () => new Error("Local build cleanup failed")
36226
- }).pipe(
36227
- catch_2((cause) => {
36228
- logEvent("services/app-publisher/src/local.ts:1262", cause);
36229
- return void_3;
36230
- })
36231
- )
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
+ })
36232
36248
  );
36233
36249
  }
36234
36250
  };
@@ -36245,10 +36261,29 @@ function createLocalBuildExecutor(options = {}) {
36245
36261
  });
36246
36262
  emissions.set(source, emission);
36247
36263
  const output = yield* compiler2.build(source, recipe);
36248
- const declaration3 = yield* tryPromise2({
36249
- try: (signal) => emission.declare(signal),
36250
- catch: (cause) => cause instanceof Error ? cause : new Error("App declaration emission failed", { cause })
36251
- });
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
+ );
36252
36287
  declarations.set(source, declaration3);
36253
36288
  return output;
36254
36289
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/computer",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Cloudflare Computer host for one durable Fungi Computer",
6
6
  "type": "module",
@@ -57,13 +57,13 @@
57
57
  ],
58
58
  "dependencies": {
59
59
  "@fungi.computer/cairn": "0.1.0",
60
- "@fungi.computer/capnweb": "0.12.0",
60
+ "@fungi.computer/capnweb": "0.12.0-fungi.0",
61
61
  "@fungi.computer/cloudflare-computer": "0.2.1-fungi.2",
62
62
  "@fungi.computer/cordyceps": "0.4.0",
63
- "@fungi.computer/knapsack": "0.4.5",
64
- "@fungi.computer/seam": "0.2.1",
65
- "@fungi.computer/watchdog": "0.1.0",
66
- "@fungi.computer/computer-contract": "0.0.10",
63
+ "@fungi.computer/knapsack": "0.4.6",
64
+ "@fungi.computer/seam": "0.2.3",
65
+ "@fungi.computer/watchdog": "0.1.1",
66
+ "@fungi.computer/computer-contract": "0.0.11",
67
67
  "effect": "4.0.2",
68
68
  "just-bash": "3.4.2",
69
69
  "zod": "4.4.3"
@@ -109,6 +109,7 @@
109
109
  "lint": "eslint src test container scripts --max-warnings=0 && oxlint --config ../../oxlint.config.ts --deny-warnings src test container scripts",
110
110
  "typecheck": "tsc -p tsconfig.json --noEmit",
111
111
  "build": "pnpm run clean && tsc -p tsconfig.build.json && node scripts/copy-daemon.mjs",
112
+ "build:container": "bash ../../tooling/proof-runner/run-proof.sh docker build --load --platform linux/amd64 --provenance=false .",
112
113
  "build:native": "fungi-apply-patch-build --out native/bin",
113
114
  "clean": "node --input-type=module --eval \"import { rm } from 'node:fs/promises'; await rm('dist', { recursive: true, force: true });\"",
114
115
  "test": "pnpm run test:unit && pnpm run test:fleet-native && node test/files-rpc.native.mjs && node test/port-proof.mjs && node test/terminal-container-proof.mjs && node test/fuse-startup-proof.mjs && node test/container-resource-proof.mjs && node test/runtime-proof.mjs && node test/process-schema-proof.mjs && node test/process-proof.mjs && node test/terminal-proof.mjs && pnpm run test:app-method-execution && pnpm run test:execution-lifecycle",
@@ -118,7 +119,7 @@
118
119
  "test:nightly": "bash ../../tooling/proof-runner/run-proof.sh node test/egress-proof.mjs",
119
120
  "test:app-method-execution": "node test/app-method-execution-proof.mjs",
120
121
  "test:execution-lifecycle": "node test/execution-lifecycle-proof.mjs",
121
- "test:unit": "node --test --test-concurrency=${BOTANICAL_TEST_WORKERS:-4} test/egress-policy.test.mjs test/preview.test.mjs test/fleet.test.mjs test/proof-worker.test.mjs test/proof-client.test.mjs test/native-readiness.test.mjs test/workspace-sync.test.mjs test/runtime-observer.test.mjs test/files-patch.test.mjs test/exec-output.test.mjs && node --test --test-concurrency=${BOTANICAL_TEST_WORKERS:-4} test/seam-signature.test.mjs test/local-backend-replay.test.mjs test/machine-link-reopen-replay.test.mjs test/computer-backends.test.mjs test/terminal-welcome.test.mjs test/on-box-vm.test.mjs && node test/terminal-protocol.test.mjs && node test/container-policy.test.mjs && node test/files-adapter-proof.mjs && node test/operation-record-proof.mjs && node test/process-inventory-proof.mjs",
122
+ "test:unit": "bash ../../tooling/proof-runner/hermetic-host.sh -- sh -c \"node --test --test-concurrency=${BOTANICAL_TEST_WORKERS:-4} test/egress-policy.test.mjs test/preview.test.mjs test/fleet.test.mjs test/proof-worker.test.mjs test/proof-client.test.mjs test/native-readiness.test.mjs test/workspace-sync.test.mjs test/runtime-observer.test.mjs test/files-patch.test.mjs test/exec-output.test.mjs && node --test --test-concurrency=${BOTANICAL_TEST_WORKERS:-4} test/seam-signature.test.mjs test/local-backend-replay.test.mjs test/machine-link-reopen-replay.test.mjs test/computer-backends.test.mjs test/terminal-welcome.test.mjs test/on-box-vm.test.mjs && node test/terminal-protocol.test.mjs && node test/container-policy.test.mjs && node test/files-adapter-proof.mjs && node test/operation-record-proof.mjs && node test/process-inventory-proof.mjs\"",
122
123
  "test:fleet-native": "node test/fleet.native.mjs",
123
124
  "assemble:image": "node scripts/assemble-image.mjs"
124
125
  }