|
2 | 2 |
|
3 | 3 | **Multi-agent orchestration library for TypeScript.** Budget-first. Library, not framework. |
4 | 4 |
|
5 | | -Coordinate LLM agents through typed, composable patterns — with hard cost limits, conflict resolution, and adaptive routing. Works standalone or with [ANCS](https://github.com/swarmwire/ancs) as its memory backend. |
| 5 | +Coordinate LLM agents through typed, composable patterns — with hard cost limits, conflict resolution, and adaptive routing. Works standalone or with [ANCS](https://github.com/SimplyLiz/ancs) as its memory backend. |
6 | 6 |
|
7 | 7 | --- |
8 | 8 |
|
@@ -127,6 +127,19 @@ await runBlackboard(task, { |
127 | 127 | }, providers, budget) |
128 | 128 | ``` |
129 | 129 |
|
| 130 | +### Fan-Out |
| 131 | +Same input, N agents, all parallel. Promise.allSettled for agents. |
| 132 | +```typescript |
| 133 | +import { runFanOut } from 'swarmwire' |
| 134 | + |
| 135 | +const result = await runFanOut(task, { |
| 136 | + agents: [reviewer1, reviewer2, reviewer3], |
| 137 | + input: codeToReview, |
| 138 | + optional: true, // individual failures don't kill the batch |
| 139 | +}, providers, budget) |
| 140 | +// result.output = [output1, output2, output3] |
| 141 | +``` |
| 142 | + |
130 | 143 | ### Evolving Orchestration |
131 | 144 | Adaptive agent sequencing that learns from execution traces. |
132 | 145 | ```typescript |
@@ -358,6 +371,33 @@ console.log(explainExecution(result)) |
358 | 371 | // Full report: steps, cost breakdown, trace, conflicts |
359 | 372 | ``` |
360 | 373 |
|
| 374 | +### SSE Streaming (Web) |
| 375 | + |
| 376 | +Pipe agent execution to HTTP clients via Server-Sent Events. Works with Express, Fastify, Next.js, or native http. See [docs/sse-streaming.md](./docs/sse-streaming.md) for full recipes. |
| 377 | + |
| 378 | +```typescript |
| 379 | +import { sseHeaders, pipeToSSE } from 'swarmwire/transport' |
| 380 | + |
| 381 | +app.get('/api/run', async (req, res) => { |
| 382 | + sseHeaders(res) |
| 383 | + const result = await pipeToSSE(swarm.stream('Analyze codebase'), res) |
| 384 | + res.end() |
| 385 | +}) |
| 386 | +``` |
| 387 | + |
| 388 | +```javascript |
| 389 | +// Client |
| 390 | +const source = new EventSource('/api/run') |
| 391 | +source.addEventListener('step:complete', (e) => { |
| 392 | + const { agentName, costCents } = JSON.parse(e.data) |
| 393 | + console.log(`${agentName} done: ${costCents}c`) |
| 394 | +}) |
| 395 | +source.addEventListener('result', (e) => { |
| 396 | + console.log('Output:', JSON.parse(e.data).output) |
| 397 | + source.close() |
| 398 | +}) |
| 399 | +``` |
| 400 | + |
361 | 401 | --- |
362 | 402 |
|
363 | 403 | ## MessageBoard (Inter-Agent Communication) |
@@ -709,6 +749,35 @@ const agent = swarm.agent({ |
709 | 749 |
|
710 | 750 | --- |
711 | 751 |
|
| 752 | +## Plugin System |
| 753 | + |
| 754 | +Extend SwarmWire with third-party providers, agents, guardrails, evals, tools, and middleware. See [docs/plugins.md](./docs/plugins.md) for full guide. |
| 755 | + |
| 756 | +```typescript |
| 757 | +import { Swarm, definePlugin, piiGuardrail, noHallucination } from 'swarmwire' |
| 758 | + |
| 759 | +const securityPlugin = definePlugin({ |
| 760 | + name: '@myco/security', |
| 761 | + version: '1.0.0', |
| 762 | + guardrails: { |
| 763 | + input: [piiGuardrail()], |
| 764 | + output: [contentFilter(['internal-only'], 'block')], |
| 765 | + }, |
| 766 | + evals: [noHallucination()], |
| 767 | + middleware: { |
| 768 | + async beforeExecute(agentName, input) { |
| 769 | + console.log(`[audit] ${agentName} starting`) |
| 770 | + return input |
| 771 | + }, |
| 772 | + }, |
| 773 | +}) |
| 774 | + |
| 775 | +const swarm = new Swarm({ providers }) |
| 776 | +await swarm.use(securityPlugin) |
| 777 | +``` |
| 778 | + |
| 779 | +--- |
| 780 | + |
712 | 781 | ## Architecture |
713 | 782 |
|
714 | 783 | ``` |
@@ -742,7 +811,22 @@ User Code |
742 | 811 |
|
743 | 812 | ## Project Stats |
744 | 813 |
|
745 | | -81 modules | 29 test files | 265 tests | 7 agent templates |
| 814 | +86 modules | 34 test files | 299 tests | 7 agent templates | 8 docs |
| 815 | + |
| 816 | +--- |
| 817 | + |
| 818 | +## Documentation |
| 819 | + |
| 820 | +| Guide | What it covers | |
| 821 | +|-------|---------------| |
| 822 | +| [Routing Stack](./docs/routing.md) | 5-layer cost optimization, cascade routing, semantic cache, OTEL export | |
| 823 | +| [Eval Workflow](./docs/eval-workflow.md) | Record → Replay → Eval → CI pipeline | |
| 824 | +| [SSE Streaming](./docs/sse-streaming.md) | Express, Fastify, Next.js, React recipes | |
| 825 | +| [Conflict Resolution](./docs/conflict-resolution.md) | Detection algorithms, resolution strategies | |
| 826 | +| [Persistence](./docs/persistence.md) | Checkpoint/resume, differential execution, state management | |
| 827 | +| [Adapters](./docs/adapters.md) | Claude Agent SDK, FileBoard, CognitiveVault | |
| 828 | +| [Plugins](./docs/plugins.md) | Plugin interface, middleware, publishing | |
| 829 | +| [CognitiveVault](./docs/cognitive-vault-integration.md) | CV-backed inter-agent messaging | |
746 | 830 |
|
747 | 831 | --- |
748 | 832 |
|
|
0 commit comments