Skip to content

Commit 62dcbd6

Browse files
Fix types and tests after Codex update
1 parent 1d25387 commit 62dcbd6

13 files changed

Lines changed: 114 additions & 44 deletions

src/CodexAcpClient.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export class CodexAcpClient {
200200
}
201201

202202
async resumeSession(request: acp.ResumeSessionRequest): Promise<SessionMetadata> {
203-
await this.refreshSkills(request.cwd, request._meta);
203+
await this.refreshSkills(request.cwd);
204204

205205
const response = await this.codexClient.threadResume({
206206
config: await this.createSessionConfig(request.cwd, request.mcpServers ?? []),
@@ -214,7 +214,7 @@ export class CodexAcpClient {
214214
sessionId: request.sessionId,
215215
currentModelId: currentModelId,
216216
models: codexModels,
217-
currentServiceTier: response.serviceTier ?? null,
217+
currentServiceTier: toServiceTier(response.serviceTier),
218218
}
219219
}
220220

@@ -231,13 +231,13 @@ export class CodexAcpClient {
231231
sessionId: request.sessionId,
232232
currentModelId: currentModelId,
233233
models: codexModels,
234-
currentServiceTier: response.serviceTier ?? null,
234+
currentServiceTier: toServiceTier(response.serviceTier),
235235
thread: response.thread,
236236
};
237237
}
238238

239239
async newSession(request: acp.NewSessionRequest): Promise<SessionMetadata> {
240-
await this.refreshSkills(request.cwd, request._meta);
240+
await this.refreshSkills(request.cwd);
241241

242242
const response = await this.codexClient.threadStart({
243243
config: await this.createSessionConfig(request.cwd, request.mcpServers),
@@ -254,7 +254,7 @@ export class CodexAcpClient {
254254
sessionId: response.thread.id,
255255
currentModelId: currentModelId,
256256
models: codexModels,
257-
currentServiceTier: response.serviceTier ?? null,
257+
currentServiceTier: toServiceTier(response.serviceTier),
258258
};
259259
}
260260

@@ -312,18 +312,13 @@ export class CodexAcpClient {
312312
return this.getModelProvider() ?? "openai";
313313
}
314314

315-
private async refreshSkills(cwd: string, meta?: Record<string, unknown> | null): Promise<void> {
315+
private async refreshSkills(cwd: string): Promise<void> {
316316
if (!cwd) {
317317
return;
318318
}
319-
const additionalRoots = readAdditionalRoots(meta);
320319
await this.codexClient.listSkills({
321320
cwds: [cwd],
322321
forceReload: true,
323-
perCwdExtraUserRoots: [{
324-
cwd: cwd,
325-
extraUserRoots: additionalRoots
326-
}]
327322
});
328323
}
329324

@@ -389,7 +384,7 @@ export class CodexAcpClient {
389384
const input = buildPromptItems(request.prompt);
390385
const effort = modelId.effort as ReasoningEffort | null; //TODO remove unsafe conversion
391386

392-
await this.refreshSkills(cwd, request._meta);
387+
await this.refreshSkills(cwd);
393388
return await this.codexClient.runTurn({
394389
threadId: request.sessionId,
395390
input: input,
@@ -623,16 +618,14 @@ interface GatewayConfig {
623618
}
624619
}
625620

626-
function readAdditionalRoots(meta: Record<string, unknown> | null | undefined): string[] {
627-
const rawRoots = meta?.["additionalRoots"];
628-
if (!Array.isArray(rawRoots)) {
629-
return [];
621+
function toServiceTier(value: string | null): ServiceTier | null {
622+
switch (value) {
623+
case "fast":
624+
case "flex":
625+
return value;
626+
default:
627+
return null;
630628
}
631-
632-
return Array.from(new Set(rawRoots
633-
.filter((value): value is string => typeof value === "string")
634-
.map(value => value.trim())
635-
.filter(value => value.length > 0)));
636629
}
637630

638631
function mergeGatewayConfig(config: JsonObject, gatewayConfig: GatewayConfig | null): JsonObject {

src/CodexEventHandler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ export class CodexEventHandler {
178178
case "thread/goal/cleared":
179179
case "remoteControl/status/changed":
180180
case "app/list/updated":
181+
case "thread/settings/updated":
182+
case "process/outputDelta":
183+
case "process/exited":
181184
return null;
182185
}
183186
}

src/__tests__/CodexACPAgent/CodexAcpClient.test.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
215215
expect(logoutSpy).toHaveBeenCalledWith({});
216216
});
217217

218-
it('prefetches session additional skill roots before thread start', async () => {
218+
it('prefetches skills before thread start', async () => {
219219
const mockFixture = createCodexMockTestFixture();
220220
const codexAcpClient = mockFixture.getCodexAcpClient();
221221
const codexAppServerClient = mockFixture.getCodexAppServerClient();
@@ -245,6 +245,8 @@ describe('ACP server test', { timeout: 40_000 }, () => {
245245
inputModalities: ["text"],
246246
supportsPersonality: false,
247247
additionalSpeedTiers: [],
248+
serviceTiers: [],
249+
defaultServiceTier: null,
248250
isDefault: true
249251
}],
250252
nextCursor: null
@@ -253,18 +255,11 @@ describe('ACP server test', { timeout: 40_000 }, () => {
253255
await codexAcpClient.newSession({
254256
cwd: "/workspace",
255257
mcpServers: [],
256-
_meta: {
257-
additionalRoots: ["/skills/one", " /skills/two ", 7]
258-
}
259258
});
260259

261260
expect(listSkillsSpy).toHaveBeenCalledWith({
262261
cwds: ["/workspace"],
263262
forceReload: true,
264-
perCwdExtraUserRoots: [{
265-
cwd: "/workspace",
266-
extraUserRoots: ["/skills/one", "/skills/two"]
267-
}]
268263
});
269264
expect(listSkillsSpy.mock.invocationCallOrder[0]!).toBeLessThan(threadStartSpy.mock.invocationCallOrder[0]!);
270265
});
@@ -358,7 +353,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
358353
expect(session.sessionId).toBe("thread-id");
359354
});
360355

361-
it('prefetches session additional skill roots before turn start', async () => {
356+
it('prefetches skills before turn start', async () => {
362357
const mockFixture = createCodexMockTestFixture();
363358
const codexAcpAgent = mockFixture.getCodexAcpAgent();
364359
const codexAppServerClient = mockFixture.getCodexAppServerClient();
@@ -380,19 +375,12 @@ describe('ACP server test', { timeout: 40_000 }, () => {
380375
const promptRequest: acp.PromptRequest = {
381376
sessionId: "session-id",
382377
prompt: [{ type: "text", text: "Hello" }],
383-
_meta: {
384-
additionalRoots: ["/skills/one", " /skills/two ", 7]
385-
}
386378
};
387379
await codexAcpAgent.prompt(promptRequest);
388380

389381
expect(listSkillsSpy).toHaveBeenCalledWith({
390382
cwds: ["/workspace"],
391383
forceReload: true,
392-
perCwdExtraUserRoots: [{
393-
cwd: "/workspace",
394-
extraUserRoots: ["/skills/one", "/skills/two"]
395-
}]
396384
});
397385
expect(listSkillsSpy.mock.invocationCallOrder[0]!).toBeLessThan(turnStartSpy.mock.invocationCallOrder[0]!);
398386
});
@@ -416,6 +404,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
416404
return {
417405
id,
418406
items: [],
407+
itemsView: "full" as const,
419408
status,
420409
error: null,
421410
startedAt: null,
@@ -657,6 +646,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
657646
turn: {
658647
id: "turn-id",
659648
items: [],
649+
itemsView: "full" as const,
660650
status: "completed",
661651
error: null,
662652
startedAt: null,
@@ -852,6 +842,8 @@ describe('ACP server test', { timeout: 40_000 }, () => {
852842
defaultReasoningEffort: 'medium',
853843
supportsPersonality: false,
854844
additionalSpeedTiers: [],
845+
serviceTiers: [],
846+
defaultServiceTier: null,
855847
isDefault: false,
856848
inputModalities: []
857849
},
@@ -870,6 +862,8 @@ describe('ACP server test', { timeout: 40_000 }, () => {
870862
defaultReasoningEffort: 'low',
871863
supportsPersonality: false,
872864
additionalSpeedTiers: [],
865+
serviceTiers: [],
866+
defaultServiceTier: null,
873867
isDefault: true,
874868
inputModalities: []
875869
}
@@ -896,6 +890,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
896890
turn: {
897891
id: "turn-id",
898892
items: [],
893+
itemsView: "full" as const,
899894
status: "inProgress",
900895
error: null,
901896
startedAt: null,
@@ -908,6 +903,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
908903
turn: {
909904
id: "turn-id",
910905
items: [],
906+
itemsView: "full" as const,
911907
status: "completed",
912908
error: null,
913909
startedAt: null,

src/__tests__/CodexACPAgent/approval-events.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describe('Approval Events', () => {
6666
threadId: sessionId,
6767
turnId: 'turn-1',
6868
itemId: `item-${optionId}`,
69+
startedAtMs: 1000,
6970
reason: 'Test command',
7071
proposedExecpolicyAmendment: null,
7172
};
@@ -92,6 +93,7 @@ describe('Approval Events', () => {
9293
threadId: sessionId,
9394
turnId: 'turn-1',
9495
itemId: 'item-cancelled',
96+
startedAtMs: 1000,
9597
reason: null,
9698
proposedExecpolicyAmendment: null,
9799
};
@@ -112,6 +114,7 @@ describe('Approval Events', () => {
112114
threadId: 'non-existent-session',
113115
turnId: 'turn-1',
114116
itemId: 'item-no-handler',
117+
startedAtMs: 1000,
115118
reason: null,
116119
proposedExecpolicyAmendment: null,
117120
};
@@ -134,6 +137,7 @@ describe('Approval Events', () => {
134137
threadId: sessionId,
135138
turnId: 'turn-1',
136139
itemId: 'item-snapshot',
140+
startedAtMs: 1000,
137141
reason: 'Running npm install',
138142
proposedExecpolicyAmendment: null,
139143
};
@@ -161,6 +165,7 @@ describe('Approval Events', () => {
161165
threadId: sessionId,
162166
turnId: 'turn-1',
163167
itemId: 'item-with-command',
168+
startedAtMs: 1000,
164169
reason: 'Installing dependencies',
165170
command: 'npm install',
166171
cwd: '/home/user/project',
@@ -198,6 +203,7 @@ describe('Approval Events', () => {
198203
threadId: sessionId,
199204
turnId: 'turn-1',
200205
itemId: 'item-shell-prefix',
206+
startedAtMs: 1000,
201207
reason: 'Installing dependencies',
202208
command,
203209
cwd: '/home/user/project',
@@ -237,6 +243,7 @@ describe('Approval Events', () => {
237243
threadId: sessionId,
238244
turnId: 'turn-1',
239245
itemId: `file-change-${optionId}`,
246+
startedAtMs: 1000,
240247
reason: 'Test file change',
241248
grantRoot: null,
242249
};
@@ -263,6 +270,7 @@ describe('Approval Events', () => {
263270
threadId: sessionId,
264271
turnId: 'turn-1',
265272
itemId: 'file-change-cancelled',
273+
startedAtMs: 1000,
266274
reason: null,
267275
grantRoot: null,
268276
};
@@ -283,6 +291,7 @@ describe('Approval Events', () => {
283291
threadId: 'non-existent-session',
284292
turnId: 'turn-1',
285293
itemId: 'file-change-no-handler',
294+
startedAtMs: 1000,
286295
reason: null,
287296
grantRoot: null,
288297
};
@@ -305,6 +314,7 @@ describe('Approval Events', () => {
305314
threadId: sessionId,
306315
turnId: 'turn-1',
307316
itemId: 'file-change-snapshot',
317+
startedAtMs: 1000,
308318
reason: 'Modifying config file',
309319
grantRoot: null,
310320
};

0 commit comments

Comments
 (0)