mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
OpenCode 2.0.13-2.0.18 submit a bare --prompt before the agent/model catalog loads and drop it (fixed upstream in 2.0.19). Orca only routed 2.0.12 and 2.0.16 through its startup-prompt plugin, so the other releases kept the prompt in the composer while the tab showed Done. Route the whole broken run through the plugin. This also lets model picks on 2.0.14/15/17/18 deliver their prompt again.
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { compareAppVersions, isValidAppVersion } from './app-version'
|
|
|
|
// These releases drop a bare --prompt (submitted before agent/model load); 2.0.19 fixed it upstream.
|
|
export const OPENCODE_NATIVE_PROMPT_VERSIONS = [
|
|
'2.0.12',
|
|
'2.0.13',
|
|
'2.0.14',
|
|
'2.0.15',
|
|
'2.0.16',
|
|
'2.0.17',
|
|
'2.0.18'
|
|
] as const
|
|
|
|
export type OpenCodeCliCapabilities = {
|
|
version: string | null
|
|
pluginApi: 'v1' | 'v2' | 'unknown'
|
|
promptMode: 'submit' | 'prefill' | 'unknown'
|
|
v1SessionPolicyFiltersTools: boolean
|
|
}
|
|
|
|
export function parseOpenCodeCliVersion(output: string | null | undefined): string | null {
|
|
const version = output
|
|
?.trim()
|
|
.match(/^(?:opencode\s+)?v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/i)?.[1]
|
|
return version && isValidAppVersion(version) ? version : null
|
|
}
|
|
|
|
export function getOpenCodeCliCapabilities(
|
|
output: string | null | undefined
|
|
): OpenCodeCliCapabilities {
|
|
const version = parseOpenCodeCliVersion(output)
|
|
const major = version?.split('.')[0]
|
|
return {
|
|
version,
|
|
pluginApi: major === '1' ? 'v1' : major === '2' ? 'v2' : 'unknown',
|
|
v1SessionPolicyFiltersTools:
|
|
major === '1' && version !== null && compareAppVersions(version, '1.3.0') >= 0,
|
|
promptMode:
|
|
major === '1'
|
|
? 'submit'
|
|
: OPENCODE_NATIVE_PROMPT_VERSIONS.some((supported) => supported === version)
|
|
? 'prefill'
|
|
: 'unknown'
|
|
}
|
|
}
|