@synergenius/flow-weaver 0.2.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 +122 -0
- package/README.md +315 -0
- package/dist/annotation-generator.d.ts +45 -0
- package/dist/annotation-generator.js +557 -0
- package/dist/api/builder.d.ts +223 -0
- package/dist/api/builder.js +345 -0
- package/dist/api/compile.d.ts +92 -0
- package/dist/api/compile.js +149 -0
- package/dist/api/extract-types.d.ts +29 -0
- package/dist/api/extract-types.js +57 -0
- package/dist/api/generate-in-place.d.ts +73 -0
- package/dist/api/generate-in-place.js +1353 -0
- package/dist/api/generate.d.ts +83 -0
- package/dist/api/generate.js +510 -0
- package/dist/api/helpers.d.ts +248 -0
- package/dist/api/helpers.js +285 -0
- package/dist/api/index.d.ts +46 -0
- package/dist/api/index.js +45 -0
- package/dist/api/inline-runtime.d.ts +27 -0
- package/dist/api/inline-runtime.js +551 -0
- package/dist/api/manipulation/connections.d.ts +79 -0
- package/dist/api/manipulation/connections.js +151 -0
- package/dist/api/manipulation/index.d.ts +34 -0
- package/dist/api/manipulation/index.js +41 -0
- package/dist/api/manipulation/node-types.d.ts +123 -0
- package/dist/api/manipulation/node-types.js +200 -0
- package/dist/api/manipulation/nodes.d.ts +144 -0
- package/dist/api/manipulation/nodes.js +333 -0
- package/dist/api/manipulation/ports.d.ts +59 -0
- package/dist/api/manipulation/ports.js +228 -0
- package/dist/api/manipulation/scopes.d.ts +52 -0
- package/dist/api/manipulation/scopes.js +156 -0
- package/dist/api/manipulation/validation.d.ts +6 -0
- package/dist/api/manipulation/validation.js +6 -0
- package/dist/api/manipulation/workflow.d.ts +81 -0
- package/dist/api/manipulation/workflow.js +116 -0
- package/dist/api/manipulation.d.ts +8 -0
- package/dist/api/manipulation.js +8 -0
- package/dist/api/parse.d.ts +48 -0
- package/dist/api/parse.js +110 -0
- package/dist/api/patterns.d.ts +112 -0
- package/dist/api/patterns.js +306 -0
- package/dist/api/query.d.ts +429 -0
- package/dist/api/query.js +816 -0
- package/dist/api/templates.d.ts +98 -0
- package/dist/api/templates.js +117 -0
- package/dist/api/transform.d.ts +31 -0
- package/dist/api/transform.js +40 -0
- package/dist/api/validate.d.ts +25 -0
- package/dist/api/validate.js +39 -0
- package/dist/api/workflow-file-operations.d.ts +29 -0
- package/dist/api/workflow-file-operations.js +180 -0
- package/dist/ast/builder.d.ts +210 -0
- package/dist/ast/builder.js +395 -0
- package/dist/ast/index.d.ts +5 -0
- package/dist/ast/index.js +5 -0
- package/dist/ast/serialization-node.d.ts +6 -0
- package/dist/ast/serialization-node.js +30 -0
- package/dist/ast/serialization.d.ts +43 -0
- package/dist/ast/serialization.js +134 -0
- package/dist/ast/types.d.ts +852 -0
- package/dist/ast/types.js +2 -0
- package/dist/ast/workflow-utils.d.ts +54 -0
- package/dist/ast/workflow-utils.js +114 -0
- package/dist/body-generator.d.ts +31 -0
- package/dist/body-generator.js +35 -0
- package/dist/built-in-nodes/delay.d.ts +11 -0
- package/dist/built-in-nodes/delay.js +29 -0
- package/dist/built-in-nodes/index.d.ts +5 -0
- package/dist/built-in-nodes/index.js +4 -0
- package/dist/built-in-nodes/invoke-workflow.d.ts +13 -0
- package/dist/built-in-nodes/invoke-workflow.js +25 -0
- package/dist/built-in-nodes/mock-types.d.ts +18 -0
- package/dist/built-in-nodes/mock-types.js +12 -0
- package/dist/built-in-nodes/wait-for-event.d.ts +13 -0
- package/dist/built-in-nodes/wait-for-event.js +25 -0
- package/dist/chevrotain-parser/connect-parser.d.ts +24 -0
- package/dist/chevrotain-parser/connect-parser.js +98 -0
- package/dist/chevrotain-parser/grammar-diagrams.d.ts +29 -0
- package/dist/chevrotain-parser/grammar-diagrams.js +264 -0
- package/dist/chevrotain-parser/index.d.ts +25 -0
- package/dist/chevrotain-parser/index.js +27 -0
- package/dist/chevrotain-parser/map-parser.d.ts +33 -0
- package/dist/chevrotain-parser/map-parser.js +130 -0
- package/dist/chevrotain-parser/node-parser.d.ts +36 -0
- package/dist/chevrotain-parser/node-parser.js +466 -0
- package/dist/chevrotain-parser/path-parser.d.ts +28 -0
- package/dist/chevrotain-parser/path-parser.js +118 -0
- package/dist/chevrotain-parser/port-parser.d.ts +36 -0
- package/dist/chevrotain-parser/port-parser.js +442 -0
- package/dist/chevrotain-parser/position-parser.d.ts +20 -0
- package/dist/chevrotain-parser/position-parser.js +83 -0
- package/dist/chevrotain-parser/scope-parser.d.ts +19 -0
- package/dist/chevrotain-parser/scope-parser.js +104 -0
- package/dist/chevrotain-parser/tokens.d.ts +78 -0
- package/dist/chevrotain-parser/tokens.js +384 -0
- package/dist/chevrotain-parser/trigger-cancel-parser.d.ts +50 -0
- package/dist/chevrotain-parser/trigger-cancel-parser.js +282 -0
- package/dist/cli/commands/changelog.d.ts +13 -0
- package/dist/cli/commands/changelog.js +135 -0
- package/dist/cli/commands/compile.d.ts +64 -0
- package/dist/cli/commands/compile.js +278 -0
- package/dist/cli/commands/create.d.ts +33 -0
- package/dist/cli/commands/create.js +147 -0
- package/dist/cli/commands/describe.d.ts +68 -0
- package/dist/cli/commands/describe.js +377 -0
- package/dist/cli/commands/dev.d.ts +32 -0
- package/dist/cli/commands/dev.js +384 -0
- package/dist/cli/commands/diagram.d.ts +13 -0
- package/dist/cli/commands/diagram.js +33 -0
- package/dist/cli/commands/diff.d.ts +11 -0
- package/dist/cli/commands/diff.js +59 -0
- package/dist/cli/commands/doctor.d.ts +57 -0
- package/dist/cli/commands/doctor.js +719 -0
- package/dist/cli/commands/export.d.ts +57 -0
- package/dist/cli/commands/export.js +163 -0
- package/dist/cli/commands/grammar.d.ts +9 -0
- package/dist/cli/commands/grammar.js +39 -0
- package/dist/cli/commands/init.d.ts +59 -0
- package/dist/cli/commands/init.js +435 -0
- package/dist/cli/commands/listen.d.ts +16 -0
- package/dist/cli/commands/listen.js +39 -0
- package/dist/cli/commands/market.d.ts +52 -0
- package/dist/cli/commands/market.js +436 -0
- package/dist/cli/commands/migrate.d.ts +13 -0
- package/dist/cli/commands/migrate.js +89 -0
- package/dist/cli/commands/openapi.d.ts +37 -0
- package/dist/cli/commands/openapi.js +67 -0
- package/dist/cli/commands/pattern.d.ts +34 -0
- package/dist/cli/commands/pattern.js +185 -0
- package/dist/cli/commands/plugin.d.ts +16 -0
- package/dist/cli/commands/plugin.js +176 -0
- package/dist/cli/commands/run.d.ts +49 -0
- package/dist/cli/commands/run.js +191 -0
- package/dist/cli/commands/serve.d.ts +45 -0
- package/dist/cli/commands/serve.js +81 -0
- package/dist/cli/commands/templates.d.ts +8 -0
- package/dist/cli/commands/templates.js +54 -0
- package/dist/cli/commands/ui.d.ts +16 -0
- package/dist/cli/commands/ui.js +130 -0
- package/dist/cli/commands/validate.d.ts +12 -0
- package/dist/cli/commands/validate.js +247 -0
- package/dist/cli/commands/watch.d.ts +9 -0
- package/dist/cli/commands/watch.js +70 -0
- package/dist/cli/flow-weaver.mjs +92924 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.js +742 -0
- package/dist/cli/templates/ai/mock-provider.d.ts +7 -0
- package/dist/cli/templates/ai/mock-provider.js +64 -0
- package/dist/cli/templates/ai/types.d.ts +47 -0
- package/dist/cli/templates/ai/types.js +5 -0
- package/dist/cli/templates/approvals/index.d.ts +15 -0
- package/dist/cli/templates/approvals/index.js +241 -0
- package/dist/cli/templates/index.d.ts +102 -0
- package/dist/cli/templates/index.js +101 -0
- package/dist/cli/templates/nodes/agent-router.d.ts +3 -0
- package/dist/cli/templates/nodes/agent-router.js +114 -0
- package/dist/cli/templates/nodes/aggregator.d.ts +7 -0
- package/dist/cli/templates/nodes/aggregator.js +63 -0
- package/dist/cli/templates/nodes/conversation-memory.d.ts +3 -0
- package/dist/cli/templates/nodes/conversation-memory.js +85 -0
- package/dist/cli/templates/nodes/http.d.ts +7 -0
- package/dist/cli/templates/nodes/http.js +80 -0
- package/dist/cli/templates/nodes/human-approval.d.ts +3 -0
- package/dist/cli/templates/nodes/human-approval.js +110 -0
- package/dist/cli/templates/nodes/json-extractor.d.ts +3 -0
- package/dist/cli/templates/nodes/json-extractor.js +119 -0
- package/dist/cli/templates/nodes/llm-call.d.ts +3 -0
- package/dist/cli/templates/nodes/llm-call.js +106 -0
- package/dist/cli/templates/nodes/prompt-template.d.ts +3 -0
- package/dist/cli/templates/nodes/prompt-template.js +52 -0
- package/dist/cli/templates/nodes/rag-retriever.d.ts +3 -0
- package/dist/cli/templates/nodes/rag-retriever.js +128 -0
- package/dist/cli/templates/nodes/tool-executor.d.ts +3 -0
- package/dist/cli/templates/nodes/tool-executor.js +108 -0
- package/dist/cli/templates/nodes/transformer.d.ts +7 -0
- package/dist/cli/templates/nodes/transformer.js +68 -0
- package/dist/cli/templates/nodes/validator.d.ts +7 -0
- package/dist/cli/templates/nodes/validator.js +62 -0
- package/dist/cli/templates/providers/index.d.ts +14 -0
- package/dist/cli/templates/providers/index.js +239 -0
- package/dist/cli/templates/shared/approval-types.d.ts +9 -0
- package/dist/cli/templates/shared/approval-types.js +31 -0
- package/dist/cli/templates/shared/llm-types.d.ts +15 -0
- package/dist/cli/templates/shared/llm-types.js +104 -0
- package/dist/cli/templates/workflows/aggregator.d.ts +7 -0
- package/dist/cli/templates/workflows/aggregator.js +104 -0
- package/dist/cli/templates/workflows/ai-agent-durable.d.ts +8 -0
- package/dist/cli/templates/workflows/ai-agent-durable.js +338 -0
- package/dist/cli/templates/workflows/ai-agent.d.ts +31 -0
- package/dist/cli/templates/workflows/ai-agent.js +326 -0
- package/dist/cli/templates/workflows/ai-chat.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-chat.js +169 -0
- package/dist/cli/templates/workflows/ai-pipeline-durable.d.ts +8 -0
- package/dist/cli/templates/workflows/ai-pipeline-durable.js +330 -0
- package/dist/cli/templates/workflows/ai-rag.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-rag.js +186 -0
- package/dist/cli/templates/workflows/ai-react.d.ts +7 -0
- package/dist/cli/templates/workflows/ai-react.js +294 -0
- package/dist/cli/templates/workflows/conditional.d.ts +12 -0
- package/dist/cli/templates/workflows/conditional.js +142 -0
- package/dist/cli/templates/workflows/error-handler.d.ts +7 -0
- package/dist/cli/templates/workflows/error-handler.js +147 -0
- package/dist/cli/templates/workflows/foreach.d.ts +7 -0
- package/dist/cli/templates/workflows/foreach.js +143 -0
- package/dist/cli/templates/workflows/sequential.d.ts +7 -0
- package/dist/cli/templates/workflows/sequential.js +198 -0
- package/dist/cli/templates/workflows/webhook.d.ts +7 -0
- package/dist/cli/templates/workflows/webhook.js +161 -0
- package/dist/cli/utils/logger.d.ts +15 -0
- package/dist/cli/utils/logger.js +46 -0
- package/dist/constants.d.ts +100 -0
- package/dist/constants.js +125 -0
- package/dist/defaults.d.ts +3 -0
- package/dist/defaults.js +3 -0
- package/dist/deployment/config/defaults.d.ts +29 -0
- package/dist/deployment/config/defaults.js +98 -0
- package/dist/deployment/config/loader.d.ts +24 -0
- package/dist/deployment/config/loader.js +236 -0
- package/dist/deployment/config/types.d.ts +117 -0
- package/dist/deployment/config/types.js +5 -0
- package/dist/deployment/core/adapters.d.ts +90 -0
- package/dist/deployment/core/adapters.js +251 -0
- package/dist/deployment/core/executor.d.ts +62 -0
- package/dist/deployment/core/executor.js +197 -0
- package/dist/deployment/core/formatters.d.ts +57 -0
- package/dist/deployment/core/formatters.js +170 -0
- package/dist/deployment/index.d.ts +31 -0
- package/dist/deployment/index.js +48 -0
- package/dist/deployment/openapi/generator.d.ts +146 -0
- package/dist/deployment/openapi/generator.js +347 -0
- package/dist/deployment/openapi/schema-converter.d.ts +49 -0
- package/dist/deployment/openapi/schema-converter.js +192 -0
- package/dist/deployment/targets/base.d.ts +316 -0
- package/dist/deployment/targets/base.js +823 -0
- package/dist/deployment/targets/cloudflare.d.ts +23 -0
- package/dist/deployment/targets/cloudflare.js +1125 -0
- package/dist/deployment/targets/inngest.d.ts +38 -0
- package/dist/deployment/targets/inngest.js +926 -0
- package/dist/deployment/targets/lambda.d.ts +23 -0
- package/dist/deployment/targets/lambda.js +1289 -0
- package/dist/deployment/targets/vercel.d.ts +23 -0
- package/dist/deployment/targets/vercel.js +886 -0
- package/dist/deployment/types.d.ts +183 -0
- package/dist/deployment/types.js +8 -0
- package/dist/diagram/geometry.d.ts +26 -0
- package/dist/diagram/geometry.js +850 -0
- package/dist/diagram/index.d.ts +16 -0
- package/dist/diagram/index.js +42 -0
- package/dist/diagram/layout.d.ts +11 -0
- package/dist/diagram/layout.js +143 -0
- package/dist/diagram/orthogonal-router.d.ts +79 -0
- package/dist/diagram/orthogonal-router.js +568 -0
- package/dist/diagram/renderer.d.ts +3 -0
- package/dist/diagram/renderer.js +207 -0
- package/dist/diagram/theme.d.ts +20 -0
- package/dist/diagram/theme.js +189 -0
- package/dist/diagram/types.d.ts +70 -0
- package/dist/diagram/types.js +2 -0
- package/dist/diff/WorkflowDiffer.d.ts +13 -0
- package/dist/diff/WorkflowDiffer.js +429 -0
- package/dist/diff/formatDiff.d.ts +10 -0
- package/dist/diff/formatDiff.js +220 -0
- package/dist/diff/impact.d.ts +29 -0
- package/dist/diff/impact.js +119 -0
- package/dist/diff/index.d.ts +10 -0
- package/dist/diff/index.js +9 -0
- package/dist/diff/types.d.ts +138 -0
- package/dist/diff/types.js +35 -0
- package/dist/doc-metadata/extractors/annotations.d.ts +56 -0
- package/dist/doc-metadata/extractors/annotations.js +337 -0
- package/dist/doc-metadata/extractors/cli-commands.d.ts +17 -0
- package/dist/doc-metadata/extractors/cli-commands.js +355 -0
- package/dist/doc-metadata/extractors/mcp-tools.d.ts +16 -0
- package/dist/doc-metadata/extractors/mcp-tools.js +689 -0
- package/dist/doc-metadata/extractors/plugin-api.d.ts +19 -0
- package/dist/doc-metadata/extractors/plugin-api.js +279 -0
- package/dist/doc-metadata/index.d.ts +5 -0
- package/dist/doc-metadata/index.js +4 -0
- package/dist/doc-metadata/types.d.ts +120 -0
- package/dist/doc-metadata/types.js +5 -0
- package/dist/editor-completions/annotationValues.d.ts +12 -0
- package/dist/editor-completions/annotationValues.js +138 -0
- package/dist/editor-completions/contextParser.d.ts +40 -0
- package/dist/editor-completions/contextParser.js +410 -0
- package/dist/editor-completions/dataTypes.d.ts +16 -0
- package/dist/editor-completions/dataTypes.js +95 -0
- package/dist/editor-completions/goToDefinition.d.ts +27 -0
- package/dist/editor-completions/goToDefinition.js +112 -0
- package/dist/editor-completions/index.d.ts +39 -0
- package/dist/editor-completions/index.js +181 -0
- package/dist/editor-completions/jsDocAnnotations.d.ts +29 -0
- package/dist/editor-completions/jsDocAnnotations.js +357 -0
- package/dist/editor-completions/modifierCompletions.d.ts +17 -0
- package/dist/editor-completions/modifierCompletions.js +197 -0
- package/dist/editor-completions/types.d.ts +119 -0
- package/dist/editor-completions/types.js +8 -0
- package/dist/export/index.d.ts +68 -0
- package/dist/export/index.js +1074 -0
- package/dist/export/templates.d.ts +24 -0
- package/dist/export/templates.js +186 -0
- package/dist/friendly-errors.d.ts +35 -0
- package/dist/friendly-errors.js +375 -0
- package/dist/function-like.d.ts +38 -0
- package/dist/function-like.js +83 -0
- package/dist/generated-branding.d.ts +16 -0
- package/dist/generated-branding.js +22 -0
- package/dist/generator/async-detection.d.ts +27 -0
- package/dist/generator/async-detection.js +56 -0
- package/dist/generator/code-utils.d.ts +76 -0
- package/dist/generator/code-utils.js +410 -0
- package/dist/generator/control-flow.d.ts +54 -0
- package/dist/generator/control-flow.js +284 -0
- package/dist/generator/inngest.d.ts +53 -0
- package/dist/generator/inngest.js +1126 -0
- package/dist/generator/scope-function-generator.d.ts +78 -0
- package/dist/generator/scope-function-generator.js +360 -0
- package/dist/generator/unified.d.ts +42 -0
- package/dist/generator/unified.js +1504 -0
- package/dist/generator.d.ts +54 -0
- package/dist/generator.js +100 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +89 -0
- package/dist/jsdoc-parser.d.ts +308 -0
- package/dist/jsdoc-parser.js +923 -0
- package/dist/jsdoc-port-sync/constants.d.ts +41 -0
- package/dist/jsdoc-port-sync/constants.js +103 -0
- package/dist/jsdoc-port-sync/diff.d.ts +76 -0
- package/dist/jsdoc-port-sync/diff.js +319 -0
- package/dist/jsdoc-port-sync/index.d.ts +42 -0
- package/dist/jsdoc-port-sync/index.js +45 -0
- package/dist/jsdoc-port-sync/port-parser.d.ts +68 -0
- package/dist/jsdoc-port-sync/port-parser.js +579 -0
- package/dist/jsdoc-port-sync/rename.d.ts +21 -0
- package/dist/jsdoc-port-sync/rename.js +256 -0
- package/dist/jsdoc-port-sync/signature-parser.d.ts +104 -0
- package/dist/jsdoc-port-sync/signature-parser.js +559 -0
- package/dist/jsdoc-port-sync/sync.d.ts +36 -0
- package/dist/jsdoc-port-sync/sync.js +644 -0
- package/dist/jsdoc-port-sync.d.ts +10 -0
- package/dist/jsdoc-port-sync.js +10 -0
- package/dist/marketplace/index.d.ts +11 -0
- package/dist/marketplace/index.js +10 -0
- package/dist/marketplace/manifest.d.ts +32 -0
- package/dist/marketplace/manifest.js +176 -0
- package/dist/marketplace/registry.d.ts +30 -0
- package/dist/marketplace/registry.js +100 -0
- package/dist/marketplace/types.d.ts +154 -0
- package/dist/marketplace/types.js +9 -0
- package/dist/marketplace/validator.d.ts +13 -0
- package/dist/marketplace/validator.js +131 -0
- package/dist/mcp/auto-registration.d.ts +3 -0
- package/dist/mcp/auto-registration.js +62 -0
- package/dist/mcp/editor-connection.d.ts +50 -0
- package/dist/mcp/editor-connection.js +125 -0
- package/dist/mcp/event-buffer.d.ts +62 -0
- package/dist/mcp/event-buffer.js +150 -0
- package/dist/mcp/index.d.ts +12 -0
- package/dist/mcp/index.js +11 -0
- package/dist/mcp/resources.d.ts +14 -0
- package/dist/mcp/resources.js +55 -0
- package/dist/mcp/response-utils.d.ts +63 -0
- package/dist/mcp/response-utils.js +89 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.js +99 -0
- package/dist/mcp/tools-diagram.d.ts +8 -0
- package/dist/mcp/tools-diagram.js +53 -0
- package/dist/mcp/tools-editor.d.ts +5 -0
- package/dist/mcp/tools-editor.js +190 -0
- package/dist/mcp/tools-export.d.ts +9 -0
- package/dist/mcp/tools-export.js +180 -0
- package/dist/mcp/tools-marketplace.d.ts +9 -0
- package/dist/mcp/tools-marketplace.js +132 -0
- package/dist/mcp/tools-pattern.d.ts +3 -0
- package/dist/mcp/tools-pattern.js +783 -0
- package/dist/mcp/tools-query.d.ts +3 -0
- package/dist/mcp/tools-query.js +364 -0
- package/dist/mcp/tools-template.d.ts +10 -0
- package/dist/mcp/tools-template.js +119 -0
- package/dist/mcp/types.d.ts +70 -0
- package/dist/mcp/types.js +8 -0
- package/dist/mcp/workflow-executor.d.ts +47 -0
- package/dist/mcp/workflow-executor.js +133 -0
- package/dist/migration/registry.d.ts +30 -0
- package/dist/migration/registry.js +29 -0
- package/dist/node-types-generator.d.ts +49 -0
- package/dist/node-types-generator.js +139 -0
- package/dist/npm-packages.d.ts +56 -0
- package/dist/npm-packages.js +255 -0
- package/dist/parser.d.ts +204 -0
- package/dist/parser.js +2100 -0
- package/dist/plugin/PluginPanel.d.ts +12 -0
- package/dist/plugin/PluginPanel.js +5 -0
- package/dist/plugin/index.d.ts +13 -0
- package/dist/plugin/index.js +14 -0
- package/dist/plugin/types.d.ts +75 -0
- package/dist/plugin/types.js +8 -0
- package/dist/resolve-package-types.d.ts +17 -0
- package/dist/resolve-package-types.js +123 -0
- package/dist/runtime/CancellationError.d.ts +11 -0
- package/dist/runtime/CancellationError.js +20 -0
- package/dist/runtime/ExecutionContext.d.ts +146 -0
- package/dist/runtime/ExecutionContext.js +235 -0
- package/dist/runtime/builtin-functions.d.ts +8 -0
- package/dist/runtime/builtin-functions.js +549 -0
- package/dist/runtime/events.d.ts +50 -0
- package/dist/runtime/events.js +2 -0
- package/dist/runtime/function-registry.d.ts +59 -0
- package/dist/runtime/function-registry.js +66 -0
- package/dist/runtime/index.d.ts +7 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/parameter-resolver.d.ts +62 -0
- package/dist/runtime/parameter-resolver.js +113 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +6 -0
- package/dist/server/types.d.ts +93 -0
- package/dist/server/types.js +5 -0
- package/dist/server/webhook-server.d.ts +50 -0
- package/dist/server/webhook-server.js +269 -0
- package/dist/server/workflow-registry.d.ts +61 -0
- package/dist/server/workflow-registry.js +202 -0
- package/dist/shared-project.d.ts +9 -0
- package/dist/shared-project.js +28 -0
- package/dist/sugar-optimizer.d.ts +40 -0
- package/dist/sugar-optimizer.js +387 -0
- package/dist/testing/assertions.d.ts +51 -0
- package/dist/testing/assertions.js +127 -0
- package/dist/testing/index.d.ts +30 -0
- package/dist/testing/index.js +24 -0
- package/dist/testing/mock-approval.d.ts +81 -0
- package/dist/testing/mock-approval.js +98 -0
- package/dist/testing/mock-llm.d.ts +124 -0
- package/dist/testing/mock-llm.js +119 -0
- package/dist/testing/recorder.d.ts +72 -0
- package/dist/testing/recorder.js +70 -0
- package/dist/testing/replayer.d.ts +56 -0
- package/dist/testing/replayer.js +143 -0
- package/dist/testing/token-tracker.d.ts +71 -0
- package/dist/testing/token-tracker.js +94 -0
- package/dist/type-checker.d.ts +42 -0
- package/dist/type-checker.js +190 -0
- package/dist/type-mappings.d.ts +29 -0
- package/dist/type-mappings.js +125 -0
- package/dist/types/branded-ports.d.ts +151 -0
- package/dist/types/branded-ports.js +121 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.js +15 -0
- package/dist/utils/error-utils.d.ts +15 -0
- package/dist/utils/error-utils.js +27 -0
- package/dist/utils/lru-cache.d.ts +15 -0
- package/dist/utils/lru-cache.js +40 -0
- package/dist/utils/port-ordering.d.ts +26 -0
- package/dist/utils/port-ordering.js +88 -0
- package/dist/utils/port-tag-utils.d.ts +23 -0
- package/dist/utils/port-tag-utils.js +41 -0
- package/dist/utils/string-distance.d.ts +14 -0
- package/dist/utils/string-distance.js +56 -0
- package/dist/validation/agent-detection.d.ts +33 -0
- package/dist/validation/agent-detection.js +115 -0
- package/dist/validation/agent-rules.d.ts +48 -0
- package/dist/validation/agent-rules.js +262 -0
- package/dist/validator.d.ts +92 -0
- package/dist/validator.js +970 -0
- package/package.json +109 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { getGeneratedBranding } from '../generated-branding.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generates inline runtime code for standalone execution
|
|
4
|
+
*
|
|
5
|
+
* This includes all types and the GeneratedExecutionContext class
|
|
6
|
+
* so generated workflows have zero runtime dependencies.
|
|
7
|
+
*
|
|
8
|
+
* @param production - Whether to generate production-optimized code (no debug events)
|
|
9
|
+
* @param exportClasses - Whether to add 'export' keyword to classes (for shared modules)
|
|
10
|
+
*/
|
|
11
|
+
export function generateInlineRuntime(production, exportClasses = false) {
|
|
12
|
+
const exportKeyword = exportClasses ? 'export ' : '';
|
|
13
|
+
const lines = [];
|
|
14
|
+
// Type definitions
|
|
15
|
+
lines.push('// ============================================================================');
|
|
16
|
+
lines.push('// Runtime Types');
|
|
17
|
+
lines.push('// ============================================================================');
|
|
18
|
+
lines.push('');
|
|
19
|
+
lines.push('type TStatusType =');
|
|
20
|
+
lines.push(' | "RUNNING"');
|
|
21
|
+
lines.push(' | "SCHEDULED"');
|
|
22
|
+
lines.push(' | "SUCCEEDED"');
|
|
23
|
+
lines.push(' | "FAILED"');
|
|
24
|
+
lines.push(' | "CANCELLED"');
|
|
25
|
+
lines.push(' | "PENDING";');
|
|
26
|
+
lines.push('');
|
|
27
|
+
lines.push('type TVariableIdentification = {');
|
|
28
|
+
lines.push(' nodeTypeName: string;');
|
|
29
|
+
lines.push(' id: string;');
|
|
30
|
+
lines.push(' scope?: string | undefined;');
|
|
31
|
+
lines.push(' side?: "start" | "exit" | undefined;');
|
|
32
|
+
lines.push(' portName: string;');
|
|
33
|
+
lines.push(' executionIndex: number;');
|
|
34
|
+
lines.push(' key?: string | undefined;');
|
|
35
|
+
lines.push('};');
|
|
36
|
+
lines.push('');
|
|
37
|
+
if (!production) {
|
|
38
|
+
// Debug types only in development mode
|
|
39
|
+
lines.push('type TStatusChangedEvent = {');
|
|
40
|
+
lines.push(' type: "STATUS_CHANGED";');
|
|
41
|
+
lines.push(' nodeTypeName: string;');
|
|
42
|
+
lines.push(' id: string;');
|
|
43
|
+
lines.push(' scope?: string;');
|
|
44
|
+
lines.push(' side?: "start" | "exit";');
|
|
45
|
+
lines.push(' executionIndex: number;');
|
|
46
|
+
lines.push(' status: TStatusType;');
|
|
47
|
+
lines.push(' innerFlowInvocation?: boolean;');
|
|
48
|
+
lines.push('};');
|
|
49
|
+
lines.push('');
|
|
50
|
+
lines.push('type TVariableSetEvent = {');
|
|
51
|
+
lines.push(' type: "VARIABLE_SET";');
|
|
52
|
+
lines.push(' identifier: TVariableIdentification;');
|
|
53
|
+
lines.push(' value?: unknown;');
|
|
54
|
+
lines.push(' innerFlowInvocation?: boolean;');
|
|
55
|
+
lines.push('};');
|
|
56
|
+
lines.push('');
|
|
57
|
+
lines.push('type TErrorLogEvent = {');
|
|
58
|
+
lines.push(' type: "LOG_ERROR";');
|
|
59
|
+
lines.push(' nodeTypeName: string;');
|
|
60
|
+
lines.push(' id: string;');
|
|
61
|
+
lines.push(' scope?: string;');
|
|
62
|
+
lines.push(' side?: "start" | "exit";');
|
|
63
|
+
lines.push(' executionIndex: number;');
|
|
64
|
+
lines.push(' error: string;');
|
|
65
|
+
lines.push(' innerFlowInvocation?: boolean;');
|
|
66
|
+
lines.push('};');
|
|
67
|
+
lines.push('');
|
|
68
|
+
lines.push('type TWorkflowCompletedEvent = {');
|
|
69
|
+
lines.push(' type: "WORKFLOW_COMPLETED";');
|
|
70
|
+
lines.push(' executionIndex: number;');
|
|
71
|
+
lines.push(' status: "SUCCEEDED" | "FAILED" | "CANCELLED";');
|
|
72
|
+
lines.push(' result?: unknown;');
|
|
73
|
+
lines.push(' innerFlowInvocation?: boolean;');
|
|
74
|
+
lines.push('};');
|
|
75
|
+
lines.push('');
|
|
76
|
+
lines.push(`${exportKeyword}type TEvent =`);
|
|
77
|
+
lines.push(' | TStatusChangedEvent');
|
|
78
|
+
lines.push(' | TVariableSetEvent');
|
|
79
|
+
lines.push(' | TErrorLogEvent');
|
|
80
|
+
lines.push(' | TWorkflowCompletedEvent;');
|
|
81
|
+
lines.push('');
|
|
82
|
+
lines.push(`${exportKeyword}type TDebugger = {`);
|
|
83
|
+
lines.push(' sendEvent: (event: TEvent) => void;');
|
|
84
|
+
lines.push(' innerFlowInvocation: boolean;');
|
|
85
|
+
lines.push(' sessionId?: string;');
|
|
86
|
+
lines.push('};');
|
|
87
|
+
lines.push('');
|
|
88
|
+
// Declare __flowWeaverDebugger__ so TypeScript knows it might exist at runtime
|
|
89
|
+
// (e.g., passed as a function parameter or injected by execution harness)
|
|
90
|
+
lines.push('declare const __flowWeaverDebugger__: TDebugger | undefined;');
|
|
91
|
+
lines.push('');
|
|
92
|
+
}
|
|
93
|
+
// Declare __abortSignal__ so TypeScript knows it might exist at runtime
|
|
94
|
+
// (passed as a function parameter for cancellation support)
|
|
95
|
+
lines.push('declare const __abortSignal__: AbortSignal | undefined;');
|
|
96
|
+
lines.push('');
|
|
97
|
+
lines.push('interface VariableAddress {');
|
|
98
|
+
lines.push(' id: string;');
|
|
99
|
+
lines.push(' portName: string;');
|
|
100
|
+
lines.push(' executionIndex: number;');
|
|
101
|
+
lines.push(' nodeTypeName?: string | undefined;');
|
|
102
|
+
lines.push(' scope?: string | undefined;');
|
|
103
|
+
lines.push(" side?: 'start' | 'exit' | undefined;");
|
|
104
|
+
lines.push('}');
|
|
105
|
+
lines.push('');
|
|
106
|
+
lines.push('interface ExecutionInfo {');
|
|
107
|
+
lines.push(' id: string;');
|
|
108
|
+
lines.push(' index: number;');
|
|
109
|
+
lines.push(' parentIndex?: number | undefined;');
|
|
110
|
+
lines.push(' scopeName?: string | undefined;');
|
|
111
|
+
lines.push('}');
|
|
112
|
+
lines.push('');
|
|
113
|
+
lines.push('type VariableValue = unknown | (() => unknown) | (() => Promise<unknown>);');
|
|
114
|
+
lines.push('');
|
|
115
|
+
// CancellationError class
|
|
116
|
+
lines.push('// ============================================================================');
|
|
117
|
+
lines.push('// Cancellation Error');
|
|
118
|
+
lines.push('// ============================================================================');
|
|
119
|
+
lines.push('');
|
|
120
|
+
lines.push(`${exportKeyword}class CancellationError extends Error {`);
|
|
121
|
+
lines.push(' public readonly executionIndex: number;');
|
|
122
|
+
lines.push(' public readonly nodeId?: string;');
|
|
123
|
+
lines.push(' public readonly timestamp: number;');
|
|
124
|
+
lines.push('');
|
|
125
|
+
lines.push(' constructor(');
|
|
126
|
+
lines.push(" message: string = 'Workflow execution cancelled',");
|
|
127
|
+
lines.push(' executionIndex: number = 0,');
|
|
128
|
+
lines.push(' nodeId?: string,');
|
|
129
|
+
lines.push(' timestamp: number = Date.now()');
|
|
130
|
+
lines.push(' ) {');
|
|
131
|
+
lines.push(' super(message);');
|
|
132
|
+
lines.push(" this.name = 'CancellationError';");
|
|
133
|
+
lines.push(' this.executionIndex = executionIndex;');
|
|
134
|
+
lines.push(' this.nodeId = nodeId;');
|
|
135
|
+
lines.push(' this.timestamp = timestamp;');
|
|
136
|
+
lines.push(' }');
|
|
137
|
+
lines.push('');
|
|
138
|
+
lines.push(' static isCancellationError(error: unknown): error is CancellationError {');
|
|
139
|
+
lines.push(' return (');
|
|
140
|
+
lines.push(' error instanceof CancellationError ||');
|
|
141
|
+
lines.push(" (error instanceof Error && error.name === 'CancellationError')");
|
|
142
|
+
lines.push(' );');
|
|
143
|
+
lines.push(' }');
|
|
144
|
+
lines.push('}');
|
|
145
|
+
lines.push('');
|
|
146
|
+
// GeneratedExecutionContext class
|
|
147
|
+
lines.push('// ============================================================================');
|
|
148
|
+
lines.push('// Execution Context');
|
|
149
|
+
lines.push('// ============================================================================');
|
|
150
|
+
lines.push('');
|
|
151
|
+
lines.push(`${exportKeyword}class GeneratedExecutionContext {`);
|
|
152
|
+
lines.push(' private variables: Map<string, VariableValue> = new Map();');
|
|
153
|
+
lines.push(' private executions: Map<string, ExecutionInfo> = new Map();');
|
|
154
|
+
lines.push(' private executionCounter: number = 0;');
|
|
155
|
+
lines.push(' private nodeExecutionCounts: Map<string, number> = new Map();');
|
|
156
|
+
lines.push(' private isAsync: boolean;');
|
|
157
|
+
if (!production) {
|
|
158
|
+
lines.push(' private flowWeaverDebugger?: TDebugger | undefined;');
|
|
159
|
+
}
|
|
160
|
+
lines.push(' private pullExecutors: Map<string, () => void | Promise<void>> = new Map();');
|
|
161
|
+
lines.push(' private nodeExecutionIndices: Map<string, number> = new Map();');
|
|
162
|
+
lines.push(' private abortSignal?: AbortSignal | undefined;');
|
|
163
|
+
lines.push('');
|
|
164
|
+
// Constructor
|
|
165
|
+
if (production) {
|
|
166
|
+
lines.push(' constructor(isAsync: boolean = true, abortSignal?: AbortSignal) {');
|
|
167
|
+
lines.push(' this.isAsync = isAsync;');
|
|
168
|
+
lines.push(' this.abortSignal = abortSignal;');
|
|
169
|
+
lines.push(' }');
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
lines.push(' constructor(isAsync: boolean = true, flowWeaverDebugger?: TDebugger, abortSignal?: AbortSignal) {');
|
|
173
|
+
lines.push(' this.isAsync = isAsync;');
|
|
174
|
+
lines.push(' this.flowWeaverDebugger = flowWeaverDebugger;');
|
|
175
|
+
lines.push(' this.abortSignal = abortSignal;');
|
|
176
|
+
lines.push(' }');
|
|
177
|
+
}
|
|
178
|
+
lines.push('');
|
|
179
|
+
// Core methods (always included)
|
|
180
|
+
lines.push(' registerPullExecutor(id: string, executor: () => void | Promise<void>): void {');
|
|
181
|
+
lines.push(' this.pullExecutors.set(id, executor);');
|
|
182
|
+
lines.push(' }');
|
|
183
|
+
lines.push('');
|
|
184
|
+
lines.push(' addExecution(id: string, parentIndex?: number, scopeName?: string): number {');
|
|
185
|
+
lines.push(' // Use per-node execution counter (each node starts at 0)');
|
|
186
|
+
lines.push(' const currentCount = this.nodeExecutionCounts.get(id) || 0;');
|
|
187
|
+
lines.push(' const index = currentCount;');
|
|
188
|
+
lines.push(' this.nodeExecutionCounts.set(id, currentCount + 1);');
|
|
189
|
+
lines.push(' this.executionCounter++;');
|
|
190
|
+
lines.push(' this.executions.set(this.getExecutionKey(id, index), {');
|
|
191
|
+
lines.push(' id,');
|
|
192
|
+
lines.push(' index,');
|
|
193
|
+
lines.push(' parentIndex,');
|
|
194
|
+
lines.push(' scopeName,');
|
|
195
|
+
lines.push(' });');
|
|
196
|
+
lines.push(' this.nodeExecutionIndices.set(id, index);');
|
|
197
|
+
lines.push(' return index;');
|
|
198
|
+
lines.push(' }');
|
|
199
|
+
lines.push('');
|
|
200
|
+
// setVariable with conditional debug code
|
|
201
|
+
lines.push(' setVariable(address: VariableAddress, value: VariableValue): void | Promise<void> {');
|
|
202
|
+
lines.push(' const key = this.getVariableKey(address);');
|
|
203
|
+
lines.push(' this.variables.set(key, value);');
|
|
204
|
+
if (!production) {
|
|
205
|
+
lines.push(' if (this.flowWeaverDebugger) {');
|
|
206
|
+
lines.push(' const actualValue = typeof value === "function" ? value() : value;');
|
|
207
|
+
lines.push(' this.sendVariableSetEvent({');
|
|
208
|
+
lines.push(' identifier: {');
|
|
209
|
+
lines.push(' nodeTypeName: address.nodeTypeName || "unknown",');
|
|
210
|
+
lines.push(' id: address.id,');
|
|
211
|
+
lines.push(' portName: address.portName,');
|
|
212
|
+
lines.push(' executionIndex: address.executionIndex,');
|
|
213
|
+
lines.push(' key: "default",');
|
|
214
|
+
lines.push(' ...(address.scope && { scope: address.scope }),');
|
|
215
|
+
lines.push(' ...(address.side && { side: address.side }),');
|
|
216
|
+
lines.push(' },');
|
|
217
|
+
lines.push(' value: actualValue,');
|
|
218
|
+
lines.push(' });');
|
|
219
|
+
lines.push(' }');
|
|
220
|
+
}
|
|
221
|
+
lines.push(' return this.isAsync ? Promise.resolve() : undefined;');
|
|
222
|
+
lines.push(' }');
|
|
223
|
+
lines.push('');
|
|
224
|
+
// getVariable
|
|
225
|
+
lines.push(' getVariable(address: VariableAddress): unknown | Promise<unknown> {');
|
|
226
|
+
lines.push(' const executor = this.pullExecutors.get(address.id);');
|
|
227
|
+
lines.push(' if (executor) {');
|
|
228
|
+
lines.push(' if (!this.hasVariable(address)) {');
|
|
229
|
+
lines.push(' const result = executor();');
|
|
230
|
+
lines.push(' // Handle async executor (returns Promise)');
|
|
231
|
+
lines.push(' if (result instanceof Promise) {');
|
|
232
|
+
lines.push(' return result.then(() => {');
|
|
233
|
+
lines.push(' const trackedIndex = this.nodeExecutionIndices.get(address.id);');
|
|
234
|
+
lines.push(' const finalAddress = trackedIndex !== undefined');
|
|
235
|
+
lines.push(' ? { ...address, executionIndex: trackedIndex }');
|
|
236
|
+
lines.push(' : address;');
|
|
237
|
+
lines.push(' return this.retrieveVariable(finalAddress);');
|
|
238
|
+
lines.push(' });');
|
|
239
|
+
lines.push(' }');
|
|
240
|
+
lines.push(' // Handle sync executor (returns void)');
|
|
241
|
+
lines.push(' const trackedIndex = this.nodeExecutionIndices.get(address.id);');
|
|
242
|
+
lines.push(' const finalAddress = trackedIndex !== undefined');
|
|
243
|
+
lines.push(' ? { ...address, executionIndex: trackedIndex }');
|
|
244
|
+
lines.push(' : address;');
|
|
245
|
+
lines.push(' return this.retrieveVariable(finalAddress);');
|
|
246
|
+
lines.push(' }');
|
|
247
|
+
lines.push(' }');
|
|
248
|
+
lines.push(' return this.retrieveVariable(address);');
|
|
249
|
+
lines.push(' }');
|
|
250
|
+
lines.push('');
|
|
251
|
+
// retrieveVariable
|
|
252
|
+
lines.push(' private retrieveVariable(address: VariableAddress): unknown | Promise<unknown> {');
|
|
253
|
+
lines.push(' const key = this.getVariableKey(address);');
|
|
254
|
+
lines.push(' if (!this.variables.has(key)) {');
|
|
255
|
+
lines.push(' throw new Error(`Variable not found: ${address.id}.${address.portName}[${address.executionIndex}]`);');
|
|
256
|
+
lines.push(' }');
|
|
257
|
+
lines.push(' const value = this.variables.get(key);');
|
|
258
|
+
lines.push(' if (typeof value === "function") {');
|
|
259
|
+
lines.push(' const result = value();');
|
|
260
|
+
lines.push(' if (result instanceof Promise) {');
|
|
261
|
+
lines.push(' return result;');
|
|
262
|
+
lines.push(' }');
|
|
263
|
+
lines.push(' return this.isAsync ? Promise.resolve(result) : result;');
|
|
264
|
+
lines.push(' }');
|
|
265
|
+
lines.push(' return this.isAsync ? Promise.resolve(value) : value;');
|
|
266
|
+
lines.push(' }');
|
|
267
|
+
lines.push('');
|
|
268
|
+
// hasVariable
|
|
269
|
+
lines.push(' hasVariable(address: VariableAddress): boolean {');
|
|
270
|
+
lines.push(' const key = this.getVariableKey(address);');
|
|
271
|
+
lines.push(' return this.variables.has(key);');
|
|
272
|
+
lines.push(' }');
|
|
273
|
+
lines.push('');
|
|
274
|
+
// getExecution
|
|
275
|
+
lines.push(' getExecution(id: string, index: number): ExecutionInfo | undefined {');
|
|
276
|
+
lines.push(' return this.executions.get(this.getExecutionKey(id, index));');
|
|
277
|
+
lines.push(' }');
|
|
278
|
+
lines.push('');
|
|
279
|
+
// createScope
|
|
280
|
+
lines.push(' createScope(_parentNodeName: string, _parentIndex: number, _scopeName: string, cleanScope: boolean = false): GeneratedExecutionContext {');
|
|
281
|
+
if (production) {
|
|
282
|
+
lines.push(' const scopedContext = new GeneratedExecutionContext(this.isAsync, this.abortSignal);');
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
lines.push(' const scopedContext = new GeneratedExecutionContext(this.isAsync, this.flowWeaverDebugger, this.abortSignal);');
|
|
286
|
+
}
|
|
287
|
+
lines.push(' // For per-port function scopes (cleanScope=true), start with empty variables');
|
|
288
|
+
lines.push(' // For node-level scopes (cleanScope=false), inherit parent variables');
|
|
289
|
+
lines.push(' scopedContext.variables = cleanScope ? new Map() : new Map(this.variables);');
|
|
290
|
+
lines.push(' scopedContext.executions = new Map(this.executions);');
|
|
291
|
+
lines.push(' scopedContext.executionCounter = this.executionCounter;');
|
|
292
|
+
lines.push(' scopedContext.nodeExecutionCounts = new Map(this.nodeExecutionCounts);');
|
|
293
|
+
lines.push(' return scopedContext;');
|
|
294
|
+
lines.push(' }');
|
|
295
|
+
lines.push('');
|
|
296
|
+
// mergeScope
|
|
297
|
+
lines.push(' mergeScope(scopedContext: GeneratedExecutionContext): void {');
|
|
298
|
+
lines.push(' scopedContext.executions.forEach((info, key) => {');
|
|
299
|
+
lines.push(' this.executions.set(key, info);');
|
|
300
|
+
lines.push(' });');
|
|
301
|
+
lines.push(' scopedContext.variables.forEach((value, key) => {');
|
|
302
|
+
lines.push(' this.variables.set(key, value);');
|
|
303
|
+
lines.push(' });');
|
|
304
|
+
lines.push(' this.executionCounter = Math.max(this.executionCounter, scopedContext.executionCounter);');
|
|
305
|
+
lines.push(' scopedContext.nodeExecutionCounts.forEach((count, id) => {');
|
|
306
|
+
lines.push(' const currentCount = this.nodeExecutionCounts.get(id) || 0;');
|
|
307
|
+
lines.push(' this.nodeExecutionCounts.set(id, Math.max(currentCount, count));');
|
|
308
|
+
lines.push(' });');
|
|
309
|
+
lines.push(' }');
|
|
310
|
+
lines.push('');
|
|
311
|
+
// Helper methods
|
|
312
|
+
lines.push(' private getVariableKey(address: VariableAddress): string {');
|
|
313
|
+
lines.push(' return `${address.id}:${address.portName}:${address.executionIndex}`;');
|
|
314
|
+
lines.push(' }');
|
|
315
|
+
lines.push('');
|
|
316
|
+
lines.push(' private getExecutionKey(id: string, index: number): string {');
|
|
317
|
+
lines.push(' return `${id}:${index}`;');
|
|
318
|
+
lines.push(' }');
|
|
319
|
+
lines.push('');
|
|
320
|
+
lines.push(' getExecutionCount(): number {');
|
|
321
|
+
lines.push(' return this.executionCounter;');
|
|
322
|
+
lines.push(' }');
|
|
323
|
+
lines.push('');
|
|
324
|
+
lines.push(' reset(): void {');
|
|
325
|
+
lines.push(' this.variables.clear();');
|
|
326
|
+
lines.push(' this.executions.clear();');
|
|
327
|
+
lines.push(' this.executionCounter = 0;');
|
|
328
|
+
lines.push(' this.nodeExecutionCounts.clear();');
|
|
329
|
+
lines.push(' }');
|
|
330
|
+
lines.push('');
|
|
331
|
+
// Cancellation methods
|
|
332
|
+
lines.push(' isAborted(): boolean {');
|
|
333
|
+
lines.push(' return this.abortSignal?.aborted ?? false;');
|
|
334
|
+
lines.push(' }');
|
|
335
|
+
lines.push('');
|
|
336
|
+
lines.push(' checkAborted(nodeId?: string): void {');
|
|
337
|
+
lines.push(' if (this.abortSignal?.aborted) {');
|
|
338
|
+
lines.push(' throw new CancellationError(');
|
|
339
|
+
lines.push(" `Workflow execution cancelled${nodeId ? ` at ${nodeId}` : ''}`,");
|
|
340
|
+
lines.push(' this.executionCounter,');
|
|
341
|
+
lines.push(' nodeId');
|
|
342
|
+
lines.push(' );');
|
|
343
|
+
lines.push(' }');
|
|
344
|
+
lines.push(' }');
|
|
345
|
+
lines.push('');
|
|
346
|
+
// Debug event methods (only in development mode)
|
|
347
|
+
if (!production) {
|
|
348
|
+
lines.push(' sendStatusChangedEvent(args: {');
|
|
349
|
+
lines.push(' nodeTypeName: string;');
|
|
350
|
+
lines.push(' id: string;');
|
|
351
|
+
lines.push(' scope?: string;');
|
|
352
|
+
lines.push(' side?: "start" | "exit";');
|
|
353
|
+
lines.push(' executionIndex: number;');
|
|
354
|
+
lines.push(' status: TStatusType;');
|
|
355
|
+
lines.push(' }): void {');
|
|
356
|
+
lines.push(' if (this.flowWeaverDebugger) {');
|
|
357
|
+
lines.push(' this.flowWeaverDebugger.sendEvent({');
|
|
358
|
+
lines.push(' type: "STATUS_CHANGED",');
|
|
359
|
+
lines.push(' ...args,');
|
|
360
|
+
lines.push(' innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,');
|
|
361
|
+
lines.push(' });');
|
|
362
|
+
lines.push(' }');
|
|
363
|
+
lines.push(' }');
|
|
364
|
+
lines.push('');
|
|
365
|
+
lines.push(' private sendVariableSetEvent(args: {');
|
|
366
|
+
lines.push(' identifier: TVariableIdentification;');
|
|
367
|
+
lines.push(' value: unknown;');
|
|
368
|
+
lines.push(' }): void {');
|
|
369
|
+
lines.push(' if (this.flowWeaverDebugger) {');
|
|
370
|
+
lines.push(' this.flowWeaverDebugger.sendEvent({');
|
|
371
|
+
lines.push(' type: "VARIABLE_SET",');
|
|
372
|
+
lines.push(' ...args,');
|
|
373
|
+
lines.push(' innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,');
|
|
374
|
+
lines.push(' });');
|
|
375
|
+
lines.push(' }');
|
|
376
|
+
lines.push(' }');
|
|
377
|
+
lines.push('');
|
|
378
|
+
lines.push(' sendLogErrorEvent(args: {');
|
|
379
|
+
lines.push(' nodeTypeName: string;');
|
|
380
|
+
lines.push(' id: string;');
|
|
381
|
+
lines.push(' scope?: string;');
|
|
382
|
+
lines.push(' side?: "start" | "exit";');
|
|
383
|
+
lines.push(' executionIndex: number;');
|
|
384
|
+
lines.push(' error: string;');
|
|
385
|
+
lines.push(' }): void {');
|
|
386
|
+
lines.push(' if (this.flowWeaverDebugger) {');
|
|
387
|
+
lines.push(' this.flowWeaverDebugger.sendEvent({');
|
|
388
|
+
lines.push(' type: "LOG_ERROR",');
|
|
389
|
+
lines.push(' ...args,');
|
|
390
|
+
lines.push(' innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,');
|
|
391
|
+
lines.push(' });');
|
|
392
|
+
lines.push(' }');
|
|
393
|
+
lines.push(' }');
|
|
394
|
+
lines.push('');
|
|
395
|
+
lines.push(' sendWorkflowCompletedEvent(args: {');
|
|
396
|
+
lines.push(' executionIndex: number;');
|
|
397
|
+
lines.push(' status: "SUCCEEDED" | "FAILED" | "CANCELLED";');
|
|
398
|
+
lines.push(' result?: unknown;');
|
|
399
|
+
lines.push(' }): void {');
|
|
400
|
+
lines.push(' if (this.flowWeaverDebugger) {');
|
|
401
|
+
lines.push(' this.flowWeaverDebugger.sendEvent({');
|
|
402
|
+
lines.push(' type: "WORKFLOW_COMPLETED",');
|
|
403
|
+
lines.push(' ...args,');
|
|
404
|
+
lines.push(' innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,');
|
|
405
|
+
lines.push(' });');
|
|
406
|
+
lines.push(' }');
|
|
407
|
+
lines.push(' }');
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
// Production mode: stub implementations (no-ops)
|
|
411
|
+
lines.push(' sendStatusChangedEvent(_args: unknown): void {');
|
|
412
|
+
lines.push(' // No-op in production mode');
|
|
413
|
+
lines.push(' }');
|
|
414
|
+
lines.push('');
|
|
415
|
+
lines.push(' sendLogErrorEvent(_args: unknown): void {');
|
|
416
|
+
lines.push(' // No-op in production mode');
|
|
417
|
+
lines.push(' }');
|
|
418
|
+
lines.push('');
|
|
419
|
+
lines.push(' sendWorkflowCompletedEvent(_args: unknown): void {');
|
|
420
|
+
lines.push(' // No-op in production mode');
|
|
421
|
+
lines.push(' }');
|
|
422
|
+
}
|
|
423
|
+
lines.push('}');
|
|
424
|
+
lines.push('');
|
|
425
|
+
return lines.join('\n');
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Generates inline WebSocket debug client for auto-detection from env var
|
|
429
|
+
* Only included in development mode builds
|
|
430
|
+
*
|
|
431
|
+
* @param moduleFormat - The module format to use for imports ('esm' or 'cjs')
|
|
432
|
+
*/
|
|
433
|
+
export function generateInlineDebugClient(moduleFormat = 'esm') {
|
|
434
|
+
const lines = [];
|
|
435
|
+
lines.push('// ============================================================================');
|
|
436
|
+
lines.push('// Inline Debug Client (auto-created from FLOW_WEAVER_DEBUG env var)');
|
|
437
|
+
lines.push('// ============================================================================');
|
|
438
|
+
lines.push('');
|
|
439
|
+
lines.push('/* eslint-disable @typescript-eslint/no-explicit-any, no-console */');
|
|
440
|
+
lines.push('function createFlowWeaverDebugClient(url: string, workflowExportName: string): any {');
|
|
441
|
+
lines.push(' let ws: any = null;');
|
|
442
|
+
lines.push(' let connected = false;');
|
|
443
|
+
lines.push(' let queue: string[] = [];');
|
|
444
|
+
lines.push(' const sessionId = Math.random().toString(36).substring(2, 15);');
|
|
445
|
+
lines.push('');
|
|
446
|
+
lines.push(' const connect = async () => {');
|
|
447
|
+
lines.push(' try {');
|
|
448
|
+
lines.push(" // Node.js environment - dynamically load 'ws' package");
|
|
449
|
+
// Generate format-appropriate import for 'ws' package
|
|
450
|
+
if (moduleFormat === 'cjs') {
|
|
451
|
+
// CommonJS: use require() directly
|
|
452
|
+
lines.push(" const wsModule = require('ws');");
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
// ESM: use dynamic import
|
|
456
|
+
lines.push(" const wsModule = await import('ws');");
|
|
457
|
+
}
|
|
458
|
+
lines.push(' const WS: any = wsModule.default || wsModule;');
|
|
459
|
+
lines.push(' ws = new WS(url);');
|
|
460
|
+
lines.push('');
|
|
461
|
+
lines.push(" ws.on('open', () => {");
|
|
462
|
+
lines.push(' connected = true;');
|
|
463
|
+
lines.push(' // Send connect message');
|
|
464
|
+
lines.push(' ws.send(JSON.stringify({');
|
|
465
|
+
lines.push(" type: 'connect',");
|
|
466
|
+
lines.push(' sessionId,');
|
|
467
|
+
lines.push(' workflowExportName,');
|
|
468
|
+
lines.push(' clientInfo: {');
|
|
469
|
+
lines.push(' platform: process.platform,');
|
|
470
|
+
lines.push(' nodeVersion: process.version,');
|
|
471
|
+
lines.push(' pid: process.pid');
|
|
472
|
+
lines.push(' }');
|
|
473
|
+
lines.push(' }));');
|
|
474
|
+
lines.push('');
|
|
475
|
+
lines.push(' // Flush queued events');
|
|
476
|
+
lines.push(' while (queue.length > 0) {');
|
|
477
|
+
lines.push(' const msg = queue.shift();');
|
|
478
|
+
lines.push(' if (ws.readyState === 1) ws.send(msg);');
|
|
479
|
+
lines.push(' }');
|
|
480
|
+
lines.push(' });');
|
|
481
|
+
lines.push('');
|
|
482
|
+
lines.push(" ws.on('error', () => { connected = false; });");
|
|
483
|
+
lines.push(" ws.on('close', () => { connected = false; });");
|
|
484
|
+
lines.push(' } catch (err: unknown) {');
|
|
485
|
+
lines.push(" // Silently fail if 'ws' package not available");
|
|
486
|
+
lines.push(" console.warn('[Flow Weaver] Debug client failed to connect:', err instanceof Error ? err.message : String(err));");
|
|
487
|
+
lines.push(' }');
|
|
488
|
+
lines.push(' };');
|
|
489
|
+
lines.push('');
|
|
490
|
+
lines.push(' return {');
|
|
491
|
+
lines.push(' sendEvent: (event: unknown) => {');
|
|
492
|
+
lines.push(" const message = JSON.stringify({ type: 'event', sessionId, event });");
|
|
493
|
+
lines.push(' if (!ws) connect().catch(() => {});');
|
|
494
|
+
lines.push(' if (connected && ws.readyState === 1) {');
|
|
495
|
+
lines.push(' ws.send(message);');
|
|
496
|
+
lines.push(' } else {');
|
|
497
|
+
lines.push(' queue.push(message);');
|
|
498
|
+
lines.push(' }');
|
|
499
|
+
lines.push(' },');
|
|
500
|
+
lines.push(' innerFlowInvocation: false,');
|
|
501
|
+
lines.push(' sessionId');
|
|
502
|
+
lines.push(' };');
|
|
503
|
+
lines.push('}');
|
|
504
|
+
lines.push('/* eslint-enable @typescript-eslint/no-explicit-any, no-console */');
|
|
505
|
+
lines.push('');
|
|
506
|
+
return lines.join('\n');
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Generates a standalone runtime module file for multi-workflow bundles.
|
|
510
|
+
* This exports all runtime types and classes so individual workflow files can import them.
|
|
511
|
+
*
|
|
512
|
+
* @param production - Whether to generate production-optimized code (no debug events)
|
|
513
|
+
* @param moduleFormat - The module format to use ('esm' or 'cjs')
|
|
514
|
+
*/
|
|
515
|
+
export function generateStandaloneRuntimeModule(production, moduleFormat = 'esm') {
|
|
516
|
+
const lines = [];
|
|
517
|
+
lines.push('// ============================================================================');
|
|
518
|
+
lines.push('// Shared Runtime Module');
|
|
519
|
+
lines.push(getGeneratedBranding().header());
|
|
520
|
+
lines.push('// ============================================================================');
|
|
521
|
+
lines.push('');
|
|
522
|
+
// Include the inline runtime (all types and GeneratedExecutionContext class)
|
|
523
|
+
// Pass exportClasses=true to add 'export' keywords for module use
|
|
524
|
+
const inlineRuntime = generateInlineRuntime(production, true);
|
|
525
|
+
lines.push(inlineRuntime);
|
|
526
|
+
lines.push('');
|
|
527
|
+
// Include debug client in development mode
|
|
528
|
+
if (!production) {
|
|
529
|
+
const debugClient = generateInlineDebugClient(moduleFormat);
|
|
530
|
+
// Add export to the createFlowWeaverDebugClient function
|
|
531
|
+
const exportedDebugClient = debugClient.replace('function createFlowWeaverDebugClient', 'export function createFlowWeaverDebugClient');
|
|
532
|
+
lines.push(exportedDebugClient);
|
|
533
|
+
lines.push('');
|
|
534
|
+
}
|
|
535
|
+
if (moduleFormat === 'cjs') {
|
|
536
|
+
// CommonJS exports
|
|
537
|
+
lines.push('// ============================================================================');
|
|
538
|
+
lines.push('// Exports');
|
|
539
|
+
lines.push('// ============================================================================');
|
|
540
|
+
lines.push('');
|
|
541
|
+
const exports = ['GeneratedExecutionContext', 'CancellationError'];
|
|
542
|
+
if (!production) {
|
|
543
|
+
exports.push('createFlowWeaverDebugClient', 'TDebugger');
|
|
544
|
+
}
|
|
545
|
+
lines.push(`module.exports = { ${exports.join(', ')} };`);
|
|
546
|
+
}
|
|
547
|
+
// For ESM, exports are added via 'export' keyword in the generated code
|
|
548
|
+
lines.push('');
|
|
549
|
+
return lines.join('\n');
|
|
550
|
+
}
|
|
551
|
+
//# sourceMappingURL=inline-runtime.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection operations for workflow manipulation
|
|
3
|
+
*/
|
|
4
|
+
import type { TWorkflowAST, TConnectionAST, TPortReference } from "../../ast/types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Add a connection between two ports
|
|
7
|
+
*
|
|
8
|
+
* @param ast - Workflow to modify
|
|
9
|
+
* @param from - Source port reference (string "node.port" or object)
|
|
10
|
+
* @param to - Target port reference (string "node.port" or object)
|
|
11
|
+
* @returns Modified workflow
|
|
12
|
+
* @throws {Error} If connection already exists
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Using string format
|
|
17
|
+
* const ast = addConnection(workflow, 'Start.input', 'processor.input');
|
|
18
|
+
*
|
|
19
|
+
* // Using object format
|
|
20
|
+
* const ast = addConnection(
|
|
21
|
+
* workflow,
|
|
22
|
+
* { node: 'Start', port: 'input' },
|
|
23
|
+
* { node: 'processor', port: 'input' }
|
|
24
|
+
* );
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function addConnection(ast: TWorkflowAST, from: string | TPortReference, to: string | TPortReference): TWorkflowAST;
|
|
28
|
+
/**
|
|
29
|
+
* Remove a connection.
|
|
30
|
+
* Uses no validation to allow deletion even when workflow has other errors.
|
|
31
|
+
*
|
|
32
|
+
* @param ast - Workflow to modify
|
|
33
|
+
* @param from - Source port reference
|
|
34
|
+
* @param to - Target port reference
|
|
35
|
+
* @returns Modified workflow
|
|
36
|
+
* @throws {Error} If connection doesn't exist
|
|
37
|
+
*/
|
|
38
|
+
export declare function removeConnection(ast: TWorkflowAST, from: string | TPortReference, to: string | TPortReference): TWorkflowAST;
|
|
39
|
+
/**
|
|
40
|
+
* Remove all connections for a node (or specific port).
|
|
41
|
+
* Uses no validation to allow deletion even when workflow has other errors.
|
|
42
|
+
*
|
|
43
|
+
* @param ast - Workflow to modify
|
|
44
|
+
* @param nodeId - Node ID
|
|
45
|
+
* @param portName - Optional port name to filter
|
|
46
|
+
* @returns Modified workflow
|
|
47
|
+
*/
|
|
48
|
+
export declare function removeAllConnections(ast: TWorkflowAST, nodeId: string, portName?: string): TWorkflowAST;
|
|
49
|
+
/**
|
|
50
|
+
* Reconnect (change target of existing connection).
|
|
51
|
+
* Uses no validation to allow reconnecting even when workflow has other errors.
|
|
52
|
+
*
|
|
53
|
+
* @param ast - Workflow to modify
|
|
54
|
+
* @param from - Source port reference (identifies connection)
|
|
55
|
+
* @param oldTo - Old target port reference
|
|
56
|
+
* @param newTo - New target port reference
|
|
57
|
+
* @returns Modified workflow
|
|
58
|
+
*/
|
|
59
|
+
export declare function reconnect(ast: TWorkflowAST, from: string | TPortReference, oldTo: string | TPortReference, newTo: string | TPortReference): TWorkflowAST;
|
|
60
|
+
/**
|
|
61
|
+
* Add multiple connections at once.
|
|
62
|
+
* Uses no validation to allow adding even when workflow has other errors.
|
|
63
|
+
*
|
|
64
|
+
* @param ast - Workflow to modify
|
|
65
|
+
* @param connections - Array of connections to add
|
|
66
|
+
* @returns Modified workflow
|
|
67
|
+
*/
|
|
68
|
+
export declare function addConnections(ast: TWorkflowAST, connections: TConnectionAST[]): TWorkflowAST;
|
|
69
|
+
/**
|
|
70
|
+
* Replace all connections for a node.
|
|
71
|
+
* Uses no validation to allow replacing even when workflow has other errors.
|
|
72
|
+
*
|
|
73
|
+
* @param ast - Workflow to modify
|
|
74
|
+
* @param nodeId - Node ID
|
|
75
|
+
* @param connections - New connections
|
|
76
|
+
* @returns Modified workflow
|
|
77
|
+
*/
|
|
78
|
+
export declare function replaceConnections(ast: TWorkflowAST, nodeId: string, connections: TConnectionAST[]): TWorkflowAST;
|
|
79
|
+
//# sourceMappingURL=connections.d.ts.map
|