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:
1 parent
783e4c595f
commit
3f9ba54477
15 files changed
+2398
-282
No files matched your search
@@ -0,0 +1,49 @@
|
||||
// An unconfined Endo caplet: a WebApp for one URL, as the fake host's
|
||||
// WebApp is (fake_host.py), with Node's fetch.
|
||||
//
|
||||
// env: URL, the WebApp's URL; FAR and BYTES_READER, the file URLs of
|
||||
// @endo/far and @endo/exo-stream's bytes-reader-from-iterator.js in the
|
||||
// daemon's checkout (this file lives outside it, so it can't import them
|
||||
// by name).
|
||||
|
||||
const within = (base, url) => {
|
||||
const b = new URL(base);
|
||||
const u = new URL(url);
|
||||
return u.origin === b.origin && u.pathname.startsWith(b.pathname);
|
||||
};
|
||||
|
||||
const makeWebApp = (lib, fetch, url) => {
|
||||
const { Far, bytesReaderFromIterator } = lib;
|
||||
const fire = async (method, body) => {
|
||||
const resp = await fetch(url, { method, body });
|
||||
return new Uint8Array(await resp.arrayBuffer());
|
||||
};
|
||||
return Far('WebApp', {
|
||||
pathjoin(path) {
|
||||
const next = new URL(path, url).href;
|
||||
if (!within(url, next)) throw Error(`pathjoin: ${next} is not within ${url}`);
|
||||
return makeWebApp(lib, fetch, next);
|
||||
},
|
||||
query(params) {
|
||||
const next = new URL(url);
|
||||
for (const [k, v] of Object.entries(params)) next.searchParams.set(k, String(v));
|
||||
return makeWebApp(lib, fetch, next.href);
|
||||
},
|
||||
get: async () => new TextDecoder().decode(await fire('GET')),
|
||||
// the body as a bytes reader (it answers streamBase64), which a
|
||||
// mount's write(path, blob) takes; fetched as the mount reads it
|
||||
blob: () =>
|
||||
bytesReaderFromIterator(
|
||||
(async function* body() {
|
||||
yield await fire('GET');
|
||||
})(),
|
||||
),
|
||||
post: async body => new TextDecoder().decode(await fire('POST', body)),
|
||||
});
|
||||
};
|
||||
|
||||
export const make = async (_powers, _context, { env }) => {
|
||||
const { Far } = await import(env.FAR);
|
||||
const { bytesReaderFromIterator } = await import(env.BYTES_READER);
|
||||
return makeWebApp({ Far, bytesReaderFromIterator }, globalThis.fetch, env.URL);
|
||||
};
|
||||
Reference in new issue
Block a user