@magpie-community/opencode-grok-auth 0.1.4 → 0.1.5
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/index.mjs +4 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -249,6 +249,10 @@ async function listModels(key) {
|
|
|
249
249
|
await sign(headers, key)
|
|
250
250
|
const res = await fetch(`${BASE}/models`, { headers })
|
|
251
251
|
const text = await res.text()
|
|
252
|
+
// a token Grok turned away before its time (signed out elsewhere) is a
|
|
253
|
+
// sign-in gone, said as one past its time is: a move takes it along
|
|
254
|
+
// untried rather than stopping on it
|
|
255
|
+
if (res.status === 401) throw new Error("Grok's sign-in has expired; run `grok login`")
|
|
252
256
|
if (!res.ok) throw new Error(`Grok models: ${res.status} ${text.slice(0, 200)}`)
|
|
253
257
|
const out = []
|
|
254
258
|
for (const d of JSON.parse(text)?.data ?? []) {
|
package/package.json
CHANGED