@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
@@ -17,11 +17,17 @@
17
17
  type BatchOutcome,
18
18
  type ParseFailure
19
19
  } from '../../chat/batchFeedback.js';
20
+ import { toToolDefinitions } from '../../chat/toolCatalogue.js';
21
+ import { runTurn, type TurnEvent } from '../../chat/turnDriver.js';
22
+ import type { ToolPreview, ToolRuntime } from '../../webmcp/types.js';
23
+ // Pure describers, no DOM: safe in the editor's static graph. The runtime
24
+ // itself (dialog included) stays behind a dynamic import in ensureRuntime.
25
+ import { describeCommand, summarizeCommands } from '../../webmcp/descriptors.js';
20
26
  import CommandPreview from './CommandPreview.svelte';
21
27
  import MarkdownDisplay from '../MarkdownDisplay.svelte';
22
- import { tick } from 'svelte';
28
+ import { onDestroy, tick } from 'svelte';
23
29
  import Icon from '@iconify/svelte';
24
- import { m } from '../../messages/index.js';
30
+ import { getMessages, m } from '../../messages/index.js';
25
31
 
26
32
  // =========================================================================
27
33
  // Internal Display Message Type
@@ -44,6 +50,20 @@
44
50
  readOnlyResults?: string[];
45
51
  /** Set when the user dismissed this message's command preview */
46
52
  commandsDismissed?: boolean;
53
+ /** Tools mode: one compact status line per tool call of this turn */
54
+ toolLines?: ToolLine[];
55
+ /** Set on the assistant placeholder while its reply is still coming */
56
+ inProgress?: boolean;
57
+ /** Tools mode: a muted notice (legacy fallback, abort) rather than a reply */
58
+ notice?: boolean;
59
+ /** Tools mode: a deterministic warning under the reply, e.g. tool calls failed this turn */
60
+ warning?: string;
61
+ }
62
+
63
+ /** One tool call as the transcript shows it: what ran and how it ended. */
64
+ interface ToolLine {
65
+ status: 'running' | 'ok' | 'rejected' | 'failed' | 'note';
66
+ text: string;
47
67
  }
48
68
 
49
69
  interface Props {
@@ -57,6 +77,10 @@
57
77
 
58
78
  const fd = getInstance();
59
79
 
80
+ // The messages getter, read once at init: the tool runtime's dialog mounts
81
+ // outside this component tree and must not touch Svelte context at call time.
82
+ const messages = getMessages();
83
+
60
84
  // Hoist the chat branch — read in placeholder, header, three welcome states,
61
85
  // auto-retry banner, and the send button aria-label.
62
86
  const t = $derived(m().chat);
@@ -74,6 +98,55 @@
74
98
  let messagesElement: HTMLDivElement | undefined = $state();
75
99
  let autoRetryCount = 0;
76
100
 
101
+ // ---- tools mode -----------------------------------------------------------
102
+
103
+ /**
104
+ * Set once the first response of the session came from a server without
105
+ * tool-calling turns (no `turnId`). The session then stays in the text mode;
106
+ * a reload tries tools again.
107
+ */
108
+ let legacyFallback: boolean = $state(false);
109
+ let runtime: ToolRuntime | null = null;
110
+ /** True when this panel created `fd.approvalGate`, so only then may it clear it. */
111
+ let publishedGate = false;
112
+ /** Set on unmount; a turn still in flight releases the runtime when it ends. */
113
+ let destroyed = false;
114
+
115
+ /**
116
+ * Whether this turn drives tools. The setting asks for it, the backend
117
+ * declares the tool-results door, and no earlier reply proved it legacy.
118
+ */
119
+ const toolsMode = $derived(
120
+ getBehaviorSettings().chatMode === 'tools' &&
121
+ chatService.supportsToolTurns(endpointConfig ?? null) &&
122
+ !legacyFallback
123
+ );
124
+
125
+ /**
126
+ * Let go of the runtime. The gate is cleared from the instance only when this
127
+ * panel published it — the registration's gate is the registration's to
128
+ * clear, and taking it away would leave the next panel building a second one.
129
+ */
130
+ function releaseRuntime(): void {
131
+ if (!runtime) return;
132
+ if (publishedGate && fd.approvalGate === runtime.gate) fd.approvalGate = null;
133
+ publishedGate = false;
134
+ runtime.dispose();
135
+ runtime = null;
136
+ }
137
+
138
+ onDestroy(() => {
139
+ destroyed = true;
140
+ // Unpublish at once so a panel mounted after us builds its own gate; but a
141
+ // turn still running keeps its runtime, or the rest of its calls would
142
+ // answer DETACHED to a model that can see the editor is fine.
143
+ if (runtime && publishedGate && fd.approvalGate === runtime.gate) {
144
+ fd.approvalGate = null;
145
+ publishedGate = false;
146
+ }
147
+ if (!isLoading) releaseRuntime();
148
+ });
149
+
77
150
  // =========================================================================
78
151
  // Derived State
79
152
  // =========================================================================
@@ -89,8 +162,10 @@
89
162
  // =========================================================================
90
163
 
91
164
  $effect(() => {
92
- // Read scroll-relevant state so the effect re-runs when messages change
93
- const _deps = [displayMessages.length, isLoading];
165
+ // Read scroll-relevant state so the effect re-runs when messages change —
166
+ // including the tool trace and reply growing on the last message.
167
+ const last = displayMessages[displayMessages.length - 1];
168
+ const _deps = [displayMessages.length, isLoading, last?.toolLines?.length, last?.content];
94
169
  tick().then(() => {
95
170
  if (messagesElement) {
96
171
  messagesElement.scrollTop = messagesElement.scrollHeight;
@@ -136,6 +211,199 @@
136
211
  return createStoreCommandContext(nodeTypes, onUIAction, fd);
137
212
  }
138
213
 
214
+ // =========================================================================
215
+ // Tools mode
216
+ // =========================================================================
217
+
218
+ /**
219
+ * The tool runtime for this panel: the same `runTool()` the WebMCP
220
+ * registration uses, with this editor's host hooks (`fd.host`) behind
221
+ * `save` / `run` / `run_status`. The gate is the editor's one shared gate
222
+ * (`fd.approvalGate`): reused when the registration published it first,
223
+ * published by us otherwise, so one "don't ask again" covers both surfaces
224
+ * and two dialogs never stack. Only the dialog title is ours — it is the
225
+ * assistant asking, not an unknown agent on the page. Loaded on demand so
226
+ * the adapter stays out of the editor's static graph.
227
+ */
228
+ async function ensureRuntime(): Promise<ToolRuntime> {
229
+ if (runtime && !runtime.disposed) return runtime;
230
+ const { createToolRuntime } = await import('../../webmcp/index.js');
231
+ const shared = fd.approvalGate;
232
+ runtime = createToolRuntime({
233
+ instance: fd,
234
+ nodeTypes: () => nodeTypes,
235
+ onUIAction,
236
+ hooks: fd.host.current,
237
+ gate: shared ?? undefined,
238
+ approval: 'confirm',
239
+ messages,
240
+ dialogTitle: (name) => messages().chat.tools.confirmTitle({ name })
241
+ });
242
+ if (!shared) {
243
+ fd.approvalGate = runtime.gate;
244
+ publishedGate = true;
245
+ }
246
+ return runtime;
247
+ }
248
+
249
+ /** Primitive argument values of a call, for a status line: `describe_type http_request`. */
250
+ function argsDetail(args: Record<string, unknown>): string {
251
+ const parts: string[] = [];
252
+ for (const value of Object.values(args)) {
253
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
254
+ parts.push(String(value));
255
+ }
256
+ }
257
+ const text = parts.join(' ');
258
+ return text.length > 60 ? `${text.slice(0, 57)}…` : text;
259
+ }
260
+
261
+ /**
262
+ * What a call changed, for the transcript, in the dialog's own words: the
263
+ * batch summary for several commands, the one-line description for one,
264
+ * the host's message for `save` / `run` / `run_status`.
265
+ */
266
+ function appliedDetail(preview: ToolPreview | null, outcome: { message?: string }): string {
267
+ if (preview && preview.commands.length > 0) {
268
+ if (preview.commands.length === 1) return describeCommand(preview.commands[0]);
269
+ return summarizeCommands(preview.commands, messages().webmcp) ?? '';
270
+ }
271
+ return outcome.message ?? '';
272
+ }
273
+
274
+ function lastLine(msg: DisplayMessage): ToolLine | undefined {
275
+ return msg.toolLines?.[msg.toolLines.length - 1];
276
+ }
277
+
278
+ /**
279
+ * Render a driver event onto the in-progress assistant message. Synchronous
280
+ * on purpose: events arrive in order and land in order.
281
+ */
282
+ function renderEvent(msg: DisplayMessage, event: TurnEvent): void {
283
+ const tt = t.tools;
284
+ switch (event.type) {
285
+ case 'note':
286
+ msg.toolLines?.push({ status: 'note', text: event.content });
287
+ break;
288
+ case 'reading':
289
+ msg.toolLines?.push({
290
+ status: 'running',
291
+ text: tt.reading({ tool: event.call.name, detail: argsDetail(event.call.args) })
292
+ });
293
+ break;
294
+ case 'awaiting-approval':
295
+ msg.toolLines?.push({
296
+ status: 'running',
297
+ text: tt.awaitingApproval({ tool: event.call.name })
298
+ });
299
+ break;
300
+ case 'applied': {
301
+ const line = lastLine(msg);
302
+ if (line) {
303
+ line.status = 'ok';
304
+ line.text = event.preview?.mutating
305
+ ? tt.applied({
306
+ tool: event.call.name,
307
+ detail: appliedDetail(event.preview, event.outcome)
308
+ })
309
+ : tt.read({ tool: event.call.name, detail: argsDetail(event.call.args) });
310
+ }
311
+ break;
312
+ }
313
+ case 'rejected': {
314
+ const line = lastLine(msg);
315
+ if (line) {
316
+ line.status = 'rejected';
317
+ line.text = tt.rejected({ tool: event.call.name });
318
+ }
319
+ break;
320
+ }
321
+ case 'failed': {
322
+ const line = lastLine(msg);
323
+ if (line) {
324
+ line.status = 'failed';
325
+ line.text = tt.failed({
326
+ tool: event.call.name,
327
+ error: event.outcome.error ?? event.outcome.code ?? 'error'
328
+ });
329
+ }
330
+ break;
331
+ }
332
+ case 'round-complete':
333
+ case 'final':
334
+ break;
335
+ }
336
+ }
337
+
338
+ /** One user message as a tool-calling turn. */
339
+ async function sendToolTurn(text: string): Promise<void> {
340
+ displayMessages.push({ role: 'user', content: text });
341
+ isLoading = true;
342
+
343
+ const progress: DisplayMessage = {
344
+ role: 'assistant',
345
+ content: '',
346
+ toolLines: [],
347
+ inProgress: true
348
+ };
349
+ displayMessages.push(progress);
350
+ // The pushed object is proxied by the state array; mutate the proxy.
351
+ const msg = displayMessages[displayMessages.length - 1];
352
+
353
+ try {
354
+ const rt = await ensureRuntime();
355
+ const history = getHistory();
356
+ const outcome = await runTurn(
357
+ {
358
+ message: text,
359
+ workflowState: getWorkflowState(),
360
+ history: history.slice(0, -2), // all except this message and the placeholder
361
+ tools: toToolDefinitions(rt)
362
+ },
363
+ {
364
+ send: (request) =>
365
+ chatService.sendMessage(fd.api.config, workflowId ?? '', request, fd.api.authProvider),
366
+ sendToolResults: (turnId, request) =>
367
+ chatService.sendToolResults(
368
+ fd.api.config,
369
+ workflowId ?? '',
370
+ turnId,
371
+ request,
372
+ fd.api.authProvider
373
+ ),
374
+ runTool: (name, input) => rt.runTool(name, input),
375
+ preview: (name, input) => rt.preview(name, input),
376
+ onEvent: (event) => renderEvent(msg, event)
377
+ }
378
+ );
379
+
380
+ if (outcome.kind === 'legacy') {
381
+ // An older server: keep its reply, and stay in the text mode from now on.
382
+ legacyFallback = true;
383
+ displayMessages.splice(displayMessages.length - 1, 1);
384
+ displayMessages.push({ role: 'assistant', content: t.tools.legacyFallback, notice: true });
385
+ displayMessages.push(processResponse(outcome.content));
386
+ return;
387
+ }
388
+ if (outcome.kind === 'aborted') {
389
+ msg.content = t.tools.aborted({ reason: outcome.reason });
390
+ } else {
391
+ msg.content = outcome.content;
392
+ if (outcome.failed > 0) {
393
+ msg.warning = t.tools.failedSummary({ count: outcome.failed });
394
+ }
395
+ }
396
+ if ((msg.toolLines?.length ?? 0) === 0) msg.toolLines = undefined;
397
+ } catch (err) {
398
+ msg.content = `Error: ${err instanceof Error ? err.message : 'Failed to send message'}`;
399
+ } finally {
400
+ msg.inProgress = false;
401
+ isLoading = false;
402
+ if (destroyed) releaseRuntime();
403
+ else tick().then(() => inputElement?.focus());
404
+ }
405
+ }
406
+
139
407
  // =========================================================================
140
408
  // Command Execution
141
409
  // =========================================================================
@@ -397,12 +665,21 @@
397
665
  displayMessages.push({ role: 'user', content: text, retryAttempt });
398
666
  isLoading = true;
399
667
 
668
+ // The reply's place in the log, shown as thinking until it arrives — the
669
+ // same placeholder the tools mode uses, so there is one spinner.
670
+ const placeholderIndex =
671
+ displayMessages.push({
672
+ role: 'assistant',
673
+ content: '',
674
+ inProgress: true
675
+ }) - 1;
676
+
400
677
  try {
401
678
  const history = getHistory();
402
679
  const request: ChatRequest = {
403
680
  message: text,
404
681
  workflowState: getWorkflowState(),
405
- history: history.slice(0, -1) // all except current message
682
+ history: history.slice(0, -2) // all except this message and the placeholder
406
683
  };
407
684
 
408
685
  const response = await chatService.sendMessage(
@@ -411,14 +688,13 @@
411
688
  request,
412
689
  fd.api.authProvider
413
690
  );
414
- const displayMsg = processResponse(response.content);
415
- displayMessages.push(displayMsg);
691
+ displayMessages[placeholderIndex] = processResponse(response.content);
416
692
  } catch (err) {
417
693
  const errorMessage = err instanceof Error ? err.message : 'Failed to send message';
418
- displayMessages.push({
694
+ displayMessages[placeholderIndex] = {
419
695
  role: 'assistant',
420
696
  content: `Error: ${errorMessage}`
421
- });
697
+ };
422
698
  } finally {
423
699
  isLoading = false;
424
700
  tick().then(() => inputElement?.focus());
@@ -430,7 +706,11 @@
430
706
  if (!text || isLoading || !workflowId) return;
431
707
  inputValue = '';
432
708
  autoRetryCount = 0;
433
- await sendMessageInternal(text);
709
+ if (toolsMode) {
710
+ await sendToolTurn(text);
711
+ } else {
712
+ await sendMessageInternal(text);
713
+ }
434
714
  }
435
715
 
436
716
  function handleKeydown(event: KeyboardEvent) {
@@ -468,21 +748,62 @@
468
748
  {#if message.retryAttempt !== undefined}
469
749
  <div
470
750
  class="ai-chat-panel__retry-notice"
471
- class:ai-chat-panel__retry-notice--active={isLoading &&
472
- msgIndex === displayMessages.length - 1}
751
+ class:ai-chat-panel__retry-notice--active={displayMessages[msgIndex + 1]?.inProgress}
473
752
  >
474
753
  <Icon icon="mdi:autorenew" />
475
754
  <span>{t.autoRetry({ attempt: message.retryAttempt, max: MAX_AUTO_RETRIES })}</span>
476
755
  </div>
477
756
  {:else}
478
- <div class="ai-chat-panel__bubble ai-chat-panel__bubble--{message.role}">
757
+ <div
758
+ class="ai-chat-panel__bubble ai-chat-panel__bubble--{message.role}"
759
+ class:ai-chat-panel__bubble--notice={message.notice}
760
+ >
761
+ {#if message.toolLines && message.toolLines.length > 0}
762
+ <ul
763
+ class="ai-chat-panel__tool-lines"
764
+ aria-label={t.tools.rounds({ count: message.toolLines.length })}
765
+ >
766
+ {#each message.toolLines as line (line)}
767
+ <li class="ai-chat-panel__tool-line ai-chat-panel__tool-line--{line.status}">
768
+ {#if line.status === 'running'}
769
+ <Icon icon="mdi:loading" class="ai-chat-panel__tool-line-spin" />
770
+ {:else if line.status === 'ok'}
771
+ <Icon icon="mdi:check" />
772
+ {:else if line.status === 'rejected'}
773
+ <Icon icon="mdi:cancel" />
774
+ {:else if line.status === 'note'}
775
+ <Icon icon="mdi:comment-text-outline" />
776
+ {:else}
777
+ <Icon icon="mdi:alert-circle-outline" />
778
+ {/if}
779
+ <span>{line.text}</span>
780
+ </li>
781
+ {/each}
782
+ </ul>
783
+ {/if}
479
784
  {#if message.role === 'user'}
480
785
  <div class="ai-chat-panel__bubble-content">{message.content}</div>
786
+ {:else if message.inProgress && !message.content}
787
+ <div class="ai-chat-panel__thinking">
788
+ <span class="ai-chat-panel__dot"></span>
789
+ <span class="ai-chat-panel__dot"></span>
790
+ <span class="ai-chat-panel__dot"></span>
791
+ </div>
792
+ {:else if message.notice}
793
+ <div class="ai-chat-panel__bubble-content ai-chat-panel__notice-text">
794
+ {message.content}
795
+ </div>
481
796
  {:else}
482
797
  <div class="ai-chat-panel__bubble-content">
483
798
  <MarkdownDisplay content={message.content} />
484
799
  </div>
485
800
  {/if}
801
+ {#if message.warning}
802
+ <div class="ai-chat-panel__turn-warning" role="status">
803
+ <Icon icon="mdi:alert-circle-outline" />
804
+ <span>{message.warning}</span>
805
+ </div>
806
+ {/if}
486
807
  {#if message.readOnlyResults && message.readOnlyResults.length > 0}
487
808
  <div class="ai-chat-panel__readonly-results">
488
809
  {#each message.readOnlyResults as result, i (i)}
@@ -502,15 +823,6 @@
502
823
  </div>
503
824
  {/if}
504
825
  {/each}
505
- {#if isLoading}
506
- <div class="ai-chat-panel__bubble ai-chat-panel__bubble--assistant">
507
- <div class="ai-chat-panel__thinking">
508
- <span class="ai-chat-panel__dot"></span>
509
- <span class="ai-chat-panel__dot"></span>
510
- <span class="ai-chat-panel__dot"></span>
511
- </div>
512
- </div>
513
- {/if}
514
826
  </div>
515
827
 
516
828
  <!-- Input area -->
@@ -722,6 +1034,82 @@
722
1034
  font-style: italic;
723
1035
  }
724
1036
 
1037
+ /* Tools mode: one status line per tool call */
1038
+ .ai-chat-panel__tool-lines {
1039
+ list-style: none;
1040
+ margin: 0 0 var(--fd-space-3xs);
1041
+ padding: 0;
1042
+ display: flex;
1043
+ flex-direction: column;
1044
+ gap: 2px;
1045
+ }
1046
+
1047
+ .ai-chat-panel__tool-line {
1048
+ display: flex;
1049
+ align-items: flex-start;
1050
+ gap: var(--fd-space-3xs);
1051
+ font-size: var(--fd-text-xs);
1052
+ color: var(--fd-muted-foreground);
1053
+ line-height: 1.4;
1054
+ }
1055
+
1056
+ .ai-chat-panel__tool-line :global(svg) {
1057
+ flex-shrink: 0;
1058
+ font-size: 0.9rem;
1059
+ margin-top: 0.1em;
1060
+ }
1061
+
1062
+ .ai-chat-panel__tool-line--ok :global(svg) {
1063
+ color: var(--fd-success, var(--fd-primary));
1064
+ }
1065
+
1066
+ .ai-chat-panel__tool-line--rejected,
1067
+ .ai-chat-panel__tool-line--failed {
1068
+ color: var(--fd-destructive, var(--fd-foreground));
1069
+ }
1070
+
1071
+ .ai-chat-panel__tool-line :global(.ai-chat-panel__tool-line-spin) {
1072
+ animation: spin 1s linear infinite;
1073
+ }
1074
+
1075
+ .ai-chat-panel__tool-line--note {
1076
+ color: var(--fd-foreground);
1077
+ font-style: italic;
1078
+ white-space: pre-wrap;
1079
+ }
1080
+
1081
+ .ai-chat-panel__tool-line--note :global(svg) {
1082
+ color: var(--fd-muted-foreground);
1083
+ }
1084
+
1085
+ /* Deterministic warning under the reply (e.g. tool calls failed this turn) */
1086
+ .ai-chat-panel__turn-warning {
1087
+ display: flex;
1088
+ align-items: center;
1089
+ gap: var(--fd-space-3xs);
1090
+ margin-top: var(--fd-space-3xs);
1091
+ font-size: var(--fd-text-xs);
1092
+ color: var(--fd-destructive, var(--fd-foreground));
1093
+ }
1094
+
1095
+ .ai-chat-panel__turn-warning :global(svg) {
1096
+ flex-shrink: 0;
1097
+ }
1098
+
1099
+ /* Notices (legacy fallback, aborted turn) */
1100
+ .ai-chat-panel__bubble--notice {
1101
+ max-width: 100%;
1102
+ align-self: center;
1103
+ }
1104
+
1105
+ .ai-chat-panel__bubble--notice .ai-chat-panel__notice-text {
1106
+ background: none;
1107
+ color: var(--fd-muted-foreground);
1108
+ font-size: var(--fd-text-xs);
1109
+ text-align: center;
1110
+ opacity: 0.8;
1111
+ }
1112
+
725
1113
  /* Read-only command results */
726
1114
  .ai-chat-panel__readonly-results {
727
1115
  margin-top: var(--fd-space-xs);
@@ -0,0 +1,53 @@
1
+ <script lang="ts">
2
+ /**
3
+ * Toast body with a close button.
4
+ *
5
+ * svelte-5-french-toast renders a component message as
6
+ * `<toast.message {toast} {...toast.props} />`, so this receives the live
7
+ * toast (for its id) plus the props the service passes. Used for errors and
8
+ * warnings, which stay on screen until the user dismisses them: a refusal
9
+ * the user has to act on must not vanish mid-read.
10
+ *
11
+ * `details` are the server's reasons behind the headline (ApiError.details);
12
+ * they render as a list rather than being joined into the headline.
13
+ * The list is keyed by index on purpose: two reasons may share their
14
+ * wording, and keying on the text throws `each_key_duplicate` — in
15
+ * production too. The list never changes for the life of a toast.
16
+ */
17
+ import { toast as toastApi, type Toast } from 'svelte-5-french-toast';
18
+
19
+ interface Props {
20
+ toast: Toast;
21
+ text: string;
22
+ details?: readonly string[];
23
+ }
24
+
25
+ let { toast, text, details = [] }: Props = $props();
26
+ </script>
27
+
28
+ <div class="flowdrop-toast-text">
29
+ <p class="flowdrop-toast-headline">{text}</p>
30
+ {#if details.length}
31
+ <ul class="flowdrop-toast-details">
32
+ {#each details as detail, i (i)}
33
+ <li>{detail}</li>
34
+ {/each}
35
+ </ul>
36
+ {/if}
37
+ </div>
38
+ <button
39
+ type="button"
40
+ class="flowdrop-toast-close"
41
+ aria-label="Dismiss"
42
+ onclick={() => toastApi.dismiss(toast.id)}
43
+ >
44
+ <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" focusable="false">
45
+ <path
46
+ d="M4 4l8 8M12 4l-8 8"
47
+ stroke="currentColor"
48
+ stroke-width="1.75"
49
+ stroke-linecap="round"
50
+ fill="none"
51
+ />
52
+ </svg>
53
+ </button>
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Toast body with a close button.
3
+ *
4
+ * svelte-5-french-toast renders a component message as
5
+ * `<toast.message {toast} {...toast.props} />`, so this receives the live
6
+ * toast (for its id) plus the props the service passes. Used for errors and
7
+ * warnings, which stay on screen until the user dismisses them: a refusal
8
+ * the user has to act on must not vanish mid-read.
9
+ *
10
+ * `details` are the server's reasons behind the headline (ApiError.details);
11
+ * they render as a list rather than being joined into the headline.
12
+ * The list is keyed by index on purpose: two reasons may share their
13
+ * wording, and keying on the text throws `each_key_duplicate` — in
14
+ * production too. The list never changes for the life of a toast.
15
+ */
16
+ import { type Toast } from 'svelte-5-french-toast';
17
+ interface Props {
18
+ toast: Toast;
19
+ text: string;
20
+ details?: readonly string[];
21
+ }
22
+ declare const DismissibleToast: import("svelte").Component<Props, {}, "">;
23
+ type DismissibleToast = ReturnType<typeof DismissibleToast>;
24
+ export default DismissibleToast;
@@ -0,0 +1,28 @@
1
+ <!--
2
+ Warning glyph for toasts. The library only ships success/error/loading
3
+ icons, so a warning would otherwise wear the error icon and be
4
+ indistinguishable from one.
5
+ -->
6
+ <svg
7
+ class="flowdrop-toast-warning-icon"
8
+ viewBox="0 0 20 20"
9
+ width="20"
10
+ height="20"
11
+ aria-hidden="true"
12
+ focusable="false"
13
+ >
14
+ <path
15
+ d="M10 2.5 18.5 17H1.5L10 2.5Z"
16
+ fill="var(--fd-warning, #f59e0b)"
17
+ stroke="var(--fd-warning, #f59e0b)"
18
+ stroke-width="1.5"
19
+ stroke-linejoin="round"
20
+ />
21
+ <path
22
+ d="M10 8v4.5"
23
+ stroke="var(--fd-warning-foreground, #fff)"
24
+ stroke-width="1.75"
25
+ stroke-linecap="round"
26
+ />
27
+ <circle cx="10" cy="14.75" r="1" fill="var(--fd-warning-foreground, #fff)" />
28
+ </svg>
@@ -0,0 +1,26 @@
1
+ export default WarningIcon;
2
+ type WarningIcon = SvelteComponent<{
3
+ [x: string]: never;
4
+ }, {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> & {
7
+ $$bindings?: string | undefined;
8
+ };
9
+ declare const WarningIcon: $$__sveltets_2_IsomorphicComponent<{
10
+ [x: string]: never;
11
+ }, {
12
+ [evt: string]: CustomEvent<any>;
13
+ }, {}, {}, string>;
14
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
+ $$bindings?: Bindings;
17
+ } & Exports;
18
+ (internal: unknown, props: {
19
+ $$events?: Events;
20
+ $$slots?: Slots;
21
+ }): Exports & {
22
+ $set?: any;
23
+ $on?: any;
24
+ };
25
+ z_$$bindings?: Bindings;
26
+ }
@@ -41,11 +41,15 @@ export declare const EDGE_MARKER_SIZES: {
41
41
  readonly height: 16;
42
42
  };
43
43
  };
44
- /** Toast notification durations in milliseconds */
44
+ /**
45
+ * How long each kind of toast stays, in milliseconds. `Infinity` means it
46
+ * stays until the user closes it: errors and warnings name something to act
47
+ * on, and a message that vanishes mid-read was never delivered.
48
+ */
45
49
  export declare const TOAST_DURATION: {
46
50
  readonly SUCCESS: 4000;
47
- readonly ERROR: 6000;
48
- readonly WARNING: 5000;
51
+ readonly ERROR: number;
52
+ readonly WARNING: number;
49
53
  readonly INFO: 4000;
50
54
  readonly CONFIRMATION: 5000;
51
55
  };