@magpie-community/opencode-qoder-auth 0.2.71 → 0.2.73

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.
Files changed (3) hide show
  1. package/README.md +9 -0
  2. package/index.mjs +28 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -106,6 +106,15 @@ 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.
114
+ - A harness's opener, such as DeepSeek Harness's `You are an AI agent
115
+ powered by DeepSeek Harness.`, goes with a comma before `powered by`
116
+ (since 0.2.73, #1517): Qoder CN puts a request whose system prompt
117
+ holds that line, as written, in a queue that never moves.
109
118
  - Messages become text and image blocks.
110
119
  - Tool calls and results become OpenAI tool turns. Images a tool returned
111
120
  follow in a user turn.
package/index.mjs CHANGED
@@ -71,6 +71,31 @@ 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
+
85
+ // Qoder CN puts a request whose system prompt holds DeepSeek Harness's
86
+ // opener, "You are an AI agent powered by DeepSeek Harness.", in a queue
87
+ // that never moves: 10605, nothing ahead, keepalives until the agent gives
88
+ // up (#1517, #1220). The same request with that line one character shorter,
89
+ // or with no such line, is answered at once, every time (lirenQa1's bisect
90
+ // on #1220: the flip sits on exactly those 48 characters; tools, size,
91
+ // max_completion_tokens and the session header changed nothing). The match
92
+ // is the line whole, as WorkBuddy's on the same opener (its OPENERS), so a
93
+ // comma before "powered by" says the same thing and passes. harnessComma
94
+ // sets it in the system text Qoder is sent only; the user's own messages go
95
+ // as written.
96
+ const HARNESS_OPENER = /(\bYou are (?:an?|the)\s[^\n.,]{0,60}?\b(?:agent|assistant))\s+(powered by|running on|running in|built on|based on)\b/gi
97
+ const harnessComma = (text) => text.replace(HARNESS_OPENER, "$1, $2")
98
+
74
99
  const hexID = () => randomUUID().replaceAll("-", "")
75
100
 
76
101
  // ---- the COSY envelope --------------------------------------------------------
@@ -1504,7 +1529,8 @@ function modelConfig(m, thinking) {
1504
1529
  // none is given). A site on this protocol with its own values (QwenWork)
1505
1530
  // passes itself last.
1506
1531
  function qoderBody(chat, m, named = "", task, site) {
1507
- const system = (chat.messages ?? []).filter((x) => x.role === "system" || x.role === "developer").map((x) => textOf(x.content)).filter(Boolean).join("\n\n")
1532
+ const given = (chat.messages ?? []).filter((x) => x.role === "system" || x.role === "developer").map((x) => textOf(x.content)).filter(Boolean).join("\n\n")
1533
+ const system = harnessComma(asAgentSDK(given))
1508
1534
  const tools = chat.tool_choice !== "none" ? (chat.tools ?? []).filter((t) => t?.type === "function" && t.function?.name) : []
1509
1535
  const baseSystem = site?.systemPrompt ?? QODER_SYS
1510
1536
  let sysText = system ? baseSystem + "\n\n" + system : baseSystem
@@ -4274,4 +4300,4 @@ export async function QwenWorkEnterpriseAuthPlugin({ client }) {
4274
4300
  export const protocol = { makePlugin, deviceSignIn, openapi, siteOf }
4275
4301
 
4276
4302
  // 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 }
4303
+ 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, harnessComma, 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.71",
3
+ "version": "0.2.73",
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",