pi-openmodel-provider 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.10] - 2026-06-20
9
+
10
+ ### Fixed
11
+ - Legacy `/v1/models` endpoint failing without API key (models now load without auth)
12
+ - `require("node:os")` bug in `/openmodel` command (ESM compatibility)
13
+ - Added fallback protocol inference when legacy endpoint unavailable
14
+
15
+ ### Added
16
+ - Test: recovers when legacy endpoint fails with 401
17
+
8
18
  ## [0.2.9] - 2026-06-20
9
19
 
10
20
  ### Added
@@ -109,6 +119,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
109
119
  - Import path extensions (.ts → .js)
110
120
  - Process import in models.ts
111
121
 
122
+ [0.2.10]: https://github.com/IvanGabrielYarupaitanRivera/pi-openmodel-provider/releases/tag/v0.2.10
112
123
  [0.2.9]: https://github.com/IvanGabrielYarupaitanRivera/pi-openmodel-provider/releases/tag/v0.2.9
113
124
  [0.2.6]: https://github.com/IvanGabrielYarupaitanRivera/pi-openmodel-provider/releases/tag/v0.2.6
114
125
  [0.2.5]: https://github.com/IvanGabrielYarupaitanRivera/pi-openmodel-provider/releases/tag/v0.2.5
package/index.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  formatHealthStatus,
14
14
  } from "./src/stability.ts"
15
15
  import { friendlyMessage } from "./src/errors.ts"
16
+ import { homedir } from "node:os"
16
17
 
17
18
  export default async function (pi: ExtensionAPI) {
18
19
  let models: Awaited<ReturnType<typeof fetchOpenModelModels>> = []
@@ -70,7 +71,7 @@ export default async function (pi: ExtensionAPI) {
70
71
  let hasApiKey = false
71
72
  try {
72
73
  const { readFileSync } = await import("node:fs")
73
- const authPath = `${require("node:os").homedir()}/.pi/agent/auth.json`
74
+ const authPath = `${homedir()}/.pi/agent/auth.json`
74
75
  const content = readFileSync(authPath, "utf-8")
75
76
  const data = JSON.parse(content)
76
77
  hasApiKey = !!(data.openmodel?.access || data.openmodel?.refresh)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-openmodel-provider",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "pi custom provider for OpenModel.ai - Multi-model AI gateway",
5
5
  "type": "module",
6
6
  "keywords": [
package/src/models.ts CHANGED
@@ -172,7 +172,7 @@ export async function fetchOpenModelModels(options?: {
172
172
 
173
173
  const [webModels, legacyModels] = await Promise.all([
174
174
  fetchWebModels({ fetchImpl }),
175
- fetchLegacyModels({ fetchImpl }),
175
+ fetchLegacyModels({ fetchImpl }).catch(() => new Map()),
176
176
  ])
177
177
 
178
178
  const models: OpenModelProviderModel[] = []
@@ -185,8 +185,13 @@ export async function fetchOpenModelModels(options?: {
185
185
 
186
186
  const legacy = legacyModels.get(id)
187
187
  const protocols = legacy?.supported_protocols ?? []
188
- const api = determineApi(protocols, web.provider_key)
189
- if (!api) continue
188
+ let api = determineApi(protocols, web.provider_key)
189
+ if (!api) {
190
+ // Fallback: infer protocol from provider
191
+ if (["openai"].includes(web.provider_key)) api = "openai-responses"
192
+ else if (["gemini"].includes(web.provider_key)) api = "google-generative-ai"
193
+ else api = "anthropic-messages"
194
+ }
190
195
 
191
196
  const inputPrice = pricePerMillion(web.prices.input_cost_per_token as number)
192
197
  const outputPrice = pricePerMillion(web.prices.output_cost_per_token as number)