@agent-inspect/eval 2.0.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/dist/index.cjs +733 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +129 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.mjs +729 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["read","openTrace","TraceReadError"],"mappings":";;;;;AAmJA,SAAS,kBAAkB,KAAA,EAA0C;AACnE,EAAA,OACE,KAAA,KAAU,QACV,OAAO,KAAA,KAAU,YACjB,MAAA,IAAU,KAAA,IACV,QAAA,IAAY,KAAA,IACZ,QAAA,IAAY,KAAA;AAEhB;AAEA,SAAS,eAAe,KAAA,EAAiC;AACvD,EAAA,OAAO,EAAE,MAAM,MAAA,EAAQ,IAAA,EAAM,iBAAiB,GAAA,GAAM,KAAA,CAAM,WAAW,KAAA,EAAM;AAC7E;AAEA,eAAe,WAAA,CACb,OACA,OAAA,EACoF;AACpF,EAAA,IAAI;AACF,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,MAAA,MAAMA,KAAAA,GAAO,MAAMC,iBAAA,CAAU,cAAA,CAAe,KAAK,CAAA,EAAG;AAAA,QAClD,GAAI,OAAA,CAAQ,MAAA,KAAW,KAAA,CAAA,IAAa,OAAA,CAAQ,MAAA,KAAW,MAAA,GACnD,EAAE,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAAO,GACzB;AAAC,OACN,CAAA;AACD,MAAA,OAAO,EAAE,MAAAD,KAAAA,EAAM,KAAA,EAAO,QAAQ,KAAA,EAAO,WAAA,EAAa,EAAC,EAAE;AAAA,IACvD;AAEA,IAAA,IAAI,iBAAA,CAAkB,KAAK,CAAA,EAAG;AAC5B,MAAA,OAAO,EAAE,MAAM,KAAA,EAAO,KAAA,EAAO,QAAQ,KAAA,EAA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CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC;AAAA,CAAA;AAC5B","file":"index.cjs","sourcesContent":["import {\n openTrace,\n TraceReadError,\n type TraceInput,\n type TraceReadResult,\n} from \"agent-inspect/readers\";\n\nexport type EvalStatus = \"pass\" | \"fail\" | \"error\";\nexport type EvalSeverity = \"error\" | \"warning\" | \"info\";\nexport type EvalFindingStatus = \"pass\" | \"fail\" | \"warning\";\nexport type EvalRuleCategory =\n | \"run\"\n | \"tool\"\n | \"llm\"\n | \"retrieval\"\n | \"structure\"\n | \"safety\"\n | \"custom\";\n\nexport interface EvalEvidence {\n runId?: string;\n eventId?: string;\n parentId?: string;\n traceId?: string;\n spanId?: string;\n kind?: string;\n name?: string;\n path?: string;\n}\n\nexport interface EvalFinding {\n ruleId: string;\n status: EvalFindingStatus;\n severity: EvalSeverity;\n message: string;\n expected?: unknown;\n actual?: unknown;\n evidence: EvalEvidence[];\n}\n\nexport interface EvalDiagnostic {\n code:\n | \"AI_EVAL_TRACE_UNREADABLE\"\n | \"AI_EVAL_UNSUPPORTED_FORMAT\"\n | \"AI_EVAL_AMBIGUOUS_FORMAT\"\n | \"AI_EVAL_RUN_SELECTION_REQUIRED\"\n | \"AI_EVAL_RULE_FAILED\"\n | \"AI_EVAL_INVALID_ARGUMENTS\"\n | \"AI_EVAL_INVALID_CONFIG\"\n | \"AI_EVAL_CONFIG_LOAD_FAILED\";\n severity: EvalSeverity;\n message: string;\n ruleId?: string;\n}\n\nexport type EvalDiagnosticCode = EvalDiagnostic[\"code\"];\n\nexport interface EvalSummary {\n passed: number;\n failed: number;\n warnings: number;\n errors: number;\n}\n\nexport interface EvalRunResult {\n ok: boolean;\n status: EvalStatus;\n format: string;\n runId?: string;\n summary: EvalSummary;\n findings: EvalFinding[];\n diagnostics: EvalDiagnostic[];\n}\n\nexport interface EvalInput {\n trace: string | URL | TraceReadResult;\n runId?: string;\n format?: \"agent-inspect-jsonl\" | \"openinference-json\" | \"otlp-json\" | \"auto\";\n}\n\nexport interface EvalRunOptions {\n checks?: readonly EvalRule[];\n runId?: string;\n format?: EvalInput[\"format\"];\n}\n\nexport type EvalRunInput = EvalInput | string | TraceReadResult;\n\n/** Experimental options for deterministic answer/context overlap checks. */\nexport interface ContextOverlapOptions {\n minOverlap?: number;\n minSharedTerms?: number;\n answerKeys?: readonly string[];\n contextKeys?: readonly string[];\n}\n\n/** Experimental options for deterministic quote grounding checks. */\nexport interface QuoteOverlapOptions {\n answerKeys?: readonly string[];\n contextKeys?: readonly string[];\n minQuoteLength?: number;\n requireQuote?: boolean;\n}\n\n/** Experimental options for deterministic citation presence checks. */\nexport interface CitationPresenceOptions {\n answerKeys?: readonly string[];\n citationKeys?: readonly string[];\n}\n\n/** Experimental options for deterministic source-id checks. */\nexport interface RequiredSourceIdsOptions {\n sourceIdKeys?: readonly string[];\n}\n\n/** Experimental options for deterministic answer length checks. */\nexport interface AnswerLengthBoundsOptions {\n minCharacters?: number;\n maxCharacters?: number;\n minWords?: number;\n maxWords?: number;\n answerKeys?: readonly string[];\n}\n\n/** Experimental options for deterministic unsupported-phrase checks. */\nexport interface BannedUnsupportedPhrasesOptions {\n answerKeys?: readonly string[];\n}\n\nexport interface EvalRule {\n id: string;\n category: EvalRuleCategory;\n severity?: EvalSeverity;\n evaluate(context: EvalContext): readonly EvalFinding[];\n}\n\ntype EvalRunTree = TraceReadResult[\"runs\"][number];\ntype EvalNode = EvalRunTree[\"children\"][number];\ntype EvalEvent = EvalNode[\"event\"];\n\nexport interface EvalContext {\n format: string;\n run: EvalRunTree;\n nodes: readonly EvalNode[];\n events: readonly TraceReadResult[\"events\"][number][];\n}\n\nfunction isTraceReadResult(value: unknown): value is TraceReadResult {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"runs\" in value &&\n \"events\" in value &&\n \"format\" in value\n );\n}\n\nfunction traceInputFrom(value: string | URL): TraceInput {\n return { type: \"file\", path: value instanceof URL ? value.pathname : value };\n}\n\nasync function resolveRead(\n input: EvalRunInput,\n options: EvalRunOptions,\n): Promise<{ read?: TraceReadResult; runId?: string; diagnostics: EvalDiagnostic[] }> {\n try {\n if (typeof input === \"string\") {\n const read = await openTrace(traceInputFrom(input), {\n ...(options.format !== undefined && options.format !== \"auto\"\n ? { format: options.format }\n : {}),\n });\n return { read, runId: options.runId, diagnostics: [] };\n }\n\n if (isTraceReadResult(input)) {\n return { read: input, runId: options.runId, diagnostics: [] };\n }\n\n if (isTraceReadResult(input.trace)) {\n return { read: input.trace, runId: options.runId ?? input.runId, diagnostics: [] };\n }\n\n const format = options.format ?? input.format;\n const read = await openTrace(traceInputFrom(input.trace), {\n ...(format !== undefined && format !== \"auto\" ? { format } : {}),\n });\n return { read, runId: options.runId ?? input.runId, diagnostics: [] };\n } catch (error) {\n return { diagnostics: [diagnosticFromError(error)] };\n }\n}\n\nfunction diagnosticFromError(error: unknown): EvalDiagnostic {\n if (error instanceof TraceReadError) {\n const code =\n error.code === \"unsupported_format\"\n ? \"AI_EVAL_UNSUPPORTED_FORMAT\"\n : error.code === \"ambiguous_format\"\n ? \"AI_EVAL_AMBIGUOUS_FORMAT\"\n : \"AI_EVAL_TRACE_UNREADABLE\";\n return { code, severity: \"error\", message: error.message };\n }\n return {\n code: \"AI_EVAL_TRACE_UNREADABLE\",\n severity: \"error\",\n message: error instanceof Error ? error.message : String(error),\n };\n}\n\nfunction flatten(nodes: readonly EvalNode[]): EvalNode[] {\n return nodes.flatMap((node) => [node, ...flatten(node.children)]);\n}\n\nfunction selectRun(\n read: TraceReadResult,\n runId: string | undefined,\n): { run?: EvalRunTree; diagnostics: EvalDiagnostic[] } {\n if (runId !== undefined) {\n const run = read.runs.find((candidate) => candidate.runId === runId);\n return run === undefined\n ? {\n diagnostics: [\n {\n code: \"AI_EVAL_RUN_SELECTION_REQUIRED\",\n severity: \"error\",\n message: `Run not found: ${runId}.`,\n },\n ],\n }\n : { run, diagnostics: [] };\n }\n\n if (read.runs.length === 1) {\n return { run: read.runs[0], diagnostics: [] };\n }\n\n if (read.runs.length === 0) {\n return {\n diagnostics: [\n {\n code: \"AI_EVAL_RUN_SELECTION_REQUIRED\",\n severity: \"error\",\n message: \"No runs are available for eval.\",\n },\n ],\n };\n }\n\n return {\n diagnostics: [\n {\n code: \"AI_EVAL_RUN_SELECTION_REQUIRED\",\n severity: \"error\",\n message: \"Multiple runs are available; select a run before eval.\",\n },\n ],\n };\n}\n\nfunction errorResult(\n format: string,\n diagnostics: readonly EvalDiagnostic[],\n runId?: string,\n): EvalRunResult {\n const errors = diagnostics.filter((item) => item.severity === \"error\").length;\n return {\n ok: false,\n status: \"error\",\n format,\n ...(runId !== undefined ? { runId } : {}),\n summary: { passed: 0, failed: 0, warnings: 0, errors },\n findings: [],\n diagnostics: [...diagnostics],\n };\n}\n\nfunction normalizeFinding(rule: EvalRule, finding: EvalFinding): EvalFinding {\n return {\n ...finding,\n ruleId: finding.ruleId || rule.id,\n severity: finding.severity ?? rule.severity ?? \"error\",\n evidence: [...finding.evidence],\n };\n}\n\nfunction compareFindings(a: EvalFinding, b: EvalFinding): number {\n const aEvidence = a.evidence[0];\n const bEvidence = b.evidence[0];\n return (\n a.ruleId.localeCompare(b.ruleId) ||\n (aEvidence?.runId ?? \"\").localeCompare(bEvidence?.runId ?? \"\") ||\n (aEvidence?.eventId ?? \"\").localeCompare(bEvidence?.eventId ?? \"\") ||\n (aEvidence?.path ?? \"\").localeCompare(bEvidence?.path ?? \"\") ||\n a.message.localeCompare(b.message)\n );\n}\n\nfunction summarize(findings: readonly EvalFinding[], ruleCount: number): EvalSummary {\n const failed = findings.filter((item) => item.status === \"fail\").length;\n const warnings = findings.filter((item) => item.status === \"warning\").length;\n const errors = findings.filter((item) => item.severity === \"error\").length;\n return {\n passed: Math.max(0, ruleCount - failed - warnings),\n failed,\n warnings,\n errors,\n };\n}\n\nfunction defaultRules(): EvalRule[] {\n return [checks.requireSuccess()];\n}\n\nexport async function evalRun(\n input: EvalRunInput,\n options: EvalRunOptions = {},\n): Promise<EvalRunResult> {\n const resolved = await resolveRead(input, options);\n if (resolved.read === undefined) {\n return errorResult(\"unknown\", resolved.diagnostics);\n }\n\n const selected = selectRun(resolved.read, resolved.runId);\n if (selected.run === undefined) {\n return errorResult(resolved.read.format, selected.diagnostics, resolved.runId);\n }\n\n const rules = [...(options.checks ?? defaultRules())].sort((a, b) =>\n a.id.localeCompare(b.id),\n );\n const context: EvalContext = {\n format: resolved.read.format,\n run: selected.run,\n nodes: flatten(selected.run.children),\n events: resolved.read.events.filter((event) => event.runId === selected.run?.runId),\n };\n\n const diagnostics: EvalDiagnostic[] = [];\n const findings: EvalFinding[] = [];\n for (const rule of rules) {\n try {\n findings.push(...rule.evaluate(context).map((finding) => normalizeFinding(rule, finding)));\n } catch (error) {\n diagnostics.push({\n code: \"AI_EVAL_RULE_FAILED\",\n severity: \"error\",\n ruleId: rule.id,\n message: `Eval rule ${rule.id} failed: ${\n error instanceof Error ? error.message : String(error)\n }`,\n });\n }\n }\n\n if (diagnostics.length > 0) {\n return errorResult(resolved.read.format, diagnostics, selected.run.runId);\n }\n\n const sortedFindings = findings.sort(compareFindings);\n const summary = summarize(sortedFindings, rules.length);\n const status = summary.failed > 0 ? \"fail\" : \"pass\";\n return {\n ok: status === \"pass\",\n status,\n format: resolved.read.format,\n runId: selected.run.runId,\n summary,\n findings: sortedFindings,\n diagnostics: [],\n };\n}\n\nfunction evidenceForRun(run: EvalRunTree, path?: string): EvalEvidence[] {\n return [{ runId: run.runId, ...(path !== undefined ? { path } : {}) }];\n}\n\nfunction evidenceForEvent(event: EvalEvent, path?: string): EvalEvidence[] {\n return [\n {\n runId: event.runId,\n eventId: event.eventId,\n ...(event.parentId !== undefined ? { parentId: event.parentId } : {}),\n kind: event.kind,\n name: event.name,\n ...(path !== undefined ? { path } : {}),\n },\n ];\n}\n\nfunction fail(\n ruleId: string,\n message: string,\n evidence: EvalEvidence[],\n expected?: unknown,\n actual?: unknown,\n): EvalFinding {\n return {\n ruleId,\n status: \"fail\",\n severity: \"error\",\n message,\n ...(expected !== undefined ? { expected } : {}),\n ...(actual !== undefined ? { actual } : {}),\n evidence,\n };\n}\n\nfunction nodeNames(nodes: readonly EvalNode[], kind?: string): string[] {\n return nodes\n .filter((node) => kind === undefined || node.event.kind === kind)\n .map((node) => node.event.name)\n .sort((a, b) => a.localeCompare(b));\n}\n\nfunction hasAttribute(node: EvalNode, key: string): boolean {\n return (\n node.event.attributes !== undefined &&\n Object.prototype.hasOwnProperty.call(node.event.attributes, key)\n );\n}\n\nfunction numericAttribute(node: EvalNode, keys: readonly string[]): number | undefined {\n const attrs = node.event.attributes;\n if (attrs === undefined) return undefined;\n for (const key of keys) {\n const value = attrs[key];\n if (typeof value === \"number\" && Number.isFinite(value)) return value;\n }\n return undefined;\n}\n\nfunction totalTokenCount(events: readonly TraceReadResult[\"events\"][number][]): number {\n return events.reduce((total, event) => {\n const usage = event.tokenUsage;\n if (usage?.total !== undefined) return total + usage.total;\n return total + (usage?.input ?? 0) + (usage?.output ?? 0);\n }, 0);\n}\n\nfunction createRule(\n id: string,\n category: EvalRuleCategory,\n evaluate: EvalRule[\"evaluate\"],\n): EvalRule {\n return { id, category, severity: \"error\", evaluate };\n}\n\nconst DEFAULT_ANSWER_KEYS = [\n \"answer\",\n \"finalAnswer\",\n \"final\",\n \"response\",\n \"result\",\n \"output\",\n \"outputPreview\",\n \"completion\",\n \"text\",\n] as const;\n\nconst DEFAULT_CONTEXT_KEYS = [\n \"context\",\n \"contexts\",\n \"document\",\n \"documents\",\n \"retrieved\",\n \"retrieval\",\n \"chunks\",\n \"chunk\",\n \"source\",\n \"sources\",\n \"sourceText\",\n] as const;\n\nconst DEFAULT_CITATION_KEYS = [\n \"citation\",\n \"citations\",\n \"reference\",\n \"references\",\n \"sourceId\",\n \"sourceIds\",\n \"source_id\",\n \"source_ids\",\n] as const;\n\nconst DEFAULT_SOURCE_ID_KEYS = [\n ...DEFAULT_CITATION_KEYS,\n \"id\",\n \"ids\",\n \"documentId\",\n \"documentIds\",\n \"docId\",\n \"docIds\",\n] as const;\n\nconst DEFAULT_BANNED_UNSUPPORTED_PHRASES = [\n \"i don't have enough information\",\n \"i do not have enough information\",\n \"not enough context\",\n \"cannot determine from the context\",\n \"unable to determine from the provided context\",\n] as const;\n\nconst STOP_WORDS = new Set([\n \"a\",\n \"an\",\n \"and\",\n \"are\",\n \"but\",\n \"for\",\n \"from\",\n \"have\",\n \"into\",\n \"not\",\n \"that\",\n \"the\",\n \"their\",\n \"this\",\n \"was\",\n \"were\",\n \"with\",\n \"you\",\n \"your\",\n]);\n\ninterface TextField {\n text: string;\n node: EvalNode;\n path: string;\n}\n\nfunction normalizeKey(key: string): string {\n return key.toLowerCase().replace(/[^a-z0-9]/g, \"\");\n}\n\nfunction keySet(keys: readonly string[]): Set<string> {\n return new Set(keys.map(normalizeKey));\n}\n\nfunction valuesAsStrings(value: unknown, depth = 0): string[] {\n if (depth > 5) return [];\n if (typeof value === \"string\") {\n const trimmed = value.trim();\n return trimmed.length > 0 ? [trimmed] : [];\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") return [String(value)];\n if (Array.isArray(value)) {\n return value.flatMap((item) => valuesAsStrings(item, depth + 1));\n }\n if (value !== null && typeof value === \"object\") {\n return Object.values(value as Record<string, unknown>).flatMap((item) =>\n valuesAsStrings(item, depth + 1),\n );\n }\n return [];\n}\n\nfunction collectTextFields(\n nodes: readonly EvalNode[],\n keys: readonly string[],\n preferredKinds: readonly string[] = [],\n): TextField[] {\n const wanted = keySet(keys);\n const preferred = new Set(preferredKinds);\n const orderedNodes = [...nodes].sort((a, b) => {\n const aPreferred = preferred.has(a.event.kind) ? 0 : 1;\n const bPreferred = preferred.has(b.event.kind) ? 0 : 1;\n return aPreferred - bPreferred || a.event.eventId.localeCompare(b.event.eventId);\n });\n const fields: TextField[] = [];\n for (const node of orderedNodes) {\n const attrs = node.event.attributes;\n if (attrs === undefined) continue;\n for (const [key, value] of Object.entries(attrs)) {\n if (!wanted.has(normalizeKey(key))) continue;\n for (const text of valuesAsStrings(value)) {\n fields.push({ text, node, path: `attributes.${key}` });\n }\n }\n }\n return fields;\n}\n\nfunction tokenize(text: string): string[] {\n return [...text.toLowerCase().matchAll(/[a-z0-9][a-z0-9'-]{2,}/g)]\n .map((match) => match[0].replace(/^['-]+|['-]+$/g, \"\"))\n .filter((token) => token.length > 2 && !STOP_WORDS.has(token));\n}\n\nfunction firstEvidence(\n fields: readonly TextField[],\n run: EvalRunTree,\n path: string,\n): EvalEvidence[] {\n const first = fields[0];\n return first === undefined\n ? evidenceForRun(run, path)\n : evidenceForEvent(first.node.event, first.path);\n}\n\nfunction collectSourceIds(\n nodes: readonly EvalNode[],\n keys: readonly string[],\n): string[] {\n const wanted = keySet(keys);\n const ids = new Set<string>();\n for (const node of nodes) {\n const attrs = node.event.attributes;\n if (attrs === undefined) continue;\n for (const [key, value] of Object.entries(attrs)) {\n if (!wanted.has(normalizeKey(key))) continue;\n for (const candidate of valuesAsStrings(value)) {\n const trimmed = candidate.trim();\n if (trimmed.length > 0 && trimmed.length <= 128) ids.add(trimmed);\n }\n }\n }\n return [...ids].sort((a, b) => a.localeCompare(b));\n}\n\nfunction citationCount(answer: string, citationFields: readonly TextField[]): number {\n const inline =\n answer.match(/\\[[^\\]\\n]{1,40}\\]|\\([A-Za-z][A-Za-z0-9_-]{0,39}\\)/g)?.length ?? 0;\n return inline + citationFields.length;\n}\n\nfunction quotedSnippets(text: string, minLength: number): string[] {\n const snippets = new Set<string>();\n const pattern = /\"([^\"\\n]+)\"|'([^'\\n]+)'|“([^”\\n]+)”/g;\n for (const match of text.matchAll(pattern)) {\n const snippet = (match[1] ?? match[2] ?? match[3] ?? \"\").trim();\n if (snippet.length >= minLength) snippets.add(snippet);\n }\n return [...snippets].sort((a, b) => a.localeCompare(b));\n}\n\nfunction wordCount(text: string): number {\n return tokenize(text).length;\n}\n\nexport const checks = {\n requireSuccess(): EvalRule {\n return createRule(\"eval.requireSuccess\", \"run\", (context) =>\n context.run.status === \"ok\"\n ? []\n : [\n fail(\n \"eval.requireSuccess\",\n \"Run did not complete successfully.\",\n evidenceForRun(context.run, \"status\"),\n \"ok\",\n context.run.status ?? \"unknown\",\n ),\n ],\n );\n },\n\n requiredTools(required: readonly string[]): EvalRule {\n const expected = [...required].sort((a, b) => a.localeCompare(b));\n return createRule(\"eval.requiredTools\", \"tool\", (context) => {\n const tools = new Set(nodeNames(context.nodes, \"TOOL\"));\n return expected\n .filter((name) => !tools.has(name))\n .map((name) =>\n fail(\n \"eval.requiredTools\",\n `Required tool ${name} did not appear.`,\n evidenceForRun(context.run, \"children\"),\n name,\n [...tools].sort((a, b) => a.localeCompare(b)),\n ),\n );\n });\n },\n\n forbiddenTools(forbidden: readonly string[]): EvalRule {\n const blocked = [...forbidden].sort((a, b) => a.localeCompare(b));\n return createRule(\"eval.forbiddenTools\", \"tool\", (context) =>\n context.nodes\n .filter((node) => node.event.kind === \"TOOL\" && blocked.includes(node.event.name))\n .map((node) =>\n fail(\n \"eval.forbiddenTools\",\n `Forbidden tool ${node.event.name} appeared.`,\n evidenceForEvent(node.event, \"name\"),\n \"tool absent\",\n node.event.name,\n ),\n ),\n );\n },\n\n maxDurationMs(maxDurationMs: number): EvalRule {\n return createRule(\"eval.maxDurationMs\", \"run\", (context) =>\n context.run.durationMs !== undefined && context.run.durationMs > maxDurationMs\n ? [\n fail(\n \"eval.maxDurationMs\",\n `Run duration exceeded ${maxDurationMs}ms.`,\n evidenceForRun(context.run, \"durationMs\"),\n { maxDurationMs },\n context.run.durationMs,\n ),\n ]\n : [],\n );\n },\n\n maxDepth(maxDepth: number): EvalRule {\n return createRule(\"eval.maxDepth\", \"structure\", (context) => {\n const deepest = context.nodes.reduce<EvalNode | undefined>(\n (current, node) =>\n current === undefined || node.depth > current.depth ? node : current,\n undefined,\n );\n return deepest !== undefined && deepest.depth > maxDepth\n ? [\n fail(\n \"eval.maxDepth\",\n `Run tree depth exceeded ${maxDepth}.`,\n evidenceForEvent(deepest.event, \"depth\"),\n { maxDepth },\n deepest.depth,\n ),\n ]\n : [];\n });\n },\n\n maxRetries(maxRetries: number): EvalRule {\n return createRule(\"eval.maxRetries\", \"structure\", (context) =>\n context.nodes.flatMap((node) => {\n const retries = numericAttribute(node, [\"retryCount\", \"retries\", \"attempt\"]);\n return retries !== undefined && retries > maxRetries\n ? [\n fail(\n \"eval.maxRetries\",\n `Retry count exceeded ${maxRetries}.`,\n evidenceForEvent(node.event, \"attributes.retryCount\"),\n { maxRetries },\n retries,\n ),\n ]\n : [];\n }),\n );\n },\n\n maxTotalTokens(maxTotalTokens: number): EvalRule {\n return createRule(\"eval.maxTotalTokens\", \"llm\", (context) => {\n const total = totalTokenCount(context.events);\n return total > maxTotalTokens\n ? [\n fail(\n \"eval.maxTotalTokens\",\n `Total token usage exceeded ${maxTotalTokens}.`,\n evidenceForRun(context.run, \"tokenUsage.total\"),\n { maxTotalTokens },\n total,\n ),\n ]\n : [];\n });\n },\n\n noFailedSteps(): EvalRule {\n return createRule(\"eval.noFailedSteps\", \"run\", (context) =>\n context.nodes\n .filter((node) => node.event.status === \"error\" || node.event.kind === \"ERROR\")\n .map((node) =>\n fail(\n \"eval.noFailedSteps\",\n \"Run contains a failed step or error node.\",\n evidenceForEvent(node.event, \"status\"),\n \"no failed nodes\",\n node.event.status ?? node.event.kind,\n ),\n ),\n );\n },\n\n requiredRetrievalBeforeGeneration(): EvalRule {\n return createRule(\"eval.requiredRetrievalBeforeGeneration\", \"retrieval\", (context) => {\n const firstLlmIndex = context.nodes.findIndex((node) => node.event.kind === \"LLM\");\n if (firstLlmIndex === -1) return [];\n const retrievalIndex = context.nodes.findIndex(\n (node, index) => index < firstLlmIndex && node.event.kind === \"RETRIEVER\",\n );\n return retrievalIndex === -1\n ? [\n fail(\n \"eval.requiredRetrievalBeforeGeneration\",\n \"No retrieval step appeared before the first LLM generation.\",\n evidenceForEvent(context.nodes[firstLlmIndex].event, \"kind\"),\n \"RETRIEVER before LLM\",\n \"LLM before RETRIEVER\",\n ),\n ]\n : [];\n });\n },\n\n requiredDecisionMetadata(keys: readonly string[]): EvalRule {\n const required = [...keys].sort((a, b) => a.localeCompare(b));\n return createRule(\"eval.requiredDecisionMetadata\", \"structure\", (context) => {\n const decisions = context.nodes.filter((node) => node.event.kind === \"DECISION\");\n if (decisions.length === 0) {\n return [\n fail(\n \"eval.requiredDecisionMetadata\",\n \"No decision node is available for required metadata.\",\n evidenceForRun(context.run, \"children\"),\n { decisionMetadata: required },\n \"no decision nodes\",\n ),\n ];\n }\n return decisions.flatMap((node) =>\n required\n .filter((key) => !hasAttribute(node, key))\n .map((key) =>\n fail(\n \"eval.requiredDecisionMetadata\",\n `Decision metadata ${key} is missing.`,\n evidenceForEvent(node.event, `attributes.${key}`),\n key,\n \"missing\",\n ),\n ),\n );\n });\n },\n\n contextOverlap(options: ContextOverlapOptions = {}): EvalRule {\n const minOverlap = options.minOverlap ?? 0.1;\n const minSharedTerms = options.minSharedTerms ?? 1;\n const answerKeys = options.answerKeys ?? DEFAULT_ANSWER_KEYS;\n const contextKeys = options.contextKeys ?? DEFAULT_CONTEXT_KEYS;\n return createRule(\"eval.contextOverlap\", \"retrieval\", (context) => {\n const answers = collectTextFields(context.nodes, answerKeys, [\"RESULT\", \"LLM\", \"AGENT\"]);\n const contexts = collectTextFields(context.nodes, contextKeys, [\"RETRIEVER\", \"TOOL\"]);\n if (answers.length === 0 || contexts.length === 0) {\n return [\n fail(\n \"eval.contextOverlap\",\n \"Answer and context text are required for overlap evaluation.\",\n firstEvidence(answers.length > 0 ? answers : contexts, context.run, \"children\"),\n { answer: \"present\", context: \"present\" },\n { answerFields: answers.length, contextFields: contexts.length },\n ),\n ];\n }\n\n const answerTerms = new Set(tokenize(answers.map((field) => field.text).join(\" \")));\n const contextTerms = new Set(tokenize(contexts.map((field) => field.text).join(\" \")));\n const sharedTerms = [...answerTerms].filter((term) => contextTerms.has(term)).length;\n const overlap = answerTerms.size === 0 ? 0 : sharedTerms / answerTerms.size;\n return sharedTerms < minSharedTerms || overlap < minOverlap\n ? [\n fail(\n \"eval.contextOverlap\",\n \"Answer text did not sufficiently overlap retrieved context.\",\n firstEvidence(answers, context.run, \"attributes.answer\"),\n { minOverlap, minSharedTerms },\n {\n answerTerms: answerTerms.size,\n contextTerms: contextTerms.size,\n sharedTerms,\n overlap: Number(overlap.toFixed(4)),\n },\n ),\n ]\n : [];\n });\n },\n\n quoteOverlap(options: QuoteOverlapOptions = {}): EvalRule {\n const answerKeys = options.answerKeys ?? DEFAULT_ANSWER_KEYS;\n const contextKeys = options.contextKeys ?? DEFAULT_CONTEXT_KEYS;\n const minQuoteLength = options.minQuoteLength ?? 6;\n const requireQuote = options.requireQuote ?? true;\n return createRule(\"eval.quoteOverlap\", \"retrieval\", (context) => {\n const answers = collectTextFields(context.nodes, answerKeys, [\"RESULT\", \"LLM\", \"AGENT\"]);\n const contexts = collectTextFields(context.nodes, contextKeys, [\"RETRIEVER\", \"TOOL\"]);\n const answerText = answers.map((field) => field.text).join(\" \");\n const contextText = contexts.map((field) => field.text).join(\" \").toLowerCase();\n const quotes = quotedSnippets(answerText, minQuoteLength);\n if (quotes.length === 0) {\n return requireQuote\n ? [\n fail(\n \"eval.quoteOverlap\",\n \"Answer did not contain a quote for overlap evaluation.\",\n firstEvidence(answers, context.run, \"attributes.answer\"),\n { quotedText: \"present\" },\n { quoteCount: 0 },\n ),\n ]\n : [];\n }\n const missing = quotes.filter((quote) => !contextText.includes(quote.toLowerCase()));\n return missing.length > 0\n ? [\n fail(\n \"eval.quoteOverlap\",\n \"Quoted answer text did not appear in retrieved context.\",\n firstEvidence(answers, context.run, \"attributes.answer\"),\n { allQuotesInContext: true },\n { quoteCount: quotes.length, missingQuotes: missing.length },\n ),\n ]\n : [];\n });\n },\n\n citationPresence(options: CitationPresenceOptions = {}): EvalRule {\n const answerKeys = options.answerKeys ?? DEFAULT_ANSWER_KEYS;\n const citationKeys = options.citationKeys ?? DEFAULT_CITATION_KEYS;\n return createRule(\"eval.citationPresence\", \"retrieval\", (context) => {\n const answers = collectTextFields(context.nodes, answerKeys, [\"RESULT\", \"LLM\", \"AGENT\"]);\n const citations = collectTextFields(context.nodes, citationKeys);\n const count = citationCount(answers.map((field) => field.text).join(\" \"), citations);\n return count === 0\n ? [\n fail(\n \"eval.citationPresence\",\n \"Answer did not include citations or source references.\",\n firstEvidence(answers, context.run, \"attributes.answer\"),\n { citationCount: \">= 1\" },\n { citationCount: 0 },\n ),\n ]\n : [];\n });\n },\n\n requiredSourceIds(\n requiredIds: readonly string[],\n options: RequiredSourceIdsOptions = {},\n ): EvalRule {\n const expected = [...requiredIds].sort((a, b) => a.localeCompare(b));\n const sourceIdKeys = options.sourceIdKeys ?? DEFAULT_SOURCE_ID_KEYS;\n return createRule(\"eval.requiredSourceIds\", \"retrieval\", (context) => {\n const available = collectSourceIds(context.nodes, sourceIdKeys);\n const availableSet = new Set(available);\n const missing = expected.filter((id) => !availableSet.has(id));\n return missing.length > 0\n ? [\n fail(\n \"eval.requiredSourceIds\",\n \"Required source IDs were not present in trace context or citations.\",\n evidenceForRun(context.run, \"children\"),\n { sourceIds: expected },\n { missingSourceIds: missing, availableSourceIds: available.slice(0, 20) },\n ),\n ]\n : [];\n });\n },\n\n answerLengthBounds(options: AnswerLengthBoundsOptions): EvalRule {\n const answerKeys = options.answerKeys ?? DEFAULT_ANSWER_KEYS;\n return createRule(\"eval.answerLengthBounds\", \"llm\", (context) => {\n const answers = collectTextFields(context.nodes, answerKeys, [\"RESULT\", \"LLM\", \"AGENT\"]);\n const answer = answers.map((field) => field.text).join(\" \").trim();\n const characters = answer.length;\n const words = wordCount(answer);\n const tooShort =\n (options.minCharacters !== undefined && characters < options.minCharacters) ||\n (options.minWords !== undefined && words < options.minWords);\n const tooLong =\n (options.maxCharacters !== undefined && characters > options.maxCharacters) ||\n (options.maxWords !== undefined && words > options.maxWords);\n return answer.length === 0 || tooShort || tooLong\n ? [\n fail(\n \"eval.answerLengthBounds\",\n \"Answer length fell outside required bounds.\",\n firstEvidence(answers, context.run, \"attributes.answer\"),\n {\n minCharacters: options.minCharacters,\n maxCharacters: options.maxCharacters,\n minWords: options.minWords,\n maxWords: options.maxWords,\n },\n { characters, words },\n ),\n ]\n : [];\n });\n },\n\n bannedUnsupportedPhrases(\n phrases: readonly string[] = DEFAULT_BANNED_UNSUPPORTED_PHRASES,\n options: BannedUnsupportedPhrasesOptions = {},\n ): EvalRule {\n const answerKeys = options.answerKeys ?? DEFAULT_ANSWER_KEYS;\n const banned = [...phrases].map((phrase) => phrase.toLowerCase()).sort();\n return createRule(\"eval.bannedUnsupportedPhrases\", \"safety\", (context) => {\n const answers = collectTextFields(context.nodes, answerKeys, [\"RESULT\", \"LLM\", \"AGENT\"]);\n const answer = answers.map((field) => field.text).join(\" \").toLowerCase();\n const matches = banned.filter((phrase) => answer.includes(phrase));\n return matches.length > 0\n ? [\n fail(\n \"eval.bannedUnsupportedPhrases\",\n \"Answer contained banned unsupported-answer phrasing.\",\n firstEvidence(answers, context.run, \"attributes.answer\"),\n { bannedPhraseCount: banned.length },\n { matchedPhraseCount: matches.length },\n ),\n ]\n : [];\n });\n },\n} as const;\n\nexport function renderEvalMarkdown(result: EvalRunResult): string {\n const lines = [\n `# AgentInspect Eval`,\n \"\",\n `Status: ${result.status}`,\n `Format: ${result.format}`,\n ...(result.runId !== undefined ? [`Run: ${result.runId}`] : []),\n `Summary: ${result.summary.passed} passed, ${result.summary.failed} failed, ${result.summary.warnings} warnings, ${result.summary.errors} errors`,\n ];\n\n if (result.diagnostics.length > 0) {\n lines.push(\"\", \"## Diagnostics\");\n for (const diagnostic of result.diagnostics) {\n lines.push(`- ${diagnostic.code}: ${diagnostic.message}`);\n }\n }\n\n if (result.findings.length > 0) {\n lines.push(\"\", \"## Findings\");\n for (const finding of result.findings) {\n const path = finding.evidence[0]?.path;\n lines.push(`- ${finding.ruleId}: ${finding.message}${path ? ` (${path})` : \"\"}`);\n }\n }\n\n return `${lines.join(\"\\n\")}\\n`;\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { TraceReadResult } from 'agent-inspect/readers';
|
|
2
|
+
|
|
3
|
+
type EvalStatus = "pass" | "fail" | "error";
|
|
4
|
+
type EvalSeverity = "error" | "warning" | "info";
|
|
5
|
+
type EvalFindingStatus = "pass" | "fail" | "warning";
|
|
6
|
+
type EvalRuleCategory = "run" | "tool" | "llm" | "retrieval" | "structure" | "safety" | "custom";
|
|
7
|
+
interface EvalEvidence {
|
|
8
|
+
runId?: string;
|
|
9
|
+
eventId?: string;
|
|
10
|
+
parentId?: string;
|
|
11
|
+
traceId?: string;
|
|
12
|
+
spanId?: string;
|
|
13
|
+
kind?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
}
|
|
17
|
+
interface EvalFinding {
|
|
18
|
+
ruleId: string;
|
|
19
|
+
status: EvalFindingStatus;
|
|
20
|
+
severity: EvalSeverity;
|
|
21
|
+
message: string;
|
|
22
|
+
expected?: unknown;
|
|
23
|
+
actual?: unknown;
|
|
24
|
+
evidence: EvalEvidence[];
|
|
25
|
+
}
|
|
26
|
+
interface EvalDiagnostic {
|
|
27
|
+
code: "AI_EVAL_TRACE_UNREADABLE" | "AI_EVAL_UNSUPPORTED_FORMAT" | "AI_EVAL_AMBIGUOUS_FORMAT" | "AI_EVAL_RUN_SELECTION_REQUIRED" | "AI_EVAL_RULE_FAILED" | "AI_EVAL_INVALID_ARGUMENTS" | "AI_EVAL_INVALID_CONFIG" | "AI_EVAL_CONFIG_LOAD_FAILED";
|
|
28
|
+
severity: EvalSeverity;
|
|
29
|
+
message: string;
|
|
30
|
+
ruleId?: string;
|
|
31
|
+
}
|
|
32
|
+
type EvalDiagnosticCode = EvalDiagnostic["code"];
|
|
33
|
+
interface EvalSummary {
|
|
34
|
+
passed: number;
|
|
35
|
+
failed: number;
|
|
36
|
+
warnings: number;
|
|
37
|
+
errors: number;
|
|
38
|
+
}
|
|
39
|
+
interface EvalRunResult {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
status: EvalStatus;
|
|
42
|
+
format: string;
|
|
43
|
+
runId?: string;
|
|
44
|
+
summary: EvalSummary;
|
|
45
|
+
findings: EvalFinding[];
|
|
46
|
+
diagnostics: EvalDiagnostic[];
|
|
47
|
+
}
|
|
48
|
+
interface EvalInput {
|
|
49
|
+
trace: string | URL | TraceReadResult;
|
|
50
|
+
runId?: string;
|
|
51
|
+
format?: "agent-inspect-jsonl" | "openinference-json" | "otlp-json" | "auto";
|
|
52
|
+
}
|
|
53
|
+
interface EvalRunOptions {
|
|
54
|
+
checks?: readonly EvalRule[];
|
|
55
|
+
runId?: string;
|
|
56
|
+
format?: EvalInput["format"];
|
|
57
|
+
}
|
|
58
|
+
type EvalRunInput = EvalInput | string | TraceReadResult;
|
|
59
|
+
/** Experimental options for deterministic answer/context overlap checks. */
|
|
60
|
+
interface ContextOverlapOptions {
|
|
61
|
+
minOverlap?: number;
|
|
62
|
+
minSharedTerms?: number;
|
|
63
|
+
answerKeys?: readonly string[];
|
|
64
|
+
contextKeys?: readonly string[];
|
|
65
|
+
}
|
|
66
|
+
/** Experimental options for deterministic quote grounding checks. */
|
|
67
|
+
interface QuoteOverlapOptions {
|
|
68
|
+
answerKeys?: readonly string[];
|
|
69
|
+
contextKeys?: readonly string[];
|
|
70
|
+
minQuoteLength?: number;
|
|
71
|
+
requireQuote?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Experimental options for deterministic citation presence checks. */
|
|
74
|
+
interface CitationPresenceOptions {
|
|
75
|
+
answerKeys?: readonly string[];
|
|
76
|
+
citationKeys?: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
/** Experimental options for deterministic source-id checks. */
|
|
79
|
+
interface RequiredSourceIdsOptions {
|
|
80
|
+
sourceIdKeys?: readonly string[];
|
|
81
|
+
}
|
|
82
|
+
/** Experimental options for deterministic answer length checks. */
|
|
83
|
+
interface AnswerLengthBoundsOptions {
|
|
84
|
+
minCharacters?: number;
|
|
85
|
+
maxCharacters?: number;
|
|
86
|
+
minWords?: number;
|
|
87
|
+
maxWords?: number;
|
|
88
|
+
answerKeys?: readonly string[];
|
|
89
|
+
}
|
|
90
|
+
/** Experimental options for deterministic unsupported-phrase checks. */
|
|
91
|
+
interface BannedUnsupportedPhrasesOptions {
|
|
92
|
+
answerKeys?: readonly string[];
|
|
93
|
+
}
|
|
94
|
+
interface EvalRule {
|
|
95
|
+
id: string;
|
|
96
|
+
category: EvalRuleCategory;
|
|
97
|
+
severity?: EvalSeverity;
|
|
98
|
+
evaluate(context: EvalContext): readonly EvalFinding[];
|
|
99
|
+
}
|
|
100
|
+
type EvalRunTree = TraceReadResult["runs"][number];
|
|
101
|
+
type EvalNode = EvalRunTree["children"][number];
|
|
102
|
+
interface EvalContext {
|
|
103
|
+
format: string;
|
|
104
|
+
run: EvalRunTree;
|
|
105
|
+
nodes: readonly EvalNode[];
|
|
106
|
+
events: readonly TraceReadResult["events"][number][];
|
|
107
|
+
}
|
|
108
|
+
declare function evalRun(input: EvalRunInput, options?: EvalRunOptions): Promise<EvalRunResult>;
|
|
109
|
+
declare const checks: {
|
|
110
|
+
readonly requireSuccess: () => EvalRule;
|
|
111
|
+
readonly requiredTools: (required: readonly string[]) => EvalRule;
|
|
112
|
+
readonly forbiddenTools: (forbidden: readonly string[]) => EvalRule;
|
|
113
|
+
readonly maxDurationMs: (maxDurationMs: number) => EvalRule;
|
|
114
|
+
readonly maxDepth: (maxDepth: number) => EvalRule;
|
|
115
|
+
readonly maxRetries: (maxRetries: number) => EvalRule;
|
|
116
|
+
readonly maxTotalTokens: (maxTotalTokens: number) => EvalRule;
|
|
117
|
+
readonly noFailedSteps: () => EvalRule;
|
|
118
|
+
readonly requiredRetrievalBeforeGeneration: () => EvalRule;
|
|
119
|
+
readonly requiredDecisionMetadata: (keys: readonly string[]) => EvalRule;
|
|
120
|
+
readonly contextOverlap: (options?: ContextOverlapOptions) => EvalRule;
|
|
121
|
+
readonly quoteOverlap: (options?: QuoteOverlapOptions) => EvalRule;
|
|
122
|
+
readonly citationPresence: (options?: CitationPresenceOptions) => EvalRule;
|
|
123
|
+
readonly requiredSourceIds: (requiredIds: readonly string[], options?: RequiredSourceIdsOptions) => EvalRule;
|
|
124
|
+
readonly answerLengthBounds: (options: AnswerLengthBoundsOptions) => EvalRule;
|
|
125
|
+
readonly bannedUnsupportedPhrases: (phrases?: readonly string[], options?: BannedUnsupportedPhrasesOptions) => EvalRule;
|
|
126
|
+
};
|
|
127
|
+
declare function renderEvalMarkdown(result: EvalRunResult): string;
|
|
128
|
+
|
|
129
|
+
export { type AnswerLengthBoundsOptions, type BannedUnsupportedPhrasesOptions, type CitationPresenceOptions, type ContextOverlapOptions, type EvalContext, type EvalDiagnostic, type EvalDiagnosticCode, type EvalEvidence, type EvalFinding, type EvalFindingStatus, type EvalInput, type EvalRule, type EvalRuleCategory, type EvalRunInput, type EvalRunOptions, type EvalRunResult, type EvalSeverity, type EvalStatus, type EvalSummary, type QuoteOverlapOptions, type RequiredSourceIdsOptions, checks, evalRun, renderEvalMarkdown };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { TraceReadResult } from 'agent-inspect/readers';
|
|
2
|
+
|
|
3
|
+
type EvalStatus = "pass" | "fail" | "error";
|
|
4
|
+
type EvalSeverity = "error" | "warning" | "info";
|
|
5
|
+
type EvalFindingStatus = "pass" | "fail" | "warning";
|
|
6
|
+
type EvalRuleCategory = "run" | "tool" | "llm" | "retrieval" | "structure" | "safety" | "custom";
|
|
7
|
+
interface EvalEvidence {
|
|
8
|
+
runId?: string;
|
|
9
|
+
eventId?: string;
|
|
10
|
+
parentId?: string;
|
|
11
|
+
traceId?: string;
|
|
12
|
+
spanId?: string;
|
|
13
|
+
kind?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
}
|
|
17
|
+
interface EvalFinding {
|
|
18
|
+
ruleId: string;
|
|
19
|
+
status: EvalFindingStatus;
|
|
20
|
+
severity: EvalSeverity;
|
|
21
|
+
message: string;
|
|
22
|
+
expected?: unknown;
|
|
23
|
+
actual?: unknown;
|
|
24
|
+
evidence: EvalEvidence[];
|
|
25
|
+
}
|
|
26
|
+
interface EvalDiagnostic {
|
|
27
|
+
code: "AI_EVAL_TRACE_UNREADABLE" | "AI_EVAL_UNSUPPORTED_FORMAT" | "AI_EVAL_AMBIGUOUS_FORMAT" | "AI_EVAL_RUN_SELECTION_REQUIRED" | "AI_EVAL_RULE_FAILED" | "AI_EVAL_INVALID_ARGUMENTS" | "AI_EVAL_INVALID_CONFIG" | "AI_EVAL_CONFIG_LOAD_FAILED";
|
|
28
|
+
severity: EvalSeverity;
|
|
29
|
+
message: string;
|
|
30
|
+
ruleId?: string;
|
|
31
|
+
}
|
|
32
|
+
type EvalDiagnosticCode = EvalDiagnostic["code"];
|
|
33
|
+
interface EvalSummary {
|
|
34
|
+
passed: number;
|
|
35
|
+
failed: number;
|
|
36
|
+
warnings: number;
|
|
37
|
+
errors: number;
|
|
38
|
+
}
|
|
39
|
+
interface EvalRunResult {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
status: EvalStatus;
|
|
42
|
+
format: string;
|
|
43
|
+
runId?: string;
|
|
44
|
+
summary: EvalSummary;
|
|
45
|
+
findings: EvalFinding[];
|
|
46
|
+
diagnostics: EvalDiagnostic[];
|
|
47
|
+
}
|
|
48
|
+
interface EvalInput {
|
|
49
|
+
trace: string | URL | TraceReadResult;
|
|
50
|
+
runId?: string;
|
|
51
|
+
format?: "agent-inspect-jsonl" | "openinference-json" | "otlp-json" | "auto";
|
|
52
|
+
}
|
|
53
|
+
interface EvalRunOptions {
|
|
54
|
+
checks?: readonly EvalRule[];
|
|
55
|
+
runId?: string;
|
|
56
|
+
format?: EvalInput["format"];
|
|
57
|
+
}
|
|
58
|
+
type EvalRunInput = EvalInput | string | TraceReadResult;
|
|
59
|
+
/** Experimental options for deterministic answer/context overlap checks. */
|
|
60
|
+
interface ContextOverlapOptions {
|
|
61
|
+
minOverlap?: number;
|
|
62
|
+
minSharedTerms?: number;
|
|
63
|
+
answerKeys?: readonly string[];
|
|
64
|
+
contextKeys?: readonly string[];
|
|
65
|
+
}
|
|
66
|
+
/** Experimental options for deterministic quote grounding checks. */
|
|
67
|
+
interface QuoteOverlapOptions {
|
|
68
|
+
answerKeys?: readonly string[];
|
|
69
|
+
contextKeys?: readonly string[];
|
|
70
|
+
minQuoteLength?: number;
|
|
71
|
+
requireQuote?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Experimental options for deterministic citation presence checks. */
|
|
74
|
+
interface CitationPresenceOptions {
|
|
75
|
+
answerKeys?: readonly string[];
|
|
76
|
+
citationKeys?: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
/** Experimental options for deterministic source-id checks. */
|
|
79
|
+
interface RequiredSourceIdsOptions {
|
|
80
|
+
sourceIdKeys?: readonly string[];
|
|
81
|
+
}
|
|
82
|
+
/** Experimental options for deterministic answer length checks. */
|
|
83
|
+
interface AnswerLengthBoundsOptions {
|
|
84
|
+
minCharacters?: number;
|
|
85
|
+
maxCharacters?: number;
|
|
86
|
+
minWords?: number;
|
|
87
|
+
maxWords?: number;
|
|
88
|
+
answerKeys?: readonly string[];
|
|
89
|
+
}
|
|
90
|
+
/** Experimental options for deterministic unsupported-phrase checks. */
|
|
91
|
+
interface BannedUnsupportedPhrasesOptions {
|
|
92
|
+
answerKeys?: readonly string[];
|
|
93
|
+
}
|
|
94
|
+
interface EvalRule {
|
|
95
|
+
id: string;
|
|
96
|
+
category: EvalRuleCategory;
|
|
97
|
+
severity?: EvalSeverity;
|
|
98
|
+
evaluate(context: EvalContext): readonly EvalFinding[];
|
|
99
|
+
}
|
|
100
|
+
type EvalRunTree = TraceReadResult["runs"][number];
|
|
101
|
+
type EvalNode = EvalRunTree["children"][number];
|
|
102
|
+
interface EvalContext {
|
|
103
|
+
format: string;
|
|
104
|
+
run: EvalRunTree;
|
|
105
|
+
nodes: readonly EvalNode[];
|
|
106
|
+
events: readonly TraceReadResult["events"][number][];
|
|
107
|
+
}
|
|
108
|
+
declare function evalRun(input: EvalRunInput, options?: EvalRunOptions): Promise<EvalRunResult>;
|
|
109
|
+
declare const checks: {
|
|
110
|
+
readonly requireSuccess: () => EvalRule;
|
|
111
|
+
readonly requiredTools: (required: readonly string[]) => EvalRule;
|
|
112
|
+
readonly forbiddenTools: (forbidden: readonly string[]) => EvalRule;
|
|
113
|
+
readonly maxDurationMs: (maxDurationMs: number) => EvalRule;
|
|
114
|
+
readonly maxDepth: (maxDepth: number) => EvalRule;
|
|
115
|
+
readonly maxRetries: (maxRetries: number) => EvalRule;
|
|
116
|
+
readonly maxTotalTokens: (maxTotalTokens: number) => EvalRule;
|
|
117
|
+
readonly noFailedSteps: () => EvalRule;
|
|
118
|
+
readonly requiredRetrievalBeforeGeneration: () => EvalRule;
|
|
119
|
+
readonly requiredDecisionMetadata: (keys: readonly string[]) => EvalRule;
|
|
120
|
+
readonly contextOverlap: (options?: ContextOverlapOptions) => EvalRule;
|
|
121
|
+
readonly quoteOverlap: (options?: QuoteOverlapOptions) => EvalRule;
|
|
122
|
+
readonly citationPresence: (options?: CitationPresenceOptions) => EvalRule;
|
|
123
|
+
readonly requiredSourceIds: (requiredIds: readonly string[], options?: RequiredSourceIdsOptions) => EvalRule;
|
|
124
|
+
readonly answerLengthBounds: (options: AnswerLengthBoundsOptions) => EvalRule;
|
|
125
|
+
readonly bannedUnsupportedPhrases: (phrases?: readonly string[], options?: BannedUnsupportedPhrasesOptions) => EvalRule;
|
|
126
|
+
};
|
|
127
|
+
declare function renderEvalMarkdown(result: EvalRunResult): string;
|
|
128
|
+
|
|
129
|
+
export { type AnswerLengthBoundsOptions, type BannedUnsupportedPhrasesOptions, type CitationPresenceOptions, type ContextOverlapOptions, type EvalContext, type EvalDiagnostic, type EvalDiagnosticCode, type EvalEvidence, type EvalFinding, type EvalFindingStatus, type EvalInput, type EvalRule, type EvalRuleCategory, type EvalRunInput, type EvalRunOptions, type EvalRunResult, type EvalSeverity, type EvalStatus, type EvalSummary, type QuoteOverlapOptions, type RequiredSourceIdsOptions, checks, evalRun, renderEvalMarkdown };
|