@fungi.computer/oyster 0.32.0 → 0.34.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 +59 -0
- package/dist/app-sandbox.d.ts +2 -2
- package/dist/app-sandbox.js +2 -2
- package/dist/app-test-copies.d.ts +87 -0
- package/dist/app-test-copies.js +170 -0
- package/dist/app-test-copy-page.d.ts +4 -0
- package/dist/app-test-copy-page.js +89 -0
- package/dist/approval-deadline.d.ts +2 -0
- package/dist/approval-deadline.js +7 -0
- package/dist/approval-home.d.ts +26 -3
- package/dist/approval-home.js +148 -18
- package/dist/apps/index.d.ts +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/browser/operations.d.ts +1 -1
- package/dist/cloudflare.d.ts +68 -3
- package/dist/cloudflare.js +214 -3
- package/dist/embed-metafiles.js +2 -2
- package/dist/embed-scripts.js +1 -1
- package/dist/host.d.ts +20 -4
- package/dist/host.js +314 -3
- package/dist/installation-operations.d.ts +247 -8
- package/dist/installation-operations.js +145 -7
- package/dist/installation-recovery-page.d.ts +24 -0
- package/dist/installation-recovery-page.js +168 -0
- package/dist/mcp.js +42 -13
- package/dist/older-oyster-store.d.ts +1 -1
- package/dist/older-oyster-store.js +2 -4
- package/dist/page/app-permissions.js +8 -7
- package/dist/page/computer-handles.d.ts +0 -1
- package/dist/page/mount.d.ts +2 -101
- package/dist/page/mount.js +1 -22
- package/dist/page-config.d.ts +102 -0
- package/dist/page-config.js +24 -0
- package/dist/page-script.js +2 -2
- package/dist/platform-skills.generated.d.ts +5 -2
- package/dist/platform-skills.generated.js +6 -2
- package/dist/recovery-style.d.ts +5 -0
- package/dist/recovery-style.js +32 -0
- package/dist/standalone/agents.d.ts +1 -1
- package/dist/standalone/agents.js +43 -7
- package/dist/standalone/computer-fleet.js +3 -0
- package/dist/standalone/computer.d.ts +6 -2
- package/dist/standalone/computer.js +27 -14
- package/dist/standalone/media.js +7 -2
- package/dist/standalone/preview.d.ts +21 -20
- package/dist/standalone/preview.js +147 -151
- package/dist/standalone/registry.d.ts +14 -21
- package/dist/standalone/registry.js +74 -28
- package/dist/standalone/worker.js +6 -3
- package/dist/starter-agent.d.ts +6 -2
- package/dist/starter-agent.js +25 -4
- package/dist/upgrade/old-worker-http.d.ts +2 -0
- package/dist/upgrade/old-worker-http.js +22 -0
- package/dist/upgrade/old-worker-readonly.d.ts +14 -0
- package/dist/upgrade/old-worker-readonly.js +22 -0
- package/dist/upgrade/old-worker-sql.d.ts +10 -0
- package/dist/upgrade/old-worker-sql.js +68 -0
- package/dist/upgrade/old-worker-stream.d.ts +12 -0
- package/dist/upgrade/old-worker-stream.js +54 -0
- package/dist/upgrade/private-stage.d.ts +23 -0
- package/dist/upgrade/private-stage.js +109 -0
- package/dist/upgrade/standalone-001.d.ts +16 -0
- package/dist/upgrade/standalone-001.js +31 -0
- package/dist/upgrade/standalone-01.d.ts +37 -0
- package/dist/upgrade/standalone-01.js +55 -0
- package/dist/upgrade/standalone-02.d.ts +37 -0
- package/dist/upgrade/standalone-02.js +55 -0
- package/dist/workers.d.ts +45 -14
- package/dist/workers.js +198 -21
- package/docs/api/README.md +8 -3
- package/docs/api/apps.md +21 -0
- package/docs/api/cloudflare.md +57 -0
- package/docs/api/host.md +263 -25
- package/docs/api/page/mount.md +13 -81
- package/docs/api/workers-git.md +246 -1
- package/docs/api/workers.md +518 -95
- package/package.json +38 -24
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { html } from "hono/html";
|
|
2
|
+
import { recoveryStyle } from "./recovery-style.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { appTestCopySchema, } from "./app-test-copies.js";
|
|
5
|
+
import { installationCommandIds, installationRequestIdSchema, installationRecoverySelectionSchema, } from "./installation-operations.js";
|
|
6
|
+
export const installationRecoveryFormSchema = installationRecoverySelectionSchema.extend({
|
|
7
|
+
authorityVersion: z.coerce
|
|
8
|
+
.number()
|
|
9
|
+
.pipe(installationRecoverySelectionSchema.shape.authorityVersion),
|
|
10
|
+
requestId: installationRequestIdSchema,
|
|
11
|
+
});
|
|
12
|
+
/** Discard names a resource, not the creation request whose receipt may expire. */
|
|
13
|
+
export const appTestCopyDiscardFormSchema = installationRecoveryFormSchema
|
|
14
|
+
.omit({ requestId: true })
|
|
15
|
+
.extend({ copyId: appTestCopySchema.shape.copyId });
|
|
16
|
+
const fields = (authorityVersion, storeGeneration) => html `
|
|
17
|
+
<input type="hidden" name="authorityVersion" value="${authorityVersion}" />
|
|
18
|
+
<input type="hidden" name="storeGeneration" value="${storeGeneration}" />
|
|
19
|
+
`;
|
|
20
|
+
const rollbackMessage = (operation) => {
|
|
21
|
+
const app = operation.installationId;
|
|
22
|
+
switch (operation.state) {
|
|
23
|
+
case "pending":
|
|
24
|
+
return `Rolling back ${app}…`;
|
|
25
|
+
case "succeeded":
|
|
26
|
+
return `Rolled back ${app}`;
|
|
27
|
+
case "refused":
|
|
28
|
+
return `Rollback failed: ${operation.code.replaceAll("_", " ")}`;
|
|
29
|
+
case "unconfirmed":
|
|
30
|
+
return `Rollback not confirmed (${operation.outcome.replaceAll("_", " ")}). Check again.`;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/** No selected App, editable Shell, JavaScript or asset loader is needed. */
|
|
34
|
+
export async function installationRecoveryPage(entries, operation,
|
|
35
|
+
/** The App whose rollback awaits an in-page confirmation. */
|
|
36
|
+
confirming = null) {
|
|
37
|
+
return new Response(await html `<!doctype html>
|
|
38
|
+
<html lang="en">
|
|
39
|
+
<meta charset="utf-8" />
|
|
40
|
+
<meta name="viewport" content="width=device-width" />
|
|
41
|
+
<title>App recovery</title>
|
|
42
|
+
${recoveryStyle}
|
|
43
|
+
<main>
|
|
44
|
+
<h1>App recovery</h1>
|
|
45
|
+
<p class="lede">
|
|
46
|
+
Roll an App back to its previous version. Your App's data stays as
|
|
47
|
+
it is; this doesn't undo anything the App already did.
|
|
48
|
+
</p>
|
|
49
|
+
${operation === null
|
|
50
|
+
? ""
|
|
51
|
+
: html `<div class="card" role="status">
|
|
52
|
+
<p><strong>${rollbackMessage(operation)}</strong></p>
|
|
53
|
+
<p><a href="">Check again</a></p>
|
|
54
|
+
</div>`}
|
|
55
|
+
${entries.map(({ installation, recovery, copy, copyAuthority }) => html `
|
|
56
|
+
<section class="card">
|
|
57
|
+
<h2>${installation.installationId}</h2>
|
|
58
|
+
<p>
|
|
59
|
+
Running: current version
|
|
60
|
+
<small class="muted">${installation.release.releaseId}</small>
|
|
61
|
+
</p>
|
|
62
|
+
${recovery === null
|
|
63
|
+
? html `<p class="muted">
|
|
64
|
+
No earlier version to roll back to yet.
|
|
65
|
+
</p>`
|
|
66
|
+
: html `
|
|
67
|
+
<p>
|
|
68
|
+
Can roll back to: previous version
|
|
69
|
+
<small class="muted"
|
|
70
|
+
>${recovery.release.releaseId}</small
|
|
71
|
+
>
|
|
72
|
+
</p>
|
|
73
|
+
<p>
|
|
74
|
+
Last check:
|
|
75
|
+
${recovery.uiCheck.kind.replaceAll("_", " ")}
|
|
76
|
+
${recovery.uiCheck.kind === "not_checked"
|
|
77
|
+
? html `<small class="muted"
|
|
78
|
+
>${recovery.uiCheck.code}</small
|
|
79
|
+
>`
|
|
80
|
+
: ""}
|
|
81
|
+
</p>
|
|
82
|
+
${confirming === installation.installationId
|
|
83
|
+
? html `<form
|
|
84
|
+
method="post"
|
|
85
|
+
action="/recovery/${installation.installationId}/rollback"
|
|
86
|
+
role="alertdialog"
|
|
87
|
+
aria-label="Confirm rollback"
|
|
88
|
+
>
|
|
89
|
+
<p>
|
|
90
|
+
<strong
|
|
91
|
+
>Roll back ${installation.installationId} to
|
|
92
|
+
the previous version?</strong
|
|
93
|
+
>
|
|
94
|
+
</p>
|
|
95
|
+
${fields(recovery.authorityVersion, recovery.storeGeneration)}
|
|
96
|
+
<input
|
|
97
|
+
type="hidden"
|
|
98
|
+
name="requestId"
|
|
99
|
+
value="${installationCommandIds.request.generate()}"
|
|
100
|
+
/>
|
|
101
|
+
<div class="row">
|
|
102
|
+
<button type="submit" class="primary">
|
|
103
|
+
Roll back
|
|
104
|
+
</button>
|
|
105
|
+
<a href="/recovery">Cancel</a>
|
|
106
|
+
</div>
|
|
107
|
+
</form>`
|
|
108
|
+
: html `<div class="row">
|
|
109
|
+
<a
|
|
110
|
+
class="button primary"
|
|
111
|
+
href="/recovery?confirm=${installation.installationId}"
|
|
112
|
+
>Roll back</a
|
|
113
|
+
>
|
|
114
|
+
</div>`}
|
|
115
|
+
`}
|
|
116
|
+
${copyAuthority === null
|
|
117
|
+
? html `<p class="muted">
|
|
118
|
+
Test copy not available for this App.
|
|
119
|
+
</p>`
|
|
120
|
+
: copy === null
|
|
121
|
+
? html `<form
|
|
122
|
+
method="post"
|
|
123
|
+
action="/recovery/${installation.installationId}/test-copy"
|
|
124
|
+
>
|
|
125
|
+
${fields(copyAuthority.selection.authorityVersion, copyAuthority.storeGeneration)}
|
|
126
|
+
<input
|
|
127
|
+
type="hidden"
|
|
128
|
+
name="requestId"
|
|
129
|
+
value="${installationCommandIds.request.generate()}"
|
|
130
|
+
/>
|
|
131
|
+
<div class="row">
|
|
132
|
+
<button type="submit">Open test copy</button>
|
|
133
|
+
</div>
|
|
134
|
+
</form>`
|
|
135
|
+
: html `<p>
|
|
136
|
+
<a
|
|
137
|
+
href="/recovery/${installation.installationId}/test-copy/${copy.copyId}"
|
|
138
|
+
>Open test copy</a
|
|
139
|
+
>
|
|
140
|
+
<small class="muted"
|
|
141
|
+
>expires at
|
|
142
|
+
${new Date(copy.expiresAt).toISOString()}</small
|
|
143
|
+
>
|
|
144
|
+
</p>
|
|
145
|
+
<form
|
|
146
|
+
method="post"
|
|
147
|
+
action="/recovery/${installation.installationId}/test-copy/${copy.copyId}/discard"
|
|
148
|
+
>
|
|
149
|
+
${fields(copy.selection.authorityVersion, copy.storeGeneration)}
|
|
150
|
+
<input
|
|
151
|
+
type="hidden"
|
|
152
|
+
name="copyId"
|
|
153
|
+
value="${copy.copyId}"
|
|
154
|
+
/>
|
|
155
|
+
<button type="submit">Discard test copy</button>
|
|
156
|
+
</form>`}
|
|
157
|
+
</section>
|
|
158
|
+
`)}
|
|
159
|
+
</main>
|
|
160
|
+
</html>`, {
|
|
161
|
+
headers: {
|
|
162
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
163
|
+
"Cache-Control": "no-store",
|
|
164
|
+
"X-Content-Type-Options": "nosniff",
|
|
165
|
+
"Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'",
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
package/dist/mcp.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { computerSizeSchema } from "@fungi.computer/computer/backing";
|
|
3
|
-
import {
|
|
3
|
+
import { ApprovalRefusalSchema } from "@fungi.computer/approvals";
|
|
4
|
+
import { oysterApprovalDeadlineAt } from "./approval-deadline.js";
|
|
4
5
|
import { admits } from "./apps/gate.js";
|
|
5
6
|
import { createMcpWorkflowControl, WORKFLOW_CONTROL_MODULE_ID, } from "./workflows.js";
|
|
6
7
|
import { causeClass } from "./cause-class.js";
|
|
@@ -9,7 +10,7 @@ import { appToolPolicySchema } from "./apps/tools.js";
|
|
|
9
10
|
import { emptyAppDeclaration } from "@fungi.computer/puffball/app";
|
|
10
11
|
import { admittedMethodCallerFacts, invocationCallerContext, } from "./invocation.js";
|
|
11
12
|
import { guestLimits } from "./guest-policy.js";
|
|
12
|
-
import { Mycelium, } from "@fungi.computer/mycelium";
|
|
13
|
+
import { BadResponse, Mycelium, } from "@fungi.computer/mycelium";
|
|
13
14
|
import { appJsonSchema, appToolFamilySchemas } from "@fungi.computer/forage";
|
|
14
15
|
import { forageDiscoveryInstructions } from "@fungi.computer/mycelium/effect";
|
|
15
16
|
import { Knapsack } from "@fungi.computer/knapsack";
|
|
@@ -25,9 +26,9 @@ import { defaultAssetPolicy, sha256, verifyRelease, } from "./release.js";
|
|
|
25
26
|
export const appApprovalInstructions = [
|
|
26
27
|
"A write (including Effect: external) may instead return AppApprovalResult:",
|
|
27
28
|
"type AppApprovalResult =",
|
|
28
|
-
' | { kind: "
|
|
29
|
+
' | { kind: "denied"; by: string; note?: string; message: string }',
|
|
29
30
|
' | { kind: "refused"; reason: string; denialNote?: string };',
|
|
30
|
-
"
|
|
31
|
+
"A write needing approval waits in this call. Approval returns its output; denial or expiry returns here, never as a Session message.",
|
|
31
32
|
].join("\n");
|
|
32
33
|
const fleetIds = defineIdFamily({
|
|
33
34
|
family: "mcp-computer-control",
|
|
@@ -348,7 +349,7 @@ export async function oysterAppSnapshot(host, surfaces, principal, installations
|
|
|
348
349
|
const outputFor = (declared, effect) => mode === "approval" && effect !== "read"
|
|
349
350
|
? approvalOutput(declared)
|
|
350
351
|
: declared;
|
|
351
|
-
const runOperation = async (name, effect, input, context, direct) => {
|
|
352
|
+
const runOperation = async (name, effect, input, context, declaredOutput, direct) => {
|
|
352
353
|
if (mode === "direct" || effect === "read")
|
|
353
354
|
return direct();
|
|
354
355
|
if (host.approvals === undefined)
|
|
@@ -369,18 +370,35 @@ export async function oysterAppSnapshot(host, surfaces, principal, installations
|
|
|
369
370
|
context.operationOrdinal ?? 0,
|
|
370
371
|
]))),
|
|
371
372
|
input,
|
|
372
|
-
|
|
373
|
-
|
|
373
|
+
deadlineAt: oysterApprovalDeadlineAt(context.deadlineAt),
|
|
374
|
+
}, context.signal);
|
|
375
|
+
if (result.kind !== "applied")
|
|
376
|
+
return result;
|
|
377
|
+
// App data must not take the host-only approval branch of the public
|
|
378
|
+
// output union, even when the App declares a permissive object schema.
|
|
379
|
+
if (isApprovalResult(result.output))
|
|
380
|
+
throw new BadResponse({
|
|
381
|
+
reason: "App output cannot impersonate an approval decision",
|
|
382
|
+
rawCause: undefined,
|
|
383
|
+
});
|
|
384
|
+
const output = declaredOutput.safeParse(result.output);
|
|
385
|
+
if (!output.success)
|
|
386
|
+
throw new BadResponse({
|
|
387
|
+
reason: "Capability output failed its declared schema",
|
|
388
|
+
rawCause: output.error,
|
|
389
|
+
});
|
|
390
|
+
return output.data;
|
|
374
391
|
};
|
|
375
392
|
const toolOperations = Object.entries(methods).map(([name, method]) => {
|
|
376
393
|
operationEffects[name] = method.effect;
|
|
394
|
+
const declaredOutput = appJsonSchema(method.output);
|
|
377
395
|
const appMethod = Mycelium.operation({
|
|
378
396
|
replay: "unsafe",
|
|
379
397
|
access: method.effect === "read" ? "read" : "write",
|
|
380
398
|
description: `${method.description}\nEffect: ${method.effect}.`,
|
|
381
399
|
input: appJsonSchema(method.input),
|
|
382
|
-
output: outputFor(
|
|
383
|
-
execute: (input, context) => runOperation(name, method.effect, input, context, () => callAppMethod(name, method.effect, input, context.signal)),
|
|
400
|
+
output: outputFor(declaredOutput, method.effect),
|
|
401
|
+
execute: (input, context) => runOperation(name, method.effect, input, context, declaredOutput, () => callAppMethod(name, method.effect, input, context.signal)),
|
|
384
402
|
});
|
|
385
403
|
return [name, appMethod];
|
|
386
404
|
});
|
|
@@ -410,7 +428,7 @@ export async function oysterAppSnapshot(host, surfaces, principal, installations
|
|
|
410
428
|
description: `${tool.description}\nEffect: ${compiled.effect}.`,
|
|
411
429
|
input: tool.input,
|
|
412
430
|
output: outputFor(tool.output, compiled.effect),
|
|
413
|
-
execute: (input, context) => runOperation(`${compiled.name}.${tool.row.tool}`, compiled.effect, input, context, () => {
|
|
431
|
+
execute: (input, context) => runOperation(`${compiled.name}.${tool.row.tool}`, compiled.effect, input, context, tool.output, () => {
|
|
414
432
|
// The declaring App owns every field below except
|
|
415
433
|
// `requestId` (this call's own identity) and `input`
|
|
416
434
|
// (the caller's tool-shaped payload): `tool.row.call` is
|
|
@@ -675,14 +693,25 @@ export function oysterMcpCatalogLoad(host) {
|
|
|
675
693
|
};
|
|
676
694
|
};
|
|
677
695
|
}
|
|
678
|
-
const
|
|
679
|
-
|
|
696
|
+
const isApprovalResult = Schema.is(Schema.Union([
|
|
697
|
+
ApprovalRefusalSchema.check(Schema.makeFilter((value) => value.reason !== "expired")),
|
|
698
|
+
Schema.Struct({
|
|
699
|
+
kind: Schema.Literal("refused"),
|
|
700
|
+
reason: Schema.Literals(["cancelled", "approval_expired"]),
|
|
701
|
+
}),
|
|
702
|
+
Schema.Struct({
|
|
703
|
+
kind: Schema.Literal("denied"),
|
|
704
|
+
by: Schema.String,
|
|
705
|
+
note: Schema.optionalKey(Schema.String),
|
|
706
|
+
message: Schema.String,
|
|
707
|
+
}),
|
|
708
|
+
]));
|
|
680
709
|
/** Approval results are a host contract, not part of each App's declaration. */
|
|
681
710
|
function approvalOutput(declared) {
|
|
682
711
|
return {
|
|
683
712
|
"~standard": {
|
|
684
713
|
...declared["~standard"],
|
|
685
|
-
validate: (value) =>
|
|
714
|
+
validate: (value) => isApprovalResult(value)
|
|
686
715
|
? { value }
|
|
687
716
|
: declared["~standard"].validate(value),
|
|
688
717
|
},
|
|
@@ -2,7 +2,7 @@ import type { WatchdogSqliteOwner } from "@fungi.computer/watchdog";
|
|
|
2
2
|
/** The closed error code a refused request carries. */
|
|
3
3
|
export declare const olderOysterStoreCode = "store_from_older_oyster";
|
|
4
4
|
/** The one message every refusal shows. */
|
|
5
|
-
export declare const olderOysterStoreMessage = "This Oyster's data was created by Oyster 0.2 or earlier, which this version cannot read.
|
|
5
|
+
export declare const olderOysterStoreMessage = "This Oyster's data was created by Oyster 0.2 or earlier, which this version cannot read. Keep the old Worker and its data untouched. Verify the old release before changing it: 0.0.1 needs a release-matched bridge; 0.1/0.2 must archive the reachable set through its own Worker before fresh setup under new names. If you cannot certify an archive, stop and keep the old Worker on its original release. This refusal deleted nothing and restored nothing.";
|
|
6
6
|
/** Raised by a store owner that finds data written by Oyster 0.2 or earlier. */
|
|
7
7
|
export declare class OlderOysterStoreError extends Error {
|
|
8
8
|
constructor();
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/** The closed error code a refused request carries. */
|
|
2
2
|
export const olderOysterStoreCode = "store_from_older_oyster";
|
|
3
|
-
/** Where the reset steps live. */
|
|
4
|
-
const olderOysterStoreGuide = "https://github.com/fungi-computer/oyster#upgrading-from-oyster-02-or-earlier";
|
|
5
3
|
/** The one message every refusal shows. */
|
|
6
|
-
export const olderOysterStoreMessage =
|
|
4
|
+
export const olderOysterStoreMessage = "This Oyster's data was created by Oyster 0.2 or earlier, which this version cannot read. Keep the old Worker and its data untouched. Verify the old release before changing it: 0.0.1 needs a release-matched bridge; 0.1/0.2 must archive the reachable set through its own Worker before fresh setup under new names. If you cannot certify an archive, stop and keep the old Worker on its original release. This refusal deleted nothing and restored nothing.";
|
|
7
5
|
/** Raised by a store owner that finds data written by Oyster 0.2 or earlier. */
|
|
8
6
|
export class OlderOysterStoreError extends Error {
|
|
9
7
|
constructor() {
|
|
@@ -38,6 +36,6 @@ export function buildJobsFromOlderOyster(sql) {
|
|
|
38
36
|
export function olderOysterStoreResponse(request) {
|
|
39
37
|
const status = 409;
|
|
40
38
|
if (request.headers.get("accept")?.includes("text/html") === true)
|
|
41
|
-
return new Response(`<!doctype html><meta charset="utf-8"><title>Oyster
|
|
39
|
+
return new Response(`<!doctype html><meta charset="utf-8"><title>Oyster upgrade stopped</title><body style="font:16px/1.5 system-ui;max-width:40rem;margin:4rem auto;padding:0 1rem"><h1>Oyster upgrade stopped</h1><p>${olderOysterStoreMessage}</p></body>`, { status, headers: { "content-type": "text/html; charset=utf-8" } });
|
|
42
40
|
return Response.json({ error: olderOysterStoreCode, message: olderOysterStoreMessage }, { status });
|
|
43
41
|
}
|
|
@@ -159,6 +159,8 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
|
|
|
159
159
|
const asked = useRef(null);
|
|
160
160
|
const describeId = useId();
|
|
161
161
|
const mounted = useRef(true);
|
|
162
|
+
/** Failures and flow notices are toasts, never text that reflows the form. */
|
|
163
|
+
const toastError = (text) => toast.error(text, { toasterId: describeId, closeButton: true });
|
|
162
164
|
const retire = useCallback(() => {
|
|
163
165
|
setRetired(true);
|
|
164
166
|
setUncertain(false);
|
|
@@ -211,7 +213,7 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
|
|
|
211
213
|
if (!mounted.current)
|
|
212
214
|
return;
|
|
213
215
|
setRefreshNeeded(true);
|
|
214
|
-
|
|
216
|
+
toastError("Permissions saved. The surrounding screen could not refresh.");
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
async function retryRefresh() {
|
|
@@ -248,11 +250,11 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
|
|
|
248
250
|
}
|
|
249
251
|
if (result === "unconfirmed") {
|
|
250
252
|
setUncertain(true);
|
|
251
|
-
|
|
253
|
+
toastError("The change could not be confirmed. Review current permissions before trying again.");
|
|
252
254
|
return;
|
|
253
255
|
}
|
|
254
256
|
if (result === "refused") {
|
|
255
|
-
|
|
257
|
+
toastError("This permission change was refused. No approval was confirmed.");
|
|
256
258
|
return;
|
|
257
259
|
}
|
|
258
260
|
if (result === "accepted") {
|
|
@@ -284,13 +286,13 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
|
|
|
284
286
|
setView(next);
|
|
285
287
|
setDraft(rebaseDraft(nextDraft, view.permissions.authority, next.permissions.authority));
|
|
286
288
|
setUncertain(false);
|
|
287
|
-
|
|
289
|
+
toast.warning("Current permissions loaded. Review your edits before saving again.", { toasterId: describeId, closeButton: true });
|
|
288
290
|
}
|
|
289
291
|
catch (cause) {
|
|
290
292
|
console.error("App permissions could not be confirmed", cause);
|
|
291
293
|
if (isMounted()) {
|
|
292
294
|
setUncertain(true);
|
|
293
|
-
|
|
295
|
+
toastError("The change could not be confirmed. Review current permissions before trying again.");
|
|
294
296
|
}
|
|
295
297
|
}
|
|
296
298
|
finally {
|
|
@@ -384,8 +386,7 @@ function PermissionEditor({ port, appKey, onAccepted, onStateChange, }) {
|
|
|
384
386
|
? `${view.appName} asks for`
|
|
385
387
|
: `${view.appName} permissions`, headings: gridHeadings, rows: first })), later.length > 0 && (_jsx(Disclosure, { open: otherOpen, onOpenChange: setOtherOpen, summary: `Other permissions · ${String(later.length)}`, children: _jsx(PermissionGrid, { caption: "Already decided", headings: gridHeadings, rows: later }) })), _jsx("div", { className: "sr-only", children: groups
|
|
386
388
|
.flatMap((group) => [...group.columns, ...group.switches])
|
|
387
|
-
.map((column) => (_jsxs("p", { id: `${describeId}-${column.capability}`, children: [column.description, column.warning === null ? "" : ` ${column.warning}`] }, column.capability))) }), screen.groups.length === 0 && _jsx("p", { children: "This App requests no permissions." }), message !== null && !showFooter && (_jsx("p", { role: "status", "aria-live": "polite", children: message })), showFooter && (_jsxs(FormFooter, { divider: false, children: [message !== null &&
|
|
388
|
-
(saved && !uncertain && !refreshNeeded ? (_jsx(Status, { role: "status", size: "compact", glyph: "dot", tone: "success", label: message })) : (_jsx("span", { role: "status", children: message }))), refreshNeeded && (_jsx(Button, { type: "button", size: "xs", variant: "outline", disabled: saving, onClick: () => void retryRefresh(), children: "Retry screen refresh" })), (changes.length > 0 || saving || uncertain) && (_jsx(Button, { type: "submit", variant: "primary", disabled: saving || retired || !screen.canEdit, children: saving
|
|
389
|
+
.map((column) => (_jsxs("p", { id: `${describeId}-${column.capability}`, children: [column.description, column.warning === null ? "" : ` ${column.warning}`] }, column.capability))) }), screen.groups.length === 0 && _jsx("p", { children: "This App requests no permissions." }), message !== null && !showFooter && (_jsx("p", { role: "status", "aria-live": "polite", children: message })), showFooter && (_jsxs(FormFooter, { divider: false, children: [message !== null && saved && !uncertain && !refreshNeeded && (_jsx(Status, { role: "status", size: "compact", glyph: "dot", tone: "success", label: message })), refreshNeeded && (_jsx(Button, { type: "button", size: "xs", variant: "outline", disabled: saving, onClick: () => void retryRefresh(), children: "Retry screen refresh" })), (changes.length > 0 || saving || uncertain) && (_jsx(Button, { type: "submit", variant: "primary", disabled: saving || retired || !screen.canEdit, children: saving
|
|
389
390
|
? "Saving…"
|
|
390
391
|
: uncertain
|
|
391
392
|
? "Review current permissions"
|
|
@@ -17,7 +17,6 @@ export declare class ComputerPortsHandle extends RpcTarget implements HandleOf<t
|
|
|
17
17
|
readonly port: number;
|
|
18
18
|
readonly previewUrl: string;
|
|
19
19
|
readonly openMode: "inline" | "external-only";
|
|
20
|
-
readonly expiresAt: number;
|
|
21
20
|
}[];
|
|
22
21
|
} | {
|
|
23
22
|
readonly error: "port_previews_not_configured";
|
package/dist/page/mount.d.ts
CHANGED
|
@@ -2,108 +2,11 @@ import { type AppOpenInput, type AppRoleChoice } from "@fungi.computer/agar/apps
|
|
|
2
2
|
import { OysterAgentBrowserHost } from "./agent-browser.js";
|
|
3
3
|
export type { OysterAgentBrowserHost } from "./agent-browser.js";
|
|
4
4
|
import type { WhistleRuntime } from "@fungi.computer/whistle";
|
|
5
|
-
|
|
5
|
+
export type { OysterAppConfig } from "../page-config.js";
|
|
6
6
|
import { type AppPermissions, type AppSetup } from "@fungi.computer/agar";
|
|
7
|
+
import { type OysterAppConfig } from "../page-config.js";
|
|
7
8
|
import { type AppHost, type AppHostLaunch, type AppHostHandlers } from "@fungi.computer/agar/host";
|
|
8
9
|
import type { WhistleJsonValue } from "@fungi.computer/whistle";
|
|
9
|
-
/** Current server-admitted configuration for one installed App page. */
|
|
10
|
-
export declare const oysterAppConfigSchema: Schema.Struct<{
|
|
11
|
-
readonly workbench: Schema.Boolean;
|
|
12
|
-
/** The home shell Release's own module, imported top-level; null if it ships none. */
|
|
13
|
-
readonly shellModuleUrl: Schema.NullOr<Schema.String>;
|
|
14
|
-
readonly storage: Schema.Boolean;
|
|
15
|
-
/** The Release declares `apps.open`; only an embedding shell can serve it. */
|
|
16
|
-
readonly appsOpen: Schema.Boolean;
|
|
17
|
-
readonly computerId: Schema.NullOr<Schema.String>;
|
|
18
|
-
readonly authorityVersion: Schema.Int;
|
|
19
|
-
readonly commands: Schema.$Array<Schema.Codec<Readonly<{
|
|
20
|
-
id: string;
|
|
21
|
-
title: string;
|
|
22
|
-
category: string;
|
|
23
|
-
description?: string | undefined;
|
|
24
|
-
sigil?: string | undefined;
|
|
25
|
-
projections?: Readonly<{
|
|
26
|
-
bindings?: (Readonly<{
|
|
27
|
-
order?: number | undefined;
|
|
28
|
-
}> & Readonly<{
|
|
29
|
-
values: readonly string[];
|
|
30
|
-
}>) | undefined;
|
|
31
|
-
agent?: (Readonly<{
|
|
32
|
-
order?: number | undefined;
|
|
33
|
-
}> & Readonly<{
|
|
34
|
-
keybind?: string | undefined;
|
|
35
|
-
}>) | undefined;
|
|
36
|
-
help?: Readonly<{
|
|
37
|
-
order?: number | undefined;
|
|
38
|
-
}> | undefined;
|
|
39
|
-
menu?: Readonly<{
|
|
40
|
-
order?: number | undefined;
|
|
41
|
-
}> | undefined;
|
|
42
|
-
palette?: Readonly<{
|
|
43
|
-
order?: number | undefined;
|
|
44
|
-
}> | undefined;
|
|
45
|
-
slash?: (Readonly<{
|
|
46
|
-
order?: number | undefined;
|
|
47
|
-
}> & Readonly<{
|
|
48
|
-
aliases: readonly string[];
|
|
49
|
-
}>) | undefined;
|
|
50
|
-
}> | undefined;
|
|
51
|
-
}>, Readonly<{
|
|
52
|
-
id: string;
|
|
53
|
-
title: string;
|
|
54
|
-
category: string;
|
|
55
|
-
description?: string | undefined;
|
|
56
|
-
sigil?: string | undefined;
|
|
57
|
-
projections?: Readonly<{
|
|
58
|
-
bindings?: (Readonly<{
|
|
59
|
-
order?: number | undefined;
|
|
60
|
-
}> & Readonly<{
|
|
61
|
-
values: readonly string[];
|
|
62
|
-
}>) | undefined;
|
|
63
|
-
agent?: (Readonly<{
|
|
64
|
-
order?: number | undefined;
|
|
65
|
-
}> & Readonly<{
|
|
66
|
-
keybind?: string | undefined;
|
|
67
|
-
}>) | undefined;
|
|
68
|
-
help?: Readonly<{
|
|
69
|
-
order?: number | undefined;
|
|
70
|
-
}> | undefined;
|
|
71
|
-
menu?: Readonly<{
|
|
72
|
-
order?: number | undefined;
|
|
73
|
-
}> | undefined;
|
|
74
|
-
palette?: Readonly<{
|
|
75
|
-
order?: number | undefined;
|
|
76
|
-
}> | undefined;
|
|
77
|
-
slash?: (Readonly<{
|
|
78
|
-
order?: number | undefined;
|
|
79
|
-
}> & Readonly<{
|
|
80
|
-
aliases: readonly string[];
|
|
81
|
-
}>) | undefined;
|
|
82
|
-
}> | undefined;
|
|
83
|
-
}>, never, never>>;
|
|
84
|
-
readonly icon: Schema.NullOr<Schema.String>;
|
|
85
|
-
readonly roles: Schema.$Array<Schema.String>;
|
|
86
|
-
readonly installationId: Schema.String;
|
|
87
|
-
readonly appId: Schema.String;
|
|
88
|
-
readonly releaseId: Schema.String;
|
|
89
|
-
readonly uiUrl: Schema.String;
|
|
90
|
-
readonly backendUrl: Schema.String;
|
|
91
|
-
readonly methodsUrl: Schema.String;
|
|
92
|
-
readonly capabilities: Schema.$Array<Schema.Struct<{
|
|
93
|
-
readonly id: Schema.String;
|
|
94
|
-
readonly version: Schema.Number;
|
|
95
|
-
readonly base: Schema.String;
|
|
96
|
-
readonly methods: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
|
|
97
|
-
readonly kind: Schema.Literal<"transport">;
|
|
98
|
-
readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "ANY"]>;
|
|
99
|
-
readonly path: Schema.String;
|
|
100
|
-
}>, Schema.Struct<{
|
|
101
|
-
readonly kind: Schema.Literals<readonly ["json", "read", "write"]>;
|
|
102
|
-
readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]>;
|
|
103
|
-
readonly path: Schema.String;
|
|
104
|
-
}>]>>;
|
|
105
|
-
}>>;
|
|
106
|
-
}>;
|
|
107
10
|
/** Role and App opens, routed by the embedding shell; the App never names a surface. */
|
|
108
11
|
export type OysterAppOpenRouting = Readonly<{
|
|
109
12
|
/** Open the declared intent through the App the Team chose for its role. */
|
|
@@ -140,8 +43,6 @@ export declare function oysterShellHandles(config: OysterAppConfig): {
|
|
|
140
43
|
* Desktop chrome (menus, palette, status) belongs to the trusted shell.
|
|
141
44
|
*/
|
|
142
45
|
export declare function mountOysterPage(): Promise<AppHost>;
|
|
143
|
-
/** The host-admitted App configuration served by Oyster. */
|
|
144
|
-
export type OysterAppConfig = typeof oysterAppConfigSchema.Type;
|
|
145
46
|
/** One isolated App connection, with the slots this host admitted for it. */
|
|
146
47
|
export type OysterAppConnectionOptions = Readonly<{
|
|
147
48
|
config: OysterAppConfig;
|
package/dist/page/mount.js
CHANGED
|
@@ -24,10 +24,9 @@ import { agentList, agentManage, agentSessionRead, agentSessionWrite, } from "@f
|
|
|
24
24
|
import { mediaGeneration } from "@fungi.computer/agar/media";
|
|
25
25
|
import { MediaGeneration, mediaGenerationDescriptionSchema, } from "@fungi.computer/agar/media-json";
|
|
26
26
|
import { registeredCapabilityHandle, } from "./capabilities.js";
|
|
27
|
-
import {
|
|
27
|
+
import { oysterAppConfigSchema } from "../page-config.js";
|
|
28
28
|
import { connectAppHost, } from "@fungi.computer/agar/host";
|
|
29
29
|
import { parseJsonValue } from "@fungi.computer/whistle/wire";
|
|
30
|
-
import { appDeclaredCommandSchema } from "@fungi.computer/puffball/app";
|
|
31
30
|
import { TerminalCapability } from "./terminal.js";
|
|
32
31
|
import { ComputerPortsHandle, ComputerProcessesHandle, } from "./computer-handles.js";
|
|
33
32
|
function agentDirectory(capabilities) {
|
|
@@ -44,26 +43,6 @@ function agentDirectory(capabilities) {
|
|
|
44
43
|
return directory;
|
|
45
44
|
}
|
|
46
45
|
/** Current server-admitted configuration for one installed App page. */
|
|
47
|
-
export const oysterAppConfigSchema = Schema.Struct({
|
|
48
|
-
workbench: Schema.Boolean,
|
|
49
|
-
/** The home shell Release's own module, imported top-level; null if it ships none. */
|
|
50
|
-
shellModuleUrl: Schema.NullOr(Schema.String),
|
|
51
|
-
storage: Schema.Boolean,
|
|
52
|
-
/** The Release declares `apps.open`; only an embedding shell can serve it. */
|
|
53
|
-
appsOpen: Schema.Boolean,
|
|
54
|
-
computerId: Schema.NullOr(Schema.String),
|
|
55
|
-
authorityVersion: Schema.Int,
|
|
56
|
-
commands: Schema.Array(appDeclaredCommandSchema),
|
|
57
|
-
icon: Schema.NullOr(Schema.String),
|
|
58
|
-
roles: Schema.Array(Schema.String),
|
|
59
|
-
installationId: Schema.String,
|
|
60
|
-
appId: Schema.String,
|
|
61
|
-
releaseId: Schema.String,
|
|
62
|
-
uiUrl: Schema.String,
|
|
63
|
-
backendUrl: Schema.String,
|
|
64
|
-
methodsUrl: Schema.String,
|
|
65
|
-
capabilities: Schema.Array(capabilityDescriptorSchema),
|
|
66
|
-
});
|
|
67
46
|
async function answer(response) {
|
|
68
47
|
if (response.status === 401 || response.status === 403)
|
|
69
48
|
throw new AppError("App permission was denied", {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/** One host-admitted configuration, shared by Worker producers and browser mounts. */
|
|
3
|
+
export declare const oysterAppConfigSchema: Schema.Struct<{
|
|
4
|
+
readonly workbench: Schema.Boolean;
|
|
5
|
+
/** The home shell Release's own module, imported top-level; null if it ships none. */
|
|
6
|
+
readonly shellModuleUrl: Schema.NullOr<Schema.String>;
|
|
7
|
+
readonly storage: Schema.Boolean;
|
|
8
|
+
/** The Release declares `apps.open`; only an embedding shell can serve it. */
|
|
9
|
+
readonly appsOpen: Schema.Boolean;
|
|
10
|
+
readonly computerId: Schema.NullOr<Schema.String>;
|
|
11
|
+
readonly authorityVersion: Schema.Int;
|
|
12
|
+
readonly commands: Schema.$Array<Schema.Codec<Readonly<{
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
category: string;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
sigil?: string | undefined;
|
|
18
|
+
projections?: Readonly<{
|
|
19
|
+
bindings?: (Readonly<{
|
|
20
|
+
order?: number | undefined;
|
|
21
|
+
}> & Readonly<{
|
|
22
|
+
values: readonly string[];
|
|
23
|
+
}>) | undefined;
|
|
24
|
+
agent?: (Readonly<{
|
|
25
|
+
order?: number | undefined;
|
|
26
|
+
}> & Readonly<{
|
|
27
|
+
keybind?: string | undefined;
|
|
28
|
+
}>) | undefined;
|
|
29
|
+
help?: Readonly<{
|
|
30
|
+
order?: number | undefined;
|
|
31
|
+
}> | undefined;
|
|
32
|
+
menu?: Readonly<{
|
|
33
|
+
order?: number | undefined;
|
|
34
|
+
}> | undefined;
|
|
35
|
+
palette?: Readonly<{
|
|
36
|
+
order?: number | undefined;
|
|
37
|
+
}> | undefined;
|
|
38
|
+
slash?: (Readonly<{
|
|
39
|
+
order?: number | undefined;
|
|
40
|
+
}> & Readonly<{
|
|
41
|
+
aliases: readonly string[];
|
|
42
|
+
}>) | undefined;
|
|
43
|
+
}> | undefined;
|
|
44
|
+
}>, Readonly<{
|
|
45
|
+
id: string;
|
|
46
|
+
title: string;
|
|
47
|
+
category: string;
|
|
48
|
+
description?: string | undefined;
|
|
49
|
+
sigil?: string | undefined;
|
|
50
|
+
projections?: Readonly<{
|
|
51
|
+
bindings?: (Readonly<{
|
|
52
|
+
order?: number | undefined;
|
|
53
|
+
}> & Readonly<{
|
|
54
|
+
values: readonly string[];
|
|
55
|
+
}>) | undefined;
|
|
56
|
+
agent?: (Readonly<{
|
|
57
|
+
order?: number | undefined;
|
|
58
|
+
}> & Readonly<{
|
|
59
|
+
keybind?: string | undefined;
|
|
60
|
+
}>) | undefined;
|
|
61
|
+
help?: Readonly<{
|
|
62
|
+
order?: number | undefined;
|
|
63
|
+
}> | undefined;
|
|
64
|
+
menu?: Readonly<{
|
|
65
|
+
order?: number | undefined;
|
|
66
|
+
}> | undefined;
|
|
67
|
+
palette?: Readonly<{
|
|
68
|
+
order?: number | undefined;
|
|
69
|
+
}> | undefined;
|
|
70
|
+
slash?: (Readonly<{
|
|
71
|
+
order?: number | undefined;
|
|
72
|
+
}> & Readonly<{
|
|
73
|
+
aliases: readonly string[];
|
|
74
|
+
}>) | undefined;
|
|
75
|
+
}> | undefined;
|
|
76
|
+
}>, never, never>>;
|
|
77
|
+
readonly icon: Schema.NullOr<Schema.String>;
|
|
78
|
+
readonly roles: Schema.$Array<Schema.String>;
|
|
79
|
+
readonly installationId: Schema.String;
|
|
80
|
+
readonly appId: Schema.String;
|
|
81
|
+
readonly releaseId: Schema.String;
|
|
82
|
+
readonly uiUrl: Schema.String;
|
|
83
|
+
readonly backendUrl: Schema.String;
|
|
84
|
+
readonly methodsUrl: Schema.String;
|
|
85
|
+
readonly capabilities: Schema.$Array<Schema.Struct<{
|
|
86
|
+
readonly id: Schema.String;
|
|
87
|
+
readonly version: Schema.Number;
|
|
88
|
+
readonly base: Schema.String;
|
|
89
|
+
readonly methods: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
|
|
90
|
+
readonly kind: Schema.Literal<"transport">;
|
|
91
|
+
readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "ANY"]>;
|
|
92
|
+
readonly path: Schema.String;
|
|
93
|
+
}>, Schema.Struct<{
|
|
94
|
+
readonly kind: Schema.Literals<readonly ["json", "read", "write"]>;
|
|
95
|
+
readonly method: Schema.Literals<readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]>;
|
|
96
|
+
readonly path: Schema.String;
|
|
97
|
+
}>]>>;
|
|
98
|
+
}>>;
|
|
99
|
+
}>;
|
|
100
|
+
/** The host-admitted App configuration served by Oyster. */
|
|
101
|
+
/** Host-authored configuration for the ordinary sandboxed App mount. */
|
|
102
|
+
export type OysterAppConfig = typeof oysterAppConfigSchema.Type;
|