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

    Interface Session

    Handle to an agent session.

    interface Session {
        addContext: (context: Ref<Unknown>[]) => Effect<void, never, Service>;
        chat: Conversation;
        feed: Feed;
        getContext: () => Effect<Ref<Unknown>[], never, Service>;
        running: Atom<boolean>;
        submitPrompt: (
            prompt:
                | string
                | (
                    | {
                        _tag: "anchor";
                        objectId: string;
                        pending?: boolean;
                        version: unknown;
                    }
                    | { _tag: "change"; after: string; before: string; pending?: boolean }
                    | {
                        _tag: "file";
                        mediaType?: string;
                        name?: string;
                        pending?: boolean;
                        url: string;
                    }
                    | {
                        _tag: "image";
                        id?: string;
                        pending?: boolean;
                        source?: | { data: string; mediaType: string; type: "base64" }
                        | { type: "http"; url: string };
                    }
                    | {
                        _tag: "json";
                        data: string;
                        disposition?: "user"
                        | "summary"
                        | "synthetic"
                        | "cot"
                        | "version-pin";
                        pending?: boolean;
                    }
                    | { _tag: "proposal"; pending?: boolean; text: string }
                    | {
                        _tag: "reasoning";
                        pending?: boolean;
                        reasoningText?: string;
                        redactedText?: string;
                        signature?: string;
                    }
                    | { _tag: "reference"; pending?: boolean; reference: Ref<Unknown> }
                    | {
                        _tag: "request";
                        options: readonly {
                            id: string;
                            kind: "allow_once" | "allow_always" | "reject_once" | "reject_always";
                            label: string;
                        }[];
                        pending?: boolean;
                        preview?: { label: string; text: string };
                        requestId: string;
                        resolution?: { optionId?: string; outcome: "selected" | "cancelled" };
                        title: string;
                        toolCallId?: string;
                    }
                    | { _tag: "select"; options: string[]; pending?: boolean }
                    | { _tag: "status"; pending?: boolean; statusText: string }
                    | { _tag: "suggestion"; pending?: boolean; text: string }
                    | {
                        _tag: "stats";
                        duration?: number;
                        errors?: number;
                        finishReason?:
                            | "length"
                            | "stop"
                            | "content-filter"
                            | "tool-calls"
                            | "error"
                            | "pause"
                            | "other"
                            | "unknown";
                        message?: string;
                        mimeType?: string;
                        model?: string;
                        pending?: boolean;
                        toolCalls?: number;
                        usage?: {
                            inputTokens?: number;
                            outputTokens?: number;
                            totalTokens?: number;
                        };
                    }
                    | {
                        _tag: "surface";
                        data?: { readonly [key: string]: unknown };
                        pending?: boolean;
                        role: string;
                    }
                    | {
                        _tag: "text";
                        disposition?: "user"
                        | "summary"
                        | "synthetic"
                        | "cot"
                        | "version-pin";
                        mimeType?: string;
                        pending?: boolean;
                        text: string;
                    }
                    | { _tag: "summary"; content: string; pending?: boolean }
                    | { _tag: "toolkit"; pending?: boolean }
                    | {
                        _tag: "toolCall";
                        displayIcon?: string;
                        displayName?: string;
                        input: string;
                        name: string;
                        operationIcon?: string;
                        operationKey?: string;
                        operationName?: string;
                        pending?: boolean;
                        providerExecuted: boolean;
                        toolCallId: string;
                    }
                    | {
                        _tag: "toolResult";
                        error?: string;
                        invocations?: { error?: string; operationKey: string }[];
                        name: string;
                        pending?: boolean;
                        providerExecuted: boolean;
                        result?:
                            | string
                            | {
                                _tag: "~@dxos/types/ContentBlock.ContentBlockResult";
                                content: readonly (
                                    | {
                                        _tag: "text";
                                        disposition?: (...)
                                        | (...)
                                        | (...)
                                        | (...)
                                        | (...)
                                        | (...);
                                        mimeType?: (...) | (...);
                                        pending?: (...) | (...) | (...);
                                        text: string;
                                    }
                                    | {
                                        _tag: "image";
                                        id?: (...)
                                        | (...);
                                        pending?: (...) | (...) | (...);
                                        source?: (...) | (...) | (...);
                                    }
                                    | {
                                        _tag: "file";
                                        mediaType?: (...)
                                        | (...);
                                        name?: (...) | (...);
                                        pending?: (...) | (...) | (...);
                                        url: string;
                                    }
                                )[];
                            };
                        toolCallId: string;
                    }
                    | {
                        _tag: "transcript";
                        candidates?: {
                            end: number;
                            kind: "noun"
                            | "proper-noun";
                            start: number;
                            suggested?: { typename: string };
                            text: string;
                        }[];
                        corrected?: string;
                        pending?: boolean;
                        references?: Ref<Unknown>[];
                        started: string;
                        text: string;
                        translation?: string;
                    }
                )[],
            options?: SubmitPromptOptions,
        ) => Effect<void>;
        subscribeEphemeral: (
            options?: SubscribeEphemeralOptions,
        ) => Stream<Trace.Message>;
        terminate: () => Effect<void>;
        waitForCompletion: () => Effect<void>;
    }
    Index

    Properties

    addContext: (context: Ref<Unknown>[]) => Effect<void, never, Service>

    Adds context objects to the agent.

    The chat that the session is associated with.

    feed: Feed

    The feed carrying the chat's messages.

    getContext: () => Effect<Ref<Unknown>[], never, Service>

    Gets the context objects from the agent.

    running: Atom<boolean>

    True while the agent is working on a turn (running, or waiting on a tool call or alarm); false when it is idle awaiting input, or terminal.

    submitPrompt: (
        prompt:
            | string
            | (
                | {
                    _tag: "anchor";
                    objectId: string;
                    pending?: boolean;
                    version: unknown;
                }
                | { _tag: "change"; after: string; before: string; pending?: boolean }
                | {
                    _tag: "file";
                    mediaType?: string;
                    name?: string;
                    pending?: boolean;
                    url: string;
                }
                | {
                    _tag: "image";
                    id?: string;
                    pending?: boolean;
                    source?: | { data: string; mediaType: string; type: "base64" }
                    | { type: "http"; url: string };
                }
                | {
                    _tag: "json";
                    data: string;
                    disposition?: "user"
                    | "summary"
                    | "synthetic"
                    | "cot"
                    | "version-pin";
                    pending?: boolean;
                }
                | { _tag: "proposal"; pending?: boolean; text: string }
                | {
                    _tag: "reasoning";
                    pending?: boolean;
                    reasoningText?: string;
                    redactedText?: string;
                    signature?: string;
                }
                | { _tag: "reference"; pending?: boolean; reference: Ref<Unknown> }
                | {
                    _tag: "request";
                    options: readonly {
                        id: string;
                        kind: "allow_once" | "allow_always" | "reject_once" | "reject_always";
                        label: string;
                    }[];
                    pending?: boolean;
                    preview?: { label: string; text: string };
                    requestId: string;
                    resolution?: { optionId?: string; outcome: "selected" | "cancelled" };
                    title: string;
                    toolCallId?: string;
                }
                | { _tag: "select"; options: string[]; pending?: boolean }
                | { _tag: "status"; pending?: boolean; statusText: string }
                | { _tag: "suggestion"; pending?: boolean; text: string }
                | {
                    _tag: "stats";
                    duration?: number;
                    errors?: number;
                    finishReason?:
                        | "length"
                        | "stop"
                        | "content-filter"
                        | "tool-calls"
                        | "error"
                        | "pause"
                        | "other"
                        | "unknown";
                    message?: string;
                    mimeType?: string;
                    model?: string;
                    pending?: boolean;
                    toolCalls?: number;
                    usage?: {
                        inputTokens?: number;
                        outputTokens?: number;
                        totalTokens?: number;
                    };
                }
                | {
                    _tag: "surface";
                    data?: { readonly [key: string]: unknown };
                    pending?: boolean;
                    role: string;
                }
                | {
                    _tag: "text";
                    disposition?: "user"
                    | "summary"
                    | "synthetic"
                    | "cot"
                    | "version-pin";
                    mimeType?: string;
                    pending?: boolean;
                    text: string;
                }
                | { _tag: "summary"; content: string; pending?: boolean }
                | { _tag: "toolkit"; pending?: boolean }
                | {
                    _tag: "toolCall";
                    displayIcon?: string;
                    displayName?: string;
                    input: string;
                    name: string;
                    operationIcon?: string;
                    operationKey?: string;
                    operationName?: string;
                    pending?: boolean;
                    providerExecuted: boolean;
                    toolCallId: string;
                }
                | {
                    _tag: "toolResult";
                    error?: string;
                    invocations?: { error?: string; operationKey: string }[];
                    name: string;
                    pending?: boolean;
                    providerExecuted: boolean;
                    result?:
                        | string
                        | {
                            _tag: "~@dxos/types/ContentBlock.ContentBlockResult";
                            content: readonly (
                                | {
                                    _tag: "text";
                                    disposition?: (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...)
                                    | (...);
                                    mimeType?: (...) | (...);
                                    pending?: (...) | (...) | (...);
                                    text: string;
                                }
                                | {
                                    _tag: "image";
                                    id?: (...)
                                    | (...);
                                    pending?: (...) | (...) | (...);
                                    source?: (...) | (...) | (...);
                                }
                                | {
                                    _tag: "file";
                                    mediaType?: (...)
                                    | (...);
                                    name?: (...) | (...);
                                    pending?: (...) | (...) | (...);
                                    url: string;
                                }
                            )[];
                        };
                    toolCallId: string;
                }
                | {
                    _tag: "transcript";
                    candidates?: {
                        end: number;
                        kind: "noun"
                        | "proper-noun";
                        start: number;
                        suggested?: { typename: string };
                        text: string;
                    }[];
                    corrected?: string;
                    pending?: boolean;
                    references?: Ref<Unknown>[];
                    started: string;
                    text: string;
                    translation?: string;
                }
            )[],
        options?: SubmitPromptOptions,
    ) => Effect<void>

    Submit a turn: a plain user prompt, or pre-built content blocks (e.g. synthetic context + prompt).

    subscribeEphemeral: (
        options?: SubscribeEphemeralOptions,
    ) => Stream<Trace.Message>

    Subscribe to ephemeral trace events (e.g., streaming partial messages). Replays buffered events, then streams new ones until the process ends.

    When forking a collector from a short-lived parent (e.g. useEffect + runPromise(Effect.forEach(subscribe))), use Effect.forkDetach so the stream survives after the parent scope closes; interrupt it on dispose.

    terminate: () => Effect<void>

    Terminates the agent process and clears its durable storage.

    waitForCompletion: () => Effect<void>

    Wait until agent has completed its work.