n8n/packages/@n8n/instance-ai/evaluations/harness/workflow-context.ts
José Braulio González Valido 7791a940dd
feat(ai-builder): Author-level conversation expectations on eval test cases (no-changelog) (#31787)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 10:06:07 +00:00

34 lines
1.1 KiB
TypeScript

import type { WorkflowResponse } from '../clients/n8n-client';
/** Render the per-build workflow structure: nodes, connections, all configs. */
export function buildWorkflowContextBlock(wf: WorkflowResponse | undefined): string {
if (!wf) return '## Workflow structure\n\n(no workflow built)';
const lines: string[] = ['## Workflow structure', ''];
for (const node of wf.nodes) {
lines.push(`- **${node.name ?? '(unnamed)'}** (${node.type})`);
}
lines.push('');
lines.push('**All node configs:**');
lines.push(
'```json',
JSON.stringify(
wf.nodes.map((node) => ({
name: node.name ?? '(unnamed)',
type: node.type,
typeVersion: node.typeVersion,
...(node.disabled !== undefined ? { disabled: node.disabled } : {}),
...(node.onError !== undefined ? { onError: node.onError } : {}),
...(node.credentials !== undefined ? { credentials: node.credentials } : {}),
parameters: node.parameters ?? {},
})),
null,
2,
),
'```',
'',
);
lines.push('**Connections:**');
lines.push('```json', JSON.stringify(wf.connections, null, 2), '```');
return lines.join('\n');
}