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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Per-request execution context surfaced via [`crate::BaseConnector::execute_with_context`].
//!
//! The Matrix server populates [`crate::types::ExecuteRequest::context`] with caller
//! identity and request-scoped metadata. Connectors that need to read these keys
//! should use the constants in [`keys`] instead of hardcoding strings.
//!
//! ## `params.metadata` ↔ `context` duplication
//!
//! Matrix populates each [`crate::types::ExecuteRequest`] with two parallel
//! views of the caller's metadata:
//!
//! - `context: HashMap<String, String>` — flat string map. Complex values
//! (like `agent_context`) are JSON-encoded strings and must be
//! `serde_json::from_str`-decoded before use.
//! - `params["metadata"]: serde_json::Value` — the same data with values
//! already decoded as JSON.
//!
//! For complex values prefer `params["metadata"][<key>]`; the `context` form
//! is provided so you can fast-path on simple keys (`tenant_id`, `user_id`)
//! without parsing the full payload.
//!
//! Tool arguments themselves are nested under `params["parameters"]`;
//! `params["metadata"]` and `params["tool"]` are siblings of that field.
//!
//! ## Example
//!
//! ```no_run
//! use std::collections::HashMap;
//! use strike48_connector::context::keys;
//!
//! fn handle(context: &HashMap<String, String>) -> &str {
//! context.get(keys::TENANT_ID).map(String::as_str).unwrap_or("default")
//! }
//! ```
/// Well-known [`crate::types::ExecuteRequest::context`] keys produced by the
/// Matrix server. Connectors that read identity off context should reference
/// these constants so a future server-side rename is a one-line SDK change.