opencode-swarm 6.28.1 → 6.29.1

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.
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Compaction service — monitors context budget and triggers graduated compaction
3
+ * when usage crosses configured thresholds.
4
+ *
5
+ * Three tiers (all thresholds as percentages 0-100):
6
+ * - Observation (default 40%): summarise older turns, preserve key decisions
7
+ * - Reflection (default 60%): re-summarise into tighter format
8
+ * - Emergency (default 80%): hard truncation to system + current task + last N turns
9
+ *
10
+ * Consumes `swarmState.lastBudgetPct` (set by system-enhancer.ts after each budget calc).
11
+ * Never throws. Advisory system message injection via callback.
12
+ */
13
+ import type { CompactionConfig } from '../config/schema';
14
+ export type { CompactionConfig };
15
+ export interface CompactionServiceHook {
16
+ toolAfter: (input: {
17
+ tool: string;
18
+ sessionID: string;
19
+ }, output: {
20
+ output?: unknown;
21
+ }) => Promise<void>;
22
+ }
23
+ export declare function createCompactionService(config: CompactionConfig, directory: string, injectMessage: (sessionId: string, message: string) => void): CompactionServiceHook;
24
+ export declare function getCompactionMetrics(): {
25
+ compactionCount: number;
26
+ lastSnapshotAt: string | null;
27
+ };
28
+ export declare function resetCompactionState(): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -11,6 +11,12 @@ export interface StatusData {
11
11
  agentCount: number;
12
12
  isLegacy: boolean;
13
13
  turboMode: boolean;
14
+ /** Last known context budget percentage (0-100), or null if not yet measured */
15
+ contextBudgetPct: number | null;
16
+ /** Number of context compaction events triggered this session */
17
+ compactionCount: number;
18
+ /** ISO timestamp of last compaction snapshot, or null if none */
19
+ lastSnapshotAt: string | null;
14
20
  }
15
21
  /**
16
22
  * Get status data from the swarm directory.
package/dist/state.d.ts CHANGED
@@ -116,6 +116,21 @@ export interface AgentSessionState {
116
116
  lastCompletedPhaseAgentsDispatched: Set<string>;
117
117
  /** Session-scoped Turbo Mode flag for controlling LLM inference speed */
118
118
  turboMode: boolean;
119
+ /** Sliding window of last 10 Task delegation hashes for loop detection */
120
+ loopDetectionWindow?: Array<{
121
+ hash: string;
122
+ timestamp: number;
123
+ }>;
124
+ /** Pending loop warning message to inject into next messagesTransform (cleared after injection) */
125
+ loopWarningPending?: {
126
+ agent: string;
127
+ message: string;
128
+ timestamp: number;
129
+ };
130
+ /** Flag to track if the 50% context pressure warning has been sent this session */
131
+ contextPressureWarningSent?: boolean;
132
+ /** Queue of advisory messages (e.g., SLOP, context pressure) pending injection into next messagesTransform */
133
+ pendingAdvisoryMessages?: string[];
119
134
  }
120
135
  /**
121
136
  * Represents a single agent invocation window with isolated guardrail budgets.
@@ -162,6 +177,8 @@ export declare const swarmState: {
162
177
  delegationChains: Map<string, DelegationEntry[]>;
163
178
  /** Number of events since last flush */
164
179
  pendingEvents: number;
180
+ /** Last known context budget percentage (0-100), updated by system-enhancer */
181
+ lastBudgetPct: number;
165
182
  /** Per-session guardrail state — keyed by sessionID */
166
183
  agentSessions: Map<string, AgentSessionState>;
167
184
  };
@@ -44,6 +44,6 @@ export interface TestErrorResult {
44
44
  message?: string;
45
45
  }
46
46
  export type TestResult = TestSuccessResult | TestErrorResult;
47
- export declare function detectTestFramework(cwd?: string): Promise<TestFramework>;
47
+ export declare function detectTestFramework(cwd: string): Promise<TestFramework>;
48
48
  export declare function runTests(framework: TestFramework, scope: 'all' | 'convention' | 'graph', files: string[], coverage: boolean, timeout_ms: number, cwd?: string): Promise<TestResult>;
49
49
  export declare const test_runner: ReturnType<typeof tool>;
@@ -50,6 +50,14 @@ export interface ReviewerGateResult {
50
50
  * @returns ReviewerGateResult indicating whether the gate is blocked
51
51
  */
52
52
  export declare function checkReviewerGate(taskId: string, workingDirectory?: string): ReviewerGateResult;
53
+ /**
54
+ * Wrapper around checkReviewerGate that appends a diff-scope advisory warning.
55
+ * Keeps checkReviewerGate synchronous for backward compatibility.
56
+ * @param taskId - The task ID to check gate state for
57
+ * @param workingDirectory - Optional working directory for plan.json fallback
58
+ * @returns ReviewerGateResult with optional scope warning appended to reason
59
+ */
60
+ export declare function checkReviewerGateWithScope(taskId: string, workingDirectory?: string): Promise<ReviewerGateResult>;
53
61
  /**
54
62
  * Recovery mechanism: reconcile task state with delegation history.
55
63
  * When reviewer/test_engineer delegations occurred but the state machine
@@ -24,6 +24,8 @@ export interface WriteRetroArgs {
24
24
  coder_revisions: number;
25
25
  /** Number of reviewer rejections received */
26
26
  reviewer_rejections: number;
27
+ loop_detections?: number;
28
+ circuit_breaker_trips?: number;
27
29
  /** Number of test failures encountered */
28
30
  test_failures: number;
29
31
  /** Number of security findings */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "6.28.1",
3
+ "version": "6.29.1",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",