@fungi.computer/oyster 0.48.0 → 0.49.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/README.md +7 -3
- package/dist/app-region.js +16 -5
- package/dist/build/candidate-cli.mjs +1 -1
- package/dist/build/snapshot-program-scripts.js +1 -1
- package/dist/computer-control-port.d.ts +17 -0
- package/dist/embed-metafiles.js +1 -1
- package/dist/install-preview.d.ts +19 -0
- package/dist/install-preview.js +41 -0
- package/dist/install-release-cli.js +3 -20
- package/dist/mcp.d.ts +61 -0
- package/dist/mcp.js +54 -0
- package/dist/pack.d.ts +21 -18
- package/dist/pack.js +22 -10
- package/dist/standalone/app-set.d.ts +20 -1
- package/dist/standalone/app-set.js +119 -60
- package/dist/standalone/computer-control.js +31 -0
- package/dist/standalone/install-apps-cli.js +25 -3
- package/dist/standalone/registry.d.ts +1 -1
- package/docs/api/mcp.md +74 -46
- package/docs/api/pack.md +123 -2
- package/docs/api/workers.md +16 -16
- package/package.json +3 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AppCapabilityId } from "@fungi.computer/puffball/app";
|
|
2
|
+
/** What the Oyster reports for one Release it would install. */
|
|
3
|
+
export type InstallPreview = Readonly<{
|
|
4
|
+
name: string;
|
|
5
|
+
capabilities: readonly AppCapabilityId[];
|
|
6
|
+
/** Set when installing would update an existing installation. */
|
|
7
|
+
update: Readonly<{
|
|
8
|
+
installationId: string;
|
|
9
|
+
needsApproval: readonly AppCapabilityId[];
|
|
10
|
+
}> | null;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* The one list an owner confirms: a fresh install grants by the shared rule;
|
|
14
|
+
* an update keeps its current grants, so it lists only what newly waits.
|
|
15
|
+
*/
|
|
16
|
+
export declare function installPreviewNotes(previews: readonly InstallPreview[]): readonly Readonly<{
|
|
17
|
+
title: string;
|
|
18
|
+
lines: readonly string[];
|
|
19
|
+
}>[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { installConfirmation, permissionCatalog, } from "./apps/index.js";
|
|
2
|
+
const lines = (rows) => rows.map((row) => `${row.label}: ${row.description}${row.warning === null ? "" : ` ${row.warning}`} (${row.apps.join(", ")})`);
|
|
3
|
+
/**
|
|
4
|
+
* The one list an owner confirms: a fresh install grants by the shared rule;
|
|
5
|
+
* an update keeps its current grants, so it lists only what newly waits.
|
|
6
|
+
*/
|
|
7
|
+
export function installPreviewNotes(previews) {
|
|
8
|
+
const fresh = previews.filter(({ update }) => update === null);
|
|
9
|
+
const confirmation = installConfirmation("owner", fresh);
|
|
10
|
+
return [
|
|
11
|
+
...(confirmation.granted.length === 0
|
|
12
|
+
? []
|
|
13
|
+
: [
|
|
14
|
+
{
|
|
15
|
+
title: `Installing ${fresh.map(({ name }) => name).join(", ")} lets them:`,
|
|
16
|
+
lines: lines(confirmation.granted),
|
|
17
|
+
},
|
|
18
|
+
]),
|
|
19
|
+
...(confirmation.needsApproval.length === 0
|
|
20
|
+
? []
|
|
21
|
+
: [
|
|
22
|
+
{
|
|
23
|
+
title: "Not granted by installing; approve in Settings > Permissions:",
|
|
24
|
+
lines: lines(confirmation.needsApproval),
|
|
25
|
+
},
|
|
26
|
+
]),
|
|
27
|
+
...previews.flatMap(({ name, update }) => update === null
|
|
28
|
+
? []
|
|
29
|
+
: [
|
|
30
|
+
{
|
|
31
|
+
title: `Updating ${update.installationId} (${name}) keeps its current permissions:`,
|
|
32
|
+
lines: update.needsApproval.length === 0
|
|
33
|
+
? ["Nothing new is requested."]
|
|
34
|
+
: [
|
|
35
|
+
"Newly requested, waiting for approval in Settings > Permissions:",
|
|
36
|
+
...update.needsApproval.map((capability) => permissionCatalog[capability].label),
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
]),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
@@ -4,7 +4,7 @@ import { basename, dirname, resolve } from "node:path";
|
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
import { Cli } from "@fungi.computer/lantern";
|
|
7
|
-
import {
|
|
7
|
+
import { installPreviewNotes } from "./install-preview.js";
|
|
8
8
|
import { installRelease, previewRelease } from "./pack.js";
|
|
9
9
|
export const installReleaseUsage = "Usage: oyster install <directory|release.json>... [--installation-id <name>] [--yes]";
|
|
10
10
|
export async function installReleaseCommand(args,
|
|
@@ -57,25 +57,8 @@ ui = new Cli({ brand: "fungi", output: process.stderr })) {
|
|
|
57
57
|
});
|
|
58
58
|
return found;
|
|
59
59
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const confirmation = installConfirmation("owner", previews.filter(({ update }) => update === null));
|
|
63
|
-
const lines = (rows) => rows.map((row) => `${row.label}: ${row.description}${row.warning === null ? "" : ` ${row.warning}`} (${row.apps.join(", ")})`);
|
|
64
|
-
if (confirmation.granted.length > 0)
|
|
65
|
-
ui.note(`Installing ${previews
|
|
66
|
-
.filter(({ update }) => update === null)
|
|
67
|
-
.map(({ name }) => name)
|
|
68
|
-
.join(", ")} lets them:`, lines(confirmation.granted));
|
|
69
|
-
if (confirmation.needsApproval.length > 0)
|
|
70
|
-
ui.note("Not granted by installing; approve in Settings > Permissions:", lines(confirmation.needsApproval));
|
|
71
|
-
for (const { name, update } of previews)
|
|
72
|
-
if (update !== null)
|
|
73
|
-
ui.note(`Updating ${update.installationId} (${name}) keeps its current permissions:`, update.needsApproval.length === 0
|
|
74
|
-
? ["Nothing new is requested."]
|
|
75
|
-
: [
|
|
76
|
-
"Newly requested, waiting for approval in Settings > Permissions:",
|
|
77
|
-
...update.needsApproval.map((capability) => permissionCatalog[capability].label),
|
|
78
|
-
]);
|
|
60
|
+
for (const note of installPreviewNotes(previews))
|
|
61
|
+
ui.note(note.title, [...note.lines]);
|
|
79
62
|
if (values.yes !== true) {
|
|
80
63
|
const answer = await ui.confirm({
|
|
81
64
|
message: `Install ${String(previews.length)} App${previews.length === 1 ? "" : "s"} with these permissions?`,
|
package/dist/mcp.d.ts
CHANGED
|
@@ -91,6 +91,29 @@ declare const fleetDetachment: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
91
91
|
uncertain: "uncertain";
|
|
92
92
|
}>;
|
|
93
93
|
}, z.core.$strict>], "kind">;
|
|
94
|
+
declare const fleetStop: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
95
|
+
kind: z.ZodLiteral<"stopped">;
|
|
96
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
97
|
+
kind: z.ZodEnum<{
|
|
98
|
+
denied: "denied";
|
|
99
|
+
busy: "busy";
|
|
100
|
+
uncertain: "uncertain";
|
|
101
|
+
}>;
|
|
102
|
+
}, z.core.$strict>], "kind">;
|
|
103
|
+
declare const fleetDelete: z.ZodObject<{
|
|
104
|
+
computerId: z.ZodString;
|
|
105
|
+
confirmHandle: z.ZodString;
|
|
106
|
+
}, z.core.$strict>;
|
|
107
|
+
declare const fleetDeletion: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
108
|
+
kind: z.ZodLiteral<"deleted">;
|
|
109
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
110
|
+
kind: z.ZodEnum<{
|
|
111
|
+
denied: "denied";
|
|
112
|
+
uncertain: "uncertain";
|
|
113
|
+
unsupported: "unsupported";
|
|
114
|
+
mismatch: "mismatch";
|
|
115
|
+
}>;
|
|
116
|
+
}, z.core.$strict>], "kind">;
|
|
94
117
|
declare const fleetCreation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
95
118
|
kind: z.ZodLiteral<"created">;
|
|
96
119
|
requestId: z.ZodString;
|
|
@@ -244,6 +267,44 @@ export declare function computerControlSpecs(port: ComputerControlPort): {
|
|
|
244
267
|
/** Mint one identity or preserve the requestId for an uncertain retry. */
|
|
245
268
|
execute: (input: z.output<typeof fleetCreate>, context: InvocationContext) => Promise<z.output<typeof fleetCreation>>;
|
|
246
269
|
};
|
|
270
|
+
stop: {
|
|
271
|
+
replay: "unsafe";
|
|
272
|
+
description: string;
|
|
273
|
+
input: z.ZodObject<{
|
|
274
|
+
computerId: z.ZodString;
|
|
275
|
+
}, z.core.$strict>;
|
|
276
|
+
output: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
277
|
+
kind: z.ZodLiteral<"stopped">;
|
|
278
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
279
|
+
kind: z.ZodEnum<{
|
|
280
|
+
denied: "denied";
|
|
281
|
+
busy: "busy";
|
|
282
|
+
uncertain: "uncertain";
|
|
283
|
+
}>;
|
|
284
|
+
}, z.core.$strict>], "kind">;
|
|
285
|
+
/** End the runtime; the Computer and its Workspace stay. */
|
|
286
|
+
execute: (input: z.output<typeof fleetComputerId>, context: InvocationContext) => Promise<z.output<typeof fleetStop>>;
|
|
287
|
+
};
|
|
288
|
+
delete: {
|
|
289
|
+
replay: "unsafe";
|
|
290
|
+
description: string;
|
|
291
|
+
input: z.ZodObject<{
|
|
292
|
+
computerId: z.ZodString;
|
|
293
|
+
confirmHandle: z.ZodString;
|
|
294
|
+
}, z.core.$strict>;
|
|
295
|
+
output: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
296
|
+
kind: z.ZodLiteral<"deleted">;
|
|
297
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
298
|
+
kind: z.ZodEnum<{
|
|
299
|
+
denied: "denied";
|
|
300
|
+
uncertain: "uncertain";
|
|
301
|
+
unsupported: "unsupported";
|
|
302
|
+
mismatch: "mismatch";
|
|
303
|
+
}>;
|
|
304
|
+
}, z.core.$strict>], "kind">;
|
|
305
|
+
/** Match the handle to the Computer's own name before anything is erased. */
|
|
306
|
+
execute: (input: z.output<typeof fleetDelete>, context: InvocationContext) => Promise<z.output<typeof fleetDeletion>>;
|
|
307
|
+
};
|
|
247
308
|
backends: {
|
|
248
309
|
replay: "safe";
|
|
249
310
|
description: string;
|
package/dist/mcp.js
CHANGED
|
@@ -89,6 +89,22 @@ const fleetDetachment = z.discriminatedUnion("kind", [
|
|
|
89
89
|
z.strictObject({ kind: z.literal("detached"), detached: z.boolean() }),
|
|
90
90
|
z.strictObject({ kind: z.enum(["denied", "uncertain", "invalid"]) }),
|
|
91
91
|
]);
|
|
92
|
+
const fleetStop = z.discriminatedUnion("kind", [
|
|
93
|
+
z.strictObject({ kind: z.literal("stopped") }),
|
|
94
|
+
z.strictObject({ kind: z.enum(["denied", "busy", "uncertain"]) }),
|
|
95
|
+
]);
|
|
96
|
+
const fleetDelete = z.strictObject({
|
|
97
|
+
computerId: fleetComputerId.shape.computerId,
|
|
98
|
+
confirmHandle: z.string().min(1).max(256),
|
|
99
|
+
});
|
|
100
|
+
const fleetDeletion = z.discriminatedUnion("kind", [
|
|
101
|
+
z.strictObject({ kind: z.literal("deleted") }),
|
|
102
|
+
z.strictObject({
|
|
103
|
+
kind: z.enum(["denied", "mismatch", "unsupported", "uncertain"]),
|
|
104
|
+
}),
|
|
105
|
+
]);
|
|
106
|
+
/** Directory pages read to find one Computer's name; a Team never has more. */
|
|
107
|
+
const maximumDirectoryPages = 20;
|
|
92
108
|
const fleetCreation = z.discriminatedUnion("kind", [
|
|
93
109
|
z.strictObject({
|
|
94
110
|
kind: z.literal("created"),
|
|
@@ -150,6 +166,36 @@ export function computerControlSpecs(port) {
|
|
|
150
166
|
return { ...result, requestId };
|
|
151
167
|
},
|
|
152
168
|
},
|
|
169
|
+
stop: {
|
|
170
|
+
replay: "unsafe",
|
|
171
|
+
description: 'Stop a Computer now and free its running slot. Running commands end; files are kept and the next start brings it back. Only the signed-in owner may; "busy" means it is starting or finishing an operation, so try again.',
|
|
172
|
+
input: fleetComputerId,
|
|
173
|
+
output: fleetStop,
|
|
174
|
+
/** End the runtime; the Computer and its Workspace stay. */
|
|
175
|
+
execute: (input, context) => port.stop(input.computerId, context),
|
|
176
|
+
},
|
|
177
|
+
delete: {
|
|
178
|
+
replay: "unsafe",
|
|
179
|
+
description: 'Delete a Computer and erase its Workspace, permanently. Pass its exact name as confirmHandle; a different handle deletes nothing. Only the signed-in owner may, never a Team key or an Agent. "uncertain" means retry: a delete cut short finishes on the next attempt.',
|
|
180
|
+
input: fleetDelete,
|
|
181
|
+
output: fleetDeletion,
|
|
182
|
+
/** Match the handle to the Computer's own name before anything is erased. */
|
|
183
|
+
execute: async (input, context) => {
|
|
184
|
+
let name;
|
|
185
|
+
for (let page = 0, offset = 0; page < maximumDirectoryPages && name === undefined; page += 1) {
|
|
186
|
+
const listed = await port.list({ limit: 100, offset }, context);
|
|
187
|
+
name = listed.computers.find((computer) => computer.computerId === input.computerId)?.name;
|
|
188
|
+
if (listed.nextOffset === null)
|
|
189
|
+
break;
|
|
190
|
+
offset = listed.nextOffset;
|
|
191
|
+
}
|
|
192
|
+
if (name === undefined)
|
|
193
|
+
return { kind: "denied" };
|
|
194
|
+
if (name !== input.confirmHandle)
|
|
195
|
+
return { kind: "mismatch" };
|
|
196
|
+
return port.delete(input.computerId, context);
|
|
197
|
+
},
|
|
198
|
+
},
|
|
153
199
|
backends: {
|
|
154
200
|
replay: "safe",
|
|
155
201
|
description: "List one Computer's attached execution backends (platform container, on-box VM, members' machines) with live status.",
|
|
@@ -652,6 +698,14 @@ export function oysterMcpCatalogLoad(host) {
|
|
|
652
698
|
...fleetSpecs.create,
|
|
653
699
|
confirm: true,
|
|
654
700
|
}),
|
|
701
|
+
stop: Mycelium.operation({
|
|
702
|
+
...fleetSpecs.stop,
|
|
703
|
+
confirm: true,
|
|
704
|
+
}),
|
|
705
|
+
delete: Mycelium.operation({
|
|
706
|
+
...fleetSpecs.delete,
|
|
707
|
+
confirm: true,
|
|
708
|
+
}),
|
|
655
709
|
backends: Mycelium.operation(fleetSpecs.backends),
|
|
656
710
|
attachLocal: Mycelium.operation(fleetSpecs.attachLocal),
|
|
657
711
|
detachLocal: Mycelium.operation(fleetSpecs.detachLocal),
|
package/dist/pack.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import { releaseSchema } from "@fungi.computer/puffball/effect";
|
|
1
3
|
import { type InstallationCompletion, type InstallationObservationBudget } from "./installation-client.js";
|
|
2
4
|
import { type ArtifactRef, type Release, type Sha256Digest } from "@fungi.computer/puffball";
|
|
3
5
|
import { type AppPublisherCoreConfigInput } from "./build.js";
|
|
@@ -58,28 +60,29 @@ export declare function installFromSource(input: Readonly<{
|
|
|
58
60
|
key: string;
|
|
59
61
|
installationId: string;
|
|
60
62
|
}> & InstallationObservationBudget): Promise<Response>;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
/** The Release `release.json` names, as read and uploaded. */
|
|
64
|
+
export type UploadedRelease = Schema.Schema.Type<typeof releaseSchema>;
|
|
65
|
+
/**
|
|
66
|
+
* Ask the Oyster what installing a Release it already holds would request,
|
|
67
|
+
* and whether it would update an existing installation.
|
|
68
|
+
*/
|
|
69
|
+
export declare function previewBuiltRelease(input: Readonly<{
|
|
64
70
|
url: string;
|
|
65
71
|
key: string;
|
|
66
|
-
|
|
72
|
+
release: UploadedRelease;
|
|
73
|
+
installationId?: string | undefined;
|
|
74
|
+
signal?: AbortSignal | undefined;
|
|
67
75
|
}>): Promise<{
|
|
68
|
-
readonly
|
|
69
|
-
readonly
|
|
70
|
-
readonly
|
|
71
|
-
readonly
|
|
72
|
-
readonly
|
|
73
|
-
|
|
74
|
-
readonly sourceRevision: import("@fungi.computer/puffball").SourceRevision;
|
|
75
|
-
readonly sourceTreeDigest: Sha256Digest;
|
|
76
|
-
readonly buildRecipeDigest: Sha256Digest;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
76
|
+
readonly name: string;
|
|
77
|
+
readonly capabilities: readonly ("computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage")[];
|
|
78
|
+
readonly update: {
|
|
79
|
+
readonly installationId: string;
|
|
80
|
+
readonly needsApproval: readonly ("computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.read" | "agent.send" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage")[];
|
|
81
|
+
} | null;
|
|
79
82
|
}>;
|
|
80
83
|
/**
|
|
81
|
-
* Upload one built Release and
|
|
82
|
-
*
|
|
84
|
+
* Upload one built Release and preview it, so an owner can confirm several
|
|
85
|
+
* Releases once before any install.
|
|
83
86
|
*/
|
|
84
87
|
export declare function previewRelease(input: Readonly<{
|
|
85
88
|
directory: string;
|
|
@@ -123,7 +126,7 @@ export declare function installRelease(input: Readonly<{
|
|
|
123
126
|
key: string;
|
|
124
127
|
installationId?: string;
|
|
125
128
|
/** The Release `previewRelease` already read and uploaded; skips both. */
|
|
126
|
-
uploaded?:
|
|
129
|
+
uploaded?: UploadedRelease;
|
|
127
130
|
/** Report owner-correlated admission without shortening the completion wait. */
|
|
128
131
|
onAdmitted?: (operation: InstallationOperation) => void;
|
|
129
132
|
/** Runs once with the completed operation, before the response is made. */
|
package/dist/pack.js
CHANGED
|
@@ -146,25 +146,37 @@ const releasePreviewSchema = Schema.Struct({
|
|
|
146
146
|
})),
|
|
147
147
|
});
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
149
|
+
* Ask the Oyster what installing a Release it already holds would request,
|
|
150
|
+
* and whether it would update an existing installation.
|
|
151
151
|
*/
|
|
152
|
-
export async function
|
|
153
|
-
const
|
|
154
|
-
const release = await uploadRelease({ ...input, signal });
|
|
155
|
-
const response = await fetch(new URL("/api/installations/preview", input.url), {
|
|
152
|
+
export async function previewBuiltRelease(input) {
|
|
153
|
+
const init = {
|
|
156
154
|
method: "POST",
|
|
157
155
|
headers: {
|
|
158
156
|
Authorization: `Bearer ${input.key}`,
|
|
159
157
|
"Content-Type": "application/json",
|
|
160
158
|
},
|
|
161
|
-
body: JSON.stringify({
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
body: JSON.stringify({
|
|
160
|
+
release: input.release,
|
|
161
|
+
installationId: input.installationId,
|
|
162
|
+
}),
|
|
163
|
+
};
|
|
164
|
+
if (input.signal !== undefined)
|
|
165
|
+
init.signal = input.signal;
|
|
166
|
+
const response = await fetch(new URL("/api/installations/preview", input.url), init);
|
|
164
167
|
if (!response.ok)
|
|
165
168
|
throw new Error(`Install preview failed (${String(response.status)}): ${await response.text()}`);
|
|
169
|
+
return Schema.decodeUnknownSync(releasePreviewSchema)(await response.json());
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Upload one built Release and preview it, so an owner can confirm several
|
|
173
|
+
* Releases once before any install.
|
|
174
|
+
*/
|
|
175
|
+
export async function previewRelease(input) {
|
|
176
|
+
const signal = installationObservationSignal({});
|
|
177
|
+
const release = await uploadRelease({ ...input, signal });
|
|
166
178
|
return {
|
|
167
|
-
...
|
|
179
|
+
...(await previewBuiltRelease({ ...input, release, signal })),
|
|
168
180
|
release,
|
|
169
181
|
};
|
|
170
182
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
-
import { type PackOptions } from "../pack.js";
|
|
2
|
+
import { previewBuiltRelease, type PackOptions } from "../pack.js";
|
|
3
|
+
import { releaseSchema } from "@fungi.computer/puffball/effect";
|
|
3
4
|
/** One starter App's identity and source; its manifest owns the build recipe. */
|
|
4
5
|
export type StarterApp = Readonly<{
|
|
5
6
|
/** Selecting this configured dashboard approves its declared shell authority only. */
|
|
@@ -76,7 +77,21 @@ export type InstalledStarterApp = Readonly<{
|
|
|
76
77
|
release: Schema.Json;
|
|
77
78
|
timings: StarterAppTimings;
|
|
78
79
|
}>;
|
|
80
|
+
/** What one built App asks for, as the Oyster reports it before install. */
|
|
81
|
+
export type StarterAppPreview = Readonly<{
|
|
82
|
+
installationId: string;
|
|
83
|
+
} & Awaited<ReturnType<typeof previewBuiltRelease>>>;
|
|
84
|
+
/** Everything the owner confirms once: what built, and what did not and why. */
|
|
85
|
+
export type StarterAppReview = Readonly<{
|
|
86
|
+
previews: readonly StarterAppPreview[];
|
|
87
|
+
failed: readonly Readonly<{
|
|
88
|
+
installationId: string;
|
|
89
|
+
reason: string;
|
|
90
|
+
}>[];
|
|
91
|
+
}>;
|
|
79
92
|
export type StarterAppSetResult = Readonly<{
|
|
93
|
+
/** The owner declined the confirmation, so nothing was installed. */
|
|
94
|
+
declined: boolean;
|
|
80
95
|
installed: readonly InstalledStarterApp[];
|
|
81
96
|
failed: readonly Readonly<{
|
|
82
97
|
installationId: string;
|
|
@@ -105,6 +120,10 @@ export declare function installStandaloneAppSet(options: Readonly<{
|
|
|
105
120
|
report: (message: string) => void;
|
|
106
121
|
/** Builds at once on the Computer, 1 to 3; one by default. */
|
|
107
122
|
concurrency?: number;
|
|
123
|
+
/** Asked once after every build settles; false installs nothing. */
|
|
124
|
+
confirm: (review: StarterAppReview) => Promise<boolean>;
|
|
125
|
+
/** Reads what a built Release requests; the real preview route by default. */
|
|
126
|
+
preview?: (release: Schema.Schema.Type<typeof releaseSchema>, installationId: string) => Promise<Awaited<ReturnType<typeof previewBuiltRelease>>>;
|
|
108
127
|
/** Install only these starter installation ids; every starter by default. */
|
|
109
128
|
only?: readonly string[];
|
|
110
129
|
/** Publishes one App's source; the real installer uses `publishSource`. */
|
|
@@ -7,7 +7,7 @@ import * as Option from "effect/Option";
|
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import { olderOysterStoreCode } from "../older-oyster-store.js";
|
|
9
9
|
import { installationNotActivatedMessage, installationNotAppliedMessage, } from "../instance-refusal.js";
|
|
10
|
-
import { publishSource } from "../pack.js";
|
|
10
|
+
import { previewBuiltRelease, publishSource, } from "../pack.js";
|
|
11
11
|
import { appBuildRecipe, readBuildManifest } from "../build/workspace-build.js";
|
|
12
12
|
import { parseSourceRevision } from "@fungi.computer/puffball";
|
|
13
13
|
import { releaseSchema } from "@fungi.computer/puffball/effect";
|
|
@@ -303,6 +303,13 @@ export async function installStandaloneAppSet(options) {
|
|
|
303
303
|
const reportFailure = ({ app, cause, }) => {
|
|
304
304
|
fail(app, cause);
|
|
305
305
|
};
|
|
306
|
+
const previewOnOyster = (release, installationId) => previewBuiltRelease({
|
|
307
|
+
url: options.url,
|
|
308
|
+
key: options.key,
|
|
309
|
+
release,
|
|
310
|
+
installationId,
|
|
311
|
+
});
|
|
312
|
+
const built = new Map();
|
|
306
313
|
const seededQueue = [];
|
|
307
314
|
const waiting = [];
|
|
308
315
|
const seeding = { finished: false };
|
|
@@ -379,66 +386,12 @@ export async function installStandaloneAppSet(options) {
|
|
|
379
386
|
});
|
|
380
387
|
if (release.appId !== next.app.appId)
|
|
381
388
|
throw new Error(`${name} build belongs to another App`);
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
key: options.key,
|
|
389
|
+
built.set(name, {
|
|
390
|
+
next,
|
|
391
|
+
build,
|
|
386
392
|
release,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
});
|
|
390
|
-
if (operation.state === "unconfirmed")
|
|
391
|
-
throw new InstallationObservationError(operation.requestId);
|
|
392
|
-
if (operation.state === "refused")
|
|
393
|
-
throw new Error(operation.code === "installation_not_applied"
|
|
394
|
-
? `${name}: ${installationNotAppliedMessage}`
|
|
395
|
-
: operation.code === "installation_not_activated"
|
|
396
|
-
? `${name}: ${installationNotActivatedMessage}`
|
|
397
|
-
: `${name} installation refused (${operation.code})`);
|
|
398
|
-
const record = operation.installation;
|
|
399
|
-
if (record === null)
|
|
400
|
-
throw new Error(`${name} completed installation version is unavailable`);
|
|
401
|
-
if (record.appId !== release.appId ||
|
|
402
|
-
record.release.releaseId !== release.releaseId ||
|
|
403
|
-
record.release.artifact.artifactDigest !==
|
|
404
|
-
release.artifact.artifactDigest)
|
|
405
|
-
throw new Error(`${name} installation does not match its build`);
|
|
406
|
-
// Only the owner can attest exclusive fresh creation. A replacement or
|
|
407
|
-
// tombstone remint never replays a default grant.
|
|
408
|
-
if (operation.creation === "fresh") {
|
|
409
|
-
if (record.status !== "enabled")
|
|
410
|
-
throw new Error(`${name} fresh installation is not enabled`);
|
|
411
|
-
if (next.app.dashboard === true)
|
|
412
|
-
await approveChosenDashboard(operation, owner);
|
|
413
|
-
}
|
|
414
|
-
options.report(`${operation.creation === "replacement" ? "Replaced" : "Installed"} ${name} from its build ${build.jobId}`);
|
|
415
|
-
// Report-only UI check: never blocks, but the owner sees it here.
|
|
416
|
-
const uiCheck = operation.uiCheck;
|
|
417
|
-
if (uiCheck?.kind === "failed")
|
|
418
|
-
options.report(`Warning: ${name} is installed, but its UI check failed (${uiCheck.code}${uiCheck.diagnostics === undefined ? "" : `: ${uiCheck.diagnostics.failedPredicate}`}).`);
|
|
419
|
-
else if (uiCheck?.kind === "not_checked")
|
|
420
|
-
options.report(`Warning: ${name} is installed, but its UI was not checked (${uiCheck.code}).`);
|
|
421
|
-
const phases = build.detail === null
|
|
422
|
-
? undefined
|
|
423
|
-
: Schema.decodeUnknownOption(computerPhasesSchema)(build.detail);
|
|
424
|
-
installed.set(name, {
|
|
425
|
-
installationId: record.installationId,
|
|
426
|
-
published: next.kind,
|
|
427
|
-
seedRevision: next.seedRevision,
|
|
428
|
-
sourceRevision: next.sourceRevision,
|
|
429
|
-
jobId: build.jobId,
|
|
430
|
-
installed: operation.creation === "replacement" ? "replaced" : "installed",
|
|
431
|
-
release: build.release,
|
|
432
|
-
timings: {
|
|
433
|
-
fetch: next.fetch,
|
|
434
|
-
publish: next.publish,
|
|
435
|
-
queue: buildStarted - next.ready,
|
|
436
|
-
build: installStarted - buildStarted,
|
|
437
|
-
install: performance.now() - installStarted,
|
|
438
|
-
computer: phases === undefined || phases._tag === "None"
|
|
439
|
-
? null
|
|
440
|
-
: phases.value.phasesMs,
|
|
441
|
-
},
|
|
393
|
+
buildStarted,
|
|
394
|
+
builtAt: performance.now(),
|
|
442
395
|
});
|
|
443
396
|
}
|
|
444
397
|
catch (cause) {
|
|
@@ -446,6 +399,70 @@ export async function installStandaloneAppSet(options) {
|
|
|
446
399
|
}
|
|
447
400
|
}
|
|
448
401
|
};
|
|
402
|
+
/** Install one built App once the owner has confirmed the whole set. */
|
|
403
|
+
const installBuilt = async ({ next, build, release, buildStarted, builtAt, }) => {
|
|
404
|
+
const name = next.app.installationId;
|
|
405
|
+
const installStarted = performance.now();
|
|
406
|
+
const operation = await installOnOyster({
|
|
407
|
+
url: options.url,
|
|
408
|
+
key: options.key,
|
|
409
|
+
release,
|
|
410
|
+
installationId: name,
|
|
411
|
+
signal: AbortSignal.timeout(options.waitMs ?? appBuildWaitMs),
|
|
412
|
+
});
|
|
413
|
+
if (operation.state === "unconfirmed")
|
|
414
|
+
throw new InstallationObservationError(operation.requestId);
|
|
415
|
+
if (operation.state === "refused")
|
|
416
|
+
throw new Error(operation.code === "installation_not_applied"
|
|
417
|
+
? `${name}: ${installationNotAppliedMessage}`
|
|
418
|
+
: operation.code === "installation_not_activated"
|
|
419
|
+
? `${name}: ${installationNotActivatedMessage}`
|
|
420
|
+
: `${name} installation refused (${operation.code})`);
|
|
421
|
+
const record = operation.installation;
|
|
422
|
+
if (record === null)
|
|
423
|
+
throw new Error(`${name} completed installation version is unavailable`);
|
|
424
|
+
if (record.appId !== release.appId ||
|
|
425
|
+
record.release.releaseId !== release.releaseId ||
|
|
426
|
+
record.release.artifact.artifactDigest !== release.artifact.artifactDigest)
|
|
427
|
+
throw new Error(`${name} installation does not match its build`);
|
|
428
|
+
// Only the owner can attest exclusive fresh creation. A replacement or
|
|
429
|
+
// tombstone remint never replays a default grant.
|
|
430
|
+
if (operation.creation === "fresh") {
|
|
431
|
+
if (record.status !== "enabled")
|
|
432
|
+
throw new Error(`${name} fresh installation is not enabled`);
|
|
433
|
+
if (next.app.dashboard === true)
|
|
434
|
+
await approveChosenDashboard(operation, owner);
|
|
435
|
+
}
|
|
436
|
+
options.report(`${operation.creation === "replacement" ? "Replaced" : "Installed"} ${name} from its build ${build.jobId}`);
|
|
437
|
+
// Report-only UI check: never blocks, but the owner sees it here.
|
|
438
|
+
const uiCheck = operation.uiCheck;
|
|
439
|
+
if (uiCheck?.kind === "failed")
|
|
440
|
+
options.report(`Warning: ${name} is installed, but its UI check failed (${uiCheck.code}${uiCheck.diagnostics === undefined ? "" : `: ${uiCheck.diagnostics.failedPredicate}`}).`);
|
|
441
|
+
else if (uiCheck?.kind === "not_checked")
|
|
442
|
+
options.report(`Warning: ${name} is installed, but its UI was not checked (${uiCheck.code}).`);
|
|
443
|
+
const phases = build.detail === null
|
|
444
|
+
? undefined
|
|
445
|
+
: Schema.decodeUnknownOption(computerPhasesSchema)(build.detail);
|
|
446
|
+
installed.set(name, {
|
|
447
|
+
installationId: record.installationId,
|
|
448
|
+
published: next.kind,
|
|
449
|
+
seedRevision: next.seedRevision,
|
|
450
|
+
sourceRevision: next.sourceRevision,
|
|
451
|
+
jobId: build.jobId,
|
|
452
|
+
installed: operation.creation === "replacement" ? "replaced" : "installed",
|
|
453
|
+
release: build.release,
|
|
454
|
+
timings: {
|
|
455
|
+
fetch: next.fetch,
|
|
456
|
+
publish: next.publish,
|
|
457
|
+
queue: buildStarted - next.ready,
|
|
458
|
+
build: builtAt - buildStarted,
|
|
459
|
+
install: performance.now() - installStarted,
|
|
460
|
+
computer: phases === undefined || phases._tag === "None"
|
|
461
|
+
? null
|
|
462
|
+
: phases.value.phasesMs,
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
};
|
|
449
466
|
// Wait for every seed and build to settle before returning the full outcome.
|
|
450
467
|
const settled = await Promise.allSettled([
|
|
451
468
|
seedAll(),
|
|
@@ -454,7 +471,49 @@ export async function installStandaloneAppSet(options) {
|
|
|
454
471
|
for (const outcome of settled)
|
|
455
472
|
if (outcome.status === "rejected")
|
|
456
473
|
throw outcome.reason;
|
|
474
|
+
// Every build has settled: ask the Oyster what the built Apps request, then
|
|
475
|
+
// the owner confirms the whole set once, naming what failed, before any
|
|
476
|
+
// App is installed.
|
|
477
|
+
const previews = [];
|
|
478
|
+
for (const app of apps) {
|
|
479
|
+
const entry = built.get(app.installationId);
|
|
480
|
+
if (entry === undefined)
|
|
481
|
+
continue;
|
|
482
|
+
try {
|
|
483
|
+
previews.push({
|
|
484
|
+
installationId: app.installationId,
|
|
485
|
+
...(await (options.preview ?? previewOnOyster)(entry.release, app.installationId)),
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
catch (cause) {
|
|
489
|
+
built.delete(app.installationId);
|
|
490
|
+
reportFailure({ app, cause });
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const confirmed = previews.length === 0 ||
|
|
494
|
+
(await options.confirm({
|
|
495
|
+
previews,
|
|
496
|
+
failed: apps.flatMap((app) => {
|
|
497
|
+
const reason = failures.get(app.installationId);
|
|
498
|
+
return reason === undefined
|
|
499
|
+
? []
|
|
500
|
+
: [{ installationId: app.installationId, reason }];
|
|
501
|
+
}),
|
|
502
|
+
}));
|
|
503
|
+
if (confirmed)
|
|
504
|
+
for (const app of apps) {
|
|
505
|
+
const entry = built.get(app.installationId);
|
|
506
|
+
if (entry === undefined)
|
|
507
|
+
continue;
|
|
508
|
+
try {
|
|
509
|
+
await installBuilt(entry);
|
|
510
|
+
}
|
|
511
|
+
catch (cause) {
|
|
512
|
+
reportFailure({ app, cause });
|
|
513
|
+
}
|
|
514
|
+
}
|
|
457
515
|
return {
|
|
516
|
+
declined: !confirmed,
|
|
458
517
|
installed: apps.flatMap((app) => {
|
|
459
518
|
const result = installed.get(app.installationId);
|
|
460
519
|
return result === undefined ? [] : [result];
|
|
@@ -19,6 +19,7 @@ const inventoryError = z.strictObject({
|
|
|
19
19
|
const backendList = z.strictObject({
|
|
20
20
|
backends: z.array(computerBackendViewSchema),
|
|
21
21
|
});
|
|
22
|
+
const stopped = z.strictObject({ state: z.literal("sleeping") });
|
|
22
23
|
const attachedBackend = z.strictObject({ backendId: z.string() });
|
|
23
24
|
const detachedBackend = z.strictObject({ detached: z.boolean() });
|
|
24
25
|
/** A typed refusal from the owner-admitted fleet, as the MCP result kinds. */
|
|
@@ -48,6 +49,36 @@ export function standaloneComputerControl(registry, memberId) {
|
|
|
48
49
|
list: async (page) => teamComputerDirectorySchema.parse(inventoryPage.parse(available(await fleet({ operation: "list", page })))),
|
|
49
50
|
state: async (computerId) => computerStateSchema.parse(available(await fleet({ operation: "state", computerId }))),
|
|
50
51
|
start: async (computerId) => computerStateSchema.parse(available(await fleet({ operation: "start", computerId }))),
|
|
52
|
+
stop: async (computerId) => {
|
|
53
|
+
let result;
|
|
54
|
+
try {
|
|
55
|
+
result = await fleet({ operation: "stop", computerId });
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// The runtime may have stopped before the RPC failed; the caller retries.
|
|
59
|
+
return { kind: "uncertain" };
|
|
60
|
+
}
|
|
61
|
+
if (result === null)
|
|
62
|
+
return { kind: "denied" };
|
|
63
|
+
const error = inventoryError.safeParse(result);
|
|
64
|
+
if (error.success) {
|
|
65
|
+
switch (error.data.error) {
|
|
66
|
+
case "busy":
|
|
67
|
+
return { kind: "busy" };
|
|
68
|
+
case "owner_required":
|
|
69
|
+
case "not_owner":
|
|
70
|
+
case "unknown_computer":
|
|
71
|
+
return { kind: "denied" };
|
|
72
|
+
default:
|
|
73
|
+
return { kind: "uncertain" };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
stopped.parse(result);
|
|
77
|
+
return { kind: "stopped" };
|
|
78
|
+
},
|
|
79
|
+
// Oyster has no delete path: inventory retirement here would leave the
|
|
80
|
+
// Computer's Workspace and runtime behind, so it refuses plainly.
|
|
81
|
+
delete: () => Promise.resolve({ kind: "unsupported" }),
|
|
51
82
|
create: async (input) => {
|
|
52
83
|
let result;
|
|
53
84
|
try {
|