dsh-codex-subscription 2.1.1 → 2.1.2
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/lib/client.js +1 -1
- package/lib/index.js +36 -4
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -7146,7 +7146,7 @@ window.__ModuleLoader__.load({
|
|
|
7146
7146
|
}
|
|
7147
7147
|
//#endregion
|
|
7148
7148
|
//#region src/version.js
|
|
7149
|
-
const PACKAGE_VERSION = "2.1.
|
|
7149
|
+
const PACKAGE_VERSION = "2.1.2";
|
|
7150
7150
|
//#endregion
|
|
7151
7151
|
//#region src/client-recovery.js
|
|
7152
7152
|
async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
|
package/lib/index.js
CHANGED
|
@@ -468,6 +468,19 @@ function bodyBytes(body) {
|
|
|
468
468
|
if (body instanceof Uint8Array) return Buffer.from(body);
|
|
469
469
|
throw new TypeError("Unsupported Codex OAuth request body");
|
|
470
470
|
}
|
|
471
|
+
function transportError(error, signal) {
|
|
472
|
+
if (signal?.aborted || error?.name === "AbortError" || error?.code === "ABORT_ERR") return error;
|
|
473
|
+
if (!/^(?:ECONNRESET|ECONNREFUSED|EPIPE|ETIMEDOUT|ENETUNREACH|EHOSTUNREACH|EAI_AGAIN|ERR_STREAM_PREMATURE_CLOSE)$/.test(error?.code ?? "")) return error;
|
|
474
|
+
return Object.assign(new Error(`Network transport failure (${error.code}): ${error.message}`, { cause: error }), { code: error.code });
|
|
475
|
+
}
|
|
476
|
+
function transportResponseBody(response, signal) {
|
|
477
|
+
const body = new PassThrough();
|
|
478
|
+
response.on("error", (error) => body.destroy(transportError(error, signal)));
|
|
479
|
+
body.on("close", () => response.destroy());
|
|
480
|
+
const stream = Readable.toWeb(body);
|
|
481
|
+
response.pipe(body);
|
|
482
|
+
return stream;
|
|
483
|
+
}
|
|
471
484
|
function fetchThroughProxy(input, init, proxyUrl) {
|
|
472
485
|
const target = new URL(typeof input === "string" || input instanceof URL ? input : input.url);
|
|
473
486
|
const body = bodyBytes(init?.body);
|
|
@@ -489,13 +502,14 @@ function fetchThroughProxy(input, init, proxyUrl) {
|
|
|
489
502
|
205,
|
|
490
503
|
304
|
|
491
504
|
].includes(status);
|
|
492
|
-
|
|
505
|
+
if (empty) response.resume();
|
|
506
|
+
resolve(new Response(empty ? null : transportResponseBody(response, init?.signal), {
|
|
493
507
|
status,
|
|
494
508
|
statusText: response.statusMessage,
|
|
495
509
|
headers: responseHeaders
|
|
496
510
|
}));
|
|
497
511
|
});
|
|
498
|
-
request$1.on("error", reject);
|
|
512
|
+
request$1.on("error", (error) => reject(transportError(error, init?.signal)));
|
|
499
513
|
if (body) request$1.write(body);
|
|
500
514
|
request$1.end();
|
|
501
515
|
});
|
|
@@ -2495,6 +2509,20 @@ function createCodexRpcHandler(coordinator, options = {}) {
|
|
|
2495
2509
|
};
|
|
2496
2510
|
}
|
|
2497
2511
|
//#endregion
|
|
2512
|
+
//#region src/transport-failure.js
|
|
2513
|
+
function normalizeTransportEvent(event, signal) {
|
|
2514
|
+
if (signal?.aborted || event?.type !== "error" || event.reason !== "error") return event;
|
|
2515
|
+
const message = event.error?.errorMessage;
|
|
2516
|
+
if (typeof message !== "string" || !/^WebSocket closed (?:1006|1011|1012|1013)(?:\s|$)/.test(message)) return event;
|
|
2517
|
+
return {
|
|
2518
|
+
...event,
|
|
2519
|
+
error: {
|
|
2520
|
+
...event.error,
|
|
2521
|
+
errorMessage: `Network transport failure: ${message}`
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
}
|
|
2525
|
+
//#endregion
|
|
2498
2526
|
//#region src/pi-ai-runtime.js
|
|
2499
2527
|
const FAST_SERVICE_TIER = "priority";
|
|
2500
2528
|
/**
|
|
@@ -2578,13 +2606,17 @@ function openaiCodexSubscriptionProvider({ resolveSpeedMode = () => void 0, reso
|
|
|
2578
2606
|
let prepared;
|
|
2579
2607
|
const step = async (method, value) => {
|
|
2580
2608
|
const request = await (prepared ??= connection?.prepare(options) ?? Promise.resolve({ options }));
|
|
2581
|
-
|
|
2609
|
+
const result = await runNetwork("model", () => {
|
|
2582
2610
|
iterator ??= factory(compaction?.requestOptions(request.options) ?? request.options)[Symbol.asyncIterator]();
|
|
2583
2611
|
return iterator[method]?.(value) ?? (method === "throw" ? Promise.reject(value) : Promise.resolve({
|
|
2584
2612
|
done: true,
|
|
2585
2613
|
value
|
|
2586
2614
|
}));
|
|
2587
2615
|
}, compaction?.networkOptions(request.network) ?? request.network);
|
|
2616
|
+
return result.done ? result : {
|
|
2617
|
+
...result,
|
|
2618
|
+
value: normalizeTransportEvent(result.value, request.options?.signal)
|
|
2619
|
+
};
|
|
2588
2620
|
};
|
|
2589
2621
|
return {
|
|
2590
2622
|
[Symbol.asyncIterator]() {
|
|
@@ -2612,7 +2644,7 @@ function openaiCodexSubscriptionProvider({ resolveSpeedMode = () => void 0, reso
|
|
|
2612
2644
|
Object.freeze(["0.82.1", "0.85.1"]);
|
|
2613
2645
|
//#endregion
|
|
2614
2646
|
//#region src/version.js
|
|
2615
|
-
const PACKAGE_VERSION = "2.1.
|
|
2647
|
+
const PACKAGE_VERSION = "2.1.2";
|
|
2616
2648
|
const USER_AGENT = `dsh-codex-subscription/${PACKAGE_VERSION}`;
|
|
2617
2649
|
//#endregion
|
|
2618
2650
|
//#region src/model-catalog.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-codex-subscription",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Use ChatGPT and Codex subscriptions in DeepSeek Harness with OAuth, quota, safe resets, web search, images, and Fast mode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|