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
65 changes: 30 additions & 35 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 @@ -41,7 +41,7 @@
"license": "ISC",
"type": "module",
"devDependencies": {
"@openai/codex": "^0.120.0",
"@openai/codex": "^0.121.0",
"@types/node": "^24.10.1",
"esbuild": "^0.25.0",
"mcp-hello-world": "^1.1.2",
Expand Down
3 changes: 2 additions & 1 deletion src/CodexEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export class CodexEventHandler {
case "thread/closed":
case "thread/realtime/started":
case "thread/realtime/itemAdded":
case "thread/realtime/transcriptUpdated":
case "thread/realtime/transcript/delta":
case "thread/realtime/transcript/done":
case "thread/realtime/outputAudio/delta":
case "thread/realtime/sdp":
case "thread/realtime/error":
Expand Down
38 changes: 36 additions & 2 deletions src/__tests__/CodexACPAgent/mcp-session.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,48 @@
// noinspection ES6RedundantAwait

import {describe, expect, it, vi, beforeEach} from 'vitest';
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
import {createTestFixture, type TestFixture} from "../acp-test-utils";
import type {McpServerStdio} from "@agentclientprotocol/sdk";
import path from "node:path";
import fs from "node:fs";
import os from "node:os";

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

let fixture: TestFixture;
let testHomeDir: string;
let previousHome: string | undefined;
let previousCodexHome: string | undefined;

beforeEach(() => {
previousHome = process.env["HOME"];
previousCodexHome = process.env["CODEX_HOME"];
testHomeDir = fs.mkdtempSync(path.join(os.tmpdir(), "codex-acp-mcp-home-"));
process.env["HOME"] = testHomeDir;
process.env["CODEX_HOME"] = path.join(testHomeDir, ".codex");
fs.mkdirSync(process.env["CODEX_HOME"], {recursive: true});
fixture = createTestFixture();
vi.clearAllMocks();
});

afterEach(() => {
if (previousHome === undefined) {
delete process.env["HOME"];
} else {
process.env["HOME"] = previousHome;
}
if (previousCodexHome === undefined) {
delete process.env["CODEX_HOME"];
} else {
process.env["CODEX_HOME"] = previousCodexHome;
}
try {
fs.rmSync(testHomeDir, {recursive: true, force: true});
} catch {
// Best-effort cleanup; Codex background writes can keep files transiently busy.
}
});


it('should return configured mcp', async () => {
const codexAcpAgent = fixture.getCodexAcpAgent();
Expand All @@ -22,7 +53,10 @@ describe('MCP session configuration', { timeout: 40_000 }, () => {
name: "test-mcp", command: "./node_modules/.bin/mcp-hello-world", args: ["example"], env: [{name:"example", value: "example"}]
};

const newSessionResponse = await codexAcpAgent.newSession({cwd: "", mcpServers: [mcpServer]});
const newSessionResponse = await codexAcpAgent.newSession({
cwd: path.resolve(process.cwd()),
mcpServers: [mcpServer]
});
fixture.clearAcpConnectionDump();
await codexAcpAgent.prompt({sessionId: newSessionResponse.sessionId, prompt: [{type: "text", text: "/mcp"}]});
const transportDump = fixture.getAcpConnectionDump([]);
Expand Down
2 changes: 1 addition & 1 deletion src/app-server/AgentMessageItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { MessagePhase } from "./MessagePhase";
* should use it when present, but retain legacy completion semantics when it
* is `None`.
*/
export type AgentMessageItem = { id: string, content: Array<AgentMessageContent>,
export type AgentMessageItem = { id: string, content: Array<AgentMessageContent>,
/**
* Optional phase metadata carried through from `ResponseItem::Message`.
*
Expand Down
6 changes: 3 additions & 3 deletions src/app-server/ApplyPatchApprovalParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import type { FileChange } from "./FileChange";
import type { ThreadId } from "./ThreadId";

export type ApplyPatchApprovalParams = { conversationId: ThreadId,
export type ApplyPatchApprovalParams = { conversationId: ThreadId,
/**
* Use to correlate this with [codex_protocol::protocol::PatchApplyBeginEvent]
* and [codex_protocol::protocol::PatchApplyEndEvent].
*/
callId: string, fileChanges: { [key in string]?: FileChange },
callId: string, fileChanges: { [key in string]?: FileChange },
/**
* Optional explanatory reason (e.g. request for extra write access).
*/
reason: string | null,
reason: string | null,
/**
* When set, the agent is asking the user to allow writes under this root
* for the remainder of the session (unclear if this is honored today).
Expand Down
8 changes: 4 additions & 4 deletions src/app-server/ApplyPatchApprovalRequestEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FileChange } from "./FileChange";

export type ApplyPatchApprovalRequestEvent = {
export type ApplyPatchApprovalRequestEvent = {
/**
* Responses API call id for the associated patch apply call, if available.
*/
call_id: string,
call_id: string,
/**
* Turn ID that this patch belongs to.
* Uses `#[serde(default)]` for backwards compatibility with older senders.
*/
turn_id: string, changes: { [key in string]?: FileChange },
turn_id: string, changes: { [key in string]?: FileChange },
/**
* Optional explanatory reason (e.g. request for extra write access).
*/
reason: string | null,
reason: string | null,
/**
* When set, the agent is asking the user to allow writes under this root for the remainder of the session.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/app-server/ByteRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

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

export type ByteRange = {
export type ByteRange = {
/**
* Start byte offset (inclusive) within the UTF-8 text buffer.
*/
start: number,
start: number,
/**
* End byte offset (exclusive) within the UTF-8 text buffer.
*/
Expand Down
Loading
Loading