incantx 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +254 -0
- package/dist/cli.js +460 -0
- package/dist/cli.js.map +16 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +473 -0
- package/dist/index.js.map +17 -0
- package/dist/src/agent/exampleJsonlAgent.d.ts +1 -0
- package/dist/src/agent/index.d.ts +3 -0
- package/dist/src/agent/mockWeatherAgent.d.ts +5 -0
- package/dist/src/agent/openaiChatAgent.d.ts +7 -0
- package/dist/src/agent/types.d.ts +48 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/fixture/index.d.ts +1 -0
- package/dist/src/fixture/load.d.ts +2 -0
- package/dist/src/fixture/types.d.ts +31 -0
- package/dist/src/judge/openaiJudge.d.ts +11 -0
- package/dist/src/runner/deepMatch.d.ts +1 -0
- package/dist/src/runner/expectations.d.ts +16 -0
- package/dist/src/runner/runFixtureFile.d.ts +17 -0
- package/dist/src/runner/subprocessAgent.d.ts +3 -0
- package/package.json +46 -0
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli.ts", "../src/runner/runFixtureFile.ts", "../src/fixture/load.ts", "../src/judge/openaiJudge.ts", "../src/runner/subprocessAgent.ts", "../src/runner/deepMatch.ts", "../src/runner/expectations.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"#!/usr/bin/env bun\nimport { stat } from \"node:fs/promises\";\nimport { extname, resolve } from \"node:path\";\nimport { Glob } from \"bun\";\nimport { runFixtureFile } from \"./runner/runFixtureFile\";\n\nfunction usage(): string {\n return [\n \"Usage:\",\n \" incantx <file-or-dir> [--judge auto|off|on] [--judge-model <model>]\",\n \" incantx run <file-or-dir> [--judge auto|off|on] [--judge-model <model>]\",\n \"\",\n \"Examples:\",\n \" incantx tests/fixtures/weather.yaml\",\n \" incantx tests/fixtures --judge off\",\n ].join(\"\\n\");\n}\n\nfunction parseArgs(argv: string[]) {\n const [first, ...restAll] = argv;\n const opts: { judge?: \"auto\" | \"off\" | \"on\"; judgeModel?: string } = {};\n\n if (!first) return { command: \"help\" as const };\n if (first === \"-h\" || first === \"--help\") return { command: \"help\" as const };\n\n const target = first === \"run\" ? restAll[0] : first;\n const rest = first === \"run\" ? restAll.slice(1) : restAll;\n\n for (let i = 0; i < rest.length; i++) {\n const a = rest[i];\n if (a === \"--judge\") opts.judge = rest[++i] as any;\n else if (a === \"--judge-model\") opts.judgeModel = rest[++i];\n else if (a === \"-h\" || a === \"--help\") return { command: \"help\" as const };\n else throw new Error(`Unknown arg: ${a}`);\n }\n\n return { command: \"run\" as const, target, opts };\n}\n\nasync function listFixtureFiles(target: string): Promise<string[]> {\n const abs = resolve(target);\n const s = await stat(abs);\n if (s.isFile()) return [abs];\n\n const glob = new Glob(\"**/*.{yaml,yml}\");\n const out: string[] = [];\n for await (const rel of glob.scan({ cwd: abs, onlyFiles: true })) {\n out.push(resolve(abs, rel));\n }\n out.sort();\n return out;\n}\n\nfunction formatStatus(status: \"pass\" | \"fail\" | \"skip\"): string {\n if (status === \"pass\") return \"PASS\";\n if (status === \"skip\") return \"SKIP\";\n return \"FAIL\";\n}\n\nasync function main() {\n const parsed = parseArgs(process.argv.slice(2));\n if ((parsed as any).command === \"help\" || !(\"command\" in parsed) || parsed.command !== \"run\") {\n console.log(usage());\n process.exit(0);\n }\n\n if (!parsed.target) throw new Error(\"Missing <file-or-dir>.\");\n\n const files = await listFixtureFiles(parsed.target);\n if (files.length === 0) throw new Error(`No fixture files found under: ${parsed.target}`);\n\n let pass = 0;\n let fail = 0;\n let skip = 0;\n\n for (const file of files) {\n if (![\".yaml\", \".yml\"].includes(extname(file))) continue;\n const res = await runFixtureFile(file, {\n judgeMode: parsed.opts.judge ?? \"auto\",\n judgeModel: parsed.opts.judgeModel,\n });\n\n console.log(res.path);\n for (const r of res.results) {\n console.log(` ${formatStatus(r.status)} ${r.id}${r.reason ? ` — ${r.reason}` : \"\"}`);\n if (r.status === \"pass\") pass++;\n else if (r.status === \"skip\") skip++;\n else fail++;\n }\n }\n\n console.log(`\\nSummary: ${pass} passed, ${fail} failed, ${skip} skipped`);\n process.exit(fail > 0 ? 1 : 0);\n}\n\nawait main();\n",
|
|
6
|
+
"import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport type { AssistantMessage } from \"../agent/types\";\nimport { loadFixtureFile } from \"../fixture/load\";\nimport type { AgentSpec, Fixture, FixtureFile } from \"../fixture/types\";\nimport { createOpenAIJudge } from \"../judge/openaiJudge\";\nimport { callSubprocessAgent } from \"./subprocessAgent\";\nimport type { ExpectationResult, Judge } from \"./expectations\";\nimport { evaluateExpectations } from \"./expectations\";\n\nexport type JudgeMode = \"off\" | \"auto\" | \"on\";\n\nexport type RunOptions = {\n judgeMode?: JudgeMode;\n judgeModel?: string;\n};\n\nexport type FixtureResult = {\n id: string;\n status: \"pass\" | \"fail\" | \"skip\";\n reason?: string;\n message?: AssistantMessage;\n};\n\nexport type FixtureFileResult = {\n path: string;\n results: FixtureResult[];\n};\n\nfunction pickAgentSpec(file: FixtureFile, fixture: Fixture): AgentSpec {\n const agent = fixture.agent ?? file.agent;\n if (!agent) throw new Error(`Fixture '${fixture.id}' has no agent. Add file-level 'agent:' or fixture-level 'agent:'.`);\n if ((agent.type ?? \"subprocess\") !== \"subprocess\") throw new Error(`Unsupported agent type: ${agent.type}`);\n return agent;\n}\n\nfunction makeJudge(mode: JudgeMode, model?: string): Judge | undefined {\n if (mode === \"off\") return undefined;\n\n const apiKey = process.env.OPENAI_API_KEY;\n if (!apiKey) {\n if (mode === \"on\") throw new Error(\"Judge mode is 'on' but OPENAI_API_KEY is not set.\");\n return undefined;\n }\n\n return createOpenAIJudge({ apiKey, model });\n}\n\nexport async function runFixtureFile(path: string, options: RunOptions = {}): Promise<FixtureFileResult> {\n const absolute = resolve(path);\n const yamlText = await readFile(absolute, \"utf8\");\n const file = loadFixtureFile(yamlText);\n\n const judgeMode = options.judgeMode ?? \"auto\";\n const judge = makeJudge(judgeMode, options.judgeModel);\n\n const results: FixtureResult[] = [];\n\n for (const fixture of file.fixtures) {\n try {\n const agent = pickAgentSpec(file, fixture);\n const messages = [...(fixture.history ?? []), { role: \"user\", content: fixture.input } as const];\n\n const message = await callSubprocessAgent(agent, {\n messages,\n tools: [],\n tool_choice: \"auto\",\n });\n\n const expectation = await evaluateExpectations(fixture.expect, message, judge);\n results.push({\n id: fixture.id,\n status: expectation.status,\n reason: (expectation as Extract<ExpectationResult, { status: \"fail\" | \"skip\" }>).reason,\n message,\n });\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n results.push({ id: fixture.id, status: \"fail\", reason });\n }\n }\n\n return { path: absolute, results };\n}\n",
|
|
7
|
+
"import { parse as parseYaml } from \"yaml\";\nimport type { AgentSpec, FixtureFile } from \"./types\";\n\nfunction expandEnvVars(value: string, env: Record<string, string | undefined>): string {\n return value.replace(/\\$\\{([A-Z0-9_]+)\\}/gi, (_, key: string) => env[key] ?? \"\");\n}\n\nfunction normalizeAgentSpec(raw: AgentSpec, env: Record<string, string | undefined>): AgentSpec {\n const normalized: AgentSpec = { ...raw };\n\n if (normalized.type === undefined) normalized.type = \"subprocess\";\n if (!Array.isArray(normalized.command) || normalized.command.length === 0) {\n throw new Error(\"`agent.command` must be a non-empty array of strings.\");\n }\n\n normalized.command = normalized.command.map((part) => String(part));\n\n if (normalized.cwd !== undefined) normalized.cwd = String(normalized.cwd);\n if (normalized.timeout_ms !== undefined) normalized.timeout_ms = Number(normalized.timeout_ms);\n\n if (normalized.env) {\n const expanded: Record<string, string> = {};\n for (const [k, v] of Object.entries(normalized.env)) {\n expanded[k] = expandEnvVars(String(v), env);\n }\n normalized.env = expanded;\n }\n\n return normalized;\n}\n\nexport function loadFixtureFile(yamlText: string, env: Record<string, string | undefined> = process.env): FixtureFile {\n const data = parseYaml(yamlText) as unknown;\n if (!data || typeof data !== \"object\") throw new Error(\"Fixture file must be a YAML object.\");\n\n const file = data as Partial<FixtureFile>;\n if (!Array.isArray(file.fixtures)) throw new Error(\"Fixture file must contain `fixtures: [...]`.\");\n\n const normalized: FixtureFile = {\n fixtures: file.fixtures as FixtureFile[\"fixtures\"],\n };\n\n if (file.agent) normalized.agent = normalizeAgentSpec(file.agent as AgentSpec, env);\n\n normalized.fixtures = normalized.fixtures.map((fixture, index) => {\n if (!fixture || typeof fixture !== \"object\") throw new Error(`fixtures[${index}] must be an object.`);\n if (!(\"id\" in fixture)) throw new Error(`fixtures[${index}].id is required.`);\n if (!(\"input\" in fixture)) throw new Error(`fixtures[${index}].input is required.`);\n\n const out = { ...fixture } as any;\n out.id = String(out.id);\n out.input = String(out.input);\n\n if (out.agent) out.agent = normalizeAgentSpec(out.agent as AgentSpec, env);\n if (out.expect?.tool_calls_match === undefined && out.expect?.tool_calls) out.expect.tool_calls_match = \"contains\";\n\n return out;\n });\n\n return normalized;\n}\n",
|
|
8
|
+
"import type { AssistantMessage } from \"../agent/types\";\nimport type { ExpectationResult } from \"../runner/expectations\";\n\nexport type OpenAIJudgeOptions = {\n apiKey: string;\n baseUrl?: string;\n model?: string;\n};\n\ntype JudgeResponse = { pass: boolean; reason: string };\n\nexport function createOpenAIJudge(options: OpenAIJudgeOptions) {\n const baseUrl = options.baseUrl ?? process.env.OPENAI_BASE_URL ?? \"https://api.openai.com/v1\";\n const model = options.model ?? process.env.OPENAI_JUDGE_MODEL ?? \"gpt-4o-mini\";\n\n return async ({ expectation, message }: { expectation: string; message: AssistantMessage }): Promise<ExpectationResult> => {\n const system =\n \"You are a strict test evaluator. Decide if the assistant message satisfies the expectation. \" +\n \"Respond with ONLY valid JSON: {\\\"pass\\\": boolean, \\\"reason\\\": string}.\";\n\n const user = JSON.stringify(\n {\n expectation,\n assistant_message: message,\n },\n null,\n 2\n );\n\n const res = await fetch(`${baseUrl}/chat/completions`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${options.apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n model,\n temperature: 0,\n messages: [\n { role: \"system\", content: system },\n { role: \"user\", content: user },\n ],\n }),\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => \"\");\n return {\n status: \"fail\",\n reason: `Judge call failed: ${res.status} ${res.statusText}${body ? `\\n${body}` : \"\"}`,\n };\n }\n\n const data = (await res.json()) as any;\n const content = data?.choices?.[0]?.message?.content;\n if (typeof content !== \"string\" || content.trim().length === 0) {\n return { status: \"fail\", reason: \"Judge returned no content.\" };\n }\n\n let parsed: JudgeResponse;\n try {\n parsed = JSON.parse(content) as JudgeResponse;\n } catch {\n return { status: \"fail\", reason: `Judge did not return valid JSON.\\n${content}` };\n }\n\n if (parsed.pass) return { status: \"pass\" };\n return { status: \"fail\", reason: parsed.reason || \"Expectation not satisfied.\" };\n };\n}\n",
|
|
9
|
+
"import type { AssistantMessage, ChatAgentRequest } from \"../agent/types\";\nimport type { AgentSpec } from \"../fixture/types\";\n\ntype AgentProcessSuccess = { message: AssistantMessage };\ntype AgentProcessError = { error: { message: string } };\n\nfunction isSuccess(value: unknown): value is AgentProcessSuccess {\n return !!value && typeof value === \"object\" && \"message\" in (value as any);\n}\n\nfunction isError(value: unknown): value is AgentProcessError {\n return !!value && typeof value === \"object\" && \"error\" in (value as any);\n}\n\nasync function readFirstNonEmptyLine(stream: ReadableStream<Uint8Array>, timeoutMs: number): Promise<string> {\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n const deadline = Date.now() + timeoutMs;\n\n type ReadResult = { value?: Uint8Array; done: boolean };\n\n while (true) {\n const timeLeft = deadline - Date.now();\n if (timeLeft <= 0) throw new Error(`Timed out waiting for agent response after ${timeoutMs}ms.`);\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n const timerPromise = new Promise<never>((_, reject) => {\n timerId = setTimeout(() => reject(new Error(`Timed out waiting for agent response after ${timeoutMs}ms.`)), timeLeft);\n });\n\n let chunk: ReadResult;\n try {\n chunk = await Promise.race([reader.read(), timerPromise]);\n } finally {\n if (timerId !== undefined) clearTimeout(timerId);\n }\n\n const { value, done } = chunk;\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n\n while (true) {\n const idx = buffer.indexOf(\"\\n\");\n if (idx === -1) break;\n const line = buffer.slice(0, idx).trim();\n buffer = buffer.slice(idx + 1);\n if (line.length > 0) return line;\n }\n }\n\n const tail = buffer.trim();\n if (tail.length > 0) return tail;\n throw new Error(\"Agent produced no output on stdout.\");\n}\n\nexport async function callSubprocessAgent(spec: AgentSpec, request: ChatAgentRequest): Promise<AssistantMessage> {\n const timeoutMs = spec.timeout_ms ?? 20_000;\n\n const proc = Bun.spawn(spec.command, {\n cwd: spec.cwd,\n env: { ...process.env, ...(spec.env ?? {}) },\n stdin: \"pipe\",\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n\n const stdin = proc.stdin;\n if (!stdin) throw new Error(\"Failed to open agent stdin.\");\n\n stdin.write(`${JSON.stringify(request)}\\n`);\n stdin.end();\n\n let stderrText = \"\";\n const stderrPromise = (async () => {\n if (!proc.stderr) return;\n stderrText = await new Response(proc.stderr).text().catch(() => \"\");\n })();\n\n try {\n if (!proc.stdout) throw new Error(\"Failed to open agent stdout.\");\n const line = await readFirstNonEmptyLine(proc.stdout, timeoutMs);\n\n let payload: unknown;\n try {\n payload = JSON.parse(line) as unknown;\n } catch {\n throw new Error(\n `Agent stdout is not valid JSON.\\n` +\n `Line: ${line}\\n` +\n (stderrText ? `Stderr:\\n${stderrText}` : \"\")\n );\n }\n\n if (isError(payload)) throw new Error(payload.error.message);\n if (!isSuccess(payload)) {\n throw new Error(`Agent response must be { \"message\": { ... } } or { \"error\": { \"message\": ... } }.`);\n }\n\n return payload.message;\n } finally {\n proc.kill();\n await Promise.allSettled([proc.exited, stderrPromise]);\n }\n}\n",
|
|
10
|
+
"export function deepPartialMatch(expected: unknown, actual: unknown): boolean {\n if (expected === actual) return true;\n\n if (expected === null || actual === null) return expected === actual;\n\n const expectedType = typeof expected;\n const actualType = typeof actual;\n if (expectedType !== actualType) return false;\n\n if (Array.isArray(expected)) {\n if (!Array.isArray(actual)) return false;\n if (expected.length !== actual.length) return false;\n for (let i = 0; i < expected.length; i++) {\n if (!deepPartialMatch(expected[i], actual[i])) return false;\n }\n return true;\n }\n\n if (expectedType === \"object\") {\n if (Array.isArray(actual)) return false;\n const expectedObj = expected as Record<string, unknown>;\n const actualObj = actual as Record<string, unknown>;\n for (const [key, expectedValue] of Object.entries(expectedObj)) {\n if (!(key in actualObj)) return false;\n if (!deepPartialMatch(expectedValue, actualObj[key])) return false;\n }\n return true;\n }\n\n return false;\n}\n\n",
|
|
11
|
+
"import type { AssistantMessage } from \"../agent/types\";\nimport type { FixtureExpectation, ToolCallExpectation } from \"../fixture/types\";\nimport { deepPartialMatch } from \"./deepMatch\";\n\nexport type ExpectationResult =\n | { status: \"pass\" }\n | { status: \"fail\"; reason: string }\n | { status: \"skip\"; reason: string };\n\nfunction parseJsonOrUndefined(value: string): unknown | undefined {\n try {\n return JSON.parse(value) as unknown;\n } catch {\n return undefined;\n }\n}\n\nfunction matchToolCall(expected: ToolCallExpectation, actual: NonNullable<AssistantMessage[\"tool_calls\"]>[number]): boolean {\n if (actual.function.name !== expected.name) return false;\n if (expected.arguments === undefined) return true;\n const actualArgs = parseJsonOrUndefined(actual.function.arguments);\n if (actualArgs === undefined) return false;\n return deepPartialMatch(expected.arguments, actualArgs);\n}\n\nfunction checkToolCalls(expect: FixtureExpectation, message: AssistantMessage): ExpectationResult {\n const expectedCalls = expect.tool_calls ?? [];\n if (expectedCalls.length === 0) return { status: \"pass\" };\n\n const actualCalls = message.tool_calls ?? [];\n const mode = expect.tool_calls_match ?? \"contains\";\n\n if (mode === \"contains\") {\n for (const expected of expectedCalls) {\n const ok = actualCalls.some((actual) => matchToolCall(expected, actual));\n if (!ok) {\n return {\n status: \"fail\",\n reason: `Expected tool call not found: ${expected.name}`,\n };\n }\n }\n return { status: \"pass\" };\n }\n\n if (actualCalls.length !== expectedCalls.length) {\n return {\n status: \"fail\",\n reason: `Expected exactly ${expectedCalls.length} tool call(s), got ${actualCalls.length}.`,\n };\n }\n\n for (let i = 0; i < expectedCalls.length; i++) {\n const expected = expectedCalls[i];\n const actual = actualCalls[i];\n if (!expected || !actual || !matchToolCall(expected, actual)) {\n return { status: \"fail\", reason: `Tool call mismatch at index ${i}.` };\n }\n }\n\n return { status: \"pass\" };\n}\n\nexport type Judge = (args: { expectation: string; message: AssistantMessage }) => Promise<ExpectationResult>;\n\nexport async function evaluateExpectations(\n expect: FixtureExpectation | undefined,\n message: AssistantMessage,\n judge: Judge | undefined\n): Promise<ExpectationResult> {\n if (!expect) return { status: \"pass\" };\n\n const toolRes = checkToolCalls(expect, message);\n if (toolRes.status !== \"pass\") return toolRes;\n\n if (expect.assistant?.llm) {\n if (!judge) return { status: \"skip\", reason: \"LLM judge not configured.\" };\n return await judge({ expectation: expect.assistant.llm, message });\n }\n\n return { status: \"pass\" };\n}\n"
|
|
12
|
+
],
|
|
13
|
+
"mappings": ";;;;AACA;AACA,6BAAkB;AAClB;;;ACHA;AACA;;;ACDA,kBAAS;AAGT,SAAS,aAAa,CAAC,OAAe,KAAiD;AAAA,EACrF,OAAO,MAAM,QAAQ,wBAAwB,CAAC,GAAG,QAAgB,IAAI,QAAQ,EAAE;AAAA;AAGjF,SAAS,kBAAkB,CAAC,KAAgB,KAAoD;AAAA,EAC9F,MAAM,aAAwB,KAAK,IAAI;AAAA,EAEvC,IAAI,WAAW,SAAS;AAAA,IAAW,WAAW,OAAO;AAAA,EACrD,IAAI,CAAC,MAAM,QAAQ,WAAW,OAAO,KAAK,WAAW,QAAQ,WAAW,GAAG;AAAA,IACzE,MAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AAAA,EAEA,WAAW,UAAU,WAAW,QAAQ,IAAI,CAAC,SAAS,OAAO,IAAI,CAAC;AAAA,EAElE,IAAI,W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,IAAI,IAAI,IAAI;AAAA,IACpB,WAAW,KAAK,IAAI,SAAS;AAAA,MAC3B,QAAQ,IAAI,KAAK,aAAa,EAAE,MAAM,MAAM,EAAE,KAAK,EAAE,SAAS,WAAK,EAAE,WAAW,IAAI;AAAA,MACpF,IAAI,EAAE,WAAW;AAAA,QAAQ;AAAA,MACpB,SAAI,EAAE,WAAW;AAAA,QAAQ;AAAA,MACzB;AAAA;AAAA,IACP;AAAA,EACF;AAAA,EAEA,QAAQ,IAAI;AAAA,WAAc,gBAAgB,gBAAgB,cAAc;AAAA,EACxE,QAAQ,KAAK,OAAO,IAAI,IAAI,CAAC;AAAA;AAG/B,MAAM,KAAK;",
|
|
14
|
+
"debugId": "E9C824803FAB034D64756E2164756E21",
|
|
15
|
+
"names": []
|
|
16
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/agent/mockWeatherAgent.ts
|
|
3
|
+
function last(items) {
|
|
4
|
+
return items.length > 0 ? items[items.length - 1] : undefined;
|
|
5
|
+
}
|
|
6
|
+
function findLatestToolMessage(messages, toolName) {
|
|
7
|
+
for (let i = messages.length - 1;i >= 0; i--) {
|
|
8
|
+
const message = messages[i];
|
|
9
|
+
if (!message)
|
|
10
|
+
continue;
|
|
11
|
+
if (message.role === "tool" && message.name === toolName)
|
|
12
|
+
return message;
|
|
13
|
+
}
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
function tryParseJson(value) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(value);
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function createMockWeatherAgent(options = {}) {
|
|
24
|
+
const toolName = options.toolName ?? "get_weather";
|
|
25
|
+
let callCounter = 0;
|
|
26
|
+
return async ({ messages }) => {
|
|
27
|
+
const latest = last(messages);
|
|
28
|
+
if (!latest || latest.role !== "user") {
|
|
29
|
+
return { role: "assistant", content: "Send a user message to continue." };
|
|
30
|
+
}
|
|
31
|
+
const userText = latest.content.toLowerCase();
|
|
32
|
+
if (userText.includes("weather")) {
|
|
33
|
+
callCounter += 1;
|
|
34
|
+
return {
|
|
35
|
+
role: "assistant",
|
|
36
|
+
content: "",
|
|
37
|
+
tool_calls: [
|
|
38
|
+
{
|
|
39
|
+
id: `call_${callCounter}`,
|
|
40
|
+
type: "function",
|
|
41
|
+
function: {
|
|
42
|
+
name: toolName,
|
|
43
|
+
arguments: JSON.stringify({ location: "Dublin", unit: "c" })
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (userText.includes("umbrella")) {
|
|
50
|
+
const toolMessage = findLatestToolMessage(messages, toolName);
|
|
51
|
+
const payload = toolMessage ? tryParseJson(toolMessage.content) : undefined;
|
|
52
|
+
const condition = payload?.condition?.toLowerCase();
|
|
53
|
+
if (condition?.includes("rain")) {
|
|
54
|
+
return { role: "assistant", content: "Yes\u2014bring an umbrella. The forecast shows rain." };
|
|
55
|
+
}
|
|
56
|
+
if (toolMessage) {
|
|
57
|
+
return { role: "assistant", content: "Probably yes\u2014better to be prepared based on the forecast." };
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
role: "assistant",
|
|
61
|
+
content: "",
|
|
62
|
+
tool_calls: [
|
|
63
|
+
{
|
|
64
|
+
id: `call_${++callCounter}`,
|
|
65
|
+
type: "function",
|
|
66
|
+
function: { name: toolName, arguments: JSON.stringify({ location: "Dublin", unit: "c" }) }
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const reply = { role: "assistant", content: "OK." };
|
|
72
|
+
return reply;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// src/agent/openaiChatAgent.ts
|
|
76
|
+
function createOpenAIChatAgent(options = {}) {
|
|
77
|
+
const apiKey = options.apiKey ?? process.env.OPENAI_API_KEY;
|
|
78
|
+
const baseUrl = options.baseUrl ?? process.env.OPENAI_BASE_URL ?? "https://api.openai.com/v1";
|
|
79
|
+
const defaultModel = options.defaultModel ?? process.env.OPENAI_MODEL ?? "gpt-4o-mini";
|
|
80
|
+
if (!apiKey) {
|
|
81
|
+
throw new Error("Missing OPENAI_API_KEY (or pass { apiKey }).");
|
|
82
|
+
}
|
|
83
|
+
return async (req) => {
|
|
84
|
+
const model = req.model ?? defaultModel;
|
|
85
|
+
const res = await fetch(`${baseUrl}/chat/completions`, {
|
|
86
|
+
method: "POST",
|
|
87
|
+
headers: {
|
|
88
|
+
Authorization: `Bearer ${apiKey}`,
|
|
89
|
+
"Content-Type": "application/json"
|
|
90
|
+
},
|
|
91
|
+
body: JSON.stringify({
|
|
92
|
+
model,
|
|
93
|
+
messages: req.messages,
|
|
94
|
+
tools: req.tools,
|
|
95
|
+
tool_choice: req.tool_choice
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
if (!res.ok) {
|
|
99
|
+
const body = await res.text().catch(() => "");
|
|
100
|
+
throw new Error(`OpenAI chat.completions failed: ${res.status} ${res.statusText}${body ? `
|
|
101
|
+
${body}` : ""}`);
|
|
102
|
+
}
|
|
103
|
+
const data = await res.json();
|
|
104
|
+
const message = data.choices?.[0]?.message;
|
|
105
|
+
if (!message)
|
|
106
|
+
throw new Error("OpenAI chat.completions returned no message.");
|
|
107
|
+
return message;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// src/fixture/load.ts
|
|
111
|
+
import { parse as parseYaml } from "yaml";
|
|
112
|
+
function expandEnvVars(value, env) {
|
|
113
|
+
return value.replace(/\$\{([A-Z0-9_]+)\}/gi, (_, key) => env[key] ?? "");
|
|
114
|
+
}
|
|
115
|
+
function normalizeAgentSpec(raw, env) {
|
|
116
|
+
const normalized = { ...raw };
|
|
117
|
+
if (normalized.type === undefined)
|
|
118
|
+
normalized.type = "subprocess";
|
|
119
|
+
if (!Array.isArray(normalized.command) || normalized.command.length === 0) {
|
|
120
|
+
throw new Error("`agent.command` must be a non-empty array of strings.");
|
|
121
|
+
}
|
|
122
|
+
normalized.command = normalized.command.map((part) => String(part));
|
|
123
|
+
if (normalized.cwd !== undefined)
|
|
124
|
+
normalized.cwd = String(normalized.cwd);
|
|
125
|
+
if (normalized.timeout_ms !== undefined)
|
|
126
|
+
normalized.timeout_ms = Number(normalized.timeout_ms);
|
|
127
|
+
if (normalized.env) {
|
|
128
|
+
const expanded = {};
|
|
129
|
+
for (const [k, v] of Object.entries(normalized.env)) {
|
|
130
|
+
expanded[k] = expandEnvVars(String(v), env);
|
|
131
|
+
}
|
|
132
|
+
normalized.env = expanded;
|
|
133
|
+
}
|
|
134
|
+
return normalized;
|
|
135
|
+
}
|
|
136
|
+
function loadFixtureFile(yamlText, env = process.env) {
|
|
137
|
+
const data = parseYaml(yamlText);
|
|
138
|
+
if (!data || typeof data !== "object")
|
|
139
|
+
throw new Error("Fixture file must be a YAML object.");
|
|
140
|
+
const file = data;
|
|
141
|
+
if (!Array.isArray(file.fixtures))
|
|
142
|
+
throw new Error("Fixture file must contain `fixtures: [...]`.");
|
|
143
|
+
const normalized = {
|
|
144
|
+
fixtures: file.fixtures
|
|
145
|
+
};
|
|
146
|
+
if (file.agent)
|
|
147
|
+
normalized.agent = normalizeAgentSpec(file.agent, env);
|
|
148
|
+
normalized.fixtures = normalized.fixtures.map((fixture, index) => {
|
|
149
|
+
if (!fixture || typeof fixture !== "object")
|
|
150
|
+
throw new Error(`fixtures[${index}] must be an object.`);
|
|
151
|
+
if (!("id" in fixture))
|
|
152
|
+
throw new Error(`fixtures[${index}].id is required.`);
|
|
153
|
+
if (!("input" in fixture))
|
|
154
|
+
throw new Error(`fixtures[${index}].input is required.`);
|
|
155
|
+
const out = { ...fixture };
|
|
156
|
+
out.id = String(out.id);
|
|
157
|
+
out.input = String(out.input);
|
|
158
|
+
if (out.agent)
|
|
159
|
+
out.agent = normalizeAgentSpec(out.agent, env);
|
|
160
|
+
if (out.expect?.tool_calls_match === undefined && out.expect?.tool_calls)
|
|
161
|
+
out.expect.tool_calls_match = "contains";
|
|
162
|
+
return out;
|
|
163
|
+
});
|
|
164
|
+
return normalized;
|
|
165
|
+
}
|
|
166
|
+
// src/runner/runFixtureFile.ts
|
|
167
|
+
import { readFile } from "fs/promises";
|
|
168
|
+
import { resolve } from "path";
|
|
169
|
+
|
|
170
|
+
// src/judge/openaiJudge.ts
|
|
171
|
+
function createOpenAIJudge(options) {
|
|
172
|
+
const baseUrl = options.baseUrl ?? process.env.OPENAI_BASE_URL ?? "https://api.openai.com/v1";
|
|
173
|
+
const model = options.model ?? process.env.OPENAI_JUDGE_MODEL ?? "gpt-4o-mini";
|
|
174
|
+
return async ({ expectation, message }) => {
|
|
175
|
+
const system = "You are a strict test evaluator. Decide if the assistant message satisfies the expectation. " + 'Respond with ONLY valid JSON: {"pass": boolean, "reason": string}.';
|
|
176
|
+
const user = JSON.stringify({
|
|
177
|
+
expectation,
|
|
178
|
+
assistant_message: message
|
|
179
|
+
}, null, 2);
|
|
180
|
+
const res = await fetch(`${baseUrl}/chat/completions`, {
|
|
181
|
+
method: "POST",
|
|
182
|
+
headers: {
|
|
183
|
+
Authorization: `Bearer ${options.apiKey}`,
|
|
184
|
+
"Content-Type": "application/json"
|
|
185
|
+
},
|
|
186
|
+
body: JSON.stringify({
|
|
187
|
+
model,
|
|
188
|
+
temperature: 0,
|
|
189
|
+
messages: [
|
|
190
|
+
{ role: "system", content: system },
|
|
191
|
+
{ role: "user", content: user }
|
|
192
|
+
]
|
|
193
|
+
})
|
|
194
|
+
});
|
|
195
|
+
if (!res.ok) {
|
|
196
|
+
const body = await res.text().catch(() => "");
|
|
197
|
+
return {
|
|
198
|
+
status: "fail",
|
|
199
|
+
reason: `Judge call failed: ${res.status} ${res.statusText}${body ? `
|
|
200
|
+
${body}` : ""}`
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const data = await res.json();
|
|
204
|
+
const content = data?.choices?.[0]?.message?.content;
|
|
205
|
+
if (typeof content !== "string" || content.trim().length === 0) {
|
|
206
|
+
return { status: "fail", reason: "Judge returned no content." };
|
|
207
|
+
}
|
|
208
|
+
let parsed;
|
|
209
|
+
try {
|
|
210
|
+
parsed = JSON.parse(content);
|
|
211
|
+
} catch {
|
|
212
|
+
return { status: "fail", reason: `Judge did not return valid JSON.
|
|
213
|
+
${content}` };
|
|
214
|
+
}
|
|
215
|
+
if (parsed.pass)
|
|
216
|
+
return { status: "pass" };
|
|
217
|
+
return { status: "fail", reason: parsed.reason || "Expectation not satisfied." };
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// src/runner/subprocessAgent.ts
|
|
222
|
+
function isSuccess(value) {
|
|
223
|
+
return !!value && typeof value === "object" && "message" in value;
|
|
224
|
+
}
|
|
225
|
+
function isError(value) {
|
|
226
|
+
return !!value && typeof value === "object" && "error" in value;
|
|
227
|
+
}
|
|
228
|
+
async function readFirstNonEmptyLine(stream, timeoutMs) {
|
|
229
|
+
const reader = stream.getReader();
|
|
230
|
+
const decoder = new TextDecoder;
|
|
231
|
+
let buffer = "";
|
|
232
|
+
const deadline = Date.now() + timeoutMs;
|
|
233
|
+
while (true) {
|
|
234
|
+
const timeLeft = deadline - Date.now();
|
|
235
|
+
if (timeLeft <= 0)
|
|
236
|
+
throw new Error(`Timed out waiting for agent response after ${timeoutMs}ms.`);
|
|
237
|
+
let timerId;
|
|
238
|
+
const timerPromise = new Promise((_, reject) => {
|
|
239
|
+
timerId = setTimeout(() => reject(new Error(`Timed out waiting for agent response after ${timeoutMs}ms.`)), timeLeft);
|
|
240
|
+
});
|
|
241
|
+
let chunk;
|
|
242
|
+
try {
|
|
243
|
+
chunk = await Promise.race([reader.read(), timerPromise]);
|
|
244
|
+
} finally {
|
|
245
|
+
if (timerId !== undefined)
|
|
246
|
+
clearTimeout(timerId);
|
|
247
|
+
}
|
|
248
|
+
const { value, done } = chunk;
|
|
249
|
+
if (done)
|
|
250
|
+
break;
|
|
251
|
+
buffer += decoder.decode(value, { stream: true });
|
|
252
|
+
while (true) {
|
|
253
|
+
const idx = buffer.indexOf(`
|
|
254
|
+
`);
|
|
255
|
+
if (idx === -1)
|
|
256
|
+
break;
|
|
257
|
+
const line = buffer.slice(0, idx).trim();
|
|
258
|
+
buffer = buffer.slice(idx + 1);
|
|
259
|
+
if (line.length > 0)
|
|
260
|
+
return line;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const tail = buffer.trim();
|
|
264
|
+
if (tail.length > 0)
|
|
265
|
+
return tail;
|
|
266
|
+
throw new Error("Agent produced no output on stdout.");
|
|
267
|
+
}
|
|
268
|
+
async function callSubprocessAgent(spec, request) {
|
|
269
|
+
const timeoutMs = spec.timeout_ms ?? 20000;
|
|
270
|
+
const proc = Bun.spawn(spec.command, {
|
|
271
|
+
cwd: spec.cwd,
|
|
272
|
+
env: { ...process.env, ...spec.env ?? {} },
|
|
273
|
+
stdin: "pipe",
|
|
274
|
+
stdout: "pipe",
|
|
275
|
+
stderr: "pipe"
|
|
276
|
+
});
|
|
277
|
+
const stdin = proc.stdin;
|
|
278
|
+
if (!stdin)
|
|
279
|
+
throw new Error("Failed to open agent stdin.");
|
|
280
|
+
stdin.write(`${JSON.stringify(request)}
|
|
281
|
+
`);
|
|
282
|
+
stdin.end();
|
|
283
|
+
let stderrText = "";
|
|
284
|
+
const stderrPromise = (async () => {
|
|
285
|
+
if (!proc.stderr)
|
|
286
|
+
return;
|
|
287
|
+
stderrText = await new Response(proc.stderr).text().catch(() => "");
|
|
288
|
+
})();
|
|
289
|
+
try {
|
|
290
|
+
if (!proc.stdout)
|
|
291
|
+
throw new Error("Failed to open agent stdout.");
|
|
292
|
+
const line = await readFirstNonEmptyLine(proc.stdout, timeoutMs);
|
|
293
|
+
let payload;
|
|
294
|
+
try {
|
|
295
|
+
payload = JSON.parse(line);
|
|
296
|
+
} catch {
|
|
297
|
+
throw new Error(`Agent stdout is not valid JSON.
|
|
298
|
+
` + `Line: ${line}
|
|
299
|
+
` + (stderrText ? `Stderr:
|
|
300
|
+
${stderrText}` : ""));
|
|
301
|
+
}
|
|
302
|
+
if (isError(payload))
|
|
303
|
+
throw new Error(payload.error.message);
|
|
304
|
+
if (!isSuccess(payload)) {
|
|
305
|
+
throw new Error(`Agent response must be { "message": { ... } } or { "error": { "message": ... } }.`);
|
|
306
|
+
}
|
|
307
|
+
return payload.message;
|
|
308
|
+
} finally {
|
|
309
|
+
proc.kill();
|
|
310
|
+
await Promise.allSettled([proc.exited, stderrPromise]);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/runner/deepMatch.ts
|
|
315
|
+
function deepPartialMatch(expected, actual) {
|
|
316
|
+
if (expected === actual)
|
|
317
|
+
return true;
|
|
318
|
+
if (expected === null || actual === null)
|
|
319
|
+
return expected === actual;
|
|
320
|
+
const expectedType = typeof expected;
|
|
321
|
+
const actualType = typeof actual;
|
|
322
|
+
if (expectedType !== actualType)
|
|
323
|
+
return false;
|
|
324
|
+
if (Array.isArray(expected)) {
|
|
325
|
+
if (!Array.isArray(actual))
|
|
326
|
+
return false;
|
|
327
|
+
if (expected.length !== actual.length)
|
|
328
|
+
return false;
|
|
329
|
+
for (let i = 0;i < expected.length; i++) {
|
|
330
|
+
if (!deepPartialMatch(expected[i], actual[i]))
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
if (expectedType === "object") {
|
|
336
|
+
if (Array.isArray(actual))
|
|
337
|
+
return false;
|
|
338
|
+
const expectedObj = expected;
|
|
339
|
+
const actualObj = actual;
|
|
340
|
+
for (const [key, expectedValue] of Object.entries(expectedObj)) {
|
|
341
|
+
if (!(key in actualObj))
|
|
342
|
+
return false;
|
|
343
|
+
if (!deepPartialMatch(expectedValue, actualObj[key]))
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// src/runner/expectations.ts
|
|
352
|
+
function parseJsonOrUndefined(value) {
|
|
353
|
+
try {
|
|
354
|
+
return JSON.parse(value);
|
|
355
|
+
} catch {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function matchToolCall(expected, actual) {
|
|
360
|
+
if (actual.function.name !== expected.name)
|
|
361
|
+
return false;
|
|
362
|
+
if (expected.arguments === undefined)
|
|
363
|
+
return true;
|
|
364
|
+
const actualArgs = parseJsonOrUndefined(actual.function.arguments);
|
|
365
|
+
if (actualArgs === undefined)
|
|
366
|
+
return false;
|
|
367
|
+
return deepPartialMatch(expected.arguments, actualArgs);
|
|
368
|
+
}
|
|
369
|
+
function checkToolCalls(expect, message) {
|
|
370
|
+
const expectedCalls = expect.tool_calls ?? [];
|
|
371
|
+
if (expectedCalls.length === 0)
|
|
372
|
+
return { status: "pass" };
|
|
373
|
+
const actualCalls = message.tool_calls ?? [];
|
|
374
|
+
const mode = expect.tool_calls_match ?? "contains";
|
|
375
|
+
if (mode === "contains") {
|
|
376
|
+
for (const expected of expectedCalls) {
|
|
377
|
+
const ok = actualCalls.some((actual) => matchToolCall(expected, actual));
|
|
378
|
+
if (!ok) {
|
|
379
|
+
return {
|
|
380
|
+
status: "fail",
|
|
381
|
+
reason: `Expected tool call not found: ${expected.name}`
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return { status: "pass" };
|
|
386
|
+
}
|
|
387
|
+
if (actualCalls.length !== expectedCalls.length) {
|
|
388
|
+
return {
|
|
389
|
+
status: "fail",
|
|
390
|
+
reason: `Expected exactly ${expectedCalls.length} tool call(s), got ${actualCalls.length}.`
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
for (let i = 0;i < expectedCalls.length; i++) {
|
|
394
|
+
const expected = expectedCalls[i];
|
|
395
|
+
const actual = actualCalls[i];
|
|
396
|
+
if (!expected || !actual || !matchToolCall(expected, actual)) {
|
|
397
|
+
return { status: "fail", reason: `Tool call mismatch at index ${i}.` };
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return { status: "pass" };
|
|
401
|
+
}
|
|
402
|
+
async function evaluateExpectations(expect, message, judge) {
|
|
403
|
+
if (!expect)
|
|
404
|
+
return { status: "pass" };
|
|
405
|
+
const toolRes = checkToolCalls(expect, message);
|
|
406
|
+
if (toolRes.status !== "pass")
|
|
407
|
+
return toolRes;
|
|
408
|
+
if (expect.assistant?.llm) {
|
|
409
|
+
if (!judge)
|
|
410
|
+
return { status: "skip", reason: "LLM judge not configured." };
|
|
411
|
+
return await judge({ expectation: expect.assistant.llm, message });
|
|
412
|
+
}
|
|
413
|
+
return { status: "pass" };
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// src/runner/runFixtureFile.ts
|
|
417
|
+
function pickAgentSpec(file, fixture) {
|
|
418
|
+
const agent = fixture.agent ?? file.agent;
|
|
419
|
+
if (!agent)
|
|
420
|
+
throw new Error(`Fixture '${fixture.id}' has no agent. Add file-level 'agent:' or fixture-level 'agent:'.`);
|
|
421
|
+
if ((agent.type ?? "subprocess") !== "subprocess")
|
|
422
|
+
throw new Error(`Unsupported agent type: ${agent.type}`);
|
|
423
|
+
return agent;
|
|
424
|
+
}
|
|
425
|
+
function makeJudge(mode, model) {
|
|
426
|
+
if (mode === "off")
|
|
427
|
+
return;
|
|
428
|
+
const apiKey = process.env.OPENAI_API_KEY;
|
|
429
|
+
if (!apiKey) {
|
|
430
|
+
if (mode === "on")
|
|
431
|
+
throw new Error("Judge mode is 'on' but OPENAI_API_KEY is not set.");
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
return createOpenAIJudge({ apiKey, model });
|
|
435
|
+
}
|
|
436
|
+
async function runFixtureFile(path, options = {}) {
|
|
437
|
+
const absolute = resolve(path);
|
|
438
|
+
const yamlText = await readFile(absolute, "utf8");
|
|
439
|
+
const file = loadFixtureFile(yamlText);
|
|
440
|
+
const judgeMode = options.judgeMode ?? "auto";
|
|
441
|
+
const judge = makeJudge(judgeMode, options.judgeModel);
|
|
442
|
+
const results = [];
|
|
443
|
+
for (const fixture of file.fixtures) {
|
|
444
|
+
try {
|
|
445
|
+
const agent = pickAgentSpec(file, fixture);
|
|
446
|
+
const messages = [...fixture.history ?? [], { role: "user", content: fixture.input }];
|
|
447
|
+
const message = await callSubprocessAgent(agent, {
|
|
448
|
+
messages,
|
|
449
|
+
tools: [],
|
|
450
|
+
tool_choice: "auto"
|
|
451
|
+
});
|
|
452
|
+
const expectation = await evaluateExpectations(fixture.expect, message, judge);
|
|
453
|
+
results.push({
|
|
454
|
+
id: fixture.id,
|
|
455
|
+
status: expectation.status,
|
|
456
|
+
reason: expectation.reason,
|
|
457
|
+
message
|
|
458
|
+
});
|
|
459
|
+
} catch (err) {
|
|
460
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
461
|
+
results.push({ id: fixture.id, status: "fail", reason });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return { path: absolute, results };
|
|
465
|
+
}
|
|
466
|
+
export {
|
|
467
|
+
runFixtureFile,
|
|
468
|
+
loadFixtureFile,
|
|
469
|
+
createOpenAIChatAgent,
|
|
470
|
+
createMockWeatherAgent
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
//# debugId=D5671399AC39730564756E2164756E21
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/agent/mockWeatherAgent.ts", "../src/agent/openaiChatAgent.ts", "../src/fixture/load.ts", "../src/runner/runFixtureFile.ts", "../src/judge/openaiJudge.ts", "../src/runner/subprocessAgent.ts", "../src/runner/deepMatch.ts", "../src/runner/expectations.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { AssistantMessage, ChatAgent, ChatMessage, ToolMessage } from \"./types\";\n\nfunction last<T>(items: T[]): T | undefined {\n return items.length > 0 ? items[items.length - 1] : undefined;\n}\n\nfunction findLatestToolMessage(messages: ChatMessage[], toolName: string): ToolMessage | undefined {\n for (let i = messages.length - 1; i >= 0; i--) {\n const message = messages[i];\n if (!message) continue;\n if (message.role === \"tool\" && message.name === toolName) return message;\n }\n return undefined;\n}\n\nfunction tryParseJson<T>(value: string): T | undefined {\n try {\n return JSON.parse(value) as T;\n } catch {\n return undefined;\n }\n}\n\nexport type MockWeatherAgentOptions = {\n toolName?: string;\n};\n\nexport function createMockWeatherAgent(options: MockWeatherAgentOptions = {}): ChatAgent {\n const toolName = options.toolName ?? \"get_weather\";\n let callCounter = 0;\n\n return async ({ messages }) => {\n const latest = last(messages);\n if (!latest || latest.role !== \"user\") {\n return { role: \"assistant\", content: \"Send a user message to continue.\" };\n }\n\n const userText = latest.content.toLowerCase();\n\n if (userText.includes(\"weather\")) {\n callCounter += 1;\n return {\n role: \"assistant\",\n content: \"\",\n tool_calls: [\n {\n id: `call_${callCounter}`,\n type: \"function\",\n function: {\n name: toolName,\n arguments: JSON.stringify({ location: \"Dublin\", unit: \"c\" }),\n },\n },\n ],\n };\n }\n\n if (userText.includes(\"umbrella\")) {\n const toolMessage = findLatestToolMessage(messages, toolName);\n const payload = toolMessage ? tryParseJson<{ temp_c?: number; condition?: string }>(toolMessage.content) : undefined;\n const condition = payload?.condition?.toLowerCase();\n\n if (condition?.includes(\"rain\")) {\n return { role: \"assistant\", content: \"Yes—bring an umbrella. The forecast shows rain.\" };\n }\n if (toolMessage) {\n return { role: \"assistant\", content: \"Probably yes—better to be prepared based on the forecast.\" };\n }\n return {\n role: \"assistant\",\n content: \"\",\n tool_calls: [\n {\n id: `call_${++callCounter}`,\n type: \"function\",\n function: { name: toolName, arguments: JSON.stringify({ location: \"Dublin\", unit: \"c\" }) },\n },\n ],\n };\n }\n\n const reply: AssistantMessage = { role: \"assistant\", content: \"OK.\" };\n return reply;\n };\n}\n",
|
|
6
|
+
"import type { AssistantMessage, ChatAgent, ChatAgentRequest } from \"./types\";\n\nexport type OpenAIChatAgentOptions = {\n apiKey?: string;\n baseUrl?: string;\n defaultModel?: string;\n};\n\ntype OpenAIChatCompletionResponse = {\n choices: Array<{\n message: AssistantMessage;\n }>;\n};\n\nexport function createOpenAIChatAgent(options: OpenAIChatAgentOptions = {}): ChatAgent {\n const apiKey = options.apiKey ?? process.env.OPENAI_API_KEY;\n const baseUrl = options.baseUrl ?? process.env.OPENAI_BASE_URL ?? \"https://api.openai.com/v1\";\n const defaultModel = options.defaultModel ?? process.env.OPENAI_MODEL ?? \"gpt-4o-mini\";\n\n if (!apiKey) {\n throw new Error(\"Missing OPENAI_API_KEY (or pass { apiKey }).\");\n }\n\n return async (req: ChatAgentRequest) => {\n const model = req.model ?? defaultModel;\n const res = await fetch(`${baseUrl}/chat/completions`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n model,\n messages: req.messages,\n tools: req.tools,\n tool_choice: req.tool_choice,\n }),\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => \"\");\n throw new Error(`OpenAI chat.completions failed: ${res.status} ${res.statusText}${body ? `\\n${body}` : \"\"}`);\n }\n\n const data = (await res.json()) as OpenAIChatCompletionResponse;\n const message = data.choices?.[0]?.message;\n if (!message) throw new Error(\"OpenAI chat.completions returned no message.\");\n return message;\n };\n}\n",
|
|
7
|
+
"import { parse as parseYaml } from \"yaml\";\nimport type { AgentSpec, FixtureFile } from \"./types\";\n\nfunction expandEnvVars(value: string, env: Record<string, string | undefined>): string {\n return value.replace(/\\$\\{([A-Z0-9_]+)\\}/gi, (_, key: string) => env[key] ?? \"\");\n}\n\nfunction normalizeAgentSpec(raw: AgentSpec, env: Record<string, string | undefined>): AgentSpec {\n const normalized: AgentSpec = { ...raw };\n\n if (normalized.type === undefined) normalized.type = \"subprocess\";\n if (!Array.isArray(normalized.command) || normalized.command.length === 0) {\n throw new Error(\"`agent.command` must be a non-empty array of strings.\");\n }\n\n normalized.command = normalized.command.map((part) => String(part));\n\n if (normalized.cwd !== undefined) normalized.cwd = String(normalized.cwd);\n if (normalized.timeout_ms !== undefined) normalized.timeout_ms = Number(normalized.timeout_ms);\n\n if (normalized.env) {\n const expanded: Record<string, string> = {};\n for (const [k, v] of Object.entries(normalized.env)) {\n expanded[k] = expandEnvVars(String(v), env);\n }\n normalized.env = expanded;\n }\n\n return normalized;\n}\n\nexport function loadFixtureFile(yamlText: string, env: Record<string, string | undefined> = process.env): FixtureFile {\n const data = parseYaml(yamlText) as unknown;\n if (!data || typeof data !== \"object\") throw new Error(\"Fixture file must be a YAML object.\");\n\n const file = data as Partial<FixtureFile>;\n if (!Array.isArray(file.fixtures)) throw new Error(\"Fixture file must contain `fixtures: [...]`.\");\n\n const normalized: FixtureFile = {\n fixtures: file.fixtures as FixtureFile[\"fixtures\"],\n };\n\n if (file.agent) normalized.agent = normalizeAgentSpec(file.agent as AgentSpec, env);\n\n normalized.fixtures = normalized.fixtures.map((fixture, index) => {\n if (!fixture || typeof fixture !== \"object\") throw new Error(`fixtures[${index}] must be an object.`);\n if (!(\"id\" in fixture)) throw new Error(`fixtures[${index}].id is required.`);\n if (!(\"input\" in fixture)) throw new Error(`fixtures[${index}].input is required.`);\n\n const out = { ...fixture } as any;\n out.id = String(out.id);\n out.input = String(out.input);\n\n if (out.agent) out.agent = normalizeAgentSpec(out.agent as AgentSpec, env);\n if (out.expect?.tool_calls_match === undefined && out.expect?.tool_calls) out.expect.tool_calls_match = \"contains\";\n\n return out;\n });\n\n return normalized;\n}\n",
|
|
8
|
+
"import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport type { AssistantMessage } from \"../agent/types\";\nimport { loadFixtureFile } from \"../fixture/load\";\nimport type { AgentSpec, Fixture, FixtureFile } from \"../fixture/types\";\nimport { createOpenAIJudge } from \"../judge/openaiJudge\";\nimport { callSubprocessAgent } from \"./subprocessAgent\";\nimport type { ExpectationResult, Judge } from \"./expectations\";\nimport { evaluateExpectations } from \"./expectations\";\n\nexport type JudgeMode = \"off\" | \"auto\" | \"on\";\n\nexport type RunOptions = {\n judgeMode?: JudgeMode;\n judgeModel?: string;\n};\n\nexport type FixtureResult = {\n id: string;\n status: \"pass\" | \"fail\" | \"skip\";\n reason?: string;\n message?: AssistantMessage;\n};\n\nexport type FixtureFileResult = {\n path: string;\n results: FixtureResult[];\n};\n\nfunction pickAgentSpec(file: FixtureFile, fixture: Fixture): AgentSpec {\n const agent = fixture.agent ?? file.agent;\n if (!agent) throw new Error(`Fixture '${fixture.id}' has no agent. Add file-level 'agent:' or fixture-level 'agent:'.`);\n if ((agent.type ?? \"subprocess\") !== \"subprocess\") throw new Error(`Unsupported agent type: ${agent.type}`);\n return agent;\n}\n\nfunction makeJudge(mode: JudgeMode, model?: string): Judge | undefined {\n if (mode === \"off\") return undefined;\n\n const apiKey = process.env.OPENAI_API_KEY;\n if (!apiKey) {\n if (mode === \"on\") throw new Error(\"Judge mode is 'on' but OPENAI_API_KEY is not set.\");\n return undefined;\n }\n\n return createOpenAIJudge({ apiKey, model });\n}\n\nexport async function runFixtureFile(path: string, options: RunOptions = {}): Promise<FixtureFileResult> {\n const absolute = resolve(path);\n const yamlText = await readFile(absolute, \"utf8\");\n const file = loadFixtureFile(yamlText);\n\n const judgeMode = options.judgeMode ?? \"auto\";\n const judge = makeJudge(judgeMode, options.judgeModel);\n\n const results: FixtureResult[] = [];\n\n for (const fixture of file.fixtures) {\n try {\n const agent = pickAgentSpec(file, fixture);\n const messages = [...(fixture.history ?? []), { role: \"user\", content: fixture.input } as const];\n\n const message = await callSubprocessAgent(agent, {\n messages,\n tools: [],\n tool_choice: \"auto\",\n });\n\n const expectation = await evaluateExpectations(fixture.expect, message, judge);\n results.push({\n id: fixture.id,\n status: expectation.status,\n reason: (expectation as Extract<ExpectationResult, { status: \"fail\" | \"skip\" }>).reason,\n message,\n });\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n results.push({ id: fixture.id, status: \"fail\", reason });\n }\n }\n\n return { path: absolute, results };\n}\n",
|
|
9
|
+
"import type { AssistantMessage } from \"../agent/types\";\nimport type { ExpectationResult } from \"../runner/expectations\";\n\nexport type OpenAIJudgeOptions = {\n apiKey: string;\n baseUrl?: string;\n model?: string;\n};\n\ntype JudgeResponse = { pass: boolean; reason: string };\n\nexport function createOpenAIJudge(options: OpenAIJudgeOptions) {\n const baseUrl = options.baseUrl ?? process.env.OPENAI_BASE_URL ?? \"https://api.openai.com/v1\";\n const model = options.model ?? process.env.OPENAI_JUDGE_MODEL ?? \"gpt-4o-mini\";\n\n return async ({ expectation, message }: { expectation: string; message: AssistantMessage }): Promise<ExpectationResult> => {\n const system =\n \"You are a strict test evaluator. Decide if the assistant message satisfies the expectation. \" +\n \"Respond with ONLY valid JSON: {\\\"pass\\\": boolean, \\\"reason\\\": string}.\";\n\n const user = JSON.stringify(\n {\n expectation,\n assistant_message: message,\n },\n null,\n 2\n );\n\n const res = await fetch(`${baseUrl}/chat/completions`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${options.apiKey}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n model,\n temperature: 0,\n messages: [\n { role: \"system\", content: system },\n { role: \"user\", content: user },\n ],\n }),\n });\n\n if (!res.ok) {\n const body = await res.text().catch(() => \"\");\n return {\n status: \"fail\",\n reason: `Judge call failed: ${res.status} ${res.statusText}${body ? `\\n${body}` : \"\"}`,\n };\n }\n\n const data = (await res.json()) as any;\n const content = data?.choices?.[0]?.message?.content;\n if (typeof content !== \"string\" || content.trim().length === 0) {\n return { status: \"fail\", reason: \"Judge returned no content.\" };\n }\n\n let parsed: JudgeResponse;\n try {\n parsed = JSON.parse(content) as JudgeResponse;\n } catch {\n return { status: \"fail\", reason: `Judge did not return valid JSON.\\n${content}` };\n }\n\n if (parsed.pass) return { status: \"pass\" };\n return { status: \"fail\", reason: parsed.reason || \"Expectation not satisfied.\" };\n };\n}\n",
|
|
10
|
+
"import type { AssistantMessage, ChatAgentRequest } from \"../agent/types\";\nimport type { AgentSpec } from \"../fixture/types\";\n\ntype AgentProcessSuccess = { message: AssistantMessage };\ntype AgentProcessError = { error: { message: string } };\n\nfunction isSuccess(value: unknown): value is AgentProcessSuccess {\n return !!value && typeof value === \"object\" && \"message\" in (value as any);\n}\n\nfunction isError(value: unknown): value is AgentProcessError {\n return !!value && typeof value === \"object\" && \"error\" in (value as any);\n}\n\nasync function readFirstNonEmptyLine(stream: ReadableStream<Uint8Array>, timeoutMs: number): Promise<string> {\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n const deadline = Date.now() + timeoutMs;\n\n type ReadResult = { value?: Uint8Array; done: boolean };\n\n while (true) {\n const timeLeft = deadline - Date.now();\n if (timeLeft <= 0) throw new Error(`Timed out waiting for agent response after ${timeoutMs}ms.`);\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n const timerPromise = new Promise<never>((_, reject) => {\n timerId = setTimeout(() => reject(new Error(`Timed out waiting for agent response after ${timeoutMs}ms.`)), timeLeft);\n });\n\n let chunk: ReadResult;\n try {\n chunk = await Promise.race([reader.read(), timerPromise]);\n } finally {\n if (timerId !== undefined) clearTimeout(timerId);\n }\n\n const { value, done } = chunk;\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n\n while (true) {\n const idx = buffer.indexOf(\"\\n\");\n if (idx === -1) break;\n const line = buffer.slice(0, idx).trim();\n buffer = buffer.slice(idx + 1);\n if (line.length > 0) return line;\n }\n }\n\n const tail = buffer.trim();\n if (tail.length > 0) return tail;\n throw new Error(\"Agent produced no output on stdout.\");\n}\n\nexport async function callSubprocessAgent(spec: AgentSpec, request: ChatAgentRequest): Promise<AssistantMessage> {\n const timeoutMs = spec.timeout_ms ?? 20_000;\n\n const proc = Bun.spawn(spec.command, {\n cwd: spec.cwd,\n env: { ...process.env, ...(spec.env ?? {}) },\n stdin: \"pipe\",\n stdout: \"pipe\",\n stderr: \"pipe\",\n });\n\n const stdin = proc.stdin;\n if (!stdin) throw new Error(\"Failed to open agent stdin.\");\n\n stdin.write(`${JSON.stringify(request)}\\n`);\n stdin.end();\n\n let stderrText = \"\";\n const stderrPromise = (async () => {\n if (!proc.stderr) return;\n stderrText = await new Response(proc.stderr).text().catch(() => \"\");\n })();\n\n try {\n if (!proc.stdout) throw new Error(\"Failed to open agent stdout.\");\n const line = await readFirstNonEmptyLine(proc.stdout, timeoutMs);\n\n let payload: unknown;\n try {\n payload = JSON.parse(line) as unknown;\n } catch {\n throw new Error(\n `Agent stdout is not valid JSON.\\n` +\n `Line: ${line}\\n` +\n (stderrText ? `Stderr:\\n${stderrText}` : \"\")\n );\n }\n\n if (isError(payload)) throw new Error(payload.error.message);\n if (!isSuccess(payload)) {\n throw new Error(`Agent response must be { \"message\": { ... } } or { \"error\": { \"message\": ... } }.`);\n }\n\n return payload.message;\n } finally {\n proc.kill();\n await Promise.allSettled([proc.exited, stderrPromise]);\n }\n}\n",
|
|
11
|
+
"export function deepPartialMatch(expected: unknown, actual: unknown): boolean {\n if (expected === actual) return true;\n\n if (expected === null || actual === null) return expected === actual;\n\n const expectedType = typeof expected;\n const actualType = typeof actual;\n if (expectedType !== actualType) return false;\n\n if (Array.isArray(expected)) {\n if (!Array.isArray(actual)) return false;\n if (expected.length !== actual.length) return false;\n for (let i = 0; i < expected.length; i++) {\n if (!deepPartialMatch(expected[i], actual[i])) return false;\n }\n return true;\n }\n\n if (expectedType === \"object\") {\n if (Array.isArray(actual)) return false;\n const expectedObj = expected as Record<string, unknown>;\n const actualObj = actual as Record<string, unknown>;\n for (const [key, expectedValue] of Object.entries(expectedObj)) {\n if (!(key in actualObj)) return false;\n if (!deepPartialMatch(expectedValue, actualObj[key])) return false;\n }\n return true;\n }\n\n return false;\n}\n\n",
|
|
12
|
+
"import type { AssistantMessage } from \"../agent/types\";\nimport type { FixtureExpectation, ToolCallExpectation } from \"../fixture/types\";\nimport { deepPartialMatch } from \"./deepMatch\";\n\nexport type ExpectationResult =\n | { status: \"pass\" }\n | { status: \"fail\"; reason: string }\n | { status: \"skip\"; reason: string };\n\nfunction parseJsonOrUndefined(value: string): unknown | undefined {\n try {\n return JSON.parse(value) as unknown;\n } catch {\n return undefined;\n }\n}\n\nfunction matchToolCall(expected: ToolCallExpectation, actual: NonNullable<AssistantMessage[\"tool_calls\"]>[number]): boolean {\n if (actual.function.name !== expected.name) return false;\n if (expected.arguments === undefined) return true;\n const actualArgs = parseJsonOrUndefined(actual.function.arguments);\n if (actualArgs === undefined) return false;\n return deepPartialMatch(expected.arguments, actualArgs);\n}\n\nfunction checkToolCalls(expect: FixtureExpectation, message: AssistantMessage): ExpectationResult {\n const expectedCalls = expect.tool_calls ?? [];\n if (expectedCalls.length === 0) return { status: \"pass\" };\n\n const actualCalls = message.tool_calls ?? [];\n const mode = expect.tool_calls_match ?? \"contains\";\n\n if (mode === \"contains\") {\n for (const expected of expectedCalls) {\n const ok = actualCalls.some((actual) => matchToolCall(expected, actual));\n if (!ok) {\n return {\n status: \"fail\",\n reason: `Expected tool call not found: ${expected.name}`,\n };\n }\n }\n return { status: \"pass\" };\n }\n\n if (actualCalls.length !== expectedCalls.length) {\n return {\n status: \"fail\",\n reason: `Expected exactly ${expectedCalls.length} tool call(s), got ${actualCalls.length}.`,\n };\n }\n\n for (let i = 0; i < expectedCalls.length; i++) {\n const expected = expectedCalls[i];\n const actual = actualCalls[i];\n if (!expected || !actual || !matchToolCall(expected, actual)) {\n return { status: \"fail\", reason: `Tool call mismatch at index ${i}.` };\n }\n }\n\n return { status: \"pass\" };\n}\n\nexport type Judge = (args: { expectation: string; message: AssistantMessage }) => Promise<ExpectationResult>;\n\nexport async function evaluateExpectations(\n expect: FixtureExpectation | undefined,\n message: AssistantMessage,\n judge: Judge | undefined\n): Promise<ExpectationResult> {\n if (!expect) return { status: \"pass\" };\n\n const toolRes = checkToolCalls(expect, message);\n if (toolRes.status !== \"pass\") return toolRes;\n\n if (expect.assistant?.llm) {\n if (!judge) return { status: \"skip\", reason: \"LLM judge not configured.\" };\n return await judge({ expectation: expect.assistant.llm, message });\n }\n\n return { status: \"pass\" };\n}\n"
|
|
13
|
+
],
|
|
14
|
+
"mappings": ";;AAEA,SAAS,IAAO,CAAC,OAA2B;AAAA,EAC1C,OAAO,MAAM,SAAS,IAAI,MAAM,MAAM,SAAS,KAAK;AAAA;AAGtD,SAAS,qBAAqB,CAAC,UAAyB,UAA2C;AAAA,EACjG,SAAS,IAAI,SAAS,SAAS,EAAG,KAAK,GAAG,KAAK;AAAA,IAC7C,MAAM,UAAU,SAAS;AAAA,IACzB,IAAI,CAAC;AAAA,MAAS;AAAA,IACd,IAAI,QAAQ,SAAS,UAAU,QAAQ,SAAS;AAAA,MAAU,OAAO;AAAA,EACnE;AAAA,EACA;AAAA;AAGF,SAAS,YAAe,CAAC,OAA8B;AAAA,EACrD,IAAI;AAAA,IACF,OAAO,KAAK,MAAM,KAAK;AAAA,IACvB,MAAM;AAAA,IACN;AAAA;AAAA;AAQG,SAAS,sBAAsB,CAAC,UAAmC,CAAC,GAAc;AAAA,EACvF,MAAM,WAAW,QAAQ,YAAY;AAAA,EACrC,IAAI,cAAc;AAAA,EAElB,OAAO,SAAS,eAAe;AAAA,IAC7B,MAAM,SAAS,KAAK,QAAQ;AAAA,IAC5B,IAAI,CAAC,UAAU,OAAO,SAAS,QAAQ;AAAA,MACrC,OAAO,EAAE,MAAM,aAAa,SAAS,mCAAmC;AAAA,IAC1E;AAAA,IAEA,MAAM,WAAW,OAAO,QAAQ,YAAY;AAAA,IAE5C,IAAI,SAAS,SAAS,SAAS,GAAG;AAAA,MAChC,eAAe;AAAA,MACf,OAAO;AAAA,QACL,MAAM;AAAA,QACN,SAAS;AAAA,QACT,YAAY;AAAA,UACV;AAAA,YACE,IAAI,QAAQ;AAAA,YACZ,MAAM;AAAA,YACN,UAAU;AAAA,cACR,MAAM;AAAA,cACN,WAAW,KAAK,UAAU,EAAE,UAAU,UAAU,MAAM,IAAI,CAAC;AAAA,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