Added slash command handling
This commit is contained in:
1 parent
10e9565e2e
commit
1bcadcf950
16 files changed
+567
-21
No files matched your search
@@ -150,18 +150,22 @@ request. The app uses this to **populate the initial view** when a channel is
|
||||
opened (complements `sync`, which only replays undelivered outbox frames).
|
||||
|
||||
### `commands.catalog`
|
||||
Response to a `commands.catalog` request. Full slash-command list.
|
||||
Request (app → server, empty payload) and response: the gateway's
|
||||
slash-command catalog for the app's `/` drawer. Derived from hermes' central
|
||||
`COMMAND_REGISTRY` (the same source the gateway help and the Telegram command
|
||||
menu use), restricted to commands available on gateway surfaces, plus
|
||||
plugin-registered commands. The app fuzzy-matches the typed prefix
|
||||
client-side (no `commands.complete` round-trip).
|
||||
```json
|
||||
{"type":"commands.catalog","id":21,"payload":{
|
||||
"commands":[
|
||||
{"name":"/new","description":"Start a new session","args_hint":"","category":"session"},
|
||||
{"name":"/model","description":"Switch model","args_hint":"<provider/model>","category":"config"},
|
||||
{"name":"/reasoning","description":"Toggle reasoning effort","args_hint":"[low|medium|high]","category":"config"},
|
||||
{"name":"/status","description":"Show session status","args_hint":"","category":"info"},
|
||||
{"name":"/cron","description":"Manage cron jobs","args_hint":"<list|add|rm>","category":"automation"},
|
||||
{"name":"/tools","description":"List available tools","args_hint":"","category":"info"}
|
||||
{"name":"/new","description":"Start a new session (fresh session ID + history)","args_hint":"[name]","category":"Session","aliases":["/reset"]},
|
||||
{"name":"/model","description":"Switch model","args_hint":"<provider/model>","category":"Configuration","aliases":[]},
|
||||
{"name":"/status","description":"Show session status","args_hint":"","category":"Info","aliases":[]}
|
||||
]}}
|
||||
```
|
||||
`name`/`aliases` carry the leading slash; `args_hint` is the registry's
|
||||
argument placeholder (empty when the command takes none).
|
||||
|
||||
### `commands.complete`
|
||||
Response to a `commands.complete` request. Autocomplete matches for a typed prefix.
|
||||
|
||||
+17
-9
@@ -81,17 +81,25 @@ app/shared/src/
|
||||
auto-grow field, attach (paperclip), mic/send (right). Send on Enter
|
||||
(configurable: Enter=send vs Enter=newline).
|
||||
|
||||
### Menu button → all slash commands
|
||||
- `Menü` opens a **bottom sheet** listing the command catalog. The catalog is
|
||||
served by the gateway via `commands.catalog` request → response with
|
||||
`{name, description, args_hint, category}` per command, so it always matches
|
||||
hermes (`/new`, `/model`, `/reasoning`, `/status`, `/cron`, `/tools`, …).
|
||||
- Typing `/` in the field shows **autocomplete** via `commands.complete`
|
||||
request (gateway matches the typed prefix). Selecting inserts `/cmd `.
|
||||
- Selecting a command sends `message.send {text:"/cmd args"}`.
|
||||
### Slash commands
|
||||
- **`/` drawer (implemented):** typing `/` in the composer rolls a drawer up
|
||||
over the input listing the command catalog. The catalog is served by the
|
||||
gateway via `commands.catalog` request → response with
|
||||
`{name, description, args_hint, category, aliases}` per command (derived
|
||||
from hermes' `COMMAND_REGISTRY`, gateway-available subset + plugin commands),
|
||||
so it always matches hermes (`/new`, `/model`, `/reasoning`, `/status`,
|
||||
`/cron`, …). The drawer is shown while the input is a bare `/…` (no space
|
||||
yet); typing fuzzy-filters it **client-side** (subsequence match over name +
|
||||
aliases — no `commands.complete` round-trip). Tapping a row sends
|
||||
`message.send {text:"/cmd"}` and closes the drawer; an unknown command
|
||||
empties the match list and closes it (the raw text can still be sent —
|
||||
hermes answers with its unknown-command reply). Escape (desktop) clears the
|
||||
`/` input.
|
||||
- **Menu button (planned):** `Menü` opens a **bottom sheet** listing the same
|
||||
catalog for discovery without typing.
|
||||
- **Interactive commands** (`/model`, `/reasoning`, `/fast`, approvals,
|
||||
clarifies) render as **native pickers** from `picker.*` frames (a dialog /
|
||||
sheet with the options; answer via `picker.select`).
|
||||
sheet with the options; answer via `picker.select`) — planned.
|
||||
|
||||
### Streaming (app-controlled)
|
||||
- **Settings → "Streaming"** toggle (default on). When off, the app ignores
|
||||
|
||||
@@ -37,6 +37,10 @@ without the app (critical for verifying frame shapes early).
|
||||
carry the new `thread_id`; no-op with an existing `thread_id`, for slash
|
||||
commands, or for media-only sends; the LLM upgrade renames the thread
|
||||
(`channel.renamed`).
|
||||
- **Slash catalog:** `commands.catalog` request → response with the
|
||||
gateway-available `COMMAND_REGISTRY` subset + plugin commands (each entry
|
||||
`name`/`description`/`args_hint`/`category`/`aliases`); `cli_only` commands
|
||||
excluded; response `id` matches the request `id`.
|
||||
- **No `~/.hermes` writes in tests** — use the `_isolate_hermes_home` fixture
|
||||
pattern (temp `HERMES_HOME`). Profile tests also mock `Path.home()`.
|
||||
|
||||
@@ -122,6 +126,11 @@ adb logcat -d > /tmp/logcat.txt
|
||||
flat lane → a new topic appears (derived name), the app jumps into it, the
|
||||
reply streams there, and the topic is renamed to the AI's title a moment
|
||||
later. Slash commands / media-only sends stay in the flat lane.
|
||||
14. **Slash drawer:** type `/` in the composer → the drawer rolls up over the
|
||||
input with the gateway catalog; keep typing → fuzzy filtering (unrelated
|
||||
entries drop out); tap a row → the command is sent and the drawer closes;
|
||||
type an unknown command → the drawer closes (the raw text can still be
|
||||
sent; hermes answers with its unknown-command reply).
|
||||
|
||||
## 13.5 Debugging tips
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
# 17 — Future Control Surface (post-M7)
|
||||
|
||||
> **Status: research / backlog — not scheduled.** M0–M7 cover the chat surface
|
||||
> (messages, streaming, tools, media, push, channels, search). This doc records
|
||||
> what the app could *additionally* control through the gateway, based on a
|
||||
> survey of the hermes-agent source (2026-08-21). Nothing here is locked; it is
|
||||
> a menu of options, each with the hermes backend that already implements it.
|
||||
|
||||
## The key insight
|
||||
|
||||
Hermes already ships a **complete REST API** — `hermes_cli/web_server.py` plus
|
||||
`hermes_cli/web_routers/` — which is the backend of the desktop/dashboard UI.
|
||||
Our gateway plugin runs **inside the same `hermes gateway` process**, so every
|
||||
capability below is reachable by importing and calling the same functions the
|
||||
web server calls. Exposing one from the app = a new request/response frame pair
|
||||
in our protocol (`protocol.py` → `Protocol.kt` → `frames.schema.json`, the
|
||||
usual three-way mirror).
|
||||
|
||||
The constraint is never "can hermes do it?" (it can — all of it) — it is how
|
||||
many frame pairs we want to add and the security review each one needs.
|
||||
|
||||
## Implementation paths
|
||||
|
||||
1. **Direct function calls (preferred).** The plugin imports the hermes
|
||||
modules (`cron.jobs`, `hermes_cli.kanban_db`, config loaders, …) and calls
|
||||
them. No extra process, no extra port, zero new deps.
|
||||
2. **Proxy to the web server's REST API.** Only works if `hermes web` /
|
||||
`hermes dashboard` is running — it is not by default. Rejected for v1.
|
||||
|
||||
## Capability menu
|
||||
|
||||
### Cron jobs — fully controllable
|
||||
|
||||
| App action | Hermes backend |
|
||||
|---|---|
|
||||
| List jobs (incl. disabled) | `cron/jobs.py` `list_jobs()` |
|
||||
| Create job | `cron/jobs.py` `create_job()` (schedules: `30m`, `every monday 9am`, 5-field cron, ISO one-shot) |
|
||||
| Edit job | `cron/jobs.py` `update_job(job_id, updates)` |
|
||||
| Pause / resume | `cron/jobs.py` `pause_job()` / `resume_job()` |
|
||||
| Trigger now | `cron/jobs.py` `trigger_job()` |
|
||||
| Delete job | web router `web_routers/cron.py` `DELETE /api/cron/jobs/{id}` |
|
||||
| Run history | `web_routers/cron.py` `GET /api/cron/jobs/{id}/runs`; `hermes_state_portability.py` `list_cron_job_runs()` |
|
||||
| Delivery targets | `web_routers/cron.py` `GET /api/cron/delivery-targets` |
|
||||
| One-tap suggestions | `cron/suggestions.py` — ready-to-run job specs the user accepts/dismisses; `accept_suggestion()` calls `create_job` directly. **Designed for a UI; ideal first feature.** |
|
||||
| Blueprints | `cron/blueprint_catalog.py`, `web_routers/cron.py` `GET /api/cron/blueprints` + `POST /api/cron/blueprints/instantiate` |
|
||||
|
||||
Per-job fields worth surfacing: `model`/`provider` overrides, `skills`,
|
||||
`script`, `context_from` (chain job A's output into job B), `workdir`,
|
||||
multi-platform delivery.
|
||||
|
||||
### Kanban board — fully controllable
|
||||
|
||||
| App action | Hermes backend |
|
||||
|---|---|
|
||||
| Boards: list / create / rename / delete / switch | `hermes_cli/kanban_db.py` `create_board()` / `list_boards()`; REST `plugins/kanban/dashboard/plugin_api.py` `/boards*` |
|
||||
| Tasks: create / list / show / update / delete | `kanban_db.py` `create_task()` / `list_tasks()` / `complete_task()`; REST `/tasks*` |
|
||||
| Comments / links / attachments | REST `/tasks/{id}/comments`, `/links`, `/tasks/{id}/attachments` |
|
||||
| Bulk operations | REST `POST /tasks/bulk` |
|
||||
| Dispatch / reassign / reclaim / estimate | REST `/dispatch`, `/tasks/{id}/reassign`, `/tasks/{id}/reclaim`, `/estimate` |
|
||||
| Runs: inspect / terminate | REST `/runs/{run_id}`, `/runs/{run_id}/terminate` |
|
||||
| Stats / diagnostics / active workers | REST `/stats`, `/diagnostics`, `/workers/active` |
|
||||
| Per-task model options | REST `/model-options` |
|
||||
|
||||
Bonus: the kanban dispatcher already runs **inside the gateway** by default
|
||||
(`kanban.dispatch_in_gateway: true`), so a phone app would see dispatch
|
||||
activity live. The full REST surface (~30 endpoints) is in
|
||||
`plugins/kanban/dashboard/plugin_api.py`.
|
||||
|
||||
### Model / provider registry — fully controllable
|
||||
|
||||
| App action | Hermes backend |
|
||||
|---|---|
|
||||
| Set active model | `web_server.py` `POST /api/model/set` |
|
||||
| List model options / info / recommended default | `GET /api/model/options`, `/api/model/info`, `/api/model/recommended-default` |
|
||||
| Auxiliary (side-LLM) models | `GET/PUT /api/model/auxiliary` |
|
||||
| MoA config | `GET/PUT /api/model/moa` |
|
||||
| Per-profile model | `web_routers/profiles.py` `PUT /api/profiles/{name}/model` |
|
||||
| Per-toolset model / provider / env | `web_routers/tools.py` `PUT /api/tools/toolsets/{name}/model` / `/provider` / `/env` |
|
||||
| Custom endpoints: CRUD + validate + activate | `web_server.py` `/api/providers/custom-endpoints*` |
|
||||
| Provider validation / OAuth flows | `POST /api/providers/validate`, `/api/providers/oauth*` |
|
||||
| API keys (`.env`): set / reveal / delete | `web_server.py` `GET/PUT/DELETE /api/env`, `POST /api/env/reveal` |
|
||||
| `config.yaml`: read / write / schema | `GET/PUT /api/config`, `GET /api/config/schema` |
|
||||
|
||||
### Webhooks
|
||||
|
||||
| App action | Hermes backend |
|
||||
|---|---|
|
||||
| Subscribe / list / remove / test inbound webhook routes | `hermes_cli/webhook.py` (`hermes webhook` CLI: `_cmd_subscribe`, `_cmd_list`, `_cmd_remove`, `_cmd_test`); subscriptions stored in `~/.hermes/webhooks/subscriptions.json` |
|
||||
|
||||
### Sessions
|
||||
|
||||
List, FTS search, rename, delete, bulk-delete, export (md/html), prune —
|
||||
`web_routers/sessions.py` (`/api/sessions*`). Overlaps with what the app
|
||||
already shows from its own chat; useful for browsing *other* platforms'
|
||||
sessions (Telegram, CLI, cron runs).
|
||||
|
||||
### Profiles
|
||||
|
||||
CRUD, switch active profile, edit soul/description, per-profile model,
|
||||
export/import — `web_routers/profiles.py` (`/api/profiles*`).
|
||||
|
||||
### Skills
|
||||
|
||||
List, toggle, create/edit content, hub search/install/uninstall/update —
|
||||
`web_routers/skills.py` (`/api/skills*`, `/api/skills/hub/*`).
|
||||
|
||||
### Tools / toolsets
|
||||
|
||||
Enable/disable per platform, per-toolset config/model/provider/env —
|
||||
`web_routers/tools.py` (`/api/tools/toolsets*`).
|
||||
|
||||
### MCP servers
|
||||
|
||||
CRUD, test, auth/OAuth flows, catalog browse + install —
|
||||
`web_routers/mcp.py` (`/api/mcp/*`).
|
||||
|
||||
### Git
|
||||
|
||||
Status, branches, worktrees, and a full review flow (stage/unstage/revert/
|
||||
commit/push/create-PR) — `web_routers/git.py` (`/api/git/*`).
|
||||
|
||||
### Files
|
||||
|
||||
Upload/download/read/write, fs list/mkdir — `web_server.py` `/api/files*`,
|
||||
`/api/fs/*`. (Complements the existing media frames in `07-media.md`.)
|
||||
|
||||
### Messaging platforms
|
||||
|
||||
List/configure/test other platforms (Telegram, WhatsApp onboarding) —
|
||||
`web_server.py` `/api/messaging/*`.
|
||||
|
||||
### Memory providers
|
||||
|
||||
Config + setup per provider — `web_server.py` `/api/memory/providers/*`.
|
||||
|
||||
### Ops / system
|
||||
|
||||
| App action | Hermes backend |
|
||||
|---|---|
|
||||
| Gateway restart / drain | `web_server.py` `POST /api/gateway/restart`, `/api/gateway/drain` |
|
||||
| Hermes update check / install | `POST /api/hermes/update`, `GET /api/hermes/update/check` |
|
||||
| Curator (skill maintenance) status / pause / run | `GET /api/curator`, `PUT /api/curator/paused`, `POST /api/curator/run` |
|
||||
| Audio: transcribe / TTS / voices | `POST /api/audio/transcribe`, `POST /api/audio/speak`, `GET /api/audio/elevenlabs/voices` |
|
||||
| System stats / status / health | `GET /api/system/stats`, `/api/status`, `/api/health` |
|
||||
| Learning graph node CRUD | `GET/PUT/DELETE /api/learning/node*` |
|
||||
|
||||
## Design notes
|
||||
|
||||
1. **Protocol cost is low.** The existing frame model (`type` + payload,
|
||||
request/response correlated by `id`) already fits; we would add pairs like
|
||||
`cron.list`/`cron.create`, `kanban.task.create`, `model.set`, following the
|
||||
standard three-way mirror (`gateway-plugin/protocol.py` →
|
||||
`app/shared/.../protocol/Protocol.kt` → `docs/protocol/frames.schema.json`).
|
||||
2. **Security is the real gate.** The single-user model in
|
||||
`09-pairing-security.md` still holds, but control frames widen the blast
|
||||
radius of a leaked `ANDROID_TOKEN`. Sensitive operations (env/secrets,
|
||||
config writes, gateway restart, profile deletion) should get either an
|
||||
in-app confirmation step or a capability flag negotiated at pairing.
|
||||
3. **Read-heavy first.** Most of the value is in list/view frames (cheap,
|
||||
low-risk); write frames can follow per domain.
|
||||
4. **Broadcast routing applies.** Frames broadcast to all connected devices
|
||||
(locked decision, `16-open-questions.md`); a control *response* should be
|
||||
routed to the requesting device only, like other request/response pairs.
|
||||
|
||||
## Natural first picks (suggested order)
|
||||
|
||||
1. **Cron** — list / create / pause / trigger + one-tap suggestions (the
|
||||
suggestion flow was literally designed for a UI).
|
||||
2. **Kanban** — view board, add task, complete task.
|
||||
3. **Model switch** — `model.set` + `model.options` (small, high value).
|
||||
4. **Sessions** — list/search across platforms.
|
||||
|
||||
All four are read-heavy with cheap writes and low security risk.
|
||||
@@ -38,6 +38,7 @@ top-to-bottom once, then use the numbered docs as a lookup while implementing.
|
||||
| 14 | [`14-milestones.md`](14-milestones.md) | Planning work / tracking progress. |
|
||||
| 15 | [`15-hermes-reference.md`](15-hermes-reference.md) | **Cheat-sheet** of hermes-agent source to read. |
|
||||
| 16 | [`16-open-questions.md`](16-open-questions.md) | Decisions made + open items. |
|
||||
| 17 | [`17-future-control-surface.md`](17-future-control-surface.md) | **Backlog** — what the app could control beyond chat (cron, kanban, models, …). |
|
||||
|
||||
Machine-readable / diagrams:
|
||||
- [`protocol/frames.schema.json`](protocol/frames.schema.json) — wire-frame schema.
|
||||
|
||||
@@ -62,7 +62,8 @@
|
||||
"sync.done": { "payload": { "cursor": { "type": "integer" } } },
|
||||
"history": { "description": "Paged full message history for a chat/thread (response to a history request). Reconstructed from the outbox log; used to populate the view on first open / after a process death, since sync only replays the outbox delta.", "payload": { "messages": { "type": "array", "items": { "type": "object", "properties": { "message_id": {"type":"string"}, "role": {"type":"string","enum":["user","assistant"]}, "text": {"type":"string"}, "reasoning": {"type":"string"}, "model": {"type":"string"}, "tokens": {"type":"integer"}, "ts": {"type":"integer"}, "media": {"type":"array","items":{"$ref":"#/definitions/media_ref"}} } } }, "has_more": { "type": "boolean", "description": "True when older pages exist." }, "oldest_message_id": { "type": "string", "description": "before_message_id for the next (older) page." } } },
|
||||
"media.pull.end": { "payload": { "ok": { "type": "boolean" } } },
|
||||
"media.upload.ack": { "description": "Response to media.upload.end; ref is cached and usable in message.send media_refs.", "payload": { "ok": { "type": "boolean" }, "media_ref": { "type": "string" } } }
|
||||
"media.upload.ack": { "description": "Response to media.upload.end; ref is cached and usable in message.send media_refs.", "payload": { "ok": { "type": "boolean" }, "media_ref": { "type": "string" } } },
|
||||
"commands.catalog": { "description": "Response to a commands.catalog request: the gateway's slash-command catalog for the app's '/' drawer. Derived from hermes' COMMAND_REGISTRY (gateway-available subset) plus plugin-registered commands. The app fuzzy-matches the typed prefix client-side.", "payload": { "commands": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string", "description": "Canonical command with leading slash, e.g. \"/new\"." }, "description": { "type": "string" }, "args_hint": { "type": "string", "description": "Argument placeholder, e.g. \"[name]\"; empty when none." }, "category": { "type": "string", "description": "Registry category (Session, Configuration, Tools & Skills, Info, Exit, Plugin)." }, "aliases": { "type": "array", "items": { "type": "string" }, "description": "Alternative names with leading slash, e.g. [\"/reset\"] for /new." } } } } } }
|
||||
},
|
||||
"app_to_server": {
|
||||
"hello": { "description": "First frame; auth + caps.", "payload": { "token": { "type": "string" }, "device_id": { "type": "string" }, "device_name": { "type": "string" }, "caps": { "type": "object", "properties": { "min_protocol": {"type":"integer"}, "media": {"type":"boolean"}, "push": {"type":"string"} } }, "fcm_token": { "type": "string" }, "ntfy_topic": { "type": "string" } } },
|
||||
@@ -78,6 +79,7 @@
|
||||
"channel.set_automation": { "description": "Mark a channel as automation (read-only for the user; it only receives gateway-originated output such as cron jobs and webhooks). The app hides the composer and the gateway rejects message.send into it. The default channel cannot be marked (error not_found). Answered by a channel.renamed carrying the full entry.", "payload": { "on": { "type": "boolean" } } },
|
||||
"channel.delete": { "payload": {} },
|
||||
"channel.list": { "description": "Request the full channel directory; answered by the server_to_app channel.list frame.", "payload": {} },
|
||||
"commands.catalog": { "description": "Request the gateway's slash-command catalog (the app's '/' drawer); answered by the server_to_app commands.catalog frame carrying the same id.", "payload": {} },
|
||||
"search": { "payload": { "query": { "type": "string" }, "scope": { "type": "string", "enum": ["all", "chat"] }, "chat_id": { "type": "string" }, "thread_id": { "type": "string" }, "limit": { "type": "integer", "description": "Optional; server default 20." } } },
|
||||
"sync": { "description": "Reconnect catch-up; replays undelivered outbox frames only (not full history).", "payload": { "cursor": { "type": "integer" } } },
|
||||
"history": { "description": "Load a page of full message history for a chat/thread (initial open, scroll-up pagination).", "payload": { "before_message_id": { "type": "string", "description": "Return messages older than this (omit for newest page)." }, "limit": { "type": "integer", "description": "Max messages (default 50, max 200)." } } },
|
||||
@@ -98,9 +100,7 @@
|
||||
{ "name": "picker.approval", "direction": "server_to_app", "note": "Approval picker prompt. Planned, not implemented (approvals arrive as notification)." },
|
||||
{ "name": "picker.confirm", "direction": "server_to_app", "note": "Confirmation picker prompt. Planned, not implemented." },
|
||||
{ "name": "picker.select", "direction": "app_to_server", "note": "Picker answer. Planned, not implemented." },
|
||||
{ "name": "commands.catalog", "direction": "server_to_app", "note": "Slash-command catalog. Planned, not implemented." },
|
||||
{ "name": "commands.catalog", "direction": "app_to_server", "note": "Slash-command catalog request. Planned, not implemented." },
|
||||
{ "name": "commands.complete", "direction": "server_to_app", "note": "Slash-command autocomplete. Planned, not implemented." },
|
||||
{ "name": "commands.complete", "direction": "server_to_app", "note": "Slash-command autocomplete. Planned, not implemented (the app fuzzy-matches the commands.catalog list client-side)." },
|
||||
{ "name": "commands.complete", "direction": "app_to_server", "note": "Slash-command autocomplete request. Planned, not implemented." },
|
||||
{ "name": "agent.busy", "direction": "server_to_app", "note": "Agent-busy indicator. Planned, not implemented (typing frames cover it)." },
|
||||
{ "name": "agent.idle", "direction": "server_to_app", "note": "Agent-idle indicator. Planned, not implemented." },
|
||||
|
||||
Reference in new issue
Block a user