@@ -855,17 +855,17 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
855
855
const systemPrompt = await this . getSystemPrompt ( )
856
856
857
857
// Get condensing configuration
858
- // Using type assertion to handle the case where Phase 1 hasn't been implemented yet
859
858
const state = await this . providerRef . deref ( ) ?. getState ( )
860
- const customCondensingPrompt = state ? ( state as any ) . customCondensingPrompt : undefined
861
- const condensingApiConfigId = state ? ( state as any ) . condensingApiConfigId : undefined
862
- const listApiConfigMeta = state ? ( state as any ) . listApiConfigMeta : undefined
859
+ // These properties may not exist in the state type yet, but are used for condensing configuration
860
+ const customCondensingPrompt = state ?. customCondensingPrompt
861
+ const condensingApiConfigId = state ?. condensingApiConfigId
862
+ const listApiConfigMeta = state ?. listApiConfigMeta
863
863
864
864
// Determine API handler to use
865
865
let condensingApiHandler : ApiHandler | undefined
866
866
if ( condensingApiConfigId && listApiConfigMeta && Array . isArray ( listApiConfigMeta ) ) {
867
- // Using type assertion for the id property to avoid implicit any
868
- const matchingConfig = listApiConfigMeta . find ( ( config : any ) => config . id === condensingApiConfigId )
867
+ // Find matching config by ID
868
+ const matchingConfig = listApiConfigMeta . find ( ( config ) => config . id === condensingApiConfigId )
869
869
if ( matchingConfig ) {
870
870
const profile = await this . providerRef . deref ( ) ?. providerSettingsManager . getProfile ( {
871
871
id : condensingApiConfigId ,
@@ -988,7 +988,12 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
988
988
lastMessage . partial = false
989
989
lastMessage . progressStatus = progressStatus
990
990
if ( options . metadata ) {
991
- ; ( lastMessage as any ) . metadata = options . metadata
991
+ // Add metadata to the message
992
+ const messageWithMetadata = lastMessage as ClineMessage & ClineMessageWithMetadata
993
+ if ( ! messageWithMetadata . metadata ) {
994
+ messageWithMetadata . metadata = { }
995
+ }
996
+ Object . assign ( messageWithMetadata . metadata , options . metadata )
992
997
}
993
998
994
999
// Instead of streaming partialMessage events, we do a save
@@ -1137,13 +1142,14 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1137
1142
1138
1143
// Check for any stored GPT-5 response IDs in the message history
1139
1144
const gpt5Messages = modifiedClineMessages . filter (
1140
- ( m ) =>
1145
+ ( m ) : m is ClineMessage & ClineMessageWithMetadata =>
1141
1146
m . type === "say" &&
1142
1147
m . say === "text" &&
1143
- ( m as ClineMessageWithMetadata ) . metadata ?. gpt5 ?. previous_response_id ,
1148
+ ! ! ( m as ClineMessageWithMetadata ) . metadata ?. gpt5 ?. previous_response_id ,
1144
1149
)
1145
1150
if ( gpt5Messages . length > 0 ) {
1146
- const lastGpt5Message = gpt5Messages [ gpt5Messages . length - 1 ] as ClineMessage & ClineMessageWithMetadata
1151
+ const lastGpt5Message = gpt5Messages [ gpt5Messages . length - 1 ]
1152
+ // The lastGpt5Message contains the previous_response_id that can be used for continuity
1147
1153
}
1148
1154
1149
1155
// Remove any resume messages that may have been added before
@@ -1400,7 +1406,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1400
1406
if ( this . bridgeService ) {
1401
1407
this . bridgeService
1402
1408
. unsubscribeFromTask ( this . taskId )
1403
- . catch ( ( error ) => console . error ( "Error unsubscribing from task bridge:" , error ) )
1409
+ . catch ( ( error : unknown ) => console . error ( "Error unsubscribing from task bridge:" , error ) )
1404
1410
this . bridgeService = null
1405
1411
}
1406
1412
@@ -2266,8 +2272,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
2266
2272
let condensingApiHandler : ApiHandler | undefined
2267
2273
2268
2274
if ( condensingApiConfigId && listApiConfigMeta && Array . isArray ( listApiConfigMeta ) ) {
2269
- // Using type assertion for the id property to avoid implicit any.
2270
- const matchingConfig = listApiConfigMeta . find ( ( config : any ) => config . id === condensingApiConfigId )
2275
+ // Find matching config by ID
2276
+ const matchingConfig = listApiConfigMeta . find ( ( config ) => config . id === condensingApiConfigId )
2271
2277
2272
2278
if ( matchingConfig ) {
2273
2279
const profile = await this . providerRef . deref ( ) ?. providerSettingsManager . getProfile ( {
@@ -2391,7 +2397,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
2391
2397
// Find the last assistant message that has a previous_response_id stored
2392
2398
const idx = findLastIndex (
2393
2399
this . clineMessages ,
2394
- ( m ) =>
2400
+ ( m ) : m is ClineMessage & ClineMessageWithMetadata =>
2395
2401
m . type === "say" &&
2396
2402
m . say === "text" &&
2397
2403
! ! ( m as ClineMessageWithMetadata ) . metadata ?. gpt5 ?. previous_response_id ,
@@ -2575,7 +2581,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
2575
2581
const modelId = this . api . getModel ( ) . id
2576
2582
if ( ! modelId || ! modelId . startsWith ( "gpt-5" ) ) return
2577
2583
2578
- const lastResponseId : string | undefined = ( this . api as any ) ?. getLastResponseId ?.( )
2584
+ // Check if the API handler has a getLastResponseId method (OpenAiNativeHandler specific)
2585
+ const handler = this . api as ApiHandler & { getLastResponseId ?: ( ) => string | undefined }
2586
+ const lastResponseId = handler . getLastResponseId ?.( )
2579
2587
const idx = findLastIndex (
2580
2588
this . clineMessages ,
2581
2589
( m ) => m . type === "say" && m . say === "text" && m . partial !== true ,
0 commit comments