@@ -15,12 +15,30 @@ type KiloContentBlock = {
1515export type KiloRawRecord = {
1616 type ?: string ;
1717 role ?: string ;
18+ timestamp ?: number ;
1819 event ?: {
1920 type ?: string ;
2021 index ?: number ;
2122 content_block ?: Record < string , unknown > ;
2223 delta ?: Record < string , unknown > ;
2324 } ;
25+ part ?: {
26+ id ?: string ;
27+ sessionID ?: string ;
28+ messageID ?: string ;
29+ type ?: string ;
30+ callID ?: string ;
31+ tool ?: string ;
32+ state ?: {
33+ status ?: string ;
34+ input ?: Record < string , unknown > ;
35+ output ?: string ;
36+ title ?: string ;
37+ metadata ?: Record < string , unknown > ;
38+ } ;
39+ text ?: string ;
40+ reason ?: string ;
41+ } ;
2442 message ?: {
2543 content ?: KiloContentBlock [ ] ;
2644 } ;
@@ -139,6 +157,48 @@ export function applyKiloRecordToState(
139157 }
140158
141159 const role = typeof record . role === "string" ? record . role . trim ( ) . toLowerCase ( ) : "" ;
160+ const recordType = typeof record . type === "string" ? record . type . trim ( ) . toLowerCase ( ) : "" ;
161+
162+ if ( recordType === "text" ) {
163+ const text = typeof record . part ?. text === "string" ? record . part . text . trim ( ) : "" ;
164+ if ( text ) {
165+ state . currentText = text ;
166+ state . phaseStatus = "Drafting response" ;
167+ }
168+ return ;
169+ }
170+
171+ if ( recordType === "tool_use" ) {
172+ const toolName = record . part ?. tool || "tool" ;
173+ const toolId = record . part ?. callID || record . part ?. id || `kilo-tool-${ Date . now ( ) } ` ;
174+ const toolState = record . part ?. state || { } ;
175+ const status = typeof toolState . status === "string" ? toolState . status : "running" ;
176+ const tool : KiloInspectorToolState = {
177+ id : toolId ,
178+ name : toolName ,
179+ status : status === "completed" || status === "error" ? status : "running" ,
180+ input : toolState . input ,
181+ output : toolState . output ,
182+ title : toolState . title ,
183+ metadata : toolState . metadata ,
184+ } ;
185+ toolById . set ( toolId , tool ) ;
186+ updateTool ( state , tool ) ;
187+ state . phaseStatus = tool . title
188+ ? `${ tool . status === "completed" ? "Finished tool" : "Running tool" } : ${ tool . title } `
189+ : `${ tool . status === "completed" ? "Finished tool" : "Running tool" } : ${ toolName } ` ;
190+ return ;
191+ }
192+
193+ if ( recordType === "step_start" ) {
194+ state . phaseStatus = "Thinking" ;
195+ return ;
196+ }
197+
198+ if ( recordType === "step_finish" ) {
199+ state . phaseStatus = record . part ?. reason ? "Working" : "Finished step" ;
200+ return ;
201+ }
142202
143203 if ( record . type === "assistant" || role === "assistant" ) {
144204 const blocks = getContentBlocks ( record ) ;
0 commit comments