@jungjaehoon/mama-os 0.9.2 → 0.9.3
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/README.md +41 -7
- package/dist/api/graph-api.js +1 -1
- package/dist/api/graph-api.js.map +1 -1
- package/dist/cli/config/config-manager.d.ts.map +1 -1
- package/dist/cli/config/config-manager.js +60 -15
- package/dist/cli/config/config-manager.js.map +1 -1
- package/dist/cli/config/types.d.ts +16 -4
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js.map +1 -1
- package/dist/gateways/slack.d.ts.map +1 -1
- package/dist/gateways/slack.js +0 -10
- package/dist/gateways/slack.js.map +1 -1
- package/dist/multi-agent/agent-process-manager.d.ts +3 -1
- package/dist/multi-agent/agent-process-manager.d.ts.map +1 -1
- package/dist/multi-agent/agent-process-manager.js +21 -12
- package/dist/multi-agent/agent-process-manager.js.map +1 -1
- package/dist/multi-agent/background-task-manager.d.ts +2 -2
- package/dist/multi-agent/background-task-manager.js +2 -2
- package/dist/multi-agent/council-engine.d.ts +60 -0
- package/dist/multi-agent/council-engine.d.ts.map +1 -0
- package/dist/multi-agent/council-engine.js +284 -0
- package/dist/multi-agent/council-engine.js.map +1 -0
- package/dist/multi-agent/multi-agent-base.d.ts +17 -9
- package/dist/multi-agent/multi-agent-base.d.ts.map +1 -1
- package/dist/multi-agent/multi-agent-base.js +109 -30
- package/dist/multi-agent/multi-agent-base.js.map +1 -1
- package/dist/multi-agent/multi-agent-discord.d.ts +3 -35
- package/dist/multi-agent/multi-agent-discord.d.ts.map +1 -1
- package/dist/multi-agent/multi-agent-discord.js +57 -300
- package/dist/multi-agent/multi-agent-discord.js.map +1 -1
- package/dist/multi-agent/multi-agent-slack.d.ts +0 -25
- package/dist/multi-agent/multi-agent-slack.d.ts.map +1 -1
- package/dist/multi-agent/multi-agent-slack.js +95 -234
- package/dist/multi-agent/multi-agent-slack.js.map +1 -1
- package/dist/multi-agent/shared-context.d.ts.map +1 -1
- package/dist/multi-agent/shared-context.js +4 -4
- package/dist/multi-agent/shared-context.js.map +1 -1
- package/dist/multi-agent/system-reminder.d.ts +1 -1
- package/dist/multi-agent/system-reminder.js +1 -1
- package/dist/multi-agent/types.d.ts +11 -15
- package/dist/multi-agent/types.d.ts.map +1 -1
- package/dist/multi-agent/types.js +1 -3
- package/dist/multi-agent/types.js.map +1 -1
- package/dist/multi-agent/ultrawork-state.d.ts +57 -0
- package/dist/multi-agent/ultrawork-state.d.ts.map +1 -0
- package/dist/multi-agent/ultrawork-state.js +191 -0
- package/dist/multi-agent/ultrawork-state.js.map +1 -0
- package/dist/multi-agent/ultrawork.d.ts +37 -19
- package/dist/multi-agent/ultrawork.d.ts.map +1 -1
- package/dist/multi-agent/ultrawork.js +587 -41
- package/dist/multi-agent/ultrawork.js.map +1 -1
- package/dist/multi-agent/workflow-engine.d.ts.map +1 -1
- package/dist/multi-agent/workflow-engine.js +39 -14
- package/dist/multi-agent/workflow-engine.js.map +1 -1
- package/dist/multi-agent/workflow-types.d.ts +69 -0
- package/dist/multi-agent/workflow-types.d.ts.map +1 -1
- package/dist/onboarding/complete-autonomous-prompt.d.ts +1 -1
- package/dist/onboarding/complete-autonomous-prompt.d.ts.map +1 -1
- package/dist/onboarding/complete-autonomous-prompt.js +27 -10
- package/dist/onboarding/complete-autonomous-prompt.js.map +1 -1
- package/dist/onboarding/phase-7-integrations.d.ts.map +1 -1
- package/dist/onboarding/phase-7-integrations.js +23 -3
- package/dist/onboarding/phase-7-integrations.js.map +1 -1
- package/dist/onboarding/phase-9-finalization.d.ts.map +1 -1
- package/dist/onboarding/phase-9-finalization.js +33 -0
- package/dist/onboarding/phase-9-finalization.js.map +1 -1
- package/package.json +1 -1
- package/templates/personas/architect.md +70 -0
- package/templates/personas/conductor.md +302 -0
- package/templates/personas/developer.md +20 -7
- package/templates/personas/pm.md +49 -33
- package/templates/personas/reviewer.md +18 -5
- package/dist/multi-agent/pr-review-poller.d.ts +0 -197
- package/dist/multi-agent/pr-review-poller.d.ts.map +0 -1
- package/dist/multi-agent/pr-review-poller.js +0 -972
- package/dist/multi-agent/pr-review-poller.js.map +0 -1
- package/templates/personas/sisyphus-builtin-en.md +0 -161
- package/templates/personas/sisyphus.md +0 -218
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Council Engine
|
|
4
|
+
*
|
|
5
|
+
* Parses council_plan blocks from Conductor responses,
|
|
6
|
+
* validates agent availability, and executes multi-round
|
|
7
|
+
* discussions among existing named agents.
|
|
8
|
+
*
|
|
9
|
+
* Unlike WorkflowEngine (ephemeral agents, DAG execution),
|
|
10
|
+
* CouncilEngine reuses existing agents and runs sequential rounds
|
|
11
|
+
* with full history accumulation.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.CouncilEngine = void 0;
|
|
15
|
+
const events_1 = require("events");
|
|
16
|
+
const crypto_1 = require("crypto");
|
|
17
|
+
const DEFAULT_MAX_ROUNDS = 5;
|
|
18
|
+
const DEFAULT_MAX_DURATION_MS = 10 * 60 * 1000; // 10 minutes
|
|
19
|
+
const DEFAULT_ROUND_TIMEOUT_MS = 2 * 60 * 1000; // 2 minutes per agent per round
|
|
20
|
+
/**
|
|
21
|
+
* CouncilEngine
|
|
22
|
+
*
|
|
23
|
+
* Events:
|
|
24
|
+
* - 'progress': CouncilProgressEvent
|
|
25
|
+
*/
|
|
26
|
+
class CouncilEngine extends events_1.EventEmitter {
|
|
27
|
+
config;
|
|
28
|
+
activeExecutions = new Map();
|
|
29
|
+
constructor(config) {
|
|
30
|
+
super();
|
|
31
|
+
this.config = config;
|
|
32
|
+
}
|
|
33
|
+
isEnabled() {
|
|
34
|
+
return this.config.enabled;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parse a council_plan JSON block from Conductor's response.
|
|
38
|
+
*/
|
|
39
|
+
parseCouncilPlan(response) {
|
|
40
|
+
const match = response.match(/```council_plan\s*\n([\s\S]*?)\n```/);
|
|
41
|
+
if (!match) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const plan = JSON.parse(match[1].trim());
|
|
46
|
+
if (typeof plan.name !== 'string' ||
|
|
47
|
+
!plan.name.trim() ||
|
|
48
|
+
typeof plan.topic !== 'string' ||
|
|
49
|
+
!plan.topic.trim() ||
|
|
50
|
+
!Array.isArray(plan.agents) ||
|
|
51
|
+
plan.agents.length === 0 ||
|
|
52
|
+
typeof plan.rounds !== 'number' ||
|
|
53
|
+
plan.rounds < 1) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
// Validate agent IDs are strings
|
|
57
|
+
if (!plan.agents.every((a) => typeof a === 'string' && a.trim().length > 0)) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return plan;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Extract text content outside the council_plan block.
|
|
68
|
+
*/
|
|
69
|
+
extractNonPlanContent(response) {
|
|
70
|
+
return response.replace(/```council_plan\s*\n[\s\S]*?\n```/, '').trim();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Validate plan against available agents and config limits.
|
|
74
|
+
* Returns error message or null if valid.
|
|
75
|
+
*/
|
|
76
|
+
validatePlan(plan, availableAgentIds) {
|
|
77
|
+
const maxRounds = this.config.max_rounds ?? DEFAULT_MAX_ROUNDS;
|
|
78
|
+
if (plan.rounds > maxRounds) {
|
|
79
|
+
return `Too many rounds (${plan.rounds}), max is ${maxRounds}`;
|
|
80
|
+
}
|
|
81
|
+
if (plan.rounds < 1) {
|
|
82
|
+
return 'Rounds must be at least 1';
|
|
83
|
+
}
|
|
84
|
+
const available = new Set(availableAgentIds);
|
|
85
|
+
const missing = plan.agents.filter((id) => !available.has(id));
|
|
86
|
+
if (missing.length > 0) {
|
|
87
|
+
return `Unknown agent(s): ${missing.join(', ')}`;
|
|
88
|
+
}
|
|
89
|
+
if (plan.agents.length < 2) {
|
|
90
|
+
return 'Council requires at least 2 agents';
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Execute a council discussion plan.
|
|
96
|
+
*/
|
|
97
|
+
async execute(plan, executeStep, agentDisplayNames) {
|
|
98
|
+
const executionId = (0, crypto_1.randomUUID)();
|
|
99
|
+
const executionState = { cancelled: false };
|
|
100
|
+
this.activeExecutions.set(executionId, executionState);
|
|
101
|
+
const maxDuration = plan.timeout_ms ?? this.config.max_duration_ms ?? DEFAULT_MAX_DURATION_MS;
|
|
102
|
+
const execution = {
|
|
103
|
+
id: executionId,
|
|
104
|
+
planName: plan.name,
|
|
105
|
+
topic: plan.topic,
|
|
106
|
+
startedAt: Date.now(),
|
|
107
|
+
status: 'running',
|
|
108
|
+
rounds: [],
|
|
109
|
+
};
|
|
110
|
+
const allResults = [];
|
|
111
|
+
const globalTimeout = setTimeout(() => {
|
|
112
|
+
executionState.cancelled = true;
|
|
113
|
+
}, maxDuration);
|
|
114
|
+
try {
|
|
115
|
+
for (let round = 1; round <= plan.rounds; round++) {
|
|
116
|
+
if (executionState.cancelled) {
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
for (const agentId of plan.agents) {
|
|
120
|
+
if (executionState.cancelled) {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
const displayName = agentDisplayNames.get(agentId) ?? agentId;
|
|
124
|
+
this.emitProgress({
|
|
125
|
+
type: 'council-round-started',
|
|
126
|
+
executionId,
|
|
127
|
+
round,
|
|
128
|
+
agentId,
|
|
129
|
+
agentDisplayName: displayName,
|
|
130
|
+
});
|
|
131
|
+
const prompt = this.buildRoundPrompt(plan.topic, allResults, round, agentId, displayName);
|
|
132
|
+
const start = Date.now();
|
|
133
|
+
try {
|
|
134
|
+
const response = await executeStep(agentId, prompt, DEFAULT_ROUND_TIMEOUT_MS);
|
|
135
|
+
const duration_ms = Date.now() - start;
|
|
136
|
+
const roundResult = {
|
|
137
|
+
round,
|
|
138
|
+
agentId,
|
|
139
|
+
agentDisplayName: displayName,
|
|
140
|
+
response,
|
|
141
|
+
duration_ms,
|
|
142
|
+
status: 'success',
|
|
143
|
+
};
|
|
144
|
+
allResults.push(roundResult);
|
|
145
|
+
execution.rounds.push(roundResult);
|
|
146
|
+
this.emitProgress({
|
|
147
|
+
type: 'council-round-completed',
|
|
148
|
+
executionId,
|
|
149
|
+
round,
|
|
150
|
+
agentId,
|
|
151
|
+
agentDisplayName: displayName,
|
|
152
|
+
response: response.substring(0, 500),
|
|
153
|
+
duration_ms,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
const duration_ms = Date.now() - start;
|
|
158
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
159
|
+
const roundResult = {
|
|
160
|
+
round,
|
|
161
|
+
agentId,
|
|
162
|
+
agentDisplayName: displayName,
|
|
163
|
+
response: '',
|
|
164
|
+
duration_ms,
|
|
165
|
+
status: errorMsg.includes('timeout') ? 'timeout' : 'failed',
|
|
166
|
+
error: errorMsg,
|
|
167
|
+
};
|
|
168
|
+
allResults.push(roundResult);
|
|
169
|
+
execution.rounds.push(roundResult);
|
|
170
|
+
this.emitProgress({
|
|
171
|
+
type: 'council-round-failed',
|
|
172
|
+
executionId,
|
|
173
|
+
round,
|
|
174
|
+
agentId,
|
|
175
|
+
agentDisplayName: displayName,
|
|
176
|
+
error: errorMsg,
|
|
177
|
+
duration_ms,
|
|
178
|
+
});
|
|
179
|
+
// Council continues even if an agent fails
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (executionState.cancelled && execution.status === 'running') {
|
|
184
|
+
execution.status = 'cancelled';
|
|
185
|
+
}
|
|
186
|
+
else if (execution.status === 'running') {
|
|
187
|
+
execution.status = 'completed';
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
finally {
|
|
191
|
+
clearTimeout(globalTimeout);
|
|
192
|
+
this.activeExecutions.delete(executionId);
|
|
193
|
+
}
|
|
194
|
+
execution.completedAt = Date.now();
|
|
195
|
+
const result = this.buildFinalResult(plan, execution);
|
|
196
|
+
this.emitProgress({
|
|
197
|
+
type: 'council-completed',
|
|
198
|
+
executionId,
|
|
199
|
+
summary: result,
|
|
200
|
+
duration_ms: execution.completedAt - execution.startedAt,
|
|
201
|
+
});
|
|
202
|
+
return { result, execution };
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Cancel a running council execution.
|
|
206
|
+
*/
|
|
207
|
+
cancel(executionId) {
|
|
208
|
+
const state = this.activeExecutions.get(executionId);
|
|
209
|
+
if (state) {
|
|
210
|
+
state.cancelled = true;
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Build prompt for a specific round + agent, including all previous responses.
|
|
217
|
+
*/
|
|
218
|
+
buildRoundPrompt(topic, previousResults, currentRound, currentAgentId, currentDisplayName) {
|
|
219
|
+
const parts = [];
|
|
220
|
+
parts.push(`## Council Discussion: ${topic}`);
|
|
221
|
+
parts.push(`You are **${currentDisplayName}** participating in Round ${currentRound} of a council discussion.`);
|
|
222
|
+
parts.push(`Topic: ${topic}`);
|
|
223
|
+
parts.push('');
|
|
224
|
+
if (previousResults.length > 0) {
|
|
225
|
+
parts.push('### Previous Responses');
|
|
226
|
+
for (const r of previousResults) {
|
|
227
|
+
if (r.status === 'success') {
|
|
228
|
+
const marker = r.agentId === currentAgentId ? ' (you)' : '';
|
|
229
|
+
parts.push(`**${r.agentDisplayName}${marker}** (Round ${r.round}):`);
|
|
230
|
+
parts.push(r.response);
|
|
231
|
+
parts.push('');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
parts.push(`### Your Turn (Round ${currentRound})`);
|
|
236
|
+
if (currentRound === 1) {
|
|
237
|
+
parts.push('Share your perspective on the topic. Be specific and provide reasoning.');
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
parts.push('Consider what others have said, then share your updated perspective. You may agree, disagree, or build on previous points.');
|
|
241
|
+
}
|
|
242
|
+
return parts.join('\n');
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Build final combined result from all rounds.
|
|
246
|
+
*/
|
|
247
|
+
buildFinalResult(plan, execution) {
|
|
248
|
+
if (execution.status === 'cancelled') {
|
|
249
|
+
return `Council "${plan.name}" was cancelled.`;
|
|
250
|
+
}
|
|
251
|
+
const parts = [];
|
|
252
|
+
const totalMs = execution.completedAt
|
|
253
|
+
? execution.completedAt - execution.startedAt
|
|
254
|
+
: Date.now() - execution.startedAt;
|
|
255
|
+
const totalSec = Math.round(totalMs / 1000);
|
|
256
|
+
parts.push(`## Council: ${plan.name} (${totalSec}s)`);
|
|
257
|
+
parts.push(`**Topic:** ${plan.topic}`);
|
|
258
|
+
parts.push('');
|
|
259
|
+
// Group by round
|
|
260
|
+
for (let round = 1; round <= plan.rounds; round++) {
|
|
261
|
+
const roundResults = execution.rounds.filter((r) => r.round === round);
|
|
262
|
+
if (roundResults.length === 0) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
parts.push(`### Round ${round}`);
|
|
266
|
+
for (const r of roundResults) {
|
|
267
|
+
if (r.status === 'success') {
|
|
268
|
+
parts.push(`**${r.agentDisplayName}:**`);
|
|
269
|
+
parts.push(r.response);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
parts.push(`**${r.agentDisplayName}:** ❌ ${r.status}: ${r.error}`);
|
|
273
|
+
}
|
|
274
|
+
parts.push('');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return parts.join('\n');
|
|
278
|
+
}
|
|
279
|
+
emitProgress(event) {
|
|
280
|
+
this.emit('progress', event);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.CouncilEngine = CouncilEngine;
|
|
284
|
+
//# sourceMappingURL=council-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"council-engine.js","sourceRoot":"","sources":["../../src/multi-agent/council-engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,mCAAsC;AACtC,mCAAoC;AASpC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAC7D,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,gCAAgC;AAQhF;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,qBAAY;IACrC,MAAM,CAAgB;IACtB,gBAAgB,GAAG,IAAI,GAAG,EAAkC,CAAC;IAErE,YAAY,MAAqB;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,QAAgB;QAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACpE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAgB,CAAC;YAExD,IACE,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAC7B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBACjB,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;gBAC9B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;gBAClB,CAAC,KAAK,CAAC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AC,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEf,iBAAiB;QACjB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YAClD,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;YACvE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9B,SAAS;YACX,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,EAAE,CAAC,CAAC;YACjC,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;gBAC7B,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB,KAAK,CAAC,CAAC;oBACzC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;gBACzB,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,gBAAgB,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;gBACrE,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,YAAY,CAAC,KAA2B;QAC9C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF;AAvTD,sCAuTC"}
|
|
@@ -15,11 +15,11 @@ import { AgentMessageQueue } from './agent-message-queue.js';
|
|
|
15
15
|
import { BackgroundTaskManager } from './background-task-manager.js';
|
|
16
16
|
import { SystemReminderService } from './system-reminder.js';
|
|
17
17
|
import { DelegationManager } from './delegation-manager.js';
|
|
18
|
-
import { PRReviewPoller } from './pr-review-poller.js';
|
|
19
18
|
import { WorkTracker } from './work-tracker.js';
|
|
20
19
|
import type { GatewayToolExecutor } from '../agent/gateway-tool-executor.js';
|
|
21
20
|
import { WorkflowEngine } from './workflow-engine.js';
|
|
22
|
-
import
|
|
21
|
+
import { CouncilEngine } from './council-engine.js';
|
|
22
|
+
import type { WorkflowProgressEvent, CouncilProgressEvent } from './workflow-types.js';
|
|
23
23
|
/** Default timeout for agent responses (15 minutes -- must accommodate sub-agent spawns) */
|
|
24
24
|
export declare const AGENT_TIMEOUT_MS: number;
|
|
25
25
|
/**
|
|
@@ -72,13 +72,13 @@ export declare abstract class MultiAgentHandlerBase {
|
|
|
72
72
|
protected processManager: AgentProcessManager;
|
|
73
73
|
protected sharedContext: SharedContextManager;
|
|
74
74
|
protected messageQueue: AgentMessageQueue;
|
|
75
|
-
protected prReviewPoller: PRReviewPoller;
|
|
76
75
|
protected backgroundTaskManager: BackgroundTaskManager;
|
|
77
76
|
protected systemReminder: SystemReminderService;
|
|
78
77
|
protected delegationManager: DelegationManager;
|
|
79
78
|
protected workTracker: WorkTracker;
|
|
80
79
|
protected gatewayToolExecutor: GatewayToolExecutor | null;
|
|
81
|
-
protected workflowEngine: WorkflowEngine
|
|
80
|
+
protected workflowEngine: WorkflowEngine;
|
|
81
|
+
protected councilEngine: CouncilEngine;
|
|
82
82
|
/** Whether multi-bot mode is initialized */
|
|
83
83
|
protected multiBotInitialized: boolean;
|
|
84
84
|
/** Dedup map for delegation mentions with timestamps (prevents double processing) */
|
|
@@ -139,10 +139,6 @@ export declare abstract class MultiAgentHandlerBase {
|
|
|
139
139
|
getSharedContext(): SharedContextManager;
|
|
140
140
|
getBackgroundTaskManager(): BackgroundTaskManager;
|
|
141
141
|
getSystemReminder(): SystemReminderService;
|
|
142
|
-
/**
|
|
143
|
-
* Get PR Review Poller instance
|
|
144
|
-
*/
|
|
145
|
-
getPRReviewPoller(): PRReviewPoller;
|
|
146
142
|
/**
|
|
147
143
|
* Get work tracker instance
|
|
148
144
|
*/
|
|
@@ -177,7 +173,7 @@ export declare abstract class MultiAgentHandlerBase {
|
|
|
177
173
|
/**
|
|
178
174
|
* Get workflow engine instance
|
|
179
175
|
*/
|
|
180
|
-
getWorkflowEngine(): WorkflowEngine
|
|
176
|
+
getWorkflowEngine(): WorkflowEngine;
|
|
181
177
|
/**
|
|
182
178
|
* Check if a Conductor response contains a workflow plan and execute it.
|
|
183
179
|
* Returns the workflow result or null if no plan was found.
|
|
@@ -186,6 +182,18 @@ export declare abstract class MultiAgentHandlerBase {
|
|
|
186
182
|
result: string;
|
|
187
183
|
directMessage: string;
|
|
188
184
|
} | null>;
|
|
185
|
+
/**
|
|
186
|
+
* Get council engine instance
|
|
187
|
+
*/
|
|
188
|
+
getCouncilEngine(): CouncilEngine;
|
|
189
|
+
/**
|
|
190
|
+
* Check if a Conductor response contains a council_plan and execute it.
|
|
191
|
+
* Returns the council result or null if no plan was found.
|
|
192
|
+
*/
|
|
193
|
+
tryExecuteCouncil(conductorResponse: string, channelId: string, source: 'discord' | 'slack', onProgress?: (event: CouncilProgressEvent) => void): Promise<{
|
|
194
|
+
result: string;
|
|
195
|
+
directMessage: string;
|
|
196
|
+
} | null>;
|
|
189
197
|
/**
|
|
190
198
|
* Format ephemeral agent response with workflow prefix
|
|
191
199
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-agent-base.d.ts","sourceRoot":"","sources":["../../src/multi-agent/multi-agent-base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,wBAAwB,EACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;A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GAAG,IAAI,CAAC;IAkG5D;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;;OAGG;IACG,iBAAiB,CACrB,iBAAiB,EAAE,MAAM,EACzB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,SAAS,GAAG,OAAO,EAC3B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GACjD,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAwG5D;;OAEG;IACH,SAAS,CAAC,4BAA4B,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAIzF;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU;IAI5C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAK/B"}
|
|
@@ -16,10 +16,10 @@ const agent_message_queue_js_1 = require("./agent-message-queue.js");
|
|
|
16
16
|
const background_task_manager_js_1 = require("./background-task-manager.js");
|
|
17
17
|
const system_reminder_js_1 = require("./system-reminder.js");
|
|
18
18
|
const delegation_manager_js_1 = require("./delegation-manager.js");
|
|
19
|
-
const pr_review_poller_js_1 = require("./pr-review-poller.js");
|
|
20
19
|
const work_tracker_js_1 = require("./work-tracker.js");
|
|
21
20
|
const log_sanitizer_js_1 = require("../utils/log-sanitizer.js");
|
|
22
21
|
const workflow_engine_js_1 = require("./workflow-engine.js");
|
|
22
|
+
const council_engine_js_1 = require("./council-engine.js");
|
|
23
23
|
/** Default timeout for agent responses (15 minutes -- must accommodate sub-agent spawns) */
|
|
24
24
|
exports.AGENT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
25
25
|
/**
|
|
@@ -38,13 +38,13 @@ class MultiAgentHandlerBase {
|
|
|
38
38
|
processManager;
|
|
39
39
|
sharedContext;
|
|
40
40
|
messageQueue;
|
|
41
|
-
prReviewPoller;
|
|
42
41
|
backgroundTaskManager;
|
|
43
42
|
systemReminder;
|
|
44
43
|
delegationManager;
|
|
45
44
|
workTracker;
|
|
46
45
|
gatewayToolExecutor = null;
|
|
47
|
-
workflowEngine
|
|
46
|
+
workflowEngine;
|
|
47
|
+
councilEngine;
|
|
48
48
|
/** Whether multi-bot mode is initialized */
|
|
49
49
|
multiBotInitialized = false;
|
|
50
50
|
/** Dedup map for delegation mentions with timestamps (prevents double processing) */
|
|
@@ -57,14 +57,12 @@ class MultiAgentHandlerBase {
|
|
|
57
57
|
this.processManager = new agent_process_manager_js_1.AgentProcessManager(config, processOptions, runtimeOptions);
|
|
58
58
|
this.sharedContext = (0, shared_context_js_1.getSharedContextManager)();
|
|
59
59
|
this.messageQueue = new agent_message_queue_js_1.AgentMessageQueue();
|
|
60
|
-
this.prReviewPoller = new pr_review_poller_js_1.PRReviewPoller();
|
|
61
60
|
const agentConfigs = Object.entries(config.agents).map(([id, cfg]) => ({ id, ...cfg }));
|
|
62
61
|
this.delegationManager = new delegation_manager_js_1.DelegationManager(agentConfigs);
|
|
63
62
|
this.workTracker = new work_tracker_js_1.WorkTracker();
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
63
|
+
// Always initialize workflow engine (enabled by default)
|
|
64
|
+
this.workflowEngine = new workflow_engine_js_1.WorkflowEngine(config.workflow ?? { enabled: true });
|
|
65
|
+
this.councilEngine = new council_engine_js_1.CouncilEngine(config.council ?? { enabled: true });
|
|
68
66
|
this.backgroundTaskManager = new background_task_manager_js_1.BackgroundTaskManager(async (agentId, prompt) => {
|
|
69
67
|
let process = null;
|
|
70
68
|
try {
|
|
@@ -260,12 +258,6 @@ class MultiAgentHandlerBase {
|
|
|
260
258
|
getSystemReminder() {
|
|
261
259
|
return this.systemReminder;
|
|
262
260
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Get PR Review Poller instance
|
|
265
|
-
*/
|
|
266
|
-
getPRReviewPoller() {
|
|
267
|
-
return this.prReviewPoller;
|
|
268
|
-
}
|
|
269
261
|
/**
|
|
270
262
|
* Get work tracker instance
|
|
271
263
|
*/
|
|
@@ -364,10 +356,10 @@ class MultiAgentHandlerBase {
|
|
|
364
356
|
}
|
|
365
357
|
const plan = this.workflowEngine.parseWorkflowPlan(conductorResponse);
|
|
366
358
|
if (!plan) {
|
|
367
|
-
const
|
|
368
|
-
|
|
359
|
+
const workflowPlanFence = '```workflow_plan';
|
|
360
|
+
const blockIdx = conductorResponse.toLowerCase().indexOf(workflowPlanFence);
|
|
361
|
+
if (blockIdx !== -1) {
|
|
369
362
|
this.logger.warn('[Workflow] Found workflow_plan block but failed to parse it');
|
|
370
|
-
const blockIdx = conductorResponse.search(/```workflow_plan/i);
|
|
371
363
|
this.logger.warn('[Workflow] Response snippet:', conductorResponse.substring(Math.max(0, blockIdx), Math.max(0, blockIdx) + 500));
|
|
372
364
|
}
|
|
373
365
|
return null;
|
|
@@ -380,14 +372,13 @@ class MultiAgentHandlerBase {
|
|
|
380
372
|
}
|
|
381
373
|
// Extract non-plan content as Conductor's direct message
|
|
382
374
|
const directMessage = this.workflowEngine.extractNonPlanContent(conductorResponse);
|
|
383
|
-
// Collect ephemeral agent
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
const progressHandler = onProgress
|
|
387
|
-
? (event) => onProgress(event)
|
|
388
|
-
: undefined;
|
|
375
|
+
// Collect ephemeral agent definitions for cleanup
|
|
376
|
+
const ephemeralAgents = plan.steps.map((s) => s.agent);
|
|
377
|
+
let progressHandler;
|
|
389
378
|
try {
|
|
390
|
-
|
|
379
|
+
progressHandler = onProgress
|
|
380
|
+
? (event) => onProgress(event)
|
|
381
|
+
: undefined;
|
|
391
382
|
if (progressHandler) {
|
|
392
383
|
this.workflowEngine.on('progress', progressHandler);
|
|
393
384
|
}
|
|
@@ -399,6 +390,12 @@ class MultiAgentHandlerBase {
|
|
|
399
390
|
const executeStep = async (agent, prompt, timeoutMs) => {
|
|
400
391
|
let process = null;
|
|
401
392
|
let timer;
|
|
393
|
+
const clearStepTimeout = () => {
|
|
394
|
+
if (timer) {
|
|
395
|
+
clearTimeout(timer);
|
|
396
|
+
timer = undefined;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
402
399
|
try {
|
|
403
400
|
process = await this.processManager.getProcess(source, channelId, agent.id);
|
|
404
401
|
const result = await Promise.race([
|
|
@@ -407,14 +404,12 @@ class MultiAgentHandlerBase {
|
|
|
407
404
|
timer = setTimeout(() => reject(new Error(`Step timeout (${timeoutMs}ms)`)), timeoutMs);
|
|
408
405
|
}),
|
|
409
406
|
]);
|
|
410
|
-
|
|
411
|
-
clearTimeout(timer);
|
|
407
|
+
clearStepTimeout();
|
|
412
408
|
const cleaned = await this.executeTextToolCalls(result.response);
|
|
413
409
|
return cleaned;
|
|
414
410
|
}
|
|
415
411
|
finally {
|
|
416
|
-
|
|
417
|
-
clearTimeout(timer);
|
|
412
|
+
clearStepTimeout();
|
|
418
413
|
if (process) {
|
|
419
414
|
this.processManager.releaseProcess(agent.id, process);
|
|
420
415
|
}
|
|
@@ -425,12 +420,97 @@ class MultiAgentHandlerBase {
|
|
|
425
420
|
}
|
|
426
421
|
finally {
|
|
427
422
|
// Cleanup: unregister ephemeral agents and remove progress listener
|
|
428
|
-
this.processManager.unregisterEphemeralAgents(
|
|
423
|
+
this.processManager.unregisterEphemeralAgents(ephemeralAgents);
|
|
429
424
|
if (progressHandler) {
|
|
430
425
|
this.workflowEngine.off('progress', progressHandler);
|
|
431
426
|
}
|
|
432
427
|
}
|
|
433
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Get council engine instance
|
|
431
|
+
*/
|
|
432
|
+
getCouncilEngine() {
|
|
433
|
+
return this.councilEngine;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Check if a Conductor response contains a council_plan and execute it.
|
|
437
|
+
* Returns the council result or null if no plan was found.
|
|
438
|
+
*/
|
|
439
|
+
async tryExecuteCouncil(conductorResponse, channelId, source, onProgress) {
|
|
440
|
+
if (!this.councilEngine?.isEnabled()) {
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
const plan = this.councilEngine.parseCouncilPlan(conductorResponse);
|
|
444
|
+
if (!plan) {
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
const enabledAgents = this.orchestrator.getEnabledAgents();
|
|
448
|
+
const availableIds = enabledAgents.map((a) => a.id);
|
|
449
|
+
const validationError = this.councilEngine.validatePlan(plan, availableIds);
|
|
450
|
+
if (validationError) {
|
|
451
|
+
this.logger.warn(`[Council] Plan validation failed: ${validationError}`);
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
this.logger.info(`[Council] Parsed plan: "${plan.name}" topic="${plan.topic}" agents=[${plan.agents.join(',')}] rounds=${plan.rounds}`);
|
|
455
|
+
const directMessage = this.councilEngine.extractNonPlanContent(conductorResponse);
|
|
456
|
+
// Build agent display name map
|
|
457
|
+
const agentDisplayNames = new Map();
|
|
458
|
+
for (const agent of enabledAgents) {
|
|
459
|
+
agentDisplayNames.set(agent.id, agent.display_name);
|
|
460
|
+
}
|
|
461
|
+
let progressHandler;
|
|
462
|
+
try {
|
|
463
|
+
progressHandler = onProgress ? (event) => onProgress(event) : undefined;
|
|
464
|
+
if (progressHandler) {
|
|
465
|
+
this.councilEngine.on('progress', progressHandler);
|
|
466
|
+
}
|
|
467
|
+
// Build step executor using existing named agents
|
|
468
|
+
const executeStep = async (agentId, prompt, timeoutMs) => {
|
|
469
|
+
let process = null;
|
|
470
|
+
let timer;
|
|
471
|
+
const clearStepTimeout = () => {
|
|
472
|
+
if (timer) {
|
|
473
|
+
clearTimeout(timer);
|
|
474
|
+
timer = undefined;
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
try {
|
|
478
|
+
process = await this.processManager.getProcess(source, channelId, agentId);
|
|
479
|
+
const result = await Promise.race([
|
|
480
|
+
process.sendMessage(prompt),
|
|
481
|
+
new Promise((_, reject) => {
|
|
482
|
+
timer = setTimeout(() => reject(new Error(`Council agent timeout (${timeoutMs}ms)`)), timeoutMs);
|
|
483
|
+
}),
|
|
484
|
+
]);
|
|
485
|
+
clearStepTimeout();
|
|
486
|
+
const cleaned = await this.executeTextToolCalls(result.response);
|
|
487
|
+
return cleaned;
|
|
488
|
+
}
|
|
489
|
+
finally {
|
|
490
|
+
clearStepTimeout();
|
|
491
|
+
if (process) {
|
|
492
|
+
this.processManager.releaseProcess(agentId, process);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
const { result, execution } = await this.councilEngine.execute(plan, executeStep, agentDisplayNames);
|
|
497
|
+
// Record council round results into SharedContext for future agent reference
|
|
498
|
+
for (const round of execution.rounds) {
|
|
499
|
+
if (round.status === 'success' && round.response) {
|
|
500
|
+
const agent = enabledAgents.find((a) => a.id === round.agentId);
|
|
501
|
+
if (agent) {
|
|
502
|
+
this.sharedContext.recordAgentMessage(channelId, agent, `[Council: ${plan.name}] ${round.response}`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return { result, directMessage };
|
|
507
|
+
}
|
|
508
|
+
finally {
|
|
509
|
+
if (progressHandler) {
|
|
510
|
+
this.councilEngine.off('progress', progressHandler);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
434
514
|
/**
|
|
435
515
|
* Format ephemeral agent response with workflow prefix
|
|
436
516
|
*/
|
|
@@ -449,7 +529,6 @@ class MultiAgentHandlerBase {
|
|
|
449
529
|
async stopAll() {
|
|
450
530
|
this.backgroundTaskManager.destroy();
|
|
451
531
|
this.processManager.stopAll();
|
|
452
|
-
this.prReviewPoller.stopAll();
|
|
453
532
|
await this.platformCleanup();
|
|
454
533
|
}
|
|
455
534
|
}
|