@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,517 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WORKFLOW_SDK_PATTERNS = exports.WORKFLOW_RULES = exports.ADDITIONAL_FUNCTIONS = exports.EXPRESSION_REFERENCE = void 0;
|
|
4
|
+
const extract_code_1 = require("./extract-code");
|
|
5
|
+
exports.EXPRESSION_REFERENCE = `Available variables inside \`expr('{{ ... }}')\`:
|
|
6
|
+
|
|
7
|
+
- \`$json\` — current item's JSON data from the immediate predecessor node
|
|
8
|
+
- \`$('NodeName').item.json\` — access any node's output by name
|
|
9
|
+
- \`$input.first()\` — first item from immediate predecessor
|
|
10
|
+
- \`$input.all()\` — all items from immediate predecessor
|
|
11
|
+
- \`$input.item\` — current item being processed
|
|
12
|
+
- \`$binary\` — binary data of current item from immediate predecessor
|
|
13
|
+
- \`$now\` — current date/time (Luxon DateTime). Example: \`$now.toISO()\`
|
|
14
|
+
- \`$today\` — start of today (Luxon DateTime). Example: \`$today.plus(1, 'days')\`
|
|
15
|
+
- \`$itemIndex\` — index of current item being processed
|
|
16
|
+
- \`$runIndex\` — current run index
|
|
17
|
+
- \`$execution.id\` — unique execution ID
|
|
18
|
+
- \`$execution.mode\` — 'test' or 'production'
|
|
19
|
+
- \`$workflow.id\` — workflow ID
|
|
20
|
+
- \`$workflow.name\` — workflow name
|
|
21
|
+
|
|
22
|
+
String composition — variables MUST always be inside \`{{ }}\`, never outside as JS variables:
|
|
23
|
+
|
|
24
|
+
- \`expr('Hello {{ $json.name }}, welcome!')\` — variable embedded in text
|
|
25
|
+
- \`expr('Report for {{ $now.toFormat("MMMM d, yyyy") }} - {{ $json.title }}')\` — multiple variables with method call
|
|
26
|
+
- \`expr('{{ $json.firstName }} {{ $json.lastName }}')\` — combining multiple fields
|
|
27
|
+
- \`expr('Total: {{ $json.items.length }} items, updated {{ $now.toISO() }}')\` — expressions with method calls
|
|
28
|
+
- \`expr('Status: {{ $json.count > 0 ? "active" : "empty" }}')\` — inline ternary
|
|
29
|
+
|
|
30
|
+
Dynamic data from other nodes — \`$()\` MUST always be inside \`{{ }}\`, never used as plain JavaScript:
|
|
31
|
+
|
|
32
|
+
- WRONG: \`expr('{{ ' + JSON.stringify($('Source').all().map(i => i.json.name)) + ' }}')\` — $() outside {{ }}
|
|
33
|
+
- CORRECT: \`expr('{{ $("Source").all().map(i => ({ option: i.json.name })) }}')\` — $() inside {{ }}`;
|
|
34
|
+
exports.ADDITIONAL_FUNCTIONS = `Additional SDK functions:
|
|
35
|
+
|
|
36
|
+
- \`placeholder('hint')\` — marks a parameter value for user input. Use directly as the parameter value — never wrap in \`expr()\`, objects, or arrays.
|
|
37
|
+
Example: \`parameters: { url: placeholder('Your API URL (e.g. https://api.example.com/v1)') }\`
|
|
38
|
+
|
|
39
|
+
- \`sticky('content', nodes?, config?)\` — creates a sticky note on the canvas.
|
|
40
|
+
Example: \`sticky('## Data Processing', [httpNode, setNode], { color: 2 })\`
|
|
41
|
+
|
|
42
|
+
- \`.output(n)\` — selects a specific output index for multi-output nodes. IF and Switch have dedicated methods (\`onTrue/onFalse\`, \`onCase\`), but \`.output(n)\` works as a generic alternative.
|
|
43
|
+
Example: \`classifier.output(1).to(categoryB)\`
|
|
44
|
+
|
|
45
|
+
- \`.onError(handler)\` — connects a node's error output to a handler node. Requires \`onError: 'continueErrorOutput'\` in the node config.
|
|
46
|
+
Example: \`httpNode.onError(errorHandler)\` (with \`config: { onError: 'continueErrorOutput' }\`)
|
|
47
|
+
|
|
48
|
+
- Additional subnode factories (all follow the same pattern as \`languageModel()\` and \`tool()\`):
|
|
49
|
+
\`memory()\`, \`outputParser()\`, \`embeddings()\`, \`vectorStore()\`, \`retriever()\`, \`documentLoader()\`, \`textSplitter()\``;
|
|
50
|
+
exports.WORKFLOW_RULES = `Follow these rules strictly when generating workflows:
|
|
51
|
+
|
|
52
|
+
1. **Always use newCredential() for authentication**
|
|
53
|
+
- When a node needs credentials, always use \`newCredential('Name')\` in the credentials config
|
|
54
|
+
- NEVER use placeholder strings, fake API keys, or hardcoded auth values
|
|
55
|
+
- Example: \`credentials: { slackApi: newCredential('Slack Bot') }\`
|
|
56
|
+
- The credential type must match what the node expects
|
|
57
|
+
|
|
58
|
+
2. **Handle empty outputs with \`alwaysOutputData: true\`**
|
|
59
|
+
- Nodes that query data (Data Table get, Google Sheets lookup, HTTP Request, etc.) may return 0 items
|
|
60
|
+
- When a node returns 0 items, all downstream nodes are SKIPPED — the workflow chain breaks silently
|
|
61
|
+
- Set \`alwaysOutputData: true\` on any node whose output feeds downstream nodes and might return empty results
|
|
62
|
+
- Common cases: fresh/empty Data Tables, filtered queries, conditional lookups, API searches with no matches
|
|
63
|
+
- Example: \`config: { ..., alwaysOutputData: true }\`
|
|
64
|
+
|
|
65
|
+
3. **Use \`executeOnce: true\` for single-execution nodes**
|
|
66
|
+
- When a node receives N items but should only execute once (not N times), set \`executeOnce: true\`
|
|
67
|
+
- Common cases: sending a summary notification, generating a report, calling an API that doesn't need per-item execution
|
|
68
|
+
- Example: \`config: { ..., executeOnce: true }\``;
|
|
69
|
+
exports.WORKFLOW_SDK_PATTERNS = `<linear_chain>
|
|
70
|
+
\`\`\`javascript
|
|
71
|
+
${extract_code_1.SDK_IMPORT_STATEMENT}
|
|
72
|
+
|
|
73
|
+
// 1. Define all nodes first
|
|
74
|
+
const startTrigger = trigger({
|
|
75
|
+
type: 'n8n-nodes-base.manualTrigger',
|
|
76
|
+
version: 1,
|
|
77
|
+
config: { name: 'Start' }
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const fetchData = node({
|
|
81
|
+
type: 'n8n-nodes-base.httpRequest',
|
|
82
|
+
version: 4.3,
|
|
83
|
+
config: { name: 'Fetch Data', parameters: { method: 'GET', url: '...' } }
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const processData = node({
|
|
87
|
+
type: 'n8n-nodes-base.set',
|
|
88
|
+
version: 3.4,
|
|
89
|
+
config: { name: 'Process Data', parameters: {} }
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// 2. Compose workflow
|
|
93
|
+
export default workflow('id', 'name')
|
|
94
|
+
.add(startTrigger)
|
|
95
|
+
.to(fetchData)
|
|
96
|
+
.to(processData);
|
|
97
|
+
\`\`\`
|
|
98
|
+
|
|
99
|
+
</linear_chain>
|
|
100
|
+
|
|
101
|
+
<independent_sources>
|
|
102
|
+
When nodes return more than 1 item, chaining causes item multiplication: if Source A returns N items, a chained Source B runs N times instead of once.
|
|
103
|
+
|
|
104
|
+
**When to use \`executeOnce: true\`:**
|
|
105
|
+
- A node fetches data independently but is chained after another data source (prevents N×M multiplication)
|
|
106
|
+
- A node should summarize/aggregate all upstream items in a single call (e.g., AI summary, send one notification)
|
|
107
|
+
- A node calls an API that doesn't vary per input item
|
|
108
|
+
|
|
109
|
+
Fix with \`executeOnce: true\` (simplest) or parallel branches + Merge (when combining results):
|
|
110
|
+
|
|
111
|
+
\`\`\`javascript
|
|
112
|
+
// sourceA outputs 10 items. sourceB outputs 10 items.
|
|
113
|
+
// WRONG - processResults runs 100 times
|
|
114
|
+
// startTrigger.to(sourceA.to(sourceB.to(processResults)))
|
|
115
|
+
|
|
116
|
+
// FIX 1 - executeOnce: sourceB runs once regardless of input items
|
|
117
|
+
const sourceB = node({ ..., config: { ..., executeOnce: true } });
|
|
118
|
+
startTrigger.to(sourceA.to(sourceB.to(processResults)));
|
|
119
|
+
|
|
120
|
+
// FIX 2 - parallel branches + Merge (combine by position)
|
|
121
|
+
const combineResults = merge({
|
|
122
|
+
version: 3.2,
|
|
123
|
+
config: { name: 'Combine Results', parameters: { mode: 'combine', combineBy: 'combineByPosition' } }
|
|
124
|
+
});
|
|
125
|
+
export default workflow('id', 'name')
|
|
126
|
+
.add(startTrigger)
|
|
127
|
+
.to(sourceA.to(combineResults.input(0)))
|
|
128
|
+
.add(startTrigger)
|
|
129
|
+
.to(sourceB.to(combineResults.input(1)))
|
|
130
|
+
.add(combineResults)
|
|
131
|
+
.to(processResults);
|
|
132
|
+
|
|
133
|
+
// FIX 3 - parallel branches + Merge (append)
|
|
134
|
+
const allResults = merge({
|
|
135
|
+
version: 3.2,
|
|
136
|
+
config: { name: 'All Results', parameters: { mode: 'append' } }
|
|
137
|
+
});
|
|
138
|
+
export default workflow('id', 'name')
|
|
139
|
+
.add(startTrigger)
|
|
140
|
+
.to(sourceA.to(allResults.input(0)))
|
|
141
|
+
.add(startTrigger)
|
|
142
|
+
.to(sourceB.to(allResults.input(1)))
|
|
143
|
+
.add(allResults)
|
|
144
|
+
.to(processResults);
|
|
145
|
+
\`\`\`
|
|
146
|
+
|
|
147
|
+
</independent_sources>
|
|
148
|
+
|
|
149
|
+
<zero_item_safety>
|
|
150
|
+
Nodes that fetch or filter data may return 0 items, which stops the entire downstream chain.
|
|
151
|
+
Use \`alwaysOutputData: true\` on data-fetching nodes to ensure the chain continues with an empty item \`{json: {}}\`.
|
|
152
|
+
|
|
153
|
+
\`\`\`javascript
|
|
154
|
+
// Data Table might be empty (fresh table, no matching rows)
|
|
155
|
+
const getReflections = node({
|
|
156
|
+
type: 'n8n-nodes-base.dataTable',
|
|
157
|
+
version: 1.1,
|
|
158
|
+
config: {
|
|
159
|
+
name: 'Get Reflections',
|
|
160
|
+
alwaysOutputData: true, // Chain continues even if table is empty
|
|
161
|
+
parameters: { resource: 'row', operation: 'get', returnAll: true }
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Downstream Code node handles the empty case
|
|
166
|
+
const processData = node({
|
|
167
|
+
type: 'n8n-nodes-base.code',
|
|
168
|
+
version: 2,
|
|
169
|
+
config: {
|
|
170
|
+
name: 'Process Data',
|
|
171
|
+
parameters: {
|
|
172
|
+
mode: 'runOnceForAllItems',
|
|
173
|
+
jsCode: \\\`
|
|
174
|
+
const items = $input.all();
|
|
175
|
+
// items will be [{json: {}}] if upstream had no data
|
|
176
|
+
const hasData = items.length > 0 && Object.keys(items[0].json).length > 0;
|
|
177
|
+
// ... handle both cases
|
|
178
|
+
\\\`.trim()
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
\`\`\`
|
|
183
|
+
|
|
184
|
+
**When to use \`alwaysOutputData: true\`:**
|
|
185
|
+
- Data Table with \`operation: 'get'\` (table may be empty or freshly created)
|
|
186
|
+
- Any lookup/search/filter node whose result feeds into downstream processing
|
|
187
|
+
- HTTP Request that may return an empty array
|
|
188
|
+
|
|
189
|
+
**When NOT to use it:**
|
|
190
|
+
- Trigger nodes (they always produce output)
|
|
191
|
+
- Code nodes (handle empty input in your code logic instead)
|
|
192
|
+
- Nodes at the end of the chain (no downstream to protect)
|
|
193
|
+
|
|
194
|
+
</zero_item_safety>
|
|
195
|
+
|
|
196
|
+
<conditional_branching>
|
|
197
|
+
|
|
198
|
+
**CRITICAL:** Each branch defines a COMPLETE processing path. Chain multiple steps INSIDE the branch using .to().
|
|
199
|
+
|
|
200
|
+
\`\`\`javascript
|
|
201
|
+
// Assume other nodes are declared
|
|
202
|
+
const checkValid = ifElse({ version: 2.2, config: { name: 'Check Valid', parameters: {...} } });
|
|
203
|
+
|
|
204
|
+
export default workflow('id', 'name')
|
|
205
|
+
.add(startTrigger)
|
|
206
|
+
.to(checkValid
|
|
207
|
+
.onTrue(formatData.to(enrichData.to(saveToDb))) // Chain 3 nodes on true branch
|
|
208
|
+
.onFalse(logError));
|
|
209
|
+
\`\`\`
|
|
210
|
+
|
|
211
|
+
</conditional_branching>
|
|
212
|
+
|
|
213
|
+
<multi_way_routing>
|
|
214
|
+
|
|
215
|
+
\`\`\`javascript
|
|
216
|
+
// Assume other nodes are declared
|
|
217
|
+
const routeByPriority = switchCase({ version: 3.2, config: { name: 'Route by Priority', parameters: {...} } });
|
|
218
|
+
|
|
219
|
+
export default workflow('id', 'name')
|
|
220
|
+
.add(startTrigger)
|
|
221
|
+
.to(routeByPriority
|
|
222
|
+
.onCase(0, processUrgent.to(notifyTeam.to(escalate))) // Chain of 3 nodes
|
|
223
|
+
.onCase(1, processNormal)
|
|
224
|
+
.onCase(2, archive));
|
|
225
|
+
\`\`\`
|
|
226
|
+
|
|
227
|
+
</multi_way_routing>
|
|
228
|
+
|
|
229
|
+
<parallel_execution>
|
|
230
|
+
\`\`\`javascript
|
|
231
|
+
// First declare the Merge node using merge()
|
|
232
|
+
const combineResults = merge({
|
|
233
|
+
version: 3.2,
|
|
234
|
+
config: { name: 'Combine Results', parameters: { mode: 'combine' } }
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Declare branch nodes
|
|
238
|
+
const branch1 = node({ type: 'n8n-nodes-base.httpRequest', ... });
|
|
239
|
+
const branch2 = node({ type: 'n8n-nodes-base.httpRequest', ... });
|
|
240
|
+
const processResults = node({ type: 'n8n-nodes-base.set', ... });
|
|
241
|
+
|
|
242
|
+
// Connect branches to specific merge inputs using .input(n)
|
|
243
|
+
export default workflow('id', 'name')
|
|
244
|
+
.add(trigger({ ... }))
|
|
245
|
+
.to(branch1.to(combineResults.input(0))) // Connect to input 0
|
|
246
|
+
.add(trigger({ ... }))
|
|
247
|
+
.to(branch2.to(combineResults.input(1))) // Connect to input 1
|
|
248
|
+
.add(combineResults)
|
|
249
|
+
.to(processResults); // Process merged results
|
|
250
|
+
\`\`\`
|
|
251
|
+
|
|
252
|
+
</parallel_execution>
|
|
253
|
+
|
|
254
|
+
<batch_processing>
|
|
255
|
+
\`\`\`javascript
|
|
256
|
+
const startTrigger = trigger({
|
|
257
|
+
type: 'n8n-nodes-base.manualTrigger',
|
|
258
|
+
version: 1,
|
|
259
|
+
config: { name: 'Start' }
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
const fetchRecords = node({
|
|
263
|
+
type: 'n8n-nodes-base.httpRequest',
|
|
264
|
+
version: 4.3,
|
|
265
|
+
config: { name: 'Fetch Records', parameters: { method: 'GET', url: '...' } }
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const finalizeResults = node({
|
|
269
|
+
type: 'n8n-nodes-base.set',
|
|
270
|
+
version: 3.4,
|
|
271
|
+
config: { name: 'Finalize', parameters: {} }
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const processRecord = node({
|
|
275
|
+
type: 'n8n-nodes-base.httpRequest',
|
|
276
|
+
version: 4.3,
|
|
277
|
+
config: { name: 'Process Record', parameters: { method: 'POST', url: '...' } }
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const sibNode = splitInBatches({ version: 3, config: { name: 'Batch Process', parameters: { batchSize: 10 } } });
|
|
281
|
+
|
|
282
|
+
export default workflow('id', 'name')
|
|
283
|
+
.add(startTrigger)
|
|
284
|
+
.to(fetchRecords)
|
|
285
|
+
.to(sibNode
|
|
286
|
+
.onDone(finalizeResults)
|
|
287
|
+
.onEachBatch(processRecord.to(nextBatch(sibNode)))
|
|
288
|
+
);
|
|
289
|
+
\`\`\`
|
|
290
|
+
|
|
291
|
+
</batch_processing>
|
|
292
|
+
|
|
293
|
+
<multiple_triggers>
|
|
294
|
+
\`\`\`javascript
|
|
295
|
+
const webhookTrigger = trigger({
|
|
296
|
+
type: 'n8n-nodes-base.webhook',
|
|
297
|
+
version: 2.1,
|
|
298
|
+
config: { name: 'Webhook' }
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
const processWebhook = node({
|
|
302
|
+
type: 'n8n-nodes-base.set',
|
|
303
|
+
version: 3.4,
|
|
304
|
+
config: { name: 'Process Webhook', parameters: {} }
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
const scheduleTrigger = trigger({
|
|
308
|
+
type: 'n8n-nodes-base.scheduleTrigger',
|
|
309
|
+
version: 1.3,
|
|
310
|
+
config: { name: 'Daily Schedule', parameters: {} }
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
const processSchedule = node({
|
|
314
|
+
type: 'n8n-nodes-base.set',
|
|
315
|
+
version: 3.4,
|
|
316
|
+
config: { name: 'Process Schedule', parameters: {} }
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
export default workflow('id', 'name')
|
|
320
|
+
.add(webhookTrigger)
|
|
321
|
+
.to(processWebhook)
|
|
322
|
+
.add(scheduleTrigger)
|
|
323
|
+
.to(processSchedule);
|
|
324
|
+
\`\`\`
|
|
325
|
+
|
|
326
|
+
</multiple_triggers>
|
|
327
|
+
|
|
328
|
+
<fan_in>
|
|
329
|
+
\`\`\`javascript
|
|
330
|
+
// Each trigger's execution runs in COMPLETE ISOLATION.
|
|
331
|
+
// Different branches have no effect on each other.
|
|
332
|
+
// Never duplicate chains for "isolation" - it's already guaranteed.
|
|
333
|
+
|
|
334
|
+
const webhookTrigger = trigger({
|
|
335
|
+
type: 'n8n-nodes-base.webhook',
|
|
336
|
+
version: 2.1,
|
|
337
|
+
config: { name: 'Webhook Trigger' }
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const scheduleTrigger = trigger({
|
|
341
|
+
type: 'n8n-nodes-base.scheduleTrigger',
|
|
342
|
+
version: 1.3,
|
|
343
|
+
config: { name: 'Daily Schedule' }
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
const processData = node({
|
|
347
|
+
type: 'n8n-nodes-base.set',
|
|
348
|
+
version: 3.4,
|
|
349
|
+
config: { name: 'Process Data', parameters: {} }
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
const sendNotification = node({
|
|
353
|
+
type: 'n8n-nodes-base.slack',
|
|
354
|
+
version: 2.3,
|
|
355
|
+
config: { name: 'Notify Slack', parameters: {} }
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
export default workflow('id', 'name')
|
|
359
|
+
.add(webhookTrigger)
|
|
360
|
+
.to(processData)
|
|
361
|
+
.to(sendNotification)
|
|
362
|
+
.add(scheduleTrigger)
|
|
363
|
+
.to(processData);
|
|
364
|
+
\`\`\`
|
|
365
|
+
|
|
366
|
+
</fan_in>
|
|
367
|
+
|
|
368
|
+
<ai_agent_basic>
|
|
369
|
+
\`\`\`javascript
|
|
370
|
+
const openAiModel = languageModel({
|
|
371
|
+
type: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
|
|
372
|
+
version: 1.3,
|
|
373
|
+
config: { name: 'OpenAI Model', parameters: {} }
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const startTrigger = trigger({
|
|
377
|
+
type: 'n8n-nodes-base.manualTrigger',
|
|
378
|
+
version: 1,
|
|
379
|
+
config: { name: 'Start' }
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const aiAgent = node({
|
|
383
|
+
type: '@n8n/n8n-nodes-langchain.agent',
|
|
384
|
+
version: 3.1,
|
|
385
|
+
config: {
|
|
386
|
+
name: 'AI Assistant',
|
|
387
|
+
parameters: { promptType: 'define', text: 'You are a helpful assistant' },
|
|
388
|
+
subnodes: { model: openAiModel }
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
export default workflow('ai-assistant', 'AI Assistant')
|
|
393
|
+
.add(startTrigger)
|
|
394
|
+
.to(aiAgent);
|
|
395
|
+
\`\`\`
|
|
396
|
+
|
|
397
|
+
</ai_agent_basic>
|
|
398
|
+
|
|
399
|
+
<ai_agent_with_tools>
|
|
400
|
+
\`\`\`javascript
|
|
401
|
+
const openAiModel = languageModel({
|
|
402
|
+
type: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
|
|
403
|
+
version: 1.3,
|
|
404
|
+
config: {
|
|
405
|
+
name: 'OpenAI Model',
|
|
406
|
+
parameters: {},
|
|
407
|
+
credentials: { openAiApi: newCredential('OpenAI') }
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
const calculatorTool = tool({
|
|
412
|
+
type: '@n8n/n8n-nodes-langchain.toolCalculator',
|
|
413
|
+
version: 1,
|
|
414
|
+
config: { name: 'Calculator', parameters: {} }
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
const startTrigger = trigger({
|
|
418
|
+
type: 'n8n-nodes-base.manualTrigger',
|
|
419
|
+
version: 1,
|
|
420
|
+
config: { name: 'Start' }
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
const aiAgent = node({
|
|
424
|
+
type: '@n8n/n8n-nodes-langchain.agent',
|
|
425
|
+
version: 3.1,
|
|
426
|
+
config: {
|
|
427
|
+
name: 'Math Agent',
|
|
428
|
+
parameters: { promptType: 'define', text: 'You can use tools to help users' },
|
|
429
|
+
subnodes: { model: openAiModel, tools: [calculatorTool] }
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
export default workflow('ai-calculator', 'AI Calculator')
|
|
434
|
+
.add(startTrigger)
|
|
435
|
+
.to(aiAgent);
|
|
436
|
+
\`\`\`
|
|
437
|
+
|
|
438
|
+
</ai_agent_with_tools>
|
|
439
|
+
|
|
440
|
+
<ai_agent_with_from_ai>
|
|
441
|
+
\`\`\`javascript
|
|
442
|
+
const openAiModel = languageModel({
|
|
443
|
+
type: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
|
|
444
|
+
version: 1.3,
|
|
445
|
+
config: {
|
|
446
|
+
name: 'OpenAI Model',
|
|
447
|
+
parameters: {},
|
|
448
|
+
credentials: { openAiApi: newCredential('OpenAI') }
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
const gmailTool = tool({
|
|
453
|
+
type: 'n8n-nodes-base.gmailTool',
|
|
454
|
+
version: 1,
|
|
455
|
+
config: {
|
|
456
|
+
name: 'Gmail Tool',
|
|
457
|
+
parameters: {
|
|
458
|
+
sendTo: fromAi('recipient', 'Email address'),
|
|
459
|
+
subject: fromAi('subject', 'Email subject'),
|
|
460
|
+
message: fromAi('body', 'Email content')
|
|
461
|
+
},
|
|
462
|
+
credentials: { gmailOAuth2: newCredential('Gmail') }
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
const startTrigger = trigger({
|
|
467
|
+
type: 'n8n-nodes-base.manualTrigger',
|
|
468
|
+
version: 1,
|
|
469
|
+
config: { name: 'Start' }
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
const aiAgent = node({
|
|
473
|
+
type: '@n8n/n8n-nodes-langchain.agent',
|
|
474
|
+
version: 3.1,
|
|
475
|
+
config: {
|
|
476
|
+
name: 'Email Agent',
|
|
477
|
+
parameters: { promptType: 'define', text: 'You can send emails' },
|
|
478
|
+
subnodes: { model: openAiModel, tools: [gmailTool] }
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
export default workflow('ai-email', 'AI Email Sender')
|
|
483
|
+
.add(startTrigger)
|
|
484
|
+
.to(aiAgent);
|
|
485
|
+
\`\`\`
|
|
486
|
+
</ai_agent_with_from_ai>
|
|
487
|
+
|
|
488
|
+
<ai_agent_with_structured_output>
|
|
489
|
+
\`\`\`javascript
|
|
490
|
+
const structuredParser = outputParser({
|
|
491
|
+
type: '@n8n/n8n-nodes-langchain.outputParserStructured',
|
|
492
|
+
version: 1.3,
|
|
493
|
+
config: {
|
|
494
|
+
name: 'Structured Output Parser',
|
|
495
|
+
parameters: {
|
|
496
|
+
schemaType: 'fromJson',
|
|
497
|
+
jsonSchemaExample: '{ "sentiment": "positive", "confidence": 0.95, "summary": "brief summary" }'
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
const aiAgent = node({
|
|
503
|
+
type: '@n8n/n8n-nodes-langchain.agent',
|
|
504
|
+
version: 3.1,
|
|
505
|
+
config: {
|
|
506
|
+
name: 'Sentiment Analyzer',
|
|
507
|
+
parameters: { promptType: 'define', text: 'Analyze the sentiment of the input text', hasOutputParser: true },
|
|
508
|
+
subnodes: { model: openAiModel, outputParser: structuredParser }
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
export default workflow('ai-sentiment', 'AI Sentiment Analyzer')
|
|
513
|
+
.add(startTrigger)
|
|
514
|
+
.to(aiAgent);
|
|
515
|
+
\`\`\`
|
|
516
|
+
</ai_agent_with_structured_output>`;
|
|
517
|
+
//# sourceMappingURL=sdk-prompt-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-prompt-sections.js","sourceRoot":"","sources":["../../src/workflow-builder/sdk-prompt-sections.ts"],"names":[],"mappings":";;;AAOA,iDAAsD;AAKzC,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;sGA4BkE,CAAC;AAK1F,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;mIAe+F,CAAC;AAKvH,QAAA,cAAc,GAAG;;;;;;;;;;;;;;;;;;qDAkBuB,CAAC;AAKzC,QAAA,qBAAqB,GAAG;;EAEnC,mCAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCA6ba,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WorkflowJSON } from '@n8n/workflow-sdk';
|
|
2
|
+
export interface ValidationWarning {
|
|
3
|
+
code: string;
|
|
4
|
+
message: string;
|
|
5
|
+
nodeName?: string;
|
|
6
|
+
parameterPath?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ParseAndValidateResult {
|
|
9
|
+
workflow: WorkflowJSON;
|
|
10
|
+
warnings: ValidationWarning[];
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/workflow-builder/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatWorkflowLoopGuidance = formatWorkflowLoopGuidance;
|
|
4
|
+
function formatWorkflowLoopGuidance(action, options = {}) {
|
|
5
|
+
switch (action.type) {
|
|
6
|
+
case 'done': {
|
|
7
|
+
if (action.mockedCredentialTypes?.length) {
|
|
8
|
+
const types = action.mockedCredentialTypes.join(', ');
|
|
9
|
+
return ('Workflow verified successfully with temporary mock data. ' +
|
|
10
|
+
`Call \`setup-credentials\` with types [${types}] and ` +
|
|
11
|
+
'credentialFlow stage "finalize" to let the user add real credentials. ' +
|
|
12
|
+
'After the user selects credentials, call `apply-workflow-credentials` ' +
|
|
13
|
+
`with the workItemId "${options.workItemId ?? 'unknown'}" and workflowId to apply them.`);
|
|
14
|
+
}
|
|
15
|
+
return `Workflow verified successfully. Report completion to the user.${action.workflowId ? ` Workflow ID: ${action.workflowId}` : ''}`;
|
|
16
|
+
}
|
|
17
|
+
case 'verify':
|
|
18
|
+
return (`VERIFY: Run workflow ${action.workflowId}. ` +
|
|
19
|
+
`If the build had mocked credentials, use \`verify-built-workflow\` with workItemId "${options.workItemId ?? 'unknown'}". ` +
|
|
20
|
+
'Otherwise use `run-workflow`. ' +
|
|
21
|
+
'If it fails, use `debug-execution` to diagnose. ' +
|
|
22
|
+
`Then call \`report-verification-verdict\` with workItemId "${options.workItemId ?? 'unknown'}" and your findings.`);
|
|
23
|
+
case 'blocked':
|
|
24
|
+
return `BUILD BLOCKED: ${action.reason}. Explain this to the user and ask how to proceed.`;
|
|
25
|
+
case 'rebuild':
|
|
26
|
+
return (`REBUILD NEEDED: The workflow at ${action.workflowId} needs structural repair. ` +
|
|
27
|
+
'Submit a new `plan` with one `build-workflow` task. ' +
|
|
28
|
+
`In the task spec, explain that workflow "${action.workflowId}" needs structural repair and include these details: ${action.failureDetails}`);
|
|
29
|
+
case 'patch':
|
|
30
|
+
return (`PATCH NEEDED: Node "${action.failedNodeName}" in workflow ${action.workflowId} needs a targeted fix. ` +
|
|
31
|
+
`Diagnosis: ${action.diagnosis}. ` +
|
|
32
|
+
(action.patch ? `Suggested fix: ${JSON.stringify(action.patch)}. ` : '') +
|
|
33
|
+
'Submit a new `plan` with one `build-workflow` task. ' +
|
|
34
|
+
`In the task spec, set mode "patch", include workflowId "${action.workflowId}", and describe the targeted fix.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=guidance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guidance.js","sourceRoot":"","sources":["../../src/workflow-loop/guidance.ts"],"names":[],"mappings":";;AAMA,gEA2CC;AA3CD,SAAgB,0BAA0B,CACzC,MAA0B,EAC1B,UAAuC,EAAE;IAEzC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,MAAM,CAAC,CAAC,CAAC;YACb,IAAI,MAAM,CAAC,qBAAqB,EAAE,MAAM,EAAE,CAAC;gBAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtD,OAAO,CACN,2DAA2D;oBAC3D,0CAA0C,KAAK,QAAQ;oBACvD,wEAAwE;oBACxE,wEAAwE;oBACxE,wBAAwB,OAAO,CAAC,UAAU,IAAI,SAAS,iCAAiC,CACxF,CAAC;YACH,CAAC;YACD,OAAO,iEAAiE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACzI,CAAC;QACD,KAAK,QAAQ;YACZ,OAAO,CACN,wBAAwB,MAAM,CAAC,UAAU,IAAI;gBAC7C,uFAAuF,OAAO,CAAC,UAAU,IAAI,SAAS,KAAK;gBAC3H,gCAAgC;gBAChC,kDAAkD;gBAClD,8DAA8D,OAAO,CAAC,UAAU,IAAI,SAAS,sBAAsB,CACnH,CAAC;QACH,KAAK,SAAS;YACb,OAAO,kBAAkB,MAAM,CAAC,MAAM,oDAAoD,CAAC;QAC5F,KAAK,SAAS;YACb,OAAO,CACN,mCAAmC,MAAM,CAAC,UAAU,4BAA4B;gBAChF,sDAAsD;gBACtD,4CAA4C,MAAM,CAAC,UAAU,wDAAwD,MAAM,CAAC,cAAc,EAAE,CAC5I,CAAC;QACH,KAAK,OAAO;YACX,OAAO,CACN,uBAAuB,MAAM,CAAC,cAAc,iBAAiB,MAAM,CAAC,UAAU,yBAAyB;gBACvG,cAAc,MAAM,CAAC,SAAS,IAAI;gBAClC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxE,sDAAsD;gBACtD,2DAA2D,MAAM,CAAC,UAAU,mCAAmC,CAC/G,CAAC;IACJ,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { workflowLoopPhaseSchema, workflowLoopStatusSchema, workflowLoopSourceSchema, workflowLoopStateSchema, attemptActionSchema, attemptResultSchema, attemptRecordSchema, triggerTypeSchema, workflowBuildOutcomeSchema, verificationVerdictSchema, verificationResultSchema, } from './workflow-loop-state';
|
|
2
|
+
export type { WorkflowLoopPhase, WorkflowLoopStatus, WorkflowLoopSource, WorkflowLoopState, AttemptAction, AttemptResult, AttemptRecord, TriggerType, WorkflowBuildOutcome, VerificationVerdict, VerificationResult, WorkflowLoopAction, } from './workflow-loop-state';
|
|
3
|
+
export { createWorkItem, handleBuildOutcome, handleVerificationVerdict, formatAttemptHistory, } from './workflow-loop-controller';
|
|
4
|
+
export { formatWorkflowLoopGuidance } from './guidance';
|
|
5
|
+
export { WorkflowTaskCoordinator } from './workflow-task-service';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowTaskCoordinator = exports.formatWorkflowLoopGuidance = exports.formatAttemptHistory = exports.handleVerificationVerdict = exports.handleBuildOutcome = exports.createWorkItem = exports.verificationResultSchema = exports.verificationVerdictSchema = exports.workflowBuildOutcomeSchema = exports.triggerTypeSchema = exports.attemptRecordSchema = exports.attemptResultSchema = exports.attemptActionSchema = exports.workflowLoopStateSchema = exports.workflowLoopSourceSchema = exports.workflowLoopStatusSchema = exports.workflowLoopPhaseSchema = void 0;
|
|
4
|
+
var workflow_loop_state_1 = require("./workflow-loop-state");
|
|
5
|
+
Object.defineProperty(exports, "workflowLoopPhaseSchema", { enumerable: true, get: function () { return workflow_loop_state_1.workflowLoopPhaseSchema; } });
|
|
6
|
+
Object.defineProperty(exports, "workflowLoopStatusSchema", { enumerable: true, get: function () { return workflow_loop_state_1.workflowLoopStatusSchema; } });
|
|
7
|
+
Object.defineProperty(exports, "workflowLoopSourceSchema", { enumerable: true, get: function () { return workflow_loop_state_1.workflowLoopSourceSchema; } });
|
|
8
|
+
Object.defineProperty(exports, "workflowLoopStateSchema", { enumerable: true, get: function () { return workflow_loop_state_1.workflowLoopStateSchema; } });
|
|
9
|
+
Object.defineProperty(exports, "attemptActionSchema", { enumerable: true, get: function () { return workflow_loop_state_1.attemptActionSchema; } });
|
|
10
|
+
Object.defineProperty(exports, "attemptResultSchema", { enumerable: true, get: function () { return workflow_loop_state_1.attemptResultSchema; } });
|
|
11
|
+
Object.defineProperty(exports, "attemptRecordSchema", { enumerable: true, get: function () { return workflow_loop_state_1.attemptRecordSchema; } });
|
|
12
|
+
Object.defineProperty(exports, "triggerTypeSchema", { enumerable: true, get: function () { return workflow_loop_state_1.triggerTypeSchema; } });
|
|
13
|
+
Object.defineProperty(exports, "workflowBuildOutcomeSchema", { enumerable: true, get: function () { return workflow_loop_state_1.workflowBuildOutcomeSchema; } });
|
|
14
|
+
Object.defineProperty(exports, "verificationVerdictSchema", { enumerable: true, get: function () { return workflow_loop_state_1.verificationVerdictSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "verificationResultSchema", { enumerable: true, get: function () { return workflow_loop_state_1.verificationResultSchema; } });
|
|
16
|
+
var workflow_loop_controller_1 = require("./workflow-loop-controller");
|
|
17
|
+
Object.defineProperty(exports, "createWorkItem", { enumerable: true, get: function () { return workflow_loop_controller_1.createWorkItem; } });
|
|
18
|
+
Object.defineProperty(exports, "handleBuildOutcome", { enumerable: true, get: function () { return workflow_loop_controller_1.handleBuildOutcome; } });
|
|
19
|
+
Object.defineProperty(exports, "handleVerificationVerdict", { enumerable: true, get: function () { return workflow_loop_controller_1.handleVerificationVerdict; } });
|
|
20
|
+
Object.defineProperty(exports, "formatAttemptHistory", { enumerable: true, get: function () { return workflow_loop_controller_1.formatAttemptHistory; } });
|
|
21
|
+
var guidance_1 = require("./guidance");
|
|
22
|
+
Object.defineProperty(exports, "formatWorkflowLoopGuidance", { enumerable: true, get: function () { return guidance_1.formatWorkflowLoopGuidance; } });
|
|
23
|
+
var workflow_task_service_1 = require("./workflow-task-service");
|
|
24
|
+
Object.defineProperty(exports, "WorkflowTaskCoordinator", { enumerable: true, get: function () { return workflow_task_service_1.WorkflowTaskCoordinator; } });
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow-loop/index.ts"],"names":[],"mappings":";;;AAAA,6DAY+B;AAX9B,8HAAA,uBAAuB,OAAA;AACvB,+HAAA,wBAAwB,OAAA;AACxB,+HAAA,wBAAwB,OAAA;AACxB,8HAAA,uBAAuB,OAAA;AACvB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AACnB,wHAAA,iBAAiB,OAAA;AACjB,iIAAA,0BAA0B,OAAA;AAC1B,gIAAA,yBAAyB,OAAA;AACzB,+HAAA,wBAAwB,OAAA;AAkBzB,uEAKoC;AAJnC,0HAAA,cAAc,OAAA;AACd,8HAAA,kBAAkB,OAAA;AAClB,qIAAA,yBAAyB,OAAA;AACzB,gIAAA,oBAAoB,OAAA;AAGrB,uCAAwD;AAA/C,sHAAA,0BAA0B,OAAA;AACnC,iEAAkE;AAAzD,gIAAA,uBAAuB,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkflowBuildOutcome, VerificationResult, WorkflowLoopAction } from './workflow-loop-state';
|
|
2
|
+
import type { WorkflowLoopStorage } from '../storage/workflow-loop-storage';
|
|
3
|
+
export declare class WorkflowLoopRuntime {
|
|
4
|
+
private readonly storage;
|
|
5
|
+
constructor(storage: WorkflowLoopStorage);
|
|
6
|
+
applyBuildOutcome(threadId: string, outcome: WorkflowBuildOutcome): Promise<WorkflowLoopAction>;
|
|
7
|
+
applyVerificationVerdict(threadId: string, verdict: VerificationResult): Promise<WorkflowLoopAction>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowLoopRuntime = void 0;
|
|
4
|
+
const workflow_loop_controller_1 = require("./workflow-loop-controller");
|
|
5
|
+
function createInitialState(threadId, outcome) {
|
|
6
|
+
return {
|
|
7
|
+
workItemId: outcome.workItemId,
|
|
8
|
+
threadId,
|
|
9
|
+
workflowId: outcome.workflowId,
|
|
10
|
+
phase: 'building',
|
|
11
|
+
status: 'active',
|
|
12
|
+
source: outcome.workflowId ? 'modify' : 'create',
|
|
13
|
+
rebuildAttempts: 0,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
class WorkflowLoopRuntime {
|
|
17
|
+
storage;
|
|
18
|
+
constructor(storage) {
|
|
19
|
+
this.storage = storage;
|
|
20
|
+
}
|
|
21
|
+
async applyBuildOutcome(threadId, outcome) {
|
|
22
|
+
const existing = await this.storage.getWorkItem(threadId, outcome.workItemId);
|
|
23
|
+
const state = existing?.state ?? createInitialState(threadId, outcome);
|
|
24
|
+
const attempts = existing?.attempts ?? [];
|
|
25
|
+
const { state: newState, action, attempt } = (0, workflow_loop_controller_1.handleBuildOutcome)(state, attempts, outcome);
|
|
26
|
+
await this.storage.saveWorkItem(threadId, newState, [...attempts, attempt], outcome);
|
|
27
|
+
return action;
|
|
28
|
+
}
|
|
29
|
+
async applyVerificationVerdict(threadId, verdict) {
|
|
30
|
+
const existing = await this.storage.getWorkItem(threadId, verdict.workItemId);
|
|
31
|
+
if (!existing) {
|
|
32
|
+
return { type: 'blocked', reason: `Unknown work item: ${verdict.workItemId}` };
|
|
33
|
+
}
|
|
34
|
+
const { state: newState, action, attempt, } = (0, workflow_loop_controller_1.handleVerificationVerdict)(existing.state, existing.attempts, verdict);
|
|
35
|
+
await this.storage.saveWorkItem(threadId, newState, [...existing.attempts, attempt]);
|
|
36
|
+
return action;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.WorkflowLoopRuntime = WorkflowLoopRuntime;
|
|
40
|
+
//# sourceMappingURL=runtime.js.map
|