Skip to content

Commit 65b19be

Browse files
Fix types and tests regressions after Codex update
1 parent 78e7859 commit 65b19be

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
@@ -901,6 +901,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
901901
secondary: null,
902902
credits: null,
903903
planType: null,
904+
rateLimitReachedType: null,
904905
}
905906
});
906907
rateLimits.set("limit-2", {
@@ -913,6 +914,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
913914
secondary: null,
914915
credits: null,
915916
planType: null,
917+
rateLimitReachedType: null,
916918
}
917919
});
918920

@@ -965,6 +967,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
965967
secondary: null,
966968
credits: null,
967969
planType: null,
970+
rateLimitReachedType: null,
968971
}
969972
}
970973
});
@@ -979,6 +982,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
979982
secondary: null,
980983
credits: null,
981984
planType: null,
985+
rateLimitReachedType: null,
982986
}
983987
}
984988
});
@@ -995,6 +999,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
995999
secondary: null,
9961000
credits: null,
9971001
planType: null,
1002+
rateLimitReachedType: null,
9981003
}
9991004
});
10001005
expect(sessionState.rateLimits!.get("fast-limit")).toEqual({
@@ -1007,6 +1012,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
10071012
secondary: null,
10081013
credits: null,
10091014
planType: null,
1015+
rateLimitReachedType: null,
10101016
}
10111017
});
10121018
});

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)