free-coding-models 0.5.34 → 0.5.36

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
  <link rel="preconnect" href="https://fonts.googleapis.com">
49
49
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
50
50
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
51
- <script type="module" crossorigin src="/assets/index-zzUvtumw.js"></script>
51
+ <script type="module" crossorigin src="/assets/index-DH3ml-b4.js"></script>
52
52
  <link rel="stylesheet" crossorigin href="/assets/index-r8niexgJ.css">
53
53
  </head>
54
54
  <body>
package/web/server.js CHANGED
@@ -38,6 +38,7 @@ import { loadConfig, getApiKey, saveConfig, isProviderEnabled } from '../src/cor
38
38
  import { getProviderBillingNote, getProviderLabelWithBilling, PROVIDER_METADATA } from '../src/core/provider-metadata.js'
39
39
  import { ensureFavoritesConfig } from '../src/core/favorites.js'
40
40
  import { ping } from '../src/core/ping.js'
41
+ import { runProviderKeyTest } from '../src/core/provider-key-tester.js'
41
42
  import { loadChangelog } from '../src/core/changelog-loader.js'
42
43
  import { checkForUpdateDetailed, checkForUpdate, runUpdate, fetchLastReleaseDate } from '../src/core/updater.js'
43
44
  import { syncShellEnv, ensureShellRcSource, removeShellEnv } from '../src/core/shell-env.js'
@@ -657,22 +658,26 @@ async function handleRequest(req, res) {
657
658
 
658
659
  // 📖 M2: /api/key/:provider/test — matched here (above the switch) so the
659
660
  // 📖 M2 path doesn't conflict with the single-segment key reveal below.
660
- // 📖 Mirrors the TUI Settings `T` key behavior: parallel auth probe + chat
661
- // 📖 ping through the existing ping() helper.
661
+ // 📖 Mirrors the TUI Settings `T` key behavior via the shared runProviderKeyTest()
662
+ // 📖 pipeline in src/core/provider-key-tester.js: fast parallel auth probe to
663
+ // 📖 /v1/account or /v1/models, then ping-based verification against real model
664
+ // 📖 IDs (discovered from the provider's /models endpoint + repo catalog) so we
665
+ // 📖 never send an empty model ID (which the provider rejects with HTTP 400).
662
666
  const keyTestMatch = url.pathname.match(/^\/api\/key\/([^/]+)\/test$/)
663
667
  if (keyTestMatch) {
664
668
  if (req.method !== 'POST') { res.writeHead(405); res.end('Method Not Allowed'); return }
665
669
  const providerKey = decodeURIComponent(keyTestMatch[1])
666
670
  if (!sources[providerKey]) { sendJson(res, 404, { error: 'Unknown provider' }); return }
667
671
  const apiKey = getApiKey(config, providerKey)
668
- if (!apiKey) { sendJson(res, 200, { outcome: 'missing_key', detail: `${providerKey} has no saved API key.` }); return }
672
+ if (!apiKey) { sendJson(res, 200, { outcome: 'missing_key', detail: `${sources[providerKey].name || providerKey} has no saved API key.` }); return }
669
673
  try {
670
- const result = await ping(apiKey, '', providerKey, sources[providerKey].url, { silent: true })
671
- if (result?.code === 200 || result?.code === '200') { sendJson(res, 200, { outcome: 'ok', code: 200 }); return }
672
- if (result?.code === 401 || result?.code === '401' || result?.code === 403 || result?.code === '403') {
673
- sendJson(res, 200, { outcome: 'auth_error', code: result.code }); return
674
- }
675
- sendJson(res, 200, { outcome: 'fail', code: result?.code ?? 'ERR', detail: 'Probe did not return a 2xx' })
674
+ const result = await runProviderKeyTest(apiKey, providerKey, sources[providerKey])
675
+ sendJson(res, 200, {
676
+ outcome: result.outcome,
677
+ detail: result.detail,
678
+ attempts: result.attempts,
679
+ discoveryNote: result.discoveryNote,
680
+ })
676
681
  } catch (err) {
677
682
  sendJson(res, 200, { outcome: 'fail', detail: err.message || 'Probe failed' })
678
683
  }