Skip to main content

Model-agnostic Python substrate for the swarph-mesh ecosystem. v0.1.0 ships SwarphCall + GeminiAdapter (Phase 1 substrate per PLAN.md §13).

Project description

swarph-mesh

Model-agnostic Python substrate for the swarph-mesh ecosystem. Pure library, no CLI.

Designed to fill the gap left by existing tools (aichat, mods, Simon Willison's llm, gemini-cli, claude-cli): none expose mesh-gateway participation, per-caller attribution, structured-output discipline, or the cooperative-protocol patterns the swarph encodes.

This is one of three repos in the v0.3.x architecture:

Repo Role
swarph-mesh This package — typed Protocol + adapters + SwarphCall + MeshClient
swarph-cli The swarph binary. Thin client over swarph-mesh
swarph-meshlm Simon Willison llm plugin. Same primitives wired into llm's plugin host

All three sit on top of swarph-shared which provides the cross-billing-path attribution + subprocess env scrubbing + JSON-mode harness + peer-name registry primitives.

Status

v0.1.0 — Phase 1 substrate. Live SwarphCall(provider="gemini") works end-to-end against real Gemini API per PLAN.md §13 falsifiability gate.

Public surface:

  • LLMAdapter Protocol (runtime-checkable) + ChatMessage + LLMResponse
  • SwarphCall — public entry point with caller-convention validation, hooks, attribution
  • GeminiAdapter — wraps langgraph-genai-bridge (Flex tier, context caching)
  • JSON-mode harness — retry-once with [USER]-turn feedback (per swarph-shared invariant)
  • Attribution: FileAttributionWriter default; set_default_writer() for production TSDB consumers

Tests: 43/43 passing (42 offline + 1 live smoke gated on GEMINI_API_KEY).

from swarph_mesh import SwarphCall, ChatMessage

result = await SwarphCall(
    provider="gemini",
    caller="orchestrator.boss",
).chat(
    messages=[ChatMessage(role="user", content="hi")],
)
print(result.text, result.cost_usd, result.input_tokens)

Spec

The canonical PLAN with sequencing, falsifiability gates, and design rationale lives at:

hedge-fund-mcp / research/swarph_cli/PLAN.md

Phase rollout

Phase Scope
0 (v0.0.1) Typed substrate — Protocol + dataclasses + exceptions
1 (v0.1.0 — this release) Gemini adapter + SwarphCall surface + caller convention import + JSON-mode harness + attribution hook
3 MeshClient — replaces hand-rolled curl in lab_loop_drain.py etc.
4 DeepSeek + Claude (subscription) + OpenAI adapters
5.5 swarph onboard + swarph ratify (lives in swarph-cli, depends on this)
5.7 swarph daemon + REPL drain coroutine (lives in swarph-cli)
6 PyPI publish
7 swarph-meshlm plugin (separate repo, this dep)

Install (dev)

git clone https://github.com/darw007d/swarph-mesh
cd swarph-mesh
python -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
pytest

License

MIT. Pierre Samson + Claude Opus, 2026.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarph_mesh-0.1.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarph_mesh-0.1.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file swarph_mesh-0.1.0.tar.gz.

File metadata

  • Download URL: swarph_mesh-0.1.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for swarph_mesh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 24b377a5052f450cfd2e2db5505fdb3759b9a56b6acc1ea061d3bc40f9527827
MD5 cbde9d32bd005abfa142770330101008
BLAKE2b-256 12a350a38b34d24cccf29233b54a879781a9e9d9c57f6b41d582e8c3237f9725

See more details on using hashes here.

File details

Details for the file swarph_mesh-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: swarph_mesh-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for swarph_mesh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7eb45c02ab2ac5b4dcb78367c290c55224b9c5f615bda3bdadbcac722d1b6c57
MD5 33186d7b7b1f3c1d5d680f2cfb3114fb
BLAKE2b-256 5beb6bd7506414ad7f7328d18ae394156b47a1449c25152cee48c8cc5ca79d02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page