diff --git a/docs/HLSD/mcp-server.md b/docs/HLSD/mcp-server.md index dd281f6c1b..53481bc092 100644 --- a/docs/HLSD/mcp-server.md +++ b/docs/HLSD/mcp-server.md @@ -444,6 +444,14 @@ process, so the journal leaves them out of those tools' calls (`without_expected `api_call` and inline `run_script` steps too, and a replay addresses by index; a `run_python` 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, +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 diff --git a/src/slic3r/GUI/Mcp/McpService.cpp b/src/slic3r/GUI/Mcp/McpService.cpp index 50811a0bc8..3787720cb1 100644 --- a/src/slic3r/GUI/Mcp/McpService.cpp +++ b/src/slic3r/GUI/Mcp/McpService.cpp @@ -168,15 +168,15 @@ const char* kInstructions = "scope, which looks through the process, filament and printer settings; each item names its scope, the one " "set_settings needs (its default is the process), and its meta has its description and where (its settings page and " "group).\n" - "- Objects, parts and plates are 0-based indices, as list_objects and list_plates give them; filament slots and " - "Preview layers are 1-based.\n" + "- Objects, parts (volume in argument names) and plates are 0-based indices, as list_objects and list_plates give " + "them; filament slots and Preview layers are 1-based.\n" "- Lists come in pages: {items, offset, total}, with next_offset while more remain (list_actions names its items " "actions); call again with that offset to read on.\n" "- Paths are absolute. Outputs never overwrite an existing file unless overwrite is true.\n" "UI lane:\n" "- run_action runs every Speed Dial command (list_actions to search): prefer it to GUI clicks.\n" - "- ui_snapshot lists widgets, menus, 3D toolbar items, gizmos and ImGui items with refs; ui_click / ui_input / " - "ui_key / ui_mouse act on refs from the latest snapshot.\n" + "- ui_snapshot lists widgets, menus, 3D toolbar items, gizmos, ImGui items and web page elements with refs; ui_click " + "/ ui_input / ui_key / ui_mouse act on refs from the latest snapshot, or on locators, which its description lists.\n" "- Gizmos (Cut, Text, SVG, the painting tools...): ui_click {target: {gizmo: \"Cut\"}} opens one; its panel's " "fields and buttons are ImGui items for ui_input / ui_click, and painting is a ui_mouse drag starting on the " "object. Turn the camera with set_view camera or orbit, never a drag: what a drag does follows the user's mouse " diff --git a/src/slic3r/GUI/Mcp/McpToolsApp.cpp b/src/slic3r/GUI/Mcp/McpToolsApp.cpp index 53482b7dee..5b91985606 100644 --- a/src/slic3r/GUI/Mcp/McpToolsApp.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsApp.cpp @@ -240,10 +240,9 @@ void register_app_tools(McpService& service) ToolDef wait = inspect_tool( "wait", L("Wait for a condition"), "Block until a condition holds or timeout_s passes (max 50). for: \"ready\" (startup finished), \"idle\" (no dialog, " - "no running job (a run_python run counts only through the calls it makes), nothing slicing or arranging, no gizmo " - "working in the background), \"dialog\" / \"no_dialog\", or " - "\"job\" with a job id returned by " - "an earlier call - then the reply is that job's result. Returns {satisfied:false} on timeout; call it again.", + "no running job, nothing slicing or arranging, no gizmo working in the background; a run_python run counts only " + "through the calls it makes), \"dialog\" / \"no_dialog\", or \"job\" with a job id an earlier call returned, whose " + "result is then the reply. On timeout the reply is {satisfied: false}: call it again.", object_schema({{"for", enum_prop({"ready", "idle", "dialog", "no_dialog", "job"}, "What to wait for; default job when job " "is given, else idle.")}, {"job", prop("string", "Job id, for \"job\".")}, diff --git a/src/slic3r/GUI/Mcp/McpToolsConfig.cpp b/src/slic3r/GUI/Mcp/McpToolsConfig.cpp index e9f8ced963..f46e3df3ba 100644 --- a/src/slic3r/GUI/Mcp/McpToolsConfig.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsConfig.cpp @@ -2007,11 +2007,12 @@ void register_config_tools(McpService& service) ToolDef save = mutate_tool( "save_preset", L("Save a preset"), - "Save the printer, process or filament preset being edited, unsaved changes included, under name, as the tab's Save " - "and the Save preset dialog's OK do; it is then selected. A filament is filament_slot's (default 1), and every slot " - "using the old preset takes the new one. Replacing another existing preset needs overwrite (pass it in scripts meant " - "to be rerun). Reply: saved, user, project, inherits, filament_slots. A temperature warning or an unsaved-changes " - "prompt makes it blocked_by_dialog. To keep only some edits, set_settings {reset_all: true, values} first.", + "Save the printer, process or filament preset being edited, with its unsaved changes, as a preset called name, " + "which is then selected: what the tab's Save button does through its dialog. A filament is filament_slot's " + "(default 1), and every slot using the old preset takes the new one. Replacing another existing preset needs " + "overwrite (pass it in scripts meant to be rerun). Reply: saved, user, project, inherits, filament_slots. A " + "temperature warning or an unsaved-changes prompt makes it blocked_by_dialog. To keep only some edits, set_settings " + "{reset_all: true, values} first.", object_schema({{"type", enum_prop({"printer", "process", "filament"}, "Preset category.")}, {"name", prop("string", "Name to save under.")}, {"filament_slot", {{"type", "integer"}, {"minimum", 1}, {"description", "Filament slot, 1-based."}}}, @@ -2141,25 +2142,27 @@ void register_config_tools(McpService& service) reg.add(inspect_tool( "get_settings", L("Read settings"), - "Read setting values (as OrcaSlicer serializes them) with meta: label, description (what the setting does, when to " - "change it, what it affects), where (its settings page and group), type, unit, range, allowed values and their " - "labels, and mode. Name keys; find the settings for an effect with query, a few words matched in keys, labels and " - "descriptions, best matches first; or list one page or group with where (an unknown one lists them all). Without " - "these, every option of the scope is listed, paged, without meta in a preset scope. Without a scope, keys and query " - "look through the process, filament and printer settings and each item names its scope, which set_settings takes; " - "anything else reads the process. Keys the scope lacks are listed in unknown_keys, and scope_of names the scope " - "that has each one another scope has. A per-variant value lists in " - "meta its variants (what each entry is for) and active (the entry each " - "extruder prints with). preset reads a saved preset without selecting it; compare lists only the keys that differ " - "from another preset, each with value and other. For object/volume scopes only the overrides that object or part " - "carries are listed, each with effective (the value it prints with) and source (part, object, process or default); " - "an object's item lists in parts the parts and modifiers that override the key inside their own volume. The project " - "scope has the plate type, slot colours, flushing volumes, purge mode, prime tower position per plate, which slots are " - "mixed and, with several extruders, the filament grouping; meta.offered lists the choices this printer has. The plate " - "scope lists a plate's curr_bed_type, print_sequence, spiral_mode, first_layer_print_sequence, " + "Read settings: each item has its value, as OrcaSlicer writes it, and meta: label, description (what the setting " + "does, when to change it), where (its settings page and group), type, unit, range, allowed values and mode. Choose " + "them by keys; by query, a few words matched in keys, labels and descriptions, best matches first; by where, a page " + "or group (an unknown one lists them all); or by none of these, for the whole scope, paged and, in a preset scope, " + "without meta. Keys the scope lacks are listed in unknown_keys, and scope_of gives the scope of those another " + "scope has.\n" + "- No scope: keys and query look through the process, filament and printer settings, and each item names its " + "scope, the one set_settings takes; anything else reads the process.\n" + "- print (process), filament, printer: the preset being edited, or with preset a saved one; compare lists only " + "the keys that differ from another preset (value and other). A per-variant value lists in meta its variants (what " + "each entry is for) and active (the entry each extruder prints with).\n" + "- object, volume: the overrides that object or part carries, each with effective (the value it prints with) and " + "source (part, object, process or default); an object's item lists in parts the parts and modifiers that override " + "the key inside their own volume.\n" + "- project: the plate type, slot colours, flushing volumes, purge mode, prime tower position per plate, mixed slots " + "and, with several extruders, the filament grouping; meta.offered lists the choices this printer has.\n" + "- plate: a plate's curr_bed_type, print_sequence, spiral_mode, first_layer_print_sequence, " "other_layers_print_sequence, name and locked, each with value (the plate's own, null where it follows the global " - "setting or Auto) and effective. The preferences scope reads the named keys of the app configuration (the Preferences " - "dialog's settings, keys as its controls are named), values as stored, and lists no keys unasked.", + "setting or Auto) and effective.\n" + "- preferences: the named keys of the app configuration (the Preferences dialog's settings, keys as its controls " + "are named), as stored; it lists none unasked.", object_schema({{"scope", read_scope_prop}, {"keys", array_prop({{"type", "string"}}, "Option keys, e.g. [\"layer_height\", \"wall_loops\"].")}, {"query", prop("string", "A few distinctive words, e.g. \"stringing\" or \"ooze travel\"; the best 20 " @@ -2187,26 +2190,27 @@ void register_config_tools(McpService& service) reg.add(mutate_tool( "set_settings", L("Change settings"), - "Change settings of one scope (default the process) as if typed into the settings tab: all values are parsed " - "strictly first and applied together, and nothing changes if any is invalid; a key of another scope is refused " - "with that scope named, as get_settings without a scope reports it. Values may be strings in OrcaSlicer's format " - "(\"15%\", \"0.2\", \"1,2\") or JSON numbers, booleans and arrays (a point as [x, y]). object/volume scopes set per-object or per-part overrides, of the " - "keys the object list offers there; a null value removes an override. extruder is the object's or part's filament " - "(1-based; 0 or null is Default), set as the Change Filament menu does. A preset's per-variant value (get_settings " - "meta.variants) takes a single value for the entries in use (meta.active, as the tab writes the variant it shows), " - "{\"index\": i, \"value\": v} for one entry, or an array of all. " - "In a preset scope, null takes a key back to its saved value (reset_to parent: the parent's), and reset_all first " - "discards every unsaved change, as the tab's undo button does (reply: reverted), then applies values. Reply: applied, " - "and changed, every setting the call changed, including those the app adjusted in turn. Spiral vase and some others " - "confirm their adjustments in a dialog (blocked_by_dialog). The project scope writes as the sidebar's controls do: " - "curr_bed_type, filament_colour (#RRGGBB per slot), flush_multiplier, flush_volumes_matrix (per nozzle, slots x slots " - "from row to column, in config order over every slot, mixed ones left as they are; before the multiplier, which the " - "G-code header applies; a colour change can recalculate it, so set it last), prime_volume_mode, and wipe_tower_x/y " - "(mm from the plate's origin, one per plate; undoable). The plate scope writes as the Plate Settings dialog's OK does, " - "after selecting the plate as its icon does: curr_bed_type, print_sequence (\"by layer\", \"by object\"), " - "spiral_mode (true asks for confirmation: blocked_by_dialog), first_layer_print_sequence (every slot once, e.g. [2, " - "1]) and other_layers_print_sequence ([{from: layer >= 2, to, order}], to omitted for the last layer), null for the " - "global setting or Auto; name, and locked (true or false). One undo step.", + "Change settings of one scope (default the process) as typing them into its settings tab would. Values are strings " + "in OrcaSlicer's format (\"15%\", \"0.2\", \"1,2\") or JSON numbers, booleans and arrays (a point as [x, y]). All are " + "parsed strictly first and applied together, so nothing changes if one is invalid, and a key of another scope is " + "refused with that scope named. Reply: applied, and changed, every setting the call changed, including those the " + "app adjusted in turn. One undo step. Spiral vase and a few others confirm their adjustments in a dialog " + "(blocked_by_dialog).\n" + "- print (process), filament, printer: null takes a key back to its saved value, or with reset_to parent to the " + "parent's; reset_all first discards every unsaved change, as the tab's undo button does (reply: reverted). A " + "per-variant value (get_settings meta.variants) takes one value for the entries in use (meta.active), {index, " + "value} for one entry, or an array of all.\n" + "- object, volume: overrides of the keys the object list offers there; null removes one. extruder is the object's " + "or part's filament (1-based; 0 or null for Default), set as the Change Filament menu does.\n" + "- project, as the sidebar's controls write them: curr_bed_type, filament_colour (#RRGGBB per slot), " + "flush_multiplier, flush_volumes_matrix, prime_volume_mode, and wipe_tower_x/y (mm from the plate's origin, one per " + "plate). flush_volumes_matrix is per nozzle, slots x slots from row to column, in config order over every slot, " + "before the multiplier; mixed slots' entries are left as they are, and a colour change can recalculate it, so set " + "it last.\n" + "- plate, which it selects and writes as the Plate Settings dialog's OK does: curr_bed_type, print_sequence (\"by " + "layer\", \"by object\"), spiral_mode (true asks for confirmation), first_layer_print_sequence (every slot once, " + "e.g. [2, 1]), other_layers_print_sequence ([{from: layer >= 2, to, order}], to omitted for the last layer), name " + "and locked; null returns a value to the global setting or Auto.", object_schema({{"scope", write_scope_prop}, {"values", {{"type", "object"}, {"description", "{key: value}, or {key: {index, value}} for one entry"}}}, {"reset_all", prop("boolean", "Preset scopes: discard the unsaved changes before applying values.")}, diff --git a/src/slic3r/GUI/Mcp/McpToolsLayers.cpp b/src/slic3r/GUI/Mcp/McpToolsLayers.cpp index 519eaf9383..3f2ba7d7d6 100644 --- a/src/slic3r/GUI/Mcp/McpToolsLayers.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsLayers.cpp @@ -588,7 +588,7 @@ void register_layer_tools(McpService& service) "set_layer_ranges", L("Set height range modifiers"), "Replace an object's height range modifiers (Height Range Modifier in the object list): Z ranges in mm, each printed " "with its own layer_height, filament and process settings, starting from the object's layer height and filament. " - "Ranges may touch but not overlap; [] removes them all. One undo step; the object is selected. Replies with the " + "Ranges may touch but not overlap; [] removes them all. One undo step; the object is selected. Reply: the " "object's height and its ranges as list_objects shows them, and warnings, such as a variable layer height profile " "deciding the layer heights instead.", object_schema({{"object", {{"type", "integer"}, {"minimum", 0}, {"description", "Object index (list_objects)."}}}, @@ -606,7 +606,7 @@ void register_layer_tools(McpService& service) "Run the Variable layer height panel's Adaptive, Smooth or Reset on an object, without opening the panel: adaptive " "computes layer heights from the object's shape (inside a height range, the range's layer_height), smooth smooths " "its profile (or the one its height ranges give), reset goes back to its layer height and ranges. One undo step; " - "the object is selected. Replies with the object's height, its layer_height_profile {points, min_height, " + "the object is selected. Reply: the object's height, its layer_height_profile {points, min_height, " "max_height} as list_objects shows it (absent after reset), and warnings.", object_schema({{"object", {{"type", "integer"}, {"minimum", 0}, {"description", "Object index (list_objects)."}}}, {"object_id", expected_id_prop("object")}, @@ -646,8 +646,8 @@ void register_layer_tools(McpService& service) "plate needs an up-to-date slice, or must be the one the Preview still shows after an earlier edit; the call selects " "it and shows the Preview. Applies clear, then remove, then add, all checked first. One code per layer: a custom " "code or filament change where there is one replaces it. Not undoable, as in the slider. A change invalidates the " - "plate's slice: slice again before exporting. Replies with the plate's codes as list_plates' layer_gcode lists " - "them, each with z and layer.", + "plate's slice: slice again before exporting. Reply: the plate's codes as list_plates' layer_gcode lists them, " + "each with z and layer.", object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "Default: the current plate."}}}, {"add", array_prop(object_schema({{"layer", layer}, {"z", z}, diff --git a/src/slic3r/GUI/Mcp/McpToolsProject.cpp b/src/slic3r/GUI/Mcp/McpToolsProject.cpp index 529506117c..e30ec6d7dc 100644 --- a/src/slic3r/GUI/Mcp/McpToolsProject.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsProject.cpp @@ -387,12 +387,14 @@ void register_project_tools(McpService& service) reg.add(mutate_tool( "open_files", L("Open files"), "Open model files (STL, 3MF, STEP, OBJ, AMF, SVG...), a project (.3mf) or G-code by absolute path, without a file " - "dialog. Models are added to the current project. A .3mf opens as a project (replacing the current one: pass " - "discard_changes when it has unsaved changes) unless as is \"geometry\". Importing can open a dialog (STEP mesh " - "options, for instance); the reply is then blocked_by_dialog.", + "dialog. Models are added to the current project. A .3mf opens as a project, replacing the current one, unless as " + "is \"geometry\"; when the current project has unsaved changes that fails, changing nothing, unless " + "discard_changes. Importing can open a dialog (STEP mesh options, for instance); the reply is then " + "blocked_by_dialog.", object_schema({{"paths", array_prop({{"type", "string"}}, "Absolute paths.")}, {"as", enum_prop({"auto", "geometry", "project"}, "How to open .3mf files. Default auto (= project).")}, - {"discard_changes", prop("boolean", "Replace a project with unsaved changes without asking.")}}, + {"discard_changes", prop("boolean", "Drop the project's unsaved changes rather than fail when a .3mf " + "replaces it.")}}, {"paths"}), [&service](const json& args, ToolContext& ctx) { std::vector paths; @@ -436,12 +438,14 @@ void register_project_tools(McpService& service) reg.add(mutate_tool( "new_project", L("New project"), - "Start a new, empty project. Fails when the current project has unsaved changes unless discard_changes is true. " - "Modified printer, process and filament presets are kept for the new project, unless changes is \"discard\", the " - "two answers of New Project's prompt. Reply: objects, names, plates; when presets had or have unsaved changes, " - "discarded and modified list per preset the keys dropped and the keys still unsaved.", - object_schema({{"discard_changes", prop("boolean", "Drop unsaved changes without asking.")}, - {"changes", enum_prop({"keep", "discard"}, "Unsaved changes of the presets: keep them (default) or drop them.")}}), + "Start a new, empty project. Fails, changing nothing, when the current project has unsaved changes, unless " + "discard_changes. The presets' unsaved changes carry over to the new project unless changes is \"discard\", as " + "New Project's prompt offers. Reply: objects, names, plates; when presets had or have unsaved changes, discarded " + "and modified list per preset the keys dropped and the keys still unsaved.", + object_schema({{"discard_changes", prop("boolean", "Drop the project's unsaved changes rather than fail; for the " + "presets', see changes.")}, + {"changes", enum_prop({"keep", "discard"}, "The presets' unsaved changes, not the project's: keep " + "them for the new project (default) or drop them.")}}), [&service](const json& args, ToolContext& ctx) { const bool discard = arg_bool(args, "discard_changes", false) || service.discard_authorized(ctx.lineage()); const bool discard_presets = arg_string(args, "changes", "keep") == "discard"; @@ -501,9 +505,10 @@ void register_project_tools(McpService& service) {"auto_scale", prop("boolean", "temperature, vfa: scale the model to the nozzle (default true).")}, {"auto_adjust", prop("boolean", "vfa: lower the layer height, else the end speed, to stay within the filament's " "maximum volumetric speed (default true).")}, - {"discard_changes", prop("boolean", "Replace a project with unsaved changes.")}, - {"changes", enum_prop({"keep", "discard"}, "Unsaved preset changes: keep them for the test, or drop them first. " - "Required when presets are modified.")}}, + {"discard_changes", prop("boolean", "Drop the project's unsaved changes rather than fail; for the presets', " + "see changes.")}, + {"changes", enum_prop({"keep", "discard"}, "The presets' unsaved changes, not the project's: keep them for the " + "test or drop them first. Required when presets are modified.")}}, {"test"}), [&service](const json& args, ToolContext& ctx) { json recorded = args; @@ -618,7 +623,7 @@ void register_project_tools(McpService& service) // A project file holds no G-code, so a .gcode.3mf saved here would lack what its name promises. if (boost::algorithm::iends_with(arg_string(args, "path"), ".gcode.3mf")) throw ToolFailure("save_project writes the project without G-code; a .gcode.3mf with the sliced plates is " - "export {format: \"sliced_3mf\"} (plate \"all\" for every plate)"); + "export {format: \"sliced_3mf\"} (plates \"all\" for every plate)"); std::string err; auto path = resolve_output_path(arg_string(args, "path"), arg_bool(args, "overwrite", false), err); if (!path) @@ -635,13 +640,15 @@ void register_project_tools(McpService& service) reg.add(mutate_tool( "export", L("Export"), - "Write the project to a file without a dialog. gcode: the current plate's G-code (slice first; runs in the " - "background and the call completes when the file is written). sliced_3mf: the sliced plate (or all plates) as " - ".gcode.3mf. 3mf: the model without slicing data. stl: all objects as one STL. Without format, the path's " - "extension (.gcode, .gcode.3mf, .3mf, .stl) says which. plate selects the plate first.", + "Write the project to a file without a dialog. gcode: the plate's G-code (slice first; it is written in the " + "background, and the call returns once it is). sliced_3mf: the sliced plate, or all plates, as .gcode.3mf. 3mf: " + "the model without slicing data. stl: all objects as one STL. Without format, the path's extension (.gcode, " + ".gcode.3mf, .3mf, .stl) says which.", object_schema({{"format", enum_prop({"gcode", "sliced_3mf", "3mf", "stl"}, "What to write; default from the path's extension.")}, {"path", prop("string", "Absolute output path.")}, - {"plate", {{"type", {"string", "integer"}}, {"description", "\"current\" (default), a plate index, or \"all\" (sliced_3mf only)."}}}, + {"plates", {{"type", {"string", "integer"}}, + {"description", "\"current\" (default), a plate index, which is selected first, or \"all\" " + "(sliced_3mf only)."}}}, {"overwrite", prop("boolean", "Replace an existing file.")}}, {"path"}), [](const json& args, ToolContext& ctx) { @@ -650,10 +657,10 @@ void register_project_tools(McpService& service) auto path = resolve_output_path(arg_string(args, "path"), arg_bool(args, "overwrite", false), err); if (!path) throw ToolFailure(err); - const json plate = args.value("plate", json("current")); + const json plate = args.value("plates", json("current")); const bool all = plate.is_string() && plate.get() == "all"; if (all && format != "sliced_3mf") - throw ToolFailure("plate \"all\" applies to sliced_3mf only"); + throw ToolFailure("plates \"all\" applies to sliced_3mf only"); json started = ctx.run_ui([&]() -> json { // A G-code export finishes in the background: held from before it starts. if (format == "gcode") diff --git a/src/slic3r/GUI/Mcp/McpToolsPython.cpp b/src/slic3r/GUI/Mcp/McpToolsPython.cpp index f039a4d8a1..244b7f4857 100644 --- a/src/slic3r/GUI/Mcp/McpToolsPython.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsPython.cpp @@ -209,7 +209,7 @@ void register_python_tools(McpService& service) "python_api says is installed or not; a file run's PEP 723 block can install it. The code runs on a worker " "thread, where calls documented as UI thread only raise RuntimeError. The run ends once its code and the non-daemon " "threads and pool tasks it started are done; its windows close with it. `args` holds the args you pass; set `result` " - "to a JSON value to return it; print() output comes back as output. Returns {status: finished | raised | cancelled | " + "to a JSON value to return it; print() output comes back as output. Reply: {status: finished | raised | cancelled | " "timed_out, result, output, traceback?, message?}; a script that raised changed what it changed before. Python runs " "with OrcaSlicer's full access to the computer, so a person must allow Python scripts in Preferences first. Recorded " "by export_script as one step with its code, which a replay runs again against the project as it is then.", diff --git a/src/slic3r/GUI/Mcp/McpToolsScene.cpp b/src/slic3r/GUI/Mcp/McpToolsScene.cpp index 0537309e03..40567d4970 100644 --- a/src/slic3r/GUI/Mcp/McpToolsScene.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsScene.cpp @@ -1040,7 +1040,7 @@ void register_scene_tools(McpService& service) "\"absolute\" sets it. An instance is dropped back onto the bed unless drop_to_bed is false. A part moves as the " "Object manipulation panel moves it: translate and rotate along the bed's axes, measured on instance 0, scale and " "size along its own axes; every instance shows the change, and Auto Drop may lower the object afterwards. One " - "undo step. Replies with the instance's offset, scale and plate, or the part's size along its own axes and its " + "undo step. Reply: the instance's offset, scale and plate, or the part's size along its own axes and its " "list_objects entry (volume_info).", object_schema({{"object", {{"type", "integer"}, {"minimum", 0}, {"description", "Object index (list_objects)."}}}, {"instance", {{"type", "integer"}, {"minimum", 0}, {"description", "Default 0."}}}, @@ -1081,8 +1081,9 @@ void register_scene_tools(McpService& service) "menu puts it (a shape beside the object, a file at its coordinates relative to the object's first part) unless " "position is given. Like the menu, adding a shape folds the instance's rotation and scale into the object's parts " "(the instance's scale then reads 1). Refused for an object with several instances: add parts first. A STEP file " - "may ask for mesh options (blocked_by_dialog). The new part is selected; one undo step. Replies with its index, which is not always the last (parts are ordered by type), " - "the object's part count and the part's list_objects entry (volume_info).", + "may ask for mesh options (blocked_by_dialog). The new part is selected; one undo step. Reply: its index, which is " + "not always the last (parts are ordered by type), the object's part count and the part's list_objects entry " + "(volume_info).", object_schema({{"object", {{"type", "integer"}, {"minimum", 0}, {"description", "Object index (list_objects)."}}}, {"object_id", expected_id_prop("object")}, {"type", enum_prop({"part", "negative", "modifier", "support_blocker", "support_enforcer", "precise_seam"}, @@ -1103,12 +1104,13 @@ void register_scene_tools(McpService& service) reg.add(mutate_tool( "arrange", L("Arrange objects or fill the bed"), - "Arrange objects as the toolbar's Arrange does (every unlocked plate) or as one plate's Arrange icon does (plates: " - "an index or \"current\"), or fill object fill's plate with more of it, as Fill bed with instances or copies does. " - "spacing, rotate, align_y and multi_material are the Arrange options panel's settings: values given are kept as the " - "panel keeps them, so later arranges use them too. Waits for the arrangement (a longer one replies with a job); " - "the reply has the settings in force, instances left off every plate, plates the all-plates arrange skipped and " - "the job's notifications. An arrange may reorder objects, so list_objects again. One undo step.", + "Arrange the objects of every unlocked plate as the toolbar's Arrange does, or of one plate (plates: an index or " + "\"current\") as its Arrange icon does. With fill, fill that object's plate with more of it instead, as Fill bed " + "with instances (or copies, by fill_with) does. spacing, rotate, align_y and multi_material are the Arrange options " + "panel's settings: the values given stay in the panel, so later arranges use them too. Waits for the arrangement " + "(a longer one replies with a job). Reply: the settings in force, instances left off every plate, plates the " + "all-plates arrange skipped and the job's notifications. An arrange may reorder objects, so list_objects again. " + "One undo step.", object_schema({{"plates", {{"type", {"string", "integer"}}, {"description", "\"all\" (default), \"current\" or a plate index."}}}, {"spacing", {{"type", "number"}, {"minimum", 0}, {"description", "mm between objects; 0 means auto."}}}, {"rotate", prop("boolean", "Auto rotate for arrangement.")}, @@ -1286,10 +1288,10 @@ void register_scene_tools(McpService& service) ToolDef cancel = mutate_tool( "cancel", L("Cancel an operation"), - "Stop the running slice or G-code export, as the cancel button on the slicing progress does, or the background job " - "(an arrange, orient or fill bed) an MCP call started. That job then reports cancelled; a background job keeps " - "other changes out until it has really stopped. With job, only when that job is the running operation, or a " - "running encode_recording, which stops and reports cancelled. Allowed while an operation holds the project.", + "Stop the running operation: a slice or G-code export, as the slicing progress's cancel button does, or a " + "background job an MCP call started (an arrange, orient or fill bed). Its job then reports cancelled; a background " + "job keeps other changes out until it has really stopped. With job, only that job is stopped: the running " + "operation, a run_python run or an encode_recording. Allowed while an operation holds the project.", object_schema({{"job", prop("string", "The operation's job to cancel, e.g. \"j12\".")}}), [&service](const json& args, ToolContext& ctx) { const auto ops = service.jobs().running_operations(); diff --git a/src/slic3r/GUI/Mcp/McpToolsScript.cpp b/src/slic3r/GUI/Mcp/McpToolsScript.cpp index 81fd165c97..dbc0f69cf4 100644 --- a/src/slic3r/GUI/Mcp/McpToolsScript.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsScript.cpp @@ -179,7 +179,7 @@ void register_script_tools(McpService& service) "with refs replaced by locators, job replies replayed with await:false, and screenshot paths moved under ${out_dir}. " "Calls that failed, at once or as a job later, are left out; so is a call whose job is still running (unless it " "waits on a dialog), which left_out_running lists as {tool, job}. " - "Returns the script; with path, also writes it. clear:true starts a new recording afterwards.", + "Reply: the script, which with path is also written there. clear:true starts a new recording afterwards.", object_schema({{"name", prop("string", "Script name.")}, {"path", prop("string", "Absolute .json path to write.")}, {"overwrite", prop("boolean", "Replace an existing file.")}, diff --git a/src/slic3r/GUI/Mcp/McpToolsUi.cpp b/src/slic3r/GUI/Mcp/McpToolsUi.cpp index 6bbf5adae4..98c1acb7e7 100644 --- a/src/slic3r/GUI/Mcp/McpToolsUi.cpp +++ b/src/slic3r/GUI/Mcp/McpToolsUi.cpp @@ -57,19 +57,11 @@ using namespace std::chrono_literals; namespace { +// The locator grammar is spelled out once, in ui_snapshot's description, which hands out the refs. const json kTargetSchema = {{"type", json::array({"string", "object"})}, - {"description", - "A ref from the latest ui_snapshot (\"w12\") or a locator: {label, class, name, within, index} for " - "widgets, {option:\"layer_height\"} for a setting field, {menu:\"File>Export>Export G-code\"}, {gltoolbar:\"arrange\"}, {gizmo:\"Move\"}, " - "{imgui:\"label\", imgui_name?:\"name\", window?, canvas?, index?} for an ImGui item, by its label, its name or both, or " - "{row:\"Plate 1>Cube>Cylinder\", column?, within?, index?} for a row of a list, tree, table or drop-down list, by its " - "last labels and the column of the cell to act on, {plate_icon:\"lock\", plate:0} for a plate or its icon in the " - "Prepare view: plate, delete, orient, arrange, lock, settings, name, move_to_front, filament_map, imex_mode, or " - "{web:\"Next\", kind?:\"button\", css?:\"#AcceptBtn\", within?, index?} for an element of a web page, by the label " - "ui_snapshot lists (exactly, else case aside, else a part of it), its kind there, a CSS selector, or together; " - "within is the window's title as for widgets " - "(without it, a modal dialog's page is searched while one is open, else every shown page). A web locator " - "waits up to 3 s for its element to show."}}; + {"description", "A ref from the latest ui_snapshot (\"w12\") or a locator, such as {label: \"OK\", " + "within: \"Preferences\"} or {menu: \"File>Export>Export G-code\"}; ui_snapshot's " + "description lists every kind."}}; const json kPageTimeoutSchema = {{"type", "integer"}, {"minimum", 1}, @@ -1047,20 +1039,30 @@ void register_ui_tools(McpService& service) { ToolDef def = inspect_tool( "ui_snapshot", L("List the GUI"), - "Describe what is on screen as an indented tree, one element per line with a ref: wx widgets of every shown window " - "(buttons, fields, checkboxes, combos, tabs, labels), the rows of lists, trees and tables (label, other cells, " - "checkbox, what an object list row is), each shown popup after the window it opened from, the main menus, the 3D " - "canvas's toolbar items and gizmos, " - "each ImGui panel drawn in the last frame with its items (kind, value, name) and text, and the elements of each shown " - "web page (dialogs, the setup wizard, sign-in, plugin windows and pages) under its web view, as the same kinds of " - "lines: button, link, text, checkbox, radio, choice (its options noted), slider, spin, tab, heading, row, canvas, " - "frame and label, the element's id as name in CSS (name=#save is {css:\"#save\"}) (with a modal dialog open, only the topmost dialog's pages are read). Pass " - "the refs to ui_click / ui_input / ui_key (and page elements to ui_mouse). Refs go stale when the " - "element goes away; take a new snapshot then. root: \"all\" (default), \"main\", \"dialog\" (topmost modal), " - "\"popup\" or a window's ref. query filters by label, value, name or class. Prefer run_action and the typed tools " - "when one fits.", - object_schema({{"root", prop("string", "all | main | dialog | popup | .")}, - {"query", prop("string", "Case-insensitive text to look for.")}, + "Describe what is on screen as an indented tree, one element per line with a ref to pass to ui_click, ui_input, " + "ui_key and webview_eval (a page element's to ui_mouse too): the widgets of every shown window, the rows of lists, " + "trees and tables, each shown popup after the window it opened from, the main menus, the 3D canvas's toolbar " + "items and gizmos, each ImGui panel drawn in the last frame with its items and text, and the elements of each " + "shown web page (dialogs, the setup wizard, sign-in, plugin windows) under its web view. With a modal dialog " + "open, only the topmost dialog's pages are read. Refs go stale when their element goes away: take a new snapshot " + "then. Prefer run_action and the typed tools when one fits.\n" + "A locator names an element without a ref, in any session (export_script records them); index (0-based) picks " + "one of several matches:\n" + "- a widget: {label, class, name, within, index}, within being its window's title; a notebook page: {tab: " + "\"General\", within}\n" + "- a setting's field: {option: \"layer_height\"}\n" + "- {menu: \"File>Export>Export G-code\"}, {gltoolbar: \"arrange\"}, {gizmo: \"Move\"}\n" + "- an ImGui item: {imgui: \"label\", imgui_name?: \"name\", window?, canvas?, index?}, by its label, its name or both\n" + "- a row of a list, tree, table or drop-down list: {row: \"Plate 1>Cube>Cylinder\", column?, within?, index?}, by " + "its last labels; column names the cell to act on\n" + "- a plate or one of its icons in the Prepare view: {plate_icon: \"lock\", plate: 0}, the icon being plate, " + "delete, orient, arrange, lock, settings, name, move_to_front, filament_map or imex_mode\n" + "- a web page's element: {web: \"Next\", kind?: \"button\", css?: \"#AcceptBtn\", within?, index?}, by the label " + "the snapshot lists (exactly, else ignoring case, else a part of it), its kind, a CSS selector (the id a line " + "shows as name: name=#save is {css: \"#save\"}), or together. Without within it looks in the topmost dialog's " + "pages while one is open, else in every shown page, and it waits up to 3 s for its element.", + object_schema({{"root", prop("string", "all (default), main, dialog (the topmost modal), popup, or a window's ref.")}, + {"query", prop("string", "Case-insensitive text to look for in labels, values, names and classes.")}, {"max_nodes", {{"type", "integer"}, {"minimum", 1}, {"maximum", 5000}, {"description", "Default 400."}}}, {"include_imgui", prop("boolean", "List ImGui items (default true).")}, {"include_menus", prop("boolean", "List menu items (default true).")}, @@ -1125,26 +1127,22 @@ void register_ui_tools(McpService& service) reg.add(recover_input_tool( "ui_click", L("Click an element"), - "Activate a GUI element: menu items, buttons, checkboxes, toggles, radio buttons, toolbar items and gizmos are activated " - "the way their owners expect (a gizmo as its toolbar icon: it opens, a second click closes it, and Text on an object " - "with no text creates a text part and replies created); other widgets and ImGui items get a synthesized mouse click, " - "after the item is scrolled into view. A row is selected as a click on its cell selects it (ctrl adds, shift extends; " - "the object list acts on the column named, as Printable toggles), a double click activates it, a right click opens " - "its menu; a drop-down row is picked. A plate icon does what clicking it in the Prepare view does: the reply says the " - "plate's lock state (locked), arrange and orient wait for their job (done), settings and filament_map list the dialog " - "they open (dialogs), and a right click opens the plate menu. With x/y, clicks that point of a 3D canvas or a " - "custom-drawn widget (logical pixels from its top left). Modifiers are seen by the 3D canvas, the " - "object list and handlers that read the event. A menu the click opens is never shown: it is listed as popup_menu, " - "or popup_item runs one of its items (ran). A click that opens a dialog returns blocked_by_dialog with the job. " - "A web page's element is scrolled into view and gets the pointer and mouse events of a click at its centre (or " - "x/y), refused when something else covers that point; a checkbox drawn as its label is clicked there. The reply " - "reads back checked, and says closed, navigated (with url) or dialogs when the click closed its dialog, changed the " - "page or opened another dialog; with closed, dialogs lists the dialogs still open under it, which still need an answer " - "(the filament picker under its colour picker). Failing those, page says what the click changed on its page by 300 " - "ms later: changed (false: the page lists what it did before), the ui_snapshot lines it added and removed, partial " - "when a plugin configuration frame could not be compared (then changed only when a line was found), and posted, " - "how many messages the page sent OrcaSlicer (its plugin) meanwhile. timeout_s (default 10) is how long the " - "page gets to answer.", + "Click a GUI element as a person would. Menu items, buttons, checkboxes, toggles, radio buttons, toolbar items and " + "gizmos are activated the way their owners expect: a gizmo opens and a second click closes it (Text on an object " + "without text creates a text part: created). Other widgets and ImGui items get a mouse click once scrolled into " + "view; with x/y, at that point of a 3D canvas or custom-drawn widget, in logical pixels from its top left. A row is " + "selected as a click on its cell selects it (ctrl adds, shift extends; in the object list the named column acts, as " + "Printable toggles), double activates it and a right click opens its menu; a drop-down list's row is picked. A " + "plate icon does what it does in the Prepare view: lock replies locked, arrange and orient reply done once their " + "job ends, settings and filament_map list the dialog they open (dialogs). Modifiers reach the 3D canvas, the object " + "list and handlers that read them. A menu the click opens is never shown: the reply lists it as popup_menu, or " + "popup_item runs one of its items (ran). A click that opens a dialog replies blocked_by_dialog.\n" + "A web page's element gets the pointer and mouse events of a click at its centre (or x/y) once scrolled into view, " + "refused when something else covers that point. The reply reads back checked, and has closed when the click closed " + "its dialog (with dialogs, those still open under it, which still need an answer), navigated (with url) when it " + "changed the page, or dialogs when it opened another. Otherwise page says what changed on the page within 300 ms: " + "changed (false when its lines are as before), the ui_snapshot lines added and removed, partial when a plugin " + "configuration frame could not be compared, and posted, how many messages the page sent OrcaSlicer.", object_schema({{"target", kTargetSchema}, {"button", enum_prop({"left", "right", "middle"}, "Default left.")}, {"double", prop("boolean", "Double click.")}, @@ -1235,18 +1233,16 @@ void register_ui_tools(McpService& service) reg.add(recover_input_tool( "ui_input", L("Set a control's value"), - "Set the text, number, selection or checked state of a control and send the event a person's edit would: text fields " - "(submit:true also presses Enter and leaves the field, which is when Orca's setting fields commit), spin controls, " - "sliders, choice / combo / list boxes (by option text or index), checkboxes and toggles (true/false), a row's " - "checkbox (true/false). An ImGui item " - "is set by its kind and its value read back: a field is typed into (a slider through the number field beside it, " - "multiline text with \\n), a combo's option is picked by its text or 0-based index, a checkbox, radio or toggle " - "clicked when it differs. For " - "settings, set_settings is more reliable. A web page's field is set as typing would leave it: text, number, range, " - "colour and date fields and editable text get the value with input and change events (submit then leaves the field; " - "press Enter with ui_key Return), a select its option by text, value or index, a checkbox or radio is clicked when " - "it differs; the value is read back, and page says what changed on the page, as for ui_click. File fields can't be " - "set.", + "Set a control's value and send the events a person's edit would. Widgets: text fields (submit, the default, also " + "presses Enter and leaves the field, which is when Orca's setting fields commit), spin controls, sliders, choice, " + "combo and list boxes (by option text or index), and checkboxes, toggles and a row's checkbox (true or false). " + "ImGui items, by their kind, with the value read back: a field is typed into (a slider through the number field " + "beside it, multiline text with \\n), a combo's option is picked by its text or 0-based index, and a checkbox, radio " + "or toggle is clicked when it differs. A web page's fields, as typing would leave them: text, number, range, colour " + "and date fields and editable text get the value with input and change events (submit then leaves the field; " + "ui_key Return presses Enter), a select its option by text, value or index, and a checkbox or radio is clicked when " + "it differs; the value is read back and page says what changed, as for ui_click. File fields can't be set. For " + "settings, set_settings is more reliable.", object_schema({{"target", kTargetSchema}, {"value", {{"type", json::array({"string", "number", "boolean"})}, {"description", "The new value."}}}, {"submit", prop("boolean", "Press Enter / commit after setting (default true).")}, @@ -1271,14 +1267,13 @@ void register_ui_tools(McpService& service) reg.add(recover_input_tool( "ui_key", L("Press keys"), "Send a key chord (\"Ctrl+S\", \"Escape\", \"Return\", \"Delete\", \"Shift+Tab\", \"Left\", \"F5\") and/or type text to " - "a target or, without one, to the focused window (the topmost dialog while one is open, the 3D view shown when nothing " - "has focus). As with a real key press, the shortcut handling of the target's panels and window sees it first. " - "Typing reaches ImGui fields and key handlers; to fill a native text field " - "use ui_input. A menu the keys open is listed as popup_menu, or popup_item runs one of its items. Keys for a web " - "page (its element, or without a target the focused web view or the topmost dialog's only page) go to the page's " - "focused element with the browser's default actions: typing, Backspace/Delete, Enter (submits a form, activates a " - "button), Space, Tab moving the focus, arrows stepping a select, range or radio group; page says what the keys " - "changed on the page, as for ui_click.", + "a target or, without one, to the focused window (the topmost dialog while one is open, the shown 3D view when " + "nothing has focus). As with a real key press, the shortcut handling of the target's panels and window sees the keys " + "first. Typing reaches ImGui fields and key handlers; fill a widget's text field with ui_input. A menu the keys open " + "is listed as popup_menu, or popup_item runs one of its items. Keys for a web page (its element, or without a " + "target the focused web view or the topmost dialog's only page) go to the page's focused element with the " + "browser's default actions: typing, Backspace/Delete, Enter (submits a form, activates a button), Space, Tab moving " + "the focus, arrows stepping a select, range or radio group; page says what they changed, as for ui_click.", object_schema({{"target", kTargetSchema}, {"keys", prop("string", "Key chord.")}, {"text", prop("string", "Characters to type.")}, @@ -1348,21 +1343,21 @@ void register_ui_tools(McpService& service) #endif reg.add(recover_input_tool( "ui_mouse", L("Mouse gesture on the 3D view"), - "Synthesize a mouse gesture on a 3D canvas, as a person's would: move, down, up, click, drag (from the start through " - "`path` to `to`, `steps` moves per leg: on an object it moves it, in a painting gizmo it paints from a press on " - "the object being painted (one drag whose path zigzags over an area paints all of it), and elsewhere it turns or pans the camera as this install's mouse settings say, so " - "turn the camera with set_view camera or orbit instead) or wheel (delta in notches, positive zooms in or scrolls a panel up). Give " - "the start as `at`, a point of the model, which is projected through the camera and by default checked to land on " - "that part there (check \"point\" only projects it), or as x/y, logical pixels from the canvas's top left. " - "Modifiers are pressed as keys for the gesture (shift for Measure's point picking, alt for erasing). A down keeps " - "its button and modifiers held, so moves drag with it, until an up or another gesture. Grabbers are set through " - "the gizmo's panel fields or transform, not dragged. A menu a right click opens is listed as popup_menu, or " - "popup_item (with click or up) runs one of its items. camera_moved in the reply says the gesture moved the camera, " - "so earlier screenshots and pixels no longer match the view. With target, the gesture is on a web page's element " - "instead (a canvas such as the colour picker's spectrum, a slider, a sortable or scrolled list): x/y, to and path are " - "logical pixels from its top left, a drag keeps the pointer captured where the page asks for it, and wheel scrolls " - "what is under the pointer unless the page takes the wheel; page says what the gesture changed there, as for " - "ui_click.", + "Make a mouse gesture on a 3D canvas as a person would: move, down, up, click, drag or wheel. It starts at `at`, a " + "point of the model, which is projected through the camera and by default checked to land on that part (check " + "\"point\" only projects it), or at x/y, logical pixels from the canvas's top left. A drag goes through `path` to " + "`to`, `steps` moves per leg: on an object it moves the object, in a painting gizmo it paints from a press on the " + "object being painted (a path zigzagging over an area paints all of it), and elsewhere it turns or pans the camera " + "as this install's mouse settings say, so turn the camera with set_view camera or orbit instead. A wheel turns delta " + "notches; positive zooms in or scrolls a panel up. Modifiers are held as keys for the gesture (shift for Measure's " + "point picking, alt for erasing). A down keeps its button and modifiers held, so moves drag, until an up or another " + "gesture. Grabbers are set through the gizmo's panel fields or transform, not dragged. A menu a right click opens " + "is listed as popup_menu, or popup_item (with click or up) runs one of its items. The reply's camera_moved says the " + "gesture moved the camera, so earlier screenshots and pixels no longer match the view.\n" + "With target, the gesture is on a web page's element instead (a canvas such as the colour picker's spectrum, a " + "slider, a sortable or scrolled list): x/y, to and path are logical pixels from its top left, a drag keeps the " + "pointer captured where the page asks for it, and a wheel scrolls what is under the pointer unless the page takes " + "it; page says what the gesture changed there, as for ui_click.", object_schema({{"action", enum_prop({"move", "down", "up", "click", "drag", "wheel"}, "Default click.")}, {"canvas", enum_prop(mouse_canvases, "Default current, the view shown. design takes x/y only.")}, {"at", target_schema}, @@ -1479,14 +1474,14 @@ void register_ui_tools(McpService& service) reg.add(recover_input_tool( "dialog_respond", L("Answer a dialog"), - "Press a button of the topmost modal dialog (or of the one whose title contains dialog.title, which must be the " - "topmost): yes, no, ok, cancel, close, apply, a button's label, or a numeric id; closed: true says it closed, " - "with the dialogs still open. A native message box (native: true) is pressed through the OS, by one of the " - "buttons get_state.dialogs lists for it; a file or folder picker can't be answered here, nor any native dialog on " - "macOS (its buttons list is empty): register dialog_auto_answer before opening them. A web dialog's " - "buttons are on its page: a label is pressed there (waiting up to 3 s for it to show), so the page's own handler " - "runs; with no such page button, or a page busy for those 3 s, cancel and close end the dialog, and ok, yes, no and " - "apply are refused rather than skipping the page's commit (page_buttons lists what it has).", + "Press a button of the topmost modal dialog: yes, no, ok, cancel, close, apply, a button's label, or a numeric id. " + "dialog.title, text the dialog's title contains, makes sure which dialog that is; it must be the topmost. Reply: " + "closed: true when it closed, and dialogs, those still open. A native message box (native: true) is pressed through " + "the OS, by one of the buttons get_state.dialogs lists for it; a file or folder picker can't be answered here, nor " + "any native dialog on macOS (its buttons list is empty): register dialog_auto_answer before opening them. A web " + "dialog's buttons are on its page: a label is pressed there, waiting up to 3 s for it to show, so the page's own " + "handler runs. With no such page button, or a page busy for those 3 s, cancel and close end the dialog, and ok, yes, " + "no and apply are refused rather than skip the page's commit; page_buttons then lists the page's buttons.", object_schema({{"button", prop("string", "Button to press.")}, {"dialog", {{"type", "object"}, {"properties", {{"title", prop("string", "Text the dialog's title contains (case-insensitive).")}}}, @@ -1641,15 +1636,15 @@ void register_ui_tools(McpService& service) { ToolDef def = recover_input_tool( "dialog_auto_answer", L("Pre-answer dialogs"), - "Answer modal dialogs automatically, native ones included, when their title or message matches a rule's regex " - "(case-insensitive): a native dialog returns that button at once and never shows; a wx dialog has the button " - "pressed as dialog_respond does, so its handler runs. A matching dialog that is already open is answered too, " - "as dialog_respond would (answered_open_dialog), so a prompt that appears around the same time (the restore " - "prompt after startup) is handled either way. Native file pickers can only be cancelled. Called from a script, the rules last until the script " - "ends; otherwise they replace the rules this session set before (an empty list clears them). A web dialog is " - "matched by its title. A button that names one of its shown wx buttons (by label, standard name or id) is pressed " - "as for any wx dialog; any other is pressed on its page once it shows there, for up to 10 s of its page being " - "loaded; then cancel and close end it, any other button gives up.", + "Answer modal dialogs automatically when their title or message matches a rule's regex (case-insensitive). " + "get_state.auto_answer_rules lists the rules in force. Called from a script, the rules last until the script " + "ends; otherwise they replace the ones this session set before, and an empty list clears them. A native dialog " + "returns the rule's button at once and never shows (a file picker can only be cancelled). A wx dialog has the " + "button pressed as dialog_respond does, so its handler runs. A matching dialog already open is answered too " + "(answered_open_dialog), so a prompt that shows around the same time, such as the restore prompt after startup, " + "is caught either way. A web dialog is matched by its title: a button that names one of its shown wx buttons (by " + "label, standard name or id) is pressed as for a wx dialog, any other on its page once it shows there, for up to " + "10 s after the page loads; past that, cancel and close end the dialog and any other button gives up.", object_schema({{"rules", array_prop({{"type", "object"}, {"properties", {{"match", prop("string", "Regex searched in \"title\\nmessage\", and also in the title alone for a dialog with no message (a web dialog), so ^Title$ matches it.")}, {"button", prop("string", "yes | no | ok | cancel | close | apply | label | id")}}}, @@ -1705,17 +1700,17 @@ void register_ui_tools(McpService& service) ToolDef eval = recover_input_tool( "webview_eval", L("Run JavaScript in a web view"), - "Evaluate JavaScript in one of OrcaSlicer's web views (Home, the device page, dialogs, plugin windows) and return the " - "value of its last expression (JSON values come back parsed). Prefer ui_snapshot and the ui_* tools, which see and " - "drive pages as they do widgets. While a modal dialog is open, scripts run in the topmost dialog's page; without a " - "target, the web view of the topmost dialog is used, else the only shown one. With a page element's ref as target, " - "the script runs in its page with the element as `el`. closed: true says the script closed its dialog, navigated: " - "true (with url) that it changed the page, dialogs that it opened another. Messages the page posts to OrcaSlicer " - "reach it once the script has returned. Scripts run through eval, which a page whose Content-Security-Policy forbids " - "it may refuse (the ui_* tools still work there). Waits up to timeout_s (default 10).", + "Evaluate JavaScript in one of OrcaSlicer's web views (Home, the device page, dialogs, plugin windows). Prefer " + "ui_snapshot and the ui_* tools, which see and drive pages as they do widgets. The script runs in the target's page: " + "a web view's (kind webview in ui_snapshot), or a page element's, with the element as `el`; without a target, in " + "the topmost dialog's web view, else in the only shown one. While a modal dialog is open, only its pages run " + "scripts. Reply: result, the value of the last expression (JSON values come back parsed), and url; closed: true when " + "the script closed its dialog, navigated: true when it changed the page, dialogs when it opened another. Messages " + "the page posts to OrcaSlicer reach it once the script has returned. Scripts run through eval, which a page whose " + "Content-Security-Policy forbids it may refuse (the ui_* tools still work there).", object_schema({{"script", prop("string", "JavaScript to run.")}, {"target", kTargetSchema}, - {"timeout_s", {{"type", "integer"}, {"minimum", 1}, {"maximum", 120}, {"description", "Default 10."}}}}, + {"timeout_s", {{"type", "integer"}, {"minimum", 1}, {"maximum", 120}, {"description", "Seconds the script gets (default 10)."}}}}, {"script"}), [&service](const json& args, ToolContext& ctx) { const std::string script = arg_string(args, "script");