fix: 消除 8 个 as any — MCP 通知、结构化输出、流事件的类型安全修复 - #1
Merged
Conversation
…m events - Group A: Add : () => AnyObjectSchema type annotations to MCP notification schema constants (useIdeSelection, useIdeLogging, usePrompts, channelNotification) - Group B: Add isStructuredOutputAttachmentMessage type guard for structured output attachment payloads (execAgentHook) - Group C: Add isMessageDeltaStreamEvent type guard for message_delta stream event usage extraction (forkedAgent) These as any casts also exist in the upstream CCB source — this fix provides real type safety without changing any runtime behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
在 CCP (CC_Pure) 项目上跑
bunx tsc --noEmit时发现 94 处 as any 类型断言。经与上游 CCB 源码交叉验证,其中 8 处在上游同样存在 — 即 Anthropic 自己的闭源 CLI 代码里也是 as any。修复内容
A 组:MCP 通知 Schema 工厂 (4 处)
lazySchema<T>()返回的 schema 常量加: () => AnyObjectSchema类型标注B 组:结构化输出附件 (2 处)
isStructuredOutputAttachmentMessage()type guardC 组:子代理流事件 (3 处)
isMessageDeltaStreamEvent()type guard验证