@@ -126,6 +126,8 @@ import {
126126 AGENTCAST_MCP_SERVER ,
127127 agentcastCodexApprovals ,
128128 agentcastStdioServer ,
129+ resolveAgentcastLauncher ,
130+ type AgentcastLauncher ,
129131} from "../../provider/agentcastMcp.ts" ;
130132import {
131133 MCP_APP_EXTENSION_ID ,
@@ -1328,8 +1330,9 @@ const CODEX_T3_MCP_TOOL_TIMEOUT_SEC = 65 * 60;
13281330function codexAgentcastConfig (
13291331 threadId : string ,
13301332 runtimePolicy : ProviderAdapter . ProviderAdapterV2RuntimePolicy | undefined ,
1333+ launcher : AgentcastLauncher | undefined ,
13311334) : Record < string , Schema . Json > {
1332- const agentcast = agentcastStdioServer ( threadId ) ;
1335+ const agentcast = agentcastStdioServer ( threadId , launcher ) ;
13331336 if ( agentcast === undefined ) return { } ;
13341337 return {
13351338 [ `mcp_servers.${ AGENTCAST_MCP_SERVER } ` ] : {
@@ -1350,15 +1353,17 @@ function codexAgentcastConfig(
13501353function codexAgentcastApprovalsKey (
13511354 mcpSession : McpProviderSession . McpProviderSessionConfig | undefined ,
13521355 runtimePolicy : ProviderAdapter . ProviderAdapterV2RuntimePolicy | undefined ,
1356+ launcher : AgentcastLauncher | undefined ,
13531357) : string | undefined {
1354- if ( mcpSession === undefined || agentcastStdioServer ( mcpSession . threadId ) === undefined ) {
1358+ if ( mcpSession === undefined || launcher === undefined ) {
13551359 return undefined ;
13561360 }
13571361 return JSON . stringify ( agentcastCodexApprovals ( runtimePolicy ) ) ;
13581362}
13591363
13601364function codexThreadRuntimeParams ( input : {
13611365 readonly mcpSession : McpProviderSession . McpProviderSessionConfig | undefined ;
1366+ readonly agentcast : AgentcastLauncher | undefined ;
13621367 readonly modelSelection ?: { readonly model : string } ;
13631368 readonly runtimePolicy ?: ProviderAdapter . ProviderAdapterV2RuntimePolicy ;
13641369} ) : {
@@ -1383,7 +1388,7 @@ function codexThreadRuntimeParams(input: {
13831388 Authorization : mcpSession . authorizationHeader ,
13841389 } ,
13851390 } ,
1386- ...codexAgentcastConfig ( mcpSession . threadId , input . runtimePolicy ) ,
1391+ ...codexAgentcastConfig ( mcpSession . threadId , input . runtimePolicy , input . agentcast ) ,
13871392 } ) ,
13881393 } ,
13891394 } ;
@@ -1663,6 +1668,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
16631668 threadId === null ? Effect . succeed ( undefined ) : mcpSessions . read ( threadId ) ;
16641669 const { clientFactory, crypto, fileSystem, idAllocator, serverConfig } = adapterOptions ;
16651670 const continuationRequests = adapterOptions . continuationRequests ;
1671+ const agentcastLauncher = yield * resolveAgentcastLauncher ( ) ;
16661672
16671673 return ProviderAdapter . ProviderAdapterV2 . of ( {
16681674 instanceId : adapterOptions . instanceId ,
@@ -1871,7 +1877,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
18711877 mcpSession : McpProviderSession . McpProviderSessionConfig | undefined ,
18721878 runtimePolicy : ProviderAdapter . ProviderAdapterV2RuntimePolicy | undefined ,
18731879 ) => {
1874- const key = codexAgentcastApprovalsKey ( mcpSession , runtimePolicy ) ;
1880+ const key = codexAgentcastApprovalsKey ( mcpSession , runtimePolicy , agentcastLauncher ) ;
18751881 if ( key === undefined ) agentcastApprovalsByThread . delete ( nativeThreadId ) ;
18761882 else agentcastApprovalsByThread . set ( nativeThreadId , key ) ;
18771883 } ;
@@ -6682,7 +6688,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
66826688 mcpSession : McpProviderSession . McpProviderSessionConfig | undefined ,
66836689 runtimePolicy : ProviderAdapter . ProviderAdapterV2RuntimePolicy | undefined ,
66846690 ) {
6685- const wanted = codexAgentcastApprovalsKey ( mcpSession , runtimePolicy ) ;
6691+ const wanted = codexAgentcastApprovalsKey ( mcpSession , runtimePolicy , agentcastLauncher ) ;
66866692 if ( wanted === undefined || agentcastApprovalsByThread . get ( nativeThreadId ) === wanted ) {
66876693 return false ;
66886694 }
@@ -6708,6 +6714,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
67086714 threadId,
67096715 excludeTurns : true ,
67106716 ...codexThreadRuntimeParams ( {
6717+ agentcast : agentcastLauncher ,
67116718 mcpSession,
67126719 modelSelection : turnInput . modelSelection ,
67136720 runtimePolicy : turnInput . runtimePolicy ,
@@ -7031,6 +7038,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
70317038 . request (
70327039 "thread/start" ,
70337040 codexThreadRuntimeParams ( {
7041+ agentcast : agentcastLauncher ,
70347042 mcpSession,
70357043 modelSelection : threadInput . modelSelection ,
70367044 runtimePolicy : threadInput . runtimePolicy ,
@@ -7088,6 +7096,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
70887096 threadId : nativeThreadId ,
70897097 excludeTurns : true ,
70907098 ...codexThreadRuntimeParams ( {
7099+ agentcast : agentcastLauncher ,
70917100 mcpSession,
70927101 ...( threadInput . modelSelection === undefined
70937102 ? { }
@@ -7877,6 +7886,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
78777886 threadId,
78787887 excludeTurns : true ,
78797888 ...codexThreadRuntimeParams ( {
7889+ agentcast : agentcastLauncher ,
78807890 mcpSession,
78817891 modelSelection : input . modelSelection ,
78827892 runtimePolicy : input . runtimePolicy ,
@@ -7931,6 +7941,7 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
79317941 ? { }
79327942 : { lastTurnId : boundary . lastTurnId } ) ,
79337943 ...codexThreadRuntimeParams ( {
7944+ agentcast : agentcastLauncher ,
79347945 mcpSession,
79357946 ...( threadInput . modelSelection === undefined
79367947 ? { }
0 commit comments