@kenkaiiii/gg-ai 5.60.0 → 5.60.1
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 +15 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2646,7 +2646,7 @@ function toCodexToolChoice(choice, tools) {
|
|
|
2646
2646
|
function streamOpenAICodex(options) {
|
|
2647
2647
|
return new StreamResult(runStream3(options), options.signal);
|
|
2648
2648
|
}
|
|
2649
|
-
async function* runStream3(options) {
|
|
2649
|
+
async function* runStream3(options, retriedWithoutReasoning = false) {
|
|
2650
2650
|
const baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
2651
2651
|
const url = `${baseUrl}/codex/responses`;
|
|
2652
2652
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
@@ -2716,6 +2716,20 @@ async function* runStream3(options) {
|
|
|
2716
2716
|
const parsed = parseCodexErrorBody(text, response.status);
|
|
2717
2717
|
const message = parsed.message ?? `Codex API returned HTTP ${response.status}.`;
|
|
2718
2718
|
const requestId = parsed.requestId ?? readHeader(response.headers, "x-request-id", "openai-request-id", "x-oai-request-id");
|
|
2719
|
+
if (!retriedWithoutReasoning && !options.signal?.aborted && response.status === 400 && (parsed.errorObj?.code === "invalid_encrypted_content" || /encrypted content.*could not be (?:verified|decrypted|parsed)/i.test(message)) && options.messages.some(
|
|
2720
|
+
(msg) => msg.role === "assistant" && Array.isArray(msg.content) && msg.content.some((part) => part.type === "raw" && isEncryptedReasoning(part.data))
|
|
2721
|
+
)) {
|
|
2722
|
+
providerDiag("codex_retry_without_encrypted_reasoning", { status: response.status });
|
|
2723
|
+
const messages = options.messages.map(
|
|
2724
|
+
(msg) => msg.role === "assistant" && Array.isArray(msg.content) ? {
|
|
2725
|
+
...msg,
|
|
2726
|
+
content: msg.content.filter(
|
|
2727
|
+
(part) => !(part.type === "raw" && isEncryptedReasoning(part.data))
|
|
2728
|
+
)
|
|
2729
|
+
} : msg
|
|
2730
|
+
);
|
|
2731
|
+
return yield* runStream3({ ...options, messages }, true);
|
|
2732
|
+
}
|
|
2719
2733
|
const usageLimit = codexUsageLimitError(parsed.errorObj, response.status, requestId);
|
|
2720
2734
|
if (usageLimit) throw usageLimit;
|
|
2721
2735
|
let hint;
|