cloudflare
Import
Section titled “Import”import * as api from "@fungi.computer/shiitake/cloudflare";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| class | abstract ShiitakeOwner |
Owns runtime opening, HTTP/ACP transport, inbox observation and alarm recovery. |
| class | abstract ShiitakeDO |
Native Cloudflare entry points; all runtime lifetime belongs to the owner. |
| type alias | CloudflareShiitakeState | Native Durable Object capabilities used by the Cloudflare adapter. |
| type alias | CloudflareShiitakeTools | Non-empty Mycelium capabilities supplied by a Cloudflare host. |
| type alias | CloudflareHostWork | Durable host work that shares Shiitake’s one native alarm, such as a host-owned delivery outbox. Shiitake never interprets it. |
| type alias | CloudflareHostJobs | Host jobs use a separate slot in Shiitake’s one Watchdog and native alarm. |
| type alias | CloudflareShiitakeAcpServer | ACP’s maintained transport, supplied by the host without a package cycle. |
| type alias | CloudflareShiitakeOptions | Cloudflare host inputs; the model owner resolves one frozen run selection. |
| type alias | CloudflareShiitake | Cloudflare host lifecycle; alarm forwarding stays outside the neutral client. |
| type alias | SessionInboxChanges | Revisioned Session inbox changes after one owner revision, oldest first. |
| function | deliverSessionGrantsToStorage() | Deliver one Session’s grants into a Cloudflare owner’s own storage, synchronously, whether or not its runtime is open; the very next tool call reads it. A plain function, not a Durable Object method, so no other Durable Object can call it over RPC: only code running inside the owner, holding its storage, delivers grants. |
| function | makeCloudflareShiitake() | Open Shiitake over one Durable Object’s storage. It resolves once the runtime is
started and initialize has run; if initialize throws, the runtime is closed
and the error is rethrown. |
abstract ShiitakeOwnerclass
Section titled “abstract ShiitakeOwner”Owns runtime opening, HTTP/ACP transport, inbox observation and alarm recovery.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Env |
- |
State extends CloudflareShiitakeState |
CloudflareShiitakeState |
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ShiitakeOwner<Env, State>(ctx, env): ShiitakeOwner<Env, State>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ctx |
State |
env |
Env |
Returns
Section titled “Returns”ShiitakeOwner<Env, State>
Methods
Section titled “Methods”shiitake()
Section titled “shiitake()”shiitake(): Promise<CloudflareShiitake>;Borrow this owner’s runtime directly; only the host owns its lifetime.
Returns
Section titled “Returns”Promise<CloudflareShiitake>
abortActiveSessions()
Section titled “abortActiveSessions()”abortActiveSessions(): Promise<void>;Stop live execution without constructing a cold owner’s runtime.
Returns
Section titled “Returns”Promise<void>
closeShiitake()
Section titled “closeShiitake()”closeShiitake(): Promise<void>;Close owned resources before storage erasure; a cold owner has none.
Returns
Section titled “Returns”Promise<void>
hasStoredSession()
Section titled “hasStoredSession()”hasStoredSession(sessionId): Promise<boolean>;Indexed owner-local existence check; corrupt stored Sessions remain unavailable.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sessionId |
string |
Returns
Section titled “Returns”Promise<boolean>
readInboxChanges()
Section titled “readInboxChanges()”readInboxChanges(after, limit): Promise<Readonly<{ rows: readonly ( | SessionSummaryRow | Readonly<{ sessionId: string; deleted: true; }>)[]; through: number; latest: number;}>>;Bounded strict-after read of this Agent’s changed inbox rows.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
after |
number |
limit |
number |
Returns
Section titled “Returns”Promise<Readonly<{ rows: readonly ( |
SessionSummaryRow | Readonly<{
sessionId: string; deleted: true; }>)[]; through: number;
latest: number; }>>
readColdSessions()
Section titled “readColdSessions()”readColdSessions(request): Promise<Readonly<{ sessions: readonly Readonly<{ sessionId: string; bytes: number; lastActivityAt: number; idle: boolean; }>[]; next?: string;}>>;One bounded, read-only page of Sessions with stored bytes, last activity and an idle flag, coldest first. The store keeper’s only view of cold Sessions; it carries no SQL, transaction or write.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
ColdSessionPageRequest |
Returns
Section titled “Returns”Promise<Readonly<{ sessions: readonly Readonly<{ sessionId:
string; bytes: number; lastActivityAt: number; idle: boolean;
}>[]; next?: string; }>>
readInboxRevision()
Section titled “readInboxRevision()”readInboxRevision(): number;Latest inbox revision; read only after the owner has opened.
Returns
Section titled “Returns”number
pruneInboxTombstones()
Section titled “pruneInboxTombstones()”pruneInboxTombstones(through): void;Prune deletion deltas after every current member inbox has acknowledged them.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
through |
number |
Returns
Section titled “Returns”void
wakeRuntime()
Section titled “wakeRuntime()”wakeRuntime(): Promise<void>;Persist a wake and run one reconciliation pass, including host work.
Returns
Section titled “Returns”Promise<void>
alarm()
Section titled “alarm()”alarm(): Promise<void>;Native alarms reconstruct the owner without an incoming user request. A construction or wake failure must not strand the claimed work on platform alarm retries: it is caught, logged, and explicitly re-armed with bounded backoff instead.
Returns
Section titled “Returns”Promise<void>
fetch()
Section titled “fetch()”fetch(request): Promise<Response>;Serve one request through Shiitake’s whole HTTP surface.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
Request |
Returns
Section titled “Returns”Promise<Response>
abstract ShiitakeDOclass
Section titled “abstract ShiitakeDO”Native Cloudflare entry points; all runtime lifetime belongs to the owner.
Extends
Section titled “Extends”DurableObject<Env>
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Env |
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ShiitakeDO<Env>(ctx, env): ShiitakeDO<Env>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ctx |
DurableObjectState |
env |
Env |
Returns
Section titled “Returns”ShiitakeDO<Env>
Inherited from
Section titled “Inherited from”DurableObject<Env>.constructorMethods
Section titled “Methods”alarm()
Section titled “alarm()”alarm(): Promise<void>;Reconcile due runtime and host work through the owner.
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”DurableObject.alarm;fetch()
Section titled “fetch()”fetch(request): Promise<Response>;Route an authenticated client request through the host’s routes, then the owner.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
request |
Request |
Returns
Section titled “Returns”Promise<Response>
Overrides
Section titled “Overrides”DurableObject.fetch;CloudflareShiitakeStatetype alias
Section titled “CloudflareShiitakeState”type CloudflareShiitakeState = Readonly<{ storage: SqliteOwner & Pick<DurableObjectStorage, "getAlarm" | "setAlarm" | "deleteAlarm"> & object; waitUntil: (task) => void; id?: Readonly<{ toString: () => string; }>;}>;Native Durable Object capabilities used by the Cloudflare adapter.
CloudflareShiitakeToolstype alias
Section titled “CloudflareShiitakeTools”type CloudflareShiitakeTools = Readonly<{ modules?: readonly ModuleRegistration[]; sources?: readonly CapabilitySource[]; sandbox: Sandbox; access?: ToolAccess;}>;Non-empty Mycelium capabilities supplied by a Cloudflare host.
CloudflareHostWorktype alias
Section titled “CloudflareHostWork”type CloudflareHostWork = Readonly<{ pending: () => Readonly<{ due: boolean; nextWakeAt: number | null; }>; run: () => Promise<void>;}>;Durable host work that shares Shiitake’s one native alarm, such as a host-owned delivery outbox. Shiitake never interprets it.
CloudflareHostJobstype alias
Section titled “CloudflareHostJobs”type CloudflareHostJobs = Readonly<{ lane: string; open: (runtime) => Readonly<{ execute: (job) => Promise<WatchdogExecutionDecision>; }>;}>;Host jobs use a separate slot in Shiitake’s one Watchdog and native alarm.
CloudflareShiitakeAcpServertype alias
Section titled “CloudflareShiitakeAcpServer”type CloudflareShiitakeAcpServer = Readonly<{ handleRequest: (request, meta) => Promise<Response>;}>;ACP’s maintained transport, supplied by the host without a package cycle.
CloudflareShiitakeOptionstype alias
Section titled “CloudflareShiitakeOptions”type CloudflareShiitakeOptions = Readonly<{ meta?: HostMetaOptions; model: ModelSource; instructions: InstructionSource; tools?: readonly [] | CloudflareShiitakeTools; storagePressure?: StoragePressureCheck; compaction?: CompactionOptions; extensions: ExtensionRosterV0; initialize?: (agent) => Promise<void>; hostWork?: readonly CloudflareHostWork[]; hostJobs?: CloudflareHostJobs; mailRoom?: BirdDogEffect; acp?: (agent) => Promise<CloudflareShiitakeAcpServer>;}>;Cloudflare host inputs; the model owner resolves one frozen run selection.
CloudflareShiitaketype alias
Section titled “CloudflareShiitake”type CloudflareShiitake = ShiitakeOwnerAgent & Readonly<{ readSettlement: ( sessionId, commandId, ) => Promise<CommandSettlement | undefined>; acceptMail: ( mail, meta?, reply?, stageAcceptedNotice?, sessionGrantDelivery?, ) => Promise<Accepted>; alarm: () => Promise<void>; activeSessions: () => Promise<readonly string[]>; abortActive: () => Promise<void>; }>;Cloudflare host lifecycle; alarm forwarding stays outside the neutral client.
SessionInboxChangestype alias
Section titled “SessionInboxChanges”type SessionInboxChanges = Readonly<{ rows: readonly ( | SessionSummaryRow | Readonly<{ sessionId: string; deleted: true; }> )[]; through: number; latest: number;}>;Revisioned Session inbox changes after one owner revision, oldest first.
deliverSessionGrantsToStorage()function
Section titled “deliverSessionGrantsToStorage()”function deliverSessionGrantsToStorage( storage, sessionId, delivery,): GrantsDeliveryResult;Deliver one Session’s grants into a Cloudflare owner’s own storage, synchronously, whether or not its runtime is open; the very next tool call reads it. A plain function, not a Durable Object method, so no other Durable Object can call it over RPC: only code running inside the owner, holding its storage, delivers grants.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
storage |
SqliteOwner |
sessionId |
string |
delivery |
GrantsDelivery |
Returns
Section titled “Returns”makeCloudflareShiitake()function
Section titled “makeCloudflareShiitake()”function makeCloudflareShiitake(unnamed, options): Promise<CloudflareShiitake>;Open Shiitake over one Durable Object’s storage. It resolves once the runtime is
started and initialize has run; if initialize throws, the runtime is closed
and the error is rethrown.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
unnamed |
CloudflareShiitakeState |
options |
CloudflareShiitakeOptions |
Returns
Section titled “Returns”Promise<CloudflareShiitake>
References
Section titled “References”ColdSessionPage
Section titled “ColdSessionPage”Re-exports ColdSessionPage
ColdSessionPageRequest
Section titled “ColdSessionPageRequest”Re-exports ColdSessionPageRequest
ColdSessionRow
Section titled “ColdSessionRow”Re-exports ColdSessionRow
GrantsDelivery
Section titled “GrantsDelivery”Re-exports GrantsDelivery
GrantsDeliveryResult
Section titled “GrantsDeliveryResult”Re-exports GrantsDeliveryResult
ShiitakeOwnerAgent
Section titled “ShiitakeOwnerAgent”Re-exports ShiitakeOwnerAgent
ToolAccess
Section titled “ToolAccess”Re-exports ToolAccess