@magpie-community/opencode-factory-auth 0.1.38 → 0.1.40

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.
Files changed (3) hide show
  1. package/README.md +11 -2
  2. package/index.mjs +15 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -65,14 +65,23 @@ Each model is served on the one API droid uses for it:
65
65
  |---|---|
66
66
  | 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 |
67
67
  | 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 |
68
- | 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 |
68
+ | 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 |
69
69
  | 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 |
70
70
 
71
71
  Reasoning efforts are the variants droid offers for each model. DeepSeek V4.1
72
- Flash, Kimi K3 and GLM-5.2 have `none`, droid's "off": they stop thinking.
72
+ Flash (1017 too), Kimi K3 and GLM-5.2 have `none`, droid's "off": they stop
73
+ thinking.
73
74
  Reasoning is mandatory on GLM-5.3 and GLM-5.3-Flash (Fireworks turns `none`
74
75
  away), so `low` is their least.
75
76
 
77
+ DeepSeek V4.1 Flash 1017 (`deepseek-v4.1-flash-1017`) is a separate model
78
+ entry, with droid 0.251.0's 1,040,000-token context, 131,072-token output,
79
+ image support, `none`/`low`/`high`/`max` efforts and 0.12x token multiplier.
80
+ Like every other model here it goes to its registry's default upstream,
81
+ `apiProviders[0]`, which is Fireworks, as droid sends it with
82
+ `x-provider-routing-source: registry_default`. Factory gates 1017 with a
83
+ feature flag, so availability still depends on the account.
84
+
76
85
  A model's price is its token multiplier in droid's registry
77
86
  (`cost.tokenMultiplier`), which magpie shows beside the model as its rate
78
87
  (`0.8×`), so a cheap one is picked without opening droid. A promotion running
package/index.mjs CHANGED
@@ -87,6 +87,7 @@ const MODELS = [
87
87
  ["glm-5.2", "GLM-5.2", CHAT, "baseten", 1040000, 131072, ["none", "high", "max"], false, 0.56],
88
88
  ["kimi-k3", "Kimi K3", CHAT, "fireworks", 262144, 65536, ["none", "low", "high", "max"], true, 1.2],
89
89
  ["deepseek-v4.1-flash", "DeepSeek V4.1 Flash", CHAT, "fireworks", 1040000, 131072, ["none", "low", "high", "max"], true, 0.12],
90
+ ["deepseek-v4.1-flash-1017", "DeepSeek V4.1 Flash 1017", CHAT, "fireworks", 1040000, 131072, ["none", "low", "high", "max"], true, 0.12],
90
91
  ["qwen3.8-max", "Qwen3.8 Max", CHAT, "fireworks", 262144, 131072, ["low", "medium", "xhigh"], false, 0.8],
91
92
  ["minimax-m3", "MiniMax M3", CHAT, "fireworks", 512000, 64000, ["high"], true, 0.12],
92
93
  ["minimax-m2.7", "MiniMax M2.7", ANTHROPIC, "fireworks", 196600, 64000, ["high"], false, 0.12],
@@ -784,12 +785,15 @@ function tooLarge(text, left) {
784
785
 
785
786
  // errorReply is an error as the API the request was for words one:
786
787
  // Anthropic's on /llm/a/, OpenAI's on the others.
787
- function errorReply(url, status, type, message, headers = new Headers(), requestId) {
788
+ // code is the vendor's error code, kept on the error: magpie and OpenCode
789
+ // tell a refusal of the request apart by it (content_policy_rejected).
790
+ function errorReply(url, status, type, message, headers = new Headers(), requestId, code) {
788
791
  headers.set("content-type", "application/json")
789
792
  headers.delete("content-length")
790
793
  headers.delete("content-encoding")
791
794
  const anthropic = new URL(url).pathname.includes("/llm/a/")
792
- const body = anthropic ? { type: "error", error: { type, message } } : { error: { message, type, code: null } }
795
+ const body = anthropic ? { type: "error", error: { type, message } } : { error: { message, type, code: code ?? null } }
796
+ if (anthropic && code) body.error.code = code
793
797
  // Anthropic's error body carries the request id beside the error
794
798
  if (anthropic && requestId) body.request_id = requestId
795
799
  return new Response(JSON.stringify(body), { status, headers })
@@ -2087,6 +2091,15 @@ export const FactoryAuthPlugin = async ({ client, magpie }) => {
2087
2091
  // the refusal, then what to do about it, as provider.Explain joins them
2088
2092
  const ids = upstreamIds(text, res.headers)
2089
2093
  const msg = `${vendorError(text, statusLine(res.status))}${ids.said} — ${why}`
2094
+ if (contentRefused(res.status, text, res.headers)) {
2095
+ // the usage policy check refused what the request says, not
2096
+ // the account: a 400 invalid_request_error with Factory's
2097
+ // code, as OpenAI words a content refusal. Its 403
2098
+ // permission_error read to agents as a failed sign-in
2099
+ // (yetone/magpie, sweanng: ZCode's "Provider
2100
+ // authentication failed", reason=auth_failed status=403)
2101
+ return answer(errorReply(url, 400, "invalid_request_error", msg, new Headers(res.headers), ids.id, "content_policy_rejected"))
2102
+ }
2090
2103
  return answer(errorReply(url, res.status, "permission_error", msg, new Headers(res.headers), ids.id))
2091
2104
  } catch (e) {
2092
2105
  // Factory refused to renew the sign-in: the built-in failed the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-factory-auth",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "Sign in to a Factory (Droid) subscription from OpenCode or magpie",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",