@fungi.computer/oyster 0.1.0 → 0.3.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 +376 -72
- package/dist/agent-avatars.d.ts +103 -0
- package/dist/agent-avatars.js +66 -0
- package/dist/agents.d.ts +15 -4
- package/dist/agents.js +43 -4
- package/dist/app-builds.d.ts +81 -8
- package/dist/app-builds.js +210 -60
- package/dist/app-storage.d.ts +3 -3
- package/dist/approval-capability.d.ts +5 -0
- package/dist/approval-capability.js +46 -0
- package/dist/approval-home.d.ts +51 -0
- package/dist/approval-home.js +226 -0
- package/dist/apps/catalog.d.ts +335 -0
- package/dist/apps/catalog.js +46 -0
- package/dist/apps/gate.d.ts +26 -12
- package/dist/apps/gate.js +48 -22
- package/dist/apps/index.d.ts +3 -1
- package/dist/apps/index.js +3 -1
- package/dist/apps/installation.d.ts +147 -66
- package/dist/apps/installation.js +193 -86
- package/dist/apps/permissions.d.ts +247 -0
- package/dist/apps/permissions.js +255 -0
- package/dist/boot-capability-route.d.ts +15 -0
- package/dist/boot-capability-route.js +196 -0
- package/dist/boot-capability.d.ts +103 -0
- package/dist/boot-capability.js +141 -0
- package/dist/boot-construction.d.ts +12 -0
- package/dist/boot-construction.js +175 -0
- package/dist/boot-gate.d.ts +267 -0
- package/dist/boot-gate.js +236 -0
- package/dist/boot-host-script.d.ts +2 -0
- package/dist/boot-host-script.js +1 -0
- package/dist/boot-mount.d.ts +21 -0
- package/dist/boot-mount.js +65 -0
- package/dist/browser/boot.d.ts +73 -0
- package/dist/browser/boot.js +502 -0
- package/dist/browser/browser.d.ts +104 -0
- package/dist/browser/browser.js +374 -0
- package/dist/browser/capability-source.d.ts +76 -0
- package/dist/browser/capability-source.js +338 -0
- package/dist/browser/cdp-client.d.ts +56 -0
- package/dist/browser/cdp-client.js +184 -0
- package/dist/browser/errors.d.ts +79 -0
- package/dist/browser/errors.js +32 -0
- package/dist/browser/index.d.ts +16 -0
- package/dist/browser/index.js +14 -0
- package/dist/browser/lease-registry.d.ts +61 -0
- package/dist/browser/lease-registry.js +101 -0
- package/dist/browser/operations.d.ts +225 -0
- package/dist/browser/operations.js +137 -0
- package/dist/browser/page.d.ts +25 -0
- package/dist/browser/page.js +172 -0
- package/dist/browser/quick-reads.d.ts +29 -0
- package/dist/browser/quick-reads.js +160 -0
- package/dist/browser/sessions.d.ts +52 -0
- package/dist/browser/sessions.js +118 -0
- package/dist/browser/url-policy.d.ts +18 -0
- package/dist/browser/url-policy.js +58 -0
- package/dist/build/app-imports.d.ts +12 -0
- package/dist/build/app-imports.js +105 -0
- package/dist/build/build-policy.d.ts +5 -3
- package/dist/build/build-policy.js +5 -3
- package/dist/build/candidate-builder.d.ts +1 -1
- package/dist/build/candidate-cli.mjs +8428 -337
- package/dist/build/local-build.d.ts +2 -0
- package/dist/build/local-build.js +28 -6
- package/dist/build/snapshot-package-store.d.ts +1 -1
- package/dist/build/snapshot-package-store.js +7 -2
- package/dist/build/workspace-build.d.ts +92 -5
- package/dist/build/workspace-build.js +93 -19
- package/dist/build-egress.js +4 -4
- package/dist/build.d.ts +1 -1
- package/dist/build.js +1 -1
- package/dist/catalog-frame.js +1 -1
- package/dist/cloudflare.d.ts +13 -3
- package/dist/cloudflare.js +106 -8
- package/dist/frame-binding-wire-script.js +1 -1
- package/dist/frame-binding-wire.d.ts +1 -1
- package/dist/frame-binding-wire.js +5 -3
- package/dist/git-auth.d.ts +0 -2
- package/dist/git-auth.js +0 -2
- package/dist/git-journal.js +4 -4
- package/dist/git.d.ts +0 -1
- package/dist/git.js +0 -2
- package/dist/host.d.ts +39 -13
- package/dist/host.js +268 -142
- package/dist/index.d.ts +26 -15
- package/dist/index.js +40 -16
- package/dist/install-release-cli.d.ts +2 -0
- package/dist/install-release-cli.js +46 -0
- package/dist/installation-client.d.ts +43 -0
- package/dist/installation-client.js +178 -0
- package/dist/installation-execution.d.ts +11 -0
- package/dist/installation-execution.js +184 -0
- package/dist/installation-operations.d.ts +1437 -0
- package/dist/installation-operations.js +664 -0
- package/dist/installation-store-generation.d.ts +3 -0
- package/dist/installation-store-generation.js +16 -0
- package/dist/instance-id.d.ts +10 -0
- package/dist/instance-id.js +10 -0
- package/dist/instance-refusal.d.ts +11 -0
- package/dist/instance-refusal.js +21 -0
- package/dist/internal/delivery.js +4 -2
- package/dist/internal/host-gate.js +7 -1
- package/dist/internal/registry-installations.js +4 -4
- package/dist/keys.d.ts +5 -1
- package/dist/keys.js +10 -2
- package/dist/machine-link/authority.d.ts +89 -0
- package/dist/machine-link/authority.js +37 -0
- package/dist/machine-link/client.d.ts +66 -0
- package/dist/machine-link/client.js +94 -0
- package/dist/machine-link/delivery.d.ts +18 -0
- package/dist/machine-link/delivery.js +55 -0
- package/dist/machine-link/enrollment.d.ts +111 -0
- package/dist/machine-link/enrollment.js +286 -0
- package/dist/machine-link/fences.d.ts +37 -0
- package/dist/machine-link/fences.js +166 -0
- package/dist/machine-link/home.d.ts +20 -0
- package/dist/machine-link/home.js +24 -0
- package/dist/machine-link/host.d.ts +43 -0
- package/dist/machine-link/host.js +189 -0
- package/dist/machine-link/index.d.ts +15 -0
- package/dist/machine-link/index.js +15 -0
- package/dist/machine-link/link.d.ts +48 -0
- package/dist/machine-link/link.js +223 -0
- package/dist/machine-link/presence.d.ts +10 -0
- package/dist/machine-link/presence.js +25 -0
- package/dist/machine-link/workers.d.ts +6 -0
- package/dist/machine-link/workers.js +6 -0
- package/dist/mcp-owner.d.ts +2 -2
- package/dist/mcp-owner.js +41 -33
- package/dist/mcp.d.ts +15 -3
- package/dist/mcp.js +146 -25
- package/dist/pack.d.ts +14 -3
- package/dist/pack.js +44 -19
- package/dist/page/app-access.d.ts +7 -0
- package/dist/page/app-access.js +75 -0
- package/dist/page/boot-host.js +57 -0
- package/dist/page/capabilities.d.ts +3 -3
- package/dist/page/capabilities.js +16 -12
- package/dist/page/computer-handles.d.ts +3 -3
- package/dist/page/computer-target.d.ts +3 -0
- package/dist/page/computer-target.js +9 -0
- package/dist/page/mount.d.ts +23 -7
- package/dist/page/mount.js +152 -16
- package/dist/page-assets.d.ts +22 -0
- package/dist/page-assets.js +28 -0
- package/dist/page-script.d.ts +3 -0
- package/dist/page-script.js +5 -4
- package/dist/release.d.ts +13 -6
- package/dist/release.js +10 -7
- package/dist/root-data.d.ts +16 -6
- package/dist/root-data.js +2 -2
- package/dist/source/index.d.ts +1 -1
- package/dist/source/team-source.d.ts +20 -8
- package/dist/source/team-source.js +39 -10
- package/dist/source/template-seed.d.ts +2 -2
- package/dist/standalone/agent-mail.d.ts +24 -0
- package/dist/standalone/agent-mail.js +62 -0
- package/dist/standalone/agent-store.d.ts +9 -0
- package/dist/standalone/agent-store.js +30 -0
- package/dist/standalone/agents.d.ts +78 -12
- package/dist/standalone/agents.js +470 -59
- package/dist/standalone/app-builds-binding.d.ts +20 -2
- package/dist/standalone/app-builds-binding.js +151 -27
- package/dist/standalone/app-set.d.ts +5 -2
- package/dist/standalone/app-set.js +174 -143
- package/dist/standalone/browser.d.ts +11 -0
- package/dist/standalone/browser.js +72 -0
- package/dist/standalone/builds.d.ts +13 -4
- package/dist/standalone/builds.js +28 -44
- package/dist/standalone/computer-egress.d.ts +2 -0
- package/dist/standalone/computer-egress.js +13 -4
- package/dist/standalone/computer-fleet.d.ts +43 -0
- package/dist/standalone/computer-fleet.js +200 -0
- package/dist/standalone/computer.d.ts +44 -9
- package/dist/standalone/computer.js +132 -25
- package/dist/standalone/install-apps-cli.js +43 -6
- package/dist/standalone/instance.d.ts +2 -2
- package/dist/standalone/instance.js +8 -11
- package/dist/standalone/machine-link.d.ts +354 -0
- package/dist/standalone/machine-link.js +368 -0
- package/dist/standalone/media.d.ts +2 -2
- package/dist/standalone/media.js +19 -16
- package/dist/standalone/preview.d.ts +2 -2
- package/dist/standalone/preview.js +39 -12
- package/dist/standalone/registry.d.ts +149 -9
- package/dist/standalone/registry.js +299 -8
- package/dist/standalone/worker.d.ts +19 -5
- package/dist/standalone/worker.js +90 -54
- package/dist/standalone/workflow-binding.d.ts +28 -32
- package/dist/standalone/workflow-binding.js +20 -20
- package/dist/standalone/workflow-control.d.ts +4 -0
- package/dist/standalone/workflow-control.js +40 -0
- package/dist/standalone/workflow-events.d.ts +2 -2
- package/dist/standalone/workflow-events.js +9 -10
- package/dist/standalone/workflow-git-capture.js +4 -3
- package/dist/standalone/workflow-host.d.ts +177 -152
- package/dist/standalone/workflow-host.js +137 -30
- package/dist/standalone/workflow-node-capture.js +11 -4
- package/dist/standalone/workflow-schedules.d.ts +5 -2
- package/dist/standalone/workflow-schedules.js +9 -10
- package/dist/standalone/workflow-trigger-host.d.ts +88 -6
- package/dist/standalone/workflow-trigger-host.js +2 -2
- package/dist/standalone/workflow-webhooks.d.ts +22 -0
- package/dist/standalone/workflow-webhooks.js +39 -0
- package/dist/standalone/workflows.d.ts +203 -50
- package/dist/standalone/workflows.js +198 -39
- package/dist/storage-frame.d.ts +6 -6
- package/dist/testing/capabilities.js +14 -3
- package/dist/testing/installation.js +26 -2
- package/dist/testing/worker.js +1 -1
- package/dist/testing/workers-runtime.d.ts +8 -2
- package/dist/testing/workers-runtime.js +20 -2
- package/dist/webhook-abuse.d.ts +25 -0
- package/dist/webhook-abuse.js +54 -0
- package/dist/webhook-custody.d.ts +144 -0
- package/dist/webhook-custody.js +222 -0
- package/dist/webhook-ingress.d.ts +36 -0
- package/dist/webhook-ingress.js +146 -0
- package/dist/webhooks.d.ts +111 -0
- package/dist/webhooks.js +189 -0
- package/dist/workers-git.d.ts +12 -17
- package/dist/workers-git.js +60 -55
- package/dist/workers.d.ts +224 -13
- package/dist/workers.js +351 -51
- package/dist/workflow-agent-authority.d.ts +8 -0
- package/dist/workflow-agent-authority.js +42 -0
- package/dist/workflows.d.ts +66 -0
- package/dist/workflows.js +97 -0
- package/docs/api/README.md +63 -37
- package/docs/api/agents.md +17 -0
- package/docs/api/app-storage.md +1 -1
- package/docs/api/apps.md +1394 -543
- package/docs/api/browser/boot.md +132 -0
- package/docs/api/browser.md +1440 -0
- package/docs/api/build-contract.md +38 -25
- package/docs/api/build.md +263 -84
- package/docs/api/cloudflare.md +93 -7
- package/docs/api/git.md +3 -13
- package/docs/api/host.md +944 -118
- package/docs/api/index.md +320 -18
- package/docs/api/keys.md +24 -1
- package/docs/api/mcp.md +59 -12
- package/docs/api/modules.md +33 -40
- package/docs/api/pack.md +57 -8
- package/docs/api/page/mount.md +92 -4
- package/docs/api/workers-git.md +103 -24
- package/docs/api/workers.md +1581 -244
- package/docs/site/agent-quickstart.mdx +28 -14
- package/examples/standalone/worker.ts +3 -1
- package/examples/standalone/wrangler.jsonc +2 -0
- package/package.json +73 -69
- package/dist/installation-consent.d.ts +0 -79
- package/dist/installation-consent.js +0 -82
- package/dist/shell/app-directory.d.ts +0 -542
- package/dist/shell/app-directory.js +0 -199
- package/dist/shell/browser-actions.d.ts +0 -7
- package/dist/shell/browser-actions.js +0 -56
- package/dist/shell/command-host.d.ts +0 -112
- package/dist/shell/command-host.js +0 -502
- package/dist/shell/commands.d.ts +0 -25
- package/dist/shell/commands.js +0 -78
- package/dist/shell/index.d.ts +0 -8
- package/dist/shell/index.js +0 -8
- package/dist/shell/keys.d.ts +0 -41
- package/dist/shell/keys.js +0 -134
- package/dist/shell/shell-module.d.ts +0 -55
- package/dist/shell/shell-module.js +0 -86
- package/dist/shell/window-manager.d.ts +0 -124
- package/dist/shell/window-manager.js +0 -711
- package/dist/shell/workbench-contract.d.ts +0 -68
- package/dist/shell/workbench-directory.d.ts +0 -332
- package/dist/shell/workbench-directory.js +0 -35
- package/dist/shell/workbench-host-types.d.ts +0 -96
- package/dist/shell/workbench-host-types.js +0 -1
- package/dist/shell/workbench-host.d.ts +0 -34
- package/dist/shell/workbench-host.js +0 -347
- package/dist/shell/workbench-model.d.ts +0 -192
- package/dist/shell/workbench-model.js +0 -53
- package/dist/shell/workbench.d.ts +0 -4
- package/dist/shell/workbench.js +0 -2
- package/docs/api/shell/app-directory.md +0 -599
- package/docs/api/shell/command-host.md +0 -224
- package/docs/api/shell/commands.md +0 -197
- package/docs/api/shell/keys.md +0 -183
- package/docs/api/shell/shell-module.md +0 -204
- package/docs/api/shell/window-manager.md +0 -267
- package/docs/api/shell/workbench-directory.md +0 -119
- package/docs/api/shell/workbench.md +0 -205
- package/docs/api/shell.md +0 -1915
- /package/dist/{shell/workbench-contract.js → page/boot-host.d.ts} +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Release } from "@fungi.computer/puffball";
|
|
3
|
+
import { type ArtifactStore } from "./release.js";
|
|
4
|
+
/** Only the host can produce these outcomes; they are not an App build input. */
|
|
5
|
+
export declare const bootFailureSchema: z.ZodEnum<{
|
|
6
|
+
backend_load_failed: "backend_load_failed";
|
|
7
|
+
backend_construction_failed: "backend_construction_failed";
|
|
8
|
+
ui_mount_failed: "ui_mount_failed";
|
|
9
|
+
boot_runner_unavailable: "boot_runner_unavailable";
|
|
10
|
+
boot_browser_binding_missing: "boot_browser_binding_missing";
|
|
11
|
+
boot_clone_unavailable: "boot_clone_unavailable";
|
|
12
|
+
boot_timeout: "boot_timeout";
|
|
13
|
+
boot_cleanup_failed: "boot_cleanup_failed";
|
|
14
|
+
}>;
|
|
15
|
+
export type BootFailure = z.output<typeof bootFailureSchema>;
|
|
16
|
+
export declare const BOOT_MOUNT_DIAGNOSTIC_LIMITS: Readonly<{
|
|
17
|
+
maxEntriesPerKind: 20;
|
|
18
|
+
maxEntriesTotal: 48;
|
|
19
|
+
maxTextChars: 300;
|
|
20
|
+
maxPathChars: 2048;
|
|
21
|
+
maxDroppedCount: 1024;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const bootMountFailurePredicateSchema: z.ZodEnum<{
|
|
24
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
25
|
+
response_status: "response_status";
|
|
26
|
+
request_failed: "request_failed";
|
|
27
|
+
page_error: "page_error";
|
|
28
|
+
candidate_not_mounted: "candidate_not_mounted";
|
|
29
|
+
}>;
|
|
30
|
+
export type BootMountFailurePredicate = z.output<typeof bootMountFailurePredicateSchema>;
|
|
31
|
+
/** Closed, safe names for exceptions used in host-side mount diagnostics. */
|
|
32
|
+
export declare const bootMountDiagnosticErrorNameSchema: z.ZodEnum<{
|
|
33
|
+
TypeError: "TypeError";
|
|
34
|
+
RangeError: "RangeError";
|
|
35
|
+
SyntaxError: "SyntaxError";
|
|
36
|
+
AbortError: "AbortError";
|
|
37
|
+
TimeoutError: "TimeoutError";
|
|
38
|
+
Other: "Other";
|
|
39
|
+
Error: "Error";
|
|
40
|
+
}>;
|
|
41
|
+
export type BootMountDiagnosticErrorName = z.output<typeof bootMountDiagnosticErrorNameSchema>;
|
|
42
|
+
declare const bootMountRequestFailureKindSchema: z.ZodEnum<{
|
|
43
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
44
|
+
response_status: "response_status";
|
|
45
|
+
request_failed: "request_failed";
|
|
46
|
+
}>;
|
|
47
|
+
export type BootMountRequestFailureKind = z.output<typeof bootMountRequestFailureKindSchema>;
|
|
48
|
+
/** Bounded, URL-redacted observations from one failed candidate mount. */
|
|
49
|
+
export declare const bootMountDiagnosticsSchema: z.ZodObject<{
|
|
50
|
+
failedPredicate: z.ZodEnum<{
|
|
51
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
52
|
+
response_status: "response_status";
|
|
53
|
+
request_failed: "request_failed";
|
|
54
|
+
page_error: "page_error";
|
|
55
|
+
candidate_not_mounted: "candidate_not_mounted";
|
|
56
|
+
}>;
|
|
57
|
+
errorName: z.ZodOptional<z.ZodEnum<{
|
|
58
|
+
TypeError: "TypeError";
|
|
59
|
+
RangeError: "RangeError";
|
|
60
|
+
SyntaxError: "SyntaxError";
|
|
61
|
+
AbortError: "AbortError";
|
|
62
|
+
TimeoutError: "TimeoutError";
|
|
63
|
+
Other: "Other";
|
|
64
|
+
Error: "Error";
|
|
65
|
+
}>>;
|
|
66
|
+
finalUrlPath: z.ZodString;
|
|
67
|
+
consoleErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
68
|
+
pageErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
69
|
+
failedRequests: z.ZodArray<z.ZodObject<{
|
|
70
|
+
path: z.ZodString;
|
|
71
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
74
|
+
response_status: "response_status";
|
|
75
|
+
request_failed: "request_failed";
|
|
76
|
+
}>>;
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
droppedCount: z.ZodNumber;
|
|
79
|
+
}, z.core.$strict>;
|
|
80
|
+
export type BootMountDiagnostics = z.output<typeof bootMountDiagnosticsSchema>;
|
|
81
|
+
/** Safe host-authored reason; never reflects guest logs, exceptions or credentials. */
|
|
82
|
+
export declare class BootGateError extends Error {
|
|
83
|
+
readonly code: BootFailure;
|
|
84
|
+
readonly name = "BootGateError";
|
|
85
|
+
readonly diagnostics?: BootMountDiagnostics;
|
|
86
|
+
constructor(code: BootFailure, options?: ErrorOptions & {
|
|
87
|
+
diagnostics?: BootMountDiagnostics;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** A finite host policy, not a candidate-configurable health check. */
|
|
91
|
+
export declare const BOOT_DEADLINE_MS = 10000;
|
|
92
|
+
/** The original outer-request allowance, reserved for transport and cleanup. */
|
|
93
|
+
export declare const BOOT_TRANSPORT_GRACE_MS = 2000;
|
|
94
|
+
/** Immutable artifact references only; bytes use the private native data plane. */
|
|
95
|
+
export declare const bootUiSchema: z.ZodObject<{
|
|
96
|
+
identity: z.ZodObject<{
|
|
97
|
+
appId: z.ZodString;
|
|
98
|
+
releaseId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@fungi.computer/puffball").ReleaseId, string>>;
|
|
99
|
+
surfaceId: z.ZodLiteral<"host-boot">;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
base: z.ZodString;
|
|
102
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
103
|
+
path: z.ZodString;
|
|
104
|
+
contentType: z.ZodString;
|
|
105
|
+
artifactRef: z.ZodPipe<z.ZodString, z.ZodTransform<import("@fungi.computer/puffball").ArtifactRef, string>>;
|
|
106
|
+
digest: z.ZodPipe<z.ZodString, z.ZodTransform<import("@fungi.computer/puffball").Sha256Digest, string>>;
|
|
107
|
+
}, z.core.$strict>>;
|
|
108
|
+
}, z.core.$strict>;
|
|
109
|
+
export type BootUi = z.output<typeof bootUiSchema>;
|
|
110
|
+
/** Captures the same no-grant UI representation as a private candidate preview. */
|
|
111
|
+
export declare function readBootUi(store: ArtifactStore, release: Release): Promise<BootUi | null>;
|
|
112
|
+
export declare const bootCheckResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
113
|
+
kind: z.ZodLiteral<"passed">;
|
|
114
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
115
|
+
kind: z.ZodLiteral<"not_checked">;
|
|
116
|
+
code: z.ZodEnum<{
|
|
117
|
+
boot_runner_unavailable: "boot_runner_unavailable";
|
|
118
|
+
boot_browser_binding_missing: "boot_browser_binding_missing";
|
|
119
|
+
boot_clone_unavailable: "boot_clone_unavailable";
|
|
120
|
+
boot_timeout: "boot_timeout";
|
|
121
|
+
boot_cleanup_failed: "boot_cleanup_failed";
|
|
122
|
+
}>;
|
|
123
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
124
|
+
kind: z.ZodLiteral<"refused">;
|
|
125
|
+
code: z.ZodEnum<{
|
|
126
|
+
backend_load_failed: "backend_load_failed";
|
|
127
|
+
backend_construction_failed: "backend_construction_failed";
|
|
128
|
+
ui_mount_failed: "ui_mount_failed";
|
|
129
|
+
boot_runner_unavailable: "boot_runner_unavailable";
|
|
130
|
+
boot_browser_binding_missing: "boot_browser_binding_missing";
|
|
131
|
+
boot_clone_unavailable: "boot_clone_unavailable";
|
|
132
|
+
boot_timeout: "boot_timeout";
|
|
133
|
+
boot_cleanup_failed: "boot_cleanup_failed";
|
|
134
|
+
}>;
|
|
135
|
+
diagnostics: z.ZodOptional<z.ZodObject<{
|
|
136
|
+
failedPredicate: z.ZodEnum<{
|
|
137
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
138
|
+
response_status: "response_status";
|
|
139
|
+
request_failed: "request_failed";
|
|
140
|
+
page_error: "page_error";
|
|
141
|
+
candidate_not_mounted: "candidate_not_mounted";
|
|
142
|
+
}>;
|
|
143
|
+
errorName: z.ZodOptional<z.ZodEnum<{
|
|
144
|
+
TypeError: "TypeError";
|
|
145
|
+
RangeError: "RangeError";
|
|
146
|
+
SyntaxError: "SyntaxError";
|
|
147
|
+
AbortError: "AbortError";
|
|
148
|
+
TimeoutError: "TimeoutError";
|
|
149
|
+
Other: "Other";
|
|
150
|
+
Error: "Error";
|
|
151
|
+
}>>;
|
|
152
|
+
finalUrlPath: z.ZodString;
|
|
153
|
+
consoleErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
154
|
+
pageErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
155
|
+
failedRequests: z.ZodArray<z.ZodObject<{
|
|
156
|
+
path: z.ZodString;
|
|
157
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
158
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
159
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
160
|
+
response_status: "response_status";
|
|
161
|
+
request_failed: "request_failed";
|
|
162
|
+
}>>;
|
|
163
|
+
}, z.core.$strict>>;
|
|
164
|
+
droppedCount: z.ZodNumber;
|
|
165
|
+
}, z.core.$strict>>;
|
|
166
|
+
}, z.core.$strict>], "kind">;
|
|
167
|
+
export type BootCheckResult = z.output<typeof bootCheckResultSchema>;
|
|
168
|
+
/** A UI check recorded on an installation operation, never installation authority. */
|
|
169
|
+
export declare const uiBootCheckOutcomeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
170
|
+
kind: z.ZodLiteral<"passed">;
|
|
171
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
172
|
+
kind: z.ZodLiteral<"failed">;
|
|
173
|
+
code: z.ZodLiteral<"ui_mount_failed">;
|
|
174
|
+
diagnostics: z.ZodOptional<z.ZodObject<{
|
|
175
|
+
failedPredicate: z.ZodEnum<{
|
|
176
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
177
|
+
response_status: "response_status";
|
|
178
|
+
request_failed: "request_failed";
|
|
179
|
+
page_error: "page_error";
|
|
180
|
+
candidate_not_mounted: "candidate_not_mounted";
|
|
181
|
+
}>;
|
|
182
|
+
errorName: z.ZodOptional<z.ZodEnum<{
|
|
183
|
+
TypeError: "TypeError";
|
|
184
|
+
RangeError: "RangeError";
|
|
185
|
+
SyntaxError: "SyntaxError";
|
|
186
|
+
AbortError: "AbortError";
|
|
187
|
+
TimeoutError: "TimeoutError";
|
|
188
|
+
Other: "Other";
|
|
189
|
+
Error: "Error";
|
|
190
|
+
}>>;
|
|
191
|
+
finalUrlPath: z.ZodString;
|
|
192
|
+
consoleErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
193
|
+
pageErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
194
|
+
failedRequests: z.ZodArray<z.ZodObject<{
|
|
195
|
+
path: z.ZodString;
|
|
196
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
197
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
198
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
199
|
+
response_status: "response_status";
|
|
200
|
+
request_failed: "request_failed";
|
|
201
|
+
}>>;
|
|
202
|
+
}, z.core.$strict>>;
|
|
203
|
+
droppedCount: z.ZodNumber;
|
|
204
|
+
}, z.core.$strict>>;
|
|
205
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
206
|
+
kind: z.ZodLiteral<"not_checked">;
|
|
207
|
+
code: z.ZodEnum<{
|
|
208
|
+
boot_runner_unavailable: "boot_runner_unavailable";
|
|
209
|
+
boot_browser_binding_missing: "boot_browser_binding_missing";
|
|
210
|
+
boot_clone_unavailable: "boot_clone_unavailable";
|
|
211
|
+
boot_timeout: "boot_timeout";
|
|
212
|
+
boot_cleanup_failed: "boot_cleanup_failed";
|
|
213
|
+
ui_check_not_run_on_host: "ui_check_not_run_on_host";
|
|
214
|
+
}>;
|
|
215
|
+
}, z.core.$strict>], "kind">;
|
|
216
|
+
/**
|
|
217
|
+
* A UI check result recorded on an installation operation, never installation authority.
|
|
218
|
+
*
|
|
219
|
+
* @inline
|
|
220
|
+
*/
|
|
221
|
+
export type UiBootCheckOutcome = z.output<typeof uiBootCheckOutcomeSchema>;
|
|
222
|
+
/** Owner-facing 422 body; diagnostics are never copied into other failures. */
|
|
223
|
+
export declare const bootRefusalSchema: z.ZodObject<{
|
|
224
|
+
error: z.ZodEnum<{
|
|
225
|
+
backend_load_failed: "backend_load_failed";
|
|
226
|
+
backend_construction_failed: "backend_construction_failed";
|
|
227
|
+
ui_mount_failed: "ui_mount_failed";
|
|
228
|
+
boot_runner_unavailable: "boot_runner_unavailable";
|
|
229
|
+
boot_browser_binding_missing: "boot_browser_binding_missing";
|
|
230
|
+
boot_clone_unavailable: "boot_clone_unavailable";
|
|
231
|
+
boot_timeout: "boot_timeout";
|
|
232
|
+
boot_cleanup_failed: "boot_cleanup_failed";
|
|
233
|
+
}>;
|
|
234
|
+
message: z.ZodString;
|
|
235
|
+
diagnostics: z.ZodOptional<z.ZodObject<{
|
|
236
|
+
failedPredicate: z.ZodEnum<{
|
|
237
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
238
|
+
response_status: "response_status";
|
|
239
|
+
request_failed: "request_failed";
|
|
240
|
+
page_error: "page_error";
|
|
241
|
+
candidate_not_mounted: "candidate_not_mounted";
|
|
242
|
+
}>;
|
|
243
|
+
errorName: z.ZodOptional<z.ZodEnum<{
|
|
244
|
+
TypeError: "TypeError";
|
|
245
|
+
RangeError: "RangeError";
|
|
246
|
+
SyntaxError: "SyntaxError";
|
|
247
|
+
AbortError: "AbortError";
|
|
248
|
+
TimeoutError: "TimeoutError";
|
|
249
|
+
Other: "Other";
|
|
250
|
+
Error: "Error";
|
|
251
|
+
}>>;
|
|
252
|
+
finalUrlPath: z.ZodString;
|
|
253
|
+
consoleErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
254
|
+
pageErrors: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
255
|
+
failedRequests: z.ZodArray<z.ZodObject<{
|
|
256
|
+
path: z.ZodString;
|
|
257
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
258
|
+
failureKind: z.ZodOptional<z.ZodEnum<{
|
|
259
|
+
unexpected_candidate_request: "unexpected_candidate_request";
|
|
260
|
+
response_status: "response_status";
|
|
261
|
+
request_failed: "request_failed";
|
|
262
|
+
}>>;
|
|
263
|
+
}, z.core.$strict>>;
|
|
264
|
+
droppedCount: z.ZodNumber;
|
|
265
|
+
}, z.core.$strict>>;
|
|
266
|
+
}, z.core.$strict>;
|
|
267
|
+
export {};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import stripAnsi from "strip-ansi";
|
|
3
|
+
import { parseArtifactRef, parseReleaseId, parseSha256Digest, } from "@fungi.computer/puffball";
|
|
4
|
+
import { defaultAssetPolicy, verifyRelease, } from "./release.js";
|
|
5
|
+
/** Only the host can produce these outcomes; they are not an App build input. */
|
|
6
|
+
export const bootFailureSchema = z.enum([
|
|
7
|
+
"backend_load_failed",
|
|
8
|
+
"backend_construction_failed",
|
|
9
|
+
"ui_mount_failed",
|
|
10
|
+
"boot_runner_unavailable",
|
|
11
|
+
"boot_browser_binding_missing",
|
|
12
|
+
"boot_clone_unavailable",
|
|
13
|
+
"boot_timeout",
|
|
14
|
+
"boot_cleanup_failed",
|
|
15
|
+
]);
|
|
16
|
+
export const BOOT_MOUNT_DIAGNOSTIC_LIMITS = Object.freeze({
|
|
17
|
+
maxEntriesPerKind: 20,
|
|
18
|
+
maxEntriesTotal: 48,
|
|
19
|
+
maxTextChars: 300,
|
|
20
|
+
maxPathChars: 2048,
|
|
21
|
+
maxDroppedCount: 1024,
|
|
22
|
+
});
|
|
23
|
+
const bootMountDiagnosticTextSchema = z
|
|
24
|
+
.string()
|
|
25
|
+
.transform((value) => {
|
|
26
|
+
const withoutTerminalControls = stripAnsi(value.slice(0, 4096)).replace(/[\p{Cc}\p{Cf}]/gu, "");
|
|
27
|
+
return withoutTerminalControls
|
|
28
|
+
.replace(/\b(?:authorization|cookie)\s*:\s*[^\r\n]*/giu, "[redacted]")
|
|
29
|
+
.replace(/\b(?:access[_-]?token|token|password|secret)\b\s*[:=]\s*["']?[^,\s;"']+/giu, "[redacted]")
|
|
30
|
+
.replace(/\bBearer\s+\S+/giu, "[redacted]")
|
|
31
|
+
.replace(/\S*(?:[a-z][a-z\d+.-]*:\/\/|\?)[^\s]*/giu, "[redacted]")
|
|
32
|
+
.trim()
|
|
33
|
+
.slice(0, BOOT_MOUNT_DIAGNOSTIC_LIMITS.maxTextChars);
|
|
34
|
+
})
|
|
35
|
+
.pipe(z.string().max(BOOT_MOUNT_DIAGNOSTIC_LIMITS.maxTextChars));
|
|
36
|
+
const bootMountDiagnosticPathSchema = z
|
|
37
|
+
.string()
|
|
38
|
+
.min(1)
|
|
39
|
+
.max(BOOT_MOUNT_DIAGNOSTIC_LIMITS.maxPathChars)
|
|
40
|
+
.refine((path) => path === "out-of-scope" ||
|
|
41
|
+
(path.startsWith("/") && !path.includes("?") && !path.includes("#")));
|
|
42
|
+
export const bootMountFailurePredicateSchema = z.enum([
|
|
43
|
+
"unexpected_candidate_request",
|
|
44
|
+
"response_status",
|
|
45
|
+
"request_failed",
|
|
46
|
+
"page_error",
|
|
47
|
+
"candidate_not_mounted",
|
|
48
|
+
]);
|
|
49
|
+
/** Closed, safe names for exceptions used in host-side mount diagnostics. */
|
|
50
|
+
export const bootMountDiagnosticErrorNameSchema = z.enum([
|
|
51
|
+
"Error",
|
|
52
|
+
"TypeError",
|
|
53
|
+
"RangeError",
|
|
54
|
+
"SyntaxError",
|
|
55
|
+
"AbortError",
|
|
56
|
+
"TimeoutError",
|
|
57
|
+
"Other",
|
|
58
|
+
]);
|
|
59
|
+
const bootMountRequestFailureKindSchema = z.enum([
|
|
60
|
+
"unexpected_candidate_request",
|
|
61
|
+
"response_status",
|
|
62
|
+
"request_failed",
|
|
63
|
+
]);
|
|
64
|
+
const bootMountFailedRequestSchema = z
|
|
65
|
+
.strictObject({
|
|
66
|
+
path: bootMountDiagnosticPathSchema,
|
|
67
|
+
status: z.number().int().min(100).max(599).optional(),
|
|
68
|
+
failureKind: bootMountRequestFailureKindSchema.optional(),
|
|
69
|
+
})
|
|
70
|
+
.refine((request) => request.status !== undefined || request.failureKind !== undefined);
|
|
71
|
+
/** Bounded, URL-redacted observations from one failed candidate mount. */
|
|
72
|
+
export const bootMountDiagnosticsSchema = z
|
|
73
|
+
.strictObject({
|
|
74
|
+
failedPredicate: bootMountFailurePredicateSchema,
|
|
75
|
+
errorName: bootMountDiagnosticErrorNameSchema.optional(),
|
|
76
|
+
finalUrlPath: bootMountDiagnosticPathSchema,
|
|
77
|
+
consoleErrors: z
|
|
78
|
+
.array(bootMountDiagnosticTextSchema)
|
|
79
|
+
.max(BOOT_MOUNT_DIAGNOSTIC_LIMITS.maxEntriesPerKind),
|
|
80
|
+
pageErrors: z
|
|
81
|
+
.array(bootMountDiagnosticTextSchema)
|
|
82
|
+
.max(BOOT_MOUNT_DIAGNOSTIC_LIMITS.maxEntriesPerKind),
|
|
83
|
+
failedRequests: z
|
|
84
|
+
.array(bootMountFailedRequestSchema)
|
|
85
|
+
.max(BOOT_MOUNT_DIAGNOSTIC_LIMITS.maxEntriesPerKind),
|
|
86
|
+
droppedCount: z
|
|
87
|
+
.number()
|
|
88
|
+
.int()
|
|
89
|
+
.min(0)
|
|
90
|
+
.max(BOOT_MOUNT_DIAGNOSTIC_LIMITS.maxDroppedCount),
|
|
91
|
+
})
|
|
92
|
+
.superRefine((diagnostics, context) => {
|
|
93
|
+
if (diagnostics.consoleErrors.length +
|
|
94
|
+
diagnostics.pageErrors.length +
|
|
95
|
+
diagnostics.failedRequests.length >
|
|
96
|
+
BOOT_MOUNT_DIAGNOSTIC_LIMITS.maxEntriesTotal)
|
|
97
|
+
context.addIssue({
|
|
98
|
+
code: "custom",
|
|
99
|
+
message: "Mount observations exceed the total bound",
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
const reasons = {
|
|
103
|
+
backend_load_failed: "Candidate backend module could not load",
|
|
104
|
+
backend_construction_failed: "Candidate backend could not construct on App storage",
|
|
105
|
+
ui_mount_failed: "Candidate UI entry did not mount",
|
|
106
|
+
boot_runner_unavailable: "Host boot runner is unavailable; the old version remains selected",
|
|
107
|
+
boot_browser_binding_missing: "Cloudflare Browser Rendering binding BROWSER is missing; configure the browser binding before installing an App with a UI",
|
|
108
|
+
boot_clone_unavailable: "Host facet clone is unavailable; copy-seeded construction refused",
|
|
109
|
+
boot_timeout: "Candidate boot exceeded the host time limit",
|
|
110
|
+
boot_cleanup_failed: "Host could not confirm candidate cleanup; activation refused",
|
|
111
|
+
};
|
|
112
|
+
/** Safe host-authored reason; never reflects guest logs, exceptions or credentials. */
|
|
113
|
+
export class BootGateError extends Error {
|
|
114
|
+
code;
|
|
115
|
+
name = "BootGateError";
|
|
116
|
+
diagnostics;
|
|
117
|
+
constructor(code, options) {
|
|
118
|
+
super(reasons[code], options);
|
|
119
|
+
this.code = code;
|
|
120
|
+
if (options?.diagnostics !== undefined) {
|
|
121
|
+
if (code !== "ui_mount_failed")
|
|
122
|
+
throw new TypeError("Mount diagnostics require ui_mount_failed");
|
|
123
|
+
this.diagnostics = bootMountDiagnosticsSchema.parse(options.diagnostics);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** A finite host policy, not a candidate-configurable health check. */
|
|
128
|
+
export const BOOT_DEADLINE_MS = 10_000;
|
|
129
|
+
/** The original outer-request allowance, reserved for transport and cleanup. */
|
|
130
|
+
export const BOOT_TRANSPORT_GRACE_MS = 2_000;
|
|
131
|
+
/** Immutable artifact references only; bytes use the private native data plane. */
|
|
132
|
+
export const bootUiSchema = z.strictObject({
|
|
133
|
+
identity: z.strictObject({
|
|
134
|
+
appId: z.string().min(1).max(256),
|
|
135
|
+
releaseId: z.string().transform(parseReleaseId),
|
|
136
|
+
surfaceId: z.literal("host-boot"),
|
|
137
|
+
}),
|
|
138
|
+
base: z.string().min(1).max(2048),
|
|
139
|
+
assets: z
|
|
140
|
+
.array(z.strictObject({
|
|
141
|
+
path: z.string().min(1).max(4096),
|
|
142
|
+
contentType: z.string().min(1).max(256),
|
|
143
|
+
artifactRef: z.string().transform(parseArtifactRef),
|
|
144
|
+
digest: z.string().transform(parseSha256Digest),
|
|
145
|
+
}))
|
|
146
|
+
.max(defaultAssetPolicy.maxObjects),
|
|
147
|
+
});
|
|
148
|
+
/** Captures the same no-grant UI representation as a private candidate preview. */
|
|
149
|
+
export async function readBootUi(store, release) {
|
|
150
|
+
const verified = await verifyRelease(store, release, defaultAssetPolicy, false);
|
|
151
|
+
if (verified.ui === null)
|
|
152
|
+
return null;
|
|
153
|
+
const identity = {
|
|
154
|
+
appId: release.appId,
|
|
155
|
+
releaseId: release.releaseId,
|
|
156
|
+
surfaceId: "host-boot",
|
|
157
|
+
};
|
|
158
|
+
if (verified.ui.kind === "html") {
|
|
159
|
+
return {
|
|
160
|
+
identity,
|
|
161
|
+
base: "./",
|
|
162
|
+
assets: [
|
|
163
|
+
{
|
|
164
|
+
path: "/index.html",
|
|
165
|
+
contentType: "text/html; charset=utf-8",
|
|
166
|
+
artifactRef: verified.ui.artifactRef,
|
|
167
|
+
digest: verified.ui.digest,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const assets = [];
|
|
173
|
+
for (const asset of verified.ui.build.assets)
|
|
174
|
+
assets.push({
|
|
175
|
+
path: asset.path,
|
|
176
|
+
contentType: asset.contentType,
|
|
177
|
+
artifactRef: asset.artifactRef,
|
|
178
|
+
digest: asset.digest,
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
identity,
|
|
182
|
+
// Preserve the build producer's relative base. A relative Vite base keeps
|
|
183
|
+
// every asset beneath the host-selected boot URL without rewriting HTML.
|
|
184
|
+
base: verified.ui.build.base,
|
|
185
|
+
assets,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
export const bootCheckResultSchema = z.discriminatedUnion("kind", [
|
|
189
|
+
z.strictObject({ kind: z.literal("passed") }),
|
|
190
|
+
z.strictObject({
|
|
191
|
+
kind: z.literal("not_checked"),
|
|
192
|
+
code: z.enum([
|
|
193
|
+
"boot_runner_unavailable",
|
|
194
|
+
"boot_browser_binding_missing",
|
|
195
|
+
"boot_timeout",
|
|
196
|
+
"boot_clone_unavailable",
|
|
197
|
+
"boot_cleanup_failed",
|
|
198
|
+
]),
|
|
199
|
+
}),
|
|
200
|
+
z
|
|
201
|
+
.strictObject({
|
|
202
|
+
kind: z.literal("refused"),
|
|
203
|
+
code: bootFailureSchema,
|
|
204
|
+
diagnostics: bootMountDiagnosticsSchema.optional(),
|
|
205
|
+
})
|
|
206
|
+
.refine((result) => result.diagnostics === undefined || result.code === "ui_mount_failed"),
|
|
207
|
+
]);
|
|
208
|
+
/** A UI check recorded on an installation operation, never installation authority. */
|
|
209
|
+
export const uiBootCheckOutcomeSchema = z.discriminatedUnion("kind", [
|
|
210
|
+
z.strictObject({ kind: z.literal("passed") }),
|
|
211
|
+
z.strictObject({
|
|
212
|
+
kind: z.literal("failed"),
|
|
213
|
+
code: z.literal("ui_mount_failed"),
|
|
214
|
+
diagnostics: bootMountDiagnosticsSchema.optional(),
|
|
215
|
+
}),
|
|
216
|
+
z.strictObject({
|
|
217
|
+
kind: z.literal("not_checked"),
|
|
218
|
+
code: z.enum([
|
|
219
|
+
// Team hosts deliberately skip this check in their own isolate.
|
|
220
|
+
"ui_check_not_run_on_host",
|
|
221
|
+
"boot_runner_unavailable",
|
|
222
|
+
"boot_browser_binding_missing",
|
|
223
|
+
"boot_timeout",
|
|
224
|
+
"boot_clone_unavailable",
|
|
225
|
+
"boot_cleanup_failed",
|
|
226
|
+
]),
|
|
227
|
+
}),
|
|
228
|
+
]);
|
|
229
|
+
/** Owner-facing 422 body; diagnostics are never copied into other failures. */
|
|
230
|
+
export const bootRefusalSchema = z
|
|
231
|
+
.strictObject({
|
|
232
|
+
error: bootFailureSchema,
|
|
233
|
+
message: z.string().min(1).max(256),
|
|
234
|
+
diagnostics: bootMountDiagnosticsSchema.optional(),
|
|
235
|
+
})
|
|
236
|
+
.refine((refusal) => refusal.diagnostics === undefined || refusal.error === "ui_mount_failed");
|