@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,185 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/**
|
|
3
|
+
* CLI pattern commands
|
|
4
|
+
* - list: Find patterns in files/directories
|
|
5
|
+
* - apply: Merge pattern into workflow
|
|
6
|
+
* - extract: Create pattern from workflow nodes
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
import { glob } from 'glob';
|
|
11
|
+
import { AnnotationParser } from '../../parser.js';
|
|
12
|
+
import { logger } from '../utils/logger.js';
|
|
13
|
+
import { listPatterns, applyPattern, extractPattern } from '../../api/patterns.js';
|
|
14
|
+
const parser = new AnnotationParser();
|
|
15
|
+
/**
|
|
16
|
+
* Find patterns in a file or directory
|
|
17
|
+
*/
|
|
18
|
+
export async function patternListCommand(inputPath, options) {
|
|
19
|
+
if (!fs.existsSync(inputPath)) {
|
|
20
|
+
throw new Error(`Path not found: ${inputPath}`);
|
|
21
|
+
}
|
|
22
|
+
const stat = fs.statSync(inputPath);
|
|
23
|
+
let files;
|
|
24
|
+
if (stat.isDirectory()) {
|
|
25
|
+
files = await glob('**/*.ts', { cwd: inputPath, absolute: true });
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
files = [inputPath];
|
|
29
|
+
}
|
|
30
|
+
const allPatterns = [];
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
try {
|
|
33
|
+
const patterns = listPatterns(file);
|
|
34
|
+
if (patterns.length > 0) {
|
|
35
|
+
allPatterns.push({ file, patterns });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Skip files that fail to parse
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const flat = allPatterns.flatMap(({ file, patterns }) => patterns.map((p) => ({ file, ...p })));
|
|
43
|
+
if (flat.length === 0) {
|
|
44
|
+
if (options.json) {
|
|
45
|
+
console.log(JSON.stringify([]));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
logger.info('No patterns found');
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (options.json) {
|
|
53
|
+
console.log(JSON.stringify(flat, null, 2));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// Human-readable output
|
|
57
|
+
for (const { file, name, description, inputPorts, outputPorts, nodes } of flat) {
|
|
58
|
+
logger.section(name);
|
|
59
|
+
if (description) {
|
|
60
|
+
logger.info(description);
|
|
61
|
+
}
|
|
62
|
+
logger.info(`File: ${path.relative(process.cwd(), file)}`);
|
|
63
|
+
if (inputPorts.length > 0) {
|
|
64
|
+
logger.info('Input ports:');
|
|
65
|
+
for (const port of inputPorts) {
|
|
66
|
+
logger.log(` ${port.name}${port.description ? ` - ${port.description}` : ''}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (outputPorts.length > 0) {
|
|
70
|
+
logger.info('Output ports:');
|
|
71
|
+
for (const port of outputPorts) {
|
|
72
|
+
logger.log(` ${port.name}${port.description ? ` - ${port.description}` : ''}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (nodes.length > 0) {
|
|
76
|
+
logger.info(`Nodes: ${nodes.join(', ')}`);
|
|
77
|
+
}
|
|
78
|
+
logger.newline();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Apply a pattern to a workflow file
|
|
83
|
+
*/
|
|
84
|
+
export async function patternApplyCommand(patternFile, targetFile, options) {
|
|
85
|
+
// Parse pattern file
|
|
86
|
+
const patternResult = parser.parse(patternFile);
|
|
87
|
+
if (patternResult.patterns.length === 0) {
|
|
88
|
+
throw new Error(`No patterns found in ${patternFile}`);
|
|
89
|
+
}
|
|
90
|
+
// Select pattern (by name if specified, otherwise first)
|
|
91
|
+
let pattern;
|
|
92
|
+
if (options.name) {
|
|
93
|
+
const found = patternResult.patterns.find((p) => p.name === options.name);
|
|
94
|
+
if (!found) {
|
|
95
|
+
throw new Error(`Pattern "${options.name}" not found in ${patternFile}`);
|
|
96
|
+
}
|
|
97
|
+
pattern = found;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
pattern = patternResult.patterns[0];
|
|
101
|
+
}
|
|
102
|
+
// Parse target to detect existing node types
|
|
103
|
+
const targetContent = fs.readFileSync(targetFile, 'utf8');
|
|
104
|
+
const targetResult = parser.parse(targetFile);
|
|
105
|
+
const existingNodeTypes = new Set(targetResult.nodeTypes.map((nt) => nt.name));
|
|
106
|
+
// Apply pattern via API
|
|
107
|
+
const result = applyPattern({
|
|
108
|
+
patternAST: pattern,
|
|
109
|
+
targetContent,
|
|
110
|
+
targetNodeTypes: existingNodeTypes,
|
|
111
|
+
prefix: options.prefix,
|
|
112
|
+
});
|
|
113
|
+
if (result.conflicts.length > 0) {
|
|
114
|
+
console.log(`\u26A0\uFE0F Node type conflict detected: ${result.conflicts.join(', ')}`);
|
|
115
|
+
console.log(' Existing node types will be preserved. Consider using --prefix to avoid conflicts.');
|
|
116
|
+
}
|
|
117
|
+
if (options.preview) {
|
|
118
|
+
console.log(result.modifiedContent);
|
|
119
|
+
logger.newline();
|
|
120
|
+
logger.section('Manual wiring required');
|
|
121
|
+
for (const instruction of result.wiringInstructions) {
|
|
122
|
+
logger.log(` ${instruction}`);
|
|
123
|
+
}
|
|
124
|
+
logger.info('Input ports:');
|
|
125
|
+
for (const name of Object.keys(pattern.inputPorts)) {
|
|
126
|
+
logger.log(` IN.${name}`);
|
|
127
|
+
}
|
|
128
|
+
logger.info('Output ports:');
|
|
129
|
+
for (const name of Object.keys(pattern.outputPorts)) {
|
|
130
|
+
logger.log(` OUT.${name}`);
|
|
131
|
+
}
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// Write modified content
|
|
135
|
+
fs.writeFileSync(targetFile, result.modifiedContent);
|
|
136
|
+
logger.success(`Applied pattern "${pattern.name}" to ${targetFile}`);
|
|
137
|
+
if (result.nodeTypesAdded.length > 0) {
|
|
138
|
+
logger.info(`Added node types: ${result.nodeTypesAdded.join(', ')}`);
|
|
139
|
+
}
|
|
140
|
+
const nodePrefix = options.prefix ? `${options.prefix}_` : '';
|
|
141
|
+
logger.info(`Added nodes: ${pattern.instances.map((i) => `${nodePrefix}${i.id}`).join(', ')}`);
|
|
142
|
+
logger.newline();
|
|
143
|
+
logger.section('Wire these ports manually');
|
|
144
|
+
for (const instruction of result.wiringInstructions) {
|
|
145
|
+
logger.log(` ${instruction}`);
|
|
146
|
+
}
|
|
147
|
+
logger.info('Input ports:');
|
|
148
|
+
for (const name of Object.keys(pattern.inputPorts)) {
|
|
149
|
+
logger.log(` IN.${name}`);
|
|
150
|
+
}
|
|
151
|
+
logger.info('Output ports:');
|
|
152
|
+
for (const name of Object.keys(pattern.outputPorts)) {
|
|
153
|
+
logger.log(` OUT.${name}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Extract a pattern from workflow nodes
|
|
158
|
+
*/
|
|
159
|
+
export async function patternExtractCommand(sourceFile, options) {
|
|
160
|
+
// Parse source file
|
|
161
|
+
const parseResult = parser.parse(sourceFile);
|
|
162
|
+
if (parseResult.workflows.length === 0) {
|
|
163
|
+
throw new Error(`No workflows found in ${sourceFile}`);
|
|
164
|
+
}
|
|
165
|
+
const workflow = parseResult.workflows[0];
|
|
166
|
+
const nodeIds = options.nodes.split(',').map((s) => s.trim());
|
|
167
|
+
// Extract pattern via API
|
|
168
|
+
const result = extractPattern({
|
|
169
|
+
workflowAST: workflow,
|
|
170
|
+
nodeTypes: parseResult.nodeTypes,
|
|
171
|
+
nodeIds,
|
|
172
|
+
name: options.name,
|
|
173
|
+
});
|
|
174
|
+
if (options.preview) {
|
|
175
|
+
console.log(result.patternCode);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
// Write to output file
|
|
179
|
+
fs.writeFileSync(options.output, result.patternCode);
|
|
180
|
+
logger.success(`Extracted pattern "${result.patternName}" to ${options.output}`);
|
|
181
|
+
logger.info(`Included nodes: ${result.nodes.join(', ')}`);
|
|
182
|
+
logger.info(`Input ports: ${result.inputPorts.join(', ') || 'none'}`);
|
|
183
|
+
logger.info(`Output ports: ${result.outputPorts.join(', ') || 'none'}`);
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=pattern.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin command — scaffolds a new external plugin directory
|
|
3
|
+
*/
|
|
4
|
+
export interface PluginInitOptions {
|
|
5
|
+
area?: string;
|
|
6
|
+
system?: boolean;
|
|
7
|
+
preview?: boolean;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function validatePluginName(name: string): string | true;
|
|
11
|
+
export declare function generatePluginFiles(pluginName: string, options: {
|
|
12
|
+
area: string;
|
|
13
|
+
system: boolean;
|
|
14
|
+
}): Record<string, string>;
|
|
15
|
+
export declare function pluginInitCommand(name: string, options: PluginInitOptions): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/**
|
|
3
|
+
* Plugin command — scaffolds a new external plugin directory
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { logger } from '../utils/logger.js';
|
|
8
|
+
// ── Validation ───────────────────────────────────────────────────────────────
|
|
9
|
+
const PLUGIN_NAME_RE = /^[a-zA-Z0-9][-a-zA-Z0-9_.]*$/;
|
|
10
|
+
const VALID_AREAS = ['sidebar', 'main', 'toolbar', 'modal', 'panel'];
|
|
11
|
+
export function validatePluginName(name) {
|
|
12
|
+
if (!name)
|
|
13
|
+
return 'Plugin name cannot be empty';
|
|
14
|
+
if (name.length > 100)
|
|
15
|
+
return 'Plugin name must be at most 100 characters';
|
|
16
|
+
if (!PLUGIN_NAME_RE.test(name)) {
|
|
17
|
+
return 'Plugin name must start with a letter or digit and contain only letters, digits, hyphens, dots, and underscores';
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
// ── File generation ──────────────────────────────────────────────────────────
|
|
22
|
+
function toPascalCase(name) {
|
|
23
|
+
return name
|
|
24
|
+
.split(/[-_.]/)
|
|
25
|
+
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
|
26
|
+
.join('');
|
|
27
|
+
}
|
|
28
|
+
export function generatePluginFiles(pluginName, options) {
|
|
29
|
+
const componentName = toPascalCase(pluginName) + 'Panel';
|
|
30
|
+
const pluginArtifact = [
|
|
31
|
+
`name: ${pluginName}`,
|
|
32
|
+
'version: 1.0.0',
|
|
33
|
+
`description: ${pluginName} plugin`,
|
|
34
|
+
'entry:',
|
|
35
|
+
' client: ./client/index.tsx',
|
|
36
|
+
...(options.system ? [' system: ./system/index.ts'] : []),
|
|
37
|
+
'capabilities: {}',
|
|
38
|
+
'',
|
|
39
|
+
].join('\n');
|
|
40
|
+
const clientIndex = [
|
|
41
|
+
"import { PluginPanel, createPlugin } from '@synergenius/flow-weaver/plugin';",
|
|
42
|
+
"import type { TPluginComponentProps, TPluginComponentApi } from '@synergenius/flow-weaver/plugin';",
|
|
43
|
+
"import React from 'react';",
|
|
44
|
+
'',
|
|
45
|
+
`const PLUGIN_NAME = '${pluginName}';`,
|
|
46
|
+
'',
|
|
47
|
+
...(options.system
|
|
48
|
+
? [
|
|
49
|
+
`const fetchData = async (api: TPluginComponentApi) =>`,
|
|
50
|
+
` api.call(PLUGIN_NAME, 'getData', undefined);`,
|
|
51
|
+
'',
|
|
52
|
+
]
|
|
53
|
+
: []),
|
|
54
|
+
`const ${componentName} = (props: TPluginComponentProps) => {`,
|
|
55
|
+
' return (',
|
|
56
|
+
' <PluginPanel {...props}>',
|
|
57
|
+
` <div style={{ padding: 16 }}>`,
|
|
58
|
+
` <h3>${pluginName}</h3>`,
|
|
59
|
+
...(options.system
|
|
60
|
+
? [
|
|
61
|
+
' <button',
|
|
62
|
+
' onClick={async () => {',
|
|
63
|
+
' const result = await fetchData(props.api);',
|
|
64
|
+
' console.log(result);',
|
|
65
|
+
' }}',
|
|
66
|
+
' >',
|
|
67
|
+
' Fetch Data',
|
|
68
|
+
' </button>',
|
|
69
|
+
]
|
|
70
|
+
: [' <p>Plugin loaded.</p>']),
|
|
71
|
+
' </div>',
|
|
72
|
+
' </PluginPanel>',
|
|
73
|
+
' );',
|
|
74
|
+
'};',
|
|
75
|
+
'',
|
|
76
|
+
'export default createPlugin(() => ({',
|
|
77
|
+
' async initialize() {},',
|
|
78
|
+
' ui: {',
|
|
79
|
+
' components: {',
|
|
80
|
+
` ${componentName},`,
|
|
81
|
+
' },',
|
|
82
|
+
' config: {',
|
|
83
|
+
` ${componentName}: {`,
|
|
84
|
+
` name: '${componentName}',`,
|
|
85
|
+
` displayName: '${pluginName}',`,
|
|
86
|
+
` area: '${options.area}',`,
|
|
87
|
+
` description: '${pluginName} plugin panel',`,
|
|
88
|
+
' },',
|
|
89
|
+
' },',
|
|
90
|
+
' },',
|
|
91
|
+
'}));',
|
|
92
|
+
'',
|
|
93
|
+
].join('\n');
|
|
94
|
+
const files = {
|
|
95
|
+
'plugin-artifact.yaml': pluginArtifact,
|
|
96
|
+
'client/index.tsx': clientIndex,
|
|
97
|
+
};
|
|
98
|
+
if (options.system) {
|
|
99
|
+
const systemIndex = [
|
|
100
|
+
"import type { TPluginSystemModule } from '@synergenius/flow-weaver/plugin';",
|
|
101
|
+
'',
|
|
102
|
+
'const plugin: TPluginSystemModule = {',
|
|
103
|
+
' async initialize() {',
|
|
104
|
+
' // Plugin system module initialized',
|
|
105
|
+
' },',
|
|
106
|
+
' methods: {',
|
|
107
|
+
' async getData() {',
|
|
108
|
+
` return { message: 'Hello from ${pluginName}!' };`,
|
|
109
|
+
' },',
|
|
110
|
+
' },',
|
|
111
|
+
' async cleanup() {',
|
|
112
|
+
' // Plugin cleanup',
|
|
113
|
+
' },',
|
|
114
|
+
'};',
|
|
115
|
+
'',
|
|
116
|
+
'export default plugin;',
|
|
117
|
+
'',
|
|
118
|
+
].join('\n');
|
|
119
|
+
files['system/index.ts'] = systemIndex;
|
|
120
|
+
}
|
|
121
|
+
return files;
|
|
122
|
+
}
|
|
123
|
+
// ── CLI entrypoint ───────────────────────────────────────────────────────────
|
|
124
|
+
export async function pluginInitCommand(name, options) {
|
|
125
|
+
const area = options.area ?? 'panel';
|
|
126
|
+
const includeSystem = options.system !== false;
|
|
127
|
+
const preview = options.preview ?? false;
|
|
128
|
+
const force = options.force ?? false;
|
|
129
|
+
// Validate plugin name
|
|
130
|
+
const valid = validatePluginName(name);
|
|
131
|
+
if (valid !== true) {
|
|
132
|
+
throw new Error(valid);
|
|
133
|
+
}
|
|
134
|
+
// Validate area
|
|
135
|
+
if (!VALID_AREAS.includes(area)) {
|
|
136
|
+
throw new Error(`Invalid area "${area}". Available: ${VALID_AREAS.join(', ')}`);
|
|
137
|
+
}
|
|
138
|
+
const files = generatePluginFiles(name, { area, system: includeSystem });
|
|
139
|
+
if (preview) {
|
|
140
|
+
logger.section('Preview');
|
|
141
|
+
for (const [relativePath, content] of Object.entries(files)) {
|
|
142
|
+
logger.log(`\n── ${relativePath} ──`);
|
|
143
|
+
logger.log(content);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Write files under plugins/<name>/
|
|
148
|
+
const targetDir = path.resolve('plugins', name);
|
|
149
|
+
const filesCreated = [];
|
|
150
|
+
const filesSkipped = [];
|
|
151
|
+
for (const [relativePath, content] of Object.entries(files)) {
|
|
152
|
+
const absPath = path.join(targetDir, relativePath);
|
|
153
|
+
const dir = path.dirname(absPath);
|
|
154
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
155
|
+
if (fs.existsSync(absPath) && !force) {
|
|
156
|
+
filesSkipped.push(relativePath);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
fs.writeFileSync(absPath, content, 'utf8');
|
|
160
|
+
filesCreated.push(relativePath);
|
|
161
|
+
}
|
|
162
|
+
// Output
|
|
163
|
+
logger.section('Plugin scaffolded');
|
|
164
|
+
for (const file of filesCreated) {
|
|
165
|
+
logger.success(`Created plugins/${name}/${file}`);
|
|
166
|
+
}
|
|
167
|
+
for (const file of filesSkipped) {
|
|
168
|
+
logger.warn(`Skipped plugins/${name}/${file} (already exists)`);
|
|
169
|
+
}
|
|
170
|
+
logger.newline();
|
|
171
|
+
logger.section('Next steps');
|
|
172
|
+
logger.log(` Ensure your .flowweaver/config.yaml has: pluginsDir: plugins`);
|
|
173
|
+
logger.log(` Then restart the editor to load the plugin.`);
|
|
174
|
+
logger.newline();
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run command - execute a workflow file directly from the CLI
|
|
3
|
+
*/
|
|
4
|
+
export interface RunOptions {
|
|
5
|
+
/** Specific workflow name to run (if file contains multiple workflows) */
|
|
6
|
+
workflow?: string;
|
|
7
|
+
/** Input parameters as JSON string */
|
|
8
|
+
params?: string;
|
|
9
|
+
/** Path to JSON file containing input parameters */
|
|
10
|
+
paramsFile?: string;
|
|
11
|
+
/** Run in production mode (no trace events) */
|
|
12
|
+
production?: boolean;
|
|
13
|
+
/** Include execution trace events */
|
|
14
|
+
trace?: boolean;
|
|
15
|
+
/** Output result as JSON (for scripting) */
|
|
16
|
+
json?: boolean;
|
|
17
|
+
/** Execution timeout in milliseconds */
|
|
18
|
+
timeout?: number;
|
|
19
|
+
/** Mock config for built-in nodes as inline JSON string */
|
|
20
|
+
mocks?: string;
|
|
21
|
+
/** Path to JSON file containing mock config for built-in nodes */
|
|
22
|
+
mocksFile?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Execute a workflow file and output the result.
|
|
26
|
+
*
|
|
27
|
+
* @param input - Path to the workflow file
|
|
28
|
+
* @param options - Execution options
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```bash
|
|
32
|
+
* # Basic execution
|
|
33
|
+
* flow-weaver run workflow.ts
|
|
34
|
+
*
|
|
35
|
+
* # With parameters
|
|
36
|
+
* flow-weaver run workflow.ts --params '{"a": 5, "b": 3}'
|
|
37
|
+
*
|
|
38
|
+
* # From params file
|
|
39
|
+
* flow-weaver run workflow.ts --params-file params.json
|
|
40
|
+
*
|
|
41
|
+
* # Specific workflow in multi-workflow file
|
|
42
|
+
* flow-weaver run workflow.ts --workflow calculate
|
|
43
|
+
*
|
|
44
|
+
* # JSON output for scripting
|
|
45
|
+
* flow-weaver run workflow.ts --json | jq '.result'
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function runCommand(input: string, options: RunOptions): Promise<void>;
|
|
49
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run command - execute a workflow file directly from the CLI
|
|
3
|
+
*/
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import { executeWorkflowFromFile } from '../../mcp/workflow-executor.js';
|
|
7
|
+
import { logger } from '../utils/logger.js';
|
|
8
|
+
import { getFriendlyError } from '../../friendly-errors.js';
|
|
9
|
+
import { getErrorMessage } from '../../utils/error-utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Execute a workflow file and output the result.
|
|
12
|
+
*
|
|
13
|
+
* @param input - Path to the workflow file
|
|
14
|
+
* @param options - Execution options
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```bash
|
|
18
|
+
* # Basic execution
|
|
19
|
+
* flow-weaver run workflow.ts
|
|
20
|
+
*
|
|
21
|
+
* # With parameters
|
|
22
|
+
* flow-weaver run workflow.ts --params '{"a": 5, "b": 3}'
|
|
23
|
+
*
|
|
24
|
+
* # From params file
|
|
25
|
+
* flow-weaver run workflow.ts --params-file params.json
|
|
26
|
+
*
|
|
27
|
+
* # Specific workflow in multi-workflow file
|
|
28
|
+
* flow-weaver run workflow.ts --workflow calculate
|
|
29
|
+
*
|
|
30
|
+
* # JSON output for scripting
|
|
31
|
+
* flow-weaver run workflow.ts --json | jq '.result'
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export async function runCommand(input, options) {
|
|
35
|
+
const filePath = path.resolve(input);
|
|
36
|
+
// Validate file exists
|
|
37
|
+
if (!fs.existsSync(filePath)) {
|
|
38
|
+
throw new Error(`File not found: ${filePath}`);
|
|
39
|
+
}
|
|
40
|
+
// Parse params from --params or --params-file
|
|
41
|
+
let params = {};
|
|
42
|
+
if (options.params) {
|
|
43
|
+
try {
|
|
44
|
+
params = JSON.parse(options.params);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new Error(`Invalid JSON in --params: ${options.params}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (options.paramsFile) {
|
|
51
|
+
const paramsFilePath = path.resolve(options.paramsFile);
|
|
52
|
+
if (!fs.existsSync(paramsFilePath)) {
|
|
53
|
+
throw new Error(`Params file not found: ${paramsFilePath}`);
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const content = fs.readFileSync(paramsFilePath, 'utf8');
|
|
57
|
+
params = JSON.parse(content);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw new Error(`Failed to parse params file: ${options.paramsFile}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Parse mocks from --mocks or --mocks-file
|
|
64
|
+
let mocks;
|
|
65
|
+
if (options.mocks) {
|
|
66
|
+
try {
|
|
67
|
+
mocks = JSON.parse(options.mocks);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new Error(`Invalid JSON in --mocks: ${options.mocks}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (options.mocksFile) {
|
|
74
|
+
const mocksFilePath = path.resolve(options.mocksFile);
|
|
75
|
+
if (!fs.existsSync(mocksFilePath)) {
|
|
76
|
+
throw new Error(`Mocks file not found: ${mocksFilePath}`);
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const content = fs.readFileSync(mocksFilePath, 'utf8');
|
|
80
|
+
mocks = JSON.parse(content);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new Error(`Failed to parse mocks file: ${options.mocksFile}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Set up timeout if specified
|
|
87
|
+
let timeoutId;
|
|
88
|
+
let timedOut = false;
|
|
89
|
+
if (options.timeout) {
|
|
90
|
+
timeoutId = setTimeout(() => {
|
|
91
|
+
timedOut = true;
|
|
92
|
+
if (!options.json) {
|
|
93
|
+
logger.error(`Execution timed out after ${options.timeout}ms`);
|
|
94
|
+
}
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}, options.timeout);
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
// Determine trace inclusion:
|
|
100
|
+
// - If --production is set, no trace (unless --trace explicitly set)
|
|
101
|
+
// - If --trace is set, include trace
|
|
102
|
+
// - Default: include trace in dev mode
|
|
103
|
+
const includeTrace = options.trace ?? !options.production;
|
|
104
|
+
if (!options.json && mocks) {
|
|
105
|
+
logger.info('Running with mock data');
|
|
106
|
+
}
|
|
107
|
+
const result = await executeWorkflowFromFile(filePath, params, {
|
|
108
|
+
workflowName: options.workflow,
|
|
109
|
+
production: options.production ?? false,
|
|
110
|
+
includeTrace,
|
|
111
|
+
mocks,
|
|
112
|
+
});
|
|
113
|
+
if (timedOut)
|
|
114
|
+
return; // Don't output if already timed out
|
|
115
|
+
if (options.json) {
|
|
116
|
+
// JSON output for scripting
|
|
117
|
+
process.stdout.write(JSON.stringify({
|
|
118
|
+
success: true,
|
|
119
|
+
workflow: result.functionName,
|
|
120
|
+
executionTime: result.executionTime,
|
|
121
|
+
result: result.result,
|
|
122
|
+
...(includeTrace && result.trace && { traceCount: result.trace.length }),
|
|
123
|
+
}, null, 2) + '\n');
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Human-readable output
|
|
127
|
+
logger.success(`Workflow "${result.functionName}" completed in ${result.executionTime}ms`);
|
|
128
|
+
logger.newline();
|
|
129
|
+
logger.section('Result');
|
|
130
|
+
logger.log(JSON.stringify(result.result, null, 2));
|
|
131
|
+
if (result.trace && result.trace.length > 0) {
|
|
132
|
+
logger.newline();
|
|
133
|
+
logger.section('Trace');
|
|
134
|
+
logger.log(`${result.trace.length} events captured`);
|
|
135
|
+
// Show first few trace events as summary
|
|
136
|
+
const preview = result.trace.slice(0, 5);
|
|
137
|
+
for (const event of preview) {
|
|
138
|
+
logger.log(` [${event.type}] ${event.data?.nodeId || ''}`);
|
|
139
|
+
}
|
|
140
|
+
if (result.trace.length > 5) {
|
|
141
|
+
logger.log(` ... and ${result.trace.length - 5} more events`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
const errorMsg = getErrorMessage(error);
|
|
148
|
+
// Try to extract validator error code from the error message for friendly formatting
|
|
149
|
+
// Common pattern: "Validation error [CODE]: message" or errors with a .code property
|
|
150
|
+
const errorObj = error;
|
|
151
|
+
if (errorObj.errors && Array.isArray(errorObj.errors)) {
|
|
152
|
+
// Structured validation errors (from compileWorkflow)
|
|
153
|
+
logger.error(`Workflow execution failed:`);
|
|
154
|
+
for (const err of errorObj.errors) {
|
|
155
|
+
const friendly = getFriendlyError(err);
|
|
156
|
+
if (friendly) {
|
|
157
|
+
logger.error(` ${friendly.title}: ${friendly.explanation}`);
|
|
158
|
+
logger.info(` How to fix: ${friendly.fix}`);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
logger.error(` - ${err.message}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else if (errorObj.code) {
|
|
166
|
+
const friendly = getFriendlyError({ code: errorObj.code, message: errorMsg });
|
|
167
|
+
if (friendly) {
|
|
168
|
+
logger.error(`${friendly.title}: ${friendly.explanation}`);
|
|
169
|
+
logger.info(` How to fix: ${friendly.fix}`);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
logger.error(`Workflow execution failed: ${errorMsg}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
logger.error(`Workflow execution failed: ${errorMsg}`);
|
|
177
|
+
}
|
|
178
|
+
if (!options.json) {
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
process.stdout.write(JSON.stringify({ success: false, error: errorMsg }, null, 2) + '\n');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
if (timeoutId) {
|
|
187
|
+
clearTimeout(timeoutId);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serve command - start HTTP server exposing workflows as endpoints
|
|
3
|
+
*/
|
|
4
|
+
export interface ServeOptions {
|
|
5
|
+
/** Server port */
|
|
6
|
+
port?: number;
|
|
7
|
+
/** Server host */
|
|
8
|
+
host?: string;
|
|
9
|
+
/** Enable file watching for hot reload */
|
|
10
|
+
watch?: boolean;
|
|
11
|
+
/** Production mode (no trace events) */
|
|
12
|
+
production?: boolean;
|
|
13
|
+
/** Precompile all workflows on startup */
|
|
14
|
+
precompile?: boolean;
|
|
15
|
+
/** CORS origin */
|
|
16
|
+
cors?: string;
|
|
17
|
+
/** Enable Swagger UI at /docs */
|
|
18
|
+
swagger?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Start a webhook server exposing workflows as HTTP endpoints.
|
|
22
|
+
*
|
|
23
|
+
* @param dir - Directory containing workflow files (defaults to current directory)
|
|
24
|
+
* @param options - Server options
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```bash
|
|
28
|
+
* # Start server with current directory
|
|
29
|
+
* flow-weaver serve
|
|
30
|
+
*
|
|
31
|
+
* # Specify workflow directory
|
|
32
|
+
* flow-weaver serve ./workflows
|
|
33
|
+
*
|
|
34
|
+
* # Custom port
|
|
35
|
+
* flow-weaver serve --port 8080
|
|
36
|
+
*
|
|
37
|
+
* # Production mode
|
|
38
|
+
* flow-weaver serve --production --precompile
|
|
39
|
+
*
|
|
40
|
+
* # Disable hot reload
|
|
41
|
+
* flow-weaver serve --no-watch
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function serveCommand(dir: string | undefined, options: ServeOptions): Promise<void>;
|
|
45
|
+
//# sourceMappingURL=serve.d.ts.map
|