@flowdrop/flowdrop 2.4.0 → 2.6.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 +49 -0
- package/dist/chat/commandClassifier.d.ts +17 -0
- package/dist/chat/commandClassifier.js +29 -0
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/components/App.svelte +8 -0
- package/dist/components/BindablePortListbox.svelte +426 -0
- package/dist/components/BindablePortListbox.svelte.d.ts +23 -0
- package/dist/components/WorkflowInterfaceEditor.svelte +142 -36
- package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +8 -0
- package/dist/components/WorkflowInterfaceEntryCard.svelte +537 -294
- package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +6 -3
- package/dist/components/WorkflowInterfaceEntryComposer.svelte +331 -0
- package/dist/components/WorkflowInterfaceEntryComposer.svelte.d.ts +19 -0
- package/dist/config/defaultPortConfig.js +27 -9
- package/dist/messages/context.d.ts +6 -0
- package/dist/messages/context.js +8 -0
- package/dist/messages/defaults.d.ts +45 -2
- package/dist/messages/defaults.js +36 -3
- package/dist/messages/index.d.ts +1 -1
- package/dist/messages/index.js +1 -1
- package/dist/openapi/v1/openapi.yaml +14 -1
- package/dist/schemas/v1/workflow.schema.json +9 -2
- package/dist/stores/instanceContainer.svelte.d.ts +26 -0
- package/dist/stores/instanceContainer.svelte.js +24 -0
- package/dist/stories/WebMCPFakeAgent.svelte +229 -0
- package/dist/stories/WebMCPFakeAgent.svelte.d.ts +10 -0
- package/dist/styles/base.css +4 -2
- package/dist/styles/tokens.css +20 -0
- package/dist/svelte-app.d.ts +20 -0
- package/dist/svelte-app.js +49 -1
- package/dist/types/index.d.ts +26 -1
- package/dist/utils/focus.d.ts +18 -0
- package/dist/utils/focus.js +24 -0
- package/dist/utils/whenWorkflowLoaded.svelte.d.ts +17 -0
- package/dist/utils/whenWorkflowLoaded.svelte.js +42 -0
- package/dist/utils/workflowInterface.d.ts +47 -3
- package/dist/utils/workflowInterface.js +84 -9
- package/dist/webmcp/WebMCP.stories.svelte +101 -0
- package/dist/webmcp/WebMCP.stories.svelte.d.ts +18 -0
- package/dist/webmcp/WebMCPConfirm.svelte +170 -0
- package/dist/webmcp/WebMCPConfirm.svelte.d.ts +11 -0
- package/dist/webmcp/descriptors.d.ts +59 -0
- package/dist/webmcp/descriptors.js +464 -0
- package/dist/webmcp/fake.d.ts +23 -0
- package/dist/webmcp/fake.js +42 -0
- package/dist/webmcp/gate.d.ts +40 -0
- package/dist/webmcp/gate.js +92 -0
- package/dist/webmcp/index.d.ts +34 -0
- package/dist/webmcp/index.js +31 -0
- package/dist/webmcp/register.d.ts +33 -0
- package/dist/webmcp/register.js +267 -0
- package/dist/webmcp/types.d.ts +166 -0
- package/dist/webmcp/types.js +23 -0
- package/dist/webmcp/validate.d.ts +32 -0
- package/dist/webmcp/validate.js +118 -0
- package/package.json +6 -1
|
@@ -200,9 +200,53 @@ export interface BindablePort {
|
|
|
200
200
|
* Mirrors `FormPorts.svelte`'s port list: a node's static metadata ports plus
|
|
201
201
|
* its user-defined dynamic ports, filtered by `isPortExposed`.
|
|
202
202
|
*
|
|
203
|
-
* Control-flow ports are excluded: the reserved `trigger
|
|
204
|
-
*
|
|
205
|
-
* (DN1's grounded fact).
|
|
203
|
+
* Control-flow ports are excluded: the reserved `trigger` dataType, the
|
|
204
|
+
* `loop_back` port and `tool` outputs are intra-graph control flow, not an
|
|
205
|
+
* external surface (DN1's grounded fact). `tool` inputs are offered — see
|
|
206
|
+
* `isControlFlowPort`. The model and validation stay permissive — this only
|
|
206
207
|
* constrains what the authoring picker offers.
|
|
207
208
|
*/
|
|
208
209
|
export declare function listBindablePorts(workflow: Workflow, direction: 'input' | 'output'): BindablePort[];
|
|
210
|
+
/** A bindable port plus what the canvas already does with it. */
|
|
211
|
+
export interface RankedBindablePort extends BindablePort {
|
|
212
|
+
/** An edge already feeds this input, or already drains this output. */
|
|
213
|
+
connected: boolean;
|
|
214
|
+
/** The id of the same-direction interface entry that already binds this port, if any. */
|
|
215
|
+
publishedAs?: string;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* A stable key for a bindable port — `nodeId::portId` — the value a picker
|
|
219
|
+
* highlights by and an entry's single binding is compared against.
|
|
220
|
+
*/
|
|
221
|
+
export declare function bindablePortKey(candidate: BindablePort | {
|
|
222
|
+
nodeId: string;
|
|
223
|
+
portId: string;
|
|
224
|
+
}): string;
|
|
225
|
+
/** A port nothing is using yet — the natural first pick for a new entry. */
|
|
226
|
+
export declare function isFreeBindablePort(candidate: RankedBindablePort): boolean;
|
|
227
|
+
/**
|
|
228
|
+
* `listBindablePorts`, annotated and ordered for a "pick a port to publish"
|
|
229
|
+
* picker: every port nothing is using yet comes first, then the ports that
|
|
230
|
+
* already have an edge or are already published by another entry. Within
|
|
231
|
+
* each group the canvas order is kept, so the list stays stable as the
|
|
232
|
+
* author edits.
|
|
233
|
+
*
|
|
234
|
+
* "Connected" mirrors `validateWorkflowInterface`'s already-connected rule
|
|
235
|
+
* for inputs (an incoming edge on the bound handle) and its natural inverse
|
|
236
|
+
* for outputs (an outgoing edge). Neither is forbidden — an output can be
|
|
237
|
+
* both wired and published — the ranking only says which ports need no
|
|
238
|
+
* second thought.
|
|
239
|
+
*/
|
|
240
|
+
export declare function rankBindablePorts(workflow: Workflow, direction: 'input' | 'output'): RankedBindablePort[];
|
|
241
|
+
/**
|
|
242
|
+
* A complete new entry for a port the author just picked: bound to it, with
|
|
243
|
+
* every field `pullEntryFieldsFromPort` can derive, and an `id` seeded from
|
|
244
|
+
* the port's own id — made unique against `existingIds` with a numeric
|
|
245
|
+
* suffix (`text`, `text_2`, `text_3`, …).
|
|
246
|
+
*
|
|
247
|
+
* Seeding the id from the port is a convenience at creation time only: the
|
|
248
|
+
* author edits it like any other field afterwards, and nothing later
|
|
249
|
+
* re-derives it. DN1's concern — a contract silently keyed on internal port
|
|
250
|
+
* names — is about that ongoing coupling, which this does not introduce.
|
|
251
|
+
*/
|
|
252
|
+
export declare function entryFromBindablePort(candidate: BindablePort, existingIds: Iterable<string>): WorkflowInterfaceEntry;
|
|
@@ -347,12 +347,22 @@ export function pullEntryFieldsFromPort(port) {
|
|
|
347
347
|
return patch;
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
|
-
* Whether a port is intra-graph control flow — the reserved `trigger
|
|
351
|
-
*
|
|
352
|
-
* workflow's interface.
|
|
350
|
+
* Whether a port is intra-graph control flow — the reserved `trigger`
|
|
351
|
+
* dataType, the loopback input, or a `tool` *output* — and therefore never
|
|
352
|
+
* publishable in a workflow's interface.
|
|
353
|
+
*
|
|
354
|
+
* A `tool` **input** is deliberately not control flow here. Tools are a typed
|
|
355
|
+
* argument of a workflow's execution (fddo DF9): exposing a consumer's `tool`
|
|
356
|
+
* input (a ToolBox's `tools`, an LLM node's `tools`) in the interface is how a
|
|
357
|
+
* parent hands its tools to a sub-workflow, so the picker must offer it. A
|
|
358
|
+
* `tool` output is the inverse — a workflow *producing* a tool — which is not
|
|
359
|
+
* a composition the runtime supports through the interface (a workflow is
|
|
360
|
+
* made a tool by a different mechanism), so it stays excluded.
|
|
353
361
|
*/
|
|
354
|
-
function isControlFlowPort(port) {
|
|
355
|
-
|
|
362
|
+
function isControlFlowPort(port, direction) {
|
|
363
|
+
if (port.dataType === 'trigger' || port.id === LOOPBACK_PORT_NAME)
|
|
364
|
+
return true;
|
|
365
|
+
return port.dataType === 'tool' && direction === 'output';
|
|
356
366
|
}
|
|
357
367
|
/**
|
|
358
368
|
* Every canvas-exposed port of a workflow, for one direction — the candidate
|
|
@@ -362,9 +372,10 @@ function isControlFlowPort(port) {
|
|
|
362
372
|
* Mirrors `FormPorts.svelte`'s port list: a node's static metadata ports plus
|
|
363
373
|
* its user-defined dynamic ports, filtered by `isPortExposed`.
|
|
364
374
|
*
|
|
365
|
-
* Control-flow ports are excluded: the reserved `trigger
|
|
366
|
-
*
|
|
367
|
-
* (DN1's grounded fact).
|
|
375
|
+
* Control-flow ports are excluded: the reserved `trigger` dataType, the
|
|
376
|
+
* `loop_back` port and `tool` outputs are intra-graph control flow, not an
|
|
377
|
+
* external surface (DN1's grounded fact). `tool` inputs are offered — see
|
|
378
|
+
* `isControlFlowPort`. The model and validation stay permissive — this only
|
|
368
379
|
* constrains what the authoring picker offers.
|
|
369
380
|
*/
|
|
370
381
|
export function listBindablePorts(workflow, direction) {
|
|
@@ -380,7 +391,7 @@ export function listBindablePorts(workflow, direction) {
|
|
|
380
391
|
const portsConfig = node.data?.config?.[PORTS_CONFIG_KEY];
|
|
381
392
|
const entries = portsConfig?.[portsConfigDirection];
|
|
382
393
|
for (const port of [...staticPorts, ...dynamicPorts]) {
|
|
383
|
-
if (isControlFlowPort(port))
|
|
394
|
+
if (isControlFlowPort(port, direction))
|
|
384
395
|
continue;
|
|
385
396
|
if (isPortExposed(port, entries)) {
|
|
386
397
|
result.push({ nodeId: node.id, nodeLabel: node.data?.label ?? node.id, port });
|
|
@@ -389,3 +400,67 @@ export function listBindablePorts(workflow, direction) {
|
|
|
389
400
|
}
|
|
390
401
|
return result;
|
|
391
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* A stable key for a bindable port — `nodeId::portId` — the value a picker
|
|
405
|
+
* highlights by and an entry's single binding is compared against.
|
|
406
|
+
*/
|
|
407
|
+
export function bindablePortKey(candidate) {
|
|
408
|
+
const portId = 'port' in candidate ? candidate.port.id : candidate.portId;
|
|
409
|
+
return `${candidate.nodeId}::${portId}`;
|
|
410
|
+
}
|
|
411
|
+
/** A port nothing is using yet — the natural first pick for a new entry. */
|
|
412
|
+
export function isFreeBindablePort(candidate) {
|
|
413
|
+
return !candidate.connected && candidate.publishedAs === undefined;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* `listBindablePorts`, annotated and ordered for a "pick a port to publish"
|
|
417
|
+
* picker: every port nothing is using yet comes first, then the ports that
|
|
418
|
+
* already have an edge or are already published by another entry. Within
|
|
419
|
+
* each group the canvas order is kept, so the list stays stable as the
|
|
420
|
+
* author edits.
|
|
421
|
+
*
|
|
422
|
+
* "Connected" mirrors `validateWorkflowInterface`'s already-connected rule
|
|
423
|
+
* for inputs (an incoming edge on the bound handle) and its natural inverse
|
|
424
|
+
* for outputs (an outgoing edge). Neither is forbidden — an output can be
|
|
425
|
+
* both wired and published — the ranking only says which ports need no
|
|
426
|
+
* second thought.
|
|
427
|
+
*/
|
|
428
|
+
export function rankBindablePorts(workflow, direction) {
|
|
429
|
+
const entries = (direction === 'input' ? workflow.interface?.inputs : workflow.interface?.outputs) ?? [];
|
|
430
|
+
const ranked = listBindablePorts(workflow, direction).map((candidate) => {
|
|
431
|
+
const handleId = buildHandleId(candidate.nodeId, direction, candidate.port.id);
|
|
432
|
+
const connected = workflow.edges.some((edge) => direction === 'input' ? edge.targetHandle === handleId : edge.sourceHandle === handleId);
|
|
433
|
+
const publishedAs = entries.find((entry) => entry.bindings.some((binding) => binding.nodeId === candidate.nodeId && binding.portId === candidate.port.id))?.id;
|
|
434
|
+
return publishedAs === undefined
|
|
435
|
+
? { ...candidate, connected }
|
|
436
|
+
: { ...candidate, connected, publishedAs };
|
|
437
|
+
});
|
|
438
|
+
return [
|
|
439
|
+
...ranked.filter(isFreeBindablePort),
|
|
440
|
+
...ranked.filter((candidate) => !isFreeBindablePort(candidate))
|
|
441
|
+
];
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* A complete new entry for a port the author just picked: bound to it, with
|
|
445
|
+
* every field `pullEntryFieldsFromPort` can derive, and an `id` seeded from
|
|
446
|
+
* the port's own id — made unique against `existingIds` with a numeric
|
|
447
|
+
* suffix (`text`, `text_2`, `text_3`, …).
|
|
448
|
+
*
|
|
449
|
+
* Seeding the id from the port is a convenience at creation time only: the
|
|
450
|
+
* author edits it like any other field afterwards, and nothing later
|
|
451
|
+
* re-derives it. DN1's concern — a contract silently keyed on internal port
|
|
452
|
+
* names — is about that ongoing coupling, which this does not introduce.
|
|
453
|
+
*/
|
|
454
|
+
export function entryFromBindablePort(candidate, existingIds) {
|
|
455
|
+
const taken = new Set(existingIds);
|
|
456
|
+
let id = candidate.port.id;
|
|
457
|
+
for (let n = 2; taken.has(id); n += 1) {
|
|
458
|
+
id = `${candidate.port.id}_${n}`;
|
|
459
|
+
}
|
|
460
|
+
return {
|
|
461
|
+
id,
|
|
462
|
+
dataType: candidate.port.dataType,
|
|
463
|
+
bindings: [{ nodeId: candidate.nodeId, portId: candidate.port.id }],
|
|
464
|
+
...pullEntryFieldsFromPort(candidate.port)
|
|
465
|
+
};
|
|
466
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import WebMCPFakeAgent from '../stories/WebMCPFakeAgent.svelte';
|
|
4
|
+
import type { NodeMetadata, NodePort, Workflow } from '../types/index.js';
|
|
5
|
+
|
|
6
|
+
// Inline fixtures: importing from src/mocks would make svelte-package emit
|
|
7
|
+
// declaration files outside src/lib.
|
|
8
|
+
const port = (id: string, name: string, type: NodePort['type'], dataType: string): NodePort => ({
|
|
9
|
+
id,
|
|
10
|
+
name,
|
|
11
|
+
type,
|
|
12
|
+
dataType
|
|
13
|
+
});
|
|
14
|
+
const nodes: NodeMetadata[] = [
|
|
15
|
+
{
|
|
16
|
+
node_type_id: 'chat_model',
|
|
17
|
+
name: 'Chat Model',
|
|
18
|
+
description: 'Chat completion using an LLM provider',
|
|
19
|
+
category: 'ai',
|
|
20
|
+
version: '1.0.0',
|
|
21
|
+
type: 'default',
|
|
22
|
+
icon: 'mdi:robot',
|
|
23
|
+
inputs: [port('message', 'Message', 'input', 'string')],
|
|
24
|
+
outputs: [port('response', 'Response', 'output', 'string')],
|
|
25
|
+
configSchema: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
model: { type: 'string', title: 'Model', default: 'gpt-4o' },
|
|
29
|
+
temperature: { type: 'number', title: 'Temperature', default: 0.7 }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
node_type_id: 'chat_output',
|
|
35
|
+
name: 'Chat Output',
|
|
36
|
+
description: 'Show a message to the user',
|
|
37
|
+
category: 'outputs',
|
|
38
|
+
version: '1.0.0',
|
|
39
|
+
type: 'default',
|
|
40
|
+
icon: 'mdi:message-text',
|
|
41
|
+
inputs: [port('message', 'Message', 'input', 'string')],
|
|
42
|
+
outputs: [],
|
|
43
|
+
configSchema: { type: 'object', properties: {} }
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
node_type_id: 'text_input',
|
|
47
|
+
name: 'Text Input',
|
|
48
|
+
description: 'Accept text from the user',
|
|
49
|
+
category: 'inputs',
|
|
50
|
+
version: '1.0.0',
|
|
51
|
+
type: 'default',
|
|
52
|
+
icon: 'mdi:text-box',
|
|
53
|
+
inputs: [],
|
|
54
|
+
outputs: [port('value', 'Value', 'output', 'string')],
|
|
55
|
+
configSchema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: { defaultValue: { type: 'string', title: 'Default value', default: '' } }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
const workflow: Workflow = {
|
|
63
|
+
id: 'webmcp-demo',
|
|
64
|
+
name: 'WebMCP demo',
|
|
65
|
+
nodes: [
|
|
66
|
+
{
|
|
67
|
+
id: 'text_input.1',
|
|
68
|
+
type: 'default',
|
|
69
|
+
position: { x: 80, y: 120 },
|
|
70
|
+
data: { label: 'Text Input', config: {}, metadata: nodes[2] }
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
edges: [],
|
|
74
|
+
metadata: {
|
|
75
|
+
schemaVersion: '1.0.0',
|
|
76
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
77
|
+
updatedAt: '2026-01-01T00:00:00Z'
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const { Story } = defineMeta({
|
|
82
|
+
title: 'Integrations/WebMCP',
|
|
83
|
+
component: WebMCPFakeAgent,
|
|
84
|
+
tags: ['autodocs'],
|
|
85
|
+
parameters: {
|
|
86
|
+
layout: 'fullscreen',
|
|
87
|
+
docs: {
|
|
88
|
+
description: {
|
|
89
|
+
component:
|
|
90
|
+
'The editor’s commands registered as WebMCP editor tools, driven by a fake browser agent in the side panel. ' +
|
|
91
|
+
'Pick a tool, invoke it, and approve or reject the change in the dialog that the real agent would trigger.'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
args: { nodes, workflow }
|
|
96
|
+
});
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<Story name="Fake agent — confirm gate" args={{ approval: 'confirm' }} />
|
|
100
|
+
|
|
101
|
+
<Story name="Fake agent — auto approval" args={{ approval: 'auto' }} />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const WebMCP: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type WebMCP = InstanceType<typeof WebMCP>;
|
|
18
|
+
export default WebMCP;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
WebMCPConfirm
|
|
3
|
+
|
|
4
|
+
The built-in approval dialog for mutating editor tools called by a browser
|
|
5
|
+
agent. Lists what is about to run and asks the person at the keyboard.
|
|
6
|
+
Mounted imperatively by `gate.ts` into the host's container (default
|
|
7
|
+
`document.body`), one at a time; a second request while one is open is
|
|
8
|
+
refused upstream with a `busy` error rather than stacking dialogs.
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { m } from '../messages/index.js';
|
|
13
|
+
import { focusOnMount } from '../utils/focus.js';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
/** Editor / workflow name, so two editors on one page are distinguishable. */
|
|
17
|
+
editorName: string;
|
|
18
|
+
/** One human-readable line per command (see `describeCommand`). */
|
|
19
|
+
lines: string[];
|
|
20
|
+
/** Called exactly once with the decision. */
|
|
21
|
+
onResolve: (approved: boolean) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let { editorName, lines, onResolve }: Props = $props();
|
|
25
|
+
|
|
26
|
+
let rejectButton = $state<HTMLButtonElement | null>(null);
|
|
27
|
+
let approveButton = $state<HTMLButtonElement | null>(null);
|
|
28
|
+
|
|
29
|
+
// Focus starts on Apply and stays inside the dialog: Tab and Shift+Tab move
|
|
30
|
+
// between the two buttons, Escape rejects. The handler sits on the dialog
|
|
31
|
+
// itself, which holds focus through its buttons, not on the window.
|
|
32
|
+
function handleKeydown(event: KeyboardEvent): void {
|
|
33
|
+
if (event.key === 'Escape') {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
onResolve(false);
|
|
36
|
+
} else if (event.key === 'Tab') {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
(document.activeElement === approveButton ? rejectButton : approveButton)?.focus();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div class="fd-webmcp-confirm" data-testid="flowdrop-webmcp-confirm">
|
|
44
|
+
<div
|
|
45
|
+
class="fd-webmcp-confirm__dialog"
|
|
46
|
+
role="alertdialog"
|
|
47
|
+
aria-modal="true"
|
|
48
|
+
aria-labelledby="fd-webmcp-confirm-title"
|
|
49
|
+
aria-describedby="fd-webmcp-confirm-list"
|
|
50
|
+
tabindex="-1"
|
|
51
|
+
onkeydown={handleKeydown}
|
|
52
|
+
>
|
|
53
|
+
<h2 id="fd-webmcp-confirm-title" class="fd-webmcp-confirm__title">
|
|
54
|
+
{m().webmcp.confirmTitle({ name: editorName })}
|
|
55
|
+
</h2>
|
|
56
|
+
<p class="fd-webmcp-confirm__hint">
|
|
57
|
+
{m().webmcp.confirmCount({ count: lines.length })}
|
|
58
|
+
</p>
|
|
59
|
+
<ol id="fd-webmcp-confirm-list" class="fd-webmcp-confirm__list">
|
|
60
|
+
{#each lines as line, i (i)}
|
|
61
|
+
<li class="fd-webmcp-confirm__line">{line}</li>
|
|
62
|
+
{/each}
|
|
63
|
+
</ol>
|
|
64
|
+
<div class="fd-webmcp-confirm__actions">
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
class="fd-webmcp-confirm__button fd-webmcp-confirm__button--reject"
|
|
68
|
+
data-testid="flowdrop-webmcp-reject"
|
|
69
|
+
bind:this={rejectButton}
|
|
70
|
+
onclick={() => onResolve(false)}
|
|
71
|
+
>
|
|
72
|
+
{m().webmcp.reject}
|
|
73
|
+
</button>
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
class="fd-webmcp-confirm__button fd-webmcp-confirm__button--approve"
|
|
77
|
+
data-testid="flowdrop-webmcp-approve"
|
|
78
|
+
bind:this={approveButton}
|
|
79
|
+
{@attach focusOnMount()}
|
|
80
|
+
onclick={() => onResolve(true)}
|
|
81
|
+
>
|
|
82
|
+
{m().webmcp.apply}
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<style>
|
|
89
|
+
.fd-webmcp-confirm {
|
|
90
|
+
position: fixed;
|
|
91
|
+
inset: 0;
|
|
92
|
+
z-index: 10000;
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
background: rgb(0 0 0 / 0.4);
|
|
97
|
+
font-family: inherit;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.fd-webmcp-confirm__dialog {
|
|
101
|
+
min-width: 20rem;
|
|
102
|
+
max-width: min(36rem, calc(100vw - 2rem));
|
|
103
|
+
max-height: calc(100vh - 2rem);
|
|
104
|
+
overflow: auto;
|
|
105
|
+
padding: var(--fd-space-lg, 1rem);
|
|
106
|
+
border: 1px solid var(--fd-border, #d4d4d8);
|
|
107
|
+
border-radius: var(--fd-radius-lg, 0.75rem);
|
|
108
|
+
background: var(--fd-background, #fff);
|
|
109
|
+
color: var(--fd-foreground, #18181b);
|
|
110
|
+
box-shadow: var(--fd-shadow-xl, 0 20px 40px rgb(0 0 0 / 0.25));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.fd-webmcp-confirm__title {
|
|
114
|
+
margin: 0 0 var(--fd-space-xs, 0.25rem);
|
|
115
|
+
font-size: var(--fd-text-md, 1rem);
|
|
116
|
+
font-weight: 600;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.fd-webmcp-confirm__hint {
|
|
120
|
+
margin: 0 0 var(--fd-space-md, 0.75rem);
|
|
121
|
+
font-size: var(--fd-text-sm, 0.875rem);
|
|
122
|
+
color: var(--fd-muted-foreground, #71717a);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.fd-webmcp-confirm__list {
|
|
126
|
+
margin: 0 0 var(--fd-space-lg, 1rem);
|
|
127
|
+
padding: var(--fd-space-sm, 0.5rem) var(--fd-space-sm, 0.5rem) var(--fd-space-sm, 0.5rem)
|
|
128
|
+
var(--fd-space-xl, 1.5rem);
|
|
129
|
+
border-radius: var(--fd-radius-md, 0.5rem);
|
|
130
|
+
background: var(--fd-muted, #f4f4f5);
|
|
131
|
+
font-family: var(--fd-font-mono, ui-monospace, monospace);
|
|
132
|
+
font-size: var(--fd-text-sm, 0.875rem);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.fd-webmcp-confirm__line {
|
|
136
|
+
padding: 0.125rem 0;
|
|
137
|
+
overflow-wrap: anywhere;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.fd-webmcp-confirm__actions {
|
|
141
|
+
display: flex;
|
|
142
|
+
justify-content: flex-end;
|
|
143
|
+
gap: var(--fd-space-sm, 0.5rem);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.fd-webmcp-confirm__button {
|
|
147
|
+
padding: var(--fd-space-xs, 0.375rem) var(--fd-space-md, 0.75rem);
|
|
148
|
+
border: 1px solid var(--fd-border, #d4d4d8);
|
|
149
|
+
border-radius: var(--fd-control-radius, 0.375rem);
|
|
150
|
+
background: var(--fd-background, #fff);
|
|
151
|
+
color: inherit;
|
|
152
|
+
font: inherit;
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.fd-webmcp-confirm__button--approve {
|
|
157
|
+
border-color: var(--fd-primary, #2563eb);
|
|
158
|
+
background: var(--fd-primary, #2563eb);
|
|
159
|
+
color: var(--fd-primary-foreground, #fff);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.fd-webmcp-confirm__button--approve:hover {
|
|
163
|
+
background: var(--fd-primary-hover, #1d4ed8);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.fd-webmcp-confirm__button:focus-visible {
|
|
167
|
+
outline: 2px solid var(--fd-primary, #2563eb);
|
|
168
|
+
outline-offset: 2px;
|
|
169
|
+
}
|
|
170
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** Editor / workflow name, so two editors on one page are distinguishable. */
|
|
3
|
+
editorName: string;
|
|
4
|
+
/** One human-readable line per command (see `describeCommand`). */
|
|
5
|
+
lines: string[];
|
|
6
|
+
/** Called exactly once with the decision. */
|
|
7
|
+
onResolve: (approved: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const WebMCPConfirm: import("svelte").Component<Props, {}, "">;
|
|
10
|
+
type WebMCPConfirm = ReturnType<typeof WebMCPConfirm>;
|
|
11
|
+
export default WebMCPConfirm;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebMCP adapter — tool descriptors.
|
|
3
|
+
*
|
|
4
|
+
* Maps the command union to `{verb, description, inputSchema, readOnly,
|
|
5
|
+
* toCommands}` records. Transport-free: no DOM, no Svelte, nothing from the
|
|
6
|
+
* runtime — so the same records can back a server-side MCP endpoint later.
|
|
7
|
+
*
|
|
8
|
+
* The schemas are written by hand next to the interfaces they mirror
|
|
9
|
+
* (`commands/types.ts`). Each exposed command is one record in `COMMANDS`:
|
|
10
|
+
* its description, its input schema, how validated arguments become the
|
|
11
|
+
* command, and how the command reads back to a human in the confirm dialog.
|
|
12
|
+
* The coverage test in `tests/unit/webmcp` asserts every literal of the
|
|
13
|
+
* `Command` union is either exposed here or on the explicit exclusion list,
|
|
14
|
+
* and that every exposed record carries all four parts, so a new DSL verb
|
|
15
|
+
* cannot slip through unclassified or half-described.
|
|
16
|
+
*
|
|
17
|
+
* @module webmcp/descriptors
|
|
18
|
+
*/
|
|
19
|
+
import type { Command } from '../commands/types.js';
|
|
20
|
+
import { VIEW_COMMAND_TYPES } from '../chat/commandClassifier.js';
|
|
21
|
+
import { type ToolDescriptor, type ToolInputSchema } from './types.js';
|
|
22
|
+
import { validateToolArgs } from './validate.js';
|
|
23
|
+
export { validateToolArgs };
|
|
24
|
+
/** Command types exposed as one tool each (verb === command type). */
|
|
25
|
+
export declare const EXPOSED_COMMAND_TYPES: readonly ["add_node", "delete_node", "rename_node", "move_node", "swap_node", "set_config", "get_config", "connect", "disconnect_ports", "disconnect_node", "list_nodes", "list_edges", "list_types", "info", "undo", "redo", "auto_layout", "beautify_layout"];
|
|
26
|
+
/**
|
|
27
|
+
* Command types folded into the single `view` tool (its `action` enum). The
|
|
28
|
+
* list itself lives in the command classifier, next to `isViewCommand`, so
|
|
29
|
+
* the chat panel and this adapter cannot disagree about what a view command is.
|
|
30
|
+
*/
|
|
31
|
+
export { VIEW_COMMAND_TYPES };
|
|
32
|
+
/**
|
|
33
|
+
* Command types deliberately not exposed.
|
|
34
|
+
* - `clear` wipes the whole workflow; an agent can delete nodes one by one and
|
|
35
|
+
* each deletion is gated.
|
|
36
|
+
* - `help` describes the text DSL; the tool schemas are the help.
|
|
37
|
+
*/
|
|
38
|
+
export declare const EXCLUDED_COMMAND_TYPES: readonly ["clear", "help"];
|
|
39
|
+
/** Extra tool verbs that are not command types. */
|
|
40
|
+
export declare const COMPOSITE_VERBS: readonly ["view", "batch"];
|
|
41
|
+
type Args = Record<string, unknown>;
|
|
42
|
+
type ExposedType = (typeof EXPOSED_COMMAND_TYPES)[number];
|
|
43
|
+
/** The record for one exposed command — for tests that check its shape. */
|
|
44
|
+
export declare function commandRecord(type: ExposedType): {
|
|
45
|
+
description: string;
|
|
46
|
+
inputSchema: ToolInputSchema;
|
|
47
|
+
build: (args: Args) => Command;
|
|
48
|
+
summarize: (command: Command) => string;
|
|
49
|
+
};
|
|
50
|
+
export interface BuildDescriptorsOptions {
|
|
51
|
+
/** Register the `view` tool. Default true. */
|
|
52
|
+
view?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build the descriptor list. Pure; call it as often as you like.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildToolDescriptors(options?: BuildDescriptorsOptions): ToolDescriptor[];
|
|
58
|
+
/** One line describing a command for a human about to approve it. */
|
|
59
|
+
export declare function describeCommand(command: Command): string;
|