@fungi.computer/computer 0.9.0 → 0.10.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.
@@ -17,6 +17,7 @@ export declare const computerActionSchema: z.ZodEnum<{
17
17
  "files.grep": "files.grep";
18
18
  "files.edit": "files.edit";
19
19
  "files.patch": "files.patch";
20
+ "files.move": "files.move";
20
21
  terminal: "terminal";
21
22
  stop: "stop";
22
23
  processStart: "processStart";
@@ -53,6 +54,7 @@ export declare const computerGrantSchema: z.ZodObject<{
53
54
  "files.grep": "files.grep";
54
55
  "files.edit": "files.edit";
55
56
  "files.patch": "files.patch";
57
+ "files.move": "files.move";
56
58
  terminal: "terminal";
57
59
  stop: "stop";
58
60
  processStart: "processStart";
package/dist/index.js CHANGED
@@ -68,7 +68,7 @@ import { z } from "zod";
68
68
  import { SystemTrustContainerBackend } from "./container-system-trust.js";
69
69
  import { computerTransportBackend } from "./transport-backend.js";
70
70
  import { PullPendingTracker } from "./pull-pending.js";
71
- import { ComputerFileConflict, ComputerFileRangeError, ComputerFileTooLargeError, capabilityNameSchema, computerValueSchema, computerCapabilities, computerPortInputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, computerPortsOutputSchema, computerPortSchema, ComputerPortLimitError, ComputerPortReservedError, computerTerminalPort, isComputerReservedPort, maximumExposedPorts, maximumProcessRecords, execInputSchema, execOutputSchema, computerToolResult, computerExecutionRequestSchema, genericComputerExecutionBudget, mintComputerRequestId, listInputSchema, listOutputSchema, maximumFileBytes, mkdirInputSchema, mkdirOutputSchema, readInputSchema, readBytesInputSchema, readOutputSchema, replaceInputSchema, writeInputSchema, writeOutputSchema, processIdInputSchema, processKillOutputSchema, processListOutputSchema, processLogsInputSchema, processLogsOutputSchema, maximumProcessLogLines, processStartInputSchema, processStartToolInputSchema, ComputerProcessNotFoundError, } from "@fungi.computer/computer-contract";
71
+ import { ComputerFileConflict, ComputerFileRangeError, ComputerFileTooLargeError, capabilityNameSchema, computerValueSchema, computerCapabilities, computerPortInputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, computerPortsOutputSchema, computerPortSchema, ComputerPortLimitError, ComputerPortReservedError, computerTerminalPort, isComputerReservedPort, maximumExposedPorts, maximumProcessRecords, execInputSchema, execOutputSchema, computerToolResult, computerExecutionRequestSchema, genericComputerExecutionBudget, mintComputerRequestId, listInputSchema, listOutputSchema, maximumFileBytes, mkdirInputSchema, mkdirOutputSchema, moveInputSchema, moveOutputSchema, ComputerFileMoveError, readInputSchema, readBytesInputSchema, readOutputSchema, replaceInputSchema, writeInputSchema, writeOutputSchema, processIdInputSchema, processKillOutputSchema, processListOutputSchema, processLogsInputSchema, processLogsOutputSchema, maximumProcessLogLines, processStartInputSchema, processStartToolInputSchema, ComputerProcessNotFoundError, } from "@fungi.computer/computer-contract";
72
72
  import { createWorkspaceFilesPort, readBoundedWorkspaceText, listWorkspaceFiles, } from "./files.js";
73
73
  import { computerExecutionResult } from "./execution-result.js";
74
74
  import { ComputerOperationRecord } from "./operation-record.js";
@@ -125,6 +125,53 @@ async function mkdir(workspace, input) {
125
125
  await workspace.fs.mkdir(path, { recursive });
126
126
  return mkdirOutputSchema.parse({ path });
127
127
  }
128
+ const isMissing = z.lazy(() => z.object({ code: z.literal("ENOENT") }));
129
+ const isInvalid = z.lazy(() => z.object({ code: z.literal("EINVAL") }));
130
+ /**
131
+ * Rename through the Workspace provider's native `rename`, which moves the
132
+ * inode under its new name, so a directory keeps its whole subtree and nothing
133
+ * is copied. The provider overwrites an existing destination, so refuse that
134
+ * first. Call inside one storage transaction: a refusal after
135
+ * `createParents` has made folders rolls them back.
136
+ */
137
+ function move(workspace, input) {
138
+ const { from, to, createParents } = moveInputSchema.parse(input);
139
+ const provider = new SQLiteWorkspaceProvider(workspace.fs.db);
140
+ const lstat = (path) => {
141
+ try {
142
+ return provider.lstatSync(path);
143
+ }
144
+ catch (cause) {
145
+ if (isMissing.safeParse(cause).success)
146
+ return null;
147
+ throw cause;
148
+ }
149
+ };
150
+ const source = lstat(from);
151
+ if (source === null)
152
+ throw new ComputerFileMoveError("missing", `no such path: ${from}`);
153
+ if (source.isDirectory() && (to === from || to.startsWith(`${from}/`)))
154
+ throw new ComputerFileMoveError("invalid", `a directory cannot move into itself: ${from}`);
155
+ if (lstat(to) !== null)
156
+ throw new ComputerFileMoveError("exists", `already exists: ${to}`);
157
+ const parent = to.slice(0, Math.max(to.lastIndexOf("/"), 1));
158
+ if (createParents)
159
+ provider.mkdirSync(parent, { recursive: true });
160
+ try {
161
+ provider.renameSync(from, to);
162
+ }
163
+ catch (cause) {
164
+ // The provider's own checks still decide what the text above cannot: a
165
+ // missing parent, and a destination that resolves inside the source
166
+ // through a symlink.
167
+ if (isMissing.safeParse(cause).success)
168
+ throw new ComputerFileMoveError("missing", `parent directory missing: ${to}`);
169
+ if (isInvalid.safeParse(cause).success)
170
+ throw new ComputerFileMoveError("invalid", `cannot move ${from} to ${to}`);
171
+ throw cause;
172
+ }
173
+ return moveOutputSchema.parse({ from, to });
174
+ }
128
175
  async function write(workspace, input) {
129
176
  const { path, content } = writeInputSchema.parse(input);
130
177
  await workspace.fs.writeFile(path, content);
@@ -1046,6 +1093,12 @@ export class ComputerDO extends ContainerComputer {
1046
1093
  await this.#syncRunningHosted("push");
1047
1094
  return result;
1048
1095
  }
1096
+ case "move": {
1097
+ await this.#syncRunningHosted("pull");
1098
+ const result = this.state.storage.transactionSync(() => move(workspace, input));
1099
+ await this.#syncRunningHosted("push");
1100
+ return result;
1101
+ }
1049
1102
  default:
1050
1103
  throw new Error(`Computer capability is unavailable: ${selected}`);
1051
1104
  }
@@ -19604,6 +19604,11 @@ var appBackendBindingKinds = {
19604
19604
  requires: ["computer.writeFile"],
19605
19605
  effect: "write"
19606
19606
  },
19607
+ move: {
19608
+ cap: "app.computer.write",
19609
+ requires: ["computer.writeFile"],
19610
+ effect: "write"
19611
+ },
19607
19612
  preview: {
19608
19613
  cap: "app.computer.exec",
19609
19614
  requires: ["computer.execute"],
@@ -19677,6 +19682,7 @@ var appCapabilityIds = [
19677
19682
  "agent.manage",
19678
19683
  "agent.rename",
19679
19684
  "agent.avatar",
19685
+ "agent.instructions",
19680
19686
  "agent.toolPolicy",
19681
19687
  "agent.read",
19682
19688
  "agent.send",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/computer",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Cloudflare Computer host for one durable Fungi Computer",
6
6
  "type": "module",
@@ -60,10 +60,10 @@
60
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.2",
63
- "@fungi.computer/knapsack": "0.4.9",
63
+ "@fungi.computer/knapsack": "0.4.10",
64
64
  "@fungi.computer/seam": "0.2.5",
65
65
  "@fungi.computer/watchdog": "0.1.3",
66
- "@fungi.computer/computer-contract": "0.2.0",
66
+ "@fungi.computer/computer-contract": "0.3.0",
67
67
  "effect": "4.0.2",
68
68
  "just-bash": "3.4.2",
69
69
  "zod": "4.4.3"