SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
MCP: --param-check checks calls to the running app (#9072) (#9073)
Rick Morgans4a781b8cd82e
diff --git a/apps/solidcraft-cli/src/main.rs b/apps/solidcraft-cli/src/main.rsindex 77d93ed902..b210b63a9e 100644--- a/apps/solidcraft-cli/src/main.rs+++ b/apps/solidcraft-cli/src/main.rs@@ -720,11 +720,8 @@ fn cmd_mcp(args: &[String]) -> Result<(), String> {eprintln!("solidcraft mcp: the design's folder is left out because {why}; add it with --allow-path if you mean it");}}- // How a headless session treats calls that break a command's parameter contract.+ // How calls that break a command's parameter contract are treated, headless or bridged.let param_check = parse_param_check("mcp", args)?;- if param_check != solidcraft_engine::schema::ParamCheck::Off && flag(args, "--connect").is_some() {- eprintln!("solidcraft mcp: --param-check applies to headless sessions; calls to the app are not checked yet");- }let backend: Box<dyn solidcraft_mcp::Backend> = match (flag(args, "--connect"), flag(args, "--in")) {(Some(_), Some(_)) => return Err("mcp: use either --connect or --in, not both".into()),(Some(addr), None) => {@@ -732,7 +729,7 @@ fn cmd_mcp(args: &[String]) -> Result<(), String> {return Err(format!("mcp: --connect wants HOST:PORT, such as 127.0.0.1:7878, not `{addr}`"));};// Serve without the app too: the tools connect once it runs, and say it isn't until then.- let mut remote = solidcraft_mcp::Remote::new(addr, flag(args, "--token"));+ let mut remote = solidcraft_mcp::Remote::new(addr, flag(args, "--token")).with_param_check(param_check);if let Err(e) = remote.try_connect() {eprintln!("solidcraft mcp: no SolidCraft app at {addr} yet ({e}); start it with `solidcraft --control {port}` \@@ -752,7 +749,8 @@ fn cmd_mcp(args: &[String]) -> Result<(), String> {let auto = !args.iter().any(|a| a == "--headless");if auto && let Some(port) = discover_app() {eprintln!("solidcraft mcp: bridged to the running app at 127.0.0.1:{port} (--headless starts a session of its own)");- return serve_mcp(Box::new(solidcraft_mcp::Remote::new(&format!("127.0.0.1:{port}"), flag(args, "--token"))), scope);+ let remote = solidcraft_mcp::Remote::new(&format!("127.0.0.1:{port}"), flag(args, "--token")).with_param_check(param_check);+ return serve_mcp(Box::new(remote), scope);}let mut headless = solidcraft_mcp::Headless::default();headless.session.param_check = param_check;diff --git a/crates/engine/src/batch_preflight.rs b/crates/engine/src/batch_preflight.rsindex b3b8802ad8..188f87cf52 100644--- a/crates/engine/src/batch_preflight.rs+++ b/crates/engine/src/batch_preflight.rs@@ -19,7 +19,7 @@use serde_json::{Value, json};use crate::schema::ParamCheck;-use crate::{EngineError, find_command};+use crate::{CommandSpec, EngineError, find_command};/// The first step a batch would refuse at its turn.#[derive(Clone, Debug, PartialEq)]@@ -61,15 +61,31 @@ pub fn check(steps: &[Value], level: ParamCheck, host: &[&str]) -> Option<Refusareturn Some(Refusal { index, command: Some(id.to_string()), error: EngineError::UnknownCommand(id.to_string()).to_string() });};if level == ParamCheck::Strict- && let Some(contract) = spec.contract- && let Some(first) = contract.check(step.get("params").unwrap_or(&Value::Null)).into_iter().next()+ && let Some(refusal) = contract_refusal(index, id, spec, step){- return Some(Refusal { index, command: Some(id.to_string()), error: crate::params::bad(id, first.message).to_string() });+ return Some(refusal);}}None}+/// The first of `steps` whose parameters break its command's typed contract, for a runner in+/// another process that checks the rest itself (the MCP server bridged to an app at+/// [`ParamCheck::Strict`]): a step naming no command, or one this registry lacks (the app may be+/// another version), is left to it.+pub fn contracts(steps: &[Value]) -> Option<Refusal> {+ steps.iter().enumerate().find_map(|(index, step)| {+ let id = step.get("command").or_else(|| step.get("id")).and_then(Value::as_str)?;+ contract_refusal(index, id, find_command(id)?, step)+ })+}++/// Step `index`'s refusal when its parameters break `spec`'s typed contract.+fn contract_refusal(index: usize, id: &str, spec: &CommandSpec, step: &Value) -> Option<Refusal> {+ let first = spec.contract?.check(step.get("params").unwrap_or(&Value::Null)).into_iter().next()?;+ Some(Refusal { index, command: Some(id.to_string()), error: crate::params::bad(id, first.message).to_string() })+}+#[cfg(test)]mod tests {use super::*;@@ -130,5 +146,9 @@ mod tests {let mut s = crate::Session { param_check: ParamCheck::Strict, ..crate::Session::default() };let at_turn = s.execute("solid.box", &steps[1]["params"]).unwrap_err().to_string();assert_eq!(r.error, at_turn);+ // Another process's runner gets the same refusal, and keeps what it checks itself.+ assert_eq!(contracts(&steps), Some(r));+ let theirs = vec![json!({"params": {}}), step("app.only", json!({"x": 1})), step("view.pick", json!({}))];+ assert_eq!(contracts(&theirs), None);}}diff --git a/crates/mcp/src/backend.rs b/crates/mcp/src/backend.rsindex cfc459e9f6..4bc2fcd1a3 100644--- a/crates/mcp/src/backend.rs+++ b/crates/mcp/src/backend.rs@@ -8,6 +8,7 @@ use serde_json::{Value, json};use solidcraft_engine::Session;use solidcraft_engine::control_pending;use solidcraft_engine::render::StandardView;+use solidcraft_engine::schema::ParamCheck;use solidcraft_engine::view::Guides;/// Something that answers control-channel methods: `engine.execute`, `engine.commands`,@@ -33,10 +34,10 @@ pub trait Backend {fn notice(&self) -> Option<String> {None}- /// How this side's session checks commands' typed contracts (`--param-check`), when this- /// process holds it. A running app checks its own (`engine.batch`), so `Remote` says off.- fn param_check(&self) -> solidcraft_engine::schema::ParamCheck {- solidcraft_engine::schema::ParamCheck::Off+ /// How calls are checked against their commands' typed contracts (`--param-check`): by the+ /// headless session, or by `Remote` before it sends them to the app.+ fn param_check(&self) -> ParamCheck {+ ParamCheck::Off}}@@ -135,6 +136,8 @@ pub struct Remote {/// An outstanding request's end, once a later call waited for it (for `pending`).settled: Option<Settled>,waits: Waits,+ /// How calls are checked before they are sent (`--param-check`).+ param_check: ParamCheck,}/// How a tool error starts when no app listens at the bridged address. The agent reads it, and@@ -160,7 +163,17 @@ impl Remote {pub fn new(addr: &str, token: Option<&str>) -> Self {let port = addr.rsplit(':').next().and_then(|p| p.parse::<u16>().ok()).unwrap_or(0);let explicit_token = token.map(str::to_string);- Self { addr: addr.to_string(), port, conn: None, next_id: 1, explicit_token, outstanding: None, settled: None, waits: WAITS }+ Self {+ addr: addr.to_string(),+ port,+ conn: None,+ next_id: 1,+ explicit_token,+ outstanding: None,+ settled: None,+ waits: WAITS,+ param_check: ParamCheck::Off,+ }}/// Shorter waits for requests still running (tests).@@ -444,12 +457,85 @@ impl Remote {}}+/// The issues `params` raise against the typed contract of `id` in this server's registry; none+/// when it has no contract for `id` (the app may have commands this server lacks).+fn contract_issues(id: &str, params: &Value) -> Vec<String> {+ let contract = solidcraft_engine::find_command(id).and_then(|c| c.contract);+ contract.map(|c| c.check(params).into_iter().map(|i| i.message).collect()).unwrap_or_default()+}++/// `reply` with `issues` as its `param_warnings`, as a headless session at the warn level adds+/// them; a reply that has its own (an app that checked the call itself) keeps those.+fn with_param_warnings(mut reply: Value, issues: Vec<String>) -> Value {+ if !issues.is_empty()+ && let Some(o) = reply.as_object_mut()+ {+ o.entry("param_warnings").or_insert_with(|| json!(issues));+ }+ reply+}++impl Remote {+ /// Check calls against their commands' contracts at `level` before sending them+ /// (`--param-check`): the app's own session checks nothing.+ pub fn with_param_check(mut self, level: ParamCheck) -> Self {+ self.param_check = level;+ self+ }++ /// `engine.execute` checked here: `strict` refuses a call that breaks its command's contract+ /// without sending it, and `warn` sends it and adds the issues to the app's reply.+ fn execute_checked(&mut self, params: Value) -> Result<Value, String> {+ let id = params.get("command").and_then(Value::as_str).unwrap_or_default();+ let issues = contract_issues(id, params.get("params").unwrap_or(&Value::Null));+ if self.param_check == ParamCheck::Strict+ && let Some(first) = issues.first()+ {+ return Err(solidcraft_engine::params::bad(id, first.as_str()).to_string());+ }+ let reply = self.call_once("engine.execute", params, true)?;+ Ok(with_param_warnings(reply, issues))+ }++ /// `engine.batch` checked here: `strict` refuses a batch with a step that breaks its command's+ /// contract before anything is sent, as the app would refuse it unrun, and `warn` adds each+ /// step's issues to its result.+ fn batch_checked(&mut self, params: Value) -> Result<Value, String> {+ let steps = params.get("commands").and_then(Value::as_array).map(Vec::as_slice).unwrap_or_default();+ if self.param_check == ParamCheck::Strict {+ if let Some(refusal) = solidcraft_engine::batch_preflight::contracts(steps) {+ return Ok(refusal.reply(steps.len()));+ }+ return self.call_once("engine.batch", params, true);+ }+ let issues: Vec<Vec<String>> = steps+ .iter()+ .map(|step| {+ let id = step.get("command").or_else(|| step.get("id")).and_then(Value::as_str).unwrap_or_default();+ contract_issues(id, step.get("params").unwrap_or(&Value::Null))+ })+ .collect();+ let mut reply = self.call_once("engine.batch", params, true)?;+ if let Some(results) = reply.get_mut("results").and_then(Value::as_array_mut) {+ for (result, issues) in results.iter_mut().zip(issues) {+ *result = with_param_warnings(std::mem::take(result), issues);+ }+ }+ Ok(reply)+ }+}+impl Backend for Remote {fn call(&mut self, method: &str, params: Value) -> Result<Value, String> {- if method == "control.pending" {- return self.pending_status();+ match method {+ "control.pending" => self.pending_status(),+ "engine.execute" if self.param_check != ParamCheck::Off => self.execute_checked(params),+ "engine.batch" if self.param_check != ParamCheck::Off => self.batch_checked(params),+ _ => self.call_once(method, params, true),}- self.call_once(method, params, true)+ }+ fn param_check(&self) -> ParamCheck {+ self.param_check}fn has_ui(&self) -> bool {true@@ -576,7 +662,7 @@ impl Backend for Headless {fn in_process(&self) -> bool {true}- fn param_check(&self) -> solidcraft_engine::schema::ParamCheck {+ fn param_check(&self) -> ParamCheck {self.session.param_check}}@@ -605,7 +691,8 @@ impl Auto {}if let Some(port) = (self.discover)() {eprintln!("solidcraft mcp: the SolidCraft app is running now; bridged to 127.0.0.1:{port}");- self.remote = Some(Remote::new(&format!("127.0.0.1:{port}"), self.token.as_deref()));+ let level = self.param_check();+ self.remote = Some(Remote::new(&format!("127.0.0.1:{port}"), self.token.as_deref()).with_param_check(level));self.headless = None;}}@@ -642,10 +729,11 @@ impl Backend for Auto {fn in_process(&self) -> bool {self.remote.is_none()}- fn param_check(&self) -> solidcraft_engine::schema::ParamCheck {+ fn param_check(&self) -> ParamCheck {match (&self.remote, &self.headless) {+ (Some(r), _) => r.param_check(),(None, Some(h)) => h.param_check(),- _ => solidcraft_engine::schema::ParamCheck::Off,+ (None, None) => ParamCheck::Off,}}fn notice(&self) -> Option<String> {diff --git a/crates/mcp/src/tests.rs b/crates/mcp/src/tests.rsindex db89875ebb..a9883270cd 100644--- a/crates/mcp/src/tests.rs+++ b/crates/mcp/src/tests.rs@@ -2322,6 +2322,58 @@ fn describe_command_and_strict_parameter_checking() {assert_eq!(m["body_count"], json!(0), "{m}");}+/// Bridged to an app (#9072), the server checks each call against its command's contract before+/// sending it, as a headless session does: the app's own session checks nothing. `strict` sends+/// nothing that breaks a contract, `warn` adds `param_warnings` to the app's reply, and a command+/// this server has no contract for goes to the app unchecked.+#[test]+fn a_bridged_server_checks_calls_at_its_param_check_level() {+ use solidcraft_engine::schema::ParamCheck;+ let (addr, seen) = scripted_app(|req| match req["method"].as_str() {+ Some("engine.batch") => {+ let n = req["params"]["commands"].as_array().map_or(0, Vec::len);+ json!({"ok": true, "result": {"completed": n, "results": vec![json!({}); n], "undone": 0}})+ }+ _ => json!({"ok": true, "result": {"created_bodies": ["Box1"]}}),+ });+ let bridged = |level| {+ let remote = crate::Remote::connect_with_token(&addr, Some("0123456789abcdef0123456789abcdef")).unwrap().with_param_check(level);+ Server::new(Box::new(remote))+ };+ let sent = |what: &str| seen.lock().unwrap().1.iter().filter(|w| w.as_str() == what).count();+ let text = |r: &Value| r["result"]["content"][0]["text"].as_str().unwrap_or_default().to_string();+ let misspelt = json!({"command": "solid.box", "params": {"length": 5, "width": 5, "height": 5, "operaton": "cut"}});+ let good = json!({"command": "solid.box", "params": {"length": 5, "width": 5, "height": 5}});+ let warning = "unknown key `operaton`; did you mean `operation`?";++ let mut s = bridged(ParamCheck::Strict);+ let r = raw_tool(&mut s, "execute", misspelt.clone());+ assert_eq!(r["result"]["isError"], json!(true), "{r}");+ assert!(text(&r).contains(&format!("invalid parameters for `solid.box`: {warning}")), "{r}");+ assert_eq!(sent("engine.execute solid.box"), 0, "refused unsent");+ let r = raw_tool(&mut s, "execute", json!({"command": "solid.fillet", "params": {"nonsense": 1}}));+ assert_ne!(r["result"]["isError"], json!(true), "{r}");+ assert_eq!(sent("engine.execute solid.fillet"), 1, "no contract here: the app decides");+ let r = raw_tool(&mut s, "batch", json!({"commands": [good, misspelt]}));+ assert_eq!(r["result"]["isError"], json!(true), "{r}");+ let reply: Value = serde_json::from_str(&text(&r)).unwrap();+ assert_eq!((&reply["failed"]["index"], &reply["completed"], &reply["not_run"]), (&json!(1), &json!(0), &json!([0, 1])), "{reply}");+ assert!(reply["failed"]["error"].as_str().unwrap_or_default().contains(warning), "{reply}");+ assert_eq!(sent("engine.batch"), 0, "refused unsent");++ let mut s = bridged(ParamCheck::Warn);+ let r = tool(&mut s, "execute", misspelt.clone());+ assert_eq!(r["param_warnings"], json!([warning]), "{r}");+ assert_eq!(sent("engine.execute solid.box"), 1);+ let r = tool(&mut s, "batch", json!({"commands": [good, misspelt]}));+ assert_eq!((r["results"][0].get("param_warnings"), &r["results"][1]["param_warnings"]), (None, &json!([warning])), "{r}");+ assert_eq!(sent("engine.batch"), 1);++ let mut s = bridged(ParamCheck::Off);+ let r = tool(&mut s, "execute", misspelt);+ assert_eq!(r.get("param_warnings"), None, "{r}");+}+/// Plain `mcp` with no app running: the session is headless, says so on every result, and bridges/// to the app once one runs, but only while it holds no work of its own.#[test]@@ -2345,6 +2397,13 @@ fn auto_session_bridges_to_a_late_app_only_while_empty() {assert!(!text(&r).contains("headless session because"), "{r}");assert!(s.backend().has_ui());assert!(s.backend().describe().contains("connected to the SolidCraft app"));+ // The headless session's `--param-check` level goes on checking the bridged calls.+ let mut headless = Headless::default();+ headless.session.param_check = solidcraft_engine::schema::ParamCheck::Strict;+ let mut strict = Server::new(Box::new(crate::Auto::new(headless, Box::new(|| Some(1)), None)));+ raw_tool(&mut strict, "inspect_design", json!({}));+ assert!(strict.backend().has_ui());+ assert_eq!(strict.backend().param_check(), solidcraft_engine::schema::ParamCheck::Strict);// With work in the headless session, the app showing up changes nothing.port.set(None);diff --git a/docs/mcp.md b/docs/mcp.mdindex 1df3da7dd7..69bc20962c 100644--- a/docs/mcp.md+++ b/docs/mcp.md@@ -68,10 +68,14 @@ temporary file by the app and read back by the server, so both must run on the sCommands with a typed parameter contract (every new command, and more of the older ones as theyare converted; `describe_command` shows a command's schemas) can be checked as they are called.`--param-check off|warn|strict` sets the level for a headless session, including a script or-recipe given with `--in`; the default is `off`, which changes nothing. `warn` runs the call and-adds `param_warnings` to its result, such as ``unknown key `operaton`; did you mean-`operation`?`` (a starting script's warnings go to stderr). `strict` refuses the call, and the-design is left as it was. Calls bridged to the app are not checked yet.+recipe given with `--in`, and for calls bridged to the app; the default is `off`, which changes+nothing. `warn` runs the call and adds `param_warnings` to its result, such as ``unknown key+`operaton`; did you mean `operation`?`` (a starting script's warnings go to stderr). `strict`+refuses the call, and the design is left as it was. Bridged, the server checks each call (and+each step of a `batch`) against its own commands' contracts before sending it: `strict` sends+nothing that breaks one, and a command the server has no contract for goes to the app unchecked.+Use the server from the same release as the app: an app newer than the server may take keys the+server's contracts don't know yet, and `strict` would refuse them.### Which files the agent can reach@@ -277,7 +281,7 @@ The `skill_reference` tool returns these documents from the copies built into So| `list_commands` | `filter?` | The command catalog: id, label, tab/panel, shortcut, parameter docs, enabled now. `filter` matches id, label, tab and panel. || `describe_command` | `id` | One command's parameter docs (`params`) and, for commands with a typed contract (every new command, and more of the older ones as they are converted), the JSON Schemas (2020-12) of its parameters (`input`) and of a successful result (`output`); `null` for the others. The same as `execute` `engine.describe {command}`. || `execute` | `command`, `params?`, `verbose?` (default true) | Run any command with JSON parameters (`list_commands` shows them). Failures leave the design unchanged. A feature command replies with the feature (`feature`, `name`), every body (`bodies`) and the bodies it created, changed and removed (`created_bodies`, `changed_bodies`, `removed_bodies`). `verbose: false` uses the same compact reply as `batch`. |-| `batch` | `commands: [{command, params}]`, `rollback?` (default true), `verbose?` (default true), `timings?`, `profile?`, `coalesce_parameters?` (default false) | Run steps in order, stop at the first error and undo the completed steps. The reply names the failing step (`failed.index`, `failed.command`, `failed.error`), every result before it, `rolled_back` (true only when the design really went back to where the batch started), `undone`, `applied` (the indices of the steps whose changes are in the design) and `not_run` (the steps never sent). A step may name a tool instead of a command, with that tool's arguments as `params`: `set_parameter` (runs `parameters.change`; `value` or `expression`), `list_commands` (`engine.commands`, filtered by `filter` as the tool filters it), `describe_command` (`engine.describe`), `execute` (`{command, params}`), `measure`, `inspect_design` (`document.inspect`: each sketch as its counts, not its full contents, and no joints), `undo`, `redo`, `export`, `save`, `open`, `new_design` and `crash_reports`. `screenshot`, `body_topology` (use `model.edges` and `model.faces`), `batch`, `pending`, `running` and `skill_reference` can't be steps, nor can `component.edit_in_place` and `component.finish_edit`, however a step names them, as they go to another design's tab (send them with the `execute` tool on their own): such a batch fails before anything is sent. So does a step the batch would certainly refuse at its turn (#5853): a step without a command, an unknown command id (the error names the closest ids) or, with `--param-check strict`, parameters that break a command's contract. A headless session checks this itself; an app checks it against its own commands when it gets the batch. `verbose: false` keeps the reply small in large designs: feature steps leave out the full body list (`created_bodies`, `changed_bodies`, `removed_bodies` stay) and sketch steps the ids they repeat outside `created`. Bridged to an app that has `engine.batch`, the whole batch is one control request (one frame of the app). Older apps, and apps showing the agent cursor, get the steps one by one. `timings: true` adds `timings: [{index, command, ms}]` for every step run, the failing one included, and `total_ms`. `profile: true` also adds each step's `profile: {boolean_ms, tessellate_ms, other_ms}`, its time in kernel booleans, in tessellation and the rest. Steps are timed where they run: in the app when bridged. An app without `engine.batch` is timed step by step, without `profile`. `coalesce_parameters: true` sets each run of consecutive plain parameter edits (`parameters.change` or `set_parameter` with a name and a value, or `changes`) together, so the design rebuilds once per run instead of once per edit. Steps between runs see the design up to date. Each step keeps its own result (`coalesced`: the run's length), and the run is one undo step. The run skips the states between its edits, so an edit refused on its own can go through with the run's later ones. A refused run goes step by step, naming the refused step. |+| `batch` | `commands: [{command, params}]`, `rollback?` (default true), `verbose?` (default true), `timings?`, `profile?`, `coalesce_parameters?` (default false) | Run steps in order, stop at the first error and undo the completed steps. The reply names the failing step (`failed.index`, `failed.command`, `failed.error`), every result before it, `rolled_back` (true only when the design really went back to where the batch started), `undone`, `applied` (the indices of the steps whose changes are in the design) and `not_run` (the steps never sent). A step may name a tool instead of a command, with that tool's arguments as `params`: `set_parameter` (runs `parameters.change`; `value` or `expression`), `list_commands` (`engine.commands`, filtered by `filter` as the tool filters it), `describe_command` (`engine.describe`), `execute` (`{command, params}`), `measure`, `inspect_design` (`document.inspect`: each sketch as its counts, not its full contents, and no joints), `undo`, `redo`, `export`, `save`, `open`, `new_design` and `crash_reports`. `screenshot`, `body_topology` (use `model.edges` and `model.faces`), `batch`, `pending`, `running` and `skill_reference` can't be steps, nor can `component.edit_in_place` and `component.finish_edit`, however a step names them, as they go to another design's tab (send them with the `execute` tool on their own): such a batch fails before anything is sent. So does a step the batch would certainly refuse at its turn (#5853): a step without a command, an unknown command id (the error names the closest ids) or, with `--param-check strict`, parameters that break a command's contract. A headless session checks this itself; an app checks it against its own commands when it gets the batch, and a bridged server at `--param-check strict` checks the contracts before it sends the batch. `verbose: false` keeps the reply small in large designs: feature steps leave out the full body list (`created_bodies`, `changed_bodies`, `removed_bodies` stay) and sketch steps the ids they repeat outside `created`. Bridged to an app that has `engine.batch`, the whole batch is one control request (one frame of the app). Older apps, and apps showing the agent cursor, get the steps one by one. `timings: true` adds `timings: [{index, command, ms}]` for every step run, the failing one included, and `total_ms`. `profile: true` also adds each step's `profile: {boolean_ms, tessellate_ms, other_ms}`, its time in kernel booleans, in tessellation and the rest. Steps are timed where they run: in the app when bridged. An app without `engine.batch` is timed step by step, without `profile`. `coalesce_parameters: true` sets each run of consecutive plain parameter edits (`parameters.change` or `set_parameter` with a name and a value, or `changes`) together, so the design rebuilds once per run instead of once per edit. Steps between runs see the design up to date. Each step keeps its own result (`coalesced`: the run's length), and the run is one undo step. The run skips the states between its edits, so an edit refused on its own can go through with the run's later ones. A refused run goes step by step, naming the refused step. || `inspect_design` | `measure?` (default true), `sketches?` (default true), `joints?` (default true) | Design properties (`metadata`: project, author… and other tools' keys; set them with `execute` `document.metadata.set`), parameters, timeline (type, suppressed, rolled back, error, warning, timing), bodies (volume, area, centre of mass, bbox, face/edge/vertex counts, visible; `removed_later: true` while a sketch is being edited on a rolled-back timeline and a later feature deletes the body, which is then not shown), sketches (curves, points, constraints, profiles, DOF, solve status, visible), joints when the design has any (as `joint.inspect` gives them: each origin's occurrence, component and path, the snap as saved, the feature, face, edge or sketch curve (`sketch: {id, name, curve}`) its persistent names refer to, `resolves` and the `error` when it is lost; kind, offset, angle, flip, values, limits, expressions, motion links; `execute` `joint.inspect {joint}` gives one joint), selection, undo depth. Hide helper sketches, bodies or construction planes with `execute` `browser.visibility` (`{items, visible}` or `{folder, visible}`), and joint glyphs with `{joints: [id or name], visible}` or `{folder: "joints", visible}` (a hidden joint still constrains and drives; `joint.list` reports each joint's `visible`). || `measure` | `body?` or `items?` | Area (mm²), bbox, topology counts and `closed` per body. Volume (mm³), volume centre of mass, density and mass are reported only for closed, consistently oriented bodies (null or omitted for open surfaces). Volume/mass totals skip open bodies; `total.open_bodies_skipped` gives their count. Area and topology totals include all bodies. With `items` (one or two selections as `execute` takes them: `face`, `edge`, `vertex`, `sketch_curve`, `profile`), the picked geometry instead: faces and edges need only `type`, `body` and `point`; `index` is optional. See below. || `body_topology` | `body` | Edges (index, midpoint, length, ends) and faces (index, name, area, centroid, normal, `point`, and for a cylindrical face its `cylinder`: `origin`, `axis`, `radius`). An edge midpoint is the `[x,y,z]` that picks that edge for fillet and chamfer. A face's `point` lies on it and picks it (its centroid may not: that of a face with a hole is in the hole); a face's `name` picks it for the commands that take faces (`face.delete`, `solid.shell`, `solid.draft`, `solid.offset_face`, `solid.split_face`, `solid.replace_face`, and `face` of `sheet.convert`). |