@magpie-community/opencode-factory-auth 0.1.16 → 0.1.18
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 +4 -1
- package/index.mjs +50 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,7 +67,10 @@ Each model is served on the one API droid uses for it:
|
|
|
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, Grok 4.7, Grok 4.6 |
|
|
68
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 Medium 3.5, Nemotron 3 Ultra |
|
|
69
69
|
|
|
70
|
-
Reasoning efforts are the variants droid offers for each model.
|
|
70
|
+
Reasoning efforts are the variants droid offers for each model. DeepSeek V4.1
|
|
71
|
+
Flash, Kimi K3 and GLM-5.2 have `none`, droid's "off": they stop thinking.
|
|
72
|
+
Reasoning is mandatory on GLM-5.3 and GLM-5.3-Flash (Fireworks turns `none`
|
|
73
|
+
away), so `low` is their least.
|
|
71
74
|
|
|
72
75
|
The list is not included:
|
|
73
76
|
|
package/index.mjs
CHANGED
|
@@ -58,11 +58,14 @@ const MODELS = [
|
|
|
58
58
|
["gpt-5.3-codex", "GPT-5.3-Codex", RESPONSES, "openai", 400000, 128000, E4, true],
|
|
59
59
|
["grok-4.7", "Grok 4.7", RESPONSES, "xai", 500000, 63356, E4, true],
|
|
60
60
|
["grok-4.6", "Grok 4.6", RESPONSES, "xai", 200000, 63356, E4, true],
|
|
61
|
+
// reasoning is mandatory on GLM-5.3 and GLM-5.3-Flash (Fireworks turns
|
|
62
|
+
// none away): low is their least. GLM-5.2, Kimi K3 and DeepSeek V4.1
|
|
63
|
+
// Flash stop thinking at none, droid's "off" (yetone/magpie#899).
|
|
61
64
|
["glm-5.3", "GLM-5.3", CHAT, "fireworks", 1040000, 131072, ["low", "high", "max"], false],
|
|
62
65
|
["glm-5.3-flash", "GLM-5.3-Flash", CHAT, "fireworks", 1048576, 131072, ["low", "high", "max"], true],
|
|
63
|
-
["glm-5.2", "GLM-5.2", CHAT, "baseten", 1040000, 131072, ["high", "max"], false],
|
|
64
|
-
["kimi-k3", "Kimi K3", CHAT, "fireworks", 262144, 65536, ["low", "high", "max"], true],
|
|
65
|
-
["deepseek-v4.1-flash", "DeepSeek V4.1 Flash", CHAT, "fireworks", 1040000, 131072, ["low", "high", "max"], true],
|
|
66
|
+
["glm-5.2", "GLM-5.2", CHAT, "baseten", 1040000, 131072, ["none", "high", "max"], false],
|
|
67
|
+
["kimi-k3", "Kimi K3", CHAT, "fireworks", 262144, 65536, ["none", "low", "high", "max"], true],
|
|
68
|
+
["deepseek-v4.1-flash", "DeepSeek V4.1 Flash", CHAT, "fireworks", 1040000, 131072, ["none", "low", "high", "max"], true],
|
|
66
69
|
["qwen3.8-max", "Qwen3.8 Max", CHAT, "fireworks", 262144, 131072, ["low", "medium", "xhigh"], false],
|
|
67
70
|
["minimax-m3", "MiniMax M3", CHAT, "fireworks", 512000, 64000, ["high"], true],
|
|
68
71
|
["minimax-m2.7", "MiniMax M2.7", ANTHROPIC, "fireworks", 196600, 64000, ["high"], false],
|
|
@@ -271,6 +274,39 @@ function explain(status, text) {
|
|
|
271
274
|
|
|
272
275
|
const DROID_LINE = "You are Droid, an AI software engineering agent built by Factory."
|
|
273
276
|
|
|
277
|
+
// pi (@earendil-works/pi-coding-agent 1.0.4) opens its system prompt with
|
|
278
|
+
// a sentence Factory refuses whole, on the OpenAI and Anthropic routes
|
|
279
|
+
// alike (yetone/magpie#952): either half of it passes, and pi's full
|
|
280
|
+
// request with the sentence cut to "You are an expert coding assistant."
|
|
281
|
+
// is answered. Only that sentence, at the start of a line of a system or
|
|
282
|
+
// developer prompt, changes; the rest of pi's prompt goes on as it is.
|
|
283
|
+
const PI_OPENING = /(^|\n)You are an expert coding assistant operating inside pi, a coding agent harness\./
|
|
284
|
+
const PI_COMPAT = "You are an expert coding assistant."
|
|
285
|
+
function clientOpening(text) {
|
|
286
|
+
return typeof text === "string" ? text.replace(PI_OPENING, (_, at) => at + PI_COMPAT) : text
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// promptOpenings adapts clientOpening in the system and developer messages
|
|
290
|
+
// of msgs (chat completions' messages, Responses' input), their string
|
|
291
|
+
// content or text parts: false when nothing changed.
|
|
292
|
+
function promptOpenings(msgs) {
|
|
293
|
+
let changed = false
|
|
294
|
+
for (const m of Array.isArray(msgs) ? msgs : []) {
|
|
295
|
+
if (!m || typeof m !== "object" || (m.role !== "system" && m.role !== "developer")) continue
|
|
296
|
+
if (typeof m.content === "string") {
|
|
297
|
+
const adapted = clientOpening(m.content)
|
|
298
|
+
if (adapted !== m.content) (m.content = adapted), (changed = true)
|
|
299
|
+
} else if (Array.isArray(m.content)) {
|
|
300
|
+
for (const p of m.content) {
|
|
301
|
+
if (!p || typeof p !== "object" || typeof p.text !== "string") continue
|
|
302
|
+
const adapted = clientOpening(p.text)
|
|
303
|
+
if (adapted !== p.text) (p.text = adapted), (changed = true)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return changed
|
|
308
|
+
}
|
|
309
|
+
|
|
274
310
|
// droidChat opens msgs' first system message with droid's line, or puts one
|
|
275
311
|
// before them with the line alone: false when it opens so already.
|
|
276
312
|
function droidChat(msgs) {
|
|
@@ -323,11 +359,15 @@ function droidBody(path, body) {
|
|
|
323
359
|
if (path.endsWith("/responses")) {
|
|
324
360
|
const v = m.instructions
|
|
325
361
|
if (v !== undefined && v !== null && typeof v !== "string") return body // not something droid sends
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
m.instructions = ins.trim() === "" ? DROID_LINE : DROID_LINE + "\n" + ins
|
|
362
|
+
const opened = promptOpenings(m.input)
|
|
363
|
+
const ins = clientOpening(v ?? "")
|
|
364
|
+
if (!ins.startsWith(DROID_LINE)) m.instructions = ins.trim() === "" ? DROID_LINE : DROID_LINE + "\n" + ins
|
|
365
|
+
else if (ins !== v || opened) m.instructions = ins
|
|
366
|
+
else return body
|
|
329
367
|
} else if (path.endsWith("/chat/completions")) {
|
|
330
|
-
if (!Array.isArray(m.messages)
|
|
368
|
+
if (!Array.isArray(m.messages)) return body
|
|
369
|
+
const opened = promptOpenings(m.messages)
|
|
370
|
+
if (!droidChat(m.messages) && !opened) return body
|
|
331
371
|
} else return body
|
|
332
372
|
return JSON.stringify(m)
|
|
333
373
|
}
|
|
@@ -708,7 +748,7 @@ function anthropicBody(body) {
|
|
|
708
748
|
block.text = DROID_LINE
|
|
709
749
|
changed = true
|
|
710
750
|
} else if (block?.type === "text") {
|
|
711
|
-
const adapted = systemModelLine(block.text)
|
|
751
|
+
const adapted = clientOpening(systemModelLine(block.text))
|
|
712
752
|
if (adapted !== block.text) {
|
|
713
753
|
block.text = adapted
|
|
714
754
|
changed = true
|
|
@@ -736,7 +776,7 @@ function anthropicBody(body) {
|
|
|
736
776
|
|
|
737
777
|
for (const message of request.messages) {
|
|
738
778
|
if (message?.role === "system" && typeof message.content === "string") {
|
|
739
|
-
const adapted = systemContext(message.content)
|
|
779
|
+
const adapted = clientOpening(systemContext(message.content))
|
|
740
780
|
if (adapted !== message.content) {
|
|
741
781
|
message.content = adapted
|
|
742
782
|
changed = true
|
|
@@ -749,7 +789,7 @@ function anthropicBody(body) {
|
|
|
749
789
|
if (message?.role === "system" && Array.isArray(message.content)) {
|
|
750
790
|
for (const block of message.content) {
|
|
751
791
|
if (block?.type !== "text" || typeof block.text !== "string") continue
|
|
752
|
-
const adapted = systemContext(block.text)
|
|
792
|
+
const adapted = clientOpening(systemContext(block.text))
|
|
753
793
|
if (adapted !== block.text) {
|
|
754
794
|
block.text = adapted
|
|
755
795
|
changed = true
|