@flowdrop/flowdrop 2.7.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 +31 -1
- package/dist/api/enhanced-client.d.ts +29 -1
- package/dist/api/enhanced-client.js +83 -9
- 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/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/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/editor/index.d.ts +1 -1
- package/dist/editor/index.js +1 -1
- package/dist/messages/defaults.d.ts +41 -0
- package/dist/messages/defaults.js +20 -0
- package/dist/services/chatService.d.ts +21 -3
- package/dist/services/chatService.js +33 -1
- package/dist/services/globalSave.js +3 -1
- 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/styles/toast.css +62 -0
- package/dist/svelte-app.d.ts +12 -2
- package/dist/svelte-app.js +29 -12
- 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/settings.d.ts +18 -1
- package/dist/types/settings.js +1 -0
- package/dist/webmcp/WebMCPConfirm.svelte +129 -68
- package/dist/webmcp/WebMCPConfirm.svelte.d.ts +2 -2
- package/dist/webmcp/descriptors.d.ts +7 -0
- package/dist/webmcp/descriptors.js +51 -0
- package/dist/webmcp/gate.d.ts +13 -7
- package/dist/webmcp/gate.js +8 -53
- package/dist/webmcp/index.d.ts +5 -2
- package/dist/webmcp/index.js +3 -1
- package/dist/webmcp/register.d.ts +11 -10
- package/dist/webmcp/register.js +59 -384
- package/dist/webmcp/runtime.d.ts +33 -0
- package/dist/webmcp/runtime.js +500 -0
- package/dist/webmcp/types.d.ts +92 -0
- package/package.json +1 -1
package/dist/webmcp/gate.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { mount, unmount } from 'svelte';
|
|
23
23
|
import { defaultMessages, mergeMessages, messagesContext } from '../messages/index.js';
|
|
24
|
-
import { describeCommand } from './descriptors.js';
|
|
24
|
+
import { describeCommand, summarizeCommands } from './descriptors.js';
|
|
25
25
|
import WebMCPConfirm from './WebMCPConfirm.svelte';
|
|
26
26
|
/** A second mutating call arrived while a decision was pending. */
|
|
27
27
|
export class GateBusyError extends Error {
|
|
@@ -31,57 +31,6 @@ export class GateBusyError extends Error {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
const CONSEQUENTIAL_TOOLS = new Set(['save', 'run']);
|
|
34
|
-
/**
|
|
35
|
-
* One sentence saying what a list of commands does, for the dialog's hint:
|
|
36
|
-
* "3 changes — adds 2 nodes, connects 1 edge. Applied together, undone together."
|
|
37
|
-
* Returns `undefined` for a single command, whose one line already says it all.
|
|
38
|
-
*/
|
|
39
|
-
export function summarizeCommands(commands, m) {
|
|
40
|
-
if (commands.length < 2)
|
|
41
|
-
return undefined;
|
|
42
|
-
let adds = 0;
|
|
43
|
-
let deletes = 0;
|
|
44
|
-
let connects = 0;
|
|
45
|
-
let disconnects = 0;
|
|
46
|
-
let configs = 0;
|
|
47
|
-
let other = 0;
|
|
48
|
-
for (const c of commands) {
|
|
49
|
-
switch (c.type) {
|
|
50
|
-
case 'add_node':
|
|
51
|
-
adds++;
|
|
52
|
-
break;
|
|
53
|
-
case 'delete_node':
|
|
54
|
-
deletes++;
|
|
55
|
-
break;
|
|
56
|
-
case 'connect':
|
|
57
|
-
connects++;
|
|
58
|
-
break;
|
|
59
|
-
case 'disconnect_ports':
|
|
60
|
-
case 'disconnect_node':
|
|
61
|
-
disconnects++;
|
|
62
|
-
break;
|
|
63
|
-
case 'set_config':
|
|
64
|
-
configs++;
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
other++;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const parts = [];
|
|
71
|
-
if (adds)
|
|
72
|
-
parts.push(m.summaryAdds({ count: adds }));
|
|
73
|
-
if (deletes)
|
|
74
|
-
parts.push(m.summaryDeletes({ count: deletes }));
|
|
75
|
-
if (connects)
|
|
76
|
-
parts.push(m.summaryConnects({ count: connects }));
|
|
77
|
-
if (disconnects)
|
|
78
|
-
parts.push(m.summaryDisconnects({ count: disconnects }));
|
|
79
|
-
if (configs)
|
|
80
|
-
parts.push(m.summaryConfigs({ count: configs }));
|
|
81
|
-
if (other)
|
|
82
|
-
parts.push(m.summaryOther({ count: other }));
|
|
83
|
-
return m.batchSummary({ count: commands.length, parts: parts.join(', ') });
|
|
84
|
-
}
|
|
85
34
|
export function createApprovalGate(approval, options) {
|
|
86
35
|
let pending = false;
|
|
87
36
|
let dismiss = null;
|
|
@@ -117,6 +66,9 @@ export function createApprovalGate(approval, options) {
|
|
|
117
66
|
return [m.runLine({ name: options.editorName() })];
|
|
118
67
|
return commands.map(describeCommand);
|
|
119
68
|
}
|
|
69
|
+
function resolveTitle(request) {
|
|
70
|
+
return request.title ?? messages().webmcp.confirmTitle({ name: options.editorName() });
|
|
71
|
+
}
|
|
120
72
|
function resolveHint(commands, request) {
|
|
121
73
|
if (request.hint !== undefined)
|
|
122
74
|
return request.hint;
|
|
@@ -153,7 +105,7 @@ export function createApprovalGate(approval, options) {
|
|
|
153
105
|
target: host,
|
|
154
106
|
context: messagesContext(messages),
|
|
155
107
|
props: {
|
|
156
|
-
|
|
108
|
+
title: resolveTitle(request),
|
|
157
109
|
lines: resolveLines(commands, request),
|
|
158
110
|
hint: resolveHint(commands, request),
|
|
159
111
|
offerRemember: offerRemember && !isConsequential(request),
|
|
@@ -167,6 +119,9 @@ export function createApprovalGate(approval, options) {
|
|
|
167
119
|
get busy() {
|
|
168
120
|
return pending;
|
|
169
121
|
},
|
|
122
|
+
get asks() {
|
|
123
|
+
return approval !== 'auto';
|
|
124
|
+
},
|
|
170
125
|
get editsPreApproved() {
|
|
171
126
|
return editsPreApproved;
|
|
172
127
|
},
|
package/dist/webmcp/index.d.ts
CHANGED
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export { attachWebMCP, detectModelContext, DEFAULT_PREFIX } from './register.js';
|
|
28
|
-
export {
|
|
28
|
+
export { createToolRuntime, buildHostToolDescriptors } from './runtime.js';
|
|
29
|
+
export { createApprovalGate, GateBusyError } from './gate.js';
|
|
30
|
+
export type { ApprovalGate, GateRequest, CreateGateOptions } from './gate.js';
|
|
31
|
+
export { buildToolDescriptors, describeCommand, summarizeCommands, EXPOSED_COMMAND_TYPES, VIEW_COMMAND_TYPES, EXCLUDED_COMMAND_TYPES, COMPOSITE_VERBS } from './descriptors.js';
|
|
29
32
|
export type { BuildDescriptorsOptions } from './descriptors.js';
|
|
30
33
|
export { validateToolArgs, VALIDATOR_KEYWORDS } from './validate.js';
|
|
31
34
|
export { ToolArgumentError } from './types.js';
|
|
@@ -33,4 +36,4 @@ export { createFakeModelContext } from './fake.js';
|
|
|
33
36
|
export type { FakeModelContext } from './fake.js';
|
|
34
37
|
export { createBridgedModelContext, installBridgedModelContext } from './bridge.js';
|
|
35
38
|
export type { WebMCPWidgetLike, BridgedModelContext } from './bridge.js';
|
|
36
|
-
export type { ToolDescriptor, ToolInputSchema, ToolSchemaProperty, ToolResult, ToolExecuteOptions, RegisteredToolDefinition, RegisterToolOptions, ModelContextLike, WebMCPApproval, WebMCPApprovalRequest, HostCode, HostEnvelope, RunStarted, RunPending, RunStatus, WebMCPOptions, WebMCPMountOptions, WebMCPHandle } from './types.js';
|
|
39
|
+
export type { ToolDescriptor, ToolInputSchema, ToolSchemaProperty, ToolResult, ToolExecuteOptions, RegisteredToolDefinition, RegisterToolOptions, ModelContextLike, WebMCPApproval, WebMCPApprovalRequest, HostCode, HostEnvelope, RunStarted, RunPending, RunStatus, WebMCPOptions, WebMCPMountOptions, WebMCPHandle, HostHooks, HostToolDescriptor, ToolPreview, ToolRuntime, ToolRuntimeOptions } from './types.js';
|
package/dist/webmcp/index.js
CHANGED
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export { attachWebMCP, detectModelContext, DEFAULT_PREFIX } from './register.js';
|
|
28
|
-
export {
|
|
28
|
+
export { createToolRuntime, buildHostToolDescriptors } from './runtime.js';
|
|
29
|
+
export { createApprovalGate, GateBusyError } from './gate.js';
|
|
30
|
+
export { buildToolDescriptors, describeCommand, summarizeCommands, EXPOSED_COMMAND_TYPES, VIEW_COMMAND_TYPES, EXCLUDED_COMMAND_TYPES, COMPOSITE_VERBS } from './descriptors.js';
|
|
29
31
|
export { validateToolArgs, VALIDATOR_KEYWORDS } from './validate.js';
|
|
30
32
|
export { ToolArgumentError } from './types.js';
|
|
31
33
|
export { createFakeModelContext } from './fake.js';
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WebMCP adapter — registration.
|
|
3
3
|
*
|
|
4
|
-
* The only file that touches the
|
|
5
|
-
* back to `navigator.modelContext`). Builds
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
* detaching is a single `abort()`.
|
|
4
|
+
* The only file that touches the browser's model context
|
|
5
|
+
* (`document.modelContext`, falling back to `navigator.modelContext`). Builds
|
|
6
|
+
* a tool runtime for the instance, registers each of its tools with an
|
|
7
|
+
* `execute` that delegates to `runTool()`, and registers the lot under one
|
|
8
|
+
* AbortSignal so detaching is a single `abort()`. What a call *does* — validation, the gate, the batch —
|
|
9
|
+
* lives in `runtime.ts`, which the chat panel shares.
|
|
9
10
|
*
|
|
10
11
|
* @module webmcp/register
|
|
11
12
|
*/
|
|
12
13
|
import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
|
|
13
|
-
import {
|
|
14
|
+
import type { ModelContextLike, WebMCPHandle, WebMCPOptions } from './types.js';
|
|
14
15
|
export declare const DEFAULT_PREFIX = "flowdrop";
|
|
15
16
|
/**
|
|
16
|
-
* Find the WebMCP
|
|
17
|
+
* Find the WebMCP model context on this page, or `null` when the browser has none.
|
|
17
18
|
* Structural: anything with a callable `registerTool` counts.
|
|
18
19
|
*/
|
|
19
20
|
export declare function detectModelContext(): ModelContextLike | null;
|
|
@@ -21,12 +22,12 @@ export declare function detectModelContext(): ModelContextLike | null;
|
|
|
21
22
|
* Register the editor's commands as WebMCP tools for `instance`.
|
|
22
23
|
*
|
|
23
24
|
* Returns `null` — with no console output — when the page has no WebMCP
|
|
24
|
-
*
|
|
25
|
-
* already registered on this
|
|
25
|
+
* model context, so hosts can call it unconditionally. Throws when the prefix is
|
|
26
|
+
* already registered on this model context (two editors on one page need distinct
|
|
26
27
|
* prefixes).
|
|
27
28
|
*
|
|
28
29
|
* Registration settles asynchronously: `handle.tools` lists the tools the
|
|
29
|
-
*
|
|
30
|
+
* model context has accepted so far and `handle.ready` resolves when every
|
|
30
31
|
* registration has settled. The registration is torn down by
|
|
31
32
|
* `handle.detach()` or automatically when `instance.destroy()` runs.
|
|
32
33
|
*/
|