mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
feat: 完成第二版类型清理
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user