@flowdrop/flowdrop 1.0.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/LICENSE +21 -0
- package/README.md +252 -0
- package/dist/adapters/WorkflowAdapter.d.ts +167 -0
- package/dist/adapters/WorkflowAdapter.js +368 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.d.ts +96 -0
- package/dist/adapters/agentspec/AgentSpecAdapter.js +626 -0
- package/dist/adapters/agentspec/agentAdapter.d.ts +59 -0
- package/dist/adapters/agentspec/agentAdapter.js +91 -0
- package/dist/adapters/agentspec/autoLayout.d.ts +34 -0
- package/dist/adapters/agentspec/autoLayout.js +127 -0
- package/dist/adapters/agentspec/componentTypeDefaults.d.ts +73 -0
- package/dist/adapters/agentspec/componentTypeDefaults.js +238 -0
- package/dist/adapters/agentspec/defaultNodeTypes.d.ts +53 -0
- package/dist/adapters/agentspec/defaultNodeTypes.js +561 -0
- package/dist/adapters/agentspec/index.d.ts +37 -0
- package/dist/adapters/agentspec/index.js +39 -0
- package/dist/adapters/agentspec/validator.d.ts +34 -0
- package/dist/adapters/agentspec/validator.js +169 -0
- package/dist/api/enhanced-client.d.ts +183 -0
- package/dist/api/enhanced-client.js +430 -0
- package/dist/components/App.svelte +981 -0
- package/dist/components/App.svelte.d.ts +54 -0
- package/dist/components/CanvasBanner.stories.svelte +29 -0
- package/dist/components/CanvasBanner.stories.svelte.d.ts +27 -0
- package/dist/components/CanvasBanner.svelte +57 -0
- package/dist/components/CanvasBanner.svelte.d.ts +8 -0
- package/dist/components/ConfigForm.svelte +1138 -0
- package/dist/components/ConfigForm.svelte.d.ts +44 -0
- package/dist/components/ConfigModal.svelte +188 -0
- package/dist/components/ConfigModal.svelte.d.ts +13 -0
- package/dist/components/ConfigPanel.stories.svelte +47 -0
- package/dist/components/ConfigPanel.stories.svelte.d.ts +27 -0
- package/dist/components/ConfigPanel.svelte +182 -0
- package/dist/components/ConfigPanel.svelte.d.ts +32 -0
- package/dist/components/ConnectionLine.svelte +32 -0
- package/dist/components/ConnectionLine.svelte.d.ts +3 -0
- package/dist/components/EdgeRefresher.svelte +41 -0
- package/dist/components/EdgeRefresher.svelte.d.ts +9 -0
- package/dist/components/FlowDropZone.svelte +83 -0
- package/dist/components/FlowDropZone.svelte.d.ts +13 -0
- package/dist/components/LoadingSpinner.stories.svelte +30 -0
- package/dist/components/LoadingSpinner.stories.svelte.d.ts +27 -0
- package/dist/components/LoadingSpinner.svelte +36 -0
- package/dist/components/LoadingSpinner.svelte.d.ts +8 -0
- package/dist/components/Logo.stories.svelte +22 -0
- package/dist/components/Logo.stories.svelte.d.ts +27 -0
- package/dist/components/Logo.svelte +102 -0
- package/dist/components/Logo.svelte.d.ts +26 -0
- package/dist/components/LogsSidebar.svelte +563 -0
- package/dist/components/LogsSidebar.svelte.d.ts +17 -0
- package/dist/components/MarkdownDisplay.stories.svelte +36 -0
- package/dist/components/MarkdownDisplay.stories.svelte.d.ts +27 -0
- package/dist/components/MarkdownDisplay.svelte +29 -0
- package/dist/components/MarkdownDisplay.svelte.d.ts +7 -0
- package/dist/components/Navbar.stories.svelte +53 -0
- package/dist/components/Navbar.stories.svelte.d.ts +27 -0
- package/dist/components/Navbar.svelte +726 -0
- package/dist/components/Navbar.svelte.d.ts +29 -0
- package/dist/components/NodeSidebar.svelte +762 -0
- package/dist/components/NodeSidebar.svelte.d.ts +9 -0
- package/dist/components/NodeStatusOverlay.stories.svelte +85 -0
- package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +27 -0
- package/dist/components/NodeStatusOverlay.svelte +327 -0
- package/dist/components/NodeStatusOverlay.svelte.d.ts +11 -0
- package/dist/components/PipelineStatus.svelte +314 -0
- package/dist/components/PipelineStatus.svelte.d.ts +20 -0
- package/dist/components/PortCoordinateTracker.svelte +58 -0
- package/dist/components/PortCoordinateTracker.svelte.d.ts +12 -0
- package/dist/components/ReadOnlyDetails.svelte +170 -0
- package/dist/components/ReadOnlyDetails.svelte.d.ts +25 -0
- package/dist/components/SchemaForm.stories.svelte +116 -0
- package/dist/components/SchemaForm.stories.svelte.d.ts +27 -0
- package/dist/components/SchemaForm.svelte +536 -0
- package/dist/components/SchemaForm.svelte.d.ts +83 -0
- package/dist/components/SettingsModal.svelte +279 -0
- package/dist/components/SettingsModal.svelte.d.ts +23 -0
- package/dist/components/SettingsPanel.svelte +638 -0
- package/dist/components/SettingsPanel.svelte.d.ts +21 -0
- package/dist/components/StatusIcon.stories.svelte +60 -0
- package/dist/components/StatusIcon.stories.svelte.d.ts +27 -0
- package/dist/components/StatusIcon.svelte +119 -0
- package/dist/components/StatusIcon.svelte.d.ts +10 -0
- package/dist/components/StatusLabel.stories.svelte +17 -0
- package/dist/components/StatusLabel.stories.svelte.d.ts +27 -0
- package/dist/components/StatusLabel.svelte +33 -0
- package/dist/components/StatusLabel.svelte.d.ts +7 -0
- package/dist/components/ThemeToggle.stories.svelte +25 -0
- package/dist/components/ThemeToggle.stories.svelte.d.ts +27 -0
- package/dist/components/ThemeToggle.svelte +185 -0
- package/dist/components/ThemeToggle.svelte.d.ts +14 -0
- package/dist/components/UniversalNode.svelte +155 -0
- package/dist/components/UniversalNode.svelte.d.ts +15 -0
- package/dist/components/WorkflowEditor.svelte +1035 -0
- package/dist/components/WorkflowEditor.svelte.d.ts +23 -0
- package/dist/components/form/FormArray.svelte +1049 -0
- package/dist/components/form/FormArray.svelte.d.ts +22 -0
- package/dist/components/form/FormAutocomplete.svelte +1009 -0
- package/dist/components/form/FormAutocomplete.svelte.d.ts +25 -0
- package/dist/components/form/FormCheckboxGroup.stories.svelte +28 -0
- package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormCheckboxGroup.svelte +155 -0
- package/dist/components/form/FormCheckboxGroup.svelte.d.ts +17 -0
- package/dist/components/form/FormCodeEditor.svelte +458 -0
- package/dist/components/form/FormCodeEditor.svelte.d.ts +25 -0
- package/dist/components/form/FormField.svelte +417 -0
- package/dist/components/form/FormField.svelte.d.ts +29 -0
- package/dist/components/form/FormFieldLight.svelte +425 -0
- package/dist/components/form/FormFieldLight.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldWrapper.stories.svelte +53 -0
- package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormFieldWrapper.svelte +125 -0
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldset.svelte +142 -0
- package/dist/components/form/FormFieldset.svelte.d.ts +11 -0
- package/dist/components/form/FormMarkdownEditor.svelte +752 -0
- package/dist/components/form/FormMarkdownEditor.svelte.d.ts +33 -0
- package/dist/components/form/FormNumberField.stories.svelte +36 -0
- package/dist/components/form/FormNumberField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormNumberField.svelte +112 -0
- package/dist/components/form/FormNumberField.svelte.d.ts +25 -0
- package/dist/components/form/FormRangeField.stories.svelte +31 -0
- package/dist/components/form/FormRangeField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormRangeField.svelte +246 -0
- package/dist/components/form/FormRangeField.svelte.d.ts +23 -0
- package/dist/components/form/FormSelect.stories.svelte +50 -0
- package/dist/components/form/FormSelect.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormSelect.svelte +129 -0
- package/dist/components/form/FormSelect.svelte.d.ts +20 -0
- package/dist/components/form/FormTemplateEditor.svelte +825 -0
- package/dist/components/form/FormTemplateEditor.svelte.d.ts +41 -0
- package/dist/components/form/FormTextField.stories.svelte +30 -0
- package/dist/components/form/FormTextField.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormTextField.svelte +91 -0
- package/dist/components/form/FormTextField.svelte.d.ts +19 -0
- package/dist/components/form/FormTextarea.stories.svelte +34 -0
- package/dist/components/form/FormTextarea.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormTextarea.svelte +97 -0
- package/dist/components/form/FormTextarea.svelte.d.ts +21 -0
- package/dist/components/form/FormToggle.stories.svelte +30 -0
- package/dist/components/form/FormToggle.stories.svelte.d.ts +27 -0
- package/dist/components/form/FormToggle.svelte +126 -0
- package/dist/components/form/FormToggle.svelte.d.ts +19 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +136 -0
- package/dist/components/form/FormUISchemaRenderer.svelte.d.ts +32 -0
- package/dist/components/form/index.d.ts +50 -0
- package/dist/components/form/index.js +54 -0
- package/dist/components/form/templateAutocomplete.d.ts +29 -0
- package/dist/components/form/templateAutocomplete.js +254 -0
- package/dist/components/form/types.d.ts +485 -0
- package/dist/components/form/types.js +73 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte +52 -0
- package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +401 -0
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +71 -0
- package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte +292 -0
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +25 -0
- package/dist/components/interrupt/FormPrompt.svelte +236 -0
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/InterruptBubble.svelte +601 -0
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +16 -0
- package/dist/components/interrupt/ReviewPrompt.stories.svelte +67 -0
- package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/ReviewPrompt.svelte +861 -0
- package/dist/components/interrupt/ReviewPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/TextInputPrompt.stories.svelte +47 -0
- package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +27 -0
- package/dist/components/interrupt/TextInputPrompt.svelte +346 -0
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +23 -0
- package/dist/components/interrupt/index.d.ts +13 -0
- package/dist/components/interrupt/index.js +15 -0
- package/dist/components/layouts/MainLayout.svelte +718 -0
- package/dist/components/layouts/MainLayout.svelte.d.ts +62 -0
- package/dist/components/nodes/GatewayNode.stories.svelte +108 -0
- package/dist/components/nodes/GatewayNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/GatewayNode.svelte +591 -0
- package/dist/components/nodes/GatewayNode.svelte.d.ts +15 -0
- package/dist/components/nodes/IdeaNode.stories.svelte +52 -0
- package/dist/components/nodes/IdeaNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/IdeaNode.svelte +455 -0
- package/dist/components/nodes/IdeaNode.svelte.d.ts +24 -0
- package/dist/components/nodes/NotesNode.stories.svelte +76 -0
- package/dist/components/nodes/NotesNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/NotesNode.svelte +378 -0
- package/dist/components/nodes/NotesNode.svelte.d.ts +24 -0
- package/dist/components/nodes/SimpleNode.stories.svelte +159 -0
- package/dist/components/nodes/SimpleNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/SimpleNode.svelte +451 -0
- package/dist/components/nodes/SimpleNode.svelte.d.ts +25 -0
- package/dist/components/nodes/SquareNode.stories.svelte +82 -0
- package/dist/components/nodes/SquareNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/SquareNode.svelte +407 -0
- package/dist/components/nodes/SquareNode.svelte.d.ts +25 -0
- package/dist/components/nodes/TerminalNode.stories.svelte +25 -0
- package/dist/components/nodes/TerminalNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/TerminalNode.svelte +690 -0
- package/dist/components/nodes/TerminalNode.svelte.d.ts +25 -0
- package/dist/components/nodes/ToolNode.stories.svelte +189 -0
- package/dist/components/nodes/ToolNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/ToolNode.svelte +471 -0
- package/dist/components/nodes/ToolNode.svelte.d.ts +36 -0
- package/dist/components/nodes/WorkflowNode.stories.svelte +55 -0
- package/dist/components/nodes/WorkflowNode.stories.svelte.d.ts +26 -0
- package/dist/components/nodes/WorkflowNode.svelte +571 -0
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +15 -0
- package/dist/components/playground/ChatPanel.svelte +905 -0
- package/dist/components/playground/ChatPanel.svelte.d.ts +46 -0
- package/dist/components/playground/ExecutionLogs.svelte +488 -0
- package/dist/components/playground/ExecutionLogs.svelte.d.ts +14 -0
- package/dist/components/playground/InputCollector.svelte +444 -0
- package/dist/components/playground/InputCollector.svelte.d.ts +16 -0
- package/dist/components/playground/MessageBubble.stories.svelte +62 -0
- package/dist/components/playground/MessageBubble.stories.svelte.d.ts +27 -0
- package/dist/components/playground/MessageBubble.svelte +633 -0
- package/dist/components/playground/MessageBubble.svelte.d.ts +24 -0
- package/dist/components/playground/Playground.svelte +1075 -0
- package/dist/components/playground/Playground.svelte.d.ts +25 -0
- package/dist/components/playground/PlaygroundModal.svelte +220 -0
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +25 -0
- package/dist/components/playground/SessionManager.svelte +538 -0
- package/dist/components/playground/SessionManager.svelte.d.ts +20 -0
- package/dist/config/agentSpecEndpoints.d.ts +70 -0
- package/dist/config/agentSpecEndpoints.js +65 -0
- package/dist/config/constants.d.ts +43 -0
- package/dist/config/constants.js +31 -0
- package/dist/config/defaultCategories.d.ts +7 -0
- package/dist/config/defaultCategories.js +126 -0
- package/dist/config/defaultPortConfig.d.ts +6 -0
- package/dist/config/defaultPortConfig.js +201 -0
- package/dist/config/endpoints.d.ts +160 -0
- package/dist/config/endpoints.js +146 -0
- package/dist/config/runtimeConfig.d.ts +47 -0
- package/dist/config/runtimeConfig.js +80 -0
- package/dist/core/index.d.ts +75 -0
- package/dist/core/index.js +92 -0
- package/dist/display/index.d.ts +29 -0
- package/dist/display/index.js +36 -0
- package/dist/editor/index.d.ts +95 -0
- package/dist/editor/index.js +138 -0
- package/dist/form/code.d.ts +101 -0
- package/dist/form/code.js +168 -0
- package/dist/form/fieldRegistry.d.ts +169 -0
- package/dist/form/fieldRegistry.js +152 -0
- package/dist/form/full.d.ts +56 -0
- package/dist/form/full.js +80 -0
- package/dist/form/index.d.ts +77 -0
- package/dist/form/index.js +91 -0
- package/dist/form/markdown.d.ts +69 -0
- package/dist/form/markdown.js +103 -0
- package/dist/helpers/nodeLayoutHelper.d.ts +14 -0
- package/dist/helpers/nodeLayoutHelper.js +19 -0
- package/dist/helpers/proximityConnect.d.ts +94 -0
- package/dist/helpers/proximityConnect.js +314 -0
- package/dist/helpers/workflowEditorHelper.d.ts +183 -0
- package/dist/helpers/workflowEditorHelper.js +595 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +64 -0
- package/dist/mocks/app-environment.d.ts +8 -0
- package/dist/mocks/app-environment.js +16 -0
- package/dist/mocks/app-forms.d.ts +2 -0
- package/dist/mocks/app-forms.js +22 -0
- package/dist/mocks/app-navigation.d.ts +5 -0
- package/dist/mocks/app-navigation.js +36 -0
- package/dist/mocks/app-stores.d.ts +14 -0
- package/dist/mocks/app-stores.js +26 -0
- package/dist/playground/index.d.ts +131 -0
- package/dist/playground/index.js +172 -0
- package/dist/playground/mount.d.ts +203 -0
- package/dist/playground/mount.js +235 -0
- 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.d.ts +77 -0
- package/dist/registry/builtinNodes.js +211 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.js +12 -0
- package/dist/registry/nodeComponentRegistry.d.ts +276 -0
- package/dist/registry/nodeComponentRegistry.js +262 -0
- package/dist/registry/plugin.d.ts +215 -0
- package/dist/registry/plugin.js +249 -0
- 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/schemas/v1/workflow.schema.json +1078 -0
- package/dist/services/agentSpecExecutionService.d.ts +106 -0
- package/dist/services/agentSpecExecutionService.js +334 -0
- package/dist/services/api.d.ts +115 -0
- package/dist/services/api.js +214 -0
- package/dist/services/apiVariableService.d.ts +114 -0
- package/dist/services/apiVariableService.js +338 -0
- package/dist/services/autoSaveService.d.ts +112 -0
- package/dist/services/autoSaveService.js +227 -0
- package/dist/services/categoriesApi.d.ts +14 -0
- package/dist/services/categoriesApi.js +49 -0
- package/dist/services/draftStorage.d.ts +171 -0
- package/dist/services/draftStorage.js +299 -0
- package/dist/services/dynamicSchemaService.d.ts +108 -0
- package/dist/services/dynamicSchemaService.js +444 -0
- package/dist/services/globalSave.d.ts +69 -0
- package/dist/services/globalSave.js +248 -0
- package/dist/services/historyService.d.ts +208 -0
- package/dist/services/historyService.js +321 -0
- package/dist/services/interruptService.d.ts +133 -0
- package/dist/services/interruptService.js +280 -0
- package/dist/services/nodeExecutionService.d.ts +63 -0
- package/dist/services/nodeExecutionService.js +266 -0
- package/dist/services/playgroundService.d.ts +130 -0
- package/dist/services/playgroundService.js +321 -0
- package/dist/services/portConfigApi.d.ts +14 -0
- package/dist/services/portConfigApi.js +54 -0
- package/dist/services/settingsService.d.ts +92 -0
- package/dist/services/settingsService.js +196 -0
- package/dist/services/toastService.d.ts +156 -0
- package/dist/services/toastService.js +265 -0
- package/dist/services/variableService.d.ts +141 -0
- package/dist/services/variableService.js +463 -0
- package/dist/services/workflowStorage.d.ts +37 -0
- package/dist/services/workflowStorage.js +116 -0
- package/dist/settings/index.d.ts +25 -0
- package/dist/settings/index.js +33 -0
- package/dist/stores/categoriesStore.svelte.d.ts +32 -0
- package/dist/stores/categoriesStore.svelte.js +77 -0
- package/dist/stores/editorStateMachine.svelte.d.ts +42 -0
- package/dist/stores/editorStateMachine.svelte.js +132 -0
- package/dist/stores/historyStore.svelte.d.ts +136 -0
- package/dist/stores/historyStore.svelte.js +207 -0
- package/dist/stores/interruptStore.svelte.d.ts +179 -0
- package/dist/stores/interruptStore.svelte.js +346 -0
- package/dist/stores/playgroundStore.svelte.d.ts +230 -0
- package/dist/stores/playgroundStore.svelte.js +515 -0
- package/dist/stores/portCoordinateStore.svelte.d.ts +66 -0
- package/dist/stores/portCoordinateStore.svelte.js +186 -0
- package/dist/stores/settingsStore.svelte.d.ts +158 -0
- package/dist/stores/settingsStore.svelte.js +544 -0
- package/dist/stores/workflowStore.svelte.d.ts +260 -0
- package/dist/stores/workflowStore.svelte.js +649 -0
- package/dist/stories/CanvasDecorator.svelte +49 -0
- package/dist/stories/CanvasDecorator.svelte.d.ts +8 -0
- package/dist/stories/NodeDecorator.svelte +73 -0
- package/dist/stories/NodeDecorator.svelte.d.ts +8 -0
- package/dist/stories/utils.d.ts +93 -0
- package/dist/stories/utils.js +122 -0
- package/dist/styles/base.css +1300 -0
- package/dist/styles/toast.css +35 -0
- package/dist/styles/tokens.css +475 -0
- package/dist/svelte-app.d.ts +150 -0
- package/dist/svelte-app.js +295 -0
- package/dist/types/agentspec.d.ts +318 -0
- package/dist/types/agentspec.js +48 -0
- package/dist/types/auth.d.ts +263 -0
- package/dist/types/auth.js +229 -0
- package/dist/types/config.d.ts +151 -0
- package/dist/types/config.js +7 -0
- package/dist/types/events.d.ts +190 -0
- package/dist/types/events.js +30 -0
- package/dist/types/index.d.ts +1234 -0
- package/dist/types/index.js +27 -0
- package/dist/types/interrupt.d.ts +390 -0
- package/dist/types/interrupt.js +145 -0
- package/dist/types/interruptState.d.ts +211 -0
- package/dist/types/interruptState.js +308 -0
- package/dist/types/playground.d.ts +351 -0
- package/dist/types/playground.js +95 -0
- package/dist/types/settings.d.ts +189 -0
- package/dist/types/settings.js +97 -0
- package/dist/types/uischema.d.ts +144 -0
- package/dist/types/uischema.js +51 -0
- package/dist/utils/colors.d.ts +288 -0
- package/dist/utils/colors.js +548 -0
- package/dist/utils/config.d.ts +37 -0
- package/dist/utils/config.js +226 -0
- package/dist/utils/connections.d.ts +125 -0
- package/dist/utils/connections.js +414 -0
- package/dist/utils/errors.d.ts +28 -0
- package/dist/utils/errors.js +44 -0
- package/dist/utils/fetchWithAuth.d.ts +25 -0
- package/dist/utils/fetchWithAuth.js +34 -0
- package/dist/utils/handleIds.d.ts +35 -0
- package/dist/utils/handleIds.js +58 -0
- package/dist/utils/handlePositioning.d.ts +31 -0
- package/dist/utils/handlePositioning.js +35 -0
- package/dist/utils/icons.d.ts +106 -0
- package/dist/utils/icons.js +157 -0
- package/dist/utils/logger.d.ts +47 -0
- package/dist/utils/logger.js +72 -0
- package/dist/utils/nodeStatus.d.ts +53 -0
- package/dist/utils/nodeStatus.js +183 -0
- package/dist/utils/nodeTypes.d.ts +117 -0
- package/dist/utils/nodeTypes.js +244 -0
- package/dist/utils/nodeWrapper.d.ts +39 -0
- package/dist/utils/nodeWrapper.js +62 -0
- package/dist/utils/performanceUtils.d.ts +30 -0
- package/dist/utils/performanceUtils.js +108 -0
- package/dist/utils/sanitize.d.ts +19 -0
- package/dist/utils/sanitize.js +31 -0
- package/dist/utils/uischema.d.ts +52 -0
- package/dist/utils/uischema.js +88 -0
- package/dist/utils/validation.d.ts +29 -0
- package/dist/utils/validation.js +39 -0
- package/package.json +292 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interrupt Service
|
|
3
|
+
*
|
|
4
|
+
* Handles API interactions for Human-in-the-Loop (HITL) interrupts,
|
|
5
|
+
* including fetching interrupt details, resolving interrupts with user
|
|
6
|
+
* responses, and optional dedicated polling for interrupt status.
|
|
7
|
+
*
|
|
8
|
+
* @module services/interruptService
|
|
9
|
+
*/
|
|
10
|
+
import { defaultInterruptPollingConfig } from '../types/interrupt.js';
|
|
11
|
+
import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
|
|
12
|
+
import { getEndpointConfig } from './api.js';
|
|
13
|
+
import { logger } from '../utils/logger.js';
|
|
14
|
+
/**
|
|
15
|
+
* Interrupt Service class
|
|
16
|
+
*
|
|
17
|
+
* Provides methods to interact with interrupt API endpoints including
|
|
18
|
+
* fetching, resolving, cancelling, and listing interrupts.
|
|
19
|
+
* Supports optional dedicated polling for interrupt status.
|
|
20
|
+
*/
|
|
21
|
+
export class InterruptService {
|
|
22
|
+
static instance;
|
|
23
|
+
pollingInterval = null;
|
|
24
|
+
pollingSessionId = null;
|
|
25
|
+
currentBackoff;
|
|
26
|
+
pollingConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Private constructor for singleton pattern
|
|
29
|
+
*/
|
|
30
|
+
constructor() {
|
|
31
|
+
this.pollingConfig = { ...defaultInterruptPollingConfig };
|
|
32
|
+
this.currentBackoff = this.pollingConfig.interval ?? defaultInterruptPollingConfig.interval;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the singleton instance of InterruptService
|
|
36
|
+
*
|
|
37
|
+
* @returns The InterruptService singleton instance
|
|
38
|
+
*/
|
|
39
|
+
static getInstance() {
|
|
40
|
+
if (!InterruptService.instance) {
|
|
41
|
+
InterruptService.instance = new InterruptService();
|
|
42
|
+
}
|
|
43
|
+
return InterruptService.instance;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Configure interrupt polling settings
|
|
47
|
+
*
|
|
48
|
+
* @param config - Polling configuration options
|
|
49
|
+
*/
|
|
50
|
+
setPollingConfig(config) {
|
|
51
|
+
this.pollingConfig = { ...this.pollingConfig, ...config };
|
|
52
|
+
this.currentBackoff = this.pollingConfig.interval ?? defaultInterruptPollingConfig.interval;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the current polling configuration
|
|
56
|
+
*
|
|
57
|
+
* @returns Current polling configuration
|
|
58
|
+
*/
|
|
59
|
+
getPollingConfig() {
|
|
60
|
+
return { ...this.pollingConfig };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if interrupt endpoints are configured
|
|
64
|
+
*
|
|
65
|
+
* @returns True if interrupt endpoints are available
|
|
66
|
+
*/
|
|
67
|
+
isConfigured() {
|
|
68
|
+
const config = getEndpointConfig();
|
|
69
|
+
return Boolean(config?.endpoints?.interrupts);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get the endpoint configuration
|
|
73
|
+
*
|
|
74
|
+
* @throws Error if endpoint configuration is not set
|
|
75
|
+
* @returns The endpoint configuration
|
|
76
|
+
*/
|
|
77
|
+
getConfig() {
|
|
78
|
+
const config = getEndpointConfig();
|
|
79
|
+
if (!config) {
|
|
80
|
+
throw new Error('Endpoint configuration not set. Call setEndpointConfig() first.');
|
|
81
|
+
}
|
|
82
|
+
if (!config.endpoints.interrupts) {
|
|
83
|
+
throw new Error('Interrupt endpoints not configured.');
|
|
84
|
+
}
|
|
85
|
+
return config;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Generic API request helper
|
|
89
|
+
*
|
|
90
|
+
* @param url - The URL to fetch
|
|
91
|
+
* @param options - Fetch options
|
|
92
|
+
* @returns The parsed JSON response
|
|
93
|
+
*/
|
|
94
|
+
async request(url, options = {}) {
|
|
95
|
+
const config = this.getConfig();
|
|
96
|
+
const headers = getEndpointHeaders(config, 'interrupts');
|
|
97
|
+
const response = await fetch(url, {
|
|
98
|
+
...options,
|
|
99
|
+
headers: {
|
|
100
|
+
...headers,
|
|
101
|
+
...options.headers
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
const errorData = await response.json().catch(() => ({}));
|
|
106
|
+
const errorMessage = errorData.error ||
|
|
107
|
+
errorData.message ||
|
|
108
|
+
`HTTP ${response.status}: ${response.statusText}`;
|
|
109
|
+
throw new Error(errorMessage);
|
|
110
|
+
}
|
|
111
|
+
return response.json();
|
|
112
|
+
}
|
|
113
|
+
// =========================================================================
|
|
114
|
+
// Interrupt Operations
|
|
115
|
+
// =========================================================================
|
|
116
|
+
/**
|
|
117
|
+
* Get interrupt details by ID
|
|
118
|
+
*
|
|
119
|
+
* @param interruptId - The interrupt UUID
|
|
120
|
+
* @returns The interrupt details
|
|
121
|
+
*/
|
|
122
|
+
async getInterrupt(interruptId) {
|
|
123
|
+
const config = this.getConfig();
|
|
124
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.get, {
|
|
125
|
+
interruptId
|
|
126
|
+
});
|
|
127
|
+
const response = await this.request(url);
|
|
128
|
+
if (!response.data) {
|
|
129
|
+
throw new Error('Interrupt not found');
|
|
130
|
+
}
|
|
131
|
+
return response.data;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Resolve an interrupt with user response
|
|
135
|
+
*
|
|
136
|
+
* @param interruptId - The interrupt UUID
|
|
137
|
+
* @param value - The user's response value
|
|
138
|
+
* @returns The updated interrupt
|
|
139
|
+
*/
|
|
140
|
+
async resolveInterrupt(interruptId, value) {
|
|
141
|
+
const config = this.getConfig();
|
|
142
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.resolve, {
|
|
143
|
+
interruptId
|
|
144
|
+
});
|
|
145
|
+
const resolution = { value };
|
|
146
|
+
const response = await this.request(url, {
|
|
147
|
+
method: 'POST',
|
|
148
|
+
body: JSON.stringify(resolution)
|
|
149
|
+
});
|
|
150
|
+
if (!response.data) {
|
|
151
|
+
throw new Error('Failed to resolve interrupt: No data returned');
|
|
152
|
+
}
|
|
153
|
+
return response.data;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Cancel a pending interrupt
|
|
157
|
+
*
|
|
158
|
+
* @param interruptId - The interrupt UUID
|
|
159
|
+
* @returns The updated interrupt
|
|
160
|
+
*/
|
|
161
|
+
async cancelInterrupt(interruptId) {
|
|
162
|
+
const config = this.getConfig();
|
|
163
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.cancel, {
|
|
164
|
+
interruptId
|
|
165
|
+
});
|
|
166
|
+
const response = await this.request(url, {
|
|
167
|
+
method: 'POST'
|
|
168
|
+
});
|
|
169
|
+
if (!response.data) {
|
|
170
|
+
throw new Error('Failed to cancel interrupt: No data returned');
|
|
171
|
+
}
|
|
172
|
+
return response.data;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* List interrupts for a playground session
|
|
176
|
+
*
|
|
177
|
+
* @param sessionId - The session UUID
|
|
178
|
+
* @returns Array of interrupts for the session
|
|
179
|
+
*/
|
|
180
|
+
async listSessionInterrupts(sessionId) {
|
|
181
|
+
const config = this.getConfig();
|
|
182
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.listBySession, {
|
|
183
|
+
sessionId
|
|
184
|
+
});
|
|
185
|
+
const response = await this.request(url);
|
|
186
|
+
return response.data ?? [];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* List interrupts for a pipeline
|
|
190
|
+
*
|
|
191
|
+
* @param pipelineId - The pipeline UUID
|
|
192
|
+
* @returns Array of interrupts for the pipeline
|
|
193
|
+
*/
|
|
194
|
+
async listPipelineInterrupts(pipelineId) {
|
|
195
|
+
const config = this.getConfig();
|
|
196
|
+
const url = buildEndpointUrl(config, config.endpoints.interrupts.listByPipeline, {
|
|
197
|
+
pipelineId
|
|
198
|
+
});
|
|
199
|
+
const response = await this.request(url);
|
|
200
|
+
return response.data ?? [];
|
|
201
|
+
}
|
|
202
|
+
// =========================================================================
|
|
203
|
+
// Polling (Optional)
|
|
204
|
+
// =========================================================================
|
|
205
|
+
/**
|
|
206
|
+
* Start polling for interrupts in a session
|
|
207
|
+
*
|
|
208
|
+
* This is optional - interrupts are typically detected via message metadata.
|
|
209
|
+
* Use this for scenarios where dedicated polling is preferred.
|
|
210
|
+
*
|
|
211
|
+
* @param sessionId - The session UUID to poll
|
|
212
|
+
* @param callback - Callback function to handle new interrupts
|
|
213
|
+
*/
|
|
214
|
+
startPolling(sessionId, callback) {
|
|
215
|
+
if (!this.pollingConfig.enabled) {
|
|
216
|
+
logger.warn('[InterruptService] Polling is disabled. Enable via setPollingConfig().');
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
// Stop any existing polling
|
|
220
|
+
this.stopPolling();
|
|
221
|
+
this.pollingSessionId = sessionId;
|
|
222
|
+
this.currentBackoff = this.pollingConfig.interval ?? defaultInterruptPollingConfig.interval;
|
|
223
|
+
const poll = async () => {
|
|
224
|
+
if (this.pollingSessionId !== sessionId) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
const interrupts = await this.listSessionInterrupts(sessionId);
|
|
229
|
+
const pendingInterrupts = interrupts.filter((i) => i.status === 'pending');
|
|
230
|
+
// Reset backoff on successful request
|
|
231
|
+
this.currentBackoff = this.pollingConfig.interval ?? defaultInterruptPollingConfig.interval;
|
|
232
|
+
// Call the callback with pending interrupts
|
|
233
|
+
callback(pendingInterrupts);
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
logger.error('[InterruptService] Polling error:', error);
|
|
237
|
+
// Exponential backoff on error
|
|
238
|
+
const maxBackoff = this.pollingConfig.maxBackoff ?? defaultInterruptPollingConfig.maxBackoff;
|
|
239
|
+
this.currentBackoff = Math.min(this.currentBackoff * 2, maxBackoff);
|
|
240
|
+
}
|
|
241
|
+
// Schedule next poll
|
|
242
|
+
if (this.pollingSessionId === sessionId) {
|
|
243
|
+
this.pollingInterval = setTimeout(poll, this.currentBackoff);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
// Start polling immediately
|
|
247
|
+
void poll();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Stop polling for interrupts
|
|
251
|
+
*/
|
|
252
|
+
stopPolling() {
|
|
253
|
+
if (this.pollingInterval) {
|
|
254
|
+
clearTimeout(this.pollingInterval);
|
|
255
|
+
this.pollingInterval = null;
|
|
256
|
+
}
|
|
257
|
+
this.pollingSessionId = null;
|
|
258
|
+
this.currentBackoff = this.pollingConfig.interval ?? defaultInterruptPollingConfig.interval;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Check if polling is active
|
|
262
|
+
*
|
|
263
|
+
* @returns True if polling is active
|
|
264
|
+
*/
|
|
265
|
+
isPolling() {
|
|
266
|
+
return this.pollingSessionId !== null;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Get the current polling session ID
|
|
270
|
+
*
|
|
271
|
+
* @returns The session ID being polled, or null
|
|
272
|
+
*/
|
|
273
|
+
getPollingSessionId() {
|
|
274
|
+
return this.pollingSessionId;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Export singleton instance
|
|
279
|
+
*/
|
|
280
|
+
export const interruptService = InterruptService.getInstance();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node Execution Service
|
|
3
|
+
* Handles fetching and managing node execution information from the backend
|
|
4
|
+
*/
|
|
5
|
+
import type { NodeExecutionInfo } from '../types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Service for managing node execution information
|
|
8
|
+
*/
|
|
9
|
+
export declare class NodeExecutionService {
|
|
10
|
+
private static instance;
|
|
11
|
+
private cache;
|
|
12
|
+
private cacheTimeout;
|
|
13
|
+
private lastFetch;
|
|
14
|
+
private apiUnavailable;
|
|
15
|
+
private apiUnavailableUntil;
|
|
16
|
+
private constructor();
|
|
17
|
+
static getInstance(): NodeExecutionService;
|
|
18
|
+
/**
|
|
19
|
+
* Get execution information for a specific node from pipeline data
|
|
20
|
+
*/
|
|
21
|
+
getNodeExecutionInfo(nodeId: string, pipelineId?: string): Promise<NodeExecutionInfo | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Get execution information for multiple nodes from pipeline data
|
|
24
|
+
*/
|
|
25
|
+
getMultipleNodeExecutionInfo(nodeIds: string[], pipelineId?: string): Promise<Record<string, NodeExecutionInfo>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get all node execution counts
|
|
28
|
+
*/
|
|
29
|
+
getAllNodeExecutionCounts(): Promise<Record<string, number>>;
|
|
30
|
+
/**
|
|
31
|
+
* Get cached execution info for a node
|
|
32
|
+
*/
|
|
33
|
+
getCachedNodeExecutionInfo(nodeId: string): NodeExecutionInfo | null;
|
|
34
|
+
/**
|
|
35
|
+
* Clear cache for a specific node
|
|
36
|
+
*/
|
|
37
|
+
clearNodeCache(nodeId: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Clear all cache
|
|
40
|
+
*/
|
|
41
|
+
clearAllCache(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Check if cache is stale
|
|
44
|
+
*/
|
|
45
|
+
isCacheStale(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Update execution info for a node (for real-time updates)
|
|
48
|
+
*/
|
|
49
|
+
updateNodeExecutionInfo(nodeId: string, executionInfo: Partial<NodeExecutionInfo>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Map job status to execution status
|
|
52
|
+
*/
|
|
53
|
+
private mapJobStatusToExecutionStatus;
|
|
54
|
+
/**
|
|
55
|
+
* Batch update execution info for multiple nodes
|
|
56
|
+
*/
|
|
57
|
+
updateMultipleNodeExecutionInfo(updates: Record<string, Partial<NodeExecutionInfo>>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Reset API availability status (useful for testing or when API becomes available)
|
|
60
|
+
*/
|
|
61
|
+
resetApiAvailability(): void;
|
|
62
|
+
}
|
|
63
|
+
export declare const nodeExecutionService: NodeExecutionService;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node Execution Service
|
|
3
|
+
* Handles fetching and managing node execution information from the backend
|
|
4
|
+
*/
|
|
5
|
+
import { getEndpointConfig } from './api.js';
|
|
6
|
+
import { buildEndpointUrl } from '../config/endpoints.js';
|
|
7
|
+
import { NODE_EXECUTION_CACHE_TIMEOUT_MS, PIPELINE_API_UNAVAILABLE_DURATION_MS } from '../config/constants.js';
|
|
8
|
+
import { logger } from '../utils/logger.js';
|
|
9
|
+
/**
|
|
10
|
+
* Service for managing node execution information
|
|
11
|
+
*/
|
|
12
|
+
export class NodeExecutionService {
|
|
13
|
+
static instance;
|
|
14
|
+
cache = new Map();
|
|
15
|
+
cacheTimeout = NODE_EXECUTION_CACHE_TIMEOUT_MS;
|
|
16
|
+
lastFetch = 0;
|
|
17
|
+
apiUnavailable = false;
|
|
18
|
+
apiUnavailableUntil = 0;
|
|
19
|
+
constructor() { }
|
|
20
|
+
static getInstance() {
|
|
21
|
+
if (!NodeExecutionService.instance) {
|
|
22
|
+
NodeExecutionService.instance = new NodeExecutionService();
|
|
23
|
+
}
|
|
24
|
+
return NodeExecutionService.instance;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get execution information for a specific node from pipeline data
|
|
28
|
+
*/
|
|
29
|
+
async getNodeExecutionInfo(nodeId, pipelineId) {
|
|
30
|
+
if (!pipelineId) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const endpointConfig = getEndpointConfig();
|
|
35
|
+
if (!endpointConfig)
|
|
36
|
+
throw new Error('Endpoint config not available');
|
|
37
|
+
const url = buildEndpointUrl(endpointConfig, endpointConfig.endpoints.pipelines.get, {
|
|
38
|
+
id: pipelineId
|
|
39
|
+
});
|
|
40
|
+
const response = await fetch(url);
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
43
|
+
}
|
|
44
|
+
const pipelineData = await response.json();
|
|
45
|
+
const jobs = pipelineData.jobs || [];
|
|
46
|
+
const nodeStatuses = pipelineData.node_statuses || {};
|
|
47
|
+
// Find the job for this node
|
|
48
|
+
const nodeJob = jobs.find((job) => job.node_id === nodeId);
|
|
49
|
+
const nodeStatus = nodeStatuses[nodeId];
|
|
50
|
+
if (!nodeJob && !nodeStatus) {
|
|
51
|
+
return {
|
|
52
|
+
status: 'idle',
|
|
53
|
+
executionCount: 0,
|
|
54
|
+
isExecuting: false
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const executionInfo = {
|
|
58
|
+
status: this.mapJobStatusToExecutionStatus(nodeStatus?.status || nodeJob?.status || 'idle'),
|
|
59
|
+
executionCount: nodeJob?.execution_count || 0,
|
|
60
|
+
isExecuting: nodeStatus?.status === 'running' || nodeJob?.status === 'running',
|
|
61
|
+
lastExecuted: nodeJob?.last_executed || nodeStatus?.last_executed,
|
|
62
|
+
lastExecutionDuration: nodeJob?.execution_time || nodeStatus?.execution_time,
|
|
63
|
+
lastError: nodeJob?.error || nodeStatus?.error
|
|
64
|
+
};
|
|
65
|
+
this.cache.set(nodeId, executionInfo);
|
|
66
|
+
return executionInfo;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
logger.error('Failed to fetch node execution info:', error);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get execution information for multiple nodes from pipeline data
|
|
75
|
+
*/
|
|
76
|
+
async getMultipleNodeExecutionInfo(nodeIds, pipelineId) {
|
|
77
|
+
if (!pipelineId) {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
// Check if API is temporarily unavailable
|
|
81
|
+
if (this.apiUnavailable && Date.now() < this.apiUnavailableUntil) {
|
|
82
|
+
const defaultExecutionInfo = {};
|
|
83
|
+
nodeIds.forEach((nodeId) => {
|
|
84
|
+
defaultExecutionInfo[nodeId] = {
|
|
85
|
+
status: 'idle',
|
|
86
|
+
executionCount: 0,
|
|
87
|
+
isExecuting: false
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
return defaultExecutionInfo;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const endpointConfig = getEndpointConfig();
|
|
94
|
+
if (!endpointConfig)
|
|
95
|
+
throw new Error('Endpoint config not available');
|
|
96
|
+
const url = buildEndpointUrl(endpointConfig, endpointConfig.endpoints.pipelines.get, {
|
|
97
|
+
id: pipelineId
|
|
98
|
+
});
|
|
99
|
+
const response = await fetch(url);
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
// If the endpoint returns 404, it means the pipeline API is not available
|
|
102
|
+
// Mark API as unavailable for 5 minutes to prevent repeated calls
|
|
103
|
+
if (response.status === 404) {
|
|
104
|
+
logger.warn(`Pipeline API endpoint not available for pipeline ${pipelineId}`);
|
|
105
|
+
this.apiUnavailable = true;
|
|
106
|
+
this.apiUnavailableUntil = Date.now() + PIPELINE_API_UNAVAILABLE_DURATION_MS;
|
|
107
|
+
const defaultExecutionInfo = {};
|
|
108
|
+
nodeIds.forEach((nodeId) => {
|
|
109
|
+
defaultExecutionInfo[nodeId] = {
|
|
110
|
+
status: 'idle',
|
|
111
|
+
executionCount: 0,
|
|
112
|
+
isExecuting: false
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
return defaultExecutionInfo;
|
|
116
|
+
}
|
|
117
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
118
|
+
}
|
|
119
|
+
const result = await response.json();
|
|
120
|
+
const jobs = result.jobs || [];
|
|
121
|
+
const executionInfoMap = {};
|
|
122
|
+
// Initialize all nodes with default values
|
|
123
|
+
nodeIds.forEach((nodeId) => {
|
|
124
|
+
executionInfoMap[nodeId] = {
|
|
125
|
+
status: 'idle',
|
|
126
|
+
executionCount: 0,
|
|
127
|
+
isExecuting: false
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
// Update with actual job data
|
|
131
|
+
jobs.forEach((job) => {
|
|
132
|
+
const nodeId = job.node_id;
|
|
133
|
+
if (nodeIds.includes(nodeId)) {
|
|
134
|
+
executionInfoMap[nodeId] = {
|
|
135
|
+
status: this.mapJobStatusToExecutionStatus(job.status),
|
|
136
|
+
executionCount: job.execution_count || 0,
|
|
137
|
+
isExecuting: job.status === 'running',
|
|
138
|
+
lastExecuted: job.completed || job.started,
|
|
139
|
+
lastExecutionDuration: job.execution_time,
|
|
140
|
+
lastError: job.error_message
|
|
141
|
+
};
|
|
142
|
+
// Update cache
|
|
143
|
+
this.cache.set(nodeId, executionInfoMap[nodeId]);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return executionInfoMap;
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
logger.error('Failed to fetch multiple node execution info:', error);
|
|
150
|
+
// Return default values instead of empty object to prevent repeated calls
|
|
151
|
+
const defaultExecutionInfo = {};
|
|
152
|
+
nodeIds.forEach((nodeId) => {
|
|
153
|
+
defaultExecutionInfo[nodeId] = {
|
|
154
|
+
status: 'idle',
|
|
155
|
+
executionCount: 0,
|
|
156
|
+
isExecuting: false
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
return defaultExecutionInfo;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get all node execution counts
|
|
164
|
+
*/
|
|
165
|
+
async getAllNodeExecutionCounts() {
|
|
166
|
+
try {
|
|
167
|
+
const endpointConfig = getEndpointConfig();
|
|
168
|
+
if (!endpointConfig)
|
|
169
|
+
throw new Error('Endpoint config not available');
|
|
170
|
+
const url = buildEndpointUrl(endpointConfig, '/node-execution-counts');
|
|
171
|
+
const response = await fetch(url);
|
|
172
|
+
if (!response.ok) {
|
|
173
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
174
|
+
}
|
|
175
|
+
const result = await response.json();
|
|
176
|
+
if (result.success && result.data) {
|
|
177
|
+
return result.data;
|
|
178
|
+
}
|
|
179
|
+
return {};
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
logger.error('Failed to fetch all node execution counts:', error);
|
|
183
|
+
return {};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get cached execution info for a node
|
|
188
|
+
*/
|
|
189
|
+
getCachedNodeExecutionInfo(nodeId) {
|
|
190
|
+
return this.cache.get(nodeId) || null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Clear cache for a specific node
|
|
194
|
+
*/
|
|
195
|
+
clearNodeCache(nodeId) {
|
|
196
|
+
this.cache.delete(nodeId);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Clear all cache
|
|
200
|
+
*/
|
|
201
|
+
clearAllCache() {
|
|
202
|
+
this.cache.clear();
|
|
203
|
+
this.lastFetch = 0;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Check if cache is stale
|
|
207
|
+
*/
|
|
208
|
+
isCacheStale() {
|
|
209
|
+
return Date.now() - this.lastFetch > this.cacheTimeout;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Update execution info for a node (for real-time updates)
|
|
213
|
+
*/
|
|
214
|
+
updateNodeExecutionInfo(nodeId, executionInfo) {
|
|
215
|
+
const existing = this.cache.get(nodeId);
|
|
216
|
+
if (existing) {
|
|
217
|
+
this.cache.set(nodeId, { ...existing, ...executionInfo });
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
this.cache.set(nodeId, {
|
|
221
|
+
status: 'idle',
|
|
222
|
+
executionCount: 0,
|
|
223
|
+
isExecuting: false,
|
|
224
|
+
...executionInfo
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Map job status to execution status
|
|
230
|
+
*/
|
|
231
|
+
mapJobStatusToExecutionStatus(jobStatus) {
|
|
232
|
+
switch (jobStatus) {
|
|
233
|
+
case 'pending':
|
|
234
|
+
return 'pending';
|
|
235
|
+
case 'running':
|
|
236
|
+
return 'running';
|
|
237
|
+
case 'completed':
|
|
238
|
+
return 'completed';
|
|
239
|
+
case 'failed':
|
|
240
|
+
return 'failed';
|
|
241
|
+
case 'cancelled':
|
|
242
|
+
return 'cancelled';
|
|
243
|
+
case 'skipped':
|
|
244
|
+
return 'skipped';
|
|
245
|
+
default:
|
|
246
|
+
return 'idle';
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Batch update execution info for multiple nodes
|
|
251
|
+
*/
|
|
252
|
+
updateMultipleNodeExecutionInfo(updates) {
|
|
253
|
+
Object.entries(updates).forEach(([nodeId, executionInfo]) => {
|
|
254
|
+
this.updateNodeExecutionInfo(nodeId, executionInfo);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Reset API availability status (useful for testing or when API becomes available)
|
|
259
|
+
*/
|
|
260
|
+
resetApiAvailability() {
|
|
261
|
+
this.apiUnavailable = false;
|
|
262
|
+
this.apiUnavailableUntil = 0;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// Export singleton instance
|
|
266
|
+
export const nodeExecutionService = NodeExecutionService.getInstance();
|