@d34dman/flowdrop 0.0.56 → 0.0.57

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.
Files changed (43) hide show
  1. package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +92 -0
  2. package/dist/adapters/agentspec/AgentSpecAdapter.js +658 -0
  3. package/dist/adapters/agentspec/agentAdapter.d.ts +59 -0
  4. package/dist/adapters/agentspec/agentAdapter.js +91 -0
  5. package/dist/adapters/agentspec/autoLayout.d.ts +34 -0
  6. package/dist/adapters/agentspec/autoLayout.js +127 -0
  7. package/dist/adapters/agentspec/index.d.ts +35 -0
  8. package/dist/adapters/agentspec/index.js +37 -0
  9. package/dist/adapters/agentspec/nodeTypeRegistry.d.ts +62 -0
  10. package/dist/adapters/agentspec/nodeTypeRegistry.js +589 -0
  11. package/dist/adapters/agentspec/validator.d.ts +34 -0
  12. package/dist/adapters/agentspec/validator.js +169 -0
  13. package/dist/components/ConfigForm.svelte +46 -12
  14. package/dist/components/ConfigForm.svelte.d.ts +8 -0
  15. package/dist/components/SchemaForm.svelte +34 -12
  16. package/dist/components/SchemaForm.svelte.d.ts +8 -0
  17. package/dist/components/form/FormFieldset.svelte +142 -0
  18. package/dist/components/form/FormFieldset.svelte.d.ts +11 -0
  19. package/dist/components/form/FormUISchemaRenderer.svelte +140 -0
  20. package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +32 -0
  21. package/dist/components/form/index.d.ts +2 -0
  22. package/dist/components/form/index.js +3 -0
  23. package/dist/config/agentSpecEndpoints.d.ts +70 -0
  24. package/dist/config/agentSpecEndpoints.js +65 -0
  25. package/dist/config/endpoints.d.ts +6 -0
  26. package/dist/core/index.d.ts +17 -1
  27. package/dist/core/index.js +17 -0
  28. package/dist/form/index.d.ts +2 -0
  29. package/dist/form/index.js +3 -0
  30. package/dist/helpers/workflowEditorHelper.d.ts +24 -0
  31. package/dist/helpers/workflowEditorHelper.js +55 -0
  32. package/dist/services/agentSpecExecutionService.d.ts +106 -0
  33. package/dist/services/agentSpecExecutionService.js +333 -0
  34. package/dist/types/agentspec.d.ts +318 -0
  35. package/dist/types/agentspec.js +48 -0
  36. package/dist/types/events.d.ts +28 -1
  37. package/dist/types/index.d.ts +13 -0
  38. package/dist/types/index.js +1 -0
  39. package/dist/types/uischema.d.ts +144 -0
  40. package/dist/types/uischema.js +51 -0
  41. package/dist/utils/uischema.d.ts +52 -0
  42. package/dist/utils/uischema.js +88 -0
  43. package/package.json +1 -1
@@ -0,0 +1,32 @@
1
+ import type { UISchemaElement } from '../../types/uischema.js';
2
+ import type { ConfigSchema, WorkflowNode, WorkflowEdge, AuthProvider } from '../../types/index.js';
3
+ import type { FieldSchema } from './types.js';
4
+ interface Props {
5
+ /** The UISchema element to render */
6
+ element: UISchemaElement;
7
+ /** The data schema (for resolving field definitions) */
8
+ schema: ConfigSchema;
9
+ /** Current form values */
10
+ values: Record<string, unknown>;
11
+ /** Required field keys from the schema */
12
+ requiredFields?: string[];
13
+ /** Base animation index for staggered animations */
14
+ animationIndexBase?: number;
15
+ /** Callback when a field value changes */
16
+ onFieldChange: (key: string, value: unknown) => void;
17
+ /** Convert a property to FieldSchema (handles template variable injection etc.) */
18
+ toFieldSchema: (property: Record<string, unknown>) => FieldSchema;
19
+ /** Current workflow node (optional, passed through to FormField) */
20
+ node?: WorkflowNode;
21
+ /** All workflow nodes (optional, passed through to FormField) */
22
+ nodes?: WorkflowNode[];
23
+ /** All workflow edges (optional, passed through to FormField) */
24
+ edges?: WorkflowEdge[];
25
+ /** Workflow ID (optional, passed through to FormField) */
26
+ workflowId?: string;
27
+ /** Auth provider (optional, passed through to FormField) */
28
+ authProvider?: AuthProvider;
29
+ }
30
+ declare const FormUISchemaRenderer: import("svelte").Component<Props, {}, "">;
31
+ type FormUISchemaRenderer = ReturnType<typeof FormUISchemaRenderer>;
32
+ export default FormUISchemaRenderer;
@@ -44,4 +44,6 @@ export { default as FormCodeEditor } from './FormCodeEditor.svelte';
44
44
  export { default as FormMarkdownEditor } from './FormMarkdownEditor.svelte';
45
45
  export { default as FormTemplateEditor } from './FormTemplateEditor.svelte';
46
46
  export { default as FormAutocomplete } from './FormAutocomplete.svelte';
47
+ export { default as FormFieldset } from './FormFieldset.svelte';
48
+ export { default as FormUISchemaRenderer } from './FormUISchemaRenderer.svelte';
47
49
  export { createTemplateAutocomplete } from './templateAutocomplete.js';
@@ -48,5 +48,8 @@ export { default as FormCodeEditor } from './FormCodeEditor.svelte';
48
48
  export { default as FormMarkdownEditor } from './FormMarkdownEditor.svelte';
49
49
  export { default as FormTemplateEditor } from './FormTemplateEditor.svelte';
50
50
  export { default as FormAutocomplete } from './FormAutocomplete.svelte';
51
+ // UISchema rendering components
52
+ export { default as FormFieldset } from './FormFieldset.svelte';
53
+ export { default as FormUISchemaRenderer } from './FormUISchemaRenderer.svelte';
51
54
  // Template autocomplete utilities
52
55
  export { createTemplateAutocomplete } from './templateAutocomplete.js';
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Agent Spec Runtime Endpoint Configuration
3
+ *
4
+ * Defines the API endpoints for connecting to Agent Spec runtimes
5
+ * (WayFlow, PyAgentSpec, or other compatible runtimes).
6
+ */
7
+ /**
8
+ * Agent Spec runtime endpoint configuration.
9
+ *
10
+ * Separate from the main FlowDrop EndpointConfig because the Agent Spec
11
+ * runtime is an independent service with its own base URL and auth.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const config: AgentSpecEndpointConfig = {
16
+ * baseUrl: 'http://localhost:8000',
17
+ * endpoints: { ...defaultAgentSpecEndpoints.endpoints },
18
+ * auth: { type: 'bearer', token: 'my-api-key' }
19
+ * };
20
+ * ```
21
+ */
22
+ export interface AgentSpecEndpointConfig {
23
+ /** Base URL for the Agent Spec runtime */
24
+ baseUrl: string;
25
+ endpoints: {
26
+ /** POST — Execute a flow (body: AgentSpecFlow JSON) */
27
+ execute: string;
28
+ /** GET — Get execution status (params: {id}) */
29
+ status: string;
30
+ /** POST — Cancel a running execution (params: {id}) */
31
+ cancel: string;
32
+ /** GET — Get execution results (params: {id}) */
33
+ results: string;
34
+ /** WS — WebSocket for streaming execution updates (params: {id}) */
35
+ stream: string;
36
+ /** POST — Validate a flow specification (body: AgentSpecFlow JSON) */
37
+ validate: string;
38
+ /** GET — List available agents on the runtime */
39
+ agents: string;
40
+ /** GET — List available tools on the runtime */
41
+ tools: string;
42
+ /** GET — Runtime health check */
43
+ health: string;
44
+ };
45
+ /** Authentication for the runtime */
46
+ auth?: {
47
+ type: 'none' | 'bearer' | 'api_key';
48
+ token?: string;
49
+ apiKey?: string;
50
+ };
51
+ /** Request timeout in milliseconds */
52
+ timeout?: number;
53
+ }
54
+ /**
55
+ * Default Agent Spec runtime endpoints.
56
+ * Targets a local WayFlow/PyAgentSpec instance on port 8000.
57
+ */
58
+ export declare const defaultAgentSpecEndpoints: AgentSpecEndpointConfig;
59
+ /**
60
+ * Create Agent Spec endpoint configuration with custom base URL.
61
+ */
62
+ export declare function createAgentSpecEndpointConfig(baseUrl: string, overrides?: Partial<AgentSpecEndpointConfig>): AgentSpecEndpointConfig;
63
+ /**
64
+ * Build a full URL for an Agent Spec runtime endpoint.
65
+ */
66
+ export declare function buildAgentSpecUrl(config: AgentSpecEndpointConfig, endpointPath: string, params?: Record<string, string>): string;
67
+ /**
68
+ * Get authentication headers for Agent Spec runtime requests.
69
+ */
70
+ export declare function getAgentSpecAuthHeaders(config: AgentSpecEndpointConfig): Record<string, string>;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Agent Spec Runtime Endpoint Configuration
3
+ *
4
+ * Defines the API endpoints for connecting to Agent Spec runtimes
5
+ * (WayFlow, PyAgentSpec, or other compatible runtimes).
6
+ */
7
+ /**
8
+ * Default Agent Spec runtime endpoints.
9
+ * Targets a local WayFlow/PyAgentSpec instance on port 8000.
10
+ */
11
+ export const defaultAgentSpecEndpoints = {
12
+ baseUrl: 'http://localhost:8000',
13
+ endpoints: {
14
+ execute: '/flows/execute',
15
+ status: '/executions/{id}',
16
+ cancel: '/executions/{id}/cancel',
17
+ results: '/executions/{id}/results',
18
+ stream: '/executions/{id}/stream',
19
+ validate: '/flows/validate',
20
+ agents: '/agents',
21
+ tools: '/tools',
22
+ health: '/health'
23
+ },
24
+ timeout: 60000
25
+ };
26
+ /**
27
+ * Create Agent Spec endpoint configuration with custom base URL.
28
+ */
29
+ export function createAgentSpecEndpointConfig(baseUrl, overrides) {
30
+ return {
31
+ ...defaultAgentSpecEndpoints,
32
+ baseUrl: baseUrl.replace(/\/$/, ''),
33
+ ...overrides
34
+ };
35
+ }
36
+ /**
37
+ * Build a full URL for an Agent Spec runtime endpoint.
38
+ */
39
+ export function buildAgentSpecUrl(config, endpointPath, params) {
40
+ let url = endpointPath;
41
+ if (params) {
42
+ for (const [key, value] of Object.entries(params)) {
43
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
44
+ }
45
+ }
46
+ if (!url.startsWith('http') && !url.startsWith('//')) {
47
+ url = `${config.baseUrl}${url.startsWith('/') ? url : `/${url}`}`;
48
+ }
49
+ return url;
50
+ }
51
+ /**
52
+ * Get authentication headers for Agent Spec runtime requests.
53
+ */
54
+ export function getAgentSpecAuthHeaders(config) {
55
+ const headers = {
56
+ 'Content-Type': 'application/json'
57
+ };
58
+ if (config.auth?.type === 'bearer' && config.auth.token) {
59
+ headers['Authorization'] = `Bearer ${config.auth.token}`;
60
+ }
61
+ else if (config.auth?.type === 'api_key' && config.auth.apiKey) {
62
+ headers['X-API-Key'] = config.auth.apiKey;
63
+ }
64
+ return headers;
65
+ }
@@ -2,6 +2,7 @@
2
2
  * FlowDrop Endpoint Configuration
3
3
  * Provides configurable endpoints for all API actions
4
4
  */
5
+ import type { AgentSpecEndpointConfig } from './agentSpecEndpoints.js';
5
6
  export interface EndpointConfig {
6
7
  /** Base URL for all endpoints */
7
8
  baseUrl: string;
@@ -88,6 +89,11 @@ export interface EndpointConfig {
88
89
  version: string;
89
90
  };
90
91
  };
92
+ /**
93
+ * Optional Agent Spec runtime configuration.
94
+ * When provided, enables Agent Spec execution features.
95
+ */
96
+ agentSpec?: AgentSpecEndpointConfig;
91
97
  /** HTTP method overrides for specific endpoints */
92
98
  methods?: {
93
99
  [key: string]: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
@@ -14,7 +14,8 @@
14
14
  * import { getStatusColor, createDefaultExecutionInfo } from "@d34dman/flowdrop/core";
15
15
  * ```
16
16
  */
17
- export type { NodeCategory, BuiltinNodeCategory, CategoryDefinition, NodeDataType, NodePort, DynamicPort, Branch, NodeMetadata, NodeExtensions, NodeUIExtensions, ConfigValues, WorkflowNode, WorkflowEdge, Workflow, ApiResponse, NodesResponse, WorkflowResponse, WorkflowsResponse, ExecutionStatus, ExecutionResult, FlowDropConfig, WorkflowEvents, BuiltinNodeType, PortConfig, PortCompatibilityRule, ConfigSchema, ConfigProperty, HttpMethod, DynamicSchemaEndpoint, ExternalEditLink, ConfigEditOptions, EdgeCategory } from '../types/index.js';
17
+ export type { NodeCategory, BuiltinNodeCategory, CategoryDefinition, NodeDataType, NodePort, DynamicPort, Branch, NodeMetadata, NodeExtensions, NodeUIExtensions, ConfigValues, WorkflowNode, WorkflowEdge, Workflow, ApiResponse, NodesResponse, WorkflowResponse, WorkflowsResponse, ExecutionStatus, ExecutionResult, FlowDropConfig, WorkflowEvents, BuiltinNodeType, PortConfig, PortCompatibilityRule, ConfigSchema, ConfigProperty, HttpMethod, DynamicSchemaEndpoint, ExternalEditLink, ConfigEditOptions, EdgeCategory, UISchemaElementType, UISchemaElementBase, UISchemaControl, UISchemaVerticalLayout, UISchemaGroup, UISchemaElement } from '../types/index.js';
18
+ export { isUISchemaControl, isUISchemaVerticalLayout, isUISchemaGroup } from '../types/index.js';
18
19
  export type { WorkflowEditorConfig, EditorFeatures, UIConfig, APIConfig, ExecutionConfig, StorageConfig } from '../types/config.js';
19
20
  export type { AuthProvider, StaticAuthConfig, CallbackAuthConfig } from '../types/auth.js';
20
21
  export type { WorkflowChangeType, FlowDropEventHandlers, FlowDropFeatures } from '../types/events.js';
@@ -37,8 +38,23 @@ export * from '../utils/config.js';
37
38
  export * from '../utils/nodeTypes.js';
38
39
  export { isLoopbackEdge, isValidLoopbackCycle, hasCycles, hasInvalidCycles } from '../utils/connections.js';
39
40
  export { isFieldOptionArray, normalizeOptions } from '../components/form/types.js';
41
+ export { resolveScopeToKey, keyToScope, generateDefaultUISchema, collectReferencedKeys } from '../utils/uischema.js';
40
42
  export { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
41
43
  export { defaultEndpointConfig, createEndpointConfig } from '../config/endpoints.js';
42
44
  export * from '../adapters/WorkflowAdapter.js';
45
+ export type { AgentSpecNodeComponentType, AgentSpecToolComponentType, AgentSpecComponentType, AgentSpecProperty, AgentSpecNodeBase, AgentSpecStartNode, AgentSpecEndNode, AgentSpecLLMNode, AgentSpecAPINode, AgentSpecAgentNode, AgentSpecFlowNode, AgentSpecMapNode, AgentSpecBranchingNode, AgentSpecToolNode, AgentSpecNode, AgentSpecBranch, AgentSpecControlFlowEdge, AgentSpecDataFlowEdge, AgentSpecFlow, AgentSpecToolBase, AgentSpecServerTool, AgentSpecClientTool, AgentSpecRemoteTool, AgentSpecTool, AgentSpecLLMConfig, AgentSpecAgent, AgentSpecDocument } from '../types/agentspec.js';
46
+ export { COMPONENT_REF_PREFIX, isComponentRef, extractComponentRefId, createComponentRef } from '../types/agentspec.js';
47
+ export { getAgentSpecNodeMetadata, getAllAgentSpecNodeTypes, createAgentSpecNodeMetadata, isAgentSpecNodeId, extractComponentType, AGENTSPEC_NAMESPACE } from '../adapters/agentspec/nodeTypeRegistry.js';
48
+ export { AgentSpecAdapter } from '../adapters/agentspec/AgentSpecAdapter.js';
49
+ export { AgentSpecAgentAdapter } from '../adapters/agentspec/agentAdapter.js';
50
+ export type { AgentConfig, AgentSpecImportResult } from '../adapters/agentspec/agentAdapter.js';
51
+ export { validateForAgentSpecExport, validateAgentSpecFlow } from '../adapters/agentspec/validator.js';
52
+ export type { AgentSpecValidationResult } from '../adapters/agentspec/validator.js';
53
+ export { computeAutoLayout } from '../adapters/agentspec/autoLayout.js';
54
+ export type { AutoLayoutConfig } from '../adapters/agentspec/autoLayout.js';
55
+ export type { AgentSpecEndpointConfig } from '../config/agentSpecEndpoints.js';
56
+ export { defaultAgentSpecEndpoints, createAgentSpecEndpointConfig, buildAgentSpecUrl, getAgentSpecAuthHeaders } from '../config/agentSpecEndpoints.js';
57
+ export { AgentSpecExecutionService, agentSpecExecutionService } from '../services/agentSpecExecutionService.js';
58
+ export type { AgentSpecExecutionHandle } from '../services/agentSpecExecutionService.js';
43
59
  export type { ThemePreference, ResolvedTheme } from '../stores/settingsStore.js';
44
60
  export { theme, resolvedTheme, setTheme, toggleTheme, cycleTheme, initializeTheme, isThemeInitialized } from '../stores/settingsStore.js';
@@ -14,6 +14,7 @@
14
14
  * import { getStatusColor, createDefaultExecutionInfo } from "@d34dman/flowdrop/core";
15
15
  * ```
16
16
  */
17
+ export { isUISchemaControl, isUISchemaVerticalLayout, isUISchemaGroup } from '../types/index.js';
17
18
  export { isChatInputNode, CHAT_INPUT_PATTERNS } from '../types/playground.js';
18
19
  // ============================================================================
19
20
  // Authentication Providers (no dependencies)
@@ -42,6 +43,8 @@ export * from '../utils/nodeTypes.js';
42
43
  export { isLoopbackEdge, isValidLoopbackCycle, hasCycles, hasInvalidCycles } from '../utils/connections.js';
43
44
  // Form type utilities
44
45
  export { isFieldOptionArray, normalizeOptions } from '../components/form/types.js';
46
+ // UISchema utilities
47
+ export { resolveScopeToKey, keyToScope, generateDefaultUISchema, collectReferencedKeys } from '../utils/uischema.js';
45
48
  // ============================================================================
46
49
  // Configuration
47
50
  // ============================================================================
@@ -51,4 +54,18 @@ export { defaultEndpointConfig, createEndpointConfig } from '../config/endpoints
51
54
  // Adapters
52
55
  // ============================================================================
53
56
  export * from '../adapters/WorkflowAdapter.js';
57
+ export { COMPONENT_REF_PREFIX, isComponentRef, extractComponentRefId, createComponentRef } from '../types/agentspec.js';
58
+ // Agent Spec node type registry
59
+ export { getAgentSpecNodeMetadata, getAllAgentSpecNodeTypes, createAgentSpecNodeMetadata, isAgentSpecNodeId, extractComponentType, AGENTSPEC_NAMESPACE } from '../adapters/agentspec/nodeTypeRegistry.js';
60
+ // Agent Spec adapter (bidirectional conversion)
61
+ export { AgentSpecAdapter } from '../adapters/agentspec/AgentSpecAdapter.js';
62
+ // Agent Spec agent-level adapter
63
+ export { AgentSpecAgentAdapter } from '../adapters/agentspec/agentAdapter.js';
64
+ // Agent Spec validation
65
+ export { validateForAgentSpecExport, validateAgentSpecFlow } from '../adapters/agentspec/validator.js';
66
+ // Agent Spec auto-layout
67
+ export { computeAutoLayout } from '../adapters/agentspec/autoLayout.js';
68
+ export { defaultAgentSpecEndpoints, createAgentSpecEndpointConfig, buildAgentSpecUrl, getAgentSpecAuthHeaders } from '../config/agentSpecEndpoints.js';
69
+ // Agent Spec execution service
70
+ export { AgentSpecExecutionService, agentSpecExecutionService } from '../services/agentSpecExecutionService.js';
54
71
  export { theme, resolvedTheme, setTheme, toggleTheme, cycleTheme, initializeTheme, isThemeInitialized } from '../stores/settingsStore.js';
@@ -69,6 +69,8 @@ export { default as FormToggle } from '../components/form/FormToggle.svelte';
69
69
  export { default as FormSelect } from '../components/form/FormSelect.svelte';
70
70
  export { default as FormCheckboxGroup } from '../components/form/FormCheckboxGroup.svelte';
71
71
  export { default as FormArray } from '../components/form/FormArray.svelte';
72
+ export { default as FormFieldset } from '../components/form/FormFieldset.svelte';
73
+ export { default as FormUISchemaRenderer } from '../components/form/FormUISchemaRenderer.svelte';
72
74
  export type { FieldSchema, FieldType, FieldFormat, FieldOption, OneOfItem, SchemaFormProps, BaseFieldProps, TextFieldProps, TextareaFieldProps, NumberFieldProps, ToggleFieldProps, RangeFieldProps, SelectFieldProps, CheckboxGroupFieldProps, ArrayFieldProps, FormFieldFactoryProps, FormFieldWrapperProps } from '../components/form/types.js';
73
75
  export { isFieldOptionArray, isOneOfArray, normalizeOptions, oneOfToOptions, getSchemaOptions } from '../components/form/types.js';
74
76
  export { registerFieldComponent, unregisterFieldComponent, resolveFieldComponent, getRegisteredFieldTypes, isFieldTypeRegistered, clearFieldRegistry, getFieldRegistrySize, hiddenFieldMatcher, checkboxGroupMatcher, enumSelectMatcher, textareaMatcher, rangeMatcher, textFieldMatcher, numberFieldMatcher, toggleMatcher, selectOptionsMatcher, arrayMatcher } from './fieldRegistry.js';
@@ -77,6 +77,9 @@ export { default as FormToggle } from '../components/form/FormToggle.svelte';
77
77
  export { default as FormSelect } from '../components/form/FormSelect.svelte';
78
78
  export { default as FormCheckboxGroup } from '../components/form/FormCheckboxGroup.svelte';
79
79
  export { default as FormArray } from '../components/form/FormArray.svelte';
80
+ // UISchema rendering components
81
+ export { default as FormFieldset } from '../components/form/FormFieldset.svelte';
82
+ export { default as FormUISchemaRenderer } from '../components/form/FormUISchemaRenderer.svelte';
80
83
  export { isFieldOptionArray, isOneOfArray, normalizeOptions, oneOfToOptions, getSchemaOptions } from '../components/form/types.js';
81
84
  // ============================================================================
82
85
  // Field Registry (for dynamic field registration)
@@ -131,6 +131,30 @@ export declare class WorkflowOperationsHelper {
131
131
  * Export workflow as JSON file
132
132
  */
133
133
  static exportWorkflow(workflow: Workflow | null): void;
134
+ /**
135
+ * Export workflow as Agent Spec JSON file.
136
+ *
137
+ * Converts the FlowDrop workflow to Agent Spec format and triggers a download.
138
+ * Validates the workflow for Agent Spec compatibility first.
139
+ *
140
+ * @param workflow - The FlowDrop workflow to export
141
+ * @returns Validation result (check .valid before assuming success)
142
+ */
143
+ static exportAsAgentSpec(workflow: Workflow | null): {
144
+ valid: boolean;
145
+ errors: string[];
146
+ warnings: string[];
147
+ };
148
+ /**
149
+ * Import a workflow from an Agent Spec JSON or YAML file.
150
+ *
151
+ * Reads the file, detects format, converts to FlowDrop format,
152
+ * and returns a Workflow ready for the editor.
153
+ *
154
+ * @param file - The file to import (JSON or YAML)
155
+ * @returns Promise resolving to the imported FlowDrop Workflow
156
+ */
157
+ static importFromAgentSpec(file: File): Promise<Workflow>;
134
158
  /**
135
159
  * Check if workflow has invalid cycles (excludes valid loopback cycles)
136
160
  * Valid loopback cycles are used for ForEach node iteration and should not
@@ -8,6 +8,9 @@ import { workflowApi, nodeApi, setEndpointConfig } from '../services/api.js';
8
8
  import { v4 as uuidv4 } from 'uuid';
9
9
  import { workflowActions } from '../stores/workflowStore.js';
10
10
  import { nodeExecutionService } from '../services/nodeExecutionService.js';
11
+ import { WorkflowAdapter } from '../adapters/WorkflowAdapter.js';
12
+ import { AgentSpecAdapter } from '../adapters/agentspec/AgentSpecAdapter.js';
13
+ import { validateForAgentSpecExport } from '../adapters/agentspec/validator.js';
11
14
  /**
12
15
  * Generate a unique node ID based on node type and existing nodes
13
16
  * Format: <node_type>.<number>
@@ -537,6 +540,58 @@ export class WorkflowOperationsHelper {
537
540
  link.click();
538
541
  URL.revokeObjectURL(url);
539
542
  }
543
+ /**
544
+ * Export workflow as Agent Spec JSON file.
545
+ *
546
+ * Converts the FlowDrop workflow to Agent Spec format and triggers a download.
547
+ * Validates the workflow for Agent Spec compatibility first.
548
+ *
549
+ * @param workflow - The FlowDrop workflow to export
550
+ * @returns Validation result (check .valid before assuming success)
551
+ */
552
+ static exportAsAgentSpec(workflow) {
553
+ if (!workflow) {
554
+ return { valid: false, errors: ['No workflow data available to export'], warnings: [] };
555
+ }
556
+ // Convert to StandardWorkflow first
557
+ const workflowAdapter = new WorkflowAdapter();
558
+ const standardWorkflow = workflowAdapter.fromSvelteFlow(workflow);
559
+ // Validate for Agent Spec
560
+ const validation = validateForAgentSpecExport(standardWorkflow);
561
+ if (!validation.valid) {
562
+ return validation;
563
+ }
564
+ // Convert to Agent Spec
565
+ const agentSpecAdapter = new AgentSpecAdapter();
566
+ const agentSpecJson = agentSpecAdapter.exportJSON(standardWorkflow);
567
+ // Trigger download
568
+ const dataBlob = new Blob([agentSpecJson], { type: 'application/json' });
569
+ const url = URL.createObjectURL(dataBlob);
570
+ const link = document.createElement('a');
571
+ link.href = url;
572
+ link.download = `${workflow.name || 'workflow'}-agentspec.json`;
573
+ link.click();
574
+ URL.revokeObjectURL(url);
575
+ return validation;
576
+ }
577
+ /**
578
+ * Import a workflow from an Agent Spec JSON or YAML file.
579
+ *
580
+ * Reads the file, detects format, converts to FlowDrop format,
581
+ * and returns a Workflow ready for the editor.
582
+ *
583
+ * @param file - The file to import (JSON or YAML)
584
+ * @returns Promise resolving to the imported FlowDrop Workflow
585
+ */
586
+ static async importFromAgentSpec(file) {
587
+ const text = await file.text();
588
+ const agentSpecAdapter = new AgentSpecAdapter();
589
+ const workflowAdapter = new WorkflowAdapter();
590
+ // Parse the Agent Spec data
591
+ const standardWorkflow = agentSpecAdapter.importJSON(text);
592
+ // Convert to SvelteFlow format
593
+ return workflowAdapter.toSvelteFlow(standardWorkflow);
594
+ }
540
595
  /**
541
596
  * Check if workflow has invalid cycles (excludes valid loopback cycles)
542
597
  * Valid loopback cycles are used for ForEach node iteration and should not
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Agent Spec Execution Service
3
+ *
4
+ * Connects FlowDrop to Agent Spec runtimes (WayFlow/PyAgentSpec) for
5
+ * workflow execution, status tracking, and result retrieval.
6
+ *
7
+ * Follows the same singleton pattern as NodeExecutionService.
8
+ */
9
+ import type { NodeExecutionInfo } from '../types/index.js';
10
+ import type { StandardWorkflow } from '../adapters/WorkflowAdapter.js';
11
+ import type { AgentSpecEndpointConfig } from '../config/agentSpecEndpoints.js';
12
+ /** Result returned when starting an execution */
13
+ export interface AgentSpecExecutionHandle {
14
+ /** Unique execution ID from the runtime */
15
+ executionId: string;
16
+ /** Stop polling and clean up */
17
+ stop: () => void;
18
+ }
19
+ /**
20
+ * Service for executing FlowDrop workflows on Agent Spec runtimes.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const service = AgentSpecExecutionService.getInstance();
25
+ * service.configure(myRuntimeConfig);
26
+ *
27
+ * // Check runtime availability
28
+ * const healthy = await service.checkHealth();
29
+ *
30
+ * // Execute a workflow
31
+ * const handle = await service.executeWorkflow(workflow, inputs, {
32
+ * onNodeUpdate: (nodeId, info) => updateNodeVisual(nodeId, info),
33
+ * onComplete: (results) => showResults(results),
34
+ * onError: (error) => showError(error)
35
+ * });
36
+ *
37
+ * // Cancel if needed
38
+ * await service.cancelExecution(handle.executionId);
39
+ * ```
40
+ */
41
+ export declare class AgentSpecExecutionService {
42
+ private static instance;
43
+ private config;
44
+ private adapter;
45
+ private activeExecutions;
46
+ private constructor();
47
+ static getInstance(): AgentSpecExecutionService;
48
+ /**
49
+ * Configure the runtime connection.
50
+ */
51
+ configure(config: AgentSpecEndpointConfig): void;
52
+ /**
53
+ * Check if the service has been configured with a runtime.
54
+ */
55
+ isConfigured(): boolean;
56
+ /**
57
+ * Check runtime health.
58
+ */
59
+ checkHealth(): Promise<boolean>;
60
+ /**
61
+ * Execute a FlowDrop workflow on the Agent Spec runtime.
62
+ *
63
+ * 1. Converts StandardWorkflow → AgentSpecFlow using the adapter
64
+ * 2. POSTs the flow JSON to the runtime
65
+ * 3. Starts polling for execution status
66
+ * 4. Maps runtime node statuses to FlowDrop's NodeExecutionInfo
67
+ */
68
+ executeWorkflow(workflow: StandardWorkflow, inputs?: Record<string, unknown>, callbacks?: {
69
+ onNodeUpdate?: (nodeId: string, info: NodeExecutionInfo) => void;
70
+ onComplete?: (results: Record<string, unknown>) => void;
71
+ onError?: (error: Error) => void;
72
+ }, pollingIntervalMs?: number): Promise<AgentSpecExecutionHandle>;
73
+ /**
74
+ * Get current execution status.
75
+ */
76
+ getExecutionStatus(executionId: string): Promise<Record<string, NodeExecutionInfo> | null>;
77
+ /**
78
+ * Cancel a running execution.
79
+ */
80
+ cancelExecution(executionId: string): Promise<void>;
81
+ /**
82
+ * Get execution results.
83
+ */
84
+ getResults(executionId: string): Promise<Record<string, unknown> | null>;
85
+ /**
86
+ * Validate a workflow against the runtime.
87
+ */
88
+ validateOnRuntime(workflow: StandardWorkflow): Promise<{
89
+ valid: boolean;
90
+ errors?: string[];
91
+ }>;
92
+ /**
93
+ * Clean up all active executions.
94
+ */
95
+ destroy(): void;
96
+ private ensureConfigured;
97
+ /** Get the config, throwing if not configured */
98
+ private getConfig;
99
+ private startPolling;
100
+ private stopPolling;
101
+ private mapRuntimeStatusToNodeInfo;
102
+ private mapSingleNodeStatus;
103
+ private mapToFlowDropStatus;
104
+ }
105
+ /** Singleton instance */
106
+ export declare const agentSpecExecutionService: AgentSpecExecutionService;