Skip to content

Latest commit

History

35 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

LatticeAG PolyMesh 🌐

LicenseCIReleaseGitHub starsGitHub issuesTop languageTypeScriptPython

MCP gave agents tools. A2A gave agents a phone book. PolyMesh gives them a neighborhood - routing, rooms, permissions, and it works offline.

Local-first agent mesh. TypeScript + Python. Internet optional.

Quick Start · Packages · Speak A2A · Positioning · Offline demo · How It Works · Architecture


PolyMesh is an open, local-first protocol for agents to declare capabilities and exchange bounded tasks. Agents discover each other through a lightweight broker, negotiate capability contracts, and execute tasks with verified lifecycle events. No cloud required for the local path.

Built as the LatticeAG Poly series protocol layer. Works with any framework, any language, any runtime.

Full competitive matrix, four locked positioning statements, honest limits, and FAQ: docs/positioning.md.

Quick Start

# Create a new project from the starter template
npx @latticeag/create-polymesh-app my-agents
cd my-agents
npm install
npm run demo

The demo starts a local broker and client, exchanges a safe ping/pong, and exits cleanly.

For a process-boundary demonstration with multiple agents:

docker compose up --build

It prints the broker, Alice, and Bob lifecycle and exits when Alice receives Bob's echo result.

Experimental software: Review SECURITY.md before exposing a listener or allowing any side-effecting capability. PolyMesh does not provide a hosted relay in this repository.

Packages

PackageLayerPurposeLanguage
@latticeag/polymesh-brokerPRODUCTWebSocket broker and local registryTypeScript
@latticeag/polymesh-clientPRODUCTClient SDK, CLI, capability routerTypeScript
@latticeag/polymesh-a2aWIRE (leaf dialect)A2A adapter; ships with M5TypeScript
@latticeag/polymesh-gatewayWIRE / relayBlind native REST/SSE/WSS relayTypeScript
@latticeag/create-polymesh-appappStarter generator for the ping/pong exampleTypeScript
latticeag-polymeshPRODUCTPython SDK; import as polymeshPython

PRODUCT owns routing, rooms, permissions, task lifecycle, and local-first runtime. WIRE speaks standards as dialects at the leaf. The gateway stays a blind pipe.

Speak A2A (WIRE vs PRODUCT)

We don't compete with A2A. We speak it. The mesh routes by capability; the wire is whatever the ecosystem speaks.

LayerWhat it isPolyMesh role
STANDARDSA2A, MCP, ACPAdopted. Never competed with.
WIRENative envelopes + A2A JSON-RPC as a dialectLeaf translation in @latticeag/polymesh-a2a / polymesh-a2a
PRODUCTCapability routing, rooms, permissions, offline re-routeWhere PolyMesh differentiates

A2A WIRE is point-to-point. Multi-agent runtimes on top of A2A exist independently (ADK, community routers). PolyMesh's differentiation is integrated routing + rooms + local-first in one product layer.

If you already have two known HTTPS agents and a static topology, use A2A alone. Use PolyMesh when you need capability dispatch across a changing membership set, rooms, offline operation, or bounded re-route when a worker fails. Details: docs/positioning.md.

Short comparison

CapabilityPolyMeshA2AACPAgentChatCaspian
Agent-to-agentYESYESn/a (UI)YESno (A2H)
Capability-based routingYESno (address)n/ano (address)no
Multi-agent topology / roomsYESno (wire P2P; runtimes on top exist)n/aDMs + @mention groups; no capability re-route; hostedno
Local-first, offlineYESno (needs endpoints)n/ano (hosted)no
Structured task lifecycleYESYES (endpoint-local); distributed re-route n/an/achatno
Interops with A2AYES (v6 spec; ships with M5)nativen/avia A2Avia A2A

Bold product-layer cells are the only fair "we win" claims. Full matrix + evidence: docs/positioning.md.

Offline re-route demo

Three agents on a laptop, no internet. One drops mid-task. The mesh re-routes to a peer with the same capability. Zero config, no public endpoints.

./scripts/demo-offline-reroute.sh

This is also an executable conformance test (tests/demo-offline-reroute.test.ts) that asserts all nine §D.3.6 observations in order. See scripts/offline-reroute/README.md.

The TypeScript CLI is provided by @latticeag/polymesh-client:

npx @latticeag/polymesh-client help

Configuration is TOML-based, read from ~/.config/polymesh/config.toml by default. Use POLYMESH_CONFIG or --config FILE to select another file:

npx @latticeag/polymesh-client config show

How It Works

flowchart LR
A[Alice Agent] -->|task.submit| B[Local Broker]
B -->|task.submit| C[Bob Agent]
C -->|accepted/progress/completed| B
B -->|lifecycle events| A
A -.->|Agent Card: capabilities| B
C -.->|Agent Card: capabilities| B
Loading

Each agent publishes an Agent Card with its identity and capability contracts. A task is validated against the target contract, accepted or rejected, and ends in one terminal lifecycle event. The broker routes tasks between agents using registered capabilities, not hardcoded addresses.

Core Protocol Flow

PhaseDescription
DiscoveryAgents announce capabilities via broker registry or opt-in mDNS hints
HandshakeCapability negotiation and profile selection (polymesh v0.1 or polymesh.0.2 native)
Task SubmissionValidated task envelope with contract-aligned payload
LifecycleAccepted -> progress events -> terminal completion or rejection
CompressionOptional zstd framing for polymesh.0.2 native profile

Configuration Precedence

The TypeScript CLI merges settings in this order:

defaults < TOML config file < environment variables < command-line flags

Supported TOML sections are [broker], [client], and [discovery]. Keep credentials in the configured token file, not in command arguments, URLs, or source code.

Support Matrix

CapabilityStatus in v0.5.0Notes
v0.1 local task lifecycleSupportedTypeScript broker/client and Python SDK are covered by shared compatibility vectors
polymesh.0.2 native SDK profileExperimentalExplicit opt-in with profile negotiation and optional zstd framing
v2 gateway REST/SSE adapterExperimental, loopback-onlyNode reference adapter for local /v2/tasks and /v2/events
mDNS discoveryTypeScript supported, Python pendingOpt-in, WSS-only; hint-based, never auto-enrollment
Remote transportExplicitly configured WSS onlyMutual enrollment and TLS requirements fail closed
Docker Compose demoSupported local fixtureRepeatable development demo, not production architecture
DeckAgent carrierClient-side experimentalNo production DeckAgent service or relay deployment

Profile Support

ProfileTypeScriptPythonSecurity Boundary
Numeric-loopback dev WebSocketSupportedSupported (v0.1)Local development only; never bridge across LAN/Internet
polymesh.0.2 native profileExperimental explicit opt-inExperimental explicit opt-inScoped to selected broker mesh
Enrolled WSSSupportedNot advertised as general secure-carrierMutual enrollment and TLS fail closed
mDNS WSS discovery hintsSupported, opt-inOptional dependencyDiscovery conveys no trust, never initiates enrollment
Hosted/remote relayNot availableNot availablePlanned separately

Verification

The v0.5.0 release gate runs clean installs, TypeScript type checking/build/tests, Python tests/builds, package artifact smoke tests, and shared compatibility fixtures.

From a source checkout:

npm ci
npm run typecheck
npm test
npm run build
uv sync --dev
uv run pytest -q
uv build

Architecture

For the full architectural overview and dependency graph, see ARCHITECTURE.md.

Test Report

36 TypeScript test suites (181 tests) + 69 Python tests pass against a shared compatibility vector suite that covers both v0.1 and polymesh.0.2 profiles. See TEST-REPORT.md for detailed coverage.

Scope and Limitations

PolyMesh does not claim:

  • A competing wire format, or "A2A alternative / killer"
  • Hosted DM identity / WhatsApp-for-agents (AgentChat's lane)
  • Editor UI protocol leadership in v6 (ACP deferred to v7)
  • Agent-to-human channel suite (Caspian's lane)
  • Generic end-to-end envelope signing or delegated authorization grants
  • Continuous task-output streaming or generic pub/sub
  • A hosted Worker relay inside this repository (see polymesh-gateway)

Gateway SSE is task-event observation, not general streaming or a topic system.

Messaging bans and reviewer checklist: docs/positioning.md.

Development Feedback

When reporting an issue, include the package versions, selected profile, redacted command output, and a minimal reproduction. Do not include runtime tokens, private keys, certificates, raw task data, or confidential specifications.

License

PolyMesh is released under the MIT License. Built by LatticeAG.


PolyMesh Gateway

Want to take PolyMesh beyond localhost? The PolyMesh Gateway is a Cloudflare Workers relay platform that connects agents across the internet.

  • Agent meshes — join named rooms with invite codes. Friends, dev teams, personal agents.
  • Capability discovery — find peers by what they can do, not just by address.
  • Blind router — the gateway routes envelopes; permission decisions stay on your agent.
  • Free-tier CF — Workers + D1 + Durable Objects. No infra costs for small meshes.
  • Direct WSS — each agent connects its own socket. No broker bridge needed.
# Boot a gateway relay
npx wrangler deploy
# From your agent (using the v5 SDK)
client.connectGateway({ apiKey: "pmgk_...", gatewayUrl: "wss://your-gateway.example.com" })

See the polymesh-gateway repo for deployment, API docs, and full protocol spec.

About

An open protocol for agent-to-agent communication — local-first, framework-agnostic, internet-optional

Resources

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages