@webmcp-auto-ui/ui 2.5.31 → 2.5.33

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 (80) hide show
  1. package/package.json +15 -2
  2. package/src/agent/DiagnosticModal.svelte +126 -50
  3. package/src/agent/EphemeralBubble.svelte +13 -3
  4. package/src/agent/MCPserversList.svelte +147 -0
  5. package/src/agent/McpConnector.svelte +10 -1
  6. package/src/agent/RecipeBrowser.svelte +384 -0
  7. package/src/agent/RemoteMCPserversDemo.svelte +5 -121
  8. package/src/agent/ToolBrowser.svelte +133 -0
  9. package/src/agent/WebMCPserversList.svelte +2 -0
  10. package/src/agent/useAgentLoop.svelte.ts +396 -0
  11. package/src/base/chat-inline.svelte +64 -0
  12. package/src/base/dialog-content.svelte +3 -1
  13. package/src/components/HeaderControls.svelte +78 -0
  14. package/src/index.ts +13 -35
  15. package/src/stores/canvas.svelte.ts +0 -6
  16. package/src/widgets/SafeImage.svelte +67 -0
  17. package/src/widgets/WidgetRenderer.svelte +153 -78
  18. package/src/widgets/notebook/executors/index.ts +0 -1
  19. package/src/widgets/notebook/executors/sql.ts +32 -182
  20. package/src/widgets/notebook/import-modal-api.ts +237 -0
  21. package/src/widgets/notebook/import-modal.svelte +738 -0
  22. package/src/widgets/notebook/left-pane.ts +1 -1
  23. package/src/widgets/notebook/notebook.svelte +75 -0
  24. package/src/widgets/notebook/notebook.ts +38 -73
  25. package/src/widgets/notebook/prose.ts +6 -3
  26. package/src/widgets/notebook/shared.ts +68 -49
  27. package/src/widgets/rich/cards.svelte +74 -0
  28. package/src/widgets/rich/carousel.svelte +126 -0
  29. package/src/widgets/rich/chart-rich.svelte +221 -0
  30. package/src/widgets/rich/chat-input.svelte +52 -0
  31. package/src/widgets/rich/data-table.svelte +132 -0
  32. package/src/widgets/rich/gallery.svelte +115 -0
  33. package/src/widgets/rich/grid-data.svelte +85 -0
  34. package/src/widgets/rich/hemicycle.svelte +95 -0
  35. package/src/widgets/rich/js-sandbox.svelte +67 -0
  36. package/src/widgets/rich/json-viewer.svelte +82 -0
  37. package/src/widgets/rich/log.svelte +62 -0
  38. package/src/widgets/rich/profile.svelte +91 -0
  39. package/src/widgets/rich/sankey.svelte +73 -0
  40. package/src/widgets/rich/stat-card.svelte +60 -0
  41. package/src/widgets/rich/timeline.svelte +95 -0
  42. package/src/widgets/rich/trombinoscope.svelte +87 -0
  43. package/src/widgets/simple/actions.svelte +36 -0
  44. package/src/widgets/simple/alert.svelte +52 -0
  45. package/src/widgets/simple/chart.svelte +38 -0
  46. package/src/widgets/simple/code.svelte +30 -0
  47. package/src/widgets/simple/kv.svelte +31 -0
  48. package/src/widgets/simple/list.svelte +35 -0
  49. package/src/widgets/simple/stat.svelte +36 -0
  50. package/src/widgets/simple/tags.svelte +34 -0
  51. package/src/widgets/simple/text.svelte +130 -0
  52. package/src/widgets/helpers/safe-image.ts +0 -78
  53. package/src/widgets/notebook/import-modals.ts +0 -560
  54. package/src/widgets/notebook/recipe-browser.ts +0 -350
  55. package/src/widgets/rich/cards.ts +0 -181
  56. package/src/widgets/rich/carousel.ts +0 -319
  57. package/src/widgets/rich/chart-rich.ts +0 -386
  58. package/src/widgets/rich/d3.ts +0 -503
  59. package/src/widgets/rich/data-table.ts +0 -342
  60. package/src/widgets/rich/gallery.ts +0 -350
  61. package/src/widgets/rich/grid-data.ts +0 -173
  62. package/src/widgets/rich/hemicycle.ts +0 -313
  63. package/src/widgets/rich/js-sandbox.ts +0 -122
  64. package/src/widgets/rich/json-viewer.ts +0 -202
  65. package/src/widgets/rich/log.ts +0 -143
  66. package/src/widgets/rich/map.ts +0 -218
  67. package/src/widgets/rich/profile.ts +0 -256
  68. package/src/widgets/rich/sankey.ts +0 -257
  69. package/src/widgets/rich/stat-card.ts +0 -125
  70. package/src/widgets/rich/timeline.ts +0 -179
  71. package/src/widgets/rich/trombinoscope.ts +0 -246
  72. package/src/widgets/simple/actions.ts +0 -89
  73. package/src/widgets/simple/alert.ts +0 -100
  74. package/src/widgets/simple/chart.ts +0 -189
  75. package/src/widgets/simple/code.ts +0 -79
  76. package/src/widgets/simple/kv.ts +0 -68
  77. package/src/widgets/simple/list.ts +0 -89
  78. package/src/widgets/simple/stat.ts +0 -58
  79. package/src/widgets/simple/tags.ts +0 -125
  80. package/src/widgets/simple/text.ts +0 -198
@@ -0,0 +1,237 @@
1
+ // @ts-nocheck
2
+ // ---------------------------------------------------------------------------
3
+ // import-modal-api.ts — Imperative wrappers around <auto-import-modal>
4
+ //
5
+ // Replaces import-modals.ts. Same 4-function API:
6
+ // openAddMdModal(onPick)
7
+ // openAddRecipeModal(opts)
8
+ // openRecipeViewerModal(recipe, onInjectCell)
9
+ // openToolViewerModal(tool, onInjectCells)
10
+ // closeImportModal()
11
+ //
12
+ // Each function ensures the singleton CE is mounted, then calls openModal()
13
+ // on it. CustomEvent 'widget:interact' carries the results back.
14
+ // ---------------------------------------------------------------------------
15
+
16
+ // Side-effect import: registers <auto-import-modal> custom element
17
+ import './import-modal.svelte';
18
+
19
+ import { renderMarkdownWithInjectButtons } from './prose.js';
20
+ import { extractCellsFromRecipe, extractCellsFromTool, extractCellFromFence } from './resource-extractor.js';
21
+ import type { NotebookCell } from './shared.js';
22
+ import type { McpToolLike } from './resource-extractor.js';
23
+
24
+ // ---------------------------------------------------------------------------
25
+ // Types (defined here to avoid exporting from .svelte; consumers import from
26
+ // import-modal-api.js, not from import-modal.svelte)
27
+ // ---------------------------------------------------------------------------
28
+
29
+ export interface ImportedRecipe {
30
+ name: string;
31
+ description?: string;
32
+ body?: string;
33
+ serverName?: string;
34
+ serverUrl?: string;
35
+ originalName?: string;
36
+ id?: string;
37
+ }
38
+
39
+ export type MdSource = { kind: 'new' } | { kind: 'content'; content: string };
40
+
41
+ export interface AddRecipeModalOptions {
42
+ mcpServers?: Array<{ name: string; url?: string }>;
43
+ scope?: 'data' | 'all';
44
+ onPick: (recipe: ImportedRecipe) => void;
45
+ }
46
+
47
+ // ---------------------------------------------------------------------------
48
+ // Singleton mount
49
+ // ---------------------------------------------------------------------------
50
+
51
+ type ModalEl = HTMLElement & {
52
+ openModal(data: Record<string, unknown>): void;
53
+ closeModal(): void;
54
+ };
55
+
56
+ let _modal: ModalEl | null = null;
57
+ let _cleanup: (() => void) | null = null;
58
+
59
+ function ensureModal(): ModalEl {
60
+ if (_modal && document.contains(_modal)) return _modal;
61
+
62
+ // Register the CE if not already done (Svelte registers it on first import
63
+ // but we ensure it here for safety).
64
+ if (!customElements.get('auto-import-modal')) {
65
+ // Dynamic import triggers CE registration via Svelte's customElement decorator.
66
+ // Since this module is already bundled with the CE, it's already registered.
67
+ // If somehow not registered, fall back gracefully.
68
+ }
69
+
70
+ const el = document.createElement('auto-import-modal') as ModalEl;
71
+ document.body.appendChild(el);
72
+ _modal = el;
73
+ return el;
74
+ }
75
+
76
+ // ---------------------------------------------------------------------------
77
+ // closeImportModal — public
78
+ // ---------------------------------------------------------------------------
79
+
80
+ export function closeImportModal(): void {
81
+ _modal?.closeModal?.();
82
+ }
83
+
84
+ // ---------------------------------------------------------------------------
85
+ // openAddMdModal
86
+ // ---------------------------------------------------------------------------
87
+
88
+ export function openAddMdModal(onPick: (content: string) => void): void {
89
+ const el = ensureModal();
90
+
91
+ // Clean up previous listener
92
+ _cleanup?.();
93
+
94
+ const handler = (e: CustomEvent) => {
95
+ const { action, payload } = e.detail ?? {};
96
+ if (action === 'pick-md') {
97
+ onPick(payload as string);
98
+ }
99
+ if (action === 'pick-md' || action === 'close') {
100
+ el.removeEventListener('widget:interact', handler as EventListener);
101
+ _cleanup = null;
102
+ }
103
+ };
104
+
105
+ el.addEventListener('widget:interact', handler as EventListener);
106
+ _cleanup = () => el.removeEventListener('widget:interact', handler as EventListener);
107
+
108
+ el.openModal({ mode: 'add-md' });
109
+ }
110
+
111
+ // ---------------------------------------------------------------------------
112
+ // openAddRecipeModal
113
+ // ---------------------------------------------------------------------------
114
+
115
+ export function openAddRecipeModal(opts: AddRecipeModalOptions): void {
116
+ const el = ensureModal();
117
+
118
+ _cleanup?.();
119
+
120
+ const handler = (e: CustomEvent) => {
121
+ const { action, payload } = e.detail ?? {};
122
+ if (action === 'pick-recipe') {
123
+ opts.onPick(payload as ImportedRecipe);
124
+ }
125
+ if (action === 'pick-recipe' || action === 'close') {
126
+ el.removeEventListener('widget:interact', handler as EventListener);
127
+ _cleanup = null;
128
+ }
129
+ };
130
+
131
+ el.addEventListener('widget:interact', handler as EventListener);
132
+ _cleanup = () => el.removeEventListener('widget:interact', handler as EventListener);
133
+
134
+ el.openModal({
135
+ mode: 'add-recipe',
136
+ mcpServers: opts.mcpServers,
137
+ scope: opts.scope,
138
+ });
139
+ }
140
+
141
+ // ---------------------------------------------------------------------------
142
+ // openRecipeViewerModal
143
+ // ---------------------------------------------------------------------------
144
+
145
+ export function openRecipeViewerModal(
146
+ recipe: ImportedRecipe,
147
+ onInjectCell: (cell: NotebookCell) => void,
148
+ ): void {
149
+ const el = ensureModal();
150
+
151
+ _cleanup?.();
152
+
153
+ // We'll hold a reference to the prose renderer's destroy fn.
154
+ let proseDestroy: (() => void) | null = null;
155
+
156
+ const handler = (e: CustomEvent) => {
157
+ const { action, payload } = e.detail ?? {};
158
+
159
+ if (action === 'inject-fence') {
160
+ const { lang, content } = payload as { lang: string; content: string };
161
+ const cell = extractCellFromFence(lang, content);
162
+ onInjectCell(cell);
163
+ }
164
+
165
+ if (action === 'inject-all') {
166
+ const cells = extractCellsFromRecipe(recipe.body ?? '', {
167
+ title: recipe.name,
168
+ description: recipe.description,
169
+ });
170
+ for (const c of cells) onInjectCell(c);
171
+ }
172
+
173
+ if (action === 'inject-all' || action === 'close') {
174
+ el.removeEventListener('widget:interact', handler as EventListener);
175
+ proseDestroy?.();
176
+ proseDestroy = null;
177
+ _cleanup = null;
178
+ }
179
+ };
180
+
181
+ el.addEventListener('widget:interact', handler as EventListener);
182
+ _cleanup = () => {
183
+ el.removeEventListener('widget:interact', handler as EventListener);
184
+ proseDestroy?.();
185
+ proseDestroy = null;
186
+ };
187
+
188
+ el.openModal({ mode: 'recipe-viewer', recipe });
189
+
190
+ // After the CE opens, inject the rendered markdown into [data-role="render"].
191
+ // requestAnimationFrame ensures Svelte has rendered the modal DOM.
192
+ requestAnimationFrame(() => {
193
+ const renderTarget = el.querySelector('[data-role="render"]') as HTMLElement | null;
194
+ if (!renderTarget) return;
195
+ const { root, destroy } = renderMarkdownWithInjectButtons(
196
+ recipe.body ?? '',
197
+ ({ lang, content }) => {
198
+ const cell = extractCellFromFence(lang, content);
199
+ onInjectCell(cell);
200
+ },
201
+ );
202
+ renderTarget.appendChild(root);
203
+ proseDestroy = destroy;
204
+ });
205
+ }
206
+
207
+ // ---------------------------------------------------------------------------
208
+ // openToolViewerModal
209
+ // ---------------------------------------------------------------------------
210
+
211
+ export function openToolViewerModal(
212
+ tool: McpToolLike,
213
+ onInjectCells: (cells: NotebookCell[]) => void,
214
+ ): void {
215
+ const el = ensureModal();
216
+
217
+ _cleanup?.();
218
+
219
+ const handler = (e: CustomEvent) => {
220
+ const { action } = e.detail ?? {};
221
+
222
+ if (action === 'inject-tool') {
223
+ const cells = extractCellsFromTool(tool);
224
+ onInjectCells(cells);
225
+ }
226
+
227
+ if (action === 'inject-tool' || action === 'close') {
228
+ el.removeEventListener('widget:interact', handler as EventListener);
229
+ _cleanup = null;
230
+ }
231
+ };
232
+
233
+ el.addEventListener('widget:interact', handler as EventListener);
234
+ _cleanup = () => el.removeEventListener('widget:interact', handler as EventListener);
235
+
236
+ el.openModal({ mode: 'tool-viewer', tool });
237
+ }