@flowdrop/flowdrop 2.5.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/chat/commandClassifier.d.ts +19 -1
  3. package/dist/chat/commandClassifier.js +33 -1
  4. package/dist/chat/index.d.ts +1 -1
  5. package/dist/chat/index.js +1 -1
  6. package/dist/commands/executor.js +270 -37
  7. package/dist/commands/index.d.ts +1 -1
  8. package/dist/commands/parser.js +20 -0
  9. package/dist/commands/types.d.ts +77 -12
  10. package/dist/components/App.svelte +8 -0
  11. package/dist/components/BindablePortListbox.svelte +426 -0
  12. package/dist/components/BindablePortListbox.svelte.d.ts +23 -0
  13. package/dist/components/WorkflowInterfaceEditor.svelte +142 -36
  14. package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +8 -0
  15. package/dist/components/WorkflowInterfaceEntryCard.svelte +537 -294
  16. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +6 -3
  17. package/dist/components/WorkflowInterfaceEntryComposer.svelte +331 -0
  18. package/dist/components/WorkflowInterfaceEntryComposer.svelte.d.ts +19 -0
  19. package/dist/components/console/CommandConsole.svelte +8 -0
  20. package/dist/components/console/formatters.d.ts +9 -1
  21. package/dist/components/console/formatters.js +54 -0
  22. package/dist/core/index.d.ts +1 -1
  23. package/dist/messages/context.d.ts +6 -0
  24. package/dist/messages/context.js +8 -0
  25. package/dist/messages/defaults.d.ts +78 -2
  26. package/dist/messages/defaults.js +50 -3
  27. package/dist/messages/index.d.ts +1 -1
  28. package/dist/messages/index.js +1 -1
  29. package/dist/services/globalSave.d.ts +7 -1
  30. package/dist/services/globalSave.js +17 -3
  31. package/dist/stores/instanceContainer.svelte.d.ts +26 -0
  32. package/dist/stores/instanceContainer.svelte.js +24 -0
  33. package/dist/stores/workflowStore.svelte.d.ts +10 -0
  34. package/dist/stores/workflowStore.svelte.js +15 -0
  35. package/dist/stories/WebMCPFakeAgent.svelte +229 -0
  36. package/dist/stories/WebMCPFakeAgent.svelte.d.ts +10 -0
  37. package/dist/styles/base.css +4 -2
  38. package/dist/styles/tokens.css +6 -0
  39. package/dist/svelte-app.d.ts +24 -2
  40. package/dist/svelte-app.js +65 -3
  41. package/dist/types/index.d.ts +49 -0
  42. package/dist/utils/focus.d.ts +18 -0
  43. package/dist/utils/focus.js +24 -0
  44. package/dist/utils/whenWorkflowLoaded.svelte.d.ts +17 -0
  45. package/dist/utils/whenWorkflowLoaded.svelte.js +42 -0
  46. package/dist/utils/workflowInterface.d.ts +47 -3
  47. package/dist/utils/workflowInterface.js +84 -9
  48. package/dist/webmcp/WebMCP.stories.svelte +101 -0
  49. package/dist/webmcp/WebMCP.stories.svelte.d.ts +18 -0
  50. package/dist/webmcp/WebMCPConfirm.svelte +216 -0
  51. package/dist/webmcp/WebMCPConfirm.svelte.d.ts +21 -0
  52. package/dist/webmcp/bridge.d.ts +63 -0
  53. package/dist/webmcp/bridge.js +106 -0
  54. package/dist/webmcp/descriptors.d.ts +59 -0
  55. package/dist/webmcp/descriptors.js +504 -0
  56. package/dist/webmcp/fake.d.ts +23 -0
  57. package/dist/webmcp/fake.js +42 -0
  58. package/dist/webmcp/gate.d.ts +76 -0
  59. package/dist/webmcp/gate.js +188 -0
  60. package/dist/webmcp/index.d.ts +36 -0
  61. package/dist/webmcp/index.js +32 -0
  62. package/dist/webmcp/register.d.ts +33 -0
  63. package/dist/webmcp/register.js +504 -0
  64. package/dist/webmcp/types.d.ts +268 -0
  65. package/dist/webmcp/types.js +23 -0
  66. package/dist/webmcp/validate.d.ts +32 -0
  67. package/dist/webmcp/validate.js +118 -0
  68. package/package.json +6 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,65 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [2.7.0] - 2026-09-09
11
+
12
+ ### Added
13
+
14
+ - **A browser agent can now _finish_ a workflow, not just edit one.** Building a four-node fetch-and-convert flow through the 2.6.0 tools showed the gaps: an agent could not learn a node type's ports or config without adding a node first, could not tell whether the result was valid, and could not run it. The editor-tool set closes them, on one rule — **the tools read only what the editor has already fetched** (the node type catalog and the open workflow); no new endpoints, no per-tool round trips.
15
+ - **`describe_type`** (new command and tool, read-only) describes a node type before it is used: input and output ports with data type and required flag, every config key with type, enum, default and description, and — when the host publishes them — the **confirmation policy** (`ask` means a run pauses for a person at this node), what the user may do with it (`can`) and host-written guidance (`agent`). Three new optional fields on `NodeMetadata` carry those: `confirmation`, `can`, `agent`; the library passes them through verbatim.
16
+ - **`search_types { query }`** (new command and tool, read-only) finds node types by a case-insensitive substring of id, name, description or tags; a blank query is refused with `EMPTY_QUERY` (new `CommandErrorCode`) instead of returning the catalog. **`list_types` rows now carry `description` and `tags`.** The text DSL gained `describe <type>` and `search <text>` to match, and the command console formats both.
17
+ - **`get_config` returns the schema next to the value**, and its `key` is optional: without one it answers every current value under `values` and the whole config schema. `get <nodeId>` works in the DSL too. The result is one of two shapes — `GetConfigKeyResultData` (`key`, `value`, `schema?`) or `GetConfigAllResultData` (`values`, `schema[]`) — narrow on `'key' in data`.
18
+ - **Errors teach.** A failure names the valid alternatives instead of stopping at "not found": an unknown node lists the workflow's nodes (or says to `add_node` first on an empty canvas); an unknown type names near misses and points at `list_types`; an unknown port lists the node's ports on both sides; a missing edge lists the edges leaving that node; an unknown config key lists the keys. Lists are capped at 15. `set_config` on a key the schema does not declare is still stored (hosts keep config open) but now carries an **`unknown_key` warning** with the declared keys — fatal only under `strict`.
19
+ - **Tool descriptions carry the call order.** `add_node`, `set_config`, `swap_node` and `batch` — the tools that take a type or a config key — end with "call `describe_type` before adding or configuring a type you have not seen; group several changes in one `batch`; `save` when done", and examples use type ids that exist (`http_request`, not `llm_node`).
20
+ - **`run` and `run_status`** tools, behind two new host hooks on `attachWebMCP` and the `webmcp` mount option: **`onRun(inputs) → Promise<HostEnvelope<RunStarted>>`** and **`onRunStatus(runId) → Promise<HostEnvelope<RunStatus>>`**. `run` is gated like `save` and flagged consequential; `run_status` is a read. A paused run is relayed as **`code: 'PENDING'`** with the node id and message it waits on — a person must act in the editor; no tool answers an interrupt, on purpose. `run_status` is registered only when both hooks are given; neither tool exists without its hook.
21
+ - **One result envelope for host hooks.** `onSave`, `onRun` and `onRunStatus` may answer `{ ok, code?, message?, data?, can? }` (`HostEnvelope`), with the codes `FORBIDDEN`, `UNAVAILABLE`, `NEEDS_APPROVAL`, `INVALID`, `CONFLICT`, `PENDING`, `NOT_FOUND` — aligned with fddo's API-8 `error_code` vocabulary where the two meet. The tool relays `code`, `message`, `data` and `can` untouched. `onSave` may still resolve to nothing (saved) or throw (`SAVE_FAILED`); a thrown error that is a 409 or carries `errorData.error_code === 'CONFLICT'` is relayed as **`CONFLICT`** with a reload hint.
22
+ - **The server stays the authority; the client pre-empts.** A workflow payload may now carry **`can: { save, run, … }`** and a **`revision`** (two new optional fields on `Workflow`). `save` and `run` answer `FORBIDDEN` before opening a dialog when `can` says no; when the host says nothing, the server decides. The save path sends the loaded `revision` back so a server that checks it can refuse a stale write, and takes the new `revision`/`can` from the response (`instance.workflow.acknowledgeServer()` — bookkeeping only, no history entry, no dirty flag).
23
+ - **The confirm dialog summarises a batch** — "4 changes — adds 2 nodes, connects 1 edge, sets 1 config key." — above the line list, and offers **"Apply further edits from any agent on this page without asking, until this page is closed"** — worded as what it does: the gate cannot tell one agent from another, so once ticked every caller on the page is covered. Ticked (and approved), later _edits_ run without the dialog; `save` and `run` always ask and never offer the box. Off with **`rememberEdits: false`**. Nine new strings under `defaultMessages.webmcp` (`runLine`, `runHint`, `summary*`, `batchSummary`, `rememberEdits`); Tab now cycles Apply → Reject → checkbox.
24
+ - **A browser agent can now save.** Feedback from the first WebMCP release: the first batch of nodes an agent added vanished on reload because nothing had persisted them — `flowdrop_add_node` and friends change the in-memory workflow, but only the editor's own Save button wrote it to the server. There is now a **`flowdrop_save`** tool: registered whenever `attachWebMCP` is given an **`onSave: () => Promise<void>`**, and automatically on the `mountFlowDropApp` path, where it defaults to the mount's own Save unless the host supplies its own `onSave`. Like any change, it asks — a save cannot be undone from the editor — and its `annotations` carry the new **`consequentialHint: true`** (added to the WebMCP spec 2026-09-03: "executing the tool will result in consequential actions that are significant, real-world, or non-reversible"). Approval callbacks (`WebMCPApproval` functions) now receive a second argument, `(commands, { tool })` — additive, existing one-argument callbacks keep working; for `save` the `commands` array is empty and `request.tool === 'save'`.
25
+ - **A bridge to desktop MCP clients, for browsers without the origin trial** (`installBridgedModelContext`, `createBridgedModelContext` in `@flowdrop/flowdrop/webmcp`). Presents the same `modelContext` surface over a page-side relay widget of the [`@jason.today/webmcp`](https://github.com/jasonjmcghee/webmcp) shape (`registerTool(name, description, inputSchema, execute)`), so Claude Code, Claude Desktop or Cursor can call the editor tools through a localhost MCP server the user runs and authorises with a token. Install it before the editor mounts; it is a no-op when a real runtime exists. The widget cannot unregister a tool, so after the editor is destroyed its tools answer a structured `UNAVAILABLE` until the page unloads. The relay's server times a tool call out after 30 seconds — a confirm dialog left open longer returns a timeout to the agent while the dialog stays up. The gate, `can` and the server's permissions apply unchanged; hosts should make the bridge an explicit opt-in.
26
+ - **New exported types** from `@flowdrop/flowdrop/core` and `/commands`: `DescribeTypeCommand`, `SearchTypesCommand`, `TypeSummary`, `PortDescription`, `ConfigKeyDescription`, `DescribeTypeResultData`, `SearchTypesResultData`, `GetConfigKeyResultData`, `GetConfigAllResultData`; from `/webmcp`: `HostCode`, `HostEnvelope`, `RunStarted`, `RunPending`, `RunStatus`, `WebMCPApprovalRequest`, `WebMCPWidgetLike`, `BridgedModelContext`. `NodeMetadata` gained `confirmation`, `can`, `agent` (`NodeConfirmation`, `NodeAgentGuidance`); `Workflow` gained `can`, `revision`.
27
+
28
+ ### Fixed
29
+
30
+ - **`mountFlowDropApp(...).save()` and `globalSaveWorkflow()` resolve `true` when the workflow was written and `false` when nothing was saved** (no workflow, or `onBeforeSave` cancelled). Before, both resolved to nothing either way, and the mount path's default `save` tool reported "Workflow saved" on a cancelled save. It now answers `{ ok: false, code: 'UNAVAILABLE' }`. Widening `void` to `boolean` is additive for callers.
31
+ - **The WebMCP confirm dialog no longer renders in the browser's serif fallback on Drupal.** The dialog mounts on `document.body`, outside the editor, and used `font-family: inherit` — on admin themes that scope their font to a wrapper, that is Times. It now uses a new public token **`--fd-font-sans`** (a system-ui stack), with an explicit size and line-height, so it reads like the editor wherever it is mounted. Hosts can override the token at `:root`.
32
+ - **`set_config` no longer warns "Expected type 'string,boolean' but got 'string'"** when a node config property declares several JSON Schema types; the warning now reads `Expected type 'string' or 'boolean' but got 'number'` and fires only when the value matches none of them.
33
+
34
+ ## [2.6.0] - 2026-09-03
35
+
36
+ ### Added
37
+
38
+ - **The editor's commands are now WebMCP editor tools.** A browser-resident agent — Chrome 149+ and Edge 150+ behind the WebMCP origin trial, Brave Leo, ChatGPT Desktop — can discover the open editor's tools on the page and drive it: `flowdrop_list_types`, `flowdrop_add_node`, `flowdrop_connect`, `flowdrop_set_config`, `flowdrop_info`, `flowdrop_undo`, a `flowdrop_batch` that runs several as one transaction, and the rest of the command layer; one tool per command, each with a JSON Schema derived from the `Command` union, so the agent gets structured errors and argument completion rather than a text grammar to guess at. New subpath **`@flowdrop/flowdrop/webmcp`**: `attachWebMCP(instance, { nodeTypes, … })` for Svelte hosts, and a **`webmcp: true | WebMCPMountOptions`** option on `mountFlowDropApp` for vanilla and Drupal hosts, which loads the adapter on demand so the core entry is unchanged. No-op in a browser without the API.
39
+ - **These are tools for editing a workflow in the browser.** They are unrelated to the tools a running workflow hands to an LLM node; the docs call them _editor tools_ and nothing else.
40
+ - **Reads run; changes ask.** Classification is the chat panel's `isMutatingCommand`, unchanged. A mutating call opens a confirm dialog inside the page listing exactly what will run, and nothing touches the workflow until the person at the keyboard clicks Apply. `approval: 'auto'` turns that off for hosts that already trust every agent on the page; `approval: (commands) => Promise<boolean>` plugs in your own gate. While one decision is pending a second mutating call is refused with `BUSY` — dialogs never stack. This matters because WebMCP's permission model is about which origins may _see_ tools, not whether a given call may change the user's document: any agent or extension on the page can call them.
41
+ - **Every call is one transaction and one undo step**, like an approved chat batch; a batch whose third command fails leaves the workflow exactly as it was and says so. The layout opt-out (`chatAllowLayoutChanges`) is honoured with the chat panel's wording — same setting, no new one.
42
+ - **`clear` is never exposed.** An agent can delete nodes one at a time and each deletion is gated. `help` is not exposed either; the schemas are the help. A test asserts every literal in the `Command` union is either mapped or on that exclusion list, so the next DSL verb cannot slip through unclassified.
43
+ - **Two editors on one page** need distinct `prefix`es; the second `attachWebMCP` with the same prefix throws rather than silently shadowing. Every tool description carries the workflow's name so an agent facing two editors can tell them apart.
44
+ - **`view` needs a host.** The `flowdrop_view` tool (select node, open config, zoom, pan) is registered only when `onUIAction` is supplied, because the mount path has no handler for it; the `webmcp` mount option therefore registers everything except `view`.
45
+ - The spec is an origin trial and has changed shape once already. The adapter probes `document.modelContext` and, structurally, the earlier `navigator.modelContext`; registers under an `AbortSignal` (the spec's only removal path) and also calls `unregisterTool` where a pre-spec runtime has one; and touches the runtime from one file. `createFakeModelContext()` is exported for hosts' own tests — CI has no browser agent, and neither does the storybook, which drives the tools from a fake-agent side panel instead.
46
+ - **A `view` call does not ask.** Selecting a node, opening its config panel, and moving the canvas viewport change what the editor shows and nothing in the workflow — there is nothing to undo — so they run without the dialog even under `approval: 'confirm'`. The classifier gained a third class for this, `isViewCommand()` and `VIEW_COMMAND_TYPES` in `@flowdrop/flowdrop/chat`; `isMutatingCommand()` is unchanged, so the AI Assistant panel still treats them as click-to-apply. `undo` and `redo` change the document and still ask. A batch that mixes view and change items asks once, for the whole batch, and lists every line.
47
+ - **`handle.tools` lists what the runtime accepted.** Registration is asynchronous in the spec, so the handle gained **`ready: Promise<void>`**, which resolves once every registration has settled; a tool the runtime refuses is warned about once through the library logger and never appears in `tools`. Hosts that only read `app.webmcp?.tools` after the fact need not care.
48
+ - **The `webmcp` mount option costs no request and no time.** `mountFlowDropApp` resolves as before; the adapter attaches in the background once the workflow is loaded and reads node types from the instance rather than fetching them a second time. `app.webmcp` is therefore `undefined` for a moment after mount even when the browser has the API. The **`nodeTypes` option of `attachWebMCP` is now optional** and defaults to the instance's list.
49
+ - **The confirm dialog is translatable.** Its four strings live under a new **`webmcp`** group in `defaultMessages` (`confirmTitle`, `confirmCount`, `reject`, `apply`); `attachWebMCP` and the `webmcp` mount option take a `messages` override in the same shape as the `messages` prop. The dialog also keeps focus inside itself — Tab moves between Reject and Apply, Escape rejects — instead of listening on the window.
50
+ - Every tool description names the workflow, so attachment waits until the workflow is loaded; the name is the one at attach time and a later rename is not re-registered.
51
+ - **`instance.onDestroy(fn)`** registers a callback for when a `FlowDropInstance` is destroyed and returns an unsubscribe. The WebMCP adapter uses it to detach itself; a host integration that binds to an instance can hook its own teardown there instead of wrapping `destroy`.
52
+ - **`instance.nodeTypes`** holds the node types the editor currently knows — what `App` fetched or was given, merged with the format-provided nodes — as a small store with `current` and `set()`. Anything outside the component tree that needs the list reads it here instead of fetching again.
53
+
54
+ - **"Add input" / "Add output" in the workflow interface editor opens an inline composer instead of dropping in a blank row.** A clearly separate two-step draft form asks first whether the new entry should bind to an existing port. _Yes_ opens a custom port picker: ports nothing is using yet are listed first under **Available**, then the ones that already have an edge or are already published, each row showing the port's type, `node › port`, description and a **Connected** / **Published as …** / **Required** badge — the metadata a native select cannot show — with a search box and full keyboard support (arrows, Home/End, Enter to add, Escape to close). Picking a port adds an entry pulled from it: bound, with name, type, description, required and default copied and the id seeded from the port's own id (suffixed if taken). _No_ adds an empty, unbound entry exactly as before. Two new pure helpers in `utils/workflowInterface`, `rankBindablePorts()` and `entryFromBindablePort()`, back the picker. Each row wears the same two chips a port row wears on the canvas — the shape symbol in the lane's colour and the outlined lane-name chip — so a candidate is recognisable as the port it points at, and the fixed-width symbol keeps the rows aligned. The editor takes an optional `checker` prop (`fd.portCompatibility`) for this, defaulting to a checker over the built-in port config.
55
+ - **An existing entry's "Bound port" is the same picker.** The native select and the separate "bound port, said back" line are one control now: a select-shaped button showing the bound port the way the canvas shows it — shape symbol, `node › port`, lane chip — that unfolds the same searchable, grouped listbox the composer uses, with the entry's own port marked **Current** and an **Unbind** action beside Cancel. A click binds and folds the picker away; a dangling binding shows its raw `node › port` ids in red. **Pull from port** moved into _More options_, the fields it fills. The listbox itself is a new component, `BindablePortListbox`, and `bindablePortKey()` in `utils/workflowInterface` is the key both callers compare bindings by.
56
+
57
+ ### Changed
58
+
59
+ - **Each side of the interface ends in its insertion slot.** The **Add input** / **Add output** action left the section header for a dashed, full-width slot after the last entry — where the new entry will land — and the composer opens in that slot's place, so the draft sits exactly where the entry it becomes will sit. An empty side is now just its slot; the "No inputs declared yet." / "No outputs declared yet." placeholders are gone, and their message keys `workflowInterface.noInputs` / `noOutputs` with them. The `.wf-interface__add` class now names the slot, and `.wf-interface__empty` no longer exists.
60
+ - **The entry health dot is gone.** The small coloured circle beside each interface entry said what the card already says: a bad binding gets the card's error border and a sentence under the field or in the footer, and an entry that is fine says nothing — neutral is the good state. `.wf-interface__dot` no longer exists.
61
+ - **The workflow interface editor now looks like the rest of the settings panel.** Entries are cards on the panel's card surface, using the shared `Input`, `Select`, `Button` and `IconButton` controls and the settings form's label voice, so the Interface tab no longer reads as a foreign screen next to the Settings tab. A bound entry says its target back as a type chip and `node › port` line with the pull action beside it; the entry health dot has a soft halo; status messages are tinted callouts instead of bare coloured text; the empty state is a quiet dashed placeholder; section titles carry an inputs/outputs glyph and an entry count. Markup, message strings and the `wf-interface__*` class names are unchanged, so existing overrides and tests keep working.
62
+ - **A `tool` input can now be published in the workflow interface.** The binding picker in the interface editor offers a consumer node's `tool`-typed input (a ToolBox's or LLM node's `tools`) alongside data ports, so a parent workflow can hand its tools to a sub-workflow through the child's declared contract instead of the child carrying its own copy of every tool node. Tools are a typed argument of a workflow's execution (fddo DF9); the server decides what binding them means. `trigger` ports, the `loop_back` port and `tool` _outputs_ remain intra-graph control flow and stay out of the picker.
63
+ - **Small buttons are 28px.** `.flowdrop-btn--sm` was 32px tall while `IconButton`'s `sm` was 28px, so the two could not share a row without the caller overriding one of them; the interface editor had grown three such overrides. `.flowdrop-btn--sm` now sizes from the same token (`--fd-size-icon-btn`) with no block padding, and the overrides are gone. **Every `size="sm"` button in the library is 4px shorter** — the settings panel, the interface tab, the chat panel and the toolbar all use it.
64
+
65
+ - **Unit tests resolve Svelte's client build.** `vite.config.ts` sets `resolve.conditions: ['browser']` under Vitest, as the Svelte testing docs recommend; without it `mount()` resolved to the server build and threw `lifecycle_function_unavailable`. Existing suites are unaffected (1716 tests, all green); it is listed because it changes what a new component test can do.
66
+
8
67
  ## [2.5.0] - 2026-08-23
9
68
 
10
69
  ### Changed
@@ -10,7 +10,8 @@
10
10
  /**
11
11
  * Determine whether a DSL command type is mutating (modifies workflow state).
12
12
  *
13
- * Read-only commands (list_nodes, list_edges, list_types, info, get_config, help)
13
+ * Read-only commands (list_nodes, list_edges, list_types, describe_type,
14
+ * search_types, info, get_config, help)
14
15
  * return false. All other commands are considered mutating and return true.
15
16
  *
16
17
  * @param commandType - The command type string (e.g., "add", "list_nodes")
@@ -28,3 +29,20 @@ export declare function isMutatingCommand(commandType: string): boolean;
28
29
  * @returns true if the command repositions existing nodes
29
30
  */
30
31
  export declare function isLayoutCommand(commandType: string): boolean;
32
+ /**
33
+ * Commands that drive the editor's *view* — selection, the config panel, the
34
+ * canvas viewport — and touch nothing in the workflow document.
35
+ *
36
+ * They are still mutating in {@link isMutatingCommand}'s sense (the chat panel
37
+ * keeps them click-to-apply), but a consumer that gates on "can this alter the
38
+ * user's document" can let them through: there is nothing to undo.
39
+ */
40
+ export declare const VIEW_COMMAND_TYPES: readonly ["select_node", "config_open", "canvas_fit_view", "canvas_zoom_in", "canvas_zoom_out", "canvas_zoom_to", "canvas_pan_to", "canvas_reset_view"];
41
+ /**
42
+ * Determine whether a DSL command type only changes what the editor shows —
43
+ * selection, an open panel, the viewport — and leaves the workflow itself as it was.
44
+ *
45
+ * @param commandType - The command type string (e.g., "canvas_zoom_in")
46
+ * @returns true if the command changes the view and not the document
47
+ */
48
+ export declare function isViewCommand(commandType: string): boolean;
@@ -12,6 +12,8 @@ const READ_ONLY_COMMANDS = new Set([
12
12
  'list_nodes',
13
13
  'list_edges',
14
14
  'list_types',
15
+ 'describe_type',
16
+ 'search_types',
15
17
  'info',
16
18
  'get_config',
17
19
  'help'
@@ -19,7 +21,8 @@ const READ_ONLY_COMMANDS = new Set([
19
21
  /**
20
22
  * Determine whether a DSL command type is mutating (modifies workflow state).
21
23
  *
22
- * Read-only commands (list_nodes, list_edges, list_types, info, get_config, help)
24
+ * Read-only commands (list_nodes, list_edges, list_types, describe_type,
25
+ * search_types, info, get_config, help)
23
26
  * return false. All other commands are considered mutating and return true.
24
27
  *
25
28
  * @param commandType - The command type string (e.g., "add", "list_nodes")
@@ -48,3 +51,32 @@ const LAYOUT_COMMANDS = new Set(['auto_layout', 'beautify_layout']);
48
51
  export function isLayoutCommand(commandType) {
49
52
  return LAYOUT_COMMANDS.has(commandType);
50
53
  }
54
+ /**
55
+ * Commands that drive the editor's *view* — selection, the config panel, the
56
+ * canvas viewport — and touch nothing in the workflow document.
57
+ *
58
+ * They are still mutating in {@link isMutatingCommand}'s sense (the chat panel
59
+ * keeps them click-to-apply), but a consumer that gates on "can this alter the
60
+ * user's document" can let them through: there is nothing to undo.
61
+ */
62
+ export const VIEW_COMMAND_TYPES = [
63
+ 'select_node',
64
+ 'config_open',
65
+ 'canvas_fit_view',
66
+ 'canvas_zoom_in',
67
+ 'canvas_zoom_out',
68
+ 'canvas_zoom_to',
69
+ 'canvas_pan_to',
70
+ 'canvas_reset_view'
71
+ ];
72
+ const VIEW_COMMANDS = new Set(VIEW_COMMAND_TYPES);
73
+ /**
74
+ * Determine whether a DSL command type only changes what the editor shows —
75
+ * selection, an open panel, the viewport — and leaves the workflow itself as it was.
76
+ *
77
+ * @param commandType - The command type string (e.g., "canvas_zoom_in")
78
+ * @returns true if the command changes the view and not the document
79
+ */
80
+ export function isViewCommand(commandType) {
81
+ return VIEW_COMMANDS.has(commandType);
82
+ }
@@ -23,6 +23,6 @@
23
23
  export { default as AIChatPanel } from '../components/chat/AIChatPanel.svelte';
24
24
  export { default as CommandPreview } from '../components/chat/CommandPreview.svelte';
25
25
  export { extractCommands } from './responseParser.js';
26
- export { isMutatingCommand, isLayoutCommand } from './commandClassifier.js';
26
+ export { isMutatingCommand, isLayoutCommand, isViewCommand, VIEW_COMMAND_TYPES } from './commandClassifier.js';
27
27
  export { buildApiHistory, type ChatLogEntry } from './historyBuilder.js';
28
28
  export type { ChatMessageRole, ChatHistoryMessage, ChatRequest, ChatResponse, ExtractedCommands, CommandExecutionStatus, CommandPreviewItem } from '../types/chat.js';
@@ -29,5 +29,5 @@ export { default as CommandPreview } from '../components/chat/CommandPreview.sve
29
29
  // Chat Utilities
30
30
  // ============================================================================
31
31
  export { extractCommands } from './responseParser.js';
32
- export { isMutatingCommand, isLayoutCommand } from './commandClassifier.js';
32
+ export { isMutatingCommand, isLayoutCommand, isViewCommand, VIEW_COMMAND_TYPES } from './commandClassifier.js';
33
33
  export { buildApiHistory } from './historyBuilder.js';