@dxos/compute - v0.16.0
    Preparing search index...

    Interface Process<_Input, _Output, _Rpcs>

    A process: one running (or finished) instance of a durable operation, wherever its runtime runs.

    Its Data fields are plain values; the rest are live members that talk to the runtime. A process read from a tree or list is a cheap snapshot that reaches its runtime only once a live member is used (see make).

    interface Process<_Input = any, _Output = any, _Rpcs extends Rpc.Any = any> {
        alarmDueAt: null | number;
        completedAt: Option<number>;
        environment: Environment;
        error: null | SerializedError;
        key: string;
        metrics: { inputCount: number; outputCount: number; wallTime: number };
        params: Params;
        parentPid: null | string & Brand<"ProcessId">;
        pid: string & Brand<"ProcessId">;
        rpc: { [K in string]: From<_Rpcs, never>[K] };
        startedAt: number;
        state: Process.State;
        status: Status;
        statusAtom: Atom<Status>;
        hydrate(
            definition: Operation.Durable<_Input, _Output, any, any>,
        ): Effect<Process.Process<_Input, _Output, _Rpcs>>;
        runAndExit(options: { inputs: readonly _Input[] }): Stream<_Output>;
        runToCompletion(): Effect<void>;
        runUntilSettled(): Effect<void>;
        submitInput(input: _Input): Effect<void>;
        subscribeEphemeral(
            options?: SubscribeEphemeralOptions,
        ): Stream<Trace.Message>;
        subscribeOutputs(): Stream<_Output>;
        terminate(): Effect<void>;
    }

    Type Parameters

    • _Input = any
    • _Output = any
    • _Rpcs extends Rpc.Any = any

    Hierarchy (View Summary)

    Index

    Properties

    alarmDueAt: null | number

    Absolute due-time (epoch ms) of the process's pending alarm, or null when none is scheduled. A host that suspends the process between turns (a Durable Object) mirrors this onto its own scheduler, since the runtime's alarm is an in-memory timer.

    completedAt: Option<number>

    UNIX timestamp in milliseconds.

    environment: Environment

    What the process is running on behalf of. See Environment.

    error: null | SerializedError

    How the process failed as a serializable SerializedError (its context carries any structured detail, e.g. a notify override), or null unless it is in FAILED state.

    key: string

    Key of the process.

    NOTE: There might be multiple running processes with the same key.

    metrics: { inputCount: number; outputCount: number; wallTime: number }

    Type declaration

    • ReadonlyinputCount: number

      Total number of inputs submitted to the process.

    • ReadonlyoutputCount: number

      Total number of outputs submitted to the process.

    • ReadonlywallTime: number

      Total wall time of all handler invocations of the process in milliseconds.

    params: Params

    Parameters of the process.

    parentPid: null | string & Brand<"ProcessId">
    pid: string & Brand<"ProcessId">
    rpc: { [K in string]: From<_Rpcs, never>[K] }
    startedAt: number

    UNIX timestamp in milliseconds.

    state: Process.State

    State of the process.

    status: Status
    statusAtom: Atom<Status>

    Methods

    • Resolves when the process settles its current foreground turn: State.IDLE or State.SUCCEEDED, or State.HYBERNATING with no pending alarm (i.e. only background children remain in flight).

      Unlike runToCompletion, this does NOT wait for background children (e.g. delegated sub-agents) to finish — so a supervisor's chat turn returns as soon as its reply is complete, while sub-agents continue running and report back out of band. Still waits through alarm-pending hybernation (more queued turn work). Defects on State.FAILED.

      Returns Effect<void>

    • Subscribe to ephemeral trace messages for this process. Replays buffered events, then streams new ones as they arrive. The stream completes when the process reaches a terminal state.

      When consuming this stream from a short-lived parent effect (e.g. React useEffect that runPromise(Effect.forEach(subscribe)) and returns), fork the collector with Effect.forkDetach, not Effect.forkChild — the parent scope closes as soon as forEach finishes and interrupts scoped forks before live pushEphemeral events arrive. Interrupt the daemon fiber explicitly on dispose.

      Parameters

      Returns Stream<Trace.Message>