@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,62 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import * as readline from 'readline';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
function defaultRegistrationDeps() {
|
|
6
|
+
return {
|
|
7
|
+
execCommand: async (cmd) => {
|
|
8
|
+
try {
|
|
9
|
+
const stdout = execSync(cmd, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
10
|
+
return { stdout: stdout.trim(), exitCode: 0 };
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return { stdout: '', exitCode: 1 };
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
prompt: (question) => new Promise((resolve) => {
|
|
17
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
18
|
+
rl.question(question, (answer) => {
|
|
19
|
+
rl.close();
|
|
20
|
+
resolve(answer.trim().toLowerCase());
|
|
21
|
+
});
|
|
22
|
+
}),
|
|
23
|
+
log: (msg) => process.stderr.write(msg + '\n'),
|
|
24
|
+
resolveCliPath: () => {
|
|
25
|
+
// import.meta.url works in ESM (tsx), __dirname works in CJS (built bundle)
|
|
26
|
+
try {
|
|
27
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return path.resolve(__dirname, '..');
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export async function offerClaudeRegistration(options, deps) {
|
|
36
|
+
const d = deps ?? defaultRegistrationDeps();
|
|
37
|
+
// 1. Detect Claude Code
|
|
38
|
+
const whichCmd = process.platform === 'win32' ? 'where claude' : 'which claude';
|
|
39
|
+
const whichResult = await d.execCommand(whichCmd);
|
|
40
|
+
if (whichResult.exitCode !== 0) {
|
|
41
|
+
d.log('Claude Code not found in PATH. Skipping auto-registration.');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// 2. Check if already registered
|
|
45
|
+
const listResult = await d.execCommand('claude mcp list');
|
|
46
|
+
if (listResult.stdout.includes('flow-weaver')) {
|
|
47
|
+
d.log('Flow Weaver MCP server already registered in Claude Code.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// 3. Prompt user
|
|
51
|
+
const answer = await d.prompt('Claude Code detected. Register Flow Weaver MCP server? (y/N) ');
|
|
52
|
+
if (answer !== 'y' && answer !== 'yes') {
|
|
53
|
+
d.log('Skipped MCP server registration.');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// 4. Register
|
|
57
|
+
const cliPath = d.resolveCliPath();
|
|
58
|
+
const cmd = `claude mcp add --scope project flow-weaver -- npx tsx ${cliPath}/index.ts mcp-server --stdio`;
|
|
59
|
+
await d.execCommand(cmd);
|
|
60
|
+
d.log('Registered Flow Weaver MCP server. Restart Claude Code to activate.');
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=auto-registration.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { AckResponse, EditorConnectionOptions } from './types.js';
|
|
2
|
+
import type { EventBuffer } from './event-buffer.js';
|
|
3
|
+
/**
|
|
4
|
+
* Manages a WebSocket connection to the Flow Weaver editor via socket.io.
|
|
5
|
+
* Supports sending commands and batches with request/response correlation,
|
|
6
|
+
* and forwards incoming `fw:` and `integration:` events to an {@link EventBuffer}.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EditorConnection {
|
|
9
|
+
private socket;
|
|
10
|
+
private serverUrl;
|
|
11
|
+
private buffer;
|
|
12
|
+
private ioFactory;
|
|
13
|
+
private ackTimeout;
|
|
14
|
+
/**
|
|
15
|
+
* @param serverUrl - The base URL of the editor WebSocket server.
|
|
16
|
+
* @param buffer - The event buffer to push incoming events into.
|
|
17
|
+
* @param options - Optional connection configuration (custom io factory, ack timeout).
|
|
18
|
+
*/
|
|
19
|
+
constructor(serverUrl: string, buffer: EventBuffer, options?: EditorConnectionOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Establishes a WebSocket connection to the editor's `/integrations` namespace.
|
|
22
|
+
* Cleans up any previous connection first. Incoming `fw:` and `integration:` events
|
|
23
|
+
* are automatically forwarded to the event buffer.
|
|
24
|
+
* @param log - Optional logging callback for connection lifecycle events.
|
|
25
|
+
*/
|
|
26
|
+
connect(log?: (msg: string) => void): void;
|
|
27
|
+
/** Whether the socket is currently connected to the editor. */
|
|
28
|
+
get isConnected(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Sends a single command to the editor and waits for an acknowledgement.
|
|
31
|
+
* Returns an error response if not connected or if the ack times out.
|
|
32
|
+
* @param action - The command action name (e.g. "get-state", "add-node").
|
|
33
|
+
* @param params - Parameters for the command.
|
|
34
|
+
* @returns The editor's acknowledgement response.
|
|
35
|
+
*/
|
|
36
|
+
sendCommand(action: string, params: Record<string, unknown>): Promise<AckResponse>;
|
|
37
|
+
/**
|
|
38
|
+
* Sends a batch of commands to the editor as a single request and waits for acknowledgement.
|
|
39
|
+
* Returns an error response if not connected or if the ack times out.
|
|
40
|
+
* @param commands - Array of commands, each with an action name and optional params.
|
|
41
|
+
* @returns The editor's acknowledgement response for the entire batch.
|
|
42
|
+
*/
|
|
43
|
+
sendBatch(commands: Array<{
|
|
44
|
+
action: string;
|
|
45
|
+
params?: Record<string, unknown>;
|
|
46
|
+
}>): Promise<AckResponse>;
|
|
47
|
+
/** Disconnects from the editor and releases the socket. */
|
|
48
|
+
disconnect(): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=editor-connection.d.ts.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { io as socketIO } from 'socket.io-client';
|
|
2
|
+
/**
|
|
3
|
+
* Manages a WebSocket connection to the Flow Weaver editor via socket.io.
|
|
4
|
+
* Supports sending commands and batches with request/response correlation,
|
|
5
|
+
* and forwards incoming `fw:` and `integration:` events to an {@link EventBuffer}.
|
|
6
|
+
*/
|
|
7
|
+
export class EditorConnection {
|
|
8
|
+
socket = null;
|
|
9
|
+
serverUrl;
|
|
10
|
+
buffer;
|
|
11
|
+
ioFactory;
|
|
12
|
+
ackTimeout;
|
|
13
|
+
/**
|
|
14
|
+
* @param serverUrl - The base URL of the editor WebSocket server.
|
|
15
|
+
* @param buffer - The event buffer to push incoming events into.
|
|
16
|
+
* @param options - Optional connection configuration (custom io factory, ack timeout).
|
|
17
|
+
*/
|
|
18
|
+
constructor(serverUrl, buffer, options) {
|
|
19
|
+
this.serverUrl = serverUrl;
|
|
20
|
+
this.buffer = buffer;
|
|
21
|
+
this.ioFactory = options?.ioFactory ?? socketIO;
|
|
22
|
+
this.ackTimeout = options?.ackTimeout ?? 10_000;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Establishes a WebSocket connection to the editor's `/integrations` namespace.
|
|
26
|
+
* Cleans up any previous connection first. Incoming `fw:` and `integration:` events
|
|
27
|
+
* are automatically forwarded to the event buffer.
|
|
28
|
+
* @param log - Optional logging callback for connection lifecycle events.
|
|
29
|
+
*/
|
|
30
|
+
connect(log) {
|
|
31
|
+
// Clean up previous connection to prevent duplicate listeners
|
|
32
|
+
if (this.socket) {
|
|
33
|
+
this.socket.removeAllListeners();
|
|
34
|
+
this.socket.disconnect();
|
|
35
|
+
this.socket = null;
|
|
36
|
+
}
|
|
37
|
+
// Write a startup event immediately so the hook file exists from the start
|
|
38
|
+
this.buffer.push('mcp:status', { status: 'connecting', server: this.serverUrl });
|
|
39
|
+
this.socket = this.ioFactory(`${this.serverUrl}/integrations`, {
|
|
40
|
+
query: { clientType: 'mcp' },
|
|
41
|
+
transports: ['websocket', 'polling'],
|
|
42
|
+
reconnection: true,
|
|
43
|
+
reconnectionDelay: 1000,
|
|
44
|
+
reconnectionAttempts: Infinity,
|
|
45
|
+
});
|
|
46
|
+
this.socket.on('connect', () => {
|
|
47
|
+
log?.(`Connected to editor at ${this.serverUrl}`);
|
|
48
|
+
this.buffer.push('mcp:status', { status: 'connected', server: this.serverUrl });
|
|
49
|
+
});
|
|
50
|
+
if (log) {
|
|
51
|
+
this.socket.on('disconnect', (reason) => log(`Disconnected from editor: ${reason}`));
|
|
52
|
+
this.socket.on('connect_error', (err) => log(`Editor connection error: ${err.message}`));
|
|
53
|
+
}
|
|
54
|
+
this.socket.onAny((event, data) => {
|
|
55
|
+
if (event.startsWith('fw:') || event.startsWith('integration:')) {
|
|
56
|
+
this.buffer.push(event, data);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** Whether the socket is currently connected to the editor. */
|
|
61
|
+
get isConnected() {
|
|
62
|
+
return this.socket?.connected ?? false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Sends a single command to the editor and waits for an acknowledgement.
|
|
66
|
+
* Returns an error response if not connected or if the ack times out.
|
|
67
|
+
* @param action - The command action name (e.g. "get-state", "add-node").
|
|
68
|
+
* @param params - Parameters for the command.
|
|
69
|
+
* @returns The editor's acknowledgement response.
|
|
70
|
+
*/
|
|
71
|
+
async sendCommand(action, params) {
|
|
72
|
+
if (!this.socket) {
|
|
73
|
+
return { requestId: '', success: false, error: 'Not connected' };
|
|
74
|
+
}
|
|
75
|
+
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
76
|
+
return new Promise((resolve) => {
|
|
77
|
+
const handler = (data) => {
|
|
78
|
+
if (data.requestId === requestId) {
|
|
79
|
+
clearTimeout(timeout);
|
|
80
|
+
this.socket.off('fw:ack', handler);
|
|
81
|
+
resolve(data);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const timeout = setTimeout(() => {
|
|
85
|
+
this.socket.off('fw:ack', handler);
|
|
86
|
+
resolve({ requestId, success: false, error: 'Timeout' });
|
|
87
|
+
}, this.ackTimeout);
|
|
88
|
+
this.socket.on('fw:ack', handler);
|
|
89
|
+
this.socket.emit('integration:command', { requestId, action, params });
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Sends a batch of commands to the editor as a single request and waits for acknowledgement.
|
|
94
|
+
* Returns an error response if not connected or if the ack times out.
|
|
95
|
+
* @param commands - Array of commands, each with an action name and optional params.
|
|
96
|
+
* @returns The editor's acknowledgement response for the entire batch.
|
|
97
|
+
*/
|
|
98
|
+
async sendBatch(commands) {
|
|
99
|
+
if (!this.socket) {
|
|
100
|
+
return { requestId: '', success: false, error: 'Not connected' };
|
|
101
|
+
}
|
|
102
|
+
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
103
|
+
return new Promise((resolve) => {
|
|
104
|
+
const handler = (data) => {
|
|
105
|
+
if (data.requestId === requestId) {
|
|
106
|
+
clearTimeout(timeout);
|
|
107
|
+
this.socket.off('fw:ack', handler);
|
|
108
|
+
resolve(data);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const timeout = setTimeout(() => {
|
|
112
|
+
this.socket.off('fw:ack', handler);
|
|
113
|
+
resolve({ requestId, success: false, error: 'Timeout' });
|
|
114
|
+
}, this.ackTimeout);
|
|
115
|
+
this.socket.on('fw:ack', handler);
|
|
116
|
+
this.socket.emit('integration:batch', { requestId, commands });
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** Disconnects from the editor and releases the socket. */
|
|
120
|
+
disconnect() {
|
|
121
|
+
this.socket?.disconnect();
|
|
122
|
+
this.socket = null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=editor-connection.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { BufferedEvent, EventFilterConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* In-memory circular buffer for editor events with filtering, deduplication, and optional
|
|
4
|
+
* file-based persistence. Events are filtered by include/exclude patterns and deduplicated
|
|
5
|
+
* within a configurable time window.
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventBuffer {
|
|
8
|
+
private events;
|
|
9
|
+
private maxSize;
|
|
10
|
+
private eventsFilePath;
|
|
11
|
+
private filter;
|
|
12
|
+
private lastEventByType;
|
|
13
|
+
/**
|
|
14
|
+
* @param maxSize - Maximum buffer capacity. Defaults to the filter's `maxBufferSize`.
|
|
15
|
+
* @param eventsFilePath - Path to a file for appending events as NDJSON. Pass `null` to disable.
|
|
16
|
+
* Falls back to the `FW_EVENTS_FILE` environment variable if not specified.
|
|
17
|
+
* @param filter - Partial filter config merged with {@link DEFAULT_EVENT_FILTER}.
|
|
18
|
+
*/
|
|
19
|
+
constructor(maxSize?: number, eventsFilePath?: string | null, filter?: Partial<EventFilterConfig>);
|
|
20
|
+
/**
|
|
21
|
+
* Updates the event filter configuration. If `maxBufferSize` changes, trims the buffer to fit.
|
|
22
|
+
* @param partial - Partial filter fields to merge into the current config.
|
|
23
|
+
* @returns The full updated filter configuration.
|
|
24
|
+
*/
|
|
25
|
+
setFilter(partial: Partial<EventFilterConfig>): EventFilterConfig;
|
|
26
|
+
/** Returns a copy of the current event filter configuration. */
|
|
27
|
+
getFilter(): EventFilterConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Pushes an event into the buffer. The event is dropped if it does not pass the
|
|
30
|
+
* include/exclude filters. If deduplication is enabled and an identical event type
|
|
31
|
+
* was pushed within the dedup window, the previous entry is replaced instead.
|
|
32
|
+
* Evicts the oldest events when the buffer exceeds `maxSize`.
|
|
33
|
+
* @param event - The event name.
|
|
34
|
+
* @param data - The event payload.
|
|
35
|
+
*/
|
|
36
|
+
push(event: string, data: unknown): void;
|
|
37
|
+
private matchesFilter;
|
|
38
|
+
private appendToFile;
|
|
39
|
+
/**
|
|
40
|
+
* Returns all buffered events and clears the buffer.
|
|
41
|
+
* @returns A copy of all events that were in the buffer.
|
|
42
|
+
*/
|
|
43
|
+
drain(): BufferedEvent[];
|
|
44
|
+
/**
|
|
45
|
+
* Returns a copy of all buffered events without clearing the buffer.
|
|
46
|
+
* @returns A copy of the current events.
|
|
47
|
+
*/
|
|
48
|
+
peek(): BufferedEvent[];
|
|
49
|
+
/** Clears all events from the buffer. */
|
|
50
|
+
clear(): void;
|
|
51
|
+
/** The number of events currently in the buffer. */
|
|
52
|
+
get length(): number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Tests whether an event name matches a filter pattern.
|
|
56
|
+
* Supports exact matching and prefix matching when the pattern ends with `*`.
|
|
57
|
+
* @param event - The event name to test.
|
|
58
|
+
* @param pattern - The pattern to match against. Trailing `*` enables prefix matching.
|
|
59
|
+
* @returns `true` if the event matches the pattern.
|
|
60
|
+
*/
|
|
61
|
+
export declare function matchPattern(event: string, pattern: string): boolean;
|
|
62
|
+
//# sourceMappingURL=event-buffer.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { DEFAULT_EVENT_FILTER } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* In-memory circular buffer for editor events with filtering, deduplication, and optional
|
|
5
|
+
* file-based persistence. Events are filtered by include/exclude patterns and deduplicated
|
|
6
|
+
* within a configurable time window.
|
|
7
|
+
*/
|
|
8
|
+
export class EventBuffer {
|
|
9
|
+
events = [];
|
|
10
|
+
maxSize;
|
|
11
|
+
eventsFilePath;
|
|
12
|
+
filter;
|
|
13
|
+
lastEventByType = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* @param maxSize - Maximum buffer capacity. Defaults to the filter's `maxBufferSize`.
|
|
16
|
+
* @param eventsFilePath - Path to a file for appending events as NDJSON. Pass `null` to disable.
|
|
17
|
+
* Falls back to the `FW_EVENTS_FILE` environment variable if not specified.
|
|
18
|
+
* @param filter - Partial filter config merged with {@link DEFAULT_EVENT_FILTER}.
|
|
19
|
+
*/
|
|
20
|
+
constructor(maxSize, eventsFilePath, filter) {
|
|
21
|
+
this.filter = { ...DEFAULT_EVENT_FILTER, ...filter };
|
|
22
|
+
this.maxSize = maxSize ?? this.filter.maxBufferSize;
|
|
23
|
+
// null = explicitly disabled, undefined = check env
|
|
24
|
+
this.eventsFilePath =
|
|
25
|
+
eventsFilePath === null ? null : (eventsFilePath ?? process.env.FW_EVENTS_FILE ?? null);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Updates the event filter configuration. If `maxBufferSize` changes, trims the buffer to fit.
|
|
29
|
+
* @param partial - Partial filter fields to merge into the current config.
|
|
30
|
+
* @returns The full updated filter configuration.
|
|
31
|
+
*/
|
|
32
|
+
setFilter(partial) {
|
|
33
|
+
this.filter = { ...this.filter, ...partial };
|
|
34
|
+
if (partial.maxBufferSize !== undefined) {
|
|
35
|
+
this.maxSize = partial.maxBufferSize;
|
|
36
|
+
if (this.events.length > this.maxSize) {
|
|
37
|
+
this.events = this.events.slice(this.events.length - this.maxSize);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { ...this.filter };
|
|
41
|
+
}
|
|
42
|
+
/** Returns a copy of the current event filter configuration. */
|
|
43
|
+
getFilter() {
|
|
44
|
+
return { ...this.filter };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Pushes an event into the buffer. The event is dropped if it does not pass the
|
|
48
|
+
* include/exclude filters. If deduplication is enabled and an identical event type
|
|
49
|
+
* was pushed within the dedup window, the previous entry is replaced instead.
|
|
50
|
+
* Evicts the oldest events when the buffer exceeds `maxSize`.
|
|
51
|
+
* @param event - The event name.
|
|
52
|
+
* @param data - The event payload.
|
|
53
|
+
*/
|
|
54
|
+
push(event, data) {
|
|
55
|
+
if (!this.matchesFilter(event))
|
|
56
|
+
return;
|
|
57
|
+
const entry = {
|
|
58
|
+
event,
|
|
59
|
+
data,
|
|
60
|
+
timestamp: new Date().toISOString(),
|
|
61
|
+
};
|
|
62
|
+
// Dedup: if same event type within window, replace the last instance
|
|
63
|
+
if (this.filter.dedupeWindowMs > 0) {
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
const lastTime = this.lastEventByType.get(event);
|
|
66
|
+
if (lastTime !== undefined && now - lastTime < this.filter.dedupeWindowMs) {
|
|
67
|
+
// Replace the last event of this type in the buffer
|
|
68
|
+
for (let i = this.events.length - 1; i >= 0; i--) {
|
|
69
|
+
if (this.events[i].event === event) {
|
|
70
|
+
this.events[i] = entry;
|
|
71
|
+
this.lastEventByType.set(event, now);
|
|
72
|
+
this.appendToFile(entry);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.lastEventByType.set(event, now);
|
|
78
|
+
}
|
|
79
|
+
this.events.push(entry);
|
|
80
|
+
// Evict oldest if over limit
|
|
81
|
+
if (this.events.length > this.maxSize) {
|
|
82
|
+
this.events = this.events.slice(this.events.length - this.maxSize);
|
|
83
|
+
}
|
|
84
|
+
this.appendToFile(entry);
|
|
85
|
+
}
|
|
86
|
+
matchesFilter(event) {
|
|
87
|
+
const { include, exclude } = this.filter;
|
|
88
|
+
// If include list is non-empty, event must match at least one pattern
|
|
89
|
+
if (include.length > 0) {
|
|
90
|
+
if (!include.some((pattern) => matchPattern(event, pattern))) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// If event matches any exclude pattern, reject it
|
|
95
|
+
if (exclude.length > 0) {
|
|
96
|
+
if (exclude.some((pattern) => matchPattern(event, pattern))) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
appendToFile(entry) {
|
|
103
|
+
if (!this.eventsFilePath)
|
|
104
|
+
return;
|
|
105
|
+
try {
|
|
106
|
+
fs.appendFileSync(this.eventsFilePath, JSON.stringify(entry) + '\n');
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// File may have been atomically moved by the hook — next push creates a new one
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns all buffered events and clears the buffer.
|
|
114
|
+
* @returns A copy of all events that were in the buffer.
|
|
115
|
+
*/
|
|
116
|
+
drain() {
|
|
117
|
+
const result = [...this.events];
|
|
118
|
+
this.events = [];
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Returns a copy of all buffered events without clearing the buffer.
|
|
123
|
+
* @returns A copy of the current events.
|
|
124
|
+
*/
|
|
125
|
+
peek() {
|
|
126
|
+
return [...this.events];
|
|
127
|
+
}
|
|
128
|
+
/** Clears all events from the buffer. */
|
|
129
|
+
clear() {
|
|
130
|
+
this.events = [];
|
|
131
|
+
}
|
|
132
|
+
/** The number of events currently in the buffer. */
|
|
133
|
+
get length() {
|
|
134
|
+
return this.events.length;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Tests whether an event name matches a filter pattern.
|
|
139
|
+
* Supports exact matching and prefix matching when the pattern ends with `*`.
|
|
140
|
+
* @param event - The event name to test.
|
|
141
|
+
* @param pattern - The pattern to match against. Trailing `*` enables prefix matching.
|
|
142
|
+
* @returns `true` if the event matches the pattern.
|
|
143
|
+
*/
|
|
144
|
+
export function matchPattern(event, pattern) {
|
|
145
|
+
if (pattern.endsWith('*')) {
|
|
146
|
+
return event.startsWith(pattern.slice(0, -1));
|
|
147
|
+
}
|
|
148
|
+
return event === pattern;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=event-buffer.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { McpServerOptions, RegistrationDeps, AckResponse, BufferedEvent, EditorConnectionOptions, } from './types.js';
|
|
2
|
+
export { EventBuffer } from './event-buffer.js';
|
|
3
|
+
export { EditorConnection } from './editor-connection.js';
|
|
4
|
+
export { offerClaudeRegistration } from './auto-registration.js';
|
|
5
|
+
export { makeToolResult, makeErrorResult } from './response-utils.js';
|
|
6
|
+
export { registerEditorTools } from './tools-editor.js';
|
|
7
|
+
export { registerQueryTools } from './tools-query.js';
|
|
8
|
+
export { registerTemplateTools } from './tools-template.js';
|
|
9
|
+
export { registerPatternTools } from './tools-pattern.js';
|
|
10
|
+
export { registerResources } from './resources.js';
|
|
11
|
+
export { startMcpServer, mcpServerCommand } from './server.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { EventBuffer } from './event-buffer.js';
|
|
2
|
+
export { EditorConnection } from './editor-connection.js';
|
|
3
|
+
export { offerClaudeRegistration } from './auto-registration.js';
|
|
4
|
+
export { makeToolResult, makeErrorResult } from './response-utils.js';
|
|
5
|
+
export { registerEditorTools } from './tools-editor.js';
|
|
6
|
+
export { registerQueryTools } from './tools-query.js';
|
|
7
|
+
export { registerTemplateTools } from './tools-template.js';
|
|
8
|
+
export { registerPatternTools } from './tools-pattern.js';
|
|
9
|
+
export { registerResources } from './resources.js';
|
|
10
|
+
export { startMcpServer, mcpServerCommand } from './server.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { EditorConnection } from './editor-connection.js';
|
|
3
|
+
import type { EventBuffer } from './event-buffer.js';
|
|
4
|
+
/**
|
|
5
|
+
* Registers MCP resources that expose editor state and event data.
|
|
6
|
+
* Registers two resources:
|
|
7
|
+
* - `fw://events` - read-only peek at the event buffer.
|
|
8
|
+
* - `fw://state` - current editor/workflow state fetched via the editor connection.
|
|
9
|
+
* @param mcp - The MCP server instance to register resources on.
|
|
10
|
+
* @param connection - The editor WebSocket connection used to query state.
|
|
11
|
+
* @param buffer - The event buffer to read events from.
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerResources(mcp: McpServer, connection: EditorConnection, buffer: EventBuffer): void;
|
|
14
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers MCP resources that expose editor state and event data.
|
|
3
|
+
* Registers two resources:
|
|
4
|
+
* - `fw://events` - read-only peek at the event buffer.
|
|
5
|
+
* - `fw://state` - current editor/workflow state fetched via the editor connection.
|
|
6
|
+
* @param mcp - The MCP server instance to register resources on.
|
|
7
|
+
* @param connection - The editor WebSocket connection used to query state.
|
|
8
|
+
* @param buffer - The event buffer to read events from.
|
|
9
|
+
*/
|
|
10
|
+
export function registerResources(mcp, connection, buffer) {
|
|
11
|
+
mcp.resource('events', 'fw://events', { description: 'Read-only view of the event buffer (does not clear it)' }, async () => ({
|
|
12
|
+
contents: [
|
|
13
|
+
{
|
|
14
|
+
uri: 'fw://events',
|
|
15
|
+
text: JSON.stringify(buffer.peek(), null, 2),
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
}));
|
|
19
|
+
mcp.resource('state', 'fw://state', { description: 'Current editor/workflow state' }, async () => {
|
|
20
|
+
if (!connection.isConnected) {
|
|
21
|
+
return {
|
|
22
|
+
contents: [
|
|
23
|
+
{
|
|
24
|
+
uri: 'fw://state',
|
|
25
|
+
text: JSON.stringify({ error: 'Not connected to editor' }),
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const result = await connection.sendCommand('get-state', {});
|
|
32
|
+
return {
|
|
33
|
+
contents: [
|
|
34
|
+
{
|
|
35
|
+
uri: 'fw://state',
|
|
36
|
+
text: JSON.stringify(result, null, 2),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
return {
|
|
43
|
+
contents: [
|
|
44
|
+
{
|
|
45
|
+
uri: 'fw://state',
|
|
46
|
+
text: JSON.stringify({
|
|
47
|
+
error: `Failed to get state: ${err instanceof Error ? err.message : String(err)}`,
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a data payload into a successful MCP tool result with JSON text content.
|
|
3
|
+
* @param data - The result data to include in the response.
|
|
4
|
+
* @returns An MCP tool result object with `success: true` and the serialized data.
|
|
5
|
+
*/
|
|
6
|
+
export declare function makeToolResult(data: unknown): {
|
|
7
|
+
content: {
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Wraps an error code and message into a failed MCP tool result.
|
|
14
|
+
* @param code - A machine-readable error code (e.g. "UNKNOWN_NODE_TYPE").
|
|
15
|
+
* @param message - A human-readable error description.
|
|
16
|
+
* @returns An MCP tool result object with `success: false`, `isError: true`, and the serialized error.
|
|
17
|
+
*/
|
|
18
|
+
export declare function makeErrorResult(code: string, message: string): {
|
|
19
|
+
content: {
|
|
20
|
+
type: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}[];
|
|
23
|
+
isError: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Maps validation error codes to suggested next MCP tool actions.
|
|
27
|
+
* Used to guide LLM agents toward resolving workflow issues.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ERROR_HINTS: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Enriches validation items with actionable hints from {@link ERROR_HINTS} and optional
|
|
32
|
+
* friendly error explanations. Replaces `<nodeId>` placeholders in hints with actual node IDs.
|
|
33
|
+
* @param items - Array of validation errors/warnings, each with a message, severity, and optional code.
|
|
34
|
+
* @param friendlyErrorFn - Optional function that produces user-friendly error explanations.
|
|
35
|
+
* @returns A new array with `hint` and `friendly` fields added where applicable.
|
|
36
|
+
*/
|
|
37
|
+
export declare function addHintsToItems(items: Array<{
|
|
38
|
+
message: string;
|
|
39
|
+
severity: string;
|
|
40
|
+
nodeId?: string;
|
|
41
|
+
code?: string;
|
|
42
|
+
}>, friendlyErrorFn?: (err: {
|
|
43
|
+
code: string;
|
|
44
|
+
message: string;
|
|
45
|
+
node?: string;
|
|
46
|
+
}) => {
|
|
47
|
+
title: string;
|
|
48
|
+
explanation: string;
|
|
49
|
+
fix: string;
|
|
50
|
+
code: string;
|
|
51
|
+
} | null): Array<{
|
|
52
|
+
message: string;
|
|
53
|
+
severity: string;
|
|
54
|
+
nodeId?: string;
|
|
55
|
+
code?: string;
|
|
56
|
+
hint?: string;
|
|
57
|
+
friendly?: {
|
|
58
|
+
title: string;
|
|
59
|
+
explanation: string;
|
|
60
|
+
fix: string;
|
|
61
|
+
};
|
|
62
|
+
}>;
|
|
63
|
+
//# sourceMappingURL=response-utils.d.ts.map
|