free-coding-models 0.5.35 → 0.5.37
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/README.md +2 -0
- package/changelog/v0.5.36.md +13 -0
- package/changelog/v0.5.37.md +14 -0
- package/package.json +1 -1
- package/src/core/config.js +13 -2
- package/src/core/provider-key-tester.js +369 -0
- package/src/core/router-daemon.js +67 -21
- package/src/tui/key-handler.js +30 -301
- package/web/dist/assets/{index-B5tTa7_O.js → index-DcYKZCte.js} +2 -2
- package/web/dist/index.html +1 -1
- package/web/server.js +14 -9
package/web/dist/index.html
CHANGED
|
@@ -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-
|
|
51
|
+
<script type="module" crossorigin src="/assets/index-DcYKZCte.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
|
|
661
|
-
// 📖
|
|
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
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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
|
}
|