Skip to content

@fungi.computer/mycelium

A capability declaration could not form one coherent installed surface.

  • Error

new MyceliumDefinitionError(message): MyceliumDefinitionError

string

MyceliumDefinitionError

Error.constructor

readonly code: "invalid_definition" = invalidDefinitionCode

Stable machine-readable failure code.


An operation attempted to use a closed Mycelium runtime.

  • Error

new MyceliumClosedError(message?): MyceliumClosedError

string = "Mycelium runtime is closed"

MyceliumClosedError

Error.constructor

readonly code: "runtime_closed" = runtimeClosedCode

Stable machine-readable failure code.


A capability source failed at its bounded host boundary.

  • Error

new MyceliumSourceError(sourceId, phase): MyceliumSourceError

string | undefined

Stable identity of the source, absent for whole-candidate failures.

MyceliumSourcePhase

Lifecycle phase that could not settle.

MyceliumSourceError

Error.constructor

readonly code: "source_failure" = sourceFailureCode

Stable machine-readable failure code.

readonly sourceId: string | undefined

Stable identity of the source, absent for whole-candidate failures.

readonly phase: MyceliumSourcePhase

Lifecycle phase that could not settle.

CapabilitySession = Readonly<{ sessionId: string; }>

Session on whose behalf one runtime acquires its capability projections.


CapabilitySourceContext = Readonly<{ session?: CapabilitySession; signal: AbortSignal; invalidate: () => void; }>

Context supplied while acquiring one current capability projection.


CapabilitySourceSnapshot = Readonly<{ version: string; modules: readonly ModuleRegistration[]; }>

Bounded current projection returned by one capability source.


CapabilitySourceAcquisition = Readonly<{ snapshot: CapabilitySourceSnapshot; release: () => Promise<void>>; }>

Acquired source projection and the cleanup that owns its live adapter.


CapabilitySource = Readonly<{ id: string; acquire: (context) => Promise<CapabilitySourceAcquisition>>; }>

Promise-shaped host boundary for one versioned capability projection.


MyceliumSourcePhase = "acquire" | "release" | "stale"

Lifecycle phase in which a capability source failed.


MyceliumError = MyceliumClosedError | MyceliumDefinitionError | MyceliumSourceError | SandboxFailure

Closed failure vocabulary for the first Mycelium runtime slice.


ExecutionOptions = Readonly<{ timeoutMs?: number; abortGraceMs?: number; }>

Host-selectable execution limits; neither budget can be disabled.


CollectedImage = Readonly<{ data: string; mimeType: "image/jpeg" | "image/png" | "image/webp"; path: string; bytes: number; }>

A single image collected during an execute run.


ExecutionImages = Readonly<{ push: (image) => string; }>

The collector as one execution’s operations see it: push only.


InvocationContext = Readonly<{ executionId: string; signal: AbortSignal; images?: ExecutionImages; }>

The only context an operation callback may observe.


MyceliumJsonValue = output<ZodJSONSchema>>

JSON value allowed to cross the sandbox and capability boundary.


SandboxValue = input<ZodUnknown>>

Untrusted value supplied by or returned from a host sandbox boundary.


SandboxBinding = (input) => Promise<MyceliumJsonValue>>

One invocation binding visible to the host-provided sandbox.

SandboxValue

Promise<MyceliumJsonValue>


SandboxRequest = Readonly<{ executionId: string; code: string; timeoutMs: number; bindings: Readonly<Record<string, Readonly<Record<string, SandboxBinding>>>>>>>>; modules?: Readonly<Record<string, string>>>>; sessionId?: string | null; }>

Request crossing the root Promise-shaped sandbox seam.


Sandbox = Readonly<{ adapter?: string; buildSha?: string; execute: (request, signal) => Promise<SandboxValue>>; }>

Promise-shaped sandbox interface implemented by a host or stranger.


MyceliumOptions = Readonly<{ modules?: readonly ModuleRegistration[]; sources?: readonly CapabilitySource[]; session?: CapabilitySession; execution?: ExecutionOptions; sandbox: Sandbox; onSandboxFailure?: (event) => Promise<void>>; }>

Inputs used to construct the Promise-facing runtime.


AcquireOptions = Readonly<{ signal?: AbortSignal; }>

Cancellation options for one Promise-facing lease acquisition.


Lease = Readonly<{ revision: string; catalog: ForageCatalog; executeTool: MuleTool; release: () => Promise<void>>; }>

One immutable Promise-facing capability revision.


Runtime = Readonly<{ acquire: (options?) => Promise<Lease>>; close: () => Promise<void>>; }>

Warm Promise-facing lifecycle for acquiring immutable run leases.


OperationDefinition<I, O> > = Readonly<{ replay?: "safe" | "unsafe"; description?: string; input: ZodType<I>>; output?: ZodType<O>>; execute: (input, context) => Promise<O>>; }>

Zod-first declaration for one operation behind the execute door.

I extends MyceliumJsonValue

O extends MyceliumJsonValue


ModuleDefinition = Readonly<{ id: string; name?: string; description?: string; operations: Readonly<Record<string, OperationRegistration>>>>; }>

Declaration for one stable module and its related operations.


MyceliumApi = Readonly<{ module: (definition) => ModuleRegistration; operation: <I, O>>(definition) => OperationRegistration<I, O>>; make: (options) => Promise<Runtime>>; gate: (module, gate) => ModuleRegistration; }>

Public convenience namespace contract.


OperationRegistration<I, O> > = Readonly<{ [operationBrand]: true; [operationTypes]?: Readonly<{ input: I; output: O; }>; }>

Opaque handle for one Zod-authored operation.

I = unknown

O = unknown


ModuleRegistration = Readonly<{ [moduleBrand]: true; }>

Opaque handle for one namespaced capability module.


GateDecision = Readonly<{ kind: "allow"; }> | Readonly<{ kind: "refuse"; value: MyceliumJsonValue; }>

A gate’s verdict for one call: run the operation, or return value instead.


OperationGate = (call) => GateDecision | Promise<GateDecision>>

Asked before every call of a gated module’s operations.

Readonly<{ operation: string; context: InvocationContext; }>

GateDecision | Promise<GateDecision>


SandboxFailureEvent = typeof SandboxFailureEventSchema.Type

Full operator diagnostics, excluded from model conversation and default reads.

const MAX_EXECUTION_IMAGES: 8 = 8

Maximum number of out-of-band images retained for one execution.


const Mycelium: MyceliumApi

Zod-first authoring and Promise-facing runtime construction.


const SandboxFailureEventSchema: Struct<{ kind: Literal<"sandbox_failure">>; ref: String; executionId: String; adapter: String; buildSha: NullOr<String>>; tag: Literals<readonly ["SourceInvalid", "GuestThrew", "DeadlineExceeded", "Cancelled", "DispatchLost", "SandboxCrashed", "BadResponse", "ResultTooLarge", "ResultNotJson", "CapabilityFailed", "Unknown"]>; fields: $Record<String, Codec<JSONType, JSONType, never, never>>>>; healthAlert: Boolean; }>

Shared structural grammar for durable operator facts and client inspection.

Re-exports sandboxFailure


Re-exports isSandboxFailure


Re-exports sandboxOperatorValue


Re-exports SourceInvalid


Re-exports GuestThrew


Re-exports DeadlineExceeded


Re-exports Cancelled


Re-exports DispatchLost


Re-exports SandboxCrashed


Re-exports BadResponse


Re-exports ResultTooLarge


Re-exports ResultNotJson


Re-exports CapabilityFailed


Re-exports Unknown


Re-exports sandboxFailureMessage


Re-exports SandboxFailure


Re-exports CapabilityDiagnostic


Re-exports CapabilityFailureFields