@n8n/instance-ai 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE_EE.md +27 -0
- package/dist/agent/instance-agent.js +17 -45
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/register-with-mastra.d.ts +1 -1
- package/dist/agent/register-with-mastra.js +5 -9
- package/dist/agent/register-with-mastra.js.map +1 -1
- package/dist/agent/sub-agent-briefing.d.ts +20 -0
- package/dist/agent/sub-agent-briefing.js +39 -0
- package/dist/agent/sub-agent-briefing.js.map +1 -0
- package/dist/agent/sub-agent-debriefing.d.ts +71 -0
- package/dist/agent/sub-agent-debriefing.js +39 -0
- package/dist/agent/sub-agent-debriefing.js.map +1 -0
- package/dist/agent/sub-agent-factory.d.ts +1 -1
- package/dist/agent/sub-agent-factory.js +15 -3
- package/dist/agent/sub-agent-factory.js.map +1 -1
- package/dist/agent/system-prompt.d.ts +1 -0
- package/dist/agent/system-prompt.js +67 -43
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/agent/tool-access.d.ts +2 -0
- package/dist/agent/tool-access.js +28 -0
- package/dist/agent/tool-access.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -1
- package/dist/domain-access/domain-gating.d.ts +1 -0
- package/dist/domain-access/domain-gating.js +3 -0
- package/dist/domain-access/domain-gating.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +15 -4
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +6 -0
- package/dist/logger.js +3 -0
- package/dist/logger.js.map +1 -0
- package/dist/memory/memory-config.js +1 -3
- package/dist/memory/memory-config.js.map +1 -1
- package/dist/parsers/structured-file-parser.d.ts +56 -0
- package/dist/parsers/structured-file-parser.js +354 -0
- package/dist/parsers/structured-file-parser.js.map +1 -0
- package/dist/planned-tasks/planned-task-permissions.d.ts +2 -0
- package/dist/planned-tasks/planned-task-permissions.js +27 -0
- package/dist/planned-tasks/planned-task-permissions.js.map +1 -0
- package/dist/planned-tasks/planned-task-service.js +6 -0
- package/dist/planned-tasks/planned-task-service.js.map +1 -1
- package/dist/runtime/background-task-manager.d.ts +2 -1
- package/dist/runtime/background-task-manager.js +13 -1
- package/dist/runtime/background-task-manager.js.map +1 -1
- package/dist/runtime/resumable-stream-executor.d.ts +8 -3
- package/dist/runtime/resumable-stream-executor.js +67 -120
- package/dist/runtime/resumable-stream-executor.js.map +1 -1
- package/dist/runtime/run-state-registry.d.ts +1 -0
- package/dist/runtime/run-state-registry.js.map +1 -1
- package/dist/runtime/stream-runner.d.ts +4 -2
- package/dist/runtime/stream-runner.js +5 -25
- package/dist/runtime/stream-runner.js.map +1 -1
- package/dist/stream/consume-with-hitl.d.ts +6 -1
- package/dist/stream/consume-with-hitl.js +12 -2
- package/dist/stream/consume-with-hitl.js.map +1 -1
- package/dist/stream/map-chunk.d.ts +1 -1
- package/dist/stream/map-chunk.js +35 -16
- package/dist/stream/map-chunk.js.map +1 -1
- package/dist/stream/work-summary-accumulator.d.ts +63 -0
- package/dist/stream/work-summary-accumulator.js +66 -0
- package/dist/stream/work-summary-accumulator.js.map +1 -0
- package/dist/tools/attachments/parse-file.tool.d.ts +90 -0
- package/dist/tools/attachments/parse-file.tool.js +135 -0
- package/dist/tools/attachments/parse-file.tool.js.map +1 -0
- package/dist/tools/best-practices/get-best-practices.tool.d.ts +6 -9
- package/dist/tools/best-practices/get-best-practices.tool.js +7 -5
- package/dist/tools/best-practices/get-best-practices.tool.js.map +1 -1
- package/dist/tools/best-practices/index.js +5 -29
- package/dist/tools/best-practices/index.js.map +1 -1
- package/dist/tools/best-practices/techniques.d.ts +1 -20
- package/dist/tools/best-practices/techniques.js +3 -36
- package/dist/tools/best-practices/techniques.js.map +1 -1
- package/dist/tools/credentials/delete-credential.tool.d.ts +13 -14
- package/dist/tools/credentials/delete-credential.tool.js +18 -11
- package/dist/tools/credentials/delete-credential.tool.js.map +1 -1
- package/dist/tools/credentials/get-credential.tool.d.ts +8 -2
- package/dist/tools/credentials/get-credential.tool.js +13 -7
- package/dist/tools/credentials/get-credential.tool.js.map +1 -1
- package/dist/tools/credentials/list-credentials.tool.d.ts +13 -3
- package/dist/tools/credentials/list-credentials.tool.js +50 -8
- package/dist/tools/credentials/list-credentials.tool.js.map +1 -1
- package/dist/tools/credentials/search-credential-types.tool.d.ts +7 -3
- package/dist/tools/credentials/search-credential-types.tool.js +7 -5
- package/dist/tools/credentials/search-credential-types.tool.js.map +1 -1
- package/dist/tools/credentials/setup-credentials.tool.d.ts +40 -44
- package/dist/tools/credentials/setup-credentials.tool.js +37 -31
- package/dist/tools/credentials/setup-credentials.tool.js.map +1 -1
- package/dist/tools/credentials/test-credential.tool.d.ts +7 -4
- package/dist/tools/credentials/test-credential.tool.js +5 -3
- package/dist/tools/credentials/test-credential.tool.js.map +1 -1
- package/dist/tools/data-tables/add-data-table-column.tool.d.ts +15 -19
- package/dist/tools/data-tables/add-data-table-column.tool.js +16 -9
- package/dist/tools/data-tables/add-data-table-column.tool.js.map +1 -1
- package/dist/tools/data-tables/create-data-table.tool.d.ts +26 -24
- package/dist/tools/data-tables/create-data-table.tool.js +49 -22
- package/dist/tools/data-tables/create-data-table.tool.js.map +1 -1
- package/dist/tools/data-tables/delete-data-table-column.tool.d.ts +13 -14
- package/dist/tools/data-tables/delete-data-table-column.tool.js +15 -8
- package/dist/tools/data-tables/delete-data-table-column.tool.js.map +1 -1
- package/dist/tools/data-tables/delete-data-table-rows.tool.d.ts +49 -15
- package/dist/tools/data-tables/delete-data-table-rows.tool.js +25 -9
- package/dist/tools/data-tables/delete-data-table-rows.tool.js.map +1 -1
- package/dist/tools/data-tables/delete-data-table.tool.d.ts +11 -14
- package/dist/tools/data-tables/delete-data-table.tool.js +17 -9
- package/dist/tools/data-tables/delete-data-table.tool.js.map +1 -1
- package/dist/tools/data-tables/get-data-table-schema.tool.d.ts +7 -8
- package/dist/tools/data-tables/get-data-table-schema.tool.js +5 -3
- package/dist/tools/data-tables/get-data-table-schema.tool.js.map +1 -1
- package/dist/tools/data-tables/insert-data-table-rows.tool.d.ts +14 -15
- package/dist/tools/data-tables/insert-data-table-rows.tool.js +22 -12
- package/dist/tools/data-tables/insert-data-table-rows.tool.js.map +1 -1
- package/dist/tools/data-tables/list-data-tables.tool.d.ts +7 -3
- package/dist/tools/data-tables/list-data-tables.tool.js +8 -6
- package/dist/tools/data-tables/list-data-tables.tool.js.map +1 -1
- package/dist/tools/data-tables/query-data-table-rows.tool.d.ts +49 -8
- package/dist/tools/data-tables/query-data-table-rows.tool.js +14 -12
- package/dist/tools/data-tables/query-data-table-rows.tool.js.map +1 -1
- package/dist/tools/data-tables/rename-data-table-column.tool.d.ts +15 -14
- package/dist/tools/data-tables/rename-data-table-column.tool.js +16 -9
- package/dist/tools/data-tables/rename-data-table-column.tool.js.map +1 -1
- package/dist/tools/data-tables/update-data-table-rows.tool.d.ts +51 -14
- package/dist/tools/data-tables/update-data-table-rows.tool.js +19 -9
- package/dist/tools/data-tables/update-data-table-rows.tool.js.map +1 -1
- package/dist/tools/executions/debug-execution.tool.d.ts +8 -2
- package/dist/tools/executions/debug-execution.tool.js +5 -3
- package/dist/tools/executions/debug-execution.tool.js.map +1 -1
- package/dist/tools/executions/get-execution.tool.d.ts +8 -2
- package/dist/tools/executions/get-execution.tool.js +5 -3
- package/dist/tools/executions/get-execution.tool.js.map +1 -1
- package/dist/tools/executions/get-node-output.tool.d.ts +14 -2
- package/dist/tools/executions/get-node-output.tool.js +14 -17
- package/dist/tools/executions/get-node-output.tool.js.map +1 -1
- package/dist/tools/executions/list-executions.tool.d.ts +11 -3
- package/dist/tools/executions/list-executions.tool.js +16 -14
- package/dist/tools/executions/list-executions.tool.js.map +1 -1
- package/dist/tools/executions/run-workflow.tool.d.ts +17 -15
- package/dist/tools/executions/run-workflow.tool.js +35 -25
- package/dist/tools/executions/run-workflow.tool.js.map +1 -1
- package/dist/tools/executions/stop-execution.tool.d.ts +7 -4
- package/dist/tools/executions/stop-execution.tool.js +8 -3
- package/dist/tools/executions/stop-execution.tool.js.map +1 -1
- package/dist/tools/filesystem/create-tools-from-mcp-server.js +77 -6
- package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
- package/dist/tools/index.d.ts +67 -2380
- package/dist/tools/index.js +9 -15
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nodes/explore-node-resources.tool.d.ts +23 -10
- package/dist/tools/nodes/explore-node-resources.tool.js +27 -25
- package/dist/tools/nodes/explore-node-resources.tool.js.map +1 -1
- package/dist/tools/nodes/get-node-description.tool.d.ts +7 -20
- package/dist/tools/nodes/get-node-description.tool.js +5 -3
- package/dist/tools/nodes/get-node-description.tool.js.map +1 -1
- package/dist/tools/nodes/get-node-type-definition.tool.d.ts +29 -6
- package/dist/tools/nodes/get-node-type-definition.tool.js +9 -7
- package/dist/tools/nodes/get-node-type-definition.tool.js.map +1 -1
- package/dist/tools/nodes/get-suggested-nodes.tool.d.ts +7 -12
- package/dist/tools/nodes/get-suggested-nodes.tool.js +9 -7
- package/dist/tools/nodes/get-suggested-nodes.tool.js.map +1 -1
- package/dist/tools/nodes/list-nodes.tool.d.ts +7 -3
- package/dist/tools/nodes/list-nodes.tool.js +8 -6
- package/dist/tools/nodes/list-nodes.tool.js.map +1 -1
- package/dist/tools/nodes/node-search-engine.d.ts +1 -0
- package/dist/tools/nodes/node-search-engine.js +12 -9
- package/dist/tools/nodes/node-search-engine.js.map +1 -1
- package/dist/tools/nodes/search-nodes.tool.d.ts +12 -24
- package/dist/tools/nodes/search-nodes.tool.js +21 -17
- package/dist/tools/nodes/search-nodes.tool.js.map +1 -1
- package/dist/tools/orchestration/add-plan-item.tool.d.ts +5 -0
- package/dist/tools/orchestration/add-plan-item.tool.js +91 -0
- package/dist/tools/orchestration/add-plan-item.tool.js.map +1 -0
- package/dist/tools/orchestration/blueprint-accumulator.d.ts +50 -0
- package/dist/tools/orchestration/blueprint-accumulator.js +215 -0
- package/dist/tools/orchestration/blueprint-accumulator.js.map +1 -0
- package/dist/tools/orchestration/blueprint.schema.d.ts +271 -0
- package/dist/tools/orchestration/blueprint.schema.js +61 -0
- package/dist/tools/orchestration/blueprint.schema.js.map +1 -0
- package/dist/tools/orchestration/browser-credential-setup.tool.d.ts +15 -12
- package/dist/tools/orchestration/browser-credential-setup.tool.js +27 -21
- package/dist/tools/orchestration/browser-credential-setup.tool.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.prompt.d.ts +1 -1
- package/dist/tools/orchestration/build-workflow-agent.prompt.js +43 -149
- package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +11 -4
- package/dist/tools/orchestration/build-workflow-agent.tool.js +52 -82
- package/dist/tools/orchestration/build-workflow-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/cancel-background-task.tool.d.ts +7 -3
- package/dist/tools/orchestration/cancel-background-task.tool.js +5 -3
- package/dist/tools/orchestration/cancel-background-task.tool.js.map +1 -1
- package/dist/tools/orchestration/correct-background-task.tool.d.ts +9 -3
- package/dist/tools/orchestration/correct-background-task.tool.js +8 -6
- package/dist/tools/orchestration/correct-background-task.tool.js.map +1 -1
- package/dist/tools/orchestration/data-table-agent.prompt.d.ts +1 -1
- package/dist/tools/orchestration/data-table-agent.prompt.js +20 -0
- package/dist/tools/orchestration/data-table-agent.prompt.js.map +1 -1
- package/dist/tools/orchestration/data-table-agent.tool.d.ts +9 -4
- package/dist/tools/orchestration/data-table-agent.tool.js +23 -25
- package/dist/tools/orchestration/data-table-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/delegate.schemas.d.ts +12 -0
- package/dist/tools/orchestration/delegate.schemas.js +17 -0
- package/dist/tools/orchestration/delegate.schemas.js.map +1 -1
- package/dist/tools/orchestration/delegate.tool.d.ts +1 -10
- package/dist/tools/orchestration/delegate.tool.js +42 -41
- package/dist/tools/orchestration/delegate.tool.js.map +1 -1
- package/dist/tools/orchestration/plan-agent-prompt.d.ts +1 -0
- package/dist/tools/orchestration/plan-agent-prompt.js +76 -0
- package/dist/tools/orchestration/plan-agent-prompt.js.map +1 -0
- package/dist/tools/orchestration/plan-with-agent.tool.d.ts +2 -0
- package/dist/tools/orchestration/plan-with-agent.tool.js +277 -0
- package/dist/tools/orchestration/plan-with-agent.tool.js.map +1 -0
- package/dist/tools/orchestration/plan.tool.d.ts +7 -39
- package/dist/tools/orchestration/plan.tool.js +15 -13
- package/dist/tools/orchestration/plan.tool.js.map +1 -1
- package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +23 -3
- package/dist/tools/orchestration/report-verification-verdict.tool.js +27 -28
- package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
- package/dist/tools/orchestration/research-with-agent.tool.d.ts +11 -4
- package/dist/tools/orchestration/research-with-agent.tool.js +26 -21
- package/dist/tools/orchestration/research-with-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/submit-plan.tool.d.ts +3 -0
- package/dist/tools/orchestration/submit-plan.tool.js +81 -0
- package/dist/tools/orchestration/submit-plan.tool.js.map +1 -0
- package/dist/tools/orchestration/update-tasks.tool.d.ts +1 -9
- package/dist/tools/orchestration/update-tasks.tool.js.map +1 -1
- package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +13 -7
- package/dist/tools/orchestration/verify-built-workflow.tool.js +14 -15
- package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
- package/dist/tools/shared/ask-user.tool.d.ts +42 -31
- package/dist/tools/shared/ask-user.tool.js +16 -15
- package/dist/tools/shared/ask-user.tool.js.map +1 -1
- package/dist/tools/templates/search-template-parameters.tool.d.ts +14 -7
- package/dist/tools/templates/search-template-parameters.tool.js +17 -15
- package/dist/tools/templates/search-template-parameters.tool.js.map +1 -1
- package/dist/tools/templates/search-template-structures.tool.d.ts +11 -8
- package/dist/tools/templates/search-template-structures.tool.js +13 -11
- package/dist/tools/templates/search-template-structures.tool.js.map +1 -1
- package/dist/tools/web-research/fetch-url.tool.d.ts +9 -23
- package/dist/tools/web-research/fetch-url.tool.js +30 -14
- package/dist/tools/web-research/fetch-url.tool.js.map +1 -1
- package/dist/tools/web-research/web-search.tool.d.ts +12 -2
- package/dist/tools/web-research/web-search.tool.js +20 -18
- package/dist/tools/web-research/web-search.tool.js.map +1 -1
- package/dist/tools/workflows/apply-workflow-credentials.tool.d.ts +11 -5
- package/dist/tools/workflows/apply-workflow-credentials.tool.js +7 -5
- package/dist/tools/workflows/apply-workflow-credentials.tool.js.map +1 -1
- package/dist/tools/workflows/build-workflow.tool.d.ts +26 -5
- package/dist/tools/workflows/build-workflow.tool.js +23 -20
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/delete-workflow.tool.d.ts +13 -14
- package/dist/tools/workflows/delete-workflow.tool.js +15 -11
- package/dist/tools/workflows/delete-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/get-workflow-as-code.tool.d.ts +6 -10
- package/dist/tools/workflows/get-workflow-as-code.tool.js +5 -3
- package/dist/tools/workflows/get-workflow-as-code.tool.js.map +1 -1
- package/dist/tools/workflows/get-workflow-version.tool.d.ts +8 -16
- package/dist/tools/workflows/get-workflow-version.tool.js +6 -4
- package/dist/tools/workflows/get-workflow-version.tool.js.map +1 -1
- package/dist/tools/workflows/get-workflow.tool.d.ts +7 -15
- package/dist/tools/workflows/get-workflow.tool.js +5 -3
- package/dist/tools/workflows/get-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/list-workflow-versions.tool.d.ts +11 -3
- package/dist/tools/workflows/list-workflow-versions.tool.js +13 -11
- package/dist/tools/workflows/list-workflow-versions.tool.js.map +1 -1
- package/dist/tools/workflows/list-workflows.tool.d.ts +9 -10
- package/dist/tools/workflows/list-workflows.tool.js +12 -10
- package/dist/tools/workflows/list-workflows.tool.js.map +1 -1
- package/dist/tools/workflows/materialize-node-type.tool.d.ts +29 -11
- package/dist/tools/workflows/materialize-node-type.tool.js +9 -7
- package/dist/tools/workflows/materialize-node-type.tool.js.map +1 -1
- package/dist/tools/workflows/publish-workflow.tool.d.ts +6 -20
- package/dist/tools/workflows/publish-workflow.tool.js +29 -24
- package/dist/tools/workflows/publish-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/restore-workflow-version.tool.d.ts +13 -15
- package/dist/tools/workflows/restore-workflow-version.tool.js +15 -8
- package/dist/tools/workflows/restore-workflow-version.tool.js.map +1 -1
- package/dist/tools/workflows/setup-workflow.service.d.ts +0 -1
- package/dist/tools/workflows/setup-workflow.service.js +23 -6
- package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
- package/dist/tools/workflows/setup-workflow.tool.d.ts +7 -144
- package/dist/tools/workflows/setup-workflow.tool.js +10 -14
- package/dist/tools/workflows/setup-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/submit-workflow.tool.d.ts +12 -9
- package/dist/tools/workflows/submit-workflow.tool.js +15 -17
- package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/unpublish-workflow.tool.d.ts +13 -15
- package/dist/tools/workflows/unpublish-workflow.tool.js +15 -11
- package/dist/tools/workflows/unpublish-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/update-workflow-version.tool.d.ts +13 -3
- package/dist/tools/workflows/update-workflow-version.tool.js +12 -10
- package/dist/tools/workflows/update-workflow-version.tool.js.map +1 -1
- package/dist/tools/workflows/write-sandbox-file.tool.d.ts +9 -9
- package/dist/tools/workflows/write-sandbox-file.tool.js +8 -6
- package/dist/tools/workflows/write-sandbox-file.tool.js.map +1 -1
- package/dist/tools/workspace/cleanup-test-executions.tool.d.ts +15 -14
- package/dist/tools/workspace/cleanup-test-executions.tool.js +19 -15
- package/dist/tools/workspace/cleanup-test-executions.tool.js.map +1 -1
- package/dist/tools/workspace/create-folder.tool.d.ts +15 -16
- package/dist/tools/workspace/create-folder.tool.js +25 -12
- package/dist/tools/workspace/create-folder.tool.js.map +1 -1
- package/dist/tools/workspace/delete-folder.tool.d.ts +19 -14
- package/dist/tools/workspace/delete-folder.tool.js +24 -17
- package/dist/tools/workspace/delete-folder.tool.js.map +1 -1
- package/dist/tools/workspace/list-folders.tool.d.ts +7 -3
- package/dist/tools/workspace/list-folders.tool.js +5 -3
- package/dist/tools/workspace/list-folders.tool.js.map +1 -1
- package/dist/tools/workspace/list-projects.tool.d.ts +3 -3
- package/dist/tools/workspace/list-projects.tool.js +3 -1
- package/dist/tools/workspace/list-projects.tool.js.map +1 -1
- package/dist/tools/workspace/list-tags.tool.d.ts +3 -6
- package/dist/tools/workspace/list-tags.tool.js +3 -1
- package/dist/tools/workspace/list-tags.tool.js.map +1 -1
- package/dist/tools/workspace/move-workflow-to-folder.tool.d.ts +17 -14
- package/dist/tools/workspace/move-workflow-to-folder.tool.js +20 -16
- package/dist/tools/workspace/move-workflow-to-folder.tool.js.map +1 -1
- package/dist/tools/workspace/tag-workflow.tool.d.ts +15 -14
- package/dist/tools/workspace/tag-workflow.tool.js +16 -12
- package/dist/tools/workspace/tag-workflow.tool.js.map +1 -1
- package/dist/tracing/langsmith-tracing.d.ts +1 -0
- package/dist/tracing/langsmith-tracing.js +47 -57
- package/dist/tracing/langsmith-tracing.js.map +1 -1
- package/dist/types.d.ts +27 -50
- package/dist/utils/eval-agents.d.ts +10 -0
- package/dist/utils/eval-agents.js +54 -0
- package/dist/utils/eval-agents.js.map +1 -0
- package/dist/workflow-builder/sdk-prompt-sections.d.ts +1 -4
- package/dist/workflow-builder/sdk-prompt-sections.js +5 -513
- package/dist/workflow-builder/sdk-prompt-sections.js.map +1 -1
- package/dist/workflow-loop/guidance.js +3 -5
- package/dist/workflow-loop/guidance.js.map +1 -1
- package/dist/workspace/create-workspace.d.ts +1 -1
- package/dist/workspace/create-workspace.js +3 -2
- package/dist/workspace/create-workspace.js.map +1 -1
- package/dist/workspace/daytona-filesystem.js +15 -1
- package/dist/workspace/daytona-filesystem.js.map +1 -1
- package/dist/workspace/snapshot-manager.d.ts +4 -2
- package/dist/workspace/snapshot-manager.js +7 -2
- package/dist/workspace/snapshot-manager.js.map +1 -1
- package/package.json +29 -11
- package/dist/memory/working-memory-template.d.ts +0 -1
- package/dist/memory/working-memory-template.js +0 -25
- package/dist/memory/working-memory-template.js.map +0 -1
- package/dist/runtime/working-memory-tracing.d.ts +0 -19
- package/dist/runtime/working-memory-tracing.js +0 -111
- package/dist/runtime/working-memory-tracing.js.map +0 -1
- package/dist/tools/best-practices/guides/chatbot.d.ts +0 -1
- package/dist/tools/best-practices/guides/chatbot.js +0 -111
- package/dist/tools/best-practices/guides/chatbot.js.map +0 -1
- package/dist/tools/best-practices/guides/content-generation.d.ts +0 -1
- package/dist/tools/best-practices/guides/content-generation.js +0 -108
- package/dist/tools/best-practices/guides/content-generation.js.map +0 -1
- package/dist/tools/best-practices/guides/data-extraction.d.ts +0 -1
- package/dist/tools/best-practices/guides/data-extraction.js +0 -115
- package/dist/tools/best-practices/guides/data-extraction.js.map +0 -1
- package/dist/tools/best-practices/guides/data-persistence.d.ts +0 -1
- package/dist/tools/best-practices/guides/data-persistence.js +0 -198
- package/dist/tools/best-practices/guides/data-persistence.js.map +0 -1
- package/dist/tools/best-practices/guides/data-transformation.d.ts +0 -1
- package/dist/tools/best-practices/guides/data-transformation.js +0 -139
- package/dist/tools/best-practices/guides/data-transformation.js.map +0 -1
- package/dist/tools/best-practices/guides/document-processing.d.ts +0 -1
- package/dist/tools/best-practices/guides/document-processing.js +0 -326
- package/dist/tools/best-practices/guides/document-processing.js.map +0 -1
- package/dist/tools/best-practices/guides/form-input.d.ts +0 -1
- package/dist/tools/best-practices/guides/form-input.js +0 -166
- package/dist/tools/best-practices/guides/form-input.js.map +0 -1
- package/dist/tools/best-practices/guides/notification.d.ts +0 -1
- package/dist/tools/best-practices/guides/notification.js +0 -128
- package/dist/tools/best-practices/guides/notification.js.map +0 -1
- package/dist/tools/best-practices/guides/scheduling.d.ts +0 -1
- package/dist/tools/best-practices/guides/scheduling.js +0 -145
- package/dist/tools/best-practices/guides/scheduling.js.map +0 -1
- package/dist/tools/best-practices/guides/scraping-and-research.d.ts +0 -1
- package/dist/tools/best-practices/guides/scraping-and-research.js +0 -151
- package/dist/tools/best-practices/guides/scraping-and-research.js.map +0 -1
- package/dist/tools/best-practices/guides/triage.d.ts +0 -1
- package/dist/tools/best-practices/guides/triage.js +0 -142
- package/dist/tools/best-practices/guides/triage.js.map +0 -1
- package/dist/tools/filesystem/get-file-tree.tool.d.ts +0 -22
- package/dist/tools/filesystem/get-file-tree.tool.js +0 -64
- package/dist/tools/filesystem/get-file-tree.tool.js.map +0 -1
- package/dist/tools/filesystem/list-files.tool.d.ts +0 -30
- package/dist/tools/filesystem/list-files.tool.js +0 -100
- package/dist/tools/filesystem/list-files.tool.js.map +0 -1
- package/dist/tools/filesystem/read-file.tool.d.ts +0 -25
- package/dist/tools/filesystem/read-file.tool.js +0 -83
- package/dist/tools/filesystem/read-file.tool.js.map +0 -1
- package/dist/tools/filesystem/search-files.tool.d.ts +0 -31
- package/dist/tools/filesystem/search-files.tool.js +0 -96
- package/dist/tools/filesystem/search-files.tool.js.map +0 -1
|
@@ -8,13 +8,13 @@ const delegate_schemas_1 = require("./delegate.schemas");
|
|
|
8
8
|
const display_utils_1 = require("./display-utils");
|
|
9
9
|
const tracing_utils_1 = require("./tracing-utils");
|
|
10
10
|
const register_with_mastra_1 = require("../../agent/register-with-mastra");
|
|
11
|
+
const sub_agent_briefing_1 = require("../../agent/sub-agent-briefing");
|
|
12
|
+
const sub_agent_debriefing_1 = require("../../agent/sub-agent-debriefing");
|
|
11
13
|
const sub_agent_factory_1 = require("../../agent/sub-agent-factory");
|
|
12
14
|
const resumable_stream_executor_1 = require("../../runtime/resumable-stream-executor");
|
|
13
|
-
const working_memory_tracing_1 = require("../../runtime/working-memory-tracing");
|
|
14
|
-
const iteration_log_1 = require("../../storage/iteration-log");
|
|
15
15
|
const consume_with_hitl_1 = require("../../stream/consume-with-hitl");
|
|
16
16
|
const langsmith_tracing_1 = require("../../tracing/langsmith-tracing");
|
|
17
|
-
const FORBIDDEN_TOOL_NAMES = new Set(['plan', 'delegate']);
|
|
17
|
+
const FORBIDDEN_TOOL_NAMES = new Set(['plan', 'create-tasks', 'delegate']);
|
|
18
18
|
const FALLBACK_MAX_STEPS = 10;
|
|
19
19
|
function generateAgentId() {
|
|
20
20
|
return `agent-${(0, nanoid_1.nanoid)(6)}`;
|
|
@@ -46,21 +46,16 @@ function resolveDelegateTools(context, toolNames) {
|
|
|
46
46
|
return { validTools, errors };
|
|
47
47
|
}
|
|
48
48
|
async function buildDelegateBriefing(context, role, briefing, artifacts, conversationContext) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return `${briefing}${conversationCtx}${serializedArtifacts}${iterationContext ? `\n\n${iterationContext}` : ''}\n\nRemember: ${sub_agent_factory_1.SUB_AGENT_PROTOCOL}`;
|
|
49
|
+
const structured = await (0, sub_agent_briefing_1.buildSubAgentBriefing)({
|
|
50
|
+
task: briefing,
|
|
51
|
+
conversationContext,
|
|
52
|
+
artifacts: artifacts,
|
|
53
|
+
iteration: context.iterationLog
|
|
54
|
+
? { log: context.iterationLog, threadId: context.threadId, taskKey: `delegate:${role}` }
|
|
55
|
+
: undefined,
|
|
56
|
+
runningTasks: context.getRunningTaskSummaries?.(),
|
|
57
|
+
});
|
|
58
|
+
return `${structured}\n\nRemember: ${sub_agent_factory_1.SUB_AGENT_PROTOCOL}`;
|
|
64
59
|
}
|
|
65
60
|
async function startDetachedDelegateTask(context, input) {
|
|
66
61
|
if (input.tools.length === 0) {
|
|
@@ -125,7 +120,7 @@ async function startDetachedDelegateTask(context, input) {
|
|
|
125
120
|
role,
|
|
126
121
|
traceContext,
|
|
127
122
|
plannedTaskId: input.plannedTaskId,
|
|
128
|
-
run: async (signal, drainCorrections) => {
|
|
123
|
+
run: async (signal, drainCorrections, waitForCorrection) => {
|
|
129
124
|
return await (0, tracing_utils_1.withTraceContextActor)(traceContext, async () => {
|
|
130
125
|
const subAgent = (0, sub_agent_factory_1.createSubAgent)({
|
|
131
126
|
agentId: subAgentId,
|
|
@@ -139,32 +134,27 @@ async function startDetachedDelegateTask(context, input) {
|
|
|
139
134
|
const traceParent = (0, langsmith_tracing_1.getTraceParentRun)();
|
|
140
135
|
return await (0, langsmith_tracing_1.withTraceParentContext)(traceParent, async () => {
|
|
141
136
|
const llmStepTraceHooks = (0, resumable_stream_executor_1.createLlmStepTraceHooks)(traceParent);
|
|
142
|
-
const stream = await (
|
|
143
|
-
phase: 'initial',
|
|
144
|
-
agentId: subAgentId,
|
|
145
|
-
agentRole: role,
|
|
146
|
-
threadId: context.threadId,
|
|
147
|
-
input: briefingMessage,
|
|
148
|
-
}, async () => await subAgent.stream(briefingMessage, {
|
|
137
|
+
const stream = await subAgent.stream(briefingMessage, {
|
|
149
138
|
maxSteps: context.subAgentMaxSteps ?? FALLBACK_MAX_STEPS,
|
|
150
139
|
abortSignal: signal,
|
|
151
140
|
providerOptions: {
|
|
152
141
|
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
153
142
|
},
|
|
154
143
|
...(llmStepTraceHooks?.executionOptions ?? {}),
|
|
155
|
-
})
|
|
144
|
+
});
|
|
156
145
|
const result = await (0, consume_with_hitl_1.consumeStreamWithHitl)({
|
|
157
146
|
agent: subAgent,
|
|
158
147
|
stream: stream,
|
|
159
148
|
runId: context.runId,
|
|
160
149
|
agentId: subAgentId,
|
|
161
150
|
eventBus: context.eventBus,
|
|
151
|
+
logger: context.logger,
|
|
162
152
|
threadId: context.threadId,
|
|
163
153
|
abortSignal: signal,
|
|
164
154
|
waitForConfirmation: context.waitForConfirmation,
|
|
165
155
|
drainCorrections,
|
|
156
|
+
waitForCorrection,
|
|
166
157
|
llmStepTraceHooks,
|
|
167
|
-
workingMemoryEnabled: false,
|
|
168
158
|
});
|
|
169
159
|
return await result.text;
|
|
170
160
|
});
|
|
@@ -196,6 +186,7 @@ function createDelegateTool(context) {
|
|
|
196
186
|
return { result: `Delegation failed: ${errors.join('; ')}` };
|
|
197
187
|
}
|
|
198
188
|
const subAgentId = generateAgentId();
|
|
189
|
+
const startTime = Date.now();
|
|
199
190
|
context.eventBus.publish(context.threadId, {
|
|
200
191
|
type: 'agent-spawned',
|
|
201
192
|
runId: context.runId,
|
|
@@ -232,44 +223,48 @@ function createDelegateTool(context) {
|
|
|
232
223
|
});
|
|
233
224
|
(0, register_with_mastra_1.registerWithMastra)(subAgentId, subAgent, context.storage);
|
|
234
225
|
const briefingMessage = await buildDelegateBriefing(context, input.role, input.briefing, input.artifacts, input.conversationContext);
|
|
235
|
-
const
|
|
226
|
+
const consumeResult = await (0, tracing_utils_1.withTraceRun)(context, traceRun, async () => {
|
|
236
227
|
const traceParent = (0, langsmith_tracing_1.getTraceParentRun)();
|
|
237
228
|
return await (0, langsmith_tracing_1.withTraceParentContext)(traceParent, async () => {
|
|
238
229
|
const llmStepTraceHooks = (0, resumable_stream_executor_1.createLlmStepTraceHooks)(traceParent);
|
|
239
|
-
const stream = await (
|
|
240
|
-
phase: 'initial',
|
|
241
|
-
agentId: subAgentId,
|
|
242
|
-
agentRole: input.role,
|
|
243
|
-
threadId: context.threadId,
|
|
244
|
-
input: briefingMessage,
|
|
245
|
-
}, async () => await subAgent.stream(briefingMessage, {
|
|
230
|
+
const stream = await subAgent.stream(briefingMessage, {
|
|
246
231
|
maxSteps: context.subAgentMaxSteps ?? FALLBACK_MAX_STEPS,
|
|
247
232
|
abortSignal: context.abortSignal,
|
|
248
233
|
providerOptions: {
|
|
249
234
|
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
250
235
|
},
|
|
251
236
|
...(llmStepTraceHooks?.executionOptions ?? {}),
|
|
252
|
-
})
|
|
253
|
-
|
|
237
|
+
});
|
|
238
|
+
return await (0, consume_with_hitl_1.consumeStreamWithHitl)({
|
|
254
239
|
agent: subAgent,
|
|
255
240
|
stream: stream,
|
|
256
241
|
runId: context.runId,
|
|
257
242
|
agentId: subAgentId,
|
|
258
243
|
eventBus: context.eventBus,
|
|
244
|
+
logger: context.logger,
|
|
259
245
|
threadId: context.threadId,
|
|
260
246
|
abortSignal: context.abortSignal,
|
|
261
247
|
waitForConfirmation: context.waitForConfirmation,
|
|
262
248
|
llmStepTraceHooks,
|
|
263
|
-
workingMemoryEnabled: false,
|
|
264
249
|
});
|
|
265
|
-
return await result.text;
|
|
266
250
|
});
|
|
267
251
|
});
|
|
252
|
+
const resultText = await consumeResult.text;
|
|
253
|
+
const debriefing = (0, sub_agent_debriefing_1.buildDebriefing)({
|
|
254
|
+
agentId: subAgentId,
|
|
255
|
+
role: input.role,
|
|
256
|
+
result: resultText,
|
|
257
|
+
workSummary: consumeResult.workSummary,
|
|
258
|
+
startTime,
|
|
259
|
+
});
|
|
268
260
|
await (0, tracing_utils_1.finishTraceRun)(context, traceRun, {
|
|
269
261
|
outputs: {
|
|
270
262
|
result: resultText,
|
|
271
263
|
agentId: subAgentId,
|
|
272
264
|
role: input.role,
|
|
265
|
+
toolCallCount: debriefing.toolCallCount,
|
|
266
|
+
toolErrorCount: debriefing.toolErrorCount,
|
|
267
|
+
durationMs: debriefing.durationMs,
|
|
273
268
|
},
|
|
274
269
|
});
|
|
275
270
|
context.eventBus.publish(context.threadId, {
|
|
@@ -281,7 +276,13 @@ function createDelegateTool(context) {
|
|
|
281
276
|
result: resultText,
|
|
282
277
|
},
|
|
283
278
|
});
|
|
284
|
-
return {
|
|
279
|
+
return {
|
|
280
|
+
result: resultText,
|
|
281
|
+
toolCallCount: debriefing.toolCallCount,
|
|
282
|
+
toolErrorCount: debriefing.toolErrorCount,
|
|
283
|
+
durationMs: debriefing.durationMs,
|
|
284
|
+
blockers: debriefing.blockers,
|
|
285
|
+
};
|
|
285
286
|
}
|
|
286
287
|
catch (error) {
|
|
287
288
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/delegate.tool.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"delegate.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/delegate.tool.ts"],"names":[],"mappings":";;AAmGA,8DAsIC;AAED,gDAuKC;AAjZD,8CAAgD;AAChD,mCAAgC;AAEhC,yDAAmG;AACnG,mDAAgD;AAChD,mDAQyB;AACzB,2EAAsE;AACtE,uEAAuE;AACvE,2EAAmE;AACnE,qEAAmF;AACnF,uFAAkF;AAClF,sEAAuE;AACvE,uEAA4F;AAG5F,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;AAE3E,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,SAAS,eAAe;IACvB,OAAO,SAAS,IAAA,eAAM,EAAC,CAAC,CAAC,EAAE,CAAC;AAC7B,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IACjC,OAAO,IAAI;SACT,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,oBAAoB,CAC5B,OAA6B,EAC7B,SAAmB;IAEnB,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,UAAU,GAAe,EAAE,CAAC;IAClC,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IAEjD,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC9B,IAAI,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,oDAAoD,CAAC,CAAC;QAC3E,CAAC;aAAM,IAAI,IAAI,IAAI,OAAO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AE,iBAAiB;oBACvB,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,OAAO,EAAE,UAAU;oBACnB,OAAO,EAAE;wBACR,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,MAAM,EAAE,UAAU;qBAClB;iBACD,CAAC,CAAC;gBAEH,OAAO;oBACN,MAAM,EAAE,UAAU;oBAClB,aAAa,EAAE,UAAU,CAAC,aAAa;oBACvC,cAAc,EAAE,UAAU,CAAC,cAAc;oBACzC,UAAU,EAAE,UAAU,CAAC,UAAU;oBACjC,QAAQ,EAAE,UAAU,CAAC,QAAQ;iBAC7B,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAEhB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC5E,MAAM,IAAA,4BAAY,EAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE;oBAC5C,QAAQ,EAAE,UAAU;oBACpB,UAAU,EAAE,KAAK,CAAC,IAAI;iBACtB,CAAC,CAAC;gBAEH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE;oBAC1C,IAAI,EAAE,iBAAiB;oBACvB,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,OAAO,EAAE,UAAU;oBACnB,OAAO,EAAE;wBACR,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,MAAM,EAAE,EAAE;wBACV,KAAK,EAAE,YAAY;qBACnB;iBACD,CAAC,CAAC;gBAEH,OAAO,EAAE,MAAM,EAAE,oBAAoB,YAAY,EAAE,EAAE,CAAC;YACvD,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLANNER_AGENT_PROMPT = "You are the n8n Workflow Planner \u2014 you design solution architectures. You do NOT build workflows.\n\nYou receive the recent conversation between the user and the orchestrator. Read it to understand what the user wants, then design the blueprint.\n\n## Output Discipline\n- Be terse. You report to a parent orchestrator, not a human.\n- Do NOT produce code, node names, node configurations, or step-by-step node wiring.\n- Do NOT narrate (\"I'll search for...\", \"Let me look up\"). Just do the work.\n- No emojis, no filler, no markdown formatting in your reasoning.\n\n## Method\n\n1. **Prefer assumptions over questions.** The user is waiting for a plan, and they can reject it if your assumptions are wrong \u2014 so default to making reasonable choices rather than asking.\n - **Never ask about things you can discover** \u2014 call `list-credentials`, `list-data-tables`, `get-best-practices` instead.\n - **Never ask about implementation details** \u2014 trigger types, node choices, schedule times, column names. Pick sensible defaults.\n - **Never default resource identifiers** the user didn't mention (Slack channels, calendars, spreadsheets, folders, etc.) \u2014 leave them for the builder to resolve at build time.\n - **Do ask when the answer would significantly change the plan** \u2014 e.g. the user's goal is ambiguous (\"build me a CRM\" \u2014 for sales? support? recruiting?), or a business rule must come from the user (\"what should happen when payment fails?\").\n - **List your assumptions** on your first `add-plan-item` call. The user reviews the plan before execution and can reject/correct.\n\n2. **Discover** (3-6 tool calls) \u2014 check what exists and learn best practices:\n - `get-best-practices` for each relevant technique (e.g. \"form_input\", \"scheduling\", \"data_persistence\"). Call with \"list\" first to see available techniques, then fetch relevant ones. **This is important** \u2014 best practices inform your design decisions.\n - `get-suggested-nodes` for the relevant categories\n - `list-data-tables` to check for existing tables\n - `list-credentials` if the request involves external services\n - Skip searches for nodes you already know exist (webhooks, schedule triggers, data tables, code, set, filter, etc.)\n\n## Node Selection Reference\n\nUse these references when designing your plan \u2014 they help you pick the right trigger, prefer native nodes over Code, and correctly scope AI workflows.\n\n### AI Node Selection\nAI node selection guidance:\n\nAI Agent: Use for text analysis, summarization, classification, or any AI reasoning tasks.\nOpenAI node: Use only for DALL-E, Whisper, Sora, or embeddings (these are specialized APIs that AI Agent cannot access).\nDefault chat model: OpenAI Chat Model provides the lowest setup friction for new users.\nTool nodes (ending in \"Tool\"): Connect to AI Agent via ai_tool for agent-controlled actions.\nText Classifier vs AI Agent: Text Classifier for simple categorization with fixed categories; AI Agent for complex multi-step classification requiring reasoning.\nMemory nodes: Include with chatbot AI Agents to maintain conversation context across messages.\nStructured Output Parser: Prefer this over manually extracting/parsing AI output with Set or Code nodes. Define the desired schema and the LLM handles parsing automatically. Use for classification, data extraction, or any workflow where AI output feeds into database storage, API calls, or Switch routing.\n\nMulti-agent systems:\nAI Agent Tool (@n8n/n8n-nodes-langchain.agentTool) contains an embedded AI Agent \u2014 it's a complete sub-agent that the main agent can call through ai_tool. Each AgentTool needs its own Chat Model. Node selection: 1 AI Agent + N AgentTools + (N+1) Chat Models.\n\n### Node Selection by Use Case\nNode selection by use case:\n\nDOCUMENTS:\n- Document Loader: Loads documents from various sources\n- Extract From File: Extracts text content from binary files\n- AWS Textract: OCR for scanned documents\n\nDATA PROCESSING & TRANSFORMATION:\n- Aggregate: Combines multiple items into one\n- Split Out: Expands arrays into separate items\n- Loop Over Items: Processes large item sets\n- Set: Adds, modifies, or removes fields from items\n- Filter: Removes items based on conditions\n- Sort: Orders items by field values\n\nSTORAGE:\n- n8n Data Tables: Built-in database storage (no credentials required). Recommend as the default storage option.\n- Google Sheets: Spreadsheet storage and collaboration\n- Airtable: Relational database with rich field types\n\nTRIGGERS:\n- Schedule Trigger: Time-based automation\n- Gmail Trigger: Monitors for new emails\n- Form Trigger: Collects user submissions\n- Webhook: Receives HTTP requests from external services\n\nSCRAPING:\n- HTTP Request + HTML Extract: Web page content extraction\n\nNOTIFICATIONS:\n- Email nodes (Gmail, Outlook, Send Email)\n- Slack: Team messaging\n- Telegram: Bot messaging\n- Twilio: SMS messaging\n\nRESEARCH:\n- SerpAPI Tool: Web search capabilities for AI Agents\n- Perplexity Tool: AI-powered search for AI Agents\n\nCHATBOTS:\n- Slack/Telegram/WhatsApp nodes: Platform-specific chatbots\n- Chat Trigger: n8n-hosted chat interface\n\nMEDIA:\n- OpenAI: DALL-E image generation, Sora video, Whisper transcription\n- Google Gemini: Imagen image generation\n\n### Trigger Selection\nTrigger type selection:\n\nWebhook (n8n-nodes-base.webhook): External systems calling your workflow via HTTP POST/GET.\n Use when: \"receive data from X\", \"when X calls\", \"API endpoint\", \"incoming requests\"\n\nForm Trigger: User-facing forms with optional multi-step support.\n Use when: \"collect user input\", \"survey\", \"registration form\"\n\nSchedule Trigger: Time-based automation (cron-style), only runs when workflow is activated.\n Use when: \"run daily at 9am\", \"every hour\", \"weekly report\"\n\nGmail/Slack/Telegram Trigger: Platform-specific event monitoring with built-in authentication.\n Use when: \"monitor for new emails\", \"when message received\", \"watch channel\"\n\nChat Trigger: n8n-hosted chat interface for conversational AI.\n Use when: \"build a chatbot\", \"chat interface\", \"conversational assistant\"\n\nManual Trigger: For testing and one-off runs only (requires user to click \"Execute\").\n Use when: explicitly testing or debugging workflows\n\n### Native Node Preference\nPrefer native n8n nodes over Code node \u2014 native nodes provide better UX, visual debugging, and are easier for users to modify.\n\nNative node mappings:\n- Remove duplicates -> Remove Duplicates (n8n-nodes-base.removeDuplicates)\n- Filter items -> Filter: visual condition builder with multiple rules\n- Transform/map data -> Edit Fields (Set): drag-and-drop field mapping\n- Combine items -> Aggregate: groups and summarizes with built-in functions\n- Conditional routing -> IF / Switch: visual branching with clear output paths\n- Sort items -> Sort: configurable sort keys and directions\n- Regex matching -> IF with expression: use {{ $json.field.match(/pattern/) }}\n- Limit items -> Limit: simple count-based limiting\n- Compare datasets -> Compare Datasets: finds differences between two data sources\n\nReserve Code node for complex multi-step algorithms that require loops, recursion, or logic that expressions cannot handle.\n\n3. **Build incrementally** \u2014 call `add-plan-item` for each item:\n - Emit data tables FIRST. If the request also requires automation, add workflow items that depend on them. A plan may consist entirely of data-table items.\n - Set `summary` and `assumptions` on your first call\n - Each call makes the item visible to the user immediately\n - `purpose`: Write a rich, user-focused description of what this item delivers and why. Include key requirements and behaviors from the user's request. 3-5 sentences. Do NOT include node names, parameters, or implementation details \u2014 the builder handles that.\n - `triggerDescription`: a few words describing trigger type (e.g. \"Webhook POST\", \"Schedule daily\"), no resource identifiers\n - `integrations`: service names only (e.g. \"Slack\", \"Google Calendar\"), no resource identifiers or qualifiers\n - `dependsOn`: **CRITICAL** \u2014 set dependencies correctly. Data tables before workflows that use them. Workflows that produce data before workflows that consume it. Independent workflows should NOT depend on each other.\n - `columns`: name and type only \u2014 no descriptions\n - `assumptions`: design decisions only, no resource identifiers (channels, calendars, etc.)\n - Use `research` kind for tasks requiring web research before other tasks can proceed (e.g. \"find the API endpoint format for service X\"). Research tasks run a dedicated web research agent.\n - After all items are added, call `submit-plan` to request user approval.\n\n4. **Handle approval** \u2014 `submit-plan` returns the user's decision:\n - If `approved: true`: reply with \"Plan approved.\" and stop.\n - If `approved: false`: read the `feedback` field. Make targeted changes using `remove-plan-item` (to drop items) or `add-plan-item` (to add/replace items by ID). Then call `submit-plan` again. Repeat until approved.\n\n## Critical Rules\n\n- **Call `add-plan-item` for each item as you design it.** Data tables first, then workflows. 3-6 discovery tool calls then start emitting items.\n- **Always call `submit-plan` after your last `add-plan-item`.** Never end without submitting.\n- **On rejection, be surgical.** Only change what the user asked for. Do NOT re-add items that are already correct.\n- **Dependencies are mandatory.** Every workflow MUST list the data table IDs it reads from or writes to in `dependsOn`. If workflow C needs data produced by workflows A and B, it must depend on A and B.\n- **No duplicate items.** Each piece of work appears exactly once. Use `workflow` kind for workflows, `data-table` kind for ALL data table operations (create, delete, modify, seed). Only use `delegate` kind for tasks that don't fit the other categories \u2014 never use `delegate` for data table operations.\n- **Data-table-only plans are valid.** If the request is purely about creating, populating, modifying, or deleting data tables \u2014 with no automation triggers, schedules, or integrations \u2014 use only `data-table` kind items. Do NOT wrap table operations in a `workflow` or `delegate` item.\n- **`data-table` kind supports any table operation.** For creation, include `columns`. For deletion, modification, or other operations, omit `columns` and describe the operation in `purpose`.\n- **Include seed data instructions in the `purpose` field.** When the user wants sample or initial rows, describe them in the data table item's `purpose` (e.g. \"Seed with 3 rows: ...\"). The data-table agent handles insertion.\n- **Each item's `purpose` must only describe what THAT item does.** Do not reference actions handled by other plan items. Each task is executed by an independent agent that only sees its own spec \u2014 cross-task context causes agents to perform work outside their scope.\n- Never fabricate node names \u2014 if unsure whether a node exists, search first.";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLANNER_AGENT_PROMPT = void 0;
|
|
4
|
+
const node_selection_1 = require("@n8n/workflow-sdk/prompts/node-selection");
|
|
5
|
+
exports.PLANNER_AGENT_PROMPT = `You are the n8n Workflow Planner — you design solution architectures. You do NOT build workflows.
|
|
6
|
+
|
|
7
|
+
You receive the recent conversation between the user and the orchestrator. Read it to understand what the user wants, then design the blueprint.
|
|
8
|
+
|
|
9
|
+
## Output Discipline
|
|
10
|
+
- Be terse. You report to a parent orchestrator, not a human.
|
|
11
|
+
- Do NOT produce code, node names, node configurations, or step-by-step node wiring.
|
|
12
|
+
- Do NOT narrate ("I'll search for...", "Let me look up"). Just do the work.
|
|
13
|
+
- No emojis, no filler, no markdown formatting in your reasoning.
|
|
14
|
+
|
|
15
|
+
## Method
|
|
16
|
+
|
|
17
|
+
1. **Prefer assumptions over questions.** The user is waiting for a plan, and they can reject it if your assumptions are wrong — so default to making reasonable choices rather than asking.
|
|
18
|
+
- **Never ask about things you can discover** — call \`list-credentials\`, \`list-data-tables\`, \`get-best-practices\` instead.
|
|
19
|
+
- **Never ask about implementation details** — trigger types, node choices, schedule times, column names. Pick sensible defaults.
|
|
20
|
+
- **Never default resource identifiers** the user didn't mention (Slack channels, calendars, spreadsheets, folders, etc.) — leave them for the builder to resolve at build time.
|
|
21
|
+
- **Do ask when the answer would significantly change the plan** — e.g. the user's goal is ambiguous ("build me a CRM" — for sales? support? recruiting?), or a business rule must come from the user ("what should happen when payment fails?").
|
|
22
|
+
- **List your assumptions** on your first \`add-plan-item\` call. The user reviews the plan before execution and can reject/correct.
|
|
23
|
+
|
|
24
|
+
2. **Discover** (3-6 tool calls) — check what exists and learn best practices:
|
|
25
|
+
- \`get-best-practices\` for each relevant technique (e.g. "form_input", "scheduling", "data_persistence"). Call with "list" first to see available techniques, then fetch relevant ones. **This is important** — best practices inform your design decisions.
|
|
26
|
+
- \`get-suggested-nodes\` for the relevant categories
|
|
27
|
+
- \`list-data-tables\` to check for existing tables
|
|
28
|
+
- \`list-credentials\` if the request involves external services
|
|
29
|
+
- Skip searches for nodes you already know exist (webhooks, schedule triggers, data tables, code, set, filter, etc.)
|
|
30
|
+
|
|
31
|
+
## Node Selection Reference
|
|
32
|
+
|
|
33
|
+
Use these references when designing your plan — they help you pick the right trigger, prefer native nodes over Code, and correctly scope AI workflows.
|
|
34
|
+
|
|
35
|
+
### AI Node Selection
|
|
36
|
+
${node_selection_1.AI_NODE_SELECTION}
|
|
37
|
+
|
|
38
|
+
### Node Selection by Use Case
|
|
39
|
+
${node_selection_1.NODE_SELECTION_PATTERNS}
|
|
40
|
+
|
|
41
|
+
### Trigger Selection
|
|
42
|
+
${node_selection_1.TRIGGER_SELECTION}
|
|
43
|
+
|
|
44
|
+
### Native Node Preference
|
|
45
|
+
${node_selection_1.NATIVE_NODE_PREFERENCE}
|
|
46
|
+
|
|
47
|
+
3. **Build incrementally** — call \`add-plan-item\` for each item:
|
|
48
|
+
- Emit data tables FIRST. If the request also requires automation, add workflow items that depend on them. A plan may consist entirely of data-table items.
|
|
49
|
+
- Set \`summary\` and \`assumptions\` on your first call
|
|
50
|
+
- Each call makes the item visible to the user immediately
|
|
51
|
+
- \`purpose\`: Write a rich, user-focused description of what this item delivers and why. Include key requirements and behaviors from the user's request. 3-5 sentences. Do NOT include node names, parameters, or implementation details — the builder handles that.
|
|
52
|
+
- \`triggerDescription\`: a few words describing trigger type (e.g. "Webhook POST", "Schedule daily"), no resource identifiers
|
|
53
|
+
- \`integrations\`: service names only (e.g. "Slack", "Google Calendar"), no resource identifiers or qualifiers
|
|
54
|
+
- \`dependsOn\`: **CRITICAL** — set dependencies correctly. Data tables before workflows that use them. Workflows that produce data before workflows that consume it. Independent workflows should NOT depend on each other.
|
|
55
|
+
- \`columns\`: name and type only — no descriptions
|
|
56
|
+
- \`assumptions\`: design decisions only, no resource identifiers (channels, calendars, etc.)
|
|
57
|
+
- Use \`research\` kind for tasks requiring web research before other tasks can proceed (e.g. "find the API endpoint format for service X"). Research tasks run a dedicated web research agent.
|
|
58
|
+
- After all items are added, call \`submit-plan\` to request user approval.
|
|
59
|
+
|
|
60
|
+
4. **Handle approval** — \`submit-plan\` returns the user's decision:
|
|
61
|
+
- If \`approved: true\`: reply with "Plan approved." and stop.
|
|
62
|
+
- If \`approved: false\`: read the \`feedback\` field. Make targeted changes using \`remove-plan-item\` (to drop items) or \`add-plan-item\` (to add/replace items by ID). Then call \`submit-plan\` again. Repeat until approved.
|
|
63
|
+
|
|
64
|
+
## Critical Rules
|
|
65
|
+
|
|
66
|
+
- **Call \`add-plan-item\` for each item as you design it.** Data tables first, then workflows. 3-6 discovery tool calls then start emitting items.
|
|
67
|
+
- **Always call \`submit-plan\` after your last \`add-plan-item\`.** Never end without submitting.
|
|
68
|
+
- **On rejection, be surgical.** Only change what the user asked for. Do NOT re-add items that are already correct.
|
|
69
|
+
- **Dependencies are mandatory.** Every workflow MUST list the data table IDs it reads from or writes to in \`dependsOn\`. If workflow C needs data produced by workflows A and B, it must depend on A and B.
|
|
70
|
+
- **No duplicate items.** Each piece of work appears exactly once. Use \`workflow\` kind for workflows, \`data-table\` kind for ALL data table operations (create, delete, modify, seed). Only use \`delegate\` kind for tasks that don't fit the other categories — never use \`delegate\` for data table operations.
|
|
71
|
+
- **Data-table-only plans are valid.** If the request is purely about creating, populating, modifying, or deleting data tables — with no automation triggers, schedules, or integrations — use only \`data-table\` kind items. Do NOT wrap table operations in a \`workflow\` or \`delegate\` item.
|
|
72
|
+
- **\`data-table\` kind supports any table operation.** For creation, include \`columns\`. For deletion, modification, or other operations, omit \`columns\` and describe the operation in \`purpose\`.
|
|
73
|
+
- **Include seed data instructions in the \`purpose\` field.** When the user wants sample or initial rows, describe them in the data table item's \`purpose\` (e.g. "Seed with 3 rows: ..."). The data-table agent handles insertion.
|
|
74
|
+
- **Each item's \`purpose\` must only describe what THAT item does.** Do not reference actions handled by other plan items. Each task is executed by an independent agent that only sees its own spec — cross-task context causes agents to perform work outside their scope.
|
|
75
|
+
- Never fabricate node names — if unsure whether a node exists, search first.`;
|
|
76
|
+
//# sourceMappingURL=plan-agent-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-agent-prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-agent-prompt.ts"],"names":[],"mappings":";;;AAAA,6EAKkD;AAErC,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BlC,kCAAiB;;;EAGjB,wCAAuB;;;EAGvB,kCAAiB;;;EAGjB,uCAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8EA8BsD,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { OrchestrationContext } from '../../types';
|
|
2
|
+
export declare function createPlanWithAgentTool(context: OrchestrationContext): import("@mastra/core/tools").Tool<InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, import("@mastra/core/tools").ToolExecutionContext<InferPublicSchema<T>, InferPublicSchema<T>, unknown>, "plan", unknown>;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPlanWithAgentTool = createPlanWithAgentTool;
|
|
4
|
+
const agent_1 = require("@mastra/core/agent");
|
|
5
|
+
const tools_1 = require("@mastra/core/tools");
|
|
6
|
+
const nanoid_1 = require("nanoid");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const add_plan_item_tool_1 = require("./add-plan-item.tool");
|
|
9
|
+
const blueprint_accumulator_1 = require("./blueprint-accumulator");
|
|
10
|
+
const display_utils_1 = require("./display-utils");
|
|
11
|
+
const plan_agent_prompt_1 = require("./plan-agent-prompt");
|
|
12
|
+
const submit_plan_tool_1 = require("./submit-plan.tool");
|
|
13
|
+
const tracing_utils_1 = require("./tracing-utils");
|
|
14
|
+
const register_with_mastra_1 = require("../../agent/register-with-mastra");
|
|
15
|
+
const resumable_stream_executor_1 = require("../../runtime/resumable-stream-executor");
|
|
16
|
+
const consume_with_hitl_1 = require("../../stream/consume-with-hitl");
|
|
17
|
+
const langsmith_tracing_1 = require("../../tracing/langsmith-tracing");
|
|
18
|
+
const PLANNER_MAX_STEPS = 30;
|
|
19
|
+
const MESSAGE_HISTORY_COUNT = 5;
|
|
20
|
+
const PLANNER_DOMAIN_TOOL_NAMES = [
|
|
21
|
+
'search-nodes',
|
|
22
|
+
'get-suggested-nodes',
|
|
23
|
+
'get-best-practices',
|
|
24
|
+
'list-credentials',
|
|
25
|
+
'list-data-tables',
|
|
26
|
+
'get-data-table-schema',
|
|
27
|
+
'list-workflows',
|
|
28
|
+
'ask-user',
|
|
29
|
+
];
|
|
30
|
+
const PLANNER_RESEARCH_TOOL_NAMES = ['web-search', 'fetch-url'];
|
|
31
|
+
function extractTextFromMemoryContent(content) {
|
|
32
|
+
if (typeof content === 'string')
|
|
33
|
+
return content;
|
|
34
|
+
if (isStructuredContent(content)) {
|
|
35
|
+
return extractTextParts(content.parts);
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(content)) {
|
|
38
|
+
return extractTextParts(content);
|
|
39
|
+
}
|
|
40
|
+
return typeof content === 'object' && content !== null ? JSON.stringify(content) : '';
|
|
41
|
+
}
|
|
42
|
+
function isStructuredContent(value) {
|
|
43
|
+
return (typeof value === 'object' &&
|
|
44
|
+
value !== null &&
|
|
45
|
+
'parts' in value &&
|
|
46
|
+
Array.isArray(value.parts));
|
|
47
|
+
}
|
|
48
|
+
function extractTextParts(parts) {
|
|
49
|
+
return parts
|
|
50
|
+
.filter((c) => typeof c === 'object' && c !== null && 'text' in c)
|
|
51
|
+
.map((c) => c.text)
|
|
52
|
+
.join('\n');
|
|
53
|
+
}
|
|
54
|
+
async function getRecentMessages(context, count) {
|
|
55
|
+
const messages = [];
|
|
56
|
+
if (context.memory) {
|
|
57
|
+
try {
|
|
58
|
+
const result = await context.memory.recall({
|
|
59
|
+
threadId: context.threadId,
|
|
60
|
+
perPage: count,
|
|
61
|
+
});
|
|
62
|
+
for (const m of result.messages) {
|
|
63
|
+
const role = m.role;
|
|
64
|
+
const content = extractTextFromMemoryContent(m.content);
|
|
65
|
+
if ((role === 'user' || role === 'assistant') && content.length > 0) {
|
|
66
|
+
messages.push({ role, content });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (context.currentUserMessage) {
|
|
74
|
+
messages.push({ role: 'user', content: context.currentUserMessage });
|
|
75
|
+
}
|
|
76
|
+
return messages;
|
|
77
|
+
}
|
|
78
|
+
function formatMessagesForBriefing(messages, guidance) {
|
|
79
|
+
const parts = [];
|
|
80
|
+
if (messages.length > 0) {
|
|
81
|
+
parts.push('## Recent conversation');
|
|
82
|
+
for (const m of messages) {
|
|
83
|
+
const label = m.role === 'user' ? 'User' : 'Assistant';
|
|
84
|
+
const content = m.content.length > 2000 ? m.content.slice(0, 2000) + '...' : m.content;
|
|
85
|
+
parts.push(`**${label}:** ${content}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (guidance) {
|
|
89
|
+
parts.push(`\n## Orchestrator guidance\n${guidance}`);
|
|
90
|
+
}
|
|
91
|
+
parts.push('\nDesign the solution blueprint based on the conversation above.');
|
|
92
|
+
return parts.join('\n\n');
|
|
93
|
+
}
|
|
94
|
+
function publishClearingEvent(context) {
|
|
95
|
+
context.eventBus.publish(context.threadId, {
|
|
96
|
+
type: 'tasks-update',
|
|
97
|
+
runId: context.runId,
|
|
98
|
+
agentId: context.orchestratorAgentId,
|
|
99
|
+
payload: { tasks: { tasks: [] }, planItems: [] },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async function clearDraftChecklist(context) {
|
|
103
|
+
try {
|
|
104
|
+
await context.taskStorage.save(context.threadId, { tasks: [] });
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function createPlanWithAgentTool(context) {
|
|
110
|
+
return (0, tools_1.createTool)({
|
|
111
|
+
id: 'plan',
|
|
112
|
+
description: 'Design and execute a multi-step plan. Spawns a planner agent that reads ' +
|
|
113
|
+
'the conversation history, discovers available credentials, data tables, ' +
|
|
114
|
+
'and best practices, designs the architecture, and shows it to the user ' +
|
|
115
|
+
'for approval. Use when the request requires 2 or more tasks with ' +
|
|
116
|
+
'dependencies. When this tool returns, the plan is already approved ' +
|
|
117
|
+
'and tasks are dispatched — just acknowledge briefly and end your turn.',
|
|
118
|
+
inputSchema: zod_1.z.object({
|
|
119
|
+
guidance: zod_1.z
|
|
120
|
+
.string()
|
|
121
|
+
.optional()
|
|
122
|
+
.describe('Optional steering note for the planner — use ONLY when the conversation ' +
|
|
123
|
+
'history alone is ambiguous about what to build. The planner reads the ' +
|
|
124
|
+
'last 5 messages directly, so do NOT rewrite the user request here.'),
|
|
125
|
+
}),
|
|
126
|
+
outputSchema: zod_1.z.object({
|
|
127
|
+
result: zod_1.z.string(),
|
|
128
|
+
}),
|
|
129
|
+
execute: async (input) => {
|
|
130
|
+
const plannerTools = {};
|
|
131
|
+
for (const name of PLANNER_DOMAIN_TOOL_NAMES) {
|
|
132
|
+
if (name in context.domainTools) {
|
|
133
|
+
plannerTools[name] = context.domainTools[name];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (const name of PLANNER_RESEARCH_TOOL_NAMES) {
|
|
137
|
+
if (name in context.domainTools) {
|
|
138
|
+
plannerTools[name] = context.domainTools[name];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const accumulator = new blueprint_accumulator_1.BlueprintAccumulator();
|
|
142
|
+
plannerTools['add-plan-item'] = (0, add_plan_item_tool_1.createAddPlanItemTool)(accumulator, context);
|
|
143
|
+
plannerTools['remove-plan-item'] = (0, add_plan_item_tool_1.createRemovePlanItemTool)(accumulator, context);
|
|
144
|
+
plannerTools['submit-plan'] = (0, submit_plan_tool_1.createSubmitPlanTool)(accumulator, context);
|
|
145
|
+
const messages = await getRecentMessages(context, MESSAGE_HISTORY_COUNT);
|
|
146
|
+
const briefing = formatMessagesForBriefing(messages, input.guidance);
|
|
147
|
+
const subAgentId = `agent-planner-${(0, nanoid_1.nanoid)(6)}`;
|
|
148
|
+
const subtitle = input.guidance ?? messages.find((m) => m.role === 'user')?.content ?? 'Planning...';
|
|
149
|
+
context.eventBus.publish(context.threadId, {
|
|
150
|
+
type: 'agent-spawned',
|
|
151
|
+
runId: context.runId,
|
|
152
|
+
agentId: subAgentId,
|
|
153
|
+
payload: {
|
|
154
|
+
parentId: context.orchestratorAgentId,
|
|
155
|
+
role: 'planner',
|
|
156
|
+
tools: Object.keys(plannerTools),
|
|
157
|
+
kind: 'planner',
|
|
158
|
+
title: 'Planning',
|
|
159
|
+
subtitle: (0, display_utils_1.truncateLabel)(subtitle),
|
|
160
|
+
goal: briefing,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
const traceRun = await (0, tracing_utils_1.startSubAgentTrace)(context, {
|
|
164
|
+
agentId: subAgentId,
|
|
165
|
+
role: 'planner',
|
|
166
|
+
kind: 'planner',
|
|
167
|
+
inputs: {
|
|
168
|
+
guidance: input.guidance,
|
|
169
|
+
messageCount: messages.length,
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
const tracedPlannerTools = (0, tracing_utils_1.traceSubAgentTools)(context, plannerTools, 'planner');
|
|
173
|
+
try {
|
|
174
|
+
const subAgent = new agent_1.Agent({
|
|
175
|
+
id: subAgentId,
|
|
176
|
+
name: 'Workflow Planner Agent',
|
|
177
|
+
instructions: {
|
|
178
|
+
role: 'system',
|
|
179
|
+
content: plan_agent_prompt_1.PLANNER_AGENT_PROMPT,
|
|
180
|
+
providerOptions: {
|
|
181
|
+
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
model: context.modelId,
|
|
185
|
+
tools: tracedPlannerTools,
|
|
186
|
+
});
|
|
187
|
+
(0, register_with_mastra_1.registerWithMastra)(subAgentId, subAgent, context.storage);
|
|
188
|
+
const resultText = await (0, tracing_utils_1.withTraceRun)(context, traceRun, async () => {
|
|
189
|
+
const traceParent = (0, langsmith_tracing_1.getTraceParentRun)();
|
|
190
|
+
return await (0, langsmith_tracing_1.withTraceParentContext)(traceParent, async () => {
|
|
191
|
+
const llmStepTraceHooks = (0, resumable_stream_executor_1.createLlmStepTraceHooks)(traceParent);
|
|
192
|
+
const stream = await subAgent.stream(briefing, {
|
|
193
|
+
maxSteps: PLANNER_MAX_STEPS,
|
|
194
|
+
abortSignal: context.abortSignal,
|
|
195
|
+
providerOptions: {
|
|
196
|
+
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
197
|
+
},
|
|
198
|
+
...(llmStepTraceHooks?.executionOptions ?? {}),
|
|
199
|
+
});
|
|
200
|
+
const result = await (0, consume_with_hitl_1.consumeStreamWithHitl)({
|
|
201
|
+
agent: subAgent,
|
|
202
|
+
stream: stream,
|
|
203
|
+
runId: context.runId,
|
|
204
|
+
agentId: subAgentId,
|
|
205
|
+
eventBus: context.eventBus,
|
|
206
|
+
logger: context.logger,
|
|
207
|
+
threadId: context.threadId,
|
|
208
|
+
abortSignal: context.abortSignal,
|
|
209
|
+
waitForConfirmation: context.waitForConfirmation,
|
|
210
|
+
llmStepTraceHooks,
|
|
211
|
+
maxSteps: PLANNER_MAX_STEPS,
|
|
212
|
+
});
|
|
213
|
+
return await result.text;
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
await (0, tracing_utils_1.finishTraceRun)(context, traceRun, {
|
|
217
|
+
outputs: {
|
|
218
|
+
result: resultText,
|
|
219
|
+
agentId: subAgentId,
|
|
220
|
+
role: 'planner',
|
|
221
|
+
hasItems: !accumulator.isEmpty(),
|
|
222
|
+
itemCount: accumulator.getTaskItemsForEvent().length,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
context.eventBus.publish(context.threadId, {
|
|
226
|
+
type: 'agent-completed',
|
|
227
|
+
runId: context.runId,
|
|
228
|
+
agentId: subAgentId,
|
|
229
|
+
payload: {
|
|
230
|
+
role: 'planner',
|
|
231
|
+
result: resultText,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
if (accumulator.isApproved()) {
|
|
235
|
+
if (context.schedulePlannedTasks) {
|
|
236
|
+
await context.schedulePlannedTasks();
|
|
237
|
+
}
|
|
238
|
+
const taskCount = accumulator.getTaskList().length;
|
|
239
|
+
return {
|
|
240
|
+
result: `Plan approved and ${taskCount} task${taskCount === 1 ? '' : 's'} dispatched.`,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
publishClearingEvent(context);
|
|
244
|
+
await clearDraftChecklist(context);
|
|
245
|
+
if (!accumulator.isEmpty()) {
|
|
246
|
+
return {
|
|
247
|
+
result: `Planner added ${accumulator.getTaskList().length} items but did not submit the plan for approval. The plan was not executed.`,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
result: `Planner finished without producing a plan. Agent output: ${resultText}`,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
256
|
+
await (0, tracing_utils_1.failTraceRun)(context, traceRun, error, {
|
|
257
|
+
agent_id: subAgentId,
|
|
258
|
+
agent_role: 'planner',
|
|
259
|
+
});
|
|
260
|
+
context.eventBus.publish(context.threadId, {
|
|
261
|
+
type: 'agent-completed',
|
|
262
|
+
runId: context.runId,
|
|
263
|
+
agentId: subAgentId,
|
|
264
|
+
payload: {
|
|
265
|
+
role: 'planner',
|
|
266
|
+
result: '',
|
|
267
|
+
error: errorMessage,
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
publishClearingEvent(context);
|
|
271
|
+
await clearDraftChecklist(context);
|
|
272
|
+
return { result: `Planner error: ${errorMessage}` };
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=plan-with-agent.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-with-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-with-agent.tool.ts"],"names":[],"mappings":";;AAyLA,0DA4MC;AAvXD,8CAA2C;AAE3C,8CAAgD;AAChD,mCAAgC;AAChC,6BAAwB;AAExB,6DAAuF;AACvF,mEAA+D;AAC/D,mDAAgD;AAChD,2DAA2D;AAC3D,yDAA0D;AAC1D,mDAMyB;AACzB,2EAAsE;AACtE,uFAAkF;AAClF,sEAAuE;AACvE,uEAA4F;AAG5F,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAG7B,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAGhC,MAAM,yBAAyB,GAAG;IACjC,cAAc;IACd,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,uBAAuB;IACvB,gBAAgB;IAChB,UAAU;CACV,CAAC;AAGF,MAAM,2BAA2B,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AAYhE,SAAS,4BAA4B,CAAC,OAAgB;IACrD,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAGhD,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAGD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,gBAAgB,CAAC,OAAO,CAAC,CA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