@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
38 lines • 1.48 kB
TypeScript
import type { PubSub } from '../events/pubsub.js';
import type { IMastraLogger } from '../logger/index.js';
import type { Mastra } from '../mastra/index.js';
import type { MastraCompositeStore } from '../storage/index.js';
/**
* Infrastructure dependencies provided to workers during initialization.
*/
export interface WorkerDeps {
pubsub: PubSub;
storage: MastraCompositeStore;
logger: IMastraLogger;
mastra?: Mastra;
}
/**
* Abstract base class for Mastra workers.
*
* Each worker is a self-contained, independently deployable unit of
* background processing. Concrete implementations include:
* - OrchestrationWorker: processes workflow events
* - SchedulerWorker: fires cron-based workflow schedules
* - BackgroundTaskWorker: manages background tool execution
*
* Workers are registered on a Mastra instance and run inline by default.
* They can also be launched standalone via the CLI for separate deployment.
*/
export declare abstract class MastraWorker {
abstract readonly name: string;
protected mastra?: Mastra;
protected deps?: WorkerDeps;
/** Called by Mastra during registration to provide the instance reference. */
__registerMastra(mastra: Mastra): void;
/** Initialize with infrastructure deps. Called before start(). */
init(deps: WorkerDeps): Promise<void>;
abstract start(): Promise<void>;
abstract stop(): Promise<void>;
abstract get isRunning(): boolean;
}
//# sourceMappingURL=worker.d.ts.map