feat: 完成第二版类型清理

This commit is contained in:
claude-code-best
2026-03-31 23:03:47 +08:00
parent 4c0a655a1c
commit d7a729ca68
604 changed files with 595 additions and 953 deletions

View File

@@ -24,7 +24,7 @@ export function extractInboundMessageFields(
| { content: string | Array<ContentBlockParam>; uuid: UUID | undefined }
| undefined {
if (msg.type !== 'user') return undefined
const content = msg.message?.content
const content = (msg.message as { content?: string | Array<ContentBlockParam> } | undefined)?.content
if (!content) return undefined
if (Array.isArray(content) && content.length === 0) return undefined

View File

@@ -284,7 +284,7 @@ export async function initReplBridge(
msg.isMeta ||
msg.toolUseResult ||
msg.isCompactSummary ||
(msg.origin && msg.origin.kind !== 'human') ||
(msg.origin && (msg.origin as { kind?: string }).kind !== 'human') ||
isSyntheticMessage(msg)
)
continue

View File

@@ -812,11 +812,11 @@ export async function initEnvLessBridgeCore(
},
writeSdkMessages(messages: SDKMessage[]) {
const filtered = messages.filter(
m => !m.uuid || !recentPostedUUIDs.has(m.uuid),
m => !m.uuid || !recentPostedUUIDs.has(m.uuid as string),
)
if (filtered.length === 0) return
for (const msg of filtered) {
if (msg.uuid) recentPostedUUIDs.add(msg.uuid)
if (msg.uuid) recentPostedUUIDs.add(msg.uuid as string)
}
const events = filtered.map(m => ({ ...m, session_id: sessionId }))
void transport.writeBatch(events)
@@ -829,7 +829,7 @@ export async function initEnvLessBridgeCore(
return
}
const event = { ...request, session_id: sessionId }
if (request.request.subtype === 'can_use_tool') {
if ((request as { request?: { subtype?: string } }).request?.subtype === 'can_use_tool') {
transport.reportState('requires_action')
}
void transport.write(event)

View File

@@ -1295,7 +1295,7 @@ export async function initBridgeCore(
if (previouslyFlushedUUIDs) {
for (const sdkMsg of sdkMessages) {
if (sdkMsg.uuid) {
previouslyFlushedUUIDs.add(sdkMsg.uuid)
previouslyFlushedUUIDs.add(sdkMsg.uuid as string)
}
}
}
@@ -1760,7 +1760,7 @@ export async function initBridgeCore(
// No initialMessageUUIDs filter — daemon has no initial messages.
// No flushGate — daemon never starts it (no initial flush).
const filtered = messages.filter(
m => !m.uuid || !recentPostedUUIDs.has(m.uuid),
m => !m.uuid || !recentPostedUUIDs.has(m.uuid as string),
)
if (filtered.length === 0) return
if (!transport) {
@@ -1771,7 +1771,7 @@ export async function initBridgeCore(
return
}
for (const msg of filtered) {
if (msg.uuid) recentPostedUUIDs.add(msg.uuid)
if (msg.uuid) recentPostedUUIDs.add(msg.uuid as string)
}
const events = filtered.map(m => ({ ...m, session_id: currentSessionId }))
void transport.writeBatch(events)