{
  "name": "Glasswarp — observe a Windows PC",
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "HTTP Request smoke: list a usable rig, start a desktop session, observe text+targets (no JPEG), end the session. Not a Glasswarp community node."
  },
  "nodes": [
    {
      "parameters": {
        "content": "## Glasswarp (HTTP Request)\n\n1. Create a **Header Auth** credential named **Glasswarp API**:\n   - Name: `Authorization`\n   - Value: `Bearer gw_live_sk_...` (include the word Bearer)\n2. Attach that credential to every HTTP Request node.\n3. Host installed, paired, **API access on**, PC online.\n4. Test workflow, then **Console → Sessions → Eye** while it runs.\n\nThis workflow does **not** click. It always ends the session. n8n stays the brain; Glasswarp is eyes and hands.",
        "height": 340,
        "width": 380,
        "color": 5
      },
      "id": "sticky-intro",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-420, -80]
    },
    {
      "parameters": {},
      "id": "manual-trigger",
      "name": "Manual trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://signal.glasswarp.com/v1/rigs",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 30000
        }
      },
      "id": "http-list-rigs",
      "name": "List rigs",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 0],
      "credentials": {
        "httpHeaderAuth": {
          "id": "GLASSWARP_HEADER_AUTH",
          "name": "Glasswarp API"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const rigs = $input.first().json.rigs || [];\nconst rig = rigs.find((r) => r.online === true && r.api_access_enabled === true);\nif (!rig) {\n  throw new Error(\n    'No online PC with API access enabled. Pair the host, flip API access in Console → PCs, and keep the tray agent running.',\n  );\n}\nreturn [{ json: { rig_id: rig.id, name: rig.name || rig.id } }];"
      },
      "id": "code-pick-rig",
      "name": "Pick a usable PC",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [440, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://signal.glasswarp.com/v1/sessions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ rig_id: $json.rig_id, mode: 'desktop', idle_timeout_seconds: 180 }) }}",
        "options": {
          "timeout": 60000
        }
      },
      "id": "http-start-session",
      "name": "Start session",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [660, 0],
      "credentials": {
        "httpHeaderAuth": {
          "id": "GLASSWARP_HEADER_AUTH",
          "name": "Glasswarp API"
        }
      }
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://signal.glasswarp.com/v1/sessions/{{ $json.session_id }}/observe?image=0",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 60000
        }
      },
      "id": "http-observe",
      "name": "Observe (text + targets)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [880, 0],
      "onError": "continueRegularOutput",
      "credentials": {
        "httpHeaderAuth": {
          "id": "GLASSWARP_HEADER_AUTH",
          "name": "Glasswarp API"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const start = $('Start session').first().json;\nconst obs = $input.first().json;\nconst targets = Array.isArray(obs.targets) ? obs.targets : [];\nreturn [{\n  json: {\n    session_id: start.session_id,\n    rig_id: start.rig_id,\n    window: obs.text && obs.text.window_title ? obs.text.window_title : '',\n    summary: obs.text && obs.text.summary ? obs.text.summary : '',\n    target_count: targets.length,\n    targets: targets.slice(0, 12).map((t) => ({\n      id: t.id,\n      name: t.name || '',\n      role: t.role || '',\n    })),\n    observe_error: obs.error || obs.message || null,\n  },\n}];"
      },
      "id": "code-summarize",
      "name": "Summarize observe",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1100, 0],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "DELETE",
        "url": "=https://signal.glasswarp.com/v1/sessions/{{ $('Start session').item.json.session_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 30000
        }
      },
      "id": "http-end-session",
      "name": "End session",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1320, 0],
      "credentials": {
        "httpHeaderAuth": {
          "id": "GLASSWARP_HEADER_AUTH",
          "name": "Glasswarp API"
        }
      }
    }
  ],
  "connections": {
    "Manual trigger": {
      "main": [[{ "node": "List rigs", "type": "main", "index": 0 }]]
    },
    "List rigs": {
      "main": [[{ "node": "Pick a usable PC", "type": "main", "index": 0 }]]
    },
    "Pick a usable PC": {
      "main": [[{ "node": "Start session", "type": "main", "index": 0 }]]
    },
    "Start session": {
      "main": [[{ "node": "Observe (text + targets)", "type": "main", "index": 0 }]]
    },
    "Observe (text + targets)": {
      "main": [[{ "node": "Summarize observe", "type": "main", "index": 0 }]]
    },
    "Summarize observe": {
      "main": [[{ "node": "End session", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "pinData": {},
  "tags": []
}
