@neurouter/evals 0.0.0-stage → 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/LICENSE +202 -0
- package/NOTICE +10 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/check.d.ts +41 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +187 -0
- package/dist/check.js.map +1 -0
- package/dist/generate.d.ts +105 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +187 -0
- package/dist/generate.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/judge.d.ts +33 -0
- package/dist/judge.d.ts.map +1 -0
- package/dist/judge.js +47 -0
- package/dist/judge.js.map +1 -0
- package/dist/llm/anthropic.d.ts +18 -0
- package/dist/llm/anthropic.d.ts.map +1 -0
- package/dist/llm/anthropic.js +47 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/factory.d.ts +49 -0
- package/dist/llm/factory.d.ts.map +1 -0
- package/dist/llm/factory.js +92 -0
- package/dist/llm/factory.js.map +1 -0
- package/dist/llm/fake.d.ts +36 -0
- package/dist/llm/fake.d.ts.map +1 -0
- package/dist/llm/fake.js +75 -0
- package/dist/llm/fake.js.map +1 -0
- package/dist/llm/gemini.d.ts +43 -0
- package/dist/llm/gemini.d.ts.map +1 -0
- package/dist/llm/gemini.js +147 -0
- package/dist/llm/gemini.js.map +1 -0
- package/dist/llm/index.d.ts +8 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +8 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/openai.d.ts +39 -0
- package/dist/llm/openai.d.ts.map +1 -0
- package/dist/llm/openai.js +145 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/llm/stub.d.ts +36 -0
- package/dist/llm/stub.d.ts.map +1 -0
- package/dist/llm/stub.js +430 -0
- package/dist/llm/stub.js.map +1 -0
- package/dist/llm/types.d.ts +121 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +59 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/mcp.d.ts +42 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +50 -0
- package/dist/mcp.js.map +1 -0
- package/dist/prompts.d.ts +18 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +38 -0
- package/dist/prompts.js.map +1 -0
- package/dist/report.d.ts +57 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +65 -0
- package/dist/report.js.map +1 -0
- package/dist/rng.d.ts +9 -0
- package/dist/rng.d.ts.map +1 -0
- package/dist/rng.js +45 -0
- package/dist/rng.js.map +1 -0
- package/dist/run.d.ts +82 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +275 -0
- package/dist/run.js.map +1 -0
- package/dist/score.d.ts +34 -0
- package/dist/score.d.ts.map +1 -0
- package/dist/score.js +154 -0
- package/dist/score.js.map +1 -0
- package/dist/suggest.d.ts +82 -0
- package/dist/suggest.d.ts.map +1 -0
- package/dist/suggest.js +239 -0
- package/dist/suggest.js.map +1 -0
- package/dist/types.d.ts +223 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/yaml-emit.d.ts +3 -0
- package/dist/yaml-emit.d.ts.map +1 -0
- package/dist/yaml-emit.js +47 -0
- package/dist/yaml-emit.js.map +1 -0
- package/package.json +55 -4
- package/README.md +0 -3
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request/response shape every LLM client speaks: the subset of the Anthropic Messages API the
|
|
3
|
+
* evals use (it mirrors `@anthropic-ai/sdk` 1.14.0 `MessageCreateParams` / `Message`). The OpenAI
|
|
4
|
+
* (Responses API) and Gemini (Interactions API) adapters translate to and from it, so the runner,
|
|
5
|
+
* generator and judge stay provider-neutral and testable with fake and stub clients.
|
|
6
|
+
*
|
|
7
|
+
* Provider state that must round-trip verbatim (OpenAI reasoning items, Gemini thought signatures)
|
|
8
|
+
* travels in an opaque assistant content block (`openai_items` / `gemini_steps`) that only the
|
|
9
|
+
* adapter that produced it reads.
|
|
10
|
+
*/
|
|
11
|
+
export const FALLBACK_BETA = 'server-side-fallback-2026-07-01';
|
|
12
|
+
/** Typed errors raised by every LlmClient. */
|
|
13
|
+
export class LlmError extends Error {
|
|
14
|
+
status;
|
|
15
|
+
constructor(message, status = null) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.status = status;
|
|
18
|
+
this.name = 'LlmError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Missing or invalid API key (→ problem `llm_key_missing`). Fails the whole run. */
|
|
22
|
+
export class LlmKeyError extends LlmError {
|
|
23
|
+
constructor(message = 'Model provider API key missing or invalid') {
|
|
24
|
+
super(message, 401);
|
|
25
|
+
this.name = 'LlmKeyError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class LlmRateLimitError extends LlmError {
|
|
29
|
+
retryAfterMs;
|
|
30
|
+
constructor(message, retryAfterMs = null) {
|
|
31
|
+
super(message, 429);
|
|
32
|
+
this.retryAfterMs = retryAfterMs;
|
|
33
|
+
this.name = 'LlmRateLimitError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function textOf(res) {
|
|
37
|
+
return res.content
|
|
38
|
+
.filter((b) => b.type === 'text' && typeof b.text === 'string')
|
|
39
|
+
.map((b) => b.text)
|
|
40
|
+
.join('');
|
|
41
|
+
}
|
|
42
|
+
export function fallbackUsed(res) {
|
|
43
|
+
return (res.usage.iterations ?? []).some((i) => i.type === 'fallback_message');
|
|
44
|
+
}
|
|
45
|
+
/** Parses the first JSON object in a text answer (structured outputs return the JSON as text). */
|
|
46
|
+
export function parseJsonText(text) {
|
|
47
|
+
const t = text.trim();
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(t);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
const start = t.indexOf('{');
|
|
53
|
+
const end = t.lastIndexOf('}');
|
|
54
|
+
if (start >= 0 && end > start)
|
|
55
|
+
return JSON.parse(t.slice(start, end + 1));
|
|
56
|
+
throw new LlmError('model did not return JSON');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA6DH,MAAM,CAAC,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAE/D,8CAA8C;AAC9C,MAAM,OAAO,QAAS,SAAQ,KAAK;IACK;IAAtC,YAAY,OAAe,EAAW,SAAwB,IAAI;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,WAAM,GAAN,MAAM,CAAsB;QAEhE,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AACD,qFAAqF;AACrF,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,YAAY,OAAO,GAAG,2CAA2C;QAC/D,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AACD,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IACP;IAAtC,YAAY,OAAe,EAAW,eAA8B,IAAI;QACtE,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QADgB,iBAAY,GAAZ,YAAY,CAAsB;QAEtE,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,UAAU,MAAM,CAAC,GAAgB;IACrC,OAAO,GAAG,CAAC,OAAO;SACf,MAAM,CAAC,CAAC,CAAC,EAAqB,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,OAAQ,CAAkB,CAAC,IAAI,KAAK,QAAQ,CAAC;SACnG,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAClB,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAgB;IAC3C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC;AACjF,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,GAAG,KAAK;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1E,MAAM,IAAI,QAAQ,CAAC,2BAA2B,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface McpToolInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
inputSchema: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface McpCallResult {
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
[k: string]: unknown;
|
|
12
|
+
}>;
|
|
13
|
+
isError?: boolean;
|
|
14
|
+
structuredContent?: unknown;
|
|
15
|
+
_meta?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/** What the runner needs from an MCP connection (tests use an in-memory fake). */
|
|
18
|
+
export interface McpSession {
|
|
19
|
+
instructions: string | null;
|
|
20
|
+
listTools(): Promise<McpToolInfo[]>;
|
|
21
|
+
callTool(name: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<McpCallResult>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare const EVAL_CLIENT_INFO: {
|
|
25
|
+
readonly name: "neurouter-eval";
|
|
26
|
+
readonly version: "0.1.0";
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Streamable-HTTP MCP client (`@modelcontextprotocol/client` 2.4.0) to a Neurouter endpoint, as a
|
|
30
|
+
* real client connects: Bearer eval API key plus the eval-only headers (mock state namespace,
|
|
31
|
+
* exposure). Version negotiation is automatic (2026-07-28 with the 2025-11-25 fallback).
|
|
32
|
+
*/
|
|
33
|
+
export declare function createMcpHttpClient(opts: {
|
|
34
|
+
url: string;
|
|
35
|
+
apiKey: string;
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
fetch?: typeof fetch;
|
|
39
|
+
}): Promise<McpSession>;
|
|
40
|
+
export declare function taskIdFromResult(res: McpCallResult): string | null;
|
|
41
|
+
export declare function resultText(res: McpCallResult): string;
|
|
42
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACt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Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
|
|
2
|
+
import { META_TASK_ID } from '@neurouter/shared';
|
|
3
|
+
export const EVAL_CLIENT_INFO = { name: 'neurouter-eval', version: '0.1.0' };
|
|
4
|
+
/**
|
|
5
|
+
* Streamable-HTTP MCP client (`@modelcontextprotocol/client` 2.4.0) to a Neurouter endpoint, as a
|
|
6
|
+
* real client connects: Bearer eval API key plus the eval-only headers (mock state namespace,
|
|
7
|
+
* exposure). Version negotiation is automatic (2026-07-28 with the 2025-11-25 fallback).
|
|
8
|
+
*/
|
|
9
|
+
export async function createMcpHttpClient(opts) {
|
|
10
|
+
const timeout = opts.timeoutMs ?? 60_000;
|
|
11
|
+
const client = new Client(EVAL_CLIENT_INFO, { capabilities: {}, versionNegotiation: { mode: 'auto', probe: { timeoutMs: Math.min(timeout, 10_000) } } });
|
|
12
|
+
const transport = new StreamableHTTPClientTransport(new URL(opts.url), {
|
|
13
|
+
requestInit: { headers: { authorization: `Bearer ${opts.apiKey}`, ...(opts.headers ?? {}) } },
|
|
14
|
+
...(opts.fetch ? { fetch: opts.fetch } : {}),
|
|
15
|
+
});
|
|
16
|
+
await client.connect(transport, { timeout });
|
|
17
|
+
return {
|
|
18
|
+
instructions: client.getInstructions() ?? null,
|
|
19
|
+
async listTools() {
|
|
20
|
+
const out = [];
|
|
21
|
+
let cursor;
|
|
22
|
+
do {
|
|
23
|
+
const res = await client.listTools(cursor ? { cursor } : undefined, { timeout });
|
|
24
|
+
for (const t of res.tools)
|
|
25
|
+
out.push({ name: t.name, ...(t.title ? { title: t.title } : {}), ...(t.description ? { description: t.description } : {}), inputSchema: t.inputSchema });
|
|
26
|
+
cursor = res.nextCursor ?? undefined;
|
|
27
|
+
} while (cursor);
|
|
28
|
+
return out;
|
|
29
|
+
},
|
|
30
|
+
async callTool(name, args, signal) {
|
|
31
|
+
const res = await client.callTool({ name, arguments: args }, { timeout, ...(signal ? { signal } : {}) });
|
|
32
|
+
return res;
|
|
33
|
+
},
|
|
34
|
+
close: () => client.close(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function taskIdFromResult(res) {
|
|
38
|
+
const v = res._meta?.[META_TASK_ID];
|
|
39
|
+
return typeof v === 'string' ? v : null;
|
|
40
|
+
}
|
|
41
|
+
export function resultText(res) {
|
|
42
|
+
const t = res.content
|
|
43
|
+
.filter((c) => c.type === 'text' && typeof c.text === 'string')
|
|
44
|
+
.map((c) => c.text)
|
|
45
|
+
.join('\n');
|
|
46
|
+
if (t)
|
|
47
|
+
return t;
|
|
48
|
+
return res.structuredContent !== undefined ? JSON.stringify(res.structuredContent) : '';
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAwBjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAW,CAAC;AAEtF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAiH;IACzJ,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC;IACzC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,gBAAgB,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,EAAW,CAAC,CAAC;IAClK,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,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ts. Generator and judge prompts carry a machine-readable marker plus a JSON input
|
|
3
|
+
* block, so the deterministic stub provider reads exactly what a real model reads.
|
|
4
|
+
*/
|
|
5
|
+
export declare const GENERATOR_PROMPT_VERSION = "gen-1";
|
|
6
|
+
export declare const AGENT_PROMPT_VERSION = "agent-1";
|
|
7
|
+
export declare const JUDGE_PROMPT_VERSION = "judge-1";
|
|
8
|
+
export declare const SUGGEST_PROMPT_VERSION = "suggest-1";
|
|
9
|
+
export declare const GENERATOR_MARKER = "<<NEUROUTER_GENERATOR";
|
|
10
|
+
export declare const JUDGE_MARKER = "<<NEUROUTER_JUDGE";
|
|
11
|
+
export declare const SUGGEST_MARKER = "<<NEUROUTER_SUGGEST";
|
|
12
|
+
export declare function markerMessage(marker: string, version: string, input: unknown, instructions: string): string;
|
|
13
|
+
export declare function readMarkerInput(text: string, marker: string): unknown | null;
|
|
14
|
+
export declare const GENERATOR_SYSTEM = "You write evaluation tasks that measure how well an AI agent can use an API through MCP tools.\nEach task is a realistic user request. Tasks must be answerable with the listed tools (except category \"impossible\").\nReference ids and values that exist in the provided sample entities so the tasks can be checked against the mock API.\nReturn JSON only, matching the schema. Categories:\n- single: one tool call solves it.\n- multi: needs 2-4 calls, the later ones using results of earlier ones.\n- ambiguous: the request is underspecified; a good agent asks a clarifying question or makes a reasonable, stated choice.\n- impossible: no tool can do it; a good agent says so and calls neurouter_report_unmet_need, and never writes.\nAssertions use this DSL: called {tool,args?,argsMatch?,minTimes?}, not_called {tool}, no_writes, max_calls {n},\nstate {resource,scope?,where,expect}, answer_contains {anyOf}, answer_matches {regex}, unmet_need_reported_or_declined, framing, judge {criterion}.\nAlways include a framing assertion. For impossible tasks include unmet_need_reported_or_declined and no called assertions.";
|
|
15
|
+
export declare function agentSystemPrompt(instructions: string | null): string;
|
|
16
|
+
export declare const JUDGE_SYSTEM = "You grade whether an AI agent's work satisfies a rubric. Be strict and concise. Return JSON only: {\"score\": 0..1, \"verdict\": \"pass\"|\"fail\", \"reasons\": [up to 3 short strings]}. Verdict pass requires score >= 0.7.";
|
|
17
|
+
export declare const SUGGEST_SYSTEM = "You improve MCP tool definitions so AI agents pick the right tool and pass correct arguments. Return JSON only, matching the schema. Descriptions start with a verb, are specific, at most 600 characters, and contrast confusable tools.";
|
|
18
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAChD,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAElD,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AACxD,eAAO,MAAM,YAAY,sBAAsB,CAAC;AAChD,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAE3G;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAI5E;AAED,eAAO,MAAM,gBAAgB,imCAU8F,CAAC;AAE5H,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGrE;AAED,eAAO,MAAM,YAAY,mOAAyN,CAAC;AAEnP,eAAO,MAAM,cAAc,8OAA8O,CAAC"}
|
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioned prompts. Generator and judge prompts carry a machine-readable marker plus a JSON input
|
|
3
|
+
* block, so the deterministic stub provider reads exactly what a real model reads.
|
|
4
|
+
*/
|
|
5
|
+
export const GENERATOR_PROMPT_VERSION = 'gen-1';
|
|
6
|
+
export const AGENT_PROMPT_VERSION = 'agent-1';
|
|
7
|
+
export const JUDGE_PROMPT_VERSION = 'judge-1';
|
|
8
|
+
export const SUGGEST_PROMPT_VERSION = 'suggest-1';
|
|
9
|
+
export const GENERATOR_MARKER = '<<NEUROUTER_GENERATOR';
|
|
10
|
+
export const JUDGE_MARKER = '<<NEUROUTER_JUDGE';
|
|
11
|
+
export const SUGGEST_MARKER = '<<NEUROUTER_SUGGEST';
|
|
12
|
+
export function markerMessage(marker, version, input, instructions) {
|
|
13
|
+
return `${marker} ${version}>>\n${instructions}\n<input>\n${JSON.stringify(input)}\n</input>`;
|
|
14
|
+
}
|
|
15
|
+
export function readMarkerInput(text, marker) {
|
|
16
|
+
if (!text.includes(marker))
|
|
17
|
+
return null;
|
|
18
|
+
const m = /<input>\n?([\s\S]*?)\n?<\/input>/.exec(text);
|
|
19
|
+
return m?.[1] ? JSON.parse(m[1]) : null;
|
|
20
|
+
}
|
|
21
|
+
export const GENERATOR_SYSTEM = `You write evaluation tasks that measure how well an AI agent can use an API through MCP tools.
|
|
22
|
+
Each task is a realistic user request. Tasks must be answerable with the listed tools (except category "impossible").
|
|
23
|
+
Reference ids and values that exist in the provided sample entities so the tasks can be checked against the mock API.
|
|
24
|
+
Return JSON only, matching the schema. Categories:
|
|
25
|
+
- single: one tool call solves it.
|
|
26
|
+
- multi: needs 2-4 calls, the later ones using results of earlier ones.
|
|
27
|
+
- ambiguous: the request is underspecified; a good agent asks a clarifying question or makes a reasonable, stated choice.
|
|
28
|
+
- impossible: no tool can do it; a good agent says so and calls neurouter_report_unmet_need, and never writes.
|
|
29
|
+
Assertions use this DSL: called {tool,args?,argsMatch?,minTimes?}, not_called {tool}, no_writes, max_calls {n},
|
|
30
|
+
state {resource,scope?,where,expect}, answer_contains {anyOf}, answer_matches {regex}, unmet_need_reported_or_declined, framing, judge {criterion}.
|
|
31
|
+
Always include a framing assertion. For impossible tasks include unmet_need_reported_or_declined and no called assertions.`;
|
|
32
|
+
export function agentSystemPrompt(instructions) {
|
|
33
|
+
const base = `You are a helpful assistant that completes the user's request by using the available tools. Be efficient: call only the tools you need. When you are done, answer the user concisely and include the key values you found.`;
|
|
34
|
+
return instructions ? `${base}\n\nThe tool server says:\n${instructions}` : base;
|
|
35
|
+
}
|
|
36
|
+
export const JUDGE_SYSTEM = `You grade whether an AI agent's work satisfies a rubric. Be strict and concise. Return JSON only: {"score": 0..1, "verdict": "pass"|"fail", "reasons": [up to 3 short strings]}. Verdict pass requires score >= 0.7.`;
|
|
37
|
+
export const SUGGEST_SYSTEM = `You improve MCP tool definitions so AI agents pick the right tool and pass correct arguments. Return JSON only, matching the schema. Descriptions start with a verb, are specific, at most 600 characters, and contrast confusable tools.`;
|
|
38
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAC9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAC9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACxD,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAEpD,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,OAAe,EAAE,KAAc,EAAE,YAAoB;IACjG,OAAO,GAAG,MAAM,IAAI,OAAO,OAAO,YAAY,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,MAAc;IAC1D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,CAAC,GAAG,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;2HAU2F,CAAC;AAE5H,MAAM,UAAU,iBAAiB,CAAC,YAA2B;IAC3D,MAAM,IAAI,GAAG,4NAA4N,CAAC;IAC1O,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,8BAA8B,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACnF,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,sNAAsN,CAAC;AAEnP,MAAM,CAAC,MAAM,cAAc,GAAG,2OAA2O,CAAC"}
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Suggestion } from './suggest.js';
|
|
2
|
+
import type { ReadinessScore, TaskRunResult } from './types.js';
|
|
3
|
+
/** CLI/CI report (`EvalReport` ≈ EvalRunDetail + suggestions, §15.8). */
|
|
4
|
+
export interface EvalReport {
|
|
5
|
+
version: 1;
|
|
6
|
+
server: {
|
|
7
|
+
slug: string;
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
run: {
|
|
11
|
+
id: string | null;
|
|
12
|
+
models: string[];
|
|
13
|
+
modes: string[];
|
|
14
|
+
repeats: number;
|
|
15
|
+
environment: string;
|
|
16
|
+
buildHash: string | null;
|
|
17
|
+
provider: string;
|
|
18
|
+
startedAt: string;
|
|
19
|
+
endedAt: string;
|
|
20
|
+
};
|
|
21
|
+
score: ReadinessScore;
|
|
22
|
+
tasks: Array<{
|
|
23
|
+
key: string;
|
|
24
|
+
category: string;
|
|
25
|
+
prompt: string;
|
|
26
|
+
cells: Array<{
|
|
27
|
+
model: string;
|
|
28
|
+
mode: string;
|
|
29
|
+
passes: number;
|
|
30
|
+
attempts: number;
|
|
31
|
+
failureCause: string | null;
|
|
32
|
+
}>;
|
|
33
|
+
}>;
|
|
34
|
+
topFailures: Array<{
|
|
35
|
+
taskKey: string;
|
|
36
|
+
model: string;
|
|
37
|
+
mode: string;
|
|
38
|
+
cause: string | null;
|
|
39
|
+
detail: string;
|
|
40
|
+
}>;
|
|
41
|
+
suggestions: Suggestion[];
|
|
42
|
+
usage: Record<string, {
|
|
43
|
+
inputTokens: number;
|
|
44
|
+
outputTokens: number;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
export declare function buildReport(input: Omit<EvalReport, 'version' | 'tasks' | 'topFailures' | 'usage'> & {
|
|
48
|
+
results: TaskRunResult[];
|
|
49
|
+
prompts: Record<string, {
|
|
50
|
+
category: string;
|
|
51
|
+
prompt: string;
|
|
52
|
+
}>;
|
|
53
|
+
}): EvalReport;
|
|
54
|
+
export declare function renderMarkdown(rep: EvalReport): string;
|
|
55
|
+
/** Plain-text table for the terminal. */
|
|
56
|
+
export declare function renderTable(rep: EvalReport): string;
|
|
57
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhE,yEAAyE;AACzE,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,I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M,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,UAAU,CA2B5M;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAmBtD;AAED,yCAAyC;AACzC,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAOnD"}
|
package/dist/report.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export function buildReport(input) {
|
|
2
|
+
const byTask = new Map();
|
|
3
|
+
for (const r of input.results)
|
|
4
|
+
byTask.set(r.taskKey, [...(byTask.get(r.taskKey) ?? []), r]);
|
|
5
|
+
const tasks = [...byTask.entries()].map(([key, rs]) => {
|
|
6
|
+
const cells = new Map();
|
|
7
|
+
for (const r of rs) {
|
|
8
|
+
const k = `${r.model}|${r.mode}`;
|
|
9
|
+
const c = cells.get(k) ?? { model: r.model, mode: r.mode, passes: 0, attempts: 0, failureCause: null };
|
|
10
|
+
c.attempts++;
|
|
11
|
+
if (r.passed)
|
|
12
|
+
c.passes++;
|
|
13
|
+
else
|
|
14
|
+
c.failureCause ??= r.failureCause;
|
|
15
|
+
cells.set(k, c);
|
|
16
|
+
}
|
|
17
|
+
return { key, category: input.prompts[key]?.category ?? rs[0].category, prompt: input.prompts[key]?.prompt ?? '', cells: [...cells.values()] };
|
|
18
|
+
});
|
|
19
|
+
const topFailures = input.results
|
|
20
|
+
.filter((r) => !r.passed)
|
|
21
|
+
.slice(0, 10)
|
|
22
|
+
.map((r) => ({ taskKey: r.taskKey, model: r.model, mode: r.mode, cause: r.failureCause, detail: r.assertionResults.filter((a) => !a.passed).map((a) => a.detail).join('; ') || r.error || '' }));
|
|
23
|
+
const usage = {};
|
|
24
|
+
for (const r of input.results) {
|
|
25
|
+
const u = (usage[r.model] ??= { inputTokens: 0, outputTokens: 0 });
|
|
26
|
+
u.inputTokens += r.inputTokens;
|
|
27
|
+
u.outputTokens += r.outputTokens;
|
|
28
|
+
}
|
|
29
|
+
const { results: _r, prompts: _p, ...rest } = input;
|
|
30
|
+
return { version: 1, ...rest, tasks, topFailures, usage };
|
|
31
|
+
}
|
|
32
|
+
export function renderMarkdown(rep) {
|
|
33
|
+
const s = rep.score;
|
|
34
|
+
const lines = [];
|
|
35
|
+
lines.push(`## Neurouter agent-readiness: ${rep.server.name} — **${s.headline}/100** (${s.band.replace('_', ' ')})`, '');
|
|
36
|
+
lines.push(`- Recommended mode: **${s.recommendedMode ?? 'n/a'}** — ${s.recommendationText}`);
|
|
37
|
+
lines.push(`- Confidence: ${s.confidence}; models: ${rep.run.models.join(', ')}; modes: ${rep.run.modes.join(', ')}; repeats: ${rep.run.repeats}; environment: ${rep.run.environment}${rep.run.provider === 'stub' ? ' (**stub provider — not a real model**)' : ''}`, '');
|
|
38
|
+
lines.push('| Model | Mode | Score | Success | Avg tokens | Avg calls | Avg latency | Flaky |', '|---|---|---:|---:|---:|---:|---:|---:|');
|
|
39
|
+
for (const c of s.cells)
|
|
40
|
+
lines.push(`| ${c.model} | ${c.mode}${c.best ? ' ★' : ''} | ${c.score} | ${Math.round(c.successRate * 100)}% | ${Math.round(c.avgTokens)} | ${c.avgCalls.toFixed(1)} | ${Math.round(c.avgLatencyMs)} ms | ${c.flakyTasks} |`);
|
|
41
|
+
lines.push('', '### Score breakdown', '', '| Component | Weight | Score | Detail |', '|---|---:|---:|---|');
|
|
42
|
+
for (const b of s.breakdown)
|
|
43
|
+
lines.push(`| ${b.label} | ${b.weight} | ${Math.round(b.score * 100)}% | ${b.detail} |`);
|
|
44
|
+
if (rep.topFailures.length) {
|
|
45
|
+
lines.push('', '### Top failures', '');
|
|
46
|
+
for (const f of rep.topFailures)
|
|
47
|
+
lines.push(`- \`${f.taskKey}\` (${f.model}, ${f.mode}): ${f.cause ?? 'failed'} — ${f.detail.slice(0, 200)}`);
|
|
48
|
+
}
|
|
49
|
+
if (rep.suggestions.length) {
|
|
50
|
+
lines.push('', '### Suggested fixes', '');
|
|
51
|
+
for (const sg of rep.suggestions)
|
|
52
|
+
lines.push(`- **${sg.kind}** ${sg.tools.join(', ')} (+${sg.predictedDelta} pts predicted, ${sg.affectedTaskKeys.length} tasks): ${sg.rationale}`);
|
|
53
|
+
}
|
|
54
|
+
return `${lines.join('\n')}\n`;
|
|
55
|
+
}
|
|
56
|
+
/** Plain-text table for the terminal. */
|
|
57
|
+
export function renderTable(rep) {
|
|
58
|
+
const s = rep.score;
|
|
59
|
+
const rows = [['model', 'mode', 'score', 'success', 'tokens', 'calls'], ...s.cells.map((c) => [c.model, c.mode + (c.best ? '*' : ''), String(c.score), `${Math.round(c.successRate * 100)}%`, String(Math.round(c.avgTokens)), c.avgCalls.toFixed(1)])];
|
|
60
|
+
const w = rows[0].map((_, i) => Math.max(...rows.map((r) => r[i].length)));
|
|
61
|
+
const table = rows.map((r) => r.map((x, i) => x.padEnd(w[i])).join(' ')).join('\n');
|
|
62
|
+
const fails = rep.topFailures.slice(0, 5).map((f) => ` - ${f.taskKey} [${f.mode}] ${f.cause ?? ''}`).join('\n');
|
|
63
|
+
return `${table}\n\nHeadline: ${s.headline}/100 (${s.band}) · recommended: ${s.recommendedMode ?? 'n/a'} · ${s.recommendationText}${fails ? `\nTop failures:\n${fails}` : ''}\n`;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,WAAW,CAAC,KAAoK;IAC9L,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAClD,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO;QAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,C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,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjH,OAAO,GAAG,KAAK,iBAAiB,CAAC,CAAC,QAAQ,SAAS,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,eAAe,IAAI,KAAK,MAAM,CAAC,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;AACnL,CAAC"}
|
package/dist/rng.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Deterministic PRNG (mulberry32) for seeded generation and sampling. */
|
|
2
|
+
export declare function mulberry32(seed: number): () => number;
|
|
3
|
+
export declare function shuffle<T>(items: readonly T[], rand: () => number): T[];
|
|
4
|
+
/** Lower-case word tokens without stop words; splits snake_case and camelCase. */
|
|
5
|
+
export declare function tokens(text: string): string[];
|
|
6
|
+
/** Very small stemmer: plural `s`/`es`/`ies`. */
|
|
7
|
+
export declare function stem(t: string): string;
|
|
8
|
+
export declare function firstSentence(text: string): string;
|
|
9
|
+
//# sourceMappingURL=rng.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rng.d.ts","sourceRoot":"","sources":["../src/rng.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,MAAM,CASrD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,MAAM,GAAG,CAAC,EAAE,CAOvE;AAID,kFAAkF;AAClF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAO7C;AAED,iDAAiD;AACjD,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKtC;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD"}
|
package/dist/rng.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Deterministic PRNG (mulberry32) for seeded generation and sampling. */
|
|
2
|
+
export function mulberry32(seed) {
|
|
3
|
+
let a = seed >>> 0;
|
|
4
|
+
return () => {
|
|
5
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
6
|
+
let t = a;
|
|
7
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
8
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
9
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function shuffle(items, rand) {
|
|
13
|
+
const a = [...items];
|
|
14
|
+
for (let i = a.length - 1; i > 0; i--) {
|
|
15
|
+
const j = Math.floor(rand() * (i + 1));
|
|
16
|
+
[a[i], a[j]] = [a[j], a[i]];
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
}
|
|
20
|
+
const STOP = new Set('a an and are as at be by can do for from get has have i in into is it its me my of on or our please set show some the their then this to up use using us we what when which with you your all any'.split(' '));
|
|
21
|
+
/** Lower-case word tokens without stop words; splits snake_case and camelCase. */
|
|
22
|
+
export function tokens(text) {
|
|
23
|
+
return text
|
|
24
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.split(/[^a-z0-9]+/)
|
|
27
|
+
.filter((t) => t.length > 1 && !STOP.has(t))
|
|
28
|
+
.map(stem);
|
|
29
|
+
}
|
|
30
|
+
/** Very small stemmer: plural `s`/`es`/`ies`. */
|
|
31
|
+
export function stem(t) {
|
|
32
|
+
if (t.length > 4 && t.endsWith('ies'))
|
|
33
|
+
return t.slice(0, -3) + 'y';
|
|
34
|
+
if (t.length > 3 && t.endsWith('es') && /(sh|ch|x|ss)es$/.test(t))
|
|
35
|
+
return t.slice(0, -2);
|
|
36
|
+
if (t.length > 3 && t.endsWith('s') && !t.endsWith('ss'))
|
|
37
|
+
return t.slice(0, -1);
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
export function firstSentence(text) {
|
|
41
|
+
const t = text.trim().split('\n')[0] ?? '';
|
|
42
|
+
const m = /^(.+?[.!?])(\s|$)/.exec(t);
|
|
43
|
+
return (m?.[1] ?? t).trim();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=rng.js.map
|
package/dist/rng.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rng.js","sourceRoot":"","sources":["../src/rng.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC;IACnB,OAAO,GAAG,EAAE;QACV,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3B,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACrC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CAAI,KAAm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BAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzF,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAChF,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,CAAC,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC"}
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type LlmClient, type LlmRequest, type LlmResponse } from './llm/types.js';
|
|
2
|
+
import { type McpSession } from './mcp.js';
|
|
3
|
+
import type { StateReader } from './check.js';
|
|
4
|
+
import type { AgentCall, AttemptRun, EvalMode, EvalTask, ObservedCall, TaskRunResult } from './types.js';
|
|
5
|
+
export interface RunSettings {
|
|
6
|
+
effort: 'low' | 'medium' | 'high';
|
|
7
|
+
/** Server-side refusal fallbacks (`fallbacks: "default"` on the beta endpoint). */
|
|
8
|
+
fallbacks: boolean;
|
|
9
|
+
maxTokens?: number;
|
|
10
|
+
cache?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface RunLimits {
|
|
13
|
+
maxTurns: number;
|
|
14
|
+
maxToolCalls: number;
|
|
15
|
+
maxTotalTokens: number;
|
|
16
|
+
wallMs: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEFAULT_LIMITS: RunLimits;
|
|
19
|
+
export declare const DEFAULT_SETTINGS: RunSettings;
|
|
20
|
+
export interface RunAttemptOptions {
|
|
21
|
+
llm: LlmClient;
|
|
22
|
+
mcp: McpSession;
|
|
23
|
+
prompt: string;
|
|
24
|
+
model: string;
|
|
25
|
+
mode: EvalMode;
|
|
26
|
+
settings?: Partial<RunSettings>;
|
|
27
|
+
limits?: Partial<RunLimits>;
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
/** Injectable for tests. */
|
|
30
|
+
now?: () => number;
|
|
31
|
+
sleep?: (ms: number) => Promise<void>;
|
|
32
|
+
random?: () => number;
|
|
33
|
+
}
|
|
34
|
+
/** The agent loop (§15.4 step 3): MCP tools 1:1 as LLM tools (each provider adapter maps them), tool_choice auto, parallel tool_use blocks. */
|
|
35
|
+
export declare function runAttempt(opts: RunAttemptOptions): Promise<AttemptRun>;
|
|
36
|
+
/** RateLimitError → backoff and retry 3× with jitter (on top of the SDK's own retries). */
|
|
37
|
+
export declare function createWithRetry(llm: LlmClient, req: LlmRequest, o: {
|
|
38
|
+
sleep: (ms: number) => Promise<void>;
|
|
39
|
+
random: () => number;
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
retries?: number;
|
|
42
|
+
}): Promise<LlmResponse>;
|
|
43
|
+
/** When the server cannot supply audit calls: the agent's own MCP calls (call_tool unwrapped). Inner script calls are invisible here. */
|
|
44
|
+
export declare function callsFromAgent(calls: AgentCall[]): ObservedCall[];
|
|
45
|
+
export interface AttemptContext {
|
|
46
|
+
task: EvalTask;
|
|
47
|
+
model: string;
|
|
48
|
+
mode: EvalMode;
|
|
49
|
+
attempt: number;
|
|
50
|
+
/** `${taskKey}|${model}|${mode}|${attempt}` — the resumability key. */
|
|
51
|
+
key: string;
|
|
52
|
+
}
|
|
53
|
+
/** A per-attempt MCP session (fresh mock namespace `eval:<runId>:<taskRunId>`, exposure for the mode). */
|
|
54
|
+
export interface AttemptSession {
|
|
55
|
+
mcp: McpSession;
|
|
56
|
+
/** Audit-log calls of the attempt's Neurouter task (incl. inner script calls). Defaults to the agent's calls. */
|
|
57
|
+
collectCalls?: (run: AttemptRun) => Promise<ObservedCall[]>;
|
|
58
|
+
stateReader?: StateReader;
|
|
59
|
+
close?: () => Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export interface RunSuiteOptions {
|
|
62
|
+
llm: LlmClient;
|
|
63
|
+
tasks: EvalTask[];
|
|
64
|
+
models: string[];
|
|
65
|
+
modes: EvalMode[];
|
|
66
|
+
repeats: number;
|
|
67
|
+
openSession: (ctx: AttemptContext) => Promise<AttemptSession>;
|
|
68
|
+
judgeModel?: string;
|
|
69
|
+
judgeLlm?: LlmClient;
|
|
70
|
+
settings?: Partial<RunSettings>;
|
|
71
|
+
limits?: Partial<RunLimits>;
|
|
72
|
+
concurrency?: number;
|
|
73
|
+
signal?: AbortSignal;
|
|
74
|
+
/** Skip attempts already stored (resume). */
|
|
75
|
+
hasResult?: (key: string) => boolean | Promise<boolean>;
|
|
76
|
+
onResult?: (r: TaskRunResult) => void | Promise<void>;
|
|
77
|
+
onProgress?: (done: number, total: number) => void;
|
|
78
|
+
}
|
|
79
|
+
export declare function attemptKey(taskKey: string, model: string, mode: EvalMode, attempt: number): string;
|
|
80
|
+
/** Runs task × model × mode × attempt with bounded concurrency (default 4). Returns the new results. */
|
|
81
|
+
export declare function runSuite(opts: RunSuiteOptions): Promise<TaskRunResult[]>;
|
|
82
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgD,KAAK,SAAS,EAAwB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAiD,MAAM,gBAAgB,CAAC;AACtM,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,KAAK,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