Add Beryl Agent and harness source

This commit is contained in:
2026-09-08 20:10:03 +08:00
parent 06d72d001c
commit 47cfbcd66a
70 changed files with 12558 additions and 0 deletions
@@ -0,0 +1,39 @@
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import type { FastifyInstance } from "fastify";
import { buildApp } from "../src/app.js";
let app: FastifyInstance;
beforeAll(async () => {
app = await buildApp();
});
afterAll(async () => app.close());
describe("server", () => {
it("is healthy", async () => {
const r = await app.inject({ url: "/health" });
expect(r.statusCode).toBe(200);
expect(r.json().requestId).toMatch(/^req_/);
});
it("creates a session and redacts model key", async () => {
const c = await app.inject({ method: "POST", url: "/api/sessions" });
const id = c.json().sessionId;
const r = await app.inject({
method: "PUT",
url: `/api/sessions/${id}/model-config`,
payload: {
providerId: "openai",
api: "openai-responses",
baseUrl: "https://api.openai.com/v1",
apiKey: "secret-value",
modelId: "demo",
supportsImages: true,
},
});
expect(r.statusCode).toBe(200);
expect(r.body).not.toContain("secret-value");
expect(r.json().config.keyHint).toBe("••••alue");
});
it("returns unified 404", async () => {
const r = await app.inject({ url: "/api/sessions/nope/model-config" });
expect(r.statusCode).toBe(404);
expect(r.json().error.code).toBe("SESSION_NOT_FOUND");
});
});