@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,169 @@
|
|
|
1
|
+
import { getProviderCode } from '../providers/index.js';
|
|
2
|
+
import { aiConfigSchema } from './ai-agent.js';
|
|
3
|
+
import { LLM_SIMPLE_TYPES, LLM_MOCK_PROVIDER } from '../shared/llm-types.js';
|
|
4
|
+
export const aiChatTemplate = {
|
|
5
|
+
id: 'ai-chat',
|
|
6
|
+
name: 'Stateful Chat',
|
|
7
|
+
description: 'Conversational AI with memory management',
|
|
8
|
+
category: 'ai',
|
|
9
|
+
configSchema: aiConfigSchema,
|
|
10
|
+
generate: (opts) => {
|
|
11
|
+
const { workflowName, config } = opts;
|
|
12
|
+
const provider = config?.provider || 'mock';
|
|
13
|
+
const model = config?.model || '';
|
|
14
|
+
// Get provider-specific code or use mock
|
|
15
|
+
const providerCode = provider === 'mock'
|
|
16
|
+
? `
|
|
17
|
+
// Mock provider for testing - replace with real provider
|
|
18
|
+
${LLM_MOCK_PROVIDER}
|
|
19
|
+
`
|
|
20
|
+
: getProviderCode(provider, model);
|
|
21
|
+
return `
|
|
22
|
+
// ============================================================
|
|
23
|
+
// LLM TYPES - Provider-agnostic interface
|
|
24
|
+
// ============================================================
|
|
25
|
+
|
|
26
|
+
${LLM_SIMPLE_TYPES}
|
|
27
|
+
|
|
28
|
+
${providerCode}
|
|
29
|
+
|
|
30
|
+
// Conversation memory store
|
|
31
|
+
const conversations: Map<string, LLMMessage[]> = new Map();
|
|
32
|
+
|
|
33
|
+
const DEFAULT_SYSTEM_PROMPT = \`You are a helpful AI assistant.
|
|
34
|
+
Be concise but friendly. Remember context from earlier in the conversation.\`;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Manages conversation memory
|
|
38
|
+
*
|
|
39
|
+
* @flowWeaver nodeType
|
|
40
|
+
* @label Memory
|
|
41
|
+
* @input conversationId [order:1] - Conversation identifier
|
|
42
|
+
* @input newMessage [order:2] - Message to add
|
|
43
|
+
* @input [maxHistory=50] [order:3] - Max messages to retain
|
|
44
|
+
* @input execute [order:0] - Execute
|
|
45
|
+
* @output history [order:2] - Conversation history
|
|
46
|
+
* @output onSuccess [order:0] - On Success
|
|
47
|
+
* @output onFailure [order:1] - On Failure
|
|
48
|
+
*/
|
|
49
|
+
function memory(
|
|
50
|
+
execute: boolean,
|
|
51
|
+
conversationId: string,
|
|
52
|
+
newMessage?: LLMMessage,
|
|
53
|
+
maxHistory?: number
|
|
54
|
+
): {
|
|
55
|
+
onSuccess: boolean;
|
|
56
|
+
onFailure: boolean;
|
|
57
|
+
history: LLMMessage[];
|
|
58
|
+
} {
|
|
59
|
+
if (!execute) {
|
|
60
|
+
return { onSuccess: false, onFailure: false, history: [] };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!conversations.has(conversationId)) {
|
|
64
|
+
conversations.set(conversationId, []);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const history = conversations.get(conversationId)!;
|
|
68
|
+
|
|
69
|
+
if (newMessage) {
|
|
70
|
+
history.push(newMessage);
|
|
71
|
+
const max = maxHistory ?? 50;
|
|
72
|
+
while (history.length > max) {
|
|
73
|
+
history.shift();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { onSuccess: true, onFailure: false, history: [...history] };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Generates chat response
|
|
82
|
+
*
|
|
83
|
+
* @flowWeaver nodeType
|
|
84
|
+
* @label Chat
|
|
85
|
+
* @input history [order:1] - Conversation history
|
|
86
|
+
* @input [systemPrompt] [order:2] - System prompt
|
|
87
|
+
* @input execute [order:0] - Execute
|
|
88
|
+
* @output response [order:2] - Assistant response
|
|
89
|
+
* @output responseMessage [order:3] - Response as LLMMessage
|
|
90
|
+
* @output onSuccess [order:0] - On Success
|
|
91
|
+
* @output onFailure [order:1] - On Failure
|
|
92
|
+
*/
|
|
93
|
+
async function chat(
|
|
94
|
+
execute: boolean,
|
|
95
|
+
history: LLMMessage[],
|
|
96
|
+
systemPrompt?: string
|
|
97
|
+
): Promise<{
|
|
98
|
+
onSuccess: boolean;
|
|
99
|
+
onFailure: boolean;
|
|
100
|
+
response: string;
|
|
101
|
+
responseMessage: LLMMessage;
|
|
102
|
+
}> {
|
|
103
|
+
if (!execute) {
|
|
104
|
+
return {
|
|
105
|
+
onSuccess: false,
|
|
106
|
+
onFailure: false,
|
|
107
|
+
response: '',
|
|
108
|
+
responseMessage: { role: 'assistant', content: '' },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const response = await llmProvider.chat(history, {
|
|
113
|
+
systemPrompt: systemPrompt ?? DEFAULT_SYSTEM_PROMPT,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const content = response.content ?? '';
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
onSuccess: true,
|
|
120
|
+
onFailure: false,
|
|
121
|
+
response: content,
|
|
122
|
+
responseMessage: { role: 'assistant', content },
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Stateful chat with conversation memory
|
|
128
|
+
*
|
|
129
|
+
* @flowWeaver workflow
|
|
130
|
+
* @node mem memory
|
|
131
|
+
* @node respond chat
|
|
132
|
+
* @node saveMem memory
|
|
133
|
+
* @position Start -350 0
|
|
134
|
+
* @position mem -150 0
|
|
135
|
+
* @position respond 50 0
|
|
136
|
+
* @position saveMem 250 0
|
|
137
|
+
* @position Exit 450 0
|
|
138
|
+
* @connect Start.execute -> mem.execute
|
|
139
|
+
* @connect Start.conversationId -> mem.conversationId
|
|
140
|
+
* @connect Start.userMessage -> mem.newMessage
|
|
141
|
+
* @connect mem.history -> respond.history
|
|
142
|
+
* @connect mem.onSuccess -> respond.execute
|
|
143
|
+
* @connect Start.conversationId -> saveMem.conversationId
|
|
144
|
+
* @connect respond.responseMessage -> saveMem.newMessage
|
|
145
|
+
* @connect respond.onSuccess -> saveMem.execute
|
|
146
|
+
* @connect respond.response -> Exit.response
|
|
147
|
+
* @connect saveMem.onSuccess -> Exit.onSuccess
|
|
148
|
+
* @param execute [order:0] - Execute
|
|
149
|
+
* @param conversationId [order:1] - Unique conversation ID
|
|
150
|
+
* @param userMessage [order:2] - User's message
|
|
151
|
+
* @param systemPrompt [order:3] - System prompt (optional)
|
|
152
|
+
* @returns onSuccess [order:0] - On Success
|
|
153
|
+
* @returns onFailure [order:1] - On Failure
|
|
154
|
+
* @returns response [order:2] - Assistant's response
|
|
155
|
+
*/
|
|
156
|
+
export async function ${workflowName}(
|
|
157
|
+
execute: boolean,
|
|
158
|
+
params: { conversationId: string; userMessage: LLMMessage; systemPrompt?: string }
|
|
159
|
+
): Promise<{
|
|
160
|
+
onSuccess: boolean;
|
|
161
|
+
onFailure: boolean;
|
|
162
|
+
response: string;
|
|
163
|
+
}> {
|
|
164
|
+
throw new Error('Compile with: flow-weaver compile <file>');
|
|
165
|
+
}
|
|
166
|
+
`.trim();
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=ai-chat.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable AI Pipeline Template
|
|
3
|
+
* Sequential data processing pipeline with durability annotations for Inngest compilation.
|
|
4
|
+
* Each node maps to a checkpointed step — if step 3 fails, it retries from step 3, not from scratch.
|
|
5
|
+
*/
|
|
6
|
+
import type { WorkflowTemplate } from '../index.js';
|
|
7
|
+
export declare const aiPipelineDurableTemplate: WorkflowTemplate;
|
|
8
|
+
//# sourceMappingURL=ai-pipeline-durable.d.ts.map
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { getProviderCode } from '../providers/index.js';
|
|
2
|
+
import { aiConfigSchema } from './ai-agent.js';
|
|
3
|
+
import { LLM_CORE_TYPES, LLM_MOCK_PROVIDER } from '../shared/llm-types.js';
|
|
4
|
+
export const aiPipelineDurableTemplate = {
|
|
5
|
+
id: 'ai-pipeline-durable',
|
|
6
|
+
name: 'Durable AI Pipeline',
|
|
7
|
+
description: 'Sequential data pipeline with durability — fetch, extract, validate, save',
|
|
8
|
+
category: 'ai',
|
|
9
|
+
configSchema: aiConfigSchema,
|
|
10
|
+
generate: ({ workflowName, config }) => {
|
|
11
|
+
const provider = config?.provider || 'mock';
|
|
12
|
+
const model = config?.model || '';
|
|
13
|
+
const providerCode = provider === 'mock'
|
|
14
|
+
? `
|
|
15
|
+
/* ============================================================
|
|
16
|
+
* MOCK PROVIDER (REPLACE IN REAL USE)
|
|
17
|
+
* ============================================================ */
|
|
18
|
+
|
|
19
|
+
${LLM_MOCK_PROVIDER}
|
|
20
|
+
`
|
|
21
|
+
: getProviderCode(provider, model);
|
|
22
|
+
return `
|
|
23
|
+
// ============================================================
|
|
24
|
+
// Durable Data Pipeline
|
|
25
|
+
// ============================================================
|
|
26
|
+
//
|
|
27
|
+
// Each node becomes a checkpointed step when compiled to Inngest.
|
|
28
|
+
// If step 3 fails, it retries from step 3 — not from scratch.
|
|
29
|
+
//
|
|
30
|
+
// Compile: flow-weaver compile <file>
|
|
31
|
+
// Export: fw export --target inngest
|
|
32
|
+
//
|
|
33
|
+
// Flow: fetchData → extract (LLM) → validate → save
|
|
34
|
+
// ↓ onFailure
|
|
35
|
+
// Exit.onFailure
|
|
36
|
+
|
|
37
|
+
/* ============================================================
|
|
38
|
+
* CORE TYPES
|
|
39
|
+
* ============================================================ */
|
|
40
|
+
|
|
41
|
+
${LLM_CORE_TYPES}
|
|
42
|
+
|
|
43
|
+
/* ============================================================
|
|
44
|
+
* STORAGE (mock — replace with real database/API)
|
|
45
|
+
* ============================================================ */
|
|
46
|
+
|
|
47
|
+
interface ExtractedRecord {
|
|
48
|
+
title: string;
|
|
49
|
+
summary: string;
|
|
50
|
+
entities: string[];
|
|
51
|
+
confidence: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const mockStore: Map<string, ExtractedRecord> = new Map();
|
|
55
|
+
|
|
56
|
+
${providerCode}
|
|
57
|
+
|
|
58
|
+
/* ============================================================
|
|
59
|
+
* NODES
|
|
60
|
+
* ============================================================ */
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Fetch raw data from a URL
|
|
64
|
+
*
|
|
65
|
+
* @flowWeaver nodeType
|
|
66
|
+
* @label Fetch Data
|
|
67
|
+
* @color blue
|
|
68
|
+
* @icon download
|
|
69
|
+
* @input execute [order:0] - Execute
|
|
70
|
+
* @input url [order:1] - URL to fetch data from
|
|
71
|
+
* @output onSuccess [order:0] - On Success
|
|
72
|
+
* @output onFailure [order:1] - On Failure
|
|
73
|
+
* @output data [order:2] - Raw fetched data
|
|
74
|
+
* @output contentType [order:3] - Response content type
|
|
75
|
+
*/
|
|
76
|
+
async function fetchData(
|
|
77
|
+
execute: boolean,
|
|
78
|
+
url: string
|
|
79
|
+
): Promise<{
|
|
80
|
+
onSuccess: boolean;
|
|
81
|
+
onFailure: boolean;
|
|
82
|
+
data: string;
|
|
83
|
+
contentType: string;
|
|
84
|
+
}> {
|
|
85
|
+
if (!execute) {
|
|
86
|
+
return { onSuccess: false, onFailure: false, data: '', contentType: '' };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
// Mock fetch — replace with real HTTP call
|
|
91
|
+
// const response = await fetch(url);
|
|
92
|
+
// const data = await response.text();
|
|
93
|
+
// return { onSuccess: true, onFailure: false, data, contentType: response.headers.get('content-type') || '' };
|
|
94
|
+
|
|
95
|
+
console.log('[Mock Fetch]', url);
|
|
96
|
+
const mockData = JSON.stringify({
|
|
97
|
+
title: 'Sample Article',
|
|
98
|
+
body: 'This article discusses the benefits of compiled workflows for AI agent reliability and testing.',
|
|
99
|
+
author: 'Jane Doe',
|
|
100
|
+
date: '2026-02-18',
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return { onSuccess: true, onFailure: false, data: mockData, contentType: 'application/json' };
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error('Fetch failed:', error);
|
|
106
|
+
return { onSuccess: false, onFailure: true, data: '', contentType: '' };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Use LLM to extract structured information from raw data
|
|
112
|
+
*
|
|
113
|
+
* @flowWeaver nodeType
|
|
114
|
+
* @label Extract Info
|
|
115
|
+
* @color purple
|
|
116
|
+
* @icon psychology
|
|
117
|
+
* @input execute [order:0] - Execute
|
|
118
|
+
* @input rawData [order:1] - Raw data to extract from
|
|
119
|
+
* @output onSuccess [order:0] - On Success
|
|
120
|
+
* @output onFailure [order:1] - On Failure
|
|
121
|
+
* @output extracted [order:2] - Extracted structured record
|
|
122
|
+
*/
|
|
123
|
+
async function extractInfo(
|
|
124
|
+
execute: boolean,
|
|
125
|
+
rawData: string
|
|
126
|
+
): Promise<{
|
|
127
|
+
onSuccess: boolean;
|
|
128
|
+
onFailure: boolean;
|
|
129
|
+
extracted: ExtractedRecord | null;
|
|
130
|
+
}> {
|
|
131
|
+
if (!execute) {
|
|
132
|
+
return { onSuccess: false, onFailure: false, extracted: null };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
const prompt = \`Extract the following from this data:
|
|
137
|
+
- title: the main title
|
|
138
|
+
- summary: a one-sentence summary
|
|
139
|
+
- entities: list of named entities (people, organizations, topics)
|
|
140
|
+
- confidence: how confident you are in the extraction (0-1)
|
|
141
|
+
|
|
142
|
+
Respond with valid JSON only.
|
|
143
|
+
|
|
144
|
+
Data:
|
|
145
|
+
\${rawData}\`;
|
|
146
|
+
|
|
147
|
+
const response = await llmProvider.chat([{ role: 'user', content: prompt }]);
|
|
148
|
+
|
|
149
|
+
// Parse LLM response as JSON
|
|
150
|
+
const content = response.content || '{}';
|
|
151
|
+
|
|
152
|
+
// Try to extract JSON from response (handle markdown fences)
|
|
153
|
+
let jsonStr = content;
|
|
154
|
+
const fenceMatch = content.match(/\`\`\`(?:json)?\\s*([\\s\\S]*?)\`\`\`/);
|
|
155
|
+
if (fenceMatch) {
|
|
156
|
+
jsonStr = fenceMatch[1].trim();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Mock extraction for mock provider
|
|
160
|
+
let extracted: ExtractedRecord;
|
|
161
|
+
try {
|
|
162
|
+
extracted = JSON.parse(jsonStr);
|
|
163
|
+
} catch {
|
|
164
|
+
// Fallback for mock provider responses
|
|
165
|
+
extracted = {
|
|
166
|
+
title: 'Extracted Title',
|
|
167
|
+
summary: 'Extracted summary from raw data.',
|
|
168
|
+
entities: ['entity1', 'entity2'],
|
|
169
|
+
confidence: 0.85,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return { onSuccess: true, onFailure: false, extracted };
|
|
174
|
+
} catch {
|
|
175
|
+
return { onSuccess: false, onFailure: true, extracted: null };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Validate extracted data against expected schema
|
|
181
|
+
*
|
|
182
|
+
* @flowWeaver nodeType
|
|
183
|
+
* @label Validate
|
|
184
|
+
* @color yellow
|
|
185
|
+
* @icon check-circle
|
|
186
|
+
* @input execute [order:0] - Execute
|
|
187
|
+
* @input data [order:1] - Extracted record to validate
|
|
188
|
+
* @output onSuccess [order:0] - On Success (valid)
|
|
189
|
+
* @output onFailure [order:1] - On Failure (invalid)
|
|
190
|
+
* @output validated [order:2] - Validated record
|
|
191
|
+
* @output errors [order:3] - Validation error messages
|
|
192
|
+
*/
|
|
193
|
+
function validateResult(
|
|
194
|
+
execute: boolean,
|
|
195
|
+
data: ExtractedRecord | null
|
|
196
|
+
): {
|
|
197
|
+
onSuccess: boolean;
|
|
198
|
+
onFailure: boolean;
|
|
199
|
+
validated: ExtractedRecord | null;
|
|
200
|
+
errors: string[];
|
|
201
|
+
} {
|
|
202
|
+
if (!execute) {
|
|
203
|
+
return { onSuccess: false, onFailure: false, validated: null, errors: [] };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const errors: string[] = [];
|
|
207
|
+
|
|
208
|
+
if (!data) {
|
|
209
|
+
errors.push('No data to validate');
|
|
210
|
+
return { onSuccess: false, onFailure: true, validated: null, errors };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (!data.title || typeof data.title !== 'string') {
|
|
214
|
+
errors.push('Missing or invalid title');
|
|
215
|
+
}
|
|
216
|
+
if (!data.summary || typeof data.summary !== 'string') {
|
|
217
|
+
errors.push('Missing or invalid summary');
|
|
218
|
+
}
|
|
219
|
+
if (!Array.isArray(data.entities)) {
|
|
220
|
+
errors.push('Missing or invalid entities array');
|
|
221
|
+
}
|
|
222
|
+
if (typeof data.confidence !== 'number' || data.confidence < 0 || data.confidence > 1) {
|
|
223
|
+
errors.push('Confidence must be a number between 0 and 1');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (errors.length > 0) {
|
|
227
|
+
return { onSuccess: false, onFailure: true, validated: null, errors };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return { onSuccess: true, onFailure: false, validated: data, errors: [] };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Save validated record to storage
|
|
235
|
+
*
|
|
236
|
+
* @flowWeaver nodeType
|
|
237
|
+
* @label Save Result
|
|
238
|
+
* @color green
|
|
239
|
+
* @icon database
|
|
240
|
+
* @input execute [order:0] - Execute
|
|
241
|
+
* @input data [order:1] - Validated record to save
|
|
242
|
+
* @output onSuccess [order:0] - On Success
|
|
243
|
+
* @output onFailure [order:1] - On Failure
|
|
244
|
+
* @output id [order:2] - Saved record identifier
|
|
245
|
+
*/
|
|
246
|
+
async function saveResult(
|
|
247
|
+
execute: boolean,
|
|
248
|
+
data: ExtractedRecord
|
|
249
|
+
): Promise<{
|
|
250
|
+
onSuccess: boolean;
|
|
251
|
+
onFailure: boolean;
|
|
252
|
+
id: string;
|
|
253
|
+
}> {
|
|
254
|
+
if (!execute) {
|
|
255
|
+
return { onSuccess: false, onFailure: false, id: '' };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
// Mock save — replace with real database/API:
|
|
260
|
+
// await db.insert('records', data);
|
|
261
|
+
// return { onSuccess: true, onFailure: false, id: result.insertedId };
|
|
262
|
+
|
|
263
|
+
const id = 'rec_' + Date.now().toString(36);
|
|
264
|
+
mockStore.set(id, data);
|
|
265
|
+
console.log('[Mock Save] Stored record:', id);
|
|
266
|
+
|
|
267
|
+
return { onSuccess: true, onFailure: false, id };
|
|
268
|
+
} catch (error) {
|
|
269
|
+
console.error('Save failed:', error);
|
|
270
|
+
return { onSuccess: false, onFailure: true, id: '' };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/* ============================================================
|
|
275
|
+
* WORKFLOW
|
|
276
|
+
* ============================================================ */
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Durable Data Pipeline — sequential fetch, extract, validate, save.
|
|
280
|
+
* Each node becomes a checkpointed step when compiled to Inngest.
|
|
281
|
+
*
|
|
282
|
+
* @flowWeaver workflow
|
|
283
|
+
* @trigger event="pipeline/start"
|
|
284
|
+
* @retries 3
|
|
285
|
+
* @node fetch fetchData
|
|
286
|
+
* @node extract extractInfo
|
|
287
|
+
* @node validate validateResult
|
|
288
|
+
* @node save saveResult
|
|
289
|
+
* @position Start -500 0
|
|
290
|
+
* @position fetch -280 0
|
|
291
|
+
* @position extract -40 0
|
|
292
|
+
* @position validate 200 0
|
|
293
|
+
* @position save 440 0
|
|
294
|
+
* @position Exit 680 0
|
|
295
|
+
* @connect Start.execute -> fetch.execute
|
|
296
|
+
* @connect Start.url -> fetch.url
|
|
297
|
+
* @connect fetch.onSuccess -> extract.execute
|
|
298
|
+
* @connect fetch.data -> extract.rawData
|
|
299
|
+
* @connect extract.onSuccess -> validate.execute
|
|
300
|
+
* @connect extract.extracted -> validate.data
|
|
301
|
+
* @connect validate.onSuccess -> save.execute
|
|
302
|
+
* @connect validate.validated -> save.data
|
|
303
|
+
* @connect fetch.onFailure -> Exit.onFailure
|
|
304
|
+
* @connect extract.onFailure -> Exit.onFailure
|
|
305
|
+
* @connect validate.onFailure -> Exit.onFailure
|
|
306
|
+
* @connect save.onSuccess -> Exit.onSuccess
|
|
307
|
+
* @connect save.id -> Exit.id
|
|
308
|
+
* @connect validate.errors -> Exit.errors
|
|
309
|
+
* @param execute [order:0] - Execute
|
|
310
|
+
* @param url [order:1] - URL to fetch and process
|
|
311
|
+
* @returns onSuccess [order:0] - Pipeline completed successfully
|
|
312
|
+
* @returns onFailure [order:1] - Pipeline encountered an error
|
|
313
|
+
* @returns id [order:2] - Saved record identifier
|
|
314
|
+
* @returns errors [order:3] - Validation errors (if any)
|
|
315
|
+
*/
|
|
316
|
+
export async function ${workflowName}(
|
|
317
|
+
execute: boolean,
|
|
318
|
+
params: { url: string }
|
|
319
|
+
): Promise<{
|
|
320
|
+
onSuccess: boolean;
|
|
321
|
+
onFailure: boolean;
|
|
322
|
+
id: string;
|
|
323
|
+
errors: string[];
|
|
324
|
+
}> {
|
|
325
|
+
throw new Error('Compile with: flow-weaver compile <file>');
|
|
326
|
+
}
|
|
327
|
+
`.trim();
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
//# sourceMappingURL=ai-pipeline-durable.js.map
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { getProviderCode } from '../providers/index.js';
|
|
2
|
+
import { aiConfigSchema } from './ai-agent.js';
|
|
3
|
+
import { LLM_SIMPLE_TYPES, LLM_MOCK_PROVIDER } from '../shared/llm-types.js';
|
|
4
|
+
export const aiRagTemplate = {
|
|
5
|
+
id: 'ai-rag',
|
|
6
|
+
name: 'RAG Pipeline',
|
|
7
|
+
description: 'Retrieval-Augmented Generation for knowledge-based Q&A',
|
|
8
|
+
category: 'ai',
|
|
9
|
+
configSchema: aiConfigSchema,
|
|
10
|
+
generate: (opts) => {
|
|
11
|
+
const { workflowName, config } = opts;
|
|
12
|
+
const provider = config?.provider || 'mock';
|
|
13
|
+
const model = config?.model || '';
|
|
14
|
+
// Get provider-specific code or use mock
|
|
15
|
+
const providerCode = provider === 'mock'
|
|
16
|
+
? `
|
|
17
|
+
// Mock provider for testing - replace with real provider
|
|
18
|
+
${LLM_MOCK_PROVIDER}
|
|
19
|
+
`
|
|
20
|
+
: getProviderCode(provider, model);
|
|
21
|
+
return `
|
|
22
|
+
// ============================================================
|
|
23
|
+
// LLM TYPES - Provider-agnostic interface
|
|
24
|
+
// ============================================================
|
|
25
|
+
|
|
26
|
+
${LLM_SIMPLE_TYPES}
|
|
27
|
+
|
|
28
|
+
${providerCode}
|
|
29
|
+
|
|
30
|
+
// Document store (replace with vector DB like Pinecone, Weaviate, etc.)
|
|
31
|
+
interface Document {
|
|
32
|
+
id: string;
|
|
33
|
+
content: string;
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const documentStore: Document[] = [
|
|
38
|
+
// TODO: Add your documents or connect to vector database
|
|
39
|
+
{ id: '1', content: 'Flow Weaver is a visual programming tool.' },
|
|
40
|
+
{ id: '2', content: 'It uses typed ports for data flow.' },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves relevant documents for a query
|
|
45
|
+
*
|
|
46
|
+
* @flowWeaver nodeType
|
|
47
|
+
* @label Retrieve
|
|
48
|
+
* @input query [order:1] - Search query
|
|
49
|
+
* @input topK [order:2] - Number of results (default 3)
|
|
50
|
+
* @input execute [order:0] - Execute
|
|
51
|
+
* @output documents [order:2] - Retrieved documents
|
|
52
|
+
* @output context [order:3] - Combined document text
|
|
53
|
+
* @output onSuccess [order:0] - On Success
|
|
54
|
+
* @output onFailure [order:1] - On Failure
|
|
55
|
+
*/
|
|
56
|
+
async function retrieve(
|
|
57
|
+
execute: boolean,
|
|
58
|
+
query: string,
|
|
59
|
+
topK?: number
|
|
60
|
+
): Promise<{
|
|
61
|
+
onSuccess: boolean;
|
|
62
|
+
onFailure: boolean;
|
|
63
|
+
documents: Document[];
|
|
64
|
+
context: string;
|
|
65
|
+
}> {
|
|
66
|
+
if (!execute) {
|
|
67
|
+
return { onSuccess: false, onFailure: false, documents: [], context: '' };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const k = topK ?? 3;
|
|
71
|
+
|
|
72
|
+
// TODO: Replace with actual vector similarity search
|
|
73
|
+
// For now, simple keyword matching
|
|
74
|
+
const queryLower = query.toLowerCase();
|
|
75
|
+
const scored = documentStore
|
|
76
|
+
.map((doc) => ({
|
|
77
|
+
doc,
|
|
78
|
+
score: doc.content.toLowerCase().includes(queryLower) ? 1 : 0,
|
|
79
|
+
}))
|
|
80
|
+
.filter((s) => s.score > 0)
|
|
81
|
+
.slice(0, k)
|
|
82
|
+
.map((s) => s.doc);
|
|
83
|
+
|
|
84
|
+
const context = scored.map((d) => d.content).join('\\n\\n');
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
onSuccess: true,
|
|
88
|
+
onFailure: false,
|
|
89
|
+
documents: scored,
|
|
90
|
+
context,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Generates answer using retrieved context
|
|
96
|
+
*
|
|
97
|
+
* @flowWeaver nodeType
|
|
98
|
+
* @label Generate
|
|
99
|
+
* @input question [order:1] - User question
|
|
100
|
+
* @input context [order:2] - Retrieved context
|
|
101
|
+
* @input execute [order:0] - Execute
|
|
102
|
+
* @output answer [order:2] - Generated answer
|
|
103
|
+
* @output sourcesUsed [order:3] - Number of sources used
|
|
104
|
+
* @output onSuccess [order:0] - On Success
|
|
105
|
+
* @output onFailure [order:1] - On Failure
|
|
106
|
+
*/
|
|
107
|
+
async function generate(
|
|
108
|
+
execute: boolean,
|
|
109
|
+
question: string,
|
|
110
|
+
context: string
|
|
111
|
+
): Promise<{
|
|
112
|
+
onSuccess: boolean;
|
|
113
|
+
onFailure: boolean;
|
|
114
|
+
answer: string;
|
|
115
|
+
sourcesUsed: number;
|
|
116
|
+
}> {
|
|
117
|
+
if (!execute) {
|
|
118
|
+
return { onSuccess: false, onFailure: false, answer: '', sourcesUsed: 0 };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const prompt = \`Answer the question based on the following context.
|
|
122
|
+
If the context doesn't contain relevant information, say so.
|
|
123
|
+
|
|
124
|
+
Context:
|
|
125
|
+
\${context}
|
|
126
|
+
|
|
127
|
+
Question: \${question}
|
|
128
|
+
|
|
129
|
+
Answer:\`;
|
|
130
|
+
|
|
131
|
+
const response = await llmProvider.chat([{ role: 'user', content: prompt }]);
|
|
132
|
+
const sourcesUsed = context
|
|
133
|
+
.split('\\n\\n')
|
|
134
|
+
.filter((s) => s.trim()).length;
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
onSuccess: true,
|
|
138
|
+
onFailure: false,
|
|
139
|
+
answer: response.content ?? '',
|
|
140
|
+
sourcesUsed,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* RAG Pipeline for knowledge-based Q&A
|
|
146
|
+
*
|
|
147
|
+
* @flowWeaver workflow
|
|
148
|
+
* @node retriever retrieve
|
|
149
|
+
* @node generator generate
|
|
150
|
+
* @position Start -300 0
|
|
151
|
+
* @position retriever -50 0
|
|
152
|
+
* @position generator 200 0
|
|
153
|
+
* @position Exit 400 0
|
|
154
|
+
* @connect Start.execute -> retriever.execute
|
|
155
|
+
* @connect Start.question -> retriever.query
|
|
156
|
+
* @connect Start.topK -> retriever.topK
|
|
157
|
+
* @connect Start.question -> generator.question
|
|
158
|
+
* @connect retriever.context -> generator.context
|
|
159
|
+
* @connect retriever.onSuccess -> generator.execute
|
|
160
|
+
* @connect generator.answer -> Exit.answer
|
|
161
|
+
* @connect generator.sourcesUsed -> Exit.sourcesUsed
|
|
162
|
+
* @connect generator.onSuccess -> Exit.onSuccess
|
|
163
|
+
* @connect generator.onFailure -> Exit.onFailure
|
|
164
|
+
* @param execute [order:0] - Execute
|
|
165
|
+
* @param question [order:1] - User's question
|
|
166
|
+
* @param topK [order:2] - Number of documents to retrieve
|
|
167
|
+
* @returns onSuccess [order:0] - On Success
|
|
168
|
+
* @returns onFailure [order:1] - On Failure
|
|
169
|
+
* @returns answer [order:2] - Generated answer
|
|
170
|
+
* @returns sourcesUsed [order:3] - Number of sources used
|
|
171
|
+
*/
|
|
172
|
+
export async function ${workflowName}(
|
|
173
|
+
execute: boolean,
|
|
174
|
+
params: { question: string; topK?: number }
|
|
175
|
+
): Promise<{
|
|
176
|
+
onSuccess: boolean;
|
|
177
|
+
onFailure: boolean;
|
|
178
|
+
answer: string;
|
|
179
|
+
sourcesUsed: number;
|
|
180
|
+
}> {
|
|
181
|
+
throw new Error('Compile with: flow-weaver compile <file>');
|
|
182
|
+
}
|
|
183
|
+
`.trim();
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
//# sourceMappingURL=ai-rag.js.map
|