Anchorage API reference
    Preparing search index...
    interface BackgroundTaskHostOptions {
        execution?: { tenantId: string };
        executors: Record<string, ToolExecutor>;
        manager?: Omit<BackgroundTaskManagerConfig, "enabled">;
        mastra: Mastra;
        pubsub: PubSub;
    }
    Index

    Properties

    execution?: { tenantId: string }

    Enable real evented-worker execution for one tenant DO. Omit to preserve the persistence/recovery-only behavior.

    executors: Record<string, ToolExecutor>

    Static tool executors, keyed by tool name, RE-REGISTERED at every boot so a task recovered on a fresh DO instance (post-eviction) resolves its executor by name. Tools are static — their executor closures are safe to rebuild deterministically at boot, unlike per-task closures which core documents are "never serialized".

    manager?: Omit<BackgroundTaskManagerConfig, "enabled">

    Manager config (core BackgroundTaskManagerConfig minus enabled, which is forced on): concurrency, backpressure ('queue'|'reject'|'fallback-sync'), timeouts, retries, and cleanup TTLs. Numeric values are validated before constructing core's manager: concurrency/retry delays/TTLs/throttle are nonnegative, timeout/cleanup intervals are positive, and all integer quantities must be safe integers. Omitted => core defaults.

    mastra: Mastra

    The DO's Mastra — must carry a storage adapter whose getStore('backgroundTasks') resolves (D1Store does). The manager reads every task through it.

    pubsub: PubSub

    The Durable Object's single raw pubsub instance from createHostPubSub(). Pass this same object to new Mastra({ pubsub }); Mastra 1.50 exposes a proxy from its public pubsub getter, so that getter is not the constructor identity. The manager both publishes dispatch events and subscribes the worker callback on the raw instance, and inside a DO one isolate serializes publisher and subscriber, so an in-process EventEmitterPubSub is exactly right (no cross-process bus). A host that streams lifecycle events to its hub also passes this same raw instance to init().