From 3dc5d236a2acdb19ec71366ed2017694c0dccfdc Mon Sep 17 00:00:00 2001 From: Christopher Mayor Date: Fri, 20 Feb 2026 17:18:33 -0800 Subject: [PATCH] feat: expand discovery with systemd services, LXC/VMs, SSH terminal, and filebrowser - Add systemd service discovery to backend - Add Proxmox LXC/VM detection - Add hostType field to config for better host categorization - Fix SSH trust between hosts (ubuntu/grizzley -> truenas/proxmox) - Add SSH terminal support via xterm.js - Add filebrowser for browsing host filesystems - Update frontend types and components for new node types --- AGENTS.md | 86 +++ package-lock.json | 899 ++++++++++++++++++++++++- package.json | 2 + server/AGENTS.md | 60 ++ server/hosts.json | 56 ++ server/index.ts | 20 + server/routes/discover.ts | 169 +++++ server/routes/files.ts | 265 ++++++++ server/routes/terminal.ts | 60 ++ server/types.ts | 4 + src/AGENTS.md | 67 ++ src/App.tsx | 147 +++- src/components/AGENTS.md | 42 ++ src/components/CommandPalette.tsx | 359 ++++++++++ src/components/FileBrowser.tsx | 146 ++++ src/components/Graph/TopologyGraph.tsx | 71 +- src/components/LeftPanel.tsx | 6 + src/components/RightPanel.tsx | 46 +- src/components/TerminalPanel.tsx | 127 ++++ src/services/discovery.ts | 48 ++ src/store/topologyStore.ts | 62 +- src/types/index.ts | 5 + src/utils/colors.ts | 3 + 23 files changed, 2680 insertions(+), 70 deletions(-) create mode 100644 AGENTS.md create mode 100644 server/AGENTS.md create mode 100644 server/hosts.json create mode 100644 server/routes/discover.ts create mode 100644 server/routes/files.ts create mode 100644 server/routes/terminal.ts create mode 100644 src/AGENTS.md create mode 100644 src/components/AGENTS.md create mode 100644 src/components/CommandPalette.tsx create mode 100644 src/components/FileBrowser.tsx create mode 100644 src/components/TerminalPanel.tsx diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..fd9f4d1 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,86 @@ +# PROJECT KNOWLEDGE BASE + +**Generated:** 2026-02-19 +**Commit:** a4cff98 +**Branch:** (current) + +## OVERVIEW + +Homelab topology visualizer - React + Express full-stack app displaying infrastructure as interactive graph (network → hosts → containers → volumes). + +## STRUCTURE + +``` +./ +├── server/ # Express API backend +│ └── routes/ # API endpoints (discover, config, stats, files) +├── src/ # React frontend +│ ├── components/ # UI components (Header, LeftPanel, RightPanel, Graph) +│ ├── services/ # Discovery logic +│ ├── store/ # Zustand state +│ ├── types/ # TypeScript definitions +│ └── utils/ # Utilities +├── docker/ # Nginx + Dockerfile +├── dist/ # Built frontend (committed - non-standard) +└── index.html # Frontend entry +``` + +## WHERE TO LOOK + +| Task | Location | Notes | +|------|----------|-------| +| Add API endpoint | server/routes/*.ts | Modular route files | +| Add UI component | src/components/*.tsx | React components | +| State management | src/store/topologyStore.ts | Zustand store | +| Discovery logic | src/services/discovery.ts | Data transformation | +| SSH discovery | src/services/sshDiscovery.ts | SSH connectivity | + +## CODE MAP + +| Symbol | Type | Location | Role | +|--------|------|----------|------| +| App | component | src/App.tsx | Main orchestrator | +| TopologyGraph | component | src/components/Graph/TopologyGraph.tsx | Graph rendering | +| useTopologyStore | hook | src/store/topologyStore.ts | Global state | +| discoverRouter | router | server/routes/discover.ts | /api/discover | + +## CONVENTIONS (THIS PROJECT) + +- **TypeScript**: Strict mode enabled, ESNext modules +- **Path alias**: `@/*` maps to `src/*` +- **Frontend**: React 18 + Vite + Tailwind CSS + Zustand +- **Backend**: Express 5 + TypeScript (tsx runtime) +- **Graph**: @xyflow/react (React Flow) + dagre layout +- **Build**: `tsc -b && vite build` +- **Lint**: `eslint .` (flat config) +- **Run dev**: `npm run dev` (frontend), `npm run server` (backend) + +## ANTI-PATTERNS (THIS PROJECT) + +- **DO NOT commit dist/**: Build artifacts in `dist/` are committed - should be in .gitignore +- **DO NOT skip tsc**: Build script runs `tsc -b` before vite - don't remove +- **DO NOT use localStorage for SSH credentials**: Security risk (documented in .sisyphus/plans) + +## UNIQUE STYLES + +- Dual runtime: frontend (Vite) + backend (tsx server/index.ts) +- Fallback to simulated data if API unavailable +- Polling-based live updates (configurable interval) +- Graph auto-layout with dagre + +## COMMANDS + +```bash +npm run dev # Frontend dev server (localhost:3000) +npm run server # Backend API server (localhost:3001) +npm run build # TypeScript + Vite build +npm run lint # ESLint check +npm run discover # Run SSH discovery standalone +``` + +## NOTES + +- Frontend expects API at `http://localhost:3001` (configurable via VITE_API_URL) +- API routes mounted under `/api/*` +- CORS configured for `http://localhost:3000` only +- SSH discovery uses ssh2 library - requires network access to hosts diff --git a/package-lock.json b/package-lock.json index fa6edbc..898ece7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,9 +8,15 @@ "name": "homelab-topology", "version": "1.0.0", "dependencies": { + "@types/cors": "^2.8.19", "@types/dagre": "^0.7.53", + "@types/express": "^5.0.6", + "@xterm/addon-fit": "^0.11.0", + "@xterm/xterm": "^6.0.0", "@xyflow/react": "^12.4.4", + "cors": "^2.8.6", "dagre": "^0.8.5", + "express": "^5.2.1", "lucide-react": "^0.468.0", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -1482,6 +1488,34 @@ "@babel/types": "^7.28.2" } }, + "node_modules/@types/body-parser": { + "version": "1.19.6", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz", + "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", + "license": "MIT", + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/cors": { + "version": "2.8.19", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz", + "integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/d3-array": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz", @@ -1592,6 +1626,35 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/express": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz", + "integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==", + "license": "MIT", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^5.0.0", + "@types/serve-static": "^2" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.1.1.tgz", + "integrity": "sha512-v4zIMr/cX7/d2BpAEX3KNKL/JrT1s43s96lLvvdTmza1oEvDudCqK9aF/djc/SWgy8Yh0h30TZx5VpzqFCxk5A==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "node_modules/@types/http-errors": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", + "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -1603,7 +1666,6 @@ "version": "22.19.11", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.11.tgz", "integrity": "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w==", - "dev": true, "license": "MIT", "dependencies": { "undici-types": "~6.21.0" @@ -1616,6 +1678,18 @@ "devOptional": true, "license": "MIT" }, + "node_modules/@types/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==", + "license": "MIT" + }, + "node_modules/@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "license": "MIT" + }, "node_modules/@types/react": { "version": "18.3.28", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.28.tgz", @@ -1637,6 +1711,25 @@ "@types/react": "^18.0.0" } }, + "node_modules/@types/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", + "integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==", + "license": "MIT", + "dependencies": { + "@types/http-errors": "*", + "@types/node": "*" + } + }, "node_modules/@types/ssh2": { "version": "1.15.5", "resolved": "https://registry.npmjs.org/@types/ssh2/-/ssh2-1.15.5.tgz", @@ -1967,6 +2060,21 @@ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, + "node_modules/@xterm/addon-fit": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@xterm/addon-fit/-/addon-fit-0.11.0.tgz", + "integrity": "sha512-jYcgT6xtVYhnhgxh3QgYDnnNMYTcf8ElbxxFzX0IZo+vabQqSPAjC3c1wJrKB5E19VwQei89QCiZZP86DCPF7g==", + "license": "MIT" + }, + "node_modules/@xterm/xterm": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-6.0.0.tgz", + "integrity": "sha512-TQwDdQGtwwDt+2cgKDLn0IRaSxYu1tSUjgKarSDkUM0ZNiSRXFpjxEsvc/Zgc5kq5omJ+V0a8/kIM2WD3sMOYg==", + "license": "MIT", + "workspaces": [ + "addons/*" + ] + }, "node_modules/@xyflow/react": { "version": "12.10.0", "resolved": "https://registry.npmjs.org/@xyflow/react/-/react-12.10.0.tgz", @@ -2027,6 +2135,19 @@ "d3-zoom": "^3.0.0" } }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/acorn": { "version": "8.15.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", @@ -2185,6 +2306,30 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/body-parser": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", + "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.1", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/brace-expansion": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", @@ -2243,6 +2388,44 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2391,6 +2574,28 @@ "dev": true, "license": "MIT" }, + "node_modules/content-disposition": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", + "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -2398,6 +2603,41 @@ "dev": true, "license": "MIT" }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2633,7 +2873,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -2660,6 +2899,15 @@ "dev": true, "license": "MIT" }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/didyoumean": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", @@ -2684,6 +2932,26 @@ "csstype": "^3.0.2" } }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, "node_modules/electron-to-chromium": { "version": "1.5.286", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.286.tgz", @@ -2691,6 +2959,45 @@ "dev": true, "license": "ISC" }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { "version": "0.25.12", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", @@ -2743,6 +3050,12 @@ "node": ">=6" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -2933,12 +3246,64 @@ "node": ">=0.10.0" } }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", "license": "MIT" }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -3035,6 +3400,27 @@ "node": ">=8" } }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -3073,6 +3459,15 @@ "dev": true, "license": "ISC" }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/fraction.js": { "version": "5.3.4", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-5.3.4.tgz", @@ -3087,6 +3482,15 @@ "url": "https://github.com/sponsors/rawify" } }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -3106,7 +3510,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3122,6 +3525,43 @@ "node": ">=6.9.0" } }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/get-tsconfig": { "version": "4.13.6", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.6.tgz", @@ -3161,6 +3601,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/graphlib": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/graphlib/-/graphlib-2.1.8.tgz", @@ -3180,11 +3632,22 @@ "node": ">=8" } }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -3193,6 +3656,42 @@ "node": ">= 0.4" } }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", + "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -3230,6 +3729,12 @@ "node": ">=0.8.19" } }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, "node_modules/internmap": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", @@ -3239,6 +3744,15 @@ "node": ">=12" } }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -3301,6 +3815,12 @@ "node": ">=0.12.0" } }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -3488,6 +4008,36 @@ "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc" } }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -3512,6 +4062,31 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3529,7 +4104,6 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/mz": { @@ -3570,6 +4144,15 @@ "dev": true, "license": "MIT" }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/node-releases": { "version": "2.0.27", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", @@ -3606,6 +4189,39 @@ "node": ">= 6" } }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -3669,6 +4285,15 @@ "node": ">=6" } }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -3696,6 +4321,16 @@ "dev": true, "license": "MIT" }, + "node_modules/path-to-regexp": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -3926,6 +4561,19 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", "license": "MIT" }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -3936,6 +4584,21 @@ "node": ">=6" } }, + "node_modules/qs": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.0.tgz", + "integrity": "sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -3957,6 +4620,30 @@ ], "license": "MIT" }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/react": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", @@ -4181,6 +4868,22 @@ "fsevents": "~2.3.2" } }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -4205,6 +4908,12 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, "node_modules/scheduler": { "version": "0.23.2", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", @@ -4224,6 +4933,57 @@ "semver": "bin/semver.js" } }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -4247,6 +5007,78 @@ "node": ">=8" } }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -4257,6 +5089,15 @@ "node": ">=0.10.0" } }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -4447,6 +5288,15 @@ "node": ">=8.0" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/ts-api-utils": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.4.0.tgz", @@ -4984,6 +5834,20 @@ "node": ">= 0.8.0" } }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/typescript": { "version": "5.6.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", @@ -5026,9 +5890,17 @@ "version": "6.21.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "dev": true, "license": "MIT" }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/update-browserslist-db": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", @@ -5086,6 +5958,15 @@ "dev": true, "license": "MIT" }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/victory-vendor": { "version": "36.9.2", "resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-36.9.2.tgz", @@ -5240,6 +6121,12 @@ "node": ">=0.10.0" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/package.json b/package.json index e202778..20c0163 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,8 @@ "@types/cors": "^2.8.19", "@types/dagre": "^0.7.53", "@types/express": "^5.0.6", + "@xterm/addon-fit": "^0.11.0", + "@xterm/xterm": "^6.0.0", "@xyflow/react": "^12.4.4", "cors": "^2.8.6", "dagre": "^0.8.5", diff --git a/server/AGENTS.md b/server/AGENTS.md new file mode 100644 index 0000000..9157644 --- /dev/null +++ b/server/AGENTS.md @@ -0,0 +1,60 @@ +# Server (Express API Backend) + +**Generated:** 2026-02-19 +**Location:** server/ + +## OVERVIEW + +Express 5 + TypeScript backend serving REST API endpoints for homelab topology discovery. + +## STRUCTURE + +``` +server/ +├── index.ts # Express app entry, CORS, route mounting +├── config.ts # Server configuration +├── types.ts # Shared TypeScript types +├── config.json # Runtime config (contains hosts, credentials) +├── config.example.json +└── routes/ # API endpoints + ├── discover.ts # POST /api/discover - SSH discovery + ├── config.ts # GET/PUT /api/config + ├── stats.ts # GET /api/stats + └── files.ts # GET /api/files +``` + +## WHERE TO LOOK + +| Task | File | Notes | +|------|------|-------| +| Add new endpoint | server/routes/{name}.ts | Create router, import in index.ts | +| Modify CORS | server/index.ts | CORS middleware (line 12-15) | +| Change port | server/index.ts | PORT const (line 9) | + +## CONVENTIONS + +- **Route files**: Export default router, mount in index.ts via `app.use('/api', router)` +- **Error handling**: Return JSON `{ error: string }` on failure +- **Config**: Use server/config.ts for shared config, not hardcode +- **Credentials**: Never log or expose SSH credentials in responses + +## ANTI-PATTERNS + +- **NEVER expose SSH credentials in API responses** +- **DO NOT store credentials in source** - use server/config.json + +## API ENDPOINTS + +| Method | Path | Purpose | +|--------|------|---------| +| POST | /api/discover | Run SSH discovery on hosts | +| GET | /api/config | Get configuration | +| PUT | /api/config | Update configuration | +| GET | /api/stats | Get statistics | +| GET | /api/files | Get file topology | + +## NOTES + +- Server runs on port 3001 +- CORS allows only `http://localhost:3000` +- Health check: GET /api/health diff --git a/server/hosts.json b/server/hosts.json new file mode 100644 index 0000000..a0be71d --- /dev/null +++ b/server/hosts.json @@ -0,0 +1,56 @@ +{ + "hosts": [ + { + "name": "ubuntu", + "ip": "192.168.50.61", + "sshUser": "bear", + "sshKeyPath": "~/.ssh/id_ed25519", + "sshPort": 22, + "hostType": "docker-host" + }, + { + "name": "grizzley", + "ip": "192.168.50.84", + "sshUser": "bear", + "sshKeyPath": "~/.ssh/id_ed25519", + "sshPort": 22, + "hostType": "docker-host" + }, + { + "name": "truenas", + "ip": "192.168.50.12", + "sshUser": "root", + "sshKeyPath": "~/.ssh/id_ed25519", + "sshPort": 22, + "hostType": "truenas" + }, + { + "name": "proxmox", + "ip": "192.168.50.11", + "sshUser": "root", + "sshKeyPath": "~/.ssh/id_ed25519", + "sshPort": 22, + "hostType": "proxmox" + }, + { + "name": "ice", + "ip": "192.168.50.197", + "sshUser": "bear", + "sshKeyPath": "~/.ssh/id_ed25519", + "sshPort": 22, + "hostType": "docker-host" + }, + { + "name": "panda", + "ip": "192.168.50.196", + "sshUser": "bear", + "sshKeyPath": "~/.ssh/id_ed25519", + "sshPort": 22, + "hostType": "docker-host" + } + ] +} + ] +} + ] +} diff --git a/server/index.ts b/server/index.ts index 75b9dfb..b99b42d 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,5 +1,11 @@ import express from 'express'; import cors from 'cors'; +import discoverRouter from './routes/discover'; +import configRouter from './routes/config'; +import statsRouter from './routes/stats'; +import filesRouter from './routes/files'; +import terminalRouter from './routes/terminal'; +import { getHostConfigs } from './config'; const app = express(); const PORT = 3001; @@ -10,11 +16,25 @@ app.use(cors({ credentials: true, })); +app.use(express.json()); + // Health check endpoint app.get('/api/health', (req, res) => { res.json({ status: 'ok' }); }); +// Debug endpoint to check config +app.get('/api/debug-config', (req, res) => { + const hosts = getHostConfigs(); + res.json({ hosts }); +}); + +app.use('/api', discoverRouter); +app.use('/api', configRouter); +app.use('/api', statsRouter); +app.use('/api', filesRouter); +app.use('/api', terminalRouter); + app.listen(PORT, () => { console.log(`Server running on http://localhost:${PORT}`); }); diff --git a/server/routes/discover.ts b/server/routes/discover.ts new file mode 100644 index 0000000..92b8b87 --- /dev/null +++ b/server/routes/discover.ts @@ -0,0 +1,169 @@ +/** + * SSH Discovery API Endpoint + * + * POST /api/discover - Discover all hosts via SSH and return their status + */ + +import { Router } from 'express'; +import { execSync } from 'child_process'; +import { homedir } from 'os'; +import { getHostConfigs } from '../config'; +import { DiscoveryResponse } from '../types'; + +const router = Router(); + +interface HostDiscoveryResult { + name: string; + ip: string; + online: boolean; + containers?: string[]; + services?: string[]; + vms?: Array<{ id: string; name: string; status: string; type: 'lxc' | 'qemu' }>; + error?: string; +} + +async function discoverHost( + name: string, + ip: string, + sshUser: string, + sshKeyPath?: string, + sshPort?: number, + hostType?: string +): Promise { + try { + const keyPath = (sshKeyPath || `${homedir()}/.ssh/id_ed25519`).replace(/^~/, homedir()); + console.error(`DEBUG: ${name} keyPath=${keyPath}, user=${sshUser}`); + const keyArg = `-i ${keyPath}`; + const portArg = sshPort && sshPort !== 22 ? `-p ${sshPort}` : ''; + + const dockerCmd = `ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no ${keyArg} ${portArg} ${sshUser}@${ip} "docker ps --format '{{.Names}}'" 2>/dev/null`; + const dockerOutput = execSync(dockerCmd, { encoding: 'utf-8', timeout: 15000 }); + const containers = dockerOutput.trim().split('\n').filter(c => c.trim()); + + let services: string[] = []; + if (hostType !== 'proxmox') { + try { + const systemdCmd = `ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no ${keyArg} ${portArg} ${sshUser}@${ip} "systemctl list-units --type=service --state=running --no-pager --no-legend --quiet | awk '{print \\$1}'" 2>/dev/null`; + const systemdOutput = execSync(systemdCmd, { encoding: 'utf-8', timeout: 10000 }); + services = systemdOutput.trim().split('\n').filter(s => s.trim()); + } catch { + console.error(`DEBUG: ${name} systemd discovery failed`); + } + } + + let vms: Array<{ id: string; name: string; status: string; type: 'lxc' | 'qemu' }> = []; + if (hostType === 'proxmox' || name === 'proxmox') { + try { + const lxcCmd = `ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no ${keyArg} ${portArg} ${sshUser}@${ip} "pct list" 2>/dev/null`; + const lxcOutput = execSync(lxcCmd, { encoding: 'utf-8', timeout: 10000 }); + const lxcLines = lxcOutput.trim().split('\n').slice(1); + for (const line of lxcLines) { + const parts = line.trim().split(/\s+/); + if (parts.length >= 2) { + vms.push({ id: parts[0], name: parts[1], status: parts[2] || 'unknown', type: 'lxc' }); + } + } + + const vmCmd = `ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no ${keyArg} ${portArg} ${sshUser}@${ip} "qm list" 2>/dev/null`; + const vmOutput = execSync(vmCmd, { encoding: 'utf-8', timeout: 10000 }); + const vmLines = vmOutput.trim().split('\n').slice(1); + for (const line of vmLines) { + const parts = line.trim().split(/\s+/); + if (parts.length >= 2) { + vms.push({ id: parts[0], name: parts[1], status: parts[2] || 'unknown', type: 'qemu' }); + } + } + } catch { + console.error(`DEBUG: ${name} Proxmox discovery failed`); + } + } + + return { + name, + ip, + online: true, + containers, + services: services.length > 0 ? services : undefined, + vms: vms.length > 0 ? vms : undefined, + }; + } catch (error: any) { + return { + name, + ip, + online: false, + containers: [], + error: error.message || 'Discovery failed', + }; + } +} + +// POST /api/discover - Discover all hosts via SSH +router.post('/discover', async (req, res) => { + try { + const hosts = getHostConfigs(); + + if (hosts.length === 0) { + const response: DiscoveryResponse = { + hosts: [], + timestamp: new Date().toISOString(), + errors: ['No hosts configured'], + }; + return res.json(response); + } + + const results: HostDiscoveryResult[] = []; + for (const host of hosts) { + try { + const keyPath = host.sshKeyPath?.replace(/^~/, homedir()); + const result = await discoverHost( + host.name, + host.ip, + host.sshUser, + keyPath, + host.sshPort, + host.hostType + ); + results.push(result); + } catch (error: any) { + results.push({ + name: host.name, + ip: host.ip, + online: false, + containers: [], + error: error.message || 'Discovery failed' + }); + } + } + + const errors: string[] = []; + results.forEach((result: HostDiscoveryResult) => { + if (!result.online && result.error) { + errors.push(`${result.name}: ${result.error}`); + } + }); + + const response: DiscoveryResponse = { + hosts: results.map(r => ({ + name: r.name, + ip: r.ip, + online: r.online, + containers: r.containers, + services: r.services, + vms: r.vms, + })), + timestamp: new Date().toISOString(), + errors, + }; + + res.json(response); + } catch (error: any) { + const response: DiscoveryResponse = { + hosts: [], + timestamp: new Date().toISOString(), + errors: [error.message || 'Discovery failed'], + }; + res.status(500).json(response); + } +}); + +export default router; diff --git a/server/routes/files.ts b/server/routes/files.ts new file mode 100644 index 0000000..276109d --- /dev/null +++ b/server/routes/files.ts @@ -0,0 +1,265 @@ +/** + * Files API Endpoint + * + * GET /api/files/:host/:container - Get volume mounts for a container + */ + +import { Router } from 'express'; +import { Client } from 'ssh2'; +import { readFileSync } from 'fs'; +import { homedir } from 'os'; +import { getHostConfigs } from '../config'; + +const router = Router(); + +interface SSHConnectionConfig { + host: string; + port?: number; + username: string; + privateKey?: Buffer; +} + +interface VolumeMount { + source: string; + destination: string; + mode: string; +} + +interface FilesResponse { + volumes: VolumeMount[]; + error?: string; +} + +async function connectSSH(config: SSHConnectionConfig, timeout: number = 30000): Promise { + return new Promise((resolve, reject) => { + const conn = new Client(); + + const timeoutId = setTimeout(() => { + conn.end(); + reject(new Error('Connection timeout')); + }, timeout); + + conn.on('ready', () => { + clearTimeout(timeoutId); + resolve(conn); + }); + + conn.on('error', (err) => { + clearTimeout(timeoutId); + reject(err); + }); + + conn.connect({ + host: config.host, + port: config.port || 22, + username: config.username, + privateKey: config.privateKey, + readyTimeout: timeout, + }); + }); +} + +async function execSSH(conn: Client, command: string): Promise { + return new Promise((resolve, reject) => { + conn.exec(command, (err, stream) => { + if (err) { + reject(err); + return; + } + let output = ''; + stream.on('close', () => resolve(output)); + stream.on('data', (data: Buffer) => { output += data.toString(); }); + stream.stderr.on('data', (data: Buffer) => { output += data.toString(); }); + }); + }); +} + +async function getContainerVolumes( + ip: string, + containerName: string, + sshUser: string, + sshKeyPath?: string, + sshPort?: number +): Promise { + try { + // Load SSH key + const keyPath = sshKeyPath || `${homedir()}/.ssh/id_ed25519`; + let privateKey: Buffer | undefined; + try { + privateKey = readFileSync(keyPath); + } catch { + // If key file doesn't exist, try without it + } + + const sshConfig: SSHConnectionConfig = { + host: ip, + port: sshPort || 22, + username: sshUser, + privateKey, + }; + + const conn = await connectSSH(sshConfig, 30000); + + // Run docker inspect to get mounts + const command = `docker inspect ${containerName} --format '{{json .Mounts}}'`; + const output = await execSSH(conn, command); + + conn.end(); + + // Parse JSON output + let mounts: any[] = []; + try { + mounts = JSON.parse(output.trim()) || []; + } catch { + // If parsing fails, return empty array + return { volumes: [] }; + } + + // Transform to VolumeMount format + const volumes: VolumeMount[] = mounts.map((mount: any) => ({ + source: mount.Source || mount.Source || '', + destination: mount.Destination || mount.Destination || '', + mode: mount.Mode || mount.Mode || 'rw', + })).filter((v: VolumeMount) => v.source && v.destination); + + return { volumes }; + } catch (error: any) { + return { + volumes: [], + error: error.message || 'Failed to get container volumes', + }; + } +} + +// GET /api/files/:host/:container - Get volume mounts for a container +router.get('/files/:host/:container', async (req, res) => { + try { + const { host, container } = req.params; + + const hosts = getHostConfigs(); + const hostConfig = hosts.find(h => h.name.toLowerCase() === host.toLowerCase()); + + if (!hostConfig) { + const response: FilesResponse = { + volumes: [], + error: `Host '${host}' not found in configuration`, + }; + return res.status(404).json(response); + } + + const result = await getContainerVolumes( + hostConfig.ip, + container, + hostConfig.sshUser, + hostConfig.sshKeyPath, + hostConfig.sshPort + ); + + res.json(result); + } catch (error: unknown) { + const errMsg = error instanceof Error ? error.message : 'Failed to get container volumes'; + const response: FilesResponse = { + volumes: [], + error: errMsg, + }; + res.status(500).json(response); + } +}); + +interface FileEntry { + name: string; + path: string; + type: 'file' | 'directory' | 'symlink'; + size: number; + modified: string; +} + +interface BrowseResponse { + path: string; + files: FileEntry[]; + error?: string; +} + +async function browseDirectory( + ip: string, + path: string, + sshUser: string, + sshKeyPath?: string, + sshPort?: number +): Promise { + try { + const keyPath = sshKeyPath || `${homedir()}/.ssh/id_ed25519`; + let privateKey: Buffer | undefined; + try { + privateKey = require('fs').readFileSync(keyPath); + } catch { + // ignore + } + + const sshConfig: SSHConnectionConfig = { + host: ip, + port: sshPort || 22, + username: sshUser, + privateKey, + }; + + const conn = await connectSSH(sshConfig, 30000); + + const command = `ls -la --time-style=long-iso "${path}" 2>/dev/null | tail -n +2`; + const output = await execSSH(conn, command); + + conn.end(); + + const files: FileEntry[] = output.trim().split('\n').filter(Boolean).map(line => { + const parts = line.split(/\s+/); + const perms = parts[0]; + const size = parseInt(parts[4], 10) || 0; + const modified = parts[5] + ' ' + parts[6]; + const name = parts.slice(8).join(' '); + const type = perms.startsWith('d') ? 'directory' : + perms.startsWith('l') ? 'symlink' : 'file'; + + return { + name, + path: path === '/' ? `/${name}` : `${path}/${name}`, + type, + size, + modified, + }; + }); + + return { path, files }; + } catch (error: unknown) { + const errMsg = error instanceof Error ? error.message : 'Failed to browse directory'; + return { path, files: [], error: errMsg }; + } +} + +router.get('/files/browse/:host', async (req, res) => { + try { + const { host } = req.params; + const path = (req.query.path as string) || '/'; + + const hosts = getHostConfigs(); + const hostConfig = hosts.find(h => h.name.toLowerCase() === host.toLowerCase()); + + if (!hostConfig) { + return res.status(404).json({ path, files: [], error: `Host '${host}' not found` }); + } + + const result = await browseDirectory( + hostConfig.ip, + path, + hostConfig.sshUser, + hostConfig.sshKeyPath, + hostConfig.sshPort + ); + + res.json(result); + } catch (error: unknown) { + const errMsg = error instanceof Error ? error.message : 'Failed to browse directory'; + res.status(500).json({ path: req.query.path as string || '/', files: [], error: errMsg }); + } +}); + +export default router; diff --git a/server/routes/terminal.ts b/server/routes/terminal.ts new file mode 100644 index 0000000..dd3fda8 --- /dev/null +++ b/server/routes/terminal.ts @@ -0,0 +1,60 @@ +import { Router } from 'express'; +import { execSync } from 'child_process'; +import { homedir } from 'os'; +import { getHostConfigs } from '../config'; + +const router = Router(); + +interface TerminalRequest { + host: string; + command: string; +} + +router.post('/terminal/exec', async (req, res) => { + try { + const { host: hostName, command }: TerminalRequest = req.body; + + if (!hostName || !command) { + return res.status(400).json({ error: 'Missing host or command' }); + } + + const hosts = getHostConfigs(); + const hostConfig = hosts.find(h => h.name === hostName); + + if (!hostConfig) { + return res.status(404).json({ error: `Host not found: ${hostName}` }); + } + + const keyPath = (hostConfig.sshKeyPath || `${homedir()}/.ssh/id_ed25519`).replace(/^~/, homedir()); + const keyArg = `-i ${keyPath}`; + const portArg = hostConfig.sshPort && hostConfig.sshPort !== 22 ? `-p ${hostConfig.sshPort}` : ''; + + const fullCommand = `ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${keyArg} ${portArg} ${hostConfig.sshUser}@${hostConfig.ip} ${command} 2>&1`; + + const output = execSync(fullCommand, { encoding: 'utf-8', timeout: 30000 }); + + res.json({ output, error: null }); + } catch (error: any) { + res.status(500).json({ + output: '', + error: error.message || 'Command execution failed' + }); + } +}); + +router.get('/terminal/hosts', async (_req, res) => { + try { + const hosts = getHostConfigs(); + res.json({ + hosts: hosts.map(h => ({ + name: h.name, + ip: h.ip, + user: h.sshUser + })) + }); + } catch (error: any) { + res.status(500).json({ error: error.message }); + } +}); + +export default router; diff --git a/server/types.ts b/server/types.ts index d7485c8..1194677 100644 --- a/server/types.ts +++ b/server/types.ts @@ -17,6 +17,8 @@ export interface HostConfig { sshKeyPath?: string; /** Optional SSH port (defaults to 22) */ sshPort?: number; + /** Host type: proxmox, truenas, docker-host, etc */ + hostType?: string; } export interface DiscoveryResponse { @@ -26,6 +28,8 @@ export interface DiscoveryResponse { ip: string; online: boolean; containers?: string[]; + services?: string[]; + vms?: Array<{ id: string; name: string; status: string; type: 'lxc' | 'qemu' }>; error?: string; }>; /** Timestamp of discovery run */ diff --git a/src/AGENTS.md b/src/AGENTS.md new file mode 100644 index 0000000..1097910 --- /dev/null +++ b/src/AGENTS.md @@ -0,0 +1,67 @@ +# Src (React Frontend) + +**Generated:** 2026-02-19 +**Location:** src/ + +## OVERVIEW + +React 18 + TypeScript frontend with Vite, Tailwind CSS, Zustand state, and React Flow graph visualization. + +## STRUCTURE + +``` +src/ +├── main.tsx # React entry point +├── App.tsx # Main app component, data loading +├── index.css # Tailwind CSS entry +├── vite-env.d.ts # Vite type definitions +├── components/ +│ ├── Header.tsx # Top header with refresh +│ ├── LeftPanel.tsx # Host list sidebar +│ ├── RightPanel.tsx # Details panel (tabs) +│ └── Graph/ +│ └── TopologyGraph.tsx # React Flow graph +├── services/ +│ ├── discovery.ts # Data transformation +│ └── sshDiscovery.ts # SSH connection logic +├── store/ +│ └── topologyStore.ts # Zustand global state +├── types/ +│ └── index.ts # TypeScript interfaces +├── utils/ +│ └── colors.ts # Color utilities +└── data/ + └── staticConfig.ts # Static fallback data +``` + +## WHERE TO LOOK + +| Task | File | Notes | +|------|------|-------| +| Add global state | src/store/topologyStore.ts | Zustand store | +| Modify graph | src/components/Graph/TopologyGraph.tsx | React Flow | +| Add new panel | src/components/*.tsx | Follow LeftPanel pattern | + +## STATE MANAGEMENT + +- Zustand store in `src/store/topologyStore.ts` +- Keys: nodes, edges, hosts, networkInfo, pollInterval, isLoading, lastUpdated +- Panels: leftPanelOpen, rightPanelOpen + +## ANTI-PATTERNS + +- **DO NOT store SSH credentials in localStorage** - security risk +- **DO NOT bypass the store** - use setState from useTopologyStore + +## COMMANDS + +```bash +npm run dev # Start Vite dev server (port 3000) +npm run build # TypeScript + Vite build to dist/ +``` + +## NOTES + +- API URL: configured via VITE_API_URL env var (default: http://localhost:3001) +- Falls back to simulated data if API call fails +- Polling interval: configurable via store (default in topologyStore.ts) diff --git a/src/App.tsx b/src/App.tsx index 4ab287d..d2ba24e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,16 +3,34 @@ import { ReactFlowProvider } from '@xyflow/react'; import { useTopologyStore } from './store/topologyStore'; import { defaultNetworkInfo, - defaultHosts, discoverHosts, - convertToTopology + convertToTopology, + DiscoveredHost } from './services/discovery'; import Header from './components/Header'; import LeftPanel from './components/LeftPanel'; import RightPanel from './components/RightPanel'; import TopologyGraph from './components/Graph/TopologyGraph'; +import CommandPalette from './components/CommandPalette'; +import StaleWarning from './components/StaleWarning'; +import TerminalPanel from './components/TerminalPanel'; -const POLLING_INTERVAL_MS = 30000; +const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001'; + +interface ApiHost { + name: string; + ip: string; + online: boolean; + containers?: string[]; + services?: string[]; + vms?: Array<{ id: string; name: string; status: string; type: 'lxc' | 'qemu' }>; +} + +interface ApiDiscoveryResponse { + hosts: ApiHost[]; + timestamp: string; + errors: string[]; +} function App() { const { @@ -22,26 +40,86 @@ function App() { setHosts, setLastUpdated, setIsLoading, + setDataSource, + incrementFailures, + resetFailures, + setLastSuccessfulDiscovery, leftPanelOpen, rightPanelOpen, - isLoading + isLoading, + pollInterval, + toggleCommandPalette, + terminalOpen, + terminalHost, + closeTerminal } = useTopologyStore(); const isLoadingRef = useRef(isLoading); isLoadingRef.current = isLoading; + const pollIntervalRef = useRef(pollInterval); + pollIntervalRef.current = pollInterval; const loadData = useCallback(async () => { if (isLoadingRef.current) return; setIsLoading(true); + try { - const hostNames = ['ubuntu', 'grizzley', 'truenas', 'ice', 'panda', 'proxmox']; - const discoveryResult = await discoverHosts(hostNames); + const response = await fetch(`${API_BASE_URL}/api/discover`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' } + }); - const { nodes, edges } = convertToTopology( - discoveryResult.hosts, - defaultNetworkInfo - ); + if (response.ok) { + const data: ApiDiscoveryResponse = await response.json(); + + const discoveredHosts: DiscoveredHost[] = data.hosts.map((h: ApiHost) => ({ + name: h.name, + ip: h.ip, + online: h.online, + containers: (h.containers || []).map((c: string) => ({ + name: c, + image: '', + status: 'running', + ports: [], + created: '' + })), + services: h.services, + vms: h.vms + })); + + const { nodes, edges } = convertToTopology(discoveredHosts, defaultNetworkInfo); + + const hosts = discoveredHosts.map(h => ({ + name: h.name, + ip: h.ip, + type: (h.name === 'ubuntu' ? 'vm' : + h.name === 'proxmox' || h.name === 'truenas' ? 'physical' : 'rpi5') as 'vm' | 'physical' | 'rpi5' | 'container', + role: h.name === 'ubuntu' ? 'Primary Docker Host' : + h.name === 'grizzley' ? 'Edge Services' : + h.name === 'truenas' ? 'Storage (NAS)' : + h.name === 'proxmox' ? 'Hypervisor' : 'Host', + containers: h.containers.map(c => c.name), + services: h.services, + vms: h.vms + })); + + setNodes(nodes); + setEdges(edges); + setNetworkInfo(defaultNetworkInfo); + setHosts(hosts); + setLastUpdated(new Date()); + setDataSource('live'); + setLastSuccessfulDiscovery(new Date()); + resetFailures(); + } else { + throw new Error(`API error: ${response.status}`); + } + } catch (error) { + console.error('Discovery failed, using simulated data:', error); + const discoveryResult = await discoverHosts(['ubuntu', 'grizzley', 'truenas', 'ice', 'panda', 'proxmox']); + + const { nodes, edges } = convertToTopology(discoveryResult.hosts, defaultNetworkInfo); const hosts = discoveryResult.hosts.map(h => ({ name: h.name, @@ -60,29 +138,37 @@ function App() { setNetworkInfo(defaultNetworkInfo); setHosts(hosts); setLastUpdated(new Date()); - } catch (error) { - console.error('Discovery failed:', error); - setNodes([]); - setEdges([]); - setNetworkInfo(defaultNetworkInfo); - setHosts(defaultHosts); - setLastUpdated(new Date()); + setDataSource('simulated'); + incrementFailures(); } finally { setIsLoading(false); } - }, [setNodes, setEdges, setNetworkInfo, setHosts, setLastUpdated, setIsLoading]); + }, [setNodes, setEdges, setNetworkInfo, setHosts, setLastUpdated, setIsLoading, setDataSource, incrementFailures, resetFailures, setLastSuccessfulDiscovery]); + + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if ((e.metaKey || e.ctrlKey) && e.key === 'k') { + e.preventDefault(); + toggleCommandPalette(); + } + }; + window.addEventListener('keydown', handleKeyDown); + return () => window.removeEventListener('keydown', handleKeyDown); + }, [toggleCommandPalette]); useEffect(() => { loadData(); - - const intervalId = setInterval(loadData, POLLING_INTERVAL_MS); - + }, []); + + useEffect(() => { + const intervalId = setInterval(loadData, pollIntervalRef.current); return () => clearInterval(intervalId); }, [loadData]); return (
+
@@ -100,14 +186,20 @@ function App() {
+ + {terminalOpen && terminalHost && ( + + )}
); } function Footer() { - const { lastUpdated, nodes } = useTopologyStore(); - const [countdown, setCountdown] = useState(30); + const { lastUpdated, nodes, dataSource, pollInterval } = useTopologyStore(); + const [countdown, setCountdown] = useState(Math.ceil(pollInterval / 1000)); + const pollIntervalRef = useRef(pollInterval); + pollIntervalRef.current = pollInterval; const formatTime = (date: Date | null) => { if (!date) return 'Never'; @@ -115,22 +207,25 @@ function Footer() { }; useEffect(() => { - setCountdown(30); + setCountdown(Math.ceil(pollInterval / 1000)); const intervalId = setInterval(() => { setCountdown(prev => { - if (prev <= 1) return 30; + if (prev <= 1) return Math.ceil(pollIntervalRef.current / 1000); return prev - 1; }); }, 1000); return () => clearInterval(intervalId); - }, [lastUpdated]); + }, [lastUpdated, pollInterval]); return (
Nodes: {nodes.length}
+ + {dataSource === 'live' ? 'Live' : 'Simulated'} + Next refresh: {countdown}s Last updated: {formatTime(lastUpdated)}
diff --git a/src/components/AGENTS.md b/src/components/AGENTS.md new file mode 100644 index 0000000..768e892 --- /dev/null +++ b/src/components/AGENTS.md @@ -0,0 +1,42 @@ +# Components (React UI) + +**Generated:** 2026-02-19 +**Location:** src/components/ + +## OVERVIEW + +React components for the topology visualization UI - header, panels, and graph. + +## COMPONENTS + +| Component | File | Purpose | +|-----------|------|---------| +| Header | Header.tsx | Top bar with title, refresh button, view mode | +| LeftPanel | LeftPanel.tsx | Collapsible host list sidebar | +| RightPanel | RightPanel.tsx | Collapsible details panel with tabs | +| TopologyGraph | Graph/TopologyGraph.tsx | React Flow graph rendering | + +## ADDING A NEW COMPONENT + +1. Create in `src/components/{Name}.tsx` +2. Export as default or named export +3. Import in parent (e.g., App.tsx) + +## PATTERNS + +- Use Zustand store: `import { useTopologyStore } from '../store/topologyStore'` +- Tailwind CSS classes for styling +- Props interfaces for type safety +- Follow existing component patterns (Header is good reference) + +## SUB-COMPONENTS + +- `Graph/TopologyGraph.tsx`: Uses @xyflow/react (React Flow) + dagre for auto-layout + - Nodes: Network → Host → Container → Volume hierarchy + - Edges: Connect related nodes + +## NOTES + +- Panels are collapsible via store state (leftPanelOpen, rightPanelOpen) +- Graph auto-layouts on data change using dagre +- All components use Tailwind for styling diff --git a/src/components/CommandPalette.tsx b/src/components/CommandPalette.tsx new file mode 100644 index 0000000..bea00b2 --- /dev/null +++ b/src/components/CommandPalette.tsx @@ -0,0 +1,359 @@ +import { useState, useEffect, useRef, useCallback, useMemo } from 'react'; +import { Search, Loader2, Network, HardDrive, Box, Database, ArrowLeftRight, ArrowUpDown, Router, Wifi, Monitor, Container, FolderTree, Folder, X } from 'lucide-react'; +import { useTopologyStore } from '../store/topologyStore'; +import { NodeType } from '../types'; + +interface Command { + id: string; + label: string; + description?: string; + icon: React.ReactNode; + category: 'action' | 'filter' | 'view' | 'orientation'; + action: () => void; +} + + const nodeTypeLabels: Record = { + gateway: 'Gateway', + vlan: 'VLAN', + wifi: 'WiFi', + host_physical: 'Physical Host', + host_vm: 'VM Host', + host_container: 'Container Host', + vm_lxc: 'LXC Container', + vm_qemu: 'QEMU VM', + systemd_service: 'Systemd Service', + service: 'Service', + volume: 'Volume', + mount: 'Mount', + path: 'Path', + }; + +const nodeTypeIcons: Record = { + gateway: , + vlan: , + wifi: , + host_physical: , + host_vm: , + host_container: , + vm_lxc: , + vm_qemu: , + systemd_service: , + service: , + volume: , + mount: , + path: +}; + +function fuzzyMatch(pattern: string, text: string): boolean { + const patternLower = pattern.toLowerCase(); + const textLower = text.toLowerCase(); + + let patternIdx = 0; + for (let i = 0; i < textLower.length && patternIdx < patternLower.length; i++) { + if (textLower[i] === patternLower[patternIdx]) { + patternIdx++; + } + } + + return patternIdx === patternLower.length; +} + +interface CommandPaletteProps { + onRefresh?: () => Promise; +} + +export default function CommandPalette({ onRefresh }: CommandPaletteProps) { + const { + commandPaletteOpen, + toggleCommandPalette, + typeFilters, + toggleTypeFilter, + setViewMode, + setOrientation + } = useTopologyStore(); + + const [search, setSearch] = useState(''); + const [selectedIndex, setSelectedIndex] = useState(0); + const inputRef = useRef(null); + const listRef = useRef(null); + + const commands = useMemo(() => { + const cmds: Command[] = [ + { + id: 'refresh', + label: 'Refresh Discovery', + description: 'Reload topology data from hosts', + icon: , + category: 'action', + action: async () => { + if (onRefresh) { + await onRefresh(); + } + toggleCommandPalette(); + } + }, + { + id: 'view-full', + label: 'Set View: Full', + description: 'Show complete topology', + icon: , + category: 'view', + action: () => { + setViewMode('full'); + toggleCommandPalette(); + } + }, + { + id: 'view-network', + label: 'Set View: Network', + description: 'Show network infrastructure', + icon: , + category: 'view', + action: () => { + setViewMode('network'); + toggleCommandPalette(); + } + }, + { + id: 'view-host', + label: 'Set View: Hosts', + description: 'Show hosts and containers', + icon: , + category: 'view', + action: () => { + setViewMode('host'); + toggleCommandPalette(); + } + }, + { + id: 'view-service', + label: 'Set View: Services', + description: 'Show services and volumes', + icon: , + category: 'view', + action: () => { + setViewMode('service'); + toggleCommandPalette(); + } + }, + { + id: 'view-filesystem', + label: 'Set View: Files', + description: 'Show filesystem hierarchy', + icon: , + category: 'view', + action: () => { + setViewMode('filesystem'); + toggleCommandPalette(); + } + }, + { + id: 'orientation-lr', + label: 'Set Orientation: Left to Right', + icon: , + category: 'orientation', + action: () => { + setOrientation('LR'); + toggleCommandPalette(); + } + }, + { + id: 'orientation-tb', + label: 'Set Orientation: Top to Bottom', + icon: , + category: 'orientation', + action: () => { + setOrientation('TB'); + toggleCommandPalette(); + } + } + ]; + + const nodeTypes: NodeType[] = [ + 'gateway', 'vlan', 'wifi', 'host_physical', 'host_vm', + 'host_container', 'service', 'volume', 'mount', 'path' + ]; + + nodeTypes.forEach((type) => { + const isActive = typeFilters.includes(type); + cmds.push({ + id: `filter-${type}`, + label: `${isActive ? 'Disable' : 'Enable'} Filter: ${nodeTypeLabels[type]}`, + description: `${isActive ? 'Hide' : 'Show'} ${nodeTypeLabels[type]} nodes`, + icon: nodeTypeIcons[type], + category: 'filter', + action: () => { + toggleTypeFilter(type); + toggleCommandPalette(); + } + }); + }); + + return cmds; + }, [typeFilters, onRefresh, setViewMode, setOrientation, toggleTypeFilter, toggleCommandPalette]); + + const filteredCommands = useMemo(() => { + if (!search.trim()) return commands; + return commands.filter(cmd => fuzzyMatch(search, cmd.label)); + }, [commands, search]); + + useEffect(() => { + setSelectedIndex(0); + }, [filteredCommands.length]); + + useEffect(() => { + if (commandPaletteOpen) { + setSearch(''); + setSelectedIndex(0); + setTimeout(() => inputRef.current?.focus(), 50); + } + }, [commandPaletteOpen]); + + useEffect(() => { + if (listRef.current) { + const selectedEl = listRef.current.children[selectedIndex] as HTMLElement; + if (selectedEl) { + selectedEl.scrollIntoView({ block: 'nearest' }); + } + } + }, [selectedIndex]); + + const handleKeyDown = useCallback((e: React.KeyboardEvent) => { + switch (e.key) { + case 'ArrowDown': + e.preventDefault(); + setSelectedIndex(prev => Math.min(prev + 1, filteredCommands.length - 1)); + break; + case 'ArrowUp': + e.preventDefault(); + setSelectedIndex(prev => Math.max(prev - 1, 0)); + break; + case 'Enter': + e.preventDefault(); + if (filteredCommands[selectedIndex]) { + filteredCommands[selectedIndex].action(); + } + break; + case 'Escape': + e.preventDefault(); + toggleCommandPalette(); + break; + } + }, [filteredCommands, selectedIndex, toggleCommandPalette]); + + const handleBackdropClick = useCallback((e: React.MouseEvent) => { + if (e.target === e.currentTarget) { + toggleCommandPalette(); + } + }, [toggleCommandPalette]); + + if (!commandPaletteOpen) return null; + + const categoryLabels: Record = { + action: 'Actions', + filter: 'Filters', + view: 'View Mode', + orientation: 'Orientation' + }; + + const groupedCommands = filteredCommands.reduce((acc, cmd) => { + if (!acc[cmd.category]) { + acc[cmd.category] = []; + } + acc[cmd.category].push(cmd); + return acc; + }, {} as Record); + + let globalIndex = 0; + + return ( +
+
+
+ + setSearch(e.target.value)} + onKeyDown={handleKeyDown} + className="flex-1 bg-transparent text-white placeholder-slate-400 outline-none text-base" + /> + +
+ +
+ {filteredCommands.length === 0 ? ( +
+ No commands found +
+ ) : ( + Object.entries(groupedCommands).map(([category, cmds]) => ( +
+
+ {categoryLabels[category as Command['category']]} +
+ {cmds.map((cmd) => { + const currentIndex = globalIndex++; + const isSelected = currentIndex === selectedIndex; + + return ( + + ); + })} +
+ )) + )} +
+ +
+ + ↑↓ + Navigate + + + Enter + Select + + + Esc + Close + +
+
+
+ ); +} diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx new file mode 100644 index 0000000..e89b50a --- /dev/null +++ b/src/components/FileBrowser.tsx @@ -0,0 +1,146 @@ +import { useState, useEffect } from 'react'; +import { Folder, File, ArrowLeft, X, RefreshCw, Terminal as TerminalIcon } from 'lucide-react'; + +const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001'; + +interface FileEntry { + name: string; + path: string; + type: 'file' | 'directory' | 'symlink'; + size: number; + modified: string; +} + +interface FileBrowserProps { + host: string; + initialPath?: string; + onClose: () => void; +} + +export default function FileBrowser({ host, initialPath = '/', onClose }: FileBrowserProps) { + const [currentPath, setCurrentPath] = useState(initialPath); + const [files, setFiles] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + const fetchFiles = async (path: string) => { + setLoading(true); + setError(null); + try { + const response = await fetch( + `${API_BASE_URL}/api/files/browse/${host}?path=${encodeURIComponent(path)}` + ); + const data = await response.json(); + if (data.error) { + setError(data.error); + setFiles([]); + } else { + setFiles(data.files || []); + } + } catch (err: unknown) { + const msg = err instanceof Error ? err.message : 'Failed to fetch files'; + setError(msg); + setFiles([]); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + fetchFiles(currentPath); + }, [host, currentPath]); + + const navigateTo = (path: string) => { + setCurrentPath(path); + }; + + const goUp = () => { + const parts = currentPath.split('/').filter(Boolean); + parts.pop(); + const newPath = parts.length === 0 ? '/' : '/' + parts.join('/'); + navigateTo(newPath); + }; + + const formatSize = (bytes: number): string => { + if (bytes < 1024) return `${bytes}B`; + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}K`; + if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)}M`; + return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)}G`; + }; + + const getFileIcon = (type: string) => { + if (type === 'directory') return ; + if (type === 'symlink') return ; + return ; + }; + + return ( +
+
+
+ / + {host} + : + setCurrentPath(e.target.value)} + onKeyDown={(e) => e.key === 'Enter' && navigateTo(e.currentTarget.value)} + className="bg-slate-700 text-slate-200 px-2 py-1 rounded text-sm font-mono w-64" + /> +
+
+ + +
+
+ +
+ {loading ? ( +
+ +
+ ) : error ? ( +
{error}
+ ) : ( +
+ {currentPath !== '/' && ( + + )} + {files.map((file) => ( + + ))} +
+ )} +
+
+ ); +} diff --git a/src/components/Graph/TopologyGraph.tsx b/src/components/Graph/TopologyGraph.tsx index ddfcc2f..ab24e9a 100644 --- a/src/components/Graph/TopologyGraph.tsx +++ b/src/components/Graph/TopologyGraph.tsx @@ -24,27 +24,36 @@ const nodeIcons: Record = { host_physical: , host_vm: , host_container: , + vm_lxc: , + vm_qemu: , + systemd_service: , service: , volume: , mount: , path: , }; -function CustomNode({ data, selected }: NodeProps) { +function CustomNode({ data, selected, id }: NodeProps) { + const { highlightPath } = useTopologyStore(); const nodeData = data as { type?: NodeType; category?: ServiceCategory; status?: 'running' | 'stopped' | 'unknown'; label?: string; ip?: string }; const nodeColor = getNodeColor(nodeData.type || 'service', nodeData.category); const statusColor = getStatusColor(nodeData.status || 'unknown'); + const isHighlighted = highlightPath.includes(id); + const isDimmed = highlightPath.length > 0 && !isHighlighted; return (
@@ -127,7 +136,8 @@ export default function TopologyGraph() { setSelectedNode, getFilteredNodes, orientation, - viewMode + viewMode, + highlightPath } = useTopologyStore(); const [nodes, setNodes] = useState([]); @@ -160,27 +170,36 @@ export default function TopologyGraph() { const newEdges: Edge[] = storeEdges .filter(e => nodeIds.has(e.source) && nodeIds.has(e.target)) - .map(edge => ({ - id: edge.id, - source: edge.source, - target: edge.target, - type: 'smoothstep', - animated: edge.source === selectedNodeId || edge.target === selectedNodeId, - style: { - stroke: edge.source === selectedNodeId || edge.target === selectedNodeId - ? '#38BDF8' - : '#475569', - strokeWidth: edge.source === selectedNodeId || edge.target === selectedNodeId - ? 2 - : 1, - }, - markerEnd: { - type: 'arrowclosed' as const, - color: edge.source === selectedNodeId || edge.target === selectedNodeId - ? '#38BDF8' - : '#475569', - }, - })); + .map(edge => { + const isPathEdge = highlightPath.includes(edge.source) && highlightPath.includes(edge.target); + const isSelected = edge.source === selectedNodeId || edge.target === selectedNodeId; + return { + id: edge.id, + source: edge.source, + target: edge.target, + type: 'smoothstep', + animated: isSelected || isPathEdge, + style: { + stroke: isSelected + ? '#38BDF8' + : isPathEdge + ? '#818CF8' + : '#475569', + strokeWidth: isSelected || isPathEdge + ? 2 + : 1, + opacity: highlightPath.length > 0 && !isPathEdge ? 0.3 : 1 + }, + markerEnd: { + type: 'arrowclosed' as const, + color: isSelected + ? '#38BDF8' + : isPathEdge + ? '#818CF8' + : '#475569', + }, + }; + }); const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements( newNodes, diff --git a/src/components/LeftPanel.tsx b/src/components/LeftPanel.tsx index b7b8e92..3003af7 100644 --- a/src/components/LeftPanel.tsx +++ b/src/components/LeftPanel.tsx @@ -10,6 +10,9 @@ const typeIcons: Record = { host_physical: , host_vm: , host_container: , + vm_lxc: , + vm_qemu: , + systemd_service: , service: , volume: , mount: , @@ -23,6 +26,9 @@ const typeLabels: Record = { host_physical: 'Physical', host_vm: 'VM', host_container: 'Container', + vm_lxc: 'LXC', + vm_qemu: 'QEMU', + systemd_service: 'Systemd', service: 'Service', volume: 'Volume', mount: 'Mount', diff --git a/src/components/RightPanel.tsx b/src/components/RightPanel.tsx index 9c0d37c..b115090 100644 --- a/src/components/RightPanel.tsx +++ b/src/components/RightPanel.tsx @@ -1,7 +1,8 @@ import { useState } from 'react'; -import { Info, FileCode, FolderOpen, BarChart3, Star, X } from 'lucide-react'; +import { Info, FileCode, FolderOpen, BarChart3, Star, X, Terminal, Folder } from 'lucide-react'; import { useTopologyStore } from '../store/topologyStore'; import { getNodeColor, getStatusColor, getImportanceLabel, getImportanceColor } from '../utils/colors'; +import FileBrowser from './FileBrowser'; type TabId = 'details' | 'config' | 'files' | 'usage' | 'importance'; @@ -14,8 +15,9 @@ const tabs: { id: TabId; label: string; icon: React.ReactNode }[] = [ ]; export default function RightPanel() { - const { nodes, selectedNodeId, setSelectedNode } = useTopologyStore(); + const { nodes, selectedNodeId, setSelectedNode, openTerminal } = useTopologyStore(); const [activeTab, setActiveTab] = useState('details'); + const [fileBrowserOpen, setFileBrowserOpen] = useState(false); const selectedNode = nodes.find(n => n.id === selectedNodeId); @@ -31,17 +33,38 @@ export default function RightPanel() { const nodeColor = getNodeColor(selectedNode.type, selectedNode.data.category); const statusColor = getStatusColor(selectedNode.data.status); + const isHost = selectedNode.type.startsWith('host_') || selectedNode.type.startsWith('vm_'); return (

{selectedNode.name}

- +
+ {isHost && selectedNodeId && ( + <> + + + + )} + +
@@ -67,6 +90,13 @@ export default function RightPanel() { {activeTab === 'usage' && } {activeTab === 'importance' && }
+ + {fileBrowserOpen && selectedNodeId && ( + setFileBrowserOpen(false)} + /> + )}
); } diff --git a/src/components/TerminalPanel.tsx b/src/components/TerminalPanel.tsx new file mode 100644 index 0000000..7660f67 --- /dev/null +++ b/src/components/TerminalPanel.tsx @@ -0,0 +1,127 @@ +import { useEffect, useRef, useState } from 'react'; +import { Terminal } from '@xterm/xterm'; +import { FitAddon } from '@xterm/addon-fit'; +import '@xterm/xterm/css/xterm.css'; +import { X } from 'lucide-react'; + +const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001'; + +interface TerminalProps { + host: string; + onClose: () => void; +} + +export default function TerminalPanel({ host, onClose }: TerminalProps) { + const terminalRef = useRef(null); + const terminalInstance = useRef(null); + const inputBuffer = useRef(''); + const [currentPath, _setCurrentPath] = useState('~'); + + useEffect(() => { + if (!terminalRef.current) return; + + const term = new Terminal({ + theme: { + background: '#0f172a', + foreground: '#e2e8f0', + cursor: '#22d3ee', + cursorAccent: '#0f172a', + selectionBackground: '#334155', + }, + fontFamily: 'Menlo, Monaco, "Courier New", monospace', + fontSize: 13, + cursorBlink: true, + scrollback: 1000, + }); + + const fit = new FitAddon(); + term.loadAddon(fit); + term.open(terminalRef.current); + fit.fit(); + + terminalInstance.current = term; + + term.writeln('\x1b[36m╔════════════════════════════════════════════════╗\x1b[0m'); + term.writeln('\x1b[36m║ Homelab Topology - SSH Terminal ║\x1b[0m'); + term.writeln('\x1b[36m╚════════════════════════════════════════════════╝\x1b[0m'); + term.writeln(`\x1b[32mConnecting to ${host}...\x1b[0m`); + term.writeln(''); + + const executeCommand = async (cmd: string) => { + try { + const response = await fetch(`${API_BASE_URL}/api/terminal/exec`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ host, command: cmd }), + }); + const data = await response.json(); + if (data.output) { + term.writeln(data.output); + } + if (data.error) { + term.writeln(`\x1b[31mError: ${data.error}\x1b[0m`); + } + } catch (err: unknown) { + const msg = err instanceof Error ? err.message : 'Unknown error'; + term.writeln(`\x1b[31mConnection error: ${msg}\x1b[0m`); + } + term.write(`\x1b[32m${host}:\x1b[0m${currentPath}$ `); + }; + + term.onData((data) => { + const code = data.charCodeAt(0); + + if (code === 13) { + term.writeln(''); + if (inputBuffer.current.trim()) { + executeCommand(inputBuffer.current); + } else { + term.write(`\x1b[32m${host}:\x1b[0m${currentPath}$ `); + } + inputBuffer.current = ''; + } else if (code === 127) { + if (inputBuffer.current.length > 0) { + inputBuffer.current = inputBuffer.current.slice(0, -1); + term.write('\b \b'); + } + } else if (code < 32) { + // skip control chars + } else { + inputBuffer.current += data; + term.write(data); + } + }); + + term.write(`\x1b[32m${host}:\x1b[0m${currentPath}$ `); + + const handleResize = () => { + fit.fit(); + }; + window.addEventListener('resize', handleResize); + + return () => { + window.removeEventListener('resize', handleResize); + term.dispose(); + }; + }, [host, currentPath]); + + return ( +
+
+
+ $ + {host} + : + {currentPath} +
+ +
+
+
+ ); +} diff --git a/src/services/discovery.ts b/src/services/discovery.ts index 36750ce..b1a499c 100644 --- a/src/services/discovery.ts +++ b/src/services/discovery.ts @@ -49,6 +49,8 @@ export interface DiscoveredHost { ip: string; online: boolean; containers: DiscoveredContainer[]; + services?: string[]; + vms?: Array<{ id: string; name: string; status: string; type: 'lxc' | 'qemu' }>; cpuUsage?: number; memoryUsage?: number; uptime?: string; @@ -225,6 +227,52 @@ export function convertToTopology( }); edges.push({ id: `e-${host.name}-${container.name}`, source: host.name, target: `${host.name}-${container.name}` }); }); + + if (host.services) { + host.services.forEach((service) => { + nodes.push({ + id: `${host.name}-service-${service}`, + type: 'systemd_service', + name: service, + data: { + status: 'running', + metadata: { + host: host.name, + type: 'systemd' + }, + category: 'infra', + importance: 3, + description: `Systemd service: ${service}`, + parentId: host.name + } + }); + edges.push({ id: `e-${host.name}-service-${service}`, source: host.name, target: `${host.name}-service-${service}` }); + }); + } + + if (host.vms) { + host.vms.forEach((vm) => { + const vmType = vm.type === 'lxc' ? 'vm_lxc' : 'vm_qemu'; + nodes.push({ + id: `${host.name}-vm-${vm.id}`, + type: vmType, + name: vm.name, + data: { + status: vm.status === 'running' ? 'running' : 'stopped', + metadata: { + host: host.name, + vmId: vm.id, + type: vm.type + }, + category: 'infra', + importance: 4, + description: `${vm.type.toUpperCase()} VM: ${vm.name}`, + parentId: host.name + } + }); + edges.push({ id: `e-${host.name}-vm-${vm.id}`, source: host.name, target: `${host.name}-vm-${vm.id}` }); + }); + } }); const truenasNode: TopologyNode = { diff --git a/src/store/topologyStore.ts b/src/store/topologyStore.ts index be7729b..9e82978 100644 --- a/src/store/topologyStore.ts +++ b/src/store/topologyStore.ts @@ -8,7 +8,7 @@ export type StatusFilter = 'all' | 'running' | 'stopped'; // All node types for default filter const ALL_NODE_TYPES: NodeType[] = [ 'gateway', 'vlan', 'wifi', 'host_physical', 'host_vm', 'host_container', - 'service', 'volume', 'mount', 'path' + 'vm_lxc', 'vm_qemu', 'systemd_service', 'service', 'volume', 'mount', 'path' ]; interface TopologyState { @@ -24,10 +24,21 @@ interface TopologyState { rightPanelOpen: boolean; lastUpdated: Date | null; isLoading: boolean; + pollInterval: number; networkInfo: NetworkInfo | null; hosts: Host[]; + dataSource: 'live' | 'simulated'; + consecutiveFailures: number; + lastSuccessfulDiscovery: Date | null; + + commandPaletteOpen: boolean; + terminalOpen: boolean; + terminalHost: string | null; + highlightPath: string[]; + staleWarningDismissed: boolean; + setNodes: (nodes: TopologyNode[]) => void; setEdges: (edges: TopologyEdge[]) => void; setSelectedNode: (nodeId: string | null) => void; @@ -39,9 +50,19 @@ interface TopologyState { toggleLeftPanel: () => void; toggleRightPanel: () => void; setLastUpdated: (date: Date) => void; + openTerminal: (host: string) => void; + closeTerminal: () => void; setIsLoading: (loading: boolean) => void; + setPollInterval: (interval: number) => void; setNetworkInfo: (info: NetworkInfo) => void; setHosts: (hosts: Host[]) => void; + setDataSource: (source: 'live' | 'simulated') => void; + incrementFailures: () => void; + resetFailures: () => void; + setLastSuccessfulDiscovery: (date: Date) => void; + toggleCommandPalette: () => void; + setHighlightPath: (ids: string[]) => void; + dismissStaleWarning: () => void; getSelectedNode: () => TopologyNode | null; getChildNodes: () => TopologyNode[]; @@ -63,12 +84,34 @@ export const useTopologyStore = create()( rightPanelOpen: true, lastUpdated: null, isLoading: false, + pollInterval: 30000, networkInfo: null, hosts: [], + dataSource: 'simulated', + consecutiveFailures: 0, + lastSuccessfulDiscovery: null, + commandPaletteOpen: false, + terminalOpen: false, + terminalHost: null, + highlightPath: [], + staleWarningDismissed: false, setNodes: (nodes) => set({ nodes }), setEdges: (edges) => set({ edges }), - setSelectedNode: (nodeId) => set({ selectedNodeId: nodeId }), + setSelectedNode: (nodeId) => { + if (!nodeId) { + set({ selectedNodeId: nodeId, highlightPath: [] }); + return; + } + const state = get(); + const path: string[] = [nodeId]; + let currentNode = state.nodes.find(n => n.id === nodeId); + while (currentNode?.data?.parentId) { + path.push(currentNode.data.parentId); + currentNode = state.nodes.find(n => n.id === currentNode?.data?.parentId); + } + set({ selectedNodeId: nodeId, highlightPath: path }); + }, setViewMode: (mode) => set({ viewMode: mode }), setOrientation: (orientation) => set({ orientation }), setSearchQuery: (query) => set({ searchQuery: query }), @@ -85,8 +128,18 @@ export const useTopologyStore = create()( toggleRightPanel: () => set((state) => ({ rightPanelOpen: !state.rightPanelOpen })), setLastUpdated: (date) => set({ lastUpdated: date }), setIsLoading: (loading) => set({ isLoading: loading }), + setPollInterval: (interval) => set({ pollInterval: interval }), setNetworkInfo: (info) => set({ networkInfo: info }), setHosts: (hosts) => set({ hosts }), + setDataSource: (source) => set({ dataSource: source }), + incrementFailures: () => set((state) => ({ consecutiveFailures: state.consecutiveFailures + 1 })), + resetFailures: () => set({ consecutiveFailures: 0 }), + setLastSuccessfulDiscovery: (date) => set({ lastSuccessfulDiscovery: date }), + toggleCommandPalette: () => set((state) => ({ commandPaletteOpen: !state.commandPaletteOpen })), + setHighlightPath: (ids) => set({ highlightPath: ids }), + dismissStaleWarning: () => set({ staleWarningDismissed: true }), + openTerminal: (host) => set({ terminalOpen: true, terminalHost: host }), + closeTerminal: () => set({ terminalOpen: false, terminalHost: null }), getSelectedNode: () => { const { nodes, selectedNodeId } = get(); @@ -159,7 +212,7 @@ export const useTopologyStore = create()( }), { name: 'homelab-topology-settings', - version: 1, + version: 2, storage: createJSONStorage(() => localStorage), partialize: (state: TopologyState) => ({ viewMode: state.viewMode, @@ -168,6 +221,7 @@ export const useTopologyStore = create()( typeFilters: state.typeFilters, statusFilter: state.statusFilter, leftPanelOpen: state.leftPanelOpen, - rightPanelOpen: state.rightPanelOpen + rightPanelOpen: state.rightPanelOpen, + pollInterval: state.pollInterval }) })); diff --git a/src/types/index.ts b/src/types/index.ts index b19a73f..9760d28 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -5,6 +5,9 @@ export type NodeType = | 'host_physical' | 'host_vm' | 'host_container' + | 'vm_lxc' + | 'vm_qemu' + | 'systemd_service' | 'service' | 'volume' | 'mount' @@ -50,6 +53,8 @@ export interface Host { type: 'physical' | 'vm' | 'container' | 'rpi5'; role: string; containers: string[]; + services?: string[]; + vms?: Array<{ id: string; name: string; status: string; type: 'lxc' | 'qemu' }>; } export interface VLAN { diff --git a/src/utils/colors.ts b/src/utils/colors.ts index f619a3a..9fe681e 100644 --- a/src/utils/colors.ts +++ b/src/utils/colors.ts @@ -8,6 +8,9 @@ export function getNodeColor(type: NodeType, category?: ServiceCategory): string host_physical: '#10B981', host_vm: '#14B8A6', host_container: '#F59E0B', + vm_lxc: '#22D3EE', + vm_qemu: '#06B6D4', + systemd_service: '#A78BFA', service: getServiceColor(category), volume: '#A855F7', mount: '#84CC16',