import type { ChannelAdapter } from "#channel/adapter.js"; import { type Session } from "#channel/session.js"; import type { Runtime } from "#channel/types.js"; import type { ScheduleRunHandler } from "#public/definitions/schedule.js"; import type { DynamicSchedulesDefinition, ScheduleOccurrenceIdentity } from "#public/schedules/subscription.js"; import { type ScheduleCollectionPayload } from "#runtime/schedules/payload.js"; import type { ResolvedChannelDefinition } from "#runtime/types.js"; export { SCHEDULE_APP_AUTH } from "#channel/schedule-auth.js"; /** * Durable adapter kind used when a schedule fires without targeting a * channel — the markdown form, and the synthesized run the dispatcher * builds for it. * * Framework-owned — authored code never constructs a schedule adapter * directly. Registered in `FRAMEWORK_ADAPTERS`. */ export declare const SCHEDULE_ADAPTER_KIND = "schedule"; export declare const SCHEDULE_ADAPTER: ChannelAdapter; /** * Loaded shape of one schedule for the dispatcher. Either `run` is * defined (authored handler) or `markdown` is defined (fire-and-forget). */ export interface ScheduleDispatchInput { readonly scheduleId: string; readonly run?: ScheduleRunHandler; readonly markdown?: string; } /** Sessions started by dispatch and background work registered by the handler. */ export interface ScheduleDispatchResult { readonly sessions: readonly Session[]; readonly waitUntilTasks: readonly Promise[]; } export interface ScheduleCollectionDispatchInput { readonly collectionId: string; readonly definition: DynamicSchedulesDefinition; readonly payload: ScheduleCollectionPayload; readonly occurrence: ScheduleOccurrenceIdentity; readonly verifyDelivery?: () => Promise; } /** * Dispatches scheduled task execution. * * For handler schedules: builds {@link ScheduleHandlerArgs} against the * request-scoped channel bundle and invokes the author's `run`. The * author owns control flow — `args.to(channel, target).send(…)` hands work off * to a channel; `args.waitUntil(promise)` extends the task lifetime * so the dispatcher awaits in-flight work before settling. * * For markdown schedules: synthesizes a channel-less run that starts a * session with {@link SCHEDULE_ADAPTER} and the markdown body as the * message. * * Returns a {@link ScheduleDispatchResult} carrying any sessions the * handler started (for telemetry / task-result observability) and the * `waitUntil` promises the handler registered. Subscription callbacks resolve * creator auth and await their registered work before returning; their channel * sends start fresh, unattended sessions rather than resume a conversation. */ export declare class ScheduleDispatcher { private readonly runtime; private readonly channels; constructor(config: { readonly runtime: Runtime; readonly channels: readonly ResolvedChannelDefinition[]; }); trigger(input: ScheduleDispatchInput): Promise; triggerCollection(input: ScheduleCollectionDispatchInput): Promise; private triggerInScope; private createHandlerContext; private runMarkdown; } /** * Convenience: extract a `run` function from one loaded schedule module * value, or throw with the file path so misconfigured modules fail * obviously instead of crashing deep inside the dispatcher. */ export declare function expectScheduleRun(value: unknown, logicalPath: string, exportName: string | undefined): ScheduleRunHandler;