@flowdrop/flowdrop 2.6.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 (72) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/api/enhanced-client.d.ts +29 -1
  3. package/dist/api/enhanced-client.js +83 -9
  4. package/dist/chat/commandClassifier.d.ts +2 -1
  5. package/dist/chat/commandClassifier.js +4 -1
  6. package/dist/chat/index.d.ts +5 -1
  7. package/dist/chat/index.js +2 -0
  8. package/dist/chat/toolCatalogue.d.ts +27 -0
  9. package/dist/chat/toolCatalogue.js +35 -0
  10. package/dist/chat/turnDriver.d.ts +143 -0
  11. package/dist/chat/turnDriver.js +124 -0
  12. package/dist/commands/executor.js +270 -37
  13. package/dist/commands/index.d.ts +1 -1
  14. package/dist/commands/parser.js +20 -0
  15. package/dist/commands/types.d.ts +77 -12
  16. package/dist/components/App.svelte +47 -56
  17. package/dist/components/SettingsPanel.svelte +13 -0
  18. package/dist/components/WorkflowEditor.svelte +4 -2
  19. package/dist/components/WorkflowEditor.svelte.d.ts +2 -0
  20. package/dist/components/chat/AIChatPanel.svelte +410 -22
  21. package/dist/components/console/CommandConsole.svelte +8 -0
  22. package/dist/components/console/formatters.d.ts +9 -1
  23. package/dist/components/console/formatters.js +54 -0
  24. package/dist/components/toast/DismissibleToast.svelte +53 -0
  25. package/dist/components/toast/DismissibleToast.svelte.d.ts +24 -0
  26. package/dist/components/toast/WarningIcon.svelte +28 -0
  27. package/dist/components/toast/WarningIcon.svelte.d.ts +26 -0
  28. package/dist/config/constants.d.ts +7 -3
  29. package/dist/config/constants.js +7 -3
  30. package/dist/config/endpoints.d.ts +7 -0
  31. package/dist/config/endpoints.js +2 -1
  32. package/dist/core/index.d.ts +1 -1
  33. package/dist/editor/index.d.ts +1 -1
  34. package/dist/editor/index.js +1 -1
  35. package/dist/messages/defaults.d.ts +74 -0
  36. package/dist/messages/defaults.js +35 -1
  37. package/dist/services/chatService.d.ts +21 -3
  38. package/dist/services/chatService.js +33 -1
  39. package/dist/services/globalSave.d.ts +7 -1
  40. package/dist/services/globalSave.js +20 -4
  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/stores/workflowStore.svelte.d.ts +10 -0
  46. package/dist/stores/workflowStore.svelte.js +15 -0
  47. package/dist/styles/toast.css +62 -0
  48. package/dist/styles/tokens.css +6 -0
  49. package/dist/svelte-app.d.ts +16 -4
  50. package/dist/svelte-app.js +45 -14
  51. package/dist/types/chat.d.ts +59 -0
  52. package/dist/types/events.d.ts +23 -0
  53. package/dist/types/events.js +3 -1
  54. package/dist/types/index.d.ts +49 -0
  55. package/dist/types/settings.d.ts +18 -1
  56. package/dist/types/settings.js +1 -0
  57. package/dist/webmcp/WebMCPConfirm.svelte +168 -61
  58. package/dist/webmcp/WebMCPConfirm.svelte.d.ts +14 -4
  59. package/dist/webmcp/bridge.d.ts +63 -0
  60. package/dist/webmcp/bridge.js +106 -0
  61. package/dist/webmcp/descriptors.d.ts +8 -1
  62. package/dist/webmcp/descriptors.js +108 -17
  63. package/dist/webmcp/gate.d.ts +44 -2
  64. package/dist/webmcp/gate.js +61 -10
  65. package/dist/webmcp/index.d.ts +7 -2
  66. package/dist/webmcp/index.js +4 -1
  67. package/dist/webmcp/register.d.ts +11 -10
  68. package/dist/webmcp/register.js +72 -160
  69. package/dist/webmcp/runtime.d.ts +33 -0
  70. package/dist/webmcp/runtime.js +500 -0
  71. package/dist/webmcp/types.d.ts +196 -2
  72. 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);
@@ -16,6 +16,8 @@
16
16
  type ListNodesResultData,
17
17
  type ListEdgesResultData,
18
18
  type ListTypesResultData,
19
+ type SearchTypesResultData,
20
+ type DescribeTypeResultData,
19
21
  type InfoResultData,
20
22
  type HelpResultData
21
23
  } from '../../commands/index.js';
@@ -29,6 +31,8 @@
29
31
  formatListNodes,
30
32
  formatListEdges,
31
33
  formatListTypes,
34
+ formatSearchTypes,
35
+ formatDescribeType,
32
36
  formatInfo,
33
37
  formatHelp
34
38
  } from './formatters.js';
@@ -65,6 +69,10 @@
65
69
  return formatListEdges(result.data as ListEdgesResultData);
66
70
  case 'list_types':
67
71
  return formatListTypes(result.data as ListTypesResultData);
72
+ case 'search_types':
73
+ return formatSearchTypes(result.data as SearchTypesResultData);
74
+ case 'describe_type':
75
+ return formatDescribeType(result.data as DescribeTypeResultData);
68
76
  case 'info':
69
77
  return formatInfo(result.data as InfoResultData);
70
78
  case 'help':
@@ -2,7 +2,7 @@
2
2
  * Pure formatting functions for rich command result display.
3
3
  * Converts CommandResult data into aligned table strings for console output.
4
4
  */
5
- import type { ListNodesResultData, ListEdgesResultData, ListTypesResultData, InfoResultData, HelpResultData } from '../../commands/types.js';
5
+ import type { ListNodesResultData, ListEdgesResultData, ListTypesResultData, SearchTypesResultData, DescribeTypeResultData, InfoResultData, HelpResultData } from '../../commands/types.js';
6
6
  /**
7
7
  * Formats list nodes result as an aligned table: ID, Label, Type.
8
8
  */
@@ -15,6 +15,14 @@ export declare function formatListEdges(data: ListEdgesResultData): string;
15
15
  * Formats list types result as a table: Type ID, Name, Category.
16
16
  */
17
17
  export declare function formatListTypes(data: ListTypesResultData): string;
18
+ /**
19
+ * Formats search types result: the same table as list types, or a hint.
20
+ */
21
+ export declare function formatSearchTypes(data: SearchTypesResultData): string;
22
+ /**
23
+ * Formats describe type result: header, ports and config schema sections.
24
+ */
25
+ export declare function formatDescribeType(data: DescribeTypeResultData): string;
18
26
  /**
19
27
  * Formats info result as structured output with header fields,
20
28
  * config section, ports section, and edges section.
@@ -51,6 +51,60 @@ export function formatListTypes(data) {
51
51
  const rows = data.types.map((t) => [t.typeId, t.name, t.category]);
52
52
  return formatTable(['Type ID', 'Name', 'Category'], rows);
53
53
  }
54
+ /**
55
+ * Formats search types result: the same table as list types, or a hint.
56
+ */
57
+ export function formatSearchTypes(data) {
58
+ if (data.types.length === 0) {
59
+ return `No node type matches "${data.query}"`;
60
+ }
61
+ return formatListTypes({ types: data.types });
62
+ }
63
+ /**
64
+ * Formats describe type result: header, ports and config schema sections.
65
+ */
66
+ export function formatDescribeType(data) {
67
+ const lines = [];
68
+ lines.push(`Type: ${data.typeId}`);
69
+ lines.push(`Name: ${data.name}`);
70
+ lines.push(`Category: ${data.category}`);
71
+ if (data.description)
72
+ lines.push(`Description: ${data.description}`);
73
+ if (data.tags && data.tags.length > 0)
74
+ lines.push(`Tags: ${data.tags.join(', ')}`);
75
+ if (data.confirmation)
76
+ lines.push(`Confirmation: ${data.confirmation.policy}`);
77
+ lines.push('');
78
+ lines.push('Inputs:');
79
+ if (data.inputs.length === 0)
80
+ lines.push(' (none)');
81
+ for (const p of data.inputs) {
82
+ lines.push(` ${p.portId} (${p.dataType})${p.required ? ' required' : ''}${p.description ? ` — ${p.description}` : ''}`);
83
+ }
84
+ lines.push('');
85
+ lines.push('Outputs:');
86
+ if (data.outputs.length === 0)
87
+ lines.push(' (none)');
88
+ for (const p of data.outputs) {
89
+ lines.push(` ${p.portId} (${p.dataType})${p.description ? ` — ${p.description}` : ''}`);
90
+ }
91
+ lines.push('');
92
+ lines.push('Config:');
93
+ if (data.config.length === 0)
94
+ lines.push(' (none)');
95
+ for (const c of data.config) {
96
+ const type = Array.isArray(c.type) ? c.type.join('|') : (c.type ?? 'any');
97
+ const parts = [` ${c.key} (${type})`];
98
+ if (c.required)
99
+ parts.push('required');
100
+ if (c.enum)
101
+ parts.push(`one of ${c.enum.map((v) => JSON.stringify(v)).join(', ')}`);
102
+ if (c.default !== undefined)
103
+ parts.push(`default ${JSON.stringify(c.default)}`);
104
+ lines.push(parts.join(' ') + (c.description ? ` — ${c.description}` : ''));
105
+ }
106
+ return lines.join('\n');
107
+ }
54
108
  /**
55
109
  * Formats info result as structured output with header fields,
56
110
  * config section, ports section, and edges section.