Skip to content

client

@fungi.computer/shiitake


@fungi.computer/shiitake / client

Accepted = Readonly<{ status: "accepted"; commandId: string; }>

Semantic acknowledgement returned after one durable acceptance commit.


ForkedSession = Readonly<{ sessionId: string; }>

Result returned after a fork commits a new cold-readable Session.


SessionCommandHandler = {(input): Promise<Readonly<{ status: "accepted"; commandId: string; }>>; (input): Promise<undefined>>; (input): Promise<Readonly<{ sessionId: string; }>>; (input): Promise<Readonly<{ status: "accepted"; commandId: string; }> | Readonly<{ sessionId: string; }> | undefined>>; }

Execute one retained type-discriminated Session command.

(input): Promise<Readonly<{ status: "accepted"; commandId: string; }>>

Accept a prompt or cancellation of one existing command.

{ delivery: "followUp" | "steer"; requestId: string; type: "prompt"; text: string; } | { commandId: string; onlyIfPending?: boolean; type: "cancel"; }

Promise<Readonly<{ status: "accepted"; commandId: string; }>>

(input): Promise<undefined>>

Abort the active run or select a complete Session lineage leaf.

{ type: "abort"; } | { type: "branch"; entryId: string; }

Promise<undefined>

(input): Promise<Readonly<{ sessionId: string; }>>

Fork one complete entry lineage into a new Session.

"fork" = ...

string = boundedId

Promise<Readonly<{ sessionId: string; }>>

(input): Promise<Readonly<{ status: "accepted"; commandId: string; }> | Readonly<{ sessionId: string; }> | undefined>>

Execute an already-decoded command union.

{ delivery: "followUp" | "steer"; requestId: string; type: "prompt"; text: string; } | { type: "abort"; } | { commandId: string; onlyIfPending?: boolean; type: "cancel"; } | { type: "branch"; entryId: string; } | { type: "fork"; entryId: string; }

Promise<Readonly<{ status: "accepted"; commandId: string; }> | Readonly<{ sessionId: string; }> | undefined>


SendOptions = Readonly<{ delivery?: PromptDelivery; requestId?: string; }>

Optional controls for the Promise-friendly text sender.


SessionMessage = Readonly<{ id: string; sequence: number; commandId: string | null; value: Message; }>

One exact completed Pi message on the selected Session lineage.


ShiitakeEventSourceConstructor = (url) => Pick<EventTarget, "addEventListener"> > & Pick<EventSource, "close"> > & object

Minimal constructor seam for runtimes without a global EventSource.

string

Pick<EventTarget, "addEventListener"> & Pick<EventSource, "close"> & object


SessionTerminal = Readonly<{ commandId: string; outcome: "completed" | "cancelled" | "failed" | "interrupted"; }>

Durable outcome for one accepted work item on the selected Session lineage.


SessionStatus = "cancelling" | "idle" | "queued" | "retrying" | "streaming" | "thinking"

Compact current Session activity derived by Shiitake.


SessionExtensionSlots = Readonly<Record<string, ExtensionSlotV1>>>>

Encoded extension slots keyed by extension identity; absent means unavailable.


SessionExtensionControls = Readonly<{ call: (command, input) => Promise<Json>>; }>

Generic Session-scope extension commands.


AgentExtensionControls = Readonly<{ list: () => Promise<readonly ExtensionStatusV1[]>; resume: (extensionId) => Promise<ExtensionStatusV1>>; call: (extensionId, command, input) => Promise<Json>>; }>

Generic Agent-scope extension controls.


SessionProgress = Readonly<{ messageId: string; revision: number; text: string; thinking: string; textTruncated: boolean; thinkingTruncated: boolean; }>

Process-local assistant progress; never a durable Session fact.


SessionPendingPrompt = Readonly<{ commandId: string; text: string; delivery: PromptDelivery; }>

Accepted prompt waiting to enter the conversation, not a scheduling command.


SessionPendingPrompts = Readonly<{ prompts: readonly SessionPendingPrompt[]; hasMore: boolean; }>

Bounded current admission view, in acceptance order rather than execution order.


SessionSnapshot = Readonly<{ sessionId: string; cursor: string | null; hasMore: boolean; messages: readonly SessionMessage[]; terminals: readonly SessionTerminal[]; pending: SessionPendingPrompts; status: SessionStatus; progress: SessionProgress | null; extensions: SessionExtensionSlots; }>

Bounded Session baseline at one opaque owner cursor.


SessionFrame = Readonly<{ kind: "update"; delivery: "replay" | "live"; cursor: string | null; pending: SessionPendingPrompts; messages: readonly SessionMessage[]; terminals: readonly SessionTerminal[]; status: SessionStatus; extensions: SessionExtensionSlots; }> | Readonly<{ kind: "progress"; progress: SessionProgress; status: SessionStatus; }> | Readonly<{ kind: "reset"; reason: "history_unavailable"; cursor: string | null; baseline: SessionSnapshot; }>

One bounded replay or live frame.


SubscribeOptions = Readonly<{ after?: string; }>

Strict-after replay request.


ReadOptions = Readonly<{ limit?: number; }>

Bounded baseline request.


WatchOptions = ReadOptions

Race-safe observation request.


SessionWatch = Readonly<{ snapshot: SessionSnapshot; changes: AsyncIterable<SessionFrame>>; close: () => Promise<void>>; }>

Race-safe baseline plus live changes resource.


ShiitakeSession = Readonly<{ address: string; command: SessionCommandHandler; abort: () => Promise<void>>; send: (text, options?) => Promise<Accepted>>; cancel: (input) => Promise<Accepted>>; extension: (extensionId) => SessionExtensionControls; modelPreference: Readonly<{ read: () => Promise<ModelPreference | null>>; set: (preference) => Promise<void>>; }>; read: (input?) => Promise<SessionSnapshot>>; subscribe: (input) => AsyncIterable<SessionFrame>>; watch: (input?) => Promise<SessionWatch>>; }>

Addressable Session interface. Addressing itself performs no I/O.


SessionSummary = Readonly<{ createdAt: number; updatedAt: number; title: string; status: SessionStatus; }>

Read-only saved conversation projection; opening does not update recency.


SessionSummaryRow = SessionSummary & Readonly<{ kind: "session"; sessionId: string; }> | Readonly<{ kind: "unavailable"; sessionId: string; }>

One listed conversation, or a saved Session its owner could not read.


SessionSummaryPage = Readonly<{ sessions: readonly SessionSummaryRow[]; next: string | undefined; }>

One owner-bounded page, in stable Session identity order.


ShiitakeAgent = Readonly<{ createSession: (requestId) => Promise<string>>; listSessions: (after?) => Promise<SessionSummaryPage>>; extensions: AgentExtensionControls; session: (sessionId) => ShiitakeSession; close: () => Promise<void>>; }>

Constructed durable harness.


ExtensionViewV1<P> > = Readonly<{ status: "unavailable"; }> | Readonly<{ status: "stopped"; reason: string; }> | Readonly<{ status: "running"; value: P | null; }>

What one client sees of an extension in a Session observation.

P


ScopedCommandsV1<C, S> > = { [K in keyof C & string]: C[K]["scope"] extends S ? K : never }[keyof C & string]

Command names of one scope, typed by the shared contract.

C extends CommandsV1

S extends "session" | "agent"


BoundCallV1<C, S> > = <K>>(name, input) => Promise<Schema.Schema.Type<C[K]["output"]>>

Typed call surface of one contract’s commands in one scope.

C extends CommandsV1

S extends "session" | "agent"

K extends ScopedCommandsV1<C, S>

K

Schema.Schema.Type<C[K]["input"]>

Promise<Schema.Schema.Type<C[K]["output"]>>


BoundSessionExtensionV1<C, P> > = Readonly<{ view: (observation) => ExtensionViewV1<P>>; call: BoundCallV1<C, "session">>; }>

One Session bound to one extension contract.

C extends CommandsV1

P


BoundAgentExtensionV1<C> > = Readonly<{ call: BoundCallV1<C, "agent">>; }>

One Agent bound to one extension contract.

C extends CommandsV1


ShiitakeClientOptions = Readonly<{ baseUrl: string; fetch?: typeof globalThis.fetch; eventSource?: ShiitakeEventSourceConstructor; }>

Network location of one remotely hosted Shiitake agent.

parseAccepted(value): Accepted

Parse one serialized command acceptance using Shiitake’s public grammar.

string

Accepted


parseShiitakeError(value): ShiitakeError

Parse one serialized canonical Shiitake failure.

string

ShiitakeError


parseSessionSummaryPage(value): SessionSummaryPage

Decode the existing bounded saved-conversation projection.

string

SessionSummaryPage


bindSessionExtension<C, P, PI>>(session, contract): BoundSessionExtensionV1<C, P>>

Bind one Session to one extension contract; the contract’s schemas decode.

C extends Readonly<Record<string, Readonly<{ scope: "session" | "agent"; input: AnyNoContext; output: AnyNoContext; }>>>

P

PI

Pick<ShiitakeSession, "extension">

ExtensionContractV1<C, P, PI>

BoundSessionExtensionV1<C, P>


bindAgentExtension<C, P, PI>>(agent, contract): BoundAgentExtensionV1<C>>

Bind one Agent to one extension contract’s Agent-scope commands.

C extends Readonly<Record<string, Readonly<{ scope: "session" | "agent"; input: AnyNoContext; output: AnyNoContext; }>>>

P

PI

Pick<ShiitakeAgent, "extensions">

ExtensionContractV1<C, P, PI>

BoundAgentExtensionV1<C>


createShiitakeClient(options): ShiitakeAgent

Connect to a remotely hosted Shiitake agent.

ShiitakeClientOptions

ShiitakeAgent

Re-exports parseForkedSession


Re-exports parseSessionFrame


Re-exports parseSessionSnapshot


Re-exports AbortCommand


Re-exports BranchCommand


Re-exports CancelCommand


Re-exports ForkCommand


Re-exports PromptCommand


Re-exports PromptDelivery


Re-exports SessionCommand


Re-exports ModelPreference