diff --git a/docs/HLSD/design-tab.md b/docs/HLSD/design-tab.md index 887da2976b..54d0aed6cc 100644 --- a/docs/HLSD/design-tab.md +++ b/docs/HLSD/design-tab.md @@ -359,7 +359,7 @@ for a checked-in header, not documentation. `McpControl` exposes the document over JSON-RPC when `ORCA_CAD_MCP` is set in the environment, with `tools/orca_cad_mcp_bridge.py` as the client side, and to the app's MCP server through its -`cad_call` tool on every platform. It describes the scene, queries topology, measures, and runs +`call_cad_tool` tool on every platform. It describes the scene, queries topology, measures, and runs the same verbs the offer does — it re-implements nothing, so a scripted action and a clicked one cannot diverge. The socket is off unless the variable is set. Where a GUI action is bound to a selection, a card or a dialog, its work is split into a function both callers share, and the @@ -414,9 +414,9 @@ as the cards do, so the window stays live during a long build. The viewport is a canvas target like Prepare's for the app's MCP server (`DesignCanvas::gl_canvas()`): `set_view {tab: "design"}` shows the tab and points its camera, `screenshot` captures the view -(sketch overlay and status line included) and composites it into window captures, `ui_mouse` +(sketch overlay and status line included) and composites it into window captures, `mouse_gesture` clicks and drags it at pixels, so a left click picks and a right click opens the offer, and -`ui_snapshot` lists its in-canvas value fields. Keys sent with `ui_key` reach the panel's +`list_widgets` lists its in-canvas value fields. Keys sent with `press_keys` reach the panel's `wxEVT_CHAR_HOOK` as a real key press does, travelling up from the focused widget, so Escape, Enter and the tool shortcuts behave as they do for a person. @@ -436,7 +436,7 @@ tests. | `src/slic3r/GUI/CAD/DesignRowList.*` | the Feature tree and Bodies lists, with per-row actions | | `src/slic3r/GUI/CAD/DesignCanvas.*` | viewport integration | | `src/slic3r/GUI/CAD/DesignSketchTool.*` | in-canvas sketching | -| `src/slic3r/GUI/CAD/McpControl.*` | the automation surface: the method table, shared by `cad_call` and the socket | +| `src/slic3r/GUI/CAD/McpControl.*` | the automation surface: the method table, shared by `call_cad_tool` and the socket | | `src/slic3r/GUI/CAD/DesignInteraction.hpp` | the Esc level contract | | `src/slic3r/GUI/CAD/DesignOffer.hpp` | generated offer table | | `scripts/CAD/tool_atlas.json` | source of truth for the offer | @@ -455,5 +455,5 @@ nothing about the viewport, so the two are reported separately rather than as on The automation surface has its own checks: `tests/slic3rutils/test_mcp_cad.cpp` runs the methods' argument checks and kernel calls on a `CadDocument` or a bare `DesignSketchTool`, with no panel, and -the replay scripts `tools/mcp/tests/cad_*.json` run the methods on a live application through -`cad_call`, launched with `tools/mcp/orca_mcp.py launch --cad`. +the replays `tools/mcp/tests/cad_*.json` run the methods on a live application through +`call_cad_tool`, launched with `tools/mcp/orca_mcp.py launch --cad`. diff --git a/docs/HLSD/mcp-server.md b/docs/HLSD/mcp-server.md index 899b88f4e1..07c9905593 100644 --- a/docs/HLSD/mcp-server.md +++ b/docs/HLSD/mcp-server.md @@ -5,14 +5,14 @@ The MCP server lets an AI agent drive a running OrcaSlicer through the Model Context Protocol. The same tools serve two audiences. A developer's agent reproduces a GitHub issue: it loads the files, picks presets, changes settings, clicks through the GUI and slices. It also takes -screenshots before and after a fix and replays the steps from a script file. A user can drive +screenshots before and after a fix and replays the steps from a replay file. A user can drive OrcaSlicer from Claude Code, Codex, Cursor or Claude Desktop. The server runs inside the GUI process, because most of what an agent reproduces is GUI -behaviour, and reuses the Speed Dial catalog, so a feature added to the palette reaches agents and -scripts too. It is off by default; until it is first turned on, `McpService` does not exist, so +behaviour, and reuses the Speed Dial catalog, so a feature added to the palette reaches agents, +replays and scripts too. It is off by default; until it is first turned on, `McpService` does not exist, so there is no thread, socket, modal-dialog hook, ImGui item recording or synthetic input state. The code is in -`src/slic3r/GUI/Mcp/`; the protocol, transport, threading core, script runner and operation logic +`src/slic3r/GUI/Mcp/`; the protocol, transport, threading core, replay runner and operation logic don't use wx, so they can be unit-tested. ``` @@ -67,12 +67,12 @@ A tool result is one compact JSON text block plus any image blocks; no tool decl Claude Code shows its model a tool's description and input schema but never its output schema, and fails a call whose structured content does not match that schema, so a schema would teach its agents nothing and could turn a call that already ran into an error. Clients that prefer structured content -over the content blocks would also drop the images and `ui_snapshot`'s tree. Tool failures, invalid +over the content blocks would also drop the images and `list_widgets`'s tree. Tool failures, invalid arguments included, are `isError` results the model can act on; an unknown tool is a JSON-RPC `-32602` error naming close matches. `validate_arguments()` checks arguments against the tool's schema first. Before it, `normalize_arguments()` reads what agents commonly send in place of the schema's form, for calls and -script steps alike, so the journal records the schema's form. An argument under a name the tool does +replay steps alike, so the journal records the schema's form. An argument under a name the tool does not take is read as one it does, when the call leaves that one out and the value fits it: `ref` as `target`, `key` as `keys`, `text` as `value`, `action` as `id` or `button`, `object` as `objects`, `plate` as `plates`, `filter` as `query`, `settings` as `values`, `target` as `root`. A value in another JSON form is converted: a @@ -84,13 +84,13 @@ too had agents give it there beside a `camera`. Anything that still does not fit validator to report. The bench's transcripts are where these come from: each was an agent's first guess, many times over, and each cost a failed call and a retry. -The server `instructions` (under the 4096 characters clients keep) give the workflow: `get_state`, +The server `instructions` (under the 4096 characters clients keep) give the workflow: `get_app_state`, act, then check the result with the reading tools, keeping screenshots for what those do not report. They say to prefer typed tools over clicks and never retry a call that returned a job, point to `get_settings`' meta and search for what a setting does, say how a gizmo opens and is driven (and that -`gizmo_file` only stands in for a file picker inside one, since its name draws agents to it for any +`pick_gizmo_file` only stands in for a file picker inside one, since its name draws agents to it for any gizmo work), that the camera turns with `set_view` rather than a drag, and which indices are 0-based. -They also point to `api_describe {query}` as the one search across every catalog an agent calls into: +They also point to `search_tools {query}` as the one search across every catalog an agent calls into: the tools, the operations plugins offer (which `tools/list` never shows, so nothing else tells an agent they exist), Speed Dial actions, settings, the Python API and the Design tab's methods. An agent rarely knows which catalog answers "how do I add a brim", and each catalog has its own search with its own @@ -104,7 +104,7 @@ The bearer token is 32 random bytes as 64 hex characters in `/mcp/token and file created 0600 with `O_CREAT|O_EXCL` on POSIX, the per-user ACL of `%APPDATA%` on Windows. It stays out of AppConfig, whose writes and backups use default permissions. `ORCA_MCP_TOKEN` (preferred, as it stays out of the process list) or `--mcp-token` overrides it for one run; -`get_state.mcp.token_source` says which is in force. Every start of the endpoint reads the file, so +`get_app_state.mcp.token_source` says which is in force. Every start of the endpoint reads the file, so deleting it and turning the server off and on in Preferences issues a new token. While serving, `/mcp/server.json` holds `{url, port, pid, version, token}` with the token in use, so the stdio bridge and the harness connect without the launch environment. It is written @@ -116,8 +116,8 @@ file, and one that stops must not hide another's server from the stdio bridge. `GUI_App::on_init_inner()` starts the service once AppConfig is loaded. That is before the first startup dialog, such as the TLS prompt or the setup wizard, so an agent can answer those dialogs. -`--mcp` or the `mcp_enabled` preference opens the endpoint, while `--mcp-script` alone, or opening -Action Replay or the Run Script panel, only builds the catalog. `get_state.ready` stays false until `post_init()` calls `mark_ready()`, the Prepare +`--mcp` or the `mcp_enabled` preference opens the endpoint, while `--mcp-run` alone, or opening +Action Replay or the Run Script panel, only builds the catalog. `get_app_state.ready` stays false until `post_init()` calls `mark_ready()`, the Prepare canvas has loaded OpenGL and the main window has built its tab pages, and tools that need the main window fail with "still starting". Starting on Home, the canvas loads OpenGL at idle after `post_init()` (MainFrame's GL prebuild), and before that a 3MF save would draw its thumbnail with no @@ -127,7 +127,7 @@ loop, and on GTK calls that came in meanwhile have left that wait unfinished for view made afterwards gets `window.wx` and a dialog page's own buttons do nothing. So `mark_ready()` polls every 100 ms until both are done. A hidden canvas that can't get a GL context loads OpenGL on its first draw instead, and the pages build only while no input arrives, so after 10 s ready no -longer waits for either. Becoming ready also starts a command-line script. Notifications don't depend on this: one pushed or updated before the first +longer waits for either. Becoming ready also starts the `--mcp-run` file. Notifications don't depend on this: one pushed or updated before the first ImGui frame has built the font waits for its first render to measure its text. The service stops, idempotently, at the start of `MainFrame::shutdown()` when the app closes @@ -168,7 +168,7 @@ the stdio bridge by `--datadir`. The server makes no attempt to route between wi Preferences turns the server on with `GUI_App::start_mcp_service()` and off with `GUI_App::stop_mcp_endpoint()`, which stops the takeover retries and calls `McpService::stop_serving()` to close only the endpoint and remove the discovery file. The -catalog, running jobs and a launch script carry on, because the call that opened Preferences may +catalog, running jobs and a launch run carry on, because the call that opened Preferences may itself be an MCP call still on the stack. The port field shows the port in use, `--mcp-port`'s included, and only an edit of it is saved and reopens the endpoint, through `GUI_App::restart_mcp_endpoint()`: the field also commits when focus merely passes through it. A @@ -178,7 +178,7 @@ that a call still running registers afterwards are refused, so a person using th never has a prompt answered for them. Closing doesn't wait for in-flight requests, which may be waiting on the UI thread that closes it; their replies are dropped. A bind failure is logged, shown as a notification and in Preferences, and a start from Preferences never reruns a -command-line script. The modal tracker is created with the service and picks up modal dialogs that +`--mcp-run` file. The modal tracker is created with the service and picks up modal dialogs that are already open, such as Preferences when the server is turned on from there. ## Threading @@ -202,32 +202,32 @@ out and paints it only in a frame, and after each frame it shows it waits for th go-ahead, which doesn't come. Waits on the UI then time out, a list can't scroll to a row and the 3D views capture blank, none of it for the reason the call would give. `undrawn_window()` asks the main window's frame clock for a frame and waits up to half a second for it to run, so only a call that -failed asks it: a `poll_ui()` timeout, a blank canvas capture and a row `ui_click` can't place say the +failed asks it: a `poll_ui()` timeout, a blank canvas capture and a row `click` can't place say the window isn't being drawn when it isn't. `GuardClass` decides what may run when: | Class | Tools | Runs behind a modal or inside another call | |---|---|---| -| `Inspect` | get_state, wait, get_log, list tools, get_settings, screenshot, ui_snapshot, start_recording, stop_recording, encode_recording | yes | -| `Recover` | dialog_respond, dialog_auto_answer, GUI input aimed at the topmost modal | yes | +| `Inspect` | get_app_state, wait, get_log, list tools, get_settings, screenshot, list_widgets, start_recording, stop_recording, encode_recording | yes | +| `Recover` | answer_dialog, auto_answer_dialogs, GUI input aimed at the topmost modal | yes | | `Mutate` | everything else | no | The closure checks the guards on the UI thread, since the app can change between posting and running. A closing app or a stopped service fails the call with "shutting down". A frame being recreated fails it with "retry". A mutate call is refused while a modal dialog is open, and the refusal lists the dialogs. It is also refused when it would run inside another UI call's nested -event loop: a modal, `ProgressDialog::Update` or `wxYield`. The GUI input tools (`ui_click`, -`ui_input`, `ui_key`) and `dialog_respond` run as recover calls. Once a target resolves outside the +event loop: a modal, `ProgressDialog::Update` or `wxYield`. The GUI input tools (`click`, +`set_widget_value`, `press_keys`) and `answer_dialog` run as recover calls. Once a target resolves outside the topmost modal, they apply the mutate checks themselves (`UiInvoker::require_mutate()`), along with -operation admission (`McpCore::admit()`). `cancel` is a recover call too, so neither a dialog the +operation admission (`McpCore::admit()`). `cancel_job` is a recover call too, so neither a dialog the operation opened nor another call's nested loop keeps it out. `ToolDef::inline_call` decides where a call runs. Pure observation tools run on the request thread. Every tool that can activate UI runs as a job on its own thread, recover tools that click in dialogs included, since a click can open another modal (Preferences, Keyboard shortcuts, Edit). `JobRegistry` names jobs `j1`, `j2`, …, records each job's tool and parent, allows 64 running and -keeps the last 64 results, plus finished jobs whose parent (a running script) may still wait for +keeps the last 64 results, plus finished jobs whose parent (a running replay) may still wait for them, up to 1024 in all. The request thread waits up to `ToolDef::budget_ms` (45 s, under Codex's 60 s tool timeout); after that the reply is `{status: "running", job, tool, note}` and the job keeps going until `wait {for: "job"}` (at most 50 s per call) returns its result. The server @@ -237,8 +237,8 @@ never retries a mutating call, and every envelope tells the model not to either. request thread posts a probe closure, which runs inside a wx dialog's loop and returns the `ModalTracker` snapshot as JSON; no `wxDialog*` crosses threads. With a modal open, the reply is `{status: "blocked_by_dialog", job, dialogs}`. Its note says how to answer the topmost dialog: -`dialog_respond` for a wx dialog or a native message box whose buttons are listed, a person for any -other dialog marked `native: true` (a picker, or any native dialog on macOS), which `dialog_respond` +`answer_dialog` for a wx dialog or a native message box whose buttons are listed, a person for any +other dialog marked `native: true` (a picker, or any native dialog on macOS), which `answer_dialog` can't press. On macOS a file picker, folder picker or message box pauses wx's pending events while it is open @@ -267,7 +267,7 @@ Slicing and G-code export finish in the background process. Their handlers call `ToolContext::begin_operation()` in a short UI closure before starting the work; that fails if another operation runs. An export starts in that same closure. A slice first waits for the background update that a change made just before has scheduled, which validates the new state, and -then requests the slice. A `cancel` that comes while it waits moves on `Plater::slice_cancel_seq()`, +then requests the slice. A `cancel_job` that comes while it waits moves on `Plater::slice_cancel_seq()`, so the slice never starts and reports its plates `cancelled`. `poll_ui()` then checks on the work through `observe_ui()` every 200 ms, so a dialog that opens meanwhile doesn't stop the watch, until the work ends or the deadline passes. The deadline is `slice.timeout_s` (default 30 minutes) for a @@ -284,23 +284,23 @@ own job then ends only once the worker is idle again, its finalization included, `ModelInstance` pointers until then. (`Worker::is_idle()` reads true from the moment the worker takes the finalize message, so a dialog finalization opens, such as an arrange's geometry error, ends the hold early; the modal guard keeps changes out until it closes.) Its reply waits within the reply budget and -then becomes a running job, as for any call. `cancel` (or the call's own timeout, 30 minutes unless +then becomes a running job, as for any call. `cancel_job` (or the call's own timeout, 30 minutes unless the tool sets a shorter one, as `arrange` does) asks the job to stop, but `Worker::cancel()` does not -wait, so the call keeps the operation until the worker is idle and then fails as cancelled. `cancel` +wait, so the call keeps the operation until the worker is idle and then fails as cancelled. `cancel_job` stops only a job an MCP call claimed. The worker doesn't record who queued a job, so a job a person starts while a call is still between its closures, after one that found the worker idle, is claimed by that call too: its reply then waits for that job. The window is the call's own length, a second or so for most calls and up to its poll timeout for a call that waits on the UI. **Admission.** While an operation job runs, every other `Mutate` call is refused ("Busy: job j12 is -running an operation (slice, export, arrange or another background job)"), whichever client or script +running an operation (slice, export, arrange or another background job)"), whichever client, replay or script sends it. So an agent can't change the project under its own operation. While the worker runs a job no call holds, a person's (typing in the Text gizmo) or one not yet claimed, changes are refused too ("Busy: a background job ..."); reads are not. The check, `McpCore::admit()`, runs when the call arrives (operations only, since the worker lives on the UI thread) and again in each of its UI closures, where operations start, so a call admitted just before an operation began still can't change the project under it. Inline tools, recover tools answering the topmost modal and -`allowed_during_operation` tools (`cancel`) still run; the GUI input tools apply the same check once +`allowed_during_operation` tools (`cancel_job`) still run; the GUI input tools apply the same check once their target is outside the topmost modal. **Identity.** An operation must never take another's completion for its own. `Plater` numbers @@ -343,7 +343,7 @@ flush and prime tower grams. The silent-mode time and extruder changes, which th out, come from the result's estimates, and only when the printer has them. The summary is read in the poll closure that decides the outcome, since a UI call of its own would wait behind the preview's loading of the new result; the serializer's one pass over the moves is short next to -that. `cancel` also drops a pending automatic reslice: it stops the delay timer, +that. `cancel_job` also drops a pending automatic reslice: it stops the delay timer, whose callback wx then never delivers, and moves on a generation that a zero-delay reslice already queued with `CallAfter` checks. An export is numbered in `export_seq` once scheduled, so an unchanged number means it never started; otherwise its `ExportRecord` ends `ok`, `failed`, @@ -358,22 +358,29 @@ and the UI job worker (arrange, orient) is idle, and no gizmo on any canvas repo `GLGizmoBase::is_busy()`: work a gizmo started in the background whose result it has yet to show (Simplify's calculation until `worker_finished()` has run, Texture Displacement's adjustment preview). It also needs no job running other than the caller and its ancestors, -so a script waiting for idle doesn't wait on itself. Only the job registry, the `ModalTracker` +so a replay or script waiting for idle doesn't wait on itself. Only the job registry, the `ModalTracker` snapshot and the journal are shared between threads, each behind a mutex. All app state is read on the UI thread. ## Tool catalog +A tool's name says what it does in the words the GUI uses, so a person's request and an agent's search for a +tool meet: `set_height_ranges` edits what the object list calls height ranges (Height Range Modifier), +`set_variable_layer_height` runs the Variable layer height panel, and `run_replay` runs what Action Replay calls +a replay file. Where the GUI has no name for the thing, the name is a plain verb and noun (`list_widgets`, +`answer_dialog`), and a word the GUI uses for something else is avoided: `run_script` would read as the Run +Script panel, which runs Python. + | Group | Tool | Purpose | |---|---|---| -| App | `get_state` | version, platform and display backend, ready, window, the MCP endpoint, whether Python runs and Python scripts are allowed, whether the Design tab is on, tab, mode, project, presets, plates, objects, the selection, slicing, the Preview's view type, time mode and layer range, print host uploads, the open gizmo, dialogs, menus closed unseen, auto-answer rules, notifications, jobs | +| App | `get_app_state` | version, platform and display backend, ready, window, the MCP endpoint, whether Python runs and Python scripts are allowed, whether the Design tab is on, tab, mode, project, presets, plates, objects, the selection, slicing, the Preview's view type, time mode and layer range, print host uploads, the open gizmo, dialogs, menus closed unseen, auto-answer rules, notifications, jobs | | | `wait` | `ready`, `idle`, `dialog`, `no_dialog` or a `job` (default the job given, else `idle`); `timeout_s` up to 50 | | | `get_log` | end of the current log file, filtered by minimum level | -| Speed Dial | `list_actions` | search the action catalog, paged | +| Speed Dial | `search_actions` | search the action catalog, paged | | | `run_action` | run an action by id (or the name inside it), with its optional `param`; an error when the action did nothing; waits for a background job it starts (arrange, orient) | | Project | `open_files` | load models, a project or G-code by absolute path, with no dialog | | | `new_project` | start an empty project (`discard_changes` if it has unsaved changes); `changes` keeps or discards modified presets | -| | `calibrate` | a Calibration menu test with typed parameters and no dialog: a new project with the test model and the preset changes the test needs, printed with filament slot 1; refused while presets are modified unless `changes` keeps or discards them | +| | `generate_calibration_test` | a Calibration menu test with typed parameters and no dialog: a new project with the test model and the preset changes the test needs, printed with filament slot 1; refused while presets are modified unless `changes` keeps or discards them | | | `save_project` | save the project as `.3mf` to a path (a `.gcode.3mf` path is refused: that is `export` `sliced_3mf`) | | | `export` | `gcode`, `sliced_3mf`, `3mf` or `stl` to a path, by default the one its extension names; `gcode` is an export operation | | Presets | `list_presets` | printer, process or filament presets with flags (system, user, inside the project, the preset inherited from), paged | @@ -384,38 +391,38 @@ the UI thread. | | `delete_preset` | delete a user or project preset, selected or not, as the tab's Delete does (destructive) | | Objects | `list_objects` | objects (filament, auto drop, overrides, brim ears, height range modifiers, variable layer height profile), instances (placement, mirrored, bounding box, canvas rectangle on request) and parts (type, filament, placement and bounding box on the bed, scaled and mesh volume, painted facets, text and SVG sources), paged | | | `list_plates` | plates with the settings they print with and those they set themselves, objects, name, lock, slice state, prime tower position and layer G-codes, paged | -| | `select` | select objects, instances or parts (indices checked against what the object has), all, or none | +| | `select_objects` | select objects, instances or parts (indices checked against what the object has), all, or none | | | `transform` | translate, rotate, scale or size one instance, relative or absolute, move it to a `position` or to another plate; or the same for one part (`volume`) | | | `add_part` | add a part, negative part, modifier, support blocker or enforcer, or precise seam to an object: a shape at a size or a model file, optionally at a position | | | `arrange` | arrange every unlocked plate or one plate, or fill an object's plate with instances or copies, with the Arrange options panel's settings; waits for the job | -| | `set_layer_ranges` | replace an object's height range modifiers: Z ranges with their own layer height, filament and process settings | -| | `set_layer_height_profile` | the Variable layer height panel's Adaptive (with its quality), Smooth (radius, keep min) or Reset on an object | +| | `set_height_ranges` | replace an object's height range modifiers: Z ranges with their own layer height, filament and process settings | +| | `set_variable_layer_height` | the Variable layer height panel's Adaptive (with its quality), Smooth (radius, keep min) or Reset on an object | | Slice | `slice` | current, one or all plates, then the Preview tab as after the Slice button; outcome for each plate, and for an `ok` one its time, filament totals with the flush, cost, layers, max Z, filament changes and grams per slot by use | -| | `cancel` | stop the running slice or G-code export, a pending automatic reslice, or a background job an MCP call started (optionally only a given job), or with `job` a running `encode_recording`; allowed during an operation | -| | `set_layer_gcode` | add or remove a plate's pauses, custom G-code, custom templates and filament changes on its sliced layers, as the Preview layer slider's menu does | +| | `cancel_job` | stop the running slice or G-code export, a pending automatic reslice, or a background job an MCP call started (optionally only a given job), or with `job` a running `encode_recording`; allowed during an operation | +| | `set_custom_gcode_at_layer` | add or remove a plate's pauses, custom G-code, custom templates and filament changes on its sliced layers, as the Preview layer slider's menu does | | View | `set_view` | tab (Design included), 3D view (Prepare, preview, assemble), camera (a direction also as `view`; the Design view's on the Design tab) and `orbit` around what it looks at by degrees, preview layers (by number or height), color scheme as the legend's combo picks it, legend rows and time estimate, window size | | | `screenshot` | window, the 3D view shown (the Design view on the Design tab), topmost dialog or one widget: a downscaled image and a full-size PNG | -| | `get_preview` | a sliced plate's summary, time and grams per feature type, per-layer Z, height, time and grams (paged), grams per object instance, and the Preview's legend state and colour ranges | +| | `get_slice_stats` | a sliced plate's summary, time and grams per feature type, per-layer Z, height, time and grams (paged), grams per object instance, and the Preview's legend state and colour ranges | | Recording | `start_recording` | record the main window with its modal dialogs, or the 3D view shown, into an MJPEG `.mkv`, with the current tool call as a caption and the pointer highlighted when asked for, and with `encode` an MP4 of it once stopped | | | `stop_recording` | capture the last state, end the recording and report its file once written: length, frames, drops, the mean UI time of a capture, size and why it ended; the job of the encode `start_recording` asked for | | | `encode_recording` | encode a recording into an H.265 or H.264 MP4 with the system ffmpeg; cancellable | -| GUI | `list_windows` | the open windows, modal or not, with refs for `screenshot`, `ui_snapshot` and the input tools, paged | -| | `ui_snapshot` | widgets, rows of lists, trees and tables, popups, menus, GL toolbar items, gizmos, the Prepare view's plates and plate icons, and ImGui items, with refs | -| | `ui_click` | activate a ref or locator, click a row's cell or a plate icon, or click a point of a 3D canvas or custom-drawn widget; list the menu it opens, or run one of its items | -| | `ui_input` | set a control's text, value, selection or checked state, or a row's checkbox | -| | `ui_key` | send a key chord to a target or the focused window, whose panels' key hooks see it first; list or run the menu it opens | -| | `ui_mouse` | canvas gestures: move, down, up, click, drag, wheel, at pixels or at points of the model (the Design view at pixels); list or run a right click's menu; reports when a gesture moved the camera | -| | `gizmo_file` | what the open gizmo's file pickers do, with a path: SVG change file and save as, texture import | -| | `dialog_respond` | press a button of the topmost wx dialog or native message box, or of its page for a web dialog | -| | `dialog_auto_answer` | answer matching modals as they open (native ones unseen, web ones on their page), and one already open | -| | `webview_eval` | run JavaScript in a web view (the topmost dialog's while a modal is open), with a page element as `el`, and return the result | -| Scripts | `run_script` | run a script file or inline script, with results per step | -| | `export_script` | write the session journal as a script that can be replayed; calls whose job is still running are left out and listed | -| | `run_python` | run Python code against `orca.host`, calling tools through `orca.host.tools`; needs the Python setting (see Python scripts); cancellable | -| | `python_api` | search the `orca` package in the running build: names, signatures and documentation, paged | -| API | `api_describe` | look up any registered tool or plugin operation by name, list every name, or search every catalog by words | -| | `api_call` | call a registered tool or plugin operation by name; runs and is journaled as that tool's own call | -| CAD | `cad_call` | a method of the Design tab: sketches, features, reads and measurements, feature and body edits, undo, commit to plate; `describe_tools` lists them (CAD builds, Design tab enabled) | +| GUI | `list_windows` | the open windows, modal or not, with refs for `screenshot`, `list_widgets` and the input tools, paged | +| | `list_widgets` | widgets, rows of lists, trees and tables, popups, menus, GL toolbar items, gizmos, the Prepare view's plates and plate icons, and ImGui items, with refs | +| | `click` | activate a ref or locator, click a row's cell or a plate icon, or click a point of a 3D canvas or custom-drawn widget; list the menu it opens, or run one of its items | +| | `set_widget_value` | set a widget's text, value, selection or checked state, or a row's checkbox | +| | `press_keys` | send a key chord to a target or the focused window, whose panels' key hooks see it first; list or run the menu it opens | +| | `mouse_gesture` | canvas gestures: move, down, up, click, drag, wheel, at pixels or at points of the model (the Design view at pixels); list or run a right click's menu; reports when a gesture moved the camera | +| | `pick_gizmo_file` | what the open gizmo's file pickers do, with a path: SVG change file and save as, texture import | +| | `answer_dialog` | press a button of the topmost wx dialog or native message box, or of its page for a web dialog | +| | `auto_answer_dialogs` | answer matching modals as they open (native ones unseen, web ones on their page), and one already open | +| | `run_javascript` | run JavaScript in a web view (the topmost dialog's while a modal is open), with a page element as `el`, and return the result | +| Replays and scripts | `run_replay` | run a replay file or inline replay, with results per step | +| | `export_replay` | write the session journal as a replay; calls whose job is still running are left out and listed | +| | `run_script` | run Python code against `orca.host`, calling tools through `orca.host.tools`; needs the Python setting (see Python scripts); cancellable | +| | `search_python_api` | search the `orca` package in the running build: names, signatures and documentation, paged | +| API | `search_tools` | look up any registered tool or plugin operation by name, list every name, or search every catalog by words | +| | `call_tool` | call a registered tool or plugin operation by name; runs and is journaled as that tool's own call | +| CAD | `call_cad_tool` | a method of the Design tab: sketches, features, reads and measurements, feature and body edits, undo, commit to plate; `describe_tools` lists them (CAD builds, Design tab enabled) | Each tool has a lane, the way it acts, set by `ToolRegistry::add()` from `tool_lane()`: core (the session, recovery and Python), API (project data by index and name, JSON in and out) and UI (the GUI @@ -431,42 +438,42 @@ So the label marks what a call does by its nature, not everything a call could r a confirmation on calls an agent makes all the time. `read_only`: the tool changes nothing in the app or the project. `screenshot` is read-only, since its -PNG replaces no file without `overwrite`; `export_script`, which can clear the journal, is not. +PNG replaces no file without `overwrite`; `export_replay`, which can clear the journal, is not. `destructive`: every call deletes what a person made, with no undo: `delete_preset`, which takes the preset's file and its cloud copy. A tool that can lose work only when an argument asks for it is not: -`new_project`, `calibrate` and `open_files` drop unsaved changes only with `discard_changes`, an output +`new_project`, `generate_calibration_test` and `open_files` drop unsaved changes only with `discard_changes`, an output replaces a file only with `overwrite: true`, and `encode_recording` deletes its source only with -`delete_source`. Nor is a tool that runs what its arguments name: the `ui_*` tools, which press -whatever is on screen, a Delete button included, `run_action`, `api_call`, `run_script` and -`run_python`. What they run may be destructive, but the client sees both in the arguments, and the +`delete_source`. Nor is a tool that runs what its arguments name: the input tools (`click`, `set_widget_value`, `press_keys`, `mouse_gesture`), which press +whatever is on screen, a Delete button included, `run_action`, `call_tool`, `run_replay` and +`run_script`. What they run may be destructive, but the client sees both in the arguments, and the label would ask on every call. `open_world` (`openWorldHint`): the tool can reach outside OrcaSlicer, to a printer, the cloud account or the network: `save_preset` (user presets sync), `delete_preset` (the cloud -copy), `webview_eval` (the page's own reach), and through what they run `run_action` (`send_gcode`, -`sync_presets`), `api_call`, `run_script` and `run_python`, which has the app's access to the computer. +copy), `run_javascript` (the page's own reach), and through what they run `run_action` (`send_gcode`, +`sync_presets`), `call_tool`, `run_replay` and `run_script`, which has the app's access to the computer. No client is known to ask on it. `idempotent`: the same call again changes nothing more. The tools that take an object index (`set_settings` object and volume scopes, `transform`, `add_part`, -`set_layer_ranges`, `set_layer_height_profile`) also take an optional `object_id`, and where they take a -part index a `volume_id`; `select` takes `object_ids`, `instance_object_ids` and `volume_ids`, one per +`set_height_ranges`, `set_variable_layer_height`) also take an optional `object_id`, and where they take a +part index a `volume_id`; `select_objects` takes `object_ids`, `instance_object_ids` and `volume_ids`, one per entry of `objects`, `instances` and `volumes`: the `ObjectID` values `list_objects` reports as `id`, which `orca.host` shows too. `check_expected_ids()` refuses the call before anything changes when the index names another object -or part now, so a script addresses what it read. `list_objects`' description says what the ids are for +or part now, so a replay or script addresses what it read. `list_objects`' description says what the ids are for and names the tools that take them, so each property only points back at it. Ids are allocated per process, so the journal leaves them out of those tools' calls (`without_expected_ids()`), through -`api_call` and inline `run_script` steps too, and a replay addresses by index; a `run_python` step's code +`call_tool` and inline `run_replay` steps too, and a replay addresses by index; a `run_script` step's code and `args`, and a plugin operation's own arguments, are kept as written. Descriptions keep one order: what the tool does, the arguments that change it, `Reply:` with the fields it has, then edge cases; a long one puts each case on a line of its own (the scopes of -`get_settings` and `set_settings`, `ui_click`'s web pages). What several tools share is written once, -since every session loads the whole tool list: the locator grammar in `ui_snapshot`'s description, +`get_settings` and `set_settings`, `click`'s web pages). What several tools share is written once, +since every session loads the whole tool list: the locator grammar in `list_widgets`'s description, which hands out the refs, each `target` giving two examples and pointing there; the paging shape, and that a part is a `volume` in argument names, in the server instructions. A tool that takes one plate calls it `plate`, an index; one that also takes `"current"` or `"all"` calls it `plates`. Each tool family registers itself from its own `McpTools*.cpp` through `register_*_tools()`. List tools take `limit` and `offset` and reply `{items, offset, total}` (`page()`), with `next_offset` while -more remain; `list_actions` names its items `actions`. The server instructions give that shape once, rather +more remain; `search_actions` names its items `actions`. The server instructions give that shape once, rather than every description, and each `limit` states its default. `McpPaths.hpp` requires absolute paths, since a relative one would resolve against `/log`, the GUI's working directory; an output's directory must exist, and an existing file is replaced only with @@ -493,7 +500,7 @@ negative parts, support blockers and enforcers, and precise seams. A precise sea names without their prefix). The `transform` reply on a part carries the same `volume_info`. An object with height range modifiers lists them as `layer_config_ranges` (`layer_config_ranges_json()`), each with its whole config serialized as `get_settings` serializes values, so a range always shows -its `layer_height` and `extruder`, and the list can be handed back to `set_layer_ranges` unchanged. An +its `layer_height` and `extruder`, and the list can be handed back to `set_height_ranges` unchanged. An object whose `layer_height_profile` has more than a flat bottom-to-top pair, which the object list marks as a variable layer height, reports it as `layer_height_profile: {points, min_height, max_height}` (`layer_height_profile_json()`): the number of (z, height) points and the extreme heights, to 0.001 mm. @@ -575,9 +582,9 @@ An arrange sorts the model's objects by arrange order (`PartPlateList::rebuild_plates_after_arrangement()`), so indices may change. After `timeout_s` (default 300) the call cancels the job. -### set_layer_ranges +### set_height_ranges -`set_layer_ranges` gives an object's whole set of height ranges (`ModelObject::layer_config_ranges`), +`set_height_ranges` gives an object's whole set of height ranges (`ModelObject::layer_config_ranges`), which a person builds with the object list's Height Range Modifier, its "+" buttons and the range editors in the sidebar, one gesture and one undo step at a time. Each range starts from what the object list gives a new one, `ObjectList::get_default_layer_config()` (the object's layer height, else the @@ -604,9 +611,9 @@ layer height. The dialog the menu shows when the process uses mixed colour subla heights instead of the ranges' `layer_height` (`PrintObject::update_layer_height_profile()` falls back to the ranges only without a valid profile). -### set_layer_height_profile +### set_variable_layer_height -`set_layer_height_profile` runs what the Variable layer height panel's Adaptive, Smooth and Reset buttons +`set_variable_layer_height` runs what the Variable layer height panel's Adaptive, Smooth and Reset buttons post: `GLCanvas3D::adaptive_layer_height_profile(quality)`, `smooth_layer_height_profile({radius, keep_min})` and `reset_layer_height_profile()`, each with the GUI's undo snapshot ("Variable layer height - Adaptive", "- Smooth all", "- Reset"), followed by a background update and the object list's variable @@ -634,9 +641,9 @@ also passes on the warning the panel shows when the process mixes colours in sub stored per object, saved in the 3MF, and discarded by the slicer when it no longer ends at the object's top (after a scale, for example). -### set_layer_gcode +### set_custom_gcode_at_layer -`set_layer_gcode` places what the Preview layer slider's right-click menu adds at the start of a layer +`set_custom_gcode_at_layer` places what the Preview layer slider's right-click menu adds at the start of a layer (Add Pause, Add Custom G-code, Add Custom Template, Change Filament > Filament N) and removes them, on one plate. The codes are a plate's `Model::plates_custom_gcodes` entry, saved in the 3MF (`custom_gcode_per_layer.xml`) and read back by `list_plates` as `layer_gcode`, with the same type names @@ -650,7 +657,7 @@ edits the slider with its own functions (`IMSlider::add_code_as_tick()`, `add_cu plate's entry rewritten, its slice invalidated, the project dirty and its revision raised. Codes sit on the layers of the plate's slice. `layer` is the slider's value plus one, as `set_view` and -`get_preview` number layers; `z` takes the layer whose top is at or above it +`get_slice_stats` number layers; `z` takes the layer whose top is at or above it (`IMSlider::get_tick_from_value(z, true)`, the rule the slider uses for a stored height), so a code is always stored at a layer's top, where the slider and the G-code generator agree on its layer. The reply gives both for every code. A plate's layers are in the slider only while the Preview shows that plate's @@ -715,7 +722,7 @@ the plain Save. A new preset goes where the edited one is (user or inside the pr choice. `detach` is refused outside Developer mode, where the dialog has no such checkbox. For a printer, the selected physical printer, if any, takes the dialog's default action (`SavePresetDialog::update_physical_printers()` with `ChangePreset`). Preset files live in the -datadir, not the project, so a script meant to be rerun passes `overwrite`. A filament temperature +datadir, not the project, so a replay or script meant to be rerun passes `overwrite`. A filament temperature warning, the unresolved-plugin confirmation or the unsaved-changes prompt of a slot switch makes the reply `blocked_by_dialog`. @@ -875,8 +882,8 @@ the preset being edited again, which would drop its unsaved changes (filament) o (process), so they are refused while it has any. The reply carries `selected`, the preset of that type selected afterwards, `filaments`, each slot's -preset, and `discarded`/`modified` as `select_preset`'s. A replayed script needs the preset to exist, -so scripts create it first with `save_preset`. +preset, and `discarded`/`modified` as `select_preset`'s. A replay needs the preset to exist, +so replays create it first with `save_preset`. ### Project settings @@ -977,19 +984,19 @@ handlers carry its effects (dark mode, the language, which recreates the GUI, th mode, render settings redrawn after the dialog closes, and this server's own `mcp_enabled` and `mcp_port`, which close the endpoint the call came through). Writing the key would skip all of them. -The dialog's controls are named after their AppConfig keys, so `ui_snapshot` shows the key and -`ui_input {"target": {"name": "export_statistics", "within": "Preferences"}, "value": true}` changes one +The dialog's controls are named after their AppConfig keys, so `list_widgets` shows the key and +`set_widget_value {"target": {"name": "export_statistics", "within": "Preferences"}, "value": true}` changes one through its own handler. The Speed Dial's `open_preferences` takes `[:]` (`general`, `files`, `behaviour`, `control`, `graphics`, `online` or `developer`) and opens the dialog there through `GUI_App::open_preferences()`, scrolled to the key's control and focused; a key on another tab is shown on its own tab. Checkboxes, number and text fields and the language combobox change this way. The other comboboxes (those of `create_item_combobox()`, the log level, the login region and the network plug-in version) save from a -handler on their drop-down list, where a person's pick arrives, while `ui_input` sends the selection to the +handler on their drop-down list, where a person's pick arrives, while `set_widget_value` sends the selection to the combobox itself: it shows the new choice and saves nothing. ### Calibration tests -`calibrate` runs a Calibration menu test (temperature, max volumetric speed, pressure advance as tower, +`generate_calibration_test` runs a Calibration menu test (temperature, max volumetric speed, pressure advance as tower, line or pattern, flow ratio in its four passes, retraction, VFA, cornering, input shaping frequency and damping) one level below its dialog: it calls the same `Plater::calib_*` the dialog's OK calls, with the `Calib_Params` the dialog would build, and never shows the dialog. The dialogs only collect and check @@ -1014,7 +1021,7 @@ Every test starts a new project, whose prompts the tool answers itself (`skip_co `calib_*`): a project with unsaved changes needs `discard_changes`, and modified presets need `changes`, `"keep"` to run the test with them or `"discard"` to drop them first through `GUI_App::discard_current_preset_changes()`. Unlike `new_project`, which keeps modified presets silently, -`calibrate` refuses without `changes` and lists the modified keys: a previous test's settings would +`generate_calibration_test` refuses without `changes` and lists the modified keys: a previous test's settings would otherwise spoil this one. With `"discard"` the test's rules and defaults come from the saved printer preset, which is what remains. The tests write their filament settings to the preset the filament tab edits, while the test objects print with slot 1, so the tool first points the tab at slot 1's preset @@ -1034,14 +1041,14 @@ computed from the presets again on replay. To keep a measured value, the agent l `new_project {"discard_changes": true, "changes": "discard"}`, sets the value with `set_settings` and saves it with `save_preset`; staying in the test project, `set_settings {"reset_all": true, "values": ...}` on the preset's scope drops the test's settings there and sets the value in one call. The Speed Dial's `calib_*` commands still open -the dialogs, and their descriptions point at `calibrate`. +the dialogs, and their descriptions point at `generate_calibration_test`. -### Design tab: `cad_call` +### Design tab: `call_cad_tool` -`cad_call {method, params}` reaches the Design tab's control surface (`CAD/McpControl.cpp`), the +`call_cad_tool {method, params}` reaches the Design tab's control surface (`CAD/McpControl.cpp`), the same methods the `ORCA_CAD_MCP` socket serves, as one generic tool rather than a schema per method, so agents that never open the Design tab pay nothing for it. It needs the CAD feature on -(Preferences > Features), which the app reads only at startup; `get_state.design_tab` says whether +(Preferences > Features), which the app reads only at startup; `get_app_state.design_tab` says whether this session built the tab. One table, `kCadMethods`, declares every method's name, access and handler; the dispatcher, the busy gate and `describe_tools` all read it. `describe_tools` is the parameter schema of record: one row per method with typed params, @@ -1055,7 +1062,7 @@ nor `sketch` methods run while a body Move is open, since its session holds a bo change could point at another body. Nothing runs while a rebuild's worker owns the document. A method that fails is an error (`CadCallError` → `isError`) and leaves the design as it was, so -`export_script` drops it and a script never replays a call that did nothing. That holds for +`export_replay` drops it and a replay never repeats a call that did nothing. That holds for argument errors and for a rebuild the kernel rejects alike. The exceptions are the older methods `describe_tools` lists in `legacy_ok_false` (`fillet`, `chamfer`, `boolean`, `pattern`, `mirror`, `shell`, the surface methods, `import_step`, `set_variable` and others): they report a rejected @@ -1065,11 +1072,11 @@ are not on that list, so none of them fails two ways depending on its arguments. methods off the list add through `add_feature()`: one checkpoint, a rebuild, and on failure `CadDocument::rollback()`, which restores the checkpoint without leaving the refused recipe on the redo stack and with the redo branch the checkpoint cleared, then "Edit rejected" on the status line -as for a refused GUI edit. Features made through `cad_call` are named as the cards name them +as for a refused GUI edit. Features made through `call_cad_tool` are named as the cards name them ("Extrude 3"), from the panel's own counter. `generation` guards face and edge ids within a session, but its value depends on the session's -history, so the journal records `cad_call` without it and a replay rebuilds the same ids. +history, so the journal records `call_cad_tool` without it and a replay rebuilds the same ids. The plane-taking methods (`sketch_begin`, `extrude`, `revolve`, the `hole` methods, `thread`, `split`, `pattern`, `mirror`, `helix`, `project`) share one resolver, `cad_resolve_plane()`: `"XY"`, @@ -1079,7 +1086,7 @@ The plane-taking methods (`sketch_begin`, `extrude`, `revolve`, the `hole` metho `CadDocument::inward_plane_of_face()`, the Hole card's plane (normal into the body, x along the longest edge), and the hole or thread goes into that face's body. Their replies carry the `frame` used. Because a sketch's base plane passes through `modeling_origin` like every feature's, a sketch -lands where the features drawn on the same plane land, and the coordinates in a script are relative +lands where the features drawn on the same plane land, and the coordinates in a replay are relative to the modeling origin on any printer. `describe_scene` reads the document: the features, each with the fields an expression drives @@ -1112,7 +1119,7 @@ through `DesignPanel::begin_sketch_session()`, the code a plane or face pick run menu that follows the click. `sketch_commit` is the sketch's ✓, whose commit handler adds the Sketch feature and solves its dimensions; the reply reads the committed feature back: `sketch_index`, its name and its loops. An empty sketch is refused before anything changes and the session stays open, -because an exported script leaves the failed call out and its next sketch call needs that session. +because an exported replay leaves the failed call out and its next sketch call needs that session. `sketch_describe {sketch}` describes a committed sketch as the open one is described, through `DesignSketchTool::loop_report(entities)`. Its loop indices are those `extrude {loop}` takes: a region lists the loops inside it under `holes`, and each of those is a loop of its own. @@ -1206,10 +1213,10 @@ the lower one follows it. Thread, sweep and loft rebuild as their cards do, through `DesignPanel::recompute_guarded()`: the kernel works on a worker thread while the UI thread waits in `wxYield()` behind a progress dialog that appears after 300 ms. A long thread or sweep takes seconds, and meanwhile the window paints -and inspection tools answer from inside that loop: `get_state`, `ui_snapshot` (the dialog is a +and inspection tools answer from inside that loop: `get_app_state`, `list_widgets` (the dialog is a non-modal `wxProgressDialog` titled "Design") and `screenshot`, of the window or of the dialog's own ref. On Windows the dialog is the system's task dialog, run on a thread of its own, so it is no wx -window and `ui_snapshot` does not list it; the other tools answer as elsewhere. Mutating calls are refused by `UiInvoker` as running inside `cad_call`, and the `ORCA_CAD_MCP` +window and `list_widgets` does not list it; the other tools answer as elsewhere. Mutating calls are refused by `UiInvoker` as running inside `call_cad_tool`, and the `ORCA_CAD_MCP` socket's requests by `mcp_busy()`, since the worker owns the document. A call past the reply budget becomes a running job; the socket waits on such a request past its 15 s queue timeout once it has started. @@ -1262,12 +1269,12 @@ view (iso, fitted), `fit_objects` its `fit_view()`, and `fit_selection` the pick nothing is picked. The camera is applied in a second UI closure after `settle()`, because the tab takes the shared camera only when its page shows (`DesignPanel::on_tab_shown()`). `fit_bed`, `view` and the Preview fields are refused with the Design tab, since they show Prepare or Preview. The -Design view is a canvas target for the `ui_*` tools and screenshots (see GUI automation and +Design view is a canvas target for `list_widgets`, the input tools and screenshots (see GUI automation and Screenshots). A change made only in the Design tab marks the project modified, as other project data outside Prepare's undo stack does: `sync_recipe_to_model()` sets the plater's dirty flag besides the -backup's change mark. So `get_state.project.dirty`, the window title and `open_files` / +backup's change mark. So `get_app_state.project.dirty`, the window title and `open_files` / `new_project {discard_changes}` agree with the unsaved-changes prompt that Open and New Project show. A project holding only a design loads no objects, and `Plater::load_project()` still names it after its file, since a loaded recipe counts as a loaded project. @@ -1276,7 +1283,7 @@ it after its file, since a loaded recipe counts as a loaded project. `describe_tools`, the plane resolver, the rollbacks, and the methods through their public seams (`cad_sketch_extrude()`, `cad_sketch_call()`, `cad_query_topology()`, `cad_thread()` and the rest), which take a `CadDocument` or a bare `DesignSketchTool` and need no Design panel. The replay -scripts run on an instance that `tools/mcp/orca_mcp.py launch --cad` starts: +replays run on an instance that `tools/mcp/orca_mcp.py launch --cad` starts: `tools/mcp/tests/cad_sketch_to_solid.json`, `cad_sketch_edit.json`, `cad_topology_targets.json`, `cad_features.json`, `cad_doc.json` and `cad_canvas.json` (the Design view as a canvas target, its key hook, and the dirty flag). `tools/mcp/test_cad_replay.py` records a session with @@ -1287,13 +1294,13 @@ properties; `tools/mcp/test_cad_slow_build.py` checks the window during a guarde ## Speed Dial catalog -`list_actions` and `run_action` serve the Speed Dial's `ActionRegistry`: built-in commands, plates, +`search_actions` and `run_action` serve the Speed Dial's `ActionRegistry`: built-in commands, plates, recent projects, plugin scripts and pages, and, on request, settings. Built-in commands are `NativeCommand`s in `NativeCommands.cpp`, with three fields for automation that the palette never shows: `description` (English, for agents), `param` (a `CommandParam {type, help}`, typed `None`, `Percent`, `Tab`, `Path`, `Index` or `Text`) and `completion` (`Export` when the effect finishes in the background after `run()` returns). `describe_commands()` fills them from one table, with a -key-prefix rule for calibration dialogs (pointing at `calibrate`), camera views and primitives, and `CommandAction` copies +key-prefix rule for calibration dialogs (pointing at `generate_calibration_test`), camera views and primitives, and `CommandAction` copies them into the `AppAction`. The palette keeps `input` for its picker and never passes a path. `ActionRegistry::describe(Query)` searches id, title, group, source and description, including the @@ -1326,7 +1333,7 @@ turns a bad path into an Error result. | `export_stl_multi` | existing directory | `Plater::export_stl(..., multiple, dir)` | | `add_primitive_svg` | `.svg` | `GLGizmoSVG::create_volume(path, type)`: a new object, or a part of the selected one; a job | | `export_config` | existing directory | `ExportConfigsDialog(parent, dir)`: the dialog still opens, and its OK writes there | -| `install_local_plugin` | `.py`, `.whl` | `install_local_plugin_package(path, parent, message)`, the Plugins dialog's install: it still asks before replacing an installed plugin, in Orca's own "Overwrite Plugin" message dialog, which `dialog_respond` answers on every platform. Cancel makes the command an error saying that the plugin was not installed. A file that is not a `.py` or `.whl` is refused before that. A package that fails inspection or installation is an Error whose message is "Plugin installation failed:" and the reason, such as a `.py` without a name in its PEP 723 `[tool.orcaslicer.plugin]` table | +| `install_local_plugin` | `.py`, `.whl` | `install_local_plugin_package(path, parent, message)`, the Plugins dialog's install: it still asks before replacing an installed plugin, in Orca's own "Overwrite Plugin" message dialog, which `answer_dialog` answers on every platform. Cancel makes the command an error saying that the plugin was not installed. A file that is not a `.py` or `.whl` is refused before that. A package that fails inspection or installation is an Error whose message is "Plugin installation failed:" and the reason, such as a `.py` without a name in its PEP 723 `[tool.orcaslicer.plugin]` table | The six shape commands (`add_primitive_cube`, `_cylinder`, `_sphere`, `_cone`, `_disc`, `_torus`) take a `Text` param, the size the Primitive size dialog asks for (`"40 40 10"`, `"90 4"`), and then @@ -1335,7 +1342,7 @@ with the wrong count of positive numbers is an Error result. With an object sele nothing (`ObjectList::can_add_shape_object()`), and say so as an Error, in the palette too. The object structure commands stand for the object list's context-menu items and the plate menu's -Order By. Like those items, they act on the object list's selected rows, which `select` sets: +Order By. Like those items, they act on the object list's selected rows, which `select_objects` sets: | Command | Param | Entry point | Refused when | |---|---|---|---| @@ -1387,8 +1394,8 @@ the printer first. A `.gcode` still loads the settings it was sliced with throug `export_config` with a directory still opens the Export Preset Bundle dialog, given that directory: its OK writes there instead of asking for a folder. The agent picks the kind by clicking its label -(`ui_click`), checks presets with `ui_input` on their checkboxes, which are named after the preset, printer -or filament they stand for, presses OK with `dialog_respond`, and answers the result message. The command +(`click`), checks presets with `set_widget_value` on their checkboxes, which are named after the preset, printer +or filament they stand for, presses OK with `answer_dialog`, and answers the result message. The command is an Error when the dialog is closed without exporting. Preset files are not exported without the dialog: its archive functions read its own checkboxes. @@ -1411,7 +1418,7 @@ Most features need only a Speed Dial command: 3. If the effect finishes in the background after `run()` returns, set `CommandCompletion::Export` so that `run_action` waits for the file. -The command then appears in the palette, in `list_actions` and `run_action`, and in scripts. +The command then appears in the palette, in `search_actions` and `run_action`, and in replays. When an agent needs structured arguments or results, or has to wait for the effect, add a typed tool to the matching `McpTools*.cpp`. Use `inspect_tool()` for pure observation, which runs inline, @@ -1429,7 +1436,7 @@ operation (see Worker jobs). Describe the tool in English, including what the re ## GUI automation -`ui_snapshot` (`UiInspector`) returns a compact text tree of the shown top-level windows, each +`list_widgets` (`UiInspector`) returns a compact text tree of the shown top-level windows, each followed by the popups that opened from it, the rows of their lists, the menus, the GL toolbar items and gizmos, and each canvas's last-frame ImGui items, capped by `max_nodes` and filtered by `query`. The tree is a second text block of the result, and each shown web page's elements are listed under @@ -1441,7 +1448,7 @@ option's definition. Failing that, the label to its left on the same row names i tooltip. A control's state reads `[checked]` or `[unchecked]`, or `[mixed]` for a checkbox that shows neither (a three-state one undetermined, Orca's `CheckBox` half-checked for an unset nullable setting). An option of a selector Orca builds of buttons (`RadioGroup`, `TabCtrl`, `MultiSwitchButton`) -is a button that reads checked while it is the selected one (`selector_option()`), so `ui_input true` +is a button that reads checked while it is the selected one (`selector_option()`), so `set_widget_value true` selects it, and a `SwitchButton` with a label at each end has the one it is on as its value. Input tools take a `target`: a ref (also read written as `{ref: "w12"}`), or a locator, which is @@ -1459,15 +1466,15 @@ stable across runs and is what the journal stores. A locator is one of: - `{web: "Next", kind, css, within, index}` for an element of a web page, by its label, kind or a CSS selector (see Web pages below). -`select` selects objects, instances and parts and replies with the selection as `get_state.selection` -gives it (`selection_state()`): in `select`'s own indices, the objects, the instances they are selected +`select_objects` selects objects, instances and parts and replies with the selection as `get_app_state.selection` +gives it (`selection_state()`): in `select_objects`'s own indices, the objects, the instances they are selected in and, when the selection holds parts rather than whole instances, those parts. An agent reads it before an operation that acts on the selection: `run_action` runs the object operations the catalog has (delete, split, mirror, center, drop, instances, arrange, orient, change type, rename, assemble, set as individual objects, order by), and `set_settings` with the object or volume scope edits their settings and filament. `add_part` adds parts, modifiers and support shapes, -`set_layer_ranges` sets height range modifiers, and `set_layer_height_profile` runs the Variable layer -height panel's buttons. `set_layer_gcode` does what the Preview layer slider's right-click menu does. +`set_height_ranges` sets height range modifiers, and `set_variable_layer_height` runs the Variable layer +height panel's buttons. `set_custom_gcode_at_layer` does what the Preview layer slider's right-click menu does. The rest of the object menu is reached through a right click on the object in the 3D view, or on its row of the object list, with `popup_item` (see Menus below). @@ -1486,17 +1493,17 @@ gestures and ImGui items get synthesized wx events with a render between steps. plain window gets the context menu event a person's would: on macOS wx makes it from the right press the window's handlers pass on, elsewhere the system sends it, so the click sends it there. A GL toolbar item's visibility and enabled state are brought up to date (`GLToolbar::update_items_state()`, what the -canvas's idle handler does) before `ui_snapshot` lists them and before a click checks them, so an -item a `select` just enabled is not read as disabled. A click on an ImGui item whose centre lies +canvas's idle handler does) before `list_widgets` lists them and before a click checks them, so an +item a `select_objects` just enabled is not read as disabled. A click on an ImGui item whose centre lies under another ImGui window (a notification over a panel's button) is refused, naming that window. `ImGuiWrapper::set_item_recording()` supplies the ImGui items (see below). `SyntheticInput` holds a gesture's keys, buttons and pointer for code that reads hardware state through `get_key_state()` and `get_mouse_state()`: the canvas, gizmos, and the object list's Ctrl/Shift multi-select. Mouse -modifiers take the names `ui_key` chords use, through `KeyChord::parse_modifier()`, so `ctrl` means +modifiers take the names `press_keys` chords use, through `KeyChord::parse_modifier()`, so `ctrl` means the shortcut modifier (Command on macOS) in both, and `rawctrl` the macOS Control key. Held -keys are released however the gesture ends; a `ui_mouse` `down` keeps its button held, and a +keys are released however the gesture ends; a `mouse_gesture` `down` keeps its button held, and a `move` drags with it, until an `up`, another gesture (one that fails included; a request the server -rejects for its arguments never runs and changes nothing), the end of the script that pressed it, +rejects for its arguments never runs and changes nothing), the end of the replay or script that pressed it, the closing of the endpoint for a client's press, or the service's stop. A client's gesture that reaches the UI thread after its endpoint closed is refused. Keys without a target go to the focused window inside the topmost modal, else that modal, else the focused window, else the 3D view @@ -1510,26 +1517,26 @@ its own hook sees the keys sent to its widgets, as the Design tab's does for Esc tool shortcuts, and the main frame's hook still sees what none below it takes. The Design tab's view is a `GLCanvas3D` of its own (`DesignCanvas::gl_canvas()`), outside the -plater's three. `live_canvases()` lists the plater's, which `get_state.gizmo` and the idle checks -read, since the Design view has no gizmos; `ui_canvases()` adds the Design view for what the `ui_*` -tools and screenshots reach: `ui_snapshot` lists its ImGui items, `ui_click` and `ui_key` act on it, -and `ui_mouse` takes `canvas: "design"` (`"current"` is the view shown, `shown_canvas()`). A click +plater's three. `live_canvases()` lists the plater's, which `get_app_state.gizmo` and the idle checks +read, since the Design view has no gizmos; `ui_canvases()` adds the Design view for what `list_widgets`, the input +tools and screenshots reach: `list_widgets` lists its ImGui items, `click` and `press_keys` act on it, +and `mouse_gesture` takes `canvas: "design"` (`"current"` is the view shown, `shown_canvas()`). A click there goes to the Design view's own handlers, so a left click picks a face, edge or body and a right click opens the offer menu, which is listed or run like any other. Points of the model name -Prepare's objects, so on the Design view `ui_mouse` takes pixels only; `cad_call query_topology` +Prepare's objects, so on the Design view `mouse_gesture` takes pixels only; `call_cad_tool query_topology` gives its faces. ### Windows -`list_windows` (`UiInspector::windows()`) lists the open windows without their widgets, in `ui_snapshot`'s +`list_windows` (`UiInspector::windows()`) lists the open windows without their widgets, in `list_widgets`'s order: the main window, the windows that don't block in the order they were created, then the modal stack, the topmost last. wx keeps top-level windows in creation order, not stacking order, so only the -modal stack orders by what is on top. Each window has the ref `ui_snapshot` gives its node, with the same -locator, so `screenshot` captures that window by it, `ui_snapshot` takes it as `root`, the input tools as +modal stack orders by what is on top. Each window has the ref `list_widgets` gives its node, with the same +locator, so `screenshot` captures that window by it, `list_widgets` takes it as `root`, the input tools as `target`, and the journal records the locator; its title is what `within` takes. A window says whether it is modal and whether it shows a web view (outside a hidden pane), with its size and, where the platform knows it (not Wayland, `window_positions_known()`), its place on screen. A native dialog of the modal -stack, which only `dialog_respond` reaches, is listed with `native` and no ref, whether or not wx reports +stack, which only `answer_dialog` reaches, is listed with `native` and no ref, whether or not wx reports it shown. A window named `kHiddenFromAutomation` is listed by its title and kind with `hidden` and nothing more: without a ref no tool acts on it, and an agent learns why a window it was told about is out of its reach. The Python scripts window is the one modal window the tracker leaves off its stack, so it is @@ -1552,8 +1559,8 @@ another, shows its menu, and a call working inside that dialog has a window of i The capture does what `wxWindowBase::PopupMenu()` does before it shows a menu: it sets the invoking window and calls `UpdateUI()`, so the `wxEVT_UPDATE_UI` handlers MenuFactory binds on the main frame -set each item's enabled and checked state as a person would see them. `ui_click`, `ui_mouse` and -`ui_key` arm a capture in the closure that delivers their input (`arm_menu()`). The first menu that +set each item's enabled and checked state as a person would see them. `click`, `mouse_gesture` and +`press_keys` arm a capture in the closure that delivers their input (`arm_menu()`). The first menu that opens goes to it: without `popup_item` it is listed in the reply as `popup_menu` (`items`, and the `disabled` and `checked` ones) and nothing runs, as if the person pressed Escape; with one, that item runs: a check item is toggled or a radio item checked, then `SendEvent()` on the submenu holding it, @@ -1564,9 +1571,9 @@ command that opens a dialog from the 3D view's queued right click leaves it open returns; the reply then lists it under `dialogs`. The call waits for that queued click by queuing a `CallAfter` on the canvas behind it (one handler's queue is first in, first out) before it settles and reads the capture. A later menu in the same call is closed unseen and counted (`menus_closed`); -a menu that opens in a window where nothing is armed (a `cad_call run_verb` whose offer opens later) +a menu that opens in a window where nothing is armed (a `call_cad_tool run_verb` whose offer opens later) is closed unseen too. The last three such menus, with the tool whose window took them, are in -`get_state.closed_menus`. +`get_app_state.closed_menus`. A menu path is the item labels joined with `>`, as `GetItemLabelText()` gives them, matched without case; a trailing `...` may be left out. A label repeated among its siblings is numbered from its @@ -1576,7 +1583,7 @@ the numbering and the matching, so a path recorded with another slot in use stil item. A path that names a submenu, a disabled item or nothing fails with the items to pick from, and so does a `popup_item` when the input opened no menu (a right click on empty space while objects are selected, in the Preview, or with a gizmo open). Paths are the UI language's text, as other locators -are. With `x`/`y`, `ui_click` clicks that point of a custom-drawn widget (such as the Design tab's +are. With `x`/`y`, `click` clicks that point of a custom-drawn widget (such as the Design tab's feature tree) as well as of a 3D canvas; a native control, which acts on what the system tells it rather than on wx mouse events, is refused. @@ -1630,7 +1637,7 @@ native list starts editing an editable icon cell instead, which the object list actions, so a click that names such a column sends `wxEVT_DATAVIEW_ITEM_EDITING_STARTED` too. A double click sends `wxEVT_DATAVIEW_ITEM_ACTIVATED` (the object list frames the object, or opens the filament editor on the Filament column), a right click `wxEVT_DATAVIEW_ITEM_CONTEXT_MENU`, whose menu -is captured like any other. `ui_input` with true or false sets a checkbox cell through +is captured like any other. `set_widget_value` with true or false sets a checkbox cell through `ChangeValue()`, as the toggle renderer does, which tells the owner. A list box row is selected with `wxEVT_LISTBOX` and a checklist row ticked with `wxEVT_CHECKLISTBOX`; a drop-down row is picked with `DropDown::ClickItem()`, which does what a release over it does; a table row's cell is made current @@ -1639,7 +1646,7 @@ object scope writes the same values. A Design list row is clicked at its centre, icon whose tooltip `column` gives, through the list's own mouse handlers. Popups (`wxPopupWindow`: the print button's menu, drop-down lists) report themselves top-level but -are children of the window they opened from. `ui_snapshot` lists each shown one as a `popup` right +are children of the window they opened from. `list_widgets` lists each shown one as a `popup` right after its window (`popups_of()`), and `root: "popup"` lists only them. A widget in a popup belongs to that window (`owning_window()`), so it is inside the topmost modal for the input guards when its popup opened from there, and its locator's `within` names that window. A screenshot of a widget in @@ -1649,7 +1656,7 @@ a popup is refused: a screenshot of its window shows the popup. A plate and its icons in the Prepare view (delete, orient, arrange, lock, settings, name, move to front, filament grouping, IDEX mode) are GL picking models, which a person reaches only by pointing at -them. `ui_snapshot` lists under the Prepare canvas a `plate_icon` node for each plate, named as the +them. `list_widgets` lists under the Prepare canvas a `plate_icon` node for each plate, named as the object list names it, then the icons of the current plate; the lock icon carries the plate's lock state. A locator `{plate_icon, plate}` names any plate's icon by the picking action `PartPlate` gives it: `plate` (the plate itself), `delete`, `orient`, `arrange`, `lock`, `settings`, `name`, @@ -1699,7 +1706,7 @@ a reorder it names the control now in its place. Call sites give each control a through the code's own click test. Nothing about the controls changes for a person, and the call costs one branch while recording is off. -`ui_snapshot` lists each ImGui window (its scroll range when it scrolls), then its items and text in +`list_widgets` lists each ImGui window (its scroll range when it scrolls), then its items and text in reading order. An item is listed by its shown label, or, for a field with none, by the text left of it on its row, which only the first field after that text takes; its name is the one it was given or its label's `##` part (`##cursor_radius` → `cursor_radius`). Orca's icon glyphs are not label text. @@ -1711,7 +1718,7 @@ windows it is a child of, to bring it into view (`SetScrollFromPosY()`, then two draws no item for rows out of view, such as Texture Displacement's library, is scrolled with the mouse wheel over its window, as a person does. -`ui_input` on an ImGui item acts by its kind and reads the value back, failing when the field shows +`set_widget_value` on an ImGui item acts by its kind and reads the value back, failing when the field shows something else (numbers compared at the precision it prints): a checkbox, radio button or named toggle is clicked when its state differs; an input is clicked, its text selected and replaced, then Return pressed; a multiline input gets Return only between lines; a drag or a slider that takes @@ -1723,18 +1730,18 @@ A gizmo is listed per canvas as its toolbar shows it (`GLGizmosManager::is_on_to on the Prepare canvas Simplify and SVG too while they can open (Simplify when activable, SVG on a selected SVG part). Clicking one does what its icon does (`click_toolbar_icon()`): it opens, or closes the open one; Text with no text selected starts a job that creates a text part and opens the -gizmo, which `ui_click` waits for. A `gizmo` locator takes the name `get_state.gizmo` gives, or +gizmo, which `click` waits for. A `gizmo` locator takes the name `get_app_state.gizmo` gives, or the English title of its toolbar button where that differs (Support Painting for FdmSupports), in -any case; the reply uses the first, and an unknown name's error lists them. `get_state.gizmo` +any case; the reply uses the first, and an unknown name's error lists them. `get_app_state.gizmo` names the open gizmo and its canvas. The assemble view is entered and left with `set_view view` (leaving does what its Return button does; entering returns once the canvas has loaded its objects, which waits for its GL surface on Wayland), -and `select` and `list_objects` act on it while it is shown. Grabbers are not dragged: a gizmo's -panel fields or `transform` set those values. Pickers inside a gizmo go through `gizmo_file`, whose +and `select_objects` and `list_objects` act on it while it is shown. Grabbers are not dragged: a gizmo's +panel fields or `transform` set those values. Pickers inside a gizmo go through `pick_gizmo_file`, whose actions are the bodies of those pickers (`GLGizmoSVG::change_file()`, `save_svg_as()`, `GLGizmoTextureDisplacement::import_texture()`). -`ui_mouse` takes points of the model (`CanvasTarget`): `{object, instance, volume}` with `point` in +`mouse_gesture` takes points of the model (`CanvasTarget`): `{object, instance, volume}` with `point` in the part's mesh coordinates (`frame: "volume"`, mapped by `GLVolume::world_matrix()`, which follows the assemble view's offset and explosion) or in the scene's (`"world"`), or `spot`, where a ray along an axis through the part's displayed bounding box first meets it. A point is projected through the @@ -1764,7 +1771,7 @@ its position so the result is the same on every install; it is how an agent look named directions, which the bench showed agents otherwise reach by dragging the canvas edge on the assumption that the left button rotates. A painting gizmo (`GLGizmoPainterBase`) takes a press only where the cursor hits the object it paints; a press that misses falls through to the canvas and moves -the camera, and the stroke paints nothing. `ui_mouse` refuses a down or drag that starts there, +the camera, and the stroke paints nothing. `mouse_gesture` refuses a down or drag that starts there, testing the start pixel's ray against the selected instance's parts, so a misaimed stroke fails instead of silently turning the view under the screenshot the agent aimed from. The refusal names the first pixel along the stroke that lands on the object, so a stroke swept in from outside it is @@ -1773,7 +1780,7 @@ moves the camera anyway (a drag off the model outside the painters, a wheel) say `camera_moved` in its reply, compared from the view matrix and zoom before and after. Every point of a -gesture is resolved before its first event, and the journal keeps the model points, so a script +gesture is resolved before its first event, and the journal keeps the model points, so a replay replays at another window size or camera. A gesture's modifiers are pressed as a keyboard does: a key-down event each before it and a key-up after, which is what switches Measure and Assembly to point picking and the painters to their Shift and Alt modes. @@ -1782,7 +1789,7 @@ point picking and the painters to their Shift and Alt modes. `ModalTracker`, a `wxModalDialogHook`, sees every `ShowModal()`, native dialogs included, and publishes the snapshot `[{title, message, class, native, buttons}]`, which other threads read. Read on -the UI thread, as `get_state`, the `blocked_by_dialog` probe, the guards' refusals and the input tools' +the UI thread, as `get_app_state`, the `blocked_by_dialog` probe, the guards' refusals and the input tools' `dialogs` read it, the snapshot describes the open dialogs again first. So it shows a dialog as it is now: text the dialog filled in once it showed (a printer's name, a list from a scan), a field typed in, a page switched. Should describing fail, the last description stands. Only a native dialog that holds @@ -1790,13 +1797,13 @@ the UI thread (macOS) leaves readers with the description published before it; i change. A dialog that can't be described is listed by its title, class, `native` and `web` flags, with no message or buttons, so the guards still see it and a rule matches it by its title. Message boxes and file and folder pickers are native; a box's message is its text, and a picker's is its prompt, such as "Choose Download Directory", since its title is often empty. Colour and -font choosers are not classified as native, because on GTK they are wx dialogs that `dialog_respond` -ends; on macOS and Windows they are OS choosers, best answered ahead with a `dialog_auto_answer` rule. +font choosers are not classified as native, because on GTK they are wx dialogs that `answer_dialog` +ends; on macOS and Windows they are OS choosers, best answered ahead with an `auto_answer_dialogs` rule. A wx dialog's message reads it as a person does, so an agent can tell what the dialog asks and what each button will do without a screenshot (`DialogReader`). Each shown child becomes a cell. Nested dialogs, popups, web views and canvases are left out; a nested dialog is described on its own. -Controls are read through the readers `ui_snapshot` uses (`kind_of`, `value_of`, `checked_of`, +Controls are read through the readers `list_widgets` uses (`kind_of`, `value_of`, `checked_of`, `selector_choices`, `list_rows`), so the two say the same about each one: - Static text, html and custom widgets that show a label (`StaticLine` titles) read as their text, and @@ -1811,7 +1818,7 @@ Controls are read through the readers `ui_snapshot` uses (`kind_of`, `value_of`, - A selector Orca builds of buttons (`RadioGroup`, `TabCtrl`, `MultiSwitchButton`), a `SwitchButton` with a label at each end, and a notebook's tabs read as one line, `(*) A | ( ) B`; an icon option reads as its tooltip. A notebook's tabs are followed by the page shown. -- A list reads one line per shown row, up to 25, then a line saying `ui_snapshot` lists the rest. +- A list reads one line per shown row, up to 25, then a line saying `list_widgets` lists the rest. - A gauge reads `[45%]`. - A disabled control adds ` (disabled)`. Disabled is judged between the control and its dialog, so a dialog under another modal does not read as all disabled. @@ -1860,14 +1867,14 @@ label. Web dialogs are read through their page (below). `buttons` lists the wx buttons a dialog shows, with `enabled: false` for a disabled one. The options of a selector made of buttons (`RadioGroup`, `TabCtrl`, `MultiSwitchButton`) are not listed, since pressing -one only selects it. `dialog_respond`, and a rule, still find such an option by its label (its tooltip +one only selects it. `answer_dialog`, and a rule, still find such an option by its label (its tooltip for an icon option, in full even where a message cut at its cap shows only its start) and select it, and -`ui_snapshot` shows the selected option checked, under the same full label. `ui_input false` on the +`list_widgets` shows the selected option checked, under the same full label. `set_widget_value false` on the selected one, or on a selected radio button or radio box, is refused, since an option is unselected by selecting another. Other radio buttons and switches are set -with `ui_click` or `ui_input true`, and notebook tabs with `ui_click` on the tab. +with `click` or `set_widget_value true`, and notebook tabs with `click` on the tab. -`dialog_respond` presses the topmost wx dialog's button, so the dialog's own handler runs. +`answer_dialog` presses the topmost wx dialog's button, so the dialog's own handler runs. `press_dialog_button()` tells what it did: - **Pressed:** the button was pressed. @@ -1875,24 +1882,24 @@ with `ui_click` or `ui_input true`, and notebook tabs with `ui_click` on the tab without a Cancel button. One whose Cancel or Close is on a page it does not show ends the same way. - **Disabled:** the button is shown but disabled, so nothing is pressed or stood in for. The dialog disabled it on purpose: OK while a name is invalid, Send until a box is ticked, Cancel while a - cancel is under way. `dialog_respond` refuses a disabled button, its message showing what the dialog + cancel is under way. `answer_dialog` refuses a disabled button, its message showing what the dialog still needs. - **Hidden:** the button is only on a page the dialog does not show, such as a wizard's Finish, so - nothing is pressed or stood in for, and `dialog_respond` refuses it. Buttons are looked up among the + nothing is pressed or stood in for, and `answer_dialog` refuses it. Buttons are looked up among the dialog's own windows, not a popup's or a nested dialog's. - **Failed:** a native message box could not be pressed. -On Windows and Linux `dialog_respond` also presses an open native message box. The tracker lists the +On Windows and Linux `answer_dialog` also presses an open native message box. The tracker lists the buttons wx gives the box for its style (Yes and No or OK, and Cancel; not Help, which on Windows shows help without closing the box), and a press goes to the OS's box by message. On Windows that is a `WM_COMMAND` to a message box, or a `TDM_CLICK_BUTTON` to the task dialog wx shows where Windows has one, found among the UI thread's windows by class and caption, the active one first. On GTK it is `gtk_dialog_response()` on the dialog's widget. The box closes once its own loop runs again, which -`dialog_respond` waits up to 1 s for, so its reply says `closed`. A box that is no longer shown is +`answer_dialog` waits up to 1 s for, so its reply says `closed`. A box that is no longer shown is refused. This is how a plugin's permission prompt is answered. On macOS a message box lists no buttons, since no call reaches one (above). -A picker, and on macOS any native dialog, can only be answered ahead with a `dialog_auto_answer` rule: +A picker, and on macOS any native dialog, can only be answered ahead with an `auto_answer_dialogs` rule: a regex and a button. The regex is searched in three places: - the title and message joined by a newline @@ -1907,24 +1914,24 @@ showing the dialog, and logs it; a file or folder picker can only be cancelled, would return without a path. A wx dialog that matches a rule opens, and the tracker presses the button once the dialog's modal loop -runs (`press_dialog_button()`, queued on the dialog), as `dialog_respond` does. Its buttons do the +runs (`press_dialog_button()`, queued on the dialog), as `answer_dialog` does. Its buttons do the dialog's work in their handlers (`UnsavedChangesDialog`'s Transfer and Discard, `CloneDialog`'s Fill), which a returned id would skip. The rule counts as used once the press pressed the button or ended the dialog. A button disabled by then leaves the dialog open, logged, and a modal opened above it before -then leaves it to `dialog_respond`. +then leaves it to `answer_dialog`. -A new rule also answers a matching dialog that is already open, as `dialog_respond` would, a message +A new rule also answers a matching dialog that is already open, as `answer_dialog` would, a message box included where it can be pressed. The first rule that names one of its buttons decides: if that button is disabled or hidden, the dialog stays open and the reply says `disabled: true` or `hidden: true` (a hidden Cancel or Close ends the dialog, as above). A prompt posted around the same time, such as the restore prompt after startup, is handled whether it opens before or after -the rule. A script's rules end with the script, a client's call replaces its earlier rules, and -`get_state` lists the rules in force. +the rule. A replay's or script's rules end with it, a client's call replaces its earlier rules, and +`get_app_state` lists the rules in force. A dialog that hosts a web view is described with `web: true`; its controls are on its page, which -`ui_snapshot root=dialog` lists and the input tools drive like any widget (see Web pages below). It +`list_widgets root=dialog` lists and the input tools drive like any widget (see Web pages below). It has no text of its own, so a rule matches it by title. Its page is the one its shown web view holds; a web -view the dialog keeps hidden has no page to press on. `dialog_respond` looks a name or label up as a +view the dialog keeps hidden has no page to press on. `answer_dialog` looks a name or label up as a wx button label first, then among the page's buttons and links, waiting up to 3 s for one to show (each ask expires with those 3 s, so the page never presses one later), and clicks it there, hit tested as a click is, so the page's own handler runs (`{pressed: true, web: true}`). With no such @@ -1939,13 +1946,13 @@ only time a complete document is shown and restarts when the document changes, s bootstrap page replaced by its content is waited out; past it, or after 2 s with no web view shown, `cancel` and `close` end the dialog natively and any other answer gives up, logged. -`webview_eval` runs JavaScript in a page through its agent, as a recover call: in a web view of the +`run_javascript` runs JavaScript in a page through its agent, as a recover call: in a web view of the topmost modal dialog whatever the dialog, in one under it never, and elsewhere with a mutate call's checks. Without a target the topmost dialog's web view is used, else the only shown one; a web view's locator names it by kind (`class: "webview"`), since its class differs per platform, and a page -element's ref or locator runs the script in its page with the element bound to `el`. The job thread -waits up to `timeout_s` (default 10) without the UI; a JSON result comes back parsed, and the script -reports `closed`, `navigated` and `dialogs` as the input tools do. The agent runs the script through +element's ref or locator runs the code in its page with the element bound to `el`. The job thread +waits up to `timeout_s` (default 10) without the UI; a JSON result comes back parsed, and the call +reports `closed`, `navigated` and `dialogs` as the input tools do. The agent runs the code through `eval`, which a page whose Content-Security-Policy forbids it may refuse ("…forbids eval"), where the port holds injected scripts to the page's policy (WebView2 does not); the agent itself is installed as inline code, so the input tools work on such a page either way. @@ -1990,7 +1997,7 @@ hidden checkbox is listed as its label, and open shadow roots and same-origin fr navigation or reload changes, so a ref from before is stale ("the page changed"). Page lines have their own budget, `max_web_nodes` (default 300), so a large page never pushes widgets listed after it out of `max_nodes`. With a modal dialog open only the topmost dialog's pages are read, since no input -reaches the others, which get the note `behind a modal dialog`. `ui_snapshot` waits up to 2 s for a +reaches the others, which get the note `behind a modal dialog`. `list_widgets` waits up to 2 s for a page still loading, then reads every page at once, for up to 3 s together. A locator `{web, kind, css, within, index}` matches the label exactly, else case aside, else as a @@ -2006,14 +2013,14 @@ among the matches of every candidate page and its configuration frames, as a rep (`journal_index()`); with no `index` when one of them was not heard from (silent, failing the search or unable to run the agent) or the action took the element away, so a replay that finds several asks for one rather than taking another. A screenshot of a page element is journalled as one of its web view, which it -captures. A web view's own ref is no page element: `ui_click` and `ui_input` refuse it, pointing to -the page's elements, and `ui_key` sends to its page's focused element. +captures. A web view's own ref is no page element: `click` and `set_widget_value` refuse it, pointing to +the page's elements, and `press_keys` sends to its page's focused element. An action runs synchronously in one task of the page. The element is scrolled into view and hit tested: one covered at its centre is refused naming what covers it, a disabled one and a file input are refused. A click sends what a person's does — pointer and mouse over, down (focusing the element), up, then `click` — so the browser's default actions follow: a label reaches its control, a link -navigates, a submit button submits its form with itself as the submitter. `ui_input` sets a value +navigates, a submit button submits its form with itself as the submitter. `set_widget_value` sets a value through the element's own setter and sends `input` and `change`, which framework-controlled fields follow; a choice is picked by its option's text, a checkbox through a click, editable text through `insertText`. Keys go as `keydown`, `keypress`, the default action (text, Enter submitting the form @@ -2023,10 +2030,10 @@ fieldset's first legend keeps its controls), arrows in a radio group, Left/Right on a selection, to its start or end) and `keyup`; Ctrl is Command on macOS, as for widgets. A disabled target is refused, and a read-only field takes no text. In editable content where the editing command is unavailable or refuses (WebKit), the text goes in, or a character goes, at the selection -as the command would. `ui_mouse` gestures send pointer events from a synthetic pointer whose capture +as the command would. `mouse_gesture` gestures send pointer events from a synthetic pointer whose capture the agent emulates while it is pressed, as a canvas that captures the pointer (the colour picker's spectrum) needs; a `down`'s button and modifiers stay pressed through later moves until its `up`, or -until any other gesture, click, `dialog_respond` or auto-answer press, a widget's included and even +until any other gesture, click, `answer_dialog` or auto-answer press, a widget's included and even one the tool then refuses, releases them where they were pressed. A move or an `up` keeps a press only on the agent that holds it: a page's own, or one of its configuration frames', which are told apart, so an `up` on a frame's page ends a press in the frame. Each agent has one synthetic pointer, which every @@ -2042,7 +2049,7 @@ anything sent after it. An up that fails or times out ends nothing: past its dea not run it. The releases are asked all at once and get one second together, so a page that doesn't answer holds up none of the others, and the call still names the dialog it works in before the soft budget, past which an open dialog would read as what it waits on. Like the widgets' held -press, a page's belongs to the client or the script that made it: a script's ends with the script, +press, a page's belongs to the client, replay or script that made it: a replay's or script's ends with it, a client's when the endpoint closes, every one when the service stops, and a client's down sent after the endpoint closed is refused. These releases, and an auto-answer rule's before it presses a button, are made on the UI thread without waiting (`release_web_presses()`) and with no deadline, @@ -2056,7 +2063,7 @@ a read-only number field as it is. Coordinates map between logical and CSS pixel scale factor. A page closes its dialog by a message to the host (`window.wx`, `chrome.webview`, a WebKit message -handler), which ends the modal loop and destroys the web view. So while an action or a script runs, +handler), which ends the modal loop and destroys the web view. So while an action, a replay or a script runs, the page's messages are held, even through a reference to the channel kept from before, and posted in order once it has returned. The tool then waits up to 1 s for the page to have posted them, lets wx run their events, and looks for 300 ms at what followed: the web view destroyed or its dialog off the @@ -2067,7 +2074,7 @@ after the action (a fragment change, which WebView2 reports no URL for on a page once the 300 ms have passed, by asking the page for its document's token, which a reload or a form posted to the same URL changes; not by `IsBusy()`, which WebView2 also reports while a page only works. Failing those, the reply's `page` says what the action changed on its page: the page outlines -itself before the action, a line per element (with its value, state and the notes `ui_snapshot` +itself before the action, a line per element (with its value, state and the notes `list_widgets` gives it, such as a select's options) and per run of text, under an id the tool gives the action, and is asked afterwards which lines it lists now that it did not (`added`) and which it no longer lists (`removed`), counted as a multiset so an element rebuilt as it was, or text that moved, is no @@ -2081,7 +2088,7 @@ worked, and `posted` how many messages the page itself sent the host meanwhile, handler say. An outline is dropped once compared, and a page keeps at most 16, none past a minute. A change that comes later is the next snapshot's to show. -A URL a reply shows (`navigated`'s, `webview_eval`'s, a web view's value in `ui_snapshot`) reads +A URL a reply shows (`navigated`'s, `run_javascript`'s, a web view's value in `list_widgets`) reads `REDACTED` for the user info of its authority and for the value of each query or fragment parameter one of whose name's words names a credential (`token`, `key`, `secret`, `password`, `auth`, `session`, `signature`, `code` and the like; `redact_url()`), after OpenTelemetry's rule for URLs in telemetry. @@ -2113,7 +2120,7 @@ Limits: a web view in a popup window is not read, which in Orca is the setting t (`MarkdownTip`, a transient popup); a dialog whose web view is hidden is answered as a wx dialog; a page element's screenshot captures its whole web view, not a crop of the element; points in a frame that a CSS transform or zoom scales are where the untransformed frame would put them; a page button -whose handler outlasts `dialog_respond`'s 3 s may still be running when `cancel` or `close` ends the +whose handler outlasts `answer_dialog`'s 3 s may still be running when `cancel` or `close` ends the dialog natively; cross-origin frames other than plugin configuration UIs are listed but not read. ## Screenshots @@ -2243,11 +2250,11 @@ block is scaled to `max_dim` on the long edge (default 1280, clamped to 256–20 ## Recording -`start_recording` records what OrcaSlicer shows into a video while an agent, a script or a person +`start_recording` records what OrcaSlicer shows into a video while an agent, a replay, a script or a person works, and `encode_recording` turns it into an MP4 to attach to an issue. Recording has to stay light, since it runs while the app works: frames are kept as JPEG in a Matroska file (MJPEG), and the H.265 encode, which costs far more, comes after it. There is no audio. `McpRecorder` holds at most one -recording; `get_state.recording` shows it while it runs. +recording; `get_app_state.recording` shows it while it runs. **Capture.** The UI thread captures a frame per tick of a one-shot `wxTimer`, which fires inside modal loops too. `start_recording` takes the first frame in its own UI closure: it fixes the video's @@ -2265,8 +2272,8 @@ reads the screen (`Capture::from_screen`: X11, and macOS's window-server capture windows over the main window as they are, modeless ones and native pickers included (a native message box, an in-process panel, should show too; OrcaSlicer raises none on demand on macOS to check), and nothing more is composited; the frame decides, so a macOS recording that falls back to drawing views composites them -from then on. Popups reaching past the window are cut at its edge, as everywhere. X11 shows the script -runner when it covers the window (a reparenting window manager's frame is searched for our window inside +from then on. Popups reaching past the window are cut at its edge, as everywhere. X11 shows Action +Replay when it covers the window (a reparenting window manager's frame is searched for our window inside it); macOS leaves it out. The capture records the rectangles it drew another of our windows in (`Capture::covered`) and composites the 3D views everywhere else, so they are not pasted over those windows (screenshots get this too). A macOS @@ -2316,14 +2323,14 @@ real, uneven times; one file rather than a folder of JPEGs because it plays as i **Ending.** `stop_recording` first captures one more frame in a UI closure, when the UI thread can run it, so the last call's effect is in the video even if the timer has not ticked since. A recording ends on `stop_recording`, after `max_seconds`, at 4 GiB, on a write error, when -the script that started it ends (`run_script_job()`, which names a file still being written after 30 s +the replay or script that started it ends (`run_replay_job()`, which names a file still being written after 30 s as the result's `unfinished_recording`), when the endpoint closes for a client's -(`stop_serving()`; a script's carries on), and at exit. Ending from any thread sets a flag the next tick +(`stop_serving()`; a run's carries on), and at exit. Ending from any thread sets a flag the next tick reads, tells the sink to finish, and posts the timer and input filter's cleanup to the UI thread; the sink drains its queue, writes the last frame again at the end time so the video lasts until then, -closes the file and calls back, on its own thread. So ending never needs a UI round trip: a script's -end waits for the file without deadlocking against `McpService::stop()`, which joins script threads on -the UI thread, and a step after the script sees a closed file. At exit `stop()` waits 5 s for the +closes the file and calls back, on its own thread. So ending never needs a UI round trip: a run's +end waits for the file without deadlocking against `McpService::stop()`, which joins run threads on +the UI thread, and a step after the replay sees a closed file. At exit `stop()` waits 5 s for the file, then drops what is still queued and leaves the sink to its threads, which own its state. A recording counts as active until its file is closed, for the one-at-a-time rule and for encodes. @@ -2350,10 +2357,10 @@ one recording, and with `silent` starts at once without the dialog and remembers that would encode without an ffmpeg is refused rather than recording unencoded. The encode is `encode_recording` itself, run by `McpService::encode_when_closed()` as an unjournaled job once the recording's file is closed (`McpRecorder::wait_closed()`), so it can be cancelled like any encode. No reply -names the job, which only exists once the file is closed: an agent finds it in `get_state.jobs` and waits +names the job, which only exists once the file is closed: an agent finds it in `get_app_state.jobs` and waits for it by its id, as the command's description says. Start Recording starts the service without its endpoint when the server is off, as Action Replay and the -Run Script panel do. The person's recording has its own owner (`kPersonOwner`), so neither a script's end nor the +Run Script panel do. The person's recording has its own owner (`kPersonOwner`), so neither a run's end nor the endpoint closing ends it. Whatever ends it tells the person where it went, in a notification whose button opens the folder: Stop Recording itself, which stops any recording, an agent's too, ending it as `stopped_in_app`; or `RecordingOptions::ended`, which the recorder runs on the UI thread when an agent's @@ -2373,16 +2380,16 @@ dot changed is queued. **Captions.** `McpCore` reports each call it runs to a `CallObserver`: when its handler starts, when `set_journal_args()` replaces its arguments (refs become locators), and its final result (a job's, worker job included). Calls refused before they run are not reported. The recorder captions calls -that are not `Inspect` (mutate and recover tools, script steps included) as the tool's translated +that are not `Inspect` (mutate and recover tools, replay steps included) as the tool's translated title and what it acts on (`caption_detail()`), with a mark: a ring while it runs, then a dot, red with the failure's first line, from which `caption_error()` takes out every value the caption hides. One caption shows at a time, the current call's (`CaptionBoard::current()`): of the calls that run or -linger (4 s after they end, then fading), the one started last, so a script's steps replace one another -and a script still running between them shows again once its step has faded. Clicks and keys are not +linger (4 s after they end, then fading), the one started last, so a replay's steps replace one another +and a replay still running between them shows again once its step has faded. Clicks and keys are not captioned. With `pointer`, a `wxEventFilter` sees every mouse and click-type command event, a person's and the ones the GUI tools synthesize alike: mouse events move the pointer, presses add a ripple, and a button, checkbox, toggle or radio command with no press on it just before is a click made without the -mouse (`ui_click`), shown at the control's centre. Events in windows the frame doesn't show, and in +mouse (`click`), shown at the control's centre. Events in windows the frame doesn't show, and in windows hidden from automation, are ignored. Both are off unless asked for, `captions` and `pointer` turning on one each; without the pointer no filter is installed. @@ -2400,9 +2407,9 @@ only when it changes, as a coverage mask (`wxMemoryDC`, white on black) the enco What a caption adds must not leak secrets, although the screen itself shows whatever its fields show. A setting whose key names a password, API key, access code, token or secret (`is_sensitive_key()`; -`printhost_apikey` is a plain text field) shows `•••` for its value; `ui_input` shows its value only +`printhost_apikey` is a plain text field) shows `•••` for its value; `set_widget_value` shows its value only for a non-sensitive setting located by its key, since a field located by its label, or a ref not yet -resolved, may be a password box; and `ui_key` shows its chord, never its text. +resolved, may be a password box; and `press_keys` shows its chord, never its text. **Encoding.** The bundled FFmpeg only decodes, so `encode_recording` runs the system `ffmpeg`: `ORCA_FFMPEG`, else `PATH`, else on macOS the Homebrew and MacPorts folders, which an app started from @@ -2418,7 +2425,7 @@ falls to almost nothing while the window is still and rises for the motion, wher spend it evenly; the video's length in the reply is the MP4's movie header's (`mp4_duration()`); an ffmpeg without the encoder is refused, naming what is needed. It runs without a console window, polled every 100 ms and terminated when the call is cancelled -(`ToolDef::cancellable`: `cancel {job}` stops it through `McpService::request_stop()`). On Windows it is +(`ToolDef::cancellable`: `cancel_job {job}` stops it through `McpService::request_stop()`). On Windows it is ended with `TerminateProcess()` on its handle and waited for on that handle, since `TerminateProcess()` returns before the process is gone and boost's `terminate()` closes the handle right after it; a child not gone within 5 s keeps its files, which the error names, and its source and destination stay reserved for @@ -2432,7 +2439,7 @@ only a recording this session made. ## Preview data -`get_preview` reads what the Preview shows for a plate without selecting the plate. Its tables +`get_slice_stats` reads what the Preview shows for a plate without selecting the plate. Its tables come from the plate's `gcode_statistics_json()`, the serializer behind the slice reply's statistics and the exported `statistics.json`, which sums the moves as the legend does: `summary` is the slice reply's `plate_summary()` with the prepare and travel times and the travel distance; `features` has @@ -2440,7 +2447,7 @@ each feature type's seconds, share of the normal-mode print time and grams, keye `;FEATURE:` names (`ExtrusionEntity::role_to_string()`), and a `Travel` row (the shares leave out retractions, wipes, Z moves, tool changes and the prepare time, as the legend's do); `layers`, paged, numbers layers as the slider's value (G-code layer index + 1, which `set_view {layer}` and -`get_state.preview` use) and carries each one's Z, so tools that number layers by the slider's label +`get_app_state.preview` use) and carries each one's Z, so tools that number layers by the slider's label can be joined on Z. `objects` lists the G-code's object instances, which it names by object and instance number; an entry gets the `list_objects` index only when one model object has that name. The wx-free shaping (`preview_features()`, `preview_layers()`, `preview_objects()`) is unit tested. @@ -2453,7 +2460,7 @@ the layer slider's range with its Z, which feature types and options are visible type's colour range. The viewer recomputes ranges at its next frame after a legend change, so the closure draws the Preview first; the ranges span the whole print but count travels, wipes and Custom extrusions only while those rows are shown. For another plate `view` is null and a `note` says how to -show it. `get_state.preview` is the same state without the legend, or null when the Preview holds no +show it. `get_app_state.preview` is the same state without the legend, or null when the Preview holds no toolpaths of the current plate. The tool refuses while anything slices or exports (`Plater::is_slicing_any()`), since a worker may be @@ -2470,7 +2477,7 @@ thread, about 15 ms on a plate of 4 million moves. the Preview as the same clicks would. Picking a view type therefore shows every feature type again when it is Line Type, and is written to the app config as `preview_last_view_type`, which the "Last used" preview default restores. Before a slice there is no legend to pick from, and `view_type` only -sets the type the next toolpaths show. `legend` names rows as `get_preview` lists them, in any case +sets the type the next toolpaths show. `legend` names rows as `get_slice_stats` lists them, in any case and with `_` or a space between words, and clicks a row only when its state differs. Hiding a row the print lacks, a feature type or option some other print has, does nothing, since agents hiding everything but one feature name rows from the whole list. The viewer keeps one visibility set, so feature types can be set @@ -2488,7 +2495,7 @@ Sending G-code to a print host (OctoPrint, Moonraker, PrusaLink, Duet and the ot `PrintHost::get_print_host()`) goes through the GUI's own dialog. The Speed Dial command `send_gcode` ("Send G-code to printer host", the dialog's title) calls `Plater::send_gcode_legacy()`, which the Print button calls for such a printer: it opens the Send dialog, whose file name an agent -sets with `ui_input` and whose Upload or Upload and Print button it presses with `dialog_respond`. +sets with `set_widget_value` and whose Upload or Upload and Print button it presses with `answer_dialog`. The plate is then sliced if needed, its G-code exported in the background process, and the upload queued. Host settings are printer settings (`host_type`, `print_host`, `printhost_apikey`, and `bbl_use_printhost` on a Bambu printer), written with `set_settings {scope: "printer"}`. Where the @@ -2497,13 +2504,13 @@ through the Bambu network or printer agents (`PresetBundle::use_bbl_network()`, `use_printer_agents`), or has no `print_host`, the condition `MainFrame::can_send_gcode()` gives the button. It is journaled like any `run_action`, so a replay uploads again. -`get_state.uploads` lists the session's rows of the upload queue (`PrintHostQueueDialog`), as the +`get_app_state.uploads` lists the session's rows of the upload queue (`PrintHostQueueDialog`), as the queue window shows them: `id` (its ID column, from 1), `state` (`queued`, `uploading`, `error`, `cancelling`, `cancelled` or `completed`), `progress` (percent), `host`, `filename`, and `error`, the queue's message, when there is one. Uploads a person started are listed too, so an agent can wait for any of them by polling. A failed upload also opens the queue's error dialog (`PrintHostQueueDialog::on_error()`), which blocks changes until it is closed with -`dialog_respond`. +`answer_dialog`. Two properties of the queue make its rows a reliable answer. A row reads `completed` only once the host has accepted the file: while the bytes go out, `PrintHostJobQueue::sent_percent()` stops at 99, @@ -2514,67 +2521,67 @@ slicing thread, reads what the row shows (host, upload path, file size) before t remove the source file, and posts `append_job()` to the queue dialog itself, the handler the upload thread's progress and error events go to, so the row exists before any of them is handled. -## Scripts and the journal +## Replays and the journal ```jsonc -{ "orca_script": 1, "name": "repro #12345", - "vars": {"model": "${script_dir}/part.stl"}, +{ "orca_replay": 1, "name": "repro #12345", + "vars": {"model": "${replay_dir}/part.stl"}, "steps": [ {"tool": "open_files", "args": {"paths": ["${vars.model}"]}}, {"tool": "slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}}, {"tool": "run_action", "args": {"id": "orca_command:open_preferences:orca"}, "await": false, "save_as": "prefs"}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Preferences"}, "button": "close"}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Preferences"}, "button": "close"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.prefs}"}}, {"tool": "screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/preview.png", "overwrite": true}} ]} ``` -A script is JSON with comments allowed. `run_script` runs a file or an inline script as a job whose +A replay is JSON with comments allowed. `run_replay` runs a file or an inline replay as a job whose steps call tools as its children (`ToolContext::call_child()`), so steps are not journaled and a -script's `wait {for: "idle"}` doesn't wait for the script. An inline script is the script object or -its JSON text, comments included, so a caller holding a script file's text passes it as read; the +replay's `wait {for: "idle"}` doesn't wait for the replay. An inline replay is the replay object or +its JSON text, comments included, so a caller holding a replay file's text passes it as read; the journal records the text as the object it parses to. Every string is substituted recursively -with `${script_dir}`, `${out_dir}`, `${env:NAME}`, `${vars.NAME}` and `${jobs.NAME}`; a string that -is just one placeholder becomes the referenced JSON value. A JSON script's own `run_script` step -gives its nested script as an object: the outer run splices placeholders into a text script as plain +with `${replay_dir}`, `${out_dir}`, `${env:NAME}`, `${vars.NAME}` and `${jobs.NAME}`; a string that +is just one placeholder becomes the referenced JSON value. A replay's own `run_replay` step +gives its nested replay as an object: the outer run splices placeholders into a text replay as plain text, so a value holding a quote or a backslash, such as a Windows path, breaks its JSON. A step that returns a job is awaited, up to `timeout_s` (default 120), before its `expect` is checked; a wait that times out with a dialog open names the topmost one, since a step can't answer a dialog it opened. `"await": false` returns the job at once and stores it under `save_as`, so later steps can answer a dialog it opened and then `wait` for it. `expect` maps JSON pointers into the result to matchers (`eq ne gt ge lt le contains regex exists empty`). A failed step or expectation stops the run unless the step is `optional`. -Auto-answer rules registered by a script end with it. `vars` passed to `run_script` override the -script's. A step naming an unknown tool makes the script invalid before anything runs; so does any +Auto-answer rules registered by a replay end with it. `vars` passed to `run_replay` override the +replay's. A step naming an unknown tool makes the replay invalid before anything runs; so does any field of the wrong type, and broken JSON is reported with its line and column. The result, also written to `/result.json`, is `{passed, name, failed_step, steps: [{index, tool, args, ok, duration_ms, result | error, expect_failure, cancelled, reason}], out_dir, result_file}`. A failed step's `reason` says why in parts a host can word: `cancelled`, `timeout {seconds}`, `expect {pointer, op, expected, actual, exists}`, `expect_invalid`, `placeholder {text}`, `missing_job {name, -saved_by}` (the step that saves that job, when one does) or `tool` (the tool's own error). A script -file's `out_dir` defaults to ` - +
- + @@ -46,7 +46,7 @@
diff --git a/resources/web/dialog/ActionReplay/script_editor.js b/resources/web/dialog/ActionReplay/replay_editor.js similarity index 97% rename from resources/web/dialog/ActionReplay/script_editor.js rename to resources/web/dialog/ActionReplay/replay_editor.js index d1773189eb..810e39b9b8 100644 --- a/resources/web/dialog/ActionReplay/script_editor.js +++ b/resources/web/dialog/ActionReplay/replay_editor.js @@ -1,12 +1,12 @@ // The replay editor's language: a replay's highlighting (the orca_replay mode), and suggestions for its keys, tool // names, a tool's args and their allowed values, and ${…} placeholders, with what accepting one and Return write. The -// editor is Ace, set up by ../js/code_editor.js; the pure functions here are also loaded by script_editor.test.js. +// editor is Ace, set up by ../js/code_editor.js; the pure functions here are also loaded by replay_editor.test.js. -// The keys of a script and of a step, with the JSON type of their values. Accepting a key writes a +// The keys of a replay and of a step, with the JSON type of their values. Accepting a key writes a // value of that type after its colon (an empty string, object or array with the caret inside, or true), // or the item's own `then`; for a number the caret waits after the colon. const ROOT_KEYS = [ - { label: "orca_script", detail: "integer", then: "1" }, + { label: "orca_replay", detail: "integer", then: "1" }, { label: "name", detail: "string" }, { label: "vars", detail: "object" }, { label: "steps", detail: "array" }, @@ -84,7 +84,7 @@ function defineReplayMode() { // Walks the tokens before `at` keeping a frame per open object ({key, colon, keys, tool}) and // array ({array, index}). Returns the frames, the string `at` is in (after its opening quote) if // any, and the vars and saved job names seen; null when `at` is in a comment. -function readScript(text, at) { +function readReplay(text, at) { const frames = []; const vars = new Set(); const jobs = new Set(); @@ -170,7 +170,7 @@ function valueItems(frames, path) { // Inside a string that is a key or a value, or after an unclosed ${ in a string; elsewhere only when // asked (`explicit`), at a key or value position. function suggestionsAt(text, at, explicit) { - const read = readScript(text, at); + const read = readReplay(text, at); if (!read || !read.frames.length) return null; const { frames, string } = read; const top = frames[frames.length - 1]; @@ -180,7 +180,7 @@ function suggestionsAt(text, at, explicit) { const typed = text.slice(string.start + 1, at); const open = typed.lastIndexOf("${"); if (open >= 0 && typed.indexOf("}", open) < 0) { - const items = ["script_dir", "out_dir", ...[...read.vars].map((k) => "vars." + k), ...[...read.jobs].map((k) => "jobs." + k)]; + const items = ["replay_dir", "out_dir", ...[...read.vars].map((k) => "vars." + k), ...[...read.jobs].map((k) => "jobs." + k)]; return { kind: "var", from: string.start + 3 + open, to: wordEnd, items: items.map((label) => ({ label })) }; } } else if (!explicit) return null; @@ -268,4 +268,4 @@ function initEditor(onChange, commands) { // The language's pure functions, for the page's tests (node --test), which load this file as a module. if (typeof module === "object" && module.exports) - module.exports = { readScript, suggestionsAt, acceptEdit, newlineEdit, setEditorTools }; + module.exports = { readReplay, suggestionsAt, acceptEdit, newlineEdit, setEditorTools }; diff --git a/resources/web/dialog/ActionReplay/script_editor.test.js b/resources/web/dialog/ActionReplay/replay_editor.test.js similarity index 94% rename from resources/web/dialog/ActionReplay/script_editor.test.js rename to resources/web/dialog/ActionReplay/replay_editor.test.js index 466b5bc73e..1db829dfa1 100644 --- a/resources/web/dialog/ActionReplay/script_editor.test.js +++ b/resources/web/dialog/ActionReplay/replay_editor.test.js @@ -1,7 +1,7 @@ "use strict"; const { test } = require("node:test"); const assert = require("node:assert/strict"); -const editor = require("./script_editor.js"); +const editor = require("./replay_editor.js"); // Two tools, as the host's catalog lists them: one taking a plain number, one an enum and a nullable number. editor.setEditorTools([ @@ -13,12 +13,12 @@ editor.setEditorTools([ function at(text, explicit) { return editor.suggestionsAt(text, text.length, !!explicit); } function labels(found) { return found.items.map((item) => item.label); } -test("a script's root keys are suggested in a key's string", () => { +test("a replay's root keys are suggested in a key's string", () => { const found = at('{\n "'); assert.equal(found.kind, "key"); assert.equal(found.from, 5); assert.equal(found.to, 5); - assert.deepEqual(labels(found), ["orca_script", "name", "vars", "steps"]); + assert.deepEqual(labels(found), ["orca_replay", "name", "vars", "steps"]); }); test("a step's keys are suggested inside steps[], leaving out the ones it has", () => { @@ -60,7 +60,7 @@ test("a placeholder suggests the folders, the vars and the saved jobs", () => { assert.equal(found.kind, "var"); assert.equal(found.from, text.length); assert.equal(found.to, text.length); - assert.deepEqual(labels(found), ["script_dir", "out_dir", "vars.part", "jobs.s1"]); + assert.deepEqual(labels(found), ["replay_dir", "out_dir", "vars.part", "jobs.s1"]); }); test("nothing is suggested outside a string unless asked for, nor in a comment", () => { @@ -80,8 +80,8 @@ test("an accepted key gets its colon and an empty value with the caret inside", const name = found.items.find((item) => item.label === "name"); assert.deepEqual(editor.acceptEdit(text, found, name), { from: 2, to: 2, insert: 'name": ""', back: 1, reopen: true }); // A number waits after the colon. - const version = found.items.find((item) => item.label === "orca_script"); - assert.deepEqual(editor.acceptEdit(text, found, version), { from: 2, to: 2, insert: 'orca_script": 1', back: 0, reopen: false }); + const version = found.items.find((item) => item.label === "orca_replay"); + assert.deepEqual(editor.acceptEdit(text, found, version), { from: 2, to: 2, insert: 'orca_replay": 1', back: 0, reopen: false }); }); test("a key accepted before an existing colon replaces only the key", () => { diff --git a/resources/web/mcp/page_agent.js b/resources/web/mcp/page_agent.js index 195e3c97cc..e99c840dc2 100644 --- a/resources/web/mcp/page_agent.js +++ b/resources/web/mcp/page_agent.js @@ -1,5 +1,5 @@ -// The MCP server's agent inside a web page: lists the page as ui_snapshot shows it and acts on its -// elements for ui_click, ui_input, ui_key, ui_mouse and dialog_respond. OrcaSlicer injects it on +// The MCP server's agent inside a web page: lists the page as list_widgets shows it and acts on its +// elements for click, set_widget_value, press_keys, mouse_gesture and answer_dialog. OrcaSlicer injects it on // demand into any of its web views (src/slic3r/GUI/Mcp/WebPages.cpp), so no page or host includes // it. It runs as the body of `function (V, SRC)`, V the version OrcaSlicer stamps it with and SRC // this source, which it hands to the plugin configuration frames it relays to, and installs @@ -175,7 +175,7 @@ function jqueryHandles(el) { function isFrame(el) { return el.localName === 'iframe' || el.localName === 'frame'; } -// The kind ui_snapshot lists an element as, in the vocabulary of wx widgets, or '' when it is only a +// The kind list_widgets lists an element as, in the vocabulary of wx widgets, or '' when it is only a // container. `pointerAbove` says whether its parent already shows the pointer cursor or is a listed // button or link, so a clickable element counts once, not with every child inside it. function kindOf(el, st, pointerAbove) { @@ -483,7 +483,7 @@ function topRect(el) { // ---- the walk ------------------------------------------------------------------------------ -// Visits the page as ui_snapshot lists it: visit(el, info, depth) for each listed element and +// Visits the page as list_widgets lists it: visit(el, info, depth) for each listed element and // text(text, depth, block) for each run of text outside one. Hidden subtrees are left out; open // shadow roots are walked through their slots and same-origin frames entered. function walkPage(visit, text) { @@ -1050,7 +1050,7 @@ function aimAt(el, dx, dy, hitTest) { // What a press lands on must be the element; a move or release may be anywhere (a drag's). if (hitTest && ((dx !== undefined && (dx < 0 || dx > r.width)) || (dy !== undefined && (dy < 0 || dy > r.height)))) fail('point', 'The point x, y is outside the element: they count from its top left, within the width and height ' + - 'ui_snapshot lists for it'); + 'list_widgets lists for it'); var at = {x: dx === undefined ? r.left + r.width / 2 : r.left + dx, y: dy === undefined ? r.top + r.height / 2 : r.top + dy}; if (hitTest) { var root = el.getRootNode ? el.getRootNode() : el.ownerDocument; @@ -1766,7 +1766,7 @@ var CHANGES_MAX = 20; var WATCHES_MAX = 16; var watches = {}; // outlines taken before actions, by the tools' id for the action: {at, lines} -// The page as ui_snapshot lists it, a line per element (kind, label, value, state and notes) and per +// The page as list_widgets lists it, a line per element (kind, label, value, state and notes) and per // run of text, and the configuration frames, whose agents outline their own pages. function outline() { var lines = []; @@ -1885,10 +1885,10 @@ function changes(req) { function element(req) { if (req.doc !== docToken) - fail('stale', 'The page changed (it navigated or reloaded); take a new ui_snapshot'); + fail('stale', 'The page changed (it navigated or reloaded); call list_widgets again'); var el = byKey.get(req.k); if (!el || !el.isConnected) - fail('stale', 'The element is gone from the page; take a new ui_snapshot'); + fail('stale', 'The element is gone from the page; call list_widgets again'); return el; } @@ -1917,7 +1917,7 @@ function forward(req) { var parts = String(req.k).split('/'); var frame = byKey.get(Number(parts[0])); if (!frame || !frame.isConnected || !relayFrame(frame)) - fail('stale', 'The element\'s frame is gone; take a new ui_snapshot'); + fail('stale', 'The element\'s frame is gone; call list_widgets again'); var inner = {}; for (var p in req) inner[p] = req[p]; @@ -1948,7 +1948,7 @@ function release(req) { function act(req) { if (typeof req.k === 'string' && req.k.indexOf('/') > 0) { if (req.doc !== docToken) - fail('stale', 'The page changed (it navigated or reloaded); take a new ui_snapshot'); + fail('stale', 'The page changed (it navigated or reloaded); call list_widgets again'); watch(req); return forward(req); } @@ -1956,7 +1956,7 @@ function act(req) { var el = req.k ? element(req) : null; if (req.action === 'key') { if (el && hiddenFromView(el)) - fail('hidden', 'The element is not shown; take a new ui_snapshot'); + fail('hidden', 'The element is not shown; call list_widgets again'); // A disabled control (its fieldset's included) takes no focus, so keys would go elsewhere. if (el) { var keyed = infoOf(el); @@ -1993,7 +1993,7 @@ function act(req) { if (!el) fail('target', 'No element'); if (hiddenFromView(el)) - fail('hidden', 'The element is not shown; take a new ui_snapshot'); + fail('hidden', 'The element is not shown; call list_widgets again'); var info = infoOf(el); if (disabledOf(info.control || el, info.st)) fail('disabled', 'The ' + info.kind + ' "' + clip(info.label, 40) + '" is disabled'); @@ -2037,7 +2037,7 @@ function press(req) { function evalScript(req) { if (typeof req.k === 'string') - fail('relayed', 'The element is in a plugin configuration frame, which webview_eval does not reach; use the ui_* tools'); + fail('relayed', 'The element is in a plugin configuration frame, which run_javascript does not reach; use click, set_widget_value and press_keys'); var el = req.k ? element(req) : undefined; // A page whose Content-Security-Policy forbids eval refuses to build the runner, before any of the // script runs; the agent itself, installed as inline code, still works there. @@ -2045,7 +2045,7 @@ function evalScript(req) { try { run = new Function('el', 'return eval(arguments[1]);'); } catch (e) { - fail('csp', 'This page\'s Content-Security-Policy forbids eval, which webview_eval runs scripts with; the ui_* tools ' + + fail('csp', 'This page\'s Content-Security-Policy forbids eval, which run_javascript runs scripts with; click, set_widget_value and press_keys ' + 'still work on it'); } var res = run(el, String(req.script)); diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index e687d4eb84..db81911722 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -1525,11 +1525,11 @@ int CLI::run(int argc, char **argv) params.mcp.port = opt->value; if (const auto *opt = m_config.opt("mcp_token")) params.mcp.token = opt->value; - // Resolved now: the GUI moves the working directory to /log before the script runs. - if (const auto *opt = m_config.opt("mcp_script")) - params.mcp.script = resolve_cli_input_path(opt->value); - if (const auto *opt = m_config.opt("mcp_script_out")) - params.mcp.script_out = resolve_cli_input_path(opt->value); + // Resolved now: the GUI moves the working directory to /log before the replay or script runs. + if (const auto *opt = m_config.opt("mcp_run")) + params.mcp.run_file = resolve_cli_input_path(opt->value); + if (const auto *opt = m_config.opt("mcp_run_out")) + params.mcp.run_out = resolve_cli_input_path(opt->value); BOOST_LOG_TRIVIAL(info) << "begin to launch OrcaSlicer GUI soon"; return Slic3r::GUI::GUI_Run(params); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index eb952087ca..15d66b2d43 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -13163,15 +13163,15 @@ CLIMiscConfigDef::CLIMiscConfigDef() def->cli_params = "token"; def->set_default_value(new ConfigOptionString()); - def = this->add("mcp_script", coString); - def->label = L("MCP script"); - def->tooltip = L("Run an MCP script once the GUI is ready, write its results, and exit: 0 when it passed, 1 when a step failed, 2 when the script is invalid."); + def = this->add("mcp_run", coString); + def->label = L("Run a replay or script"); + def->tooltip = L("Run a replay (.json) or a Python script (.py) once the GUI is ready, then exit: 0 when it passed or finished, 1 when a step failed or the script did not finish, 2 when the file is invalid or cannot be read."); def->cli_params = "file"; def->set_default_value(new ConfigOptionString()); - def = this->add("mcp_script_out", coString); - def->label = L("MCP script output directory"); - def->tooltip = L("Where --mcp-script writes result.json and screenshots. Defaults to """ -# Its Content-Security-Policy forbids eval, which the page agent doesn't need and webview_eval may +# Its Content-Security-Policy forbids eval, which the page agent doesn't need and run_javascript may # (where the port holds injected scripts to the page's policy). PANEL = r""" diff --git a/tools/mcp/tests/presets.json b/tools/mcp/tests/presets.json index 0b44bb7e3a..6763024cc5 100644 --- a/tools/mcp/tests/presets.json +++ b/tools/mcp/tests/presets.json @@ -9,15 +9,15 @@ // Preset Bundle dialog to its out_dir and imports it again with a path, and changes a preference in the // Preferences dialog, reading it back with get_settings. It starts from the harness's default printer // (Bambu Lab X1 Carbon, Bambu PLA Basic) with one filament slot in Simple mode; it deletes other slots and -// selects the mode first, so it also runs after scripts that leave more slots or another mode. Preset files -// stay in the datadir, so the first save of each name passes overwrite and the script reruns. Run it with -// tools/mcp/orca_mcp.py run-script tools/mcp/tests/presets.json --out /tmp/presets +// selects the mode first, so it also runs after replays that leave more slots or another mode. Preset files +// stay in the datadir, so the first save of each name passes overwrite and the replay reruns. Run it with +// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/presets.json --out /tmp/presets { - "orca_script": 1, + "orca_replay": 1, "name": "save presets and drop edits", "steps": [ {"tool": "wait", "args": {"for": "ready"}}, - {"tool": "dialog_auto_answer", "args": {"rules": [{"match": "restore", "button": "no"}, {"match": "Uniform scale", "button": "ok"}]}}, + {"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "restore", "button": "no"}, {"match": "Uniform scale", "button": "ok"}]}}, // Unsaved edits a person (or an earlier run) left are dropped first, so nothing below asks about them. {"tool": "new_project", "args": {"discard_changes": true, "changes": "discard"}}, {"tool": "set_view", "args": {"window_size": [1920, 1200]}}, @@ -30,7 +30,7 @@ {"tool": "run_action", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true}, {"tool": "run_action", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true}, {"tool": "run_action", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true}, - {"tool": "get_state", "expect": {"/presets/filaments/1": {"exists": false}}}, + {"tool": "get_app_state", "expect": {"/presets/filaments/1": {"exists": false}}}, {"tool": "select_preset", "args": {"type": "printer", "name": "Bambu Lab X1 Carbon 0.4 nozzle"}}, {"tool": "select_preset", "args": {"type": "process", "name": "0.20mm Standard @BBL X1C"}}, {"tool": "select_preset", "args": {"type": "filament", "name": "Bambu PLA Basic", "filament_slot": 1}}, @@ -48,7 +48,7 @@ // one of those rather than on the default filament. {"tool": "select_preset", "args": {"type": "printer", "name": "Bambu Lab A1 mini 0.4 nozzle", "changes": "discard"}, "expect": {"/selected": {"eq": "Bambu Lab A1 mini 0.4 nozzle"}}}, - {"tool": "get_state", "expect": {"/presets/filaments/0": {"regex": "@BBL A1M$"}}}, + {"tool": "get_app_state", "expect": {"/presets/filaments/0": {"regex": "@BBL A1M$"}}}, {"tool": "select_preset", "args": {"type": "printer", "name": "Bambu Lab X1 Carbon 0.4 nozzle", "changes": "discard"}}, {"tool": "select_preset", "args": {"type": "process", "name": "0.20mm Standard @BBL X1C", "changes": "discard"}}, {"tool": "select_preset", "args": {"type": "filament", "name": "Bambu PLA Basic", "filament_slot": 1}, @@ -143,7 +143,7 @@ "expect": {"/items/0/value": {"eq": "2"}}}, {"tool": "get_settings", "args": {"scope": "process", "preset": "0.16mm Optimal @BBL X1C", "keys": ["layer_height"], "include_meta": false}, "expect": {"/items/0/value": {"eq": "0.16"}}}, - {"tool": "get_state", "expect": {"/presets/process": {"eq": "0.20mm Standard @BBL X1C"}}}, + {"tool": "get_app_state", "expect": {"/presets/process": {"eq": "0.20mm Standard @BBL X1C"}}}, {"tool": "get_settings", "args": {"scope": "process", "compare": "0.16mm Optimal @BBL X1C", "keys": ["layer_height", "wall_loops"]}, "expect": {"/right": {"eq": "0.16mm Optimal @BBL X1C"}, "/items/0/key": {"eq": "layer_height"}, "/items/0/value": {"eq": "0.2"}, "/items/0/other": {"eq": "0.16"}, "/items/1/key": {"eq": "wall_loops"}, "/items/1/other": {"eq": "2"}}}, @@ -170,7 +170,7 @@ {"tool": "set_settings", "args": {"scope": "filament", "reset_all": true}, "expect": {"/changed/nozzle_temperature": {"eq": "220,220"}}}, // ---- changed shows what the app adjusts in turn: spiral vase, confirmed in its dialog ---- - {"tool": "dialog_auto_answer", "args": {"rules": [{"match": "Spiral mode only works", "button": "yes"}]}}, + {"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "Spiral mode only works", "button": "yes"}]}}, {"tool": "set_settings", "args": {"scope": "process", "values": {"spiral_mode": true}}, "expect": {"/applied/spiral_mode": {"eq": "1"}, "/changed/spiral_mode": {"eq": "1"}, "/changed/wall_loops": {"eq": "1"}, "/changed/top_shell_layers": {"eq": "0"}, "/changed/sparse_infill_density": {"eq": "0%"}}}, @@ -218,8 +218,8 @@ // ---- select_preset: without changes the Transfer-or-discard prompt opens, as before ---- {"tool": "select_preset", "args": {"type": "process", "name": "0.16mm Optimal @BBL X1C"}, "await": false, "save_as": "switch"}, {"tool": "wait", "args": {"for": "dialog"}}, - {"tool": "get_state", "expect": {"/dialogs/0/title": {"eq": "Transfer or discard changes"}}}, - {"tool": "dialog_respond", "args": {"button": "Transfer"}}, + {"tool": "get_app_state", "expect": {"/dialogs/0/title": {"eq": "Transfer or discard changes"}}}, + {"tool": "answer_dialog", "args": {"button": "Transfer"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.switch}"}, "expect": {"/selected": {"eq": "0.16mm Optimal @BBL X1C"}, "/modified/process/keys": {"eq": ["sparse_infill_density"]}}}, {"tool": "get_settings", "args": {"scope": "process", "keys": ["sparse_infill_density"], "include_meta": false}, "expect": {"/items/0/value": {"eq": "25%"}}}, @@ -252,7 +252,7 @@ {"tool": "select_preset", "args": {"type": "filament", "name": "MCP Test PLA", "filament_slot": 1}}, {"tool": "set_settings", "args": {"scope": "filament", "values": {"slow_down_layer_time": 8}}}, {"tool": "select_preset", "args": {"type": "filament", "name": "MCP Test PETG", "filament_slot": 1, "changes": "transfer"}, "optional": true}, - {"tool": "get_state", "expect": {"/presets/filaments/0": {"eq": "MCP Test PLA"}}}, + {"tool": "get_app_state", "expect": {"/presets/filaments/0": {"eq": "MCP Test PLA"}}}, {"tool": "select_preset", "args": {"type": "filament", "name": "MCP Test PETG", "filament_slot": 1, "changes": "discard"}, "expect": {"/selected": {"eq": "MCP Test PETG"}, "/discarded/filament/name": {"eq": "MCP Test PLA"}, "/discarded/filament/keys": {"eq": ["slow_down_layer_time"]}}}, @@ -324,17 +324,17 @@ // ---- Presets exported with the Export Preset Bundle dialog to a directory, then imported with a path ---- // A detached filament is listed in the dialog under its own name. A rerun finds the last run's archive, // which the dialog asks before replacing. - {"tool": "dialog_auto_answer", "args": {"rules": [{"match": "already exists", "button": "yes"}]}}, + {"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "already exists", "button": "yes"}]}}, {"tool": "run_action", "args": {"id": "orca_command:toggle_developer_mode:orca"}}, {"tool": "save_preset", "args": {"type": "filament", "name": "MCP Export PLA", "detach": true, "overwrite": true}, "expect": {"/inherits": {"exists": false}}}, {"tool": "run_action", "args": {"id": "orca_command:toggle_developer_mode:orca"}}, {"tool": "run_action", "args": {"id": "orca_command:export_config:orca", "param": "${out_dir}"}, "await": false, "save_as": "export"}, - {"tool": "ui_click", "args": {"target": {"label": "Filament presets(.zip)", "within": "Export Preset Bundle"}}}, - {"tool": "ui_input", "args": {"target": {"name": "MCP Export PLA", "within": "Export Preset Bundle"}, "value": true}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Export Preset Bundle"}, "button": "ok"}, "await": false, "save_as": "export_ok"}, - {"tool": "get_state", "expect": {"/dialogs/1/message": {"eq": "Export successful"}}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Info"}, "button": "ok"}}, + {"tool": "click", "args": {"target": {"label": "Filament presets(.zip)", "within": "Export Preset Bundle"}}}, + {"tool": "set_widget_value", "args": {"target": {"name": "MCP Export PLA", "within": "Export Preset Bundle"}, "value": true}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Export Preset Bundle"}, "button": "ok"}, "await": false, "save_as": "export_ok"}, + {"tool": "get_app_state", "expect": {"/dialogs/1/message": {"eq": "Export successful"}}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Info"}, "button": "ok"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.export_ok}"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.export}"}, "expect": {"/level": {"eq": "success"}}}, // The preset exists: the import keeps it by default, and the message names it. @@ -347,7 +347,7 @@ {"tool": "list_presets", "args": {"type": "filament", "query": "MCP Export PLA"}, "expect": {"/total": {"eq": 1}, "/items/0/user": {"eq": true}}}, {"tool": "delete_preset", "args": {"type": "filament", "name": "MCP Export PLA"}}, // One preset file, inheriting a system filament. - {"tool": "run_action", "args": {"id": "orca_command:import_configs:orca", "param": "${script_dir}/fixtures/mcp_import_pla.json"}, + {"tool": "run_action", "args": {"id": "orca_command:import_configs:orca", "param": "${replay_dir}/fixtures/mcp_import_pla.json"}, "expect": {"/message": {"eq": "Imported presets: MCP Import PLA."}}}, {"tool": "list_presets", "args": {"type": "filament", "query": "MCP Import PLA"}, "expect": {"/items/0/inherits": {"eq": "Bambu PLA Basic @BBL X1C"}}}, {"tool": "get_settings", "args": {"scope": "filament", "preset": "MCP Import PLA", "keys": ["filament_cost"], "include_meta": false}, @@ -361,23 +361,23 @@ // set_settings refuses the scope (expected to fail), and so does open_preferences an unknown tab; no dialog opens. {"tool": "set_settings", "args": {"scope": "preferences", "values": {"auto_arrange": false}}, "optional": true}, {"tool": "run_action", "args": {"id": "orca_command:open_preferences:orca", "param": "advanced"}, "optional": true}, - {"tool": "get_state", "expect": {"/dialogs": {"empty": true}}}, + {"tool": "get_app_state", "expect": {"/dialogs": {"empty": true}}}, {"tool": "run_action", "args": {"id": "orca_command:open_preferences:orca", "param": "behaviour:auto_arrange"}, "await": false, "save_as": "prefs"}, - {"tool": "ui_input", "args": {"target": {"name": "auto_arrange", "within": "Preferences"}, "value": false}, "expect": {"/checked": {"eq": false}}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Preferences"}, "button": "close"}}, + {"tool": "set_widget_value", "args": {"target": {"name": "auto_arrange", "within": "Preferences"}, "value": false}, "expect": {"/checked": {"eq": false}}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Preferences"}, "button": "close"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.prefs}"}}, {"tool": "get_settings", "args": {"scope": "preferences", "keys": ["auto_arrange"]}, "expect": {"/items/0/value": {"eq": "false"}}}, // A key on another tab than the one named is shown on its own tab, where it can be changed. {"tool": "run_action", "args": {"id": "orca_command:open_preferences:orca", "param": "general:auto_arrange"}, "await": false, "save_as": "prefs2"}, - {"tool": "ui_input", "args": {"target": {"name": "auto_arrange", "within": "Preferences"}, "value": true}, "expect": {"/checked": {"eq": true}}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Preferences"}, "button": "close"}}, + {"tool": "set_widget_value", "args": {"target": {"name": "auto_arrange", "within": "Preferences"}, "value": true}, "expect": {"/checked": {"eq": true}}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Preferences"}, "button": "close"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.prefs2}"}}, {"tool": "get_settings", "args": {"scope": "preferences", "keys": ["auto_arrange"]}, "expect": {"/items/0/value": {"eq": "true"}}}, // ---- A printer preset, deleted once selected, then back to the system printer ---- {"tool": "save_preset", "args": {"type": "printer", "name": "MCP Test Printer", "overwrite": true}, "expect": {"/user": {"eq": true}, "/inherits": {"eq": "Bambu Lab X1 Carbon 0.4 nozzle"}, "/selected": {"eq": true}}}, - {"tool": "get_state", "expect": {"/presets/printer": {"eq": "MCP Test Printer"}}}, + {"tool": "get_app_state", "expect": {"/presets/printer": {"eq": "MCP Test Printer"}}}, {"tool": "new_project", "args": {"discard_changes": true}}, {"tool": "select_preset", "args": {"type": "printer", "name": "Bambu Lab X1 Carbon 0.4 nozzle"}}, // A printer that is not selected is refused (expected to fail): switching printers is no round trip. diff --git a/tools/mcp/tests/preview.json b/tools/mcp/tests/preview.json index 16c95d6e7c..16202bfc00 100644 --- a/tools/mcp/tests/preview.json +++ b/tools/mcp/tests/preview.json @@ -1,19 +1,19 @@ -// get_preview and get_state.preview on a sliced 25.6 mm cube: the summary, the feature and layer +// get_slice_stats and get_app_state.preview on a sliced 25.6 mm cube: the summary, the feature and layer // tables, the object with its list_objects index, the legend's state as set_view changes it (rows, // time estimate, layers by height, a view type picked as the legend's combo does), and the same reads // on the cube's G-code opened for viewing. Run it on a fresh datadir set up with the // default printer (Bambu Lab X1 Carbon 0.4, 0.2 mm layers): -// tools/mcp/orca_mcp.py run-script tools/mcp/tests/preview.json --out /tmp/preview +// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/preview.json --out /tmp/preview // The tables' arithmetic (shares of the print time, heights, paging, the unique-name rule) is unit -// tested in tests/slic3rutils/test_mcp_results.cpp, since a script step cannot add values up, and a -// refusal cannot be expected in a script; tools/mcp/test_set_view_preview.py checks set_view's. +// tested in tests/slic3rutils/test_mcp_results.cpp, since a replay step cannot add values up, and a +// refusal cannot be expected in a replay; tools/mcp/test_set_view_preview.py checks set_view's. { - "orca_script": 1, + "orca_replay": 1, "name": "preview data", "steps": [ {"tool": "wait", "args": {"for": "ready"}}, // Opening a G-code file asks to save the project it replaces, discard_changes or not. - {"tool": "dialog_auto_answer", "args": {"rules": [{"match": "Uniform scale", "button": "ok"}, + {"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "Uniform scale", "button": "ok"}, {"match": "unsaved changes. Would you like to save", "button": "No"}]}}, {"tool": "new_project", "args": {"discard_changes": true}}, {"tool": "set_view", "args": {"tab": "prepare", "window_size": [1920, 1200]}}, @@ -24,7 +24,7 @@ {"tool": "set_view", "args": {"view_type": "feature_type", "layer_range": [1, 128]}}, // ---- The tables, and the legend of the plate the Preview shows ---- - {"tool": "get_preview", "args": {"include": ["features", "layers", "objects", "view"], "limit": 5}, "expect": { + {"tool": "get_slice_stats", "args": {"include": ["features", "layers", "objects", "view"], "limit": 5}, "expect": { "/plate": {"eq": 0}, "/summary/layers": {"eq": 128}, "/summary/filament_g": {"gt": 0}, @@ -54,7 +54,7 @@ "/view/ranges/volumetric_flow_rate/1": {"gt": 0}, "/view/ranges/layer_time_linear/1": {"gt": 0}}}, // The last page, with each layer's seconds per feature type, and no other part. - {"tool": "get_preview", "args": {"include": ["layer_features"], "offset": 127}, "expect": { + {"tool": "get_slice_stats", "args": {"include": ["layer_features"], "offset": 127}, "expect": { "/layers/items/0/layer": {"eq": 128}, "/layers/items/0/z": {"eq": 25.6}, "/layers/items/0/features/Top surface": {"gt": 0}, @@ -68,7 +68,7 @@ "/legend/travel": {"eq": true}, "/layers/1": {"eq": 5}, "/z/1": {"eq": 1.0}}}, - {"tool": "get_preview", "args": {"include": ["view"]}, "expect": { + {"tool": "get_slice_stats", "args": {"include": ["view"]}, "expect": { "/view/legend/features/Sparse infill": {"eq": false}, "/view/legend/features/Outer wall": {"eq": true}, "/view/legend/options/travel": {"eq": true}, @@ -78,24 +78,24 @@ {"tool": "set_view", "args": {"time_mode": "normal"}, "expect": {"/time_mode": {"eq": "normal"}}}, // A view type is picked as in the legend's combo: Line Type shows every feature type again. {"tool": "set_view", "args": {"view_type": "speed"}}, - {"tool": "get_preview", "args": {"include": ["view"]}, "expect": {"/view/legend/features/Sparse infill": {"eq": false}}}, + {"tool": "get_slice_stats", "args": {"include": ["view"]}, "expect": {"/view/legend/features/Sparse infill": {"eq": false}}}, {"tool": "set_view", "args": {"view_type": "feature_type", "legend": {"travel": false}}}, - {"tool": "get_preview", "args": {"include": ["view"]}, "expect": { + {"tool": "get_slice_stats", "args": {"include": ["view"]}, "expect": { "/view/legend/features/Sparse infill": {"eq": true}, "/view/legend/options/travel": {"eq": false}}}, {"tool": "screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/legend.png", "overwrite": true, "include_image": false}}, - // ---- get_state.preview follows set_view ---- + // ---- get_app_state.preview follows set_view ---- {"tool": "set_view", "args": {"layer": 5}}, - {"tool": "get_state", "expect": { + {"tool": "get_app_state", "expect": { "/preview/plate": {"eq": 0}, "/preview/layers/0": {"eq": 1}, "/preview/layers/1": {"eq": 5}, "/preview/z/1": {"eq": 1.0}, "/preview/layer_count": {"eq": 128}}}, {"tool": "set_view", "args": {"view_type": "fan_speed"}}, - {"tool": "get_state", "expect": {"/preview/view_type": {"eq": "fan_speed"}}}, - {"tool": "get_preview", "args": {"include": ["view"]}, "expect": { + {"tool": "get_app_state", "expect": {"/preview/view_type": {"eq": "fan_speed"}}}, + {"tool": "get_slice_stats", "args": {"include": ["view"]}, "expect": { "/view/view_type": {"eq": "fan_speed"}, "/view/layers/1": {"eq": 5}, "/features": {"exists": false}}}, @@ -106,7 +106,7 @@ {"tool": "set_view", "args": {"tab": "prepare"}}, {"tool": "run_action", "args": {"id": "orca_command:plate_add:orca"}}, {"tool": "run_action", "args": {"id": "orca_command:plate_goto:orca", "param": "1"}}, - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca"}}, {"tool": "wait", "args": {"for": "idle"}}, {"tool": "list_plates", "expect": {"/items/1/objects/0": {"exists": true}}}, @@ -116,23 +116,23 @@ {"tool": "run_action", "args": {"id": "orca_command:plate_goto:orca", "param": "0"}}, {"tool": "set_view", "args": {"tab": "preview"}}, {"tool": "wait", "args": {"for": "idle"}}, - {"tool": "get_state", "expect": {"/plates/current": {"eq": 0}, "/preview/plate": {"eq": 0}}}, + {"tool": "get_app_state", "expect": {"/plates/current": {"eq": 0}, "/preview/plate": {"eq": 0}}}, {"tool": "set_view", "args": {"tab": "prepare"}}, {"tool": "run_action", "args": {"id": "orca_command:plate_goto:orca", "param": "1"}}, - {"tool": "get_state", "expect": {"/plates/current": {"eq": 1}, "/preview": {"eq": null}}}, - {"tool": "get_preview", "expect": {"/plate": {"eq": 1}, "/summary/layers": {"eq": 128}, "/view": {"eq": null}, + {"tool": "get_app_state", "expect": {"/plates/current": {"eq": 1}, "/preview": {"eq": null}}}, + {"tool": "get_slice_stats", "expect": {"/plate": {"eq": 1}, "/summary/layers": {"eq": 128}, "/view": {"eq": null}, "/note": {"contains": "has not loaded this plate's toolpaths"}}}, {"tool": "set_view", "args": {"tab": "preview"}}, {"tool": "wait", "args": {"for": "idle"}}, - {"tool": "get_state", "expect": {"/preview/plate": {"eq": 1}}}, - {"tool": "get_preview", "args": {"include": ["view"]}, "expect": {"/view/layer_count": {"eq": 128}, "/note": {"exists": false}}}, + {"tool": "get_app_state", "expect": {"/preview/plate": {"eq": 1}}}, + {"tool": "get_slice_stats", "args": {"include": ["view"]}, "expect": {"/view/layer_count": {"eq": 128}, "/note": {"exists": false}}}, // ---- The same cube's G-code opened for viewing: its plate is never marked sliced ---- {"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/cube.gcode", "overwrite": true}}, {"tool": "open_files", "args": {"paths": ["${out_dir}/cube.gcode"], "discard_changes": true}}, {"tool": "wait", "args": {"for": "idle"}}, - {"tool": "get_state", "expect": {"/preview/layer_count": {"eq": 128}}}, - {"tool": "get_preview", "args": {"include": ["features", "layers", "objects", "view"]}, "expect": { + {"tool": "get_app_state", "expect": {"/preview/layer_count": {"eq": 128}}}, + {"tool": "get_slice_stats", "args": {"include": ["features", "layers", "objects", "view"]}, "expect": { "/summary/layers": {"eq": 128}, "/summary/filament_g": {"gt": 0}, "/features/Outer wall/time_s": {"gt": 0}, diff --git a/tools/mcp/tests/recording.json b/tools/mcp/tests/recording.json index abe680a953..81490e7499 100644 --- a/tools/mcp/tests/recording.json +++ b/tools/mcp/tests/recording.json @@ -1,34 +1,34 @@ // Recordings: one while the GUI is driven (clicks on the 3D view, a setting typed, a dialog opened and -// answered, a slice), stopped and encoded; then one a nested script starts and never stops, which ends -// with that script and is encoded by a step after it. Run with -// tools/mcp/orca_mcp.py run-script tools/mcp/tests/recording.json --out /tmp/recording +// answered, a slice), stopped and encoded; then one a nested replay starts and never stops, which ends +// with that replay and is encoded by a step after it. Run with +// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/recording.json --out /tmp/recording // The encode steps need an ffmpeg with libx265 (ORCA_FFMPEG or on PATH), so they are optional. { - "orca_script": 1, + "orca_replay": 1, "name": "recording", - "vars": {"model": "${script_dir}/../../../resources/handy_models/OrcaCube_v2.drc"}, + "vars": {"model": "${replay_dir}/../../../resources/handy_models/OrcaCube_v2.drc"}, "steps": [ {"tool": "wait", "args": {"for": "ready"}}, - {"tool": "dialog_auto_answer", "args": {"rules": [{"match": "unsaved changes", "button": "no"}, + {"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "unsaved changes", "button": "no"}, {"match": "restore", "button": "no"}]}}, {"tool": "new_project"}, {"tool": "set_view", "args": {"window_size": [1600, 1000], "tab": "prepare"}}, {"tool": "start_recording", "args": {"save_path": "${out_dir}/session.mkv", "overwrite": true, "captions": true, "pointer": true}, "expect": {"/width": {"ge": 320}, "/fps": {"eq": 10}, "/captions": {"eq": true}, "/pointer": {"eq": true}}}, - {"tool": "get_state", "expect": {"/recording/path": {"regex": "session\\.mkv$"}}}, + {"tool": "get_app_state", "expect": {"/recording/path": {"regex": "session\\.mkv$"}}}, {"tool": "open_files", "args": {"paths": ["${vars.model}"]}, "expect": {"/added": {"eq": 1}}}, - {"tool": "ui_mouse", "args": {"action": "click", "x": 300, "y": 200}}, - {"tool": "ui_mouse", "args": {"action": "click", "at": {"object": 0, "spot": "top"}}}, - // The global settings, whatever an earlier script left the Process panel's Global/Objects switch on. - {"tool": "ui_input", "args": {"target": {"label": "Process"}, "value": false}}, - {"tool": "ui_input", "args": {"target": {"option": "layer_height"}, "value": "0.16"}}, - {"tool": "ui_key", "args": {"target": {"option": "initial_layer_print_height"}, "keys": "ctrl+a", "text": "0.24"}}, + {"tool": "mouse_gesture", "args": {"action": "click", "x": 300, "y": 200}}, + {"tool": "mouse_gesture", "args": {"action": "click", "at": {"object": 0, "spot": "top"}}}, + // The global settings, whatever an earlier replay left the Process panel's Global/Objects switch on. + {"tool": "set_widget_value", "args": {"target": {"label": "Process"}, "value": false}}, + {"tool": "set_widget_value", "args": {"target": {"option": "layer_height"}, "value": "0.16"}}, + {"tool": "press_keys", "args": {"target": {"option": "initial_layer_print_height"}, "keys": "ctrl+a", "text": "0.24"}}, // The action blocks in the dialog it opens, so it is not awaited until the dialog is answered. {"tool": "run_action", "args": {"id": "orca_command:open_preferences:orca"}, "await": false, "save_as": "prefs"}, {"tool": "wait", "args": {"for": "dialog", "timeout_s": 10}, "expect": {"/satisfied": {"eq": true}}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Preferences"}, "button": "close"}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Preferences"}, "button": "close"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.prefs}"}}, {"tool": "slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}}, @@ -36,20 +36,20 @@ {"tool": "stop_recording", "expect": {"/ended": {"eq": "stopped"}, "/frames": {"ge": 5}, "/written": {"ge": 5}, "/seconds": {"gt": 1}, "/size_bytes": {"gt": 0}, "/capture_ms": {"gt": 0}}}, - {"tool": "get_state", "expect": {"/recording": {"exists": false}}}, + {"tool": "get_app_state", "expect": {"/recording": {"exists": false}}}, {"tool": "encode_recording", "args": {"save_path": "${out_dir}/session.mp4", "overwrite": true}, "optional": true, "expect": {"/codec": {"eq": "h265"}, "/encoder": {"eq": "libx265"}, "/seconds": {"gt": 1}}}, - // A recording a script starts ends with that script, its file closed when the script's call returns. - {"tool": "run_script", "args": {"script": {"orca_script": 1, "name": "inner", "steps": [ + // A recording a replay starts ends with that replay, its file closed when the replay's call returns. + {"tool": "run_replay", "args": {"replay": {"orca_replay": 1, "name": "inner", "steps": [ {"tool": "start_recording", "args": {"target": "canvas", "fps": 5, "save_path": "${out_dir}/inner.mkv", "overwrite": true}}, {"tool": "set_view", "args": {"camera": "iso"}}, - {"tool": "ui_mouse", "args": {"action": "drag", "x": 400, "y": 300, "to": [500, 340]}}]}}, + {"tool": "mouse_gesture", "args": {"action": "drag", "x": 400, "y": 300, "to": [500, 340]}}]}}, "expect": {"/passed": {"eq": true}, "/unfinished_recording": {"exists": false}}}, - {"tool": "stop_recording", "expect": {"/ended": {"eq": "script_ended"}, "/path": {"regex": "inner\\.mkv$"}}}, + {"tool": "stop_recording", "expect": {"/ended": {"eq": "run_ended"}, "/path": {"regex": "inner\\.mkv$"}}}, {"tool": "encode_recording", "args": {"overwrite": true, "codec": "h264"}, "optional": true, "expect": {"/path": {"regex": "inner\\.mp4$"}, "/encoder": {"eq": "libx264"}}}, - // The script's end released the file: recording to it again starts at once, with no overlays by default. + // The replay's end released the file: recording to it again starts at once, with no overlays by default. {"tool": "start_recording", "args": {"save_path": "${out_dir}/inner.mkv", "overwrite": true}, "expect": {"/captions": {"eq": false}, "/pointer": {"eq": false}}}, {"tool": "stop_recording", "expect": {"/ended": {"eq": "stopped"}}}, @@ -70,7 +70,7 @@ {"tool": "stop_recording", "optional": true, "expect": {"/path": {"regex": "encoded\\.mkv$"}, "/encode/status": {"eq": "running"}, "/encode/job": {"exists": true}}}, {"tool": "wait", "args": {"for": "idle", "timeout_s": 50}, "optional": true, "expect": {"/satisfied": {"eq": true}}}, - {"tool": "get_state", "optional": true, + {"tool": "get_app_state", "optional": true, "expect": {"/jobs/0/tool": {"eq": "encode_recording"}, "/jobs/0/state": {"eq": "done"}}} ] } diff --git a/tools/mcp/tests/script_basic.json b/tools/mcp/tests/replay_basic.json similarity index 83% rename from tools/mcp/tests/script_basic.json rename to tools/mcp/tests/replay_basic.json index 533755a8df..10c6124af9 100644 --- a/tools/mcp/tests/script_basic.json +++ b/tools/mcp/tests/replay_basic.json @@ -1,10 +1,10 @@ // Opens a model, changes a print setting, slices and captures the preview: the smallest end-to-end -// check of --mcp-script. Run from anywhere: -// orca-slicer --mcp-script tools/mcp/tests/script_basic.json --mcp-script-out /tmp/out +// check of --mcp-run. Run from anywhere: +// orca-slicer --mcp-run tools/mcp/tests/replay_basic.json --mcp-run-out /tmp/out { - "orca_script": 1, + "orca_replay": 1, "name": "basic slice", - "vars": {"model": "${script_dir}/../../../resources/handy_models/OrcaCube_v2.drc"}, + "vars": {"model": "${replay_dir}/../../../resources/handy_models/OrcaCube_v2.drc"}, "steps": [ {"tool": "wait", "args": {"for": "ready"}}, {"tool": "new_project", "args": {"discard_changes": true}}, diff --git a/tools/mcp/tests/rows.json b/tools/mcp/tests/rows.json index eefb26737d..7d45176eea 100644 --- a/tools/mcp/tests/rows.json +++ b/tools/mcp/tests/rows.json @@ -2,15 +2,15 @@ // an object, its parts and the Printable column), the object's and a part's menus run from their rows, // Compare presets' rows, the object settings table, the print button's popup and a drop-down list. Run // it on a fresh datadir set up with the default printer (Bambu Lab X1 Carbon 0.4): -// tools/mcp/orca_mcp.py run-script tools/mcp/tests/rows.json --out /tmp/rows +// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/rows.json --out /tmp/rows // Refusals (a bad column, a row without a checkbox, two rows a locator names) and checklist rows (the // Add Settings checklist is on no FFF menu) are unit tests in tests/slic3rutils/test_mcp_results.cpp. { - "orca_script": 1, + "orca_replay": 1, "name": "rows and popups", "steps": [ {"tool": "wait", "args": {"for": "ready"}}, - {"tool": "dialog_auto_answer", "args": {"rules": [ + {"tool": "auto_answer_dialogs", "args": {"rules": [ {"match": "Uniform scale", "button": "ok"}, {"match": "per-object setting mode", "button": "ok"}]}}, {"tool": "new_project", "args": {"discard_changes": true}}, @@ -19,77 +19,77 @@ {"tool": "wait", "args": {"for": "idle"}}, // ---- The object list shows while the sidebar's switch is on Objects ---- - {"tool": "ui_input", "args": {"target": {"class": "SwitchButton", "label": "Process"}, "value": true}}, - {"tool": "ui_snapshot", "args": {"root": "main", "query": "row"}, "expect": {"/nodes": {"ge": 2}}}, + {"tool": "set_widget_value", "args": {"target": {"class": "SwitchButton", "label": "Process"}, "value": true}}, + {"tool": "list_widgets", "args": {"root": "main", "query": "row"}, "expect": {"/nodes": {"ge": 2}}}, // ---- Plate rows pick the plate ---- - {"tool": "ui_click", "args": {"target": {"gltoolbar": "addplate"}}}, + {"tool": "click", "args": {"target": {"gltoolbar": "addplate"}}}, {"tool": "wait", "args": {"for": "idle"}}, - {"tool": "ui_click", "args": {"target": {"row": "Plate 2"}}, "expect": {"/selected": {"eq": ["Plate 2"]}}}, - {"tool": "get_state", "expect": {"/plates/current": {"eq": 1}}}, - {"tool": "ui_click", "args": {"target": {"row": "Plate 1"}}}, - {"tool": "get_state", "expect": {"/plates/current": {"eq": 0}}}, + {"tool": "click", "args": {"target": {"row": "Plate 2"}}, "expect": {"/selected": {"eq": ["Plate 2"]}}}, + {"tool": "get_app_state", "expect": {"/plates/current": {"eq": 1}}}, + {"tool": "click", "args": {"target": {"row": "Plate 1"}}}, + {"tool": "get_app_state", "expect": {"/plates/current": {"eq": 0}}}, // ---- An object row: selected as a click selects it, its menu listed and run ---- - {"tool": "select", "args": {"none": true}}, - {"tool": "ui_click", "args": {"target": {"row": "Cube"}}, "expect": {"/selected": {"eq": ["Plate 1>Cube"]}}}, - {"tool": "ui_click", "args": {"target": {"row": "Cube"}, "button": "right"}, + {"tool": "select_objects", "args": {"none": true}}, + {"tool": "click", "args": {"target": {"row": "Cube"}}, "expect": {"/selected": {"eq": ["Plate 1>Cube"]}}}, + {"tool": "click", "args": {"target": {"row": "Cube"}, "button": "right"}, "expect": {"/popup_menu/items": {"contains": "Add Modifier>Cylinder"}}}, - {"tool": "ui_click", "args": {"target": {"row": "Cube"}, "button": "right", "popup_item": "Add Modifier>Cylinder"}, + {"tool": "click", "args": {"target": {"row": "Cube"}, "button": "right", "popup_item": "Add Modifier>Cylinder"}, "expect": {"/ran": {"eq": "Add Modifier>Cylinder"}}}, {"tool": "wait", "args": {"for": "idle"}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/type": {"eq": "modifier"}}}, // ---- Part rows: a click, Ctrl adds another; a right click keeps a selection it is in, so the part // is clicked alone before its menu changes its type ---- - {"tool": "ui_click", "args": {"target": {"row": "Cube>Generic-Cylinder"}}, "expect": {"/selected": {"eq": ["Plate 1>Cube>Generic-Cylinder"]}}}, - {"tool": "ui_click", "args": {"target": {"row": "Cube>Cube"}, "modifiers": ["ctrl"]}, + {"tool": "click", "args": {"target": {"row": "Cube>Generic-Cylinder"}}, "expect": {"/selected": {"eq": ["Plate 1>Cube>Generic-Cylinder"]}}}, + {"tool": "click", "args": {"target": {"row": "Cube>Cube"}, "modifiers": ["ctrl"]}, "expect": {"/selected": {"eq": ["Plate 1>Cube>Cube", "Plate 1>Cube>Generic-Cylinder"]}}}, - {"tool": "ui_click", "args": {"target": {"row": "Cube>Generic-Cylinder"}}}, - {"tool": "ui_click", "args": {"target": {"row": "Cube>Generic-Cylinder"}, "button": "right", "popup_item": "Change Type>Negative Part"}, + {"tool": "click", "args": {"target": {"row": "Cube>Generic-Cylinder"}}}, + {"tool": "click", "args": {"target": {"row": "Cube>Generic-Cylinder"}, "button": "right", "popup_item": "Change Type>Negative Part"}, "expect": {"/ran": {"eq": "Change Type>Negative Part"}}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/type": {"eq": "negative"}}}, // ---- The Printable column acts as a click on its icon; a double click frames the object ---- - {"tool": "ui_click", "args": {"target": {"row": "Plate 1>Cube", "column": "Printable"}}}, + {"tool": "click", "args": {"target": {"row": "Plate 1>Cube", "column": "Printable"}}}, {"tool": "list_objects", "expect": {"/items/0/instances/0/printable": {"eq": false}}}, - {"tool": "ui_click", "args": {"target": {"row": "Plate 1>Cube", "column": "Printable"}}}, + {"tool": "click", "args": {"target": {"row": "Plate 1>Cube", "column": "Printable"}}}, {"tool": "list_objects", "expect": {"/items/0/instances/0/printable": {"eq": true}}}, - {"tool": "ui_click", "args": {"target": {"row": "Plate 1>Cube"}, "double": true}, "expect": {"/selected": {"eq": ["Plate 1>Cube"]}}}, + {"tool": "click", "args": {"target": {"row": "Plate 1>Cube"}, "double": true}, "expect": {"/selected": {"eq": ["Plate 1>Cube"]}}}, {"tool": "list_objects", "expect": {"/total": {"eq": 1}, "/items/0/instances/0/printable": {"eq": true}}}, // ---- Compare presets: a data view's rows, with both presets' values ---- - {"tool": "ui_click", "args": {"target": {"label": "Compare presets"}}}, - {"tool": "ui_input", "args": {"target": {"class": "PresetComboBox", "within": "Compare presets", "index": 5}, "value": "0.12mm Fine @BBL X1C"}}, - {"tool": "ui_click", "args": {"target": {"row": "Quality>Layer height>Layer height", "within": "Compare presets"}}, + {"tool": "click", "args": {"target": {"label": "Compare presets"}}}, + {"tool": "set_widget_value", "args": {"target": {"class": "PresetComboBox", "within": "Compare presets", "index": 5}, "value": "0.12mm Fine @BBL X1C"}}, + {"tool": "click", "args": {"target": {"row": "Quality>Layer height>Layer height", "within": "Compare presets"}}, "expect": {"/clicked": {"contains": "Quality>Layer height>Layer height"}}}, - {"tool": "ui_key", "args": {"target": {"class": "DiffPresetDialog"}, "keys": "Escape"}}, + {"tool": "press_keys", "args": {"target": {"class": "DiffPresetDialog"}, "keys": "Escape"}}, // ---- The object settings table: rows named by their Name cell, read-only ---- - {"tool": "ui_click", "args": {"target": {"row": "Plate 1>Cube"}, "button": "right", "popup_item": "Edit in Parameter Table"}, + {"tool": "click", "args": {"target": {"row": "Plate 1>Cube"}, "button": "right", "popup_item": "Edit in Parameter Table"}, "await": false, "save_as": "table"}, {"tool": "wait", "args": {"for": "dialog", "timeout_s": 10}, "expect": {"/satisfied": {"eq": true}}}, - {"tool": "ui_snapshot", "args": {"root": "dialog", "query": "Generic-Cylinder"}, "expect": {"/nodes": {"eq": 1}}}, - {"tool": "ui_click", "args": {"target": {"row": "Generic-Cylinder", "within": "Object/Part Settings", "column": "Wall loops"}}, + {"tool": "list_widgets", "args": {"root": "dialog", "query": "Generic-Cylinder"}, "expect": {"/nodes": {"eq": 1}}}, + {"tool": "click", "args": {"target": {"row": "Generic-Cylinder", "within": "Object/Part Settings", "column": "Wall loops"}}, "expect": {"/column": {"eq": "Wall loops"}}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Object/Part Settings"}, "button": "close"}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Object/Part Settings"}, "button": "close"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.table}"}}, // ---- The print button's popup: listed as a root, one of its buttons picked ---- - {"tool": "ui_click", "args": {"target": {"class": "SideButton", "index": 3}}}, - {"tool": "ui_snapshot", "args": {"root": "popup", "query": "Export plate sliced file"}, "expect": {"/nodes": {"eq": 1}}}, - {"tool": "ui_click", "args": {"target": {"class": "SideButton", "label": "Export plate sliced file"}}}, - {"tool": "ui_snapshot", "args": {"root": "popup"}, "expect": {"/nodes": {"eq": 0}}}, - {"tool": "ui_snapshot", "args": {"root": "main", "query": "Export plate sliced file", "include_menus": false}, "expect": {"/nodes": {"eq": 1}}}, + {"tool": "click", "args": {"target": {"class": "SideButton", "index": 3}}}, + {"tool": "list_widgets", "args": {"root": "popup", "query": "Export plate sliced file"}, "expect": {"/nodes": {"eq": 1}}}, + {"tool": "click", "args": {"target": {"class": "SideButton", "label": "Export plate sliced file"}}}, + {"tool": "list_widgets", "args": {"root": "popup"}, "expect": {"/nodes": {"eq": 0}}}, + {"tool": "list_widgets", "args": {"root": "main", "query": "Export plate sliced file", "include_menus": false}, "expect": {"/nodes": {"eq": 1}}}, // ---- A drop-down list's rows: the plate type, picked, then put back through the combo itself (a - // press within 20 ms of its list closing, which a script can make, does not reopen it) ---- - {"tool": "ui_click", "args": {"target": {"class": "ComboBox", "label": "Smooth Cool Plate"}}}, - {"tool": "ui_snapshot", "args": {"root": "popup", "query": "row"}, "expect": {"/nodes": {"ge": 2}}}, - {"tool": "ui_click", "args": {"target": {"row": "Textured PEI Plate"}}, "expect": {"/clicked": {"eq": "Textured PEI Plate"}}}, - {"tool": "ui_snapshot", "args": {"root": "main", "query": "Textured PEI Plate"}, "expect": {"/nodes": {"eq": 1}}}, - {"tool": "ui_input", "args": {"target": {"class": "ComboBox", "label": "Textured PEI Plate"}, "value": "Smooth Cool Plate"}}, - {"tool": "ui_snapshot", "args": {"root": "main", "query": "Smooth Cool Plate"}, "expect": {"/nodes": {"eq": 1}}}, - {"tool": "get_state", "expect": {"/dialogs": {"empty": true}, "/closed_menus": {"empty": true}}} + // press within 20 ms of its list closing, which a replay can make, does not reopen it) ---- + {"tool": "click", "args": {"target": {"class": "ComboBox", "label": "Smooth Cool Plate"}}}, + {"tool": "list_widgets", "args": {"root": "popup", "query": "row"}, "expect": {"/nodes": {"ge": 2}}}, + {"tool": "click", "args": {"target": {"row": "Textured PEI Plate"}}, "expect": {"/clicked": {"eq": "Textured PEI Plate"}}}, + {"tool": "list_widgets", "args": {"root": "main", "query": "Textured PEI Plate"}, "expect": {"/nodes": {"eq": 1}}}, + {"tool": "set_widget_value", "args": {"target": {"class": "ComboBox", "label": "Textured PEI Plate"}, "value": "Smooth Cool Plate"}}, + {"tool": "list_widgets", "args": {"root": "main", "query": "Smooth Cool Plate"}, "expect": {"/nodes": {"eq": 1}}}, + {"tool": "get_app_state", "expect": {"/dialogs": {"empty": true}, "/closed_menus": {"empty": true}}} ] } diff --git a/tools/mcp/tests/scene.json b/tools/mcp/tests/scene.json index aa4b2048d8..32d0a030bf 100644 --- a/tools/mcp/tests/scene.json +++ b/tools/mcp/tests/scene.json @@ -1,15 +1,15 @@ -// Object structure and scene: transform on instances, plates and parts, the selection as select and -// get_state report it, shapes added at a size without the Primitive size dialog, arrange, parts added to an object with add_part, and the object +// Object structure and scene: transform on instances, plates and parts, the selection as select_objects and +// get_app_state report it, shapes added at a size without the Primitive size dialog, arrange, parts added to an object with add_part, and the object // list's context-menu commands (Change Type, Rename, instances, Assemble, Order By), then all of them // on one scene from start to slice. Run on a live app: -// python3 tools/mcp/orca_mcp.py run-script tools/mcp/tests/scene.json --out +// python3 tools/mcp/orca_mcp.py run-replay tools/mcp/tests/scene.json --out // A refusal can't be asserted directly (a failed step stops the run), so each one is an optional // step followed by a check that nothing changed. { - "orca_script": 1, + "orca_replay": 1, "name": "object structure and scene", - "vars": {"cube": "${script_dir}/../../../resources/handy_models/OrcaCube_v2.drc", - "svg": "${script_dir}/fixtures/star.svg"}, + "vars": {"cube": "${replay_dir}/../../../resources/handy_models/OrcaCube_v2.drc", + "svg": "${replay_dir}/fixtures/star.svg"}, "steps": [ {"tool": "wait", "args": {"for": "ready"}}, {"tool": "new_project", "args": {"discard_changes": true}}, @@ -36,10 +36,10 @@ "expect": {"/offset/0": {"ge": 99.99, "le": 100.01}, "/plate": {"eq": 0}}}, // ---- A part: the Object manipulation panel's path, measured on instance 0 ---- - {"tool": "select", "args": {"objects": [0]}}, + {"tool": "select_objects", "args": {"objects": [0]}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_svg:orca", "param": "${vars.svg}"}}, {"tool": "wait", "args": {"for": "idle"}}, - {"tool": "ui_click", "args": {"target": {"gizmo": "SVG"}}}, + {"tool": "click", "args": {"target": {"gizmo": "SVG"}}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/svg/path": {"contains": "star.svg"}}}, {"tool": "transform", "args": {"object": 0, "volume": 1, "translate": [100, 100, 15], "mode": "absolute"}, "expect": {"/volume_info/position/0": {"ge": 99.99, "le": 100.01}, "/volume_info/position/1": {"ge": 99.99, "le": 100.01}, @@ -74,14 +74,14 @@ "/items/0/volumes/1/mesh_volume": {"gt": 1000}, "/items/0/volumes/1/scaled_volume": {"gt": 0, "lt": 100}}}, // a mirrored part is mirrored in the object's frame; an instance mirrored twice is a half turn - {"tool": "select", "args": {"volumes": [[0, 1]]}, + {"tool": "select_objects", "args": {"volumes": [[0, 1]]}, "expect": {"/canvas": {"eq": "3d"}, "/objects": {"eq": [0]}, "/instances": {"eq": [[0, 0]]}, "/volumes": {"eq": [[0, 1]]}}}, - {"tool": "get_state", "expect": {"/selection/volumes": {"eq": [[0, 1]]}, "/python/available": {"eq": true}, + {"tool": "get_app_state", "expect": {"/selection/volumes": {"eq": [[0, 1]]}, "/python/available": {"eq": true}, "/python/scripts_allowed": {"ne": null}, "/design_tab": {"ne": null}}}, {"tool": "run_action", "args": {"id": "orca_command:obj_mirror_x:orca"}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/mirrored": {"eq": true}, "/items/0/instances/0/mirrored": {"eq": false}}}, // a whole instance lists no parts - {"tool": "select", "args": {"objects": [0]}, "expect": {"/instances": {"eq": [[0, 0]]}, "/volumes": {"exists": false}}}, + {"tool": "select_objects", "args": {"objects": [0]}, "expect": {"/instances": {"eq": [[0, 0]]}, "/volumes": {"exists": false}}}, {"tool": "run_action", "args": {"id": "orca_command:obj_mirror_y:orca"}}, {"tool": "list_objects", "expect": {"/items/0/instances/0/mirrored": {"eq": true}, "/items/0/instances/0/scale/0": {"gt": 0}, "/items/0/volumes/1/mirrored": {"eq": true}}}, @@ -89,20 +89,20 @@ {"tool": "list_objects", "expect": {"/items/0/instances/0/mirrored": {"eq": false}}}, // ---- Shapes at a size, without the dialog ---- - {"tool": "select", "args": {"none": true}, "expect": {"/empty": {"eq": true}, "/objects": {"empty": true}}}, + {"tool": "select_objects", "args": {"none": true}, "expect": {"/empty": {"eq": true}, "/objects": {"empty": true}}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "40 40 10"}}, {"tool": "list_objects", "expect": {"/total": {"eq": 2}, "/items/1/bbox/size/0": {"ge": 39.99, "le": 40.01}, "/items/1/bbox/size/2": {"ge": 9.99, "le": 10.01}}}, {"tool": "transform", "args": {"object": 1, "volume": 0, "translate": [1, 0, 0]}, "optional": true}, // a wrong count adds nothing - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cylinder:orca", "param": "1 2 3"}, "optional": true}, {"tool": "list_objects", "expect": {"/total": {"eq": 2}}}, // with an object selected, an error instead of a silent success - {"tool": "select", "args": {"objects": [1]}}, + {"tool": "select_objects", "args": {"objects": [1]}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cylinder:orca", "param": "10 5"}, "optional": true}, {"tool": "list_objects", "expect": {"/total": {"eq": 2}}}, - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cylinder:orca", "param": "10 5"}}, {"tool": "list_objects", "expect": {"/total": {"eq": 3}}}, @@ -133,7 +133,7 @@ {"tool": "arrange", "expect": {"/settings/spacing": {"eq": 10}, "/off_plate": {"empty": true}}}, {"tool": "run_action", "args": {"id": "orca_command:obj_arrange:orca"}, "expect": {"/level": {"eq": "success"}}}, // a Speed Dial command that does nothing (no selection) is an error step - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:obj_mirror_x:orca"}, "optional": true}, // ---- add_part: the context menu's Add items, with a size, a file or a position, one undo step each ---- @@ -173,18 +173,18 @@ {"tool": "add_part", "args": {"object": 0, "type": "modifier", "shape": "cube", "path": "${vars.cube}"}, "optional": true}, {"tool": "add_part", "args": {"object": 0, "type": "modifier", "shape": "cylinder", "size": [1, 2, 3]}, "optional": true}, {"tool": "add_part", "args": {"object": 0, "type": "part", "path": "${vars.svg}"}, "optional": true}, - {"tool": "add_part", "args": {"object": 0, "type": "modifier", "path": "${script_dir}/fixtures/heightmap.png"}, "optional": true}, - {"tool": "select", "args": {"objects": [0]}}, + {"tool": "add_part", "args": {"object": 0, "type": "modifier", "path": "${replay_dir}/fixtures/heightmap.png"}, "optional": true}, + {"tool": "select_objects", "args": {"objects": [0]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_instances_up:orca"}}, {"tool": "add_part", "args": {"object": 0, "type": "modifier", "shape": "cube"}, "optional": true}, {"tool": "list_objects", "expect": {"/items/0/volumes/6": {"exists": false}, "/items/0/instances/1": {"exists": true}}}, // the selection names the instances it is in - {"tool": "select", "args": {"instances": [[0, 1]]}, "expect": {"/objects": {"eq": [0]}, "/instances": {"eq": [[0, 1]]}}}, - {"tool": "select", "args": {"objects": [0]}, "expect": {"/instances": {"eq": [[0, 0], [0, 1]]}}}, - {"tool": "get_state", "expect": {"/selection/instances": {"eq": [[0, 0], [0, 1]]}}}, + {"tool": "select_objects", "args": {"instances": [[0, 1]]}, "expect": {"/objects": {"eq": [0]}, "/instances": {"eq": [[0, 1]]}}}, + {"tool": "select_objects", "args": {"objects": [0]}, "expect": {"/instances": {"eq": [[0, 0], [0, 1]]}}}, + {"tool": "get_app_state", "expect": {"/selection/instances": {"eq": [[0, 0], [0, 1]]}}}, {"tool": "run_action", "args": {"id": "orca_command:obj_instances_down:orca"}}, // a shape folds the instance's scale into the parts, as the menu does - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}}, {"tool": "transform", "args": {"object": 1, "scale": 1.5}}, {"tool": "add_part", "args": {"object": 1, "type": "modifier", "shape": "cube"}, "expect": {"/volume": {"eq": 1}}}, @@ -193,80 +193,80 @@ "/items/1/volumes/0/scale/0": {"ge": 1.499, "le": 1.501}}}, // ---- Object structure commands: the context menus' Change Type, Rename, number of instances, - // Set as Individual Objects and Assemble, each a run_action on what select picked ---- + // Set as Individual Objects and Assemble, each a run_action on what select_objects picked ---- {"tool": "new_project", "args": {"discard_changes": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "30 30 10"}}, {"tool": "add_part", "args": {"object": 0, "type": "modifier", "shape": "cube", "size": [10, 10, 10]}, "expect": {"/volume": {"eq": 1}}}, // Change Type, one undo step each; a seam made a part again is listed after the first part - {"tool": "select", "args": {"volumes": [[0, 1]]}}, + {"tool": "select_objects", "args": {"volumes": [[0, 1]]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_type_negative:orca"}, "expect": {"/level": {"eq": "success"}}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/type": {"eq": "negative"}}}, {"tool": "run_action", "args": {"id": "orca_command:obj_type_support_blocker:orca"}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/type": {"eq": "support_blocker"}}}, {"tool": "run_action", "args": {"id": "orca_command:undo:orca"}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/type": {"eq": "negative"}}}, - {"tool": "select", "args": {"volumes": [[0, 1]]}}, + {"tool": "select_objects", "args": {"volumes": [[0, 1]]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_type_precise_seam:orca"}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/type": {"eq": "precise_seam"}, "/items/0/volumes/1/subtype": {"eq": "center"}}}, - {"tool": "select", "args": {"volumes": [[0, 1]]}}, + {"tool": "select_objects", "args": {"volumes": [[0, 1]]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_type_part:orca"}}, {"tool": "list_objects", "expect": {"/items/0/volumes/0/type": {"eq": "part"}, "/items/0/volumes/1/type": {"eq": "part"}}}, - {"tool": "select", "args": {"volumes": [[0, 1]]}}, + {"tool": "select_objects", "args": {"volumes": [[0, 1]]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_type_modifier:orca"}}, // refused, changing nothing: the object's last solid part, and an object's row, which is not a part - {"tool": "select", "args": {"volumes": [[0, 0]]}}, + {"tool": "select_objects", "args": {"volumes": [[0, 0]]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_type_modifier:orca"}, "optional": true}, - {"tool": "select", "args": {"objects": [0]}}, + {"tool": "select_objects", "args": {"objects": [0]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_type_part:orca"}, "optional": true}, {"tool": "list_objects", "expect": {"/items/0/volumes/0/type": {"eq": "part"}, "/items/0/volumes/1/type": {"eq": "modifier"}}}, // refused: an SVG part stays a part, a modifier or a negative part {"tool": "run_action", "args": {"id": "orca_command:add_primitive_svg:orca", "param": "${vars.svg}"}}, {"tool": "wait", "args": {"for": "idle"}}, - {"tool": "ui_click", "args": {"target": {"gizmo": "SVG"}}}, + {"tool": "click", "args": {"target": {"gizmo": "SVG"}}}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/svg/path": {"contains": "star.svg"}, "/items/0/volumes/2/type": {"eq": "modifier"}}}, - {"tool": "select", "args": {"volumes": [[0, 1]]}}, + {"tool": "select_objects", "args": {"volumes": [[0, 1]]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_type_support_enforcer:orca"}, "optional": true}, {"tool": "list_objects", "expect": {"/items/0/volumes/1/type": {"eq": "part"}}}, // Rename an object and a part; refused: a name a file name cannot hold - {"tool": "select", "args": {"objects": [0]}}, + {"tool": "select_objects", "args": {"objects": [0]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_rename:orca", "param": "base"}}, - {"tool": "select", "args": {"volumes": [[0, 2]]}}, + {"tool": "select_objects", "args": {"volumes": [[0, 2]]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_rename:orca", "param": "infill zone"}}, {"tool": "run_action", "args": {"id": "orca_command:obj_rename:orca", "param": "a/b"}, "optional": true}, {"tool": "list_objects", "expect": {"/items/0/name": {"eq": "base"}, "/items/0/volumes/2/name": {"eq": "infill zone"}}}, // a number of instances in one undo step; refused: 0 and a word - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}}, - {"tool": "select", "args": {"objects": [1]}}, + {"tool": "select_objects", "args": {"objects": [1]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_set_instances:orca", "param": "6"}, "expect": {"/object": {"eq": 1}, "/instances": {"eq": 6}}}, {"tool": "run_action", "args": {"id": "orca_command:undo:orca"}}, {"tool": "list_objects", "expect": {"/items/1/instances/1": {"exists": false}}}, - {"tool": "select", "args": {"objects": [1]}}, + {"tool": "select_objects", "args": {"objects": [1]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_set_instances:orca", "param": "3"}}, {"tool": "run_action", "args": {"id": "orca_command:obj_set_instances:orca", "param": "0"}, "optional": true}, {"tool": "run_action", "args": {"id": "orca_command:obj_set_instances:orca", "param": "three"}, "optional": true}, {"tool": "list_objects", "expect": {"/total": {"eq": 2}, "/items/1/instances/2": {"exists": true}, "/items/1/instances/3": {"exists": false}}}, // every instance its own object (the whole object selected), then two of them assembled - {"tool": "select", "args": {"objects": [1]}}, + {"tool": "select_objects", "args": {"objects": [1]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_instances_to_objects:orca"}, "expect": {"/objects/0": {"eq": 1}, "/objects/2": {"eq": 3}}}, {"tool": "list_objects", "expect": {"/total": {"eq": 4}, "/items/3/instances/1": {"exists": false}}}, - {"tool": "select", "args": {"objects": [1]}}, + {"tool": "select_objects", "args": {"objects": [1]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_instances_to_objects:orca"}, "optional": true}, - {"tool": "select", "args": {"objects": [2, 3]}}, + {"tool": "select_objects", "args": {"objects": [2, 3]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_assemble:orca"}, "expect": {"/object": {"eq": 2}, "/name": {"eq": "Assembly"}}}, {"tool": "list_objects", "expect": {"/total": {"eq": 3}, "/items/2/name": {"eq": "Assembly"}, "/items/2/volumes/1": {"exists": true}}}, - {"tool": "select", "args": {"objects": [0]}}, + {"tool": "select_objects", "args": {"objects": [0]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_assemble:orca"}, "optional": true}, {"tool": "list_objects", "expect": {"/total": {"eq": 3}}}, // ---- Order By: ascending, reversed when run again, and the reply says which ---- {"tool": "new_project", "args": {"discard_changes": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 30"}}, - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 10"}}, - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}}, {"tool": "run_action", "args": {"id": "orca_command:obj_order_by_height:orca"}, "expect": {"/descending": {"eq": false}, "/order/2/object": {"eq": 2}, "/order/2/plate": {"eq": 0}}}, @@ -294,7 +294,7 @@ // a boss on top; solid parts are listed before negative ones {"tool": "add_part", "args": {"object": 0, "type": "part", "shape": "cylinder", "size": [10, 5], "position": [100, 100, 12.5]}, "expect": {"/volume": {"eq": 1}, "/volume_count": {"eq": 3}, "/volume_info/bbox/min/2": {"ge": 9.99, "le": 10.01}}}, - {"tool": "select", "args": {"volumes": [[0, 1]]}}, + {"tool": "select_objects", "args": {"volumes": [[0, 1]]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_rename:orca", "param": "boss"}}, {"tool": "transform", "args": {"object": 0, "volume": 1, "translate": [5, 0, 0]}, "expect": {"/volume_info/name": {"eq": "boss"}, "/volume_info/position/0": {"ge": 104.99, "le": 105.01}}}, @@ -307,22 +307,22 @@ {"tool": "run_action", "args": {"id": "orca_command:plate_add:orca"}}, {"tool": "transform", "args": {"object": 0, "plate": 1}, "expect": {"/plate": {"eq": 1}}}, // six copies, overlapping where Set Number of Instances puts them, spread out on plate 1 alone - {"tool": "select", "args": {"objects": [0]}}, + {"tool": "select_objects", "args": {"objects": [0]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_set_instances:orca", "param": "6"}, "expect": {"/instances": {"eq": 6}}}, {"tool": "arrange", "args": {"plates": 1, "spacing": 10, "rotate": false}, "expect": {"/off_plate": {"empty": true}, "/settings/spacing": {"eq": 10}, "/plates": {"eq": 2}}}, {"tool": "list_objects", "args": {"plate": 0}, "expect": {"/total": {"eq": 0}}}, {"tool": "list_objects", "args": {"plate": 1}, "expect": {"/items/0/instances/5/plate": {"eq": 1}}}, // every instance its own object (the whole object selected), each with the three parts - {"tool": "select", "args": {"objects": [0]}}, + {"tool": "select_objects", "args": {"objects": [0]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_instances_to_objects:orca"}, "expect": {"/objects/5": {"eq": 5}}}, {"tool": "list_objects", "expect": {"/total": {"eq": 6}, "/items/5/volumes/1/name": {"eq": "boss"}, "/items/5/volumes/2/type": {"eq": "negative"}, "/items/5/instances/0/plate": {"eq": 1}}}, - {"tool": "select", "args": {"objects": [5]}}, + {"tool": "select_objects", "args": {"objects": [5]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_mirror_x:orca"}}, {"tool": "list_objects", "expect": {"/items/5/instances/0/mirrored": {"eq": true}, "/items/4/instances/0/mirrored": {"eq": false}}}, // two assembled into one object, which goes last; the mirrored one moves up to index 3 - {"tool": "select", "args": {"objects": [0, 1]}}, + {"tool": "select_objects", "args": {"objects": [0, 1]}}, {"tool": "run_action", "args": {"id": "orca_command:obj_assemble:orca"}, "expect": {"/object": {"eq": 4}, "/name": {"eq": "Assembly"}}}, {"tool": "list_objects", "expect": {"/total": {"eq": 5}, "/items/4/volumes/5": {"exists": true}, "/items/4/bbox/min/2": {"ge": -0.001, "le": 0.001}, diff --git a/tools/mcp/tests/slice_stats.json b/tools/mcp/tests/slice_stats.json index 3d259bd66e..4e9ac4b7a5 100644 --- a/tools/mcp/tests/slice_stats.json +++ b/tools/mcp/tests/slice_stats.json @@ -2,19 +2,19 @@ // every filament slot split into model, support, flush and prime tower. A 25.6 mm cube on filament 1 // of two, then a second cube on filament 2, so every layer changes filament. Run it on a fresh // datadir set up with the default printer (Bambu Lab X1 Carbon 0.4, prime tower on): -// tools/mcp/orca_mcp.py run-script tools/mcp/tests/slice_stats.json --out /tmp/slice_stats +// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/slice_stats.json --out /tmp/slice_stats // The sums (filament_g as the slots' g, a slot's g as its four uses) are unit tests in -// tests/slic3rutils/test_mcp_results.cpp, since a script step cannot add values up. +// tests/slic3rutils/test_mcp_results.cpp, since a replay step cannot add values up. { - "orca_script": 1, + "orca_replay": 1, "name": "slice statistics", "steps": [ {"tool": "wait", "args": {"for": "ready"}}, - {"tool": "dialog_auto_answer", "args": {"rules": [{"match": "Uniform scale", "button": "ok"}]}}, + {"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "Uniform scale", "button": "ok"}]}}, {"tool": "new_project", "args": {"discard_changes": true}}, {"tool": "set_view", "args": {"tab": "prepare", "window_size": [1920, 1200]}}, - {"tool": "ui_click", "args": {"target": {"label": "Add one filament"}}}, - {"tool": "get_state", "expect": {"/presets/filaments/1": {"exists": true}}}, + {"tool": "click", "args": {"target": {"label": "Add one filament"}}}, + {"tool": "get_app_state", "expect": {"/presets/filaments/1": {"exists": true}}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca"}}, {"tool": "wait", "args": {"for": "idle"}}, @@ -34,15 +34,15 @@ "/plates/0/filaments/1/g": {"eq": 0}}}, // ---- Two colours: the second cube on filament 2 ---- - {"tool": "select", "args": {"none": true}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca"}}, {"tool": "wait", "args": {"for": "idle"}}, {"tool": "run_action", "args": {"id": "orca_command:obj_arrange:orca"}}, {"tool": "wait", "args": {"for": "idle"}}, - {"tool": "select", "args": {"objects": [1]}}, + {"tool": "select_objects", "args": {"objects": [1]}}, // To the canvas by name: without a target the key goes to whatever has focus. - {"tool": "ui_key", "args": {"target": {"name": "OrcaSceneCanvas"}, "keys": "2"}, "expect": {"/to": {"eq": "wxGLCanvas"}}}, - {"tool": "select", "args": {"none": true}}, + {"tool": "press_keys", "args": {"target": {"name": "OrcaSceneCanvas"}, "keys": "2"}, "expect": {"/to": {"eq": "wxGLCanvas"}}}, + {"tool": "select_objects", "args": {"none": true}}, {"tool": "slice", "expect": { "/plates/0/outcome": {"eq": "ok"}, "/plates/0/layers": {"eq": 128}, diff --git a/tools/mcp/tests/web_dialogs.json b/tools/mcp/tests/web_dialogs.json index 92ef80bfdf..5650923657 100644 --- a/tools/mcp/tests/web_dialogs.json +++ b/tools/mcp/tests/web_dialogs.json @@ -4,9 +4,9 @@ // colour it returns read back from the native dialog under it; the setup wizard's first steps (a // region, Next to the printer page, a printer card). Run it on a fresh datadir set up with the default // printer: -// tools/mcp/orca_mcp.py run-script tools/mcp/tests/web_dialogs.json --out /tmp/web_dialogs +// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/web_dialogs.json --out /tmp/web_dialogs { - "orca_script": 1, + "orca_replay": 1, "name": "web dialogs through the GUI tools", "steps": [ {"tool": "wait", "args": {"for": "ready"}}, @@ -15,40 +15,40 @@ // ---- The preset bundle dialog, closed by its page's own button ---- {"tool": "run_action", "args": {"id": "orca_command:preset_bundle:orca"}, "await": false, "save_as": "bundle"}, {"tool": "wait", "args": {"for": "dialog", "timeout_s": 10}, "expect": {"/satisfied": {"eq": true}}}, - {"tool": "ui_snapshot", "args": {"root": "dialog"}, "expect": {"/nodes": {"gt": 2}}}, - {"tool": "ui_click", "args": {"target": {"css": "#close_btn", "within": "Preset Bundle"}}, "expect": {"/closed": {"eq": true}}}, + {"tool": "list_widgets", "args": {"root": "dialog"}, "expect": {"/nodes": {"gt": 2}}}, + {"tool": "click", "args": {"target": {"css": "#close_btn", "within": "Preset Bundle"}}, "expect": {"/closed": {"eq": true}}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.bundle}"}}, - {"tool": "get_state", "expect": {"/dialogs": {"empty": true}}}, + {"tool": "get_app_state", "expect": {"/dialogs": {"empty": true}}}, // ---- The colour picker over the filament picker ---- - {"tool": "ui_click", "args": {"target": {"label": "1", "class": "wxBitmapButton"}}, "await": false, "save_as": "swatch"}, + {"tool": "click", "args": {"target": {"label": "1", "class": "wxBitmapButton"}}, "await": false, "save_as": "swatch"}, {"tool": "wait", "args": {"for": "dialog", "timeout_s": 10}, "expect": {"/satisfied": {"eq": true}}}, - {"tool": "ui_click", "args": {"target": {"label": "+ More Colors", "within": "Select Filament"}}, "await": false, "save_as": "more"}, - {"tool": "ui_input", "args": {"target": {"web": "Hex color", "within": "Color Picker"}, "value": "FF0000"}, + {"tool": "click", "args": {"target": {"label": "+ More Colors", "within": "Select Filament"}}, "await": false, "save_as": "more"}, + {"tool": "set_widget_value", "args": {"target": {"web": "Hex color", "within": "Color Picker"}, "value": "FF0000"}, "expect": {"/value": {"eq": "FF0000FF"}}}, - {"tool": "ui_snapshot", "args": {"root": "dialog", "query": "FF0000FF"}, "expect": {"/nodes": {"ge": 1}}}, - {"tool": "ui_mouse", "args": {"target": {"css": "#spectrum", "within": "Color Picker"}, "action": "drag", "x": 20, "y": 20, + {"tool": "list_widgets", "args": {"root": "dialog", "query": "FF0000FF"}, "expect": {"/nodes": {"ge": 1}}}, + {"tool": "mouse_gesture", "args": {"target": {"css": "#spectrum", "within": "Color Picker"}, "action": "drag", "x": 20, "y": 20, "to": [200, 100], "steps": 6}, "expect": {"/done": {"eq": "drag"}}}, - {"tool": "ui_snapshot", "args": {"root": "dialog", "query": "FF0000FF"}, "expect": {"/nodes": {"eq": 0}}}, - {"tool": "ui_click", "args": {"target": {"web": "OK", "within": "Color Picker"}}, + {"tool": "list_widgets", "args": {"root": "dialog", "query": "FF0000FF"}, "expect": {"/nodes": {"eq": 0}}}, + {"tool": "click", "args": {"target": {"web": "OK", "within": "Color Picker"}}, "expect": {"/closed": {"eq": true}, "/dialogs/0/title": {"eq": "Select Filament"}}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.more}"}}, - {"tool": "ui_snapshot", "args": {"root": "dialog", "query": "#26A69A"}, "expect": {"/nodes": {"eq": 0}}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Select Filament"}, "button": "cancel"}}, + {"tool": "list_widgets", "args": {"root": "dialog", "query": "#26A69A"}, "expect": {"/nodes": {"eq": 0}}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Select Filament"}, "button": "cancel"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.swatch}"}}, - {"tool": "get_state", "expect": {"/dialogs": {"empty": true}}}, + {"tool": "get_app_state", "expect": {"/dialogs": {"empty": true}}}, // ---- The setup wizard's first steps ---- {"tool": "run_action", "args": {"id": "orca_command:help_setup_wizard:orca"}, "await": false, "save_as": "wizard"}, {"tool": "wait", "args": {"for": "dialog", "timeout_s": 30}, "expect": {"/satisfied": {"eq": true}}}, - {"tool": "ui_click", "args": {"target": {"web": "Europe", "within": "Setup Wizard"}}, "expect": {"/checked": {"eq": true}}}, - {"tool": "ui_click", "args": {"target": {"web": "Next", "within": "Setup Wizard"}}, + {"tool": "click", "args": {"target": {"web": "Europe", "within": "Setup Wizard"}}, "expect": {"/checked": {"eq": true}}}, + {"tool": "click", "args": {"target": {"web": "Next", "within": "Setup Wizard"}}, "expect": {"/navigated": {"eq": true}, "/url": {"contains": "/guide/21/"}}}, - {"tool": "ui_click", "args": {"target": {"web": "Nozzle 0.4 Marlin", "kind": "button", "within": "Setup Wizard"}}, + {"tool": "click", "args": {"target": {"web": "Nozzle 0.4 Marlin", "kind": "button", "within": "Setup Wizard"}}, "expect": {"/checked": {"eq": true}}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Setup Wizard"}, "button": "close"}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Setup Wizard"}, "button": "close"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.wizard}"}}, - {"tool": "get_state", "expect": {"/dialogs": {"empty": true}}} + {"tool": "get_app_state", "expect": {"/dialogs": {"empty": true}}} ] } diff --git a/tools/mcp/tests/webview_modal.json b/tools/mcp/tests/webview_modal.json index 1dc60ab26e..9d5d8ec21e 100644 --- a/tools/mcp/tests/webview_modal.json +++ b/tools/mcp/tests/webview_modal.json @@ -1,11 +1,11 @@ -// Scripts in the web views of modal dialogs, which webview_eval runs in whenever the dialog is the +// Scripts in the web views of modal dialogs, which run_javascript runs in whenever the dialog is the // topmost: by default and by locator, and the bundle dialog closed from its page's own button, which // replies closed. Run it on a fresh datadir set up with the default printer: -// tools/mcp/orca_mcp.py run-script tools/mcp/tests/webview_modal.json --out /tmp/webview_modal +// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/webview_modal.json --out /tmp/webview_modal // The refusals (a web view behind a modal, a dialog under the topmost) are in // tools/mcp/test_webview_modal.py; the same dialogs driven through the GUI tools are in web_dialogs.json. { - "orca_script": 1, + "orca_replay": 1, "name": "web views in modal dialogs", "steps": [ {"tool": "wait", "args": {"for": "ready"}}, @@ -14,20 +14,20 @@ // ---- The preset bundle dialog ---- {"tool": "run_action", "args": {"id": "orca_command:preset_bundle:orca"}, "await": false, "save_as": "bundle"}, {"tool": "wait", "args": {"for": "dialog", "timeout_s": 10}, "expect": {"/satisfied": {"eq": true}}}, - {"tool": "webview_eval", "args": {"script": "document.title"}, + {"tool": "run_javascript", "args": {"code": "document.title"}, "expect": {"/result": {"eq": "Preset Bundle"}, "/url": {"contains": "PresetBundleDialog"}}}, - {"tool": "webview_eval", "args": {"script": "!!document.getElementById('close_btn')", "target": {"class": "webview", "within": "Preset Bundle"}}, + {"tool": "run_javascript", "args": {"code": "!!document.getElementById('close_btn')", "target": {"class": "webview", "within": "Preset Bundle"}}, "expect": {"/result": {"eq": true}}}, - {"tool": "webview_eval", "args": {"script": "document.getElementById('close_btn').click()"}, "expect": {"/closed": {"eq": true}}}, + {"tool": "run_javascript", "args": {"code": "document.getElementById('close_btn').click()"}, "expect": {"/closed": {"eq": true}}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.bundle}"}}, - {"tool": "get_state", "expect": {"/dialogs": {"empty": true}}}, + {"tool": "get_app_state", "expect": {"/dialogs": {"empty": true}}}, // ---- The setup wizard: its page is read, and the dialog only closed ---- {"tool": "run_action", "args": {"id": "orca_command:help_setup_wizard:orca"}, "await": false, "save_as": "wizard"}, {"tool": "wait", "args": {"for": "dialog", "timeout_s": 30}, "expect": {"/satisfied": {"eq": true}}}, - {"tool": "webview_eval", "args": {"script": "typeof document.title"}, "expect": {"/result": {"eq": "string"}, "/url": {"contains": "/guide/"}}}, - {"tool": "dialog_respond", "args": {"dialog": {"title": "Setup Wizard"}, "button": "close"}}, + {"tool": "run_javascript", "args": {"code": "typeof document.title"}, "expect": {"/result": {"eq": "string"}, "/url": {"contains": "/guide/"}}}, + {"tool": "answer_dialog", "args": {"dialog": {"title": "Setup Wizard"}, "button": "close"}}, {"tool": "wait", "args": {"for": "job", "job": "${jobs.wizard}"}}, - {"tool": "get_state", "expect": {"/dialogs": {"empty": true}}} + {"tool": "get_app_state", "expect": {"/dialogs": {"empty": true}}} ] }