diff --git a/.awoooi-agent-rules.md b/.awoooi-agent-rules.md index 9bd4dcd4..6269c6ed 100644 --- a/.awoooi-agent-rules.md +++ b/.awoooi-agent-rules.md @@ -218,7 +218,7 @@ const API_KEY = process.env.API_KEY | **機械爪藍** | `#4A90D9` (claw-blue) | AI 核心 LED 發光色 | | **思維紫** | `#8B5CF6` (status-thinking) | AI 思考狀態專用 | -#### ClawBot 視覺規範 +#### OpenClaw 視覺規範 ```tsx // 機械爪面板 - 3D 骨架風格 @@ -312,7 +312,7 @@ import { Eye, Sparkles } from 'lucide-react' |-----|------|------| | **192.168.0.110** | DevOps 金庫 | Harbor:5000 (`awoooi/` Project), GH Runner (`awoooi-runner`) | | **192.168.0.112** | Kali Security | Scanner API:8080 (Header 區分: `X-Source: awoooi`) | -| **192.168.0.188** | AI+Web 中心 | Nginx SSL, Ollama:11434, **ClawBot:8089**, **SigNoz:3301 (OTEL 收集器)** | +| **192.168.0.188** | AI+Web 中心 | Nginx SSL, Ollama:11434, **OpenClaw:8089**, **SigNoz:3301 (OTEL 收集器)** | | **192.168.0.120** | K3s Master | **awoooi-prod (API:32334, Frontend:32335)** ⚠️ 唯一部署目標 | | **192.168.0.121** | K3s Worker | HA 備援 | @@ -320,7 +320,7 @@ import { Eye, Sparkles } from 'lucide-react' > ⚠️ **絕對禁令**: 禁止部署 UAT 環境,僅使用 Prod (32334/32335) -| 環境 | Frontend | API | ClawBot | 狀態 | +| 環境 | Frontend | API | OpenClaw | 狀態 | |------|----------|-----|---------|------| | **AWOOOI Prod** | **32335** | **32334** | 8089 | ✅ 唯一部署目標 | | ~~AWOOOI UAT~~ | ~~32235~~ | ~~32234~~ | - | ❌ **已廢除** | @@ -531,7 +531,7 @@ scp awoooi.wooo.work.conf root@192.168.0.188:/etc/nginx/ 此操作將: - 向 Webhook API 發送模擬告警 -- 觸發 ClawBot AI 分析 +- 觸發 OpenClaw AI 分析 - 建立一筆待簽核卡片 統帥,是否授權執行? [Y/n] @@ -786,6 +786,62 @@ qaCheck() --- +## 🧠 架構溯源義務 (Architecture Traceability) + +> **2026-03-23 新增 (ADR-008)**: 模組化開發必須具備跨模組架構記憶 + +### 條款 17:跨模組溯源義務 + +**在修改任何 `packages/` 下的核心積木前,AI 必須先讀取以下檔案:** + +| 檔案 | 用途 | +|------|------| +| `docs/adr/` | 架構決策記錄 (ADR) | +| `docs/api/api-contract.yaml` | API 通訊契約 | +| `docs/ARCHITECTURE_MEMORY.md` | 模組地圖索引 | + +**確保新代碼與既有模組通訊契約相容。** + +### 條款 18:自動化 ADR 更新 + +**當新增獨立模組或重大 API 變更時,AI 必須主動產出 ADR:** + +```markdown +# ADR-XXX: [決策標題] + +**狀態**: 已批准/提議中 +**日期**: YYYY-MM-DD + +## 背景 +[為什麼需要這個決策] + +## 決策 +[採用的方案] + +## 後果 +[優缺點分析] +``` + +### 條款 19:模組註冊義務 + +**新增積木後,必須在 `docs/ARCHITECTURE_MEMORY.md` 登記:** + +- 模組名稱與職責 +- 對外介面 (ABC/API) +- 關聯 ADR 編號 + +### 條款 20:接口防撞檢查 + +**執行 `pnpm build` 或 `pip install` 前,必須先確認模組間無命名衝突:** + +```bash +# 檢查 Python 模組是否可引用 +python -c "from lewooogo_brain.interfaces import IProposalEngine; print('OK')" +python -c "from lewooogo_data.interfaces import IMemoryProvider; print('OK')" +``` + +--- + ## 🏗️ 專案結構 ``` @@ -795,13 +851,9 @@ awoooi/ │ ├── web/ # Next.js 前端 │ └── api/ # FastAPI BFF Gateway ├── packages/ -│ ├── lewooogo-core/ # 核心引擎 -│ ├── lewooogo-input/ # INPUT 積木 -│ ├── lewooogo-brain/ # BRAIN 積木 -│ ├── lewooogo-output/ # OUTPUT 積木 -│ ├── lewooogo-action/ # ACTION 積木 -│ ├── lewooogo-data/ # DATA 積木 -│ └── lewooogo-ui/ # UI 積木 +│ ├── lewooogo-core/ # 核心引擎 (TS) +│ ├── lewooogo-brain/ # BRAIN 積木 (Python) ← ADR-008 +│ ├── lewooogo-data/ # DATA 積木 (Python) ← ADR-008 ├── docs/ │ ├── adr/ # 架構決策記錄 │ └── api/ # OpenAPI 規格 diff --git a/apps/api/src/core/config.py b/apps/api/src/core/config.py index d3ec6c78..8be384b2 100644 --- a/apps/api/src/core/config.py +++ b/apps/api/src/core/config.py @@ -105,8 +105,8 @@ class Settings(BaseSettings): ) # Deprecated: use OPENCLAW_URL instead CLAWBOT_URL: str = Field( - default="http://192.168.0.188:8088", # 🔧 修正: ClawBot 實際 port 是 8088 - description="[Deprecated] ClawBot URL - use OPENCLAW_URL", + default="http://192.168.0.188:8088", # 🔧 修正: OpenClaw 實際 port 是 8088 + description="[Deprecated] Legacy ClawBot URL - use OPENCLAW_URL", ) KALI_SCANNER_URL: str = Field( default="http://192.168.0.112:8080", diff --git a/apps/web/tailwind.config.ts b/apps/web/tailwind.config.ts index 17c80626..29cecb7e 100644 --- a/apps/web/tailwind.config.ts +++ b/apps/web/tailwind.config.ts @@ -37,7 +37,7 @@ const config: Config = { critical: '#FF3300', // 橘紅 - 嚴重 idle: '#A3A3A3', // 灰色 - 閒置 }, - // 智慧之眼 - ClawBot 品牌藍 + // 智慧之眼 - OpenClaw 品牌藍 claw: { blue: '#4A90D9', // 智慧之眼核心藍 'blue-light': '#6BA3E0', // 淺藍光暈 diff --git a/docs/api/openapi.yaml b/docs/api/openapi.yaml new file mode 100644 index 00000000..a46eebb0 --- /dev/null +++ b/docs/api/openapi.yaml @@ -0,0 +1,1755 @@ +openapi: 3.1.0 +info: + title: AWOOOI API + description: AWOOOI 智能運維平台 API - 由 leWOOOgo Engine 驅動 + version: 1.0.0 +paths: + /api/v1/health: + get: + tags: + - Health + summary: Get Health + description: 'Full health check with real component probes + + + Performs async health checks on all external dependencies: + + - PostgreSQL: Primary database + + - Redis: Cache layer + + - Ollama: Local LLM service + + - OpenClaw: AI Agent service + + - SigNoz: Observability platform + + + Returns overall system status based on component health.' + operationId: get_health_api_v1_health_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/HealthResponse' + /api/v1/health/ready: + get: + tags: + - Health + summary: Get Readiness + description: 'K8s readinessProbe + + + Returns 200 when the service is ready to accept traffic. + + Lightweight check - doesn''t probe external services.' + operationId: get_readiness_api_v1_health_ready_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + additionalProperties: + type: string + type: object + title: Response Get Readiness Api V1 Health Ready Get + /api/v1/health/live: + get: + tags: + - Health + summary: Get Liveness + description: 'K8s livenessProbe + + + Returns 200 when the service is alive. + + Used by K8s to determine if pod needs restart.' + operationId: get_liveness_api_v1_health_live_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + additionalProperties: + type: string + type: object + title: Response Get Liveness Api V1 Health Live Get + /api/v1/dashboard: + get: + tags: + - Dashboard + summary: Get Dashboard + description: 'Get aggregated dashboard data + + + Fetches status from all four hosts using asyncio.gather. + + Returns CPU/Memory metrics when MOCK_MODE is enabled.' + operationId: get_dashboard_api_v1_dashboard_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/DashboardResponse' + /api/v1/dashboard/stream: + get: + tags: + - Dashboard + summary: Stream Dashboard + description: "SSE real-time dashboard updates\n\nEnterprise-grade SSE implementation\ + \ with:\n- Automatic disconnect detection\n- Resource cleanup on disconnect\n\ + - Heartbeat mechanism (every 15s)\n- Backpressure handling\n\nClient Usage\ + \ (JavaScript):\n```javascript\nconst es = new EventSource('/api/v1/dashboard/stream');\n\ + es.addEventListener('host_update', (e) => {\n const data = JSON.parse(e.data);\n\ + \ console.log('Host update:', data);\n});\nes.addEventListener('heartbeat',\ + \ (e) => {\n console.log('Heartbeat received');\n});\nes.onerror = (e)\ + \ => {\n console.log('Connection lost, reconnecting...');\n};\n```\n\n\ + Disconnect Detection:\n- When browser closes or navigates away\n- When network\ + \ connection is lost\n- When client calls es.close()\n\nThe server automatically\ + \ detects disconnection via:\n1. asyncio.CancelledError on generator exit\n\ + 2. Heartbeat timeout detection\n3. Queue full backpressure" + operationId: stream_dashboard_api_v1_dashboard_stream_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + /api/v1/dashboard/hosts: + get: + tags: + - Dashboard + summary: Get Hosts + description: 'Get four-host architecture status + + + Returns the configured four-host IPs and their roles.' + operationId: get_hosts_api_v1_dashboard_hosts_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + additionalProperties: true + type: object + title: Response Get Hosts Api V1 Dashboard Hosts Get + /api/v1/dashboard/stream/clients: + get: + tags: + - Dashboard + summary: Get Stream Clients + description: Get current SSE client count (debug endpoint) + operationId: get_stream_clients_api_v1_dashboard_stream_clients_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + additionalProperties: true + type: object + title: Response Get Stream Clients Api V1 Dashboard Stream Clients + Get + /api/v1/dashboard/snapshot: + get: + tags: + - Dashboard + summary: Get Dashboard Snapshot + description: 'Full dashboard snapshot for SSE hydration + + + Client workflow: + + 1. Connect to /dashboard/stream (SSE) + + 2. Immediately fetch /dashboard/snapshot + + 3. Apply snapshot as initial state + + 4. Process SSE events for incremental updates + + + This ensures no alerts are missed during connection setup.' + operationId: get_dashboard_snapshot_api_v1_dashboard_snapshot_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + additionalProperties: true + type: object + title: Response Get Dashboard Snapshot Api V1 Dashboard Snapshot Get + /api/v1/approvals/k8s-test: + get: + tags: + - HITL Approvals + - HITL Approvals + summary: 測試 K8s 連線 + description: 連接 K3s 叢集並列出所有 Namespace。用於驗證 kubeconfig 設定。 + operationId: test_k8s_connection_api_v1_approvals_k8s_test_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + additionalProperties: true + type: object + title: Response Test K8S Connection Api V1 Approvals K8S Test Get + /api/v1/approvals/pending: + get: + tags: + - HITL Approvals + - HITL Approvals + summary: 取得待簽核清單 + description: 獲取所有等待簽核的授權請求,供戰情室前端渲染。 + operationId: get_pending_approvals_api_v1_approvals_pending_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/PendingApprovalsResponse' + /api/v1/approvals: + post: + tags: + - HITL Approvals + - HITL Approvals + summary: 建立授權請求 + description: 建立新的 HITL 授權請求。LOW 風險自動批准,MEDIUM/CRITICAL 需要簽核。 + operationId: create_approval_api_v1_approvals_post + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApprovalRequestCreate' + required: true + responses: + '201': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/ApprovalRequestResponse' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/approvals/{approval_id}/sign: + post: + tags: + - HITL Approvals + - HITL Approvals + summary: 簽核授權請求 + description: 提交簽核。當滿足所需簽核數時,狀態轉為 APPROVED 並觸發背景執行。 + operationId: sign_approval_api_v1_approvals__approval_id__sign_post + parameters: + - name: approval_id + in: path + required: true + schema: + type: string + format: uuid + title: Approval Id + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SignRequest' + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/SignResponse' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/approvals/{approval_id}/reject: + post: + tags: + - HITL Approvals + - HITL Approvals + summary: 拒絕授權請求 + description: 拒絕並終止授權請求。狀態轉為 REJECTED。 + operationId: reject_approval_api_v1_approvals__approval_id__reject_post + parameters: + - name: approval_id + in: path + required: true + schema: + type: string + format: uuid + title: Approval Id + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RejectRequest' + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/ApprovalRequestResponse' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/ai/analyze-and-propose: + post: + tags: + - AI Decision + - AI Decision + summary: AI 分析並自動立案 + description: 拉取當前監控數據,交給 OpenClaw 分析。若判定需要修復,自動建立 ApprovalRecord。 + operationId: analyze_and_propose_api_v1_ai_analyze_and_propose_post + requestBody: + content: + application/json: + schema: + anyOf: + - $ref: '#/components/schemas/OpenClawAnalysisRequest' + - type: 'null' + title: Request + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/OpenClawAnalysisResponse' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/ai/status: + get: + tags: + - AI Decision + - AI Decision + summary: AI 服務狀態 + description: 檢查 OpenClaw AI 服務狀態與可用的 AI 提供者。 + operationId: get_ai_status_api_v1_ai_status_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + additionalProperties: true + type: object + title: Response Get Ai Status Api V1 Ai Status Get + /api/v1/plugins: + get: + tags: + - Plugins + summary: List Plugins + description: 列出所有已註冊 Plugin + operationId: list_plugins_api_v1_plugins_get + parameters: + - name: category + in: query + required: false + schema: + anyOf: + - enum: + - INPUT + - BRAIN + - OUTPUT + - ACTION + - DATA + - UI + type: string + - type: 'null' + title: Category + - name: enabled + in: query + required: false + schema: + anyOf: + - type: boolean + - type: 'null' + title: Enabled + responses: + '200': + description: Successful Response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Plugin' + title: Response List Plugins Api V1 Plugins Get + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/plugins/{plugin_id}: + get: + tags: + - Plugins + summary: Get Plugin + description: 取得 Plugin 詳情 + operationId: get_plugin_api_v1_plugins__plugin_id__get + parameters: + - name: plugin_id + in: path + required: true + schema: + type: string + title: Plugin Id + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Plugin' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/plugins/{plugin_id}/health: + get: + tags: + - Plugins + summary: Get Plugin Health + description: Plugin 健康檢查 + operationId: get_plugin_health_api_v1_plugins__plugin_id__health_get + parameters: + - name: plugin_id + in: path + required: true + schema: + type: string + title: Plugin Id + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/PluginHealth' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/pipelines: + get: + tags: + - Pipelines + summary: List Pipelines + description: 列出工作流 + operationId: list_pipelines_api_v1_pipelines_get + parameters: + - name: status + in: query + required: false + schema: + anyOf: + - enum: + - draft + - active + - paused + - archived + type: string + - type: 'null' + title: Status + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/PipelineList' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + post: + tags: + - Pipelines + summary: Create Pipeline + description: 建立工作流 + operationId: create_pipeline_api_v1_pipelines_post + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PipelineCreate' + responses: + '201': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Pipeline' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/pipelines/{pipeline_id}: + get: + tags: + - Pipelines + summary: Get Pipeline + description: 取得工作流詳情 + operationId: get_pipeline_api_v1_pipelines__pipeline_id__get + parameters: + - name: pipeline_id + in: path + required: true + schema: + type: string + format: uuid + title: Pipeline Id + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Pipeline' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + delete: + tags: + - Pipelines + summary: Delete Pipeline + description: 刪除工作流 + operationId: delete_pipeline_api_v1_pipelines__pipeline_id__delete + parameters: + - name: pipeline_id + in: path + required: true + schema: + type: string + format: uuid + title: Pipeline Id + responses: + '204': + description: Successful Response + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/pipelines/{pipeline_id}/trigger: + post: + tags: + - Pipelines + summary: Trigger Pipeline + description: 手動觸發工作流 + operationId: trigger_pipeline_api_v1_pipelines__pipeline_id__trigger_post + parameters: + - name: pipeline_id + in: path + required: true + schema: + type: string + format: uuid + title: Pipeline Id + responses: + '202': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/PipelineExecution' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/agent/chat: + post: + tags: + - Agent + summary: Chat With Agent + description: 與 OpenClaw 對話 + operationId: chat_with_agent_api_v1_agent_chat_post + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChatRequest' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/ChatResponse' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/agent/chat/stream: + post: + tags: + - Agent + summary: Chat With Agent Stream + description: 與 OpenClaw 對話 (SSE 串流) + operationId: chat_with_agent_stream_api_v1_agent_chat_stream_post + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChatRequest' + required: true + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/agent/status: + get: + tags: + - Agent + summary: Get Agent Status + description: OpenClaw 狀態 + operationId: get_agent_status_api_v1_agent_status_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/AgentStatus' + /api/v1/agent/thinking: + get: + tags: + - Agent + summary: Get Agent Thinking + description: 'OpenClaw 思考軌跡 (SSE 串流) + + Phase 1.2: 真實串接 Ollama at 192.168.0.188:11434' + operationId: get_agent_thinking_api_v1_agent_thinking_get + parameters: + - name: prompt + in: query + required: false + schema: + type: string + description: 發送給 AI 的提示詞 + default: 你是 AWOOOI 智能運維助手。請簡短分析一下目前系統的健康狀態,用中文回答。 + title: Prompt + description: 發送給 AI 的提示詞 + - name: model + in: query + required: false + schema: + type: string + description: Ollama 模型名稱 + default: llama3.2:latest + title: Model + description: Ollama 模型名稱 + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' + /api/v1/notifications/channels: + get: + tags: + - Notifications + summary: List Notification Channels + description: 列出通知頻道 + operationId: list_notification_channels_api_v1_notifications_channels_get + responses: + '200': + description: Successful Response + content: + application/json: + schema: + items: + $ref: '#/components/schemas/NotificationChannel' + type: array + title: Response List Notification Channels Api V1 Notifications Channels + Get + /api/v1/notifications/send: + post: + tags: + - Notifications + summary: Send Notification + description: 發送通知 + operationId: send_notification_api_v1_notifications_send_post + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationRequest' + required: true + responses: + '202': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/NotificationResult' + '422': + description: Validation Error + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPValidationError' +components: + schemas: + AIRiskLevel: + type: string + enum: + - low + - medium + - critical + title: AIRiskLevel + description: AI 風險評估等級 + AgentStatus: + properties: + status: + type: string + enum: + - idle + - thinking + - executing + - waiting_approval + title: Status + active_conversations: + type: integer + title: Active Conversations + current_task: + anyOf: + - type: string + - type: 'null' + title: Current Task + last_activity: + anyOf: + - type: string + format: date-time + - type: 'null' + title: Last Activity + type: object + required: + - status + - active_conversations + title: AgentStatus + ApprovalRequestCreate: + properties: + action: + type: string + title: Action + description: 執行動作描述 + description: + type: string + title: Description + description: 詳細說明 + risk_level: + $ref: '#/components/schemas/RiskLevel' + description: 風險等級 + blast_radius: + $ref: '#/components/schemas/BlastRadius' + dry_run_checks: + items: + $ref: '#/components/schemas/DryRunCheck' + type: array + title: Dry Run Checks + requested_by: + type: string + title: Requested By + description: 請求發起者 + expires_at: + anyOf: + - type: string + format: date-time + - type: 'null' + title: Expires At + description: 到期時間 + metadata: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Metadata + description: 額外元資料 + type: object + required: + - action + - description + - risk_level + - requested_by + title: ApprovalRequestCreate + description: 建立授權請求 (API 輸入) + ApprovalRequestResponse: + properties: + id: + type: string + title: Id + action: + type: string + title: Action + description: + type: string + title: Description + status: + $ref: '#/components/schemas/ApprovalStatus' + risk_level: + $ref: '#/components/schemas/RiskLevel' + blast_radius: + $ref: '#/components/schemas/BlastRadius' + dry_run_checks: + items: + $ref: '#/components/schemas/DryRunCheck' + type: array + title: Dry Run Checks + required_signatures: + type: integer + title: Required Signatures + current_signatures: + type: integer + title: Current Signatures + signatures: + items: + $ref: '#/components/schemas/Signature' + type: array + title: Signatures + requested_by: + type: string + title: Requested By + created_at: + type: string + format: date-time + title: Created At + expires_at: + anyOf: + - type: string + format: date-time + - type: 'null' + title: Expires At + resolved_at: + anyOf: + - type: string + format: date-time + - type: 'null' + title: Resolved At + type: object + required: + - id + - action + - description + - status + - risk_level + - blast_radius + - dry_run_checks + - required_signatures + - current_signatures + - signatures + - requested_by + - created_at + - expires_at + - resolved_at + title: ApprovalRequestResponse + description: 授權請求 API 回應 + ApprovalStatus: + type: string + enum: + - pending + - approved + - rejected + - expired + - execution_success + - execution_failed + title: ApprovalStatus + description: "授權請求狀態機\n\nPENDING → APPROVED → EXECUTION_SUCCESS\n \ + \ → EXECUTION_FAILED\nPENDING → REJECTED\nPENDING → EXPIRED" + BlastRadius: + properties: + affected_pods: + type: integer + minimum: 0.0 + title: Affected Pods + default: 0 + estimated_downtime: + type: string + title: Estimated Downtime + default: '0' + related_services: + items: + type: string + type: array + title: Related Services + data_impact: + $ref: '#/components/schemas/DataImpact' + default: none + type: object + title: BlastRadius + description: 爆炸半徑 - 影響範圍評估 + ChatRequest: + properties: + message: + type: string + title: Message + conversation_id: + anyOf: + - type: string + format: uuid + - type: 'null' + title: Conversation Id + context: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Context + type: object + required: + - message + title: ChatRequest + ChatResponse: + properties: + message: + type: string + title: Message + conversation_id: + type: string + format: uuid + title: Conversation Id + actions: + anyOf: + - items: + $ref: '#/components/schemas/src__routes__agent__SuggestedAction' + type: array + - type: 'null' + title: Actions + requires_approval: + type: boolean + title: Requires Approval + default: false + approval_id: + anyOf: + - type: string + format: uuid + - type: 'null' + title: Approval Id + type: object + required: + - message + - conversation_id + title: ChatResponse + OpenClawAnalysisRequest: + properties: + force_refresh: + type: boolean + title: Force Refresh + description: 強制重新抓取監控數據 + default: false + type: object + title: OpenClawAnalysisRequest + description: 分析請求 + OpenClawAnalysisResponse: + properties: + success: + type: boolean + title: Success + message: + type: string + title: Message + decision: + anyOf: + - $ref: '#/components/schemas/OpenClawDecision' + - type: 'null' + approval_created: + type: boolean + title: Approval Created + description: 是否已建立待簽核卡片 + default: false + approval_id: + anyOf: + - type: string + - type: 'null' + title: Approval Id + description: 建立的 ApprovalRecord ID + ai_provider: + type: string + title: Ai Provider + description: 使用的 AI 提供者 (ollama/gemini/claude) + default: unknown + raw_llm_response: + anyOf: + - type: string + - type: 'null' + title: Raw Llm Response + description: LLM 原始回應 (debug 用) + type: object + required: + - success + - message + title: OpenClawAnalysisResponse + description: 分析回應 + OpenClawDecision: + properties: + suggested_action: + $ref: '#/components/schemas/src__models__ai__SuggestedAction' + description: 建議執行的操作類型 + target_resource: + type: string + title: Target Resource + description: 目標資源名稱 (e.g., 'harbor', 'grafana') + namespace: + type: string + title: Namespace + description: Kubernetes namespace + default: default + risk_level: + $ref: '#/components/schemas/AIRiskLevel' + description: 風險等級評估 + reasoning: + type: string + title: Reasoning + description: 給人類主管看的分析理由 (繁體中文) + deviation_analysis: + type: string + title: Deviation Analysis + description: 基準線偏差分析 (例如:CPU 85% 超出基準線 45% 達 +4σ) + default: '' + confidence: + type: number + maximum: 1.0 + minimum: 0.0 + title: Confidence + description: 決策信心度 (0-1) + default: 0.8 + affected_services: + items: + type: string + type: array + title: Affected Services + description: 可能受影響的相關服務 + type: object + required: + - suggested_action + - target_resource + - risk_level + - reasoning + title: OpenClawDecision + description: 'OpenClaw AI 決策輸出 (強制結構化) + + + LLM 必須輸出此格式的 JSON,否則視為解析失敗' + ComponentHealth: + properties: + status: + type: string + enum: + - up + - down + - degraded + title: Status + latency_ms: + anyOf: + - type: number + - type: 'null' + title: Latency Ms + error: + anyOf: + - type: string + - type: 'null' + title: Error + type: object + required: + - status + title: ComponentHealth + description: Individual component health status + DashboardResponse: + properties: + timestamp: + type: string + format: date-time + title: Timestamp + environment: + type: string + title: Environment + mock_mode: + type: boolean + title: Mock Mode + overall_status: + type: string + title: Overall Status + hosts: + items: + $ref: '#/components/schemas/HostStatusResponse' + type: array + title: Hosts + alerts_count: + type: integer + title: Alerts Count + pending_approvals: + type: integer + title: Pending Approvals + type: object + required: + - timestamp + - environment + - mock_mode + - overall_status + - hosts + - alerts_count + - pending_approvals + title: DashboardResponse + description: Dashboard aggregated data + DataImpact: + type: string + enum: + - none + - read_only + - write + - destructive + title: DataImpact + description: 資料影響類型 + DryRunCheck: + properties: + name: + type: string + title: Name + passed: + type: boolean + title: Passed + message: + anyOf: + - type: string + - type: 'null' + title: Message + type: object + required: + - name + - passed + title: DryRunCheck + description: Dry-Run 預演檢查結果 + HTTPValidationError: + properties: + detail: + items: + $ref: '#/components/schemas/ValidationError' + type: array + title: Detail + type: object + title: HTTPValidationError + HealthResponse: + properties: + status: + type: string + enum: + - healthy + - degraded + - unhealthy + title: Status + version: + type: string + title: Version + environment: + type: string + title: Environment + mock_mode: + type: boolean + title: Mock Mode + timestamp: + type: string + format: date-time + title: Timestamp + components: + additionalProperties: + $ref: '#/components/schemas/ComponentHealth' + type: object + title: Components + type: object + required: + - status + - version + - environment + - mock_mode + - timestamp + - components + title: HealthResponse + description: Full health check response + HostStatusResponse: + properties: + ip: + type: string + title: Ip + name: + type: string + title: Name + role: + type: string + title: Role + status: + type: string + title: Status + services: + items: + additionalProperties: true + type: object + type: array + title: Services + metrics: + anyOf: + - additionalProperties: + type: number + type: object + - type: 'null' + title: Metrics + type: object + required: + - ip + - name + - role + - status + - services + title: HostStatusResponse + description: Host status for API response + NotificationChannel: + properties: + id: + type: string + title: Id + type: + type: string + enum: + - telegram + - slack + - line + - email + - discord + - webhook + title: Type + name: + type: string + title: Name + enabled: + type: boolean + title: Enabled + type: object + required: + - id + - type + - name + - enabled + title: NotificationChannel + NotificationRequest: + properties: + channel_id: + type: string + title: Channel Id + message: + type: string + title: Message + template_id: + anyOf: + - type: string + - type: 'null' + title: Template Id + variables: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Variables + priority: + type: string + enum: + - low + - normal + - high + - urgent + title: Priority + default: normal + type: object + required: + - channel_id + - message + title: NotificationRequest + NotificationResult: + properties: + id: + type: string + format: uuid + title: Id + status: + type: string + enum: + - queued + - sent + - failed + title: Status + sent_at: + anyOf: + - type: string + format: date-time + - type: 'null' + title: Sent At + error: + anyOf: + - type: string + - type: 'null' + title: Error + type: object + required: + - id + - status + title: NotificationResult + PendingApprovalsResponse: + properties: + count: + type: integer + title: Count + approvals: + items: + $ref: '#/components/schemas/ApprovalRequestResponse' + type: array + title: Approvals + type: object + required: + - count + - approvals + title: PendingApprovalsResponse + description: 待簽核清單回應 + Pipeline: + properties: + id: + type: string + format: uuid + title: Id + name: + type: string + title: Name + description: + anyOf: + - type: string + - type: 'null' + title: Description + status: + type: string + enum: + - draft + - active + - paused + - archived + title: Status + steps: + items: + $ref: '#/components/schemas/PipelineStep' + type: array + title: Steps + created_at: + type: string + format: date-time + title: Created At + updated_at: + type: string + format: date-time + title: Updated At + type: object + required: + - id + - name + - status + - steps + - created_at + - updated_at + title: Pipeline + PipelineCreate: + properties: + name: + type: string + title: Name + description: + anyOf: + - type: string + - type: 'null' + title: Description + steps: + items: + $ref: '#/components/schemas/PipelineStep' + type: array + title: Steps + type: object + required: + - name + - steps + title: PipelineCreate + PipelineExecution: + properties: + id: + type: string + format: uuid + title: Id + pipeline_id: + type: string + format: uuid + title: Pipeline Id + status: + type: string + enum: + - pending + - running + - completed + - failed + - cancelled + title: Status + started_at: + type: string + format: date-time + title: Started At + completed_at: + anyOf: + - type: string + format: date-time + - type: 'null' + title: Completed At + type: object + required: + - id + - pipeline_id + - status + - started_at + title: PipelineExecution + PipelineList: + properties: + items: + items: + $ref: '#/components/schemas/Pipeline' + type: array + title: Items + next_page_token: + anyOf: + - type: string + - type: 'null' + title: Next Page Token + type: object + required: + - items + title: PipelineList + PipelineStep: + properties: + id: + type: string + title: Id + plugin_id: + type: string + title: Plugin Id + type: + type: string + enum: + - INPUT + - BRAIN + - OUTPUT + - ACTION + - DATA + - UI + title: Type + config: + anyOf: + - additionalProperties: true + type: object + - type: 'null' + title: Config + type: object + required: + - id + - plugin_id + - type + title: PipelineStep + Plugin: + properties: + id: + type: string + title: Id + name: + type: string + title: Name + version: + type: string + title: Version + category: + type: string + enum: + - INPUT + - BRAIN + - OUTPUT + - ACTION + - DATA + - UI + title: Category + enabled: + type: boolean + title: Enabled + description: + anyOf: + - type: string + - type: 'null' + title: Description + type: object + required: + - id + - name + - version + - category + - enabled + title: Plugin + PluginHealth: + properties: + plugin_id: + type: string + title: Plugin Id + status: + type: string + enum: + - healthy + - unhealthy + - unknown + title: Status + last_check: + type: string + format: date-time + title: Last Check + error: + anyOf: + - type: string + - type: 'null' + title: Error + type: object + required: + - plugin_id + - status + - last_check + title: PluginHealth + RejectRequest: + properties: + rejector_id: + type: string + title: Rejector Id + description: 退回者 ID + rejector_name: + type: string + title: Rejector Name + description: 退回者名稱 + reason: + type: string + title: Reason + description: 退回原因 + type: object + required: + - rejector_id + - rejector_name + - reason + title: RejectRequest + description: 退回請求 + RiskLevel: + type: string + enum: + - low + - medium + - critical + title: RiskLevel + description: '風險等級 - 決定所需簽核人數 + + + - LOW: 0 人,自動放行 + + - MEDIUM: 需 1 人簽核 + + - CRITICAL: 需 2 人 Multi-Sig 雙重簽核' + SignRequest: + properties: + signer_id: + type: string + title: Signer Id + description: 簽核者 ID + signer_name: + type: string + title: Signer Name + description: 簽核者名稱 + comment: + anyOf: + - type: string + - type: 'null' + title: Comment + description: 簽核備註 + type: object + required: + - signer_id + - signer_name + title: SignRequest + description: 簽核請求 + SignResponse: + properties: + success: + type: boolean + title: Success + message: + type: string + title: Message + approval: + $ref: '#/components/schemas/ApprovalRequestResponse' + execution_triggered: + type: boolean + title: Execution Triggered + description: 是否觸發執行 (當簽核數滿足時) + default: false + type: object + required: + - success + - message + - approval + title: SignResponse + description: 簽核回應 + Signature: + properties: + id: + type: string + format: uuid + title: Id + signer_id: + type: string + title: Signer Id + description: 簽核者 ID + signer_name: + type: string + title: Signer Name + description: 簽核者名稱 + signed_at: + type: string + format: date-time + title: Signed At + comment: + anyOf: + - type: string + - type: 'null' + title: Comment + type: object + required: + - signer_id + - signer_name + title: Signature + description: 簽核記錄 + ValidationError: + properties: + loc: + items: + anyOf: + - type: string + - type: integer + type: array + title: Location + msg: + type: string + title: Message + type: + type: string + title: Error Type + input: + title: Input + ctx: + type: object + title: Context + type: object + required: + - loc + - msg + - type + title: ValidationError + src__models__ai__SuggestedAction: + type: string + enum: + - RESTART_DEPLOYMENT + - DELETE_POD + - SCALE_DEPLOYMENT + - NO_ACTION + title: SuggestedAction + description: 'AI 建議操作類型 + + + 必須與 executor.OperationType 對應' + src__routes__agent__SuggestedAction: + properties: + id: + type: string + title: Id + label: + type: string + title: Label + description: + anyOf: + - type: string + - type: 'null' + title: Description + risk_level: + type: string + enum: + - low + - medium + - high + - critical + title: Risk Level + type: object + required: + - id + - label + - risk_level + title: SuggestedAction +