Anchorage API reference
    Preparing search index...
    interface ThreadSignalRoutesOptions {
        canPersist?: (scope: ThreadScope) => boolean | Promise<boolean>;
        canPersistSchedule?: (
            scope: ThreadScope,
            input: {
                agentId: string;
                dispatchId: string;
                resourceId: string;
                runId: string;
                scheduleId: string;
                threadId: string;
            },
        ) => boolean
        | Promise<boolean>;
        consultRunCap?: RunCapConsult;
        contentPolicy?: SignalContentPolicy;
        resolveAgent: (
            scope: ThreadScope,
            agentId: string | undefined,
            entryPath:
                | "approval.resume"
                | "http.start"
                | "signal.message"
                | "signal.queue"
                | "signal.reactive"
                | "signal.state"
                | "signal.notification"
                | "signal.wake"
                | "notification.dispatch"
                | "schedule.fire",
        ) => | Agent<
            string,
            ToolsInput,
            undefined,
            unknown,
            AgentEditorConfig
            | undefined,
        >
        | Promise<
            Agent<
                string,
                ToolsInput,
                undefined,
                unknown,
                AgentEditorConfig
                | undefined,
            >,
        >;
        resolveBlockingRun?: (
            scope: ThreadScope,
        ) =>
            | Promise<{ principal: ExecutionPrincipal; runId: string } | undefined>
            | { principal: ExecutionPrincipal; runId: string }
            | undefined;
        resolveNotificationsStorage?: (
            scope: ThreadScope,
        ) => NotificationsStorage | Promise<NotificationsStorage>;
        resolveResourceId?: (scope: ThreadScope) => string | undefined;
        resolveScheduleDispatchStore?: (
            scope: ThreadScope,
        ) => ScheduleSignalDispatchStore | Promise<ScheduleSignalDispatchStore>;
        resolveScheduleRunStatus?: (
            scope: ThreadScope,
            input: { agentId: string; resourceId: string; runId: string },
        ) => Promise<{ runId: string; status?: string } | undefined>;
        resolveScheduleTarget?: (
            scope: ThreadScope,
            input: { dispatchId: string; runId: string; scheduleId: string },
        ) => Promise<AgentScheduleTarget | undefined>;
        serializeDispatch?: <T>(
            scope: ThreadScope,
            operation: () => Promise<T>,
        ) => Promise<T>;
        startIdleRun?: StartIdleRun;
    }
    Index

    Properties

    canPersist?: (scope: ThreadScope) => boolean | Promise<boolean>

    Whether this principal owns the thread and may persist future input. Its effect is route-dependent; see persistenceForbiddenResponse().

    canPersistSchedule?: (
        scope: ThreadScope,
        input: {
            agentId: string;
            dispatchId: string;
            resourceId: string;
            runId: string;
            scheduleId: string;
            threadId: string;
        },
    ) => boolean
    | Promise<boolean>

    Whether the registered schedule owner may persist to its fixed target.

    consultRunCap?: RunCapConsult

    Run-cap seam for idle-thread wakes. Absent means wakes are unmetered.

    contentPolicy?: SignalContentPolicy

    Optional model-visible content gate. FlowSafe supplies only trusted route identity plus Mastra's canonical escaped XML; the callback must return the opaque structural result and is never given a request body or storage row.

    resolveAgent: (
        scope: ThreadScope,
        agentId: string | undefined,
        entryPath:
            | "approval.resume"
            | "http.start"
            | "signal.message"
            | "signal.queue"
            | "signal.reactive"
            | "signal.state"
            | "signal.notification"
            | "signal.wake"
            | "notification.dispatch"
            | "schedule.fire",
    ) => | Agent<
        string,
        ToolsInput,
        undefined,
        unknown,
        AgentEditorConfig
        | undefined,
    >
    | Promise<
        Agent<
            string,
            ToolsInput,
            undefined,
            unknown,
            AgentEditorConfig
            | undefined,
        >,
    >

    The per-thread agent whose public signal methods these routes drive. Built once per DO instance by the host (its model/memory/tools are the host's concern); these routes only need its identity and pubsub.

    MUST be a runtime-driven durable agent for an idle wake. The host-provided startIdleRun seam starts it through RunnerRuntime with a host-minted, path-safe run id. Without either requirement, wake degrades to durable persistence only when the principal may persist and the agent has memory; otherwise the route returns persistence-forbidden or memory-unavailable, and never escapes onto core's default execution engine. Trusted notification dispatch supplies the persisted agent id; other routes pass undefined.

    resolveBlockingRun?: (
        scope: ThreadScope,
    ) =>
        | Promise<{ principal: ExecutionPrincipal; runId: string } | undefined>
        | { principal: ExecutionPrincipal; runId: string }
        | undefined

    Storage-backed thread occupancy, including runs surviving DO eviction.

    resolveNotificationsStorage?: (
        scope: ThreadScope,
    ) => NotificationsStorage | Promise<NotificationsStorage>

    Durable inbox used by the trusted due-notification dispatch route. Required for non-owner /signal/notification ingestion, which returns 409 without it.

    resolveResourceId?: (scope: ThreadScope) => string | undefined

    The thread's host-owned memory resourceId — part of core's (resourceId, threadId) signal key, so it MUST match whatever the loop registered under or a send never finds the active run. Server-derived (a memory id is TCB-only — never a client field); the host mints it from the authenticated host. Absent ⇒ threadId-only keying (resourceId ''), which is consistent within this DO but only interoperates with a loop that also omits it — the binding expected by the registered durable run.

    resolveScheduleDispatchStore?: (
        scope: ThreadScope,
    ) => ScheduleSignalDispatchStore | Promise<ScheduleSignalDispatchStore>

    Target-side lease and receipt store for at-least-once schedule fires.

    resolveScheduleRunStatus?: (
        scope: ThreadScope,
        input: { agentId: string; resourceId: string; runId: string },
    ) => Promise<{ runId: string; status?: string } | undefined>

    Recover a stable schedule-wake run after its HTTP receipt was lost.

    resolveScheduleTarget?: (
        scope: ThreadScope,
        input: { dispatchId: string; runId: string; scheduleId: string },
    ) => Promise<AgentScheduleTarget | undefined>

    Resolve the canonical target bound to one prepared schedule fire.

    serializeDispatch?: <T>(
        scope: ThreadScope,
        operation: () => Promise<T>,
    ) => Promise<T>

    Host-shared target-thread critical section. Required with resolveBlockingRun: the occupancy/principal check and signal action must serialize with public agent start/resume routes.

    startIdleRun?: StartIdleRun

    Runtime-driven start seam. When absent, a requested wake degrades to a durable persist when the principal may persist and the agent has memory; otherwise the route answers persistence-forbidden or memory-unavailable.