@fungi.computer/oyster 0.48.0 → 0.49.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 +7 -3
- package/dist/build/candidate-cli.mjs +1 -1
- package/dist/build/snapshot-program-scripts.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/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/install-apps-cli.js +25 -3
- package/docs/api/pack.md +123 -2
- package/package.json +1 -1
|
@@ -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/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];
|
|
@@ -15,16 +15,19 @@ import process from "node:process";
|
|
|
15
15
|
import { parseArgs } from "node:util";
|
|
16
16
|
import { Cli } from "@fungi.computer/lantern";
|
|
17
17
|
import { createTryCli, reportTryFailure, tryOyster, tryUsage, } from "./try-cli.js";
|
|
18
|
+
import { installPreviewNotes } from "../install-preview.js";
|
|
18
19
|
import { installReleaseCommand, installReleaseUsage, } from "../install-release-cli.js";
|
|
19
20
|
import { defaultStarterBuildConcurrency, installStandaloneAppSet, } from "./app-set.js";
|
|
20
21
|
/** The starter Apps' public source repositories. */
|
|
21
22
|
const defaultRepositories = "https://github.com/fungi-computer";
|
|
22
|
-
const usage = "Usage: oyster install-apps [--repositories <base URL>] [--ref <ref>] [--from <checkout>] [--concurrency 1-3] [--timings <file>] [--only <app>[,<app>]]";
|
|
23
|
+
const usage = "Usage: oyster install-apps [--repositories <base URL>] [--ref <ref>] [--from <checkout>] [--concurrency 1-3] [--timings <file>] [--only <app>[,<app>]] [--yes]";
|
|
23
24
|
const urlSource = "OYSTER_URL is the address of your deployed Oyster Worker, such as https://oyster.<your-subdomain>.workers.dev. You set it when you deploy. For a local trial, run `oyster try`; it sets up its Computer and starter Apps.";
|
|
24
25
|
const keySource = "OYSTER_OWNER_KEY is the owner key you chose for that Oyster: export OYSTER_OWNER_KEY=$(openssl rand -hex 24), then store it with `wrangler secret put OYSTER_OWNER_KEY`.";
|
|
25
26
|
const helpText = `${usage}
|
|
26
27
|
|
|
27
|
-
Builds the seven starter Apps on your Oyster's own Computer
|
|
28
|
+
Builds the seven starter Apps on your Oyster's own Computer, shows what they
|
|
29
|
+
built, what failed and the permissions they ask for, asks you to confirm once,
|
|
30
|
+
then installs them.
|
|
28
31
|
Starter builds need a deployed Oyster host; this command does not create one.
|
|
29
32
|
Deploy first (see the Oyster README), then set:
|
|
30
33
|
|
|
@@ -37,6 +40,7 @@ Options:
|
|
|
37
40
|
--from <checkout> install from a Botanical checkout directory
|
|
38
41
|
--concurrency 1-3 Apps to build at once
|
|
39
42
|
--only <app>[,<app>] install only these Apps, such as --only prints
|
|
43
|
+
-y, --yes confirm the permissions without asking (required without a terminal)
|
|
40
44
|
--timings <file> write the build timings as JSON
|
|
41
45
|
-h, --help show this help
|
|
42
46
|
`;
|
|
@@ -94,6 +98,7 @@ export async function installApps(args, install = installStandaloneAppSet, ui =
|
|
|
94
98
|
concurrency: { type: "string" },
|
|
95
99
|
timings: { type: "string" },
|
|
96
100
|
only: { type: "string" },
|
|
101
|
+
yes: { type: "boolean", short: "y" },
|
|
97
102
|
help: { type: "boolean", short: "h" },
|
|
98
103
|
},
|
|
99
104
|
strict: true,
|
|
@@ -134,18 +139,35 @@ export async function installApps(args, install = installStandaloneAppSet, ui =
|
|
|
134
139
|
source = { kind: "checkout", directory, revision: `git:${revision}` };
|
|
135
140
|
}
|
|
136
141
|
const started = performance.now();
|
|
137
|
-
const { installed, failed } = await install({
|
|
142
|
+
const { installed, failed, declined } = await install({
|
|
138
143
|
source,
|
|
139
144
|
url,
|
|
140
145
|
key,
|
|
141
146
|
concurrency,
|
|
142
147
|
only,
|
|
148
|
+
// Once, after every build settles: what built, what failed and why, and
|
|
149
|
+
// the permissions of what built. Nothing installs before the answer.
|
|
150
|
+
confirm: async ({ previews, failed }) => {
|
|
151
|
+
ui.note("Built", previews.map(({ installationId }) => installationId));
|
|
152
|
+
if (failed.length > 0)
|
|
153
|
+
ui.note("Failed; these will not be installed", failed.map(({ installationId, reason }) => `${installationId}: ${reason}`));
|
|
154
|
+
for (const note of installPreviewNotes(previews))
|
|
155
|
+
ui.note(note.title, [...note.lines]);
|
|
156
|
+
if (values.yes === true)
|
|
157
|
+
return true;
|
|
158
|
+
const answer = await ui.confirm({
|
|
159
|
+
message: `Install ${String(previews.length)} built App${previews.length === 1 ? "" : "s"} with these permissions${failed.length > 0 ? ` (${String(failed.length)} failed)` : ""}?`,
|
|
160
|
+
});
|
|
161
|
+
return answer === true;
|
|
162
|
+
},
|
|
143
163
|
// Builds run side by side, so each report is its own line, not a spinner.
|
|
144
164
|
report: (message) => {
|
|
145
165
|
ui.step(message);
|
|
146
166
|
},
|
|
147
167
|
});
|
|
148
168
|
const elapsed = performance.now() - started;
|
|
169
|
+
if (declined)
|
|
170
|
+
throw new Error("Install cancelled; nothing was installed. Run with --yes to confirm without asking.");
|
|
149
171
|
if (installed.length > 0)
|
|
150
172
|
ui.note("Build timings", timingTable(installed));
|
|
151
173
|
ui.note("Apps", [
|