@@ -34,13 +34,16 @@ import type {
3434 SkillsListResponse ,
3535 SandboxPolicy ,
3636 Thread ,
37+ ThreadGoal ,
3738 ThreadGoalStatus ,
3839 ThreadSourceKind ,
3940 TurnCompletedNotification ,
4041 UserInput ,
4142} from "./app-server/v2" ;
4243import packageJson from "../package.json" ;
4344import type { AuthenticationStatusResponse } from "./AcpExtensions" ;
45+ import { createCodexCollaborationMode } from "./CollaborationModeConfig" ;
46+ import type { ModeKind } from "./app-server/ModeKind" ;
4447
4548/**
4649 * Well-known provider id for the client-configurable custom LLM gateway.
@@ -85,7 +88,10 @@ export class CodexAcpClient {
8588
8689 async initialize ( request : acp . InitializeRequest ) : Promise < void > {
8790 await this . codexClient . initialize ( {
88- capabilities : null ,
91+ capabilities : {
92+ experimentalApi : true ,
93+ requestAttestation : false ,
94+ } ,
8995 clientInfo : {
9096 name : request . clientInfo ?. name ?? this . defaultClientInfo . name ,
9197 version : request . clientInfo ?. version ?? this . defaultClientInfo . version ,
@@ -331,6 +337,7 @@ export class CodexAcpClient {
331337 sessionId : request . sessionId ,
332338 currentModelId : currentModelId ,
333339 models : codexModels ,
340+ collaborationMode : this . getCollaborationMode ( response . thread . id ) ,
334341 modelProvider : response . modelProvider ,
335342 currentServiceTier : response . serviceTier as ServiceTier ?? null ,
336343 additionalDirectories,
@@ -358,6 +365,7 @@ export class CodexAcpClient {
358365 sessionId : request . sessionId ,
359366 currentModelId : currentModelId ,
360367 models : codexModels ,
368+ collaborationMode : this . getCollaborationMode ( response . thread . id ) ,
361369 modelProvider : response . modelProvider ,
362370 currentServiceTier : response . serviceTier as ServiceTier ?? null ,
363371 thread : historyResponse . thread ,
@@ -384,6 +392,7 @@ export class CodexAcpClient {
384392 sessionId : response . thread . id ,
385393 currentModelId : currentModelId ,
386394 models : codexModels ,
395+ collaborationMode : this . getCollaborationMode ( response . thread . id ) ,
387396 modelProvider : response . modelProvider ,
388397 currentServiceTier : response . serviceTier as ServiceTier ?? null ,
389398 additionalDirectories,
@@ -418,6 +427,11 @@ export class CodexAcpClient {
418427 await this . codexClient . runCompact ( { threadId : sessionId } ) ;
419428 }
420429
430+ async getGoal ( sessionId : string ) : Promise < ThreadGoal | null > {
431+ const response = await this . codexClient . threadGoalGet ( { threadId : sessionId } ) ;
432+ return response ?. goal ?? null ;
433+ }
434+
421435 async setGoal (
422436 sessionId : string ,
423437 objective : string ,
@@ -430,11 +444,18 @@ export class CodexAcpClient {
430444 } , onTurnStarted ) ;
431445 }
432446
433- async setGoalStatus ( sessionId : string , status : ThreadGoalStatus ) : Promise < void > {
447+ async setGoalStatus ( sessionId : string , status : ThreadGoalStatus ) : Promise < ThreadGoal > {
448+ let updatedGoal : ThreadGoal | null = null ;
434449 await this . codexClient . runGoalSet ( {
435450 threadId : sessionId ,
436451 status,
452+ } , undefined , undefined , ( goal ) => {
453+ updatedGoal = goal ;
437454 } ) ;
455+ if ( updatedGoal === null ) {
456+ throw new Error ( `Goal update for session ${ sessionId } returned no goal` ) ;
457+ }
458+ return updatedGoal ;
438459 }
439460
440461 async resumeGoal (
@@ -681,6 +702,17 @@ export class CodexAcpClient {
681702 } , onTurnStarted ) ;
682703 }
683704
705+ async setCollaborationMode ( sessionId : string , mode : ModeKind , currentModelId : string ) : Promise < void > {
706+ await this . codexClient . threadSettingsUpdate ( {
707+ threadId : sessionId ,
708+ collaborationMode : createCodexCollaborationMode ( mode , currentModelId ) ,
709+ } ) ;
710+ }
711+
712+ private getCollaborationMode ( sessionId : string ) : ModeKind {
713+ return this . codexClient . getThreadSettings ( sessionId ) ?. collaborationMode . mode ?? "default" ;
714+ }
715+
684716 resolveTurnInterrupted ( params : { threadId : string , turnId : string } ) : void {
685717 this . codexClient . resolveTurnInterrupted ( params . threadId , params . turnId ) ;
686718 }
@@ -863,6 +895,7 @@ export type SessionMetadata = {
863895 sessionId : string ,
864896 currentModelId : string ,
865897 models : Model [ ] ,
898+ collaborationMode : ModeKind ,
866899 modelProvider ?: string | null ,
867900 currentServiceTier ?: ServiceTier | null ,
868901 additionalDirectories : string [ ] ,
0 commit comments