Skip to content

Commit 6605006

Browse files
Fix types and tests after Codex update compatibility changes
1 parent 51c70a1 commit 6605006

6 files changed

Lines changed: 61 additions & 17 deletions

File tree

src/CodexEventHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export class CodexEventHandler {
133133
case "thread/realtime/itemAdded":
134134
case "thread/realtime/transcriptUpdated":
135135
case "thread/realtime/outputAudio/delta":
136+
case "thread/realtime/sdp":
136137
case "thread/realtime/error":
137138
case "thread/realtime/closed":
138139
case "windowsSandbox/setupCompleted":

src/__tests__/CodexACPAgent/CodexAcpClient.test.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
229229
defaultReasoningEffort: "medium",
230230
inputModalities: ["text"],
231231
supportsPersonality: false,
232+
additionalSpeedTiers: [],
232233
isDefault: true
233234
}],
234235
nextCursor: null
@@ -524,7 +525,15 @@ describe('ACP server test', { timeout: 40_000 }, () => {
524525

525526
vi.spyOn(codexAppServerClient, "awaitTurnCompleted").mockResolvedValue({
526527
threadId: "session-id",
527-
turn: { id: "turn-id", items: [], status: "completed", error: null }
528+
turn: {
529+
id: "turn-id",
530+
items: [],
531+
status: "completed",
532+
error: null,
533+
startedAt: null,
534+
completedAt: null,
535+
durationMs: null,
536+
}
528537
});
529538

530539
const sessionState: SessionState = createTestSessionState();
@@ -735,6 +744,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
735744
],
736745
defaultReasoningEffort: 'medium',
737746
supportsPersonality: false,
747+
additionalSpeedTiers: [],
738748
isDefault: false,
739749
inputModalities: []
740750
},
@@ -752,6 +762,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
752762
],
753763
defaultReasoningEffort: 'low',
754764
supportsPersonality: false,
765+
additionalSpeedTiers: [],
755766
isDefault: true,
756767
inputModalities: []
757768
}
@@ -775,11 +786,27 @@ describe('ACP server test', { timeout: 40_000 }, () => {
775786
const mockFixture = createCodexMockTestFixture();
776787
const sessionState = createTestSessionState(sessionOverrides);
777788
const turnStartSpy = vi.spyOn(mockFixture.getCodexAppServerClient(), "turnStart").mockResolvedValue({
778-
turn: { id: "turn-id", items: [], status: "inProgress", error: null }
789+
turn: {
790+
id: "turn-id",
791+
items: [],
792+
status: "inProgress",
793+
error: null,
794+
startedAt: null,
795+
completedAt: null,
796+
durationMs: null,
797+
}
779798
});
780799
vi.spyOn(mockFixture.getCodexAppServerClient(), "awaitTurnCompleted").mockResolvedValue({
781800
threadId: sessionState.sessionId,
782-
turn: { id: "turn-id", items: [], status: "completed", error: null }
801+
turn: {
802+
id: "turn-id",
803+
items: [],
804+
status: "completed",
805+
error: null,
806+
startedAt: null,
807+
completedAt: null,
808+
durationMs: null,
809+
}
783810
});
784811
vi.spyOn(mockFixture.getCodexAcpAgent(), "getSessionState").mockReturnValue(sessionState);
785812
return { mockFixture, sessionState, turnStartSpy };

src/__tests__/CodexACPAgent/list-sessions.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe("CodexACPAgent - list sessions", () => {
1414

1515
const threadA: Thread = {
1616
id: "sess-1",
17+
forkedFromId: null,
1718
preview: "First session",
1819
ephemeral: false,
1920
modelProvider: "openai",
@@ -32,6 +33,7 @@ describe("CodexACPAgent - list sessions", () => {
3233
};
3334
const threadB: Thread = {
3435
id: "sess-2",
36+
forkedFromId: null,
3537
preview: "Other session",
3638
ephemeral: false,
3739
modelProvider: "openai",

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe("CodexACPAgent - loadSession", () => {
3333
defaultReasoningEffort: "medium",
3434
inputModalities: ["text", "image"],
3535
supportsPersonality: false,
36+
additionalSpeedTiers: [],
3637
isDefault: true,
3738
};
3839

@@ -43,6 +44,7 @@ describe("CodexACPAgent - loadSession", () => {
4344

4445
const thread: Thread = {
4546
id: "session-1",
47+
forkedFromId: null,
4648
preview: "Hi",
4749
ephemeral: false,
4850
modelProvider: "openai",
@@ -62,6 +64,9 @@ describe("CodexACPAgent - loadSession", () => {
6264
id: "turn-1",
6365
status: "completed",
6466
error: null,
67+
startedAt: null,
68+
completedAt: null,
69+
durationMs: null,
6570
items: [
6671
{
6772
type: "userMessage",
@@ -192,6 +197,7 @@ describe("CodexACPAgent - loadSession", () => {
192197
defaultReasoningEffort: "medium",
193198
inputModalities: ["text"],
194199
supportsPersonality: false,
200+
additionalSpeedTiers: [],
195201
isDefault: true,
196202
};
197203

@@ -202,6 +208,7 @@ describe("CodexACPAgent - loadSession", () => {
202208
codexAppServerClient.threadResume = vi.fn().mockResolvedValue({
203209
thread: {
204210
id: "session-1",
211+
forkedFromId: null,
205212
preview: "",
206213
ephemeral: false,
207214
modelProvider: "openai",
@@ -263,6 +270,7 @@ describe("CodexACPAgent - loadSession", () => {
263270
defaultReasoningEffort: "medium",
264271
inputModalities: ["text"],
265272
supportsPersonality: false,
273+
additionalSpeedTiers: [],
266274
isDefault: true,
267275
};
268276

@@ -273,6 +281,7 @@ describe("CodexACPAgent - loadSession", () => {
273281
codexAppServerClient.threadResume = vi.fn().mockResolvedValue({
274282
thread: {
275283
id: "session-1",
284+
forkedFromId: null,
276285
preview: "",
277286
ephemeral: false,
278287
modelProvider: "openai",

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
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});
19-
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]});
26-
fixture.clearAcpConnectionDump();
27-
await codexAcpAgent.prompt({sessionId: newSessionResponse.sessionId, prompt: [{type: "text", text: "/mcp"}]});
17+
const sessionState = createTestSessionState({
18+
sessionId: "session-id",
19+
sessionMcpServers: ["test-mcp"],
20+
});
21+
vi.spyOn(codexAcpAgent, "getSessionState").mockReturnValue(sessionState);
22+
23+
vi.spyOn(fixture.getCodexAcpClient(), "listMcpServers").mockResolvedValue({
24+
data: [],
25+
nextCursor: null,
26+
});
27+
28+
await codexAcpAgent.prompt({sessionId: "session-id", prompt: [{type: "text", text: "/mcp"}]});
2829
const transportDump = fixture.getAcpConnectionDump([]);
2930
expect(transportDump).contain("Configured MCP servers:");
3031
expect(transportDump).contain("- test-mcp");

src/__tests__/CodexACPAgent/model-filtering.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe("Model filtering", () => {
2525
supportedReasoningEfforts: efforts,
2626
defaultReasoningEffort: "medium",
2727
supportsPersonality: false,
28+
additionalSpeedTiers: [],
2829
isDefault: false,
2930
inputModalities: []
3031
},
@@ -40,6 +41,7 @@ describe("Model filtering", () => {
4041
supportedReasoningEfforts: [defaultEffort],
4142
defaultReasoningEffort: "medium",
4243
supportsPersonality: false,
44+
additionalSpeedTiers: [],
4345
isDefault: false,
4446
inputModalities: []
4547
},
@@ -55,6 +57,7 @@ describe("Model filtering", () => {
5557
supportedReasoningEfforts: [defaultEffort],
5658
defaultReasoningEffort: "medium",
5759
supportsPersonality: false,
60+
additionalSpeedTiers: [],
5861
isDefault: false,
5962
inputModalities: []
6063
},
@@ -70,6 +73,7 @@ describe("Model filtering", () => {
7073
supportedReasoningEfforts: [defaultEffort],
7174
defaultReasoningEffort: "medium",
7275
supportsPersonality: false,
76+
additionalSpeedTiers: [],
7377
isDefault: false,
7478
inputModalities: []
7579
},

0 commit comments

Comments
 (0)