{
  "name": "Agent Builder",
  "nodes": [
    {
      "parameters": {
        "workflowId": "agent-swarm-main"
      },
      "id": "workflow-trigger",
      "name": "Workflow Trigger",
      "type": "n8n-nodes-base.workflowTrigger",
      "typeVersion": 1.1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Extract task information from parent workflow\nconst input = $input.item.json;\n\n// Get task from current_subtask if exists, otherwise use input directly\nconst subtask = input.current_subtask || input;\n\nreturn {\n  json: {\n    task: subtask.subtask || subtask.task || '',\n    description: subtask.description || '',\n    context: input.context || {},\n    priority: subtask.priority || 1\n  }\n};"
      },
      "id": "prepare-task",
      "name": "Prepare Task",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "url": "=https://api.openai.com/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"gpt-4o\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"Du bist der BUILDER im Agent-Swarm-System.\\n\\nROLLE:\\nTechnische und inhaltliche Umsetzung von Vorgaben.\\n\\nAUFGABEN:\\n- Schreibe Code, Skripte und Workflows\\n- Erstelle Prompts und Konfigurationen\\n- Setze exakt das um, was der Orchestrator vorgibt\\n- Liefert reproduzierbare, funktionsf\u00e4hige Ergebnisse\\n\\nREGELN:\\n- Denke nicht strategisch (das macht der Orchestrator)\\n- Setze exakt um, was beauftragt wurde\\n- Mache keine konzeptionellen Entscheidungen\\n- Wenn etwas unklar ist, mache eine begr\u00fcndete Annahme und kennzeichne sie\\n\\nOUTPUT:\\n- Vollst\u00e4ndiger, ausf\u00fchrbarer Code\\n- Erkl\u00e4rende Kommentare wo n\u00f6tig\\n- Liste ben\u00f6tigter Abh\u00e4ngigkeiten\\n- Kurze Anleitung zur Nutzung\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"=Task: {{ $json.task }}\\nBeschreibung: {{ $json.description }}\\nKontext: {{ JSON.stringify($json.context) }}\"\n    }\n  ],\n  \"temperature\": 0.2\n}",
        "options": {}
      },
      "id": "builder-llm",
      "name": "Builder LLM",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        650,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Extract and format builder output\nconst response = $input.item.json;\nlet output;\n\ntry {\n  if (response.choices && response.choices[0]) {\n    output = response.choices[0].message.content;\n  } else if (response.content) {\n    output = typeof response.content === 'string' ? response.content : JSON.stringify(response.content);\n  } else {\n    output = JSON.stringify(response);\n  }\n} catch (e) {\n  output = `Error parsing response: ${e.message}`;\n}\n\nreturn {\n  json: {\n    output: output,\n    status: 'completed',\n    agent: 'builder',\n    timestamp: new Date().toISOString()\n  }\n};"
      },
      "id": "format-output",
      "name": "Format Output",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Workflow Trigger": {
      "main": [
        [
          {
            "node": "Prepare Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Task": {
      "main": [
        [
          {
            "node": "Builder LLM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Builder LLM": {
      "main": [
        [
          {
            "node": "Format Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "updatedAt": "2025-12-19T12:00:00.000Z",
  "versionId": "1"
}