@d34dman/flowdrop 0.0.57 → 0.0.58
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/README.md +4 -4
- package/dist/adapters/WorkflowAdapter.d.ts +2 -1
- package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +4 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.js +27 -22
- package/dist/adapters/agentspec/componentTypeDefaults.d.ts +73 -0
- package/dist/adapters/agentspec/componentTypeDefaults.js +238 -0
- package/dist/adapters/agentspec/{nodeTypeRegistry.d.ts → defaultNodeTypes.d.ts} +21 -30
- package/dist/adapters/agentspec/{nodeTypeRegistry.js → defaultNodeTypes.js} +31 -59
- package/dist/adapters/agentspec/index.d.ts +3 -1
- package/dist/adapters/agentspec/index.js +4 -2
- package/dist/components/App.svelte +57 -13
- package/dist/components/NodeSidebar.svelte +20 -8
- package/dist/components/NodeSidebar.svelte.d.ts +2 -1
- package/dist/components/WorkflowEditor.svelte +14 -13
- package/dist/components/form/FormMarkdownEditor.svelte +546 -422
- package/dist/components/form/FormMarkdownEditor.svelte.d.ts +2 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +4 -8
- package/dist/components/form/types.d.ts +1 -1
- package/dist/components/nodes/WorkflowNode.svelte +1 -2
- package/dist/core/index.d.ts +13 -3
- package/dist/core/index.js +16 -3
- package/dist/form/code.js +6 -1
- package/dist/form/fieldRegistry.d.ts +79 -15
- package/dist/form/fieldRegistry.js +104 -49
- package/dist/form/full.d.ts +2 -2
- package/dist/form/full.js +2 -2
- package/dist/form/index.d.ts +3 -3
- package/dist/form/index.js +6 -2
- package/dist/form/markdown.d.ts +3 -3
- package/dist/form/markdown.js +8 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/registry/BaseRegistry.d.ts +92 -0
- package/dist/registry/BaseRegistry.js +124 -0
- package/dist/registry/builtinFormats.d.ts +23 -0
- package/dist/registry/builtinFormats.js +70 -0
- package/dist/registry/builtinNodes.js +4 -0
- package/dist/registry/index.d.ts +2 -1
- package/dist/registry/index.js +2 -0
- package/dist/registry/nodeComponentRegistry.d.ts +26 -57
- package/dist/registry/nodeComponentRegistry.js +29 -82
- package/dist/registry/workflowFormatRegistry.d.ts +122 -0
- package/dist/registry/workflowFormatRegistry.js +96 -0
- package/dist/schema/index.d.ts +23 -0
- package/dist/schema/index.js +23 -0
- package/dist/stores/portCoordinateStore.js +1 -4
- package/dist/stores/workflowStore.d.ts +3 -0
- package/dist/stores/workflowStore.js +3 -0
- package/dist/svelte-app.d.ts +4 -0
- package/dist/svelte-app.js +9 -1
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.js +4 -0
- package/package.json +231 -225
- package/schemas/v1/workflow.schema.json +952 -0
package/README.md
CHANGED
|
@@ -224,10 +224,10 @@ Runtime configuration means you build once and deploy to staging, production, or
|
|
|
224
224
|
## Development
|
|
225
225
|
|
|
226
226
|
```bash
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
pnpm install # Install dependencies
|
|
228
|
+
pnpm dev # Start dev server
|
|
229
|
+
pnpm build # Build library
|
|
230
|
+
pnpm test # Run all tests
|
|
231
231
|
```
|
|
232
232
|
|
|
233
233
|
## Contributing
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - External applications that want to integrate with FlowDrop
|
|
14
14
|
* - Systems that need to generate or modify workflows programmatically
|
|
15
15
|
*/
|
|
16
|
-
import type { Workflow, NodeMetadata } from '../types/index.js';
|
|
16
|
+
import type { Workflow, NodeMetadata, WorkflowFormat } from '../types/index.js';
|
|
17
17
|
/**
|
|
18
18
|
* Standard workflow node interface (SvelteFlow-agnostic)
|
|
19
19
|
*/
|
|
@@ -55,6 +55,7 @@ export interface StandardWorkflow {
|
|
|
55
55
|
updatedAt: string;
|
|
56
56
|
author?: string;
|
|
57
57
|
tags?: string[];
|
|
58
|
+
format?: WorkflowFormat;
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
@@ -59,6 +59,10 @@ export declare class AgentSpecAdapter {
|
|
|
59
59
|
private resolveComponentType;
|
|
60
60
|
/**
|
|
61
61
|
* Convert an Agent Spec node to a FlowDrop StandardNode.
|
|
62
|
+
*
|
|
63
|
+
* Uses lightweight component type defaults for trigger ports and visual styling.
|
|
64
|
+
* Does NOT depend on the full node type registry — works with any component_type,
|
|
65
|
+
* including custom/unknown types (falls back to sensible defaults).
|
|
62
66
|
*/
|
|
63
67
|
private convertNodeFromAgentSpec;
|
|
64
68
|
/**
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @see https://github.com/oracle/agent-spec
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import { getComponentTypeDefaults, extractComponentType, AGENTSPEC_NAMESPACE } from './componentTypeDefaults.js';
|
|
13
13
|
import { computeAutoLayout } from './autoLayout.js';
|
|
14
14
|
import { v4 as uuidv4 } from 'uuid';
|
|
15
15
|
// ============================================================================
|
|
@@ -424,6 +424,10 @@ export class AgentSpecAdapter {
|
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
426
|
* Convert an Agent Spec node to a FlowDrop StandardNode.
|
|
427
|
+
*
|
|
428
|
+
* Uses lightweight component type defaults for trigger ports and visual styling.
|
|
429
|
+
* Does NOT depend on the full node type registry — works with any component_type,
|
|
430
|
+
* including custom/unknown types (falls back to sensible defaults).
|
|
427
431
|
*/
|
|
428
432
|
convertNodeFromAgentSpec(asNode, nodeId, position) {
|
|
429
433
|
// Restore position from metadata if available (round-trip)
|
|
@@ -432,22 +436,25 @@ export class AgentSpecAdapter {
|
|
|
432
436
|
// Convert inputs/outputs to FlowDrop ports
|
|
433
437
|
const dataInputs = (asNode.inputs || []).map((p) => agentSpecPropertyToNodePort(p, 'input'));
|
|
434
438
|
const dataOutputs = (asNode.outputs || []).map((p) => agentSpecPropertyToNodePort(p, 'output'));
|
|
435
|
-
//
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
439
|
+
// Use lightweight adapter defaults (never throws on unknown types)
|
|
440
|
+
const defaults = getComponentTypeDefaults(asNode.component_type);
|
|
441
|
+
const nodeTypeId = asNode.metadata?.['flowdrop:node_type_id'] ||
|
|
442
|
+
`${AGENTSPEC_NAMESPACE}.${asNode.component_type}`;
|
|
443
|
+
const metadata = {
|
|
444
|
+
id: nodeTypeId,
|
|
445
|
+
name: defaults.defaultName,
|
|
446
|
+
type: defaults.visualType,
|
|
447
|
+
description: asNode.description || defaults.defaultDescription,
|
|
448
|
+
category: defaults.category,
|
|
449
|
+
version: '1.0.0',
|
|
450
|
+
icon: defaults.icon,
|
|
451
|
+
color: defaults.color,
|
|
452
|
+
badge: defaults.badge,
|
|
453
|
+
inputs: [...defaults.triggerInputs, ...dataInputs],
|
|
454
|
+
outputs: [...defaults.triggerOutputs, ...dataOutputs],
|
|
455
|
+
configSchema: { type: 'object', properties: {} },
|
|
456
|
+
formats: ['agentspec'],
|
|
449
457
|
extensions: {
|
|
450
|
-
...metadata.extensions,
|
|
451
458
|
'agentspec:component_type': asNode.component_type,
|
|
452
459
|
'agentspec:original_name': asNode.name
|
|
453
460
|
}
|
|
@@ -456,12 +463,12 @@ export class AgentSpecAdapter {
|
|
|
456
463
|
const config = this.extractConfigFromAgentSpec(asNode);
|
|
457
464
|
return {
|
|
458
465
|
id: nodeId,
|
|
459
|
-
type:
|
|
466
|
+
type: nodeTypeId,
|
|
460
467
|
position: finalPosition,
|
|
461
468
|
data: {
|
|
462
469
|
label: asNode.name,
|
|
463
470
|
config,
|
|
464
|
-
metadata
|
|
471
|
+
metadata
|
|
465
472
|
}
|
|
466
473
|
};
|
|
467
474
|
}
|
|
@@ -506,8 +513,7 @@ export class AgentSpecAdapter {
|
|
|
506
513
|
case 'agent_node': {
|
|
507
514
|
const agent = asNode;
|
|
508
515
|
if (agent.agent) {
|
|
509
|
-
config.agent_ref =
|
|
510
|
-
typeof agent.agent === 'string' ? agent.agent : agent.agent.name;
|
|
516
|
+
config.agent_ref = typeof agent.agent === 'string' ? agent.agent : agent.agent.name;
|
|
511
517
|
}
|
|
512
518
|
break;
|
|
513
519
|
}
|
|
@@ -525,8 +531,7 @@ export class AgentSpecAdapter {
|
|
|
525
531
|
if (map.output_collection)
|
|
526
532
|
config.output_collection = map.output_collection;
|
|
527
533
|
if (map.map_flow) {
|
|
528
|
-
config.map_flow_ref =
|
|
529
|
-
typeof map.map_flow === 'string' ? map.map_flow : map.map_flow.name;
|
|
534
|
+
config.map_flow_ref = typeof map.map_flow === 'string' ? map.map_flow : map.map_flow.name;
|
|
530
535
|
}
|
|
531
536
|
break;
|
|
532
537
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Spec Component Type Defaults
|
|
3
|
+
*
|
|
4
|
+
* Internal adapter infrastructure for import/export.
|
|
5
|
+
* Provides lightweight defaults per component_type (trigger ports, visual styling)
|
|
6
|
+
* WITHOUT prescribing full node type definitions (data ports, config schemas).
|
|
7
|
+
*
|
|
8
|
+
* Full node type definitions are user-provided via getDefaultAgentSpecNodeTypes()
|
|
9
|
+
* or custom node arrays passed to mountFlowDropApp().
|
|
10
|
+
*/
|
|
11
|
+
import type { NodePort } from '../../types/index.js';
|
|
12
|
+
/** Namespace prefix for Agent Spec node type IDs */
|
|
13
|
+
export declare const AGENTSPEC_NAMESPACE = "agentspec";
|
|
14
|
+
/** Standard trigger input port — control flow into a node */
|
|
15
|
+
export declare const TRIGGER_INPUT: NodePort;
|
|
16
|
+
/** Standard trigger output port — control flow out of a node */
|
|
17
|
+
export declare const TRIGGER_OUTPUT: NodePort;
|
|
18
|
+
/**
|
|
19
|
+
* Lightweight defaults for a component_type.
|
|
20
|
+
* Used during import to construct minimal NodeMetadata from Agent Spec JSON.
|
|
21
|
+
* These are NOT full node type definitions — they only contain what the
|
|
22
|
+
* adapter needs to create valid FlowDrop nodes.
|
|
23
|
+
*/
|
|
24
|
+
export interface ComponentTypeDefaults {
|
|
25
|
+
/** FlowDrop visual node type (terminal, gateway, default, tool, simple) */
|
|
26
|
+
visualType: string;
|
|
27
|
+
/** Node category for sidebar grouping */
|
|
28
|
+
category: string;
|
|
29
|
+
/** Default display color */
|
|
30
|
+
color: string;
|
|
31
|
+
/** Default icon (MDI format) */
|
|
32
|
+
icon: string;
|
|
33
|
+
/** Badge text for node header */
|
|
34
|
+
badge: string;
|
|
35
|
+
/** Default node name when no name provided */
|
|
36
|
+
defaultName: string;
|
|
37
|
+
/** Default description */
|
|
38
|
+
defaultDescription: string;
|
|
39
|
+
/** Trigger/tool ports to prepend to data inputs during import */
|
|
40
|
+
triggerInputs: NodePort[];
|
|
41
|
+
/** Trigger/tool ports to prepend to data outputs during import */
|
|
42
|
+
triggerOutputs: NodePort[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get adapter defaults for a component type.
|
|
46
|
+
* Returns sensible fallbacks for unrecognized types (never throws).
|
|
47
|
+
*
|
|
48
|
+
* @param componentType - The Agent Spec component_type value
|
|
49
|
+
* @returns ComponentTypeDefaults for the type, or fallback for unknown types
|
|
50
|
+
*/
|
|
51
|
+
export declare function getComponentTypeDefaults(componentType: string): ComponentTypeDefaults;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a FlowDrop node ID belongs to an Agent Spec node type.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* isAgentSpecNodeId('agentspec.llm_node') // true
|
|
58
|
+
* isAgentSpecNodeId('calculator') // false
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function isAgentSpecNodeId(nodeId: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Extract the component_type string from a FlowDrop node type ID.
|
|
64
|
+
* Does not validate against any registry — any string after the namespace prefix is returned.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* extractComponentType('agentspec.llm_node') // 'llm_node'
|
|
69
|
+
* extractComponentType('agentspec.my_custom') // 'my_custom'
|
|
70
|
+
* extractComponentType('calculator') // undefined
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function extractComponentType(nodeTypeId: string): string | undefined;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Spec Component Type Defaults
|
|
3
|
+
*
|
|
4
|
+
* Internal adapter infrastructure for import/export.
|
|
5
|
+
* Provides lightweight defaults per component_type (trigger ports, visual styling)
|
|
6
|
+
* WITHOUT prescribing full node type definitions (data ports, config schemas).
|
|
7
|
+
*
|
|
8
|
+
* Full node type definitions are user-provided via getDefaultAgentSpecNodeTypes()
|
|
9
|
+
* or custom node arrays passed to mountFlowDropApp().
|
|
10
|
+
*/
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Constants
|
|
13
|
+
// ============================================================================
|
|
14
|
+
/** Namespace prefix for Agent Spec node type IDs */
|
|
15
|
+
export const AGENTSPEC_NAMESPACE = 'agentspec';
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Standard ports (adapter infrastructure)
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/** Standard trigger input port — control flow into a node */
|
|
20
|
+
export const TRIGGER_INPUT = {
|
|
21
|
+
id: 'trigger',
|
|
22
|
+
name: 'Trigger',
|
|
23
|
+
type: 'input',
|
|
24
|
+
dataType: 'trigger',
|
|
25
|
+
required: false,
|
|
26
|
+
description: 'Control flow input'
|
|
27
|
+
};
|
|
28
|
+
/** Standard trigger output port — control flow out of a node */
|
|
29
|
+
export const TRIGGER_OUTPUT = {
|
|
30
|
+
id: 'trigger',
|
|
31
|
+
name: 'Trigger',
|
|
32
|
+
type: 'output',
|
|
33
|
+
dataType: 'trigger',
|
|
34
|
+
required: false,
|
|
35
|
+
description: 'Control flow output'
|
|
36
|
+
};
|
|
37
|
+
/** Tool input port for tool_node */
|
|
38
|
+
const TOOL_INPUT = {
|
|
39
|
+
id: 'tool',
|
|
40
|
+
name: 'Tool',
|
|
41
|
+
type: 'input',
|
|
42
|
+
dataType: 'tool',
|
|
43
|
+
required: false,
|
|
44
|
+
description: 'Tool connection'
|
|
45
|
+
};
|
|
46
|
+
/** Tool output port for tool_node */
|
|
47
|
+
const TOOL_OUTPUT = {
|
|
48
|
+
id: 'tool',
|
|
49
|
+
name: 'Tool',
|
|
50
|
+
type: 'output',
|
|
51
|
+
dataType: 'tool',
|
|
52
|
+
description: 'Tool passthrough'
|
|
53
|
+
};
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// Defaults mapping
|
|
56
|
+
// ============================================================================
|
|
57
|
+
const COMPONENT_TYPE_DEFAULTS = new Map([
|
|
58
|
+
[
|
|
59
|
+
'start_node',
|
|
60
|
+
{
|
|
61
|
+
visualType: 'terminal',
|
|
62
|
+
category: 'triggers',
|
|
63
|
+
color: '#22c55e',
|
|
64
|
+
icon: 'mdi:play-circle',
|
|
65
|
+
badge: 'START',
|
|
66
|
+
defaultName: 'Start',
|
|
67
|
+
defaultDescription: 'Flow entry point. Defines the initial inputs for the flow.',
|
|
68
|
+
triggerInputs: [],
|
|
69
|
+
triggerOutputs: [TRIGGER_OUTPUT]
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
'end_node',
|
|
74
|
+
{
|
|
75
|
+
visualType: 'terminal',
|
|
76
|
+
category: 'outputs',
|
|
77
|
+
color: '#ef4444',
|
|
78
|
+
icon: 'mdi:stop-circle',
|
|
79
|
+
badge: 'END',
|
|
80
|
+
defaultName: 'End',
|
|
81
|
+
defaultDescription: 'Flow exit point. Defines the final outputs of the flow.',
|
|
82
|
+
triggerInputs: [TRIGGER_INPUT],
|
|
83
|
+
triggerOutputs: []
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
'llm_node',
|
|
88
|
+
{
|
|
89
|
+
visualType: 'default',
|
|
90
|
+
category: 'ai',
|
|
91
|
+
color: '#8b5cf6',
|
|
92
|
+
icon: 'mdi:brain',
|
|
93
|
+
badge: 'LLM',
|
|
94
|
+
defaultName: 'LLM',
|
|
95
|
+
defaultDescription: 'Generate text using a large language model with configurable prompts.',
|
|
96
|
+
triggerInputs: [TRIGGER_INPUT],
|
|
97
|
+
triggerOutputs: [TRIGGER_OUTPUT]
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
'branching_node',
|
|
102
|
+
{
|
|
103
|
+
visualType: 'gateway',
|
|
104
|
+
category: 'logic',
|
|
105
|
+
color: '#f59e0b',
|
|
106
|
+
icon: 'mdi:source-branch',
|
|
107
|
+
badge: 'BRANCH',
|
|
108
|
+
defaultName: 'Branch',
|
|
109
|
+
defaultDescription: 'Route execution to different paths based on conditions.',
|
|
110
|
+
triggerInputs: [TRIGGER_INPUT],
|
|
111
|
+
triggerOutputs: []
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
'tool_node',
|
|
116
|
+
{
|
|
117
|
+
visualType: 'tool',
|
|
118
|
+
category: 'tools',
|
|
119
|
+
color: '#06b6d4',
|
|
120
|
+
icon: 'mdi:wrench',
|
|
121
|
+
badge: 'TOOL',
|
|
122
|
+
defaultName: 'Tool',
|
|
123
|
+
defaultDescription: 'Execute a tool function with inputs and receive outputs.',
|
|
124
|
+
triggerInputs: [TRIGGER_INPUT, TOOL_INPUT],
|
|
125
|
+
triggerOutputs: [TRIGGER_OUTPUT, TOOL_OUTPUT]
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
'api_node',
|
|
130
|
+
{
|
|
131
|
+
visualType: 'default',
|
|
132
|
+
category: 'data',
|
|
133
|
+
color: '#3b82f6',
|
|
134
|
+
icon: 'mdi:api',
|
|
135
|
+
badge: 'API',
|
|
136
|
+
defaultName: 'API Call',
|
|
137
|
+
defaultDescription: 'Make an HTTP API call with configurable endpoint, method, and headers.',
|
|
138
|
+
triggerInputs: [TRIGGER_INPUT],
|
|
139
|
+
triggerOutputs: [TRIGGER_OUTPUT]
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
[
|
|
143
|
+
'agent_node',
|
|
144
|
+
{
|
|
145
|
+
visualType: 'default',
|
|
146
|
+
category: 'agents',
|
|
147
|
+
color: '#ec4899',
|
|
148
|
+
icon: 'mdi:robot',
|
|
149
|
+
badge: 'AGENT',
|
|
150
|
+
defaultName: 'Agent',
|
|
151
|
+
defaultDescription: 'Run a multi-round agent conversation within the flow.',
|
|
152
|
+
triggerInputs: [TRIGGER_INPUT],
|
|
153
|
+
triggerOutputs: [TRIGGER_OUTPUT]
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
[
|
|
157
|
+
'flow_node',
|
|
158
|
+
{
|
|
159
|
+
visualType: 'simple',
|
|
160
|
+
category: 'processing',
|
|
161
|
+
color: '#14b8a6',
|
|
162
|
+
icon: 'mdi:sitemap',
|
|
163
|
+
badge: 'FLOW',
|
|
164
|
+
defaultName: 'Sub-Flow',
|
|
165
|
+
defaultDescription: 'Execute another flow as a sub-routine within this flow.',
|
|
166
|
+
triggerInputs: [TRIGGER_INPUT],
|
|
167
|
+
triggerOutputs: [TRIGGER_OUTPUT]
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
[
|
|
171
|
+
'map_node',
|
|
172
|
+
{
|
|
173
|
+
visualType: 'default',
|
|
174
|
+
category: 'processing',
|
|
175
|
+
color: '#f97316',
|
|
176
|
+
icon: 'mdi:map-marker-path',
|
|
177
|
+
badge: 'MAP',
|
|
178
|
+
defaultName: 'Map',
|
|
179
|
+
defaultDescription: 'Apply a flow or operation to each item in a collection (map-reduce).',
|
|
180
|
+
triggerInputs: [TRIGGER_INPUT],
|
|
181
|
+
triggerOutputs: [TRIGGER_OUTPUT]
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
]);
|
|
185
|
+
/** Fallback defaults for unrecognized component types */
|
|
186
|
+
const UNKNOWN_DEFAULTS = {
|
|
187
|
+
visualType: 'default',
|
|
188
|
+
category: 'processing',
|
|
189
|
+
color: '#6b7280',
|
|
190
|
+
icon: 'mdi:puzzle',
|
|
191
|
+
badge: '',
|
|
192
|
+
defaultName: 'Unknown',
|
|
193
|
+
defaultDescription: 'Agent Spec node',
|
|
194
|
+
triggerInputs: [TRIGGER_INPUT],
|
|
195
|
+
triggerOutputs: [TRIGGER_OUTPUT]
|
|
196
|
+
};
|
|
197
|
+
// ============================================================================
|
|
198
|
+
// Public API
|
|
199
|
+
// ============================================================================
|
|
200
|
+
/**
|
|
201
|
+
* Get adapter defaults for a component type.
|
|
202
|
+
* Returns sensible fallbacks for unrecognized types (never throws).
|
|
203
|
+
*
|
|
204
|
+
* @param componentType - The Agent Spec component_type value
|
|
205
|
+
* @returns ComponentTypeDefaults for the type, or fallback for unknown types
|
|
206
|
+
*/
|
|
207
|
+
export function getComponentTypeDefaults(componentType) {
|
|
208
|
+
return COMPONENT_TYPE_DEFAULTS.get(componentType) ?? UNKNOWN_DEFAULTS;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Check if a FlowDrop node ID belongs to an Agent Spec node type.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* isAgentSpecNodeId('agentspec.llm_node') // true
|
|
216
|
+
* isAgentSpecNodeId('calculator') // false
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export function isAgentSpecNodeId(nodeId) {
|
|
220
|
+
return nodeId.startsWith(`${AGENTSPEC_NAMESPACE}.`);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Extract the component_type string from a FlowDrop node type ID.
|
|
224
|
+
* Does not validate against any registry — any string after the namespace prefix is returned.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* extractComponentType('agentspec.llm_node') // 'llm_node'
|
|
229
|
+
* extractComponentType('agentspec.my_custom') // 'my_custom'
|
|
230
|
+
* extractComponentType('calculator') // undefined
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
export function extractComponentType(nodeTypeId) {
|
|
234
|
+
if (!isAgentSpecNodeId(nodeTypeId))
|
|
235
|
+
return undefined;
|
|
236
|
+
const componentType = nodeTypeId.slice(AGENTSPEC_NAMESPACE.length + 1);
|
|
237
|
+
return componentType || undefined;
|
|
238
|
+
}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Agent Spec Node
|
|
2
|
+
* Agent Spec Default Node Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Provides optional starter node type definitions for the Agent Spec format.
|
|
5
|
+
* These are full NodeMetadata objects with visual type, category, default ports,
|
|
6
|
+
* config schema, and icon — suitable for populating the sidebar.
|
|
7
|
+
*
|
|
8
|
+
* These definitions are NOT required by the adapter — the adapter uses
|
|
9
|
+
* componentTypeDefaults.ts for import/export infrastructure.
|
|
10
|
+
* Users can provide their own node definitions instead.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { getDefaultAgentSpecNodeTypes } from '@d34dman/flowdrop/core';
|
|
15
|
+
*
|
|
16
|
+
* mountFlowDropApp(container, {
|
|
17
|
+
* nodes: getDefaultAgentSpecNodeTypes(), // or your own definitions
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
7
20
|
*/
|
|
8
21
|
import type { NodeMetadata, NodePort } from '../../types/index.js';
|
|
9
22
|
import type { AgentSpecNodeComponentType } from '../../types/agentspec.js';
|
|
@@ -21,12 +34,12 @@ import type { AgentSpecNodeComponentType } from '../../types/agentspec.js';
|
|
|
21
34
|
*/
|
|
22
35
|
export declare function getAgentSpecNodeMetadata(componentType: AgentSpecNodeComponentType): NodeMetadata | undefined;
|
|
23
36
|
/**
|
|
24
|
-
* Get all Agent Spec node types as FlowDrop NodeMetadata.
|
|
25
|
-
*
|
|
37
|
+
* Get all default Agent Spec node types as FlowDrop NodeMetadata.
|
|
38
|
+
* These are starter templates — users can provide their own node types instead.
|
|
26
39
|
*
|
|
27
|
-
* @returns Array of NodeMetadata for all 9 Agent Spec node types
|
|
40
|
+
* @returns Array of NodeMetadata for all 9 default Agent Spec node types
|
|
28
41
|
*/
|
|
29
|
-
export declare function
|
|
42
|
+
export declare function getDefaultAgentSpecNodeTypes(): NodeMetadata[];
|
|
30
43
|
/**
|
|
31
44
|
* Get a copy of the NodeMetadata for a component type with custom inputs/outputs.
|
|
32
45
|
* Used during import to create node metadata that matches the Agent Spec definition's
|
|
@@ -38,25 +51,3 @@ export declare function getAllAgentSpecNodeTypes(): NodeMetadata[];
|
|
|
38
51
|
* @returns A new NodeMetadata with the custom ports merged in
|
|
39
52
|
*/
|
|
40
53
|
export declare function createAgentSpecNodeMetadata(componentType: AgentSpecNodeComponentType, inputs?: NodePort[], outputs?: NodePort[]): NodeMetadata | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Check if a FlowDrop node ID belongs to an Agent Spec node type.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* isAgentSpecNodeId('agentspec.llm_node') // true
|
|
47
|
-
* isAgentSpecNodeId('calculator') // false
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare function isAgentSpecNodeId(nodeId: string): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Extract the Agent Spec component_type from a FlowDrop node type ID.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* extractComponentType('agentspec.llm_node') // 'llm_node'
|
|
57
|
-
* extractComponentType('calculator') // undefined
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function extractComponentType(nodeTypeId: string): AgentSpecNodeComponentType | undefined;
|
|
61
|
-
/** The namespace prefix used for Agent Spec node type IDs */
|
|
62
|
-
export declare const AGENTSPEC_NAMESPACE = "agentspec";
|