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:
oliver 2026-05-03 23:54:38 +08:00
parent 83f46f8aa2
commit b0e0c05d8a
60 changed files with 1143 additions and 46 deletions

View file

@ -0,0 +1,9 @@
---
title: fallback_ollama_failure_en
summary: ollama transport failure banner in English
read_when: ollama transport exception
---
**Could not reach the Ollama / compatible endpoint:** `{{error_type}}: {{error_message}}`
_Falling back to the built-in rule engine for this reply._

View file

@ -0,0 +1,9 @@
---
title: fallback_ollama_failure_zh
summary: ollama transport failure banner in Chinese
read_when: ollama transport exception
---
**无法连接本地 Ollama(或兼容接口):** `{{error_type}}: {{error_message}}`
_本次回答已改用内置规则引擎兜底。_

View file

@ -0,0 +1,11 @@
---
title: fallback_openai_missing_key_user_en
summary: user-facing message when openai key is missing
read_when: openai mode selected but no api key
---
**Cannot use this profile:** no API Key is set for the OpenAI-compatible endpoint, and `OPENAI_API_KEY` is not in the environment.
Add a key in **Settings** and save, or switch to the built-in **Local Ollama (default)** profile.
_No request was sent to the model service._

View file

@ -0,0 +1,11 @@
---
title: fallback_openai_missing_key_user_zh
summary: user-facing message when openai key is missing
read_when: openai mode selected but no api key
---
**当前配置无法接入模型:** 本配置为 OpenAI / 兼容 API,但未填写 API Key,且环境中也没有 `OPENAI_API_KEY`。
请在「设置」中填写 Key 并保存,或切换到内置的「本地 Ollama(默认)」配置后再试。
_本次未向模型服务发送请求。_

View file

@ -0,0 +1,9 @@
---
title: fallback_openai_transport_error_en
summary: generic OpenAI-compatible transport error in English
read_when: model request failed
---
**Model request failed:** `{{error_type}}: {{error_message}}`
Check API key, base URL, and network, then try again.{{extra_tail}}

View file

@ -0,0 +1,9 @@
---
title: fallback_openai_transport_error_zh
summary: generic OpenAI-compatible transport error in Chinese
read_when: model request failed
---
**调用模型失败:** `{{error_type}}: {{error_message}}`
请检查 API Key、Base URL 与网络后重试。{{extra_tail}}

View file

@ -0,0 +1,9 @@
---
title: fallback_openai_transport_oversized_en
summary: oversized payload failure in English
read_when: model request too large
---
**Model request failed (message too large):** `{{error_type}}: {{error_message}}`
Common causes: oversized tools schema or large tool results in history. Tune `AIA_OPENAI_TOOLS_MAX_JSON_CHARS`, reduce MCP tools, or narrow the query.

View file

@ -0,0 +1,9 @@
---
title: fallback_openai_transport_oversized_zh
summary: oversized payload failure in Chinese
read_when: model request too large
---
**调用模型失败(单条消息过长):** `{{error_type}}: {{error_message}}`
常见原因:tools 负载过大或 tool 返回过长。可调整 `AIA_OPENAI_TOOLS_MAX_JSON_CHARS`,或减少 MCP / 缩小查询范围后重试。

View file

@ -0,0 +1,7 @@
---
title: fallback_openclaw_runtime_error_en
summary: fallback text when openclaw runtime failed
read_when: gateway exception path
---
oclaw runtime error: executor missing model/tools

View file

@ -0,0 +1,7 @@
---
title: fallback_oclaw_runtime_error_zh
summary: fallback text when oclaw runtime failed
read_when: gateway exception path
---
oclaw 运行失败:执行器缺少 model/tools

View file

@ -0,0 +1,7 @@
---
title: fallback_task_queued_en
summary: User-visible text when async task is enqueued.
read_when: gateway async_task mode
---
Task queued, task_id={{task_id}}

View file

@ -0,0 +1,7 @@
---
title: fallback_task_queued_zh
summary: User-visible text when async task is enqueued.
read_when: gateway async_task mode
---
任务已入队,task_id={{task_id}}

View file

@ -0,0 +1,7 @@
---
title: image_default_edit_prompt_zh
summary: Default image editing prompt text.
read_when: image prompt is empty
---
请基于输入图片和用户要求完成图像编辑,并返回结果图片。

View file

@ -0,0 +1,25 @@
---
title: oclaw_router_decide_route
summary: LLM JSON routing prompt for sync vs async oclaw turns (Chinese only).
read_when: AIA_OCLAW_ROUTER_MODE=llm_json
---
# 路由决策(结构化输出)
你需要判断当前用户输入应采用哪种执行模式:
- `sync_direct`:当前请求内直接回复(默认)。
- `async_task`:明确是多步骤后台流程(例如“总结并发送”)、或输入极大且带附件。
## 输入
- 用户文本:
```
{{user_text}}
```
- 是否有附件:`{{has_attachments}}`
## 输出(严格)
只返回一行 JSON,不要 Markdown、不要解释:
`{"mode":"sync_direct"|"async_task","reason":"<简短原因>"}`
默认倾向 `sync_direct`,只有明确需要异步才选 `async_task`。

View file

@ -0,0 +1,27 @@
---
title: default_runtime_system_en
summary: Default system prompt for general runtime (English template).
read_when: agent runtime start
---
# Identity
You are a general-purpose AI assistant.
## Input Constraints
- Answer in the same language as the user.
## Execution Rules
- When external data or actions are needed, prefer the tools provided by the system.
- Tool calls are carried by the platform protocol; do not paste tool-protocol JSON in the user-visible reply.
## Output Format
- Produce user-readable text; conclusions first, steps concise.
## Safety
- Do not fabricate tool results.
- When uncertain, state limits and ask for missing information.

View file

@ -0,0 +1,22 @@
---
title: default_runtime_system_zh
summary: Default system prompt for general runtime.
read_when: agent runtime start
---
# Identity
你是一个通用 AI 助手。
## Input Constraints
- 使用用户输入的语言回答。
## Execution Rules
- 当需要外部数据或执行动作时,优先调用系统提供的工具。
- 工具调用由平台协议承载,不要在正文里输出工具协议 JSON。
## Output Format
- 直接输出用户可读内容,结论优先,步骤简洁。
## Safety
- 不要伪造工具结果。
- 不确定时先说明边界并请求补充信息。

View file

@ -0,0 +1,10 @@
---
title: oclaw_runtime_memory_context_block
summary: Runtime markdown wrapper for memory context.
read_when: assembling runtime memory context
---
[short_term_digest]
{{short_term_block}}
[semantic_memory_hits]
{{semantic_hits_block}}

View file

@ -0,0 +1,7 @@
---
title: oclaw_runtime_project_context_block
summary: Inject workspace bootstrap files into system prompt project context.
read_when: oclaw system assembly with workspace context
---
[project_context]
{{project_context}}

View file

@ -0,0 +1,9 @@
---
title: oclaw_runtime_system_with_memory
summary: Runtime system prompt wrapper with injected memory context.
read_when: oclaw system assembly
---
{{system_prompt}}
[memory_context]
{{memory_context}}

View file

@ -0,0 +1,6 @@
---
title: oclaw_runtime_system_with_skills
summary: System prompt body plus optional skills catalog XML.
read_when: oclaw direct loop with skill runtime
---
{{system_body}}{{skills_catalog}}

View file

@ -0,0 +1,8 @@
---
title: image_attachment_meta_block
summary: Metadata-only image attachment block for LLM message context.
read_when: building user message content
---
--- Image Attachment (meta only) ---
{{meta_line}}

View file

@ -0,0 +1,9 @@
---
title: text_attachment_wrap_block
summary: Wrapper for text file attachments in LLM context.
read_when: building user message content
---
--- File: {{name}} ---
{{content}}
--- End of File ---

View file

@ -0,0 +1,8 @@
---
title: tool_result_unpaired_block
summary: Downgraded tool result block when call id pairing is broken.
read_when: building assistant fallback message
---
[{{tag}}]
{{payload}}

View file

@ -90,6 +90,10 @@ def _workspace_signature() -> tuple[Any, ...]:
for item in sorted(root.iterdir(), key=lambda p: p.name.lower()):
if not item.is_dir():
continue
# Internal workspace directories (single underscore prefix) are not experts.
# Example: `_system` is used for builtin prompt templates.
if item.name.startswith("_"):
continue
if item.name.startswith("__"):
continue
eid = normalize_expert_id(item.name)
@ -159,6 +163,10 @@ def list_experts() -> list[dict[str, Any]]:
for item in sorted(root.iterdir(), key=lambda p: p.name.lower()):
if not item.is_dir():
continue
# Internal workspace directories (single underscore prefix) are not experts.
# Example: `_system` is used for builtin prompt templates.
if item.name.startswith("_"):
continue
eid = normalize_expert_id(item.name)
if not eid:
continue

View file

@ -10,3 +10,13 @@
## 输出格式:
- 先结论,再给证据与最小修复步骤。
## netx 明细与统计(内部工具)
每轮对话 **system 末尾会自动附带当前最新导入的 batch_id 锚点**(类似附件里的 id),无需你先「查列表再找 batch」。涉及告警/统计时仍应用工具拉明细。
- **省略 batch_id**:`netx_query_alarms`、`netx_aggregate_alarms`、`netx_run_diagnostics` 也可不传 batch_id,此时与锚点一致(最新导入批次)。
- **netx_list_import_batches**:仅在需要多看几个历史批次时使用。
- **netx_query_alarms** / **netx_aggregate_alarms** / **netx_run_diagnostics**:用锚点中的 batch_id(或省略 batch_id)获取明细与诊断。
工具走 netx(`OCLAW_NETX_BASE_URL` / `OCLAW_NETX_API_TOKEN`)。关闭自动锚点:环境变量 `OCLAW_OPS_NETX_CONTEXT_INJECT=0`。