javierdonoso88/storm-response-commander

GitHub: javierdonoso88/storm-response-commander

基于 Anthropic Claude 和 SAP AI Core 的多智能体电力风暴应急响应模拟系统,通过 6 个协作 AI 智能体实时编排故障分诊、抢修调度和资源分配等完整指挥流程。

Stars: 0 | Forks: 0

# ⚡ Storm-Response Commander 用于模拟风暴导致电力 incidents 响应的多 AI 智能体系统。该系统模拟了 Iberdrola 在 Comarques de Girona 的真实运营情况:47 个活跃故障,22 支抢修队,拥有备用电池的关键设施以及即将到来的第二波风暴窗口。 **在线演示:** [storm-response-commander.cfapps.eu10.hana.ondemand.com](https://storm-response-commander.cfapps.eu10.hana.ondemand.com) ## 功能说明 在启动模拟时,一个 Claude 编排器会协调 6 个专门的智能体,它们会实时针对当前场景进行推理: | 阶段 | 智能体 | 模式 | |------|---------|------| | 1 — 评估 | Triage · Rerouting · Priority | 并行 | | 2 — 执行 | Crew-Dispatch → Resource → Comms | 顺序 | 每个智能体接收场景状态,使用特定工具做出决策(切换故障、派遣抢修队、分配物资、发送通信),并发出 SSE 事件,实时更新地图、日志和 KPI。 ## 架构 ``` ┌─────────────────────────────────────────────────────────────────┐ │ React Frontend │ │ MapPanel · LogPanel · GanttPanel · ParametersPanel · StatsPanel│ │ (Comms Feed + Acciones SAP) │ └────────────────────┬────────────────────────────────────────────┘ │ SSE /api/simulate ┌────────────────────▼────────────────────────────────────────────┐ │ Express Server │ │ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ Orchestrator (Claude) │ │ │ │ invoke_triage ─┐ │ │ │ │ invoke_rerouting ─┤ Promise.all (Fase 1) │ │ │ │ invoke_priority ─┘ │ │ │ │ invoke_crew_dispatch → invoke_resource → invoke_comms │ │ │ │ finalize │ │ │ └──────────────────────────┬──────────────────────────────┘ │ │ │ runAgent() │ │ ┌───────────┐ ┌──────────┐ │ ┌──────────┐ ┌──────────────┐ │ │ │ Triage │ │Rerouting │ │ │ Priority │ │Crew-Dispatch │ │ │ └───────────┘ └──────────┘ │ └──────────┘ └──────────────┘ │ │ ┌───────────┐ ┌──────────┐ │ │ │ │ Resource │ │ Comms │ │ │ │ └───────────┘ └──────────┘ │ │ │ │ │ │ ┌───────────────────────────▼──────────────────────────────┐ │ │ │ SAP AI Core — Anthropic Claude Sonnet 4.6 │ │ │ │ OAuth2 · /invoke · /invoke-with-response-stream │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────┘ ``` 有关完整技术细节,请参阅 [docs/architecture.md](docs/architecture.md)。 ## 基础场景 - **127,000 名客户** — Comarques de Girona - **47 个活跃故障**:22 个可切换故障(远程控制),7 台变压器,18 条电缆 - **7 个关键设施**:医院、CPDs、透析中心、污水处理厂、警察局 — 均配备有限备用电池 - **22 支抢修队**:分布在 6 个基地(Girona、Figueres、Olot、Banyoles、Lloret、Blanes) - **可配置参数**:SLA、可用抢修队、有限库存、第二波风暴窗口 ## 技术栈 | 层级 | 技术栈 | |------|-------| | 前端 | React 18、TypeScript、Vite、Tailwind CSS、React-Leaflet | | 后端 | Node.js、Express、SSE | | AI | 通过 SAP AI Core 使用 Anthropic Claude Sonnet 4.6 | | SDK | `@anthropic-ai/sdk` 及用于 AI Core 的自定义适配器 | | 部署 | SAP BTP Cloud Foundry (`nodejs_buildpack`) | ## 本地安装 **前提条件**:Node.js ≥ 18,具备 SAP AI Core 访问权限 ``` git clone https://github.com/javierdonoso88/storm-response-commander cd storm-response-commander npm install ``` 配置环境变量(可选 — 演示租户已提供默认值): ``` export AICORE_CLIENT_ID=... export AICORE_CLIENT_SECRET=... export AICORE_TOKEN_URL=... export AICORE_API_URL=... export AICORE_DEPLOYMENT_ID=... export AICORE_RESOURCE_GROUP=default ``` 以开发模式启动: ``` npm run dev # 客户端:http://localhost:5173 # 服务器:http://localhost:3001 ``` ## 脚本命令 | 命令 | 说明 | |---------|-------------| | `npm run dev` | 以开发模式启动服务器 + 客户端(支持热重载) | | `npm run build` | 编译 TypeScript + Vite 以用于生产环境 | | `npm start` | 启动生产环境服务器 | ## Cloud Foundry 部署 ``` cf push ``` Buildpack 会在 staging 阶段自动执行 `heroku-postbuild` → `npm run build`,因此在部署前无需在本地进行编译。 CF 中的环境变量: ``` cf set-env storm-response-commander AICORE_CLIENT_ID ... cf set-env storm-response-commander AICORE_CLIENT_SECRET ... cf set-env storm-response-commander AICORE_TOKEN_URL ... cf set-env storm-response-commander AICORE_DEPLOYMENT_ID ... cf restage storm-response-commander ``` ## 项目结构 ``` src/ ├── client/ │ ├── App.tsx # Layout principal y orquestación de estado │ ├── hooks/useSimulation.ts # Gestión de SSE y estado de simulación │ ├── components/ │ │ ├── MapPanel.tsx # Mapa de Girona con nodos de fallo │ │ ├── LogPanel.tsx # Logs CoT en tiempo real por agente │ │ ├── ParametersPanel.tsx # Controles + KPIs │ │ ├── GanttPanel.tsx # Timeline de ejecución de agentes │ │ └── StatsPanel.tsx # Comms Feed + Acciones SAP (integración por agente) │ └── data/mapData.ts # Posiciones geográficas └── server/ ├── index.ts # Express server ├── routes/simulation.ts # Endpoint SSE /api/simulate └── engine/ ├── types.ts # Tipos: Fault, Crew, SimEvent, SimParams… ├── scenario.ts # Escenario base y buildScenario() ├── anthropicClient.ts # Adaptador SAP AI Core + SSE transformer ├── agentRunner.ts # Bucle genérico de tool-use con streaming ├── orchestrator.ts # Agente orquestador + ejecución paralela Fase 1 └── agents/ ├── triage.ts # Clasificación de fallos ├── rerouting.ts # Conmutación remota ├── priority.ts # Rankeado + alertas regulatorias ├── crew-dispatch.ts # Asignación de brigadas ├── resource.ts # Inventario + conflictos de material └── comms.ts # SMS · Prensa · Regulatorio ``` ## 更多文档 - [技术架构](docs/architecture.md) — SSE、AI Core 适配器、流式模型 - [智能体参考](docs/agents.md) — 各智能体的工具、提示和决策
标签:Anthropic Claude, Express, GIS地图, Iberdrola, MITM代理, PyRIT, React, SAP AI Core, SAP BTP, SSE, Syscalls, 人工智能, 公共事业管理, 决策支持系统, 多智能体协同, 多智能体系统, 大型语言模型, 实时仿真, 应急管理, 智慧电网, 灾害响应模拟, 用户模式Hook绕过, 电网故障抢修, 电网韧性, 自动化攻击, 资源调度, 配电网络, 风暴应急响应