@magpie-community/opencode-grok-auth 0.1.10 → 0.1.11

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 +18 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -66,6 +66,10 @@ leaves these out:
66
66
  - a `tool_choice` naming a dropped type
67
67
  - a reasoning item's `"content": null`
68
68
 
69
+ Plain Codex collaboration items (`agent_message`) reach Grok as user
70
+ messages, with their sender, recipient and content preserved. Sealed or
71
+ unrecognized content stays unchanged; the plugin does not decrypt tasks.
72
+
69
73
  ## Models
70
74
 
71
75
  Grok 4.7 until signed in. Signed in, the models are the ones the account
package/index.mjs CHANGED
@@ -288,7 +288,7 @@ const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v)
288
288
  // which Grok turns away otherwise: "tool parameter root must be an object
289
289
  // type" (magpie#1271).
290
290
  function rewrite(body) {
291
- if (typeof body !== "string" || (!body.includes('"tools"') && !body.includes('"reasoning"'))) return body
291
+ if (typeof body !== "string" || (!body.includes('"tools"') && !body.includes('"reasoning"') && !body.includes('"agent_message"'))) return body
292
292
  let m
293
293
  try {
294
294
  m = JSON.parse(body)
@@ -323,6 +323,23 @@ function rewrite(body) {
323
323
  dirty = true
324
324
  }
325
325
  }
326
+ if (Array.isArray(m.input)) {
327
+ m.input = m.input.map((it) => {
328
+ if (!isObj(it) || it.type !== "agent_message" || Object.hasOwn(it, "encrypted_content") ||
329
+ !Array.isArray(it.content) || !it.content.length ||
330
+ !it.content.every((part) => isObj(part) && !Object.hasOwn(part, "encrypted_content") &&
331
+ (part.type === "input_text" && typeof part.text === "string" ||
332
+ part.type === "input_image" && typeof part.image_url === "string"))) return it
333
+ // Grok takes ordinary messages, not Codex's collaboration item.
334
+ // Sealed tasks remain untouched for the gateway's existing guard.
335
+ const from = typeof it.author === "string" ? it.author : ""
336
+ const to = typeof it.recipient === "string" ? it.recipient : ""
337
+ const header = from && to ? `From ${from} to ${to}` : from ? `From ${from}` : to ? `To ${to}` : ""
338
+ dirty = true
339
+ return { type: "message", role: "user", content: header
340
+ ? [{ type: "input_text", text: `${header}\n\n` }, ...it.content] : it.content }
341
+ })
342
+ }
326
343
  for (const it of Array.isArray(m.input) ? m.input : []) {
327
344
  if (it && it.type === "reasoning" && "content" in it && it.content === null) {
328
345
  delete it.content
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-grok-auth",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
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",