Skip to content
Open
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
4 changes: 2 additions & 2 deletions readme-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Run from sources

Run from binaries

1. Download a `codex-acp-<platform>.zip` archive from https://github.com/agentclientprotocol/codex-acp/releases
1. Download a `codex-acp-<platform>.zip` archive from https://github.com/agentclientprotocol/codex-acp/releases (`<platform>` is one of: `linux`, `darwin`, `win32`)
2. Unzip the archive:
```bash
unzip codex-acp-<platform>.zip
Expand Down Expand Up @@ -69,6 +69,6 @@ npm run package:all

### Update supported Codex version

1. Update Codex dependency: `package.json`
1. Update the `@openai/codex` version in `package.json` (under `dependencies`).
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`
4 changes: 2 additions & 2 deletions src/CodexAcpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class CodexAcpClient {
case "gateway":
if (!authRequest._meta) throw RequestError.invalidRequest();

const gatewaySettings = authRequest._meta["gateway"]
const gatewaySettings = authRequest._meta["gateway"];
if (!gatewaySettings) throw RequestError.invalidRequest();

const baseUrl = gatewaySettings.baseUrl;
Expand All @@ -127,7 +127,7 @@ export class CodexAcpClient {
http_headers: headers,
wire_api: "responses"
}
}
};

// Early return: model provider information will be sent to Codex later during the session creation
return true;
Expand Down
10 changes: 5 additions & 5 deletions src/CodexAcpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export class CodexAcpServer {
let sessionMetadata: SessionMetadata;
let resumeSubscribed = false;
if ("sessionId" in request) {
logger.log(`Resume existing session: ${request.sessionId}...`)
logger.log(`Resume existing session: ${request.sessionId}...`);
try {
sessionMetadata = await this.runWithProcessCheck(() =>
this.codexAcpClient.resumeSession(request, () => {
Expand All @@ -337,7 +337,7 @@ export class CodexAcpServer {
throw err;
}
} else {
logger.log(`Create new session...`)
logger.log(`Create new session...`);
sessionMetadata = await this.runWithProcessCheck(() => this.codexAcpClient.newSession(request));
}

Expand Down Expand Up @@ -378,7 +378,7 @@ export class CodexAcpServer {
currentModelSupportsFast: currentModelSupportsFast,
sessionMcpServers: sessionMcpServers,
terminalOutputMode: this.terminalOutputMode,
}
};
this.sessions.set(sessionId, sessionState);
resumeSubscribed = false;

Expand Down Expand Up @@ -1318,7 +1318,7 @@ export class CodexAcpServer {
_meta: this.buildQuotaMeta(sessionState),
};
}
const error = eventHandler.getFailure()
const error = eventHandler.getFailure();
if (error) {
// noinspection ExceptionCaughtLocallyJS
throw error;
Expand Down Expand Up @@ -1420,7 +1420,7 @@ export class CodexAcpServer {
};
}

const error = eventHandler.getFailure()
const error = eventHandler.getFailure();
if (error) {
// noinspection ExceptionCaughtLocallyJS
throw error;
Expand Down
1 change: 0 additions & 1 deletion src/CodexEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {
ServerNotification
} from "./app-server";
import type {SessionState} from "./CodexAcpServer";
import * as acp from "@agentclientprotocol/sdk";
import {type PlanEntry, RequestError} from "@agentclientprotocol/sdk";
import {ACPSessionConnection, type AcpClientConnection, type UpdateSessionEvent} from "./ACPSessionConnection";
import type {
Expand Down
2 changes: 1 addition & 1 deletion src/CodexJsonRpcConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface CodexConnection {
export function startCodexConnection(codexPath?: string, env?: NodeJS.ProcessEnv): CodexConnection {
const spawnEnv = env ?? process.env;

let codex: ChildProcessWithoutNullStreams
let codex: ChildProcessWithoutNullStreams;
if (codexPath) {
codex = process.platform === 'win32'
? spawn(`"${codexPath}" app-server`, { shell: true, env: spawnEnv })
Expand Down
3 changes: 1 addition & 2 deletions src/ResponseItemHistoryFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -975,8 +975,7 @@ function sedFileArguments(args: string[]): string[] {
}

function looksLikeSedRangeScript(arg: string): boolean {
return /^(\d+|\$)?(,(\d+|\$))?[pd]$/.test(arg)
|| /^(\d+|\$)?(,(\d+|\$))?p$/.test(arg);
return /^(\d+|\$)?(,(\d+|\$))?[pd]$/.test(arg);
}

function headTailFileArguments(args: string[]): string[] {
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/CodexACPAgent/CodexAcpClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ describe('ACP server test', { timeout: 40_000 }, () => {

keyFixture.clearCodexConnectionDump();

const authRequest: CodexAuthRequest = { methodId: "api-key", _meta: { "api-key": { apiKey: "TOKEN" }}}
const authRequest: CodexAuthRequest = { methodId: "api-key", _meta: { "api-key": { apiKey: "TOKEN" }}};
await codexAcpAgent.authenticate(authRequest);
const newSessionResponse = await codexAcpAgent.newSession({cwd: "", mcpServers: []});
expect(newSessionResponse.sessionId).toBeDefined()
expect(newSessionResponse.sessionId).toBeDefined();

const transportEvents = keyFixture.getCodexConnectionEvents([...ignoredFields, "upgrade"]);
const transportMethods = transportEvents.flatMap(event => "method" in event ? [event.method] : []);
Expand Down Expand Up @@ -149,8 +149,8 @@ describe('ACP server test', { timeout: 40_000 }, () => {
expect(authenticatedResponse).toEqual({type: "gateway", name: "custom-gateway"});

const newSessionResponse = await codexAcpAgent.newSession({cwd: "", mcpServers: []});
expect(newSessionResponse.sessionId).toBeDefined()
})
expect(newSessionResponse.sessionId).toBeDefined();
});

it('should show account in /status for api key auth and hide it for gateway auth', async () => {
const authFixture = createTestFixture();
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function startAcpServer() {
stderr = (stderr + data.toString()).slice(-maxStderrTailChars);
});

process.stdin.on("close", (chunk: Buffer) => {
process.stdin.on("close", () => {
codexConnection.process.stdin.end();
// Kill the codex process if it doesn't exit naturally
setTimeout(() => {
Expand Down
Loading