@fungi.computer/computer 0.21.0 → 0.22.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.
@@ -90,12 +90,19 @@ export declare class FleetLifecycle {
90
90
  readComputerState(): Promise<{
91
91
  state: "queued";
92
92
  position: number;
93
+ reason?: never;
93
94
  } | {
94
95
  state: "running" | "starting";
95
96
  position?: never;
97
+ reason?: never;
98
+ } | {
99
+ state: "sleeping";
100
+ reason: string;
101
+ position?: never;
96
102
  } | {
97
103
  state: "running" | "sleeping";
98
104
  position?: never;
105
+ reason?: never;
99
106
  }>;
100
107
  /** The Computer page's read: each attached backend and its live status. */
101
108
  readAttachedBackends(): Promise<(Omit<AttachedBackendView, "status"> & {
@@ -122,6 +122,7 @@ export class FleetLifecycle {
122
122
  return { state: "queued", position };
123
123
  if (this.#startingHosted > 0)
124
124
  return { state: "starting" };
125
+ let stoppedReason;
125
126
  for (const backing of this.ports.backend.attachedBackends()) {
126
127
  if (backing.kind === "on-box-vm") {
127
128
  const runtime = await this.ports.backend
@@ -133,12 +134,17 @@ export class FleetLifecycle {
133
134
  ? "starting"
134
135
  : "running",
135
136
  };
137
+ if (runtime.exit?.code === "scratch_pool_full")
138
+ stoppedReason = runtime.exit.reason;
136
139
  }
137
140
  else if (backing.kind === "platform-container" &&
138
141
  (await this.ports.backend.containerRunning(backing))) {
139
142
  return { state: "running" };
140
143
  }
141
144
  }
145
+ if (!backends.some((backend) => backend.status === "online") &&
146
+ stoppedReason !== undefined)
147
+ return { state: "sleeping", reason: stoppedReason };
142
148
  return {
143
149
  state: backends.some((backend) => backend.status === "online")
144
150
  ? "running"
@@ -98,6 +98,9 @@ export declare const computerStateSchema: z.ZodUnion<readonly [z.ZodObject<{
98
98
  sleeping: "sleeping";
99
99
  starting: "starting";
100
100
  }>;
101
+ }, z.core.$strict>, z.ZodObject<{
102
+ state: z.ZodLiteral<"sleeping">;
103
+ reason: z.ZodString;
101
104
  }, z.core.$strict>, z.ZodObject<{
102
105
  state: z.ZodLiteral<"start_failed">;
103
106
  }, z.core.$strict>, z.ZodObject<{
@@ -252,6 +255,9 @@ export declare const computerFactSchema: z.ZodLazy<z.ZodDiscriminatedUnion<[z.Zo
252
255
  sleeping: "sleeping";
253
256
  starting: "starting";
254
257
  }>;
258
+ }, z.core.$strict>, z.ZodObject<{
259
+ state: z.ZodLiteral<"sleeping">;
260
+ reason: z.ZodString;
255
261
  }, z.core.$strict>, z.ZodObject<{
256
262
  state: z.ZodLiteral<"start_failed">;
257
263
  }, z.core.$strict>, z.ZodObject<{
@@ -42,6 +42,10 @@ export const computerGrantSchema = z.strictObject({
42
42
  /** State visible without knowing which application hosts the Computer. */
43
43
  export const computerStateSchema = z.union([
44
44
  z.strictObject({ state: z.enum(["running", "sleeping", "starting"]) }),
45
+ z.strictObject({
46
+ state: z.literal("sleeping"),
47
+ reason: z.string().min(1).max(1_024),
48
+ }),
45
49
  // An owed start ended without running; start again. `reason` says why
46
50
  // where the reader asked for it or decodes extra keys: released strict
47
51
  // readers, and Hubs from before it, see `start_failed` alone. Two shapes,
@@ -57,6 +57,7 @@ declare const vmStateSchema: z.ZodObject<{
57
57
  runtimeId: z.ZodNullable<z.ZodString>;
58
58
  exit: z.ZodNullable<z.ZodLazy<z.ZodObject<{
59
59
  reason: z.ZodString;
60
+ code: z.ZodExactOptional<z.ZodLiteral<"scratch_pool_full">>;
60
61
  exitedAt: z.ZodNumber;
61
62
  }, z.core.$strict>>>;
62
63
  }, z.core.$strict>;
@@ -66,6 +67,7 @@ declare const vmInventorySchema: z.ZodArray<z.ZodObject<{
66
67
  runtimeId: z.ZodNullable<z.ZodString>;
67
68
  exit: z.ZodNullable<z.ZodLazy<z.ZodObject<{
68
69
  reason: z.ZodString;
70
+ code: z.ZodExactOptional<z.ZodLiteral<"scratch_pool_full">>;
69
71
  exitedAt: z.ZodNumber;
70
72
  }, z.core.$strict>>>;
71
73
  id: z.ZodString;
@@ -123,11 +125,13 @@ export declare class OnBoxVmContainerHost implements IWorkspaceContainerAPI {
123
125
  exit: {
124
126
  reason: string;
125
127
  exitedAt: number;
128
+ code?: "scratch_pool_full";
126
129
  } | null;
127
130
  }>;
128
131
  exitInfo(): Promise<{
129
132
  reason: string;
130
133
  exitedAt: number;
134
+ code?: "scratch_pool_full";
131
135
  } | null>;
132
136
  /** Whether the VM is running now; the platform container answers from `ctx.container.running`. */
133
137
  running(): Promise<boolean>;
package/dist/on-box-vm.js CHANGED
@@ -91,6 +91,7 @@ const vmHostAudience = (hostId) => `computer-vm-host:${hostId}`;
91
91
  const vmIngressAudience = "computer-vm-ingress";
92
92
  const exitSchema = z.lazy(() => z.strictObject({
93
93
  reason: z.string().max(1_024),
94
+ code: z.literal("scratch_pool_full").exactOptional(),
94
95
  exitedAt: z.number().int().nonnegative(),
95
96
  }));
96
97
  const vmStateSchema = z.strictObject({
@@ -20385,6 +20385,7 @@ var appApiReservedMethodNames = Object.freeze({
20385
20385
  "onGitPush",
20386
20386
  "syncRefused",
20387
20387
  "authorizeGitPush",
20388
+ "authorizeGitRepository",
20388
20389
  "onRegion",
20389
20390
  "fetch",
20390
20391
  "alarm",
@@ -20430,6 +20431,13 @@ var backgroundOrigin = _lazy(() => strictObject({
20430
20431
  var appMethodCallerSchema = object2({
20431
20432
  scope: appCallerScopeSchema,
20432
20433
  computerId: nullable2(identity2),
20434
+ /** Host-attested repository ceiling; absent preserves unscoped key access. */
20435
+ repositoryScope: optional4(discriminatedUnion("kind", [
20436
+ strictObject({ kind: literal2("all") }),
20437
+ strictObject({ kind: literal2("selected"), ids: array3(identity2) })
20438
+ ])),
20439
+ /** Installation selected by the host for repository-scoped attribution. */
20440
+ repositoryInstallationId: optional4(identity2),
20433
20441
  actor: hostActorSchema,
20434
20442
  /** Host-attested enqueue eligibility for this ordinary write; absent otherwise. */
20435
20443
  backgroundLane: optional4(string5().check(_minLength(8), _maxLength(263))),
@@ -20467,6 +20475,8 @@ var strictCaller = strictObject({
20467
20475
  });
20468
20476
  var parseAppMethodCallContext = (value, rejectUnknownKeys = false) => validateCaller((rejectUnknownKeys ? strictCaller : appMethodCallerSchema).parse(value));
20469
20477
  function validateCaller(context3) {
20478
+ if ((context3.repositoryScope !== void 0 || context3.repositoryInstallationId !== void 0) && context3.actor.kind !== "team-key")
20479
+ throw new Error("Only a Team key carries a repository scope");
20470
20480
  if (context3.soleMember !== void 0 && (context3.actor.kind !== "member" || context3.workflow !== void 0))
20471
20481
  throw new Error("Only a member's own call can be its Team's sole member");
20472
20482
  if (context3.backgroundLane === void 0 !== (context3.backgroundOrigin === void 0))
@@ -20840,6 +20850,7 @@ var appRoles = [
20840
20850
  ];
20841
20851
  var appCapabilityIds = [
20842
20852
  "approvals",
20853
+ "team.issue-index.read",
20843
20854
  "agent.list",
20844
20855
  "agent.manage",
20845
20856
  "agent.rename",
@@ -21211,6 +21222,7 @@ var appCallSchema = declareConstructor()([appCallFields], ([fields]) => (input,
21211
21222
  var appCallsSchema = ArraySchema(appCallSchema).check(isMinLength(1), isMaxLength(16), makeFilter2((calls) => isUnique2(calls.map((call) => call.appId)), unique2));
21212
21223
  var declarationSchemaFor = (gill) => Struct({
21213
21224
  api: optionalKey2(appApiSchema),
21225
+ repositoryScopedKeys: optionalKey2(Literal2(true)),
21214
21226
  displayName: optional2(String4.pipe(check(isMinLength(1)), check(isMaxLength(64)))),
21215
21227
  capabilities: ArraySchema(appCapabilityIdSchema).pipe(check(makeFilter2(isUnique2, unique2))),
21216
21228
  calls: optionalKey2(appCallsSchema),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/computer",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Cloudflare Computer host for one durable Fungi Computer",
6
6
  "type": "module",
@@ -68,15 +68,15 @@
68
68
  "LICENSE"
69
69
  ],
70
70
  "dependencies": {
71
- "@fungi.computer/agar": "0.32.0",
71
+ "@fungi.computer/agar": "0.33.0",
72
72
  "@fungi.computer/cairn": "0.1.1",
73
73
  "@fungi.computer/capnweb": "0.12.0-fungi.0",
74
74
  "@fungi.computer/cloudflare-computer": "0.2.1-fungi.4",
75
75
  "@fungi.computer/cordyceps": "0.4.3",
76
- "@fungi.computer/knapsack": "0.4.45",
76
+ "@fungi.computer/knapsack": "0.4.46",
77
77
  "@fungi.computer/seam": "0.2.9",
78
78
  "@fungi.computer/watchdog": "0.1.7",
79
- "@fungi.computer/computer-contract": "0.6.22",
79
+ "@fungi.computer/computer-contract": "0.6.23",
80
80
  "effect": "4.0.2",
81
81
  "just-bash": "3.4.2",
82
82
  "zod": "4.4.3",