@minded-ai/mindedjs 1.0.28 → 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/agent.js +1 -1
- package/dist/agent.js.map +1 -1
- 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/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/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/package.json +5 -1
- package/src/agent.ts +1 -1
- package/.github/workflows/CI.yml +0 -34
- package/.prettierrc +0 -8
- 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,92 +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
|
-
userName: z.string(),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('Prompt Edges', () => {
|
|
13
|
-
let agent: Agent;
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
17
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
18
|
-
agent = new Agent({
|
|
19
|
-
memorySchema,
|
|
20
|
-
config: {
|
|
21
|
-
flows: [flowsPath],
|
|
22
|
-
tools: [toolsPath],
|
|
23
|
-
llm: {
|
|
24
|
-
name: 'ChatOpenAI',
|
|
25
|
-
properties: {
|
|
26
|
-
model: 'gpt-4.1'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
tools: [
|
|
31
|
-
{
|
|
32
|
-
name: 'successTool',
|
|
33
|
-
description: 'Success Tool',
|
|
34
|
-
input: z.object({
|
|
35
|
-
userName: z.string(),
|
|
36
|
-
}),
|
|
37
|
-
execute: async ({ input }) => ({
|
|
38
|
-
memory: { userName: input.userName },
|
|
39
|
-
}),
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'failureTool',
|
|
43
|
-
description: 'Failure Tool',
|
|
44
|
-
input: z.object({
|
|
45
|
-
userName: z.string(),
|
|
46
|
-
}),
|
|
47
|
-
execute: async ({ input }) => ({
|
|
48
|
-
memory: { userName: input.userName },
|
|
49
|
-
}),
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Add trigger event handler
|
|
55
|
-
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
|
|
56
|
-
if (triggerName === 'Trigger') {
|
|
57
|
-
return {
|
|
58
|
-
memory: {},
|
|
59
|
-
messages: [new HumanMessage(triggerBody.message)],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should evaluate prompt condition edge correctly', async function () {
|
|
66
|
-
this.timeout(10000); // Increase timeout to 10 seconds
|
|
67
|
-
|
|
68
|
-
const result = await agent.invoke({
|
|
69
|
-
triggerBody: {
|
|
70
|
-
message: 'Hi, my name is Itay',
|
|
71
|
-
},
|
|
72
|
-
triggerName: 'Trigger',
|
|
73
|
-
appName: 'test',
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
expect(result.memory.userName).to.equal('Itay');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should evaluate prompt condition edge correctly', async function () {
|
|
80
|
-
this.timeout(10000); // Increase timeout to 10 seconds
|
|
81
|
-
|
|
82
|
-
const result = await agent.invoke({
|
|
83
|
-
triggerBody: {
|
|
84
|
-
message: 'Hi, my name is Ilan',
|
|
85
|
-
},
|
|
86
|
-
triggerName: 'Trigger',
|
|
87
|
-
appName: 'test',
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(result.memory.userName).to.equal('Ilan');
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
name: Test Flow
|
|
2
|
-
nodes:
|
|
3
|
-
- type: 'trigger'
|
|
4
|
-
triggerType: 'manual'
|
|
5
|
-
name: 'Trigger'
|
|
6
|
-
|
|
7
|
-
- type: 'promptNode'
|
|
8
|
-
name: 'Prompt'
|
|
9
|
-
prompt: 'Ask the user for their name'
|
|
10
|
-
humanInTheLoop: true
|
|
11
|
-
canStayOnNode: true
|
|
12
|
-
|
|
13
|
-
- type: 'tool'
|
|
14
|
-
name: 'Success'
|
|
15
|
-
toolName: 'successTool'
|
|
16
|
-
|
|
17
|
-
edges:
|
|
18
|
-
- source: 'Trigger'
|
|
19
|
-
target: 'Prompt'
|
|
20
|
-
type: 'stepForward'
|
|
21
|
-
|
|
22
|
-
- source: 'Prompt'
|
|
23
|
-
target: 'Success'
|
|
24
|
-
type: 'stepForward'
|
|
@@ -1,88 +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('Prompt 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 execute a multi-stage prompt node with onMessage callback', async function () {
|
|
61
|
-
this.timeout(20000); // Set timeout to 10 seconds for all tests in this suite
|
|
62
|
-
|
|
63
|
-
const sessionId = uuidv4();
|
|
64
|
-
const result = await agent.invoke({
|
|
65
|
-
triggerBody: {
|
|
66
|
-
message: 'Hi there',
|
|
67
|
-
},
|
|
68
|
-
triggerName: 'Trigger',
|
|
69
|
-
sessionId: sessionId,
|
|
70
|
-
appName: 'test',
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Should pause execution at prompt node
|
|
74
|
-
expect(result.memory.success).to.not.equal(true);
|
|
75
|
-
|
|
76
|
-
// Should resume execution at success node
|
|
77
|
-
const result2 = await agent.invoke({
|
|
78
|
-
triggerBody: {
|
|
79
|
-
message: 'Itay',
|
|
80
|
-
},
|
|
81
|
-
triggerName: 'Trigger',
|
|
82
|
-
sessionId: sessionId,
|
|
83
|
-
appName: 'test',
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
expect(result2.memory.success).to.equal(true);
|
|
87
|
-
});
|
|
88
|
-
});
|
package/test/setup.ts
DELETED
|
@@ -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
|
-
import { HumanMessage } from '@langchain/core/messages';
|
|
7
|
-
|
|
8
|
-
const memorySchema = z.object({
|
|
9
|
-
processed: z.boolean(),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('Tool Node', function () {
|
|
13
|
-
this.timeout(10000); // Set timeout to 10 seconds for all tests in this suite
|
|
14
|
-
|
|
15
|
-
let agent: Agent;
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
19
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
20
|
-
agent = new Agent({
|
|
21
|
-
memorySchema,
|
|
22
|
-
config: {
|
|
23
|
-
flows: [flowsPath],
|
|
24
|
-
tools: [toolsPath],
|
|
25
|
-
llm: {
|
|
26
|
-
name: 'ChatOpenAI',
|
|
27
|
-
properties: {
|
|
28
|
-
model: 'gpt-4.1'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
tools: [
|
|
33
|
-
{
|
|
34
|
-
name: 'testTool',
|
|
35
|
-
description: 'Test Tool',
|
|
36
|
-
input: z.object({
|
|
37
|
-
test: z.string(),
|
|
38
|
-
}),
|
|
39
|
-
execute: async () => ({
|
|
40
|
-
memory: { processed: true },
|
|
41
|
-
}),
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Add trigger event handler
|
|
47
|
-
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
|
|
48
|
-
if (triggerName === 'Trigger') {
|
|
49
|
-
return {
|
|
50
|
-
memory: {},
|
|
51
|
-
messages: [new HumanMessage(triggerBody.message)],
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should execute tool with correct input', async () => {
|
|
58
|
-
const result = await agent.invoke({
|
|
59
|
-
triggerBody: {
|
|
60
|
-
message: 'Test message',
|
|
61
|
-
},
|
|
62
|
-
triggerName: 'Trigger',
|
|
63
|
-
appName: 'test',
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
expect(result.memory.processed).to.equal(true);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,185 +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
|
-
import { Tool } from '../../src/types/Tools.types';
|
|
8
|
-
type Memory = z.infer<typeof memorySchema>;
|
|
9
|
-
|
|
10
|
-
const memorySchema = z.object({
|
|
11
|
-
success: z.boolean(),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const schema = z.object({
|
|
16
|
-
orderId: z.string(),
|
|
17
|
-
customerName: z.string(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const testTool: Tool<typeof schema, Memory> = {
|
|
21
|
-
name: 'testTool',
|
|
22
|
-
description: 'Test tool',
|
|
23
|
-
input: schema,
|
|
24
|
-
execute: async ({ triggerInvocations }) => {
|
|
25
|
-
expect(triggerInvocations).to.have.lengthOf(1);
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
describe('Trigger Node', () => {
|
|
30
|
-
let agent: Agent;
|
|
31
|
-
|
|
32
|
-
it('should add trigger invocation to history', async function () {
|
|
33
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
34
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
35
|
-
agent = new Agent({
|
|
36
|
-
memorySchema,
|
|
37
|
-
config: {
|
|
38
|
-
flows: [flowsPath],
|
|
39
|
-
tools: [toolsPath],
|
|
40
|
-
llm: {
|
|
41
|
-
name: 'ChatOpenAI',
|
|
42
|
-
properties: {
|
|
43
|
-
model: 'gpt-4.1'
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
tools: [testTool],
|
|
48
|
-
});
|
|
49
|
-
await agent.invoke({
|
|
50
|
-
triggerBody: {
|
|
51
|
-
message: 'Test message',
|
|
52
|
-
},
|
|
53
|
-
triggerName: 'Trigger',
|
|
54
|
-
appName: 'test',
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should properly transform trigger input', async function () {
|
|
60
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
61
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
62
|
-
agent = new Agent({
|
|
63
|
-
memorySchema,
|
|
64
|
-
config: {
|
|
65
|
-
flows: [flowsPath],
|
|
66
|
-
tools: [toolsPath],
|
|
67
|
-
llm: {
|
|
68
|
-
name: 'ChatOpenAI',
|
|
69
|
-
properties: {
|
|
70
|
-
model: 'gpt-4.1'
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
tools: [],
|
|
75
|
-
});
|
|
76
|
-
// Add trigger event handler
|
|
77
|
-
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
|
|
78
|
-
if (triggerName === 'Trigger') {
|
|
79
|
-
return {
|
|
80
|
-
memory: { success: true },
|
|
81
|
-
messages: [new HumanMessage(triggerBody.message)],
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
this.timeout(10000); // Increase timeout to 10 seconds
|
|
86
|
-
|
|
87
|
-
const result = await agent.invoke({
|
|
88
|
-
triggerBody: {
|
|
89
|
-
message: 'Test message',
|
|
90
|
-
},
|
|
91
|
-
triggerName: 'Trigger',
|
|
92
|
-
appName: 'test',
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
expect(result.messages).to.have.lengthOf(1);
|
|
96
|
-
expect(result.messages[0].content).to.equal('Test message');
|
|
97
|
-
expect(result.memory.success).to.equal(true);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should add trigger invocation to tool calls', async function () {
|
|
101
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
102
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
103
|
-
agent = new Agent({
|
|
104
|
-
memorySchema,
|
|
105
|
-
config: {
|
|
106
|
-
flows: [flowsPath],
|
|
107
|
-
tools: [toolsPath],
|
|
108
|
-
llm: {
|
|
109
|
-
name: 'ChatOpenAI',
|
|
110
|
-
properties: {
|
|
111
|
-
model: 'gpt-4.1'
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
tools: [testTool],
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
await agent.invoke({
|
|
119
|
-
triggerBody: {
|
|
120
|
-
message: 'Test message',
|
|
121
|
-
},
|
|
122
|
-
triggerName: 'Trigger',
|
|
123
|
-
appName: 'test',
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('should add human message for Slack triggers', async function () {
|
|
128
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
129
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
130
|
-
agent = new Agent({
|
|
131
|
-
memorySchema,
|
|
132
|
-
config: {
|
|
133
|
-
flows: [flowsPath],
|
|
134
|
-
tools: [toolsPath],
|
|
135
|
-
llm: {
|
|
136
|
-
name: 'ChatOpenAI',
|
|
137
|
-
properties: {
|
|
138
|
-
model: 'gpt-4.1'
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
tools: [],
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const slackResult = await agent.invoke({
|
|
146
|
-
triggerBody: {
|
|
147
|
-
text: 'Hello from Slack'
|
|
148
|
-
},
|
|
149
|
-
triggerName: 'New Direct Message (Instant)',
|
|
150
|
-
appName: 'Slack',
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
expect(slackResult.messages).to.have.lengthOf(1);
|
|
154
|
-
expect(slackResult.messages[0].content).to.equal('Hello from Slack');
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('should not add messages for triggers without default message injection', async function () {
|
|
158
|
-
const flowsPath = path.join(__dirname, 'flows');
|
|
159
|
-
const toolsPath = path.join(__dirname, 'tools');
|
|
160
|
-
agent = new Agent({
|
|
161
|
-
memorySchema,
|
|
162
|
-
config: {
|
|
163
|
-
flows: [flowsPath],
|
|
164
|
-
tools: [toolsPath],
|
|
165
|
-
llm: {
|
|
166
|
-
name: 'ChatOpenAI',
|
|
167
|
-
properties: {
|
|
168
|
-
model: 'gpt-4.1'
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
tools: [],
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
const otherResult = await agent.invoke({
|
|
176
|
-
triggerBody: {
|
|
177
|
-
text: 'Hello from other app'
|
|
178
|
-
},
|
|
179
|
-
triggerName: 'SomeOtherTrigger',
|
|
180
|
-
appName: 'OtherApp',
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
expect(otherResult.messages).to.have.lengthOf(0);
|
|
184
|
-
});
|
|
185
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2018",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"moduleResolution": "node",
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"sourceMap": true
|
|
14
|
-
},
|
|
15
|
-
"include": ["src/**/*"],
|
|
16
|
-
"exclude": ["node_modules", "dist"]
|
|
17
|
-
}
|