@@ -267,20 +267,20 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
267267 let accumulatedReasoning = ''
268268
269269 // 监听原生 thinking 事件(Extended Thinking)
270- stream . on ( 'thinking' , ( thinkingDelta ) => {
270+ ; ( stream as any ) . on ( 'thinking' , ( thinkingDelta : string ) => {
271271 accumulatedReasoning += thinkingDelta
272272 if ( callbacks . onReasoningToken ) {
273273 callbacks . onReasoningToken ( thinkingDelta )
274274 }
275275 } )
276276
277277 // 监听文本内容事件(同时支持 <think> 标签)
278- stream . on ( 'text' , ( text ) => {
278+ ; ( stream as any ) . on ( 'text' , ( text : string ) => {
279279 this . processStreamContentWithThinkTags ( text , callbacks , thinkState )
280280 } )
281281
282282 // 监听最终消息
283- stream . on ( 'message' , ( message ) => {
283+ ; ( stream as any ) . on ( 'message' , ( message : any ) => {
284284 const response : LLMResponse = {
285285 content : this . extractContent ( message ) ,
286286 reasoning : accumulatedReasoning || undefined ,
@@ -293,7 +293,7 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
293293 callbacks . onComplete ( response )
294294 } )
295295
296- stream . on ( 'error' , ( error ) => {
296+ ; ( stream as any ) . on ( 'error' , ( error : any ) => {
297297 callbacks . onError ( error )
298298 } )
299299
@@ -346,40 +346,40 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
346346 let currentToolCallIndex = - 1
347347
348348 // 监听原生 thinking 事件(Extended Thinking)
349- stream . on ( 'thinking' , ( thinkingDelta ) => {
349+ ; ( stream as any ) . on ( 'thinking' , ( thinkingDelta : string ) => {
350350 accumulatedReasoning += thinkingDelta
351351 if ( callbacks . onReasoningToken ) {
352352 callbacks . onReasoningToken ( thinkingDelta )
353353 }
354354 } )
355355
356356 // 监听内容块开始事件
357- stream . on ( 'contentBlockStart' , ( event ) => {
358- if ( event . content_block . type === 'tool_use' ) {
357+ ; ( stream as any ) . on ( 'contentBlockStart' , ( event : any ) => {
358+ if ( event . contentBlock ? .type === 'tool_use' ) {
359359 currentToolCallIndex ++
360360 toolCalls . push ( {
361- id : event . content_block . id ,
361+ id : event . contentBlock . id ,
362362 type : 'function' as const ,
363363 function : {
364- name : event . content_block . name ,
364+ name : event . contentBlock . name ,
365365 arguments : ''
366366 }
367367 } )
368368 }
369369 } )
370370
371371 // 监听内容块增量事件
372- stream . on ( 'contentBlockDelta' , ( event ) => {
373- if ( event . delta . type === 'text_delta' ) {
372+ ; ( stream as any ) . on ( 'contentBlockDelta' , ( event : any ) => {
373+ if ( event . delta ? .type === 'text_delta' ) {
374374 // 处理文本内容
375375 const text = event . delta . text || ''
376376 accumulatedContent += text
377377 this . processStreamContentWithThinkTags ( text , callbacks , thinkState )
378- } else if ( event . delta . type === 'input_json_delta' ) {
378+ } else if ( event . delta ? .type === 'input_json_delta' ) {
379379 // 处理工具调用参数增量
380380 if ( currentToolCallIndex >= 0 && toolCalls [ currentToolCallIndex ] ) {
381381 toolCalls [ currentToolCallIndex ] . function . arguments += event . delta . partial_json || ''
382-
382+
383383 // 尝试解析完整的 JSON,如果成功则触发回调
384384 try {
385385 JSON . parse ( toolCalls [ currentToolCallIndex ] . function . arguments )
@@ -394,7 +394,7 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
394394 } )
395395
396396 // 监听最终消息
397- stream . on ( 'message' , ( message ) => {
397+ ; ( stream as any ) . on ( 'message' , ( message : any ) => {
398398 const response : LLMResponse = {
399399 content : accumulatedContent ,
400400 reasoning : accumulatedReasoning || undefined ,
@@ -408,7 +408,7 @@ export class AnthropicAdapter extends AbstractTextProviderAdapter {
408408 callbacks . onComplete ( response )
409409 } )
410410
411- stream . on ( 'error' , ( error ) => {
411+ ; ( stream as any ) . on ( 'error' , ( error : any ) => {
412412 callbacks . onError ( error )
413413 } )
414414
0 commit comments