UNPKG

@mastra/core

Version:
1 lines 62 kB
{"version":3,"sources":["../src/schedules/types.ts","../src/workflows/scheduler/cron.ts","../src/schedules/schedules.ts"],"names":["z","Cron","slugify","MastraError","ErrorDomain","ErrorCategory","randomUUID","claimId"],"mappings":";;;;;;;;;;;;AA0CO,IAAM,qBAAA,GAAwB;AAS9B,IAAM,wBAAA,GAA2B;AAoBxC,IAAM,wBAAA,GAA2BA,KAAE,MAAA,CAAOA,IAAA,CAAE,QAAO,EAAGA,IAAA,CAAE,KAAA,CAAM,CAACA,IAAA,CAAE,MAAA,IAAUA,IAAA,CAAE,MAAA,IAAUA,IAAA,CAAE,OAAA,IAAWA,IAAA,CAAE,IAAA,EAAM,CAAC,CAAC,CAAA;AAG9G,IAAM,2BAAA,GAA8BA,KAAE,MAAA,CAAO;AAAA,EAC3C,cAAA,EAAgBA,IAAA,CAAE,MAAA,CAAOA,IAAA,CAAE,MAAA,IAAUA,IAAA,CAAE,OAAA,EAAS,CAAA,CAAE,QAAA;AACpD,CAAC,CAAA;AAGD,IAAM,sBAAA,GAAyBA,KAAE,MAAA,CAAO;AAAA,EACtC,QAAA,EAAUA,KAAE,IAAA,CAAK,CAAC,WAAW,SAAA,EAAW,SAAS,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC7D,UAAA,EAAY,yBAAyB,QAAA;AACvC,CAAC,CAAA;AAGD,IAAM,oBAAA,GAAuBA,KAAE,MAAA,CAAO;AAAA,EACpC,QAAA,EAAUA,KAAE,IAAA,CAAK,CAAC,QAAQ,SAAA,EAAW,SAAS,CAAC,CAAA,CAAE,QAAA,EAAS;AAAA,EAC1D,UAAA,EAAY,yBAAyB,QAAA,EAAS;AAAA,EAC9C,aAAA,EAAe,4BAA4B,QAAA;AAC7C,CAAC,CAAA;AAMM,IAAM,mBAAA,GAAsBA,KAAE,MAAA,CAAO;AAAA,EAC1C,UAAA,EAAYA,KAAE,MAAA,EAAO;AAAA,EACrB,OAAA,EAASA,KAAE,MAAA,EAAO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AA,KAAc,EAAC;AAAA,IAC9D,GAAI,OAAO,SAAA,KAAc,MAAA,GAAY,EAAE,SAAA,EAAW,MAAA,CAAO,SAAA,EAAU,GAAI,EAAC;AAAA,IACxE,GAAI,OAAO,YAAA,KAAiB,MAAA,GAAY,EAAE,YAAA,EAAc,MAAA,CAAO,YAAA,EAAa,GAAI,EAAC;AAAA,IACjF,GAAI,OAAO,cAAA,KAAmB,MAAA,GAAY,EAAE,cAAA,EAAgB,MAAA,CAAO,cAAA,EAAe,GAAI,EAAC;AAAA,IACvF,GAAI,SAAS,QAAA,GAAW,EAAE,UAAU,QAAA,CAAS,QAAA,KAAa,EAAC;AAAA,IAC3D,WAAW,QAAA,CAAS,SAAA;AAAA,IACpB,WAAW,QAAA,CAAS;AAAA,GACtB;AACF;AAGO,SAAS,eAAe,QAAA,EAAwC;AACrE,EAAA,OAAO,eAAA,CAAgB,QAAQ,CAAA,IAAK,kBAAA,CAAmB,QAAQ,CAAA;AACjE","file":"chunk-5Z776ZCD.cjs","sourcesContent":["import { z } from 'zod/v4';\nimport type { AgentSignalAttributes, AgentSignalType } from '../agent/signals';\nimport type { AgentSignalActiveBehavior, AgentSignalIdleBehavior } from '../agent/types';\n\n/**\n * Serializable subset of `AgentExecutionOptions` that an agent schedule persists and\n * applies to the woken run. Schedule config is JSON-persisted to schedule\n * storage, so only JSON-safe fields are accepted here — non-serializable run\n * options (callbacks, abort signals, live handles) are excluded by design.\n *\n * `requestContext` is stored as a plain object and rehydrated into a\n * `RequestContext` by the worker before the wake signal runs. This is how a\n * schedule-woken run receives request context (e.g. channel render context).\n */\nexport type ScheduleStreamOptions = {\n /** Request context applied to the woken run, stored as a plain object. */\n requestContext?: Record<string, unknown>;\n};\n\n/**\n * Options applied when the target thread is actively streaming. Threaded only.\n * Mirrors the signal runtime's `ifActive` options so agent schedules accept the same\n * shape `agent.sendSignal` allows.\n */\nexport type ScheduleIfActive = {\n behavior?: AgentSignalActiveBehavior;\n attributes?: AgentSignalAttributes;\n};\n\n/**\n * Options applied when the target thread is idle. Threaded only. Mirrors the\n * signal runtime's `ifIdle` options, but `streamOptions` is restricted to the\n * serializable {@link ScheduleStreamOptions} subset so the config can be\n * persisted to schedule storage.\n */\nexport type ScheduleIfIdle = {\n behavior?: AgentSignalIdleBehavior;\n attributes?: AgentSignalAttributes;\n streamOptions?: ScheduleStreamOptions;\n};\n\n/** Stable schedule id prefix for agent schedules. */\nexport const AGENT_SCHEDULE_PREFIX = 'agent_';\n\n/**\n * Stable schedule id prefix for imperative workflow schedules created via\n * `mastra.schedules.create({ workflowId, ... })`. Intentionally distinct from\n * the `wf_` prefix used by declarative `createWorkflow({ schedule })` rows —\n * the boot-time declarative sync sweeps `wf_` rows against the in-code\n * config and must never delete imperative rows.\n */\nexport const WORKFLOW_SCHEDULE_PREFIX = 'schedule_';\n\n/**\n * Status reported by a single agent-schedule run. The {@link AgentScheduleWorker}\n * derives the scheduler trigger row's `outcome` (`succeeded`, `delivered`,\n * `persisted`, `discarded`, `skipped`, `aborted`, or `failed`) from this;\n * the status is also surfaced on the trigger row's metadata.\n *\n * Distinct from `ScheduleTriggerOutcome` (which describes scheduler-level\n * dispatch results); this describes what the agent-schedule tick itself did.\n */\nexport type ScheduleRunStatus =\n | 'fired'\n | 'signal-accepted'\n | 'skipped-thread-blocked'\n | 'thread-missing'\n | 'agent-missing'\n | 'invalid-input';\n\n/** Shared zod for {@link AgentSignalAttributes} (XML tag attribute values). */\nconst ScheduleAttributesSchema = z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()]));\n\n/** Serializable stream options applied to a woken run. See {@link ScheduleStreamOptions}. */\nconst ScheduleStreamOptionsSchema = z.object({\n requestContext: z.record(z.string(), z.unknown()).optional(),\n});\n\n/** Options applied when the target thread is actively streaming. */\nconst ScheduleIfActiveSchema = z.object({\n behavior: z.enum(['deliver', 'persist', 'discard']).optional(),\n attributes: ScheduleAttributesSchema.optional(),\n});\n\n/** Options applied when the target thread is idle. */\nconst ScheduleIfIdleSchema = z.object({\n behavior: z.enum(['wake', 'persist', 'discard']).optional(),\n attributes: ScheduleAttributesSchema.optional(),\n streamOptions: ScheduleStreamOptionsSchema.optional(),\n});\n\n/**\n * Input payload persisted in `Schedule.target.inputData` for the built-in\n * agent-schedule fire. The scheduler tick rehydrates this on every fire.\n */\nexport const ScheduleInputSchema = z.object({\n scheduleId: z.string(),\n agentId: z.string(),\n prompt: z.string(),\n threadId: z.string().optional(),\n resourceId: z.string().optional(),\n signalType: z.enum(['user', 'state', 'reactive', 'notification', 'user-message', 'system-reminder']).optional(),\n /**\n * XML tag name the signal renders as. Defaults to `schedule`, so a fire\n * surfaces to the agent as `<schedule>…</schedule>`. Override to render a\n * different tag.\n */\n tagName: z.string().optional(),\n /** Attributes rendered onto the signal's XML tag. */\n attributes: ScheduleAttributesSchema.optional(),\n /**\n * Provider options merged into the schedule signal payload on every fire.\n * Stored as a plain JSON object (`MastraProviderMetadata` is JSON-safe) and\n * applied regardless of `ifActive` / `ifIdle`.\n */\n providerOptions: z.record(z.string(), z.unknown()).optional(),\n ifActive: ScheduleIfActiveSchema.optional(),\n ifIdle: ScheduleIfIdleSchema.optional(),\n});\n\nexport type ScheduleInput = z.infer<typeof ScheduleInputSchema>;\n\nexport const ScheduleOutputSchema = z.object({\n status: z.enum([\n 'fired',\n 'signal-accepted',\n 'skipped-thread-blocked',\n 'thread-missing',\n 'agent-missing',\n 'invalid-input',\n ]),\n reason: z.string().optional(),\n});\n\nexport type ScheduleOutput = z.infer<typeof ScheduleOutputSchema>;\n\n// ---------------------------------------------------------------------------\n// Lifecycle hooks\n//\n// User-defined callbacks configured via `new Mastra({ schedules: { ... } })`.\n// A single hook bundle runs for every schedule fire; each context carries\n// `agentId` so a hook can branch per agent. Mirror the\n// `agent.stream` `onFinish`/`onError`/`onAbort` conventions so users learn one\n// mental model. `prepare` lets users compute fire-time parameters (e.g. create\n// a Slack thread per fire) or skip the fire entirely by returning null.\n// ---------------------------------------------------------------------------\n\n/** Effective parameters the agent-schedule worker uses on a single fire. */\nexport type ScheduleEffective = {\n threadId?: string;\n resourceId?: string;\n prompt: string;\n signalType?: AgentSignalType;\n tagName?: string;\n ifActive?: ScheduleIfActive;\n ifIdle?: ScheduleIfIdle;\n attributes?: AgentSignalAttributes;\n providerOptions?: Record<string, unknown>;\n};\n\n/** Trigger context passed to every hook. */\nexport type ScheduleTriggerInfo = {\n kind: 'cron' | 'manual';\n firedAt: Date;\n};\n\n/** Limited terminal-state snapshot for a schedule-driven agent run. */\nexport type ScheduleRunResultSnapshot = {\n text?: string;\n usage?: Record<string, unknown>;\n finishReason?: string;\n};\n\n/** Forward-declared so this file does not import from `./schedules`. */\ninterface ScheduleRef {\n id: string;\n agentId: string;\n name?: string;\n [key: string]: unknown;\n}\n\n/** Argument passed to `schedules.prepare`. */\nexport type SchedulePrepareContext<TMastra = unknown> = {\n mastra: TMastra;\n /** The agent this schedule fires. Convenience alias for `schedule.agentId`. */\n agentId: string;\n schedule: ScheduleRef;\n trigger: ScheduleTriggerInfo;\n};\n\n/**\n * Return value from `schedules.prepare`.\n *\n * - object → merged into the row defaults; missing fields fall back to the row\n * - `null` → skip this fire (outcome: 'skipped'); the worker records the trigger\n * row and fires `onFinish({ outcome: 'skipped' })`\n * - `undefined` → use row defaults verbatim\n */\nexport type SchedulePrepareResult = Partial<ScheduleEffective>;\n\n/** Argument passed to `schedules.onFinish` for any non-error, non-abort outcome. */\nexport type ScheduleFinishContext<TMastra = unknown> = {\n mastra: TMastra;\n /** The agent this schedule fires. Convenience alias for `schedule.agentId`. */\n agentId: string;\n schedule: ScheduleRef;\n trigger: ScheduleTriggerInfo;\n outcome: 'succeeded' | 'delivered' | 'persisted' | 'discarded' | 'skipped';\n /** Present for `succeeded` and `delivered` outcomes. */\n runId?: string;\n /** True when `outcome === 'delivered'` and the signal joined an active run. */\n joinedExistingRun?: boolean;\n /** Best-effort terminal snapshot; populated for `succeeded` runs. */\n result?: ScheduleRunResultSnapshot;\n effective: ScheduleEffective;\n};\n\n/** Argument passed to `schedules.onError` whenever `prepare`, `sendSignal`, or the agent run threw. */\nexport type ScheduleErrorContext<TMastra = unknown> = {\n mastra: TMastra;\n /** The agent this schedule fires. Convenience alias for `schedule.agentId`. */\n agentId: string;\n schedule: ScheduleRef;\n trigger: ScheduleTriggerInfo;\n phase: 'prepare' | 'run';\n error: Error;\n runId?: string;\n /** Best-effort effective view; may be partial if `prepare` threw before merging. */\n effective?: ScheduleEffective;\n};\n\n/** Argument passed to `schedules.onAbort` when the run was aborted mid-stream. */\nexport type ScheduleAbortContext<TMastra = unknown> = {\n mastra: TMastra;\n /** The agent this schedule fires. Convenience alias for `schedule.agentId`. */\n agentId: string;\n schedule: ScheduleRef;\n trigger: ScheduleTriggerInfo;\n runId: string;\n effective: ScheduleEffective;\n};\n\n/**\n * Bundle of lifecycle hooks. A single bundle runs for every schedule fire;\n * each context carries `agentId` so a hook can branch per agent.\n *\n * `onFinish` fires once per schedule trigger when the trigger reached a\n * non-error, non-abort terminal state. `onError` fires when `prepare`,\n * `sendSignal`, or the agent run threw. `onAbort` fires when the run was\n * aborted mid-stream. `prepare` can return overrides, `null` to skip, or\n * `undefined` to use row defaults.\n *\n * Hook exceptions are caught and logged; they never re-route the worker or\n * recurse into another hook.\n */\nexport type ScheduleHooks<TMastra = unknown> = {\n prepare?: (\n ctx: SchedulePrepareContext<TMastra>,\n ) => Promise<SchedulePrepareResult | null | undefined> | SchedulePrepareResult | null | undefined;\n onFinish?: (ctx: ScheduleFinishContext<TMastra>) => Promise<void> | void;\n onError?: (ctx: ScheduleErrorContext<TMastra>) => Promise<void> | void;\n onAbort?: (ctx: ScheduleAbortContext<TMastra>) => Promise<void> | void;\n};\n\n/**\n * Schedules runtime configuration passed to the Mastra constructor via\n * `schedules`. Holds a single lifecycle hook bundle that runs for every\n * schedule fire. Hooks live at the Mastra level so they apply to both\n * code-defined and stored agents (stored agents cannot define functions in\n * their serialized config). Each hook context carries `agentId`, so branch\n * on it when a hook should behave differently per agent.\n *\n * @example\n * ```typescript\n * new Mastra({\n * schedules: {\n * prepare: async ({ agentId, schedule }) => ({ threadId: '...' }),\n * onFinish: async ({ agentId, trigger }) => { ... },\n * },\n * });\n * ```\n */\nexport type SchedulesConfig<TMastra = unknown> = ScheduleHooks<TMastra>;\n","import { Cron } from 'croner';\n\n/**\n * Validate a cron expression. Throws if the pattern is invalid.\n *\n * @param cron - Cron expression (5-, 6-, or 7-part).\n * @param timezone - Optional IANA timezone (e.g. 'America/New_York').\n */\nexport function validateCron(cron: string, timezone?: string): void {\n if (typeof cron !== 'string' || cron.trim() === '') {\n throw new Error(\n `Invalid cron expression: expected a non-empty cron string (e.g. \"0 * * * *\"), but received ${cron === undefined ? 'undefined' : JSON.stringify(cron)}.`,\n );\n }\n // Croner throws synchronously on an invalid pattern when the job is\n // constructed. Validate the pattern on its own first so timezone problems\n // (which croner only surfaces lazily) are not mislabeled as cron errors.\n let job: Cron;\n try {\n job = new Cron(cron);\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(`Invalid cron expression \"${cron}\": ${reason}`);\n }\n // The timezone is only exercised when a fire time is computed.\n if (timezone !== undefined) {\n try {\n new Cron(cron, { timezone }).nextRun();\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(`Invalid timezone \"${timezone}\": ${reason}`);\n }\n } else {\n job.nextRun();\n }\n}\n\n/**\n * Compute the next fire time (ms since epoch) for a cron expression.\n *\n * @param cron - Cron expression.\n * @param options - Optional timezone and reference time (`after`, ms since epoch).\n * The next fire time is the first cron occurrence strictly after `after`.\n * Defaults to `Date.now()`.\n * @returns The next fire time in ms since epoch.\n * @throws If the cron expression is invalid or has no future occurrence.\n */\nexport function computeNextFireAt(cron: string, options?: { timezone?: string; after?: number }): number {\n const job = new Cron(cron, { timezone: options?.timezone });\n const reference = options?.after !== undefined ? new Date(options.after) : new Date();\n const next = job.nextRun(reference);\n if (!next) {\n throw new Error(`Cron expression \"${cron}\" has no future occurrence after ${reference.toISOString()}`);\n }\n return next.getTime();\n}\n","import { randomUUID } from 'node:crypto';\nimport slugify from '@sindresorhus/slugify';\nimport type { AgentSignalAttributes, AgentSignalType } from '../agent/signals';\nimport { ErrorCategory, ErrorDomain, MastraError } from '../error';\nimport type { Mastra } from '../mastra';\nimport type { Schedule, SchedulesStorage } from '../storage/domains/schedules/base';\nimport { computeNextFireAt, validateCron } from '../workflows/scheduler/cron';\nimport type { ScheduleIfActive, ScheduleIfIdle } from './types';\nimport { AGENT_SCHEDULE_PREFIX, WORKFLOW_SCHEDULE_PREFIX } from './types';\n\ntype AgentTarget = Extract<Schedule['target'], { type: 'agent' }>;\ntype WorkflowTarget = Extract<Schedule['target'], { type: 'workflow' }>;\n\n/** PubSub topic consumed by the workflow event processor. */\nconst TOPIC_WORKFLOWS = 'workflows';\n\n/**\n * Slugify the caller-facing portion of a schedule id into a canonical\n * `<prefix><slug>` shape. The slug part is lowercased and stripped of\n * characters that are unsafe in storage keys / URLs; the prefix is added only\n * if missing so a caller can pass either `nightly-summary` or\n * `agent_nightly-summary` and get the same canonical id. Returns an empty\n * string when nothing slug-able remains.\n */\nfunction canonicalizeScheduleId(rawId: string, prefix: string): string {\n const trimmed = rawId.trim();\n const withoutPrefix = trimmed.startsWith(prefix) ? trimmed.slice(prefix.length) : trimmed;\n const slug = slugify(withoutPrefix);\n if (!slug) return '';\n return `${prefix}${slug}`;\n}\n\n/**\n * Normalize a caller-supplied schedule id for `create`. Throws\n * `SCHEDULES_INVALID_ID` when the id is empty after normalization so callers\n * cannot create an unaddressable schedule.\n */\nfunction normalizeScheduleId(rawId: string, prefix: string): string {\n const canonical = canonicalizeScheduleId(rawId, prefix);\n if (!canonical) {\n throw new MastraError({\n id: 'SCHEDULES_INVALID_ID',\n domain: ErrorDomain.AGENT,\n category: ErrorCategory.USER,\n text: `schedules.create: id \"${rawId}\" is empty after normalization. Provide an id with at least one alphanumeric character.`,\n });\n }\n return canonical;\n}\n\n/**\n * Flat agent-schedule view returned by the {@link Schedules} service.\n * Projects the underlying `Schedule` row + `target.type === 'agent'` payload\n * onto a single object so callers never have to know about the schedules\n * storage shape. Discriminate from {@link WorkflowSchedule} via the\n * `agentId` field.\n */\nexport interface AgentSchedule {\n id: string;\n agentId: string;\n /** Discriminant mirror — always absent on agent schedules. Check `workflowId` to narrow {@link AnySchedule}. */\n workflowId?: undefined;\n name?: string;\n threadId?: string;\n resourceId?: string;\n prompt: string;\n cron: string;\n timezone?: string;\n status: 'active' | 'paused';\n nextFireAt: number;\n lastFireAt?: number;\n lastRunId?: string;\n signalType?: AgentSignalType;\n tagName?: string;\n attributes?: AgentSignalAttributes;\n providerOptions?: Record<string, unknown>;\n ifActive?: ScheduleIfActive;\n ifIdle?: ScheduleIfIdle;\n metadata?: Record<string, unknown>;\n createdAt: number;\n updatedAt: number;\n}\n\n/**\n * Flat workflow-schedule view returned by the {@link Schedules} service.\n * Discriminate from {@link AgentSchedule} via the `workflowId` field.\n */\nexport interface WorkflowSchedule {\n id: string;\n workflowId: string;\n /** Discriminant mirror — always absent on workflow schedules. Check `agentId` to narrow {@link AnySchedule}. */\n agentId?: undefined;\n cron: string;\n timezone?: string;\n status: 'active' | 'paused';\n nextFireAt: number;\n lastFireAt?: number;\n lastRunId?: string;\n inputData?: unknown;\n initialState?: unknown;\n requestContext?: Record<string, unknown>;\n metadata?: Record<string, unknown>;\n createdAt: number;\n updatedAt: number;\n}\n\n/** Union of the flat views returned by the {@link Schedules} service. */\nexport type AnySchedule = AgentSchedule | WorkflowSchedule;\n\n/** Agent variant of {@link CreateScheduleInput}. */\nexport interface CreateAgentScheduleInput {\n /**\n * Optional stable id. Normalized to `agent_<slug>` (the `agent_` prefix is\n * added if missing and the rest is slugified). When omitted, a random\n * `agent_<uuid>` id is generated. Creating a schedule with an id that\n * already exists throws.\n */\n id?: string;\n agentId: string;\n cron: string;\n prompt: string;\n /** Optional free-form label for distinguishing multiple schedules on the same agent/thread. */\n name?: string;\n timezone?: string;\n threadId?: string;\n resourceId?: string;\n /** Signal category for the fire. Defaults to `'notification'`. */\n signalType?: AgentSignalType;\n /** XML tag the signal renders as. Defaults to `'schedule'` (so a fire surfaces as `<schedule>…</schedule>`). */\n tagName?: string;\n /** Attributes rendered onto the signal's XML tag. */\n attributes?: AgentSignalAttributes;\n /** Provider options merged into the schedule signal payload on every fire. JSON-safe. */\n providerOptions?: Record<string, unknown>;\n ifActive?: ScheduleIfActive;\n ifIdle?: ScheduleIfIdle;\n metadata?: Record<string, unknown>;\n /** Schedule lifecycle status. Defaults to `'active'`. */\n status?: 'active' | 'paused';\n}\n\n/** Workflow variant of {@link CreateScheduleInput}. */\nexport interface CreateWorkflowScheduleInput {\n /**\n * Optional stable id. Normalized to `schedule_<slug>`. When omitted, a\n * random `schedule_<uuid>` id is generated. Imperative workflow schedules\n * intentionally never use the `wf_` prefix — that prefix is reserved for\n * declarative `createWorkflow({ schedule })` rows, which the boot-time\n * sync sweeps against the in-code config.\n */\n id?: string;\n workflowId: string;\n cron: string;\n timezone?: string;\n inputData?: unknown;\n initialState?: unknown;\n requestContext?: Record<string, unknown>;\n metadata?: Record<string, unknown>;\n /** Schedule lifecycle status. Defaults to `'active'`. */\n status?: 'active' | 'paused';\n}\n\n/**\n * Input to {@link Schedules.create}. Discriminated by `agentId` vs\n * `workflowId`.\n */\nexport type CreateScheduleInput = CreateAgentScheduleInput | CreateWorkflowScheduleInput;\n\n/** Agent variant of {@link UpdateScheduleInput}. */\nexport interface UpdateAgentScheduleInput {\n cron?: string;\n timezone?: string;\n prompt?: string;\n name?: string;\n signalType?: AgentSignalType;\n tagName?: string;\n attributes?: AgentSignalAttributes;\n providerOptions?: Record<string, unknown>;\n ifActive?: ScheduleIfActive;\n ifIdle?: ScheduleIfIdle;\n metadata?: Record<string, unknown>;\n status?: 'active' | 'paused';\n}\n\n/** Workflow variant of {@link UpdateScheduleInput}. */\nexport interface UpdateWorkflowScheduleInput {\n cron?: string;\n timezone?: string;\n inputData?: unknown;\n initialState?: unknown;\n requestContext?: Record<string, unknown>;\n metadata?: Record<string, unknown>;\n status?: 'active' | 'paused';\n}\n\n/** Patch input to {@link Schedules.update}. */\nexport type UpdateScheduleInput = UpdateAgentScheduleInput | UpdateWorkflowScheduleInput;\n\n/** Filter for {@link Schedules.list}. */\nexport interface ListSchedulesFilter {\n /** Return only agent schedules for this agent. */\n agentId?: string;\n /** Return only workflow schedules for this workflow. */\n workflowId?: string;\n /** Agent-schedule only: match the target threadId. */\n threadId?: string;\n /** Agent-schedule only: match the target resourceId. */\n resourceId?: string;\n /** Agent-schedule only: match the free-form target name. */\n name?: string;\n status?: 'active' | 'paused';\n}\n\n/**\n * Unified service for cron schedules. Schedules are persisted as `Schedule`\n * rows whose `target` discriminates what fires: `type: 'agent'` rows run an\n * agent (via signal or `agent.generate`), `type: 'workflow'` rows start a\n * workflow run. This class is a typed projection over `SchedulesStorage`\n * that knows how to build targets and surface flat\n * {@link AgentSchedule} / {@link WorkflowSchedule} views.\n *\n * Use via `mastra.schedules` (the canonical CRUD surface).\n */\nexport class Schedules {\n #mastra: Mastra;\n\n constructor(mastra: Mastra) {\n this.#mastra = mastra;\n }\n\n async #getStore() {\n const storage = this.#mastra.getStorage();\n const store = await storage?.getStore('schedules');\n if (!store) {\n throw new MastraError({\n id: 'SCHEDULES_NO_SCHEDULES_STORAGE',\n domain: ErrorDomain.AGENT,\n category: ErrorCategory.USER,\n text: 'Schedules require a storage adapter that implements the schedules domain.',\n });\n }\n return store;\n }\n\n /**\n * Resolve a caller-supplied id to a stored row. An id is first looked up\n * verbatim (covering `agent_`, `schedule_`, `wf_`, and legacy `hb_` ids);\n * when that misses, a bare caller id is canonicalized to `agent_<slug>` to\n * match what agent-schedule `create` persisted.\n */\n async #load(id: string): Promise<Schedule | null> {\n const store = await this.#getStore();\n const trimmed = id.trim();\n const exact = trimmed ? await store.getSchedule(trimmed) : null;\n if (exact) return exact;\n const canonical = canonicalizeScheduleId(trimmed, AGENT_SCHEDULE_PREFIX);\n if (!canonical || canonical === trimmed) return null;\n return store.getSchedule(canonical);\n }\n\n async create(input: CreateAgentScheduleInput): Promise<AgentSchedule>;\n async create(input: CreateWorkflowScheduleInput): Promise<WorkflowSchedule>;\n async create(input: CreateScheduleInput): Promise<AnySchedule> {\n if ('workflowId' in input && input.workflowId) {\n return this.#createWorkflowSchedule(input);\n }\n return this.#createAgentSchedule(input as CreateAgentScheduleInput);\n }\n\n async #createAgentSchedule(input: CreateAgentScheduleInput): Promise<AgentSchedule> {\n validateCron(input.cron, input.timezone);\n\n if (!input.agentId) {\n throw new MastraError({\n id: 'SCHEDULES_MISSING_TARGET_ID',\n domain: ErrorDomain.AGENT,\n category: ErrorCategory.USER,\n text: 'schedules.create requires `agentId` or `workflowId`.',\n });\n }\n\n if (input.threadId && !input.resourceId) {\n throw new MastraError({\n id: 'SCHEDULES_MISSING_RESOURCE_ID',\n domain: ErrorDomain.AGENT,\n category: ErrorCategory.USER,\n text: 'schedules.create requires `resourceId` when `threadId` is set.',\n });\n }\n if (!input.threadId) {\n const offenders: string[] = [];\n if (input.signalType !== undefined) offenders.push('signalType');\n if (input.ifActive !== undefined) offenders.push('ifActive');\n if (input.ifIdle !== undefined) offenders.push('ifIdle');\n if (input.resourceId !== undefined) offenders.push('resourceId');\n if (offenders.length > 0) {\n throw new MastraError({\n id: 'SCHEDULES_THREADLESS_OPTIONS',\n domain: ErrorDomain.AGENT,\n category: ErrorCategory.USER,\n text: `schedules.create: ${offenders.join(', ')} require a threadId.`,\n });\n }\n }\n\n const store = await this.#getStore();\n // Make sure the scheduler + agent-schedule worker are running. Boot-time\n // detection covers existing rows; imperative creates after\n // startWorkers() need to flip the request flag and lazily inject.\n await this.#mastra.__ensureScheduleRuntimeReady();\n\n const id =\n input.id !== undefined\n ? normalizeScheduleId(input.id, AGENT_SCHEDULE_PREFIX)\n : `${AGENT_SCHEDULE_PREFIX}${randomUUID()}`;\n await this.#assertIdAvailable(store, id, input.id !== undefined);\n const now = Date.now();\n const nextFireAt = computeNextFireAt(input.cron, { timezone: input.timezone, after: now });\n\n const target: AgentTarget = {\n type: 'agent',\n agentId: input.agentId,\n prompt: input.prompt,\n ...(input.name !== undefined ? { name: input.name } : {}),\n ...(input.threadId ? { threadId: input.threadId } : {}),\n ...(input.resourceId ? { resourceId: input.resourceId } : {}),\n ...(input.signalType ? { signalType: input.signalType } : {}),\n ...(input.tagName ? { tagName: input.tagName } : {}),\n ...(input.attributes ? { attributes: input.attributes } : {}),\n ...(input.providerOptions ? { providerOptions: input.providerOptions } : {}),\n ...(input.ifActive ? { ifActive: input.ifActive } : {}),\n ...(input.ifIdle ? { ifIdle: input.ifIdle } : {}),\n };\n\n const schedule: Schedule = {\n id,\n target,\n cron: input.cron,\n timezone: input.timezone,\n status: input.status ?? 'active',\n nextFireAt,\n createdAt: now,\n updatedAt: now,\n ownerType: 'agent',\n ownerId: input.agentId,\n ...(input.metadata ? { metadata: input.metadata } : {}),\n };\n\n const created = await store.createSchedule(schedule);\n return toAgentSchedule(created)!;\n }\n\n async #createWorkflowSchedule(input: CreateWorkflowScheduleInput): Promise<WorkflowSchedule> {\n validateCron(input.cron, input.timezone);\n\n const store = await this.#getStore();\n // Imperative workflow schedules need the scheduler tick loop running,\n // same as agent schedules created after startWorkers().\n await this.#mastra.__ensureScheduleRuntimeReady();\n\n const id =\n input.id !== undefined\n ? normalizeScheduleId(input.id, WORKFLOW_SCHEDULE_PREFIX)\n : `${WORKFLOW_SCHEDULE_PREFIX}${randomUUID()}`;\n await this.#assertIdAvailable(store, id, input.id !== undefined);\n const now = Date.now();\n const nextFireAt = computeNextFireAt(input.cron, { timezone: input.timezone, after: now });\n\n const target: WorkflowTarget = {\n type: 'workflow',\n workflowId: input.workflowId,\n ...(input.inputData !== undefined ? { inputData: input.inputData } : {}),\n ...(input.initialState !== undefined ? { initialState: input.initialState } : {}),\n ...(input.requestContext !== undefined ? { requestContext: input.requestContext } : {}),\n };\n\n const schedule: Schedule = {\n id,\n target,\n cron: input.cron,\n timezone: input.timezone,\n status: input.status ?? 'active',\n nextFireAt,\n createdAt: now,\n updatedAt: now,\n ...(input.metadata ? { metadata: input.metadata } : {}),\n };\n\n const created = await store.createSchedule(schedule);\n return toWorkflowSchedule(created)!;\n }\n\n async #assertIdAvailable(store: SchedulesStorage, id: string, callerProvided: boolean): Promise<void> {\n if (!callerProvided) return;\n const existing = await store.getSchedule(id);\n if (existing) {\n throw new MastraError({\n id: 'SCHEDULES_ID_EXISTS',\n domain: ErrorDomain.AGENT,\n category: ErrorCategory.USER,\n text: `schedules.create: a schedule with id \"${id}\" already exists. Use update() to modify it or choose a different id.`,\n });\n }\n }\n\n async get(id: string): Promise<AnySchedule | null> {\n const schedule = await this.#load(id);\n if (!schedule) return null;\n return toScheduleView(schedule);\n }\n\n async list(filter?: ListSchedulesFilter): Promise<AnySchedule[]> {\n const store = await this.#getStore();\n const schedules = await store.listSchedules({\n ...(filter?.agentId ? { ownerType: 'agent', ownerId: filter.agentId } : {}),\n ...(filter?.workflowId ? { workflowId: filter.workflowId } : {}),\n ...(filter?.status ? { status: filter.status } : {}),\n });\n const views = schedules\n .map(toScheduleView)\n .filter((s): s is AnySchedule => s !== null)\n // `workflowId` filters at the store level, but an `agentId` filter must\n // not surface workflow rows (and vice versa when both are set).\n .filter(s => (filter?.agentId ? s.agentId !== undefined : true));\n const agentOnly = filter?.threadId !== undefined || filter?.