@@ -10,12 +10,12 @@ import { ILogService } from '../../../../platform/log/common/logService';
1010import { IWorkspaceService } from '../../../../platform/workspace/common/workspaceService' ;
1111import { CancellationToken } from '../../../../util/vs/base/common/cancellation' ;
1212import { DisposableStore } from '../../../../util/vs/base/common/lifecycle' ;
13- import { ChatResponseThinkingProgressPart , ChatSessionStatus , EventEmitter , LanguageModelTextPart } from '../../../../vscodeTypes' ;
13+ import { ChatRequestTurn2 , ChatResponseThinkingProgressPart , ChatResponseTurn2 , ChatSessionStatus , EventEmitter , LanguageModelTextPart } from '../../../../vscodeTypes' ;
1414import { IToolsService } from '../../../tools/common/toolsService' ;
1515import { ExternalEditTracker } from '../../common/externalEditTracker' ;
1616import { getAffectedUrisForEditTool } from '../common/copilotcliTools' ;
1717import { ICopilotCLISDK } from './copilotCli' ;
18- import { processToolExecutionComplete , processToolExecutionStart } from './copilotcliToolInvocationFormatter' ;
18+ import { buildChatHistoryFromEvents , processToolExecutionComplete , processToolExecutionStart } from './copilotcliToolInvocationFormatter' ;
1919import { getCopilotLogger } from './logger' ;
2020import { getConfirmationToolParams , PermissionRequest } from './permissionHelpers' ;
2121
@@ -32,6 +32,14 @@ export class CopilotCLISession extends DisposableStore {
3232
3333 public readonly onDidChangeStatus = this . _statusChange . event ;
3434
35+ private _aborted ?: boolean ;
36+ public get aborted ( ) : boolean {
37+ return this . _aborted ?? false ;
38+ }
39+ private readonly _onDidAbort = this . add ( new EventEmitter < void > ( ) ) ;
40+
41+ public readonly onDidAbort = this . _onDidAbort . event ;
42+
3543 constructor (
3644 private readonly _sdkSession : Session ,
3745 @ILogService private readonly logService : ILogService ,
@@ -128,6 +136,28 @@ export class CopilotCLISession extends DisposableStore {
128136 }
129137 }
130138
139+ addUserMessage ( content : string ) {
140+ this . _sdkSession . addEvent ( { type : 'user.message' , data : { content } } ) ;
141+ }
142+
143+ addUserAssistantMessage ( content : string ) {
144+ this . _sdkSession . addEvent ( {
145+ type : 'assistant.message' , data : {
146+ messageId : `msg_${ Date . now ( ) } ` ,
147+ content
148+ }
149+ } ) ;
150+ }
151+
152+ public getSelectedModelId ( ) {
153+ return this . _sdkSession . getSelectedModel ( ) ;
154+ }
155+
156+ public async getChatHistory ( ) : Promise < ( ChatRequestTurn2 | ChatResponseTurn2 ) [ ] > {
157+ const events = await this . _sdkSession . getEvents ( ) ;
158+ return buildChatHistoryFromEvents ( events ) ;
159+ }
160+
131161 private _toolNames = new Map < string , string > ( ) ;
132162 private _processEvent (
133163 event : SessionEvent ,
0 commit comments