free-coding-models 0.5.89 → 0.5.90

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.
@@ -48,7 +48,7 @@
48
48
  <!-- 📖 No webfont links: the dashboard must work fully offline / air-gapped.
49
49
  📖 Font stacks live in web/src/global.css and fall back to system fonts
50
50
  📖 (locally installed Inter / JetBrains Mono are still picked up if present). -->
51
- <script type="module" crossorigin src="/assets/index-C5hgQLYN.js"></script>
51
+ <script type="module" crossorigin src="/assets/index-CCkuXrqE.js"></script>
52
52
  <link rel="stylesheet" crossorigin href="/assets/index-CCaxIOti.css">
53
53
  </head>
54
54
  <body>
package/web/server.js CHANGED
@@ -37,7 +37,8 @@ import { sources, MODELS } from '../sources.js'
37
37
  import { loadConfig, getApiKey, saveConfig, isProviderEnabled } from '../src/core/config.js'
38
38
  import { getProviderBillingNote, getProviderLabelWithBilling, PROVIDER_METADATA } from '../src/core/provider-metadata.js'
39
39
  import { ensureFavoritesConfig } from '../src/core/favorites.js'
40
- import { ping, getProviderQuotaPercentCached } from '../src/core/ping.js'
40
+ import { ping, getProviderQuotaPercentCached, getProviderSessionHeaders } from '../src/core/ping.js'
41
+ import { resolveCloudflareUrlAsync } from '../src/core/cloudflare-account.js'
41
42
  import { runProviderKeyTest } from '../src/core/provider-key-tester.js'
42
43
  import { loadChangelog } from '../src/core/changelog-loader.js'
43
44
  import { checkForUpdateDetailed, checkForUpdate, runUpdate, fetchLastReleaseDate } from '../src/core/updater.js'
@@ -1328,6 +1329,14 @@ async function handleRequest(req, res) {
1328
1329
  upstreamUrl = upstreamUrl.replace(/\/+$/, '') + '/v1/chat/completions'
1329
1330
  }
1330
1331
 
1332
+ // 📖 Cloudflare's endpoint is account-scoped (issue #181): the catalog
1333
+ // 📖 URL carries an {$CLOUDFLARE_ACCOUNT_ID} placeholder, so it must be
1334
+ // 📖 resolved (env > stored config > auto-discovery) before this fetch,
1335
+ // 📖 otherwise Cloudflare answers 404 for every model.
1336
+ if (result.providerKey === 'cloudflare') {
1337
+ upstreamUrl = await resolveCloudflareUrlAsync(upstreamUrl)
1338
+ }
1339
+
1331
1340
  // 📖 ZAI provider: strip the "zai/" prefix from modelId for the API
1332
1341
  let apiModelId = result.modelId
1333
1342
  if (result.providerKey === 'zai' && apiModelId.startsWith('zai/')) {
@@ -1345,6 +1354,10 @@ async function handleRequest(req, res) {
1345
1354
  upstreamHeaders['X-Title'] = 'free-coding-models'
1346
1355
  }
1347
1356
 
1357
+ // 📖 Mandatory per-provider headers (issue #181): OpenCode Zen rejects
1358
+ // 📖 every request without `x-opencode-session` (HTTP 400 MissingSessionID).
1359
+ Object.assign(upstreamHeaders, getProviderSessionHeaders(result.providerKey))
1360
+
1348
1361
  const reqBody = {
1349
1362
  model: apiModelId,
1350
1363
  messages: [{ role: 'user', content: BENCHMARK_PROMPT }],
@@ -1824,6 +1837,12 @@ async function handleRequest(req, res) {
1824
1837
  if (!baseUrl.includes('/chat/completions')) {
1825
1838
  baseUrl = baseUrl.replace(/\/+$/, '') + '/v1/chat/completions'
1826
1839
  }
1840
+ // 📖 Cloudflare's endpoint is account-scoped (issue #181): resolve
1841
+ // 📖 the {$CLOUDFLARE_ACCOUNT_ID} placeholder (env > stored config >
1842
+ // 📖 auto-discovery) or the API would 404 every direct chat.
1843
+ if (providerKey === 'cloudflare') {
1844
+ baseUrl = await resolveCloudflareUrlAsync(baseUrl)
1845
+ }
1827
1846
  directUrl = baseUrl
1828
1847
  directModelId = modelId
1829
1848
  }
@@ -1876,6 +1895,9 @@ async function handleRequest(req, res) {
1876
1895
  upstreamHeaders['HTTP-Referer'] = 'https://github.com/vava-nessa/free-coding-models'
1877
1896
  upstreamHeaders['X-Title'] = 'free-coding-models'
1878
1897
  }
1898
+ // 📖 Mandatory per-provider headers (issue #181): OpenCode Zen rejects
1899
+ // 📖 every request without `x-opencode-session` (HTTP 400 MissingSessionID).
1900
+ Object.assign(upstreamHeaders, getProviderSessionHeaders(providerKey))
1879
1901
  }
1880
1902
 
1881
1903
  const controller = new AbortController()