@magpie-community/opencode-workbuddy-auth 0.1.38 → 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 +6 -2
- package/index.mjs +32 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,8 +164,12 @@ refusal rests the account.
|
|
|
164
164
|
|
|
165
165
|
The loader also translates OpenAI-compatible request spellings WorkBuddy
|
|
166
166
|
doesn't take: `max_completion_tokens` becomes `max_tokens`, `developer`
|
|
167
|
-
messages become `system`,
|
|
168
|
-
string form
|
|
167
|
+
messages become `system`, an object `tool_choice` becomes WorkBuddy's
|
|
168
|
+
string form, and an earlier assistant turn's `reasoning_content` (or
|
|
169
|
+
`reasoning_details` text) goes as `reasoning`, the field WorkBuddy's own
|
|
170
|
+
client sends. WorkBuddy drops `reasoning_content`, so a client such as Grok
|
|
171
|
+
Build that sends it lost its earlier thinking; nothing is folded into the
|
|
172
|
+
message's content.
|
|
169
173
|
|
|
170
174
|
A chat's tools are given shapes WorkBuddy's models take. Without them
|
|
171
175
|
WorkBuddy AI answers 400 "Invalid request parameters" (11133), DeepSeek's
|
package/index.mjs
CHANGED
|
@@ -705,6 +705,36 @@ function unflag(messages) {
|
|
|
705
705
|
// OpenAI-compatible client normally uses max_completion_tokens and may call a
|
|
706
706
|
// reasoning prompt developer; WorkBuddy's endpoint takes max_tokens and
|
|
707
707
|
// system instead.
|
|
708
|
+
// An earlier turn's thinking goes back as `reasoning`, the field WorkBuddy's
|
|
709
|
+
// own client (CodeBuddy's agents converter) sets on an assistant message.
|
|
710
|
+
// WorkBuddy drops `reasoning_content`, which Grok Build, DeepSeek-style
|
|
711
|
+
// clients and magpie's own replies use: measured 2026-10-27 on
|
|
712
|
+
// www.workbuddy.ai, a codeword in reasoning_content reached none of
|
|
713
|
+
// kimi-k2.6, kimi-k3, glm-5.3, deepseek-v4.1-flash and minimax-m3, while
|
|
714
|
+
// the same words as `reasoning` reached kimi-k2.6 and minimax-m3.
|
|
715
|
+
// OpenRouter-style reasoning_details are read for their text the same way.
|
|
716
|
+
function reasoningOf(m) {
|
|
717
|
+
if (typeof m.reasoning_content === "string" && m.reasoning_content) return m.reasoning_content
|
|
718
|
+
if (Array.isArray(m.reasoning_details)) {
|
|
719
|
+
const text = m.reasoning_details.map((d) => (typeof d?.text === "string" ? d.text : typeof d?.summary === "string" ? d.summary : "")).join("")
|
|
720
|
+
if (text) return text
|
|
721
|
+
}
|
|
722
|
+
return ""
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function asReasoning(messages) {
|
|
726
|
+
let changed = false
|
|
727
|
+
for (const m of messages) {
|
|
728
|
+
if (m?.role !== "assistant" || (m.reasoning_content === undefined && m.reasoning_details === undefined)) continue
|
|
729
|
+
const text = reasoningOf(m)
|
|
730
|
+
if (text && !(typeof m.reasoning === "string" && m.reasoning)) m.reasoning = text
|
|
731
|
+
delete m.reasoning_content
|
|
732
|
+
delete m.reasoning_details
|
|
733
|
+
changed = true
|
|
734
|
+
}
|
|
735
|
+
return changed
|
|
736
|
+
}
|
|
737
|
+
|
|
708
738
|
function withSystem(body) {
|
|
709
739
|
// a body magpie or OpenCode hands over as bytes is read as the text it is
|
|
710
740
|
if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) body = new TextDecoder().decode(body)
|
|
@@ -723,6 +753,7 @@ function withSystem(body) {
|
|
|
723
753
|
m.role = "system"
|
|
724
754
|
changed = true
|
|
725
755
|
}
|
|
756
|
+
if (asReasoning(b.messages)) changed = true
|
|
726
757
|
if (b.messages[0]?.role !== "system") {
|
|
727
758
|
b.messages.unshift({ role: "system", content: "You are a helpful assistant." })
|
|
728
759
|
changed = true
|
|
@@ -2492,4 +2523,4 @@ export const WorkBuddyAuthPlugin = makePlugin(SITES.workbuddy)
|
|
|
2492
2523
|
export const WorkBuddyAIAuthPlugin = makePlugin(SITES["workbuddy-ai"])
|
|
2493
2524
|
|
|
2494
2525
|
// for tests
|
|
2495
|
-
export const _internal = { FREE_ONLY, PRICE_TTL, keyAccount, remoteConfig, cycleOf, typeUnions, systemAsUser, systemKey, DEFAULT_SYSTEM, EDGE_READS, fitShape, replyAfterTools, AFTER_TOOLS_REFUSED, enterpriseUsageOf, notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, normalizeToolChoice, fitTools, fitted, renamed, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, freeCredits, creditsOf, priceOf, fresh, SITES, renewing, renewed, SESSION, attend, turnKey, conversationKey, signatureOf, isMessages, withoutUnsigned, withoutSignedThinking, answeredBefore, nativeOf, modelOf, configModels, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM }
|
|
2526
|
+
export const _internal = { FREE_ONLY, PRICE_TTL, keyAccount, remoteConfig, cycleOf, typeUnions, systemAsUser, systemKey, DEFAULT_SYSTEM, EDGE_READS, fitShape, replyAfterTools, AFTER_TOOLS_REFUSED, enterpriseUsageOf, notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, asReasoning, normalizeToolChoice, fitTools, fitted, renamed, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, freeCredits, creditsOf, priceOf, fresh, SITES, renewing, renewed, SESSION, attend, turnKey, conversationKey, signatureOf, isMessages, withoutUnsigned, withoutSignedThinking, answeredBefore, nativeOf, modelOf, configModels, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-workbuddy-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.39",
|
|
4
4
|
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|