opencode-swarm-plugin 0.22.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.
Files changed (128) hide show
  1. package/.turbo/turbo-build.log +9 -0
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +109 -429
  4. package/dist/agent-mail.d.ts +480 -0
  5. package/dist/agent-mail.d.ts.map +1 -0
  6. package/dist/anti-patterns.d.ts +257 -0
  7. package/dist/anti-patterns.d.ts.map +1 -0
  8. package/dist/beads.d.ts +377 -0
  9. package/dist/beads.d.ts.map +1 -0
  10. package/dist/eval-capture.d.ts +206 -0
  11. package/dist/eval-capture.d.ts.map +1 -0
  12. package/dist/index.d.ts +1299 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +498 -4246
  15. package/dist/learning.d.ts +670 -0
  16. package/dist/learning.d.ts.map +1 -0
  17. package/dist/mandate-promotion.d.ts +93 -0
  18. package/dist/mandate-promotion.d.ts.map +1 -0
  19. package/dist/mandate-storage.d.ts +209 -0
  20. package/dist/mandate-storage.d.ts.map +1 -0
  21. package/dist/mandates.d.ts +230 -0
  22. package/dist/mandates.d.ts.map +1 -0
  23. package/dist/output-guardrails.d.ts +125 -0
  24. package/dist/output-guardrails.d.ts.map +1 -0
  25. package/dist/pattern-maturity.d.ts +246 -0
  26. package/dist/pattern-maturity.d.ts.map +1 -0
  27. package/dist/plugin.d.ts +22 -0
  28. package/dist/plugin.d.ts.map +1 -0
  29. package/dist/plugin.js +493 -4241
  30. package/dist/rate-limiter.d.ts +218 -0
  31. package/dist/rate-limiter.d.ts.map +1 -0
  32. package/dist/repo-crawl.d.ts +146 -0
  33. package/dist/repo-crawl.d.ts.map +1 -0
  34. package/dist/schemas/bead.d.ts +255 -0
  35. package/dist/schemas/bead.d.ts.map +1 -0
  36. package/dist/schemas/evaluation.d.ts +161 -0
  37. package/dist/schemas/evaluation.d.ts.map +1 -0
  38. package/dist/schemas/index.d.ts +34 -0
  39. package/dist/schemas/index.d.ts.map +1 -0
  40. package/dist/schemas/mandate.d.ts +336 -0
  41. package/dist/schemas/mandate.d.ts.map +1 -0
  42. package/dist/schemas/swarm-context.d.ts +131 -0
  43. package/dist/schemas/swarm-context.d.ts.map +1 -0
  44. package/dist/schemas/task.d.ts +188 -0
  45. package/dist/schemas/task.d.ts.map +1 -0
  46. package/dist/skills.d.ts +471 -0
  47. package/dist/skills.d.ts.map +1 -0
  48. package/dist/storage.d.ts +260 -0
  49. package/dist/storage.d.ts.map +1 -0
  50. package/dist/structured.d.ts +196 -0
  51. package/dist/structured.d.ts.map +1 -0
  52. package/dist/swarm-decompose.d.ts +201 -0
  53. package/dist/swarm-decompose.d.ts.map +1 -0
  54. package/dist/swarm-mail.d.ts +240 -0
  55. package/dist/swarm-mail.d.ts.map +1 -0
  56. package/dist/swarm-orchestrate.d.ts +708 -0
  57. package/dist/swarm-orchestrate.d.ts.map +1 -0
  58. package/dist/swarm-prompts.d.ts +292 -0
  59. package/dist/swarm-prompts.d.ts.map +1 -0
  60. package/dist/swarm-strategies.d.ts +100 -0
  61. package/dist/swarm-strategies.d.ts.map +1 -0
  62. package/dist/swarm.d.ts +455 -0
  63. package/dist/swarm.d.ts.map +1 -0
  64. package/dist/tool-availability.d.ts +91 -0
  65. package/dist/tool-availability.d.ts.map +1 -0
  66. package/docs/planning/ADR-001-monorepo-structure.md +171 -0
  67. package/docs/planning/ADR-002-package-extraction.md +393 -0
  68. package/docs/planning/ADR-003-performance-improvements.md +451 -0
  69. package/docs/planning/ADR-004-message-queue-features.md +187 -0
  70. package/docs/planning/ADR-005-devtools-observability.md +202 -0
  71. package/docs/planning/ROADMAP.md +368 -0
  72. package/package.json +13 -24
  73. package/src/agent-mail.ts +1 -1
  74. package/src/beads.ts +1 -2
  75. package/src/index.ts +2 -2
  76. package/src/learning.integration.test.ts +66 -11
  77. package/src/mandate-storage.test.ts +3 -3
  78. package/src/storage.ts +78 -10
  79. package/src/swarm-mail.ts +3 -3
  80. package/src/swarm-orchestrate.ts +7 -7
  81. package/src/tool-availability.ts +1 -1
  82. package/tsconfig.json +1 -1
  83. package/.beads/.local_version +0 -1
  84. package/.beads/README.md +0 -81
  85. package/.beads/analysis/skill-architecture-meta-skills.md +0 -1562
  86. package/.beads/config.yaml +0 -62
  87. package/.beads/issues.jsonl +0 -2197
  88. package/.beads/metadata.json +0 -4
  89. package/.gitattributes +0 -3
  90. package/.github/workflows/ci.yml +0 -30
  91. package/.github/workflows/opencode.yml +0 -31
  92. package/.opencode/skills/tdd/SKILL.md +0 -182
  93. package/INTEGRATION_EXAMPLE.md +0 -66
  94. package/VERIFICATION_QUALITY_PATTERNS.md +0 -565
  95. package/bun.lock +0 -286
  96. package/dist/pglite.data +0 -0
  97. package/dist/pglite.wasm +0 -0
  98. package/src/streams/agent-mail.test.ts +0 -777
  99. package/src/streams/agent-mail.ts +0 -535
  100. package/src/streams/debug.test.ts +0 -500
  101. package/src/streams/debug.ts +0 -727
  102. package/src/streams/effect/ask.integration.test.ts +0 -314
  103. package/src/streams/effect/ask.ts +0 -202
  104. package/src/streams/effect/cursor.integration.test.ts +0 -418
  105. package/src/streams/effect/cursor.ts +0 -288
  106. package/src/streams/effect/deferred.test.ts +0 -357
  107. package/src/streams/effect/deferred.ts +0 -445
  108. package/src/streams/effect/index.ts +0 -17
  109. package/src/streams/effect/layers.ts +0 -73
  110. package/src/streams/effect/lock.test.ts +0 -385
  111. package/src/streams/effect/lock.ts +0 -399
  112. package/src/streams/effect/mailbox.test.ts +0 -260
  113. package/src/streams/effect/mailbox.ts +0 -318
  114. package/src/streams/events.test.ts +0 -924
  115. package/src/streams/events.ts +0 -329
  116. package/src/streams/index.test.ts +0 -229
  117. package/src/streams/index.ts +0 -578
  118. package/src/streams/migrations.test.ts +0 -359
  119. package/src/streams/migrations.ts +0 -362
  120. package/src/streams/projections.test.ts +0 -611
  121. package/src/streams/projections.ts +0 -504
  122. package/src/streams/store.integration.test.ts +0 -658
  123. package/src/streams/store.ts +0 -1075
  124. package/src/streams/swarm-mail.ts +0 -552
  125. package/test-bug-fixes.ts +0 -86
  126. package/vitest.integration.config.ts +0 -19
  127. package/vitest.integration.setup.ts +0 -48
  128. package/workflow-integration-analysis.md +0 -876
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Rate Limiter Module - Distributed rate limiting for Agent Mail
3
+ *
4
+ * Provides sliding window rate limiting with dual backends:
5
+ * - Redis (primary) - Distributed, uses sorted sets for sliding window
6
+ * - SQLite (fallback) - Local, file-based persistence
7
+ *
8
+ * Features:
9
+ * - Dual window enforcement: per-minute AND per-hour limits
10
+ * - Automatic backend fallback (Redis → SQLite)
11
+ * - Configurable limits per endpoint via env vars
12
+ * - Auto-cleanup of expired entries
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Create rate limiter (auto-selects backend)
17
+ * const limiter = await createRateLimiter();
18
+ *
19
+ * // Check if request is allowed
20
+ * const result = await limiter.checkLimit("BlueLake", "send");
21
+ * if (!result.allowed) {
22
+ * console.log(`Rate limited. Reset at ${result.resetAt}`);
23
+ * }
24
+ *
25
+ * // Record a request after it completes
26
+ * await limiter.recordRequest("BlueLake", "send");
27
+ * ```
28
+ */
29
+ import Redis from "ioredis";
30
+ /**
31
+ * Result of checking a rate limit
32
+ */
33
+ export interface RateLimitResult {
34
+ /** Whether the request is allowed */
35
+ allowed: boolean;
36
+ /** Remaining requests in the most restrictive window */
37
+ remaining: number;
38
+ /** Unix timestamp (ms) when the limit resets */
39
+ resetAt: number;
40
+ }
41
+ /**
42
+ * Rate limiter interface
43
+ */
44
+ export interface RateLimiter {
45
+ /**
46
+ * Check if a request is allowed under rate limits
47
+ * Checks BOTH minute and hour windows - both must pass
48
+ *
49
+ * @param agentName - The agent making the request
50
+ * @param endpoint - The endpoint being accessed
51
+ * @returns Rate limit check result
52
+ */
53
+ checkLimit(agentName: string, endpoint: string): Promise<RateLimitResult>;
54
+ /**
55
+ * Record a request against the rate limit
56
+ * Should be called AFTER the request succeeds
57
+ *
58
+ * @param agentName - The agent making the request
59
+ * @param endpoint - The endpoint being accessed
60
+ */
61
+ recordRequest(agentName: string, endpoint: string): Promise<void>;
62
+ /**
63
+ * Close the rate limiter and release resources
64
+ */
65
+ close(): Promise<void>;
66
+ }
67
+ /**
68
+ * Rate limit configuration for an endpoint
69
+ */
70
+ export interface EndpointLimits {
71
+ /** Requests allowed per minute */
72
+ perMinute: number;
73
+ /** Requests allowed per hour */
74
+ perHour: number;
75
+ }
76
+ /**
77
+ * Default rate limits per endpoint
78
+ * Can be overridden via OPENCODE_RATE_LIMIT_{ENDPOINT}_PER_MIN and _PER_HOUR
79
+ */
80
+ export declare const DEFAULT_LIMITS: Record<string, EndpointLimits>;
81
+ /**
82
+ * Get rate limits for an endpoint, with env var overrides
83
+ *
84
+ * @param endpoint - The endpoint name
85
+ * @returns Rate limits for the endpoint
86
+ */
87
+ export declare function getLimitsForEndpoint(endpoint: string): EndpointLimits;
88
+ /**
89
+ * Redis-backed rate limiter using sorted sets
90
+ *
91
+ * Uses sliding window algorithm:
92
+ * 1. Store each request as a member with timestamp as score
93
+ * 2. Remove expired entries (outside window)
94
+ * 3. Count remaining entries
95
+ *
96
+ * Key format: ratelimit:{agent}:{endpoint}:{window}
97
+ * Window values: "minute" or "hour"
98
+ */
99
+ export declare class RedisRateLimiter implements RateLimiter {
100
+ private redis;
101
+ private connected;
102
+ constructor(redis: Redis);
103
+ /**
104
+ * Build Redis key for rate limiting
105
+ */
106
+ private buildKey;
107
+ /**
108
+ * Get window duration in milliseconds
109
+ */
110
+ private getWindowDuration;
111
+ checkLimit(agentName: string, endpoint: string): Promise<RateLimitResult>;
112
+ /**
113
+ * Check a single window's rate limit
114
+ */
115
+ private checkWindow;
116
+ recordRequest(agentName: string, endpoint: string): Promise<void>;
117
+ close(): Promise<void>;
118
+ }
119
+ /**
120
+ * SQLite-backed rate limiter for local/fallback use
121
+ *
122
+ * Table schema:
123
+ * - agent_name: TEXT
124
+ * - endpoint: TEXT
125
+ * - window: TEXT ('minute' or 'hour')
126
+ * - timestamp: INTEGER (Unix ms)
127
+ *
128
+ * Uses sliding window via COUNT query with timestamp filter.
129
+ */
130
+ export declare class SqliteRateLimiter implements RateLimiter {
131
+ private db;
132
+ constructor(dbPath: string);
133
+ /**
134
+ * Initialize the database schema and cleanup old entries
135
+ */
136
+ private initialize;
137
+ checkLimit(agentName: string, endpoint: string): Promise<RateLimitResult>;
138
+ /**
139
+ * Check a single window's rate limit
140
+ */
141
+ private checkWindow;
142
+ /**
143
+ * Clean up old rate limit entries in bounded batches
144
+ *
145
+ * Limits cleanup to prevent blocking recordRequest on large datasets:
146
+ * - BATCH_SIZE: 1000 rows per iteration
147
+ * - MAX_BATCHES: 10 (max 10k rows per cleanup invocation)
148
+ *
149
+ * Stops early if fewer than BATCH_SIZE rows deleted (no more to clean).
150
+ */
151
+ private cleanup;
152
+ recordRequest(agentName: string, endpoint: string): Promise<void>;
153
+ close(): Promise<void>;
154
+ }
155
+ /**
156
+ * In-memory rate limiter for testing
157
+ *
158
+ * Uses Map storage with timestamp arrays per key.
159
+ * No persistence - resets on process restart.
160
+ */
161
+ export declare class InMemoryRateLimiter implements RateLimiter {
162
+ private storage;
163
+ private buildKey;
164
+ checkLimit(agentName: string, endpoint: string): Promise<RateLimitResult>;
165
+ private checkWindow;
166
+ recordRequest(agentName: string, endpoint: string): Promise<void>;
167
+ close(): Promise<void>;
168
+ /**
169
+ * Reset all rate limits (for testing)
170
+ */
171
+ reset(): void;
172
+ }
173
+ /**
174
+ * Create a rate limiter with automatic backend selection
175
+ *
176
+ * Tries Redis first, falls back to SQLite on connection failure.
177
+ * Warns once when falling back to SQLite.
178
+ *
179
+ * @returns Configured rate limiter instance
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * // Auto-select backend
184
+ * const limiter = await createRateLimiter();
185
+ *
186
+ * // Force SQLite
187
+ * const limiter = await createRateLimiter({ backend: "sqlite" });
188
+ *
189
+ * // Force in-memory (testing)
190
+ * const limiter = await createRateLimiter({ backend: "memory" });
191
+ * ```
192
+ */
193
+ export declare function createRateLimiter(options?: {
194
+ backend?: "redis" | "sqlite" | "memory";
195
+ redisUrl?: string;
196
+ sqlitePath?: string;
197
+ }): Promise<RateLimiter>;
198
+ /**
199
+ * Reset the fallback warning flag (for testing)
200
+ */
201
+ export declare function resetFallbackWarning(): void;
202
+ /**
203
+ * Get or create the global rate limiter instance
204
+ *
205
+ * Uses auto-selection (Redis → SQLite) by default.
206
+ */
207
+ export declare function getRateLimiter(): Promise<RateLimiter>;
208
+ /**
209
+ * Set the global rate limiter instance
210
+ *
211
+ * Useful for testing or custom configurations.
212
+ */
213
+ export declare function setRateLimiter(limiter: RateLimiter): void;
214
+ /**
215
+ * Reset the global rate limiter instance
216
+ */
217
+ export declare function resetRateLimiter(): Promise<void>;
218
+ //# sourceMappingURL=rate-limiter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limiter.d.ts","sourceRoot":"","sources":["../src/rate-limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,MAAM,SAAS,CAAC;AA0C5B;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;OAOG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE1E;;;;;;OAMG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElE;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;GA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CAAC;CAG7B;AAMD;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,WAAW;IACrD,OAAO,CAAC,OAAO,CAAoC;IAEnD,OAAO,CAAC,QAAQ;IAQV,UAAU,CACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC;IA4B3B,OAAO,CAAC,WAAW;IA4Bb,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AASD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,CAAC,EAAE;IAChD,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,WAAW,CAAC,CA6EvB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAQD;;;;GAIG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAK3D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAEzD;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKtD"}
@@ -0,0 +1,146 @@
1
+ import { z } from "zod";
2
+ export declare class RepoCrawlError extends Error {
3
+ readonly statusCode?: number | undefined;
4
+ readonly endpoint?: string | undefined;
5
+ constructor(message: string, statusCode?: number | undefined, endpoint?: string | undefined);
6
+ }
7
+ /**
8
+ * Get README.md content from a repository
9
+ */
10
+ export declare const repo_readme: {
11
+ description: string;
12
+ args: {
13
+ repo: z.ZodString;
14
+ maxLength: z.ZodOptional<z.ZodNumber>;
15
+ };
16
+ execute(args: {
17
+ repo: string;
18
+ maxLength?: number | undefined;
19
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
20
+ };
21
+ /**
22
+ * Get repository structure and detect tech stack
23
+ */
24
+ export declare const repo_structure: {
25
+ description: string;
26
+ args: {
27
+ repo: z.ZodString;
28
+ depth: z.ZodOptional<z.ZodNumber>;
29
+ };
30
+ execute(args: {
31
+ repo: string;
32
+ depth?: number | undefined;
33
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
34
+ };
35
+ /**
36
+ * Get directory tree for a specific path
37
+ */
38
+ export declare const repo_tree: {
39
+ description: string;
40
+ args: {
41
+ repo: z.ZodString;
42
+ path: z.ZodOptional<z.ZodString>;
43
+ maxDepth: z.ZodOptional<z.ZodNumber>;
44
+ };
45
+ execute(args: {
46
+ repo: string;
47
+ path?: string | undefined;
48
+ maxDepth?: number | undefined;
49
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
50
+ };
51
+ /**
52
+ * Get file content from repository
53
+ */
54
+ export declare const repo_file: {
55
+ description: string;
56
+ args: {
57
+ repo: z.ZodString;
58
+ path: z.ZodString;
59
+ maxLength: z.ZodOptional<z.ZodNumber>;
60
+ };
61
+ execute(args: {
62
+ repo: string;
63
+ path: string;
64
+ maxLength?: number | undefined;
65
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
66
+ };
67
+ /**
68
+ * Search code in a repository
69
+ */
70
+ export declare const repo_search: {
71
+ description: string;
72
+ args: {
73
+ repo: z.ZodString;
74
+ query: z.ZodString;
75
+ maxResults: z.ZodOptional<z.ZodNumber>;
76
+ };
77
+ execute(args: {
78
+ repo: string;
79
+ query: string;
80
+ maxResults?: number | undefined;
81
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
82
+ };
83
+ export declare const repoCrawlTools: {
84
+ repo_readme: {
85
+ description: string;
86
+ args: {
87
+ repo: z.ZodString;
88
+ maxLength: z.ZodOptional<z.ZodNumber>;
89
+ };
90
+ execute(args: {
91
+ repo: string;
92
+ maxLength?: number | undefined;
93
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
94
+ };
95
+ repo_structure: {
96
+ description: string;
97
+ args: {
98
+ repo: z.ZodString;
99
+ depth: z.ZodOptional<z.ZodNumber>;
100
+ };
101
+ execute(args: {
102
+ repo: string;
103
+ depth?: number | undefined;
104
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
105
+ };
106
+ repo_tree: {
107
+ description: string;
108
+ args: {
109
+ repo: z.ZodString;
110
+ path: z.ZodOptional<z.ZodString>;
111
+ maxDepth: z.ZodOptional<z.ZodNumber>;
112
+ };
113
+ execute(args: {
114
+ repo: string;
115
+ path?: string | undefined;
116
+ maxDepth?: number | undefined;
117
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
118
+ };
119
+ repo_file: {
120
+ description: string;
121
+ args: {
122
+ repo: z.ZodString;
123
+ path: z.ZodString;
124
+ maxLength: z.ZodOptional<z.ZodNumber>;
125
+ };
126
+ execute(args: {
127
+ repo: string;
128
+ path: string;
129
+ maxLength?: number | undefined;
130
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
131
+ };
132
+ repo_search: {
133
+ description: string;
134
+ args: {
135
+ repo: z.ZodString;
136
+ query: z.ZodString;
137
+ maxResults: z.ZodOptional<z.ZodNumber>;
138
+ };
139
+ execute(args: {
140
+ repo: string;
141
+ query: string;
142
+ maxResults?: number | undefined;
143
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
144
+ };
145
+ };
146
+ //# sourceMappingURL=repo-crawl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-crawl.d.ts","sourceRoot":"","sources":["../src/repo-crawl.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqExB,qBAAa,cAAe,SAAQ,KAAK;aAGrB,UAAU,CAAC,EAAE,MAAM;aACnB,QAAQ,CAAC,EAAE,MAAM;gBAFjC,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,QAAQ,CAAC,EAAE,MAAM,YAAA;CAKpC;AA4KD;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;CA8CtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;CAqEzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;CAiFpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;CAmDpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;CAgDtB,CAAC;AAMH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAM1B,CAAC"}
@@ -0,0 +1,255 @@
1
+ /**
2
+ * Bead schemas for type-safe beads operations
3
+ *
4
+ * These schemas validate all data from the `bd` CLI to ensure
5
+ * type safety and catch malformed responses early.
6
+ */
7
+ import { z } from "zod";
8
+ /** Valid bead statuses */
9
+ export declare const BeadStatusSchema: z.ZodEnum<{
10
+ open: "open";
11
+ in_progress: "in_progress";
12
+ blocked: "blocked";
13
+ closed: "closed";
14
+ }>;
15
+ export type BeadStatus = z.infer<typeof BeadStatusSchema>;
16
+ /** Valid bead types */
17
+ export declare const BeadTypeSchema: z.ZodEnum<{
18
+ bug: "bug";
19
+ feature: "feature";
20
+ task: "task";
21
+ epic: "epic";
22
+ chore: "chore";
23
+ }>;
24
+ export type BeadType = z.infer<typeof BeadTypeSchema>;
25
+ /** Dependency relationship between beads */
26
+ export declare const BeadDependencySchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ type: z.ZodEnum<{
29
+ blocks: "blocks";
30
+ "blocked-by": "blocked-by";
31
+ related: "related";
32
+ "discovered-from": "discovered-from";
33
+ }>;
34
+ }, z.core.$strip>;
35
+ export type BeadDependency = z.infer<typeof BeadDependencySchema>;
36
+ /**
37
+ * Core bead schema - validates bd CLI JSON output
38
+ *
39
+ * ID format:
40
+ * - Standard: `{project}-{hash}` (e.g., `opencode-swarm-plugin-1i8`)
41
+ * - Subtask: `{project}-{hash}.{index}` (e.g., `opencode-swarm-plugin-1i8.1`)
42
+ * - Custom: `{project}-{custom-id}` (e.g., `migrate-egghead-phase-0`)
43
+ * - Custom subtask: `{project}-{custom-id}.{suffix}` (e.g., `migrate-egghead-phase-0.e2e-test`)
44
+ */
45
+ export declare const BeadSchema: z.ZodObject<{
46
+ id: z.ZodString;
47
+ title: z.ZodString;
48
+ description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
49
+ status: z.ZodDefault<z.ZodEnum<{
50
+ open: "open";
51
+ in_progress: "in_progress";
52
+ blocked: "blocked";
53
+ closed: "closed";
54
+ }>>;
55
+ priority: z.ZodDefault<z.ZodNumber>;
56
+ issue_type: z.ZodDefault<z.ZodEnum<{
57
+ bug: "bug";
58
+ feature: "feature";
59
+ task: "task";
60
+ epic: "epic";
61
+ chore: "chore";
62
+ }>>;
63
+ created_at: z.ZodString;
64
+ updated_at: z.ZodOptional<z.ZodString>;
65
+ closed_at: z.ZodOptional<z.ZodString>;
66
+ parent_id: z.ZodOptional<z.ZodString>;
67
+ dependencies: z.ZodDefault<z.ZodArray<z.ZodObject<{
68
+ id: z.ZodString;
69
+ type: z.ZodEnum<{
70
+ blocks: "blocks";
71
+ "blocked-by": "blocked-by";
72
+ related: "related";
73
+ "discovered-from": "discovered-from";
74
+ }>;
75
+ }, z.core.$strip>>>;
76
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
77
+ }, z.core.$strip>;
78
+ export type Bead = z.infer<typeof BeadSchema>;
79
+ /** Arguments for creating a bead */
80
+ export declare const BeadCreateArgsSchema: z.ZodObject<{
81
+ title: z.ZodString;
82
+ type: z.ZodDefault<z.ZodEnum<{
83
+ bug: "bug";
84
+ feature: "feature";
85
+ task: "task";
86
+ epic: "epic";
87
+ chore: "chore";
88
+ }>>;
89
+ priority: z.ZodDefault<z.ZodNumber>;
90
+ description: z.ZodOptional<z.ZodString>;
91
+ parent_id: z.ZodOptional<z.ZodString>;
92
+ id: z.ZodOptional<z.ZodString>;
93
+ }, z.core.$strip>;
94
+ export type BeadCreateArgs = z.infer<typeof BeadCreateArgsSchema>;
95
+ /** Arguments for updating a bead */
96
+ export declare const BeadUpdateArgsSchema: z.ZodObject<{
97
+ id: z.ZodString;
98
+ status: z.ZodOptional<z.ZodEnum<{
99
+ open: "open";
100
+ in_progress: "in_progress";
101
+ blocked: "blocked";
102
+ closed: "closed";
103
+ }>>;
104
+ description: z.ZodOptional<z.ZodString>;
105
+ priority: z.ZodOptional<z.ZodNumber>;
106
+ }, z.core.$strip>;
107
+ export type BeadUpdateArgs = z.infer<typeof BeadUpdateArgsSchema>;
108
+ /** Arguments for closing a bead */
109
+ export declare const BeadCloseArgsSchema: z.ZodObject<{
110
+ id: z.ZodString;
111
+ reason: z.ZodString;
112
+ }, z.core.$strip>;
113
+ export type BeadCloseArgs = z.infer<typeof BeadCloseArgsSchema>;
114
+ /** Arguments for querying beads */
115
+ export declare const BeadQueryArgsSchema: z.ZodObject<{
116
+ status: z.ZodOptional<z.ZodEnum<{
117
+ open: "open";
118
+ in_progress: "in_progress";
119
+ blocked: "blocked";
120
+ closed: "closed";
121
+ }>>;
122
+ type: z.ZodOptional<z.ZodEnum<{
123
+ bug: "bug";
124
+ feature: "feature";
125
+ task: "task";
126
+ epic: "epic";
127
+ chore: "chore";
128
+ }>>;
129
+ ready: z.ZodOptional<z.ZodBoolean>;
130
+ limit: z.ZodDefault<z.ZodNumber>;
131
+ }, z.core.$strip>;
132
+ export type BeadQueryArgs = z.infer<typeof BeadQueryArgsSchema>;
133
+ /**
134
+ * Subtask specification for epic decomposition
135
+ *
136
+ * Used when creating an epic with subtasks in one operation.
137
+ * The `files` array is used for Agent Mail file reservations.
138
+ */
139
+ export declare const SubtaskSpecSchema: z.ZodObject<{
140
+ title: z.ZodString;
141
+ description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
142
+ files: z.ZodDefault<z.ZodArray<z.ZodString>>;
143
+ dependencies: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
144
+ estimated_complexity: z.ZodDefault<z.ZodNumber>;
145
+ }, z.core.$strip>;
146
+ export type SubtaskSpec = z.infer<typeof SubtaskSpecSchema>;
147
+ /**
148
+ * Bead tree for swarm decomposition
149
+ *
150
+ * Represents an epic with its subtasks, ready for spawning agents.
151
+ */
152
+ export declare const BeadTreeSchema: z.ZodObject<{
153
+ epic: z.ZodObject<{
154
+ title: z.ZodString;
155
+ description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
156
+ }, z.core.$strip>;
157
+ subtasks: z.ZodArray<z.ZodObject<{
158
+ title: z.ZodString;
159
+ description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
160
+ files: z.ZodDefault<z.ZodArray<z.ZodString>>;
161
+ dependencies: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
162
+ estimated_complexity: z.ZodDefault<z.ZodNumber>;
163
+ }, z.core.$strip>>;
164
+ }, z.core.$strip>;
165
+ export type BeadTree = z.infer<typeof BeadTreeSchema>;
166
+ /** Arguments for creating an epic with subtasks */
167
+ export declare const EpicCreateArgsSchema: z.ZodObject<{
168
+ epic_title: z.ZodString;
169
+ epic_description: z.ZodOptional<z.ZodString>;
170
+ epic_id: z.ZodOptional<z.ZodString>;
171
+ subtasks: z.ZodArray<z.ZodObject<{
172
+ title: z.ZodString;
173
+ priority: z.ZodDefault<z.ZodNumber>;
174
+ files: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
175
+ id_suffix: z.ZodOptional<z.ZodString>;
176
+ }, z.core.$strip>>;
177
+ }, z.core.$strip>;
178
+ export type EpicCreateArgs = z.infer<typeof EpicCreateArgsSchema>;
179
+ /**
180
+ * Result of epic creation
181
+ *
182
+ * Contains the created epic and all subtasks with their IDs.
183
+ */
184
+ export declare const EpicCreateResultSchema: z.ZodObject<{
185
+ success: z.ZodBoolean;
186
+ epic: z.ZodObject<{
187
+ id: z.ZodString;
188
+ title: z.ZodString;
189
+ description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
190
+ status: z.ZodDefault<z.ZodEnum<{
191
+ open: "open";
192
+ in_progress: "in_progress";
193
+ blocked: "blocked";
194
+ closed: "closed";
195
+ }>>;
196
+ priority: z.ZodDefault<z.ZodNumber>;
197
+ issue_type: z.ZodDefault<z.ZodEnum<{
198
+ bug: "bug";
199
+ feature: "feature";
200
+ task: "task";
201
+ epic: "epic";
202
+ chore: "chore";
203
+ }>>;
204
+ created_at: z.ZodString;
205
+ updated_at: z.ZodOptional<z.ZodString>;
206
+ closed_at: z.ZodOptional<z.ZodString>;
207
+ parent_id: z.ZodOptional<z.ZodString>;
208
+ dependencies: z.ZodDefault<z.ZodArray<z.ZodObject<{
209
+ id: z.ZodString;
210
+ type: z.ZodEnum<{
211
+ blocks: "blocks";
212
+ "blocked-by": "blocked-by";
213
+ related: "related";
214
+ "discovered-from": "discovered-from";
215
+ }>;
216
+ }, z.core.$strip>>>;
217
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
218
+ }, z.core.$strip>;
219
+ subtasks: z.ZodArray<z.ZodObject<{
220
+ id: z.ZodString;
221
+ title: z.ZodString;
222
+ description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
223
+ status: z.ZodDefault<z.ZodEnum<{
224
+ open: "open";
225
+ in_progress: "in_progress";
226
+ blocked: "blocked";
227
+ closed: "closed";
228
+ }>>;
229
+ priority: z.ZodDefault<z.ZodNumber>;
230
+ issue_type: z.ZodDefault<z.ZodEnum<{
231
+ bug: "bug";
232
+ feature: "feature";
233
+ task: "task";
234
+ epic: "epic";
235
+ chore: "chore";
236
+ }>>;
237
+ created_at: z.ZodString;
238
+ updated_at: z.ZodOptional<z.ZodString>;
239
+ closed_at: z.ZodOptional<z.ZodString>;
240
+ parent_id: z.ZodOptional<z.ZodString>;
241
+ dependencies: z.ZodDefault<z.ZodArray<z.ZodObject<{
242
+ id: z.ZodString;
243
+ type: z.ZodEnum<{
244
+ blocks: "blocks";
245
+ "blocked-by": "blocked-by";
246
+ related: "related";
247
+ "discovered-from": "discovered-from";
248
+ }>;
249
+ }, z.core.$strip>>>;
250
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
251
+ }, z.core.$strip>>;
252
+ rollback_hint: z.ZodOptional<z.ZodString>;
253
+ }, z.core.$strip>;
254
+ export type EpicCreateResult = z.infer<typeof EpicCreateResultSchema>;
255
+ //# sourceMappingURL=bead.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bead.d.ts","sourceRoot":"","sources":["../../src/schemas/bead.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0BAA0B;AAC1B,eAAO,MAAM,gBAAgB;;;;;EAK3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,uBAAuB;AACvB,eAAO,MAAM,cAAc;;;;;;EAMzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,4CAA4C;AAC5C,eAAO,MAAM,oBAAoB;;;;;;;;iBAG/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCrB,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,oCAAoC;AACpC,eAAO,MAAM,oBAAoB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