Skip to content

feat: omp three-mode alignment (proxy / launcher / native plugin) + runtime-info - #981

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-19_omp-native-three-mode
Sep 19, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-19_omp-native-three-mode

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #957

omp is an opencode fork on Bun that keeps the full pi extension API (config hooks / chat hooks / fetch patch / tool registration) — verified by live probe in the issue thread. This aligns omp with the #964 (pi) / #941 (dsh) three-mode playbook.

1. Native mode (bili plugin install omp, no launcher)

  • New src/agent/omp-native.ts mirroring pi-native.ts: at load it spawns its own proxy (or attaches to a healthy running one, parent-pid watchdog), rewrites model traffic to <proxy>/bili/<upstream> via the global fetch intercept, registers compress / decompress / acp_status as native client tools (plugin mode), and gates the plugin-mode header on tool readiness (round 1 rides wire mode). Sets BILLION_CONTEXT_NATIVE=omp synchronously at module evaluation so standalone extensions back off in-process. Opt-out: BILI_NATIVE_OMP=0.
  • tsup.config.ts: new entry → self-contained dist/agent/omp-native.js (acp-kernel inlined). Thin dist/agent/omp.js stays for launcher mode.

2. Installer migration (src/plugin-install.ts)

  • pluginInstall("omp") now targets dist/agent/omp-native.js. Pre-[native] omp: three-mode alignment (proxy / launcher / native plugin) + runtime-info #957 thin dist/agent/omp.js entries are recognized by the shared entry regex and replaced on re-install — old installs upgrade to native mode, exactly one bili owner per config, output notes (replaced …). Remove / status / launcher loader-check accept both forms; stale paths still report broken.

3. Runtime-info (#955 protocol, src/agent/pi.ts)

  • omp has no per-request header event, so the "omp" flavor of createBiliPlugin reports via POST /__bili/plugin/runtime-info from before_provider_request — same shape as the other native hosts, deduped per model switch, soft-fail. Proxy-side window resolution unchanged (runtime-info table already exists).

Tests: 12 new — tests/omp-native.test.ts (bootstrap gate table incl. cross-host opt-out isolation, native-marker invariant, script-path resolution, installer fresh / idempotent / thin→native migration / dedupe / remove / status / launcher -e skip) and a real-HTTP fake-proxy end-to-end for the runtime-info flow in tests/plugin-agent.test.ts (silence before tool readiness, dedupe, model switch). Two pre-existing tests updated for the intentional migration semantics (#392 sub-test a, fake-HOME roundtrip). 1930 pass / 0 fail; typecheck + build green on the rebased head (current master ba6c9ad).

Docs: README en/zh — client table, Option-1 list, opt-out envs, runtime-info implementations list.

Not touched: wire protocol, config schema, persistence format, acp-kernel pin, src/update.ts.

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-19_omp-native-three-mode (5071a29)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-981

Each push to this PR publishes a new version under the pr-981 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr981.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Picked up — this is a completed-work PR, so I'm verifying rather than redoing: fetching 2026-09-19_omp-native-three-mode (f017055), reviewing the diff against master ba6c9ad, re-running typecheck/test/build on the head, and tracking CI (one windows check still in progress at pickup). Will report findings here shortly.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Verification complete — this PR is solid and ready for a human merge. I reviewed rather than redid (completed-work PR from the #957 session).

Branch & base

  • Single commit f017055 directly on current master ba6c9ad — fresh base, zero drift.
  • CI: all 8 checks green (ubuntu/windows × 22/24, real-codex e2e, build-artifact, version-guard); mergeable_state: clean.

Local pre-flight on the head (re-ran everything)

  • npm run typecheck — green
  • npm test — 1930 pass / 0 fail / 2 skipped (matches the PR claim exactly)
  • npm run build — green; dist/agent/omp-native.js = 1.91 MB self-contained (acp-kernel inlined, same class as pi-native.js), thin dist/agent/omp.js still built for launcher mode
  • Artifact smoke: importing the built dist/agent/omp-native.js sets BILLION_CONTEXT_NATIVE=omp synchronously at module evaluation (the coexistence-marker invariant holds in the shipped bundle, not just source) and exports an ExtensionFactory

Code review findings

  • src/agent/omp-native.ts mirrors pi-native.ts faithfully but DRY-er than the PR body implies — it reuses the shared native-bootstrap.ts / native-intercept.ts plumbing instead of duplicating. Gate table verified: BILI_NATIVE_OMP=0 / BILLION_CONTEXT_PLUGIN=0 opt-outs, backoff when a bili launch already owns the proxy (BILLION_CONTEXT_PROXY / BILI_PROVIDER_REWRITES — so bili omp never double-spawns against a loadable installed entry), cross-host opt-out isolation (BILI_NATIVE_PI=0 doesn't affect omp), NODE_TEST_CONTEXT guard so tests never spawn a real proxy.
  • Installer migration (src/plugin-install.ts): traced every edge — fresh / idempotent / thin→native replace-with-note / duplicate-collapse / stale-only→broken status / remove keeps foreign entries / launcher -e skip accepts both forms. OMP_ENTRY_RE now matches both omp.js and omp-native.js; "exactly one bili owner per config" holds. The intentional semantic change (any in-block entry matching our shape is now managed, even if stale) is covered by the updated Claude Opus 5 经中转被当 200K 用:models.dev 查找被 host 门槛旁路 + 面板硬编码 200K 兜底 + 变体后缀失配 + 自愈只降不升 #392 sub-test.
  • Runtime-info (src/agent/pi.ts): omp reports via POST /__bili/plugin/runtime-info from before_provider_request, gated on toolsReady (round 1 rides wire mode, same as pi's header path), deduped per model switch through the shared reportRuntimeInfoOnChange, soft-fails when no proxy base — same shape as the other native hosts. Two-mode check (§6): plugin mode is the only mode omp native uses (carrier = the agent's own tool calls); proxy mode is untouched.
  • Docs en/zh in sync (client table, Option-1 list, opt-out envs, runtime-info implementations list).
  • Diff is clean: 8 files, every line on-purpose, no whitespace churn, no lock-file/generated churn. Nothing I would fix directly — no defects found.
  • E2E regression suite not required here: no changes to server.ts, src/loop/, adapters, or preflight/compact paths.

⚠️ Sequencing note (hot-file contention with open PRs)
This PR shares files with three open PRs; whoever merges second must rebase + re-run the full gate:

Suggested order: merge whichever of #974/#979/#980 is furthest along first, then rebase #981 (trivial — its hunks are disjoint in intent; the tsup.config.ts array line is the only likely textual collision) and re-run typecheck+test+build. Merging remains human-only; this is a feat: with new capability surface, so it doesn't qualify for auto-merge regardless.


中文摘要:核验了 #957 的 omp 三模式对齐 PR(分支新、CI 全绿,本地重跑 typecheck/1930 测试/build 全过,产物冒烟确认原生标记同步生效);代码与 pi/dsh 既有模式一致、迁移语义完整,未发现需修复的问题——可以合并,但注意与 #974/#979/#980 存在热文件竞争(尤其 tsup.config.ts 入口行必撞),建议先合其中一个再 rebase 本 PR。

@ranxianglei
ranxianglei force-pushed the 2026-09-19_omp-native-three-mode branch from f017055 to 5071a29 Compare September 19, 2026 07:26
@ranxianglei
ranxianglei merged commit 1802e86 into master Sep 19, 2026
8 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-19_omp-native-three-mode branch October 15, 2026 05:32
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.

[native] omp: three-mode alignment (proxy / launcher / native plugin) + runtime-info

1 participant