@magpie-community/opencode-qoder-auth 0.2.72 → 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 +4 -0
  2. package/index.mjs +16 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -111,6 +111,10 @@ itself.
111
111
  agent, built on Anthropic's Claude Agent SDK.` (since 0.2.72): Qoder
112
112
  answers a prompt with that line with 400 `Cannot find model`, whatever
113
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.
114
118
  - Messages become text and image blocks.
115
119
  - Tool calls and results become OpenAI tool turns. Images a tool returned
116
120
  follow in a user turn.
package/index.mjs CHANGED
@@ -82,6 +82,20 @@ const CLAUDE_CODE_LINE = /You\s+are\s+Claude\s+Code,\s+Anthropic's\s+official\s+
82
82
  const AGENT_SDK_LINE = "You are a Claude agent, built on Anthropic's Claude Agent SDK."
83
83
  const asAgentSDK = (text) => text.replace(CLAUDE_CODE_LINE, AGENT_SDK_LINE)
84
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
+
85
99
  const hexID = () => randomUUID().replaceAll("-", "")
86
100
 
87
101
  // ---- the COSY envelope --------------------------------------------------------
@@ -1516,7 +1530,7 @@ function modelConfig(m, thinking) {
1516
1530
  // passes itself last.
1517
1531
  function qoderBody(chat, m, named = "", task, site) {
1518
1532
  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)
1533
+ const system = harnessComma(asAgentSDK(given))
1520
1534
  const tools = chat.tool_choice !== "none" ? (chat.tools ?? []).filter((t) => t?.type === "function" && t.function?.name) : []
1521
1535
  const baseSystem = site?.systemPrompt ?? QODER_SYS
1522
1536
  let sysText = system ? baseSystem + "\n\n" + system : baseSystem
@@ -4286,4 +4300,4 @@ export async function QwenWorkEnterpriseAuthPlugin({ client }) {
4286
4300
  export const protocol = { makePlugin, deviceSignIn, openapi, siteOf }
4287
4301
 
4288
4302
  // for tests
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 }
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.72",
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",