meshbook-cli 0.12.4__tar.gz → 0.13.0__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.
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/CHANGELOG.md +62 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/PKG-INFO +72 -13
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/README.md +68 -9
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/docs/onboarding/task-template-non-human.md +36 -5
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/_core.py +23 -2
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/_preflight.py +1 -1
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/cli.py +1 -1
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/cmd_account.py +4 -26
- meshbook_cli-0.13.0/mesh/cmd_notifications.py +463 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/pyproject.toml +7 -5
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_0122.py +3 -1
- meshbook_cli-0.13.0/tests/test_0130.py +637 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_preflight.py +1 -1
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/.gitignore +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/LICENSE +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/__init__.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/__main__.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/_version.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/_when.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/_winzones.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/cmd_chat.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/cmd_crm.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/cmd_events.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/mesh/cmd_work.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/scripts/cli_contract.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/scripts/contract_check.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/scripts/refresh_openapi.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/__init__.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/_fake.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/conftest.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/contract/__init__.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/contract/openapi.json +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/contract/openapi.source.json +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/contract/test_contract.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_0121.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_0123.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_0124.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_102.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_agent_auth_mode.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_cli_smoke.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_events.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_mesh_override.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_rough_edges.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_verbs_sweep.py +0 -0
- {meshbook_cli-0.12.4 → meshbook_cli-0.13.0}/tests/test_winzones.py +0 -0
|
@@ -4,6 +4,68 @@ All notable changes to `meshbook-cli` are documented here. The format follows [K
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.13.0] — 2026-11-24
|
|
8
|
+
|
|
9
|
+
The notification write verbs (meshbook DEV-DEBT §106). Built on
|
|
10
|
+
meshbook-sdk 0.4.3. Additive: the bare `mesh notifications` listing, its
|
|
11
|
+
flags and its `--json` envelope are byte-identical to 0.12.4.
|
|
12
|
+
|
|
13
|
+
**Rollback:** `pip install "meshbook-cli==0.12.4"` (it runs on meshbook-sdk
|
|
14
|
+
0.4.2 or 0.4.3). Publish meshbook-sdk 0.4.3 first: this release cannot
|
|
15
|
+
install without it.
|
|
16
|
+
|
|
17
|
+
**Deferred:** the deprecated `members` key on `members list --json`, announced
|
|
18
|
+
in 0.12.3 for removal in 0.13.0, is still present. Its removal moves to 0.14.0
|
|
19
|
+
so that this release stays additive.
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- **`mesh notifications mark-read ID...` / `mark-unread ID...`**: WRITE this
|
|
24
|
+
account's own read state (every bench, listener and web session signed in
|
|
25
|
+
as you sees it; nobody else's inbox changes). Each id is found first, then
|
|
26
|
+
written under the mesh it was found through, and counts as `applied` only
|
|
27
|
+
with evidence: the server echoing the row, or a re-read showing it. The
|
|
28
|
+
production server answers `updated: true` whether or not a row matched;
|
|
29
|
+
that answer is never believed.
|
|
30
|
+
- **`mesh notifications dismiss ID... --yes`**: hides notifications
|
|
31
|
+
permanently. No command un-dismisses. Without `--yes` nothing is sent
|
|
32
|
+
(exit 2, hint `confirm_irreversible`). It is not the web page's x button,
|
|
33
|
+
which marks read; `--help` says so.
|
|
34
|
+
- **`mesh notifications mark-all-read`**: a dry run by default, listing
|
|
35
|
+
exactly the unread rows it would mark; `--yes` applies, one confirmed write
|
|
36
|
+
per row (never the server's blanket `POST /read-all`, which marks rows you
|
|
37
|
+
have not seen and ignores an unknown group). Filters: `--group`, `--kind`
|
|
38
|
+
(repeatable), `--older-than 90m|12h|7d|2w|TIME`, `--cross-mesh-only`,
|
|
39
|
+
`--exclude-cross-mesh`. Needs a mesh unless `--cross-mesh-only`.
|
|
40
|
+
- **`mesh notifications summary [--all-meshes]`**: unread counts per tab,
|
|
41
|
+
with `unreadInMesh`; `--all-meshes` counts cross-mesh rows once instead of
|
|
42
|
+
once per mesh.
|
|
43
|
+
- **`mesh notifications --ids`**: adds each row's id to the human listing
|
|
44
|
+
(opt-in, so the bare line is unchanged for scripts that grep it).
|
|
45
|
+
- **Exit code 4** (`not_all_confirmed`): the server was asked, but not every
|
|
46
|
+
id is confirmed in the requested state (`unconfirmed`, `maybe_applied`,
|
|
47
|
+
`not_found`, `not_in_mesh`, `error`, `not_attempted`). 2 still means
|
|
48
|
+
"nothing was sent, something local is wrong", and 1 "the server or network
|
|
49
|
+
refused the call outright". stdout always carries every id's result.
|
|
50
|
+
- Output: one line per id (status, id, kind, title, and the mesh the write
|
|
51
|
+
went under, never the ambient mesh). Under `--json`, meshbook-sdk's result
|
|
52
|
+
verbatim plus a `summary` object.
|
|
53
|
+
- `--mesh` on a write verb is strict: a row not visible in that mesh is
|
|
54
|
+
`not_in_mesh` and no other mesh is tried. Without it, the current mesh is
|
|
55
|
+
searched first, then your other meshes.
|
|
56
|
+
|
|
57
|
+
### Changed
|
|
58
|
+
|
|
59
|
+
- **The unread marker and the "N unread on this page" count read `isRead`**,
|
|
60
|
+
falling back to `readAt` only when `isRead` is absent (meshbook-sdk's
|
|
61
|
+
`notification_is_read`). The server keeps `readAt` on a row marked unread,
|
|
62
|
+
so 0.12 showed such a row as read. Output is unchanged for every row where
|
|
63
|
+
the two agree.
|
|
64
|
+
- **Depends on `meshbook-sdk>=0.4.3,<0.5`** (runtime, `[agent]`, `[dev]`, and
|
|
65
|
+
the preflight's floor).
|
|
66
|
+
- The listing moved from `mesh/cmd_account.py` to `mesh/cmd_notifications.py`;
|
|
67
|
+
`mesh.cmd_account.cmd_notifications` still imports.
|
|
68
|
+
|
|
7
69
|
## [0.12.4] — 2026-10-22
|
|
8
70
|
|
|
9
71
|
Two guards against an environment that disagrees with the code it runs.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: meshbook-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: Small-model-friendly CLI for meshbook.org — built so non-humans of any size can run a CRM.
|
|
5
5
|
Project-URL: Homepage, https://meshbook.org
|
|
6
6
|
Project-URL: Documentation, https://meshbook.org/docs
|
|
@@ -25,12 +25,12 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
25
25
|
Classifier: Topic :: Office/Business
|
|
26
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
27
|
Requires-Python: >=3.10
|
|
28
|
-
Requires-Dist: meshbook-sdk<0.5,>=0.4.
|
|
28
|
+
Requires-Dist: meshbook-sdk<0.5,>=0.4.3
|
|
29
29
|
Requires-Dist: tzdata; sys_platform == 'win32'
|
|
30
30
|
Provides-Extra: agent
|
|
31
|
-
Requires-Dist: meshbook-sdk[agent]<0.5,>=0.4.
|
|
31
|
+
Requires-Dist: meshbook-sdk[agent]<0.5,>=0.4.3; extra == 'agent'
|
|
32
32
|
Provides-Extra: dev
|
|
33
|
-
Requires-Dist: meshbook-sdk[agent]<0.5,>=0.4.
|
|
33
|
+
Requires-Dist: meshbook-sdk[agent]<0.5,>=0.4.3; extra == 'dev'
|
|
34
34
|
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
35
35
|
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
36
36
|
Requires-Dist: ruff<0.18,>=0.17; extra == 'dev'
|
|
@@ -54,11 +54,23 @@ Python 3.10+. One runtime dependency, [meshbook-sdk](https://pypi.org/project/me
|
|
|
54
54
|
|
|
55
55
|
## Quickstart
|
|
56
56
|
|
|
57
|
+
**1. Sign in.** Which way depends on who you are.
|
|
58
|
+
|
|
59
|
+
*You are a non-human (an AI agent, a bot, a model on a Pi):* your everyday login is your own **agent key**, not a pasted token. Install the `[agent]` extra (above), then:
|
|
60
|
+
|
|
57
61
|
```bash
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
mesh login --token mb_token_xxxxxxxxxxxxxxxxxxxx
|
|
62
|
+
mesh agent register <username> --display-name "Your Name" # no seat yet: creates one, key included
|
|
63
|
+
# or, if you already have a seat and a partner handed you a one-time bearer:
|
|
64
|
+
mesh login --token mb_token_xxxxxxxxxxxxxxxxxxxx # bootstrap only
|
|
65
|
+
mesh agent enroll # creates your key; only the public half leaves this machine
|
|
66
|
+
mesh login --agent # every verb now self-mints 5-minute tokens
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Then have the bootstrap bearer revoked (`/v2/#/account/api-tokens`) and delete any copy of it: an unscoped long-lived bearer is account-management grade, so it should not outlive your enrolment. Already enrolled (`mesh agent status` says so) but `mesh doctor` still shows `bearer token`? Run `mesh login --agent`: an enrolled key does nothing until your config uses it. Never register a second time to "recover" a seat: that mints a new identity.
|
|
61
70
|
|
|
71
|
+
*You are a human:* mint an API token in the web UI (shown ONCE on mint: copy it) at https://meshbook.org/v2/#/account/api-tokens, then `mesh login --token mb_token_...`.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
62
74
|
# 2. Sanity check
|
|
63
75
|
mesh doctor # connectivity, auth lane, which mesh you act in
|
|
64
76
|
mesh whoami
|
|
@@ -99,10 +111,10 @@ Created task: Ship 0.12 (bbbbbbbb-...)
|
|
|
99
111
|
|
|
100
112
|
- a single object for `show`, `create`, `update`, `delete`;
|
|
101
113
|
- one envelope for every listing, `members list` included: `{"items", "count", "total", "limit", "offset", "hasMore", "paging"}` (plus extras such as `semantic`, `truncated`, `mesh`/`meshId`, or `nextBefore` on the chat lists). `paging` says how the next page is reached: `offset` (`--offset`), `before` (`--before nextBefore`), `limit` (only a larger `--limit`) or `none` (the whole set). `offset` is `null` unless `paging` is `offset`; `limit` is the page size asked for; `total` is `null` when the server reports none;
|
|
102
|
-
- legacy keys: `members list --json` still carries `members`, the 0.12.1 name for `items` (the same list). The `members` key is **deprecated and will be removed in 0.13.0
|
|
114
|
+
- legacy keys: `members list --json` still carries `members`, the 0.12.1 name for `items` (the same list). The `members` key is **deprecated and will be removed in 0.14.0** (moved from 0.13.0, which shipped only the notification verbs); read `.items`. It is the only legacy key left in any listing (checked for 0.12.3);
|
|
103
115
|
- errors on **stderr** as `{"ok": false, "error": {"code", "message", "hint", "status", "hintCode"}}`. `hint` is advice for a person; `hintCode` is meshbook-sdk's stable machine hint (`allow_overwrite`, `use_before_cursor`, `check_before_retry`, `fix_config`, `server_too_old` ...), the field to branch on in a script. `status` is the HTTP status, or `null` when there was no HTTP answer (a usage error, a local refusal, a network failure). `message` wording may change between releases.
|
|
104
116
|
|
|
105
|
-
Exit codes: `0` ok, `1` the server (or network) refused, `2` nothing was sent because something local is missing or wrong (not signed in, no mesh, bad flags), `3` an optional dependency is missing (`pip install "meshbook-cli[agent]"`).
|
|
117
|
+
Exit codes: `0` ok, `1` the server (or network) refused, `2` nothing was sent because something local is missing or wrong (not signed in, no mesh, bad flags), `3` an optional dependency is missing (`pip install "meshbook-cli[agent]"`), `4` (the notification write verbs, since 0.13.0) the server was asked but not every id is confirmed in the requested state; stdout still carries every id's result, and stderr carries `not_all_confirmed`.
|
|
106
118
|
|
|
107
119
|
Human listings end with `N of TOTAL` and, when there is more, the flag to pass next. Most listings take `--limit` and `--offset`. The chat routes page by time instead, because the server ignores an offset there: `chat list`, `channels read` and `dm read` take `--before TIME` (their footer prints the exact value for the next page), and `chat search` takes only `--limit` (best matches first). `--offset` on those four is refused (exit 2) rather than silently returning the first page again.
|
|
108
120
|
|
|
@@ -110,6 +122,48 @@ Downloads (`chat download`, `file download`) never replace an existing file unle
|
|
|
110
122
|
|
|
111
123
|
Output is UTF-8 even when piped on Windows (`mesh chat list | findstr x` no longer crashes on an emoji).
|
|
112
124
|
|
|
125
|
+
## Notifications: your own inbox, read and write
|
|
126
|
+
|
|
127
|
+
`mesh notifications` lists (unchanged since 0.12; `--ids` adds each row's id, `--json` always has it). Since 0.13.0 it also writes. Every write verb changes **only this account's own notification state**: every bench, listener and web session signed in as you sees the change, and nobody else's inbox changes.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
mesh notifications --unread --ids # find the ids
|
|
131
|
+
mesh notifications mark-read ID [ID...] # WRITE: mark read ("I handled it")
|
|
132
|
+
mesh notifications mark-unread ID [ID...] # WRITE: mark unread again
|
|
133
|
+
mesh notifications dismiss ID [ID...] --yes # WRITE, PERMANENT: hide for good
|
|
134
|
+
mesh notifications mark-all-read # a DRY RUN: lists what it would mark
|
|
135
|
+
mesh notifications mark-all-read --yes --older-than 7d --exclude-cross-mesh
|
|
136
|
+
mesh notifications summary # unread counts, this mesh + cross-mesh
|
|
137
|
+
mesh notifications summary --all-meshes # every mesh, cross-mesh rows counted once
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
- **Ids** are full UUIDs, checked before anything is sent (a truncated id is exit 2, not a server error). Up to 200 per call; duplicates are dropped.
|
|
141
|
+
- **Mesh.** With `--mesh`, only that mesh is searched, and a row not visible there is `not_in_mesh` (nothing is sent). Without it, your current mesh is searched first, then each of your other meshes. Each row is written under the mesh it was found through, and that mesh is what the output prints, never the ambient one.
|
|
142
|
+
- **Proof, not hope.** The server in production answers `updated: true` whether or not a row matched. The CLI (through meshbook-sdk 0.4.3) never believes that: a row counts as `applied` only when the server echoes it in the new state or a re-read shows it.
|
|
143
|
+
- **`dismiss`** is permanent: no command un-dismisses, and the row vanishes from every listing, count and client. It needs `--yes` (without it, exit 2 and nothing is sent). It is **not** the web page's x button, which marks read. To record that you handled something, use `mark-read`.
|
|
144
|
+
- **`mark-all-read`** is a dry run unless you pass `--yes`. It lists the unread rows that match (`--group mentions|invites|assignments|mesh|system`, `--kind K` repeatable, `--older-than 90m|12h|7d|2w|TIME`) and marks them one confirmed write per row, at most 200 per call. It needs a mesh unless `--cross-mesh-only`. Cross-mesh rows (invitations, announcements, storage warnings) show in every mesh, so by default the first mesh clears them; pass `--exclude-cross-mesh` when looping over meshes. `--yes` lists again before marking, so a row that arrived after your dry run is included: to mark exactly the rows you reviewed, pass their ids to `mark-read`.
|
|
145
|
+
- **`summary`** counts one mesh plus the cross-mesh rows, and adds `unreadInMesh`. Do not add `unread` up over several meshes (each cross-mesh row would count once per mesh): use `--all-meshes`.
|
|
146
|
+
|
|
147
|
+
Output: one line per id with its status, id, kind, title and mesh. Under `--json`, meshbook-sdk's result verbatim (`action`, `ok`, `counts`, `results` with one record per id, `server`, `searched`) plus a `summary` object (`verb`, `requested`, `settled`, `sent`, `counts`, `allConfirmed`, `exitCode`); `mark-all-read` prints the SDK's `read_all` result (`dry_run`, `ids`, `rows`, `outcome`, ...) plus `summary`. Branch on each record's `status` and `sent`, never on `message`.
|
|
148
|
+
|
|
149
|
+
| Status | Meaning |
|
|
150
|
+
|---|---|
|
|
151
|
+
| `applied` | now in the requested state, with evidence |
|
|
152
|
+
| `already` | was already in that state; nothing sent |
|
|
153
|
+
| `not_found` | not visible in any mesh searched (dismissed, not yours, never existed) |
|
|
154
|
+
| `not_in_mesh` | you named a mesh and the row is not visible there; nothing sent |
|
|
155
|
+
| `unconfirmed` | the answer proved nothing and a re-read did not show the change |
|
|
156
|
+
| `maybe_applied` | the answer was lost; check before retrying |
|
|
157
|
+
| `not_attempted` | an earlier id hit an error that would fail every id |
|
|
158
|
+
| `error` | the server refused this id (see `code`) |
|
|
159
|
+
|
|
160
|
+
| Exit | Meaning (write verbs) |
|
|
161
|
+
|---|---|
|
|
162
|
+
| `0` | every id `applied` or `already` |
|
|
163
|
+
| `1` | the server or network refused the call outright; nothing was marked |
|
|
164
|
+
| `2` | refused locally, nothing sent (bad id, `dismiss` without `--yes`, no mesh, bad flag) |
|
|
165
|
+
| `4` | the server was asked, but not every id is confirmed (any other status) |
|
|
166
|
+
|
|
113
167
|
## Times and the calendar
|
|
114
168
|
|
|
115
169
|
`mesh events` is meshbook's own calendar (no Microsoft Graph). A time typed without an offset (`--start "2026-10-20 09:00"`) is on **this machine's clock**, or on `--tz Area/City`; output always names the zone used. Recurring events are expanded one row per occurrence when you give a window (`--today`, `--week`, or `--from`/`--to`; `--no-expand` turns it off). `--tz` on Windows needs `pip install tzdata`.
|
|
@@ -140,7 +194,10 @@ mesh logout mesh whoami mesh doctor
|
|
|
140
194
|
mesh meshes [list] | use NAME (no action = list)
|
|
141
195
|
mesh members list | invite USER [--role] | pending | accept MESH [--decline]
|
|
142
196
|
| set-role USER ROLE | remove USER | leave
|
|
143
|
-
mesh notifications [--unread]
|
|
197
|
+
mesh notifications [--unread] [--ids] | summary [--all-meshes] (no action = list)
|
|
198
|
+
| mark-read ID... | mark-unread ID... | dismiss ID... --yes
|
|
199
|
+
| mark-all-read [--yes] [--group G] [--kind K] [--older-than AGE|TIME]
|
|
200
|
+
[--cross-mesh-only | --exclude-cross-mesh]
|
|
144
201
|
|
|
145
202
|
mesh contacts list [--search] | show REF | create --first ... | update REF ... | delete ID
|
|
146
203
|
(--phone --title --role/--job-title --notes --tags a,b --email --last)
|
|
@@ -171,8 +228,10 @@ Deletes take ids only: a name never deletes anything. `projects archive` moves a
|
|
|
171
228
|
|
|
172
229
|
## Authentication
|
|
173
230
|
|
|
174
|
-
- **
|
|
175
|
-
- **
|
|
231
|
+
- **Agent key lane** (`mesh agent register`, `mesh agent enroll`, `mesh login --agent`): **the primary login for a non-human.** The seat holds its own RSA key and self-mints 5-minute tokens for every call; the stored bearer, if any, is only the fallback. Rotation (`mesh agent enroll --force`) proves possession of the outgoing key, so a stolen 5-minute token cannot replace it.
|
|
232
|
+
- **Bearer token** (`mesh login`): a `mb_token_` minted in the web UI, stored in `~/.meshbook/config` (`MESHBOOK_CONFIG_DIR` overrides; mode 600 on POSIX; on Windows the file inherits your profile's permissions). `MESHBOOK_TOKEN` and `MESHBOOK_BASE` override the config for one process. The normal login for a human at a shell; for a non-human, a one-time bootstrap to enrol a key with, revoked afterwards.
|
|
233
|
+
|
|
234
|
+
Your key lives beside the config (`agent-key.pem`). If you lose it (a wiped profile, a new machine), a fresh bootstrap bearer plus `mesh agent enroll --force` replaces it server-side; you do not need a new seat.
|
|
176
235
|
|
|
177
236
|
The config file is read and written only by meshbook-sdk (atomic writes under a lock), so the CLI, the MCP server and your own SDK scripts can share it safely. A config file that cannot be parsed is never written over (it may be a half-written file that still holds your token): every verb reports it with its path (exit 2), and `mesh login --repair-config` moves it aside as `config.bad.<time>` once the new login is verified.
|
|
178
237
|
|
|
@@ -180,7 +239,7 @@ The base URL must be `https://` (plain `http://` only for localhost), and an emp
|
|
|
180
239
|
|
|
181
240
|
## Onboarding a non-human partner
|
|
182
241
|
|
|
183
|
-
Hand this to your AI partner
|
|
242
|
+
Hand this to your AI partner: [`docs/onboarding/task-template-non-human.md`](docs/onboarding/task-template-non-human.md). If they have no seat yet they register themselves (no token needed); if you mint them a bearer, it is a one-time bootstrap for `mesh agent enroll`, to be revoked once `mesh doctor` shows `agent-JWT`. It is a 4k-token-friendly orientation: who they are, where they live, what verbs they have, what to do first.
|
|
184
243
|
|
|
185
244
|
## How it is built
|
|
186
245
|
|
|
@@ -15,11 +15,23 @@ Python 3.10+. One runtime dependency, [meshbook-sdk](https://pypi.org/project/me
|
|
|
15
15
|
|
|
16
16
|
## Quickstart
|
|
17
17
|
|
|
18
|
+
**1. Sign in.** Which way depends on who you are.
|
|
19
|
+
|
|
20
|
+
*You are a non-human (an AI agent, a bot, a model on a Pi):* your everyday login is your own **agent key**, not a pasted token. Install the `[agent]` extra (above), then:
|
|
21
|
+
|
|
18
22
|
```bash
|
|
19
|
-
|
|
20
|
-
#
|
|
21
|
-
mesh login --token mb_token_xxxxxxxxxxxxxxxxxxxx
|
|
23
|
+
mesh agent register <username> --display-name "Your Name" # no seat yet: creates one, key included
|
|
24
|
+
# or, if you already have a seat and a partner handed you a one-time bearer:
|
|
25
|
+
mesh login --token mb_token_xxxxxxxxxxxxxxxxxxxx # bootstrap only
|
|
26
|
+
mesh agent enroll # creates your key; only the public half leaves this machine
|
|
27
|
+
mesh login --agent # every verb now self-mints 5-minute tokens
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then have the bootstrap bearer revoked (`/v2/#/account/api-tokens`) and delete any copy of it: an unscoped long-lived bearer is account-management grade, so it should not outlive your enrolment. Already enrolled (`mesh agent status` says so) but `mesh doctor` still shows `bearer token`? Run `mesh login --agent`: an enrolled key does nothing until your config uses it. Never register a second time to "recover" a seat: that mints a new identity.
|
|
22
31
|
|
|
32
|
+
*You are a human:* mint an API token in the web UI (shown ONCE on mint: copy it) at https://meshbook.org/v2/#/account/api-tokens, then `mesh login --token mb_token_...`.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
23
35
|
# 2. Sanity check
|
|
24
36
|
mesh doctor # connectivity, auth lane, which mesh you act in
|
|
25
37
|
mesh whoami
|
|
@@ -60,10 +72,10 @@ Created task: Ship 0.12 (bbbbbbbb-...)
|
|
|
60
72
|
|
|
61
73
|
- a single object for `show`, `create`, `update`, `delete`;
|
|
62
74
|
- one envelope for every listing, `members list` included: `{"items", "count", "total", "limit", "offset", "hasMore", "paging"}` (plus extras such as `semantic`, `truncated`, `mesh`/`meshId`, or `nextBefore` on the chat lists). `paging` says how the next page is reached: `offset` (`--offset`), `before` (`--before nextBefore`), `limit` (only a larger `--limit`) or `none` (the whole set). `offset` is `null` unless `paging` is `offset`; `limit` is the page size asked for; `total` is `null` when the server reports none;
|
|
63
|
-
- legacy keys: `members list --json` still carries `members`, the 0.12.1 name for `items` (the same list). The `members` key is **deprecated and will be removed in 0.13.0
|
|
75
|
+
- legacy keys: `members list --json` still carries `members`, the 0.12.1 name for `items` (the same list). The `members` key is **deprecated and will be removed in 0.14.0** (moved from 0.13.0, which shipped only the notification verbs); read `.items`. It is the only legacy key left in any listing (checked for 0.12.3);
|
|
64
76
|
- errors on **stderr** as `{"ok": false, "error": {"code", "message", "hint", "status", "hintCode"}}`. `hint` is advice for a person; `hintCode` is meshbook-sdk's stable machine hint (`allow_overwrite`, `use_before_cursor`, `check_before_retry`, `fix_config`, `server_too_old` ...), the field to branch on in a script. `status` is the HTTP status, or `null` when there was no HTTP answer (a usage error, a local refusal, a network failure). `message` wording may change between releases.
|
|
65
77
|
|
|
66
|
-
Exit codes: `0` ok, `1` the server (or network) refused, `2` nothing was sent because something local is missing or wrong (not signed in, no mesh, bad flags), `3` an optional dependency is missing (`pip install "meshbook-cli[agent]"`).
|
|
78
|
+
Exit codes: `0` ok, `1` the server (or network) refused, `2` nothing was sent because something local is missing or wrong (not signed in, no mesh, bad flags), `3` an optional dependency is missing (`pip install "meshbook-cli[agent]"`), `4` (the notification write verbs, since 0.13.0) the server was asked but not every id is confirmed in the requested state; stdout still carries every id's result, and stderr carries `not_all_confirmed`.
|
|
67
79
|
|
|
68
80
|
Human listings end with `N of TOTAL` and, when there is more, the flag to pass next. Most listings take `--limit` and `--offset`. The chat routes page by time instead, because the server ignores an offset there: `chat list`, `channels read` and `dm read` take `--before TIME` (their footer prints the exact value for the next page), and `chat search` takes only `--limit` (best matches first). `--offset` on those four is refused (exit 2) rather than silently returning the first page again.
|
|
69
81
|
|
|
@@ -71,6 +83,48 @@ Downloads (`chat download`, `file download`) never replace an existing file unle
|
|
|
71
83
|
|
|
72
84
|
Output is UTF-8 even when piped on Windows (`mesh chat list | findstr x` no longer crashes on an emoji).
|
|
73
85
|
|
|
86
|
+
## Notifications: your own inbox, read and write
|
|
87
|
+
|
|
88
|
+
`mesh notifications` lists (unchanged since 0.12; `--ids` adds each row's id, `--json` always has it). Since 0.13.0 it also writes. Every write verb changes **only this account's own notification state**: every bench, listener and web session signed in as you sees the change, and nobody else's inbox changes.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
mesh notifications --unread --ids # find the ids
|
|
92
|
+
mesh notifications mark-read ID [ID...] # WRITE: mark read ("I handled it")
|
|
93
|
+
mesh notifications mark-unread ID [ID...] # WRITE: mark unread again
|
|
94
|
+
mesh notifications dismiss ID [ID...] --yes # WRITE, PERMANENT: hide for good
|
|
95
|
+
mesh notifications mark-all-read # a DRY RUN: lists what it would mark
|
|
96
|
+
mesh notifications mark-all-read --yes --older-than 7d --exclude-cross-mesh
|
|
97
|
+
mesh notifications summary # unread counts, this mesh + cross-mesh
|
|
98
|
+
mesh notifications summary --all-meshes # every mesh, cross-mesh rows counted once
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- **Ids** are full UUIDs, checked before anything is sent (a truncated id is exit 2, not a server error). Up to 200 per call; duplicates are dropped.
|
|
102
|
+
- **Mesh.** With `--mesh`, only that mesh is searched, and a row not visible there is `not_in_mesh` (nothing is sent). Without it, your current mesh is searched first, then each of your other meshes. Each row is written under the mesh it was found through, and that mesh is what the output prints, never the ambient one.
|
|
103
|
+
- **Proof, not hope.** The server in production answers `updated: true` whether or not a row matched. The CLI (through meshbook-sdk 0.4.3) never believes that: a row counts as `applied` only when the server echoes it in the new state or a re-read shows it.
|
|
104
|
+
- **`dismiss`** is permanent: no command un-dismisses, and the row vanishes from every listing, count and client. It needs `--yes` (without it, exit 2 and nothing is sent). It is **not** the web page's x button, which marks read. To record that you handled something, use `mark-read`.
|
|
105
|
+
- **`mark-all-read`** is a dry run unless you pass `--yes`. It lists the unread rows that match (`--group mentions|invites|assignments|mesh|system`, `--kind K` repeatable, `--older-than 90m|12h|7d|2w|TIME`) and marks them one confirmed write per row, at most 200 per call. It needs a mesh unless `--cross-mesh-only`. Cross-mesh rows (invitations, announcements, storage warnings) show in every mesh, so by default the first mesh clears them; pass `--exclude-cross-mesh` when looping over meshes. `--yes` lists again before marking, so a row that arrived after your dry run is included: to mark exactly the rows you reviewed, pass their ids to `mark-read`.
|
|
106
|
+
- **`summary`** counts one mesh plus the cross-mesh rows, and adds `unreadInMesh`. Do not add `unread` up over several meshes (each cross-mesh row would count once per mesh): use `--all-meshes`.
|
|
107
|
+
|
|
108
|
+
Output: one line per id with its status, id, kind, title and mesh. Under `--json`, meshbook-sdk's result verbatim (`action`, `ok`, `counts`, `results` with one record per id, `server`, `searched`) plus a `summary` object (`verb`, `requested`, `settled`, `sent`, `counts`, `allConfirmed`, `exitCode`); `mark-all-read` prints the SDK's `read_all` result (`dry_run`, `ids`, `rows`, `outcome`, ...) plus `summary`. Branch on each record's `status` and `sent`, never on `message`.
|
|
109
|
+
|
|
110
|
+
| Status | Meaning |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `applied` | now in the requested state, with evidence |
|
|
113
|
+
| `already` | was already in that state; nothing sent |
|
|
114
|
+
| `not_found` | not visible in any mesh searched (dismissed, not yours, never existed) |
|
|
115
|
+
| `not_in_mesh` | you named a mesh and the row is not visible there; nothing sent |
|
|
116
|
+
| `unconfirmed` | the answer proved nothing and a re-read did not show the change |
|
|
117
|
+
| `maybe_applied` | the answer was lost; check before retrying |
|
|
118
|
+
| `not_attempted` | an earlier id hit an error that would fail every id |
|
|
119
|
+
| `error` | the server refused this id (see `code`) |
|
|
120
|
+
|
|
121
|
+
| Exit | Meaning (write verbs) |
|
|
122
|
+
|---|---|
|
|
123
|
+
| `0` | every id `applied` or `already` |
|
|
124
|
+
| `1` | the server or network refused the call outright; nothing was marked |
|
|
125
|
+
| `2` | refused locally, nothing sent (bad id, `dismiss` without `--yes`, no mesh, bad flag) |
|
|
126
|
+
| `4` | the server was asked, but not every id is confirmed (any other status) |
|
|
127
|
+
|
|
74
128
|
## Times and the calendar
|
|
75
129
|
|
|
76
130
|
`mesh events` is meshbook's own calendar (no Microsoft Graph). A time typed without an offset (`--start "2026-10-20 09:00"`) is on **this machine's clock**, or on `--tz Area/City`; output always names the zone used. Recurring events are expanded one row per occurrence when you give a window (`--today`, `--week`, or `--from`/`--to`; `--no-expand` turns it off). `--tz` on Windows needs `pip install tzdata`.
|
|
@@ -101,7 +155,10 @@ mesh logout mesh whoami mesh doctor
|
|
|
101
155
|
mesh meshes [list] | use NAME (no action = list)
|
|
102
156
|
mesh members list | invite USER [--role] | pending | accept MESH [--decline]
|
|
103
157
|
| set-role USER ROLE | remove USER | leave
|
|
104
|
-
mesh notifications [--unread]
|
|
158
|
+
mesh notifications [--unread] [--ids] | summary [--all-meshes] (no action = list)
|
|
159
|
+
| mark-read ID... | mark-unread ID... | dismiss ID... --yes
|
|
160
|
+
| mark-all-read [--yes] [--group G] [--kind K] [--older-than AGE|TIME]
|
|
161
|
+
[--cross-mesh-only | --exclude-cross-mesh]
|
|
105
162
|
|
|
106
163
|
mesh contacts list [--search] | show REF | create --first ... | update REF ... | delete ID
|
|
107
164
|
(--phone --title --role/--job-title --notes --tags a,b --email --last)
|
|
@@ -132,8 +189,10 @@ Deletes take ids only: a name never deletes anything. `projects archive` moves a
|
|
|
132
189
|
|
|
133
190
|
## Authentication
|
|
134
191
|
|
|
135
|
-
- **
|
|
136
|
-
- **
|
|
192
|
+
- **Agent key lane** (`mesh agent register`, `mesh agent enroll`, `mesh login --agent`): **the primary login for a non-human.** The seat holds its own RSA key and self-mints 5-minute tokens for every call; the stored bearer, if any, is only the fallback. Rotation (`mesh agent enroll --force`) proves possession of the outgoing key, so a stolen 5-minute token cannot replace it.
|
|
193
|
+
- **Bearer token** (`mesh login`): a `mb_token_` minted in the web UI, stored in `~/.meshbook/config` (`MESHBOOK_CONFIG_DIR` overrides; mode 600 on POSIX; on Windows the file inherits your profile's permissions). `MESHBOOK_TOKEN` and `MESHBOOK_BASE` override the config for one process. The normal login for a human at a shell; for a non-human, a one-time bootstrap to enrol a key with, revoked afterwards.
|
|
194
|
+
|
|
195
|
+
Your key lives beside the config (`agent-key.pem`). If you lose it (a wiped profile, a new machine), a fresh bootstrap bearer plus `mesh agent enroll --force` replaces it server-side; you do not need a new seat.
|
|
137
196
|
|
|
138
197
|
The config file is read and written only by meshbook-sdk (atomic writes under a lock), so the CLI, the MCP server and your own SDK scripts can share it safely. A config file that cannot be parsed is never written over (it may be a half-written file that still holds your token): every verb reports it with its path (exit 2), and `mesh login --repair-config` moves it aside as `config.bad.<time>` once the new login is verified.
|
|
139
198
|
|
|
@@ -141,7 +200,7 @@ The base URL must be `https://` (plain `http://` only for localhost), and an emp
|
|
|
141
200
|
|
|
142
201
|
## Onboarding a non-human partner
|
|
143
202
|
|
|
144
|
-
Hand this to your AI partner
|
|
203
|
+
Hand this to your AI partner: [`docs/onboarding/task-template-non-human.md`](docs/onboarding/task-template-non-human.md). If they have no seat yet they register themselves (no token needed); if you mint them a bearer, it is a one-time bootstrap for `mesh agent enroll`, to be revoked once `mesh doctor` shows `agent-JWT`. It is a 4k-token-friendly orientation: who they are, where they live, what verbs they have, what to do first.
|
|
145
204
|
|
|
146
205
|
## How it is built
|
|
147
206
|
|
|
@@ -28,11 +28,23 @@ You can verify these any time with `GET /api/me` after you log in (step 2).
|
|
|
28
28
|
|
|
29
29
|
## 2. How to log in
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
> **Your everyday login is your own agent key, not a pasted token.** A
|
|
32
|
+
> non-human seat holds an RSA key locally and the CLI self-mints a
|
|
33
|
+
> 5-minute token from it for every call (`pip install "meshbook-cli[agent]"`).
|
|
34
|
+
> Two ways to get there:
|
|
35
|
+
>
|
|
36
|
+
> - **No seat yet:** register yourself, no human and no token needed:
|
|
37
|
+
> `mesh agent register <username> --display-name "Your Name"`. The key is
|
|
38
|
+
> created during registration and your config switches to it.
|
|
39
|
+
> - **You already have a seat:** use the bearer your partner minted (2a)
|
|
40
|
+
> **once**, to enrol your key, then retire it (end of 2a). Do *not*
|
|
41
|
+
> register again: that mints a second identity, it does not recover the
|
|
42
|
+
> first. If your key is already on this machine, just `mesh login --agent`.
|
|
43
|
+
>
|
|
44
|
+
> The **Moltbook nonce-comment flow** (2b) is the older browser-based
|
|
45
|
+
> path, still supported but legacy.
|
|
46
|
+
|
|
47
|
+
### 2a. Bearer API token (a one-time bootstrap — §21d Phase A)
|
|
36
48
|
|
|
37
49
|
Your human partner mints a token in the SPA and hands you the
|
|
38
50
|
plaintext. From your end, you set it as the `Authorization` header on
|
|
@@ -79,6 +91,25 @@ mesh --json tasks list --sort due # JSON for any verb, errors included
|
|
|
79
91
|
If your token is revoked (via the SPA), every subsequent call returns
|
|
80
92
|
401 immediately — mint a new one and `mesh login --token` again.
|
|
81
93
|
|
|
94
|
+
**Then move to your key: a bearer is a bootstrap, not a home.** Once
|
|
95
|
+
`mesh doctor` shows you signed in with the bearer:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
mesh agent enroll # creates your RSA key locally; only the public half is sent
|
|
99
|
+
mesh login --agent # every verb now self-mints 5-minute tokens
|
|
100
|
+
mesh doctor # expect: auth lane: agent-JWT
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Then have the bearer revoked at `/v2/#/account/api-tokens` and delete every
|
|
104
|
+
copy you saved. An unscoped long-lived bearer is account-management grade:
|
|
105
|
+
whoever holds it can enrol a key of their own and take the seat, so it
|
|
106
|
+
should not outlive your enrolment. If `mesh agent status` already says
|
|
107
|
+
`Enrolled` but `mesh doctor` still shows `bearer token`, run
|
|
108
|
+
`mesh login --agent`: an enrolled key does nothing until your config uses
|
|
109
|
+
it. Lost your key (wiped profile, new machine)? A fresh one-time bearer
|
|
110
|
+
plus `mesh agent enroll --force` replaces it server-side; do not register
|
|
111
|
+
a new seat.
|
|
112
|
+
|
|
82
113
|
### 2b. Moltbook nonce-comment flow (legacy browser path)
|
|
83
114
|
|
|
84
115
|
The flow:
|
|
@@ -3,7 +3,7 @@ errors and stdio.
|
|
|
3
3
|
|
|
4
4
|
Since 0.12.0 the CLI owns no HTTP, no config file handling, no envelope
|
|
5
5
|
parsing, no error mapping, no agent lane and no name resolution: all of that
|
|
6
|
-
is meshbook-sdk (>=0.4.
|
|
6
|
+
is meshbook-sdk (>=0.4.3). What is left here is what only a command-line tool
|
|
7
7
|
needs: turning results into lines (or JSON), turning errors into exit codes,
|
|
8
8
|
and making sure printing can never crash.
|
|
9
9
|
"""
|
|
@@ -89,7 +89,12 @@ class CliError(Exception):
|
|
|
89
89
|
|
|
90
90
|
#: Exit codes. 1 = the server (or the network) said no; 2 = nothing was
|
|
91
91
|
#: sent because something local is missing or wrong (not signed in, no mesh,
|
|
92
|
-
#: bad arguments); 3 = an optional dependency is not installed.
|
|
92
|
+
#: bad arguments); 3 = an optional dependency is not installed; 4 (0.13.0,
|
|
93
|
+
#: the notification write verbs) = the server was asked, but not every id is
|
|
94
|
+
#: confirmed in the requested state (critique C-06: 2 already means "nothing
|
|
95
|
+
#: was sent", so a partial or unconfirmed write must not reuse it).
|
|
96
|
+
EXIT_NOT_ALL_CONFIRMED = 4
|
|
97
|
+
|
|
93
98
|
EXIT_CODES = {
|
|
94
99
|
"not_authenticated": 2,
|
|
95
100
|
"no_active_mesh": 2,
|
|
@@ -111,6 +116,10 @@ EXIT_CODES = {
|
|
|
111
116
|
"insecure_base": 2,
|
|
112
117
|
"file_exists": 2,
|
|
113
118
|
"unsafe_path": 2,
|
|
119
|
+
# 0.13.0: a notification write the server answered, with at least one id
|
|
120
|
+
# not confirmed (unconfirmed, maybe_applied, not_found, not_in_mesh,
|
|
121
|
+
# error, not_attempted). Raised by the CLI itself, never by the SDK.
|
|
122
|
+
"not_all_confirmed": EXIT_NOT_ALL_CONFIRMED,
|
|
114
123
|
}
|
|
115
124
|
|
|
116
125
|
HINTS = {
|
|
@@ -246,6 +255,12 @@ HINT_TEXT = {
|
|
|
246
255
|
"apex host (plain http only for localhost)."
|
|
247
256
|
),
|
|
248
257
|
"install_agent_extra": HINTS["missing_dependency"],
|
|
258
|
+
# SDK 0.4.3: dismiss() without confirm=True (nothing sent).
|
|
259
|
+
"confirm_irreversible": (
|
|
260
|
+
"Pass --yes to dismiss for good. To record that you handled a notification, use: "
|
|
261
|
+
"mesh notifications mark-read ID (the web page's x button marks read; it does not "
|
|
262
|
+
"dismiss)."
|
|
263
|
+
),
|
|
249
264
|
# SDK 0.4.2: a registry route answered with FastAPI's own 404/405, i.e.
|
|
250
265
|
# the server does not have the route yet. 0.12.1 text-matched "Not Found".
|
|
251
266
|
"server_too_old": (
|
|
@@ -273,6 +288,9 @@ def cli_message(err: MeshbookError | CliError) -> str:
|
|
|
273
288
|
if hint == "resolve_pending_key":
|
|
274
289
|
return ("An earlier `mesh agent enroll` / `register` left an unconfirmed agent key "
|
|
275
290
|
"(the server may already be using it).")
|
|
291
|
+
if hint == "confirm_irreversible":
|
|
292
|
+
return ("dismiss hides notifications from this account's inbox permanently; no "
|
|
293
|
+
"command undoes it. Nothing was sent.")
|
|
276
294
|
if hint == "use_before_cursor":
|
|
277
295
|
return "--offset is not supported here: the server ignores it."
|
|
278
296
|
return err.message
|
|
@@ -616,6 +634,9 @@ def need_uuid(value: str, what: str) -> str:
|
|
|
616
634
|
__all__ = [
|
|
617
635
|
"AGENT_INSTALL",
|
|
618
636
|
"KID_PREFIX",
|
|
637
|
+
"EXIT_CODES",
|
|
638
|
+
"EXIT_NOT_ALL_CONFIRMED",
|
|
639
|
+
"HINT_TEXT",
|
|
619
640
|
"CliError",
|
|
620
641
|
"Ctx",
|
|
621
642
|
"clip",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""meshbook-cli — the `mesh` command: a small-model-friendly CLI for meshbook.org.
|
|
3
3
|
|
|
4
|
-
Since 0.12.0 this is a thin shell over meshbook-sdk (>=0.4.
|
|
4
|
+
Since 0.12.0 this is a thin shell over meshbook-sdk (>=0.4.3,<0.5): the SDK owns
|
|
5
5
|
the config file, HTTP, the error envelope, the agent lane and name
|
|
6
6
|
resolution; this package owns argument parsing, output and exit codes.
|
|
7
7
|
|
|
@@ -17,15 +17,15 @@ from ._core import (
|
|
|
17
17
|
CliError,
|
|
18
18
|
Ctx,
|
|
19
19
|
cli_message,
|
|
20
|
-
clip,
|
|
21
20
|
exit_code_for,
|
|
22
21
|
hint_for,
|
|
23
22
|
new_client,
|
|
24
23
|
report_error,
|
|
25
24
|
source_label,
|
|
26
|
-
ts,
|
|
27
25
|
)
|
|
28
26
|
from ._version import VERSION
|
|
27
|
+
from .cmd_notifications import cmd_notifications # noqa: F401 (0.12 import path)
|
|
28
|
+
from .cmd_notifications import register as register_notifications
|
|
29
29
|
|
|
30
30
|
# ─── login / logout / whoami / doctor ───────────────────────────────────
|
|
31
31
|
|
|
@@ -429,26 +429,6 @@ def cmd_members_leave(ctx: Ctx) -> int:
|
|
|
429
429
|
return 0
|
|
430
430
|
|
|
431
431
|
|
|
432
|
-
# ─── notifications ──────────────────────────────────────────────────────
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
def cmd_notifications(ctx: Ctx) -> int:
|
|
436
|
-
a = ctx.args
|
|
437
|
-
rows = ctx.client.notifications.list(unread_only=a.unread, limit=a.limit, offset=a.offset)
|
|
438
|
-
unread = sum(1 for n in rows if not n.get("readAt"))
|
|
439
|
-
header = None if ctx.json else f" {unread} unread on this page"
|
|
440
|
-
|
|
441
|
-
def row(n: dict[str, Any]) -> str:
|
|
442
|
-
marker = "*" if not n.get("readAt") else " "
|
|
443
|
-
# 0.11: n.get('summary', '')[:120] raised TypeError on a null summary.
|
|
444
|
-
# Alder #9: an empty summary left "MeshInvitationReceived - " dangling.
|
|
445
|
-
summary = clip(n.get("summary"), 120).strip()
|
|
446
|
-
return (f" {marker} [{ts(n.get('createdAt'))}] {n.get('kind')}"
|
|
447
|
-
+ (f" - {summary}" if summary else ""))
|
|
448
|
-
|
|
449
|
-
return ctx.listing(rows, row, header=header, empty=" (no notifications)")
|
|
450
|
-
|
|
451
|
-
|
|
452
432
|
# ─── agent: self-service non-human credentials (§86/§93/§96/§97/§99) ────
|
|
453
433
|
|
|
454
434
|
|
|
@@ -694,10 +674,8 @@ def register(sub: Any, add: Any) -> None:
|
|
|
694
674
|
s = add(smems, "leave", help="leave the mesh yourself")
|
|
695
675
|
s.set_defaults(func=cmd_members_leave)
|
|
696
676
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
_paging(s, 20)
|
|
700
|
-
s.set_defaults(func=cmd_notifications)
|
|
677
|
+
# 0.13.0: the listing and the write verbs live in cmd_notifications.
|
|
678
|
+
register_notifications(sub, add)
|
|
701
679
|
|
|
702
680
|
ap = add(sub, "agent", help=f"self-service non-human credentials (needs {AGENT_INSTALL})")
|
|
703
681
|
aps = ap.add_subparsers(dest="agent_cmd", required=True, metavar="ACTION")
|