thinkpool-pair 0.6.12 → 0.6.13
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/claude-session.mjs +8 -1
- package/package.json +1 -1
package/claude-session.mjs
CHANGED
|
@@ -92,6 +92,7 @@ export function startClaudeSession({ cwd, model, resume, onEvent, requestPermiss
|
|
|
92
92
|
// setPermissionMode) route through it once streaming.
|
|
93
93
|
let mode = 'default' // mirrors Claude Code's ⇧⇥ cycle
|
|
94
94
|
const alwaysAllow = new Set() // tool:risk signatures the user chose "don't ask again" for
|
|
95
|
+
const toolStart = new Map() // tool_use id → start time, for the duration badge
|
|
95
96
|
|
|
96
97
|
const emit = (evt) => { try { onEvent?.(evt) } catch { /* never let a consumer throw into the loop */ } }
|
|
97
98
|
|
|
@@ -193,13 +194,19 @@ export function startClaudeSession({ cwd, model, resume, onEvent, requestPermiss
|
|
|
193
194
|
emit({ kind: 'system', sessionId, model: m.model || model || null })
|
|
194
195
|
break
|
|
195
196
|
case 'assistant':
|
|
197
|
+
// Stamp tool-call start times so tool_result can report a duration.
|
|
198
|
+
for (const b of (m.message?.content || [])) {
|
|
199
|
+
if (b?.type === 'tool_use' && b.id) toolStart.set(b.id, Date.now())
|
|
200
|
+
}
|
|
196
201
|
emit({ kind: 'assistant', blocks: simplifyBlocks(m.message?.content) })
|
|
197
202
|
break
|
|
198
203
|
case 'user':
|
|
199
204
|
// tool_result blocks arrive on the user-role echo
|
|
200
205
|
for (const b of (m.message?.content || [])) {
|
|
201
206
|
if (b?.type === 'tool_result') {
|
|
202
|
-
|
|
207
|
+
const start = toolStart.get(b.tool_use_id)
|
|
208
|
+
if (start != null) toolStart.delete(b.tool_use_id)
|
|
209
|
+
emit({ kind: 'tool_result', toolUseId: b.tool_use_id, content: b.content, isError: !!b.is_error, durationMs: start != null ? Date.now() - start : undefined })
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
212
|
break
|