@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
package/dist/webmcp/types.d.ts
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { Command, UIAction } from '../commands/types.js';
|
|
18
18
|
import type { NodeMetadata } from '../types/index.js';
|
|
19
|
+
import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
|
|
20
|
+
import type { ApprovalGate } from './gate.js';
|
|
19
21
|
import type { MessagesOverride } from '../messages/types.js';
|
|
20
22
|
/** One property of a tool's input schema. */
|
|
21
23
|
export interface ToolSchemaProperty {
|
|
@@ -81,6 +83,11 @@ export interface RegisteredToolDefinition {
|
|
|
81
83
|
annotations?: {
|
|
82
84
|
readOnlyHint?: boolean;
|
|
83
85
|
untrustedContentHint?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Spec added 2026-09-03: "executing the tool will result in consequential
|
|
88
|
+
* actions that are significant, real-world, or non-reversible."
|
|
89
|
+
*/
|
|
90
|
+
consequentialHint?: boolean;
|
|
84
91
|
};
|
|
85
92
|
execute(input: unknown, options?: ToolExecuteOptions): Promise<ToolResult>;
|
|
86
93
|
}
|
|
@@ -99,15 +106,79 @@ export interface ModelContextLike {
|
|
|
99
106
|
/** Pre-spec runtimes only; called when present, never relied upon. */
|
|
100
107
|
unregisterTool?(name: string): unknown;
|
|
101
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Stable codes a host hook (`onSave`, `onRun`, `onRunStatus`) may answer with.
|
|
111
|
+
* They align with fddo's API-8 `error_code` vocabulary where the two meet
|
|
112
|
+
* (`CONFLICT`, `NOT_FOUND`); the rest name what a browser agent must do next.
|
|
113
|
+
*
|
|
114
|
+
* - `FORBIDDEN` — the server refused; the agent should tell the user.
|
|
115
|
+
* - `UNAVAILABLE` — nothing to act on yet (unsaved workflow, no runtime).
|
|
116
|
+
* - `NEEDS_APPROVAL` — a person must approve in the UI first.
|
|
117
|
+
* - `INVALID` — the workflow failed validation; `message` says where.
|
|
118
|
+
* - `CONFLICT` — the server copy changed since it was loaded; reload.
|
|
119
|
+
* - `PENDING` — a run is paused for a person (never for the agent, D8).
|
|
120
|
+
* - `NOT_FOUND` — the run id is unknown.
|
|
121
|
+
*/
|
|
122
|
+
export type HostCode = 'FORBIDDEN' | 'UNAVAILABLE' | 'NEEDS_APPROVAL' | 'INVALID' | 'CONFLICT' | 'PENDING' | 'NOT_FOUND' | (string & Record<never, never>);
|
|
123
|
+
/**
|
|
124
|
+
* What every host hook returns. `ok: false` needs a `code`; `ok: true` may
|
|
125
|
+
* still carry one (`PENDING`). `can` lets a host refresh what the user may do
|
|
126
|
+
* after the call — passed through to the agent untouched.
|
|
127
|
+
*/
|
|
128
|
+
export interface HostEnvelope<T = unknown> {
|
|
129
|
+
ok: boolean;
|
|
130
|
+
code?: HostCode;
|
|
131
|
+
message?: string;
|
|
132
|
+
data?: T;
|
|
133
|
+
can?: Record<string, boolean>;
|
|
134
|
+
}
|
|
135
|
+
/** What `onRun` reports back once a run is accepted. */
|
|
136
|
+
export interface RunStarted {
|
|
137
|
+
/** The id `run_status` polls with. */
|
|
138
|
+
runId: string;
|
|
139
|
+
status?: string;
|
|
140
|
+
queued?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/** The person-facing pause a paused run is waiting on (D8: no tool answers it). */
|
|
143
|
+
export interface RunPending {
|
|
144
|
+
interruptId?: string;
|
|
145
|
+
type?: string;
|
|
146
|
+
nodeId?: string;
|
|
147
|
+
message?: string;
|
|
148
|
+
}
|
|
149
|
+
/** What `onRunStatus` reports. `status` vocabulary is the host's; `paused` is special-cased. */
|
|
150
|
+
export interface RunStatus {
|
|
151
|
+
runId: string;
|
|
152
|
+
status: 'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'cancelled' | (string & Record<never, never>);
|
|
153
|
+
startedAt?: string | null;
|
|
154
|
+
finishedAt?: string | null;
|
|
155
|
+
/** Set when `status` is `paused` and a person must act. */
|
|
156
|
+
pending?: RunPending | null;
|
|
157
|
+
/** Why an execution budget paused the run, when it did. */
|
|
158
|
+
pausedReason?: string | null;
|
|
159
|
+
/** The run's output once it has one. Host-shaped. */
|
|
160
|
+
outputs?: unknown;
|
|
161
|
+
/** Per-node status once the host has it. Host-shaped. */
|
|
162
|
+
nodeStatuses?: unknown;
|
|
163
|
+
error?: string;
|
|
164
|
+
}
|
|
165
|
+
/** Context passed to a custom {@link WebMCPApproval} callback alongside the commands. */
|
|
166
|
+
export interface WebMCPApprovalRequest {
|
|
167
|
+
/** The tool being called, without prefix: `add_node`, `batch`, `save`, … */
|
|
168
|
+
tool: string;
|
|
169
|
+
}
|
|
102
170
|
/**
|
|
103
171
|
* Approval policy for mutating tools.
|
|
104
172
|
*
|
|
105
173
|
* - `'confirm'` (default): a confirm dialog rendered inside the page.
|
|
106
174
|
* - `'auto'`: run without asking. Only for hosts that already trust every
|
|
107
175
|
* agent on the page (kiosks, tests).
|
|
108
|
-
* - A callback receiving the commands about to run
|
|
176
|
+
* - A callback receiving the commands about to run and the request they came
|
|
177
|
+
* from; resolve `true` to run. For `save`, `commands` is empty and
|
|
178
|
+
* `request.tool === 'save'` — there is no command to describe, only the
|
|
179
|
+
* act of persisting.
|
|
109
180
|
*/
|
|
110
|
-
export type WebMCPApproval = 'confirm' | 'auto' | ((commands: Command[]) => Promise<boolean>);
|
|
181
|
+
export type WebMCPApproval = 'confirm' | 'auto' | ((commands: Command[], request: WebMCPApprovalRequest) => Promise<boolean>);
|
|
111
182
|
export interface WebMCPOptions {
|
|
112
183
|
/**
|
|
113
184
|
* Node type definitions the tools resolve `add_node` and `list_types`
|
|
@@ -126,6 +197,39 @@ export interface WebMCPOptions {
|
|
|
126
197
|
* it could do.
|
|
127
198
|
*/
|
|
128
199
|
onUIAction?: (action: UIAction) => void;
|
|
200
|
+
/**
|
|
201
|
+
* Persist the workflow (the editor's Save). When supplied, a `save` tool
|
|
202
|
+
* is registered; it is gated like a change because a save cannot be
|
|
203
|
+
* undone from the editor. When omitted the tool is not registered —
|
|
204
|
+
* there is nothing it could do.
|
|
205
|
+
*
|
|
206
|
+
* May resolve to nothing (saved) or to a {@link HostEnvelope} — e.g.
|
|
207
|
+
* `{ok: false, code: 'CONFLICT'}` when the server copy moved on. A thrown
|
|
208
|
+
* error is reported as `SAVE_FAILED`, except an error whose `errorData.error_code`
|
|
209
|
+
* or `status` says conflict, which is relayed as `CONFLICT`.
|
|
210
|
+
*/
|
|
211
|
+
onSave?: () => Promise<void | HostEnvelope>;
|
|
212
|
+
/**
|
|
213
|
+
* Start a run of the workflow being edited, with optional inputs for its
|
|
214
|
+
* interface ports. When supplied, a `run` tool is registered — gated like
|
|
215
|
+
* `save`, and flagged consequential — and `run_status` too when
|
|
216
|
+
* {@link onRunStatus} is also given. The hook answers with an envelope; the
|
|
217
|
+
* tool relays it. `data.runId` is what `run_status` polls with.
|
|
218
|
+
*/
|
|
219
|
+
onRun?: (inputs: Record<string, unknown>) => Promise<HostEnvelope<RunStarted>>;
|
|
220
|
+
/**
|
|
221
|
+
* Report a run's status. A read: never gated. `status: 'paused'` is relayed
|
|
222
|
+
* as `code: 'PENDING'` with `pending.nodeId` / `pending.message` — the agent
|
|
223
|
+
* tells the person, and the person acts in the UI (D8).
|
|
224
|
+
*/
|
|
225
|
+
onRunStatus?: (runId: string) => Promise<HostEnvelope<RunStatus>>;
|
|
226
|
+
/**
|
|
227
|
+
* Offer "don't ask again for edits in this session" in the confirm dialog.
|
|
228
|
+
* Ticked, later *edits* run without the dialog until the adapter detaches;
|
|
229
|
+
* `save` and `run` always ask. Default true. Irrelevant unless `approval`
|
|
230
|
+
* is `'confirm'`.
|
|
231
|
+
*/
|
|
232
|
+
rememberEdits?: boolean;
|
|
129
233
|
/** Where the built-in confirm dialog mounts. Default `document.body`. */
|
|
130
234
|
container?: HTMLElement;
|
|
131
235
|
/**
|
|
@@ -148,6 +252,96 @@ export interface WebMCPOptions {
|
|
|
148
252
|
export type WebMCPMountOptions = Omit<WebMCPOptions, 'nodeTypes' | 'onUIAction' | 'modelContext'> & {
|
|
149
253
|
nodeTypes?: WebMCPOptions['nodeTypes'];
|
|
150
254
|
};
|
|
255
|
+
/** The host hooks behind the `save`, `run` and `run_status` tools. */
|
|
256
|
+
export type HostHooks = Pick<WebMCPOptions, 'onSave' | 'onRun' | 'onRunStatus'>;
|
|
257
|
+
/**
|
|
258
|
+
* One host tool (`save`, `run`, `run_status`) as the runtime offers it. Like a
|
|
259
|
+
* {@link ToolDescriptor} but without `toCommands`: these tools run a hook,
|
|
260
|
+
* not commands.
|
|
261
|
+
*/
|
|
262
|
+
export interface HostToolDescriptor {
|
|
263
|
+
verb: 'save' | 'run' | 'run_status';
|
|
264
|
+
description: string;
|
|
265
|
+
inputSchema: ToolInputSchema;
|
|
266
|
+
readOnly: boolean;
|
|
267
|
+
/** Never covered by "don't ask again for edits"; always asks. */
|
|
268
|
+
consequential: boolean;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* What a tool call would do, before it runs — for a transcript or a dialog.
|
|
272
|
+
* Computed the way `runTool` will act: the layout opt-out is already applied
|
|
273
|
+
* and `asks` reflects the gate's current state, so a caller announcing the
|
|
274
|
+
* call announces what actually happens.
|
|
275
|
+
*/
|
|
276
|
+
export interface ToolPreview {
|
|
277
|
+
/** The commands the call will run; empty for a host tool. */
|
|
278
|
+
commands: Command[];
|
|
279
|
+
/** Layout commands the opt-out will skip (`chatAllowLayoutChanges` off). */
|
|
280
|
+
skipped: Command[];
|
|
281
|
+
/** True when the call passes through the approval gate. */
|
|
282
|
+
mutating: boolean;
|
|
283
|
+
/** True for `save` and `run`. */
|
|
284
|
+
consequential: boolean;
|
|
285
|
+
/**
|
|
286
|
+
* True when the call will wait on the gate's decision — a mutating call
|
|
287
|
+
* the person has not pre-approved, or a consequential one — under a policy
|
|
288
|
+
* that asks at all (`approval: 'auto'` never does).
|
|
289
|
+
*/
|
|
290
|
+
asks: boolean;
|
|
291
|
+
}
|
|
292
|
+
export interface ToolRuntimeOptions {
|
|
293
|
+
instance: FlowDropInstance;
|
|
294
|
+
/** See {@link WebMCPOptions.nodeTypes}. Defaults to the instance's list. */
|
|
295
|
+
nodeTypes?: NodeMetadata[] | (() => NodeMetadata[]);
|
|
296
|
+
/** See {@link WebMCPOptions.onUIAction}. Without it there is no `view` tool. */
|
|
297
|
+
onUIAction?: (action: UIAction) => void;
|
|
298
|
+
/** Host hooks; each present hook adds its tool. */
|
|
299
|
+
hooks?: HostHooks;
|
|
300
|
+
/**
|
|
301
|
+
* An existing gate to ask, e.g. the registration's. When omitted the
|
|
302
|
+
* runtime creates one from `approval`, `container`, `messages` and
|
|
303
|
+
* `rememberEdits` and disposes it with itself.
|
|
304
|
+
*/
|
|
305
|
+
gate?: ApprovalGate;
|
|
306
|
+
approval?: WebMCPApproval;
|
|
307
|
+
container?: HTMLElement;
|
|
308
|
+
messages?: MessagesOverride | (() => MessagesOverride);
|
|
309
|
+
rememberEdits?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* The approval dialog's title for this runtime's calls, given the editor
|
|
312
|
+
* name — who is asking. Defaults to the gate's WebMCP wording. Lets two
|
|
313
|
+
* runtimes share one gate and still say which surface wants the change.
|
|
314
|
+
*/
|
|
315
|
+
dialogTitle?: (editorName: string) => string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* The tool runtime: every editor tool and host tool of one editor instance
|
|
319
|
+
* behind a single `runTool(name, input)`. Built by `createToolRuntime`.
|
|
320
|
+
*/
|
|
321
|
+
export interface ToolRuntime {
|
|
322
|
+
/** Editor tools (commands), in registration order. */
|
|
323
|
+
readonly descriptors: readonly ToolDescriptor[];
|
|
324
|
+
/** Host tools present for the supplied hooks, in registration order. */
|
|
325
|
+
readonly hostTools: readonly HostToolDescriptor[];
|
|
326
|
+
/** The gate mutating calls pass through. */
|
|
327
|
+
readonly gate: ApprovalGate;
|
|
328
|
+
/**
|
|
329
|
+
* Run a tool by its bare verb (`add_node`, `batch`, `save`, …): validate,
|
|
330
|
+
* map, gate, execute. Never throws for a bad call — argument errors, a
|
|
331
|
+
* rejected dialog, an unknown name all come back as an `isError` result the
|
|
332
|
+
* model can read. Throws only for a bug.
|
|
333
|
+
*/
|
|
334
|
+
runTool(name: string, input: unknown): Promise<ToolResult>;
|
|
335
|
+
/**
|
|
336
|
+
* What `runTool(name, input)` would do, without doing it. `null` for an
|
|
337
|
+
* unknown tool or arguments the schema refuses.
|
|
338
|
+
*/
|
|
339
|
+
preview(name: string, input: unknown): ToolPreview | null;
|
|
340
|
+
/** True after `dispose()`; every later call answers `DETACHED`. */
|
|
341
|
+
readonly disposed: boolean;
|
|
342
|
+
/** Dismiss any open dialog (as a rejection) and refuse further calls. */
|
|
343
|
+
dispose(): void;
|
|
344
|
+
}
|
|
151
345
|
/** Returned by `attachWebMCP`. */
|
|
152
346
|
export interface WebMCPHandle {
|
|
153
347
|
/**
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.8.0",
|
|
7
7
|
"author": "Shibin Das (D34dMan)",
|
|
8
8
|
"bugs": {
|
|
9
9
|
"url": "https://github.com/flowdrop-io/flowdrop/issues"
|