Fix AG, Kiro, Xiaomi Provider

This commit is contained in:
decolua
2026-06-18 14:58:00 +07:00
parent 9ab14e7714
commit 3f9382dee4
7 changed files with 149 additions and 8 deletions

View File

@@ -18,6 +18,9 @@ function sanitizeFunctionName(name) {
const MAX_RETRY_AFTER_MS = 10000;
const MAX_ANTIGRAVITY_OUTPUT_TOKENS = 16384;
// Fields Google generateContent rejects (e.g. Claude adaptive output_config) — stripped from antigravity request envelope
const ANTIGRAVITY_REQUEST_BLACKLIST = ["output_config"];
export class AntigravityExecutor extends BaseExecutor {
constructor() {
super("antigravity", PROVIDERS.antigravity);
@@ -83,7 +86,9 @@ export class AntigravityExecutor extends BaseExecutor {
tools = allDeclarations.length > 0 ? [{ functionDeclarations: allDeclarations }] : [];
}
// Strip tools/toolConfig (handled separately) and blacklisted fields that Google rejects
const { tools: _originalTools, toolConfig: _originalToolConfig, ...requestWithoutTools } = body.request || {};
for (const key of ANTIGRAVITY_REQUEST_BLACKLIST) delete requestWithoutTools[key];
const generationConfig = { ...(requestWithoutTools.generationConfig || {}) };
if (generationConfig.maxOutputTokens > MAX_ANTIGRAVITY_OUTPUT_TOKENS) {
generationConfig.maxOutputTokens = MAX_ANTIGRAVITY_OUTPUT_TOKENS;

View File

@@ -1,19 +1,20 @@
import { DefaultExecutor } from "./default.js";
import { resolveXiaomiTokenplanBaseUrl } from "../config/providers.js";
import { getModelTargetFormat } from "../config/providerModels.js";
import { FORMATS } from "../translator/formats.js";
// import { getModelTargetFormat } from "../config/providerModels.js";
// import { FORMATS } from "../translator/formats.js";
export class XiaomiTokenplanExecutor extends DefaultExecutor {
constructor() {
super("xiaomi-tokenplan");
}
// Claude-native aliases route to the Anthropic-compatible messages endpoint
// Token Plan keys are region-specific — always OpenAI-compatible /chat/completions
buildUrl(model, stream, urlIndex = 0, credentials = null) {
const baseUrl = resolveXiaomiTokenplanBaseUrl(credentials);
if (getModelTargetFormat(model, model) === FORMATS.CLAUDE) {
return `${baseUrl.replace(/\/v1\/?$/, "/anthropic/v1")}/messages`;
}
// Claude-native aliases route to the Anthropic-compatible messages endpoint
// if (getModelTargetFormat(this.provider, model) === FORMATS.CLAUDE) {
// return `${baseUrl.replace(/\/v1\/?$/, "/anthropic/v1")}/messages`;
// }
return `${baseUrl}/chat/completions`;
}
}

View File

@@ -29,7 +29,7 @@ export default {
},
retry: {
"429": {
attempts: 6,
attempts: 3,
},
"503": {
attempts: 3,

View File

@@ -30,6 +30,7 @@ import {
isThinkingEnabled,
buildThinkingSystemPrefix,
KIRO_AGENTIC_SYSTEM_PROMPT,
resolveDefaultProfileArn,
} from "../../config/kiroConstants.js";
import { DEFAULT_IMAGE_MIME } from "../schema/index.js";
import { ROLE, CLAUDE_BLOCK } from "../schema/index.js";
@@ -397,7 +398,11 @@ export function claudeToKiroRequest(model, body, stream, credentials) {
reconcileOrphanedToolResults(history, currentMessage);
}
const profileArn = credentials?.providerSpecificData?.profileArn || "";
// API-key auth must never use the shared default ARN (403); OAuth/social fall back to it.
const authMethod = credentials?.providerSpecificData?.authMethod;
const profileArn = authMethod === "api_key"
? (credentials?.providerSpecificData?.profileArn || "")
: (credentials?.providerSpecificData?.profileArn || resolveDefaultProfileArn(authMethod));
let finalContent = currentMessage?.userInputMessage?.content || "";