Repository navigation
[native] omp: three-mode alignment (proxy / launcher / native plugin) + runtime-info #957
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Goal
Bring omp to full three-mode alignment like pi / opencode / dsh already have:
- Mode 1 — proxy (URL prefix, exists today via launcher)
- Mode 2 — launcher (
bili omp— exists) - Mode 3 — native plugin (
bili plugin install omp— the gap): plugin loaded by the CLIENT itself, spawns/attaches its own proxy, rewrites model traffic, registers ACP tools natively, stamps plugin-mode headers, implements the runtime-info protocol.
Feasibility pre-assessment
OpenCode-fork
HIGH — omp is an opencode fork; if it retains opencode's plugin API (config hooks / chat hooks / tool registration), the opencode v1 native path (src/agent/opencode-native.ts) ports almost directly. Start by diffing its plugin surface against opencode 1.x.
Reference implementations (read these first)
src/agent/dsh-native.ts— cleanest full native (dynamic service inject, fetch patch, header gating, runtime-info stamps). PR feat: dsh native mode — full plugin viabili plugin install dsh+ upgraded launcher (#941) #942 / issue dsh: full plugin/native mode (mode 3) + upgrade launcher to plugin-mode compression (mode 2) #941.src/agent/opencode-native.ts(v1) +src/agent/opencode-v2.ts— config/catalog-based window+output maps, legacy-lane routing. PRs feat: OpenCode 1.x native support — V1 .server() hooks on the standard install path #919/feat: v1 legacy-lane routing — opencode-acp old sessions keep working, new sessions go to bili (#920) #921.src/agent/pi.ts/src/agent/pi-native.ts— header stamping discipline (toolsReady gate).- Installer:
src/plugin-install.ts(bili plugin install <client>); launcher wiring:src/launcher.ts. - Runtime-info protocol ([native] runtime-info protocol: plugins report real model config (model / contextWindow / maxOutput) to the proxy #955, PR feat: runtime-info protocol — plugins report real model config to the proxy (#955) #956): per-request headers
x-bili-plugin-context-window/x-bili-plugin-max-output/x-bili-plugin-model(gated onx-bili-plugin) + bootstrapPOST /__bili/plugin/runtime-info. README "Runtime-info protocol" table is the contract — follow it exactly.
Requirements if feasible
- No launcher, no env vars, no fixed port for the end user; opt-out env
BILI_NATIVE_OMP=0 - Plugin-mode gating: stamp
x-bili-pluginONLY after native tools are registered (round 1 rides wire mode) - Parent-pid watchdog proxy teardown; attach to a healthy proxy when present
- Runtime-info stamps (model + contextWindow + maxOutput whenever the client exposes them)
npm run typecheck+npm test+npm run buildgreen; new tests for the plugin module (see tests/dsh-native.test.ts for the harness style)- README (en + zh) client table + install section updated
If NOT feasible
Post the evidence (what extension points exist, why wire interception / native tools are impossible) and close as wontfix — a documented no is a deliverable too.
For ework
This issue is directly implementable. Follow the dsh playbook; ask in this thread before inventing new protocol surface. PR must reference this issue (Fixes #N).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
ranxianglei commentedon Sep 19, 2026
开工。omp 是 opencode fork,可行性预评估 HIGH——按 dsh playbook 先确认它保留的插件 API(config hooks / chat hooks / fetch patch),可行即全量三模式,不可行贴证据 wontfix。
ranxianglei commentedon Sep 19, 2026
@ework 开工 #957(omp 三模式)。omp 是 opencode fork,可行性预评估 HIGH。按 dsh playbook 先做可行性预研:确认 omp 保留的插件 API(config hooks / chat hooks / fetch patch / 工具注册面),可行即按 #964/#941 同款 playbook 全量三模式(companion → launcher → native),不可行贴证据 wontfix。注意先看 repo 的 AGENTS.md。
ranxianglei commentedon Sep 19, 2026
可行性预研完成,结论:HIGH,全量三模式开工(不 wontfix)。先纠正一个前提:
omp 不是 opencode fork,是 pi(oh-my-pi)fork。 本机装了
@ranxianglei/omp-stablev18.0.3(源码可读),证据:github.com/ranxianglei/oh-my-pi,依赖全是@oh-my-pi/pi-*系(pi-agent-core / pi-ai / pi-catalog);作者 Stencil Labs / Mario Zechner(pi 的作者)。bili 自己的代码也一直按 pi-based 处理它(src/agent/omp.ts就是createBiliPlugin("omp"))。ExtensionFactory(default export)、on/registerTool(含loadMode:"essential")/registerCommand/registerProvider/setModel/sendMessage;事件面有session_start/session_switch/session_before_compact/session_compact/before_provider_request/auto_compaction_start|end;ctx.model带id / contextWindow / maxTokens / baseUrl(runtime-info 字段齐全)。before_provider_headers在 omp 全源码树零命中——所以 omp 的 plugin-mode 绑定走 identity register +prompt_cache_keystamp(现有src/agent/pi.ts已实现),runtime-info 只能走POST /__bili/plugin/runtime-info通道(per-request header 通道在 omp 上不存在)。运行时实证(不是纸面推断):用隔离 HOME 跑了一次真
omp-stable -p,注入探针扩展——isBun:true,#!/usr/bin/env bun直接跑 TS 源码树);globalThis.fetch可赋值(patched:true)→ pi-native 同款的 fetch 拦截机制在 omp 下成立;extensions:绝对路径条目 + default-export factory 加载路径在 18.0.3 验证通过。因此 playbook 按 dsh/pi-native 同款执行(companion 已有 → launcher 已有 → 补 native):
src/agent/omp-native.ts(镜像pi-native.ts:自拉起代理 attach-or-spawn、fetch 拦截、BILLION_CONTEXT_PROXY、opt-outBILI_NATIVE_OMP=0、coexistence marker);pi.ts:omp 的 runtime-info 上报挂到before_provider_request(toolsReady 门控,与 pi 的 header 路径同语义);bili plugin install omp改装 native 入口,旧 thin 条目(dist/agent/omp.js)自动迁移;做完贴 PR(带
Fixes #957)。ranxianglei commentedon Sep 19, 2026
完工 ✅ 可行性预研 HIGH 坐实(上条回复的探针结论:Bun 运行时、fetch 可 patch、插件 API 面完整),已按 pi/dsh playbook 全量三模式落地。
PR: #981
交付内容
1. 原生模式(
bili plugin install omp,免启动器)src/agent/omp-native.ts(镜像pi-native.ts):加载时自拉起代理(健康实例则附看 + parent-pid 看门狗)、全局 fetch 拦截把模型流量改写到<proxy>/bili/<upstream>、注册compress/decompress/acp_status原生工具(plugin 模式)、工具就绪前第一轮走 wire 模式。模块求值时同步置BILLION_CONTEXT_NATIVE=omp,独立扩展进程内自动退让。退出开关BILI_NATIVE_OMP=0。tsup.config.ts新入口 → 自包含dist/agent/omp-native.js(acp-kernel 内联);薄版dist/agent/omp.js保留给 launcher 模式。2. 安装器迁移(
src/plugin-install.ts)dist/agent/omp.js条目被同一 entry 正则识别,重装即替换升级——每个 config 恰好一个 bili owner,输出带(replaced …)。remove/status/launcher loader-check 两种形态都认,stale 路径仍报broken。3. runtime-info(#955 协议,
src/agent/pi.ts)createBiliPlugin("omp")改从before_provider_request走POST /__bili/plugin/runtime-info上报(与其他 native host 同形状,按模型切换去重,soft-fail)。代理侧窗口解析链不变(runtime-info 表本来就存在)。验证
tests/omp-native.test.ts(bootstrap gate 真值表含跨宿主 opt-out 隔离、native-marker 不变量、script-path 解析、安装器 fresh/idempotent/薄→原生迁移/去重/remove/status/launcher-e跳过)+tests/plugin-agent.test.ts里一个走真实 HTTP fake proxy 的 runtime-info 端到端(工具就绪前静默、同模型去重、换模型再报)。src/update.ts。README en/zh 已同步(客户端表、Option 1 清单、opt-out envs、runtime-info 实现列表)。等 CI + 人工合并。
一句话中文摘要:omp 三模式对齐完成——新增自拉起原生插件入口、安装器把旧薄版条目原地迁移为 native 形态、补齐 runtime-info 上报通道,12 个新测试 + 既有套件在最新 master 上全绿,可以合并。
feat: omp three-mode alignment — native self-spawning plugin + runtim…
fix: size OMP native windows from conversation-scoped runtime-info (#…