factory 0.1.3: a refusal says what to do after an em dash ("<Factory's message> — Factory refused this account…"), as the built-in's Provider.Explain joins them, where it used ": "; an empty 403 reads "403 Forbidden", the status Go falls back to
This commit is contained in:
@@ -681,7 +681,8 @@ export const FactoryAuthPlugin = async ({ client }) => {
|
||||
text = await res.text()
|
||||
}
|
||||
const why = explain(res.status, text)
|
||||
const msg = `${apiError(text, "Forbidden")}: ${why}`
|
||||
// the refusal, then what to do about it, as provider.Explain joins them
|
||||
const msg = `${apiError(text, "403 Forbidden")} — ${why}`
|
||||
return errorReply(url, res.status, "permission_error", msg, new Headers(res.headers))
|
||||
},
|
||||
}
|
||||
|
||||
@@ -52,3 +52,16 @@ test("and OpenAI's on /llm/o/", async () => {
|
||||
expect(b.error.code).toBe(null)
|
||||
expect(b.type).toBeUndefined()
|
||||
})
|
||||
|
||||
test("a refusal says what to do after an em dash, as the built-in's Explain joins it", async () => {
|
||||
globalThis.fetch = async () => new Response(JSON.stringify({ error: { message: "model not allowed" } }), { status: 403 })
|
||||
const auth = { ...expired, access: "tok", expires: Date.now() + 3_600_000 }
|
||||
const hooks = await FactoryAuthPlugin({ client: { auth: { set: async () => {} } } })
|
||||
const l = await hooks.auth.loader(async () => auth)
|
||||
let res = await l.fetch("https://api.factory.ai/api/llm/o/v1/responses", { method: "POST", body: JSON.stringify({ model: "gpt-x" }) })
|
||||
expect(res.status).toBe(403)
|
||||
expect((await res.json()).error.message).toMatch(/^model not allowed — Factory refused this account the request; check that `droid`/)
|
||||
globalThis.fetch = async () => new Response("", { status: 403 })
|
||||
res = await l.fetch("https://api.factory.ai/api/llm/o/v1/responses", { method: "POST", body: JSON.stringify({ model: "gpt-x" }) })
|
||||
expect((await res.json()).error.message).toMatch(/^403 Forbidden — Factory refused/)
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-factory-auth",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "Sign in to a Factory (Droid) subscription from OpenCode or magpie",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
Reference in New Issue
Block a user