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 of the protocol spec, one per
78    /// pending approval.
79    pub approvals: Vec<ApprovalRequestParams>,
80    /// Exactly the `userInput/request` params of the protocol spec, one per
81    /// pending prompt.
82    pub user_inputs: Vec<UserInputRequestParams>,
83}
84
85/// `session/setApprovalMode` params: switch the session's approval enforcement
86/// mode mid-session. A standard command.
87///
88/// **Select, never create.** A client may *select* a mode the host's
89/// configuration already defines; it may not construct one, supply inline
90/// rules, or otherwise describe a policy on the wire — which is why
91/// [`ApprovalMode`] is closed.
92#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
93#[serde(rename_all = "camelCase")]
94pub struct SessionSetApprovalModeParams {
95    /// The target session.
96    pub session_id: String,
97    /// The idempotency handle (UUIDv7).
98    pub command_id: String,
99    /// The preconfigured mode to select. The requesting actor is recorded from
100    /// the connection's `clientInfo.name`.
101    pub mode: ApprovalMode,
102}
103
104/// Whether a mode change did anything, mirroring
105/// `ApprovalReconfigureApplyOutcome`. Apply failures are `commandRejected`.
106#[derive(Debug, Clone, PartialEq, Eq)]
107#[non_exhaustive]
108pub enum ApprovalModeApplyOutcome {
109    /// The mode changed.
110    Completed,
111    /// Already in that mode; a success that writes no relaxation audit fact.
112    Noop,
113    /// A value from a newer host, kept verbatim so an older client decodes the
114    /// rest of the message. Never construct it with a known word.
115    Unknown(String),
116}
117
118/// `session/setApprovalMode` result. Applies next-action — an in-flight tool
119/// action's pending approval is not retroactively decided by a mode change.
120#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
121#[serde(rename_all = "camelCase")]
122#[non_exhaustive]
123pub struct SessionSetApprovalModeResult {
124    /// Echoes the client's id.
125    pub command_id: String,
126    /// Admission status.
127    pub status: CommandStatus,
128    /// Whether the change did anything.
129    pub apply_outcome: ApprovalModeApplyOutcome,
130    /// The folded effective-mode projection — the same object the `Session`
131    /// carries as `approvalMode`.
132    pub effective_mode: EffectiveApprovalModeState,
133}