@minded-ai/mindedjs 1.0.29 → 1.0.30
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 +1 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/checkpointer/checkpointSaverFactory.d.ts +1 -0
- package/dist/checkpointer/checkpointSaverFactory.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +0 -0
- package/dist/edges/createDirectEdge.d.ts +1 -0
- package/dist/edges/createDirectEdge.d.ts.map +1 -0
- package/dist/edges/createLogicalRouter.d.ts +1 -0
- package/dist/edges/createLogicalRouter.d.ts.map +1 -0
- package/dist/edges/createPromptRouter.d.ts +1 -0
- package/dist/edges/createPromptRouter.d.ts.map +1 -0
- package/dist/edges/edgeFactory.d.ts +1 -0
- package/dist/edges/edgeFactory.d.ts.map +1 -0
- package/dist/events/AgentEvents.d.ts +1 -0
- package/dist/events/AgentEvents.d.ts.map +1 -0
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/llm/createLlmInstance.d.ts +1 -0
- package/dist/llm/createLlmInstance.d.ts.map +1 -0
- package/dist/nodes/addHumanInTheLoopNode.d.ts +1 -0
- package/dist/nodes/addHumanInTheLoopNode.d.ts.map +1 -0
- package/dist/nodes/addPromptNode.d.ts +1 -0
- package/dist/nodes/addPromptNode.d.ts.map +1 -0
- package/dist/nodes/addToolNode.d.ts +1 -0
- package/dist/nodes/addToolNode.d.ts.map +1 -0
- package/dist/nodes/addTriggerNode.d.ts +1 -0
- package/dist/nodes/addTriggerNode.d.ts.map +1 -0
- package/dist/nodes/nodeFactory.d.ts +1 -0
- package/dist/nodes/nodeFactory.d.ts.map +1 -0
- package/dist/platform/config.d.ts +1 -0
- package/dist/platform/config.d.ts.map +1 -0
- package/dist/platform/mindedChatOpenAI.d.ts +1 -0
- package/dist/platform/mindedChatOpenAI.d.ts.map +1 -0
- package/dist/platform/mindedCheckpointSaver.d.ts +1 -0
- package/dist/platform/mindedCheckpointSaver.d.ts.map +1 -0
- package/dist/platform/mindedConnection.d.ts +1 -0
- package/dist/platform/mindedConnection.d.ts.map +1 -0
- package/dist/platform/mindedConnectionTypes.d.ts +1 -0
- package/dist/platform/mindedConnectionTypes.d.ts.map +1 -0
- package/dist/platform/mindedRequest.js +2 -2
- package/dist/platform/mindedRequest.js.map +1 -1
- package/dist/triggers/triggerTypeToDefaultMessage.d.ts +1 -0
- package/dist/triggers/triggerTypeToDefaultMessage.d.ts.map +1 -0
- package/dist/types/Agent.types.d.ts +1 -0
- package/dist/types/Agent.types.d.ts.map +1 -0
- package/dist/types/Flows.types.d.ts +1 -0
- package/dist/types/Flows.types.d.ts.map +1 -0
- package/dist/types/LLM.types.d.ts +1 -0
- package/dist/types/LLM.types.d.ts.map +1 -0
- package/dist/types/LangGraph.types.d.ts +1 -0
- package/dist/types/LangGraph.types.d.ts.map +1 -0
- package/dist/types/Tools.types.d.ts +1 -0
- package/dist/types/Tools.types.d.ts.map +1 -0
- package/dist/types/Triggers.types.d.ts +1 -0
- package/dist/types/Triggers.types.js +3 -0
- package/dist/types/Triggers.types.js.map +1 -0
- package/package.json +6 -2
- package/.github/workflows/CI.yml +0 -34
- package/.prettierrc +0 -8
- package/dist/internalTools/appActionRunnerTool.d.ts +0 -6
- package/dist/internalTools/appActionRunnerTool.js +0 -55
- package/dist/internalTools/appActionRunnerTool.js.map +0 -1
- package/dist/nodes/actionRunnerTool.d.ts +0 -11
- package/dist/nodes/actionRunnerTool.js +0 -84
- package/dist/nodes/actionRunnerTool.js.map +0 -1
- package/dist/nodes/addAppTool.d.ts +0 -8
- package/dist/nodes/addAppTool.js +0 -12
- package/dist/nodes/addAppTool.js.map +0 -1
- package/dist/nodes/addAppToolNode.d.ts +0 -8
- package/dist/nodes/addAppToolNode.js +0 -29
- package/dist/nodes/addAppToolNode.js.map +0 -1
- package/dist/nodes/callTool.d.ts +0 -10
- package/dist/nodes/callTool.js +0 -57
- package/dist/nodes/callTool.js.map +0 -1
- package/dist/nodes/toolNodeRunner.d.ts +0 -15
- package/dist/nodes/toolNodeRunner.js +0 -79
- package/dist/nodes/toolNodeRunner.js.map +0 -1
- package/dist/tools/appToolRunner.d.ts +0 -30
- package/dist/tools/appToolRunner.js +0 -35
- package/dist/tools/appToolRunner.js.map +0 -1
- package/dist/tools/parser.d.ts +0 -14
- package/dist/tools/parser.js +0 -17
- package/dist/tools/parser.js.map +0 -1
- package/dist/tools/triggerTypeToDefaultMessage.d.ts +0 -3
- package/dist/tools/triggerTypeToDefaultMessage.js +0 -10
- package/dist/tools/triggerTypeToDefaultMessage.js.map +0 -1
- package/docs/.gitbook/assets/image.png +0 -0
- package/docs/README.md +0 -51
- package/docs/SUMMARY.md +0 -23
- package/docs/api-reference/.nojekyll +0 -1
- package/docs/api-reference/assets/hierarchy.js +0 -1
- package/docs/api-reference/assets/highlight.css +0 -120
- package/docs/api-reference/assets/icons.js +0 -18
- package/docs/api-reference/assets/icons.svg +0 -1
- package/docs/api-reference/assets/main.js +0 -60
- package/docs/api-reference/assets/navigation.js +0 -1
- package/docs/api-reference/assets/search.js +0 -1
- package/docs/api-reference/assets/style.css +0 -1640
- package/docs/api-reference/classes/index.Agent.html +0 -4
- package/docs/api-reference/enums/index.EdgeType.html +0 -4
- package/docs/api-reference/enums/index.NodeType.html +0 -6
- package/docs/api-reference/enums/index.TriggerType.html +0 -4
- package/docs/api-reference/enums/index.events.html +0 -3
- package/docs/api-reference/hierarchy.html +0 -1
- package/docs/api-reference/index.html +0 -310
- package/docs/api-reference/interfaces/index.AppToolNode.html +0 -5
- package/docs/api-reference/interfaces/index.AppTriggerNode.html +0 -6
- package/docs/api-reference/interfaces/index.Flow.html +0 -4
- package/docs/api-reference/interfaces/index.JunctionNode.html +0 -4
- package/docs/api-reference/interfaces/index.LogicalConditionEdge.html +0 -5
- package/docs/api-reference/interfaces/index.ManualTriggerNode.html +0 -5
- package/docs/api-reference/interfaces/index.PromptConditionEdge.html +0 -5
- package/docs/api-reference/interfaces/index.PromptNode.html +0 -6
- package/docs/api-reference/interfaces/index.StepForwardEdge.html +0 -4
- package/docs/api-reference/interfaces/index.Tool.html +0 -6
- package/docs/api-reference/interfaces/index.ToolNode.html +0 -5
- package/docs/api-reference/modules/index-1.html +0 -1
- package/docs/api-reference/modules/index.html +0 -1
- package/docs/api-reference/modules.html +0 -1
- package/docs/api-reference/types/index.Edge.html +0 -1
- package/docs/api-reference/types/index.Node.html +0 -1
- package/docs/api-reference/types/index.TriggerNode.html +0 -1
- package/docs/core-concepts/edges.md +0 -299
- package/docs/core-concepts/events.md +0 -165
- package/docs/core-concepts/flows.md +0 -74
- package/docs/core-concepts/memory-types.md +0 -208
- package/docs/core-concepts/nodes.md +0 -257
- package/docs/core-concepts/tools.md +0 -225
- package/docs/core-concepts/triggers.md +0 -87
- package/docs/examples/order-refund-flow.md +0 -560
- package/docs/getting-started/environment-configuration.md +0 -117
- package/docs/getting-started/installation.md +0 -40
- package/docs/getting-started/quick-start.md +0 -264
- package/docs-structure.md +0 -144
- package/eslint.config.js +0 -68
- package/examples/orderRefundAgent/flows/orderRefundFlow.yaml +0 -26
- package/examples/orderRefundAgent/minded.json +0 -10
- package/examples/orderRefundAgent/orderRefundAgent.ts +0 -64
- package/examples/orderRefundAgent/schema.ts +0 -7
- package/examples/orderRefundAgent/tools/escalateConversation.ts +0 -28
- package/examples/orderRefundAgent/tools/index.ts +0 -4
- package/examples/orderRefundAgent/tools/refundOrder.ts +0 -27
- package/test/can-stay-on-node/can-stay-on-node.test.ts +0 -154
- package/test/can-stay-on-node/flows/test-flow.yaml +0 -25
- package/test/cannot-stay-on-node/cannot-stay-on-node.test.ts +0 -209
- package/test/cannot-stay-on-node/flows/test-flow.yaml +0 -34
- package/test/checkpoint-saver/minded-checkpoint-saver-list.test.ts +0 -140
- package/test/checkpoint-saver/minded-checkpoint-saver.test.ts +0 -100
- package/test/edge-priority/edge-priority.test.ts +0 -182
- package/test/edge-priority/flows/all-three-edges/test-flow.yaml +0 -35
- package/test/edge-priority/flows/logical-prompt-edges/test-flow.yaml +0 -26
- package/test/edge-priority/flows/stepforward-logical-edges/test-flow.yaml +0 -25
- package/test/edge-priority/flows/stepforward-prompt-edges/test-flow.yaml +0 -25
- package/test/human-in-the-loop-node/flows/test-flow.yaml +0 -23
- package/test/human-in-the-loop-node/human-in-the-loop-node.test.ts +0 -94
- package/test/logical-edges/flows/logical-edge-test-flow.yaml +0 -24
- package/test/logical-edges/logical-edges.test.ts +0 -68
- package/test/no-human-in-the-loop-node/flows/test-flow.yaml +0 -23
- package/test/no-human-in-the-loop-node/no-human-in-the-loop-node.test.ts +0 -81
- package/test/prompt-edges/flows/test-flow.yaml +0 -24
- package/test/prompt-edges/prompt-edges.test.ts +0 -92
- package/test/prompt-node/flows/test-flow.yaml +0 -24
- package/test/prompt-node/prompt-node.test.ts +0 -88
- package/test/setup.ts +0 -5
- package/test/tool-node/flows/test-flow.yaml +0 -14
- package/test/tool-node/tool-node.test.ts +0 -68
- package/test/trigger/flows/test-flow.yaml +0 -7
- package/test/trigger/trigger.test.ts +0 -185
- package/tsconfig.json +0 -17
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { Agent } from '../../src/agent';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
6
|
-
import { HumanMessage } from '@langchain/core/messages';
|
|
7
|
-
|
|
8
|
-
const memorySchema = z.object({
|
|
9
|
-
result: z.string().optional(),
|
|
10
|
-
userAge: z.number().optional(),
|
|
11
|
-
userName: z.string().optional(),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const createTestAgent = (flowsPath: string) => {
|
|
15
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
16
|
-
const agent = new Agent({
|
|
17
|
-
memorySchema,
|
|
18
|
-
config: {
|
|
19
|
-
flows: [flowsPath],
|
|
20
|
-
tools: [toolsPath],
|
|
21
|
-
llm: {
|
|
22
|
-
name: 'ChatOpenAI',
|
|
23
|
-
properties: {
|
|
24
|
-
model: 'gpt-4.1',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
tools: [
|
|
29
|
-
{
|
|
30
|
-
name: 'stepForwardTool',
|
|
31
|
-
description: 'Step Forward Tool',
|
|
32
|
-
input: z.object({
|
|
33
|
-
message: z.string(),
|
|
34
|
-
}),
|
|
35
|
-
execute: async () => ({
|
|
36
|
-
memory: { result: 'stepForward' },
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'logicalTool',
|
|
41
|
-
description: 'Logical Tool',
|
|
42
|
-
input: z.object({
|
|
43
|
-
message: z.string(),
|
|
44
|
-
}),
|
|
45
|
-
execute: async () => ({
|
|
46
|
-
memory: { result: 'logical' },
|
|
47
|
-
}),
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'promptTool',
|
|
51
|
-
description: 'Prompt Tool',
|
|
52
|
-
input: z.object({
|
|
53
|
-
message: z.string(),
|
|
54
|
-
}),
|
|
55
|
-
execute: async () => ({
|
|
56
|
-
memory: { result: 'prompt' },
|
|
57
|
-
}),
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Add trigger event handler
|
|
63
|
-
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
|
|
64
|
-
if (triggerName === 'TestTrigger') {
|
|
65
|
-
return {
|
|
66
|
-
memory: triggerBody.memory || {},
|
|
67
|
-
messages: [new HumanMessage(triggerBody.message)],
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return agent;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
describe('Edge Priority Logic', () => {
|
|
76
|
-
describe('All 3 Edge Types (Step Forward > Logical > Prompt)', () => {
|
|
77
|
-
let agent: Agent;
|
|
78
|
-
|
|
79
|
-
beforeEach(() => {
|
|
80
|
-
const flowsPath = path.join(__dirname, 'flows/all-three-edges');
|
|
81
|
-
agent = createTestAgent(flowsPath);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should prioritize step forward over logical and prompt', async function () {
|
|
85
|
-
this.timeout(20000);
|
|
86
|
-
|
|
87
|
-
const result = await agent.invoke({
|
|
88
|
-
triggerBody: {
|
|
89
|
-
message: 'Test message',
|
|
90
|
-
memory: { userAge: 25, userName: 'Test' }, // Satisfies logical condition
|
|
91
|
-
},
|
|
92
|
-
triggerName: 'TestTrigger',
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Step forward should win regardless of other conditions
|
|
96
|
-
expect(result.memory.result).to.equal('stepForward');
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('Logical + Prompt Edges (Logical > Prompt)', () => {
|
|
101
|
-
let agent: Agent;
|
|
102
|
-
|
|
103
|
-
beforeEach(() => {
|
|
104
|
-
const flowsPath = path.join(__dirname, 'flows/logical-prompt-edges');
|
|
105
|
-
agent = createTestAgent(flowsPath);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should prioritize logical over prompt when logical condition is met', async function () {
|
|
109
|
-
this.timeout(20000);
|
|
110
|
-
|
|
111
|
-
const result = await agent.invoke({
|
|
112
|
-
triggerBody: {
|
|
113
|
-
message: 'Test message',
|
|
114
|
-
memory: { userAge: 25 }, // Satisfies logical condition (age >= 18)
|
|
115
|
-
},
|
|
116
|
-
triggerName: 'TestTrigger',
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
expect(result.memory.result).to.equal('logical');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should fall back to prompt when logical condition is not met', async function () {
|
|
123
|
-
this.timeout(20000);
|
|
124
|
-
|
|
125
|
-
const result = await agent.invoke({
|
|
126
|
-
triggerBody: {
|
|
127
|
-
message: 'Test message',
|
|
128
|
-
memory: { userAge: 15 }, // Does not satisfy logical condition (age < 18)
|
|
129
|
-
},
|
|
130
|
-
triggerName: 'TestTrigger',
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
expect(result.memory.result).to.equal('prompt');
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
describe('Step Forward + Prompt Edges (Step Forward > Prompt)', () => {
|
|
138
|
-
let agent: Agent;
|
|
139
|
-
|
|
140
|
-
beforeEach(() => {
|
|
141
|
-
const flowsPath = path.join(__dirname, 'flows/stepforward-prompt-edges');
|
|
142
|
-
agent = createTestAgent(flowsPath);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('should prioritize step forward over prompt', async function () {
|
|
146
|
-
this.timeout(20000);
|
|
147
|
-
|
|
148
|
-
const result = await agent.invoke({
|
|
149
|
-
triggerBody: {
|
|
150
|
-
message: 'Test message',
|
|
151
|
-
memory: { userName: 'TestUser' }, // Would satisfy prompt condition
|
|
152
|
-
},
|
|
153
|
-
triggerName: 'TestTrigger',
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
expect(result.memory.result).to.equal('stepForward');
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe('Step Forward + Logical Edges (Step Forward > Logical)', () => {
|
|
161
|
-
let agent: Agent;
|
|
162
|
-
|
|
163
|
-
beforeEach(() => {
|
|
164
|
-
const flowsPath = path.join(__dirname, 'flows/stepforward-logical-edges');
|
|
165
|
-
agent = createTestAgent(flowsPath);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should prioritize step forward over logical', async function () {
|
|
169
|
-
this.timeout(20000);
|
|
170
|
-
|
|
171
|
-
const result = await agent.invoke({
|
|
172
|
-
triggerBody: {
|
|
173
|
-
message: 'Test message',
|
|
174
|
-
memory: { userAge: 25 }, // Would satisfy logical condition
|
|
175
|
-
},
|
|
176
|
-
triggerName: 'TestTrigger',
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
expect(result.memory.result).to.equal('stepForward');
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
name: All Three Edges Priority Test
|
|
2
|
-
nodes:
|
|
3
|
-
- type: 'trigger'
|
|
4
|
-
triggerType: 'manual'
|
|
5
|
-
name: 'TestTrigger'
|
|
6
|
-
|
|
7
|
-
- type: 'tool'
|
|
8
|
-
name: 'Step Forward Tool'
|
|
9
|
-
toolName: 'stepForwardTool'
|
|
10
|
-
|
|
11
|
-
- type: 'tool'
|
|
12
|
-
name: 'Logical Tool'
|
|
13
|
-
toolName: 'logicalTool'
|
|
14
|
-
|
|
15
|
-
- type: 'tool'
|
|
16
|
-
name: 'Prompt Tool'
|
|
17
|
-
toolName: 'promptTool'
|
|
18
|
-
|
|
19
|
-
edges:
|
|
20
|
-
# Prompt condition edge (Priority 3)
|
|
21
|
-
- source: 'TestTrigger'
|
|
22
|
-
target: 'Prompt Tool'
|
|
23
|
-
type: 'promptCondition'
|
|
24
|
-
prompt: 'User wants to use prompt tool'
|
|
25
|
-
|
|
26
|
-
# Step forward edge (Priority 1 - should win)
|
|
27
|
-
- source: 'TestTrigger'
|
|
28
|
-
target: 'Step Forward Tool'
|
|
29
|
-
type: 'stepForward'
|
|
30
|
-
|
|
31
|
-
# Logical condition edge (Priority 2)
|
|
32
|
-
- source: 'TestTrigger'
|
|
33
|
-
target: 'Logical Tool'
|
|
34
|
-
type: 'logicalCondition'
|
|
35
|
-
condition: '({ memory }) => memory.userAge >= 18'
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Logical + Prompt Edges Priority Test
|
|
2
|
-
nodes:
|
|
3
|
-
- type: 'trigger'
|
|
4
|
-
triggerType: 'manual'
|
|
5
|
-
name: 'TestTrigger'
|
|
6
|
-
|
|
7
|
-
- type: 'tool'
|
|
8
|
-
name: 'Logical Tool'
|
|
9
|
-
toolName: 'logicalTool'
|
|
10
|
-
|
|
11
|
-
- type: 'tool'
|
|
12
|
-
name: 'Prompt Tool'
|
|
13
|
-
toolName: 'promptTool'
|
|
14
|
-
|
|
15
|
-
edges:
|
|
16
|
-
# Prompt condition edge (Priority 3 - fallback when logical fails)
|
|
17
|
-
- source: 'TestTrigger'
|
|
18
|
-
target: 'Prompt Tool'
|
|
19
|
-
type: 'promptCondition'
|
|
20
|
-
prompt: 'User wants to use prompt tool'
|
|
21
|
-
|
|
22
|
-
# Logical condition edge (Priority 2 - should win when condition met)
|
|
23
|
-
- source: 'TestTrigger'
|
|
24
|
-
target: 'Logical Tool'
|
|
25
|
-
type: 'logicalCondition'
|
|
26
|
-
condition: '({ memory }) => memory.userAge >= 18'
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Step Forward + Logical Edges Priority Test
|
|
2
|
-
nodes:
|
|
3
|
-
- type: 'trigger'
|
|
4
|
-
triggerType: 'manual'
|
|
5
|
-
name: 'TestTrigger'
|
|
6
|
-
|
|
7
|
-
- type: 'tool'
|
|
8
|
-
name: 'Step Forward Tool'
|
|
9
|
-
toolName: 'stepForwardTool'
|
|
10
|
-
|
|
11
|
-
- type: 'tool'
|
|
12
|
-
name: 'Logical Tool'
|
|
13
|
-
toolName: 'logicalTool'
|
|
14
|
-
|
|
15
|
-
edges:
|
|
16
|
-
# Logical condition edge (Priority 2)
|
|
17
|
-
- source: 'TestTrigger'
|
|
18
|
-
target: 'Logical Tool'
|
|
19
|
-
type: 'logicalCondition'
|
|
20
|
-
condition: '({ memory }) => memory.userAge >= 18'
|
|
21
|
-
|
|
22
|
-
# Step forward edge (Priority 1 - should win)
|
|
23
|
-
- source: 'TestTrigger'
|
|
24
|
-
target: 'Step Forward Tool'
|
|
25
|
-
type: 'stepForward'
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Step Forward + Prompt Edges Priority Test
|
|
2
|
-
nodes:
|
|
3
|
-
- type: 'trigger'
|
|
4
|
-
triggerType: 'manual'
|
|
5
|
-
name: 'TestTrigger'
|
|
6
|
-
|
|
7
|
-
- type: 'tool'
|
|
8
|
-
name: 'Step Forward Tool'
|
|
9
|
-
toolName: 'stepForwardTool'
|
|
10
|
-
|
|
11
|
-
- type: 'tool'
|
|
12
|
-
name: 'Prompt Tool'
|
|
13
|
-
toolName: 'promptTool'
|
|
14
|
-
|
|
15
|
-
edges:
|
|
16
|
-
# Prompt condition edge (Priority 3)
|
|
17
|
-
- source: 'TestTrigger'
|
|
18
|
-
target: 'Prompt Tool'
|
|
19
|
-
type: 'promptCondition'
|
|
20
|
-
prompt: 'User wants to use prompt tool'
|
|
21
|
-
|
|
22
|
-
# Step forward edge (Priority 1 - should win)
|
|
23
|
-
- source: 'TestTrigger'
|
|
24
|
-
target: 'Step Forward Tool'
|
|
25
|
-
type: 'stepForward'
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: Human In The Loop Test Flow
|
|
2
|
-
nodes:
|
|
3
|
-
- type: 'trigger'
|
|
4
|
-
triggerType: 'manual'
|
|
5
|
-
name: 'Trigger'
|
|
6
|
-
|
|
7
|
-
- type: 'promptNode'
|
|
8
|
-
name: 'ProcessingNode'
|
|
9
|
-
prompt: 'Process the user input and prepare for human review'
|
|
10
|
-
humanInTheLoop: true
|
|
11
|
-
|
|
12
|
-
- type: 'tool'
|
|
13
|
-
name: 'Success'
|
|
14
|
-
toolName: 'successTool'
|
|
15
|
-
|
|
16
|
-
edges:
|
|
17
|
-
- source: 'Trigger'
|
|
18
|
-
target: 'ProcessingNode'
|
|
19
|
-
type: 'stepForward'
|
|
20
|
-
|
|
21
|
-
- source: 'ProcessingNode'
|
|
22
|
-
target: 'Success'
|
|
23
|
-
type: 'stepForward'
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { Agent } from '../../src/agent';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
7
|
-
import { HumanMessage } from '@langchain/core/messages';
|
|
8
|
-
|
|
9
|
-
const memorySchema = z.object({
|
|
10
|
-
success: z.boolean(),
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe('Human In The Loop Node', function () {
|
|
14
|
-
this.timeout(10000); // Set timeout to 10 seconds for all tests in this suite
|
|
15
|
-
|
|
16
|
-
let agent: Agent;
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
20
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
21
|
-
agent = new Agent({
|
|
22
|
-
memorySchema,
|
|
23
|
-
config: {
|
|
24
|
-
flows: [flowsPath],
|
|
25
|
-
tools: [toolsPath],
|
|
26
|
-
llm: {
|
|
27
|
-
name: 'ChatOpenAI',
|
|
28
|
-
properties: {
|
|
29
|
-
model: 'gpt-4.1',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
tools: [
|
|
34
|
-
{
|
|
35
|
-
name: 'successTool',
|
|
36
|
-
description: 'Success Tool',
|
|
37
|
-
input: z.object({
|
|
38
|
-
name: z.string(),
|
|
39
|
-
}),
|
|
40
|
-
execute: async () => ({
|
|
41
|
-
memory: {
|
|
42
|
-
success: true,
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Add trigger event handler
|
|
50
|
-
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
|
|
51
|
-
if (triggerName === 'Trigger') {
|
|
52
|
-
return {
|
|
53
|
-
memory: {},
|
|
54
|
-
messages: [new HumanMessage(triggerBody.message)],
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should pause execution at human-in-the-loop node and resume after human input', async function () {
|
|
61
|
-
this.timeout(20000); // Set timeout to 20 seconds for this test
|
|
62
|
-
|
|
63
|
-
const sessionId = uuidv4();
|
|
64
|
-
|
|
65
|
-
// First invocation should execute the ProcessingNode and then pause at the human-in-the-loop node
|
|
66
|
-
const result = await agent.invoke({
|
|
67
|
-
triggerBody: {
|
|
68
|
-
message: 'Initial user input for processing',
|
|
69
|
-
},
|
|
70
|
-
triggerName: 'Trigger',
|
|
71
|
-
sessionId: sessionId,
|
|
72
|
-
appName: 'test',
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Should pause execution at human-in-the-loop node, not reaching the success tool yet
|
|
76
|
-
expect(result.memory.success).to.not.equal(true);
|
|
77
|
-
|
|
78
|
-
// Verify that we have messages from the processing node
|
|
79
|
-
expect(result.messages).to.have.length.greaterThan(0);
|
|
80
|
-
|
|
81
|
-
// Second invocation should provide human input and continue to the Success node
|
|
82
|
-
const result2 = await agent.invoke({
|
|
83
|
-
triggerBody: {
|
|
84
|
-
message: 'Human approval: proceed with the workflow',
|
|
85
|
-
},
|
|
86
|
-
triggerName: 'Trigger',
|
|
87
|
-
sessionId: sessionId,
|
|
88
|
-
appName: 'test',
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// Should complete execution and reach the success tool
|
|
92
|
-
expect(result2.memory.success).to.equal(true);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
name: Age Flow
|
|
2
|
-
nodes:
|
|
3
|
-
- type: "trigger"
|
|
4
|
-
triggerType: "manual"
|
|
5
|
-
name: "AgeTrigger"
|
|
6
|
-
|
|
7
|
-
- type: "tool"
|
|
8
|
-
name: "Adult Tool"
|
|
9
|
-
toolName: "adultTool"
|
|
10
|
-
|
|
11
|
-
- type: "tool"
|
|
12
|
-
name: "Minor Tool"
|
|
13
|
-
toolName: "minorTool"
|
|
14
|
-
|
|
15
|
-
edges:
|
|
16
|
-
- source: "AgeTrigger"
|
|
17
|
-
target: "Adult Tool"
|
|
18
|
-
type: "logicalCondition"
|
|
19
|
-
condition: "({ memory }) => memory.userAge >= 18"
|
|
20
|
-
|
|
21
|
-
- source: "AgeTrigger"
|
|
22
|
-
target: "Minor Tool"
|
|
23
|
-
type: "logicalCondition"
|
|
24
|
-
condition: "({ memory }) => memory.userAge < 18"
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { Agent } from "../../src/agent";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { AgentEvents } from "../../src/events/AgentEvents";
|
|
6
|
-
|
|
7
|
-
const memorySchema = z.object({
|
|
8
|
-
userAge: z.number(),
|
|
9
|
-
isMinor: z.boolean(),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('Logical Edges', () => {
|
|
13
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
14
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
15
|
-
const agent = new Agent({
|
|
16
|
-
memorySchema,
|
|
17
|
-
config: {
|
|
18
|
-
flows: [flowsPath],
|
|
19
|
-
tools: [toolsPath],
|
|
20
|
-
llm: {
|
|
21
|
-
name: 'ChatOpenAI',
|
|
22
|
-
properties: {
|
|
23
|
-
model: 'gpt-4.1'
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
tools: [
|
|
28
|
-
{
|
|
29
|
-
name: 'adultTool',
|
|
30
|
-
description: 'Adult Tool',
|
|
31
|
-
input: z.object({}),
|
|
32
|
-
execute: async () => ({ memory: { isMinor: false } }),
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'minorTool',
|
|
36
|
-
description: 'Minor Tool',
|
|
37
|
-
input: z.object({}),
|
|
38
|
-
execute: async () => ({ memory: { isMinor: true } }),
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerBody }) => {
|
|
44
|
-
return {
|
|
45
|
-
memory: triggerBody
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should execute the Adult Tool', async function () {
|
|
50
|
-
this.timeout(10000); // Increase timeout to 10 seconds
|
|
51
|
-
const result = await agent.invoke({
|
|
52
|
-
triggerBody: { userAge: 25 },
|
|
53
|
-
triggerName: 'AgeTrigger',
|
|
54
|
-
appName: 'test',
|
|
55
|
-
});
|
|
56
|
-
expect(result.memory.isMinor).to.equal(false);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should execute the Minor Tool', async function () {
|
|
60
|
-
this.timeout(10000); // Increase timeout to 10 seconds
|
|
61
|
-
const result = await agent.invoke({
|
|
62
|
-
triggerBody: { userAge: 15 },
|
|
63
|
-
triggerName: 'AgeTrigger',
|
|
64
|
-
appName: 'test',
|
|
65
|
-
});
|
|
66
|
-
expect(result.memory.isMinor).to.equal(true);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
name: No Human In The Loop Test Flow
|
|
2
|
-
nodes:
|
|
3
|
-
- type: 'trigger'
|
|
4
|
-
triggerType: 'manual'
|
|
5
|
-
name: 'Trigger'
|
|
6
|
-
|
|
7
|
-
- type: 'promptNode'
|
|
8
|
-
name: 'ProcessingNode'
|
|
9
|
-
prompt: 'Process the user input and prepare for completion'
|
|
10
|
-
humanInTheLoop: false
|
|
11
|
-
|
|
12
|
-
- type: 'tool'
|
|
13
|
-
name: 'Success'
|
|
14
|
-
toolName: 'successTool'
|
|
15
|
-
|
|
16
|
-
edges:
|
|
17
|
-
- source: 'Trigger'
|
|
18
|
-
target: 'ProcessingNode'
|
|
19
|
-
type: 'stepForward'
|
|
20
|
-
|
|
21
|
-
- source: 'ProcessingNode'
|
|
22
|
-
target: 'Success'
|
|
23
|
-
type: 'stepForward'
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { Agent } from '../../src/agent';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { AgentEvents } from '../../src/events/AgentEvents';
|
|
7
|
-
import { HumanMessage } from '@langchain/core/messages';
|
|
8
|
-
|
|
9
|
-
const memorySchema = z.object({
|
|
10
|
-
success: z.boolean(),
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe('No Human In The Loop Node', function () {
|
|
14
|
-
this.timeout(10000); // Set timeout to 10 seconds for all tests in this suite
|
|
15
|
-
|
|
16
|
-
let agent: Agent;
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
20
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
21
|
-
agent = new Agent({
|
|
22
|
-
memorySchema,
|
|
23
|
-
config: {
|
|
24
|
-
flows: [flowsPath],
|
|
25
|
-
tools: [toolsPath],
|
|
26
|
-
llm: {
|
|
27
|
-
name: 'ChatOpenAI',
|
|
28
|
-
properties: {
|
|
29
|
-
model: 'gpt-4.1',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
tools: [
|
|
34
|
-
{
|
|
35
|
-
name: 'successTool',
|
|
36
|
-
description: 'Success Tool',
|
|
37
|
-
input: z.object({
|
|
38
|
-
name: z.string(),
|
|
39
|
-
}),
|
|
40
|
-
execute: async () => ({
|
|
41
|
-
memory: {
|
|
42
|
-
success: true,
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Add trigger event handler
|
|
50
|
-
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
|
|
51
|
-
if (triggerName === 'Trigger') {
|
|
52
|
-
return {
|
|
53
|
-
memory: {},
|
|
54
|
-
messages: [new HumanMessage(triggerBody.message)],
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should complete execution without pausing when humanInTheLoop is false', async function () {
|
|
61
|
-
this.timeout(20000); // Set timeout to 20 seconds for this test
|
|
62
|
-
|
|
63
|
-
const sessionId = uuidv4();
|
|
64
|
-
|
|
65
|
-
// Single invocation should complete the entire flow without pausing
|
|
66
|
-
const result = await agent.invoke({
|
|
67
|
-
triggerBody: {
|
|
68
|
-
message: 'Input for processing without human intervention',
|
|
69
|
-
},
|
|
70
|
-
triggerName: 'Trigger',
|
|
71
|
-
sessionId: sessionId,
|
|
72
|
-
appName: 'test',
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Should complete execution and reach the success tool in one go
|
|
76
|
-
expect(result.memory.success).to.equal(true);
|
|
77
|
-
|
|
78
|
-
// Verify that we have messages from both the processing node and the tool execution
|
|
79
|
-
expect(result.messages).to.have.length.greaterThan(0);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
name: Test Flow
|
|
2
|
-
nodes:
|
|
3
|
-
- type: 'trigger'
|
|
4
|
-
triggerType: 'manual'
|
|
5
|
-
name: 'Trigger'
|
|
6
|
-
|
|
7
|
-
- type: 'tool'
|
|
8
|
-
name: 'Success Tool'
|
|
9
|
-
toolName: 'successTool'
|
|
10
|
-
|
|
11
|
-
- type: 'tool'
|
|
12
|
-
name: 'Failure Tool'
|
|
13
|
-
toolName: 'failureTool'
|
|
14
|
-
|
|
15
|
-
edges:
|
|
16
|
-
- source: 'Trigger'
|
|
17
|
-
target: 'Success Tool'
|
|
18
|
-
type: 'promptCondition'
|
|
19
|
-
prompt: 'User name is Itay'
|
|
20
|
-
|
|
21
|
-
- source: 'Trigger'
|
|
22
|
-
target: 'Failure Tool'
|
|
23
|
-
type: 'promptCondition'
|
|
24
|
-
prompt: 'User name is not Itay'
|