Select OpenCode plugin exports from the execution host version (#24662)

* fix: wait for OpenCode worker composer before first dispatch

Reuse captured composer readiness on local and paired execution hosts and revoke launching-shell paste anchors.

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>

* feat(opencode): probe execution-host CLI capabilities

* fix(opencode): select plugin default for execution host loader

* fix(opencode): limit prompt prefill capability to verified release

* feat(opencode): probe launch capabilities on the execution host

* fix(opencode): select plugin loader for the launched host binary

* fix(opencode): match WSL probe cwd and declared guest environment

* fix(opencode): preserve launch environment deletion boundaries

* STRICT launch CI contract correction

* CAPS launch CI contract correction

* test: initialize Claude prompt state in output retention fixture

---------

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
This commit is contained in:
Neil
2026-10-03 23:13:06 -07:00
committed by GitHub
co-authored by Brennan Benson
parent 3cc5e1dac6
commit 5a2aa87f1c
23 changed files with 1173 additions and 20 deletions
+87
View File
@@ -0,0 +1,87 @@
import { createHash } from 'node:crypto'
import path from 'node:path'
import {
ORCA_SCRUB_SAFE_LAUNCH_ENV,
ORCA_SCRUB_SAFE_PANE_ENV
} from '../../shared/agent-hook-scrub-safe-env'
import { runProcess } from '../../shared/child-process/run-process'
import {
getOpenCodeCliCapabilities,
type OpenCodeCliCapabilities
} from '../../shared/opencode-cli-version'
export type OpenCodeCliVersionProbe = {
executablePath: string
env: NodeJS.ProcessEnv
cwd?: string
hostIdentity?: string
execute?: () => Promise<{ code: number | null; timedOut: boolean; stdout: string }>
}
const probes = new Map<string, { expiresAt: number; result: Promise<OpenCodeCliCapabilities> }>()
const CACHE_TTL_MS = 60_000
const MAX_CACHED_PROBES = 128
const PANE_IDENTITY_ENV_KEYS = new Set([
'ORCA_PANE_KEY',
'ORCA_TAB_ID',
'ORCA_WORKTREE_ID',
'ORCA_TERMINAL_HANDLE',
'ORCA_AGENT_LAUNCH_TOKEN',
ORCA_SCRUB_SAFE_PANE_ENV,
ORCA_SCRUB_SAFE_LAUNCH_ENV
])
export function probeOpenCodeCliVersion(
options: OpenCodeCliVersionProbe
): Promise<OpenCodeCliCapabilities> {
const identity = JSON.stringify([
options.execute ? 'host-callback' : 'native-process',
options.hostIdentity ?? process.platform,
options.executablePath,
options.cwd,
Object.entries(options.env)
.filter(([key]) => !PANE_IDENTITY_ENV_KEYS.has(key))
.sort(([left], [right]) => left.localeCompare(right))
])
const key = createHash('sha256').update(identity).digest('hex')
const cached = probes.get(key)
if (cached && cached.expiresAt > Date.now()) {
return cached.result
}
const result = runVersionProbe(options)
probes.delete(key)
probes.set(key, { expiresAt: Date.now() + CACHE_TTL_MS, result })
if (probes.size > MAX_CACHED_PROBES) {
const oldest = probes.keys().next().value
if (oldest !== undefined) {
probes.delete(oldest)
}
}
return result
}
async function runVersionProbe(options: OpenCodeCliVersionProbe): Promise<OpenCodeCliCapabilities> {
try {
const pathKey = process.platform === 'win32' && options.env.Path !== undefined ? 'Path' : 'PATH'
const executableDir = path.dirname(options.executablePath)
const inheritedPath = options.env[pathKey]
const result = options.execute
? await options.execute()
: await runProcess({
program: options.executablePath,
args: ['--version'],
cwd: options.cwd,
env: {
...options.env,
[pathKey]: inheritedPath
? `${executableDir}${path.delimiter}${inheritedPath}`
: executableDir
},
timeoutMs: 5_000,
maxOutputBytes: 4_096
})
return getOpenCodeCliCapabilities(result.code === 0 && !result.timedOut ? result.stdout : null)
} catch {
return getOpenCodeCliCapabilities(null)
}
}