opencode-swarm 7.132.2 → 7.133.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.
Files changed (97) hide show
  1. package/README.md +4 -1
  2. package/dist/agents/agent-output-schema.d.ts +74 -0
  3. package/dist/agents/critic.d.ts +2 -1
  4. package/dist/agents/reviewer.d.ts +1 -1
  5. package/dist/background/completion-observer.d.ts +2 -0
  6. package/dist/background/pending-delegations.d.ts +39 -1
  7. package/dist/background/stage-b-gates.d.ts +2 -0
  8. package/dist/cli/{config-doctor-bp5spb79.js → config-doctor-8nbdwnn6.js} +2 -2
  9. package/dist/cli/{core-wg3re04e.js → core-egwpry19.js} +2 -2
  10. package/dist/cli/{curation-policy-7zp2m9gv.js → curation-policy-gae3xm5d.js} +2 -2
  11. package/dist/cli/{curator-h067mrcc.js → curator-e88bm4mg.js} +17 -18
  12. package/dist/cli/{curator-llm-factory-605d08hf.js → curator-llm-factory-1a7esr69.js} +17 -18
  13. package/dist/cli/{evidence-summary-service-jfagmvrh.js → evidence-summary-service-nhsmsap8.js} +3 -3
  14. package/dist/cli/{guardrail-explain-s7vzm6z7.js → guardrail-explain-zgja2b9m.js} +18 -19
  15. package/dist/cli/{guardrail-log-aa112fxv.js → guardrail-log-fjgyx76r.js} +3 -3
  16. package/dist/cli/{hive-promoter-nv0m5rzk.js → hive-promoter-2b04e0wh.js} +17 -18
  17. package/dist/cli/{index-9cf1yr67.js → index-0vd91yb8.js} +3 -3
  18. package/dist/cli/{index-w9cb5zwh.js → index-17zjp67y.js} +1 -1
  19. package/dist/cli/{index-djwemsjn.js → index-66zght9d.js} +1 -1
  20. package/dist/cli/{index-6ccynjv3.js → index-7ftthvqt.js} +2 -2
  21. package/dist/cli/{index-jgfcp9bh.js → index-bz08438z.js} +1 -1
  22. package/dist/cli/{index-mwkwyej1.js → index-cpest8sa.js} +5 -5
  23. package/dist/cli/{index-y5qp59rc.js → index-hfpw5m0e.js} +9 -3
  24. package/dist/cli/{index-3s9rfnqq.js → index-j5pnah1w.js} +4 -4
  25. package/dist/cli/{index-jj4earrh.js → index-kc1m6vpr.js} +2 -2
  26. package/dist/cli/{index-8d3m0ge3.js → index-mhcge2ry.js} +34 -23
  27. package/dist/cli/{index-yvv1wt2h.js → index-mmvaf4t6.js} +1 -1
  28. package/dist/cli/{index-f6480ee6.js → index-mwqfyjja.js} +37751 -33949
  29. package/dist/cli/{index-fgcmxjp7.js → index-sp7tm8t7.js} +1 -1
  30. package/dist/cli/{index-k4tmx21m.js → index-sw82jvf2.js} +2 -2
  31. package/dist/cli/{index-630badhp.js → index-tj2mkfb3.js} +149 -6
  32. package/dist/cli/{index-rt5jgktq.js → index-wz36r0fk.js} +1 -1
  33. package/dist/cli/{index-bvp2v7k1.js → index-wzb4dv5s.js} +263 -16
  34. package/dist/cli/index.js +21 -20
  35. package/dist/cli/{knowledge-escalator-j0nceas7.js → knowledge-escalator-hzkw1ban.js} +3 -3
  36. package/dist/cli/{knowledge-events-gpqc62jr.js → knowledge-events-pbycdhqd.js} +1 -1
  37. package/dist/cli/{knowledge-store-ggxr3ww5.js → knowledge-store-45jawb2p.js} +1 -1
  38. package/dist/cli/{knowledge-validator-007smap6.js → knowledge-validator-ge576f8n.js} +4 -4
  39. package/dist/cli/pending-delegations-kxy8mdqg.js +75 -0
  40. package/dist/cli/{scan-cursor-wz4bff7a.js → scan-cursor-kvw872be.js} +2 -2
  41. package/dist/cli/{schema-023gwne7.js → schema-a2zm2m3r.js} +6 -2
  42. package/dist/cli/{scope-persistence-dm5bab50.js → scope-persistence-5qypzxxm.js} +1 -1
  43. package/dist/cli/{skill-generator-rtsg1m7x.js → skill-generator-ch79hvxh.js} +5 -5
  44. package/dist/commands/command-dispatch.d.ts +7 -0
  45. package/dist/commands/index.d.ts +7 -0
  46. package/dist/commands/registry.d.ts +16 -0
  47. package/dist/commands/review.d.ts +21 -0
  48. package/dist/config/agent-names.d.ts +3 -3
  49. package/dist/config/evidence-schema.d.ts +47 -47
  50. package/dist/config/index.d.ts +2 -2
  51. package/dist/config/schema.d.ts +58 -6
  52. package/dist/consensus/contracts.d.ts +3 -3
  53. package/dist/evaluation/contracts.d.ts +1 -1
  54. package/dist/evaluation/ephemeral-agent-dispatcher.d.ts +64 -0
  55. package/dist/evaluation/model-dispatcher.d.ts +11 -5
  56. package/dist/evaluation/public-api.d.ts +1 -1
  57. package/dist/hooks/auto-review.d.ts +30 -65
  58. package/dist/hooks/delegation-gate.d.ts +1 -1
  59. package/dist/hooks/guardrails/tool-before.d.ts +8 -0
  60. package/dist/hooks/review-receipt-collector.d.ts +53 -10
  61. package/dist/hooks/review-receipt-scope.d.ts +74 -0
  62. package/dist/hooks/review-receipt.d.ts +104 -10
  63. package/dist/hooks/reviewer-scope-file-fingerprint.d.ts +21 -0
  64. package/dist/hooks/reviewer-scope-lifecycle.d.ts +19 -0
  65. package/dist/hooks/task-result-classifier.d.ts +6 -0
  66. package/dist/index.d.ts +2 -0
  67. package/dist/index.js +660 -607
  68. package/dist/memory/schema.d.ts +5 -5
  69. package/dist/review/contracts.d.ts +29 -0
  70. package/dist/review/diff-source.d.ts +134 -0
  71. package/dist/review/engine.d.ts +60 -0
  72. package/dist/review/evidence.d.ts +88 -0
  73. package/dist/review/finding-validator.d.ts +77 -0
  74. package/dist/review/phase-runner.d.ts +37 -0
  75. package/dist/review/runtime.d.ts +32 -0
  76. package/dist/scope/scope-binding.d.ts +9 -0
  77. package/dist/services/config-doctor.d.ts +12 -0
  78. package/dist/state.d.ts +179 -0
  79. package/dist/tools/dispatch-lanes.d.ts +2 -0
  80. package/dist/tools/lean-turbo-review.d.ts +4 -1
  81. package/dist/tools/lean-turbo-run-phase.d.ts +3 -1
  82. package/dist/tools/phase-complete/gates/final-review-gate.d.ts +18 -0
  83. package/dist/tools/phase-complete/gates/index.d.ts +1 -0
  84. package/dist/tools/phase-complete/gates/types.d.ts +10 -0
  85. package/dist/tools/phase-complete.d.ts +13 -1
  86. package/dist/tools/plugin-registration.d.ts +3 -1
  87. package/dist/tools/swarm-command.d.ts +4 -1
  88. package/dist/tools/tool-metadata.d.ts +22 -22
  89. package/dist/turbo/lean/integration.d.ts +18 -2
  90. package/dist/turbo/lean/reviewer.d.ts +19 -3
  91. package/dist/turbo/lean/runner.d.ts +1 -1
  92. package/package.json +1 -1
  93. package/dist/cli/index-y2pfmd0z.js +0 -259
  94. package/dist/cli/pending-delegations-37t4xecr.js +0 -34
  95. package/dist/cli/{curator-drift-y1wm4atk.js → curator-drift-ea0p8nh1.js} +2 -2
  96. package/dist/cli/{index-4ff0x4cg.js → index-74tptrss.js} +0 -0
  97. package/dist/cli/{index-03zyn94g.js → index-r260ybay.js} +4 -4
package/dist/state.d.ts CHANGED
@@ -64,6 +64,54 @@ export interface PrSubscriptionState {
64
64
  * Transitions must be forward-only: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
65
65
  */
66
66
  export type TaskWorkflowState = 'idle' | 'coder_delegated' | 'pre_check_passed' | 'reviewer_run' | 'tests_run' | 'complete';
67
+ /** Exact lifecycle state for one coder generation and its paired reviewer. */
68
+ export interface ReviewerScopeGeneration {
69
+ taskId: string;
70
+ coderCallID: string;
71
+ generation: number;
72
+ sessionIncarnation: string;
73
+ background: boolean;
74
+ declaredFiles: string[];
75
+ modifiedFiles: string[];
76
+ modifiedFileFingerprints: import('./hooks/reviewer-scope-file-fingerprint.js').ReviewerScopeFileFingerprint[];
77
+ status: 'collecting' | 'ready' | 'claimed';
78
+ createdAt: number;
79
+ readyAt?: number;
80
+ reviewerCallID?: string;
81
+ reviewerDispatchScope?: ReviewerScopeDispatchSnapshot;
82
+ }
83
+ export interface ReviewerScopeDispatchSnapshot {
84
+ hash: string;
85
+ description: string;
86
+ files: string[];
87
+ headSha: string;
88
+ taskId: string;
89
+ coderCallID: string;
90
+ generation: number;
91
+ sessionIncarnation: string;
92
+ }
93
+ export interface ReviewerScopeGenerationIdentity {
94
+ generation: number;
95
+ coderCallID: string;
96
+ sessionIncarnation: string;
97
+ }
98
+ /**
99
+ * Immutable ownership provenance retained after a background generation's
100
+ * reviewer consumes the live handoff. Delayed sibling completion ingestion may
101
+ * consult this bounded history, but only exact fingerprints and overlapping
102
+ * dispatch intervals can establish ownership.
103
+ */
104
+ export interface ReviewerScopeOwnershipTombstone extends ReviewerScopeGenerationIdentity {
105
+ parentSessionID: string;
106
+ taskId: string;
107
+ background: true;
108
+ declaredFiles: string[];
109
+ modifiedFiles: string[];
110
+ modifiedFileFingerprints: import('./hooks/reviewer-scope-file-fingerprint.js').ReviewerScopeFileFingerprint[];
111
+ createdAt: number;
112
+ readyAt: number;
113
+ consumedAt: number;
114
+ }
67
115
  /**
68
116
  * Represents per-session state for guardrail tracking.
69
117
  * Budget fields (toolCallCount, consecutiveErrors, etc.) have moved to InvocationWindow.
@@ -172,6 +220,16 @@ export interface AgentSessionState {
172
220
  scopeViolationDetected?: boolean;
173
221
  /** Files modified by the current coder task (populated by guardrails toolBefore/toolAfter, reset on new coder delegation) */
174
222
  modifiedFilesThisCoderTask: string[];
223
+ /** Bounded coder generations awaiting exact reviewer claims. */
224
+ reviewerScopeGenerations?: Map<string, ReviewerScopeGeneration>;
225
+ /** Monotonic per-session generation source; call identity remains authoritative. */
226
+ reviewerScopeGenerationCounter?: number;
227
+ /** Non-reused identity for this in-memory parent-session incarnation. */
228
+ reviewerScopeIncarnation?: string;
229
+ /** Latest generation token by task, retained through async validation. */
230
+ reviewerScopeLatestGenerationByTask?: Map<string, ReviewerScopeGenerationIdentity>;
231
+ /** Bounded recent background ownership retained after reviewer consumption. */
232
+ reviewerScopeOwnershipHistory?: Map<string, ReviewerScopeOwnershipTombstone>;
175
233
  /** Number of coder revisions in the current task (incremented on each coder delegation completion) */
176
234
  coderRevisions: number;
177
235
  /** Flag set when coder revisions hit the configured ceiling */
@@ -449,6 +507,127 @@ export declare function resetSwarmState(): void;
449
507
  * propagate to caller (no try/catch wrapper).
450
508
  */
451
509
  export declare function resetSwarmStatePreservingSingletons(): void;
510
+ /** Match the Stage-B scope builder's hard file-count ceiling. */
511
+ export declare const MAX_REVIEWER_SCOPE_GENERATION_FILES = 256;
512
+ /** One parent session may retain at most this many parallel task generations. */
513
+ export declare const MAX_REVIEWER_SCOPE_GENERATIONS = 256;
514
+ /** Recent consumed owners are bounded to the maximum parallel generation set. */
515
+ export declare const MAX_REVIEWER_SCOPE_OWNERSHIP_HISTORY = 256;
516
+ /** Generation expiry never exceeds the parent session's normal idle TTL. */
517
+ export declare const REVIEWER_SCOPE_GENERATION_TTL_MS = 7200000;
518
+ /** Begin one exact coder generation after the full blocking before-chain passes. */
519
+ export declare function startReviewerScopeGeneration(input: {
520
+ parentSessionID: string;
521
+ taskId: string;
522
+ coderCallID: string;
523
+ background?: boolean;
524
+ declaredFiles?: string[];
525
+ createdAt?: number;
526
+ }): ReviewerScopeGeneration | null;
527
+ /** Route one child-observed write to its exact parent/task/coder generation. */
528
+ export declare function recordReviewerScopeGenerationFile(input: {
529
+ parentSessionID: string;
530
+ taskId: string;
531
+ coderCallID: string;
532
+ file: string;
533
+ now?: number;
534
+ }): boolean;
535
+ /**
536
+ * Record the bounded post-write state only after a guarded child write returns
537
+ * successfully. Pre-write routing in modifiedFiles remains authorization metadata.
538
+ */
539
+ export declare function recordReviewerScopeGenerationFileFingerprint(input: {
540
+ parentSessionID: string;
541
+ taskId: string;
542
+ coderCallID: string;
543
+ fingerprint: import('./hooks/reviewer-scope-file-fingerprint.js').ReviewerScopeFileFingerprint;
544
+ }): boolean;
545
+ /** Mark the exact coder call terminal; background running placeholders do not call this. */
546
+ export declare function markReviewerScopeGenerationReady(input: {
547
+ parentSessionID: string;
548
+ taskId: string;
549
+ coderCallID: string;
550
+ readyAt?: number;
551
+ }): boolean;
552
+ /** Read one exact coder generation for terminal guardrail/evidence checks. */
553
+ export declare function getReviewerScopeGenerationForCoderCall(input: {
554
+ parentSessionID: string;
555
+ taskId?: string;
556
+ coderCallID: string;
557
+ now?: number;
558
+ }): ReviewerScopeGeneration | null;
559
+ /** Inspect the only ready generation for a task without claiming it. */
560
+ export declare function peekReadyReviewerScopeGeneration(input: {
561
+ parentSessionID: string;
562
+ taskId: string;
563
+ now?: number;
564
+ }): ReviewerScopeGeneration | null;
565
+ /**
566
+ * Claim the only ready generation for an exact task after every blocking
567
+ * reviewer before-hook has passed. Ambiguity fails closed to no receipt.
568
+ */
569
+ export declare function claimReviewerScopeGeneration(input: {
570
+ parentSessionID: string;
571
+ taskId: string;
572
+ reviewerCallID: string;
573
+ now?: number;
574
+ }): ReviewerScopeGeneration | null;
575
+ /** Bind the immutable scope captured immediately before the reviewer Task dispatch. */
576
+ export declare function attachReviewerScopeGenerationDispatchSnapshot(input: {
577
+ parentSessionID: string;
578
+ taskId: string;
579
+ reviewerCallID: string;
580
+ snapshot: ReviewerScopeDispatchSnapshot;
581
+ }): boolean;
582
+ /** Terminal one-shot consumption by exact task and reviewer Task call. */
583
+ export declare function takeReviewerScopeGeneration(input: {
584
+ parentSessionID: string;
585
+ taskId: string;
586
+ reviewerCallID: string;
587
+ now?: number;
588
+ }): ReviewerScopeGeneration | null;
589
+ /** Read bounded immutable ownership history for delayed background ingestion. */
590
+ export declare function getReviewerScopeOwnershipHistory(input: {
591
+ parentSessionID: string;
592
+ }): ReviewerScopeOwnershipTombstone[];
593
+ /** Inspect one exact reviewer claim without consuming retryable state. */
594
+ export declare function peekReviewerScopeGenerationClaim(input: {
595
+ parentSessionID: string;
596
+ taskId: string;
597
+ reviewerCallID: string;
598
+ now?: number;
599
+ }): ReviewerScopeGeneration | null;
600
+ /** Clear one exact terminal/stale reviewer claim without touching parallel tasks. */
601
+ export declare function discardReviewerScopeGenerationClaim(input: {
602
+ parentSessionID: string;
603
+ taskId?: string;
604
+ reviewerCallID: string;
605
+ }): boolean;
606
+ /**
607
+ * Detect a concurrently collecting coder generation whose declaration overlaps
608
+ * this exact coder call. Shared declared paths cannot be attributed safely from
609
+ * one workspace snapshot, even when child write routing observed both calls.
610
+ */
611
+ export declare function reviewerScopeGenerationHasDeclaredOverlap(input: {
612
+ parentSessionID: string;
613
+ taskId: string;
614
+ coderCallID: string;
615
+ declaredFiles: string[];
616
+ }): boolean;
617
+ /** Clear one exact collecting/ready coder generation on terminal error/stale. */
618
+ export declare function discardReviewerScopeGenerationForCoderCall(input: {
619
+ parentSessionID: string;
620
+ taskId?: string;
621
+ coderCallID: string;
622
+ }): boolean;
623
+ /** Validate an async result against the latest coder generation for its task. */
624
+ export declare function isReviewerScopeGenerationCurrent(input: {
625
+ parentSessionID: string;
626
+ taskId: string;
627
+ coderCallID: string;
628
+ generation: number;
629
+ sessionIncarnation: string;
630
+ }): boolean;
452
631
  /**
453
632
  * Evict every agent session whose last tool activity is older than
454
633
  * staleDurationMs, and drop the delegation chain keyed by that same sessionID
@@ -256,6 +256,7 @@ export declare const _test_exports: {
256
256
  applyCommonPrompt: typeof applyCommonPrompt;
257
257
  applyExplorerFormatSuffix: typeof applyExplorerFormatSuffix;
258
258
  applyPrWorkflowPromptContract: typeof applyPrWorkflowPromptContract;
259
+ buildCollectResult: typeof buildCollectResult;
259
260
  buildReadOnlyTools: typeof buildReadOnlyTools;
260
261
  buildLaneSessionCreateArgs: typeof buildLaneSessionCreateArgs;
261
262
  extractAssistantTranscript: typeof extractAssistantTranscript;
@@ -341,6 +342,7 @@ declare function extractAssistantTranscript(messages: Array<{
341
342
  transcriptIncomplete: boolean;
342
343
  };
343
344
  declare function nextCollectPollInterval(currentMs: number): number;
345
+ declare function buildCollectResult(batchId: string, records: BackgroundDelegationRecord[], includePending: boolean): CollectLaneResultsResult;
344
346
  declare function recordToLaneResult(record: BackgroundDelegationRecord, batchId: string): DispatchLaneResult;
345
347
  declare function buildReadOnlyTools(): ReadOnlyToolPermissions;
346
348
  type ApplyCommonPromptResult = {
@@ -4,6 +4,8 @@
4
4
  * Dispatches a read-only reviewer agent to evaluate a completed Lean Turbo phase.
5
5
  */
6
6
  import type { ToolDefinition } from '@opencode-ai/plugin/tool';
7
+ import type { ReviewModelDispatcher } from '../review/contracts.js';
8
+ import type { ReviewAgentModelRegistry } from '../review/runtime.js';
7
9
  import { type PhaseReviewerResult } from '../turbo/lean/reviewer';
8
10
  /**
9
11
  * Arguments for the lean_turbo_review tool
@@ -27,8 +29,9 @@ export interface LeanTurboReviewResult {
27
29
  * Execute the lean_turbo_review tool.
28
30
  * Dispatches a read-only reviewer agent to evaluate a completed Lean Turbo phase.
29
31
  */
30
- export declare function executeLeanTurboReview(args: LeanTurboReviewArgs): Promise<LeanTurboReviewResult>;
32
+ export declare function executeLeanTurboReview(args: LeanTurboReviewArgs, dispatcher?: ReviewModelDispatcher, generatedAgentNames?: readonly string[], agentModelRegistry?: ReviewAgentModelRegistry, activeAgentName?: string): Promise<LeanTurboReviewResult>;
31
33
  /**
32
34
  * Tool definition for lean_turbo_review
33
35
  */
36
+ export declare function createLeanTurboReviewTool(dispatcher?: ReviewModelDispatcher, generatedAgentNames?: readonly string[], agentModelRegistry?: ReviewAgentModelRegistry, getActiveAgentName?: (sessionID: string) => string | undefined): ToolDefinition;
34
37
  export declare const lean_turbo_review: ToolDefinition;
@@ -36,6 +36,7 @@ export interface LeanTurboRunPhaseResult {
36
36
  /**
37
37
  * Test-only dependency-injection seam.
38
38
  * Allows tests to inject mocks without mock.module leakage.
39
+ * @tool-opt-out Test-only dependency-injection seam; not a public tool.
39
40
  */
40
41
  export declare const _internals: {
41
42
  LeanTurboRunner: typeof LeanTurboRunner_import;
@@ -45,8 +46,9 @@ export declare const _internals: {
45
46
  * Execute the lean_turbo_run_phase tool.
46
47
  * Creates a LeanTurboRunner and executes the specified phase.
47
48
  */
48
- export declare function executeLeanTurboRunPhase(args: LeanTurboRunPhaseArgs): Promise<LeanTurboRunPhaseResult>;
49
+ export declare function executeLeanTurboRunPhase(args: LeanTurboRunPhaseArgs, generatedAgentNames?: readonly string[]): Promise<LeanTurboRunPhaseResult>;
49
50
  /**
50
51
  * Tool definition for lean_turbo_run_phase
51
52
  */
53
+ export declare function createLeanTurboRunPhaseTool(generatedAgentNames?: readonly string[]): ToolDefinition;
52
54
  export declare const lean_turbo_run_phase: ToolDefinition;
@@ -0,0 +1,18 @@
1
+ import { collectReviewDiff } from '../../../review/diff-source.js';
2
+ import type { GateContext, GateResult } from './types.js';
3
+ /**
4
+ * Evidence-only final review gate.
5
+ *
6
+ * The model dispatch belongs to the phase_complete tool body. This gate performs
7
+ * one bounded, model-free scope collection at the terminal decision point, then
8
+ * verifies that the persisted artifact and in-memory result both describe that
9
+ * current scope and that the configured blocking policy is satisfied.
10
+ */
11
+ export declare function runFinalReviewGate(ctx: GateContext): Promise<GateResult>;
12
+ /**
13
+ * File-scoped injection seam. Production always uses the bounded Git collector;
14
+ * tests replace only this boundary to avoid process-global module mocks.
15
+ */
16
+ export declare const _internals: {
17
+ collectReviewDiff: typeof collectReviewDiff;
18
+ };
@@ -6,6 +6,7 @@ export { runArchitectureSupervisorGate } from './architecture-supervisor-gate.js
6
6
  export { runCompletionVerifyGate } from './completion-verify-gate.js';
7
7
  export { runDriftGate } from './drift-gate.js';
8
8
  export { runFinalCouncilGate } from './final-council-gate.js';
9
+ export { runFinalReviewGate } from './final-review-gate.js';
9
10
  export { runHallucinationGate } from './hallucination-gate.js';
10
11
  export { runMutationGate } from './mutation-gate.js';
11
12
  export { runPhaseCouncilGate } from './phase-council-gate.js';
@@ -40,4 +40,14 @@ export interface GateContext {
40
40
  loadedRetroBundle?: import('../../../config/evidence-schema').EvidenceBundle | null;
41
41
  /** Task id for the accepted retrospective bundle, if one was loaded */
42
42
  loadedRetroTaskId?: string | null;
43
+ /** Exact scope produced by the model-dispatching phase_complete body. */
44
+ autoReviewScopeHash?: string;
45
+ /** Completeness of the freshly collected in-memory review scope. */
46
+ autoReviewScopeComplete?: boolean;
47
+ /** Distinguishes ordinary phase review from the final durable plan phase. */
48
+ autoReviewTrigger?: 'phase_completion' | 'plan_completion';
49
+ /** Fresh in-memory disposition from the review run owned by phase_complete. */
50
+ autoReviewBlocked?: boolean;
51
+ /** Machine-readable reason from the current review run, when blocked. */
52
+ autoReviewBlockReason?: import('../../../review/engine').ReviewEngineResult['blockReason'];
43
53
  }
@@ -3,6 +3,8 @@
3
3
  * Core implementation - gathers data, enforces policy, writes event, resets state.
4
4
  */
5
5
  import type { ToolDefinition } from '@opencode-ai/plugin/tool';
6
+ import type { ReviewModelDispatcher } from '../review/contracts.js';
7
+ import type { ReviewAgentModelRegistry } from '../review/runtime.js';
6
8
  /**
7
9
  * Arguments for the phase_complete tool
8
10
  */
@@ -24,6 +26,14 @@ export interface PhaseCompleteArgs {
24
26
  /** Calling agent identity (from tool ctx) — gates the override to the architect. */
25
27
  callerAgent?: string;
26
28
  }
29
+ export interface PhaseCompleteRuntime {
30
+ reviewModelDispatcher?: ReviewModelDispatcher;
31
+ generatedAgentNames?: readonly string[];
32
+ reviewAgentModelRegistry?: ReviewAgentModelRegistry;
33
+ getActiveAgentName?: (sessionID: string) => string | undefined;
34
+ }
35
+ declare function resolvePhaseReviewAgentNames(runtime: PhaseCompleteRuntime): Iterable<string>;
36
+ /** @tool-opt-out Output-size constant, not a tool definition. */
27
37
  export declare const MAX_OUTPUT_BYTES = 512000;
28
38
  declare function allCompletedTasksHavePassedGateEvidence(directory: string, tasks: Array<{
29
39
  id: string;
@@ -33,7 +43,7 @@ declare function allCompletedTasksHavePassedGateEvidence(directory: string, task
33
43
  * Execute the phase_complete tool
34
44
  * Gathers data, enforces policy, writes event, resets state
35
45
  */
36
- export declare function executePhaseComplete(args: PhaseCompleteArgs, workingDirectory?: string, directory?: string): Promise<string>;
46
+ export declare function executePhaseComplete(args: PhaseCompleteArgs, workingDirectory?: string, directory?: string, runtime?: PhaseCompleteRuntime): Promise<string>;
37
47
  /** @internal exported for testing only */
38
48
  export declare function _buildOutputJson(outputData: {
39
49
  phase: number;
@@ -50,8 +60,10 @@ export declare function _buildOutputJson(outputData: {
50
60
  /**
51
61
  * Tool definition for phase_complete
52
62
  */
63
+ export declare function createPhaseCompleteTool(runtime?: PhaseCompleteRuntime): ToolDefinition;
53
64
  export declare const phase_complete: ToolDefinition;
54
65
  export declare const _test_exports: {
55
66
  allCompletedTasksHavePassedGateEvidence: typeof allCompletedTasksHavePassedGateEvidence;
67
+ resolvePhaseReviewAgentNames: typeof resolvePhaseReviewAgentNames;
56
68
  };
57
69
  export {};
@@ -12,6 +12,8 @@ import type { ToolDefinition } from '@opencode-ai/plugin/tool';
12
12
  import type { AgentDefinition } from '../agents/index.js';
13
13
  import type { PluginConfig } from '../config/index.js';
14
14
  import type { EvaluationModelDispatcher } from '../evaluation/model-dispatcher.js';
15
+ import type { ReviewModelDispatcher } from '../review/contracts.js';
16
+ import type { ReviewAgentModelRegistry } from '../review/runtime.js';
15
17
  /**
16
18
  * Construct the plugin tool object: one handler per manifest entry, with
17
19
  * `swarm_command` overridden by its dependency-injected instance.
@@ -22,4 +24,4 @@ import type { EvaluationModelDispatcher } from '../evaluation/model-dispatcher.j
22
24
  *
23
25
  * Knowledge tools are conditionally excluded when config.knowledge.enabled = false.
24
26
  */
25
- export declare function buildPluginToolObject(agents: Record<string, AgentDefinition>, config?: PluginConfig, evaluationModelDispatcher?: EvaluationModelDispatcher): Record<string, ToolDefinition>;
27
+ export declare function buildPluginToolObject(agents: Record<string, AgentDefinition>, config?: PluginConfig, evaluationModelDispatcher?: EvaluationModelDispatcher, reviewModelDispatcher?: ReviewModelDispatcher, generatedAgentNames?: Iterable<string>, reviewAgentModelRegistry?: ReviewAgentModelRegistry, getActiveAgentName?: (sessionID: string) => string | undefined): Record<string, ToolDefinition>;
@@ -1,5 +1,8 @@
1
1
  import type { AgentDefinition } from '../agents/index.js';
2
+ import type { AutoReviewConfig } from '../config/schema.js';
2
3
  import type { EvaluationModelDispatcher } from '../evaluation/model-dispatcher.js';
4
+ import type { ReviewModelDispatcher } from '../review/contracts.js';
5
+ import type { ReviewAgentModelRegistry } from '../review/runtime.js';
3
6
  import { createSwarmTool } from './create-tool.js';
4
- export declare function createSwarmCommandTool(agents: Record<string, AgentDefinition>, evaluationModelDispatcher?: EvaluationModelDispatcher): ReturnType<typeof createSwarmTool>;
7
+ export declare function createSwarmCommandTool(agents: Record<string, AgentDefinition>, evaluationModelDispatcher?: EvaluationModelDispatcher, reviewModelDispatcher?: ReviewModelDispatcher, autoReviewConfig?: AutoReviewConfig, reviewAgentModelRegistry?: ReviewAgentModelRegistry, getActiveAgentName?: (sessionID: string) => string | undefined): ReturnType<typeof createSwarmTool>;
5
8
  export declare const swarm_command: ReturnType<typeof createSwarmTool>;
@@ -34,7 +34,7 @@ export interface ToolMeta {
34
34
  export declare const TOOL_METADATA: {
35
35
  diff: {
36
36
  description: string;
37
- agents: ("reviewer" | "test_engineer" | "coder" | "critic_oversight" | "architect")[];
37
+ agents: ("reviewer" | "test_engineer" | "coder" | "critic_oversight" | "critic_finding_validator" | "architect")[];
38
38
  prWorkflow: {
39
39
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
40
40
  capability: "observe";
@@ -42,7 +42,7 @@ export declare const TOOL_METADATA: {
42
42
  };
43
43
  diff_summary: {
44
44
  description: string;
45
- agents: ("reviewer" | "critic_oversight" | "architect")[];
45
+ agents: ("reviewer" | "critic_oversight" | "critic_finding_validator" | "architect")[];
46
46
  prWorkflow: {
47
47
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
48
48
  capability: "observe";
@@ -58,7 +58,7 @@ export declare const TOOL_METADATA: {
58
58
  };
59
59
  placeholder_scan: {
60
60
  description: string;
61
- agents: ("reviewer" | "architect")[];
61
+ agents: ("reviewer" | "critic_finding_validator" | "architect")[];
62
62
  prWorkflow: {
63
63
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
64
64
  capability: "observe";
@@ -66,7 +66,7 @@ export declare const TOOL_METADATA: {
66
66
  };
67
67
  imports: {
68
68
  description: string;
69
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "architect" | "researcher" | "docs_design")[];
69
+ agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_finding_validator" | "architect" | "researcher" | "docs_design")[];
70
70
  prWorkflow: {
71
71
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
72
72
  capability: "observe";
@@ -74,7 +74,7 @@ export declare const TOOL_METADATA: {
74
74
  };
75
75
  lint: {
76
76
  description: string;
77
- agents: ("reviewer" | "coder" | "architect")[];
77
+ agents: ("reviewer" | "coder" | "critic_finding_validator" | "architect")[];
78
78
  prWorkflow: {
79
79
  modes: "PR_REVIEW"[];
80
80
  capability: "validate";
@@ -82,7 +82,7 @@ export declare const TOOL_METADATA: {
82
82
  };
83
83
  secretscan: {
84
84
  description: string;
85
- agents: ("reviewer" | "critic_oversight" | "architect")[];
85
+ agents: ("reviewer" | "critic_oversight" | "critic_finding_validator" | "architect")[];
86
86
  prWorkflow: {
87
87
  modes: "PR_REVIEW"[];
88
88
  capability: "validate";
@@ -90,7 +90,7 @@ export declare const TOOL_METADATA: {
90
90
  };
91
91
  sast_scan: {
92
92
  description: string;
93
- agents: ("reviewer" | "critic_oversight" | "architect")[];
93
+ agents: ("reviewer" | "critic_oversight" | "critic_finding_validator" | "architect")[];
94
94
  prWorkflow: {
95
95
  modes: "PR_REVIEW"[];
96
96
  capability: "validate";
@@ -102,7 +102,7 @@ export declare const TOOL_METADATA: {
102
102
  };
103
103
  pre_check_batch: {
104
104
  description: string;
105
- agents: ("reviewer" | "architect")[];
105
+ agents: ("reviewer" | "critic_finding_validator" | "architect")[];
106
106
  };
107
107
  quality_budget: {
108
108
  description: string;
@@ -114,11 +114,11 @@ export declare const TOOL_METADATA: {
114
114
  };
115
115
  symbols: {
116
116
  description: string;
117
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "architect" | "researcher" | "docs_design" | "spec_writer")[];
117
+ agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_finding_validator" | "architect" | "researcher" | "docs_design" | "spec_writer")[];
118
118
  };
119
119
  complexity_hotspots: {
120
120
  description: string;
121
- agents: ("reviewer" | "test_engineer" | "explorer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_oversight" | "architect" | "researcher")[];
121
+ agents: ("reviewer" | "test_engineer" | "explorer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_oversight" | "critic_finding_validator" | "architect" | "researcher")[];
122
122
  };
123
123
  schema_drift: {
124
124
  description: string;
@@ -186,7 +186,7 @@ export declare const TOOL_METADATA: {
186
186
  };
187
187
  pkg_audit: {
188
188
  description: string;
189
- agents: ("reviewer" | "test_engineer" | "critic_hallucination_verifier" | "critic_oversight" | "architect")[];
189
+ agents: ("reviewer" | "test_engineer" | "critic_hallucination_verifier" | "critic_oversight" | "critic_finding_validator" | "architect")[];
190
190
  prWorkflow: {
191
191
  modes: "PR_REVIEW"[];
192
192
  capability: "validate";
@@ -214,7 +214,7 @@ export declare const TOOL_METADATA: {
214
214
  };
215
215
  test_runner: {
216
216
  description: string;
217
- agents: ("reviewer" | "test_engineer" | "architect")[];
217
+ agents: ("reviewer" | "test_engineer" | "critic_finding_validator" | "architect")[];
218
218
  prWorkflow: {
219
219
  modes: "PR_REVIEW"[];
220
220
  capability: "validate";
@@ -222,7 +222,7 @@ export declare const TOOL_METADATA: {
222
222
  };
223
223
  test_impact: {
224
224
  description: string;
225
- agents: ("reviewer" | "test_engineer" | "critic_oversight" | "architect")[];
225
+ agents: ("reviewer" | "test_engineer" | "critic_oversight" | "critic_finding_validator" | "architect")[];
226
226
  prWorkflow: {
227
227
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
228
228
  capability: "observe";
@@ -242,7 +242,7 @@ export declare const TOOL_METADATA: {
242
242
  };
243
243
  git_blame: {
244
244
  description: string;
245
- agents: ("reviewer" | "explorer" | "architect")[];
245
+ agents: ("reviewer" | "explorer" | "critic_finding_validator" | "architect")[];
246
246
  prWorkflow: {
247
247
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
248
248
  capability: "observe";
@@ -258,7 +258,7 @@ export declare const TOOL_METADATA: {
258
258
  };
259
259
  retrieve_summary: {
260
260
  description: string;
261
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "architect" | "docs_design" | "spec_writer")[];
261
+ agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_finding_validator" | "architect" | "docs_design" | "spec_writer")[];
262
262
  prWorkflow: {
263
263
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
264
264
  capability: "observe";
@@ -338,7 +338,7 @@ export declare const TOOL_METADATA: {
338
338
  };
339
339
  knowledge_recall: {
340
340
  description: string;
341
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_oversight" | "architect" | "docs_design" | "curator_init" | "curator_phase" | "skill_improver" | "spec_writer")[];
341
+ agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_oversight" | "critic_finding_validator" | "architect" | "docs_design" | "curator_init" | "curator_phase" | "skill_improver" | "spec_writer")[];
342
342
  };
343
343
  knowledge_remove: {
344
344
  description: string;
@@ -354,7 +354,7 @@ export declare const TOOL_METADATA: {
354
354
  };
355
355
  search: {
356
356
  description: string;
357
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic_hallucination_verifier" | "critic_oversight" | "architect" | "researcher" | "docs_design" | "skill_improver" | "spec_writer")[];
357
+ agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic_hallucination_verifier" | "critic_oversight" | "critic_finding_validator" | "architect" | "researcher" | "docs_design" | "skill_improver" | "spec_writer")[];
358
358
  };
359
359
  ast_grep: {
360
360
  description: string;
@@ -394,11 +394,11 @@ export declare const TOOL_METADATA: {
394
394
  };
395
395
  batch_symbols: {
396
396
  description: string;
397
- agents: ("reviewer" | "explorer" | "critic_hallucination_verifier" | "critic_oversight" | "architect")[];
397
+ agents: ("reviewer" | "explorer" | "critic_hallucination_verifier" | "critic_oversight" | "critic_finding_validator" | "architect")[];
398
398
  };
399
399
  suggest_patch: {
400
400
  description: string;
401
- agents: ("reviewer" | "architect")[];
401
+ agents: ("reviewer" | "critic_finding_validator" | "architect")[];
402
402
  };
403
403
  req_coverage: {
404
404
  description: string;
@@ -410,7 +410,7 @@ export declare const TOOL_METADATA: {
410
410
  };
411
411
  repo_map: {
412
412
  description: string;
413
- agents: ("reviewer" | "coder" | "explorer" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_oversight" | "architect")[];
413
+ agents: ("reviewer" | "coder" | "explorer" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_oversight" | "critic_finding_validator" | "architect")[];
414
414
  prWorkflow: {
415
415
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
416
416
  capability: "observe";
@@ -478,7 +478,7 @@ export declare const TOOL_METADATA: {
478
478
  };
479
479
  knowledge_receipt: {
480
480
  description: string;
481
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "architect" | "docs_design" | "curator_init" | "curator_phase" | "skill_improver" | "spec_writer")[];
481
+ agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_finding_validator" | "architect" | "docs_design" | "curator_init" | "curator_phase" | "skill_improver" | "spec_writer")[];
482
482
  };
483
483
  knowledge_archive: {
484
484
  description: string;
@@ -494,7 +494,7 @@ export declare const TOOL_METADATA: {
494
494
  };
495
495
  swarm_command: {
496
496
  description: string;
497
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic" | "architect" | "researcher" | "docs_design")[];
497
+ agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic" | "critic_finding_validator" | "architect" | "researcher" | "docs_design")[];
498
498
  };
499
499
  dispatch_lanes: {
500
500
  description: string;
@@ -1,3 +1,5 @@
1
+ import type { ReviewModelDispatcher } from '../../review/contracts';
2
+ import { type ReviewAgentModelRegistry } from '../../review/runtime';
1
3
  import { type ModelOverride } from '../../utils/model-dispatch-fallback';
2
4
  import { type LaneEvidence, listLaneEvidence, readPhaseEvidence, type ValidationArtifact } from './evidence';
3
5
  /**
@@ -15,6 +17,20 @@ export interface LeanTurboPhaseCriticConfig {
15
17
  * Default: no timeout (critic is awaited indefinitely).
16
18
  */
17
19
  timeoutMs?: number;
20
+ /**
21
+ * Instance-local dispatcher bound to the active plugin client.
22
+ * New runtime call paths inject this instead of reading global client state.
23
+ */
24
+ dispatcher?: ReviewModelDispatcher;
25
+ /**
26
+ * Immutable agent-name registry captured by the plugin instance.
27
+ * Direct callers may omit this only when a single/default critic suffices.
28
+ */
29
+ generatedAgentNames?: readonly string[];
30
+ /** Exact active agent identity used to select this session's swarm. */
31
+ activeAgentName?: string;
32
+ /** Immutable plugin-instance model configuration for fallback ownership. */
33
+ agentModelRegistry?: ReviewAgentModelRegistry;
18
34
  }
19
35
  /**
20
36
  * Result of a phase critic dispatch.
@@ -43,7 +59,7 @@ interface ReviewerEvidence {
43
59
  * for the default swarm. Follows the same suffix-based resolution used by
44
60
  * `getCanonicalAgentRole` so that arbitrary swarm prefixes are handled correctly.
45
61
  */
46
- declare function resolveDefaultCriticAgent(generatedAgentNames: string[]): string;
62
+ declare function resolveDefaultCriticAgent(generatedAgentNames: readonly string[], activeAgentName?: string): string;
47
63
  /**
48
64
  * Reads the reviewer evidence from .swarm/evidence/{phase}/lean-turbo-reviewer.json.
49
65
  *
@@ -114,7 +130,7 @@ export declare const _internals: {
114
130
  compileCriticPackage: typeof compileCriticPackage;
115
131
  parseCriticVerdict: typeof parseCriticVerdict;
116
132
  writeCriticEvidence: typeof writeCriticEvidence;
117
- dispatchCriticAgent: (directory: string, pkg: CriticPackage, agentName: string, timeoutMs: number, parentSessionId?: string, model?: ModelOverride) => Promise<string>;
133
+ dispatchCriticAgent: (directory: string, pkg: CriticPackage, agentName: string, timeoutMs: number, parentSessionId?: string, model?: ModelOverride, dispatcher?: ReviewModelDispatcher) => Promise<string>;
118
134
  resolveDefaultCriticAgent: typeof resolveDefaultCriticAgent;
119
135
  readReviewerEvidence: typeof readReviewerEvidence;
120
136
  listLaneEvidence: typeof listLaneEvidence;