* Builds a model definition for a provider Pi supports but whose bundled catalog * doesn't list this exact id (e.g. a newer model Pi wires to a different * provider). Mirrors the cloud CLI's passthrough: clone one of the provider's * models as a template, swap in the requested id, and force reaso
( modelRegistry: ModelRegistry, provider: string, modelId: string, thinkingLevel: ReturnType<typeof mapThinkingLevel> )
| 80 | * models at all, so even passthrough can't route it. |
| 81 | */ |
| 82 | function buildPiFallbackModel( |
| 83 | modelRegistry: ModelRegistry, |
| 84 | provider: string, |
| 85 | modelId: string, |
| 86 | thinkingLevel: ReturnType<typeof mapThinkingLevel> |
| 87 | ) { |
| 88 | const providerModels = modelRegistry.getAll().filter((m) => m.provider === provider) |
| 89 | if (providerModels.length === 0) return undefined |
| 90 | const fallback = { ...providerModels[0], id: modelId, name: modelId } |
| 91 | return thinkingLevel && thinkingLevel !== 'off' ? { ...fallback, reasoning: true } : fallback |
| 92 | } |
| 93 | |
| 94 | export const runLocalPi: PiBackendRun<PiLocalRunParams> = async (params, context) => { |
| 95 | // Isolate Pi resource discovery: an empty cwd/agentDir keeps DefaultResourceLoader |