fix: updated metadata URLs and Bun WebSocket types
- Added homepage metadata entries to the Rust and Python package manifests. - Replaced OpenRouter HTTP-Referer values with https://omp.sh/ in completion and image requests. - Updated Codex WebSocket typing and construction to use Bun.WebSocket for handshake header capture. Fixes #1102
This commit is contained in:
@@ -8,6 +8,7 @@ version = "15.1.0"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Can Boluk"]
|
||||
homepage = "https://omp.sh/"
|
||||
repository = "https://github.com/can1357/oh-my-pi"
|
||||
|
||||
[patch.crates-io]
|
||||
|
||||
@@ -348,7 +348,7 @@ function updateCodexSessionMetadataFromHeaders(
|
||||
}
|
||||
}
|
||||
|
||||
function extractCodexWebSocketHandshakeHeaders(socket: WebSocket, openEvent?: Event): Headers | undefined {
|
||||
function extractCodexWebSocketHandshakeHeaders(socket: Bun.WebSocket, openEvent?: Event): Headers | undefined {
|
||||
const eventRecord = openEvent as Record<string, unknown> | undefined;
|
||||
const eventResponse = eventRecord?.response as Record<string, unknown> | undefined;
|
||||
const socketRecord = socket as unknown as Record<string, unknown>;
|
||||
@@ -1889,7 +1889,7 @@ class CodexWebSocketConnection {
|
||||
#idleTimeoutMs: number;
|
||||
#firstEventTimeoutMs: number;
|
||||
#onHandshakeHeaders?: (headers: Headers) => void;
|
||||
#socket: WebSocket | null = null;
|
||||
#socket: Bun.WebSocket | null = null;
|
||||
#queue: Array<Record<string, unknown> | Error | null> = [];
|
||||
#waiters: Array<() => void> = [];
|
||||
#connectPromise?: Promise<void>;
|
||||
@@ -1930,7 +1930,10 @@ class CodexWebSocketConnection {
|
||||
}
|
||||
const { promise, resolve, reject } = Promise.withResolvers<void>();
|
||||
this.#connectPromise = promise;
|
||||
const socket = new WebSocket(this.#url, { headers: this.#headers });
|
||||
const socket = new (WebSocket as unknown as new (url: string, opts: Bun.WebSocketOptions) => Bun.WebSocket)(
|
||||
this.#url,
|
||||
{ headers: this.#headers },
|
||||
);
|
||||
socket.binaryType = "nodebuffer";
|
||||
this.#socket = socket;
|
||||
let settled = false;
|
||||
@@ -2092,7 +2095,7 @@ class CodexWebSocketConnection {
|
||||
}
|
||||
}
|
||||
|
||||
#captureHandshakeHeaders(socket: WebSocket, openEvent?: Event): void {
|
||||
#captureHandshakeHeaders(socket: Bun.WebSocket, openEvent?: Event): void {
|
||||
if (!this.#onHandshakeHeaders) return;
|
||||
const headers = extractCodexWebSocketHandshakeHeaders(socket, openEvent);
|
||||
if (!headers) return;
|
||||
|
||||
@@ -914,7 +914,7 @@ async function createClient(
|
||||
// SDK UA so traffic is identifiable in upstream provider logs.
|
||||
// https://openrouter.ai/docs/app-attribution
|
||||
headers["User-Agent"] = `Oh-My-Pi/${packageJson.version}`;
|
||||
headers["HTTP-Referer"] = "https://github.com/can1357/oh-my-pi";
|
||||
headers["HTTP-Referer"] = "https://omp.sh/";
|
||||
headers["X-OpenRouter-Title"] = "Oh-My-Pi";
|
||||
headers["X-OpenRouter-Categories"] = "cli-agent";
|
||||
// Always-on response caching: identical requests return cached responses for free.
|
||||
|
||||
@@ -1075,7 +1075,7 @@ export const imageGenTool: CustomTool<typeof imageGenSchema, ImageGenToolDetails
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${apiKey.apiKey}`,
|
||||
"HTTP-Referer": "https://github.com/can1357/oh-my-pi",
|
||||
"HTTP-Referer": "https://omp.sh/",
|
||||
"X-OpenRouter-Title": "Oh-My-Pi",
|
||||
"X-OpenRouter-Categories": "cli-agent",
|
||||
},
|
||||
|
||||
@@ -23,6 +23,7 @@ classifiers = [
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://omp.sh/"
|
||||
Repository = "https://github.com/can1357/oh-my-pi"
|
||||
Documentation = "https://github.com/can1357/oh-my-pi/blob/main/docs/rpc.md"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user