@novu/framework 2.13.0 → 2.13.1-rc.852194fa77
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-Dqm2VBTO.d.cts → agent.types-CQKSD7NC.d.cts} +84 -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-B9FbzRbm.d.cts → health-check.types-B6RuXNc8.d.cts} +72 -66
- package/dist/cjs/{index-CLZZRnNV.d.cts → index-phn3kJ9H.d.cts} +18 -6
- package/dist/cjs/index.cjs +112 -112
- package/dist/cjs/index.d.cts +6 -6
- package/dist/cjs/internal/index.cjs +46 -43
- package/dist/cjs/internal/index.d.cts +314 -28
- package/dist/cjs/langchain/index.cjs +4 -1
- package/dist/cjs/langchain/index.d.cts +38 -6
- package/dist/cjs/servers/express.cjs +102 -102
- package/dist/cjs/servers/express.d.cts +7 -7
- package/dist/cjs/servers/h3.cjs +106 -106
- package/dist/cjs/servers/h3.d.cts +7 -7
- package/dist/cjs/servers/hono.cjs +106 -106
- package/dist/cjs/servers/hono.d.cts +7 -7
- package/dist/cjs/servers/lambda.cjs +102 -102
- package/dist/cjs/servers/lambda.d.cts +7 -7
- package/dist/cjs/servers/nest.cjs +115 -115
- package/dist/cjs/servers/nest.d.cts +9 -9
- package/dist/cjs/servers/next.cjs +124 -124
- package/dist/cjs/servers/next.d.cts +7 -7
- package/dist/cjs/servers/nuxt.cjs +106 -106
- package/dist/cjs/servers/nuxt.d.cts +7 -7
- package/dist/cjs/servers/remix.cjs +117 -117
- package/dist/cjs/servers/remix.d.cts +7 -7
- package/dist/cjs/servers/sveltekit.cjs +114 -114
- package/dist/cjs/servers/sveltekit.d.cts +7 -7
- package/dist/cjs/step-resolver.cjs +4 -4
- package/dist/cjs/step-resolver.d.cts +18 -4
- package/dist/cjs/{subscriber.types-DubxcL8q.d.cts → subscriber.types-_eHz1E0m.d.cts} +738 -20
- package/dist/cjs/validators.cjs +1 -1
- package/dist/esm/{agent.types-E3sxq6xr.d.ts → agent.types-C17NUGxY.d.ts} +84 -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-PU74XQ2P.js +1 -0
- package/dist/esm/chunk-Q3ALQWIF.js +1 -0
- package/dist/esm/chunk-QZ6TSYCK.js +4 -0
- package/dist/esm/{chunk-CANJPWLT.js → chunk-UXO4RWZV.js} +4 -4
- package/dist/esm/{chunk-FRWG7YTE.js → chunk-VY27ZAO7.js} +1 -1
- package/dist/esm/chunk-WJUYDVXH.js +98 -0
- package/dist/esm/{chunk-46AHJTS7.js → chunk-X5AZIKIR.js} +8 -8
- package/dist/esm/{chunk-22DBAEUX.js → chunk-XIVU4VDS.js} +1 -1
- package/dist/esm/{chunk-2M25EATE.js → chunk-YLCLZVYS.js} +1 -1
- package/dist/esm/chunk-YZ3P3MMZ.js +1 -0
- package/dist/esm/{health-check.types-BNocZ4Wk.d.ts → health-check.types-CL5-B_D4.d.ts} +72 -66
- package/dist/esm/{index-CWldA6G5.d.ts → index-CYtGHJJu.d.ts} +18 -6
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +306 -20
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/jsx-dev-runtime.js +1 -1
- package/dist/esm/{jsx-runtime-P2HN3TPO.js → jsx-runtime-5ZWEWA4A.js} +1 -1
- package/dist/esm/jsx-runtime.js +1 -1
- package/dist/esm/langchain/index.d.ts +38 -6
- package/dist/esm/langchain/index.js +1 -1
- package/dist/esm/servers/express.d.ts +7 -7
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +7 -7
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/hono.d.ts +7 -7
- package/dist/esm/servers/hono.js +1 -1
- package/dist/esm/servers/lambda.d.ts +7 -7
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +9 -9
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +7 -7
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +7 -7
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +7 -7
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +7 -7
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +18 -4
- package/dist/esm/step-resolver.js +1 -1
- package/dist/esm/{subscriber.types-CmybpXhA.d.ts → subscriber.types-D4PvRIKR.d.ts} +738 -20
- package/dist/esm/validators.js +1 -1
- package/langchain/package.json +4 -0
- package/nest/package.json +2 -1
- package/package.json +4 -3
- package/dist/esm/chunk-LHU5A7DI.js +0 -1
- package/dist/esm/chunk-W6DIBD4Z.js +0 -1
- package/dist/esm/chunk-WDBIT4NK.js +0 -98
- /package/dist/esm/{chunk-3ZWME5KT.js → chunk-7C3QBYLB.js} +0 -0
- /package/dist/esm/{chunk-XEHQJMMQ.js → chunk-RBTQQ5IZ.js} +0 -0
|
@@ -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
|
|
1
|
+
import { P as PostActionEnum } from '../health-check.types-CL5-B_D4.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-CL5-B_D4.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-D4PvRIKR.js';
|
|
4
4
|
import { Filter, LiquidOptions, Liquid } from 'liquidjs';
|
|
5
5
|
import { Emoji } from 'chat';
|
|
6
|
-
import {
|
|
7
|
-
export {
|
|
6
|
+
import { j as AgentHandlerContext, E as ToolResult, G as ToolApprovalRequestPayload, T as ToolApprovalCard, R as ReplyHandle, o as AgentMessageContext, H as AgentEventEnum, a as AgentAction, m as AgentMessage, r as AgentReaction, g as AgentConversation, u as AgentSubscriber, e as AgentContextPayload, p as AgentNotification, l as AgentHistoryEntry, q as AgentPlatformContext, J as TypingControl, K as ToolApprovalControl, L as AgentBridgeRequest, x as ToolApprovalConfig, M as MessageContent, F as FileRef, N as ReplyContent, S as Signal, O as AddReactionPayload, P as DeleteMessagePayload, Q as SentMessageInfo, U as TypingOp, B as TriggerRecipientsPayload } from '../agent.types-C17NUGxY.js';
|
|
7
|
+
export { V as AgentReplyPayload, X as EditPayload, Y as MetadataSignal, Z as ParsedApprovalAction, _ as TriggerSignal, $ as buildApprovalActionId, a0 as parseApprovalActionId } from '../agent.types-C17NUGxY.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,248 @@ 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 AgentEvent = {
|
|
229
|
+
type: 'run-start';
|
|
230
|
+
} | {
|
|
231
|
+
type: 'run-finish';
|
|
232
|
+
outcome: AgentRunOutcome;
|
|
233
|
+
finishReason?: AgentFinishReason;
|
|
234
|
+
usage?: AgentEventUsage;
|
|
235
|
+
approvals?: AgentApprovalRequest[];
|
|
236
|
+
} | {
|
|
237
|
+
type: 'run-error';
|
|
238
|
+
message: string;
|
|
239
|
+
code?: string;
|
|
240
|
+
} | {
|
|
241
|
+
type: 'step-start';
|
|
242
|
+
name?: string;
|
|
243
|
+
index?: number;
|
|
244
|
+
} | {
|
|
245
|
+
type: 'step-end';
|
|
246
|
+
name?: string;
|
|
247
|
+
index?: number;
|
|
248
|
+
usage?: AgentEventUsage;
|
|
249
|
+
} | {
|
|
250
|
+
type: 'message';
|
|
251
|
+
messageId: string;
|
|
252
|
+
/** Who authored this durable message. Streaming events stay assistant-only and omit role. */
|
|
253
|
+
role: AgentMessageRole;
|
|
254
|
+
content: AgentMessageContent;
|
|
255
|
+
files?: AgentFileRef[];
|
|
256
|
+
} | {
|
|
257
|
+
type: 'message-start';
|
|
258
|
+
messageId: string;
|
|
259
|
+
} | {
|
|
260
|
+
type: 'message-delta';
|
|
261
|
+
messageId: string;
|
|
262
|
+
delta: string;
|
|
263
|
+
} | {
|
|
264
|
+
type: 'message-end';
|
|
265
|
+
messageId: string;
|
|
266
|
+
content?: AgentMessageContent;
|
|
267
|
+
files?: AgentFileRef[];
|
|
268
|
+
} | {
|
|
269
|
+
type: 'thinking-start';
|
|
270
|
+
thinkingId: string;
|
|
271
|
+
} | {
|
|
272
|
+
type: 'thinking-delta';
|
|
273
|
+
thinkingId: string;
|
|
274
|
+
delta: string;
|
|
275
|
+
} | {
|
|
276
|
+
type: 'thinking-end';
|
|
277
|
+
thinkingId: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: 'source';
|
|
280
|
+
messageId: string;
|
|
281
|
+
sourceType: 'url' | 'document';
|
|
282
|
+
url?: string;
|
|
283
|
+
title?: string;
|
|
284
|
+
filename?: string;
|
|
285
|
+
} | {
|
|
286
|
+
type: 'tool-use-start';
|
|
287
|
+
toolUseId: string;
|
|
288
|
+
toolName: string;
|
|
289
|
+
source?: AgentToolSource;
|
|
290
|
+
} | {
|
|
291
|
+
type: 'tool-use-delta';
|
|
292
|
+
toolUseId: string;
|
|
293
|
+
delta: string;
|
|
294
|
+
} | {
|
|
295
|
+
type: 'tool-use-done';
|
|
296
|
+
toolUseId: string;
|
|
297
|
+
toolName: string;
|
|
298
|
+
input?: Record<string, unknown>;
|
|
299
|
+
source?: AgentToolSource;
|
|
300
|
+
} | {
|
|
301
|
+
type: 'tool-use-result';
|
|
302
|
+
toolUseId: string;
|
|
303
|
+
content: AgentToolResultContent[];
|
|
304
|
+
isError?: boolean;
|
|
305
|
+
} | ({
|
|
306
|
+
type: 'tool-approval-request';
|
|
307
|
+
/** Stable assistant message id used to preserve the approval's timeline position during history replay. */
|
|
308
|
+
messageId?: string;
|
|
309
|
+
/** When true, no companion message carries the approval UI. The consumer should render its default approval card. */
|
|
310
|
+
deliverCard?: boolean;
|
|
311
|
+
} & AgentApprovalRequest) | {
|
|
312
|
+
type: 'tool-approval-response';
|
|
313
|
+
approvalId: string;
|
|
314
|
+
decision: 'approved' | 'denied';
|
|
315
|
+
reason?: string;
|
|
316
|
+
automatic?: boolean;
|
|
317
|
+
} | {
|
|
318
|
+
type: 'mcp-connection-request';
|
|
319
|
+
actionId: string;
|
|
320
|
+
mcpId: string;
|
|
321
|
+
displayName: string;
|
|
322
|
+
authorizeUrl: string;
|
|
323
|
+
authorizeUrlWithAutoApprove?: string;
|
|
324
|
+
} | {
|
|
325
|
+
type: 'mcp-connection-result';
|
|
326
|
+
actionId: string;
|
|
327
|
+
mcpId: string;
|
|
328
|
+
status: 'connected' | 'failed';
|
|
329
|
+
message?: string;
|
|
330
|
+
} | {
|
|
331
|
+
type: 'resolve';
|
|
332
|
+
summary?: string;
|
|
333
|
+
} | {
|
|
334
|
+
type: 'signal';
|
|
335
|
+
signal: AgentSignal;
|
|
336
|
+
} | {
|
|
337
|
+
type: 'channel.typing';
|
|
338
|
+
state: 'on' | 'off';
|
|
339
|
+
status?: string;
|
|
340
|
+
} | {
|
|
341
|
+
type: 'channel.edit';
|
|
342
|
+
messageId: string;
|
|
343
|
+
content: AgentMessageContent;
|
|
344
|
+
files?: AgentFileRef[];
|
|
345
|
+
} | {
|
|
346
|
+
type: 'channel.delete';
|
|
347
|
+
messageId: string;
|
|
348
|
+
} | {
|
|
349
|
+
type: 'channel.reaction';
|
|
350
|
+
messageId: string;
|
|
351
|
+
emoji: string;
|
|
352
|
+
op: 'add' | 'remove';
|
|
353
|
+
} | {
|
|
354
|
+
type: 'connection.error';
|
|
355
|
+
source: 'mcp';
|
|
356
|
+
serverName: string;
|
|
357
|
+
reason: 'authentication' | 'connection';
|
|
358
|
+
message: string;
|
|
359
|
+
} | {
|
|
360
|
+
type: 'provider-event';
|
|
361
|
+
provider: string;
|
|
362
|
+
event: string;
|
|
363
|
+
data: unknown;
|
|
364
|
+
} | {
|
|
365
|
+
type: 'custom';
|
|
366
|
+
name: string;
|
|
367
|
+
data: unknown;
|
|
368
|
+
};
|
|
369
|
+
interface AgentEventEnvelope {
|
|
370
|
+
version: typeof AGENT_EVENT_PROTOCOL_VERSION;
|
|
371
|
+
conversationId: string;
|
|
372
|
+
/** Public `conv_*` identifier. Clients receive only this id, never `conversationId`. */
|
|
373
|
+
conversationIdentifier?: string;
|
|
374
|
+
agentId: string;
|
|
375
|
+
runId: string;
|
|
376
|
+
turnId: string;
|
|
377
|
+
sequence: number;
|
|
378
|
+
timestamp: string;
|
|
379
|
+
event: AgentEvent;
|
|
380
|
+
}
|
|
381
|
+
|
|
140
382
|
/**
|
|
141
383
|
* Check if the object is a native error.
|
|
142
384
|
*
|
|
@@ -431,18 +673,46 @@ interface AgentRuntimeContext extends AgentHandlerContext {
|
|
|
431
673
|
asMessageContext(): AgentMessageContext;
|
|
432
674
|
}
|
|
433
675
|
|
|
434
|
-
|
|
435
|
-
|
|
676
|
+
/** Pending side effects queued between replies, drained atomically before each turn action. */
|
|
677
|
+
interface SideEffectsSnapshot {
|
|
678
|
+
toolApprovalRequest: ToolApprovalRequestPayload | null;
|
|
679
|
+
signals: Signal[];
|
|
680
|
+
toolResults: ToolResult[];
|
|
681
|
+
addReactions: AddReactionPayload[];
|
|
682
|
+
deleteMessages: DeleteMessagePayload[];
|
|
683
|
+
resolve: {
|
|
684
|
+
summary?: string;
|
|
685
|
+
} | null;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* A turn's delivery mechanism. Legacy bridges POST a single `AgentReplyPayload` per action;
|
|
689
|
+
* SDK-native runs emit one or more `AgentEvent`s to the outbox. `AgentContextImpl` selects one
|
|
690
|
+
* implementation per run and delegates to it, instead of branching on the mode at every call site.
|
|
691
|
+
*/
|
|
692
|
+
interface TurnTransport {
|
|
693
|
+
sendReply(reply: ReplyContent, sideEffects: SideEffectsSnapshot): Promise<SentMessageInfo | null>;
|
|
694
|
+
/**
|
|
695
|
+
* Returns `'unaddressable'` when the card was rendered but there is no client-addressable
|
|
696
|
+
* message handle for it (event mode: the sink owns approval-card rendering, so there is no
|
|
697
|
+
* id it could later resolve an edit/delete against).
|
|
698
|
+
*/
|
|
699
|
+
sendApprovalCard(card: ToolApprovalCard, sideEffects: SideEffectsSnapshot): Promise<SentMessageInfo | null | 'unaddressable'>;
|
|
700
|
+
editMessage(messageId: string, reply: ReplyContent): Promise<SentMessageInfo | null>;
|
|
701
|
+
deleteMessage(messageId: string): Promise<void>;
|
|
702
|
+
setTyping(op: TypingOp): Promise<void>;
|
|
703
|
+
flushSideEffects(sideEffects: SideEffectsSnapshot): Promise<void>;
|
|
704
|
+
emitCustom(name: string, data: unknown): Promise<void>;
|
|
705
|
+
queueRunStart(): void;
|
|
706
|
+
emitRunFinish(outcome: AgentRunOutcome): Promise<void>;
|
|
707
|
+
reportTurnError(message?: string): Promise<void>;
|
|
436
708
|
}
|
|
437
709
|
declare class ReplyHandleImpl implements ReplyHandle {
|
|
438
|
-
private readonly
|
|
439
|
-
private readonly integrationIdentifier;
|
|
440
|
-
private readonly poster;
|
|
710
|
+
private readonly transport;
|
|
441
711
|
messageId: string;
|
|
442
712
|
platformThreadId: string;
|
|
443
713
|
/** @internal set when the handler calls `edit()`; dispatch skips default approval card cleanup. */
|
|
444
714
|
editedByHandler: boolean;
|
|
445
|
-
constructor(messageId: string, platformThreadId: string,
|
|
715
|
+
constructor(messageId: string, platformThreadId: string, transport: TurnTransport);
|
|
446
716
|
edit(content: MessageContent, options?: {
|
|
447
717
|
files?: FileRef[];
|
|
448
718
|
}): Promise<ReplyHandle>;
|
|
@@ -456,6 +726,8 @@ declare class AgentContextImpl implements AgentRuntimeContext {
|
|
|
456
726
|
readonly reaction: AgentReaction | null;
|
|
457
727
|
readonly conversation: AgentConversation;
|
|
458
728
|
readonly subscriber: AgentSubscriber | null;
|
|
729
|
+
readonly context: AgentContextPayload | null;
|
|
730
|
+
readonly notification: AgentNotification | null;
|
|
459
731
|
readonly history: AgentHistoryEntry[];
|
|
460
732
|
readonly platform: string;
|
|
461
733
|
readonly platformContext: AgentPlatformContext;
|
|
@@ -476,11 +748,7 @@ declare class AgentContextImpl implements AgentRuntimeContext {
|
|
|
476
748
|
private _resolveSignal;
|
|
477
749
|
private _metadataState;
|
|
478
750
|
private readonly _toolApprovalConfig?;
|
|
479
|
-
private readonly
|
|
480
|
-
private readonly _conversationId;
|
|
481
|
-
private readonly _integrationIdentifier;
|
|
482
|
-
private readonly _secretKey;
|
|
483
|
-
private readonly _poster;
|
|
751
|
+
private readonly _transport;
|
|
484
752
|
constructor(request: AgentBridgeRequest, secretKey: string, toolApprovalConfig?: ToolApprovalConfig);
|
|
485
753
|
asMessageContext(): AgentMessageContext;
|
|
486
754
|
reply(content: MessageContent, options?: {
|
|
@@ -489,6 +757,10 @@ declare class AgentContextImpl implements AgentRuntimeContext {
|
|
|
489
757
|
replyApprovalCard(card: ToolApprovalCard): Promise<ReplyHandle>;
|
|
490
758
|
/** @internal Build a handle to an already-posted message (used to resume an approval). */
|
|
491
759
|
createReplyHandle(messageId: string): ReplyHandleImpl;
|
|
760
|
+
emit(event: {
|
|
761
|
+
name: string;
|
|
762
|
+
data: unknown;
|
|
763
|
+
}): Promise<void>;
|
|
492
764
|
resolve(summary?: string): void;
|
|
493
765
|
trigger(workflowId: string, opts?: {
|
|
494
766
|
to?: TriggerRecipientsPayload;
|
|
@@ -500,18 +772,29 @@ declare class AgentContextImpl implements AgentRuntimeContext {
|
|
|
500
772
|
emitToolResult(result: ToolResult): void;
|
|
501
773
|
addReaction(messageId: string, emojiName: Emoji): void;
|
|
502
774
|
deleteMessage(messageId: string): void;
|
|
775
|
+
/** @internal Enqueue run-start before handler execution; flushed with the first emit. */
|
|
776
|
+
queueRunStart(): void;
|
|
777
|
+
/** @internal Enqueue and flush run-finish as the terminal success event. */
|
|
778
|
+
emitRunFinish(options: {
|
|
779
|
+
outcome: AgentRunOutcome;
|
|
780
|
+
}): Promise<void>;
|
|
503
781
|
/** Best-effort failure report to Novu. Never throws. */
|
|
504
|
-
reportTurnError(): Promise<void>;
|
|
782
|
+
reportTurnError(message?: string): Promise<void>;
|
|
505
783
|
/**
|
|
506
784
|
* Flush any remaining signals that weren't sent with reply().
|
|
507
785
|
* Called internally after onResolve returns.
|
|
508
786
|
*/
|
|
509
787
|
flush(): Promise<void>;
|
|
510
788
|
private _hasPendingSideEffects;
|
|
511
|
-
|
|
512
|
-
private
|
|
789
|
+
/** Atomically drains all queued side effects into a snapshot for the transport to deliver. */
|
|
790
|
+
private _drainSideEffectsSnapshot;
|
|
513
791
|
}
|
|
514
792
|
|
|
793
|
+
/** Maximum outbound body length included before the payload. */
|
|
794
|
+
declare const WORKFLOW_ORIGIN_LINE_MAX_CHARS = 500;
|
|
795
|
+
declare function buildWorkflowOriginLine(workflowIdentifier: string, messageContent: string): string;
|
|
796
|
+
declare function buildWorkflowOriginInjection(workflowIdentifier: string, messageContent: string, payload: Record<string, unknown>): string;
|
|
797
|
+
|
|
515
798
|
/**
|
|
516
799
|
* Creates a configured Liquid instance with Novu's default settings.
|
|
517
800
|
*
|
|
@@ -521,4 +804,7 @@ declare class AgentContextImpl implements AgentRuntimeContext {
|
|
|
521
804
|
*/
|
|
522
805
|
declare function createLiquidEngine(options?: LiquidOptions): Liquid;
|
|
523
806
|
|
|
524
|
-
|
|
807
|
+
declare function repairJsonString(value: string): string;
|
|
808
|
+
declare function compileJsonControlValues(values: Record<string, unknown>, context: Record<string, unknown>, liquidEngine?: ReturnType<typeof createLiquidEngine>): Promise<Record<string, unknown>>;
|
|
809
|
+
|
|
810
|
+
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 B,d as G,e as H,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-Q3ALQWIF.js";import"../chunk-X5AZIKIR.js";import"../chunk-RBTQQ5IZ.js";import{e as g,f as u}from"../chunk-UXO4RWZV.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,G as ExecutionEventControlsInvalidError,B as ExecutionEventPayloadInvalidError,Q as ExecutionProviderOutputInvalidError,H 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 +1 @@
|
|
|
1
|
-
import"./chunk-2GCKOQK4.js";import"./chunk-
|
|
1
|
+
import"./chunk-2GCKOQK4.js";import"./chunk-7C3QBYLB.js";import{A as x,B as e,C as j,z as s}from"./chunk-RBTQQ5IZ.js";import"./chunk-FHYMHX3T.js";export{j as Fragment,s as jsx,e as jsxDEV,x as jsxs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-7C3QBYLB.js";import{A as c,B as d,C as e,D as f,E as g,F as h,y as a,z as b}from"./chunk-RBTQQ5IZ.js";import"./chunk-FHYMHX3T.js";export{e as Fragment,a as isCardLinkProps,h as isJSX,b as jsx,d as jsxDEV,c as jsxs,f as toCardElement,g as toModalElement};
|
package/dist/esm/jsx-runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-2GCKOQK4.js";import"./chunk-
|
|
1
|
+
import"./chunk-2GCKOQK4.js";import"./chunk-7C3QBYLB.js";import{A as b,B as c,C as d,z as a}from"./chunk-RBTQQ5IZ.js";import"./chunk-FHYMHX3T.js";export{d as Fragment,a as jsx,c as jsxDEV,b as jsxs};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
import {
|
|
2
|
+
import { l as AgentHistoryEntry, j as AgentHandlerContext, M as MessageContent, k as AgentHandlers, m as AgentMessage, o as AgentMessageContext, y as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent } from '../agent.types-C17NUGxY.js';
|
|
3
3
|
import { LanguageModelLike } from '@langchain/core/language_models/base';
|
|
4
|
+
import { RunnableConfig } from '@langchain/core/runnables';
|
|
4
5
|
import { StructuredToolInterface } from '@langchain/core/tools';
|
|
5
6
|
import { AgentMiddleware } from 'langchain';
|
|
6
7
|
import { A as Awaitable } from '../util.types-DaFfsxgy.js';
|
|
@@ -13,10 +14,13 @@ interface ToolResultPayload {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* Convert
|
|
17
|
+
* Convert conversation context into LangChain `BaseMessage[]` for `createAgent().invoke(...)`.
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
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`.
|
|
20
24
|
*
|
|
21
25
|
* @param system - Optional system prompt prepended as a `SystemMessage`. Omit it when the
|
|
22
26
|
* agent already receives a prompt (e.g. via `createAgent({ prompt })`) to avoid duplication.
|
|
@@ -24,6 +28,17 @@ interface ToolResultPayload {
|
|
|
24
28
|
* with a fresh result are replayed as resolved call+result pairs.
|
|
25
29
|
*/
|
|
26
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[]>;
|
|
27
42
|
|
|
28
43
|
/** A tool call surfaced to `needsApproval` before it executes. */
|
|
29
44
|
interface LangChainToolCall {
|
|
@@ -39,7 +54,11 @@ interface LangChainToolCall {
|
|
|
39
54
|
* `ctx.history` — no LangGraph checkpointer required.
|
|
40
55
|
*/
|
|
41
56
|
interface LangChainAgentConfig {
|
|
42
|
-
/**
|
|
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
|
+
*/
|
|
43
62
|
model: string | LanguageModelLike;
|
|
44
63
|
/** Tools available to the agent. */
|
|
45
64
|
tools?: StructuredToolInterface[];
|
|
@@ -49,6 +68,19 @@ interface LangChainAgentConfig {
|
|
|
49
68
|
needsApproval?: (toolCall: LangChainToolCall) => boolean;
|
|
50
69
|
/** Extra LangChain middleware, appended after Novu's approval middleware. */
|
|
51
70
|
middleware?: AgentMiddleware[];
|
|
71
|
+
/**
|
|
72
|
+
* Run config forwarded as the second argument to `agent.invoke(...)` (e.g.
|
|
73
|
+
* `signal`, `configurable`, `context`, `recursionLimit`, `callbacks`). Use this
|
|
74
|
+
* to control the LangGraph run for a turn.
|
|
75
|
+
*/
|
|
76
|
+
invokeConfig?: RunnableConfig;
|
|
77
|
+
/**
|
|
78
|
+
* Optional post-run reply formatter. Receives the model's final text and returns
|
|
79
|
+
* the content to deliver — a string or a {@link MessageContent} card. Return
|
|
80
|
+
* `void`/`undefined` to deliver the final text unchanged. Runs only when the
|
|
81
|
+
* model produced a non-empty final text.
|
|
82
|
+
*/
|
|
83
|
+
formatReply?: (finalText: string) => Awaitable<MessageContent | void>;
|
|
52
84
|
}
|
|
53
85
|
/**
|
|
54
86
|
* Result of a LangChain agent/graph you invoked yourself (e.g. `await agent.invoke(...)`).
|
|
@@ -103,4 +135,4 @@ declare class NovuToolApprovalRequired extends Error {
|
|
|
103
135
|
});
|
|
104
136
|
}
|
|
105
137
|
|
|
106
|
-
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,11 +1,11 @@
|
|
|
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-CYtGHJJu.js';
|
|
2
|
+
export { C as Client, N as NovuRequestHandler, a as agent, i as isFromWorkflow, w as workflow } from '../index-CYtGHJJu.js';
|
|
3
|
+
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-CL5-B_D4.js';
|
|
4
|
+
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-D4PvRIKR.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
|
|
8
|
-
export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from '../step-resolver.js';
|
|
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 AgentMessage, n as AgentMessageAuthor, o as AgentMessageContext, p as AgentNotification, q as AgentPlatformContext, r as AgentReaction, s as AgentReactionContext, t as AgentResolveContext, u as AgentSubscriber, v as AgentSubscriberAccess, w as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, x as ToolApprovalConfig, y as ToolApprovalDecision, z as toAgentError } from '../agent.types-C17NUGxY.js';
|
|
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';
|
|
11
11
|
import 'json-schema-to-ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as N,c as a,d as k,e as i}from"../chunk-WJUYDVXH.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-Q3ALQWIF.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-UXO4RWZV.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};
|