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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// @generated from the MSP stable schema and protocol sources; do not edit by hand.
use crate::msp::view::item_background::BackgroundInitiator;
use crate::msp::view::item_background::BackgroundStatus;
use crate::msp::view::item_content::ModelVisibleContent;
use crate::msp::view::item_content::OutputRef;
use crate::msp::view::item_content::PatchSummary;
use crate::msp::view::item_hold::HeldFor;
use crate::msp::view::item_status::StatusAttempt;
use crate::msp::view::item_status::StatusChildren;
use crate::msp::view::item_status::StatusHealth;
use crate::msp::view::item_status::StatusProgress;
use crate::msp::view::item_status::StatusStep;
use crate::msp::view::tool_receipt::ToolReceipt;
use serde::Deserialize;
use serde::Serialize;
/// `toolCall` members, flattened into the item row.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct ToolCallMembers {
/// `toolCall`: tool name.
#[serde(skip_serializing_if = "Option::is_none")]
pub tool: Option<String>,
/// `toolCall`: the provider call id (`call_...`), opaque.
#[serde(skip_serializing_if = "Option::is_none")]
pub call_id: Option<String>,
/// `toolCall`: the model-authored argument JSON, **verbatim**; clients
/// parse. Verbatim keeps the fold byte-deterministic and survives
/// model-emitted almost-JSON.
#[serde(skip_serializing_if = "Option::is_none")]
pub args: Option<String>,
/// `toolCall`/`subagent`: `Failed`/`Rejected`/`Cancelled` reason text,
/// verbatim.
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_reason: Option<String>,
/// `toolCall`: machine-readable failure class.
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_kind: Option<String>,
/// `toolCall`/`userShell`: bounded transcript-visible result text; streams
/// via `item/delta` field `"output"`.
#[serde(skip_serializing_if = "Option::is_none")]
pub visible_output: Option<String>,
/// `toolCall`/`userShell`: stored-output reference; fetch the full bytes
/// via `item/readOutput`.
#[serde(skip_serializing_if = "Option::is_none")]
pub output_ref: Option<OutputRef>,
/// `toolCall`: the shared semantic receipt — what the operation did, as
/// machine-readable fact. Optional and additive: absence is always valid
/// and is never an error. When present, a server serves the **same**
/// receipt on every item path — `item/completed`, `view/page`, seeded
/// snapshots and resume. Observation only; carries no control authority,
/// and no field in it enters model-visible content.
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_receipt: Option<Box<ToolReceipt>>,
/// `toolCall`: server-authored edit-family diff summary — always beside
/// `patchRef`; absent = no diff available.
#[serde(skip_serializing_if = "Option::is_none")]
pub patch_summary: Option<PatchSummary>,
/// `toolCall`: stored structured-patch reference (`kind: "tool_patch"`,
/// `mediaType: "application/json"`); the body is fetched via
/// `item/readOutput` with `patchRef.id`, and the ref survives the
/// elided-snapshot rung exactly like `outputRef` without ever being an
/// elision trigger.
#[serde(skip_serializing_if = "Option::is_none")]
pub patch_ref: Option<OutputRef>,
/// `toolCall`: rich content the model saw beyond text; base64 is not
/// inlined on the view.
#[serde(skip_serializing_if = "Option::is_none")]
pub model_visible_content: Option<Vec<ModelVisibleContent>>,
/// `toolCall`: the approval that gated this call; join key for the approval
/// view events.
#[serde(skip_serializing_if = "Option::is_none")]
pub approval_id: Option<String>,
/// `toolCall`: `true` while the call is held before it is admitted to
/// execute. Present on an item started at hold time, cleared by the release
/// `item/updated`, absent on calls never held.
#[serde(skip_serializing_if = "Option::is_none")]
pub held: Option<bool>,
/// `toolCall`: what holds the call; present exactly when `held` is.
#[serde(skip_serializing_if = "Option::is_none")]
pub held_for: Option<HeldFor>,
/// `toolCall`: `true` once the task was durably backgrounded; delivered
/// via `item/updated`.
#[serde(skip_serializing_if = "Option::is_none")]
pub background: Option<bool>,
/// `toolCall`: who backgrounded the task; absent on pre-split records —
/// never inferred.
#[serde(skip_serializing_if = "Option::is_none")]
pub background_initiator: Option<BackgroundInitiator>,
/// `toolCall`: the backgrounded-row payload for a running backgrounded item
/// — auto-yield or an explicit user/timeout background; may appear with or
/// without `background`/`backgroundInitiator`. Experimental, delivered via
/// `item/updated`. Presentation only — never a durability claim.
#[serde(skip_serializing_if = "Option::is_none")]
pub background_status: Option<BackgroundStatus>,
/// `toolCall`: the task's visible latest-status line — the latest `Status`
/// message through the shared detail normalization; absent when no status
/// folded or nothing displayable remains.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_line: Option<String>,
/// `toolCall`: the latest detail's phase row, verbatim; absent when the
/// latest detail carries none.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_phase: Option<String>,
/// `toolCall`: the latest progress facet, field-for-field; absent when the
/// latest detail carries none.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_progress: Option<StatusProgress>,
/// `toolCall`: the latest active-step facet, field-for-field; absent when
/// the latest detail carries none.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_step: Option<StatusStep>,
/// `toolCall`: the latest external-attempt facet, field-for-field —
/// countdown inputs the client renders the tick from; absent when the
/// latest detail carries none.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_attempt: Option<StatusAttempt>,
/// `toolCall`: the latest health facet, field-for-field; absent when the
/// latest detail carries none.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_health: Option<StatusHealth>,
/// `toolCall`: the latest child-summary facet, field-for-field; absent when
/// the latest detail carries none.
#[serde(skip_serializing_if = "Option::is_none")]
pub status_children: Option<StatusChildren>,
/// `toolCall`: the tool's own words for this call; absent = none.
#[serde(skip_serializing_if = "Option::is_none")]
pub display_label: Option<Box<crate::msp::view::tool_label::ToolDisplayLabel>>,
/// `toolCall`: the call's Bash Title — its `description` argument through
/// the shared Bash Title normalizer, for a managed Bash call, served only
/// while the host's `bash_titles` gate is on. The host adds it when it
/// serves the item and never stores it; absent for any other call. Old
/// clients ignore it.
#[serde(skip_serializing_if = "Option::is_none")]
pub bash_title: Option<String>,
/// `toolCall`: the task's registered Work ID, verbatim
/// (`work.v2.managed_bash.sha256.…`); present only when the task registered
/// a ManagedBash id, absent otherwise. Stable from day one: no
/// `x-msp-stability` marker. The host serves it at the later of the task
/// terminal and the inbox admission; absence keeps the client's v1
/// derivation.
#[serde(skip_serializing_if = "Option::is_none")]
pub work_id: Option<String>,
/// `toolCall`: this call's live background-target record. Set when the
/// foreground tool starts, refreshed by whole-item `item/updated` when the
/// facts change, omitted once the call settles or unregisters — present
/// means a live candidate. Absent (pre-feature hosts, unregistered calls)
/// keeps the client's derived behavior, never an error. Old clients ignore
/// it.
#[serde(skip_serializing_if = "Option::is_none")]
pub background_target: Option<BackgroundTarget>,
/// `toolCall`: the name of the remote node this call is dispatched to.
/// **Experimental** (`Item.node`). Present once a dispatch to that node is
/// recorded for the call. Absent while none is: a call on the host's own
/// machine (in a session that never had a remote node this keeps today's
/// bytes), or a remote call that is not dispatched yet, or was refused or
/// failed before its dispatch; its approval request, when one was made,
/// names the node. Never `local`, and absence never means the default node.
#[serde(skip_serializing_if = "Option::is_none")]
pub node: Option<String>,
}
/// One call's live background-target record: exactly the runtime snapshot's
/// four facts, no new nouns.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct BackgroundTarget {
/// The tool call this record describes (the provider call id).
pub tool_call_id: String,
/// Point-in-time Ctrl+B chooser hint; the runtime re-checks
/// admission on the action.
pub manual_release_admissible: bool,
/// Whether the call sits in its foreground wait right now.
pub foreground_wait_active: bool,
/// Whether the background was already requested for this call.
pub background_requested: bool,
}