Files
orca/src/main/pi/omp-model-command-source.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

26 lines
1.1 KiB
TypeScript

export function getOmpModelCommandSourceLines(): string[] {
return [
" if (isOmpRuntime() && typeof pi.registerCommand === 'function' && typeof pi.setModel === 'function') {",
" pi.registerCommand('orca-model', {",
" description: 'Switch the model selected in Orca',",
' handler: async (selector, ctx) => {',
' const models = ctx.modelRegistry.getAvailable()',
" const model = models.find((candidate) => candidate.provider + '/' + candidate.id === selector.trim())",
' if (!model) {',
" ctx.ui.notify('Model is no longer available. Refresh the Orca model picker.', 'error')",
' return',
' }',
' if (!await pi.setModel(model)) {',
" ctx.ui.notify('Could not switch model: no API key is available.', 'error')",
' return',
' }',
' updateRuntimeOmpSessionMetadata(ctx)',
' updateModelMetadata({ model })',
" post('model_select')",
' }',
' })',
' ompModelSwitchSupported = true',
' }'
]
}