@fungi.computer/oyster 0.19.5 → 0.19.7
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.d.ts +2 -1
- package/dist/agents.js +2 -1
- package/dist/boot-host-script.js +1 -1
- package/dist/embed-metafiles.js +2 -2
- package/dist/hello-app-script.js +1 -1
- package/dist/page-script.js +1 -1
- package/dist/standalone/app-set.d.ts +1 -1
- package/dist/standalone/computer-fleet.js +1 -0
- package/dist/standalone/computer.d.ts +22 -1
- package/dist/standalone/computer.js +30 -5
- package/dist/standalone/registry.d.ts +3 -0
- package/dist/standalone/registry.js +9 -7
- package/dist/standalone/trial-computer.d.ts +9 -0
- package/dist/standalone/trial-computer.js +75 -0
- package/dist/standalone/try-cli.d.ts +2 -0
- package/dist/standalone/try-cli.js +33 -4
- package/dist/standalone/worker.js +4 -0
- package/dist/workers-git.d.ts +4 -1
- package/dist/workers-git.js +4 -3
- package/docs/api/agents.md +5 -4
- package/docs/api/workers-git.md +6 -0
- package/package.json +12 -12
|
@@ -14,7 +14,7 @@ export type StarterApp = Readonly<{
|
|
|
14
14
|
repository: string;
|
|
15
15
|
/**
|
|
16
16
|
* What `oyster try` can do with it: `local` runs on a laptop; `needs-runtime`
|
|
17
|
-
*
|
|
17
|
+
* also needs the trial Computer runtime to have started successfully.
|
|
18
18
|
*/
|
|
19
19
|
trial: "local" | "needs-runtime";
|
|
20
20
|
}>;
|
|
@@ -20,6 +20,8 @@ import { type WorkflowGitStepEnv } from "./workflow-binding.js";
|
|
|
20
20
|
/** Native bindings selected by the standalone composition, never by an App. */
|
|
21
21
|
export type StandaloneComputerEnv = ComputerEnv & Pick<OysterWorkerEnv, "RELEASES"> & Readonly<{
|
|
22
22
|
OYSTER_COMPUTER_ID: string;
|
|
23
|
+
/** Local trials offer attached machines rather than hosted containers. */
|
|
24
|
+
OYSTER_COMPUTER_BACKEND?: "local";
|
|
23
25
|
COMPUTER: DurableObjectNamespace<ComputerDO>;
|
|
24
26
|
/** The registry owns installations and this Computer's App build jobs. */
|
|
25
27
|
REGISTRY: DurableObjectNamespace<StandaloneRegistry>;
|
|
@@ -37,7 +39,7 @@ export type StandaloneComputerResult = z.output<typeof listOutputSchema> | Reado
|
|
|
37
39
|
encoding: "base64";
|
|
38
40
|
truncated: boolean;
|
|
39
41
|
}> | Readonly<{
|
|
40
|
-
error: "conflict";
|
|
42
|
+
error: "conflict" | "no_runtime";
|
|
41
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>;
|
|
42
44
|
/**
|
|
43
45
|
* A port-preview listing, or the typed refusal the owner route presents with
|
|
@@ -100,8 +102,27 @@ export declare class ComputerDO extends NativeComputerDO implements ComputerFetc
|
|
|
100
102
|
};
|
|
101
103
|
/** An admitted fleet control starts exactly this Computer's hosted backend. */
|
|
102
104
|
startHostedComputer(authority: ComputerGrant): Promise<{
|
|
105
|
+
state: "running" | "starting";
|
|
106
|
+
position?: never;
|
|
107
|
+
} | {
|
|
108
|
+
state: "running" | "sleeping";
|
|
109
|
+
position?: never;
|
|
110
|
+
} | {
|
|
103
111
|
state: "running";
|
|
112
|
+
} | {
|
|
113
|
+
error: "no_runtime";
|
|
104
114
|
}>;
|
|
115
|
+
/** Runtime facts for the host's owner-admitted setup read. */
|
|
116
|
+
runtimeSetup(): {
|
|
117
|
+
terminal: "exec-only";
|
|
118
|
+
terminalReason?: undefined;
|
|
119
|
+
} | {
|
|
120
|
+
terminal: "ready";
|
|
121
|
+
terminalReason?: undefined;
|
|
122
|
+
} | {
|
|
123
|
+
terminal: "missing";
|
|
124
|
+
terminalReason: string;
|
|
125
|
+
};
|
|
105
126
|
/** Observe an admitted fleet Computer without starting its backend. */
|
|
106
127
|
readHostedComputerState(authority: ComputerGrant): Promise<{
|
|
107
128
|
state: "queued";
|
|
@@ -10,7 +10,7 @@ import { standaloneTenancy } from "./tenancy.js";
|
|
|
10
10
|
import { Base64 } from "effect/encoding";
|
|
11
11
|
import * as z from "zod";
|
|
12
12
|
import { ComputerPortConflictError, computerByteReadReplySchema, computerProcessSchema, installationProcessScope, processStartInputSchema, processStartToolInputSchema, computerCapabilities, computerToolResultSchema, readOutputSchema, } from "@fungi.computer/computer-contract";
|
|
13
|
-
import { ComputerDO as NativeComputerDO, ComputerOperationConflictError, } from "@fungi.computer/computer";
|
|
13
|
+
import { ComputerDO as NativeComputerDO, ComputerOperationConflictError, ComputerBackendUnavailableError, } from "@fungi.computer/computer";
|
|
14
14
|
import { patchInputSchema, patchOutputSchema, } from "@fungi.computer/knapsack/files-patch";
|
|
15
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";
|
|
16
16
|
import { workflowGitExecutionEnvironment, workflowGitPassGrantSchema, } from "@fungi.computer/braid/runtime";
|
|
@@ -45,7 +45,7 @@ const processStartHttpBody = processStartInputSchema.omit({
|
|
|
45
45
|
});
|
|
46
46
|
const processStartReply = z.lazy(() => z.union([
|
|
47
47
|
computerProcessSchema,
|
|
48
|
-
z.strictObject({ error: z.
|
|
48
|
+
z.strictObject({ error: z.enum(["conflict", "no_runtime"]) }),
|
|
49
49
|
]));
|
|
50
50
|
const bindingWrite = writeInputSchema.extend({
|
|
51
51
|
expectedContent: replaceInputSchema.shape.expectedContent.optional(),
|
|
@@ -225,11 +225,29 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
225
225
|
/** An admitted fleet control starts exactly this Computer's hosted backend. */
|
|
226
226
|
async startHostedComputer(authority) {
|
|
227
227
|
this.#accept(authority, "start");
|
|
228
|
+
if (this.previewBindings.OYSTER_COMPUTER_BACKEND === "local") {
|
|
229
|
+
const state = await this.#fleetLifecycle().readComputerState();
|
|
230
|
+
return state.state === "running"
|
|
231
|
+
? state
|
|
232
|
+
: { error: "no_runtime" };
|
|
233
|
+
}
|
|
228
234
|
return this.#fleetLifecycle().startHostedComputer(async (_backing, run) => {
|
|
229
235
|
this.#accept(authority, "start");
|
|
230
236
|
await run();
|
|
231
237
|
});
|
|
232
238
|
}
|
|
239
|
+
/** Runtime facts for the host's owner-admitted setup read. */
|
|
240
|
+
runtimeSetup() {
|
|
241
|
+
const backends = this.describeBackends();
|
|
242
|
+
if (backends.some((backend) => backend.kind === "local" && backend.status === "online"))
|
|
243
|
+
return { terminal: "exec-only" };
|
|
244
|
+
if (backends.some((backend) => backend.kind !== "local"))
|
|
245
|
+
return { terminal: "ready" };
|
|
246
|
+
return {
|
|
247
|
+
terminal: "missing",
|
|
248
|
+
terminalReason: "No Computer runtime is connected. Restart oyster try on a machine with a supported Workspace sandbox.",
|
|
249
|
+
};
|
|
250
|
+
}
|
|
233
251
|
/** Observe an admitted fleet Computer without starting its backend. */
|
|
234
252
|
readHostedComputerState(authority) {
|
|
235
253
|
this.#accept(authority, "start");
|
|
@@ -402,11 +420,14 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
402
420
|
const owner = createFleetBacking(this.state.storage);
|
|
403
421
|
owner.ensure();
|
|
404
422
|
const hostId = this.bindings.COMPUTER_VM_DEFAULT_HOST;
|
|
405
|
-
this.#backends = owner
|
|
423
|
+
this.#backends = owner
|
|
424
|
+
.computerCreated(this.#id(), [
|
|
406
425
|
hostId === undefined
|
|
407
426
|
? { kind: "platform-container" }
|
|
408
427
|
: { kind: "on-box-vm", hostId },
|
|
409
|
-
])
|
|
428
|
+
])
|
|
429
|
+
.backends.filter((backend) => this.previewBindings.OYSTER_COMPUTER_BACKEND !== "local" ||
|
|
430
|
+
backend.kind === "local");
|
|
410
431
|
return this.#backends;
|
|
411
432
|
}
|
|
412
433
|
#accept(authority, action) {
|
|
@@ -456,6 +477,8 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
456
477
|
return await this.startProcessAfterAcceptance(input, accept, executionContext);
|
|
457
478
|
}
|
|
458
479
|
catch (cause) {
|
|
480
|
+
if (cause instanceof ComputerBackendUnavailableError)
|
|
481
|
+
return { error: "no_runtime" };
|
|
459
482
|
if (cause instanceof ComputerOperationConflictError ||
|
|
460
483
|
cause instanceof ComputerPortConflictError)
|
|
461
484
|
return { error: "conflict" };
|
|
@@ -666,7 +689,9 @@ export function standaloneComputerCapabilities(env, workspace) {
|
|
|
666
689
|
...input.data,
|
|
667
690
|
requestScope: `owner:${env.OYSTER_OWNER_NAME ?? "owner"}`,
|
|
668
691
|
})));
|
|
669
|
-
return Response.json(result, {
|
|
692
|
+
return Response.json(result, {
|
|
693
|
+
status: "error" in result ? (result.error === "no_runtime" ? 503 : 409) : 200,
|
|
694
|
+
});
|
|
670
695
|
});
|
|
671
696
|
// The host wire body is `{ id }`, as on Hub; it is parsed here.
|
|
672
697
|
routes.post("/processes/kill", reach, async (context, { principal }) => {
|
|
@@ -18,6 +18,7 @@ import { type StandaloneFleetRequest } from "./computer-fleet.js";
|
|
|
18
18
|
/** What the registry needs to build Apps on the standalone's one Computer. */
|
|
19
19
|
export type StandaloneRegistryEnv = OysterWorkerEnv & Pick<ComputerEnv, "COMPUTER_VM_DEFAULT_HOST"> & StandaloneTenancyEnv & OysterGitEnv & Readonly<{
|
|
20
20
|
OYSTER_COMPUTER_ID: string;
|
|
21
|
+
OYSTER_COMPUTER_BACKEND?: "local";
|
|
21
22
|
COMPUTER: DurableObjectNamespace<ComputerDO>;
|
|
22
23
|
}>;
|
|
23
24
|
/** One repository a build clone may read, at one installation. */
|
|
@@ -111,6 +112,8 @@ export declare abstract class StandaloneRegistry extends OysterRegistry implemen
|
|
|
111
112
|
position?: never | undefined;
|
|
112
113
|
} & Disposable) | ({
|
|
113
114
|
state: "running";
|
|
115
|
+
} & Disposable) | ({
|
|
116
|
+
error: "no_runtime";
|
|
114
117
|
} & Disposable) | {
|
|
115
118
|
error: string;
|
|
116
119
|
computers?: undefined;
|
|
@@ -91,11 +91,13 @@ export class StandaloneRegistry extends OysterRegistry {
|
|
|
91
91
|
const hostId = this.#env.COMPUTER_VM_DEFAULT_HOST;
|
|
92
92
|
let created;
|
|
93
93
|
try {
|
|
94
|
-
created = this.#computers.create({ kind: "owner", id: memberId }, input.request,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
created = this.#computers.create({ kind: "owner", id: memberId }, input.request, this.#env.OYSTER_COMPUTER_BACKEND === "local"
|
|
95
|
+
? []
|
|
96
|
+
: [
|
|
97
|
+
hostId === undefined
|
|
98
|
+
? { kind: "platform-container" }
|
|
99
|
+
: { kind: "on-box-vm", hostId },
|
|
100
|
+
]).computer;
|
|
99
101
|
}
|
|
100
102
|
catch (cause) {
|
|
101
103
|
if (cause instanceof ComputerInventoryError)
|
|
@@ -173,7 +175,7 @@ export class StandaloneRegistry extends OysterRegistry {
|
|
|
173
175
|
return computer;
|
|
174
176
|
}
|
|
175
177
|
case "state":
|
|
176
|
-
if (this
|
|
178
|
+
if (!this.ownsComputer(input.computerId))
|
|
177
179
|
return null;
|
|
178
180
|
return this.#env.COMPUTER.getByName(input.computerId).readHostedComputerState({
|
|
179
181
|
computerId: input.computerId,
|
|
@@ -182,7 +184,7 @@ export class StandaloneRegistry extends OysterRegistry {
|
|
|
182
184
|
provenance: { actor: memberId },
|
|
183
185
|
});
|
|
184
186
|
case "start":
|
|
185
|
-
if (this
|
|
187
|
+
if (!this.ownsComputer(input.computerId))
|
|
186
188
|
return null;
|
|
187
189
|
return this.#env.COMPUTER.getByName(input.computerId).startHostedComputer({
|
|
188
190
|
computerId: input.computerId,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { createInterface } from "node:readline";
|
|
5
|
+
import { Option, Schema } from "effect";
|
|
6
|
+
const readRuntimeStatus = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({ kind: Schema.Literals(["online", "no_runtime"]) })));
|
|
7
|
+
class TrialComputerUnavailable extends Error {
|
|
8
|
+
code = "no_runtime";
|
|
9
|
+
constructor() {
|
|
10
|
+
super("Install the Truffle local runtime and make fungi-local-computer available on PATH, then restart oyster try.");
|
|
11
|
+
this.name = "TrialComputerUnavailable";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Local owns attachment and sandboxing; Oyster owns the CLI child's lifetime. */
|
|
15
|
+
export async function startTrialComputer(input) {
|
|
16
|
+
const folder = join(input.directory, "computer");
|
|
17
|
+
await mkdir(folder, { recursive: true });
|
|
18
|
+
input.signal.throwIfAborted();
|
|
19
|
+
const child = spawn(process.env.FUNGI_LOCAL_COMPUTER ?? "fungi-local-computer", ["attach"], {
|
|
20
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
21
|
+
});
|
|
22
|
+
const online = Promise.withResolvers();
|
|
23
|
+
const closed = Promise.withResolvers();
|
|
24
|
+
const unavailable = () => {
|
|
25
|
+
online.reject(new TrialComputerUnavailable());
|
|
26
|
+
};
|
|
27
|
+
child.once("error", unavailable);
|
|
28
|
+
child.once("close", () => {
|
|
29
|
+
unavailable();
|
|
30
|
+
closed.resolve(undefined);
|
|
31
|
+
});
|
|
32
|
+
child.stdin.on("error", unavailable);
|
|
33
|
+
const lines = createInterface({ input: child.stdout });
|
|
34
|
+
lines.on("line", (line) => {
|
|
35
|
+
const status = readRuntimeStatus(line);
|
|
36
|
+
if (Option.isSome(status) && status.value.kind === "online")
|
|
37
|
+
online.resolve(undefined);
|
|
38
|
+
else
|
|
39
|
+
unavailable();
|
|
40
|
+
});
|
|
41
|
+
const abort = () => {
|
|
42
|
+
child.kill("SIGTERM");
|
|
43
|
+
online.reject(input.signal.reason);
|
|
44
|
+
};
|
|
45
|
+
input.signal.addEventListener("abort", abort, { once: true });
|
|
46
|
+
if (input.signal.aborted)
|
|
47
|
+
abort();
|
|
48
|
+
child.stdin.end(JSON.stringify({
|
|
49
|
+
endpoint: new URL("/mcp", input.url).href,
|
|
50
|
+
computer: "workspace",
|
|
51
|
+
computerId: "workspace",
|
|
52
|
+
folderPath: folder,
|
|
53
|
+
credentialPath: join(input.directory, ".oyster", "computer.json"),
|
|
54
|
+
ownerKey: input.key,
|
|
55
|
+
}));
|
|
56
|
+
const timer = setTimeout(unavailable, 30_000);
|
|
57
|
+
const stop = async () => {
|
|
58
|
+
input.signal.removeEventListener("abort", abort);
|
|
59
|
+
child.kill("SIGTERM");
|
|
60
|
+
await closed.promise;
|
|
61
|
+
lines.close();
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
await online.promise;
|
|
65
|
+
input.signal.throwIfAborted();
|
|
66
|
+
return { stop };
|
|
67
|
+
}
|
|
68
|
+
catch (cause) {
|
|
69
|
+
await stop();
|
|
70
|
+
throw cause;
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { startTrialComputer } from "./trial-computer.js";
|
|
1
2
|
import { Cli } from "@fungi.computer/lantern";
|
|
2
3
|
import { type DesktopReadiness } from "./local-desktop.js";
|
|
3
4
|
import { type StarterApp } from "./app-set.js";
|
|
@@ -13,6 +14,7 @@ export declare function createTryCli(args: readonly string[]): Cli;
|
|
|
13
14
|
export declare function reportTryFailure(cause: unknown, ui: Cli): void;
|
|
14
15
|
/** The injectable effects of `oyster try`; tests replace them. */
|
|
15
16
|
export type TryEffects = Readonly<{
|
|
17
|
+
startComputer: typeof startTrialComputer;
|
|
16
18
|
/** Install the scaffolded project's dependencies. */
|
|
17
19
|
installDependencies: (directory: string, manager: Manager, verbose: boolean, signal: AbortSignal) => Promise<void>;
|
|
18
20
|
/** Start Oyster and resolve once it answers; `stop` ends it. */
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// is quiet by default; install and server output go to files under .oyster/
|
|
13
13
|
// and --verbose streams them instead. Piped output or CI gets plain lines.
|
|
14
14
|
import { spawn } from "node:child_process";
|
|
15
|
+
import { startTrialComputer } from "./trial-computer.js";
|
|
15
16
|
import { randomBytes } from "node:crypto";
|
|
16
17
|
import { addAbortListener } from "node:events";
|
|
17
18
|
import { finished } from "node:stream/promises";
|
|
@@ -411,6 +412,8 @@ function startWrangler(input) {
|
|
|
411
412
|
`OYSTER_OWNER_KEY:${input.key}`,
|
|
412
413
|
"--var",
|
|
413
414
|
`OYSTER_ORIGIN:${url}`,
|
|
415
|
+
"--var",
|
|
416
|
+
"OYSTER_COMPUTER_BACKEND:local",
|
|
414
417
|
], {
|
|
415
418
|
cwd: input.directory,
|
|
416
419
|
detached: process.platform !== "win32",
|
|
@@ -529,6 +532,7 @@ const realEffects = {
|
|
|
529
532
|
reportStarters: (input, installing) => reportTrialStarters({ ...input, installing }),
|
|
530
533
|
takeRetries: takeTrialRetries,
|
|
531
534
|
modelSetup: localModelSetup,
|
|
535
|
+
startComputer: startTrialComputer,
|
|
532
536
|
signInLink: startSignInLink,
|
|
533
537
|
open: openBrowser,
|
|
534
538
|
portFree,
|
|
@@ -574,6 +578,8 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
|
|
|
574
578
|
process.on("SIGINT", interrupt);
|
|
575
579
|
process.on("SIGTERM", interrupt);
|
|
576
580
|
let acquiredServer;
|
|
581
|
+
let closeComputer;
|
|
582
|
+
let computerReady = false;
|
|
577
583
|
let closeLink;
|
|
578
584
|
try {
|
|
579
585
|
if (positionals[0] === undefined &&
|
|
@@ -673,6 +679,23 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
|
|
|
673
679
|
return result;
|
|
674
680
|
});
|
|
675
681
|
};
|
|
682
|
+
await setupTask("Starting the local Computer", async () => {
|
|
683
|
+
try {
|
|
684
|
+
const computer = await effects.startComputer({
|
|
685
|
+
directory,
|
|
686
|
+
url,
|
|
687
|
+
key,
|
|
688
|
+
signal,
|
|
689
|
+
});
|
|
690
|
+
closeComputer = () => computer.stop();
|
|
691
|
+
computerReady = true;
|
|
692
|
+
}
|
|
693
|
+
catch (cause) {
|
|
694
|
+
if (signal.aborted)
|
|
695
|
+
throw cause;
|
|
696
|
+
ui.warn(`The Computer runtime is unavailable (${innermostError(cause).message}).`, "Files remain available. Fix the runtime and restart oyster try to run commands.");
|
|
697
|
+
}
|
|
698
|
+
});
|
|
676
699
|
const desktop = await setupTask(fresh
|
|
677
700
|
? "Installing Hello and building Tourtois"
|
|
678
701
|
: "Installing Hello and checking Tourtois", async () => {
|
|
@@ -839,7 +862,7 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
|
|
|
839
862
|
});
|
|
840
863
|
ui.warn(`${name} couldn't be installed: ${innermostError(settled.cause).message}`, `Retry it from the desktop, or run \`${retry}\` again.`);
|
|
841
864
|
}
|
|
842
|
-
else if (app.trial === "needs-runtime") {
|
|
865
|
+
else if (app.trial === "needs-runtime" && !computerReady) {
|
|
843
866
|
pending.set(name, {
|
|
844
867
|
installationId: name,
|
|
845
868
|
displayName: app.displayName,
|
|
@@ -917,10 +940,16 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
|
|
|
917
940
|
finally {
|
|
918
941
|
try {
|
|
919
942
|
const cleanup = async () => {
|
|
920
|
-
const
|
|
921
|
-
Promise.resolve().then(() =>
|
|
922
|
-
Promise.resolve().then(() => acquiredServer?.stop()),
|
|
943
|
+
const computerStopped = await Promise.allSettled([
|
|
944
|
+
Promise.resolve().then(() => closeComputer?.()),
|
|
923
945
|
]);
|
|
946
|
+
const outcomes = [
|
|
947
|
+
...computerStopped,
|
|
948
|
+
...(await Promise.allSettled([
|
|
949
|
+
Promise.resolve().then(() => closeLink?.()),
|
|
950
|
+
Promise.resolve().then(() => acquiredServer?.stop()),
|
|
951
|
+
])),
|
|
952
|
+
];
|
|
924
953
|
if (outcomes.some((result) => result.status === "rejected"))
|
|
925
954
|
throw new TryError("Oyster cleanup did not complete.", `Check ${join(directory, logFile)} and the local listener before running \`${retry}\` again.`);
|
|
926
955
|
};
|
|
@@ -68,6 +68,10 @@ const standaloneRoot = (selectComputer) => {
|
|
|
68
68
|
}),
|
|
69
69
|
homeInstallationId: (env) => env.OYSTER_HOME_INSTALLATION,
|
|
70
70
|
agents: standaloneAgents,
|
|
71
|
+
computerSetup: async (env, scope) => {
|
|
72
|
+
const id = await tenantRegistry(env, scope).selectedComputer();
|
|
73
|
+
return env.COMPUTER.getByName(id).runtimeSetup();
|
|
74
|
+
},
|
|
71
75
|
permissionResources: (env, scope) => standalonePermissionResources({
|
|
72
76
|
// Acquire the registry stub only when owner inventory is requested.
|
|
73
77
|
computerFleet: (memberId, request) => tenantRegistry(env, scope).computerFleet(memberId, request),
|
package/dist/workers-git.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AppSetup } from "@fungi.computer/agar";
|
|
1
2
|
import { type OysterTenancy, type ResolvedTenant, type TenantScope } from "./tenant.js";
|
|
2
3
|
/**
|
|
3
4
|
* Cloudflare adapters for git Apps on a standalone Oyster: the GIT binding
|
|
@@ -193,6 +194,8 @@ export declare abstract class OysterGitInstance<Env extends OysterGitWorkerEnv =
|
|
|
193
194
|
export type OysterGitWorkerOptions<Env extends OysterGitWorkerEnv> = Readonly<{
|
|
194
195
|
/** Picker facts through this host's existing, owner-admitted directories. */
|
|
195
196
|
permissionResources?: (env: Env, scope: TenantScope) => NonNullable<OysterHost["permissionResources"]>;
|
|
197
|
+
/** Read the selected Computer's live runtime facts for the owner setup surface. */
|
|
198
|
+
computerSetup?: (env: Env, scope: TenantScope) => Promise<Pick<AppSetup, "terminal" | "terminalReason">>;
|
|
196
199
|
/** Host-owned fleet control, admitted on every invocation by its durable owner. */
|
|
197
200
|
computerControl?: (env: Env, scope: TenantScope) => NonNullable<OysterHost["computerControl"]>;
|
|
198
201
|
/** Workflow controls supplied by the host's existing run owner. */
|
|
@@ -285,6 +288,6 @@ export declare function oysterGitWorkerHost<Env extends OysterGitWorkerEnv>(env:
|
|
|
285
288
|
* routes, and Agent approval and MCP server custody. The host and the
|
|
286
289
|
* authorization law both compose it here.
|
|
287
290
|
*/
|
|
288
|
-
export declare function oysterGitOwnerRoutes(env: OysterGitEnv, scope: TenantScope, hostOwnerRoutes: Routes<OysterEnv> | undefined, agents: OysterAgents | undefined): Routes<OysterEnv>;
|
|
291
|
+
export declare function oysterGitOwnerRoutes(env: OysterGitEnv, scope: TenantScope, hostOwnerRoutes: Routes<OysterEnv> | undefined, agents: OysterAgents | undefined, computerSetup?: () => Promise<Pick<AppSetup, "terminal" | "terminalReason">>): Routes<OysterEnv>;
|
|
289
292
|
/** Deploy the MCP owner from the same root as createOysterGitWorker. */
|
|
290
293
|
export declare function createOysterGitMcpOwner<Env extends OysterGitWorkerEnv>(root: OysterGitRoot<Env>): new (ctx: DurableObjectState, env: Env) => import("./mcp-owner.js").OysterMcpOwner<Env>;
|
package/dist/workers-git.js
CHANGED
|
@@ -1135,7 +1135,8 @@ export async function oysterGitWorkerHost(env, options, selected, request) {
|
|
|
1135
1135
|
if (options.buildGitPass !== undefined)
|
|
1136
1136
|
gitOptions = { ...gitOptions, buildGitPass: options.buildGitPass };
|
|
1137
1137
|
const git = oysterWorkerGit(env, gitOptions);
|
|
1138
|
-
const
|
|
1138
|
+
const computerSetup = options.computerSetup;
|
|
1139
|
+
const ownerRoutes = oysterGitOwnerRoutes(env, scope, options.ownerRoutes?.(env, scope), agents, computerSetup === undefined ? undefined : () => computerSetup(env, scope));
|
|
1139
1140
|
let host = {
|
|
1140
1141
|
...base,
|
|
1141
1142
|
capabilities,
|
|
@@ -1163,14 +1164,14 @@ export async function oysterGitWorkerHost(env, options, selected, request) {
|
|
|
1163
1164
|
* routes, and Agent approval and MCP server custody. The host and the
|
|
1164
1165
|
* authorization law both compose it here.
|
|
1165
1166
|
*/
|
|
1166
|
-
export function oysterGitOwnerRoutes(env, scope, hostOwnerRoutes, agents) {
|
|
1167
|
+
export function oysterGitOwnerRoutes(env, scope, hostOwnerRoutes, agents, computerSetup) {
|
|
1167
1168
|
const ownerRoutes = gitAdminRoutes(env, scope);
|
|
1168
1169
|
if (hostOwnerRoutes !== undefined)
|
|
1169
1170
|
ownerRoutes.include(hostOwnerRoutes);
|
|
1170
1171
|
if (agents !== undefined) {
|
|
1171
1172
|
ownerRoutes.include(agentApprovalRoutes(agents));
|
|
1172
1173
|
ownerRoutes.include(connectionRoutes(agents));
|
|
1173
|
-
ownerRoutes.include(modelKeyRoutes(agents));
|
|
1174
|
+
ownerRoutes.include(modelKeyRoutes(agents, computerSetup));
|
|
1174
1175
|
}
|
|
1175
1176
|
return ownerRoutes;
|
|
1176
1177
|
}
|
package/docs/api/agents.md
CHANGED
|
@@ -570,7 +570,7 @@ Host-owned direct approval under the admitted owner; never an App capability.
|
|
|
570
570
|
### modelKeyRoutes()
|
|
571
571
|
|
|
572
572
|
```ts
|
|
573
|
-
function modelKeyRoutes(agents): Routes<OysterEnv>;
|
|
573
|
+
function modelKeyRoutes(agents, computerSetup?): Routes<OysterEnv>;
|
|
574
574
|
```
|
|
575
575
|
|
|
576
576
|
Host-owned model-key custody for the owner directly. A key goes in once and
|
|
@@ -578,9 +578,10 @@ never comes back out; listings carry provider, label and times only.
|
|
|
578
578
|
|
|
579
579
|
#### Parameters
|
|
580
580
|
|
|
581
|
-
| Parameter
|
|
582
|
-
|
|
|
583
|
-
| `agents`
|
|
581
|
+
| Parameter | Type |
|
|
582
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
583
|
+
| `agents` | [`OysterAgents`](#oysteragents) |
|
|
584
|
+
| `computerSetup?` | () => `Promise`\<`Pick`\<`Readonly`\<\{ `models`: `SetupState`; `media`: `SetupState`; `git`: `SetupState`; `terminal`: `"unknown"` \| `"ready"` \| `"missing"` \| `"exec-only"`; `terminalReason?`: `string`; \}\>, `"terminal"` \| `"terminalReason"`\>\> |
|
|
584
585
|
|
|
585
586
|
#### Returns
|
|
586
587
|
|
package/docs/api/workers-git.md
CHANGED
|
@@ -1311,6 +1311,10 @@ type OysterGitWorkerOptions<Env> = Readonly<{
|
|
|
1311
1311
|
env,
|
|
1312
1312
|
scope,
|
|
1313
1313
|
) => NonNullable<OysterHost["permissionResources"]>;
|
|
1314
|
+
computerSetup?: (
|
|
1315
|
+
env,
|
|
1316
|
+
scope,
|
|
1317
|
+
) => Promise<Pick<AppSetup, "terminal" | "terminalReason">>;
|
|
1314
1318
|
computerControl?: (env, scope) => NonNullable<OysterHost["computerControl"]>;
|
|
1315
1319
|
workflows?: (env, host) => NonNullable<OysterHost["workflows"]>;
|
|
1316
1320
|
tenancy: (env) => OysterTenancy;
|
|
@@ -1718,6 +1722,7 @@ function oysterGitOwnerRoutes(
|
|
|
1718
1722
|
scope,
|
|
1719
1723
|
hostOwnerRoutes,
|
|
1720
1724
|
agents,
|
|
1725
|
+
computerSetup?,
|
|
1721
1726
|
): Routes<OysterEnv>;
|
|
1722
1727
|
```
|
|
1723
1728
|
|
|
@@ -1733,6 +1738,7 @@ both compose it here.
|
|
|
1733
1738
|
| `scope` | [`TenantScope`](tenant.md#tenantscope) |
|
|
1734
1739
|
| `hostOwnerRoutes` | \| [`Routes`](authorization.md#routes)\<[`OysterEnv`](host.md#oysterenv)\> \| `undefined` |
|
|
1735
1740
|
| `agents` | \| `Readonly`\<\{ `list`: `Promise`\<readonly `Readonly`\<\{ `agentId`: `string`; `name`: `string`; `avatar`: \{ `v`: `1`; `character`: `"mushroom"` \| `"cat"` \| `"burger"`; `appearance`: `z.ZodRecord`\<`z.ZodString`, `z.ZodUnion`\<readonly ...\>\>; `expression`: `string`; `renderStyle`: \| `"plain"` \| `"pencil"` \| `"manga"` \| `"riso"` \| `"halftone"` \| `"blueprint"` \| `"crt"` \| `"watercolor"`; \}; `sessionOperations`: readonly (`"agent.manage"` \| `"agent.read"` \| `"agent.send"`)[]; \}\>[]\>; `ensureStarter`: `Promise`\<[`StarterOutcome`](agents.md#starteroutcome)\>; `setArchived`: `Promise`\< \| `Readonly`\<\{ `archived`: `boolean`; `revision`: `number`; \}\> \| `Readonly`\<\{ `error`: \| `"archived"` \| `"pending"` \| `"not_found"` \| `"running"` \| `"not_granted"` \| `"self"` \| `"not_creator"` \| `"unreadable"`; `message?`: `string`; `archived?`: `boolean`; `revision?`: `number`; \}\>\>; `create`: `Promise`\<`Readonly`\<\{ `agentId`: `string`; `name`: `string`; `avatar`: \{ `v`: `1`; `character`: `"mushroom"` \| `"cat"` \| `"burger"`; `appearance`: `z.ZodRecord`\<`z.ZodString`, `z.ZodUnion`\<readonly \[..., ..., ...\]\>\>; `expression`: `string`; `renderStyle`: \| `"plain"` \| `"pencil"` \| `"manga"` \| `"riso"` \| `"halftone"` \| `"blueprint"` \| `"crt"` \| `"watercolor"`; \}; `sessionOperations`: readonly (`"agent.manage"` \| `"agent.read"` \| `"agent.send"`)[]; \}\>\>; `rename`: `Promise`\< \| `Readonly`\<\{ `agentId`: `string`; `name`: `string`; `avatar`: \{ `v`: `1`; `character`: `"mushroom"` \| `"cat"` \| `"burger"`; `appearance`: `z.ZodRecord`\<`z.ZodString`, `z.ZodUnion`\<readonly ...\>\>; `expression`: `string`; `renderStyle`: \| `"plain"` \| `"pencil"` \| `"manga"` \| `"riso"` \| `"halftone"` \| `"blueprint"` \| `"crt"` \| `"watercolor"`; \}; `sessionOperations`: readonly (`"agent.manage"` \| `"agent.read"` \| `"agent.send"`)[]; \}\> \| `Readonly`\<\{ `error`: `"not_found"` \| `"not_granted"` \| `"name_taken"`; \}\>\>; `setAvatar`: `Promise`\< \| `Readonly`\<\{ `agentId`: `string`; `name`: `string`; `avatar`: \{ `v`: `1`; `character`: `"mushroom"` \| `"cat"` \| `"burger"`; `appearance`: `z.ZodRecord`\<`z.ZodString`, `z.ZodUnion`\<readonly ...\>\>; `expression`: `string`; `renderStyle`: \| `"plain"` \| `"pencil"` \| `"manga"` \| `"riso"` \| `"halftone"` \| `"blueprint"` \| `"crt"` \| `"watercolor"`; \}; `sessionOperations`: readonly (`"agent.manage"` \| `"agent.read"` \| `"agent.send"`)[]; \}\> \| `Readonly`\<\{ `error`: `"not_found"` \| `"not_granted"`; \}\>\>; `readModelChoice`: `Promise`\< \| \{ `keySource`: `"workers-ai"` \| `"ai-gateway"` \| `"byok"`; `model`: \{ `providerId`: `string`; `modelId`: `string`; `reasoning?`: `"max"` \| `"low"` \| `"medium"` \| `"high"` \| `"minimal"` \| `"xhigh"`; \}; `keyId?`: `string`; \} \| `null`\>; `decodeModelChoice`: \| \{ `keySource`: `"workers-ai"` \| `"ai-gateway"` \| `"byok"`; `model`: \{ `providerId`: `string`; `modelId`: `string`; `reasoning?`: `"max"` \| `"low"` \| `"medium"` \| `"high"` \| `"minimal"` \| `"xhigh"`; \}; `keyId?`: `string`; \} \| `null`; `setModelChoice`: `Promise`\< \| \{ `keySource`: `"workers-ai"` \| `"ai-gateway"` \| `"byok"`; `model`: \{ `providerId`: `string`; `modelId`: `string`; `reasoning?`: `"max"` \| `"low"` \| `"medium"` \| `"high"` \| `"minimal"` \| `"xhigh"`; \}; `keyId?`: `string`; \} \| `Readonly`\<\{ `error`: \| `"not_found"` \| `"not_granted"` \| [`AgentModelRefusal`](agents.md#agentmodelrefusal); \}\>\>; `policyStatus`: `Promise`\< \| `Readonly`\<\{ `status`: `"pending"` \| `"approved"`; `revision`: `string`; \}\> \| `null`\>; `appToolPolicy`: `Promise`\< \| \{ `level`: `"read"` \| `"write"`; `revision`: `string`; `grantedBy`: `string`; \} \| `null`\>; `policyRevision`: `Promise`\<`string` \| `null`\>; `approveAppToolPolicy`: `Promise`\< \| \{ `level`: `"read"` \| `"write"`; `revision`: `string`; `grantedBy`: `string`; \} \| `Readonly`\<\{ `status`: `"pending"`; `revision`: `string`; \}\> \| `Readonly`\<\{ `error`: `"not_found"` \| `"not_granted"` \| `"revision_conflict"`; \}\>\>; `setup`: `Promise`\<`Readonly`\<\{ `models`: `"ready"` \| `"missing"`; `media`: `"ready"` \| `"missing"`; \}\>\>; `modelKeys`: `Promise`\<readonly `Readonly`\<\{ `keyId`: `string`; `provider`: `"anthropic"` \| `"openai"` \| `"openrouter"` \| `"openai-compatible"`; `label`: `string`; `createdAt`: `number`; `validatedAt`: `number`; \}\>[]\>; `sealModelKey`: `Promise`\< \| `Readonly`\<\{ `keyId`: `string`; `provider`: `"anthropic"` \| `"openai"` \| `"openrouter"` \| `"openai-compatible"`; `label`: `string`; `createdAt`: `number`; `validatedAt`: `number`; \}\> \| `Readonly`\<\{ `error`: [`ModelKeyRefusal`](agents.md#modelkeyrefusal); \}\>\>; `removeModelKey`: `Promise`\<`"deleted"` \| `"absent"`\>; `connections`: `Promise`\<readonly `Readonly`\<\{ `connectionId`: `string`; `name`: `string`; `label`: `string`; `kind`: `"mcp"` \| `"openapi"`; `url`: `string`; `auth`: `"none"` \| `"token"` \| `"oauth"`; `state`: `"pending"` \| `"connected"` \| `"reconnect_required"`; `grants`: readonly `Readonly`\<\{ `agentId`: `string`; `access`: [`ConnectionAccess`](agents.md#connectionaccess); \}\>[]; \}\>[]\>; `addConnection`: `Promise`\< \| `Readonly`\<\{ `connectionId`: `string`; `authorizeUrl`: `string` \| `null`; \}\> \| `Readonly`\<\{ `error`: `"limit"` \| `"not_found"` \| `"duplicate_name"` \| `"invalid_endpoint"`; \}\>\>; `grantConnection`: `Promise`\< \| `Readonly`\<\{ `error`: `"limit"` \| `"not_found"` \| `"duplicate_name"` \| `"invalid_endpoint"`; \}\> \| `Readonly`\<\{ `ok`: `true`; \}\>\>; `ungrantConnection`: `Promise`\<`boolean`\>; `removeConnection`: `Promise`\<`boolean`\>; `connectionTools`: `Promise`\< \| readonly `string`[] \| `Readonly`\<\{ `error`: `"limit"` \| `"not_found"` \| `"duplicate_name"` \| `"invalid_endpoint"`; \}\>\>; `completeMcpConnection`: `Promise`\< \| `Readonly`\<\{ `ok`: `true`; \}\> \| `Readonly`\<\{ `error`: `string`; \}\>\>; `mcpCallbackUrl`: `string`; `fetch`: `Promise`\<`Response` \| `null`\>; `inbox`: `Promise`\<`Readonly`\<\{ `items`: readonly ( \| \{ `agentId`: `string`; `sessionId`: `string`; `title`: `string`; `triggerId?`: `string`; `createdAt`: `number`; `lastActivityAt`: `number`; `settledAt?`: `number`; `visitedAt?`: `number`; `state`: `"running"` \| `"done"` \| `"errored"` \| `"needs_you"`; \} \| \{ `agentId`: `string`; `sessionId`: `string`; `state`: `"unavailable"`; \} \| \{ `kind`: `"workflow-review"`; `key`: \{ `runId`: `string`; `nodeId`: `string`; `iteration`: `string`; \}; `installationId`: `string`; `workflowId`: `string` \| `null`; `workflowTitle`: `string`; `reviewTitle`: `string`; `reviewers`: `"owners"` \| `"runner"`; `show`: readonly `Json`[]; `choices?`: readonly ...[]; `openedAt`: `number`; `expiresAt`: `number`; `state`: `"pending"` \| `"delivered"` \| `"answered"` \| `"timed_out"` \| `"closed"`; \})[]; `revision`: `number`; \}\>\>; `revision`: `Promise`\<`number`\>; `visit`: `Promise`\<`boolean`\>; \}\> \| `undefined` |
|
|
1741
|
+
| `computerSetup?` | () => `Promise`\<`Pick`\<`Readonly`\<\{ `models`: `SetupState`; `media`: `SetupState`; `git`: `SetupState`; `terminal`: `"unknown"` \| `"ready"` \| `"missing"` \| `"exec-only"`; `terminalReason?`: `string`; \}\>, `"terminal"` \| `"terminalReason"`\>\> |
|
|
1736
1742
|
|
|
1737
1743
|
#### Returns
|
|
1738
1744
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/oyster",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.7",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Run your own Apps on Cloudflare Workers or celld: installable App Releases, each with its own Durable Object, SQLite database and declared bindings",
|
|
6
6
|
"type": "module",
|
|
@@ -328,37 +328,37 @@
|
|
|
328
328
|
"dependencies": {
|
|
329
329
|
"@cfworker/json-schema": "4.1.1",
|
|
330
330
|
"@earendil-works/pi-ai": "1.3.0",
|
|
331
|
-
"@fungi.computer/agar": "0.9.
|
|
331
|
+
"@fungi.computer/agar": "0.9.1",
|
|
332
332
|
"@fungi.computer/bird-dog": "0.3.6",
|
|
333
|
-
"@fungi.computer/braid": "0.4.
|
|
333
|
+
"@fungi.computer/braid": "0.4.8",
|
|
334
334
|
"@fungi.computer/burrow": "0.2.1",
|
|
335
335
|
"@fungi.computer/cairn": "0.1.0",
|
|
336
336
|
"@fungi.computer/capnweb": "0.12.0-fungi.0",
|
|
337
337
|
"@fungi.computer/caps": "0.10.1",
|
|
338
338
|
"@fungi.computer/carrier": "0.2.4",
|
|
339
|
-
"@fungi.computer/computer": "0.8.
|
|
339
|
+
"@fungi.computer/computer": "0.8.2",
|
|
340
340
|
"@fungi.computer/computer-contract": "0.1.0",
|
|
341
|
-
"@fungi.computer/darkroom": "0.5.
|
|
341
|
+
"@fungi.computer/darkroom": "0.5.6",
|
|
342
342
|
"@fungi.computer/ear-tag": "0.1.0",
|
|
343
343
|
"@fungi.computer/forage": "0.3.5",
|
|
344
344
|
"@fungi.computer/gills": "0.3.0",
|
|
345
345
|
"@fungi.computer/knapsack": "0.4.9",
|
|
346
346
|
"@fungi.computer/lantern": "0.4.2",
|
|
347
347
|
"@fungi.computer/mycelium": "0.3.8",
|
|
348
|
-
"@fungi.computer/nacre": "0.4.
|
|
349
|
-
"@fungi.computer/parakeet": "0.11.
|
|
348
|
+
"@fungi.computer/nacre": "0.4.4",
|
|
349
|
+
"@fungi.computer/parakeet": "0.11.4",
|
|
350
350
|
"@fungi.computer/puffball": "0.5.5",
|
|
351
351
|
"@fungi.computer/seam": "0.2.5",
|
|
352
|
-
"@fungi.computer/shiitake": "0.12.
|
|
353
|
-
"@fungi.computer/shiitake-extensions": "0.6.
|
|
352
|
+
"@fungi.computer/shiitake": "0.12.4",
|
|
353
|
+
"@fungi.computer/shiitake-extensions": "0.6.11",
|
|
354
354
|
"@fungi.computer/sigils": "0.3.0",
|
|
355
355
|
"@fungi.computer/sprite": "0.2.2",
|
|
356
356
|
"@fungi.computer/sprite-zdog": "0.3.2",
|
|
357
357
|
"@fungi.computer/veil": "0.6.5",
|
|
358
358
|
"@fungi.computer/watchdog": "0.1.3",
|
|
359
359
|
"@fungi.computer/whistle": "0.3.0",
|
|
360
|
-
"@fungi.computer/workflows-wire": "0.4.
|
|
361
|
-
"@fungi.computer/zookeeper": "0.0.
|
|
360
|
+
"@fungi.computer/workflows-wire": "0.4.8",
|
|
361
|
+
"@fungi.computer/zookeeper": "0.0.18",
|
|
362
362
|
"@modelcontextprotocol/server": "2.0.0",
|
|
363
363
|
"@pnpm/lockfile.fs": "1100.2.13",
|
|
364
364
|
"@pnpm/lockfile.pruner": "1100.0.27",
|
|
@@ -370,9 +370,9 @@
|
|
|
370
370
|
"jose": "6.2.11",
|
|
371
371
|
"mime": "4.1.0",
|
|
372
372
|
"oauth4webapi": "3.8.8",
|
|
373
|
+
"parse5": "8.0.1",
|
|
373
374
|
"path-to-regexp": "8.4.2",
|
|
374
375
|
"strip-ansi": "7.2.0",
|
|
375
|
-
"parse5": "8.0.1",
|
|
376
376
|
"zod": "4.4.3"
|
|
377
377
|
},
|
|
378
378
|
"license": "MIT",
|