import { k as AgentHandlers, n as AgentMessage, p as AgentMessageContext, M as MessageContent, D as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent, l as AgentHistoryEntry, j as AgentHandlerContext } from '../agent.types-DFLG1_vb.js'; import { streamText, generateText, ModelMessage } from 'ai'; import { A as Awaitable } from '../util.types-DaFfsxgy.js'; import 'chat'; type AiSdkStreamResult = Awaited>; type AiSdkGenerateResult = Awaited>; type AiSdkResult = AiSdkStreamResult | AiSdkGenerateResult; /** * Handlers for `@novu/framework/ai-sdk` agents. * * Extends {@link AgentHandlers}: same events and config (`toolApproval`, etc.), * but `onMessage` and `onToolApproval` may return an AI SDK result for automatic delivery. */ type AiSdkAgentHandlers = Omit & { onMessage: (message: AgentMessage, ctx: AgentMessageContext) => Awaitable; /** * Optional. Auto-resumes `onMessage` after approve/deny unless you return an * `AiSdkResult` to drive the resume yourself. */ onToolApproval?: (decision: ToolApprovalDecision, ctx: AgentActionContext) => Awaitable; onError?: AgentHandlers['onError']; }; type AiSdkMessageHandler = AiSdkAgentHandlers['onMessage']; declare function agent(id: string, handlers: AiSdkMessageHandler | AiSdkAgentHandlers): Agent; /** * Convert conversation context into AI SDK `ModelMessage[]` for `streamText` / `generateText`. * * Pass `ctx` to prepend `ctx.notification` as an assistant row. Pass `ctx.history` to skip that * injection (e.g. after `isFromWorkflow`). History already includes the current inbound message. * * For http/localhost attachment URLs (e.g. LocalStack), wrap the result in * `hydrateUnreachableAttachmentUrls` before passing it to `generateText`. * * Pass the system prompt via the top-level `instructions` option of `streamText` / * `generateText`. AI SDK 7 rejects `system` messages inside the `messages` array by default, * so this helper never injects one. */ declare function toModelMessages(history: AgentHistoryEntry[]): ModelMessage[]; declare function toModelMessages(ctx: Pick): ModelMessage[]; /** * Replace attachment URLs a hosted model cannot fetch with inline bytes. * HTTPS public URLs are left as-is so production signed S3 links stay URL-based. * Over-budget downloads are omitted so one large file cannot abort the turn. */ declare function hydrateUnreachableAttachmentUrls(messages: ModelMessage[]): Promise; export { type AiSdkAgentHandlers, agent, hydrateUnreachableAttachmentUrls, toModelMessages };