@fungi.computer/oyster 0.57.4 → 0.57.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed-metafiles.js +1 -1
- package/dist/embed-scripts.js +1 -1
- package/dist/standalone/install-apps-cli.d.ts +7 -0
- package/dist/standalone/install-apps-cli.js +15 -5
- package/dist/standalone/local-desktop.d.ts +20 -0
- package/dist/standalone/local-desktop.js +64 -0
- package/dist/standalone/try-cli.d.ts +12 -2
- package/dist/standalone/try-cli.js +28 -10
- package/package.json +2 -2
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Cli } from "@fungi.computer/lantern";
|
|
3
3
|
import { installStandaloneAppSet } from "./app-set.js";
|
|
4
|
+
/**
|
|
5
|
+
* The commit a checkout installs from. A checkout with uncommitted edits is
|
|
6
|
+
* the owner's own, so it is recorded as a commit holding those edits (made
|
|
7
|
+
* with `git stash create`, which leaves the stash and the tree alone), never
|
|
8
|
+
* as the release tag's commit it started from.
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkoutRevision(directory: string): string;
|
|
4
11
|
export declare function installApps(args: readonly string[], install?: typeof installStandaloneAppSet, ui?: Cli): Promise<void>;
|
|
5
12
|
export declare function runInstallAppsCli(args?: readonly string[]): Promise<void>;
|
|
@@ -44,6 +44,16 @@ Options:
|
|
|
44
44
|
--timings <file> write the build timings as JSON
|
|
45
45
|
-h, --help show this help
|
|
46
46
|
`;
|
|
47
|
+
/**
|
|
48
|
+
* The commit a checkout installs from. A checkout with uncommitted edits is
|
|
49
|
+
* the owner's own, so it is recorded as a commit holding those edits (made
|
|
50
|
+
* with `git stash create`, which leaves the stash and the tree alone), never
|
|
51
|
+
* as the release tag's commit it started from.
|
|
52
|
+
*/
|
|
53
|
+
export function checkoutRevision(directory) {
|
|
54
|
+
const git = (...args) => execFileSync("git", args, { cwd: directory, encoding: "utf8" }).trim();
|
|
55
|
+
return git("stash", "create") || git("rev-parse", "HEAD");
|
|
56
|
+
}
|
|
47
57
|
function missingVariableMessage(url, key) {
|
|
48
58
|
const lines = [];
|
|
49
59
|
if (!url)
|
|
@@ -132,11 +142,11 @@ export async function installApps(args, install = installStandaloneAppSet, ui =
|
|
|
132
142
|
};
|
|
133
143
|
else {
|
|
134
144
|
const directory = resolve(values.from);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
source = {
|
|
146
|
+
kind: "checkout",
|
|
147
|
+
directory,
|
|
148
|
+
revision: `git:${checkoutRevision(directory)}`,
|
|
149
|
+
};
|
|
140
150
|
}
|
|
141
151
|
const started = performance.now();
|
|
142
152
|
const { installed, failed, declined } = await install({
|
|
@@ -31,6 +31,26 @@ export declare function localStarterInstalled(input: Readonly<{
|
|
|
31
31
|
installationId: string;
|
|
32
32
|
signal?: AbortSignal;
|
|
33
33
|
}>): Promise<boolean>;
|
|
34
|
+
/** The commit each `v<version>` tag of one starter repository points at. */
|
|
35
|
+
export declare function starterTagCommits(listing: string): ReadonlyMap<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* Whether a saved starter is an untouched release from an older Oyster: built
|
|
38
|
+
* from another `v<version>` tag's commit, not this Oyster's. A revision that
|
|
39
|
+
* is in no tag is the owner's own edit, and stays theirs.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isOlderStarterRelease(sourceRevision: string, tag: string, commits: ReadonlyMap<string, string>): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether this machine's saved copy of a starter App was released by an older
|
|
44
|
+
* Oyster than this one, so it would run against a host it was not built for.
|
|
45
|
+
* When the release tags cannot be listed (offline, GitHub down, too slow) the
|
|
46
|
+
* saved App is kept and `warn` says why, once. Read-only.
|
|
47
|
+
*/
|
|
48
|
+
export declare function savedStarterIsOlder(app: StarterApp, input: Readonly<{
|
|
49
|
+
url: string;
|
|
50
|
+
key: string;
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
warn: (message: string) => void;
|
|
53
|
+
}>, repository?: string, timeoutMilliseconds?: number): Promise<boolean>;
|
|
34
54
|
/** The host-owned entry decides whether the saved desktop may run. Read-only. */
|
|
35
55
|
export declare function localDesktopState(input: Readonly<{
|
|
36
56
|
url: string;
|
|
@@ -84,6 +84,70 @@ export async function localStarterInstalled(input) {
|
|
|
84
84
|
.parse(await response.json())
|
|
85
85
|
.some((row) => row.installationId === input.installationId);
|
|
86
86
|
}
|
|
87
|
+
/** The commit each `v<version>` tag of one starter repository points at. */
|
|
88
|
+
export function starterTagCommits(listing) {
|
|
89
|
+
const commits = new Map();
|
|
90
|
+
for (const line of listing.split("\n")) {
|
|
91
|
+
const [commit, ref] = line.split("\t");
|
|
92
|
+
const match = /^refs\/tags\/(v[^^]+)(\^\{\})?$/u.exec(ref ?? "");
|
|
93
|
+
// An annotated tag lists its own object first and its commit as `^{}`.
|
|
94
|
+
if (commit &&
|
|
95
|
+
match?.[1] &&
|
|
96
|
+
(match[2] !== undefined || !commits.has(match[1])))
|
|
97
|
+
commits.set(match[1], commit);
|
|
98
|
+
}
|
|
99
|
+
return commits;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether a saved starter is an untouched release from an older Oyster: built
|
|
103
|
+
* from another `v<version>` tag's commit, not this Oyster's. A revision that
|
|
104
|
+
* is in no tag is the owner's own edit, and stays theirs.
|
|
105
|
+
*/
|
|
106
|
+
export function isOlderStarterRelease(sourceRevision, tag, commits) {
|
|
107
|
+
const current = commits.get(tag);
|
|
108
|
+
if (current === undefined || sourceRevision === `git:${current}`)
|
|
109
|
+
return false;
|
|
110
|
+
return [...commits.values()].some((commit) => sourceRevision === `git:${commit}`);
|
|
111
|
+
}
|
|
112
|
+
/** How long the release tags may take to list before the saved App is kept. */
|
|
113
|
+
const tagCheckTimeoutMilliseconds = 10_000;
|
|
114
|
+
/**
|
|
115
|
+
* Whether this machine's saved copy of a starter App was released by an older
|
|
116
|
+
* Oyster than this one, so it would run against a host it was not built for.
|
|
117
|
+
* When the release tags cannot be listed (offline, GitHub down, too slow) the
|
|
118
|
+
* saved App is kept and `warn` says why, once. Read-only.
|
|
119
|
+
*/
|
|
120
|
+
export async function savedStarterIsOlder(app, input, repository = repositoryUrl(app), timeoutMilliseconds = tagCheckTimeoutMilliseconds) {
|
|
121
|
+
const signal = input.signal ?? new AbortController().signal;
|
|
122
|
+
const response = await fetch(new URL("/api/installations", input.url), {
|
|
123
|
+
headers: { Authorization: `Bearer ${input.key}` },
|
|
124
|
+
signal,
|
|
125
|
+
});
|
|
126
|
+
if (!response.ok)
|
|
127
|
+
throw new Error(`Installation read failed (HTTP ${String(response.status)}).`);
|
|
128
|
+
const saved = installationRowsSchema
|
|
129
|
+
.parse(await response.json())
|
|
130
|
+
.find((row) => row.installationId === app.installationId);
|
|
131
|
+
if (saved?.status !== "enabled")
|
|
132
|
+
return false;
|
|
133
|
+
const timeout = AbortSignal.timeout(timeoutMilliseconds);
|
|
134
|
+
let listing;
|
|
135
|
+
try {
|
|
136
|
+
listing = await git(tmpdir(), ["ls-remote", "--tags", repository, "refs/tags/v*"], AbortSignal.any([signal, timeout]));
|
|
137
|
+
}
|
|
138
|
+
catch (cause) {
|
|
139
|
+
// A stop of the trial is not a failed check.
|
|
140
|
+
signal.throwIfAborted();
|
|
141
|
+
const reason = timeout.aborted
|
|
142
|
+
? `timed out after ${String(timeoutMilliseconds / 1000)}s`
|
|
143
|
+
: cause instanceof Error
|
|
144
|
+
? cause.message.replaceAll(/\s+/gu, " ").trim()
|
|
145
|
+
: String(cause);
|
|
146
|
+
input.warn(`Couldn't check for a newer ${app.displayName}: ${reason}; keeping the saved one.`);
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return isOlderStarterRelease(saved.release.artifact.provenance.sourceRevision, await starterReleaseTag(), starterTagCommits(listing));
|
|
150
|
+
}
|
|
87
151
|
/** The host-owned entry decides whether the saved desktop may run. Read-only. */
|
|
88
152
|
export async function localDesktopState(input) {
|
|
89
153
|
const request = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { startTrialComputer } from "./trial-computer.js";
|
|
2
2
|
import { type CredentialKeyring } from "@fungi.computer/veil/credential-store";
|
|
3
3
|
import { Cli } from "@fungi.computer/lantern";
|
|
4
|
-
import { type DesktopReadiness } from "./local-desktop.js";
|
|
4
|
+
import { installLocalStarter, localDesktopState, savedStarterIsOlder, localStarterInstalled, type DesktopReadiness } from "./local-desktop.js";
|
|
5
5
|
import { type StarterApp } from "./app-set.js";
|
|
6
6
|
import { type SignInLink } from "./sign-in-link.js";
|
|
7
7
|
import type { InstallingApp } from "@fungi.computer/nacre/workbench-directory";
|
|
@@ -43,6 +43,8 @@ export type TryEffects = Readonly<{
|
|
|
43
43
|
url: string;
|
|
44
44
|
key: string;
|
|
45
45
|
signal: AbortSignal;
|
|
46
|
+
/** Say something once that does not stop the install. */
|
|
47
|
+
warn: (message: string) => void;
|
|
46
48
|
}) => Promise<DesktopReadiness>;
|
|
47
49
|
/** Build and install one more starter App; resolves once it is installed. */
|
|
48
50
|
installStarter: (app: StarterApp, input: {
|
|
@@ -50,6 +52,7 @@ export type TryEffects = Readonly<{
|
|
|
50
52
|
key: string;
|
|
51
53
|
packageStoreDirectory: string;
|
|
52
54
|
signal: AbortSignal;
|
|
55
|
+
warn: (message: string) => void;
|
|
53
56
|
}) => Promise<"installed" | "already-installed">;
|
|
54
57
|
/** Tell the Oyster which starter Apps are not ready yet. */
|
|
55
58
|
reportStarters: (input: {
|
|
@@ -93,6 +96,13 @@ export type TrialKeychainEntry = Readonly<{
|
|
|
93
96
|
export type TrialKeychain = (account: string) => Promise<TrialKeychainEntry | undefined>;
|
|
94
97
|
/** Keep the trial KEK outside its database and deliver it to the Worker over stdin. */
|
|
95
98
|
export declare function prepareTryModelKeyCustody(directory: string, keychain?: TrialKeychain): Promise<CredentialKeyring>;
|
|
99
|
+
/** What `oyster try` asks of the starter Apps saved on a trial's Oyster. */
|
|
100
|
+
export type StarterInstalls = Readonly<{
|
|
101
|
+
desktopState: typeof localDesktopState;
|
|
102
|
+
installed: typeof localStarterInstalled;
|
|
103
|
+
isOlder: typeof savedStarterIsOlder;
|
|
104
|
+
install: typeof installLocalStarter;
|
|
105
|
+
}>;
|
|
96
106
|
/** The real trial effects; `keychain` holds the wrapping keys (the OS keychain by default). */
|
|
97
|
-
export declare const tryEffects: (keychain?: TrialKeychain) => TryEffects;
|
|
107
|
+
export declare const tryEffects: (keychain?: TrialKeychain, starters?: StarterInstalls) => TryEffects;
|
|
98
108
|
export declare function tryOyster(args: readonly string[], effects?: TryEffects, ui?: Cli, callerSignal?: AbortSignal): Promise<void>;
|
|
@@ -32,7 +32,7 @@ import { isDeepStrictEqual, parseArgs, parseEnv, stripVTControlCharacters, } fro
|
|
|
32
32
|
import { Cli } from "@fungi.computer/lantern";
|
|
33
33
|
import * as z from "zod";
|
|
34
34
|
import { installHelloApp } from "./hello-app.js";
|
|
35
|
-
import { desktopApp, installLocalStarter, localDesktopState, localStarterInstalled, localModelSetup, } from "./local-desktop.js";
|
|
35
|
+
import { desktopApp, installLocalStarter, localDesktopState, savedStarterIsOlder, localStarterInstalled, localModelSetup, } from "./local-desktop.js";
|
|
36
36
|
import { standaloneAppSet, trialStarterOrder, } from "./app-set.js";
|
|
37
37
|
import { startSignInLink } from "./sign-in-link.js";
|
|
38
38
|
import { reportTrialStarters, takeTrialRetries, } from "./trial-starters-client.js";
|
|
@@ -745,27 +745,35 @@ function isTryCancellation(cause, signal) {
|
|
|
745
745
|
(cause instanceof Error && cause.name === "AbortError") ||
|
|
746
746
|
cause instanceof InstallationObservationError));
|
|
747
747
|
}
|
|
748
|
+
const localStarterInstalls = {
|
|
749
|
+
desktopState: localDesktopState,
|
|
750
|
+
installed: localStarterInstalled,
|
|
751
|
+
isOlder: savedStarterIsOlder,
|
|
752
|
+
install: installLocalStarter,
|
|
753
|
+
};
|
|
748
754
|
/** The real trial effects; `keychain` holds the wrapping keys (the OS keychain by default). */
|
|
749
|
-
export const tryEffects = (keychain = osKeychain) => ({
|
|
755
|
+
export const tryEffects = (keychain = osKeychain, starters = localStarterInstalls) => ({
|
|
750
756
|
installDependencies: installTryDependencies,
|
|
751
757
|
startServer: (input) => startWrangler(input, keychain),
|
|
752
758
|
installHello: installHelloApp,
|
|
753
759
|
installDesktop: async ({ directory, ...input }) => {
|
|
754
760
|
process.env.PATH = `${join(directory, "node_modules", ".bin")}${delimiter}${process.env.PATH ?? ""}`;
|
|
755
|
-
const saved = await
|
|
756
|
-
|
|
761
|
+
const saved = await starters.desktopState(input);
|
|
762
|
+
// A desktop saved by an older Oyster is replaced by this Oyster's own.
|
|
763
|
+
if (saved !== "missing" && !(await starters.isOlder(desktopApp, input)))
|
|
757
764
|
return saved;
|
|
758
|
-
await
|
|
759
|
-
const installed = await
|
|
765
|
+
await starters.install(desktopApp, input);
|
|
766
|
+
const installed = await starters.desktopState(input);
|
|
760
767
|
return installed === "missing" ? "unavailable" : installed;
|
|
761
768
|
},
|
|
762
769
|
installStarter: async (app, input) => {
|
|
763
|
-
if (await
|
|
770
|
+
if ((await starters.installed({
|
|
764
771
|
...input,
|
|
765
772
|
installationId: app.installationId,
|
|
766
|
-
}))
|
|
773
|
+
})) &&
|
|
774
|
+
!(await starters.isOlder(app, input)))
|
|
767
775
|
return "already-installed";
|
|
768
|
-
await
|
|
776
|
+
await starters.install(app, input);
|
|
769
777
|
return "installed";
|
|
770
778
|
},
|
|
771
779
|
reportStarters: (input, installing) => reportTrialStarters({ ...input, installing }),
|
|
@@ -942,6 +950,9 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
|
|
|
942
950
|
}
|
|
943
951
|
});
|
|
944
952
|
const packageStoreDirectory = join(directory, ".oyster", "package-store");
|
|
953
|
+
const checkWarning = (message) => {
|
|
954
|
+
ui.warn(message, "Run it again once you are online to check.");
|
|
955
|
+
};
|
|
945
956
|
const desktop = await setupTask(fresh
|
|
946
957
|
? "Installing Hello and building Tourtois"
|
|
947
958
|
: "Installing Hello and checking Tourtois", async () => {
|
|
@@ -955,6 +966,7 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
|
|
|
955
966
|
url,
|
|
956
967
|
key,
|
|
957
968
|
signal: AbortSignal.any([signal, preparation.signal]),
|
|
969
|
+
warn: checkWarning,
|
|
958
970
|
};
|
|
959
971
|
void watchedExit.then(() => {
|
|
960
972
|
preparation.abort();
|
|
@@ -1073,7 +1085,13 @@ export async function tryOyster(args, effects = realEffects, ui = createTryCli(a
|
|
|
1073
1085
|
const stopped = () => trialSignal.aborted;
|
|
1074
1086
|
// What the desktop shows for each starter App that is not ready yet.
|
|
1075
1087
|
const pending = new Map();
|
|
1076
|
-
const trial = {
|
|
1088
|
+
const trial = {
|
|
1089
|
+
url,
|
|
1090
|
+
key,
|
|
1091
|
+
packageStoreDirectory,
|
|
1092
|
+
signal: trialSignal,
|
|
1093
|
+
warn: checkWarning,
|
|
1094
|
+
};
|
|
1077
1095
|
let publishing = Promise.resolve();
|
|
1078
1096
|
const publish = () => {
|
|
1079
1097
|
const installing = [...pending.values()];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/oyster",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.6",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Oyster by Fungi: open-source Apps for people and AI agents. Try with one command or run on your own Cloudflare account.",
|
|
6
6
|
"homepage": "https://docs.fungi.computer/oyster",
|
|
@@ -380,7 +380,7 @@
|
|
|
380
380
|
"@fungi.computer/lantern": "0.4.2",
|
|
381
381
|
"@fungi.computer/mycelium": "0.4.12",
|
|
382
382
|
"@fungi.computer/nacre": "0.9.5",
|
|
383
|
-
"@fungi.computer/parakeet": "0.17.
|
|
383
|
+
"@fungi.computer/parakeet": "0.17.6",
|
|
384
384
|
"@fungi.computer/puffball": "0.15.0",
|
|
385
385
|
"@fungi.computer/seam": "0.2.7",
|
|
386
386
|
"@fungi.computer/shiitake": "0.22.7",
|