Skip to content
API reference

node

Import
import * as api from "@fungi.computer/shiitake/node";
Kind Export Description
type alias NodeRuntimeHost The event-loop runtime host one Node process gives one durable Agent.
type alias NodeStoreLease An exclusive, process-held claim on one store file.
type alias NodeShiitakeOptions Everything a Node host supplies except the store and runtime it owns.
type alias NodeShiitake One durable Agent in a SQLite file, owned by this Node process.
function nodeRuntimeHost() The Node event loop as Shiitake’s runtime host: one reconciliation at a time, re-run when woken during a pass, and a timer for the earliest due retry. It has no queue policy; Watchdog owns execution and retries. observeFailure sees a failed pass, which is retried after five seconds; if it throws, the throw is logged and the retry still happens.
function acquireNodeStoreLease() Claim one store for this process: an exclusive transaction held open on a sidecar file, so a second owner of the same store is refused at once and the claim ends with the process, never with a missed heartbeat.
function openNodeShiitake() Open one durable Agent in a SQLite file on disk. The process holds an exclusive lease on the store until close, so a second opener is refused. The store and its lease file are private to this user (0600), and a store reached through a symbolic link or with a second hard link is refused. Accepted work survives a restart: reopening the file resumes it.

NodeRuntimeHosttype alias

Section titled “NodeRuntimeHost”
Signature
type NodeRuntimeHost = Readonly<{
runtime: RuntimeHost;
scheduleWake: (at) => void;
close: () => Promise<void>;
}>;

The event-loop runtime host one Node process gives one durable Agent.


NodeStoreLeasetype alias

Section titled “NodeStoreLease”
Signature
type NodeStoreLease = Readonly<{
release: () => void;
}>;

An exclusive, process-held claim on one store file.


NodeShiitakeOptionstype alias

Section titled “NodeShiitakeOptions”
Signature
type NodeShiitakeOptions = Omit<ShiitakeOptions, "store" | "runtime"> &
Readonly<{
path: string;
onRuntimeFailure?: (cause) => void;
}>;

Everything a Node host supplies except the store and runtime it owns.


NodeShiitaketype alias

Section titled “NodeShiitake”
Signature
type NodeShiitake = Readonly<{
agent: ShiitakeOwnerAgent;
routes: Hono<ShiitakeHttpEnv>;
close: () => Promise<void>;
}>;

One durable Agent in a SQLite file, owned by this Node process.

nodeRuntimeHost()function

Section titled “nodeRuntimeHost()”
Signature
function nodeRuntimeHost(observeFailure): NodeRuntimeHost;

The Node event loop as Shiitake’s runtime host: one reconciliation at a time, re-run when woken during a pass, and a timer for the earliest due retry. It has no queue policy; Watchdog owns execution and retries. observeFailure sees a failed pass, which is retried after five seconds; if it throws, the throw is logged and the retry still happens.

Parameter Type
observeFailure (cause) => void

NodeRuntimeHost


acquireNodeStoreLease()function

Section titled “acquireNodeStoreLease()”
Signature
function acquireNodeStoreLease(sidecarPath): NodeStoreLease;

Claim one store for this process: an exclusive transaction held open on a sidecar file, so a second owner of the same store is refused at once and the claim ends with the process, never with a missed heartbeat.

Parameter Type
sidecarPath string

NodeStoreLease


openNodeShiitake()function

Section titled “openNodeShiitake()”
Signature
function openNodeShiitake(options): Promise<
Readonly<{
agent: ShiitakeOwnerAgent;
routes: Hono<ShiitakeHttpEnv>;
close: () => Promise<void>;
}>
>;

Open one durable Agent in a SQLite file on disk. The process holds an exclusive lease on the store until close, so a second opener is refused. The store and its lease file are private to this user (0600), and a store reached through a symbolic link or with a second hard link is refused. Accepted work survives a restart: reopening the file resumes it.

Parameter Type
options NodeShiitakeOptions

Promise<Readonly<{ agent: ShiitakeOwnerAgent; routes: Hono<ShiitakeHttpEnv>; close: () => Promise<void>; }>>