@spexcode/transcript 0.7.0-next.6 → 0.7.0-next.7
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/parsers.js +27 -3
- package/package.json +1 -1
package/dist/parsers.js
CHANGED
|
@@ -50,6 +50,30 @@ const compact = (value) => {
|
|
|
50
50
|
return String(value);
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
// A RESULT IS WHAT THE TOOL SAID, NOT ITS WIRE SHAPE. Every harness that records a result as content blocks
|
|
54
|
+
// (Claude's tool_result content, Codex's input_text output blocks, MCP results everywhere) means the text of
|
|
55
|
+
// those blocks, with their line breaks; encoding the block list itself as JSON would show the reader escaped
|
|
56
|
+
// newlines inside a JSON shell. A block that is not text — an image, a reference — is named, not dumped.
|
|
57
|
+
const resultText = (value) => {
|
|
58
|
+
if (typeof value === 'string')
|
|
59
|
+
return value;
|
|
60
|
+
if (!Array.isArray(value))
|
|
61
|
+
return compact(value);
|
|
62
|
+
return value.map((blockValue) => {
|
|
63
|
+
const block = object(blockValue);
|
|
64
|
+
if (!block)
|
|
65
|
+
return compact(blockValue);
|
|
66
|
+
const text = string(block.text);
|
|
67
|
+
if (text !== null)
|
|
68
|
+
return text;
|
|
69
|
+
const type = string(block.type);
|
|
70
|
+
if (type === 'image')
|
|
71
|
+
return '[image]';
|
|
72
|
+
if (type)
|
|
73
|
+
return `[${type}]`;
|
|
74
|
+
return compact(blockValue);
|
|
75
|
+
}).join('\n');
|
|
76
|
+
};
|
|
53
77
|
const lineCount = (value) => value ? value.split(/\r?\n/).length : 0;
|
|
54
78
|
// --- the seven native shapes -------------------------------------------------------------------------------
|
|
55
79
|
export function claudeEvent(value) {
|
|
@@ -82,7 +106,7 @@ export function claudeEvent(value) {
|
|
|
82
106
|
const outputs = blocks.flatMap((block) => {
|
|
83
107
|
const b = object(block);
|
|
84
108
|
const id = string(b?.tool_use_id);
|
|
85
|
-
return b?.type === 'tool_result' && id ? [{ id, text:
|
|
109
|
+
return b?.type === 'tool_result' && id ? [{ id, text: resultText(b?.content ?? ''), ...(b?.is_error === true ? { outcome: 'failed' } : {}) }] : [];
|
|
86
110
|
});
|
|
87
111
|
if (outputs.length)
|
|
88
112
|
return { at: eventAt, turn: null, toolOutputs: outputs };
|
|
@@ -142,7 +166,7 @@ export function codexEvent(value) {
|
|
|
142
166
|
if (entry.type === 'response_item' && (type === 'custom_tool_call_output' || type === 'function_call_output')) {
|
|
143
167
|
const id = string(payload.call_id ?? payload.id);
|
|
144
168
|
const output = payload.output ?? payload.result ?? '';
|
|
145
|
-
return id ? { at: eventAt, turn: null, toolOutputs: [{ id, text:
|
|
169
|
+
return id ? { at: eventAt, turn: null, toolOutputs: [{ id, text: resultText(output) }] } : null;
|
|
146
170
|
}
|
|
147
171
|
return null;
|
|
148
172
|
}
|
|
@@ -211,7 +235,7 @@ export function codexAppServerEvent(value) {
|
|
|
211
235
|
if (output === undefined || output === null) {
|
|
212
236
|
return outcome ? { at: eventAt, turn: null, toolOutputs: [{ id, text: '', outcome }] } : { at: eventAt, turn: null };
|
|
213
237
|
}
|
|
214
|
-
return { at: eventAt, turn: null, toolOutputs: [{ id, text:
|
|
238
|
+
return { at: eventAt, turn: null, toolOutputs: [{ id, text: resultText(output), ...(outcome ? { outcome } : {}) }] };
|
|
215
239
|
}
|
|
216
240
|
// Agent-message deltas are fragments of one native item. The closure remembers only that item's text and
|
|
217
241
|
// re-emits its native id, allowing IntervalCollector to replace the earlier turn in place.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spexcode/transcript",
|
|
3
|
-
"version": "0.7.0-next.
|
|
3
|
+
"version": "0.7.0-next.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Normalized agent transcripts: one parser per harness, a bounded interval reader over a native thread file or an in-memory event stream, and the full/delta frame protocol every transport and renderer share.",
|
|
6
6
|
"files": [
|