Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): add OpenAI Codex as a subscription provider

Elian Doran1ddb93f2055e
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index ceb6b7c61d..e234ff907e 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -4066,6 +4066,7 @@
"claude_agent_description": "Uses your Claude Pro/Max subscription through Claude Code, so no API key is needed. Claude Code must be installed on the machine running Trilium (the server when self-hosting, or this computer on desktop); sign in once by running \"claude /login\" there.",
"copilot_agent_description": "Uses your GitHub Copilot subscription through the GitHub Copilot CLI, so no API key is needed. The Copilot CLI must be installed on the machine running Trilium (the server when self-hosting, or this computer on desktop); sign in once by running \"copilot login\" there — an existing Copilot login from another editor is reused automatically.",
"antigravity_agent_description": "Uses the Gemini quota of your Google account (free, Google AI Pro or Ultra) through Google Antigravity, so no API key is needed.\n\nGoogle's Antigravity ACP server must be downloaded to the device running Trilium: the server when self-hosting, or this computer on desktop. If it isn't installed yet, the next step shows how to install it.\n\nThe first time the models are listed, the Google sign-in page opens in a browser on that device.",
+ "codex_agent_description": "Uses the Codex usage of your ChatGPT plan (Free, Go, Plus, Pro or Business) through OpenAI Codex, so no API key is needed.\n\nThe Codex ACP adapter must be installed on the device running Trilium: the server when self-hosting, or this computer on desktop. Install it by running \"npm install -g @agentclientprotocol/codex-acp\" there.\n\nThe first time the models are listed, the ChatGPT sign-in page opens in a browser on that device.",
"antigravity_setup_download": "On the device running Trilium, download the archive for your platform from Google's <Link>ACP registry entry</Link> and unzip it into a folder it can stay in.",
"antigravity_setup_archive": "Download <Link>the archive for the device running Trilium</Link> and unzip it there, into a folder it can stay in.",
"antigravity_setup_path": "Add that folder to <Code>PATH</Code>, or set the <Code>TRILIUM_ANTIGRAVITY_ACP_PATH</Code> environment variable to <Code>agy_acp_server.par</Code> in it (<Code>agy_acp_server.exe</Code> on Windows), then restart Trilium.",
diff --git a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
index 38b5d723da..af591ae743 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
+++ b/apps/client/src/widgets/type_widgets/options/llm/AddProviderModal.tsx
@@ -132,6 +132,8 @@ export const PROVIDER_TYPES: ProviderType[] = [
// That sign-in runs inside the model-list request, so the request outlasts the
// server's own 5-minute wait for it (`SIGN_IN_TIMEOUT_MS`).
{ id: "antigravity-agent", name: "Google Antigravity", group: "subscription", defaultBaseUrl: "", iconUrl: PROVIDER_ICONS["antigravity-agent"], connectionDescription: t("llm.antigravity_agent_description"), beta: true, apiKey: "none", baseUrl: "none", needsHostProcess: true, modelListTimeoutMs: 6 * 60_000 },
+ // A ChatGPT plan through the Codex ACP adapter, which signs in the same way.
+ { id: "codex-agent", name: "OpenAI Codex", group: "subscription", defaultBaseUrl: "", iconUrl: PROVIDER_ICONS["codex-agent"], connectionDescription: t("llm.codex_agent_description"), beta: true, apiKey: "none", baseUrl: "none", needsHostProcess: true, modelListTimeoutMs: 6 * 60_000 },
// The three self-hosted cards share one server-side provider; they differ only in
// the endpoint they prefill and the setup hint they show.
// No blurbs: the group heading already says local/self-hosted, and how to start
diff --git a/apps/client/src/widgets/type_widgets/options/llm/provider_icons.ts b/apps/client/src/widgets/type_widgets/options/llm/provider_icons.ts
index 1cd584cdc2..dafd2dc71b 100644
--- a/apps/client/src/widgets/type_widgets/options/llm/provider_icons.ts
+++ b/apps/client/src/widgets/type_widgets/options/llm/provider_icons.ts
@@ -25,6 +25,7 @@ export const PROVIDER_ICONS: Record<string, string> = {
anthropic: anthropicIcon,
"antigravity-agent": antigravityIcon,
"claude-agent": claudeAgentIcon,
+ "codex-agent": openaiIcon,
"copilot-agent": githubCopilotIcon,
deepseek: deepseekIcon,
google: geminiIcon,
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI/Providers.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI/Providers.html
index 3813ce2909..49cdcdd20b 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI/Providers.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI/Providers.html
@@ -31,6 +31,7 @@
<li>Claude Code by reusing your CLI.</li>
<li>GitHub Copilot by reusing your CLI's ACP.</li>
<li>Google Antigravity by downloading and setting up an ACP for Trilium.</li>
+ <li>OpenAI Codex by installing the Codex ACP adapter for Trilium.</li>
</ul>
<h2>Local/self-hosted providers</h2>
<p>Local or self-hosted providers are a free alternative which respects your
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI/Providers/Subscription-based providers.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI/Providers/Subscription-based providers.html
index 8455a964a4..01265bb9c2 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI/Providers/Subscription-based providers.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI/Providers/Subscription-based providers.html
@@ -2,9 +2,10 @@
instead of pay-per-use (unlike the API keys).</p>
<p>In a nutshell, subscription-based providers work by either reusing your
existing CLI tools (e.g. Claude Code, GitHub Copilot via ACP) whereas some
- require installing the ACP server manually (e.g. Google Antigravity). Because
- they require something to be installed on your device, these providers
- are not available on Mobile (Android or iOS) or standalone mode.</p>
+ require installing the ACP server manually (e.g. Google Antigravity, OpenAI
+ Codex). Because they require something to be installed on your device,
+ these providers are not available on Mobile (Android or iOS) or standalone
+ mode.</p>
<p>See also the dedicated&nbsp;<a class="reference-link" href="#root/_help_cRRrdZjgyhNc">Privacy</a>&nbsp;section
to better understand what data is being sent to a cloud provider.</p>
<h2>Claude Code</h2>
@@ -130,4 +131,45 @@ trilium</code></pre>
note tools are enabled.</li>
<li>The results of tool calls (e.g. reading a note, writing attributes) are
not properly displayed because they are not exposed by the ACP server.</li>
+</ul>
+<h2>OpenAI Codex</h2>
+<aside class="admonition note">
+ <p>This subscription-based provider is still in beta. It is safe to use (won't
+ use additional funds and respects the terms of use), but you might experience
+ small issues. Consider <a class="reference-link" href="#root/_help_wy8So3yZZlH9">Reporting issues</a>.</p>
+</aside>
+<p>OpenAI Codex gives access to the Codex models of your ChatGPT plan (Free,
+ Go, Plus, Pro or Business), without an API key. Usage counts against your
+ plan's Codex limits, which are small on the Free plan.</p>
+<ol>
+ <li>Install the Codex ACP adapter on the machine that runs Trilium with <code>npm install -g @agentclientprotocol/codex-acp</code>.
+ It brings its own copy of the Codex CLI, so Codex doesn't need to be installed
+ separately. For a <a class="reference-link" href="#root/_help_WOcw2SLH6tbX">Server Installation</a> it
+ needs to be installed on the server.</li>
+ <li>Go to <a class="reference-link" href="#root/_help_4TIF1oA4VQRO">Options</a> → <em>AI / LLM</em> and
+ add the OpenAI Codex provider. When the list of models is loaded for the
+ first time, the ChatGPT sign-in page opens in a browser on the machine
+ running Trilium; finish signing in there.</li>
+</ol>
+<p>Trilium keeps its own Codex sign-in and settings, separate from any Codex
+ CLI you use in a terminal, so an existing <code>codex login</code> is not
+ reused.</p>
+<p>Trilium will identify the Codex ACP adapter in this order:</p>
+<ul>
+ <li>By looking for a <code>TRILIUM_CODEX_ACP_PATH</code> environment variable
+ pointing to the <code>codex-acp</code> binary.</li>
+ <li>By looking for <code>codex-acp</code> in your PATH.</li>
+ <li>By asking your login shell for its <code>PATH</code>, the same as for Claude
+ Code.</li>
+</ul>
+<h3>Known limitations</h3>
+<ul>
+ <li>Codex runs in its read-only mode and every action it asks permission for
+ is denied, so it cannot edit files, run commands or search the web.</li>
+ <li>Trilium's note tools and web search are not supported yet, so Codex cannot
+ read or modify your notes.</li>
+ <li>The ChatGPT sign-in opens in a browser on the device running Trilium,
+ so it might not be possible to set up the provider while using the web
+ version of a Docker installation. <a class="reference-link" href="#root/_help_poXkQfguuA0U">Desktop Installation</a> should
+ work fine.</li>
</ul>
\ No newline at end of file
diff --git a/apps/server/src/services/llm/index.spec.ts b/apps/server/src/services/llm/index.spec.ts
index f7a4da05b1..2a1a388ad5 100644
--- a/apps/server/src/services/llm/index.spec.ts
+++ b/apps/server/src/services/llm/index.spec.ts
@@ -25,6 +25,7 @@ vi.mock("@triliumnext/core/src/services/llm/tools/registration.js", () => ({
import { registerServerLlmExtensions } from "./index.js";
import { AntigravityAgentProvider } from "./providers/antigravity_agent.js";
import { ClaudeAgentProvider } from "./providers/claude_agent.js";
+import { CodexAgentProvider } from "./providers/codex_agent.js";
import { CopilotAgentProvider } from "./providers/copilot_agent.js";
import { helpTools } from "./tools/help_tools.js";
@@ -33,13 +34,15 @@ describe("registerServerLlmExtensions", () => {
registerServerLlmExtensions();
// The subscription providers, which shell out to the Claude Code and Copilot
- // CLIs and to Google's Antigravity ACP server, under the types core knows them by. Registered as async factories
- // that import their module on first use, so neither the provider nor its
- // agent SDK loads until a chat asks for it.
- expect(registrations.hostProviders.map(p => p.type)).toEqual(["claude-agent", "copilot-agent", "antigravity-agent"]);
+ // CLIs, Google's Antigravity ACP server and the Codex ACP adapter, under the
+ // types core knows them by. Registered as async factories that import their
+ // module on first use, so neither the provider nor its agent SDK loads until
+ // a chat asks for it.
+ expect(registrations.hostProviders.map(p => p.type)).toEqual(["claude-agent", "copilot-agent", "antigravity-agent", "codex-agent"]);
expect(await registrations.hostProviders[0].factory()).toBeInstanceOf(ClaudeAgentProvider);
expect(await registrations.hostProviders[1].factory()).toBeInstanceOf(CopilotAgentProvider);
expect(await registrations.hostProviders[2].factory()).toBeInstanceOf(AntigravityAgentProvider);
+ expect(await registrations.hostProviders[3].factory()).toBeInstanceOf(CodexAgentProvider);
// The User Guide reader, which core's note-content helper calls for doc notes.
expect(registrations.docNoteReader).toBeTypeOf("function");
// The skill sheets: core owns the catalog and the tool, the server only
diff --git a/apps/server/src/services/llm/index.ts b/apps/server/src/services/llm/index.ts
index 8ada13aae2..98d067a18b 100644
--- a/apps/server/src/services/llm/index.ts
+++ b/apps/server/src/services/llm/index.ts
@@ -4,7 +4,7 @@
* The stack itself lives in `@triliumnext/core`, so the browser-hosted
* (standalone) build can run it too. What could not follow it there is anything
* that needs Node: the providers that spawn the Claude Code and GitHub Copilot
- * CLIs and Google's Antigravity ACP server, and the User Guide tools, which read pages off disk. Core exposes a seam
+ * CLIs, Google's Antigravity ACP server and the Codex ACP adapter, and the User Guide tools, which read pages off disk. Core exposes a seam
* for each; this is where the server fills them in — including the skill sheets,
* whose catalog is core's while the reading is per-runtime.
*
@@ -35,6 +35,7 @@ export function registerServerLlmExtensions() {
registerHostProvider("claude-agent", async () => new (await import("./providers/claude_agent.js")).ClaudeAgentProvider());
registerHostProvider("copilot-agent", async () => new (await import("./providers/copilot_agent.js")).CopilotAgentProvider());
registerHostProvider("antigravity-agent", async () => new (await import("./providers/antigravity_agent.js")).AntigravityAgentProvider());
+ registerHostProvider("codex-agent", async () => new (await import("./providers/codex_agent.js")).CodexAgentProvider());
registerDocNoteHtmlReader(getDocNoteHtml);
registerSkillReader(loadSkillSheet);
registerToolRegistryLoader(async () => (await import("./tools/help_tools.js")).helpTools);
diff --git a/apps/server/src/services/llm/providers/codex_agent.live.spec.ts b/apps/server/src/services/llm/providers/codex_agent.live.spec.ts
new file mode 100644
index 0000000000..74aca0da6e
--- /dev/null
+++ b/apps/server/src/services/llm/providers/codex_agent.live.spec.ts
@@ -0,0 +1,56 @@
+/**
+ * Live integration test for the Codex Agent provider: drives the user's real
+ * `codex-acp` and asserts that a chat turn gets an answer.
+ *
+ * Opt-in — it starts the adapter, needs a saved ChatGPT sign-in, and spends the
+ * plan's Codex usage, so it never runs in CI:
+ *
+ * TRILIUM_CODEX_LIVE_TEST=1 pnpm --filter server test codex_agent.live
+ *
+ * The sign-in (`auth.json`) is copied from TRILIUM_CODEX_LIVE_HOME (default: the
+ * dev server's `data/codex-agent/home`) into a temporary data directory.
+ */
+
+import type { LlmStreamChunk } from "@triliumnext/commons";
+import fs from "fs";
+import os from "os";
+import path from "path";
+import { describe, expect, it, vi } from "vitest";
+
+import { resetAcpAgentStateForTests } from "./acp_agent.js";
+import { CodexAgentProvider } from "./codex_agent.js";
+
+const live = process.env.TRILIUM_CODEX_LIVE_TEST === "1";
+
+/** A data directory of the run's own, so the dev server's sessions are left alone. */
+const dataDir = path.join(os.tmpdir(), "trilium-codex-live");
+vi.mock("../../data_dir.js", async () => {
+ const nodeOs = await import("os");
+ const nodePath = await import("path");
+ return { default: { TRILIUM_DATA_DIR: nodePath.join(nodeOs.tmpdir(), "trilium-codex-live") } };
+});
+
+describe.runIf(live)("CodexAgentProvider (live adapter)", () => {
+ it("lists the account's models and answers a chat turn", async () => {
+ const sourceHome = process.env.TRILIUM_CODEX_LIVE_HOME ?? path.resolve("data", "codex-agent", "home");
+ const home = path.join(dataDir, "codex-agent", "home");
+ fs.mkdirSync(home, { recursive: true });
+ fs.copyFileSync(path.join(sourceHome, "auth.json"), path.join(home, "auth.json"));
+
+ const provider = new CodexAgentProvider();
+ try {
+ const models = await provider.listModels();
+ expect(models.length).toBeGreaterThan(1);
+
+ const chunks: LlmStreamChunk[] = [];
+ for await (const chunk of provider.chatChunks([{ role: "user", content: "Reply with exactly the word: Hi" }], { chatNoteId: "live-codex" })) {
+ chunks.push(chunk);
+ }
+ const text = chunks.map(c => (c.type === "text" ? c.content : "")).join("");
+ expect(chunks.filter(c => c.type === "error")).toEqual([]);
+ expect(text).toMatch(/\bHi\b/);
+ } finally {
+ resetAcpAgentStateForTests();
+ }
+ }, 180_000);
+});
diff --git a/apps/server/src/services/llm/providers/codex_agent.spec.ts b/apps/server/src/services/llm/providers/codex_agent.spec.ts
new file mode 100644
index 0000000000..285ed8fff1
--- /dev/null
+++ b/apps/server/src/services/llm/providers/codex_agent.spec.ts
@@ -0,0 +1,193 @@
+import type { LlmStreamChunk } from "@triliumnext/commons";
+import os from "os";
+import path from "path";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("@triliumnext/core", () => ({
+ getLog: () => ({ info: vi.fn(), error: vi.fn() }),
+ // buildSystemPrompt reads the workspace task states; none in this unit test.
+ task_states: { getTaskStates: () => [] }
+}));
+
+const DATA_DIR = path.join(os.tmpdir(), "trilium-codex-agent-spec");
+vi.mock("../../data_dir.js", async () => {
+ const os = await import("os");
+ const path = await import("path");
+ return { default: { TRILIUM_DATA_DIR: path.join(os.tmpdir(), "trilium-codex-agent-spec") } };
+});
+
+vi.mock("./codex_binary.js", () => ({ resolveCodexBinaryPath: async () => "/usr/bin/codex-acp" }));
+vi.mock("./acp_mcp_endpoint.js", () => ({ getAcpMcpEndpointUrl: async () => "http://127.0.0.1:12345/mcp-secret" }));
+vi.mock("@triliumnext/core/src/services/llm/note_hint.js", () => ({ buildNoteHint: () => null }));
+vi.mock("@triliumnext/core/src/services/llm/attachment_content.js", () => ({ resolveAttachmentPart: vi.fn() }));
+
+class FakeAcpError extends Error {
+ constructor(public readonly code: number, message: string) {
+ super(message);
+ }
+}
+
+/** Answers like `codex-acp`: `session/new` fails until `authenticate` has run, when `signedIn` is false. */
+class FakeAcpClient {
+ static current: FakeAcpClient | undefined;
+ static lastStart: { binary: string; opts: { args?: string[]; env?: Record<string, string>; cwd: string } } | undefined;
+ static signedIn = true;
+ /** An error `session/new` fails with, when set. */
+ static sessionFailure: Error | undefined;
+
+ requests: { method: string; params: unknown }[] = [];
+ onAgentRequest?: (method: string, params: unknown) => unknown;
+
+ static start(binary: string, opts: { args?: string[]; env?: Record<string, string>; cwd: string; onAgentRequest?: (m: string, p: unknown) => unknown }) {
+ FakeAcpClient.lastStart = { binary, opts };
+ FakeAcpClient.current = new FakeAcpClient();
+ FakeAcpClient.current.onAgentRequest = opts.onAgentRequest;
+ return FakeAcpClient.current;
+ }
+
+ async request<T>(method: string, params: unknown): Promise<T> {
+ this.requests.push({ method, params });
+ if (method === "authenticate") {
+ FakeAcpClient.signedIn = true;
+ }
+ if (method === "session/new") {
+ if (FakeAcpClient.sessionFailure) throw FakeAcpClient.sessionFailure;
+ if (!FakeAcpClient.signedIn) throw new FakeAcpError(-32000, "Authentication required");
+ return { sessionId: "sess-1", models: { currentModelId: "gpt-6-luna[medium]", availableModels: REMOTE_MODELS } } as T;
+ }
+ if (method === "session/prompt") {
+ return { stopReason: "end_turn" } as T;
+ }
+ return {} as T;
+ }
+
+ notify(): void {}
+ dispose(): void {}
+ get alive(): boolean {
+ return true;
+ }
+
+ methods(): string[] {
+ return this.requests.map(r => r.method);
+ }
+}
+
+vi.mock("./acp_client.js", () => ({ AcpClient: FakeAcpClient, AcpError: FakeAcpError }));
+
+const { resetAcpAgentStateForTests } = await import("./acp_agent.js");
+const { buildCodexModelList, CodexAgentProvider, resetCodexCatalogForTests } = await import("./codex_agent.js");
+
+/** Part of the catalog codex-acp 1.13.1 reports on session/new for a ChatGPT account. */
+const REMOTE_MODELS = [
+ ...["low", "medium", "high", "xhigh", "max"].map(effort => ({
+ modelId: `gpt-6-luna[${effort}]`,
+ name: `6 Luna (${effort})`,
+ description: "Fast and affordable model for easier tasks."
+ })),
+ ...["low", "medium", "high", "xhigh", "max", "ultra"].map(effort => ({
+ modelId: `gpt-5.6-terra[${effort}]`,
+ name: `5.6 Terra (${effort})`,
+ description: "Older balanced model for straightforward work."
+ })),
+ { modelId: "gpt-5.5[high]", name: "5.5 (high)", description: "Legacy coding model." },
+ { modelId: "gpt-5.5[low]", name: "5.5 (low)", description: "Legacy coding model." }
+];
+
+async function collect(iterable: AsyncIterable<LlmStreamChunk>): Promise<LlmStreamChunk[]> {
+ const chunks: LlmStreamChunk[] = [];
+ for await (const chunk of iterable) {
+ if (chunk.type !== "status") {
+ chunks.push(chunk);
+ }
+ }
+ return chunks;
+}
+
+beforeEach(() => {
+ resetAcpAgentStateForTests();
+ resetCodexCatalogForTests();
+ FakeAcpClient.current = undefined;
+ FakeAcpClient.lastStart = undefined;
+ FakeAcpClient.signedIn = true;
+ FakeAcpClient.sessionFailure = undefined;
+});
+
+describe("CodexAgentProvider", () => {
+ it("launches the adapter read-only, with a home of Trilium's own, and denies what it asks permission for", async () => {
+ await collect(new CodexAgentProvider().chatChunks([{ role: "user", content: "hi" }], {}));
+
+ const start = FakeAcpClient.lastStart;
+ expect(start?.binary).toBe("/usr/bin/codex-acp");
+ expect(start?.opts.env).toEqual({ CODEX_HOME: path.join(DATA_DIR, "codex-agent", "home"), INITIAL_AGENT_MODE: "read-only" });
+ expect(start?.opts.cwd).toBe(path.join(DATA_DIR, "codex-agent", "workspace"));
+ expect(FakeAcpClient.current?.onAgentRequest?.("session/request_permission", {
+ toolCall: { kind: "execute", title: "rm -rf /" },
+ options: [{ optionId: "allow", kind: "allow_once" }, { optionId: "deny", kind: "reject_once" }]
+ })).toEqual({ outcome: { outcome: "selected", optionId: "deny" } });
+ });
+
+ it("signs in with ChatGPT during the model probe, but reports a missing sign-in in the chat instead", async () => {
+ FakeAcpClient.signedIn = false;
+ const chunks = await collect(new CodexAgentProvider().chatChunks([{ role: "user", content: "hi" }], {}));
+ expect(chunks).toEqual([{ type: "error", error: expect.stringContaining("not signed in") }]);
+ expect(FakeAcpClient.current?.methods()).not.toContain("authenticate");
+
+ await new CodexAgentProvider().listModels();
+ expect(FakeAcpClient.current?.methods()).toEqual(["initialize", "session/new", "authenticate", "session/new"]);
+ expect(FakeAcpClient.current?.requests[2].params).toEqual({ methodId: "chat-gpt" });
+ });
+
+ it("explains a failure to start, sign in or answer in words the user can act on", async () => {
+ const failureOf = async (error: Error) => {
+ FakeAcpClient.sessionFailure = error;
+ resetAcpAgentStateForTests();
+ return new CodexAgentProvider().listModels().then(() => "resolved", (err: Error) => err.message);
+ };
+ expect(await failureOf(new Error("ACP request \"authenticate\" timed out after 300000ms"))).toMatch(/sign-in was not completed in time/);
+ expect(await failureOf(new Error("spawn /usr/bin/codex-acp ENOENT"))).toBe("Failed to start the Codex ACP adapter: spawn /usr/bin/codex-acp ENOENT");
+ expect(await failureOf(new Error("Something else"))).toBe("Something else");
+ });
+
+ it("leaves the default model to Codex, runs any other at the chosen effort, and titles on the lead model at its lightest", async () => {
+ const provider = new CodexAgentProvider();
+ const modelSetFor = async (config: Record<string, unknown>) => {
+ await collect(provider.chatChunks([{ role: "user", content: "hi" }], config));
+ return (FakeAcpClient.current?.requests.filter(r => r.method === "session/set_model").at(-1)?.params as { modelId?: string } | undefined)?.modelId;
+ };
+
+ expect(await modelSetFor({})).toBeUndefined();
+ expect(await modelSetFor({ model: "gpt-6-luna", reasoningEffort: "high" })).toBe("gpt-6-luna[high]");
+ // No choice: the model's default, medium.
+ expect(await modelSetFor({ model: "gpt-5.6-terra" })).toBe("gpt-5.6-terra[medium]");
+ // A level the model lacks: the nearest one, the higher on a tie.
+ expect(await modelSetFor({ model: "gpt-5.5", reasoningEffort: "medium" })).toBe("gpt-5.5[high]");
+ // An id that names no grouped model passes through.
+ expect(await modelSetFor({ model: "gpt-6-luna[low]" })).toBe("gpt-6-luna[low]");
+
+ const pooled = FakeAcpClient.current;
+ await provider.listModels();
+ await provider.generateTitle("plan my week");
+ expect(pooled?.requests.filter(r => r.method === "session/set_model").at(-1)?.params).toEqual({ sessionId: "sess-1", modelId: "gpt-6-luna[low]" });
+ });
+});
+
+describe("buildCodexModelList", () => {
+ it("lists each model once with the efforts it comes in, marks the older ones and pre-selects the rest", () => {
+ const models = buildCodexModelList({ availableModels: REMOTE_MODELS });
+
+ expect(models).toEqual([
+ { id: "default", name: "Default", pricing: { input: 0, output: 0 }, isDefault: true, isSubscription: true },
+ { id: "gpt-6-luna", name: "GPT-6 Luna", pricing: { input: 0, output: 0 }, isSubscription: true, reasoningEfforts: ["low", "medium", "high", "xhigh", "max"], defaultReasoningEffort: "medium" },
+ // `ultra` is no level Trilium can name, so it is left out.
+ { id: "gpt-5.6-terra", name: "GPT-5.6 Terra", pricing: { input: 0, output: 0 }, isSubscription: true, isLegacy: true, reasoningEfforts: ["low", "medium", "high", "xhigh", "max"], defaultReasoningEffort: "medium" },
+ // Sorted weakest first, defaulting to the lightest without medium.
+ { id: "gpt-5.5", name: "GPT-5.5", pricing: { input: 0, output: 0 }, isSubscription: true, isLegacy: true, reasoningEfforts: ["low", "high"], defaultReasoningEffort: "low" }
+ ]);
+ expect([...new CodexAgentProvider().recommendedModelIds(models)]).toEqual(["default", "gpt-6-luna"]);
+ });
+
+ it("keeps a model without a level in its id as it is", () => {
+ expect(buildCodexModelList({ availableModels: [{ modelId: "codex-mini", name: "Codex Mini" }] })[1])
+ .toEqual({ id: "codex-mini", name: "Codex Mini", pricing: { input: 0, output: 0 }, isSubscription: true });
+ });
+});
diff --git a/apps/server/src/services/llm/providers/codex_agent.ts b/apps/server/src/services/llm/providers/codex_agent.ts
new file mode 100644
index 0000000000..6ecda285a3
--- /dev/null
+++ b/apps/server/src/services/llm/providers/codex_agent.ts
@@ -0,0 +1,244 @@
+/**
+ * Codex Agent provider — drives OpenAI Codex through its ACP adapter
+ * (`codex-acp`, the Agent Client Protocol) as a subprocess. This lets users
+ * with a ChatGPT account — Free, Go, Plus, Pro or Business — use the in-app
+ * chat without an API key: the adapter signs in with the ChatGPT account and
+ * bills the plan's Codex usage.
+ *
+ * `CODEX_HOME` points the adapter at a directory of Trilium's own, so its
+ * sign-in, sessions, MCP servers and skills are Trilium's rather than those of
+ * the user's own Codex setup. The session starts in the `read-only` mode, where
+ * Codex asks before anything that writes or reaches the network, and the
+ * default permission policy denies every such request.
+ */
+
+import { LLM_REASONING_EFFORTS, type LlmReasoningEffort } from "@triliumnext/commons";
+import type { LlmProviderConfig, ModelInfo } from "@triliumnext/core/src/services/llm/types.js";
+import fs from "fs";
+import path from "path";
+
+import dataDirs from "../../data_dir.js";
+import { AcpAgentProvider, type AcpLaunchSpec, type AcpModel, type AcpNewSessionParams, type AcpSessionModelState, describeError } from "./acp_agent.js";
+import { type AcpClient, AcpError } from "./acp_client.js";
+import { resolveCodexBinaryPath } from "./codex_binary.js";
+import { needsShell } from "./copilot_binary.js";
+
+/** The model id that leaves the session on the model Codex picks. */
+const DEFAULT_MODEL_ID = "default";
+
+/**
+ * The catalog available without asking the adapter. Codex's line-up moves too
+ * fast to name here, so it holds only the entry that defers to Codex's own
+ * default.
+ */
+const AVAILABLE_MODELS: ModelInfo[] = [
+ { id: DEFAULT_MODEL_ID, name: "Default", pricing: { input: 0, output: 0 }, isDefault: true, isSubscription: true }
+];
+
+/** The adapter's sign-in method for a ChatGPT account; its other one takes an API key, which the OpenAI provider serves. */
+const SIGN_IN_METHOD = "chat-gpt";
+
+/** How long the add-provider screen waits for the user to finish signing in in the browser. */
+export const SIGN_IN_TIMEOUT_MS = 5 * 60_000;
+
+/** `gpt-6-luna[medium]` → model `gpt-6-luna`, level `medium`. */
+const VARIANT_ID = /^(.+)\[([^\]]+)\]$/;
+
+/** `6 Luna (medium)` → `6 Luna`. */
+const VARIANT_NAME = /^(.+?) \([^)]+\)$/;
+
+/**
+ * What the last catalog Codex reported says about its variants: for each
+ * listed model, the effort levels it comes in, and the cheap model for the
+ * title turn. Every `session/new` refreshes it.
+ */
+let catalog: { efforts: Map<string, LlmReasoningEffort[]>; titleModel?: string } = { efforts: new Map() };
+
+export class CodexAgentProvider extends AcpAgentProvider {
+ name = "codex-agent";
+ protected readonly logLabel = "Codex Agent provider";
+ protected readonly fallbackModels = AVAILABLE_MODELS;
+ protected readonly defaultModelId = DEFAULT_MODEL_ID;
+ protected readonly agentDirName = path.join("codex-agent", "workspace");
+
+ /** Everything Codex does not describe as older or legacy. */
+ recommendedModelIds(models: ModelInfo[]): Set<string> {
+ return new Set(models.filter(m => !m.isLegacy).map(m => m.id));
+ }
+
+ protected titleModelId(): string | undefined {
+ return catalog.titleModel;
+ }
+
+ protected sessionModelId(model: string, config: LlmProviderConfig): string {
+ return resolveCodexModel(model, config.reasoningEffort, catalog.efforts);
+ }
+
+ protected async launchSpec(): Promise<AcpLaunchSpec> {
+ const binary = await resolveCodexBinaryPath();
+ const home = agentHome();
+ fs.mkdirSync(home, { recursive: true });
+ return {
+ binary,
+ args: [],
+ shell: needsShell(binary),
+ env: { CODEX_HOME: home, INITIAL_AGENT_MODE: "read-only" }
+ };
+ }
+
+ protected buildModelList(remote: AcpSessionModelState): ModelInfo[] {
+ recordCatalog(remote);
+ return buildCodexModelList(remote);
+ }
+
+ /**
+ * Open a session, signing in first when Codex has no saved sign-in and the
+ * user is on the add-provider screen to complete it. The adapter opens the
+ * ChatGPT sign-in page in a browser on the device running Trilium and
+ * answers `authenticate` once the user has finished there; it keeps the
+ * sign-in under `CODEX_HOME`, so later sessions need none.
+ */
+ protected async createSession(client: AcpClient, params: AcpNewSessionParams, interactive: boolean, timeoutMs: number) {
+ let created: Awaited<ReturnType<AcpAgentProvider["createSession"]>>;
+ try {
+ created = await super.createSession(client, params, interactive, timeoutMs);
+ } catch (err) {
+ if (!interactive || !isSignInRequired(err)) {
+ throw err;
+ }
+ await client.request("authenticate", { methodId: SIGN_IN_METHOD }, SIGN_IN_TIMEOUT_MS);
+ created = await super.createSession(client, params, interactive, timeoutMs);
+ }
+ if (created.models) {
+ recordCatalog(created.models);
+ }
+ return created;
+ }
+
+ protected describeFailure(error: unknown): string {
+ const text = describeError(error);
+ if (isSignInRequired(error)) {
+ return "OpenAI Codex is not signed in. Open this provider in the AI settings and go to the model selection, which opens the ChatGPT sign-in page in a browser on the device running Trilium.";
+ }
+ if (/"authenticate" timed out/.test(text)) {
+ return "The ChatGPT sign-in was not completed in time. Try again, and finish signing in in the browser window that opens on the device running Trilium.";
+ }
+ if (/ENOENT|spawn/i.test(text)) {
+ return `Failed to start the Codex ACP adapter: ${text}`;
+ }
+ return text;
+ }
+}
+
+/**
+ * Codex's catalog, led by the entry that defers to its own default, with each
+ * model listed once. Codex names an effort level inside the model id
+ * (`gpt-6-luna[medium]`), so its variants become one entry, `gpt-6-luna`, that
+ * lists the levels as `reasoningEfforts`; {@link resolveCodexModel} picks the
+ * variant for a turn. A level Trilium has no name for (`ultra`, which also
+ * delegates to sub-agents) is left out. Codex's order is kept: it is the picker
+ * Codex itself shows, newest first.
+ */
+export function buildCodexModelList(remote: AcpSessionModelState): ModelInfo[] {
+ const models = groupCodexCatalog(remote).map<ModelInfo>(entry => {
+ const common = { pricing: { input: 0, output: 0 }, isSubscription: true, ...(entry.legacy && { isLegacy: true }) };
+ if (entry.efforts.length === 0) {
+ return { id: entry.id, name: entry.name, ...common };
+ }
+ return { id: entry.id, name: entry.name, ...common, reasoningEfforts: entry.efforts, defaultReasoningEffort: defaultEffort(entry.efforts) };
+ });
+ return [ ...AVAILABLE_MODELS, ...models ];
+}
+
+/**
+ * The real model id for a listed model at an effort level: the variant for
+ * that level, the nearest one when the model lacks it (the higher on a tie),
+ * or the model's default level without a choice. An id that names no grouped
+ * model is returned as it is.
+ */
+export function resolveCodexModel(model: string, effort: LlmReasoningEffort | undefined, efforts: Map<string, LlmReasoningEffort[]>): string {
+ const levels = efforts.get(model);
+ if (!levels?.length) {
+ return model;
+ }
+ const wanted = LLM_REASONING_EFFORTS.indexOf(effort ?? defaultEffort(levels));
+ let chosen = levels[0];
+ for (const level of levels) {
+ if (Math.abs(LLM_REASONING_EFFORTS.indexOf(level) - wanted) <= Math.abs(LLM_REASONING_EFFORTS.indexOf(chosen) - wanted)) {
+ chosen = level;
+ }
+ }
+ return `${model}[${chosen}]`;
+}
+
+/** The catalog's models, variants of one model gathered into one entry. */
+function groupCodexCatalog(remote: AcpSessionModelState) {
+ const entries = new Map<string, { id: string; name: string; efforts: LlmReasoningEffort[]; legacy: boolean }>();
+ for (const model of remote.availableModels ?? []) {
+ if (!model.modelId || model.modelId === DEFAULT_MODEL_ID) {
+ continue;
+ }
+ const variant = VARIANT_ID.exec(model.modelId);
+ const effort = variant ? asEffort(variant[2]) : undefined;
+ if (variant && !effort) {
+ continue;
+ }
+ const id = variant ? variant[1] : model.modelId;
+ let entry = entries.get(id);
+ if (!entry) {
+ entry = { id, name: displayName(id, model), efforts: [], legacy: isLegacy(model) };
+ entries.set(id, entry);
+ }
+ if (effort) {
+ entry.efforts.push(effort);
+ }
+ }
+ for (const entry of entries.values()) {
+ entry.efforts.sort((a, b) => LLM_REASONING_EFFORTS.indexOf(a) - LLM_REASONING_EFFORTS.indexOf(b));
+ }
+ return [ ...entries.values() ];
+}
+
+/** Remember the variants and the title model of a catalog Codex reported. */
+function recordCatalog(remote: AcpSessionModelState) {
+ const entries = groupCodexCatalog(remote);
+ const efforts = new Map(entries.filter(e => e.efforts.length > 0).map(e => [ e.id, e.efforts ]));
+ // The newest model at its lightest level; Codex lists its fast model first.
+ const lead = entries.find(e => !e.legacy) ?? entries[0];
+ const titleModel = lead && (lead.efforts.length ? `${lead.id}[${lead.efforts[0]}]` : lead.id);
+ catalog = { efforts, titleModel };
+}
+
+/** `gpt-6-luna` named `6 Luna (medium)` → `GPT-6 Luna`, as Codex's own picker shows it. */
+function displayName(id: string, model: AcpModel): string {
+ const name = model.name ? (VARIANT_NAME.exec(model.name)?.[1] ?? model.name) : id;
+ return /^gpt-/i.test(id) && !/^gpt/i.test(name) ? `GPT-${name}` : name;
+}
+
+/** Codex describes the models it keeps for compatibility as `Older …` or `Legacy …`. */
+function isLegacy(model: AcpModel): boolean {
+ return /^(older|legacy)\b/i.test(model.description ?? "");
+}
+
+function asEffort(level: string): LlmReasoningEffort | undefined {
+ return (LLM_REASONING_EFFORTS as readonly string[]).includes(level) ? level as LlmReasoningEffort : undefined;
+}
+
+/** Medium where the model has it, as Codex itself defaults to it; the lightest otherwise. */
+function defaultEffort(sortedEfforts: LlmReasoningEffort[]): LlmReasoningEffort {
+ return sortedEfforts.includes("medium") ? "medium" : sortedEfforts[0];
+}
+
+/** The adapter's `CODEX_HOME`: its sign-in, sessions and config. */
+function agentHome(): string {
+ return path.resolve(dataDirs.TRILIUM_DATA_DIR, "codex-agent", "home");
+}
+
+function isSignInRequired(error: unknown): boolean {
+ return error instanceof AcpError && error.code === -32000 && /authentication required/i.test(error.message);
+}
+
+/** For tests: forget the recorded catalog. */
+export function resetCodexCatalogForTests(): void {
+ catalog = { efforts: new Map() };
+}
diff --git a/apps/server/src/services/llm/providers/codex_binary.ts b/apps/server/src/services/llm/providers/codex_binary.ts
new file mode 100644
index 0000000000..058b63cf4b
--- /dev/null
+++ b/apps/server/src/services/llm/providers/codex_binary.ts
@@ -0,0 +1,88 @@
+/**
+ * Resolves the Codex ACP adapter (`codex-acp`), which the Codex Agent provider
+ * drives.
+ *
+ * Bring-your-own-binary like the other agent providers: nothing is bundled. The
+ * adapter is the npm package `@agentclientprotocol/codex-acp`, which depends on
+ * `@openai/codex` and starts that Codex CLI itself, so it is the only thing the
+ * user installs.
+ *
+ * Resolution order: the TRILIUM_CODEX_ACP_PATH override, then `codex-acp` on
+ * PATH (see `findOnPath`, which also asks the login shell). The resolved binary
+ * is probed with `--version` once so a broken install surfaces as a clear error
+ * instead of an opaque spawn failure mid-chat.
+ */
+
+import { getLog } from "@triliumnext/core";
+import { execFile } from "child_process";
+import { existsSync } from "fs";
+import { promisify } from "util";
+
+import { findOnPath } from "./binary_lookup.js";
+import { needsShell } from "./copilot_binary.js";
+
+const execFileAsync = promisify(execFile);
+
+const PROBE_TIMEOUT_MS = 15000;
+
+const INSTALL_HINT = "Install it with `npm install -g @agentclientprotocol/codex-acp` on the machine running the Trilium server, or set the TRILIUM_CODEX_ACP_PATH environment variable to its location.";
+
+/**
+ * The in-flight/successful resolution. Caching the promise lets concurrent
+ * first calls share one probe; a failed probe clears it so a later install is
+ * picked up without a restart.
+ */
+let cachedResolution: Promise<string> | undefined;
+
+export function resolveCodexBinaryPath(): Promise<string> {
+ if (!cachedResolution) {
+ cachedResolution = probeBinary().catch((err: unknown) => {
+ cachedResolution = undefined;
+ throw err;
+ });
+ }
+ return cachedResolution;
+}
+
+/** For tests: forget the probed binary so the next call re-resolves. */
+export function resetCodexBinaryCache(): void {
+ cachedResolution = undefined;
+}
+
+async function probeBinary(): Promise<string> {
+ const binary = await locateBinary();
+
+ // Async on purpose — this runs on the first chat request, and a sync probe
+ // would freeze the whole server for up to the timeout.
+ let version: string;
+ try {
+ // `shell` is required for the .cmd shim npm creates on Windows, and
+ // then the path is not quoted for us.
+ const shell = needsShell(binary);
+ const { stdout } = await execFileAsync(shell ? `"${binary}"` : binary, ["--version"], { timeout: PROBE_TIMEOUT_MS, encoding: "utf8", shell });
+ version = stdout.trim() || "version not reported";
+ } catch (err) {
+ const detail = err instanceof Error ? err.message : String(err);
+ throw new Error(`Found the Codex ACP adapter at "${binary}" but it failed to run (${detail}). ${INSTALL_HINT}`);
+ }
+
+ getLog().info(`Codex Agent provider: using the Codex ACP adapter at ${binary} (${version})`);
+ return binary;
+}
+
+async function locateBinary(): Promise<string> {
+ const override = process.env.TRILIUM_CODEX_ACP_PATH?.trim();
+ if (override) {
+ if (!existsSync(override)) {
+ throw new Error(`TRILIUM_CODEX_ACP_PATH is set to "${override}", but no file exists there.`);
+ }
+ return override;
+ }
+
+ const onPath = await findOnPath("codex-acp");
+ if (onPath) {
+ return onPath;
+ }
+
+ throw new Error(`The Codex ACP adapter (codex-acp) was not found. ${INSTALL_HINT}`);
+}
diff --git a/docs/User Guide/User Guide/AI/Providers.md b/docs/User Guide/User Guide/AI/Providers.md
index 3bd5e26dfb..f59b53698b 100644
--- a/docs/User Guide/User Guide/AI/Providers.md
+++ b/docs/User Guide/User Guide/AI/Providers.md
@@ -27,6 +27,7 @@ Trilium integrates multiple <a class="reference-link" href="Providers/Subscript
* Claude Code by reusing your CLI.
* GitHub Copilot by reusing your CLI's ACP.
* Google Antigravity by downloading and setting up an ACP for Trilium.
+* OpenAI Codex by installing the Codex ACP adapter for Trilium.
## Local/self-hosted providers
diff --git a/docs/User Guide/User Guide/AI/Providers/Subscription-based providers.md b/docs/User Guide/User Guide/AI/Providers/Subscription-based providers.md
index dc371fdbc0..8f36d122ba 100644
--- a/docs/User Guide/User Guide/AI/Providers/Subscription-based providers.md
+++ b/docs/User Guide/User Guide/AI/Providers/Subscription-based providers.md
@@ -1,7 +1,7 @@
# Subscription-based providers
Some cloud providers offer a subscription, which has a fixed monthly fee instead of pay-per-use (unlike the API keys).
-In a nutshell, subscription-based providers work by either reusing your existing CLI tools (e.g. Claude Code, GitHub Copilot via ACP) whereas some require installing the ACP server manually (e.g. Google Antigravity). Because they require something to be installed on your device, these providers are not available on Mobile (Android or iOS) or standalone mode.
+In a nutshell, subscription-based providers work by either reusing your existing CLI tools (e.g. Claude Code, GitHub Copilot via ACP) whereas some require installing the ACP server manually (e.g. Google Antigravity, OpenAI Codex). Because they require something to be installed on your device, these providers are not available on Mobile (Android or iOS) or standalone mode.
See also the dedicated <a class="reference-link" href="../Privacy.md">Privacy</a> section to better understand what data is being sent to a cloud provider.
@@ -78,4 +78,28 @@ trilium
* The agent can only work with your notes through Trilium's note tools; its own file and shell tools are blocked for security reasons.
* The Antigravity ACP server requires authentication via a login link. The login link needs to be run on the same device, so it might not be possible to set up the provider while using the web version of a Docker installation. <a class="reference-link" href="../../Installation%20%26%20Setup/Desktop%20Installation.md">Desktop Installation</a> should work fine.
* Images can be attached to the conversation, PDFs cannot. The LLM should still be able to read PDF notes and attachments via <a class="reference-link" href="../../Advanced%20Usage/Text%20Extraction%20(OCR).md">Text Extraction (OCR)</a> when the note tools are enabled.
-* The results of tool calls (e.g. reading a note, writing attributes) are not properly displayed because they are not exposed by the ACP server.
\ No newline at end of file
+* The results of tool calls (e.g. reading a note, writing attributes) are not properly displayed because they are not exposed by the ACP server.
+
+## OpenAI Codex
+
+> [!NOTE]
+> This subscription-based provider is still in beta. It is safe to use (won't use additional funds and respects the terms of use), but you might experience small issues. Consider <a class="reference-link" href="../../Troubleshooting/Reporting%20issues.md">Reporting issues</a>.
+
+OpenAI Codex gives access to the Codex models of your ChatGPT plan (Free, Go, Plus, Pro or Business), without an API key. Usage counts against your plan's Codex limits, which are small on the Free plan.
+
+1. Install the Codex ACP adapter on the machine that runs Trilium with `npm install -g @agentclientprotocol/codex-acp`. It brings its own copy of the Codex CLI, so Codex doesn't need to be installed separately. For a <a class="reference-link" href="../../Installation%20%26%20Setup/Server%20Installation.md">Server Installation</a> it needs to be installed on the server.
+2. Go to <a class="reference-link" href="../../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → _AI / LLM_ and add the OpenAI Codex provider. When the list of models is loaded for the first time, the ChatGPT sign-in page opens in a browser on the machine running Trilium; finish signing in there.
+
+Trilium keeps its own Codex sign-in and settings, separate from any Codex CLI you use in a terminal, so an existing `codex login` is not reused.
+
+Trilium will identify the Codex ACP adapter in this order:
+
+* By looking for a `TRILIUM_CODEX_ACP_PATH` environment variable pointing to the `codex-acp` binary.
+* By looking for `codex-acp` in your PATH.
+* By asking your login shell for its `PATH`, the same as for Claude Code.
+
+### Known limitations
+
+* Codex runs in its read-only mode and every action it asks permission for is denied, so it cannot edit files, run commands or search the web.
+* Trilium's note tools and web search are not supported yet, so Codex cannot read or modify your notes.
+* The ChatGPT sign-in opens in a browser on the device running Trilium, so it might not be possible to set up the provider while using the web version of a Docker installation. <a class="reference-link" href="../../Installation%20%26%20Setup/Desktop%20Installation.md">Desktop Installation</a> should work fine.
\ No newline at end of file
diff --git a/packages/trilium-core/src/services/llm/host_providers.ts b/packages/trilium-core/src/services/llm/host_providers.ts
index 42ea607f1d..ec34b76565 100644
--- a/packages/trilium-core/src/services/llm/host_providers.ts
+++ b/packages/trilium-core/src/services/llm/host_providers.ts
@@ -30,7 +30,9 @@ export const HOST_PROVIDED_TYPES = {
/** GitHub Copilot through the Copilot CLI's ACP mode, authenticated by `copilot login`. */
"copilot-agent": "GitHub Copilot",
/** A Google account's Gemini quota through Google's Antigravity ACP server, signed in from the provider screen. */
- "antigravity-agent": "Google Antigravity"
+ "antigravity-agent": "Google Antigravity",
+ /** A ChatGPT plan's Codex usage through the Codex ACP adapter, signed in from the provider screen. */
+ "codex-agent": "OpenAI Codex"
} as const;
/** A provider type from {@link HOST_PROVIDED_TYPES}. */
diff --git a/packages/trilium-core/src/services/llm/index.ts b/packages/trilium-core/src/services/llm/index.ts
index c4aab8309d..7f50e83e3e 100644
--- a/packages/trilium-core/src/services/llm/index.ts
+++ b/packages/trilium-core/src/services/llm/index.ts
@@ -26,7 +26,7 @@ export interface LlmProviderSetup {
}
/** Provider type identifiers that can be instantiated, for error messages. */
-const PROVIDER_TYPES = ["anthropic", "openai", "google", "deepseek", "claude-agent", "copilot-agent", "antigravity-agent", "ollama", "lmstudio", "openai-compatible"];
+const PROVIDER_TYPES = ["anthropic", "openai", "google", "deepseek", "claude-agent", "copilot-agent", "antigravity-agent", "codex-agent", "ollama", "lmstudio", "openai-compatible"];
/**
* Instantiate a provider from its type identifier.
@@ -67,6 +67,8 @@ async function createProviderInstance(provider: string, apiKey: string, baseURL?
return await createHostProvider("copilot-agent");
case "antigravity-agent":
return await createHostProvider("antigravity-agent");
+ case "codex-agent":
+ return await createHostProvider("codex-agent");
// Self-hosted endpoints. The three cards differ only in the URL and setup
// hint the UI prefills; they all speak the OpenAI-compatible API, with
// Ollama and LM Studio additionally offering a richer native listing.