@@ -785,17 +785,17 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
785
785
const systemPrompt = await this . getSystemPrompt ( )
786
786
787
787
// Get condensing configuration
788
- // Using type assertion to handle the case where Phase 1 hasn't been implemented yet
789
788
const state = await this . providerRef . deref ( ) ?. getState ( )
790
- const customCondensingPrompt = state ? ( state as any ) . customCondensingPrompt : undefined
791
- const condensingApiConfigId = state ? ( state as any ) . condensingApiConfigId : undefined
792
- const listApiConfigMeta = state ? ( state as any ) . listApiConfigMeta : undefined
789
+ // These properties may not exist in the state type yet, but are used for condensing configuration
790
+ const customCondensingPrompt = state ?. customCondensingPrompt
791
+ const condensingApiConfigId = state ?. condensingApiConfigId
792
+ const listApiConfigMeta = state ?. listApiConfigMeta
793
793
794
794
// Determine API handler to use
795
795
let condensingApiHandler : ApiHandler | undefined
796
796
if ( condensingApiConfigId && listApiConfigMeta && Array . isArray ( listApiConfigMeta ) ) {
797
- // Using type assertion for the id property to avoid implicit any
798
- const matchingConfig = listApiConfigMeta . find ( ( config : any ) => config . id === condensingApiConfigId )
797
+ // Find matching config by ID
798
+ const matchingConfig = listApiConfigMeta . find ( ( config ) => config . id === condensingApiConfigId )
799
799
if ( matchingConfig ) {
800
800
const profile = await this . providerRef . deref ( ) ?. providerSettingsManager . getProfile ( {
801
801
id : condensingApiConfigId ,
@@ -918,7 +918,12 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
918
918
lastMessage . partial = false
919
919
lastMessage . progressStatus = progressStatus
920
920
if ( options . metadata ) {
921
- ; ( lastMessage as any ) . metadata = options . metadata
921
+ // Add metadata to the message
922
+ const messageWithMetadata = lastMessage as ClineMessage & ClineMessageWithMetadata
923
+ if ( ! messageWithMetadata . metadata ) {
924
+ messageWithMetadata . metadata = { }
925
+ }
926
+ Object . assign ( messageWithMetadata . metadata , options . metadata )
922
927
}
923
928
924
929
// Instead of streaming partialMessage events, we do a save
@@ -1068,13 +1073,14 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1068
1073
1069
1074
// Check for any stored GPT-5 response IDs in the message history
1070
1075
const gpt5Messages = modifiedClineMessages . filter (
1071
- ( m ) =>
1076
+ ( m ) : m is ClineMessage & ClineMessageWithMetadata =>
1072
1077
m . type === "say" &&
1073
1078
m . say === "text" &&
1074
- ( m as ClineMessageWithMetadata ) . metadata ?. gpt5 ?. previous_response_id ,
1079
+ ! ! ( m as ClineMessageWithMetadata ) . metadata ?. gpt5 ?. previous_response_id ,
1075
1080
)
1076
1081
if ( gpt5Messages . length > 0 ) {
1077
- const lastGpt5Message = gpt5Messages [ gpt5Messages . length - 1 ] as ClineMessage & ClineMessageWithMetadata
1082
+ const lastGpt5Message = gpt5Messages [ gpt5Messages . length - 1 ]
1083
+ // The lastGpt5Message contains the previous_response_id that can be used for continuity
1078
1084
}
1079
1085
1080
1086
// Remove any resume messages that may have been added before
@@ -1324,7 +1330,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
1324
1330
if ( this . bridgeService ) {
1325
1331
this . bridgeService
1326
1332
. unsubscribeFromTask ( this . taskId )
1327
- . catch ( ( error ) => console . error ( "Error unsubscribing from task bridge:" , error ) )
1333
+ . catch ( ( error : unknown ) => console . error ( "Error unsubscribing from task bridge:" , error ) )
1328
1334
this . bridgeService = null
1329
1335
}
1330
1336
@@ -2016,8 +2022,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
2016
2022
let condensingApiHandler : ApiHandler | undefined
2017
2023
2018
2024
if ( condensingApiConfigId && listApiConfigMeta && Array . isArray ( listApiConfigMeta ) ) {
2019
- // Using type assertion for the id property to avoid implicit any.
2020
- const matchingConfig = listApiConfigMeta . find ( ( config : any ) => config . id === condensingApiConfigId )
2025
+ // Find matching config by ID
2026
+ const matchingConfig = listApiConfigMeta . find ( ( config ) => config . id === condensingApiConfigId )
2021
2027
2022
2028
if ( matchingConfig ) {
2023
2029
const profile = await this . providerRef . deref ( ) ?. providerSettingsManager . getProfile ( {
@@ -2141,7 +2147,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
2141
2147
// Find the last assistant message that has a previous_response_id stored
2142
2148
const idx = findLastIndex (
2143
2149
this . clineMessages ,
2144
- ( m ) =>
2150
+ ( m ) : m is ClineMessage & ClineMessageWithMetadata =>
2145
2151
m . type === "say" &&
2146
2152
m . say === "text" &&
2147
2153
! ! ( m as ClineMessageWithMetadata ) . metadata ?. gpt5 ?. previous_response_id ,
@@ -2325,7 +2331,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
2325
2331
const modelId = this . api . getModel ( ) . id
2326
2332
if ( ! modelId || ! modelId . startsWith ( "gpt-5" ) ) return
2327
2333
2328
- const lastResponseId : string | undefined = ( this . api as any ) ?. getLastResponseId ?.( )
2334
+ // Check if the API handler has a getLastResponseId method (OpenAiNativeHandler specific)
2335
+ const handler = this . api as ApiHandler & { getLastResponseId ?: ( ) => string | undefined }
2336
+ const lastResponseId = handler . getLastResponseId ?.( )
2329
2337
const idx = findLastIndex (
2330
2338
this . clineMessages ,
2331
2339
( m ) => m . type === "say" && m . say === "text" && m . partial !== true ,
0 commit comments