( error: unknown, )
| 370 | } |
| 371 | |
| 372 | function undoLimitFromError( |
| 373 | error: unknown, |
| 374 | ): (UndoAvailability & { readonly requestedCount: number }) | undefined { |
| 375 | if (!isKimiError(error)) return undefined; |
| 376 | const details = error.details; |
| 377 | if (details?.['reason'] !== 'undo_limit') return undefined; |
| 378 | const requestedCount = details['requestedCount']; |
| 379 | const maxCount = details['undoableCount']; |
| 380 | const stoppedAtCompaction = details['stoppedAtCompaction']; |
| 381 | if ( |
| 382 | typeof requestedCount !== 'number' || |
| 383 | typeof maxCount !== 'number' || |
| 384 | typeof stoppedAtCompaction !== 'boolean' |
| 385 | ) { |
| 386 | return undefined; |
| 387 | } |
| 388 | return { requestedCount, maxCount, stoppedAtCompaction }; |
| 389 | } |
| 390 | |
| 391 | function isUndoAnchorEntry(entry: TranscriptEntry): boolean { |
| 392 | return ( |
no test coverage detected