opencode-orchestra 0.0.0-stage → 1.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/README.md +49 -2
- package/dist/board.d.ts +47 -0
- package/dist/board.js +89 -0
- package/dist/context.d.ts +22 -0
- package/dist/context.js +120 -0
- package/dist/dispatch.d.ts +24 -0
- package/dist/dispatch.js +49 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +591 -0
- package/dist/parser.d.ts +63 -0
- package/dist/parser.js +411 -0
- package/dist/pipeline.d.ts +74 -0
- package/dist/pipeline.js +188 -0
- package/dist/prompts.d.ts +7 -0
- package/dist/prompts.js +175 -0
- package/dist/session-registry.d.ts +77 -0
- package/dist/session-registry.js +200 -0
- package/dist/swarm.d.ts +61 -0
- package/dist/swarm.js +369 -0
- package/dist/teamwork.d.ts +45 -0
- package/dist/teamwork.js +545 -0
- package/dist/tui.d.ts +3 -0
- package/dist/tui.js +169 -0
- package/dist/verify.d.ts +24 -0
- package/dist/verify.js +117 -0
- package/package.json +34 -3
package/dist/swarm.js
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { postToBoard, readBoard, } from "./board.js";
|
|
2
|
+
import { extractConversationContext, mergeAdditionalContext, } from "./context.js";
|
|
3
|
+
import { heuristicClassifySwarm, parseSwarmClassifierDecision, parseSwarmSlices, } from "./parser.js";
|
|
4
|
+
import { runIsolatedWorker, throwIfAborted, } from "./pipeline.js";
|
|
5
|
+
export function buildSwarmClassifyPrompt(task) {
|
|
6
|
+
return [
|
|
7
|
+
"Classify the following task into exactly one Swarm orchestration mode:",
|
|
8
|
+
"- `fanout`: single-stage parallel Swarm Orchestrator (partition task across parallel workers and synthesize).",
|
|
9
|
+
"- `pipeline`: multi-stage Pipeline Conductor (Stage 1 parallel Generate/Explore -> Stage 2 parallel Critique/Verify -> Stage 3 Synthesis).",
|
|
10
|
+
"",
|
|
11
|
+
"Reply with ONLY one word: `fanout` or `pipeline`.",
|
|
12
|
+
"",
|
|
13
|
+
`<task>\n${task}\n</task>`,
|
|
14
|
+
].join("\n");
|
|
15
|
+
}
|
|
16
|
+
function renderSwarmContextBlock(additionalContext) {
|
|
17
|
+
const trimmed = additionalContext?.trim();
|
|
18
|
+
if (!trimmed)
|
|
19
|
+
return "";
|
|
20
|
+
return `\n\n<additional_context>\n${trimmed}\n</additional_context>`;
|
|
21
|
+
}
|
|
22
|
+
export function buildSwarmSlicePlannerPrompt(task, workerCount, additionalContext) {
|
|
23
|
+
return [
|
|
24
|
+
`Partition the following objective into exactly ${workerCount} distinct, non-overlapping focus slices for parallel Swarm Workers.`,
|
|
25
|
+
"Each slice should cover a clear aspect (e.g., subsystem, perspective, risk area, or verification angle).",
|
|
26
|
+
`Output ONLY a numbered list of ${workerCount} concise one-line slice descriptions.`,
|
|
27
|
+
"",
|
|
28
|
+
`<objective>\n${task}\n</objective>${renderSwarmContextBlock(additionalContext)}`,
|
|
29
|
+
].join("\n");
|
|
30
|
+
}
|
|
31
|
+
export function buildSwarmWorkerPrompt(task, workerId, slice, stageLabel, boardId, additionalContext) {
|
|
32
|
+
const boardSection = boardId
|
|
33
|
+
? `\n\n## Shared Message Board\nYou have access to \`swarm_board_head\`, \`swarm_board_read\`, \`swarm_wait_check\`, and \`swarm_board_post\` for \`boardId="${boardId}"\`.\n- Call \`swarm_board_head\` or \`swarm_board_read\` (with \`workerId="${workerId}"\`, optional \`channel\`) at the start/mid-run to check peer updates.\n- Post important discoveries, blockers, or handoffs via \`swarm_board_post\` (with \`author="${workerId}"\`, optional \`channel\`, and \`@worker-N\` mentions to tag peers).\n- Before finishing, call \`swarm_wait_check\` (with \`workerId="${workerId}"\`) to ensure no unread peer handoff was missed.`
|
|
34
|
+
: "";
|
|
35
|
+
return `You are **Swarm Worker (${workerId})** in stage **${stageLabel}**.
|
|
36
|
+
A Synthesizer agent will later review all workers' contributions and consolidate the best elements.
|
|
37
|
+
|
|
38
|
+
<objective>
|
|
39
|
+
${task}
|
|
40
|
+
</objective>${renderSwarmContextBlock(additionalContext)}
|
|
41
|
+
|
|
42
|
+
<assigned_slice>
|
|
43
|
+
${slice}
|
|
44
|
+
</assigned_slice>${boardSection}
|
|
45
|
+
|
|
46
|
+
## Rules
|
|
47
|
+
1. Focus deeply on your <assigned_slice> without duplicating unrelated areas.
|
|
48
|
+
2. Ground every claim in actual workspace files, line numbers, symbols, or command output.
|
|
49
|
+
3. Produce a crisp, self-contained report with:
|
|
50
|
+
- **Key Findings / Deliverables**
|
|
51
|
+
- **Evidence & Citations**
|
|
52
|
+
- **Risks / Open Questions for Synthesizer**`;
|
|
53
|
+
}
|
|
54
|
+
export function buildSwarmCritiqueWorkerPrompt(task, blackboard, stage1Outputs, additionalContext) {
|
|
55
|
+
return `You are the **Swarm Verification & Critique Worker** (Stage 2 of Pipeline Conductor).
|
|
56
|
+
Review the Stage 1 Swarm Blackboard and worker outputs below.
|
|
57
|
+
|
|
58
|
+
<objective>
|
|
59
|
+
${task}
|
|
60
|
+
</objective>${renderSwarmContextBlock(additionalContext)}
|
|
61
|
+
|
|
62
|
+
<swarm_blackboard>
|
|
63
|
+
${blackboard}
|
|
64
|
+
</swarm_blackboard>
|
|
65
|
+
|
|
66
|
+
<stage1_outputs>
|
|
67
|
+
${stage1Outputs}
|
|
68
|
+
</stage1_outputs>
|
|
69
|
+
|
|
70
|
+
## Rules
|
|
71
|
+
1. Cross-check claims across workers for contradictions, blind spots, or unverified assumptions.
|
|
72
|
+
2. Spot-check critical file paths, symbols, or behaviors directly in the workspace.
|
|
73
|
+
3. Report:
|
|
74
|
+
- **Verified Agreements**
|
|
75
|
+
- **Contradictions & Corrections**
|
|
76
|
+
- **Missing Coverage / Risks**`;
|
|
77
|
+
}
|
|
78
|
+
export function buildSwarmSentinelPrompt(task, blackboard, stage1Outputs, additionalContext) {
|
|
79
|
+
return `You are the **Swarm Sentinel & Gap Auditor** (Stage 2 of Pipeline Conductor).
|
|
80
|
+
Audit the Stage 1 worker outputs for silent omissions, unverified claims, and integration risks across slices.
|
|
81
|
+
|
|
82
|
+
<objective>
|
|
83
|
+
${task}
|
|
84
|
+
</objective>${renderSwarmContextBlock(additionalContext)}
|
|
85
|
+
|
|
86
|
+
<swarm_blackboard>
|
|
87
|
+
${blackboard}
|
|
88
|
+
</swarm_blackboard>
|
|
89
|
+
|
|
90
|
+
<stage1_outputs>
|
|
91
|
+
${stage1Outputs}
|
|
92
|
+
</stage1_outputs>
|
|
93
|
+
|
|
94
|
+
## Rules
|
|
95
|
+
1. Check whether every requirement in <objective> is covered across the union of slices.
|
|
96
|
+
2. Flag any unverified claim, failed worker coverage gap, or cross-slice conflict.
|
|
97
|
+
3. Provide a concise **Sentinel Audit** (Coverage Gaps, Risk Flags, Required Synthesizer Callouts).`;
|
|
98
|
+
}
|
|
99
|
+
export function buildSwarmSynthesizerPrompt(task, mode, blackboard, workerOutputs, critiqueReport, additionalContext) {
|
|
100
|
+
const critiqueSection = critiqueReport
|
|
101
|
+
? `\n\n<stage2_critique>\n${critiqueReport}\n</stage2_critique>`
|
|
102
|
+
: "";
|
|
103
|
+
return `You are the **Swarm Synthesizer** (${mode === "pipeline" ? "Pipeline Conductor" : "Swarm Orchestrator"}).
|
|
104
|
+
Consolidate all parallel workers' contributions into a single authoritative final response.
|
|
105
|
+
|
|
106
|
+
<objective>
|
|
107
|
+
${task}
|
|
108
|
+
</objective>${renderSwarmContextBlock(additionalContext)}
|
|
109
|
+
|
|
110
|
+
<swarm_blackboard>
|
|
111
|
+
${blackboard}
|
|
112
|
+
</swarm_blackboard>
|
|
113
|
+
|
|
114
|
+
<worker_outputs>
|
|
115
|
+
${workerOutputs}
|
|
116
|
+
</worker_outputs>${critiqueSection}
|
|
117
|
+
|
|
118
|
+
## Instructions
|
|
119
|
+
1. Synthesize the strongest, verified elements from every worker into a cohesive, non-redundant answer.
|
|
120
|
+
2. Resolve any contradictions explicitly (preferring evidence-backed findings).
|
|
121
|
+
3. If any worker failed (noted in the blackboard), acknowledge the coverage gap honestly.
|
|
122
|
+
4. End with a clear, actionable summary directly answering <objective>.`;
|
|
123
|
+
}
|
|
124
|
+
export function renderSwarmBlackboard(task, mode, records, stage2Status) {
|
|
125
|
+
const lines = [
|
|
126
|
+
`# Swarm Blackboard`,
|
|
127
|
+
"",
|
|
128
|
+
`- **Objective**: ${task}`,
|
|
129
|
+
`- **Orchestration**: \`${mode === "pipeline" ? "Pipeline Conductor" : "Swarm Orchestrator"}\``,
|
|
130
|
+
`- **Workers**: ${records.filter((r) => r.status === "completed").length}/${records.length} succeeded`,
|
|
131
|
+
"",
|
|
132
|
+
"## Worker Status",
|
|
133
|
+
...records.map((r) => `- **${r.id}** [\`${r.status}\`]: ${r.slice}${r.worktreeFallback ? " _(shared workspace fallback)_" : ""}${r.error ? ` — _Error: ${r.error}_` : ""}`),
|
|
134
|
+
];
|
|
135
|
+
if (stage2Status) {
|
|
136
|
+
lines.push("", "## Stage 2 (Critique / Verification)", `- ${stage2Status}`);
|
|
137
|
+
}
|
|
138
|
+
return lines.join("\n");
|
|
139
|
+
}
|
|
140
|
+
async function resolveSwarmMode(sessionClient, sessionID, task, requestedMode) {
|
|
141
|
+
if (requestedMode === "fanout" || requestedMode === "pipeline") {
|
|
142
|
+
return requestedMode;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const res = await sessionClient.generate({
|
|
146
|
+
sessionID,
|
|
147
|
+
prompt: buildSwarmClassifyPrompt(task),
|
|
148
|
+
});
|
|
149
|
+
return parseSwarmClassifierDecision(res.text, task);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return heuristicClassifySwarm(task);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async function planSwarmSlices(sessionClient, sessionID, task, workerCount, additionalContext) {
|
|
156
|
+
try {
|
|
157
|
+
const res = await sessionClient.generate({
|
|
158
|
+
sessionID,
|
|
159
|
+
prompt: buildSwarmSlicePlannerPrompt(task, workerCount, additionalContext),
|
|
160
|
+
});
|
|
161
|
+
return parseSwarmSlices(res.text, workerCount, task);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return parseSwarmSlices("", workerCount, task);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export async function runSwarmPipeline(sessionClient, options) {
|
|
168
|
+
const { sessionID, task, additionalContext, mode: requestedMode = "auto", workers = 3, useWorktree = false, projectID: explicitProjectID, storage, worktree, modelOverride, onProgress, signal, } = options;
|
|
169
|
+
const workerCount = Math.max(2, Math.min(6, Math.floor(workers)));
|
|
170
|
+
const childSessionIDs = [];
|
|
171
|
+
const boardId = `sw-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;
|
|
172
|
+
throwIfAborted(signal, "Swarm pipeline");
|
|
173
|
+
const parentContext = additionalContext?.trim()
|
|
174
|
+
? undefined
|
|
175
|
+
: await extractConversationContext(sessionClient, sessionID);
|
|
176
|
+
const effectiveContext = mergeAdditionalContext(additionalContext, parentContext);
|
|
177
|
+
await onProgress?.("Swarm Phase 1: Selecting orchestration mode & partitioning slices...");
|
|
178
|
+
const mode = await resolveSwarmMode(sessionClient, sessionID, task, requestedMode);
|
|
179
|
+
throwIfAborted(signal, "Swarm pipeline");
|
|
180
|
+
const slices = await planSwarmSlices(sessionClient, sessionID, task, workerCount, effectiveContext);
|
|
181
|
+
throwIfAborted(signal, "Swarm pipeline");
|
|
182
|
+
let seedSeq = 0;
|
|
183
|
+
if (storage) {
|
|
184
|
+
try {
|
|
185
|
+
const seedPost = await postToBoard(storage, boardId, {
|
|
186
|
+
author: "coordinator",
|
|
187
|
+
to: "all",
|
|
188
|
+
message: `Mission (${mode}): ${task}\nSlices:\n${slices.map((s, i) => `${i + 1}. worker-${i + 1}: ${s}`).join("\n")}`,
|
|
189
|
+
});
|
|
190
|
+
seedSeq = seedPost.seq;
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
// Non-fatal board seed error
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
let effectiveProjectID = explicitProjectID;
|
|
197
|
+
if (useWorktree && worktree && !effectiveProjectID && sessionClient.get) {
|
|
198
|
+
try {
|
|
199
|
+
const parent = await sessionClient.get({ sessionID });
|
|
200
|
+
effectiveProjectID = parent?.projectID;
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// Ignore if session.get fails
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const createdWorktrees = slices.map(() => undefined);
|
|
207
|
+
const worktreeFallbacks = slices.map(() => false);
|
|
208
|
+
let worktreesUsed = 0;
|
|
209
|
+
try {
|
|
210
|
+
if (useWorktree && worktree && effectiveProjectID) {
|
|
211
|
+
throwIfAborted(signal, "Swarm pipeline");
|
|
212
|
+
await onProgress?.(`Swarm Phase 1b: Provisioning ${workerCount} isolated git worktrees...`);
|
|
213
|
+
await Promise.all(slices.map(async (_, idx) => {
|
|
214
|
+
try {
|
|
215
|
+
const wt = await worktree.create({
|
|
216
|
+
projectID: effectiveProjectID,
|
|
217
|
+
name: `${boardId}-w${idx + 1}`,
|
|
218
|
+
});
|
|
219
|
+
createdWorktrees[idx] = { directory: wt.directory };
|
|
220
|
+
worktreesUsed++;
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
// Gracefully fall back to shared workspace if worktree creation fails
|
|
224
|
+
createdWorktrees[idx] = undefined;
|
|
225
|
+
worktreeFallbacks[idx] = true;
|
|
226
|
+
}
|
|
227
|
+
}));
|
|
228
|
+
throwIfAborted(signal, "Swarm pipeline");
|
|
229
|
+
}
|
|
230
|
+
else if (useWorktree) {
|
|
231
|
+
worktreeFallbacks.fill(true);
|
|
232
|
+
}
|
|
233
|
+
await onProgress?.(`Swarm Stage 1: Running ${workerCount} parallel Swarm Workers...`);
|
|
234
|
+
const settled = await Promise.allSettled(slices.map((slice, idx) => runIsolatedWorker(sessionClient, sessionID, `Swarm Worker #${idx + 1}`, buildSwarmWorkerPrompt(task, `worker-${idx + 1}`, slice, mode === "pipeline" ? "Stage 1 (Generate/Explore)" : "Parallel Fan-Out", storage ? boardId : undefined, effectiveContext), modelOverride, signal, createdWorktrees[idx], undefined, storage
|
|
235
|
+
? {
|
|
236
|
+
swarmWorker: {
|
|
237
|
+
boardId,
|
|
238
|
+
workerId: `worker-${idx + 1}`,
|
|
239
|
+
initialSeenSeq: seedSeq,
|
|
240
|
+
},
|
|
241
|
+
}
|
|
242
|
+
: undefined)));
|
|
243
|
+
throwIfAborted(signal, "Swarm pipeline");
|
|
244
|
+
const records = settled.map((res, idx) => {
|
|
245
|
+
const id = `worker-${idx + 1}`;
|
|
246
|
+
const slice = slices[idx];
|
|
247
|
+
const wtDir = createdWorktrees[idx]?.directory;
|
|
248
|
+
const wtFallback = worktreeFallbacks[idx];
|
|
249
|
+
if (res.status === "fulfilled") {
|
|
250
|
+
childSessionIDs.push(res.value.sessionID);
|
|
251
|
+
return {
|
|
252
|
+
id,
|
|
253
|
+
slice,
|
|
254
|
+
status: "completed",
|
|
255
|
+
sessionID: res.value.sessionID,
|
|
256
|
+
...(wtDir ? { worktreeDirectory: wtDir } : {}),
|
|
257
|
+
...(wtFallback ? { worktreeFallback: true } : {}),
|
|
258
|
+
output: res.value.text,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
id,
|
|
263
|
+
slice,
|
|
264
|
+
status: "failed",
|
|
265
|
+
...(wtDir ? { worktreeDirectory: wtDir } : {}),
|
|
266
|
+
...(wtFallback ? { worktreeFallback: true } : {}),
|
|
267
|
+
error: res.reason instanceof Error ? res.reason.message : String(res.reason),
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
const succeeded = records.filter((r) => r.status === "completed");
|
|
271
|
+
const failed = records.filter((r) => r.status === "failed");
|
|
272
|
+
if (succeeded.length === 0) {
|
|
273
|
+
throw new Error(`All ${workerCount} Swarm Workers failed: ${failed.map((f) => `${f.id}: ${f.error}`).join("; ")}`);
|
|
274
|
+
}
|
|
275
|
+
const workerOutputsText = succeeded
|
|
276
|
+
.map((r) => `<worker id="${r.id}" slice="${r.slice}">\n${r.output}\n</worker>`)
|
|
277
|
+
.join("\n\n");
|
|
278
|
+
let critiqueReport;
|
|
279
|
+
let stage2Status;
|
|
280
|
+
if (mode === "pipeline") {
|
|
281
|
+
const stage1Blackboard = renderSwarmBlackboard(task, mode, records);
|
|
282
|
+
await onProgress?.("Swarm Stage 2 (Pipeline Conductor): Running Verification & Critique + Sentinel Audit in parallel...");
|
|
283
|
+
const [critiqueSettled, sentinelSettled] = await Promise.allSettled([
|
|
284
|
+
runIsolatedWorker(sessionClient, sessionID, "Swarm Pipeline Critique", buildSwarmCritiqueWorkerPrompt(task, stage1Blackboard, workerOutputsText, effectiveContext), modelOverride, signal, undefined, undefined, { readOnly: true }),
|
|
285
|
+
runIsolatedWorker(sessionClient, sessionID, "Swarm Pipeline Sentinel", buildSwarmSentinelPrompt(task, stage1Blackboard, workerOutputsText, effectiveContext), modelOverride, signal, undefined, undefined, { readOnly: true }),
|
|
286
|
+
]);
|
|
287
|
+
if (signal?.aborted) {
|
|
288
|
+
throw new Error("Swarm pipeline aborted.");
|
|
289
|
+
}
|
|
290
|
+
const stage2Parts = [];
|
|
291
|
+
const stage2Labels = [];
|
|
292
|
+
if (critiqueSettled.status === "fulfilled") {
|
|
293
|
+
childSessionIDs.push(critiqueSettled.value.sessionID);
|
|
294
|
+
stage2Parts.push(`## Verification & Critique\n${critiqueSettled.value.text}`);
|
|
295
|
+
stage2Labels.push(`Critique (${critiqueSettled.value.sessionID})`);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
const msg = critiqueSettled.reason instanceof Error
|
|
299
|
+
? critiqueSettled.reason.message
|
|
300
|
+
: String(critiqueSettled.reason);
|
|
301
|
+
stage2Labels.push(`Critique failed: ${msg}`);
|
|
302
|
+
}
|
|
303
|
+
if (sentinelSettled.status === "fulfilled") {
|
|
304
|
+
childSessionIDs.push(sentinelSettled.value.sessionID);
|
|
305
|
+
stage2Parts.push(`## Sentinel & Gap Audit\n${sentinelSettled.value.text}`);
|
|
306
|
+
stage2Labels.push(`Sentinel (${sentinelSettled.value.sessionID})`);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
const msg = sentinelSettled.reason instanceof Error
|
|
310
|
+
? sentinelSettled.reason.message
|
|
311
|
+
: String(sentinelSettled.reason);
|
|
312
|
+
stage2Labels.push(`Sentinel failed: ${msg}`);
|
|
313
|
+
}
|
|
314
|
+
if (stage2Parts.length > 0) {
|
|
315
|
+
critiqueReport = stage2Parts.join("\n\n");
|
|
316
|
+
stage2Status = `Completed: ${stage2Labels.join(", ")}`;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
stage2Status = `Failed (continuing to Synthesizer): ${stage2Labels.join("; ")}`;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const finalBlackboard = renderSwarmBlackboard(task, mode, records, stage2Status);
|
|
323
|
+
let boardPostsCount = 0;
|
|
324
|
+
let boardLogSection = "";
|
|
325
|
+
if (storage) {
|
|
326
|
+
try {
|
|
327
|
+
const posts = await readBoard(storage, boardId, 0);
|
|
328
|
+
boardPostsCount = posts.length;
|
|
329
|
+
if (posts.length > 0) {
|
|
330
|
+
boardLogSection =
|
|
331
|
+
"\n\n<shared_board_log>\n" +
|
|
332
|
+
posts
|
|
333
|
+
.map((p) => `#${p.seq} [@${p.author}${p.to ? ` -> @${p.to}` : ""}]: ${p.message}`)
|
|
334
|
+
.join("\n") +
|
|
335
|
+
"\n</shared_board_log>";
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
// Non-fatal board read error
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
await onProgress?.("Swarm Final Stage: Consolidating results via Synthesizer...");
|
|
343
|
+
const synthRes = await runIsolatedWorker(sessionClient, sessionID, "Swarm Synthesizer", buildSwarmSynthesizerPrompt(task, mode, finalBlackboard, workerOutputsText + boardLogSection, critiqueReport, effectiveContext), modelOverride, signal, undefined, undefined, { readOnly: true });
|
|
344
|
+
childSessionIDs.push(synthRes.sessionID);
|
|
345
|
+
return {
|
|
346
|
+
boardId,
|
|
347
|
+
boardPostsCount,
|
|
348
|
+
worktreesUsed,
|
|
349
|
+
mode,
|
|
350
|
+
workerCount,
|
|
351
|
+
succeededWorkers: succeeded.length,
|
|
352
|
+
failedWorkers: failed.length,
|
|
353
|
+
childSessionIDs,
|
|
354
|
+
blackboard: finalBlackboard,
|
|
355
|
+
report: synthRes.text,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
finally {
|
|
359
|
+
if (worktree && effectiveProjectID && worktreesUsed > 0) {
|
|
360
|
+
await Promise.allSettled(createdWorktrees
|
|
361
|
+
.filter((wt) => Boolean(wt))
|
|
362
|
+
.map((wt) => worktree.remove({
|
|
363
|
+
projectID: effectiveProjectID,
|
|
364
|
+
directory: wt.directory,
|
|
365
|
+
force: true,
|
|
366
|
+
})));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type PluginStorage } from "./board.js";
|
|
2
|
+
import { type ModelRef, type ResolvedTeamworkMode, type TeamworkMode } from "./parser.js";
|
|
3
|
+
import { type BoostSessionClient } from "./pipeline.js";
|
|
4
|
+
export interface TeamworkPipelineOptions {
|
|
5
|
+
sessionID: string;
|
|
6
|
+
task: string;
|
|
7
|
+
additionalContext?: string;
|
|
8
|
+
mode?: TeamworkMode;
|
|
9
|
+
maxQaRounds?: number;
|
|
10
|
+
workers?: number;
|
|
11
|
+
scopingContext?: string;
|
|
12
|
+
storage?: PluginStorage;
|
|
13
|
+
modelOverride?: ModelRef;
|
|
14
|
+
onProgress?: (status: string) => void | Promise<void>;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
export interface TeamworkPipelineResult {
|
|
18
|
+
runId: string;
|
|
19
|
+
mode: ResolvedTeamworkMode;
|
|
20
|
+
qaRoundsExecuted: number;
|
|
21
|
+
childSessionIDs: string[];
|
|
22
|
+
report: string;
|
|
23
|
+
gateVerdict: "PASS" | "FAIL" | "N/A";
|
|
24
|
+
gateSummary: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function buildTeamworkClassifyPrompt(task: string): string;
|
|
27
|
+
export declare function buildTeamworkImplementerPrompt(task: string, contextBlocks?: string): string;
|
|
28
|
+
export declare function buildTeamworkReviewerPrompt(task: string, implementerReport: string, contextBlocks?: string): string;
|
|
29
|
+
export declare function buildTeamworkCriticPrompt(task: string, subjectReport: string, contextBlocks?: string): string;
|
|
30
|
+
export declare function buildTeamworkQaPrompt(task: string, implementerReport: string, reviewerReport: string, criticReport: string, round: number, contextBlocks?: string, openIssuesLedger?: readonly string[]): string;
|
|
31
|
+
export declare function buildTeamworkReviewTrackPrompt(task: string, role: "reviewer" | "critic", contextBlocks?: string): string;
|
|
32
|
+
export declare function buildTeamworkSynthesizerPrompt(task: string, reviewerReport: string, criticReport: string, contextBlocks?: string): string;
|
|
33
|
+
export declare function buildTeamworkColosseumWorkerPrompt(task: string, contenderIndex: number, totalContenders: number, contextBlocks?: string): string;
|
|
34
|
+
export declare function buildTeamworkColosseumVerifierPrompt(task: string, proposals: readonly {
|
|
35
|
+
label: string;
|
|
36
|
+
report: string;
|
|
37
|
+
}[], contextBlocks?: string): string;
|
|
38
|
+
export declare function buildTeamworkJudgePrompt(task: string, proposals: readonly {
|
|
39
|
+
label: string;
|
|
40
|
+
report: string;
|
|
41
|
+
}[], contextBlocks?: string, verifierReport?: string): string;
|
|
42
|
+
export declare function buildTeamworkDiscoveryWorkerPrompt(task: string, role: "explorer" | "empirical_challenger", contextBlocks?: string): string;
|
|
43
|
+
export declare function buildTeamworkKnowledgeCuratorPrompt(task: string, explorerReport: string, challengerReport: string, contextBlocks?: string): string;
|
|
44
|
+
export declare function buildTeamworkAuditWorkerPrompt(task: string, role: "forensic_auditor" | "victory_auditor", contextBlocks?: string): string;
|
|
45
|
+
export declare function runTeamworkPipeline(sessionClient: BoostSessionClient, options: TeamworkPipelineOptions): Promise<TeamworkPipelineResult>;
|