Skip to content
Merged
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
2 changes: 0 additions & 2 deletions bunfig.toml

This file was deleted.

73 changes: 73 additions & 0 deletions e2e/live.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Live calls against the ChatGPT Codex backend. Opt in by setting both
// CODEX_LIVE_ACCESS_TOKEN (a "Login with ChatGPT" access token) and
// CODEX_LIVE_ACCOUNT_ID. CODEX_LIVE_MODEL is optional.

import { describe, expect, test } from "bun:test";
import { createDefaultScheduler, runInference } from "@intx/inference";
import type { InferenceEvent, InferenceSource } from "@intx/types/runtime";
import {
CODEX_ACCOUNT_ID_OPTION,
CODEX_BASE_URL,
CODEX_PROVIDER,
createCodexResponsesAdapter,
withCodexContentTypeRepair,
} from "../src/index";

const accessToken = process.env["CODEX_LIVE_ACCESS_TOKEN"] ?? "";
const accountId = process.env["CODEX_LIVE_ACCOUNT_ID"] ?? "";
const model = process.env["CODEX_LIVE_MODEL"] ?? "gpt-5.5";

const source: InferenceSource = {
id: `codex:${model}`,
provider: CODEX_PROVIDER,
baseURL: CODEX_BASE_URL,
credentialId: "codex",
model,
quirks: { productName: "Corbits Live Test", environmentTagName: "live_test" },
};

const deps = {
fetch: withCodexContentTypeRepair(fetch),
scheduler: createDefaultScheduler(),
adapters: {
has: (provider: string) => provider === CODEX_PROVIDER,
resolve: createCodexResponsesAdapter,
},
};

describe.skipIf(accessToken === "" || accountId === "")(
"live Codex backend",
() => {
test("streams a text turn", async () => {
let seq = 0;
const events: InferenceEvent[] = [];
for await (const ev of runInference({
turns: [
{
role: "user",
timestamp: 0,
content: [{ type: "text", text: "Reply with the word pong." }],
},
],
source,
inferenceOptions: {
systemPrompt: "Answer in one word.",
providerOptions: { [CODEX_ACCOUNT_ID_OPTION]: accountId },
},
nextSeq: () => seq++,
readMaterial: () => ({ secret: accessToken }),
deps,
}))
events.push(ev);
const done = events.find((e) => e.type === "inference.done");
if (done?.type !== "inference.done")
throw new Error(
`expected inference.done, got ${JSON.stringify(events)}`,
);
const text = done.data.turn.content.find((b) => b.type === "text");
expect(text?.type === "text" && text.text.toLowerCase()).toContain(
"pong",
);
}, 60_000);
},
);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
"lint": "eslint .",
"format": "prettier --write .",
"format:check": "prettier --check .",
"test": "bun test",
"check": "bun run typecheck && bun run lint && bun run format:check && bun run test"
"test": "bun test src",
"check": "bun run typecheck && bun run lint && bun run format:check && bun run test",
"test:e2e": "bun test e2e"
},
"dependencies": {
"arktype": "^2.2.3"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"lib": ["ESNext"],
"types": ["bun"]
},
"include": ["src"]
"include": ["src", "e2e"]
}
Loading