@kenkaiiii/gg-ai 5.60.0 → 5.60.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/dist/index.cjs +20 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1109,13 +1109,11 @@ function toOpenAIMessages(messages, options) {
|
|
|
1109
1109
|
const parts = typeof msg.content === "string" ? msg.content : void 0;
|
|
1110
1110
|
const toolCalls = typeof msg.content !== "string" ? msg.content.filter(
|
|
1111
1111
|
(p) => p.type === "tool_call"
|
|
1112
|
-
).map(
|
|
1113
|
-
(tc)
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
})
|
|
1118
|
-
) : void 0;
|
|
1112
|
+
).map((tc) => ({
|
|
1113
|
+
id: remapToolCallId(tc.id, idMap),
|
|
1114
|
+
type: "function",
|
|
1115
|
+
function: { name: tc.name, arguments: JSON.stringify(tc.args) }
|
|
1116
|
+
})) : void 0;
|
|
1119
1117
|
const textParts = typeof msg.content !== "string" ? msg.content.filter((p) => p.type === "text").map((p) => p.text).join("") : void 0;
|
|
1120
1118
|
const thinkingParts = typeof msg.content !== "string" ? msg.content.filter((p) => p.type === "thinking").map((p) => p.text).join("") : void 0;
|
|
1121
1119
|
const contentValue = parts || textParts || null;
|
|
@@ -2579,7 +2577,7 @@ function toCodexToolChoice(choice, tools) {
|
|
|
2579
2577
|
function streamOpenAICodex(options) {
|
|
2580
2578
|
return new StreamResult(runStream3(options), options.signal);
|
|
2581
2579
|
}
|
|
2582
|
-
async function* runStream3(options) {
|
|
2580
|
+
async function* runStream3(options, retriedWithoutReasoning = false) {
|
|
2583
2581
|
const baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
2584
2582
|
const url = `${baseUrl}/codex/responses`;
|
|
2585
2583
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
@@ -2649,6 +2647,20 @@ async function* runStream3(options) {
|
|
|
2649
2647
|
const parsed = parseCodexErrorBody(text, response.status);
|
|
2650
2648
|
const message = parsed.message ?? `Codex API returned HTTP ${response.status}.`;
|
|
2651
2649
|
const requestId = parsed.requestId ?? readHeader(response.headers, "x-request-id", "openai-request-id", "x-oai-request-id");
|
|
2650
|
+
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(
|
|
2651
|
+
(msg) => msg.role === "assistant" && Array.isArray(msg.content) && msg.content.some((part) => part.type === "raw" && isEncryptedReasoning(part.data))
|
|
2652
|
+
)) {
|
|
2653
|
+
providerDiag("codex_retry_without_encrypted_reasoning", { status: response.status });
|
|
2654
|
+
const messages = options.messages.map(
|
|
2655
|
+
(msg) => msg.role === "assistant" && Array.isArray(msg.content) ? {
|
|
2656
|
+
...msg,
|
|
2657
|
+
content: msg.content.filter(
|
|
2658
|
+
(part) => !(part.type === "raw" && isEncryptedReasoning(part.data))
|
|
2659
|
+
)
|
|
2660
|
+
} : msg
|
|
2661
|
+
);
|
|
2662
|
+
return yield* runStream3({ ...options, messages }, true);
|
|
2663
|
+
}
|
|
2652
2664
|
const usageLimit = codexUsageLimitError(parsed.errorObj, response.status, requestId);
|
|
2653
2665
|
if (usageLimit) throw usageLimit;
|
|
2654
2666
|
let hint;
|