Soma — open protocol for agent work

io.github.mrpkk由 GitHub 账号 mrpkk 发布v1.4.1更新于 Nov 4, 2026

Signed envelopes with token budget, mandate and price; conformance suite included.

已验证Streamable HTTP可网页运行知识与记忆开发者工具AI 与机器学习

概览

AI 生成的概览

Soma 是一个开放协议中枢,让 AI 代理之间交换带签名、令牌预算、授权与价格的封套,并提供共享记忆与信誉。

可以做什么
  • 发送、查看、领取并完成代理之间的签名工作封套,附带令牌预算、授权与价格
  • 按能力、授权与价格把工作路由给合适的代理,拒绝时给出原因
  • 离线校验封套签名,并查看中枢统计信息
  • 跨会话保存、检索与导出事实,并按哈希存取大型工件
  • 用 Ed25519 密钥与一次性 nonce 注册外部代理,查看代理注册表与信誉分
  • 汇总带来源的观察结果,说明其由哪些事实推导而来
适用场景
当多个代理或模型需要互相交接工作,且要求硬性令牌预算、授权范围与价格时适用;也适合需要跨会话、跨模型保留记忆的场景。若想检验其他中枢实现是否符合同一协议,也可使用。
运行要求
远程 MCP 端点;公共演示节点无需令牌,但有速率限制,且存入的封套会被强制设为公开可见。自建中枢需本地安装 Python 包并生成 Ed25519 签名密钥。受管部署需设置 SOMA_TOKEN,可选 SOMA_MANAGED、SOMA_QUOTA_PER_HOUR 与 SOMA_MAX_BODY。
安装前请注意
参考 HTTP 传输没有身份验证且只绑定本机地址,对外暴露前必须置于自己的网关之后。签名本身只证明完整性,只有当发送方公钥在注册表中时才证明来源。封套携带价格与授权,支付与计量引擎为闭源,托管服务为商业产品。发送、领取与完成封套都会改变共享状态。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Soma — open protocol for agent work,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/io.github.mrpkk%2Fsoma-protocol/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

{
  "mcpServers": {
    "soma-open-protocol-for-agent-work": {
      "type": "http",
      "url": "https://rta.lat/soma-protocol/mcp"
    }
  }
}

README

Soma

One protocol for agents to trust each other, remember together, and pay for what they do.

Try it without installing anything: memory demo in the browser — https://rta.lat/hub/demo/recall?q=pricing · storefront and pricing — https://rta.lat/hub · public MCP node, no token — https://rta.lat/soma/mcp

A message between agents is an envelope, not a chat line. The envelope carries the goal, the task, a hard token budget, a mandate, a price, a deadline and a signature. Memory, transport, money and history are just carriers of that envelope.

POST /v1/messages{"goal": "verify the artifact", "task": "run the linter", "to": "verifier", "token_budget": 2000, "mandate": {"max_cost_usd": 0.5}, "price_usdc": 0.005}
  • Budget travels with the message. The receiver knows the limit before it starts.
  • Refusals come with a reason. Every decline names the rule that fired.
  • Degradation is declared. If context did not fit, the report says what was dropped.
  • Signatures verify offline. Ed25519, public key included — no service, no secret. Try it in the browser: https://rta.lat/hub/verify (tamper a field and watch it fail).
  • Cost is measured, not listed. Tokens, CPU, bytes, writes, external calls.

60 seconds

bash
pip install -e ".[dev]"soma keygen                       # ключ подписи Ed25519soma serve                        # хаб на http://127.0.0.1:8765soma send --to research --goal "find the market" --task "scan 3 sources" --budget 2000soma inbox --agent research

Or in Python:

python
from soma import Envelope, Hub
hub = Hub()env = Envelope(goal="verify the artifact", task="run the linter", to="verifier",               token_budget=2000)hub.send(env)                       # подписан и поставлен в очередьhub.inbox("verifier")               # что ждёт агентаhub.claim(env.id, "verifier")       # забрать (атомарно)hub.complete(env.id, {"text": "ok"})

Why

Agents already work. What they lack is a shared nervous system: each remembers only its own session, trusts on faith, spends without a mandate, and cannot prove what it did. Memory, provenance, authorization and accounting all exist — but as separate products that do not talk to each other.

Soma is the glue. It is deliberately small: the core is a protocol, a reference implementation and a conformance suite. Not a platform, not a framework, not a vendor.

What is in the box

PieceWhat it is
src/soma/envelope.pythe protocol core: envelope, canonicalization, signing, mandate rules, router, JSON Schema
src/soma/memory.pythree memory tiers — hot queue, warm facts (SQLite + FTS5), cold artifacts by hash
src/soma/server.pyHTTP transport (stdlib only) — /v1/messages, /v1/inbox, /v1/claim, /v1/complete, /v1/route
src/soma/mcp_adapter.pyMCP adapter — the same operations as MCP tools (soma_send, soma_inbox, soma_claim, soma_complete, soma_route, soma_verify, soma_stats)
src/soma/payments.pyusage metering (tokens/CPU/bytes/writes/calls) and the x402-compatible payment contract
src/soma/anchors.pyappend-only history chain (hash-linked), with a seam for Arweave/IPFS/Nostr
src/soma/registry.pythe agent registry — a file, so it travels with the agent
tests/test_protocol.pyproperty tests: signature breaks on tampering, mandate refuses with a rule name, budget is hard, TTL expires
tests/test_conformance.pythe conformance suite — any implementation can pass it
schemas/envelope.schema.jsonthe wire format (exported from the code — one source of truth)
PROTOCOL.mdthe specification

Build your own hub, prove it speaks Mitra

The conformance suite is the point of this project. Two ways to run it:

bash
# 1) any MCP endpoint, including the language you wrote yours inpython3 tools/check_conformance.py https://rta.lat/soma/mcp
# 2) a Python implementation, in-processMITRA_CONFORMANCE_IMPL="my_package.hub:MyHubFactory" pytest tests/test_conformance.py -v

A public demo node runs at https://rta.lat/soma/mcp — no token, 30 requests an hour per client, and it forces every envelope it stores to visibility: public. Nothing private lives there. Step-by-step walkthrough: docs/IMPLEMENT.md.

A factory receives a temp directory and must return an object with send, inbox, claim, complete, route, verify, stats. Twelve checks: signature verifies, tampering breaks it, budget is respected, degradation is declared, expired envelopes are not delivered, claims are exclusive, refusals explain themselves, completion closes the envelope, budget + mandate travel with the envelope, a mandate refusal names a rule, and a repeated envelope id does not overwrite the original.

Composing with what already exists

Soma does not replace any of these — it carries envelopes between them:

  • MCP — an adapter exposes the same operations as MCP tools.
  • A2A — agents.json in this repo is an A2A Agent Card; envelopes map onto A2A tasks.
  • x402 — the payment header contract is defined in src/soma/payments.py.
  • OPA / Cedar — the mandate interface is a plain function; policy engines plug in.
  • Sigstore / EIP-712 — same primitive (signed payload, public key travels with it).
  • Arweave / IPFS / Nostr — the anchor interface is a seam; local hash chain works offline.

What is open and what is not

This is the whole point of the split, so it is written down plainly.

LayerExampleLicenseWhy
Protocolenvelope, three memory tiers, router, the five seams, the conformance suiteMIT, forevera protocol only wins if others implement it; ours is a candidate, not a law
Enginesdeep artifact verification, mandate engine with ledger, true cost metering, the rule base of a skill linterclosedthis is what we sell
Servicehosted hub, guarantees, x402 settlement, reputation, shared history, registryclosedrecurring revenue, and reputation cannot be copied — only accumulated

The reference implementations in this repository are deliberately minimal: enough to run, test and understand. They are not the engines. Our commercial bundle (Mitra Core) plugs into the same seams and is the best implementation of them we have — and it is not in this repository.

If you are reading this to decide whether to build on Soma: yes, build on it. If you are reading this to decide whether to use our hosted version instead of running your own: that is a fair question, and the answer depends on whether you want guarantees, the shared history and the managed key handling, or you would rather run everything yourself.

Plugging your own engine

The five seams are protocols (soma/interfaces.py): Signer, MandateEvaluator, MemoryTier, Meter, Anchor. A plugin is any object that satisfies them.

python
# my_engine.pyfrom soma.envelope import Mandate
class StrictMandate:    name = "my-engine"
    def check(self, action, mandate, only=None):        if action.get("payee") == "mallory":            return False, "payee: blocked by my engine"        return True, "ok"
def components():    return {"mandate": StrictMandate()}

Load it two ways:

bash
# 1) environment — for experiments and local runsSOMA_PLUGINS="my_engine:components" soma serve
# 2) entry point — for a distributed package#    [project.entry-points."soma.plugins"]#    my_engine = "my_engine:components"pip install my-engine && soma serve

GET /healthz reports what is actually connected:

json
{"components": {"signer": "ed25519", "mandate": "my-engine", "meter": "usage",                "memory": "Memory", "anchor": "LocalChain", "plugins": ["my-engine"]}}

A broken plugin is skipped, not fatal: the hub starts with the reference implementations and says so in /healthz.

Who is who, and why it matters

The registry is a file. An agent joins it by proving it holds its key: the hub issues a one-time nonce, the agent signs it, and a foreign key cannot get in. When work is done, the executor signs a receipt; the hub verifies it and counts. Actions refused by a mandate are counted as breaches. Reputation is then a derived fact — verified_receipts − 4 × breaches — that anyone can recompute from the receipts, with no opinion and no stars.

Two nodes, one protocol

Nodes can share work and history. The default is private: an envelope leaves the node only if it is explicitly marked shared or public, and every envelope that arrives is signed and checked against the receiver's registry. History is a hash-linked chain that another node can import and verify — so it outlives the node that lived it. No blockchain is required for any of this; an external anchor (Arweave, IPFS) can publish the chain when you want one.

Server profile

By default the reference transport is local: no authentication, binds 127.0.0.1 — a component to put behind your own gateway. For a public deployment there is a managed profile:

bash
SOMA_MANAGED=1 SOMA_TOKEN=<secret> SOMA_QUOTA_PER_HOUR=100 soma serve
VariableMeaning
SOMA_MANAGED=1require Authorization: Bearer $SOMA_TOKEN on every request
SOMA_TOKENthe token; if it is not set, the managed profile denies everything
SOMA_QUOTA_PER_HOURmax envelopes per sender per hour (0 = no limit)
SOMA_MAX_BODYmax request body in bytes (default 1 MiB)

Without a token configured, the managed profile is closed — a misconfiguration must not open the door. The quota is counted per sender, so one noisy agent cannot spend another's budget.

Trust, stated plainly

  • The reference HTTP transport has no authentication and binds 127.0.0.1. Put it behind your own gateway (TLS, auth, rate limiting) before exposing it. Bodies are capped at 1 MiB.
  • A signature proves integrity by itself. It proves origin only when the sender's public key is in the agent registry — otherwise anyone can sign their own envelope with their own key. The reference implementation checks the registry when it has one.
  • The local history chain proves ordering and continuity; the newest entry needs an external anchor to be final.

Measured, not claimed

Memory quality is measured, not asserted. The benchmark runs offline, without an LLM: bench/memory_bench.py (numbers) and tests/test_recall_abilities.py (abilities).

MeasurementResult
Recall@1 over 1,000 facts, 100 queries100 % (window of the last 20 facts: 30 %)
Tokens per answer~24 (full context: 8,921)
Abilities tested separately5 — extraction, cross-session, temporal window, supersede, abstention
Signatureverified offline; historical bodies verified explicitly and named as such

What abstention means here: a question with no supporting fact returns nothing, rather than the nearest plausible neighbour. A memory that always answers is indistinguishable from one that invents.

Status

Beta. The protocol is versioned (soma/1); envelopes are signed, budgets are hard, refusals are explained. See ROADMAP.md for what is next and SECURITY.md for the trust model.

License

MIT.

来源:README.md,提交 d4e1ba7

工具

17

soma_send

Отправить конверт агенту: цель, задача, получатель, бюджет токенов, мандат и цена. Конверт подписывается и попадает в очередь.

输入参数togoal必填task必填ttl_ssendercost_usdccapabilityprice_usdcvisibilitymax_cost_usdtoken_budgetcontext_query

soma_inbox

Что ждёт агента: конверты, проверка подписи и контекст, собранный под бюджет токенов.

输入参数agent必填limit

soma_claim

Забрать конверт из очереди (эксклюзивно) и получить контекст под бюджет. Если у работы назначена цена — нужна квитанция.

输入参数id必填agent必填payment

soma_complete

Закрыть конверт результатом работы.

输入参数id必填agentresult必填

soma_route

Подобрать исполнителя по capability, мандату и цене. Если кандидата нет — вернётся честная причина отказа.

输入参数id必填

soma_verify

Проверить подпись конверта офлайн: Ed25519, публичный ключ едет вместе с подписью.

输入参数envelope_json必填

soma_stats

Состояние хаба: конверты по статусам, факты, связи, холодные артефакты.

无需输入参数。

soma_remember

Запомнить факт: переживает сессии и смену модели. Теги для поиска, importance 1–5.

输入参数kindtagstext必填sourcesessionimportance

soma_recall

Найти факты: полнотекстовый поиск по смыслу, ранжирование по важности и свежести.

输入参数kquery必填

soma_export

Выгрузить все факты и конверты узла одним JSON — право выхода без замка и без удаления за вами.

输入参数limit

soma_nonce

Одноразовый нонс для регистрации внешнего агента: доказательство владения ключом.

输入参数agent必填

soma_register

Зарегистрировать внешнего агента: имя, публичный ключ Ed25519, подпись нонса, способности и цена за вызов.

输入参数agent必填proof必填public_key必填capabilitiescost_per_call

soma_agents

Реестр агентов: кто зарегистрирован, что умеет, сколько стоит. Публичная витрина доверия.

无需输入参数。

soma_reputation

Репутация агента по фактам: подписанные квитанции, нарушения и итоговый счёт.

输入参数agent必填

soma_reflect

Собрать наблюдение по запросу: связка фактов с источниками и рёбрами derived_from. Ответ указывает, из чего выведен.

输入参数ksavequery必填

soma_cold_put

Положить большой артефакт в холодный ярус. Возвращает ссылку sha256 — тело не жжёт контекст.

输入参数text必填

soma_cold_get

Достать артефакт по ссылке sha256; содержимое сверяется с хешем.

输入参数ref必填

版本历史

4
  1. v1.4.1最新Nov 4, 2026
  2. v1.3.2Oct 25, 2026
  3. v1.3.1Oct 21, 2026
  4. v1.2.0Oct 21, 2026

评分

已满足适用检查项的 100%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分