muse-cli 0.3.11__tar.gz → 0.3.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {muse_cli-0.3.11 → muse_cli-0.3.12}/.gitignore +3 -0
  2. {muse_cli-0.3.11 → muse_cli-0.3.12}/PKG-INFO +41 -5
  3. {muse_cli-0.3.11 → muse_cli-0.3.12}/README.md +40 -4
  4. {muse_cli-0.3.11 → muse_cli-0.3.12}/docs/PROTOCOL.md +22 -0
  5. muse_cli-0.3.12/docs/TUI.md +171 -0
  6. {muse_cli-0.3.11 → muse_cli-0.3.12}/pyproject.toml +4 -0
  7. {muse_cli-0.3.11 → muse_cli-0.3.12}/skills/muse-cli/SKILL.md +5 -4
  8. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/__init__.py +1 -1
  9. muse_cli-0.3.12/src/muse_cli/bridge.py +886 -0
  10. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/cli.py +100 -46
  11. muse_cli-0.3.12/src/muse_cli/demo.py +665 -0
  12. muse_cli-0.3.12/src/muse_cli/tui/bun.lock +86 -0
  13. muse_cli-0.3.12/src/muse_cli/tui/package.json +21 -0
  14. muse_cli-0.3.12/src/muse_cli/tui/src/app.tsx +294 -0
  15. muse_cli-0.3.12/src/muse_cli/tui/src/bridge.ts +170 -0
  16. muse_cli-0.3.12/src/muse_cli/tui/src/components/Composer.tsx +235 -0
  17. muse_cli-0.3.12/src/muse_cli/tui/src/components/Header.tsx +64 -0
  18. muse_cli-0.3.12/src/muse_cli/tui/src/components/Overlays.tsx +367 -0
  19. muse_cli-0.3.12/src/muse_cli/tui/src/components/Panels.tsx +512 -0
  20. muse_cli-0.3.12/src/muse_cli/tui/src/components/Sidebar.tsx +122 -0
  21. muse_cli-0.3.12/src/muse_cli/tui/src/components/Splash.tsx +111 -0
  22. muse_cli-0.3.12/src/muse_cli/tui/src/components/Transcript.tsx +378 -0
  23. muse_cli-0.3.12/src/muse_cli/tui/src/components/common.tsx +43 -0
  24. muse_cli-0.3.12/src/muse_cli/tui/src/context.tsx +123 -0
  25. muse_cli-0.3.12/src/muse_cli/tui/src/controller.ts +465 -0
  26. muse_cli-0.3.12/src/muse_cli/tui/src/format.ts +170 -0
  27. muse_cli-0.3.12/src/muse_cli/tui/src/main.tsx +50 -0
  28. muse_cli-0.3.12/src/muse_cli/tui/src/protocol.ts +148 -0
  29. muse_cli-0.3.12/src/muse_cli/tui/src/store.ts +167 -0
  30. muse_cli-0.3.12/src/muse_cli/tui/src/theme.ts +58 -0
  31. muse_cli-0.3.12/src/muse_cli/tui/test/app.test.tsx +177 -0
  32. muse_cli-0.3.12/src/muse_cli/tui/test/fake.ts +174 -0
  33. muse_cli-0.3.12/src/muse_cli/tui/test/logic.test.ts +364 -0
  34. muse_cli-0.3.12/src/muse_cli/tui/tsconfig.json +15 -0
  35. muse_cli-0.3.12/src/muse_cli/tui.py +245 -0
  36. {muse_cli-0.3.11 → muse_cli-0.3.12}/LICENSE +0 -0
  37. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/__main__.py +0 -0
  38. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/browsers.py +0 -0
  39. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/chat.py +0 -0
  40. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/desc0.bin +0 -0
  41. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/desc1.bin +0 -0
  42. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/gateway.py +0 -0
  43. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/routes.json +0 -0
  44. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/skill.py +0 -0
  45. {muse_cli-0.3.11 → muse_cli-0.3.12}/src/muse_cli/update.py +0 -0
@@ -18,3 +18,6 @@ config.json
18
18
 
19
19
  # Firebase local cache
20
20
  .firebase/
21
+
22
+ # OpenTUI app dependencies
23
+ node_modules/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: muse-cli
3
- Version: 0.3.11
3
+ Version: 0.3.12
4
4
  Summary: Command-line client for your personal muse.ai AI agent: chat, automate, and manage side chats, feed, goals, ideas, and sessions from the terminal. No browser needed.
5
5
  Project-URL: Homepage, https://github.com/nikships/muse-cli
6
6
  Project-URL: Documentation, https://github.com/nikships/muse-cli#readme
@@ -56,6 +56,7 @@ https://github.com/user-attachments/assets/8c9aefe8-c5a4-4e4b-9393-48e2325f99a9
56
56
 
57
57
  A command-line client for your personal muse.ai AI agent: chat from the terminal, automate it with scripts, and manage side chats, feed, goals, ideas, and sessions without opening a browser. It speaks the app's own gateway protocol directly: HTTPS auth, then an encrypted Noise-XX WebSocket to your personal VM.
58
58
 
59
+ - **A full-screen app:** `muse-cli` opens a chat app built on [OpenTUI](https://github.com/anomalyco/opentui), with your chats, feed, goals, ideas, tasks, mail and files a keystroke away.
59
60
  - **Chat from the shell:** send a message and get the agent's reply back as JSON.
60
61
  - **Script it:** every command prints JSON, so it pipes into `jq`, cron jobs, and other AI agents.
61
62
  - **Full coverage:** named commands for the common tasks, plus a `raw` escape hatch for all 402 gateway methods.
@@ -220,7 +221,9 @@ muse-cli status
220
221
  ## Usage
221
222
 
222
223
  ```bash
223
- muse-cli # interactive chat (same as `muse-cli chat`)
224
+ muse-cli # full-screen app on a terminal with Bun, else the plain chat
225
+ muse-cli tui # the full-screen app (`--demo`: made-up data, no account)
226
+ muse-cli chat # plain line-by-line chat
224
227
  muse-cli auth export --browser auto # import the browser login (macOS: direct read)
225
228
  muse-cli threads # main chat + side chats
226
229
  muse-cli history --limit 5 # recent messages
@@ -260,7 +263,33 @@ muse-cli wake
260
263
  muse-cli raw <method> --body '{}' # escape hatch: any of 402 gateway methods
261
264
  ```
262
265
 
263
- The interactive chat prints plain text, one message per line, so it works well
266
+ ### The full-screen app
267
+
268
+ ![The muse-cli full-screen app in demo mode](https://raw.githubusercontent.com/nikships/muse-cli/main/assets/tui.png)
269
+
270
+ On a terminal, `muse-cli` opens a full-screen app built on
271
+ [OpenTUI](https://github.com/anomalyco/opentui). It needs
272
+ [Bun](https://bun.sh) 1.3.14 or later; `muse-cli tui` offers to install it.
273
+ The first run copies the app to `~/.cache/muse-cli/tui` and installs its
274
+ dependencies, which takes a few seconds once per release.
275
+
276
+ - Replies stream in as they arrive, with Markdown, code blocks and file chips.
277
+ Press Enter on a file to save it to `~/Downloads/muse`.
278
+ - Your chats sit on the left. `Tab` moves between them and the message box,
279
+ `Ctrl+N` starts a side chat.
280
+ - `Ctrl+K` jumps to any chat, space or action. `Alt+1` to `Alt+7` open Chat,
281
+ Feed, Goals, Ideas, Tasks, Mail and Files. Type `/` for commands, `F1` for
282
+ every shortcut.
283
+ - `Ctrl+C` clears the message box, and quits when it is empty.
284
+
285
+ `muse-cli tui --demo` runs it on made-up data and never contacts muse.ai.
286
+ Set `MUSE_CLI_UI=plain` to make bare `muse-cli` open the plain chat instead.
287
+ Without Bun, or when stdin or stdout is not a terminal, `muse-cli` opens the
288
+ plain chat. Problems are logged to `~/.config/muse-cli/tui.log`.
289
+
290
+ ### The plain chat
291
+
292
+ `muse-cli chat` prints plain text, one message per line, so it works well
264
293
  with screen readers. It resumes the conversation you used last; type `/help`
265
294
  inside it for `/chats`, `/open N`, `/main`, `/new`, `/history`, and `/login`.
266
295
  Any command above can also be run with a leading slash (`/status`, `/goals`,
@@ -307,18 +336,25 @@ git clone https://github.com/nikships/muse-cli.git
307
336
  cd muse-cli
308
337
  uv run muse-cli --help
309
338
  uv run python -m unittest discover -s tests # unit tests (no network)
339
+ cd src/muse_cli/tui && bun install && bun test && bunx tsc --noEmit # app tests
340
+ MUSE_CLI_TUI_DIR=$PWD uv run muse-cli tui --demo # run the app from the checkout
310
341
  ```
311
342
 
312
343
  ```
313
344
  muse-cli/
314
- assets/ README artwork (generated with Muse Image)
345
+ assets/ README artwork (generated with Muse Image) and app screenshots
315
346
  docs/PROTOCOL.md protocol reference for re-derivation
347
+ docs/TUI.md the full-screen app and its bridge protocol
316
348
  scripts/ release version bump (used by CI), route table extractor
317
349
  site/ landing page (Firebase Hosting)
318
350
  skills/muse-cli/ agent skill
319
351
  src/muse_cli/
320
352
  cli.py argument parsing and all commands
321
- chat.py interactive chat (the default command)
353
+ chat.py plain interactive chat (`muse-cli chat`)
354
+ tui.py launches the full-screen app (finds Bun, caches the app)
355
+ tui/ the full-screen app: TypeScript on OpenTUI and Bun
356
+ bridge.py JSON-lines bridge the app talks to muse.ai through
357
+ demo.py made-up data for `muse-cli tui --demo`
322
358
  browsers.py reads the muse.ai login from Chromium browsers on macOS
323
359
  gateway.py gateway client (auth, Noise transport, subscriptions)
324
360
  update.py daily update notice and `muse-cli update`
@@ -19,6 +19,7 @@ https://github.com/user-attachments/assets/8c9aefe8-c5a4-4e4b-9393-48e2325f99a9
19
19
 
20
20
  A command-line client for your personal muse.ai AI agent: chat from the terminal, automate it with scripts, and manage side chats, feed, goals, ideas, and sessions without opening a browser. It speaks the app's own gateway protocol directly: HTTPS auth, then an encrypted Noise-XX WebSocket to your personal VM.
21
21
 
22
+ - **A full-screen app:** `muse-cli` opens a chat app built on [OpenTUI](https://github.com/anomalyco/opentui), with your chats, feed, goals, ideas, tasks, mail and files a keystroke away.
22
23
  - **Chat from the shell:** send a message and get the agent's reply back as JSON.
23
24
  - **Script it:** every command prints JSON, so it pipes into `jq`, cron jobs, and other AI agents.
24
25
  - **Full coverage:** named commands for the common tasks, plus a `raw` escape hatch for all 402 gateway methods.
@@ -183,7 +184,9 @@ muse-cli status
183
184
  ## Usage
184
185
 
185
186
  ```bash
186
- muse-cli # interactive chat (same as `muse-cli chat`)
187
+ muse-cli # full-screen app on a terminal with Bun, else the plain chat
188
+ muse-cli tui # the full-screen app (`--demo`: made-up data, no account)
189
+ muse-cli chat # plain line-by-line chat
187
190
  muse-cli auth export --browser auto # import the browser login (macOS: direct read)
188
191
  muse-cli threads # main chat + side chats
189
192
  muse-cli history --limit 5 # recent messages
@@ -223,7 +226,33 @@ muse-cli wake
223
226
  muse-cli raw <method> --body '{}' # escape hatch: any of 402 gateway methods
224
227
  ```
225
228
 
226
- The interactive chat prints plain text, one message per line, so it works well
229
+ ### The full-screen app
230
+
231
+ ![The muse-cli full-screen app in demo mode](https://raw.githubusercontent.com/nikships/muse-cli/main/assets/tui.png)
232
+
233
+ On a terminal, `muse-cli` opens a full-screen app built on
234
+ [OpenTUI](https://github.com/anomalyco/opentui). It needs
235
+ [Bun](https://bun.sh) 1.3.14 or later; `muse-cli tui` offers to install it.
236
+ The first run copies the app to `~/.cache/muse-cli/tui` and installs its
237
+ dependencies, which takes a few seconds once per release.
238
+
239
+ - Replies stream in as they arrive, with Markdown, code blocks and file chips.
240
+ Press Enter on a file to save it to `~/Downloads/muse`.
241
+ - Your chats sit on the left. `Tab` moves between them and the message box,
242
+ `Ctrl+N` starts a side chat.
243
+ - `Ctrl+K` jumps to any chat, space or action. `Alt+1` to `Alt+7` open Chat,
244
+ Feed, Goals, Ideas, Tasks, Mail and Files. Type `/` for commands, `F1` for
245
+ every shortcut.
246
+ - `Ctrl+C` clears the message box, and quits when it is empty.
247
+
248
+ `muse-cli tui --demo` runs it on made-up data and never contacts muse.ai.
249
+ Set `MUSE_CLI_UI=plain` to make bare `muse-cli` open the plain chat instead.
250
+ Without Bun, or when stdin or stdout is not a terminal, `muse-cli` opens the
251
+ plain chat. Problems are logged to `~/.config/muse-cli/tui.log`.
252
+
253
+ ### The plain chat
254
+
255
+ `muse-cli chat` prints plain text, one message per line, so it works well
227
256
  with screen readers. It resumes the conversation you used last; type `/help`
228
257
  inside it for `/chats`, `/open N`, `/main`, `/new`, `/history`, and `/login`.
229
258
  Any command above can also be run with a leading slash (`/status`, `/goals`,
@@ -270,18 +299,25 @@ git clone https://github.com/nikships/muse-cli.git
270
299
  cd muse-cli
271
300
  uv run muse-cli --help
272
301
  uv run python -m unittest discover -s tests # unit tests (no network)
302
+ cd src/muse_cli/tui && bun install && bun test && bunx tsc --noEmit # app tests
303
+ MUSE_CLI_TUI_DIR=$PWD uv run muse-cli tui --demo # run the app from the checkout
273
304
  ```
274
305
 
275
306
  ```
276
307
  muse-cli/
277
- assets/ README artwork (generated with Muse Image)
308
+ assets/ README artwork (generated with Muse Image) and app screenshots
278
309
  docs/PROTOCOL.md protocol reference for re-derivation
310
+ docs/TUI.md the full-screen app and its bridge protocol
279
311
  scripts/ release version bump (used by CI), route table extractor
280
312
  site/ landing page (Firebase Hosting)
281
313
  skills/muse-cli/ agent skill
282
314
  src/muse_cli/
283
315
  cli.py argument parsing and all commands
284
- chat.py interactive chat (the default command)
316
+ chat.py plain interactive chat (`muse-cli chat`)
317
+ tui.py launches the full-screen app (finds Bun, caches the app)
318
+ tui/ the full-screen app: TypeScript on OpenTUI and Bun
319
+ bridge.py JSON-lines bridge the app talks to muse.ai through
320
+ demo.py made-up data for `muse-cli tui --demo`
285
321
  browsers.py reads the muse.ai login from Chromium browsers on macOS
286
322
  gateway.py gateway client (auth, Noise transport, subscriptions)
287
323
  update.py daily update notice and `muse-cli update`
@@ -86,6 +86,28 @@ chat / feed / goals / ideas / sessions / ...
86
86
  not in `routes.json`; sent as a raw-path daemon request over the Noise
87
87
  tunnel it returns the file (body chunks). `Gateway.download_file()` wraps
88
88
  this. `artifacts.fetch_url` is unrelated (needs `project_dir`).
89
+ - **Presentations**: images, files and other widgets the agent shows arrive
90
+ in history as their own `delta.presentation` events (role `assistant`,
91
+ empty `reply_to_message_id`, no `status`) after the text reply.
92
+ `payload.kind` is `image` (`data.images[]`), `file` (`data.file`, a single
93
+ object), `external_link` (`data.url`), `internal_link_action_card`
94
+ (`data.title`, `data.subtitle`, `data.data.url`), `space_build_completed`
95
+ (`data.display_name`, `data.summary`), `browser_task` (`data.display_state`,
96
+ `data.current_site`), `html` (`data.html`) or `voice_options`.
97
+ `display_text` is a caption or a markdown link, `fallback_text` the
98
+ markdown version. Names in `display_text` are wrapped in Unicode isolates
99
+ (U+2068/U+2069). A browser task that updates is re-sent with a new `seq`
100
+ and the same `payload.id`; when `data.activity_title_source` is `state`,
101
+ `display_text` is only the status ("Task completed").
102
+ - **User uploads** (a photo sent from the phone app): the text is
103
+ `[image:<mime> workspace/<p>]` and `payload.metadata.attachments[]` has
104
+ `{path: "workspace/<p>", mime_type, filename, bytes_len, width, height}`.
105
+ The bare path downloads like an agent file as `sandbox://workspace/<p>`.
106
+ - **Quick-reply widgets**: the text holds `[hatch_widget:<widget_id>]` (or
107
+ `[[hatch_widget:<widget_id>]]`) and `payload.widgets[]` has
108
+ `{widget_id, kind: "option", data: {options: [...]}, fallback_text,
109
+ state: {data: {selectedText}, version}}`. `widgets.state.set` and
110
+ `widgets.state.patch` exist in `routes.json` but are not mapped yet.
89
111
  - `session.start`: `{method: "/api/session/start", params: {origin: "fresh",
90
112
  lifecycle: "persistent"}}`. A `title` param is accepted but ignored (the
91
113
  chat stays untitled), so `start_session` follows up with `session.rename`.
@@ -0,0 +1,171 @@
1
+ # The full-screen app (`muse-cli tui`)
2
+
3
+ `muse-cli tui` (and bare `muse-cli` on an interactive terminal) opens a
4
+ full-screen app built on [OpenTUI](https://github.com/anomalyco/opentui).
5
+ `muse-cli chat` stays the plain, line-by-line chat for screen readers and
6
+ dumb terminals.
7
+
8
+ ## Architecture
9
+
10
+ ```
11
+ muse-cli tui (Python launcher, muse_cli/tui.py)
12
+ │ prepares the app in ~/.cache/muse-cli/tui/<hash>, then runs
13
+ ▼
14
+ bun src/main.tsx (OpenTUI + React, muse_cli/tui/) ── owns the terminal
15
+ │ spawns, talks JSON lines over pipes
16
+ ▼
17
+ python -m muse_cli.bridge (muse_cli/bridge.py) ── owns the Gateway
18
+ ```
19
+
20
+ - The TypeScript app owns the terminal. It never talks to muse.ai itself.
21
+ - The bridge is the only process with a `Gateway`. One worker thread makes
22
+ every gateway call, so the WebSocket has exactly one consumer.
23
+ - The bridge keeps its protocol on the original stdout file descriptor and
24
+ points `sys.stdout` and fd 1 at stderr, so a stray `print()` from a CLI
25
+ helper can never corrupt the protocol. The app writes the bridge's stderr
26
+ to `~/.config/muse-cli/tui.log`.
27
+
28
+ ### Launcher
29
+
30
+ - Finds Bun (`bun` on PATH, else `~/.bun/bin/bun`). Bun 1.3.14 or later.
31
+ - Copies `muse_cli/tui` (without `node_modules`) to
32
+ `~/.cache/muse-cli/tui/<hash>` where `<hash>` covers every shipped file,
33
+ then runs `bun install --frozen-lockfile` there once. Later launches reuse
34
+ it. `MUSE_CLI_TUI_DIR=<dir>` runs a checkout in place instead (development).
35
+ - Runs `bun <dir>/src/main.tsx` with the terminal inherited, and sets
36
+ `MUSE_CLI_PYTHON=<sys.executable>` so the app can start the bridge with
37
+ `[$MUSE_CLI_PYTHON, -m, muse_cli.bridge]` (plus `--demo` in demo mode).
38
+ - Exit code: the app's.
39
+ - Bare `muse-cli` opens the app when stdin and stdout are terminals, Bun is
40
+ available and `MUSE_CLI_UI` is not `plain`; otherwise the plain chat.
41
+ `muse-cli tui` without Bun offers to install it on a terminal and falls
42
+ back to the plain chat when declined.
43
+ - `muse-cli tui --demo` (or `MUSE_CLI_DEMO=1`) runs the bridge with made-up
44
+ data and never touches muse.ai. Screenshots and tests use it. Its fake
45
+ gateway (`muse_cli/demo.py`) answers with the real server's shapes, and a
46
+ reply streams in word by word. `MUSE_CLI_DEMO_SPEED=N` plays every demo
47
+ delay N times faster; in demo mode `idle` comes 3 s after the last reply.
48
+
49
+ ## Bridge protocol
50
+
51
+ Newline-delimited JSON, UTF-8, one object per line.
52
+
53
+ App to bridge (request):
54
+
55
+ ```json
56
+ {"id": 7, "method": "history", "params": {"session_id": null, "limit": 40}}
57
+ ```
58
+
59
+ Bridge to app (response, exactly one per request id):
60
+
61
+ ```json
62
+ {"id": 7, "result": {...}}
63
+ {"id": 7, "error": {"kind": "gateway", "message": "...", "status": 404}}
64
+ ```
65
+
66
+ Error `kind`: `auth` (no or expired login), `not_found` (deleted chat),
67
+ `gateway`, `timeout`, `bad_request` (unknown method or bad params),
68
+ `internal`. A gateway error whose body carries the server's reason uses its
69
+ `message`, and adds its `code` (for example `email_not_enabled`). The app
70
+ shows a code ending in `_not_enabled` as a feature the account lacks rather
71
+ than a failure to retry.
72
+
73
+ Bridge to app (event, no id):
74
+
75
+ ```json
76
+ {"event": "message", "data": {...}}
77
+ ```
78
+
79
+ ### Shapes
80
+
81
+ `Chat`: `{"session_id": str|null, "title": str}`. `session_id: null` is the
82
+ main chat.
83
+
84
+ `Session`: `{"session_id", "title", "is_thread", "pinned", "archived",
85
+ "updated_at_ms", "unread"}`. The main chat has `session_id: null` here too,
86
+ so its `Session` opens with `open` as is.
87
+
88
+ `Message`:
89
+
90
+ ```json
91
+ {"seq": 26693, "id": "assistant-msg-…", "role": "user"|"assistant",
92
+ "text": "markdown text", "at_ms": 1794117896436,
93
+ "final": true, "push": false,
94
+ "files": [{"path": "sandbox://…", "kind": "image", "mime": "image/png",
95
+ "label": "…", "byte_len": 1234}],
96
+ "choices": [{"id": "widget-…", "options": ["Yes", "Not now"], "selected": null}],
97
+ "card": null, "widget": false}
98
+ ```
99
+
100
+ - `at_ms` is `occurred_at_ms` (fallback `display_text_updated_at_ms`).
101
+ - `final` is false while the assistant is still writing (no `status`).
102
+ - `push` is true for proactive assistant messages (non-empty
103
+ `reply_to_message_id`, same rule as `cli.is_reply`).
104
+ - Only `message.user` and `message.assistant` events with text, files or
105
+ choices become messages, plus `delta.presentation` events (below).
106
+ - A `delta.presentation` event is something the agent shows after its text:
107
+ an image or file (`files`, empty `text`), or a link, connector, finished
108
+ space, browser task or note (`card`: `{"id", "kind", "title", "subtitle",
109
+ "url", "status"}`). These messages have `widget: true`; they never count as
110
+ the reply, and the app draws them as part of the assistant message before
111
+ them. A widget that changes (a browser task finishing) comes back with a new
112
+ `seq` but the same `card.id`; only the latest is kept. Kinds with nothing
113
+ to show (`voice_options`) are skipped.
114
+ - `choices` come from `payload.widgets` of kind `option` (quick replies);
115
+ `selected` is `state.data.selectedText`. Their `[hatch_widget:…]` or
116
+ `[[hatch_widget:…]]` placeholder is removed from `text`. The app sends a
117
+ picked option as a normal message.
118
+ - A user's own uploads come from `payload.metadata.attachments` (a bare
119
+ `workspace/…` path, given a `sandbox://` prefix), and their
120
+ `[image:<mime> <path>]` placeholder is removed from `text`.
121
+
122
+ ### Events
123
+
124
+ | event | data | when |
125
+ | ------------ | ---- | ---- |
126
+ | `ready` | `{"version", "demo"}` | first line, before any connection |
127
+ | `connection` | `{"state": "connecting"\|"online"\|"offline"\|"auth_needed", "detail"}` | connection state changes |
128
+ | `message` | `{"session_id", "message": Message}` | a new final message in the active chat (user or assistant), ordered by seq |
129
+ | `draft` | `{"session_id", "message": Message}` | the assistant's in-progress reply changed (`final: false`) |
130
+ | `thinking` | `{"session_id", "since_ms"}` | after `send`, until the first reply |
131
+ | `idle` | `{"session_id", "replied": bool}` | the agent went quiet after a send (10 s after the last reply, or 300 s with no reply) |
132
+ | `unread` | unread-count payload | every 30 s while online |
133
+ | `log` | `{"level", "text"}` | notices worth a toast |
134
+
135
+ The bridge tracks one active chat (`open`). It polls that chat's history:
136
+ every 1 s from `send` until `idle`, otherwise every 8 s, and emits
137
+ `message` for every final message newer than the last one it reported.
138
+ That covers proactive pushes too. A poll failure never kills the loop; three
139
+ failures in a row emit `connection` `offline` and the bridge reconnects with
140
+ backoff.
141
+
142
+ ### Methods
143
+
144
+ | method | params | result |
145
+ | ------ | ------ | ------ |
146
+ | `connect` | `{}` | `{"vm_id", "chat": Chat, "identity"}`; uses `chat.json` for the last chat |
147
+ | `login` | `{}` | `{"ok": bool, "log": str}`; runs `auth export` with its output captured, reconnects on success |
148
+ | `sessions` | `{"archived": false}` | `{"sessions": [Session]}`; main chat first, then pinned, then by `updated_at_ms` desc. `archived: true` also lists archived chats |
149
+ | `open` | `{"session_id": str\|null, "title": str, "limit": 40}` | `{"chat": Chat, "messages": [Message]}`; sets the active chat and saves `chat.json`. `not_found` for a deleted chat |
150
+ | `history` | `{"limit": 40, "before_seq": int?}` | `{"messages": [Message]}` for the active chat |
151
+ | `send` | `{"text": str}` | `{"sent": true, "baseline": seq}`; then `thinking`, `draft`, `message`, `idle` events |
152
+ | `new_chat` | `{"title": str?}` | `{"chat": Chat}`; also makes it active |
153
+ | `session_op` | `{"op": "rename"\|"pin"\|"unpin"\|"archive"\|"unarchive"\|"delete", "session_id", "title"?}` | server result |
154
+ | `status` | `{}` | `{"vm_id", "sessions", "unread", "identity"}` |
155
+ | `feed` | `{"limit": 50}` | `{"units": [{"id", "title", "date", "edition", "summary", "reaction", "emoji", "kicker", "category", "source", "why"}]}` |
156
+ | `feed_react` | `{"unit", "reaction": "like"\|"love"\|"dislike"}` | server result |
157
+ | `goals` | `{}` | `{"goals": [{"id", "title", "status", "subtitle"}]}` |
158
+ | `goal` | `{"id"}` | server result |
159
+ | `ideas` | `{}` | `{"ideas": [{"id", "title", "section", "summary"}]}` |
160
+ | `idea` | `{"id"}` | server result |
161
+ | `idea_exec` | `{"id"}` | server result (runs in the active chat) |
162
+ | `tasks` | `{}` | `{"tasks": [...same rows as cmd_tasks]}` |
163
+ | `task_runs` | `{"job": str?, "limit": 10}` | `{"runs": [...same rows as cmd_task_runs]}` |
164
+ | `email` | `{}` | `{"mailbox", "threads": [...same rows as cmd_email]}` |
165
+ | `email_thread` | `{"id"}` | `{"messages": [...same rows as _email_message]}` |
166
+ | `files` | `{"limit": 200}` | `{"files": [{"seq", "message_id", "path", "kind", "mime", "label", "byte_len"}]}` for the active chat, newest first, uploads and presented files included |
167
+ | `download` | `{"path", "dir"?}` | `{"rows": [...save_resources rows]}`; default dir `~/Downloads/muse` |
168
+ | `ping` | `{}` | `{"pong": true}` |
169
+ | `shutdown` | `{}` | `{}`, then the bridge closes the gateway and exits 0 |
170
+
171
+ The bridge also exits when its stdin closes.
@@ -72,6 +72,10 @@ muse-cli = "muse_cli.cli:main"
72
72
  [tool.hatch.version]
73
73
  path = "src/muse_cli/__init__.py"
74
74
 
75
+ [tool.hatch.build]
76
+ # The app's dependencies are installed per user at first launch.
77
+ exclude = ["node_modules"]
78
+
75
79
  [tool.hatch.build.targets.wheel]
76
80
  packages = ["src/muse_cli"]
77
81
 
@@ -11,8 +11,9 @@ fails and report it.
11
11
 
12
12
  The `muse-cli` package (on PyPI) talks to the muse.ai personal gateway
13
13
  directly. No browser needed after the one-time cookie export. Every command
14
- prints JSON except the interactive chat (`muse-cli` with no arguments, or
15
- `muse-cli chat`), which is a human REPL. Agents should never run it.
14
+ prints JSON except the interactive ones: `muse-cli` with no arguments (the
15
+ full-screen app on a terminal, else the plain chat), `muse-cli tui` and
16
+ `muse-cli chat`. They are for humans. Agents should never run them.
16
17
 
17
18
  ## 1. Install
18
19
 
@@ -226,8 +227,8 @@ only for methods with no wrapper.
226
227
  - `export-data` writes the user's entire agent data (workspace, chats) to
227
228
  disk. It takes about 20 s for a few hundred MB. Run it only when asked, and
228
229
  keep the ZIP private.
229
- - Running `muse-cli` with no command opens the interactive chat and blocks on
230
- stdin. From an agent, always pass an explicit command such as `status` or
230
+ - Running `muse-cli` with no command opens the full-screen app (or the plain
231
+ chat without Bun) and blocks on the terminal. From an agent, always pass an explicit command such as `status` or
231
232
  `send`.
232
233
  - `history` without `--thread` reads the main chat only.
233
234
  - Agent media shows up as `sandbox://workspace/...` paths, often in a
@@ -1,3 +1,3 @@
1
1
  """muse-cli: talk to your personal muse.ai AI agent from the terminal."""
2
2
 
3
- __version__ = "0.3.11"
3
+ __version__ = "0.3.12"