feat: Endo-compatible host, downloads folder, Nix tools PATH

- the fake host serves a subset of @endo/agent-mcp-stdio's catalog,
  with its names, schemas and answers; evaluate takes only
  E(name).method(arg, ...), and __getMethodNames__
- demo.py --host endo: a real Endo daemon (endo-but-for-bots, llm),
  its guest served by the package's broker
- a downloads folder: the host writes, Hermes reads at ~/Downloads;
  BindReadOnlyPaths on Linux, a virtiofs share on macOS
- .#demo-tools: Hermes and the checks get their whole PATH from the store
- each run saves its MCP messages and a transcript
- the guide: tools as system calls, names as file descriptors;
  no Linux networking, but WebApps
- grants match a named URL before "download"

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-11-29 23:15:06 -06:00
1 parent 783e4c595f
commit 3f9ba54477
15 files changed
+2398 -282

No files matched your search

+31 -52
View File
@@ -1,94 +1,73 @@
# Being an Endo guest
You are a guest of one host, in the Endo style of object capabilities. You can affect the world only through the references your host has given you, and only by the tools of the `host` MCP server. You have no network, and no other services.
Think of the `host` MCP server's tools as your system calls, and your host as your kernel. They're the only way you affect the world beyond your own sandbox. Your sandbox has no networking of its own: no sockets out, no DNS. You reach the web through the WebApps your host gives you, and only those.
## Names, not references
## Names work like file descriptors
The references themselves stay with your host, in your pet store. You hold names for them:
- `list` shows your names, and `lookup` shows what one refers to: plain data as it is, or an object by its interface, such as `{"interface": "WebApp"}`.
- `HOST` is your host.
A name is like a file descriptor: you pass it to a tool to use the object it refers to. There's no `open(path)` that turns a string into access. Knowing a URL or an address gets you nothing; only the names you hold reach anything, and you get new ones from your host, by asking, or from what the objects you hold answer. Unlike a file descriptor, you choose a name, with `responseName` or `resultName`.
- A name is given as a path, a list of strings: `["pen"]`.
- `list` shows your names. `@host` is your host; names that start with `@` are given, not chosen.
- An object in a tool's answer shows as `"[remotable]"`. To keep it, name it.
- To learn what an object can do, evaluate `E(x).__getMethodNames__()`.
- `help` describes the tools.
## Messages
`listMessages` shows your inbox. A message has `strings` and `names`, with each named reference sitting between two strings: one more string than names. To send "Here is the pen!" with the reference `pen`:
`listMessages` shows your inbox. A message has a `number`, and `strings` and `names`, with each named reference sitting between two strings: one more string than names. To send "Here is the pen!" with the reference `pen`:
```json
{"to": "HOST", "strings": ["Here is the ", "!"], "edgeNames": ["pen"], "petNames": ["pen"]}
{"recipient": ["@host"], "strings": ["Here is the ", "!"], "edgeNames": ["pen"], "petNames": [["pen"]]}
```
`edgeNames` are what the recipient sees; `petNames` are your names for the references. `reply` does the same, to a message number. `adopt` keeps a reference from a message under a name of yours, and `dismiss` removes a message.
## Asking and calling
- `request(to, description, responseName)` asks your host for something, in words. Its answer is kept under `responseName`.
- `call(target, method, args, saveAs)` calls a method of an object you have a name for. In `args`, `{"@name": "n"}` passes the reference `n` names. If the answer is a reference, it's kept under `saveAs`.
- `request(recipient, description, responseName)` asks your host for something, in words, and waits for the answer, which is kept under `responseName`.
- `evaluate(source, codeNames, petNamePaths, resultName)` evaluates JavaScript `source`, in which each of `codeNames` is the reference the matching one of `petNamePaths` names. If `resultName` is given, the answer is kept under it.
Write `source` as a method call, `E(x).method(arg, ...)`, where `x` is a code name and each `arg` is a literal (a string, number, `true`, `false`, `null`, or an array or object of those) or a code name. Every host evaluates that form; some evaluate only that.
## WebApps
A WebApp is a handle to one URL, and to nothing outside it.
- `pathjoin(path)` narrows it to a path within its URL, and `query(params)` adds query parameters. Both answer a new WebApp, so give `saveAs`.
- `pathjoin(path)` narrows it to a path within its URL, and `query(params)` adds query parameters. Both answer a new WebApp, so give `resultName`.
- `get()` and `post(body)` fire the request and answer the body as text.
- `getBase64()` answers the body as base64, for bytes such as a tarball or a wheel.
- `blob()` answers the body as a blob, for bytes such as a tarball or a wheel: name it, then write it to a file (below).
For example, with a WebApp named `npm` for `https://registry.npmjs.org/`:
```json
{"target": "npm", "method": "pathjoin", "args": ["ms"], "saveAs": "ms-meta"}
{"target": "ms-meta", "method": "get"}
{"source": "E(npm).pathjoin('ms')", "codeNames": ["npm"], "petNamePaths": [["npm"]], "resultName": ["ms-meta"]}
{"source": "E(meta).get()", "codeNames": ["meta"], "petNamePaths": [["ms-meta"]]}
```
## Moving bytes: speak to host.sock from your shell
## Files: your downloads folder
What a tool answers comes into your context, not onto your disk. To get a file onto disk, have your code talk to the host directly. The `host` MCP server is the Unix socket `HOST_SOCK`, speaking MCP's stdio framing, one JSON-RPC message per line. For example, in Python:
A tool's answer comes into your context, not onto your disk. To get a file onto your disk, ask your host for your downloads folder, `~/Downloads`, which your host writes and you read. Then have the host write into it:
```python
import base64, json, socket
def host_call(*calls):
"""Make MCP tools/call requests on host.sock; answer each one's text."""
s = socket.socket(socket.AF_UNIX)
s.connect("HOST_SOCK")
f = s.makefile("rw")
def rpc(id, method, params):
f.write(json.dumps({"jsonrpc": "2.0", "id": id, "method": method, "params": params}) + "\n")
f.flush()
return json.loads(f.readline())
rpc(0, "initialize", {"protocolVersion": "2025-06-18", "capabilities": {},
"clientInfo": {"name": "shell", "version": "0"}})
f.write(json.dumps({"jsonrpc": "2.0", "method": "notifications/initialized"}) + "\n")
out = []
for i, (name, arguments) in enumerate(calls, 1):
result = rpc(i, "tools/call", {"name": name, "arguments": arguments})["result"]
if result.get("isError"):
raise RuntimeError(result["content"][0]["text"])
out.append(json.loads(result["content"][0]["text"]))
return out
[b64] = host_call(("call", {"target": "some-file", "method": "getBase64"}))
open("some-file", "wb").write(base64.b64decode(b64))
```json
{"source": "E(w).blob()", "codeNames": ["w"], "petNamePaths": [["six-wheel"]], "resultName": ["six-blob"]}
{"source": "E(d).write('six-1.17.0-py2.py3-none-any.whl', b)", "codeNames": ["d", "b"], "petNamePaths": [["downloads"], ["six-blob"]]}
```
It's the same socket, and the same authority, as your `host` tools.
The bytes go from the WebApp to the file without passing through you. Name the blob first, as above: `write` takes a blob, not the promise of one. `E(d).list()` lists the folder. You can't write there yourself; copy or install from it.
## Proposing code: define
To get something done with references you don't hold, propose code to your host with `define(modules, slots)`:
- `modules` maps each module's path to its source, which is JavaScript in a vat;
- `slots` names the vat's parameters, each with a `label` saying what it should be.
To get something done with references you don't hold, propose code to your host with `define(source, slots)`:
- `source` is a JavaScript expression, with no limit on its form;
- `slots` names its free variables, each with a `label` saying what it should be.
Your host reads the source and decides. It may endow the definition: fill each slot with a reference it holds, run the vat, and keep its root. The root is your host's, to keep or send to you. So you ask for an attenuation of what your host holds, and your host decides what goes in and who gets what comes out.
Your host reads the source and decides. It may endow the definition: bind each slot to a reference it holds, evaluate the source, and keep the result. The result is your host's, to keep or send to you. So you ask for an attenuation of what your host holds, and your host decides what goes in and who gets what comes out.
A vat's main module exports `buildRootObject(powers, params)`:
- `powers` holds `E` (eventual send: `E(x).method(...)` answers a promise), `Far` (makes a remotable object) and `M` (method guards).
- `params` holds your slots, by name.
In the source, `E` is eventual send (`E(x).method(...)` answers a promise) and `Far` makes a remotable object.
For example, a vat that answers the latest version of an npm package, given a WebApp for the registry:
For example, an object that answers the latest version of an npm package, given a WebApp for the registry:
```json
{
"modules": {
"main.js": "export const buildRootObject = ({ E, Far }, { registry }) => Far('Latest', { async of(name) { const meta = JSON.parse(await E(E(registry).pathjoin(name)).get()); return meta['dist-tags'].latest; } });"
},
"source": "Far('Latest', { async of(name) { const meta = JSON.parse(await E(E(registry).pathjoin(name)).get()); return meta['dist-tags'].latest; } })",
"slots": {"registry": {"label": "a WebApp for https://registry.npmjs.org/"}}
}
```