Skip to content
API reference

remote

Import
import * as api from "@fungi.computer/mycelium/remote";
Kind Export Description
type alias RemoteOperationDescriptor One operation’s model-facing contract with its schemas as JSON Schema.
type alias RemoteModuleDescriptor A module’s operations keyed by their dotted path below the module, for a host that runs the module in another isolate. Identity, alias and placement stay the host’s decision; this carries only what the model may call.
function describeModule() Project one module’s callable surface; unrepresentable schemas throw.
function invokeModuleOperation() Run one described operation through its own input and output schemas.
function remoteModule() Rebuild a described module on the host side. Each operation parses its input and output against the described JSON Schema, then forwards to invoke.

RemoteOperationDescriptortype alias

Section titled “RemoteOperationDescriptor”
Signature
type RemoteOperationDescriptor = Readonly<{
replay: "safe" | "unsafe";
description?: string;
input: MyceliumJsonValue;
output: MyceliumJsonValue | null;
}>;

One operation’s model-facing contract with its schemas as JSON Schema.


RemoteModuleDescriptortype alias

Section titled “RemoteModuleDescriptor”
Signature
type RemoteModuleDescriptor = Readonly<{
description?: string;
operations: Readonly<Record<string, RemoteOperationDescriptor>>;
}>;

A module’s operations keyed by their dotted path below the module, for a host that runs the module in another isolate. Identity, alias and placement stay the host’s decision; this carries only what the model may call.

describeModule()function

Section titled “describeModule()”
Signature
function describeModule(registration): RemoteModuleDescriptor;

Project one module’s callable surface; unrepresentable schemas throw.

Parameter Type
registration ModuleRegistration

RemoteModuleDescriptor


invokeModuleOperation()function

Section titled “invokeModuleOperation()”
Signature
function invokeModuleOperation(
registration,
path,
input,
context,
): Promise<JSONType>;

Run one described operation through its own input and output schemas.

Parameter Type
registration ModuleRegistration
path string
input unknown
context InvocationContext

Promise<JSONType>


remoteModule()function

Section titled “remoteModule()”
Signature
function remoteModule(options): ModuleRegistration;

Rebuild a described module on the host side. Each operation parses its input and output against the described JSON Schema, then forwards to invoke.

Parameter Type
options Readonly<{ id: string; name: string; descriptor: RemoteModuleDescriptor; invoke: (path, input, context) => Promise<MyceliumJsonValue>; }>

ModuleRegistration