Skip to content
API reference

cloudflare

Import
import * as api from "@fungi.computer/oyster/cloudflare";
Kind Export Description
type alias FrameBindingProps Host-minted caller-frame routing props; never supplied by the App.
type alias FrameBindingMethod The host’s maintained positional argument/result codecs and operation policy.
type alias FrameBindingMethods Method descriptors for the closed App binding vocabulary.
type alias AppFacetStub Native facet handle; method RPCs are decoded at the invocation boundary.
type alias AppInstanceContext Only the native storage and facet capabilities used by an App Instance. FacetClass is the host’s Durable Object class type (DurableObjectClass on workerd, celld and Cloudflare); Oyster passes it through unopened.
type alias AppWorkerCode The module set the Worker Loader runs for one App backend.
type alias AppInstanceLoader Loader memoization and class lookup; entrypoint access is not required.
type alias FrameBindingReply Private RPC envelope. Domain results, including domain refusals, stay inside value.
type alias FrameBindingWire Native entrypoint methods carry the envelope; guest interfaces are restored by wrap.
type alias GuestLimits Per-invocation budgets enforced by the guest Worker Loader, including facets.
constant MAX_APP_REPLY_BYTES Retained shard reply ceiling; replies settle before the frame aborts its facet.
constant backgroundFrameMethods Shared replay-only port codecs. Origin input is verified by the host and fails with a typed refusal.
constant frameBindingPropsSchema The shared RPC boundary decoder for host-minted invocation binding props.
function checkBackendConstruction() The Instance owns the disposable facet and supplies its already-read prior state schema. Only initialized App storage is copied; supervisor state and authority are never copied. A unique Loader ID isolates candidate globals. No invocation frame or guestEnv factory is accepted.
function edgeVerifiedObjectCache() The zone’s edge cache as a VerifiedObjectCache: each verified object under a digest-named key on origin that no route serves. A failed write is logged and answers unstored; the next reader verifies from the store again.
function r2ArtifactStore() Store Release artifacts without loading the Worker ownership barrel.
function captureFrameBindingReply() Encode supervisor refusals before native RPC can discard Error properties.
function decodeFrameBindingProps() Decode a host routing packet or refuse it before any Instance lookup.
function frameBindingEntrypoint() One native binding factory for both Hub and standalone, preserving RPC values.
function createCloudflareInvocationGate() End the native App facet when live authority closes early, before the gate admits again.
function createCloudflareAppInstance() Run an App Instance inside a SQLite-backed Durable Object on workerd, celld or Cloudflare. Supervisor state lives in the Durable Object’s own SQLite; the App backend runs in a named app facet loaded through the Worker Loader, so its database survives Release replacement and stays separate from the supervisor. Guest code gets only host gatekeeper bindings and no ambient outbound access.

FrameBindingPropstype alias

Section titled “FrameBindingProps”
Signature
type FrameBindingProps = Readonly<{
instanceId: string;
binding: AppBackendBindingName;
frameId: string;
}>;

Host-minted caller-frame routing props; never supplied by the App.


FrameBindingMethodtype alias

Section titled “FrameBindingMethod”
Signature
type FrameBindingMethod<Result> = Readonly<{
decodeArgs: (raw) => readonly unknown[];
decodeResult: z.ZodType<Result>["parse"];
requiredOperations: (args) => readonly string[];
}>;

The host’s maintained positional argument/result codecs and operation policy.

Type Parameter
Result

FrameBindingMethodstype alias

Section titled “FrameBindingMethods”
Signature
type FrameBindingMethods<Result> = Readonly<
Partial<
Record<
AppBackendBindingName,
Readonly<Record<string, FrameBindingMethod<Result>>>
>
>
>;

Method descriptors for the closed App binding vocabulary.

Type Parameter
Result

AppFacetStubtype alias

Section titled “AppFacetStub”
Signature
type AppFacetStub = Readonly<{
fetch: (request) => Promise<Response>;
}>;

Native facet handle; method RPCs are decoded at the invocation boundary.


AppInstanceContexttype alias

Section titled “AppInstanceContext”
Signature
type AppInstanceContext<FacetClass> = Readonly<{
id: Readonly<{
name?: string;
}>;
storage: WatchdogSqliteOwner;
facets: Readonly<{
get: (name, prepare) => AppFacetStub;
abort: (name, reason) => void;
delete: (name) => void;
clone?: (source, destination) => void;
}>;
}>;

Only the native storage and facet capabilities used by an App Instance. FacetClass is the host’s Durable Object class type (DurableObjectClass on workerd, celld and Cloudflare); Oyster passes it through unopened.

Type Parameter
FacetClass

AppWorkerCodetype alias

Section titled “AppWorkerCode”
Signature
type AppWorkerCode = Readonly<{
compatibilityDate: string;
mainModule: string;
modules: Readonly<Record<string, string>>;
env: object;
globalOutbound: null;
limits: GuestLimits;
}>;

The module set the Worker Loader runs for one App backend.


AppInstanceLoadertype alias

Section titled “AppInstanceLoader”
Signature
type AppInstanceLoader<FacetClass> = Readonly<{
get: (
id,
configure,
) => Readonly<{
getDurableObjectClass: (exportName) => FacetClass;
}>;
}>;

Loader memoization and class lookup; entrypoint access is not required.

Type Parameter
FacetClass

FrameBindingReplytype alias

Section titled “FrameBindingReply”
Signature
type FrameBindingReply<Value> =
| Readonly<{
kind: "result";
value: Value;
}>
| Readonly<{
kind: "local_refusal";
code: AppInstanceErrorCode;
}>;

Private RPC envelope. Domain results, including domain refusals, stay inside value.

Type Parameter
Value

FrameBindingWiretype alias

Section titled “FrameBindingWire”
Signature
type FrameBindingWire<Methods> = {
[Name in keyof Methods]: Methods[Name] extends (
args: infer Args,
) => Promise<infer Value>
? (args: Args) => Promise<FrameBindingReply<Value>>
: never;
};

Native entrypoint methods carry the envelope; guest interfaces are restored by wrap.

Type Parameter
Methods

GuestLimitstype alias

Section titled “GuestLimits”
Signature
type GuestLimits = Readonly<{
cpuMs: number;
subRequests: number;
}>;

Per-invocation budgets enforced by the guest Worker Loader, including facets.

MAX_APP_REPLY_BYTESconstant

Section titled “MAX_APP_REPLY_BYTES”
Signature
const MAX_APP_REPLY_BYTES: number;

Retained shard reply ceiling; replies settle before the frame aborts its facet.


backgroundFrameMethodsconstant

Section titled “backgroundFrameMethods”
Signature
const backgroundFrameMethods: object;

Shared replay-only port codecs. Origin input is verified by the host and fails with a typed refusal.

Name Type Description
BACKGROUND object -
BACKGROUND.admit object -
BACKGROUND.admit.decodeArgs() (raw) => [unknown] | undefined[] Malformed arity supplies invalid origin evidence for the host’s typed refusal.
BACKGROUND.admit.decodeResult() (raw) => | { kind: "admitted"; } | { kind: "refused"; code: "access_changed"; } Preserve the host’s closed admitted/refused result.
BACKGROUND.admit.requiredOperations() () => string[] Only the host-minted replay grant supplies this operation.

frameBindingPropsSchemaconstant

Section titled “frameBindingPropsSchema”
Signature
const frameBindingPropsSchema: Struct<{
instanceId: Codec<InstanceId, string, never, never>;
frameId: String;
binding: refine<
| "BACKGROUND"
| "GIT"
| "EVENTS"
| "APPS"
| "WORKFLOWS"
| "APP_STORAGE"
| "MEDIA"
| "COMPUTER"
| "INBOX"
| "AGENTS",
String
>;
}>;

The shared RPC boundary decoder for host-minted invocation binding props.

checkBackendConstruction()function

Section titled “checkBackendConstruction()”
Signature
function checkBackendConstruction<FacetClass>(
ctx,
loader,
artifact,
limits,
priorStateSchema,
): Promise<void>;

The Instance owns the disposable facet and supplies its already-read prior state schema. Only initialized App storage is copied; supervisor state and authority are never copied. A unique Loader ID isolates candidate globals. No invocation frame or guestEnv factory is accepted.

Type Parameter
FacetClass
Parameter Type
ctx Pick<AppInstanceContext<FacetClass>, "facets">
loader | Readonly<{ get: (id, configure) => Readonly<{ getDurableObjectClass: (exportName) => FacetClass; }>; }> | undefined
artifact Backend
limits GuestLimits
priorStateSchema number | null

Promise<void>


edgeVerifiedObjectCache()function

Section titled “edgeVerifiedObjectCache()”
Signature
function edgeVerifiedObjectCache(cache, origin): VerifiedObjectCache;

The zone’s edge cache as a VerifiedObjectCache: each verified object under a digest-named key on origin that no route serves. A failed write is logged and answers unstored; the next reader verifies from the store again.

Parameter Type
cache Pick<Cache, "match" | "put">
origin string

VerifiedObjectCache


r2ArtifactStore()function

Section titled “r2ArtifactStore()”
Signature
function r2ArtifactStore(bucket): Readonly<{
get: (artifactRef) => Promise<Uint8Array<ArrayBufferLike> | null>;
put: (artifactRef, bytes) => Promise<void>;
}> &
Readonly<{
head: (artifactRef) => Promise<Readonly<{
byteLength: number;
digest: Sha256Digest | null;
}> | null>;
}> &
Readonly<{
stream: (
artifactRef,
signal?,
) => Promise<ReadableStream<Uint8Array<ArrayBufferLike>> | null>;
}>;

Store Release artifacts without loading the Worker ownership barrel.

Parameter Type
bucket R2Bucket

Readonly<{ get: (artifactRef) => Promise<Uint8Array<ArrayBufferLike> | null>; put: (artifactRef, bytes) => Promise<void>; }> & Readonly<{ head: (artifactRef) => Promise< | Readonly<{ byteLength: number; digest: Sha256Digest | null; }> | null>; }> & Readonly<{ stream: (artifactRef, signal?) => Promise<ReadableStream<Uint8Array<ArrayBufferLike>> | null>; }>


captureFrameBindingReply()function

Section titled “captureFrameBindingReply()”
Signature
function captureFrameBindingReply<Value>(
run,
): Promise<FrameBindingReply<Value>>;

Encode supervisor refusals before native RPC can discard Error properties.

Type Parameter
Value
Parameter Type
run () => Promise<Value>

Promise<FrameBindingReply<Value>>


decodeFrameBindingProps()function

Section titled “decodeFrameBindingProps()”
Signature
function decodeFrameBindingProps(raw): FrameBindingProps;

Decode a host routing packet or refuse it before any Instance lookup.

Parameter Type
raw unknown

FrameBindingProps


frameBindingEntrypoint()function

Section titled “frameBindingEntrypoint()”
Signature
function frameBindingEntrypoint<Env, Result>(
methods,
dispatch,
): typeof WorkerEntrypoint;

One native binding factory for both Hub and standalone, preserving RPC values.

Type Parameter
Env
Result
Parameter Type
methods FrameBindingMethods<Result>
dispatch (env, props, method, args) => Promise<FrameBindingReply<unknown>>

typeof WorkerEntrypoint


createCloudflareInvocationGate()function

Section titled “createCloudflareInvocationGate()”
Signature
function createCloudflareInvocationGate<Host, FacetClass>(
ctx,
close,
): InvocationGate<Host>;

End the native App facet when live authority closes early, before the gate admits again.

Type Parameter
Host
FacetClass
Parameter Type
ctx Pick<AppInstanceContext<FacetClass>, "facets">
close (frame) => Promise<void>

InvocationGate<Host>


createCloudflareAppInstance()function

Section titled “createCloudflareAppInstance()”
Signature
function createCloudflareAppInstance<FacetClass, Host>(
ctx,
loader,
resolve,
guestEnv,
bootUi,
limits?,
onAbort?,
): AppInstance<Host>;

Run an App Instance inside a SQLite-backed Durable Object on workerd, celld or Cloudflare. Supervisor state lives in the Durable Object’s own SQLite; the App backend runs in a named app facet loaded through the Worker Loader, so its database survives Release replacement and stays separate from the supervisor. Guest code gets only host gatekeeper bindings and no ambient outbound access.

Type Parameter
FacetClass
Host
Parameter Type Description
ctx AppInstanceContext<FacetClass> The Durable Object’s name, storage and facets.
loader | Readonly<{ get: (id, configure) => Readonly<{ getDurableObjectClass: (exportName) => FacetClass; }>; }> | undefined The Worker Loader binding; without it backend execution is unavailable.
resolve (release, scope) => Effect<Readonly<{ release: Release; digest: Sha256Digest; backend: DurableBackend; }>, Error> Resolves a Release ID to its verified durable backend.
guestEnv (frame) => object Mints loopbacks bound to the captured invocation frame.
bootUi (release) => Promise< | { kind: "passed"; } | { kind: "failed"; code: "ui_mount_failed"; diagnostics?: { failedPredicate: | "unexpected_candidate_request" | "response_status" | "request_failed" | "page_error" | "candidate_not_mounted"; errorName?: | "TypeError" | "RangeError" | "SyntaxError" | "AbortError" | "TimeoutError" | "Other" | "Error"; finalUrlPath: string; consoleErrors: string[]; pageErrors: string[]; failedRequests: object[]; droppedCount: number; }; } | { kind: "not_checked"; code: | "boot_runner_unavailable" | "boot_browser_binding_missing" | "boot_clone_unavailable" | "boot_timeout" | "boot_cleanup_failed" | "ui_check_not_run_on_host"; } | null> Host-owned UI check, or null when this executor deliberately skips it (for example, after the signed host already checked).
limits? Partial<Readonly<{ cpuMs: number; subRequests: number; }>> Guest CPU and subrequest budgets; omitted fields use safe defaults.
onAbort? (reason) => Promise<void> Close the host’s existing invocation frame after its state is fenced.

AppInstance<Host>

Re-exports BackgroundFrameState