@mastra/core
Version:
63 lines • 2.51 kB
TypeScript
import type { BackgroundTaskManager } from './manager.js';
export { BACKGROUND_TASK_WORKFLOW_ID } from './workflow-id.js';
/**
* Builds the per-task workflow that owns executor + retries.
*
* Uses the standard (default) execution engine so the workflow runs entirely
* in-process on whichever background-task worker calls `run.start()`. This is
* critical for distributed deployments: routing through the evented pipeline
* would introduce another competing-consumer hop that could move execution to
* an orchestration worker or API process without the internal workflow or
* invocation-bound task context registered.
*
* Shape: outer workflow runs an inner `[run-attempt, classify-outcome]`
* workflow inside a `dountil` loop. `run-attempt` invokes the executor and
* categorises the outcome; `classify-outcome` persists final state, advances
* retry bookkeeping, and decides whether the loop is done. The dountil
* predicate exits on `done === true`.
*
* Step bodies close over `manager` directly — the bg-tasks layer is the only
* consumer of the `@internal` private fields.
*/
export declare function buildBackgroundTaskWorkflow(manager: BackgroundTaskManager): import("../workflows").Workflow<import("../workflows").DefaultEngineType, import("../workflows").Workflow<import("../workflows").DefaultEngineType, (import("../workflows").Step<"classify-outcome", unknown, {
taskId: string;
outcome: "cancelled" | "failed" | "retry" | "success" | "timed_out";
result?: unknown;
error?: any;
}, {
taskId: string;
done: boolean;
result?: unknown;
}, unknown, unknown, import("../workflows").DefaultEngineType, unknown> | import("../workflows").Step<"run-attempt", unknown, {
taskId: string;
done?: boolean | undefined;
result?: unknown;
}, {
taskId: string;
outcome: "cancelled" | "failed" | "retry" | "success" | "timed_out";
result?: unknown;
error?: any;
}, unknown, unknown, import("../workflows").DefaultEngineType, unknown>)[], "__background-task__attempt", unknown, {
taskId: string;
done?: boolean | undefined;
result?: unknown;
}, {
taskId: string;
done: boolean;
result?: unknown;
}, {
taskId: string;
done: boolean;
result?: unknown;
}, unknown, 1>[], "__background-task", unknown, {
taskId: string;
}, {
taskId: string;
done: boolean;
result?: unknown;
}, {
taskId: string;
done: boolean;
result?: unknown;
}, unknown, 1>;
//# sourceMappingURL=workflow.d.ts.map