@fungi.computer/oyster 0.30.2 → 0.31.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.
- package/dist/embed-metafiles.js +1 -1
- package/dist/embed-scripts.js +2 -2
- package/dist/files.d.ts +2 -0
- package/dist/r2-files.js +3 -0
- package/dist/standalone/computer.d.ts +4 -2
- package/dist/standalone/computer.js +27 -1
- package/dist/standalone/media.d.ts +2 -0
- package/dist/standalone/media.js +12 -4
- package/docs/api/files.md +1 -0
- package/package.json +4 -4
package/dist/files.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export type FileSource = Readonly<{
|
|
|
31
31
|
read(path: string): Promise<Uint8Array | null>;
|
|
32
32
|
/** Create or replace a file. */
|
|
33
33
|
write(path: string, content: Uint8Array): Promise<void>;
|
|
34
|
+
/** Delete one file; resolves when nothing is left at the path. */
|
|
35
|
+
delete(path: string): Promise<void>;
|
|
34
36
|
/** Create a directory. */
|
|
35
37
|
mkdir(path: string): Promise<void>;
|
|
36
38
|
/** Write `content` only if the file still holds `expectedContent`. */
|
package/dist/r2-files.js
CHANGED
|
@@ -59,6 +59,9 @@ export function r2FileSource(bucket, prefix) {
|
|
|
59
59
|
async write(path, content) {
|
|
60
60
|
await bucket.put(key(path), content);
|
|
61
61
|
},
|
|
62
|
+
async delete(path) {
|
|
63
|
+
await bucket.delete(key(path));
|
|
64
|
+
},
|
|
62
65
|
async mkdir(path) {
|
|
63
66
|
await bucket.put(dirKey(path), new Uint8Array());
|
|
64
67
|
},
|
|
@@ -8,7 +8,7 @@ import * as z from "zod";
|
|
|
8
8
|
import { computerProcessSchema, computerToolResultSchema, readOutputSchema } from "@fungi.computer/computer-contract";
|
|
9
9
|
import { ComputerDO as NativeComputerDO, type AttachedBackend, type ComputerEnv, type ComputerFilesRpc } from "@fungi.computer/computer";
|
|
10
10
|
import { patchInputSchema, patchOutputSchema } from "@fungi.computer/knapsack/files-patch";
|
|
11
|
-
import { listOutputSchema, writeOutputSchema, mkdirOutputSchema, moveOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsOutputSchema, processWaitOutputSchema, computerOperationResultSchema, type ComputerExecutionHostHooks, type ComputerValue } from "@fungi.computer/computer-contract";
|
|
11
|
+
import { listOutputSchema, writeOutputSchema, mkdirOutputSchema, moveOutputSchema, removeOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsOutputSchema, processWaitOutputSchema, computerOperationResultSchema, type ComputerExecutionHostHooks, type ComputerValue } from "@fungi.computer/computer-contract";
|
|
12
12
|
import { type WorkflowGitCredential, type WorkflowGitPassGrant } from "@fungi.computer/braid/runtime";
|
|
13
13
|
import { type ComputerAction, type ComputerBackendView, type ComputerGrant, type LocalBackendAttachInput, type LocalBackendDetachInput } from "@fungi.computer/computer/fleet";
|
|
14
14
|
import type { InvocationFrame } from "../invocation.js";
|
|
@@ -42,7 +42,7 @@ export type StandaloneComputerResult = z.output<typeof listOutputSchema> | Reado
|
|
|
42
42
|
truncated: boolean;
|
|
43
43
|
}> | Readonly<{
|
|
44
44
|
error: "conflict" | "no_runtime" | "not_found" | "invalid";
|
|
45
|
-
}> | 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 processWaitOutputSchema> | z.output<typeof computerProcessSchema> | ComputerPorts["ports"][number] | z.output<typeof computerOperationResultSchema> | z.output<typeof readOutputSchema> | z.output<typeof computerToolResultSchema>;
|
|
45
|
+
}> | z.output<typeof writeOutputSchema> | z.output<typeof moveOutputSchema> | z.output<typeof removeOutputSchema> | 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 processWaitOutputSchema> | z.output<typeof computerProcessSchema> | ComputerPorts["ports"][number] | z.output<typeof computerOperationResultSchema> | z.output<typeof readOutputSchema> | z.output<typeof computerToolResultSchema>;
|
|
46
46
|
/**
|
|
47
47
|
* A port-preview listing, or the typed refusal the owner route presents with
|
|
48
48
|
* {@link appMethodRefusalStatus}. A refusal never escapes as a 500.
|
|
@@ -207,6 +207,8 @@ export declare class ComputerDO extends NativeComputerDO implements ComputerFetc
|
|
|
207
207
|
/** Binary files share the same native filesystem as commands and PTYs. */
|
|
208
208
|
fileRead(authority: ComputerGrant, path: string): Promise<Uint8Array | null>;
|
|
209
209
|
fileWrite(authority: ComputerGrant, path: string, bytes: Uint8Array): Promise<void>;
|
|
210
|
+
/** Delete one file; a path that is already absent is already deleted. */
|
|
211
|
+
fileDelete(authority: ComputerGrant, path: string): Promise<void>;
|
|
210
212
|
/** Patch is handled by the Computer's pinned native engine, not by the Agent. */
|
|
211
213
|
filePatch(authority: ComputerGrant, input: z.output<typeof patchInputSchema>): Promise<z.output<typeof patchOutputSchema>>;
|
|
212
214
|
fileReplace(authority: ComputerGrant, path: string, expectedContent: string | null, content: string): Promise<{
|
|
@@ -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, ComputerFileMoveError, computerExecutionRequestSchema, computerValueSchema, computerPortInputSchema, listInputSchema, listOutputSchema, readBytesInputSchema, writeInputSchema, replaceInputSchema, writeOutputSchema, mkdirOutputSchema, moveInputSchema, moveOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsInputSchema, processWaitInputSchema, processLogsOutputSchema, processWaitOutputSchema, computerOperationResultSchema, mintComputerRequestId, processIdInputSchema, } from "@fungi.computer/computer-contract";
|
|
15
|
+
import { ComputerFileConflict, ComputerFileMoveError, ComputerFileRemoveError, computerExecutionRequestSchema, computerValueSchema, computerPortInputSchema, listInputSchema, listOutputSchema, readBytesInputSchema, writeInputSchema, replaceInputSchema, writeOutputSchema, mkdirOutputSchema, moveInputSchema, moveOutputSchema, removeOutputSchema, computerPortsOutputSchema, computerPortOutputSchema, computerPortRemovalOutputSchema, processListOutputSchema, processKillOutputSchema, processLogsInputSchema, processWaitInputSchema, processLogsOutputSchema, processWaitOutputSchema, 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";
|
|
@@ -586,6 +586,17 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
586
586
|
};
|
|
587
587
|
throw error;
|
|
588
588
|
}
|
|
589
|
+
case "files.remove":
|
|
590
|
+
try {
|
|
591
|
+
return removeOutputSchema.parse(await this.callAfterAcceptance("remove", input, accept));
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
if (error instanceof ComputerFileRemoveError)
|
|
595
|
+
return {
|
|
596
|
+
error: error.reason === "missing" ? "not_found" : "invalid",
|
|
597
|
+
};
|
|
598
|
+
throw error;
|
|
599
|
+
}
|
|
589
600
|
case "mkdir":
|
|
590
601
|
return mkdirOutputSchema.parse(await this.callAfterAcceptance("mkdir", input, accept));
|
|
591
602
|
default:
|
|
@@ -628,6 +639,20 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
628
639
|
this.#accept(authority, "files.writeBytes");
|
|
629
640
|
});
|
|
630
641
|
}
|
|
642
|
+
/** Delete one file; a path that is already absent is already deleted. */
|
|
643
|
+
async fileDelete(authority, path) {
|
|
644
|
+
try {
|
|
645
|
+
await this.callAfterAcceptance("remove", { path }, () => {
|
|
646
|
+
this.#accept(authority, "files.remove");
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
catch (error) {
|
|
650
|
+
if (error instanceof ComputerFileRemoveError &&
|
|
651
|
+
error.reason === "missing")
|
|
652
|
+
return;
|
|
653
|
+
throw error;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
631
656
|
/** Patch is handled by the Computer's pinned native engine, not by the Agent. */
|
|
632
657
|
async filePatch(authority, input) {
|
|
633
658
|
return this.applyPatchAfterAcceptance(input, () => {
|
|
@@ -696,6 +721,7 @@ export function standaloneWorkspace(env, keysLive, selectedComputerId = env.OYST
|
|
|
696
721
|
list: (path, limit, offset) => computer().fileList(authority(), path, limit, offset),
|
|
697
722
|
read: (path) => computer().fileRead(authority(), path),
|
|
698
723
|
write: (path, bytes) => computer().fileWrite(authority(), path, bytes),
|
|
724
|
+
delete: (path) => computer().fileDelete(authority(), path),
|
|
699
725
|
mkdir: async (path) => {
|
|
700
726
|
await computer().value(authority(), "mkdir", { path, recursive: true });
|
|
701
727
|
},
|
|
@@ -31,6 +31,8 @@ export declare function workersMedia(env: OysterMediaEnv, workspace: Readonly<{
|
|
|
31
31
|
computerId: string;
|
|
32
32
|
files: FileSource;
|
|
33
33
|
}>): readonly OysterCapability[];
|
|
34
|
+
/** Erase a written file from the workspace only while it still holds the written bytes. */
|
|
35
|
+
export declare function workspaceMediaRemove(files: Pick<FileSource, "read" | "delete">): MediaServiceHost["destination"]["remove"];
|
|
34
36
|
/** The Instance gate and native guest entrypoint share these argument codecs. */
|
|
35
37
|
export declare const mediaFrameMethods: {
|
|
36
38
|
MEDIA: {
|
package/dist/standalone/media.js
CHANGED
|
@@ -7,7 +7,7 @@ import { computer, routes as routeTable } from "../authorization.js";
|
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import { pendingSchema } from "@fungi.computer/agar/backend-definition";
|
|
9
9
|
import { mediaGenerationDescriptionSchema, mediaGenerationJsonRequestSchema, mediaGenerationQuoteRequestSchema, mediaGenerationReferenceSchema, } from "@fungi.computer/agar/media-json";
|
|
10
|
-
import { createDailyMediaMetering, createMediaService, readHostReference, referenceFilename, estimateMediaModel, mediaPendingSchema, mediaResultSchema, mediaBindingCallSchema, mediaBindingRequest, parseMediaBindingCall, readMediaBindingReply, } from "@fungi.computer/darkroom/server";
|
|
10
|
+
import { createDailyMediaMetering, createMediaService, readHostReference, removeMediaIfWritten, referenceFilename, estimateMediaModel, mediaPendingSchema, mediaResultSchema, mediaBindingCallSchema, mediaBindingRequest, parseMediaBindingCall, readMediaBindingReply, } from "@fungi.computer/darkroom/server";
|
|
11
11
|
import { createWorkersAiMediaProvider, createImagesReferenceFitter, } from "@fungi.computer/darkroom/cloudflare";
|
|
12
12
|
import { oysterPrincipalId, } from "../host.js";
|
|
13
13
|
import { normalizeFilePath } from "../files.js";
|
|
@@ -186,6 +186,16 @@ function workspacePath(path) {
|
|
|
186
186
|
throw new Error("Media destination must be an absolute workspace file path");
|
|
187
187
|
return normalized;
|
|
188
188
|
}
|
|
189
|
+
/** Erase a written file from the workspace only while it still holds the written bytes. */
|
|
190
|
+
export function workspaceMediaRemove(files) {
|
|
191
|
+
return async (path, written) => {
|
|
192
|
+
const target = workspacePath(path);
|
|
193
|
+
return await removeMediaIfWritten({
|
|
194
|
+
read: () => files.read(target),
|
|
195
|
+
delete: () => files.delete(target),
|
|
196
|
+
}, written.sha256);
|
|
197
|
+
};
|
|
198
|
+
}
|
|
189
199
|
/** Both the HTTP capability and guest binding construct the existing Darkroom service. */
|
|
190
200
|
function standaloneMediaService(env, actorId, workspace, owner = "owner", libraryPath) {
|
|
191
201
|
const { computerId, files } = workspace;
|
|
@@ -210,9 +220,7 @@ function standaloneMediaService(env, actorId, workspace, owner = "owner", librar
|
|
|
210
220
|
await files.mkdir(workspacePath(libraryPath));
|
|
211
221
|
},
|
|
212
222
|
write: (path, bytes) => files.write(workspacePath(path), bytes),
|
|
213
|
-
|
|
214
|
-
// stays in the workspace; erasure reports it kept.
|
|
215
|
-
remove: () => Promise.resolve("kept"),
|
|
223
|
+
remove: workspaceMediaRemove(files),
|
|
216
224
|
readAudioReference: (reference) => readWorkspaceReference("audio", reference),
|
|
217
225
|
};
|
|
218
226
|
const admittedDestination = fit === undefined
|
package/docs/api/files.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/oyster",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
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",
|
|
@@ -354,8 +354,8 @@
|
|
|
354
354
|
"@fungi.computer/capnweb": "0.12.0-fungi.0",
|
|
355
355
|
"@fungi.computer/caps": "0.11.7",
|
|
356
356
|
"@fungi.computer/carrier": "0.2.4",
|
|
357
|
-
"@fungi.computer/computer": "0.
|
|
358
|
-
"@fungi.computer/computer-contract": "0.
|
|
357
|
+
"@fungi.computer/computer": "0.13.0",
|
|
358
|
+
"@fungi.computer/computer-contract": "0.5.0",
|
|
359
359
|
"@fungi.computer/darkroom": "0.11.0",
|
|
360
360
|
"@fungi.computer/ear-tag": "0.1.0",
|
|
361
361
|
"@fungi.computer/forage": "0.3.9",
|
|
@@ -364,7 +364,7 @@
|
|
|
364
364
|
"@fungi.computer/lantern": "0.4.2",
|
|
365
365
|
"@fungi.computer/mycelium": "0.4.0",
|
|
366
366
|
"@fungi.computer/nacre": "0.6.6",
|
|
367
|
-
"@fungi.computer/parakeet": "0.11.
|
|
367
|
+
"@fungi.computer/parakeet": "0.11.37",
|
|
368
368
|
"@fungi.computer/puffball": "0.9.0",
|
|
369
369
|
"@fungi.computer/seam": "0.2.5",
|
|
370
370
|
"@fungi.computer/shiitake": "0.18.2",
|