@novu/framework 2.13.1-rc.72c80d5b17 → 2.13.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/README.md +2 -2
- package/dist/cjs/{agent.types-B5VnP69G.d.cts → agent.types-crcJBtCy.d.cts} +154 -3
- package/dist/cjs/ai-sdk/index.cjs +4 -1
- package/dist/cjs/ai-sdk/index.d.cts +16 -5
- package/dist/cjs/cards.cjs +28 -28
- package/dist/cjs/cards.d.cts +1 -1
- package/dist/cjs/{health-check.types-CtWQ_YSy.d.cts → health-check.types-C2XZ-Tpt.d.cts} +70 -65
- package/dist/cjs/{index-vgb88C84.d.cts → index-DVSB455a.d.cts} +18 -6
- package/dist/cjs/index.cjs +111 -111
- package/dist/cjs/index.d.cts +5 -5
- package/dist/cjs/internal/index.cjs +42 -39
- package/dist/cjs/internal/index.d.cts +324 -27
- package/dist/cjs/langchain/index.cjs +4 -1
- package/dist/cjs/langchain/index.d.cts +24 -6
- package/dist/cjs/servers/express.cjs +109 -109
- package/dist/cjs/servers/express.d.cts +6 -6
- package/dist/cjs/servers/h3.cjs +110 -110
- package/dist/cjs/servers/h3.d.cts +6 -6
- package/dist/cjs/servers/hono.cjs +109 -109
- package/dist/cjs/servers/hono.d.cts +6 -6
- package/dist/cjs/servers/lambda.cjs +109 -109
- package/dist/cjs/servers/lambda.d.cts +6 -6
- package/dist/cjs/servers/nest.cjs +120 -120
- package/dist/cjs/servers/nest.d.cts +8 -8
- package/dist/cjs/servers/next.cjs +109 -109
- package/dist/cjs/servers/next.d.cts +6 -6
- package/dist/cjs/servers/nuxt.cjs +110 -110
- package/dist/cjs/servers/nuxt.d.cts +6 -6
- package/dist/cjs/servers/remix.cjs +109 -109
- package/dist/cjs/servers/remix.d.cts +6 -6
- package/dist/cjs/servers/sveltekit.cjs +109 -109
- package/dist/cjs/servers/sveltekit.d.cts +6 -6
- package/dist/cjs/step-resolver.cjs +4 -4
- package/dist/cjs/step-resolver.d.cts +3 -2
- package/dist/cjs/{subscriber.types-CyNKT0nZ.d.cts → subscriber.types-BanvmGul.d.cts} +680 -27
- package/dist/esm/{agent.types-HUDhyXrV.d.ts → agent.types-DFLG1_vb.d.ts} +154 -3
- package/dist/esm/ai-sdk/index.d.ts +16 -5
- package/dist/esm/ai-sdk/index.js +1 -1
- package/dist/esm/cards.d.ts +1 -1
- package/dist/esm/cards.js +1 -1
- package/dist/esm/chunk-4ETX7FIT.js +1 -0
- package/dist/esm/{chunk-SPS3KBKF.js → chunk-IREH6K2M.js} +4 -4
- package/dist/esm/chunk-PBC7WR2R.js +98 -0
- package/dist/esm/chunk-PU74XQ2P.js +1 -0
- package/dist/esm/chunk-QZ6TSYCK.js +4 -0
- package/dist/esm/chunk-YZ3P3MMZ.js +1 -0
- package/dist/esm/{health-check.types-0Rv-l8yD.d.ts → health-check.types-DORn4djx.d.ts} +70 -65
- package/dist/esm/{index-C0oUWDlb.d.ts → index-BvRGmHFw.d.ts} +18 -6
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +317 -20
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/langchain/index.d.ts +24 -6
- package/dist/esm/langchain/index.js +1 -1
- package/dist/esm/servers/express.d.ts +6 -6
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +6 -6
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/hono.d.ts +6 -6
- package/dist/esm/servers/hono.js +1 -1
- package/dist/esm/servers/lambda.d.ts +6 -6
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +8 -8
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +6 -6
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +6 -6
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +6 -6
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +6 -6
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +3 -2
- package/dist/esm/step-resolver.js +1 -1
- package/dist/esm/{subscriber.types-g7VnI_ZQ.d.ts → subscriber.types-Drf26WPA.d.ts} +680 -27
- package/package.json +3 -2
- package/dist/esm/chunk-CGZ5P44A.js +0 -98
- package/dist/esm/chunk-FMKD6TON.js +0 -1
- package/dist/esm/chunk-W6DIBD4Z.js +0 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { C as Client, N as NovuRequestHandler, S as ServeHandlerOptions, a as agent, w as workflow } from './index-
|
|
2
|
-
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-
|
|
3
|
-
export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
|
|
4
|
-
export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentContextPayload, f as AgentContextValue, g as AgentConversation, h as AgentDeliveryError, i as AgentError, j as AgentHandlerContext, k as AgentHandlers, l as AgentHistoryEntry, m as
|
|
1
|
+
export { C as Client, N as NovuRequestHandler, S as ServeHandlerOptions, a as agent, i as isFromWorkflow, w as workflow } from './index-BvRGmHFw.js';
|
|
2
|
+
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-DORn4djx.js';
|
|
3
|
+
export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Image, ImageElement, Select, SelectOption, TextInput } from 'chat';
|
|
4
|
+
export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentContextPayload, f as AgentContextValue, g as AgentConversation, h as AgentDeliveryError, i as AgentError, j as AgentHandlerContext, k as AgentHandlers, l as AgentHistoryEntry, m as AgentHumanResponse, n as AgentMessage, o as AgentMessageAuthor, p as AgentMessageContext, q as AgentNotification, r as AgentPlatformContext, s as AgentReaction, t as AgentReactionContext, u as AgentResolveContext, v as AgentSubscriber, w as AgentSubscriberAccess, x as AgentToolCall, F as FileRef, H as HumanAskApproveOptions, y as HumanChooseOptions, z as HumanInteractionKind, B as HumanTellOptions, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, C as ToolApprovalConfig, D as ToolApprovalDecision, E as toAgentError } from './agent.types-DFLG1_vb.js';
|
|
5
5
|
export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, ToolStepResolver, step } from './step-resolver.js';
|
|
6
|
-
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from './subscriber.types-
|
|
6
|
+
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from './subscriber.types-Drf26WPA.js';
|
|
7
7
|
import './util.types-DaFfsxgy.js';
|
|
8
8
|
import './base.schema.types-BApIn9jr.js';
|
|
9
9
|
import 'json-schema-to-ts';
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as m,c as q,d as r,e as u}from"./chunk-PBC7WR2R.js";import{a as v}from"./chunk-YLCLZVYS.js";import"./chunk-XIVU4VDS.js";import{N as n,O as o,P as p,W as t}from"./chunk-4ETX7FIT.js";import{a,b,c,d,e,f,i as g,p as h,q as i,r as j}from"./chunk-X5AZIKIR.js";import"./chunk-RBTQQ5IZ.js";import{a as s}from"./chunk-IREH6K2M.js";import{f as k}from"./chunk-VY27ZAO7.js";import{b as l}from"./chunk-PU74XQ2P.js";import"./chunk-FHYMHX3T.js";export{a as Actions,o as AgentDeliveryError,n as AgentError,b as Button,c as Card,d as CardLink,e as CardText,m as Client,k as CronExpression,f as Divider,g as Image,q as NovuRequestHandler,h as Select,i as SelectOption,t as SeverityLevelEnum,j as TextInput,r as agent,l as isFromWorkflow,s as providerSchemas,v as step,p as toAgentError,u as workflow};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { P as PostActionEnum } from '../health-check.types-
|
|
2
|
-
export { b as CancelEventTriggerResponse, c as ChannelPreference, C as ClientOptions, d as CodeResult, a as CronExpression, D as DiscoverAgentOutput, e as DiscoverOutput, f as DiscoverProviderOutput, g as DiscoverStepOutput, h as DiscoverWorkflowOutput, i as Event, j as EventTriggerParams, k as EventTriggerResponse, l as EventTriggerResult, m as Execute, E as ExecuteInput, n as ExecuteOutput, o as ExecuteOutputMetadata, p as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, L as Logger, S as SeverityLevelEnum, q as State, r as StepType, W as Workflow, s as WorkflowChannelEnum, t as WorkflowOptions, u as WorkflowPreference, v as WorkflowPreferences } from '../health-check.types-
|
|
3
|
-
export { e as ActionStep, A as ActionStepEnum, f as ChannelStep, c as ChannelStepEnum, g as ChatOutput, h as ChatOutputUnvalidated, i as ChatResult, a as ContextPayload, C as ContextResolved, j as ContextValue, k as CustomStep, D as DelayDynamicOutput, l as DelayDynamicOutputUnvalidated, m as DelayOutput, n as DelayOutputUnvalidated, o as DelayRegularOutput, q as DelayRegularOutputUnvalidated, r as DelayResult, s as DelayTimedOutput, t as DelayTimedOutputUnvalidated, u as DigestOutput, v as DigestOutputUnvalidated, w as DigestRegularOutput, x as DigestRegularOutputUnvalidated, y as DigestResult, z as DigestTimedOutput, B as DigestTimedOutputUnvalidated, F as EmailOutput, G as EmailOutputUnvalidated, H as EmailResult, E as EnvironmentSystemVariables, I as InAppOutput, J as InAppOutputUnvalidated, K as InAppResult, L as JobStatusEnum, P as PushOutput, M as PushOutputUnvalidated, N as PushResult, O as Skip, Q as SmsOutput, R as SmsOutputUnvalidated, T as SmsResult, b as Step, U as StepContext, d as StepOptions, V as StepOutput, S as Subscriber, X as ThrottleOutput, Y as ThrottleOutputUnvalidated, Z as ThrottleResult, _ as ToolOutput, $ as ToolOutputUnvalidated, a0 as actionStepSchemas, a1 as channelStepSchemas } from '../subscriber.types-
|
|
1
|
+
import { P as PostActionEnum } from '../health-check.types-DORn4djx.js';
|
|
2
|
+
export { b as CancelEventTriggerResponse, c as ChannelPreference, C as ClientOptions, d as CodeResult, a as CronExpression, D as DiscoverAgentOutput, e as DiscoverOutput, f as DiscoverProviderOutput, g as DiscoverStepOutput, h as DiscoverWorkflowOutput, i as Event, j as EventTriggerParams, k as EventTriggerResponse, l as EventTriggerResult, m as Execute, E as ExecuteInput, n as ExecuteOutput, o as ExecuteOutputMetadata, p as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, L as Logger, S as SeverityLevelEnum, q as State, r as StepType, W as Workflow, s as WorkflowChannelEnum, t as WorkflowOptions, u as WorkflowPreference, v as WorkflowPreferences } from '../health-check.types-DORn4djx.js';
|
|
3
|
+
export { e as ActionStep, A as ActionStepEnum, f as ChannelStep, c as ChannelStepEnum, g as ChatOutput, h as ChatOutputUnvalidated, i as ChatResult, a as ContextPayload, C as ContextResolved, j as ContextValue, k as CustomStep, D as DelayDynamicOutput, l as DelayDynamicOutputUnvalidated, m as DelayOutput, n as DelayOutputUnvalidated, o as DelayRegularOutput, q as DelayRegularOutputUnvalidated, r as DelayResult, s as DelayTimedOutput, t as DelayTimedOutputUnvalidated, u as DigestOutput, v as DigestOutputUnvalidated, w as DigestRegularOutput, x as DigestRegularOutputUnvalidated, y as DigestResult, z as DigestTimedOutput, B as DigestTimedOutputUnvalidated, F as EmailOutput, G as EmailOutputUnvalidated, H as EmailResult, E as EnvironmentSystemVariables, I as InAppOutput, J as InAppOutputUnvalidated, K as InAppResult, L as JobStatusEnum, P as PushOutput, M as PushOutputUnvalidated, N as PushResult, O as Skip, Q as SmsOutput, R as SmsOutputUnvalidated, T as SmsResult, b as Step, U as StepContext, d as StepOptions, V as StepOutput, S as Subscriber, X as ThrottleOutput, Y as ThrottleOutputUnvalidated, Z as ThrottleResult, _ as ToolOutput, $ as ToolOutputUnvalidated, a0 as actionStepSchemas, a1 as channelStepSchemas } from '../subscriber.types-Drf26WPA.js';
|
|
4
4
|
import { Filter, LiquidOptions, Liquid } from 'liquidjs';
|
|
5
5
|
import { Emoji } from 'chat';
|
|
6
|
-
import { j as AgentHandlerContext,
|
|
7
|
-
export {
|
|
6
|
+
import { j as AgentHandlerContext, L as ToolResult, N as ToolApprovalRequestPayload, T as ToolApprovalCard, R as ReplyHandle, p as AgentMessageContext, O as AgentEventEnum, a as AgentAction, n as AgentMessage, s as AgentReaction, g as AgentConversation, v as AgentSubscriber, e as AgentContextPayload, q as AgentNotification, l as AgentHistoryEntry, r as AgentPlatformContext, m as AgentHumanResponse, P as TypingControl, Q as ToolApprovalControl, S as AgentBridgeRequest, C as ToolApprovalConfig, M as MessageContent, F as FileRef, U as ReplyContent, V as Signal, X as AddReactionPayload, Y as DeleteMessagePayload, Z as SentMessageInfo, _ as TypingOp, G as TriggerRecipientsPayload, H as HumanAskApproveOptions, y as HumanChooseOptions, B as HumanTellOptions } from '../agent.types-DFLG1_vb.js';
|
|
7
|
+
export { $ as AgentReplyPayload, a0 as EditPayload, a1 as HumanSignal, a2 as MetadataSignal, a3 as ParsedApprovalAction, a4 as TriggerSignal, a5 as buildApprovalActionId, a6 as parseApprovalActionId } from '../agent.types-DFLG1_vb.js';
|
|
8
8
|
export { a as FromSchema, F as FromSchemaUnvalidated, J as JsonSchema, S as Schema, Z as ZodSchema, b as ZodSchemaMinimal } from '../base.schema.types-BApIn9jr.js';
|
|
9
9
|
export { S as SupportedFrameworkName } from '../server.types-Cc6o5eYH.js';
|
|
10
10
|
export { A as Awaitable, C as ConditionalPartial, D as DeepPartial, b as DeepRequired, E as Either, I as Indexable, c as PickOptional, d as PickOptionalKeys, e as PickRequired, P as PickRequiredKeys, a as Prettify } from '../util.types-DaFfsxgy.js';
|
|
@@ -137,6 +137,257 @@ declare enum ResourceEnum {
|
|
|
137
137
|
STEP = "step"
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
type AgentMessageRole = 'user' | 'assistant';
|
|
141
|
+
type AgentToolSource = {
|
|
142
|
+
type: 'builtin';
|
|
143
|
+
} | {
|
|
144
|
+
type: 'custom';
|
|
145
|
+
} | {
|
|
146
|
+
type: 'mcp';
|
|
147
|
+
serverName: string;
|
|
148
|
+
};
|
|
149
|
+
type AgentToolResultContent = {
|
|
150
|
+
type: 'text';
|
|
151
|
+
text: string;
|
|
152
|
+
} | {
|
|
153
|
+
type: 'citation';
|
|
154
|
+
url: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
excerpts?: string[];
|
|
157
|
+
} | {
|
|
158
|
+
type: 'json';
|
|
159
|
+
value: unknown;
|
|
160
|
+
} | {
|
|
161
|
+
type: 'media';
|
|
162
|
+
mediaType: string;
|
|
163
|
+
data: string;
|
|
164
|
+
name?: string;
|
|
165
|
+
} | {
|
|
166
|
+
type: 'unknown';
|
|
167
|
+
providerType: string;
|
|
168
|
+
data: Record<string, unknown>;
|
|
169
|
+
};
|
|
170
|
+
type AgentMessageContent = {
|
|
171
|
+
markdown: string;
|
|
172
|
+
} | {
|
|
173
|
+
card: Record<string, unknown>;
|
|
174
|
+
};
|
|
175
|
+
interface AgentFileRef {
|
|
176
|
+
fileId: string;
|
|
177
|
+
name?: string;
|
|
178
|
+
mediaType?: string;
|
|
179
|
+
/** Transitional: inline base64 payload until the pre-upload path ships. Same 5 MB limit as the reply API. */
|
|
180
|
+
data?: string;
|
|
181
|
+
/** Transitional: publicly-accessible URL until the pre-upload path ships. Same limits as the reply API. */
|
|
182
|
+
url?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare const AGENT_EVENT_PROTOCOL_VERSION: 1;
|
|
186
|
+
interface AgentEventUsage {
|
|
187
|
+
inputTokens?: number;
|
|
188
|
+
outputTokens?: number;
|
|
189
|
+
totalTokens?: number;
|
|
190
|
+
}
|
|
191
|
+
type AgentRunOutcome = 'completed' | 'paused' | 'aborted';
|
|
192
|
+
type AgentFinishReason = 'stop' | 'length' | 'refused' | 'other';
|
|
193
|
+
interface AgentApprovalRequest {
|
|
194
|
+
approvalId: string;
|
|
195
|
+
toolUseId: string;
|
|
196
|
+
toolName: string;
|
|
197
|
+
input?: Record<string, unknown>;
|
|
198
|
+
source?: AgentToolSource;
|
|
199
|
+
/**
|
|
200
|
+
* Server-minted platform action ids for headless / card UIs to echo back.
|
|
201
|
+
* Clients must not invent these — grammars differ across runtimes.
|
|
202
|
+
*/
|
|
203
|
+
approveActionId?: string;
|
|
204
|
+
denyActionId?: string;
|
|
205
|
+
/** Server-minted always-allow-this-tool action id. Echo via respondToAction / card click. */
|
|
206
|
+
trustToolActionId?: string;
|
|
207
|
+
/** Server-minted always-allow-MCP-server action id (MCP tools only). */
|
|
208
|
+
trustServerActionId?: string;
|
|
209
|
+
}
|
|
210
|
+
type AgentSignal = {
|
|
211
|
+
type: 'metadata';
|
|
212
|
+
action: 'set';
|
|
213
|
+
key: string;
|
|
214
|
+
value: unknown;
|
|
215
|
+
} | {
|
|
216
|
+
type: 'metadata';
|
|
217
|
+
action: 'delete';
|
|
218
|
+
key: string;
|
|
219
|
+
} | {
|
|
220
|
+
type: 'metadata';
|
|
221
|
+
action: 'clear';
|
|
222
|
+
} | {
|
|
223
|
+
type: 'trigger';
|
|
224
|
+
workflowId: string;
|
|
225
|
+
to?: unknown;
|
|
226
|
+
payload?: Record<string, unknown>;
|
|
227
|
+
} | {
|
|
228
|
+
type: 'human';
|
|
229
|
+
kind: 'ask' | 'approve' | 'choose' | 'tell';
|
|
230
|
+
prompt: string;
|
|
231
|
+
requestId: string;
|
|
232
|
+
options?: string[];
|
|
233
|
+
from?: string;
|
|
234
|
+
ttlSeconds?: number;
|
|
235
|
+
to?: string | string[];
|
|
236
|
+
};
|
|
237
|
+
type AgentEvent = {
|
|
238
|
+
type: 'run-start';
|
|
239
|
+
} | {
|
|
240
|
+
type: 'run-finish';
|
|
241
|
+
outcome: AgentRunOutcome;
|
|
242
|
+
finishReason?: AgentFinishReason;
|
|
243
|
+
usage?: AgentEventUsage;
|
|
244
|
+
approvals?: AgentApprovalRequest[];
|
|
245
|
+
} | {
|
|
246
|
+
type: 'run-error';
|
|
247
|
+
message: string;
|
|
248
|
+
code?: string;
|
|
249
|
+
} | {
|
|
250
|
+
type: 'step-start';
|
|
251
|
+
name?: string;
|
|
252
|
+
index?: number;
|
|
253
|
+
} | {
|
|
254
|
+
type: 'step-end';
|
|
255
|
+
name?: string;
|
|
256
|
+
index?: number;
|
|
257
|
+
usage?: AgentEventUsage;
|
|
258
|
+
} | {
|
|
259
|
+
type: 'message';
|
|
260
|
+
messageId: string;
|
|
261
|
+
/** Who authored this durable message. Streaming events stay assistant-only and omit role. */
|
|
262
|
+
role: AgentMessageRole;
|
|
263
|
+
content: AgentMessageContent;
|
|
264
|
+
files?: AgentFileRef[];
|
|
265
|
+
} | {
|
|
266
|
+
type: 'message-start';
|
|
267
|
+
messageId: string;
|
|
268
|
+
} | {
|
|
269
|
+
type: 'message-delta';
|
|
270
|
+
messageId: string;
|
|
271
|
+
delta: string;
|
|
272
|
+
} | {
|
|
273
|
+
type: 'message-end';
|
|
274
|
+
messageId: string;
|
|
275
|
+
content?: AgentMessageContent;
|
|
276
|
+
files?: AgentFileRef[];
|
|
277
|
+
} | {
|
|
278
|
+
type: 'thinking-start';
|
|
279
|
+
thinkingId: string;
|
|
280
|
+
} | {
|
|
281
|
+
type: 'thinking-delta';
|
|
282
|
+
thinkingId: string;
|
|
283
|
+
delta: string;
|
|
284
|
+
} | {
|
|
285
|
+
type: 'thinking-end';
|
|
286
|
+
thinkingId: string;
|
|
287
|
+
} | {
|
|
288
|
+
type: 'source';
|
|
289
|
+
messageId: string;
|
|
290
|
+
sourceType: 'url' | 'document';
|
|
291
|
+
url?: string;
|
|
292
|
+
title?: string;
|
|
293
|
+
filename?: string;
|
|
294
|
+
} | {
|
|
295
|
+
type: 'tool-use-start';
|
|
296
|
+
toolUseId: string;
|
|
297
|
+
toolName: string;
|
|
298
|
+
source?: AgentToolSource;
|
|
299
|
+
} | {
|
|
300
|
+
type: 'tool-use-delta';
|
|
301
|
+
toolUseId: string;
|
|
302
|
+
delta: string;
|
|
303
|
+
} | {
|
|
304
|
+
type: 'tool-use-done';
|
|
305
|
+
toolUseId: string;
|
|
306
|
+
toolName: string;
|
|
307
|
+
input?: Record<string, unknown>;
|
|
308
|
+
source?: AgentToolSource;
|
|
309
|
+
} | {
|
|
310
|
+
type: 'tool-use-result';
|
|
311
|
+
toolUseId: string;
|
|
312
|
+
content: AgentToolResultContent[];
|
|
313
|
+
isError?: boolean;
|
|
314
|
+
} | ({
|
|
315
|
+
type: 'tool-approval-request';
|
|
316
|
+
/** Stable assistant message id used to preserve the approval's timeline position during history replay. */
|
|
317
|
+
messageId?: string;
|
|
318
|
+
/** When true, no companion message carries the approval UI. The consumer should render its default approval card. */
|
|
319
|
+
deliverCard?: boolean;
|
|
320
|
+
} & AgentApprovalRequest) | {
|
|
321
|
+
type: 'tool-approval-response';
|
|
322
|
+
approvalId: string;
|
|
323
|
+
decision: 'approved' | 'denied';
|
|
324
|
+
reason?: string;
|
|
325
|
+
automatic?: boolean;
|
|
326
|
+
} | {
|
|
327
|
+
type: 'mcp-connection-request';
|
|
328
|
+
actionId: string;
|
|
329
|
+
mcpId: string;
|
|
330
|
+
displayName: string;
|
|
331
|
+
authorizeUrl: string;
|
|
332
|
+
authorizeUrlWithAutoApprove?: string;
|
|
333
|
+
} | {
|
|
334
|
+
type: 'mcp-connection-result';
|
|
335
|
+
actionId: string;
|
|
336
|
+
mcpId: string;
|
|
337
|
+
status: 'connected' | 'failed';
|
|
338
|
+
message?: string;
|
|
339
|
+
} | {
|
|
340
|
+
type: 'resolve';
|
|
341
|
+
summary?: string;
|
|
342
|
+
} | {
|
|
343
|
+
type: 'signal';
|
|
344
|
+
signal: AgentSignal;
|
|
345
|
+
} | {
|
|
346
|
+
type: 'channel.typing';
|
|
347
|
+
state: 'on' | 'off';
|
|
348
|
+
status?: string;
|
|
349
|
+
} | {
|
|
350
|
+
type: 'channel.edit';
|
|
351
|
+
messageId: string;
|
|
352
|
+
content: AgentMessageContent;
|
|
353
|
+
files?: AgentFileRef[];
|
|
354
|
+
} | {
|
|
355
|
+
type: 'channel.delete';
|
|
356
|
+
messageId: string;
|
|
357
|
+
} | {
|
|
358
|
+
type: 'channel.reaction';
|
|
359
|
+
messageId: string;
|
|
360
|
+
emoji: string;
|
|
361
|
+
op: 'add' | 'remove';
|
|
362
|
+
} | {
|
|
363
|
+
type: 'connection.error';
|
|
364
|
+
source: 'mcp';
|
|
365
|
+
serverName: string;
|
|
366
|
+
reason: 'authentication' | 'connection';
|
|
367
|
+
message: string;
|
|
368
|
+
} | {
|
|
369
|
+
type: 'provider-event';
|
|
370
|
+
provider: string;
|
|
371
|
+
event: string;
|
|
372
|
+
data: unknown;
|
|
373
|
+
} | {
|
|
374
|
+
type: 'custom';
|
|
375
|
+
name: string;
|
|
376
|
+
data: unknown;
|
|
377
|
+
};
|
|
378
|
+
interface AgentEventEnvelope {
|
|
379
|
+
version: typeof AGENT_EVENT_PROTOCOL_VERSION;
|
|
380
|
+
conversationId: string;
|
|
381
|
+
/** Public `conv_*` identifier. Clients receive only this id, never `conversationId`. */
|
|
382
|
+
conversationIdentifier?: string;
|
|
383
|
+
agentId: string;
|
|
384
|
+
runId: string;
|
|
385
|
+
turnId: string;
|
|
386
|
+
sequence: number;
|
|
387
|
+
timestamp: string;
|
|
388
|
+
event: AgentEvent;
|
|
389
|
+
}
|
|
390
|
+
|
|
140
391
|
/**
|
|
141
392
|
* Check if the object is a native error.
|
|
142
393
|
*
|
|
@@ -431,18 +682,46 @@ interface AgentRuntimeContext extends AgentHandlerContext {
|
|
|
431
682
|
asMessageContext(): AgentMessageContext;
|
|
432
683
|
}
|
|
433
684
|
|
|
434
|
-
|
|
435
|
-
|
|
685
|
+
/** Pending side effects queued between replies, drained atomically before each turn action. */
|
|
686
|
+
interface SideEffectsSnapshot {
|
|
687
|
+
toolApprovalRequest: ToolApprovalRequestPayload | null;
|
|
688
|
+
signals: Signal[];
|
|
689
|
+
toolResults: ToolResult[];
|
|
690
|
+
addReactions: AddReactionPayload[];
|
|
691
|
+
deleteMessages: DeleteMessagePayload[];
|
|
692
|
+
resolve: {
|
|
693
|
+
summary?: string;
|
|
694
|
+
} | null;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* A turn's delivery mechanism. Legacy bridges POST a single `AgentReplyPayload` per action;
|
|
698
|
+
* SDK-native runs emit one or more `AgentEvent`s to the outbox. `AgentContextImpl` selects one
|
|
699
|
+
* implementation per run and delegates to it, instead of branching on the mode at every call site.
|
|
700
|
+
*/
|
|
701
|
+
interface TurnTransport {
|
|
702
|
+
sendReply(reply: ReplyContent, sideEffects: SideEffectsSnapshot): Promise<SentMessageInfo | null>;
|
|
703
|
+
/**
|
|
704
|
+
* Returns `'unaddressable'` when the card was rendered but there is no client-addressable
|
|
705
|
+
* message handle for it (event mode: the sink owns approval-card rendering, so there is no
|
|
706
|
+
* id it could later resolve an edit/delete against).
|
|
707
|
+
*/
|
|
708
|
+
sendApprovalCard(card: ToolApprovalCard, sideEffects: SideEffectsSnapshot): Promise<SentMessageInfo | null | 'unaddressable'>;
|
|
709
|
+
editMessage(messageId: string, reply: ReplyContent): Promise<SentMessageInfo | null>;
|
|
710
|
+
deleteMessage(messageId: string): Promise<void>;
|
|
711
|
+
setTyping(op: TypingOp): Promise<void>;
|
|
712
|
+
flushSideEffects(sideEffects: SideEffectsSnapshot): Promise<void>;
|
|
713
|
+
emitCustom(name: string, data: unknown): Promise<void>;
|
|
714
|
+
queueRunStart(): void;
|
|
715
|
+
emitRunFinish(outcome: AgentRunOutcome): Promise<void>;
|
|
716
|
+
reportTurnError(message?: string): Promise<void>;
|
|
436
717
|
}
|
|
437
718
|
declare class ReplyHandleImpl implements ReplyHandle {
|
|
438
|
-
private readonly
|
|
439
|
-
private readonly integrationIdentifier;
|
|
440
|
-
private readonly poster;
|
|
719
|
+
private readonly transport;
|
|
441
720
|
messageId: string;
|
|
442
721
|
platformThreadId: string;
|
|
443
722
|
/** @internal set when the handler calls `edit()`; dispatch skips default approval card cleanup. */
|
|
444
723
|
editedByHandler: boolean;
|
|
445
|
-
constructor(messageId: string, platformThreadId: string,
|
|
724
|
+
constructor(messageId: string, platformThreadId: string, transport: TurnTransport);
|
|
446
725
|
edit(content: MessageContent, options?: {
|
|
447
726
|
files?: FileRef[];
|
|
448
727
|
}): Promise<ReplyHandle>;
|
|
@@ -457,9 +736,11 @@ declare class AgentContextImpl implements AgentRuntimeContext {
|
|
|
457
736
|
readonly conversation: AgentConversation;
|
|
458
737
|
readonly subscriber: AgentSubscriber | null;
|
|
459
738
|
readonly context: AgentContextPayload | null;
|
|
739
|
+
readonly notification: AgentNotification | null;
|
|
460
740
|
readonly history: AgentHistoryEntry[];
|
|
461
741
|
readonly platform: string;
|
|
462
742
|
readonly platformContext: AgentPlatformContext;
|
|
743
|
+
readonly humanResponse: AgentHumanResponse | null;
|
|
463
744
|
readonly typing: TypingControl;
|
|
464
745
|
readonly toolApproval: ToolApprovalControl;
|
|
465
746
|
readonly metadata: {
|
|
@@ -477,11 +758,7 @@ declare class AgentContextImpl implements AgentRuntimeContext {
|
|
|
477
758
|
private _resolveSignal;
|
|
478
759
|
private _metadataState;
|
|
479
760
|
private readonly _toolApprovalConfig?;
|
|
480
|
-
private readonly
|
|
481
|
-
private readonly _conversationId;
|
|
482
|
-
private readonly _integrationIdentifier;
|
|
483
|
-
private readonly _secretKey;
|
|
484
|
-
private readonly _poster;
|
|
761
|
+
private readonly _transport;
|
|
485
762
|
constructor(request: AgentBridgeRequest, secretKey: string, toolApprovalConfig?: ToolApprovalConfig);
|
|
486
763
|
asMessageContext(): AgentMessageContext;
|
|
487
764
|
reply(content: MessageContent, options?: {
|
|
@@ -490,29 +767,49 @@ declare class AgentContextImpl implements AgentRuntimeContext {
|
|
|
490
767
|
replyApprovalCard(card: ToolApprovalCard): Promise<ReplyHandle>;
|
|
491
768
|
/** @internal Build a handle to an already-posted message (used to resume an approval). */
|
|
492
769
|
createReplyHandle(messageId: string): ReplyHandleImpl;
|
|
770
|
+
emit(event: {
|
|
771
|
+
name: string;
|
|
772
|
+
data: unknown;
|
|
773
|
+
}): Promise<void>;
|
|
493
774
|
resolve(summary?: string): void;
|
|
494
775
|
trigger(workflowId: string, opts?: {
|
|
495
776
|
to?: TriggerRecipientsPayload;
|
|
496
777
|
payload?: Record<string, unknown>;
|
|
497
778
|
}): void;
|
|
779
|
+
ask(question: string, opts?: HumanAskApproveOptions): string;
|
|
780
|
+
approve(action: string, opts?: HumanAskApproveOptions): string;
|
|
781
|
+
choose(question: string, options: string[], opts?: HumanChooseOptions): string;
|
|
782
|
+
tell(message: string, opts?: HumanTellOptions): string;
|
|
783
|
+
private queueHumanSignal;
|
|
498
784
|
/** @internal Queue a gated tool call for the ledger; flushed with the next reply. */
|
|
499
785
|
emitToolApprovalRequest(request: ToolApprovalRequestPayload): void;
|
|
500
786
|
/** @internal Queue a tool-call outcome to be recorded in history; flushed with the next reply. */
|
|
501
787
|
emitToolResult(result: ToolResult): void;
|
|
502
788
|
addReaction(messageId: string, emojiName: Emoji): void;
|
|
503
789
|
deleteMessage(messageId: string): void;
|
|
790
|
+
/** @internal Enqueue run-start before handler execution; flushed with the first emit. */
|
|
791
|
+
queueRunStart(): void;
|
|
792
|
+
/** @internal Enqueue and flush run-finish as the terminal success event. */
|
|
793
|
+
emitRunFinish(options: {
|
|
794
|
+
outcome: AgentRunOutcome;
|
|
795
|
+
}): Promise<void>;
|
|
504
796
|
/** Best-effort failure report to Novu. Never throws. */
|
|
505
|
-
reportTurnError(): Promise<void>;
|
|
797
|
+
reportTurnError(message?: string): Promise<void>;
|
|
506
798
|
/**
|
|
507
799
|
* Flush any remaining signals that weren't sent with reply().
|
|
508
800
|
* Called internally after onResolve returns.
|
|
509
801
|
*/
|
|
510
802
|
flush(): Promise<void>;
|
|
511
803
|
private _hasPendingSideEffects;
|
|
512
|
-
|
|
513
|
-
private
|
|
804
|
+
/** Atomically drains all queued side effects into a snapshot for the transport to deliver. */
|
|
805
|
+
private _drainSideEffectsSnapshot;
|
|
514
806
|
}
|
|
515
807
|
|
|
808
|
+
/** Maximum outbound body length included before the payload. */
|
|
809
|
+
declare const WORKFLOW_ORIGIN_LINE_MAX_CHARS = 500;
|
|
810
|
+
declare function buildWorkflowOriginLine(workflowIdentifier: string, messageContent: string): string;
|
|
811
|
+
declare function buildWorkflowOriginInjection(workflowIdentifier: string, messageContent: string, payload: Record<string, unknown>): string;
|
|
812
|
+
|
|
516
813
|
/**
|
|
517
814
|
* Creates a configured Liquid instance with Novu's default settings.
|
|
518
815
|
*
|
|
@@ -525,4 +822,4 @@ declare function createLiquidEngine(options?: LiquidOptions): Liquid;
|
|
|
525
822
|
declare function repairJsonString(value: string): string;
|
|
526
823
|
declare function compileJsonControlValues(values: Record<string, unknown>, context: Record<string, unknown>, liquidEngine?: ReturnType<typeof createLiquidEngine>): Promise<Record<string, unknown>>;
|
|
527
824
|
|
|
528
|
-
export { AgentBridgeRequest, AgentContextImpl, AgentEventEnum,
|
|
825
|
+
export { AgentBridgeRequest, AgentContextImpl, type AgentEvent, AgentEventEnum, type AgentEventEnvelope, type AgentRuntimeContext, BadRequestError, BridgeError, ConflictError, DeleteMessagePayload, ErrorCodeEnum, ExecutionEventControlsInvalidError, ExecutionEventPayloadInvalidError, ExecutionProviderOutputInvalidError, ExecutionStateControlsInvalidError, ExecutionStateCorruptError, ExecutionStateOutputInvalidError, ExecutionStateResultInvalidError, FILTER_VALIDATORS, ForbiddenError, FrameworkError, HttpHeaderKeysEnum, HttpMethodEnum, HttpQueryKeysEnum, HttpStatusEnum, InvalidActionError, type LiquidFilterIssue, MethodNotAllowedError, MissingSecretKeyError, NotFoundError, NovuApiEndpointsEnum, PlatformError, PostActionEnum, ProviderExecutionFailedError, ProviderNotFoundError, ReplyContent, ResourceConflictError, ResourceEnum, ResourceExecutionFailed, ResourceNotFoundError, SIGNATURE_TIMESTAMP_TOLERANCE, SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES, SentMessageInfo, ServerError, Signal, SignatureExpiredError, SignatureInvalidError, SignatureMismatchError, SignatureNotFoundError, SignatureVersionInvalidError, SigningKeyNotFoundError, StepAlreadyExistsError, StepControlCompilationFailedError, StepExecutionFailedError, StepNotFoundError, ToolApprovalRequestPayload, ToolResult, UnauthorizedError, WORKFLOW_ORIGIN_LINE_MAX_CHARS, WorkflowAlreadyExistsError, WorkflowNotFoundError, WorkflowPayloadInvalidError, buildWorkflowOriginInjection, buildWorkflowOriginLine, compileJsonControlValues, createLiquidEngine, digest, isFrameworkError, isNativeError, pluralize, repairJsonString, toSentence, toSentenceArgsValidator };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as ue,B as ce,C as de,D as fe,E as xe,F as Ae,I as ye,J as Re,K as Se,L as r,M as o,Q as a,T as m,V as ve,W as Ee,a as j,b as D,c as H,d as B,e as G,f as K,g as X,h as z,i as Q,j as U,k as Y,m as Z,n as $,o as ee,p as oe,q as re,r as te,s as ne,t as ie,u as pe,v as ae,w as se,x as le,y as me,z as ge}from"../chunk-4ETX7FIT.js";import"../chunk-X5AZIKIR.js";import"../chunk-RBTQQ5IZ.js";import{e as g,f as u}from"../chunk-IREH6K2M.js";import{a as y,b as R,c as S,d as v,e as E,f as I,g as L,h as w,i as O,j as k,k as q,l as J,m as C,n as F,o as P,p as T,q as V,r as h,s as N,t as _,u as M,v as W,w as b}from"../chunk-VY27ZAO7.js";import{a as c,b as d,c as f}from"../chunk-QZ6TSYCK.js";import{e as s,f as l}from"../chunk-PU74XQ2P.js";import"../chunk-FHYMHX3T.js";var Le={toSentence:r};import{jsonrepair as t}from"jsonrepair";function x(e){return t(e)}async function A(e,n,i=o()){let p=await i.parseAndRender(JSON.stringify(e),n);try{return JSON.parse(t(p))}catch{throw new Error("Rendered template output is not valid JSON")}}export{F as ActionStepEnum,m as AgentContextImpl,a as AgentEventEnum,N as BadRequestError,j as BridgeError,C as ChannelStepEnum,W as ConflictError,I as CronExpression,L as ErrorCodeEnum,B as ExecutionEventControlsInvalidError,H as ExecutionEventPayloadInvalidError,Q as ExecutionProviderOutputInvalidError,G as ExecutionStateControlsInvalidError,D as ExecutionStateCorruptError,K as ExecutionStateOutputInvalidError,X as ExecutionStateResultInvalidError,Le as FILTER_VALIDATORS,b as ForbiddenError,V as FrameworkError,R as GetActionEnum,w as HttpHeaderKeysEnum,O as HttpMethodEnum,k as HttpQueryKeysEnum,q as HttpStatusEnum,$ as InvalidActionError,ve as JobStatusEnum,Z as MethodNotAllowedError,ee as MissingSecretKeyError,h as NotFoundError,S as NovuApiEndpointsEnum,oe as PlatformError,y as PostActionEnum,pe as ProviderExecutionFailedError,ie as ProviderNotFoundError,re as ResourceConflictError,J as ResourceEnum,ne as ResourceExecutionFailed,te as ResourceNotFoundError,E as SIGNATURE_TIMESTAMP_TOLERANCE,v as SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES,M as ServerError,Ee as SeverityLevelEnum,me as SignatureExpiredError,le as SignatureInvalidError,ae as SignatureMismatchError,se as SignatureNotFoundError,ue as SignatureVersionInvalidError,ge as SigningKeyNotFoundError,de as StepAlreadyExistsError,z as StepControlCompilationFailedError,fe as StepExecutionFailedError,ce as StepNotFoundError,_ as UnauthorizedError,c as WORKFLOW_ORIGIN_LINE_MAX_CHARS,Ae as WorkflowAlreadyExistsError,P as WorkflowChannelEnum,xe as WorkflowNotFoundError,U as WorkflowPayloadInvalidError,g as actionStepSchemas,s as buildApprovalActionId,f as buildWorkflowOriginInjection,d as buildWorkflowOriginLine,u as channelStepSchemas,A as compileJsonControlValues,o as createLiquidEngine,ye as digest,Y as isFrameworkError,T as isNativeError,l as parseApprovalActionId,Re as pluralize,x as repairJsonString,Se as toSentence,r as toSentenceArgsValidator};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
import { l as AgentHistoryEntry, M as MessageContent, k as AgentHandlers,
|
|
2
|
+
import { l as AgentHistoryEntry, j as AgentHandlerContext, M as MessageContent, k as AgentHandlers, n as AgentMessage, p as AgentMessageContext, D as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent } from '../agent.types-DFLG1_vb.js';
|
|
3
3
|
import { LanguageModelLike } from '@langchain/core/language_models/base';
|
|
4
4
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
5
5
|
import { StructuredToolInterface } from '@langchain/core/tools';
|
|
@@ -14,10 +14,13 @@ interface ToolResultPayload {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Convert
|
|
17
|
+
* Convert conversation context into LangChain `BaseMessage[]` for `createAgent().invoke(...)`.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
* `
|
|
19
|
+
* Pass `ctx` to prepend `ctx.notification` as an `AIMessage`. Pass `ctx.history` to skip that
|
|
20
|
+
* injection (e.g. after `isFromWorkflow`). History already includes the current inbound message.
|
|
21
|
+
*
|
|
22
|
+
* Returning a `LangChainAgentConfig` hydrates unreachable attachment URLs for you.
|
|
23
|
+
* If you invoke the agent yourself, wrap this result in `hydrateUnreachableAttachmentUrls`.
|
|
21
24
|
*
|
|
22
25
|
* @param system - Optional system prompt prepended as a `SystemMessage`. Omit it when the
|
|
23
26
|
* agent already receives a prompt (e.g. via `createAgent({ prompt })`) to avoid duplication.
|
|
@@ -25,6 +28,17 @@ interface ToolResultPayload {
|
|
|
25
28
|
* with a fresh result are replayed as resolved call+result pairs.
|
|
26
29
|
*/
|
|
27
30
|
declare function toLangChainMessages(history: AgentHistoryEntry[], system?: string, freshResults?: Map<string, ToolResultPayload>): BaseMessage[];
|
|
31
|
+
declare function toLangChainMessages(ctx: Pick<AgentHandlerContext, 'history' | 'notification'>, system?: string, freshResults?: Map<string, ToolResultPayload>): BaseMessage[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Replace attachment URLs a hosted model cannot fetch with inline base64.
|
|
35
|
+
* HTTPS public URLs are left as-is so production signed S3 links stay URL-based.
|
|
36
|
+
* Over-budget downloads are omitted so one large file cannot abort the turn.
|
|
37
|
+
*
|
|
38
|
+
* Novu calls this automatically when you return a `LangChainAgentConfig`.
|
|
39
|
+
* Call it yourself before `createAgent().invoke(...)` when you map history.
|
|
40
|
+
*/
|
|
41
|
+
declare function hydrateUnreachableAttachmentUrls(messages: BaseMessage[]): Promise<BaseMessage[]>;
|
|
28
42
|
|
|
29
43
|
/** A tool call surfaced to `needsApproval` before it executes. */
|
|
30
44
|
interface LangChainToolCall {
|
|
@@ -40,7 +54,11 @@ interface LangChainToolCall {
|
|
|
40
54
|
* `ctx.history` — no LangGraph checkpointer required.
|
|
41
55
|
*/
|
|
42
56
|
interface LangChainAgentConfig {
|
|
43
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Chat model instance or `"provider:model"` identifier passed to `createAgent`.
|
|
59
|
+
* On Next.js, model strings require LangChain packages in `serverExternalPackages`
|
|
60
|
+
* (scaffolded by `novu connect --runtime langchain`).
|
|
61
|
+
*/
|
|
44
62
|
model: string | LanguageModelLike;
|
|
45
63
|
/** Tools available to the agent. */
|
|
46
64
|
tools?: StructuredToolInterface[];
|
|
@@ -117,4 +135,4 @@ declare class NovuToolApprovalRequired extends Error {
|
|
|
117
135
|
});
|
|
118
136
|
}
|
|
119
137
|
|
|
120
|
-
export { type LangChainAgentConfig, type LangChainAgentHandlers, type LangChainInvokeResult, type LangChainResult, type LangChainToolCall, NovuToolApprovalRequired, agent, toLangChainMessages };
|
|
138
|
+
export { type LangChainAgentConfig, type LangChainAgentHandlers, type LangChainInvokeResult, type LangChainResult, type LangChainToolCall, NovuToolApprovalRequired, agent, hydrateUnreachableAttachmentUrls, toLangChainMessages };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{a as R,b as M,c as x,d as P,f as L}from"../chunk-YZ3P3MMZ.js";import{c as w}from"../chunk-QZ6TSYCK.js";import{a as I,d as g,g as T}from"../chunk-PU74XQ2P.js";import"../chunk-FHYMHX3T.js";import{AIMessage as j,HumanMessage as D,SystemMessage as te}from"@langchain/core/messages";import{AIMessage as Q,ToolMessage as H}from"@langchain/core/messages";var S="tool_approval_request",k="tool_approval_decision",N="tool_result",X=JSON.stringify({type:"execution-denied"});function m(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 _(e){let t=e.toolData;if(!(!t||typeof t.approvalId!="string"||typeof t.approved!="boolean"))return{approvalId:t.approvalId,approved:t.approved}}function B(e){let t=e.toolData;if(!(!t||typeof t.toolCallId!="string"))return{toolCallId:t.toolCallId,toolName:t.toolName,output:t.output}}function b(e,t){let o=new Set,n=new Map,a=new Map;for(let r of e)if(r.type===S){let s=m(r);s&&a.set(s.approvalId,s.toolCallId)}else if(r.type===k){let s=_(r);s&&!s.approved&&o.add(s.approvalId)}else if(r.type===N){let s=B(r);s&&n.set(s.toolCallId,s)}if(t)for(let[r,s]of t)n.set(r,s);return{deniedApprovalIds:o,toolResults:n,approvalIdToToolCallId:a}}function W(e,t){return t.deniedApprovalIds.has(e.approvalId)?"denied":t.toolResults.has(e.toolCallId)?"resolved":"in-flight"}function E(e){var t;return new Q({content:"",tool_calls:[{id:e.toolCallId,name:e.name,args:(t=e.input)!=null?t:{},type:"tool_call"}]})}function K(e){return typeof e=="string"?e:JSON.stringify(e)}function Z(e){var t;return new H({content:K(e.output),tool_call_id:e.toolCallId,name:(t=e.toolName)!=null?t:"tool"})}function ee(e){return new H({content:X,tool_call_id:e.toolCallId,name:e.name,status:"error"})}function O(e,t){let o=m(e);if(!o)return[];let n=W(o,t);switch(n){case"denied":return[E(o),ee(o)];case"resolved":{let a=t.toolResults.get(o.toolCallId);return a?[E(o),Z(a)]:[]}case"in-flight":return[];default:return n}}function U(e){let t=new Set,o=new Set,n=[];for(let a of e)if(a.type===S){let r=m(a);r&&n.push({approvalId:r.approvalId,toolCallId:r.toolCallId,toolName:r.name,input:r.input})}else if(a.type===k){let r=_(a);r!=null&&r.approved&&t.add(r.approvalId)}else if(a.type===N){let r=B(a);r&&o.add(r.toolCallId)}return n.filter(a=>t.has(a.approvalId)&&!o.has(a.toolCallId)).map(({toolCallId:a,toolName:r,input:s})=>({toolCallId:a,toolName:r,input:s}))}function q(e){return x(e).map(t=>M(t.mediaType)?{type:"image",url:t.url,mimeType:t.mediaType}:{type:"file",url:t.url,mimeType:t.mediaType,...t.name?{metadata:{title:t.name}}:{}})}var oe="message",ne="tool_approval_request";function $(e){return e==="agent"||e==="assistant"}function ae(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 re(e,t){let o=$(e.role),n=!!e.content.trim(),a=o?[]:q(e);if(!n&&a.length===0)return;if(o)return new j(e.content);let r=t&&e.senderName?`${e.senderName}: ${e.content}`:e.content;if(a.length===0)return new D(r);let s=n?[...a,{type:"text",text:r}]:a;return new D({content:s})}function se(e,t,o){switch(e.type){case oe:{let n=re(e,t);return n?[n]:[]}case ne:return O(e,o);default:return[]}}function y(e,t,o){let{history:n,notification:a}=R(e),r=ae(n)>1,s=b(n,o),l=n.flatMap(p=>se(p,r,s)),i=a?[new j(w(a.workflowId,a.body,a.payload)),...l]:l;return t?[new te(t),...i]:i}import{HumanMessage as le,isHumanMessage as ie}from"@langchain/core/messages";async function pe(e){if(!e||typeof e!="object")return e;let t=e;if(t.type!=="image"&&t.type!=="file"||typeof t.url!="string"||P(t.url))return e;let o=await L(t.url);if(!o)return null;let{url:n,...a}=t;return{...a,data:o}}async function A(e){return Promise.all(e.map(async t=>{if(!ie(t)||!Array.isArray(t.content))return t;let o=(await Promise.all(t.content.map(n=>pe(n)))).filter(n=>n!=null);return new le({content:o})}))}import{isAIMessage as ve,isBaseMessage as V}from"@langchain/core/messages";import{createAgent as he}from"langchain";import{isBaseMessage as ue}from"@langchain/core/messages";import{createMiddleware as de}from"langchain";var d=class extends Error{constructor(t){super(`Tool "${t.toolName}" requires approval`),this.name="NovuToolApprovalRequired",this.toolCallId=t.toolCallId,this.toolName=t.toolName,this.input=t.input}},ge=10;function Y(e){let t=e;for(let o=0;o<ge&&t!=null;o+=1){if(t instanceof d)return t;t=t.cause}}function z(e){return de({name:"novu-tool-approval",wrapToolCall:async(t,o)=>{let{id:n,name:a,args:r}=t.toolCall,s=r!=null?r:{};if(e({id:n,name:a,args:s}))throw new d({toolCallId:n!=null?n:a,toolName:a,input:s});return o(t)}})}async function F(e,t,o){let n={id:t.toolCallId,name:t.toolName,input:t.input};await T(e,n,o)}function ce(e){return ue(e)?e.content:e}function fe(e){let t=new Map;for(let o of e!=null?e:[])t.set(o.name,o);return t}async function J(e,t){var r;let o=U(t.history),n=new Map;if(o.length===0)return n;let a=fe(e);for(let s of o){let l=a.get(s.toolName);if(!l)continue;let i=ce(await l.invoke((r=s.input)!=null?r:{}));n.set(s.toolCallId,{toolCallId:s.toolCallId,toolName:s.toolName,output:i}),t.emitToolResult({toolCallId:s.toolCallId,toolName:s.toolName,output:i,preview:`Tool "${s.toolName}" result`})}return n}import{isToolMessage as me}from"@langchain/core/messages";function ye(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}function Ae(e,t){var n;let o=new Set(t);for(let a of e.history)a.type==="tool_result"&&((n=a.toolData)!=null&&n.toolCallId)&&o.add(a.toolData.toolCallId);return o}function Ce(e){return typeof e=="string"?e:JSON.stringify(e)}function C(e,t,o=new Set){var r;let n=ye(t);if(n.size===0)return;let a=Ae(t,o);for(let s of e){if(!me(s))continue;let l=s.tool_call_id;!n.has(l)||a.has(l)||(a.add(l),t.emitToolResult({toolCallId:l,toolName:s.name,output:Ce(s.content),preview:`Tool "${(r=s.name)!=null?r:l}" result`}))}}function G(e){if(typeof e!="object"||e===null)return!1;let t=e.model;return typeof t=="string"||typeof t=="object"&&t!==null}function Ie(e){return typeof e=="object"&&e!==null&&Array.isArray(e.messages)}function c(e){return typeof e!="object"||e===null||I(e)?!1:V(e)||G(e)||Ie(e)}function Te(e){return typeof e=="string"?e:e.map(t=>{let o=t;return o.type==="text"&&typeof o.text=="string"?o.text:""}).join("")}function v(e){for(let t=e.length-1;t>=0;t-=1){let o=e[t];if(ve(o))return Te(o.content).trim()}return""}async function h(e,t,o){var a;if(!e){await t.typing.stop();return}let n=o&&(a=await o(e))!=null?a:e;await t.reply(n)}async function Re(e,t,o){var i;let n=await J(e.tools,t),a=await A(y(t,void 0,n)),r=[];e.needsApproval&&r.push(z(e.needsApproval)),e.middleware&&r.push(...e.middleware);let s=he({model:e.model,tools:(i=e.tools)!=null?i:[],...e.system?{prompt:e.system}:{},...r.length>0?{middleware:r}:{}}),l;try{l=await s.invoke({messages:a},e.invokeConfig)}catch(p){let u=Y(p);if(u){await F(t,u,o);return}throw p}C(l.messages,t,new Set(n.keys())),await h(v(l.messages),t,e.formatReply)}async function f(e,t,o){if(G(e)){await Re(e,t,o);return}if(V(e)){await h(v([e]),t);return}C(e.messages,t),await h(v(e.messages),t)}var we={text:"",platformMessageId:"",author:{userId:"",fullName:"",userName:"",isBot:!1},timestamp:""};function Me(e){return typeof e=="object"&&e!==null&&"messageId"in e&&"platformThreadId"in e}function xe(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 Pe(e,t){if(!e)throw new Error("agent() requires a non-empty agentId");let o=xe(e,t),n=o.toolApproval,a=typeof o.onToolApproval=="function",r=async l=>{let i=g(l),p=await o.onMessage(we,i.asMessageContext());c(p)&&await f(p,i,n)},s={onMessage:async(l,i)=>{let p=await o.onMessage(l,i);if(c(p)){await f(p,g(i),n);return}return p},onToolApproval:async(l,i)=>{let p=g(i);if(o.onToolApproval){let u=await o.onToolApproval(l,i);if(c(u)){await f(u,p,n);return}u!=null&&!Me(u)&&await p.reply(u)}await r(i)},...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:a}}export{d as NovuToolApprovalRequired,Pe as agent,A as hydrateUnreachableAttachmentUrls,y as toLangChainMessages};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { S as ServeHandlerOptions } from '../index-
|
|
2
|
-
export { C as Client, N as NovuRequestHandler, a as agent, w as workflow } from '../index-
|
|
3
|
-
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-
|
|
4
|
-
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-
|
|
1
|
+
import { S as ServeHandlerOptions } from '../index-BvRGmHFw.js';
|
|
2
|
+
export { C as Client, N as NovuRequestHandler, a as agent, i as isFromWorkflow, w as workflow } from '../index-BvRGmHFw.js';
|
|
3
|
+
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-DORn4djx.js';
|
|
4
|
+
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-Drf26WPA.js';
|
|
5
5
|
import { S as SupportedFrameworkName } from '../server.types-Cc6o5eYH.js';
|
|
6
|
-
export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
|
|
7
|
-
export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentContextPayload, f as AgentContextValue, g as AgentConversation, h as AgentDeliveryError, i as AgentError, j as AgentHandlerContext, k as AgentHandlers, l as AgentHistoryEntry, m as
|
|
6
|
+
export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Image, ImageElement, Select, SelectOption, TextInput } from 'chat';
|
|
7
|
+
export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentContextPayload, f as AgentContextValue, g as AgentConversation, h as AgentDeliveryError, i as AgentError, j as AgentHandlerContext, k as AgentHandlers, l as AgentHistoryEntry, m as AgentHumanResponse, n as AgentMessage, o as AgentMessageAuthor, p as AgentMessageContext, q as AgentNotification, r as AgentPlatformContext, s as AgentReaction, t as AgentReactionContext, u as AgentResolveContext, v as AgentSubscriber, w as AgentSubscriberAccess, x as AgentToolCall, F as FileRef, H as HumanAskApproveOptions, y as HumanChooseOptions, z as HumanInteractionKind, B as HumanTellOptions, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, C as ToolApprovalConfig, D as ToolApprovalDecision, E as toAgentError } from '../agent.types-DFLG1_vb.js';
|
|
8
8
|
export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, ToolStepResolver, step } from '../step-resolver.js';
|
|
9
9
|
import '../util.types-DaFfsxgy.js';
|
|
10
10
|
import '../base.schema.types-BApIn9jr.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as N,c as a,d as k,e as i}from"../chunk-PBC7WR2R.js";import{a as F}from"../chunk-YLCLZVYS.js";import"../chunk-XIVU4VDS.js";import{N as R,O as V,P as b,W as $}from"../chunk-4ETX7FIT.js";import{a as y,b as h,c,d as m,e as f,f as H,i as v,p as w,q as E,r as S}from"../chunk-X5AZIKIR.js";import"../chunk-RBTQQ5IZ.js";import{a as O}from"../chunk-IREH6K2M.js";import{f as x}from"../chunk-VY27ZAO7.js";import{b as A}from"../chunk-PU74XQ2P.js";import"../chunk-FHYMHX3T.js";var l="express",q=p=>new a({frameworkName:l,...p,handler:(t,o)=>({body:()=>t.body,headers:e=>{let r=t.headers[e];return Array.isArray(r)?r[0]:r},method:()=>t.method||"GET",url:()=>{let e=t.headers.host||"",r=e!=null&&e.includes("://")?"":`${t.protocol||"https"}://`;return new URL(t.originalUrl||t.url||"",`${r}${e||""}`)},queryString:e=>{let r=t.query[e];return Array.isArray(r)?r[0]:r},transformResponse:({body:e,headers:r,status:s})=>(Object.entries(r).forEach(([n,d])=>{o.setHeader(n,d)}),o.status(s).send(e))})}).createHandler();export{y as Actions,V as AgentDeliveryError,R as AgentError,h as Button,c as Card,m as CardLink,f as CardText,N as Client,x as CronExpression,H as Divider,v as Image,a as NovuRequestHandler,w as Select,E as SelectOption,$ as SeverityLevelEnum,S as TextInput,k as agent,l as frameworkName,A as isFromWorkflow,O as providerSchemas,q as serve,F as step,b as toAgentError,i as workflow};
|