Files
united-workforce/packages/workflow-agent-hermes/__tests__/hermes-agent.test.ts
T
xingyue c5fd84432f fix(agent): defer config validation to call time
Bundle top-level code runs during `workflow add` (descriptor extraction),
but agent config env vars (e.g. WORKFLOW_HERMES_COMMAND) are only available
at `workflow run` time. Deferring validation prevents premature throws.
2026-05-12 12:58:06 +08:00

49 lines
1.2 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { createHermesAgent, validateHermesAgentConfig } from "../src/index.js";
describe("validateHermesAgentConfig", () => {
test("accepts valid config", () => {
const r = validateHermesAgentConfig({
command: "/usr/local/bin/hermes",
model: null,
timeout: null,
});
expect(r.ok).toBe(true);
});
test("rejects non-absolute command", () => {
const r = validateHermesAgentConfig({
command: "hermes",
model: null,
timeout: null,
});
expect(r.ok).toBe(false);
if (!r.ok) {
expect(r.error).toContain("absolute path");
}
});
test("rejects negative timeout", () => {
const r = validateHermesAgentConfig({
command: "/usr/local/bin/hermes",
model: null,
timeout: -5,
});
expect(r.ok).toBe(false);
if (!r.ok) {
expect(r.error).toContain("timeout");
}
});
});
describe("createHermesAgent", () => {
test("returns an AgentFn even with invalid config (validation deferred to call)", () => {
const agent = createHermesAgent({
command: "/usr/local/bin/hermes",
model: null,
timeout: -5,
});
expect(typeof agent).toBe("function");
});
});