@fungi.computer/oyster 0.50.0 → 0.50.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.
- package/dist/agents.js +8 -17
- package/dist/auth.js +3 -5
- package/dist/body-limit.d.ts +8 -0
- package/dist/body-limit.js +14 -0
- package/dist/build/job-log.d.ts +3 -1
- package/dist/build/job-log.js +5 -3
- package/dist/embed-metafiles.js +1 -1
- package/dist/embed-scripts.js +1 -1
- package/dist/files.js +9 -10
- package/package.json +3 -3
package/dist/files.js
CHANGED
|
@@ -6,10 +6,15 @@
|
|
|
6
6
|
* the Oyster's workspace unchanged. Other sources (a git repository) implement
|
|
7
7
|
* the same `FileSource`.
|
|
8
8
|
*/
|
|
9
|
+
import { bodyAtMost } from "./body-limit.js";
|
|
9
10
|
import { computer, routes } from "./authorization.js";
|
|
10
11
|
import * as Schema from "effect/Schema";
|
|
11
12
|
import { computerList, computerReadFile, computerWriteFile, } from "@fungi.computer/agar/computer";
|
|
12
13
|
const MAX_FILE_BYTES = 25 * 1024 * 1024;
|
|
14
|
+
/** A replace carries the expected and the new text: each at most a file. */
|
|
15
|
+
const MAX_REPLACE_REQUEST_BYTES = 2 * MAX_FILE_BYTES + 64 * 1024;
|
|
16
|
+
/** A mkdir carries one path of at most 4,096 characters. */
|
|
17
|
+
const MAX_PATH_REQUEST_BYTES = 16 * 1024;
|
|
13
18
|
const MAX_LIST = 1000;
|
|
14
19
|
/** Normalize an absolute path; `null` when it is not one or escapes the root. */
|
|
15
20
|
export function normalizeFilePath(raw) {
|
|
@@ -96,15 +101,9 @@ function createFileRoutes(source) {
|
|
|
96
101
|
const path = pathOf(context.req.query("path"));
|
|
97
102
|
if (path === null || path === "/")
|
|
98
103
|
return refusal(400, "Invalid path");
|
|
99
|
-
|
|
100
|
-
if (length > MAX_FILE_BYTES)
|
|
101
|
-
return refusal(413, "File too large");
|
|
102
|
-
const bytes = new Uint8Array(await context.req.arrayBuffer());
|
|
103
|
-
if (bytes.length > MAX_FILE_BYTES)
|
|
104
|
-
return refusal(413, "File too large");
|
|
105
|
-
await source.write(path, bytes);
|
|
104
|
+
await source.write(path, new Uint8Array(await context.req.arrayBuffer()));
|
|
106
105
|
return new Response(null, { status: 204 });
|
|
107
|
-
});
|
|
106
|
+
}, bodyAtMost(MAX_FILE_BYTES, "File too large"));
|
|
108
107
|
table.post("/mkdir", computer(), async (context) => {
|
|
109
108
|
const body = Schema.decodeUnknownOption(mkdirSchema)(await context.req.json());
|
|
110
109
|
const path = body._tag === "Some" ? normalizeFilePath(body.value.path) : null;
|
|
@@ -112,13 +111,13 @@ function createFileRoutes(source) {
|
|
|
112
111
|
return refusal(400, "Invalid path");
|
|
113
112
|
await source.mkdir(path);
|
|
114
113
|
return new Response(null, { status: 204 });
|
|
115
|
-
});
|
|
114
|
+
}, bodyAtMost(MAX_PATH_REQUEST_BYTES));
|
|
116
115
|
table.post("/replace", computer(), async (context) => {
|
|
117
116
|
const body = Schema.decodeUnknownOption(replaceSchema)(await context.req.json());
|
|
118
117
|
const path = body._tag === "Some" ? normalizeFilePath(body.value.path) : null;
|
|
119
118
|
if (body._tag === "None" || path === null)
|
|
120
119
|
return refusal(400, "Invalid request");
|
|
121
120
|
return Response.json(await source.replace(path, body.value.expectedContent, body.value.content));
|
|
122
|
-
});
|
|
121
|
+
}, bodyAtMost(MAX_REPLACE_REQUEST_BYTES));
|
|
123
122
|
return table;
|
|
124
123
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/oyster",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.1",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Oyster by Fungi: open-source Apps for people and AI agents. Try with one command or run on your own Cloudflare account.",
|
|
6
6
|
"homepage": "https://docs.fungi.computer/oyster",
|
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
"@fungi.computer/burrow": "0.2.1",
|
|
369
369
|
"@fungi.computer/cairn": "0.1.0",
|
|
370
370
|
"@fungi.computer/capnweb": "0.12.0-fungi.0",
|
|
371
|
-
"@fungi.computer/caps": "0.12.
|
|
371
|
+
"@fungi.computer/caps": "0.12.3",
|
|
372
372
|
"@fungi.computer/carrier": "0.2.5",
|
|
373
373
|
"@fungi.computer/computer": "0.16.3",
|
|
374
374
|
"@fungi.computer/computer-contract": "0.5.8",
|
|
@@ -380,7 +380,7 @@
|
|
|
380
380
|
"@fungi.computer/lantern": "0.4.2",
|
|
381
381
|
"@fungi.computer/mycelium": "0.4.7",
|
|
382
382
|
"@fungi.computer/nacre": "0.8.6",
|
|
383
|
-
"@fungi.computer/parakeet": "0.16.
|
|
383
|
+
"@fungi.computer/parakeet": "0.16.3",
|
|
384
384
|
"@fungi.computer/puffball": "0.12.0",
|
|
385
385
|
"@fungi.computer/seam": "0.2.6",
|
|
386
386
|
"@fungi.computer/shiitake": "0.21.11",
|