fix: complete immutable message migration
This commit is contained in:
@@ -439,9 +439,12 @@ export function unknownToolCallIds(rawLog: string): string[] {
|
||||
if (record.type !== 'tool/result') return []
|
||||
const data = record.data
|
||||
if (data === null || typeof data !== 'object') return []
|
||||
const { source, error } = data as { source?: unknown; error?: unknown }
|
||||
const { message, error } = data as { message?: unknown; error?: unknown }
|
||||
if (error === null || typeof error !== 'object') return []
|
||||
if ((error as { code?: unknown }).code !== 'UNKNOWN_TOOL') return []
|
||||
const source = typeof message === 'object' && message !== null
|
||||
? (message as { source?: unknown }).source
|
||||
: undefined
|
||||
const callId = typeof source === 'object' && source !== null
|
||||
? (source as { callId?: unknown }).callId
|
||||
: undefined
|
||||
|
||||
@@ -432,8 +432,8 @@ describe('tool-schema snapshots', () => {
|
||||
describe('unknownToolCallIds', () => {
|
||||
it('returns structured UNKNOWN_TOOL call ids and ignores other results', () => {
|
||||
const log = [
|
||||
'{"type":"tool/result","data":{"callId":"missing","error":{"code":"UNKNOWN_TOOL"}}}',
|
||||
'{"type":"tool/result","data":{"callId":"failed","error":{"code":"EXECUTION_FAILED"}}}',
|
||||
'{"type":"tool/result","data":{"message":{"source":{"kind":"tool","callId":"missing"}},"error":{"code":"UNKNOWN_TOOL"}}}',
|
||||
'{"type":"tool/result","data":{"message":{"source":{"kind":"tool","callId":"failed"}},"error":{"code":"EXECUTION_FAILED"}}}',
|
||||
'{"type":"tool/result","data":null}',
|
||||
'{"type":"tool/result","data":"invalid"}',
|
||||
'{"type":"tool/result","data":{"error":null}}',
|
||||
@@ -446,7 +446,7 @@ describe('unknownToolCallIds', () => {
|
||||
})
|
||||
|
||||
it('returns no failures for ordinary tool results', () => {
|
||||
expect(unknownToolCallIds('{"type":"tool/result","data":{"callId":"ok"}}\n')).toEqual([])
|
||||
expect(unknownToolCallIds('{"type":"tool/result","data":{"message":{"source":{"kind":"tool","callId":"ok"}}}}\n')).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user