@novu/framework 2.11.1 → 2.11.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -9
- package/ai-sdk/package.json +4 -0
- package/cards/package.json +4 -0
- package/dist/{esm/index-D6L0Yufw.d.ts → cjs/agent.types-Dqm2VBTO.d.cts} +410 -193
- package/dist/cjs/ai-sdk/index.cjs +1 -0
- package/dist/cjs/ai-sdk/index.d.cts +40 -0
- package/dist/cjs/cards.cjs +57 -0
- package/dist/cjs/cards.d.cts +2 -0
- package/dist/cjs/{health-check.types-D4NEyjyC.d.cts → health-check.types-B9FbzRbm.d.cts} +6 -140
- package/dist/cjs/index-1DobCKAF.d.cts +160 -0
- package/dist/cjs/index.cjs +138 -138
- package/dist/cjs/index.d.cts +5 -3
- package/dist/cjs/internal/index.cjs +1 -1
- package/dist/cjs/internal/index.d.cts +98 -4
- package/dist/cjs/jsx-dev-runtime.cjs +1 -1
- package/dist/cjs/jsx-runtime.cjs +1 -1
- package/dist/cjs/langchain/index.cjs +1 -0
- package/dist/cjs/langchain/index.d.cts +106 -0
- package/dist/cjs/servers/express.cjs +138 -138
- package/dist/cjs/servers/express.d.cts +6 -4
- package/dist/cjs/servers/h3.cjs +137 -137
- package/dist/cjs/servers/h3.d.cts +6 -4
- package/dist/cjs/servers/lambda.cjs +137 -137
- package/dist/cjs/servers/lambda.d.cts +6 -5
- package/dist/cjs/servers/nest.cjs +138 -138
- package/dist/cjs/servers/nest.d.cts +21 -7
- package/dist/cjs/servers/next.cjs +137 -137
- package/dist/cjs/servers/next.d.cts +6 -4
- package/dist/cjs/servers/nuxt.cjs +137 -137
- package/dist/cjs/servers/nuxt.d.cts +6 -4
- package/dist/cjs/servers/remix.cjs +137 -137
- package/dist/cjs/servers/remix.d.cts +6 -4
- package/dist/cjs/servers/sveltekit.cjs +137 -137
- package/dist/cjs/servers/sveltekit.d.cts +6 -4
- package/dist/cjs/step-resolver.cjs +1 -1
- package/dist/cjs/step-resolver.d.cts +3 -2
- package/dist/cjs/{subscriber.types-PRaHFLJu.d.cts → subscriber.types-DubxcL8q.d.cts} +18 -78
- package/dist/cjs/util.types-DaFfsxgy.d.cts +78 -0
- package/dist/cjs/validators.cjs +1 -1
- package/dist/{cjs/index-BNiIiOE-.d.cts → esm/agent.types-E3sxq6xr.d.ts} +410 -193
- package/dist/esm/ai-sdk/index.d.ts +40 -0
- package/dist/esm/ai-sdk/index.js +1 -0
- package/dist/esm/cards.d.ts +2 -0
- package/dist/esm/cards.js +1 -0
- package/dist/esm/{chunk-DKQLYSZS.js → chunk-22DBAEUX.js} +1 -1
- package/dist/esm/{chunk-KLCBNFAF.js → chunk-3XT6S7TZ.js} +14 -14
- package/dist/esm/chunk-3ZWME5KT.js +0 -0
- package/dist/esm/chunk-C3P3ZH2I.js +36 -0
- package/dist/esm/{chunk-QTWEINJ4.js → chunk-CANJPWLT.js} +1 -1
- package/dist/esm/chunk-E2MET7IR.js +1 -0
- package/dist/esm/chunk-FHYMHX3T.js +1 -0
- package/dist/esm/chunk-Q6BV36LU.js +98 -0
- package/dist/esm/chunk-W6DIBD4Z.js +1 -0
- package/dist/esm/{health-check.types-C-81VaBO.d.ts → health-check.types-BNocZ4Wk.d.ts} +6 -140
- package/dist/esm/index-aVljLqR4.d.ts +160 -0
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +98 -4
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/jsx-dev-runtime.js +1 -1
- package/dist/esm/jsx-runtime-7EPQR56T.js +1 -0
- package/dist/esm/jsx-runtime.js +1 -1
- package/dist/esm/langchain/index.d.ts +106 -0
- package/dist/esm/langchain/index.js +1 -0
- package/dist/esm/servers/express.d.ts +6 -4
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +6 -4
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/lambda.d.ts +6 -5
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +21 -7
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +6 -4
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +6 -4
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +6 -4
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +6 -4
- 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-CC7F0JO_.d.ts → subscriber.types-CmybpXhA.d.ts} +18 -78
- package/dist/esm/util.types-DaFfsxgy.d.ts +78 -0
- package/dist/esm/validators.js +1 -1
- package/package.json +56 -8
- package/dist/esm/chunk-52LSX2V5.js +0 -1
- package/dist/esm/chunk-N4PZBM53.js +0 -1
- package/dist/esm/chunk-ND6IQFTA.js +0 -133
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { i as AgentHandlers, A as Agent } from './agent.types-E3sxq6xr.js';
|
|
2
|
+
import { L as Logger, C as ClientOptions, W as Workflow, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-BNocZ4Wk.js';
|
|
3
|
+
import { A as Awaitable } from './util.types-DaFfsxgy.js';
|
|
4
|
+
import 'chat';
|
|
5
|
+
import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.js';
|
|
6
|
+
import './step-resolver.js';
|
|
7
|
+
import './subscriber.types-CmybpXhA.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Define a new conversational agent.
|
|
11
|
+
*
|
|
12
|
+
* @param agentId - Unique identifier matching the agent entity created in Novu (e.g. 'wine-bot')
|
|
13
|
+
* @param handlers - Handler functions for agent events
|
|
14
|
+
*/
|
|
15
|
+
declare function agent(agentId: string, handlers: AgentHandlers): Agent;
|
|
16
|
+
|
|
17
|
+
declare class Client {
|
|
18
|
+
private discoveredWorkflows;
|
|
19
|
+
private discoverWorkflowPromises;
|
|
20
|
+
private registeredAgents;
|
|
21
|
+
private templateEngine;
|
|
22
|
+
secretKey: string;
|
|
23
|
+
apiUrl: string;
|
|
24
|
+
version: string;
|
|
25
|
+
strictAuthentication: boolean;
|
|
26
|
+
verbose: boolean;
|
|
27
|
+
logger: Logger;
|
|
28
|
+
constructor(options?: ClientOptions);
|
|
29
|
+
private buildOptions;
|
|
30
|
+
private log;
|
|
31
|
+
/**
|
|
32
|
+
* Adds workflows to the client.
|
|
33
|
+
*
|
|
34
|
+
* A locking mechanism is used to ensure that duplicate workflows are not added.
|
|
35
|
+
*
|
|
36
|
+
* @param workflows - The workflows to add.
|
|
37
|
+
*/
|
|
38
|
+
addWorkflows(workflows: Array<Workflow>): Promise<void>;
|
|
39
|
+
addAgents(agents: Array<Agent>): void;
|
|
40
|
+
getAgent(agentId: string): Agent | undefined;
|
|
41
|
+
private addWorkflow;
|
|
42
|
+
healthCheck(): HealthCheck;
|
|
43
|
+
private getWorkflow;
|
|
44
|
+
private getStep;
|
|
45
|
+
private getRegisteredWorkflows;
|
|
46
|
+
discover(): DiscoverOutput;
|
|
47
|
+
/**
|
|
48
|
+
* Mocks data based on the given schema.
|
|
49
|
+
* The `default` value in the schema is used as the base data.
|
|
50
|
+
* If no `default` value is provided, the data is generated using JSONSchemaFaker.
|
|
51
|
+
*
|
|
52
|
+
* @param schema
|
|
53
|
+
* @returns mocked data
|
|
54
|
+
*/
|
|
55
|
+
private mock;
|
|
56
|
+
private validate;
|
|
57
|
+
private throwInvalidProvider;
|
|
58
|
+
private throwInvalidStep;
|
|
59
|
+
private throwInvalidEvent;
|
|
60
|
+
private executeStepFactory;
|
|
61
|
+
private shouldSanitize;
|
|
62
|
+
private shouldSkip;
|
|
63
|
+
executeWorkflow(event: Event): Promise<ExecuteOutput>;
|
|
64
|
+
private createExecutionPayload;
|
|
65
|
+
private prettyPrintExecute;
|
|
66
|
+
private executeProviders;
|
|
67
|
+
private previewProvider;
|
|
68
|
+
private executeProvider;
|
|
69
|
+
private executeStep;
|
|
70
|
+
private compileControls;
|
|
71
|
+
/**
|
|
72
|
+
* Preprocesses standalone translation patterns.
|
|
73
|
+
* Transforms {{t.key}} to [T:key] placeholder (not Liquid syntax, passes through unchanged).
|
|
74
|
+
*/
|
|
75
|
+
private preprocessTranslationPatterns;
|
|
76
|
+
/**
|
|
77
|
+
* Preprocesses translation keys used as filter arguments.
|
|
78
|
+
* Transforms 't.key' to '[T:key]' placeholder (not Liquid syntax, passes through unchanged).
|
|
79
|
+
* Example: pluralize: 't.apple', 't.apples' → pluralize: '[T:apple]', '[T:apples]'
|
|
80
|
+
*/
|
|
81
|
+
private preprocessFilterTranslationArgs;
|
|
82
|
+
/**
|
|
83
|
+
* Post-processes placeholders back to translation markers after Liquid render.
|
|
84
|
+
* Transforms [T:key] back to {{t.key}} for the translation service.
|
|
85
|
+
*/
|
|
86
|
+
private postprocessTranslationMarkers;
|
|
87
|
+
/**
|
|
88
|
+
* Create the controls for a step, taking both the event controls and the default controls into account
|
|
89
|
+
*
|
|
90
|
+
* @param step The step to create the controls for
|
|
91
|
+
* @param event The event that triggered the step
|
|
92
|
+
* @returns The controls for the step
|
|
93
|
+
*/
|
|
94
|
+
private createStepControls;
|
|
95
|
+
private previewStep;
|
|
96
|
+
private constructStepForPreview;
|
|
97
|
+
private extractMockDataForPreviousSteps;
|
|
98
|
+
private previewRequiredStep;
|
|
99
|
+
private getStepState;
|
|
100
|
+
private getStepCode;
|
|
101
|
+
private getWorkflowCode;
|
|
102
|
+
getCode(workflowId: string, stepId?: string): CodeResult;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface ServeHandlerOptions {
|
|
106
|
+
client?: Client;
|
|
107
|
+
workflows?: Array<Workflow>;
|
|
108
|
+
agents?: Array<Agent>;
|
|
109
|
+
}
|
|
110
|
+
type INovuRequestHandlerOptions<Input extends any[] = any[], Output = any> = ServeHandlerOptions & {
|
|
111
|
+
frameworkName: string;
|
|
112
|
+
client?: Client;
|
|
113
|
+
workflows?: Array<Workflow>;
|
|
114
|
+
agents?: Array<Agent>;
|
|
115
|
+
handler: Handler<Input, Output>;
|
|
116
|
+
};
|
|
117
|
+
type Handler<Input extends any[] = any[], Output = any> = (...args: Input) => HandlerResponse<Output>;
|
|
118
|
+
type HandlerResponse<Output = any> = {
|
|
119
|
+
body: () => Awaitable<any>;
|
|
120
|
+
headers: (key: string) => Awaitable<string | null | undefined>;
|
|
121
|
+
method: () => Awaitable<string>;
|
|
122
|
+
queryString?: (key: string, url: URL) => Awaitable<string | null | undefined>;
|
|
123
|
+
url: () => Awaitable<URL>;
|
|
124
|
+
transformResponse: (res: IActionResponse<string>) => Output;
|
|
125
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
126
|
+
};
|
|
127
|
+
type IActionResponse<TBody extends string = string> = {
|
|
128
|
+
status: number;
|
|
129
|
+
headers: Record<string, string>;
|
|
130
|
+
body: TBody;
|
|
131
|
+
};
|
|
132
|
+
declare class NovuRequestHandler<Input extends any[] = any[], Output = any> {
|
|
133
|
+
readonly frameworkName: string;
|
|
134
|
+
readonly handler: Handler<Input, Output>;
|
|
135
|
+
readonly client: Client;
|
|
136
|
+
private readonly hmacEnabled;
|
|
137
|
+
private readonly http;
|
|
138
|
+
private readonly workflows;
|
|
139
|
+
private readonly agents;
|
|
140
|
+
constructor(options: INovuRequestHandlerOptions<Input, Output>);
|
|
141
|
+
createHandler(): (...args: Input) => Promise<Output>;
|
|
142
|
+
private getStaticHeaders;
|
|
143
|
+
private createResponse;
|
|
144
|
+
private createError;
|
|
145
|
+
private handleAction;
|
|
146
|
+
private getPostActionMap;
|
|
147
|
+
triggerAction(triggerEvent: EventTriggerParams): () => Promise<IActionResponse<string>>;
|
|
148
|
+
private getGetActionMap;
|
|
149
|
+
private handlePostAction;
|
|
150
|
+
private handleGetAction;
|
|
151
|
+
private handleError;
|
|
152
|
+
private validateHmac;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Define a new notification workflow.
|
|
157
|
+
*/
|
|
158
|
+
declare function workflow<T_PayloadSchema extends Schema, T_ControlSchema extends Schema, T_EnvSchema extends Schema, T_PayloadValidated extends Record<string, unknown> = FromSchema<T_PayloadSchema>, T_PayloadUnvalidated extends Record<string, unknown> = FromSchemaUnvalidated<T_PayloadSchema>, T_Controls extends Record<string, unknown> = FromSchema<T_ControlSchema>, T_Env extends Record<string, unknown> = FromSchema<T_EnvSchema>>(workflowId: string, execute: Execute<T_PayloadValidated, T_Controls, T_Env>, workflowOptions?: WorkflowOptions<T_PayloadSchema, T_ControlSchema, T_EnvSchema>): Workflow<T_PayloadUnvalidated>;
|
|
159
|
+
|
|
160
|
+
export { Client as C, type INovuRequestHandlerOptions as I, NovuRequestHandler as N, type ServeHandlerOptions as S, agent as a, workflow as w };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-
|
|
1
|
+
export { C as Client, N as NovuRequestHandler, S as ServeHandlerOptions, a as agent, w as workflow } from './index-aVljLqR4.js';
|
|
2
|
+
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-BNocZ4Wk.js';
|
|
3
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 AgentConversation, f as AgentDeliveryError, g as AgentError, h as AgentHandlerContext, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentResolveContext, r as AgentSubscriber, s as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, t as ToolApprovalConfig, u as ToolApprovalDecision, v as toAgentError } from './agent.types-E3sxq6xr.js';
|
|
4
5
|
export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from './step-resolver.js';
|
|
5
|
-
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-CmybpXhA.js';
|
|
7
|
+
import './util.types-DaFfsxgy.js';
|
|
6
8
|
import './base.schema.types-BApIn9jr.js';
|
|
7
9
|
import 'json-schema-to-ts';
|
|
8
10
|
import 'zod';
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b,c,d,e,f,g,h,i
|
|
1
|
+
import{b as k,c as o,d as p,e as s}from"./chunk-Q6BV36LU.js";import{a,b,c,d,e,f,g,h,i}from"./chunk-C3P3ZH2I.js";import"./chunk-3XT6S7TZ.js";import{a as t}from"./chunk-2M25EATE.js";import"./chunk-22DBAEUX.js";import{M as l,N as m,O as n,V as r}from"./chunk-E2MET7IR.js";import{a as q}from"./chunk-CANJPWLT.js";import{f as j}from"./chunk-FRWG7YTE.js";import"./chunk-W6DIBD4Z.js";import"./chunk-FHYMHX3T.js";export{a as Actions,m as AgentDeliveryError,l as AgentError,b as Button,c as Card,d as CardLink,e as CardText,k as Client,j as CronExpression,f as Divider,o as NovuRequestHandler,g as Select,h as SelectOption,r as SeverityLevelEnum,i as TextInput,p as agent,q as providerSchemas,t as step,n as toAgentError,s as workflow};
|
|
@@ -1,9 +1,13 @@
|
|
|
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 {
|
|
1
|
+
import { P as PostActionEnum } from '../health-check.types-BNocZ4Wk.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-BNocZ4Wk.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 actionStepSchemas, $ as channelStepSchemas } from '../subscriber.types-CmybpXhA.js';
|
|
4
4
|
import { Filter, LiquidOptions, Liquid } from 'liquidjs';
|
|
5
|
+
import { Emoji } from 'chat';
|
|
6
|
+
import { h as AgentHandlerContext, z as ToolResult, B as ToolApprovalRequestPayload, T as ToolApprovalCard, R as ReplyHandle, m as AgentMessageContext, C as AgentEventEnum, a as AgentAction, k as AgentMessage, o as AgentReaction, e as AgentConversation, r as AgentSubscriber, j as AgentHistoryEntry, n as AgentPlatformContext, D as TypingControl, E as ToolApprovalControl, G as AgentBridgeRequest, t as ToolApprovalConfig, M as MessageContent, F as FileRef, H as AgentReplyPayload, S as SentMessageInfo, w as TriggerRecipientsPayload } from '../agent.types-E3sxq6xr.js';
|
|
7
|
+
export { J as DeleteMessagePayload, K as EditPayload, L as MetadataSignal, P as ParsedApprovalAction, N as ReplyContent, O as Signal, Q as TriggerSignal, U as buildApprovalActionId, V as parseApprovalActionId } from '../agent.types-E3sxq6xr.js';
|
|
5
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';
|
|
6
9
|
export { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
|
|
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';
|
|
7
11
|
export { a as ValidateFunction, V as ValidateResult, b as ValidationError, c as Validator } from '../validator.types-BIQli_m1.js';
|
|
8
12
|
import 'json-schema-to-ts';
|
|
9
13
|
import 'zod';
|
|
@@ -418,6 +422,96 @@ type FilterValidators = {
|
|
|
418
422
|
};
|
|
419
423
|
declare const FILTER_VALIDATORS: FilterValidators;
|
|
420
424
|
|
|
425
|
+
declare const RUNTIME_CONTEXT_BRAND: unique symbol;
|
|
426
|
+
interface AgentRuntimeContext extends AgentHandlerContext {
|
|
427
|
+
readonly [RUNTIME_CONTEXT_BRAND]: true;
|
|
428
|
+
emitToolResult(result: ToolResult): void;
|
|
429
|
+
emitToolApprovalRequest(request: ToolApprovalRequestPayload): void;
|
|
430
|
+
replyApprovalCard(card: ToolApprovalCard): Promise<ReplyHandle>;
|
|
431
|
+
asMessageContext(): AgentMessageContext;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
interface ReplyPoster {
|
|
435
|
+
post(body: AgentReplyPayload): Promise<SentMessageInfo | null>;
|
|
436
|
+
}
|
|
437
|
+
declare class ReplyHandleImpl implements ReplyHandle {
|
|
438
|
+
private readonly conversationId;
|
|
439
|
+
private readonly integrationIdentifier;
|
|
440
|
+
private readonly poster;
|
|
441
|
+
messageId: string;
|
|
442
|
+
platformThreadId: string;
|
|
443
|
+
/** @internal set when the handler calls `edit()`; dispatch skips default approval card cleanup. */
|
|
444
|
+
editedByHandler: boolean;
|
|
445
|
+
constructor(messageId: string, platformThreadId: string, conversationId: string, integrationIdentifier: string, poster: ReplyPoster);
|
|
446
|
+
edit(content: MessageContent, options?: {
|
|
447
|
+
files?: FileRef[];
|
|
448
|
+
}): Promise<ReplyHandle>;
|
|
449
|
+
delete(): Promise<void>;
|
|
450
|
+
}
|
|
451
|
+
declare class AgentContextImpl implements AgentRuntimeContext {
|
|
452
|
+
readonly [RUNTIME_CONTEXT_BRAND] = true;
|
|
453
|
+
readonly event: AgentEventEnum;
|
|
454
|
+
readonly action: AgentAction | null;
|
|
455
|
+
readonly message: AgentMessage | null;
|
|
456
|
+
readonly reaction: AgentReaction | null;
|
|
457
|
+
readonly conversation: AgentConversation;
|
|
458
|
+
readonly subscriber: AgentSubscriber | null;
|
|
459
|
+
readonly history: AgentHistoryEntry[];
|
|
460
|
+
readonly platform: string;
|
|
461
|
+
readonly platformContext: AgentPlatformContext;
|
|
462
|
+
readonly typing: TypingControl;
|
|
463
|
+
readonly toolApproval: ToolApprovalControl;
|
|
464
|
+
readonly metadata: {
|
|
465
|
+
get(key: string): unknown;
|
|
466
|
+
set(key: string, value: unknown): void;
|
|
467
|
+
delete(key: string): void;
|
|
468
|
+
clear(): void;
|
|
469
|
+
readonly current: Readonly<Record<string, unknown>>;
|
|
470
|
+
};
|
|
471
|
+
private _signals;
|
|
472
|
+
private _toolResults;
|
|
473
|
+
private _pendingToolApprovalRequest;
|
|
474
|
+
private _pendingReactions;
|
|
475
|
+
private _pendingDeletes;
|
|
476
|
+
private _resolveSignal;
|
|
477
|
+
private _metadataState;
|
|
478
|
+
private readonly _toolApprovalConfig?;
|
|
479
|
+
private readonly _replyUrl;
|
|
480
|
+
private readonly _conversationId;
|
|
481
|
+
private readonly _integrationIdentifier;
|
|
482
|
+
private readonly _secretKey;
|
|
483
|
+
private readonly _poster;
|
|
484
|
+
constructor(request: AgentBridgeRequest, secretKey: string, toolApprovalConfig?: ToolApprovalConfig);
|
|
485
|
+
asMessageContext(): AgentMessageContext;
|
|
486
|
+
reply(content: MessageContent, options?: {
|
|
487
|
+
files?: FileRef[];
|
|
488
|
+
}): Promise<ReplyHandle>;
|
|
489
|
+
replyApprovalCard(card: ToolApprovalCard): Promise<ReplyHandle>;
|
|
490
|
+
/** @internal Build a handle to an already-posted message (used to resume an approval). */
|
|
491
|
+
createReplyHandle(messageId: string): ReplyHandleImpl;
|
|
492
|
+
resolve(summary?: string): void;
|
|
493
|
+
trigger(workflowId: string, opts?: {
|
|
494
|
+
to?: TriggerRecipientsPayload;
|
|
495
|
+
payload?: Record<string, unknown>;
|
|
496
|
+
}): void;
|
|
497
|
+
/** @internal Queue a gated tool call for the ledger; flushed with the next reply. */
|
|
498
|
+
emitToolApprovalRequest(request: ToolApprovalRequestPayload): void;
|
|
499
|
+
/** @internal Queue a tool-call outcome to be recorded in history; flushed with the next reply. */
|
|
500
|
+
emitToolResult(result: ToolResult): void;
|
|
501
|
+
addReaction(messageId: string, emojiName: Emoji): void;
|
|
502
|
+
deleteMessage(messageId: string): void;
|
|
503
|
+
/** Best-effort failure report to Novu. Never throws. */
|
|
504
|
+
reportTurnError(): Promise<void>;
|
|
505
|
+
/**
|
|
506
|
+
* Flush any remaining signals that weren't sent with reply().
|
|
507
|
+
* Called internally after onResolve returns.
|
|
508
|
+
*/
|
|
509
|
+
flush(): Promise<void>;
|
|
510
|
+
private _hasPendingSideEffects;
|
|
511
|
+
private _drainSideEffects;
|
|
512
|
+
private _post;
|
|
513
|
+
}
|
|
514
|
+
|
|
421
515
|
/**
|
|
422
516
|
* Creates a configured Liquid instance with Novu's default settings.
|
|
423
517
|
*
|
|
@@ -427,4 +521,4 @@ declare const FILTER_VALIDATORS: FilterValidators;
|
|
|
427
521
|
*/
|
|
428
522
|
declare function createLiquidEngine(options?: LiquidOptions): Liquid;
|
|
429
523
|
|
|
430
|
-
export { BadRequestError, BridgeError, ConflictError, 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, ResourceConflictError, ResourceEnum, ResourceExecutionFailed, ResourceNotFoundError, SIGNATURE_TIMESTAMP_TOLERANCE, SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES, ServerError, SignatureExpiredError, SignatureInvalidError, SignatureMismatchError, SignatureNotFoundError, SignatureVersionInvalidError, SigningKeyNotFoundError, StepAlreadyExistsError, StepControlCompilationFailedError, StepExecutionFailedError, StepNotFoundError, UnauthorizedError, WorkflowAlreadyExistsError, WorkflowNotFoundError, WorkflowPayloadInvalidError, createLiquidEngine, digest, isFrameworkError, isNativeError, pluralize, toSentence, toSentenceArgsValidator };
|
|
524
|
+
export { AgentBridgeRequest, AgentContextImpl, AgentEventEnum, AgentReplyPayload, type AgentRuntimeContext, BadRequestError, BridgeError, ConflictError, 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, ResourceConflictError, ResourceEnum, ResourceExecutionFailed, ResourceNotFoundError, SIGNATURE_TIMESTAMP_TOLERANCE, SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES, SentMessageInfo, ServerError, SignatureExpiredError, SignatureInvalidError, SignatureMismatchError, SignatureNotFoundError, SignatureVersionInvalidError, SigningKeyNotFoundError, StepAlreadyExistsError, StepControlCompilationFailedError, StepExecutionFailedError, StepNotFoundError, ToolApprovalRequestPayload, ToolResult, UnauthorizedError, WorkflowAlreadyExistsError, WorkflowNotFoundError, WorkflowPayloadInvalidError, createLiquidEngine, digest, isFrameworkError, isNativeError, pluralize, toSentence, toSentenceArgsValidator };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as oe,B as re,C as ae,D as pe,E as ne,F as ie,H as le,I as se,J as me,K as e,L as t,P as o,S as p,U as ge,V as fe,a as C,b as M,c as D,d as b,e as k,f as B,g as O,h as _,i as j,j as w,k as z,m as G,n as H,o as J,p as K,q as N,r as Q,s as U,t as W,u as X,v as Y,w as Z,x as $,y as ee,z as te}from"../chunk-E2MET7IR.js";import{e as n,f as i}from"../chunk-CANJPWLT.js";import{a as l,b as s,c as m,d as g,e as f,f as x,g as d,h as c,i as u,j as A,k as y,l as S,m as I,n as R,o as v,p as q,q as E,r as F,s as L,t as P,u as T,v as V,w as h}from"../chunk-FRWG7YTE.js";import{d as r,e as a}from"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";var de={toSentence:e};export{R as ActionStepEnum,p as AgentContextImpl,o as AgentEventEnum,L as BadRequestError,C as BridgeError,I as ChannelStepEnum,V as ConflictError,x as CronExpression,d as ErrorCodeEnum,b as ExecutionEventControlsInvalidError,D as ExecutionEventPayloadInvalidError,j as ExecutionProviderOutputInvalidError,k as ExecutionStateControlsInvalidError,M as ExecutionStateCorruptError,B as ExecutionStateOutputInvalidError,O as ExecutionStateResultInvalidError,de as FILTER_VALIDATORS,h as ForbiddenError,E as FrameworkError,s as GetActionEnum,c as HttpHeaderKeysEnum,u as HttpMethodEnum,A as HttpQueryKeysEnum,y as HttpStatusEnum,H as InvalidActionError,ge as JobStatusEnum,G as MethodNotAllowedError,J as MissingSecretKeyError,F as NotFoundError,m as NovuApiEndpointsEnum,K as PlatformError,l as PostActionEnum,X as ProviderExecutionFailedError,W as ProviderNotFoundError,N as ResourceConflictError,S as ResourceEnum,U as ResourceExecutionFailed,Q as ResourceNotFoundError,f as SIGNATURE_TIMESTAMP_TOLERANCE,g as SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES,T as ServerError,fe as SeverityLevelEnum,ee as SignatureExpiredError,$ as SignatureInvalidError,Y as SignatureMismatchError,Z as SignatureNotFoundError,oe as SignatureVersionInvalidError,te as SigningKeyNotFoundError,ae as StepAlreadyExistsError,_ as StepControlCompilationFailedError,pe as StepExecutionFailedError,re as StepNotFoundError,P as UnauthorizedError,ie as WorkflowAlreadyExistsError,v as WorkflowChannelEnum,ne as WorkflowNotFoundError,w as WorkflowPayloadInvalidError,n as actionStepSchemas,r as buildApprovalActionId,i as channelStepSchemas,t as createLiquidEngine,le as digest,z as isFrameworkError,q as isNativeError,a as parseApprovalActionId,se as pluralize,me as toSentence,e as toSentenceArgsValidator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-2GCKOQK4.js";import{
|
|
1
|
+
import"./chunk-2GCKOQK4.js";import"./chunk-3ZWME5KT.js";import{q as s,r as x,s as e,t as j}from"./chunk-3XT6S7TZ.js";import"./chunk-FHYMHX3T.js";export{j as Fragment,s as jsx,e as jsxDEV,x as jsxs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-3ZWME5KT.js";import{p as a,q as b,r as c,s as d,t as e,u as f,v as g,w as h}from"./chunk-3XT6S7TZ.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{
|
|
1
|
+
import"./chunk-2GCKOQK4.js";import"./chunk-3ZWME5KT.js";import{q as a,r as b,s as c,t as d}from"./chunk-3XT6S7TZ.js";import"./chunk-FHYMHX3T.js";export{d as Fragment,a as jsx,c as jsxDEV,b as jsxs};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import { j as AgentHistoryEntry, i as AgentHandlers, k as AgentMessage, m as AgentMessageContext, M as MessageContent, u as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent } from '../agent.types-E3sxq6xr.js';
|
|
3
|
+
import { LanguageModelLike } from '@langchain/core/language_models/base';
|
|
4
|
+
import { StructuredToolInterface } from '@langchain/core/tools';
|
|
5
|
+
import { AgentMiddleware } from 'langchain';
|
|
6
|
+
import { A as Awaitable } from '../util.types-DaFfsxgy.js';
|
|
7
|
+
import 'chat';
|
|
8
|
+
|
|
9
|
+
interface ToolResultPayload {
|
|
10
|
+
toolCallId: string;
|
|
11
|
+
toolName?: string;
|
|
12
|
+
output: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Convert `ctx.history` into LangChain `BaseMessage[]` for `createAgent().invoke(...)`.
|
|
17
|
+
*
|
|
18
|
+
* History already includes the current incoming message — do not append the handler's
|
|
19
|
+
* `message` argument on top of it.
|
|
20
|
+
*
|
|
21
|
+
* @param system - Optional system prompt prepended as a `SystemMessage`. Omit it when the
|
|
22
|
+
* agent already receives a prompt (e.g. via `createAgent({ prompt })`) to avoid duplication.
|
|
23
|
+
* @param freshResults - Tool outputs the adapter executed this turn (approve-resume). Cycles
|
|
24
|
+
* with a fresh result are replayed as resolved call+result pairs.
|
|
25
|
+
*/
|
|
26
|
+
declare function toLangChainMessages(history: AgentHistoryEntry[], system?: string, freshResults?: Map<string, ToolResultPayload>): BaseMessage[];
|
|
27
|
+
|
|
28
|
+
/** A tool call surfaced to `needsApproval` before it executes. */
|
|
29
|
+
interface LangChainToolCall {
|
|
30
|
+
id?: string;
|
|
31
|
+
name: string;
|
|
32
|
+
args: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Declarative agent config the adapter runs on your behalf.
|
|
36
|
+
*
|
|
37
|
+
* Returning this from `onMessage` lets Novu own the tool-approval loop: gated
|
|
38
|
+
* tools pause the turn with an approval card and resume statelessly from
|
|
39
|
+
* `ctx.history` — no LangGraph checkpointer required.
|
|
40
|
+
*/
|
|
41
|
+
interface LangChainAgentConfig {
|
|
42
|
+
/** Chat model instance or `"provider:model"` identifier passed to `createAgent`. */
|
|
43
|
+
model: string | LanguageModelLike;
|
|
44
|
+
/** Tools available to the agent. */
|
|
45
|
+
tools?: StructuredToolInterface[];
|
|
46
|
+
/** System prompt for the agent (forwarded to `createAgent` as `prompt`). */
|
|
47
|
+
system?: string;
|
|
48
|
+
/** Return `true` to gate a tool call behind a Novu approval card before it runs. */
|
|
49
|
+
needsApproval?: (toolCall: LangChainToolCall) => boolean;
|
|
50
|
+
/** Extra LangChain middleware, appended after Novu's approval middleware. */
|
|
51
|
+
middleware?: AgentMiddleware[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Result of a LangChain agent/graph you invoked yourself (e.g. `await agent.invoke(...)`).
|
|
55
|
+
* Delivered as-is — tool approval is not managed by Novu on this path.
|
|
56
|
+
*/
|
|
57
|
+
interface LangChainInvokeResult {
|
|
58
|
+
messages: BaseMessage[];
|
|
59
|
+
}
|
|
60
|
+
/** Anything a `@novu/framework/langchain` handler may return for automatic delivery. */
|
|
61
|
+
type LangChainResult = LangChainAgentConfig | LangChainInvokeResult | BaseMessage;
|
|
62
|
+
/**
|
|
63
|
+
* Handlers for `@novu/framework/langchain` agents.
|
|
64
|
+
*
|
|
65
|
+
* Extends {@link AgentHandlers}: same events and config (`toolApproval`, etc.),
|
|
66
|
+
* but `onMessage` and `onToolApproval` may return a {@link LangChainResult} for
|
|
67
|
+
* automatic delivery.
|
|
68
|
+
*/
|
|
69
|
+
type LangChainAgentHandlers = Omit<AgentHandlers, 'onMessage' | 'onToolApproval'> & {
|
|
70
|
+
onMessage: (message: AgentMessage, ctx: AgentMessageContext) => Awaitable<MessageContent | LangChainResult | void>;
|
|
71
|
+
/**
|
|
72
|
+
* Optional. Auto-resumes `onMessage` after approve/deny unless you return a
|
|
73
|
+
* `LangChainResult` to drive the resume yourself.
|
|
74
|
+
*/
|
|
75
|
+
onToolApproval?: (decision: ToolApprovalDecision, ctx: AgentActionContext) => Awaitable<MessageContent | LangChainResult | ReplyHandle | void>;
|
|
76
|
+
onError?: AgentHandlers['onError'];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type LangChainMessageHandler = LangChainAgentHandlers['onMessage'];
|
|
80
|
+
/**
|
|
81
|
+
* Wrap LangChain handlers as a Novu {@link Agent}.
|
|
82
|
+
*
|
|
83
|
+
* Return a {@link import('./types').LangChainAgentConfig} from `onMessage` to let Novu run the
|
|
84
|
+
* agent and own the tool-approval loop; gated tools pause with an approval card and resume
|
|
85
|
+
* statelessly from `ctx.history`. You may also return already-produced messages, a card, or plain
|
|
86
|
+
* text. Approvals auto-resume `onMessage` unless a custom `onToolApproval` handles them.
|
|
87
|
+
*/
|
|
88
|
+
declare function agent(id: string, handlers: LangChainMessageHandler | LangChainAgentHandlers): Agent;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Thrown from the approval middleware when a gated tool is about to run. It propagates out
|
|
92
|
+
* of `agent.invoke()` so the adapter can post a Novu approval card and end the turn instead
|
|
93
|
+
* of executing the tool. The approval decision is later replayed from `ctx.history`.
|
|
94
|
+
*/
|
|
95
|
+
declare class NovuToolApprovalRequired extends Error {
|
|
96
|
+
readonly toolCallId: string;
|
|
97
|
+
readonly toolName: string;
|
|
98
|
+
readonly input?: Record<string, unknown>;
|
|
99
|
+
constructor(toolCall: {
|
|
100
|
+
toolCallId: string;
|
|
101
|
+
toolName: string;
|
|
102
|
+
input?: Record<string, unknown>;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { type LangChainAgentConfig, type LangChainAgentHandlers, type LangChainInvokeResult, type LangChainResult, type LangChainToolCall, NovuToolApprovalRequired, agent, toLangChainMessages };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as g,c as I,f as T}from"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";import{AIMessage as J,HumanMessage as V,SystemMessage as G}from"@langchain/core/messages";import{AIMessage as D,ToolMessage as w}from"@langchain/core/messages";var M="tool_approval_request",h="tool_approval_decision",x="tool_result",U=JSON.stringify({type:"execution-denied"});function m(e){var t;let o=e.toolData;if(!(!o||typeof o.approvalId!="string"||typeof o.toolCallId!="string"))return{approvalId:o.approvalId,toolCallId:o.toolCallId,name:(t=o.toolName)!=null?t:"tool",input:o.input}}function E(e){let o=e.toolData;if(!(!o||typeof o.approvalId!="string"||typeof o.approved!="boolean"))return{approvalId:o.approvalId,approved:o.approved}}function L(e){let o=e.toolData;if(!(!o||typeof o.toolCallId!="string"))return{toolCallId:o.toolCallId,toolName:o.toolName,output:o.output}}function N(e,o){let t=new Set,n=new Map,s=new Map;for(let a of e)if(a.type===M){let r=m(a);r&&s.set(r.approvalId,r.toolCallId)}else if(a.type===h){let r=E(a);r&&!r.approved&&t.add(r.approvalId)}else if(a.type===x){let r=L(a);r&&n.set(r.toolCallId,r)}if(o)for(let[a,r]of o)n.set(a,r);return{deniedApprovalIds:t,toolResults:n,approvalIdToToolCallId:s}}function j(e,o){return o.deniedApprovalIds.has(e.approvalId)?"denied":o.toolResults.has(e.toolCallId)?"resolved":"in-flight"}function R(e){var o;return new D({content:"",tool_calls:[{id:e.toolCallId,name:e.name,args:(o=e.input)!=null?o:{},type:"tool_call"}]})}function $(e){return typeof e=="string"?e:JSON.stringify(e)}function Y(e){var o;return new w({content:$(e.output),tool_call_id:e.toolCallId,name:(o=e.toolName)!=null?o:"tool"})}function z(e){return new w({content:U,tool_call_id:e.toolCallId,name:e.name,status:"error"})}function S(e,o){let t=m(e);if(!t)return[];let n=j(t,o);switch(n){case"denied":return[R(t),z(t)];case"resolved":{let s=o.toolResults.get(t.toolCallId);return s?[R(t),Y(s)]:[]}case"in-flight":return[];default:return n}}function P(e){let o=new Set,t=new Set,n=[];for(let s of e)if(s.type===M){let a=m(s);a&&n.push({approvalId:a.approvalId,toolCallId:a.toolCallId,toolName:a.name,input:a.input})}else if(s.type===h){let a=E(s);a!=null&&a.approved&&o.add(a.approvalId)}else if(s.type===x){let a=L(s);a&&t.add(a.toolCallId)}return n.filter(s=>o.has(s.approvalId)&&!t.has(s.toolCallId)).map(({toolCallId:s,toolName:a,input:r})=>({toolCallId:s,toolName:a,input:r}))}var Q="message",X="tool_approval_request";function _(e){return e==="agent"||e==="assistant"}function F(e){let o=new Set;for(let t of e)!_(t.role)&&t.role!=="system"&&t.senderName&&o.add(t.senderName);return o.size}function K(e,o){if(!e.content.trim())return;if(_(e.role))return new J(e.content);let n=o&&e.senderName?`${e.senderName}: ${e.content}`:e.content;return new V(n)}function W(e,o,t){switch(e.type){case Q:{let n=K(e,o);return n?[n]:[]}case X:return S(e,t);default:return[]}}function y(e,o,t){let n=F(e)>1,s=N(e,t),a=e.flatMap(r=>W(r,n,s));return o?[new G(o),...a]:a}import{isAIMessage as ie,isBaseMessage as q}from"@langchain/core/messages";import{createAgent as pe}from"langchain";import{isBaseMessage as Z}from"@langchain/core/messages";import{createMiddleware as ee}from"langchain";var d=class extends Error{constructor(o){super(`Tool "${o.toolName}" requires approval`),this.name="NovuToolApprovalRequired",this.toolCallId=o.toolCallId,this.toolName=o.toolName,this.input=o.input}},oe=10;function H(e){let o=e;for(let t=0;t<oe&&o!=null;t+=1){if(o instanceof d)return o;o=o.cause}}function k(e){return ee({name:"novu-tool-approval",wrapToolCall:async(o,t)=>{let{id:n,name:s,args:a}=o.toolCall,r=a!=null?a:{};if(e({id:n,name:s,args:r}))throw new d({toolCallId:n!=null?n:s,toolName:s,input:r});return t(o)}})}async function B(e,o,t){let n={id:o.toolCallId,name:o.toolName,input:o.input};await T(e,n,t)}function te(e){return Z(e)?e.content:e}function ne(e){let o=new Map;for(let t of e!=null?e:[])o.set(t.name,t);return o}async function O(e,o){var a;let t=P(o.history),n=new Map;if(t.length===0)return n;let s=ne(e);for(let r of t){let l=s.get(r.toolName);if(!l)continue;let i=te(await l.invoke((a=r.input)!=null?a:{}));n.set(r.toolCallId,{toolCallId:r.toolCallId,toolName:r.toolName,output:i}),o.emitToolResult({toolCallId:r.toolCallId,toolName:r.toolName,output:i,preview:`Tool "${r.toolName}" result`})}return n}import{isToolMessage as ae}from"@langchain/core/messages";function re(e){var t;let o=new Set;for(let n of e.history)n.type==="tool_approval_request"&&((t=n.toolData)!=null&&t.toolCallId)&&o.add(n.toolData.toolCallId);return o}function se(e,o){var n;let t=new Set(o);for(let s of e.history)s.type==="tool_result"&&((n=s.toolData)!=null&&n.toolCallId)&&t.add(s.toolData.toolCallId);return t}function le(e){return typeof e=="string"?e:JSON.stringify(e)}function A(e,o,t=new Set){var a;let n=re(o);if(n.size===0)return;let s=se(o,t);for(let r of e){if(!ae(r))continue;let l=r.tool_call_id;!n.has(l)||s.has(l)||(s.add(l),o.emitToolResult({toolCallId:l,toolName:r.name,output:le(r.content),preview:`Tool "${(a=r.name)!=null?a:l}" result`}))}}function b(e){if(typeof e!="object"||e===null)return!1;let o=e.model;return typeof o=="string"||typeof o=="object"&&o!==null}function ue(e){return typeof e=="object"&&e!==null&&Array.isArray(e.messages)}function f(e){return typeof e!="object"||e===null||I(e)?!1:q(e)||b(e)||ue(e)}function de(e){return typeof e=="string"?e:e.map(o=>{let t=o;return t.type==="text"&&typeof t.text=="string"?t.text:""}).join("")}function C(e){for(let o=e.length-1;o>=0;o-=1){let t=e[o];if(ie(t))return de(t.content).trim()}return""}async function v(e,o){if(!e){await o.typing.stop();return}await o.reply(e)}async function ge(e,o,t){var i;let n=await O(e.tools,o),s=y(o.history,void 0,n),a=[];e.needsApproval&&a.push(k(e.needsApproval)),e.middleware&&a.push(...e.middleware);let r=pe({model:e.model,tools:(i=e.tools)!=null?i:[],...e.system?{prompt:e.system}:{},...a.length>0?{middleware:a}:{}}),l;try{l=await r.invoke({messages:s})}catch(p){let u=H(p);if(u){await B(o,u,t);return}throw p}A(l.messages,o,new Set(n.keys())),await v(C(l.messages),o)}async function c(e,o,t){if(b(e)){await ge(e,o,t);return}if(q(e)){await v(C([e]),o);return}A(e.messages,o),await v(C(e.messages),o)}var fe={text:"",platformMessageId:"",author:{userId:"",fullName:"",userName:"",isBot:!1},timestamp:""};function ce(e){return typeof e=="object"&&e!==null&&"messageId"in e&&"platformThreadId"in e}function me(e,o){let t=typeof o=="function"?{onMessage:o}:o;if(typeof t.onMessage!="function")throw new Error(`agent('${e}') requires an onMessage handler`);return t}function ye(e,o){if(!e)throw new Error("agent() requires a non-empty agentId");let t=me(e,o),n=t.toolApproval,s=typeof t.onToolApproval=="function",a=async l=>{let i=g(l),p=await t.onMessage(fe,i.asMessageContext());f(p)&&await c(p,i,n)},r={onMessage:async(l,i)=>{let p=await t.onMessage(l,i);if(f(p)){await c(p,g(i),n);return}return p},onToolApproval:async(l,i)=>{let p=g(i);if(t.onToolApproval){let u=await t.onToolApproval(l,i);if(f(u)){await c(u,p,n);return}u!=null&&!ce(u)&&await p.reply(u)}await a(i)},...n&&{toolApproval:n},...t.onAction&&{onAction:t.onAction},...t.onReaction&&{onReaction:t.onReaction},...t.onResolve&&{onResolve:t.onResolve},...t.onError&&{onError:t.onError}};return{id:e,handlers:r,userOnToolApproval:s}}export{d as NovuToolApprovalRequired,ye as agent,y as toLangChainMessages};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { S as ServeHandlerOptions } from '../index-
|
|
2
|
-
export {
|
|
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-aVljLqR4.js';
|
|
2
|
+
export { C as Client, N as NovuRequestHandler, a as agent, w as workflow } from '../index-aVljLqR4.js';
|
|
3
|
+
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-BNocZ4Wk.js';
|
|
4
|
+
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CmybpXhA.js';
|
|
5
5
|
import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
|
|
6
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 AgentConversation, f as AgentDeliveryError, g as AgentError, h as AgentHandlerContext, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentResolveContext, r as AgentSubscriber, s as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, t as ToolApprovalConfig, u as ToolApprovalDecision, v as toAgentError } from '../agent.types-E3sxq6xr.js';
|
|
7
8
|
export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from '../step-resolver.js';
|
|
9
|
+
import '../util.types-DaFfsxgy.js';
|
|
8
10
|
import '../base.schema.types-BApIn9jr.js';
|
|
9
11
|
import 'json-schema-to-ts';
|
|
10
12
|
import 'zod';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as x,c as a,d as V,e as O}from"../chunk-Q6BV36LU.js";import{a as y,b as h,c,d as m,e as f,f as H,g as v,h as w,i as E}from"../chunk-C3P3ZH2I.js";import"../chunk-3XT6S7TZ.js";import{a as $}from"../chunk-2M25EATE.js";import"../chunk-22DBAEUX.js";import{M as A,N,O as R,V as k}from"../chunk-E2MET7IR.js";import{a as b}from"../chunk-CANJPWLT.js";import{f as S}from"../chunk-FRWG7YTE.js";import"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";var l="express",U=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,N as AgentDeliveryError,A as AgentError,h as Button,c as Card,m as CardLink,f as CardText,x as Client,S as CronExpression,H as Divider,a as NovuRequestHandler,v as Select,w as SelectOption,k as SeverityLevelEnum,E as TextInput,V as agent,l as frameworkName,b as providerSchemas,U as serve,$ as step,R as toAgentError,O as workflow};
|
package/dist/esm/servers/h3.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as h3 from 'h3';
|
|
2
2
|
import { H3Event } from 'h3';
|
|
3
|
-
import { S as ServeHandlerOptions } from '../index-
|
|
4
|
-
export {
|
|
5
|
-
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-
|
|
6
|
-
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-
|
|
3
|
+
import { S as ServeHandlerOptions } from '../index-aVljLqR4.js';
|
|
4
|
+
export { C as Client, N as NovuRequestHandler, a as agent, w as workflow } from '../index-aVljLqR4.js';
|
|
5
|
+
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-BNocZ4Wk.js';
|
|
6
|
+
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CmybpXhA.js';
|
|
7
7
|
import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
|
|
8
8
|
export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
|
|
9
|
+
export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentConversation, f as AgentDeliveryError, g as AgentError, h as AgentHandlerContext, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentResolveContext, r as AgentSubscriber, s as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, t as ToolApprovalConfig, u as ToolApprovalDecision, v as toAgentError } from '../agent.types-E3sxq6xr.js';
|
|
9
10
|
export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from '../step-resolver.js';
|
|
11
|
+
import '../util.types-DaFfsxgy.js';
|
|
10
12
|
import '../base.schema.types-BApIn9jr.js';
|
|
11
13
|
import 'json-schema-to-ts';
|
|
12
14
|
import 'zod';
|
package/dist/esm/servers/h3.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as E,c as t,d as b,e as $}from"../chunk-Q6BV36LU.js";import{a as l,b as y,c as H,d as S,e as i,f,g,h as N,i as w}from"../chunk-C3P3ZH2I.js";import"../chunk-3XT6S7TZ.js";import{a as B}from"../chunk-2M25EATE.js";import"../chunk-22DBAEUX.js";import{M as k,N as x,O,V as F}from"../chunk-E2MET7IR.js";import{a as q}from"../chunk-CANJPWLT.js";import{f as c}from"../chunk-FRWG7YTE.js";import"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";import{getHeader as o,getQuery as a,readBody as p,send as n,setHeaders as m}from"h3";var h="h3",L=d=>new t({frameworkName:h,...d,handler:r=>({body:()=>p(r),headers:e=>o(r,e),method:()=>r.method,url:()=>new URL(String(r.path),`${process.env.NODE_ENV==="development"?"http":"https"}://${String(o(r,"host"))}`),queryString:e=>String(a(r)[e]),transformResponse:e=>{let{res:s}=r.node;return s.statusCode=e.status,m(r,e.headers),n(r,e.body)}})}).createHandler();export{l as Actions,x as AgentDeliveryError,k as AgentError,y as Button,H as Card,S as CardLink,i as CardText,E as Client,c as CronExpression,f as Divider,t as NovuRequestHandler,g as Select,N as SelectOption,F as SeverityLevelEnum,w as TextInput,b as agent,h as frameworkName,q as providerSchemas,L as serve,B as step,O as toAgentError,$ as workflow};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as aws_lambda from 'aws-lambda';
|
|
2
2
|
import { APIGatewayProxyEventV2, APIGatewayProxyResult } from 'aws-lambda';
|
|
3
|
-
import { S as ServeHandlerOptions } from '../index-
|
|
4
|
-
export {
|
|
5
|
-
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { S as ServeHandlerOptions } from '../index-aVljLqR4.js';
|
|
4
|
+
export { C as Client, N as NovuRequestHandler, a as agent, w as workflow } from '../index-aVljLqR4.js';
|
|
5
|
+
export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-BNocZ4Wk.js';
|
|
6
|
+
export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CmybpXhA.js';
|
|
7
|
+
import { E as Either } from '../util.types-DaFfsxgy.js';
|
|
8
8
|
import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
|
|
9
9
|
export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
|
|
10
|
+
export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentConversation, f as AgentDeliveryError, g as AgentError, h as AgentHandlerContext, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentResolveContext, r as AgentSubscriber, s as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, t as ToolApprovalConfig, u as ToolApprovalDecision, v as toAgentError } from '../agent.types-E3sxq6xr.js';
|
|
10
11
|
export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from '../step-resolver.js';
|
|
11
12
|
import '../base.schema.types-BApIn9jr.js';
|
|
12
13
|
import 'json-schema-to-ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as E,c as n,d as S,e as g}from"../chunk-Q6BV36LU.js";import{a as m,b as u,c as P,d as h,e as i,f as w,g as l,h as f,i as x}from"../chunk-C3P3ZH2I.js";import"../chunk-3XT6S7TZ.js";import{a as V}from"../chunk-2M25EATE.js";import"../chunk-22DBAEUX.js";import{M as I,N as A,O as G,V as q}from"../chunk-E2MET7IR.js";import{a as b}from"../chunk-CANJPWLT.js";import{f as c}from"../chunk-FRWG7YTE.js";import"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";var p="lambda",N=y=>new n({frameworkName:p,...y,handler:r=>{let s=(e=>e.version==="2.0")(r);return{url:()=>{let e=s?r.requestContext.http.path:r.path,t=r.headers["x-forwarded-proto"]||"https",a=new URL(e,`${t}://${r.headers.host||r.headers.Host||""}`);for(let o in r.queryStringParameters)o&&a.searchParams.set(o,r.queryStringParameters[o]);return a},body:()=>{let e="{}";return r.body&&(e=r.isBase64Encoded?Buffer.from(r.body,"base64").toString():r.body),JSON.parse(e)},headers:e=>r.headers[e],queryString:e=>{var t;return(t=r.queryStringParameters)==null?void 0:t[e]},transformResponse:({body:e,status:t,headers:a})=>Promise.resolve({body:e,statusCode:t,headers:a}),method:()=>s?r.requestContext.http.method:r.httpMethod}}}).createHandler();export{m as Actions,A as AgentDeliveryError,I as AgentError,u as Button,P as Card,h as CardLink,i as CardText,E as Client,c as CronExpression,w as Divider,n as NovuRequestHandler,l as Select,f as SelectOption,q as SeverityLevelEnum,x as TextInput,S as agent,p as frameworkName,b as providerSchemas,N as serve,V as step,G as toAgentError,g as workflow};
|