This commit is contained in:
weishu
2026-03-20 13:19:10 +08:00
parent 32f05d99a0
commit a02f908dc5
3 changed files with 25 additions and 13 deletions
+19
View File
@@ -6,6 +6,13 @@ type RoleWrappedRecord = {
meta?: unknown
}
const VISIBLE_CLAUDE_SYSTEM_SUBTYPES = new Set([
'api_error',
'turn_duration',
'microcompact_boundary',
'compact_boundary'
])
export function isRoleWrappedRecord(value: unknown): value is RoleWrappedRecord {
if (!isObject(value)) return false
return typeof value.role === 'string' && 'content' in value
@@ -27,4 +34,16 @@ export function unwrapRoleWrappedRecordEnvelope(value: unknown): RoleWrappedReco
return null
}
export function isClaudeChatVisibleSystemSubtype(subtype: unknown): subtype is string {
return typeof subtype === 'string' && VISIBLE_CLAUDE_SYSTEM_SUBTYPES.has(subtype)
}
export function isClaudeChatVisibleMessage(message: { type: unknown; subtype?: unknown }): boolean {
if (message.type !== 'system') {
return true
}
return isClaudeChatVisibleSystemSubtype(message.subtype)
}
export type { RoleWrappedRecord }