@n8n/instance-ai 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +88 -0
- package/dist/agent/instance-agent.d.ts +3 -0
- package/dist/agent/instance-agent.js +215 -0
- package/dist/agent/instance-agent.js.map +1 -0
- package/dist/agent/register-with-mastra.d.ts +3 -0
- package/dist/agent/register-with-mastra.js +19 -0
- package/dist/agent/register-with-mastra.js.map +1 -0
- package/dist/agent/sanitize-mcp-schemas.d.ts +2 -0
- package/dist/agent/sanitize-mcp-schemas.js +91 -0
- package/dist/agent/sanitize-mcp-schemas.js.map +1 -0
- package/dist/agent/sub-agent-factory.d.ts +14 -0
- package/dist/agent/sub-agent-factory.js +48 -0
- package/dist/agent/sub-agent-factory.js.map +1 -0
- package/dist/agent/system-prompt.d.ts +13 -0
- package/dist/agent/system-prompt.js +226 -0
- package/dist/agent/system-prompt.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -0
- package/dist/compaction/compaction-helper.d.ts +9 -0
- package/dist/compaction/compaction-helper.js +58 -0
- package/dist/compaction/compaction-helper.js.map +1 -0
- package/dist/compaction/index.d.ts +2 -0
- package/dist/compaction/index.js +6 -0
- package/dist/compaction/index.js.map +1 -0
- package/dist/domain-access/domain-access-tracker.d.ts +9 -0
- package/dist/domain-access/domain-access-tracker.js +46 -0
- package/dist/domain-access/domain-access-tracker.js.map +1 -0
- package/dist/domain-access/domain-gating.d.ts +65 -0
- package/dist/domain-access/domain-gating.js +68 -0
- package/dist/domain-access/domain-gating.js.map +1 -0
- package/dist/domain-access/index.d.ts +4 -0
- package/dist/domain-access/index.js +11 -0
- package/dist/domain-access/index.js.map +1 -0
- package/dist/event-bus/event-bus.interface.d.ts +15 -0
- package/dist/event-bus/event-bus.interface.js +3 -0
- package/dist/event-bus/event-bus.interface.js.map +1 -0
- package/dist/event-bus/index.d.ts +1 -0
- package/dist/event-bus/index.js +3 -0
- package/dist/event-bus/index.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/mcp-client-manager.d.ts +6 -0
- package/dist/mcp/mcp-client-manager.js +34 -0
- package/dist/mcp/mcp-client-manager.js.map +1 -0
- package/dist/memory/memory-config.d.ts +3 -0
- package/dist/memory/memory-config.js +29 -0
- package/dist/memory/memory-config.js.map +1 -0
- package/dist/memory/title-utils.d.ts +3 -0
- package/dist/memory/title-utils.js +42 -0
- package/dist/memory/title-utils.js.map +1 -0
- package/dist/memory/working-memory-template.d.ts +1 -0
- package/dist/memory/working-memory-template.js +25 -0
- package/dist/memory/working-memory-template.js.map +1 -0
- package/dist/planned-tasks/planned-task-service.d.ts +33 -0
- package/dist/planned-tasks/planned-task-service.js +151 -0
- package/dist/planned-tasks/planned-task-service.js.map +1 -0
- package/dist/runtime/background-task-manager.d.ts +53 -0
- package/dist/runtime/background-task-manager.js +127 -0
- package/dist/runtime/background-task-manager.js.map +1 -0
- package/dist/runtime/resumable-stream-executor.d.ts +75 -0
- package/dist/runtime/resumable-stream-executor.js +1552 -0
- package/dist/runtime/resumable-stream-executor.js.map +1 -0
- package/dist/runtime/run-state-registry.d.ts +109 -0
- package/dist/runtime/run-state-registry.js +210 -0
- package/dist/runtime/run-state-registry.js.map +1 -0
- package/dist/runtime/stream-runner.d.ts +27 -0
- package/dist/runtime/stream-runner.js +87 -0
- package/dist/runtime/stream-runner.js.map +1 -0
- package/dist/runtime/working-memory-tracing.d.ts +19 -0
- package/dist/runtime/working-memory-tracing.js +111 -0
- package/dist/runtime/working-memory-tracing.js.map +1 -0
- package/dist/storage/agent-tree-snapshot.d.ts +7 -0
- package/dist/storage/agent-tree-snapshot.js +3 -0
- package/dist/storage/agent-tree-snapshot.js.map +1 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.js +17 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/iteration-log.d.ts +30 -0
- package/dist/storage/iteration-log.js +31 -0
- package/dist/storage/iteration-log.js.map +1 -0
- package/dist/storage/mastra-iteration-log-storage.d.ts +10 -0
- package/dist/storage/mastra-iteration-log-storage.js +57 -0
- package/dist/storage/mastra-iteration-log-storage.js.map +1 -0
- package/dist/storage/mastra-task-storage.d.ts +9 -0
- package/dist/storage/mastra-task-storage.js +35 -0
- package/dist/storage/mastra-task-storage.js.map +1 -0
- package/dist/storage/planned-task-storage.d.ts +10 -0
- package/dist/storage/planned-task-storage.js +97 -0
- package/dist/storage/planned-task-storage.js.map +1 -0
- package/dist/storage/thread-patch.d.ts +16 -0
- package/dist/storage/thread-patch.js +50 -0
- package/dist/storage/thread-patch.js.map +1 -0
- package/dist/storage/workflow-loop-storage.d.ts +217 -0
- package/dist/storage/workflow-loop-storage.js +59 -0
- package/dist/storage/workflow-loop-storage.js.map +1 -0
- package/dist/stream/consume-with-hitl.d.ts +22 -0
- package/dist/stream/consume-with-hitl.js +29 -0
- package/dist/stream/consume-with-hitl.js.map +1 -0
- package/dist/stream/map-chunk.d.ts +2 -0
- package/dist/stream/map-chunk.js +224 -0
- package/dist/stream/map-chunk.js.map +1 -0
- package/dist/tools/best-practices/get-best-practices.tool.d.ts +12 -0
- package/dist/tools/best-practices/get-best-practices.tool.js +64 -0
- package/dist/tools/best-practices/get-best-practices.tool.js.map +1 -0
- package/dist/tools/best-practices/guides/chatbot.d.ts +1 -0
- package/dist/tools/best-practices/guides/chatbot.js +111 -0
- package/dist/tools/best-practices/guides/chatbot.js.map +1 -0
- package/dist/tools/best-practices/guides/content-generation.d.ts +1 -0
- package/dist/tools/best-practices/guides/content-generation.js +108 -0
- package/dist/tools/best-practices/guides/content-generation.js.map +1 -0
- package/dist/tools/best-practices/guides/data-extraction.d.ts +1 -0
- package/dist/tools/best-practices/guides/data-extraction.js +115 -0
- package/dist/tools/best-practices/guides/data-extraction.js.map +1 -0
- package/dist/tools/best-practices/guides/data-persistence.d.ts +1 -0
- package/dist/tools/best-practices/guides/data-persistence.js +198 -0
- package/dist/tools/best-practices/guides/data-persistence.js.map +1 -0
- package/dist/tools/best-practices/guides/data-transformation.d.ts +1 -0
- package/dist/tools/best-practices/guides/data-transformation.js +139 -0
- package/dist/tools/best-practices/guides/data-transformation.js.map +1 -0
- package/dist/tools/best-practices/guides/document-processing.d.ts +1 -0
- package/dist/tools/best-practices/guides/document-processing.js +326 -0
- package/dist/tools/best-practices/guides/document-processing.js.map +1 -0
- package/dist/tools/best-practices/guides/form-input.d.ts +1 -0
- package/dist/tools/best-practices/guides/form-input.js +166 -0
- package/dist/tools/best-practices/guides/form-input.js.map +1 -0
- package/dist/tools/best-practices/guides/notification.d.ts +1 -0
- package/dist/tools/best-practices/guides/notification.js +128 -0
- package/dist/tools/best-practices/guides/notification.js.map +1 -0
- package/dist/tools/best-practices/guides/scheduling.d.ts +1 -0
- package/dist/tools/best-practices/guides/scheduling.js +145 -0
- package/dist/tools/best-practices/guides/scheduling.js.map +1 -0
- package/dist/tools/best-practices/guides/scraping-and-research.d.ts +1 -0
- package/dist/tools/best-practices/guides/scraping-and-research.js +151 -0
- package/dist/tools/best-practices/guides/scraping-and-research.js.map +1 -0
- package/dist/tools/best-practices/guides/triage.d.ts +1 -0
- package/dist/tools/best-practices/guides/triage.js +142 -0
- package/dist/tools/best-practices/guides/triage.js.map +1 -0
- package/dist/tools/best-practices/index.d.ts +2 -0
- package/dist/tools/best-practices/index.js +34 -0
- package/dist/tools/best-practices/index.js.map +1 -0
- package/dist/tools/best-practices/techniques.d.ts +20 -0
- package/dist/tools/best-practices/techniques.js +40 -0
- package/dist/tools/best-practices/techniques.js.map +1 -0
- package/dist/tools/credentials/delete-credential.tool.d.ts +21 -0
- package/dist/tools/credentials/delete-credential.tool.js +51 -0
- package/dist/tools/credentials/delete-credential.tool.js.map +1 -0
- package/dist/tools/credentials/get-credential.tool.d.ts +4 -0
- package/dist/tools/credentials/get-credential.tool.js +26 -0
- package/dist/tools/credentials/get-credential.tool.js.map +1 -0
- package/dist/tools/credentials/list-credentials.tool.d.ts +6 -0
- package/dist/tools/credentials/list-credentials.tool.js +30 -0
- package/dist/tools/credentials/list-credentials.tool.js.map +1 -0
- package/dist/tools/credentials/search-credential-types.tool.d.ts +6 -0
- package/dist/tools/credentials/search-credential-types.tool.js +44 -0
- package/dist/tools/credentials/search-credential-types.tool.js.map +1 -0
- package/dist/tools/credentials/setup-credentials.tool.d.ts +73 -0
- package/dist/tools/credentials/setup-credentials.tool.js +134 -0
- package/dist/tools/credentials/setup-credentials.tool.js.map +1 -0
- package/dist/tools/credentials/test-credential.tool.d.ts +7 -0
- package/dist/tools/credentials/test-credential.tool.js +30 -0
- package/dist/tools/credentials/test-credential.tool.js.map +1 -0
- package/dist/tools/data-tables/add-data-table-column.tool.d.ts +27 -0
- package/dist/tools/data-tables/add-data-table-column.tool.js +60 -0
- package/dist/tools/data-tables/add-data-table-column.tool.js.map +1 -0
- package/dist/tools/data-tables/create-data-table.tool.d.ts +36 -0
- package/dist/tools/data-tables/create-data-table.tool.js +79 -0
- package/dist/tools/data-tables/create-data-table.tool.js.map +1 -0
- package/dist/tools/data-tables/delete-data-table-column.tool.d.ts +21 -0
- package/dist/tools/data-tables/delete-data-table-column.tool.js +48 -0
- package/dist/tools/data-tables/delete-data-table-column.tool.js.map +1 -0
- package/dist/tools/data-tables/delete-data-table-rows.tool.d.ts +29 -0
- package/dist/tools/data-tables/delete-data-table-rows.tool.js +63 -0
- package/dist/tools/data-tables/delete-data-table-rows.tool.js.map +1 -0
- package/dist/tools/data-tables/delete-data-table.tool.d.ts +20 -0
- package/dist/tools/data-tables/delete-data-table.tool.js +46 -0
- package/dist/tools/data-tables/delete-data-table.tool.js.map +1 -0
- package/dist/tools/data-tables/get-data-table-schema.tool.d.ts +11 -0
- package/dist/tools/data-tables/get-data-table-schema.tool.js +27 -0
- package/dist/tools/data-tables/get-data-table-schema.tool.js.map +1 -0
- package/dist/tools/data-tables/insert-data-table-rows.tool.d.ts +21 -0
- package/dist/tools/data-tables/insert-data-table-rows.tool.js +52 -0
- package/dist/tools/data-tables/insert-data-table-rows.tool.js.map +1 -0
- package/dist/tools/data-tables/list-data-tables.tool.d.ts +6 -0
- package/dist/tools/data-tables/list-data-tables.tool.js +32 -0
- package/dist/tools/data-tables/list-data-tables.tool.js.map +1 -0
- package/dist/tools/data-tables/query-data-table-rows.tool.d.ts +21 -0
- package/dist/tools/data-tables/query-data-table-rows.tool.js +54 -0
- package/dist/tools/data-tables/query-data-table-rows.tool.js.map +1 -0
- package/dist/tools/data-tables/rename-data-table-column.tool.d.ts +22 -0
- package/dist/tools/data-tables/rename-data-table-column.tool.js +49 -0
- package/dist/tools/data-tables/rename-data-table-column.tool.js.map +1 -0
- package/dist/tools/data-tables/update-data-table-rows.tool.d.ts +29 -0
- package/dist/tools/data-tables/update-data-table-rows.tool.js +57 -0
- package/dist/tools/data-tables/update-data-table-rows.tool.js.map +1 -0
- package/dist/tools/executions/debug-execution.tool.d.ts +4 -0
- package/dist/tools/executions/debug-execution.tool.js +41 -0
- package/dist/tools/executions/debug-execution.tool.js.map +1 -0
- package/dist/tools/executions/get-execution.tool.d.ts +4 -0
- package/dist/tools/executions/get-execution.tool.js +26 -0
- package/dist/tools/executions/get-execution.tool.js.map +1 -0
- package/dist/tools/executions/get-node-output.tool.d.ts +7 -0
- package/dist/tools/executions/get-node-output.tool.js +44 -0
- package/dist/tools/executions/get-node-output.tool.js.map +1 -0
- package/dist/tools/executions/list-executions.tool.d.ts +8 -0
- package/dist/tools/executions/list-executions.tool.js +45 -0
- package/dist/tools/executions/list-executions.tool.js.map +1 -0
- package/dist/tools/executions/run-workflow.tool.d.ts +24 -0
- package/dist/tools/executions/run-workflow.tool.js +82 -0
- package/dist/tools/executions/run-workflow.tool.js.map +1 -0
- package/dist/tools/executions/stop-execution.tool.d.ts +7 -0
- package/dist/tools/executions/stop-execution.tool.js +22 -0
- package/dist/tools/executions/stop-execution.tool.js.map +1 -0
- package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +3 -0
- package/dist/tools/filesystem/create-tools-from-mcp-server.js +61 -0
- package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -0
- package/dist/tools/filesystem/get-file-tree.tool.d.ts +22 -0
- package/dist/tools/filesystem/get-file-tree.tool.js +64 -0
- package/dist/tools/filesystem/get-file-tree.tool.js.map +1 -0
- package/dist/tools/filesystem/list-files.tool.d.ts +30 -0
- package/dist/tools/filesystem/list-files.tool.js +100 -0
- package/dist/tools/filesystem/list-files.tool.js.map +1 -0
- package/dist/tools/filesystem/read-file.tool.d.ts +25 -0
- package/dist/tools/filesystem/read-file.tool.js +83 -0
- package/dist/tools/filesystem/read-file.tool.js.map +1 -0
- package/dist/tools/filesystem/search-files.tool.d.ts +31 -0
- package/dist/tools/filesystem/search-files.tool.js +96 -0
- package/dist/tools/filesystem/search-files.tool.js.map +1 -0
- package/dist/tools/index.d.ts +2385 -0
- package/dist/tools/index.js +195 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/nodes/explore-node-resources.tool.d.ts +21 -0
- package/dist/tools/nodes/explore-node-resources.tool.js +71 -0
- package/dist/tools/nodes/explore-node-resources.tool.js.map +1 -0
- package/dist/tools/nodes/get-node-description.tool.d.ts +23 -0
- package/dist/tools/nodes/get-node-description.tool.js +52 -0
- package/dist/tools/nodes/get-node-description.tool.js.map +1 -0
- package/dist/tools/nodes/get-node-type-definition.tool.d.ts +17 -0
- package/dist/tools/nodes/get-node-type-definition.tool.js +73 -0
- package/dist/tools/nodes/get-node-type-definition.tool.js.map +1 -0
- package/dist/tools/nodes/get-suggested-nodes.tool.d.ts +14 -0
- package/dist/tools/nodes/get-suggested-nodes.tool.js +54 -0
- package/dist/tools/nodes/get-suggested-nodes.tool.js.map +1 -0
- package/dist/tools/nodes/list-nodes.tool.d.ts +6 -0
- package/dist/tools/nodes/list-nodes.tool.js +33 -0
- package/dist/tools/nodes/list-nodes.tool.js.map +1 -0
- package/dist/tools/nodes/node-search-engine.d.ts +18 -0
- package/dist/tools/nodes/node-search-engine.js +266 -0
- package/dist/tools/nodes/node-search-engine.js.map +1 -0
- package/dist/tools/nodes/node-search-engine.types.d.ts +38 -0
- package/dist/tools/nodes/node-search-engine.types.js +18 -0
- package/dist/tools/nodes/node-search-engine.types.js.map +1 -0
- package/dist/tools/nodes/search-nodes.tool.d.ts +28 -0
- package/dist/tools/nodes/search-nodes.tool.js +87 -0
- package/dist/tools/nodes/search-nodes.tool.js.map +1 -0
- package/dist/tools/nodes/suggested-nodes-data.d.ts +11 -0
- package/dist/tools/nodes/suggested-nodes-data.js +326 -0
- package/dist/tools/nodes/suggested-nodes-data.js.map +1 -0
- package/dist/tools/orchestration/browser-credential-setup.tool.d.ts +14 -0
- package/dist/tools/orchestration/browser-credential-setup.tool.js +429 -0
- package/dist/tools/orchestration/browser-credential-setup.tool.js.map +1 -0
- package/dist/tools/orchestration/build-workflow-agent.prompt.d.ts +2 -0
- package/dist/tools/orchestration/build-workflow-agent.prompt.js +836 -0
- package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -0
- package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +23 -0
- package/dist/tools/orchestration/build-workflow-agent.tool.js +503 -0
- package/dist/tools/orchestration/build-workflow-agent.tool.js.map +1 -0
- package/dist/tools/orchestration/cancel-background-task.tool.d.ts +6 -0
- package/dist/tools/orchestration/cancel-background-task.tool.js +24 -0
- package/dist/tools/orchestration/cancel-background-task.tool.js.map +1 -0
- package/dist/tools/orchestration/correct-background-task.tool.d.ts +7 -0
- package/dist/tools/orchestration/correct-background-task.tool.js +41 -0
- package/dist/tools/orchestration/correct-background-task.tool.js.map +1 -0
- package/dist/tools/orchestration/data-table-agent.prompt.d.ts +1 -0
- package/dist/tools/orchestration/data-table-agent.prompt.js +29 -0
- package/dist/tools/orchestration/data-table-agent.prompt.js.map +1 -0
- package/dist/tools/orchestration/data-table-agent.tool.d.ts +21 -0
- package/dist/tools/orchestration/data-table-agent.tool.js +171 -0
- package/dist/tools/orchestration/data-table-agent.tool.js.map +1 -0
- package/dist/tools/orchestration/delegate.schemas.d.ts +32 -0
- package/dist/tools/orchestration/delegate.schemas.js +29 -0
- package/dist/tools/orchestration/delegate.schemas.js.map +1 -0
- package/dist/tools/orchestration/delegate.tool.d.ts +27 -0
- package/dist/tools/orchestration/delegate.tool.js +307 -0
- package/dist/tools/orchestration/delegate.tool.js.map +1 -0
- package/dist/tools/orchestration/display-utils.d.ts +1 -0
- package/dist/tools/orchestration/display-utils.js +8 -0
- package/dist/tools/orchestration/display-utils.js.map +1 -0
- package/dist/tools/orchestration/plan.tool.d.ts +45 -0
- package/dist/tools/orchestration/plan.tool.js +99 -0
- package/dist/tools/orchestration/plan.tool.js.map +1 -0
- package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +14 -0
- package/dist/tools/orchestration/report-verification-verdict.tool.js +66 -0
- package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -0
- package/dist/tools/orchestration/research-agent-prompt.d.ts +1 -0
- package/dist/tools/orchestration/research-agent-prompt.js +28 -0
- package/dist/tools/orchestration/research-agent-prompt.js.map +1 -0
- package/dist/tools/orchestration/research-with-agent.tool.d.ts +23 -0
- package/dist/tools/orchestration/research-with-agent.tool.js +160 -0
- package/dist/tools/orchestration/research-with-agent.tool.js.map +1 -0
- package/dist/tools/orchestration/tracing-utils.d.ts +20 -0
- package/dist/tools/orchestration/tracing-utils.js +102 -0
- package/dist/tools/orchestration/tracing-utils.js.map +1 -0
- package/dist/tools/orchestration/update-tasks.tool.d.ts +10 -0
- package/dist/tools/orchestration/update-tasks.tool.js +26 -0
- package/dist/tools/orchestration/update-tasks.tool.js.map +1 -0
- package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +13 -0
- package/dist/tools/orchestration/verify-built-workflow.tool.js +58 -0
- package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -0
- package/dist/tools/shared/ask-user.tool.d.ts +61 -0
- package/dist/tools/shared/ask-user.tool.js +98 -0
- package/dist/tools/shared/ask-user.tool.js.map +1 -0
- package/dist/tools/templates/search-template-parameters.tool.d.ts +11 -0
- package/dist/tools/templates/search-template-parameters.tool.js +55 -0
- package/dist/tools/templates/search-template-parameters.tool.js.map +1 -0
- package/dist/tools/templates/search-template-structures.tool.d.ts +12 -0
- package/dist/tools/templates/search-template-structures.tool.js +45 -0
- package/dist/tools/templates/search-template-structures.tool.js.map +1 -0
- package/dist/tools/templates/template-api.d.ts +21 -0
- package/dist/tools/templates/template-api.js +104 -0
- package/dist/tools/templates/template-api.js.map +1 -0
- package/dist/tools/templates/types.d.ts +52 -0
- package/dist/tools/templates/types.js +37 -0
- package/dist/tools/templates/types.js.map +1 -0
- package/dist/tools/utils/mermaid.utils.d.ts +15 -0
- package/dist/tools/utils/mermaid.utils.js +622 -0
- package/dist/tools/utils/mermaid.utils.js.map +1 -0
- package/dist/tools/utils/node-configuration.utils.d.ts +6 -0
- package/dist/tools/utils/node-configuration.utils.js +77 -0
- package/dist/tools/utils/node-configuration.utils.js.map +1 -0
- package/dist/tools/web-research/fetch-url.tool.d.ts +27 -0
- package/dist/tools/web-research/fetch-url.tool.js +116 -0
- package/dist/tools/web-research/fetch-url.tool.js.map +1 -0
- package/dist/tools/web-research/index.d.ts +1 -0
- package/dist/tools/web-research/index.js +6 -0
- package/dist/tools/web-research/index.js.map +1 -0
- package/dist/tools/web-research/sanitize-web-content.d.ts +3 -0
- package/dist/tools/web-research/sanitize-web-content.js +36 -0
- package/dist/tools/web-research/sanitize-web-content.js.map +1 -0
- package/dist/tools/web-research/web-search.tool.d.ts +6 -0
- package/dist/tools/web-research/web-search.tool.js +57 -0
- package/dist/tools/web-research/web-search.tool.js.map +1 -0
- package/dist/tools/workflows/apply-workflow-credentials.tool.d.ts +10 -0
- package/dist/tools/workflows/apply-workflow-credentials.tool.js +87 -0
- package/dist/tools/workflows/apply-workflow-credentials.tool.js.map +1 -0
- package/dist/tools/workflows/build-workflow.tool.d.ts +16 -0
- package/dist/tools/workflows/build-workflow.tool.js +163 -0
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -0
- package/dist/tools/workflows/delete-workflow.tool.d.ts +21 -0
- package/dist/tools/workflows/delete-workflow.tool.js +51 -0
- package/dist/tools/workflows/delete-workflow.tool.js.map +1 -0
- package/dist/tools/workflows/get-workflow-as-code.tool.d.ts +14 -0
- package/dist/tools/workflows/get-workflow-as-code.tool.js +37 -0
- package/dist/tools/workflows/get-workflow-as-code.tool.js.map +1 -0
- package/dist/tools/workflows/get-workflow-version.tool.d.ts +21 -0
- package/dist/tools/workflows/get-workflow-version.tool.js +38 -0
- package/dist/tools/workflows/get-workflow-version.tool.js.map +1 -0
- package/dist/tools/workflows/get-workflow.tool.d.ts +18 -0
- package/dist/tools/workflows/get-workflow.tool.js +36 -0
- package/dist/tools/workflows/get-workflow.tool.js.map +1 -0
- package/dist/tools/workflows/list-workflow-versions.tool.d.ts +8 -0
- package/dist/tools/workflows/list-workflow-versions.tool.js +47 -0
- package/dist/tools/workflows/list-workflow-versions.tool.js.map +1 -0
- package/dist/tools/workflows/list-workflows.tool.d.ts +14 -0
- package/dist/tools/workflows/list-workflows.tool.js +42 -0
- package/dist/tools/workflows/list-workflows.tool.js.map +1 -0
- package/dist/tools/workflows/materialize-node-type.tool.d.ts +23 -0
- package/dist/tools/workflows/materialize-node-type.tool.js +105 -0
- package/dist/tools/workflows/materialize-node-type.tool.js.map +1 -0
- package/dist/tools/workflows/publish-workflow.tool.d.ts +24 -0
- package/dist/tools/workflows/publish-workflow.tool.js +92 -0
- package/dist/tools/workflows/publish-workflow.tool.js.map +1 -0
- package/dist/tools/workflows/resolve-credentials.d.ts +14 -0
- package/dist/tools/workflows/resolve-credentials.js +89 -0
- package/dist/tools/workflows/resolve-credentials.js.map +1 -0
- package/dist/tools/workflows/restore-workflow-version.tool.d.ts +22 -0
- package/dist/tools/workflows/restore-workflow-version.tool.js +65 -0
- package/dist/tools/workflows/restore-workflow-version.tool.js.map +1 -0
- package/dist/tools/workflows/setup-workflow.schema.d.ts +331 -0
- package/dist/tools/workflows/setup-workflow.schema.js +21 -0
- package/dist/tools/workflows/setup-workflow.schema.js.map +1 -0
- package/dist/tools/workflows/setup-workflow.service.d.ts +40 -0
- package/dist/tools/workflows/setup-workflow.service.js +470 -0
- package/dist/tools/workflows/setup-workflow.service.js.map +1 -0
- package/dist/tools/workflows/setup-workflow.tool.d.ts +150 -0
- package/dist/tools/workflows/setup-workflow.tool.js +219 -0
- package/dist/tools/workflows/setup-workflow.tool.js.map +1 -0
- package/dist/tools/workflows/submit-workflow.tool.d.ts +33 -0
- package/dist/tools/workflows/submit-workflow.tool.js +258 -0
- package/dist/tools/workflows/submit-workflow.tool.js.map +1 -0
- package/dist/tools/workflows/unpublish-workflow.tool.d.ts +22 -0
- package/dist/tools/workflows/unpublish-workflow.tool.js +61 -0
- package/dist/tools/workflows/unpublish-workflow.tool.js.map +1 -0
- package/dist/tools/workflows/update-workflow-version.tool.d.ts +9 -0
- package/dist/tools/workflows/update-workflow-version.tool.js +35 -0
- package/dist/tools/workflows/update-workflow-version.tool.js.map +1 -0
- package/dist/tools/workflows/write-sandbox-file.tool.d.ts +13 -0
- package/dist/tools/workflows/write-sandbox-file.tool.js +53 -0
- package/dist/tools/workflows/write-sandbox-file.tool.js.map +1 -0
- package/dist/tools/workspace/cleanup-test-executions.tool.d.ts +22 -0
- package/dist/tools/workspace/cleanup-test-executions.tool.js +58 -0
- package/dist/tools/workspace/cleanup-test-executions.tool.js.map +1 -0
- package/dist/tools/workspace/create-folder.tool.d.ts +24 -0
- package/dist/tools/workspace/create-folder.tool.js +59 -0
- package/dist/tools/workspace/create-folder.tool.js.map +1 -0
- package/dist/tools/workspace/delete-folder.tool.d.ts +24 -0
- package/dist/tools/workspace/delete-folder.tool.js +60 -0
- package/dist/tools/workspace/delete-folder.tool.js.map +1 -0
- package/dist/tools/workspace/list-folders.tool.d.ts +6 -0
- package/dist/tools/workspace/list-folders.tool.js +26 -0
- package/dist/tools/workspace/list-folders.tool.js.map +1 -0
- package/dist/tools/workspace/list-projects.tool.d.ts +4 -0
- package/dist/tools/workspace/list-projects.tool.js +24 -0
- package/dist/tools/workspace/list-projects.tool.js.map +1 -0
- package/dist/tools/workspace/list-tags.tool.d.ts +7 -0
- package/dist/tools/workspace/list-tags.tool.js +23 -0
- package/dist/tools/workspace/list-tags.tool.js.map +1 -0
- package/dist/tools/workspace/move-workflow-to-folder.tool.d.ts +23 -0
- package/dist/tools/workspace/move-workflow-to-folder.tool.js +56 -0
- package/dist/tools/workspace/move-workflow-to-folder.tool.js.map +1 -0
- package/dist/tools/workspace/tag-workflow.tool.d.ts +22 -0
- package/dist/tools/workspace/tag-workflow.tool.js +52 -0
- package/dist/tools/workspace/tag-workflow.tool.js.map +1 -0
- package/dist/tracing/langsmith-tracing.d.ts +56 -0
- package/dist/tracing/langsmith-tracing.js +810 -0
- package/dist/tracing/langsmith-tracing.js.map +1 -0
- package/dist/types.d.ts +709 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/agent-tree.d.ts +3 -0
- package/dist/utils/agent-tree.js +23 -0
- package/dist/utils/agent-tree.js.map +1 -0
- package/dist/utils/format-timestamp.d.ts +1 -0
- package/dist/utils/format-timestamp.js +19 -0
- package/dist/utils/format-timestamp.js.map +1 -0
- package/dist/utils/stream-helpers.d.ts +15 -0
- package/dist/utils/stream-helpers.js +26 -0
- package/dist/utils/stream-helpers.js.map +1 -0
- package/dist/workflow-builder/extract-code.d.ts +5 -0
- package/dist/workflow-builder/extract-code.js +105 -0
- package/dist/workflow-builder/extract-code.js.map +1 -0
- package/dist/workflow-builder/index.d.ts +5 -0
- package/dist/workflow-builder/index.js +19 -0
- package/dist/workflow-builder/index.js.map +1 -0
- package/dist/workflow-builder/parse-validate.d.ts +6 -0
- package/dist/workflow-builder/parse-validate.js +49 -0
- package/dist/workflow-builder/parse-validate.js.map +1 -0
- package/dist/workflow-builder/patch-code.d.ts +14 -0
- package/dist/workflow-builder/patch-code.js +117 -0
- package/dist/workflow-builder/patch-code.js.map +1 -0
- package/dist/workflow-builder/sdk-prompt-sections.d.ts +4 -0
- package/dist/workflow-builder/sdk-prompt-sections.js +517 -0
- package/dist/workflow-builder/sdk-prompt-sections.js.map +1 -0
- package/dist/workflow-builder/types.d.ts +11 -0
- package/dist/workflow-builder/types.js +3 -0
- package/dist/workflow-builder/types.js.map +1 -0
- package/dist/workflow-loop/guidance.d.ts +5 -0
- package/dist/workflow-loop/guidance.js +37 -0
- package/dist/workflow-loop/guidance.js.map +1 -0
- package/dist/workflow-loop/index.d.ts +5 -0
- package/dist/workflow-loop/index.js +25 -0
- package/dist/workflow-loop/index.js.map +1 -0
- package/dist/workflow-loop/runtime.d.ts +8 -0
- package/dist/workflow-loop/runtime.js +40 -0
- package/dist/workflow-loop/runtime.js.map +1 -0
- package/dist/workflow-loop/workflow-loop-controller.d.ts +11 -0
- package/dist/workflow-loop/workflow-loop-controller.js +212 -0
- package/dist/workflow-loop/workflow-loop-controller.js.map +1 -0
- package/dist/workflow-loop/workflow-loop-state.d.ts +189 -0
- package/dist/workflow-loop/workflow-loop-state.js +77 -0
- package/dist/workflow-loop/workflow-loop-state.js.map +1 -0
- package/dist/workflow-loop/workflow-task-service.d.ts +13 -0
- package/dist/workflow-loop/workflow-task-service.js +35 -0
- package/dist/workflow-loop/workflow-task-service.js.map +1 -0
- package/dist/workspace/builder-sandbox-factory.d.ts +25 -0
- package/dist/workspace/builder-sandbox-factory.js +199 -0
- package/dist/workspace/builder-sandbox-factory.js.map +1 -0
- package/dist/workspace/create-workspace.d.ts +33 -0
- package/dist/workspace/create-workspace.js +56 -0
- package/dist/workspace/create-workspace.js.map +1 -0
- package/dist/workspace/daytona-filesystem.d.ts +25 -0
- package/dist/workspace/daytona-filesystem.js +109 -0
- package/dist/workspace/daytona-filesystem.js.map +1 -0
- package/dist/workspace/n8n-sandbox-client.d.ts +105 -0
- package/dist/workspace/n8n-sandbox-client.js +335 -0
- package/dist/workspace/n8n-sandbox-client.js.map +1 -0
- package/dist/workspace/n8n-sandbox-filesystem.d.ts +25 -0
- package/dist/workspace/n8n-sandbox-filesystem.js +128 -0
- package/dist/workspace/n8n-sandbox-filesystem.js.map +1 -0
- package/dist/workspace/n8n-sandbox-image-manager.d.ts +5 -0
- package/dist/workspace/n8n-sandbox-image-manager.js +25 -0
- package/dist/workspace/n8n-sandbox-image-manager.js.map +1 -0
- package/dist/workspace/n8n-sandbox-sandbox.d.ts +27 -0
- package/dist/workspace/n8n-sandbox-sandbox.js +103 -0
- package/dist/workspace/n8n-sandbox-sandbox.js.map +1 -0
- package/dist/workspace/sandbox-fs.d.ts +9 -0
- package/dist/workspace/sandbox-fs.js +43 -0
- package/dist/workspace/sandbox-fs.js.map +1 -0
- package/dist/workspace/sandbox-setup.d.ts +11 -0
- package/dist/workspace/sandbox-setup.js +139 -0
- package/dist/workspace/sandbox-setup.js.map +1 -0
- package/dist/workspace/snapshot-manager.d.ts +8 -0
- package/dist/workspace/snapshot-manager.js +31 -0
- package/dist/workspace/snapshot-manager.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.categories = void 0;
|
|
4
|
+
exports.categories = [
|
|
5
|
+
'AI',
|
|
6
|
+
'AI Chatbot',
|
|
7
|
+
'AI RAG',
|
|
8
|
+
'AI Summarization',
|
|
9
|
+
'Content Creation',
|
|
10
|
+
'CRM',
|
|
11
|
+
'Crypto Trading',
|
|
12
|
+
'DevOps',
|
|
13
|
+
'Document Extraction',
|
|
14
|
+
'Document Ops',
|
|
15
|
+
'Engineering',
|
|
16
|
+
'File Management',
|
|
17
|
+
'HR',
|
|
18
|
+
'Internal Wiki',
|
|
19
|
+
'Invoice Processing',
|
|
20
|
+
'IT Ops',
|
|
21
|
+
'Lead Generation',
|
|
22
|
+
'Lead Nurturing',
|
|
23
|
+
'Marketing',
|
|
24
|
+
'Market Research',
|
|
25
|
+
'Miscellaneous',
|
|
26
|
+
'Multimodal AI',
|
|
27
|
+
'Other',
|
|
28
|
+
'Personal Productivity',
|
|
29
|
+
'Project Management',
|
|
30
|
+
'Sales',
|
|
31
|
+
'SecOps',
|
|
32
|
+
'Social Media',
|
|
33
|
+
'Support',
|
|
34
|
+
'Support Chatbot',
|
|
35
|
+
'Ticket Management',
|
|
36
|
+
];
|
|
37
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/tools/templates/types.ts"],"names":[],"mappings":";;;AA0Ca,QAAA,UAAU,GAAG;IACzB,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,kBAAkB;IAClB,kBAAkB;IAClB,KAAK;IACL,gBAAgB;IAChB,QAAQ;IACR,qBAAqB;IACrB,cAAc;IACd,aAAa;IACb,iBAAiB;IACjB,IAAI;IACJ,eAAe;IACf,oBAAoB;IACpB,QAAQ;IACR,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;IACX,iBAAiB;IACjB,eAAe;IACf,eAAe;IACf,OAAO;IACP,uBAAuB;IACvB,oBAAoB;IACpB,OAAO;IACP,QAAQ;IACR,cAAc;IACd,SAAS;IACT,iBAAiB;IACjB,mBAAmB;CACV,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TemplateConnections, TemplateNode, WorkflowMetadata } from '../templates/types';
|
|
2
|
+
export interface MermaidWorkflowInput {
|
|
3
|
+
workflow: {
|
|
4
|
+
name?: string;
|
|
5
|
+
nodes: TemplateNode[];
|
|
6
|
+
connections: TemplateConnections;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface MermaidOptions {
|
|
10
|
+
includeNodeType?: boolean;
|
|
11
|
+
includeNodeParameters?: boolean;
|
|
12
|
+
includeNodeName?: boolean;
|
|
13
|
+
includeNodeId?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function mermaidStringify(input: WorkflowMetadata | MermaidWorkflowInput, options?: MermaidOptions): string;
|
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mermaidStringify = mermaidStringify;
|
|
4
|
+
const DEFAULT_MERMAID_OPTIONS = {
|
|
5
|
+
includeNodeType: true,
|
|
6
|
+
includeNodeParameters: true,
|
|
7
|
+
includeNodeName: true,
|
|
8
|
+
includeNodeId: true,
|
|
9
|
+
};
|
|
10
|
+
const CONDITIONAL_NODE_TYPES = new Set([
|
|
11
|
+
'n8n-nodes-base.if',
|
|
12
|
+
'n8n-nodes-base.switch',
|
|
13
|
+
'n8n-nodes-base.filter',
|
|
14
|
+
]);
|
|
15
|
+
const AGENT_NODE_TYPE = '@n8n/n8n-nodes-langchain.agent';
|
|
16
|
+
const STICKY_NOTE_TYPE = 'n8n-nodes-base.stickyNote';
|
|
17
|
+
const DEFAULT_NODE_WIDTH = 100;
|
|
18
|
+
const DEFAULT_NODE_HEIGHT = 100;
|
|
19
|
+
const DEFAULT_STICKY_WIDTH = 150;
|
|
20
|
+
const DEFAULT_STICKY_HEIGHT = 80;
|
|
21
|
+
class MermaidBuilder {
|
|
22
|
+
nodes;
|
|
23
|
+
connections;
|
|
24
|
+
options;
|
|
25
|
+
nodeIdMap;
|
|
26
|
+
nodeByName;
|
|
27
|
+
stickyOverlaps;
|
|
28
|
+
agentSubgraphs;
|
|
29
|
+
nodesInSubgraphs;
|
|
30
|
+
definedNodes = new Set();
|
|
31
|
+
lines = [];
|
|
32
|
+
subgraphCounter = 0;
|
|
33
|
+
constructor(nodes, connections, options) {
|
|
34
|
+
const regularNodes = nodes.filter((n) => n.type !== STICKY_NOTE_TYPE);
|
|
35
|
+
const stickyNotes = nodes.filter((n) => n.type === STICKY_NOTE_TYPE);
|
|
36
|
+
this.nodes = regularNodes;
|
|
37
|
+
this.connections = connections;
|
|
38
|
+
this.options = options;
|
|
39
|
+
this.nodeIdMap = this.createNodeIdMap();
|
|
40
|
+
this.nodeByName = new Map(regularNodes.map((n) => [n.name, n]));
|
|
41
|
+
this.stickyOverlaps = this.categorizeStickyOverlaps(stickyNotes);
|
|
42
|
+
const nodesInStickySubgraphs = new Set();
|
|
43
|
+
for (const { nodeNames } of this.stickyOverlaps.multiNodeOverlap) {
|
|
44
|
+
for (const name of nodeNames) {
|
|
45
|
+
nodesInStickySubgraphs.add(name);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
this.agentSubgraphs = this.findAgentSubgraphs(nodesInStickySubgraphs);
|
|
49
|
+
this.nodesInSubgraphs = new Set(nodesInStickySubgraphs);
|
|
50
|
+
for (const { agentNode, aiConnectedNodeNames } of this.agentSubgraphs) {
|
|
51
|
+
this.nodesInSubgraphs.add(agentNode.name);
|
|
52
|
+
for (const name of aiConnectedNodeNames) {
|
|
53
|
+
this.nodesInSubgraphs.add(name);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
build() {
|
|
58
|
+
for (const sticky of this.stickyOverlaps.noOverlap) {
|
|
59
|
+
this.lines.push(this.formatStickyComment(sticky.content));
|
|
60
|
+
}
|
|
61
|
+
this.buildMainFlow();
|
|
62
|
+
this.buildStickySubgraphs();
|
|
63
|
+
this.buildAgentSubgraphs();
|
|
64
|
+
this.buildConnectionsToSubgraphs();
|
|
65
|
+
this.buildConnectionsFromSubgraphs();
|
|
66
|
+
this.buildInterSubgraphConnections();
|
|
67
|
+
return ['```mermaid', 'flowchart TD', ...this.lines, '```'];
|
|
68
|
+
}
|
|
69
|
+
createNodeIdMap() {
|
|
70
|
+
const map = new Map();
|
|
71
|
+
this.nodes.forEach((node, idx) => {
|
|
72
|
+
map.set(node.name, `n${idx + 1}`);
|
|
73
|
+
});
|
|
74
|
+
return map;
|
|
75
|
+
}
|
|
76
|
+
categorizeStickyOverlaps(stickyNotes) {
|
|
77
|
+
const result = {
|
|
78
|
+
noOverlap: [],
|
|
79
|
+
singleNodeOverlap: new Map(),
|
|
80
|
+
multiNodeOverlap: [],
|
|
81
|
+
};
|
|
82
|
+
for (const sticky of stickyNotes) {
|
|
83
|
+
const bounds = this.extractStickyBounds(sticky);
|
|
84
|
+
if (!bounds.content)
|
|
85
|
+
continue;
|
|
86
|
+
const overlappingNodes = this.nodes.filter((node) => this.isNodeWithinStickyBounds(node.position[0], node.position[1], bounds));
|
|
87
|
+
if (overlappingNodes.length === 0) {
|
|
88
|
+
result.noOverlap.push(bounds);
|
|
89
|
+
}
|
|
90
|
+
else if (overlappingNodes.length === 1) {
|
|
91
|
+
result.singleNodeOverlap.set(overlappingNodes[0].name, bounds);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
result.multiNodeOverlap.push({
|
|
95
|
+
sticky: bounds,
|
|
96
|
+
nodeNames: overlappingNodes.map((n) => n.name),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
extractStickyBounds(node) {
|
|
103
|
+
return {
|
|
104
|
+
node,
|
|
105
|
+
x: node.position[0],
|
|
106
|
+
y: node.position[1],
|
|
107
|
+
width: typeof node.parameters.width === 'number' ? node.parameters.width : DEFAULT_STICKY_WIDTH,
|
|
108
|
+
height: typeof node.parameters.height === 'number' ? node.parameters.height : DEFAULT_STICKY_HEIGHT,
|
|
109
|
+
content: typeof node.parameters.content === 'string' ? node.parameters.content.trim() : '',
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
isNodeWithinStickyBounds(nodeX, nodeY, sticky) {
|
|
113
|
+
const nodeCenterX = nodeX + DEFAULT_NODE_WIDTH / 2;
|
|
114
|
+
const nodeCenterY = nodeY + DEFAULT_NODE_HEIGHT / 2;
|
|
115
|
+
return (nodeCenterX >= sticky.x &&
|
|
116
|
+
nodeCenterX <= sticky.x + sticky.width &&
|
|
117
|
+
nodeCenterY >= sticky.y &&
|
|
118
|
+
nodeCenterY <= sticky.y + sticky.height);
|
|
119
|
+
}
|
|
120
|
+
findAgentSubgraphs(nodesInStickySubgraphs) {
|
|
121
|
+
const agentSubgraphs = [];
|
|
122
|
+
const agentNodes = this.nodes.filter((n) => n.type === AGENT_NODE_TYPE && !nodesInStickySubgraphs.has(n.name));
|
|
123
|
+
const reverseConnections = this.buildReverseConnectionMap();
|
|
124
|
+
for (const agentNode of agentNodes) {
|
|
125
|
+
const incomingConns = reverseConnections.get(agentNode.name) ?? [];
|
|
126
|
+
const aiConnectedNodeNames = incomingConns
|
|
127
|
+
.filter(({ connType, sourceName }) => connType !== 'main' && !nodesInStickySubgraphs.has(sourceName))
|
|
128
|
+
.map(({ sourceName }) => sourceName);
|
|
129
|
+
const nestedStickySubgraphs = this.findNestedStickySubgraphs(incomingConns);
|
|
130
|
+
if (aiConnectedNodeNames.length > 0 || nestedStickySubgraphs.length > 0) {
|
|
131
|
+
agentSubgraphs.push({ agentNode, aiConnectedNodeNames, nestedStickySubgraphs });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return agentSubgraphs;
|
|
135
|
+
}
|
|
136
|
+
findNestedStickySubgraphs(incomingConns) {
|
|
137
|
+
const nested = [];
|
|
138
|
+
for (const stickySubgraph of this.stickyOverlaps.multiNodeOverlap) {
|
|
139
|
+
const allNodesConnectToAgent = stickySubgraph.nodeNames.every((nodeName) => incomingConns.some(({ sourceName, connType }) => sourceName === nodeName && connType !== 'main'));
|
|
140
|
+
if (allNodesConnectToAgent) {
|
|
141
|
+
nested.push(stickySubgraph);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return nested;
|
|
145
|
+
}
|
|
146
|
+
buildReverseConnectionMap() {
|
|
147
|
+
const reverseConnections = new Map();
|
|
148
|
+
for (const [sourceName, sourceConns] of Object.entries(this.connections)) {
|
|
149
|
+
for (const { nodeName: targetName, connType } of this.getConnectionTargets(sourceConns)) {
|
|
150
|
+
if (!reverseConnections.has(targetName)) {
|
|
151
|
+
reverseConnections.set(targetName, []);
|
|
152
|
+
}
|
|
153
|
+
reverseConnections.get(targetName).push({ sourceName, connType });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return reverseConnections;
|
|
157
|
+
}
|
|
158
|
+
getConnectionTargets(nodeConns) {
|
|
159
|
+
const targets = [];
|
|
160
|
+
for (const [connType, connList] of Object.entries(nodeConns)) {
|
|
161
|
+
for (const connArray of connList) {
|
|
162
|
+
if (!connArray)
|
|
163
|
+
continue;
|
|
164
|
+
for (const conn of connArray) {
|
|
165
|
+
targets.push({ nodeName: conn.node, connType });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return targets;
|
|
170
|
+
}
|
|
171
|
+
getMainConnectionTargets(nodeConns) {
|
|
172
|
+
if (!nodeConns.main)
|
|
173
|
+
return [];
|
|
174
|
+
return nodeConns.main
|
|
175
|
+
.filter((connArray) => connArray !== null)
|
|
176
|
+
.flatMap((connArray) => connArray.map((conn) => conn.node));
|
|
177
|
+
}
|
|
178
|
+
findStartNodes() {
|
|
179
|
+
const nodesWithIncoming = new Set();
|
|
180
|
+
Object.values(this.connections)
|
|
181
|
+
.filter((conn) => conn.main)
|
|
182
|
+
.forEach((sourceConnections) => {
|
|
183
|
+
for (const connArray of sourceConnections.main) {
|
|
184
|
+
if (!connArray)
|
|
185
|
+
continue;
|
|
186
|
+
for (const conn of connArray) {
|
|
187
|
+
nodesWithIncoming.add(conn.node);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return this.nodes.filter((n) => !nodesWithIncoming.has(n.name));
|
|
192
|
+
}
|
|
193
|
+
formatStickyComment(content) {
|
|
194
|
+
return `%% ${content.replace(/\n/g, ' ').replace(/\s+/g, ' ').trim()}`;
|
|
195
|
+
}
|
|
196
|
+
getNextSubgraphId() {
|
|
197
|
+
this.subgraphCounter++;
|
|
198
|
+
return `sg${this.subgraphCounter}`;
|
|
199
|
+
}
|
|
200
|
+
buildNodeDefinition(node, id) {
|
|
201
|
+
const isConditional = CONDITIONAL_NODE_TYPES.has(node.type);
|
|
202
|
+
if (this.options.includeNodeName) {
|
|
203
|
+
const escapedName = node.name.replace(/"/g, "'");
|
|
204
|
+
return isConditional ? `${id}{"${escapedName}"}` : `${id}["${escapedName}"]`;
|
|
205
|
+
}
|
|
206
|
+
return id;
|
|
207
|
+
}
|
|
208
|
+
buildNodeCommentLines(node) {
|
|
209
|
+
const lines = [];
|
|
210
|
+
if (this.options.includeNodeType ||
|
|
211
|
+
this.options.includeNodeParameters ||
|
|
212
|
+
this.options.includeNodeId) {
|
|
213
|
+
const idPart = this.options.includeNodeId && node.id ? `[${node.id}] ` : '';
|
|
214
|
+
const typePart = this.options.includeNodeType ? this.buildNodeTypePart(node) : '';
|
|
215
|
+
const paramsPart = this.options.includeNodeParameters && Object.keys(node.parameters).length > 0
|
|
216
|
+
? ` | ${JSON.stringify(node.parameters)}`
|
|
217
|
+
: '';
|
|
218
|
+
if (idPart || typePart || paramsPart) {
|
|
219
|
+
lines.push(`%% ${idPart}${typePart}${paramsPart}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return lines;
|
|
223
|
+
}
|
|
224
|
+
buildNodeTypePart(node) {
|
|
225
|
+
const parts = [node.type];
|
|
226
|
+
if (typeof node.parameters.resource === 'string' && node.parameters.resource) {
|
|
227
|
+
parts.push(node.parameters.resource);
|
|
228
|
+
}
|
|
229
|
+
if (typeof node.parameters.operation === 'string' && node.parameters.operation) {
|
|
230
|
+
parts.push(node.parameters.operation);
|
|
231
|
+
}
|
|
232
|
+
return parts.join(':');
|
|
233
|
+
}
|
|
234
|
+
buildSingleNodeLines(node, id) {
|
|
235
|
+
const lines = this.buildNodeCommentLines(node);
|
|
236
|
+
lines.push(this.buildNodeDefinition(node, id));
|
|
237
|
+
return lines;
|
|
238
|
+
}
|
|
239
|
+
defineNodeIfNeeded(nodeName) {
|
|
240
|
+
const node = this.nodeByName.get(nodeName);
|
|
241
|
+
const id = this.nodeIdMap.get(nodeName);
|
|
242
|
+
if (!node || !id)
|
|
243
|
+
return id ?? '';
|
|
244
|
+
if (!this.definedNodes.has(nodeName)) {
|
|
245
|
+
this.definedNodes.add(nodeName);
|
|
246
|
+
const stickyForNode = this.stickyOverlaps.singleNodeOverlap.get(nodeName);
|
|
247
|
+
if (stickyForNode) {
|
|
248
|
+
this.lines.push(this.formatStickyComment(stickyForNode.content));
|
|
249
|
+
}
|
|
250
|
+
this.lines.push(...this.buildNodeCommentLines(node));
|
|
251
|
+
return this.buildNodeDefinition(node, id);
|
|
252
|
+
}
|
|
253
|
+
return id;
|
|
254
|
+
}
|
|
255
|
+
defineTargetAndConnect(sourceId, targetName, connType) {
|
|
256
|
+
const targetId = this.nodeIdMap.get(targetName);
|
|
257
|
+
if (!targetId)
|
|
258
|
+
return false;
|
|
259
|
+
if (!this.definedNodes.has(targetName)) {
|
|
260
|
+
const targetNode = this.nodeByName.get(targetName);
|
|
261
|
+
if (targetNode) {
|
|
262
|
+
const stickyForNode = this.stickyOverlaps.singleNodeOverlap.get(targetName);
|
|
263
|
+
if (stickyForNode) {
|
|
264
|
+
this.lines.push(this.formatStickyComment(stickyForNode.content));
|
|
265
|
+
}
|
|
266
|
+
this.lines.push(...this.buildNodeCommentLines(targetNode));
|
|
267
|
+
this.addConnection(sourceId, this.buildNodeDefinition(targetNode, targetId), connType);
|
|
268
|
+
this.definedNodes.add(targetName);
|
|
269
|
+
return connType === 'main';
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
this.addConnection(sourceId, targetId, connType);
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
addConnection(sourceId, targetDef, connType) {
|
|
278
|
+
const arrow = connType === 'main' ? '-->' : `-.${connType}.->`;
|
|
279
|
+
this.lines.push(`${sourceId} ${arrow} ${targetDef}`);
|
|
280
|
+
}
|
|
281
|
+
buildMainFlow() {
|
|
282
|
+
const visited = new Set();
|
|
283
|
+
const startNodes = this.findStartNodes();
|
|
284
|
+
const traverse = (nodeName) => {
|
|
285
|
+
if (visited.has(nodeName))
|
|
286
|
+
return;
|
|
287
|
+
visited.add(nodeName);
|
|
288
|
+
const nodeConns = this.connections[nodeName];
|
|
289
|
+
const targets = nodeConns ? this.getConnectionTargets(nodeConns) : [];
|
|
290
|
+
for (const { nodeName: targetName, connType } of targets) {
|
|
291
|
+
if (this.nodesInSubgraphs.has(targetName) || this.nodesInSubgraphs.has(nodeName))
|
|
292
|
+
continue;
|
|
293
|
+
const sourceId = this.nodeIdMap.get(nodeName);
|
|
294
|
+
const targetDef = this.defineNodeIfNeeded(targetName);
|
|
295
|
+
if (sourceId) {
|
|
296
|
+
this.addConnection(sourceId, targetDef, connType);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (nodeConns) {
|
|
300
|
+
this.getMainConnectionTargets(nodeConns)
|
|
301
|
+
.filter((target) => !this.nodesInSubgraphs.has(target))
|
|
302
|
+
.forEach((target) => traverse(target));
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
for (const startNode of startNodes) {
|
|
306
|
+
if (this.nodesInSubgraphs.has(startNode.name))
|
|
307
|
+
continue;
|
|
308
|
+
const id = this.nodeIdMap.get(startNode.name);
|
|
309
|
+
if (id && !this.definedNodes.has(startNode.name)) {
|
|
310
|
+
const stickyForNode = this.stickyOverlaps.singleNodeOverlap.get(startNode.name);
|
|
311
|
+
if (stickyForNode) {
|
|
312
|
+
this.lines.push(this.formatStickyComment(stickyForNode.content));
|
|
313
|
+
}
|
|
314
|
+
this.lines.push(...this.buildSingleNodeLines(startNode, id));
|
|
315
|
+
this.definedNodes.add(startNode.name);
|
|
316
|
+
}
|
|
317
|
+
traverse(startNode.name);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
buildStickySubgraphs() {
|
|
321
|
+
const nestedStickyIds = this.getNestedStickyIds();
|
|
322
|
+
for (const { sticky, nodeNames } of this.stickyOverlaps.multiNodeOverlap) {
|
|
323
|
+
if (nestedStickyIds.has(sticky.node.id ?? ''))
|
|
324
|
+
continue;
|
|
325
|
+
this.buildSingleStickySubgraph(sticky, nodeNames);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
getNestedStickyIds() {
|
|
329
|
+
const ids = new Set();
|
|
330
|
+
for (const { nestedStickySubgraphs } of this.agentSubgraphs) {
|
|
331
|
+
for (const { sticky } of nestedStickySubgraphs) {
|
|
332
|
+
ids.add(sticky.node.id ?? '');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return ids;
|
|
336
|
+
}
|
|
337
|
+
buildSingleStickySubgraph(sticky, nodeNames) {
|
|
338
|
+
const subgraphId = this.getNextSubgraphId();
|
|
339
|
+
const subgraphLabel = sticky.content.replace(/\n/g, ' ').replace(/\s+/g, ' ').trim();
|
|
340
|
+
this.lines.push(this.formatStickyComment(sticky.content));
|
|
341
|
+
this.lines.push(`subgraph ${subgraphId}["${subgraphLabel.replace(/"/g, "'")}"]`);
|
|
342
|
+
const subgraphNodeSet = new Set(nodeNames);
|
|
343
|
+
const subgraphDefinedNodes = new Set();
|
|
344
|
+
const startNodes = this.findSubgraphStartNodes(nodeNames, subgraphNodeSet);
|
|
345
|
+
for (const startNode of startNodes) {
|
|
346
|
+
const id = this.nodeIdMap.get(startNode.name);
|
|
347
|
+
if (id && !subgraphDefinedNodes.has(startNode.name)) {
|
|
348
|
+
this.lines.push(...this.buildSingleNodeLines(startNode, id));
|
|
349
|
+
subgraphDefinedNodes.add(startNode.name);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
this.buildSubgraphInternalConnections(startNodes, subgraphNodeSet, subgraphDefinedNodes);
|
|
353
|
+
for (const name of nodeNames) {
|
|
354
|
+
this.definedNodes.add(name);
|
|
355
|
+
}
|
|
356
|
+
this.lines.push('end');
|
|
357
|
+
}
|
|
358
|
+
findSubgraphStartNodes(nodeNames, subgraphNodeSet) {
|
|
359
|
+
const nodesWithInternalIncoming = new Set();
|
|
360
|
+
for (const nodeName of nodeNames) {
|
|
361
|
+
const nodeConns = this.connections[nodeName];
|
|
362
|
+
if (!nodeConns)
|
|
363
|
+
continue;
|
|
364
|
+
for (const { nodeName: targetName } of this.getConnectionTargets(nodeConns)) {
|
|
365
|
+
if (subgraphNodeSet.has(targetName)) {
|
|
366
|
+
nodesWithInternalIncoming.add(targetName);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return nodeNames
|
|
371
|
+
.filter((name) => !nodesWithInternalIncoming.has(name))
|
|
372
|
+
.map((name) => this.nodeByName.get(name))
|
|
373
|
+
.filter((node) => node !== undefined);
|
|
374
|
+
}
|
|
375
|
+
buildSubgraphInternalConnections(startNodes, subgraphNodeSet, subgraphDefinedNodes) {
|
|
376
|
+
const visited = new Set();
|
|
377
|
+
const traverse = (nodeName) => {
|
|
378
|
+
if (visited.has(nodeName))
|
|
379
|
+
return;
|
|
380
|
+
visited.add(nodeName);
|
|
381
|
+
const nodeConns = this.connections[nodeName];
|
|
382
|
+
if (!nodeConns)
|
|
383
|
+
return;
|
|
384
|
+
const sourceId = this.nodeIdMap.get(nodeName);
|
|
385
|
+
if (!sourceId)
|
|
386
|
+
return;
|
|
387
|
+
for (const { nodeName: targetName, connType } of this.getConnectionTargets(nodeConns)) {
|
|
388
|
+
if (!subgraphNodeSet.has(targetName))
|
|
389
|
+
continue;
|
|
390
|
+
const targetId = this.nodeIdMap.get(targetName);
|
|
391
|
+
const targetNode = this.nodeByName.get(targetName);
|
|
392
|
+
if (!targetId || !targetNode)
|
|
393
|
+
continue;
|
|
394
|
+
const arrow = connType === 'main' ? '-->' : `-.${connType}.->`;
|
|
395
|
+
if (!subgraphDefinedNodes.has(targetName)) {
|
|
396
|
+
this.lines.push(...this.buildNodeCommentLines(targetNode));
|
|
397
|
+
this.lines.push(`${sourceId} ${arrow} ${this.buildNodeDefinition(targetNode, targetId)}`);
|
|
398
|
+
subgraphDefinedNodes.add(targetName);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
this.lines.push(`${sourceId} ${arrow} ${targetId}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
this.getMainConnectionTargets(nodeConns)
|
|
405
|
+
.filter((t) => subgraphNodeSet.has(t))
|
|
406
|
+
.forEach((t) => traverse(t));
|
|
407
|
+
};
|
|
408
|
+
startNodes.forEach((n) => traverse(n.name));
|
|
409
|
+
}
|
|
410
|
+
buildAgentSubgraphs() {
|
|
411
|
+
for (const agentSubgraph of this.agentSubgraphs) {
|
|
412
|
+
this.buildSingleAgentSubgraph(agentSubgraph);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
buildSingleAgentSubgraph(agentSubgraph) {
|
|
416
|
+
const { agentNode, aiConnectedNodeNames, nestedStickySubgraphs } = agentSubgraph;
|
|
417
|
+
const agentId = this.nodeIdMap.get(agentNode.name);
|
|
418
|
+
if (!agentId)
|
|
419
|
+
return;
|
|
420
|
+
const subgraphId = this.getNextSubgraphId();
|
|
421
|
+
this.lines.push(`subgraph ${subgraphId}["${agentNode.name.replace(/"/g, "'")}"]`);
|
|
422
|
+
for (const nodeName of aiConnectedNodeNames) {
|
|
423
|
+
this.defineAgentConnectedNode(nodeName);
|
|
424
|
+
}
|
|
425
|
+
for (const { sticky, nodeNames } of nestedStickySubgraphs) {
|
|
426
|
+
this.buildNestedStickySubgraph(sticky, nodeNames);
|
|
427
|
+
}
|
|
428
|
+
this.buildAgentNodeConnections(agentNode, agentId, aiConnectedNodeNames, nestedStickySubgraphs);
|
|
429
|
+
this.markAgentSubgraphNodesDefined(agentNode, aiConnectedNodeNames, nestedStickySubgraphs);
|
|
430
|
+
this.lines.push('end');
|
|
431
|
+
}
|
|
432
|
+
defineAgentConnectedNode(nodeName) {
|
|
433
|
+
const node = this.nodeByName.get(nodeName);
|
|
434
|
+
const id = this.nodeIdMap.get(nodeName);
|
|
435
|
+
if (!node || !id)
|
|
436
|
+
return;
|
|
437
|
+
const stickyForNode = this.stickyOverlaps.singleNodeOverlap.get(nodeName);
|
|
438
|
+
if (stickyForNode) {
|
|
439
|
+
this.lines.push(this.formatStickyComment(stickyForNode.content));
|
|
440
|
+
}
|
|
441
|
+
this.lines.push(...this.buildSingleNodeLines(node, id));
|
|
442
|
+
}
|
|
443
|
+
buildNestedStickySubgraph(sticky, nodeNames) {
|
|
444
|
+
const nestedSubgraphId = this.getNextSubgraphId();
|
|
445
|
+
const label = sticky.content.replace(/\n/g, ' ').replace(/\s+/g, ' ').trim();
|
|
446
|
+
this.lines.push(this.formatStickyComment(sticky.content));
|
|
447
|
+
this.lines.push(`subgraph ${nestedSubgraphId}["${label.replace(/"/g, "'")}"]`);
|
|
448
|
+
for (const nodeName of nodeNames) {
|
|
449
|
+
const node = this.nodeByName.get(nodeName);
|
|
450
|
+
const id = this.nodeIdMap.get(nodeName);
|
|
451
|
+
if (node && id) {
|
|
452
|
+
this.lines.push(...this.buildSingleNodeLines(node, id));
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
this.lines.push('end');
|
|
456
|
+
}
|
|
457
|
+
buildAgentNodeConnections(agentNode, agentId, aiConnectedNodeNames, nestedStickySubgraphs) {
|
|
458
|
+
const stickyForAgent = this.stickyOverlaps.singleNodeOverlap.get(agentNode.name);
|
|
459
|
+
if (stickyForAgent) {
|
|
460
|
+
this.lines.push(this.formatStickyComment(stickyForAgent.content));
|
|
461
|
+
}
|
|
462
|
+
this.lines.push(...this.buildNodeCommentLines(agentNode));
|
|
463
|
+
const allAiNodeNames = [
|
|
464
|
+
...aiConnectedNodeNames,
|
|
465
|
+
...nestedStickySubgraphs.flatMap(({ nodeNames }) => nodeNames),
|
|
466
|
+
];
|
|
467
|
+
let agentDefined = false;
|
|
468
|
+
for (const nodeName of allAiNodeNames) {
|
|
469
|
+
const sourceId = this.nodeIdMap.get(nodeName);
|
|
470
|
+
const nodeConns = this.connections[nodeName];
|
|
471
|
+
if (!sourceId || !nodeConns)
|
|
472
|
+
continue;
|
|
473
|
+
for (const { nodeName: targetName, connType } of this.getConnectionTargets(nodeConns)) {
|
|
474
|
+
if (targetName !== agentNode.name || connType === 'main')
|
|
475
|
+
continue;
|
|
476
|
+
const arrow = `-.${connType}.->`;
|
|
477
|
+
if (!agentDefined) {
|
|
478
|
+
this.lines.push(`${sourceId} ${arrow} ${this.buildNodeDefinition(agentNode, agentId)}`);
|
|
479
|
+
agentDefined = true;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
this.lines.push(`${sourceId} ${arrow} ${agentId}`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
if (!agentDefined) {
|
|
487
|
+
this.lines.push(this.buildNodeDefinition(agentNode, agentId));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
markAgentSubgraphNodesDefined(agentNode, aiConnectedNodeNames, nestedStickySubgraphs) {
|
|
491
|
+
for (const name of aiConnectedNodeNames) {
|
|
492
|
+
this.definedNodes.add(name);
|
|
493
|
+
}
|
|
494
|
+
for (const { nodeNames } of nestedStickySubgraphs) {
|
|
495
|
+
for (const name of nodeNames) {
|
|
496
|
+
this.definedNodes.add(name);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
this.definedNodes.add(agentNode.name);
|
|
500
|
+
}
|
|
501
|
+
buildConnectionsToSubgraphs() {
|
|
502
|
+
for (const nodeName of this.definedNodes) {
|
|
503
|
+
if (this.nodesInSubgraphs.has(nodeName))
|
|
504
|
+
continue;
|
|
505
|
+
const nodeConns = this.connections[nodeName];
|
|
506
|
+
if (!nodeConns)
|
|
507
|
+
continue;
|
|
508
|
+
for (const { nodeName: targetName, connType } of this.getConnectionTargets(nodeConns)) {
|
|
509
|
+
if (this.nodesInSubgraphs.has(targetName)) {
|
|
510
|
+
const sourceId = this.nodeIdMap.get(nodeName);
|
|
511
|
+
const targetId = this.nodeIdMap.get(targetName);
|
|
512
|
+
if (sourceId && targetId) {
|
|
513
|
+
this.addConnection(sourceId, targetId, connType);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
buildConnectionsFromSubgraphs() {
|
|
520
|
+
const nodesToProcess = [];
|
|
521
|
+
for (const nodeName of this.nodesInSubgraphs) {
|
|
522
|
+
const nodeConns = this.connections[nodeName];
|
|
523
|
+
if (!nodeConns)
|
|
524
|
+
continue;
|
|
525
|
+
const sourceId = this.nodeIdMap.get(nodeName);
|
|
526
|
+
if (!sourceId)
|
|
527
|
+
continue;
|
|
528
|
+
for (const { nodeName: targetName, connType } of this.getConnectionTargets(nodeConns)) {
|
|
529
|
+
if (this.nodesInSubgraphs.has(targetName))
|
|
530
|
+
continue;
|
|
531
|
+
const wasNewMainConnection = this.defineTargetAndConnect(sourceId, targetName, connType);
|
|
532
|
+
if (wasNewMainConnection) {
|
|
533
|
+
nodesToProcess.push(targetName);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
this.continueTraversalFromNodes(nodesToProcess);
|
|
538
|
+
}
|
|
539
|
+
continueTraversalFromNodes(nodesToProcess) {
|
|
540
|
+
const visited = new Set();
|
|
541
|
+
const traverse = (nodeName) => {
|
|
542
|
+
if (visited.has(nodeName) || this.nodesInSubgraphs.has(nodeName))
|
|
543
|
+
return;
|
|
544
|
+
visited.add(nodeName);
|
|
545
|
+
const nodeConns = this.connections[nodeName];
|
|
546
|
+
if (!nodeConns)
|
|
547
|
+
return;
|
|
548
|
+
const sourceId = this.nodeIdMap.get(nodeName);
|
|
549
|
+
if (!sourceId)
|
|
550
|
+
return;
|
|
551
|
+
for (const { nodeName: targetName, connType } of this.getConnectionTargets(nodeConns)) {
|
|
552
|
+
if (this.nodesInSubgraphs.has(targetName)) {
|
|
553
|
+
const targetId = this.nodeIdMap.get(targetName);
|
|
554
|
+
if (targetId) {
|
|
555
|
+
this.addConnection(sourceId, targetId, connType);
|
|
556
|
+
}
|
|
557
|
+
continue;
|
|
558
|
+
}
|
|
559
|
+
this.defineTargetAndConnect(sourceId, targetName, connType);
|
|
560
|
+
}
|
|
561
|
+
this.getMainConnectionTargets(nodeConns)
|
|
562
|
+
.filter((t) => !this.nodesInSubgraphs.has(t))
|
|
563
|
+
.forEach((t) => traverse(t));
|
|
564
|
+
};
|
|
565
|
+
nodesToProcess.forEach((n) => traverse(n));
|
|
566
|
+
}
|
|
567
|
+
buildInterSubgraphConnections() {
|
|
568
|
+
const nestedStickyIds = this.getNestedStickyIds();
|
|
569
|
+
const outputConnections = new Set();
|
|
570
|
+
for (const nodeName of this.nodesInSubgraphs) {
|
|
571
|
+
const nodeConns = this.connections[nodeName];
|
|
572
|
+
if (!nodeConns)
|
|
573
|
+
continue;
|
|
574
|
+
for (const { nodeName: targetName, connType } of this.getConnectionTargets(nodeConns)) {
|
|
575
|
+
if (!this.nodesInSubgraphs.has(targetName))
|
|
576
|
+
continue;
|
|
577
|
+
if (this.isInNestedSticky(nodeName, nestedStickyIds))
|
|
578
|
+
continue;
|
|
579
|
+
if (this.isInNestedSticky(targetName, nestedStickyIds))
|
|
580
|
+
continue;
|
|
581
|
+
const sourceSubgraphId = this.getSubgraphId(nodeName, nestedStickyIds);
|
|
582
|
+
const targetSubgraphId = this.getSubgraphId(targetName, nestedStickyIds);
|
|
583
|
+
if (sourceSubgraphId === targetSubgraphId)
|
|
584
|
+
continue;
|
|
585
|
+
const sourceId = this.nodeIdMap.get(nodeName);
|
|
586
|
+
const targetId = this.nodeIdMap.get(targetName);
|
|
587
|
+
if (!sourceId || !targetId)
|
|
588
|
+
continue;
|
|
589
|
+
const connKey = `${sourceId}-${connType}-${targetId}`;
|
|
590
|
+
if (outputConnections.has(connKey))
|
|
591
|
+
continue;
|
|
592
|
+
outputConnections.add(connKey);
|
|
593
|
+
this.addConnection(sourceId, targetId, connType);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
isInNestedSticky(nodeName, nestedStickyIds) {
|
|
598
|
+
return this.stickyOverlaps.multiNodeOverlap.some(({ sticky, nodeNames }) => nodeNames.includes(nodeName) && nestedStickyIds.has(sticky.node.id ?? ''));
|
|
599
|
+
}
|
|
600
|
+
getSubgraphId(nodeName, nestedStickyIds) {
|
|
601
|
+
const stickySubgraph = this.stickyOverlaps.multiNodeOverlap.find(({ sticky, nodeNames }) => nodeNames.includes(nodeName) && !nestedStickyIds.has(sticky.node.id ?? ''));
|
|
602
|
+
if (stickySubgraph) {
|
|
603
|
+
return `sticky:${stickySubgraph.sticky.node.id}`;
|
|
604
|
+
}
|
|
605
|
+
const agentSubgraph = this.agentSubgraphs.find(({ agentNode, aiConnectedNodeNames }) => agentNode.name === nodeName || aiConnectedNodeNames.includes(nodeName));
|
|
606
|
+
if (agentSubgraph) {
|
|
607
|
+
return `agent:${agentSubgraph.agentNode.id}`;
|
|
608
|
+
}
|
|
609
|
+
return 'none';
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
function mermaidStringify(input, options) {
|
|
613
|
+
const { workflow: wf } = input;
|
|
614
|
+
const mergedOptions = {
|
|
615
|
+
...DEFAULT_MERMAID_OPTIONS,
|
|
616
|
+
...options,
|
|
617
|
+
};
|
|
618
|
+
const builder = new MermaidBuilder(wf.nodes, wf.connections, mergedOptions);
|
|
619
|
+
const lines = builder.build();
|
|
620
|
+
return lines.join('\n');
|
|
621
|
+
}
|
|
622
|
+
//# sourceMappingURL=mermaid.utils.js.map
|