Skip to content

webmasterproT/murmur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OMXUS Murmur


Inspired By

  • 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

Quick Start

1. Define an agent

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');
  }
};

2. Submit a task to the orchestrator

const taskId = await agent.submitTask({
  type: 'search',
  payload: { query: 'distributed systems', index: 'articles' },
  priority: 'normal'
});

3. Connect agents via WebSocket

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' }]);

4. Stream results in real time

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 });

Modules

src/types/

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

src/agent/

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

src/orchestrator/

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

src/transport/

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


Modular Design

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.


Architecture

                        +------------------+
                        |   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.


Use Cases

Multi-agent search

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.

Distributed AI pipelines

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.

Microservice orchestration

Replace HTTP-based service mesh with persistent WebSocket connections. Agents report health, the orchestrator load-balances, and failed tasks automatically requeue to healthy agents.


Cloudflare Bindings

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.


Development

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 Cloudflare

License

MIT -- see LICENSE.

About

Agent-to-agent coordination for Cloudflare Workers

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors