No description
Find a file
oliver ab1b76dd47 feat(start): auto-install web dependencies when WithWeb is enabled
Install frontend npm dependencies automatically in start_netx so fresh machines can bring up the 5173 Vite UI without separate manual npm install.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-06 17:38:14 +08:00
.github/ISSUE_TEMPLATE docs: add CONTRIBUTING and GitHub issue templates 2026-05-04 12:17:04 +08:00
netx_api feat: initialize netx ops tool repository 2026-05-03 23:43:21 +08:00
scripts feat(start): auto-install web dependencies when WithWeb is enabled 2026-05-06 17:38:14 +08:00
web feat: initialize netx ops tool repository 2026-05-03 23:43:21 +08:00
.env.example feat: initialize netx ops tool repository 2026-05-03 23:43:21 +08:00
.gitignore chore: ignore runtime process artifacts 2026-05-03 23:44:44 +08:00
CONTRIBUTING.md docs: add MIT license, security policy, and README updates 2026-05-04 12:53:56 +08:00
LICENSE docs: add MIT license, security policy, and README updates 2026-05-04 12:53:56 +08:00
mcp_install_payload.json feat: initialize netx ops tool repository 2026-05-03 23:43:21 +08:00
PROD_MIN_CHECKLIST.md feat: initialize netx ops tool repository 2026-05-03 23:43:21 +08:00
README.md feat(setup): add idempotent PostgreSQL bootstrap script for first install 2026-05-06 16:47:12 +08:00
requirements.txt fix: declare httpx dependency for netx API 2026-05-04 12:28:26 +08:00
SECURITY.md docs: add MIT license, security policy, and README updates 2026-05-04 12:53:56 +08:00

netx

Independent operations tool (web + MCP) for alarm-centric workflows.

Licensed under the MIT License. Security reports: SECURITY.md.

Phase 1 scope

  • Import ZTE Alarm Monitor Excel
  • Normalize and store alarms into an isolated PostgreSQL
  • Query and aggregate alarms via REST API
  • Expose the same read capabilities through MCP stdio tools
  • Quick diagnostics endpoint (/v1/diagnostics)
  • AP analysis bridge to oclaw (/v1/ap/analyze)

Environment setup (from scratch)

0) Prerequisites

  • Python 3.11+ (project currently tested on newer versions too)
  • Node.js 20+ (includes npm) for frontend
  • PostgreSQL 14+
  • PowerShell (Windows startup scripts use .ps1)

Quick check:

python --version
node --version
npm --version
psql --version

If Node/npm is missing (Windows example):

winget install OpenJS.NodeJS.LTS

For first-time setup on a new machine, run:

cd netx
powershell -ExecutionPolicy Bypass -File .\scripts\init_pg.ps1

The script is idempotent: it creates/repairs role netx, database netx, grants privileges, and verifies connection.

Common options:

powershell -ExecutionPolicy Bypass -File .\scripts\init_pg.ps1 `
  -SuperUser postgres `
  -SuperPassword "your-postgres-password" `
  -NetxUser netx `
  -NetxPassword "your-netx-password" `
  -NetxDatabase netx

2) Python virtual environment and backend deps

cd netx
python -m venv .venv
.\.venv\Scripts\python -m pip install --upgrade pip
.\.venv\Scripts\python -m pip install -r requirements.txt

3) Frontend deps (npm)

cd .\web
npm install
cd ..

4) Configure environment variables

Option A: temporary env vars in current shell

$env:NETX_DATABASE_URL = "postgresql+psycopg://netx:netx@127.0.0.1:5432/netx"
$env:NETX_HOST = "127.0.0.1"
$env:NETX_PORT = "8890"

Option B: local .env (recommended)

NETX_DATABASE_URL=postgresql+psycopg://postgres:admin123@127.0.0.1:5432/netx
NETX_OCLAW_ANALYZE_TOKEN=admin123
NETX_OCLAW_HEALTH_URL=http://127.0.0.1:8787/admin/api/ops-ai/health

5) Start services

Direct backend start:

.\.venv\Scripts\python -m netx_api.main

Or use automation scripts (recommended):

  • API only (background):
powershell -ExecutionPolicy Bypass -File .\scripts\start_netx.ps1 -SkipInstall -Background
  • API + Vite UI (background):
powershell -ExecutionPolicy Bypass -File .\scripts\start_netx.ps1 -SkipInstall -Background -WithWeb

Stop all started services:

powershell -ExecutionPolicy Bypass -File .\scripts\stop_netx.ps1 -Force

Primary web UI (Vite): http://127.0.0.1:5173/
API base: http://127.0.0.1:8890/

6) Optional: MCP server (for oclaw integration)

.\.venv\Scripts\python -m netx_api.mcp_server

Or install via payload:

  • netx/mcp_install_payload.json

Useful API endpoints

  • POST /v1/alarms/import
  • GET /v1/batches
  • GET /v1/batches/{batch_id}
  • GET /v1/batches/{batch_id}/errors.csv
  • GET /v1/alarms
  • GET /v1/alarms/aggregate
  • GET /v1/diagnostics?batch_id=...
  • GET /v1/integrations/status
  • POST /v1/ap/analyze

Web UI now includes an AI analyze panel that calls /v1/ap/analyze directly.

Set the same token on both sides:

  • oclaw env: OCLAW_OPS_AI_SHARED_TOKEN=<token>
  • netx env: NETX_OCLAW_ANALYZE_TOKEN=<token>

Optional: configure oclaw health check endpoint (defaults shown in .env.example):

  • NETX_OCLAW_HEALTH_URL=http://127.0.0.1:8787/admin/api/ops-ai/health

analyze-sync runs a full LLM + gateway turn in oclaw; if netx reports timeout errors, raise the read timeout (seconds):

  • NETX_OCLAW_ANALYZE_READ_TIMEOUT_SEC=180 (default 180; was effectively ~35s before)

Key sample file

Phase 1 parser (netx_api/config/parsers/zte_alarm_monitor_v1.yaml) is tuned for ZTE Alarm Monitor style exports. Use any local path: place your .xlsx on disk and import it from the web UI or API (POST /v1/alarms/import). A typical filename pattern is fm-active-Alarm Monitor-*-YYYYMMDDhhmmss.xlsx (columns are resolved via YAML aliases, not by absolute path).

Contributing

Fork / PR 流程与注意事项见仓库根目录 CONTRIBUTING.md。