Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions docs/en/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ sidebar_position: 1

Before changing a flow below, update its connection graph, sequence diagram, code ownership, and essential invariants, confirm that the path is complete, and only then change code. Keep one independently maintained file per topic; add one file and one catalog row for a new governed flow.

| Logic | Architecture file | Change scope |
| -------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| Board automation and Wegent execution | [board-automation.md](board-automation.md) | Assignment, execution truth, runtime activation, continuation, cancellation, terminal projection |
| Custom AI manager comment continuation | [automation-manager-continuation.md](automation-manager-continuation.md) | Comment identity, execution binding, runtime-session continuation, task-state isolation |
| Embedded-browser navigation and tabs | [embedded-browser.md](embedded-browser.md) | Bridge routing, pending open, WebView lifecycle, navigation completion, multi-tab E2E |
| Project execution state and Runtime capacity | [project-execution-state.md](project-execution-state.md) | Claim, event ordering, cancellation, retry, lease, concurrency capacity, UI projection |
| Git Worktree execution | [git-worktree-execution.md](git-worktree-execution.md) | Device routing, capability, preflight, queued creation, lifecycle, persistence, UI projection |
| Logic | Architecture file | Change scope |
| -------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
| Board automation and Wegent execution | [board-automation.md](board-automation.md) | Assignment, execution truth, runtime activation, continuation, cancellation, terminal projection |
| Custom AI manager comment continuation | [automation-manager-continuation.md](automation-manager-continuation.md) | Comment identity, execution binding, runtime-session continuation, task-state isolation |
| Embedded-browser navigation and tabs | [embedded-browser.md](embedded-browser.md) | Bridge routing, pending open, WebView lifecycle, navigation completion, multi-tab E2E |
| Project execution state and Runtime capacity | [project-execution-state.md](project-execution-state.md) | Claim, event ordering, cancellation, retry, lease, concurrency capacity, UI projection |
| Git Worktree execution | [git-worktree-execution.md](git-worktree-execution.md) | Device routing, capability, preflight, queued creation, lifecycle, persistence, UI projection |
| Text-model vision delegation | [model-vision-delegation.md](model-vision-delegation.md) | Explicit model reference, catalog capability, sidecar configuration, image replacement, failure isolation |
| IM private-chat runtime streaming | [im-runtime-streaming.md](im-runtime-streaming.md) | Callback key, `runtime:event` envelope, relay and IM forwarding, terminal event, failure isolation |
| Wework host plugin runtime | [workbench-plugin-runtime.md](workbench-plugin-runtime.md) | Profile composition, services and UI slots, dynamic modules, sidecars, teardown, and recovery |
| IM private-chat runtime streaming | [im-runtime-streaming.md](im-runtime-streaming.md) | Callback key, `runtime:event` envelope, relay and IM forwarding, terminal event, failure isolation |
| Codex notification isolation | [codex-notification-routing.md](codex-notification-routing.md) | Shared app-server, thread routing, burst isolation, process exit, terminal projection |

Detailed product prose remains in the existing developer guides. This directory contains only reviewable architecture truth.
70 changes: 70 additions & 0 deletions docs/en/architecture/workbench-plugin-runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
sidebar_position: 25
---

# Wework host plugin runtime

Scope: local product composition, plugin lifecycle, UI contributions, desktop sidecars, and failure recovery for Wework React and Tauri, excluding the Executor implementation. This flow does not depend on Backend or handle cloud plugin distribution.

```mermaid
flowchart LR
PROFILE[client-version-pinned profile] --> CONTEXT[Cordis Context]
INSTALLED[locally installed Codex plugins] --> HOST[dynamic plugin host]
ROOTS[local plugin directories] --> SCAN[Tauri manifest and SHA-256 validation]
SCAN --> HOST
HOST --> MODULE[same-realm ESM frontend module]
HOST --> SIDECAR[desktop sidecar]
MODULE --> CONTEXT
CONTEXT --> ROUTES[Routes]
CONTEXT --> APPS[Apps]
CONTEXT --> SETTINGS[Settings]
CONTEXT --> SLOTS[React UI Slots]
SIDECAR <-->|JSON-RPC stdio| TAURI[Tauri sidecar host]
CONTEXT --> EXECUTOR[Executor protocol boundary]
```

```mermaid
sequenceDiagram
participant P as Profile
participant I as Local installed inventory
participant D as Dynamic plugin host
participant T as Tauri scanner
participant C as Cordis Context
participant F as Frontend module
participant S as Desktop sidecar
participant U as React slot renderer

P->>C: apply required entries with exact clientVersion
C->>U: register built-in routes, apps, settings, right panels, and slots
I->>D: installed and enabled plugin names
D->>T: scan device plugin roots
T->>T: canonicalize paths and verify SHA-256
T-->>D: valid local manifests and entry paths
D->>F: import selected ESM entry in the host realm
F->>C: activate(plugin API)
C->>U: publish reactive contributions

alt activation failure
C->>U: dispose the failed plugin fiber
D->>S: stop a started sidecar
end

F->>S: optionally start or call a desktop capability
S-->>F: JSON-RPC result
I->>D: local disable, uninstall, or update event
D->>C: dispose plugin fiber
C->>U: remove contributions and notify subscribers
D->>S: stop process
```

| Edge | Code owner |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| Context, services, and plugin fibers | Pinned `@deepseek-ai/cordis` |
| Wework routes, apps, settings, right panels, slots, and SDK | `wework/src/plugin-runtime/` |
| React slot contracts and React 19 renderer | `wework/src/plugin-runtime/slots.tsx` |
| Built-in required profile and product entrypoints | `wework/src/plugins/` |
| Manifest scan, path/SHA-256 checks, sidecar lifecycle | `wework/src-tauri/src/workbench_plugins.rs` |
| Local installed inventory and plugin change events | Wework local Codex plugin API and plugin workspace |
| Executor startup and protocol transport | Existing Executor bridge; Executor internals are outside this flow |

Invariants: the product entrypoint loads only a profile and never enumerates concrete features; every registration belongs to a Cordis effect, and unloading may leave no route, slot, setting, app, right panel, listener, or process behind; React, ReactDOM, Cordis, and the Wework Plugin SDK have exactly one host instance across frontend plugins; required plugins must be pinned by the client profile to an exactly matching `clientVersion`; optional plugins load only when locally installed and enabled and when the device has a valid manifest with matching content hashes; local install, disable, uninstall, or update operations must trigger serialized rescans; dynamic registration and unloading must notify React subscribers; packages without `.wework-plugin/plugin.json` remain valid Executor capability plugins; frontend plugins execute in the same JavaScript realm with host-page authority, so SHA-256 proves content integrity but not publisher identity or permission isolation; sidecars may start only from verified files under approved local plugin directories and inside their package root, and the requested plugin ID must match the manifest; each JSON-RPC method requires an identically named manifest `capabilities` entry, requests are serialized per plugin, notifications and unrelated responses are ignored, and the sidecar is terminated after a 30-second timeout or process exit; this flow does not read cloud desired state, and Backend never loads or executes plugin code.
17 changes: 9 additions & 8 deletions docs/zh/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ sidebar_position: 1

修改下表逻辑前,先更新对应连线图、时序图、代码归属和必要不变量,确认逻辑闭环后再改代码。每个主题独立维护;新增受约束逻辑时增加一个文件和一行索引。

| 逻辑 | 架构文件 | 修改范围 |
| --------------------------- | -------------------------------------------------------- | ----------------------------------------------------------------- |
| 看板自动化与 Wegent 执行 | [board-automation.md](board-automation.md) | 指派、执行真值、runtime 激活、续聊、取消、终态投影 |
| 自定义 AI 调度员评论续聊 | [automation-manager-continuation.md](automation-manager-continuation.md) | 评论身份、execution 绑定、runtime 会话续聊、任务状态隔离 |
| 内置浏览器导航与多标签 | [embedded-browser.md](embedded-browser.md) | bridge 路由、pending open、WebView 生命周期、导航完成、多标签 E2E |
| 项目执行状态与 Runtime 容量 | [project-execution-state.md](project-execution-state.md) | claim、事件顺序、取消、重试、lease、并发容量、UI 投影 |
| Git Worktree 执行 | [git-worktree-execution.md](git-worktree-execution.md) | 设备路由、能力、preflight、排队创建、生命周期、持久化、UI 投影 |
| 逻辑 | 架构文件 | 修改范围 |
| --------------------------- | ------------------------------------------------------------------------ | ----------------------------------------------------------------- |
| 看板自动化与 Wegent 执行 | [board-automation.md](board-automation.md) | 指派、执行真值、runtime 激活、续聊、取消、终态投影 |
| 自定义 AI 调度员评论续聊 | [automation-manager-continuation.md](automation-manager-continuation.md) | 评论身份、execution 绑定、runtime 会话续聊、任务状态隔离 |
| 内置浏览器导航与多标签 | [embedded-browser.md](embedded-browser.md) | bridge 路由、pending open、WebView 生命周期、导航完成、多标签 E2E |
| 项目执行状态与 Runtime 容量 | [project-execution-state.md](project-execution-state.md) | claim、事件顺序、取消、重试、lease、并发容量、UI 投影 |
| Git Worktree 执行 | [git-worktree-execution.md](git-worktree-execution.md) | 设备路由、能力、preflight、排队创建、生命周期、持久化、UI 投影 |
| 文本模型视觉委托 | [model-vision-delegation.md](model-vision-delegation.md) | 显式模型引用、catalog 能力、sidecar 配置、图片替换、失败隔离 |
| IM 私聊续聊本地 Runtime | [im-runtime-streaming.md](im-runtime-streaming.md) | callback key、`runtime:event` 信封、中继与 IM 转发、终态、失败隔离 |
| Wework 宿主插件运行时 | [workbench-plugin-runtime.md](workbench-plugin-runtime.md) | profile 装配、服务与 UI slot、动态模块、sidecar、卸载与恢复 |
| IM 私聊续聊本地 Runtime | [im-runtime-streaming.md](im-runtime-streaming.md) | callback key、`runtime:event` 信封、中继与 IM 转发、终态、失败隔离 |
| Codex 通知流隔离 | [codex-notification-routing.md](codex-notification-routing.md) | 共享 app-server、线程路由、突发隔离、进程退出、终态投影 |

详细产品说明继续放在原开发指南;本目录只保存可评审的架构真值。
70 changes: 70 additions & 0 deletions docs/zh/architecture/workbench-plugin-runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
sidebar_position: 25
---

# Wework 宿主插件运行时

范围:Wework React 与 Tauri 中除 Executor 实现之外的本地产品功能装配、插件生命周期、UI 贡献、桌面 sidecar 和故障恢复。本流程不依赖 Backend,也不处理云端插件分发。

```mermaid
flowchart LR
PROFILE[客户端版本锁定 profile] --> CONTEXT[Cordis Context]
INSTALLED[本地 Codex 已安装插件] --> HOST[动态插件宿主]
ROOTS[本地插件目录] --> SCAN[Tauri 清单与 SHA-256 校验]
SCAN --> HOST
HOST --> MODULE[同 realm ESM 前端模块]
HOST --> SIDECAR[桌面 sidecar]
MODULE --> CONTEXT
CONTEXT --> ROUTES[Routes]
CONTEXT --> APPS[Apps]
CONTEXT --> SETTINGS[Settings]
CONTEXT --> SLOTS[React UI Slots]
SIDECAR <-->|JSON-RPC stdio| TAURI[Tauri sidecar host]
CONTEXT --> EXECUTOR[Executor 协议边界]
```

```mermaid
sequenceDiagram
participant P as Profile
participant I as 本地已安装清单
participant D as Dynamic plugin host
participant T as Tauri scanner
participant C as Cordis Context
participant F as Frontend module
participant S as Desktop sidecar
participant U as React slot renderer

P->>C: apply required entries with exact clientVersion
C->>U: register built-in routes, apps, settings, right panels and slots
I->>D: 已安装且启用的插件名
D->>T: scan device plugin roots
T->>T: canonicalize paths and verify SHA-256
T-->>D: valid local manifests and entry paths
D->>F: import selected ESM entry in host realm
F->>C: activate(plugin API)
C->>U: publish reactive contributions

alt activation failure
C->>U: dispose the failed plugin fiber
D->>S: stop a started sidecar
end

F->>S: optionally start or call desktop capability
S-->>F: JSON-RPC result
I->>D: 本地禁用、卸载或更新事件
D->>C: dispose plugin fiber
C->>U: remove contributions and notify subscribers
D->>S: stop process
```

| 边 | 代码归属 |
| ----------------------------------------------- | --------------------------------------------------------- |
| Context、service 和插件 fiber | 固定版本的 `@deepseek-ai/cordis` |
| Wework routes、apps、settings、right panels、slots 和 SDK | `wework/src/plugin-runtime/` |
| React slot 合同和 React 19 renderer | `wework/src/plugin-runtime/slots.tsx` |
| 内置 required profile 和产品插件入口 | `wework/src/plugins/` |
| 清单扫描、路径与 SHA-256 校验、sidecar 生命周期 | `wework/src-tauri/src/workbench_plugins.rs` |
| 本地安装清单与插件变更事件 | Wework local Codex plugin API 和插件工作区 |
| Executor 的启动和协议传输 | 现有 Executor bridge;Executor 内部不属于本流程 |

不变量:产品入口只加载 profile,不枚举具体功能;所有注册必须属于一个 Cordis effect,插件卸载后不得残留 route、slot、settings、app、right panel、listener 或进程;React、ReactDOM、Cordis 和 Wework Plugin SDK 在所有前端插件中只有一个宿主实例;required 插件必须随客户端 profile 锁定到完全一致的 `clientVersion`;可选插件同时满足本地已安装且启用、设备存在有效清单、内容哈希匹配才会加载;本地安装、禁用、卸载或更新必须触发串行重新扫描;动态注册和卸载必须通知 React 订阅者;没有 `.wework-plugin/plugin.json` 的旧包仍是合法 Executor capability plugin;前端插件在同一 JS realm 运行,拥有宿主页面权限,SHA-256 只证明内容完整性,不构成发布者身份或权限隔离;sidecar 只能从受认可的本地插件目录和包根目录内的已校验文件启动,插件 ID 必须与清单一致;每个 JSON-RPC method 必须在清单 `capabilities` 中同名声明,宿主按插件串行请求、忽略通知和无关响应,并在 30 秒超时或进程退出后终止 sidecar;本流程不读取云端期望态,也不由 Backend 加载或执行插件代码。
Loading
Loading