diff --git a/packages/factory/README.md b/packages/factory/README.md index 465982c..b1c472f 100644 --- a/packages/factory/README.md +++ b/packages/factory/README.md @@ -65,14 +65,22 @@ Each model is served on the one API droid uses for it: |---|---| | Anthropic Messages (`/api/llm/a`) | Fable 5.1, Fable 5, Opus 5.5, Opus 5, Opus 4.8 (each also in Fast Mode), Sonnet 5.5, Sonnet 5, Sonnet 4.6, Haiku 5.5, Haiku 4.5, MiniMax M2.7 | | OpenAI Responses (`/api/llm/o/v1`) | GPT-6.1 Sol, GPT-6 Sol/Astra/Luna, GPT-5.6 Sol/Terra/Luna, GPT-5.5, GPT-5.4, GPT-5.3-Codex (each also in Fast Mode), Grok 4.7, Grok 4.6 | -| Chat completions (`/api/llm/o/v1`) | GLM-5.3, GLM-5.3-Flash, GLM-5.2, Kimi K3, DeepSeek V4.1 Flash, Qwen3.8 Max, MiniMax M3, Mistral Large 4, Mistral Medium 3.5, Nemotron 3 Ultra | +| Chat completions (`/api/llm/o/v1`) | GLM-5.3, GLM-5.3-Flash, GLM-5.2, Kimi K3, DeepSeek V4.1 Flash, DeepSeek V4.1 Flash 1017, Qwen3.8 Max, MiniMax M3, Mistral Large 4, Mistral Medium 3.5, Nemotron 3 Ultra | | Gemini generate (`/api/llm/g/v1/generate`) | Gemini 4 Argon, Gemini 3.1 Pro, Gemini 3.8/3.7/3.6/3.5 Flash, Gemini 3 Flash | Reasoning efforts are the variants droid offers for each model. DeepSeek V4.1 -Flash, Kimi K3 and GLM-5.2 have `none`, droid's "off": they stop thinking. +Flash (including 1017), Kimi K3 and GLM-5.2 have `none`, droid's "off": they stop thinking. Reasoning is mandatory on GLM-5.3 and GLM-5.3-Flash (Fireworks turns `none` away), so `low` is their least. +DeepSeek V4.1 Flash 1017 (`deepseek-v4.1-flash-1017`) is a separate model +entry, with droid 0.251.0's 1,040,000-token context, 131,072-token output, +image support, `none`/`low`/`high`/`max` efforts and 0.12x token multiplier. +It uses Baseten, first in Factory's routing when checked on 2026-10-29; +live requests accepted the model on both Baseten and Fireworks. The +original Flash stays on Fireworks. Factory gates 1017 with a feature flag, +so availability still depends on the account. + A model's price is its token multiplier in droid's registry (`cost.tokenMultiplier`), which magpie shows beside the model as its rate (`0.8×`), so a cheap one is picked without opening droid. A promotion running diff --git a/packages/factory/droid.test.mjs b/packages/factory/droid.test.mjs index d904c6e..6216425 100644 --- a/packages/factory/droid.test.mjs +++ b/packages/factory/droid.test.mjs @@ -80,6 +80,22 @@ test("another agent's request to /api/llm/o opens with droid's line", async () = expect(b.instructions).toBe(DROID_LINE) }) +// Factory's routing on 2026-10-29 prefers Baseten for 1017 and Fireworks +// for the original Flash; live 1017 requests succeeded on both upstreams. +test("1017 uses Baseten with every reasoning effort and keeps the original Flash on Fireworks", async () => { + const { send } = await loaded({ ...signedIn }) + const model = "deepseek-v4.1-flash-1017" + for (const effort of ["none", "low", "high", "max"]) { + const s = await send(chat, JSON.stringify({ model, messages: [{ role: "user", content: "hi" }], reasoning_effort: effort, stream: true })) + expect(s.url).toBe(chat) + expect(s.headers.get("x-api-provider")).toBe("baseten") + expect(JSON.parse(s.body)).toMatchObject({ model, reasoning_effort: effort, stream: true }) + } + const original = await send(chat, JSON.stringify({ model: "deepseek-v4.1-flash", messages: [{ role: "user", content: "hi" }] })) + expect(original.headers.get("x-api-provider")).toBe("fireworks") + expect(JSON.parse(original.body).model).toBe("deepseek-v4.1-flash") +}) + test("droid's own requests go on byte for byte on each API", async () => { const { send } = await loaded({ ...signedIn }) for (const [url, body] of [ diff --git a/packages/factory/index.mjs b/packages/factory/index.mjs index a79e09b..f4ea380 100644 --- a/packages/factory/index.mjs +++ b/packages/factory/index.mjs @@ -87,6 +87,8 @@ const MODELS = [ ["glm-5.2", "GLM-5.2", CHAT, "baseten", 1040000, 131072, ["none", "high", "max"], false, 0.56], ["kimi-k3", "Kimi K3", CHAT, "fireworks", 262144, 65536, ["none", "low", "high", "max"], true, 1.2], ["deepseek-v4.1-flash", "DeepSeek V4.1 Flash", CHAT, "fireworks", 1040000, 131072, ["none", "low", "high", "max"], true, 0.12], + // Factory's routing prefers Baseten for 1017; both upstreams accept it. + ["deepseek-v4.1-flash-1017", "DeepSeek V4.1 Flash 1017", CHAT, "baseten", 1040000, 131072, ["none", "low", "high", "max"], true, 0.12], ["qwen3.8-max", "Qwen3.8 Max", CHAT, "fireworks", 262144, 131072, ["low", "medium", "xhigh"], false, 0.8], ["minimax-m3", "MiniMax M3", CHAT, "fireworks", 512000, 64000, ["high"], true, 0.12], ["minimax-m2.7", "MiniMax M2.7", ANTHROPIC, "fireworks", 196600, 64000, ["high"], false, 0.12], diff --git a/packages/factory/models.test.mjs b/packages/factory/models.test.mjs index c6aff99..ab6c3a0 100644 --- a/packages/factory/models.test.mjs +++ b/packages/factory/models.test.mjs @@ -109,3 +109,36 @@ test("droid 0.241.1's Gemini models are offered on Factory's Gemini route, as dr } expect(got["gemini-4-argon"].variants.high).toEqual({ thinkingConfig: { includeThoughts: true, thinkingLevel: "high" } }) }) + +const DROID_251 = readFileSync(new URL("./testdata/droid-0.251.0-deepseek-1017.txt", import.meta.url), "utf8") + +test("DeepSeek V4.1 Flash 1017 reaches both model hooks as droid 0.251.0 has it", async () => { + const id = "deepseek-v4.1-flash-1017" + const text = DROID_251.split("\n").find((l) => l.startsWith(`"${id}":{id:"${id}",`)) + expect(text).toContain('apiModelProvider:"generic-chat-completion-api"') + expect(text).toContain('apiProviders:["fireworks","baseten","databricks"]') + expect(text).toContain("images:!0") + expect(DROID_251).toContain("function c(o,t){return R({maxInputTokens:o-t,maxOutputTokens:t})}") + const [, context, output] = text.match(/contextLimits:c\((\d+),(\d+)\)/) + const efforts = JSON.parse(text.match(/reasoningEffort:\{supported:(\[[^\]]*\])/)[1]).map((e) => e === "off" ? "none" : e) + const variants = Object.fromEntries(efforts.map((e) => [e, { reasoningEffort: e }])) + const hooks = await FactoryAuthPlugin({ client: { auth: { set: async () => {} } } }) + const config = (await models())[id] + const provider = (await hooks.provider.models({ id: "factory" }, {}))[id] + for (const m of [config, provider]) { + expect(m).toBeDefined() + expect(m.id).toBe(id) + expect(m.name).toBe(text.match(/,name:"([^"]+)"/)[1]) + expect(m.limit).toEqual({ context: Number(context), output: Number(output) }) + expect(m.variants).toEqual(variants) + expect(m.rate).toBe(Number(text.match(/cost:\{tokenMultiplier:([\d.]+)/)[1])) + expect(m.rateWas).toBe(0) + } + expect(config.provider).toEqual({ npm: "@ai-sdk/openai-compatible", api: "https://api.factory.ai/api/llm/o/v1" }) + expect(config.attachment).toBe(true) + expect(config.modalities.input).toEqual(["text", "image"]) + expect(provider.providerID).toBe("factory") + expect(provider.api).toEqual({ id, url: config.provider.api, npm: config.provider.npm }) + expect(provider.capabilities.attachment).toBe(true) + expect(provider.capabilities.input.image).toBe(true) +}) diff --git a/packages/factory/package.json b/packages/factory/package.json index cd8a3b0..36f3ba1 100644 --- a/packages/factory/package.json +++ b/packages/factory/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-factory-auth", - "version": "0.1.38", + "version": "0.1.39", "description": "Sign in to a Factory (Droid) subscription from OpenCode or magpie", "type": "module", "main": "./index.mjs", diff --git a/packages/factory/rate.test.mjs b/packages/factory/rate.test.mjs index 505e869..b0103f1 100644 --- a/packages/factory/rate.test.mjs +++ b/packages/factory/rate.test.mjs @@ -4,18 +4,19 @@ // droid. A promotion running comes off it, with the multiplier before the // discount as rateWas — magpie strikes that through beside the price, as it // does for WorkBuddy's credits and Qoder's price factors. The cases are droid -// 0.241.1's own registry entries, saved byte for byte in testdata. +// 0.241.1's registry costs and 0.251.0's 1017 entry, saved in testdata. import { expect, test } from "bun:test" import { readFileSync } from "node:fs" import { FactoryAuthPlugin, _internal } from "./index.mjs" -const DROID = readFileSync(new URL("./testdata/droid-0.241.1-costs.txt", import.meta.url), "utf8") +const DROID = ["droid-0.241.1-costs.txt", "droid-0.251.0-deepseek-1017.txt"] + .map((name) => readFileSync(new URL(`./testdata/${name}`, import.meta.url), "utf8")).join("\n") // cost is a model's cost text, as its entry keeps it. function cost(id) { - const line = DROID.split("\n").find((l) => l.startsWith(`"${id}":cost:`)) + const line = DROID.split("\n").find((l) => l.startsWith(`"${id}":`)) if (!line) throw new Error(`${id} is not in the fixture`) - return line.slice(id.length + 3) + return line.slice(line.indexOf("cost:")) } // multiplier is the token multiplier an entry lists. @@ -53,7 +54,7 @@ function price(id, now) { return { rate: Number((base * (1 - p.discount)).toFixed(4)), rateWas: base } } -test("every model's rate is the token multiplier droid 0.241.1 lists it with", () => { +test("every model's rate is the token multiplier its droid registry entry lists", () => { for (const m of _internal.MODELS) { expect(m.rate).toBe(multiplier(m.id)) } diff --git a/packages/factory/testdata/droid-0.251.0-deepseek-1017.txt b/packages/factory/testdata/droid-0.251.0-deepseek-1017.txt new file mode 100644 index 0000000..f61300c --- /dev/null +++ b/packages/factory/testdata/droid-0.251.0-deepseek-1017.txt @@ -0,0 +1,5 @@ +// Excerpts, byte for byte, of Factory.app's bundled droid 0.251.0 +// (Contents/Resources/bin/droid): the total-context helper and 1017 entry. +// Binary SHA-256: 7cf155967a78b75a47de53c5ed99522b77c22a4abd1617e74f167d882c059cfa +function c(o,t){return R({maxInputTokens:o-t,maxOutputTokens:t})} +"deepseek-v4.1-flash-1017":{id:"deepseek-v4.1-flash-1017",name:"DeepSeek V4.1 Flash 1017",shortName:"DeepSeek V4.1 Flash 1017",provider:"factory",apiModelProvider:"generic-chat-completion-api",featureFlag:w.DeepSeekV41Flash1017,apiProviders:["fireworks","baseten","databricks"],routingConfig:m.DEEPSEEK_V4_1_FLASH_1017,apiProviderConfig:{fireworks:{...Z,modelId:"accounts/fireworks/models/deepseek-v4p1-flash-1017"},baseten:{...Z,modelId:"deepseek-ai/DeepSeek-V4.1-Flash-1017",chatCompletions:{...Z.chatCompletions,thinkingMode:"reasoning-effort"}},databricks:{...bt,modelId:"system.ai.deepseek-v4-1-flash-1017"}},reasoningEffort:{supported:["off","low","high","max"],default:"high"},chatCompletionRequest:Pe(),tier:"standard",billingPool:"core",images:!0,pdf:!1,contextLimits:c(1040000,131072),disabledForPilots:!1,cost:{tokenMultiplier:0.12,cacheReadTokenMultiplier:0.024,outputTokenMultiplier:4},usesUSBasedInference:!0,matchPatterns:[/deepseek[^a-z0-9]*v?4(?:[^a-z0-9]*1|p1)[^a-z0-9]*flash[^a-z0-9]*1017/i],newUntil:new Date("2026-10-22T00:00:00Z")} diff --git a/packages/factory/usage.test.mjs b/packages/factory/usage.test.mjs index 161a304..57d0a81 100644 --- a/packages/factory/usage.test.mjs +++ b/packages/factory/usage.test.mjs @@ -20,7 +20,7 @@ const LIMITS = { extraUsageAllowed: true, } -const CORE = ["glm-5.3", "glm-5.3-flash", "glm-5.2", "kimi-k3", "deepseek-v4.1-flash", "qwen3.8-max", "minimax-m3", "minimax-m2.7", "mistral-large-4", "mistral-medium-3.5", "nemotron-3-ultra"] +const CORE = ["glm-5.3", "glm-5.3-flash", "glm-5.2", "kimi-k3", "deepseek-v4.1-flash", "deepseek-v4.1-flash-1017", "qwen3.8-max", "minimax-m3", "minimax-m2.7", "mistral-large-4", "mistral-medium-3.5", "nemotron-3-ultra"] const account = (over = {}) => ({ type: "oauth",