@fungi.computer/computer 0.2.0 → 0.2.1

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 (2) hide show
  1. package/dist/files.js +15 -3
  2. package/package.json +2 -2
package/dist/files.js CHANGED
@@ -1,5 +1,5 @@
1
- import { WorkspaceFileStore } from "@fungi.computer/cloudflare-computer/tools";
2
1
  import { posix } from "node:path";
2
+ import { z } from "zod";
3
3
  import { SearchVisibility } from "@fungi.computer/knapsack/files-search";
4
4
  import { imageReadResult, imageSniffBytes, imageTooLargeMessage, maximumImageBytes, sniffImageMimeType, } from "@fungi.computer/knapsack/files-read";
5
5
  import { replaceOutputSchema, } from "@fungi.computer/computer-contract";
@@ -203,13 +203,25 @@ function workspacePath(path) {
203
203
  return "/";
204
204
  return path.startsWith("/") ? path : `/${path}`;
205
205
  }
206
+ const missingSchema = z.object({ code: z.literal("ENOENT") });
207
+ /** A regular file's stat, or null when the path is absent or not a file. */
208
+ async function fileStat(workspace, path) {
209
+ try {
210
+ const stat = await workspace.fs.stat(path);
211
+ return stat.isFile ? stat : null;
212
+ }
213
+ catch (error) {
214
+ if (missingSchema.safeParse(error).success)
215
+ return null;
216
+ throw error;
217
+ }
218
+ }
206
219
  /** Storage adapter only; shared Files policy owns visibility and grammar. */
207
220
  function workspaceSearchVisibility(workspace) {
208
- const store = new WorkspaceFileStore(workspace);
209
221
  let bytes = 0;
210
222
  return new SearchVisibility(async (directory) => {
211
223
  const path = posix.join("/", directory, ".gitignore");
212
- const stat = await store.stat(path);
224
+ const stat = await fileStat(workspace, path);
213
225
  if (stat !== null) {
214
226
  // Match Local's bounded text reads; never silently omit unreadable rules.
215
227
  if (stat.size > 128 * 1_024 || bytes + stat.size > 64 * 1_024 * 1_024)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/computer",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Cloudflare Computer host for one durable Fungi Computer",
6
6
  "type": "module",
@@ -55,7 +55,7 @@
55
55
  "@fungi.computer/cairn": "0.1.0",
56
56
  "@fungi.computer/capnweb": "0.12.0",
57
57
  "@fungi.computer/cloudflare-computer": "0.2.1-fungi.1",
58
- "@fungi.computer/cordyceps": "0.3.0",
58
+ "@fungi.computer/cordyceps": "0.3.1",
59
59
  "@fungi.computer/knapsack": "0.2.0",
60
60
  "@fungi.computer/seam": "0.1.0",
61
61
  "@fungi.computer/watchdog": "0.1.0",