@magpie-community/opencode-factory-auth 0.1.31 → 0.1.33
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 +16 -3
- package/index.mjs +158 -60
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,6 +73,14 @@ Flash, Kimi K3 and GLM-5.2 have `none`, droid's "off": they stop thinking.
|
|
|
73
73
|
Reasoning is mandatory on GLM-5.3 and GLM-5.3-Flash (Fireworks turns `none`
|
|
74
74
|
away), so `low` is their least.
|
|
75
75
|
|
|
76
|
+
A model's price is its token multiplier in droid's registry
|
|
77
|
+
(`cost.tokenMultiplier`), which magpie shows beside the model as its rate
|
|
78
|
+
(`0.8×`), so a cheap one is picked without opening droid. A promotion running
|
|
79
|
+
comes off it, with the multiplier before the discount struck through beside
|
|
80
|
+
the price (`rateWas`): Mistral Large 4's launch discount, Gemini 4 Argon's,
|
|
81
|
+
Gemini 3.8/3.7 Flash's and GPT-5.6 Sol's, each while droid's own dates for it
|
|
82
|
+
hold. A promotion that has ended is no discount at all.
|
|
83
|
+
|
|
76
84
|
Gemini's requests go to Factory's generate route with the model in the
|
|
77
85
|
body, droid's line opening the system instruction. Gemini 4 Argon is behind
|
|
78
86
|
a Factory feature flag in droid 0.241.1, so an account it isn't on for may
|
|
@@ -120,9 +128,14 @@ The fixed Claude identity is recognized as a complete first line too when
|
|
|
120
128
|
magpie joins it with the following system instructions into one text block.
|
|
121
129
|
|
|
122
130
|
For the built-in `update-config` skill, the adapter changes only the known
|
|
123
|
-
self-reference "not Claude" to "not the assistant" inside
|
|
124
|
-
generated skill
|
|
125
|
-
|
|
131
|
+
self-reference "not Claude" to "not the assistant" inside that skill's entry
|
|
132
|
+
in a generated skill list. Claude Code renders the entry two ways: as a
|
|
133
|
+
system message (`- update-config: …`) and, in the `claude-code-guide` agent's
|
|
134
|
+
own system prompt under `# User's Current Configuration`, with the slash that
|
|
135
|
+
invokes it (`- /update-config: …`). Both spellings are adapted, and only the
|
|
136
|
+
sentence Factory refuses changes, so the entry's name and the rest of the list
|
|
137
|
+
stay. Its configuration instructions, other skill descriptions, tools and
|
|
138
|
+
caller text are preserved.
|
|
126
139
|
|
|
127
140
|
Claude 5 can send runtime metadata in string-content `system` messages
|
|
128
141
|
instead of user-message reminders. The plugin adapts the known environment,
|
package/index.mjs
CHANGED
|
@@ -56,62 +56,62 @@ const E4 = ["low", "medium", "high", "xhigh"]
|
|
|
56
56
|
// base models aren't offered), GPT-5.6 Sol Fast (unreleased:!0) and
|
|
57
57
|
// GLM-5.2 Fast (behind a feature flag, on a Baseten model id of its own).
|
|
58
58
|
const MODELS = [
|
|
59
|
-
["claude-fable-5.1", "Fable 5.1", ANTHROPIC, "anthropic", 867000, 128000, E5, true],
|
|
60
|
-
["claude-fable-5", "Fable 5", ANTHROPIC, "anthropic", 867000, 128000, E5, true],
|
|
61
|
-
["claude-opus-5-5", "Opus 5.5", ANTHROPIC, "anthropic", 872000, 128000, E5, true],
|
|
62
|
-
["claude-opus-5", "Opus 5", ANTHROPIC, "anthropic", 867000, 128000, E5, true],
|
|
63
|
-
["claude-opus-4-8", "Opus 4.8", ANTHROPIC, "anthropic", 867000, 128000, E5, true],
|
|
64
|
-
["claude-sonnet-5-5", "Sonnet 5.5", ANTHROPIC, "anthropic", 872000, 128000, E5, true],
|
|
65
|
-
["claude-sonnet-5", "Sonnet 5", ANTHROPIC, "anthropic", 872000, 128000, E5, true],
|
|
66
|
-
["claude-sonnet-4-6", "Sonnet 4.6", ANTHROPIC, "anthropic", 931000, 64000, ["low", "medium", "high", "max"], true],
|
|
67
|
-
["claude-haiku-5-5", "Haiku 5.5", ANTHROPIC, "anthropic", 872000, 128000, E5, true],
|
|
68
|
-
["claude-haiku-4-5-20251001", "Haiku 4.5", ANTHROPIC, "anthropic", 0, 0, ["low", "medium", "high"], true],
|
|
69
|
-
["gpt-6.1-sol", "GPT-6.1 Sol", RESPONSES, "openai", 1050000, 128000, E5, true],
|
|
70
|
-
["gpt-6-sol", "GPT-6 Sol", RESPONSES, "openai", 1050000, 128000, E6, true],
|
|
71
|
-
["gpt-6-astra", "GPT-6 Astra", RESPONSES, "openai", 1050000, 128000, E5, true],
|
|
72
|
-
["gpt-6-luna", "GPT-6 Luna", RESPONSES, "openai", 1050000, 128000, E6, true],
|
|
73
|
-
["gpt-5.6-sol", "GPT-5.6 Sol", RESPONSES, "openai", 1050000, 128000, E6, true],
|
|
74
|
-
["gpt-5.6-terra", "GPT-5.6 Terra", RESPONSES, "openai", 1050000, 128000, E6, true],
|
|
75
|
-
["gpt-5.6-luna", "GPT-5.6 Luna", RESPONSES, "openai", 1050000, 128000, E6, true],
|
|
76
|
-
["gpt-5.5", "GPT-5.5", RESPONSES, "openai", 1050000, 128000, E4, true],
|
|
77
|
-
["gpt-5.4", "GPT-5.4", RESPONSES, "openai", 1050000, 128000, E4, true],
|
|
78
|
-
["gpt-5.3-codex", "GPT-5.3-Codex", RESPONSES, "openai", 400000, 128000, E4, true],
|
|
79
|
-
["grok-4.7", "Grok 4.7", RESPONSES, "xai", 500000, 63356, E4, true],
|
|
80
|
-
["grok-4.6", "Grok 4.6", RESPONSES, "xai", 200000, 63356, E4, true],
|
|
59
|
+
["claude-fable-5.1", "Fable 5.1", ANTHROPIC, "anthropic", 867000, 128000, E5, true, 4],
|
|
60
|
+
["claude-fable-5", "Fable 5", ANTHROPIC, "anthropic", 867000, 128000, E5, true, 4],
|
|
61
|
+
["claude-opus-5-5", "Opus 5.5", ANTHROPIC, "anthropic", 872000, 128000, E5, true, 1.6],
|
|
62
|
+
["claude-opus-5", "Opus 5", ANTHROPIC, "anthropic", 867000, 128000, E5, true, 2],
|
|
63
|
+
["claude-opus-4-8", "Opus 4.8", ANTHROPIC, "anthropic", 867000, 128000, E5, true, 2],
|
|
64
|
+
["claude-sonnet-5-5", "Sonnet 5.5", ANTHROPIC, "anthropic", 872000, 128000, E5, true, 0.8],
|
|
65
|
+
["claude-sonnet-5", "Sonnet 5", ANTHROPIC, "anthropic", 872000, 128000, E5, true, 0.8],
|
|
66
|
+
["claude-sonnet-4-6", "Sonnet 4.6", ANTHROPIC, "anthropic", 931000, 64000, ["low", "medium", "high", "max"], true, 1.2],
|
|
67
|
+
["claude-haiku-5-5", "Haiku 5.5", ANTHROPIC, "anthropic", 872000, 128000, E5, true, 0.04],
|
|
68
|
+
["claude-haiku-4-5-20251001", "Haiku 4.5", ANTHROPIC, "anthropic", 0, 0, ["low", "medium", "high"], true, 0.4],
|
|
69
|
+
["gpt-6.1-sol", "GPT-6.1 Sol", RESPONSES, "openai", 1050000, 128000, E5, true, 0.8],
|
|
70
|
+
["gpt-6-sol", "GPT-6 Sol", RESPONSES, "openai", 1050000, 128000, E6, true, 0.8],
|
|
71
|
+
["gpt-6-astra", "GPT-6 Astra", RESPONSES, "openai", 1050000, 128000, E5, true, 4],
|
|
72
|
+
["gpt-6-luna", "GPT-6 Luna", RESPONSES, "openai", 1050000, 128000, E6, true, 0.04],
|
|
73
|
+
["gpt-5.6-sol", "GPT-5.6 Sol", RESPONSES, "openai", 1050000, 128000, E6, true, 2],
|
|
74
|
+
["gpt-5.6-terra", "GPT-5.6 Terra", RESPONSES, "openai", 1050000, 128000, E6, true, 0.8],
|
|
75
|
+
["gpt-5.6-luna", "GPT-5.6 Luna", RESPONSES, "openai", 1050000, 128000, E6, true, 0.08],
|
|
76
|
+
["gpt-5.5", "GPT-5.5", RESPONSES, "openai", 1050000, 128000, E4, true, 2],
|
|
77
|
+
["gpt-5.4", "GPT-5.4", RESPONSES, "openai", 1050000, 128000, E4, true, 1],
|
|
78
|
+
["gpt-5.3-codex", "GPT-5.3-Codex", RESPONSES, "openai", 400000, 128000, E4, true, 0.7],
|
|
79
|
+
["grok-4.7", "Grok 4.7", RESPONSES, "xai", 500000, 63356, E4, true, 0.8],
|
|
80
|
+
["grok-4.6", "Grok 4.6", RESPONSES, "xai", 200000, 63356, E4, true, 0.8],
|
|
81
81
|
// reasoning is mandatory on GLM-5.3 and GLM-5.3-Flash (Fireworks turns
|
|
82
82
|
// none away): low is their least. GLM-5.2, Kimi K3 and DeepSeek V4.1
|
|
83
83
|
// Flash stop thinking at none, droid's "off" (yetone/magpie#899).
|
|
84
|
-
["glm-5.3", "GLM-5.3", CHAT, "fireworks", 1040000, 131072, ["low", "high", "max"], false],
|
|
85
|
-
["glm-5.3-flash", "GLM-5.3-Flash", CHAT, "fireworks", 1048576, 131072, ["low", "high", "max"], true],
|
|
86
|
-
["glm-5.2", "GLM-5.2", CHAT, "baseten", 1040000, 131072, ["none", "high", "max"], false],
|
|
87
|
-
["kimi-k3", "Kimi K3", CHAT, "fireworks", 262144, 65536, ["none", "low", "high", "max"], true],
|
|
88
|
-
["deepseek-v4.1-flash", "DeepSeek V4.1 Flash", CHAT, "fireworks", 1040000, 131072, ["none", "low", "high", "max"], true],
|
|
89
|
-
["qwen3.8-max", "Qwen3.8 Max", CHAT, "fireworks", 262144, 131072, ["low", "medium", "xhigh"], false],
|
|
90
|
-
["minimax-m3", "MiniMax M3", CHAT, "fireworks", 512000, 64000, ["high"], true],
|
|
91
|
-
["minimax-m2.7", "MiniMax M2.7", ANTHROPIC, "fireworks", 196600, 64000, ["high"], false],
|
|
92
|
-
["mistral-large-4", "Mistral Large 4", CHAT, "mistral", 524288, 64000, ["high"], true],
|
|
93
|
-
["mistral-medium-3.5", "Mistral Medium 3.5", CHAT, "mistral", 256000, 64000, ["high"], true],
|
|
94
|
-
["nemotron-3-ultra", "Nemotron 3 Ultra", CHAT, "baseten", 202000, 65536, ["high"], false],
|
|
95
|
-
["gemini-4-argon", "Gemini 4 Argon", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true],
|
|
96
|
-
["gemini-3.1-pro-preview", "Gemini 3.1 Pro", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true],
|
|
97
|
-
["gemini-3.8-flash", "Gemini 3.8 Flash", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true],
|
|
98
|
-
["gemini-3.7-flash", "Gemini 3.7 Flash", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true],
|
|
99
|
-
["gemini-3.6-flash", "Gemini 3.6 Flash", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true],
|
|
100
|
-
["gemini-3.5-flash", "Gemini 3.5 Flash", GEMINI, "google", 1000000, 65536, ["minimal", "low", "medium", "high"], true],
|
|
101
|
-
["gemini-3-flash-preview", "Gemini 3 Flash", GEMINI, "google", 1000000, 65536, ["minimal", "low", "medium", "high"], true],
|
|
84
|
+
["glm-5.3", "GLM-5.3", CHAT, "fireworks", 1040000, 131072, ["low", "high", "max"], false, 0.56],
|
|
85
|
+
["glm-5.3-flash", "GLM-5.3-Flash", CHAT, "fireworks", 1048576, 131072, ["low", "high", "max"], true, 0.06],
|
|
86
|
+
["glm-5.2", "GLM-5.2", CHAT, "baseten", 1040000, 131072, ["none", "high", "max"], false, 0.56],
|
|
87
|
+
["kimi-k3", "Kimi K3", CHAT, "fireworks", 262144, 65536, ["none", "low", "high", "max"], true, 1.2],
|
|
88
|
+
["deepseek-v4.1-flash", "DeepSeek V4.1 Flash", CHAT, "fireworks", 1040000, 131072, ["none", "low", "high", "max"], true, 0.12],
|
|
89
|
+
["qwen3.8-max", "Qwen3.8 Max", CHAT, "fireworks", 262144, 131072, ["low", "medium", "xhigh"], false, 0.8],
|
|
90
|
+
["minimax-m3", "MiniMax M3", CHAT, "fireworks", 512000, 64000, ["high"], true, 0.12],
|
|
91
|
+
["minimax-m2.7", "MiniMax M2.7", ANTHROPIC, "fireworks", 196600, 64000, ["high"], false, 0.12],
|
|
92
|
+
["mistral-large-4", "Mistral Large 4", CHAT, "mistral", 524288, 64000, ["high"], true, 0.544],
|
|
93
|
+
["mistral-medium-3.5", "Mistral Medium 3.5", CHAT, "mistral", 256000, 64000, ["high"], true, 0.6],
|
|
94
|
+
["nemotron-3-ultra", "Nemotron 3 Ultra", CHAT, "baseten", 202000, 65536, ["high"], false, 0.24],
|
|
95
|
+
["gemini-4-argon", "Gemini 4 Argon", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true, 1.6],
|
|
96
|
+
["gemini-3.1-pro-preview", "Gemini 3.1 Pro", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true, 0.8],
|
|
97
|
+
["gemini-3.8-flash", "Gemini 3.8 Flash", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true, 0.6],
|
|
98
|
+
["gemini-3.7-flash", "Gemini 3.7 Flash", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true, 0.6],
|
|
99
|
+
["gemini-3.6-flash", "Gemini 3.6 Flash", GEMINI, "google", 1000000, 65536, ["low", "medium", "high"], true, 0.6],
|
|
100
|
+
["gemini-3.5-flash", "Gemini 3.5 Flash", GEMINI, "google", 1000000, 65536, ["minimal", "low", "medium", "high"], true, 0.6],
|
|
101
|
+
["gemini-3-flash-preview", "Gemini 3 Flash", GEMINI, "google", 1000000, 65536, ["minimal", "low", "medium", "high"], true, 0.2],
|
|
102
102
|
// The Fast Mode models come last: magpie shows a provider with no models
|
|
103
103
|
// picked only the first 24 of its list, and placed beside their base
|
|
104
104
|
// models in 0.1.27 they pushed GPT-5.3-Codex, Grok 4.7, Grok 4.6, GLM-5.3
|
|
105
105
|
// and GLM-5.3-Flash out of it (#119, psylch). A Fast Mode model costs more credits, so it is the one
|
|
106
106
|
// to pick; asking its base model for fast reaches it all the same
|
|
107
107
|
// (fastBody).
|
|
108
|
-
["claude-opus-5-5-fast", "Opus 5.5 Fast Mode", ANTHROPIC, "anthropic", 872000, 128000, E5, true],
|
|
109
|
-
["claude-opus-5-fast", "Opus 5 Fast Mode", ANTHROPIC, "anthropic", 867000, 128000, E5, true],
|
|
110
|
-
["claude-opus-4-8-fast", "Opus 4.8 Fast Mode", ANTHROPIC, "anthropic", 867000, 128000, E5, true],
|
|
111
|
-
["gpt-5.5-fast", "GPT-5.5 Fast Mode", RESPONSES, "openai", 1050000, 128000, E4, true],
|
|
112
|
-
["gpt-5.4-fast", "GPT-5.4 Fast Mode", RESPONSES, "openai", 1050000, 128000, E4, true],
|
|
113
|
-
["gpt-5.3-codex-fast", "GPT-5.3-Codex Fast Mode", RESPONSES, "openai", 400000, 128000, E4, true],
|
|
114
|
-
].map(([id, name, wire, upstream, context, output, efforts, images]) => ({ id, name, wire, upstream, context, output, efforts, images }))
|
|
108
|
+
["claude-opus-5-5-fast", "Opus 5.5 Fast Mode", ANTHROPIC, "anthropic", 872000, 128000, E5, true, 3.2],
|
|
109
|
+
["claude-opus-5-fast", "Opus 5 Fast Mode", ANTHROPIC, "anthropic", 867000, 128000, E5, true, 4],
|
|
110
|
+
["claude-opus-4-8-fast", "Opus 4.8 Fast Mode", ANTHROPIC, "anthropic", 867000, 128000, E5, true, 4],
|
|
111
|
+
["gpt-5.5-fast", "GPT-5.5 Fast Mode", RESPONSES, "openai", 1050000, 128000, E4, true, 5],
|
|
112
|
+
["gpt-5.4-fast", "GPT-5.4 Fast Mode", RESPONSES, "openai", 1050000, 128000, E4, true, 2],
|
|
113
|
+
["gpt-5.3-codex-fast", "GPT-5.3-Codex Fast Mode", RESPONSES, "openai", 400000, 128000, E4, true, 1.4],
|
|
114
|
+
].map(([id, name, wire, upstream, context, output, efforts, images, rate]) => ({ id, name, wire, upstream, context, output, efforts, images, rate }))
|
|
115
115
|
|
|
116
116
|
const byId = new Map(MODELS.map((m) => [m.id, m]))
|
|
117
117
|
|
|
@@ -162,9 +162,35 @@ function variant(npm, effort) {
|
|
|
162
162
|
return { reasoningEffort: effort }
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
// Factory's running promotions, as droid's registry keeps them
|
|
166
|
+
// (cost.promotions): while one runs, a model's price is its token multiplier
|
|
167
|
+
// less the promotion's discount. magpie shows the price now with the price
|
|
168
|
+
// before it struck through (rateWas), as it does for WorkBuddy's credits and
|
|
169
|
+
// Qoder's price factors, so a cheap model is picked without opening droid. A
|
|
170
|
+
// promotion that has ended is no discount at all.
|
|
171
|
+
const PROMOTIONS = [
|
|
172
|
+
{ id: "gpt-5.6-sol", discount: 0.2, from: "2026-08-22T00:00:00Z", to: "2026-11-22T00:00:00Z" },
|
|
173
|
+
{ id: "mistral-large-4", discount: 0.5, from: "2026-10-06T00:00:00Z", to: "2026-10-20T00:00:00Z" },
|
|
174
|
+
{ id: "gemini-4-argon", discount: 0.5, from: "2026-10-13T16:00:00Z", to: "2026-12-01T08:00:00Z" },
|
|
175
|
+
{ id: "gemini-3.8-flash", discount: 0.5, from: "2026-08-17T21:10:19Z", to: "2027-01-01T08:00:00Z" },
|
|
176
|
+
{ id: "gemini-3.7-flash", discount: 0.5, from: "2026-08-17T21:10:19Z", to: "2027-01-01T08:00:00Z" },
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
// rateOf is a model's price as magpie keeps it: rate, the token multiplier a
|
|
180
|
+
// request costs now, and rateWas, the multiplier before a promotion running
|
|
181
|
+
// now (0: none). droid reads it the same way (ib(cost, now)): the first
|
|
182
|
+
// promotion that has started and not ended takes its discount off the
|
|
183
|
+
// multiplier.
|
|
184
|
+
function rateOf(m, now = Date.now()) {
|
|
185
|
+
const p = PROMOTIONS.find((p) => p.id === m.id && now >= Date.parse(p.from) && now < Date.parse(p.to))
|
|
186
|
+
if (!p) return { rate: m.rate, rateWas: 0 }
|
|
187
|
+
return { rate: Number((m.rate * (1 - p.discount)).toFixed(4)), rateWas: m.rate }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function configModels(now = Date.now()) {
|
|
166
191
|
const out = {}
|
|
167
192
|
for (const m of MODELS) {
|
|
193
|
+
const { rate, rateWas } = rateOf(m, now)
|
|
168
194
|
out[m.id] = {
|
|
169
195
|
id: m.id,
|
|
170
196
|
name: m.name,
|
|
@@ -177,12 +203,57 @@ function configModels() {
|
|
|
177
203
|
modalities: { input: m.images ? ["text", "image"] : ["text"], output: ["text"] },
|
|
178
204
|
cost: { input: 0, output: 0 },
|
|
179
205
|
limit: { context: m.context, output: m.output },
|
|
206
|
+
// magpie's own: the token multiplier a request costs now, and the
|
|
207
|
+
// multiplier before a promotion running now (0: none)
|
|
208
|
+
rate,
|
|
209
|
+
rateWas,
|
|
180
210
|
variants: Object.fromEntries(m.efforts.map((e) => [e, variant(m.wire.npm, e)])),
|
|
181
211
|
}
|
|
182
212
|
}
|
|
183
213
|
return out
|
|
184
214
|
}
|
|
185
215
|
|
|
216
|
+
// providerModel is a model as magpie's provider hook keeps it: the same model
|
|
217
|
+
// configModels gives OpenCode, in magpie's shape. magpie reads a provider's
|
|
218
|
+
// models from this hook, and a config hook's models without the price beside
|
|
219
|
+
// them, so the token multiplier droid shows a model by (rateOf) is carried
|
|
220
|
+
// here.
|
|
221
|
+
function providerModel(provider, m, now = Date.now()) {
|
|
222
|
+
const { rate, rateWas } = rateOf(m, now)
|
|
223
|
+
return {
|
|
224
|
+
id: m.id,
|
|
225
|
+
providerID: provider.id,
|
|
226
|
+
name: m.name,
|
|
227
|
+
api: { id: m.id, url: m.wire.api, npm: m.wire.npm },
|
|
228
|
+
status: "active",
|
|
229
|
+
headers: {},
|
|
230
|
+
options: {},
|
|
231
|
+
cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
|
|
232
|
+
limit: { context: m.context, output: m.output },
|
|
233
|
+
capabilities: {
|
|
234
|
+
temperature: true,
|
|
235
|
+
reasoning: m.efforts.length > 0,
|
|
236
|
+
attachment: m.images,
|
|
237
|
+
toolcall: true,
|
|
238
|
+
input: { text: true, image: m.images, audio: false, video: false, pdf: false },
|
|
239
|
+
output: { text: true, image: false, audio: false, video: false, pdf: false },
|
|
240
|
+
interleaved: false,
|
|
241
|
+
},
|
|
242
|
+
release_date: "",
|
|
243
|
+
variants: Object.fromEntries(m.efforts.map((e) => [e, variant(m.wire.npm, e)])),
|
|
244
|
+
free: false,
|
|
245
|
+
// magpie's own: the token multiplier a request costs now, and the
|
|
246
|
+
// multiplier before a promotion running now (0: none)
|
|
247
|
+
rate,
|
|
248
|
+
rateWas,
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// providerModels is the list the provider hook answers with, at now.
|
|
253
|
+
function providerModels(provider, now = Date.now()) {
|
|
254
|
+
return Object.fromEntries(MODELS.map((m) => [m.id, providerModel(provider, m, now)]))
|
|
255
|
+
}
|
|
256
|
+
|
|
186
257
|
// ---- tokens -----------------------------------------------------------------
|
|
187
258
|
|
|
188
259
|
class FactoryStatus extends Error {
|
|
@@ -882,11 +953,29 @@ const CLAUDE_IDENTITIES = new Set([
|
|
|
882
953
|
const ENV_REMINDER = /^<system-reminder>\n# Environment\nYou have been invoked in the following environment:[ \t]*\n(?: {1,2}- [^\n]*\n)+<\/system-reminder>$/
|
|
883
954
|
const MODEL_REMINDER = /^<system-reminder>\nYou are powered by the model (?:named )?[^\n<>]+\.\n<\/system-reminder>$/
|
|
884
955
|
const SKILL_REMINDER = /^<system-reminder>\nThe following skills are available for use with the Skill tool:\n\n(?:(?!<\/?system-reminder>)[\s\S])*\n<\/system-reminder>$/
|
|
885
|
-
// Factory also refuses this fixed self-reference in Claude Code
|
|
886
|
-
//
|
|
887
|
-
//
|
|
888
|
-
|
|
889
|
-
|
|
956
|
+
// Factory also refuses this fixed self-reference in Claude Code's built-in
|
|
957
|
+
// update-config description. Keep its instructions and the rest of the skill
|
|
958
|
+
// list intact; only that entry changes.
|
|
959
|
+
//
|
|
960
|
+
// Claude Code renders the entry two ways: as a system message ("- update-
|
|
961
|
+
// config: …") and, in the claude-code-guide agent's own system prompt under
|
|
962
|
+
// "# User's Current Configuration", with the slash that invokes it
|
|
963
|
+
// ("- /update-config: …"). Match the entry by its name in either spelling and
|
|
964
|
+
// change only the refused sentence in it, so a rewording of the rest of the
|
|
965
|
+
// description cannot defeat the match. The sentence is the built-in
|
|
966
|
+
// description's own text, so no other entry carries it by accident.
|
|
967
|
+
const CONFIG_SKILL_ENTRY = /^- \/?update-config: /
|
|
968
|
+
const CONFIG_SKILL_REFUSED = "the harness executes these, not Claude, so memory/preferences cannot fulfill them."
|
|
969
|
+
const CONFIG_SKILL_SAFE = CONFIG_SKILL_REFUSED.replace("not Claude", "not the assistant")
|
|
970
|
+
|
|
971
|
+
// configSkillText repairs that entry wherever the text carries a skill list.
|
|
972
|
+
function configSkillText(text) {
|
|
973
|
+
if (!text.includes(CONFIG_SKILL_REFUSED)) return text
|
|
974
|
+
return text
|
|
975
|
+
.split("\n")
|
|
976
|
+
.map((line) => (CONFIG_SKILL_ENTRY.test(line) ? line.replace(CONFIG_SKILL_REFUSED, CONFIG_SKILL_SAFE) : line))
|
|
977
|
+
.join("\n")
|
|
978
|
+
}
|
|
890
979
|
|
|
891
980
|
// Claude Code also sends the skill list alone as a system message: the
|
|
892
981
|
// entries only, no header, no <system-reminder> wrapper and no token tail,
|
|
@@ -894,7 +983,7 @@ const CONFIG_SKILL_COMPAT = CONFIG_SKILL_METADATA.replace("not Claude", "not the
|
|
|
894
983
|
// list (it opens with an entry) changes, and in it only the known line.
|
|
895
984
|
function bareSkills(text) {
|
|
896
985
|
if (!text.startsWith("- ")) return text
|
|
897
|
-
return (
|
|
986
|
+
return configSkillText(text)
|
|
898
987
|
}
|
|
899
988
|
|
|
900
989
|
// Claude 5 also sends its runtime metadata as a string-content system
|
|
@@ -947,7 +1036,7 @@ function announcedSkills(text) {
|
|
|
947
1036
|
const list = parts[i + 1]
|
|
948
1037
|
// Skill descriptions can contain continuation lines.
|
|
949
1038
|
if (!list.startsWith("- ")) continue
|
|
950
|
-
parts[i + 1] = (
|
|
1039
|
+
parts[i + 1] = configSkillText(list)
|
|
951
1040
|
}
|
|
952
1041
|
return parts.join("\n\n")
|
|
953
1042
|
}
|
|
@@ -998,7 +1087,7 @@ function announcedContext(text, start = 1) {
|
|
|
998
1087
|
} else if (SYSTEM_MODEL_UPDATE.test(part)) {
|
|
999
1088
|
parts[i] = systemModelLine(part)
|
|
1000
1089
|
} else if (parts[i - 1] === "The following skills are available for use with the Skill tool:") {
|
|
1001
|
-
parts[i] = (
|
|
1090
|
+
parts[i] = configSkillText(part)
|
|
1002
1091
|
}
|
|
1003
1092
|
}
|
|
1004
1093
|
return parts.join("\n\n")
|
|
@@ -1052,7 +1141,7 @@ function generatedContext(text) {
|
|
|
1052
1141
|
const skills = out.indexOf(skillHeader)
|
|
1053
1142
|
if (skills >= 0) {
|
|
1054
1143
|
const start = skills + skillHeader.length - 1
|
|
1055
|
-
out = out.slice(0, start) + out.slice(start)
|
|
1144
|
+
out = out.slice(0, start) + configSkillText(out.slice(start))
|
|
1056
1145
|
}
|
|
1057
1146
|
return out
|
|
1058
1147
|
}
|
|
@@ -1231,7 +1320,7 @@ function claudeIdentity(text) {
|
|
|
1231
1320
|
|
|
1232
1321
|
// promptText adapts a system prompt's text.
|
|
1233
1322
|
function promptText(text) {
|
|
1234
|
-
return clientOpening(systemModelLine(claudeIdentity(text)))
|
|
1323
|
+
return configSkillText(clientOpening(systemModelLine(claudeIdentity(text))))
|
|
1235
1324
|
}
|
|
1236
1325
|
|
|
1237
1326
|
// systemMessageText adapts a system message's text after the prompt.
|
|
@@ -1256,7 +1345,7 @@ function userBlockText(text) {
|
|
|
1256
1345
|
.replace("The exact model ID is", "Model ID:")
|
|
1257
1346
|
.replace("Assistant knowledge cutoff is", "Model knowledge cutoff:")
|
|
1258
1347
|
}
|
|
1259
|
-
if (SKILL_REMINDER.test(text)) return text
|
|
1348
|
+
if (SKILL_REMINDER.test(text)) return configSkillText(text)
|
|
1260
1349
|
return text
|
|
1261
1350
|
}
|
|
1262
1351
|
|
|
@@ -1621,6 +1710,15 @@ export const FactoryAuthPlugin = async ({ client }) => {
|
|
|
1621
1710
|
}
|
|
1622
1711
|
|
|
1623
1712
|
return {
|
|
1713
|
+
// magpie's list for this provider: the same models configModels gives
|
|
1714
|
+
// OpenCode, each with the token multiplier droid shows it by, which
|
|
1715
|
+
// magpie shows beside the model as its rate
|
|
1716
|
+
provider: {
|
|
1717
|
+
id: PROVIDER,
|
|
1718
|
+
async models(provider) {
|
|
1719
|
+
return providerModels(provider)
|
|
1720
|
+
},
|
|
1721
|
+
},
|
|
1624
1722
|
config: async (config) => {
|
|
1625
1723
|
config.provider ??= {}
|
|
1626
1724
|
const was = config.provider[PROVIDER] ?? {}
|
|
@@ -1786,4 +1884,4 @@ export const FactoryAuthPlugin = async ({ client }) => {
|
|
|
1786
1884
|
}
|
|
1787
1885
|
|
|
1788
1886
|
// for tests
|
|
1789
|
-
export const _internal = { fastBody, FAST_BETA, limitWindows, windowEnd, dollars, vendorError, CORE, droidBody, DROID_LINE, geminiBody, leaveOutAttachments, LEFT_OUT, TOO_LARGE_HINT }
|
|
1887
|
+
export const _internal = { fastBody, FAST_BETA, limitWindows, windowEnd, dollars, vendorError, CORE, droidBody, DROID_LINE, geminiBody, leaveOutAttachments, LEFT_OUT, TOO_LARGE_HINT, MODELS, PROMOTIONS, rateOf, configModels, providerModel, providerModels }
|