Files
zeekayandGitHub 8849eef91e release: name the repository the run is in (hanzoai/dev is the app now) (#26)
* release: name the repository the run is in, not the one it was (hanzoai/dev is the app now)

The release API calls, the Homebrew formula, the npm fallback download and the
Windows diagnose script named hanzoai/dev. That name now belongs to the app, so
a run uploaded into a release that is not there. The workflow and the formula
read GITHUB_REPOSITORY; the shipped files name hanzoai/dev-v1.

Claude-Session: https://claude.ai/code/session_015XYKLn69gF4x75RWePpDBV

* The repository is hanzoai/dev-v1: clone URLs, the npm download, the formula, crate and package metadata

hanzoai/dev is the app now. npm/bin/coder.js and the committed formula still
downloaded releases from it.

Claude-Session: https://claude.ai/code/session_015XYKLn69gF4x75RWePpDBV
2026-11-21 01:58:51 -08:00
..
2025-09-29 13:27:13 -07:00

Codex SDK

Embed the Codex agent in your workflows and apps.

The TypeScript SDK wraps the codex CLI from @openai/codex. It spawns the CLI and exchanges JSONL events over stdin/stdout.

Installation

npm install @openai/codex-sdk

Requires Node.js 18+.

Quickstart

import { Codex } from "@openai/codex-sdk";

const codex = new Codex();
const thread = codex.startThread();
const turn = await thread.run("Diagnose the test failure and propose a fix");

console.log(turn.finalResponse);
console.log(turn.items);

Call run() repeatedly on the same Thread instance to continue that conversation.

const nextTurn = await thread.run("Implement the fix");

Streaming responses

run() buffers events until the turn finishes. To react to intermediate progress—tool calls, streaming responses, and file diffs—use runStreamed() instead, which returns an async generator of structured events.

const { events } = await thread.runStreamed("Diagnose the test failure and propose a fix");

for await (const event of events) {
  switch (event.type) {
    case "item.completed":
      console.log("item", event.item);
      break;
    case "turn.completed":
      console.log("usage", event.usage);
      break;
  }
}

Resuming an existing thread

Threads are persisted in ~/.codex/sessions. If you lose the in-memory Thread object, reconstruct it with resumeThread() and keep going.

const savedThreadId = process.env.DEV_THREAD_ID!;
const thread = codex.resumeThread(savedThreadId);
await thread.run("Implement the fix");

Working directory controls

Codex runs in the current working directory by default. To avoid unrecoverable errors, Codex requires the working directory to be a Git repository. You can skip the Git repository check by passing the skipGitRepoCheck option when creating a thread.

const thread = codex.startThread({
  workingDirectory: "/path/to/project",
  skipGitRepoCheck: true,
});