Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"license": "ISC",
"type": "module",
"devDependencies": {
"@openai/codex": "^0.114.0",
"@openai/codex": "^0.117.0",
"@types/node": "^24.10.1",
"mcp-hello-world": "^1.1.2",
"tsx": "^4.20.6",
Expand Down
7 changes: 6 additions & 1 deletion readme-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ npm run package:all

1. Update Codex dependency: `package.json`
2. Regenerate Codex types in `src/app-server/`: `npm run generate-types`
3. Ensure there are no type errors or failed tests: `npm run typecheck` and `npm run test`
3. Ensure there are no type errors or failed tests: `npm run typecheck` and `npm run test`

### Integration test toggle

- `CODEX_INTEGRATION_TESTS=1` enables tests that require running a real Codex process and external auth/runtime behavior.
- By default, these tests are skipped to keep local/CI test runs deterministic in sandboxed environments.
2 changes: 2 additions & 0 deletions src/CodexAcpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ export class CodexAcpServer implements acp.Agent {
switch (item.type) {
case "userMessage":
return this.createUserMessageUpdates(item);
case "hookPrompt":
return [];
case "agentMessage":
return [{
sessionUpdate: "agent_message_chunk",
Expand Down
8 changes: 8 additions & 0 deletions src/CodexEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export class CodexEventHandler {
case "turn/completed":
this.sessionState.currentTurnId = null;
return null;
case "item/autoApprovalReview/started":
case "item/autoApprovalReview/completed":
return null;
case "thread/tokenUsage/updated":
this.handleTokenUsageUpdated(notification.params);
return null;
Expand All @@ -102,6 +105,7 @@ export class CodexEventHandler {
case "item/mcpToolCall/progress":
case "serverRequest/resolved":
case "account/updated":
case "fs/changed":
return null;
case "account/rateLimits/updated":
this.handleRateLimitsUpdated(notification.params);
Expand Down Expand Up @@ -131,11 +135,13 @@ export class CodexEventHandler {
case "skills/changed":
case "deprecationNotice":
case "mcpServer/oauthLogin/completed":
case "mcpServer/startupStatus/updated":
case "rawResponseItem/completed":
case "thread/started":
case "thread/name/updated":
case "item/plan/delta":
case "app/list/updated":
case "thread/realtime/transcriptUpdated":
return null;
case "model/rerouted":
return this.createModelReroutedEvent(notification.params);
Expand Down Expand Up @@ -189,6 +195,7 @@ export class CodexEventHandler {
return await createDynamicToolCallUpdate(event.item);
case "collabAgentToolCall":
case "userMessage":
case "hookPrompt":
case "agentMessage":
case "reasoning":
case "webSearch":
Expand Down Expand Up @@ -226,6 +233,7 @@ export class CodexEventHandler {
}
case "collabAgentToolCall":
case "userMessage":
case "hookPrompt":
case "agentMessage":
case "webSearch":
case "imageView":
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/CodexACPAgent/CodexAcpClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {RateLimitsMap} from "../../RateLimitsMap";
import {ModelId} from "../../ModelId";

const CODEX_HOME_ENV = "CODEX_HOME";
const integrationTest = process.env["CODEX_INTEGRATION_TESTS"] === "1" ? it : it.skip;

async function overrideCodexHome<T>(configToml: string, run: () => Promise<T>): Promise<T> {
const previousCodexHome = process.env[CODEX_HOME_ENV];
Expand Down Expand Up @@ -75,7 +76,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
});
});

it('should authenticate with key', async () => {
integrationTest('should authenticate with key', async () => {
// In sandboxed environments Codex may fail when trying to write to the OS keychain (`Operation not permitted`).
await overrideCodexHome('cli_auth_credentials_store = "file"', async () => {
const keyFixture = createTestFixture();
Expand Down Expand Up @@ -107,7 +108,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
});
});

it('should authenticate with a gateway', async () => {
integrationTest('should authenticate with a gateway', async () => {
const codexAcpAgent = fixture.getCodexAcpAgent();

await codexAcpAgent.initialize({protocolVersion: 1});
Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/CodexACPAgent/command-action-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('CodexEventHandler - command action events', () => {
command: 'ls /test/project',
cwd: '/test/project',
processId: null,
source: "agent",
status: 'inProgress',
commandActions: [
{
Expand Down Expand Up @@ -65,6 +66,7 @@ describe('CodexEventHandler - command action events', () => {
command: 'ls',
cwd: '/test/project',
processId: null,
source: "agent",
status: 'completed',
commandActions: [
{
Expand Down Expand Up @@ -99,6 +101,7 @@ describe('CodexEventHandler - command action events', () => {
command: 'rg "Service" src',
cwd: '/test/project',
processId: null,
source: "agent",
status: 'inProgress',
commandActions: [
{
Expand Down Expand Up @@ -134,6 +137,7 @@ describe('CodexEventHandler - command action events', () => {
command: 'rg "Service"',
cwd: '/test/project',
processId: null,
source: "agent",
status: 'inProgress',
commandActions: [
{
Expand Down Expand Up @@ -169,6 +173,7 @@ describe('CodexEventHandler - command action events', () => {
command: 'rg --files -g "*service*"',
cwd: '/test/project',
processId: null,
source: "agent",
status: 'inProgress',
commandActions: [
{
Expand Down Expand Up @@ -204,6 +209,7 @@ describe('CodexEventHandler - command action events', () => {
command: 'rg',
cwd: '/test/project',
processId: null,
source: "agent",
status: 'inProgress',
commandActions: [
{
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/CodexACPAgent/fuzzy-file-search-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe("CodexEventHandler - fuzzy file search events", () => {
sessionId: "search-1",
query: "event handler",
files: [
{ root: "/repo", path: "src/CodexEventHandler.ts", file_name: "CodexEventHandler.ts", score: 0.98, indices: [0, 1] },
{ root: "/repo", path: "src/CodexToolCallMapper.ts", file_name: "CodexToolCallMapper.ts", score: 0.85, indices: [2, 3] },
{ root: "/repo", path: "src/CodexEventHandler.ts", match_type: "file", file_name: "CodexEventHandler.ts", score: 0.98, indices: [0, 1] },
{ root: "/repo", path: "src/CodexToolCallMapper.ts", match_type: "file", file_name: "CodexToolCallMapper.ts", score: 0.85, indices: [2, 3] },
],
},
};
Expand All @@ -42,7 +42,7 @@ describe("CodexEventHandler - fuzzy file search events", () => {
sessionId: "search-1",
query: "event handler",
files: [
{ root: "/repo", path: "src/CodexEventHandler.ts", file_name: "CodexEventHandler.ts", score: 0.99, indices: [0, 1] },
{ root: "/repo", path: "src/CodexEventHandler.ts", match_type: "file", file_name: "CodexEventHandler.ts", score: 0.99, indices: [0, 1] },
],
},
};
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/CodexACPAgent/load-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe("CodexACPAgent - loadSession", () => {
id: "item-agent-1",
text: "Hello!",
phase: null,
memoryCitation: null,
},
{
type: "reasoning",
Expand All @@ -89,6 +90,7 @@ describe("CodexACPAgent - loadSession", () => {
command: "ls",
cwd: "/test/project",
processId: null,
source: "agent",
status: "completed",
commandActions: [],
aggregatedOutput: null,
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/CodexACPAgent/mcp-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {describe, expect, it, vi, beforeEach} from 'vitest';
import {createTestFixture, type TestFixture} from "../acp-test-utils";
import type {McpServerStdio} from "@agentclientprotocol/sdk";

const integrationTest = process.env["CODEX_INTEGRATION_TESTS"] === "1" ? it : it.skip;

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

let fixture: TestFixture;
Expand All @@ -13,7 +15,7 @@ describe('MCP session configuration', { timeout: 40_000 }, () => {
});


it('should return configured mcp', async () => {
integrationTest('should return configured mcp', async () => {
const codexAcpAgent = fixture.getCodexAcpAgent();
await codexAcpAgent.initialize({protocolVersion: 1});

Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/CodexACPAgent/terminal-output-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('CodexEventHandler - terminal output events', () => {
command: 'ls -la',
cwd: '/test/project',
processId: null,
source: "agent",
status: 'inProgress',
commandActions: [],
aggregatedOutput: null,
Expand Down Expand Up @@ -67,6 +68,7 @@ describe('CodexEventHandler - terminal output events', () => {
command,
cwd: '/test/project',
processId: null,
source: "agent",
status: 'inProgress',
commandActions: [],
aggregatedOutput: null,
Expand Down Expand Up @@ -114,6 +116,7 @@ describe('CodexEventHandler - terminal output events', () => {
command: 'ls -la',
cwd: '/test/project',
processId: 'pid-456',
source: "agent",
status: 'completed',
commandActions: [],
aggregatedOutput: 'file1.txt\nfile2.txt\nfile3.txt\n',
Expand Down Expand Up @@ -142,6 +145,7 @@ describe('CodexEventHandler - terminal output events', () => {
command: 'cat nonexistent.txt',
cwd: '/test/project',
processId: 'pid-789',
source: "agent",
status: 'failed',
commandActions: [],
aggregatedOutput: 'cat: nonexistent.txt: No such file or directory',
Expand Down Expand Up @@ -196,6 +200,7 @@ describe('CodexEventHandler - terminal output events', () => {
command: 'echo hello',
cwd: '/test/project',
processId: null,
source: "agent",
status: 'inProgress',
commandActions: [],
aggregatedOutput: null,
Expand Down Expand Up @@ -226,6 +231,7 @@ describe('CodexEventHandler - terminal output events', () => {
command: 'echo hello',
cwd: '/test/project',
processId: 'pid-123',
source: "agent",
status: 'completed',
commandActions: [],
aggregatedOutput: 'hello\n',
Expand Down
5 changes: 5 additions & 0 deletions src/app-server/AgentPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!

// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type AgentPath = string;
Loading
Loading