@fungi.computer/computer 0.15.1 → 0.16.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.
@@ -78,17 +78,21 @@ export declare const computerGrantSchema: z.ZodObject<{
78
78
  }, z.core.$strict>;
79
79
  export type ComputerGrant = z.output<typeof computerGrantSchema>;
80
80
  /** State visible without knowing which application hosts the Computer. */
81
- export declare const computerStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
81
+ export declare const computerStateSchema: z.ZodUnion<readonly [z.ZodObject<{
82
82
  state: z.ZodEnum<{
83
83
  running: "running";
84
84
  sleeping: "sleeping";
85
85
  starting: "starting";
86
- start_failed: "start_failed";
87
86
  }>;
87
+ }, z.core.$strict>, z.ZodObject<{
88
+ state: z.ZodLiteral<"start_failed">;
89
+ }, z.core.$strict>, z.ZodObject<{
90
+ state: z.ZodLiteral<"start_failed">;
91
+ reason: z.ZodString;
88
92
  }, z.core.$strict>, z.ZodObject<{
89
93
  state: z.ZodLiteral<"queued">;
90
94
  position: z.ZodNumber;
91
- }, z.core.$strict>], "state">;
95
+ }, z.core.$strict>]>;
92
96
  export type ComputerRuntimeState = z.output<typeof computerStateSchema>;
93
97
  /** Hosted fallback order, with the same bound and identity law as the retained owner. */
94
98
  export declare const hostedBackingsSchema: z.ZodLazy<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -228,17 +232,21 @@ export declare const computerFactSchema: z.ZodLazy<z.ZodDiscriminatedUnion<[z.Zo
228
232
  }, z.core.$strict>, z.ZodObject<{
229
233
  kind: z.ZodLiteral<"lifecycle">;
230
234
  observedAt: z.ZodNumber;
231
- state: z.ZodDiscriminatedUnion<[z.ZodObject<{
235
+ state: z.ZodUnion<readonly [z.ZodObject<{
232
236
  state: z.ZodEnum<{
233
237
  running: "running";
234
238
  sleeping: "sleeping";
235
239
  starting: "starting";
236
- start_failed: "start_failed";
237
240
  }>;
241
+ }, z.core.$strict>, z.ZodObject<{
242
+ state: z.ZodLiteral<"start_failed">;
243
+ }, z.core.$strict>, z.ZodObject<{
244
+ state: z.ZodLiteral<"start_failed">;
245
+ reason: z.ZodString;
238
246
  }, z.core.$strict>, z.ZodObject<{
239
247
  state: z.ZodLiteral<"queued">;
240
248
  position: z.ZodNumber;
241
- }, z.core.$strict>], "state">;
249
+ }, z.core.$strict>]>;
242
250
  computerId: z.ZodString;
243
251
  provenance: z.ZodObject<{
244
252
  actor: z.ZodString;
@@ -33,10 +33,16 @@ export const computerGrantSchema = z.strictObject({
33
33
  provenance: computerProvenanceSchema,
34
34
  });
35
35
  /** State visible without knowing which application hosts the Computer. */
36
- export const computerStateSchema = z.discriminatedUnion("state", [
37
- // start_failed: a queued start ended without running; start again.
36
+ export const computerStateSchema = z.union([
37
+ z.strictObject({ state: z.enum(["running", "sleeping", "starting"]) }),
38
+ // An owed start ended without running; start again. `reason` says why
39
+ // where the reader asked for it or decodes extra keys: released strict
40
+ // readers, and Hubs from before it, see `start_failed` alone. Two shapes,
41
+ // not an optional key, keep the state plain JSON.
42
+ z.strictObject({ state: z.literal("start_failed") }),
38
43
  z.strictObject({
39
- state: z.enum(["running", "sleeping", "starting", "start_failed"]),
44
+ state: z.literal("start_failed"),
45
+ reason: z.string().min(1).max(1_024),
40
46
  }),
41
47
  z.strictObject({
42
48
  state: z.literal("queued"),
package/dist/index.d.ts CHANGED
@@ -342,7 +342,7 @@ export declare class ComputerDO extends ContainerComputer implements ComputerFil
342
342
  }
343
343
  export { WorkspaceProxy, WorkspaceServiceProxy };
344
344
  export { computerName, learnComputerName } from "./computer-name.js";
345
- export { OnBoxVmContainerHost, OnBoxVmTimeoutError, onBoxVmPlacement, onBoxVmIngress, type OnBoxVmEnv, type OnBoxVmOperation, type OnBoxVmState, } from "./on-box-vm.js";
345
+ export { OnBoxVmContainerHost, OnBoxVmTimeoutError, OnBoxVmUnavailableError, onBoxVmPlacement, onBoxVmIngress, type OnBoxVmEnv, type OnBoxVmOperation, type OnBoxVmState, } from "./on-box-vm.js";
346
346
  export { computerContainerSleepAfterMs } from "./container-policy.js";
347
347
  export { isVaultExecutionContext, vaultExecutionContext, withVaultExecution, type VaultGrantPort, type VaultHolder, type VaultReferenceAdmission, type VaultSecretGrant, type VaultSubject, } from "./vault-references.js";
348
348
  export * from "./computer-backends.js";
package/dist/index.js CHANGED
@@ -1747,7 +1747,7 @@ export class ComputerDO extends ContainerComputer {
1747
1747
  // entrypoints. The consuming Worker must re-export both from its main module.
1748
1748
  export { WorkspaceProxy, WorkspaceServiceProxy };
1749
1749
  export { computerName, learnComputerName } from "./computer-name.js";
1750
- export { OnBoxVmContainerHost, OnBoxVmTimeoutError, onBoxVmPlacement, onBoxVmIngress, } from "./on-box-vm.js";
1750
+ export { OnBoxVmContainerHost, OnBoxVmTimeoutError, OnBoxVmUnavailableError, onBoxVmPlacement, onBoxVmIngress, } from "./on-box-vm.js";
1751
1751
  export { computerContainerSleepAfterMs } from "./container-policy.js";
1752
1752
  export { isVaultExecutionContext, vaultExecutionContext, withVaultExecution, } from "./vault-references.js";
1753
1753
  export * from "./computer-backends.js";
@@ -40,6 +40,12 @@ export type OnBoxVmPlacement = Readonly<{
40
40
  }>;
41
41
  /** The registered host `hostId`, or `undefined` when this Worker has none. */
42
42
  export declare function onBoxVmPlacement(env: OnBoxVmEnv, hostId: string | undefined): OnBoxVmPlacement | undefined;
43
+ /** The host service refused an operation; `status` is its HTTP answer. */
44
+ export declare class OnBoxVmUnavailableError extends Error {
45
+ readonly operation: string;
46
+ readonly status: number;
47
+ constructor(operation: string, status: number, detail?: string);
48
+ }
43
49
  declare const vmStateSchema: z.ZodObject<{
44
50
  running: z.ZodBoolean;
45
51
  runtimeId: z.ZodNullable<z.ZodString>;
package/dist/on-box-vm.js CHANGED
@@ -39,9 +39,14 @@ export function onBoxVmPlacement(env, hostId) {
39
39
  const host = hostRegistry(env)[hostIdSchema.parse(hostId)];
40
40
  return host === undefined ? undefined : { hostId, origin: host.origin };
41
41
  }
42
- class OnBoxVmUnavailableError extends Error {
42
+ /** The host service refused an operation; `status` is its HTTP answer. */
43
+ export class OnBoxVmUnavailableError extends Error {
44
+ operation;
45
+ status;
43
46
  constructor(operation, status, detail = "") {
44
47
  super(`On-box Computer VM ${operation} failed with HTTP ${String(status)}${detail ? `: ${detail}` : ""}`);
48
+ this.operation = operation;
49
+ this.status = status;
45
50
  this.name = "OnBoxVmUnavailableError";
46
51
  }
47
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/computer",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Cloudflare Computer host for one durable Fungi Computer",
6
6
  "type": "module",
@@ -64,10 +64,10 @@
64
64
  "@fungi.computer/capnweb": "0.12.0-fungi.0",
65
65
  "@fungi.computer/cloudflare-computer": "0.2.1-fungi.2",
66
66
  "@fungi.computer/cordyceps": "0.4.3",
67
- "@fungi.computer/knapsack": "0.4.20",
67
+ "@fungi.computer/knapsack": "0.4.21",
68
68
  "@fungi.computer/seam": "0.2.6",
69
69
  "@fungi.computer/watchdog": "0.1.4",
70
- "@fungi.computer/computer-contract": "0.5.7",
70
+ "@fungi.computer/computer-contract": "0.5.8",
71
71
  "effect": "4.0.2",
72
72
  "just-bash": "3.4.2",
73
73
  "zod": "4.4.3",