@@ -11,7 +11,7 @@ import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
1111
1212import * as EffectAcpAgent from "effect-acp/agent" ;
1313import * as AcpError from "effect-acp/errors" ;
14- import type * as AcpSchema from "effect-acp/schema" ;
14+ import * as AcpSchema from "effect-acp/schema" ;
1515import type * as AcpCompat from "effect-acp/compat" ;
1616
1717import { beginAcpMockPrompt } from "./acpMockCancellationState.ts" ;
@@ -36,6 +36,12 @@ const emitBackgroundToolDuringAnswer =
3636 process . env . T3_ACP_EMIT_BACKGROUND_TOOL_DURING_ANSWER === "1" ;
3737const emitMcpToolApprovalElicitation =
3838 process . env . T3_ACP_EMIT_MCP_TOOL_APPROVAL_ELICITATION === "1" ;
39+ const emitElicitation = process . env . T3_ACP_EMIT_ELICITATION === "1" ;
40+ const elicitationSchema = process . env . T3_ACP_ELICITATION_SCHEMA ;
41+ const decodeElicitationSchema = Schema . decodeUnknownSync (
42+ Schema . fromJsonString ( AcpSchema . ElicitationSchema ) ,
43+ ) ;
44+ const elicitationResponseLogPath = process . env . T3_ACP_ELICITATION_RESPONSE_LOG_PATH ;
3945const grokKillTaskShape = process . env . T3_ACP_GROK_KILL_TASK_SHAPE ;
4046const emitGrokBackgroundTaskPoll = process . env . T3_ACP_GROK_BACKGROUND_TASK_COMPLETION === "poll" ;
4147const emitForeignSessionUpdates = process . env . T3_ACP_EMIT_FOREIGN_SESSION_UPDATES === "1" ;
@@ -1541,21 +1547,25 @@ const program = Effect.gen(function* () {
15411547 return yield * finishPrompt ( requestedSessionId , "end_turn" ) ;
15421548 }
15431549
1544- if ( emitMcpToolApprovalElicitation ) {
1545- yield * agent . client . elicit ( {
1550+ if ( emitElicitation || emitMcpToolApprovalElicitation ) {
1551+ const response = yield * agent . client . elicit ( {
15461552 sessionId : requestedSessionId ,
15471553 message : "Approve this request?" ,
15481554 mode : "form" ,
1549- requestedSchema : {
1550- type : "object" ,
1551- properties : {
1552- approved : { type : "boolean" , title : "Approved" } ,
1553- } ,
1554- } ,
1555+ requestedSchema : elicitationSchema
1556+ ? decodeElicitationSchema ( elicitationSchema )
1557+ : {
1558+ type : "object" ,
1559+ properties : {
1560+ approved : { type : "boolean" , title : "Approved" } ,
1561+ } ,
1562+ } ,
15551563 ...( emitMcpToolApprovalElicitation
15561564 ? { _meta : { codex_approval_kind : "mcp_tool_call" } }
15571565 : { } ) ,
15581566 } ) ;
1567+ if ( elicitationResponseLogPath )
1568+ NodeFS . appendFileSync ( elicitationResponseLogPath , `${ encodeJson ( response ) } \n` , "utf8" ) ;
15591569 return yield * finishPrompt ( requestedSessionId , "end_turn" ) ;
15601570 }
15611571
0 commit comments