@magpie-community/opencode-kiro-auth 0.1.8 → 0.1.9

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 +2 -0
  2. package/index.mjs +11 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -76,6 +76,8 @@ request:
76
76
  - Tool ids Kiro wouldn't take are rewritten. A tool name over 64
77
77
  characters (an MCP plugin's, in Claude Code) is sent shortened with a
78
78
  hash and its calls come back under the full name.
79
+ - A tool's images (a screenshot, Codex's view_image) go with the
80
+ message that answers the call, as Kiro's tool results hold text alone.
79
81
  - Only the latest images are sent.
80
82
  - Tools the history used but the request doesn't offer are declared.
81
83
  - It turns the AWS event stream Kiro answers with back into Messages'
package/index.mjs CHANGED
@@ -614,6 +614,12 @@ function imageFormat(mediaType) {
614
614
  return f
615
615
  }
616
616
 
617
+ // addImage puts an Anthropic image block in images as Kiro takes it: the
618
+ // bytes inline. One named only by a URL has no bytes to send and is left out.
619
+ function addImage(images, p) {
620
+ if (p.source?.type === "base64" && p.source.data) images.push({ format: imageFormat(p.source.media_type), source: { bytes: p.source.data } })
621
+ }
622
+
617
623
  const textOf = (c) =>
618
624
  typeof c === "string" ? c : Array.isArray(c) ? c.filter((p) => p?.type === "text").map((p) => p.text ?? "").join("\n\n") : ""
619
625
  const joinNonEmpty = (a, b) => (a && b ? a + "\n\n" + b : a + b)
@@ -669,12 +675,14 @@ function buildKiro(req, model, profile, budget) {
669
675
  if (p?.type === "text") {
670
676
  if (p.text) texts.push(p.text)
671
677
  } else if (p?.type === "document") texts.push(documentText(p))
672
- else if (p?.type === "image") {
673
- if (p.source?.type === "base64" && p.source.data) u.images.push({ format: imageFormat(p.source.media_type), source: { bytes: p.source.data } })
674
- } else if (p?.type === "tool_result") {
678
+ else if (p?.type === "image") addImage(u.images, p)
679
+ else if (p?.type === "tool_result") {
675
680
  let out = textOf(p.content)
676
681
  if (out.length > RESULT_LIMIT) out = out.slice(0, RESULT_LIMIT) + "\n… (cut)"
677
682
  results.push({ toolUseId: toolID(p.tool_use_id), status: p.is_error ? "error" : "success", content: [{ text: out || "(no output)" }] })
683
+ // a tool's images (a screenshot, Codex's view_image) go with the
684
+ // message, as Kiro's tool results carry text alone (magpie #369, #1861)
685
+ if (Array.isArray(p.content)) for (const c of p.content) if (c?.type === "image") addImage(u.images, c)
678
686
  }
679
687
  }
680
688
  u.content = texts.join("\n\n")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-kiro-auth",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Kiro subscriptions (Free, Pro, Pro+, Power) in OpenCode and magpie",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",