copilot-api-plus 1.4.6 → 1.4.7
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 +20 -1
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -4133,15 +4133,34 @@ async function handleCompletion(c) {
|
|
|
4133
4133
|
if (state.manualApprove) await awaitApproval();
|
|
4134
4134
|
const route = resolveAnthropicRoute(anthropicPayload.model);
|
|
4135
4135
|
consola.debug(`Anthropic route resolved: ${route}`);
|
|
4136
|
-
if (route === "native-anthropic") return handleNativePassthrough(c, anthropicPayload);
|
|
4136
|
+
if (route === "native-anthropic" && !nativeBlockedModels.has(anthropicPayload.model)) return handleNativePassthrough(c, anthropicPayload);
|
|
4137
4137
|
return handleTranslatedCompletion(c, anthropicPayload);
|
|
4138
4138
|
}
|
|
4139
|
+
/**
|
|
4140
|
+
* Models whose native /v1/messages path returned an unrecoverable upstream
|
|
4141
|
+
* policy error (e.g. Vertex AI's `structured_outputs` GCP org policy).
|
|
4142
|
+
* Once added, future requests for that model skip the native path and go
|
|
4143
|
+
* straight to the translated /chat/completions path.
|
|
4144
|
+
*
|
|
4145
|
+
* Cleared on process restart — so a fixed Copilot routing self-heals.
|
|
4146
|
+
*/
|
|
4147
|
+
const nativeBlockedModels = /* @__PURE__ */ new Set();
|
|
4148
|
+
const VERTEX_STRUCTURED_OUTPUTS_PATTERN = /vertexai\.allowedPartnerModelFeatures.*?structured_outputs/i;
|
|
4149
|
+
function isVertexStructuredOutputsBlock(error) {
|
|
4150
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4151
|
+
return VERTEX_STRUCTURED_OUTPUTS_PATTERN.test(message);
|
|
4152
|
+
}
|
|
4139
4153
|
async function handleNativePassthrough(c, anthropicPayload) {
|
|
4140
4154
|
const anthropicBeta = c.req.header("anthropic-beta");
|
|
4141
4155
|
let result;
|
|
4142
4156
|
try {
|
|
4143
4157
|
result = await createAnthropicMessages(injectIntoAnthropicPayload(stripSystemReminders(anthropicPayload)), { anthropicBeta });
|
|
4144
4158
|
} catch (error) {
|
|
4159
|
+
if (isVertexStructuredOutputsBlock(error)) {
|
|
4160
|
+
nativeBlockedModels.add(anthropicPayload.model);
|
|
4161
|
+
consola.warn(`Native /v1/messages blocked by Vertex GCP policy for "${anthropicPayload.model}" — falling back to translated path (cached for this process)`);
|
|
4162
|
+
return handleTranslatedCompletion(c, anthropicPayload);
|
|
4163
|
+
}
|
|
4145
4164
|
consola.warn(`Native /v1/messages failed: ${error.message || String(error)}`);
|
|
4146
4165
|
throw error;
|
|
4147
4166
|
}
|