@flowdrop/flowdrop 2.7.0 → 2.8.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 (55) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/dist/api/enhanced-client.d.ts +29 -1
  3. package/dist/api/enhanced-client.js +83 -9
  4. package/dist/chat/index.d.ts +5 -1
  5. package/dist/chat/index.js +2 -0
  6. package/dist/chat/toolCatalogue.d.ts +27 -0
  7. package/dist/chat/toolCatalogue.js +35 -0
  8. package/dist/chat/turnDriver.d.ts +143 -0
  9. package/dist/chat/turnDriver.js +124 -0
  10. package/dist/components/App.svelte +47 -56
  11. package/dist/components/SettingsPanel.svelte +13 -0
  12. package/dist/components/WorkflowEditor.svelte +4 -2
  13. package/dist/components/WorkflowEditor.svelte.d.ts +2 -0
  14. package/dist/components/chat/AIChatPanel.svelte +410 -22
  15. package/dist/components/toast/DismissibleToast.svelte +53 -0
  16. package/dist/components/toast/DismissibleToast.svelte.d.ts +24 -0
  17. package/dist/components/toast/WarningIcon.svelte +28 -0
  18. package/dist/components/toast/WarningIcon.svelte.d.ts +26 -0
  19. package/dist/config/constants.d.ts +7 -3
  20. package/dist/config/constants.js +7 -3
  21. package/dist/config/endpoints.d.ts +7 -0
  22. package/dist/config/endpoints.js +2 -1
  23. package/dist/editor/index.d.ts +1 -1
  24. package/dist/editor/index.js +1 -1
  25. package/dist/messages/defaults.d.ts +41 -0
  26. package/dist/messages/defaults.js +20 -0
  27. package/dist/services/chatService.d.ts +21 -3
  28. package/dist/services/chatService.js +33 -1
  29. package/dist/services/globalSave.js +3 -1
  30. package/dist/services/toastService.d.ts +23 -2
  31. package/dist/services/toastService.js +72 -28
  32. package/dist/stores/instanceContainer.svelte.d.ts +34 -0
  33. package/dist/stores/instanceContainer.svelte.js +30 -0
  34. package/dist/styles/toast.css +62 -0
  35. package/dist/svelte-app.d.ts +12 -2
  36. package/dist/svelte-app.js +29 -12
  37. package/dist/types/chat.d.ts +59 -0
  38. package/dist/types/events.d.ts +23 -0
  39. package/dist/types/events.js +3 -1
  40. package/dist/types/settings.d.ts +18 -1
  41. package/dist/types/settings.js +1 -0
  42. package/dist/webmcp/WebMCPConfirm.svelte +129 -68
  43. package/dist/webmcp/WebMCPConfirm.svelte.d.ts +2 -2
  44. package/dist/webmcp/descriptors.d.ts +7 -0
  45. package/dist/webmcp/descriptors.js +51 -0
  46. package/dist/webmcp/gate.d.ts +13 -7
  47. package/dist/webmcp/gate.js +8 -53
  48. package/dist/webmcp/index.d.ts +5 -2
  49. package/dist/webmcp/index.js +3 -1
  50. package/dist/webmcp/register.d.ts +11 -10
  51. package/dist/webmcp/register.js +59 -384
  52. package/dist/webmcp/runtime.d.ts +33 -0
  53. package/dist/webmcp/runtime.js +500 -0
  54. package/dist/webmcp/types.d.ts +92 -0
  55. package/package.json +1 -1
@@ -16,9 +16,9 @@ import { type FlowDropInstance } from './stores/instanceContainer.svelte.js';
16
16
  import { type DraftStorageOption } from './services/draftStorage.js';
17
17
  import type { PartialSettings, SettingsCategory, SurfacePlacement } from './types/settings.js';
18
18
  import type { NavbarAction } from './types/navbar.js';
19
- import type { WebMCPHandle, WebMCPMountOptions } from './webmcp/types.js';
19
+ import type { HostHooks, WebMCPHandle, WebMCPMountOptions } from './webmcp/types.js';
20
20
  export type { NavbarAction };
21
- export type { WebMCPHandle, WebMCPMountOptions };
21
+ export type { HostHooks, WebMCPHandle, WebMCPMountOptions };
22
22
  /**
23
23
  * Mount options for FlowDrop App
24
24
  */
@@ -141,6 +141,16 @@ export interface FlowDropMountOptions {
141
141
  * API. Default off.
142
142
  */
143
143
  webmcp?: boolean | WebMCPMountOptions;
144
+ /**
145
+ * The host's save/run/status hooks, published on the instance as
146
+ * `instance.host` for every agent surface the editor has — the AI
147
+ * Assistant panel's tool loop today, the WebMCP editor tools when
148
+ * {@link webmcp} is on. `onSave` defaults to the mount's own Save. Hooks
149
+ * given inside the {@link webmcp} option take precedence, so a host that
150
+ * already passes them there need not repeat them; pass them here when the
151
+ * assistant must be able to run the workflow even with WebMCP switched off.
152
+ */
153
+ host?: HostHooks;
144
154
  }
145
155
  /**
146
156
  * Return type for mounted FlowDrop app
@@ -12,7 +12,7 @@ import App from './components/App.svelte';
12
12
  import { DEFAULT_PORT_CONFIG } from './config/defaultPortConfig.js';
13
13
  import { fetchPortConfig } from './services/portConfigApi.js';
14
14
  import { fetchCategories } from './services/categoriesApi.js';
15
- import { createFlowDropInstance, getDefaultInstance, DEFAULT_DRAFT_PREFIX } from './stores/instanceContainer.svelte.js';
15
+ import { createFlowDropInstance, definedHostHooks, getDefaultInstance, DEFAULT_DRAFT_PREFIX } from './stores/instanceContainer.svelte.js';
16
16
  import { DraftAutoSaveManager, getDraftStorageKey, migrateLegacyDraftKey, setDraftStorage, resolveDraftStorage, clearAllDrafts as clearAllDraftsFromStorage } from './services/draftStorage.js';
17
17
  import { mergeFeatures } from './types/events.js';
18
18
  import { initializeSettings, getBehaviorSettings, onSettingsChange } from './stores/settingsStore.svelte.js';
@@ -157,7 +157,7 @@ function attachWebMCPToMount(fd, options, isDestroyed) {
157
157
  * ```
158
158
  */
159
159
  export async function mountFlowDropApp(container, options = {}) {
160
- const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, pipelineId, navbarTitle, navbarActions, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp } = options;
160
+ const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, pipelineId, navbarTitle, navbarActions, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host } = options;
161
161
  // Per-instance state container — this is what allows multiple FlowDrop
162
162
  // editors to coexist on one page without sharing workflow/history state.
163
163
  const { fd, isDefault } = acquireInstance(instanceId);
@@ -375,17 +375,34 @@ export async function mountFlowDropApp(container, options = {}) {
375
375
  // not wait for it — and detaches with the mount. Defaults `onSave` to the
376
376
  // mount's own Save so a browser agent's `save` tool persists exactly like
377
377
  // clicking Save does; a host that supplies its own `onSave` overrides it.
378
- if (webmcp) {
379
- const webmcpOptions = {
380
- onSave: async () => (await mountedApp.save())
381
- ? undefined
382
- : {
383
- ok: false,
384
- code: 'UNAVAILABLE',
385
- message: 'Nothing was saved: the host cancelled the save or no workflow is loaded.'
386
- },
387
- ...(webmcp === true ? {} : webmcp)
378
+ //
379
+ // The same hooks are published on the instance (`fd.host`) whether or not
380
+ // WebMCP is on: the chat panel's tool loop offers `save`, `run` and
381
+ // `run_status` through them, so the built-in assistant and a browser agent
382
+ // persist and run the same way.
383
+ const defaultOnSave = async () => (await mountedApp.save())
384
+ ? undefined
385
+ : {
386
+ ok: false,
387
+ code: 'UNAVAILABLE',
388
+ message: 'Nothing was saved: the host cancelled the save or no workflow is loaded.'
388
389
  };
390
+ // Hook keys are merged through `definedHostHooks` on both inputs, so an
391
+ // explicit `onSave: undefined` in either never shadows the default.
392
+ const webmcpGiven = webmcp === true || !webmcp ? {} : webmcp;
393
+ const { onSave: _s, onRun: _r, onRunStatus: _rs, ...webmcpRest } = webmcpGiven;
394
+ const webmcpOptions = {
395
+ ...webmcpRest,
396
+ onSave: defaultOnSave,
397
+ ...definedHostHooks(host ?? {}),
398
+ ...definedHostHooks(webmcpGiven)
399
+ };
400
+ fd.host.set({
401
+ onSave: webmcpOptions.onSave,
402
+ onRun: webmcpOptions.onRun,
403
+ onRunStatus: webmcpOptions.onRunStatus
404
+ });
405
+ if (webmcp) {
389
406
  void attachWebMCPToMount(fd, webmcpOptions, () => destroyed).then((handle) => {
390
407
  if (destroyed)
391
408
  handle?.detach();
@@ -65,3 +65,62 @@ export interface CommandPreviewItem {
65
65
  /** Optional result or error message after execution */
66
66
  result?: string;
67
67
  }
68
+ /**
69
+ * One tool as the panel offers it to the server, in the shape a function-
70
+ * calling reasoner expects: `{name, description, input_schema}` plus the
71
+ * read-only flag. Projected from the editor's tool descriptors by
72
+ * `toToolDefinitions()`; the server holds no copy of these schemas.
73
+ *
74
+ * Names are the bare verbs (`describe_type`, `batch`, `save`) — no prefix.
75
+ */
76
+ export interface ChatToolDefinition {
77
+ name: string;
78
+ description: string;
79
+ input_schema: Record<string, unknown>;
80
+ readOnly: boolean;
81
+ }
82
+ /** A tool call the assistant made; the panel runs it and posts the result. */
83
+ export interface ChatToolCall {
84
+ /** Server-issued id, echoed back as `toolCallId`. */
85
+ id: string;
86
+ name: string;
87
+ args: Record<string, unknown>;
88
+ }
89
+ /**
90
+ * The first request of a turn. A superset of {@link ChatRequest}: a server
91
+ * that knows tool-calling turns reads `tools`; an older one ignores it and
92
+ * answers a plain {@link ChatResponse}, which the panel treats as legacy.
93
+ */
94
+ export interface ChatTurnRequest extends ChatRequest {
95
+ /** The tools the panel can run for this turn, in call order preference. */
96
+ tools: ChatToolDefinition[];
97
+ }
98
+ /** One tool result, posted back to continue the turn. */
99
+ export interface ChatToolResult {
100
+ toolCallId: string;
101
+ /** The tool's result as text — the JSON the runtime returned. */
102
+ content: string;
103
+ /** Set when the tool reported an error (`isError` on the tool result). */
104
+ isError?: boolean;
105
+ }
106
+ export interface ChatToolResultsRequest {
107
+ results: ChatToolResult[];
108
+ }
109
+ /**
110
+ * What the server answers to a turn request or a tool-results post.
111
+ *
112
+ * `done: true` carries the assistant's final `content`; `done: false`
113
+ * carries `toolCalls` the panel must run and post back. `turnId` is present
114
+ * on every response of a tool-calling server; its absence marks a legacy
115
+ * server and a plain {@link ChatResponse}.
116
+ *
117
+ * `content` may also accompany `toolCalls` on a non-final response
118
+ * (`done: false`): text the model wrote alongside its calls — a note to the
119
+ * user, e.g. "this node has no url input port" — rather than the reply.
120
+ * Shown in the trace, never as the message body.
121
+ */
122
+ export interface ChatTurnResponse extends ChatResponse {
123
+ turnId?: string;
124
+ toolCalls?: ChatToolCall[];
125
+ done?: boolean;
126
+ }
@@ -221,6 +221,29 @@ export interface FlowDropFeatures {
221
221
  * @default true
222
222
  */
223
223
  builtinEditors?: boolean;
224
+ /**
225
+ * Offer the Command Console tab in the console / AI Assistant group.
226
+ *
227
+ * The console is a command line for the editor's DSL. Hosts whose users
228
+ * are not developers may prefer to hide it, so nobody mistakes it for a
229
+ * chat. When both `console` and `assistant` are off, the group's toggle
230
+ * button and its backtick shortcut disappear as well.
231
+ *
232
+ * @default true
233
+ */
234
+ console?: boolean;
235
+ /**
236
+ * Offer the AI Assistant tab in the console / AI Assistant group.
237
+ *
238
+ * Independent of this flag, the tab is only offered when the endpoint
239
+ * configuration carries a `chat` endpoint group — an assistant with no
240
+ * backend has nothing to say. Browser agents (WebMCP) do not depend on the
241
+ * panel: they drive the same tool runtime through the browser's model
242
+ * context and keep working with the assistant hidden.
243
+ *
244
+ * @default true
245
+ */
246
+ assistant?: boolean;
224
247
  }
225
248
  /**
226
249
  * Default feature values
@@ -16,7 +16,9 @@ export const DEFAULT_FEATURES = {
16
16
  autoSaveDraftInterval: 30000,
17
17
  showToasts: true,
18
18
  enableNodeSwap: true,
19
- builtinEditors: true
19
+ builtinEditors: true,
20
+ console: true,
21
+ assistant: true
20
22
  };
21
23
  /**
22
24
  * Merge user-provided features with defaults
@@ -105,7 +105,24 @@ export interface BehaviorSettings {
105
105
  undoHistoryLimit: number;
106
106
  /** Show confirmation dialog before deleting nodes */
107
107
  confirmDelete: boolean;
108
- /** Automatically re-submit batch failures to the AI for self-correction */
108
+ /**
109
+ * How the AI assistant works with the editor.
110
+ *
111
+ * - `'tools'` (default): the assistant calls the editor's tools — the same
112
+ * `describe_type`, `batch`, `save`, `run`, … a WebMCP browser agent gets —
113
+ * in a loop inside one message; reads run at once, document changes ask
114
+ * once per round in the approval dialog. Needs a backend with the
115
+ * `chat.toolResults` endpoint; without one the panel falls back to `'dsl'`
116
+ * for the session and says so.
117
+ * - `'dsl'`: the legacy text mode — one reply holding a ```flowdrop block,
118
+ * previewed and applied on click. Deprecated; kept for one minor.
119
+ */
120
+ chatMode: 'tools' | 'dsl';
121
+ /**
122
+ * Automatically re-submit batch failures to the AI for self-correction.
123
+ * Legacy `'dsl'` mode only: in `'tools'` mode the tool result itself tells
124
+ * the assistant what went wrong, in the same turn.
125
+ */
109
126
  chatAutoRetry: boolean;
110
127
  /**
111
128
  * Allow the AI assistant's commands to reposition nodes
@@ -75,6 +75,7 @@ export const DEFAULT_BEHAVIOR_SETTINGS = {
75
75
  storeDraftsInBrowser: true,
76
76
  undoHistoryLimit: 50,
77
77
  confirmDelete: false,
78
+ chatMode: 'tools',
78
79
  chatAutoRetry: true,
79
80
  chatAllowLayoutChanges: true
80
81
  };
@@ -13,8 +13,8 @@
13
13
  import { focusOnMount } from '../utils/focus.js';
14
14
 
15
15
  interface Props {
16
- /** Editor / workflow name, so two editors on one page are distinguishable. */
17
- editorName: string;
16
+ /** The title — who wants to change which editor (see `GateRequest.title`). */
17
+ title: string;
18
18
  /** One human-readable line per command (see `describeCommand`). */
19
19
  lines: string[];
20
20
  /**
@@ -31,7 +31,7 @@
31
31
  onResolve: (approved: boolean, remember?: boolean) => void;
32
32
  }
33
33
 
34
- let { editorName, lines, hint, offerRemember = false, onResolve }: Props = $props();
34
+ let { title, lines, hint, offerRemember = false, onResolve }: Props = $props();
35
35
 
36
36
  let rejectButton = $state<HTMLButtonElement | null>(null);
37
37
  let approveButton = $state<HTMLButtonElement | null>(null);
@@ -67,32 +67,36 @@
67
67
  tabindex="-1"
68
68
  onkeydown={handleKeydown}
69
69
  >
70
- <h2 id="fd-webmcp-confirm-title" class="fd-webmcp-confirm__title">
71
- {m().webmcp.confirmTitle({ name: editorName })}
72
- </h2>
73
- <p class="fd-webmcp-confirm__hint">
74
- {hint ?? m().webmcp.confirmCount({ count: lines.length })}
75
- </p>
76
- <ol id="fd-webmcp-confirm-list" class="fd-webmcp-confirm__list">
77
- {#each lines as line, i (i)}
78
- <li class="fd-webmcp-confirm__line">{line}</li>
79
- {/each}
80
- </ol>
81
- {#if offerRemember}
82
- <label class="fd-webmcp-confirm__remember">
83
- <input
84
- type="checkbox"
85
- data-testid="flowdrop-webmcp-remember"
86
- bind:this={rememberBox}
87
- bind:checked={remember}
88
- />
89
- {m().webmcp.rememberEdits}
90
- </label>
91
- {/if}
92
- <div class="fd-webmcp-confirm__actions">
70
+ <header class="fd-webmcp-confirm__header">
71
+ <h2 id="fd-webmcp-confirm-title" class="fd-webmcp-confirm__title">
72
+ {title}
73
+ </h2>
74
+ <p class="fd-webmcp-confirm__hint">
75
+ {hint ?? m().webmcp.confirmCount({ count: lines.length })}
76
+ </p>
77
+ </header>
78
+ <div class="fd-webmcp-confirm__body">
79
+ <ol id="fd-webmcp-confirm-list" class="fd-webmcp-confirm__list">
80
+ {#each lines as line, i (i)}
81
+ <li class="fd-webmcp-confirm__line">{line}</li>
82
+ {/each}
83
+ </ol>
84
+ {#if offerRemember}
85
+ <label class="fd-webmcp-confirm__remember">
86
+ <input
87
+ type="checkbox"
88
+ data-testid="flowdrop-webmcp-remember"
89
+ bind:this={rememberBox}
90
+ bind:checked={remember}
91
+ />
92
+ <span>{m().webmcp.rememberEdits}</span>
93
+ </label>
94
+ {/if}
95
+ </div>
96
+ <footer class="fd-webmcp-confirm__actions">
93
97
  <button
94
98
  type="button"
95
- class="fd-webmcp-confirm__button fd-webmcp-confirm__button--reject"
99
+ class="flowdrop-btn flowdrop-btn--outline fd-webmcp-confirm__button"
96
100
  data-testid="flowdrop-webmcp-reject"
97
101
  bind:this={rejectButton}
98
102
  onclick={() => onResolve(false)}
@@ -101,7 +105,7 @@
101
105
  </button>
102
106
  <button
103
107
  type="button"
104
- class="fd-webmcp-confirm__button fd-webmcp-confirm__button--approve"
108
+ class="flowdrop-btn flowdrop-btn--primary fd-webmcp-confirm__button"
105
109
  data-testid="flowdrop-webmcp-approve"
106
110
  bind:this={approveButton}
107
111
  {@attach focusOnMount()}
@@ -109,11 +113,17 @@
109
113
  >
110
114
  {m().webmcp.apply}
111
115
  </button>
112
- </div>
116
+ </footer>
113
117
  </div>
114
118
  </div>
115
119
 
116
120
  <style>
121
+ /* Mounted on document.body, outside the editor tree: the tokens come from
122
+ :root (tokens.css), the button classes from base.css — both global — and
123
+ the dark skin from [data-theme='dark'] on <html>. Only the font has no
124
+ host to inherit from, so it is set here. The shell follows
125
+ SettingsModal: blurred backdrop, header / body / footer with the xl
126
+ rhythm, and an enter animation. */
117
127
  .fd-webmcp-confirm {
118
128
  position: fixed;
119
129
  inset: 0;
@@ -121,96 +131,147 @@
121
131
  display: flex;
122
132
  align-items: center;
123
133
  justify-content: center;
124
- background: rgb(0 0 0 / 0.4);
125
- /* Mounted on document.body, outside the editor: no host font to inherit. */
134
+ padding: var(--fd-space-xl, 1rem);
135
+ background: rgb(0 0 0 / 0.5);
136
+ backdrop-filter: blur(4px);
126
137
  font-family: var(--fd-font-sans, system-ui, sans-serif);
127
- font-size: var(--fd-text-md, 1rem);
138
+ font-size: var(--fd-text-sm, 0.875rem);
128
139
  line-height: var(--fd-leading-normal, 1.5);
129
140
  }
130
141
 
131
142
  .fd-webmcp-confirm__dialog {
132
- min-width: 20rem;
133
- max-width: min(36rem, calc(100vw - 2rem));
134
- max-height: calc(100vh - 2rem);
135
- overflow: auto;
136
- padding: var(--fd-space-lg, 1rem);
143
+ display: flex;
144
+ flex-direction: column;
145
+ width: 100%;
146
+ max-width: 36rem;
147
+ max-height: calc(100vh - 2 * var(--fd-space-xl, 1rem));
148
+ overflow: hidden;
137
149
  border: 1px solid var(--fd-border, #d4d4d8);
138
- border-radius: var(--fd-radius-lg, 0.75rem);
150
+ border-radius: var(--fd-radius-lg, 0.5rem);
139
151
  background: var(--fd-background, #fff);
140
152
  color: var(--fd-foreground, #18181b);
141
153
  box-shadow: var(--fd-shadow-xl, 0 20px 40px rgb(0 0 0 / 0.25));
154
+ animation: fd-webmcp-confirm-enter 0.2s ease-out;
155
+ }
156
+
157
+ .fd-webmcp-confirm__dialog:focus {
158
+ outline: none;
159
+ }
160
+
161
+ @keyframes fd-webmcp-confirm-enter {
162
+ from {
163
+ opacity: 0;
164
+ transform: scale(0.95) translateY(-10px);
165
+ }
166
+ to {
167
+ opacity: 1;
168
+ transform: scale(1) translateY(0);
169
+ }
170
+ }
171
+
172
+ .fd-webmcp-confirm__header {
173
+ flex-shrink: 0;
174
+ padding: var(--fd-space-xl, 1rem) var(--fd-space-xl, 1rem) var(--fd-space-lg, 0.875rem);
175
+ border-bottom: 1px solid var(--fd-border, #d4d4d8);
142
176
  }
143
177
 
144
178
  .fd-webmcp-confirm__title {
145
- margin: 0 0 var(--fd-space-xs, 0.25rem);
146
- font-size: var(--fd-text-md, 1rem);
179
+ margin: 0 0 var(--fd-space-2xs, 0.25rem);
180
+ font-size: var(--fd-text-lg, 1.125rem);
147
181
  font-weight: 600;
182
+ line-height: var(--fd-leading-tight, 1.3);
183
+ color: var(--fd-foreground, #18181b);
184
+ overflow-wrap: anywhere;
148
185
  }
149
186
 
150
187
  .fd-webmcp-confirm__hint {
151
- margin: 0 0 var(--fd-space-md, 0.75rem);
188
+ margin: 0;
152
189
  font-size: var(--fd-text-sm, 0.875rem);
153
190
  color: var(--fd-muted-foreground, #71717a);
154
191
  }
155
192
 
193
+ .fd-webmcp-confirm__body {
194
+ flex: 1;
195
+ min-height: 0;
196
+ overflow: auto;
197
+ padding: var(--fd-space-xl, 1rem);
198
+ }
199
+
156
200
  .fd-webmcp-confirm__list {
157
- margin: 0 0 var(--fd-space-lg, 1rem);
158
- padding: var(--fd-space-sm, 0.5rem) var(--fd-space-sm, 0.5rem) var(--fd-space-sm, 0.5rem)
159
- var(--fd-space-xl, 1.5rem);
160
- border-radius: var(--fd-radius-md, 0.5rem);
201
+ margin: 0;
202
+ padding: var(--fd-space-md, 0.75rem) var(--fd-space-lg, 0.875rem) var(--fd-space-md, 0.75rem)
203
+ var(--fd-space-3xl, 2.25rem);
204
+ border: 1px solid var(--fd-border, #d4d4d8);
205
+ border-radius: var(--fd-radius-md, 0.375rem);
161
206
  background: var(--fd-muted, #f4f4f5);
162
207
  font-family: var(--fd-font-mono, ui-monospace, monospace);
163
- font-size: var(--fd-text-sm, 0.875rem);
208
+ font-size: var(--fd-text-xs, 0.8125rem);
209
+ line-height: var(--fd-leading-relaxed, 1.6);
210
+ color: var(--fd-foreground, #18181b);
164
211
  }
165
212
 
166
213
  .fd-webmcp-confirm__line {
167
- padding: 0.125rem 0;
214
+ padding: var(--fd-space-3xs, 0.125rem) 0;
168
215
  overflow-wrap: anywhere;
169
216
  }
170
217
 
218
+ .fd-webmcp-confirm__line::marker {
219
+ color: var(--fd-muted-foreground, #71717a);
220
+ }
221
+
171
222
  .fd-webmcp-confirm__remember {
172
223
  display: flex;
173
224
  align-items: flex-start;
174
- gap: var(--fd-space-sm, 0.5rem);
175
- margin: 0 0 var(--fd-space-lg, 1rem);
225
+ gap: var(--fd-space-sm, 0.625rem);
226
+ margin: var(--fd-space-lg, 0.875rem) 0 0;
176
227
  font-size: var(--fd-text-sm, 0.875rem);
177
228
  color: var(--fd-muted-foreground, #71717a);
178
229
  cursor: pointer;
179
230
  }
180
231
 
181
232
  .fd-webmcp-confirm__remember input {
233
+ flex-shrink: 0;
234
+ width: 1rem;
235
+ height: 1rem;
182
236
  margin: 0.2em 0 0;
183
237
  accent-color: var(--fd-primary, #2563eb);
238
+ cursor: pointer;
239
+ }
240
+
241
+ .fd-webmcp-confirm__remember:hover {
242
+ color: var(--fd-foreground, #18181b);
184
243
  }
185
244
 
186
245
  .fd-webmcp-confirm__actions {
246
+ flex-shrink: 0;
187
247
  display: flex;
188
248
  justify-content: flex-end;
189
- gap: var(--fd-space-sm, 0.5rem);
249
+ gap: var(--fd-space-sm, 0.625rem);
250
+ padding: var(--fd-space-lg, 0.875rem) var(--fd-space-xl, 1rem);
251
+ border-top: 1px solid var(--fd-border, #d4d4d8);
252
+ background: var(--fd-muted, #f4f4f5);
190
253
  }
191
254
 
255
+ /* The buttons are .flowdrop-btn from base.css; this only keeps them from
256
+ inheriting the host page's button font when base.css is absent. */
192
257
  .fd-webmcp-confirm__button {
193
- padding: var(--fd-space-xs, 0.375rem) var(--fd-space-md, 0.75rem);
194
- border: 1px solid var(--fd-border, #d4d4d8);
195
- border-radius: var(--fd-control-radius, 0.375rem);
196
- background: var(--fd-background, #fff);
197
- color: inherit;
198
- font: inherit;
199
- cursor: pointer;
258
+ font-family: inherit;
200
259
  }
201
260
 
202
- .fd-webmcp-confirm__button--approve {
203
- border-color: var(--fd-primary, #2563eb);
204
- background: var(--fd-primary, #2563eb);
205
- color: var(--fd-primary-foreground, #fff);
206
- }
261
+ @media (max-width: 640px) {
262
+ .fd-webmcp-confirm {
263
+ padding: 0;
264
+ align-items: flex-end;
265
+ }
207
266
 
208
- .fd-webmcp-confirm__button--approve:hover {
209
- background: var(--fd-primary-hover, #1d4ed8);
210
- }
267
+ .fd-webmcp-confirm__dialog {
268
+ max-width: 100%;
269
+ max-height: 100vh;
270
+ border-radius: var(--fd-radius-lg, 0.5rem) var(--fd-radius-lg, 0.5rem) 0 0;
271
+ }
211
272
 
212
- .fd-webmcp-confirm__button:focus-visible {
213
- outline: 2px solid var(--fd-primary, #2563eb);
214
- outline-offset: 2px;
273
+ .fd-webmcp-confirm__actions {
274
+ flex-direction: column-reverse;
275
+ }
215
276
  }
216
277
  </style>
@@ -1,6 +1,6 @@
1
1
  interface Props {
2
- /** Editor / workflow name, so two editors on one page are distinguishable. */
3
- editorName: string;
2
+ /** The title — who wants to change which editor (see `GateRequest.title`). */
3
+ title: string;
4
4
  /** One human-readable line per command (see `describeCommand`). */
5
5
  lines: string[];
6
6
  /**
@@ -17,6 +17,7 @@
17
17
  * @module webmcp/descriptors
18
18
  */
19
19
  import type { Command } from '../commands/types.js';
20
+ import type { Messages } from '../messages/types.js';
20
21
  import { VIEW_COMMAND_TYPES } from '../chat/commandClassifier.js';
21
22
  import { type ToolDescriptor, type ToolInputSchema } from './types.js';
22
23
  import { validateToolArgs } from './validate.js';
@@ -57,3 +58,9 @@ export interface BuildDescriptorsOptions {
57
58
  export declare function buildToolDescriptors(options?: BuildDescriptorsOptions): ToolDescriptor[];
58
59
  /** One line describing a command for a human about to approve it. */
59
60
  export declare function describeCommand(command: Command): string;
61
+ /**
62
+ * One sentence saying what a list of commands does, for the approval dialog's hint and the chat transcript:
63
+ * "3 changes — adds 2 nodes, connects 1 edge. Applied together, undone together."
64
+ * Returns `undefined` for a single command, whose one line already says it all.
65
+ */
66
+ export declare function summarizeCommands(commands: Command[], m: Messages['webmcp']): string | undefined;
@@ -502,3 +502,54 @@ export function describeCommand(command) {
502
502
  }
503
503
  return OTHER_SUMMARIES[type](command);
504
504
  }
505
+ /**
506
+ * One sentence saying what a list of commands does, for the approval dialog's hint and the chat transcript:
507
+ * "3 changes — adds 2 nodes, connects 1 edge. Applied together, undone together."
508
+ * Returns `undefined` for a single command, whose one line already says it all.
509
+ */
510
+ export function summarizeCommands(commands, m) {
511
+ if (commands.length < 2)
512
+ return undefined;
513
+ let adds = 0;
514
+ let deletes = 0;
515
+ let connects = 0;
516
+ let disconnects = 0;
517
+ let configs = 0;
518
+ let other = 0;
519
+ for (const c of commands) {
520
+ switch (c.type) {
521
+ case 'add_node':
522
+ adds++;
523
+ break;
524
+ case 'delete_node':
525
+ deletes++;
526
+ break;
527
+ case 'connect':
528
+ connects++;
529
+ break;
530
+ case 'disconnect_ports':
531
+ case 'disconnect_node':
532
+ disconnects++;
533
+ break;
534
+ case 'set_config':
535
+ configs++;
536
+ break;
537
+ default:
538
+ other++;
539
+ }
540
+ }
541
+ const parts = [];
542
+ if (adds)
543
+ parts.push(m.summaryAdds({ count: adds }));
544
+ if (deletes)
545
+ parts.push(m.summaryDeletes({ count: deletes }));
546
+ if (connects)
547
+ parts.push(m.summaryConnects({ count: connects }));
548
+ if (disconnects)
549
+ parts.push(m.summaryDisconnects({ count: disconnects }));
550
+ if (configs)
551
+ parts.push(m.summaryConfigs({ count: configs }));
552
+ if (other)
553
+ parts.push(m.summaryOther({ count: other }));
554
+ return m.batchSummary({ count: commands.length, parts: parts.join(', ') });
555
+ }
@@ -20,7 +20,7 @@
20
20
  * @module webmcp/gate
21
21
  */
22
22
  import type { Command } from '../commands/types.js';
23
- import type { Messages, MessagesOverride } from '../messages/index.js';
23
+ import type { MessagesOverride } from '../messages/index.js';
24
24
  import type { WebMCPApproval, WebMCPApprovalRequest } from './types.js';
25
25
  /** What the gate needs to know about the call it is asking approval for. */
26
26
  export interface GateRequest extends WebMCPApprovalRequest {
@@ -32,6 +32,12 @@ export interface GateRequest extends WebMCPApprovalRequest {
32
32
  lines?: string[];
33
33
  /** Extra sentence shown under the title, e.g. "This cannot be undone." */
34
34
  hint?: string;
35
+ /**
36
+ * The dialog's title — who is asking. Defaults to the WebMCP wording ("A
37
+ * browser agent wants to change …"); the chat panel passes its own so a
38
+ * shared gate still says which surface is asking.
39
+ */
40
+ title?: string;
35
41
  /**
36
42
  * A consequential call (`save`, `run`) is never covered by the "don't ask
37
43
  * again for edits" choice and never offers it. Defaults to `tool` being
@@ -48,6 +54,12 @@ export interface ApprovalGate {
48
54
  request(commands: Command[], request: GateRequest): Promise<boolean>;
49
55
  /** True while a decision is pending. */
50
56
  readonly busy: boolean;
57
+ /**
58
+ * Whether this gate can ask at all. `false` under `approval: 'auto'`, where
59
+ * every request resolves at once; a caller announcing "waiting for your
60
+ * approval" reads this rather than guessing from how it got the gate.
61
+ */
62
+ readonly asks: boolean;
51
63
  /** True once the person chose to apply further edits without asking. */
52
64
  readonly editsPreApproved: boolean;
53
65
  /** Dismiss any open dialog (as a rejection) and release resources. */
@@ -67,10 +79,4 @@ export interface CreateGateOptions {
67
79
  /** Offer the "don't ask again for edits" choice. Default true. */
68
80
  rememberEdits?: boolean;
69
81
  }
70
- /**
71
- * One sentence saying what a list of commands does, for the dialog's hint:
72
- * "3 changes — adds 2 nodes, connects 1 edge. Applied together, undone together."
73
- * Returns `undefined` for a single command, whose one line already says it all.
74
- */
75
- export declare function summarizeCommands(commands: Command[], m: Messages['webmcp']): string | undefined;
76
82
  export declare function createApprovalGate(approval: WebMCPApproval, options: CreateGateOptions): ApprovalGate;