Phase 4: TypeScript/Node.js Components

Updated all TypeScript and JavaScript source files:

- Renamed sdk/typescript/src/codex.ts → llmx.ts
- Renamed sdk/typescript/src/codexOptions.ts → llmxOptions.ts
- Updated class names: Codex → LLMX, CodexExec → LLMXExec, CodexOptions → LLMXOptions
- Updated property names: codexPathOverride → llmxPathOverride
- Updated package imports: @openai/codex-sdk → @llmx/llmx-sdk
- Updated all references in sample files and tests
- Renamed responses-api-proxy binary: codex-responses-api-proxy.js → llmx-responses-api-proxy.js
- Updated comments referencing Codex → LLMX
- Updated session path references: ~/.codex → ~/.llmx

Files changed: 16 TypeScript/JavaScript files across SDK, samples, and tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Sebastian Krüger
2025-11-11 14:43:58 +01:00
parent a6c537ac50
commit 0c2c36e14e
16 changed files with 81 additions and 81 deletions

View File

@@ -3,12 +3,12 @@
import { createInterface } from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
import { Codex } from "@openai/codex-sdk";
import type { ThreadEvent, ThreadItem } from "@openai/codex-sdk";
import { codexPathOverride } from "./helpers.ts";
import { LLMX } from "@llmx/llmx-sdk";
import type { ThreadEvent, ThreadItem } from "@llmx/llmx-sdk";
import { llmxPathOverride } from "./helpers.ts";
const codex = new Codex({ codexPathOverride: codexPathOverride() });
const thread = codex.startThread();
const llmx = new LLMX({ llmxPathOverride: llmxPathOverride() });
const thread = llmx.startThread();
const rl = createInterface({ input, output });
const handleItemCompleted = (item: ThreadItem): void => {

View File

@@ -1,8 +1,8 @@
import path from "node:path";
export function codexPathOverride() {
export function llmxPathOverride() {
return (
process.env.CODEX_EXECUTABLE ??
path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex")
path.join(process.cwd(), "..", "..", "llmx-rs", "target", "debug", "llmx")
);
}

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
import { Codex } from "@openai/codex-sdk";
import { LLMX } from "@llmx/llmx-sdk";
import { codexPathOverride } from "./helpers.ts";
import { llmxPathOverride } from "./helpers.ts";
const codex = new Codex({ codexPathOverride: codexPathOverride() });
const llmx = new LLMX({ llmxPathOverride: llmxPathOverride() });
const thread = codex.startThread();
const thread = llmx.startThread();
const schema = {
type: "object",

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env -S NODE_NO_WARNINGS=1 pnpm ts-node-esm --files
import { Codex } from "@openai/codex-sdk";
import { codexPathOverride } from "./helpers.ts";
import { LLMX } from "@llmx/llmx-sdk";
import { llmxPathOverride } from "./helpers.ts";
import z from "zod";
import zodToJsonSchema from "zod-to-json-schema";
const codex = new Codex({ codexPathOverride: codexPathOverride() });
const thread = codex.startThread();
const llmx = new LLMX({ llmxPathOverride: llmxPathOverride() });
const thread = llmx.startThread();
const schema = z.object({
summary: z.string(),

View File

@@ -1,5 +0,0 @@
export type CodexOptions = {
codexPathOverride?: string;
baseUrl?: string;
apiKey?: string;
};

View File

@@ -1,4 +1,4 @@
// based on event types from codex-rs/exec/src/exec_events.rs
// based on event types from llmx-rs/exec/src/exec_events.rs
import type { ThreadItem } from "./items";
@@ -68,7 +68,7 @@ export type ThreadErrorEvent = {
message: string;
};
/** Top-level JSONL events emitted by codex exec. */
/** Top-level JSONL events emitted by llmx exec. */
export type ThreadEvent =
| ThreadStartedEvent
| TurnStartedEvent

View File

@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
import { SandboxMode, ModelReasoningEffort, ApprovalMode } from "./threadOptions";
export type CodexExecArgs = {
export type LLMXExecArgs = {
input: string;
baseUrl?: string;
@@ -35,13 +35,13 @@ export type CodexExecArgs = {
const INTERNAL_ORIGINATOR_ENV = "CODEX_INTERNAL_ORIGINATOR_OVERRIDE";
const TYPESCRIPT_SDK_ORIGINATOR = "codex_sdk_ts";
export class CodexExec {
export class LLMXExec {
private executablePath: string;
constructor(executablePath: string | null = null) {
this.executablePath = executablePath || findCodexPath();
}
async *run(args: CodexExecArgs): AsyncGenerator<string> {
async *run(args: LLMXExecArgs): AsyncGenerator<string> {
const commandArgs: string[] = ["exec", "--experimental-json"];
if (args.model) {
@@ -147,7 +147,7 @@ export class CodexExec {
} else {
const stderrBuffer = Buffer.concat(stderrChunks);
reject(
new Error(`Codex Exec exited with code ${code}: ${stderrBuffer.toString("utf8")}`),
new Error(`LLMX Exec exited with code ${code}: ${stderrBuffer.toString("utf8")}`),
);
}
});
@@ -222,8 +222,8 @@ function findCodexPath() {
const vendorRoot = path.join(scriptDirName, "..", "vendor");
const archRoot = path.join(vendorRoot, targetTriple);
const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
const binaryPath = path.join(archRoot, "codex", codexBinaryName);
const codexBinaryName = process.platform === "win32" ? "llmx.exe" : "llmx";
const binaryPath = path.join(archRoot, "llmx", codexBinaryName);
return binaryPath;
}

View File

@@ -26,9 +26,9 @@ export type {
export { Thread } from "./thread";
export type { RunResult, RunStreamedResult, Input, UserInput } from "./thread";
export { Codex } from "./codex";
export { LLMX } from "./llmx";
export type { CodexOptions } from "./codexOptions";
export type { LLMXOptions } from "./llmxOptions";
export type {
ThreadOptions,

View File

@@ -1,4 +1,4 @@
// based on item types from codex-rs/exec/src/exec_events.rs
// based on item types from llmx-rs/exec/src/exec_events.rs
import type { ContentBlock as McpContentBlock } from "@modelcontextprotocol/sdk/types.js";

View File

@@ -1,19 +1,19 @@
import { CodexOptions } from "./codexOptions";
import { CodexExec } from "./exec";
import { LLMXOptions } from "./llmxOptions";
import { LLMXExec } from "./exec";
import { Thread } from "./thread";
import { ThreadOptions } from "./threadOptions";
/**
* Codex is the main class for interacting with the Codex agent.
* LLMX is the main class for interacting with the LLMX agent.
*
* Use the `startThread()` method to start a new thread or `resumeThread()` to resume a previously started thread.
*/
export class Codex {
private exec: CodexExec;
private options: CodexOptions;
export class LLMX {
private exec: LLMXExec;
private options: LLMXOptions;
constructor(options: CodexOptions = {}) {
this.exec = new CodexExec(options.codexPathOverride);
constructor(options: LLMXOptions = {}) {
this.exec = new LLMXExec(options.llmxPathOverride);
this.options = options;
}
@@ -27,7 +27,7 @@ export class Codex {
/**
* Resumes a conversation with an agent based on the thread id.
* Threads are persisted in ~/.codex/sessions.
* Threads are persisted in ~/.llmx/sessions.
*
* @param id The id of the thread to resume.
* @returns A new thread instance.

View File

@@ -0,0 +1,5 @@
export type LLMXOptions = {
llmxPathOverride?: string;
baseUrl?: string;
apiKey?: string;
};

View File

@@ -16,7 +16,7 @@ export async function createOutputSchemaFile(schema: unknown): Promise<OutputSch
throw new Error("outputSchema must be a plain JSON object");
}
const schemaDir = await fs.mkdtemp(path.join(os.tmpdir(), "codex-output-schema-"));
const schemaDir = await fs.mkdtemp(path.join(os.tmpdir(), "llmx-output-schema-"));
const schemaPath = path.join(schemaDir, "schema.json");
const cleanup = async () => {
try {

View File

@@ -1,6 +1,6 @@
import { CodexOptions } from "./codexOptions";
import { LLMXOptions } from "./llmxOptions";
import { ThreadEvent, ThreadError, Usage } from "./events";
import { CodexExec } from "./exec";
import { LLMXExec } from "./exec";
import { ThreadItem } from "./items";
import { ThreadOptions } from "./threadOptions";
import { TurnOptions } from "./turnOptions";
@@ -39,8 +39,8 @@ export type Input = string | UserInput[];
/** Respesent a thread of conversation with the agent. One thread can have multiple consecutive turns. */
export class Thread {
private _exec: CodexExec;
private _options: CodexOptions;
private _exec: LLMXExec;
private _options: LLMXOptions;
private _id: string | null;
private _threadOptions: ThreadOptions;
@@ -51,8 +51,8 @@ export class Thread {
/* @internal */
constructor(
exec: CodexExec,
options: CodexOptions,
exec: LLMXExec,
options: LLMXOptions,
threadOptions: ThreadOptions,
id: string | null = null,
) {

View File

@@ -5,7 +5,7 @@ import path from "node:path";
import { codexExecSpy } from "./codexExecSpy";
import { describe, expect, it } from "@jest/globals";
import { Codex } from "../src/codex";
import { LLMX } from "../src/llmx";
import {
assistantMessage,
@@ -16,9 +16,9 @@ import {
startResponsesTestProxy,
} from "./responsesProxy";
const codexExecPath = path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex");
const codexExecPath = path.join(process.cwd(), "..", "..", "llmx-rs", "target", "debug", "llmx");
describe("Codex", () => {
describe("LLMX", () => {
it("returns thread events", async () => {
const { url, close } = await startResponsesTestProxy({
statusCode: 200,
@@ -26,7 +26,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
const result = await thread.run("Hello, world!");
@@ -68,7 +68,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
await thread.run("first input");
@@ -111,7 +111,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
await thread.run("first input");
@@ -155,7 +155,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const originalThread = client.startThread();
await originalThread.run("first input");
@@ -199,7 +199,7 @@ describe("Codex", () => {
const { args: spawnArgs, restore } = codexExecSpy();
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread({
model: "gpt-test-1",
@@ -238,7 +238,7 @@ describe("Codex", () => {
const { args: spawnArgs, restore } = codexExecSpy();
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread({
modelReasoningEffort: "high",
@@ -269,7 +269,7 @@ describe("Codex", () => {
const { args: spawnArgs, restore } = codexExecSpy();
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread({
networkAccessEnabled: true,
@@ -300,7 +300,7 @@ describe("Codex", () => {
const { args: spawnArgs, restore } = codexExecSpy();
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread({
webSearchEnabled: true,
@@ -331,7 +331,7 @@ describe("Codex", () => {
const { args: spawnArgs, restore } = codexExecSpy();
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread({
approvalPolicy: "on-request",
@@ -371,7 +371,7 @@ describe("Codex", () => {
} as const;
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
await thread.run("structured", { outputSchema: schema });
@@ -416,7 +416,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
await thread.run([
@@ -445,7 +445,7 @@ describe("Codex", () => {
});
const { args: spawnArgs, restore } = codexExecSpy();
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "codex-images-"));
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "llmx-images-"));
const imagesDirectoryEntries: [string, string] = [
path.join(tempDir, "first.png"),
path.join(tempDir, "second.jpg"),
@@ -455,7 +455,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
await thread.run([
@@ -494,9 +494,9 @@ describe("Codex", () => {
const { args: spawnArgs, restore } = codexExecSpy();
try {
const workingDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "codex-working-dir-"));
const client = new Codex({
codexPathOverride: codexExecPath,
const workingDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "llmx-working-dir-"));
const client = new LLMX({
llmxPathOverride: codexExecPath,
baseUrl: url,
apiKey: "test",
});
@@ -528,9 +528,9 @@ describe("Codex", () => {
});
try {
const workingDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "codex-working-dir-"));
const client = new Codex({
codexPathOverride: codexExecPath,
const workingDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "llmx-working-dir-"));
const client = new LLMX({
llmxPathOverride: codexExecPath,
baseUrl: url,
apiKey: "test",
});
@@ -546,14 +546,14 @@ describe("Codex", () => {
}
});
it("sets the codex sdk originator header", async () => {
it("sets the llmx sdk originator header", async () => {
const { url, close, requests } = await startResponsesTestProxy({
statusCode: 200,
responseBodies: [sse(responseStarted(), assistantMessage("Hi!"), responseCompleted())],
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
await thread.run("Hello, originator!");
@@ -579,7 +579,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
await expect(thread.run("fail")).rejects.toThrow("stream disconnected before completion:");
} finally {

View File

@@ -2,7 +2,7 @@ import path from "node:path";
import { describe, expect, it } from "@jest/globals";
import { Codex } from "../src/codex";
import { LLMX } from "../src/llmx";
import { ThreadEvent } from "../src/index";
import {
@@ -13,9 +13,9 @@ import {
startResponsesTestProxy,
} from "./responsesProxy";
const codexExecPath = path.join(process.cwd(), "..", "..", "codex-rs", "target", "debug", "codex");
const codexExecPath = path.join(process.cwd(), "..", "..", "llmx-rs", "target", "debug", "llmx");
describe("Codex", () => {
describe("LLMX", () => {
it("returns thread events", async () => {
const { url, close } = await startResponsesTestProxy({
statusCode: 200,
@@ -23,7 +23,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
const result = await thread.runStreamed("Hello, world!");
@@ -82,7 +82,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
const first = await thread.runStreamed("first input");
@@ -128,7 +128,7 @@ describe("Codex", () => {
});
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const originalThread = client.startThread();
const first = await originalThread.runStreamed("first input");
@@ -180,7 +180,7 @@ describe("Codex", () => {
} as const;
try {
const client = new Codex({ codexPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const client = new LLMX({ llmxPathOverride: codexExecPath, baseUrl: url, apiKey: "test" });
const thread = client.startThread();
const streamed = await thread.runStreamed("structured", { outputSchema: schema });