@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,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm voting tools for consensus decision-making
|
|
3
|
+
*/
|
|
4
|
+
import type { Blackboard, SwarmEventEmitter } from '@cogitator-ai/types';
|
|
5
|
+
/**
|
|
6
|
+
* Create voting tools for consensus strategies
|
|
7
|
+
*/
|
|
8
|
+
export declare function createVotingTools(blackboard: Blackboard, events: SwarmEventEmitter, currentAgent: string, agentWeight?: number): {
|
|
9
|
+
castVote: import("@cogitator-ai/types").Tool<{
|
|
10
|
+
decision: string;
|
|
11
|
+
reasoning?: string | undefined;
|
|
12
|
+
confidence?: number | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
success: boolean;
|
|
15
|
+
error: string;
|
|
16
|
+
voteRecorded?: undefined;
|
|
17
|
+
round?: undefined;
|
|
18
|
+
decision?: undefined;
|
|
19
|
+
weight?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
success: boolean;
|
|
22
|
+
voteRecorded: boolean;
|
|
23
|
+
round: number;
|
|
24
|
+
decision: string;
|
|
25
|
+
weight: number;
|
|
26
|
+
error?: undefined;
|
|
27
|
+
}>;
|
|
28
|
+
getVotes: import("@cogitator-ai/types").Tool<{
|
|
29
|
+
round?: number | undefined;
|
|
30
|
+
includeReasoning?: boolean | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
success: boolean;
|
|
33
|
+
error: string;
|
|
34
|
+
votes: never[];
|
|
35
|
+
currentRound?: undefined;
|
|
36
|
+
totalVotes?: undefined;
|
|
37
|
+
threshold?: undefined;
|
|
38
|
+
resolution?: undefined;
|
|
39
|
+
summary?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
success: boolean;
|
|
42
|
+
currentRound: number;
|
|
43
|
+
totalVotes: number;
|
|
44
|
+
threshold: number;
|
|
45
|
+
resolution: string;
|
|
46
|
+
votes: {
|
|
47
|
+
reasoning?: string | undefined;
|
|
48
|
+
agent: string;
|
|
49
|
+
decision: string;
|
|
50
|
+
round: number;
|
|
51
|
+
weight: number;
|
|
52
|
+
}[];
|
|
53
|
+
summary: {
|
|
54
|
+
decision: string;
|
|
55
|
+
count: number;
|
|
56
|
+
weightedCount: number;
|
|
57
|
+
voters: string[];
|
|
58
|
+
}[];
|
|
59
|
+
error?: undefined;
|
|
60
|
+
}>;
|
|
61
|
+
changeVote: import("@cogitator-ai/types").Tool<{
|
|
62
|
+
newDecision: string;
|
|
63
|
+
reasoning?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
success: boolean;
|
|
66
|
+
error: string;
|
|
67
|
+
previousDecision?: undefined;
|
|
68
|
+
newDecision?: undefined;
|
|
69
|
+
round?: undefined;
|
|
70
|
+
} | {
|
|
71
|
+
success: boolean;
|
|
72
|
+
previousDecision: string | null;
|
|
73
|
+
newDecision: string;
|
|
74
|
+
round: number;
|
|
75
|
+
error?: undefined;
|
|
76
|
+
}>;
|
|
77
|
+
getConsensusStatus: import("@cogitator-ai/types").Tool<{}, {
|
|
78
|
+
active: boolean;
|
|
79
|
+
error: string;
|
|
80
|
+
topic?: undefined;
|
|
81
|
+
currentRound?: undefined;
|
|
82
|
+
maxRounds?: undefined;
|
|
83
|
+
roundsRemaining?: undefined;
|
|
84
|
+
threshold?: undefined;
|
|
85
|
+
resolution?: undefined;
|
|
86
|
+
currentVotes?: undefined;
|
|
87
|
+
leadingDecision?: undefined;
|
|
88
|
+
leadingVotes?: undefined;
|
|
89
|
+
consensusRatio?: undefined;
|
|
90
|
+
wouldReachConsensus?: undefined;
|
|
91
|
+
hasVoted?: undefined;
|
|
92
|
+
} | {
|
|
93
|
+
active: boolean;
|
|
94
|
+
topic: string;
|
|
95
|
+
currentRound: number;
|
|
96
|
+
maxRounds: number;
|
|
97
|
+
roundsRemaining: number;
|
|
98
|
+
threshold: number;
|
|
99
|
+
resolution: string;
|
|
100
|
+
currentVotes: number;
|
|
101
|
+
leadingDecision: string;
|
|
102
|
+
leadingVotes: number;
|
|
103
|
+
consensusRatio: number;
|
|
104
|
+
wouldReachConsensus: boolean;
|
|
105
|
+
hasVoted: boolean;
|
|
106
|
+
error?: undefined;
|
|
107
|
+
}>;
|
|
108
|
+
};
|
|
109
|
+
export type VotingTools = ReturnType<typeof createVotingTools>;
|
|
110
|
+
//# sourceMappingURL=voting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting.d.ts","sourceRoot":"","sources":["../../src/tools/voting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAWzE;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,iBAAiB,EACzB,YAAY,EAAE,MAAM,EACpB,WAAW,SAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkPhB;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm voting tools for consensus decision-making
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { tool } from '@cogitator-ai/core';
|
|
6
|
+
/**
|
|
7
|
+
* Create voting tools for consensus strategies
|
|
8
|
+
*/
|
|
9
|
+
export function createVotingTools(blackboard, events, currentAgent, agentWeight = 1) {
|
|
10
|
+
const castVote = tool({
|
|
11
|
+
name: 'cast_vote',
|
|
12
|
+
description: 'Cast a vote in the current consensus round',
|
|
13
|
+
parameters: z.object({
|
|
14
|
+
decision: z.string().describe('Your decision/vote'),
|
|
15
|
+
reasoning: z.string().optional().describe('Optional reasoning for your vote'),
|
|
16
|
+
confidence: z.number().optional().describe('Confidence level 0-1 (optional, affects display only)'),
|
|
17
|
+
}),
|
|
18
|
+
execute: async ({ decision, reasoning, confidence }) => {
|
|
19
|
+
const consensusState = blackboard.read('consensus');
|
|
20
|
+
if (!consensusState) {
|
|
21
|
+
return {
|
|
22
|
+
success: false,
|
|
23
|
+
error: 'No active consensus session',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const vote = {
|
|
27
|
+
agentName: currentAgent,
|
|
28
|
+
decision,
|
|
29
|
+
reasoning,
|
|
30
|
+
weight: agentWeight,
|
|
31
|
+
round: consensusState.currentRound,
|
|
32
|
+
timestamp: Date.now(),
|
|
33
|
+
};
|
|
34
|
+
consensusState.votes.push(vote);
|
|
35
|
+
blackboard.write('consensus', consensusState, currentAgent);
|
|
36
|
+
events.emit('consensus:vote', {
|
|
37
|
+
agent: currentAgent,
|
|
38
|
+
decision,
|
|
39
|
+
round: consensusState.currentRound,
|
|
40
|
+
confidence,
|
|
41
|
+
}, currentAgent);
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
voteRecorded: true,
|
|
45
|
+
round: consensusState.currentRound,
|
|
46
|
+
decision,
|
|
47
|
+
weight: agentWeight,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
const getVotes = tool({
|
|
52
|
+
name: 'get_votes',
|
|
53
|
+
description: 'Get all votes cast in the current consensus session',
|
|
54
|
+
parameters: z.object({
|
|
55
|
+
round: z.number().optional().describe('Specific round to get votes for (all rounds if omitted)'),
|
|
56
|
+
includeReasoning: z.boolean().optional().describe('Include vote reasoning'),
|
|
57
|
+
}),
|
|
58
|
+
execute: async ({ round, includeReasoning = false }) => {
|
|
59
|
+
const consensusState = blackboard.read('consensus');
|
|
60
|
+
if (!consensusState) {
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
error: 'No active consensus session',
|
|
64
|
+
votes: [],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
let votes = consensusState.votes;
|
|
68
|
+
if (round !== undefined) {
|
|
69
|
+
votes = votes.filter(v => v.round === round);
|
|
70
|
+
}
|
|
71
|
+
const voteCounts = new Map();
|
|
72
|
+
for (const vote of votes) {
|
|
73
|
+
const key = vote.decision.toLowerCase().trim();
|
|
74
|
+
const existing = voteCounts.get(key) ?? { count: 0, weighted: 0, voters: [] };
|
|
75
|
+
existing.count++;
|
|
76
|
+
existing.weighted += vote.weight;
|
|
77
|
+
existing.voters.push(vote.agentName);
|
|
78
|
+
voteCounts.set(key, existing);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
success: true,
|
|
82
|
+
currentRound: consensusState.currentRound,
|
|
83
|
+
totalVotes: votes.length,
|
|
84
|
+
threshold: consensusState.threshold,
|
|
85
|
+
resolution: consensusState.resolution,
|
|
86
|
+
votes: votes.map(v => ({
|
|
87
|
+
agent: v.agentName,
|
|
88
|
+
decision: v.decision,
|
|
89
|
+
round: v.round,
|
|
90
|
+
weight: v.weight,
|
|
91
|
+
...(includeReasoning ? { reasoning: v.reasoning } : {}),
|
|
92
|
+
})),
|
|
93
|
+
summary: Array.from(voteCounts.entries()).map(([decision, data]) => ({
|
|
94
|
+
decision,
|
|
95
|
+
count: data.count,
|
|
96
|
+
weightedCount: data.weighted,
|
|
97
|
+
voters: data.voters,
|
|
98
|
+
})),
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
const changeVote = tool({
|
|
103
|
+
name: 'change_vote',
|
|
104
|
+
description: 'Change your previous vote in the current round',
|
|
105
|
+
parameters: z.object({
|
|
106
|
+
newDecision: z.string().describe('Your new decision/vote'),
|
|
107
|
+
reasoning: z.string().optional().describe('Reasoning for changing your vote'),
|
|
108
|
+
}),
|
|
109
|
+
execute: async ({ newDecision, reasoning }) => {
|
|
110
|
+
const consensusState = blackboard.read('consensus');
|
|
111
|
+
if (!consensusState) {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
error: 'No active consensus session',
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const previousVoteIndex = consensusState.votes.findIndex(v => v.agentName === currentAgent && v.round === consensusState.currentRound);
|
|
118
|
+
const previousDecision = previousVoteIndex >= 0
|
|
119
|
+
? consensusState.votes[previousVoteIndex].decision
|
|
120
|
+
: null;
|
|
121
|
+
if (previousVoteIndex >= 0) {
|
|
122
|
+
consensusState.votes.splice(previousVoteIndex, 1);
|
|
123
|
+
}
|
|
124
|
+
const vote = {
|
|
125
|
+
agentName: currentAgent,
|
|
126
|
+
decision: newDecision,
|
|
127
|
+
reasoning,
|
|
128
|
+
weight: agentWeight,
|
|
129
|
+
round: consensusState.currentRound,
|
|
130
|
+
timestamp: Date.now(),
|
|
131
|
+
};
|
|
132
|
+
consensusState.votes.push(vote);
|
|
133
|
+
blackboard.write('consensus', consensusState, currentAgent);
|
|
134
|
+
events.emit('consensus:vote:changed', {
|
|
135
|
+
agent: currentAgent,
|
|
136
|
+
previousDecision,
|
|
137
|
+
newDecision,
|
|
138
|
+
round: consensusState.currentRound,
|
|
139
|
+
}, currentAgent);
|
|
140
|
+
return {
|
|
141
|
+
success: true,
|
|
142
|
+
previousDecision,
|
|
143
|
+
newDecision,
|
|
144
|
+
round: consensusState.currentRound,
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
const getConsensusStatus = tool({
|
|
149
|
+
name: 'get_consensus_status',
|
|
150
|
+
description: 'Get the current status of the consensus session',
|
|
151
|
+
parameters: z.object({}),
|
|
152
|
+
execute: async () => {
|
|
153
|
+
const consensusState = blackboard.read('consensus');
|
|
154
|
+
if (!consensusState) {
|
|
155
|
+
return {
|
|
156
|
+
active: false,
|
|
157
|
+
error: 'No active consensus session',
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const currentRoundVotes = consensusState.votes.filter(v => v.round === consensusState.currentRound);
|
|
161
|
+
const voteCounts = new Map();
|
|
162
|
+
for (const vote of currentRoundVotes) {
|
|
163
|
+
const key = vote.decision.toLowerCase().trim();
|
|
164
|
+
voteCounts.set(key, (voteCounts.get(key) ?? 0) + 1);
|
|
165
|
+
}
|
|
166
|
+
const totalVotes = currentRoundVotes.length;
|
|
167
|
+
let leadingDecision = '';
|
|
168
|
+
let leadingCount = 0;
|
|
169
|
+
for (const [decision, count] of voteCounts) {
|
|
170
|
+
if (count > leadingCount) {
|
|
171
|
+
leadingCount = count;
|
|
172
|
+
leadingDecision = decision;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const consensusRatio = totalVotes > 0 ? leadingCount / totalVotes : 0;
|
|
176
|
+
const wouldReachConsensus = consensusRatio >= consensusState.threshold;
|
|
177
|
+
return {
|
|
178
|
+
active: true,
|
|
179
|
+
topic: consensusState.topic,
|
|
180
|
+
currentRound: consensusState.currentRound,
|
|
181
|
+
maxRounds: consensusState.maxRounds,
|
|
182
|
+
roundsRemaining: consensusState.maxRounds - consensusState.currentRound,
|
|
183
|
+
threshold: consensusState.threshold,
|
|
184
|
+
resolution: consensusState.resolution,
|
|
185
|
+
currentVotes: totalVotes,
|
|
186
|
+
leadingDecision,
|
|
187
|
+
leadingVotes: leadingCount,
|
|
188
|
+
consensusRatio: Math.round(consensusRatio * 100) / 100,
|
|
189
|
+
wouldReachConsensus,
|
|
190
|
+
hasVoted: currentRoundVotes.some(v => v.agentName === currentAgent),
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
castVote,
|
|
196
|
+
getVotes,
|
|
197
|
+
changeVote,
|
|
198
|
+
getConsensusStatus,
|
|
199
|
+
};
|
|
200
|
+
}
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Y,EAAE,YAAY;gBAC1B,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,GAAG,CAAC,GAAG,GAAG;gBACtD,mBAAmB;gBACnB,QAAQ,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,YAAY,CAAC;aACpE,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QACR,QAAQ;QACR,UAAU;QACV,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SwarmNode - Run a swarm as a workflow node
|
|
3
|
+
*/
|
|
4
|
+
import type { WorkflowNode, WorkflowState, NodeContext, SwarmConfig, SwarmRunOptions, StrategyResult } from '@cogitator-ai/types';
|
|
5
|
+
import type { Cogitator } from '@cogitator-ai/core';
|
|
6
|
+
import { Swarm } from '../swarm';
|
|
7
|
+
/**
|
|
8
|
+
* Extended context with Cogitator for swarm nodes
|
|
9
|
+
*/
|
|
10
|
+
export interface SwarmNodeContext<S = WorkflowState> extends NodeContext<S> {
|
|
11
|
+
cogitator: Cogitator;
|
|
12
|
+
}
|
|
13
|
+
export interface SwarmNodeOptions<S = WorkflowState> {
|
|
14
|
+
/**
|
|
15
|
+
* Map swarm result to state updates
|
|
16
|
+
*/
|
|
17
|
+
stateMapper?: (result: StrategyResult) => Partial<S>;
|
|
18
|
+
/**
|
|
19
|
+
* Map current state to swarm input
|
|
20
|
+
*/
|
|
21
|
+
inputMapper?: (state: S, input?: unknown) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Additional run options for the swarm
|
|
24
|
+
*/
|
|
25
|
+
runOptions?: Partial<SwarmRunOptions>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a workflow node that runs a swarm
|
|
29
|
+
*/
|
|
30
|
+
export declare function swarmNode<S extends WorkflowState = WorkflowState>(swarmOrConfig: Swarm | SwarmConfig, options?: SwarmNodeOptions<S>): WorkflowNode<S>;
|
|
31
|
+
/**
|
|
32
|
+
* Create a conditional swarm node that only runs if condition is met
|
|
33
|
+
*/
|
|
34
|
+
export declare function conditionalSwarmNode<S extends WorkflowState = WorkflowState>(swarmOrConfig: Swarm | SwarmConfig, condition: (state: S, ctx: NodeContext<S>) => boolean, options?: SwarmNodeOptions<S>): WorkflowNode<S>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a node that runs multiple swarms in parallel and merges results
|
|
37
|
+
*/
|
|
38
|
+
export declare function parallelSwarmsNode<S extends WorkflowState = WorkflowState>(swarms: {
|
|
39
|
+
swarm: Swarm | SwarmConfig;
|
|
40
|
+
key: string;
|
|
41
|
+
options?: SwarmNodeOptions<S>;
|
|
42
|
+
}[], mergeResults?: (results: Record<string, StrategyResult>) => Partial<S>): WorkflowNode<S>;
|
|
43
|
+
//# sourceMappingURL=swarm-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-node.d.ts","sourceRoot":"","sources":["../../src/workflow/swarm-node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EAEX,WAAW,EACX,eAAe,EACf,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,aAAa,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IACzE,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,aAAa;IACjD;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAErD;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IAEpD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAC/D,aAAa,EAAE,KAAK,GAAG,WAAW,EAClC,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC5B,YAAY,CAAC,CAAC,CAAC,CA6CjB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAC1E,aAAa,EAAE,KAAK,GAAG,WAAW,EAClC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,EACrD,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC5B,YAAY,CAAC,CAAC,CAAC,CAcjB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EACxE,MAAM,EAAE;IACN,KAAK,EAAE,KAAK,GAAG,WAAW,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAC/B,EAAE,EACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GACrE,YAAY,CAAC,CAAC,CAAC,CA4CjB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SwarmNode - Run a swarm as a workflow node
|
|
3
|
+
*/
|
|
4
|
+
import { Swarm } from '../swarm';
|
|
5
|
+
/**
|
|
6
|
+
* Create a workflow node that runs a swarm
|
|
7
|
+
*/
|
|
8
|
+
export function swarmNode(swarmOrConfig, options) {
|
|
9
|
+
const name = swarmOrConfig instanceof Swarm
|
|
10
|
+
? swarmOrConfig.name
|
|
11
|
+
: swarmOrConfig.name;
|
|
12
|
+
return {
|
|
13
|
+
name: `swarm:${name}`,
|
|
14
|
+
fn: async (ctx) => {
|
|
15
|
+
const extCtx = ctx;
|
|
16
|
+
const swarm = swarmOrConfig instanceof Swarm
|
|
17
|
+
? swarmOrConfig
|
|
18
|
+
: new Swarm(extCtx.cogitator, swarmOrConfig);
|
|
19
|
+
let input;
|
|
20
|
+
if (options?.inputMapper) {
|
|
21
|
+
input = options.inputMapper(ctx.state, ctx.input);
|
|
22
|
+
}
|
|
23
|
+
else if (typeof ctx.input === 'string') {
|
|
24
|
+
input = ctx.input;
|
|
25
|
+
}
|
|
26
|
+
else if (ctx.input !== undefined) {
|
|
27
|
+
input = JSON.stringify(ctx.input);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
input = JSON.stringify(ctx.state);
|
|
31
|
+
}
|
|
32
|
+
const result = await swarm.run({
|
|
33
|
+
input,
|
|
34
|
+
context: {
|
|
35
|
+
workflowContext: {
|
|
36
|
+
nodeId: ctx.nodeId,
|
|
37
|
+
step: ctx.step,
|
|
38
|
+
workflowState: ctx.state,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
...options?.runOptions,
|
|
42
|
+
});
|
|
43
|
+
const stateUpdate = options?.stateMapper?.(result);
|
|
44
|
+
return {
|
|
45
|
+
state: stateUpdate,
|
|
46
|
+
output: result.output,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a conditional swarm node that only runs if condition is met
|
|
53
|
+
*/
|
|
54
|
+
export function conditionalSwarmNode(swarmOrConfig, condition, options) {
|
|
55
|
+
const baseNode = swarmNode(swarmOrConfig, options);
|
|
56
|
+
return {
|
|
57
|
+
name: baseNode.name,
|
|
58
|
+
fn: async (ctx) => {
|
|
59
|
+
if (!condition(ctx.state, ctx)) {
|
|
60
|
+
return {
|
|
61
|
+
output: null,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return baseNode.fn(ctx);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create a node that runs multiple swarms in parallel and merges results
|
|
70
|
+
*/
|
|
71
|
+
export function parallelSwarmsNode(swarms, mergeResults) {
|
|
72
|
+
return {
|
|
73
|
+
name: `parallel-swarms:${swarms.map(s => {
|
|
74
|
+
const swarm = s.swarm instanceof Swarm ? s.swarm : s.swarm;
|
|
75
|
+
return 'name' in swarm ? swarm.name : 'unnamed';
|
|
76
|
+
}).join(',')}`,
|
|
77
|
+
fn: async (ctx) => {
|
|
78
|
+
const extCtx = ctx;
|
|
79
|
+
const results = {};
|
|
80
|
+
await Promise.all(swarms.map(async ({ swarm: swarmOrConfig, key, options }) => {
|
|
81
|
+
const swarm = swarmOrConfig instanceof Swarm
|
|
82
|
+
? swarmOrConfig
|
|
83
|
+
: new Swarm(extCtx.cogitator, swarmOrConfig);
|
|
84
|
+
let input;
|
|
85
|
+
if (options?.inputMapper) {
|
|
86
|
+
input = options.inputMapper(ctx.state, ctx.input);
|
|
87
|
+
}
|
|
88
|
+
else if (typeof ctx.input === 'string') {
|
|
89
|
+
input = ctx.input;
|
|
90
|
+
}
|
|
91
|
+
else if (ctx.input !== undefined) {
|
|
92
|
+
input = JSON.stringify(ctx.input);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
input = JSON.stringify(ctx.state);
|
|
96
|
+
}
|
|
97
|
+
const result = await swarm.run({
|
|
98
|
+
input,
|
|
99
|
+
...options?.runOptions,
|
|
100
|
+
});
|
|
101
|
+
results[key] = result;
|
|
102
|
+
}));
|
|
103
|
+
const stateUpdate = mergeResults?.(results);
|
|
104
|
+
return {
|
|
105
|
+
state: stateUpdate,
|
|
106
|
+
output: results,
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=swarm-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-node.js","sourceRoot":"","sources":["../../src/workflow/swarm-node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AA0BjC;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,aAAkC,EAClC,OAA6B;IAE7B,MAAM,IAAI,GAAG,aAAa,YAAY,KAAK;QACzC,CAAC,CAAC,aAAa,CAAC,IAAI;QACpB,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;IAEvB,OAAO;QACL,IAAI,EAAE,SAAS,IAAI,EAAE;QACrB,EAAE,EAAE,KAAK,EAAE,GAAG,EAA0B,EAAE;YACxC,MAAM,MAAM,GAAG,GAA0B,CAAC;YAE1C,MAAM,KAAK,GAAG,aAAa,YAAY,KAAK;gBAC1C,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YAE/C,IAAI,KAAa,CAAC;YAClB,IAAI,OAAO,EAAE,WAAW,EAAE,CAAC;gBACzB,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YACpD,CAAC;iBAAM,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACzC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;YACpB,CAAC;iBAAM,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBACnC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpC,CA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AG,CAAC,GAAG,MAAM,CAAC;YACxB,CAAC,CAAC,CACH,CAAC;YAEF,MAAM,WAAW,GAAG,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC;YAE5C,OAAO;gBACL,KAAK,EAAE,WAAW;gBAClB,MAAM,EAAE,OAAO;aAChB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cogitator-ai/swarms",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Multi-agent swarm coordination for Cogitator",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"nanoid": "^5.0.4",
|
|
19
|
+
"zod": "^3.22.0",
|
|
20
|
+
"@cogitator-ai/workflows": "0.1.0",
|
|
21
|
+
"@cogitator-ai/types": "0.1.0",
|
|
22
|
+
"@cogitator-ai/core": "0.1.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"typescript": "^5.3.0",
|
|
26
|
+
"vitest": "^1.0.0"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/eL1fe/cogitator.git",
|
|
31
|
+
"directory": "packages/swarms"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc",
|
|
39
|
+
"dev": "tsc --watch",
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest"
|
|
44
|
+
}
|
|
45
|
+
}
|