Skip to content
Merged
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
15 changes: 15 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ jobs:
src/main/codex/codex-structured-session-cancel.test.ts
src/main/codex/codex-structured-launch-resolution.test.ts
src/main/codex/codex-session-index-heal.test.ts
src/main/codex/codex-daemon-socket-path-guard.test.ts
src/main/codex/codex-config-mirror.test.ts
src/main/codex/config-settings-promotion.test.ts
src/main/codex/config-sync-stall.test.ts
src/main/codex-accounts/codex-config-mirror.test.ts
src/main/codex-accounts/legacy-shared-config-compatibility.test.ts
src/main/codex-accounts/runtime-home-managed-auth-recovery.test.ts
src/main/codex-accounts/runtime-home-real-home-lane-routing.test.ts
src/main/codex-accounts/runtime-home-retained-auth-provenance.test.ts
src/main/codex-accounts/runtime-home-system-resource-materialization.test.ts
src/main/codex-accounts/service-account-add-login.test.ts
src/main/codex-accounts/service-reset-credit-home-ownership.test.ts
src/main/codex-accounts/service-wsl-accounts.test.ts
src/main/codex-accounts/service.test.ts
src/main/ssh/relay-socket-path-limit.test.ts
src/main/codex-accounts/codex-credential-absence-grace.test.ts
src/main/codex-accounts/codex-windows-interactive-login.test.ts
src/main/codex-accounts/service-login-process-teardown.test.ts
Expand Down
1 change: 1 addition & 0 deletions config/tsconfig.cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"../src/main/codex/codex-config-settings-preservation.ts",
"../src/main/codex/codex-config-settings-removal.ts",
"../src/main/codex/codex-config-settings-upsert.ts",
"../src/main/codex/codex-daemon-socket-path-guard.ts",
"../src/main/codex/codex-home-paths.ts",
"../src/main/codex/codex-hook-definition.ts",
"../src/main/codex/codex-managed-home-resource-copy-marker.ts",
Expand Down
6 changes: 4 additions & 2 deletions ref/upstream.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ managed server 自动部署、SSH → managed server、WSL 生命周期、proces

维护对象为 Claude、Cursor、DSH、GitHub Copilot、Codex、OpenCode。按智能体及实际依赖同步,不能按目录覆盖;共享主机的宿主设置链已由 #592 更新,但不代表所有智能体的进程、模型、账号与统计框架都已升级。

本表记录**当前采用边界**。**采用**指已接入的指定行为;**保留**指沿用 BW 已有实现;**未迁**指固定上游有而未采用;**上游无**指固定版本没有相应原生 provider;**未专项核对**不代表无能力或已经对齐。DSH、Cursor、Codex 的核对日期均为 2026-11-09;源码对照与验证证据见各行 PR。
本表记录**当前采用边界**。**采用**指已接入的指定行为;**保留**指沿用 BW 已有实现;**未迁**指固定上游有而未采用;**上游无**指固定版本没有相应原生 provider;**未专项核对**不代表无能力或已经对齐。DSH、Cursor、Codex 的六维核对日期为 2026-11-09;源码对照与验证证据见各行 PR。

| 智能体 / 已合入依据 | 启动与交互 | 账号、服务商与模型 | 会话管理 | 套餐额度 | Token 与费用统计 | 执行环境 |
| --- | --- | --- | --- | --- | --- | --- |
| **DSH** · [#581](https://github.com/forcegravity1989/builder-workbench/pull/581) | 采用发现、工作区启动、首条输入及 hooks;启动/续接固定 DSH backend;新版启动页重试未迁 | 使用执行宿主的 DSH/profile/CLI 配置;未新增 BW 独立账号管理和模型目录 | 采用 hook session ID、休眠续接及宿主能力门控;无 ID 不承诺恢复;未接入压缩历史扫描 | **上游无 DSH 原生额度 provider**;BW 未接入 | **上游无 DSH 历史用量 provider**;BW 未接入 | 采用身份别名、WSL 透传和现有远端接线;CLI、账号及匹配 hooks 由实际宿主提供 |
| **Cursor** · [#578](https://github.com/forcegravity1989/builder-workbench/pull/578) | 保留 TUI/输入;采用显式模型去重、hook 编码与防重复上报;通用输入框架未整体迁移 | 采用本机账号状态与凭据只读;登录/切号仍归 Cursor;保留模型选择,公共参数解析剩余差异未迁 | 采用 conversation ID 续接、能力门控及拒读元数据保持未知;通用历史框架未整体迁移 | 采用套餐/模型池/重置周期/团队个人额度;外部 SQLite worker 隔离未迁;其他宿主账号未接入 | **上游无 Cursor 每日 token provider**;套餐数字不等于每日 token/费用统计 | 保留既有宿主路由,改善 Windows/POSIX hooks;实际启动 HOME/信任上下文链未迁 |
| **Codex** · [#577](https://github.com/forcegravity1989/builder-workbench/pull/577) | 保留 TUI/结构化会话;采用退出末尾回复排空、短时额度/索引探测禁插件;完整新启动/停止协议未迁 | 采用 180 秒登录等待及凭据暂缺跟踪容量;保留账号/模型配置;设备码/可取消登录、共享模型目录未迁 | 保留历史、恢复、审批及停止,采用索引探测与退出修复;新 reopen/catch-up/共享恢复协议未迁 | 采用 HTTP 替代隐藏交互终端、索引重建期额度读取、WSL 请求去重;会话固定账号用量/额外余额显示未迁 | 保留既有日志、每日聚合及成本估算;**上游有但未迁** v7 去重、长上下文计数、追加扫描/轮换识别和主会话上下文用量 | 保留既有账号/目录/宿主路由;Windows 异步命令解析、guest-only WSL CLI、process-host/sealed env 未迁 |
| **Codex** · [#577](https://github.com/forcegravity1989/builder-workbench/pull/577) | 保留 TUI/结构化会话;采用退出末尾回复排空、短时额度/索引探测禁插件;按 [Orca #22878](https://github.com/stablyai/orca/pull/22878) 在套接字路径超限的托管目录关闭后台服务自动启动;完整新启动/停止协议未迁 | 采用 180 秒登录等待及凭据暂缺跟踪容量;保留账号/模型配置;设备码/可取消登录、共享模型目录未迁 | 保留历史、恢复、审批及停止,采用索引探测与退出修复;新 reopen/catch-up/共享恢复协议未迁 | 采用 HTTP 替代隐藏交互终端、索引重建期额度读取、WSL 请求去重;会话固定账号用量/额外余额显示未迁 | 保留既有日志、每日聚合及成本估算;**上游有但未迁** v7 去重、长上下文计数、追加扫描/轮换识别和主会话上下文用量 | 保留既有账号/目录/宿主路由;Windows 异步命令解析、guest-only WSL CLI、process-host/sealed env 未迁 |
| **Claude** | 未专项核对,沿用既有实现 | 未专项核对 | 未专项核对 | 未专项核对 | 未专项核对 | 未专项核对 |
| **GitHub Copilot** | 未专项核对,沿用既有实现 | 未专项核对 | 未专项核对 | 未专项核对 | 未专项核对 | 未专项核对 |
| **OpenCode** | 未专项核对,沿用既有实现 | 未专项核对 | 未专项核对 | 未专项核对 | 未专项核对 | 未专项核对 |

来源边界:Cursor/Codex 对照上述 v251 SHA;DSH 采用的独立提交及排除范围见 [DSH 接入来源](dsh-harness-integration.md#上游来源),本轮再用 v251 核对 provider 缺口。[固定版额度类型](https://github.com/stablyai/orca/blob/a162e08b29b2883b02d8a0dfcc99e26c80b2cfe7/src/shared/rate-limit-types.ts)没有 DSH;[历史用量 provider](https://github.com/stablyai/orca/blob/a162e08b29b2883b02d8a0dfcc99e26c80b2cfe7/src/main/usage/usage-provider-contract.ts)没有 DSH/Cursor。这不判断 CLI 自身或第三方插件是否有统计能力。Cursor 的每日 token 需求仍见 [#498](https://github.com/forcegravity1989/builder-workbench/issues/498),不能用账号额度代替它。

Codex 托管目录的套接字修复单独核对于 2026-11-13,来源为 Orca 提交 `c220d92c03addc5b608b4074b5efc8d44c91d0d3`(BW [#643](https://github.com/forcegravity1989/builder-workbench/issues/643))。覆盖系统默认镜像、单账号托管目录、旧共享目录及 WSL 托管启动;按执行宿主的套接字路径上限判定。配置镜像的本地覆盖项不会回写到用户源配置;写入采用 [Orca #31228](https://github.com/stablyai/orca/pull/31228) 的托管镜像文件权限(POSIX `0600`)。

公共依赖适配不等于该智能体已专项同步;例如修正 Cursor 导入 Claude hook 时的重复上报,不构成 Claude 六维升级。

### 0.5 共享主机与网页批注采用索引
Expand Down
83 changes: 83 additions & 0 deletions src/main/codex-accounts/codex-config-mirror.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
import type * as NodeOs from 'node:os'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { getDefaultSettings } from '../../shared/constants'

const testState = vi.hoisted(() => ({ fakeHomeDir: '' }))

vi.mock('electron', () => ({
app: {
getPath: () => {
throw new Error('tests pass explicit homes')
}
}
}))

vi.mock('node:os', async () => {
const actual = await vi.importActual<typeof NodeOs>('node:os')
return { ...actual, homedir: () => testState.fakeHomeDir }
})

import { CodexConfigMirror } from './codex-config-mirror'

const OVERRIDE_LINE = 'daemon_auto_start = false # orca: CODEX_HOME too long for the daemon socket'

describe('CodexConfigMirror without ~/.codex/config.toml', () => {
let root: string
let managedHomePath: string
let mirror: CodexConfigMirror

beforeEach(() => {
root = mkdtempSync(join(tmpdir(), 'orca-codex-accounts-mirror-'))
testState.fakeHomeDir = join(root, 'user-home')
mkdirSync(testState.fakeHomeDir)
// Long enough to exceed sun_path on every platform, like a real account home.
managedHomePath = join(root, 'a'.repeat(80), 'home')
mkdirSync(managedHomePath, { recursive: true })
const settings = {
...getDefaultSettings(testState.fakeHomeDir),
codexManagedAccounts: [
{
id: 'acct',
email: 'user@example.com',
managedHomePath,
createdAt: 1,
updatedAt: 1,
lastAuthenticatedAt: 1
}
]
}
mirror = new CodexConfigMirror({ getSettings: () => settings }, (path) => path)
})

afterEach(() => {
rmSync(root, { recursive: true, force: true })
})

it('still guards every managed home against the daemon socket limit', () => {
mirror.safeSyncToManagedHomes()

expect(readFileSync(join(managedHomePath, 'config.toml'), 'utf-8')).toBe(
`[features]\n${OVERRIDE_LINE}\n`
)
expect(existsSync(join(testState.fakeHomeDir, '.codex'))).toBe(false)
})

it('leaves a WSL home to launch prep instead of running its blocking ownership check', () => {
const assertManagedHomePath = vi.fn((path: string) => path)
const wslMirror = new CodexConfigMirror(
{ getSettings: () => getDefaultSettings(testState.fakeHomeDir) },
assertManagedHomePath
)

wslMirror.safeSyncIntoManagedHome(
'\\\\wsl.localhost\\Ubuntu\\home\\u\\.local\\share\\orca\\codex-accounts\\acct\\home',
undefined,
'acct'
)

expect(assertManagedHomePath).not.toHaveBeenCalled()
})
})
12 changes: 10 additions & 2 deletions src/main/codex-accounts/codex-config-mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { existsSync, readFileSync } from 'node:fs'
import { homedir } from 'node:os'
import { join } from 'node:path'
import { parseWslUncPath } from '../../shared/wsl-paths'
import { syncSystemConfigIntoManagedCodexHome } from '../codex/codex-config-mirror'
import {
ensureCodexDaemonSocketGuard,
syncSystemConfigIntoManagedCodexHome
} from '../codex/codex-config-mirror'
import { readCodexTopLevelModelProvider } from '../codex/codex-model-provider-config'
import type { Store } from '../persistence'
import { toWindowsWslPath } from '../wsl'
Expand All @@ -17,7 +20,7 @@ export type CanonicalCodexConfig = {

export class CodexConfigMirror {
constructor(
private readonly store: Store,
private readonly store: Pick<Store, 'getSettings'>,
private readonly assertManagedHomePath: (
candidatePath: string,
expectedAccountId?: string
Expand Down Expand Up @@ -106,6 +109,11 @@ export class CodexConfigMirror {
expectedAccountId?: string
): void {
if (canonicalConfig === null) {
// Why: with no ~/.codex/config.toml there is nothing to mirror, but Codex still cannot start in a long home without the daemon guard.
// WSL homes are skipped: their ownership check is a blocking wsl.exe call (startup, account switch), and WSL launch prep guards the home it launches.
if (!parseWslUncPath(managedHomePath)) {
ensureCodexDaemonSocketGuard(this.assertManagedHomePath(managedHomePath, expectedAccountId))
}
return
}
const trustedManagedHomePath = this.assertManagedHomePath(managedHomePath, expectedAccountId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const generationRace = vi.hoisted(() => ({
beforeGuardedReplace: null as (() => void) | null
}))

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('../codex/codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

vi.mock('./fs-utils', async (importOriginal) => {
const actual = await importOriginal<typeof FsUtils>()
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import {
testState
} from './runtime-home-service-test-harness'

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('../codex/codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

vi.mock('electron', () => ({
app: {
getPath: () => testState.userDataDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ function expectBaselineKeptWithLaunchDatePending(markerPath: string): void {
).toBe(true)
}

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('../codex/codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

vi.mock('electron', () => ({
app: {
getPath: () => testState.userDataDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import {
testState
} from './runtime-home-service-test-harness'

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('../codex/codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

vi.mock('electron', () => ({
app: {
getPath: () => testState.userDataDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import {
testState
} from './runtime-home-service-test-harness'

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('../codex/codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

vi.mock('electron', () => ({
app: {
getPath: () => testState.userDataDir
Expand Down
6 changes: 6 additions & 0 deletions src/main/codex-accounts/service-account-add-login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import {
} from './service-test-harness'
import { createCanonicalHookTrustFixture } from './service-hook-trust-test-fixtures'

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('../codex/codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

vi.mock('electron', () => ({
app: {
getPath: () => testState.userDataDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ describe('Codex reset-credit managed-home ownership', () => {
fixture.store.getCodexResetCreditAttemptLedger.mockClear()
fixture.store.replaceCodexResetCreditAttemptLedgerAndFlush.mockClear()
fixture.store.updateSettings.mockClear()
const restarted = fixture.createService()
// Why: construction mirrors config into every managed home; only the retry itself is under test.
fsFaults.resetMkdirCalls()

const restarted = fixture.createService()
await expect(
restarted.consumeRateLimitResetCredit(fixture.idempotencyKey, fixture.expectedScope)
).rejects.toThrow(expectedError)
Expand All @@ -186,13 +187,13 @@ describe('Codex reset-credit managed-home ownership', () => {
fixture.consume.mockClear()
fixture.store.replaceCodexResetCreditAttemptLedgerAndFlush.mockClear()
fixture.store.updateSettings.mockClear()
// Why: construction mirrors config into every managed home; only the replay itself is under test.
const restarted = fixture.createService()
fsFaults.hold(join(realpathSync(fixture.managedHomePath), '.orca-managed-home'))
fsFaults.resetMkdirCalls()

await expect(
fixture
.createService()
.consumeRateLimitResetCredit(fixture.idempotencyKey, fixture.expectedScope)
restarted.consumeRateLimitResetCredit(fixture.idempotencyKey, fixture.expectedScope)
).resolves.toMatchObject({ outcome: 'reset', scope: fixture.expectedScope })

expect(fsFaults.heldReads()).toBe(0)
Expand Down
12 changes: 12 additions & 0 deletions src/main/codex-accounts/service-wsl-accounts.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it, vi } from 'vitest'
import type * as NodeChildProcess from 'node:child_process'
import { EventEmitter } from 'node:events'
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
Expand All @@ -15,6 +16,12 @@ import {
testState
} from './service-test-harness'

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('../codex/codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

vi.mock('electron', () => ({
app: {
getPath: () => testState.userDataDir
Expand Down Expand Up @@ -78,6 +85,11 @@ describe('CodexAccountService config sync', () => {
'utf-8'
)

// On Windows, the ownership check resolves the managed home inside the distro.
vi.doMock('node:child_process', async (importOriginal) => ({
...(await importOriginal<typeof NodeChildProcess>()),
execFileSync: vi.fn(() => `${wslLinuxHomePath}\n`)
}))
vi.doMock('../../shared/wsl-paths', () => ({
parseWslUncPath: (path: string) => {
if (path === wslManagedHomePath) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/codex-accounts/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import {
} from './service-test-harness'
import { createCanonicalHookTrustFixture } from './service-hook-trust-test-fixtures'

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('../codex/codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

vi.mock('electron', () => ({
app: {
getPath: () => testState.userDataDir
Expand Down
6 changes: 6 additions & 0 deletions src/main/codex/codex-config-mirror.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { tmpdir } from 'node:os'
import type * as NodeOs from 'node:os'
import { join } from 'node:path'

// Why: temp homes exceed sun_path on macOS but not on Linux; keep asserted config bytes host-independent.
vi.mock('./codex-daemon-socket-path-guard', async (importOriginal) => ({
...(await importOriginal<object>()),
applyCodexDaemonSocketGuard: (config: string) => config
}))

const { getPathMock, homedirMock } = vi.hoisted(() => ({
getPathMock: vi.fn<(name: string) => string>(),
homedirMock: vi.fn<() => string>()
Expand Down
Loading
Loading