@magpie-community/opencode-grok-auth 0.2.2 → 0.2.3

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 (2) hide show
  1. package/index.mjs +15 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -395,6 +395,10 @@ function foldRoot(root, ps, depth) {
395
395
  return out
396
396
  }
397
397
 
398
+ // what Codex asks an OpenAI provider for with output token replay on
399
+ // (codex-rs/core/src/client.rs)
400
+ const OUTPUT_REPLAY = "output.encrypted_content"
401
+
398
402
  const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v)
399
403
 
400
404
  // rewrite leaves out what Grok's backend doesn't take: tools of other
@@ -407,9 +411,13 @@ const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v)
407
411
  // encrypted reasoning. A function's parameters with a union at the root
408
412
  // (Codex desktop's codex_app automation_update) are folded to an object,
409
413
  // which Grok turns away otherwise: "tool parameter root must be an object
410
- // type" (magpie#1271).
414
+ // type" (magpie#1271). Codex's output token replay asks for each message's
415
+ // own sealed copy ("output.encrypted_content" in include), which Grok turns
416
+ // away: 'Argument not supported: "output.encrypted_content" in "include"
417
+ // field' (#524). Only that value goes; reasoning.encrypted_content and the
418
+ // tool-output values xAI documents stay.
411
419
  function rewrite(body, xSearch = false) {
412
- if (typeof body !== "string" || (!xSearch && !body.includes('"tools"') && !body.includes('"tool_choice"') && !body.includes('"reasoning"') && !body.includes('"agent_message"'))) return body
420
+ if (typeof body !== "string" || (!xSearch && !body.includes('"tools"') && !body.includes('"tool_choice"') && !body.includes('"reasoning"') && !body.includes('"agent_message"') && !body.includes(`"${OUTPUT_REPLAY}"`))) return body
413
421
  let m
414
422
  try {
415
423
  m = JSON.parse(body)
@@ -475,6 +483,11 @@ function rewrite(body, xSearch = false) {
475
483
  ? [{ type: "input_text", text: `${header}\n\n` }, ...it.content] : it.content }
476
484
  })
477
485
  }
486
+ if (Array.isArray(m.include) && m.include.includes(OUTPUT_REPLAY)) {
487
+ m.include = m.include.filter((v) => v !== OUTPUT_REPLAY)
488
+ if (!m.include.length) delete m.include
489
+ dirty = true
490
+ }
478
491
  for (const it of Array.isArray(m.input) ? m.input : []) {
479
492
  if (it && it.type === "reasoning" && "content" in it && it.content === null) {
480
493
  delete it.content
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-grok-auth",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "OpenCode provider plugin: Grok (SuperGrok / X Premium+) through the Grok Build CLI's sign-in",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",