opencode-orchestra 1.0.0 → 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 CHANGED
@@ -1,27 +1,19 @@
1
1
  # opencode-orchestra
2
2
 
3
- Plugin OpenCode (`/boost`, `/teamwork`, `/swarm` slash commands + `boost`, `teamwork`, `swarm` tools) yang mereplikasi arsitektur multi-agen Antigravity (**Boost**, **Teamwork**, dan **Swarm**) secara **model-agnostic**—bekerja dengan model apa pun yang aktif di OpenCode (Claude, GPT, Gemini, DeepSeek, Qwen, Ollama, dll.).
3
+ Plugin OpenCode V2 (`@opencode/plugin`) yang menyediakan tiga *pipeline* orkestrasi multi-agen (`/boost`, `/teamwork`, `/swarm`) secara **model-agnostic**—mewarisi model aktif sesi OpenCode (atau *override* via `--model` / konfigurasi).
4
4
 
5
- ## Perintah & Arsitektur
5
+ ## Perintah
6
6
 
7
- 1. **`/boost`** (`DeepCoder` / `DeepInvestigator`):
8
- - **Layer 0 Worker** → **Adversarial Improvement Worker(s)** (dengan *adaptive early-stop* saat laporan sudah bersih) → **Independent Orchestrator Spot-Check** (+ targeted fix loop jika gate gagal).
9
- 2. **`/teamwork`** (Role-based multi-agent tracks, mendukung `--no-interview` / `[skip-interview]`):
10
- - `--swe` (**SWE Light**): `Implementer` → parallel `Gate Reviewer` + `Critic` → `QA` fix loop dengan *cumulative open-issues ledger* → final Gate.
11
- - `--review` (**Review Track**): parallel `Reviewer` + `Critic` → `Track Synthesizer` (read-only).
12
- - `--colosseum` (**Colosseum**): competing `Contenders` secara paralel → independent `Proof Verifier` → `Teamwork Judge`.
13
- - `--audit` (**Audit Track**): parallel security/correctness/edge-case auditors → `Audit Synthesizer` (read-only).
14
- - `--discover` (**Discover Track**): parallel discovery investigators → `Discovery Synthesizer` (read-only).
15
- 3. **`/swarm`** (Parallel fan-out & multi-stage pipeline):
16
- - `--fanout` (**Swarm Orchestrator**): slice planner → parallel `Swarm Workers` (`Promise.allSettled`) + multi-channel board (`@mention` routing & idle park-guard) → `Swarm Blackboard` → `Synthesizer`.
17
- - `--pipeline` (**Pipeline Conductor**): Stage 1 parallel workers → Stage 2 `Verification & Critique` → Stage 3 `Synthesizer` + `Swarm Blackboard`.
7
+ | Perintah | Tool | Ringkasan Alur |
8
+ | --- | --- | --- |
9
+ | `/boost` | `boost` | `DeepCoder` / `DeepInvestigator` (Worker L0) → *Adversarial Improvement Worker* (*adaptive early-stop*) → *Orchestrator Spot-Check* (+ perbaikan jika gagal). |
10
+ | `/teamwork` | `teamwork` | Orkestrasi berbasis peran (`--swe`, `--review`, `--colosseum`, `--audit`, `--discover`) dengan *scoping interview* opsional (`--no-interview` / `[skip-interview]`), gerbang verifikasi paralel, dan persistensi milestone. |
11
+ | `/swarm` | `swarm` | Eksekusi *worker* paralel (`--fanout` / `--pipeline`) dengan *shared message board* multi-channel (`@mention` & *idle park-guard*) dan isolasi *git worktree* opsional (`--worktree`). |
18
12
 
19
- ## Instalasi di OpenCode
20
-
21
- Pasang dari npm tanpa clone manual:
13
+ ## Instalasi
22
14
 
23
15
  ```sh
24
- opencode plugin add opencode-orchestra@latest
16
+ opencode plugin add opencode-orchestra@1.1.0
25
17
  ```
26
18
 
27
19
  Atau tambahkan ke `opencode.jsonc` proyek / `~/.config/opencode/opencode.jsonc`:
@@ -29,46 +21,30 @@ Atau tambahkan ke `opencode.jsonc` proyek / `~/.config/opencode/opencode.jsonc`:
29
21
  ```jsonc
30
22
  {
31
23
  "$schema": "https://opencode.ai/config.json",
32
- "plugins": ["opencode-orchestra@latest"]
24
+ "plugins": ["opencode-orchestra@1.1.0"]
33
25
  }
34
26
  ```
35
27
 
36
- Dengan opsi konfigurasi:
37
-
38
- ```jsonc
39
- {
40
- "$schema": "https://opencode.ai/config.json",
41
- "plugins": [
42
- {
43
- "package": "opencode-orchestra@latest",
44
- "options": {
45
- "defaultMode": "auto",
46
- "improvementRounds": 1,
47
- "maxExtraVerificationRounds": 1
48
- }
49
- }
50
- ]
51
- }
52
- ```
28
+ Gunakan `@latest` untuk mengikuti rilis terbaru (`opencode plugin update`). Cek status dengan `opencode plugin list` / `opencode plugin check`.
53
29
 
54
- `@latest` mengikuti rilis terbaru lewat `opencode plugin update`; gunakan nomor versi tetap (mis. `@1.0.0`) untuk mem-pin. Cek status dengan `opencode plugin list` / `opencode plugin check`.
55
-
56
- Untuk pengembangan lokal, clone repo lalu jalankan `bun install && bun run build`, dan arahkan config ke `"package": "./"` seperti di `opencode.jsonc` repo ini.
30
+ Untuk pengembangan lokal: `bun install && bun run build`, lalu tambahkan `"package": "./"` ke `plugins` pada config lokal (gunakan `"./"`, bukan `"."`).
57
31
 
58
32
  ## Penggunaan
59
33
 
60
- Di OpenCode TUI / App:
34
+ Perintah `/boost`, `/teamwork`, dan `/swarm` menjalankan pipeline di background tanpa menampilkan prompt internal. Setelah pemeriksaan oleh verifier independen, sesi utama menerima hasil atau informasi tentang kendala. Sidebar TUI menampilkan aktivitas Boost untuk sesi yang sedang dibuka.
35
+
61
36
  ```text
62
37
  /boost Perbaiki race condition di connection pool dan tambahkan stress test
63
38
  /boost --investigate Telusuri kenapa request timeout melonjak di atas 2MB
64
- /boost --coder --rounds=2 Refactor middleware auth ke async
65
-
66
39
  /teamwork --swe --no-interview Implementasi rate limiter dengan unit test
67
- /teamwork [skip-interview] --review Audit keamanan parser JWT
68
- /teamwork --audit Audit celah keamanan dan error handling di modul auth
69
- /teamwork --discover Eksplorasi akar masalah memory leak di worker pool
70
40
  /teamwork --colosseum --workers=3 Bandingkan Redis vs SQLite untuk session store
71
-
72
41
  /swarm --fanout --workers=3 --worktree Analisis bottleneck latency di seluruh service
73
42
  /swarm --pipeline --workers=3 Audit dan desain ulang alur autentikasi
74
43
  ```
44
+
45
+ ## Dokumentasi
46
+
47
+ - [Daftar Isi Dokumentasi](docs/README.md)
48
+ - [Arsitektur & Cara Kerja](docs/architecture.md)
49
+ - [Konfigurasi, Opsi, Flag & Skema Tool](docs/configuration.md)
50
+ - [Catatan Reverse Engineering](docs/reverse-engineering.md)
@@ -0,0 +1,24 @@
1
+ export type PipelineRole = "boost" | "teamwork" | "swarm";
2
+ export type VerificationMode = "coder" | "investigate" | "review" | "generic";
3
+ export interface VerificationOutcome {
4
+ status: "verified" | "blocked" | "inconclusive";
5
+ detail: string;
6
+ }
7
+ export interface CompletionSession {
8
+ synthetic(input: {
9
+ sessionID: string;
10
+ text: string;
11
+ resume: boolean;
12
+ }): Promise<unknown>;
13
+ }
14
+ export interface DispatchOptions {
15
+ session: CompletionSession;
16
+ sessionID: string;
17
+ role: PipelineRole;
18
+ task: string;
19
+ extra?: string[];
20
+ run: () => Promise<string>;
21
+ verify: (report: string) => Promise<VerificationOutcome>;
22
+ }
23
+ export declare function completionMessage(role: PipelineRole, runID: string, task: string, report: string, outcome: VerificationOutcome): string;
24
+ export declare function dispatchBackground(options: DispatchOptions): string;
@@ -0,0 +1,49 @@
1
+ export function completionMessage(role, runID, task, report, outcome) {
2
+ const header = outcome.status === "verified"
3
+ ? "Independent verification passed"
4
+ : outcome.status === "blocked"
5
+ ? "Bounded by a blocker"
6
+ : "Final evidence check required";
7
+ return [
8
+ `[Orchestra ${role} run ${runID} finished: ${header}]`,
9
+ `Original task: ${task}`,
10
+ ...(outcome.detail ? [`Verification: ${outcome.detail}`] : []),
11
+ "",
12
+ "FINAL EVIDENCE CHECK (required before replying): confirm the claims below that would change the answer with primary evidence from the workspace, rerunning the relevant tests for coding work.",
13
+ "Then reply ONLY with the answer to the original request, stated plainly and directly.",
14
+ "Omit any account of the process, who asserted what, mistakes, confidence language, or verification narrative. If a blocker truly prevents completion, state the specific blocker and what is needed, and nothing else.",
15
+ "",
16
+ "<untrusted_worker_report>",
17
+ report,
18
+ "</untrusted_worker_report>",
19
+ ].join("\n");
20
+ }
21
+ export function dispatchBackground(options) {
22
+ const { session, sessionID, role, task, run, verify } = options;
23
+ const runID = `${role}-${crypto.randomUUID()}`;
24
+ void Promise.resolve()
25
+ .then(run)
26
+ .then(async (report) => {
27
+ const outcome = await verify(report).catch((error) => ({
28
+ status: "inconclusive",
29
+ detail: `automatic verification error: ${error instanceof Error ? error.message : String(error)}`,
30
+ }));
31
+ return session.synthetic({
32
+ sessionID,
33
+ resume: true,
34
+ text: completionMessage(role, runID, task, report, outcome),
35
+ });
36
+ })
37
+ .catch((error) => session.synthetic({
38
+ sessionID,
39
+ resume: true,
40
+ text: [
41
+ `[Orchestra ${role} run ${runID} stopped: blocking failure]`,
42
+ `Original task: ${task}`,
43
+ `Error: ${error instanceof Error ? error.message : String(error)}`,
44
+ "Explain the specific blocker to the user. Do not present a result.",
45
+ ].join("\n"),
46
+ }))
47
+ .catch((error) => console.error(`Orchestra ${runID}: completion delivery failed`, error));
48
+ return runID;
49
+ }
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { Plugin } from "@opencode/plugin";
2
+ import { dispatchBackground } from "./dispatch.js";
2
3
  import { checkPeerWait, getBoardHead, postToBoard, readBoard, } from "./board.js";
3
4
  import { parseBoostArgs, parseModelRef, parseSwarmArgs, parseTeamworkArgs, } from "./parser.js";
4
5
  import { runBoostPipeline } from "./pipeline.js";
5
6
  import { runSwarmPipeline } from "./swarm.js";
6
7
  import { runTeamworkPipeline, } from "./teamwork.js";
7
- import { advanceSwarmWorkerOnOwnPost, applyContextHook, applyIdleParkGuardHook, clearCoordinatorOnIdle, getSwarmWorkerSession, markSwarmWorkerRead, registerCoordinatorSession, resetSessionRegistry, unregisterCoordinatorSession, } from "./session-registry.js";
8
+ import { verifyReportAutomatically } from "./verify.js";
9
+ import { advanceSwarmWorkerOnOwnPost, applyContextHook, applyIdleParkGuardHook, clearCoordinatorOnIdle, registerCoordinatorSession, resetSessionRegistry, unregisterCoordinatorSession, } from "./session-registry.js";
8
10
  function clampInt(value, min, max, fallback) {
9
11
  if (typeof value === "number" && Number.isFinite(value)) {
10
12
  return Math.max(min, Math.min(max, Math.floor(value)));
@@ -38,6 +40,11 @@ function readPluginConfig(options) {
38
40
  modelOverride: parseModelRef(cfg.model),
39
41
  };
40
42
  }
43
+ function verificationMode(requested) {
44
+ return requested === "investigate" || requested === "review" || requested === "coder"
45
+ ? requested
46
+ : "generic";
47
+ }
41
48
  function formatBoostOutput(result) {
42
49
  const pipelineName = result.mode === "coder" ? "DeepCoder" : "DeepInvestigator";
43
50
  return [
@@ -47,10 +54,6 @@ function formatBoostOutput(result) {
47
54
  `- **Isolated sub-sessions**: ${result.childSessionIDs.length}`,
48
55
  "",
49
56
  result.report,
50
- "",
51
- "---",
52
- "## Orchestrator Spot-Check",
53
- result.verificationNote,
54
57
  ].join("\n");
55
58
  }
56
59
  function formatTeamworkOutput(result) {
@@ -71,8 +74,6 @@ function formatTeamworkOutput(result) {
71
74
  "",
72
75
  result.report,
73
76
  "",
74
- "---",
75
- "## Gate & Review Summary",
76
77
  result.gateSummary,
77
78
  ].join("\n");
78
79
  }
@@ -86,16 +87,52 @@ function formatSwarmOutput(result) {
86
87
  "",
87
88
  result.report,
88
89
  "",
89
- "---",
90
90
  result.blackboard,
91
91
  ].join("\n");
92
92
  }
93
+ function dispatchDirective(role, args, mode, askFirst) {
94
+ return [
95
+ `[Orchestra ${role} command] The latest user message is the original request. Do not solve it inline and do not delegate it to a generic subagent.`,
96
+ askFirst
97
+ ? "Ask concise scoping questions first, then call the tool with the user's answers."
98
+ : `Call the \`${role}\` tool now with these arguments, keeping the task verbatim.`,
99
+ JSON.stringify(args),
100
+ `One ${role} head orchestrator will control every worker and verifier subagent. The tool returns at once, so tell the user only what was dispatched and end this turn.`,
101
+ "When the completion arrives, confirm the material claims in the workspace, then reply only with the answer to the original request. Leave out the process, who was right or wrong, mistakes, confidence language, and the verification narrative.",
102
+ `Verification mode: ${mode}.`,
103
+ ].join("\n");
104
+ }
105
+ const EMPTY_TASK_DIRECTIVE = {
106
+ boost: "The user invoked /boost without an inline task. If the conversation has a clear pending task, call boost with that task. Otherwise show /boost [--coder | --investigate] [--rounds=N] <task>. Do not invent a task.",
107
+ teamwork: "The user invoked /teamwork without an inline task. If a clear pending task exists, call teamwork with it. Otherwise show /teamwork [--swe | --review | --audit | --discover | --colosseum] <task>. Do not invent a task.",
108
+ swarm: "The user invoked /swarm without an inline task. If a clear pending task exists, call swarm with it. Otherwise show /swarm [--fanout | --pipeline] <task>. Do not invent a task.",
109
+ };
93
110
  export default Plugin.define({
94
111
  id: "opencode.orchestra",
95
112
  async setup(ctx) {
96
113
  const pluginCfg = readPluginConfig(ctx.options);
97
114
  const registrations = [];
98
115
  const formatModelSpec = (ref) => ref ? `${ref.providerID}/${ref.id}` : undefined;
116
+ const runVerifier = async (sessionID, task, report, mode, modelOverride, verifierTitle) => {
117
+ const result = await verifyReportAutomatically(ctx.session, {
118
+ sessionID,
119
+ task,
120
+ report,
121
+ mode,
122
+ verifierTitle,
123
+ maxVerificationRounds: pluginCfg.maxExtraVerificationRounds + 1,
124
+ ...(modelOverride ? { modelOverride } : {}),
125
+ });
126
+ if (!result.blocked)
127
+ return { status: "verified", detail: "" };
128
+ return {
129
+ status: "blocked",
130
+ detail: result.blockers.join("; "),
131
+ };
132
+ };
133
+ const dispatched = (role, runID) => ({
134
+ content: `Dispatched ${runID}. One ${role} head orchestrator owns all worker and verifier subagents. Tell the user only what was dispatched, then end this turn.`,
135
+ });
99
136
  const cmdReg = await ctx.command.transform((editor) => {
100
137
  editor.add({
101
138
  name: "boost",
@@ -112,35 +149,15 @@ export default Plugin.define({
112
149
  }
113
150
  : {}),
114
151
  };
115
- if (parsed.task) {
116
- registerCoordinatorSession(sessionID, "boost");
117
- }
152
+ registerCoordinatorSession(sessionID, "boost", {
153
+ directive: parsed.task
154
+ ? dispatchDirective("boost", baseArgs, verificationMode(parsed.mode), false)
155
+ : EMPTY_TASK_DIRECTIVE.boost,
156
+ });
118
157
  await ctx.session.prompt({
119
158
  ...prompt,
120
159
  sessionID,
121
- text: parsed.task
122
- ? [
123
- "You are the **Boost Orchestrator**.",
124
- "Immediately invoke the `boost` tool (do not solve the task manually first) using the base arguments below:",
125
- "```json",
126
- JSON.stringify(baseArgs, null, 2),
127
- "```",
128
- "",
129
- "### Rules for `task` and `additionalContext`",
130
- "- Keep `task` **verbatim** as provided above (do not rephrase or inject your own solution).",
131
- "- **First turn**: omit `additionalContext`.",
132
- "- **Follow-up turn**: include `additionalContext` summarizing only the relevant facts, decisions, file paths, or constraints from earlier turns that the worker needs to understand `task` (do not include your own proposed solution).",
133
- "- Present the verified result clearly to the user after the tool completes.",
134
- ].join("\n")
135
- : [
136
- "You are the **Boost Orchestrator**.",
137
- "The user invoked `/boost` without an inline task.",
138
- "- If earlier turns in this conversation contain a clear pending task or request, immediately invoke the `boost` tool with `task` capturing that request verbatim, `additionalContext` summarizing the relevant prior-turn context, and the base options below.",
139
- "- Otherwise, briefly show the usage: `/boost [--coder | --investigate] [--rounds=N] [--model=provider/model] <task>`.",
140
- "```json",
141
- JSON.stringify(baseArgs, null, 2),
142
- "```",
143
- ].join("\n"),
160
+ text: prompt.text || "/boost",
144
161
  delivery,
145
162
  });
146
163
  },
@@ -163,44 +180,15 @@ export default Plugin.define({
163
180
  }
164
181
  : {}),
165
182
  };
166
- if (!parsed.task) {
167
- await ctx.session.prompt({
168
- ...prompt,
169
- sessionID,
170
- text: [
171
- "You are the **Teamwork Orchestrator**.",
172
- "The user invoked `/teamwork` without an inline task.",
173
- "- If earlier turns in this conversation contain a clear pending task, invoke the `teamwork` tool with `task` verbatim, `additionalContext` summarizing relevant prior-turn context, and the base options below.",
174
- "- Otherwise, briefly show the usage: `/teamwork [--swe | --review | --audit | --discover | --colosseum] [--qa-rounds=N] [--workers=N] [--no-interview] [--model=provider/model] <task>`.",
175
- "```json",
176
- JSON.stringify(baseArgs, null, 2),
177
- "```",
178
- ].join("\n"),
179
- delivery,
180
- });
181
- return;
182
- }
183
- registerCoordinatorSession(sessionID, "teamwork");
183
+ registerCoordinatorSession(sessionID, "teamwork", {
184
+ directive: parsed.task
185
+ ? dispatchDirective("teamwork", baseArgs, verificationMode(parsed.mode), !parsed.skipInterview)
186
+ : EMPTY_TASK_DIRECTIVE.teamwork,
187
+ });
184
188
  await ctx.session.prompt({
185
189
  ...prompt,
186
190
  sessionID,
187
- text: parsed.skipInterview
188
- ? [
189
- "You are the **Teamwork Orchestrator**.",
190
- "Immediately invoke the `teamwork` tool (do not solve the task manually first) using the base arguments below:",
191
- "```json",
192
- JSON.stringify(baseArgs, null, 2),
193
- "```",
194
- "Keep `task` verbatim. On follow-up turns, include `additionalContext` summarizing relevant prior-turn context (without injecting your own solution). Then present the verified result clearly to the user.",
195
- ].join("\n")
196
- : [
197
- "You are the **Teamwork Orchestrator**.",
198
- "Before dispatching workers, conduct a brief upfront **scoping interview** (2–4 concise multiple-choice/clarifying questions about scope, constraints, and acceptance criteria) using the `question` tool (unless the task is already 100% unambiguous).",
199
- "Once the user answers, immediately invoke the `teamwork` tool with the base arguments below plus `scopingContext` (their answers) and, on follow-up turns, `additionalContext` summarizing relevant prior-turn context. Keep `task` verbatim:",
200
- "```json",
201
- JSON.stringify(baseArgs, null, 2),
202
- "```",
203
- ].join("\n"),
191
+ text: prompt.text || "/teamwork",
204
192
  delivery,
205
193
  });
206
194
  },
@@ -223,30 +211,15 @@ export default Plugin.define({
223
211
  }
224
212
  : {}),
225
213
  };
226
- if (parsed.task) {
227
- registerCoordinatorSession(sessionID, "swarm");
228
- }
214
+ registerCoordinatorSession(sessionID, "swarm", {
215
+ directive: parsed.task
216
+ ? dispatchDirective("swarm", baseArgs, "generic", false)
217
+ : EMPTY_TASK_DIRECTIVE.swarm,
218
+ });
229
219
  await ctx.session.prompt({
230
220
  ...prompt,
231
221
  sessionID,
232
- text: parsed.task
233
- ? [
234
- "You are the **Swarm Orchestrator**.",
235
- "Immediately invoke the `swarm` tool (do not solve the task manually first) using the base arguments below:",
236
- "```json",
237
- JSON.stringify(baseArgs, null, 2),
238
- "```",
239
- "Keep `task` verbatim. On follow-up turns, include `additionalContext` summarizing relevant prior-turn context (without injecting your own solution). Then present the verified result clearly to the user.",
240
- ].join("\n")
241
- : [
242
- "You are the **Swarm Orchestrator**.",
243
- "The user invoked `/swarm` without an inline task.",
244
- "- If earlier turns in this conversation contain a clear pending task, invoke the `swarm` tool with `task` verbatim, `additionalContext` summarizing relevant prior-turn context, and the base options below.",
245
- "- Otherwise, briefly show the usage: `/swarm [--fanout | --pipeline] [--workers=N] [--worktree] [--model=provider/model] <task>`.",
246
- "```json",
247
- JSON.stringify(baseArgs, null, 2),
248
- "```",
249
- ].join("\n"),
222
+ text: prompt.text || "/swarm",
250
223
  delivery,
251
224
  });
252
225
  },
@@ -294,28 +267,32 @@ export default Plugin.define({
294
267
  },
295
268
  execute: async (rawInput, context) => {
296
269
  const input = rawInput;
297
- try {
298
- const result = await runBoostPipeline(ctx.session, {
299
- sessionID: context.sessionID,
300
- task: input.task,
301
- additionalContext: input.additionalContext,
302
- continueSessionID: input.continueSessionID,
303
- mode: input.mode ?? pluginCfg.defaultMode,
304
- improvementRounds: input.rounds ?? pluginCfg.improvementRounds,
305
- maxExtraVerificationRounds: pluginCfg.maxExtraVerificationRounds,
306
- modelOverride: parseModelRef(input.model) ?? pluginCfg.modelOverride,
307
- signal: context.signal,
308
- onProgress: async (status) => {
309
- await context.progress({ status });
310
- },
311
- });
312
- return {
313
- content: formatBoostOutput(result),
314
- };
315
- }
316
- finally {
317
- unregisterCoordinatorSession(context.sessionID);
318
- }
270
+ const modelOverride = parseModelRef(input.model) ?? pluginCfg.modelOverride;
271
+ const requestedMode = input.mode ?? pluginCfg.defaultMode;
272
+ let report = "";
273
+ const runID = dispatchBackground({
274
+ session: ctx.session,
275
+ sessionID: context.sessionID,
276
+ role: "boost",
277
+ task: input.task,
278
+ run: async () => {
279
+ const result = await runBoostPipeline(ctx.session, {
280
+ sessionID: context.sessionID,
281
+ task: input.task,
282
+ additionalContext: input.additionalContext,
283
+ continueSessionID: input.continueSessionID,
284
+ mode: requestedMode,
285
+ improvementRounds: input.rounds ?? pluginCfg.improvementRounds,
286
+ maxExtraVerificationRounds: pluginCfg.maxExtraVerificationRounds,
287
+ modelOverride,
288
+ });
289
+ report = formatBoostOutput(result);
290
+ return report;
291
+ },
292
+ verify: () => runVerifier(context.sessionID, input.task, report, verificationMode(requestedMode), modelOverride, "Boost Final Verifier"),
293
+ });
294
+ unregisterCoordinatorSession(context.sessionID);
295
+ return dispatched("boost", runID);
319
296
  },
320
297
  });
321
298
  editor.add({
@@ -363,29 +340,33 @@ export default Plugin.define({
363
340
  },
364
341
  execute: async (rawInput, context) => {
365
342
  const input = rawInput;
366
- try {
367
- const result = await runTeamworkPipeline(ctx.session, {
368
- sessionID: context.sessionID,
369
- task: input.task,
370
- additionalContext: input.additionalContext,
371
- mode: input.mode ?? pluginCfg.teamworkDefaultMode,
372
- maxQaRounds: input.qaRounds ?? pluginCfg.teamworkQaRounds,
373
- workers: input.workers ?? pluginCfg.teamworkWorkers,
374
- scopingContext: input.scopingContext,
375
- storage: ctx.storage,
376
- modelOverride: parseModelRef(input.model) ?? pluginCfg.modelOverride,
377
- signal: context.signal,
378
- onProgress: async (status) => {
379
- await context.progress({ status });
380
- },
381
- });
382
- return {
383
- content: formatTeamworkOutput(result),
384
- };
385
- }
386
- finally {
387
- unregisterCoordinatorSession(context.sessionID);
388
- }
343
+ const modelOverride = parseModelRef(input.model) ?? pluginCfg.modelOverride;
344
+ const requestedMode = input.mode ?? pluginCfg.teamworkDefaultMode;
345
+ let report = "";
346
+ const runID = dispatchBackground({
347
+ session: ctx.session,
348
+ sessionID: context.sessionID,
349
+ role: "teamwork",
350
+ task: input.task,
351
+ run: async () => {
352
+ const result = await runTeamworkPipeline(ctx.session, {
353
+ sessionID: context.sessionID,
354
+ task: input.task,
355
+ additionalContext: input.additionalContext,
356
+ mode: requestedMode,
357
+ maxQaRounds: input.qaRounds ?? pluginCfg.teamworkQaRounds,
358
+ workers: input.workers ?? pluginCfg.teamworkWorkers,
359
+ scopingContext: input.scopingContext,
360
+ storage: ctx.storage,
361
+ modelOverride,
362
+ });
363
+ report = formatTeamworkOutput(result);
364
+ return report;
365
+ },
366
+ verify: () => runVerifier(context.sessionID, input.task, report, verificationMode(requestedMode), modelOverride),
367
+ });
368
+ unregisterCoordinatorSession(context.sessionID);
369
+ return dispatched("teamwork", runID);
389
370
  },
390
371
  });
391
372
  editor.add({
@@ -427,29 +408,32 @@ export default Plugin.define({
427
408
  },
428
409
  execute: async (rawInput, context) => {
429
410
  const input = rawInput;
430
- try {
431
- const result = await runSwarmPipeline(ctx.session, {
432
- sessionID: context.sessionID,
433
- task: input.task,
434
- additionalContext: input.additionalContext,
435
- mode: input.mode ?? pluginCfg.swarmDefaultMode,
436
- workers: input.workers ?? pluginCfg.swarmWorkers,
437
- useWorktree: input.useWorktree ?? false,
438
- storage: ctx.storage,
439
- worktree: ctx.worktree,
440
- modelOverride: parseModelRef(input.model) ?? pluginCfg.modelOverride,
441
- signal: context.signal,
442
- onProgress: async (status) => {
443
- await context.progress({ status });
444
- },
445
- });
446
- return {
447
- content: formatSwarmOutput(result),
448
- };
449
- }
450
- finally {
451
- unregisterCoordinatorSession(context.sessionID);
452
- }
411
+ const modelOverride = parseModelRef(input.model) ?? pluginCfg.modelOverride;
412
+ let report = "";
413
+ const runID = dispatchBackground({
414
+ session: ctx.session,
415
+ sessionID: context.sessionID,
416
+ role: "swarm",
417
+ task: input.task,
418
+ run: async () => {
419
+ const result = await runSwarmPipeline(ctx.session, {
420
+ sessionID: context.sessionID,
421
+ task: input.task,
422
+ additionalContext: input.additionalContext,
423
+ mode: input.mode ?? pluginCfg.swarmDefaultMode,
424
+ workers: input.workers ?? pluginCfg.swarmWorkers,
425
+ useWorktree: input.useWorktree ?? false,
426
+ storage: ctx.storage,
427
+ worktree: ctx.worktree,
428
+ modelOverride,
429
+ });
430
+ report = formatSwarmOutput(result);
431
+ return report;
432
+ },
433
+ verify: () => runVerifier(context.sessionID, input.task, report, "generic", modelOverride),
434
+ });
435
+ unregisterCoordinatorSession(context.sessionID);
436
+ return dispatched("swarm", runID);
453
437
  },
454
438
  });
455
439
  editor.add({
@@ -470,13 +454,9 @@ export default Plugin.define({
470
454
  type: "string",
471
455
  description: "Optional recipient (e.g. all, worker-2, coordinator).",
472
456
  },
473
- channel: {
474
- type: "string",
475
- description: "Optional channel name (default 'general', e.g. 'findings', 'blockers', 'handoffs').",
476
- },
477
457
  message: {
478
458
  type: "string",
479
- description: "Concise status, finding, or blocker to share. Supports @worker-N mentions.",
459
+ description: "Concise status, finding, or blocker to share.",
480
460
  },
481
461
  },
482
462
  required: ["boardId", "author", "message"],
@@ -487,12 +467,11 @@ export default Plugin.define({
487
467
  const post = await postToBoard(ctx.storage, input.boardId, {
488
468
  author: input.author,
489
469
  to: input.to,
490
- channel: input.channel,
491
470
  message: input.message,
492
471
  });
493
472
  advanceSwarmWorkerOnOwnPost(input.boardId, input.author, post.seq);
494
473
  return {
495
- content: `Posted #${post.seq} to board ${input.boardId}${post.channel ? ` (#${post.channel})` : ""}.`,
474
+ content: `Posted #${post.seq} to board ${input.boardId}.`,
496
475
  };
497
476
  },
498
477
  });
@@ -506,14 +485,6 @@ export default Plugin.define({
506
485
  type: "string",
507
486
  description: "The Swarm board identifier provided in your prompt.",
508
487
  },
509
- workerId: {
510
- type: "string",
511
- description: "Optional worker ID (e.g. worker-1) to advance your read cursor.",
512
- },
513
- channel: {
514
- type: "string",
515
- description: "Optional channel filter (e.g. 'general', 'findings', 'blockers').",
516
- },
517
488
  afterSeq: {
518
489
  type: "integer",
519
490
  minimum: 0,
@@ -523,25 +494,15 @@ export default Plugin.define({
523
494
  required: ["boardId"],
524
495
  additionalProperties: false,
525
496
  },
526
- execute: async (rawInput, context) => {
497
+ execute: async (rawInput) => {
527
498
  const input = rawInput;
528
- const posts = await readBoard(ctx.storage, input.boardId, input.afterSeq ?? 0, input.channel);
529
- if (posts.length > 0 && !input.channel) {
530
- const latestSeq = Math.max(...posts.map((p) => p.seq));
531
- const effectiveWorkerId = input.workerId ??
532
- (getSwarmWorkerSession(context.sessionID)?.boardId === input.boardId
533
- ? getSwarmWorkerSession(context.sessionID)?.workerId
534
- : undefined);
535
- if (effectiveWorkerId) {
536
- markSwarmWorkerRead(input.boardId, effectiveWorkerId, latestSeq);
537
- }
538
- }
499
+ const posts = await readBoard(ctx.storage, input.boardId, input.afterSeq ?? 0);
539
500
  if (posts.length === 0) {
540
501
  return { content: "(no new posts on board)" };
541
502
  }
542
503
  return {
543
504
  content: posts
544
- .map((p) => `#${p.seq}${p.channel && p.channel !== "general" ? ` [#${p.channel}]` : ""} [@${p.author}${p.to ? ` -> @${p.to}` : ""}]: ${p.message}`)
505
+ .map((p) => `#${p.seq} [@${p.author}${p.to ? ` -> @${p.to}` : ""}]: ${p.message}`)
545
506
  .join("\n"),
546
507
  };
547
508
  },
@@ -564,7 +525,7 @@ export default Plugin.define({
564
525
  const input = rawInput;
565
526
  const head = await getBoardHead(ctx.storage, input.boardId);
566
527
  return {
567
- content: JSON.stringify(head),
528
+ content: `boardId="${input.boardId}" latestSeq=${head.latestSeq} totalPosts=${head.totalPosts} authors=${head.authors.join(", ") || "(none)"}`,
568
529
  };
569
530
  },
570
531
  });
@@ -594,17 +555,13 @@ export default Plugin.define({
594
555
  execute: async (rawInput) => {
595
556
  const input = rawInput;
596
557
  const status = await checkPeerWait(ctx.storage, input.boardId, input.workerId, input.afterSeq ?? 0);
597
- markSwarmWorkerRead(input.boardId, input.workerId, status.latestSeq);
598
558
  if (!status.hasUnreadPeerActivity) {
599
- return {
600
- content: `No unread peer messages for ${input.workerId} (latestSeq=${status.latestSeq}). Safe to finalize.`,
601
- };
559
+ return { content: "(no unread peer activity)" };
602
560
  }
603
- const formatted = status.unreadForWorker
604
- .map((p) => `#${p.seq} [@${p.author}${p.to ? ` -> @${p.to}` : ""}]: ${p.message}`)
605
- .join("\n");
606
561
  return {
607
- content: `Unread peer messages for ${input.workerId} (latestSeq=${status.latestSeq}):\n${formatted}`,
562
+ content: status.unreadForWorker
563
+ .map((p) => `#${p.seq} [@${p.author}${p.to ? ` -> @${p.to}` : ""}]: ${p.message}`)
564
+ .join("\n"),
608
565
  };
609
566
  },
610
567
  });
@@ -624,10 +581,10 @@ export default Plugin.define({
624
581
  if (idleHookReg)
625
582
  registrations.push(idleHookReg);
626
583
  }
627
- await ctx.command.reload();
628
- await ctx.tool.reload();
629
584
  return async () => {
630
- await Promise.allSettled(registrations.map((reg) => reg.dispose()));
585
+ for (const registration of registrations) {
586
+ await registration.dispose().catch(() => { });
587
+ }
631
588
  resetSessionRegistry();
632
589
  };
633
590
  },
@@ -9,12 +9,14 @@ export interface SwarmWorkerMeta {
9
9
  export type CoordinatorRole = "boost" | "teamwork" | "swarm";
10
10
  export interface CoordinatorSessionMeta {
11
11
  role: CoordinatorRole;
12
+ directive?: string;
12
13
  registeredAt: number;
13
14
  injections: number;
14
15
  maxInjections: number;
15
16
  ttlMs: number;
16
17
  }
17
18
  export interface RegisterCoordinatorOptions {
19
+ directive?: string;
18
20
  maxInjections?: number;
19
21
  ttlMs?: number;
20
22
  now?: number;
@@ -30,6 +30,7 @@ function isCoordinatorExpired(meta, now) {
30
30
  export function registerCoordinatorSession(sessionID, role, options) {
31
31
  coordinatorSessions.set(sessionID, {
32
32
  role,
33
+ directive: options?.directive,
33
34
  registeredAt: options?.now ?? Date.now(),
34
35
  injections: 0,
35
36
  maxInjections: options?.maxInjections ?? DEFAULT_COORDINATOR_MAX_INJECTIONS[role],
@@ -140,7 +141,7 @@ export async function applyContextHook(event, storage, now = Date.now()) {
140
141
  coordinatorMeta.injections += 1;
141
142
  event.system.push({
142
143
  type: "text",
143
- text: `[Orchestrator Role Reminder (${coordinatorMeta.role})] You are the Orchestrator. Delegate implementation/investigation to the \`${coordinatorMeta.role}\` tool rather than performing edits or deep exploration directly, then synthesize and spot-check the final result.`,
144
+ text: coordinatorMeta.directive ?? `[Orchestrator Role Reminder (${coordinatorMeta.role})] Delegate to the \`${coordinatorMeta.role}\` tool. Once dispatched, tell the user what is running and end this turn without waiting. When a completion arrives, distrust its claims and verify against primary evidence before reporting.`,
144
145
  });
145
146
  if (coordinatorMeta.injections >= coordinatorMeta.maxInjections) {
146
147
  coordinatorSessions.delete(event.sessionID);
package/dist/tui.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Plugin } from "@opencode/plugin/tui";
2
+ declare const _default: Plugin.Definition;
3
+ export default _default;
package/dist/tui.js ADDED
@@ -0,0 +1,169 @@
1
+ import { Plugin } from "@opencode/plugin/tui";
2
+ import { jsx } from "@opentui/solid/jsx-runtime";
3
+ import { createComponent, createMemo, createSignal, For, onMount } from "solid-js";
4
+ const BOOST_WORKER = /^Boost (?:Deep(?:Coder|Investigator) (?:L0|(?:Improvement|Fix) #\d+)|Orchestrator Verify #\d+|Final Verifier(?: Recheck #\d+)?)$/;
5
+ const MAX_WORKERS = 4;
6
+ const graphemes = new Intl.Segmenter();
7
+ function fit(text, width) {
8
+ const line = text.replace(/\s+/g, " ").trim();
9
+ if (Bun.stringWidth(line) <= width)
10
+ return line;
11
+ if (width <= 3)
12
+ return ".".repeat(Math.max(0, width));
13
+ let prefix = "";
14
+ let remaining = width - 3;
15
+ for (const { segment } of graphemes.segment(line)) {
16
+ remaining -= Bun.stringWidth(segment);
17
+ if (remaining < 0)
18
+ break;
19
+ prefix += segment;
20
+ }
21
+ return `${prefix.trimEnd()}...`;
22
+ }
23
+ function visibleWorkers(sessions, parentID) {
24
+ const workers = [...new Set(sessions.family(parentID))]
25
+ .map((id) => sessions.get(id))
26
+ .filter((session) => session?.parentID === parentID && BOOST_WORKER.test(session.title ?? ""))
27
+ .sort((a, b) => b.time.updated - a.time.updated);
28
+ const running = workers.filter((session) => sessions.status(session.id) === "running");
29
+ const idle = workers.filter((session) => sessions.status(session.id) === "idle");
30
+ return [...running, ...idle.slice(0, Math.max(0, MAX_WORKERS - running.length))].map((session) => session.id);
31
+ }
32
+ function workerRow(ctx, id, width) {
33
+ const sessions = ctx.data.session;
34
+ onMount(() => void sessions.message.sync(id).catch(() => { }));
35
+ const worker = createMemo(() => {
36
+ const session = sessions.get(id);
37
+ let assistant;
38
+ const messages = sessions.message.list(id);
39
+ for (let i = messages.length - 1; i >= 0; i--) {
40
+ const message = messages[i];
41
+ if (message.type === "user")
42
+ break;
43
+ if (message.type === "assistant") {
44
+ assistant = message;
45
+ break;
46
+ }
47
+ }
48
+ const running = sessions.status(id) === "running";
49
+ let tool;
50
+ if (running && assistant && !assistant.time.completed) {
51
+ for (let i = assistant.content.length - 1; i >= 0; i--) {
52
+ const part = assistant.content[i];
53
+ if (part.type === "tool" && (part.state.status === "running" || part.state.status === "streaming")) {
54
+ tool = part;
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ const model = assistant?.model ?? session?.model;
60
+ const outcome = session?.outcome;
61
+ const waitingForPermission = running && Boolean(sessions.permission.list(id)?.length);
62
+ const responding = running && Boolean(assistant?.time.firstToken && !assistant.time.completed);
63
+ const activity = waitingForPermission ? "Waiting for approval"
64
+ : running && tool ? `Running: ${tool.name}`
65
+ : responding ? "Responding"
66
+ : running ? "Waiting for model"
67
+ : outcome === "failed" ? "Failed"
68
+ : outcome === "interrupted" ? "Interrupted"
69
+ : "Waiting to start";
70
+ return {
71
+ name: (session?.title ?? "").replace(/^Boost (?:Orchestrator )?/, ""),
72
+ model: model?.id.split("/").at(-1) || "Unknown model",
73
+ activity,
74
+ color: waitingForPermission ? ctx.theme.text.feedback.warning.base
75
+ : running && (tool || responding) ? ctx.theme.hue.interactive[200]
76
+ : outcome === "failed" ? ctx.theme.text.feedback.error.base
77
+ : ctx.theme.text.muted,
78
+ };
79
+ });
80
+ const modelWidth = () => Math.min(18, Math.floor(width() * 0.4));
81
+ const nameWidth = () => width() - modelWidth() - 2;
82
+ const completed = () => isCompleted(sessions, id);
83
+ const line = { height: 1, wrapMode: "none", flexShrink: 0 };
84
+ return jsx("box", {
85
+ flexDirection: "column",
86
+ children: [
87
+ jsx("text", {
88
+ ...line,
89
+ get fg() { return ctx.theme.text.base; },
90
+ children: [
91
+ jsx("b", {
92
+ get children() { return fit(worker().name, nameWidth()); },
93
+ }),
94
+ jsx("span", {
95
+ get style() { return { fg: ctx.theme.text.muted }; },
96
+ get children() {
97
+ const name = fit(worker().name, nameWidth());
98
+ const padding = Math.max(0, nameWidth() - Bun.stringWidth(name) + 2);
99
+ return `${" ".repeat(padding)}${fit(worker().model, modelWidth())}`;
100
+ },
101
+ }),
102
+ ],
103
+ }),
104
+ () => completed() ? null : jsx("text", {
105
+ ...line,
106
+ get fg() { return worker().color; },
107
+ get children() { return fit(worker().activity, width()); },
108
+ }),
109
+ ],
110
+ });
111
+ }
112
+ function isCompleted(sessions, id) {
113
+ return sessions.status(id) === "idle" && sessions.get(id)?.outcome === "succeeded";
114
+ }
115
+ export default Plugin.define({
116
+ id: "opencode.orchestra.sidebar",
117
+ setup(ctx) {
118
+ return ctx.ui.slot({
119
+ append: "sidebar.content",
120
+ render(input) {
121
+ const workers = createMemo(() => visibleWorkers(ctx.data.session, input.sessionID));
122
+ const completed = createMemo(() => workers().filter((id) => isCompleted(ctx.data.session, id)));
123
+ const current = createMemo(() => workers().filter((id) => !isCompleted(ctx.data.session, id)));
124
+ const [width, setWidth] = createSignal(24);
125
+ const contentWidth = () => Math.max(0, width() - 2);
126
+ return jsx("box", {
127
+ flexDirection: "column",
128
+ ref(box) {
129
+ box.onSizeChange = () => setWidth(box.width);
130
+ },
131
+ children: [
132
+ () => workers().length ? jsx("box", {
133
+ paddingLeft: 1,
134
+ get backgroundColor() { return ctx.theme.background.raised.high; },
135
+ children: jsx("text", {
136
+ get fg() { return ctx.theme.hue.interactive[200]; },
137
+ children: jsx("b", { children: "Boost" }),
138
+ }),
139
+ }) : null,
140
+ jsx("box", {
141
+ flexDirection: "column",
142
+ paddingX: 1,
143
+ get backgroundColor() { return ctx.theme.background.raised.base; },
144
+ children: [
145
+ jsx("box", {
146
+ flexDirection: "column",
147
+ gap: 1,
148
+ children: createComponent(For, {
149
+ get each() { return current(); },
150
+ children: (id) => workerRow(ctx, id, contentWidth),
151
+ }),
152
+ }),
153
+ () => completed().length ? jsx("text", {
154
+ get marginTop() { return current().length ? 1 : 0; },
155
+ get fg() { return ctx.theme.text.feedback.success.base; },
156
+ children: "Completed",
157
+ }) : null,
158
+ createComponent(For, {
159
+ get each() { return completed(); },
160
+ children: (id) => workerRow(ctx, id, contentWidth),
161
+ }),
162
+ ],
163
+ }),
164
+ ],
165
+ });
166
+ },
167
+ });
168
+ },
169
+ });
@@ -0,0 +1,24 @@
1
+ import { type ModelRef } from "./parser.js";
2
+ import type { BoostSessionClient } from "./pipeline.js";
3
+ export interface VerificationOptions {
4
+ sessionID: string;
5
+ task: string;
6
+ report: string;
7
+ mode: "coder" | "investigate" | "review" | "generic";
8
+ modelOverride?: ModelRef;
9
+ verifierTitle?: string;
10
+ maxVerificationRounds?: number;
11
+ }
12
+ export interface VerificationResult {
13
+ blocked: boolean;
14
+ answer: string;
15
+ verifierSessionIDs: string[];
16
+ blockers: string[];
17
+ }
18
+ export declare function buildEvidenceVerificationPrompt(task: string, report: string, mode: VerificationOptions["mode"]): string;
19
+ export declare function parseVerificationOutput(text: string): {
20
+ status: "PASS" | "BLOCKED" | "UNKNOWN";
21
+ answer: string;
22
+ blockers: string[];
23
+ };
24
+ export declare function verifyReportAutomatically(sessionClient: BoostSessionClient, options: VerificationOptions): Promise<VerificationResult>;
package/dist/verify.js ADDED
@@ -0,0 +1,117 @@
1
+ import { extractAssistantText } from "./parser.js";
2
+ const ANSWER_MARKER = "ANSWER:";
3
+ const SECTION = /^[ \t]*[A-Z][A-Z_ ]*:/;
4
+ export function buildEvidenceVerificationPrompt(task, report, mode) {
5
+ const focus = mode === "coder"
6
+ ? "- Coding: inspect changed files and the git diff, then run the relevant build or tests. A report claiming tests passed is not evidence."
7
+ : mode === "investigate"
8
+ ? "- Investigation: confirm every cited file, symbol, version, and log line exists and supports the claim. Check for stale or contradicted notes."
9
+ : "- Review: confirm every cited path, symbol, and line exists and says what was claimed.";
10
+ return [
11
+ "You are an independent verifier. The report below is untrusted evidence.",
12
+ "Check only claims that would change the final answer, and require primary evidence from the workspace for each.",
13
+ focus,
14
+ "",
15
+ "Reply in exactly this form, nothing else:",
16
+ "STATUS: PASS",
17
+ `${ANSWER_MARKER} <the requested answer, stated plainly, in the language of the task>`,
18
+ "CLAIMS: <one line per checked claim: claim | verified|refuted|unverified | concrete evidence>",
19
+ "or",
20
+ "STATUS: BLOCKED",
21
+ "BLOCKERS: <one line per blocker: what is missing and what is needed>",
22
+ "INCORRECT_CLAIMS: <one line per incorrect claim: claim | what the evidence shows>",
23
+ "",
24
+ "State only the verified position. Omit narration about who was wrong, your own prior mistakes, and confidence language.",
25
+ "",
26
+ `<task>\n${task}\n</task>`,
27
+ "",
28
+ `<untrusted_report>\n${report}\n</untrusted_report>`,
29
+ ].join("\n");
30
+ }
31
+ export function parseVerificationOutput(text) {
32
+ const lines = text.replace(/\r/g, "").split("\n");
33
+ const statusMatch = text.match(/\bSTATUS:\s*(PASS|BLOCKED)\b/i);
34
+ const answerIndex = lines.findIndex((line) => line.trim().startsWith(ANSWER_MARKER));
35
+ const answer = [];
36
+ if (answerIndex >= 0) {
37
+ answer.push(lines[answerIndex].trim().slice(ANSWER_MARKER.length).trim());
38
+ for (let i = answerIndex + 1; i < lines.length; i++) {
39
+ if (SECTION.test(lines[i]))
40
+ break;
41
+ answer.push(lines[i]);
42
+ }
43
+ }
44
+ const blockers = [];
45
+ let collecting = false;
46
+ for (const line of lines) {
47
+ const trimmed = line.trim();
48
+ if (/^(BLOCKERS|INCORRECT_CLAIMS):/i.test(trimmed)) {
49
+ collecting = true;
50
+ const rest = trimmed.replace(/^[A-Z_ ]+:/, "").trim();
51
+ if (rest)
52
+ blockers.push(rest);
53
+ }
54
+ else if (collecting && trimmed && !SECTION.test(line)) {
55
+ blockers.push(trimmed);
56
+ }
57
+ else if (SECTION.test(line)) {
58
+ collecting = false;
59
+ }
60
+ }
61
+ return {
62
+ status: statusMatch ? statusMatch[1].toUpperCase() : "UNKNOWN",
63
+ answer: answer.join("\n").trim(),
64
+ blockers,
65
+ };
66
+ }
67
+ async function runVerifier(sessionClient, title, prompt, options) {
68
+ if (!sessionClient.get)
69
+ throw new Error("Verifier requires a session client");
70
+ const parent = await sessionClient.get({ sessionID: options.sessionID });
71
+ const model = options.modelOverride ?? parent?.model;
72
+ const child = await sessionClient.create({
73
+ parentID: options.sessionID,
74
+ title,
75
+ ...(model ? { model } : {}),
76
+ });
77
+ try {
78
+ await sessionClient.prompt({ sessionID: child.id, text: prompt });
79
+ await sessionClient.wait({ sessionID: child.id });
80
+ const { text, error } = extractAssistantText(await sessionClient.context({ sessionID: child.id }));
81
+ if (error)
82
+ throw new Error(`${title} failed: ${error}`);
83
+ if (!text)
84
+ throw new Error(`${title} returned no verification output`);
85
+ return { sessionID: child.id, text };
86
+ }
87
+ finally {
88
+ await Promise.resolve(sessionClient.interrupt?.({ sessionID: child.id })).catch(() => { });
89
+ }
90
+ }
91
+ export async function verifyReportAutomatically(sessionClient, options) {
92
+ const prompt = buildEvidenceVerificationPrompt(options.task, options.report, options.mode);
93
+ const rounds = Math.max(1, Math.min(3, options.maxVerificationRounds ?? 2));
94
+ const verifierSessionIDs = [];
95
+ let latestAnswer = "";
96
+ let latestBlockers = [];
97
+ for (let round = 1; round <= rounds; round++) {
98
+ const result = await runVerifier(sessionClient, `${options.verifierTitle ?? "Orchestra Verifier"}${round > 1 ? ` Recheck #${round}` : ""}`, `${prompt}\n\nVerification round ${round} of at most ${rounds}. Re-read the workspace from scratch.`, options);
99
+ verifierSessionIDs.push(result.sessionID);
100
+ const parsed = parseVerificationOutput(result.text);
101
+ if (parsed.status === "PASS" && parsed.answer) {
102
+ return { blocked: false, answer: parsed.answer, verifierSessionIDs, blockers: [] };
103
+ }
104
+ latestAnswer = parsed.answer;
105
+ latestBlockers = parsed.blockers;
106
+ if (parsed.status === "BLOCKED")
107
+ break;
108
+ }
109
+ return {
110
+ blocked: true,
111
+ answer: latestAnswer,
112
+ verifierSessionIDs,
113
+ blockers: latestBlockers.length
114
+ ? latestBlockers
115
+ : ["Verification did not produce a definitive verified answer after rechecking"],
116
+ };
117
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-orchestra",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Model-agnostic multi-agent orchestration (/boost, /teamwork, /swarm) plugin for OpenCode V2.",
5
5
  "type": "module",
6
6
  "files": [
@@ -12,6 +12,10 @@
12
12
  ".": {
13
13
  "types": "./dist/index.d.ts",
14
14
  "import": "./dist/index.js"
15
+ },
16
+ "./tui": {
17
+ "types": "./dist/tui.d.ts",
18
+ "import": "./dist/tui.js"
15
19
  }
16
20
  },
17
21
  "scripts": {
@@ -24,7 +28,10 @@
24
28
  "@opencode/plugin": "^2.4.3"
25
29
  },
26
30
  "devDependencies": {
31
+ "@opentui/core": "^0.9.13",
32
+ "@opentui/solid": "^0.9.13",
27
33
  "@types/bun": "latest",
34
+ "solid-js": "1.9.16",
28
35
  "typescript": "^5.8.0"
29
36
  }
30
- }
37
+ }