Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions src/CodexApprovalHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,13 @@ export class CodexApprovalHandler implements ApprovalHandler {
params: CommandExecutionRequestApprovalParams
): acp.RequestPermissionRequest {
const options = this.buildCommandOptions(params).map(({ option }) => option);
const content = this.createContent([
params.reason ?? null,
this.formatNetworkApprovalContext(params),
this.formatExecpolicyAmendment(params),
this.formatNetworkPolicyAmendments(params),
]);
return {
sessionId,
toolCall: {
toolCallId: params.itemId,
kind: "execute",
status: "pending",
rawInput: params.command ? { command: stripShellPrefix(params.command), cwd: params.cwd } : null,
...(content ? { content } : {}),
},
options,
_meta: { codex: { params } }
Expand All @@ -126,17 +119,12 @@ export class CodexApprovalHandler implements ApprovalHandler {
params: FileChangeRequestApprovalParams
): acp.RequestPermissionRequest {
const options = this.buildFileChangeOptions(params).map(({ option }) => option);
const content = this.createContent([
params.reason ?? null,
params.grantRoot ? `Grant Root: ${params.grantRoot}` : null,
]);
return {
sessionId,
toolCall: {
toolCallId: params.itemId,
kind: "edit",
status: "pending",
...(content ? { content } : {}),
},
options,
_meta: { codex: { params } }
Expand Down Expand Up @@ -363,26 +351,6 @@ export class CodexApprovalHandler implements ApprovalHandler {
: `Block ${amendment.host} in the Future`;
}

private formatNetworkApprovalContext(params: CommandExecutionRequestApprovalParams): string | null {
const context = params.networkApprovalContext;
if (!context) return null;
return `Network Approval Context: ${context.protocol} ${context.host}`;
}

private formatExecpolicyAmendment(params: CommandExecutionRequestApprovalParams): string | null {
const amendment = params.proposedExecpolicyAmendment;
if (!amendment || amendment.length === 0) return null;
return `Proposed Command Pattern: ${amendment.join(" ")}`;
}

private formatNetworkPolicyAmendments(params: CommandExecutionRequestApprovalParams): string | null {
const amendments = params.proposedNetworkPolicyAmendments;
if (!amendments || amendments.length === 0) return null;
return `Proposed Network Policy Amendments: ${amendments
.map((amendment) => `${amendment.action} ${amendment.host}`)
.join(", ")}`;
}

private formatRequestedPermissions(permissions: RequestPermissionProfile): string | null {
const content: string[] = [];
if (permissions.network?.enabled !== undefined && permissions.network.enabled !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@
"toolCallId": "item-snapshot",
"kind": "execute",
"status": "pending",
"rawInput": null,
"content": [
{
"type": "content",
"content": {
"type": "text",
"text": "Running npm install"
}
}
]
"rawInput": null
},
"options": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@
"rawInput": {
"command": "npm install",
"cwd": "/home/user/project"
},
"content": [
{
"type": "content",
"content": {
"type": "text",
"text": "Installing dependencies"
}
}
]
}
},
"options": [
{
Expand Down
11 changes: 1 addition & 10 deletions src/__tests__/CodexACPAgent/data/approval-file-change.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@
"toolCall": {
"toolCallId": "file-change-snapshot",
"kind": "edit",
"status": "pending",
"content": [
{
"type": "content",
"content": {
"type": "text",
"text": "Modifying config file"
}
}
]
"status": "pending"
},
"options": [
{
Expand Down
Loading