@fungi.computer/oyster 0.24.0 → 0.26.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 (57) hide show
  1. package/dist/agent-instructions.d.ts +35 -0
  2. package/dist/agent-instructions.js +42 -0
  3. package/dist/agents.d.ts +14 -0
  4. package/dist/agents.js +43 -1
  5. package/dist/app-builds.d.ts +4 -2
  6. package/dist/app-builds.js +14 -0
  7. package/dist/apps/catalog.d.ts +11 -0
  8. package/dist/apps/catalog.js +1 -0
  9. package/dist/apps/gate.d.ts +2 -2
  10. package/dist/apps/installation.d.ts +7 -7
  11. package/dist/apps/permissions.d.ts +5 -5
  12. package/dist/boot-host-script.js +1 -1
  13. package/dist/browser/boot-once.d.ts +84 -0
  14. package/dist/browser/boot-once.js +48 -0
  15. package/dist/build/build-memory.d.ts +13 -0
  16. package/dist/build/build-memory.js +29 -0
  17. package/dist/build/candidate-cli.mjs +25 -2
  18. package/dist/build/local-build.js +4 -5
  19. package/dist/cloudflare.d.ts +2 -2
  20. package/dist/cloudflare.js +3 -0
  21. package/dist/computer-control-port.d.ts +2 -0
  22. package/dist/embed-metafiles.js +2 -2
  23. package/dist/embed-scripts.js +1 -1
  24. package/dist/installation-operations.d.ts +8 -8
  25. package/dist/mcp.d.ts +26 -0
  26. package/dist/mcp.js +12 -2
  27. package/dist/page-script.js +2 -2
  28. package/dist/release.d.ts +5 -0
  29. package/dist/standalone/agents.d.ts +6 -0
  30. package/dist/standalone/agents.js +46 -3
  31. package/dist/standalone/app-set.d.ts +4 -3
  32. package/dist/standalone/app-set.js +9 -5
  33. package/dist/standalone/computer-control.js +7 -1
  34. package/dist/standalone/computer-fleet.d.ts +5 -0
  35. package/dist/standalone/computer-skill-source.d.ts +20 -0
  36. package/dist/standalone/computer-skill-source.js +165 -0
  37. package/dist/standalone/computer.d.ts +7 -4
  38. package/dist/standalone/computer.js +62 -3
  39. package/dist/standalone/install-apps-cli.js +1 -1
  40. package/dist/standalone/media.d.ts +1 -1
  41. package/dist/standalone/registry.d.ts +3 -0
  42. package/dist/standalone/registry.js +1 -1
  43. package/dist/standalone/workflow-host.d.ts +5 -5
  44. package/dist/standalone/workflow-trigger-host.d.ts +1 -1
  45. package/docs/api/agents.md +18 -0
  46. package/docs/api/apps.md +148 -131
  47. package/docs/api/browser/boot-once.md +169 -0
  48. package/docs/api/build-contract.md +27 -21
  49. package/docs/api/build.md +70 -69
  50. package/docs/api/cloudflare.md +4 -1
  51. package/docs/api/git.md +3 -3
  52. package/docs/api/host.md +91 -85
  53. package/docs/api/mcp.md +68 -62
  54. package/docs/api/modules.md +1 -0
  55. package/docs/api/workers-git.md +7 -7
  56. package/docs/api/workers.md +24 -21
  57. package/package.json +25 -17
package/dist/release.d.ts CHANGED
@@ -15,6 +15,11 @@ export type ArtifactHead = Readonly<{
15
15
  /** The digest the store verified when it took the bytes, if it did. */
16
16
  digest: Sha256Digest | null;
17
17
  }>;
18
+ /** A store that can remove one object; only host-owned namespaces use it. */
19
+ export type ArtifactDeletes = Readonly<{
20
+ /** Remove the object at `artifactRef`; a missing object is not an error. */
21
+ delete: (artifactRef: ArtifactRef) => Promise<void>;
22
+ }>;
18
23
  /** A store that can describe an object without reading its bytes. */
19
24
  export type ArtifactHeads = Readonly<{
20
25
  /** Describe the object at `artifactRef`, or `null` when absent. */
@@ -268,6 +268,12 @@ export declare abstract class StandaloneAgentBase<Env extends StandaloneAgentEnv
268
268
  /** A byok choice must name a stored key of the chosen provider. */
269
269
  private admitKey;
270
270
  private choice;
271
+ private instructionsOwner;
272
+ private ownerInstructions;
273
+ /** The owner's standing instructions for this Agent; the host admits the owner first. */
274
+ readInstructions(): string;
275
+ /** Replace them. The next turn follows the new text; a run already going does not change. */
276
+ writeInstructions(instructions: string): string;
271
277
  /** Secret-free default of this Agent; stored separately from Session history. */
272
278
  readModelChoice(): Promise<AgentModelChoice>;
273
279
  setModelChoice(input: AgentModelChoice): Promise<AgentModelChoice | Readonly<{
@@ -16,6 +16,8 @@ import { createDiscordReplies, } from "../channels/discord-replies.js";
16
16
  import { isDiscordBinding, createDiscordBindings, createDiscordInputSchema, updateDiscordInputSchema, } from "../channels/discord-binding.js";
17
17
  import { DISCORD_SETTLEMENT_WAIT_MS, discordDenial, discordFailureText, patchOriginal, postChannelMessage, postFollowUp, quoted, STILL_WORKING_TEXT, splitDiscordMessage, registerAskCommand, } from "../channels/discord-interactions.js";
18
18
  import { discordOutcome, sealDiscordToken, } from "./discord-channels.js";
19
+ import { createAgentInstructions, withOwnerInstructions, } from "../agent-instructions.js";
20
+ import { computerSkillsEmpty, createComputerSkillSource, } from "./computer-skill-source.js";
19
21
  import { channelSessionDoor } from "./channel-session-door.js";
20
22
  import { createAuthenticatedVisitorChannel } from "../channels/visitor-channel.js";
21
23
  import { verifyVisitor } from "./visitor-proof.js";
@@ -1038,6 +1040,18 @@ export class StandaloneAgentBase extends ShiitakeDO {
1038
1040
  });
1039
1041
  });
1040
1042
  }
1043
+ instructionsOwner;
1044
+ ownerInstructions() {
1045
+ return (this.instructionsOwner ??= createAgentInstructions(this.ctx.storage.sql));
1046
+ }
1047
+ /** The owner's standing instructions for this Agent; the host admits the owner first. */
1048
+ readInstructions() {
1049
+ return this.ownerInstructions().read().instructions;
1050
+ }
1051
+ /** Replace them. The next turn follows the new text; a run already going does not change. */
1052
+ writeInstructions(instructions) {
1053
+ return this.ownerInstructions().write(instructions).instructions;
1054
+ }
1041
1055
  /** Secret-free default of this Agent; stored separately from Session history. */
1042
1056
  async readModelChoice() {
1043
1057
  return this.choice().read();
@@ -1215,7 +1229,16 @@ export class StandaloneAgentBase extends ShiitakeDO {
1215
1229
  return () => this.computerInvalidations.delete(invalidate);
1216
1230
  },
1217
1231
  });
1218
- const extensions = oysterAgentExtensions(conversationAgents.source(this.controlDirectory()));
1232
+ // Skills the owner put on the Agent's Computer, found by the rules Local uses on a disk.
1233
+ const extensions = oysterAgentExtensions(conversationAgents.source(this.controlDirectory()), {
1234
+ source: createComputerSkillSource({
1235
+ computers: async () => {
1236
+ await this.preparedComputerSnapshot();
1237
+ return readAgentComputerConnections(this.computerConnections()).map(({ name, files }) => ({ name, port: files.port }));
1238
+ },
1239
+ }),
1240
+ empty: computerSkillsEmpty,
1241
+ });
1219
1242
  const keeping = agentStoreKeeping(this.ctx.storage, (request) => this.readColdSessions(request));
1220
1243
  const principal = {
1221
1244
  actor: { kind: "agent", agentId: this.ctx.id.name ?? "agent" },
@@ -1236,10 +1259,10 @@ export class StandaloneAgentBase extends ShiitakeDO {
1236
1259
  instructions: this.channelInstructions({
1237
1260
  load: async () => {
1238
1261
  const { appApprovalInstructions } = await import("../mcp.js");
1239
- return {
1262
+ return withOwnerInstructions({
1240
1263
  revision: "oyster-7",
1241
1264
  text: instructions + "\n" + appApprovalInstructions,
1242
- };
1265
+ }, this.ownerInstructions().read());
1243
1266
  },
1244
1267
  }),
1245
1268
  tools: {
@@ -2420,6 +2443,26 @@ export function standaloneAgents(env, scope) {
2420
2443
  const parsed = Schema.decodeUnknownOption(Schema.fromJsonString(agentModelChoiceSchema), { onExcessProperty: "error" })(json);
2421
2444
  return parsed._tag === "None" ? null : parsed.value;
2422
2445
  },
2446
+ readInstructions: async (agentId, principal) => {
2447
+ if (!oysterPrincipalIsOwner(principal))
2448
+ return { error: "not_granted" };
2449
+ if (!(await directory().has(agentId)))
2450
+ return { error: "not_found" };
2451
+ return {
2452
+ agentId,
2453
+ instructions: await env.AGENTS.getByName(agentId).readInstructions(),
2454
+ };
2455
+ },
2456
+ setInstructions: async (agentId, instructions, principal) => {
2457
+ if (!oysterPrincipalIsOwner(principal))
2458
+ return { error: "not_granted" };
2459
+ if (!(await directory().has(agentId)))
2460
+ return { error: "not_found" };
2461
+ return {
2462
+ agentId,
2463
+ instructions: await env.AGENTS.getByName(agentId).writeInstructions(instructions),
2464
+ };
2465
+ },
2423
2466
  setModelChoice: async (agentId, choice, principal) => {
2424
2467
  if (!oysterPrincipalIsOwner(principal))
2425
2468
  return { error: "not_granted" };
@@ -80,10 +80,11 @@ export type StarterAppSetResult = Readonly<{
80
80
  }>;
81
81
  /**
82
82
  * Builds the installer runs at once by default. A build's compiler may take a
83
- * 4 GB heap, so two fit the platform's 12 GiB Computer (standard-4) with room
84
- * for pnpm and esbuild; a third is the most it will run.
83
+ * 4 GiB heap and pnpm and esbuild another 2 GiB, so a Computer runs one build
84
+ * per 6 GiB, two at most: two on a 12 GiB container or 16 GiB VM, one on an
85
+ * 8 GiB or 4 GiB VM. A third runs only when asked for.
85
86
  */
86
- export declare const defaultStarterBuildConcurrency = 2;
87
+ export declare function defaultStarterBuildConcurrency(): number;
87
88
  /**
88
89
  * Install the standalone App set, each App built on the Oyster's own
89
90
  * Computer. Each App's editable source is published as its template; the host
@@ -1,3 +1,4 @@
1
+ import { defaultBuildConcurrency, machineMemoryMib, } from "../build/build-memory.js";
1
2
  import { execFile } from "node:child_process";
2
3
  import { mkdtemp, rm } from "node:fs/promises";
3
4
  import { join } from "node:path";
@@ -146,11 +147,14 @@ const computerPhasesSchema = Schema.fromJsonString(Schema.Struct({
146
147
  const appBuildWaitMs = 20 * 60_000;
147
148
  /**
148
149
  * Builds the installer runs at once by default. A build's compiler may take a
149
- * 4 GB heap, so two fit the platform's 12 GiB Computer (standard-4) with room
150
- * for pnpm and esbuild; a third is the most it will run.
150
+ * 4 GiB heap and pnpm and esbuild another 2 GiB, so a Computer runs one build
151
+ * per 6 GiB, two at most: two on a 12 GiB container or 16 GiB VM, one on an
152
+ * 8 GiB or 4 GiB VM. A third runs only when asked for.
151
153
  */
152
- export const defaultStarterBuildConcurrency = 2;
153
- /** The most builds at once on the 12 GiB Computer. */
154
+ export function defaultStarterBuildConcurrency() {
155
+ return defaultBuildConcurrency(machineMemoryMib());
156
+ }
157
+ /** The most builds at once, when the caller asks for more than the default. */
154
158
  const maxStarterBuildConcurrency = 3;
155
159
  const run = (command, args, cwd) => new Promise((resolveRun, reject) => {
156
160
  execFile(command, args, { cwd, encoding: "utf8", maxBuffer: 1_048_576 }, (error, stdout) => {
@@ -169,7 +173,7 @@ const run = (command, args, cwd) => new Promise((resolveRun, reject) => {
169
173
  * is compiled on this machine and no installed App is needed to build.
170
174
  */
171
175
  export async function installStandaloneAppSet(options) {
172
- const concurrency = options.concurrency ?? defaultStarterBuildConcurrency;
176
+ const concurrency = options.concurrency ?? defaultStarterBuildConcurrency();
173
177
  if (!Number.isInteger(concurrency) ||
174
178
  concurrency < 1 ||
175
179
  concurrency > maxStarterBuildConcurrency)
@@ -1,9 +1,11 @@
1
1
  import { z } from "zod";
2
+ import { computerSizeSchema } from "@fungi.computer/computer/backing";
2
3
  import { computerBackendViewSchema, computerStateSchema, } from "@fungi.computer/computer/fleet";
3
4
  import { teamComputerDirectorySchema } from "@fungi.computer/nacre/workbench";
4
5
  const inventoryComputer = z.strictObject({
5
6
  computerId: z.string(),
6
7
  name: z.string(),
8
+ size: computerSizeSchema,
7
9
  createdAt: z.number(),
8
10
  updatedAt: z.number(),
9
11
  });
@@ -75,7 +77,11 @@ export function standaloneComputerControl(registry, memberId) {
75
77
  const computer = inventoryComputer.parse(result);
76
78
  return {
77
79
  kind: "created",
78
- computer: { computerId: computer.computerId, name: computer.name },
80
+ computer: {
81
+ computerId: computer.computerId,
82
+ name: computer.name,
83
+ size: computer.size,
84
+ },
79
85
  };
80
86
  },
81
87
  backends: async (computerId) => backendList.parse(available(await fleet({ operation: "backends", computerId }))).backends,
@@ -6,6 +6,11 @@ export declare const standaloneFleetRequestSchema: z.ZodDiscriminatedUnion<[z.Zo
6
6
  operation: z.ZodLiteral<"create">;
7
7
  request: z.ZodObject<{
8
8
  name: z.ZodOptional<z.ZodString>;
9
+ size: z.ZodOptional<z.ZodEnum<{
10
+ default: "default";
11
+ small: "small";
12
+ large: "large";
13
+ }>>;
9
14
  requestId: z.ZodString;
10
15
  }, z.core.$strict>;
11
16
  }, z.core.$strict>, z.ZodObject<{
@@ -0,0 +1,20 @@
1
+ import type { FilesPort } from "@fungi.computer/knapsack";
2
+ import type { SkillSource } from "@fungi.computer/shiitake-extensions/skills/source";
3
+ /**
4
+ * Skills on an Agent's own Computer. Discovery follows the same rules Local
5
+ * applies on a disk (frontmatter, naming, bounds, first name wins): this
6
+ * module only walks and reads folders through the Computer's Files port, and
7
+ * the port, not this code, confines every path to the Computer's workspace.
8
+ */
9
+ /** One attached Computer, as the Agent reaches it. */
10
+ export type SkillComputer = Readonly<{
11
+ name: string;
12
+ port: FilesPort;
13
+ }>;
14
+ /** What a person is told when no skill is installed on the Computer. */
15
+ export declare const computerSkillsEmpty = "No skills are installed; put one at .agents/skills/<name>/SKILL.md on the Computer.";
16
+ /** Discover and load the skills on the Agent's attached Computers. */
17
+ export declare function createComputerSkillSource(options: Readonly<{
18
+ /** The Computers the Agent may use now; read at each discovery. */
19
+ computers: () => Promise<readonly SkillComputer[]>;
20
+ }>): SkillSource;
@@ -0,0 +1,165 @@
1
+ import { admitSkill, maximumDirectoryEntries, maximumFileBytes, newSkillAdmission, parseSkill, skillCatalogOf, skillDiagnostic, skillExplanation, skillFileSchema, SkillSourceError, } from "@fungi.computer/shiitake-extensions/skills/discovery";
2
+ import { defineIdFamily } from "@fungi.computer/cairn/id";
3
+ import { z } from "zod";
4
+ /** Each Files call this source makes is its own invocation. */
5
+ const skillIds = defineIdFamily({
6
+ family: "computer-skills",
7
+ version: 1,
8
+ kinds: { execution: { prefix: "skill_exec" } },
9
+ });
10
+ /** Where the Computer keeps skills, searched in this order; the first name wins. */
11
+ const skillRoots = [".fungi/skills", ".agents/skills"];
12
+ /** What a person is told when no skill is installed on the Computer. */
13
+ export const computerSkillsEmpty = "No skills are installed; put one at .agents/skills/<name>/SKILL.md on the Computer.";
14
+ const nameLength = z.string().min(1);
15
+ const segments = (path) => path.split("/").filter(Boolean);
16
+ const fileName = (path) => segments(path).at(-1) ?? "";
17
+ const directoryOf = (path) => `/${segments(path).slice(0, -1).join("/")}`;
18
+ /** The model's view of a skill file: bare when one Computer, else a computer:// locator. */
19
+ function located(computer, path, several) {
20
+ return several
21
+ ? `computer://${encodeURIComponent(computer)}${path.startsWith("/") ? path : `/${path}`}`
22
+ : path;
23
+ }
24
+ /** Read one whole file or refuse it plainly: oversized, not text, or unreadable. */
25
+ async function readWhole(port, path, signal) {
26
+ signal.throwIfAborted();
27
+ let page;
28
+ try {
29
+ page = await port.read({ path, offset: 0, limit: maximumFileBytes }, invocation(signal));
30
+ }
31
+ catch (cause) {
32
+ signal.throwIfAborted();
33
+ throw new SkillSourceError("Skill file cannot be read", { cause });
34
+ }
35
+ if (!("content" in page))
36
+ throw new SkillSourceError("Skill file is not text");
37
+ if (page.truncated)
38
+ throw new SkillSourceError("Skill file exceeds the 128 KiB bound");
39
+ return page.content;
40
+ }
41
+ function invocation(signal) {
42
+ return {
43
+ executionId: skillIds.execution.generate(),
44
+ deadlineAt: null,
45
+ signal,
46
+ };
47
+ }
48
+ /** Skill folders under one root of one Computer, found by their SKILL.md. */
49
+ async function findSkillFiles(port, root, signal, diagnostics) {
50
+ let found;
51
+ try {
52
+ found = await port.glob({ path: root, pattern: "**/SKILL.md", limit: 256 }, invocation(signal));
53
+ }
54
+ catch {
55
+ // A Computer without the folder, or one the Agent may not search, has no skills here.
56
+ signal.throwIfAborted();
57
+ return [];
58
+ }
59
+ if (found.truncated !== null)
60
+ diagnostics.push(skillDiagnostic(root, "bound", "Skill discovery exceeds its 256-skill search bound"));
61
+ const files = [];
62
+ for (const row of found.results) {
63
+ if (row.type === "directory")
64
+ continue;
65
+ const inside = row.path.startsWith("/") ? row.path : `/${row.path}`;
66
+ const relative = segments(inside).slice(segments(root).length);
67
+ // Like Local: dot folders and node_modules are not searched.
68
+ if (relative
69
+ .slice(0, -1)
70
+ .some((part) => part.startsWith(".") || part === "node_modules")) {
71
+ diagnostics.push(skillDiagnostic(inside, "skipped", "Dot directories and node_modules are not searched"));
72
+ continue;
73
+ }
74
+ files.push(inside);
75
+ }
76
+ return files.sort();
77
+ }
78
+ /** Discover and load the skills on the Agent's attached Computers. */
79
+ export function createComputerSkillSource(options) {
80
+ const scan = async (signal) => {
81
+ const computers = await options.computers();
82
+ const several = computers.length > 1;
83
+ const state = newSkillAdmission();
84
+ const homes = new Map();
85
+ for (const computer of computers) {
86
+ for (const root of skillRoots) {
87
+ signal.throwIfAborted();
88
+ const files = await findSkillFiles(computer.port, root, signal, state.diagnostics);
89
+ for (const path of files) {
90
+ const directoryName = fileName(directoryOf(path));
91
+ const skillPath = located(computer.name, path, several);
92
+ try {
93
+ const { metadata } = parseSkill(await readWhole(computer.port, path, signal), directoryName);
94
+ const before = state.skills.length;
95
+ admitSkill(state, {
96
+ metadata,
97
+ directoryName,
98
+ skillPath,
99
+ location: skillPath,
100
+ displayLocation: skillPath,
101
+ origin: { kind: "project" },
102
+ });
103
+ if (state.skills.length > before)
104
+ homes.set(metadata.name, { computer, location: path });
105
+ }
106
+ catch (cause) {
107
+ signal.throwIfAborted();
108
+ state.diagnostics.push({
109
+ path: skillPath,
110
+ reason: "invalid",
111
+ message: skillExplanation(cause, "Skill metadata or file is invalid"),
112
+ cause,
113
+ });
114
+ }
115
+ }
116
+ }
117
+ }
118
+ if (state.skills.length === 0 && state.diagnostics.length === 0)
119
+ state.diagnostics.push(skillDiagnostic(".agents/skills", "empty", "No skill folders on the Computer"));
120
+ return { catalog: skillCatalogOf(state), homes };
121
+ };
122
+ return {
123
+ catalog: async (signal) => (await scan(signal)).catalog,
124
+ read: async (name, file, signal) => {
125
+ nameLength.parse(name);
126
+ const { catalog, homes } = await scan(signal);
127
+ const home = homes.get(name);
128
+ const found = catalog.skills.find((skill) => skill.name === name);
129
+ if (home === undefined || found === undefined)
130
+ throw new Error(`Unknown or hidden skill: ${name}`);
131
+ const baseDirectory = directoryOf(home.location);
132
+ const selected = file === undefined ? "SKILL.md" : skillFileSchema.parse(file);
133
+ const content = await readWhole(home.computer.port, `${baseDirectory}/${selected}`, signal);
134
+ if (selected !== "SKILL.md")
135
+ return {
136
+ name,
137
+ file: selected,
138
+ content,
139
+ baseDirectory,
140
+ supportingFiles: [],
141
+ };
142
+ const parsed = parseSkill(content, fileName(baseDirectory));
143
+ if (parsed.metadata["disable-model-invocation"])
144
+ throw new Error(`Hidden skill: ${name}`);
145
+ const listed = await home.computer.port.glob({ path: baseDirectory, pattern: "**/*", limit: 256 }, invocation(signal));
146
+ if (listed.truncated !== null ||
147
+ listed.results.length > maximumDirectoryEntries)
148
+ throw new SkillSourceError("Skill supporting files exceed the entry bound");
149
+ const prefix = `${baseDirectory}/`;
150
+ const supportingFiles = listed.results
151
+ .filter((row) => row.type !== "directory")
152
+ .map((row) => (row.path.startsWith("/") ? row.path : `/${row.path}`))
153
+ .filter((path) => path.startsWith(prefix) && path !== home.location)
154
+ .map((path) => path.slice(prefix.length))
155
+ .sort();
156
+ return {
157
+ name,
158
+ file: selected,
159
+ content: parsed.body,
160
+ baseDirectory,
161
+ supportingFiles,
162
+ };
163
+ },
164
+ };
165
+ }
@@ -1,3 +1,4 @@
1
+ import { type ComputerSize } from "@fungi.computer/computer/backing";
1
2
  import { type AppMethodRefusedReply } from "@fungi.computer/agar/backend";
2
3
  import { type ComputerPorts } from "@fungi.computer/agar/computer";
3
4
  import { type PreviewSelector } from "./preview.js";
@@ -6,7 +7,7 @@ import * as z from "zod";
6
7
  import { computerProcessSchema, computerToolResultSchema, readOutputSchema } from "@fungi.computer/computer-contract";
7
8
  import { ComputerDO as NativeComputerDO, type AttachedBackend, type ComputerEnv, type ComputerFilesRpc } from "@fungi.computer/computer";
8
9
  import { patchInputSchema, patchOutputSchema } from "@fungi.computer/knapsack/files-patch";
9
- import { listOutputSchema, writeOutputSchema, mkdirOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsOutputSchema, computerOperationResultSchema, type ComputerExecutionHostHooks, type ComputerValue } from "@fungi.computer/computer-contract";
10
+ import { listOutputSchema, writeOutputSchema, mkdirOutputSchema, moveOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsOutputSchema, computerOperationResultSchema, type ComputerExecutionHostHooks, type ComputerValue } from "@fungi.computer/computer-contract";
10
11
  import { type WorkflowGitCredential, type WorkflowGitPassGrant } from "@fungi.computer/braid/runtime";
11
12
  import { type ComputerAction, type ComputerBackendView, type ComputerGrant, type LocalBackendAttachInput, type LocalBackendDetachInput } from "@fungi.computer/computer/fleet";
12
13
  import type { InvocationFrame } from "../invocation.js";
@@ -39,8 +40,8 @@ export type StandaloneComputerResult = z.output<typeof listOutputSchema> | Reado
39
40
  encoding: "base64";
40
41
  truncated: boolean;
41
42
  }> | Readonly<{
42
- error: "conflict" | "no_runtime" | "not_found";
43
- }> | z.output<typeof writeOutputSchema> | z.output<typeof mkdirOutputSchema> | z.output<typeof computerPortsOutputSchema> | z.output<typeof computerPortOutputSchema> | z.output<typeof computerPortRemovalOutputSchema> | z.output<typeof processListOutputSchema> | z.output<typeof processKillOutputSchema> | z.output<typeof processLogsOutputSchema> | z.output<typeof computerProcessSchema> | ComputerPorts["ports"][number] | z.output<typeof computerOperationResultSchema> | z.output<typeof readOutputSchema> | z.output<typeof computerToolResultSchema>;
43
+ error: "conflict" | "no_runtime" | "not_found" | "invalid";
44
+ }> | z.output<typeof writeOutputSchema> | z.output<typeof moveOutputSchema> | z.output<typeof mkdirOutputSchema> | z.output<typeof computerPortsOutputSchema> | z.output<typeof computerPortOutputSchema> | z.output<typeof computerPortRemovalOutputSchema> | z.output<typeof processListOutputSchema> | z.output<typeof processKillOutputSchema> | z.output<typeof processLogsOutputSchema> | z.output<typeof computerProcessSchema> | ComputerPorts["ports"][number] | z.output<typeof computerOperationResultSchema> | z.output<typeof readOutputSchema> | z.output<typeof computerToolResultSchema>;
44
45
  /**
45
46
  * A port-preview listing, or the typed refusal the owner route presents with
46
47
  * {@link appMethodRefusalStatus}. A refusal never escapes as a 500.
@@ -86,8 +87,10 @@ export declare class ComputerDO extends NativeComputerDO implements ComputerFetc
86
87
  * name from the configured id once the namespace verifies it.
87
88
  */
88
89
  protected nameCandidates(): readonly string[];
90
+ /** The size fixed at creation; a Computer never created by the fleet has none. */
91
+ protected computerSize(): ComputerSize;
89
92
  /** Install the fleet's creation projection before exposing its new identity. */
90
- initializeFleetBackings(backings: readonly AttachedBackend[]): void;
93
+ initializeFleetBackings(backings: readonly AttachedBackend[], size: ComputerSize): void;
91
94
  /** The owner's attached backends with live status. Reads wake nothing. */
92
95
  readBackends(authority: ComputerGrant, actor: string): ComputerBackendView[];
93
96
  /** Attach the owner's machine; a replay of the same request returns it. */
@@ -1,4 +1,4 @@
1
- import { attachedBackendId, hostedBackingSchema, } from "@fungi.computer/computer/backing";
1
+ import { attachedBackendId, computerSizeSchema, hostedBackingSchema, } from "@fungi.computer/computer/backing";
2
2
  import { appMethodRefusalStatus, appMethodRefusedReplySchema, } from "@fungi.computer/agar/backend";
3
3
  import * as Schema from "effect/Schema";
4
4
  import { computerPortsSchema, } from "@fungi.computer/agar/computer";
@@ -12,7 +12,7 @@ import * as z from "zod";
12
12
  import { ComputerPortConflictError, computerByteReadReplySchema, computerProcessSchema, installationProcessScope, processStartInputSchema, processStartToolInputSchema, computerCapabilities, computerToolResultSchema, readOutputSchema, } from "@fungi.computer/computer-contract";
13
13
  import { ComputerDO as NativeComputerDO, ComputerOperationConflictError, ComputerBackendUnavailableError, } from "@fungi.computer/computer";
14
14
  import { patchInputSchema, patchOutputSchema, } from "@fungi.computer/knapsack/files-patch";
15
- import { ComputerFileConflict, computerExecutionRequestSchema, computerValueSchema, computerPortInputSchema, listInputSchema, listOutputSchema, readBytesInputSchema, writeInputSchema, replaceInputSchema, writeOutputSchema, mkdirOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsInputSchema, processLogsOutputSchema, computerOperationResultSchema, mintComputerRequestId, processIdInputSchema, } from "@fungi.computer/computer-contract";
15
+ import { ComputerFileConflict, ComputerFileMoveError, computerExecutionRequestSchema, computerValueSchema, computerPortInputSchema, listInputSchema, listOutputSchema, readBytesInputSchema, writeInputSchema, replaceInputSchema, writeOutputSchema, mkdirOutputSchema, moveInputSchema, moveOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsInputSchema, processLogsOutputSchema, computerOperationResultSchema, mintComputerRequestId, processIdInputSchema, } from "@fungi.computer/computer-contract";
16
16
  import { workflowGitExecutionEnvironment, workflowGitPassGrantSchema, } from "@fungi.computer/braid/runtime";
17
17
  import { checkComputerGrant, computerActionSchema, computerGrantSchema, ComputerBackingError, createFleetBacking, FleetGrantRefused, FleetLifecycle, } from "@fungi.computer/computer/fleet";
18
18
  import { AppInstanceError, selectionOf } from "../index.js";
@@ -50,6 +50,7 @@ const processStartReply = z.lazy(() => z.union([
50
50
  const bindingWrite = writeInputSchema.extend({
51
51
  expectedContent: replaceInputSchema.shape.expectedContent.optional(),
52
52
  });
53
+ const bindingMkdir = z.strictObject({ path: writeInputSchema.shape.path });
53
54
  const allActions = new Set(computerActionSchema.options);
54
55
  const terminalGrantHeader = "X-Oyster-Computer-Grant";
55
56
  const terminalGrant = computerGrantSchema.extend({
@@ -84,6 +85,7 @@ const computerTools = {
84
85
  read: { action: "files.read", output: readOutputSchema },
85
86
  list: { action: "files.list", output: listOutputSchema },
86
87
  write: { action: "files.write", output: writeOutputSchema },
88
+ move: { action: "files.move", output: moveOutputSchema },
87
89
  mkdir: { action: "mkdir", output: mkdirOutputSchema },
88
90
  bash: { action: "bash", output: computerToolResultSchema },
89
91
  exec: { action: "exec", output: computerToolResultSchema },
@@ -95,6 +97,7 @@ const computerTool = z.enum([
95
97
  "read",
96
98
  "list",
97
99
  "write",
100
+ "move",
98
101
  "mkdir",
99
102
  "bash",
100
103
  "exec",
@@ -109,6 +112,7 @@ const previewRefusal = appMethodRefusedReplySchema.parse({
109
112
  });
110
113
  /** The non-secret context a native command carries for its admitted Git step. */
111
114
  const workflowGitExecutionContextSchema = z.lazy(() => z.strictObject({ workflowGit: workflowGitPassGrantSchema }));
115
+ const sizeTable = "CREATE TABLE IF NOT EXISTS oyster_computer_size (singleton INTEGER PRIMARY KEY CHECK (singleton = 1), size TEXT NOT NULL CHECK (size IN ('small','default','large'))) STRICT";
112
116
  /** Durable workspace and existing backings, with fleet checks at native acceptance. */
113
117
  export class ComputerDO extends NativeComputerDO {
114
118
  previewBindings;
@@ -165,8 +169,21 @@ export class ComputerDO extends NativeComputerDO {
165
169
  });
166
170
  return this.#lifecycle;
167
171
  }
172
+ /** The size fixed at creation; a Computer never created by the fleet has none. */
173
+ computerSize() {
174
+ const sql = this.state.storage.sql;
175
+ sql.exec(sizeTable);
176
+ const row = sql
177
+ .exec("SELECT size FROM oyster_computer_size WHERE singleton=1")
178
+ .toArray()[0];
179
+ if (row === undefined)
180
+ throw new Error("Computer was created without a size");
181
+ return computerSizeSchema.parse(row.size);
182
+ }
168
183
  /** Install the fleet's creation projection before exposing its new identity. */
169
- initializeFleetBackings(backings) {
184
+ initializeFleetBackings(backings, size) {
185
+ this.state.storage.sql.exec(sizeTable);
186
+ this.state.storage.sql.exec("INSERT OR IGNORE INTO oyster_computer_size (singleton, size) VALUES (1, ?)", size);
170
187
  const owner = createFleetBacking(this.state.storage);
171
188
  owner.ensure();
172
189
  this.#backends = owner.computerCreated(this.#id(), z.array(hostedBackingSchema).parse(backings)).backends;
@@ -534,6 +551,21 @@ export class ComputerDO extends NativeComputerDO {
534
551
  }
535
552
  case "files.write":
536
553
  return writeOutputSchema.parse(await this.callAfterAcceptance("write", input, accept));
554
+ case "files.move":
555
+ try {
556
+ return moveOutputSchema.parse(await this.callAfterAcceptance("move", input, accept));
557
+ }
558
+ catch (error) {
559
+ if (error instanceof ComputerFileMoveError)
560
+ return {
561
+ error: error.reason === "exists"
562
+ ? "conflict"
563
+ : error.reason === "missing"
564
+ ? "not_found"
565
+ : "invalid",
566
+ };
567
+ throw error;
568
+ }
537
569
  case "mkdir":
538
570
  return mkdirOutputSchema.parse(await this.callAfterAcceptance("mkdir", input, accept));
539
571
  default:
@@ -778,6 +810,23 @@ export const computerFrameMethods = {
778
810
  .parse(value),
779
811
  requiredOperations: () => ["write"],
780
812
  },
813
+ mkdir: {
814
+ decodeArgs: (args) => z.tuple([bindingMkdir]).parse(args),
815
+ decodeResult: (value) => mkdirOutputSchema.parse(value),
816
+ requiredOperations: () => ["mkdir"],
817
+ },
818
+ move: {
819
+ decodeArgs: (args) => z.tuple([moveInputSchema]).parse(args),
820
+ decodeResult: (value) => z
821
+ .union([
822
+ moveOutputSchema,
823
+ z.strictObject({
824
+ error: z.enum(["conflict", "not_found", "invalid"]),
825
+ }),
826
+ ])
827
+ .parse(value),
828
+ requiredOperations: () => ["move"],
829
+ },
781
830
  ports: {
782
831
  decodeArgs: (args) => z.tuple([empty]).parse(args),
783
832
  decodeResult: (value) => computerPortsOutputSchema.parse(value),
@@ -907,6 +956,16 @@ export async function computerInvocation(env, scope, frame, method, args) {
907
956
  };
908
957
  break;
909
958
  }
959
+ case "mkdir": {
960
+ const [parsed] = z.tuple([bindingMkdir]).parse(args);
961
+ action = "mkdir";
962
+ input = { path: parsed.path, recursive: true };
963
+ break;
964
+ }
965
+ case "move":
966
+ action = "files.move";
967
+ [input] = z.tuple([moveInputSchema]).parse(args);
968
+ break;
910
969
  case "ports":
911
970
  action = "listPorts";
912
971
  [input] = z.tuple([empty]).parse(args);
@@ -108,7 +108,7 @@ export async function installApps(args, install = installStandaloneAppSet, ui =
108
108
  if (values.from !== undefined && values.repositories !== undefined)
109
109
  throw new Error("Choose either --from or --repositories");
110
110
  const concurrency = values.concurrency === undefined
111
- ? defaultStarterBuildConcurrency
111
+ ? defaultStarterBuildConcurrency()
112
112
  : Number(values.concurrency);
113
113
  const scratch = await mkdtemp(join(tmpdir(), "oyster-install-apps-"));
114
114
  try {
@@ -55,7 +55,7 @@ export declare const mediaFrameMethods: {
55
55
  requestId: string;
56
56
  libraryPath: string;
57
57
  settings: {
58
- model: "bytedance/seedance-2.0" | "google/veo-3.1" | "bytedance/seedance-2.0-fast" | "bytedance/seedance-2.0-mini" | "google/veo-3.1-fast" | "minimax/h3-max";
58
+ model: "bytedance/seedance-2.0" | "google/veo-3.1" | "bytedance/seedance-2.5" | "bytedance/seedance-2.0-fast" | "bytedance/seedance-2.0-mini" | "google/veo-3.1-fast" | "minimax/h3-max";
59
59
  prompt: string;
60
60
  resolution?: "480p" | "720p" | "768p" | "1080p" | "4k" | undefined;
61
61
  aspectRatio?: "16:9" | "4:3" | "1:1" | "3:4" | "9:16" | "21:9" | "9:21" | undefined;
@@ -69,12 +69,14 @@ export declare abstract class StandaloneRegistry extends OysterRegistry implemen
69
69
  computerFleet(memberId: string, request: StandaloneFleetRequest): Promise<Readonly<{
70
70
  computerId: string;
71
71
  name: string;
72
+ size: import("@fungi.computer/computer").ComputerSize;
72
73
  createdAt: number;
73
74
  updatedAt: number;
74
75
  }> | {
75
76
  readonly computers: Readonly<{
76
77
  computerId: string;
77
78
  name: string;
79
+ size: import("@fungi.computer/computer").ComputerSize;
78
80
  createdAt: number;
79
81
  updatedAt: number;
80
82
  }>[];
@@ -128,6 +130,7 @@ export declare abstract class StandaloneRegistry extends OysterRegistry implemen
128
130
  } | Readonly<{
129
131
  computerId: string;
130
132
  name: string;
133
+ size: import("@fungi.computer/computer").ComputerSize;
131
134
  createdAt: number;
132
135
  updatedAt: number;
133
136
  }>)[];
@@ -107,7 +107,7 @@ export class StandaloneRegistry extends OysterRegistry {
107
107
  const backings = this.#computers.readBacking(created.computerId);
108
108
  if (backings === null)
109
109
  throw new Error("Computer backing is missing");
110
- await this.#env.COMPUTER.getByName(created.computerId).initializeFleetBackings(backings);
110
+ await this.#env.COMPUTER.getByName(created.computerId).initializeFleetBackings(backings, created.size);
111
111
  return created;
112
112
  }
113
113
  case "list":