@kenkaiiii/gg-ai 5.19.2 → 5.19.3
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/index.cjs +56 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +56 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -309,6 +309,9 @@ function providerGuidance(provider, message, statusCode) {
|
|
|
309
309
|
if (statusCode === 503 || lower.includes("service unavailable")) {
|
|
310
310
|
return `${name} is temporarily unavailable. Retry shortly \u2014 not a GG Coder issue.`;
|
|
311
311
|
}
|
|
312
|
+
if (statusCode === 507 || lower.includes("exceeded request buffer limit while retrying upstream")) {
|
|
313
|
+
return `${name}'s proxy could not retry this large request. GG Coder already retried automatically \u2014 compact the conversation, then retry.`;
|
|
314
|
+
}
|
|
312
315
|
if (statusCode === 500 || lower.includes("server_error") || lower.includes("500") && lower.includes("internal server error")) {
|
|
313
316
|
return status ? `This is an error from ${name}, not GG Coder. Retry \u2014 if it keeps happening, check ${status}.` : `This is an error from ${name}, not GG Coder. Retry \u2014 if it keeps happening, try a different model via the model selector.`;
|
|
314
317
|
}
|
|
@@ -2245,6 +2248,7 @@ function toError2(err, provider = "openai") {
|
|
|
2245
2248
|
|
|
2246
2249
|
// src/providers/openai-codex.ts
|
|
2247
2250
|
var import_node_os = __toESM(require("os"), 1);
|
|
2251
|
+
var zstd = __toESM(require("@bokuweb/zstd-wasm"), 1);
|
|
2248
2252
|
|
|
2249
2253
|
// src/utils/sse.ts
|
|
2250
2254
|
function parseSseBuffer(buffer) {
|
|
@@ -2300,6 +2304,50 @@ function extractRequestIdFromMessage(message) {
|
|
|
2300
2304
|
// src/providers/openai-codex.ts
|
|
2301
2305
|
var DEFAULT_BASE_URL = "https://chatgpt.com/backend-api";
|
|
2302
2306
|
var CODEX_CLIENT_VERSION = "0.144.1";
|
|
2307
|
+
var CODEX_REQUEST_COMPRESSION_MIN_BYTES = 16 * 1024;
|
|
2308
|
+
var zstdInitPromise;
|
|
2309
|
+
async function encodeCodexRequest(body) {
|
|
2310
|
+
const json = JSON.stringify(body);
|
|
2311
|
+
const raw = new TextEncoder().encode(json);
|
|
2312
|
+
if (raw.byteLength < CODEX_REQUEST_COMPRESSION_MIN_BYTES) {
|
|
2313
|
+
return {
|
|
2314
|
+
body: json,
|
|
2315
|
+
compressed: false,
|
|
2316
|
+
rawBytes: raw.byteLength,
|
|
2317
|
+
encodedBytes: raw.byteLength
|
|
2318
|
+
};
|
|
2319
|
+
}
|
|
2320
|
+
try {
|
|
2321
|
+
zstdInitPromise ??= zstd.init();
|
|
2322
|
+
await zstdInitPromise;
|
|
2323
|
+
const compressed = Uint8Array.from(zstd.compress(raw));
|
|
2324
|
+
if (compressed.byteLength >= raw.byteLength) {
|
|
2325
|
+
return {
|
|
2326
|
+
body: json,
|
|
2327
|
+
compressed: false,
|
|
2328
|
+
rawBytes: raw.byteLength,
|
|
2329
|
+
encodedBytes: raw.byteLength
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
return {
|
|
2333
|
+
body: compressed,
|
|
2334
|
+
compressed: true,
|
|
2335
|
+
rawBytes: raw.byteLength,
|
|
2336
|
+
encodedBytes: compressed.byteLength
|
|
2337
|
+
};
|
|
2338
|
+
} catch (error) {
|
|
2339
|
+
providerDiag("codex_request_compression_failed", {
|
|
2340
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2341
|
+
rawBytes: raw.byteLength
|
|
2342
|
+
});
|
|
2343
|
+
return {
|
|
2344
|
+
body: json,
|
|
2345
|
+
compressed: false,
|
|
2346
|
+
rawBytes: raw.byteLength,
|
|
2347
|
+
encodedBytes: raw.byteLength
|
|
2348
|
+
};
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2303
2351
|
function usesResponsesLite(model) {
|
|
2304
2352
|
return model.startsWith("gpt-5.6-");
|
|
2305
2353
|
}
|
|
@@ -2377,10 +2425,17 @@ async function* runStream3(options) {
|
|
|
2377
2425
|
headers["session_id"] = transportSessionId;
|
|
2378
2426
|
headers["x-client-request-id"] = transportSessionId;
|
|
2379
2427
|
}
|
|
2428
|
+
const encodedRequest = await encodeCodexRequest(body);
|
|
2429
|
+
if (encodedRequest.compressed) headers["Content-Encoding"] = "zstd";
|
|
2430
|
+
providerDiag("codex_request_body", {
|
|
2431
|
+
rawBytes: encodedRequest.rawBytes,
|
|
2432
|
+
encodedBytes: encodedRequest.encodedBytes,
|
|
2433
|
+
compressed: encodedRequest.compressed
|
|
2434
|
+
});
|
|
2380
2435
|
const response = await fetch(url, {
|
|
2381
2436
|
method: "POST",
|
|
2382
2437
|
headers,
|
|
2383
|
-
body:
|
|
2438
|
+
body: encodedRequest.body,
|
|
2384
2439
|
signal: options.signal
|
|
2385
2440
|
});
|
|
2386
2441
|
if (!response.ok) {
|