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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// @generated from the MSP stable schema and protocol sources; do not edit by hand.
use crate::msp::method::turn::CommandStatus;
use crate::msp::view::item_content::BackgroundInitiator;
use serde::Deserialize;
use serde::Deserializer;
use serde::Serialize;
use serde::Serializer;
mod catch_all;
/// `task/background` params: durably send a running foreground tool task to the
/// background.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TaskBackgroundParams {
/// The target session.
pub session_id: String,
/// The idempotency handle (UUIDv7).
pub command_id: String,
/// The task to background, exactly as the view names it: the `toolCall`
/// item's `itemId` IS the task id.
pub task_id: String,
}
/// `task/stop` params: stop one named background task. Required target, never
/// "whichever is loudest" — is the blanket verb.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TaskStopParams {
/// The target session.
pub session_id: String,
/// The idempotency handle (UUIDv7).
pub command_id: String,
/// The task to stop, the `toolCall` item's `itemId`.
pub task_id: String,
}
/// `task/stopAll` params: stop every stoppable background workload live at
/// admission.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TaskStopAllParams {
/// The target session.
pub session_id: String,
/// The idempotency handle (UUIDv7).
pub command_id: String,
}
/// The `task/background` / `task/stop` ack: admission-only, echoing the
/// targeted task.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct TaskCommandResult {
/// Echoes the client's id.
pub command_id: String,
/// Admission status.
pub status: CommandStatus,
/// Echoes the targeted task id.
pub task_id: String,
}
/// The `task/stopAll` ack: always `accepted`, including over an empty set — a
/// blanket stop over nothing is a satisfied gesture. The ack deliberately
/// carries no stopped-task list; count the kills from the view.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct TaskStopAllResult {
/// Echoes the client's id.
pub command_id: String,
/// Admission status.
pub status: CommandStatus,
}
/// `task/list` params: the session whose background-task inventory to read. A
/// read-only query in the `skill/list` mold: no `commandId`, no durable record,
/// no view event.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TaskListParams {
/// The target session.
pub session_id: String,
}
/// `task/list` result: one row per live workload, background and foreground,
/// oldest first; empty when nothing is running.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct TaskListResult {
/// The session's live task rows.
pub tasks: Vec<TaskListEntry>,
}
/// One task inventory row. The row is the stable contract: `kind` and `status`
/// stay open so a future state extends them without breaking clients.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct TaskListEntry {
/// The `toolCall` item's `itemId` for item rows; the runtime registry
/// id for registry-only rows.
pub task_id: String,
/// What the workload is: `"tool"` or `"tool.*"` for item rows (the
/// recorded kind when the registry records one, else `"tool"`); the
/// recorded registry kind string verbatim for registry-only rows.
/// Open vocabulary — clients MUST ignore unknown kinds. A `String`,
/// not an enum: registry kind strings are unbounded.
pub kind: String,
/// `"inProgress"` — the only value at this increment, since every
/// listed row is non-terminal by construction.
pub status: TaskListStatus,
/// The short tool name on item-visible tool rows only; never a label,
/// never arguments. **Additive-optional**: absent elsewhere.
#[serde(skip_serializing_if = "Option::is_none")]
pub tool: Option<String>,
/// The host-known task start, RFC3339. **Additive-optional**: omitted,
/// never guessed, when the host does not know it.
#[serde(skip_serializing_if = "Option::is_none")]
pub started_at: Option<String>,
/// Who backgrounded the task, mirroring the item field.
/// **Additive-optional**: absent on pre-split records and
/// registry-only rows, never inferred.
#[serde(skip_serializing_if = "Option::is_none")]
pub background_initiator: Option<BackgroundInitiator>,
/// `"foreground" | "background"`. **Additive-optional**: absent means
/// `"background"` (only pre-change hosts omit it, and those list background
/// rows only); never guessed.
#[serde(skip_serializing_if = "Option::is_none")]
pub execution_mode: Option<TaskExecutionMode>,
/// The raw command text: the joined `toolCall` item's `command` argument
/// verbatim. **Additive-optional**: omitted when the row has no item or the
/// item carries no command. Monitors join raw — clients redact.
#[serde(skip_serializing_if = "Option::is_none")]
pub command: Option<String>,
}
/// A task row's status. Open: a future state is additive, and clients MUST
/// ignore unknown statuses.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum TaskListStatus {
/// The workload is live; every listed row carries this today.
InProgress,
/// A value from a newer host, kept verbatim so an older client decodes the
/// rest of the message. Never construct it with a known word.
Unknown(String),
}
/// A task row's execution mode. Open: clients MUST ignore unknown modes.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum TaskExecutionMode {
/// The task holds the turn (a census counts it; the stop sweep skips it).
Foreground,
/// The task runs detached (census and sweep both cover it).
Background,
/// A mode introduced by a newer server. Preserved verbatim so an older
/// client keeps the unknown word instead of failing the parse. Not a v1
/// server-emission value, so it is excluded from the generated known-value
/// schema while the enum remains declared open (the `AdmissionDecision`
/// precedent).
Unknown(String),
}
impl TaskExecutionMode {
/// The exact wire spelling, including a future value an older
/// client does not understand.
#[must_use]
pub fn as_str(&self) -> &str {
match self {
Self::Foreground => "foreground",
Self::Background => "background",
Self::Unknown(value) => value,
}
}
}
impl Serialize for TaskExecutionMode {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for TaskExecutionMode {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value = String::deserialize(deserializer)?;
Ok(match value.as_str() {
"foreground" => Self::Foreground,
"background" => Self::Background,
_ => Self::Unknown(value),
})
}
}