@n8n/instance-ai 1.2.1 → 1.3.1
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/dist/agent/instance-agent.js +4 -12
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/sanitize-mcp-schemas.d.ts +4 -0
- package/dist/agent/sanitize-mcp-schemas.js +88 -18
- package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
- package/dist/agent/sub-agent-debriefing.d.ts +4 -4
- package/dist/agent/system-prompt.js +18 -18
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/constants/max-steps.d.ts +9 -0
- package/dist/constants/max-steps.js +13 -0
- package/dist/constants/max-steps.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/memory/title-utils.d.ts +1 -1
- package/dist/memory/title-utils.js +5 -23
- package/dist/memory/title-utils.js.map +1 -1
- package/dist/planned-tasks/planned-task-service.js +42 -6
- package/dist/planned-tasks/planned-task-service.js.map +1 -1
- package/dist/storage/workflow-loop-storage.d.ts +10 -0
- package/dist/stream/work-summary-accumulator.d.ts +6 -6
- package/dist/tools/credentials.tool.d.ts +2 -0
- package/dist/tools/credentials.tool.js +253 -0
- package/dist/tools/credentials.tool.js.map +1 -0
- package/dist/tools/data-tables.tool.d.ts +2 -0
- package/dist/tools/data-tables.tool.js +410 -0
- package/dist/tools/data-tables.tool.js.map +1 -0
- package/dist/tools/executions.tool.d.ts +2 -0
- package/dist/tools/executions.tool.js +177 -0
- package/dist/tools/executions.tool.js.map +1 -0
- package/dist/tools/index.d.ts +21 -57
- package/dist/tools/index.js +35 -132
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nodes.tool.d.ts +2 -0
- package/dist/tools/nodes.tool.js +298 -0
- package/dist/tools/nodes.tool.js.map +1 -0
- package/dist/tools/orchestration/blueprint.schema.d.ts +15 -15
- package/dist/tools/orchestration/browser-credential-setup.tool.js +13 -17
- package/dist/tools/orchestration/browser-credential-setup.tool.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.prompt.js +32 -28
- package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +9 -1
- package/dist/tools/orchestration/build-workflow-agent.tool.js +73 -58
- package/dist/tools/orchestration/build-workflow-agent.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 +7 -7
- package/dist/tools/orchestration/data-table-agent.tool.js +10 -22
- package/dist/tools/orchestration/data-table-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/delegate.tool.js +3 -3
- package/dist/tools/orchestration/delegate.tool.js.map +1 -1
- package/dist/tools/orchestration/plan-agent-prompt.d.ts +1 -1
- package/dist/tools/orchestration/plan-agent-prompt.js +5 -5
- package/dist/tools/orchestration/plan-with-agent.tool.js +9 -11
- package/dist/tools/orchestration/plan-with-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/research-with-agent.tool.js +6 -9
- package/dist/tools/orchestration/research-with-agent.tool.js.map +1 -1
- package/dist/tools/research.tool.d.ts +2 -0
- package/dist/tools/research.tool.js +159 -0
- package/dist/tools/research.tool.js.map +1 -0
- package/dist/tools/{orchestration/update-tasks.tool.d.ts → task-control.tool.d.ts} +2 -2
- package/dist/tools/task-control.tool.js +81 -0
- package/dist/tools/task-control.tool.js.map +1 -0
- package/dist/tools/templates.tool.d.ts +1 -0
- package/dist/tools/templates.tool.js +144 -0
- package/dist/tools/templates.tool.js.map +1 -0
- package/dist/tools/workflows/build-workflow.tool.js +2 -0
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/materialize-node-type.tool.d.ts +4 -4
- package/dist/tools/workflows/setup-workflow.service.d.ts +4 -1
- package/dist/tools/workflows/setup-workflow.service.js +91 -15
- package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
- package/dist/tools/workflows/submit-workflow.tool.d.ts +1 -0
- package/dist/tools/workflows/submit-workflow.tool.js +5 -0
- package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
- package/dist/tools/workflows.tool.d.ts +2 -0
- package/dist/tools/workflows.tool.js +498 -0
- package/dist/tools/workflows.tool.js.map +1 -0
- package/dist/tools/workspace.tool.d.ts +2 -0
- package/dist/tools/workspace.tool.js +278 -0
- package/dist/tools/workspace.tool.js.map +1 -0
- package/dist/tracing/langsmith-tracing.d.ts +1 -0
- package/dist/tracing/langsmith-tracing.js +170 -2
- package/dist/tracing/langsmith-tracing.js.map +1 -1
- package/dist/tracing/trace-replay.d.ts +61 -0
- package/dist/tracing/trace-replay.js +208 -0
- package/dist/tracing/trace-replay.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/workflow-loop/guidance.js +5 -5
- package/dist/workflow-loop/guidance.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-controller.js +5 -0
- package/dist/workflow-loop/workflow-loop-controller.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-state.d.ts +7 -0
- package/dist/workflow-loop/workflow-loop-state.js +2 -0
- package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
- package/package.json +10 -8
- package/dist/agent/tool-access.d.ts +0 -2
- package/dist/agent/tool-access.js +0 -28
- package/dist/agent/tool-access.js.map +0 -1
- package/dist/tools/best-practices/get-best-practices.tool.d.ts +0 -9
- package/dist/tools/best-practices/get-best-practices.tool.js +0 -66
- package/dist/tools/best-practices/get-best-practices.tool.js.map +0 -1
- package/dist/tools/credentials/delete-credential.tool.d.ts +0 -20
- package/dist/tools/credentials/delete-credential.tool.js +0 -58
- package/dist/tools/credentials/delete-credential.tool.js.map +0 -1
- package/dist/tools/credentials/get-credential.tool.d.ts +0 -10
- package/dist/tools/credentials/get-credential.tool.js +0 -32
- package/dist/tools/credentials/get-credential.tool.js.map +0 -1
- package/dist/tools/credentials/list-credentials.tool.d.ts +0 -16
- package/dist/tools/credentials/list-credentials.tool.js +0 -72
- package/dist/tools/credentials/list-credentials.tool.js.map +0 -1
- package/dist/tools/credentials/search-credential-types.tool.d.ts +0 -10
- package/dist/tools/credentials/search-credential-types.tool.js +0 -46
- package/dist/tools/credentials/search-credential-types.tool.js.map +0 -1
- package/dist/tools/credentials/setup-credentials.tool.d.ts +0 -69
- package/dist/tools/credentials/setup-credentials.tool.js +0 -140
- package/dist/tools/credentials/setup-credentials.tool.js.map +0 -1
- package/dist/tools/credentials/test-credential.tool.d.ts +0 -10
- package/dist/tools/credentials/test-credential.tool.js +0 -32
- package/dist/tools/credentials/test-credential.tool.js.map +0 -1
- package/dist/tools/data-tables/add-data-table-column.tool.d.ts +0 -23
- package/dist/tools/data-tables/add-data-table-column.tool.js +0 -67
- package/dist/tools/data-tables/add-data-table-column.tool.js.map +0 -1
- package/dist/tools/data-tables/create-data-table.tool.d.ts +0 -38
- package/dist/tools/data-tables/create-data-table.tool.js +0 -106
- package/dist/tools/data-tables/create-data-table.tool.js.map +0 -1
- package/dist/tools/data-tables/delete-data-table-column.tool.d.ts +0 -20
- package/dist/tools/data-tables/delete-data-table-column.tool.js +0 -55
- package/dist/tools/data-tables/delete-data-table-column.tool.js.map +0 -1
- package/dist/tools/data-tables/delete-data-table-rows.tool.d.ts +0 -63
- package/dist/tools/data-tables/delete-data-table-rows.tool.js +0 -79
- package/dist/tools/data-tables/delete-data-table-rows.tool.js.map +0 -1
- package/dist/tools/data-tables/delete-data-table.tool.d.ts +0 -17
- package/dist/tools/data-tables/delete-data-table.tool.js +0 -54
- package/dist/tools/data-tables/delete-data-table.tool.js.map +0 -1
- package/dist/tools/data-tables/get-data-table-schema.tool.d.ts +0 -10
- package/dist/tools/data-tables/get-data-table-schema.tool.js +0 -29
- package/dist/tools/data-tables/get-data-table-schema.tool.js.map +0 -1
- package/dist/tools/data-tables/insert-data-table-rows.tool.d.ts +0 -20
- package/dist/tools/data-tables/insert-data-table-rows.tool.js +0 -62
- package/dist/tools/data-tables/insert-data-table-rows.tool.js.map +0 -1
- package/dist/tools/data-tables/list-data-tables.tool.d.ts +0 -10
- package/dist/tools/data-tables/list-data-tables.tool.js +0 -34
- package/dist/tools/data-tables/list-data-tables.tool.js.map +0 -1
- package/dist/tools/data-tables/query-data-table-rows.tool.d.ts +0 -62
- package/dist/tools/data-tables/query-data-table-rows.tool.js +0 -56
- package/dist/tools/data-tables/query-data-table-rows.tool.js.map +0 -1
- package/dist/tools/data-tables/rename-data-table-column.tool.d.ts +0 -23
- package/dist/tools/data-tables/rename-data-table-column.tool.js +0 -56
- package/dist/tools/data-tables/rename-data-table-column.tool.js.map +0 -1
- package/dist/tools/data-tables/update-data-table-rows.tool.d.ts +0 -66
- package/dist/tools/data-tables/update-data-table-rows.tool.js +0 -67
- package/dist/tools/data-tables/update-data-table-rows.tool.js.map +0 -1
- package/dist/tools/executions/debug-execution.tool.d.ts +0 -10
- package/dist/tools/executions/debug-execution.tool.js +0 -43
- package/dist/tools/executions/debug-execution.tool.js.map +0 -1
- package/dist/tools/executions/get-execution.tool.d.ts +0 -10
- package/dist/tools/executions/get-execution.tool.js +0 -28
- package/dist/tools/executions/get-execution.tool.js.map +0 -1
- package/dist/tools/executions/get-node-output.tool.d.ts +0 -19
- package/dist/tools/executions/get-node-output.tool.js +0 -41
- package/dist/tools/executions/get-node-output.tool.js.map +0 -1
- package/dist/tools/executions/list-executions.tool.d.ts +0 -16
- package/dist/tools/executions/list-executions.tool.js +0 -47
- package/dist/tools/executions/list-executions.tool.js.map +0 -1
- package/dist/tools/executions/run-workflow.tool.d.ts +0 -26
- package/dist/tools/executions/run-workflow.tool.js +0 -92
- package/dist/tools/executions/run-workflow.tool.js.map +0 -1
- package/dist/tools/executions/stop-execution.tool.d.ts +0 -10
- package/dist/tools/executions/stop-execution.tool.js +0 -27
- package/dist/tools/executions/stop-execution.tool.js.map +0 -1
- package/dist/tools/nodes/explore-node-resources.tool.d.ts +0 -34
- package/dist/tools/nodes/explore-node-resources.tool.js +0 -73
- package/dist/tools/nodes/explore-node-resources.tool.js.map +0 -1
- package/dist/tools/nodes/get-node-description.tool.d.ts +0 -10
- package/dist/tools/nodes/get-node-description.tool.js +0 -54
- package/dist/tools/nodes/get-node-description.tool.js.map +0 -1
- package/dist/tools/nodes/get-node-type-definition.tool.d.ts +0 -40
- package/dist/tools/nodes/get-node-type-definition.tool.js +0 -75
- package/dist/tools/nodes/get-node-type-definition.tool.js.map +0 -1
- package/dist/tools/nodes/get-suggested-nodes.tool.d.ts +0 -9
- package/dist/tools/nodes/get-suggested-nodes.tool.js +0 -56
- package/dist/tools/nodes/get-suggested-nodes.tool.js.map +0 -1
- package/dist/tools/nodes/list-nodes.tool.d.ts +0 -10
- package/dist/tools/nodes/list-nodes.tool.js +0 -35
- package/dist/tools/nodes/list-nodes.tool.js.map +0 -1
- package/dist/tools/nodes/search-nodes.tool.d.ts +0 -16
- package/dist/tools/nodes/search-nodes.tool.js +0 -91
- package/dist/tools/nodes/search-nodes.tool.js.map +0 -1
- package/dist/tools/orchestration/cancel-background-task.tool.d.ts +0 -10
- package/dist/tools/orchestration/cancel-background-task.tool.js +0 -26
- package/dist/tools/orchestration/cancel-background-task.tool.js.map +0 -1
- package/dist/tools/orchestration/correct-background-task.tool.d.ts +0 -13
- package/dist/tools/orchestration/correct-background-task.tool.js +0 -43
- package/dist/tools/orchestration/correct-background-task.tool.js.map +0 -1
- package/dist/tools/orchestration/update-tasks.tool.js +0 -26
- package/dist/tools/orchestration/update-tasks.tool.js.map +0 -1
- package/dist/tools/templates/search-template-parameters.tool.d.ts +0 -18
- package/dist/tools/templates/search-template-parameters.tool.js +0 -57
- package/dist/tools/templates/search-template-parameters.tool.js.map +0 -1
- package/dist/tools/templates/search-template-structures.tool.d.ts +0 -15
- package/dist/tools/templates/search-template-structures.tool.js +0 -47
- package/dist/tools/templates/search-template-structures.tool.js.map +0 -1
- package/dist/tools/web-research/fetch-url.tool.d.ts +0 -13
- package/dist/tools/web-research/fetch-url.tool.js +0 -132
- package/dist/tools/web-research/fetch-url.tool.js.map +0 -1
- package/dist/tools/web-research/index.d.ts +0 -1
- package/dist/tools/web-research/index.js +0 -6
- package/dist/tools/web-research/index.js.map +0 -1
- package/dist/tools/web-research/web-search.tool.d.ts +0 -16
- package/dist/tools/web-research/web-search.tool.js +0 -59
- package/dist/tools/web-research/web-search.tool.js.map +0 -1
- package/dist/tools/workflows/delete-workflow.tool.d.ts +0 -20
- package/dist/tools/workflows/delete-workflow.tool.js +0 -55
- package/dist/tools/workflows/delete-workflow.tool.js.map +0 -1
- package/dist/tools/workflows/get-workflow-as-code.tool.d.ts +0 -10
- package/dist/tools/workflows/get-workflow-as-code.tool.js +0 -39
- package/dist/tools/workflows/get-workflow-as-code.tool.js.map +0 -1
- package/dist/tools/workflows/get-workflow-version.tool.d.ts +0 -13
- package/dist/tools/workflows/get-workflow-version.tool.js +0 -40
- package/dist/tools/workflows/get-workflow-version.tool.js.map +0 -1
- package/dist/tools/workflows/get-workflow.tool.d.ts +0 -10
- package/dist/tools/workflows/get-workflow.tool.js +0 -38
- package/dist/tools/workflows/get-workflow.tool.js.map +0 -1
- package/dist/tools/workflows/list-workflow-versions.tool.d.ts +0 -16
- package/dist/tools/workflows/list-workflow-versions.tool.js +0 -49
- package/dist/tools/workflows/list-workflow-versions.tool.js.map +0 -1
- package/dist/tools/workflows/list-workflows.tool.d.ts +0 -13
- package/dist/tools/workflows/list-workflows.tool.js +0 -44
- package/dist/tools/workflows/list-workflows.tool.js.map +0 -1
- package/dist/tools/workflows/publish-workflow.tool.d.ts +0 -10
- package/dist/tools/workflows/publish-workflow.tool.js +0 -97
- package/dist/tools/workflows/publish-workflow.tool.js.map +0 -1
- package/dist/tools/workflows/restore-workflow-version.tool.d.ts +0 -20
- package/dist/tools/workflows/restore-workflow-version.tool.js +0 -72
- package/dist/tools/workflows/restore-workflow-version.tool.js.map +0 -1
- package/dist/tools/workflows/setup-workflow.tool.d.ts +0 -13
- package/dist/tools/workflows/setup-workflow.tool.js +0 -215
- package/dist/tools/workflows/setup-workflow.tool.js.map +0 -1
- package/dist/tools/workflows/unpublish-workflow.tool.d.ts +0 -20
- package/dist/tools/workflows/unpublish-workflow.tool.js +0 -65
- package/dist/tools/workflows/unpublish-workflow.tool.js.map +0 -1
- package/dist/tools/workflows/update-workflow-version.tool.d.ts +0 -19
- package/dist/tools/workflows/update-workflow-version.tool.js +0 -37
- package/dist/tools/workflows/update-workflow-version.tool.js.map +0 -1
- package/dist/tools/workspace/cleanup-test-executions.tool.d.ts +0 -23
- package/dist/tools/workspace/cleanup-test-executions.tool.js +0 -62
- package/dist/tools/workspace/cleanup-test-executions.tool.js.map +0 -1
- package/dist/tools/workspace/create-folder.tool.d.ts +0 -23
- package/dist/tools/workspace/create-folder.tool.js +0 -72
- package/dist/tools/workspace/create-folder.tool.js.map +0 -1
- package/dist/tools/workspace/delete-folder.tool.d.ts +0 -29
- package/dist/tools/workspace/delete-folder.tool.js +0 -67
- package/dist/tools/workspace/delete-folder.tool.js.map +0 -1
- package/dist/tools/workspace/list-folders.tool.d.ts +0 -10
- package/dist/tools/workspace/list-folders.tool.js +0 -28
- package/dist/tools/workspace/list-folders.tool.js.map +0 -1
- package/dist/tools/workspace/list-projects.tool.d.ts +0 -4
- package/dist/tools/workspace/list-projects.tool.js +0 -26
- package/dist/tools/workspace/list-projects.tool.js.map +0 -1
- package/dist/tools/workspace/list-tags.tool.d.ts +0 -4
- package/dist/tools/workspace/list-tags.tool.js +0 -25
- package/dist/tools/workspace/list-tags.tool.js.map +0 -1
- package/dist/tools/workspace/move-workflow-to-folder.tool.d.ts +0 -26
- package/dist/tools/workspace/move-workflow-to-folder.tool.js +0 -60
- package/dist/tools/workspace/move-workflow-to-folder.tool.js.map +0 -1
- package/dist/tools/workspace/tag-workflow.tool.d.ts +0 -23
- package/dist/tools/workspace/tag-workflow.tool.js +0 -56
- package/dist/tools/workspace/tag-workflow.tool.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/data-table-agent.tool.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"data-table-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/data-table-agent.tool.ts"],"names":[],"mappings":";;;AAkDA,0DAoIC;AAgBD,4DAiBC;AA/MD,8CAA2C;AAE3C,8CAAgD;AAChD,mCAAgC;AAChC,6BAAwB;AAExB,uEAAoE;AACpE,mDAAgD;AAChD,mDAIyB;AACzB,2EAAsE;AACtE,uEAAuE;AACvE,yDAAsD;AACtD,uFAAkF;AAClF,sEAAuE;AACvE,uEAKyC;AAGzC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAgBpC,KAAK,UAAU,uBAAuB,CAC5C,OAA6B,EAC7B,KAA+B;IAG/B,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,IAAI,oBAAoB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACjD,cAAc,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAClF,CAAC;IACD,IAAI,YAAY,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACzC,cAAc,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,CAAC,CAAC,oBAAoB,IAAI,cAAc,CAAC,EAAE,CAAC;QAC/C,OAAO,EAAE,MAAM,EAAE,wCAAwC,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACtF,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAClC,OAAO,EAAE,MAAM,EAAE,+CAA+C,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC7F,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,IAAI,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AAW,EACV,gDAAgD;YAChD,2EAA2E;YAC3E,gDAAgD;QACjD,WAAW,EAAE,iCAAyB;QACtC,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC;YACtB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;YAClB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;SAClB,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,KAAgD,EAAE,EAAE;YACnE,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC7D,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAChF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -11,11 +11,11 @@ const register_with_mastra_1 = require("../../agent/register-with-mastra");
|
|
|
11
11
|
const sub_agent_briefing_1 = require("../../agent/sub-agent-briefing");
|
|
12
12
|
const sub_agent_debriefing_1 = require("../../agent/sub-agent-debriefing");
|
|
13
13
|
const sub_agent_factory_1 = require("../../agent/sub-agent-factory");
|
|
14
|
+
const max_steps_1 = require("../../constants/max-steps");
|
|
14
15
|
const resumable_stream_executor_1 = require("../../runtime/resumable-stream-executor");
|
|
15
16
|
const consume_with_hitl_1 = require("../../stream/consume-with-hitl");
|
|
16
17
|
const langsmith_tracing_1 = require("../../tracing/langsmith-tracing");
|
|
17
18
|
const FORBIDDEN_TOOL_NAMES = new Set(['plan', 'create-tasks', 'delegate']);
|
|
18
|
-
const FALLBACK_MAX_STEPS = 10;
|
|
19
19
|
function generateAgentId() {
|
|
20
20
|
return `agent-${(0, nanoid_1.nanoid)(6)}`;
|
|
21
21
|
}
|
|
@@ -135,7 +135,7 @@ async function startDetachedDelegateTask(context, input) {
|
|
|
135
135
|
return await (0, langsmith_tracing_1.withTraceParentContext)(traceParent, async () => {
|
|
136
136
|
const llmStepTraceHooks = (0, resumable_stream_executor_1.createLlmStepTraceHooks)(traceParent);
|
|
137
137
|
const stream = await subAgent.stream(briefingMessage, {
|
|
138
|
-
maxSteps: context.subAgentMaxSteps ??
|
|
138
|
+
maxSteps: context.subAgentMaxSteps ?? max_steps_1.MAX_STEPS.DELEGATE_FALLBACK,
|
|
139
139
|
abortSignal: signal,
|
|
140
140
|
providerOptions: {
|
|
141
141
|
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
@@ -228,7 +228,7 @@ function createDelegateTool(context) {
|
|
|
228
228
|
return await (0, langsmith_tracing_1.withTraceParentContext)(traceParent, async () => {
|
|
229
229
|
const llmStepTraceHooks = (0, resumable_stream_executor_1.createLlmStepTraceHooks)(traceParent);
|
|
230
230
|
const stream = await subAgent.stream(briefingMessage, {
|
|
231
|
-
maxSteps: context.subAgentMaxSteps ??
|
|
231
|
+
maxSteps: context.subAgentMaxSteps ?? max_steps_1.MAX_STEPS.DELEGATE_FALLBACK,
|
|
232
232
|
abortSignal: context.abortSignal,
|
|
233
233
|
providerOptions: {
|
|
234
234
|
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
@@ -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":";;AAkGA,8DAsIC;AAED,gDAuKC;AAhZD,8CAAgD;AAChD,mCAAgC;AAEhC,yDAAmG;AACnG,mDAAgD;AAChD,mDAQyB;AACzB,2EAAsE;AACtE,uEAAuE;AACvE,2EAAmE;AACnE,qEAAmF;AACnF,yDAAsD;AACtD,uFAAkF;AAClF,sEAAuE;AACvE,uEAA4F;AAG5F,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;AAE3E,SAA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;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"}
|
|
@@ -1 +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.";
|
|
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 `credentials(action=\"list\")`, `data-tables(action=\"list\")`, `templates(action=\"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 - `templates(action=\"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 - `nodes(action=\"suggested\")` for the relevant categories\n - `data-tables(action=\"list\")` to check for existing tables\n - `credentials(action=\"list\")` 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.";
|
|
@@ -15,17 +15,17 @@ You receive the recent conversation between the user and the orchestrator. Read
|
|
|
15
15
|
## Method
|
|
16
16
|
|
|
17
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
|
|
18
|
+
- **Never ask about things you can discover** — call \`credentials(action="list")\`, \`data-tables(action="list")\`, \`templates(action="best-practices")\` instead.
|
|
19
19
|
- **Never ask about implementation details** — trigger types, node choices, schedule times, column names. Pick sensible defaults.
|
|
20
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
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
22
|
- **List your assumptions** on your first \`add-plan-item\` call. The user reviews the plan before execution and can reject/correct.
|
|
23
23
|
|
|
24
24
|
2. **Discover** (3-6 tool calls) — check what exists and learn best practices:
|
|
25
|
-
- \`
|
|
26
|
-
- \`
|
|
27
|
-
- \`
|
|
28
|
-
- \`list
|
|
25
|
+
- \`templates(action="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
|
+
- \`nodes(action="suggested")\` for the relevant categories
|
|
27
|
+
- \`data-tables(action="list")\` to check for existing tables
|
|
28
|
+
- \`credentials(action="list")\` if the request involves external services
|
|
29
29
|
- Skip searches for nodes you already know exist (webhooks, schedule triggers, data tables, code, set, filter, etc.)
|
|
30
30
|
|
|
31
31
|
## Node Selection Reference
|
|
@@ -12,22 +12,20 @@ const plan_agent_prompt_1 = require("./plan-agent-prompt");
|
|
|
12
12
|
const submit_plan_tool_1 = require("./submit-plan.tool");
|
|
13
13
|
const tracing_utils_1 = require("./tracing-utils");
|
|
14
14
|
const register_with_mastra_1 = require("../../agent/register-with-mastra");
|
|
15
|
+
const max_steps_1 = require("../../constants/max-steps");
|
|
15
16
|
const resumable_stream_executor_1 = require("../../runtime/resumable-stream-executor");
|
|
16
17
|
const consume_with_hitl_1 = require("../../stream/consume-with-hitl");
|
|
17
18
|
const langsmith_tracing_1 = require("../../tracing/langsmith-tracing");
|
|
18
|
-
const PLANNER_MAX_STEPS = 30;
|
|
19
19
|
const MESSAGE_HISTORY_COUNT = 5;
|
|
20
20
|
const PLANNER_DOMAIN_TOOL_NAMES = [
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'get-data-table-schema',
|
|
27
|
-
'list-workflows',
|
|
21
|
+
'nodes',
|
|
22
|
+
'templates',
|
|
23
|
+
'credentials',
|
|
24
|
+
'data-tables',
|
|
25
|
+
'workflows',
|
|
28
26
|
'ask-user',
|
|
29
27
|
];
|
|
30
|
-
const PLANNER_RESEARCH_TOOL_NAMES = ['
|
|
28
|
+
const PLANNER_RESEARCH_TOOL_NAMES = ['research'];
|
|
31
29
|
function extractTextFromMemoryContent(content) {
|
|
32
30
|
if (typeof content === 'string')
|
|
33
31
|
return content;
|
|
@@ -190,7 +188,7 @@ function createPlanWithAgentTool(context) {
|
|
|
190
188
|
return await (0, langsmith_tracing_1.withTraceParentContext)(traceParent, async () => {
|
|
191
189
|
const llmStepTraceHooks = (0, resumable_stream_executor_1.createLlmStepTraceHooks)(traceParent);
|
|
192
190
|
const stream = await subAgent.stream(briefing, {
|
|
193
|
-
maxSteps:
|
|
191
|
+
maxSteps: max_steps_1.MAX_STEPS.PLANNER,
|
|
194
192
|
abortSignal: context.abortSignal,
|
|
195
193
|
providerOptions: {
|
|
196
194
|
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
@@ -208,7 +206,7 @@ function createPlanWithAgentTool(context) {
|
|
|
208
206
|
abortSignal: context.abortSignal,
|
|
209
207
|
waitForConfirmation: context.waitForConfirmation,
|
|
210
208
|
llmStepTraceHooks,
|
|
211
|
-
maxSteps:
|
|
209
|
+
maxSteps: max_steps_1.MAX_STEPS.PLANNER,
|
|
212
210
|
});
|
|
213
211
|
return await result.text;
|
|
214
212
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-with-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-with-agent.tool.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"plan-with-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-with-agent.tool.ts"],"names":[],"mappings":";;AAsLA,0DA4MC;AApXD,8CAA2C;AAE3C,8CAAgD;AAChD,mCAAgC;AAChC,6BAAwB;AAExB,6DAAuF;AACvF,mEAA+D;AAC/D,mDAAgD;AAChD,2DAA2D;AAC3D,yDAA0D;AAC1D,mDAMyB;AACzB,2EAAsE;AACtE,yDAAsD;AACtD,uFAAkF;AAClF,sEAAuE;AACvE,uEAA4F;AAI5F,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAGhC,MAAM,yBAAyB,GAAG;IACjC,OAAO;IACP,WAAW;IACX,aAAa;IACb,aAAa;IACb,WAAW;IACX,UAAU;CACV,CAAC;AAGF,MAAM,2BAA2B,GAAG,CAAC,UAAU,CAAC,CAAC;AAYjD,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,CAAC;IAClC,CAAC;IAED,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvF,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IAC1C,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI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AAM,EAAE,EAAE;wBACV,KAAK,EAAE,YAAY;qBACnB;iBACD,CAAC,CAAC;gBAGH,oBAAoB,CAAC,OAAO,CAAC,CAAC;gBAC9B,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBAEnC,OAAO,EAAE,MAAM,EAAE,kBAAkB,YAAY,EAAE,EAAE,CAAC;YACrD,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -12,20 +12,17 @@ const research_agent_prompt_1 = require("./research-agent-prompt");
|
|
|
12
12
|
const tracing_utils_1 = require("./tracing-utils");
|
|
13
13
|
const register_with_mastra_1 = require("../../agent/register-with-mastra");
|
|
14
14
|
const sub_agent_briefing_1 = require("../../agent/sub-agent-briefing");
|
|
15
|
+
const max_steps_1 = require("../../constants/max-steps");
|
|
15
16
|
const resumable_stream_executor_1 = require("../../runtime/resumable-stream-executor");
|
|
16
17
|
const consume_with_hitl_1 = require("../../stream/consume-with-hitl");
|
|
17
18
|
const langsmith_tracing_1 = require("../../tracing/langsmith-tracing");
|
|
18
|
-
const RESEARCH_MAX_STEPS = 25;
|
|
19
19
|
async function startResearchAgentTask(context, input) {
|
|
20
20
|
const researchTools = {};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (name in context.domainTools) {
|
|
24
|
-
researchTools[name] = context.domainTools[name];
|
|
25
|
-
}
|
|
21
|
+
if ('research' in context.domainTools) {
|
|
22
|
+
researchTools.research = context.domainTools.research;
|
|
26
23
|
}
|
|
27
|
-
if (
|
|
28
|
-
return { result: 'Error:
|
|
24
|
+
if (Object.keys(researchTools).length === 0) {
|
|
25
|
+
return { result: 'Error: research tool not available.', taskId: '', agentId: '' };
|
|
29
26
|
}
|
|
30
27
|
if (!context.spawnBackgroundTask) {
|
|
31
28
|
return { result: 'Error: background task support not available.', taskId: '', agentId: '' };
|
|
@@ -98,7 +95,7 @@ async function startResearchAgentTask(context, input) {
|
|
|
98
95
|
return await (0, langsmith_tracing_1.withTraceParentContext)(traceParent, async () => {
|
|
99
96
|
const llmStepTraceHooks = (0, resumable_stream_executor_1.createLlmStepTraceHooks)(traceParent);
|
|
100
97
|
const stream = await subAgent.stream(briefing, {
|
|
101
|
-
maxSteps:
|
|
98
|
+
maxSteps: max_steps_1.MAX_STEPS.RESEARCH,
|
|
102
99
|
abortSignal: signal,
|
|
103
100
|
providerOptions: {
|
|
104
101
|
anthropic: { cacheControl: { type: 'ephemeral' } },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"research-with-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/research-with-agent.tool.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"research-with-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/research-with-agent.tool.ts"],"names":[],"mappings":";;;AAgDA,wDA+HC;AAqBD,kEAkBC;AA/MD,8CAA2C;AAE3C,8CAAgD;AAChD,mCAAgC;AAChC,6BAAwB;AAExB,mDAAgD;AAChD,mEAAgE;AAChE,mDAIyB;AACzB,2EAAsE;AACtE,uEAAuE;AACvE,yDAAsD;AACtD,uFAAkF;AAClF,sEAAuE;AACvE,uEAKyC;AAkBlC,KAAK,UAAU,sBAAsB,CAC3C,OAA6B,EAC7B,KAA8B;IAE9B,MAAM,aAAa,GAAe,EAAE,CAAC;IACrC,IAAI,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACvC,aAAa,CAAC,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC;IACvD,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,MAAM,EAAE,qCAAqC,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACnF,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAClC,OAAO,EAAE,MAAM,EAAE,+CA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AAQ,CACR,uEAAuE;QACtE,oDAAoD,CACrD;IACF,WAAW,EAAE,OAAC;SACZ,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,6DAA6D,CAAC;IACzE,mBAAmB,EAAE,OAAC;SACpB,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACR,qLAAqL,CACrL;CACF,CAAC,CAAC;AAEH,SAAgB,2BAA2B,CAAC,OAA6B;IACxE,OAAO,IAAA,kBAAU,EAAC;QACjB,EAAE,EAAE,qBAAqB;QACzB,WAAW,EACV,0EAA0E;YAC1E,6EAA6E;YAC7E,8EAA8E;YAC9E,mEAAmE;QACpE,WAAW,EAAE,oCAA4B;QACzC,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC;YACtB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;YAClB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;SAClB,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,KAAmD,EAAE,EAAE;YACtE,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC5D,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAChF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { InstanceAiContext } from '../types';
|
|
2
|
+
export declare function createResearchTool(context: InstanceAiContext): import("@mastra/core/tools").Tool<InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, import("@mastra/core/tools").ToolExecutionContext<InferPublicSchema<T>, InferPublicSchema<T>, unknown>, "research", unknown>;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createResearchTool = createResearchTool;
|
|
4
|
+
const tools_1 = require("@mastra/core/tools");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const sanitize_mcp_schemas_1 = require("../agent/sanitize-mcp-schemas");
|
|
7
|
+
const domain_access_1 = require("../domain-access");
|
|
8
|
+
const sanitize_web_content_1 = require("./web-research/sanitize-web-content");
|
|
9
|
+
const webSearchAction = zod_1.z.object({
|
|
10
|
+
action: zod_1.z.literal('web-search').describe('Search the web for information'),
|
|
11
|
+
query: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.describe('Search query. Be specific — include service names, API versions, error codes.'),
|
|
14
|
+
maxResults: zod_1.z
|
|
15
|
+
.number()
|
|
16
|
+
.int()
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(20)
|
|
19
|
+
.default(5)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Maximum number of results to return (default 5, max 20)'),
|
|
22
|
+
includeDomains: zod_1.z
|
|
23
|
+
.array(zod_1.z.string())
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Restrict results to these domains, e.g. ["docs.stripe.com"]'),
|
|
26
|
+
});
|
|
27
|
+
const fetchUrlAction = zod_1.z.object({
|
|
28
|
+
action: zod_1.z.literal('fetch-url').describe('Fetch a web page and extract its content as markdown'),
|
|
29
|
+
url: zod_1.z.string().url().describe('URL of the page to fetch'),
|
|
30
|
+
maxContentLength: zod_1.z
|
|
31
|
+
.number()
|
|
32
|
+
.int()
|
|
33
|
+
.positive()
|
|
34
|
+
.max(100_000)
|
|
35
|
+
.default(30_000)
|
|
36
|
+
.optional()
|
|
37
|
+
.describe('Maximum content length in characters (default 30000)'),
|
|
38
|
+
});
|
|
39
|
+
const inputSchema = (0, sanitize_mcp_schemas_1.sanitizeInputSchema)(zod_1.z.discriminatedUnion('action', [webSearchAction, fetchUrlAction]));
|
|
40
|
+
async function handleWebSearch(context, input) {
|
|
41
|
+
if (!context.webResearchService?.search) {
|
|
42
|
+
return { query: input.query, results: [] };
|
|
43
|
+
}
|
|
44
|
+
const result = await context.webResearchService.search(input.query, {
|
|
45
|
+
maxResults: input.maxResults ?? undefined,
|
|
46
|
+
includeDomains: input.includeDomains ?? undefined,
|
|
47
|
+
});
|
|
48
|
+
for (const r of result.results) {
|
|
49
|
+
r.snippet = (0, sanitize_web_content_1.sanitizeWebContent)(r.snippet);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
async function handleFetchUrl(context, input, ctx) {
|
|
54
|
+
if (!context.webResearchService) {
|
|
55
|
+
return {
|
|
56
|
+
url: input.url,
|
|
57
|
+
finalUrl: input.url,
|
|
58
|
+
title: '',
|
|
59
|
+
content: 'Web research is not available in this environment.',
|
|
60
|
+
truncated: false,
|
|
61
|
+
contentLength: 0,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const resumeData = ctx?.agent?.resumeData;
|
|
65
|
+
const suspend = ctx?.agent?.suspend;
|
|
66
|
+
if (resumeData !== undefined && resumeData !== null) {
|
|
67
|
+
let host;
|
|
68
|
+
try {
|
|
69
|
+
host = new URL(input.url).hostname;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
host = input.url;
|
|
73
|
+
}
|
|
74
|
+
const { proceed } = (0, domain_access_1.applyDomainAccessResume)({
|
|
75
|
+
resumeData,
|
|
76
|
+
host,
|
|
77
|
+
tracker: context.domainAccessTracker,
|
|
78
|
+
runId: context.runId,
|
|
79
|
+
});
|
|
80
|
+
if (!proceed) {
|
|
81
|
+
return {
|
|
82
|
+
url: input.url,
|
|
83
|
+
finalUrl: input.url,
|
|
84
|
+
title: '',
|
|
85
|
+
content: 'User denied access to this URL.',
|
|
86
|
+
truncated: false,
|
|
87
|
+
contentLength: 0,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (resumeData === undefined || resumeData === null) {
|
|
92
|
+
const check = (0, domain_access_1.checkDomainAccess)({
|
|
93
|
+
url: input.url,
|
|
94
|
+
tracker: context.domainAccessTracker,
|
|
95
|
+
permissionMode: context.permissions?.fetchUrl,
|
|
96
|
+
runId: context.runId,
|
|
97
|
+
});
|
|
98
|
+
if (!check.allowed) {
|
|
99
|
+
if (check.blocked) {
|
|
100
|
+
return {
|
|
101
|
+
url: input.url,
|
|
102
|
+
finalUrl: input.url,
|
|
103
|
+
title: '',
|
|
104
|
+
content: 'Action blocked by admin.',
|
|
105
|
+
truncated: false,
|
|
106
|
+
contentLength: 0,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
await suspend?.(check.suspendPayload);
|
|
110
|
+
return {
|
|
111
|
+
url: input.url,
|
|
112
|
+
finalUrl: input.url,
|
|
113
|
+
title: '',
|
|
114
|
+
content: '',
|
|
115
|
+
truncated: false,
|
|
116
|
+
contentLength: 0,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const authorizeUrl = async (targetUrl) => {
|
|
121
|
+
const redirectCheck = (0, domain_access_1.checkDomainAccess)({
|
|
122
|
+
url: targetUrl,
|
|
123
|
+
tracker: context.domainAccessTracker,
|
|
124
|
+
permissionMode: context.permissions?.fetchUrl,
|
|
125
|
+
runId: context.runId,
|
|
126
|
+
});
|
|
127
|
+
if (!redirectCheck.allowed) {
|
|
128
|
+
const reason = redirectCheck.blocked
|
|
129
|
+
? `Access to ${new URL(targetUrl).hostname} is blocked by admin.`
|
|
130
|
+
: `Redirect to ${new URL(targetUrl).hostname} requires approval. ` +
|
|
131
|
+
`Retry with the direct URL: ${targetUrl}`;
|
|
132
|
+
throw new Error(reason);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const result = await context.webResearchService.fetchUrl(input.url, {
|
|
136
|
+
maxContentLength: input.maxContentLength ?? undefined,
|
|
137
|
+
authorizeUrl,
|
|
138
|
+
});
|
|
139
|
+
result.content = (0, sanitize_web_content_1.wrapInBoundaryTags)((0, sanitize_web_content_1.sanitizeWebContent)(result.content), result.finalUrl);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
function createResearchTool(context) {
|
|
143
|
+
return (0, tools_1.createTool)({
|
|
144
|
+
id: 'research',
|
|
145
|
+
description: 'Search the web or fetch page content.',
|
|
146
|
+
inputSchema,
|
|
147
|
+
suspendSchema: domain_access_1.domainGatingSuspendSchema,
|
|
148
|
+
resumeSchema: domain_access_1.domainGatingResumeSchema,
|
|
149
|
+
execute: async (input, ctx) => {
|
|
150
|
+
switch (input.action) {
|
|
151
|
+
case 'web-search':
|
|
152
|
+
return await handleWebSearch(context, input);
|
|
153
|
+
case 'fetch-url':
|
|
154
|
+
return await handleFetchUrl(context, input, ctx);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=research.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research.tool.js","sourceRoot":"","sources":["../../src/tools/research.tool.ts"],"names":[],"mappings":";;AAsLA,gDAgBC;AAnMD,8CAAgD;AAChD,6BAAwB;AAExB,wEAAoE;AACpE,oDAK0B;AAE1B,8EAA6F;AAI7F,MAAM,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IAChC,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,gCAAgC,CAAC;IAC1E,KAAK,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CAAC,+EAA+E,CAAC;IAC3F,UAAU,EAAE,OAAC;SACX,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,EAAE,CAAC;SACP,OAAO,CAAC,CAAC,CAAC;SACV,QAAQ,EAAE;SACV,QAAQ,CAAC,yDAAyD,CAAC;IACrE,cAAc,EAAE,OAAC;SACf,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CAAC,6DAA6D,CAAC;CACzE,CAAC,CAAC;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sB;oBACjE,8BAA8B,SAAS,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACF,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE;QACnE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,IAAI,SAAS;QACrD,YAAY;KACZ,CAAC,CAAC;IACH,MAAM,CAAC,OAAO,GAAG,IAAA,yCAAkB,EAAC,IAAA,yCAAkB,EAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzF,OAAO,MAAM,CAAC;AACf,CAAC;AAID,SAAgB,kBAAkB,CAAC,OAA0B;IAC5D,OAAO,IAAA,kBAAU,EAAC;QACjB,EAAE,EAAE,UAAU;QACd,WAAW,EAAE,uCAAuC;QACpD,WAAW;QACX,aAAa,EAAE,yCAAyB;QACxC,YAAY,EAAE,wCAAwB;QACtC,OAAO,EAAE,KAAK,EAAE,KAAY,EAAE,GAAG,EAAE,EAAE;YACpC,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;gBACtB,KAAK,YAAY;oBAChB,OAAO,MAAM,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC9C,KAAK,WAAW;oBACf,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YACnD,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { OrchestrationContext } from '
|
|
2
|
-
export declare function
|
|
1
|
+
import type { OrchestrationContext } from '../types';
|
|
2
|
+
export declare function createTaskControlTool(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>, "task-control", unknown>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTaskControlTool = createTaskControlTool;
|
|
4
|
+
const tools_1 = require("@mastra/core/tools");
|
|
5
|
+
const api_types_1 = require("@n8n/api-types");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const sanitize_mcp_schemas_1 = require("../agent/sanitize-mcp-schemas");
|
|
8
|
+
const updateChecklistAction = zod_1.z.object({
|
|
9
|
+
action: zod_1.z
|
|
10
|
+
.literal('update-checklist')
|
|
11
|
+
.describe('Write or update a visible task checklist for multi-step work'),
|
|
12
|
+
tasks: api_types_1.taskListSchema.shape.tasks,
|
|
13
|
+
});
|
|
14
|
+
const cancelTaskAction = zod_1.z.object({
|
|
15
|
+
action: zod_1.z.literal('cancel-task').describe('Cancel a running background task by its task ID'),
|
|
16
|
+
taskId: zod_1.z.string().describe('Task ID (e.g. build-XXXXXXXX)'),
|
|
17
|
+
});
|
|
18
|
+
const correctTaskAction = zod_1.z.object({
|
|
19
|
+
action: zod_1.z.literal('correct-task').describe('Send a correction to a running background task'),
|
|
20
|
+
taskId: zod_1.z.string().describe('Task ID (e.g. build-XXXXXXXX)'),
|
|
21
|
+
correction: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.describe("The correction message from the user (e.g. 'use the Projects database')"),
|
|
24
|
+
});
|
|
25
|
+
const inputSchema = (0, sanitize_mcp_schemas_1.sanitizeInputSchema)(zod_1.z.discriminatedUnion('action', [updateChecklistAction, cancelTaskAction, correctTaskAction]));
|
|
26
|
+
async function handleUpdateChecklist(context, input) {
|
|
27
|
+
const taskList = { tasks: input.tasks };
|
|
28
|
+
await context.taskStorage.save(context.threadId, taskList);
|
|
29
|
+
context.eventBus.publish(context.threadId, {
|
|
30
|
+
type: 'tasks-update',
|
|
31
|
+
runId: context.runId,
|
|
32
|
+
agentId: context.orchestratorAgentId,
|
|
33
|
+
payload: { tasks: taskList },
|
|
34
|
+
});
|
|
35
|
+
return { saved: true };
|
|
36
|
+
}
|
|
37
|
+
async function handleCancelTask(context, input) {
|
|
38
|
+
if (!context.cancelBackgroundTask) {
|
|
39
|
+
return { result: 'Error: background task cancellation not available.' };
|
|
40
|
+
}
|
|
41
|
+
await context.cancelBackgroundTask(input.taskId);
|
|
42
|
+
return { result: `Background task ${input.taskId} cancelled.` };
|
|
43
|
+
}
|
|
44
|
+
async function handleCorrectTask(context, input) {
|
|
45
|
+
if (!context.sendCorrectionToTask) {
|
|
46
|
+
return await Promise.resolve({ result: 'Error: correction delivery not available.' });
|
|
47
|
+
}
|
|
48
|
+
const status = context.sendCorrectionToTask(input.taskId, input.correction);
|
|
49
|
+
if (status === 'task-not-found') {
|
|
50
|
+
return await Promise.resolve({
|
|
51
|
+
result: `Task ${input.taskId} not found. It may have already been cleaned up.`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (status === 'task-completed') {
|
|
55
|
+
return await Promise.resolve({
|
|
56
|
+
result: `Task ${input.taskId} has already completed. The correction was not delivered. ` +
|
|
57
|
+
`Incorporate "${input.correction}" into a new follow-up task instead.`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return await Promise.resolve({
|
|
61
|
+
result: `Correction sent to task ${input.taskId}: "${input.correction}". The builder will see this on its next step.`,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function createTaskControlTool(context) {
|
|
65
|
+
return (0, tools_1.createTool)({
|
|
66
|
+
id: 'task-control',
|
|
67
|
+
description: 'Manage tasks and background work.',
|
|
68
|
+
inputSchema,
|
|
69
|
+
execute: async (input) => {
|
|
70
|
+
switch (input.action) {
|
|
71
|
+
case 'update-checklist':
|
|
72
|
+
return await handleUpdateChecklist(context, input);
|
|
73
|
+
case 'cancel-task':
|
|
74
|
+
return await handleCancelTask(context, input);
|
|
75
|
+
case 'correct-task':
|
|
76
|
+
return await handleCorrectTask(context, input);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=task-control.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-control.tool.js","sourceRoot":"","sources":["../../src/tools/task-control.tool.ts"],"names":[],"mappings":";;AA6FA,sDAgBC;AA1GD,8CAAgD;AAChD,8CAAgD;AAChD,6BAAwB;AAExB,wEAAoE;AAKpE,MAAM,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,MAAM,EAAE,OAAC;SACP,OAAO,CAAC,kBAAkB,CAAC;SAC3B,QAAQ,CAAC,8DAA8D,CAAC;IAC1E,KAAK,EAAE,0BAAc,CAAC,KAAK,CAAC,KAAK;CACjC,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAC5F,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CAC5D,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,gDAAgD,CAAC;IAC5F,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAC5D,UAAU,EAAE,OAAC;SACX,MAAM,EAAE;SACR,QAAQ,CAAC,yEAAyE,CAAC;CACrF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,IAAA,0CAAmB,EACtC,OAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC,qBAAqB,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC,CAC5F,CAAC;AAMF,KAAK,UAAU,qBAAqB,CACnC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AAK,CAAC,MAAM,kDAAkD;SAC9E,CAAC,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,KAAK,gBAAgB,EAAE,CAAC;QACjC,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC;YAC5B,MAAM,EACL,QAAQ,KAAK,CAAC,MAAM,4DAA4D;gBAChF,gBAAgB,KAAK,CAAC,UAAU,sCAAsC;SACvE,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC;QAC5B,MAAM,EAAE,2BAA2B,KAAK,CAAC,MAAM,MAAM,KAAK,CAAC,UAAU,gDAAgD;KACrH,CAAC,CAAC;AACJ,CAAC;AAID,SAAgB,qBAAqB,CAAC,OAA6B;IAClE,OAAO,IAAA,kBAAU,EAAC;QACjB,EAAE,EAAE,cAAc;QAClB,WAAW,EAAE,mCAAmC;QAChD,WAAW;QACX,OAAO,EAAE,KAAK,EAAE,KAAY,EAAE,EAAE;YAC/B,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;gBACtB,KAAK,kBAAkB;oBACtB,OAAO,MAAM,qBAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBACpD,KAAK,aAAa;oBACjB,OAAO,MAAM,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC/C,KAAK,cAAc;oBAClB,OAAO,MAAM,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACjD,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createTemplatesTool(): import("@mastra/core/tools").Tool<InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, import("@mastra/core/tools").ToolExecutionContext<InferPublicSchema<T>, InferPublicSchema<T>, unknown>, "templates", unknown>;
|