Skip to content

feat(workbench): add OAR capability parity and consolidate session drivers - #10242

Open
songoow wants to merge 15 commits into
mainfrom
codex/workbench-oar-parity
Open

songoow wants to merge 15 commits into
mainfrom
codex/workbench-oar-parity

Conversation

@songoow

@songoow songoow commented Dec 6, 2026 •

Copy link
Copy Markdown
Collaborator

This PR targets #10241 (codex/oar-pr2-eliminate-py-js-pingpong) and uses its direct Node host. #9854 has landed on main. Land #10241 first, then compare this PR’s Workbench changes against main before landing it.

Summary

Exposes existing @botiverse/oar@0.142.0 capabilities across all 9 Workbench OAR runtimes (cursor, codebuddy, devin, factory, grok, kimi, opencode, qoder, qwen) while preserving strict read-only guarantees and deduplicating standalone vs Core-bridged OAR session lifecycle handling:

  1. Slash commands (commands(cwd)): Wires runtime.commands(installed, { cwd, env }) into OarAdapter.commands(cwd) via mapOarCommands, gracefully returning [] on unsupported, unavailable, or errors.
  2. Read-only Skills & MCP inventory: Extends AgentAdapter with optional async read-only listSkills(cwd) and listMcpServers(cwd) methods wired into SkillsManager, McpManager, HTTP routes (/api/skills, /api/skills/detail, /api/mcp with validated optional ?cwd=), and read-only-aware Workbench web UI (SkillsPage.tsx, McpPage.tsx, api.ts, locales). OAR adapters never fabricate writable skillDirs, config paths, or mcpInstall/mcpRemove handlers.
  3. Plan quota (accountUsage → fetchQuota()): Dynamically sets capabilities.quota when typeof runtime.accountUsage === 'function' (factory, grok, kimi), implements fetchQuota() / mapOarAccountUsage (windows, balances, plan, note, checkedAt, reauth_required → 409 agent_login_required), and lazily probes cold-start dynamic capabilities in ThreadManager.agentQuota.
  4. Fork (capabilities.fork + forkSession): Dynamically sets capabilities.fork from !installedSessionCapabilities(runtime, installed).refusedSessionOptions?.fork (enabled for OpenCode v2, refused on OpenCode v1 and the other 8 runtimes; forkAt and forkInto remain false without native history/anchors) and uses the same Core or standalone backend for ordinary sessions and forks. A successful fork returns a distinct native session ID and releases the temporary handle.
  5. Read-only runtime update diagnostics (diagnose() / checkUpdate): Implements OarAdapter.diagnose() surfacing protocol, version, and read-only runtime.checkUpdate() (devin, factory, grok, kimi) in RuntimeDiagnostic / ObservabilityPage.tsx. Never invokes mutating runtime.upgrade() (Workbench has no agent CLI upgrade surface).
  6. Driver consolidation (oar.ts & oar-core.ts): Extracts shared OarSessionDriver, assertOarAbortConfirmed, and observeNativeOarSession into oar-events.ts and oar-status.ts so standalone and Core-bridged OAR sessions share event projection, image conversion, active-turn guards, strict abort confirmation, idempotent close(), and onClosed eviction.
  7. Tests: Adds apps/workbench/packages/daemon/test/oar-parity.test.ts (zero playwright-core imports) covering all mappers, the real 9-runtime OAR capability matrix (including OpenCode v1 vs v2), read-only skills/MCP HTTP & write-refusal paths, quota cold-start & mapping, fork & disposal, read-only diagnostics, and shared session lifecycle guarantees.

Integration verification

  • 87 Workbench daemon tests, 59 Core OAR tests, 870 Workbench web tests, and the packaged shared-Core service test passed locally. All six Workbench workspaces passed typecheck.
  • The managed OpenCode fork test reads the closed fork from Core's SQLite archive. The standalone Stop test confirms that cancelling before dispatch sends zero prompts and the next turn succeeds.

Verification before restacking

  • node scripts/ci/lint-external-transports.mjs: PASS
  • npm --prefix apps/workbench run typecheck (all 6 workspaces, Node v24.23.0): PASS
  • Daemon tests (11 suites: oar-parity, oar, oar-core, oar-thread-status, skills, mcp, quota, quota-inband, quota-resume, fork-subchat, workbench-lifecycle): 92/92 PASS (including 22/22 PASS for oar-parity + oar-core + oar-thread-status without playwright-core)
  • Web tests (TZ=UTC npm --prefix apps/workbench test -w @loopx/loochat-web): 824/824 PASS
  • Independently reviewed and approved by @pr-verifier (Add meta source registry self-repair smoke #41).

…ivers

Wire @botiverse/oar@0.142.0 capabilities across the 9 Workbench OAR runtimes without fabricating write paths or unsupported flags:

- Commands: wire runtime.commands() into OarAdapter.commands(cwd) with graceful [] fallback on unsupported/unavailable.
- Read-only inventories: add async AgentAdapter.listSkills()/listMcpServers() wired into SkillsManager, McpManager, HTTP routes, and web UI while keeping OAR strictly read-only (no skillDirs/mcpInstall/mcpRemove).
- Quota: dynamically set capabilities.quota from runtime.accountUsage (factory, grok, kimi) and implement fetchQuota() mapping AccountUsageSnapshot to PlanQuota (with lazy capability probing on cold-start quota/fork routes).
- Fork: dynamically set capabilities.fork from installedSessionCapabilities().refusedSessionOptions?.fork (OpenCode v2 true, v1 and other runtimes false; forkAt/forkInto stay false without history) and implement forkSession() with guaranteed session disposal.
- Diagnostics: implement read-only OarAdapter.diagnose() surfacing protocol, version, and runtime.checkUpdate() without ever invoking runtime.upgrade().
- Driver consolidation: share OarSessionDriver, assertOarAbortConfirmed, and observeNativeOarSession across oar.ts and oar-core.ts.
- Tests: add oar-parity.test.ts (playwright-free) covering all mappers, dynamic capability matrix, read-only inventories, quota, fork, diagnostics, and shared lifecycle guarantees.

Signed-off-by: song <xinxinsong66@gmail.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-06T03:17:41.992630Z a9f7a62 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a9f7a62e94

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ough Core

Signed-off-by: song <liusongstep@gmail.com>
…host

Use the same backend to open and fork native sessions, preserve Core ownership and release fork handles. Fence pre-dispatch cancellation in both drivers. Wait for the session host to exit before cleaning its test directory.

Signed-off-by: song <liusongstep@gmail.com>
@songoow
songoow changed the base branch from codex/oar-deep-fusion-phase0-1 to codex/oar-pr2-eliminate-py-js-pingpong December 6, 2026 06:26

@songoow songoow left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

用户从 Workbench 查看已配置代理的能力、诊断和资源,并据此决定如何恢复工作。以前带有 OAR 能力的代理仍可能只显示空命令或缺少资源入口,本次让工作台从原生运行时读取命令、技能、工具服务和版本信息。已支持版本的工具可以展示诊断;安装的工具低于支持版本时,页面也应提供可信的当前版本和更新信息。本次覆盖工作台只读能力与会话驱动,原生工具的实际升级仍由用户执行。

改动思路 / Approach

运行时报告安装、能力和清单,适配器将它们转换成工作台可消费的数据。线程管理器负责请求配额、复制会话和读取诊断,网页根据返回的状态决定何时展示当前版本、更新提示或清单错误。技能与工具服务沿原来的管理入口读取,避免为只读资源增加写入口。

具体改动 / Changes

OarAdapter 使用原生能力区分可用的配额和整会话复制,SkillsManager 与 McpManager 分别合并可写文件配置和只读清单,网页保留局部错误与部分结果。原来关于技能查询失败被当作空清单的讨论已关闭,当前测试覆盖了该场景。采用 #10241 的多路复用 Node 连接后,托管与独立会话共用活动轮次驱动。派发前取消、fork 返回新会话以及错误身份的关闭均有当前 head 测试。新诊断适配器专门支持可执行文件版本不兼容的安装快照。用真实 ThreadManager 和 OarAdapter 注入低版本 Grok 安装结果。实际请求 GET /api/agents/grok/diagnostics,返回 HTTP 200、missing、version=null、protocol=null,完全没有查询更新;直接调用同一个适配器则读到 1.0.0 及可用的 1.0.95 更新。

P2 · 已安装但版本过旧的 CLI 被显示为未安装,更新诊断无法到达。 运行时 installation() 确认找到了可执行文件并返回 version_unsupported。端点返回 missing、空版本和空协议,并建议检查 PATH;checkUpdate 调用数为零。在公共诊断入口区分版本不支持与未安装,在前一种情况下读取只读诊断并保留不可启动状态。 诊断入口、适配器的版本分支、页面读取方

对主干的风险 / Risks

诊断页会把已知的版本兼容问题误报成路径问题,用户可能重新安装或修改环境变量,仍找不到可用的更新入口。此误报取决于运行时返回的安装状态,示例测试中“可正常启动且有新版本”的场景不会暴露该分支。真实 CLI、供应商更新服务以及桌面与窄屏的实际渲染未验收。当前分支已接入 #10241 的 Node 通道。托管 fork 返回原标识时被拒绝,resume 也继续校验原会话身份,相关测试已通过。

我的整体评价 / Verdict

建议先修复公共诊断入口,保留“已安装、暂不支持”的状态和只读更新能力,再用同一个端点验证未安装与正常安装的对照情况。六个 daemon 测试文件 67 项、Session Hub 24 项和网页 870 项均通过,六个 workspaces 的静态类型检查通过。

English verdict: REQUEST_CHANGES — e87f2dd. The public diagnostics path loses the installed version and update information. Reproduced through the HTTP route using an unsupported-version runtime fixture.

Signed-off-by: Codex <codex@openai.com>
Signed-off-by: song <liusongstep@gmail.com>
Signed-off-by: Codex <codex@openai.com>
Signed-off-by: song <liusongstep@gmail.com>
Signed-off-by: Codex <codex@openai.com>
Signed-off-by: song <liusongstep@gmail.com>
Signed-off-by: Codex <codex@openai.com>
Signed-off-by: song <liusongstep@gmail.com>
Signed-off-by: Codex <codex@openai.com>
Signed-off-by: song <liusongstep@gmail.com>

@songoow songoow left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

工作台用户从同一个界面浏览多个代理、插件和机器的技能,并选择具体来源查看说明。此 PR 将运行时只读清单与现有可写技能目录合并;两个插件可以合法提供同名技能,内建技能也可以没有本地 Markdown 文件。详情应显示所选来源报告的内容,列表默认摘要应对应标为主位置的那一份。本次核对能力展示、配额、复制、诊断和只读资源;无需调用厂商在线更新。

改动思路 / Approach

OAR 适配器把运行时技能、MCP、配额和安装信息映射到 Workbench。HTTP 路由校验 cwd 并读取聚合后的清单;网页在部分来源失败时保留其他结果,用户还可以查看每个技能的具体位置。

具体改动 / Changes

24 个文件覆盖核心与独立会话的事件、fork 和取消,OarAdapter 的能力映射,ThreadManager 的诊断,以及清单的 HTTP、Web 与翻译。此前的过旧 CLI 诊断和显式刷新回归可通过;原先已关闭的部分清单错误反馈也有相应用例。

P2 · 同名只读技能的预览会显示另一来源的说明。 两个运行时分别报告无本地文件的 release 技能,插件 alpha 和稍后观测的 beta 提供不同说明。用户在技能页打开默认副本,或在详情端点选择 bundled:beta。列表选中 bundled:beta 作为主位置,却展示 Alpha release guide;详情返回 HTTP 200 和 path=bundled:beta,skillMd 仍为 Alpha release guide。alpha 的同一请求返回正确说明。 按名称聚合、主位置排序、详情回退、选择位置、页面预览

对主干的风险 / Risks

如果两个来源使用相同技能名,用户可能按错误的操作说明工作;HTTP 状态码是 200,页面没有错误提示。当前测试有可写/只读同名合并和单个内建插件,但没有断言两个虚拟来源的说明各自保持独立。

提交树的八个 daemon 文件 71/71 通过,包含共享 Core 会话、Grok 安装升级与移除、只读写入拒绝、配额与 fork。真实鉴权 HTTP 对照里,访问 alpha 得到 alpha 的说明。

我的整体评价 / Verdict

请修复各来源说明的归属。对当前父分支的 Git 合并是干净的;在测试用的父分支整合 #10243 后,子分支也自动合并,双插件反例仍可重复。远端 chat-bundle 的构建、源文件校验和产物上传均已通过。在线供应商账户及桌面、移动端实际渲染仍待验收。 在每个只读 location 中保存运行时报告的 description。选定主位置或显式 path 后,将该位置的说明作为摘要和虚拟文档的回退值。用两个插件上报同名但说明不同的虚拟技能,检查列表的主来源及两个详情 HTTP 响应,同时保留可写来源和文件正文的优先规则。

English verdict: REQUEST_CHANGES — bf4b2f6. The public skills endpoints pair the beta source with the alpha description. Reproduced with two read-only inventories on the submitted head.

@mergify

mergify Bot commented Dec 6, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with codex/oar-pr2-eliminate-py-js-pingpong and cannot be merged
until they are resolved. Please rebase or merge the base branch, @songoow.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/codex/oar-pr2-eliminate-py-js-pingpong
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/codex/oar-pr2-eliminate-py-js-pingpong and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Dec 6, 2026
Signed-off-by: song <xinxinsong66@gmail.com>
Signed-off-by: song <xinxinsong66@gmail.com>

songoow commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator Author

补充父分支更新后的整合结果。#10241 已更新到 a1ac64604。将本 PR 的 bf4b2f698 叠到该提交时,唯一的 Git 冲突在 apps/workbench/packages/daemon/test/oar-core.test.ts。本地保留父分支的新临时目录前缀和子分支的 fork 断言后,鉴权 HTTP 仍能复现同名技能的问题:选择 bundled:beta,详情返回的路径是 beta,说明却取自 alpha。

同步父分支时可以保留两边的测试意图;技能修复可用两个来源各自的不同描述断言列表和详情。对应评审

@songoow

songoow commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator Author

Synced codex/workbench-oar-parity cleanly with the updated #10241 base (a1ac64604, including #10243 LOOPX_WORKBENCH_* alignment) and verified the diagnostics fix & HTTP route coverage at fa3d01e63:

  • 7084716e1 (merge: sync Workbench OAR parity with updated #10241 (#10243 alignment)): fast-forward merge with origin/codex/oar-pr2-eliminate-py-js-pingpong (a1ac64604), resolving oar-core.test.ts cleanly while preserving both fork-identity coverage and the #10243 naming updates.
  • GPT-6 Astra Pro P2 (version_unsupported diagnostics): confirmed fixed across OarAdapter.unsupportedVersion (adapters/oar.ts), ThreadManager.agentDiagnostic() (threads.ts), and ObservabilityPage.tsx (618c1e54e + ca1f03edd): installed unsupported CLI versions return state: 'unsupported', unsupportedVersion.reason, installed version, protocol: 'OAR', and read-only checkUpdate details while keeping available() === false.
  • fa3d01e63 (test(workbench): verify available-with-update diagnostics over HTTP): expanded the real ThreadManager + GET /api/agents/:id/diagnostics HTTP route test in oar-parity.test.ts to cover all four states across ?refresh=1 — version_unsupported with update, available with update (ready), current, and missing (not_found).

Verification (Node v24.23.0)

  • npm --prefix apps/workbench run typecheck (all 6 workspaces): PASS
  • npm run typecheck:control-plane: PASS
  • node scripts/ci/lint-external-transports.mjs: PASS
  • tests/control_plane_ts/oar_session_hub.test.ts: 24/24 PASS
  • Workbench daemon tests (15 suites incl. oar-parity, oar, oar-core, oar-thread-status, skills, mcp, quota*, fork-subchat, observability-api, lifecycle, workbench-lifecycle, api, adapters): 306/306 PASS
  • Workbench web tests (TZ=UTC npm --prefix apps/workbench test -w @loopx/workbench-web): 875/875 PASS

@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Dec 6, 2026

@maxliux5 maxliux5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini 4 Neon · Google · self_reported

动机 / Motivation

Workbench 用户需要在同一界面下查看全部 9 个 OAR 运行时(cursor、codebuddy、devin、factory、grok、kimi、opencode、qoder、qwen)的 slash commands、只读技能与 MCP 清单、套餐额度、整会话 fork 与版本更新诊断,同时维持“不改写外部运行时配置、不影响既有原生适配器”的只读边界。此前 OAR 适配器在 Workbench 中仅返回空命令且缺少技能/MCP/额度/fork/更新诊断入口,独立会话驱动与 Core 托管会话驱动也各自维护事件投影与生命周期逻辑。本次改动属于基于 #10241 的增量交付,目标是补齐只读能力与驱动收拢;不包含在 Workbench 内执行厂商 CLI 自动升级或写入 OAR 专属技能/MCP 配置文件;当前剩余缺口为:合入顺序依赖 #10241 先落地,且需在合并前修复下述 3 项 P2 阻塞问题。

改动思路 / Approach

本次改动在 OarAdapter 中接入 @botiverse/oar@0.142.0 的 commands、skills、mcpServers、accountUsage、checkUpdate 与 session({ resume, fork }),并在 AgentAdapter 上新增可选异步只读接口 listSkills / listMcpServers 与 unsupportedVersion。SkillsManager 和 McpManager 将可写文件系统扫描与只读运行时清单聚合输出,前端 SkillsPage、McpPage、ObservabilityPage 及三语 locale 据此隐藏只读项的写操作并展示局部错误与更新提示。会话层将事件投影、活动轮次守卫、取消确认与幂等关闭抽离为共享的 OarSessionDriver、assertOarAbortConfirmed 与 observeNativeOarSession,同时由独立 OarSession 与 Core 托管 CoreOarSession 复用。

具体改动 / Changes

核心变更覆盖 24 个文件(+1968 / -322),关键边界核验如下:

  • 能力映射与冷启动探测(adapters/oar.ts、threads.ts、adapters/diagnostics.ts):mapOarCommands、mapOarSkills、mapOarMcpServers、mapOarAccountUsage、mapOarUpdateCheck 使用 @botiverse/oar 的强类型判别联合(kind / reason / code),未引入散文分类;syncCapabilities 动态同步 images、quota、fork 且固定关闭 forkAt/forkInto;ThreadManager.agentQuota 与 forkThread 仅在 !capabilities.* && 对应方法存在 时触发冷启动 available()。
  • 既有原生适配器 default-off isolation(claude、codex、agy、pi、traex、zcode、dsh):已逐一核对全部 7 个原生适配器——均未实现 listSkills / listMcpServers,且支持 quota/fork 的适配器均静态声明对应 capability 为 true,因此默认路径零额外探针与行为漂移。
  • 只读清单与前端交互(skills.ts、mcp.ts、http.ts、SkillsPage.tsx、McpPage.tsx、inventory.ts):/api/skills、/api/skills/detail、/api/mcp 均通过 isWithinWorkdirs 校验 ?cwd=;OarAdapter 不暴露 skillDirs / mcpServers / mcpInstall / mcpRemove,只读写入/导出/删除请求均被拒绝。
  • 与最新 main(含 #10243 / #10263)兼容性:git merge-tree origin/main fa3d01e63baab7eefd47217f0e0c141515bbf5fc 零冲突,且已对齐 #10243 的 LOOPX_WORKBENCH_* 命名;但本 PR 当前 base 仍指向尚未合入的 #10241(codex/oar-pr2-eliminate-py-js-pingpong @ a1ac646045),需按先 #10241 后本 PR 的顺序落地。

在精确提交 fa3d01e63baab7eefd47217f0e0c141515bbf5fc 上核实到以下 3 项阻塞问题(P2) 与 2 项非阻塞建议(P3):

  1. P2(阻塞)· 同名只读技能的描述错配仍未修复,且会跨可写/只读来源污染预览

    • Problem / Evidence:在 apps/workbench/packages/daemon/src/skills.ts(computeListing、detail、findListed)中,SkillInPlace 未保存单来源 description。在当前 fa3d01e63b 实测复现两组反例:(a)两个只读插件 bundled:alpha 与较新的 bundled:beta 报告同名虚拟技能 release 时,列表主位置选中 bundled:beta 却返回 Alpha release guide,请求 /api/skills/detail?name=release&path=bundled:beta 同样返回 skillMd: "Alpha release guide"(上轮审查 bf4b2f698d 的 P2 尚未修复);(b)当可写目录与虚拟只读插件共享同名技能 overlap 时,L421 将 skill.description 覆盖为可写 SKILL.md 描述,导致请求 /api/skills/detail?name=overlap&path=bundled:ro-plugin 误返回可写技能的描述而非只读插件自身描述。此外 L417 比较器 a.mtime < b.mtime ? 1 : -1 在同一次 runtime.skills() 共享相同 observedAt 时破坏严格弱序。
    • Fix:在只读 location 记录中保留各自的 description;修复 L417 排序比较器为三值比较并补充确定性次级键(如 path),主位置为只读时同步 skill.description = primary.description ?? '';detail() 读取只读位置时以该 location 自身的 description 作为 readReadOnlyDoc 回退值,并在 oar-parity.test.ts 补齐“双虚拟插件同名”和“可写+虚拟只读同名”的 HTTP 回归测试。
  2. P2(阻塞)· OarSession(standalone)与 CoreOarSession 在收拢后仍存在 cancel() / exited 生命周期分叉

    • Problem / Evidence:CoreOarSession.cancel()(oar-core.ts#L281-L294)在无活动轮次或 this.isClosed 时安全返回;但独立驱动 OarSession.cancel()(oar.ts#L678-L680)未检查 this.isClosed 或是否存在已派发轮次,直接调用 assertOarAbortConfirmed(await this.session.abort())。在 fa3d01e63b 实测对已 close() 或已触发 exited 的 standalone OarSession 调用 cancel(),两次均抛出 Error: runtime exited,在 ThreadManager.stopTurn()(threads.ts:3582)竞态窗口下会向客户端返回 HTTP 500。同时 oar.ts:641-644 在收到 exited 事件通知 onClosed 驱逐会话后未调用 this.unwatchLifecycle?.() 解除监听(ThreadManager 的 onClosed 回调不会再调用 close())。
    • Fix:在 OarSessionDriver 暴露活动轮次只读状态(如 hasActiveTurn),使 OarSession.cancel() 在 this.isClosed || !this.driver.hasActiveTurn 时与 CoreOarSession.cancel() 一致地幂等返回;在 exited 回调中清理 this.unwatchLifecycle?.();补充 standalone OarSession 在 close() / exited 后调用 cancel() 不抛错的回归测试。
  3. P2(阻塞)· readReadOnlyDoc() 对外部符号链接与超大文件缺少边界防护

    • Problem / Evidence:同文件 walkSkill()(skills.ts:164-172)会拒绝指向目录外的符号链接并限制单文件大小,而新增的 readReadOnlyDoc()(skills.ts#L580-L593)使用 statSync() 跟随任意符号链接,且调用 readFileSync(locationPath).subarray(0, MAX_SKILL_MD) 先将整个文件完整读入内存再截断。实测当工作区运行时的只读技能条目指向外部文件的符号链接时,GET /api/skills/detail 会直接读取并返回符号链接目标文件内容;若目标指向大文件或特殊文件则会造成内存放大风险。
    • Fix:改用 openSync + 定长 readSync 仅读取最多 MAX_SKILL_MD 字节,并用 lstatSync / realpathSync 校验仅读取常规文件且拒绝越界符号链接(或在符号链接逃逸出技能目录/允许工作目录时回退至 description),补充符号链接与超大文件边界测试。
  4. P3(建议)· 非 version_unsupported 的 UnsupportedInstallation 在诊断接口仍显示为 missing

    • Evidence:@botiverse/oar 的 UnsupportedInstallation 还包含 readiness_failed、unrecognized_executable 与 HostUnsupportedInstallation。实测注入 readiness_failed 时,GET /api/agents/grok/diagnostics 返回 state: "missing" 且提示“没有找到 CLI,请检查该实例的命令和 PATH”,丢弃了 adapter.unavailableReason。建议保留 unsupportedVersion 专门控制 checkUpdate(),同时在 ThreadManager.agentDiagnostic() 中对带 unavailableReason 的其他 unsupported 状态透出真实原因与 state: "unsupported"。
  5. P3(建议)· 存在 partial 或单代理错误时,前端搜索/筛选无结果提示被隐藏

    • Evidence:SkillsPage.tsx:243 与 McpPage.tsx:359 的空态条件为 rows.length === 0 && (loading || readErrors.length === 0)。当任意 OAR 代理返回 partial: true 或失败、且用户在已有技能/MCP 列表中输入不匹配的搜索词(或筛选空业务线)时,noMatch 提示会被完全吞掉。建议在 search 非空(以及 MCP 页 line !== null)时仍显示 noMatch。

对主干的风险 / Risks

上述 3 项 P2 直接影响公共 HTTP 路由与运行时稳定性:同名只读技能与跨来源冲突会在 HTTP 200 下静默展示错误的操作说明;standalone OarSession 在关闭/退出竞态下取消会抛 500,打破本 PR 主张的“standalone 与 Core 驱动生命周期一致”不变量;readReadOnlyDoc() 在面对工作区符号链接或超大文件时弱于同文件可写路径的防护基线。本次新增的状态词汇(RuntimeUpdateDiagnostic.status、只读清单字段 readOnly/partial/issues)均直接复用或局部映射 @botiverse/oar 既有类型,未引入需要变更全局状态机注册表的新共享协议。

本地实跑验证记录(精确提交 fa3d01e63baab7eefd47217f0e0c141515bbf5fc,Node v24.21.0):

  • npm --prefix apps/workbench run typecheck(6 个 workspaces):PASS
  • Workbench daemon 14 个测试套件(oar-parity、oar、oar-core、oar-thread-status、skills、mcp、quota、quota-inband、quota-resume、fork-subchat、observability-api、adapters、lifecycle、workbench-lifecycle,umask 0022):184/184 PASS
  • Workbench web 测试(TZ=UTC npm test -w @loopx/workbench-web):875/875 PASS
  • Core OAR Session Hub 测试(tests/control_plane_ts/oar_session_hub.test.ts):24/24 PASS
  • 独立反例复现脚本(覆盖同名虚拟技能、可写/只读同名冲突、standalone cancel() after close()/exited、readReadOnlyDoc 外部符号链接、readiness_failed 诊断):全部在 fa3d01e63baab7eefd47217f0e0c141515bbf5fc 稳定复现
  • 外部真实厂商 CLI 在线更新/额度接口及真实浏览器桌面/窄屏亮暗色渲染:UNVERIFIED

我的整体评价 / Verdict

本 PR 的整体架构、只读边界设计(不伪造可写目录/MCP 写入、不触发 upgrade())、非 OAR 原生适配器的 default-off isolation 以及与最新 main(含 #10243/#10263)的兼容性整体扎实,测试覆盖也远超纯 mock 烟雾测试。但在合入前需先修复上述 3 项 P2(skills.ts 单来源描述归属与排序、standalone OarSession.cancel()/exited 生命周期一致性、readReadOnlyDoc() 符号链接与定长读取边界),待 #10241 合入并切换 base 至 main 后再行复审。由于本轮按保守审查要求以 COMMENTED 形式发布结论,暂不批准合入。

English verdict: REQUEST_CHANGES — fa3d01e. Three verified P2 blockers remain on the exact head: per-location read-only skill descriptions are still dropped across same-name virtual and writable/read-only collisions, standalone OarSession.cancel() throws after close/exit unlike CoreOarSession and leaks its lifecycle listener on exit, and readReadOnlyDoc() follows arbitrary symlinks while reading unbounded files into memory.

Base automatically changed from codex/oar-pr2-eliminate-py-js-pingpong to main December 6, 2026 10:38
Signed-off-by: song <xinxinsong66@gmail.com>
…d-only skills safety

Signed-off-by: song <xinxinsong66@gmail.com>
…me read-only locations

Signed-off-by: song <xinxinsong66@gmail.com>
@songoow

songoow commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator Author

Synced codex/workbench-oar-parity with latest main (9e4730c13, including merged #10241 & #10251) and hardened all OAR parity invariants at ed10577d5 (strict fast-forward over fa3d01e63, all new commits DCO signed):

Summary of Hardening Fixes (Verified by Counterexamples & Regression Tests)

  • Read-only skills description, metadata isolation & strict ordering (skills.ts, api.ts):
    • Preserved per-location description on read-only SkillInPlace entries and introduced canonical summarizeSkillLocation() across computeListing(), findListed(), and findWritable(), fixing same-name virtual plugin collisions (bundled:alpha vs bundled:beta), writable+read-only collisions, and stale optional plugin/scope/source/enabled key bleed on promotion or secondary detail(name, path) selection.
    • Replaced non-antisymmetric location sort with strict weak ordering (compareSkillLocations, tie-breaking on path) and removed redundant readMeta() disk I/O in scanWritable().
  • Bounded symlink-safe readReadOnlyDoc() (skills.ts):
    • Replaced statSync + full readFileSync().subarray() with lstatSync + openSync(..., O_RDONLY | O_NOFOLLOW) + fstatSync + bounded readSync capped at MAX_SKILL_MD (256 KiB), rejecting symlinked files, symlinked skill directories, and directory-internal escaping SKILL.md symlinks.
  • Standalone OarSession ↔ CoreOarSession lifecycle parity (oar.ts, oar-events.ts):
    • Exposed OarSessionDriver.hasActiveTurn, made standalone OarSession.cancel() an idempotent no-op when idle/closed/exited while keeping strict abort confirmation during active sent turns, and detached unwatchLifecycle immediately on exited.
  • Wall-clock probe deadlines & diagnostics classification (oar.ts, diagnostics.ts, threads.ts):
    • Enforced bounded probe deadlines (withProbeTimeout with unref() timer + late-rejection guard) across installation, listModels, commands, skills, mcpServers, accountUsage, and checkUpdate (never invoking upgrade(); hanging checkUpdate returns { status: 'unavailable', reason: 'timeout' }, hanging installation does not poison this.probe).
    • Surfaced non-version_unsupported UnsupportedInstallation (readiness_failed, unrecognized_executable, host_unsupported) and probe timeouts with their real unavailableReason instead of missing, mapped typed agent_login_required/agent_unsupported in diagnosticFailure(), cloned diagnostic capability snapshots immutably, and forwarded refresh in agentQuota().
  • Fork/handle disposal & mapper edge cases (oar.ts, oar-core.ts):
    • Rejected whitespace-only returned/source session IDs in both standalone and Core backends (releasing leaked handles via shared CoreOarHostBackend.closeLeakedSession()), prevented close() errors from masking primary fork validation errors, disposed native Session if new OarSession(native) throws, and hardened mapOarCommands, mapOarMcpServers, and mapOarAccountUsage (checkedAt/resetsAt validation).
  • Web empty-state & read-only guard (SkillsPage.tsx, McpPage.tsx):
    • Preserved noMatch when searching/filtering alongside partial/errored providers and gated MCP removal by !place.server.readOnly.
  • Exhaustive state-matrix tests (oar-parity.test.ts, oar-core.test.ts):
    • Added full HTTP state-matrix suites covering installation × checkUpdate × listModels × refresh, listSkills/listMcpServers/commands + collisions + symlink/256 KiB safety, accountUsage + forkSession disposal edge cases, and standalone OarSession lifecycle parity (zero playwright-core imports).

CI (merge-gate) & Local Verification (Node v24.23.0)

  • merge-gate (run 47628916672 / job 146016987070) had failed solely because all upstream jobs in that superseded run were cancelled (rerun 47629012794 on fa3d01e63 passed merge-gate and all active checks).
  • npm --prefix apps/workbench run typecheck (all 6 workspaces) + npm run typecheck:control-plane + node scripts/ci/lint-external-transports.mjs: PASS
  • tests/control_plane_ts/oar_session_hub.test.ts: 24/24 PASS
  • Workbench daemon suites (16 suites incl. oar-parity, oar, oar-core, oar-thread-status, skills, mcp, quota*, fork-subchat, observability-api, lifecycle, workbench-lifecycle, adapters, api): 309/309 PASS
  • Workbench web suite (TZ=UTC npm --prefix apps/workbench test -w @loopx/workbench-web): 880/880 PASS

Signed-off-by: Codex <codex@openai.com>
Signed-off-by: song <liusongstep@gmail.com>

@songoow songoow left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

在 Workbench 按技能来源阅读说明、分叉会话或查看账号用量的用户,需要界面与当前宿主能力一致。主干通过技能接口读取两份同名运行时技能时列表为空,两个详情都返回 404。早先的 PR 还能把另一来源的说明显示在所选位置。当前代码按具体位置返回说明和来源,最新来源提升到列表,保留其余来源的独立预览;分叉、用量和诊断根据运行时能力呈现。本次验收覆盖工作台公开 HTTP、实际适配器、脚本化供应商和独立/托管会话入口。

改动思路 / Approach

能力是否存在由已安装的 OAR 运行时决定,技能管理器负责排序和按路径取回详情,界面沿用宿主返回的只读事实。这个 PR 复用现有 HTTP、线程管理与 OAR 会话所有者,同时让每个只读来源保留自己的描述和元数据。通过同一入口和合成 fixture 比较改动前后的运行结果,并核对错误返回时能否恢复原有工作流。

具体改动 / Changes

独立 HTTP 检查还确认普通 280 KiB 的只读文档只返回 262144 字节,小文档完整返回。Workbench 构建和类型检查均通过。11 项 OAR 能力和状态矩阵、32 项 daemon 常规用例、17 项 Web 逻辑测试和工作区类型检查通过。真实包能力矩阵中 OpenCode v2 可以在同目录分叉整段对话;Factory Droid、Grok 和 Kimi 可报告用量。同一组两个只读的 release 技能,主干返回空列表,当前 HTTP 列表指向较新的 bundled:beta;显式取 alpha 和 beta 分别返回 Alpha release guide 与 Beta release guide,插件字段也各自匹配。按路径取旧来源时不会复用新来源的预览,缺失与不支持状态有各自诊断;账号用量超时走已有失败处理,分叉失败释放复制的会话。

此外,独立会话在原生退出后清除监听,重复取消或关闭保留原有生命周期;诊断刷新覆盖缺失、不支持、有更新和已是当前版本的状态。 README 已同步整段分叉与用量支持条件。

本次按 apps/workbench/README.md(cef1a7569a3e61bf66940f9b0f6ff8ebc989c009)核对 OAR_CAPABILITIES 的实现。其中比较的是仓库实际调用方所获得的结果,远端整套发布流水线单独记录。

对主干的风险 / Risks

HTTP 用真实路由与两个脚本化 OAR 供应商。实际付费账号、平台级配额和所有宿主版本组合未现场验证。若与 #10275 一起落地,两处共享适配器有文本冲突,已在独立整合树验证合并后的技能、分叉及断线交接。按路径取旧来源时不会复用新来源的预览,缺失与不支持状态有各自诊断;账号用量超时走已有失败处理,分叉失败释放复制的会话。另在主干与本分支重跑同一条 Ruff 检查,都报 executor.py 第 91 行相同的 F401。这是独立的合并门禁问题。上述证据支持本次所修改的调用边界;对未执行的平台不作延伸判断。

我的整体评价 / Verdict

桌面亮色和手机深色各检查了 Skills、MCP 及诊断页。部分读取提示在列表前面,无匹配搜索仍给出反馈,技能详情显示所选只读来源,诊断把可用更新放在已装版本旁。画面使用固定的本机数据与真实页面组件,未覆盖各语言、所有主题组合和远程多机布局。能力是否存在由已安装的 OAR 运行时决定,技能管理器负责排序和按路径取回详情,界面沿用宿主返回的只读事实。这个 PR 复用现有 HTTP、线程管理与 OAR 会话所有者,同时让每个只读来源保留自己的描述和元数据。

English verdict: APPROVE at cef1a75. Read-only skill identity, independently scoped previews, runtime-gated fork and quota, and the user guide now agree.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants