Skip to content

Commit e654a4a

Browse files
fix: test
1 parent 36e7b2f commit e654a4a

4 files changed

Lines changed: 266 additions & 5 deletions

File tree

src/__tests__/CodexACPAgent/CodexAcpClient.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {describe, expect, it, vi, beforeEach, afterEach} from 'vitest';
1+
import {describe, expect, it, vi, beforeEach} from 'vitest';
22
import type {CodexAuthRequest} from "../../CodexAuthMethod";
33
import {createTestFixture, type TestFixture} from "../acp-test-utils";
44
import type {ServerNotification} from "../../app-server";
@@ -12,7 +12,7 @@ describe('ACP server test', () => {
1212
vi.clearAllMocks();
1313
});
1414

15-
const ignoredFields = ["thread", "cwd", "id", "createdAt", "path", "threadId", "userAgent", "sandbox", "reasoningEffort"];
15+
const ignoredFields = ["thread", "cwd", "id", "createdAt", "path", "threadId", "userAgent", "sandbox", "reasoningEffort", "conversationId"];
1616

1717
it('should start conversation', async () => {
1818
const codexAcpAgent = fixture.getCodexAcpAgent();
@@ -79,7 +79,15 @@ describe('ACP server test', () => {
7979

8080
fixture.getCodexAppServerClient().turnStart = vi.fn().mockResolvedValue(undefined);
8181
fixture.getCodexAppServerClient().awaitTurnCompleted = vi.fn().mockResolvedValue(undefined);
82-
fixture.getCodexAcpAgent().getSessionState = vi.fn().mockResolvedValue({ pendingPrompt: null, sessionId: "id" });
82+
const sessionState: SessionState = {
83+
pendingPrompt: null,
84+
sessionMetadata: {
85+
sessionId: "id",
86+
currentModelId: "model-id",
87+
models: [],
88+
}
89+
};
90+
vi.spyOn(codexAcpAgent, "getSessionState").mockReturnValue(sessionState);
8391

8492
await codexAcpAgent.prompt({ sessionId: "id", prompt: [{type: "text", text: ""}] });
8593

src/__tests__/CodexACPAgent/data/auth-with-key.json

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"eventType": "request",
2929
"method": "thread/start",
3030
"params": {
31-
"config": null,
31+
"config": {},
3232
"modelProvider": null,
3333
"model": null,
3434
"cwd": "cwd",
@@ -47,4 +47,129 @@
4747
"approvalPolicy": "never",
4848
"sandbox": "sandbox",
4949
"reasoningEffort": "reasoningEffort"
50+
}
51+
{
52+
"eventType": "request",
53+
"method": "model/list",
54+
"params": {
55+
"cursor": null,
56+
"limit": null
57+
}
58+
}
59+
{
60+
"eventType": "notification",
61+
"method": "thread/started",
62+
"params": {
63+
"thread": "thread"
64+
},
65+
"jsonrpc": "2.0"
66+
}
67+
{
68+
"eventType": "notification",
69+
"method": "codex/event/mcp_startup_complete",
70+
"params": {
71+
"id": "id",
72+
"msg": {
73+
"type": "mcp_startup_complete",
74+
"ready": [],
75+
"failed": [],
76+
"cancelled": []
77+
},
78+
"conversationId": "conversationId"
79+
},
80+
"jsonrpc": "2.0"
81+
}
82+
{
83+
"eventType": "response",
84+
"data": [
85+
{
86+
"id": "id",
87+
"model": "gpt-5.1-codex-max",
88+
"displayName": "gpt-5.1-codex-max",
89+
"description": "Latest Codex-optimized flagship for deep and fast reasoning.",
90+
"supportedReasoningEfforts": [
91+
{
92+
"reasoningEffort": "reasoningEffort",
93+
"description": "Fast responses with lighter reasoning"
94+
},
95+
{
96+
"reasoningEffort": "reasoningEffort",
97+
"description": "Balances speed and reasoning depth for everyday tasks"
98+
},
99+
{
100+
"reasoningEffort": "reasoningEffort",
101+
"description": "Maximizes reasoning depth for complex problems"
102+
},
103+
{
104+
"reasoningEffort": "reasoningEffort",
105+
"description": "Extra high reasoning depth for complex problems"
106+
}
107+
],
108+
"defaultReasoningEffort": "medium",
109+
"isDefault": true
110+
},
111+
{
112+
"id": "id",
113+
"model": "gpt-5.1-codex",
114+
"displayName": "gpt-5.1-codex",
115+
"description": "Optimized for codex.",
116+
"supportedReasoningEfforts": [
117+
{
118+
"reasoningEffort": "reasoningEffort",
119+
"description": "Fastest responses with limited reasoning"
120+
},
121+
{
122+
"reasoningEffort": "reasoningEffort",
123+
"description": "Dynamically adjusts reasoning based on the task"
124+
},
125+
{
126+
"reasoningEffort": "reasoningEffort",
127+
"description": "Maximizes reasoning depth for complex or ambiguous problems"
128+
}
129+
],
130+
"defaultReasoningEffort": "medium",
131+
"isDefault": false
132+
},
133+
{
134+
"id": "id",
135+
"model": "gpt-5.1-codex-mini",
136+
"displayName": "gpt-5.1-codex-mini",
137+
"description": "Optimized for codex. Cheaper, faster, but less capable.",
138+
"supportedReasoningEfforts": [
139+
{
140+
"reasoningEffort": "reasoningEffort",
141+
"description": "Dynamically adjusts reasoning based on the task"
142+
},
143+
{
144+
"reasoningEffort": "reasoningEffort",
145+
"description": "Maximizes reasoning depth for complex or ambiguous problems"
146+
}
147+
],
148+
"defaultReasoningEffort": "medium",
149+
"isDefault": false
150+
},
151+
{
152+
"id": "id",
153+
"model": "gpt-5.1",
154+
"displayName": "gpt-5.1",
155+
"description": "Broad world knowledge with strong general reasoning.",
156+
"supportedReasoningEfforts": [
157+
{
158+
"reasoningEffort": "reasoningEffort",
159+
"description": "Balances speed with some reasoning; useful for straightforward queries and short explanations"
160+
},
161+
{
162+
"reasoningEffort": "reasoningEffort",
163+
"description": "Provides a solid balance of reasoning depth and latency for general-purpose tasks"
164+
},
165+
{
166+
"reasoningEffort": "reasoningEffort",
167+
"description": "Maximizes reasoning depth for complex or ambiguous problems"
168+
}
169+
],
170+
"defaultReasoningEffort": "medium",
171+
"isDefault": false
172+
}
173+
],
174+
"nextCursor": null
50175
}

src/__tests__/CodexACPAgent/data/output-acp-events.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"method": "sessionUpdate",
33
"args": [
44
{
5+
"sessionId": "id",
56
"update": {
67
"sessionUpdate": "agent_message_chunk",
78
"content": {
@@ -16,6 +17,7 @@
1617
"method": "sessionUpdate",
1718
"args": [
1819
{
20+
"sessionId": "id",
1921
"update": {
2022
"sessionUpdate": "agent_message_chunk",
2123
"content": {
@@ -30,6 +32,7 @@
3032
"method": "sessionUpdate",
3133
"args": [
3234
{
35+
"sessionId": "id",
3336
"update": {
3437
"sessionUpdate": "agent_message_chunk",
3538
"content": {

src/__tests__/CodexACPAgent/data/start-conversation.json

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"eventType": "request",
1818
"method": "thread/start",
1919
"params": {
20-
"config": null,
20+
"config": {},
2121
"modelProvider": null,
2222
"model": null,
2323
"cwd": "cwd",
@@ -37,6 +37,131 @@
3737
"sandbox": "sandbox",
3838
"reasoningEffort": "reasoningEffort"
3939
}
40+
{
41+
"eventType": "request",
42+
"method": "model/list",
43+
"params": {
44+
"cursor": null,
45+
"limit": null
46+
}
47+
}
48+
{
49+
"eventType": "notification",
50+
"method": "thread/started",
51+
"params": {
52+
"thread": "thread"
53+
},
54+
"jsonrpc": "2.0"
55+
}
56+
{
57+
"eventType": "notification",
58+
"method": "codex/event/mcp_startup_complete",
59+
"params": {
60+
"id": "id",
61+
"msg": {
62+
"type": "mcp_startup_complete",
63+
"ready": [],
64+
"failed": [],
65+
"cancelled": []
66+
},
67+
"conversationId": "conversationId"
68+
},
69+
"jsonrpc": "2.0"
70+
}
71+
{
72+
"eventType": "response",
73+
"data": [
74+
{
75+
"id": "id",
76+
"model": "gpt-5.1-codex-max",
77+
"displayName": "gpt-5.1-codex-max",
78+
"description": "Latest Codex-optimized flagship for deep and fast reasoning.",
79+
"supportedReasoningEfforts": [
80+
{
81+
"reasoningEffort": "reasoningEffort",
82+
"description": "Fast responses with lighter reasoning"
83+
},
84+
{
85+
"reasoningEffort": "reasoningEffort",
86+
"description": "Balances speed and reasoning depth for everyday tasks"
87+
},
88+
{
89+
"reasoningEffort": "reasoningEffort",
90+
"description": "Maximizes reasoning depth for complex problems"
91+
},
92+
{
93+
"reasoningEffort": "reasoningEffort",
94+
"description": "Extra high reasoning depth for complex problems"
95+
}
96+
],
97+
"defaultReasoningEffort": "medium",
98+
"isDefault": true
99+
},
100+
{
101+
"id": "id",
102+
"model": "gpt-5.1-codex",
103+
"displayName": "gpt-5.1-codex",
104+
"description": "Optimized for codex.",
105+
"supportedReasoningEfforts": [
106+
{
107+
"reasoningEffort": "reasoningEffort",
108+
"description": "Fastest responses with limited reasoning"
109+
},
110+
{
111+
"reasoningEffort": "reasoningEffort",
112+
"description": "Dynamically adjusts reasoning based on the task"
113+
},
114+
{
115+
"reasoningEffort": "reasoningEffort",
116+
"description": "Maximizes reasoning depth for complex or ambiguous problems"
117+
}
118+
],
119+
"defaultReasoningEffort": "medium",
120+
"isDefault": false
121+
},
122+
{
123+
"id": "id",
124+
"model": "gpt-5.1-codex-mini",
125+
"displayName": "gpt-5.1-codex-mini",
126+
"description": "Optimized for codex. Cheaper, faster, but less capable.",
127+
"supportedReasoningEfforts": [
128+
{
129+
"reasoningEffort": "reasoningEffort",
130+
"description": "Dynamically adjusts reasoning based on the task"
131+
},
132+
{
133+
"reasoningEffort": "reasoningEffort",
134+
"description": "Maximizes reasoning depth for complex or ambiguous problems"
135+
}
136+
],
137+
"defaultReasoningEffort": "medium",
138+
"isDefault": false
139+
},
140+
{
141+
"id": "id",
142+
"model": "gpt-5.1",
143+
"displayName": "gpt-5.1",
144+
"description": "Broad world knowledge with strong general reasoning.",
145+
"supportedReasoningEfforts": [
146+
{
147+
"reasoningEffort": "reasoningEffort",
148+
"description": "Balances speed with some reasoning; useful for straightforward queries and short explanations"
149+
},
150+
{
151+
"reasoningEffort": "reasoningEffort",
152+
"description": "Provides a solid balance of reasoning depth and latency for general-purpose tasks"
153+
},
154+
{
155+
"reasoningEffort": "reasoningEffort",
156+
"description": "Maximizes reasoning depth for complex or ambiguous problems"
157+
}
158+
],
159+
"defaultReasoningEffort": "medium",
160+
"isDefault": false
161+
}
162+
],
163+
"nextCursor": null
164+
}
40165
{
41166
"eventType": "request",
42167
"method": "turn/start",

0 commit comments

Comments
 (0)