@magpie-community/opencode-factory-auth 0.1.37 → 0.1.39
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/README.md +35 -2
- package/index.mjs +43 -8
- 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
|
|
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
|
|
@@ -115,6 +124,30 @@ magpie plugin add @magpie-community/opencode-factory-auth
|
|
|
115
124
|
magpie plugin login factory
|
|
116
125
|
```
|
|
117
126
|
|
|
127
|
+
## Standard usage only (optional)
|
|
128
|
+
|
|
129
|
+
In magpie, open the Factory provider, turn on **Standard usage only** under
|
|
130
|
+
**Plugin options**, and save (or set `"pluginOptions": {"factory":
|
|
131
|
+
{"standard_only": true}}` in magpie's settings.json). It is off by default,
|
|
132
|
+
applies to every Factory account, and takes effect at each account's next
|
|
133
|
+
usage reading.
|
|
134
|
+
|
|
135
|
+
When on, the plugin reports the Standard 5 hours, 7 days and 30 days
|
|
136
|
+
windows as counting every model, Droid Core's open models too, whether or
|
|
137
|
+
not the account has Extra usage. Droid Core's windows and Extra usage are
|
|
138
|
+
still shown but never keep an account in routing.
|
|
139
|
+
|
|
140
|
+
magpie leaves an account out before sending only when it is held at a
|
|
141
|
+
usage cap, so pair the option with a cap on each account, for example
|
|
142
|
+
`magpie provider account-cap factory <account> 99`. An account is then
|
|
143
|
+
skipped once any Standard window reaches the cap, the request goes to the
|
|
144
|
+
next account with the same model, and when every account is held magpie
|
|
145
|
+
answers 429 without sending. Without a cap, an account whose Standard
|
|
146
|
+
usage is gone is still tried, and Factory may serve a Droid Core model
|
|
147
|
+
from Core or Extra usage. Readings lag, so the last requests before a
|
|
148
|
+
window fills still go out; to never spend Extra usage, turn it off in
|
|
149
|
+
Factory.
|
|
150
|
+
|
|
118
151
|
## Claude Code through magpie
|
|
119
152
|
|
|
120
153
|
Factory's Anthropic route requires Droid's fixed client preamble and
|
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],
|
|
@@ -983,11 +984,19 @@ function dollars(cents) {
|
|
|
983
984
|
return "$" + ((lo % 2 === 0 ? lo : lo + 1) / 100).toFixed(2)
|
|
984
985
|
}
|
|
985
986
|
|
|
987
|
+
// STANDARD_ONLY is the switch (magpie's plugin options, off by default)
|
|
988
|
+
// that keeps an account in routing only while its Standard usage lasts
|
|
989
|
+
// (magpie-community/plugins#349)
|
|
990
|
+
const STANDARD_ONLY = "standard_only"
|
|
991
|
+
|
|
986
992
|
// limitWindows turns the limits into windows: standard's by their span,
|
|
987
993
|
// then Droid Core's, then the extra usage left. For routing, standard counts
|
|
988
994
|
// the vendors' models and Core the open ones Factory hosts; with extra usage
|
|
989
|
-
// to spend, a window used up stops neither.
|
|
990
|
-
|
|
995
|
+
// to spend, a window used up stops neither. standardOnly (STANDARD_ONLY on)
|
|
996
|
+
// makes standard's windows count every model, Core's too, extra usage or
|
|
997
|
+
// not, and leaves Droid Core's and the extra usage to be shown only: an
|
|
998
|
+
// account stops when any of standard's windows is used up.
|
|
999
|
+
function limitWindows(l, standardOnly = false) {
|
|
991
1000
|
const out = []
|
|
992
1001
|
const cents = typeof l.extraUsageBalanceCents === "number" ? l.extraUsageBalanceCents : null
|
|
993
1002
|
const extra = l.extraUsageAllowed === true && cents !== null && cents > 0
|
|
@@ -1003,9 +1012,16 @@ function limitWindows(l) {
|
|
|
1003
1012
|
const win = { name: prefix + name, used: Math.min(Math.max(used, 0), 100), span }
|
|
1004
1013
|
const end = windowEnd(w.windowEnd)
|
|
1005
1014
|
if (end) win.resetsAt = end
|
|
1006
|
-
if (
|
|
1007
|
-
|
|
1008
|
-
|
|
1015
|
+
if (standardOnly) {
|
|
1016
|
+
if (core) {
|
|
1017
|
+
win.aside = true
|
|
1018
|
+
win.models = CORE
|
|
1019
|
+
}
|
|
1020
|
+
} else {
|
|
1021
|
+
if (extra) win.aside = true
|
|
1022
|
+
if (core) win.models = CORE
|
|
1023
|
+
else win.notModels = CORE
|
|
1024
|
+
}
|
|
1009
1025
|
out.push(win)
|
|
1010
1026
|
}
|
|
1011
1027
|
}
|
|
@@ -1676,7 +1692,16 @@ function anthropicBody(body) {
|
|
|
1676
1692
|
return changed ? JSON.stringify(request) : body
|
|
1677
1693
|
}
|
|
1678
1694
|
|
|
1679
|
-
export const FactoryAuthPlugin = async ({ client }) => {
|
|
1695
|
+
export const FactoryAuthPlugin = async ({ client, magpie }) => {
|
|
1696
|
+
// standardOnly is the user's STANDARD_ONLY as magpie has it now, read at
|
|
1697
|
+
// each usage reading so a change needs no restart; false outside magpie
|
|
1698
|
+
const standardOnly = () => {
|
|
1699
|
+
try {
|
|
1700
|
+
return magpie?.option?.(PROVIDER, STANDARD_ONLY) === true
|
|
1701
|
+
} catch {
|
|
1702
|
+
return false
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1680
1705
|
// the session id this process's requests carry
|
|
1681
1706
|
const session = crypto.randomUUID()
|
|
1682
1707
|
// serializes checking, rotating and saving tokens: WorkOS rotates the
|
|
@@ -1870,7 +1895,7 @@ export const FactoryAuthPlugin = async ({ client }) => {
|
|
|
1870
1895
|
l = await limits()
|
|
1871
1896
|
}
|
|
1872
1897
|
if (!l?.limits?.standard) return { error: "Factory: the account reported no limits", signIn }
|
|
1873
|
-
return { windows: limitWindows(l), signIn }
|
|
1898
|
+
return { windows: limitWindows(l, standardOnly()), signIn }
|
|
1874
1899
|
} catch (e) {
|
|
1875
1900
|
if (e?.lapsed) signIn = "expired"
|
|
1876
1901
|
return { error: e?.message ?? String(e), signIn }
|
|
@@ -1924,6 +1949,16 @@ export const FactoryAuthPlugin = async ({ client }) => {
|
|
|
1924
1949
|
// droid's FACTORY_API_KEY: the key is the bearer, never renewed
|
|
1925
1950
|
{ type: "api", label: "Factory API key (fk-…)", placeholder: "fk-…" },
|
|
1926
1951
|
],
|
|
1952
|
+
// magpie's own switches (input.magpie.option), read at each usage
|
|
1953
|
+
// reading
|
|
1954
|
+
options: [
|
|
1955
|
+
{
|
|
1956
|
+
key: STANDARD_ONLY,
|
|
1957
|
+
label: "Standard usage only",
|
|
1958
|
+
description:
|
|
1959
|
+
"Keeps an account in routing only while its Standard usage lasts: once any Standard window (5 hours, 7 days, 30 days) is used up, magpie moves every model, Droid Core's too, to the next account until the window resets. Droid Core and Extra usage are shown but never keep an account in routing.",
|
|
1960
|
+
},
|
|
1961
|
+
],
|
|
1927
1962
|
// magpie renews the sign-in MAGPIE_LEAD before its end, before its
|
|
1928
1963
|
// requests and usage ask for it, and saves what this gives. Under
|
|
1929
1964
|
// the same lock as the renewal before a request, so the two never
|
|
@@ -2068,4 +2103,4 @@ export const FactoryAuthPlugin = async ({ client }) => {
|
|
|
2068
2103
|
}
|
|
2069
2104
|
|
|
2070
2105
|
// for tests
|
|
2071
|
-
export const _internal = { contentRefused, explain, fastBody, FAST_BETA, limitWindows, windowEnd, dollars, vendorError, CORE, droidBody, DROID_LINE, geminiBody, leaveOutAttachments, LEFT_OUT, TOO_LARGE_HINT, MODELS, PROMOTIONS, rateOf, configModels, providerModel, providerModels }
|
|
2106
|
+
export const _internal = { STANDARD_ONLY, contentRefused, explain, fastBody, FAST_BETA, limitWindows, windowEnd, dollars, vendorError, CORE, droidBody, DROID_LINE, geminiBody, leaveOutAttachments, LEFT_OUT, TOO_LARGE_HINT, MODELS, PROMOTIONS, rateOf, configModels, providerModel, providerModels }
|