@flowdrop/flowdrop 2.7.0 → 2.9.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 (66) hide show
  1. package/CHANGELOG.md +71 -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/form/FieldFactory.svelte +478 -0
  16. package/dist/components/form/FieldFactory.svelte.d.ts +14 -0
  17. package/dist/components/form/FormField.svelte +19 -404
  18. package/dist/components/form/FormField.svelte.d.ts +2 -27
  19. package/dist/components/form/FormFieldLight.svelte +11 -424
  20. package/dist/components/form/FormFieldLight.svelte.d.ts +2 -28
  21. package/dist/components/form/FormMarkdownEditor.svelte +11 -4
  22. package/dist/components/form/FormTemplateEditor.svelte +12 -5
  23. package/dist/components/form/resolveFieldType.d.ts +18 -15
  24. package/dist/components/form/resolveFieldType.js +33 -12
  25. package/dist/components/form/types.d.ts +14 -2
  26. package/dist/components/toast/DismissibleToast.svelte +53 -0
  27. package/dist/components/toast/DismissibleToast.svelte.d.ts +24 -0
  28. package/dist/components/toast/WarningIcon.svelte +28 -0
  29. package/dist/components/toast/WarningIcon.svelte.d.ts +26 -0
  30. package/dist/config/constants.d.ts +7 -3
  31. package/dist/config/constants.js +7 -3
  32. package/dist/config/endpoints.d.ts +7 -0
  33. package/dist/config/endpoints.js +2 -1
  34. package/dist/editor/index.d.ts +1 -1
  35. package/dist/editor/index.js +1 -1
  36. package/dist/messages/defaults.d.ts +41 -0
  37. package/dist/messages/defaults.js +20 -0
  38. package/dist/services/chatService.d.ts +21 -3
  39. package/dist/services/chatService.js +33 -1
  40. package/dist/services/globalSave.js +3 -1
  41. package/dist/services/toastService.d.ts +23 -2
  42. package/dist/services/toastService.js +72 -28
  43. package/dist/stores/instanceContainer.svelte.d.ts +34 -0
  44. package/dist/stores/instanceContainer.svelte.js +30 -0
  45. package/dist/styles/toast.css +62 -0
  46. package/dist/svelte-app.d.ts +12 -2
  47. package/dist/svelte-app.js +29 -12
  48. package/dist/types/chat.d.ts +59 -0
  49. package/dist/types/events.d.ts +23 -0
  50. package/dist/types/events.js +3 -1
  51. package/dist/types/settings.d.ts +18 -1
  52. package/dist/types/settings.js +1 -0
  53. package/dist/webmcp/WebMCPConfirm.svelte +129 -68
  54. package/dist/webmcp/WebMCPConfirm.svelte.d.ts +2 -2
  55. package/dist/webmcp/descriptors.d.ts +7 -0
  56. package/dist/webmcp/descriptors.js +51 -0
  57. package/dist/webmcp/gate.d.ts +13 -7
  58. package/dist/webmcp/gate.js +8 -53
  59. package/dist/webmcp/index.d.ts +5 -2
  60. package/dist/webmcp/index.js +3 -1
  61. package/dist/webmcp/register.d.ts +11 -10
  62. package/dist/webmcp/register.js +59 -384
  63. package/dist/webmcp/runtime.d.ts +33 -0
  64. package/dist/webmcp/runtime.js +500 -0
  65. package/dist/webmcp/types.d.ts +92 -0
  66. package/package.json +1 -1
@@ -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;
@@ -21,7 +21,7 @@
21
21
  */
22
22
  import { mount, unmount } from 'svelte';
23
23
  import { defaultMessages, mergeMessages, messagesContext } from '../messages/index.js';
24
- import { describeCommand } from './descriptors.js';
24
+ import { describeCommand, summarizeCommands } from './descriptors.js';
25
25
  import WebMCPConfirm from './WebMCPConfirm.svelte';
26
26
  /** A second mutating call arrived while a decision was pending. */
27
27
  export class GateBusyError extends Error {
@@ -31,57 +31,6 @@ export class GateBusyError extends Error {
31
31
  }
32
32
  }
33
33
  const CONSEQUENTIAL_TOOLS = new Set(['save', 'run']);
34
- /**
35
- * One sentence saying what a list of commands does, for the dialog's hint:
36
- * "3 changes — adds 2 nodes, connects 1 edge. Applied together, undone together."
37
- * Returns `undefined` for a single command, whose one line already says it all.
38
- */
39
- export function summarizeCommands(commands, m) {
40
- if (commands.length < 2)
41
- return undefined;
42
- let adds = 0;
43
- let deletes = 0;
44
- let connects = 0;
45
- let disconnects = 0;
46
- let configs = 0;
47
- let other = 0;
48
- for (const c of commands) {
49
- switch (c.type) {
50
- case 'add_node':
51
- adds++;
52
- break;
53
- case 'delete_node':
54
- deletes++;
55
- break;
56
- case 'connect':
57
- connects++;
58
- break;
59
- case 'disconnect_ports':
60
- case 'disconnect_node':
61
- disconnects++;
62
- break;
63
- case 'set_config':
64
- configs++;
65
- break;
66
- default:
67
- other++;
68
- }
69
- }
70
- const parts = [];
71
- if (adds)
72
- parts.push(m.summaryAdds({ count: adds }));
73
- if (deletes)
74
- parts.push(m.summaryDeletes({ count: deletes }));
75
- if (connects)
76
- parts.push(m.summaryConnects({ count: connects }));
77
- if (disconnects)
78
- parts.push(m.summaryDisconnects({ count: disconnects }));
79
- if (configs)
80
- parts.push(m.summaryConfigs({ count: configs }));
81
- if (other)
82
- parts.push(m.summaryOther({ count: other }));
83
- return m.batchSummary({ count: commands.length, parts: parts.join(', ') });
84
- }
85
34
  export function createApprovalGate(approval, options) {
86
35
  let pending = false;
87
36
  let dismiss = null;
@@ -117,6 +66,9 @@ export function createApprovalGate(approval, options) {
117
66
  return [m.runLine({ name: options.editorName() })];
118
67
  return commands.map(describeCommand);
119
68
  }
69
+ function resolveTitle(request) {
70
+ return request.title ?? messages().webmcp.confirmTitle({ name: options.editorName() });
71
+ }
120
72
  function resolveHint(commands, request) {
121
73
  if (request.hint !== undefined)
122
74
  return request.hint;
@@ -153,7 +105,7 @@ export function createApprovalGate(approval, options) {
153
105
  target: host,
154
106
  context: messagesContext(messages),
155
107
  props: {
156
- editorName: options.editorName(),
108
+ title: resolveTitle(request),
157
109
  lines: resolveLines(commands, request),
158
110
  hint: resolveHint(commands, request),
159
111
  offerRemember: offerRemember && !isConsequential(request),
@@ -167,6 +119,9 @@ export function createApprovalGate(approval, options) {
167
119
  get busy() {
168
120
  return pending;
169
121
  },
122
+ get asks() {
123
+ return approval !== 'auto';
124
+ },
170
125
  get editsPreApproved() {
171
126
  return editsPreApproved;
172
127
  },
@@ -25,7 +25,10 @@
25
25
  * ```
26
26
  */
27
27
  export { attachWebMCP, detectModelContext, DEFAULT_PREFIX } from './register.js';
28
- export { buildToolDescriptors, describeCommand, EXPOSED_COMMAND_TYPES, VIEW_COMMAND_TYPES, EXCLUDED_COMMAND_TYPES, COMPOSITE_VERBS } from './descriptors.js';
28
+ export { createToolRuntime, buildHostToolDescriptors } from './runtime.js';
29
+ export { createApprovalGate, GateBusyError } from './gate.js';
30
+ export type { ApprovalGate, GateRequest, CreateGateOptions } from './gate.js';
31
+ export { buildToolDescriptors, describeCommand, summarizeCommands, EXPOSED_COMMAND_TYPES, VIEW_COMMAND_TYPES, EXCLUDED_COMMAND_TYPES, COMPOSITE_VERBS } from './descriptors.js';
29
32
  export type { BuildDescriptorsOptions } from './descriptors.js';
30
33
  export { validateToolArgs, VALIDATOR_KEYWORDS } from './validate.js';
31
34
  export { ToolArgumentError } from './types.js';
@@ -33,4 +36,4 @@ export { createFakeModelContext } from './fake.js';
33
36
  export type { FakeModelContext } from './fake.js';
34
37
  export { createBridgedModelContext, installBridgedModelContext } from './bridge.js';
35
38
  export type { WebMCPWidgetLike, BridgedModelContext } from './bridge.js';
36
- export type { ToolDescriptor, ToolInputSchema, ToolSchemaProperty, ToolResult, ToolExecuteOptions, RegisteredToolDefinition, RegisterToolOptions, ModelContextLike, WebMCPApproval, WebMCPApprovalRequest, HostCode, HostEnvelope, RunStarted, RunPending, RunStatus, WebMCPOptions, WebMCPMountOptions, WebMCPHandle } from './types.js';
39
+ export type { ToolDescriptor, ToolInputSchema, ToolSchemaProperty, ToolResult, ToolExecuteOptions, RegisteredToolDefinition, RegisterToolOptions, ModelContextLike, WebMCPApproval, WebMCPApprovalRequest, HostCode, HostEnvelope, RunStarted, RunPending, RunStatus, WebMCPOptions, WebMCPMountOptions, WebMCPHandle, HostHooks, HostToolDescriptor, ToolPreview, ToolRuntime, ToolRuntimeOptions } from './types.js';
@@ -25,7 +25,9 @@
25
25
  * ```
26
26
  */
27
27
  export { attachWebMCP, detectModelContext, DEFAULT_PREFIX } from './register.js';
28
- export { buildToolDescriptors, describeCommand, EXPOSED_COMMAND_TYPES, VIEW_COMMAND_TYPES, EXCLUDED_COMMAND_TYPES, COMPOSITE_VERBS } from './descriptors.js';
28
+ export { createToolRuntime, buildHostToolDescriptors } from './runtime.js';
29
+ export { createApprovalGate, GateBusyError } from './gate.js';
30
+ export { buildToolDescriptors, describeCommand, summarizeCommands, EXPOSED_COMMAND_TYPES, VIEW_COMMAND_TYPES, EXCLUDED_COMMAND_TYPES, COMPOSITE_VERBS } from './descriptors.js';
29
31
  export { validateToolArgs, VALIDATOR_KEYWORDS } from './validate.js';
30
32
  export { ToolArgumentError } from './types.js';
31
33
  export { createFakeModelContext } from './fake.js';
@@ -1,19 +1,20 @@
1
1
  /**
2
2
  * WebMCP adapter — registration.
3
3
  *
4
- * The only file that touches the runtime (`document.modelContext`, falling
5
- * back to `navigator.modelContext`). Builds the descriptors, wraps each in an
6
- * `execute` that validates → maps to commands → gates → runs one
7
- * `executeBatch` transaction, and registers the lot under one AbortSignal so
8
- * detaching is a single `abort()`.
4
+ * The only file that touches the browser's model context
5
+ * (`document.modelContext`, falling back to `navigator.modelContext`). Builds
6
+ * a tool runtime for the instance, registers each of its tools with an
7
+ * `execute` that delegates to `runTool()`, and registers the lot under one
8
+ * AbortSignal so detaching is a single `abort()`. What a call *does* — validation, the gate, the batch —
9
+ * lives in `runtime.ts`, which the chat panel shares.
9
10
  *
10
11
  * @module webmcp/register
11
12
  */
12
13
  import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
13
- import { type ModelContextLike, type WebMCPHandle, type WebMCPOptions } from './types.js';
14
+ import type { ModelContextLike, WebMCPHandle, WebMCPOptions } from './types.js';
14
15
  export declare const DEFAULT_PREFIX = "flowdrop";
15
16
  /**
16
- * Find the WebMCP runtime on this page, or `null` when the browser has none.
17
+ * Find the WebMCP model context on this page, or `null` when the browser has none.
17
18
  * Structural: anything with a callable `registerTool` counts.
18
19
  */
19
20
  export declare function detectModelContext(): ModelContextLike | null;
@@ -21,12 +22,12 @@ export declare function detectModelContext(): ModelContextLike | null;
21
22
  * Register the editor's commands as WebMCP tools for `instance`.
22
23
  *
23
24
  * Returns `null` — with no console output — when the page has no WebMCP
24
- * runtime, so hosts can call it unconditionally. Throws when the prefix is
25
- * already registered on this runtime (two editors on one page need distinct
25
+ * model context, so hosts can call it unconditionally. Throws when the prefix is
26
+ * already registered on this model context (two editors on one page need distinct
26
27
  * prefixes).
27
28
  *
28
29
  * Registration settles asynchronously: `handle.tools` lists the tools the
29
- * runtime has accepted so far and `handle.ready` resolves when every
30
+ * model context has accepted so far and `handle.ready` resolves when every
30
31
  * registration has settled. The registration is torn down by
31
32
  * `handle.detach()` or automatically when `instance.destroy()` runs.
32
33
  */