2026-05-17 00:09:21 +09:00
|
|
|
import { describe, expect, test } from "bun:test"
|
2026-05-07 16:18:41 +02:00
|
|
|
import { buildAgent } from "./agent-builder"
|
|
|
|
|
import type { AgentFactory } from "./types"
|
|
|
|
|
|
|
|
|
|
describe("#given an agent factory with mode", () => {
|
2026-05-17 00:09:21 +09:00
|
|
|
const mockFactory: AgentFactory = Object.assign((model: string) => ({
|
2026-05-07 16:18:41 +02:00
|
|
|
name: "test-agent",
|
|
|
|
|
description: "Test",
|
|
|
|
|
instructions: "test",
|
|
|
|
|
model,
|
|
|
|
|
temperature: 0.1,
|
2026-05-17 00:09:21 +09:00
|
|
|
}), { mode: "subagent" as const })
|
2026-05-07 16:18:41 +02:00
|
|
|
|
|
|
|
|
test("#when building agent from factory", () => {
|
|
|
|
|
const agent = buildAgent(mockFactory, "test-model")
|
|
|
|
|
expect(agent.mode).toBe("subagent")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe("#given an agent factory with mode=primary", () => {
|
2026-05-17 00:09:21 +09:00
|
|
|
const mockFactory: AgentFactory = Object.assign((model: string) => ({
|
2026-05-07 16:18:41 +02:00
|
|
|
name: "primary-agent",
|
|
|
|
|
description: "Primary Test",
|
|
|
|
|
instructions: "test",
|
|
|
|
|
model,
|
|
|
|
|
temperature: 0.1,
|
2026-05-17 00:09:21 +09:00
|
|
|
}), { mode: "primary" as const })
|
2026-05-07 16:18:41 +02:00
|
|
|
|
|
|
|
|
test("#when building agent from factory", () => {
|
|
|
|
|
const agent = buildAgent(mockFactory, "test-model")
|
|
|
|
|
expect(agent.mode).toBe("primary")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe("#given an agent config object without mode", () => {
|
|
|
|
|
const mockConfig = {
|
|
|
|
|
name: "config-agent",
|
|
|
|
|
description: "Config Test",
|
|
|
|
|
instructions: "test",
|
|
|
|
|
model: "test-model",
|
|
|
|
|
temperature: 0.1,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test("#when building agent from config object", () => {
|
|
|
|
|
const agent = buildAgent(mockConfig, "test-model")
|
|
|
|
|
expect(agent.mode).toBeUndefined()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe("#given an agent factory with mode but config already has mode", () => {
|
2026-05-17 00:09:21 +09:00
|
|
|
const mockFactory: AgentFactory = Object.assign((model: string) => ({
|
2026-05-07 16:18:41 +02:00
|
|
|
name: "override-agent",
|
|
|
|
|
description: "Override Test",
|
|
|
|
|
instructions: "test",
|
|
|
|
|
model,
|
|
|
|
|
temperature: 0.1,
|
2026-05-17 00:09:21 +09:00
|
|
|
mode: "all" as const,
|
|
|
|
|
}), { mode: "subagent" as const })
|
2026-05-07 16:18:41 +02:00
|
|
|
|
|
|
|
|
test("#when building agent from factory", () => {
|
|
|
|
|
const agent = buildAgent(mockFactory, "test-model")
|
|
|
|
|
expect(agent.mode).toBe("all")
|
|
|
|
|
})
|
|
|
|
|
})
|