UNPKG

@mastra/core

Version:
41 lines • 2.37 kB
import type { NotificationDeliveryAction, NotificationDeliveryDecision, NotificationDeliveryThreadState, NotificationPriority, NotificationRecord, NotificationStatus } from './types.js'; /** * Delivery attempts allowed before a notification is marked `failed`. A failed * record is no longer due, so a deterministic delivery error (a missing model, * a rejected request context) stops being retried on every dispatch tick. */ export declare const MAX_NOTIFICATION_DELIVERY_ATTEMPTS = 5; /** * Attempt bookkeeping applied when a delivery attempt throws, spread into the * `updateNotification` call at each failure site. */ export declare function resolveDeliveryFailureUpdate(record: NotificationRecord): { deliveryAttempts: number; status?: NotificationStatus; }; export type NotificationDeliveryPolicyDecision = NotificationDeliveryAction | NotificationDeliveryDecision; export type NotificationDeliveryPolicyInput = { record: NotificationRecord; threadState: NotificationDeliveryThreadState; now: Date; }; /** * Custom delivery decision logic. Runs at receipt time (when the notification * is sent) and, for records the receipt-time decision deferred or scheduled * for summary, AGAIN at delivery time when the dispatch workflow picks them * up. At delivery time only the decision's `streamOptions` and `hold` are * honored — the record's persisted schedule already fixed when and how it * delivers — so deciders should be side-effect free. */ export type NotificationDeliveryPolicyDecider = (input: NotificationDeliveryPolicyInput) => NotificationDeliveryPolicyDecision | undefined | Promise<NotificationDeliveryPolicyDecision | undefined>; export type NotificationDeliveryPolicyConfig = { default?: NotificationDeliveryPolicyDecision; priorities?: Partial<Record<NotificationPriority, NotificationDeliveryPolicyDecision>>; sources?: Record<string, NotificationDeliveryPolicyDecision>; decide?: NotificationDeliveryPolicyDecider; }; export declare function defaultNotificationDeliveryDecision(input: NotificationDeliveryPolicyInput): NotificationDeliveryDecision; export declare function resolveNotificationDeliveryDecision({ config, ...input }: NotificationDeliveryPolicyInput & { config?: NotificationDeliveryPolicyConfig; }): Promise<NotificationDeliveryDecision>; //# sourceMappingURL=delivery-policy.d.ts.map