muse-code-sdk 1.4.24

Async Rust client for Muse Code over MSP
Documentation
// @generated from the MSP stable schema and protocol sources; do not edit by hand.

use serde::Deserialize;
use serde::Serialize;

/// The `session/start` `limits` choice: every member is optional — a start
/// names only the axes it chooses, and an omitted axis reads the daemon
/// default: the daemon's own posture on the sandbox axes, and on trust
/// untrusted unless the daemon serves trusted by default. On a daemon whose
/// default sandbox is off, turning the sandbox on takes both `sandboxEnabled:
/// true` and `sandboxNetwork`; naming `sandboxEnabled: true` without
/// `sandboxNetwork`, or a network restriction (`restricted` or `proxy-only`)
/// without naming `sandboxEnabled`, is refused `-32602` (`data.reason:
/// "tighterSandboxUnserved"`) until a tracked change settles how a session
/// turns the sandbox on there; a network restriction beside an explicit
/// `sandboxEnabled: false`, which never turns it on, is refused the same way
/// while a tracked change is open, so drop the restriction. Where the ceiling
/// allows the sandbox off over a sandbox-on default, a network restriction
/// beside `sandboxEnabled: false` is admitted and restricts nothing: with the
/// sandbox off the network is not sandboxed, so the session runs and reports
/// `sandboxNetwork: "enabled"`. Reports use `SessionLimits`, whose members are
/// always present. A `session/resume` names only `workspaceTrusted` here.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionLimitsChoice {
    /// Shell filesystem/network sandboxing (`--disable-sandbox` absent).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sandbox_enabled: Option<bool>,
    /// Sandbox network policy (`--sandbox-network` grammar).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sandbox_network: Option<LimitsNetworkMode>,
    /// Non-shell workspace filesystem writes (`--disable-write` absent).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub writes_enabled: Option<bool>,
    /// Workspace shell execution (`--disable-shell` absent).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shell_enabled: Option<bool>,
    /// Loading the workspace's skills and rules (`--trust-workspace`).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub workspace_trusted: Option<bool>,
}

/// A five-axis limits report: every `maxLimits` / `currentLimits` member is
/// this one definition, and every member is required — reporting always fills
/// all five, so readers never see an absence.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct SessionLimits {
    /// Shell filesystem/network sandboxing (`--disable-sandbox` absent).
    pub sandbox_enabled: bool,
    /// Sandbox network policy (`--sandbox-network` grammar).
    pub sandbox_network: LimitsNetworkMode,
    /// Non-shell workspace filesystem writes (`--disable-write` absent).
    pub writes_enabled: bool,
    /// Workspace shell execution (`--disable-shell` absent).
    pub shell_enabled: bool,
    /// Loading the workspace's skills and rules (`--trust-workspace`).
    pub workspace_trusted: bool,
}

impl SessionLimits {
    /// The wire name of the sandbox-enabled axis (single source: this
    /// struct's camelCase).
    pub const SANDBOX_ENABLED_AXIS: &str = "sandboxEnabled";
    /// The wire name of the sandbox-network axis (single source: this
    /// struct's camelCase).
    pub const SANDBOX_NETWORK_AXIS: &str = "sandboxNetwork";
    /// The wire name of the writes axis (single source: this struct's
    /// camelCase).
    pub const WRITES_ENABLED_AXIS: &str = "writesEnabled";
    /// The wire name of the shell axis (single source: this struct's
    /// camelCase).
    pub const SHELL_ENABLED_AXIS: &str = "shellEnabled";
    /// The wire name of the trust axis, shared by the `-32028` axes and
    /// the resume `tightenedAxes` (single source: this struct's camelCase).
    pub const WORKSPACE_TRUSTED_AXIS: &str = "workspaceTrusted";
}

/// The sandbox-network axis values. **Closed**: a client selects one of the
/// three serve spellings and can never construct another; the socket promise is
/// same-version, so the result use needs no unknown arm.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum LimitsNetworkMode {
    /// `restricted`: no network for sandboxed shells.
    #[serde(rename = "restricted")]
    Restricted,
    /// `enabled`: full network for sandboxed shells — also what a sandbox-OFF
    /// ceiling reports, so the plain per-axis compare needs no special case.
    #[serde(rename = "enabled")]
    Enabled,
    /// `proxy-only`: the built-in default.
    #[serde(rename = "proxy-only")]
    ProxyOnly,
}

/// One too-wide axis in a `-32028 limitsAboveMax` refusal: every too-wide axis
/// is listed, never the first only. `requested`/`max` carry the axis's own JSON
/// values.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct LimitsAboveMaxAxis {
    /// The axis name (`workspaceTrusted`,...).
    pub axis: String,
    /// The requested value.
    pub requested: LimitsAxisValue,
    /// The ceiling value.
    pub max: LimitsAxisValue,
}

/// One axis value in a limits refusal: a boolean on the four boolean axes, the
/// mode string on `sandboxNetwork`. **Closed**: exactly the two shapes, never
/// another — named in the governing rules closed untagged-union list
/// (`CLOSED_WITHOUT_MARKER`), since the untagged shape carries no schema
/// marker. Untagged so the wire carries the bare JSON value; untagged also
/// keeps the shape the schema builder requires (a bare `serde_json::Value`
/// renders no type and is rejected).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LimitsAxisValue {
    /// A boolean-axis value.
    Bool(bool),
    /// A `sandboxNetwork`-axis value.
    Mode(LimitsNetworkMode),
}

/// What caps the ceiling a `-32028 limitsAboveMax` refusal names: the kind of
/// the ceiling, so a client can tell a ceiling a newer daemon start can raise
/// from one managed policy fixes. **Closed**: exactly these two — a refusal's
/// ceiling is either the daemon's own start posture or the widest managed
/// policy allows, never a third source (the socket limits regime's ceiling
/// computation has exactly these two arms).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum LimitsCeilingKind {
    /// The ceiling is the daemon's own start posture: the daemon runs
    /// without `--allow-session-posture`, so a choice wider than what it
    /// started with is refused. A daemon started with the allowance may
    /// admit wider, up to managed policy.
    #[serde(rename = "daemonDefault")]
    DaemonDefault,
    /// The ceiling is the widest managed policy allows: the daemon runs with
    /// `--allow-session-posture` and the refusal is the managed cap itself.
    /// Restarting the daemon cannot raise it.
    #[serde(rename = "managedPolicy")]
    ManagedPolicy,
}