Skip to content

Commit da653e4

Browse files
fix: rebase
1 parent 76f9ea2 commit da653e4

9 files changed

Lines changed: 26 additions & 38 deletions

package-lock.json

Lines changed: 2 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/CodexAcpServer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export class CodexAcpServer implements acp.Agent {
127127
list: { }
128128
},
129129
mcpCapabilities: {
130+
acp: false,
130131
http: true,
131132
sse: false
132133
}

src/McpApprovalOptionId.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/__tests__/CodexACPAgent/e2e/acp-e2e-file-approval.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describeE2E("E2E file approval tests", () => {
1919
let fixture: SpawnedAgentFixture;
2020

2121
beforeEach(async () => {
22-
fixture = await createAuthenticatedFixture({initialMode: AgentMode.ReadOnly});
22+
fixture = await createAuthenticatedFixture(AgentMode.ReadOnly);
2323
});
2424

2525
afterEach(async () => {
@@ -43,7 +43,7 @@ describeE2E("E2E Agent mode file permission tests", () => {
4343
let fixture: SpawnedAgentFixture;
4444

4545
beforeEach(async () => {
46-
fixture = await createAuthenticatedFixture({initialMode: AgentMode.Agent});
46+
fixture = await createAuthenticatedFixture(AgentMode.Agent);
4747
});
4848

4949
afterEach(async () => {
@@ -65,7 +65,7 @@ describeE2E("E2E Agent with full access file permission tests", () => {
6565
let fixture: SpawnedAgentFixture;
6666

6767
beforeEach(async () => {
68-
fixture = await createAuthenticatedFixture({initialMode: AgentMode.AgentFullAccess});
68+
fixture = await createAuthenticatedFixture(AgentMode.AgentFullAccess);
6969
});
7070

7171
afterEach(async () => {

src/__tests__/CodexACPAgent/e2e/acp-e2e-mcp-approval.test.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import type * as acp from "@agentclientprotocol/sdk";
22
import fs from "node:fs";
33
import path from "node:path";
44
import {afterEach, beforeEach, describe, expect, it} from "vitest";
5-
import {McpApprovalOptionId, type McpApprovalOptionId as McpApprovalOptionIdValue} from "../../../McpApprovalOptionId";
65
import {ApprovalOptionId} from "../../../ApprovalOptionId";
76
import {
8-
createAuthenticatedFixture,
7+
createAuthenticatedFixture, createPermissionResponse,
98
describeE2E,
109
expectEndTurn,
1110
type PermissionResponder,
@@ -33,18 +32,18 @@ function isMcpPermissionRequest(request: acp.RequestPermissionRequest): boolean
3332
return request.toolCall.kind === "execute" && request._meta?.["is_mcp_tool_approval"] === true;
3433
}
3534

36-
function createMcpPermissionResponse(optionId: McpApprovalOptionIdValue | null): acp.RequestPermissionResponse {
35+
function createMcpPermissionResponse(optionId: ApprovalOptionId | null): acp.RequestPermissionResponse {
3736
if (optionId === null) {
3837
return {outcome: {outcome: "cancelled"}};
3938
}
4039
return {outcome: {outcome: "selected", optionId}};
4140
}
4241

43-
function createMcpPermissionResponder(...optionIds: McpApprovalOptionIdValue[]): PermissionResponder {
42+
function createMcpPermissionResponder(...optionIds: ApprovalOptionId[]): PermissionResponder {
4443
const queue = [...optionIds];
4544
return (request) => createMcpPermissionResponse(
4645
isMcpPermissionRequest(request)
47-
? queue.shift() ?? McpApprovalOptionId.Decline
46+
? queue.shift() ?? ApprovalOptionId.RejectOnce
4847
: null,
4948
);
5049
}
@@ -89,7 +88,7 @@ describeE2E("E2E MCP approval tests (configured in session)", () => {
8988
}
9089

9190
it("executes an approved MCP tool call", async () => {
92-
fixture.setPermissionResponder(createMcpPermissionResponder(McpApprovalOptionId.AllowOnce));
91+
fixture.setPermissionResponder(createMcpPermissionResponder(ApprovalOptionId.AllowOnce));
9392
const {sessionId, invocationMarkerPath} = await createMcpSession();
9493

9594
await expectEchoToolReply(fixture, sessionId, MCP_ECHO_MESSAGE);
@@ -98,7 +97,7 @@ describeE2E("E2E MCP approval tests (configured in session)", () => {
9897
});
9998

10099
it("ends turn when MCP tool call is rejected", async () => {
101-
fixture.setPermissionResponder(createMcpPermissionResponder(McpApprovalOptionId.Decline));
100+
fixture.setPermissionResponder(createMcpPermissionResponder(ApprovalOptionId.RejectOnce));
102101
const {sessionId, invocationMarkerPath} = await createMcpSession();
103102

104103
expectEndTurn(await fixture.connection.prompt({
@@ -113,7 +112,7 @@ describeE2E("E2E MCP approval tests (configured in session)", () => {
113112
});
114113

115114
it("skips subsequent approvals in the same session when allow_session is selected", async () => {
116-
fixture.setPermissionResponder(createMcpPermissionResponder(McpApprovalOptionId.AllowSession));
115+
fixture.setPermissionResponder(createMcpPermissionResponder(ApprovalOptionId.AllowForSession));
117116
const {sessionId, invocationMarkerPath} = await createMcpSession();
118117

119118
await expectEchoToolReply(fixture, sessionId, "session approval first");
@@ -124,7 +123,7 @@ describeE2E("E2E MCP approval tests (configured in session)", () => {
124123
});
125124

126125
it("requests subsequent approvals after session restart when allow_session is selected", async () => {
127-
fixture.setPermissionResponder(createMcpPermissionResponder(McpApprovalOptionId.AllowSession, McpApprovalOptionId.AllowOnce));
126+
fixture.setPermissionResponder(createMcpPermissionResponder(ApprovalOptionId.AllowForSession, ApprovalOptionId.AllowOnce));
128127
const {sessionId, invocationMarkerPath} = await createMcpSession();
129128

130129
await expectEchoToolReply(fixture, sessionId, MCP_ECHO_MESSAGE);
@@ -162,9 +161,10 @@ describeE2E("E2E MCP approval tests (configured in toml)", () => {
162161
fixture = await createAuthenticatedFixture(undefined, [createMcpServer(invocationMarkerPath)]);
163162
});
164163

164+
//TODO: recheck allow_always == persist?
165165
it("skips subsequent approvals in the same session when allow_always is selected", async () => {
166166
fixture.setPermissionResponder(
167-
createMcpPermissionResponder(McpApprovalOptionId.AllowAlways),
167+
createMcpPermissionResponder(ApprovalOptionId.AllowPersist),
168168
);
169169
const sessionId = (await fixture.createSession()).sessionId;
170170

@@ -177,7 +177,7 @@ describeE2E("E2E MCP approval tests (configured in toml)", () => {
177177

178178
it.skip("skips subsequent approvals after session restart when allow_always is selected", async () => {
179179
fixture.setPermissionResponder(
180-
createMcpPermissionResponder(McpApprovalOptionId.AllowAlways),
180+
createMcpPermissionResponder(ApprovalOptionId.AllowPersist),
181181
);
182182
const firstSessionId = (await fixture.createSession()).sessionId;
183183

@@ -200,15 +200,14 @@ describeE2E("E2E MCP approval tests (configured in toml)", () => {
200200
describe("persisted approvals", () => {
201201
let beforeRestartFixture: SpawnedAgentFixture | null = null;
202202
let afterRestartFixture: SpawnedAgentFixture | null = null;
203+
let sessionId: string;
203204

204205
beforeEach(async () => {
205206
// The outer beforeEach already created `fixture` without a config-backed MCP server.
206207
// Persistence tests need the server in config.toml so Codex offers "Always allow",
207208
// so dispose that fixture and replace it with a config-backed one.
208209
await fixture.dispose();
209-
beforeRestartFixture = await createAuthenticatedFixture({
210-
configBackedMcpServers: [createMcpServer()],
211-
});
210+
beforeRestartFixture = await createAuthenticatedFixture(undefined, [createMcpServer(invocationMarkerPath)]);
212211
fixture = beforeRestartFixture;
213212
sessionId = (await fixture.createSession()).sessionId;
214213
});

src/__tests__/CodexACPAgent/e2e/acp-e2e-shell-approval.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describeE2E("E2E shell approval tests", () => {
2424
let sessionId: string;
2525

2626
beforeEach(async () => {
27-
fixture = await createAuthenticatedFixture({initialMode: AgentMode.ReadOnly});
27+
fixture = await createAuthenticatedFixture(AgentMode.ReadOnly);
2828
sessionId = (await fixture.createSession()).sessionId;
2929
});
3030

@@ -78,7 +78,7 @@ describeE2E("E2E Agent mode shell permission tests", () => {
7878
let fixture: SpawnedAgentFixture;
7979

8080
beforeEach(async () => {
81-
fixture = await createAuthenticatedFixture({initialMode: AgentMode.Agent});
81+
fixture = await createAuthenticatedFixture(AgentMode.Agent);
8282
});
8383

8484
afterEach(async () => {
@@ -103,7 +103,7 @@ describeE2E("E2E Agent with full access shell permission tests", () => {
103103
let fixture: SpawnedAgentFixture;
104104

105105
beforeEach(async () => {
106-
fixture = await createAuthenticatedFixture({initialMode: AgentMode.AgentFullAccess});
106+
fixture = await createAuthenticatedFixture(AgentMode.AgentFullAccess);
107107
});
108108

109109
afterEach(async () => {
@@ -135,7 +135,7 @@ describeE2E("E2E shell cancellation tests", () => {
135135
}
136136

137137
it("cancels a running shell command", async () => {
138-
fixture = await createAuthenticatedFixture({initialMode: AgentMode.AgentFullAccess});
138+
fixture = await createAuthenticatedFixture(AgentMode.AgentFullAccess);
139139
const sessionId = (await fixture.createSession()).sessionId;
140140
const pidFilePath = path.join(fixture.workspaceDir, "cancel-command.pid");
141141
const command = `/bin/sh -c 'echo $$ > "${pidFilePath}"; exec sleep 100'`;

src/__tests__/CodexACPAgent/e2e/acp-e2e.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describeE2E("E2E tests", () => {
8080

8181
it("respects INITIAL_AGENT_MODE when seeding the initial session mode", async () => {
8282
const initialMode = AgentMode.ReadOnly;
83-
fixture = await createAuthenticatedFixture({initialMode});
83+
fixture = await createAuthenticatedFixture(initialMode);
8484
const session = await fixture.createSession();
8585

8686
expect(session.modes?.currentModeId).toBe(initialMode.id);

src/__tests__/CodexACPAgent/initialize.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('CodexACPAgent - initialize', () => {
5151
list: {},
5252
},
5353
mcpCapabilities: {
54+
acp: false,
5455
http: true,
5556
sse: false,
5657
},

src/__tests__/acp-test-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {CodexAcpClient} from '../CodexAcpClient';
33
import {CodexAppServerClient, type CodexConnectionEvent} from '../CodexAppServerClient';
44
import {startCodexConnection} from "../CodexJsonRpcConnection";
55
import {CodexAcpServer, type SessionState} from "../CodexAcpServer";
6-
import type {AgentSideConnection, RequestPermissionResponse} from "@agentclientprotocol/sdk";
76
import type {ServerNotification} from "../app-server";
87
import type {MessageConnection} from "vscode-jsonrpc/node";
98
import path from "node:path";
@@ -346,6 +345,7 @@ export function createTestSessionState(overrides?: Partial<SessionState>): Sessi
346345
agentMode: AgentMode.DEFAULT_AGENT_MODE,
347346
fastModeEnabled: false,
348347
currentModelSupportsFast: false,
348+
sessionMcpServers: [],
349349
...overrides,
350350
};
351351
}

0 commit comments

Comments
 (0)