@kairos-sdk/core 0.4.5 → 0.5.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.
@@ -2,7 +2,7 @@ import {
2
2
  RULE_EXAMPLES,
3
3
  RULE_MITIGATIONS,
4
4
  scoreToMode
5
- } from "./chunk-6IXW3WCC.js";
5
+ } from "./chunk-VPPWTMRJ.js";
6
6
 
7
7
  // src/generation/prompt-builder.ts
8
8
  import { readFileSync } from "fs";
@@ -208,6 +208,14 @@ Cron: { "rule": { "interval": [{ "field": "cronExpression", "expression": "0 9 *
208
208
  8. No deprecated $node["NodeName"].json \u2014 use $('NodeName').item.json.field
209
209
  9. No $json.items[0] array indexing \u2014 access fields directly as $json.field
210
210
  10. No bare $('NodeName').json \u2014 always use .first().json.field or .all()
211
+ 11. httpRequest URL is a real endpoint (not "example.com" or "YOUR_URL")
212
+ 12. code nodes contain actual logic \u2014 not empty or comment-only
213
+ 13. Slack message nodes have a channel specified (channelId or channel)
214
+ 14. Gmail send nodes have a recipient (to field non-empty)
215
+ 15. if nodes have at least one condition in conditions.conditions[]
216
+ 16. set nodes have at least one entry in assignments.assignments[]
217
+ 17. scheduleTrigger has at least one rule in rule.interval[]
218
+ 18. webhook path is relative (no spaces, no leading slash, no http://)
211
219
 
212
220
  ---
213
221
 
@@ -243,18 +251,37 @@ var PromptBuilder = class {
243
251
  }
244
252
  build(request, matches, globalFailureRates = [], dynamicCatalog) {
245
253
  const mode = this.resolveMode(matches);
246
- const system = this.buildSystem(matches, mode, globalFailureRates, dynamicCatalog);
254
+ const system = this.buildSystem(matches, mode, globalFailureRates, dynamicCatalog, request.description);
247
255
  const userMessage = this.buildUserMessage(request, matches, mode);
248
256
  return { system, userMessage, mode, matches };
249
257
  }
250
- buildCorrectionMessage(request, matches, allIssues, attempt) {
258
+ buildCorrectionMessage(request, matches, allIssues, attempt, failingRuleIds) {
251
259
  const base = this.buildUserMessage(request, matches, this.resolveMode(matches));
260
+ let examplesSection = "";
261
+ if (failingRuleIds && failingRuleIds.length > 0) {
262
+ const uniqueRules = [...new Set(failingRuleIds)];
263
+ const exampleLines = [];
264
+ for (const rule of uniqueRules) {
265
+ const ex = RULE_EXAMPLES[rule];
266
+ if (ex) {
267
+ exampleLines.push(`Rule ${rule}:
268
+ Bad: ${ex.bad}
269
+ Good: ${ex.good}`);
270
+ }
271
+ }
272
+ if (exampleLines.length > 0) {
273
+ examplesSection = `
274
+
275
+ ## Concrete Fix Examples
276
+ ${exampleLines.join("\n\n")}`;
277
+ }
278
+ }
252
279
  return `${base}
253
280
 
254
281
  IMPORTANT: A previous generation attempt (attempt ${attempt}) failed validation with these issues:
255
282
  ${allIssues.join("\n")}
256
283
 
257
- Fix ALL of the above issues in your new response. Do not repeat any of these mistakes.`;
284
+ Fix ALL of the above issues in your new response. Do not repeat any of these mistakes.${examplesSection}`;
258
285
  }
259
286
  resolveMode(matches) {
260
287
  if (matches.length === 0) return "scratch";
@@ -262,7 +289,7 @@ Fix ALL of the above issues in your new response. Do not repeat any of these mis
262
289
  if (!top) return "scratch";
263
290
  return scoreToMode(top.score);
264
291
  }
265
- buildSystem(matches, mode, globalFailureRates = [], dynamicCatalog) {
292
+ buildSystem(matches, mode, globalFailureRates = [], dynamicCatalog, description) {
266
293
  let basePrompt = SYSTEM_PROMPT_V1;
267
294
  if (dynamicCatalog) {
268
295
  basePrompt = basePrompt.replace(
@@ -322,7 +349,7 @@ A loosely similar workflow (score: ${hint.score.toFixed(2)}) used these node typ
322
349
  });
323
350
  }
324
351
  }
325
- const warnings = this.buildFailureWarnings(matches, globalFailureRates);
352
+ const warnings = this.buildFailureWarnings(matches, globalFailureRates, description);
326
353
  if (warnings) {
327
354
  blocks.push({ type: "text", text: warnings });
328
355
  }
@@ -349,15 +376,34 @@ A loosely similar workflow (score: ${hint.score.toFixed(2)}) used these node typ
349
376
  const patterns = this._lastActivePatterns ?? this.getActivePatterns(this.resolveMaxPatterns());
350
377
  return patterns.map((p) => p.rule);
351
378
  }
352
- getActivePatterns(maxCount = 10) {
379
+ getActivePatterns(maxCount = 10, description) {
353
380
  const all = this.loadPatterns().filter((p) => p.state !== "resolved" && p.confidence > 0);
354
381
  const regressed = all.filter((p) => p.regressed).sort((a, b) => b.compositeScore - a.compositeScore);
355
382
  const confirmed = all.filter((p) => !p.regressed && p.state === "confirmed").sort((a, b) => b.compositeScore - a.compositeScore);
356
383
  const drafts = all.filter((p) => !p.regressed && p.state !== "confirmed").sort((a, b) => b.compositeScore - a.compositeScore);
357
- return [...regressed, ...confirmed, ...drafts].slice(0, maxCount);
384
+ const ordered = [...regressed, ...confirmed, ...drafts];
385
+ if (this.profile === "minimal" && description) {
386
+ return this.rankByRelevance(ordered, description).slice(0, maxCount);
387
+ }
388
+ return ordered.slice(0, maxCount);
389
+ }
390
+ rankByRelevance(patterns, description) {
391
+ const lower = description.toLowerCase();
392
+ const STAGE_KEYWORDS = {
393
+ credential_injection: ["credential", "auth", "api key", "token", "oauth", "smtp", "imap", "password", "secret"],
394
+ connection_wiring: ["connect", "link", "wire", "chain", "merge", "branch", "join"],
395
+ expression_syntax: ["expression", "variable", "json", "field", "data", "$json", "item"],
396
+ workflow_structure: ["trigger", "webhook", "schedule", "structure", "workflow"],
397
+ node_generation: ["node", "generate", "create", "build", "send", "fetch", "email", "slack", "http"]
398
+ };
399
+ return patterns.map((p) => {
400
+ const keywords = STAGE_KEYWORDS[p.pipelineStage] ?? [];
401
+ const relevanceBoost = keywords.some((kw) => lower.includes(kw)) ? 1 : 0;
402
+ return { pattern: p, sort: relevanceBoost * 10 + p.compositeScore };
403
+ }).sort((a, b) => b.sort - a.sort).map((x) => x.pattern);
358
404
  }
359
- buildFailureWarnings(matches, globalFailureRates) {
360
- const richPatterns = this.getActivePatterns(this.resolveMaxPatterns());
405
+ buildFailureWarnings(matches, globalFailureRates, description) {
406
+ const richPatterns = this.getActivePatterns(this.resolveMaxPatterns(), description);
361
407
  this._lastActivePatterns = richPatterns;
362
408
  if (richPatterns.length > 0) {
363
409
  return this.buildStageGroupedWarnings(richPatterns, matches);
@@ -520,4 +566,4 @@ export {
520
566
  PromptBuilder,
521
567
  inferWorkflowType
522
568
  };
523
- //# sourceMappingURL=chunk-CR2NHLOH.js.map
569
+ //# sourceMappingURL=chunk-V2IZBZGB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generation/prompt-builder.ts","../src/generation/prompts/v1.ts","../src/utils/workflow-type.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { homedir } from 'node:os'\nimport type { WorkflowMatch } from '../library/types.js'\nimport type { RuleFailureRate } from '../telemetry/reader.js'\nimport type { PatternAnalysis, Pattern } from '../telemetry/pattern-analyzer.js'\nimport type { DesignRequest, BuiltPrompt, SystemPromptBlock } from './types.js'\nimport { SYSTEM_PROMPT_V1 } from './prompts/v1.js'\nimport { scoreToMode } from '../utils/thresholds.js'\nimport { RULE_MITIGATIONS, RULE_EXAMPLES } from '../validation/rule-metadata.js'\n\nconst CRITICAL_SCORE_THRESHOLD = 0.15\n\ntype PromptProfile = 'minimal' | 'standard' | 'rich'\n\nfunction resolveProfile(): PromptProfile {\n const env = process.env['KAIROS_PROMPT_PROFILE']\n if (env === 'minimal' || env === 'standard' || env === 'rich') return env\n return 'standard'\n}\n\nconst PROACTIVE_EXPRESSION_GUIDANCE = `## Expression Syntax Quick Reference\\n\\nAlways use these patterns in expressions:\\n- Access node data: $('NodeName').item.json.field (not $node[\"NodeName\"].json)\\n- Access JSON field: $json.field (not $json.items[0].field)\\n- Single item: $('NodeName').first().json.field\\n- All items: $('NodeName').all()`\n\nexport class PromptBuilder {\n private readonly patternsPath: string\n private readonly profile: PromptProfile\n private _lastActivePatterns: Pattern[] | null = null\n\n constructor(patternsPath?: string, profile?: PromptProfile) {\n this.patternsPath = patternsPath ?? join(homedir(), '.kairos', 'patterns.json')\n this.profile = profile ?? resolveProfile()\n }\n\n private resolveMaxPatterns(): number {\n if (this.profile === 'minimal') return 3\n if (this.profile === 'rich') return 15\n return 10\n }\n\n build(request: DesignRequest, matches: WorkflowMatch[], globalFailureRates: RuleFailureRate[] = [], dynamicCatalog?: string): BuiltPrompt {\n const mode = this.resolveMode(matches)\n const system = this.buildSystem(matches, mode, globalFailureRates, dynamicCatalog, request.description)\n const userMessage = this.buildUserMessage(request, matches, mode)\n return { system, userMessage, mode, matches }\n }\n\n buildCorrectionMessage(\n request: DesignRequest,\n matches: WorkflowMatch[],\n allIssues: string[],\n attempt: number,\n failingRuleIds?: number[],\n ): string {\n const base = this.buildUserMessage(request, matches, this.resolveMode(matches))\n\n let examplesSection = ''\n if (failingRuleIds && failingRuleIds.length > 0) {\n const uniqueRules = [...new Set(failingRuleIds)]\n const exampleLines: string[] = []\n for (const rule of uniqueRules) {\n const ex = RULE_EXAMPLES[rule]\n if (ex) {\n exampleLines.push(`Rule ${rule}:\\n Bad: ${ex.bad}\\n Good: ${ex.good}`)\n }\n }\n if (exampleLines.length > 0) {\n examplesSection = `\\n\\n## Concrete Fix Examples\\n${exampleLines.join('\\n\\n')}`\n }\n }\n\n return `${base}\n\nIMPORTANT: A previous generation attempt (attempt ${attempt}) failed validation with these issues:\n${allIssues.join('\\n')}\n\nFix ALL of the above issues in your new response. Do not repeat any of these mistakes.${examplesSection}`\n }\n\n private resolveMode(matches: WorkflowMatch[]): 'direct' | 'reference' | 'scratch' {\n if (matches.length === 0) return 'scratch'\n const top = matches[0]\n if (!top) return 'scratch'\n return scoreToMode(top.score)\n }\n\n private buildSystem(matches: WorkflowMatch[], mode: 'direct' | 'reference' | 'scratch', globalFailureRates: RuleFailureRate[] = [], dynamicCatalog?: string, description?: string): SystemPromptBlock[] {\n let basePrompt = SYSTEM_PROMPT_V1\n if (dynamicCatalog) {\n basePrompt = basePrompt.replace(\n /## NODE CATALOG — exact type strings and safe typeVersions[\\s\\S]*?(?=## PRE-DELIVERY SELF-CHECK)/,\n dynamicCatalog + '\\n\\n',\n )\n }\n\n const blocks: SystemPromptBlock[] = [\n {\n type: 'text',\n text: basePrompt,\n cache_control: { type: 'ephemeral' },\n },\n ]\n\n if (this.profile !== 'minimal') {\n if (mode === 'reference' && matches.length > 0) {\n const refText = matches\n .slice(0, 3)\n .map((m) => {\n const nodes = m.workflow.workflow.nodes\n .map((n) => ` - ${n.name} (${n.type} v${n.typeVersion})`)\n .join('\\n')\n return `Reference workflow: \"${m.workflow.description}\" (similarity: ${m.score.toFixed(2)})\\nNodes:\\n${nodes}`\n })\n .join('\\n\\n')\n\n blocks.push({\n type: 'text',\n text: `## Similar Workflows From Library (for reference only — adapt, do not copy verbatim)\\n\\n${refText}`,\n })\n }\n\n if (mode === 'direct' && matches[0]) {\n const match = matches[0]\n const json = JSON.stringify(match.workflow.workflow, null, 2)\n if (json.length > 30_000) {\n const nodes = match.workflow.workflow.nodes\n .map((n) => ` - ${n.name} (${n.type} v${n.typeVersion})`)\n .join('\\n')\n blocks.push({\n type: 'text',\n text: `## Closely Matched Workflow (score: ${match.score.toFixed(2)}) — too large for full JSON, using reference:\\nNodes:\\n${nodes}`,\n })\n } else {\n blocks.push({\n type: 'text',\n text: `## Closely Matched Workflow (score: ${match.score.toFixed(2)}) — adapt this structure:\\n\\n${json}`,\n })\n }\n }\n\n if (mode === 'scratch' && matches.length > 0 && matches[0]!.score >= 0.40) {\n const hint = matches[0]!\n const nodeTypes = hint.workflow.workflow.nodes.map((n) => n.type.split('.').pop()).join(', ')\n blocks.push({\n type: 'text',\n text: `## Weak Structural Hint\\nA loosely similar workflow (score: ${hint.score.toFixed(2)}) used these node types: ${nodeTypes}`,\n })\n }\n }\n\n const warnings = this.buildFailureWarnings(matches, globalFailureRates, description)\n if (warnings) {\n blocks.push({ type: 'text', text: warnings })\n }\n\n if (this.profile === 'rich') {\n const expressionRules = new Set([24, 25, 26])\n const expressionAlreadyCovered = (this._lastActivePatterns ?? []).some(p => expressionRules.has(p.rule))\n if (!expressionAlreadyCovered) {\n blocks.push({ type: 'text', text: PROACTIVE_EXPRESSION_GUIDANCE })\n }\n }\n\n return blocks\n }\n\n private loadPatterns(): Pattern[] {\n try {\n const raw = readFileSync(this.patternsPath, 'utf-8')\n const analysis = JSON.parse(raw) as PatternAnalysis\n const patterns = analysis.topFailureRules ?? []\n return patterns.filter(p => typeof p.pipelineStage === 'string' && typeof p.state === 'string')\n } catch {\n return []\n }\n }\n\n getWarnedRules(): number[] {\n const patterns = this._lastActivePatterns ?? this.getActivePatterns(this.resolveMaxPatterns())\n return patterns.map(p => p.rule)\n }\n\n private getActivePatterns(maxCount = 10, description?: string): Pattern[] {\n const all = this.loadPatterns()\n .filter(p => p.state !== 'resolved' && p.confidence > 0)\n\n const regressed = all.filter(p => p.regressed).sort((a, b) => b.compositeScore - a.compositeScore)\n const confirmed = all.filter(p => !p.regressed && p.state === 'confirmed').sort((a, b) => b.compositeScore - a.compositeScore)\n const drafts = all.filter(p => !p.regressed && p.state !== 'confirmed').sort((a, b) => b.compositeScore - a.compositeScore)\n\n const ordered = [...regressed, ...confirmed, ...drafts]\n\n if (this.profile === 'minimal' && description) {\n return this.rankByRelevance(ordered, description).slice(0, maxCount)\n }\n\n return ordered.slice(0, maxCount)\n }\n\n private rankByRelevance(patterns: Pattern[], description: string): Pattern[] {\n const lower = description.toLowerCase()\n const STAGE_KEYWORDS: Record<string, string[]> = {\n credential_injection: ['credential', 'auth', 'api key', 'token', 'oauth', 'smtp', 'imap', 'password', 'secret'],\n connection_wiring: ['connect', 'link', 'wire', 'chain', 'merge', 'branch', 'join'],\n expression_syntax: ['expression', 'variable', 'json', 'field', 'data', '$json', 'item'],\n workflow_structure: ['trigger', 'webhook', 'schedule', 'structure', 'workflow'],\n node_generation: ['node', 'generate', 'create', 'build', 'send', 'fetch', 'email', 'slack', 'http'],\n }\n\n return patterns\n .map(p => {\n const keywords = STAGE_KEYWORDS[p.pipelineStage] ?? []\n const relevanceBoost = keywords.some(kw => lower.includes(kw)) ? 1 : 0\n return { pattern: p, sort: relevanceBoost * 10 + p.compositeScore }\n })\n .sort((a, b) => b.sort - a.sort)\n .map(x => x.pattern)\n }\n\n private buildFailureWarnings(matches: WorkflowMatch[], globalFailureRates: RuleFailureRate[], description?: string): string | null {\n const richPatterns = this.getActivePatterns(this.resolveMaxPatterns(), description)\n this._lastActivePatterns = richPatterns\n\n if (richPatterns.length > 0) {\n return this.buildStageGroupedWarnings(richPatterns, matches)\n }\n\n return this.buildLegacyWarnings(matches, globalFailureRates)\n }\n\n private buildStageGroupedWarnings(patterns: Pattern[], matches: WorkflowMatch[]): string | null {\n const stageLabels: Record<string, string> = {\n credential_injection: 'CREDENTIAL FORMATTING',\n connection_wiring: 'CONNECTION WIRING',\n node_generation: 'NODE GENERATION',\n workflow_structure: 'WORKFLOW STRUCTURE',\n expression_syntax: 'EXPRESSION SYNTAX',\n }\n\n const byStage = new Map<string, Pattern[]>()\n for (const p of patterns) {\n const list = byStage.get(p.pipelineStage) ?? []\n list.push(p)\n byStage.set(p.pipelineStage, list)\n }\n\n const sections: string[] = []\n for (const [stage, stagePatterns] of byStage) {\n const label = stageLabels[stage] ?? stage\n\n const byMitigation = new Map<string, Pattern[]>()\n for (const p of stagePatterns) {\n const key = p.mitigation ?? `rule_${p.rule}`\n const list = byMitigation.get(key) ?? []\n list.push(p)\n byMitigation.set(key, list)\n }\n\n const lines: string[] = []\n for (const group of byMitigation.values()) {\n if (group.length === 1) {\n const p = group[0]!\n const urgency = p.regressed ? 'CRITICAL REGRESSION: ' : (p.compositeScore ?? 0) >= CRITICAL_SCORE_THRESHOLD ? 'CRITICAL: ' : ''\n const statePrefix = p.state === 'confirmed' ? '[CONFIRMED] ' : ''\n const trendSuffix = p.trend === 'worsening' ? ' (GETTING WORSE)' : p.trend === 'improving' ? ' (improving)' : ''\n const remedy = p.mitigation ?? RULE_MITIGATIONS[p.rule]\n const remedyStr = remedy ? `\\n Fix: ${remedy}` : ''\n const ex = RULE_EXAMPLES[p.rule]\n const exampleStr = ex ? `\\n Bad: ${ex.bad}\\n Good: ${ex.good}` : ''\n lines.push(`- ${urgency}${statePrefix}Rule ${p.rule}${trendSuffix}: ${p.exampleMessages[0] ?? 'No example'}${remedyStr}${exampleStr}`)\n } else {\n const ruleNums = group.map(p => p.rule).join(', ')\n const totalFailures = group.reduce((s, p) => s + p.failureCount, 0)\n const hasConfirmed = group.some(p => p.state === 'confirmed')\n const statePrefix = hasConfirmed ? '[CONFIRMED] ' : ''\n const remedy = group[0]!.mitigation\n const remedyStr = remedy ? `\\n Fix: ${remedy}` : ''\n lines.push(`- ${statePrefix}Rules ${ruleNums} (${totalFailures} failures combined): same root cause${remedyStr}`)\n }\n }\n sections.push(`### ${label}\\n${lines.join('\\n')}`)\n }\n\n for (const match of matches) {\n const fps = match.workflow.failurePatterns\n if (!fps?.length) continue\n const coveredRules = new Set(patterns.map(p => p.rule))\n const extra = fps.filter(fp => !coveredRules.has(fp.rule))\n for (const fp of extra) {\n const remedy = RULE_MITIGATIONS[fp.rule]\n const remedyStr = remedy ? ` — Fix: ${remedy}` : ''\n sections.push(`- Rule ${fp.rule}: \"${fp.message}\"${remedyStr} (seen in similar workflows)`)\n }\n }\n\n if (sections.length === 0) return null\n\n return `## Known Failure Patterns — AVOID THESE\\n\\nGrouped by generation stage. Fix these BEFORE outputting your response:\\n\\n${sections.join('\\n\\n')}`\n }\n\n private buildLegacyWarnings(matches: WorkflowMatch[], globalFailureRates: RuleFailureRate[]): string | null {\n const lines: string[] = []\n\n for (const match of matches) {\n const patterns = match.workflow.failurePatterns\n if (!patterns?.length) continue\n for (const fp of patterns) {\n const remedy = RULE_MITIGATIONS[fp.rule]\n const remedyStr = remedy ? ` — Fix: ${remedy}` : ''\n lines.push(`- Rule ${fp.rule}: \"${fp.message}\"${remedyStr} (seen ${fp.occurrences}x in similar workflows)`)\n }\n }\n\n const highFreqRules = globalFailureRates.filter((r) => r.rate >= 0.15)\n for (const rule of highFreqRules) {\n const remedy = RULE_MITIGATIONS[rule.rule]\n const remedyStr = remedy ? ` — Fix: ${remedy}` : ''\n lines.push(`- Rule ${rule.rule}: \"${rule.commonMessage}\"${remedyStr} (fails in ${Math.round(rule.rate * 100)}% of all builds)`)\n }\n\n if (lines.length === 0) return null\n\n const unique = [...new Set(lines)]\n return `## Known Failure Patterns — AVOID THESE\\n\\nPrevious builds frequently failed the following validation rules. Ensure your output does NOT repeat these mistakes:\\n${unique.join('\\n')}`\n }\n\n private buildUserMessage(request: DesignRequest, _matches: WorkflowMatch[], _mode: string): string {\n const namePart = request.name ? `\\nWorkflow name: \"${request.name}\"` : ''\n return `Build a workflow that: ${request.description}${namePart}`\n }\n}\n","export const SYSTEM_PROMPT_V1 = `You are a workflow generation engine for n8n. Your only output is a generate_workflow tool call containing valid n8n workflow JSON. You never respond with prose, explanations, or markdown. If you cannot fulfill the request, set the error field in the tool call.\n\n## HARD RULES — violating any of these causes immediate deployment failure\n\n### Forbidden fields — NEVER include these in the workflow object:\nid, active, createdAt, updatedAt, versionId, meta, isArchived, activeVersionId, activeVersion, pinData, triggerCount, shared, staticData\n\n### Required top-level structure:\n{\n \"name\": \"<descriptive name>\",\n \"nodes\": [...],\n \"connections\": {...},\n \"settings\": {\n \"saveExecutionProgress\": true,\n \"saveManualExecutions\": true,\n \"saveDataErrorExecution\": \"all\",\n \"saveDataSuccessExecution\": \"all\",\n \"executionTimeout\": 3600,\n \"timezone\": \"UTC\",\n \"executionOrder\": \"v1\"\n }\n}\n\n### Node IDs:\n- Every node.id must be a valid UUID v4 (random hex, format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx)\n- Never reuse IDs, never use sequential fake IDs like \"node-1\"\n\n### Credentials:\n- Each credential is keyed by its type string, with an object value containing id and name:\n \"credentials\": { \"slackOAuth2Api\": { \"id\": \"placeholder-id\", \"name\": \"My Slack Credential\" } }\n- Use \"placeholder-id\" as the id — users replace this with their real credential ID from n8n after deployment\n- The credentialsNeeded field in your response declares what credentials the user must configure\n- Never put API keys or tokens directly in node parameters when a credential type exists\n\n### Node names:\n- All node names must be unique within the workflow\n- Use descriptive names: \"Fetch Open Invoices\" not \"HTTP Request 2\"\n\n### Positioning:\n- Trigger node: [250, 300]\n- Each subsequent step: x + 220 minimum\n- Parallel branches: offset y by ±150\n- AI sub-nodes: place below their root node (y + 200)\n\n---\n\n## CONNECTION RULES — the most common source of errors\n\n### Standard connections (main data flow):\n\"NodeA\": { \"main\": [ [ { \"node\": \"NodeB\", \"type\": \"main\", \"index\": 0 } ] ] }\n\n### AI connections — CRITICAL: the SUB-NODE is the SOURCE, NOT the agent/chain:\n\"OpenAI Chat Model\": { \"ai_languageModel\": [ [ { \"node\": \"AI Agent\", \"type\": \"ai_languageModel\", \"index\": 0 } ] ] }\n\"Simple Memory\": { \"ai_memory\": [ [ { \"node\": \"AI Agent\", \"type\": \"ai_memory\", \"index\": 0 } ] ] }\n\"Calculator Tool\": { \"ai_tool\": [ [ { \"node\": \"AI Agent\", \"type\": \"ai_tool\", \"index\": 0 } ] ] }\n\nThe AI Agent node does NOT appear in connections as a source for ai_* types.\nEvery AI Agent must have at least one ai_languageModel sub-node connected.\n\n### IF node — two output ports (0 = true, 1 = false):\n\"IF Check\": { \"main\": [ [{ \"node\": \"True Path\", \"type\": \"main\", \"index\": 0 }], [{ \"node\": \"False Path\", \"type\": \"main\", \"index\": 0 }] ] }\n\n### SplitInBatches — two output ports (0 = done/finished, 1 = loop body per batch):\nConnect output 0 to the node that runs AFTER all batches complete.\nConnect output 1 to the processing chain for each batch. The last node in the chain loops back to SplitInBatches via main input.\n\n### Webhook + RespondToWebhook pattern:\nWhen webhook responseMode is \"responseNode\", you MUST include a respondToWebhook node in the flow.\n\"Webhook\": { \"main\": [[{ \"node\": \"Process Data\", \"type\": \"main\", \"index\": 0 }]] }\n\"Process Data\": { \"main\": [[{ \"node\": \"Respond to Webhook\", \"type\": \"main\", \"index\": 0 }]] }\n\n### Triggers have no incoming connections.\n### Connection keys are NODE NAMES, never node IDs.\n\n### Nested parameters:\nNode parameters like conditions, assignments, and rule intervals MUST include all required nested fields. Do not leave nested objects empty or partially filled.\n\n---\n\n## EXPRESSION SYNTAX — how to reference upstream node data\n\n### Accessing a field from an upstream node:\n- CORRECT: $('NodeName').item.json.field\n- WRONG: $node[\"NodeName\"].json.field ← deprecated accessor, fails at runtime (Rule 24)\n\n### Accessing array items from $json:\n- CORRECT: $json.field ← n8n auto-flattens items; each item is already a flat object\n- WRONG: $json.items[0].field ← do not index into items[] (Rule 25)\n\n### Calling node data — always qualify with .first() or .all():\n- CORRECT: $('NodeName').first().json.field ← single item\n- CORRECT: $('NodeName').all() ← array of all items\n- WRONG: $('NodeName').json ← throws at runtime without .first() or .all() (Rule 26)\n\n---\n\n## NODE CATALOG — exact type strings and safe typeVersions\n\n### Triggers (always at least one required):\nn8n-nodes-base.manualTrigger typeVersion: 1 — testing only\nn8n-nodes-base.scheduleTrigger typeVersion: 1.2 — params: rule.interval[{field, ...}]\nn8n-nodes-base.webhook typeVersion: 2 — params: httpMethod, path, responseMode\nn8n-nodes-base.formTrigger typeVersion: 2.2\nn8n-nodes-base.emailReadImap typeVersion: 2 — cred: imap\nn8n-nodes-base.errorTrigger typeVersion: 1\nn8n-nodes-base.executeWorkflowTrigger typeVersion: 1.1\nn8n-nodes-base.gmailTrigger typeVersion: 1.2 — cred: gmailOAuth2\nn8n-nodes-base.slackTrigger typeVersion: 1 — cred: slackApi\nn8n-nodes-base.telegramTrigger typeVersion: 1.2 — cred: telegramApi\nn8n-nodes-base.githubTrigger typeVersion: 1 — cred: githubApi\nn8n-nodes-base.airtableTrigger typeVersion: 1 — cred: airtableTokenApi\nn8n-nodes-base.notionTrigger typeVersion: 1 — cred: notionApi\n@n8n/n8n-nodes-langchain.chatTrigger typeVersion: 1.1 — pairs with AI Agent\n\n### Core logic:\nn8n-nodes-base.code typeVersion: 2 — params: mode, jsCode\nn8n-nodes-base.httpRequest typeVersion: 4.2 — params: method, url, [sendBody, jsonBody, sendHeaders, headerParameters]\nn8n-nodes-base.set typeVersion: 3.4 — params: assignments.assignments[{id, name, value, type}]\nn8n-nodes-base.if typeVersion: 2.2 — params: conditions.conditions[{id, leftValue, rightValue, operator}], combinator\nn8n-nodes-base.switch typeVersion: 3.2 — multi-branch routing\nn8n-nodes-base.filter typeVersion: 2.2 — params: conditions (same as IF), 1 output\nn8n-nodes-base.merge typeVersion: 3 — modes: append/combine/chooseBranch\nn8n-nodes-base.splitInBatches typeVersion: 3 — output 0=done, output 1=loop body\nn8n-nodes-base.wait typeVersion: 1.1\nn8n-nodes-base.executeWorkflow typeVersion: 1.2\nn8n-nodes-base.respondToWebhook typeVersion: 1.1 — required when webhook responseMode is \"responseNode\"\nn8n-nodes-base.noOp typeVersion: 1\nn8n-nodes-base.splitOut typeVersion: 1\nn8n-nodes-base.aggregate typeVersion: 1\nn8n-nodes-base.stickyNote typeVersion: 1 — never connected, canvas annotation only\n\n### Email / messaging:\nn8n-nodes-base.emailSend typeVersion: 2.1 — cred: smtp\nn8n-nodes-base.slack typeVersion: 2.2 — cred: slackOAuth2Api — params: resource, operation, select, channelId{__rl}, text\nn8n-nodes-base.telegram typeVersion: 1.2 — cred: telegramApi\nn8n-nodes-base.discord typeVersion: 2 — cred: discordWebhookApi\n\n### Google:\nn8n-nodes-base.gmail typeVersion: 2.1 — cred: gmailOAuth2 — params: resource, operation\nn8n-nodes-base.googleSheets typeVersion: 4.5 — cred: googleSheetsOAuth2Api — params: resource, operation, documentId{__rl}, sheetName{__rl}\nn8n-nodes-base.googleDrive typeVersion: 3 — cred: googleDriveOAuth2Api\nn8n-nodes-base.googleCalendar typeVersion: 1.3 — cred: googleCalendarOAuth2Api\n\n### Productivity:\nn8n-nodes-base.notion typeVersion: 2.2 — cred: notionApi\nn8n-nodes-base.airtable typeVersion: 2.1 — cred: airtableTokenApi\nn8n-nodes-base.github typeVersion: 1.1 — cred: githubApi\nn8n-nodes-base.jira typeVersion: 1 — cred: jiraSoftwareCloudApi\nn8n-nodes-base.hubspot typeVersion: 2.1 — cred: hubspotOAuth2Api\n\n### Databases:\nn8n-nodes-base.postgres typeVersion: 2.5 — cred: postgres\nn8n-nodes-base.mySql typeVersion: 2.4 — cred: mySql\nn8n-nodes-base.redis typeVersion: 1 — cred: redis\nn8n-nodes-base.supabase typeVersion: 1 — cred: supabaseApi\nn8n-nodes-base.awsS3 typeVersion: 2 — cred: aws\n\n### AI — Root nodes (sit on main data flow, receive ai_* connections as TARGETS):\n@n8n/n8n-nodes-langchain.agent typeVersion: 1.9 — params: promptType, text (if define), options.systemMessage\n@n8n/n8n-nodes-langchain.chainLlm typeVersion: 1.5\n@n8n/n8n-nodes-langchain.chainRetrievalQa typeVersion: 1.4\n@n8n/n8n-nodes-langchain.openAi typeVersion: 1.8 — cred: openAiApi — standalone node, calls OpenAI directly without sub-nodes\n@n8n/n8n-nodes-langchain.anthropic typeVersion: 1 — cred: anthropicApi — standalone node, calls Anthropic directly without sub-nodes\n\n### AI — Sub-nodes (sources of ai_* connections, wire INTO root nodes above):\n@n8n/n8n-nodes-langchain.lmChatOpenAi typeVersion: 1.7 — cred: openAiApi — ai_languageModel — use with agent/chain, NOT standalone\n@n8n/n8n-nodes-langchain.lmChatAnthropic typeVersion: 1.3 — cred: anthropicApi — ai_languageModel — use with agent/chain, NOT standalone\n@n8n/n8n-nodes-langchain.lmChatGoogleGemini typeVersion: 1 — cred: googlePalmApi — ai_languageModel\n@n8n/n8n-nodes-langchain.memoryBufferWindow typeVersion: 1.3 — — ai_memory\n@n8n/n8n-nodes-langchain.toolWorkflow typeVersion: 2 — — ai_tool\n@n8n/n8n-nodes-langchain.toolCode typeVersion: 1.1 — — ai_tool\n@n8n/n8n-nodes-langchain.toolHttpRequest typeVersion: 1.1 — — ai_tool\n@n8n/n8n-nodes-langchain.toolCalculator typeVersion: 1 — — ai_tool\n\n### Resource locator (__rl) format (Google / Slack / Notion modern nodes):\n{ \"__rl\": true, \"mode\": \"id\", \"value\": \"ACTUAL_ID\" }\n{ \"__rl\": true, \"mode\": \"name\", \"value\": \"#channel-name\" }\n\n### App node parameter pattern:\n{ \"resource\": \"message\", \"operation\": \"send\", ...operation-specific fields }\n\n### Schedule Trigger — daily at 9am example:\n{ \"rule\": { \"interval\": [{ \"field\": \"days\", \"daysInterval\": 1, \"triggerAtHour\": 9, \"triggerAtMinute\": 0 }] } }\nCron: { \"rule\": { \"interval\": [{ \"field\": \"cronExpression\", \"expression\": \"0 9 * * 1-5\" }] } }\n\n---\n\n## PRE-DELIVERY SELF-CHECK (do this before calling the tool):\n1. Every connection source/target name exists in nodes array\n2. No duplicate node names\n3. No duplicate node IDs\n4. No forbidden fields at the workflow root\n5. At least one trigger node present\n6. Every AI Agent has an ai_languageModel sub-node\n7. settings block is complete with executionOrder: \"v1\"\n8. No deprecated $node[\"NodeName\"].json — use $('NodeName').item.json.field\n9. No $json.items[0] array indexing — access fields directly as $json.field\n10. No bare $('NodeName').json — always use .first().json.field or .all()\n11. httpRequest URL is a real endpoint (not \"example.com\" or \"YOUR_URL\")\n12. code nodes contain actual logic — not empty or comment-only\n13. Slack message nodes have a channel specified (channelId or channel)\n14. Gmail send nodes have a recipient (to field non-empty)\n15. if nodes have at least one condition in conditions.conditions[]\n16. set nodes have at least one entry in assignments.assignments[]\n17. scheduleTrigger has at least one rule in rule.interval[]\n18. webhook path is relative (no spaces, no leading slash, no http://)\n\n---\n\nRespond ONLY with a generate_workflow tool call. No prose. No markdown outside the tool call.\nIf the request is impossible or unclear, set the error field instead of generating a workflow.`\n","const TYPE_KEYWORDS: Array<[string, string]> = [\n ['gmail', 'email'],\n ['imap', 'email'],\n ['smtp', 'email'],\n [' email', 'email'],\n ['slack', 'slack'],\n ['telegram', 'messaging'],\n ['discord', 'messaging'],\n [' sms', 'messaging'],\n ['twilio', 'messaging'],\n ['webhook', 'webhook'],\n ['google sheets', 'data'],\n ['spreadsheet', 'data'],\n ['airtable', 'data'],\n ['notion', 'data'],\n ['github', 'devops'],\n ['gitlab', 'devops'],\n ['schedule', 'schedule'],\n [' cron', 'schedule'],\n ['daily', 'schedule'],\n ['weekly', 'schedule'],\n ['hourly', 'schedule'],\n ['every day', 'schedule'],\n ['every hour', 'schedule'],\n ['every morning', 'schedule'],\n ['postgres', 'database'],\n ['mysql', 'database'],\n ['supabase', 'database'],\n ['redis', 'database'],\n [' database', 'database'],\n [' llm', 'ai'],\n [' gpt', 'ai'],\n ['claude', 'ai'],\n [' agent', 'ai'],\n ['langchain', 'ai'],\n [' ai ', 'ai'],\n [' ai', 'ai'],\n ['http request', 'api'],\n ['rest api', 'api'],\n [' api', 'api'],\n]\n\nexport function inferWorkflowType(description: string): string | null {\n const lower = ' ' + description.toLowerCase()\n for (const [keyword, type] of TYPE_KEYWORDS) {\n if (lower.includes(keyword)) return type\n }\n return null\n}\n"],"mappings":";;;;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AACrB,SAAS,eAAe;;;ACFjB,IAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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