@minded-ai/mindedjs 1.0.78-beta-2 → 1.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +136 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +142 -4
- package/dist/agent.js.map +1 -1
- package/dist/events/AgentEvents.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/nodes/addAppToolNode.d.ts.map +1 -1
- package/dist/nodes/addAppToolNode.js +2 -9
- package/dist/nodes/addAppToolNode.js.map +1 -1
- package/dist/nodes/addJumpToNode.d.ts +1 -1
- package/dist/nodes/addJumpToNode.d.ts.map +1 -1
- package/dist/nodes/addJumpToNode.js +2 -2
- package/dist/nodes/addJumpToNode.js.map +1 -1
- package/dist/nodes/addPromptNode.d.ts.map +1 -1
- package/dist/nodes/addPromptNode.js +1 -10
- package/dist/nodes/addPromptNode.js.map +1 -1
- package/dist/nodes/addToolNode.js +1 -1
- package/dist/nodes/addToolNode.js.map +1 -1
- package/dist/nodes/addTriggerNode.js +1 -1
- package/dist/nodes/addTriggerNode.js.map +1 -1
- package/dist/types/Agent.types.d.ts +13 -22
- package/dist/types/Agent.types.d.ts.map +1 -1
- package/dist/types/Agent.types.js +7 -9
- package/dist/types/Agent.types.js.map +1 -1
- package/dist/types/Flows.types.d.ts +1 -1
- package/dist/types/Flows.types.d.ts.map +1 -1
- package/dist/types/LangGraph.types.d.ts +45 -3
- package/dist/types/LangGraph.types.d.ts.map +1 -1
- package/dist/types/LangGraph.types.js +5 -0
- package/dist/types/LangGraph.types.js.map +1 -1
- package/package.json +1 -1
- package/src/agent.ts +146 -5
- package/src/events/AgentEvents.ts +2 -2
- package/src/index.ts +1 -8
- package/src/nodes/addAppToolNode.ts +3 -10
- package/src/nodes/addJumpToNode.ts +9 -3
- package/src/nodes/addPromptNode.ts +2 -10
- package/src/nodes/addToolNode.ts +2 -2
- package/src/nodes/addTriggerNode.ts +1 -1
- package/src/types/Agent.types.ts +14 -24
- package/src/types/Flows.types.ts +2 -2
- package/src/types/LangGraph.types.ts +10 -2
- package/dist/utils/history.d.ts +0 -3
- package/dist/utils/history.d.ts.map +0 -1
- package/dist/utils/history.js +0 -12
- package/dist/utils/history.js.map +0 -1
- package/src/utils/history.ts +0 -9
|
@@ -4,7 +4,7 @@ exports.addTriggerNode = void 0;
|
|
|
4
4
|
const logger_1 = require("../utils/logger");
|
|
5
5
|
const addTriggerNode = async ({ graph, node }) => {
|
|
6
6
|
const callback = async () => {
|
|
7
|
-
logger_1.logger.info(`Executing trigger node ${node.
|
|
7
|
+
logger_1.logger.info(`Executing trigger node ${node.name}`);
|
|
8
8
|
return;
|
|
9
9
|
};
|
|
10
10
|
graph.addNode(node.name, callback);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addTriggerNode.js","sourceRoot":"","sources":["../../src/nodes/addTriggerNode.ts"],"names":[],"mappings":";;;AAGA,4CAAyC;AAElC,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAkD,EAAE,EAAE;IACtG,MAAM,QAAQ,GAAiB,KAAK,IAAI,EAAE;QACxC,eAAM,CAAC,IAAI,CAAC,0BAA0B,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"addTriggerNode.js","sourceRoot":"","sources":["../../src/nodes/addTriggerNode.ts"],"names":[],"mappings":";;;AAGA,4CAAyC;AAElC,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAkD,EAAE,EAAE;IACtG,MAAM,QAAQ,GAAiB,KAAK,IAAI,EAAE;QACxC,eAAM,CAAC,IAAI,CAAC,0BAA0B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,OAAO;IACT,CAAC,CAAC;IAEF,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAC;AAPW,QAAA,cAAc,kBAOzB"}
|
|
@@ -23,31 +23,22 @@ export interface AgentInvokeParams {
|
|
|
23
23
|
/** Optional name of the application triggering the agent in case of an app trigger */
|
|
24
24
|
appName?: string;
|
|
25
25
|
}
|
|
26
|
-
export declare enum
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
APP_ACTION_NODE = "appActionNode",
|
|
30
|
-
CUSTOM_ACTION_NODE = "customActionNode",
|
|
31
|
-
PROMPT_NODE = "promptNode"
|
|
26
|
+
export declare enum FlowHistoryType {
|
|
27
|
+
TRIGGER_INVOCATION = "triggerInvocation",
|
|
28
|
+
APP_ACTION_INVOCATION = "appActionInvocation"
|
|
32
29
|
}
|
|
33
|
-
export interface
|
|
34
|
-
type:
|
|
35
|
-
step: number;
|
|
36
|
-
raw: any;
|
|
37
|
-
nodeId: string;
|
|
38
|
-
nodeDisplayName: string;
|
|
39
|
-
messageId?: string;
|
|
30
|
+
export interface FlowHistory {
|
|
31
|
+
type: FlowHistoryType;
|
|
40
32
|
}
|
|
41
|
-
export interface
|
|
42
|
-
type:
|
|
43
|
-
appName
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type: FlowHistoryStepType.APP_ACTION_NODE;
|
|
47
|
-
appName: string;
|
|
33
|
+
export interface TriggerInvocationHistory extends FlowHistory {
|
|
34
|
+
type: FlowHistoryType.TRIGGER_INVOCATION;
|
|
35
|
+
appName?: string;
|
|
36
|
+
triggerName: string;
|
|
37
|
+
triggerBody: any;
|
|
48
38
|
}
|
|
49
|
-
export interface
|
|
50
|
-
type:
|
|
39
|
+
export interface AppActionInvocationHistory extends FlowHistory {
|
|
40
|
+
type: FlowHistoryType.APP_ACTION_INVOCATION;
|
|
41
|
+
nodeTitle: string;
|
|
51
42
|
}
|
|
52
43
|
export declare enum SessionType {
|
|
53
44
|
VOICE = "voice",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.types.d.ts","sourceRoot":"","sources":["../../src/types/Agent.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,aAAa,CAAC,MAAM,EAAE,CAAC,SAAS,MAAM,yBAAyB,CAAC,MAAM,CAAC,IAAI,CACrF,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAC1C,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,EAAE,SAAS,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,WAAW,EAAE,GAAG,CAAC;IACjB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,oBAAY,
|
|
1
|
+
{"version":3,"file":"Agent.types.d.ts","sourceRoot":"","sources":["../../src/types/Agent.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,aAAa,CAAC,MAAM,EAAE,CAAC,SAAS,MAAM,yBAAyB,CAAC,MAAM,CAAC,IAAI,CACrF,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAC1C,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,EAAE,SAAS,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,WAAW,EAAE,GAAG,CAAC;IACjB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,oBAAY,eAAe;IACzB,kBAAkB,sBAAsB;IACxC,qBAAqB,wBAAwB;CAC9C;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,IAAI,EAAE,eAAe,CAAC,kBAAkB,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,MAAM,WAAW,0BAA2B,SAAQ,WAAW;IAC7D,IAAI,EAAE,eAAe,CAAC,qBAAqB,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,IAAI,SAAS;CACd"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SessionType = exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
FlowHistoryStepType["PROMPT_NODE"] = "promptNode";
|
|
11
|
-
})(FlowHistoryStepType || (exports.FlowHistoryStepType = FlowHistoryStepType = {}));
|
|
3
|
+
exports.SessionType = exports.FlowHistoryType = void 0;
|
|
4
|
+
var FlowHistoryType;
|
|
5
|
+
(function (FlowHistoryType) {
|
|
6
|
+
FlowHistoryType["TRIGGER_INVOCATION"] = "triggerInvocation";
|
|
7
|
+
FlowHistoryType["APP_ACTION_INVOCATION"] = "appActionInvocation";
|
|
8
|
+
})(FlowHistoryType || (exports.FlowHistoryType = FlowHistoryType = {}));
|
|
9
|
+
;
|
|
12
10
|
var SessionType;
|
|
13
11
|
(function (SessionType) {
|
|
14
12
|
SessionType["VOICE"] = "voice";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.types.js","sourceRoot":"","sources":["../../src/types/Agent.types.ts"],"names":[],"mappings":";;;AAgCA,IAAY,
|
|
1
|
+
{"version":3,"file":"Agent.types.js","sourceRoot":"","sources":["../../src/types/Agent.types.ts"],"names":[],"mappings":";;;AAgCA,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,2DAAwC,CAAA;IACxC,gEAA6C,CAAA;AAC/C,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B;AAgBA,CAAC;AAEF,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,4BAAa,CAAA;AACf,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flows.types.d.ts","sourceRoot":"","sources":["../../src/types/Flows.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACr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CAC3B;AACD,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC;IACnC,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,oBAAoB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,oBAAoB,CAAC;QAC3B,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;KACjC,CAAC;CACH,CAAC;AAEF,oBAAY,oBAAoB;IAC9B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,GAAG,QAAQ;CACZ;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;CAChC"}
|
|
@@ -1,17 +1,59 @@
|
|
|
1
1
|
import { BaseMessage } from '@langchain/core/messages';
|
|
2
2
|
import { CompiledStateGraph, StateGraph } from '@langchain/langgraph';
|
|
3
|
-
import {
|
|
3
|
+
import { FlowHistory, SessionType, TriggerInvocationHistory } from './Agent.types';
|
|
4
4
|
export declare const createStateAnnotation: <Memory = any>() => import("@langchain/langgraph").AnnotationRoot<{
|
|
5
5
|
messages: import("@langchain/langgraph").BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
|
|
6
6
|
memory: import("@langchain/langgraph").BinaryOperatorAggregate<Memory, Memory>;
|
|
7
|
-
|
|
7
|
+
triggerInvocations: import("@langchain/langgraph").BinaryOperatorAggregate<TriggerInvocationHistory[], TriggerInvocationHistory[]>;
|
|
8
|
+
triggerMetadata: {
|
|
9
|
+
(): import("@langchain/langgraph").LastValue<{
|
|
10
|
+
name: string;
|
|
11
|
+
triggerBody: any;
|
|
12
|
+
} | null>;
|
|
13
|
+
(annotation: import("@langchain/langgraph").SingleReducer<{
|
|
14
|
+
name: string;
|
|
15
|
+
triggerBody: any;
|
|
16
|
+
} | null, {
|
|
17
|
+
name: string;
|
|
18
|
+
triggerBody: any;
|
|
19
|
+
} | null>): import("@langchain/langgraph").BinaryOperatorAggregate<{
|
|
20
|
+
name: string;
|
|
21
|
+
triggerBody: any;
|
|
22
|
+
} | null, {
|
|
23
|
+
name: string;
|
|
24
|
+
triggerBody: any;
|
|
25
|
+
} | null>;
|
|
26
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
27
|
+
};
|
|
28
|
+
history: import("@langchain/langgraph").BinaryOperatorAggregate<FlowHistory[], FlowHistory[]>;
|
|
8
29
|
sessionId: import("@langchain/langgraph").LastValue<string>;
|
|
9
30
|
sessionType: import("@langchain/langgraph").BinaryOperatorAggregate<SessionType, SessionType>;
|
|
10
31
|
}>;
|
|
11
32
|
export declare const stateAnnotation: import("@langchain/langgraph").AnnotationRoot<{
|
|
12
33
|
messages: import("@langchain/langgraph").BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
|
|
13
34
|
memory: import("@langchain/langgraph").BinaryOperatorAggregate<any, any>;
|
|
14
|
-
|
|
35
|
+
triggerInvocations: import("@langchain/langgraph").BinaryOperatorAggregate<TriggerInvocationHistory[], TriggerInvocationHistory[]>;
|
|
36
|
+
triggerMetadata: {
|
|
37
|
+
(): import("@langchain/langgraph").LastValue<{
|
|
38
|
+
name: string;
|
|
39
|
+
triggerBody: any;
|
|
40
|
+
} | null>;
|
|
41
|
+
(annotation: import("@langchain/langgraph").SingleReducer<{
|
|
42
|
+
name: string;
|
|
43
|
+
triggerBody: any;
|
|
44
|
+
} | null, {
|
|
45
|
+
name: string;
|
|
46
|
+
triggerBody: any;
|
|
47
|
+
} | null>): import("@langchain/langgraph").BinaryOperatorAggregate<{
|
|
48
|
+
name: string;
|
|
49
|
+
triggerBody: any;
|
|
50
|
+
} | null, {
|
|
51
|
+
name: string;
|
|
52
|
+
triggerBody: any;
|
|
53
|
+
} | null>;
|
|
54
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
55
|
+
};
|
|
56
|
+
history: import("@langchain/langgraph").BinaryOperatorAggregate<FlowHistory[], FlowHistory[]>;
|
|
15
57
|
sessionId: import("@langchain/langgraph").LastValue<string>;
|
|
16
58
|
sessionType: import("@langchain/langgraph").BinaryOperatorAggregate<SessionType, SessionType>;
|
|
17
59
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LangGraph.types.d.ts","sourceRoot":"","sources":["../../src/types/LangGraph.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAc,kBAAkB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"LangGraph.types.d.ts","sourceRoot":"","sources":["../../src/types/LangGraph.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAc,kBAAkB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEnF,eAAO,MAAM,qBAAqB,GAAI,MAAM,GAAG,GAAG;;;;;;kBA4BtC,MAAM;yBACC,GAAG;;;kBADV,MAAM;yBACC,GAAG;;kBADV,MAAM;yBACC,GAAG;;kBADV,MAAM;yBACC,GAAG;;kBADV,MAAM;yBACC,GAAG;;;;;;;EAWlB,CAAC;AAGL,eAAO,MAAM,eAAe;;;;;;kBAfhB,MAAM;yBACC,GAAG;;;kBADV,MAAM;yBACC,GAAG;;kBADV,MAAM;yBACC,GAAG;;kBADV,MAAM;yBACC,GAAG;;kBADV,MAAM;yBACC,GAAG;;;;;;;EAcgC,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAC5D,MAAM,MAAM,KAAK,CAAC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -27,6 +27,11 @@ const createStateAnnotation = () => langgraph_1.Annotation.Root({
|
|
|
27
27
|
default: () => ({}),
|
|
28
28
|
reducer: (a, b) => ({ ...a, ...b }),
|
|
29
29
|
}),
|
|
30
|
+
triggerInvocations: (0, langgraph_1.Annotation)({
|
|
31
|
+
default: () => [],
|
|
32
|
+
reducer: (a, b) => a.concat(b),
|
|
33
|
+
}),
|
|
34
|
+
triggerMetadata: (langgraph_1.Annotation),
|
|
30
35
|
history: (0, langgraph_1.Annotation)({
|
|
31
36
|
default: () => [],
|
|
32
37
|
reducer: (a, b) => a.concat(b),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LangGraph.types.js","sourceRoot":"","sources":["../../src/types/LangGraph.types.ts"],"names":[],"mappings":";;;AACA,oDAAkF;AAClF,+
|
|
1
|
+
{"version":3,"file":"LangGraph.types.js","sourceRoot":"","sources":["../../src/types/LangGraph.types.ts"],"names":[],"mappings":";;;AACA,oDAAkF;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AAC;IACF,eAAe,EAAE,CAAA,sBAGR,CAAA;IACT,OAAO,EAAE,IAAA,sBAAU,EAAqB;QACtC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;QACjB,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;KAC/B,CAAC;IACF,SAAS,EAAE,IAAA,sBAAU,GAAU;IAC/B,WAAW,EAAE,IAAA,sBAAU,EAAc;QACnC,OAAO,EAAE,GAAG,EAAE,CAAC,yBAAW,CAAC,IAAI;QAC/B,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;KAC1B,CAAC;CACH,CAAC,CAAC;AAxCQ,QAAA,qBAAqB,yBAwC7B;AAEL,gDAAgD;AACnC,QAAA,eAAe,GAAG,IAAA,6BAAqB,GAAE,CAAC"}
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { InvokeMessage, MindedConnectionSocketMessageType } from './platform/min
|
|
|
15
15
|
import * as fs from 'fs';
|
|
16
16
|
import * as path from 'path';
|
|
17
17
|
import * as yaml from 'js-yaml';
|
|
18
|
-
import { AgentInvokeParams,
|
|
18
|
+
import { AgentInvokeParams, FlowHistoryType, MindedSDKConfig, SessionType, TriggerInvocationHistory } from './types/Agent.types';
|
|
19
19
|
import { createLlmInstance } from './llm/createLlmInstance';
|
|
20
20
|
import { createCheckpointSaver } from './checkpointer/checkpointSaverFactory';
|
|
21
21
|
import { getConfig } from './platform/config';
|
|
@@ -315,7 +315,9 @@ export class Agent {
|
|
|
315
315
|
return {
|
|
316
316
|
messages: [],
|
|
317
317
|
memory: {} as z.infer<typeof this.memorySchema>,
|
|
318
|
+
triggerMetadata: null,
|
|
318
319
|
history: [],
|
|
320
|
+
triggerInvocations: [] as Array<TriggerInvocationHistory>,
|
|
319
321
|
sessionId: state.sessionId || uuidv4(), // Preserve existing sessionId or generate new one
|
|
320
322
|
sessionType: state.sessionType || SessionType.TEXT,
|
|
321
323
|
};
|
|
@@ -390,7 +392,7 @@ export class Agent {
|
|
|
390
392
|
const triggerInvocation = { appName, triggerName, triggerBody };
|
|
391
393
|
const history = [
|
|
392
394
|
{
|
|
393
|
-
type:
|
|
395
|
+
type: FlowHistoryType.TRIGGER_INVOCATION,
|
|
394
396
|
...triggerInvocation,
|
|
395
397
|
},
|
|
396
398
|
];
|
|
@@ -402,16 +404,155 @@ export class Agent {
|
|
|
402
404
|
if (state.tasks?.[0]?.interrupts?.length > 0) {
|
|
403
405
|
res = await this.compiledGraph.invoke(
|
|
404
406
|
new Command({
|
|
405
|
-
resume: { memory: memoryUpdate, messages, history, sessionId, sessionType },
|
|
407
|
+
resume: { memory: memoryUpdate, messages, history, triggerInvocations: [triggerInvocation], sessionId, sessionType },
|
|
406
408
|
}),
|
|
407
409
|
langraphConfig,
|
|
408
410
|
);
|
|
409
411
|
} else {
|
|
410
|
-
res = await this.compiledGraph.invoke(
|
|
412
|
+
res = await this.compiledGraph.invoke(
|
|
413
|
+
{ messages, memory: memoryUpdate, history, triggerInvocations: [triggerInvocation], sessionId, sessionType },
|
|
414
|
+
langraphConfig,
|
|
415
|
+
);
|
|
411
416
|
}
|
|
412
417
|
return res;
|
|
413
418
|
}
|
|
414
419
|
|
|
420
|
+
/**
|
|
421
|
+
* Register an event handler for specific agent events.
|
|
422
|
+
*
|
|
423
|
+
* This method allows you to listen for and respond to various events that occur during
|
|
424
|
+
* agent execution, such as trigger events, memory updates, or custom application events.
|
|
425
|
+
* Multiple handlers can be registered for the same event type and will be executed in the order they are registered.
|
|
426
|
+
*
|
|
427
|
+
* ## Available Event Types
|
|
428
|
+
*
|
|
429
|
+
* ### AI_MESSAGE
|
|
430
|
+
* Emitted when an AI generates a message that should be sent to the user.
|
|
431
|
+
*
|
|
432
|
+
* **Input Structure:**
|
|
433
|
+
* ```typescript
|
|
434
|
+
* {
|
|
435
|
+
* message: string; // The AI-generated message content
|
|
436
|
+
* state: { // Full agent state
|
|
437
|
+
* messages: BaseMessage[]; // Conversation messages
|
|
438
|
+
* memory: Memory; // Current memory state (your defined memory schema)
|
|
439
|
+
* triggerInvocations: Array<...>; // Trigger invocation history
|
|
440
|
+
* triggerMetadata: {...} | null; // Current trigger metadata
|
|
441
|
+
* history: FlowHistory[]; // Flow execution history
|
|
442
|
+
* sessionId: string; // Session identifier
|
|
443
|
+
* }
|
|
444
|
+
* }
|
|
445
|
+
* ```
|
|
446
|
+
*
|
|
447
|
+
* **Expected Output:** `void` - Handlers are used for side effects like sending messages to UI
|
|
448
|
+
*
|
|
449
|
+
* **Common Use Cases:**
|
|
450
|
+
* - Real-time chat UI updates with session context
|
|
451
|
+
* - Logging AI responses for analytics or debugging
|
|
452
|
+
* - Message formatting and transformation
|
|
453
|
+
* - Notifications and alerts based on AI responses
|
|
454
|
+
* - Session-based message routing
|
|
455
|
+
*
|
|
456
|
+
* ### TRIGGER_EVENT
|
|
457
|
+
* Emitted when a trigger node is executed. Allows you to qualify, transform, and provide
|
|
458
|
+
* initial state for trigger inputs before they're processed by the agent.
|
|
459
|
+
*
|
|
460
|
+
* **Input Structure:**
|
|
461
|
+
* ```typescript
|
|
462
|
+
* {
|
|
463
|
+
* triggerName: string; // Name of the trigger being executed
|
|
464
|
+
* triggerBody: any; // The trigger input data (type varies by trigger)
|
|
465
|
+
* }
|
|
466
|
+
* ```
|
|
467
|
+
*
|
|
468
|
+
* **Expected Output:** One of three possible return types:
|
|
469
|
+
*
|
|
470
|
+
* 1. **Provide Initial State:**
|
|
471
|
+
* ```typescript
|
|
472
|
+
* {
|
|
473
|
+
* messages?: BaseMessage[]; // Initial messages for the conversation
|
|
474
|
+
* memory?: Memory; // Initial memory state
|
|
475
|
+
* sessionId?: string; // Session ID for persistence (resumes existing sessions)
|
|
476
|
+
* }
|
|
477
|
+
* ```
|
|
478
|
+
*
|
|
479
|
+
* 2. **Disqualify the Trigger:**
|
|
480
|
+
* ```typescript
|
|
481
|
+
* false // Rejects/disqualifies the trigger from processing
|
|
482
|
+
* ```
|
|
483
|
+
*
|
|
484
|
+
* 3. **Qualify without Initial State:**
|
|
485
|
+
* ```typescript
|
|
486
|
+
* void // Qualifies the trigger but provides no initial state
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
489
|
+
* **Common Use Cases:**
|
|
490
|
+
* - Input validation and trigger qualification
|
|
491
|
+
* - Data transformation into standardized formats
|
|
492
|
+
* - Context setting with initial memory state
|
|
493
|
+
* - Access control and business rule enforcement
|
|
494
|
+
* - Routing logic for different trigger types
|
|
495
|
+
*
|
|
496
|
+
* @template E - The event type, constrained to known agent event types
|
|
497
|
+
* @param event - The name of the event to listen for
|
|
498
|
+
* @param handler - The function to call when the event is emitted
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```typescript
|
|
502
|
+
* // AI_MESSAGE Event Handler
|
|
503
|
+
* agent.on('AI_MESSAGE', async ({ message, state }) => {
|
|
504
|
+
* logger.info({ msg: 'AI said:', output: message });
|
|
505
|
+
* logger.info({ msg: 'Current memory:', output: state.memory });
|
|
506
|
+
* logger.info({ msg: 'Session ID:', output: state.sessionId });
|
|
507
|
+
*
|
|
508
|
+
* // Send to user interface with session context
|
|
509
|
+
* await sendMessageToUser(message, state.sessionId);
|
|
510
|
+
*
|
|
511
|
+
* // Send via WebSocket
|
|
512
|
+
* await websocket.send(JSON.stringify({
|
|
513
|
+
* type: 'ai_message',
|
|
514
|
+
* content: message,
|
|
515
|
+
* sessionId: state.sessionId,
|
|
516
|
+
* memory: state.memory
|
|
517
|
+
* }));
|
|
518
|
+
* });
|
|
519
|
+
*
|
|
520
|
+
* // TRIGGER_EVENT Event Handler - Input Validation
|
|
521
|
+
* agent.on('TRIGGER_EVENT', async ({ triggerName, triggerBody }) => {
|
|
522
|
+
* // Validate trigger input
|
|
523
|
+
* if (!isValidInput(triggerBody)) {
|
|
524
|
+
* return false; // Disqualify the trigger
|
|
525
|
+
* }
|
|
526
|
+
*
|
|
527
|
+
* // Business hours check
|
|
528
|
+
* if (triggerName === 'supportRequest' && !isBusinessHours()) {
|
|
529
|
+
* return false;
|
|
530
|
+
* }
|
|
531
|
+
*
|
|
532
|
+
* return {
|
|
533
|
+
* memory: { validatedInput: triggerBody },
|
|
534
|
+
* messages: [new HumanMessage('Support request received')],
|
|
535
|
+
* sessionId: triggerBody.userId // Resume existing session
|
|
536
|
+
* };
|
|
537
|
+
* });
|
|
538
|
+
*
|
|
539
|
+
* // TRIGGER_EVENT Event Handler - Data Transformation
|
|
540
|
+
* agent.on('TRIGGER_EVENT', async ({ triggerName, triggerBody }) => {
|
|
541
|
+
* if (triggerName === 'emailTrigger') {
|
|
542
|
+
* // Transform email data into structured format
|
|
543
|
+
* const parsedEmail = parseEmailContent(triggerBody);
|
|
544
|
+
*
|
|
545
|
+
* return {
|
|
546
|
+
* memory: {
|
|
547
|
+
* emailSubject: parsedEmail.subject,
|
|
548
|
+
* senderEmail: parsedEmail.from
|
|
549
|
+
* },
|
|
550
|
+
* messages: [new HumanMessage(parsedEmail.content)],
|
|
551
|
+
* };
|
|
552
|
+
* }
|
|
553
|
+
* });
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
415
556
|
// Public API for registering event listeners
|
|
416
557
|
public on<E extends keyof AgentEventRequestPayloads<z.infer<typeof this.memorySchema>>>(
|
|
417
558
|
event: E,
|
|
@@ -445,7 +586,7 @@ export class Agent {
|
|
|
445
586
|
}
|
|
446
587
|
return this.flows
|
|
447
588
|
.flatMap((flow) => flow.nodes.filter((node) => node.type === NodeType.APP_TOOL))
|
|
448
|
-
.map((node) => appActionRunnerToolCreator(node.metadata.schema, node.
|
|
589
|
+
.map((node) => appActionRunnerToolCreator(node.metadata.schema, node.displayName!, this.mindedConnection as MindedConnection));
|
|
449
590
|
}
|
|
450
591
|
|
|
451
592
|
// Private method to get secrets from the backend service and load them into environment variables
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
import {
|
|
2
|
+
import { FlowHistory } from '../types/Agent.types';
|
|
3
3
|
import { createStateAnnotation } from '../types/LangGraph.types';
|
|
4
4
|
|
|
5
5
|
export enum AgentEvents {
|
|
@@ -28,7 +28,7 @@ export type AgentEventResponsePayloads<Memory> = {
|
|
|
28
28
|
isQualified: boolean;
|
|
29
29
|
messages?: BaseMessage[];
|
|
30
30
|
memory?: Memory;
|
|
31
|
-
history?:
|
|
31
|
+
history?: FlowHistory[];
|
|
32
32
|
sessionId?: string;
|
|
33
33
|
};
|
|
34
34
|
};
|
package/src/index.ts
CHANGED
|
@@ -35,14 +35,7 @@ export {
|
|
|
35
35
|
KnownTriggerNames,
|
|
36
36
|
} from './types/Flows.types';
|
|
37
37
|
export type { Tool, ToolExecuteInput } from './types/Tools.types';
|
|
38
|
-
export {
|
|
39
|
-
FlowHistoryStepType,
|
|
40
|
-
HistoryStep,
|
|
41
|
-
TrigggerHistoryStep,
|
|
42
|
-
AppActionInvocationHistoryStep,
|
|
43
|
-
CustomActionInvocationHistoryStep,
|
|
44
|
-
SessionType,
|
|
45
|
-
} from './types/Agent.types';
|
|
38
|
+
export { FlowHistoryType, FlowHistory, TriggerInvocationHistory, AppActionInvocationHistory, SessionType } from './types/Agent.types';
|
|
46
39
|
export type { AgentInvokeParams, MindedSDKConfig } from './types/Agent.types';
|
|
47
40
|
export type { Environment } from './types/Platform.types';
|
|
48
41
|
export type { State } from './types/LangGraph.types';
|
|
@@ -6,11 +6,10 @@ import { RunnableLike } from '@langchain/core/runnables';
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { LLMProviders } from '../types/LLM.types';
|
|
8
8
|
import { getAppActionRunnerTool } from '../internalTools/appActionRunnerTool';
|
|
9
|
-
import {
|
|
9
|
+
import { FlowHistoryType } from '../types/Agent.types';
|
|
10
10
|
import { Agent } from '../agent';
|
|
11
11
|
import { logger } from '../utils/logger';
|
|
12
12
|
import { compilePlaybooks } from '../playbooks/playbooks';
|
|
13
|
-
import { createHistoryStep } from '../utils/history';
|
|
14
13
|
|
|
15
14
|
export const addAppToolNode = async ({
|
|
16
15
|
graph,
|
|
@@ -24,7 +23,7 @@ export const addAppToolNode = async ({
|
|
|
24
23
|
agent: Agent;
|
|
25
24
|
}) => {
|
|
26
25
|
const cleanedParameters = Object.fromEntries(Object.entries(node.parameters || {}).filter(([, value]) => value !== ''));
|
|
27
|
-
const appRunnerTool = getAppActionRunnerTool(node.
|
|
26
|
+
const appRunnerTool = getAppActionRunnerTool(node.displayName!);
|
|
28
27
|
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
29
28
|
logger.info(`Executing tool node ${appRunnerTool.name}`);
|
|
30
29
|
|
|
@@ -77,13 +76,7 @@ export const addAppToolNode = async ({
|
|
|
77
76
|
};
|
|
78
77
|
return {
|
|
79
78
|
messages: [AIToolCallMessage, toolCallMessage],
|
|
80
|
-
history:
|
|
81
|
-
type: FlowHistoryStepType.APP_ACTION_NODE,
|
|
82
|
-
nodeId: node.name,
|
|
83
|
-
nodeDisplayName: node.displayName!,
|
|
84
|
-
raw: AIToolCallMessage.tool_calls[0],
|
|
85
|
-
appName: node.appName,
|
|
86
|
-
}),
|
|
79
|
+
history: [{ type: FlowHistoryType.APP_ACTION_INVOCATION, nodeTitle: node.displayName }],
|
|
87
80
|
};
|
|
88
81
|
};
|
|
89
82
|
graph.addNode(node.name, callback);
|
|
@@ -3,13 +3,19 @@ import { PreCompiledGraph } from '../types/LangGraph.types';
|
|
|
3
3
|
import { JumpToNode } from '../types/Flows.types';
|
|
4
4
|
import { logger } from '../utils/logger';
|
|
5
5
|
|
|
6
|
-
export const addJumpToNode = async ({
|
|
6
|
+
export const addJumpToNode = async ({
|
|
7
|
+
graph,
|
|
8
|
+
node,
|
|
9
|
+
}: {
|
|
10
|
+
graph: PreCompiledGraph;
|
|
11
|
+
node: JumpToNode;
|
|
12
|
+
}) => {
|
|
7
13
|
const callback: RunnableLike = async () => {
|
|
8
|
-
logger.info(`Executing jump node ${node.
|
|
14
|
+
logger.info(`Executing jump node ${node.name} – jumping to ${node.targetNodeId}`);
|
|
9
15
|
// No state modifications are necessary; control flow is handled via edges.
|
|
10
16
|
return;
|
|
11
17
|
};
|
|
12
18
|
|
|
13
19
|
graph.addNode(node.name, callback);
|
|
14
20
|
graph.addEdge(node.name as any, node.targetNodeId as any);
|
|
15
|
-
};
|
|
21
|
+
};
|
|
@@ -7,13 +7,12 @@ import { SystemMessage, AIMessage, ToolMessage } from '@langchain/core/messages'
|
|
|
7
7
|
import { Tool } from '../types/Tools.types';
|
|
8
8
|
import { tool as langchainTool } from '@langchain/core/tools';
|
|
9
9
|
import { AgentEventRequestPayloads, AgentEvents } from '../events/AgentEvents';
|
|
10
|
-
import { EmitSignature
|
|
10
|
+
import { EmitSignature } from '../types/Agent.types';
|
|
11
11
|
import { createLlmInstance } from '../llm/createLlmInstance';
|
|
12
12
|
import extractToolStateResponse from '../utils/extractStateMemoryResponse';
|
|
13
13
|
import { Agent } from '../agent';
|
|
14
14
|
import { logger } from '../utils/logger';
|
|
15
15
|
import { compilePlaybooks } from '../playbooks/playbooks';
|
|
16
|
-
import { createHistoryStep } from '../utils/history';
|
|
17
16
|
|
|
18
17
|
type AddPromptNodeParams = {
|
|
19
18
|
graph: PreCompiledGraph;
|
|
@@ -26,7 +25,7 @@ type AddPromptNodeParams = {
|
|
|
26
25
|
|
|
27
26
|
export const addPromptNode = async ({ graph, node, llm, tools, emit, agent }: AddPromptNodeParams) => {
|
|
28
27
|
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
29
|
-
logger.info(`Executing prompt node ${node.
|
|
28
|
+
logger.info(`Executing prompt node ${node.name}`);
|
|
30
29
|
const llmToUse = node.llmConfig ? createLlmInstance(node.llmConfig) : llm;
|
|
31
30
|
|
|
32
31
|
const globalTools = tools
|
|
@@ -99,13 +98,6 @@ export const addPromptNode = async ({ graph, node, llm, tools, emit, agent }: Ad
|
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
return {
|
|
102
|
-
history: createHistoryStep<HistoryStep>(state.history, {
|
|
103
|
-
type: FlowHistoryStepType.PROMPT_NODE,
|
|
104
|
-
nodeId: node.name,
|
|
105
|
-
nodeDisplayName: node.displayName,
|
|
106
|
-
raw: result.content,
|
|
107
|
-
messageId: result.id,
|
|
108
|
-
}),
|
|
109
101
|
messages: [result],
|
|
110
102
|
};
|
|
111
103
|
};
|
package/src/nodes/addToolNode.ts
CHANGED
|
@@ -28,9 +28,9 @@ export const addToolNode = async ({
|
|
|
28
28
|
throw new Error(`Tool not found: ${toolNode.toolName}`);
|
|
29
29
|
}
|
|
30
30
|
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
31
|
-
logger.info(`Executing tool node ${toolNode.
|
|
31
|
+
logger.info(`Executing tool node ${toolNode.name}`);
|
|
32
32
|
|
|
33
|
-
const tool = langchainTool(() => {}, {
|
|
33
|
+
const tool = langchainTool(() => { }, {
|
|
34
34
|
name: matchedTool.name,
|
|
35
35
|
description: matchedTool.description,
|
|
36
36
|
schema: matchedTool.input,
|
|
@@ -5,7 +5,7 @@ import { logger } from '../utils/logger';
|
|
|
5
5
|
|
|
6
6
|
export const addTriggerNode = async ({ graph, node }: { graph: PreCompiledGraph; node: TriggerNode }) => {
|
|
7
7
|
const callback: RunnableLike = async () => {
|
|
8
|
-
logger.info(`Executing trigger node ${node.
|
|
8
|
+
logger.info(`Executing trigger node ${node.name}`);
|
|
9
9
|
return;
|
|
10
10
|
};
|
|
11
11
|
|
package/src/types/Agent.types.ts
CHANGED
|
@@ -30,36 +30,26 @@ export interface AgentInvokeParams {
|
|
|
30
30
|
appName?: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export enum
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
APP_ACTION_NODE = 'appActionNode',
|
|
37
|
-
CUSTOM_ACTION_NODE = 'customActionNode',
|
|
38
|
-
PROMPT_NODE = 'promptNode',
|
|
33
|
+
export enum FlowHistoryType {
|
|
34
|
+
TRIGGER_INVOCATION = 'triggerInvocation',
|
|
35
|
+
APP_ACTION_INVOCATION = 'appActionInvocation',
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
export interface
|
|
42
|
-
type:
|
|
43
|
-
step: number;
|
|
44
|
-
raw: any;
|
|
45
|
-
nodeId: string;
|
|
46
|
-
nodeDisplayName: string;
|
|
47
|
-
messageId?: string;
|
|
38
|
+
export interface FlowHistory {
|
|
39
|
+
type: FlowHistoryType;
|
|
48
40
|
}
|
|
49
41
|
|
|
50
|
-
export interface
|
|
51
|
-
type:
|
|
52
|
-
appName
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export interface AppActionInvocationHistoryStep extends HistoryStep {
|
|
56
|
-
type: FlowHistoryStepType.APP_ACTION_NODE;
|
|
57
|
-
appName: string;
|
|
42
|
+
export interface TriggerInvocationHistory extends FlowHistory {
|
|
43
|
+
type: FlowHistoryType.TRIGGER_INVOCATION;
|
|
44
|
+
appName?: string;
|
|
45
|
+
triggerName: string;
|
|
46
|
+
triggerBody: any;
|
|
58
47
|
}
|
|
59
48
|
|
|
60
|
-
export interface
|
|
61
|
-
type:
|
|
62
|
-
|
|
49
|
+
export interface AppActionInvocationHistory extends FlowHistory {
|
|
50
|
+
type: FlowHistoryType.APP_ACTION_INVOCATION;
|
|
51
|
+
nodeTitle: string;
|
|
52
|
+
};
|
|
63
53
|
|
|
64
54
|
export enum SessionType {
|
|
65
55
|
VOICE = 'voice',
|