@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
package/dist/host.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { OysterApprovalCall } from "./approval-home.js";
|
|
2
|
-
|
|
1
|
+
import type { OysterApprovalCall, OysterApprovalResult } from "./approval-home.js";
|
|
2
|
+
export type { OysterApprovalResult };
|
|
3
3
|
import type { WorkflowControl } from "./workflows.js";
|
|
4
4
|
import type { ComputerControlPort } from "./computer-control-port.js";
|
|
5
5
|
import { type InstallationOperations } from "./installation-operations.js";
|
|
6
6
|
export type { InstallationOperations };
|
|
7
|
+
import { type AppTestCopy, type AppTestCopyAuthority } from "./app-test-copies.js";
|
|
8
|
+
export { appTestCopySchema, appTestCopyAuthoritySchema, type AppTestCopy, type AppTestCopyAuthority, } from "./app-test-copies.js";
|
|
7
9
|
import type { KnapsackComputer } from "@fungi.computer/knapsack";
|
|
8
10
|
import type { TenantPrincipal } from "./tenant.js";
|
|
9
11
|
import { type GillCall, type GillReply } from "@fungi.computer/gills";
|
|
@@ -33,6 +35,7 @@ import { type GitDoorTarget } from "./git.js";
|
|
|
33
35
|
import type { AdmittedGit } from "./git-admission.js";
|
|
34
36
|
import { type PageAssetLoader } from "./page-assets.js";
|
|
35
37
|
import { type AppApi } from "@fungi.computer/puffball";
|
|
38
|
+
import type { AppMethodCallContext } from "@fungi.computer/puffball/app";
|
|
36
39
|
export { ReleaseError, defaultAssetPolicy, parseRelease, resolveBackend, sha256, verifyRelease, type ArtifactStore, type VerifiedObjectCache, type VerifiedRelease, } from "./release.js";
|
|
37
40
|
/** Stable actor identity for host storage and backend attribution. */
|
|
38
41
|
export declare function oysterPrincipalId(principal: TenantPrincipal): string;
|
|
@@ -90,6 +93,19 @@ export type InstanceResult<T> = Readonly<{
|
|
|
90
93
|
}>;
|
|
91
94
|
/** One running App Instance, wherever the host runs it. */
|
|
92
95
|
export type InstanceHandle = Readonly<{
|
|
96
|
+
/** Optional native App-only siblings; absence is an honest unavailable host. */
|
|
97
|
+
testCopies?: Readonly<{
|
|
98
|
+
/** Open a bounded snapshot or answer its retained creation request. */
|
|
99
|
+
open: (authority: AppTestCopyAuthority, requestId: string) => Promise<InstanceResult<AppTestCopy>>;
|
|
100
|
+
/** Observe the current sibling under fresh source and store fences. */
|
|
101
|
+
inspect: (authority: AppTestCopyAuthority) => Promise<InstanceResult<AppTestCopy | null>>;
|
|
102
|
+
/** Retire only the named resource; delayed discard cannot target a replacement. */
|
|
103
|
+
discard: (authority: AppTestCopyAuthority, copyId: string) => Promise<InstanceResult<boolean>>;
|
|
104
|
+
/** Serve the copied App backend without live host bindings. */
|
|
105
|
+
fetch: (authority: AppTestCopyAuthority, copyId: string, request: Request) => Promise<Response>;
|
|
106
|
+
/** Invoke one admitted declared method with owner attribution, not live grants. */
|
|
107
|
+
call: (authority: AppTestCopyAuthority, copyId: string, name: string, input: OysterJson, caller: AppMethodCallContext) => Promise<InstanceResult<AppMethodReply>>;
|
|
108
|
+
}>;
|
|
93
109
|
/** Check lifecycle and construction without activating or changing Instance state. */
|
|
94
110
|
prepare: (state: OwnerState, release: Release) => Promise<InstanceResult<UiBootCheckOutcome | null>>;
|
|
95
111
|
/** Activate a complete owner state only after its registry selection commits. */
|
|
@@ -170,8 +186,8 @@ export type OysterEnv = {
|
|
|
170
186
|
export type OysterHost = Readonly<{
|
|
171
187
|
/** Native approval home. A host without one cannot execute App tool writes. */
|
|
172
188
|
approvals?: Readonly<{
|
|
173
|
-
/**
|
|
174
|
-
submit(call: OysterApprovalCall): Promise<
|
|
189
|
+
/** Wait for a decision and return the native home's in-call result. */
|
|
190
|
+
submit(call: OysterApprovalCall, signal: AbortSignal): Promise<OysterApprovalResult>;
|
|
175
191
|
}>;
|
|
176
192
|
/**
|
|
177
193
|
* Host-bound Workflow control; absence exposes no Workflow authority.
|
package/dist/host.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { hostGateFacts, releaseCache } from "./internal/host-gate.js";
|
|
2
|
-
import { InstallationOperationError, installationCommandIds, installationRequestIdSchema, installationWaitQuerySchema, maxSettlementWaitMs, } from "./installation-operations.js";
|
|
2
|
+
import { InstallationOperationError, installationCommandIds, installationRequestIdSchema, installationRecoverySelectionSchema, installationWaitQuerySchema, maxSettlementWaitMs, } from "./installation-operations.js";
|
|
3
3
|
import { completedInstallationResponse, observeInstallation, InstallationObservationError, } from "./installation-client.js";
|
|
4
|
+
import { installationRecoveryFormSchema, appTestCopyDiscardFormSchema, installationRecoveryPage, } from "./installation-recovery-page.js";
|
|
5
|
+
import { sameOriginReadRequest, sameOriginRequest } from "./request-origin.js";
|
|
6
|
+
import { appTestCopySchema, } from "./app-test-copies.js";
|
|
7
|
+
import { appTestCopyPage } from "./app-test-copy-page.js";
|
|
8
|
+
export { appTestCopySchema, appTestCopyAuthoritySchema, } from "./app-test-copies.js";
|
|
4
9
|
import { instanceRefusalBody, instanceRefusalStatus, } from "./instance-refusal.js";
|
|
5
10
|
import { appSandbox } from "./app-sandbox.js";
|
|
6
11
|
import { shellModuleAsset, shellModuleAssetPath, } from "@fungi.computer/puffball/assets";
|
|
@@ -658,6 +663,309 @@ export function oysterRouteTable(host) {
|
|
|
658
663
|
? admitted
|
|
659
664
|
: Response.json(admitted, { status: 202 });
|
|
660
665
|
});
|
|
666
|
+
table.get("/recovery", owner("direct"), async (context) => {
|
|
667
|
+
const operations = host.installations.operations;
|
|
668
|
+
if (operations === undefined)
|
|
669
|
+
return noStoreRefusal(503, "Installation commands unavailable");
|
|
670
|
+
try {
|
|
671
|
+
let operation = null;
|
|
672
|
+
if (context.req.query("requestId") !== undefined) {
|
|
673
|
+
const key = installationRequestIdSchema.safeParse(context.req.query("requestId"));
|
|
674
|
+
const id = installationIdSchema.safeParse(context.req.query("installationId"));
|
|
675
|
+
if (!key.success || !id.success)
|
|
676
|
+
return noStoreRefusal(400, "Invalid rollback identity");
|
|
677
|
+
operation = await operations.read(key.data, id.data);
|
|
678
|
+
if (operation === null)
|
|
679
|
+
return noStoreRefusal(404, "Installation request not found");
|
|
680
|
+
}
|
|
681
|
+
const installations = (await host.installations.list()).filter((installation) => installation.status !== "deleted");
|
|
682
|
+
const entries = await Promise.all(installations.map(async (installation) => {
|
|
683
|
+
const entry = {
|
|
684
|
+
installation,
|
|
685
|
+
recovery: await operations.recovery(installation.installationId),
|
|
686
|
+
copy: null,
|
|
687
|
+
copyAuthority: null,
|
|
688
|
+
};
|
|
689
|
+
if (installation.status !== "enabled" ||
|
|
690
|
+
installation.instanceId === null)
|
|
691
|
+
return entry;
|
|
692
|
+
const copies = host.instances.get(installation.instanceId, limits).testCopies;
|
|
693
|
+
if (copies === undefined)
|
|
694
|
+
return entry;
|
|
695
|
+
const authority = {
|
|
696
|
+
selection: selectionOf(installation),
|
|
697
|
+
storeGeneration: await host.installations.generation(),
|
|
698
|
+
};
|
|
699
|
+
let observed;
|
|
700
|
+
try {
|
|
701
|
+
observed = await copies.inspect(authority);
|
|
702
|
+
}
|
|
703
|
+
catch (cause) {
|
|
704
|
+
// Optional copy observation must not take down rollback controls.
|
|
705
|
+
console.error("Oyster recovery: test copy unavailable", {
|
|
706
|
+
causeClass: causeClass(cause),
|
|
707
|
+
});
|
|
708
|
+
return entry;
|
|
709
|
+
}
|
|
710
|
+
return observed.ok
|
|
711
|
+
? { ...entry, copy: observed.value, copyAuthority: authority }
|
|
712
|
+
: entry;
|
|
713
|
+
}));
|
|
714
|
+
const confirm = installationIdSchema.safeParse(context.req.query("confirm"));
|
|
715
|
+
return await installationRecoveryPage(entries, operation, confirm.success ? confirm.data : null);
|
|
716
|
+
}
|
|
717
|
+
catch (cause) {
|
|
718
|
+
if (cause instanceof InstallationOperationError)
|
|
719
|
+
return installationOperationRefusal(cause);
|
|
720
|
+
throw cause;
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
table.post("/recovery/:installationId/rollback", owner("direct"), async (context, { principal }) => {
|
|
724
|
+
if (!sameOriginRequest(context.req.raw))
|
|
725
|
+
return noStoreRefusal(403, "Same origin required");
|
|
726
|
+
const id = installationIdSchema.safeParse(context.req.param("installationId"));
|
|
727
|
+
if (!id.success)
|
|
728
|
+
return noStoreRefusal(400, "Invalid installation id");
|
|
729
|
+
let form;
|
|
730
|
+
try {
|
|
731
|
+
form = installationRecoveryFormSchema.parse(await context.req.parseBody());
|
|
732
|
+
}
|
|
733
|
+
catch {
|
|
734
|
+
return noStoreRefusal(400, "Invalid rollback request");
|
|
735
|
+
}
|
|
736
|
+
const operations = host.installations.operations;
|
|
737
|
+
if (operations === undefined)
|
|
738
|
+
return noStoreRefusal(503, "Installation commands unavailable");
|
|
739
|
+
try {
|
|
740
|
+
await operations.admit({
|
|
741
|
+
...form,
|
|
742
|
+
installationId: id.data,
|
|
743
|
+
actor: principal.actor,
|
|
744
|
+
intent: "rollback",
|
|
745
|
+
origin: "owner-direct",
|
|
746
|
+
});
|
|
747
|
+
const query = new URLSearchParams({
|
|
748
|
+
installationId: id.data,
|
|
749
|
+
requestId: form.requestId,
|
|
750
|
+
});
|
|
751
|
+
return new Response(null, {
|
|
752
|
+
status: 303,
|
|
753
|
+
headers: {
|
|
754
|
+
Location: `/recovery?${query.toString()}`,
|
|
755
|
+
"Cache-Control": "no-store",
|
|
756
|
+
},
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
catch (cause) {
|
|
760
|
+
if (cause instanceof InstallationOperationError)
|
|
761
|
+
return installationOperationRefusal(cause);
|
|
762
|
+
throw cause;
|
|
763
|
+
}
|
|
764
|
+
}, {
|
|
765
|
+
middleware: [
|
|
766
|
+
bodyLimit({
|
|
767
|
+
maxSize: 64 * 1024,
|
|
768
|
+
onError: () => noStoreRefusal(413, "Recovery request too large"),
|
|
769
|
+
}),
|
|
770
|
+
],
|
|
771
|
+
});
|
|
772
|
+
const copyOwner = async (context, principal) => {
|
|
773
|
+
// Provenance first: no installation or copy state answers a foreign page.
|
|
774
|
+
if (context.req.method === "GET"
|
|
775
|
+
? !sameOriginReadRequest(context.req.raw)
|
|
776
|
+
: !sameOriginRequest(context.req.raw))
|
|
777
|
+
return noStoreRefusal(403, "Same origin required");
|
|
778
|
+
const id = installationIdSchema.safeParse(context.req.param("installationId"));
|
|
779
|
+
if (!id.success)
|
|
780
|
+
return noStoreRefusal(400, "Invalid installation id");
|
|
781
|
+
const installation = await host.installations.get(id.data);
|
|
782
|
+
if (installation?.status !== "enabled" || installation.instanceId === null)
|
|
783
|
+
return noStoreRefusal(404, "Enabled App Instance required");
|
|
784
|
+
const copies = host.instances.get(installation.instanceId, limits).testCopies;
|
|
785
|
+
if (copies === undefined)
|
|
786
|
+
return noStoreRefusal(503, "Native test copies unavailable");
|
|
787
|
+
return {
|
|
788
|
+
principal,
|
|
789
|
+
installation,
|
|
790
|
+
copies,
|
|
791
|
+
authority: {
|
|
792
|
+
selection: selectionOf(installation),
|
|
793
|
+
storeGeneration: await host.installations.generation(),
|
|
794
|
+
},
|
|
795
|
+
};
|
|
796
|
+
};
|
|
797
|
+
const copyForm = async (context, schema) => {
|
|
798
|
+
try {
|
|
799
|
+
return schema.parse(await context.req.parseBody());
|
|
800
|
+
}
|
|
801
|
+
catch {
|
|
802
|
+
return noStoreRefusal(400, "Invalid test copy request");
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
const copyBodyLimit = {
|
|
806
|
+
middleware: [
|
|
807
|
+
bodyLimit({
|
|
808
|
+
maxSize: 64 * 1024,
|
|
809
|
+
onError: () => noStoreRefusal(413, "Recovery request too large"),
|
|
810
|
+
}),
|
|
811
|
+
],
|
|
812
|
+
};
|
|
813
|
+
table.post("/recovery/:installationId/test-copy", owner("direct"), async (context, { principal }) => {
|
|
814
|
+
const copyOwned = await copyOwner(context, principal);
|
|
815
|
+
if (copyOwned instanceof Response)
|
|
816
|
+
return copyOwned;
|
|
817
|
+
const form = await copyForm(context, installationRecoveryFormSchema);
|
|
818
|
+
if (form instanceof Response)
|
|
819
|
+
return form;
|
|
820
|
+
if (form.authorityVersion !==
|
|
821
|
+
copyOwned.authority.selection.authorityVersion ||
|
|
822
|
+
form.storeGeneration !== copyOwned.authority.storeGeneration)
|
|
823
|
+
return noStoreRefusal(409, "Stale copy authority");
|
|
824
|
+
const opened = await copyOwned.copies.open(copyOwned.authority, form.requestId);
|
|
825
|
+
if (!opened.ok)
|
|
826
|
+
return instanceRefusal(opened.code, opened.causeClass);
|
|
827
|
+
return new Response(null, {
|
|
828
|
+
status: 303,
|
|
829
|
+
headers: {
|
|
830
|
+
Location: `/recovery/${copyOwned.installation.installationId}/test-copy/${opened.value.copyId}`,
|
|
831
|
+
"Cache-Control": "no-store",
|
|
832
|
+
},
|
|
833
|
+
});
|
|
834
|
+
}, copyBodyLimit);
|
|
835
|
+
table.post("/recovery/:installationId/test-copy/:copyId/discard", owner("direct"), async (context, { principal }) => {
|
|
836
|
+
const copyOwned = await copyOwner(context, principal);
|
|
837
|
+
if (copyOwned instanceof Response)
|
|
838
|
+
return copyOwned;
|
|
839
|
+
const form = await copyForm(context, appTestCopyDiscardFormSchema);
|
|
840
|
+
if (form instanceof Response)
|
|
841
|
+
return form;
|
|
842
|
+
if (form.authorityVersion !==
|
|
843
|
+
copyOwned.authority.selection.authorityVersion ||
|
|
844
|
+
form.storeGeneration !== copyOwned.authority.storeGeneration ||
|
|
845
|
+
form.copyId !== context.req.param("copyId"))
|
|
846
|
+
return noStoreRefusal(409, "Stale copy authority");
|
|
847
|
+
const discarded = await copyOwned.copies.discard(copyOwned.authority, form.copyId);
|
|
848
|
+
if (!discarded.ok)
|
|
849
|
+
return instanceRefusal(discarded.code, discarded.causeClass);
|
|
850
|
+
return new Response(null, {
|
|
851
|
+
status: 303,
|
|
852
|
+
headers: { Location: "/recovery", "Cache-Control": "no-store" },
|
|
853
|
+
});
|
|
854
|
+
}, copyBodyLimit);
|
|
855
|
+
table.get("/recovery/:installationId/test-copy/:copyId", owner("direct"), async (context, { principal }) => {
|
|
856
|
+
const copyOwned = await copyOwner(context, principal);
|
|
857
|
+
if (copyOwned instanceof Response)
|
|
858
|
+
return copyOwned;
|
|
859
|
+
const observed = await copyOwned.copies.inspect(copyOwned.authority);
|
|
860
|
+
if (!observed.ok)
|
|
861
|
+
return instanceRefusal(observed.code, observed.causeClass);
|
|
862
|
+
if (observed.value?.copyId !== context.req.param("copyId"))
|
|
863
|
+
return noStoreRefusal(404, "Test copy expired or discarded");
|
|
864
|
+
return appTestCopyPage(copyOwned.installation.installationId, observed.value, (await releaseOf(copyOwned.installation.release)).declaration, (await assets()).page.path);
|
|
865
|
+
});
|
|
866
|
+
table.put("/recovery/:installationId/test-copy/:copyId/backend", owner("direct"), async (context, { principal }) => {
|
|
867
|
+
const copyOwned = await copyOwner(context, principal);
|
|
868
|
+
if (copyOwned instanceof Response)
|
|
869
|
+
return copyOwned;
|
|
870
|
+
const copyId = appTestCopySchema.shape.copyId.safeParse(context.req.param("copyId"));
|
|
871
|
+
if (!copyId.success)
|
|
872
|
+
return noStoreRefusal(400, "Invalid copy id");
|
|
873
|
+
const request = new Request("https://app.internal/", {
|
|
874
|
+
method: "PUT",
|
|
875
|
+
headers: {
|
|
876
|
+
"Content-Type": "text/plain",
|
|
877
|
+
[appBackendActorHeader]: oysterPrincipalId(copyOwned.principal),
|
|
878
|
+
},
|
|
879
|
+
body: await context.req.text(),
|
|
880
|
+
});
|
|
881
|
+
return copyOwned.copies.fetch(copyOwned.authority, copyId.data, request);
|
|
882
|
+
}, {
|
|
883
|
+
middleware: [
|
|
884
|
+
bodyLimit({
|
|
885
|
+
maxSize: maxBackendBody,
|
|
886
|
+
onError: () => noStoreRefusal(413, "Request too large"),
|
|
887
|
+
}),
|
|
888
|
+
],
|
|
889
|
+
});
|
|
890
|
+
table.post("/recovery/:installationId/test-copy/:copyId/methods/:name", owner("direct"), async (context, { principal }) => {
|
|
891
|
+
const copyOwned = await copyOwner(context, principal);
|
|
892
|
+
if (copyOwned instanceof Response)
|
|
893
|
+
return copyOwned;
|
|
894
|
+
const copyId = appTestCopySchema.shape.copyId.safeParse(context.req.param("copyId"));
|
|
895
|
+
if (!copyId.success)
|
|
896
|
+
return noStoreRefusal(400, "Invalid copy id");
|
|
897
|
+
const release = await releaseOf(copyOwned.installation.release);
|
|
898
|
+
if (release.api === null)
|
|
899
|
+
return noStoreRefusal(404, "This App declares no methods");
|
|
900
|
+
let input;
|
|
901
|
+
try {
|
|
902
|
+
input = await methodInput(context.req.raw);
|
|
903
|
+
}
|
|
904
|
+
catch (error) {
|
|
905
|
+
return error instanceof MethodBodyTooLarge
|
|
906
|
+
? noStoreRefusal(413, "Request too large")
|
|
907
|
+
: noStoreRefusal(400, "Method input must be JSON");
|
|
908
|
+
}
|
|
909
|
+
const name = context.req.param("name");
|
|
910
|
+
const admitted = admits(await gateFacts(copyOwned.installation, release, copyOwned.principal), { kind: "method", name, input, via: "ui" });
|
|
911
|
+
if (admitted.kind === "refused")
|
|
912
|
+
return noStoreRefusal(admitted.code === "invalid_input" ? 400 : 403, admitted.code);
|
|
913
|
+
const result = await copyOwned.copies.call(copyOwned.authority, copyId.data, name, input, invocationCallerContext(copyOwned.principal, null));
|
|
914
|
+
return result.ok
|
|
915
|
+
? methodResponse(result.value)
|
|
916
|
+
: instanceRefusal(result.code, result.causeClass);
|
|
917
|
+
});
|
|
918
|
+
table.get("/api/installations/:installationId/recovery", owner("direct"), async (context) => {
|
|
919
|
+
if (!sameOriginReadRequest(context.req.raw))
|
|
920
|
+
return refusal(403, "Cross-origin recovery refused");
|
|
921
|
+
const id = installationIdSchema.safeParse(context.req.param("installationId"));
|
|
922
|
+
if (!id.success)
|
|
923
|
+
return refusal(400, "Invalid installation id");
|
|
924
|
+
const operations = host.installations.operations;
|
|
925
|
+
if (operations === undefined)
|
|
926
|
+
return refusal(503, "Installation commands unavailable");
|
|
927
|
+
try {
|
|
928
|
+
return Response.json(await operations.recovery(id.data));
|
|
929
|
+
}
|
|
930
|
+
catch (cause) {
|
|
931
|
+
if (cause instanceof InstallationOperationError)
|
|
932
|
+
return installationOperationRefusal(cause);
|
|
933
|
+
throw cause;
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
table.post("/api/installations/:installationId/rollback", owner("direct"), async (context, { principal }) => {
|
|
937
|
+
if (!sameOriginReadRequest(context.req.raw))
|
|
938
|
+
return refusal(403, "Cross-origin recovery refused");
|
|
939
|
+
const id = installationIdSchema.safeParse(context.req.param("installationId"));
|
|
940
|
+
const key = installationRequestIdSchema.safeParse(context.req.header("Idempotency-Key"));
|
|
941
|
+
if (!id.success || !key.success)
|
|
942
|
+
return refusal(400, "Invalid rollback identity");
|
|
943
|
+
let selection;
|
|
944
|
+
try {
|
|
945
|
+
selection = installationRecoverySelectionSchema.parse(await context.req.json());
|
|
946
|
+
}
|
|
947
|
+
catch {
|
|
948
|
+
return refusal(400, "Invalid rollback request");
|
|
949
|
+
}
|
|
950
|
+
const operations = host.installations.operations;
|
|
951
|
+
if (operations === undefined)
|
|
952
|
+
return refusal(503, "Installation commands unavailable");
|
|
953
|
+
try {
|
|
954
|
+
return Response.json(await operations.admit({
|
|
955
|
+
...selection,
|
|
956
|
+
requestId: key.data,
|
|
957
|
+
installationId: id.data,
|
|
958
|
+
actor: principal.actor,
|
|
959
|
+
intent: "rollback",
|
|
960
|
+
origin: "owner-direct",
|
|
961
|
+
}), { status: 202 });
|
|
962
|
+
}
|
|
963
|
+
catch (cause) {
|
|
964
|
+
if (cause instanceof InstallationOperationError)
|
|
965
|
+
return installationOperationRefusal(cause);
|
|
966
|
+
throw cause;
|
|
967
|
+
}
|
|
968
|
+
});
|
|
661
969
|
table.get("/api/installations/:installationId/status", owner("direct"), async (context) => {
|
|
662
970
|
const key = installationRequestIdSchema.safeParse(context.req.query("requestId"));
|
|
663
971
|
if (!key.success)
|
|
@@ -880,7 +1188,9 @@ export function oysterRouteTable(host) {
|
|
|
880
1188
|
installation.installationId === host.homeInstallationId &&
|
|
881
1189
|
declaration?.capabilities.includes("team.workbenchHost") === true &&
|
|
882
1190
|
grantsFor(facts.installation, facts.declaration, facts.declaredOperations, "team.workbenchHost") !== null;
|
|
883
|
-
const
|
|
1191
|
+
const uiPath = `/ui/${installation.installationId}/${installation.release.releaseId}/`;
|
|
1192
|
+
// Immutable App documents also carry the host's sandbox policy.
|
|
1193
|
+
const uiUrl = `${uiPath}?${new URLSearchParams({ sandbox: appSandbox }).toString()}`;
|
|
884
1194
|
const config = {
|
|
885
1195
|
workbench,
|
|
886
1196
|
// The home shell's own code: the module its Release ships beside
|
|
@@ -918,7 +1228,7 @@ export function oysterRouteTable(host) {
|
|
|
918
1228
|
? release.ui.build.assets
|
|
919
1229
|
.filter((asset) => asset.contentType.startsWith("text/javascript") &&
|
|
920
1230
|
asset.path !== shellModuleAssetPath)
|
|
921
|
-
.map((asset) => `<link rel="modulepreload" href="${escapeHtml(`${
|
|
1231
|
+
.map((asset) => `<link rel="modulepreload" href="${escapeHtml(`${uiPath.slice(0, -1)}${asset.path}`)}">`)
|
|
922
1232
|
.join("")
|
|
923
1233
|
: "";
|
|
924
1234
|
const head = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>${escapeHtml(installation.installationId)} · ${escapeHtml(title)}</title>${tabIcon}<link rel="stylesheet" href="${(await assets()).fonts.path}">${shellPreloads}`;
|
|
@@ -1042,6 +1352,7 @@ export function oysterRouteTable(host) {
|
|
|
1042
1352
|
rows: [],
|
|
1043
1353
|
reason: "params_required",
|
|
1044
1354
|
error: `Choose a ${missing.kind}`,
|
|
1355
|
+
recovery: { kind: "configure", param: missing.key },
|
|
1045
1356
|
});
|
|
1046
1357
|
const authority = invocationAuthorityOf(installation, release);
|
|
1047
1358
|
const grants = scopedBindings(authority.grants, method, "read");
|