Skip to content
Korus-DevPublic

About

TypeScript SDK for building apps on Codex, with streaming conversations, approvals, tools, and Node.js app-server transports.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

Repository files navigation

Codex SDK

Build Node.js applications on the Codex app-server.

A typed TypeScript client for streaming conversations, responding to approvals, and connecting your tools to Codex. Bring your own application state and interface—the SDK handles the protocol and connection.

npm version CI Documentation License Node.js

Documentation → · Getting started · API reference · Contributing

What you get

  • Typed requests and events. Parameters, results, notifications, and tool responses follow the Codex app-server schema.
  • Streaming conversations. Start and resume threads, submit turns, and receive incremental output.
  • Approvals and tools. Respond to server requests with your application's authorization policy.
  • Two ways to connect. Launch an app-server over stdio or attach to an existing Unix control socket.
  • Request diagnostics. Observe outcomes and timings without collecting protocol payloads.
  • Zero runtime dependencies. ESM built on Node.js, with TypeScript declarations for bundler-based projects.

This is an independently maintained SDK, separate from OpenAI's official SDKs.

Use multi-agent-sdk for a provider-neutral agent API and agent-ui-sdk for Vue conversation components and Electron integration.

Install

npm install @korus-dev/codex-sdk

Requires Node.js 22.19.0 or newer and a separately installed Codex CLI. TypeScript projects also need @types/node. Use ESM ("type": "module" in your app's package.json).

The generated protocol targets Codex CLI 0.167.0, including experimental APIs. Feature availability depends on the running server and its configuration.

Your first conversation

With Codex installed and authenticated, stream your first reply:

import { CodexAppServerClient, CodexAppServerStdioTransport } from '@korus-dev/codex-sdk';

const client = new CodexAppServerClient(new CodexAppServerStdioTransport());
client.onNotification('item/agentMessage/delta', ({ params }) => {
  process.stdout.write(params.delta);
});

await client.start();
try {
  await client.initialize({
    clientInfo: { name: 'hello_codex', title: null, version: '1.0.0' },
    capabilities: null,
  });
  const { thread } = await client.request('thread/start', {});
  const finished = new Promise<void>(resolve => {
    client.onNotification('turn/completed', () => resolve());
  });
  await client.request('turn/start', {
    threadId: thread.id,
    input: [{ type: 'text', text: 'Say hello!', text_elements: [] }],
  });
  await finished;
} finally {
  await client.close();
}

The SDK finds Codex automatically and uses your current directory. See the full conversation guide for approvals, deadlines, and connection recovery.

Connect your way

Transport Use it when Lifecycle
CodexAppServerStdioTransport Your app should launch its own Codex process Closing the transport stops its child
CodexAppServerUnixSocketTransport An app-server is already running Closing disconnects this client and leaves the server running

Configure command, cwd, codexHome, environment variables, and Codex overrides in your trusted Node.js host. There are no implicit feature flags. Set executableDiscovery: false when you want only your supplied command and environment.

See Connect to Codex to choose a transport, and transports and executable discovery for every option and custom transports.

Go further

Build Guide
Live rendering of turns Stream events
History and thread resumption Threads and turns
Crash and disconnect handling Reconnect and recover
Account and sign-in flows Authentication
App-owned tools and approval handling Approvals and tools
External tool services MCP servers
Pairing and remote connections Remote control
Every typed protocol method Protocol inventory

Import runtime APIs and types from @korus-dev/codex-sdk. See the export reference for the complete API and generated types.

Development

npm ci
npm run check

Development uses Node.js 26.12.1, pinned in .node-version. check runs typechecks, tests with coverage, the package build, a packed-consumer check, and the VitePress build. Preview the VitePress documentation with npm run dev:docs.

See the development guide for schema generation, CLI verification, and release workflows.

Contributing

Issues and pull requests are welcome. Read CONTRIBUTING.md, or open an issue for bugs and questions.

License and security

Released under Apache-2.0. See CHANGELOG.md for release notes and SECURITY.md to report vulnerabilities privately.

About

TypeScript SDK for building apps on Codex, with streaming conversations, approvals, tools, and Node.js app-server transports.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages