@cogitator-ai/swarms 0.1.0
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/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/communication/blackboard.d.ts +24 -0
- package/dist/communication/blackboard.d.ts.map +1 -0
- package/dist/communication/blackboard.js +135 -0
- package/dist/communication/blackboard.js.map +1 -0
- package/dist/communication/event-emitter.d.ts +20 -0
- package/dist/communication/event-emitter.d.ts.map +1 -0
- package/dist/communication/event-emitter.js +87 -0
- package/dist/communication/event-emitter.js.map +1 -0
- package/dist/communication/index.d.ts +7 -0
- package/dist/communication/index.d.ts.map +1 -0
- package/dist/communication/index.js +7 -0
- package/dist/communication/index.js.map +1 -0
- package/dist/communication/message-bus.d.ts +23 -0
- package/dist/communication/message-bus.d.ts.map +1 -0
- package/dist/communication/message-bus.js +128 -0
- package/dist/communication/message-bus.js.map +1 -0
- package/dist/coordinator.d.ts +44 -0
- package/dist/coordinator.d.ts.map +1 -0
- package/dist/coordinator.js +283 -0
- package/dist/coordinator.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/circuit-breaker.d.ts +29 -0
- package/dist/resources/circuit-breaker.d.ts.map +1 -0
- package/dist/resources/circuit-breaker.js +82 -0
- package/dist/resources/circuit-breaker.js.map +1 -0
- package/dist/resources/index.d.ts +7 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +6 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/tracker.d.ts +30 -0
- package/dist/resources/tracker.d.ts.map +1 -0
- package/dist/resources/tracker.js +84 -0
- package/dist/resources/tracker.js.map +1 -0
- package/dist/strategies/auction.d.ts +17 -0
- package/dist/strategies/auction.d.ts.map +1 -0
- package/dist/strategies/auction.js +204 -0
- package/dist/strategies/auction.js.map +1 -0
- package/dist/strategies/base.d.ts +34 -0
- package/dist/strategies/base.d.ts.map +1 -0
- package/dist/strategies/base.js +74 -0
- package/dist/strategies/base.js.map +1 -0
- package/dist/strategies/consensus.d.ts +20 -0
- package/dist/strategies/consensus.d.ts.map +1 -0
- package/dist/strategies/consensus.js +328 -0
- package/dist/strategies/consensus.js.map +1 -0
- package/dist/strategies/debate.d.ts +15 -0
- package/dist/strategies/debate.d.ts.map +1 -0
- package/dist/strategies/debate.js +171 -0
- package/dist/strategies/debate.js.map +1 -0
- package/dist/strategies/hierarchical.d.ts +13 -0
- package/dist/strategies/hierarchical.d.ts.map +1 -0
- package/dist/strategies/hierarchical.js +86 -0
- package/dist/strategies/hierarchical.js.map +1 -0
- package/dist/strategies/index.d.ts +28 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +106 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/strategies/pipeline.d.ts +16 -0
- package/dist/strategies/pipeline.d.ts.map +1 -0
- package/dist/strategies/pipeline.js +180 -0
- package/dist/strategies/pipeline.js.map +1 -0
- package/dist/strategies/round-robin.d.ts +27 -0
- package/dist/strategies/round-robin.d.ts.map +1 -0
- package/dist/strategies/round-robin.js +98 -0
- package/dist/strategies/round-robin.js.map +1 -0
- package/dist/swarm.d.ts +113 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +280 -0
- package/dist/swarm.js.map +1 -0
- package/dist/tools/blackboard.d.ts +71 -0
- package/dist/tools/blackboard.d.ts.map +1 -0
- package/dist/tools/blackboard.js +149 -0
- package/dist/tools/blackboard.js.map +1 -0
- package/dist/tools/delegation.d.ts +120 -0
- package/dist/tools/delegation.d.ts.map +1 -0
- package/dist/tools/delegation.js +257 -0
- package/dist/tools/delegation.js.map +1 -0
- package/dist/tools/index.d.ts +26 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +65 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/messaging.d.ts +73 -0
- package/dist/tools/messaging.d.ts.map +1 -0
- package/dist/tools/messaging.js +146 -0
- package/dist/tools/messaging.js.map +1 -0
- package/dist/tools/voting.d.ts +110 -0
- package/dist/tools/voting.d.ts.map +1 -0
- package/dist/tools/voting.js +201 -0
- package/dist/tools/voting.js.map +1 -0
- package/dist/workflow/swarm-node.d.ts +43 -0
- package/dist/workflow/swarm-node.d.ts.map +1 -0
- package/dist/workflow/swarm-node.js +111 -0
- package/dist/workflow/swarm-node.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm delegation tools for hierarchical task management
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { tool } from '@cogitator-ai/core';
|
|
6
|
+
/**
|
|
7
|
+
* Create delegation tools for supervisor agents
|
|
8
|
+
*/
|
|
9
|
+
export function createDelegationTools(coordinator, blackboard, currentAgent) {
|
|
10
|
+
const delegateTask = tool({
|
|
11
|
+
name: 'delegate_task',
|
|
12
|
+
description: 'Delegate a task to a worker agent',
|
|
13
|
+
parameters: z.object({
|
|
14
|
+
worker: z.string().describe('Name of the worker agent to delegate to'),
|
|
15
|
+
task: z.string().describe('The task description to delegate'),
|
|
16
|
+
context: z.record(z.unknown()).optional().describe('Additional context for the worker'),
|
|
17
|
+
priority: z.enum(['high', 'normal', 'low']).optional().describe('Task priority'),
|
|
18
|
+
waitForCompletion: z.boolean().optional().describe('Wait for worker to complete (default: true)'),
|
|
19
|
+
}),
|
|
20
|
+
execute: async ({ worker, task, context, priority = 'normal', waitForCompletion = true }) => {
|
|
21
|
+
const workerAgent = coordinator.getAgent(worker);
|
|
22
|
+
if (!workerAgent) {
|
|
23
|
+
return {
|
|
24
|
+
success: false,
|
|
25
|
+
error: `Worker agent '${worker}' not found`,
|
|
26
|
+
availableWorkers: coordinator.getAgentsByRole('worker').map(a => a.agent.name),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const tasks = blackboard.read('tasks') ?? [];
|
|
30
|
+
const taskId = `task_${Date.now()}_${worker}`;
|
|
31
|
+
tasks.push({
|
|
32
|
+
id: taskId,
|
|
33
|
+
worker,
|
|
34
|
+
task,
|
|
35
|
+
status: 'delegated',
|
|
36
|
+
delegatedBy: currentAgent,
|
|
37
|
+
timestamp: Date.now(),
|
|
38
|
+
});
|
|
39
|
+
blackboard.write('tasks', tasks, currentAgent);
|
|
40
|
+
if (!waitForCompletion) {
|
|
41
|
+
coordinator.runAgent(worker, task, {
|
|
42
|
+
...context,
|
|
43
|
+
delegationContext: {
|
|
44
|
+
delegatedBy: currentAgent,
|
|
45
|
+
taskId,
|
|
46
|
+
priority,
|
|
47
|
+
},
|
|
48
|
+
}).then(result => {
|
|
49
|
+
const currentTasks = blackboard.read('tasks') ?? [];
|
|
50
|
+
const taskIndex = currentTasks.findIndex(t => t.id === taskId);
|
|
51
|
+
if (taskIndex >= 0) {
|
|
52
|
+
currentTasks[taskIndex].status = 'completed';
|
|
53
|
+
}
|
|
54
|
+
blackboard.write('tasks', currentTasks, worker);
|
|
55
|
+
const workerResults = blackboard.read('workerResults') ?? {};
|
|
56
|
+
workerResults[taskId] = result.output;
|
|
57
|
+
blackboard.write('workerResults', workerResults, worker);
|
|
58
|
+
}).catch(() => {
|
|
59
|
+
const currentTasks = blackboard.read('tasks') ?? [];
|
|
60
|
+
const taskIndex = currentTasks.findIndex(t => t.id === taskId);
|
|
61
|
+
if (taskIndex >= 0) {
|
|
62
|
+
currentTasks[taskIndex].status = 'failed';
|
|
63
|
+
}
|
|
64
|
+
blackboard.write('tasks', currentTasks, worker);
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
taskId,
|
|
69
|
+
worker,
|
|
70
|
+
async: true,
|
|
71
|
+
message: `Task delegated to ${worker}, running in background`,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const result = await coordinator.runAgent(worker, task, {
|
|
76
|
+
...context,
|
|
77
|
+
delegationContext: {
|
|
78
|
+
delegatedBy: currentAgent,
|
|
79
|
+
taskId,
|
|
80
|
+
priority,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
const currentTasks = blackboard.read('tasks') ?? [];
|
|
84
|
+
const taskIndex = currentTasks.findIndex(t => t.id === taskId);
|
|
85
|
+
if (taskIndex >= 0) {
|
|
86
|
+
currentTasks[taskIndex].status = 'completed';
|
|
87
|
+
}
|
|
88
|
+
blackboard.write('tasks', currentTasks, worker);
|
|
89
|
+
const workerResults = blackboard.read('workerResults') ?? {};
|
|
90
|
+
workerResults[taskId] = result.output;
|
|
91
|
+
blackboard.write('workerResults', workerResults, worker);
|
|
92
|
+
return {
|
|
93
|
+
success: true,
|
|
94
|
+
taskId,
|
|
95
|
+
worker,
|
|
96
|
+
output: result.output,
|
|
97
|
+
usage: {
|
|
98
|
+
tokens: result.usage.totalTokens,
|
|
99
|
+
cost: result.usage.cost,
|
|
100
|
+
duration: result.usage.duration,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
const currentTasks = blackboard.read('tasks') ?? [];
|
|
106
|
+
const taskIndex = currentTasks.findIndex(t => t.id === taskId);
|
|
107
|
+
if (taskIndex >= 0) {
|
|
108
|
+
currentTasks[taskIndex].status = 'failed';
|
|
109
|
+
}
|
|
110
|
+
blackboard.write('tasks', currentTasks, worker);
|
|
111
|
+
return {
|
|
112
|
+
success: false,
|
|
113
|
+
taskId,
|
|
114
|
+
worker,
|
|
115
|
+
error: error instanceof Error ? error.message : 'Worker failed',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
const checkProgress = tool({
|
|
121
|
+
name: 'check_progress',
|
|
122
|
+
description: 'Check the progress and state of a worker agent',
|
|
123
|
+
parameters: z.object({
|
|
124
|
+
worker: z.string().describe('Name of the worker agent to check'),
|
|
125
|
+
}),
|
|
126
|
+
execute: async ({ worker }) => {
|
|
127
|
+
const workerAgent = coordinator.getAgent(worker);
|
|
128
|
+
if (!workerAgent) {
|
|
129
|
+
return {
|
|
130
|
+
found: false,
|
|
131
|
+
error: `Worker agent '${worker}' not found`,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const tasks = blackboard.read('tasks') ?? [];
|
|
135
|
+
const workerTasks = tasks.filter(t => t.worker === worker);
|
|
136
|
+
const lastTask = workerTasks[workerTasks.length - 1];
|
|
137
|
+
const workerResults = blackboard.read('workerResults') ?? {};
|
|
138
|
+
const lastResult = lastTask ? workerResults[lastTask.id] : undefined;
|
|
139
|
+
return {
|
|
140
|
+
found: true,
|
|
141
|
+
worker,
|
|
142
|
+
state: workerAgent.state,
|
|
143
|
+
tokenCount: workerAgent.tokenCount,
|
|
144
|
+
tasks: {
|
|
145
|
+
total: workerTasks.length,
|
|
146
|
+
completed: workerTasks.filter(t => t.status === 'completed').length,
|
|
147
|
+
pending: workerTasks.filter(t => t.status === 'delegated').length,
|
|
148
|
+
failed: workerTasks.filter(t => t.status === 'failed').length,
|
|
149
|
+
},
|
|
150
|
+
lastTask: lastTask ? {
|
|
151
|
+
id: lastTask.id,
|
|
152
|
+
task: lastTask.task.slice(0, 200),
|
|
153
|
+
status: lastTask.status,
|
|
154
|
+
result: typeof lastResult === 'string' ? lastResult.slice(0, 500) : lastResult,
|
|
155
|
+
} : null,
|
|
156
|
+
};
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
const requestRevision = tool({
|
|
160
|
+
name: 'request_revision',
|
|
161
|
+
description: 'Ask a worker to revise their previous work',
|
|
162
|
+
parameters: z.object({
|
|
163
|
+
worker: z.string().describe('Name of the worker agent'),
|
|
164
|
+
feedback: z.string().describe('Feedback on what needs to be revised'),
|
|
165
|
+
taskId: z.string().optional().describe('Specific task ID to revise (uses last task if omitted)'),
|
|
166
|
+
}),
|
|
167
|
+
execute: async ({ worker, feedback, taskId }) => {
|
|
168
|
+
const workerAgent = coordinator.getAgent(worker);
|
|
169
|
+
if (!workerAgent) {
|
|
170
|
+
return {
|
|
171
|
+
success: false,
|
|
172
|
+
error: `Worker agent '${worker}' not found`,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const tasks = blackboard.read('tasks') ?? [];
|
|
176
|
+
const workerTasks = tasks.filter(t => t.worker === worker);
|
|
177
|
+
const targetTask = taskId
|
|
178
|
+
? workerTasks.find(t => t.id === taskId)
|
|
179
|
+
: workerTasks[workerTasks.length - 1];
|
|
180
|
+
if (!targetTask) {
|
|
181
|
+
return {
|
|
182
|
+
success: false,
|
|
183
|
+
error: taskId ? `Task '${taskId}' not found` : 'No previous task found for this worker',
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const workerResults = blackboard.read('workerResults') ?? {};
|
|
187
|
+
const previousResult = workerResults[targetTask.id];
|
|
188
|
+
const revisionInput = `
|
|
189
|
+
REVISION REQUEST
|
|
190
|
+
|
|
191
|
+
Your previous work on this task needs revision.
|
|
192
|
+
|
|
193
|
+
Original task:
|
|
194
|
+
${targetTask.task}
|
|
195
|
+
|
|
196
|
+
Your previous output:
|
|
197
|
+
${typeof previousResult === 'string' ? previousResult : JSON.stringify(previousResult)}
|
|
198
|
+
|
|
199
|
+
Feedback:
|
|
200
|
+
${feedback}
|
|
201
|
+
|
|
202
|
+
Please provide a revised response addressing the feedback.
|
|
203
|
+
`.trim();
|
|
204
|
+
const result = await coordinator.runAgent(worker, revisionInput, {
|
|
205
|
+
delegationContext: {
|
|
206
|
+
delegatedBy: currentAgent,
|
|
207
|
+
taskId: targetTask.id,
|
|
208
|
+
isRevision: true,
|
|
209
|
+
originalTask: targetTask.task,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
workerResults[targetTask.id] = result.output;
|
|
213
|
+
blackboard.write('workerResults', workerResults, worker);
|
|
214
|
+
const updatedTasks = blackboard.read('tasks') ?? [];
|
|
215
|
+
const taskIndex = updatedTasks.findIndex(t => t.id === targetTask.id);
|
|
216
|
+
if (taskIndex >= 0) {
|
|
217
|
+
updatedTasks[taskIndex].status = 'revised';
|
|
218
|
+
}
|
|
219
|
+
blackboard.write('tasks', updatedTasks, worker);
|
|
220
|
+
return {
|
|
221
|
+
success: true,
|
|
222
|
+
taskId: targetTask.id,
|
|
223
|
+
worker,
|
|
224
|
+
revisedOutput: result.output,
|
|
225
|
+
};
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
const listWorkers = tool({
|
|
229
|
+
name: 'list_workers',
|
|
230
|
+
description: 'List all available worker agents and their status',
|
|
231
|
+
parameters: z.object({
|
|
232
|
+
includeMetadata: z.boolean().optional().describe('Include worker metadata like expertise'),
|
|
233
|
+
}),
|
|
234
|
+
execute: async ({ includeMetadata }) => {
|
|
235
|
+
const workers = coordinator.getAgentsByRole('worker');
|
|
236
|
+
return {
|
|
237
|
+
count: workers.length,
|
|
238
|
+
workers: workers.map(w => ({
|
|
239
|
+
name: w.agent.name,
|
|
240
|
+
state: w.state,
|
|
241
|
+
tokenCount: w.tokenCount,
|
|
242
|
+
...(includeMetadata ? {
|
|
243
|
+
expertise: w.metadata.expertise ?? [],
|
|
244
|
+
priority: w.metadata.priority ?? 0,
|
|
245
|
+
} : {}),
|
|
246
|
+
})),
|
|
247
|
+
};
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
return {
|
|
251
|
+
delegateTask,
|
|
252
|
+
checkProgress,
|
|
253
|
+
requestRevision,
|
|
254
|
+
listWorkers,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=delegation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../src/tools/delegation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAAsC,EACtC,UAA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AAU,EAAE,CAAC,CAAC,UAAU;oBACxB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;wBACpB,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE;wBACrC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,IAAI,CAAC;qBACnC,CAAC,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,YAAY;QACZ,aAAa;QACb,eAAe;QACf,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm tools exports
|
|
3
|
+
*/
|
|
4
|
+
export { createMessagingTools, type MessagingTools } from './messaging';
|
|
5
|
+
export { createBlackboardTools, type BlackboardTools } from './blackboard';
|
|
6
|
+
export { createDelegationTools, type DelegationTools } from './delegation';
|
|
7
|
+
export { createVotingTools, type VotingTools } from './voting';
|
|
8
|
+
import type { Tool } from '@cogitator-ai/types';
|
|
9
|
+
import type { SwarmCoordinatorInterface, Blackboard, MessageBus, SwarmEventEmitter } from '@cogitator-ai/types';
|
|
10
|
+
export interface SwarmToolContext {
|
|
11
|
+
coordinator: SwarmCoordinatorInterface;
|
|
12
|
+
blackboard: Blackboard;
|
|
13
|
+
messageBus: MessageBus;
|
|
14
|
+
events: SwarmEventEmitter;
|
|
15
|
+
agentName: string;
|
|
16
|
+
agentWeight?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create all swarm tools for an agent
|
|
20
|
+
*/
|
|
21
|
+
export declare function createSwarmTools(context: SwarmToolContext): Tool<unknown, unknown>[];
|
|
22
|
+
/**
|
|
23
|
+
* Create tools for a specific strategy
|
|
24
|
+
*/
|
|
25
|
+
export declare function createStrategyTools(strategy: 'hierarchical' | 'consensus' | 'debate' | 'auction' | 'pipeline' | 'round-robin', context: SwarmToolContext): Tool<unknown, unknown>[];
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMhH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,yBAAyB,CAAC;IACvC,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAkCpF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,EAC1F,OAAO,EAAE,gBAAgB,GACxB,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAiC1B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm tools exports
|
|
3
|
+
*/
|
|
4
|
+
export { createMessagingTools } from './messaging';
|
|
5
|
+
export { createBlackboardTools } from './blackboard';
|
|
6
|
+
export { createDelegationTools } from './delegation';
|
|
7
|
+
export { createVotingTools } from './voting';
|
|
8
|
+
import { createMessagingTools } from './messaging';
|
|
9
|
+
import { createBlackboardTools } from './blackboard';
|
|
10
|
+
import { createDelegationTools } from './delegation';
|
|
11
|
+
import { createVotingTools } from './voting';
|
|
12
|
+
/**
|
|
13
|
+
* Create all swarm tools for an agent
|
|
14
|
+
*/
|
|
15
|
+
export function createSwarmTools(context) {
|
|
16
|
+
const messagingTools = createMessagingTools(context.messageBus, context.agentName);
|
|
17
|
+
const blackboardTools = createBlackboardTools(context.blackboard, context.agentName);
|
|
18
|
+
const delegationTools = createDelegationTools(context.coordinator, context.blackboard, context.agentName);
|
|
19
|
+
const votingTools = createVotingTools(context.blackboard, context.events, context.agentName, context.agentWeight);
|
|
20
|
+
return [
|
|
21
|
+
messagingTools.sendMessage,
|
|
22
|
+
messagingTools.readMessages,
|
|
23
|
+
messagingTools.broadcastMessage,
|
|
24
|
+
messagingTools.replyToMessage,
|
|
25
|
+
blackboardTools.readBlackboard,
|
|
26
|
+
blackboardTools.writeBlackboard,
|
|
27
|
+
blackboardTools.appendBlackboard,
|
|
28
|
+
blackboardTools.listBlackboardSections,
|
|
29
|
+
blackboardTools.getBlackboardHistory,
|
|
30
|
+
delegationTools.delegateTask,
|
|
31
|
+
delegationTools.checkProgress,
|
|
32
|
+
delegationTools.requestRevision,
|
|
33
|
+
delegationTools.listWorkers,
|
|
34
|
+
votingTools.castVote,
|
|
35
|
+
votingTools.getVotes,
|
|
36
|
+
votingTools.changeVote,
|
|
37
|
+
votingTools.getConsensusStatus,
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create tools for a specific strategy
|
|
42
|
+
*/
|
|
43
|
+
export function createStrategyTools(strategy, context) {
|
|
44
|
+
const baseTools = [
|
|
45
|
+
...Object.values(createMessagingTools(context.messageBus, context.agentName)),
|
|
46
|
+
...Object.values(createBlackboardTools(context.blackboard, context.agentName)),
|
|
47
|
+
];
|
|
48
|
+
switch (strategy) {
|
|
49
|
+
case 'hierarchical': {
|
|
50
|
+
const delegationTools = createDelegationTools(context.coordinator, context.blackboard, context.agentName);
|
|
51
|
+
return [...baseTools, ...Object.values(delegationTools)];
|
|
52
|
+
}
|
|
53
|
+
case 'consensus':
|
|
54
|
+
case 'debate': {
|
|
55
|
+
const votingTools = createVotingTools(context.blackboard, context.events, context.agentName, context.agentWeight);
|
|
56
|
+
return [...baseTools, ...Object.values(votingTools)];
|
|
57
|
+
}
|
|
58
|
+
case 'auction':
|
|
59
|
+
case 'pipeline':
|
|
60
|
+
case 'round-robin':
|
|
61
|
+
default:
|
|
62
|
+
return baseTools;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAuB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAwB,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAwB,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAoB,MAAM,UAAU,CAAC;AAI/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAW7C;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAyB;IACxD,MAAM,cAAc,GAAG,oBAAoB,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACnF,MAAM,e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,CAAC,WAAW,EACnB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,SAAS,CAClB,CAAC;YACF,OAAO,CAAC,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAA6B,CAAC;QACvF,CAAC;QAED,KAAK,WAAW,CAAC;QACjB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,WAAW,GAAG,iBAAiB,CACnC,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,WAAW,CACpB,CAAC;YACF,OAAO,CAAC,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAA6B,CAAC;QACnF,CAAC;QAED,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,aAAa,CAAC;QACnB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm messaging tools for agent-to-agent communication
|
|
3
|
+
*/
|
|
4
|
+
import type { MessageBus } from '@cogitator-ai/types';
|
|
5
|
+
/**
|
|
6
|
+
* Create messaging tools bound to a message bus
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMessagingTools(messageBus: MessageBus, currentAgent: string): {
|
|
9
|
+
sendMessage: import("@cogitator-ai/types").Tool<{
|
|
10
|
+
to: string;
|
|
11
|
+
message: string;
|
|
12
|
+
channel?: string | undefined;
|
|
13
|
+
waitForReply?: boolean | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
sent: boolean;
|
|
16
|
+
messageId: string;
|
|
17
|
+
reply: string;
|
|
18
|
+
replyId: string;
|
|
19
|
+
timeout?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
sent: boolean;
|
|
22
|
+
messageId: string;
|
|
23
|
+
reply: null;
|
|
24
|
+
timeout: boolean;
|
|
25
|
+
replyId?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
sent: boolean;
|
|
28
|
+
messageId: string;
|
|
29
|
+
reply?: undefined;
|
|
30
|
+
replyId?: undefined;
|
|
31
|
+
timeout?: undefined;
|
|
32
|
+
}>;
|
|
33
|
+
readMessages: import("@cogitator-ai/types").Tool<{
|
|
34
|
+
from?: string | undefined;
|
|
35
|
+
channel?: string | undefined;
|
|
36
|
+
limit?: number | undefined;
|
|
37
|
+
unreadOnly?: boolean | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
count: number;
|
|
40
|
+
messages: {
|
|
41
|
+
id: string;
|
|
42
|
+
from: string;
|
|
43
|
+
content: string;
|
|
44
|
+
channel: string | undefined;
|
|
45
|
+
timestamp: number;
|
|
46
|
+
type: import("@cogitator-ai/types").SwarmMessageType;
|
|
47
|
+
}[];
|
|
48
|
+
}>;
|
|
49
|
+
broadcastMessage: import("@cogitator-ai/types").Tool<{
|
|
50
|
+
message: string;
|
|
51
|
+
channel?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
broadcasted: boolean;
|
|
54
|
+
from: string;
|
|
55
|
+
channel: string;
|
|
56
|
+
}>;
|
|
57
|
+
replyToMessage: import("@cogitator-ai/types").Tool<{
|
|
58
|
+
message: string;
|
|
59
|
+
originalMessageId: string;
|
|
60
|
+
}, {
|
|
61
|
+
success: boolean;
|
|
62
|
+
error: string;
|
|
63
|
+
replyId?: undefined;
|
|
64
|
+
to?: undefined;
|
|
65
|
+
} | {
|
|
66
|
+
success: boolean;
|
|
67
|
+
replyId: string;
|
|
68
|
+
to: string;
|
|
69
|
+
error?: undefined;
|
|
70
|
+
}>;
|
|
71
|
+
};
|
|
72
|
+
export type MessagingTools = ReturnType<typeof createMessagingTools>;
|
|
73
|
+
//# sourceMappingURL=messaging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../src/tools/messaging.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2JhF;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm messaging tools for agent-to-agent communication
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { tool } from '@cogitator-ai/core';
|
|
6
|
+
/**
|
|
7
|
+
* Create messaging tools bound to a message bus
|
|
8
|
+
*/
|
|
9
|
+
export function createMessagingTools(messageBus, currentAgent) {
|
|
10
|
+
const sendMessage = tool({
|
|
11
|
+
name: 'send_message',
|
|
12
|
+
description: 'Send a message to another agent in the swarm',
|
|
13
|
+
parameters: z.object({
|
|
14
|
+
to: z.string().describe('Name of the recipient agent'),
|
|
15
|
+
message: z.string().describe('The message content to send'),
|
|
16
|
+
channel: z.string().optional().describe('Optional channel for message categorization'),
|
|
17
|
+
waitForReply: z.boolean().optional().describe('Whether to wait for a response (default: false)'),
|
|
18
|
+
}),
|
|
19
|
+
execute: async ({ to, message, channel, waitForReply }) => {
|
|
20
|
+
const msg = await messageBus.send({
|
|
21
|
+
swarmId: '',
|
|
22
|
+
from: currentAgent,
|
|
23
|
+
to,
|
|
24
|
+
type: 'request',
|
|
25
|
+
content: message,
|
|
26
|
+
channel,
|
|
27
|
+
});
|
|
28
|
+
if (waitForReply) {
|
|
29
|
+
const maxWait = 30000;
|
|
30
|
+
const pollInterval = 500;
|
|
31
|
+
let waited = 0;
|
|
32
|
+
while (waited < maxWait) {
|
|
33
|
+
const messages = messageBus.getMessages(currentAgent);
|
|
34
|
+
const reply = messages.find(m => m.from === to &&
|
|
35
|
+
m.type === 'response' &&
|
|
36
|
+
m.metadata?.correlationId === msg.id);
|
|
37
|
+
if (reply) {
|
|
38
|
+
return {
|
|
39
|
+
sent: true,
|
|
40
|
+
messageId: msg.id,
|
|
41
|
+
reply: reply.content,
|
|
42
|
+
replyId: reply.id,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
await new Promise(r => setTimeout(r, pollInterval));
|
|
46
|
+
waited += pollInterval;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
sent: true,
|
|
50
|
+
messageId: msg.id,
|
|
51
|
+
reply: null,
|
|
52
|
+
timeout: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
sent: true,
|
|
57
|
+
messageId: msg.id,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
const readMessages = tool({
|
|
62
|
+
name: 'read_messages',
|
|
63
|
+
description: 'Read messages sent to you from other agents',
|
|
64
|
+
parameters: z.object({
|
|
65
|
+
limit: z.number().optional().describe('Maximum number of messages to return (default: 10)'),
|
|
66
|
+
from: z.string().optional().describe('Filter by sender agent name'),
|
|
67
|
+
channel: z.string().optional().describe('Filter by channel'),
|
|
68
|
+
unreadOnly: z.boolean().optional().describe('Only return unread messages'),
|
|
69
|
+
}),
|
|
70
|
+
execute: async ({ limit = 10, from, channel }) => {
|
|
71
|
+
let messages = messageBus.getMessages(currentAgent);
|
|
72
|
+
if (from) {
|
|
73
|
+
messages = messages.filter(m => m.from === from);
|
|
74
|
+
}
|
|
75
|
+
if (channel) {
|
|
76
|
+
messages = messages.filter(m => m.channel === channel);
|
|
77
|
+
}
|
|
78
|
+
messages = messages.slice(0, limit);
|
|
79
|
+
return {
|
|
80
|
+
count: messages.length,
|
|
81
|
+
messages: messages.map(m => ({
|
|
82
|
+
id: m.id,
|
|
83
|
+
from: m.from,
|
|
84
|
+
content: m.content,
|
|
85
|
+
channel: m.channel,
|
|
86
|
+
timestamp: m.timestamp,
|
|
87
|
+
type: m.type,
|
|
88
|
+
})),
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
const broadcastMessage = tool({
|
|
93
|
+
name: 'broadcast_message',
|
|
94
|
+
description: 'Broadcast a message to all agents in the swarm',
|
|
95
|
+
parameters: z.object({
|
|
96
|
+
message: z.string().describe('The message content to broadcast'),
|
|
97
|
+
channel: z.string().optional().describe('Optional channel for message categorization'),
|
|
98
|
+
}),
|
|
99
|
+
execute: async ({ message, channel }) => {
|
|
100
|
+
await messageBus.broadcast(currentAgent, message, channel);
|
|
101
|
+
return {
|
|
102
|
+
broadcasted: true,
|
|
103
|
+
from: currentAgent,
|
|
104
|
+
channel: channel ?? 'default',
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
const replyToMessage = tool({
|
|
109
|
+
name: 'reply_to_message',
|
|
110
|
+
description: 'Reply to a specific message',
|
|
111
|
+
parameters: z.object({
|
|
112
|
+
originalMessageId: z.string().describe('ID of the message to reply to'),
|
|
113
|
+
message: z.string().describe('The reply content'),
|
|
114
|
+
}),
|
|
115
|
+
execute: async ({ originalMessageId, message }) => {
|
|
116
|
+
const allMessages = messageBus.getMessages(currentAgent);
|
|
117
|
+
const original = allMessages.find(m => m.id === originalMessageId);
|
|
118
|
+
if (!original) {
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: 'Original message not found',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const reply = await messageBus.send({
|
|
125
|
+
swarmId: '',
|
|
126
|
+
from: currentAgent,
|
|
127
|
+
to: original.from,
|
|
128
|
+
type: 'response',
|
|
129
|
+
content: message,
|
|
130
|
+
metadata: { correlationId: originalMessageId },
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
success: true,
|
|
134
|
+
replyId: reply.id,
|
|
135
|
+
to: original.from,
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
sendMessage,
|
|
141
|
+
readMessages,
|
|
142
|
+
broadcastMessage,
|
|
143
|
+
replyToMessage,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=messaging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../src/tools/messaging.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAsB,EAAE,YAAoB;IAC/E,MAAM,WAAW,GAAG,IAAI,CAAC;QACvB,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,8CAA8C;QAC3D,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;YACnB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;YACtD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;YAC3D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;YACtF,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;SACjG,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE;YACxD,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC;gBAChC,OAAO,EAAE,EAAE;gBACX,IAAI,EAAE,YAAY;gBAClB,EAAE;gBACF,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,OAAO;gBAChB,OAAO;aACR,CAAC,CAAC;YAEH,IAAI,YAAY,EAAE,CA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