feat(shared): define harness protocols
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import * as shared from "../src/index.js";
|
||||
|
||||
function modelSchema(): { safeParse(value: unknown): { success: boolean } } {
|
||||
const candidate = Reflect.get(shared, "ModelConnectionInputSchema");
|
||||
expect(candidate, "ModelConnectionInputSchema must be exported").toBeDefined();
|
||||
return candidate;
|
||||
}
|
||||
|
||||
const valid = {
|
||||
providerId: "openai",
|
||||
api: "openai-responses",
|
||||
modelId: "gpt-image",
|
||||
supportsImages: true,
|
||||
};
|
||||
|
||||
describe("ModelConnectionInputSchema", () => {
|
||||
it("accepts a supported API with bounded model metadata", () => {
|
||||
expect(modelSchema().safeParse({
|
||||
...valid,
|
||||
baseUrl: "https://api.example.com/v1",
|
||||
apiKey: "sk-example",
|
||||
displayName: "Training model",
|
||||
contextWindow: 128_000,
|
||||
maxTokens: 4096,
|
||||
}).success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects unknown fields instead of silently stripping them", () => {
|
||||
expect(modelSchema().safeParse({ ...valid, headers: { authorization: "secret" } }).success).toBe(false);
|
||||
});
|
||||
|
||||
it.each(["gemini", "openai-chat", ""])("rejects unsupported API %s", (api) => {
|
||||
expect(modelSchema().safeParse({ ...valid, api }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user