opencode-swarm-plugin 0.22.0 → 0.23.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.
Files changed (128) hide show
  1. package/.turbo/turbo-build.log +9 -0
  2. package/CHANGELOG.md +20 -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
@@ -1,318 +0,0 @@
1
- /**
2
- * DurableMailbox - Actor-style messaging with envelope pattern
3
- *
4
- * Combines DurableCursor (positioned consumption) with Envelope pattern for
5
- * request/response messaging between agents.
6
- *
7
- * @example
8
- * ```typescript
9
- * const program = Effect.gen(function* () {
10
- * const mailbox = yield* DurableMailbox;
11
- * const myMailbox = yield* mailbox.create({ agent: "worker-1" });
12
- *
13
- * // Send message with optional reply channel
14
- * yield* myMailbox.send("worker-2", {
15
- * payload: { task: "process-data" },
16
- * replyTo: "deferred:xyz"
17
- * });
18
- *
19
- * // Receive messages
20
- * for await (const envelope of myMailbox.receive()) {
21
- * yield* handleMessage(envelope.payload);
22
- * if (envelope.replyTo) {
23
- * yield* DurableDeferred.resolve(envelope.replyTo, result);
24
- * }
25
- * yield* envelope.commit();
26
- * }
27
- * });
28
- * ```
29
- */
30
- import { Context, Effect, Layer } from "effect";
31
- import { DurableCursor, type Cursor } from "./cursor";
32
- import { appendEvent } from "../store";
33
- import type { MessageSentEvent } from "../events";
34
-
35
- // ============================================================================
36
- // Types
37
- // ============================================================================
38
-
39
- /**
40
- * Envelope wrapping a message with metadata
41
- */
42
- export interface Envelope<T = unknown> {
43
- /** Message payload */
44
- readonly payload: T;
45
- /** Optional URL of DurableDeferred for response */
46
- readonly replyTo?: string;
47
- /** Agent who sent the message */
48
- readonly sender: string;
49
- /** Original message ID */
50
- readonly messageId: number;
51
- /** Thread ID for conversation tracking */
52
- readonly threadId?: string;
53
- /** Commit this message position */
54
- readonly commit: () => Effect.Effect<void>;
55
- }
56
-
57
- /**
58
- * Configuration for creating a mailbox
59
- */
60
- export interface MailboxConfig {
61
- /** Agent name (mailbox owner) */
62
- readonly agent: string;
63
- /** Project key for scoping messages */
64
- readonly projectKey: string;
65
- /** Optional project path for database location */
66
- readonly projectPath?: string;
67
- /** Batch size for reading messages (default: 100) */
68
- readonly batchSize?: number;
69
- }
70
-
71
- /**
72
- * Mailbox instance for an agent
73
- */
74
- export interface Mailbox {
75
- /** Agent name */
76
- readonly agent: string;
77
- /** Send a message to another agent */
78
- readonly send: <T>(
79
- to: string | string[],
80
- envelope: {
81
- payload: T;
82
- replyTo?: string;
83
- threadId?: string;
84
- importance?: "low" | "normal" | "high" | "urgent";
85
- },
86
- ) => Effect.Effect<void>;
87
- /** Receive messages as async iterable */
88
- readonly receive: <T = unknown>() => AsyncIterable<Envelope<T>>;
89
- /** Peek at next message without consuming */
90
- readonly peek: <T = unknown>() => Effect.Effect<Envelope<T> | null>;
91
- }
92
-
93
- /**
94
- * DurableMailbox service interface
95
- */
96
- export interface DurableMailboxService {
97
- /** Create a new mailbox instance */
98
- readonly create: (
99
- config: MailboxConfig,
100
- ) => Effect.Effect<Mailbox, never, DurableCursor>;
101
- }
102
-
103
- // ============================================================================
104
- // Service Definition
105
- // ============================================================================
106
-
107
- /**
108
- * DurableMailbox Context.Tag
109
- */
110
- export class DurableMailbox extends Context.Tag("DurableMailbox")<
111
- DurableMailbox,
112
- DurableMailboxService
113
- >() {}
114
-
115
- // ============================================================================
116
- // Implementation
117
- // ============================================================================
118
-
119
- /**
120
- * Extract envelope from MessageSentEvent
121
- */
122
- function eventToEnvelope<T>(
123
- event: MessageSentEvent & { id: number; sequence: number },
124
- agentName: string,
125
- commitFn: () => Effect.Effect<void>,
126
- ): Envelope<T> | null {
127
- // Filter: only messages addressed to this agent
128
- if (!event.to_agents.includes(agentName)) {
129
- return null;
130
- }
131
-
132
- // Parse body as envelope (assume JSON-encoded)
133
- let payload: T;
134
- let replyTo: string | undefined;
135
- let sender = event.from_agent;
136
-
137
- try {
138
- // Body can be either:
139
- // 1. Plain JSON payload (legacy)
140
- // 2. Envelope JSON with { payload, replyTo?, sender? }
141
- const parsed = JSON.parse(event.body);
142
- if (parsed.payload !== undefined) {
143
- // It's an envelope
144
- payload = parsed.payload as T;
145
- replyTo = parsed.replyTo;
146
- sender = parsed.sender || event.from_agent;
147
- } else {
148
- // It's a plain payload
149
- payload = parsed as T;
150
- }
151
- } catch {
152
- // Body is not JSON, treat as string payload
153
- payload = event.body as unknown as T;
154
- }
155
-
156
- return {
157
- payload,
158
- replyTo,
159
- sender,
160
- messageId: event.message_id || event.id,
161
- threadId: event.thread_id,
162
- commit: commitFn,
163
- };
164
- }
165
-
166
- /**
167
- * Create send function
168
- */
169
- function createSendFn(config: MailboxConfig): <T>(
170
- to: string | string[],
171
- envelope: {
172
- payload: T;
173
- replyTo?: string;
174
- threadId?: string;
175
- importance?: "low" | "normal" | "high" | "urgent";
176
- },
177
- ) => Effect.Effect<void> {
178
- return <T>(
179
- to: string | string[],
180
- envelope: {
181
- payload: T;
182
- replyTo?: string;
183
- threadId?: string;
184
- importance?: "low" | "normal" | "high" | "urgent";
185
- },
186
- ): Effect.Effect<void> => {
187
- return Effect.gen(function* () {
188
- const toAgents = Array.isArray(to) ? to : [to];
189
-
190
- // Create envelope body
191
- const envelopeBody = {
192
- payload: envelope.payload,
193
- replyTo: envelope.replyTo,
194
- sender: config.agent,
195
- };
196
-
197
- // Create MessageSentEvent
198
- const event: Omit<
199
- MessageSentEvent,
200
- "id" | "sequence" | "timestamp" | "type"
201
- > = {
202
- project_key: config.projectKey,
203
- from_agent: config.agent,
204
- to_agents: toAgents,
205
- subject: envelope.threadId || `msg-${Date.now()}`,
206
- body: JSON.stringify(envelopeBody),
207
- thread_id: envelope.threadId,
208
- importance: envelope.importance || "normal",
209
- ack_required: false,
210
- };
211
-
212
- // Append to event store
213
- yield* Effect.promise(() =>
214
- appendEvent(
215
- {
216
- type: "message_sent",
217
- timestamp: Date.now(),
218
- ...event,
219
- },
220
- config.projectPath,
221
- ),
222
- );
223
- });
224
- };
225
- }
226
-
227
- /**
228
- * Create receive function
229
- */
230
- function createReceiveFn(
231
- cursor: Cursor,
232
- agentName: string,
233
- ): <T = unknown>() => AsyncIterable<Envelope<T>> {
234
- return <T = unknown>(): AsyncIterable<Envelope<T>> => {
235
- const messageStream = cursor.consume<
236
- MessageSentEvent & { id: number; sequence: number }
237
- >();
238
-
239
- return {
240
- async *[Symbol.asyncIterator]() {
241
- for await (const msg of messageStream) {
242
- const envelope = eventToEnvelope<T>(msg.value, agentName, msg.commit);
243
- if (envelope) {
244
- yield envelope;
245
- } else {
246
- // Not for this agent, skip and commit
247
- await Effect.runPromise(msg.commit());
248
- }
249
- }
250
- },
251
- };
252
- };
253
- }
254
-
255
- /**
256
- * Create peek function
257
- */
258
- function createPeekFn(
259
- cursor: Cursor,
260
- agentName: string,
261
- ): <T = unknown>() => Effect.Effect<Envelope<T> | null> {
262
- return <T = unknown>(): Effect.Effect<Envelope<T> | null> => {
263
- return Effect.promise(async () => {
264
- const messageStream = cursor.consume<
265
- MessageSentEvent & { id: number; sequence: number }
266
- >();
267
-
268
- for await (const msg of messageStream) {
269
- const envelope = eventToEnvelope<T>(msg.value, agentName, msg.commit);
270
- if (envelope) {
271
- return envelope;
272
- }
273
- // Not for this agent, skip and commit
274
- await Effect.runPromise(msg.commit());
275
- }
276
-
277
- return null;
278
- });
279
- };
280
- }
281
-
282
- /**
283
- * Create mailbox implementation
284
- */
285
- function createMailboxImpl(
286
- config: MailboxConfig,
287
- ): Effect.Effect<Mailbox, never, DurableCursor> {
288
- return Effect.gen(function* () {
289
- const cursorService = yield* DurableCursor;
290
-
291
- // Create cursor for this agent's messages
292
- const cursor = yield* cursorService.create({
293
- stream: `projects/${config.projectKey}/events`,
294
- checkpoint: `agents/${config.agent}/mailbox`,
295
- projectPath: config.projectPath,
296
- batchSize: config.batchSize,
297
- types: ["message_sent"], // Only read message_sent events
298
- });
299
-
300
- return {
301
- agent: config.agent,
302
- send: createSendFn(config),
303
- receive: createReceiveFn(cursor, config.agent),
304
- peek: createPeekFn(cursor, config.agent),
305
- };
306
- });
307
- }
308
-
309
- // ============================================================================
310
- // Layer
311
- // ============================================================================
312
-
313
- /**
314
- * Live implementation of DurableMailbox service
315
- */
316
- export const DurableMailboxLive = Layer.succeed(DurableMailbox, {
317
- create: createMailboxImpl,
318
- });