@flowdrop/flowdrop 2.5.0 → 2.7.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 +59 -0
- package/dist/chat/commandClassifier.d.ts +19 -1
- package/dist/chat/commandClassifier.js +33 -1
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.js +1 -1
- 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 +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/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/core/index.d.ts +1 -1
- package/dist/messages/context.d.ts +6 -0
- package/dist/messages/context.js +8 -0
- package/dist/messages/defaults.d.ts +78 -2
- package/dist/messages/defaults.js +50 -3
- package/dist/messages/index.d.ts +1 -1
- package/dist/messages/index.js +1 -1
- package/dist/services/globalSave.d.ts +7 -1
- package/dist/services/globalSave.js +17 -3
- package/dist/stores/instanceContainer.svelte.d.ts +26 -0
- package/dist/stores/instanceContainer.svelte.js +24 -0
- package/dist/stores/workflowStore.svelte.d.ts +10 -0
- package/dist/stores/workflowStore.svelte.js +15 -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 +6 -0
- package/dist/svelte-app.d.ts +24 -2
- package/dist/svelte-app.js +65 -3
- package/dist/types/index.d.ts +49 -0
- 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 +216 -0
- package/dist/webmcp/WebMCPConfirm.svelte.d.ts +21 -0
- package/dist/webmcp/bridge.d.ts +63 -0
- package/dist/webmcp/bridge.js +106 -0
- package/dist/webmcp/descriptors.d.ts +59 -0
- package/dist/webmcp/descriptors.js +504 -0
- package/dist/webmcp/fake.d.ts +23 -0
- package/dist/webmcp/fake.js +42 -0
- package/dist/webmcp/gate.d.ts +76 -0
- package/dist/webmcp/gate.js +188 -0
- package/dist/webmcp/index.d.ts +36 -0
- package/dist/webmcp/index.js +32 -0
- package/dist/webmcp/register.d.ts +33 -0
- package/dist/webmcp/register.js +504 -0
- package/dist/webmcp/types.d.ts +268 -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
|
@@ -60,6 +60,141 @@ export function resolveNode(shortId, nodes) {
|
|
|
60
60
|
return nodes.find((n) => n.id.endsWith(`.${shortId}`));
|
|
61
61
|
}
|
|
62
62
|
// ============================================================================
|
|
63
|
+
// Teaching errors (D7 of the browser-agent plan)
|
|
64
|
+
// ============================================================================
|
|
65
|
+
//
|
|
66
|
+
// A failed command names the valid alternatives, because for a browser agent
|
|
67
|
+
// the error text is the only channel there is: an unknown node lists the
|
|
68
|
+
// nodes, an unknown type points at list_types and names near misses, an
|
|
69
|
+
// unknown port lists the node's ports, an unknown config key lists the keys.
|
|
70
|
+
// Lists are capped so a large workflow cannot turn one error into a dump.
|
|
71
|
+
const MAX_LISTED = 15;
|
|
72
|
+
function listCapped(items) {
|
|
73
|
+
if (items.length === 0)
|
|
74
|
+
return 'none';
|
|
75
|
+
const shown = items.slice(0, MAX_LISTED);
|
|
76
|
+
const rest = items.length - shown.length;
|
|
77
|
+
return shown.join(', ') + (rest > 0 ? `, … and ${rest} more` : '');
|
|
78
|
+
}
|
|
79
|
+
/** Near misses for an unknown id: same prefix, or one contains the other. */
|
|
80
|
+
function nearMisses(needle, haystack) {
|
|
81
|
+
const n = needle.toLowerCase();
|
|
82
|
+
const stem = n.split(/[._-]/)[0];
|
|
83
|
+
return haystack
|
|
84
|
+
.filter((h) => {
|
|
85
|
+
const l = h.toLowerCase();
|
|
86
|
+
return l.includes(n) || n.includes(l) || (stem.length >= 3 && l.startsWith(stem));
|
|
87
|
+
})
|
|
88
|
+
.slice(0, 5);
|
|
89
|
+
}
|
|
90
|
+
function nodeNotFoundMessage(nodeId, nodes) {
|
|
91
|
+
const ids = nodes.map((n) => toShortId(n.id));
|
|
92
|
+
return nodes.length === 0
|
|
93
|
+
? `Node not found: ${nodeId}. The workflow has no nodes yet — add_node first.`
|
|
94
|
+
: `Node not found: ${nodeId}. Nodes in this workflow: ${listCapped(ids)}.`;
|
|
95
|
+
}
|
|
96
|
+
function typeNotFoundMessage(typeId, context) {
|
|
97
|
+
const ids = context.nodeTypes.map((m) => toShortTypeId(m.node_type_id));
|
|
98
|
+
const near = nearMisses(typeId, ids);
|
|
99
|
+
const hint = near.length > 0
|
|
100
|
+
? ` Did you mean: ${near.join(', ')}?`
|
|
101
|
+
: ' Call list_types (or search_types) for the ids this editor accepts.';
|
|
102
|
+
return `Unknown node type: ${typeId}.${hint}`;
|
|
103
|
+
}
|
|
104
|
+
/** Every port id a node exposes in one direction, static and config-driven. */
|
|
105
|
+
function portIds(node, direction) {
|
|
106
|
+
const metadata = node.data?.metadata;
|
|
107
|
+
const config = node.data?.config;
|
|
108
|
+
if (direction === 'output') {
|
|
109
|
+
return [
|
|
110
|
+
...(metadata?.outputs ?? []).map((p) => p.id),
|
|
111
|
+
...(config?.branches ?? []).map((b) => b.name),
|
|
112
|
+
...(config?.dynamicOutputs ?? []).map((p) => p.name)
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
return [
|
|
116
|
+
...(metadata?.inputs ?? []).map((p) => p.id),
|
|
117
|
+
...(config?.dynamicInputs ?? []).map((p) => p.name)
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
function portNotFoundMessage(node, portId, direction) {
|
|
121
|
+
const short = toShortId(node.id);
|
|
122
|
+
const wanted = portIds(node, direction);
|
|
123
|
+
const other = portIds(node, direction === 'input' ? 'output' : 'input');
|
|
124
|
+
const otherWord = direction === 'input' ? 'outputs' : 'inputs';
|
|
125
|
+
return (`Port '${portId}' not found on node ${short}. ` +
|
|
126
|
+
`Its ${direction}s: ${listCapped(wanted)}; its ${otherWord}: ${listCapped(other)}.`);
|
|
127
|
+
}
|
|
128
|
+
function configKeys(node) {
|
|
129
|
+
const schemaKeys = Object.keys(node.data?.metadata?.configSchema?.properties ?? {});
|
|
130
|
+
const valueKeys = Object.keys(node.data?.config ?? {});
|
|
131
|
+
return Array.from(new Set([...schemaKeys, ...valueKeys]));
|
|
132
|
+
}
|
|
133
|
+
// ============================================================================
|
|
134
|
+
// Describing types (shared by list_types, search_types, describe_type, get_config)
|
|
135
|
+
// ============================================================================
|
|
136
|
+
function typeSummary(m) {
|
|
137
|
+
const row = {
|
|
138
|
+
typeId: toShortTypeId(m.node_type_id),
|
|
139
|
+
name: m.name,
|
|
140
|
+
category: m.category
|
|
141
|
+
};
|
|
142
|
+
if (m.description)
|
|
143
|
+
row.description = m.description;
|
|
144
|
+
if (m.tags && m.tags.length > 0)
|
|
145
|
+
row.tags = m.tags;
|
|
146
|
+
return row;
|
|
147
|
+
}
|
|
148
|
+
function describePort(p) {
|
|
149
|
+
const out = { portId: p.id, name: p.name, dataType: p.dataType };
|
|
150
|
+
if (p.required)
|
|
151
|
+
out.required = true;
|
|
152
|
+
if (p.description)
|
|
153
|
+
out.description = p.description;
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
function describeConfigKey(key, property, required) {
|
|
157
|
+
const out = { key };
|
|
158
|
+
if (property) {
|
|
159
|
+
// Host schemas may declare `type` as a JSON Schema array; keep it as sent.
|
|
160
|
+
const type = property.type;
|
|
161
|
+
if (type !== undefined)
|
|
162
|
+
out.type = type;
|
|
163
|
+
if (property.title)
|
|
164
|
+
out.title = property.title;
|
|
165
|
+
if (property.description)
|
|
166
|
+
out.description = property.description;
|
|
167
|
+
if (property.enum && property.enum.length > 0)
|
|
168
|
+
out.enum = property.enum;
|
|
169
|
+
if (property.default !== undefined)
|
|
170
|
+
out.default = property.default;
|
|
171
|
+
}
|
|
172
|
+
if (required)
|
|
173
|
+
out.required = true;
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
function describeConfigSchema(schema) {
|
|
177
|
+
if (!schema?.properties)
|
|
178
|
+
return [];
|
|
179
|
+
const required = new Set(schema.required ?? []);
|
|
180
|
+
return Object.entries(schema.properties).map(([key, property]) => describeConfigKey(key, property, required.has(key)));
|
|
181
|
+
}
|
|
182
|
+
function describeType(m) {
|
|
183
|
+
const out = {
|
|
184
|
+
...typeSummary(m),
|
|
185
|
+
inputs: (m.inputs ?? []).map(describePort),
|
|
186
|
+
outputs: (m.outputs ?? []).map(describePort),
|
|
187
|
+
config: describeConfigSchema(m.configSchema)
|
|
188
|
+
};
|
|
189
|
+
if (m.confirmation)
|
|
190
|
+
out.confirmation = m.confirmation;
|
|
191
|
+
if (m.can)
|
|
192
|
+
out.can = m.can;
|
|
193
|
+
if (m.agent)
|
|
194
|
+
out.agent = m.agent;
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
// ============================================================================
|
|
63
198
|
// Command Handlers
|
|
64
199
|
// ============================================================================
|
|
65
200
|
function executeAddNode(command, context) {
|
|
@@ -71,7 +206,7 @@ function executeAddNode(command, context) {
|
|
|
71
206
|
if (!metadata) {
|
|
72
207
|
return {
|
|
73
208
|
ok: false,
|
|
74
|
-
error:
|
|
209
|
+
error: typeNotFoundMessage(command.nodeTypeId, context),
|
|
75
210
|
code: 'NODE_TYPE_NOT_FOUND'
|
|
76
211
|
};
|
|
77
212
|
}
|
|
@@ -112,7 +247,7 @@ function executeDeleteNode(command, context) {
|
|
|
112
247
|
if (!node) {
|
|
113
248
|
return {
|
|
114
249
|
ok: false,
|
|
115
|
-
error:
|
|
250
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
116
251
|
code: 'NODE_NOT_FOUND'
|
|
117
252
|
};
|
|
118
253
|
}
|
|
@@ -131,7 +266,7 @@ function executeRenameNode(command, context) {
|
|
|
131
266
|
if (!node) {
|
|
132
267
|
return {
|
|
133
268
|
ok: false,
|
|
134
|
-
error:
|
|
269
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
135
270
|
code: 'NODE_NOT_FOUND'
|
|
136
271
|
};
|
|
137
272
|
}
|
|
@@ -203,14 +338,20 @@ function validateConfigValue(key, value, property) {
|
|
|
203
338
|
// Type validation
|
|
204
339
|
if (property.type) {
|
|
205
340
|
const actualType = Array.isArray(value) ? 'array' : typeof value;
|
|
206
|
-
|
|
341
|
+
// Node config schemas from the backend sometimes declare `type` as a JSON
|
|
342
|
+
// Schema array (e.g. ['string', 'boolean']) rather than a single literal;
|
|
343
|
+
// `ConfigProperty.type` stays a single literal (it drives the schema
|
|
344
|
+
// form elsewhere), so normalise here instead of widening that interface.
|
|
345
|
+
const rawType = property.type;
|
|
346
|
+
const declaredTypes = Array.isArray(rawType) ? rawType : [rawType];
|
|
347
|
+
const expectedTypes = declaredTypes.map((t) => (t === 'integer' ? 'number' : t));
|
|
207
348
|
// Only warn if there's a genuine mismatch (null/object handled specially)
|
|
208
349
|
if (value !== null &&
|
|
209
|
-
actualType
|
|
210
|
-
!(
|
|
350
|
+
!expectedTypes.includes(actualType) &&
|
|
351
|
+
!(expectedTypes.includes('object') && actualType === 'object')) {
|
|
211
352
|
warnings.push({
|
|
212
353
|
type: 'type_mismatch',
|
|
213
|
-
message: `Expected type '${
|
|
354
|
+
message: `Expected type ${expectedTypes.map((t) => `'${t}'`).join(' or ')} but got '${actualType}'`,
|
|
214
355
|
expectedType: property.type,
|
|
215
356
|
actualType
|
|
216
357
|
});
|
|
@@ -227,7 +368,7 @@ function executeSetConfig(command, context) {
|
|
|
227
368
|
if (!node) {
|
|
228
369
|
return {
|
|
229
370
|
ok: false,
|
|
230
|
-
error:
|
|
371
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
231
372
|
code: 'NODE_NOT_FOUND'
|
|
232
373
|
};
|
|
233
374
|
}
|
|
@@ -236,7 +377,19 @@ function executeSetConfig(command, context) {
|
|
|
236
377
|
const metadata = node.data.metadata;
|
|
237
378
|
const configSchema = metadata?.configSchema;
|
|
238
379
|
const property = configSchema?.properties?.[command.key];
|
|
239
|
-
const warnings = validateConfigValue(command.key, parsedValue, property);
|
|
380
|
+
const warnings = validateConfigValue(command.key, parsedValue, property) ?? [];
|
|
381
|
+
// A key the schema does not declare is stored anyway — hosts keep config
|
|
382
|
+
// open — but the caller is told, with the keys that do exist, so an agent
|
|
383
|
+
// that misspelt one finds out now rather than at run time. Silent when the
|
|
384
|
+
// node has no schema at all: there is nothing to compare against.
|
|
385
|
+
const declaredKeys = Object.keys(configSchema?.properties ?? {});
|
|
386
|
+
if (!property && declaredKeys.length > 0) {
|
|
387
|
+
warnings.push({
|
|
388
|
+
type: 'unknown_key',
|
|
389
|
+
message: `Key '${command.key}' is not in the config schema of ${toShortId(node.id)}. Declared keys: ${listCapped(declaredKeys)}`,
|
|
390
|
+
knownKeys: declaredKeys
|
|
391
|
+
});
|
|
392
|
+
}
|
|
240
393
|
// In strict mode, validation warnings become errors
|
|
241
394
|
if (command.strict && warnings && warnings.length > 0) {
|
|
242
395
|
const messages = warnings.map((w) => w.message).join('; ');
|
|
@@ -274,26 +427,47 @@ function executeGetConfig(command, context) {
|
|
|
274
427
|
if (!node) {
|
|
275
428
|
return {
|
|
276
429
|
ok: false,
|
|
277
|
-
error:
|
|
430
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
278
431
|
code: 'NODE_NOT_FOUND'
|
|
279
432
|
};
|
|
280
433
|
}
|
|
281
|
-
const config = node.data.config;
|
|
282
|
-
|
|
434
|
+
const config = node.data.config ?? {};
|
|
435
|
+
const schema = node.data.metadata?.configSchema;
|
|
436
|
+
const shortId = toShortId(node.id);
|
|
437
|
+
// No key: every value, and the schema that explains them.
|
|
438
|
+
if (command.key === undefined) {
|
|
439
|
+
const resultData = {
|
|
440
|
+
nodeId: shortId,
|
|
441
|
+
values: config,
|
|
442
|
+
schema: describeConfigSchema(schema)
|
|
443
|
+
};
|
|
444
|
+
const keys = Object.keys(config);
|
|
445
|
+
return {
|
|
446
|
+
ok: true,
|
|
447
|
+
message: keys.length === 0
|
|
448
|
+
? `${shortId} has no config values set`
|
|
449
|
+
: `${shortId} config: ${keys.map((k) => `${k} = ${JSON.stringify(config[k])}`).join(', ')}`,
|
|
450
|
+
data: resultData
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
const property = schema?.properties?.[command.key];
|
|
454
|
+
if (!(command.key in config) && !property) {
|
|
283
455
|
return {
|
|
284
456
|
ok: false,
|
|
285
|
-
error: `Config key not found: ${command.key} on ${
|
|
457
|
+
error: `Config key not found: ${command.key} on ${shortId}. Keys: ${listCapped(configKeys(node))}.`,
|
|
286
458
|
code: 'CONFIG_KEY_NOT_FOUND'
|
|
287
459
|
};
|
|
288
460
|
}
|
|
461
|
+
const required = new Set(schema?.required ?? []).has(command.key);
|
|
289
462
|
const resultData = {
|
|
290
|
-
nodeId:
|
|
463
|
+
nodeId: shortId,
|
|
291
464
|
key: command.key,
|
|
292
|
-
value: config[command.key]
|
|
465
|
+
value: config[command.key],
|
|
466
|
+
...(property ? { schema: describeConfigKey(command.key, property, required) } : {})
|
|
293
467
|
};
|
|
294
468
|
return {
|
|
295
469
|
ok: true,
|
|
296
|
-
message: `${
|
|
470
|
+
message: `${shortId}:${command.key} = ${JSON.stringify(config[command.key])}`,
|
|
297
471
|
data: resultData
|
|
298
472
|
};
|
|
299
473
|
}
|
|
@@ -306,7 +480,7 @@ function executeInfo(command, context) {
|
|
|
306
480
|
if (!node) {
|
|
307
481
|
return {
|
|
308
482
|
ok: false,
|
|
309
|
-
error:
|
|
483
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
310
484
|
code: 'NODE_NOT_FOUND'
|
|
311
485
|
};
|
|
312
486
|
}
|
|
@@ -433,7 +607,7 @@ function executeConnect(command, context) {
|
|
|
433
607
|
if (!sourceNode) {
|
|
434
608
|
return {
|
|
435
609
|
ok: false,
|
|
436
|
-
error:
|
|
610
|
+
error: nodeNotFoundMessage(command.sourceNodeId, workflow.nodes),
|
|
437
611
|
code: 'NODE_NOT_FOUND'
|
|
438
612
|
};
|
|
439
613
|
}
|
|
@@ -441,7 +615,7 @@ function executeConnect(command, context) {
|
|
|
441
615
|
if (!targetNode) {
|
|
442
616
|
return {
|
|
443
617
|
ok: false,
|
|
444
|
-
error:
|
|
618
|
+
error: nodeNotFoundMessage(command.targetNodeId, workflow.nodes),
|
|
445
619
|
code: 'NODE_NOT_FOUND'
|
|
446
620
|
};
|
|
447
621
|
}
|
|
@@ -453,7 +627,7 @@ function executeConnect(command, context) {
|
|
|
453
627
|
if (!sourcePortInfo) {
|
|
454
628
|
return {
|
|
455
629
|
ok: false,
|
|
456
|
-
error:
|
|
630
|
+
error: portNotFoundMessage(sourceNode, command.sourcePort, 'output'),
|
|
457
631
|
code: 'PORT_NOT_FOUND'
|
|
458
632
|
};
|
|
459
633
|
}
|
|
@@ -461,7 +635,7 @@ function executeConnect(command, context) {
|
|
|
461
635
|
if (!targetPortInfo) {
|
|
462
636
|
return {
|
|
463
637
|
ok: false,
|
|
464
|
-
error:
|
|
638
|
+
error: portNotFoundMessage(targetNode, command.targetPort, 'input'),
|
|
465
639
|
code: 'PORT_NOT_FOUND'
|
|
466
640
|
};
|
|
467
641
|
}
|
|
@@ -536,7 +710,7 @@ function executeDisconnectPorts(command, context) {
|
|
|
536
710
|
if (!sourceNode) {
|
|
537
711
|
return {
|
|
538
712
|
ok: false,
|
|
539
|
-
error:
|
|
713
|
+
error: nodeNotFoundMessage(command.sourceNodeId, workflow.nodes),
|
|
540
714
|
code: 'NODE_NOT_FOUND'
|
|
541
715
|
};
|
|
542
716
|
}
|
|
@@ -544,7 +718,7 @@ function executeDisconnectPorts(command, context) {
|
|
|
544
718
|
if (!targetNode) {
|
|
545
719
|
return {
|
|
546
720
|
ok: false,
|
|
547
|
-
error:
|
|
721
|
+
error: nodeNotFoundMessage(command.targetNodeId, workflow.nodes),
|
|
548
722
|
code: 'NODE_NOT_FOUND'
|
|
549
723
|
};
|
|
550
724
|
}
|
|
@@ -557,9 +731,13 @@ function executeDisconnectPorts(command, context) {
|
|
|
557
731
|
return sourcePort === command.sourcePort && targetPort === command.targetPort;
|
|
558
732
|
});
|
|
559
733
|
if (!edge) {
|
|
734
|
+
const outgoing = workflow.edges
|
|
735
|
+
.filter((e) => e.source === sourceNode.id)
|
|
736
|
+
.map((e) => `${toShortId(e.source)}:${extractPortId(e.sourceHandle) ?? '?'} → ${toShortId(e.target)}:${extractPortId(e.targetHandle) ?? '?'}`);
|
|
560
737
|
return {
|
|
561
738
|
ok: false,
|
|
562
|
-
error: `No edge found from ${toShortId(sourceNode.id)}:${command.sourcePort} to ${toShortId(targetNode.id)}:${command.targetPort}
|
|
739
|
+
error: `No edge found from ${toShortId(sourceNode.id)}:${command.sourcePort} to ${toShortId(targetNode.id)}:${command.targetPort}. ` +
|
|
740
|
+
`Edges leaving ${toShortId(sourceNode.id)}: ${listCapped(outgoing)}.`,
|
|
563
741
|
code: 'EDGE_NOT_FOUND'
|
|
564
742
|
};
|
|
565
743
|
}
|
|
@@ -578,7 +756,7 @@ function executeDisconnectNode(command, context) {
|
|
|
578
756
|
if (!node) {
|
|
579
757
|
return {
|
|
580
758
|
ok: false,
|
|
581
|
-
error:
|
|
759
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
582
760
|
code: 'NODE_NOT_FOUND'
|
|
583
761
|
};
|
|
584
762
|
}
|
|
@@ -634,11 +812,7 @@ function executeListEdges(context) {
|
|
|
634
812
|
};
|
|
635
813
|
}
|
|
636
814
|
function executeListTypes(context) {
|
|
637
|
-
const types = context.nodeTypes.map(
|
|
638
|
-
typeId: toShortTypeId(m.node_type_id),
|
|
639
|
-
name: m.name,
|
|
640
|
-
category: m.category
|
|
641
|
-
}));
|
|
815
|
+
const types = context.nodeTypes.map(typeSummary);
|
|
642
816
|
const resultData = { types };
|
|
643
817
|
return {
|
|
644
818
|
ok: true,
|
|
@@ -646,6 +820,51 @@ function executeListTypes(context) {
|
|
|
646
820
|
data: resultData
|
|
647
821
|
};
|
|
648
822
|
}
|
|
823
|
+
function executeSearchTypes(command, context) {
|
|
824
|
+
const query = command.query.trim().toLowerCase();
|
|
825
|
+
if (!query) {
|
|
826
|
+
return {
|
|
827
|
+
ok: false,
|
|
828
|
+
error: 'search_types needs text to look for. For the whole catalog call list_types.',
|
|
829
|
+
code: 'EMPTY_QUERY'
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
const matches = context.nodeTypes.filter((m) => {
|
|
833
|
+
const fields = [
|
|
834
|
+
toShortTypeId(m.node_type_id),
|
|
835
|
+
m.node_type_id,
|
|
836
|
+
m.name,
|
|
837
|
+
m.description ?? '',
|
|
838
|
+
...(m.tags ?? [])
|
|
839
|
+
];
|
|
840
|
+
return fields.some((f) => f.toLowerCase().includes(query));
|
|
841
|
+
});
|
|
842
|
+
const types = matches.map(typeSummary);
|
|
843
|
+
const resultData = { query: command.query, types };
|
|
844
|
+
return {
|
|
845
|
+
ok: true,
|
|
846
|
+
message: types.length === 0
|
|
847
|
+
? `No node type matches "${command.query}" — try list_types for the full catalog`
|
|
848
|
+
: `${types.length} type(s) match "${command.query}": ${listCapped(types.map((t) => t.typeId))}`,
|
|
849
|
+
data: resultData
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function executeDescribeType(command, context) {
|
|
853
|
+
const metadata = context.typeMap.get(command.nodeTypeId);
|
|
854
|
+
if (!metadata) {
|
|
855
|
+
return {
|
|
856
|
+
ok: false,
|
|
857
|
+
error: typeNotFoundMessage(command.nodeTypeId, context),
|
|
858
|
+
code: 'NODE_TYPE_NOT_FOUND'
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
const resultData = describeType(metadata);
|
|
862
|
+
return {
|
|
863
|
+
ok: true,
|
|
864
|
+
message: `${resultData.typeId}: ${resultData.inputs.length} input(s), ${resultData.outputs.length} output(s), ${resultData.config.length} config key(s)`,
|
|
865
|
+
data: resultData
|
|
866
|
+
};
|
|
867
|
+
}
|
|
649
868
|
/** All command help entries */
|
|
650
869
|
export const COMMAND_HELP = [
|
|
651
870
|
{
|
|
@@ -670,8 +889,8 @@ export const COMMAND_HELP = [
|
|
|
670
889
|
},
|
|
671
890
|
{
|
|
672
891
|
name: 'get',
|
|
673
|
-
syntax: 'get <nodeId
|
|
674
|
-
description: 'Get a config value from a node'
|
|
892
|
+
syntax: 'get <nodeId>[:<key>]',
|
|
893
|
+
description: 'Get a config value from a node, or every value plus the schema'
|
|
675
894
|
},
|
|
676
895
|
{
|
|
677
896
|
name: 'connect',
|
|
@@ -693,6 +912,16 @@ export const COMMAND_HELP = [
|
|
|
693
912
|
syntax: 'list nodes|edges|types',
|
|
694
913
|
description: 'List workflow nodes, edges, or available types'
|
|
695
914
|
},
|
|
915
|
+
{
|
|
916
|
+
name: 'describe',
|
|
917
|
+
syntax: 'describe <type>',
|
|
918
|
+
description: 'Show the ports, config schema and defaults of a node type'
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
name: 'search',
|
|
922
|
+
syntax: 'search <text>',
|
|
923
|
+
description: 'Find node types by id, name, description or tag'
|
|
924
|
+
},
|
|
696
925
|
{
|
|
697
926
|
name: 'info',
|
|
698
927
|
syntax: 'info <nodeId>',
|
|
@@ -835,7 +1064,7 @@ function executeConfigOpen(command, context) {
|
|
|
835
1064
|
if (!node) {
|
|
836
1065
|
return {
|
|
837
1066
|
ok: false,
|
|
838
|
-
error:
|
|
1067
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
839
1068
|
code: 'NODE_NOT_FOUND'
|
|
840
1069
|
};
|
|
841
1070
|
}
|
|
@@ -861,7 +1090,7 @@ function executeSelectNode(command, context) {
|
|
|
861
1090
|
if (!node) {
|
|
862
1091
|
return {
|
|
863
1092
|
ok: false,
|
|
864
|
-
error:
|
|
1093
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
865
1094
|
code: 'NODE_NOT_FOUND'
|
|
866
1095
|
};
|
|
867
1096
|
}
|
|
@@ -887,7 +1116,7 @@ function executeSwapNode(command, context) {
|
|
|
887
1116
|
if (!node) {
|
|
888
1117
|
return {
|
|
889
1118
|
ok: false,
|
|
890
|
-
error:
|
|
1119
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
891
1120
|
code: 'NODE_NOT_FOUND'
|
|
892
1121
|
};
|
|
893
1122
|
}
|
|
@@ -895,7 +1124,7 @@ function executeSwapNode(command, context) {
|
|
|
895
1124
|
if (!newMetadata) {
|
|
896
1125
|
return {
|
|
897
1126
|
ok: false,
|
|
898
|
-
error:
|
|
1127
|
+
error: typeNotFoundMessage(command.newTypeId, context),
|
|
899
1128
|
code: 'NODE_TYPE_NOT_FOUND'
|
|
900
1129
|
};
|
|
901
1130
|
}
|
|
@@ -956,7 +1185,7 @@ function executeMoveNode(command, context) {
|
|
|
956
1185
|
if (!node) {
|
|
957
1186
|
return {
|
|
958
1187
|
ok: false,
|
|
959
|
-
error:
|
|
1188
|
+
error: nodeNotFoundMessage(command.nodeId, workflow.nodes),
|
|
960
1189
|
code: 'NODE_NOT_FOUND'
|
|
961
1190
|
};
|
|
962
1191
|
}
|
|
@@ -1131,6 +1360,10 @@ export function executeCommand(command, context) {
|
|
|
1131
1360
|
return executeListEdges(context);
|
|
1132
1361
|
case 'list_types':
|
|
1133
1362
|
return executeListTypes(context);
|
|
1363
|
+
case 'describe_type':
|
|
1364
|
+
return executeDescribeType(command, context);
|
|
1365
|
+
case 'search_types':
|
|
1366
|
+
return executeSearchTypes(command, context);
|
|
1134
1367
|
case 'help':
|
|
1135
1368
|
return executeHelp(command);
|
|
1136
1369
|
case 'undo':
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module commands
|
|
8
8
|
*/
|
|
9
|
-
export type { AddNodeCommand, DeleteNodeCommand, RenameNodeCommand, SetConfigCommand, GetConfigCommand, ConnectCommand, DisconnectPortsCommand, DisconnectNodeCommand, ListNodesCommand, ListEdgesCommand, ListTypesCommand, InfoCommand, UndoCommand, RedoCommand, ConfigOpenCommand, SelectNodeCommand, HelpCommand, ClearCommand, SwapNodeCommand, MoveNodeCommand, AutoLayoutCommand, BeautifyLayoutCommand, CanvasFitViewCommand, CanvasZoomInCommand, CanvasZoomOutCommand, CanvasZoomToCommand, CanvasPanToCommand, CanvasResetViewCommand, Command, ParseResult, CommandErrorCode, AddNodeResultData, ListNodesResultData, ListEdgesResultData, ListTypesResultData, InfoResultData, GetConfigResultData, SetConfigResultData, HelpResultData, SwapNodeResultData, CommandResultData, CommandResultOk, CommandResultError, CommandResult, BatchResult, UIAction, CommandDispatch, CommandContext } from './types.js';
|
|
9
|
+
export type { AddNodeCommand, DeleteNodeCommand, RenameNodeCommand, SetConfigCommand, GetConfigCommand, ConnectCommand, DisconnectPortsCommand, DisconnectNodeCommand, ListNodesCommand, ListEdgesCommand, ListTypesCommand, DescribeTypeCommand, SearchTypesCommand, InfoCommand, UndoCommand, RedoCommand, ConfigOpenCommand, SelectNodeCommand, HelpCommand, ClearCommand, SwapNodeCommand, MoveNodeCommand, AutoLayoutCommand, BeautifyLayoutCommand, CanvasFitViewCommand, CanvasZoomInCommand, CanvasZoomOutCommand, CanvasZoomToCommand, CanvasPanToCommand, CanvasResetViewCommand, Command, ParseResult, CommandErrorCode, AddNodeResultData, ListNodesResultData, ListEdgesResultData, ListTypesResultData, SearchTypesResultData, DescribeTypeResultData, TypeSummary, ConfigKeyDescription, PortDescription, InfoResultData, GetConfigResultData, GetConfigKeyResultData, GetConfigAllResultData, SetConfigResultData, HelpResultData, SwapNodeResultData, CommandResultData, CommandResultOk, CommandResultError, CommandResult, BatchResult, UIAction, CommandDispatch, CommandContext } from './types.js';
|
|
10
10
|
export { buildTypeMap } from './types.js';
|
|
11
11
|
export { parseCommand } from './parser.js';
|
|
12
12
|
export { executeCommand, toShortId, toShortTypeId, resolveNode, COMMAND_HELP } from './executor.js';
|
package/dist/commands/parser.js
CHANGED
|
@@ -105,6 +105,14 @@ const rules = [
|
|
|
105
105
|
key: m[2]
|
|
106
106
|
})
|
|
107
107
|
},
|
|
108
|
+
// get <nodeId> — every config value plus the schema
|
|
109
|
+
{
|
|
110
|
+
pattern: /^get\s+([^\s:]+)$/i,
|
|
111
|
+
parse: (m) => ({
|
|
112
|
+
type: 'get_config',
|
|
113
|
+
nodeId: m[1]
|
|
114
|
+
})
|
|
115
|
+
},
|
|
108
116
|
// info <nodeId>
|
|
109
117
|
{
|
|
110
118
|
pattern: /^info\s+(\S+)$/i,
|
|
@@ -174,6 +182,16 @@ const rules = [
|
|
|
174
182
|
pattern: /^list\s+types$/i,
|
|
175
183
|
parse: () => ({ type: 'list_types' })
|
|
176
184
|
},
|
|
185
|
+
// describe <type>
|
|
186
|
+
{
|
|
187
|
+
pattern: /^describe\s+(\S+)$/i,
|
|
188
|
+
parse: (m) => ({ type: 'describe_type', nodeTypeId: m[1] })
|
|
189
|
+
},
|
|
190
|
+
// search <text...>
|
|
191
|
+
{
|
|
192
|
+
pattern: /^search\s+(.+)$/i,
|
|
193
|
+
parse: (m) => ({ type: 'search_types', query: m[1].trim() })
|
|
194
|
+
},
|
|
177
195
|
// undo
|
|
178
196
|
{
|
|
179
197
|
pattern: /^undo$/i,
|
|
@@ -318,6 +336,8 @@ export function parseCommand(input) {
|
|
|
318
336
|
'connect',
|
|
319
337
|
'disconnect',
|
|
320
338
|
'list',
|
|
339
|
+
'describe',
|
|
340
|
+
'search',
|
|
321
341
|
'undo',
|
|
322
342
|
'redo',
|
|
323
343
|
'help',
|