@magpie-community/opencode-qoder-auth 0.2.71 → 0.2.72
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 +5 -0
- package/index.mjs +14 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,6 +106,11 @@ itself.
|
|
|
106
106
|
|
|
107
107
|
- It writes the chat completion as Qoder's request:
|
|
108
108
|
- Qoder's own system line comes before yours.
|
|
109
|
+
- Claude Code's identity line, `You are Claude Code, Anthropic's official
|
|
110
|
+
CLI for Claude.`, goes as the Claude Agent SDK's, `You are a Claude
|
|
111
|
+
agent, built on Anthropic's Claude Agent SDK.` (since 0.2.72): Qoder
|
|
112
|
+
answers a prompt with that line with 400 `Cannot find model`, whatever
|
|
113
|
+
the model. The rest of the prompt and your messages go as written.
|
|
109
114
|
- Messages become text and image blocks.
|
|
110
115
|
- Tool calls and results become OpenAI tool turns. Images a tool returned
|
|
111
116
|
follow in a user turn.
|
package/index.mjs
CHANGED
|
@@ -71,6 +71,17 @@ XcW+ML9FoCI6AOvOzwIDAQAB
|
|
|
71
71
|
|
|
72
72
|
const QODER_SYS = "You are a Qoder agent. Use the instructions below and the tools available to you to assist the user."
|
|
73
73
|
|
|
74
|
+
// Qoder answers a system prompt that opens with Claude Code's identity
|
|
75
|
+
// line with 400 "Cannot find model", on any model; the same request with
|
|
76
|
+
// only that line swapped for the Claude Agent SDK's goes through (ByFanX
|
|
77
|
+
// on X, 11-24). asAgentSDK makes that swap, in what Qoder is sent only:
|
|
78
|
+
// the line is matched whatever its white space, and the rest of the
|
|
79
|
+
// prompt goes as written. Claude Code's SDK form (", running within the
|
|
80
|
+
// Claude Agent SDK.") is swapped the same way.
|
|
81
|
+
const CLAUDE_CODE_LINE = /You\s+are\s+Claude\s+Code,\s+Anthropic's\s+official\s+CLI\s+for\s+Claude(?:,\s+running\s+within\s+the\s+Claude\s+Agent\s+SDK)?\./g
|
|
82
|
+
const AGENT_SDK_LINE = "You are a Claude agent, built on Anthropic's Claude Agent SDK."
|
|
83
|
+
const asAgentSDK = (text) => text.replace(CLAUDE_CODE_LINE, AGENT_SDK_LINE)
|
|
84
|
+
|
|
74
85
|
const hexID = () => randomUUID().replaceAll("-", "")
|
|
75
86
|
|
|
76
87
|
// ---- the COSY envelope --------------------------------------------------------
|
|
@@ -1504,7 +1515,8 @@ function modelConfig(m, thinking) {
|
|
|
1504
1515
|
// none is given). A site on this protocol with its own values (QwenWork)
|
|
1505
1516
|
// passes itself last.
|
|
1506
1517
|
function qoderBody(chat, m, named = "", task, site) {
|
|
1507
|
-
const
|
|
1518
|
+
const given = (chat.messages ?? []).filter((x) => x.role === "system" || x.role === "developer").map((x) => textOf(x.content)).filter(Boolean).join("\n\n")
|
|
1519
|
+
const system = asAgentSDK(given)
|
|
1508
1520
|
const tools = chat.tool_choice !== "none" ? (chat.tools ?? []).filter((t) => t?.type === "function" && t.function?.name) : []
|
|
1509
1521
|
const baseSystem = site?.systemPrompt ?? QODER_SYS
|
|
1510
1522
|
let sysText = system ? baseSystem + "\n\n" + system : baseSystem
|
|
@@ -4274,4 +4286,4 @@ export async function QwenWorkEnterpriseAuthPlugin({ client }) {
|
|
|
4274
4286
|
export const protocol = { makePlugin, deviceSignIn, openapi, siteOf }
|
|
4275
4287
|
|
|
4276
4288
|
// for tests
|
|
4277
|
-
export const _internal = { spentOf, OUTPUT_CAPS, LEARNED_CAPS, outputCap, fetchListing, accountIdentity, deviceRefreshBody, qwenworkClientHeaders, freeView, maskPhone, phoneLabelOf, realEmailOf, chatHeaders, machineOS, machineHostname, cosyHeaders, typedUnions, Splitter, campaignRuntime, RUNTIMES, campaignPage, campaignTarget, vpcInstance, vpcSite, dedicatedOrigin, dedicatedHost, dedicatedSite, lingmaRoots, lingmaDecode, lingmaSite, lingmaHeaders, LINGMA_MODELS, parseUsage, gfmt, when, failure, modelInfo, qoderBody, qoderMessages, kimiModel, cacheMarked, sessionOf, namedSession, taskOf, TASKS, TASK_MAX, TASK_IDLE, SESSION, SITES, decodeBody, events, QUEUE, queueState }
|
|
4289
|
+
export const _internal = { spentOf, OUTPUT_CAPS, LEARNED_CAPS, outputCap, fetchListing, accountIdentity, deviceRefreshBody, qwenworkClientHeaders, freeView, maskPhone, phoneLabelOf, realEmailOf, chatHeaders, machineOS, machineHostname, cosyHeaders, typedUnions, Splitter, campaignRuntime, RUNTIMES, campaignPage, campaignTarget, vpcInstance, vpcSite, dedicatedOrigin, dedicatedHost, dedicatedSite, lingmaRoots, lingmaDecode, lingmaSite, lingmaHeaders, LINGMA_MODELS, parseUsage, gfmt, when, failure, modelInfo, qoderBody, asAgentSDK, qoderMessages, kimiModel, cacheMarked, sessionOf, namedSession, taskOf, TASKS, TASK_MAX, TASK_IDLE, SESSION, SITES, decodeBody, events, QUEUE, queueState }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-qoder-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.72",
|
|
4
4
|
"description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship, VPC and dedicated domains",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./opencode.mjs",
|