copilot-api-plus 1.3.1 → 1.3.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/main.js +11 -4
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3286,6 +3286,7 @@ function stripAssistantThinkingBlocks(payload) {
|
|
|
3286
3286
|
/** Detect the upstream "invalid thinking signature" 400 to trigger retry. */
|
|
3287
3287
|
async function isInvalidThinkingSignatureError(error) {
|
|
3288
3288
|
if (!(error instanceof HTTPError) || error.response.status !== 400) return false;
|
|
3289
|
+
if (INVALID_THINKING_SIGNATURE_PATTERN.test(error.message)) return true;
|
|
3289
3290
|
const message = await readUpstreamErrorMessage(error.response);
|
|
3290
3291
|
return typeof message === "string" && INVALID_THINKING_SIGNATURE_PATTERN.test(message);
|
|
3291
3292
|
}
|
|
@@ -3427,13 +3428,19 @@ function buildAnthropicHeaders(payload, source, options$1) {
|
|
|
3427
3428
|
}
|
|
3428
3429
|
async function createAnthropicMessages(payload, options$1) {
|
|
3429
3430
|
injectMaxThinkingBudget(payload);
|
|
3430
|
-
|
|
3431
|
-
|
|
3431
|
+
const preStripped = stripAssistantThinkingBlocks(payload);
|
|
3432
|
+
let workingPayload = payload;
|
|
3433
|
+
if (preStripped.stripped) {
|
|
3434
|
+
consola.debug(`Pre-stripped ${preStripped.strippedBlocks} assistant thinking block(s) from history (Copilot/Vertex does not accept replay)`);
|
|
3435
|
+
workingPayload = preStripped.payload;
|
|
3436
|
+
}
|
|
3437
|
+
sanitizeForCopilotBackend(workingPayload);
|
|
3438
|
+
normalizeAdaptiveThinkingForCopilot(workingPayload);
|
|
3432
3439
|
try {
|
|
3433
|
-
return await dispatchAnthropicRequest(
|
|
3440
|
+
return await dispatchAnthropicRequest(workingPayload, options$1);
|
|
3434
3441
|
} catch (error) {
|
|
3435
3442
|
if (!await isInvalidThinkingSignatureError(error)) throw error;
|
|
3436
|
-
const stripped = stripAssistantThinkingBlocks(
|
|
3443
|
+
const stripped = stripAssistantThinkingBlocks(workingPayload);
|
|
3437
3444
|
if (!stripped.stripped) throw error;
|
|
3438
3445
|
const droppedSuffix = stripped.droppedAssistantMessages > 0 ? ` and dropping ${stripped.droppedAssistantMessages} thinking-only assistant turn(s)` : "";
|
|
3439
3446
|
consola.warn(`Native /v1/messages signature retry: stripped ${stripped.strippedBlocks} thinking block(s)${droppedSuffix}`);
|