@flowdrop/flowdrop 2.9.0 → 2.10.1
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 +200 -0
- package/dist/commands/executor.js +52 -8
- package/dist/commands/types.d.ts +3 -0
- package/dist/components/App.svelte +8 -0
- package/dist/components/App.svelte.d.ts +6 -0
- package/dist/components/CanvasContextMenu.stories.svelte +63 -0
- package/dist/components/CanvasContextMenu.stories.svelte.d.ts +19 -0
- package/dist/components/CanvasContextMenu.svelte +259 -0
- package/dist/components/CanvasContextMenu.svelte.d.ts +16 -0
- package/dist/components/CanvasController.svelte +24 -2
- package/dist/components/CanvasController.svelte.d.ts +16 -0
- package/dist/components/EdgeRefresher.svelte +1 -1
- package/dist/components/FlowDropZone.svelte +11 -7
- package/dist/components/FlowDropZone.svelte.d.ts +12 -0
- package/dist/components/PortCoordinateTracker.svelte +1 -1
- package/dist/components/UniversalNode.svelte +12 -13
- package/dist/components/WorkflowEditor.svelte +486 -149
- package/dist/components/WorkflowEditor.svelte.d.ts +7 -0
- package/dist/components/WorkflowInterfaceEditor.svelte +28 -3
- package/dist/components/WorkflowInterfaceEntryCard.svelte +112 -2
- package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +3 -1
- package/dist/components/nodes/CaptionNode.stories.svelte +65 -0
- package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +18 -0
- package/dist/components/nodes/CaptionNode.svelte +313 -0
- package/dist/components/nodes/CaptionNode.svelte.d.ts +16 -0
- package/dist/components/nodes/NotesNode.svelte +6 -0
- package/dist/components/playground/ChatBubble.svelte +2 -0
- package/dist/components/playground/ChatInput.svelte +18 -34
- package/dist/components/playground/ChatInput.svelte.d.ts +7 -0
- package/dist/components/playground/ControlPanel.svelte +27 -0
- package/dist/components/playground/ControlPanel.svelte.d.ts +12 -0
- package/dist/components/playground/ExecutionLogs.svelte +11 -8
- package/dist/components/playground/InterfaceInputForm.svelte +74 -0
- package/dist/components/playground/InterfaceInputForm.svelte.d.ts +14 -0
- package/dist/components/playground/LogRow.svelte +2 -0
- package/dist/components/playground/MessageCard.svelte +15 -3
- package/dist/components/playground/MessageNotice.svelte +2 -0
- package/dist/components/playground/MessageStream.svelte +87 -23
- package/dist/components/playground/OriginBadge.svelte +48 -0
- package/dist/components/playground/OriginBadge.svelte.d.ts +7 -0
- package/dist/components/playground/Playground.svelte +155 -38
- package/dist/components/playground/messageDisplay.d.ts +23 -1
- package/dist/components/playground/messageDisplay.js +49 -0
- package/dist/config/endpoints.d.ts +65 -0
- package/dist/config/endpoints.js +39 -0
- package/dist/core/index.d.ts +6 -3
- package/dist/core/index.js +2 -1
- package/dist/editor/contextMenu.d.ts +107 -0
- package/dist/editor/contextMenu.js +134 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/messages/defaults.d.ts +63 -0
- package/dist/messages/defaults.js +59 -0
- package/dist/openapi/v1/openapi.yaml +356 -7
- package/dist/playground/commands/registry.js +4 -2
- package/dist/playground/index.d.ts +3 -2
- package/dist/playground/index.js +2 -1
- package/dist/registry/builtinNodeTypes.d.ts +1 -1
- package/dist/registry/builtinNodeTypes.js +1 -0
- package/dist/registry/builtinNodes.js +13 -0
- package/dist/registry/nodeComponentRegistry.d.ts +18 -0
- package/dist/registry/nodeComponentRegistry.js +14 -2
- package/dist/schemas/v1/workflow.schema.json +22 -1
- package/dist/services/historyService.d.ts +1 -1
- package/dist/services/historyService.js +2 -2
- package/dist/services/playgroundService.d.ts +35 -1
- package/dist/services/playgroundService.js +82 -36
- package/dist/stores/inlineEditStore.svelte.d.ts +35 -0
- package/dist/stores/inlineEditStore.svelte.js +63 -0
- package/dist/stores/instanceContainer.svelte.d.ts +6 -0
- package/dist/stores/instanceContainer.svelte.js +2 -0
- package/dist/stores/playgroundStore.svelte.d.ts +59 -2
- package/dist/stores/playgroundStore.svelte.js +128 -2
- package/dist/styles/base.css +8 -0
- package/dist/styles/tokens.css +8 -0
- package/dist/svelte-app.d.ts +15 -0
- package/dist/svelte-app.js +6 -4
- package/dist/types/index.d.ts +34 -1
- package/dist/types/index.js +11 -0
- package/dist/types/playground.d.ts +90 -9
- package/dist/types/playground.js +12 -4
- package/dist/utils/captionText.d.ts +43 -0
- package/dist/utils/captionText.js +49 -0
- package/dist/utils/focus.d.ts +16 -0
- package/dist/utils/focus.js +40 -0
- package/dist/utils/nodeTypes.js +1 -0
- package/dist/utils/nodeWrapper.js +2 -0
- package/dist/utils/workflowInterface.d.ts +83 -1
- package/dist/utils/workflowInterface.js +192 -1
- package/package.json +2 -2
|
@@ -1163,7 +1163,17 @@
|
|
|
1163
1163
|
"meta": {
|
|
1164
1164
|
"type": "object",
|
|
1165
1165
|
"additionalProperties": true,
|
|
1166
|
-
"description": "Opaque consumer metadata. The library never reads or interprets this field\n— it round-trips verbatim on every read/write. Servers use it to say what\n\"external\" means for them, e.g. `{\"http\": {\"in\": \"query\"}}` or\n`{\"mcp\": {\"toolParam\": true}}`.\n\nKeys under the `fd.` prefix are reserved for future library use — consumers\nmust not write keys starting with `fd.`.\n"
|
|
1166
|
+
"description": "Opaque consumer metadata. The library never reads or interprets this field\n— it round-trips verbatim on every read/write. Servers use it to say what\n\"external\" means for them, e.g. `{\"http\": {\"in\": \"query\"}}` or\n`{\"mcp\": {\"toolParam\": true}}`.\n\nKeys under the `fd.` prefix are reserved for future library use — consumers\nmust not write keys starting with `fd.`.\n\nOne exception, owned by `turn`: on a `history` entry, `limit` (a positive\ninteger, default 10) is how many past user and assistant messages the\nsession fills the port with. The interface editor writes that one key.\n"
|
|
1167
|
+
},
|
|
1168
|
+
"turn": {
|
|
1169
|
+
"allOf": [
|
|
1170
|
+
{
|
|
1171
|
+
"$ref": "#/$defs/WorkflowInterfaceTurn"
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
"description": "What this port is for in a chat turn. Absent means the port plays no part\nin a turn. Validated by the server against its vocabulary.\n"
|
|
1175
|
+
}
|
|
1176
|
+
]
|
|
1167
1177
|
}
|
|
1168
1178
|
},
|
|
1169
1179
|
"required": [
|
|
@@ -1172,6 +1182,17 @@
|
|
|
1172
1182
|
"bindings"
|
|
1173
1183
|
]
|
|
1174
1184
|
},
|
|
1185
|
+
"WorkflowInterfaceTurn": {
|
|
1186
|
+
"type": "string",
|
|
1187
|
+
"enum": [
|
|
1188
|
+
"message",
|
|
1189
|
+
"history",
|
|
1190
|
+
"session_id",
|
|
1191
|
+
"message_id",
|
|
1192
|
+
"reply"
|
|
1193
|
+
],
|
|
1194
|
+
"description": "The chat-turn vocabulary of an interface port.\n\nInputs — at most one entry per value:\n- `message` — the person's message (the turn's content), a string\n- `history` — past user and assistant messages, bounded by `meta.limit`\n (default 10)\n- `session_id` — the session's id\n- `message_id` — the id of the person's message\n\nOutputs — any number:\n- `reply` — each value becomes one assistant message\n"
|
|
1195
|
+
},
|
|
1175
1196
|
"WorkflowMetadata": {
|
|
1176
1197
|
"type": "object",
|
|
1177
1198
|
"properties": {
|
|
@@ -213,7 +213,7 @@ export declare class HistoryService {
|
|
|
213
213
|
/**
|
|
214
214
|
* Create a deep clone of a workflow
|
|
215
215
|
*
|
|
216
|
-
* Strips non-serializable values (e.g., onConfigOpen callbacks) before cloning
|
|
216
|
+
* Strips non-serializable values (e.g., onConfigOpen and onInlineCommit callbacks) before cloning
|
|
217
217
|
* so structuredClone doesn't throw on function references.
|
|
218
218
|
* Falls back to JSON round-trip if structuredClone still fails (e.g., Svelte proxies).
|
|
219
219
|
*/
|
|
@@ -332,7 +332,7 @@ export class HistoryService {
|
|
|
332
332
|
/**
|
|
333
333
|
* Create a deep clone of a workflow
|
|
334
334
|
*
|
|
335
|
-
* Strips non-serializable values (e.g., onConfigOpen callbacks) before cloning
|
|
335
|
+
* Strips non-serializable values (e.g., onConfigOpen and onInlineCommit callbacks) before cloning
|
|
336
336
|
* so structuredClone doesn't throw on function references.
|
|
337
337
|
* Falls back to JSON round-trip if structuredClone still fails (e.g., Svelte proxies).
|
|
338
338
|
*/
|
|
@@ -341,7 +341,7 @@ export class HistoryService {
|
|
|
341
341
|
...workflow,
|
|
342
342
|
nodes: workflow.nodes.map((n) => ({
|
|
343
343
|
...n,
|
|
344
|
-
data: { ...n.data, onConfigOpen: undefined }
|
|
344
|
+
data: { ...n.data, onConfigOpen: undefined, onInlineCommit: undefined }
|
|
345
345
|
}))
|
|
346
346
|
};
|
|
347
347
|
try {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module services/playgroundService
|
|
8
8
|
*/
|
|
9
|
-
import type { PlaygroundSession, PlaygroundMessage, PlaygroundMessagesApiResponse, PlaygroundSessionStatus } from '../types/playground.js';
|
|
9
|
+
import type { PlaygroundSession, PlaygroundMessage, PlaygroundMessageRequest, PlaygroundMessagesApiResponse, PlaygroundSessionStatus, PlaygroundTurnResponse } from '../types/playground.js';
|
|
10
10
|
import type { EndpointConfig } from '../config/endpoints.js';
|
|
11
11
|
import type { AuthProvider } from '../types/auth.js';
|
|
12
12
|
/**
|
|
@@ -52,12 +52,20 @@ export declare class PlaygroundService {
|
|
|
52
52
|
* @returns The endpoint configuration
|
|
53
53
|
*/
|
|
54
54
|
private getConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve a per-session call (see {@link resolveSessionEndpoint}): the
|
|
57
|
+
* `sessions` group when configured, the legacy `playground` key otherwise.
|
|
58
|
+
*
|
|
59
|
+
* @throws Error when the backend does not offer the call
|
|
60
|
+
*/
|
|
61
|
+
private sessionEndpoint;
|
|
55
62
|
/**
|
|
56
63
|
* Generic API request helper
|
|
57
64
|
*
|
|
58
65
|
* @param config - The endpoint configuration
|
|
59
66
|
* @param url - The URL to fetch
|
|
60
67
|
* @param options - Fetch options
|
|
68
|
+
* @param endpointKey - Group whose static headers apply (default `playground`)
|
|
61
69
|
* @returns The parsed JSON response
|
|
62
70
|
*/
|
|
63
71
|
private request;
|
|
@@ -108,9 +116,35 @@ export declare class PlaygroundService {
|
|
|
108
116
|
* @returns Messages and session status
|
|
109
117
|
*/
|
|
110
118
|
getMessages(endpointConfig: EndpointConfig | null, sessionId: string, options?: GetMessagesOptions, authProvider?: AuthProvider): Promise<PlaygroundMessagesApiResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Take a turn in a session: post the person's message and/or named inputs
|
|
121
|
+
* and run the session's workflow on them.
|
|
122
|
+
*
|
|
123
|
+
* Goes to `sessions.turn` when that group is configured, else to the legacy
|
|
124
|
+
* `playground.sendMessage`. The two doors answer differently (the legacy one
|
|
125
|
+
* with the user's message row, the turn door with a turn result), so the
|
|
126
|
+
* answer is returned tagged. The tag follows the door the request went to
|
|
127
|
+
* (the endpoint group), never the shape of the payload; either way the rest
|
|
128
|
+
* of the turn arrives through the messages poll.
|
|
129
|
+
*
|
|
130
|
+
* `content` is optional: a workflow whose interface declares no `message`
|
|
131
|
+
* port takes `inputs` alone, and its server refuses `content` with a 400
|
|
132
|
+
* whose message names the fix. Refusals are thrown as an `Error` carrying
|
|
133
|
+
* the server's message.
|
|
134
|
+
*
|
|
135
|
+
* @param sessionId - The session UUID
|
|
136
|
+
* @param request - `content` (the person's message) and/or `inputs` (named
|
|
137
|
+
* interface inputs); keys left `undefined` are not sent
|
|
138
|
+
*/
|
|
139
|
+
sendTurn(endpointConfig: EndpointConfig | null, sessionId: string, request: PlaygroundMessageRequest, authProvider?: AuthProvider): Promise<PlaygroundTurnResponse>;
|
|
111
140
|
/**
|
|
112
141
|
* Send a message to a playground session
|
|
113
142
|
*
|
|
143
|
+
* @deprecated Use {@link sendTurn}, which also takes a turn without
|
|
144
|
+
* `content` and understands the `sessions.turn` door. This method throws
|
|
145
|
+
* when the configured door answers with a turn result instead of the
|
|
146
|
+
* user's message row.
|
|
147
|
+
*
|
|
114
148
|
* @param sessionId - The session UUID
|
|
115
149
|
* @param content - The message content
|
|
116
150
|
* @param inputs - Optional additional inputs for workflow nodes
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module services/playgroundService
|
|
8
8
|
*/
|
|
9
9
|
import { defaultShouldStopPolling } from '../types/playground.js';
|
|
10
|
-
import { buildEndpointUrl } from '../config/endpoints.js';
|
|
10
|
+
import { buildEndpointUrl, resolveSessionEndpoint } from '../config/endpoints.js';
|
|
11
11
|
import { authenticatedFetch } from '../utils/fetchWithAuth.js';
|
|
12
12
|
import { logger } from '../utils/logger.js';
|
|
13
13
|
/**
|
|
@@ -57,18 +57,35 @@ export class PlaygroundService {
|
|
|
57
57
|
}
|
|
58
58
|
return config;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolve a per-session call (see {@link resolveSessionEndpoint}): the
|
|
62
|
+
* `sessions` group when configured, the legacy `playground` key otherwise.
|
|
63
|
+
*
|
|
64
|
+
* @throws Error when the backend does not offer the call
|
|
65
|
+
*/
|
|
66
|
+
sessionEndpoint(config, key, sessionId) {
|
|
67
|
+
const endpoint = resolveSessionEndpoint(config, key);
|
|
68
|
+
if (!endpoint) {
|
|
69
|
+
throw new Error(`Session ${key} is not supported by this backend`);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
url: buildEndpointUrl(config, endpoint.path, { sessionId }),
|
|
73
|
+
group: endpoint.group
|
|
74
|
+
};
|
|
75
|
+
}
|
|
60
76
|
/**
|
|
61
77
|
* Generic API request helper
|
|
62
78
|
*
|
|
63
79
|
* @param config - The endpoint configuration
|
|
64
80
|
* @param url - The URL to fetch
|
|
65
81
|
* @param options - Fetch options
|
|
82
|
+
* @param endpointKey - Group whose static headers apply (default `playground`)
|
|
66
83
|
* @returns The parsed JSON response
|
|
67
84
|
*/
|
|
68
|
-
async request(config, url, options = {}, authProvider) {
|
|
85
|
+
async request(config, url, options = {}, authProvider, endpointKey = 'playground') {
|
|
69
86
|
const response = await authenticatedFetch(url, options, {
|
|
70
87
|
config,
|
|
71
|
-
endpointKey
|
|
88
|
+
endpointKey,
|
|
72
89
|
authProvider
|
|
73
90
|
});
|
|
74
91
|
if (!response.ok) {
|
|
@@ -140,10 +157,8 @@ export class PlaygroundService {
|
|
|
140
157
|
*/
|
|
141
158
|
async getSession(endpointConfig, sessionId, authProvider) {
|
|
142
159
|
const config = this.getConfig(endpointConfig);
|
|
143
|
-
const url =
|
|
144
|
-
|
|
145
|
-
});
|
|
146
|
-
const response = await this.request(config, url, {}, authProvider);
|
|
160
|
+
const { url, group } = this.sessionEndpoint(config, 'get', sessionId);
|
|
161
|
+
const response = await this.request(config, url, {}, authProvider, group);
|
|
147
162
|
if (!response.data) {
|
|
148
163
|
throw new Error('Session not found');
|
|
149
164
|
}
|
|
@@ -156,12 +171,10 @@ export class PlaygroundService {
|
|
|
156
171
|
*/
|
|
157
172
|
async deleteSession(endpointConfig, sessionId, authProvider) {
|
|
158
173
|
const config = this.getConfig(endpointConfig);
|
|
159
|
-
const url =
|
|
160
|
-
sessionId
|
|
161
|
-
});
|
|
174
|
+
const { url, group } = this.sessionEndpoint(config, 'delete', sessionId);
|
|
162
175
|
await this.request(config, url, {
|
|
163
176
|
method: 'DELETE'
|
|
164
|
-
}, authProvider);
|
|
177
|
+
}, authProvider, group);
|
|
165
178
|
}
|
|
166
179
|
// =========================================================================
|
|
167
180
|
// Message Handling
|
|
@@ -181,9 +194,8 @@ export class PlaygroundService {
|
|
|
181
194
|
*/
|
|
182
195
|
async getMessages(endpointConfig, sessionId, options = {}, authProvider) {
|
|
183
196
|
const config = this.getConfig(endpointConfig);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
});
|
|
197
|
+
const endpoint = this.sessionEndpoint(config, 'messages', sessionId);
|
|
198
|
+
let url = endpoint.url;
|
|
187
199
|
const params = new URLSearchParams();
|
|
188
200
|
if (options.since !== undefined) {
|
|
189
201
|
params.append('since', options.since.toString());
|
|
@@ -201,33 +213,69 @@ export class PlaygroundService {
|
|
|
201
213
|
if (queryString) {
|
|
202
214
|
url = `${url}?${queryString}`;
|
|
203
215
|
}
|
|
204
|
-
return this.request(config, url, {}, authProvider);
|
|
216
|
+
return this.request(config, url, {}, authProvider, endpoint.group);
|
|
205
217
|
}
|
|
206
218
|
/**
|
|
207
|
-
*
|
|
219
|
+
* Take a turn in a session: post the person's message and/or named inputs
|
|
220
|
+
* and run the session's workflow on them.
|
|
221
|
+
*
|
|
222
|
+
* Goes to `sessions.turn` when that group is configured, else to the legacy
|
|
223
|
+
* `playground.sendMessage`. The two doors answer differently (the legacy one
|
|
224
|
+
* with the user's message row, the turn door with a turn result), so the
|
|
225
|
+
* answer is returned tagged. The tag follows the door the request went to
|
|
226
|
+
* (the endpoint group), never the shape of the payload; either way the rest
|
|
227
|
+
* of the turn arrives through the messages poll.
|
|
228
|
+
*
|
|
229
|
+
* `content` is optional: a workflow whose interface declares no `message`
|
|
230
|
+
* port takes `inputs` alone, and its server refuses `content` with a 400
|
|
231
|
+
* whose message names the fix. Refusals are thrown as an `Error` carrying
|
|
232
|
+
* the server's message.
|
|
208
233
|
*
|
|
209
234
|
* @param sessionId - The session UUID
|
|
210
|
-
* @param
|
|
211
|
-
*
|
|
212
|
-
* @returns The created message
|
|
235
|
+
* @param request - `content` (the person's message) and/or `inputs` (named
|
|
236
|
+
* interface inputs); keys left `undefined` are not sent
|
|
213
237
|
*/
|
|
214
|
-
async
|
|
238
|
+
async sendTurn(endpointConfig, sessionId, request, authProvider) {
|
|
215
239
|
const config = this.getConfig(endpointConfig);
|
|
216
|
-
const url =
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
240
|
+
const { url, group } = this.sessionEndpoint(config, 'turn', sessionId);
|
|
241
|
+
const requestBody = {};
|
|
242
|
+
if (request.content !== undefined) {
|
|
243
|
+
requestBody.content = request.content;
|
|
244
|
+
}
|
|
245
|
+
if (request.inputs !== undefined) {
|
|
246
|
+
requestBody.inputs = request.inputs;
|
|
222
247
|
}
|
|
223
248
|
const response = await this.request(config, url, {
|
|
224
249
|
method: 'POST',
|
|
225
250
|
body: JSON.stringify(requestBody)
|
|
226
|
-
}, authProvider);
|
|
227
|
-
|
|
251
|
+
}, authProvider, group);
|
|
252
|
+
const data = response.data;
|
|
253
|
+
if (!data) {
|
|
228
254
|
throw new Error('Failed to send message: No data returned');
|
|
229
255
|
}
|
|
230
|
-
return
|
|
256
|
+
return group === 'sessions'
|
|
257
|
+
? { kind: 'turn', result: data }
|
|
258
|
+
: { kind: 'message', message: data };
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Send a message to a playground session
|
|
262
|
+
*
|
|
263
|
+
* @deprecated Use {@link sendTurn}, which also takes a turn without
|
|
264
|
+
* `content` and understands the `sessions.turn` door. This method throws
|
|
265
|
+
* when the configured door answers with a turn result instead of the
|
|
266
|
+
* user's message row.
|
|
267
|
+
*
|
|
268
|
+
* @param sessionId - The session UUID
|
|
269
|
+
* @param content - The message content
|
|
270
|
+
* @param inputs - Optional additional inputs for workflow nodes
|
|
271
|
+
* @returns The created message
|
|
272
|
+
*/
|
|
273
|
+
async sendMessage(endpointConfig, sessionId, content, inputs, authProvider) {
|
|
274
|
+
const response = await this.sendTurn(endpointConfig, sessionId, { content, inputs }, authProvider);
|
|
275
|
+
if (response.kind !== 'message') {
|
|
276
|
+
throw new Error('The turn endpoint answered with a turn result, not a message; use sendTurn()');
|
|
277
|
+
}
|
|
278
|
+
return response.message;
|
|
231
279
|
}
|
|
232
280
|
/**
|
|
233
281
|
* Stop execution in a playground session
|
|
@@ -236,12 +284,10 @@ export class PlaygroundService {
|
|
|
236
284
|
*/
|
|
237
285
|
async stopExecution(endpointConfig, sessionId, authProvider) {
|
|
238
286
|
const config = this.getConfig(endpointConfig);
|
|
239
|
-
const url =
|
|
240
|
-
sessionId
|
|
241
|
-
});
|
|
287
|
+
const { url, group } = this.sessionEndpoint(config, 'stop', sessionId);
|
|
242
288
|
await this.request(config, url, {
|
|
243
289
|
method: 'POST'
|
|
244
|
-
}, authProvider);
|
|
290
|
+
}, authProvider, group);
|
|
245
291
|
}
|
|
246
292
|
/**
|
|
247
293
|
* Reset a stuck session to idle, cancelling pending messages and clearing
|
|
@@ -256,14 +302,14 @@ export class PlaygroundService {
|
|
|
256
302
|
*/
|
|
257
303
|
async resetSession(endpointConfig, sessionId, authProvider) {
|
|
258
304
|
const config = this.getConfig(endpointConfig);
|
|
259
|
-
const endpoint = config
|
|
305
|
+
const endpoint = resolveSessionEndpoint(config, 'reset');
|
|
260
306
|
if (!endpoint) {
|
|
261
307
|
throw new Error('Session reset is not supported by this backend');
|
|
262
308
|
}
|
|
263
|
-
const url = buildEndpointUrl(config, endpoint, { sessionId });
|
|
309
|
+
const url = buildEndpointUrl(config, endpoint.path, { sessionId });
|
|
264
310
|
await this.request(config, url, {
|
|
265
311
|
method: 'POST'
|
|
266
|
-
}, authProvider);
|
|
312
|
+
}, authProvider, endpoint.group);
|
|
267
313
|
}
|
|
268
314
|
// =========================================================================
|
|
269
315
|
// Polling
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline edit channel.
|
|
3
|
+
*
|
|
4
|
+
* The single way to say "open this node for typing in place". The node
|
|
5
|
+
* context menu's "Edit text" and "Add caption", Enter on a focused node and a
|
|
6
|
+
* double-click all call `request(id)`. A node component that edits in place
|
|
7
|
+
* (registered with `editsInPlace`) registers its starter with `register`, and
|
|
8
|
+
* `request` calls it directly.
|
|
9
|
+
*
|
|
10
|
+
* A callback registry rather than reactive state: a request is an event, not a
|
|
11
|
+
* value, and state read by a per-node `$effect` would need a clear-after-read
|
|
12
|
+
* dance to behave like one. The one case an event cannot cover is a request
|
|
13
|
+
* that arrives before the node has mounted ("Add caption" places the node and
|
|
14
|
+
* asks in the same tick), so one pending id is kept and handed to the starter
|
|
15
|
+
* when it registers.
|
|
16
|
+
*
|
|
17
|
+
* @module stores/inlineEditStore
|
|
18
|
+
*/
|
|
19
|
+
export declare class InlineEditStore {
|
|
20
|
+
#private;
|
|
21
|
+
/** Whether requests are honoured. The editor turns this off in read-only and locked modes. */
|
|
22
|
+
editable: boolean;
|
|
23
|
+
setEditable(editable: boolean): void;
|
|
24
|
+
/**
|
|
25
|
+
* Register the function that starts editing for a node. If a request for
|
|
26
|
+
* this id is already waiting, it runs now.
|
|
27
|
+
*
|
|
28
|
+
* @returns a function that unregisters it (only if it is still the one registered)
|
|
29
|
+
*/
|
|
30
|
+
register(id: string, start: () => void): () => void;
|
|
31
|
+
/** Ask a node to start editing in place. Ignored while the editor is not editable. */
|
|
32
|
+
request(id: string): void;
|
|
33
|
+
/** Forget a pending request (the workflow changed under it). */
|
|
34
|
+
clear(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline edit channel.
|
|
3
|
+
*
|
|
4
|
+
* The single way to say "open this node for typing in place". The node
|
|
5
|
+
* context menu's "Edit text" and "Add caption", Enter on a focused node and a
|
|
6
|
+
* double-click all call `request(id)`. A node component that edits in place
|
|
7
|
+
* (registered with `editsInPlace`) registers its starter with `register`, and
|
|
8
|
+
* `request` calls it directly.
|
|
9
|
+
*
|
|
10
|
+
* A callback registry rather than reactive state: a request is an event, not a
|
|
11
|
+
* value, and state read by a per-node `$effect` would need a clear-after-read
|
|
12
|
+
* dance to behave like one. The one case an event cannot cover is a request
|
|
13
|
+
* that arrives before the node has mounted ("Add caption" places the node and
|
|
14
|
+
* asks in the same tick), so one pending id is kept and handed to the starter
|
|
15
|
+
* when it registers.
|
|
16
|
+
*
|
|
17
|
+
* @module stores/inlineEditStore
|
|
18
|
+
*/
|
|
19
|
+
export class InlineEditStore {
|
|
20
|
+
/** Whether requests are honoured. The editor turns this off in read-only and locked modes. */
|
|
21
|
+
editable = true;
|
|
22
|
+
#starters = new Map();
|
|
23
|
+
/** A request made before its node registered. One is enough: only the latest matters. */
|
|
24
|
+
#pending = null;
|
|
25
|
+
setEditable(editable) {
|
|
26
|
+
this.editable = editable;
|
|
27
|
+
if (!editable)
|
|
28
|
+
this.#pending = null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Register the function that starts editing for a node. If a request for
|
|
32
|
+
* this id is already waiting, it runs now.
|
|
33
|
+
*
|
|
34
|
+
* @returns a function that unregisters it (only if it is still the one registered)
|
|
35
|
+
*/
|
|
36
|
+
register(id, start) {
|
|
37
|
+
this.#starters.set(id, start);
|
|
38
|
+
if (this.#pending === id) {
|
|
39
|
+
this.#pending = null;
|
|
40
|
+
start();
|
|
41
|
+
}
|
|
42
|
+
return () => {
|
|
43
|
+
if (this.#starters.get(id) === start)
|
|
44
|
+
this.#starters.delete(id);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Ask a node to start editing in place. Ignored while the editor is not editable. */
|
|
48
|
+
request(id) {
|
|
49
|
+
if (!this.editable)
|
|
50
|
+
return;
|
|
51
|
+
const start = this.#starters.get(id);
|
|
52
|
+
if (start) {
|
|
53
|
+
start();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.#pending = id;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Forget a pending request (the workflow changed under it). */
|
|
60
|
+
clear() {
|
|
61
|
+
this.#pending = null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -24,6 +24,7 @@ import { InterruptStore } from './interruptStore.svelte.js';
|
|
|
24
24
|
import { CategoriesStore } from './categoriesStore.svelte.js';
|
|
25
25
|
import { PortCoordinateStore } from './portCoordinateStore.svelte.js';
|
|
26
26
|
import { PipelinePanelStore } from './pipelinePanelStore.svelte.js';
|
|
27
|
+
import { InlineEditStore } from './inlineEditStore.svelte.js';
|
|
27
28
|
import { ApiContext } from './apiContext.js';
|
|
28
29
|
import { PortCompatibilityChecker } from '../utils/connections.js';
|
|
29
30
|
import { NodeComponentRegistry } from '../registry/nodeComponentRegistry.js';
|
|
@@ -79,6 +80,11 @@ export interface FlowDropInstance {
|
|
|
79
80
|
readonly portCoordinates: PortCoordinateStore;
|
|
80
81
|
/** Pipeline panel open/close state (instance-scoped persistence). */
|
|
81
82
|
readonly pipelinePanel: PipelinePanelStore;
|
|
83
|
+
/**
|
|
84
|
+
* The "open this node for typing in place" channel. Nodes registered with
|
|
85
|
+
* `editsInPlace` (the caption) watch it for their own id.
|
|
86
|
+
*/
|
|
87
|
+
readonly inlineEdit: InlineEditStore;
|
|
82
88
|
/**
|
|
83
89
|
* The node types this editor currently knows: what `App` fetched (or was
|
|
84
90
|
* given), merged with the format-provided nodes. Written by the editor as
|
|
@@ -21,6 +21,7 @@ import { InterruptStore } from './interruptStore.svelte.js';
|
|
|
21
21
|
import { CategoriesStore } from './categoriesStore.svelte.js';
|
|
22
22
|
import { PortCoordinateStore } from './portCoordinateStore.svelte.js';
|
|
23
23
|
import { PipelinePanelStore } from './pipelinePanelStore.svelte.js';
|
|
24
|
+
import { InlineEditStore } from './inlineEditStore.svelte.js';
|
|
24
25
|
import { ApiContext } from './apiContext.js';
|
|
25
26
|
import { PortCompatibilityChecker } from '../utils/connections.js';
|
|
26
27
|
import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
|
|
@@ -132,6 +133,7 @@ export function createFlowDropInstance(options = {}) {
|
|
|
132
133
|
portCompatibility: new PortCompatibilityChecker(DEFAULT_PORT_CONFIG),
|
|
133
134
|
// The default instance keeps the legacy bare localStorage key.
|
|
134
135
|
pipelinePanel: new PipelinePanelStore(id),
|
|
136
|
+
inlineEdit: new InlineEditStore(),
|
|
135
137
|
nodeTypes: new NodeTypesStore(),
|
|
136
138
|
host: new HostHooksStore(),
|
|
137
139
|
approvalGate: null,
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module stores/playgroundStore
|
|
12
12
|
*/
|
|
13
|
-
import type { PlaygroundSession, PlaygroundMessage, PlaygroundInputField, PlaygroundSessionStatus, PlaygroundMessagesApiResponse, PlaygroundExecution } from '../types/playground.js';
|
|
14
|
-
import type { Workflow } from '../types/index.js';
|
|
13
|
+
import type { PlaygroundSession, PlaygroundTurnResult, PlaygroundMessage, PlaygroundInputField, PlaygroundSessionStatus, PlaygroundMessagesApiResponse, PlaygroundExecution } from '../types/playground.js';
|
|
14
|
+
import type { Workflow, WorkflowInterfaceEntry } from '../types/index.js';
|
|
15
|
+
import { type InterfaceInputsResult, type PlaygroundInputMode } from '../utils/workflowInterface.js';
|
|
15
16
|
/**
|
|
16
17
|
* Playground mutation actions for a {@link PlaygroundStore}.
|
|
17
18
|
*
|
|
@@ -37,6 +38,11 @@ export interface PlaygroundStoreActions {
|
|
|
37
38
|
pinExecution: (executionId: string | null) => void;
|
|
38
39
|
setShowLogs: (value: boolean) => void;
|
|
39
40
|
toggleShowLogs: () => void;
|
|
41
|
+
setTurnPending: (value: boolean) => void;
|
|
42
|
+
lockRunUntilEnabled: () => void;
|
|
43
|
+
releaseRunLock: () => void;
|
|
44
|
+
setFormValues: (values: Record<string, unknown>) => void;
|
|
45
|
+
setLastTurn: (result: PlaygroundTurnResult | null) => void;
|
|
40
46
|
}
|
|
41
47
|
/**
|
|
42
48
|
* Per-instance playground state: sessions, messages, executions, and the
|
|
@@ -55,6 +61,17 @@ export declare class PlaygroundStore {
|
|
|
55
61
|
get messages(): PlaygroundMessage[];
|
|
56
62
|
/** Executing state (derived from server status). */
|
|
57
63
|
get isExecuting(): boolean;
|
|
64
|
+
/** Whether a turn request is in flight (see `setTurnPending`). */
|
|
65
|
+
get turnPending(): boolean;
|
|
66
|
+
/** Whether Run is locked until the backend posts an `enableRun` message. */
|
|
67
|
+
get runLocked(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether a Run control may start a turn now. The one gate any Run control
|
|
70
|
+
* reads (the Playground's button today, a canvas run bar later), so they
|
|
71
|
+
* cannot disagree: nothing is running, no request is in flight and the
|
|
72
|
+
* legacy `enableRun` lock is not holding Run back.
|
|
73
|
+
*/
|
|
74
|
+
get canRun(): boolean;
|
|
58
75
|
/** Loading state. */
|
|
59
76
|
get isLoading(): boolean;
|
|
60
77
|
/** Error state. */
|
|
@@ -85,6 +102,32 @@ export declare class PlaygroundStore {
|
|
|
85
102
|
* schemas for auto-generating input forms.
|
|
86
103
|
*/
|
|
87
104
|
get inputFields(): PlaygroundInputField[];
|
|
105
|
+
/**
|
|
106
|
+
* How a turn is collected, read from the workflow interface's turn ports
|
|
107
|
+
* (see {@link PlaygroundInputMode}). `legacy` while no workflow is set or
|
|
108
|
+
* its interface declares no `turn`.
|
|
109
|
+
*/
|
|
110
|
+
get inputMode(): PlaygroundInputMode;
|
|
111
|
+
/**
|
|
112
|
+
* The interface inputs a person fills in (inputs without a `turn`), in
|
|
113
|
+
* interface order. Empty in `legacy` mode: there the node-based
|
|
114
|
+
* {@link inputFields} apply.
|
|
115
|
+
*/
|
|
116
|
+
get interfaceFormEntries(): WorkflowInterfaceEntry[];
|
|
117
|
+
/** Values of the interface input form, keyed by entry id. */
|
|
118
|
+
get formValues(): Record<string, unknown>;
|
|
119
|
+
/**
|
|
120
|
+
* What a turn would send now: the form's inputs, or which required inputs
|
|
121
|
+
* are still missing. A Run control can open the form on `missing` instead
|
|
122
|
+
* of failing the request.
|
|
123
|
+
*/
|
|
124
|
+
get turnInputs(): InterfaceInputsResult;
|
|
125
|
+
/**
|
|
126
|
+
* The sessions door's answer (pipelineId, status, userMessageId) for the
|
|
127
|
+
* turn just taken; `null` before any turn, and on the legacy door, which
|
|
128
|
+
* answers with a message row instead.
|
|
129
|
+
*/
|
|
130
|
+
get lastTurn(): PlaygroundTurnResult | null;
|
|
88
131
|
/** Whether the workflow has a chat input. */
|
|
89
132
|
get hasChatInput(): boolean;
|
|
90
133
|
/** Session count. */
|
|
@@ -166,6 +209,20 @@ export declare class PlaygroundStore {
|
|
|
166
209
|
setShowLogs(value: boolean): void;
|
|
167
210
|
/** Toggle log message visibility. */
|
|
168
211
|
toggleShowLogs(): void;
|
|
212
|
+
/** Mark a turn request as in flight (or finished). */
|
|
213
|
+
setTurnPending(value: boolean): void;
|
|
214
|
+
/**
|
|
215
|
+
* Lock Run until the backend posts a message with `enableRun` metadata
|
|
216
|
+
* (the legacy protocol). Locking at the current count means only a
|
|
217
|
+
* *newer* flagged message unlocks it.
|
|
218
|
+
*/
|
|
219
|
+
lockRunUntilEnabled(): void;
|
|
220
|
+
/** Replace the interface input form's values. */
|
|
221
|
+
setFormValues(values: Record<string, unknown>): void;
|
|
222
|
+
/** Record the sessions door's answer for the turn just taken (`null` clears it). */
|
|
223
|
+
setLastTurn(result: PlaygroundTurnResult | null): void;
|
|
224
|
+
/** Free Run again, e.g. because the run was refused and no `enableRun` will come. */
|
|
225
|
+
releaseRunLock(): void;
|
|
169
226
|
/**
|
|
170
227
|
* Apply a server response to the store. All message and status updates from
|
|
171
228
|
* the server flow through here — polling callback, manual fetches, interrupt
|