Skip to content

Commit 2351fa2

Browse files
Fix types and tests regressions after Codex update
1 parent 8361236 commit 2351fa2

4 files changed

Lines changed: 31 additions & 19 deletions

File tree

src/CodexAcpClient.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ export class CodexAcpClient {
190190

191191
async resumeSession(request: acp.ResumeSessionRequest): Promise<SessionMetadata> {
192192
await this.refreshSkills(request.cwd, request._meta);
193+
const mode = AgentMode.getInitialAgentMode();
193194

194195
const response = await this.codexClient.threadResume({
195-
approvalPolicy: null,
196-
sandbox: null,
196+
approvalPolicy: mode.approvalPolicy,
197+
sandbox: mode.sandboxMode,
197198
baseInstructions: null,
198199
config: this.createSessionConfig(request.cwd, request.mcpServers ?? []),
199200
cwd: request.cwd,
@@ -216,9 +217,10 @@ export class CodexAcpClient {
216217
}
217218

218219
async loadSession(request: acp.LoadSessionRequest): Promise<SessionMetadataWithThread> {
220+
const mode = AgentMode.getInitialAgentMode();
219221
const response = await this.codexClient.threadResume({
220-
approvalPolicy: null,
221-
sandbox: null,
222+
approvalPolicy: mode.approvalPolicy,
223+
sandbox: mode.sandboxMode,
222224
baseInstructions: null,
223225
config: this.createSessionConfig(request.cwd, request.mcpServers ?? []),
224226
cwd: request.cwd,
@@ -243,14 +245,15 @@ export class CodexAcpClient {
243245

244246
async newSession(request: acp.NewSessionRequest): Promise<SessionMetadata> {
245247
await this.refreshSkills(request.cwd, request._meta);
248+
const mode = AgentMode.getInitialAgentMode();
246249

247250
const response = await this.codexClient.threadStart({
248251
config: this.createSessionConfig(request.cwd, request.mcpServers),
249252
modelProvider: this.getModelProvider(),
250253
model: null,
251254
cwd: request.cwd,
252-
approvalPolicy: null,
253-
sandbox: null,
255+
approvalPolicy: mode.approvalPolicy,
256+
sandbox: mode.sandboxMode,
254257
baseInstructions: null,
255258
developerInstructions: null,
256259
personality: null,

src/CodexEventHandler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,19 @@ export class CodexEventHandler {
130130
case "thread/closed":
131131
case "thread/realtime/started":
132132
case "thread/realtime/itemAdded":
133-
case "thread/realtime/transcriptUpdated":
133+
case "thread/realtime/transcript/delta":
134+
case "thread/realtime/transcript/done":
134135
case "thread/realtime/outputAudio/delta":
135136
case "thread/realtime/sdp":
136137
case "thread/realtime/error":
137138
case "thread/realtime/closed":
138139
case "windowsSandbox/setupCompleted":
139140
case "account/login/completed":
140141
case "skills/changed":
142+
case "warning":
141143
case "deprecationNotice":
142144
case "mcpServer/oauthLogin/completed":
145+
case "externalAgentConfig/import/completed":
143146
case "rawResponseItem/completed":
144147
case "thread/started":
145148
case "thread/name/updated":
@@ -153,6 +156,8 @@ export class CodexEventHandler {
153156
case "fuzzyFileSearch/sessionCompleted":
154157
return this.handleFuzzyFileSearchSessionCompleted(notification.params);
155158
}
159+
const exhaustiveNotification: never = notification;
160+
return exhaustiveNotification;
156161
}
157162

158163
private async createTextEvent(event: AgentMessageDeltaNotification): Promise<UpdateSessionEvent> {

src/__tests__/CodexACPAgent/CodexAcpClient.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
798798
secondary: null,
799799
credits: null,
800800
planType: null,
801+
rateLimitReachedType: null,
801802
}
802803
});
803804
rateLimits.set("limit-2", {
@@ -810,6 +811,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
810811
secondary: null,
811812
credits: null,
812813
planType: null,
814+
rateLimitReachedType: null,
813815
}
814816
});
815817

@@ -862,6 +864,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
862864
secondary: null,
863865
credits: null,
864866
planType: null,
867+
rateLimitReachedType: null,
865868
}
866869
}
867870
});
@@ -876,6 +879,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
876879
secondary: null,
877880
credits: null,
878881
planType: null,
882+
rateLimitReachedType: null,
879883
}
880884
}
881885
});
@@ -892,6 +896,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
892896
secondary: null,
893897
credits: null,
894898
planType: null,
899+
rateLimitReachedType: null,
895900
}
896901
});
897902
expect(sessionState.rateLimits!.get("fast-limit")).toEqual({
@@ -904,6 +909,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
904909
secondary: null,
905910
credits: null,
906911
planType: null,
912+
rateLimitReachedType: null,
907913
}
908914
});
909915
});

src/__tests__/CodexACPAgent/mcp-session.test.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
// noinspection ES6RedundantAwait
22

33
import {describe, expect, it, vi, beforeEach} from 'vitest';
4-
import {createTestFixture, type TestFixture} from "../acp-test-utils";
5-
import type {McpServerStdio} from "@agentclientprotocol/sdk";
4+
import {createCodexMockTestFixture, createTestSessionState, type CodexMockTestFixture} from "../acp-test-utils";
65

76
describe('MCP session configuration', { timeout: 40_000 }, () => {
87

9-
let fixture: TestFixture;
8+
let fixture: CodexMockTestFixture;
109
beforeEach(() => {
11-
fixture = createTestFixture();
10+
fixture = createCodexMockTestFixture();
1211
vi.clearAllMocks();
1312
});
1413

1514

1615
it('should return configured mcp', async () => {
1716
const codexAcpAgent = fixture.getCodexAcpAgent();
18-
await codexAcpAgent.initialize({protocolVersion: 1});
17+
const sessionId = "session-id";
18+
vi.spyOn(codexAcpAgent, "getSessionState").mockReturnValue(createTestSessionState({
19+
sessionId,
20+
sessionMcpServers: ["test-mcp"],
21+
}));
22+
vi.spyOn(fixture.getCodexAcpClient(), "listMcpServers").mockResolvedValue({ data: [], nextCursor: null });
1923

20-
fixture.getCodexAcpClient().authRequired = vi.fn().mockResolvedValue(false);
21-
const mcpServer: McpServerStdio = {
22-
name: "test-mcp", command: "./node_modules/.bin/mcp-hello-world", args: ["example"], env: [{name:"example", value: "example"}]
23-
};
24-
25-
const newSessionResponse = await codexAcpAgent.newSession({cwd: "", mcpServers: [mcpServer]});
2624
fixture.clearAcpConnectionDump();
27-
await codexAcpAgent.prompt({sessionId: newSessionResponse.sessionId, prompt: [{type: "text", text: "/mcp"}]});
25+
await codexAcpAgent.prompt({sessionId, prompt: [{type: "text", text: "/mcp"}]});
2826
const transportDump = fixture.getAcpConnectionDump([]);
2927
expect(transportDump).contain("Configured MCP servers:");
3028
expect(transportDump).contain("- test-mcp");

0 commit comments

Comments
 (0)