(cwd: string, provider: string, modelId: string)
| 160 | } |
| 161 | |
| 162 | async function setDraftComposerModel(cwd: string, provider: string, modelId: string) { |
| 163 | const { AuthStorage, ModelRegistry, SettingsManager, getAgentDir } = await getPiModule() |
| 164 | const agentDir = getAgentDir() |
| 165 | const authStorage = AuthStorage.create() |
| 166 | const modelRegistry = normalizeModelRegistryContextWindows( |
| 167 | ModelRegistry.create(authStorage, `${agentDir}/models.json`), |
| 168 | ) |
| 169 | const model = modelRegistry.find(provider, modelId) |
| 170 | |
| 171 | if (!model) { |
| 172 | throw new Error(`Unknown Pi model: ${provider}/${modelId}`) |
| 173 | } |
| 174 | |
| 175 | const currentComposer = await buildComposerStateSnapshot({ projectId: cwd, sessionPath: null }) |
| 176 | const nextThinkingLevel = clampThinkingLevel( |
| 177 | currentComposer.currentThinkingLevel, |
| 178 | getAvailableThinkingLevelsForModel(model), |
| 179 | ) |
| 180 | const settingsManager = SettingsManager.create(cwd, agentDir) |
| 181 | |
| 182 | settingsManager.setDefaultModelAndProvider(provider, modelId) |
| 183 | settingsManager.setDefaultThinkingLevel(nextThinkingLevel) |
| 184 | } |
| 185 | |
| 186 | async function setDraftComposerThinkingLevel(cwd: string, level: ComposerThinkingLevel) { |
| 187 | const { SettingsManager, getAgentDir } = await getPiModule() |
no test coverage detected