@mjasnikovs/pi-task 0.14.3 → 0.14.4
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.
- package/dist/remote/ui-script.js +21 -1
- package/package.json +1 -1
package/dist/remote/ui-script.js
CHANGED
|
@@ -313,13 +313,33 @@ export function clientScript(wsUrl) {
|
|
|
313
313
|
sendBtn.disabled = !allow;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
// Pull the human-readable text out of a tool result. Many tools (Read, Bash,
|
|
317
|
+
// MCP tools) return Anthropic content-block shapes — { content: [{type:'text',
|
|
318
|
+
// text:'...'}] } or a bare array of such blocks — which JSON.stringify would
|
|
319
|
+
// render as escaped, unreadable JSON. Extract the text blocks and join them;
|
|
320
|
+
// return null when there's nothing text-shaped so the caller falls back to JSON.
|
|
321
|
+
function contentBlocksText(result) {
|
|
322
|
+
const blocks = Array.isArray(result) ? result
|
|
323
|
+
: (result && Array.isArray(result.content)) ? result.content
|
|
324
|
+
: null;
|
|
325
|
+
if (!blocks) return null;
|
|
326
|
+
const parts = [];
|
|
327
|
+
for (const b of blocks) {
|
|
328
|
+
if (typeof b === 'string') parts.push(b);
|
|
329
|
+
else if (b && b.type === 'text' && typeof b.text === 'string') parts.push(b.text);
|
|
330
|
+
}
|
|
331
|
+
return parts.length ? parts.join('\\n') : null;
|
|
332
|
+
}
|
|
333
|
+
|
|
316
334
|
// Stringify a tool result safely. A null/undefined result (e.g. a tool that
|
|
317
335
|
// hasn't produced output) must NOT become the JS value undefined, whose
|
|
318
336
|
// .slice() throws — a throw here aborts the whole snapshot rebuild after the
|
|
319
337
|
// log was already cleared, blanking the transcript on reconnect.
|
|
320
338
|
function toolResultText(result) {
|
|
321
339
|
if (result == null) return '';
|
|
322
|
-
|
|
340
|
+
if (typeof result === 'string') return result.slice(0, 8000);
|
|
341
|
+
const text = contentBlocksText(result);
|
|
342
|
+
const r = text != null ? text : JSON.stringify(result, null, 2);
|
|
323
343
|
return (r == null ? '' : r).slice(0, 8000);
|
|
324
344
|
}
|
|
325
345
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mjasnikovs/pi-task",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "Deterministic spec-orchestration for local models, with a bundled real-time remote web view and web/docs/fetch/worker subagent tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|