opencode-swarm 4.2.0 → 4.3.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.
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Shared state module for OpenCode Swarm plugin.
3
+ * Provides a module-scoped singleton for cross-hook state sharing.
4
+ *
5
+ * This module is used by multiple hooks (tool.execute.before, tool.execute.after,
6
+ * chat.message, system-enhancer) to share state like active agents, tool call tracking,
7
+ * and delegation chains.
8
+ */
9
+ /**
10
+ * Represents a single tool call entry for tracking purposes
11
+ */
12
+ export interface ToolCallEntry {
13
+ tool: string;
14
+ sessionID: string;
15
+ callID: string;
16
+ startTime: number;
17
+ }
18
+ /**
19
+ * Aggregated statistics for a specific tool
20
+ */
21
+ export interface ToolAggregate {
22
+ tool: string;
23
+ count: number;
24
+ successCount: number;
25
+ failureCount: number;
26
+ totalDuration: number;
27
+ }
28
+ /**
29
+ * Represents a delegation from one agent to another
30
+ */
31
+ export interface DelegationEntry {
32
+ from: string;
33
+ to: string;
34
+ timestamp: number;
35
+ }
36
+ /**
37
+ * Singleton state object for sharing data across hooks
38
+ */
39
+ export declare const swarmState: {
40
+ /** Active tool calls — keyed by callID for before→after correlation */
41
+ activeToolCalls: Map<string, ToolCallEntry>;
42
+ /** Aggregated tool usage stats — keyed by tool name */
43
+ toolAggregates: Map<string, ToolAggregate>;
44
+ /** Active agent per session — keyed by sessionID, updated by chat.message hook */
45
+ activeAgent: Map<string, string>;
46
+ /** Delegation chains per session — keyed by sessionID */
47
+ delegationChains: Map<string, DelegationEntry[]>;
48
+ /** Number of events since last flush */
49
+ pendingEvents: number;
50
+ };
51
+ /**
52
+ * Reset all state to initial values - useful for testing
53
+ */
54
+ export declare function resetSwarmState(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
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",