@n8n/instance-ai 1.4.1 → 1.6.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.
Files changed (266) hide show
  1. package/dist/agent/computer-use-prompt.d.ts +5 -0
  2. package/dist/agent/computer-use-prompt.js +97 -0
  3. package/dist/agent/computer-use-prompt.js.map +1 -0
  4. package/dist/agent/instance-agent.js +48 -73
  5. package/dist/agent/instance-agent.js.map +1 -1
  6. package/dist/agent/mcp-tool-name-validation.d.ts +15 -0
  7. package/dist/agent/mcp-tool-name-validation.js +67 -0
  8. package/dist/agent/mcp-tool-name-validation.js.map +1 -0
  9. package/dist/agent/sanitize-mcp-schemas.d.ts +56 -2
  10. package/dist/agent/sanitize-mcp-schemas.js +226 -19
  11. package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
  12. package/dist/agent/sub-agent-debriefing.d.ts +2 -2
  13. package/dist/agent/sub-agent-factory.d.ts +1 -0
  14. package/dist/agent/sub-agent-factory.js +1 -0
  15. package/dist/agent/sub-agent-factory.js.map +1 -1
  16. package/dist/agent/system-prompt.d.ts +1 -1
  17. package/dist/agent/system-prompt.js +46 -104
  18. package/dist/agent/system-prompt.js.map +1 -1
  19. package/dist/build.tsbuildinfo +1 -1
  20. package/dist/constants/model-settings.d.ts +3 -0
  21. package/dist/constants/model-settings.js +7 -0
  22. package/dist/constants/model-settings.js.map +1 -0
  23. package/dist/domain-access/domain-access-tracker.d.ts +3 -0
  24. package/dist/domain-access/domain-access-tracker.js +16 -0
  25. package/dist/domain-access/domain-access-tracker.js.map +1 -1
  26. package/dist/domain-access/domain-gating.d.ts +35 -6
  27. package/dist/domain-access/domain-gating.js +47 -1
  28. package/dist/domain-access/domain-gating.js.map +1 -1
  29. package/dist/domain-access/index.d.ts +1 -1
  30. package/dist/domain-access/index.js +3 -1
  31. package/dist/domain-access/index.js.map +1 -1
  32. package/dist/index.d.ts +14 -6
  33. package/dist/index.js +19 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/logger.d.ts +6 -0
  36. package/dist/mcp/mcp-client-manager.d.ts +18 -2
  37. package/dist/mcp/mcp-client-manager.js +124 -20
  38. package/dist/mcp/mcp-client-manager.js.map +1 -1
  39. package/dist/parsers/docx-parser.d.ts +6 -0
  40. package/dist/parsers/docx-parser.js +65 -0
  41. package/dist/parsers/docx-parser.js.map +1 -0
  42. package/dist/parsers/html-parser.d.ts +7 -0
  43. package/dist/parsers/html-parser.js +67 -0
  44. package/dist/parsers/html-parser.js.map +1 -0
  45. package/dist/parsers/index.d.ts +4 -0
  46. package/dist/parsers/index.js +16 -0
  47. package/dist/parsers/index.js.map +1 -0
  48. package/dist/parsers/pdf-parser.d.ts +7 -0
  49. package/dist/parsers/pdf-parser.js +72 -0
  50. package/dist/parsers/pdf-parser.js.map +1 -0
  51. package/dist/parsers/structured-file-parser.d.ts +8 -3
  52. package/dist/parsers/structured-file-parser.js +36 -4
  53. package/dist/parsers/structured-file-parser.js.map +1 -1
  54. package/dist/parsers/validate-attachments.d.ts +14 -0
  55. package/dist/parsers/validate-attachments.js +61 -0
  56. package/dist/parsers/validate-attachments.js.map +1 -0
  57. package/dist/parsers/xlsx-parser.d.ts +2 -0
  58. package/dist/parsers/xlsx-parser.js +75 -0
  59. package/dist/parsers/xlsx-parser.js.map +1 -0
  60. package/dist/planned-tasks/planned-task-permissions.d.ts +2 -0
  61. package/dist/planned-tasks/planned-task-permissions.js +8 -2
  62. package/dist/planned-tasks/planned-task-permissions.js.map +1 -1
  63. package/dist/planned-tasks/planned-task-service.d.ts +14 -1
  64. package/dist/planned-tasks/planned-task-service.js +138 -2
  65. package/dist/planned-tasks/planned-task-service.js.map +1 -1
  66. package/dist/runtime/background-task-manager.d.ts +32 -1
  67. package/dist/runtime/background-task-manager.js +134 -4
  68. package/dist/runtime/background-task-manager.js.map +1 -1
  69. package/dist/runtime/builder-sandbox-session-registry.d.ts +45 -0
  70. package/dist/runtime/builder-sandbox-session-registry.js +159 -0
  71. package/dist/runtime/builder-sandbox-session-registry.js.map +1 -0
  72. package/dist/runtime/liveness-policy.d.ts +40 -0
  73. package/dist/runtime/liveness-policy.js +74 -0
  74. package/dist/runtime/liveness-policy.js.map +1 -0
  75. package/dist/runtime/resumable-stream-executor.d.ts +1 -0
  76. package/dist/runtime/resumable-stream-executor.js +1 -0
  77. package/dist/runtime/resumable-stream-executor.js.map +1 -1
  78. package/dist/runtime/run-state-registry.d.ts +21 -5
  79. package/dist/runtime/run-state-registry.js +109 -7
  80. package/dist/runtime/run-state-registry.js.map +1 -1
  81. package/dist/runtime/stream-runner.d.ts +3 -0
  82. package/dist/runtime/stream-runner.js +3 -0
  83. package/dist/runtime/stream-runner.js.map +1 -1
  84. package/dist/runtime/terminal-response-guard.d.ts +30 -0
  85. package/dist/runtime/terminal-response-guard.js +149 -0
  86. package/dist/runtime/terminal-response-guard.js.map +1 -0
  87. package/dist/storage/agent-tree-snapshot.d.ts +2 -0
  88. package/dist/storage/index.d.ts +2 -0
  89. package/dist/storage/index.js +3 -1
  90. package/dist/storage/index.js.map +1 -1
  91. package/dist/storage/planned-task-storage.js +2 -1
  92. package/dist/storage/planned-task-storage.js.map +1 -1
  93. package/dist/storage/terminal-outcome-storage.d.ts +48 -0
  94. package/dist/storage/terminal-outcome-storage.js +84 -0
  95. package/dist/storage/terminal-outcome-storage.js.map +1 -0
  96. package/dist/storage/workflow-loop-storage.d.ts +442 -16
  97. package/dist/stream/consume-with-hitl.d.ts +2 -0
  98. package/dist/stream/consume-with-hitl.js +2 -0
  99. package/dist/stream/consume-with-hitl.js.map +1 -1
  100. package/dist/stream/map-chunk.js +6 -0
  101. package/dist/stream/map-chunk.js.map +1 -1
  102. package/dist/tools/attachments/parse-file.tool.d.ts +46 -34
  103. package/dist/tools/attachments/parse-file.tool.js +115 -56
  104. package/dist/tools/attachments/parse-file.tool.js.map +1 -1
  105. package/dist/tools/credentials.tool.d.ts +120 -1
  106. package/dist/tools/credentials.tool.js +65 -12
  107. package/dist/tools/credentials.tool.js.map +1 -1
  108. package/dist/tools/data-tables.tool.d.ts +1 -0
  109. package/dist/tools/data-tables.tool.js +64 -24
  110. package/dist/tools/data-tables.tool.js.map +1 -1
  111. package/dist/tools/executions.tool.js +4 -1
  112. package/dist/tools/executions.tool.js.map +1 -1
  113. package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +2 -1
  114. package/dist/tools/filesystem/create-tools-from-mcp-server.js +74 -5
  115. package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
  116. package/dist/tools/index.d.ts +4 -24
  117. package/dist/tools/index.js +23 -7
  118. package/dist/tools/index.js.map +1 -1
  119. package/dist/tools/nodes.tool.js +15 -15
  120. package/dist/tools/nodes.tool.js.map +1 -1
  121. package/dist/tools/orchestration/add-plan-item.tool.js +3 -1
  122. package/dist/tools/orchestration/add-plan-item.tool.js.map +1 -1
  123. package/dist/tools/orchestration/blueprint-accumulator.d.ts +4 -1
  124. package/dist/tools/orchestration/blueprint-accumulator.js +28 -0
  125. package/dist/tools/orchestration/blueprint-accumulator.js.map +1 -1
  126. package/dist/tools/orchestration/blueprint.schema.d.ts +61 -16
  127. package/dist/tools/orchestration/blueprint.schema.js +15 -1
  128. package/dist/tools/orchestration/blueprint.schema.js.map +1 -1
  129. package/dist/tools/orchestration/browser-credential-setup.nudge.d.ts +5 -0
  130. package/dist/tools/orchestration/browser-credential-setup.nudge.js +11 -0
  131. package/dist/tools/orchestration/browser-credential-setup.nudge.js.map +1 -0
  132. package/dist/tools/orchestration/browser-credential-setup.prompt.js +2 -1
  133. package/dist/tools/orchestration/browser-credential-setup.prompt.js.map +1 -1
  134. package/dist/tools/orchestration/browser-credential-setup.tool.js +55 -7
  135. package/dist/tools/orchestration/browser-credential-setup.tool.js.map +1 -1
  136. package/dist/tools/orchestration/build-workflow-agent.prompt.js +86 -60
  137. package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -1
  138. package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +56 -3
  139. package/dist/tools/orchestration/build-workflow-agent.tool.js +1020 -300
  140. package/dist/tools/orchestration/build-workflow-agent.tool.js.map +1 -1
  141. package/dist/tools/orchestration/builder-memory-compaction.d.ts +38 -0
  142. package/dist/tools/orchestration/builder-memory-compaction.js +146 -0
  143. package/dist/tools/orchestration/builder-memory-compaction.js.map +1 -0
  144. package/dist/tools/orchestration/complete-checkpoint.tool.d.ts +2 -0
  145. package/dist/tools/orchestration/complete-checkpoint.tool.js +76 -0
  146. package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -0
  147. package/dist/tools/orchestration/data-table-agent.tool.js +34 -17
  148. package/dist/tools/orchestration/data-table-agent.tool.js.map +1 -1
  149. package/dist/tools/orchestration/delegate.tool.js +34 -16
  150. package/dist/tools/orchestration/delegate.tool.js.map +1 -1
  151. package/dist/tools/orchestration/plan-agent-prompt.d.ts +1 -1
  152. package/dist/tools/orchestration/plan-agent-prompt.js +7 -0
  153. package/dist/tools/orchestration/plan-agent-prompt.js.map +1 -1
  154. package/dist/tools/orchestration/plan-with-agent.tool.d.ts +23 -0
  155. package/dist/tools/orchestration/plan-with-agent.tool.js +314 -13
  156. package/dist/tools/orchestration/plan-with-agent.tool.js.map +1 -1
  157. package/dist/tools/orchestration/plan.tool.js +17 -1
  158. package/dist/tools/orchestration/plan.tool.js.map +1 -1
  159. package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +40 -2
  160. package/dist/tools/orchestration/report-verification-verdict.tool.js +85 -6
  161. package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
  162. package/dist/tools/orchestration/research-with-agent.tool.js +33 -16
  163. package/dist/tools/orchestration/research-with-agent.tool.js.map +1 -1
  164. package/dist/tools/orchestration/tracing-utils.js +8 -0
  165. package/dist/tools/orchestration/tracing-utils.js.map +1 -1
  166. package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +8 -2
  167. package/dist/tools/orchestration/verify-built-workflow.tool.js +476 -6
  168. package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
  169. package/dist/tools/research.tool.js +56 -10
  170. package/dist/tools/research.tool.js.map +1 -1
  171. package/dist/tools/shared/ask-user.tool.d.ts +1 -0
  172. package/dist/tools/shared/ask-user.tool.js +3 -2
  173. package/dist/tools/shared/ask-user.tool.js.map +1 -1
  174. package/dist/tools/templates.tool.js +5 -90
  175. package/dist/tools/templates.tool.js.map +1 -1
  176. package/dist/tools/web-research/sanitize-web-content.d.ts +0 -1
  177. package/dist/tools/web-research/sanitize-web-content.js +0 -9
  178. package/dist/tools/web-research/sanitize-web-content.js.map +1 -1
  179. package/dist/tools/workflows/apply-workflow-credentials.tool.d.ts +2 -2
  180. package/dist/tools/workflows/build-workflow.tool.d.ts +2 -2
  181. package/dist/tools/workflows/build-workflow.tool.js +6 -4
  182. package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
  183. package/dist/tools/workflows/materialize-node-type.tool.d.ts +8 -8
  184. package/dist/tools/workflows/resolve-credentials.d.ts +9 -4
  185. package/dist/tools/workflows/resolve-credentials.js +59 -27
  186. package/dist/tools/workflows/resolve-credentials.js.map +1 -1
  187. package/dist/tools/workflows/setup-workflow.schema.d.ts +40 -0
  188. package/dist/tools/workflows/setup-workflow.service.d.ts +5 -1
  189. package/dist/tools/workflows/setup-workflow.service.js +71 -5
  190. package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
  191. package/dist/tools/workflows/submit-workflow-identity.d.ts +25 -3
  192. package/dist/tools/workflows/submit-workflow-identity.js +92 -5
  193. package/dist/tools/workflows/submit-workflow-identity.js.map +1 -1
  194. package/dist/tools/workflows/submit-workflow.tool.d.ts +60 -6
  195. package/dist/tools/workflows/submit-workflow.tool.js +102 -19
  196. package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
  197. package/dist/tools/workflows/workflow-json-utils.d.ts +4 -0
  198. package/dist/tools/workflows/workflow-json-utils.js +54 -0
  199. package/dist/tools/workflows/workflow-json-utils.js.map +1 -0
  200. package/dist/tools/workflows.tool.d.ts +7 -1
  201. package/dist/tools/workflows.tool.js +283 -54
  202. package/dist/tools/workflows.tool.js.map +1 -1
  203. package/dist/tracing/langsmith-tracing.d.ts +2 -0
  204. package/dist/tracing/langsmith-tracing.js +12 -3
  205. package/dist/tracing/langsmith-tracing.js.map +1 -1
  206. package/dist/tracing/trace-replay.d.ts +3 -0
  207. package/dist/tracing/trace-replay.js +65 -0
  208. package/dist/tracing/trace-replay.js.map +1 -1
  209. package/dist/types.d.ts +92 -16
  210. package/dist/workflow-builder/parse-validate.d.ts +5 -1
  211. package/dist/workflow-builder/parse-validate.js +5 -4
  212. package/dist/workflow-builder/parse-validate.js.map +1 -1
  213. package/dist/workflow-loop/guidance.js +8 -2
  214. package/dist/workflow-loop/guidance.js.map +1 -1
  215. package/dist/workflow-loop/index.d.ts +3 -2
  216. package/dist/workflow-loop/index.js +11 -1
  217. package/dist/workflow-loop/index.js.map +1 -1
  218. package/dist/workflow-loop/remediation.d.ts +13 -0
  219. package/dist/workflow-loop/remediation.js +36 -0
  220. package/dist/workflow-loop/remediation.js.map +1 -0
  221. package/dist/workflow-loop/runtime.js +7 -0
  222. package/dist/workflow-loop/runtime.js.map +1 -1
  223. package/dist/workflow-loop/workflow-loop-controller.d.ts +1 -1
  224. package/dist/workflow-loop/workflow-loop-controller.js +196 -29
  225. package/dist/workflow-loop/workflow-loop-controller.js.map +1 -1
  226. package/dist/workflow-loop/workflow-loop-state.d.ts +500 -10
  227. package/dist/workflow-loop/workflow-loop-state.js +74 -1
  228. package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
  229. package/dist/workflow-loop/workflow-task-service.d.ts +2 -1
  230. package/dist/workflow-loop/workflow-task-service.js +4 -0
  231. package/dist/workflow-loop/workflow-task-service.js.map +1 -1
  232. package/dist/workspace/builder-sandbox-factory.d.ts +3 -4
  233. package/dist/workspace/builder-sandbox-factory.js +74 -35
  234. package/dist/workspace/builder-sandbox-factory.js.map +1 -1
  235. package/dist/workspace/create-workspace.d.ts +2 -0
  236. package/dist/workspace/create-workspace.js.map +1 -1
  237. package/dist/workspace/n8n-sandbox-filesystem.js +2 -2
  238. package/dist/workspace/n8n-sandbox-filesystem.js.map +1 -1
  239. package/dist/workspace/n8n-sandbox-sandbox.d.ts +2 -3
  240. package/dist/workspace/n8n-sandbox-sandbox.js +3 -7
  241. package/dist/workspace/n8n-sandbox-sandbox.js.map +1 -1
  242. package/dist/workspace/sandbox-setup.d.ts +1 -1
  243. package/dist/workspace/sandbox-setup.js +41 -16
  244. package/dist/workspace/sandbox-setup.js.map +1 -1
  245. package/dist/workspace/snapshot-manager.d.ts +14 -2
  246. package/dist/workspace/snapshot-manager.js +57 -1
  247. package/dist/workspace/snapshot-manager.js.map +1 -1
  248. package/package.json +35 -10
  249. package/dist/tools/templates/template-api.d.ts +0 -21
  250. package/dist/tools/templates/template-api.js +0 -104
  251. package/dist/tools/templates/template-api.js.map +0 -1
  252. package/dist/tools/templates/types.d.ts +0 -52
  253. package/dist/tools/templates/types.js +0 -37
  254. package/dist/tools/templates/types.js.map +0 -1
  255. package/dist/tools/utils/mermaid.utils.d.ts +0 -15
  256. package/dist/tools/utils/mermaid.utils.js +0 -622
  257. package/dist/tools/utils/mermaid.utils.js.map +0 -1
  258. package/dist/tools/utils/node-configuration.utils.d.ts +0 -6
  259. package/dist/tools/utils/node-configuration.utils.js +0 -77
  260. package/dist/tools/utils/node-configuration.utils.js.map +0 -1
  261. package/dist/workspace/n8n-sandbox-client.d.ts +0 -105
  262. package/dist/workspace/n8n-sandbox-client.js +0 -335
  263. package/dist/workspace/n8n-sandbox-client.js.map +0 -1
  264. package/dist/workspace/n8n-sandbox-image-manager.d.ts +0 -5
  265. package/dist/workspace/n8n-sandbox-image-manager.js +0 -25
  266. package/dist/workspace/n8n-sandbox-image-manager.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"delegate.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/delegate.tool.ts"],"names":[],"mappings":";;AAkGA,8DAuIC;AAED,gDAwK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,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- You report to a parent agent, not a human. Be terse.\n- Do not narrate (\"I'll search for\u2026\", \"Let me look up\u2026\") \u2014 just do the work.\n- No emojis, filler phrases, or markdown headers in your text output.\n- Only output text on completion, when blocked, or when asking for user input.\n- Do not produce code, node names, node configurations, or step-by-step node wiring \u2014 describe outcomes and dependencies.\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 - **Do ask when a required service has more than one credential of the same type** (e.g. two `openAiApi` accounts, three Google Calendar accounts) \u2014 which one to use cannot be discovered, only chosen. Record the chosen credential name in `assumptions`.\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** \u2014 check what exists and learn best practices. Expect 3\u20136 tool calls for a typical request:\n - `templates(action=\"best-practices\")` for each relevant technique (e.g. \"form_input\", \"scheduling\", \"data_persistence\", \"web_app\"). Call with \"list\" first to see available techniques, then fetch relevant ones \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- **Dependencies are mandatory.** Every workflow must list the data table IDs it reads from or writes to in `dependsOn`. If workflow C needs data from A and B, it must depend on both.\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), `research` kind for web research. Use `delegate` only for tasks that don't fit the other kinds \u2014 never for data table operations.\n- **Data-table-only plans are valid.** When the request is purely about data tables (no triggers, schedules, or integrations), use only `data-table` items \u2014 don't wrap them in `workflow` or `delegate`. For creation, include `columns`; for other operations, omit `columns` and describe the operation in `purpose`. Include seed rows in `purpose` when the user wants sample data.\n- **Each item's `purpose` describes only that item.** Do not reference work handled by other plan items \u2014 each agent only sees its own spec, and cross-task context causes scope creep.\n- **Always call `submit-plan` after the last `add-plan-item`.** On rejection, be surgical \u2014 change only what the user asked for. Never fabricate node names; search first if unsure.";
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- You report to a parent agent, not a human. Be terse.\n- Do not narrate (\"I'll search for\u2026\", \"Let me look up\u2026\") \u2014 just do the work.\n- No emojis, filler phrases, or markdown headers in your text output.\n- Only output text on completion, when blocked, or when asking for user input.\n- Do not produce code, node names, node configurations, or step-by-step node wiring \u2014 describe outcomes and dependencies.\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 - **Trust already-collected briefing context** \u2014 if the briefing includes an Already-collected answers or Already-discovered resources section, treat those entries as authoritative. Do not ask again for purpose, trigger, integrations, schedule, model, resource, or credential choices already listed there.\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 - **Do ask when a required service has more than one credential of the same type** (e.g. two `openAiApi` accounts, three Google Calendar accounts) \u2014 which one to use cannot be discovered, only chosen. Record the chosen credential name in `assumptions`.\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** \u2014 check what exists and learn best practices. Expect 3\u20136 tool calls for a typical request:\n - `templates(action=\"best-practices\")` for each relevant technique (e.g. \"form_input\", \"scheduling\", \"data_persistence\", \"web_app\"). Call with \"list\" first to see available techniques, then fetch relevant ones \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 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 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- **User time zone is in context as `<current-datetime>` / `<user-timezone>`.** Schedule times, cron expressions, and digest times must be stated in the user's time zone. Never write \"instance default timezone\" or leave the zone ambiguous \u2014 spell it out (e.g. \"daily at 08:00 America/New_York\").\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 from A and B, it must depend on both.\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), `research` kind for web research. Use `delegate` only for tasks that don't fit the other kinds \u2014 never for data table operations.\n- **Data-table-only plans are valid.** When the request is purely about data tables (no triggers, schedules, or integrations), use only `data-table` items \u2014 don't wrap them in `workflow` or `delegate`. For creation, include `columns`; for other operations, omit `columns` and describe the operation in `purpose`. Include seed rows in `purpose` when the user wants sample data.\n- **Each item's `purpose` describes only that item.** Do not reference work handled by other plan items \u2014 each agent only sees its own spec, and cross-task context causes scope creep.\n- **Workflow verification is mandatory.** For **every** `workflow` item you add, also add a `checkpoint` item whose `dependsOn` includes that workflow's ID. Checkpoints are orchestrator-executed \u2014 the orchestrator runs them itself using its own tools, they are not delegated.\n - `title`: a user-readable verification goal, e.g. `\"Verify 'Daily API Email' workflow runs successfully\"`.\n - `instructions`: detailed steps the orchestrator must execute. Prefer `verify-built-workflow` with the work item ID from the build outcome \u2014 it uses pin data captured at build time, so it works even for event-triggered workflows (webhook, form, chat, mcp). For workflows with real credentials and a testable trigger (manual, schedule), `executions(action=\"run\")` is acceptable. State the pass condition in plain terms (e.g. \"run completes without errors and produces at least one output row\").\n - Do NOT list `tools` on a checkpoint \u2014 it is not a delegate task.\n - Do NOT emit a checkpoint for a `data-table`, `research`, or `delegate` item. Checkpoints are for workflows only.\n- **Always call `submit-plan` after the last `add-plan-item`.** On rejection, be surgical \u2014 change only what the user asked for. Never fabricate node names; search first if unsure.";
@@ -16,6 +16,7 @@ ${shared_prompts_1.SUBAGENT_OUTPUT_CONTRACT}
16
16
  - **Never ask about things you can discover** — call \`credentials(action="list")\`, \`data-tables(action="list")\`, \`templates(action="best-practices")\` instead.
17
17
  - **Never ask about implementation details** — trigger types, node choices, schedule times, column names. Pick sensible defaults.
18
18
  - **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.
19
+ - **Trust already-collected briefing context** — if the briefing includes an Already-collected answers or Already-discovered resources section, treat those entries as authoritative. Do not ask again for purpose, trigger, integrations, schedule, model, resource, or credential choices already listed there.
19
20
  - **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?").
20
21
  - **Do ask when a required service has more than one credential of the same type** (e.g. two \`openAiApi\` accounts, three Google Calendar accounts) — which one to use cannot be discovered, only chosen. Record the chosen credential name in \`assumptions\`.
21
22
  - **List your assumptions** on your first \`add-plan-item\` call. The user reviews the plan before execution and can reject/correct.
@@ -62,9 +63,15 @@ ${node_selection_1.NATIVE_NODE_PREFERENCE}
62
63
 
63
64
  ## Critical Rules
64
65
 
66
+ - **User time zone is in context as \`<current-datetime>\` / \`<user-timezone>\`.** Schedule times, cron expressions, and digest times must be stated in the user's time zone. Never write "instance default timezone" or leave the zone ambiguous — spell it out (e.g. "daily at 08:00 America/New_York").
65
67
  - **Dependencies are mandatory.** Every workflow must list the data table IDs it reads from or writes to in \`dependsOn\`. If workflow C needs data from A and B, it must depend on both.
66
68
  - **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), \`research\` kind for web research. Use \`delegate\` only for tasks that don't fit the other kinds — never for data table operations.
67
69
  - **Data-table-only plans are valid.** When the request is purely about data tables (no triggers, schedules, or integrations), use only \`data-table\` items — don't wrap them in \`workflow\` or \`delegate\`. For creation, include \`columns\`; for other operations, omit \`columns\` and describe the operation in \`purpose\`. Include seed rows in \`purpose\` when the user wants sample data.
68
70
  - **Each item's \`purpose\` describes only that item.** Do not reference work handled by other plan items — each agent only sees its own spec, and cross-task context causes scope creep.
71
+ - **Workflow verification is mandatory.** For **every** \`workflow\` item you add, also add a \`checkpoint\` item whose \`dependsOn\` includes that workflow's ID. Checkpoints are orchestrator-executed — the orchestrator runs them itself using its own tools, they are not delegated.
72
+ - \`title\`: a user-readable verification goal, e.g. \`"Verify 'Daily API Email' workflow runs successfully"\`.
73
+ - \`instructions\`: detailed steps the orchestrator must execute. Prefer \`verify-built-workflow\` with the work item ID from the build outcome — it uses pin data captured at build time, so it works even for event-triggered workflows (webhook, form, chat, mcp). For workflows with real credentials and a testable trigger (manual, schedule), \`executions(action="run")\` is acceptable. State the pass condition in plain terms (e.g. "run completes without errors and produces at least one output row").
74
+ - Do NOT list \`tools\` on a checkpoint — it is not a delegate task.
75
+ - Do NOT emit a checkpoint for a \`data-table\`, \`research\`, or \`delegate\` item. Checkpoints are for workflows only.
69
76
  - **Always call \`submit-plan\` after the last \`add-plan-item\`.** On rejection, be surgical — change only what the user asked for. Never fabricate node names; search first if unsure.`;
70
77
  //# sourceMappingURL=plan-agent-prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plan-agent-prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-agent-prompt.ts"],"names":[],"mappings":";;;AAAA,6EAKkD;AAElD,+DAAsE;AAEzD,QAAA,oBAAoB,GAAG;;;;EAIlC,yCAAwB;;;;;;;;;;;;;;;;;;;;;;;;;EAyBxB,kCAAiB;;;EAGjB,wCAAuB;;;EAGvB,kCAAiB;;;EAGjB,uCAAsB;;;;;;;;;;;;;;;;;;;;;;;;;yLAyBiK,CAAC"}
1
+ {"version":3,"file":"plan-agent-prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-agent-prompt.ts"],"names":[],"mappings":";;;AAAA,6EAKkD;AAElD,+DAAsE;AAEzD,QAAA,oBAAoB,GAAG;;;;EAIlC,yCAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BxB,kCAAiB;;;EAGjB,wCAAuB;;;EAGvB,kCAAiB;;;EAGjB,uCAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yLA+BiK,CAAC"}
@@ -1,2 +1,25 @@
1
1
  import type { OrchestrationContext } from '../../types';
2
+ interface FormattedMessage {
3
+ role: 'user' | 'assistant';
4
+ content: string;
5
+ }
6
+ interface PlannerBriefingContext {
7
+ collectedAnswers: string[];
8
+ discoveredResources: string[];
9
+ }
10
+ interface ToolObservation {
11
+ toolName: string;
12
+ args: Record<string, unknown>;
13
+ result: unknown;
14
+ }
15
+ declare function getRecentMessages(context: OrchestrationContext, count: number): Promise<FormattedMessage[]>;
16
+ declare function getPriorToolObservations(context: OrchestrationContext): ToolObservation[];
17
+ declare function buildPlannerBriefingContext(observations: ToolObservation[]): PlannerBriefingContext;
18
+ declare function formatMessagesForBriefing(messages: FormattedMessage[], guidance?: string, timeZone?: string, briefingContext?: PlannerBriefingContext): string;
19
+ export declare const __testFormatMessagesForBriefing: typeof formatMessagesForBriefing;
20
+ export declare const __testGetRecentMessages: typeof getRecentMessages;
21
+ export declare const __testGetPriorToolObservations: typeof getPriorToolObservations;
22
+ export declare const __testBuildPlannerBriefingContext: typeof buildPlannerBriefingContext;
23
+ export declare function __testClearPlannedTaskGraph(context: OrchestrationContext): Promise<void>;
2
24
  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>;
25
+ export {};
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__testBuildPlannerBriefingContext = exports.__testGetPriorToolObservations = exports.__testGetRecentMessages = exports.__testFormatMessagesForBriefing = void 0;
4
+ exports.__testClearPlannedTaskGraph = __testClearPlannedTaskGraph;
3
5
  exports.createPlanWithAgentTool = createPlanWithAgentTool;
4
6
  const agent_1 = require("@mastra/core/agent");
5
7
  const tools_1 = require("@mastra/core/tools");
8
+ const luxon_1 = require("luxon");
6
9
  const nanoid_1 = require("nanoid");
7
10
  const zod_1 = require("zod");
8
11
  const add_plan_item_tool_1 = require("./add-plan-item.tool");
@@ -16,16 +19,18 @@ const max_steps_1 = require("../../constants/max-steps");
16
19
  const resumable_stream_executor_1 = require("../../runtime/resumable-stream-executor");
17
20
  const consume_with_hitl_1 = require("../../stream/consume-with-hitl");
18
21
  const langsmith_tracing_1 = require("../../tracing/langsmith-tracing");
22
+ const credentials_tool_1 = require("../credentials.tool");
23
+ const data_tables_tool_1 = require("../data-tables.tool");
24
+ const ask_user_tool_1 = require("../shared/ask-user.tool");
25
+ const templates_tool_1 = require("../templates.tool");
19
26
  const MESSAGE_HISTORY_COUNT = 5;
20
- const PLANNER_DOMAIN_TOOL_NAMES = [
21
- 'nodes',
22
- 'templates',
23
- 'credentials',
24
- 'data-tables',
25
- 'workflows',
26
- 'ask-user',
27
- ];
27
+ const PLANNER_DOMAIN_TOOL_NAMES = ['nodes', 'credentials', 'data-tables', 'workflows', 'ask-user'];
28
28
  const PLANNER_RESEARCH_TOOL_NAMES = ['research'];
29
+ const RELEVANT_PRIOR_TOOL_NAMES = new Set([
30
+ ask_user_tool_1.ASK_USER_TOOL_ID,
31
+ credentials_tool_1.CREDENTIALS_TOOL_ID,
32
+ data_tables_tool_1.DATA_TABLES_TOOL_ID,
33
+ ]);
29
34
  function extractTextFromMemoryContent(content) {
30
35
  if (typeof content === 'string')
31
36
  return content;
@@ -49,6 +54,32 @@ function extractTextParts(parts) {
49
54
  .map((c) => c.text)
50
55
  .join('\n');
51
56
  }
57
+ function isRecord(value) {
58
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
59
+ }
60
+ function readString(value) {
61
+ return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
62
+ }
63
+ function readRecord(value) {
64
+ return isRecord(value) ? value : undefined;
65
+ }
66
+ function readArray(value) {
67
+ return Array.isArray(value) ? value : [];
68
+ }
69
+ function readStringArray(value) {
70
+ return readArray(value).filter((item) => typeof item === 'string');
71
+ }
72
+ function addUnique(target, seen, value) {
73
+ if (!value || seen.has(value))
74
+ return;
75
+ seen.add(value);
76
+ target.push(value);
77
+ }
78
+ function summarizeList(values, limit = 10) {
79
+ const visible = values.slice(0, limit).join(', ');
80
+ const remaining = values.length - limit;
81
+ return remaining > 0 ? `${visible}, and ${remaining} more` : visible;
82
+ }
52
83
  async function getRecentMessages(context, count) {
53
84
  const messages = [];
54
85
  if (context.memory) {
@@ -68,13 +99,238 @@ async function getRecentMessages(context, count) {
68
99
  catch {
69
100
  }
70
101
  }
71
- if (context.currentUserMessage) {
102
+ if (shouldAppendCurrentUserMessage(messages, context.currentUserMessage)) {
72
103
  messages.push({ role: 'user', content: context.currentUserMessage });
73
104
  }
74
105
  return messages;
75
106
  }
76
- function formatMessagesForBriefing(messages, guidance) {
107
+ function shouldAppendCurrentUserMessage(messages, currentUserMessage) {
108
+ const current = currentUserMessage?.trim();
109
+ if (!current)
110
+ return false;
111
+ const lastUserMessage = [...messages].reverse().find((message) => message.role === 'user');
112
+ return lastUserMessage?.content.trim() !== current;
113
+ }
114
+ function getPriorToolObservations(context) {
115
+ const toolCalls = new Map();
116
+ const pendingResults = new Map();
117
+ for (const event of getPriorToolEvents(context)) {
118
+ if (event.type === 'tool-call') {
119
+ const { toolCallId, toolName, args } = event.payload;
120
+ if (!RELEVANT_PRIOR_TOOL_NAMES.has(toolName))
121
+ continue;
122
+ const pendingResult = pendingResults.get(toolCallId);
123
+ toolCalls.set(toolCallId, {
124
+ toolName,
125
+ args,
126
+ result: pendingResult,
127
+ hasResult: pendingResults.has(toolCallId),
128
+ });
129
+ continue;
130
+ }
131
+ if (event.type === 'tool-result') {
132
+ const { toolCallId, result } = event.payload;
133
+ const existing = toolCalls.get(toolCallId);
134
+ if (existing) {
135
+ existing.result = result;
136
+ existing.hasResult = true;
137
+ }
138
+ else {
139
+ pendingResults.set(toolCallId, result);
140
+ }
141
+ }
142
+ }
143
+ return [...toolCalls.values()]
144
+ .filter((observation) => observation.hasResult)
145
+ .map(({ toolName, args, result }) => ({ toolName, args, result }));
146
+ }
147
+ function getPriorToolEvents(context) {
148
+ if (context.messageGroupId) {
149
+ const runIds = getMessageGroupRunIds(context);
150
+ if (runIds.length > 0) {
151
+ try {
152
+ return context.eventBus.getEventsForRuns(context.threadId, runIds);
153
+ }
154
+ catch {
155
+ }
156
+ }
157
+ }
158
+ try {
159
+ return context.eventBus.getEventsForRun(context.threadId, context.runId);
160
+ }
161
+ catch {
162
+ return [];
163
+ }
164
+ }
165
+ function getMessageGroupRunIds(context) {
166
+ const messageGroupId = context.messageGroupId;
167
+ if (!messageGroupId)
168
+ return [];
169
+ const runIds = new Set();
170
+ try {
171
+ for (const { event } of context.eventBus.getEventsAfter(context.threadId, 0)) {
172
+ if (event.type === 'run-start' && event.payload.messageGroupId === messageGroupId) {
173
+ runIds.add(event.runId);
174
+ }
175
+ }
176
+ }
177
+ catch {
178
+ return [context.runId];
179
+ }
180
+ runIds.add(context.runId);
181
+ return [...runIds];
182
+ }
183
+ function buildPlannerBriefingContext(observations) {
184
+ const collectedAnswers = [];
185
+ const discoveredResources = [];
186
+ const seenAnswers = new Set();
187
+ const seenResources = new Set();
188
+ const credentialsById = buildCredentialLookup(observations);
189
+ for (const observation of observations) {
190
+ if (observation.toolName === ask_user_tool_1.ASK_USER_TOOL_ID) {
191
+ for (const answer of extractAskUserAnswerLines(observation)) {
192
+ addUnique(collectedAnswers, seenAnswers, answer);
193
+ }
194
+ continue;
195
+ }
196
+ if (observation.toolName === credentials_tool_1.CREDENTIALS_TOOL_ID) {
197
+ const action = readString(observation.args.action);
198
+ if (action === 'list') {
199
+ addUnique(discoveredResources, seenResources, summarizeCredentials(observation.result));
200
+ }
201
+ if (action === 'setup') {
202
+ for (const selection of extractCredentialSelectionLines(observation, credentialsById)) {
203
+ addUnique(collectedAnswers, seenAnswers, selection);
204
+ }
205
+ }
206
+ continue;
207
+ }
208
+ if (observation.toolName === data_tables_tool_1.DATA_TABLES_TOOL_ID &&
209
+ readString(observation.args.action) === 'list') {
210
+ addUnique(discoveredResources, seenResources, summarizeDataTables(observation.result));
211
+ }
212
+ }
213
+ return { collectedAnswers, discoveredResources };
214
+ }
215
+ function buildCredentialLookup(observations) {
216
+ const credentialsById = new Map();
217
+ for (const observation of observations) {
218
+ if (observation.toolName !== credentials_tool_1.CREDENTIALS_TOOL_ID)
219
+ continue;
220
+ for (const credential of extractCredentials(observation.result)) {
221
+ if (credential.id)
222
+ credentialsById.set(credential.id, credential);
223
+ }
224
+ }
225
+ return credentialsById;
226
+ }
227
+ function extractAskUserAnswerLines(observation) {
228
+ const result = readRecord(observation.result);
229
+ if (!result || result.answered === false)
230
+ return [];
231
+ const questionsById = extractQuestionTextById(observation.args);
232
+ const answers = readArray(result.answers);
233
+ const lines = [];
234
+ for (const answerValue of answers) {
235
+ const answer = readRecord(answerValue);
236
+ if (!answer || answer.skipped === true)
237
+ continue;
238
+ const questionId = readString(answer.questionId);
239
+ const question = readString(answer.question) ?? (questionId ? questionsById.get(questionId) : undefined);
240
+ const selectedOptions = readStringArray(answer.selectedOptions);
241
+ const customText = readString(answer.customText);
242
+ const values = [...selectedOptions, ...(customText ? [customText] : [])];
243
+ if (!question || values.length === 0)
244
+ continue;
245
+ lines.push(`${question}: ${values.join(', ')}`);
246
+ }
247
+ return lines;
248
+ }
249
+ function extractQuestionTextById(args) {
250
+ const questionsById = new Map();
251
+ for (const questionValue of readArray(args.questions)) {
252
+ const question = readRecord(questionValue);
253
+ const id = readString(question?.id);
254
+ const text = readString(question?.question);
255
+ if (id && text)
256
+ questionsById.set(id, text);
257
+ }
258
+ return questionsById;
259
+ }
260
+ function extractCredentialSelectionLines(observation, credentialsById) {
261
+ const result = readRecord(observation.result);
262
+ const credentials = readRecord(result?.credentials);
263
+ if (!credentials)
264
+ return [];
265
+ const lines = [];
266
+ for (const [credentialType, credentialIdValue] of Object.entries(credentials)) {
267
+ const credentialId = readString(credentialIdValue);
268
+ if (!credentialId)
269
+ continue;
270
+ const credential = credentialsById.get(credentialId);
271
+ const label = credential
272
+ ? `${credential.name} (${credential.type})`
273
+ : `credential ID ${credentialId}`;
274
+ lines.push(`Credential selected for ${credentialType}: ${label}`);
275
+ }
276
+ return lines;
277
+ }
278
+ function summarizeCredentials(result) {
279
+ const credentials = extractCredentials(result);
280
+ if (credentials.length === 0)
281
+ return undefined;
282
+ return `Credentials available: ${summarizeList(credentials.map((credential) => `${credential.name} (${credential.type})`))}`;
283
+ }
284
+ function extractCredentials(result) {
285
+ const record = readRecord(result);
286
+ return readArray(record?.credentials)
287
+ .map(readCredentialBrief)
288
+ .filter((credential) => credential !== undefined);
289
+ }
290
+ function readCredentialBrief(value) {
291
+ const record = readRecord(value);
292
+ const name = readString(record?.name);
293
+ const type = readString(record?.type);
294
+ if (!name || !type)
295
+ return undefined;
296
+ const id = readString(record?.id);
297
+ return {
298
+ name,
299
+ type,
300
+ ...(id ? { id } : {}),
301
+ };
302
+ }
303
+ function summarizeDataTables(result) {
304
+ const tables = extractDataTables(result);
305
+ if (tables.length === 0)
306
+ return undefined;
307
+ return `Data tables available: ${summarizeList(tables.map((table) => table.name))}`;
308
+ }
309
+ function extractDataTables(result) {
310
+ const record = readRecord(result);
311
+ return readArray(record?.tables)
312
+ .map(readDataTableBrief)
313
+ .filter((table) => table !== undefined);
314
+ }
315
+ function readDataTableBrief(value) {
316
+ const record = readRecord(value);
317
+ const name = readString(record?.name);
318
+ if (!name)
319
+ return undefined;
320
+ const id = readString(record?.id);
321
+ return {
322
+ name,
323
+ ...(id ? { id } : {}),
324
+ };
325
+ }
326
+ function formatMessagesForBriefing(messages, guidance, timeZone, briefingContext) {
77
327
  const parts = [];
328
+ const now = timeZone ? luxon_1.DateTime.now().setZone(timeZone) : luxon_1.DateTime.now();
329
+ const isoNow = now.toISO({ includeOffset: true }) ?? new Date().toISOString();
330
+ parts.push(`<current-datetime>${isoNow}</current-datetime>`);
331
+ if (timeZone) {
332
+ parts.push(`<user-timezone>${timeZone}</user-timezone>`);
333
+ }
78
334
  if (messages.length > 0) {
79
335
  parts.push('## Recent conversation');
80
336
  for (const m of messages) {
@@ -83,12 +339,28 @@ function formatMessagesForBriefing(messages, guidance) {
83
339
  parts.push(`**${label}:** ${content}`);
84
340
  }
85
341
  }
342
+ if (briefingContext?.collectedAnswers.length) {
343
+ parts.push('## Already-collected answers');
344
+ for (const answer of briefingContext.collectedAnswers) {
345
+ parts.push(`- ${answer}`);
346
+ }
347
+ }
348
+ if (briefingContext?.discoveredResources.length) {
349
+ parts.push('## Already-discovered resources');
350
+ for (const resource of briefingContext.discoveredResources) {
351
+ parts.push(`- ${resource}`);
352
+ }
353
+ }
86
354
  if (guidance) {
87
355
  parts.push(`\n## Orchestrator guidance\n${guidance}`);
88
356
  }
89
357
  parts.push('\nDesign the solution blueprint based on the conversation above.');
90
358
  return parts.join('\n\n');
91
359
  }
360
+ exports.__testFormatMessagesForBriefing = formatMessagesForBriefing;
361
+ exports.__testGetRecentMessages = getRecentMessages;
362
+ exports.__testGetPriorToolObservations = getPriorToolObservations;
363
+ exports.__testBuildPlannerBriefingContext = buildPlannerBriefingContext;
92
364
  function publishClearingEvent(context) {
93
365
  context.eventBus.publish(context.threadId, {
94
366
  type: 'tasks-update',
@@ -104,6 +376,25 @@ async function clearDraftChecklist(context) {
104
376
  catch {
105
377
  }
106
378
  }
379
+ async function __testClearPlannedTaskGraph(context) {
380
+ return await clearPlannedTaskGraph(context);
381
+ }
382
+ async function clearPlannedTaskGraph(context) {
383
+ if (!context.plannedTaskService)
384
+ return;
385
+ try {
386
+ const graph = await context.plannedTaskService.getGraph(context.threadId);
387
+ if (!graph)
388
+ return;
389
+ if (graph.planRunId !== context.runId)
390
+ return;
391
+ if (graph.status !== 'awaiting_approval')
392
+ return;
393
+ await context.plannedTaskService.clear(context.threadId);
394
+ }
395
+ catch {
396
+ }
397
+ }
107
398
  function createPlanWithAgentTool(context) {
108
399
  return (0, tools_1.createTool)({
109
400
  id: 'plan',
@@ -136,12 +427,14 @@ function createPlanWithAgentTool(context) {
136
427
  plannerTools[name] = context.domainTools[name];
137
428
  }
138
429
  }
430
+ plannerTools.templates = (0, templates_tool_1.createTemplatesTool)();
139
431
  const accumulator = new blueprint_accumulator_1.BlueprintAccumulator();
140
432
  plannerTools['add-plan-item'] = (0, add_plan_item_tool_1.createAddPlanItemTool)(accumulator, context);
141
433
  plannerTools['remove-plan-item'] = (0, add_plan_item_tool_1.createRemovePlanItemTool)(accumulator, context);
142
434
  plannerTools['submit-plan'] = (0, submit_plan_tool_1.createSubmitPlanTool)(accumulator, context);
143
435
  const messages = await getRecentMessages(context, MESSAGE_HISTORY_COUNT);
144
- const briefing = formatMessagesForBriefing(messages, input.guidance);
436
+ const briefingContext = buildPlannerBriefingContext(getPriorToolObservations(context));
437
+ const briefing = formatMessagesForBriefing(messages, input.guidance, context.timeZone, briefingContext);
145
438
  const subAgentId = `agent-planner-${(0, nanoid_1.nanoid)(6)}`;
146
439
  const subtitle = input.guidance ?? messages.find((m) => m.role === 'user')?.content ?? 'Planning...';
147
440
  context.eventBus.publish(context.threadId, {
@@ -205,6 +498,7 @@ function createPlanWithAgentTool(context) {
205
498
  threadId: context.threadId,
206
499
  abortSignal: context.abortSignal,
207
500
  waitForConfirmation: context.waitForConfirmation,
501
+ onActivity: context.touchRun,
208
502
  llmStepTraceHooks,
209
503
  maxSteps: max_steps_1.MAX_STEPS.PLANNER,
210
504
  });
@@ -230,6 +524,9 @@ function createPlanWithAgentTool(context) {
230
524
  },
231
525
  });
232
526
  if (accumulator.isApproved()) {
527
+ if (context.plannedTaskService) {
528
+ await context.plannedTaskService.approvePlan(context.threadId);
529
+ }
233
530
  if (context.schedulePlannedTasks) {
234
531
  await context.schedulePlannedTasks();
235
532
  }
@@ -240,6 +537,7 @@ function createPlanWithAgentTool(context) {
240
537
  }
241
538
  publishClearingEvent(context);
242
539
  await clearDraftChecklist(context);
540
+ await clearPlannedTaskGraph(context);
243
541
  if (!accumulator.isEmpty()) {
244
542
  return {
245
543
  result: `Planner added ${accumulator.getTaskList().length} items but did not submit the plan for approval. The plan was not executed.`,
@@ -265,8 +563,11 @@ function createPlanWithAgentTool(context) {
265
563
  error: errorMessage,
266
564
  },
267
565
  });
268
- publishClearingEvent(context);
269
- await clearDraftChecklist(context);
566
+ if (!accumulator.isApproved()) {
567
+ publishClearingEvent(context);
568
+ await clearDraftChecklist(context);
569
+ await clearPlannedTaskGraph(context);
570
+ }
270
571
  return { result: `Planner error: ${errorMessage}` };
271
572
  }
272
573
  },