@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.
- package/CHANGELOG.md +56 -0
- package/dist/api/enhanced-client.d.ts +29 -1
- package/dist/api/enhanced-client.js +83 -9
- package/dist/chat/commandClassifier.d.ts +2 -1
- package/dist/chat/commandClassifier.js +4 -1
- package/dist/chat/index.d.ts +5 -1
- package/dist/chat/index.js +2 -0
- package/dist/chat/toolCatalogue.d.ts +27 -0
- package/dist/chat/toolCatalogue.js +35 -0
- package/dist/chat/turnDriver.d.ts +143 -0
- package/dist/chat/turnDriver.js +124 -0
- package/dist/commands/executor.js +270 -37
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/parser.js +20 -0
- package/dist/commands/types.d.ts +77 -12
- package/dist/components/App.svelte +47 -56
- package/dist/components/SettingsPanel.svelte +13 -0
- package/dist/components/WorkflowEditor.svelte +4 -2
- package/dist/components/WorkflowEditor.svelte.d.ts +2 -0
- package/dist/components/chat/AIChatPanel.svelte +410 -22
- package/dist/components/console/CommandConsole.svelte +8 -0
- package/dist/components/console/formatters.d.ts +9 -1
- package/dist/components/console/formatters.js +54 -0
- package/dist/components/toast/DismissibleToast.svelte +53 -0
- package/dist/components/toast/DismissibleToast.svelte.d.ts +24 -0
- package/dist/components/toast/WarningIcon.svelte +28 -0
- package/dist/components/toast/WarningIcon.svelte.d.ts +26 -0
- package/dist/config/constants.d.ts +7 -3
- package/dist/config/constants.js +7 -3
- package/dist/config/endpoints.d.ts +7 -0
- package/dist/config/endpoints.js +2 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +1 -1
- package/dist/messages/defaults.d.ts +74 -0
- package/dist/messages/defaults.js +35 -1
- package/dist/services/chatService.d.ts +21 -3
- package/dist/services/chatService.js +33 -1
- package/dist/services/globalSave.d.ts +7 -1
- package/dist/services/globalSave.js +20 -4
- package/dist/services/toastService.d.ts +23 -2
- package/dist/services/toastService.js +72 -28
- package/dist/stores/instanceContainer.svelte.d.ts +34 -0
- package/dist/stores/instanceContainer.svelte.js +30 -0
- package/dist/stores/workflowStore.svelte.d.ts +10 -0
- package/dist/stores/workflowStore.svelte.js +15 -0
- package/dist/styles/toast.css +62 -0
- package/dist/styles/tokens.css +6 -0
- package/dist/svelte-app.d.ts +16 -4
- package/dist/svelte-app.js +45 -14
- package/dist/types/chat.d.ts +59 -0
- package/dist/types/events.d.ts +23 -0
- package/dist/types/events.js +3 -1
- package/dist/types/index.d.ts +49 -0
- package/dist/types/settings.d.ts +18 -1
- package/dist/types/settings.js +1 -0
- package/dist/webmcp/WebMCPConfirm.svelte +168 -61
- package/dist/webmcp/WebMCPConfirm.svelte.d.ts +14 -4
- package/dist/webmcp/bridge.d.ts +63 -0
- package/dist/webmcp/bridge.js +106 -0
- package/dist/webmcp/descriptors.d.ts +8 -1
- package/dist/webmcp/descriptors.js +108 -17
- package/dist/webmcp/gate.d.ts +44 -2
- package/dist/webmcp/gate.js +61 -10
- package/dist/webmcp/index.d.ts +7 -2
- package/dist/webmcp/index.js +4 -1
- package/dist/webmcp/register.d.ts +11 -10
- package/dist/webmcp/register.js +72 -160
- package/dist/webmcp/runtime.d.ts +33 -0
- package/dist/webmcp/runtime.js +500 -0
- package/dist/webmcp/types.d.ts +196 -2
- package/package.json +1 -1
|
@@ -5,6 +5,18 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { toast } from 'svelte-5-french-toast';
|
|
7
7
|
import { TOAST_DURATION } from '../config/constants.js';
|
|
8
|
+
import { errorDetails } from '../api/enhanced-client.js';
|
|
9
|
+
import DismissibleToast from '../components/toast/DismissibleToast.svelte';
|
|
10
|
+
import WarningIcon from '../components/toast/WarningIcon.svelte';
|
|
11
|
+
/**
|
|
12
|
+
* TYPE DEBT — remove when svelte-5-french-toast types `Renderable` as
|
|
13
|
+
* Svelte 5's `Component` instead of the legacy `SvelteComponent` class
|
|
14
|
+
* (dist/core/types.d.ts). The runtime renders a Svelte 5 component fine;
|
|
15
|
+
* only the declaration is behind, so this is the one place the lie lives.
|
|
16
|
+
*/
|
|
17
|
+
const asRenderable = (component) => component;
|
|
18
|
+
const dismissibleToast = asRenderable(DismissibleToast);
|
|
19
|
+
const warningIcon = asRenderable(WarningIcon);
|
|
8
20
|
/**
|
|
9
21
|
* Default toast options themed with FlowDrop design tokens.
|
|
10
22
|
* Use with <Toaster toastOptions={flowdropToastOptions} containerClassName="flowdrop-toaster" />
|
|
@@ -34,31 +46,54 @@ export const flowdropToastOptions = {
|
|
|
34
46
|
};
|
|
35
47
|
/** Container class for FlowDrop-themed Toaster (used with toast.css). */
|
|
36
48
|
export const FLOWDROP_TOASTER_CLASS = 'flowdrop-toaster';
|
|
49
|
+
/** Default id for a persistent toast: one per distinct text. */
|
|
50
|
+
function dedupeId(kind, message, details = []) {
|
|
51
|
+
return `${kind}:${[message, ...details].join('\n')}`;
|
|
52
|
+
}
|
|
37
53
|
/**
|
|
38
54
|
* Show a success toast notification
|
|
39
55
|
*/
|
|
40
56
|
export function showSuccess(message, options) {
|
|
41
57
|
return toast.success(message, {
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
id: options?.id,
|
|
59
|
+
duration: options?.duration ?? TOAST_DURATION.SUCCESS,
|
|
60
|
+
position: options?.position ?? 'bottom-center'
|
|
44
61
|
});
|
|
45
62
|
}
|
|
46
63
|
/**
|
|
47
|
-
* Show an error toast notification
|
|
64
|
+
* Show an error toast notification.
|
|
65
|
+
*
|
|
66
|
+
* Stays until the user closes it (TOAST_DURATION.ERROR is Infinity). Pass a
|
|
67
|
+
* finite `duration` to opt back into auto-dismiss.
|
|
48
68
|
*/
|
|
49
69
|
export function showError(message, options) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
const details = options?.details ?? [];
|
|
71
|
+
return toast.error(dismissibleToast, {
|
|
72
|
+
id: options?.id ?? dedupeId('error', message, details),
|
|
73
|
+
props: { text: message, details },
|
|
74
|
+
duration: options?.duration ?? TOAST_DURATION.ERROR,
|
|
75
|
+
position: options?.position ?? 'bottom-center'
|
|
53
76
|
});
|
|
54
77
|
}
|
|
55
78
|
/**
|
|
56
|
-
* Show a warning toast notification
|
|
79
|
+
* Show a warning toast notification.
|
|
80
|
+
*
|
|
81
|
+
* Persists until dismissed, like an error. The stance behind that: a warning
|
|
82
|
+
* here is not "done, by the way" — the editor reserves it for something the
|
|
83
|
+
* user should act on (an agent's config key that was ignored, an import that
|
|
84
|
+
* dropped nodes), and a message like that must not vanish mid-read. Pass a
|
|
85
|
+
* finite `duration` for a warning that is only informational. Wears its own
|
|
86
|
+
* icon and colour so it is not mistaken for an error.
|
|
57
87
|
*/
|
|
58
88
|
export function showWarning(message, options) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
89
|
+
const details = options?.details ?? [];
|
|
90
|
+
return toast(dismissibleToast, {
|
|
91
|
+
id: options?.id ?? dedupeId('warning', message, details),
|
|
92
|
+
props: { text: message, details },
|
|
93
|
+
icon: warningIcon,
|
|
94
|
+
className: 'flowdrop-toast-bar flowdrop-toast-bar--warning',
|
|
95
|
+
duration: options?.duration ?? TOAST_DURATION.WARNING,
|
|
96
|
+
position: options?.position ?? 'bottom-center'
|
|
62
97
|
});
|
|
63
98
|
}
|
|
64
99
|
/**
|
|
@@ -66,8 +101,9 @@ export function showWarning(message, options) {
|
|
|
66
101
|
*/
|
|
67
102
|
export function showInfo(message, options) {
|
|
68
103
|
return toast.success(message, {
|
|
69
|
-
|
|
70
|
-
|
|
104
|
+
id: options?.id,
|
|
105
|
+
duration: options?.duration ?? TOAST_DURATION.INFO,
|
|
106
|
+
position: options?.position ?? 'bottom-center'
|
|
71
107
|
});
|
|
72
108
|
}
|
|
73
109
|
/**
|
|
@@ -75,8 +111,9 @@ export function showInfo(message, options) {
|
|
|
75
111
|
*/
|
|
76
112
|
export function showLoading(message, options) {
|
|
77
113
|
return toast.loading(message, {
|
|
78
|
-
|
|
79
|
-
|
|
114
|
+
id: options?.id,
|
|
115
|
+
duration: options?.duration ?? Infinity,
|
|
116
|
+
position: options?.position ?? 'bottom-center'
|
|
80
117
|
});
|
|
81
118
|
}
|
|
82
119
|
/**
|
|
@@ -107,10 +144,17 @@ export function showPromise(promise, { loading, success, error, options }) {
|
|
|
107
144
|
*/
|
|
108
145
|
export function showConfirmation(message, options) {
|
|
109
146
|
return toast(message, {
|
|
110
|
-
|
|
111
|
-
|
|
147
|
+
id: options?.id,
|
|
148
|
+
duration: options?.duration ?? TOAST_DURATION.CONFIRMATION,
|
|
149
|
+
position: options?.position ?? 'bottom-center'
|
|
112
150
|
});
|
|
113
151
|
}
|
|
152
|
+
/** Headline and reasons of a thrown error; see `errorDetails`. */
|
|
153
|
+
function errorParts(error) {
|
|
154
|
+
if (typeof error === 'string')
|
|
155
|
+
return { message: error, details: [] };
|
|
156
|
+
return { message: error.message, details: errorDetails(error) };
|
|
157
|
+
}
|
|
114
158
|
/**
|
|
115
159
|
* API-specific toast helpers
|
|
116
160
|
*/
|
|
@@ -126,8 +170,8 @@ export const apiToasts = {
|
|
|
126
170
|
* Show API error message
|
|
127
171
|
*/
|
|
128
172
|
error: (operation, error) => {
|
|
129
|
-
const
|
|
130
|
-
return showError(`${operation} failed: ${
|
|
173
|
+
const { message, details } = errorParts(error);
|
|
174
|
+
return showError(`${operation} failed: ${message}`, { details });
|
|
131
175
|
},
|
|
132
176
|
/**
|
|
133
177
|
* Show API loading message
|
|
@@ -163,8 +207,8 @@ export const workflowToasts = {
|
|
|
163
207
|
* Show workflow save error
|
|
164
208
|
*/
|
|
165
209
|
saveError: (error) => {
|
|
166
|
-
const
|
|
167
|
-
return showError(`Failed to save workflow: ${
|
|
210
|
+
const { message, details } = errorParts(error);
|
|
211
|
+
return showError(`Failed to save workflow: ${message}`, { details });
|
|
168
212
|
},
|
|
169
213
|
/**
|
|
170
214
|
* Show workflow delete success
|
|
@@ -179,8 +223,8 @@ export const workflowToasts = {
|
|
|
179
223
|
* Show workflow delete error
|
|
180
224
|
*/
|
|
181
225
|
deleteError: (error) => {
|
|
182
|
-
const
|
|
183
|
-
return showError(`Failed to delete workflow: ${
|
|
226
|
+
const { message, details } = errorParts(error);
|
|
227
|
+
return showError(`Failed to delete workflow: ${message}`, { details });
|
|
184
228
|
},
|
|
185
229
|
/**
|
|
186
230
|
* Show workflow execution started
|
|
@@ -213,8 +257,8 @@ export const workflowToasts = {
|
|
|
213
257
|
* Show workflow execution error
|
|
214
258
|
*/
|
|
215
259
|
executionError: (error) => {
|
|
216
|
-
const
|
|
217
|
-
return showError(`Workflow execution failed: ${
|
|
260
|
+
const { message, details } = errorParts(error);
|
|
261
|
+
return showError(`Workflow execution failed: ${message}`, { details });
|
|
218
262
|
}
|
|
219
263
|
};
|
|
220
264
|
/**
|
|
@@ -234,8 +278,8 @@ export const pipelineToasts = {
|
|
|
234
278
|
* Show pipeline creation error
|
|
235
279
|
*/
|
|
236
280
|
creationError: (error) => {
|
|
237
|
-
const
|
|
238
|
-
return showError(`Failed to create pipeline: ${
|
|
281
|
+
const { message, details } = errorParts(error);
|
|
282
|
+
return showError(`Failed to create pipeline: ${message}`, { details });
|
|
239
283
|
},
|
|
240
284
|
/**
|
|
241
285
|
* Show pipeline execution started
|
|
@@ -253,8 +297,8 @@ export const pipelineToasts = {
|
|
|
253
297
|
* Show pipeline execution error
|
|
254
298
|
*/
|
|
255
299
|
executionError: (pipelineId, error) => {
|
|
256
|
-
const
|
|
257
|
-
return showError(`Pipeline ${pipelineId} execution failed: ${
|
|
300
|
+
const { message, details } = errorParts(error);
|
|
301
|
+
return showError(`Pipeline ${pipelineId} execution failed: ${message}`, { details });
|
|
258
302
|
},
|
|
259
303
|
/**
|
|
260
304
|
* Show pipeline status update
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* @module stores/instanceContainer
|
|
15
15
|
*/
|
|
16
16
|
import type { NodeMetadata } from '../types/index.js';
|
|
17
|
+
import type { HostHooks } from '../webmcp/types.js';
|
|
18
|
+
import type { ApprovalGate } from '../webmcp/gate.js';
|
|
17
19
|
import { HistoryService } from '../services/historyService.js';
|
|
18
20
|
import { WorkflowStore } from './workflowStore.svelte.js';
|
|
19
21
|
import { HistoryStore } from './historyStore.svelte.js';
|
|
@@ -84,6 +86,23 @@ export interface FlowDropInstance {
|
|
|
84
86
|
* again (the WebMCP adapter's `list_types`, `add_node`).
|
|
85
87
|
*/
|
|
86
88
|
readonly nodeTypes: NodeTypesStore;
|
|
89
|
+
/**
|
|
90
|
+
* The host's save/run/status hooks for this editor, as the mount supplied
|
|
91
|
+
* them (`mountFlowDropApp` sets `onSave` to its own Save and copies the
|
|
92
|
+
* `webmcp` option's `onRun`/`onRunStatus`). Read by anything that offers
|
|
93
|
+
* the `save`, `run` and `run_status` tools without a WebMCP runtime — the
|
|
94
|
+
* chat panel's tool loop — so both agents persist and run exactly the way
|
|
95
|
+
* clicking Save does.
|
|
96
|
+
*/
|
|
97
|
+
readonly host: HostHooksStore;
|
|
98
|
+
/**
|
|
99
|
+
* The approval gate every agent surface on this editor asks — the WebMCP
|
|
100
|
+
* registration and the chat panel's tool loop. Whichever surface comes
|
|
101
|
+
* first creates its gate and publishes it here; the other reuses it, so one
|
|
102
|
+
* "don't ask again for edits" covers both and two dialogs never stack. The
|
|
103
|
+
* publisher clears it when it goes away. `null` until a surface exists.
|
|
104
|
+
*/
|
|
105
|
+
approvalGate: ApprovalGate | null;
|
|
87
106
|
/**
|
|
88
107
|
* Run `fn` when this instance is destroyed. Returns an unsubscribe; calling
|
|
89
108
|
* it before `destroy()` means `fn` never runs. Adapters that bind to an
|
|
@@ -109,6 +128,21 @@ export declare class NodeTypesStore {
|
|
|
109
128
|
get current(): NodeMetadata[];
|
|
110
129
|
set(list: NodeMetadata[]): void;
|
|
111
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* The hooks actually supplied: an explicit `undefined` is dropped, so it can
|
|
133
|
+
* never shadow a default when the result is spread over one.
|
|
134
|
+
*/
|
|
135
|
+
export declare function definedHostHooks(hooks: HostHooks): HostHooks;
|
|
136
|
+
/**
|
|
137
|
+
* The host hooks of one editor. A plain holder, not reactive: hooks are set
|
|
138
|
+
* once by the mount and read at call time.
|
|
139
|
+
*/
|
|
140
|
+
export declare class HostHooksStore {
|
|
141
|
+
#private;
|
|
142
|
+
get current(): HostHooks;
|
|
143
|
+
/** Replace the hooks. Keys set to `undefined` are dropped. */
|
|
144
|
+
set(hooks: HostHooks): void;
|
|
145
|
+
}
|
|
112
146
|
export interface CreateInstanceOptions {
|
|
113
147
|
/** Explicit instance id; auto-generated (`fd-<n>`) when omitted. */
|
|
114
148
|
id?: string;
|
|
@@ -46,6 +46,34 @@ export class NodeTypesStore {
|
|
|
46
46
|
this.#list = list;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* The hooks actually supplied: an explicit `undefined` is dropped, so it can
|
|
51
|
+
* never shadow a default when the result is spread over one.
|
|
52
|
+
*/
|
|
53
|
+
export function definedHostHooks(hooks) {
|
|
54
|
+
const out = {};
|
|
55
|
+
if (hooks.onSave)
|
|
56
|
+
out.onSave = hooks.onSave;
|
|
57
|
+
if (hooks.onRun)
|
|
58
|
+
out.onRun = hooks.onRun;
|
|
59
|
+
if (hooks.onRunStatus)
|
|
60
|
+
out.onRunStatus = hooks.onRunStatus;
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The host hooks of one editor. A plain holder, not reactive: hooks are set
|
|
65
|
+
* once by the mount and read at call time.
|
|
66
|
+
*/
|
|
67
|
+
export class HostHooksStore {
|
|
68
|
+
#hooks = {};
|
|
69
|
+
get current() {
|
|
70
|
+
return this.#hooks;
|
|
71
|
+
}
|
|
72
|
+
/** Replace the hooks. Keys set to `undefined` are dropped. */
|
|
73
|
+
set(hooks) {
|
|
74
|
+
this.#hooks = definedHostHooks(hooks);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
49
77
|
// Feeds auto-generated ids only (`fd-1`, `fd-2`, …) — cosmetic monotonicity.
|
|
50
78
|
// Incrementing across SSR requests is harmless; no state hangs off the value.
|
|
51
79
|
let instanceCounter = 0;
|
|
@@ -105,6 +133,8 @@ export function createFlowDropInstance(options = {}) {
|
|
|
105
133
|
// The default instance keeps the legacy bare localStorage key.
|
|
106
134
|
pipelinePanel: new PipelinePanelStore(id),
|
|
107
135
|
nodeTypes: new NodeTypesStore(),
|
|
136
|
+
host: new HostHooksStore(),
|
|
137
|
+
approvalGate: null,
|
|
108
138
|
onDestroy(fn) {
|
|
109
139
|
cleanups.push(fn);
|
|
110
140
|
return () => {
|
|
@@ -180,6 +180,16 @@ export declare class WorkflowStore {
|
|
|
180
180
|
* Call this after a successful backend save.
|
|
181
181
|
*/
|
|
182
182
|
markAsSaved(): void;
|
|
183
|
+
/**
|
|
184
|
+
* Take the server's word on the workflow's revision and permissions after a
|
|
185
|
+
* save (the load path sets them with the payload). Bookkeeping only: no history entry, no dirty flag, no
|
|
186
|
+
* change notification — the document the user edits is unchanged. Keys the
|
|
187
|
+
* server did not send are left as they were.
|
|
188
|
+
*/
|
|
189
|
+
acknowledgeServer(state: {
|
|
190
|
+
revision?: Workflow['revision'];
|
|
191
|
+
can?: Workflow['can'];
|
|
192
|
+
}): void;
|
|
183
193
|
/**
|
|
184
194
|
* Set the restoring from history flag.
|
|
185
195
|
*
|
|
@@ -324,6 +324,21 @@ export class WorkflowStore {
|
|
|
324
324
|
this.#onDirtyStateChange(false);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Take the server's word on the workflow's revision and permissions after a
|
|
329
|
+
* save (the load path sets them with the payload). Bookkeeping only: no history entry, no dirty flag, no
|
|
330
|
+
* change notification — the document the user edits is unchanged. Keys the
|
|
331
|
+
* server did not send are left as they were.
|
|
332
|
+
*/
|
|
333
|
+
acknowledgeServer(state) {
|
|
334
|
+
if (!this.#workflow)
|
|
335
|
+
return;
|
|
336
|
+
this.#workflow = {
|
|
337
|
+
...this.#workflow,
|
|
338
|
+
...(state.revision !== undefined && { revision: state.revision }),
|
|
339
|
+
...(state.can !== undefined && { can: state.can })
|
|
340
|
+
};
|
|
341
|
+
}
|
|
327
342
|
/**
|
|
328
343
|
* Set the restoring from history flag.
|
|
329
344
|
*
|
package/dist/styles/toast.css
CHANGED
|
@@ -33,3 +33,65 @@
|
|
|
33
33
|
border-color var(--fd-transition-fast),
|
|
34
34
|
box-shadow var(--fd-transition-fast);
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Dismissible toasts (errors, warnings): headline, optional reason list and a
|
|
39
|
+
* close button, rendered by DismissibleToast.svelte inside the library's
|
|
40
|
+
* `.message` flex row.
|
|
41
|
+
*/
|
|
42
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-text {
|
|
43
|
+
flex: 1 1 auto;
|
|
44
|
+
min-width: 0;
|
|
45
|
+
overflow-wrap: anywhere;
|
|
46
|
+
text-align: start;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-headline {
|
|
50
|
+
margin: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-details {
|
|
54
|
+
margin: var(--fd-space-xs, 4px) 0 0;
|
|
55
|
+
padding-inline-start: 1.1em;
|
|
56
|
+
color: var(--fd-muted-foreground, inherit);
|
|
57
|
+
font-size: var(--fd-text-xs, 0.85em);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-details li + li {
|
|
61
|
+
margin-top: 2px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-close {
|
|
65
|
+
flex: 0 0 auto;
|
|
66
|
+
align-self: flex-start;
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
margin-inline-start: var(--fd-space-sm, 8px);
|
|
71
|
+
padding: var(--fd-space-xs, 4px);
|
|
72
|
+
border: 0;
|
|
73
|
+
border-radius: var(--fd-radius-sm, 4px);
|
|
74
|
+
background: transparent;
|
|
75
|
+
color: var(--fd-muted-foreground, inherit);
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
line-height: 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-close:hover {
|
|
81
|
+
background: var(--fd-muted, rgba(0, 0, 0, 0.06));
|
|
82
|
+
color: var(--fd-card-foreground, inherit);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-close:focus-visible {
|
|
86
|
+
outline: 2px solid var(--fd-ring, var(--fd-primary));
|
|
87
|
+
outline-offset: 1px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Warning variant: same persistence as an error, its own colour so it reads as one. */
|
|
91
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-bar--warning {
|
|
92
|
+
border-color: var(--fd-warning, #f59e0b) !important;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.flowdrop-toaster.flowdrop-toaster .flowdrop-toast-warning-icon {
|
|
96
|
+
flex: 0 0 auto;
|
|
97
|
+
}
|
package/dist/styles/tokens.css
CHANGED
|
@@ -282,6 +282,12 @@
|
|
|
282
282
|
--fd-leading-relaxed: 1.6; /* @public */
|
|
283
283
|
|
|
284
284
|
/* ----- FONT FAMILIES ----- */
|
|
285
|
+
/* The editor inherits the host page's font. This stack is for UI the
|
|
286
|
+
library mounts outside the editor's subtree (the WebMCP confirm dialog
|
|
287
|
+
on document.body), where "inherit" means whatever the host's body has —
|
|
288
|
+
on Drupal admin themes, the browser's serif fallback. */
|
|
289
|
+
--fd-font-sans:
|
|
290
|
+
system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; /* @public */
|
|
285
291
|
--fd-font-mono:
|
|
286
292
|
ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; /* @public */
|
|
287
293
|
|
package/dist/svelte-app.d.ts
CHANGED
|
@@ -16,9 +16,9 @@ import { type FlowDropInstance } from './stores/instanceContainer.svelte.js';
|
|
|
16
16
|
import { type DraftStorageOption } from './services/draftStorage.js';
|
|
17
17
|
import type { PartialSettings, SettingsCategory, SurfacePlacement } from './types/settings.js';
|
|
18
18
|
import type { NavbarAction } from './types/navbar.js';
|
|
19
|
-
import type { WebMCPHandle, WebMCPMountOptions } from './webmcp/types.js';
|
|
19
|
+
import type { HostHooks, WebMCPHandle, WebMCPMountOptions } from './webmcp/types.js';
|
|
20
20
|
export type { NavbarAction };
|
|
21
|
-
export type { WebMCPHandle, WebMCPMountOptions };
|
|
21
|
+
export type { HostHooks, WebMCPHandle, WebMCPMountOptions };
|
|
22
22
|
/**
|
|
23
23
|
* Mount options for FlowDrop App
|
|
24
24
|
*/
|
|
@@ -141,6 +141,16 @@ export interface FlowDropMountOptions {
|
|
|
141
141
|
* API. Default off.
|
|
142
142
|
*/
|
|
143
143
|
webmcp?: boolean | WebMCPMountOptions;
|
|
144
|
+
/**
|
|
145
|
+
* The host's save/run/status hooks, published on the instance as
|
|
146
|
+
* `instance.host` for every agent surface the editor has — the AI
|
|
147
|
+
* Assistant panel's tool loop today, the WebMCP editor tools when
|
|
148
|
+
* {@link webmcp} is on. `onSave` defaults to the mount's own Save. Hooks
|
|
149
|
+
* given inside the {@link webmcp} option take precedence, so a host that
|
|
150
|
+
* already passes them there need not repeat them; pass them here when the
|
|
151
|
+
* assistant must be able to run the workflow even with WebMCP switched off.
|
|
152
|
+
*/
|
|
153
|
+
host?: HostHooks;
|
|
144
154
|
}
|
|
145
155
|
/**
|
|
146
156
|
* Return type for mounted FlowDrop app
|
|
@@ -171,9 +181,11 @@ export interface MountedFlowDropApp {
|
|
|
171
181
|
*/
|
|
172
182
|
getWorkflow: () => Workflow | null;
|
|
173
183
|
/**
|
|
174
|
-
* Trigger save operation
|
|
184
|
+
* Trigger save operation. Resolves `true` when the workflow was written,
|
|
185
|
+
* `false` when the save was cancelled (`onBeforeSave`) or there was nothing
|
|
186
|
+
* to save; rejects when the request failed.
|
|
175
187
|
*/
|
|
176
|
-
save: () => Promise<
|
|
188
|
+
save: () => Promise<boolean>;
|
|
177
189
|
/**
|
|
178
190
|
* Trigger export operation (downloads JSON)
|
|
179
191
|
*/
|
package/dist/svelte-app.js
CHANGED
|
@@ -12,7 +12,7 @@ import App from './components/App.svelte';
|
|
|
12
12
|
import { DEFAULT_PORT_CONFIG } from './config/defaultPortConfig.js';
|
|
13
13
|
import { fetchPortConfig } from './services/portConfigApi.js';
|
|
14
14
|
import { fetchCategories } from './services/categoriesApi.js';
|
|
15
|
-
import { createFlowDropInstance, getDefaultInstance, DEFAULT_DRAFT_PREFIX } from './stores/instanceContainer.svelte.js';
|
|
15
|
+
import { createFlowDropInstance, definedHostHooks, getDefaultInstance, DEFAULT_DRAFT_PREFIX } from './stores/instanceContainer.svelte.js';
|
|
16
16
|
import { DraftAutoSaveManager, getDraftStorageKey, migrateLegacyDraftKey, setDraftStorage, resolveDraftStorage, clearAllDrafts as clearAllDraftsFromStorage } from './services/draftStorage.js';
|
|
17
17
|
import { mergeFeatures } from './types/events.js';
|
|
18
18
|
import { initializeSettings, getBehaviorSettings, onSettingsChange } from './stores/settingsStore.svelte.js';
|
|
@@ -157,7 +157,7 @@ function attachWebMCPToMount(fd, options, isDestroyed) {
|
|
|
157
157
|
* ```
|
|
158
158
|
*/
|
|
159
159
|
export async function mountFlowDropApp(container, options = {}) {
|
|
160
|
-
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, pipelineId, navbarTitle, navbarActions, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp } = options;
|
|
160
|
+
const { workflow, nodes, endpointConfig, portConfig, categories, height = '100vh', width = '100%', showNavbar = false, disableSidebar, configPlacement, consolePlacement, mode, pipelineId, navbarTitle, navbarActions, showSettings, showStatus, authProvider, eventHandlers, features: userFeatures, settings: initialSettings, draftStorageKey: customDraftKey, draftStorage, formatAdapters, workflowFormats, theme, settingsCategories, showSettingsSyncButton, showSettingsResetButton, instanceId, webmcp, host } = options;
|
|
161
161
|
// Per-instance state container — this is what allows multiple FlowDrop
|
|
162
162
|
// editors to coexist on one page without sharing workflow/history state.
|
|
163
163
|
const { fd, isDefault } = acquireInstance(instanceId);
|
|
@@ -281,18 +281,10 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
281
281
|
eventHandlers: eventHandlers ?? null,
|
|
282
282
|
unsubscribeDraftSettings
|
|
283
283
|
};
|
|
284
|
-
// WebMCP editor tools, opt-in.
|
|
285
|
-
//
|
|
284
|
+
// WebMCP editor tools, opt-in. Attached below, once `mountedApp` exists —
|
|
285
|
+
// its default `onSave` is `mountedApp.save()`.
|
|
286
286
|
let webmcpHandle;
|
|
287
287
|
let destroyed = false;
|
|
288
|
-
if (webmcp) {
|
|
289
|
-
void attachWebMCPToMount(fd, webmcp === true ? {} : webmcp, () => destroyed).then((handle) => {
|
|
290
|
-
if (destroyed)
|
|
291
|
-
handle?.detach();
|
|
292
|
-
else
|
|
293
|
-
webmcpHandle = handle;
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
288
|
// Create the mounted app interface
|
|
297
289
|
const mountedApp = {
|
|
298
290
|
instance: fd,
|
|
@@ -351,7 +343,7 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
351
343
|
},
|
|
352
344
|
getWorkflow: () => fd.workflow.current,
|
|
353
345
|
save: async () => {
|
|
354
|
-
|
|
346
|
+
return globalSaveWorkflow({
|
|
355
347
|
instance: fd,
|
|
356
348
|
onSaved: (saved) => {
|
|
357
349
|
// globalSaveWorkflow does not write the server-assigned ID back to the
|
|
@@ -379,6 +371,45 @@ export async function mountFlowDropApp(container, options = {}) {
|
|
|
379
371
|
return removed;
|
|
380
372
|
}
|
|
381
373
|
};
|
|
374
|
+
// WebMCP editor tools, opt-in. Attaches in the background — mounting does
|
|
375
|
+
// not wait for it — and detaches with the mount. Defaults `onSave` to the
|
|
376
|
+
// mount's own Save so a browser agent's `save` tool persists exactly like
|
|
377
|
+
// clicking Save does; a host that supplies its own `onSave` overrides it.
|
|
378
|
+
//
|
|
379
|
+
// The same hooks are published on the instance (`fd.host`) whether or not
|
|
380
|
+
// WebMCP is on: the chat panel's tool loop offers `save`, `run` and
|
|
381
|
+
// `run_status` through them, so the built-in assistant and a browser agent
|
|
382
|
+
// persist and run the same way.
|
|
383
|
+
const defaultOnSave = async () => (await mountedApp.save())
|
|
384
|
+
? undefined
|
|
385
|
+
: {
|
|
386
|
+
ok: false,
|
|
387
|
+
code: 'UNAVAILABLE',
|
|
388
|
+
message: 'Nothing was saved: the host cancelled the save or no workflow is loaded.'
|
|
389
|
+
};
|
|
390
|
+
// Hook keys are merged through `definedHostHooks` on both inputs, so an
|
|
391
|
+
// explicit `onSave: undefined` in either never shadows the default.
|
|
392
|
+
const webmcpGiven = webmcp === true || !webmcp ? {} : webmcp;
|
|
393
|
+
const { onSave: _s, onRun: _r, onRunStatus: _rs, ...webmcpRest } = webmcpGiven;
|
|
394
|
+
const webmcpOptions = {
|
|
395
|
+
...webmcpRest,
|
|
396
|
+
onSave: defaultOnSave,
|
|
397
|
+
...definedHostHooks(host ?? {}),
|
|
398
|
+
...definedHostHooks(webmcpGiven)
|
|
399
|
+
};
|
|
400
|
+
fd.host.set({
|
|
401
|
+
onSave: webmcpOptions.onSave,
|
|
402
|
+
onRun: webmcpOptions.onRun,
|
|
403
|
+
onRunStatus: webmcpOptions.onRunStatus
|
|
404
|
+
});
|
|
405
|
+
if (webmcp) {
|
|
406
|
+
void attachWebMCPToMount(fd, webmcpOptions, () => destroyed).then((handle) => {
|
|
407
|
+
if (destroyed)
|
|
408
|
+
handle?.detach();
|
|
409
|
+
else
|
|
410
|
+
webmcpHandle = handle;
|
|
411
|
+
});
|
|
412
|
+
}
|
|
382
413
|
return mountedApp;
|
|
383
414
|
}
|
|
384
415
|
/**
|
|
@@ -428,7 +459,7 @@ export async function mountWorkflowEditor(container, options = {}) {
|
|
|
428
459
|
markAsSaved: () => fd.workflow.markAsSaved(),
|
|
429
460
|
getWorkflow: () => fd.workflow.current,
|
|
430
461
|
save: async () => {
|
|
431
|
-
|
|
462
|
+
return globalSaveWorkflow({ instance: fd });
|
|
432
463
|
},
|
|
433
464
|
export: () => {
|
|
434
465
|
globalExportWorkflow({ instance: fd });
|
package/dist/types/chat.d.ts
CHANGED
|
@@ -65,3 +65,62 @@ export interface CommandPreviewItem {
|
|
|
65
65
|
/** Optional result or error message after execution */
|
|
66
66
|
result?: string;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* One tool as the panel offers it to the server, in the shape a function-
|
|
70
|
+
* calling reasoner expects: `{name, description, input_schema}` plus the
|
|
71
|
+
* read-only flag. Projected from the editor's tool descriptors by
|
|
72
|
+
* `toToolDefinitions()`; the server holds no copy of these schemas.
|
|
73
|
+
*
|
|
74
|
+
* Names are the bare verbs (`describe_type`, `batch`, `save`) — no prefix.
|
|
75
|
+
*/
|
|
76
|
+
export interface ChatToolDefinition {
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
input_schema: Record<string, unknown>;
|
|
80
|
+
readOnly: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** A tool call the assistant made; the panel runs it and posts the result. */
|
|
83
|
+
export interface ChatToolCall {
|
|
84
|
+
/** Server-issued id, echoed back as `toolCallId`. */
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
args: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The first request of a turn. A superset of {@link ChatRequest}: a server
|
|
91
|
+
* that knows tool-calling turns reads `tools`; an older one ignores it and
|
|
92
|
+
* answers a plain {@link ChatResponse}, which the panel treats as legacy.
|
|
93
|
+
*/
|
|
94
|
+
export interface ChatTurnRequest extends ChatRequest {
|
|
95
|
+
/** The tools the panel can run for this turn, in call order preference. */
|
|
96
|
+
tools: ChatToolDefinition[];
|
|
97
|
+
}
|
|
98
|
+
/** One tool result, posted back to continue the turn. */
|
|
99
|
+
export interface ChatToolResult {
|
|
100
|
+
toolCallId: string;
|
|
101
|
+
/** The tool's result as text — the JSON the runtime returned. */
|
|
102
|
+
content: string;
|
|
103
|
+
/** Set when the tool reported an error (`isError` on the tool result). */
|
|
104
|
+
isError?: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface ChatToolResultsRequest {
|
|
107
|
+
results: ChatToolResult[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* What the server answers to a turn request or a tool-results post.
|
|
111
|
+
*
|
|
112
|
+
* `done: true` carries the assistant's final `content`; `done: false`
|
|
113
|
+
* carries `toolCalls` the panel must run and post back. `turnId` is present
|
|
114
|
+
* on every response of a tool-calling server; its absence marks a legacy
|
|
115
|
+
* server and a plain {@link ChatResponse}.
|
|
116
|
+
*
|
|
117
|
+
* `content` may also accompany `toolCalls` on a non-final response
|
|
118
|
+
* (`done: false`): text the model wrote alongside its calls — a note to the
|
|
119
|
+
* user, e.g. "this node has no url input port" — rather than the reply.
|
|
120
|
+
* Shown in the trace, never as the message body.
|
|
121
|
+
*/
|
|
122
|
+
export interface ChatTurnResponse extends ChatResponse {
|
|
123
|
+
turnId?: string;
|
|
124
|
+
toolCalls?: ChatToolCall[];
|
|
125
|
+
done?: boolean;
|
|
126
|
+
}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -221,6 +221,29 @@ export interface FlowDropFeatures {
|
|
|
221
221
|
* @default true
|
|
222
222
|
*/
|
|
223
223
|
builtinEditors?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Offer the Command Console tab in the console / AI Assistant group.
|
|
226
|
+
*
|
|
227
|
+
* The console is a command line for the editor's DSL. Hosts whose users
|
|
228
|
+
* are not developers may prefer to hide it, so nobody mistakes it for a
|
|
229
|
+
* chat. When both `console` and `assistant` are off, the group's toggle
|
|
230
|
+
* button and its backtick shortcut disappear as well.
|
|
231
|
+
*
|
|
232
|
+
* @default true
|
|
233
|
+
*/
|
|
234
|
+
console?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Offer the AI Assistant tab in the console / AI Assistant group.
|
|
237
|
+
*
|
|
238
|
+
* Independent of this flag, the tab is only offered when the endpoint
|
|
239
|
+
* configuration carries a `chat` endpoint group — an assistant with no
|
|
240
|
+
* backend has nothing to say. Browser agents (WebMCP) do not depend on the
|
|
241
|
+
* panel: they drive the same tool runtime through the browser's model
|
|
242
|
+
* context and keep working with the assistant hidden.
|
|
243
|
+
*
|
|
244
|
+
* @default true
|
|
245
|
+
*/
|
|
246
|
+
assistant?: boolean;
|
|
224
247
|
}
|
|
225
248
|
/**
|
|
226
249
|
* Default feature values
|
package/dist/types/events.js
CHANGED
|
@@ -16,7 +16,9 @@ export const DEFAULT_FEATURES = {
|
|
|
16
16
|
autoSaveDraftInterval: 30000,
|
|
17
17
|
showToasts: true,
|
|
18
18
|
enableNodeSwap: true,
|
|
19
|
-
builtinEditors: true
|
|
19
|
+
builtinEditors: true,
|
|
20
|
+
console: true,
|
|
21
|
+
assistant: true
|
|
20
22
|
};
|
|
21
23
|
/**
|
|
22
24
|
* Merge user-provided features with defaults
|