@minded-ai/mindedjs 1.0.19
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/.github/workflows/CI.yml +34 -0
- package/.prettierrc +8 -0
- package/README.md +6 -0
- package/dist/agent.d.ts +36 -0
- package/dist/agent.js +199 -0
- package/dist/agent.js.map +1 -0
- package/dist/analytics.d.ts +6 -0
- package/dist/analytics.js +19 -0
- package/dist/analytics.js.map +1 -0
- package/dist/edges/createDirectEdge.d.ts +4 -0
- package/dist/edges/createDirectEdge.js +14 -0
- package/dist/edges/createDirectEdge.js.map +1 -0
- package/dist/edges/createLogicalRouter.d.ts +5 -0
- package/dist/edges/createLogicalRouter.js +18 -0
- package/dist/edges/createLogicalRouter.js.map +1 -0
- package/dist/edges/createPromptRouter.d.ts +7 -0
- package/dist/edges/createPromptRouter.js +54 -0
- package/dist/edges/createPromptRouter.js.map +1 -0
- package/dist/edges/edgeFactory.d.ts +9 -0
- package/dist/edges/edgeFactory.js +65 -0
- package/dist/edges/edgeFactory.js.map +1 -0
- package/dist/events/AgentEvents.d.ts +22 -0
- package/dist/events/AgentEvents.js +9 -0
- package/dist/events/AgentEvents.js.map +1 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +5 -0
- package/dist/events/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure.ts/mindedRequest.d.ts +8 -0
- package/dist/infrastructure.ts/mindedRequest.js +22 -0
- package/dist/infrastructure.ts/mindedRequest.js.map +1 -0
- package/dist/llm/createLlmInstance.d.ts +2 -0
- package/dist/llm/createLlmInstance.js +14 -0
- package/dist/llm/createLlmInstance.js.map +1 -0
- package/dist/nodes/addHumanInTheLoopNode.d.ts +8 -0
- package/dist/nodes/addHumanInTheLoopNode.js +17 -0
- package/dist/nodes/addHumanInTheLoopNode.js.map +1 -0
- package/dist/nodes/addPromptNode.d.ts +15 -0
- package/dist/nodes/addPromptNode.js +52 -0
- package/dist/nodes/addPromptNode.js.map +1 -0
- package/dist/nodes/addToolNode.d.ts +10 -0
- package/dist/nodes/addToolNode.js +82 -0
- package/dist/nodes/addToolNode.js.map +1 -0
- package/dist/nodes/addTriggerNode.d.ts +6 -0
- package/dist/nodes/addTriggerNode.js +12 -0
- package/dist/nodes/addTriggerNode.js.map +1 -0
- package/dist/nodes/nodeFactory.d.ts +13 -0
- package/dist/nodes/nodeFactory.js +41 -0
- package/dist/nodes/nodeFactory.js.map +1 -0
- package/dist/platform/analytics.d.ts +6 -0
- package/dist/platform/analytics.js +19 -0
- package/dist/platform/analytics.js.map +1 -0
- package/dist/platform/mindedCheckpointSaver.d.ts +10 -0
- package/dist/platform/mindedCheckpointSaver.js +49 -0
- package/dist/platform/mindedCheckpointSaver.js.map +1 -0
- package/dist/platform/mindedConnection.d.ts +13 -0
- package/dist/platform/mindedConnection.js +117 -0
- package/dist/platform/mindedConnection.js.map +1 -0
- package/dist/platform/mindedConnectionTypes.d.ts +10 -0
- package/dist/platform/mindedConnectionTypes.js +8 -0
- package/dist/platform/mindedConnectionTypes.js.map +1 -0
- package/dist/platform/mindedRequest.d.ts +8 -0
- package/dist/platform/mindedRequest.js +22 -0
- package/dist/platform/mindedRequest.js.map +1 -0
- package/dist/types/Agent.types.d.ts +8 -0
- package/dist/types/Agent.types.js +3 -0
- package/dist/types/Agent.types.js.map +1 -0
- package/dist/types/Flows.types.d.ts +83 -0
- package/dist/types/Flows.types.js +24 -0
- package/dist/types/Flows.types.js.map +1 -0
- package/dist/types/LLM.types.d.ts +10 -0
- package/dist/types/LLM.types.js +9 -0
- package/dist/types/LLM.types.js.map +1 -0
- package/dist/types/LangGraph.types.d.ts +29 -0
- package/dist/types/LangGraph.types.js +20 -0
- package/dist/types/LangGraph.types.js.map +1 -0
- package/dist/types/Tools.types.d.ts +14 -0
- package/dist/types/Tools.types.js +3 -0
- package/dist/types/Tools.types.js.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/docs/.gitbook/assets/image.png +0 -0
- package/docs/README.md +51 -0
- package/docs/SUMMARY.md +21 -0
- package/docs/api-reference/.nojekyll +1 -0
- package/docs/api-reference/assets/hierarchy.js +1 -0
- package/docs/api-reference/assets/highlight.css +120 -0
- package/docs/api-reference/assets/icons.js +18 -0
- package/docs/api-reference/assets/icons.svg +1 -0
- package/docs/api-reference/assets/main.js +60 -0
- package/docs/api-reference/assets/navigation.js +1 -0
- package/docs/api-reference/assets/search.js +1 -0
- package/docs/api-reference/assets/style.css +1640 -0
- package/docs/api-reference/classes/index.Agent.html +4 -0
- package/docs/api-reference/enums/index.EdgeType.html +4 -0
- package/docs/api-reference/enums/index.NodeType.html +6 -0
- package/docs/api-reference/enums/index.TriggerType.html +4 -0
- package/docs/api-reference/enums/index.events.html +3 -0
- package/docs/api-reference/hierarchy.html +1 -0
- package/docs/api-reference/index.html +310 -0
- package/docs/api-reference/interfaces/index.AppToolNode.html +5 -0
- package/docs/api-reference/interfaces/index.AppTriggerNode.html +6 -0
- package/docs/api-reference/interfaces/index.Flow.html +4 -0
- package/docs/api-reference/interfaces/index.JunctionNode.html +4 -0
- package/docs/api-reference/interfaces/index.LogicalConditionEdge.html +5 -0
- package/docs/api-reference/interfaces/index.ManualTriggerNode.html +5 -0
- package/docs/api-reference/interfaces/index.PromptConditionEdge.html +5 -0
- package/docs/api-reference/interfaces/index.PromptNode.html +6 -0
- package/docs/api-reference/interfaces/index.StepForwardEdge.html +4 -0
- package/docs/api-reference/interfaces/index.Tool.html +6 -0
- package/docs/api-reference/interfaces/index.ToolNode.html +5 -0
- package/docs/api-reference/modules/index-1.html +1 -0
- package/docs/api-reference/modules/index.html +1 -0
- package/docs/api-reference/modules.html +1 -0
- package/docs/api-reference/types/index.Edge.html +1 -0
- package/docs/api-reference/types/index.Node.html +1 -0
- package/docs/api-reference/types/index.TriggerNode.html +1 -0
- package/docs/core-concepts/edges.md +242 -0
- package/docs/core-concepts/events.md +161 -0
- package/docs/core-concepts/flows.md +74 -0
- package/docs/core-concepts/memory-types.md +208 -0
- package/docs/core-concepts/nodes.md +239 -0
- package/docs/core-concepts/tools.md +205 -0
- package/docs/examples/order-refund-flow.md +560 -0
- package/docs/getting-started/installation.md +34 -0
- package/docs/getting-started/quick-start.md +264 -0
- package/docs-structure.md +144 -0
- package/eslint.config.js +68 -0
- package/examples/orderRefundAgent/flows/orderRefundFlow.yaml +32 -0
- package/examples/orderRefundAgent/minded.json +14 -0
- package/examples/orderRefundAgent/orderRefundAgent.ts +58 -0
- package/examples/orderRefundAgent/schema.ts +7 -0
- package/examples/orderRefundAgent/tools/escalateConversation.ts +28 -0
- package/examples/orderRefundAgent/tools/index.ts +4 -0
- package/examples/orderRefundAgent/tools/refundOrder.ts +27 -0
- package/package.json +46 -0
- package/src/agent.ts +216 -0
- package/src/edges/createDirectEdge.ts +11 -0
- package/src/edges/createLogicalRouter.ts +16 -0
- package/src/edges/createPromptRouter.ts +52 -0
- package/src/edges/edgeFactory.ts +85 -0
- package/src/events/AgentEvents.ts +22 -0
- package/src/events/index.ts +3 -0
- package/src/index.ts +22 -0
- package/src/llm/createLlmInstance.ts +10 -0
- package/src/nodes/addHumanInTheLoopNode.ts +20 -0
- package/src/nodes/addPromptNode.ts +66 -0
- package/src/nodes/addToolNode.ts +95 -0
- package/src/nodes/addTriggerNode.ts +12 -0
- package/src/nodes/nodeFactory.ts +65 -0
- package/src/platform/analytics.ts +16 -0
- package/src/platform/mindedCheckpointSaver.ts +74 -0
- package/src/platform/mindedConnection.ts +106 -0
- package/src/platform/mindedConnectionTypes.ts +15 -0
- package/src/platform/mindedRequest.ts +28 -0
- package/src/types/Agent.types.ts +10 -0
- package/src/types/Flows.types.ts +103 -0
- package/src/types/LLM.types.ts +13 -0
- package/src/types/LangGraph.types.ts +25 -0
- package/src/types/Tools.types.ts +9 -0
- package/test/can-stay-on-node/can-stay-on-node.test.ts +148 -0
- package/test/can-stay-on-node/flows/test-flow.yaml +25 -0
- package/test/cannot-stay-on-node/cannot-stay-on-node.test.ts +201 -0
- package/test/cannot-stay-on-node/flows/test-flow.yaml +34 -0
- package/test/human-in-the-loop-node/flows/test-flow.yaml +23 -0
- package/test/human-in-the-loop-node/human-in-the-loop-node.test.ts +92 -0
- package/test/logical-edges/flows/logical-edge-test-flow.yaml +24 -0
- package/test/logical-edges/logical-edges.test.ts +66 -0
- package/test/no-human-in-the-loop-node/flows/test-flow.yaml +23 -0
- package/test/no-human-in-the-loop-node/no-human-in-the-loop-node.test.ts +80 -0
- package/test/prompt-edges/flows/test-flow.yaml +24 -0
- package/test/prompt-edges/prompt-edges.test.ts +90 -0
- package/test/prompt-node/flows/test-flow.yaml +24 -0
- package/test/prompt-node/prompt-node.test.ts +86 -0
- package/test/setup.ts +5 -0
- package/test/tool-node/flows/test-flow.yaml +14 -0
- package/test/tool-node/tool-node.test.ts +67 -0
- package/test/trigger/flows/test-flow.yaml +7 -0
- package/test/trigger/trigger.test.ts +57 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,86 @@
|
|
|
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,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Should pause execution at prompt node
|
|
73
|
+
expect(result.memory.success).to.not.equal(true);
|
|
74
|
+
|
|
75
|
+
// Should resume execution at success node
|
|
76
|
+
const result2 = await agent.invoke({
|
|
77
|
+
triggerBody: {
|
|
78
|
+
message: 'Itay',
|
|
79
|
+
},
|
|
80
|
+
triggerName: 'Trigger',
|
|
81
|
+
sessionId,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(result2.memory.success).to.equal(true);
|
|
85
|
+
});
|
|
86
|
+
});
|
package/test/setup.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
});
|
|
64
|
+
|
|
65
|
+
expect(result.memory.processed).to.equal(true);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
success: z.boolean(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('Trigger Node', () => {
|
|
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
|
+
// Add trigger event handler
|
|
33
|
+
agent.on(AgentEvents.TRIGGER_EVENT, async ({ triggerName, triggerBody }) => {
|
|
34
|
+
if (triggerName === 'Trigger') {
|
|
35
|
+
return {
|
|
36
|
+
memory: { success: true },
|
|
37
|
+
messages: [new HumanMessage(triggerBody.message)],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should properly transform trigger input', async function () {
|
|
44
|
+
this.timeout(10000); // Increase timeout to 10 seconds
|
|
45
|
+
|
|
46
|
+
const result = await agent.invoke({
|
|
47
|
+
triggerBody: {
|
|
48
|
+
message: 'Test message',
|
|
49
|
+
},
|
|
50
|
+
triggerName: 'Trigger',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
expect(result.messages).to.have.lengthOf(1);
|
|
54
|
+
expect(result.messages[0].content).to.equal('Test message');
|
|
55
|
+
expect(result.memory.success).to.equal(true);
|
|
56
|
+
});
|
|
57
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|