mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:23:23 +08:00
Simplify oclaw product surface: drop niche specialists and admin noise.
Remove stock/image/video specialists, Gmail watcher, CocoLoop market, desktop packaging, and extra memory plugins; disable dynamic agents and hide Session Monitor / API grants / Admin Audit from nav. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
efa72df362
commit
cf31fd104d
290 changed files with 127 additions and 64576 deletions
|
|
@ -1,84 +1,5 @@
|
|||
# 图片专家(Chat UI)专用链路
|
||||
# Image specialist lane (removed)
|
||||
|
||||
本文描述 **Admin `/chat` 选择「图片」专家** 时的端到端路径。这是一条 **与通用 Responses / 主对话模型环路隔离** 的特殊分支:仅在 `skill_binding_role == "image"` 时进入,其它专家或综合模式不受影响。
|
||||
This specialist early-exit lane was removed from the product surface.
|
||||
Use `query_image_attachment` for OCR/vision in generalist/ops sessions.
|
||||
|
||||
> 与本文无关:`docs/GATEWAY_IMAGE_GENERATE.md`(网关 RPC `image.generate`)、OCR 工具使用的 `image_ocr_client` 等。
|
||||
|
||||
---
|
||||
|
||||
## 1. 触发条件与隔离边界
|
||||
|
||||
| 条件 | 说明 |
|
||||
|------|------|
|
||||
| UI / Gateway | 用户在前端选择专家 **`image`**,请求体携带 `skill_binding_role`(或等价字段)为 **`image`**。 |
|
||||
| 入口守卫 | `runtime/direct_loop.py` 中 **`_maybe_image_specialist_legacy_gateway_turn`**:仅当 `skill_binding_role.lower() == "image"` 且未设置禁用开关时执行;否则返回 `None`,后续仍走常规 `run_oclaw_direct_loop`。 |
|
||||
| 禁用开关 | `AIA_IMAGE_SPECIALIST_DISABLE_LEGACY_GATEWAY_LANE=1`:关闭本 Early Return,图片专家改走与普通会话相同的模型/传输栈(用于调试或迁移)。 |
|
||||
|
||||
**不要在本链路外混用**:DashScope 形态的多模态 HTTP、`qwen-image*` 的空兼容响应回退等,均封装在 `platform/llm/image_legacy_client.py` 与 `image_http_common.py`,避免改到 `openai_responses` 的通用逻辑。
|
||||
|
||||
---
|
||||
|
||||
## 2. 运行时数据流(网关 → 落库)
|
||||
|
||||
1. **`run_oclaw_direct_loop`** 在用户消息落库后立刻调用 **`_maybe_image_specialist_legacy_gateway_turn`**。
|
||||
2. **输入附件**:`collect_legacy_lane_images_from_attachments` 将 UI 附件规范为 `data:` URL 或 HTTP URL(`image_ref` / `input_image` / `image_url` / `relay_pointer` 等)。若本轮无可用图且未关闭 **`AIA_IMAGE_SPECIALIST_SESSION_IMAGE_FALLBACK`**,则 **`collect_legacy_lane_images_with_session_fallback`** 按「最近一条带图的助手消息 → 更早的用户上传」从落库历史中补齐。**非 compatible** 的 native 网关:`messages[0].content` 为 DashScope 文档形态(若干 **`{"image": …}`** + **`{"text": …}`**)。**`compatible-mode/v1`** 默认改为 OpenAI 形状(每条含 **`type`**:`image_url` / `text`),否则上游常报缺少 `content[n].type`;仅当网关明确要求无 `type` 的旧形态时设 **`AIA_IMAGE_EXPERT_COMPAT_USE_DASHSCOPE_NATIVE_BLOCKS=1`**。
|
||||
3. **仍无图**(本轮与历史均未解析出输入图):直接写入一条 `assistant` / `assistant_text` 提示语并返回,不调用上游。
|
||||
4. **有图**:调用 **`send_legacy_image_messages`**(`/chat/completions` 兼容路径,非 Responses API)。
|
||||
5. **输出解析**:**`legacy_image_turn_bundle`**
|
||||
- 文本可为空;若有生成图则 **`materialize_legacy_response_output_attachments`** 写入本地 blob,产出 **`image_ref`**(或退化为 **`image_url`**)。
|
||||
6. **占位文案**:成功但只有图、无模型正文时,由 **`legacy_image_assistant_body_with_placeholder`**(`image_legacy_client`)写入中英文占位句;与 `direct_loop` early-exit 共用。
|
||||
7. **持久化**:**`store.add_message(role=assistant, event_type=assistant_text, attachments=…)`** —— 附件以 JSON 形式挂在助手消息上,而非 tool 行。
|
||||
|
||||
---
|
||||
|
||||
## 3. 与其它入口的差异
|
||||
|
||||
| 场景 | 模块 | 说明 |
|
||||
|------|------|------|
|
||||
| Chat 网关 + 图片专家 | `direct_loop._maybe_image_specialist_legacy_gateway_turn` | 上文主路径;Early Return,不进主 LLM 循环。 |
|
||||
| Gateway early-exit | `runtime/direct_loop.py` | Image specialist 走 legacy HTTP lane,不经过 Responses 协议。 |
|
||||
|
||||
两处共用 **`platform/llm/image_legacy_client.py`**,避免分叉实现。
|
||||
|
||||
---
|
||||
|
||||
## 4. 鉴权与下载(严格 ACL)
|
||||
|
||||
助手消息上的 **`image_ref`** 需在 **`attachment_acl`** 中有记录,才能在 **`AIA_ATTACHMENT_ACL_STRICT=1`** 下通过 **`GET /admin/api/chat/attachments/{id}`**。
|
||||
|
||||
- **`SqliteStore.add_message`** 会在落库后根据会话 **`ui_session_owner`** 对引用型附件执行 **`link_attachment_acl`**(与 tool 结果路径一致)。
|
||||
- 历史数据可用 **`POST /admin/api/chat/admin/attachments/acl/backfill`**(管理员)补齐。详见 **`docs/attachment-acl.md`**。
|
||||
|
||||
---
|
||||
|
||||
## 5. WebSocket 收口与前端展示
|
||||
|
||||
- **`interfaces/ws/turn_runner.py`**:`final_msg` 从最近一条非空助手消息组装;**`_persisted_chat_attachments_nonempty`** 需识别 **JSON 数组或单个 JSON 对象**,否则纯附件回合会选错行。
|
||||
- **`interfaces/admin/static/chat.js`**:聚合气泡 **`_buildAggregatedAssistantBubble`** 须对 **`assistant_text`** 片段调用 **`renderAttachmentsEl`**(不仅 `tool_result`),否则会出现「只有配文、无图」的现象。
|
||||
|
||||
---
|
||||
|
||||
## 6. 环境变量(索引)
|
||||
|
||||
详细列表与默认值以 **`docs/ENVIRONMENT_VARIABLES.md`** 为准。与本链路相关的典型前缀:
|
||||
|
||||
- **`AIA_IMAGE_EXPERT_*`** / **`AIA_IMAGE_SPECIALIST_*`**:图片专家 HTTP 基址、端点、模型、请求扩展等(与 **`AIA_OCR_*`** 分离)。
|
||||
- **`AIA_IMAGE_SPECIALIST_DISABLE_LEGACY_GATEWAY_LANE`**:禁用网关侧 legacy 专用线。
|
||||
- **`AIA_ATTACHMENT_ACL_STRICT`**:附件下载是否仅信任 ACL。
|
||||
|
||||
---
|
||||
|
||||
## 7. 测试与回归
|
||||
|
||||
- **`tests/test_image_legacy_gateway_lane.py`**:legacy 解析与规范化。
|
||||
- **`tests/test_attachment_acl_backfill.py`**:严格 ACL 下助手附件与 ACL 写入。
|
||||
- 修改 **`chat.js`** 聚合或 **`turn_runner`** final 消息逻辑后,应用图片专家跑一轮 **生成图 + 刷新历史** 做冒烟。
|
||||
|
||||
---
|
||||
|
||||
## 8. 变更原则(避免波及其它链路)
|
||||
|
||||
1. **默认改动范围**:`image_legacy_client.py`、`image_http_common.py`、`direct_loop` 中 **`_maybe_image_specialist_*` 函数体**、`turn_runner` / `chat.js` 中与 **assistant + attachments** 展示相邻逻辑。
|
||||
2. **勿在** `openai_responses.py` **中为图片专家单独分支**,除非明确要做「非 legacy」通用能力。
|
||||
3. 新增开关优先 **`AIA_IMAGE_*` / `AIA_IMAGE_SPECIALIST_*`**,勿复用 OCR 变量。
|
||||
4. UI 层附件渲染:**assistant_text 与 tool_result** 对称处理引用型附件,避免只修一端。
|
||||
|
|
|
|||
|
|
@ -30,15 +30,11 @@ Transport selection happens in `oclaw/runtime/agents/factory.py`.
|
|||
- **Streaming**: output text deltas via `on_token` → WS `chat.delta`
|
||||
- **Key**: profile secret or `OPENAI_API_KEY`
|
||||
|
||||
### Chat UI「图片专家」(绕行本矩阵)
|
||||
### Image / video specialist lanes (removed)
|
||||
|
||||
- **Not** a separate profile transport: when the user selects specialist **`image`** in `/chat`, `runtime/direct_loop.py` takes an early return and calls **`platform/llm/image_legacy_client.send_legacy_image_messages`** (DashScope-style `/chat/completions`), so that turn does **not** use `OpenAIResponsesModel` / chat transports above.
|
||||
- Details, env vars, ACL, and UI hooks: **`docs/IMAGE_SPECIALIST_LANE.md`**.
|
||||
|
||||
### Chat UI「视频生成专家」(绕行本矩阵)
|
||||
|
||||
- When the user selects specialist **`video`**, `runtime/direct_loop.py` early-returns into **`platform/llm/video_generation_client.send_video_generation_request`** (DashScope async `video-synthesis` + task polling). Without an input image: **text-to-video**; with an image attachment (or session image fallback): **`input.img_url`** for **image-to-video** (use an i2v model id). That turn does **not** use the generic tool loop or `OpenAIResponsesModel`.
|
||||
- **`docs/VIDEO_SPECIALIST_LANE.md`**.
|
||||
- Former Chat UI **image** / **video** specialist early-exit lanes were removed from the product surface.
|
||||
- Ops/generalist sessions still use **`query_image_attachment`** (OCR / vision tool) when needed.
|
||||
- See git history / older docs for the legacy DashScope multimodal HTTP path.
|
||||
|
||||
### `anthropic` (Anthropic Messages streaming)
|
||||
- **Transport**: `oclaw/platform/llm/transports/anthropic_messages.py::AnthropicMessagesModel`
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
# 视频生成专家(Chat UI)专用链路
|
||||
|
||||
本文描述 **Admin `/chat` 选择「视频」专家**(工作区 id **`video`**)时的端到端路径。与图片专家类似,这是一条 **与通用 Responses / 主对话工具环路隔离** 的分支:在 `skill_binding_role == "video"` 时 **Early Return**,不进入常规 `run_oclaw_direct_loop` 多轮工具循环。
|
||||
|
||||
参考 API 形态:阿里云 Model Studio **Wan**(DashScope 异步:同一 `POST …/video-synthesis` → `GET …/api/v1/tasks/{task_id}`)。**文生视频**仅 `input.prompt`;**图生视频**额外设置 `input.img_url`(公网 HTTPS 或 `data:image/...;base64,...` 首帧),需使用 **i2v** 模型(如 `wan2.6-i2v-flash`,以控制台为准)。区域化的 **`base_url` 必须与 API Key 区域一致**。控制台 API 入口示例:[百炼控制台](https://bailian.console.aliyun.com/)。
|
||||
|
||||
---
|
||||
|
||||
## 1. 触发条件与隔离边界
|
||||
|
||||
| 条件 | 说明 |
|
||||
|------|------|
|
||||
| UI / Gateway | 用户选择专家 **`video`**,请求携带 `skill_binding_role` 为 **`video`**。 |
|
||||
| 入口守卫 | `runtime/direct_loop.py` 中 **`_maybe_video_specialist_legacy_gateway_turn`**:仅当 `skill_binding_role.lower() == "video"` 且未设置禁用开关时执行。 |
|
||||
| 禁用开关 | `AIA_VIDEO_SPECIALIST_DISABLE_LEGACY_GATEWAY_LANE=1`:关闭本 Early Return,视频专家改走与普通会话相同的模型/传输栈。 |
|
||||
|
||||
实现集中在 **`platform/llm/video_generation_client.py`**(HTTP + 轮询 + 附件落地),避免在 `openai_responses` 中分叉。
|
||||
|
||||
---
|
||||
|
||||
## 2. 运行时数据流(网关 → 落库)
|
||||
|
||||
1. **`run_oclaw_direct_loop`** 在用户消息落库后,在图片专家分支之后调用 **`_maybe_video_specialist_legacy_gateway_turn`**。
|
||||
2. **Prompt**:使用本轮用户文本;若为空则使用 **`VIDEO_SPECIALIST_DEFAULT_PROMPT_ZH`**(`video_generation_client`)。图生视频时 `prompt` 仍建议填写(描述期望动态与镜头)。
|
||||
3. **首帧图**:与图片专家相同,使用 **`collect_legacy_lane_images_with_session_fallback`**(`image_legacy_client`)从**本轮附件**或(未关闭 **`AIA_IMAGE_SPECIALIST_SESSION_IMAGE_FALLBACK`** 时)**会话历史**中取 **1 张**图,转为 URL / data URL 后写入 **`input.img_url`**。无图则走纯文生视频。
|
||||
4. **鉴权与根 URL**:优先使用会话所选模型的 **`model` / `base_url` / `api_key`**;缺省字段由 **`AIA_VIDEO_EXPERT_*`** 环境变量补全。若 `base_url` 指向 **`compatible-mode/v1`**,实现会剥离该后缀以拼接原生 DashScope 路径。
|
||||
5. **调用**:`send_video_generation_request` — `POST .../video-synthesis`(`X-DashScope-Async: enable`),再轮询 **`GET .../api/v1/tasks/{task_id}`** 直至 `SUCCEEDED` / 失败 / 超时。
|
||||
6. **输出**:成功时从 `output.video_url` 下载为本地 blob,产出 **`video_ref`**;下载失败时退化为仅带 **`url`** 的 `video_ref` 行(前端仍可尝试外链播放)。
|
||||
7. **占位文案**:`legacy_video_assistant_body_with_placeholder` 与图片专家对称(仅附件、无正文时插入中英文短句)。
|
||||
8. **编排**:video specialist 在 `direct_loop` early-exit 中调用同一客户端;综合模式经 gateway 选中 video specialist 后走同一路径。
|
||||
|
||||
---
|
||||
|
||||
## 3. 执行器与工具面
|
||||
|
||||
- **`runtime/agents/factory.py`**:`video` 与 `image` 一样使用 **不可能工具名 allowlist**,避免默认工具注册混入。
|
||||
- **`runtime/gateway.py`**:综合模式 Manager 白名单包含 **`video`**,否则子专家选择会被回退。
|
||||
|
||||
---
|
||||
|
||||
## 4. 鉴权与附件(ACL)
|
||||
|
||||
与 **`image_ref`** 相同,助手消息上的 **`video_ref`** 依赖 **`attachment_acl`** 才能在严格模式下通过下载接口访问;落库时由 `SqliteStore.add_message` 链路处理。参见 **`docs/attachment-acl.md`**。
|
||||
|
||||
---
|
||||
|
||||
## 5. 前端
|
||||
|
||||
- **`interfaces/admin/static/chat.js`**:`specialistLabel` 对 **`video`** 显示短标签;`video_ref` 卡片在可用 blob URL 或外链 URL 时附加 **`<video controls>`** 便于预览。
|
||||
|
||||
---
|
||||
|
||||
## 6. 环境变量(索引)
|
||||
|
||||
详见 **`docs/ENVIRONMENT_VARIABLES.md`** 中 **`AIA_VIDEO_EXPERT_*`** 与 **`DASHSCOPE_VIDEO_*`** 小节。
|
||||
|
||||
---
|
||||
|
||||
## 7. 测试
|
||||
|
||||
- **`tests/test_video_generation_client.py`**:提交 / 轮询 HTTP 形态的单元测试(mock `httpx`)。
|
||||
|
||||
---
|
||||
|
||||
## 8. 变更原则
|
||||
|
||||
1. 默认只改 **`video_generation_client.py`**、`direct_loop` 的 **`_maybe_video_specialist_*`**、`factory` / `gateway` 白名单、**`chat.js`** 附件展示、本文与 **`ENVIRONMENT_VARIABLES.md`**。
|
||||
2. 勿在通用 **`openai_responses`** 中为视频专家单独绕路,除非产品明确要求统一传输。
|
||||
Loading…
Add table
Add a link
Reference in a new issue