@bivy/bivy 0.16.24-staging.5 → 0.16.24-staging.6
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.
|
@@ -10,6 +10,31 @@ function compactValue(value, max = 200) {
|
|
|
10
10
|
s = String(s ?? "").replace(/\s+/g, " ").trim();
|
|
11
11
|
return s.length > max ? `${s.slice(0, Math.max(0, max - 1))}…` : s;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Summarise a tool_result's content for the portable transcript. A tool_result
|
|
15
|
+
* can carry `image` parts (a Playwright/screenshot MCP tool's output); those
|
|
16
|
+
* bytes don't round-trip across runtimes, and JSON-stringifying them here would
|
|
17
|
+
* spend the compaction budget on a truncated base64 blob that reads as noise.
|
|
18
|
+
* Keep the readable text and mark each image as `[image]` so the tool result is
|
|
19
|
+
* disclosed cleanly instead. A string result is returned as-is (compacted by the
|
|
20
|
+
* caller); an unknown shape falls back to `compactValue`.
|
|
21
|
+
*/
|
|
22
|
+
function summarizeToolResultContent(content) {
|
|
23
|
+
if (typeof content === "string")
|
|
24
|
+
return content;
|
|
25
|
+
if (!Array.isArray(content))
|
|
26
|
+
return compactValue(content);
|
|
27
|
+
const parts = [];
|
|
28
|
+
for (const raw of content) {
|
|
29
|
+
if (raw?.type === "text" && typeof raw.text === "string")
|
|
30
|
+
parts.push(raw.text);
|
|
31
|
+
else if (raw?.type === "image")
|
|
32
|
+
parts.push("[image]");
|
|
33
|
+
else
|
|
34
|
+
parts.push(compactValue(raw));
|
|
35
|
+
}
|
|
36
|
+
return parts.join(" ").trim();
|
|
37
|
+
}
|
|
13
38
|
/** Flatten one runtime message's content into text + tool annotations. */
|
|
14
39
|
function readContent(content) {
|
|
15
40
|
if (typeof content === "string") {
|
|
@@ -34,7 +59,7 @@ function readContent(content) {
|
|
|
34
59
|
}
|
|
35
60
|
else if (type === "tool_result") {
|
|
36
61
|
sawToolResult = true;
|
|
37
|
-
tools.push({ name: undefined, summary: `→ ${compactValue(raw.content)}` });
|
|
62
|
+
tools.push({ name: undefined, summary: `→ ${compactValue(summarizeToolResultContent(raw.content))}` });
|
|
38
63
|
}
|
|
39
64
|
else if (type === "image") {
|
|
40
65
|
// Image bytes don't round-trip across runtimes (each has its own store
|
package/package.json
CHANGED