@novu/framework 2.11.2-alpha.0 → 2.11.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{agent.types-DdgaVUb7.d.cts → agent.types-Dqm2VBTO.d.cts} +56 -2
- package/dist/cjs/ai-sdk/index.cjs +1 -1
- package/dist/cjs/ai-sdk/index.d.cts +2 -1
- package/dist/cjs/{health-check.types-CkUmYLNG.d.cts → health-check.types-B9FbzRbm.d.cts} +2 -2
- package/dist/cjs/{index-BCp3U0UG.d.cts → index-1DobCKAF.d.cts} +4 -33
- package/dist/cjs/index.cjs +72 -72
- package/dist/cjs/index.d.cts +4 -4
- package/dist/cjs/internal/index.cjs +1 -1
- package/dist/cjs/internal/index.d.cts +7 -5
- package/dist/cjs/langchain/index.cjs +1 -1
- package/dist/cjs/langchain/index.d.cts +2 -1
- package/dist/cjs/servers/express.cjs +86 -86
- package/dist/cjs/servers/express.d.cts +5 -5
- package/dist/cjs/servers/h3.cjs +93 -93
- package/dist/cjs/servers/h3.d.cts +5 -5
- package/dist/cjs/servers/lambda.cjs +72 -72
- package/dist/cjs/servers/lambda.d.cts +5 -5
- package/dist/cjs/servers/nest.cjs +105 -105
- package/dist/cjs/servers/nest.d.cts +7 -7
- package/dist/cjs/servers/next.cjs +86 -86
- package/dist/cjs/servers/next.d.cts +5 -5
- package/dist/cjs/servers/nuxt.cjs +93 -93
- package/dist/cjs/servers/nuxt.d.cts +5 -5
- package/dist/cjs/servers/remix.cjs +86 -86
- package/dist/cjs/servers/remix.d.cts +5 -5
- package/dist/cjs/servers/sveltekit.cjs +91 -91
- package/dist/cjs/servers/sveltekit.d.cts +5 -5
- package/dist/cjs/step-resolver.cjs +1 -1
- package/dist/cjs/step-resolver.d.cts +2 -2
- package/dist/cjs/{subscriber.types-DxMMRBIi.d.cts → subscriber.types-DubxcL8q.d.cts} +16 -0
- package/dist/cjs/validators.cjs +1 -1
- package/dist/esm/{agent.types-Bu3DhlVb.d.ts → agent.types-E3sxq6xr.d.ts} +56 -2
- package/dist/esm/ai-sdk/index.d.ts +2 -1
- package/dist/esm/ai-sdk/index.js +1 -1
- package/dist/esm/{chunk-DKQLYSZS.js → chunk-22DBAEUX.js} +1 -1
- package/dist/esm/{chunk-QTWEINJ4.js → chunk-CANJPWLT.js} +1 -1
- package/dist/esm/chunk-E2MET7IR.js +1 -0
- package/dist/esm/chunk-Q6BV36LU.js +98 -0
- package/dist/esm/{health-check.types-nDCnGlmX.d.ts → health-check.types-BNocZ4Wk.d.ts} +2 -2
- package/dist/esm/{index-DEehllqa.d.ts → index-aVljLqR4.d.ts} +4 -33
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +7 -5
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/langchain/index.d.ts +2 -1
- package/dist/esm/langchain/index.js +1 -1
- package/dist/esm/servers/express.d.ts +5 -5
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +5 -5
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/lambda.d.ts +5 -5
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +7 -7
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +5 -5
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +5 -5
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +5 -5
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +5 -5
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +2 -2
- package/dist/esm/step-resolver.js +1 -1
- package/dist/esm/{subscriber.types-BbyO_Cz6.d.ts → subscriber.types-CmybpXhA.d.ts} +16 -0
- package/dist/esm/validators.js +1 -1
- package/package.json +2 -2
- package/dist/esm/chunk-KLIOXJR3.js +0 -1
- package/dist/esm/chunk-YF62BBGH.js +0 -98
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { ChatElement, Emoji, CardElement } from 'chat';
|
|
2
2
|
import { A as Awaitable } from './util.types-DaFfsxgy.cjs';
|
|
3
3
|
|
|
4
|
+
type AgentErrorDelivery = {
|
|
5
|
+
statusCode: number;
|
|
6
|
+
responseBody: string;
|
|
7
|
+
};
|
|
8
|
+
type AgentErrorOptions = {
|
|
9
|
+
cause?: unknown;
|
|
10
|
+
delivery?: AgentErrorDelivery;
|
|
11
|
+
};
|
|
12
|
+
/** Turn and handler failures. Delivery failures use {@link AgentDeliveryError}. */
|
|
13
|
+
declare class AgentError extends Error {
|
|
14
|
+
readonly cause?: unknown;
|
|
15
|
+
readonly delivery?: AgentErrorDelivery;
|
|
16
|
+
constructor(message: string, options?: AgentErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thrown by `ctx.reply()` and `handle.edit()` when the upstream message delivery
|
|
20
|
+
* fails — e.g. the configured email provider returns 401, Slack rejects the token,
|
|
21
|
+
* or Teams rejects the request.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { AgentDeliveryError } from '@novu/framework';
|
|
26
|
+
*
|
|
27
|
+
* try {
|
|
28
|
+
* await ctx.reply('Hello!');
|
|
29
|
+
* } catch (err) {
|
|
30
|
+
* if (err instanceof AgentDeliveryError) {
|
|
31
|
+
* console.error('Delivery failed:', err.message, err.statusCode);
|
|
32
|
+
* return;
|
|
33
|
+
* }
|
|
34
|
+
* throw err;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare class AgentDeliveryError extends AgentError {
|
|
39
|
+
readonly statusCode: number;
|
|
40
|
+
readonly responseBody: string;
|
|
41
|
+
constructor(statusCode: number, responseBody: string);
|
|
42
|
+
}
|
|
43
|
+
declare function toAgentError(err: unknown): AgentError;
|
|
44
|
+
|
|
4
45
|
declare enum ChannelTypeEnum {
|
|
5
46
|
IN_APP = "in_app",
|
|
6
47
|
EMAIL = "email",
|
|
@@ -67,7 +108,8 @@ declare enum ChatProviderIdEnum {
|
|
|
67
108
|
RocketChat = "rocket-chat",
|
|
68
109
|
WhatsAppBusiness = "whatsapp-business",
|
|
69
110
|
ChatWebhook = "chat-webhook",
|
|
70
|
-
Telegram = "telegram"
|
|
111
|
+
Telegram = "telegram",
|
|
112
|
+
Sendblue = "sendblue"
|
|
71
113
|
}
|
|
72
114
|
declare enum PushProviderIdEnum {
|
|
73
115
|
FCM = "fcm",
|
|
@@ -647,11 +689,21 @@ interface AgentHandlers {
|
|
|
647
689
|
* Register this handler whenever you call `ctx.toolApproval.request()` in `onMessage`.
|
|
648
690
|
*/
|
|
649
691
|
onToolApproval?: (decision: ToolApprovalDecision, ctx: AgentActionContext) => Awaitable<MessageContent | void>;
|
|
692
|
+
/**
|
|
693
|
+
* Optional turn failure handler. Return `{ suppress: true }` to skip user notification,
|
|
694
|
+
* return message content for a custom user reply, or return nothing to auto-report
|
|
695
|
+
* `{ error: true }` to Novu (generic end-user copy delivered by the API).
|
|
696
|
+
*/
|
|
697
|
+
onError?: (error: AgentError, ctx: AgentMessageContext | AgentActionContext | AgentReactionContext | AgentResolveContext) => Awaitable<AgentErrorResult>;
|
|
650
698
|
/**
|
|
651
699
|
* Customize how approval messages look. Omit to use the built-in Approve/Deny card.
|
|
652
700
|
*/
|
|
653
701
|
toolApproval?: ToolApprovalConfig;
|
|
654
702
|
}
|
|
703
|
+
type AgentErrorSuppress = {
|
|
704
|
+
suppress: true;
|
|
705
|
+
};
|
|
706
|
+
type AgentErrorResult = MessageContent | void | AgentErrorSuppress;
|
|
655
707
|
interface Agent {
|
|
656
708
|
id: string;
|
|
657
709
|
handlers: AgentHandlers;
|
|
@@ -762,6 +814,8 @@ interface AgentReplyPayload {
|
|
|
762
814
|
addReactions?: AddReactionPayload[];
|
|
763
815
|
deleteMessages?: DeleteMessagePayload[];
|
|
764
816
|
typing?: TypingOp;
|
|
817
|
+
/** Bridge reports a real turn failure; Novu delivers generic user copy. */
|
|
818
|
+
error?: true;
|
|
765
819
|
}
|
|
766
820
|
/** Shape returned by /agents/:id/reply when a reply or edit was delivered. */
|
|
767
821
|
interface SentMessageInfo {
|
|
@@ -769,4 +823,4 @@ interface SentMessageInfo {
|
|
|
769
823
|
platformThreadId: string;
|
|
770
824
|
}
|
|
771
825
|
|
|
772
|
-
export { type Agent as A, type
|
|
826
|
+
export { type Agent as A, type ToolApprovalRequestPayload as B, AgentEventEnum as C, type TypingControl as D, type ToolApprovalControl as E, type FileRef as F, type AgentBridgeRequest as G, type AgentReplyPayload as H, type ITriggerPayload as I, type DeleteMessagePayload as J, type EditPayload as K, type MetadataSignal as L, type MessageContent as M, type ReplyContent as N, type Signal as O, type ParsedApprovalAction as P, type TriggerSignal as Q, type ReplyHandle as R, type SentMessageInfo as S, type ToolApprovalCard as T, buildApprovalActionId as U, parseApprovalActionId as V, type WorkflowPreferencesPartial as W, type AgentAction as a, type AgentActionContext as b, type AgentAttachment as c, type AgentContext as d, type AgentConversation as e, AgentDeliveryError as f, AgentError as g, type AgentHandlerContext as h, type AgentHandlers as i, type AgentHistoryEntry as j, type AgentMessage as k, type AgentMessageAuthor as l, type AgentMessageContext as m, type AgentPlatformContext as n, type AgentReaction as o, type AgentReactionContext as p, type AgentResolveContext as q, type AgentSubscriber as r, type AgentToolCall as s, type ToolApprovalConfig as t, type ToolApprovalDecision as u, toAgentError as v, type TriggerRecipientsPayload as w, type ISubscriberPayload as x, TriggerEventStatusEnum as y, type ToolResult as z };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var A=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var o in t)A(e,o,{get:t[o],enumerable:!0})},L=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of h(t))!D.call(e,r)&&r!==o&&A(e,r,{get:()=>t[r],enumerable:!(n=O(t,r))||n.enumerable});return e};var V=e=>L(A({},"__esModule",{value:!0}),e);var ge={};j(ge,{agent:()=>I,toModelMessages:()=>N});module.exports=V(ge);var U=Symbol.for("novu.agent.runtimeContext");function Y(e){return e[U]===!0}function d(e){if(!Y(e))throw new Error("Agent context must be created by Novu dispatch");return e}function v(e){return"type"in e&&e.type==="card"}function R(e){return typeof e=="object"&&e!==null&&e.type==="tool-approval-card"}var $="tool-approval";function g(e,t){return`${$}:${e}:${t}`}async function C(e,t,o,n){var i,u;let r=n!=null?n:t.id,a={approve:g("approve",r),deny:g("deny",r)},s=b=>({type:"tool-approval-card",...b}),l=(u=(i=o==null?void 0:o.renderApproval)==null?void 0:i.call(o,{toolCall:t,actionIds:a,approvalCard:s}))!=null?u:s(),p={approvalId:r,toolCallId:t.id,name:t.name,input:t.input};if(e.emitToolApprovalRequest(p),R(l)){await e.replyApprovalCard(l);return}await e.reply(l)}function G(e){return e.role==="tool"&&Array.isArray(e.content)}function z(e){return typeof e=="object"&&e!==null&&e.type==="tool-result"}function B(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="execution-denied"}function X(e){if(e&&typeof e=="object"&&"type"in e&&"value"in e){let t=e;if(t.type==="json"||t.type==="text")return t.value}return e}async function Q(e){var o;return((o=await Promise.resolve(e.responseMessages))!=null?o:[]).filter(G).flatMap(n=>n.content).filter(z).filter(n=>!B(n.output)).map(n=>({toolCallId:n.toolCallId,toolName:n.toolName,output:X(n.output)}))}function F(e){var o;let t=new Set;for(let n of e.history)n.type==="tool_approval_request"&&((o=n.toolData)!=null&&o.toolCallId)&&t.add(n.toolData.toolCallId);return t}async function T(e,t){var r;let o=await Q(e);if(o.length===0)return;let n=F(t);for(let a of o)n.has(a.toolCallId)&&t.emitToolResult({toolCallId:a.toolCallId,toolName:a.toolName,output:a.output,preview:`Tool "${(r=a.toolName)!=null?r:a.toolCallId}" result`})}function m(e){return typeof e=="object"&&e!==null&&typeof e.consumeStream=="function"}function J(e){return typeof e=="object"&&e!==null&&"text"in e&&"steps"in e&&"usage"in e&&!m(e)}function c(e){return typeof e!="object"||e===null||v(e)?!1:m(e)||J(e)}function K(e){var o;if(typeof e!="object"||e===null||e.type!=="tool-approval-request")return!1;let t=e;return!t.isAutomatic&&typeof((o=t.toolCall)==null?void 0:o.toolCallId)=="string"}async function W(e){let t=await Promise.resolve(e.content);return Array.isArray(t)?t.filter(K):[]}async function f(e,t,o){m(e)&&await e.consumeStream(),await T(e,t);let n=await W(e);if(n.length>0){let r=n[0],a={id:r.toolCall.toolCallId,name:r.toolCall.toolName,input:r.toolCall.input};await C(t,a,o,r.approvalId);return}await Z(e,t)}async function Z(e,t){let o=(await Promise.resolve(e.text)).trim();if(!o){await t.typing.stop();return}await t.reply(o)}var ee={text:"",platformMessageId:"",author:{userId:"",fullName:"",userName:"",isBot:!1},timestamp:""};function te(e){return typeof e=="object"&&e!==null&&"messageId"in e&&"platformThreadId"in e}function oe(e,t){let o=typeof t=="function"?{onMessage:t}:t;if(typeof o.onMessage!="function")throw new Error(`agent('${e}') requires an onMessage handler`);return o}function I(e,t){if(!e)throw new Error("agent() requires a non-empty agentId");let o=oe(e,t),n=o.toolApproval,r=typeof o.onToolApproval=="function",a=async l=>{let p=d(l),i=await o.onMessage(ee,p.asMessageContext());c(i)&&await f(i,p,n)},s={onMessage:async(l,p)=>{let i=await o.onMessage(l,p);if(c(i)){await f(i,d(p),n);return}return i},onToolApproval:async(l,p)=>{let i=d(p);if(o.onToolApproval){let u=await o.onToolApproval(l,p);if(c(u)){await f(u,i,n);return}u!=null&&!te(u)&&await i.reply(u)}await a(p)},...n&&{toolApproval:n},...o.onAction&&{onAction:o.onAction},...o.onReaction&&{onReaction:o.onReaction},...o.onResolve&&{onResolve:o.onResolve}};return{id:e,handlers:s,userOnToolApproval:r}}var ne="tool_approval_request",re="tool_approval_decision",le="tool_result";function x(e){var o;let t=e.toolData;if(!(!t||typeof t.approvalId!="string"||typeof t.toolCallId!="string"))return{approvalId:t.approvalId,toolCallId:t.toolCallId,name:(o=t.toolName)!=null?o:"tool",input:t.input}}function S(e){let t=e.toolData;if(!(!t||typeof t.approvalId!="string"||typeof t.approved!="boolean"))return{approvalId:t.approvalId,approved:t.approved}}function w(e){let t=e.toolData;if(!(!t||typeof t.toolCallId!="string"))return{toolCallId:t.toolCallId,toolName:t.toolName,output:t.output}}function
|
|
1
|
+
"use strict";var A=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var o in t)A(e,o,{get:t[o],enumerable:!0})},L=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of h(t))!D.call(e,r)&&r!==o&&A(e,r,{get:()=>t[r],enumerable:!(n=O(t,r))||n.enumerable});return e};var V=e=>L(A({},"__esModule",{value:!0}),e);var ge={};j(ge,{agent:()=>I,toModelMessages:()=>N});module.exports=V(ge);var U=Symbol.for("novu.agent.runtimeContext");function Y(e){return e[U]===!0}function d(e){if(!Y(e))throw new Error("Agent context must be created by Novu dispatch");return e}function v(e){return"type"in e&&e.type==="card"}function R(e){return typeof e=="object"&&e!==null&&e.type==="tool-approval-card"}var $="tool-approval";function g(e,t){return`${$}:${e}:${t}`}async function C(e,t,o,n){var i,u;let r=n!=null?n:t.id,a={approve:g("approve",r),deny:g("deny",r)},s=b=>({type:"tool-approval-card",...b}),l=(u=(i=o==null?void 0:o.renderApproval)==null?void 0:i.call(o,{toolCall:t,actionIds:a,approvalCard:s}))!=null?u:s(),p={approvalId:r,toolCallId:t.id,name:t.name,input:t.input};if(e.emitToolApprovalRequest(p),R(l)){await e.replyApprovalCard(l);return}await e.reply(l)}function G(e){return e.role==="tool"&&Array.isArray(e.content)}function z(e){return typeof e=="object"&&e!==null&&e.type==="tool-result"}function B(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="execution-denied"}function X(e){if(e&&typeof e=="object"&&"type"in e&&"value"in e){let t=e;if(t.type==="json"||t.type==="text")return t.value}return e}async function Q(e){var o;return((o=await Promise.resolve(e.responseMessages))!=null?o:[]).filter(G).flatMap(n=>n.content).filter(z).filter(n=>!B(n.output)).map(n=>({toolCallId:n.toolCallId,toolName:n.toolName,output:X(n.output)}))}function F(e){var o;let t=new Set;for(let n of e.history)n.type==="tool_approval_request"&&((o=n.toolData)!=null&&o.toolCallId)&&t.add(n.toolData.toolCallId);return t}async function T(e,t){var r;let o=await Q(e);if(o.length===0)return;let n=F(t);for(let a of o)n.has(a.toolCallId)&&t.emitToolResult({toolCallId:a.toolCallId,toolName:a.toolName,output:a.output,preview:`Tool "${(r=a.toolName)!=null?r:a.toolCallId}" result`})}function m(e){return typeof e=="object"&&e!==null&&typeof e.consumeStream=="function"}function J(e){return typeof e=="object"&&e!==null&&"text"in e&&"steps"in e&&"usage"in e&&!m(e)}function c(e){return typeof e!="object"||e===null||v(e)?!1:m(e)||J(e)}function K(e){var o;if(typeof e!="object"||e===null||e.type!=="tool-approval-request")return!1;let t=e;return!t.isAutomatic&&typeof((o=t.toolCall)==null?void 0:o.toolCallId)=="string"}async function W(e){let t=await Promise.resolve(e.content);return Array.isArray(t)?t.filter(K):[]}async function f(e,t,o){m(e)&&await e.consumeStream({onError:r=>{throw r}}),await T(e,t);let n=await W(e);if(n.length>0){let r=n[0],a={id:r.toolCall.toolCallId,name:r.toolCall.toolName,input:r.toolCall.input};await C(t,a,o,r.approvalId);return}await Z(e,t)}async function Z(e,t){let o=(await Promise.resolve(e.text)).trim();if(!o){await t.typing.stop();return}await t.reply(o)}var ee={text:"",platformMessageId:"",author:{userId:"",fullName:"",userName:"",isBot:!1},timestamp:""};function te(e){return typeof e=="object"&&e!==null&&"messageId"in e&&"platformThreadId"in e}function oe(e,t){let o=typeof t=="function"?{onMessage:t}:t;if(typeof o.onMessage!="function")throw new Error(`agent('${e}') requires an onMessage handler`);return o}function I(e,t){if(!e)throw new Error("agent() requires a non-empty agentId");let o=oe(e,t),n=o.toolApproval,r=typeof o.onToolApproval=="function",a=async l=>{let p=d(l),i=await o.onMessage(ee,p.asMessageContext());c(i)&&await f(i,p,n)},s={onMessage:async(l,p)=>{let i=await o.onMessage(l,p);if(c(i)){await f(i,d(p),n);return}return i},onToolApproval:async(l,p)=>{let i=d(p);if(o.onToolApproval){let u=await o.onToolApproval(l,p);if(c(u)){await f(u,i,n);return}u!=null&&!te(u)&&await i.reply(u)}await a(p)},...n&&{toolApproval:n},...o.onAction&&{onAction:o.onAction},...o.onReaction&&{onReaction:o.onReaction},...o.onResolve&&{onResolve:o.onResolve},...o.onError&&{onError:o.onError}};return{id:e,handlers:s,userOnToolApproval:r}}var ne="tool_approval_request",re="tool_approval_decision",le="tool_result";function x(e){var o;let t=e.toolData;if(!(!t||typeof t.approvalId!="string"||typeof t.toolCallId!="string"))return{approvalId:t.approvalId,toolCallId:t.toolCallId,name:(o=t.toolName)!=null?o:"tool",input:t.input}}function S(e){let t=e.toolData;if(!(!t||typeof t.approvalId!="string"||typeof t.approved!="boolean"))return{approvalId:t.approvalId,approved:t.approved}}function w(e){let t=e.toolData;if(!(!t||typeof t.toolCallId!="string"))return{toolCallId:t.toolCallId,toolName:t.toolName,output:t.output}}function E(e){let t=new Set,o=new Map,n=new Map,r=new Set;for(let s of e)if(s.type===ne){let l=x(s);l&&(n.set(l.approvalId,l.toolCallId),r.add(l.toolCallId))}else if(s.type===re){let l=S(s);l&&!l.approved&&t.add(l.approvalId)}else if(s.type===le){let l=w(s);l&&o.set(l.toolCallId,l)}let a=new Set;for(let s of o.keys())r.has(s)&&a.add(s);return{deniedApprovalIds:t,toolResults:o,approvalIdToToolCallId:n,pairedAtRequest:a}}function ae(e,t){return t.deniedApprovalIds.has(e.approvalId)?"denied":t.toolResults.has(e.toolCallId)?"resolved":"in-flight"}function y(e,t){var n;let o=[{type:"tool-call",toolCallId:e.toolCallId,toolName:e.name,input:(n=e.input)!=null?n:{}}];return t&&o.push({type:"tool-approval-request",approvalId:e.approvalId,toolCallId:e.toolCallId}),{role:"assistant",content:o}}function se(e){return{role:"tool",content:[{type:"tool-result",toolCallId:e,toolName:"tool",output:{type:"execution-denied"}}]}}function P(e){var t;return{role:"tool",content:[{type:"tool-result",toolCallId:e.toolCallId,toolName:(t=e.toolName)!=null?t:"tool",output:{type:"json",value:e.output}}]}}function M(e,t){return[y(e,!1),t]}function k(e,t){let o=x(e);if(!o)return[];let n=ae(o,t);switch(n){case"denied":return M(o,se(o.toolCallId));case"resolved":{let r=t.toolResults.get(o.toolCallId);return r?M(o,P(r)):[y(o,!1)]}case"in-flight":return[y(o,!0)];default:return n}}function q(e,t){let o=S(e);if(!o||!o.approved)return;let n=t.approvalIdToToolCallId.get(o.approvalId);if(!(n&&t.toolResults.has(n)))return{role:"tool",content:[{type:"tool-approval-response",approvalId:o.approvalId,approved:!0}]}}function H(e,t){let o=w(e);if(o&&!t.pairedAtRequest.has(o.toolCallId))return P(o)}var ie="message",pe="tool_approval_request",ue="tool_approval_decision",de="tool_result";function _(e){return e==="agent"||e==="assistant"}function ce(e){let t=new Set;for(let o of e)!_(o.role)&&o.role!=="system"&&o.senderName&&t.add(o.senderName);return t.size}function fe(e,t){if(!e.content.trim())return;let o=_(e.role),n=!o&&t&&e.senderName?`${e.senderName}: ${e.content}`:e.content;return{role:o?"assistant":"user",content:n}}function Ae(e,t,o){switch(e.type){case ie:{let n=fe(e,t);return n?[n]:[]}case pe:return k(e,o);case ue:{let n=q(e,o);return n?[n]:[]}case de:{let n=H(e,o);return n?[n]:[]}default:return[]}}function N(e){let t=ce(e)>1,o=E(e);return e.flatMap(n=>Ae(n,t,o))}0&&(module.exports={agent,toModelMessages});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as AgentHandlers, k as AgentMessage, m as AgentMessageContext, M as MessageContent, u as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent, j as AgentHistoryEntry } from '../agent.types-Dqm2VBTO.cjs';
|
|
2
2
|
import { streamText, generateText, ModelMessage } from 'ai';
|
|
3
3
|
import { A as Awaitable } from '../util.types-DaFfsxgy.cjs';
|
|
4
4
|
import 'chat';
|
|
@@ -19,6 +19,7 @@ type AiSdkAgentHandlers = Omit<AgentHandlers, 'onMessage' | 'onToolApproval'> &
|
|
|
19
19
|
* `AiSdkResult` to drive the resume yourself.
|
|
20
20
|
*/
|
|
21
21
|
onToolApproval?: (decision: ToolApprovalDecision, ctx: AgentActionContext) => Awaitable<MessageContent | AiSdkResult | ReplyHandle | void>;
|
|
22
|
+
onError?: AgentHandlers['onError'];
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
type AiSdkMessageHandler = AiSdkAgentHandlers['onMessage'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-
|
|
2
|
-
import { I as ITriggerPayload,
|
|
1
|
+
import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-DubxcL8q.cjs';
|
|
2
|
+
import { I as ITriggerPayload, w as TriggerRecipientsPayload, x as ISubscriberPayload, y as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-Dqm2VBTO.cjs';
|
|
3
3
|
import { C as ConditionalPartial, P as PickRequiredKeys, a as Prettify, D as DeepPartial, A as Awaitable } from './util.types-DaFfsxgy.cjs';
|
|
4
4
|
import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.cjs';
|
|
5
5
|
|
|
@@ -1,39 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { L as Logger, C as ClientOptions, W as Workflow, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-
|
|
1
|
+
import { i as AgentHandlers, A as Agent } from './agent.types-Dqm2VBTO.cjs';
|
|
2
|
+
import { L as Logger, C as ClientOptions, W as Workflow, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-B9FbzRbm.cjs';
|
|
3
3
|
import { A as Awaitable } from './util.types-DaFfsxgy.cjs';
|
|
4
4
|
import 'chat';
|
|
5
5
|
import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.cjs';
|
|
6
6
|
import './step-resolver.cjs';
|
|
7
|
-
import './subscriber.types-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Thrown by `ctx.reply()` and `handle.edit()` when the upstream message delivery
|
|
11
|
-
* fails — e.g. the configured email provider returns 401, Slack rejects the token,
|
|
12
|
-
* or Teams rejects the request.
|
|
13
|
-
*
|
|
14
|
-
* `message` is always a short, human-readable summary.
|
|
15
|
-
* `responseBody` preserves the raw upstream body for debugging.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* import { AgentDeliveryError } from '@novu/framework';
|
|
20
|
-
*
|
|
21
|
-
* try {
|
|
22
|
-
* await ctx.reply('Hello!');
|
|
23
|
-
* } catch (err) {
|
|
24
|
-
* if (err instanceof AgentDeliveryError) {
|
|
25
|
-
* console.error('Delivery failed:', err.message);
|
|
26
|
-
* return;
|
|
27
|
-
* }
|
|
28
|
-
* throw err;
|
|
29
|
-
* }
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
declare class AgentDeliveryError extends Error {
|
|
33
|
-
readonly statusCode: number;
|
|
34
|
-
readonly responseBody: string;
|
|
35
|
-
constructor(statusCode: number, responseBody: string);
|
|
36
|
-
}
|
|
7
|
+
import './subscriber.types-DubxcL8q.cjs';
|
|
37
8
|
|
|
38
9
|
/**
|
|
39
10
|
* Define a new conversational agent.
|
|
@@ -186,4 +157,4 @@ declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
|
186
157
|
*/
|
|
187
158
|
declare function workflow<T_PayloadSchema extends Schema, T_ControlSchema extends Schema, T_EnvSchema extends Schema, T_PayloadValidated extends Record<string, unknown> = FromSchema<T_PayloadSchema>, T_PayloadUnvalidated extends Record<string, unknown> = FromSchemaUnvalidated<T_PayloadSchema>, T_Controls extends Record<string, unknown> = FromSchema<T_ControlSchema>, T_Env extends Record<string, unknown> = FromSchema<T_EnvSchema>>(workflowId: string, execute: Execute<T_PayloadValidated, T_Controls, T_Env>, workflowOptions?: WorkflowOptions<T_PayloadSchema, T_ControlSchema, T_EnvSchema>): Workflow<T_PayloadUnvalidated>;
|
|
188
159
|
|
|
189
|
-
export {
|
|
160
|
+
export { Client as C, type INovuRequestHandlerOptions as I, NovuRequestHandler as N, type ServeHandlerOptions as S, agent as a, workflow as w };
|