Skip to main content

muse_code_sdk/msp/view/
approval.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::error::ApprovalRequirementRef;
4use crate::msp::view::SourceRange;
5pub use decision::ApprovalAmendment;
6pub use decision::ApprovalAmendmentDurability;
7pub use decision::ApprovalChange;
8pub use decision::ApprovalChoice;
9pub use decision::ApprovalChoiceScope;
10pub use decision::ApprovalDecision;
11pub use decision::ApprovalPersistenceStatus;
12pub use decision::ApprovalPolicyResult;
13pub use decision::ApprovalResolvedBy;
14pub use decision::ApprovalStageEvidence;
15use serde::Deserialize;
16use serde::Serialize;
17
18pub(crate) mod decision;
19
20/// Full params shared by `approval/request` and `approval/requested`.
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
22#[serde(rename_all = "camelCase")]
23#[non_exhaustive]
24pub struct ApprovalRequestParams {
25    pub session_id: String,
26    pub approval_id: String,
27    pub turn_id: String,
28    pub task_id: String,
29    pub item_id: String,
30    pub tool_call_id: String,
31    pub tool_name: String,
32    pub raw_args: String,
33    pub view_cursor: String,
34    pub source_range: SourceRange,
35    pub subject: ApprovalSubject,
36    pub current_requirement_id: ApprovalRequirementRef,
37    pub available_choices: Vec<ApprovalChoice>,
38    pub protected_write: bool,
39    pub judge_escalated: bool,
40    /// Present only for a child (native subagent) approval projected onto the
41    /// parent session's plane; parent-own approvals omit it.
42    #[serde(default, skip_serializing_if = "Option::is_none")]
43    pub subagent_origin: Option<ApprovalSubagentOrigin>,
44}
45
46/// `approval/updated` params: the refreshed pending view plus one change.
47#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
48#[serde(rename_all = "camelCase")]
49#[non_exhaustive]
50pub struct ApprovalUpdatedParams {
51    pub session_id: String,
52    pub view_cursor: String,
53    pub source_range: SourceRange,
54    pub approval_id: String,
55    pub current_requirement_id: ApprovalRequirementRef,
56    pub subject: ApprovalSubject,
57    pub available_choices: Vec<ApprovalChoice>,
58    pub change: ApprovalChange,
59    /// Present only for a child (native subagent) approval projected onto the
60    /// parent session's plane; parent-own approvals omit it.
61    #[serde(default, skip_serializing_if = "Option::is_none")]
62    pub subagent_origin: Option<ApprovalSubagentOrigin>,
63}
64
65/// `approval/resolved` params: the first durable terminal decision.
66#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
67#[serde(rename_all = "camelCase")]
68#[non_exhaustive]
69pub struct ApprovalResolvedParams {
70    pub session_id: String,
71    pub view_cursor: String,
72    pub source_range: SourceRange,
73    pub approval_id: String,
74    pub item_id: String,
75    pub turn_id: String,
76    pub decision: ApprovalDecision,
77    pub policy_result: ApprovalPolicyResult,
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub amendment: Option<ApprovalAmendment>,
80    pub resolved_by: ApprovalResolvedBy,
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub decided_by_command_id: Option<String>,
83    /// The decision time as RFC3339, projected from the durable
84    /// `DecisionApplied` record's own stamp: optional on the wire so decoders
85    /// tolerate its absence, always populated by current hosts.
86    #[serde(default, skip_serializing_if = "Option::is_none")]
87    pub decided_at: Option<String>,
88    pub stage_evidence: Vec<ApprovalStageEvidence>,
89    /// Present only for a child (native subagent) approval projected onto the
90    /// parent session's plane; parent-own approvals omit it.
91    #[serde(default, skip_serializing_if = "Option::is_none")]
92    pub subagent_origin: Option<ApprovalSubagentOrigin>,
93}
94
95/// Child (native subagent) provenance for an approval projected onto the PARENT
96/// session's approval plane: identifies the originating child run/agent so a
97/// client can attribute the prompt. Omitted (`skip_serializing_if`) on the
98/// parent's own approvals, so pre-existing parent frames stay byte-identical.
99#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
100#[serde(rename_all = "camelCase")]
101#[non_exhaustive]
102pub struct ApprovalSubagentOrigin {
103    /// The originating child's subagent id, from the parent session's
104    /// durable subagent control records.
105    pub subagent_id: String,
106    /// The child session stream id whose records carry this approval.
107    pub child_session_id: String,
108    /// The child run that parked on this approval.
109    pub child_run_id: String,
110}
111
112/// Open approval subject union. Unknown kinds are rendered generically and
113/// never auto-approved by clients.
114#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
115#[serde(rename_all = "camelCase")]
116#[non_exhaustive]
117pub struct ApprovalSubject {
118    /// Open discriminator: `shell | fileAccess | network | unixSocket | process | tool`.
119    pub kind: String,
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub command: Option<String>,
122    #[serde(skip_serializing_if = "Option::is_none")]
123    pub workspace_root: Option<String>,
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub stages: Option<Vec<ApprovalStage>>,
126    #[serde(skip_serializing_if = "Option::is_none")]
127    pub tool_name: Option<String>,
128    #[serde(skip_serializing_if = "Option::is_none")]
129    pub path: Option<String>,
130    #[serde(skip_serializing_if = "Option::is_none")]
131    pub access: Option<String>,
132    #[serde(skip_serializing_if = "Option::is_none")]
133    pub host: Option<String>,
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub port: Option<u16>,
136    #[serde(skip_serializing_if = "Option::is_none")]
137    pub protocol: Option<String>,
138    #[serde(skip_serializing_if = "Option::is_none")]
139    pub target: Option<String>,
140    #[serde(skip_serializing_if = "Option::is_none")]
141    pub origin: Option<ApprovalOrigin>,
142}
143
144/// The `ApprovalSubject.kind` wire words — one source for the session-view fold
145/// that writes them and every client that inverts them.
146impl ApprovalSubject {
147    pub const KIND_SHELL: &'static str = "shell";
148    pub const KIND_FILE_ACCESS: &'static str = "fileAccess";
149    pub const KIND_NETWORK: &'static str = "network";
150    pub const KIND_UNIX_SOCKET: &'static str = "unixSocket";
151    pub const KIND_PROCESS: &'static str = "process";
152    pub const KIND_TOOL: &'static str = "tool";
153    /// `access` wire words (`fileAccess` reads/writes; `process` control).
154    pub const ACCESS_READ: &'static str = "read";
155    pub const ACCESS_WRITE: &'static str = "write";
156    pub const ACCESS_CONTROL: &'static str = "control";
157}
158
159#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
160#[serde(rename_all = "camelCase")]
161#[non_exhaustive]
162pub struct ApprovalOrigin {
163    pub kind: String,
164    #[serde(skip_serializing_if = "Option::is_none")]
165    pub command: Option<String>,
166    #[serde(skip_serializing_if = "Option::is_none")]
167    pub url: Option<String>,
168}
169
170#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
171#[serde(rename_all = "camelCase")]
172#[non_exhaustive]
173pub struct ApprovalStage {
174    pub requirement_id: ApprovalRequirementRef,
175    pub position: usize,
176    pub total_stages: usize,
177    pub argv: Vec<String>,
178    pub argv_complete: bool,
179    pub resolution: ApprovalStageResolution,
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub suggested_prefix: Option<ApprovalSuggestedPrefix>,
182}
183
184/// The `ApprovalOrigin.kind` wire words (same single-source rule).
185impl ApprovalOrigin {
186    pub const KIND_SHELL_COMMAND: &'static str = "shellCommand";
187    pub const KIND_URL: &'static str = "url";
188}
189
190#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
191#[serde(rename_all = "camelCase")]
192#[non_exhaustive]
193pub struct ApprovalStageResolution {
194    pub kind: String,
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub diagnostic: Option<String>,
197    #[serde(skip_serializing_if = "Option::is_none")]
198    pub argv_prefix: Option<Vec<String>>,
199}
200
201/// The `ApprovalStageResolution.kind` wire words (same single-source rule).
202impl ApprovalStageResolution {
203    pub const KIND_UNRESOLVED: &'static str = "unresolved";
204    pub const KIND_KNOWN_SAFE: &'static str = "knownSafe";
205    pub const KIND_POLICY_ALLOW: &'static str = "policyAllow";
206    pub const KIND_ALLOW_ONCE: &'static str = "allowOnce";
207    pub const KIND_POLICY_AMENDMENT: &'static str = "policyAmendment";
208}
209
210#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
211#[serde(rename_all = "camelCase")]
212#[non_exhaustive]
213pub struct ApprovalSuggestedPrefix {
214    pub argv_prefix: Vec<String>,
215    pub label: String,
216}