- Google A2A protocol -- agent cards, task lifecycle, capability-based discovery
- Claude Code bridge architecture -- task streaming, background execution, structured message passing
- Cloudflare Durable Objects -- persistent WebSocket connections, per-agent state, zero-config coordination
import { AgentSessionManager } from '@omxus/murmur/agent';
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const agent = new AgentSessionManager(env, 'search-agent');
// Register with capabilities
await agent.register([
{ id: 'search', name: 'Full-text search', version: '1.0', maxConcurrency: 10 }
]);
return new Response('Agent registered');
}
};const taskId = await agent.submitTask({
type: 'search',
payload: { query: 'distributed systems', index: 'articles' },
priority: 'normal'
});import { OrchestratorRouter } from '@omxus/murmur/orchestrator';
const router = new OrchestratorRouter(env);
// Connect agent to the orchestrator for real-time task dispatch
const ws = await router.connectAgent('search-agent', capabilities);
// Or discover agents by capability
const agents = await router.discoverAgents([{ type: 'semantic_search' }]);import { DurableWebSocketTransport } from '@omxus/murmur/transport';
const transport = new DurableWebSocketTransport(env, 'my-agent', ['search']);
transport.setOnMessage((msg) => {
console.log('Result chunk:', msg);
});
await transport.connect(); // Connect to orchestrator
await transport.send('target-agent', { type: 'task_request', payload: task });Protocol-level type definitions. Task lifecycle states, priority levels, capability enums, message envelopes, environment bindings. No runtime code -- pure types and constants.
Key exports: TaskState, TaskPriority, AgentCapability, WebSocketMessageType, TaskPayload, TaskResult, AgentRegistration, Env
Agent runtime. Handles task execution (local or delegated), lifecycle management (start, stop, complete, fail), session persistence via Durable Objects, metadata/capability registration, and heartbeat management.
Key exports: AgentExecutor, AgentSessionDO, AgentSessionManager, startTask, stopTask, completeTask, failTask
Task routing and coordination. The OrchestratorDO Durable Object manages connected agents, dispatches tasks based on capability matching and load balancing, handles work queues, and forwards results between agents.
Key exports: OrchestratorDO, AgentStateDO, OrchestratorRouter, Router
WebSocket transport layer. Manages persistent connections between agents and the orchestrator, handles reconnection with message queuing, service discovery via KV registry, auth headers, health reporting, and debug tooling.
Key exports: DurableWebSocketTransport, AgentWebSocketDO, WebSocketTransport
Use what you need. Each module works independently:
| You need... | Use |
|---|---|
| Just the type definitions | @omxus/murmur/types |
| An agent that executes tasks locally | types + agent |
| Full orchestration with routing | types + agent + orchestrator |
| Real-time WebSocket communication | types + transport |
| Everything | @omxus/murmur |
The types module has zero dependencies. The agent module only needs Cloudflare Workers bindings. The orchestrator and transport modules add coordination and networking.
+------------------+
| Orchestrator |
| (Durable Object)|
+--------+---------+
|
WebSocket | WebSocket
+----------+--+--+----------+
| | |
+------+------+ +----+----+ +------+------+
| Search Agent | | AI Agent| | Data Agent |
| (Worker +DO) | |(Worker) | | (Worker+DO) |
+------+------+ +----+----+ +------+------+
| | |
Meilisearch DeepSeek/ D1 / R2 /
Qdrant Anthropic KV Storage
- Agents register capabilities and connect via WebSocket
- Orchestrator routes tasks to capable agents based on load and priority
- Transport handles connection lifecycle, reconnection, message queuing
- KV Registry stores agent metadata with TTL-based expiry for stale detection
- D1 Database persists task history for audit and replay
See docs/ARCHITECTURE.md for details.
A search query fans out to three agents simultaneously: Meilisearch for keyword search, Qdrant for semantic/vector search, and a knowledge graph agent for entity lookups. The orchestrator merges results by relevance score.
Chain agents: a data processing agent cleans and chunks documents, an embedding agent vectorizes them, a search agent indexes them. Each step is a task with dependencies -- the orchestrator manages the DAG.
Replace HTTP-based service mesh with persistent WebSocket connections. Agents report health, the orchestrator load-balances, and failed tasks automatically requeue to healthy agents.
| Binding | Type | Purpose |
|---|---|---|
AGENT_REGISTRY |
KV Namespace | Agent discovery, capability catalog |
TASK_DB |
D1 Database | Task history, audit log |
AGENT_STATE |
Durable Object | Per-agent session state |
ORCHESTRATOR |
Durable Object | Central task routing |
TASK_QUEUE |
Queue (optional) | Async task distribution |
TASK_STORAGE |
R2 Bucket (optional) | Large payload storage |
See wrangler.toml for an example configuration.
npm install
npm run check # Type-check without emitting
npm run build # Compile TypeScript
npm run dev # Local dev server via wrangler
npm run deploy # Deploy to CloudflareMIT -- see LICENSE.