opencode-swarm-plugin 0.21.0 → 0.23.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/.turbo/turbo-build.log +9 -0
- package/CHANGELOG.md +12 -0
- package/README.md +111 -166
- package/dist/agent-mail.d.ts +480 -0
- package/dist/agent-mail.d.ts.map +1 -0
- package/dist/anti-patterns.d.ts +257 -0
- package/dist/anti-patterns.d.ts.map +1 -0
- package/dist/beads.d.ts +377 -0
- package/dist/beads.d.ts.map +1 -0
- package/dist/eval-capture.d.ts +206 -0
- package/dist/eval-capture.d.ts.map +1 -0
- package/dist/index.d.ts +1299 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +776 -4387
- package/dist/learning.d.ts +670 -0
- package/dist/learning.d.ts.map +1 -0
- package/dist/mandate-promotion.d.ts +93 -0
- package/dist/mandate-promotion.d.ts.map +1 -0
- package/dist/mandate-storage.d.ts +209 -0
- package/dist/mandate-storage.d.ts.map +1 -0
- package/dist/mandates.d.ts +230 -0
- package/dist/mandates.d.ts.map +1 -0
- package/dist/output-guardrails.d.ts +125 -0
- package/dist/output-guardrails.d.ts.map +1 -0
- package/dist/pattern-maturity.d.ts +246 -0
- package/dist/pattern-maturity.d.ts.map +1 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +755 -4375
- package/dist/rate-limiter.d.ts +218 -0
- package/dist/rate-limiter.d.ts.map +1 -0
- package/dist/repo-crawl.d.ts +146 -0
- package/dist/repo-crawl.d.ts.map +1 -0
- package/dist/schemas/bead.d.ts +255 -0
- package/dist/schemas/bead.d.ts.map +1 -0
- package/dist/schemas/evaluation.d.ts +161 -0
- package/dist/schemas/evaluation.d.ts.map +1 -0
- package/dist/schemas/index.d.ts +34 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/mandate.d.ts +336 -0
- package/dist/schemas/mandate.d.ts.map +1 -0
- package/dist/schemas/swarm-context.d.ts +131 -0
- package/dist/schemas/swarm-context.d.ts.map +1 -0
- package/dist/schemas/task.d.ts +188 -0
- package/dist/schemas/task.d.ts.map +1 -0
- package/dist/skills.d.ts +471 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/storage.d.ts +260 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/structured.d.ts +196 -0
- package/dist/structured.d.ts.map +1 -0
- package/dist/swarm-decompose.d.ts +201 -0
- package/dist/swarm-decompose.d.ts.map +1 -0
- package/dist/swarm-mail.d.ts +240 -0
- package/dist/swarm-mail.d.ts.map +1 -0
- package/dist/swarm-orchestrate.d.ts +708 -0
- package/dist/swarm-orchestrate.d.ts.map +1 -0
- package/dist/swarm-prompts.d.ts +292 -0
- package/dist/swarm-prompts.d.ts.map +1 -0
- package/dist/swarm-strategies.d.ts +100 -0
- package/dist/swarm-strategies.d.ts.map +1 -0
- package/dist/swarm.d.ts +455 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/tool-availability.d.ts +91 -0
- package/dist/tool-availability.d.ts.map +1 -0
- package/docs/planning/ADR-001-monorepo-structure.md +171 -0
- package/docs/planning/ADR-002-package-extraction.md +393 -0
- package/docs/planning/ADR-003-performance-improvements.md +451 -0
- package/docs/planning/ADR-004-message-queue-features.md +187 -0
- package/docs/planning/ADR-005-devtools-observability.md +202 -0
- package/docs/planning/ROADMAP.md +368 -0
- package/docs/semantic-memory-cli-syntax.md +123 -0
- package/docs/swarm-mail-architecture.md +1147 -0
- package/package.json +13 -24
- package/scripts/cleanup-test-memories.ts +346 -0
- package/src/agent-mail.ts +1 -1
- package/src/beads.ts +1 -2
- package/src/index.ts +2 -2
- package/src/learning.integration.test.ts +80 -10
- package/src/mandate-storage.test.ts +3 -3
- package/src/storage.ts +189 -9
- package/src/swarm-mail.ts +3 -3
- package/src/swarm-orchestrate.ts +399 -246
- package/src/swarm.integration.test.ts +124 -0
- package/src/tool-availability.ts +1 -1
- package/tsconfig.json +1 -1
- package/.beads/.local_version +0 -1
- package/.beads/README.md +0 -81
- package/.beads/analysis/skill-architecture-meta-skills.md +0 -1562
- package/.beads/config.yaml +0 -62
- package/.beads/issues.jsonl +0 -2186
- package/.beads/metadata.json +0 -4
- package/.gitattributes +0 -3
- package/.github/workflows/ci.yml +0 -30
- package/.github/workflows/opencode.yml +0 -31
- package/.opencode/skills/tdd/SKILL.md +0 -182
- package/INTEGRATION_EXAMPLE.md +0 -66
- package/VERIFICATION_QUALITY_PATTERNS.md +0 -565
- package/bun.lock +0 -286
- package/dist/pglite.data +0 -0
- package/dist/pglite.wasm +0 -0
- package/src/streams/agent-mail.test.ts +0 -777
- package/src/streams/agent-mail.ts +0 -535
- package/src/streams/debug.test.ts +0 -500
- package/src/streams/debug.ts +0 -727
- package/src/streams/effect/ask.integration.test.ts +0 -314
- package/src/streams/effect/ask.ts +0 -202
- package/src/streams/effect/cursor.integration.test.ts +0 -418
- package/src/streams/effect/cursor.ts +0 -288
- package/src/streams/effect/deferred.test.ts +0 -357
- package/src/streams/effect/deferred.ts +0 -445
- package/src/streams/effect/index.ts +0 -17
- package/src/streams/effect/layers.ts +0 -73
- package/src/streams/effect/lock.test.ts +0 -385
- package/src/streams/effect/lock.ts +0 -399
- package/src/streams/effect/mailbox.test.ts +0 -260
- package/src/streams/effect/mailbox.ts +0 -318
- package/src/streams/events.test.ts +0 -924
- package/src/streams/events.ts +0 -329
- package/src/streams/index.test.ts +0 -229
- package/src/streams/index.ts +0 -578
- package/src/streams/migrations.test.ts +0 -359
- package/src/streams/migrations.ts +0 -362
- package/src/streams/projections.test.ts +0 -611
- package/src/streams/projections.ts +0 -504
- package/src/streams/store.integration.test.ts +0 -658
- package/src/streams/store.ts +0 -1075
- package/src/streams/swarm-mail.ts +0 -552
- package/test-bug-fixes.ts +0 -86
- package/vitest.integration.config.ts +0 -13
- package/workflow-integration-analysis.md +0 -876
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Module - Pluggable persistence for learning data
|
|
3
|
+
*
|
|
4
|
+
* Provides a unified storage interface with multiple backends:
|
|
5
|
+
* - semantic-memory (default) - Persistent with semantic search
|
|
6
|
+
* - in-memory - For testing and ephemeral sessions
|
|
7
|
+
*
|
|
8
|
+
* The semantic-memory backend uses collections:
|
|
9
|
+
* - `swarm-feedback` - Criterion feedback events
|
|
10
|
+
* - `swarm-patterns` - Decomposition patterns and anti-patterns
|
|
11
|
+
* - `swarm-maturity` - Pattern maturity tracking
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Use default semantic-memory storage
|
|
16
|
+
* const storage = createStorage();
|
|
17
|
+
*
|
|
18
|
+
* // Or configure explicitly
|
|
19
|
+
* const storage = createStorage({
|
|
20
|
+
* backend: "semantic-memory",
|
|
21
|
+
* collections: {
|
|
22
|
+
* feedback: "my-feedback",
|
|
23
|
+
* patterns: "my-patterns",
|
|
24
|
+
* maturity: "my-maturity",
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Or use in-memory for testing
|
|
29
|
+
* const storage = createStorage({ backend: "memory" });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import type { FeedbackEvent } from "./learning";
|
|
33
|
+
import type { DecompositionPattern } from "./anti-patterns";
|
|
34
|
+
import type { PatternMaturity, MaturityFeedback } from "./pattern-maturity";
|
|
35
|
+
/**
|
|
36
|
+
* Reset the cached command (for testing)
|
|
37
|
+
*/
|
|
38
|
+
export declare function resetCommandCache(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Storage backend type
|
|
41
|
+
*/
|
|
42
|
+
export type StorageBackend = "semantic-memory" | "memory";
|
|
43
|
+
/**
|
|
44
|
+
* Collection names for semantic-memory
|
|
45
|
+
*/
|
|
46
|
+
export interface StorageCollections {
|
|
47
|
+
feedback: string;
|
|
48
|
+
patterns: string;
|
|
49
|
+
maturity: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Storage configuration
|
|
53
|
+
*/
|
|
54
|
+
export interface StorageConfig {
|
|
55
|
+
/** Backend to use (default: "semantic-memory") */
|
|
56
|
+
backend: StorageBackend;
|
|
57
|
+
/** Collection names for semantic-memory backend */
|
|
58
|
+
collections: StorageCollections;
|
|
59
|
+
/** Whether to use semantic search for queries (default: true) */
|
|
60
|
+
useSemanticSearch: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate unique test collection name
|
|
64
|
+
*
|
|
65
|
+
* Creates a timestamp-based suffix for test collections to ensure complete isolation.
|
|
66
|
+
* Each test run gets its own collections that don't pollute production semantic-memory.
|
|
67
|
+
*
|
|
68
|
+
* @returns Unique suffix like "test-1734567890123"
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* // In test setup:
|
|
73
|
+
* process.env.TEST_SEMANTIC_MEMORY_COLLECTION = getTestCollectionName();
|
|
74
|
+
* // Results in collections like: swarm-feedback-test-1734567890123
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function getTestCollectionName(): string;
|
|
78
|
+
/**
|
|
79
|
+
* Get default storage configuration
|
|
80
|
+
*
|
|
81
|
+
* Returns a fresh config object on each call to ensure env vars (like
|
|
82
|
+
* TEST_SEMANTIC_MEMORY_COLLECTION) are read at runtime, not module load time.
|
|
83
|
+
*
|
|
84
|
+
* @returns Default storage configuration
|
|
85
|
+
*/
|
|
86
|
+
export declare function getDefaultStorageConfig(): StorageConfig;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use getDefaultStorageConfig() instead. This static export
|
|
89
|
+
* captures collections at module load time, breaking test isolation.
|
|
90
|
+
*/
|
|
91
|
+
export declare const DEFAULT_STORAGE_CONFIG: StorageConfig;
|
|
92
|
+
/**
|
|
93
|
+
* Unified storage interface for all learning data
|
|
94
|
+
*/
|
|
95
|
+
export interface LearningStorage {
|
|
96
|
+
storeFeedback(event: FeedbackEvent): Promise<void>;
|
|
97
|
+
getFeedbackByCriterion(criterion: string): Promise<FeedbackEvent[]>;
|
|
98
|
+
getFeedbackByBead(beadId: string): Promise<FeedbackEvent[]>;
|
|
99
|
+
getAllFeedback(): Promise<FeedbackEvent[]>;
|
|
100
|
+
findSimilarFeedback(query: string, limit?: number): Promise<FeedbackEvent[]>;
|
|
101
|
+
storePattern(pattern: DecompositionPattern): Promise<void>;
|
|
102
|
+
getPattern(id: string): Promise<DecompositionPattern | null>;
|
|
103
|
+
getAllPatterns(): Promise<DecompositionPattern[]>;
|
|
104
|
+
getAntiPatterns(): Promise<DecompositionPattern[]>;
|
|
105
|
+
getPatternsByTag(tag: string): Promise<DecompositionPattern[]>;
|
|
106
|
+
findSimilarPatterns(query: string, limit?: number): Promise<DecompositionPattern[]>;
|
|
107
|
+
storeMaturity(maturity: PatternMaturity): Promise<void>;
|
|
108
|
+
getMaturity(patternId: string): Promise<PatternMaturity | null>;
|
|
109
|
+
getAllMaturity(): Promise<PatternMaturity[]>;
|
|
110
|
+
getMaturityByState(state: string): Promise<PatternMaturity[]>;
|
|
111
|
+
storeMaturityFeedback(feedback: MaturityFeedback): Promise<void>;
|
|
112
|
+
getMaturityFeedback(patternId: string): Promise<MaturityFeedback[]>;
|
|
113
|
+
close(): Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
interface SessionStats {
|
|
116
|
+
storesCount: number;
|
|
117
|
+
queriesCount: number;
|
|
118
|
+
sessionStart: number;
|
|
119
|
+
lastAlertCheck: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Reset session stats (for testing)
|
|
123
|
+
*/
|
|
124
|
+
export declare function resetSessionStats(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Get current session stats
|
|
127
|
+
*/
|
|
128
|
+
export declare function getSessionStats(): Readonly<SessionStats>;
|
|
129
|
+
/**
|
|
130
|
+
* Semantic-memory backed storage
|
|
131
|
+
*
|
|
132
|
+
* Uses the semantic-memory CLI for persistence with semantic search.
|
|
133
|
+
* Data survives across sessions and can be searched by meaning.
|
|
134
|
+
*/
|
|
135
|
+
export declare class SemanticMemoryStorage implements LearningStorage {
|
|
136
|
+
private config;
|
|
137
|
+
constructor(config?: Partial<StorageConfig>);
|
|
138
|
+
/**
|
|
139
|
+
* Check if low usage alert should be sent
|
|
140
|
+
*
|
|
141
|
+
* Sends alert via agentmail if:
|
|
142
|
+
* - More than 10 minutes have elapsed since session start
|
|
143
|
+
* - Less than 1 store operation has occurred
|
|
144
|
+
* - Alert hasn't been sent in the last 10 minutes
|
|
145
|
+
*/
|
|
146
|
+
private checkLowUsageAlert;
|
|
147
|
+
private store;
|
|
148
|
+
private find;
|
|
149
|
+
private list;
|
|
150
|
+
storeFeedback(event: FeedbackEvent): Promise<void>;
|
|
151
|
+
getFeedbackByCriterion(criterion: string): Promise<FeedbackEvent[]>;
|
|
152
|
+
getFeedbackByBead(beadId: string): Promise<FeedbackEvent[]>;
|
|
153
|
+
getAllFeedback(): Promise<FeedbackEvent[]>;
|
|
154
|
+
findSimilarFeedback(query: string, limit?: number): Promise<FeedbackEvent[]>;
|
|
155
|
+
storePattern(pattern: DecompositionPattern): Promise<void>;
|
|
156
|
+
getPattern(id: string): Promise<DecompositionPattern | null>;
|
|
157
|
+
getAllPatterns(): Promise<DecompositionPattern[]>;
|
|
158
|
+
getAntiPatterns(): Promise<DecompositionPattern[]>;
|
|
159
|
+
getPatternsByTag(tag: string): Promise<DecompositionPattern[]>;
|
|
160
|
+
findSimilarPatterns(query: string, limit?: number): Promise<DecompositionPattern[]>;
|
|
161
|
+
storeMaturity(maturity: PatternMaturity): Promise<void>;
|
|
162
|
+
getMaturity(patternId: string): Promise<PatternMaturity | null>;
|
|
163
|
+
getAllMaturity(): Promise<PatternMaturity[]>;
|
|
164
|
+
getMaturityByState(state: string): Promise<PatternMaturity[]>;
|
|
165
|
+
storeMaturityFeedback(feedback: MaturityFeedback): Promise<void>;
|
|
166
|
+
getMaturityFeedback(patternId: string): Promise<MaturityFeedback[]>;
|
|
167
|
+
close(): Promise<void>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* In-memory storage adapter
|
|
171
|
+
*
|
|
172
|
+
* Wraps the existing in-memory implementations into the unified interface.
|
|
173
|
+
* Useful for testing and ephemeral sessions.
|
|
174
|
+
*/
|
|
175
|
+
export declare class InMemoryStorage implements LearningStorage {
|
|
176
|
+
private feedback;
|
|
177
|
+
private patterns;
|
|
178
|
+
private maturity;
|
|
179
|
+
constructor();
|
|
180
|
+
storeFeedback(event: FeedbackEvent): Promise<void>;
|
|
181
|
+
getFeedbackByCriterion(criterion: string): Promise<FeedbackEvent[]>;
|
|
182
|
+
getFeedbackByBead(beadId: string): Promise<FeedbackEvent[]>;
|
|
183
|
+
getAllFeedback(): Promise<FeedbackEvent[]>;
|
|
184
|
+
findSimilarFeedback(query: string, limit?: number): Promise<FeedbackEvent[]>;
|
|
185
|
+
storePattern(pattern: DecompositionPattern): Promise<void>;
|
|
186
|
+
getPattern(id: string): Promise<DecompositionPattern | null>;
|
|
187
|
+
getAllPatterns(): Promise<DecompositionPattern[]>;
|
|
188
|
+
getAntiPatterns(): Promise<DecompositionPattern[]>;
|
|
189
|
+
getPatternsByTag(tag: string): Promise<DecompositionPattern[]>;
|
|
190
|
+
findSimilarPatterns(query: string, limit?: number): Promise<DecompositionPattern[]>;
|
|
191
|
+
storeMaturity(maturity: PatternMaturity): Promise<void>;
|
|
192
|
+
getMaturity(patternId: string): Promise<PatternMaturity | null>;
|
|
193
|
+
getAllMaturity(): Promise<PatternMaturity[]>;
|
|
194
|
+
getMaturityByState(state: string): Promise<PatternMaturity[]>;
|
|
195
|
+
storeMaturityFeedback(feedback: MaturityFeedback): Promise<void>;
|
|
196
|
+
getMaturityFeedback(patternId: string): Promise<MaturityFeedback[]>;
|
|
197
|
+
close(): Promise<void>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Create a storage instance
|
|
201
|
+
*
|
|
202
|
+
* @param config - Storage configuration (default: semantic-memory)
|
|
203
|
+
* @returns Configured storage instance
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* // Default semantic-memory storage
|
|
208
|
+
* const storage = createStorage();
|
|
209
|
+
*
|
|
210
|
+
* // In-memory for testing
|
|
211
|
+
* const storage = createStorage({ backend: "memory" });
|
|
212
|
+
*
|
|
213
|
+
* // Custom collections
|
|
214
|
+
* const storage = createStorage({
|
|
215
|
+
* backend: "semantic-memory",
|
|
216
|
+
* collections: {
|
|
217
|
+
* feedback: "my-project-feedback",
|
|
218
|
+
* patterns: "my-project-patterns",
|
|
219
|
+
* maturity: "my-project-maturity",
|
|
220
|
+
* },
|
|
221
|
+
* });
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
export declare function createStorage(config?: Partial<StorageConfig>): LearningStorage;
|
|
225
|
+
/**
|
|
226
|
+
* Check if semantic-memory is available (native or via bunx)
|
|
227
|
+
*/
|
|
228
|
+
export declare function isSemanticMemoryAvailable(): Promise<boolean>;
|
|
229
|
+
/**
|
|
230
|
+
* Get the resolved semantic-memory command (for debugging/logging)
|
|
231
|
+
*/
|
|
232
|
+
export declare function getResolvedCommand(): Promise<string[]>;
|
|
233
|
+
/**
|
|
234
|
+
* Create storage with automatic fallback
|
|
235
|
+
*
|
|
236
|
+
* Uses semantic-memory if available, otherwise falls back to in-memory.
|
|
237
|
+
*
|
|
238
|
+
* @param config - Storage configuration
|
|
239
|
+
* @returns Storage instance
|
|
240
|
+
*/
|
|
241
|
+
export declare function createStorageWithFallback(config?: Partial<StorageConfig>): Promise<LearningStorage>;
|
|
242
|
+
/**
|
|
243
|
+
* Get or create the global storage instance
|
|
244
|
+
*
|
|
245
|
+
* Uses semantic-memory by default, with automatic fallback to in-memory.
|
|
246
|
+
* Prevents race conditions by storing the initialization promise.
|
|
247
|
+
*/
|
|
248
|
+
export declare function getStorage(): Promise<LearningStorage>;
|
|
249
|
+
/**
|
|
250
|
+
* Set the global storage instance
|
|
251
|
+
*
|
|
252
|
+
* Useful for testing or custom configurations.
|
|
253
|
+
*/
|
|
254
|
+
export declare function setStorage(storage: LearningStorage): void;
|
|
255
|
+
/**
|
|
256
|
+
* Reset the global storage instance
|
|
257
|
+
*/
|
|
258
|
+
export declare function resetStorage(): Promise<void>;
|
|
259
|
+
export {};
|
|
260
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAwE5E;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAMD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,QAAQ,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,OAAO,EAAE,cAAc,CAAC;IACxB,mDAAmD;IACnD,WAAW,EAAE,kBAAkB,CAAC;IAChC,iEAAiE;IACjE,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AA0DD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,IAAI,aAAa,CAMvD;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAAyC,CAAC;AAM/E;;GAEG;AACH,MAAM,W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,CAAC,eAAe,CAAC,CAc1B;AASD;;;;;GAKG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,eAAe,CAAC,CAQ3D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAGzD;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAMlD"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { z, type ZodSchema } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Structured validation error with formatted feedback
|
|
4
|
+
*
|
|
5
|
+
* Contains both raw Zod errors for programmatic access and
|
|
6
|
+
* pre-formatted error bullets suitable for retry prompts.
|
|
7
|
+
*/
|
|
8
|
+
export declare class StructuredValidationError extends Error {
|
|
9
|
+
readonly zodError: z.ZodError | null;
|
|
10
|
+
readonly rawInput: string;
|
|
11
|
+
readonly extractionMethod?: string | undefined;
|
|
12
|
+
readonly errorBullets: string[];
|
|
13
|
+
constructor(message: string, zodError: z.ZodError | null, rawInput: string, extractionMethod?: string | undefined);
|
|
14
|
+
/**
|
|
15
|
+
* Format errors as bullet list for retry prompts
|
|
16
|
+
*/
|
|
17
|
+
toFeedback(): string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error when JSON cannot be extracted from text
|
|
21
|
+
*/
|
|
22
|
+
export declare class JsonExtractionError extends Error {
|
|
23
|
+
readonly rawInput: string;
|
|
24
|
+
readonly attemptedStrategies: string[];
|
|
25
|
+
constructor(message: string, rawInput: string, attemptedStrategies: string[]);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Format Zod validation errors as readable bullet points
|
|
29
|
+
*
|
|
30
|
+
* @param error - Zod error from schema validation
|
|
31
|
+
* @returns Array of error messages suitable for feedback
|
|
32
|
+
*/
|
|
33
|
+
declare function formatZodErrors(error: z.ZodError): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Get schema by name from registry
|
|
36
|
+
*/
|
|
37
|
+
declare function getSchemaByName(name: string): ZodSchema;
|
|
38
|
+
/**
|
|
39
|
+
* Extract JSON from text using multiple strategies.
|
|
40
|
+
*
|
|
41
|
+
* Strategies tried in priority order:
|
|
42
|
+
* 1. Direct parse - fastest, works for clean JSON
|
|
43
|
+
* 2. JSON code block - common in markdown responses
|
|
44
|
+
* 3. Generic code block - fallback for unlabeled blocks
|
|
45
|
+
* 4. First brace match - finds outermost {...}
|
|
46
|
+
* 5. Last brace match - handles trailing content
|
|
47
|
+
* 6. Repair attempt - fixes common issues (quotes, trailing commas)
|
|
48
|
+
*
|
|
49
|
+
* @param text Raw text potentially containing JSON
|
|
50
|
+
* @returns Parsed JSON object or null if all strategies fail
|
|
51
|
+
*/
|
|
52
|
+
declare function extractJsonFromText(text: string): [unknown, string];
|
|
53
|
+
/**
|
|
54
|
+
* Extract JSON from markdown/text response
|
|
55
|
+
*
|
|
56
|
+
* Tries multiple extraction strategies in order:
|
|
57
|
+
* 1. Direct JSON parse
|
|
58
|
+
* 2. ```json code blocks
|
|
59
|
+
* 3. Any code blocks
|
|
60
|
+
* 4. Brace matching for objects
|
|
61
|
+
* 5. Bracket matching for arrays
|
|
62
|
+
* 6. JSON repair attempts
|
|
63
|
+
*/
|
|
64
|
+
export declare const structured_extract_json: {
|
|
65
|
+
description: string;
|
|
66
|
+
args: {
|
|
67
|
+
text: z.ZodString;
|
|
68
|
+
};
|
|
69
|
+
execute(args: {
|
|
70
|
+
text: string;
|
|
71
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Validate agent response against a named schema
|
|
75
|
+
*
|
|
76
|
+
* Extracts JSON from the response using multiple strategies,
|
|
77
|
+
* then validates against the specified schema.
|
|
78
|
+
*/
|
|
79
|
+
export declare const structured_validate: {
|
|
80
|
+
description: string;
|
|
81
|
+
args: {
|
|
82
|
+
response: z.ZodString;
|
|
83
|
+
schema_name: z.ZodEnum<{
|
|
84
|
+
evaluation: "evaluation";
|
|
85
|
+
task_decomposition: "task_decomposition";
|
|
86
|
+
bead_tree: "bead_tree";
|
|
87
|
+
}>;
|
|
88
|
+
max_retries: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
};
|
|
90
|
+
execute(args: {
|
|
91
|
+
response: string;
|
|
92
|
+
schema_name: "evaluation" | "task_decomposition" | "bead_tree";
|
|
93
|
+
max_retries?: number | undefined;
|
|
94
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Parse and validate evaluation response from an agent
|
|
98
|
+
*
|
|
99
|
+
* Specialized tool for parsing self-evaluations. Returns
|
|
100
|
+
* the validated Evaluation or structured errors.
|
|
101
|
+
*/
|
|
102
|
+
export declare const structured_parse_evaluation: {
|
|
103
|
+
description: string;
|
|
104
|
+
args: {
|
|
105
|
+
response: z.ZodString;
|
|
106
|
+
};
|
|
107
|
+
execute(args: {
|
|
108
|
+
response: string;
|
|
109
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Parse and validate task decomposition response
|
|
113
|
+
*
|
|
114
|
+
* Specialized tool for parsing decomposition results.
|
|
115
|
+
* Validates the structure and returns file lists for reservations.
|
|
116
|
+
*/
|
|
117
|
+
export declare const structured_parse_decomposition: {
|
|
118
|
+
description: string;
|
|
119
|
+
args: {
|
|
120
|
+
response: z.ZodString;
|
|
121
|
+
};
|
|
122
|
+
execute(args: {
|
|
123
|
+
response: string;
|
|
124
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Parse and validate a bead tree (epic with subtasks)
|
|
128
|
+
*
|
|
129
|
+
* Validates the structure before creating beads.
|
|
130
|
+
*/
|
|
131
|
+
export declare const structured_parse_bead_tree: {
|
|
132
|
+
description: string;
|
|
133
|
+
args: {
|
|
134
|
+
response: z.ZodString;
|
|
135
|
+
};
|
|
136
|
+
execute(args: {
|
|
137
|
+
response: string;
|
|
138
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
139
|
+
};
|
|
140
|
+
export { extractJsonFromText, formatZodErrors, getSchemaByName };
|
|
141
|
+
export declare const structuredTools: {
|
|
142
|
+
structured_extract_json: {
|
|
143
|
+
description: string;
|
|
144
|
+
args: {
|
|
145
|
+
text: z.ZodString;
|
|
146
|
+
};
|
|
147
|
+
execute(args: {
|
|
148
|
+
text: string;
|
|
149
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
150
|
+
};
|
|
151
|
+
structured_validate: {
|
|
152
|
+
description: string;
|
|
153
|
+
args: {
|
|
154
|
+
response: z.ZodString;
|
|
155
|
+
schema_name: z.ZodEnum<{
|
|
156
|
+
evaluation: "evaluation";
|
|
157
|
+
task_decomposition: "task_decomposition";
|
|
158
|
+
bead_tree: "bead_tree";
|
|
159
|
+
}>;
|
|
160
|
+
max_retries: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
};
|
|
162
|
+
execute(args: {
|
|
163
|
+
response: string;
|
|
164
|
+
schema_name: "evaluation" | "task_decomposition" | "bead_tree";
|
|
165
|
+
max_retries?: number | undefined;
|
|
166
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
167
|
+
};
|
|
168
|
+
structured_parse_evaluation: {
|
|
169
|
+
description: string;
|
|
170
|
+
args: {
|
|
171
|
+
response: z.ZodString;
|
|
172
|
+
};
|
|
173
|
+
execute(args: {
|
|
174
|
+
response: string;
|
|
175
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
176
|
+
};
|
|
177
|
+
structured_parse_decomposition: {
|
|
178
|
+
description: string;
|
|
179
|
+
args: {
|
|
180
|
+
response: z.ZodString;
|
|
181
|
+
};
|
|
182
|
+
execute(args: {
|
|
183
|
+
response: string;
|
|
184
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
185
|
+
};
|
|
186
|
+
structured_parse_bead_tree: {
|
|
187
|
+
description: string;
|
|
188
|
+
args: {
|
|
189
|
+
response: z.ZodString;
|
|
190
|
+
};
|
|
191
|
+
execute(args: {
|
|
192
|
+
response: string;
|
|
193
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=structured.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured.d.ts","sourceRoot":"","sources":["../src/structured.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAiBxC;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;aAKhC,QAAQ,EAAE,CAAC,CAAC,QAAQ,GAAG,IAAI;aAC3B,QAAQ,EAAE,MAAM;aAChB,gBAAgB,CAAC,EAAE,MAAM;IAN3C,SAAgB,YAAY,EAAE,MAAM,EAAE,CAAC;gBAGrC,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,CAAC,CAAC,QAAQ,GAAG,IAAI,EAC3B,QAAQ,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,MAAM,YAAA;IAO3C;;OAEG;IACH,UAAU,IAAI,MAAM;CAGrB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aAG1B,QAAQ,EAAE,MAAM;aAChB,mBAAmB,EAAE,MAAM,EAAE;gBAF7C,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAAE;CAKhD;AAMD;;;;;GAKG;AACH,iBAAS,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,GAAG,MAAM,EAAE,CAKpD;AAWD;;GAEG;AACH,iBAAS,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAQhD;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAS,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAwE5D;AAwHD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;CAkClC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;CAkF9B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;CA4EtC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;CAoGzC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;CAkFrC,CAAC;AAMH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAMjE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAM3B,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm Decompose Module - Task decomposition and validation
|
|
3
|
+
*
|
|
4
|
+
* Handles breaking tasks into parallelizable subtasks with file assignments,
|
|
5
|
+
* validates decomposition structure, and detects conflicts.
|
|
6
|
+
*
|
|
7
|
+
* Key responsibilities:
|
|
8
|
+
* - Decomposition prompt generation
|
|
9
|
+
* - BeadTree validation
|
|
10
|
+
* - File conflict detection
|
|
11
|
+
* - Instruction conflict detection
|
|
12
|
+
* - Delegation to planner subagents
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
/**
|
|
16
|
+
* A detected conflict between subtask instructions
|
|
17
|
+
*/
|
|
18
|
+
export interface InstructionConflict {
|
|
19
|
+
subtask_a: number;
|
|
20
|
+
subtask_b: number;
|
|
21
|
+
directive_a: string;
|
|
22
|
+
directive_b: string;
|
|
23
|
+
conflict_type: "positive_negative" | "contradictory";
|
|
24
|
+
description: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Detect conflicts between subtask instructions
|
|
28
|
+
*
|
|
29
|
+
* Looks for cases where one subtask says "always use X" and another says "avoid X".
|
|
30
|
+
*
|
|
31
|
+
* @param subtasks - Array of subtask descriptions
|
|
32
|
+
* @returns Array of detected conflicts
|
|
33
|
+
*
|
|
34
|
+
* @see https://github.com/Dicklesworthstone/cass_memory_system/blob/main/src/curate.ts#L36-L89
|
|
35
|
+
*/
|
|
36
|
+
export declare function detectInstructionConflicts(subtasks: Array<{
|
|
37
|
+
title: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
}>): InstructionConflict[];
|
|
40
|
+
/**
|
|
41
|
+
* Detect file conflicts in a bead tree
|
|
42
|
+
*
|
|
43
|
+
* @param subtasks - Array of subtasks with file assignments
|
|
44
|
+
* @returns Array of files that appear in multiple subtasks
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectFileConflicts(subtasks: Array<{
|
|
47
|
+
files: string[];
|
|
48
|
+
}>): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Decompose a task into a bead tree
|
|
51
|
+
*
|
|
52
|
+
* This is a PROMPT tool - it returns a prompt for the agent to respond to.
|
|
53
|
+
* The agent's response (JSON) should be validated with BeadTreeSchema.
|
|
54
|
+
*
|
|
55
|
+
* Optionally queries CASS for similar past tasks to inform decomposition.
|
|
56
|
+
*/
|
|
57
|
+
export declare const swarm_decompose: {
|
|
58
|
+
description: string;
|
|
59
|
+
args: {
|
|
60
|
+
task: z.ZodString;
|
|
61
|
+
max_subtasks: z.ZodDefault<z.ZodNumber>;
|
|
62
|
+
context: z.ZodOptional<z.ZodString>;
|
|
63
|
+
query_cass: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
cass_limit: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
};
|
|
66
|
+
execute(args: {
|
|
67
|
+
task: string;
|
|
68
|
+
max_subtasks: number;
|
|
69
|
+
context?: string | undefined;
|
|
70
|
+
query_cass?: boolean | undefined;
|
|
71
|
+
cass_limit?: number | undefined;
|
|
72
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Validate a decomposition response from an agent
|
|
76
|
+
*
|
|
77
|
+
* Use this after the agent responds to swarm:decompose to validate the structure.
|
|
78
|
+
*/
|
|
79
|
+
export declare const swarm_validate_decomposition: {
|
|
80
|
+
description: string;
|
|
81
|
+
args: {
|
|
82
|
+
response: z.ZodString;
|
|
83
|
+
};
|
|
84
|
+
execute(args: {
|
|
85
|
+
response: string;
|
|
86
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Delegate task decomposition to a swarm/planner subagent
|
|
90
|
+
*
|
|
91
|
+
* Returns a prompt for spawning a planner agent that will handle all decomposition
|
|
92
|
+
* reasoning. This keeps the coordinator context lean by offloading:
|
|
93
|
+
* - Strategy selection
|
|
94
|
+
* - CASS queries
|
|
95
|
+
* - Skills discovery
|
|
96
|
+
* - File analysis
|
|
97
|
+
* - BeadTree generation
|
|
98
|
+
*
|
|
99
|
+
* The planner returns ONLY structured BeadTree JSON, which the coordinator
|
|
100
|
+
* validates and uses to create beads.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // Coordinator workflow:
|
|
105
|
+
* const delegateResult = await swarm_delegate_planning({
|
|
106
|
+
* task: "Add user authentication",
|
|
107
|
+
* context: "Next.js 14 app",
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* // Parse the result
|
|
111
|
+
* const { prompt, subagent_type } = JSON.parse(delegateResult);
|
|
112
|
+
*
|
|
113
|
+
* // Spawn subagent using Task tool
|
|
114
|
+
* const plannerResponse = await Task(prompt, subagent_type);
|
|
115
|
+
*
|
|
116
|
+
* // Validate the response
|
|
117
|
+
* await swarm_validate_decomposition({ response: plannerResponse });
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare const swarm_delegate_planning: {
|
|
121
|
+
description: string;
|
|
122
|
+
args: {
|
|
123
|
+
task: z.ZodString;
|
|
124
|
+
context: z.ZodOptional<z.ZodString>;
|
|
125
|
+
max_subtasks: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
126
|
+
strategy: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
127
|
+
"file-based": "file-based";
|
|
128
|
+
"feature-based": "feature-based";
|
|
129
|
+
"risk-based": "risk-based";
|
|
130
|
+
auto: "auto";
|
|
131
|
+
}>>>;
|
|
132
|
+
query_cass: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
133
|
+
};
|
|
134
|
+
execute(args: {
|
|
135
|
+
task: string;
|
|
136
|
+
max_subtasks: number;
|
|
137
|
+
strategy: "file-based" | "feature-based" | "risk-based" | "auto";
|
|
138
|
+
query_cass: boolean;
|
|
139
|
+
context?: string | undefined;
|
|
140
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
141
|
+
};
|
|
142
|
+
export declare class SwarmError extends Error {
|
|
143
|
+
readonly operation: string;
|
|
144
|
+
readonly details?: unknown | undefined;
|
|
145
|
+
constructor(message: string, operation: string, details?: unknown | undefined);
|
|
146
|
+
}
|
|
147
|
+
export declare class DecompositionError extends SwarmError {
|
|
148
|
+
readonly zodError?: z.ZodError | undefined;
|
|
149
|
+
constructor(message: string, zodError?: z.ZodError | undefined);
|
|
150
|
+
}
|
|
151
|
+
export declare const decomposeTools: {
|
|
152
|
+
swarm_decompose: {
|
|
153
|
+
description: string;
|
|
154
|
+
args: {
|
|
155
|
+
task: z.ZodString;
|
|
156
|
+
max_subtasks: z.ZodDefault<z.ZodNumber>;
|
|
157
|
+
context: z.ZodOptional<z.ZodString>;
|
|
158
|
+
query_cass: z.ZodOptional<z.ZodBoolean>;
|
|
159
|
+
cass_limit: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
};
|
|
161
|
+
execute(args: {
|
|
162
|
+
task: string;
|
|
163
|
+
max_subtasks: number;
|
|
164
|
+
context?: string | undefined;
|
|
165
|
+
query_cass?: boolean | undefined;
|
|
166
|
+
cass_limit?: number | undefined;
|
|
167
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
168
|
+
};
|
|
169
|
+
swarm_validate_decomposition: {
|
|
170
|
+
description: string;
|
|
171
|
+
args: {
|
|
172
|
+
response: z.ZodString;
|
|
173
|
+
};
|
|
174
|
+
execute(args: {
|
|
175
|
+
response: string;
|
|
176
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
177
|
+
};
|
|
178
|
+
swarm_delegate_planning: {
|
|
179
|
+
description: string;
|
|
180
|
+
args: {
|
|
181
|
+
task: z.ZodString;
|
|
182
|
+
context: z.ZodOptional<z.ZodString>;
|
|
183
|
+
max_subtasks: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
184
|
+
strategy: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
185
|
+
"file-based": "file-based";
|
|
186
|
+
"feature-based": "feature-based";
|
|
187
|
+
"risk-based": "risk-based";
|
|
188
|
+
auto: "auto";
|
|
189
|
+
}>>>;
|
|
190
|
+
query_cass: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
191
|
+
};
|
|
192
|
+
execute(args: {
|
|
193
|
+
task: string;
|
|
194
|
+
max_subtasks: number;
|
|
195
|
+
strategy: "file-based" | "feature-based" | "risk-based" | "auto";
|
|
196
|
+
query_cass: boolean;
|
|
197
|
+
context?: string | undefined;
|
|
198
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=swarm-decompose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarm-decompose.d.ts","sourceRoot":"","sources":["../src/swarm-decompose.ts"],"names":[],"mappings":"AAAA;;;;;;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