This commit is contained in:
2026-07-06 00:01:34 +07:00
parent 2729408ef3
commit e7470e955e
108 changed files with 4131 additions and 529 deletions

View File

@@ -1,7 +1,7 @@
// Real Antigravity-MITM requests (Gemini-internal: { request: { contents, ... } }) → OpenAI.
import { describe, it, expect } from "vitest";
import "./registerAll.js";
import { translateRequest } from "../../open-sse/translator/index.js";
import { translateRequest, translateResponse, initState } from "../../open-sse/translator/index.js";
import { FORMATS } from "../../open-sse/translator/formats.js";
import { AntigravityExecutor } from "../../open-sse/executors/antigravity.js";
@@ -9,10 +9,9 @@ const AG2O = (req) =>
translateRequest(FORMATS.ANTIGRAVITY, FORMATS.OPENAI, "m", { request: req }, true, null, null);
describe("Antigravity → OpenAI", () => {
// antigravity-to-openai.js:177-189 — content with BOTH functionResponse and functionCall/text
// returns toolResults early → drops the tool calls / text.
// KNOWN BUG
it.fails("functionResponse + functionCall in same content keeps both", () => {
// antigravity-to-openai.js — content with BOTH functionResponse and functionCall/text
// previously returned toolResults early → dropped tool calls / text (fixed in #2225)
it("functionResponse + functionCall in same content keeps both", () => {
const out = AG2O({
contents: [{
role: "model",
@@ -54,6 +53,32 @@ describe("Antigravity → OpenAI", () => {
});
});
describe("Antigravity → Claude", () => {
it("tool call input_json_delta includes Anthropic index", () => {
const state = initState(FORMATS.CLAUDE);
const events = translateResponse(FORMATS.ANTIGRAVITY, FORMATS.CLAUDE, {
response: {
responseId: "resp-1",
modelVersion: "gemini-pro-agent",
candidates: [{
content: {
role: "model",
parts: [{ functionCall: { name: "bash", args: { command: "git status" } } }],
},
finishReason: "STOP",
index: 0,
}],
},
}, state);
const jsonDelta = events.find(
(event) => event.type === "content_block_delta" && event.delta?.type === "input_json_delta"
);
expect(jsonDelta).toMatchObject({ index: expect.any(Number) });
expect(JSON.parse(jsonDelta.delta.partial_json)).toEqual({ command: "git status" });
});
});
describe("Antigravity executor", () => {
it("strips optional from nested tool schemas", () => {
const out = new AntigravityExecutor().transformRequest("gemini-2.5-pro", {

View File

@@ -171,6 +171,7 @@ describe("Kiro → Claude (direct route, OpenAI-shaped chunks from executor)", (
const jsonDelta = events.find(
(e) => e.type === "content_block_delta" && e.delta.type === "input_json_delta"
);
expect(jsonDelta.index).toBeDefined();
expect(jsonDelta.delta.partial_json).toBe('{"q":"x"}');
const md = events.find((e) => e.type === "message_delta");
expect(md.delta.stop_reason).toBe("tool_use");

View File

@@ -0,0 +1,58 @@
// E2E: hit live local proxy → verify nvidia MiniMax M2.7 doesn't 400 on
// unsupported "thinking" param (nvidia NIM is OpenAI-compatible).
// Requires dev server running on NV_E2E_PORT + an active router API key in DB.
// RUN_E2E=1 npx vitest run --config tests/vitest.config.js tests/translator/real/nvidia-thinking.e2e.test.js
import { describe, it, expect, beforeAll } from "vitest";
import { getApiKeys } from "../../../src/lib/db/repos/apiKeysRepo.js";
const PORT = process.env.NV_E2E_PORT || "20127";
const BASE = `http://localhost:${PORT}`;
const MODELS = [
"nvidia/minimaxai/minimax-m2.7",
"nvidia/minimaxai/minimax-m3",
"nvidia/z-ai/glm-5.2",
"nvidia/deepseek-ai/deepseek-v4-pro",
"nvidia/deepseek-ai/deepseek-v4-flash",
"nvidia/moonshotai/kimi-k2.6",
"nvidia/nvidia/nemotron-3-ultra-550b-a55b",
];
const RUN = process.env.RUN_E2E === "1";
const maybe = RUN ? describe : describe.skip;
async function drain(res) {
const reader = res.body.getReader();
const decoder = new TextDecoder();
let out = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
out += decoder.decode(value, { stream: true });
}
return out;
}
maybe("nvidia thinking e2e", () => {
let apiKey = "";
beforeAll(async () => {
const keys = await getApiKeys();
apiKey = keys.find((k) => k.isActive)?.key || process.env.NV_E2E_KEY || "";
});
it.each(MODELS)("%s with reasoning_effort -> no 'thinking' 400", async (model) => {
if (!apiKey) return expect(true).toBe(true);
const res = await fetch(`${BASE}/v1/chat/completions`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` },
body: JSON.stringify({
model,
stream: true,
max_tokens: 64,
reasoning_effort: "low",
messages: [{ role: "user", content: "Reply with the single word: hi" }],
}),
});
const raw = await drain(res);
expect(/Unsupported parameter.*thinking/i.test(raw), `${model} rejected 'thinking'`).toBe(false);
expect(res.status, `${model} bad status ${res.status}`).toBeLessThan(400);
}, 90000);
});