Node.js client for controlling Codex CLI app-server over JSON-RPC.
npm install @raylin01/codex-client- Node.js 18+
- Codex CLI available on your PATH (or pass
codexPath)
import { CodexClient } from '@raylin01/codex-client';
const client = new CodexClient({ cwd: process.cwd() });
client.on('ready', () => console.log('Codex app-server ready'));
client.on('notification', (notification) => {
console.log('Notification:', notification.method);
});
await client.start();
const threads = await client.listThreads();
console.log('threads', threads.data?.length ?? 0);
await client.shutdown();ready: initialize handshake completerequest: incoming JSON-RPC server request requiring a responsenotification: incoming JSON-RPC notificationlog: stderr output from app-servererror: protocol/process errors
cwd,codexPath,args,envanalyticsDefaultEnabledclientInfoandcapabilities
start()andshutdown()sendRequest(method, params)sendResponse(id, result)sendError(id, error)
- Threads:
startThread,resumeThread,forkThread,listThreads,readThread, ... - Models:
listModels,setDefaultModel - Config:
readConfig,writeConfigValue,batchWriteConfig - Turns:
startTurn,interruptTurn
See /examples:
basic.tsevents.tserror-handling.ts
- If startup fails, verify
codex app-serverruns from your shell. - Listen for
loganderrorevents to debug handshake failures.
This package uses independent semver releases.
DisCode uses this package as a real-world integration example:
ISC