@fungi.computer/oyster 0.8.2 → 0.9.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/README.md +21 -17
- package/dist/agents.js +3 -0
- package/dist/apps/catalog.d.ts +11 -0
- package/dist/apps/catalog.js +1 -0
- package/dist/apps/gate.d.ts +2 -2
- package/dist/apps/installation.d.ts +7 -7
- package/dist/apps/permissions.d.ts +5 -5
- package/dist/boot-host-script.js +1 -1
- package/dist/build/candidate-cli.mjs +1 -0
- package/dist/host.js +11 -4
- package/dist/installation-client.d.ts +6 -5
- package/dist/installation-client.js +21 -17
- package/dist/installation-execution.js +41 -8
- package/dist/installation-operations.d.ts +30 -8
- package/dist/installation-operations.js +122 -24
- package/dist/instance-refusal.d.ts +4 -2
- package/dist/instance-refusal.js +5 -1
- package/dist/mcp.d.ts +4 -2
- package/dist/page/mount.d.ts +8 -1
- package/dist/page/mount.js +72 -6
- package/dist/page-script.js +3 -3
- package/dist/standalone/app-set.js +6 -7
- package/dist/standalone/computer-fleet.d.ts +8 -2
- package/dist/standalone/computer-fleet.js +21 -17
- package/dist/standalone/registry.js +9 -0
- package/dist/standalone/workflow-host.d.ts +5 -5
- package/dist/standalone/workflow-trigger-host.d.ts +1 -1
- package/docs/api/apps.md +31 -31
- package/docs/api/host.md +157 -0
- package/docs/api/mcp.md +6 -4
- package/docs/api/page/mount.md +6 -1
- package/docs/api/workers.md +3 -3
- package/docs/site/agent-quickstart.mdx +4 -2
- package/package.json +16 -16
package/dist/instance-refusal.js
CHANGED
|
@@ -12,8 +12,12 @@ export function instanceRefusalStatus(code) {
|
|
|
12
12
|
return 422;
|
|
13
13
|
return conflicts.has(code) ? 409 : 403;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/** The host-authored settlement for an installation that changed nothing. */
|
|
16
|
+
export const installationNotAppliedMessage = "The new release was not applied: Oyster could not prepare it. The previous release is still installed; install again to retry.";
|
|
17
|
+
/** Only closed host-authored reasons produce a caller-facing message. */
|
|
16
18
|
export function instanceRefusalBody(code) {
|
|
19
|
+
if (code === "installation_not_applied")
|
|
20
|
+
return { error: code, message: installationNotAppliedMessage };
|
|
17
21
|
const boot = bootFailureSchema.safeParse(code);
|
|
18
22
|
return boot.success
|
|
19
23
|
? { error: boot.data, message: new BootGateError(boot.data).message }
|
package/dist/mcp.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
83
83
|
running: "running";
|
|
84
84
|
sleeping: "sleeping";
|
|
85
85
|
starting: "starting";
|
|
86
|
+
start_failed: "start_failed";
|
|
86
87
|
}>;
|
|
87
88
|
}, z.core.$strict>, z.ZodObject<{
|
|
88
89
|
state: z.ZodLiteral<"queued">;
|
|
@@ -90,7 +91,7 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
90
91
|
}, z.core.$strict>], "state">;
|
|
91
92
|
/** Return liveness without waking the runtime. */
|
|
92
93
|
execute: (input: z.output<typeof fleetComputerId>, context: InvocationContext) => Promise<{
|
|
93
|
-
state: "running" | "sleeping" | "starting";
|
|
94
|
+
state: "running" | "sleeping" | "starting" | "start_failed";
|
|
94
95
|
} | {
|
|
95
96
|
state: "queued";
|
|
96
97
|
position: number;
|
|
@@ -107,6 +108,7 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
107
108
|
running: "running";
|
|
108
109
|
sleeping: "sleeping";
|
|
109
110
|
starting: "starting";
|
|
111
|
+
start_failed: "start_failed";
|
|
110
112
|
}>;
|
|
111
113
|
}, z.core.$strict>, z.ZodObject<{
|
|
112
114
|
state: z.ZodLiteral<"queued">;
|
|
@@ -114,7 +116,7 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
114
116
|
}, z.core.$strict>], "state">;
|
|
115
117
|
/** Admit and start this Computer. */
|
|
116
118
|
execute: (input: z.output<typeof fleetComputerId>, context: InvocationContext) => Promise<{
|
|
117
|
-
state: "running" | "sleeping" | "starting";
|
|
119
|
+
state: "running" | "sleeping" | "starting" | "start_failed";
|
|
118
120
|
} | {
|
|
119
121
|
state: "queued";
|
|
120
122
|
position: number;
|
package/dist/page/mount.d.ts
CHANGED
|
@@ -160,7 +160,14 @@ export type OysterAppConnectionOptions = Readonly<{
|
|
|
160
160
|
reservedChords: readonly import("@fungi.computer/agar/host").AppHostReservedChord[];
|
|
161
161
|
theme: string;
|
|
162
162
|
}>;
|
|
163
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Connect a child or home App using the same admitted Oyster slot handles.
|
|
165
|
+
* The host navigates the App's frame (`config.uiUrl`) only once it listens for
|
|
166
|
+
* the App's ready signal, so slow capability resolution on a cold Oyster can
|
|
167
|
+
* never outlast that signal. Opening is bounded: the capabilities and the
|
|
168
|
+
* document get the shared cold-document budget, and the handshake after the
|
|
169
|
+
* document loads gets the App's own ready window.
|
|
170
|
+
*/
|
|
164
171
|
export declare function connectOysterApp(options: OysterAppConnectionOptions): Promise<AppHost>;
|
|
165
172
|
export { oysterStorageHandle } from "./storage.js";
|
|
166
173
|
export { appSandbox } from "../app-sandbox.js";
|
package/dist/page/mount.js
CHANGED
|
@@ -2,6 +2,7 @@ import { appOpenInputSchema, appsCall, appsOpen, } from "@fungi.computer/agar/ap
|
|
|
2
2
|
import { appApiMethodNameSchema } from "@fungi.computer/puffball/app";
|
|
3
3
|
import { appIdSchema } from "@fungi.computer/puffball/effect";
|
|
4
4
|
import { createBrowserActionHandler } from "@fungi.computer/nacre";
|
|
5
|
+
import { APP_SURFACE_DOCUMENT_TIMEOUT_MS } from "@fungi.computer/nacre/window-manager";
|
|
5
6
|
import { createAppSurfaceCommandHost } from "@fungi.computer/nacre/command-host";
|
|
6
7
|
// App page: mounts one installed App's sandboxed frame and gives it the
|
|
7
8
|
// capabilities this Oyster host provides. Bundled into `shellScript`.
|
|
@@ -251,20 +252,83 @@ export async function mountOysterPage() {
|
|
|
251
252
|
},
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
|
-
/**
|
|
255
|
+
/** The App's own ready window: once its document loads, it announces itself for 10 s. */
|
|
256
|
+
const APP_CONNECT_TIMEOUT_MS = 10_000;
|
|
257
|
+
/** Resolve `work`, or reject with the signal's reason once it aborts. */
|
|
258
|
+
function untilAborted(work, signal) {
|
|
259
|
+
const stopped = () => signal.reason instanceof Error
|
|
260
|
+
? signal.reason
|
|
261
|
+
: new Error("App open was stopped", { cause: signal.reason });
|
|
262
|
+
if (signal.aborted)
|
|
263
|
+
return Promise.reject(stopped());
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
const stop = () => {
|
|
266
|
+
reject(stopped());
|
|
267
|
+
};
|
|
268
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
269
|
+
work.then((value) => {
|
|
270
|
+
signal.removeEventListener("abort", stop);
|
|
271
|
+
resolve(value);
|
|
272
|
+
}, (cause) => {
|
|
273
|
+
signal.removeEventListener("abort", stop);
|
|
274
|
+
reject(cause instanceof Error
|
|
275
|
+
? cause
|
|
276
|
+
: new Error("App open failed", { cause }));
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Connect a child or home App using the same admitted Oyster slot handles.
|
|
282
|
+
* The host navigates the App's frame (`config.uiUrl`) only once it listens for
|
|
283
|
+
* the App's ready signal, so slow capability resolution on a cold Oyster can
|
|
284
|
+
* never outlast that signal. Opening is bounded: the capabilities and the
|
|
285
|
+
* document get the shared cold-document budget, and the handshake after the
|
|
286
|
+
* document loads gets the App's own ready window.
|
|
287
|
+
*/
|
|
255
288
|
export async function connectOysterApp(options) {
|
|
256
289
|
const { config, frame } = options;
|
|
257
290
|
if (frame.contentWindow === null)
|
|
258
291
|
throw new Error("App frame is unavailable");
|
|
259
|
-
const
|
|
292
|
+
const deadline = new AbortController();
|
|
293
|
+
const expire = () => {
|
|
294
|
+
deadline.abort();
|
|
295
|
+
};
|
|
296
|
+
let timer = setTimeout(expire, APP_SURFACE_DOCUMENT_TIMEOUT_MS);
|
|
297
|
+
const opening = AbortSignal.any([options.signal, deadline.signal]);
|
|
298
|
+
const documentLoaded = () => {
|
|
299
|
+
clearTimeout(timer);
|
|
300
|
+
timer = setTimeout(expire, APP_CONNECT_TIMEOUT_MS);
|
|
301
|
+
};
|
|
302
|
+
try {
|
|
303
|
+
return await openOysterApp(options, frame.contentWindow, opening, () => {
|
|
304
|
+
frame.addEventListener("load", documentLoaded, { once: true });
|
|
305
|
+
frame.src = config.uiUrl;
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
catch (cause) {
|
|
309
|
+
if (deadline.signal.aborted && !options.signal.aborted)
|
|
310
|
+
throw new AppError("App did not open in time", {
|
|
311
|
+
code: "TIMEOUT",
|
|
312
|
+
retryable: true,
|
|
313
|
+
});
|
|
314
|
+
throw cause;
|
|
315
|
+
}
|
|
316
|
+
finally {
|
|
317
|
+
clearTimeout(timer);
|
|
318
|
+
frame.removeEventListener("load", documentLoaded);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
async function openOysterApp(options, appWindow, opening, navigate) {
|
|
322
|
+
const { config, frame } = options;
|
|
323
|
+
const capabilities = await untilAborted(oysterAppCapabilities(options), opening);
|
|
260
324
|
const agents = agentDirectory(capabilities);
|
|
261
325
|
const releaseBrowser = options.agentBrowser.mount(frame, options.agentCommands);
|
|
262
326
|
options.signal.addEventListener("abort", releaseBrowser, { once: true });
|
|
263
|
-
const
|
|
264
|
-
appWindow
|
|
327
|
+
const connecting = connectAppHost({
|
|
328
|
+
appWindow,
|
|
265
329
|
expectedAppOrigin: "null",
|
|
266
330
|
hostWindow: window,
|
|
267
|
-
signal:
|
|
331
|
+
signal: opening,
|
|
268
332
|
launch: {
|
|
269
333
|
identity: {
|
|
270
334
|
appId: config.appId,
|
|
@@ -301,7 +365,9 @@ export async function connectOysterApp(options) {
|
|
|
301
365
|
signal: options.signal,
|
|
302
366
|
}),
|
|
303
367
|
},
|
|
304
|
-
})
|
|
368
|
+
});
|
|
369
|
+
navigate();
|
|
370
|
+
const host = await connecting.catch((cause) => {
|
|
305
371
|
releaseBrowser();
|
|
306
372
|
throw cause;
|
|
307
373
|
});
|