Files
orca/src/shared/agent-model-probe-spec.ts
T
NeilandSudoAI-DEV ae9c06c941 feat(omp): discover and switch native-chat models on desktop and mobile (#20612)
* fix(omp): discover and switch native-chat models

Report the running OMP provider/model and discover available choices on
the execution host for desktop and mobile. Register an extension command
to switch through the OMP API because its TUI does not accept /model args.
Advertise that command in status so older hosts remain read-only.

Addresses the OMP portion of #17603; Pi chat enablement remains separate.
Model reporting begins on lifecycle activity; no startup status is invented.

Co-authored-by: SudoAI-DEV <220139811+SudoAI-DEV@users.noreply.github.com>

* refactor(omp): check generated model metadata types

* test(omp): verify model picker command and reported selection

* test(omp): add repeatable real model-switch runtime proof

* test(omp): require model capability delivery in runtime smoke

* fix(mobile): decode OMP model discovery through RPC operations

* fix(omp): preserve exact reported model selectors

* fix(omp): preserve generated extension syntax after rebase

* fix(omp): merge generated harness UI context types

* test(omp): model switching keeps one session manager

* test(omp): include transcript path in model status proof

* test(omp): avoid renderer error-type union

* test(omp): keep renderer test type explicit

---------

Co-authored-by: SudoAI-DEV <220139811+SudoAI-DEV@users.noreply.github.com>
2026-09-19 05:11:48 -07:00

59 lines
2.0 KiB
TypeScript

import { getCommitMessageAgentSpec, type CommitMessageAgentSpec } from './commit-message-agent-spec'
import { GROK_MODEL_LIST_ARGS, parseGrokModelList } from './grok-model-list-probe'
import { OMP_MODEL_LIST_ARGS, parseOmpModelList } from './omp-model-list-probe'
import type { TuiAgent } from './tui-agent'
/** Why: model discovery reads only these fields; excluding the prompt-delivery
* half is what keeps a probe-only agent out of the commit-message registry. */
export type AgentModelProbeSpec = Omit<CommitMessageAgentSpec, 'promptDelivery' | 'buildArgs'>
/** Agents that support model discovery but are not commit-message agents. */
const MODEL_DISCOVERY_ONLY_SPECS: Partial<Record<TuiAgent, AgentModelProbeSpec>> = {
grok: {
id: 'grok',
label: 'Grok',
binary: 'grok',
modelSource: 'dynamic',
modelDiscovery: {
binary: 'grok',
args: GROK_MODEL_LIST_ARGS,
parse: parseGrokModelList
},
// Why: empty so a failed probe degrades to the catalog seed instead of a
// second model list here that can drift from it.
models: [],
defaultModelId: 'grok-4.6'
},
omp: {
id: 'omp',
label: 'OMP',
binary: 'omp',
modelSource: 'dynamic',
modelDiscovery: {
binary: 'omp',
args: OMP_MODEL_LIST_ARGS,
parse: parseOmpModelList
},
// Why: nothing is available on every OMP install, so there is no seed and no
// default to name; discovery's first row stands in when a default is required.
models: [],
defaultModelId: ''
}
}
export function getAgentModelProbeSpec(agentId: TuiAgent): AgentModelProbeSpec | undefined {
const spec = getCommitMessageAgentSpec(agentId) ?? MODEL_DISCOVERY_ONLY_SPECS[agentId]
if (!spec) {
return undefined
}
// OMP's `default` means the provider configured in its own settings, not a selectable model.
if (agentId !== 'omp') {
return spec
}
return {
...spec,
models: spec.models.filter((model) => model.id !== 'default'),
defaultModelId: spec.defaultModelId === 'default' ? '' : spec.defaultModelId
}
}