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;
        maxDeliveryAttempts?: number;
        notificationDispatchAllowed?: (
            scope: ThreadScope,
            agentId: string,
        ) => boolean | Promise<boolean>;
        resolveAgent: (
            scope: ThreadScope,
            agentId: string | undefined,
            entryPath:
                | "approval.resume"
                | "http.start"
                | "remote-step.resume"
                | "signal.message"
                | "signal.queue"
                | "signal.reactive"
                | "signal.state"
                | "signal.notification"
                | "signal.wake"
                | "notification.dispatch"
                | "schedule.fire",
        ) => | Agent<
            string,
            ToolsInput,
            undefined,
            any,
            AgentEditorConfig
            | undefined,
        >
        | Promise<
            Agent<
                string,
                ToolsInput,
                undefined,
                any,
                AgentEditorConfig
                | undefined,
            >,
        >;
        resolveBlockingRun?: (
            scope: ThreadScope,
        ) =>
            | Promise<
                | { principal: ExecutionPrincipal; runId: string; status?: RunStatus }
                | undefined,
            >
            | { principal: ExecutionPrincipal; runId: string; status?: RunStatus }
            | 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>;
        scheduleProviderOptionsPolicy?: ScheduleProviderOptionsPolicy;
        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 input for a later turn. Absent, every principal may, signal providers included. A principal that may not persist is answered persistence-forbidden where a route would persist its input, and its deliveries carry a marker that keeps the runner's terminal refusal from persisting them.

    For /signal/notification, an owner's notification to a runtime-driven agent is delivered at ingestion under the owner's principal, and a non-owner's is recorded for the notification dispatch tick, which this callback then judges as the dispatch principal. An unbranded agent's owner notification follows Mastra's delivery policy.

    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. When set, schedule fires consult it instead of canPersist, which is not called for those fires.

    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.

    maxDeliveryAttempts?: number

    Failed delivery rounds before a pending notification is discarded.

    notificationDispatchAllowed?: (
        scope: ThreadScope,
        agentId: string,
    ) => boolean | Promise<boolean>

    Consulted only for a non-owner /signal/notification. A false result answers 409 with notification-dispatch-forbidden before the inbox write. When absent, every non-owner notification is recorded for the dispatch tick. A true result does not guarantee dispatch: the host's automated-entry authorizer and required permissions still apply at the tick.

    resolveAgent: (
        scope: ThreadScope,
        agentId: string | undefined,
        entryPath:
            | "approval.resume"
            | "http.start"
            | "remote-step.resume"
            | "signal.message"
            | "signal.queue"
            | "signal.reactive"
            | "signal.state"
            | "signal.notification"
            | "signal.wake"
            | "notification.dispatch"
            | "schedule.fire",
    ) => | Agent<
        string,
        ToolsInput,
        undefined,
        any,
        AgentEditorConfig
        | undefined,
    >
    | Promise<
        Agent<string, ToolsInput, undefined, any, 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. When the thread's init() has a pub/sub, a runtime-driven agent must return that same instance from getPubSub() or the routes answer 503. The routes install the thread's pub/sub on a non-runtime-driven agent.

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

    Storage-backed thread occupancy, including runs surviving DO eviction. status is the run's stored status when the host knows it. A delivery into a run that is not executing persists to memory because a queued delivery lives only in this isolate until the run drains it. A run that reports no status is treated as running.

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

    Durable inbox used by the trusted due-notification dispatch route. Required for /signal/notification ingestion to a runtime-driven agent or from a non-owner, 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. Delivery routes refuse with 409 when no resourceId resolves.

    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.

    scheduleProviderOptionsPolicy?: ScheduleProviderOptionsPolicy

    Receives stored options and target identity on every threaded agent-schedule fire before signal creation. A denied result settles a discard; an error, throw, or malformed result leaves the lease for a later tick. Without the callback, stored options reach the signal unchecked.

    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.