Skip to main content

muse_code_sdk/msp/method/
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::method::session::EffectiveApprovalModeState;
5use crate::msp::method::turn::CommandStatus;
6use crate::msp::view::approval::ApprovalRequestParams;
7use crate::msp::view::state::ApprovalMode;
8use crate::msp::view::user_input::UserInputRequestParams;
9use serde::Deserialize;
10use serde::Serialize;
11
12mod catch_all;
13
14/// `approval/decide` params: the decision. A standard command — requires the
15/// session loaded on this host, requires `commandId`, durable intake before
16/// ack, value-identical replay.
17#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
18#[serde(rename_all = "camelCase")]
19pub struct ApprovalDecideParams {
20    /// The target session.
21    pub session_id: String,
22    /// The idempotency handle (UUIDv7).
23    pub command_id: String,
24    /// The approval being decided.
25    pub approval_id: String,
26    /// Must equal the approval's `currentRequirementId`. The multi-stage race
27    /// guard: a decision aimed at stage 1 can never accidentally satisfy stage
28    /// 2, and a stale value is -32053.
29    pub requirement_id: ApprovalRequirementRef,
30    /// One of the current `availableChoices`; else -32052.
31    pub choice_id: String,
32    /// Free-text guidance delivered to the model with the denial. Only valid on
33    /// choices with `acceptsFeedback`. Never persisted in the durable audit
34    /// record (live steer only), so it is absent from `approval/resolved`.
35    /// Omitted and explicit `null` both mean "no feedback".
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub feedback: Option<String>,
38}
39
40/// `approval/decide` result. Admission-ack rules still apply: the authoritative
41/// outcome is `approval/resolved` / `approval/updated` on the view stream.
42#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
43#[serde(rename_all = "camelCase")]
44#[non_exhaustive]
45pub struct ApprovalDecideResult {
46    /// Echoes the client's id.
47    pub command_id: String,
48    /// Admission status.
49    pub status: CommandStatus,
50    /// The approval this decision was applied to.
51    pub approval_id: String,
52    /// `false` when the choice satisfied a stage but further requirements
53    /// remain (the approval stays pending and an updated `approval/request`
54    /// follows); `true` when this decision produced the terminal
55    /// `DecisionApplied`.
56    pub terminal: bool,
57}
58
59/// `approval/listPending` params: the pull dual of the re-issued requests. A
60/// log-fold read — no lease, works on loaded and unloaded sessions, never
61/// subscribes.
62#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
63#[serde(rename_all = "camelCase")]
64pub struct ApprovalListPendingParams {
65    /// The session to read.
66    pub session_id: String,
67}
68
69/// `approval/listPending` result. Ordering is by opening `viewCursor`; empty
70/// arrays when nothing is pending. The result is point-in-time — to act on it
71/// race-safely, `approval/decide` carries the `requirementId` guard regardless
72/// of how the client learned the state.
73#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
74#[serde(rename_all = "camelCase")]
75#[non_exhaustive]
76pub struct ApprovalListPendingResult {
77    /// Exactly the `approval/request` params, one per pending approval.
78    pub approvals: Vec<ApprovalRequestParams>,
79    /// Exactly the `userInput/request` params, one per pending prompt.
80    pub user_inputs: Vec<UserInputRequestParams>,
81}
82
83/// `session/setApprovalMode` params: switch the session's approval enforcement
84/// mode mid-session. A standard command.
85///
86/// **Select, never create.** A client may *select* a mode the host's
87/// configuration already defines; it may not construct one, supply inline
88/// rules, or otherwise describe a policy on the wire — which is why
89/// [`ApprovalMode`] is closed.
90#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
91#[serde(rename_all = "camelCase")]
92pub struct SessionSetApprovalModeParams {
93    /// The target session.
94    pub session_id: String,
95    /// The idempotency handle (UUIDv7).
96    pub command_id: String,
97    /// The preconfigured mode to select. The requesting actor is recorded from
98    /// the connection's `clientInfo.name`.
99    pub mode: ApprovalMode,
100}
101
102/// Whether a mode change did anything, mirroring
103/// `ApprovalReconfigureApplyOutcome`. Apply failures are `commandRejected`.
104#[derive(Debug, Clone, PartialEq, Eq)]
105#[non_exhaustive]
106pub enum ApprovalModeApplyOutcome {
107    /// The mode changed.
108    Completed,
109    /// Already in that mode; a success that writes no relaxation audit fact.
110    Noop,
111    /// A value from a newer host, kept verbatim so an older client decodes the
112    /// rest of the message. Never construct it with a known word.
113    Unknown(String),
114}
115
116/// `session/setApprovalMode` result. Applies next-action — an in-flight tool
117/// action's pending approval is not retroactively decided by a mode change.
118#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
119#[serde(rename_all = "camelCase")]
120#[non_exhaustive]
121pub struct SessionSetApprovalModeResult {
122    /// Echoes the client's id.
123    pub command_id: String,
124    /// Admission status.
125    pub status: CommandStatus,
126    /// Whether the change did anything.
127    pub apply_outcome: ApprovalModeApplyOutcome,
128    /// The folded effective-mode projection — the same object the `Session`
129    /// carries as `approvalMode`.
130    pub effective_mode: EffectiveApprovalModeState,
131}
132
133/// One client-supplied shell prefix allow-rule: argv tokens in the
134/// `ShellPrefixSuggestion.argv_prefix` shape. An object, not a bare array, so
135/// the element can grow additively later.
136#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
137#[serde(rename_all = "camelCase")]
138pub struct ClientApprovalRule {
139    /// The argv-token prefix. Must be non-empty with no empty token; banned
140    /// prefixes refuse the carrying call.
141    pub argv_prefix: Vec<String>,
142}
143
144/// Where a session policy rule came from.
145#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
146#[serde(rename_all = "camelCase")]
147pub enum PolicyRuleOrigin {
148    /// Supplied by the client over MSP (`approvalRules` / set command).
149    Client,
150    /// Minted from a server-offered `approval/decide` choice.
151    Server,
152}
153
154/// One listed client-supplied rule in `EffectivePermissionState`: the prefix
155/// plus its origin.
156#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
157#[serde(rename_all = "camelCase")]
158#[non_exhaustive]
159pub struct ClientApprovalRuleState {
160    /// The argv-token prefix.
161    pub argv_prefix: Vec<String>,
162    /// Always `client` on this surface; carried so the listing stays
163    /// attributable if it ever merges families.
164    pub origin: PolicyRuleOrigin,
165}