factory 0.1.5: another agent's request to /api/llm/o opens as Droid's does, and a Factory API key can be added (yetone/magpie#506: factory-plugin/glm-5.3-flash answered 403 "Factory refused this account the request; check that droid…" on magpie v0.1.641) — the plugin had none of the built-in's fixes after 30 Sep. As the built-in's factoryDroidBody (e413dd84, magpie v0.1.630) has it, Responses' instructions, or chat completions' first system message (text parts joined with "\n"), open with droid 0.231.0's "You are Droid, an AI software engineering agent built by Factory." and "\n" before the agent's own; with none, the line alone goes first; droid's own requests and everything on /api/llm/a go on byte for byte, and a rewritten body drops the old Content-Length. The requests say droid 0.231.0, GLM-5.3-Flash takes images, and a 403 says what the built-in's factoryExplain says (5523eb17). A Factory API key (fk-…), droid's FACTORY_API_KEY, is an "api" sign-in method as factory_key.go (bb5e8a2b) keeps one: the bearer with droid's headers, never renewed, no X-Factory-Org-Id, not mended on a 403; whoami asked once with the key gives its region/host and whose it is, kept in the key's metadata. No request was made to Factory. droid.test.mjs (the built-in's TestFactoryOpensAsDroid cases, images, key requests and usage) fails against 0.1.4; bun test and scripts/check.mjs factory pass.

This commit is contained in:
yetone
2026-10-02 16:33:14 +08:00
parent bd5e91ee00
commit 427947eadc
5 changed files with 345 additions and 11 deletions
+15
View File
@@ -9,6 +9,10 @@ model requests to Factory's API the way `droid` sends them. Provider id:
- **Sign in with Factory (device code).** This is WorkOS's device flow
under droid's own client. The browser opens Factory's page with the code
filled in. Confirm it there, and the plugin picks up the tokens.
- **Factory API key.** A key (`fk-…`), as droid takes one from
`FACTORY_API_KEY`. It is sent as the bearer token with droid's headers
and never renewed. A key carries no organization header; `whoami`, asked
once with the key, says whose it is and where its organization is served.
- **Organization.** A token that isn't in an organization yet is put in
the first one your account belongs to.
- **Whoami.** The plugin asks `whoami` for your active organization, its
@@ -33,6 +37,17 @@ at once.
plugin asks `whoami` again and resends the request once. If the refusal
stands, the error says what to check.
## Requests from other agents
Factory serves a subscription's model requests to Droid. Every request
droid sends opens its system prompt with "You are Droid, an AI software
engineering agent built by Factory.", so another agent's request to
Factory's OpenAI-shaped API (`/api/llm/o`: GPT and Grok on Responses, the
open models on chat completions) opens with that line too, the agent's own
prompt after it. Claude models (and MiniMax M2.7) on Anthropic's Messages
are sent as the agent sent them, and Factory may refuse them from agents
other than Droid.
## Models
Each model is served on the one API droid uses for it:
+176
View File
@@ -0,0 +1,176 @@
// magpie #506: Codex on glm-5.3-flash through the plugin's Factory account
// got 403 "Factory refused this account the request…", where the built-in
// (since v0.1.630, e413dd84) opens another agent's request to /api/llm/o as
// droid 0.231.0 opens its own: Responses' instructions, or chat
// completions' first system message, start with droid's line, joined with
// "\n". droid's own requests and Anthropic's Messages go on byte for byte.
// The cases are the built-in's TestFactoryOpensAsDroid.
import { afterEach, expect, test } from "bun:test"
import { FactoryAuthPlugin, _internal } from "./index.mjs"
const { DROID_LINE } = _internal
const real = globalThis.fetch
afterEach(() => (globalThis.fetch = real))
const API = "https://api.factory.ai"
const chat = API + "/api/llm/o/v1/chat/completions"
const responses = API + "/api/llm/o/v1/responses"
const messages = API + "/api/llm/a/v1/messages"
async function loaded(auth) {
const sent = []
globalThis.fetch = async (url, init = {}) => {
const u = new URL(String(url))
if (u.pathname === "/api/cli/whoami") return new Response(JSON.stringify({ userId: "user_k", orgId: "fac_K", email: "k@example.com", region: "" }))
sent.push({ url: String(url), headers: new Headers(init.headers), body: init.body })
return new Response('{"id":"ok"}')
}
let saved = auth
const hooks = await FactoryAuthPlugin({ client: { auth: { set: async ({ body }) => (saved = body) } } })
const l = await hooks.auth.loader(async () => saved)
const send = async (url, body) => {
const res = await l.fetch(url, { method: "POST", headers: { "content-type": "application/json", "content-length": String(body.length) }, body })
expect(res.status).toBe(200)
return sent.at(-1)
}
return { send, sent, saved: () => saved, hooks }
}
const signedIn = {
type: "oauth",
access: "tok",
refresh: "r",
expires: Date.now() + 3_600_000,
accountId: "d@example.com",
activeOrganizationId: "fac_D",
region: "",
premBaseHost: "",
}
test("another agent's request to /api/llm/o opens with droid's line", async () => {
const { send } = await loaded({ ...signedIn })
// Codex on glm-5.3-flash, its Responses request made chat completions
let s = await send(chat, `{"model":"glm-5.3-flash","messages":[{"role":"system","content":"You are Codex, a coding agent."},{"role":"user","content":"hi <b> & co"}],"stream":true,"reasoning_effort":"high"}`)
let b = JSON.parse(s.body)
expect(b.messages).toEqual([
{ role: "system", content: DROID_LINE + "\nYou are Codex, a coding agent." },
{ role: "user", content: "hi <b> & co" },
])
expect(b.model).toBe("glm-5.3-flash")
expect(b.reasoning_effort).toBe("high")
expect(b.stream).toBe(true)
// the length was the old body's: it isn't sent on
expect(s.headers.get("content-length")).toBe(null)
expect(s.headers.get("x-api-provider")).toBe("fireworks")
expect(s.headers.get("x-client-version")).toBe("0.231.0")
expect(s.headers.get("user-agent")).toBe("factory-cli/0.231.0")
expect(s.headers.get("x-factory-org-id")).toBe("fac_D")
// Claude Code's system blocks, made chat completions as parts: joined
b = JSON.parse((await send(chat, `{"model":"kimi-k3","messages":[{"role":"system","content":[{"type":"text","text":"You are Claude Code."},{"type":"text","text":"Be brief."}]},{"role":"user","content":"hi"}]}`)).body)
expect(b.messages[0]).toEqual({ role: "system", content: DROID_LINE + "\nYou are Claude Code.\nBe brief." })
expect(b.messages.length).toBe(2)
// no system prompt: droid's line alone, before the rest
b = JSON.parse((await send(chat, `{"model":"glm-5.3","messages":[{"role":"user","content":"hi"}]}`)).body)
expect(b.messages).toEqual([{ role: "system", content: DROID_LINE }, { role: "user", content: "hi" }])
// Codex on GPT, Responses: the instructions open with the line
b = JSON.parse((await send(responses, `{"model":"gpt-5.5","instructions":"You are Codex, a coding agent.","input":[{"role":"user","content":"hi"}],"stream":true}`)).body)
expect(b.instructions).toBe(DROID_LINE + "\nYou are Codex, a coding agent.")
expect(b.input.length).toBe(1)
b = JSON.parse((await send(responses, `{"model":"grok-4.7","input":"hi"}`)).body)
expect(b.instructions).toBe(DROID_LINE)
})
test("droid's own requests, and Anthropic's Messages, go on byte for byte", async () => {
const { send } = await loaded({ ...signedIn })
for (const [url, body] of [
[chat, `{"model":"glm-5.3-flash","messages":[{"role":"system","content":"${DROID_LINE}\\nYou work in the user's terminal."},{"role":"user","content":"hi"}],"stream":true,"n":1.0}`],
[responses, `{"model":"gpt-5.5","input":[],"store":false,"instructions":"${DROID_LINE}\\nYou work in the user's terminal.","stream":true}`],
[messages, `{"model":"claude-opus-5-5","system":"You are Claude Code.","messages":[{"role":"user","content":"hi"}]}`],
[messages, `{"model":"minimax-m2.7","messages":[{"role":"user","content":"hi"}]}`],
]) {
const s = await send(url, body)
expect(s.body).toBe(body)
expect(s.headers.get("content-length")).toBe(String(body.length))
}
})
test("bytes are read as the string, and what isn't JSON goes as it is", () => {
const { droidBody } = _internal
const out = droidBody("/api/llm/o/v1/responses", new TextEncoder().encode(`{"model":"gpt-5.5","input":"hi"}`))
expect(JSON.parse(out).instructions).toBe(DROID_LINE)
expect(droidBody("/api/llm/o/v1/responses", "not json")).toBe("not json")
expect(droidBody("/api/llm/o/v1/responses", `{"instructions":[1]}`)).toBe(`{"instructions":[1]}`)
expect(droidBody("/api/llm/o/v1/models", `{"a":1}`)).toBe(`{"a":1}`)
})
test("GLM-5.3-Flash takes images, as droid 0.231.0's registry says", async () => {
const hooks = await FactoryAuthPlugin({ client: { auth: { set: async () => {} } } })
const cfg = { provider: {} }
await hooks.config(cfg)
const m = cfg.provider.factory.models["glm-5.3-flash"]
expect(m.attachment).toBe(true)
expect(m.modalities.input).toEqual(["text", "image"])
})
// droid's FACTORY_API_KEY, as the built-in's factory_key.go keeps one: the
// key is the bearer with droid's headers, no X-Factory-Org-Id, no WorkOS;
// whoami asked with the key says whose it is and where its org is served.
test("an API key account is the bearer, with no org and no renewal", async () => {
const hooks = await FactoryAuthPlugin({ client: { auth: { set: async () => {} } } })
const api = hooks.auth.methods.find((m) => m.type === "api")
expect(api.label).toBe("Factory API key (fk-…)")
const seen = []
globalThis.fetch = async (url, init = {}) => {
const u = new URL(String(url))
seen.push({ host: u.host, path: u.pathname, headers: new Headers(init.headers) })
if (u.pathname === "/api/cli/whoami") return new Response(JSON.stringify({ userId: "user_k", orgId: "fac_K", email: "k@example.com", region: "eu" }))
return new Response('{"id":"ok"}')
}
let saved = { type: "api", key: "fk-test-0123456789" }
const h2 = await FactoryAuthPlugin({ client: { auth: { set: async ({ body }) => (saved = body) } } })
const l = await h2.auth.loader(async () => saved)
expect(typeof l.fetch).toBe("function")
for (let i = 0; i < 2; i++) {
const res = await l.fetch(chat, { method: "POST", body: `{"model":"glm-5.3-flash","messages":[{"role":"user","content":"hi"}]}` })
expect(res.status).toBe(200)
}
const whoamis = seen.filter((s) => s.path === "/api/cli/whoami")
expect(whoamis.length).toBe(1) // once; then it is kept
expect(whoamis[0].headers.get("authorization")).toBe("Bearer fk-test-0123456789")
expect(whoamis[0].headers.get("x-factory-org-id")).toBe(null)
const reqs = seen.filter((s) => s.path === "/api/llm/o/v1/chat/completions")
expect(reqs.length).toBe(2)
for (const r of reqs) {
expect(r.host).toBe("api.eu.factory.ai") // whoami's region
expect(r.headers.get("authorization")).toBe("Bearer fk-test-0123456789")
expect(r.headers.get("x-factory-org-id")).toBe(null)
expect(r.headers.get("x-factory-client")).toBe("cli")
}
expect(seen.some((s) => s.host === "api.workos.com")).toBe(false)
expect(saved).toEqual({ type: "api", key: "fk-test-0123456789", metadata: { email: "k@example.com", userId: "user_k", region: "eu", premBaseHost: "" } })
// a 403 to a key isn't mended with an org: Factory's answer, explained
globalThis.fetch = async () => new Response(JSON.stringify({ error: { message: "nope" } }), { status: 403 })
const res = await l.fetch(chat, { method: "POST", body: `{"model":"glm-5.3","messages":[]}` })
expect(res.status).toBe(403)
expect((await res.json()).error.message).toMatch(/^nope — Factory takes/)
})
test("a key account's usage reads the limits with the key", async () => {
let asked
globalThis.fetch = async (url, init = {}) => {
const u = new URL(String(url))
if (u.pathname === "/api/billing/limits") {
asked = { host: u.host, auth: new Headers(init.headers).get("authorization") }
return new Response(JSON.stringify({ limits: { standard: { fiveHour: { usedPercent: 5 } } } }))
}
return new Response("{}", { status: 500 })
}
const auth = { type: "api", key: "fk-test-0123456789", metadata: { email: "k@example.com", region: "", premBaseHost: "" } }
const hooks = await FactoryAuthPlugin({ client: { auth: { set: async () => {} } } })
const u = await hooks.auth.usage(async () => auth)
expect(u.error).toBeUndefined()
expect(u.windows[0].used).toBe(5)
expect(asked).toEqual({ host: "api.factory.ai", auth: "Bearer fk-test-0123456789" })
})
+151 -8
View File
@@ -13,7 +13,7 @@ const API_EU = "https://api.eu.factory.ai"
// droid's WorkOS client, production
const CLIENT_ID = "client_01HNM792M5G5G1A2THWPXKFMXB"
// the droid release the requests say they are
const VERSION = "0.229.0"
const VERSION = "0.231.0"
// how long before an access token lapses it is renewed (droid: a minute)
const REFRESH_LEAD = 2 * 60 * 1000
// how long an account whose whoami failed waits before asking again
@@ -53,7 +53,7 @@ const MODELS = [
["grok-4.7", "Grok 4.7", RESPONSES, "xai", 500000, 63356, E4, true],
["grok-4.6", "Grok 4.6", RESPONSES, "xai", 200000, 63356, E4, true],
["glm-5.3", "GLM-5.3", CHAT, "fireworks", 1040000, 131072, ["low", "high", "max"], false],
["glm-5.3-flash", "GLM-5.3-Flash", CHAT, "fireworks", 1048576, 131072, ["low", "high", "max"], false],
["glm-5.3-flash", "GLM-5.3-Flash", CHAT, "fireworks", 1048576, 131072, ["low", "high", "max"], true],
["glm-5.2", "GLM-5.2", CHAT, "baseten", 1040000, 131072, ["high", "max"], false],
["kimi-k3", "Kimi K3", CHAT, "fireworks", 262144, 65536, ["low", "high", "max"], true],
["deepseek-v4.1-flash", "DeepSeek V4.1 Flash", CHAT, "fireworks", 1040000, 131072, ["low", "high", "max"], true],
@@ -245,7 +245,85 @@ const orgRefused = (status, text) => status === 403 && text.toLowerCase().includ
function explain(status, text) {
if (status !== 403) return ""
if (orgRefused(status, text)) return "the Factory account's organization changed; remove the account in magpie and sign in to it again"
return "Factory refused this account the request; check that `droid`, signed in to the same account and organization, can use this model (an organization's model policy or the plan may not allow it), and if it can, remove the Factory account in magpie and sign in to it again"
return "Factory takes a Factory subscription's requests only from Droid itself. magpie opens other agents' requests to Factory's GPT, Grok and open models (GLM, Kimi…) as Droid's do, but Factory may still tell them apart, and Claude models (and MiniMax M2.7) are sent as the agent sent them, so Claude Code's and other agents' are refused there; use the model from Droid, and if Droid is refused it too, the organization's model policy or the plan doesn't allow this model"
}
// ---- opening as droid ---------------------------------------------------------
//
// Factory takes a subscription's model requests only from Droid (magpie
// #242, #506): the same account's GPT, Grok and GLM answered Droid every
// time and refused Codex, Grok Build and Claude Code every time, on the same
// models, efforts, endpoint and headers, the body the only difference. Every
// request droid sends opens its system prompt with one line (droid 0.231.0:
// its system blocks are [that line, the agent's prompt, …], sent as
// Responses' instructions joined with "\n", and on chat completions as one
// system message first, joined the same way). So another agent's request to
// /api/llm/o opens with the line too, as the built-in's factoryDroidBody
// (internal/provider/factory_client.go) has it. Anthropic's Messages
// (/api/llm/a) is left as the agent sent it, and so is a request that
// already opens with the line: droid's own goes on byte for byte.
const DROID_LINE = "You are Droid, an AI software engineering agent built by Factory."
// droidChat opens msgs' first system message with droid's line, or puts one
// before them with the line alone: false when it opens so already.
function droidChat(msgs) {
const first = msgs[0]
if (first && typeof first === "object" && first.role === "system") {
const c = first.content
if (typeof c === "string") {
if (c.startsWith(DROID_LINE)) return false
first.content = c.trim() === "" ? DROID_LINE : DROID_LINE + "\n" + c
return true
}
if (Array.isArray(c)) {
// droid sends a string, its blocks joined with "\n": text parts
// alone are joined so
let texts = [DROID_LINE]
for (let i = 0; i < c.length; i++) {
const p = c[i]
if (!p || typeof p !== "object" || p.type !== "text" || typeof p.text !== "string") {
texts = null
break
}
if (i === 0 && p.text.startsWith(DROID_LINE)) return false
texts.push(p.text)
}
first.content = texts ? texts.join("\n") : [{ type: "text", text: DROID_LINE }, ...c]
return true
}
}
msgs.unshift({ role: "system", content: DROID_LINE })
return true
}
// droidBody is body, a request to Factory's /api/llm/o at path, as droid
// would open it: Responses' instructions, or chat completions' first system
// message, starting with droid's line. Anything else, a body that can't be
// read, or one that already starts so is returned as it is.
function droidBody(path, body) {
if (!path.includes("/llm/o/") || body == null) return body
let text
if (typeof body === "string") text = body
else if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) text = Buffer.from(body instanceof ArrayBuffer ? body : body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength)).toString("utf8")
else return body
let m
try {
m = JSON.parse(text)
} catch {
return body
}
if (!m || typeof m !== "object" || Array.isArray(m)) return body
if (path.endsWith("/responses")) {
const v = m.instructions
if (v !== undefined && v !== null && typeof v !== "string") return body // not something droid sends
const ins = v ?? ""
if (ins.startsWith(DROID_LINE)) return body
m.instructions = ins.trim() === "" ? DROID_LINE : DROID_LINE + "\n" + ins
} else if (path.endsWith("/chat/completions")) {
if (!Array.isArray(m.messages) || !droidChat(m.messages)) return body
} else return body
return JSON.stringify(m)
}
// errorReply is an error as the API the request was for words one:
@@ -268,6 +346,35 @@ function said(res, v) {
return new Response(res.body, { status: res.status, statusText: res.statusText, headers: h })
}
// ---- API keys -----------------------------------------------------------------
//
// A Factory API key (fk-…), as droid takes one from FACTORY_API_KEY: its
// om() hands the key on as the token, sent as "Authorization: Bearer fk-…"
// with the headers every request carries, and never renewed. droid's active
// org (st(), X-Factory-Org-Id) is what a sign-in stored, so a key alone
// sends none. As the built-in's factory_key.go keeps one.
const isKey = (a) => a?.type === "api" && typeof a.key === "string" && a.key.trim() !== ""
// keyAccount is a key as the account the requests are signed with.
function keyAccount(a) {
const md = a.metadata ?? {}
const key = a.key.trim()
return {
key: true,
access: key,
refresh: "",
expires: 0,
accountId: md.email || md.userId || "",
email: md.email ?? "",
userId: md.userId ?? "",
activeOrganizationId: "",
region: md.region ?? "",
premBaseHost: md.premBaseHost ?? "",
whoKnown: typeof md.region === "string",
}
}
// ---- sign-in ----------------------------------------------------------------
// signedInWith is the account WorkOS just signed in, as droid keeps it: a
@@ -476,8 +583,8 @@ export const FactoryAuthPlugin = async ({ client }) => {
// when each account last asked whoami for its org, so one whoami can't
// answer doesn't ask before every request, nor hold back the others
const asked = new Map()
const askedOf = (c) => asked.get(c.accountId || c.refresh || "") ?? 0
const ask = (c) => asked.set(c.accountId || c.refresh || "", Date.now())
const askedOf = (c) => asked.get(c.accountId || c.refresh || c.access || "") ?? 0
const ask = (c) => asked.set(c.accountId || c.refresh || c.access || "", Date.now())
// account is the account getAuth reads, with what keeps its token live
// and its org right.
@@ -488,10 +595,39 @@ export const FactoryAuthPlugin = async ({ client }) => {
}
const current = async () => {
const a = await getAuth()
if (isKey(a)) return keyAccount(a)
if (a?.type !== "oauth" || !a.access) throw new Error("Factory: not signed in")
return { ...a }
}
// keyed is a key account with where Factory serves its org: whoami,
// asked with the key and no org (droid's st() is null for a key), as
// droid's yP checks a key before it is used, and as the built-in asks
// it when the key is added. What it names is kept in the key's
// metadata, so magpie shows whose the key is; a whoami that fails is
// asked again ASK_AGAIN later, the request going on meanwhile.
const keyed = async (c) => {
if (c.whoKnown || Date.now() - askedOf(c) < ASK_AGAIN) return c
ask(c)
let who
try {
who = await whoami({ ...c, activeOrganizationId: "" })
} catch {
return c
}
c.region = who.region ?? ""
c.premBaseHost = who.premBaseHostV2 ?? ""
c.email ||= who.email ?? ""
c.userId ||= who.userId ?? ""
c.whoKnown = true
const a = await getAuth()
if (isKey(a) && a.key === c.access) {
const metadata = { ...(a.metadata ?? {}), email: c.email, userId: c.userId, region: c.region, premBaseHost: c.premBaseHost }
await client.auth.set({ path: { id: PROVIDER }, body: { ...a, metadata } }).catch(() => {})
}
return c
}
// orgOf fills in the active org when there is none: droid asks
// whoami as soon as it holds a token and sends the orgId it answers
// as X-Factory-Org-Id on every request after.
@@ -507,6 +643,7 @@ export const FactoryAuthPlugin = async ({ client }) => {
const fresh = (renewed) =>
locked(async () => {
const c = await current()
if (c.key) return keyed(c) // an API key: nothing to renew, and no org with it
if ((c.expires > 0 && Date.now() < c.expires - REFRESH_LEAD) || !c.refresh) return orgOf(c)
let t
try {
@@ -539,6 +676,7 @@ export const FactoryAuthPlugin = async ({ client }) => {
if (status !== 403) return false
const isOrg = orgRefused(status, text)
const c = await current()
if (c.key) return false // an API key carries no org droid would send
if (c.activeOrganizationId) {
if (!isOrg) return false // the org was sent: the refusal is about something else
const was = c.activeOrganizationId
@@ -633,6 +771,8 @@ export const FactoryAuthPlugin = async ({ client }) => {
label: "Sign in with Factory (device code)",
authorize: deviceSignIn,
},
// droid's FACTORY_API_KEY: the key is the bearer, never renewed
{ type: "api", label: "Factory API key (fk-…)", placeholder: "fk-…" },
],
// magpie's own hook: the account's limits
async usage(getAuth) {
@@ -640,7 +780,7 @@ export const FactoryAuthPlugin = async ({ client }) => {
},
async loader(getAuth) {
const first = await getAuth()
if (first?.type !== "oauth") return {}
if (first?.type !== "oauth" && !isKey(first)) return {}
const { fresh, mendOrg } = account(getAuth)
@@ -665,7 +805,10 @@ export const FactoryAuthPlugin = async ({ client }) => {
// droid's Anthropic client is made with the key "placeholder",
// which Anthropic's SDK sends beside the bearer token
if (path.includes("/llm/a/")) h.set("X-Api-Key", "placeholder")
return fetch(url, { ...init, method: init?.method ?? (input instanceof Request ? input.method : "POST"), headers: h, body })
// another agent's request opens as droid's does (droidBody)
const out = droidBody(path, body)
if (out !== body) h.delete("content-length")
return fetch(url, { ...init, method: init?.method ?? (input instanceof Request ? input.method : "POST"), headers: h, body: out })
}
return {
@@ -710,4 +853,4 @@ export const FactoryAuthPlugin = async ({ client }) => {
}
// for tests
export const _internal = { limitWindows, windowEnd, dollars, vendorError, CORE }
export const _internal = { limitWindows, windowEnd, dollars, vendorError, CORE, droidBody, DROID_LINE }
+2 -2
View File
@@ -66,10 +66,10 @@ test("a refusal says what to do after an em dash, as the built-in's Explain join
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(res.headers.get("X-Magpie-Sign-In")).toBe("kept")
expect((await res.json()).error.message).toMatch(/^model not allowed — Factory refused this account the request; check that `droid`/)
expect((await res.json()).error.message).toMatch(/^model not allowed — Factory takes a Factory subscription's requests only from Droid itself\. /)
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/)
expect((await res.json()).error.message).toMatch(/^403 Forbidden — Factory takes a Factory subscription's requests only from Droid/)
})
// a live account whose requests fetch answers with serve
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-factory-auth",
"version": "0.1.4",
"version": "0.1.5",
"description": "Sign in to a Factory (Droid) subscription from OpenCode or magpie",
"type": "module",
"main": "./index.mjs",