@@ -7,9 +7,15 @@ const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345"
77const SYNTHETIC_PART_ID = "prt_01234567890123456789012345"
88const SYNTHETIC_CALL_ID = "call_01234567890123456789012345"
99
10- const isGeminiModel = ( modelID : string ) : boolean => {
10+ export const isDeepSeekOrKimi = ( providerID : string , modelID : string ) : boolean => {
11+ const lowerProviderID = providerID . toLowerCase ( )
1112 const lowerModelID = modelID . toLowerCase ( )
12- return lowerModelID . includes ( "gemini" )
13+ return (
14+ lowerProviderID . includes ( "deepseek" ) ||
15+ lowerProviderID . includes ( "kimi" ) ||
16+ lowerModelID . includes ( "deepseek" ) ||
17+ lowerModelID . includes ( "kimi" )
18+ )
1319}
1420
1521export const createSyntheticUserMessage = (
@@ -50,54 +56,59 @@ export const createSyntheticAssistantMessage = (
5056 const userInfo = baseMessage . info as UserMessage
5157 const now = Date . now ( )
5258
53- const baseInfo = {
54- id : SYNTHETIC_MESSAGE_ID ,
55- sessionID : userInfo . sessionID ,
56- role : "assistant" as const ,
57- agent : userInfo . agent || "code" ,
58- parentID : userInfo . id ,
59- modelID : userInfo . model . modelID ,
60- providerID : userInfo . model . providerID ,
61- mode : "default" ,
62- path : {
63- cwd : "/" ,
64- root : "/" ,
65- } ,
66- time : { created : now , completed : now } ,
67- cost : 0 ,
68- tokens : { input : 0 , output : 0 , reasoning : 0 , cache : { read : 0 , write : 0 } } ,
69- ...( variant !== undefined && { variant } ) ,
70- }
71-
72- // For Gemini models, add thoughtSignature bypass to avoid validation errors
73- const toolPartMetadata = isGeminiModel ( userInfo . model . modelID )
74- ? { google : { thoughtSignature : "skip_thought_signature_validator" } }
75- : undefined
76-
7759 return {
78- info : baseInfo ,
60+ info : {
61+ id : SYNTHETIC_MESSAGE_ID ,
62+ sessionID : userInfo . sessionID ,
63+ role : "assistant" as const ,
64+ agent : userInfo . agent || "code" ,
65+ parentID : userInfo . id ,
66+ modelID : userInfo . model . modelID ,
67+ providerID : userInfo . model . providerID ,
68+ mode : "default" ,
69+ path : {
70+ cwd : "/" ,
71+ root : "/" ,
72+ } ,
73+ time : { created : now , completed : now } ,
74+ cost : 0 ,
75+ tokens : { input : 0 , output : 0 , reasoning : 0 , cache : { read : 0 , write : 0 } } ,
76+ ...( variant !== undefined && { variant } ) ,
77+ } ,
7978 parts : [
8079 {
8180 id : SYNTHETIC_PART_ID ,
8281 sessionID : userInfo . sessionID ,
8382 messageID : SYNTHETIC_MESSAGE_ID ,
84- type : "tool" ,
85- callID : SYNTHETIC_CALL_ID ,
86- tool : "context_info" ,
87- state : {
88- status : "completed" ,
89- input : { } ,
90- output : content ,
91- title : "Context Info" ,
92- metadata : { } ,
93- time : { start : now , end : now } ,
94- } ,
95- ...( toolPartMetadata && { metadata : toolPartMetadata } ) ,
83+ type : "text" ,
84+ text : content ,
9685 } ,
9786 ] ,
9887 }
9988}
10089
90+ export const createSyntheticToolPart = ( baseMessage : WithParts , content : string ) => {
91+ const userInfo = baseMessage . info as UserMessage
92+ const now = Date . now ( )
93+
94+ return {
95+ id : SYNTHETIC_PART_ID ,
96+ sessionID : userInfo . sessionID ,
97+ messageID : baseMessage . info . id ,
98+ type : "tool" as const ,
99+ callID : SYNTHETIC_CALL_ID ,
100+ tool : "context_info" ,
101+ state : {
102+ status : "completed" as const ,
103+ input : { } ,
104+ output : content ,
105+ title : "Context Info" ,
106+ metadata : { } ,
107+ time : { start : now , end : now } ,
108+ } ,
109+ }
110+ }
111+
101112/**
102113 * Extracts a human-readable key from tool metadata for display purposes.
103114 */
0 commit comments