@n8n/instance-ai 1.7.0 → 1.8.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 (363) hide show
  1. package/dist/agent/instance-agent.d.ts +1 -1
  2. package/dist/agent/instance-agent.js +88 -75
  3. package/dist/agent/instance-agent.js.map +1 -1
  4. package/dist/agent/mcp-tool-name-validation.d.ts +4 -2
  5. package/dist/agent/mcp-tool-name-validation.js +2 -2
  6. package/dist/agent/mcp-tool-name-validation.js.map +1 -1
  7. package/dist/agent/runtime-workspace.d.ts +6 -0
  8. package/dist/agent/runtime-workspace.js +14 -0
  9. package/dist/agent/runtime-workspace.js.map +1 -0
  10. package/dist/agent/sanitize-mcp-schemas.d.ts +4 -3
  11. package/dist/agent/sanitize-mcp-schemas.js +53 -24
  12. package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
  13. package/dist/agent/sub-agent-debriefing.d.ts +2 -2
  14. package/dist/agent/sub-agent-factory.d.ts +7 -4
  15. package/dist/agent/sub-agent-factory.js +24 -13
  16. package/dist/agent/sub-agent-factory.js.map +1 -1
  17. package/dist/agent/system-prompt.js +18 -15
  18. package/dist/agent/system-prompt.js.map +1 -1
  19. package/dist/build.tsbuildinfo +1 -1
  20. package/dist/constants/max-steps.d.ts +1 -1
  21. package/dist/constants/max-steps.js +1 -1
  22. package/dist/constants/max-steps.js.map +1 -1
  23. package/dist/domain-access/domain-gating.d.ts +2 -2
  24. package/dist/error-formatting.d.ts +1 -0
  25. package/dist/error-formatting.js +159 -0
  26. package/dist/error-formatting.js.map +1 -0
  27. package/dist/index.d.ts +65 -24
  28. package/dist/index.js +96 -52
  29. package/dist/index.js.map +1 -1
  30. package/dist/mcp/mcp-client-manager.d.ts +5 -4
  31. package/dist/mcp/mcp-client-manager.js +42 -17
  32. package/dist/mcp/mcp-client-manager.js.map +1 -1
  33. package/dist/memory/title-utils.d.ts +4 -1
  34. package/dist/memory/title-utils.js +10 -2
  35. package/dist/memory/title-utils.js.map +1 -1
  36. package/dist/parsers/structured-file-parser.d.ts +5 -2
  37. package/dist/parsers/structured-file-parser.js +9 -2
  38. package/dist/parsers/structured-file-parser.js.map +1 -1
  39. package/dist/planned-tasks/planned-task-permissions.js +3 -5
  40. package/dist/planned-tasks/planned-task-permissions.js.map +1 -1
  41. package/dist/planned-tasks/planned-task-service.d.ts +1 -0
  42. package/dist/planned-tasks/planned-task-service.js +8 -0
  43. package/dist/planned-tasks/planned-task-service.js.map +1 -1
  44. package/dist/runtime/background-task-manager.d.ts +9 -2
  45. package/dist/runtime/background-task-manager.js +7 -2
  46. package/dist/runtime/background-task-manager.js.map +1 -1
  47. package/dist/runtime/liveness-policy.js +4 -3
  48. package/dist/runtime/liveness-policy.js.map +1 -1
  49. package/dist/runtime/resumable-stream-executor.d.ts +4 -24
  50. package/dist/runtime/resumable-stream-executor.js +103 -1318
  51. package/dist/runtime/resumable-stream-executor.js.map +1 -1
  52. package/dist/runtime/run-state-registry.d.ts +8 -2
  53. package/dist/runtime/run-state-registry.js +19 -1
  54. package/dist/runtime/run-state-registry.js.map +1 -1
  55. package/dist/runtime/stream-runner.d.ts +4 -4
  56. package/dist/runtime/stream-runner.js +11 -25
  57. package/dist/runtime/stream-runner.js.map +1 -1
  58. package/dist/skills/materialize-runtime-skills.d.ts +62 -0
  59. package/dist/skills/materialize-runtime-skills.js +465 -0
  60. package/dist/skills/materialize-runtime-skills.js.map +1 -0
  61. package/dist/skills/runtime-skills.d.ts +4 -0
  62. package/dist/skills/runtime-skills.js +17 -0
  63. package/dist/skills/runtime-skills.js.map +1 -0
  64. package/dist/source-map-filter.d.ts +17 -0
  65. package/dist/source-map-filter.js +39 -0
  66. package/dist/source-map-filter.js.map +1 -0
  67. package/dist/storage/agent-tree-snapshot.d.ts +2 -0
  68. package/dist/storage/index.d.ts +3 -3
  69. package/dist/storage/index.js +8 -7
  70. package/dist/storage/index.js.map +1 -1
  71. package/dist/storage/planned-task-storage.d.ts +3 -3
  72. package/dist/storage/planned-task-storage.js +3 -8
  73. package/dist/storage/planned-task-storage.js.map +1 -1
  74. package/dist/storage/terminal-outcome-storage.d.ts +4 -4
  75. package/dist/storage/terminal-outcome-storage.js +1 -1
  76. package/dist/storage/terminal-outcome-storage.js.map +1 -1
  77. package/dist/storage/{mastra-iteration-log-storage.d.ts → thread-iteration-log-storage.d.ts} +3 -3
  78. package/dist/storage/{mastra-iteration-log-storage.js → thread-iteration-log-storage.js} +5 -5
  79. package/dist/storage/thread-iteration-log-storage.js.map +1 -0
  80. package/dist/storage/thread-patch.d.ts +16 -10
  81. package/dist/storage/thread-patch.js +37 -36
  82. package/dist/storage/thread-patch.js.map +1 -1
  83. package/dist/storage/{mastra-task-storage.d.ts → thread-task-storage.d.ts} +3 -3
  84. package/dist/storage/{mastra-task-storage.js → thread-task-storage.js} +5 -5
  85. package/dist/storage/thread-task-storage.js.map +1 -0
  86. package/dist/storage/workflow-loop-storage.d.ts +28 -28
  87. package/dist/storage/workflow-loop-storage.js +1 -1
  88. package/dist/storage/workflow-loop-storage.js.map +1 -1
  89. package/dist/stream/consume-with-hitl.d.ts +11 -11
  90. package/dist/stream/consume-with-hitl.js +27 -15
  91. package/dist/stream/consume-with-hitl.js.map +1 -1
  92. package/dist/stream/map-chunk.d.ts +1 -1
  93. package/dist/stream/map-chunk.js +153 -36
  94. package/dist/stream/map-chunk.js.map +1 -1
  95. package/dist/tool-registry.d.ts +8 -0
  96. package/dist/tool-registry.js +45 -0
  97. package/dist/tool-registry.js.map +1 -0
  98. package/dist/tools/attachments/parse-file.tool.d.ts +42 -45
  99. package/dist/tools/attachments/parse-file.tool.js +140 -97
  100. package/dist/tools/attachments/parse-file.tool.js.map +1 -1
  101. package/dist/tools/credentials.tool.d.ts +5 -5
  102. package/dist/tools/credentials.tool.js +31 -34
  103. package/dist/tools/credentials.tool.js.map +1 -1
  104. package/dist/tools/data-tables.tool.d.ts +3 -2
  105. package/dist/tools/data-tables.tool.js +99 -100
  106. package/dist/tools/data-tables.tool.js.map +1 -1
  107. package/dist/tools/evals/apply-pin-data.service.d.ts +3 -0
  108. package/dist/tools/evals/apply-pin-data.service.js +19 -0
  109. package/dist/tools/evals/apply-pin-data.service.js.map +1 -0
  110. package/dist/tools/evals/column-ref-utils.d.ts +3 -0
  111. package/dist/tools/evals/column-ref-utils.js +205 -48
  112. package/dist/tools/evals/column-ref-utils.js.map +1 -1
  113. package/dist/tools/evals/detect-agent-named-refs.service.js +20 -4
  114. package/dist/tools/evals/detect-agent-named-refs.service.js.map +1 -1
  115. package/dist/tools/evals/ensure-eval-data-table.service.d.ts +15 -0
  116. package/dist/tools/evals/ensure-eval-data-table.service.js +83 -0
  117. package/dist/tools/evals/ensure-eval-data-table.service.js.map +1 -0
  118. package/dist/tools/evals/eval-data-requirements.service.d.ts +1 -0
  119. package/dist/tools/evals/eval-data-requirements.service.js +23 -4
  120. package/dist/tools/evals/eval-data-requirements.service.js.map +1 -1
  121. package/dist/tools/evals/evals.tool.d.ts +2 -0
  122. package/dist/tools/evals/evals.tool.js +452 -0
  123. package/dist/tools/evals/evals.tool.js.map +1 -0
  124. package/dist/tools/evals/extract-rows-from-history.service.d.ts +17 -0
  125. package/dist/tools/evals/extract-rows-from-history.service.js +103 -0
  126. package/dist/tools/evals/extract-rows-from-history.service.js.map +1 -0
  127. package/dist/tools/evals/format-eval-setup-task.d.ts +16 -0
  128. package/dist/tools/evals/format-eval-setup-task.js +167 -0
  129. package/dist/tools/evals/format-eval-setup-task.js.map +1 -0
  130. package/dist/tools/evals/generate-sample-rows.service.d.ts +35 -0
  131. package/dist/tools/evals/generate-sample-rows.service.js +278 -0
  132. package/dist/tools/evals/generate-sample-rows.service.js.map +1 -0
  133. package/dist/tools/evals/generate-tool-ref-pin-data.service.d.ts +11 -0
  134. package/dist/tools/evals/generate-tool-ref-pin-data.service.js +125 -0
  135. package/dist/tools/evals/generate-tool-ref-pin-data.service.js.map +1 -0
  136. package/dist/tools/evals/metric-catalog.d.ts +10 -4
  137. package/dist/tools/evals/metric-catalog.js.map +1 -1
  138. package/dist/tools/executions.tool.d.ts +1 -1
  139. package/dist/tools/executions.tool.js +25 -34
  140. package/dist/tools/executions.tool.js.map +1 -1
  141. package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +2 -3
  142. package/dist/tools/filesystem/create-tools-from-mcp-server.js +129 -67
  143. package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
  144. package/dist/tools/index.d.ts +4 -16
  145. package/dist/tools/index.js +102 -92
  146. package/dist/tools/index.js.map +1 -1
  147. package/dist/tools/nodes.tool.d.ts +1 -1
  148. package/dist/tools/nodes.tool.js +31 -33
  149. package/dist/tools/nodes.tool.js.map +1 -1
  150. package/dist/tools/orchestration/add-plan-item.tool.d.ts +2 -2
  151. package/dist/tools/orchestration/add-plan-item.tool.js +45 -49
  152. package/dist/tools/orchestration/add-plan-item.tool.js.map +1 -1
  153. package/dist/tools/orchestration/agent-persistence.d.ts +14 -0
  154. package/dist/tools/orchestration/agent-persistence.js +43 -0
  155. package/dist/tools/orchestration/agent-persistence.js.map +1 -0
  156. package/dist/tools/orchestration/blueprint-accumulator.d.ts +4 -8
  157. package/dist/tools/orchestration/blueprint-accumulator.js +11 -78
  158. package/dist/tools/orchestration/blueprint-accumulator.js.map +1 -1
  159. package/dist/tools/orchestration/blueprint.schema.d.ts +13 -147
  160. package/dist/tools/orchestration/blueprint.schema.js +4 -23
  161. package/dist/tools/orchestration/blueprint.schema.js.map +1 -1
  162. package/dist/tools/orchestration/browser-credential-setup.nudge.d.ts +2 -4
  163. package/dist/tools/orchestration/browser-credential-setup.nudge.js +1 -1
  164. package/dist/tools/orchestration/browser-credential-setup.nudge.js.map +1 -1
  165. package/dist/tools/orchestration/browser-credential-setup.tool.d.ts +10 -2
  166. package/dist/tools/orchestration/browser-credential-setup.tool.js +299 -270
  167. package/dist/tools/orchestration/browser-credential-setup.tool.js.map +1 -1
  168. package/dist/tools/orchestration/build-workflow-agent.prompt.d.ts +7 -1
  169. package/dist/tools/orchestration/build-workflow-agent.prompt.js +46 -20
  170. package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -1
  171. package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +50 -5
  172. package/dist/tools/orchestration/build-workflow-agent.tool.js +748 -605
  173. package/dist/tools/orchestration/build-workflow-agent.tool.js.map +1 -1
  174. package/dist/tools/orchestration/builder-memory-compaction.d.ts +6 -2
  175. package/dist/tools/orchestration/builder-memory-compaction.js +32 -46
  176. package/dist/tools/orchestration/builder-memory-compaction.js.map +1 -1
  177. package/dist/tools/orchestration/complete-checkpoint.tool.d.ts +1 -1
  178. package/dist/tools/orchestration/complete-checkpoint.tool.js +46 -47
  179. package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -1
  180. package/dist/tools/orchestration/delegate.tool.d.ts +1 -1
  181. package/dist/tools/orchestration/delegate.tool.js +170 -166
  182. package/dist/tools/orchestration/delegate.tool.js.map +1 -1
  183. package/dist/tools/orchestration/eval-data-agent.tool.d.ts +2 -0
  184. package/dist/tools/orchestration/eval-data-agent.tool.js +183 -0
  185. package/dist/tools/orchestration/eval-data-agent.tool.js.map +1 -0
  186. package/dist/tools/orchestration/eval-setup-agent.prompt.d.ts +1 -0
  187. package/dist/tools/orchestration/eval-setup-agent.prompt.js +238 -0
  188. package/dist/tools/orchestration/eval-setup-agent.prompt.js.map +1 -0
  189. package/dist/tools/orchestration/eval-setup-agent.tool.d.ts +31 -0
  190. package/dist/tools/orchestration/eval-setup-agent.tool.js +204 -0
  191. package/dist/tools/orchestration/eval-setup-agent.tool.js.map +1 -0
  192. package/dist/tools/orchestration/plan-agent-prompt.d.ts +1 -1
  193. package/dist/tools/orchestration/plan-agent-prompt.js +9 -9
  194. package/dist/tools/orchestration/plan-with-agent.tool.d.ts +1 -1
  195. package/dist/tools/orchestration/plan-with-agent.tool.js +210 -179
  196. package/dist/tools/orchestration/plan-with-agent.tool.js.map +1 -1
  197. package/dist/tools/orchestration/plan.tool.d.ts +5 -2
  198. package/dist/tools/orchestration/plan.tool.js +125 -105
  199. package/dist/tools/orchestration/plan.tool.js.map +1 -1
  200. package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +3 -3
  201. package/dist/tools/orchestration/report-verification-verdict.tool.js +65 -66
  202. package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
  203. package/dist/tools/orchestration/submit-plan.tool.d.ts +1 -1
  204. package/dist/tools/orchestration/submit-plan.tool.js +83 -66
  205. package/dist/tools/orchestration/submit-plan.tool.js.map +1 -1
  206. package/dist/tools/orchestration/tracing-utils.d.ts +3 -2
  207. package/dist/tools/orchestration/tracing-utils.js +58 -39
  208. package/dist/tools/orchestration/tracing-utils.js.map +1 -1
  209. package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +5 -5
  210. package/dist/tools/orchestration/verify-built-workflow.tool.js +166 -166
  211. package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
  212. package/dist/tools/research.tool.d.ts +1 -1
  213. package/dist/tools/research.tool.js +59 -27
  214. package/dist/tools/research.tool.js.map +1 -1
  215. package/dist/tools/shared/ask-user.tool.d.ts +3 -2
  216. package/dist/tools/shared/ask-user.tool.js +61 -63
  217. package/dist/tools/shared/ask-user.tool.js.map +1 -1
  218. package/dist/tools/task-control.tool.d.ts +1 -1
  219. package/dist/tools/task-control.tool.js +15 -16
  220. package/dist/tools/task-control.tool.js.map +1 -1
  221. package/dist/tools/templates.tool.d.ts +1 -1
  222. package/dist/tools/templates.tool.js +6 -7
  223. package/dist/tools/templates.tool.js.map +1 -1
  224. package/dist/tools/tool-ids.d.ts +40 -0
  225. package/dist/tools/tool-ids.js +62 -0
  226. package/dist/tools/tool-ids.js.map +1 -0
  227. package/dist/tools/workflows/apply-workflow-credentials.tool.d.ts +3 -3
  228. package/dist/tools/workflows/apply-workflow-credentials.tool.js +72 -73
  229. package/dist/tools/workflows/apply-workflow-credentials.tool.js.map +1 -1
  230. package/dist/tools/workflows/build-workflow.tool.d.ts +3 -3
  231. package/dist/tools/workflows/build-workflow.tool.js +113 -114
  232. package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
  233. package/dist/tools/workflows/materialize-node-type.tool.d.ts +6 -6
  234. package/dist/tools/workflows/materialize-node-type.tool.js +64 -65
  235. package/dist/tools/workflows/materialize-node-type.tool.js.map +1 -1
  236. package/dist/tools/workflows/resolve-credentials.d.ts +3 -5
  237. package/dist/tools/workflows/resolve-credentials.js +15 -6
  238. package/dist/tools/workflows/resolve-credentials.js.map +1 -1
  239. package/dist/tools/workflows/setup-workflow.schema.d.ts +2 -2
  240. package/dist/tools/workflows/submit-workflow-identity.d.ts +8 -9
  241. package/dist/tools/workflows/submit-workflow-identity.js +41 -27
  242. package/dist/tools/workflows/submit-workflow-identity.js.map +1 -1
  243. package/dist/tools/workflows/submit-workflow.tool.d.ts +10 -7
  244. package/dist/tools/workflows/submit-workflow.tool.js +224 -191
  245. package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
  246. package/dist/tools/workflows/validate-workflow.service.d.ts +15 -0
  247. package/dist/tools/workflows/validate-workflow.service.js +289 -0
  248. package/dist/tools/workflows/validate-workflow.service.js.map +1 -0
  249. package/dist/tools/workflows/write-sandbox-file.tool.d.ts +2 -2
  250. package/dist/tools/workflows/write-sandbox-file.tool.js +29 -30
  251. package/dist/tools/workflows/write-sandbox-file.tool.js.map +1 -1
  252. package/dist/tools/workflows.tool.d.ts +5 -2
  253. package/dist/tools/workflows.tool.js +184 -85
  254. package/dist/tools/workflows.tool.js.map +1 -1
  255. package/dist/tools/workspace.tool.d.ts +1 -1
  256. package/dist/tools/workspace.tool.js +49 -65
  257. package/dist/tools/workspace.tool.js.map +1 -1
  258. package/dist/tracing/langsmith-tracing.d.ts +17 -18
  259. package/dist/tracing/langsmith-tracing.js +941 -677
  260. package/dist/tracing/langsmith-tracing.js.map +1 -1
  261. package/dist/tracing/trace-labels.d.ts +5 -0
  262. package/dist/tracing/trace-labels.js +36 -0
  263. package/dist/tracing/trace-labels.js.map +1 -0
  264. package/dist/tracing/trace-payloads.d.ts +23 -0
  265. package/dist/tracing/trace-payloads.js +1008 -0
  266. package/dist/tracing/trace-payloads.js.map +1 -0
  267. package/dist/types.d.ts +57 -25
  268. package/dist/types.js +3 -0
  269. package/dist/types.js.map +1 -1
  270. package/dist/utils/eval-agents.js +1 -1
  271. package/dist/utils/eval-agents.js.map +1 -1
  272. package/dist/utils/scrub-secrets.js +1 -1
  273. package/dist/utils/scrub-secrets.js.map +1 -1
  274. package/dist/utils/stream-helpers.d.ts +2 -5
  275. package/dist/utils/stream-helpers.js +12 -1
  276. package/dist/utils/stream-helpers.js.map +1 -1
  277. package/dist/workflow-loop/workflow-loop-state.d.ts +18 -18
  278. package/dist/workspace/builder-templates-service.d.ts +54 -0
  279. package/dist/workspace/builder-templates-service.js +442 -0
  280. package/dist/workspace/builder-templates-service.js.map +1 -0
  281. package/dist/workspace/create-workspace.d.ts +16 -3
  282. package/dist/workspace/create-workspace.js +45 -21
  283. package/dist/workspace/create-workspace.js.map +1 -1
  284. package/dist/workspace/daytona-auth-manager.d.ts +26 -0
  285. package/dist/workspace/daytona-auth-manager.js +90 -0
  286. package/dist/workspace/daytona-auth-manager.js.map +1 -0
  287. package/dist/workspace/daytona-filesystem.d.ts +5 -4
  288. package/dist/workspace/daytona-filesystem.js +25 -15
  289. package/dist/workspace/daytona-filesystem.js.map +1 -1
  290. package/dist/workspace/daytona-sandbox.d.ts +65 -0
  291. package/dist/workspace/daytona-sandbox.js +314 -0
  292. package/dist/workspace/daytona-sandbox.js.map +1 -0
  293. package/dist/workspace/lazy-daytona.d.ts +2 -0
  294. package/dist/workspace/lazy-daytona.js +12 -0
  295. package/dist/workspace/lazy-daytona.js.map +1 -0
  296. package/dist/workspace/lazy-runtime-workspace.d.ts +8 -0
  297. package/dist/workspace/lazy-runtime-workspace.js +246 -0
  298. package/dist/workspace/lazy-runtime-workspace.js.map +1 -0
  299. package/dist/workspace/local-filesystem.d.ts +48 -0
  300. package/dist/workspace/local-filesystem.js +250 -0
  301. package/dist/workspace/local-filesystem.js.map +1 -0
  302. package/dist/workspace/local-sandbox.d.ts +28 -0
  303. package/dist/workspace/local-sandbox.js +121 -0
  304. package/dist/workspace/local-sandbox.js.map +1 -0
  305. package/dist/workspace/n8n-sandbox-filesystem.d.ts +3 -3
  306. package/dist/workspace/n8n-sandbox-filesystem.js +3 -3
  307. package/dist/workspace/n8n-sandbox-filesystem.js.map +1 -1
  308. package/dist/workspace/n8n-sandbox-sandbox.d.ts +12 -3
  309. package/dist/workspace/n8n-sandbox-sandbox.js +54 -10
  310. package/dist/workspace/n8n-sandbox-sandbox.js.map +1 -1
  311. package/dist/workspace/sandbox-fs.d.ts +35 -4
  312. package/dist/workspace/sandbox-fs.js +1 -1
  313. package/dist/workspace/sandbox-fs.js.map +1 -1
  314. package/dist/workspace/sandbox-setup.d.ts +13 -4
  315. package/dist/workspace/sandbox-setup.js +250 -36
  316. package/dist/workspace/sandbox-setup.js.map +1 -1
  317. package/dist/workspace/scoped-workspace.d.ts +2 -0
  318. package/dist/workspace/scoped-workspace.js +141 -0
  319. package/dist/workspace/scoped-workspace.js.map +1 -0
  320. package/dist/workspace/snapshot-manager.d.ts +11 -5
  321. package/dist/workspace/snapshot-manager.js +74 -17
  322. package/dist/workspace/snapshot-manager.js.map +1 -1
  323. package/dist/workspace/template-telemetry.d.ts +4 -4
  324. package/dist/workspace/template-telemetry.js +18 -6
  325. package/dist/workspace/template-telemetry.js.map +1 -1
  326. package/package.json +13 -16
  327. package/skills/data-table-manager/SKILL.md +119 -0
  328. package/skills/data-table-manager/references/data-table-playbook.md +212 -0
  329. package/dist/agent/register-with-mastra.d.ts +0 -3
  330. package/dist/agent/register-with-mastra.js +0 -15
  331. package/dist/agent/register-with-mastra.js.map +0 -1
  332. package/dist/compaction/compaction-helper.d.ts +0 -9
  333. package/dist/compaction/compaction-helper.js +0 -58
  334. package/dist/compaction/compaction-helper.js.map +0 -1
  335. package/dist/compaction/index.d.ts +0 -2
  336. package/dist/compaction/index.js +0 -6
  337. package/dist/compaction/index.js.map +0 -1
  338. package/dist/memory/memory-config.d.ts +0 -3
  339. package/dist/memory/memory-config.js +0 -27
  340. package/dist/memory/memory-config.js.map +0 -1
  341. package/dist/runtime/builder-sandbox-session-registry.d.ts +0 -47
  342. package/dist/runtime/builder-sandbox-session-registry.js +0 -166
  343. package/dist/runtime/builder-sandbox-session-registry.js.map +0 -1
  344. package/dist/storage/mastra-iteration-log-storage.js.map +0 -1
  345. package/dist/storage/mastra-task-storage.js.map +0 -1
  346. package/dist/tools/orchestration/data-table-agent.prompt.d.ts +0 -1
  347. package/dist/tools/orchestration/data-table-agent.prompt.js +0 -47
  348. package/dist/tools/orchestration/data-table-agent.prompt.js.map +0 -1
  349. package/dist/tools/orchestration/data-table-agent.tool.d.ts +0 -26
  350. package/dist/tools/orchestration/data-table-agent.tool.js +0 -174
  351. package/dist/tools/orchestration/data-table-agent.tool.js.map +0 -1
  352. package/dist/tools/orchestration/research-agent-prompt.d.ts +0 -1
  353. package/dist/tools/orchestration/research-agent-prompt.js +0 -26
  354. package/dist/tools/orchestration/research-agent-prompt.js.map +0 -1
  355. package/dist/tools/orchestration/research-with-agent.tool.d.ts +0 -30
  356. package/dist/tools/orchestration/research-with-agent.tool.js +0 -179
  357. package/dist/tools/orchestration/research-with-agent.tool.js.map +0 -1
  358. package/dist/workspace/builder-sandbox-factory.d.ts +0 -30
  359. package/dist/workspace/builder-sandbox-factory.js +0 -289
  360. package/dist/workspace/builder-sandbox-factory.js.map +0 -1
  361. package/dist/workspace/guarded-filesystem.d.ts +0 -10
  362. package/dist/workspace/guarded-filesystem.js +0 -136
  363. package/dist/workspace/guarded-filesystem.js.map +0 -1
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatEvalSetupTask = formatEvalSetupTask;
4
+ const column_ref_utils_1 = require("./column-ref-utils");
5
+ const ensure_eval_data_table_service_1 = require("./ensure-eval-data-table.service");
6
+ function taskString(value) {
7
+ return JSON.stringify(value) ?? '""';
8
+ }
9
+ function evalTriggerJsonRef(column) {
10
+ return `={{ $('Eval Trigger').item.json${(0, column_ref_utils_1.jsonFieldAccessor)(column)} }}`;
11
+ }
12
+ function formatProductionAdapter(namedRefs, agentNodeName, columnNameFor) {
13
+ if (namedRefs.length === 0)
14
+ return '';
15
+ const assignmentsByColumn = new Map();
16
+ for (const r of namedRefs) {
17
+ const column = columnNameFor(r.column);
18
+ if (!assignmentsByColumn.has(column)) {
19
+ assignmentsByColumn.set(column, {
20
+ column,
21
+ nodeName: r.nodeName,
22
+ field: r.field,
23
+ });
24
+ }
25
+ }
26
+ const assignments = [...assignmentsByColumn.values()]
27
+ .map((a) => ` - { name: ${taskString(a.column)}, value: ${taskString(`={{ ${(0, column_ref_utils_1.nodeItemJsonExpression)(a.nodeName, a.field)} }}`)}, type: "string" }`)
28
+ .join('\n');
29
+ const byTarget = new Map();
30
+ for (const r of namedRefs) {
31
+ const arr = byTarget.get(r.targetNodeName) ?? [];
32
+ arr.push(r);
33
+ byTarget.set(r.targetNodeName, arr);
34
+ }
35
+ const rewriteBlocks = [];
36
+ for (const [target, refs] of byTarget) {
37
+ const isAgent = target === agentNodeName;
38
+ const lines = refs
39
+ .map((r) => {
40
+ const column = columnNameFor(r.column);
41
+ const replacement = isAgent
42
+ ? `{{ ${(0, column_ref_utils_1.currentJsonExpression)(column)} }}`
43
+ : `{{ ${(0, column_ref_utils_1.nodeItemJsonExpression)(agentNodeName, column)} }}`;
44
+ return ` - Replace \`${r.originalExpression}\` with \`${replacement}\``;
45
+ })
46
+ .join('\n');
47
+ rewriteBlocks.push(` In \`${target}\`:\n${lines}`);
48
+ }
49
+ const rewrites = rewriteBlocks.join('\n');
50
+ const sourceList = [...new Set(namedRefs.map((r) => r.nodeName))]
51
+ .map((n) => `\`${n}\``)
52
+ .join(', ');
53
+ const sourceLabel = assignmentsByColumn.size === 1 ? 'node' : 'nodes';
54
+ return `
55
+ PRODUCTION ADAPTER (REQUIRED — the agent and/or its connected sub-components currently read input from named ${sourceLabel} ${sourceList}, which won't resolve in eval runs):
56
+
57
+ 1. Insert a new \`n8n-nodes-base.set\` node named \`"Eval Production Adapter"\` (\`typeVersion: 3.4\`) immediately upstream of the agent on the PRODUCTION path. The agent's existing \`main\` input parent on the production path becomes the Set adapter's \`main\` input parent. The Set adapter's \`main\` output goes to the agent.
58
+ 2. Configure the Set adapter's \`assignments.assignments\` array (one entry per unique dataset column):
59
+ ${assignments}
60
+ 3. Rewrite parameter expressions in each affected node — the agent and any sub-components (memory, tools, output parsers) that reference named source nodes. **The replacement form depends on the target:** the agent itself uses \`{{ $json.<col> }}\` (it receives \`$json\` directly), but sub-components must use the exact selected-agent expression listed below because their runtime context does not propagate \`$json\` from the agent's input row.
61
+ ${rewrites}
62
+ 4. The eval branch wires \`EvaluationTrigger\` directly to the agent's \`main\` input as a SECOND incoming connection (no Set adapter between them — the trigger row already has \`$json.<column>\` shape).
63
+
64
+ After your edits the agent has TWO incoming \`main\` connections: one from the Eval Production Adapter (production runs) and one from the EvaluationTrigger (eval runs). Both produce \`$json.<column>\` for the agent. Sub-components reference the selected agent node by name, so they resolve to the agent's last input row in both modes.`;
65
+ }
66
+ function formatMetric(m, input, columnNameFor) {
67
+ const cannedSuffix = m.cannedMetricKey ? `, canned=${m.cannedMetricKey}` : '';
68
+ const promptSuffix = m.prompt ? `\n Prompt: ${m.prompt}` : '';
69
+ const expectedOutputColumn = input.suggestedOutputColumns[0]
70
+ ? columnNameFor(input.suggestedOutputColumns[0])
71
+ : 'expected_output';
72
+ const inputColumn = input.suggestedInputColumns[0]
73
+ ? columnNameFor(input.suggestedInputColumns[0])
74
+ : 'input';
75
+ switch (m.cannedMetricKey) {
76
+ case 'correctness':
77
+ return `- ${m.name} (${m.kind}${cannedSuffix}): ${m.description}
78
+ Configure Evaluation(setMetrics) with \`metric: 'correctness'\`, \`expectedAnswer: ${evalTriggerJsonRef(expectedOutputColumn)}\`, \`actualAnswer: ={{ $json.output }}\`, and \`options.metricName: '${m.name}'\`. Connect an \`ai_languageModel\` input.${promptSuffix}`;
79
+ case 'helpfulness':
80
+ return `- ${m.name} (${m.kind}${cannedSuffix}): ${m.description}
81
+ Configure Evaluation(setMetrics) with \`metric: 'helpfulness'\`, \`userQuery: ${evalTriggerJsonRef(inputColumn)}\`, \`actualAnswer: ={{ $json.output }}\`, and \`options.metricName: '${m.name}'\`. Connect an \`ai_languageModel\` input.${promptSuffix}`;
82
+ case 'tool_use':
83
+ return `- ${m.name} (${m.kind}${cannedSuffix}): ${m.description}
84
+ Configure Evaluation(setMetrics) with \`metric: 'toolsUsed'\` (not \`'tool_use'\`), \`expectedTools\` from the dataset or the user's selected expected tool list, \`intermediateSteps: ={{ $json.intermediateSteps }}\`, and \`options.metricName: '${m.name}'\`. Enable returning intermediate steps on the agent.`;
85
+ case 'relevance':
86
+ return `- ${m.name} (${m.kind}${cannedSuffix}): ${m.description}
87
+ There is no native \`relevance\` metric option. Configure Evaluation(setMetrics) with \`metric: 'helpfulness'\`, \`userQuery: ${evalTriggerJsonRef(inputColumn)}\`, \`actualAnswer\` mapped to the retrieved context or response field being judged, \`options.metricName: '${m.name}'\`, and the relevance prompt below. Connect an \`ai_languageModel\` input.${promptSuffix}`;
88
+ default:
89
+ return `- ${m.name} (${m.kind}): ${m.description}${promptSuffix}`;
90
+ }
91
+ }
92
+ function formatDatasetSection(input, dataTableColumns) {
93
+ if (input.datasetChoice === 'link-existing') {
94
+ return `Wire the EvaluationTrigger to DataTable id \`${input.existingDataTableId}\`. This table already exists — do not modify its rows or schema.`;
95
+ }
96
+ if (input.datasetChoice === 'later') {
97
+ return "Do not create a DataTable. Leave the EvaluationTrigger's dataTableId empty — the user will wire it manually later.";
98
+ }
99
+ const tableName = (0, ensure_eval_data_table_service_1.formatEvalDataTableName)(input.workflowName);
100
+ const columns = dataTableColumns.map((c) => `- ${c}`).join('\n');
101
+ return `Create an empty DataTable named "${tableName}"${input.projectId ? ` in project id \`${input.projectId}\`` : ''} using only the \`create-empty-eval-data-table\` tool. Columns to create as strings:\n${columns}\n\nDo not insert rows, generate rows, or mutate row data. After creating the empty table, wire the EvaluationTrigger and setOutputs dataTableId to the created table id.`;
102
+ }
103
+ function formatSetOutputsDataTableInstruction(input) {
104
+ if (input.datasetChoice === 'link-existing') {
105
+ const id = input.existingDataTableId ?? '<existing DataTable id>';
106
+ return `The setOutputs node MUST have \`source: 'dataTable'\` and \`dataTableId: { mode: 'id', value: '${id}' }\` set explicitly (the node default for older typeVersions is googleSheets — that's a silent failure mode).`;
107
+ }
108
+ if (input.datasetChoice === 'later') {
109
+ return 'Leave setOutputs dataTableId empty until the user selects a DataTable. Do not write placeholder values into EvaluationTrigger or setOutputs.';
110
+ }
111
+ return "The setOutputs node MUST have `source: 'dataTable'` and `dataTableId` set explicitly using the id returned by `create-empty-eval-data-table` (the same id wired on the EvaluationTrigger). The node default for older typeVersions is googleSheets — that's a silent failure mode.";
112
+ }
113
+ function formatEvalSetupTask(input) {
114
+ const rawInputColumns = [
115
+ ...input.suggestedInputColumns,
116
+ ...(input.namedRefs ?? []).map((r) => r.column),
117
+ ];
118
+ const rawOutputColumns = input.suggestedOutputColumns;
119
+ const columnNameByRaw = (0, ensure_eval_data_table_service_1.formatEvalDataTableColumnNameMap)([
120
+ ...rawInputColumns,
121
+ ...rawOutputColumns,
122
+ ]);
123
+ const columnNameFor = (column) => columnNameByRaw.get(column) ?? (0, ensure_eval_data_table_service_1.formatEvalDataTableColumnName)(column);
124
+ const inputColumnNames = [...new Set(rawInputColumns.map(columnNameFor))];
125
+ const outputColumnNames = [...new Set(rawOutputColumns.map(columnNameFor))];
126
+ const dataTableColumns = [...new Set([...inputColumnNames, ...outputColumnNames])];
127
+ const outputColumns = outputColumnNames.map((c) => `- ${c}`).join('\n');
128
+ const inputColumns = inputColumnNames.map((c) => `- ${c}`).join('\n');
129
+ const metrics = input.enabledMetrics
130
+ .map((m) => formatMetric(m, input, columnNameFor))
131
+ .join('\n\n');
132
+ const datasetSection = formatDatasetSection(input, dataTableColumns);
133
+ const setOutputsDataTableInstruction = formatSetOutputsDataTableInstruction(input);
134
+ const agentNodeName = input.targetAgentNodeName ?? input.detectedAiNodes[0] ?? '';
135
+ const adapterSection = formatProductionAdapter(input.namedRefs ?? [], agentNodeName, columnNameFor);
136
+ return `Set up evaluations for workflow "${input.workflowName}" (id: ${input.workflowId}).
137
+
138
+ AI AGENT NODES IN WORKFLOW: ${input.detectedAiNodes.join(', ')}
139
+
140
+ DATASET:
141
+ ${datasetSection}
142
+
143
+ INPUT COLUMNS (the AI agent's parameters MUST reference each of these via \`={{ $json.<column> }}\`. If the agent's existing parameters reference different fields, rewrite those parameter expressions to use these dataset columns. Only rewrite input-reading parameters — leave credentials, tools, model selection, and unrelated configuration untouched):
144
+ ${inputColumns}
145
+ ${adapterSection}
146
+
147
+ GROUND-TRUTH OUTPUT COLUMNS (already in the dataset — these hold the EXPECTED values per row):
148
+ ${outputColumns}
149
+
150
+ For setOutputs, write the agent's actual output to NEW columns derived from these ground-truth column names — convention: prefix with \`actual_\` (e.g. ground-truth \`expected_output\` → setOutputs writes to \`actual_output\`; ground-truth \`expected_response\` → setOutputs writes to \`actual_response\`). Never overwrite the ground-truth column itself. The Evaluation node auto-adds the new column on first eval run.
151
+
152
+ ${setOutputsDataTableInstruction} Use \`typeVersion: 4.8\` for the Evaluation node.
153
+
154
+ METRICS TO CONFIGURE (on setMetrics):
155
+ ${metrics}
156
+
157
+ Use the field mappings specified per metric above. Use the explicit name you assign to the EvaluationTrigger node (name it \`"Eval Trigger"\` when creating it, then reference exactly that name everywhere — never use the stock default \`"When fetching a dataset row"\` and never create a separate node for that purpose).
158
+
159
+ For \`correctness\`, \`helpfulness\`, and \`relevance\` (configured with the native \`helpfulness\` metric): also wire an \`ai_languageModel\` connection from the workflow's existing LLM model node (the one already feeding the AI agent) to each setMetrics node that uses an AI-judged metric. The LLM is reused — same node, additional outgoing \`ai_languageModel\` connection. Without this, AI-judged metrics fail silently. \`stringSimilarity\`/\`categorization\`/\`toolsUsed\` don't need this.
160
+
161
+ Apply the topology as described in your instructions:
162
+ 1. EvaluationTrigger → target AI agent node (direct \`main\` connection). No intermediate Set/Code/transform node. The trigger emits each dataset column as \`$json.<column>\`. If the agent's existing parameters reference fields that don't match the listed INPUT COLUMNS, rewrite those parameter expressions to use \`{{ $json.<column> }}\`. NOTE: \`Evaluation(setInputs)\` does NOT reshape data — it only attaches metadata for the eval-results display tab.
163
+ 2. After the AI agent: insert \`Evaluation(checkIfEvaluating)\` (no separate IF node — it has two native output slots). Slot 0 (Evaluation) routes to setOutputs → setMetrics. Slot 1 (Normal) preserves the original production path with side-effects.
164
+
165
+ Report back with a one-line summary when done.`;
166
+ }
167
+ //# sourceMappingURL=format-eval-setup-task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-eval-setup-task.js","sourceRoot":"","sources":["../../../src/tools/evals/format-eval-setup-task.ts"],"names":[],"mappings":";;AA4KA,kDA2DC;AAvOD,yDAI4B;AAE5B,qFAI0C;AAiB1C,SAAS,UAAU,CAAC,KAAa;IAChC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;AACtC,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAc;IACzC,OAAO,kCAAkC,IAAA,oCAAiB,EAAC,MAAM,CAAC,KAAK,CAAC;AACzE,CAAC;AAED,SAAS,uBAAuB,CAC/B,SAAqB,EACrB,aAAqB,EACrB,aAAyC;IAEzC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAGtC,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAGhC,CAAC;IACJ,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,mBAAmB,CAAC,GAA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AAI,EAAE,CAAC;IAClF,MAAM,cAAc,GAAG,uBAAuB,CAC7C,KAAK,CAAC,SAAS,IAAI,EAAE,EACrB,aAAa,EACb,aAAa,CACb,CAAC;IAEF,OAAO,oCAAoC,KAAK,CAAC,YAAY,UAAU,KAAK,CAAC,UAAU;;8BAE1D,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAG5D,cAAc;;;EAGd,YAAY;EACZ,cAAc;;;EAGd,aAAa;;;;EAIb,8BAA8B;;;EAG9B,OAAO;;;;;;;;;;+CAUsC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { WorkflowJSON } from '@n8n/workflow-sdk';
2
+ import type { Logger } from '../../logger';
3
+ export interface SampleRowFacet {
4
+ length: string;
5
+ edgeMode: string;
6
+ instructions: string;
7
+ }
8
+ export interface AgentContext {
9
+ workflowName: string;
10
+ agentNodeName: string;
11
+ systemPrompt: string | undefined;
12
+ promptTemplate: string | undefined;
13
+ connectedToolNames: string[];
14
+ }
15
+ export declare const SAMPLE_ROW_FACETS: readonly SampleRowFacet[];
16
+ export declare function distributeRowCount(rowCount: number): number[];
17
+ export declare function extractAgentContext(workflow: WorkflowJSON, agentNodeName: string): AgentContext | undefined;
18
+ export interface RunBatchInput {
19
+ facet: SampleRowFacet;
20
+ rowCount: number;
21
+ context: AgentContext | undefined;
22
+ columns: string[];
23
+ realExamples?: ReadonlyArray<Record<string, unknown>>;
24
+ logger?: Pick<Logger, 'warn'>;
25
+ }
26
+ export declare function runBatch(input: RunBatchInput): Promise<Array<Record<string, string>>>;
27
+ export interface GenerateSampleRowsInput {
28
+ workflow: WorkflowJSON;
29
+ columns: string[];
30
+ rowCount?: number;
31
+ targetAgentNodeName?: string;
32
+ realExamples?: ReadonlyArray<Record<string, unknown>>;
33
+ logger?: Pick<Logger, 'warn'>;
34
+ }
35
+ export declare function generateSampleRows(input: GenerateSampleRowsInput): Promise<Array<Record<string, string>>>;
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SAMPLE_ROW_FACETS = void 0;
4
+ exports.distributeRowCount = distributeRowCount;
5
+ exports.extractAgentContext = extractAgentContext;
6
+ exports.runBatch = runBatch;
7
+ exports.generateSampleRows = generateSampleRows;
8
+ const zod_1 = require("zod");
9
+ const column_ref_utils_1 = require("./column-ref-utils");
10
+ const detect_ai_nodes_1 = require("./detect-ai-nodes");
11
+ const eval_agents_1 = require("../../utils/eval-agents");
12
+ const FACET_COUNT = 5;
13
+ const DEFAULT_ROW_COUNT = 25;
14
+ const SYSTEM_PROMPT_MAX_CHARS = 2000;
15
+ const REAL_EXAMPLES_MAX_COUNT = 10;
16
+ const REAL_EXAMPLE_VALUE_MAX_CHARS = 300;
17
+ exports.SAMPLE_ROW_FACETS = [
18
+ {
19
+ length: 'short (single sentence or one-line snippet)',
20
+ edgeMode: 'happy — typical, well-formed inputs the agent commonly receives',
21
+ instructions: 'Produce concise, realistic inputs the AI Agent would handle on a regular day. Each input should fit on one line. No edge cases.',
22
+ },
23
+ {
24
+ length: 'long (multi-paragraph or several lines)',
25
+ edgeMode: 'happy — typical, well-formed inputs',
26
+ instructions: 'Produce longer realistic inputs spanning multiple paragraphs or several lines. The content stays in-domain and well-structured.',
27
+ },
28
+ {
29
+ length: 'medium (2–3 sentences or comparable size)',
30
+ edgeMode: 'edge — ambiguity, truncations, typos, imperfect formatting',
31
+ instructions: 'Produce inputs that are messy but plausible: typos, ambiguous references, truncated phrasing, irregular casing or spacing. Still in-domain.',
32
+ },
33
+ {
34
+ length: 'long (multi-paragraph)',
35
+ edgeMode: 'adversarial — out-of-scope requests, contradictions, prompt injection',
36
+ instructions: 'Produce inputs that try to push the agent off task: out-of-scope demands, internally contradictory requirements, attempts at prompt injection ("ignore previous instructions"), or hostile framing.',
37
+ },
38
+ {
39
+ length: 'mixed extremes (empty, very short, or very long)',
40
+ edgeMode: 'robustness — empty inputs, multi-language fragments, malformed data',
41
+ instructions: 'Produce robustness probes: an empty input, an input of one or two characters, an input that mixes two languages, and an input with malformed structure (e.g., truncated JSON, broken markup). Use whatever the agent would plausibly stumble on in production.',
42
+ },
43
+ ];
44
+ function distributeRowCount(rowCount) {
45
+ const safe = Math.max(0, Math.floor(rowCount));
46
+ const base = Math.floor(safe / FACET_COUNT);
47
+ const extra = safe % FACET_COUNT;
48
+ return Array.from({ length: FACET_COUNT }, (_, i) => base + (i < extra ? 1 : 0));
49
+ }
50
+ function readSystemPrompt(parameters) {
51
+ if (!parameters)
52
+ return undefined;
53
+ const direct = parameters.systemMessage;
54
+ if (typeof direct === 'string' && direct.length > 0) {
55
+ return direct.slice(0, SYSTEM_PROMPT_MAX_CHARS);
56
+ }
57
+ const options = parameters.options;
58
+ if ((0, column_ref_utils_1.isRecord)(options)) {
59
+ const nested = options.systemMessage;
60
+ if (typeof nested === 'string' && nested.length > 0) {
61
+ return nested.slice(0, SYSTEM_PROMPT_MAX_CHARS);
62
+ }
63
+ }
64
+ return undefined;
65
+ }
66
+ function readPromptTemplate(parameters) {
67
+ if (!parameters)
68
+ return undefined;
69
+ const text = parameters.text;
70
+ return typeof text === 'string' && text.length > 0 ? text : undefined;
71
+ }
72
+ function findConnectedTools(workflow, agentName) {
73
+ const tools = [];
74
+ const connections = workflow.connections ?? {};
75
+ for (const [sourceName, byType] of Object.entries(connections)) {
76
+ if (!(0, column_ref_utils_1.isRecord)(byType))
77
+ continue;
78
+ const aiTool = byType?.ai_tool;
79
+ if (!Array.isArray(aiTool))
80
+ continue;
81
+ const matches = aiTool.some((slot) => {
82
+ if (!Array.isArray(slot))
83
+ return false;
84
+ return slot.some((link) => (0, column_ref_utils_1.isRecord)(link) && link.node === agentName);
85
+ });
86
+ if (matches)
87
+ tools.push(sourceName);
88
+ }
89
+ return tools;
90
+ }
91
+ function extractAgentContext(workflow, agentNodeName) {
92
+ const node = (workflow.nodes ?? []).find((n) => n.name === agentNodeName);
93
+ if (!node)
94
+ return undefined;
95
+ const parameters = (0, column_ref_utils_1.isRecord)(node.parameters) ? node.parameters : undefined;
96
+ return {
97
+ workflowName: workflow.name ?? 'Untitled',
98
+ agentNodeName,
99
+ systemPrompt: readSystemPrompt(parameters),
100
+ promptTemplate: readPromptTemplate(parameters),
101
+ connectedToolNames: findConnectedTools(workflow, agentNodeName),
102
+ };
103
+ }
104
+ const batchRowSchema = zod_1.z.array(zod_1.z.record(zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()])));
105
+ function isExpectedOutputColumn(column) {
106
+ return column.startsWith('expected');
107
+ }
108
+ function buildAgentContextBlock(context) {
109
+ if (!context)
110
+ return 'Workflow context unavailable.';
111
+ const lines = [
112
+ `Workflow name: ${context.workflowName}`,
113
+ `AI Agent node: ${context.agentNodeName}`,
114
+ ];
115
+ if (context.systemPrompt) {
116
+ lines.push('Agent system prompt:', context.systemPrompt);
117
+ }
118
+ if (context.promptTemplate) {
119
+ lines.push(`Agent prompt template: ${context.promptTemplate}`);
120
+ }
121
+ if (context.connectedToolNames.length > 0) {
122
+ lines.push(`Connected tools: ${context.connectedToolNames.join(', ')}`);
123
+ }
124
+ return lines.join('\n');
125
+ }
126
+ const FORMAT_INFERENCE = "Inspect the agent's system prompt, prompt template, and connected tools to infer what kind of text this agent receives at runtime. It may be a user chat message, output from another tool, scraped web content, structured records (JSON/key-value), document chunks, log lines, code, etc. Generate inputs that look like what would arrive at the agent in production. Do not assume a human user when the agent suggests otherwise.";
127
+ function truncateExampleValue(value) {
128
+ return value.length > REAL_EXAMPLE_VALUE_MAX_CHARS
129
+ ? `${value.slice(0, REAL_EXAMPLE_VALUE_MAX_CHARS)}…`
130
+ : value;
131
+ }
132
+ function buildRealExamplesBlock(examples, columns) {
133
+ if (!examples || examples.length === 0 || columns.length === 0)
134
+ return '';
135
+ const filtered = [];
136
+ for (const example of examples.slice(0, REAL_EXAMPLES_MAX_COUNT)) {
137
+ const row = {};
138
+ let hasValue = false;
139
+ for (const col of columns) {
140
+ const raw = example[col];
141
+ if (raw === undefined || raw === null)
142
+ continue;
143
+ const str = typeof raw === 'string' ? raw : JSON.stringify(raw);
144
+ if (str.length === 0)
145
+ continue;
146
+ row[col] = truncateExampleValue(str);
147
+ hasValue = true;
148
+ }
149
+ if (hasValue)
150
+ filtered.push(row);
151
+ }
152
+ if (filtered.length === 0)
153
+ return '';
154
+ const numbered = filtered.map((row, i) => `${i + 1}. ${JSON.stringify(row)}`).join('\n');
155
+ return [
156
+ '',
157
+ 'Recent real inputs the agent has received in production (REFERENCE, not seeds):',
158
+ numbered,
159
+ 'Use these as a hint about the actual domain, tone and shape of inputs the agent sees. Do NOT copy or paraphrase them — produce NEW inputs that fit the same setting.',
160
+ ].join('\n');
161
+ }
162
+ const BATCH_SYSTEM_INSTRUCTIONS = `You generate realistic test inputs for an n8n workflow evaluation dataset.
163
+
164
+ Output: JSON array of objects. Keys = exactly the provided column names. Values = short strings. No prose outside the JSON.
165
+
166
+ Generate only INPUT data — the inputs the agent would receive in production. Do not invent expected outputs, answers, or labels. Those columns are filled in by the user, who decides what the correct answer is. Generating both inputs and expected outputs with the same model would measure self-consistency, not correctness.
167
+
168
+ Return only the JSON array.`;
169
+ function normalizeBatchRow(rawRow, columns) {
170
+ const row = {};
171
+ for (const col of columns) {
172
+ if (isExpectedOutputColumn(col)) {
173
+ row[col] = '';
174
+ continue;
175
+ }
176
+ const v = rawRow[col];
177
+ if (v === undefined || v === null)
178
+ row[col] = '';
179
+ else if (typeof v === 'string')
180
+ row[col] = v;
181
+ else
182
+ row[col] = String(v);
183
+ }
184
+ return row;
185
+ }
186
+ function stripMarkdownFences(text) {
187
+ const trimmed = text.trim();
188
+ const fencedMatch = /^```(?:json)?\s*([\s\S]*?)\s*```$/i.exec(trimmed);
189
+ return fencedMatch ? fencedMatch[1].trim() : trimmed;
190
+ }
191
+ async function runBatch(input) {
192
+ const requestedRowCount = Math.max(0, Math.floor(input.rowCount));
193
+ if (requestedRowCount <= 0)
194
+ return [];
195
+ try {
196
+ const generatedColumns = input.columns.filter((column) => !isExpectedOutputColumn(column));
197
+ const agent = (0, eval_agents_1.createEvalAgent)('eval-sample-rows', {
198
+ model: eval_agents_1.HAIKU_MODEL,
199
+ instructions: BATCH_SYSTEM_INSTRUCTIONS,
200
+ });
201
+ const realExamplesBlock = buildRealExamplesBlock(input.realExamples, generatedColumns);
202
+ const sections = [buildAgentContextBlock(input.context)];
203
+ if (realExamplesBlock)
204
+ sections.push(realExamplesBlock);
205
+ sections.push(FORMAT_INFERENCE);
206
+ sections.push([
207
+ `Variation focus for this batch: length = ${input.facet.length}; mode = ${input.facet.edgeMode}.`,
208
+ input.facet.instructions,
209
+ ].join('\n'));
210
+ sections.push([
211
+ `Columns: ${generatedColumns.join(', ')}`,
212
+ `Generate exactly ${requestedRowCount} rows.`,
213
+ ].join('\n'));
214
+ const userText = sections.join('\n\n');
215
+ const result = await agent.generate(userText);
216
+ const text = (0, eval_agents_1.extractText)(result);
217
+ const parsed = JSON.parse(stripMarkdownFences(text));
218
+ const validated = batchRowSchema.safeParse(parsed);
219
+ if (!validated.success) {
220
+ input.logger?.warn('generate-sample-rows: invalid batch rows returned', {
221
+ rowCount: requestedRowCount,
222
+ facet: input.facet.edgeMode,
223
+ issues: validated.error.issues,
224
+ });
225
+ return [];
226
+ }
227
+ return validated.data
228
+ .slice(0, requestedRowCount)
229
+ .map((rawRow) => normalizeBatchRow(rawRow, input.columns));
230
+ }
231
+ catch (error) {
232
+ input.logger?.warn('generate-sample-rows: batch generation failed', {
233
+ rowCount: requestedRowCount,
234
+ facet: input.facet.edgeMode,
235
+ error,
236
+ });
237
+ return [];
238
+ }
239
+ }
240
+ function resolveAgentContext(workflow, targetAgentNodeName) {
241
+ if (targetAgentNodeName) {
242
+ return extractAgentContext(workflow, targetAgentNodeName);
243
+ }
244
+ const detected = (0, detect_ai_nodes_1.detectAiNodes)(workflow);
245
+ const firstAgent = detected.aiNodeNames[0];
246
+ if (!firstAgent)
247
+ return undefined;
248
+ return extractAgentContext(workflow, firstAgent);
249
+ }
250
+ function emptyRow(columns) {
251
+ return Object.fromEntries(columns.map((c) => [c, '']));
252
+ }
253
+ async function generateSampleRows(input) {
254
+ const rowCount = input.rowCount ?? DEFAULT_ROW_COUNT;
255
+ const counts = distributeRowCount(rowCount);
256
+ const context = resolveAgentContext(input.workflow, input.targetAgentNodeName);
257
+ const settled = await Promise.allSettled(exports.SAMPLE_ROW_FACETS.map(async (facet, i) => {
258
+ if (counts[i] <= 0)
259
+ return [];
260
+ return await runBatch({
261
+ facet,
262
+ rowCount: counts[i],
263
+ context,
264
+ columns: input.columns,
265
+ realExamples: input.realExamples,
266
+ logger: input.logger,
267
+ });
268
+ }));
269
+ const merged = [];
270
+ for (const r of settled) {
271
+ if (r.status === 'fulfilled')
272
+ merged.push(...r.value);
273
+ }
274
+ if (merged.length === 0)
275
+ return [emptyRow(input.columns)];
276
+ return merged;
277
+ }
278
+ //# sourceMappingURL=generate-sample-rows.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-sample-rows.service.js","sourceRoot":"","sources":["../../../src/tools/evals/generate-sample-rows.service.ts"],"names":[],"mappings":";;;AA6DA,gDAKC;AAwCD,kDAcC;AAoHD,4BAiDC;AAoCD,gDA2BC;AA3VD,6BAAwB;AAExB,yDAA8C;AAC9C,uDAAkD;AAElD,yDAAoF;AAEpF,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAgB5B,QAAA,iBAAiB,GAA8B;IAC3D;QACC,MAAM,EAAE,6CAA6C;QACrD,QAAQ,EAAE,iEAAiE;QAC3E,YAAY,EACX,iIAAiI;KAClI;IACD;QACC,MAAM,EAAE,yCAAyC;QACjD,QAAQ,EAAE,qCAAqC;QAC/C,YAAY,EACX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B,CAAC,CAAC;IAE/E,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACvC,yBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QACxC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QAC9B,OAAO,MAAM,QAAQ,CAAC;YACrB,KAAK;YACL,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;YACnB,OAAO;YACP,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,MAAM,EAAE,KAAK,CAAC,MAAM;SACpB,CAAC,CAAC;IACJ,CAAC,CAAC,CACF,CAAC;IAEF,MAAM,MAAM,GAAkC,EAAE,CAAC;IACjD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { WorkflowJSON } from '@n8n/workflow-sdk';
2
+ import type { ToolRef } from './detect-tool-refs.service';
3
+ export type ToolRefPinData = Record<string, Array<{
4
+ json: Record<string, unknown>;
5
+ }>>;
6
+ export interface GenerateToolRefPinDataInput {
7
+ workflow: WorkflowJSON;
8
+ agentNodeName: string;
9
+ refs: ToolRef[];
10
+ }
11
+ export declare function generateToolRefPinData(input: GenerateToolRefPinDataInput): Promise<ToolRefPinData>;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateToolRefPinData = generateToolRefPinData;
4
+ const zod_1 = require("zod");
5
+ const column_ref_utils_1 = require("./column-ref-utils");
6
+ const eval_agents_1 = require("../../utils/eval-agents");
7
+ const PinDataResponseSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.object({ json: zod_1.z.record(zod_1.z.unknown()) })).min(1));
8
+ const SYSTEM_INSTRUCTIONS = `You generate realistic mock output for n8n trigger and source nodes referenced inside an AI agent's tools/memory.
9
+
10
+ Output: a single JSON object whose keys are node names and whose values are arrays of n8n pinData items in the form { "json": { ... } }. One item per node is enough.
11
+
12
+ For each node, return data that matches what the node would naturally emit at runtime — based on its type and parameters. Make sure every requested field appears in your output, with a plausible value.
13
+
14
+ Return only the JSON object. No prose, no markdown fences.`;
15
+ function readAgentPurpose(agent) {
16
+ if (!agent)
17
+ return undefined;
18
+ const params = agent.parameters;
19
+ if (!params)
20
+ return undefined;
21
+ const direct = params.systemMessage;
22
+ if (typeof direct === 'string' && direct.length > 0)
23
+ return direct.slice(0, 1000);
24
+ const options = params.options;
25
+ if (options && typeof options === 'object') {
26
+ const nested = options.systemMessage;
27
+ if (typeof nested === 'string' && nested.length > 0)
28
+ return nested.slice(0, 1000);
29
+ }
30
+ const text = params.text;
31
+ if (typeof text === 'string' && text.length > 0)
32
+ return text.slice(0, 1000);
33
+ return undefined;
34
+ }
35
+ function buildNodeContexts(workflow, refs) {
36
+ const fieldsBySource = new Map();
37
+ for (const r of refs) {
38
+ const set = fieldsBySource.get(r.sourceNodeName) ?? new Set();
39
+ set.add(r.field);
40
+ fieldsBySource.set(r.sourceNodeName, set);
41
+ }
42
+ const nodesByName = new Map((workflow.nodes ?? []).filter(column_ref_utils_1.nodeHasName).map((n) => [n.name, n]));
43
+ const contexts = [];
44
+ for (const [name, fields] of fieldsBySource) {
45
+ const node = nodesByName.get(name);
46
+ if (!node)
47
+ continue;
48
+ contexts.push({
49
+ name,
50
+ type: node.type,
51
+ parameters: node.parameters,
52
+ requiredFields: [...fields],
53
+ });
54
+ }
55
+ return contexts;
56
+ }
57
+ function formatNodeContextBlock(ctx) {
58
+ const paramsLine = ctx.parameters
59
+ ? `Parameters: ${JSON.stringify(ctx.parameters).slice(0, 500)}`
60
+ : 'Parameters: (none)';
61
+ return [
62
+ `Node name: ${ctx.name}`,
63
+ `Node type: ${ctx.type}`,
64
+ paramsLine,
65
+ `Required fields on json: ${ctx.requiredFields.join(', ')}`,
66
+ ].join('\n');
67
+ }
68
+ function buildUserMessage(contexts, agentPurpose) {
69
+ const blocks = contexts.map(formatNodeContextBlock).join('\n\n');
70
+ const purpose = agentPurpose ? `\nAgent purpose / system prompt:\n${agentPurpose}\n` : '';
71
+ const nodeList = contexts.map((c) => `"${c.name}"`).join(', ');
72
+ return [
73
+ 'Generate realistic mock output (pinData items) for the following n8n nodes.',
74
+ purpose,
75
+ blocks,
76
+ '',
77
+ `Output a single JSON object with exactly these keys: ${nodeList}.`,
78
+ 'Each value: an array with one item shaped like { "json": { ...fields } }.',
79
+ 'All required fields above MUST appear inside `json` for the corresponding node.',
80
+ ].join('\n');
81
+ }
82
+ function stripMarkdownFences(text) {
83
+ const trimmed = text.trim();
84
+ const fencedMatch = /^```(?:json)?\s*([\s\S]*?)\s*```$/i.exec(trimmed);
85
+ return fencedMatch ? fencedMatch[1].trim() : trimmed;
86
+ }
87
+ function filterToRequested(parsed, requested) {
88
+ const out = {};
89
+ for (const [name, items] of Object.entries(parsed)) {
90
+ if (!requested.has(name))
91
+ continue;
92
+ out[name] = items;
93
+ }
94
+ return out;
95
+ }
96
+ async function generateToolRefPinData(input) {
97
+ if (input.refs.length === 0)
98
+ return {};
99
+ const contexts = buildNodeContexts(input.workflow, input.refs);
100
+ if (contexts.length === 0)
101
+ return {};
102
+ const agent = (input.workflow.nodes ?? []).find((n) => (0, column_ref_utils_1.nodeHasName)(n) && n.name === input.agentNodeName);
103
+ const agentPurpose = readAgentPurpose(agent);
104
+ const userText = buildUserMessage(contexts, agentPurpose);
105
+ try {
106
+ const llm = (0, eval_agents_1.createEvalAgent)('eval-tool-ref-pin-data', {
107
+ model: eval_agents_1.HAIKU_MODEL,
108
+ instructions: SYSTEM_INSTRUCTIONS,
109
+ });
110
+ const result = await llm.generate([
111
+ { role: 'user', content: [{ type: 'text', text: userText }] },
112
+ ]);
113
+ const text = (0, eval_agents_1.extractText)(result);
114
+ const parsed = JSON.parse(stripMarkdownFences(text));
115
+ const validated = PinDataResponseSchema.safeParse(parsed);
116
+ if (!validated.success)
117
+ return {};
118
+ const requested = new Set(contexts.map((c) => c.name));
119
+ return filterToRequested(validated.data, requested);
120
+ }
121
+ catch {
122
+ return {};
123
+ }
124
+ }
125
+ //# sourceMappingURL=generate-tool-ref-pin-data.service.js.map