@minded-ai/mindedjs 1.0.25 → 1.0.26
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 +6 -2
- package/dist/agent.js +4 -7
- package/dist/agent.js.map +1 -1
- package/docs/core-concepts/triggers.md +4 -6
- package/package.json +1 -1
- package/src/agent.ts +4 -7
- package/test/can-stay-on-node/can-stay-on-node.test.ts +18 -31
- package/test/cannot-stay-on-node/cannot-stay-on-node.test.ts +24 -41
- package/test/human-in-the-loop-node/human-in-the-loop-node.test.ts +6 -11
- package/test/logical-edges/logical-edges.test.ts +4 -11
- package/test/no-human-in-the-loop-node/no-human-in-the-loop-node.test.ts +3 -6
- package/test/prompt-edges/prompt-edges.test.ts +4 -11
- package/test/prompt-node/prompt-node.test.ts +6 -11
- package/test/tool-node/tool-node.test.ts +2 -6
- package/test/trigger/trigger.test.ts +10 -26
package/dist/agent.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Tool } from './types/Tools.types';
|
|
|
2
2
|
import { BaseCheckpointSaver } from '@langchain/langgraph';
|
|
3
3
|
import { AgentEventRequestPayloads, AgentEventResponsePayloads } from './events/AgentEvents';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { OnAppTrigger } from './platform/mindedConnectionTypes';
|
|
6
5
|
import { MindedSDKConfig } from './types/Agent.types';
|
|
7
6
|
type CreateAgentParams<Memory> = {
|
|
8
7
|
memorySchema: z.ZodSchema;
|
|
@@ -26,7 +25,12 @@ export declare class Agent {
|
|
|
26
25
|
private validate;
|
|
27
26
|
private initializeGraph;
|
|
28
27
|
private init;
|
|
29
|
-
invoke(
|
|
28
|
+
invoke({ triggerBody, triggerName, sessionId, appName }: {
|
|
29
|
+
triggerBody: any;
|
|
30
|
+
triggerName: string;
|
|
31
|
+
sessionId?: string;
|
|
32
|
+
appName?: string;
|
|
33
|
+
}): Promise<import("@langchain/langgraph").StateType<import("@langchain/langgraph").StateDefinition>>;
|
|
30
34
|
on<E extends keyof AgentEventRequestPayloads<z.infer<typeof this.memorySchema>>>(event: E, handler: (payload: AgentEventRequestPayloads<z.infer<typeof this.memorySchema>>[E]) => Promise<AgentEventResponsePayloads<z.infer<typeof this.memorySchema>>[E] | void>): void;
|
|
31
35
|
private emit;
|
|
32
36
|
}
|
package/dist/agent.js
CHANGED
|
@@ -72,7 +72,7 @@ class Agent {
|
|
|
72
72
|
this.mindedConnection.start();
|
|
73
73
|
this.mindedConnection.on(mindedConnectionTypes_1.MindedConnectionSocketMessageType.OnAppTrigger, async (message) => {
|
|
74
74
|
const trigger = message;
|
|
75
|
-
await this.invoke(trigger);
|
|
75
|
+
await this.invoke({ triggerBody: trigger.body, triggerName: trigger.name, appName: trigger.appName });
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
this.checkpointer = memorySaver || (0, checkpointSaverFactory_1.createCheckpointSaver)(this.mindedConnection);
|
|
@@ -159,12 +159,9 @@ class Agent {
|
|
|
159
159
|
triggerInvocations: [],
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
async invoke(
|
|
162
|
+
async invoke({ triggerBody, triggerName, sessionId, appName }) {
|
|
163
163
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
164
|
-
const session =
|
|
165
|
-
const triggerName = trigger.name;
|
|
166
|
-
const triggerBody = trigger.body;
|
|
167
|
-
const appName = trigger.appName;
|
|
164
|
+
const session = sessionId || (0, uuid_1.v4)();
|
|
168
165
|
const results = await this.emit(AgentEvents_1.AgentEvents.TRIGGER_EVENT, {
|
|
169
166
|
triggerName,
|
|
170
167
|
triggerBody,
|
|
@@ -176,7 +173,7 @@ class Agent {
|
|
|
176
173
|
memoryUpdate = handlerResult.memory || {};
|
|
177
174
|
messages = (_a = handlerResult.messages) !== null && _a !== void 0 ? _a : [];
|
|
178
175
|
}
|
|
179
|
-
else {
|
|
176
|
+
else if (appName) {
|
|
180
177
|
messages = (_d = (_c = (_b = triggerTypeToDefaultMessage_1.default[appName]) === null || _b === void 0 ? void 0 : _b[triggerName]) === null || _c === void 0 ? void 0 : _c.call(_b, triggerBody)) !== null && _d !== void 0 ? _d : [];
|
|
181
178
|
}
|
|
182
179
|
const triggerInvocation = { appName, triggerName, triggerBody };
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA2D;AAE3D,+BAAoC;AAEpC,oDAA2D;AAE3D,qDAAkD;AAClD,6DAA2F;AAC3F,qDAAkD;AAClD,sDAA0G;AAE1G,kEAA+D;AAC/D,4EAAsI;AACtI,uCAAyB;AACzB,2CAA6B;AAC7B,8CAAgC;AAEhC,+DAA4D;AAC5D,mCAAgC;AAChC,+BAA+B;AAC/B,kFAA8E;AAE9E,yGAAiF;AAEjF,IAAA,eAAM,EAAC,EAAE,IAAI,EAAE,IAAA,cAAO,EAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;AAShD,MAAa,KAAK;IAmBhB,YAAY,MAA4D;QAbhE,qBAAgB,GAA4B,IAAI,CAAC;QAMzD,sFAAsF;QAC9E,kBAAa,GAIjB,EAAE,CAAC;QAGL,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;QAC3E,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,GAAG,GAAG,IAAA,qCAAiB,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QA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AC,CAAC;YAC1I,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,6CAA6C;IACtC,EAAE,CACP,KAAQ,EACR,OAEqF;QAErF,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACjC,CAAC;QACD,4DAA4D;QAC3D,IAAI,CAAC,aAAa,CAAC,KAAK,CAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,6DAA6D;IACrD,KAAK,CAAC,IAAI,CAChB,KAAQ,EACR,OAAwE;QAExE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAE,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACvG,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AApMD,sBAoMC"}
|
|
@@ -56,18 +56,16 @@ Example:
|
|
|
56
56
|
```typescript
|
|
57
57
|
// Slack trigger will automatically add a human message
|
|
58
58
|
const slackResult = await agent.invoke({
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
triggerName: 'New Direct Message (Instant)',
|
|
60
|
+
triggerBody: { text: 'Hello from Slack' },
|
|
61
61
|
appName: 'Slack',
|
|
62
|
-
// ... other required fields
|
|
63
62
|
});
|
|
64
63
|
|
|
65
64
|
// Other triggers won't add any messages by default
|
|
66
65
|
const otherResult = await agent.invoke({
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
triggerName: 'SomeOtherTrigger',
|
|
67
|
+
triggerBody: { text: 'Hello' },
|
|
69
68
|
appName: 'OtherApp',
|
|
70
|
-
// ... other required fields
|
|
71
69
|
});
|
|
72
70
|
```
|
|
73
71
|
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -64,7 +64,7 @@ export class Agent {
|
|
|
64
64
|
this.mindedConnection.start();
|
|
65
65
|
this.mindedConnection.on(MindedConnectionSocketMessageType.OnAppTrigger, async (message: BaseMindedConnectionSocketMessage) => {
|
|
66
66
|
const trigger = message as OnAppTrigger;
|
|
67
|
-
await this.invoke(trigger);
|
|
67
|
+
await this.invoke({ triggerBody: trigger.body, triggerName: trigger.name, appName: trigger.appName });
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
this.checkpointer = memorySaver || createCheckpointSaver(this.mindedConnection);
|
|
@@ -164,11 +164,8 @@ export class Agent {
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
public async invoke(
|
|
168
|
-
const session =
|
|
169
|
-
const triggerName = trigger.name;
|
|
170
|
-
const triggerBody = trigger.body;
|
|
171
|
-
const appName = trigger.appName;
|
|
167
|
+
public async invoke({ triggerBody, triggerName, sessionId, appName }: { triggerBody: any; triggerName: string; sessionId?: string; appName?: string }) {
|
|
168
|
+
const session = sessionId || uuidv4();
|
|
172
169
|
const results = await this.emit(AgentEvents.TRIGGER_EVENT, {
|
|
173
170
|
triggerName,
|
|
174
171
|
triggerBody,
|
|
@@ -179,7 +176,7 @@ export class Agent {
|
|
|
179
176
|
if (handlerResult) {
|
|
180
177
|
memoryUpdate = handlerResult.memory || {};
|
|
181
178
|
messages = handlerResult.messages ?? [];
|
|
182
|
-
} else {
|
|
179
|
+
} else if (appName) {
|
|
183
180
|
messages = triggerTypeToDefaultMessage[appName]?.[triggerName]?.(triggerBody) ?? [];
|
|
184
181
|
}
|
|
185
182
|
const triggerInvocation = { appName, triggerName, triggerBody };
|
|
@@ -5,7 +5,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
7
7
|
import { HumanMessage } from '@langchain/core/messages';
|
|
8
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
9
8
|
|
|
10
9
|
const memorySchema = z.object({
|
|
11
10
|
success: z.boolean(),
|
|
@@ -66,14 +65,12 @@ describe('Can Stay On Node', function () {
|
|
|
66
65
|
|
|
67
66
|
// First invocation - triggers the flow and reaches the human-in-the-loop pause
|
|
68
67
|
const result1 = await agent.invoke({
|
|
69
|
-
|
|
70
|
-
body: {
|
|
68
|
+
triggerBody: {
|
|
71
69
|
message: 'Initial input for processing',
|
|
72
70
|
},
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
triggerName: 'Trigger',
|
|
72
|
+
sessionId: sessionId,
|
|
75
73
|
appName: 'test',
|
|
76
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
77
74
|
});
|
|
78
75
|
|
|
79
76
|
// Should pause at human-in-the-loop, not reach success tool yet
|
|
@@ -82,14 +79,12 @@ describe('Can Stay On Node', function () {
|
|
|
82
79
|
|
|
83
80
|
// Second invocation - provide "stay" instruction
|
|
84
81
|
const result2 = await agent.invoke({
|
|
85
|
-
|
|
86
|
-
body: {
|
|
82
|
+
triggerBody: {
|
|
87
83
|
message: 'stay',
|
|
88
84
|
},
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
triggerName: 'Trigger',
|
|
86
|
+
sessionId: sessionId,
|
|
91
87
|
appName: 'test',
|
|
92
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
93
88
|
});
|
|
94
89
|
|
|
95
90
|
// Should stay on the node, pause again, not reach success tool
|
|
@@ -98,14 +93,12 @@ describe('Can Stay On Node', function () {
|
|
|
98
93
|
|
|
99
94
|
// Third invocation - provide another "stay" instruction
|
|
100
95
|
const result3 = await agent.invoke({
|
|
101
|
-
|
|
102
|
-
body: {
|
|
96
|
+
triggerBody: {
|
|
103
97
|
message: 'stay',
|
|
104
98
|
},
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
triggerName: 'Trigger',
|
|
100
|
+
sessionId: sessionId,
|
|
107
101
|
appName: 'test',
|
|
108
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
109
102
|
});
|
|
110
103
|
|
|
111
104
|
// Should still stay on the node, pause again
|
|
@@ -114,14 +107,12 @@ describe('Can Stay On Node', function () {
|
|
|
114
107
|
|
|
115
108
|
// Fourth invocation - provide "continue" instruction
|
|
116
109
|
const result4 = await agent.invoke({
|
|
117
|
-
|
|
118
|
-
body: {
|
|
110
|
+
triggerBody: {
|
|
119
111
|
message: 'continue',
|
|
120
112
|
},
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
triggerName: 'Trigger',
|
|
114
|
+
sessionId: sessionId,
|
|
123
115
|
appName: 'test',
|
|
124
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
125
116
|
});
|
|
126
117
|
|
|
127
118
|
// Should now move to success tool and complete
|
|
@@ -135,14 +126,12 @@ describe('Can Stay On Node', function () {
|
|
|
135
126
|
|
|
136
127
|
// First invocation - triggers the flow and reaches the human-in-the-loop pause
|
|
137
128
|
const result1 = await agent.invoke({
|
|
138
|
-
|
|
139
|
-
body: {
|
|
129
|
+
triggerBody: {
|
|
140
130
|
message: 'Initial input for processing',
|
|
141
131
|
},
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
triggerName: 'Trigger',
|
|
133
|
+
sessionId: sessionId,
|
|
144
134
|
appName: 'test',
|
|
145
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
146
135
|
});
|
|
147
136
|
|
|
148
137
|
// Should pause at human-in-the-loop, not reach success tool yet
|
|
@@ -151,14 +140,12 @@ describe('Can Stay On Node', function () {
|
|
|
151
140
|
|
|
152
141
|
// Second invocation - provide "continue" instruction
|
|
153
142
|
const result2 = await agent.invoke({
|
|
154
|
-
|
|
155
|
-
body: {
|
|
143
|
+
triggerBody: {
|
|
156
144
|
message: 'continue',
|
|
157
145
|
},
|
|
158
|
-
|
|
159
|
-
|
|
146
|
+
triggerName: 'Trigger',
|
|
147
|
+
sessionId: sessionId,
|
|
160
148
|
appName: 'test',
|
|
161
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
162
149
|
});
|
|
163
150
|
|
|
164
151
|
// Should now move to success tool and complete
|
|
@@ -5,7 +5,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
7
7
|
import { HumanMessage } from '@langchain/core/messages';
|
|
8
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
9
8
|
|
|
10
9
|
const memorySchema = z.object({
|
|
11
10
|
success: z.boolean(),
|
|
@@ -80,14 +79,12 @@ describe('Cannot Stay On Node', function () {
|
|
|
80
79
|
|
|
81
80
|
// First invocation - triggers the flow and reaches the human-in-the-loop pause
|
|
82
81
|
const result1 = await agent.invoke({
|
|
83
|
-
|
|
84
|
-
body: {
|
|
82
|
+
triggerBody: {
|
|
85
83
|
message: 'Initial input for processing',
|
|
86
84
|
},
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
triggerName: 'Trigger',
|
|
86
|
+
sessionId: sessionId,
|
|
89
87
|
appName: 'test',
|
|
90
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
91
88
|
});
|
|
92
89
|
|
|
93
90
|
// Should pause at human-in-the-loop, not reach any tool yet
|
|
@@ -97,14 +94,12 @@ describe('Cannot Stay On Node', function () {
|
|
|
97
94
|
|
|
98
95
|
// Second invocation - explicitly request to stay on the node
|
|
99
96
|
const result2 = await agent.invoke({
|
|
100
|
-
|
|
101
|
-
body: {
|
|
97
|
+
triggerBody: {
|
|
102
98
|
message: 'You must stay at the node! Do not move to the next step. Stay here and continue processing on this same node.',
|
|
103
99
|
},
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
triggerName: 'Trigger',
|
|
101
|
+
sessionId: sessionId,
|
|
106
102
|
appName: 'test',
|
|
107
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
108
103
|
});
|
|
109
104
|
|
|
110
105
|
// Should NOT stay on the node - should move to one of the target nodes
|
|
@@ -119,14 +114,12 @@ describe('Cannot Stay On Node', function () {
|
|
|
119
114
|
|
|
120
115
|
// First invocation - initial trigger
|
|
121
116
|
const result1 = await agent.invoke({
|
|
122
|
-
|
|
123
|
-
body: {
|
|
117
|
+
triggerBody: {
|
|
124
118
|
message: 'Start processing',
|
|
125
119
|
},
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
triggerName: 'Trigger',
|
|
121
|
+
sessionId: sessionId,
|
|
128
122
|
appName: 'test',
|
|
129
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
130
123
|
});
|
|
131
124
|
|
|
132
125
|
expect(result1.memory.success).to.not.equal(true);
|
|
@@ -134,14 +127,12 @@ describe('Cannot Stay On Node', function () {
|
|
|
134
127
|
|
|
135
128
|
// Second invocation - request main workflow
|
|
136
129
|
const result2 = await agent.invoke({
|
|
137
|
-
|
|
138
|
-
body: {
|
|
130
|
+
triggerBody: {
|
|
139
131
|
message: 'Proceed with the main workflow',
|
|
140
132
|
},
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
triggerName: 'Trigger',
|
|
134
|
+
sessionId: sessionId,
|
|
143
135
|
appName: 'test',
|
|
144
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
145
136
|
});
|
|
146
137
|
|
|
147
138
|
// Should move to success node
|
|
@@ -156,14 +147,12 @@ describe('Cannot Stay On Node', function () {
|
|
|
156
147
|
|
|
157
148
|
// First invocation - initial trigger
|
|
158
149
|
const result1 = await agent.invoke({
|
|
159
|
-
|
|
160
|
-
body: {
|
|
150
|
+
triggerBody: {
|
|
161
151
|
message: 'Begin workflow',
|
|
162
152
|
},
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
triggerName: 'Trigger',
|
|
154
|
+
sessionId: sessionId,
|
|
165
155
|
appName: 'test',
|
|
166
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
167
156
|
});
|
|
168
157
|
|
|
169
158
|
expect(result1.memory.success).to.not.equal(true);
|
|
@@ -171,14 +160,12 @@ describe('Cannot Stay On Node', function () {
|
|
|
171
160
|
|
|
172
161
|
// Second invocation - request alternative approach
|
|
173
162
|
const result2 = await agent.invoke({
|
|
174
|
-
|
|
175
|
-
body: {
|
|
163
|
+
triggerBody: {
|
|
176
164
|
message: 'I want an alternative approach instead',
|
|
177
165
|
},
|
|
178
|
-
|
|
179
|
-
|
|
166
|
+
triggerName: 'Trigger',
|
|
167
|
+
sessionId: sessionId,
|
|
180
168
|
appName: 'test',
|
|
181
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
182
169
|
});
|
|
183
170
|
|
|
184
171
|
// Should move to alternative node
|
|
@@ -193,14 +180,12 @@ describe('Cannot Stay On Node', function () {
|
|
|
193
180
|
|
|
194
181
|
// First invocation - initial trigger
|
|
195
182
|
const result1 = await agent.invoke({
|
|
196
|
-
|
|
197
|
-
body: {
|
|
183
|
+
triggerBody: {
|
|
198
184
|
message: 'Process this data',
|
|
199
185
|
},
|
|
200
|
-
|
|
201
|
-
|
|
186
|
+
triggerName: 'Trigger',
|
|
187
|
+
sessionId: sessionId,
|
|
202
188
|
appName: 'test',
|
|
203
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
204
189
|
});
|
|
205
190
|
|
|
206
191
|
expect(result1.memory.success).to.not.equal(true);
|
|
@@ -208,15 +193,13 @@ describe('Cannot Stay On Node', function () {
|
|
|
208
193
|
|
|
209
194
|
// Second invocation - very strong request to stay
|
|
210
195
|
const result2 = await agent.invoke({
|
|
211
|
-
|
|
212
|
-
body: {
|
|
196
|
+
triggerBody: {
|
|
213
197
|
message:
|
|
214
198
|
'STAY! Do not proceed! You must remain on this current node and not move forward. Keep processing here. Do not go to any other node.',
|
|
215
199
|
},
|
|
216
|
-
|
|
217
|
-
|
|
200
|
+
triggerName: 'Trigger',
|
|
201
|
+
sessionId: sessionId,
|
|
218
202
|
appName: 'test',
|
|
219
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
220
203
|
});
|
|
221
204
|
|
|
222
205
|
// Should still be forced to move to one of the available target nodes
|
|
@@ -5,7 +5,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
7
7
|
import { HumanMessage } from '@langchain/core/messages';
|
|
8
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
9
8
|
|
|
10
9
|
const memorySchema = z.object({
|
|
11
10
|
success: z.boolean(),
|
|
@@ -65,14 +64,12 @@ describe('Human In The Loop Node', function () {
|
|
|
65
64
|
|
|
66
65
|
// First invocation should execute the ProcessingNode and then pause at the human-in-the-loop node
|
|
67
66
|
const result = await agent.invoke({
|
|
68
|
-
|
|
69
|
-
body: {
|
|
67
|
+
triggerBody: {
|
|
70
68
|
message: 'Initial user input for processing',
|
|
71
69
|
},
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
triggerName: 'Trigger',
|
|
71
|
+
sessionId: sessionId,
|
|
74
72
|
appName: 'test',
|
|
75
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
76
73
|
});
|
|
77
74
|
|
|
78
75
|
// Should pause execution at human-in-the-loop node, not reaching the success tool yet
|
|
@@ -83,14 +80,12 @@ describe('Human In The Loop Node', function () {
|
|
|
83
80
|
|
|
84
81
|
// Second invocation should provide human input and continue to the Success node
|
|
85
82
|
const result2 = await agent.invoke({
|
|
86
|
-
|
|
87
|
-
body: {
|
|
83
|
+
triggerBody: {
|
|
88
84
|
message: 'Human approval: proceed with the workflow',
|
|
89
85
|
},
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
triggerName: 'Trigger',
|
|
87
|
+
sessionId: sessionId,
|
|
92
88
|
appName: 'test',
|
|
93
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
94
89
|
});
|
|
95
90
|
|
|
96
91
|
// Should complete execution and reach the success tool
|
|
@@ -3,7 +3,6 @@ import { Agent } from "../../src/agent";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { AgentEvents } from "../../src/events/AgentEvents";
|
|
6
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
7
6
|
|
|
8
7
|
const memorySchema = z.object({
|
|
9
8
|
userAge: z.number(),
|
|
@@ -50,12 +49,9 @@ describe('Logical Edges', () => {
|
|
|
50
49
|
it('should execute the Adult Tool', async function () {
|
|
51
50
|
this.timeout(10000); // Increase timeout to 10 seconds
|
|
52
51
|
const result = await agent.invoke({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
cnvId: 'test',
|
|
56
|
-
agentId: 'test',
|
|
52
|
+
triggerBody: { userAge: 25 },
|
|
53
|
+
triggerName: 'AgeTrigger',
|
|
57
54
|
appName: 'test',
|
|
58
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
59
55
|
});
|
|
60
56
|
expect(result.memory.isMinor).to.equal(false);
|
|
61
57
|
});
|
|
@@ -63,12 +59,9 @@ describe('Logical Edges', () => {
|
|
|
63
59
|
it('should execute the Minor Tool', async function () {
|
|
64
60
|
this.timeout(10000); // Increase timeout to 10 seconds
|
|
65
61
|
const result = await agent.invoke({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
cnvId: 'test',
|
|
69
|
-
agentId: 'test',
|
|
62
|
+
triggerBody: { userAge: 15 },
|
|
63
|
+
triggerName: 'AgeTrigger',
|
|
70
64
|
appName: 'test',
|
|
71
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
72
65
|
});
|
|
73
66
|
expect(result.memory.isMinor).to.equal(true);
|
|
74
67
|
});
|
|
@@ -5,7 +5,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
7
7
|
import { HumanMessage } from '@langchain/core/messages';
|
|
8
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
9
8
|
|
|
10
9
|
const memorySchema = z.object({
|
|
11
10
|
success: z.boolean(),
|
|
@@ -65,14 +64,12 @@ describe('No Human In The Loop Node', function () {
|
|
|
65
64
|
|
|
66
65
|
// Single invocation should complete the entire flow without pausing
|
|
67
66
|
const result = await agent.invoke({
|
|
68
|
-
|
|
69
|
-
body: {
|
|
67
|
+
triggerBody: {
|
|
70
68
|
message: 'Input for processing without human intervention',
|
|
71
69
|
},
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
triggerName: 'Trigger',
|
|
71
|
+
sessionId: sessionId,
|
|
74
72
|
appName: 'test',
|
|
75
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
76
73
|
});
|
|
77
74
|
|
|
78
75
|
// Should complete execution and reach the success tool in one go
|
|
@@ -4,7 +4,6 @@ import { z } from 'zod';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
6
6
|
import { HumanMessage } from '@langchain/core/messages';
|
|
7
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
8
7
|
|
|
9
8
|
const memorySchema = z.object({
|
|
10
9
|
userName: z.string(),
|
|
@@ -67,14 +66,11 @@ describe('Prompt Edges', () => {
|
|
|
67
66
|
this.timeout(10000); // Increase timeout to 10 seconds
|
|
68
67
|
|
|
69
68
|
const result = await agent.invoke({
|
|
70
|
-
|
|
71
|
-
body: {
|
|
69
|
+
triggerBody: {
|
|
72
70
|
message: 'Hi, my name is Itay',
|
|
73
71
|
},
|
|
74
|
-
|
|
75
|
-
agentId: 'test',
|
|
72
|
+
triggerName: 'Trigger',
|
|
76
73
|
appName: 'test',
|
|
77
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
78
74
|
});
|
|
79
75
|
|
|
80
76
|
expect(result.memory.userName).to.equal('Itay');
|
|
@@ -84,14 +80,11 @@ describe('Prompt Edges', () => {
|
|
|
84
80
|
this.timeout(10000); // Increase timeout to 10 seconds
|
|
85
81
|
|
|
86
82
|
const result = await agent.invoke({
|
|
87
|
-
|
|
88
|
-
body: {
|
|
83
|
+
triggerBody: {
|
|
89
84
|
message: 'Hi, my name is Ilan',
|
|
90
85
|
},
|
|
91
|
-
|
|
92
|
-
agentId: 'test',
|
|
86
|
+
triggerName: 'Trigger',
|
|
93
87
|
appName: 'test',
|
|
94
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
95
88
|
});
|
|
96
89
|
|
|
97
90
|
expect(result.memory.userName).to.equal('Ilan');
|
|
@@ -5,7 +5,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
7
7
|
import { HumanMessage } from '@langchain/core/messages';
|
|
8
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
9
8
|
|
|
10
9
|
const memorySchema = z.object({
|
|
11
10
|
success: z.boolean(),
|
|
@@ -63,14 +62,12 @@ describe('Prompt Node', function () {
|
|
|
63
62
|
|
|
64
63
|
const sessionId = uuidv4();
|
|
65
64
|
const result = await agent.invoke({
|
|
66
|
-
|
|
67
|
-
body: {
|
|
65
|
+
triggerBody: {
|
|
68
66
|
message: 'Hi there',
|
|
69
67
|
},
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
triggerName: 'Trigger',
|
|
69
|
+
sessionId: sessionId,
|
|
72
70
|
appName: 'test',
|
|
73
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
74
71
|
});
|
|
75
72
|
|
|
76
73
|
// Should pause execution at prompt node
|
|
@@ -78,14 +75,12 @@ describe('Prompt Node', function () {
|
|
|
78
75
|
|
|
79
76
|
// Should resume execution at success node
|
|
80
77
|
const result2 = await agent.invoke({
|
|
81
|
-
|
|
82
|
-
body: {
|
|
78
|
+
triggerBody: {
|
|
83
79
|
message: 'Itay',
|
|
84
80
|
},
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
triggerName: 'Trigger',
|
|
82
|
+
sessionId: sessionId,
|
|
87
83
|
appName: 'test',
|
|
88
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
89
84
|
});
|
|
90
85
|
|
|
91
86
|
expect(result2.memory.success).to.equal(true);
|
|
@@ -4,7 +4,6 @@ import { z } from 'zod';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
6
6
|
import { HumanMessage } from '@langchain/core/messages';
|
|
7
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
8
7
|
|
|
9
8
|
const memorySchema = z.object({
|
|
10
9
|
processed: z.boolean(),
|
|
@@ -57,14 +56,11 @@ describe('Tool Node', function () {
|
|
|
57
56
|
|
|
58
57
|
it('should execute tool with correct input', async () => {
|
|
59
58
|
const result = await agent.invoke({
|
|
60
|
-
|
|
61
|
-
body: {
|
|
59
|
+
triggerBody: {
|
|
62
60
|
message: 'Test message',
|
|
63
61
|
},
|
|
64
|
-
|
|
65
|
-
agentId: 'test',
|
|
62
|
+
triggerName: 'Trigger',
|
|
66
63
|
appName: 'test',
|
|
67
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
68
64
|
});
|
|
69
65
|
|
|
70
66
|
expect(result.memory.processed).to.equal(true);
|
|
@@ -4,7 +4,6 @@ import { z } from 'zod';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
6
6
|
import { HumanMessage } from '@langchain/core/messages';
|
|
7
|
-
import { MindedConnectionSocketMessageType } from '../../src/platform/mindedConnectionTypes';
|
|
8
7
|
import { Tool } from '../../src/types/Tools.types';
|
|
9
8
|
type Memory = z.infer<typeof memorySchema>;
|
|
10
9
|
|
|
@@ -48,14 +47,11 @@ describe('Trigger Node', () => {
|
|
|
48
47
|
tools: [testTool],
|
|
49
48
|
});
|
|
50
49
|
await agent.invoke({
|
|
51
|
-
|
|
52
|
-
body: {
|
|
50
|
+
triggerBody: {
|
|
53
51
|
message: 'Test message',
|
|
54
52
|
},
|
|
55
|
-
|
|
56
|
-
agentId: 'test',
|
|
53
|
+
triggerName: 'Trigger',
|
|
57
54
|
appName: 'test',
|
|
58
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
59
55
|
});
|
|
60
56
|
|
|
61
57
|
});
|
|
@@ -89,14 +85,11 @@ describe('Trigger Node', () => {
|
|
|
89
85
|
this.timeout(10000); // Increase timeout to 10 seconds
|
|
90
86
|
|
|
91
87
|
const result = await agent.invoke({
|
|
92
|
-
|
|
93
|
-
body: {
|
|
88
|
+
triggerBody: {
|
|
94
89
|
message: 'Test message',
|
|
95
90
|
},
|
|
96
|
-
|
|
97
|
-
agentId: 'test',
|
|
91
|
+
triggerName: 'Trigger',
|
|
98
92
|
appName: 'test',
|
|
99
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
100
93
|
});
|
|
101
94
|
|
|
102
95
|
expect(result.messages).to.have.lengthOf(1);
|
|
@@ -123,14 +116,11 @@ describe('Trigger Node', () => {
|
|
|
123
116
|
});
|
|
124
117
|
|
|
125
118
|
await agent.invoke({
|
|
126
|
-
|
|
127
|
-
body: {
|
|
119
|
+
triggerBody: {
|
|
128
120
|
message: 'Test message',
|
|
129
121
|
},
|
|
130
|
-
|
|
131
|
-
agentId: 'test',
|
|
122
|
+
triggerName: 'Trigger',
|
|
132
123
|
appName: 'test',
|
|
133
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
134
124
|
});
|
|
135
125
|
});
|
|
136
126
|
|
|
@@ -153,14 +143,11 @@ describe('Trigger Node', () => {
|
|
|
153
143
|
});
|
|
154
144
|
|
|
155
145
|
const slackResult = await agent.invoke({
|
|
156
|
-
|
|
157
|
-
body: {
|
|
146
|
+
triggerBody: {
|
|
158
147
|
text: 'Hello from Slack'
|
|
159
148
|
},
|
|
160
|
-
|
|
161
|
-
agentId: 'test',
|
|
149
|
+
triggerName: 'New Direct Message (Instant)',
|
|
162
150
|
appName: 'Slack',
|
|
163
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
164
151
|
});
|
|
165
152
|
|
|
166
153
|
expect(slackResult.messages).to.have.lengthOf(1);
|
|
@@ -186,14 +173,11 @@ describe('Trigger Node', () => {
|
|
|
186
173
|
});
|
|
187
174
|
|
|
188
175
|
const otherResult = await agent.invoke({
|
|
189
|
-
|
|
190
|
-
body: {
|
|
176
|
+
triggerBody: {
|
|
191
177
|
text: 'Hello from other app'
|
|
192
178
|
},
|
|
193
|
-
|
|
194
|
-
agentId: 'test',
|
|
179
|
+
triggerName: 'SomeOtherTrigger',
|
|
195
180
|
appName: 'OtherApp',
|
|
196
|
-
type: MindedConnectionSocketMessageType.OnAppTrigger,
|
|
197
181
|
});
|
|
198
182
|
|
|
199
183
|
expect(otherResult.messages).to.have.lengthOf(0);
|