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,80 @@
|
||||
"""A Hermes session as Markdown: what was said, thought, and called, in order.
|
||||
|
||||
Rows are Hermes's `messages` table (state.db), as dicts.
|
||||
|
||||
>>> print(render([
|
||||
... {'role': 'user', 'content': 'Check your messages.'},
|
||||
... {'role': 'assistant', 'content': '', 'reasoning': 'I should look.',
|
||||
... 'tool_calls': '[{"function": {"name": "mcp__host__listMessages", "arguments": "{}"}}]'},
|
||||
... {'role': 'tool', 'tool_name': 'mcp__host__listMessages', 'content': '[]'},
|
||||
... {'role': 'assistant', 'content': 'Nothing there.'},
|
||||
... ], system_prompt='You are Hermes.'))
|
||||
# Hermes session
|
||||
<BLANKLINE>
|
||||
<details><summary>system prompt</summary>
|
||||
<BLANKLINE>
|
||||
````
|
||||
You are Hermes.
|
||||
````
|
||||
</details>
|
||||
<BLANKLINE>
|
||||
## user
|
||||
<BLANKLINE>
|
||||
Check your messages.
|
||||
<BLANKLINE>
|
||||
## assistant
|
||||
<BLANKLINE>
|
||||
> I should look.
|
||||
<BLANKLINE>
|
||||
calls `mcp__host__listMessages`:
|
||||
````json
|
||||
{}
|
||||
````
|
||||
<BLANKLINE>
|
||||
## tool: mcp__host__listMessages
|
||||
<BLANKLINE>
|
||||
````
|
||||
[]
|
||||
````
|
||||
<BLANKLINE>
|
||||
## assistant
|
||||
<BLANKLINE>
|
||||
Nothing there.
|
||||
<BLANKLINE>
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
FENCE = "````"
|
||||
|
||||
|
||||
def _pretty(arguments):
|
||||
try:
|
||||
return json.dumps(json.loads(arguments), indent=2)
|
||||
except (TypeError, ValueError):
|
||||
return str(arguments)
|
||||
|
||||
|
||||
def render(rows, system_prompt=None):
|
||||
"""Markdown for a session's `rows`, after its `system_prompt` if given."""
|
||||
out = ["# Hermes session", ""]
|
||||
if system_prompt:
|
||||
out += ["<details><summary>system prompt</summary>", "",
|
||||
FENCE, system_prompt, FENCE, "</details>", ""]
|
||||
for row in rows:
|
||||
role = row["role"]
|
||||
content = row.get("content") or ""
|
||||
if role == "tool":
|
||||
out += [f"## tool: {row.get('tool_name')}", "", FENCE, content, FENCE, ""]
|
||||
continue
|
||||
out += [f"## {role}", ""]
|
||||
thought = row.get("reasoning") or row.get("reasoning_content")
|
||||
if thought:
|
||||
out += ["\n".join("> " + line for line in thought.splitlines()), ""]
|
||||
if content:
|
||||
out += [content, ""]
|
||||
for call in json.loads(row.get("tool_calls") or "[]"):
|
||||
fn = call.get("function", {})
|
||||
out += [f"calls `{fn.get('name')}`:", FENCE + "json",
|
||||
_pretty(fn.get("arguments")), FENCE, ""]
|
||||
return "\n".join(out)
|
||||
Reference in new issue
Block a user