- 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
74 lines
4.8 KiB
Markdown
74 lines
4.8 KiB
Markdown
# Being an Endo guest
|
|
|
|
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 work like file descriptors
|
|
|
|
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 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
|
|
{"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(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 `resultName`.
|
|
- `get()` and `post(body)` fire the request and answer the body as text.
|
|
- `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
|
|
{"source": "E(npm).pathjoin('ms')", "codeNames": ["npm"], "petNamePaths": [["npm"]], "resultName": ["ms-meta"]}
|
|
{"source": "E(meta).get()", "codeNames": ["meta"], "petNamePaths": [["ms-meta"]]}
|
|
```
|
|
|
|
## Files: your downloads folder
|
|
|
|
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:
|
|
|
|
```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"]]}
|
|
```
|
|
|
|
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(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: 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.
|
|
|
|
In the source, `E` is eventual send (`E(x).method(...)` answers a promise) and `Far` makes a remotable object.
|
|
|
|
For example, an object that answers the latest version of an npm package, given a WebApp for the registry:
|
|
|
|
```json
|
|
{
|
|
"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/"}}
|
|
}
|
|
```
|