File size: 1,703 Bytes
06671aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import assert from "node:assert/strict";
import test from "node:test";
import { resetInferenceManifestCache } from "./config";
import { MissingApiKeyError } from "./errors";
import { executeCompleteText } from "./execute";

test.beforeEach(() => {
    resetInferenceManifestCache();
    delete process.env.INFERENCE_MANIFEST_PATH;
    delete process.env.OPENAI_API_KEY;
    delete process.env.GEMINI_API_KEY;
});

test("executeCompleteText routes openai-api to proxy-openai adapter", async () => {
    await assert.rejects(
        () =>
            executeCompleteText({
                model: "gemini-3-flash-agent-high",
                explicitRequestProvider: "openai-api",
                user: "hello",
            }),
        (error: unknown) => {
            assert.ok(error instanceof MissingApiKeyError);
            assert.equal(error.provider, "proxy-openai");
            return true;
        },
    );
});

test("executeCompleteText rejects direct Gemini for proxy-only models", async () => {
    await assert.rejects(
        () =>
            executeCompleteText({
                model: "gemini-3.5-flash-high",
                explicitRequestProvider: "gemini_sdk",
                user: "hello",
            }),
        (error: unknown) => {
            return error instanceof Error &&
                error.message === "provider_model_mismatch";
        },
    );
});

test("execute layer does not implement empty-turn retries", async () => {
    const fs = await import("node:fs/promises");
    const executeSource = await fs.readFile(
        new URL("./execute.ts", import.meta.url),
        "utf8",
    );
    assert.doesNotMatch(executeSource, /emptyTurn|emptyRetries/i);
});