(runtime: PiRuntime, request: ComposerStateRequest)
| 74 | } |
| 75 | |
| 76 | async function selectRequestedComposerModel(runtime: PiRuntime, request: ComposerStateRequest) { |
| 77 | const selection = request.composerModelSelection ?? null |
| 78 | if (selection?.provider) { |
| 79 | const model = runtime.session.modelRegistry.find(selection.provider, selection.id) |
| 80 | if (model) return model |
| 81 | const [fallbackModel] = await runtime.session.modelRegistry.getAvailable() |
| 82 | return fallbackModel ?? runtime.session.model |
| 83 | } |
| 84 | if (!request.composerUseDefaultModel) return runtime.session.model |
| 85 | const defaultComposer = await buildComposerStateSnapshot({ |
| 86 | projectId: runtime.cwd, |
| 87 | composerSessionDir: request.composerSessionDir, |
| 88 | }) |
| 89 | if (!defaultComposer.currentModel) return runtime.session.model |
| 90 | return ( |
| 91 | runtime.session.modelRegistry.find( |
| 92 | defaultComposer.currentModel.provider, |
| 93 | defaultComposer.currentModel.id, |
| 94 | ) ?? runtime.session.model |
| 95 | ) |
| 96 | } |
| 97 | |
| 98 | async function getRequestedComposerThinkingLevel( |
| 99 | runtime: PiRuntime, |
no test coverage detected