muse-cli 0.3.10__tar.gz → 0.3.11__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.
- {muse_cli-0.3.10 → muse_cli-0.3.11}/PKG-INFO +23 -6
- {muse_cli-0.3.10 → muse_cli-0.3.11}/README.md +22 -5
- {muse_cli-0.3.10 → muse_cli-0.3.11}/docs/PROTOCOL.md +58 -2
- {muse_cli-0.3.10 → muse_cli-0.3.11}/skills/muse-cli/SKILL.md +18 -1
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/__init__.py +1 -1
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/cli.py +273 -1
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/desc1.bin +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/gateway.py +51 -16
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/routes.json +1035 -35
- {muse_cli-0.3.10 → muse_cli-0.3.11}/.gitignore +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/LICENSE +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/pyproject.toml +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/__main__.py +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/browsers.py +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/chat.py +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/desc0.bin +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/skill.py +0 -0
- {muse_cli-0.3.10 → muse_cli-0.3.11}/src/muse_cli/update.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: muse-cli
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.11
|
|
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
|
|
@@ -58,7 +58,7 @@ A command-line client for your personal muse.ai AI agent: chat from the terminal
|
|
|
58
58
|
|
|
59
59
|
- **Chat from the shell:** send a message and get the agent's reply back as JSON.
|
|
60
60
|
- **Script it:** every command prints JSON, so it pipes into `jq`, cron jobs, and other AI agents.
|
|
61
|
-
- **Full coverage:** named commands for the common tasks, plus a `raw` escape hatch for all
|
|
61
|
+
- **Full coverage:** named commands for the common tasks, plus a `raw` escape hatch for all 402 gateway methods.
|
|
62
62
|
- **Agent-ready:** ships an agent skill so coding agents can drive your muse.ai agent for you.
|
|
63
63
|
|
|
64
64
|
## Agents driving agents
|
|
@@ -241,12 +241,23 @@ muse-cli goals # one goal: muse-cli goal <id>
|
|
|
241
241
|
muse-cli ideas # one idea: muse-cli idea <id>
|
|
242
242
|
muse-cli idea-exec <idea-id> # agent acts on the idea
|
|
243
243
|
|
|
244
|
+
muse-cli tasks # scheduled tasks (reminders, recurring jobs)
|
|
245
|
+
muse-cli task-runs --job <task-id> --limit 5 # recent runs, all tasks without --job
|
|
246
|
+
muse-cli task-run <task-id> # run a scheduled task now
|
|
247
|
+
muse-cli voices --gender F --accent British # voice catalog; also --search, --tone
|
|
248
|
+
muse-cli voice # the agent's current voice
|
|
249
|
+
muse-cli email # Muse Mail: mailbox + threads (--cursor for more)
|
|
250
|
+
muse-cli email-thread <thread-id> # messages in a thread; also email-message <id>
|
|
251
|
+
muse-cli email-attachment <message-id> 0 -o ./out # save attachment number 0
|
|
252
|
+
muse-cli peers # Trusted Network status and connected agents
|
|
253
|
+
muse-cli export-data -o ./out # download all your agent's data as a ZIP
|
|
254
|
+
|
|
244
255
|
muse-cli session-start --title "trip planning" # new side chat
|
|
245
256
|
muse-cli session-rename <id> "new title"
|
|
246
257
|
muse-cli session-archive <id> # also: pin, unpin, unarchive, delete
|
|
247
258
|
muse-cli seen <thread-id>
|
|
248
259
|
muse-cli wake
|
|
249
|
-
muse-cli raw <method> --body '{}' # escape hatch: any of
|
|
260
|
+
muse-cli raw <method> --body '{}' # escape hatch: any of 402 gateway methods
|
|
250
261
|
```
|
|
251
262
|
|
|
252
263
|
The interactive chat prints plain text, one message per line, so it works well
|
|
@@ -258,6 +269,12 @@ Any command above can also be run with a leading slash (`/status`, `/goals`,
|
|
|
258
269
|
Every other command prints JSON. Your VM is auto-discovered from your session, and a
|
|
259
270
|
random device id is generated on first run.
|
|
260
271
|
|
|
272
|
+
Some features are rolled out per account. When yours does not have one, the
|
|
273
|
+
command exits with a gateway error that names it, for example
|
|
274
|
+
`email_not_enabled` for Muse Mail. `peers` reports when the Trusted Network is
|
|
275
|
+
turned off instead of failing. `export-data` streams the ZIP to disk (the
|
|
276
|
+
server picks the file name), so a large agent does not need the memory.
|
|
277
|
+
|
|
261
278
|
Pipe it into other tools:
|
|
262
279
|
|
|
263
280
|
```bash
|
|
@@ -280,7 +297,7 @@ found during reverse engineering.
|
|
|
280
297
|
|----------|-------------|
|
|
281
298
|
| [skills/muse-cli/SKILL.md](https://github.com/nikships/muse-cli/blob/main/skills/muse-cli/SKILL.md) | Agent skill: install check, auth setup, command reference |
|
|
282
299
|
| [docs/PROTOCOL.md](https://github.com/nikships/muse-cli/blob/main/docs/PROTOCOL.md) | Gateway protocol reference: auth chain, Noise transport, framing, method quirks |
|
|
283
|
-
| [routes.json](https://github.com/nikships/muse-cli/blob/main/src/muse_cli/routes.json) | All
|
|
300
|
+
| [routes.json](https://github.com/nikships/muse-cli/blob/main/src/muse_cli/routes.json) | All 402 gateway methods with paths and services |
|
|
284
301
|
| `muse-cli raw --help` | Escape hatch for calling any gateway method directly |
|
|
285
302
|
|
|
286
303
|
## Development
|
|
@@ -296,7 +313,7 @@ uv run python -m unittest discover -s tests # unit tests (no network)
|
|
|
296
313
|
muse-cli/
|
|
297
314
|
assets/ README artwork (generated with Muse Image)
|
|
298
315
|
docs/PROTOCOL.md protocol reference for re-derivation
|
|
299
|
-
scripts/ release version bump (used by CI)
|
|
316
|
+
scripts/ release version bump (used by CI), route table extractor
|
|
300
317
|
site/ landing page (Firebase Hosting)
|
|
301
318
|
skills/muse-cli/ agent skill
|
|
302
319
|
src/muse_cli/
|
|
@@ -306,7 +323,7 @@ src/muse_cli/
|
|
|
306
323
|
gateway.py gateway client (auth, Noise transport, subscriptions)
|
|
307
324
|
update.py daily update notice and `muse-cli update`
|
|
308
325
|
skill.py installs and refreshes the bundled agent skill
|
|
309
|
-
routes.json
|
|
326
|
+
routes.json 402 gateway methods extracted from the web client
|
|
310
327
|
desc0.bin protobuf descriptors for the wire framing
|
|
311
328
|
desc1.bin
|
|
312
329
|
tests/ unit tests (no network)
|
|
@@ -21,7 +21,7 @@ A command-line client for your personal muse.ai AI agent: chat from the terminal
|
|
|
21
21
|
|
|
22
22
|
- **Chat from the shell:** send a message and get the agent's reply back as JSON.
|
|
23
23
|
- **Script it:** every command prints JSON, so it pipes into `jq`, cron jobs, and other AI agents.
|
|
24
|
-
- **Full coverage:** named commands for the common tasks, plus a `raw` escape hatch for all
|
|
24
|
+
- **Full coverage:** named commands for the common tasks, plus a `raw` escape hatch for all 402 gateway methods.
|
|
25
25
|
- **Agent-ready:** ships an agent skill so coding agents can drive your muse.ai agent for you.
|
|
26
26
|
|
|
27
27
|
## Agents driving agents
|
|
@@ -204,12 +204,23 @@ muse-cli goals # one goal: muse-cli goal <id>
|
|
|
204
204
|
muse-cli ideas # one idea: muse-cli idea <id>
|
|
205
205
|
muse-cli idea-exec <idea-id> # agent acts on the idea
|
|
206
206
|
|
|
207
|
+
muse-cli tasks # scheduled tasks (reminders, recurring jobs)
|
|
208
|
+
muse-cli task-runs --job <task-id> --limit 5 # recent runs, all tasks without --job
|
|
209
|
+
muse-cli task-run <task-id> # run a scheduled task now
|
|
210
|
+
muse-cli voices --gender F --accent British # voice catalog; also --search, --tone
|
|
211
|
+
muse-cli voice # the agent's current voice
|
|
212
|
+
muse-cli email # Muse Mail: mailbox + threads (--cursor for more)
|
|
213
|
+
muse-cli email-thread <thread-id> # messages in a thread; also email-message <id>
|
|
214
|
+
muse-cli email-attachment <message-id> 0 -o ./out # save attachment number 0
|
|
215
|
+
muse-cli peers # Trusted Network status and connected agents
|
|
216
|
+
muse-cli export-data -o ./out # download all your agent's data as a ZIP
|
|
217
|
+
|
|
207
218
|
muse-cli session-start --title "trip planning" # new side chat
|
|
208
219
|
muse-cli session-rename <id> "new title"
|
|
209
220
|
muse-cli session-archive <id> # also: pin, unpin, unarchive, delete
|
|
210
221
|
muse-cli seen <thread-id>
|
|
211
222
|
muse-cli wake
|
|
212
|
-
muse-cli raw <method> --body '{}' # escape hatch: any of
|
|
223
|
+
muse-cli raw <method> --body '{}' # escape hatch: any of 402 gateway methods
|
|
213
224
|
```
|
|
214
225
|
|
|
215
226
|
The interactive chat prints plain text, one message per line, so it works well
|
|
@@ -221,6 +232,12 @@ Any command above can also be run with a leading slash (`/status`, `/goals`,
|
|
|
221
232
|
Every other command prints JSON. Your VM is auto-discovered from your session, and a
|
|
222
233
|
random device id is generated on first run.
|
|
223
234
|
|
|
235
|
+
Some features are rolled out per account. When yours does not have one, the
|
|
236
|
+
command exits with a gateway error that names it, for example
|
|
237
|
+
`email_not_enabled` for Muse Mail. `peers` reports when the Trusted Network is
|
|
238
|
+
turned off instead of failing. `export-data` streams the ZIP to disk (the
|
|
239
|
+
server picks the file name), so a large agent does not need the memory.
|
|
240
|
+
|
|
224
241
|
Pipe it into other tools:
|
|
225
242
|
|
|
226
243
|
```bash
|
|
@@ -243,7 +260,7 @@ found during reverse engineering.
|
|
|
243
260
|
|----------|-------------|
|
|
244
261
|
| [skills/muse-cli/SKILL.md](https://github.com/nikships/muse-cli/blob/main/skills/muse-cli/SKILL.md) | Agent skill: install check, auth setup, command reference |
|
|
245
262
|
| [docs/PROTOCOL.md](https://github.com/nikships/muse-cli/blob/main/docs/PROTOCOL.md) | Gateway protocol reference: auth chain, Noise transport, framing, method quirks |
|
|
246
|
-
| [routes.json](https://github.com/nikships/muse-cli/blob/main/src/muse_cli/routes.json) | All
|
|
263
|
+
| [routes.json](https://github.com/nikships/muse-cli/blob/main/src/muse_cli/routes.json) | All 402 gateway methods with paths and services |
|
|
247
264
|
| `muse-cli raw --help` | Escape hatch for calling any gateway method directly |
|
|
248
265
|
|
|
249
266
|
## Development
|
|
@@ -259,7 +276,7 @@ uv run python -m unittest discover -s tests # unit tests (no network)
|
|
|
259
276
|
muse-cli/
|
|
260
277
|
assets/ README artwork (generated with Muse Image)
|
|
261
278
|
docs/PROTOCOL.md protocol reference for re-derivation
|
|
262
|
-
scripts/ release version bump (used by CI)
|
|
279
|
+
scripts/ release version bump (used by CI), route table extractor
|
|
263
280
|
site/ landing page (Firebase Hosting)
|
|
264
281
|
skills/muse-cli/ agent skill
|
|
265
282
|
src/muse_cli/
|
|
@@ -269,7 +286,7 @@ src/muse_cli/
|
|
|
269
286
|
gateway.py gateway client (auth, Noise transport, subscriptions)
|
|
270
287
|
update.py daily update notice and `muse-cli update`
|
|
271
288
|
skill.py installs and refreshes the bundled agent skill
|
|
272
|
-
routes.json
|
|
289
|
+
routes.json 402 gateway methods extracted from the web client
|
|
273
290
|
desc0.bin protobuf descriptors for the wire framing
|
|
274
291
|
desc1.bin
|
|
275
292
|
tests/ unit tests (no network)
|
|
@@ -43,13 +43,15 @@ chat / feed / goals / ideas / sessions / ...
|
|
|
43
43
|
- **Request:** `ServiceRequest{service, payload =
|
|
44
44
|
ServiceFrame{stream_id, request =
|
|
45
45
|
ApplicationRequest{verb, path, headers, body, end_body}}}`. Stream ids start
|
|
46
|
-
at 1. Services: daemon 0, sentinel 1, vault 2, authd 3
|
|
46
|
+
at 1. Services: daemon 0, sentinel 1, vault 2, authd 3, ssh_access 4,
|
|
47
|
+
yolk 5.
|
|
47
48
|
- **Response:** `ServiceResponse{payload = ServiceFrame{... response =
|
|
48
49
|
ApplicationResponse{status, headers, body, end_body}}}` plus `body_chunk`
|
|
49
50
|
frames until `end_body`.
|
|
50
51
|
- **Subscriptions** (`chat.subscribe`, `chat.stream`, ...): same envelope, the
|
|
51
52
|
server streams `application/x-ndjson` records in body chunks.
|
|
52
|
-
- **Method table:** `routes.json` (
|
|
53
|
+
- **Method table:** `routes.json` (402 methods extracted from the web bundle
|
|
54
|
+
by `scripts/extract_routes.py`).
|
|
53
55
|
|
|
54
56
|
## Server quirks learned from live errors
|
|
55
57
|
|
|
@@ -94,6 +96,60 @@ chat / feed / goals / ideas / sessions / ...
|
|
|
94
96
|
- `api.idea-cards.execute`: `{ideaCardId, mode: "full"}` plus path param. A
|
|
95
97
|
`session_id` in the body did not move the run into that side chat; the
|
|
96
98
|
user message and the agent's reply landed in the main chat.
|
|
99
|
+
- **Re-deriving the method table:** `scripts/extract_routes.py` crawls the web
|
|
100
|
+
app and rewrites `routes.json`, `desc0.bin` and `desc1.bin`. Logged out,
|
|
101
|
+
every muse.ai page redirects to the marketing page (`?aymh_complete=1`),
|
|
102
|
+
whose ~50 chunks do not include the app. The script therefore loads `/`
|
|
103
|
+
with the saved cookies, then follows `static/chunks/*.js` references
|
|
104
|
+
(about 1300 chunks, all public). The route table is one array of
|
|
105
|
+
`{method,httpMethod,path,...}` literals; the descriptors are base64
|
|
106
|
+
`FileDescriptorProto` blobs (`noise_transport.proto`,
|
|
107
|
+
`noise_envelope.proto`). Route literals may carry `requestBody: "empty"`,
|
|
108
|
+
`requestTimeoutMs`, `responseIdleTimeoutMs` and `maxResponseBytes`
|
|
109
|
+
(numbers such as `12e4`, `0x2400000`, `1/0` for no limit).
|
|
110
|
+
- **How the web client builds a request:** GET routes fill `{path}` params
|
|
111
|
+
from the params object and send the rest as query; non-GET routes send the
|
|
112
|
+
whole params object (path params included) as the JSON body, except
|
|
113
|
+
`requestBody: "empty"` routes, which send no body and no content-type.
|
|
114
|
+
`Gateway` matches this. List filters are repeated query keys:
|
|
115
|
+
`voice.catalog?source=library&gender=F&gender=M` works.
|
|
116
|
+
- `Gateway.request()` with `timeout=None` uses the route's `requestTimeoutMs`
|
|
117
|
+
(30 s when absent); `raw` and `export-data` default to that.
|
|
118
|
+
- `tasks.list` returns `{schedules: [{id, title, mode, enabled,
|
|
119
|
+
schedule_key, next_run_at_utc (s), cadence, ...}], invalid}`;
|
|
120
|
+
`tasks.runs` takes `{limit, job_id?}` and returns `{runs: [{run_id,
|
|
121
|
+
job_id, status, trigger_reason, scheduled_for_utc, result_summary,
|
|
122
|
+
error_text}]}`. `tasks.run` is POST `/tasks/{job_id}/run` with body
|
|
123
|
+
`{job_id}`, and the web client treats it as an inference call like
|
|
124
|
+
`chat.stream`.
|
|
125
|
+
- `voice.catalog`: `{source: "library", query?, gender?: [F|M|N], accent?:
|
|
126
|
+
[..], tone?: [..], limit, offset}`; `voice.catalog_filters` lists the
|
|
127
|
+
values with counts. `voice.speak` (`{voice_id, text, format: "mp3",
|
|
128
|
+
stream: true}`, binary `audio/mpeg`) returned 404 `preview_audio_disabled`
|
|
129
|
+
on the test account.
|
|
130
|
+
- Muse Mail (`email.*`) answers 403 `{"code": "email_not_enabled"}` when the
|
|
131
|
+
account has no mailbox. Thread list: `{data: [{id, subject,
|
|
132
|
+
message_count, participants, last_message}], paging: {cursors: {after}}}`,
|
|
133
|
+
next page with `{cursor}`. Messages carry `header_from`,
|
|
134
|
+
`header_from_name`, `header_to`, `text_body`/`html_body`/`extracted_text`,
|
|
135
|
+
`sender_authentication.verdict`, `attachments[{index, filename, mime_type,
|
|
136
|
+
size}]`. `email.attachment.get` returns JSON with `content_base64` and
|
|
137
|
+
`metadata.mime_type`, not raw bytes.
|
|
138
|
+
- Trusted Network (`peers.*`, `grants.list`, `peerSpaces.*`): `peers.status`
|
|
139
|
+
always answers, with `availability` (`"disabled"` when off), `features`,
|
|
140
|
+
`limits` and the agent's `muse_id`. While it is off, the list calls return
|
|
141
|
+
503 `peer_operation_unavailable` (`peers.connections.list`:
|
|
142
|
+
`connections_unavailable`). Page params are `{limit (1-100), cursor?}`.
|
|
143
|
+
- `dyi.export` (POST, empty body, ~65 min client timeout) streams the whole
|
|
144
|
+
data export as `application/zip` with `content-length` and a
|
|
145
|
+
`content-disposition` file name (`EYI Package_<date>_<n>.zip`). The test
|
|
146
|
+
account's export was 347 MB / 290 files in ~21 s. `export-data` writes the
|
|
147
|
+
body chunks straight to disk and checks type and length before keeping it.
|
|
148
|
+
- Services `ssh_access` (4, `ssh.operator.*`) and `yolk` (5,
|
|
149
|
+
`rv_migration.enable_export`) joined the `ServiceType` enum. Both are
|
|
150
|
+
operator/migration switches; muse-cli has no named commands for them.
|
|
151
|
+
- `vault.luks_status` returns 401 `request must come through nginx
|
|
152
|
+
auth_request` over the tunnel.
|
|
97
153
|
- POSTs to muse.ai need browser `Sec-Fetch-*` headers or they return 403.
|
|
98
154
|
- `auth export` on macOS decrypts the muse.ai rows of the browser's own cookie
|
|
99
155
|
database (`~/Library/Application Support/<browser>/<profile>/{Network/,}Cookies`,
|
|
@@ -177,6 +177,15 @@ muse-cli goals # one goal: muse-cli goa
|
|
|
177
177
|
muse-cli ideas # one idea: muse-cli idea <id>
|
|
178
178
|
muse-cli unread
|
|
179
179
|
muse-cli seen <thread-id>
|
|
180
|
+
muse-cli tasks # scheduled tasks (id, schedule, next_run)
|
|
181
|
+
muse-cli task-runs --job <task-id> --limit 5 # what recent runs did
|
|
182
|
+
muse-cli voices --search calm --limit 5 # voice catalog; --gender F|M|N --accent --tone
|
|
183
|
+
muse-cli voice # current voice
|
|
184
|
+
muse-cli email # Muse Mail mailbox + threads
|
|
185
|
+
muse-cli email-thread <thread-id> # also: email-message <id>
|
|
186
|
+
muse-cli email-attachment <message-id> <index> -o DIR
|
|
187
|
+
muse-cli peers # Trusted Network status / connected agents
|
|
188
|
+
muse-cli export-data -o DIR # full data export ZIP (can be hundreds of MB)
|
|
180
189
|
```
|
|
181
190
|
|
|
182
191
|
Management (visible side effects, confirm with the user first when destructive):
|
|
@@ -184,6 +193,7 @@ Management (visible side effects, confirm with the user first when destructive):
|
|
|
184
193
|
```bash
|
|
185
194
|
muse-cli feed-react <unit-id> love
|
|
186
195
|
muse-cli idea-exec <idea-id> # the agent acts on the idea (real work)
|
|
196
|
+
muse-cli task-run <task-id> # runs a scheduled task now (real work)
|
|
187
197
|
muse-cli session-start --title "x" # new side chat
|
|
188
198
|
muse-cli session-rename <id> "title" # also: pin, unpin, archive, unarchive, delete
|
|
189
199
|
muse-cli wake
|
|
@@ -191,7 +201,7 @@ muse-cli wake
|
|
|
191
201
|
|
|
192
202
|
## Escape hatch
|
|
193
203
|
|
|
194
|
-
`muse-cli raw <method> --body '{...}' [--param k=v]` calls any of the
|
|
204
|
+
`muse-cli raw <method> --body '{...}' [--param k=v]` calls any of the 402
|
|
195
205
|
gateway methods in `routes.json`. Prefer the named commands above; use raw
|
|
196
206
|
only for methods with no wrapper.
|
|
197
207
|
|
|
@@ -209,6 +219,13 @@ only for methods with no wrapper.
|
|
|
209
219
|
may be missing.
|
|
210
220
|
- `idea-exec --thread` may be ignored by the server; the run can land in the
|
|
211
221
|
main chat.
|
|
222
|
+
- Muse Mail, the Trusted Network (`peers`) and some other features are
|
|
223
|
+
enabled per account. `email` failing with `email_not_enabled` (exit 3) means
|
|
224
|
+
the account has no Muse Mail, not a broken install. `peers` prints
|
|
225
|
+
`availability: "disabled"` and a note when the Trusted Network is off.
|
|
226
|
+
- `export-data` writes the user's entire agent data (workspace, chats) to
|
|
227
|
+
disk. It takes about 20 s for a few hundred MB. Run it only when asked, and
|
|
228
|
+
keep the ZIP private.
|
|
212
229
|
- Running `muse-cli` with no command opens the interactive chat and blocks on
|
|
213
230
|
stdin. From an agent, always pass an explicit command such as `status` or
|
|
214
231
|
`send`.
|
|
@@ -777,6 +777,235 @@ def cmd_idea_exec(args):
|
|
|
777
777
|
gw.close()
|
|
778
778
|
|
|
779
779
|
|
|
780
|
+
def _when(ts):
|
|
781
|
+
"""Local 'YYYY-MM-DD HH:MM' for a unix time in seconds or milliseconds."""
|
|
782
|
+
if not isinstance(ts, (int, float)) or ts <= 0:
|
|
783
|
+
return None
|
|
784
|
+
if ts > 1e11:
|
|
785
|
+
ts = ts / 1000
|
|
786
|
+
return time.strftime("%Y-%m-%d %H:%M", time.localtime(ts))
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
def cmd_tasks(args):
|
|
790
|
+
gw = connect(load_config())
|
|
791
|
+
try:
|
|
792
|
+
d = gw.call_json("tasks.list")
|
|
793
|
+
if args.raw:
|
|
794
|
+
out(d); return
|
|
795
|
+
out([{"id": s.get("id"), "title": s.get("title"), "mode": s.get("mode"),
|
|
796
|
+
"enabled": s.get("enabled"), "schedule": s.get("schedule_key"),
|
|
797
|
+
"next_run": _when(s.get("next_run_at_utc")), "timezone": s.get("timezone")}
|
|
798
|
+
for s in d.get("schedules", [])])
|
|
799
|
+
finally:
|
|
800
|
+
gw.close()
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
def cmd_task_runs(args):
|
|
804
|
+
gw = connect(load_config())
|
|
805
|
+
try:
|
|
806
|
+
body = {"limit": args.limit}
|
|
807
|
+
if args.job:
|
|
808
|
+
body["job_id"] = args.job
|
|
809
|
+
d = gw.call_json("tasks.runs", body=body)
|
|
810
|
+
if args.raw:
|
|
811
|
+
out(d); return
|
|
812
|
+
out([{"run_id": r.get("run_id"), "job_id": r.get("job_id"), "status": r.get("status"),
|
|
813
|
+
"trigger": r.get("trigger_reason"), "scheduled": _when(r.get("scheduled_for_utc")),
|
|
814
|
+
"summary": r.get("result_summary"), "error": r.get("error_text")}
|
|
815
|
+
for r in d.get("runs", [])])
|
|
816
|
+
finally:
|
|
817
|
+
gw.close()
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
def cmd_task_run(args):
|
|
821
|
+
gw = connect(load_config())
|
|
822
|
+
try:
|
|
823
|
+
out(gw.call_json("tasks.run", path_params={"job_id": args.id}, body={"job_id": args.id}))
|
|
824
|
+
finally:
|
|
825
|
+
gw.close()
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
def cmd_voices(args):
|
|
829
|
+
gw = connect(load_config())
|
|
830
|
+
try:
|
|
831
|
+
query = {"source": "library", "limit": args.limit, "offset": args.offset}
|
|
832
|
+
if args.search:
|
|
833
|
+
query["query"] = args.search
|
|
834
|
+
for key in ("gender", "accent", "tone"):
|
|
835
|
+
if getattr(args, key):
|
|
836
|
+
query[key] = [getattr(args, key)]
|
|
837
|
+
d = gw.call_json("voice.catalog", query=query)
|
|
838
|
+
if args.raw:
|
|
839
|
+
out(d); return
|
|
840
|
+
out({"total": d.get("total"), "offset": d.get("offset"), "current": d.get("current"),
|
|
841
|
+
"voices": [{"id": v.get("id"), "name": v.get("name"),
|
|
842
|
+
"description": v.get("description"), "selected": v.get("is_selected")}
|
|
843
|
+
for v in d.get("voices", [])]})
|
|
844
|
+
finally:
|
|
845
|
+
gw.close()
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
def cmd_voice(_args):
|
|
849
|
+
gw = connect(load_config())
|
|
850
|
+
try:
|
|
851
|
+
out(gw.call_json("voice.active_voice"))
|
|
852
|
+
finally:
|
|
853
|
+
gw.close()
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
def _email_message(m):
|
|
857
|
+
who = m.get("header_from")
|
|
858
|
+
if m.get("header_from_name") and who:
|
|
859
|
+
who = f"{m['header_from_name']} <{who}>"
|
|
860
|
+
return {"id": m.get("id"), "thread_id": m.get("thread_id"), "direction": m.get("direction"),
|
|
861
|
+
"from": who, "to": m.get("header_to"), "cc": m.get("header_cc"),
|
|
862
|
+
"subject": m.get("subject"), "date": _when(m.get("created_at")),
|
|
863
|
+
"text": m.get("text_body") or m.get("extracted_text") or m.get("preview") or "",
|
|
864
|
+
"authentication": (m.get("sender_authentication") or {}).get("verdict"),
|
|
865
|
+
"attachments": [{"index": a.get("index", i), "filename": a.get("filename"),
|
|
866
|
+
"mime": a.get("mime_type"), "size": a.get("size")}
|
|
867
|
+
for i, a in enumerate(m.get("attachments") or [])
|
|
868
|
+
if isinstance(a, dict)]}
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
def cmd_email(args):
|
|
872
|
+
gw = connect(load_config())
|
|
873
|
+
try:
|
|
874
|
+
mailbox = gw.call_json("email.mailbox.get")
|
|
875
|
+
d = gw.call_json("email.threads.list", body={"cursor": args.cursor} if args.cursor else {})
|
|
876
|
+
if args.raw:
|
|
877
|
+
out({"mailbox": mailbox, "threads": d}); return
|
|
878
|
+
rows = []
|
|
879
|
+
for t in d.get("data", []):
|
|
880
|
+
last = t.get("last_message") or {}
|
|
881
|
+
rows.append({"id": t.get("id"), "subject": t.get("subject"),
|
|
882
|
+
"messages": t.get("message_count"), "participants": t.get("participants"),
|
|
883
|
+
"last_from": last.get("header_from"), "last_date": _when(last.get("created_at")),
|
|
884
|
+
"preview": last.get("preview")})
|
|
885
|
+
out({"mailbox": mailbox, "threads": rows,
|
|
886
|
+
"next_cursor": ((d.get("paging") or {}).get("cursors") or {}).get("after")})
|
|
887
|
+
finally:
|
|
888
|
+
gw.close()
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
def cmd_email_thread(args):
|
|
892
|
+
gw = connect(load_config())
|
|
893
|
+
try:
|
|
894
|
+
d = gw.call_json("email.threads.get", path_params={"thread_id": args.id})
|
|
895
|
+
if args.raw:
|
|
896
|
+
out(d); return
|
|
897
|
+
out([_email_message(m) for m in d.get("messages", []) if isinstance(m, dict)])
|
|
898
|
+
finally:
|
|
899
|
+
gw.close()
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
def cmd_email_message(args):
|
|
903
|
+
gw = connect(load_config())
|
|
904
|
+
try:
|
|
905
|
+
d = gw.call_json("email.messages.get", path_params={"message_id": args.id})
|
|
906
|
+
out(d if args.raw else _email_message(d.get("message", d)))
|
|
907
|
+
finally:
|
|
908
|
+
gw.close()
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
def cmd_email_attachment(args):
|
|
912
|
+
import base64
|
|
913
|
+
gw = connect(load_config())
|
|
914
|
+
try:
|
|
915
|
+
d = gw.call_json("email.attachment.get",
|
|
916
|
+
path_params={"message_id": args.message, "index": args.index})
|
|
917
|
+
finally:
|
|
918
|
+
gw.close()
|
|
919
|
+
if not d.get("content_base64"):
|
|
920
|
+
raise GatewayError(-1, "attachment response carried no content")
|
|
921
|
+
meta = d.get("metadata") or {}
|
|
922
|
+
name = meta.get("filename") or d.get("filename") or f"attachment-{args.index}"
|
|
923
|
+
dest = _local_name(name, args.output)
|
|
924
|
+
if os.path.exists(dest) and not args.force:
|
|
925
|
+
out({"file": os.path.abspath(dest), "skipped": "exists"}); return
|
|
926
|
+
data = base64.b64decode(d["content_base64"])
|
|
927
|
+
os.makedirs(args.output, exist_ok=True)
|
|
928
|
+
with open(dest, "wb") as fh:
|
|
929
|
+
fh.write(data)
|
|
930
|
+
out({"file": os.path.abspath(dest), "bytes": len(data),
|
|
931
|
+
"mime": meta.get("mime_type") or d.get("mime_type")})
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
def cmd_peers(args):
|
|
935
|
+
gw = connect(load_config())
|
|
936
|
+
try:
|
|
937
|
+
st = gw.call_json("peers.status")
|
|
938
|
+
if args.raw:
|
|
939
|
+
out(st); return
|
|
940
|
+
res = {"muse_id": (st.get("identity") or {}).get("muse_id"),
|
|
941
|
+
"supported": st.get("supported"), "availability": st.get("availability"),
|
|
942
|
+
"features": sorted(k for k, v in (st.get("features") or {}).items() if v)}
|
|
943
|
+
if st.get("availability") == "disabled":
|
|
944
|
+
res["note"] = "Trusted Network (peer connections) is turned off for this agent"
|
|
945
|
+
else:
|
|
946
|
+
try:
|
|
947
|
+
res["peers"] = gw.call_json("peers.list", body={"limit": args.limit})
|
|
948
|
+
except GatewayError as e:
|
|
949
|
+
res["peers_error"] = str(e)
|
|
950
|
+
out(res)
|
|
951
|
+
finally:
|
|
952
|
+
gw.close()
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
_FILENAME_RE = re.compile(r"filename\*?\s*=\s*(?:UTF-8'[^']*')?\"?([^\";]+)", re.I)
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
def _export_name(headers):
|
|
959
|
+
m = _FILENAME_RE.search(headers.get("content-disposition", ""))
|
|
960
|
+
name = os.path.basename(urllib.parse.unquote(m.group(1)).strip()) if m else ""
|
|
961
|
+
name = re.sub(r'[<>:"|?*\x00-\x1f]', "_", name).strip(". ") or "Agent Data.zip"
|
|
962
|
+
return name if name.lower().endswith(".zip") else name + ".zip"
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
def cmd_export_data(args):
|
|
966
|
+
target = args.output
|
|
967
|
+
to_dir = os.path.isdir(target) or target.endswith(("/", os.sep))
|
|
968
|
+
if not to_dir and os.path.exists(target) and not args.force:
|
|
969
|
+
print(f"{target} exists; pass -f to overwrite", file=sys.stderr)
|
|
970
|
+
sys.exit(2)
|
|
971
|
+
directory = target if to_dir else (os.path.dirname(target) or ".")
|
|
972
|
+
os.makedirs(directory, exist_ok=True)
|
|
973
|
+
part = os.path.join(directory, ".muse-cli-export.part")
|
|
974
|
+
show = sys.stderr.isatty()
|
|
975
|
+
last = [0.0]
|
|
976
|
+
|
|
977
|
+
def progress(n):
|
|
978
|
+
if show and time.time() - last[0] > 0.5:
|
|
979
|
+
last[0] = time.time()
|
|
980
|
+
print(f"\rdownloaded {n / 1e6:.1f} MB", end="", file=sys.stderr, flush=True)
|
|
981
|
+
|
|
982
|
+
print("Preparing your data export; large agents can take a few minutes...", file=sys.stderr)
|
|
983
|
+
gw = connect(load_config())
|
|
984
|
+
try:
|
|
985
|
+
with open(part, "wb") as fh:
|
|
986
|
+
headers = gw.request_to(fh, "dyi.export", timeout=args.timeout, on_progress=progress)
|
|
987
|
+
except BaseException:
|
|
988
|
+
if os.path.exists(part):
|
|
989
|
+
os.remove(part)
|
|
990
|
+
raise
|
|
991
|
+
finally:
|
|
992
|
+
gw.close()
|
|
993
|
+
if show:
|
|
994
|
+
print(file=sys.stderr)
|
|
995
|
+
size = os.path.getsize(part)
|
|
996
|
+
ctype = headers.get("content-type", "").split(";", 1)[0].strip().lower()
|
|
997
|
+
expected = headers.get("content-length")
|
|
998
|
+
if ctype != "application/zip" or (expected and expected.isdigit() and int(expected) != size):
|
|
999
|
+
os.remove(part)
|
|
1000
|
+
raise GatewayError(-1, f"data export was not a complete ZIP (content-type {ctype!r}, "
|
|
1001
|
+
f"{size} of {expected or '?'} bytes)")
|
|
1002
|
+
dest = os.path.join(directory, _export_name(headers)) if to_dir else target
|
|
1003
|
+
if os.path.exists(dest) and not args.force:
|
|
1004
|
+
stem, ext = os.path.splitext(dest)
|
|
1005
|
+
dest = f"{stem} {time.strftime('%Y%m%d-%H%M%S')}{ext}"
|
|
1006
|
+
os.replace(part, dest)
|
|
1007
|
+
out({"file": os.path.abspath(dest), "bytes": size})
|
|
1008
|
+
|
|
780
1009
|
def cmd_unread(_args):
|
|
781
1010
|
gw = connect(load_config())
|
|
782
1011
|
try:
|
|
@@ -978,6 +1207,47 @@ def build_parser():
|
|
|
978
1207
|
p.add_argument("--thread", default=None,
|
|
979
1208
|
help="side chat to run it in (the server may ignore this and use the main chat)")
|
|
980
1209
|
p.set_defaults(fn=cmd_idea_exec)
|
|
1210
|
+
p = sub.add_parser("tasks", help="list scheduled tasks (reminders, recurring jobs)")
|
|
1211
|
+
p.add_argument("--raw", action="store_true"); p.set_defaults(fn=cmd_tasks)
|
|
1212
|
+
p = sub.add_parser("task-runs", help="recent runs of scheduled tasks")
|
|
1213
|
+
p.add_argument("--job", default=None, help="only runs of this task id")
|
|
1214
|
+
p.add_argument("--limit", type=int, default=10); p.add_argument("--raw", action="store_true")
|
|
1215
|
+
p.set_defaults(fn=cmd_task_runs)
|
|
1216
|
+
p = sub.add_parser("task-run", help="run a scheduled task now (agent does the work)")
|
|
1217
|
+
p.add_argument("id", help="task id from `tasks`"); p.set_defaults(fn=cmd_task_run)
|
|
1218
|
+
p = sub.add_parser("voices", help="browse the voice catalog")
|
|
1219
|
+
p.add_argument("--search", default=None, help="free-text search (name, accent, tone)")
|
|
1220
|
+
p.add_argument("--gender", default=None, choices=["F", "M", "N"])
|
|
1221
|
+
p.add_argument("--accent", default=None, help="e.g. American, British, Indian")
|
|
1222
|
+
p.add_argument("--tone", default=None, help="e.g. Warm, Friendly, Calm")
|
|
1223
|
+
p.add_argument("--limit", type=int, default=50); p.add_argument("--offset", type=int, default=0)
|
|
1224
|
+
p.add_argument("--raw", action="store_true"); p.set_defaults(fn=cmd_voices)
|
|
1225
|
+
sub.add_parser("voice", help="show the agent's current voice").set_defaults(fn=cmd_voice)
|
|
1226
|
+
p = sub.add_parser("email", help="the agent's Muse Mail inbox: mailbox and threads")
|
|
1227
|
+
p.add_argument("--cursor", default=None, help="next_cursor from a previous page")
|
|
1228
|
+
p.add_argument("--raw", action="store_true"); p.set_defaults(fn=cmd_email)
|
|
1229
|
+
p = sub.add_parser("email-thread", help="read one Muse Mail thread")
|
|
1230
|
+
p.add_argument("id"); p.add_argument("--raw", action="store_true")
|
|
1231
|
+
p.set_defaults(fn=cmd_email_thread)
|
|
1232
|
+
p = sub.add_parser("email-message", help="read one Muse Mail message")
|
|
1233
|
+
p.add_argument("id"); p.add_argument("--raw", action="store_true")
|
|
1234
|
+
p.set_defaults(fn=cmd_email_message)
|
|
1235
|
+
p = sub.add_parser("email-attachment", help="save a Muse Mail attachment")
|
|
1236
|
+
p.add_argument("message", help="message id"); p.add_argument("index", type=int,
|
|
1237
|
+
help="attachment index from email-thread / email-message")
|
|
1238
|
+
p.add_argument("-o", "--output", default=".", help="directory to save into (default .)")
|
|
1239
|
+
p.add_argument("-f", "--force", action="store_true", help="overwrite an existing file")
|
|
1240
|
+
p.set_defaults(fn=cmd_email_attachment)
|
|
1241
|
+
p = sub.add_parser("peers", help="Trusted Network status and connected Muse agents")
|
|
1242
|
+
p.add_argument("--limit", type=int, default=50); p.add_argument("--raw", action="store_true")
|
|
1243
|
+
p.set_defaults(fn=cmd_peers)
|
|
1244
|
+
p = sub.add_parser("export-data", help="download all your agent's data as a ZIP")
|
|
1245
|
+
p.add_argument("-o", "--output", default=".",
|
|
1246
|
+
help="directory (file name comes from the server) or .zip path (default .)")
|
|
1247
|
+
p.add_argument("-f", "--force", action="store_true", help="overwrite an existing file")
|
|
1248
|
+
p.add_argument("--timeout", type=int, default=None,
|
|
1249
|
+
help="seconds to wait (default: the web app's limit, 65 minutes)")
|
|
1250
|
+
p.set_defaults(fn=cmd_export_data)
|
|
981
1251
|
sub.add_parser("unread", help="unread counts").set_defaults(fn=cmd_unread)
|
|
982
1252
|
p = sub.add_parser("seen", help="mark a thread seen"); p.add_argument("thread")
|
|
983
1253
|
p.set_defaults(fn=cmd_seen)
|
|
@@ -999,7 +1269,9 @@ def build_parser():
|
|
|
999
1269
|
p = sub.add_parser("raw", help="call any gateway method (escape hatch)")
|
|
1000
1270
|
p.add_argument("method"); p.add_argument("--body", default=None)
|
|
1001
1271
|
p.add_argument("--param", action="append", default=[], help="path param k=v (repeatable)")
|
|
1002
|
-
p.add_argument("--timeout", type=int, default=
|
|
1272
|
+
p.add_argument("--timeout", type=int, default=None,
|
|
1273
|
+
help="seconds to wait (default: the method's own limit, else 30)")
|
|
1274
|
+
p.set_defaults(fn=cmd_raw)
|
|
1003
1275
|
return ap
|
|
1004
1276
|
|
|
1005
1277
|
|
|
Binary file
|