@fungi.computer/oyster 0.47.5 → 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 +11 -3
- package/dist/apps/index.d.ts +1 -0
- package/dist/apps/index.js +1 -0
- package/dist/apps/install-confirmation.d.ts +26 -0
- package/dist/apps/install-confirmation.js +28 -0
- package/dist/apps/installation.d.ts +6 -0
- package/dist/apps/installation.js +12 -7
- package/dist/build/candidate-cli.mjs +1 -1
- package/dist/build/snapshot-program-scripts.js +1 -1
- package/dist/host.js +42 -2
- package/dist/install-preview.d.ts +19 -0
- package/dist/install-preview.js +41 -0
- package/dist/install-release-cli.d.ts +1 -1
- package/dist/install-release-cli.js +56 -24
- package/dist/pack.d.ts +55 -1
- package/dist/pack.js +66 -11
- package/dist/page/app-permissions.js +2 -5
- package/dist/page-script.js +1 -1
- package/dist/standalone/agents.js +1 -4
- package/dist/standalone/app-set.d.ts +20 -1
- package/dist/standalone/app-set.js +119 -60
- package/dist/standalone/computer.d.ts +10 -0
- package/dist/standalone/computer.js +43 -1
- package/dist/standalone/install-apps-cli.js +25 -3
- package/dist/starter-agent.d.ts +1 -3
- package/dist/starter-agent.js +4 -8
- package/docs/api/apps.md +53 -0
- package/docs/api/pack.md +252 -3
- package/package.json +3 -3
|
@@ -1505,7 +1505,6 @@ export class StandaloneAgentBase extends ShiitakeDO {
|
|
|
1505
1505
|
roster: [
|
|
1506
1506
|
...extensions.roster,
|
|
1507
1507
|
homeExtension({
|
|
1508
|
-
instructionsRoot: "",
|
|
1509
1508
|
computers: {
|
|
1510
1509
|
prepare: async () => {
|
|
1511
1510
|
await this.preparedComputerSnapshot();
|
|
@@ -2798,9 +2797,7 @@ export function standaloneAgents(env, scope) {
|
|
|
2798
2797
|
// AGENTS.md. A Home the owner already wrote to is left as it is. With
|
|
2799
2798
|
// no Home, the same section stays on the Agent until it has one.
|
|
2800
2799
|
seedHome: async (agentId) => {
|
|
2801
|
-
await seedStarterHome(
|
|
2802
|
-
if (path !== "AGENTS.md")
|
|
2803
|
-
throw new Error(`The starter seeds only AGENTS.md, not ${path}`);
|
|
2800
|
+
await seedStarterHome(async (content) => {
|
|
2804
2801
|
const result = await env.AGENTS.getByName(agentId).replaceInstructions(JSON.stringify(principal), null, content);
|
|
2805
2802
|
if (!("error" in result))
|
|
2806
2803
|
return;
|
|
@@ -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];
|
|
@@ -97,6 +97,16 @@ export declare class ComputerDO extends NativeComputerDO implements ComputerFetc
|
|
|
97
97
|
#private;
|
|
98
98
|
private readonly previewBindings;
|
|
99
99
|
constructor(state: DurableObjectState, previewBindings: StandaloneComputerOwnerEnv);
|
|
100
|
+
/**
|
|
101
|
+
* Once per Computer, copy an owner's Home AGENTS.md from the Workspace root,
|
|
102
|
+
* where the owner editor used to write it and no guest could see it, to
|
|
103
|
+
* /workspace/AGENTS.md, the file an Agent's relative path names. The root copy
|
|
104
|
+
* is kept. The copy pulls every attached guest first and happens only while
|
|
105
|
+
* /workspace/AGENTS.md is absent: when both exist, nothing changes, the
|
|
106
|
+
* conflict is logged and the Agent uses the /workspace file. A guest that
|
|
107
|
+
* cannot be pulled leaves the marker unset, so the next request tries again.
|
|
108
|
+
*/
|
|
109
|
+
protected prepareFiles(): Promise<void>;
|
|
100
110
|
/**
|
|
101
111
|
* The configured Computer predates the name record, and the container's
|
|
102
112
|
* object-id reconnect wakes it nameless after every redeploy; it learns its
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { agentWorkspacePath } from "@fungi.computer/computer/files";
|
|
1
2
|
import { PortAccessError } from "@fungi.computer/computer/port-access";
|
|
2
3
|
import { attachedBackendId, computerSizeSchema, defaultComputerSize, hostedBackingSchema, } from "@fungi.computer/computer/backing";
|
|
3
4
|
import { appMethodRefusalStatus, appMethodRefusedReplySchema, } from "@fungi.computer/agar/backend";
|
|
@@ -140,6 +141,8 @@ export function standaloneComputerSize(sql) {
|
|
|
140
141
|
? defaultComputerSize
|
|
141
142
|
: computerSizeSchema.parse(row.size);
|
|
142
143
|
}
|
|
144
|
+
/** Set once the Workspace root's Home AGENTS.md has been copied under /workspace. */
|
|
145
|
+
const homeInstructionsRootMarker = "home-instructions-root:v1";
|
|
143
146
|
/** Durable workspace and existing backings, with fleet checks at native acceptance. */
|
|
144
147
|
export class ComputerDO extends NativeComputerDO {
|
|
145
148
|
previewBindings;
|
|
@@ -155,6 +158,45 @@ export class ComputerDO extends NativeComputerDO {
|
|
|
155
158
|
});
|
|
156
159
|
this.previewBindings = previewBindings;
|
|
157
160
|
}
|
|
161
|
+
#homeInstructionsCopied;
|
|
162
|
+
#homeInstructionsDone = false;
|
|
163
|
+
/**
|
|
164
|
+
* Once per Computer, copy an owner's Home AGENTS.md from the Workspace root,
|
|
165
|
+
* where the owner editor used to write it and no guest could see it, to
|
|
166
|
+
* /workspace/AGENTS.md, the file an Agent's relative path names. The root copy
|
|
167
|
+
* is kept. The copy pulls every attached guest first and happens only while
|
|
168
|
+
* /workspace/AGENTS.md is absent: when both exist, nothing changes, the
|
|
169
|
+
* conflict is logged and the Agent uses the /workspace file. A guest that
|
|
170
|
+
* cannot be pulled leaves the marker unset, so the next request tries again.
|
|
171
|
+
*/
|
|
172
|
+
async prepareFiles() {
|
|
173
|
+
if (this.#homeInstructionsDone)
|
|
174
|
+
return;
|
|
175
|
+
this.#homeInstructionsCopied ??= this.#copyHomeInstructions().finally(() => {
|
|
176
|
+
this.#homeInstructionsCopied = undefined;
|
|
177
|
+
});
|
|
178
|
+
await this.#homeInstructionsCopied;
|
|
179
|
+
}
|
|
180
|
+
async #copyHomeInstructions() {
|
|
181
|
+
try {
|
|
182
|
+
if ((await this.state.storage.get(homeInstructionsRootMarker)) !== undefined) {
|
|
183
|
+
this.#homeInstructionsDone = true;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const copied = await this.copyWorkspaceFileIfFree("/AGENTS.md", agentWorkspacePath("AGENTS.md"));
|
|
187
|
+
if (copied === "unknown")
|
|
188
|
+
return;
|
|
189
|
+
if (copied === "conflict")
|
|
190
|
+
console.warn("home-instructions-root-conflict", {
|
|
191
|
+
computerId: this.#id(),
|
|
192
|
+
});
|
|
193
|
+
await this.state.storage.put(homeInstructionsRootMarker, true);
|
|
194
|
+
this.#homeInstructionsDone = true;
|
|
195
|
+
}
|
|
196
|
+
catch (cause) {
|
|
197
|
+
console.error("Home AGENTS.md copy under /workspace failed", cause);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
158
200
|
/**
|
|
159
201
|
* The configured Computer predates the name record, and the container's
|
|
160
202
|
* object-id reconnect wakes it nameless after every redeploy; it learns its
|
|
@@ -766,7 +808,7 @@ export function standaloneWorkspace(env, keysLive, selectedComputerId = env.OYST
|
|
|
766
808
|
*/
|
|
767
809
|
export function standaloneHomeInstructionsFile(computer, computerId, actor) {
|
|
768
810
|
const authority = grant(computerId, actor);
|
|
769
|
-
const path = "
|
|
811
|
+
const path = agentWorkspacePath("AGENTS.md");
|
|
770
812
|
return {
|
|
771
813
|
read: async () => {
|
|
772
814
|
const bytes = await computer.fileRead(authority, path);
|
|
@@ -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", [
|
package/dist/starter-agent.d.ts
CHANGED
|
@@ -14,9 +14,7 @@ export declare const starterAgent: {
|
|
|
14
14
|
readonly requestId: "starter-agent:v1";
|
|
15
15
|
};
|
|
16
16
|
/** Seed only a missing Home file; the host supplies an atomic create-if-absent. */
|
|
17
|
-
export declare function seedStarterHome(
|
|
18
|
-
/** Where this host keeps Home's AGENTS.md. */
|
|
19
|
-
instructionsPath: string, writeIfMissing: (path: string, content: string) => Promise<void>): Promise<void>;
|
|
17
|
+
export declare function seedStarterHome(writeIfMissing: (content: string) => Promise<void>): Promise<void>;
|
|
20
18
|
/** Why the last create or Home seed attempt failed, in plain words. */
|
|
21
19
|
export type StarterFailure = Readonly<{
|
|
22
20
|
reason: string;
|
package/dist/starter-agent.js
CHANGED
|
@@ -6,21 +6,17 @@ export const starterAgent = {
|
|
|
6
6
|
requestId: "starter-agent:v1",
|
|
7
7
|
};
|
|
8
8
|
/** Seed only a missing Home file; the host supplies an atomic create-if-absent. */
|
|
9
|
-
export async function seedStarterHome(
|
|
10
|
-
|
|
11
|
-
instructionsPath, writeIfMissing) {
|
|
12
|
-
await writeIfMissing(instructionsPath, starterHomeInstructions(`computer://home/${instructionsPath.replace(/^\//u, "")}`));
|
|
9
|
+
export async function seedStarterHome(writeIfMissing) {
|
|
10
|
+
await writeIfMissing(starterHomeInstructions);
|
|
13
11
|
}
|
|
14
12
|
/**
|
|
15
13
|
* The Home AGENTS.md a new Team's Agent starts with. It says nothing about
|
|
16
14
|
* money; the person and the Agent both edit it from here on.
|
|
17
15
|
*/
|
|
18
|
-
const starterHomeInstructions =
|
|
19
|
-
/** Where Home's AGENTS.md is read from on this host, as the Agent names it. */
|
|
20
|
-
location) => `# Shiitake's instructions
|
|
16
|
+
const starterHomeInstructions = `# Shiitake's instructions
|
|
21
17
|
|
|
22
18
|
These are my standing instructions. They live on my Computer at
|
|
23
|
-
|
|
19
|
+
computer://home/AGENTS.md and load at the start of every conversation. My
|
|
24
20
|
person and I both edit this file.
|
|
25
21
|
|
|
26
22
|
## First conversation
|
package/docs/api/apps.md
CHANGED
|
@@ -338,6 +338,38 @@ admission.
|
|
|
338
338
|
|
|
339
339
|
---
|
|
340
340
|
|
|
341
|
+
### InstallConfirmationLine
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
type InstallConfirmationLine = Readonly<{
|
|
345
|
+
capability: AppCapabilityId;
|
|
346
|
+
label: string;
|
|
347
|
+
description: string;
|
|
348
|
+
warning: string | null;
|
|
349
|
+
apps: readonly string[];
|
|
350
|
+
}>;
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
One declared permission as the install confirmation words it.
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
### InstallConfirmation
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
type InstallConfirmation = Readonly<{
|
|
361
|
+
granted: readonly InstallConfirmationLine[];
|
|
362
|
+
needsApproval: readonly InstallConfirmationLine[];
|
|
363
|
+
}>;
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Every permission an install declares, once, for one confirmation. `granted` is
|
|
367
|
+
what confirming approves; `needsApproval` is what stays refused until an owner
|
|
368
|
+
approves it. Both come from the rule the install reducer applies, so the list
|
|
369
|
+
cannot promise more or less than the install does.
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
341
373
|
### ResourceRef
|
|
342
374
|
|
|
343
375
|
```ts
|
|
@@ -1862,6 +1894,27 @@ stay outside this pure gate.
|
|
|
1862
1894
|
|
|
1863
1895
|
---
|
|
1864
1896
|
|
|
1897
|
+
### installConfirmation()
|
|
1898
|
+
|
|
1899
|
+
```ts
|
|
1900
|
+
function installConfirmation(role, apps): InstallConfirmation;
|
|
1901
|
+
```
|
|
1902
|
+
|
|
1903
|
+
Merge any number of Apps into one combined, once-per-permission list.
|
|
1904
|
+
|
|
1905
|
+
#### Parameters
|
|
1906
|
+
|
|
1907
|
+
| Parameter | Type |
|
|
1908
|
+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1909
|
+
| `role` | `"member"` \| `"owner"` \| `"admin"` \| `null` |
|
|
1910
|
+
| `apps` | readonly `Readonly`\<\{ `name`: `string`; `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"`)[]; \}\>[] |
|
|
1911
|
+
|
|
1912
|
+
#### Returns
|
|
1913
|
+
|
|
1914
|
+
[`InstallConfirmation`](#installconfirmation)
|
|
1915
|
+
|
|
1916
|
+
---
|
|
1917
|
+
|
|
1865
1918
|
### applyGrantCommand()
|
|
1866
1919
|
|
|
1867
1920
|
```ts
|