@wacry/codeks-bridge 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.d.ts +0 -2
- package/dist/catalog.js +0 -2
- package/dist/server.js +1 -5
- package/docs/config.md +1 -1
- package/package.json +1 -1
package/dist/catalog.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { BridgeConfig } from "./types.ts";
|
|
2
|
-
/** Codex bounds downloads from an explicit model_catalog_url to 1 MiB. */
|
|
3
|
-
export declare const MAX_HTTP_CATALOG_BYTES: number;
|
|
4
2
|
/** Serve client-exposed aliases, using their own reviewed client behavior. */
|
|
5
3
|
export declare function buildCatalog(config: BridgeConfig): {
|
|
6
4
|
models: Record<string, any>[];
|
package/dist/catalog.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { modelProfile } from "./profiles.js";
|
|
2
2
|
import { BridgeError } from "./errors.js";
|
|
3
|
-
/** Codex bounds downloads from an explicit model_catalog_url to 1 MiB. */
|
|
4
|
-
export const MAX_HTTP_CATALOG_BYTES = 1024 * 1024;
|
|
5
3
|
function exposedModels(config) {
|
|
6
4
|
return Object.entries(config.models).filter(([, model]) => model.expose !== false);
|
|
7
5
|
}
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
2
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
3
3
|
import { validateConfig, resolveModel, resolveCompactionModel } from "./config.js";
|
|
4
|
-
import { buildCatalog
|
|
4
|
+
import { buildCatalog } from "./catalog.js";
|
|
5
5
|
import { reasoningSummaryRequested } from "./profiles.js";
|
|
6
6
|
import { BridgeError, ResponsesIncompleteError, ResponsesStreamError, transportError, UpstreamHttpError } from "./errors.js";
|
|
7
7
|
import { ResponseWriter, usageJson } from "./writer.js";
|
|
@@ -75,7 +75,6 @@ export function createBridgeServer(value, options = {}) {
|
|
|
75
75
|
const config = validateConfig(value);
|
|
76
76
|
const compactions = new CompactionHandoffStore(config, BACKENDS);
|
|
77
77
|
const catalog = JSON.stringify(buildCatalog(config));
|
|
78
|
-
const catalogBytes = Buffer.byteLength(catalog);
|
|
79
78
|
const catalogEtag = `"${createHash("sha256").update(catalog).digest("hex")}"`;
|
|
80
79
|
const token = config.token_env ? process.env[config.token_env] : undefined;
|
|
81
80
|
if (config.token_env && !token)
|
|
@@ -111,9 +110,6 @@ export function createBridgeServer(value, options = {}) {
|
|
|
111
110
|
return;
|
|
112
111
|
}
|
|
113
112
|
if (req.method === "GET" && path === "/models") {
|
|
114
|
-
if (catalogBytes > MAX_HTTP_CATALOG_BYTES) {
|
|
115
|
-
throw new BridgeError("HTTP model catalog exceeds the client's 1 MiB limit. Reduce model aliases or export a static catalog and use model_catalog_json.", "invalid_prompt", 413);
|
|
116
|
-
}
|
|
117
113
|
res.writeHead(200, { "content-type": "application/json", "cache-control": "no-cache", etag: catalogEtag });
|
|
118
114
|
res.end(catalog);
|
|
119
115
|
return;
|
package/docs/config.md
CHANGED
|
@@ -275,7 +275,7 @@ provider 显示名为 `Local bridge`,并显式声明 `[model_providers.bridge.
|
|
|
275
275
|
|
|
276
276
|
bridge 使用 HTTP/SSE。已核对 Codex `0.163.0` 的 `codex-rs/model-provider-info/src/lib.rs` 与 `codex-rs/core/src/client.rs`:自定义 provider 的 `supports_websockets` 默认为 `false`,生成的片段沿用该默认值;目录中的 `prefer_websockets: true` 保留源条目原值,不会越过 provider 的能力开关。若将片段合并到已有 provider 配置,应确认没有遗留的 `supports_websockets = true`。今后接入 WebSocket 时需实现相应传输契约,而不只是修改目录偏好。
|
|
277
277
|
|
|
278
|
-
目录响应带 `ETag`,普通响应带同值的 `x-models-etag`。服务配置修改后重启 bridge
|
|
278
|
+
目录响应带 `ETag`,普通响应带同值的 `x-models-etag`。服务配置修改后重启 bridge,新内容的标记会让客户端刷新模型目录;客户端也有定时缓存刷新。HTTP 和静态导出都提供完整目录,每个别名包含完整提示词,窗口或部署别名较多时响应也会增大。目录下载的大小与超时边界由客户端控制;codeks 的显式 HTTP 目录上限为 32 MiB,超时为 5 秒且不跟随重定向。需要固定本地快照时可使用下方的静态 `model_catalog_json` 方案。
|
|
279
279
|
|
|
280
280
|
顶层 `model_catalog_json` 的优先级高于 HTTP 目录。若已有该配置,迁移时移除它,再重载客户端配置。
|
|
281
281
|
|
package/package.json
CHANGED