@n8n/instance-ai 1.7.2 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/instance-agent.d.ts +1 -1
- package/dist/agent/instance-agent.js +88 -75
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/mcp-tool-name-validation.d.ts +4 -2
- package/dist/agent/mcp-tool-name-validation.js +2 -2
- package/dist/agent/mcp-tool-name-validation.js.map +1 -1
- package/dist/agent/runtime-workspace.d.ts +6 -0
- package/dist/agent/runtime-workspace.js +14 -0
- package/dist/agent/runtime-workspace.js.map +1 -0
- package/dist/agent/sanitize-mcp-schemas.d.ts +4 -3
- package/dist/agent/sanitize-mcp-schemas.js +53 -24
- package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
- package/dist/agent/sub-agent-debriefing.d.ts +2 -2
- package/dist/agent/sub-agent-factory.d.ts +7 -4
- package/dist/agent/sub-agent-factory.js +24 -13
- package/dist/agent/sub-agent-factory.js.map +1 -1
- package/dist/agent/system-prompt.js +18 -15
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/constants/max-steps.d.ts +1 -1
- package/dist/constants/max-steps.js +1 -1
- package/dist/constants/max-steps.js.map +1 -1
- package/dist/domain-access/domain-gating.d.ts +2 -2
- package/dist/error-formatting.d.ts +1 -0
- package/dist/error-formatting.js +159 -0
- package/dist/error-formatting.js.map +1 -0
- package/dist/index.d.ts +65 -24
- package/dist/index.js +96 -52
- package/dist/index.js.map +1 -1
- package/dist/mcp/mcp-client-manager.d.ts +5 -4
- package/dist/mcp/mcp-client-manager.js +42 -17
- package/dist/mcp/mcp-client-manager.js.map +1 -1
- package/dist/memory/title-utils.d.ts +4 -1
- package/dist/memory/title-utils.js +10 -2
- package/dist/memory/title-utils.js.map +1 -1
- package/dist/parsers/structured-file-parser.d.ts +5 -2
- package/dist/parsers/structured-file-parser.js +9 -2
- package/dist/parsers/structured-file-parser.js.map +1 -1
- package/dist/planned-tasks/planned-task-permissions.js +3 -5
- package/dist/planned-tasks/planned-task-permissions.js.map +1 -1
- package/dist/planned-tasks/planned-task-service.d.ts +1 -0
- package/dist/planned-tasks/planned-task-service.js +8 -0
- package/dist/planned-tasks/planned-task-service.js.map +1 -1
- package/dist/runtime/background-task-manager.d.ts +9 -2
- package/dist/runtime/background-task-manager.js +7 -2
- package/dist/runtime/background-task-manager.js.map +1 -1
- package/dist/runtime/liveness-policy.js +4 -3
- package/dist/runtime/liveness-policy.js.map +1 -1
- package/dist/runtime/resumable-stream-executor.d.ts +4 -24
- package/dist/runtime/resumable-stream-executor.js +103 -1318
- package/dist/runtime/resumable-stream-executor.js.map +1 -1
- package/dist/runtime/run-state-registry.d.ts +8 -2
- package/dist/runtime/run-state-registry.js +19 -1
- package/dist/runtime/run-state-registry.js.map +1 -1
- package/dist/runtime/stream-runner.d.ts +4 -4
- package/dist/runtime/stream-runner.js +11 -25
- package/dist/runtime/stream-runner.js.map +1 -1
- package/dist/skills/materialize-runtime-skills.d.ts +62 -0
- package/dist/skills/materialize-runtime-skills.js +467 -0
- package/dist/skills/materialize-runtime-skills.js.map +1 -0
- package/dist/skills/runtime-skills.d.ts +4 -0
- package/dist/skills/runtime-skills.js +17 -0
- package/dist/skills/runtime-skills.js.map +1 -0
- package/dist/source-map-filter.d.ts +17 -0
- package/dist/source-map-filter.js +39 -0
- package/dist/source-map-filter.js.map +1 -0
- package/dist/storage/agent-tree-snapshot.d.ts +2 -0
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +8 -7
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/planned-task-storage.d.ts +3 -3
- package/dist/storage/planned-task-storage.js +3 -8
- package/dist/storage/planned-task-storage.js.map +1 -1
- package/dist/storage/terminal-outcome-storage.d.ts +4 -4
- package/dist/storage/terminal-outcome-storage.js +1 -1
- package/dist/storage/terminal-outcome-storage.js.map +1 -1
- package/dist/storage/{mastra-iteration-log-storage.d.ts → thread-iteration-log-storage.d.ts} +3 -3
- package/dist/storage/{mastra-iteration-log-storage.js → thread-iteration-log-storage.js} +5 -5
- package/dist/storage/thread-iteration-log-storage.js.map +1 -0
- package/dist/storage/thread-patch.d.ts +16 -10
- package/dist/storage/thread-patch.js +37 -36
- package/dist/storage/thread-patch.js.map +1 -1
- package/dist/storage/{mastra-task-storage.d.ts → thread-task-storage.d.ts} +3 -3
- package/dist/storage/{mastra-task-storage.js → thread-task-storage.js} +5 -5
- package/dist/storage/thread-task-storage.js.map +1 -0
- package/dist/storage/workflow-loop-storage.d.ts +28 -28
- package/dist/storage/workflow-loop-storage.js +1 -1
- package/dist/storage/workflow-loop-storage.js.map +1 -1
- package/dist/stream/consume-with-hitl.d.ts +11 -11
- package/dist/stream/consume-with-hitl.js +27 -15
- package/dist/stream/consume-with-hitl.js.map +1 -1
- package/dist/stream/map-chunk.d.ts +1 -1
- package/dist/stream/map-chunk.js +153 -36
- package/dist/stream/map-chunk.js.map +1 -1
- package/dist/tool-registry.d.ts +8 -0
- package/dist/tool-registry.js +45 -0
- package/dist/tool-registry.js.map +1 -0
- package/dist/tools/attachments/parse-file.tool.d.ts +42 -45
- package/dist/tools/attachments/parse-file.tool.js +140 -97
- package/dist/tools/attachments/parse-file.tool.js.map +1 -1
- package/dist/tools/credentials.tool.d.ts +5 -5
- package/dist/tools/credentials.tool.js +31 -34
- package/dist/tools/credentials.tool.js.map +1 -1
- package/dist/tools/data-tables.tool.d.ts +3 -2
- package/dist/tools/data-tables.tool.js +99 -100
- package/dist/tools/data-tables.tool.js.map +1 -1
- package/dist/tools/evals/apply-pin-data.service.d.ts +3 -0
- package/dist/tools/evals/apply-pin-data.service.js +19 -0
- package/dist/tools/evals/apply-pin-data.service.js.map +1 -0
- package/dist/tools/evals/column-ref-utils.d.ts +3 -0
- package/dist/tools/evals/column-ref-utils.js +205 -48
- package/dist/tools/evals/column-ref-utils.js.map +1 -1
- package/dist/tools/evals/detect-agent-named-refs.service.js +20 -4
- package/dist/tools/evals/detect-agent-named-refs.service.js.map +1 -1
- package/dist/tools/evals/ensure-eval-data-table.service.d.ts +15 -0
- package/dist/tools/evals/ensure-eval-data-table.service.js +83 -0
- package/dist/tools/evals/ensure-eval-data-table.service.js.map +1 -0
- package/dist/tools/evals/eval-data-requirements.service.d.ts +1 -0
- package/dist/tools/evals/eval-data-requirements.service.js +23 -4
- package/dist/tools/evals/eval-data-requirements.service.js.map +1 -1
- package/dist/tools/evals/evals.tool.d.ts +2 -0
- package/dist/tools/evals/evals.tool.js +452 -0
- package/dist/tools/evals/evals.tool.js.map +1 -0
- package/dist/tools/evals/extract-rows-from-history.service.d.ts +17 -0
- package/dist/tools/evals/extract-rows-from-history.service.js +103 -0
- package/dist/tools/evals/extract-rows-from-history.service.js.map +1 -0
- package/dist/tools/evals/format-eval-setup-task.d.ts +16 -0
- package/dist/tools/evals/format-eval-setup-task.js +167 -0
- package/dist/tools/evals/format-eval-setup-task.js.map +1 -0
- package/dist/tools/evals/generate-sample-rows.service.d.ts +35 -0
- package/dist/tools/evals/generate-sample-rows.service.js +278 -0
- package/dist/tools/evals/generate-sample-rows.service.js.map +1 -0
- package/dist/tools/evals/generate-tool-ref-pin-data.service.d.ts +11 -0
- package/dist/tools/evals/generate-tool-ref-pin-data.service.js +125 -0
- package/dist/tools/evals/generate-tool-ref-pin-data.service.js.map +1 -0
- package/dist/tools/evals/metric-catalog.d.ts +10 -4
- package/dist/tools/evals/metric-catalog.js.map +1 -1
- package/dist/tools/executions.tool.d.ts +1 -1
- package/dist/tools/executions.tool.js +25 -34
- package/dist/tools/executions.tool.js.map +1 -1
- package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +2 -3
- package/dist/tools/filesystem/create-tools-from-mcp-server.js +129 -67
- package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
- package/dist/tools/index.d.ts +4 -16
- package/dist/tools/index.js +102 -92
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nodes.tool.d.ts +1 -1
- package/dist/tools/nodes.tool.js +31 -33
- package/dist/tools/nodes.tool.js.map +1 -1
- package/dist/tools/orchestration/add-plan-item.tool.d.ts +2 -2
- package/dist/tools/orchestration/add-plan-item.tool.js +45 -49
- package/dist/tools/orchestration/add-plan-item.tool.js.map +1 -1
- package/dist/tools/orchestration/agent-persistence.d.ts +14 -0
- package/dist/tools/orchestration/agent-persistence.js +43 -0
- package/dist/tools/orchestration/agent-persistence.js.map +1 -0
- package/dist/tools/orchestration/blueprint-accumulator.d.ts +4 -8
- package/dist/tools/orchestration/blueprint-accumulator.js +11 -78
- package/dist/tools/orchestration/blueprint-accumulator.js.map +1 -1
- package/dist/tools/orchestration/blueprint.schema.d.ts +13 -147
- package/dist/tools/orchestration/blueprint.schema.js +4 -23
- package/dist/tools/orchestration/blueprint.schema.js.map +1 -1
- package/dist/tools/orchestration/browser-credential-setup.nudge.d.ts +2 -4
- package/dist/tools/orchestration/browser-credential-setup.nudge.js +1 -1
- package/dist/tools/orchestration/browser-credential-setup.nudge.js.map +1 -1
- package/dist/tools/orchestration/browser-credential-setup.tool.d.ts +10 -2
- package/dist/tools/orchestration/browser-credential-setup.tool.js +299 -270
- package/dist/tools/orchestration/browser-credential-setup.tool.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.prompt.d.ts +7 -1
- package/dist/tools/orchestration/build-workflow-agent.prompt.js +46 -20
- package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +50 -5
- package/dist/tools/orchestration/build-workflow-agent.tool.js +748 -605
- package/dist/tools/orchestration/build-workflow-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/builder-memory-compaction.d.ts +6 -2
- package/dist/tools/orchestration/builder-memory-compaction.js +32 -46
- package/dist/tools/orchestration/builder-memory-compaction.js.map +1 -1
- package/dist/tools/orchestration/complete-checkpoint.tool.d.ts +1 -1
- package/dist/tools/orchestration/complete-checkpoint.tool.js +46 -47
- package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -1
- package/dist/tools/orchestration/delegate.tool.d.ts +1 -1
- package/dist/tools/orchestration/delegate.tool.js +170 -166
- package/dist/tools/orchestration/delegate.tool.js.map +1 -1
- package/dist/tools/orchestration/eval-data-agent.tool.d.ts +2 -0
- package/dist/tools/orchestration/eval-data-agent.tool.js +183 -0
- package/dist/tools/orchestration/eval-data-agent.tool.js.map +1 -0
- package/dist/tools/orchestration/eval-setup-agent.prompt.d.ts +1 -0
- package/dist/tools/orchestration/eval-setup-agent.prompt.js +238 -0
- package/dist/tools/orchestration/eval-setup-agent.prompt.js.map +1 -0
- package/dist/tools/orchestration/eval-setup-agent.tool.d.ts +31 -0
- package/dist/tools/orchestration/eval-setup-agent.tool.js +204 -0
- package/dist/tools/orchestration/eval-setup-agent.tool.js.map +1 -0
- package/dist/tools/orchestration/plan-agent-prompt.d.ts +1 -1
- package/dist/tools/orchestration/plan-agent-prompt.js +9 -9
- package/dist/tools/orchestration/plan-with-agent.tool.d.ts +1 -1
- package/dist/tools/orchestration/plan-with-agent.tool.js +210 -179
- package/dist/tools/orchestration/plan-with-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/plan.tool.d.ts +5 -2
- package/dist/tools/orchestration/plan.tool.js +125 -105
- package/dist/tools/orchestration/plan.tool.js.map +1 -1
- package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +3 -3
- package/dist/tools/orchestration/report-verification-verdict.tool.js +65 -66
- package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
- package/dist/tools/orchestration/submit-plan.tool.d.ts +1 -1
- package/dist/tools/orchestration/submit-plan.tool.js +83 -66
- package/dist/tools/orchestration/submit-plan.tool.js.map +1 -1
- package/dist/tools/orchestration/tracing-utils.d.ts +3 -2
- package/dist/tools/orchestration/tracing-utils.js +58 -39
- package/dist/tools/orchestration/tracing-utils.js.map +1 -1
- package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +5 -5
- package/dist/tools/orchestration/verify-built-workflow.tool.js +166 -166
- package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
- package/dist/tools/research.tool.d.ts +1 -1
- package/dist/tools/research.tool.js +59 -27
- package/dist/tools/research.tool.js.map +1 -1
- package/dist/tools/shared/ask-user.tool.d.ts +3 -2
- package/dist/tools/shared/ask-user.tool.js +61 -63
- package/dist/tools/shared/ask-user.tool.js.map +1 -1
- package/dist/tools/task-control.tool.d.ts +1 -1
- package/dist/tools/task-control.tool.js +15 -16
- package/dist/tools/task-control.tool.js.map +1 -1
- package/dist/tools/templates.tool.d.ts +1 -1
- package/dist/tools/templates.tool.js +6 -7
- package/dist/tools/templates.tool.js.map +1 -1
- package/dist/tools/tool-ids.d.ts +40 -0
- package/dist/tools/tool-ids.js +62 -0
- package/dist/tools/tool-ids.js.map +1 -0
- package/dist/tools/workflows/apply-workflow-credentials.tool.d.ts +3 -3
- package/dist/tools/workflows/apply-workflow-credentials.tool.js +72 -73
- package/dist/tools/workflows/apply-workflow-credentials.tool.js.map +1 -1
- package/dist/tools/workflows/build-workflow.tool.d.ts +3 -3
- package/dist/tools/workflows/build-workflow.tool.js +113 -114
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/materialize-node-type.tool.d.ts +6 -6
- package/dist/tools/workflows/materialize-node-type.tool.js +64 -65
- package/dist/tools/workflows/materialize-node-type.tool.js.map +1 -1
- package/dist/tools/workflows/resolve-credentials.d.ts +3 -5
- package/dist/tools/workflows/resolve-credentials.js +15 -6
- package/dist/tools/workflows/resolve-credentials.js.map +1 -1
- package/dist/tools/workflows/setup-workflow.schema.d.ts +2 -2
- package/dist/tools/workflows/submit-workflow-identity.d.ts +8 -9
- package/dist/tools/workflows/submit-workflow-identity.js +41 -27
- package/dist/tools/workflows/submit-workflow-identity.js.map +1 -1
- package/dist/tools/workflows/submit-workflow.tool.d.ts +10 -7
- package/dist/tools/workflows/submit-workflow.tool.js +224 -191
- package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/validate-workflow.service.d.ts +15 -0
- package/dist/tools/workflows/validate-workflow.service.js +289 -0
- package/dist/tools/workflows/validate-workflow.service.js.map +1 -0
- package/dist/tools/workflows/write-sandbox-file.tool.d.ts +2 -2
- package/dist/tools/workflows/write-sandbox-file.tool.js +29 -30
- package/dist/tools/workflows/write-sandbox-file.tool.js.map +1 -1
- package/dist/tools/workflows.tool.d.ts +5 -2
- package/dist/tools/workflows.tool.js +184 -85
- package/dist/tools/workflows.tool.js.map +1 -1
- package/dist/tools/workspace.tool.d.ts +1 -1
- package/dist/tools/workspace.tool.js +49 -65
- package/dist/tools/workspace.tool.js.map +1 -1
- package/dist/tracing/langsmith-tracing.d.ts +17 -18
- package/dist/tracing/langsmith-tracing.js +941 -677
- package/dist/tracing/langsmith-tracing.js.map +1 -1
- package/dist/tracing/trace-labels.d.ts +5 -0
- package/dist/tracing/trace-labels.js +36 -0
- package/dist/tracing/trace-labels.js.map +1 -0
- package/dist/tracing/trace-payloads.d.ts +23 -0
- package/dist/tracing/trace-payloads.js +1008 -0
- package/dist/tracing/trace-payloads.js.map +1 -0
- package/dist/types.d.ts +57 -25
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/eval-agents.js +1 -1
- package/dist/utils/eval-agents.js.map +1 -1
- package/dist/utils/scrub-secrets.js +1 -1
- package/dist/utils/scrub-secrets.js.map +1 -1
- package/dist/utils/stream-helpers.d.ts +2 -5
- package/dist/utils/stream-helpers.js +12 -1
- package/dist/utils/stream-helpers.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-state.d.ts +18 -18
- package/dist/workspace/builder-templates-service.d.ts +54 -0
- package/dist/workspace/builder-templates-service.js +442 -0
- package/dist/workspace/builder-templates-service.js.map +1 -0
- package/dist/workspace/create-workspace.d.ts +16 -3
- package/dist/workspace/create-workspace.js +45 -21
- package/dist/workspace/create-workspace.js.map +1 -1
- package/dist/workspace/daytona-auth-manager.d.ts +26 -0
- package/dist/workspace/daytona-auth-manager.js +90 -0
- package/dist/workspace/daytona-auth-manager.js.map +1 -0
- package/dist/workspace/daytona-filesystem.d.ts +5 -4
- package/dist/workspace/daytona-filesystem.js +25 -15
- package/dist/workspace/daytona-filesystem.js.map +1 -1
- package/dist/workspace/daytona-sandbox.d.ts +65 -0
- package/dist/workspace/daytona-sandbox.js +314 -0
- package/dist/workspace/daytona-sandbox.js.map +1 -0
- package/dist/workspace/lazy-daytona.d.ts +2 -0
- package/dist/workspace/lazy-daytona.js +12 -0
- package/dist/workspace/lazy-daytona.js.map +1 -0
- package/dist/workspace/lazy-runtime-workspace.d.ts +8 -0
- package/dist/workspace/lazy-runtime-workspace.js +246 -0
- package/dist/workspace/lazy-runtime-workspace.js.map +1 -0
- package/dist/workspace/local-filesystem.d.ts +48 -0
- package/dist/workspace/local-filesystem.js +250 -0
- package/dist/workspace/local-filesystem.js.map +1 -0
- package/dist/workspace/local-sandbox.d.ts +28 -0
- package/dist/workspace/local-sandbox.js +121 -0
- package/dist/workspace/local-sandbox.js.map +1 -0
- package/dist/workspace/n8n-sandbox-filesystem.d.ts +3 -3
- package/dist/workspace/n8n-sandbox-filesystem.js +3 -3
- package/dist/workspace/n8n-sandbox-filesystem.js.map +1 -1
- package/dist/workspace/n8n-sandbox-sandbox.d.ts +12 -3
- package/dist/workspace/n8n-sandbox-sandbox.js +54 -10
- package/dist/workspace/n8n-sandbox-sandbox.js.map +1 -1
- package/dist/workspace/sandbox-fs.d.ts +35 -4
- package/dist/workspace/sandbox-fs.js +1 -1
- package/dist/workspace/sandbox-fs.js.map +1 -1
- package/dist/workspace/sandbox-setup.d.ts +13 -4
- package/dist/workspace/sandbox-setup.js +250 -36
- package/dist/workspace/sandbox-setup.js.map +1 -1
- package/dist/workspace/scoped-workspace.d.ts +2 -0
- package/dist/workspace/scoped-workspace.js +141 -0
- package/dist/workspace/scoped-workspace.js.map +1 -0
- package/dist/workspace/snapshot-manager.d.ts +11 -5
- package/dist/workspace/snapshot-manager.js +64 -17
- package/dist/workspace/snapshot-manager.js.map +1 -1
- package/dist/workspace/template-telemetry.d.ts +4 -4
- package/dist/workspace/template-telemetry.js +18 -6
- package/dist/workspace/template-telemetry.js.map +1 -1
- package/package.json +12 -15
- package/skills/data-table-manager/SKILL.md +119 -0
- package/skills/data-table-manager/references/data-table-playbook.md +212 -0
- package/dist/agent/register-with-mastra.d.ts +0 -3
- package/dist/agent/register-with-mastra.js +0 -15
- package/dist/agent/register-with-mastra.js.map +0 -1
- package/dist/compaction/compaction-helper.d.ts +0 -9
- package/dist/compaction/compaction-helper.js +0 -58
- package/dist/compaction/compaction-helper.js.map +0 -1
- package/dist/compaction/index.d.ts +0 -2
- package/dist/compaction/index.js +0 -6
- package/dist/compaction/index.js.map +0 -1
- package/dist/memory/memory-config.d.ts +0 -3
- package/dist/memory/memory-config.js +0 -27
- package/dist/memory/memory-config.js.map +0 -1
- package/dist/runtime/builder-sandbox-session-registry.d.ts +0 -47
- package/dist/runtime/builder-sandbox-session-registry.js +0 -166
- package/dist/runtime/builder-sandbox-session-registry.js.map +0 -1
- package/dist/storage/mastra-iteration-log-storage.js.map +0 -1
- package/dist/storage/mastra-task-storage.js.map +0 -1
- package/dist/tools/orchestration/data-table-agent.prompt.d.ts +0 -1
- package/dist/tools/orchestration/data-table-agent.prompt.js +0 -47
- package/dist/tools/orchestration/data-table-agent.prompt.js.map +0 -1
- package/dist/tools/orchestration/data-table-agent.tool.d.ts +0 -26
- package/dist/tools/orchestration/data-table-agent.tool.js +0 -174
- package/dist/tools/orchestration/data-table-agent.tool.js.map +0 -1
- package/dist/tools/orchestration/research-agent-prompt.d.ts +0 -1
- package/dist/tools/orchestration/research-agent-prompt.js +0 -26
- package/dist/tools/orchestration/research-agent-prompt.js.map +0 -1
- package/dist/tools/orchestration/research-with-agent.tool.d.ts +0 -30
- package/dist/tools/orchestration/research-with-agent.tool.js +0 -179
- package/dist/tools/orchestration/research-with-agent.tool.js.map +0 -1
- package/dist/workspace/builder-sandbox-factory.d.ts +0 -30
- package/dist/workspace/builder-sandbox-factory.js +0 -289
- package/dist/workspace/builder-sandbox-factory.js.map +0 -1
- package/dist/workspace/guarded-filesystem.d.ts +0 -10
- package/dist/workspace/guarded-filesystem.js +0 -136
- package/dist/workspace/guarded-filesystem.js.map +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEvalDataAgentTool = createEvalDataAgentTool;
|
|
4
|
+
const agents_1 = require("@n8n/agents");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const eval_data_requirements_service_1 = require("../evals/eval-data-requirements.service");
|
|
7
|
+
const extract_rows_from_history_service_1 = require("../evals/extract-rows-from-history.service");
|
|
8
|
+
const generate_sample_rows_service_1 = require("../evals/generate-sample-rows.service");
|
|
9
|
+
const HISTORY_THRESHOLD = 10;
|
|
10
|
+
const GENERATE_ROW_COUNT = 10;
|
|
11
|
+
async function ensureColumnsExist(dataTableService, dataTableId, rows, extraColumns, options) {
|
|
12
|
+
const referencedColumns = new Set(extraColumns);
|
|
13
|
+
for (const row of rows) {
|
|
14
|
+
for (const key of Object.keys(row))
|
|
15
|
+
referencedColumns.add(key);
|
|
16
|
+
}
|
|
17
|
+
if (referencedColumns.size === 0)
|
|
18
|
+
return;
|
|
19
|
+
const schema = await dataTableService.getSchema(dataTableId, options);
|
|
20
|
+
const existing = new Set(schema.map((c) => c.name));
|
|
21
|
+
const missing = [...referencedColumns].filter((name) => !existing.has(name));
|
|
22
|
+
for (const name of missing) {
|
|
23
|
+
await dataTableService.addColumn(dataTableId, { name, type: 'string' }, options);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const evalDataInputSchema = zod_1.z.object({
|
|
27
|
+
workflowId: zod_1.z.string().describe('ID of the workflow whose eval DataTable should be populated'),
|
|
28
|
+
projectId: zod_1.z.string().optional(),
|
|
29
|
+
});
|
|
30
|
+
const PREVIEW_ROW_COUNT = 3;
|
|
31
|
+
const PREVIEW_VALUE_MAX_LEN = 80;
|
|
32
|
+
const tableSummarySchema = zod_1.z.object({
|
|
33
|
+
id: zod_1.z.string(),
|
|
34
|
+
name: zod_1.z.string(),
|
|
35
|
+
projectId: zod_1.z.string().optional(),
|
|
36
|
+
rowCount: zod_1.z.number(),
|
|
37
|
+
inputColumns: zod_1.z.array(zod_1.z.string()),
|
|
38
|
+
expectedOutputColumns: zod_1.z.array(zod_1.z.string()),
|
|
39
|
+
previewRows: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())),
|
|
40
|
+
});
|
|
41
|
+
const outputSchema = zod_1.z.object({
|
|
42
|
+
status: zod_1.z.enum(['imported', 'generated', 'skipped']),
|
|
43
|
+
rowCount: zod_1.z.number().optional(),
|
|
44
|
+
source: zod_1.z.enum(['history', 'synthetic']).optional(),
|
|
45
|
+
reason: zod_1.z.string().optional(),
|
|
46
|
+
expectedOutputsNeedUserReview: zod_1.z.boolean().optional(),
|
|
47
|
+
expectedOutputColumns: zod_1.z.array(zod_1.z.string()).optional(),
|
|
48
|
+
table: tableSummarySchema.optional(),
|
|
49
|
+
});
|
|
50
|
+
function truncateForPreview(value) {
|
|
51
|
+
if (typeof value !== 'string')
|
|
52
|
+
return value;
|
|
53
|
+
return value.length > PREVIEW_VALUE_MAX_LEN ? `${value.slice(0, PREVIEW_VALUE_MAX_LEN)}…` : value;
|
|
54
|
+
}
|
|
55
|
+
function buildPreviewRows(rows) {
|
|
56
|
+
return rows.slice(0, PREVIEW_ROW_COUNT).map((row) => {
|
|
57
|
+
const truncated = {};
|
|
58
|
+
for (const [key, value] of Object.entries(row)) {
|
|
59
|
+
truncated[key] = truncateForPreview(value);
|
|
60
|
+
}
|
|
61
|
+
return truncated;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function createEvalDataAgentTool(context) {
|
|
65
|
+
return new agents_1.Tool('eval-data')
|
|
66
|
+
.description('Populate an eval DataTable for a workflow that already has its eval setup wired. ' +
|
|
67
|
+
'First scans the workflow execution history for real rows (these include real expected ' +
|
|
68
|
+
'outputs); if fewer than 10 valid rows are available, generates synthetic rows with INPUT ' +
|
|
69
|
+
'columns only — expected-output columns are left empty so the user can fill them in with ' +
|
|
70
|
+
'the correct answers. We never auto-fill expected outputs with model-generated guesses, ' +
|
|
71
|
+
'because that would measure self-consistency rather than correctness. ' +
|
|
72
|
+
'Inserts at most 25 rows total. Synchronous — no sub-agent, no HITL.')
|
|
73
|
+
.input(evalDataInputSchema)
|
|
74
|
+
.output(outputSchema)
|
|
75
|
+
.handler(async (input) => {
|
|
76
|
+
const domain = context.domainContext;
|
|
77
|
+
if (!domain) {
|
|
78
|
+
return { status: 'skipped', reason: 'Domain context unavailable.' };
|
|
79
|
+
}
|
|
80
|
+
const log = (level, msg) => {
|
|
81
|
+
domain.logger?.[level]?.(`[eval-data] ${msg}`);
|
|
82
|
+
};
|
|
83
|
+
const j = (v) => JSON.stringify(v);
|
|
84
|
+
log('info', `start workflowId=${input.workflowId} projectId=${j(input.projectId)}`);
|
|
85
|
+
const workflow = await domain.workflowService.getAsWorkflowJSON(input.workflowId);
|
|
86
|
+
const reqs = (0, eval_data_requirements_service_1.analyzeEvalDataRequirements)(workflow);
|
|
87
|
+
const target = reqs.targets[0];
|
|
88
|
+
if (!target) {
|
|
89
|
+
log('warn', `skip:no-target reason=${j(reqs.reason)}`);
|
|
90
|
+
return { status: 'skipped', reason: reqs.reason ?? 'No eval target.' };
|
|
91
|
+
}
|
|
92
|
+
log('info', `target dataTableId=${target.dataTableId} agent=${j(target.targetAgentNodeName)} inputColumns=${j(target.inputColumns)} expectedOutputColumns=${j(target.expectedOutputColumns)} pairs=${j(target.expectedToActualPairs)}`);
|
|
93
|
+
if (!target.targetAgentNodeName) {
|
|
94
|
+
log('warn', 'skip:no-agent');
|
|
95
|
+
return {
|
|
96
|
+
status: 'skipped',
|
|
97
|
+
reason: 'No agent node reachable from EvaluationTrigger.',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const { rows: historyRows } = await (0, extract_rows_from_history_service_1.extractRowsFromExecutionHistory)(domain, {
|
|
101
|
+
workflow,
|
|
102
|
+
workflowId: input.workflowId,
|
|
103
|
+
agentNodeName: target.targetAgentNodeName,
|
|
104
|
+
inputColumns: target.inputColumns,
|
|
105
|
+
expectedToActualPairs: target.expectedToActualPairs,
|
|
106
|
+
});
|
|
107
|
+
log('info', `history-extracted count=${historyRows.length}`);
|
|
108
|
+
let rowsToInsert;
|
|
109
|
+
let source;
|
|
110
|
+
if (historyRows.length >= HISTORY_THRESHOLD) {
|
|
111
|
+
rowsToInsert = historyRows;
|
|
112
|
+
source = 'history';
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
rowsToInsert = await (0, generate_sample_rows_service_1.generateSampleRows)({
|
|
116
|
+
workflow,
|
|
117
|
+
columns: target.inputColumns,
|
|
118
|
+
rowCount: GENERATE_ROW_COUNT,
|
|
119
|
+
targetAgentNodeName: target.targetAgentNodeName,
|
|
120
|
+
...(historyRows.length > 0 ? { realExamples: historyRows } : {}),
|
|
121
|
+
});
|
|
122
|
+
source = 'synthetic';
|
|
123
|
+
}
|
|
124
|
+
log('info', `rows-prepared source=${source} count=${rowsToInsert.length} firstRowKeys=${j(rowsToInsert[0] ? Object.keys(rowsToInsert[0]) : [])}`);
|
|
125
|
+
const dataTableOptions = input.projectId ? { projectId: input.projectId } : undefined;
|
|
126
|
+
const extraColumns = source === 'synthetic' ? target.expectedOutputColumns : [];
|
|
127
|
+
try {
|
|
128
|
+
await ensureColumnsExist(domain.dataTableService, target.dataTableId, rowsToInsert, extraColumns, dataTableOptions);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
132
|
+
log('error', `ensureColumnsExist-failed error=${j(message)}`);
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
let insertResult;
|
|
136
|
+
try {
|
|
137
|
+
insertResult = await domain.dataTableService.insertRows(target.dataTableId, rowsToInsert, dataTableOptions);
|
|
138
|
+
log('info', `insertRows-ok result=${j(insertResult)}`);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
142
|
+
log('error', `insertRows-failed error=${j(message)}`);
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
let previewRows = [];
|
|
146
|
+
try {
|
|
147
|
+
const preview = await domain.dataTableService.queryRows(target.dataTableId, {
|
|
148
|
+
limit: PREVIEW_ROW_COUNT,
|
|
149
|
+
...(insertResult.projectId ? { projectId: insertResult.projectId } : {}),
|
|
150
|
+
});
|
|
151
|
+
previewRows = buildPreviewRows(preview.data);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
155
|
+
log('warn', `preview-query-failed error=${j(message)}`);
|
|
156
|
+
}
|
|
157
|
+
log('info', `done source=${source} rowCount=${rowsToInsert.length}`);
|
|
158
|
+
const needsReview = source === 'synthetic' && target.expectedOutputColumns.length > 0;
|
|
159
|
+
const table = {
|
|
160
|
+
id: target.dataTableId,
|
|
161
|
+
name: insertResult.tableName,
|
|
162
|
+
...(insertResult.projectId ? { projectId: insertResult.projectId } : {}),
|
|
163
|
+
rowCount: rowsToInsert.length,
|
|
164
|
+
inputColumns: target.inputColumns,
|
|
165
|
+
expectedOutputColumns: target.expectedOutputColumns,
|
|
166
|
+
previewRows,
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
status: source === 'history' ? 'imported' : 'generated',
|
|
170
|
+
rowCount: rowsToInsert.length,
|
|
171
|
+
source,
|
|
172
|
+
...(needsReview
|
|
173
|
+
? {
|
|
174
|
+
expectedOutputsNeedUserReview: true,
|
|
175
|
+
expectedOutputColumns: target.expectedOutputColumns,
|
|
176
|
+
}
|
|
177
|
+
: {}),
|
|
178
|
+
table,
|
|
179
|
+
};
|
|
180
|
+
})
|
|
181
|
+
.build();
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=eval-data-agent.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval-data-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/eval-data-agent.tool.ts"],"names":[],"mappings":";;AAwFA,0DA2JC;AAnPD,wCAAmC;AACnC,6BAAwB;AAGxB,4FAAsF;AACtF,kGAA6F;AAC7F,wFAA2E;AAE3E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,KAAK,UAAU,kBAAkB,CAChC,gBAA4C,EAC5C,WAAmB,EACnB,IAAoC,EACpC,YAA+B,EAC/B,OAA2C;IAE3C,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS,YAAY,CAAC,CAAC;IACxD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,iBAAiB,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO;IAEzC,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACtE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,CAAC,GAAG,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAE7E,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,gBAAgB,CAAC,SAAS,C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AY,EAAE,MAAM,CAAC,YAAY;YACjC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;YACnD,WAAW;SACX,CAAC;QACF,OAAO;YACN,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAE,UAAoB,CAAC,CAAC,CAAE,WAAqB;YAC7E,QAAQ,EAAE,YAAY,CAAC,MAAM;YAC7B,MAAM;YACN,GAAG,CAAC,WAAW;gBACd,CAAC,CAAC;oBACA,6BAA6B,EAAE,IAAa;oBAC5C,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;iBACnD;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,KAAK;SACL,CAAC;IACH,CAAC,CAAC;SACD,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EVAL_SETUP_AGENT_PROMPT = "You are an eval setup specialist for n8n workflows. You receive an approved eval setup request from the parent agent and handle the topology setup: workflow patching with evaluation nodes (EvaluationTrigger, Evaluation(checkIfEvaluating)/setOutputs/setMetrics) wired directly to the target AI agent, using the DataTable id provided in the task. Synthetic row generation is outside your scope.\n\n## Output Discipline\n- You report to a parent agent, not a human. Be terse.\n- Do NOT narrate (\"I'll read the workflow now\", \"Let me check the schema\"). Just do the work.\n- No emojis, no filler phrases, no markdown headers in conversational output.\n- Only output a final one-line summary (e.g., \"Eval setup complete: 4 eval nodes added and existing DataTable 'Wf eval dataset' wired\").\n\n## Mandatory Process\n\n1. **Read the workflow** via `workflows(action=\"get-json\", workflowId)` using the workflowId in the task. Identify the AI agent nodes named in the task. Trace the main trigger path.\n2. **Use the DataTable id from the task.** The task always names an existing DataTable id under \"Wire the EvaluationTrigger to DataTable id ...\". Use it as-is. Do not create, modify rows, or modify schema. If the task says to leave it empty (the `later` path), set the `EvaluationTrigger.dataTableId` to an empty string and report that the user must wire it manually.\n3. **Patch the workflow.** Build the eval topology in this order:\n a. Insert `EvaluationTrigger` (`name: \"Eval Trigger\"`).\n b. **If the task contains a `PRODUCTION ADAPTER` section, follow it LITERALLY.** Insert the named Set node immediately upstream of the agent on the production path with the exact assignments listed; for each rewrite line under section 3 of the PRODUCTION ADAPTER (which lists target nodes \u2014 the agent itself AND any of its connected sub-components like memory, tools, output parsers), substring-replace the listed `originalExpression` with the EXACT replacement form shown on that line. **Do not assume the replacement is always `$json.<column>`** \u2014 the task uses `$json.<column>` for the agent target but `{{ $('<AgentName>').item.json.<column> }}` for sub-components, because sub-components do not see `$json` from the agent's input row. Use what the task says verbatim. Do not invent extra assignments, do not skip any, do not add intermediate nodes between the Set adapter and the agent. Do not skip any target node. After this step the agent has TWO incoming `main` connections \u2014 one from the Set adapter (production), one from the EvaluationTrigger (eval).\n c. **If the task does NOT contain a `PRODUCTION ADAPTER` section**, wire `EvaluationTrigger` directly to the agent's `main` input \u2014 no Set node, no rewrites. The agent's existing parameters reference `$json.<column>` already (the orchestrator validated this).\n d. After the agent: insert `Evaluation(checkIfEvaluating)` (no separate IF node \u2014 it has two native main output slots). Slot 0 (Evaluation) \u2192 `Evaluation(setOutputs)` \u2192 one `Evaluation(setMetrics)` per metric listed under \"Metrics\". Slot 1 (Normal) preserves the original production downstream path with side-effects.\n e. For `correctness` and `helpfulness` metrics: wire an additional outgoing `ai_languageModel` connection from the workflow's existing LLM model node to each setMetrics node that uses an AI-judged metric. The LLM gets reused \u2014 same node, additional connection. Without this, AI-judged metrics fail silently.\n4. **Save** the modified workflow via `workflows(action=\"update\", ...)`.\n5. **Validate**: re-read the workflow via `workflows(action=\"get-json\", workflowId)` and assert:\n - EvaluationTrigger \u2192 target AI agent (direct `main` connection, no intermediate node).\n - Agent \u2192 checkIfEvaluating; slot 0 \u2192 setOutputs \u2192 setMetrics; slot 1 \u2192 original downstream path.\n - When input columns are non-empty, the agent's parameters contain at least one `{{ $json.<column> }}` expression matching a column from \"Input columns\".\n - For `correctness`/`helpfulness` metrics: existing LLM model node has an outgoing `ai_languageModel` connection to the corresponding setMetrics node.\n If any assertion fails, attempt one fix cycle. If still broken, include the specific failure in your summary and stop.\n6. **Report** with a one-line summary.\n\nDo NOT produce visible output during steps 1-5. All reasoning happens internally.\n\nHard boundary: this sub-agent has NO DataTable mutation tools. Do not attempt to create, populate, or modify any DataTable. Row population is handled by a separate `eval-data` step downstream.\n\nParameter-rewrite scope: rewrite parameters in the agent and sub-components **only** as instructed by the task's `PRODUCTION ADAPTER` section. Do not rewrite anything else. Do not invent rewrites. If the task has no adapter section, leave all node parameters byte-for-byte identical.\n\n## Eval Node Knowledge\n\n### Data Flow Semantics (read this first)\n\nFor a single eval run on row N of the DataTable:\n\n1. `EvaluationTrigger` reads row N \u2192 emits its columns as `$json` (e.g. `{ input, expected_output, row_id: N, ... }`).\n2. The emitted row flows DIRECTLY into the target AI agent node. The agent's parameters must reference `$json.<column>` for the listed input columns. If they reference different fields, those parameters are rewritten during eval setup (see step 3 in Mandatory Process above).\n3. `AI agent` produces its output (e.g. `$json.output`).\n4. `Evaluation(checkIfEvaluating)` gates the path: slot 0 (Evaluation) routes into the eval branch; slot 1 (Normal) routes through the production path with side-effects.\n5. Eval branch: `Evaluation(setOutputs)` WRITES the agent's output back into row N of the DataTable, in a NEW column distinct from any ground-truth column. Then `Evaluation(setMetrics)` reads ground-truth (via the EvaluationTrigger reference) and the agent's output (`$json`), computes a score.\n\nKey invariants:\n- setOutputs adds NEW columns to the dataset; setMetrics compares them against the ground-truth columns. NEVER overwrite a ground-truth column with setOutputs.\n- The `Evaluation(setInputs)` node does NOT reshape `$json` \u2014 it only attaches metadata for the eval-results display. Skip it unless you specifically want extra dataset columns surfaced in the eval results display.\n\n### n8n-nodes-base.evaluationTrigger\nPulls rows from a dataset. For v3 we always use DataTable source.\n\n**typeVersion**: `4.7` (latest supported \u2014 do NOT use 4.8, the Evaluation node version range is different from the EvaluationTrigger's).\n\n**Name the node explicitly** when adding it: `name: \"Eval Trigger\"`. The node's stock default name is `\"When fetching a dataset row\"` \u2014 DON'T rely on that, and DON'T add a separate node with that name. There is exactly ONE EvaluationTrigger per workflow. Use the explicit name everywhere you reference it (e.g. in setMetrics expressions: `={{ $('Eval Trigger').item.json.expected_output }}`).\n\nRequired parameters (all three are necessary \u2014 missing any one makes the trigger inert):\n```\n{\n source: \"dataTable\",\n dataTableId: { __rl: true, mode: \"id\", value: \"<dt_id>\" }, // resourceLocator format\n limitRows: false // (default) \u2014 explicit avoids subtle UI defaults\n}\n```\n\nThe `dataTableId` field is a resourceLocator (`__rl: true` flag). The `mode: \"id\"` + `value` shape is what gets the trigger to actually pull rows. If you skip `__rl: true`, n8n may not recognize the field and the trigger silently does nothing.\n\nWiring: connect the EvaluationTrigger directly to the target AI agent node's main input (direct `main` connection). Do not insert any intermediate Set/Code/transform node between the EvaluationTrigger and the agent.\n\n### n8n-nodes-base.evaluation (4 operations)\n\n**setInputs**: optional. This node does NOT reshape `$json` for downstream nodes \u2014 it only attaches an `evaluationData` metadata field that the n8n \"Evaluations\" tab uses to display dataset column values alongside the eval result row. The downstream `$json` shape is unchanged. Skip this node unless you specifically want extra dataset columns surfaced in the eval results display.\n\nIf used: place it on the eval branch (e.g. between checkIfEvaluating slot 0 and setOutputs). `inputs.values` entries with `inputName`/`inputValue` simply annotate; they don't transform.\n\n**setOutputs**: writes the AI agent's output BACK to the same DataTable row, into a NEW column. After the run, the row contains both the original ground-truth columns AND the agent's actual output, so setMetrics can compare them.\n\nCRITICAL \u2014 set these THREE parameter groups, otherwise the node silently does nothing:\n\n1. **Pin the source to dataTable.** The setOutputs operation has its OWN `source` parameter (independent from EvaluationTrigger's). The default depends on `typeVersion` \u2014 `googleSheets` for \u2264 4.7, `dataTable` for \u2265 4.8. Always set it explicitly:\n - `source: 'dataTable'`\n - `dataTableId: { mode: 'id', value: '<same id as the EvaluationTrigger>' }`\n Use the same DataTable id passed in the task. Strongly prefer `typeVersion: 4.8` (latest) for the Evaluation node so dataTable is the natural default.\n\n2. **outputName must be a NEW column** distinct from any ground-truth column. If the dataset has `expected_output`, use `actual_output` (or `actual_<thing>`) \u2014 never the same name as ground truth, otherwise you'd overwrite the ground truth. The Evaluation node auto-adds the new column on first eval run.\n\n3. **Sub-field names** are `outputName` and `outputValue` (NOT `name`/`value`).\n\nFull parameter shape:\n\n```\n{\n operation: \"setOutputs\",\n source: \"dataTable\",\n dataTableId: { mode: \"id\", value: \"<dt_id>\" },\n outputs: {\n values: [\n { outputName: \"actual_<column>\", outputValue: \"<n8n expression>\" },\n ...\n ]\n }\n}\n```\n\nFor a LangChain agent, the canonical config is:\n\n```\n{\n operation: \"setOutputs\",\n source: \"dataTable\",\n dataTableId: { mode: \"id\", value: \"<dt_id>\" },\n outputs: {\n values: [\n { outputName: \"actual_output\", outputValue: \"={{ $json.output }}\" }\n ]\n }\n}\n```\n\nSo if the task lists ground-truth output columns like `expected_output`, the corresponding setOutputs entries should write to `actual_output`, `actual_response`, etc. \u2014 pick names that pair naturally with the ground-truth columns. Use snake_case.\n\n**setMetrics**: configures ONE metric per node. For multiple metrics, add multiple `Evaluation(setMetrics)` nodes in series (or use `customMetrics` which accepts multiple entries). The `metric` parameter is a SINGLE string, NOT an array.\n\nTop-level parameter:\n- `metric`: one of\n - `correctness` \u2014 AI-judged factual correctness (scale 1-5). Requires `expectedAnswer` + `actualAnswer`.\n - `helpfulness` \u2014 AI-judged helpfulness (scale 1-5). Requires `userQuery` + `actualAnswer`.\n - `stringSimilarity` \u2014 character-level similarity (edit distance, 0-1). Requires `expectedAnswer` + `actualAnswer`.\n - `categorization` \u2014 exact string match (1 or 0). Requires `expectedAnswer` + `actualAnswer`.\n - `toolsUsed` \u2014 whether tools were used (0-1). No ground-truth fields needed.\n - `customMetrics` \u2014 user-defined metrics (advanced, rarely chosen).\n\nHow to reference the values (use the EvaluationTrigger's explicit name \u2014 see above; \"Eval Trigger\" if you followed the convention):\n- `expectedAnswer` (ground truth) \u2014 pulls from the EvaluationTrigger's emitted row. Example: `={{ $('Eval Trigger').item.json.expected_output }}`.\n- `actualAnswer` (agent's response) \u2014 pulls from the AI agent's output JSON, which is still on `$json` at the setMetrics stage (setOutputs forwards its input data unchanged). Example: `={{ $json.output }}`.\n- `userQuery` (for `helpfulness`) \u2014 pulls from the EvaluationTrigger row, e.g. `={{ $('Eval Trigger').item.json.input }}`.\n\nRequired fields per `metric`:\n- `correctness` / `stringSimilarity` / `categorization`: `expectedAnswer` + `actualAnswer`.\n- `helpfulness`: `userQuery` + `actualAnswer`.\n- `toolsUsed`: no extra required fields.\n\n**CRITICAL \u2014 AI-judged metrics need an `ai_languageModel` connection**: when `metric` is `correctness` or `helpfulness` (the LLM-as-judge metrics), the setMetrics node has TWO inputs \u2014 the standard `main` from the eval branch AND a separate `ai_languageModel` slot for the LLM judge. The node will not work without an LLM connected to the `ai_languageModel` slot.\n\nTo wire this:\n1. Find the LLM model node already used by the AI agent in the workflow (e.g., `@n8n/n8n-nodes-langchain.lmChatOpenAi`, `@n8n/n8n-nodes-langchain.lmChatAnthropic`, etc.). It connects to the agent via `ai_languageModel` connection type.\n2. Add a SECOND outgoing `ai_languageModel` connection from the SAME LLM node to the new setMetrics node. The LLM gets reused \u2014 don't duplicate it.\n3. The connection in `workflow.connections` looks like:\n```\n\"Existing LLM Node Name\": {\n \"ai_languageModel\": [\n [\n { \"node\": \"Agent Name\", \"type\": \"ai_languageModel\", \"index\": 0 },\n { \"node\": \"EvalSetMetricsCorrectness\", \"type\": \"ai_languageModel\", \"index\": 0 }\n ]\n ]\n}\n```\n(Both consumers in the SAME inner array under `ai_languageModel[0]` \u2014 one connection slot, multiple downstream consumers.)\n\nIf the workflow has no LLM model node yet (rare for an AI workflow), add one \u2014 but reuse credentials and config of any existing model. `stringSimilarity`, `categorization`, `toolsUsed` do NOT need an `ai_languageModel` connection \u2014 they're deterministic/local metrics.\n\nCanned metric key mapping from the task's `canned=<key>` hints to the `metric` parameter value:\n- `canned=correctness` \u2192 `metric: \"correctness\"`\n- `canned=helpfulness` \u2192 `metric: \"helpfulness\"`\n- `canned=tool_use` \u2192 `metric: \"toolsUsed\"`\n- `canned=relevance` \u2192 `metric: \"categorization\"` (closest stock match)\n- If no canned key present \u2192 use `customMetrics` or pick the most appropriate built-in.\n\n**checkIfEvaluating**: gates the workflow flow based on whether the current run is an eval run. Place it immediately after the AI agent. IMPORTANT: this node has TWO native `main` output slots \u2014 no separate IF node needed:\n- **slot 0 (Evaluation)**: fires when the EvaluationTrigger was executed (i.e., we are in an eval run). Wire this to setOutputs \u2192 setMetrics.\n- **slot 1 (Normal)**: fires during normal (non-eval) workflow execution. Wire this to whatever the AI agent was originally connected to downstream (the production path).\n\nThe node forwards the AI agent's data unchanged down whichever slot is active; it's a flow-control switch, not a data transformer.\n\n### Fallback: schema lookup\nIf you need exact parameter names or displayOptions for any node variant, call `nodes(action=\"describe\", nodeType=<node-type>)`. For TypeScript-level type signatures (useful for complex parameter shapes) use `nodes(action=\"type-definition\", nodeTypes=[<node-type>])`. Don't guess parameter shapes.\n\n## LangChain AI Agent Output\n\n`@n8n/n8n-nodes-langchain.agent` nodes emit output JSON shaped like:\n- `output`: string \u2014 the final response text.\n- `intermediateSteps`: array \u2014 tool calls the agent made (only when tools are attached).\n\nFor setOutputs the most common pattern is `{ outputName: 'actual_output', outputValue: '={{ $json.output }}' }`. For tool-using agents, add columns like `{ outputName: 'tool_used', outputValue: '={{ $json.intermediateSteps?.[0]?.action?.tool }}' }`.\n\n## Required Topology\n\nApply the correct diagram based on whether the task contains a `PRODUCTION ADAPTER` section.\n\n**Direct case (no `PRODUCTION ADAPTER` section in task):**\n\n```\n[Production Trigger] \u2500\u2192 ... \u2500\u2192 [AI Agent] \u2500\u2500\u2192 [checkIfEvaluating]\n \u2191 \u251C\u2500\u2500 slot 0: [setOutputs] \u2500\u2500\u2192 [setMetrics]\n[EvaluationTrigger] \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500 slot 1: [original downstream]\n```\n\n**Adapter case (task contains `PRODUCTION ADAPTER` section):**\n\n```\n[Production Trigger] \u2500\u2192 ... \u2500\u2192 [Eval Production Adapter (Set)] \u2500\u2192 [AI Agent] \u2500\u2192 [checkIfEvaluating]\n \u2191 \u251C\u2500\u2500 slot 0: [setOutputs] \u2500\u2500\u2192 [setMetrics]\n[EvaluationTrigger] \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500 slot 1: [original downstream]\n```\n\nRules:\n- **Direct case**: EvaluationTrigger connects DIRECTLY to the target AI agent node's `main` input. NO Set/Code/transform node in between. The trigger emits each dataset row column as `$json.<column>`. The agent's parameters already reference these columns (no rewrites needed).\n- **Adapter case**: A Set node (`\"Eval Production Adapter\"`) sits between the production trigger path and the agent. The EvaluationTrigger connects DIRECTLY to the agent as a SECOND incoming `main` connection (no Set adapter on the eval path). After the adapter is in place the agent has TWO incoming `main` connections: one from the Set adapter (production runs) and one from the EvaluationTrigger (eval runs). Both paths produce `$json.<column>` so the rewritten agent parameters resolve in both modes.\n- Insert `checkIfEvaluating + setOutputs + setMetrics` AFTER the AI agent node. No IF node needed \u2014 the checkIfEvaluating node itself has two output slots.\n- `checkIfEvaluating` slot 0 (Evaluation) routes to setOutputs \u2192 setMetrics (eval branch; terminates).\n- `checkIfEvaluating` slot 1 (Normal) routes to whatever the AI agent was originally connected to (production path preserved).\n- Side-effect nodes (Send message, HTTP POST, DB writes) MUST be reachable ONLY via slot 1. This is the core invariant \u2014 it's what makes eval runs safe.\n\nMultiple AI agents: one `checkIfEvaluating + setOutputs + setMetrics` block per agent by default. Your judgment: if multiple agents share output semantics (e.g. multi-stage pipeline with one final response), group them and place the eval block after the final agent. Use the task's \"AI AGENT NODES IN WORKFLOW\" hint to prioritize the agent that produces the user-visible output.\n\n## Error Handling & Validation\n\nAfter patching:\n1. Re-read the workflow: `workflows(action=\"get-json\", workflowId)`.\n2. Assert EvaluationTrigger connects DIRECTLY to the target AI agent (no intermediate node on the eval branch).\n3. Assert connections after the agent: agent \u2192 checkIfEvaluating; slot 0 \u2192 setOutputs \u2192 setMetrics (one per metric); slot 1 \u2192 original downstream path.\n4. When the task contained a `PRODUCTION ADAPTER` section: assert\n - The named Set adapter node exists with `typeVersion: 3.4`.\n - The Set adapter's `assignments.assignments` array contains EVERY entry from the task spec.\n - The Set adapter's `main` output connects to the agent's `main` input.\n - EACH target node listed under section 3 of the PRODUCTION ADAPTER (agent and all sub-components) no longer contains any of its original `$('NodeName').item.json.<field>` expressions. The agent target's parameters now use `$json.<column>`; sub-component targets (memory, tools, output parsers) use `$('<AgentName>').item.json.<column>` instead \u2014 match each line of the task verbatim.\n - The EvaluationTrigger has a `main` connection to the agent's `main` input (a SECOND incoming connection).\n When the task did NOT contain an adapter section: assert the agent's parameters reference `$json.<column>` for at least one column from the task's INPUT COLUMNS list (existing rule).\n5. For `correctness`/`helpfulness` metrics: assert the workflow's existing LLM model node has an outgoing `ai_languageModel` connection to the corresponding setMetrics node (in addition to its existing connection to the AI agent).\n6. If any assertion fails, attempt one fix cycle: edit the workflow JSON to repair the missing/incorrect pieces and save again.\n7. If still broken after one fix, include the specific failure in your summary and stop.\n\nDo NOT run the workflow or call `executions(action=\"run\")` \u2014 validation is structural, not behavioral.";
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVAL_SETUP_AGENT_PROMPT = void 0;
|
|
4
|
+
exports.EVAL_SETUP_AGENT_PROMPT = `You are an eval setup specialist for n8n workflows. You receive an approved eval setup request from the parent agent and handle the topology setup: workflow patching with evaluation nodes (EvaluationTrigger, Evaluation(checkIfEvaluating)/setOutputs/setMetrics) wired directly to the target AI agent, using the DataTable id provided in the task. Synthetic row generation is outside your scope.
|
|
5
|
+
|
|
6
|
+
## Output Discipline
|
|
7
|
+
- You report to a parent agent, not a human. Be terse.
|
|
8
|
+
- Do NOT narrate ("I'll read the workflow now", "Let me check the schema"). Just do the work.
|
|
9
|
+
- No emojis, no filler phrases, no markdown headers in conversational output.
|
|
10
|
+
- Only output a final one-line summary (e.g., "Eval setup complete: 4 eval nodes added and existing DataTable 'Wf eval dataset' wired").
|
|
11
|
+
|
|
12
|
+
## Mandatory Process
|
|
13
|
+
|
|
14
|
+
1. **Read the workflow** via \`workflows(action="get-json", workflowId)\` using the workflowId in the task. Identify the AI agent nodes named in the task. Trace the main trigger path.
|
|
15
|
+
2. **Use the DataTable id from the task.** The task always names an existing DataTable id under "Wire the EvaluationTrigger to DataTable id ...". Use it as-is. Do not create, modify rows, or modify schema. If the task says to leave it empty (the \`later\` path), set the \`EvaluationTrigger.dataTableId\` to an empty string and report that the user must wire it manually.
|
|
16
|
+
3. **Patch the workflow.** Build the eval topology in this order:
|
|
17
|
+
a. Insert \`EvaluationTrigger\` (\`name: "Eval Trigger"\`).
|
|
18
|
+
b. **If the task contains a \`PRODUCTION ADAPTER\` section, follow it LITERALLY.** Insert the named Set node immediately upstream of the agent on the production path with the exact assignments listed; for each rewrite line under section 3 of the PRODUCTION ADAPTER (which lists target nodes — the agent itself AND any of its connected sub-components like memory, tools, output parsers), substring-replace the listed \`originalExpression\` with the EXACT replacement form shown on that line. **Do not assume the replacement is always \`$json.<column>\`** — the task uses \`$json.<column>\` for the agent target but \`{{ $('<AgentName>').item.json.<column> }}\` for sub-components, because sub-components do not see \`$json\` from the agent's input row. Use what the task says verbatim. Do not invent extra assignments, do not skip any, do not add intermediate nodes between the Set adapter and the agent. Do not skip any target node. After this step the agent has TWO incoming \`main\` connections — one from the Set adapter (production), one from the EvaluationTrigger (eval).
|
|
19
|
+
c. **If the task does NOT contain a \`PRODUCTION ADAPTER\` section**, wire \`EvaluationTrigger\` directly to the agent's \`main\` input — no Set node, no rewrites. The agent's existing parameters reference \`$json.<column>\` already (the orchestrator validated this).
|
|
20
|
+
d. After the agent: insert \`Evaluation(checkIfEvaluating)\` (no separate IF node — it has two native main output slots). Slot 0 (Evaluation) → \`Evaluation(setOutputs)\` → one \`Evaluation(setMetrics)\` per metric listed under "Metrics". Slot 1 (Normal) preserves the original production downstream path with side-effects.
|
|
21
|
+
e. For \`correctness\` and \`helpfulness\` metrics: wire an additional outgoing \`ai_languageModel\` connection from the workflow's existing LLM model node to each setMetrics node that uses an AI-judged metric. The LLM gets reused — same node, additional connection. Without this, AI-judged metrics fail silently.
|
|
22
|
+
4. **Save** the modified workflow via \`workflows(action="update", ...)\`.
|
|
23
|
+
5. **Validate**: re-read the workflow via \`workflows(action="get-json", workflowId)\` and assert:
|
|
24
|
+
- EvaluationTrigger → target AI agent (direct \`main\` connection, no intermediate node).
|
|
25
|
+
- Agent → checkIfEvaluating; slot 0 → setOutputs → setMetrics; slot 1 → original downstream path.
|
|
26
|
+
- When input columns are non-empty, the agent's parameters contain at least one \`{{ $json.<column> }}\` expression matching a column from "Input columns".
|
|
27
|
+
- For \`correctness\`/\`helpfulness\` metrics: existing LLM model node has an outgoing \`ai_languageModel\` connection to the corresponding setMetrics node.
|
|
28
|
+
If any assertion fails, attempt one fix cycle. If still broken, include the specific failure in your summary and stop.
|
|
29
|
+
6. **Report** with a one-line summary.
|
|
30
|
+
|
|
31
|
+
Do NOT produce visible output during steps 1-5. All reasoning happens internally.
|
|
32
|
+
|
|
33
|
+
Hard boundary: this sub-agent has NO DataTable mutation tools. Do not attempt to create, populate, or modify any DataTable. Row population is handled by a separate \`eval-data\` step downstream.
|
|
34
|
+
|
|
35
|
+
Parameter-rewrite scope: rewrite parameters in the agent and sub-components **only** as instructed by the task's \`PRODUCTION ADAPTER\` section. Do not rewrite anything else. Do not invent rewrites. If the task has no adapter section, leave all node parameters byte-for-byte identical.
|
|
36
|
+
|
|
37
|
+
## Eval Node Knowledge
|
|
38
|
+
|
|
39
|
+
### Data Flow Semantics (read this first)
|
|
40
|
+
|
|
41
|
+
For a single eval run on row N of the DataTable:
|
|
42
|
+
|
|
43
|
+
1. \`EvaluationTrigger\` reads row N → emits its columns as \`$json\` (e.g. \`{ input, expected_output, row_id: N, ... }\`).
|
|
44
|
+
2. The emitted row flows DIRECTLY into the target AI agent node. The agent's parameters must reference \`$json.<column>\` for the listed input columns. If they reference different fields, those parameters are rewritten during eval setup (see step 3 in Mandatory Process above).
|
|
45
|
+
3. \`AI agent\` produces its output (e.g. \`$json.output\`).
|
|
46
|
+
4. \`Evaluation(checkIfEvaluating)\` gates the path: slot 0 (Evaluation) routes into the eval branch; slot 1 (Normal) routes through the production path with side-effects.
|
|
47
|
+
5. Eval branch: \`Evaluation(setOutputs)\` WRITES the agent's output back into row N of the DataTable, in a NEW column distinct from any ground-truth column. Then \`Evaluation(setMetrics)\` reads ground-truth (via the EvaluationTrigger reference) and the agent's output (\`$json\`), computes a score.
|
|
48
|
+
|
|
49
|
+
Key invariants:
|
|
50
|
+
- setOutputs adds NEW columns to the dataset; setMetrics compares them against the ground-truth columns. NEVER overwrite a ground-truth column with setOutputs.
|
|
51
|
+
- The \`Evaluation(setInputs)\` node does NOT reshape \`$json\` — it only attaches metadata for the eval-results display. Skip it unless you specifically want extra dataset columns surfaced in the eval results display.
|
|
52
|
+
|
|
53
|
+
### n8n-nodes-base.evaluationTrigger
|
|
54
|
+
Pulls rows from a dataset. For v3 we always use DataTable source.
|
|
55
|
+
|
|
56
|
+
**typeVersion**: \`4.7\` (latest supported — do NOT use 4.8, the Evaluation node version range is different from the EvaluationTrigger's).
|
|
57
|
+
|
|
58
|
+
**Name the node explicitly** when adding it: \`name: "Eval Trigger"\`. The node's stock default name is \`"When fetching a dataset row"\` — DON'T rely on that, and DON'T add a separate node with that name. There is exactly ONE EvaluationTrigger per workflow. Use the explicit name everywhere you reference it (e.g. in setMetrics expressions: \`={{ $('Eval Trigger').item.json.expected_output }}\`).
|
|
59
|
+
|
|
60
|
+
Required parameters (all three are necessary — missing any one makes the trigger inert):
|
|
61
|
+
\`\`\`
|
|
62
|
+
{
|
|
63
|
+
source: "dataTable",
|
|
64
|
+
dataTableId: { __rl: true, mode: "id", value: "<dt_id>" }, // resourceLocator format
|
|
65
|
+
limitRows: false // (default) — explicit avoids subtle UI defaults
|
|
66
|
+
}
|
|
67
|
+
\`\`\`
|
|
68
|
+
|
|
69
|
+
The \`dataTableId\` field is a resourceLocator (\`__rl: true\` flag). The \`mode: "id"\` + \`value\` shape is what gets the trigger to actually pull rows. If you skip \`__rl: true\`, n8n may not recognize the field and the trigger silently does nothing.
|
|
70
|
+
|
|
71
|
+
Wiring: connect the EvaluationTrigger directly to the target AI agent node's main input (direct \`main\` connection). Do not insert any intermediate Set/Code/transform node between the EvaluationTrigger and the agent.
|
|
72
|
+
|
|
73
|
+
### n8n-nodes-base.evaluation (4 operations)
|
|
74
|
+
|
|
75
|
+
**setInputs**: optional. This node does NOT reshape \`$json\` for downstream nodes — it only attaches an \`evaluationData\` metadata field that the n8n "Evaluations" tab uses to display dataset column values alongside the eval result row. The downstream \`$json\` shape is unchanged. Skip this node unless you specifically want extra dataset columns surfaced in the eval results display.
|
|
76
|
+
|
|
77
|
+
If used: place it on the eval branch (e.g. between checkIfEvaluating slot 0 and setOutputs). \`inputs.values\` entries with \`inputName\`/\`inputValue\` simply annotate; they don't transform.
|
|
78
|
+
|
|
79
|
+
**setOutputs**: writes the AI agent's output BACK to the same DataTable row, into a NEW column. After the run, the row contains both the original ground-truth columns AND the agent's actual output, so setMetrics can compare them.
|
|
80
|
+
|
|
81
|
+
CRITICAL — set these THREE parameter groups, otherwise the node silently does nothing:
|
|
82
|
+
|
|
83
|
+
1. **Pin the source to dataTable.** The setOutputs operation has its OWN \`source\` parameter (independent from EvaluationTrigger's). The default depends on \`typeVersion\` — \`googleSheets\` for ≤ 4.7, \`dataTable\` for ≥ 4.8. Always set it explicitly:
|
|
84
|
+
- \`source: 'dataTable'\`
|
|
85
|
+
- \`dataTableId: { mode: 'id', value: '<same id as the EvaluationTrigger>' }\`
|
|
86
|
+
Use the same DataTable id passed in the task. Strongly prefer \`typeVersion: 4.8\` (latest) for the Evaluation node so dataTable is the natural default.
|
|
87
|
+
|
|
88
|
+
2. **outputName must be a NEW column** distinct from any ground-truth column. If the dataset has \`expected_output\`, use \`actual_output\` (or \`actual_<thing>\`) — never the same name as ground truth, otherwise you'd overwrite the ground truth. The Evaluation node auto-adds the new column on first eval run.
|
|
89
|
+
|
|
90
|
+
3. **Sub-field names** are \`outputName\` and \`outputValue\` (NOT \`name\`/\`value\`).
|
|
91
|
+
|
|
92
|
+
Full parameter shape:
|
|
93
|
+
|
|
94
|
+
\`\`\`
|
|
95
|
+
{
|
|
96
|
+
operation: "setOutputs",
|
|
97
|
+
source: "dataTable",
|
|
98
|
+
dataTableId: { mode: "id", value: "<dt_id>" },
|
|
99
|
+
outputs: {
|
|
100
|
+
values: [
|
|
101
|
+
{ outputName: "actual_<column>", outputValue: "<n8n expression>" },
|
|
102
|
+
...
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
\`\`\`
|
|
107
|
+
|
|
108
|
+
For a LangChain agent, the canonical config is:
|
|
109
|
+
|
|
110
|
+
\`\`\`
|
|
111
|
+
{
|
|
112
|
+
operation: "setOutputs",
|
|
113
|
+
source: "dataTable",
|
|
114
|
+
dataTableId: { mode: "id", value: "<dt_id>" },
|
|
115
|
+
outputs: {
|
|
116
|
+
values: [
|
|
117
|
+
{ outputName: "actual_output", outputValue: "={{ $json.output }}" }
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
So if the task lists ground-truth output columns like \`expected_output\`, the corresponding setOutputs entries should write to \`actual_output\`, \`actual_response\`, etc. — pick names that pair naturally with the ground-truth columns. Use snake_case.
|
|
124
|
+
|
|
125
|
+
**setMetrics**: configures ONE metric per node. For multiple metrics, add multiple \`Evaluation(setMetrics)\` nodes in series (or use \`customMetrics\` which accepts multiple entries). The \`metric\` parameter is a SINGLE string, NOT an array.
|
|
126
|
+
|
|
127
|
+
Top-level parameter:
|
|
128
|
+
- \`metric\`: one of
|
|
129
|
+
- \`correctness\` — AI-judged factual correctness (scale 1-5). Requires \`expectedAnswer\` + \`actualAnswer\`.
|
|
130
|
+
- \`helpfulness\` — AI-judged helpfulness (scale 1-5). Requires \`userQuery\` + \`actualAnswer\`.
|
|
131
|
+
- \`stringSimilarity\` — character-level similarity (edit distance, 0-1). Requires \`expectedAnswer\` + \`actualAnswer\`.
|
|
132
|
+
- \`categorization\` — exact string match (1 or 0). Requires \`expectedAnswer\` + \`actualAnswer\`.
|
|
133
|
+
- \`toolsUsed\` — whether tools were used (0-1). No ground-truth fields needed.
|
|
134
|
+
- \`customMetrics\` — user-defined metrics (advanced, rarely chosen).
|
|
135
|
+
|
|
136
|
+
How to reference the values (use the EvaluationTrigger's explicit name — see above; "Eval Trigger" if you followed the convention):
|
|
137
|
+
- \`expectedAnswer\` (ground truth) — pulls from the EvaluationTrigger's emitted row. Example: \`={{ $('Eval Trigger').item.json.expected_output }}\`.
|
|
138
|
+
- \`actualAnswer\` (agent's response) — pulls from the AI agent's output JSON, which is still on \`$json\` at the setMetrics stage (setOutputs forwards its input data unchanged). Example: \`={{ $json.output }}\`.
|
|
139
|
+
- \`userQuery\` (for \`helpfulness\`) — pulls from the EvaluationTrigger row, e.g. \`={{ $('Eval Trigger').item.json.input }}\`.
|
|
140
|
+
|
|
141
|
+
Required fields per \`metric\`:
|
|
142
|
+
- \`correctness\` / \`stringSimilarity\` / \`categorization\`: \`expectedAnswer\` + \`actualAnswer\`.
|
|
143
|
+
- \`helpfulness\`: \`userQuery\` + \`actualAnswer\`.
|
|
144
|
+
- \`toolsUsed\`: no extra required fields.
|
|
145
|
+
|
|
146
|
+
**CRITICAL — AI-judged metrics need an \`ai_languageModel\` connection**: when \`metric\` is \`correctness\` or \`helpfulness\` (the LLM-as-judge metrics), the setMetrics node has TWO inputs — the standard \`main\` from the eval branch AND a separate \`ai_languageModel\` slot for the LLM judge. The node will not work without an LLM connected to the \`ai_languageModel\` slot.
|
|
147
|
+
|
|
148
|
+
To wire this:
|
|
149
|
+
1. Find the LLM model node already used by the AI agent in the workflow (e.g., \`@n8n/n8n-nodes-langchain.lmChatOpenAi\`, \`@n8n/n8n-nodes-langchain.lmChatAnthropic\`, etc.). It connects to the agent via \`ai_languageModel\` connection type.
|
|
150
|
+
2. Add a SECOND outgoing \`ai_languageModel\` connection from the SAME LLM node to the new setMetrics node. The LLM gets reused — don't duplicate it.
|
|
151
|
+
3. The connection in \`workflow.connections\` looks like:
|
|
152
|
+
\`\`\`
|
|
153
|
+
"Existing LLM Node Name": {
|
|
154
|
+
"ai_languageModel": [
|
|
155
|
+
[
|
|
156
|
+
{ "node": "Agent Name", "type": "ai_languageModel", "index": 0 },
|
|
157
|
+
{ "node": "EvalSetMetricsCorrectness", "type": "ai_languageModel", "index": 0 }
|
|
158
|
+
]
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
\`\`\`
|
|
162
|
+
(Both consumers in the SAME inner array under \`ai_languageModel[0]\` — one connection slot, multiple downstream consumers.)
|
|
163
|
+
|
|
164
|
+
If the workflow has no LLM model node yet (rare for an AI workflow), add one — but reuse credentials and config of any existing model. \`stringSimilarity\`, \`categorization\`, \`toolsUsed\` do NOT need an \`ai_languageModel\` connection — they're deterministic/local metrics.
|
|
165
|
+
|
|
166
|
+
Canned metric key mapping from the task's \`canned=<key>\` hints to the \`metric\` parameter value:
|
|
167
|
+
- \`canned=correctness\` → \`metric: "correctness"\`
|
|
168
|
+
- \`canned=helpfulness\` → \`metric: "helpfulness"\`
|
|
169
|
+
- \`canned=tool_use\` → \`metric: "toolsUsed"\`
|
|
170
|
+
- \`canned=relevance\` → \`metric: "categorization"\` (closest stock match)
|
|
171
|
+
- If no canned key present → use \`customMetrics\` or pick the most appropriate built-in.
|
|
172
|
+
|
|
173
|
+
**checkIfEvaluating**: gates the workflow flow based on whether the current run is an eval run. Place it immediately after the AI agent. IMPORTANT: this node has TWO native \`main\` output slots — no separate IF node needed:
|
|
174
|
+
- **slot 0 (Evaluation)**: fires when the EvaluationTrigger was executed (i.e., we are in an eval run). Wire this to setOutputs → setMetrics.
|
|
175
|
+
- **slot 1 (Normal)**: fires during normal (non-eval) workflow execution. Wire this to whatever the AI agent was originally connected to downstream (the production path).
|
|
176
|
+
|
|
177
|
+
The node forwards the AI agent's data unchanged down whichever slot is active; it's a flow-control switch, not a data transformer.
|
|
178
|
+
|
|
179
|
+
### Fallback: schema lookup
|
|
180
|
+
If you need exact parameter names or displayOptions for any node variant, call \`nodes(action="describe", nodeType=<node-type>)\`. For TypeScript-level type signatures (useful for complex parameter shapes) use \`nodes(action="type-definition", nodeTypes=[<node-type>])\`. Don't guess parameter shapes.
|
|
181
|
+
|
|
182
|
+
## LangChain AI Agent Output
|
|
183
|
+
|
|
184
|
+
\`@n8n/n8n-nodes-langchain.agent\` nodes emit output JSON shaped like:
|
|
185
|
+
- \`output\`: string — the final response text.
|
|
186
|
+
- \`intermediateSteps\`: array — tool calls the agent made (only when tools are attached).
|
|
187
|
+
|
|
188
|
+
For setOutputs the most common pattern is \`{ outputName: 'actual_output', outputValue: '={{ $json.output }}' }\`. For tool-using agents, add columns like \`{ outputName: 'tool_used', outputValue: '={{ $json.intermediateSteps?.[0]?.action?.tool }}' }\`.
|
|
189
|
+
|
|
190
|
+
## Required Topology
|
|
191
|
+
|
|
192
|
+
Apply the correct diagram based on whether the task contains a \`PRODUCTION ADAPTER\` section.
|
|
193
|
+
|
|
194
|
+
**Direct case (no \`PRODUCTION ADAPTER\` section in task):**
|
|
195
|
+
|
|
196
|
+
\`\`\`
|
|
197
|
+
[Production Trigger] ─→ ... ─→ [AI Agent] ──→ [checkIfEvaluating]
|
|
198
|
+
↑ ├── slot 0: [setOutputs] ──→ [setMetrics]
|
|
199
|
+
[EvaluationTrigger] ──────────────┘ └── slot 1: [original downstream]
|
|
200
|
+
\`\`\`
|
|
201
|
+
|
|
202
|
+
**Adapter case (task contains \`PRODUCTION ADAPTER\` section):**
|
|
203
|
+
|
|
204
|
+
\`\`\`
|
|
205
|
+
[Production Trigger] ─→ ... ─→ [Eval Production Adapter (Set)] ─→ [AI Agent] ─→ [checkIfEvaluating]
|
|
206
|
+
↑ ├── slot 0: [setOutputs] ──→ [setMetrics]
|
|
207
|
+
[EvaluationTrigger] ──────────────────────────────────────────────────┘ └── slot 1: [original downstream]
|
|
208
|
+
\`\`\`
|
|
209
|
+
|
|
210
|
+
Rules:
|
|
211
|
+
- **Direct case**: EvaluationTrigger connects DIRECTLY to the target AI agent node's \`main\` input. NO Set/Code/transform node in between. The trigger emits each dataset row column as \`$json.<column>\`. The agent's parameters already reference these columns (no rewrites needed).
|
|
212
|
+
- **Adapter case**: A Set node (\`"Eval Production Adapter"\`) sits between the production trigger path and the agent. The EvaluationTrigger connects DIRECTLY to the agent as a SECOND incoming \`main\` connection (no Set adapter on the eval path). After the adapter is in place the agent has TWO incoming \`main\` connections: one from the Set adapter (production runs) and one from the EvaluationTrigger (eval runs). Both paths produce \`$json.<column>\` so the rewritten agent parameters resolve in both modes.
|
|
213
|
+
- Insert \`checkIfEvaluating + setOutputs + setMetrics\` AFTER the AI agent node. No IF node needed — the checkIfEvaluating node itself has two output slots.
|
|
214
|
+
- \`checkIfEvaluating\` slot 0 (Evaluation) routes to setOutputs → setMetrics (eval branch; terminates).
|
|
215
|
+
- \`checkIfEvaluating\` slot 1 (Normal) routes to whatever the AI agent was originally connected to (production path preserved).
|
|
216
|
+
- Side-effect nodes (Send message, HTTP POST, DB writes) MUST be reachable ONLY via slot 1. This is the core invariant — it's what makes eval runs safe.
|
|
217
|
+
|
|
218
|
+
Multiple AI agents: one \`checkIfEvaluating + setOutputs + setMetrics\` block per agent by default. Your judgment: if multiple agents share output semantics (e.g. multi-stage pipeline with one final response), group them and place the eval block after the final agent. Use the task's "AI AGENT NODES IN WORKFLOW" hint to prioritize the agent that produces the user-visible output.
|
|
219
|
+
|
|
220
|
+
## Error Handling & Validation
|
|
221
|
+
|
|
222
|
+
After patching:
|
|
223
|
+
1. Re-read the workflow: \`workflows(action="get-json", workflowId)\`.
|
|
224
|
+
2. Assert EvaluationTrigger connects DIRECTLY to the target AI agent (no intermediate node on the eval branch).
|
|
225
|
+
3. Assert connections after the agent: agent → checkIfEvaluating; slot 0 → setOutputs → setMetrics (one per metric); slot 1 → original downstream path.
|
|
226
|
+
4. When the task contained a \`PRODUCTION ADAPTER\` section: assert
|
|
227
|
+
- The named Set adapter node exists with \`typeVersion: 3.4\`.
|
|
228
|
+
- The Set adapter's \`assignments.assignments\` array contains EVERY entry from the task spec.
|
|
229
|
+
- The Set adapter's \`main\` output connects to the agent's \`main\` input.
|
|
230
|
+
- EACH target node listed under section 3 of the PRODUCTION ADAPTER (agent and all sub-components) no longer contains any of its original \`$('NodeName').item.json.<field>\` expressions. The agent target's parameters now use \`$json.<column>\`; sub-component targets (memory, tools, output parsers) use \`$('<AgentName>').item.json.<column>\` instead — match each line of the task verbatim.
|
|
231
|
+
- The EvaluationTrigger has a \`main\` connection to the agent's \`main\` input (a SECOND incoming connection).
|
|
232
|
+
When the task did NOT contain an adapter section: assert the agent's parameters reference \`$json.<column>\` for at least one column from the task's INPUT COLUMNS list (existing rule).
|
|
233
|
+
5. For \`correctness\`/\`helpfulness\` metrics: assert the workflow's existing LLM model node has an outgoing \`ai_languageModel\` connection to the corresponding setMetrics node (in addition to its existing connection to the AI agent).
|
|
234
|
+
6. If any assertion fails, attempt one fix cycle: edit the workflow JSON to repair the missing/incorrect pieces and save again.
|
|
235
|
+
7. If still broken after one fix, include the specific failure in your summary and stop.
|
|
236
|
+
|
|
237
|
+
Do NOT run the workflow or call \`executions(action="run")\` — validation is structural, not behavioral.`;
|
|
238
|
+
//# sourceMappingURL=eval-setup-agent.prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval-setup-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/eval-setup-agent.prompt.ts"],"names":[],"mappings":";;;AAOa,QAAA,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yGAyOkE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { InstanceAiToolRegistry, OrchestrationContext } from '../../types';
|
|
3
|
+
export declare function buildEvalSetupTools(context: OrchestrationContext): InstanceAiToolRegistry;
|
|
4
|
+
export interface StartEvalSetupAgentInput {
|
|
5
|
+
workflowId: string;
|
|
6
|
+
task: string;
|
|
7
|
+
conversationContext?: string;
|
|
8
|
+
taskId?: string;
|
|
9
|
+
agentId?: string;
|
|
10
|
+
plannedTaskId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface StartedEvalSetupAgentTask {
|
|
13
|
+
result: string;
|
|
14
|
+
taskId: string;
|
|
15
|
+
agentId: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function startEvalSetupAgentTask(context: OrchestrationContext, input: StartEvalSetupAgentInput): StartedEvalSetupAgentTask;
|
|
18
|
+
export declare const evalSetupAgentInputSchema: z.ZodObject<{
|
|
19
|
+
workflowId: z.ZodString;
|
|
20
|
+
task: z.ZodString;
|
|
21
|
+
conversationContext: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
workflowId: string;
|
|
24
|
+
task: string;
|
|
25
|
+
conversationContext?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
workflowId: string;
|
|
28
|
+
task: string;
|
|
29
|
+
conversationContext?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function createEvalSetupAgentTool(context: OrchestrationContext): import("@n8n/agents").BuiltTool;
|