mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +08:00
feat: integrate netx ops data access and unify prompt/workspace runtime
Migrate prompt templates into runtime workspaces, add network_ops netx toolchain (latest batch injection, raw fields, SQL query), and align docs/tests/admin/runtime wiring so ops analysis can query netx detail data through stable role-scoped paths. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
83f46f8aa2
commit
b0e0c05d8a
60 changed files with 1143 additions and 46 deletions
|
|
@ -7,7 +7,7 @@
|
|||
- `runtime/`:运行时主域(agent、gateway 执行流、skills/hooks/extensions、operations)。
|
||||
- `interfaces/`:对外接口层(HTTP、WS、Admin、Gateway method bridge)。
|
||||
- `platform/`:通用平台能力(配置、存储、LLM transport、文件层)。
|
||||
- `prompts/`:统一提示词体系(含 runtime 相关提示模板)。
|
||||
- `runtime/workspaces/_system/`:内置系统提示词 Markdown 树(原顶层 `prompts/`,与按角色分区的 `workspaces/<role>/` 并列);`runtime/prompt_templates/` 为加载与 frontmatter 解析。
|
||||
- `tests/`:测试代码(按你的要求保持顶层)。
|
||||
- `docs/`:设计文档、运维说明、迁移记录。
|
||||
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@
|
|||
|
||||
- `AIA_PROMPT_FRONTMATTER_STRICT`
|
||||
- 默认:`0`
|
||||
- 作用:`1` 时 `SKILL.md` / `oclaw/prompts/*.md` 的 frontmatter 必须为可解析 YAML;解析失败直接报错(不回落旧版行解析)
|
||||
- 生效:`oclaw/prompts/frontmatter.py`, `oclaw/prompts/loader.py`, `oclaw/oclaw_runtime/skills.py`
|
||||
- 作用:`1` 时 `SKILL.md` / `runtime/workspaces/_system/**/*.md` 的 frontmatter 必须为可解析 YAML;解析失败直接报错(不回落旧版行解析)
|
||||
- 生效:`oclaw/runtime/prompt_templates/frontmatter.py`, `oclaw/runtime/prompt_templates/loader.py`, `oclaw/runtime/skills.py`
|
||||
|
||||
- `AIA_SKILLS_PROMPT_IN_SYSTEM`
|
||||
- 默认:`1`(开启;仅当技能运行时启用)
|
||||
|
|
@ -83,7 +83,7 @@
|
|||
- `AIA_OCLAW_ROUTER_MODE`
|
||||
- 默认:`rule`
|
||||
- 取值:`rule`(启发式)或 `llm_json`(由当前 executor 的 `model.chat` 产出 `{mode,reason}` JSON;解析失败则回落 `rule`)
|
||||
- 说明:亦可通过同名环境变量覆盖;提示词见 `oclaw/prompts_runtime/router/decide_route.md`
|
||||
- 说明:亦可通过同名环境变量覆盖;提示词见 `runtime/workspaces/_system/router/decide_route.md`
|
||||
- 生效:`oclaw/oclaw_runtime/router.py`, `oclaw/oclaw_runtime/gateway.py`
|
||||
|
||||
- oclaw trace 字段与 `event_type` ↔ `oc_stage` 对照见 `oclaw/docs/oclaw-trace-taxonomy.md`
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@
|
|||
- 依赖:`PyYAML`(`requirements.txt`)。
|
||||
|
||||
### Changed
|
||||
- `oclaw/prompts/loader.py` 与 `oclaw/oclaw_runtime/skills.py` 统一使用 YAML 解析 frontmatter(失败时默认回落旧行解析,除非开启 STRICT)。
|
||||
- `runtime/prompt_templates/loader.py` 与 `runtime/skills.py` 统一使用 YAML 解析 frontmatter(失败时默认回落旧行解析,除非开启 STRICT)。(历史:`oclaw/prompts/` 已迁至 `runtime/workspaces/_system/` + `runtime/prompt_templates/`。)
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
105
docs/NETX_MCP_INTEGRATION.md
Normal file
105
docs/NETX_MCP_INTEGRATION.md
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
# netx MCP Integration (same-host)
|
||||
|
||||
This guide wires `oclaw` to the independent ops tool in:
|
||||
|
||||
- `D:/project/chatgpt/netx`
|
||||
|
||||
Assumption: `oclaw` and `netx` run on the same host.
|
||||
|
||||
## 1) Start netx API
|
||||
|
||||
In `D:/project/chatgpt/netx`:
|
||||
|
||||
```powershell
|
||||
python -m pip install -r requirements.txt
|
||||
$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"
|
||||
python -m netx_api.main
|
||||
```
|
||||
|
||||
Health check:
|
||||
|
||||
```powershell
|
||||
curl http://127.0.0.1:8890/health
|
||||
```
|
||||
|
||||
## 2) Register netx MCP in oclaw Admin
|
||||
|
||||
Use MCP install payload from:
|
||||
|
||||
- `D:/project/chatgpt/netx/mcp_install_payload.json`
|
||||
|
||||
Equivalent manual values:
|
||||
|
||||
- `source_type`: `local`
|
||||
- `source_ref`: `netx-local-mcp`
|
||||
- `server_id`: `netx-local`
|
||||
- `entry_command`: `python`
|
||||
- `entry_args`: `["D:/project/chatgpt/netx/netx_api/mcp_server.py"]`
|
||||
- `timeout_s`: `30`
|
||||
|
||||
Then run:
|
||||
|
||||
1. `Health`
|
||||
2. `Sync Tools`
|
||||
|
||||
Expected tools:
|
||||
|
||||
- `queryAlarms`
|
||||
- `aggregateAlarms`
|
||||
- `getImportBatch`
|
||||
- `runDiagnostics`
|
||||
|
||||
## 3) Bind to ops specialist
|
||||
|
||||
In MCP specialist binding, include `netx-local` for your ops specialist/workspace.
|
||||
|
||||
## 4) Use from chat
|
||||
|
||||
After binding, model can call namespaced tools like:
|
||||
|
||||
- `mcp__netx-local__queryAlarms`
|
||||
- `mcp__netx-local__aggregateAlarms`
|
||||
- `mcp__netx-local__getImportBatch`
|
||||
- `mcp__netx-local__runDiagnostics`
|
||||
|
||||
## 5) External link in Admin
|
||||
|
||||
`oclaw` admin sidebar includes an external link:
|
||||
|
||||
- `Open netx ops tool` -> `http://127.0.0.1:5173/`
|
||||
|
||||
If your netx host/port differs, update the link in:
|
||||
|
||||
- `interfaces/admin/static/index.html`
|
||||
|
||||
## 6) netx -> oclaw AP analyze auth
|
||||
|
||||
`netx` can call:
|
||||
|
||||
- `POST /admin/api/ops-ai/analyze-sync`
|
||||
- `GET /admin/api/ops-ai/health`
|
||||
|
||||
Recommended auth:
|
||||
|
||||
1. Set shared token in `oclaw` runtime env:
|
||||
- `OCLAW_OPS_AI_SHARED_TOKEN=<your_token>`
|
||||
2. Set same token in `netx`:
|
||||
- `NETX_OCLAW_ANALYZE_TOKEN=<your_token>`
|
||||
|
||||
Then `netx /v1/ap/analyze` can invoke `oclaw` synchronously.
|
||||
|
||||
**Timeouts:** `netx` → `oclaw` uses HTTP; `analyze-sync` often exceeds old ~35s limits. In netx set `NETX_OCLAW_ANALYZE_READ_TIMEOUT_SEC` (default `180` in `netx_api/config.py`) if you still see read timeouts on slow models or multi-tool turns.
|
||||
|
||||
Integration health in netx:
|
||||
|
||||
- `GET http://127.0.0.1:8890/v1/integrations/status`
|
||||
|
||||
## 7) Observe AP calls in oclaw
|
||||
|
||||
Recent ops-ai analyze calls can be fetched from:
|
||||
|
||||
- `GET /admin/api/ops-ai/logs?limit=50&offset=0`
|
||||
|
||||
Permission: `admin:user:write` (same as admin audit access).
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# Prompt Style Guide
|
||||
|
||||
## Goal
|
||||
- All model-facing prompts must be Markdown templates under `oclaw/prompts/`.
|
||||
- System/builtin model-facing prompt templates live under `runtime/workspaces/_system/`; role-specific copy lives under `runtime/workspaces/<role>/` (e.g. `ROLE_SYSTEM.md`). Load via `oclaw.runtime.prompt_templates`.
|
||||
- Business code must inject variables only; no long inline prompt strings.
|
||||
|
||||
## Template Contract
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue