1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Handler for `trusty-memory send-message` (issue #99).
//!
//! Why: gives non-MCP callers (shell scripts, Makefiles, the `claude-mpm`
//! migration shim) a way to deliver inter-project messages without going
//! through stdio MCP. Talks to the running daemon over the same HTTP API
//! the MCP tool ultimately uses, so behaviour stays in lockstep with the
//! MCP path.
//!
//! What: a one-shot async command that posts to
//! `POST /api/v1/messages` and prints the new drawer id on success.
//! Defaults `--from` to the cwd-derived palace slug when omitted.
//!
//! Test: round-trip via the unit test in `messaging::tests`; the HTTP
//! handler is itself covered by `web::tests::messages_post_then_get_unread`.
use ;
use json;
use Duration;
/// Default HTTP timeout for the send call.
///
/// Why: The daemon's write path is short (one drawer insert) but we don't
/// want a stalled daemon to hang the CLI for minutes. 10 s leaves room for
/// a paged-out cache while still surfacing real outages quickly.
const CALL_TIMEOUT: Duration = from_secs;
/// Entry point for `trusty-memory send-message`.
///
/// Why: pure CLI shim around the HTTP send endpoint so the binary surface
/// stays consistent ("anything you can do via MCP, you can do via CLI").
/// What: calls `memory.message_send` through `crate::client`, prints the
/// response JSON, and exits non-zero on any failure
/// (unlike the SessionStart hook, this command is run by a human / script
/// who wants to see failures).
/// Test: covered manually via `trusty-memory start && trusty-memory
/// send-message --to <p> --purpose <p> --content <c>`.
pub async