Skip to content

Commit 110a273

Browse files
Aleksandr Slapoguzovslapoguzov
authored andcommitted
LLM-24245 pass command to rawInput
1 parent bee1529 commit 110a273

4 files changed

Lines changed: 75 additions & 1 deletion

File tree

src/CodexApprovalHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class CodexApprovalHandler implements ApprovalHandler {
6868
kind: "execute",
6969
status: "pending",
7070
content: reasonContent ? [reasonContent] : null,
71+
rawInput: params.command ? { command: params.command, cwd: params.cwd } : null,
7172
},
7273
options: APPROVAL_OPTIONS,
7374
};

src/__tests__/CodexACPAgent/approval-events.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,35 @@ describe('Approval Events', () => {
150150
completeTurn();
151151
await promptPromise;
152152
});
153+
154+
it('should include rawInput with command and cwd', async () => {
155+
const { promptPromise, completeTurn } = setupSessionWithPendingPrompt();
156+
fixture.setPermissionResponse({
157+
outcome: { outcome: 'selected', optionId: 'allow_once' }
158+
});
159+
160+
const params: CommandExecutionRequestApprovalParams = {
161+
threadId: sessionId,
162+
turnId: 'turn-1',
163+
itemId: 'item-with-command',
164+
reason: 'Installing dependencies',
165+
command: 'npm install',
166+
cwd: '/home/user/project',
167+
proposedExecpolicyAmendment: null,
168+
};
169+
170+
await fixture.sendServerRequest(
171+
'item/commandExecution/requestApproval',
172+
params
173+
);
174+
175+
await expect(fixture.getAcpConnectionDump(['_meta'])).toMatchFileSnapshot(
176+
'data/approval-command-with-rawInput.json'
177+
);
178+
179+
completeTurn();
180+
await promptPromise;
181+
});
153182
});
154183

155184
describe('File change approval', () => {

src/__tests__/CodexACPAgent/data/approval-command-allow-once.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"text": "Running npm install"
1616
}
1717
}
18-
]
18+
],
19+
"rawInput": null
1920
},
2021
"options": [
2122
{
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"method": "requestPermission",
3+
"args": [
4+
{
5+
"sessionId": "test-session-id",
6+
"toolCall": {
7+
"toolCallId": "item-with-command",
8+
"kind": "execute",
9+
"status": "pending",
10+
"content": [
11+
{
12+
"type": "content",
13+
"content": {
14+
"type": "text",
15+
"text": "Installing dependencies"
16+
}
17+
}
18+
],
19+
"rawInput": {
20+
"command": "npm install",
21+
"cwd": "/home/user/project"
22+
}
23+
},
24+
"options": [
25+
{
26+
"optionId": "allow_once",
27+
"name": "Allow Once",
28+
"kind": "allow_once"
29+
},
30+
{
31+
"optionId": "allow_always",
32+
"name": "Allow for Session",
33+
"kind": "allow_always"
34+
},
35+
{
36+
"optionId": "reject_once",
37+
"name": "Reject",
38+
"kind": "reject_once"
39+
}
40+
]
41+
}
42+
]
43+
}

0 commit comments

Comments
 (0)