@ai.ntellect/core 0.5.0 → 0.6.1
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/.mocharc.json +1 -1
- package/README.md +311 -272
- package/create-llm-to-select-multiple-graph copy.ts +243 -0
- package/create-llm-to-select-multiple-graph.ts +148 -0
- package/dist/graph/controller.js +63 -0
- package/dist/graph/engine.js +563 -0
- package/dist/index.js +6 -6
- package/dist/memory/adapters/meilisearch/index.js +249 -0
- package/dist/memory/adapters/redis/index.js +96 -0
- package/dist/memory/index.js +9 -0
- package/dist/services/agenda.js +115 -0
- package/dist/services/embedding.js +40 -0
- package/dist/services/queue.js +99 -103
- package/dist/test/graph/controller.test.js +170 -0
- package/dist/test/graph/engine.test.js +465 -0
- package/dist/test/memory/adapters/meilisearch.test.js +250 -0
- package/dist/test/memory/adapters/redis.test.js +143 -0
- package/dist/test/memory/base.test.js +209 -0
- package/dist/test/services/agenda.test.js +230 -0
- package/dist/test/services/queue.test.js +258 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/generate-object.js +32 -11
- package/dist/utils/inject-actions.js +2 -2
- package/dist/utils/queue-item-transformer.js +2 -2
- package/dist/utils/state-manager.js +20 -0
- package/graph/controller.ts +64 -0
- package/graph/engine.ts +790 -0
- package/index copy.ts +81 -0
- package/index.ts +7 -7
- package/interfaces/index.ts +119 -0
- package/memory/adapters/meilisearch/index.ts +286 -0
- package/memory/adapters/redis/index.ts +103 -0
- package/memory/index.ts +22 -0
- package/package.json +7 -2
- package/services/agenda.ts +48 -43
- package/services/embedding.ts +26 -0
- package/services/queue.ts +2 -29
- package/test/.env.test +4 -0
- package/test/graph/controller.test.ts +186 -0
- package/test/graph/engine.test.ts +546 -0
- package/test/memory/adapters/meilisearch.test.ts +297 -0
- package/test/memory/adapters/redis.test.ts +160 -0
- package/test/memory/base.test.ts +229 -0
- package/test/services/agenda.test.ts +280 -0
- package/test/services/queue.test.ts +286 -44
- package/tsconfig.json +10 -10
- package/types/index.ts +278 -0
- package/utils/queue-item-transformer.ts +8 -11
- package/utils/setup-graphs.ts +45 -0
- package/utils/stringifiy-zod-schema.ts +45 -0
- package/.nvmrc +0 -1
- package/README.FR.md +0 -916
- package/agent/index.ts +0 -151
- package/agent/workflow/conditions.ts +0 -16
- package/agent/workflow/handlers/interpreter.handler.ts +0 -48
- package/agent/workflow/handlers/memory.handler.ts +0 -106
- package/agent/workflow/handlers/orchestrator.handler.ts +0 -23
- package/agent/workflow/handlers/queue.handler.ts +0 -34
- package/agent/workflow/handlers/scheduler.handler.ts +0 -61
- package/agent/workflow/index.ts +0 -62
- package/dist/agent/index.d.ts +0 -38
- package/dist/agent/index.js +0 -143
- package/dist/agent/tools/get-rss.d.ts +0 -16
- package/dist/agent/tools/get-rss.js +0 -62
- package/dist/bull.d.ts +0 -1
- package/dist/bull.js +0 -9
- package/dist/examples/index.d.ts +0 -2
- package/dist/examples/index.js +0 -89
- package/dist/index.d.ts +0 -7
- package/dist/llm/interpreter/context.d.ts +0 -15
- package/dist/llm/interpreter/context.js +0 -89
- package/dist/llm/interpreter/index.d.ts +0 -21
- package/dist/llm/interpreter/index.js +0 -87
- package/dist/llm/memory-manager/context.d.ts +0 -2
- package/dist/llm/memory-manager/context.js +0 -22
- package/dist/llm/memory-manager/index.d.ts +0 -17
- package/dist/llm/memory-manager/index.js +0 -107
- package/dist/llm/orchestrator/context.d.ts +0 -2
- package/dist/llm/orchestrator/context.js +0 -23
- package/dist/llm/orchestrator/index.d.ts +0 -44
- package/dist/llm/orchestrator/index.js +0 -139
- package/dist/llm/orchestrator/types.d.ts +0 -12
- package/dist/memory/cache.d.ts +0 -22
- package/dist/memory/cache.js +0 -165
- package/dist/memory/persistent.d.ts +0 -57
- package/dist/memory/persistent.js +0 -189
- package/dist/services/queue.d.ts +0 -13
- package/dist/services/redis-cache.d.ts +0 -37
- package/dist/services/redis-cache.js +0 -93
- package/dist/services/scheduler.d.ts +0 -40
- package/dist/services/scheduler.js +0 -99
- package/dist/services/telegram-monitor.d.ts +0 -0
- package/dist/services/telegram-monitor.js +0 -118
- package/dist/t.d.ts +0 -46
- package/dist/t.js +0 -102
- package/dist/test.d.ts +0 -0
- package/dist/test.js +0 -438
- package/dist/types.d.ts +0 -258
- package/dist/types.js +0 -22
- package/dist/utils/generate-object.d.ts +0 -12
- package/dist/utils/header-builder.d.ts +0 -11
- package/dist/utils/inject-actions.d.ts +0 -2
- package/dist/utils/queue-item-transformer.d.ts +0 -7
- package/dist/utils/sanitize-results.d.ts +0 -17
- package/dist/utils/schema-generator.d.ts +0 -16
- package/examples/actions/get-rss.ts +0 -71
- package/examples/index.ts +0 -98
- package/index.html +0 -42
- package/llm/dynamic-condition/example.ts +0 -36
- package/llm/dynamic-condition/index.ts +0 -108
- package/llm/interpreter/context.ts +0 -94
- package/llm/interpreter/index.ts +0 -140
- package/llm/memory-manager/context.ts +0 -19
- package/llm/memory-manager/index.ts +0 -115
- package/llm/orchestrator/context.ts +0 -19
- package/llm/orchestrator/index.ts +0 -192
- package/llm/orchestrator/types.ts +0 -14
- package/memory/cache.ts +0 -221
- package/memory/persistent.ts +0 -265
- package/script.js +0 -167
- package/services/cache.ts +0 -298
- package/services/telegram-monitor.ts +0 -138
- package/services/workflow.ts +0 -491
- package/t.py +0 -79
- package/t.ts +0 -25
- package/test/llm/orchestrator.test.ts +0 -47
- package/test/llm/synthesizer.test.ts +0 -31
- package/types.ts +0 -367
- package/utils/schema-generator.ts +0 -73
- package/utils/state-manager.ts +0 -25
- /package/dist/{llm/orchestrator/types.js → interfaces/index.js} +0 -0
package/services/agenda.ts
CHANGED
@@ -1,25 +1,9 @@
|
|
1
|
+
import { ScheduledRequest } from "@/types";
|
1
2
|
import cron from "node-cron";
|
2
|
-
import { Orchestrator } from "../llm/orchestrator";
|
3
|
-
import { RedisCache } from "./cache";
|
4
|
-
|
5
|
-
interface ScheduledRequest {
|
6
|
-
id: string;
|
7
|
-
originalRequest: string;
|
8
|
-
cronExpression: string;
|
9
|
-
isRecurring: boolean;
|
10
|
-
createdAt: Date;
|
11
|
-
}
|
12
3
|
|
13
4
|
export class Agenda {
|
14
5
|
private scheduledRequests: Map<string, ScheduledRequest> = new Map();
|
15
6
|
private cronJobs: Map<string, cron.ScheduledTask> = new Map();
|
16
|
-
private readonly orchestrator: Orchestrator;
|
17
|
-
private readonly cache: RedisCache;
|
18
|
-
|
19
|
-
constructor(orchestrator: Orchestrator, cache: RedisCache) {
|
20
|
-
this.orchestrator = orchestrator;
|
21
|
-
this.cache = cache;
|
22
|
-
}
|
23
7
|
|
24
8
|
/**
|
25
9
|
* Schedule a new request to be processed later
|
@@ -45,39 +29,34 @@ export class Agenda {
|
|
45
29
|
};
|
46
30
|
|
47
31
|
// Create cron job
|
48
|
-
const cronJob = cron.schedule(request.cronExpression,
|
49
|
-
|
32
|
+
const cronJob = cron.schedule(request.cronExpression, () => {
|
33
|
+
console.log(`🔄 Executing scheduled request: ${id}`);
|
50
34
|
|
51
|
-
if (callbacks?.onExecuted)
|
35
|
+
if (callbacks?.onExecuted) {
|
52
36
|
callbacks.onExecuted(id, scheduledRequest.originalRequest);
|
37
|
+
}
|
38
|
+
|
39
|
+
console.log(`✅ Scheduled request executed successfully: ${id}`);
|
53
40
|
|
41
|
+
// Auto-stop pour les tâches non récurrentes
|
54
42
|
if (!scheduledRequest.isRecurring) {
|
55
43
|
this.cancelScheduledRequest(id);
|
56
44
|
}
|
57
45
|
});
|
58
46
|
|
47
|
+
// Démarrer le job en mode non-running
|
48
|
+
cronJob.stop();
|
49
|
+
|
59
50
|
// Store request and job
|
60
51
|
this.scheduledRequests.set(id, scheduledRequest);
|
61
52
|
this.cronJobs.set(id, cronJob);
|
62
53
|
|
63
54
|
if (callbacks?.onScheduled) callbacks.onScheduled(id);
|
64
55
|
|
65
|
-
|
66
|
-
|
56
|
+
// Démarrer le job après l'avoir stocké
|
57
|
+
cronJob.start();
|
67
58
|
|
68
|
-
|
69
|
-
* Execute a scheduled request by launching a new process
|
70
|
-
*/
|
71
|
-
private async executeScheduledRequest(
|
72
|
-
request: ScheduledRequest
|
73
|
-
): Promise<void> {
|
74
|
-
try {
|
75
|
-
console.log(`🔄 Executing scheduled request from ${request.createdAt}`);
|
76
|
-
|
77
|
-
console.log(`✅ Scheduled request executed successfully`);
|
78
|
-
} catch (error) {
|
79
|
-
console.error(`❌ Failed to execute scheduled request:`, error);
|
80
|
-
}
|
59
|
+
return id;
|
81
60
|
}
|
82
61
|
|
83
62
|
/**
|
@@ -86,10 +65,17 @@ export class Agenda {
|
|
86
65
|
cancelScheduledRequest(requestId: string): boolean {
|
87
66
|
const cronJob = this.cronJobs.get(requestId);
|
88
67
|
if (cronJob) {
|
89
|
-
|
90
|
-
|
68
|
+
try {
|
69
|
+
cronJob.stop();
|
70
|
+
this.cronJobs.delete(requestId);
|
71
|
+
this.scheduledRequests.delete(requestId);
|
72
|
+
return true;
|
73
|
+
} catch (error) {
|
74
|
+
console.error(`Failed to stop cron job ${requestId}:`, error);
|
75
|
+
return false;
|
76
|
+
}
|
91
77
|
}
|
92
|
-
return
|
78
|
+
return false;
|
93
79
|
}
|
94
80
|
|
95
81
|
/**
|
@@ -103,11 +89,30 @@ export class Agenda {
|
|
103
89
|
* Stop all cron jobs
|
104
90
|
*/
|
105
91
|
stopAll(): void {
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
92
|
+
const ids = Array.from(this.cronJobs.keys());
|
93
|
+
|
94
|
+
// Arrêter tous les jobs de manière synchrone
|
95
|
+
for (const id of ids) {
|
96
|
+
const job = this.cronJobs.get(id);
|
97
|
+
if (job) {
|
98
|
+
job.stop();
|
99
|
+
this.cronJobs.delete(id);
|
100
|
+
this.scheduledRequests.delete(id);
|
101
|
+
}
|
110
102
|
}
|
111
|
-
|
103
|
+
|
104
|
+
// Double vérification
|
105
|
+
this.cronJobs.clear();
|
106
|
+
this.scheduledRequests.clear();
|
107
|
+
}
|
108
|
+
|
109
|
+
public async stop(): Promise<void> {
|
110
|
+
this.stopAll();
|
111
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
112
|
+
}
|
113
|
+
|
114
|
+
public async cancel(query: {}): Promise<void> {
|
115
|
+
this.stopAll();
|
116
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
112
117
|
}
|
113
118
|
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { EmbeddingService } from "@/interfaces";
|
2
|
+
import { cosineSimilarity, embed, EmbeddingModel, embedMany } from "ai";
|
3
|
+
|
4
|
+
export class AIEmbeddingService implements EmbeddingService {
|
5
|
+
constructor(private readonly model: EmbeddingModel<string>) {}
|
6
|
+
|
7
|
+
async embedText(text: string): Promise<number[]> {
|
8
|
+
const { embedding } = await embed({
|
9
|
+
model: this.model,
|
10
|
+
value: text,
|
11
|
+
});
|
12
|
+
return embedding;
|
13
|
+
}
|
14
|
+
|
15
|
+
async embedMany(texts: string[]): Promise<number[][]> {
|
16
|
+
const { embeddings } = await embedMany({
|
17
|
+
model: this.model,
|
18
|
+
values: texts,
|
19
|
+
});
|
20
|
+
return embeddings;
|
21
|
+
}
|
22
|
+
|
23
|
+
calculateSimilarity(embedding1: number[], embedding2: number[]): number {
|
24
|
+
return (cosineSimilarity(embedding1, embedding2) + 1) * 50;
|
25
|
+
}
|
26
|
+
}
|
package/services/queue.ts
CHANGED
@@ -20,38 +20,29 @@ export class Queue {
|
|
20
20
|
|
21
21
|
add(actions: QueueItem | QueueItem[]) {
|
22
22
|
if (Array.isArray(actions)) {
|
23
|
-
console.log("\n📋 Adding actions to queue:");
|
24
|
-
actions.forEach((action, index) => {
|
25
|
-
console.log(` ${index + 1}. ${action.name}`);
|
26
|
-
});
|
27
23
|
this.queue.push(...actions);
|
28
24
|
} else {
|
29
|
-
console.log("\n📋 Adding single action to queue:", actions.name);
|
30
25
|
this.queue.push(actions);
|
31
26
|
}
|
32
27
|
}
|
33
28
|
|
34
29
|
async execute() {
|
35
30
|
if (this.isProcessing) {
|
36
|
-
console.log("\n⚠️ Queue is already being processed");
|
37
31
|
return;
|
38
32
|
}
|
39
33
|
|
40
|
-
console.log("\n🔄 Starting queue processing");
|
41
34
|
this.isProcessing = true;
|
42
35
|
const actionPromises: Promise<QueueResult>[] = [];
|
43
36
|
|
44
37
|
for (const action of this.queue) {
|
45
38
|
const actionConfig = this.actions.find((a) => a.name === action.name);
|
46
39
|
if (actionConfig?.confirmation?.requireConfirmation) {
|
47
|
-
console.log("\n🔒 Action requires confirmation:", action.name);
|
48
40
|
const shouldProceed = await this.callbacks.onConfirmationRequired?.(
|
49
41
|
actionConfig.confirmation.message ||
|
50
42
|
`Do you want to proceed with action: ${action.name}?`
|
51
43
|
);
|
52
44
|
|
53
45
|
if (!shouldProceed) {
|
54
|
-
console.log("❌ Action cancelled by user:", action.name);
|
55
46
|
this.results.push({
|
56
47
|
name: action.name,
|
57
48
|
parameters: this.formatArguments(action.parameters),
|
@@ -61,7 +52,6 @@ export class Queue {
|
|
61
52
|
});
|
62
53
|
continue;
|
63
54
|
}
|
64
|
-
console.log("✅ Action confirmed by user");
|
65
55
|
}
|
66
56
|
const parameters = this.formatArguments(action.parameters);
|
67
57
|
|
@@ -85,17 +75,14 @@ export class Queue {
|
|
85
75
|
}
|
86
76
|
|
87
77
|
try {
|
88
|
-
console.log("\n⏳ Waiting for all actions to complete...");
|
89
78
|
const results = await Promise.all(actionPromises);
|
90
79
|
this.results.push(...results);
|
91
80
|
this.queue = [];
|
92
81
|
this.callbacks.onQueueComplete?.(this.results);
|
93
82
|
this.isProcessing = false;
|
94
|
-
console.log("\n✅ Queue processing completed successfully");
|
95
83
|
return this.results;
|
96
84
|
} catch (error) {
|
97
85
|
this.isProcessing = false;
|
98
|
-
console.error("\n❌ Unexpected error in queue processing:", error);
|
99
86
|
throw error;
|
100
87
|
}
|
101
88
|
}
|
@@ -124,12 +111,10 @@ export class Queue {
|
|
124
111
|
}
|
125
112
|
|
126
113
|
private async executeAction(action: QueueItem): Promise<QueueResult> {
|
127
|
-
console.log("\n🎯 Executing action:", action.name);
|
128
114
|
this.callbacks.onActionStart?.(action);
|
129
115
|
|
130
116
|
const actionConfig = this.actions.find((a) => a.name === action.name);
|
131
117
|
if (!actionConfig) {
|
132
|
-
console.error("❌ Action not found:", action.name);
|
133
118
|
return {
|
134
119
|
name: action.name,
|
135
120
|
parameters: {},
|
@@ -138,35 +123,23 @@ export class Queue {
|
|
138
123
|
};
|
139
124
|
}
|
140
125
|
|
141
|
-
console.log(
|
142
|
-
"📝 Action parameters:",
|
143
|
-
JSON.stringify(action.parameters, null, 2)
|
144
|
-
);
|
145
126
|
const actionArgs = this.formatArguments(action.parameters);
|
146
127
|
|
147
128
|
try {
|
148
129
|
const result = await actionConfig.execute(actionArgs);
|
149
|
-
|
130
|
+
return {
|
150
131
|
name: action.name,
|
151
132
|
parameters: actionArgs,
|
152
133
|
result,
|
153
134
|
error: null,
|
154
135
|
};
|
155
|
-
console.log(`\n✨ Action "${action.name}" completed successfully`);
|
156
|
-
return actionResult;
|
157
136
|
} catch (error) {
|
158
|
-
|
137
|
+
return {
|
159
138
|
name: action.name,
|
160
139
|
parameters: actionArgs,
|
161
140
|
result: null,
|
162
141
|
error: (error as Error).message || "Unknown error occurred",
|
163
142
|
};
|
164
|
-
console.error(`\n❌ Action "${action.name}" failed:`, error);
|
165
|
-
console.log(
|
166
|
-
"Failed action details:",
|
167
|
-
JSON.stringify(actionResult, null, 2)
|
168
|
-
);
|
169
|
-
return actionResult;
|
170
143
|
}
|
171
144
|
}
|
172
145
|
}
|
package/test/.env.test
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
import { GraphController } from "@/graph/controller";
|
2
|
+
import { GraphDefinition } from "@/types";
|
3
|
+
import { expect } from "chai";
|
4
|
+
import { z } from "zod";
|
5
|
+
|
6
|
+
describe("Controller", () => {
|
7
|
+
// Define test schema
|
8
|
+
const TestSchema = z.object({
|
9
|
+
status: z.string(),
|
10
|
+
count: z.number(),
|
11
|
+
});
|
12
|
+
|
13
|
+
type TestState = z.infer<typeof TestSchema>;
|
14
|
+
|
15
|
+
// Sample workflow definitions
|
16
|
+
const simpleWorkflow: GraphDefinition<TestState> = {
|
17
|
+
name: "simple-workflow",
|
18
|
+
entryNode: "start",
|
19
|
+
nodes: {
|
20
|
+
start: {
|
21
|
+
name: "start",
|
22
|
+
execute: async (_params: any, state: any) => ({
|
23
|
+
context: {
|
24
|
+
...state.context,
|
25
|
+
status: "completed",
|
26
|
+
count: state.context.count + 1,
|
27
|
+
},
|
28
|
+
}),
|
29
|
+
relationships: [],
|
30
|
+
},
|
31
|
+
},
|
32
|
+
schema: TestSchema,
|
33
|
+
};
|
34
|
+
|
35
|
+
const complexWorkflow: GraphDefinition<TestState> = {
|
36
|
+
name: "complex-workflow",
|
37
|
+
entryNode: "first",
|
38
|
+
nodes: {
|
39
|
+
first: {
|
40
|
+
name: "first",
|
41
|
+
execute: async (_params: any, state: any) => ({
|
42
|
+
context: {
|
43
|
+
...state.context,
|
44
|
+
status: "step1",
|
45
|
+
count: state.context.count + 2,
|
46
|
+
},
|
47
|
+
}),
|
48
|
+
relationships: [],
|
49
|
+
},
|
50
|
+
},
|
51
|
+
schema: TestSchema,
|
52
|
+
};
|
53
|
+
|
54
|
+
let controller: GraphController<TestState>;
|
55
|
+
|
56
|
+
beforeEach(() => {
|
57
|
+
controller = new GraphController<TestState>();
|
58
|
+
});
|
59
|
+
|
60
|
+
describe("Basic Execution", () => {
|
61
|
+
it("should execute a single workflow successfully", async () => {
|
62
|
+
const actions = [
|
63
|
+
{
|
64
|
+
name: "simple-workflow",
|
65
|
+
parameters: [
|
66
|
+
{ name: "status", value: "initial" },
|
67
|
+
{ name: "count", value: 0 },
|
68
|
+
],
|
69
|
+
},
|
70
|
+
];
|
71
|
+
|
72
|
+
const result = await controller.run(actions, [simpleWorkflow]);
|
73
|
+
|
74
|
+
expect(result.context).to.deep.equal({
|
75
|
+
status: "completed",
|
76
|
+
count: 1,
|
77
|
+
});
|
78
|
+
});
|
79
|
+
|
80
|
+
it("should handle multiple workflows", async () => {
|
81
|
+
const actions = [
|
82
|
+
{
|
83
|
+
name: "complex-workflow",
|
84
|
+
parameters: [
|
85
|
+
{ name: "status", value: "initial" },
|
86
|
+
{ name: "count", value: 0 },
|
87
|
+
],
|
88
|
+
},
|
89
|
+
];
|
90
|
+
|
91
|
+
const result = await controller.run(actions, [
|
92
|
+
simpleWorkflow,
|
93
|
+
complexWorkflow,
|
94
|
+
]);
|
95
|
+
|
96
|
+
expect(result.context).to.deep.equal({
|
97
|
+
status: "step1",
|
98
|
+
count: 2,
|
99
|
+
});
|
100
|
+
});
|
101
|
+
});
|
102
|
+
|
103
|
+
describe("Error Handling", () => {
|
104
|
+
it("should throw error when no actions provided", async () => {
|
105
|
+
try {
|
106
|
+
await controller.run([], [simpleWorkflow]);
|
107
|
+
expect.fail("Should have thrown an error");
|
108
|
+
} catch (error) {
|
109
|
+
expect((error as Error).message).to.equal("No actions provided");
|
110
|
+
}
|
111
|
+
});
|
112
|
+
|
113
|
+
it("should throw error when workflow not found", async () => {
|
114
|
+
const actions = [
|
115
|
+
{
|
116
|
+
name: "non-existent-workflow",
|
117
|
+
parameters: [
|
118
|
+
{ name: "status", value: "initial" },
|
119
|
+
{ name: "count", value: 0 },
|
120
|
+
],
|
121
|
+
},
|
122
|
+
];
|
123
|
+
|
124
|
+
try {
|
125
|
+
await controller.run(actions, [simpleWorkflow]);
|
126
|
+
expect.fail("Should have thrown an error");
|
127
|
+
} catch (error) {
|
128
|
+
expect((error as Error).message).to.equal(
|
129
|
+
"Graph not found: non-existent-workflow"
|
130
|
+
);
|
131
|
+
}
|
132
|
+
});
|
133
|
+
});
|
134
|
+
|
135
|
+
describe("Parameter Handling", () => {
|
136
|
+
it("should correctly process workflow parameters", async () => {
|
137
|
+
const actions = [
|
138
|
+
{
|
139
|
+
name: "simple-workflow",
|
140
|
+
parameters: [
|
141
|
+
{ name: "status", value: "custom-initial" },
|
142
|
+
{ name: "count", value: 10 },
|
143
|
+
],
|
144
|
+
},
|
145
|
+
];
|
146
|
+
|
147
|
+
const result = await controller.run(actions, [simpleWorkflow]);
|
148
|
+
|
149
|
+
expect(result.context).to.deep.equal({
|
150
|
+
status: "completed",
|
151
|
+
count: 11,
|
152
|
+
});
|
153
|
+
});
|
154
|
+
});
|
155
|
+
|
156
|
+
describe("Multiple Actions", () => {
|
157
|
+
it("should process the first action only", async () => {
|
158
|
+
const actions = [
|
159
|
+
{
|
160
|
+
name: "simple-workflow",
|
161
|
+
parameters: [
|
162
|
+
{ name: "status", value: "initial" },
|
163
|
+
{ name: "count", value: 0 },
|
164
|
+
],
|
165
|
+
},
|
166
|
+
{
|
167
|
+
name: "complex-workflow",
|
168
|
+
parameters: [
|
169
|
+
{ name: "status", value: "initial" },
|
170
|
+
{ name: "count", value: 5 },
|
171
|
+
],
|
172
|
+
},
|
173
|
+
];
|
174
|
+
|
175
|
+
const result = await controller.run(actions, [
|
176
|
+
simpleWorkflow,
|
177
|
+
complexWorkflow,
|
178
|
+
]);
|
179
|
+
|
180
|
+
expect(result.context).to.deep.equal({
|
181
|
+
status: "completed",
|
182
|
+
count: 1,
|
183
|
+
});
|
184
|
+
});
|
185
|
+
});
|
186
|
+
});
|