feat: added WebSocket transport support for OpenAI Codex with SSE fallback

- Added WebSocket transport support for OpenAI Codex responses with automatic fallback to SSE on connection failure.
- Added preferWebsockets option to Agent and Model configurations to hint that WebSocket transport should be preferred when supported by provider implementations.
- Added prewarmOpenAICodexResponses() function to pre-establish WebSocket connections for improved performance.
- Added getProviderDetails() function and getOpenAICodexTransportDetails() function to expose transport state and provider configuration information.
- Added provider details display in session info showing active provider configuration and authentication details.
- Added OpenAI websockets setting to enable WebSocket transport preference for OpenAI Codex models in coding agent configuration.
This commit is contained in:
can1357
2026-02-14 00:01:25 +01:00
parent d1e16d2101
commit 7bf5664690
17 changed files with 1092 additions and 49 deletions
@@ -0,0 +1,34 @@
import { describe, expect, it } from "bun:test";
import { getProviderDetails, type Model } from "@oh-my-pi/pi-ai";
import { renderProviderSection } from "@oh-my-pi/pi-coding-agent/modes/controllers/command-controller";
describe("session provider section", () => {
it("renders codex provider details with transport fields", () => {
const model: Model<"openai-codex-responses"> = {
id: "gpt-5.3-codex-spark",
name: "GPT-5.3 Codex Spark",
api: "openai-codex-responses",
provider: "openai-codex",
baseUrl: "https://chatgpt.com/backend-api",
reasoning: true,
preferWebsockets: true,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 128000,
maxTokens: 128000,
};
const details = getProviderDetails({
model,
sessionId: "session-1",
authMode: "oauth",
});
const output = renderProviderSection(details, { fg: (_color: string, text: string) => text });
expect(output).toContain("Name:");
expect(output).toContain("openai-codex");
expect(output).toContain("Transport:");
expect(output).toContain("WebSocket:");
expect(output).toContain("Reuse:");
expect(output).toContain("Auth:");
});
});