{ "id": "KanydpqJrpsAGDCMqkpgD", "name": "Outline Daily Notes", "nodes": [ { "parameters": { "rule": { "interval": [ { "triggerAtHour": 4 } ] } }, "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.3, "position": [ 0, 0 ], "id": "5d2e1844-e4ba-4e6a-92fa-86c3ded88897", "name": "Schedule Trigger" }, { "parameters": { "authentication": "privateKey", "command": "/home/b3nw/projects/personal/daily-ideas/run-daily.sh", "cwd": "/home/b3nw/projects/personal/daily-ideas" }, "type": "n8n-nodes-base.ssh", "typeVersion": 1, "position": [ 208, 0 ], "id": "6cb707c1-1ee5-409b-84cb-3ed810136c70", "name": "Execute a command", "credentials": { "sshPrivateKey": { "id": "S2dcVMjrpg0I0kdV", "name": "vscode-dev.local.ben.io" } } }, { "parameters": { "language": "pythonNative", "pythonCode": "import json\nimport re\n\n# Get stdout from Execute Command node\nstdout_content = _items[0][\"json\"].get(\"stdout\", \"\")\n\n# Parse NDJSON\nlines = stdout_content.strip().split(\"\\n\")\n\n# Collect all events by type\nresult = {\n \"session_id\": None,\n \"status\": \"unknown\",\n \"created_document\": None,\n \"tool_calls\": [],\n \"text_responses\": [],\n \"steps\": [],\n \"total_cost\": 0.0,\n \"total_tokens\": {\n \"input\": 0,\n \"output\": 0,\n \"reasoning\": 0\n }\n}\n\nfor line in lines:\n try:\n event = json.loads(line)\n event_type = event.get(\"type\")\n \n # Capture session ID\n if not result[\"session_id\"]:\n result[\"session_id\"] = event.get(\"sessionID\")\n \n part = event.get(\"part\", {})\n \n if event_type == \"text\":\n result[\"text_responses\"].append({\n \"id\": part.get(\"id\"),\n \"text\": part.get(\"text\", \"\"),\n \"timestamp\": event.get(\"timestamp\")\n })\n \n elif event_type == \"tool_use\":\n tool_name = part.get(\"tool\", \"\")\n state = part.get(\"state\", {})\n \n tool_call = {\n \"tool\": tool_name,\n \"call_id\": part.get(\"callID\"),\n \"status\": state.get(\"status\"),\n \"input\": state.get(\"input\"),\n \"timestamp\": event.get(\"timestamp\")\n }\n \n # Parse output if completed\n if state.get(\"status\") == \"completed\":\n output_str = state.get(\"output\", \"{}\")\n try:\n tool_call[\"output\"] = json.loads(output_str)\n except:\n tool_call[\"output\"] = output_str\n \n result[\"tool_calls\"].append(tool_call)\n \n # Check for document creation\n if \"create_document\" in tool_name and state.get(\"status\") == \"completed\":\n try:\n output_data = json.loads(state.get(\"output\", \"{}\"))\n if \"data\" in output_data and \"id\" in output_data[\"data\"]:\n result[\"created_document\"] = output_data[\"data\"]\n result[\"status\"] = \"document_created\"\n except:\n pass\n \n elif event_type == \"step_finish\":\n step_info = {\n \"id\": part.get(\"id\"),\n \"reason\": part.get(\"reason\"),\n \"cost\": part.get(\"cost\", 0),\n \"tokens\": part.get(\"tokens\", {}),\n \"timestamp\": event.get(\"timestamp\")\n }\n result[\"steps\"].append(step_info)\n \n # Accumulate costs and tokens\n result[\"total_cost\"] += part.get(\"cost\", 0)\n tokens = part.get(\"tokens\", {})\n result[\"total_tokens\"][\"input\"] += tokens.get(\"input\", 0)\n result[\"total_tokens\"][\"output\"] += tokens.get(\"output\", 0)\n result[\"total_tokens\"][\"reasoning\"] += tokens.get(\"reasoning\", 0)\n \n except json.JSONDecodeError:\n continue\n\n# Determine final status\nif result[\"created_document\"]:\n result[\"status\"] = \"document_created\"\nelif result[\"tool_calls\"]:\n # Check if any tool calls failed\n failed = [t for t in result[\"tool_calls\"] if t.get(\"status\") != \"completed\"]\n if failed:\n result[\"status\"] = \"tool_error\"\n else:\n result[\"status\"] = \"tools_completed\"\nelif result[\"text_responses\"]:\n result[\"status\"] = \"text_response\"\n\n# Combine all text for summary\nresult[\"full_text\"] = \"\\n\\n\".join([t[\"text\"] for t in result[\"text_responses\"]])\n\nreturn result" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 416, 0 ], "id": "74be33c5-e738-4b83-9bd6-9ae19186f86a", "name": "Code in Python (Native)" } ], "connections": { "Schedule Trigger": { "main": [ [ { "node": "Execute a command", "type": "main", "index": 0 } ] ] }, "Execute a command": { "main": [ [ { "node": "Code in Python (Native)", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1", "availableInMCP": false }, "triggerCount": 1, "versionId": "4a28d8c0-0420-4555-8019-4b972d63cdac", "owner": { "type": "personal", "projectId": "FeLO36wNUAcn61Wj", "projectName": "Ben W ", "personalEmail": "admin@ben.io" }, "parentFolderId": "OJ2UfPNUOAOHlllh", "isArchived": false }