muse_code_sdk/msp/method/limits.rs
1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Serialize;
5
6/// The `session/start` `limits` choice: every member is optional — a start
7/// names only the axes it chooses, and an omitted axis reads the daemon
8/// default: the daemon's own posture on the sandbox axes, and on trust
9/// untrusted unless the daemon serves trusted by default. On a daemon whose
10/// default sandbox is off, turning the sandbox on takes both `sandboxEnabled:
11/// true` and `sandboxNetwork`; naming `sandboxEnabled: true` without
12/// `sandboxNetwork`, or a network restriction (`restricted` or `proxy-only`)
13/// without naming `sandboxEnabled`, is refused `-32602` (`data.reason:
14/// "tighterSandboxUnserved"`) until a tracked change settles how a session
15/// turns the sandbox on there; a network restriction beside an explicit
16/// `sandboxEnabled: false`, which never turns it on, is refused the same way
17/// while a tracked change is open, so drop the restriction. Where the ceiling
18/// allows the sandbox off over a sandbox-on default, a network restriction
19/// beside `sandboxEnabled: false` is admitted and restricts nothing: with the
20/// sandbox off the network is not sandboxed, so the session runs and reports
21/// `sandboxNetwork: "enabled"`. Reports use `SessionLimits`, whose members are
22/// always present. A `session/resume` names only `workspaceTrusted` here.
23#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
24#[serde(rename_all = "camelCase")]
25pub struct SessionLimitsChoice {
26 /// Shell filesystem/network sandboxing (`--disable-sandbox` absent).
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub sandbox_enabled: Option<bool>,
29 /// Sandbox network policy (`--sandbox-network` grammar).
30 #[serde(skip_serializing_if = "Option::is_none")]
31 pub sandbox_network: Option<LimitsNetworkMode>,
32 /// Non-shell workspace filesystem writes (`--disable-write` absent).
33 #[serde(skip_serializing_if = "Option::is_none")]
34 pub writes_enabled: Option<bool>,
35 /// Workspace shell execution (`--disable-shell` absent).
36 #[serde(skip_serializing_if = "Option::is_none")]
37 pub shell_enabled: Option<bool>,
38 /// Loading the workspace's skills and rules (`--trust-workspace`).
39 #[serde(skip_serializing_if = "Option::is_none")]
40 pub workspace_trusted: Option<bool>,
41}
42
43/// A five-axis limits report: every `maxLimits` / `currentLimits` member is
44/// this one definition, and every member is required — reporting always fills
45/// all five, so readers never see an absence.
46#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
47#[serde(rename_all = "camelCase")]
48#[non_exhaustive]
49pub struct SessionLimits {
50 /// Shell filesystem/network sandboxing (`--disable-sandbox` absent).
51 pub sandbox_enabled: bool,
52 /// Sandbox network policy (`--sandbox-network` grammar).
53 pub sandbox_network: LimitsNetworkMode,
54 /// Non-shell workspace filesystem writes (`--disable-write` absent).
55 pub writes_enabled: bool,
56 /// Workspace shell execution (`--disable-shell` absent).
57 pub shell_enabled: bool,
58 /// Loading the workspace's skills and rules (`--trust-workspace`).
59 pub workspace_trusted: bool,
60}
61
62impl SessionLimits {
63 /// The wire name of the sandbox-enabled axis (single source: this
64 /// struct's camelCase).
65 pub const SANDBOX_ENABLED_AXIS: &str = "sandboxEnabled";
66 /// The wire name of the sandbox-network axis (single source: this
67 /// struct's camelCase).
68 pub const SANDBOX_NETWORK_AXIS: &str = "sandboxNetwork";
69 /// The wire name of the writes axis (single source: this struct's
70 /// camelCase).
71 pub const WRITES_ENABLED_AXIS: &str = "writesEnabled";
72 /// The wire name of the shell axis (single source: this struct's
73 /// camelCase).
74 pub const SHELL_ENABLED_AXIS: &str = "shellEnabled";
75 /// The wire name of the trust axis, shared by the `-32028` axes and
76 /// the resume `tightenedAxes` (single source: this struct's camelCase).
77 pub const WORKSPACE_TRUSTED_AXIS: &str = "workspaceTrusted";
78}
79
80/// The sandbox-network axis values. **Closed**: a client selects one of the
81/// three serve spellings and can never construct another; the socket promise is
82/// same-version, so the result use needs no unknown arm.
83#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
84pub enum LimitsNetworkMode {
85 /// `restricted`: no network for sandboxed shells.
86 #[serde(rename = "restricted")]
87 Restricted,
88 /// `enabled`: full network for sandboxed shells — also what a sandbox-OFF
89 /// ceiling reports, so the plain per-axis compare needs no special case.
90 #[serde(rename = "enabled")]
91 Enabled,
92 /// `proxy-only`: the built-in default.
93 #[serde(rename = "proxy-only")]
94 ProxyOnly,
95}
96
97/// One too-wide axis in a `-32028 limitsAboveMax` refusal: every too-wide axis
98/// is listed, never the first only. `requested`/`max` carry the axis's own JSON
99/// values.
100#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
101#[serde(rename_all = "camelCase")]
102#[non_exhaustive]
103pub struct LimitsAboveMaxAxis {
104 /// The axis name (`workspaceTrusted`,...).
105 pub axis: String,
106 /// The requested value.
107 pub requested: LimitsAxisValue,
108 /// The ceiling value.
109 pub max: LimitsAxisValue,
110}
111
112/// One axis value in a limits refusal: a boolean on the four boolean axes, the
113/// mode string on `sandboxNetwork`. **Closed**: exactly the two shapes, never
114/// another — named in the governing rules closed untagged-union list
115/// (`CLOSED_WITHOUT_MARKER`), since the untagged shape carries no schema
116/// marker. Untagged so the wire carries the bare JSON value; untagged also
117/// keeps the shape the schema builder requires (a bare `serde_json::Value`
118/// renders no type and is rejected).
119#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum LimitsAxisValue {
122 /// A boolean-axis value.
123 Bool(bool),
124 /// A `sandboxNetwork`-axis value.
125 Mode(LimitsNetworkMode),
126}
127
128/// What caps the ceiling a `-32028 limitsAboveMax` refusal names: the kind of
129/// the ceiling, so a client can tell a ceiling a newer daemon start can raise
130/// from one managed policy fixes. **Closed**: exactly these two — a refusal's
131/// ceiling is either the daemon's own start posture or the widest managed
132/// policy allows, never a third source (the socket limits regime's ceiling
133/// computation has exactly these two arms).
134#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
135pub enum LimitsCeilingKind {
136 /// The ceiling is the daemon's own start posture: the daemon runs
137 /// without `--allow-session-posture`, so a choice wider than what it
138 /// started with is refused. A daemon started with the allowance may
139 /// admit wider, up to managed policy.
140 #[serde(rename = "daemonDefault")]
141 DaemonDefault,
142 /// The ceiling is the widest managed policy allows: the daemon runs with
143 /// `--allow-session-posture` and the refusal is the managed cap itself.
144 /// Restarting the daemon cannot raise it.
145 #[serde(rename = "managedPolicy")]
146 ManagedPolicy,
147}