nervネルフ

Where the vendor knowledge lives

One question — where does the knowledge of how to talk to a vendor live? — and a tenfold difference in what the answer costs. Measured against the Rust ports.

pideepseeknerv
where it livesin-process: thirteen protocol modules and a 103-row tableone crate behind a port traita separate program, spawned per turn
size~9,700 production lines1,121 lines~5,300 production lines, plus 943 of Lua
providers shipped103 — 88 of them pure data18
wire protocols13 native modules18 Lua tables
adding a compatible provider~17 lines of Rust data, then recompilenot a supported operation~10 lines of Lua, no rebuild
adding a new protocola module, a route kind, a normaliser, recompilea new cratea do … end block, no rebuild
HTTPhand-rolled HTTP/1.1, 3,034 linesa librarya library
does it streamyesnoyes, end to end, across the pipe
credential store13,156 lines: four OAuth flows, an AWS chain, an SSO cache, a rotation ringenvironment variables, 83 linesenvironment variables and one OAuth store

The same shape, at a tenth of the cost

pi and nerv arrive at structurally similar layers — a catalog of vendors as data, a small set of protocol adapters, one neutral message model. pi pays roughly ten times for it, and most of that is not the process boundary. It is the difference between “a protocol is a Rust module” and “a protocol is a Lua table”.

-- melchior/config/providers.lua — one provider, no rebuild
melchior.provider("deepseek", {
  name = "DeepSeek", api = "openai-completions",
  base_url = "https://api.deepseek.com",
  auth = { kind = "api-key", vars = { "DEEPSEEK_API_KEY" } },
  compat = { thinking_format = "deepseek" },
  models = { { id = "deepseek-chat" } },
})

The best idea in pi's provider layer

Its table feeds everything else, including predicates that would otherwise be hardcoded lists — “is this provider keyless” is derived from having no auth variables and no auth header, so local runtimes work without being named anywhere — and including the published documentation, rendered from the same table with a golden test on the output. That is cheap and worth having.

What the separate process is for

What was deliberately not taken: the 103-row table itself, the hand-rolled HTTP client, the failover chains, the credential-rotation ring, and the credential scavenging that reads other agents' configuration files. Seven providers answer the same question, and the eighth costs ten lines.