@fungi.computer/oyster 0.13.0 → 0.13.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/dist/build/candidate-cli.mjs +257 -142
- package/dist/build/definition-emission.js +17 -3
- package/dist/build/local-build.d.ts +6 -0
- package/dist/build/local-build.js +104 -91
- package/dist/build/process-group.d.ts +6 -0
- package/dist/build/process-group.js +92 -0
- package/dist/build.d.ts +1 -1
- package/dist/build.js +1 -1
- package/dist/host-page-assets.js +1 -1
- package/dist/host-page.d.ts +6 -1
- package/dist/host-page.js +40 -0
- package/dist/host.js +8 -8
- package/dist/pack.d.ts +3 -1
- package/dist/pack.js +28 -7
- package/dist/page/app-permissions.js +3 -13
- package/dist/page-script.js +1 -1
- package/dist/standalone/hello-app.d.ts +4 -1
- package/dist/standalone/hello-app.js +67 -22
- package/dist/standalone/hello-lesson.d.ts +2 -0
- package/dist/standalone/hello-lesson.js +36 -0
- package/dist/standalone/local-desktop.d.ts +6 -4
- package/dist/standalone/local-desktop.js +39 -20
- package/dist/standalone/sign-in-link.d.ts +2 -1
- package/dist/standalone/sign-in-link.js +58 -17
- package/dist/standalone/try-cli.d.ts +12 -9
- package/dist/standalone/try-cli.js +402 -137
- package/docs/api/pack.md +3 -2
- package/package.json +8 -8
package/dist/host-page.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type AppPermissionsViewData } from "./apps/permissions.js";
|
|
1
2
|
/** Human-facing states only. API refusals keep their original wire format. */
|
|
2
|
-
export type HostPageState = "root" | "empty" | "login" | "login-invalid" | "key-help" | "signing-in" | "link-expired" | "not-found" | "server-error" | "access-denied" | "desktop-missing";
|
|
3
|
+
export type HostPageState = "permissions" | "root" | "empty" | "login" | "login-invalid" | "key-help" | "signing-in" | "link-expired" | "not-found" | "server-error" | "access-denied" | "desktop-missing";
|
|
3
4
|
export type HostPageOptions = Readonly<{
|
|
4
5
|
state: HostPageState;
|
|
5
6
|
title?: string;
|
|
@@ -19,6 +20,10 @@ export type HostPageOptions = Readonly<{
|
|
|
19
20
|
action: string;
|
|
20
21
|
key: string;
|
|
21
22
|
}>;
|
|
23
|
+
permissions?: Readonly<{
|
|
24
|
+
config: AppPermissionsViewData;
|
|
25
|
+
script: string;
|
|
26
|
+
}>;
|
|
22
27
|
}>;
|
|
23
28
|
/** Serve only qualified build outputs; no filesystem or runtime image tools. */
|
|
24
29
|
export declare function hostPageAsset(path: string): Promise<Response>;
|
package/dist/host-page.js
CHANGED
|
@@ -5,8 +5,15 @@ import { Button } from "@fungi.computer/caps/components/button";
|
|
|
5
5
|
import { Input } from "@fungi.computer/caps/components/input";
|
|
6
6
|
import { Card, CardHeader, CardTitle, CardContent, } from "@fungi.computer/caps/components/card";
|
|
7
7
|
import { fungiFaviconHref } from "@fungi.computer/sigils/favicon";
|
|
8
|
+
import { permissionScreen, } from "./apps/permissions.js";
|
|
9
|
+
import { permissionCatalog } from "./apps/catalog.js";
|
|
8
10
|
const docs = "https://docs.fungi.computer";
|
|
9
11
|
const copy = {
|
|
12
|
+
permissions: [
|
|
13
|
+
"Choose what this App can do.",
|
|
14
|
+
"Oyster · App permissions",
|
|
15
|
+
"Review the requested access. To decline, return to Apps without saving or confirming a change.",
|
|
16
|
+
],
|
|
10
17
|
root: [
|
|
11
18
|
"Your Apps, all together.",
|
|
12
19
|
"Oyster · App directory",
|
|
@@ -64,6 +71,12 @@ const copy = {
|
|
|
64
71
|
],
|
|
65
72
|
};
|
|
66
73
|
const abilities = {
|
|
74
|
+
permissions: [
|
|
75
|
+
"You choose the access",
|
|
76
|
+
"Check the App and Release below.",
|
|
77
|
+
"Review each permission before saving.",
|
|
78
|
+
"Leave unchanged if you are unsure.",
|
|
79
|
+
],
|
|
67
80
|
root: [
|
|
68
81
|
"Choose your next App",
|
|
69
82
|
"Open an App from the directory.",
|
|
@@ -159,6 +172,22 @@ function pageContent(options, url) {
|
|
|
159
172
|
const { state, signIn } = options;
|
|
160
173
|
const content = [];
|
|
161
174
|
const actions = [];
|
|
175
|
+
if (state === "permissions" && options.permissions) {
|
|
176
|
+
const { config } = options.permissions;
|
|
177
|
+
const screen = permissionScreen({
|
|
178
|
+
...config.permissions,
|
|
179
|
+
resources: config.resources,
|
|
180
|
+
canEdit: config.canEdit,
|
|
181
|
+
});
|
|
182
|
+
content.push(h("h2", null, `${config.appName} permissions`), h("p", { className: "detail" }, "App: ", config.appId, h("br"), "Installation: ", config.installationId, h("br"), "Release: ", h("code", null, config.artifactDigest)), h("div", { id: "oyster-consent" }, h("p", { role: "status" }, "Changes apply only after you save or confirm."), h("ul", { className: "form-stack" }, ...config.permissions.declaredOperations.capabilities.map(({ capability }) => h("li", { key: capability }, h("strong", null, permissionCatalog[capability].label, permissionCatalog[capability].consent === "affordance"
|
|
183
|
+
? " · No approval required"
|
|
184
|
+
: screen.pending.includes(capability)
|
|
185
|
+
? " · Needs review"
|
|
186
|
+
: " · Approved"), h("p", null, permissionCatalog[capability].description), permissionCatalog[capability].warning
|
|
187
|
+
? h("p", null, permissionCatalog[capability].warning)
|
|
188
|
+
: null))), h("noscript", null, h("p", null, "JavaScript is needed to review and change permissions. No permissions have changed.")), h("div", { className: "actions" }, link("Back to Apps", url("/"), true))));
|
|
189
|
+
return { content, actions };
|
|
190
|
+
}
|
|
162
191
|
if (state === "login" || state === "login-invalid") {
|
|
163
192
|
content.push(h("form", { method: "post", action: url("/login"), className: "form-stack" }, state === "login-invalid"
|
|
164
193
|
? h("p", { className: "error-copy", role: "alert" }, "The key wasn’t accepted. Please check it and try again.")
|
|
@@ -208,6 +237,7 @@ function illustration(state, assetUrl) {
|
|
|
208
237
|
const eyebrow = copy[state][1];
|
|
209
238
|
const [ability, ...steps] = abilities[state];
|
|
210
239
|
const keyArt = [
|
|
240
|
+
"permissions",
|
|
211
241
|
"login",
|
|
212
242
|
"login-invalid",
|
|
213
243
|
"key-help",
|
|
@@ -287,6 +317,16 @@ export async function hostPage(options) {
|
|
|
287
317
|
? "Your key is sent only to this Oyster."
|
|
288
318
|
: h("a", { href: `${docs}/agents/index.md` }, "Hand your LLM the setup guide →")))), h("footer", { className: "page-footer" }, h("span", null, "Oyster · A home for your Apps")), assetUrl("host-page.js")
|
|
289
319
|
? h("script", { type: "module", src: assetUrl("host-page.js") })
|
|
320
|
+
: null, options.permissions
|
|
321
|
+
? h("script", {
|
|
322
|
+
type: "application/json",
|
|
323
|
+
id: "oyster-consent-config",
|
|
324
|
+
dangerouslySetInnerHTML: {
|
|
325
|
+
__html: JSON.stringify(options.permissions.config).replaceAll("<", "\\u003c"),
|
|
326
|
+
},
|
|
327
|
+
})
|
|
328
|
+
: null, options.permissions
|
|
329
|
+
? h("script", { type: "module", src: options.permissions.script })
|
|
290
330
|
: null)));
|
|
291
331
|
return new Response(`<!doctype html>${body}`, {
|
|
292
332
|
status: options.status ?? 200,
|
package/dist/host.js
CHANGED
|
@@ -708,15 +708,15 @@ export function oysterRouteTable(host) {
|
|
|
708
708
|
return Response.json(config, {
|
|
709
709
|
headers: { "Cache-Control": "no-store" },
|
|
710
710
|
});
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
"Content-Security-Policy": "default-src 'none'; script-src 'self'; connect-src 'self'; style-src 'self' 'unsafe-inline'; font-src data:; base-uri 'none'; form-action 'self'; frame-ancestors 'self'",
|
|
718
|
-
},
|
|
711
|
+
const pageAssets = await assets();
|
|
712
|
+
const response = await hostPage({
|
|
713
|
+
state: "permissions",
|
|
714
|
+
title,
|
|
715
|
+
stylesheets: [pageAssets.loginFonts.path, pageAssets.styles.path],
|
|
716
|
+
permissions: { config, script: pageAssets.grantConsent.path },
|
|
719
717
|
});
|
|
718
|
+
response.headers.set("Content-Security-Policy", "default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src data:; base-uri 'none'; form-action 'self'; frame-ancestors 'self'");
|
|
719
|
+
return response;
|
|
720
720
|
});
|
|
721
721
|
table.put("/api/installations/:installationId/grants",
|
|
722
722
|
// Capability-origin requests cannot become direct owner consent.
|
package/dist/pack.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export type PackOptions = Readonly<{
|
|
|
20
20
|
packageStoreDirectory?: string;
|
|
21
21
|
/** Where to write `release.json` and the immutable `artifacts/` directory. */
|
|
22
22
|
outDirectory: string;
|
|
23
|
+
/** Interrupt local preparation and await its owned scratch/process cleanup. */
|
|
24
|
+
signal?: AbortSignal;
|
|
23
25
|
}>;
|
|
24
26
|
/** A packed Release on disk. */
|
|
25
27
|
export type PackedRelease = Readonly<{
|
|
@@ -37,7 +39,7 @@ export declare function packRelease(options: PackOptions): Promise<PackedRelease
|
|
|
37
39
|
* and install it, or switch an existing installation to it
|
|
38
40
|
* ({@link installRelease}).
|
|
39
41
|
* `waitMs` starts with the upload/observation phase after packing; a supplied
|
|
40
|
-
* caller signal retains its original lifetime
|
|
42
|
+
* caller signal also interrupts packing and retains its original lifetime.
|
|
41
43
|
*/
|
|
42
44
|
export declare function installFromSource(input: Readonly<{
|
|
43
45
|
appId: string;
|
package/dist/pack.js
CHANGED
|
@@ -2,6 +2,8 @@ import { mkdir, mkdtemp, readdir, readFile, rm, writeFile, } from "node:fs/promi
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join, relative, resolve } from "node:path";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Cause from "effect/Cause";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
5
7
|
import * as Schema from "effect/Schema";
|
|
6
8
|
import { releaseSchema } from "@fungi.computer/puffball/effect";
|
|
7
9
|
import { installOnOyster, installationObservationSignal, completedInstallationResponse, } from "./installation-client.js";
|
|
@@ -23,6 +25,7 @@ async function filesUnder(directory) {
|
|
|
23
25
|
.sort();
|
|
24
26
|
}
|
|
25
27
|
async function packCapturedSource(options, sourceCapture) {
|
|
28
|
+
options.signal?.throwIfAborted();
|
|
26
29
|
const revision = parseSourceRevision(options.sourceRevision);
|
|
27
30
|
const out = resolve(options.outDirectory);
|
|
28
31
|
const artifactsDirectory = join(out, "artifacts");
|
|
@@ -33,14 +36,30 @@ async function packCapturedSource(options, sourceCapture) {
|
|
|
33
36
|
? {}
|
|
34
37
|
: { packageStoreDirectory: options.packageStoreDirectory }),
|
|
35
38
|
});
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const packed = await Effect.runPromiseExit(Effect.gen(function* () {
|
|
40
|
+
const prepared = yield* Effect.scoped(preparer.prepareCandidate(parseReleaseId(options.releaseId ??
|
|
41
|
+
`rel_${revision.slice("git:".length, "git:".length + 12)}`)));
|
|
42
|
+
// These are local artifact writes, not host installation admission.
|
|
43
|
+
// Settle them before the caller may remove its output directory.
|
|
44
|
+
return yield* Effect.uninterruptible(commitPreparedCandidate(prepared, {
|
|
45
|
+
artifactWriter: createLocalArtifactWriter(artifactsDirectory, options.recipe.assets),
|
|
46
|
+
releaseCatalog: { createRelease: (value) => Promise.resolve(value) },
|
|
47
|
+
}));
|
|
48
|
+
}), { signal: options.signal });
|
|
49
|
+
if (Exit.isFailure(packed)) {
|
|
50
|
+
// Scope cleanup defects must not disappear behind a simultaneous build failure.
|
|
51
|
+
const defect = packed.cause.reasons.find(Cause.isDieReason);
|
|
52
|
+
if (defect !== undefined)
|
|
53
|
+
throw defect.defect;
|
|
54
|
+
if (Cause.hasInterruptsOnly(packed.cause))
|
|
55
|
+
options.signal?.throwIfAborted();
|
|
56
|
+
throw Cause.squash(packed.cause);
|
|
57
|
+
}
|
|
58
|
+
const release = packed.value;
|
|
59
|
+
options.signal?.throwIfAborted();
|
|
42
60
|
await mkdir(out, { recursive: true });
|
|
43
61
|
await writeFile(join(out, "release.json"), `${Schema.encodeUnknownSync(Schema.fromJsonString(releaseSchema))(release)}\n`);
|
|
62
|
+
options.signal?.throwIfAborted();
|
|
44
63
|
const artifacts = (await filesUnder(artifactsDirectory)).map((path) => ({
|
|
45
64
|
artifactRef: parseArtifactRef(`artifact:${relative(artifactsDirectory, path)}`),
|
|
46
65
|
path,
|
|
@@ -56,7 +75,7 @@ export async function packRelease(options) {
|
|
|
56
75
|
* and install it, or switch an existing installation to it
|
|
57
76
|
* ({@link installRelease}).
|
|
58
77
|
* `waitMs` starts with the upload/observation phase after packing; a supplied
|
|
59
|
-
* caller signal retains its original lifetime
|
|
78
|
+
* caller signal also interrupts packing and retains its original lifetime.
|
|
60
79
|
*/
|
|
61
80
|
export async function installFromSource(input) {
|
|
62
81
|
const outDirectory = await mkdtemp(join(tmpdir(), "oyster-source-release-"));
|
|
@@ -67,6 +86,8 @@ export async function installFromSource(input) {
|
|
|
67
86
|
sourceRevision: input.source.sourceRevision,
|
|
68
87
|
outDirectory,
|
|
69
88
|
};
|
|
89
|
+
if (input.signal !== undefined)
|
|
90
|
+
options = { ...options, signal: input.signal };
|
|
70
91
|
if (input.releaseId !== undefined)
|
|
71
92
|
options = { ...options, releaseId: input.releaseId };
|
|
72
93
|
if (input.packageStoreDirectory !== undefined)
|
|
@@ -262,17 +262,7 @@ function ShellPermissionRow({ column, changed, otherChanges, disabled, onToggle,
|
|
|
262
262
|
gap: "var(--spacing-sm)",
|
|
263
263
|
padding: 0,
|
|
264
264
|
minHeight: 36,
|
|
265
|
-
}, children: [_jsx(Sigil, { name: column.sigil, size: 20 }), _jsxs("div", { style: {
|
|
266
|
-
display: "flex",
|
|
267
|
-
alignItems: "baseline",
|
|
268
|
-
gap: "var(--spacing-sm)",
|
|
269
|
-
minWidth: 0,
|
|
270
|
-
}, children: [_jsx("strong", { style: { whiteSpace: "nowrap", flexShrink: 0 }, children: column.label }), _jsx("span", { title: column.description, style: {
|
|
271
|
-
color: "var(--stipe-fg-muted)",
|
|
272
|
-
whiteSpace: "nowrap",
|
|
273
|
-
overflow: "hidden",
|
|
274
|
-
textOverflow: "ellipsis",
|
|
275
|
-
}, children: column.description })] }), _jsxs("div", { style: {
|
|
265
|
+
}, children: [_jsx(Sigil, { name: column.sigil, size: 20 }), _jsx("strong", { children: column.label }), _jsxs("div", { style: {
|
|
276
266
|
display: "flex",
|
|
277
267
|
alignItems: "center",
|
|
278
268
|
gap: "var(--spacing-sm)",
|
|
@@ -280,11 +270,11 @@ function ShellPermissionRow({ column, changed, otherChanges, disabled, onToggle,
|
|
|
280
270
|
? "Shell change not saved"
|
|
281
271
|
: on
|
|
282
272
|
? "Shell allowed"
|
|
283
|
-
: "Shell not allowed" }), _jsx(Button, { type: "button", size: "xs", variant: changed || !on ? "outline" : "ghost-destructive", disabled: disabled, onClick: changed ? onCancel : onToggle, children: changed ? "Cancel" : on ? "Revoke" : "Allow" })] })] }) }),
|
|
273
|
+
: "Shell not allowed" }), _jsx(Button, { type: "button", size: "xs", variant: changed || !on ? "outline" : "ghost-destructive", disabled: disabled, onClick: changed ? onCancel : onToggle, children: changed ? "Cancel" : on ? "Revoke" : "Allow" })] })] }) }), _jsxs("p", { style: {
|
|
284
274
|
margin: 0,
|
|
285
275
|
color: "var(--stipe-fg-muted)",
|
|
286
276
|
fontSize: "var(--text-sm)",
|
|
287
|
-
}, children: column.warning }), changed && (_jsx(FormFooter, { divider: false, status: otherChanges
|
|
277
|
+
}, children: [_jsx("span", { style: { display: "block" }, children: column.description }), column.warning] }), changed && (_jsx(FormFooter, { divider: false, status: otherChanges
|
|
288
278
|
? "Save all permission edits, including Shell access?"
|
|
289
279
|
: on
|
|
290
280
|
? "Allow Shell full access?"
|