@arnilo/prism-hosts 0.0.0-stage → 0.13.1
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/CHANGELOG.md +394 -0
- package/LICENSE +21 -0
- package/README.md +34 -2
- package/acp/README.md +87 -0
- package/acp/src/capabilities.ts +184 -0
- package/acp/src/errors.ts +24 -0
- package/acp/src/host.ts +36 -0
- package/acp/src/index.ts +25 -0
- package/acp/src/limits.ts +49 -0
- package/acp/src/mapper.ts +419 -0
- package/acp/src/permission.ts +37 -0
- package/acp/src/projection.ts +39 -0
- package/acp/src/prompt.ts +170 -0
- package/acp/src/serve.ts +345 -0
- package/acp/src/session-map.ts +49 -0
- package/ag-ui/README.md +56 -0
- package/ag-ui/src/a2ui.ts +570 -0
- package/ag-ui/src/ag-ui-mapper.ts +507 -0
- package/ag-ui/src/encrypted-value.ts +40 -0
- package/ag-ui/src/errors.ts +29 -0
- package/ag-ui/src/handler.ts +642 -0
- package/ag-ui/src/index.ts +177 -0
- package/ag-ui/src/input.ts +190 -0
- package/ag-ui/src/limits.ts +279 -0
- package/ag-ui/src/mcp-apps.ts +256 -0
- package/ag-ui/src/mcp.ts +94 -0
- package/ag-ui/src/projection.ts +201 -0
- package/ag-ui/src/projectors.ts +272 -0
- package/ag-ui/src/renderer/bind.ts +152 -0
- package/ag-ui/src/renderer/core.ts +270 -0
- package/ag-ui/src/renderer/index.ts +165 -0
- package/ag-ui/src/replay.ts +189 -0
- package/ag-ui/src/types.ts +66 -0
- package/channels/README.md +139 -0
- package/channels/src/admission.ts +8 -0
- package/channels/src/approvals.ts +262 -0
- package/channels/src/checkpoint-contract.ts +97 -0
- package/channels/src/delivery.ts +116 -0
- package/channels/src/host-ui.ts +356 -0
- package/channels/src/identity.ts +46 -0
- package/channels/src/index.ts +82 -0
- package/channels/src/limits.ts +49 -0
- package/channels/src/memory-stores.ts +112 -0
- package/channels/src/pairing.ts +178 -0
- package/channels/src/runtime-admit.ts +389 -0
- package/channels/src/runtime-core.ts +621 -0
- package/channels/src/runtime-reconcile.ts +299 -0
- package/channels/src/runtime-turn.ts +664 -0
- package/channels/src/runtime-types.ts +95 -0
- package/channels/src/runtime.ts +86 -0
- package/channels/src/secret-ref.ts +42 -0
- package/channels/src/signal.ts +790 -0
- package/channels/src/state.ts +355 -0
- package/channels/src/telegram.ts +1317 -0
- package/channels/src/types.ts +442 -0
- package/devtools/README.md +92 -0
- package/devtools/bin/prism-devtools.ts +63 -0
- package/devtools/src/args.ts +71 -0
- package/devtools/src/bun.d.ts +27 -0
- package/devtools/src/compare.ts +190 -0
- package/devtools/src/errors.ts +15 -0
- package/devtools/src/index.ts +25 -0
- package/devtools/src/replay.ts +36 -0
- package/devtools/src/security.ts +80 -0
- package/devtools/src/serve.ts +259 -0
- package/devtools/src/ui/assets.ts +108 -0
- package/devtools/src/ui/inspector.ts +182 -0
- package/driver-process/README.md +197 -0
- package/driver-process/src/abort.ts +74 -0
- package/driver-process/src/adapter.ts +211 -0
- package/driver-process/src/driver.ts +303 -0
- package/driver-process/src/errors.ts +17 -0
- package/driver-process/src/extend.ts +72 -0
- package/driver-process/src/index.ts +5 -0
- package/driver-process/src/inspect.ts +33 -0
- package/driver-process/src/session.ts +72 -0
- package/driver-process/src/testing.ts +394 -0
- package/driver-process/src/transports/json-rpc.ts +147 -0
- package/driver-process/src/transports/jsonl-stream.ts +12 -0
- package/driver-process/src/transports/types.ts +11 -0
- package/driver-process/src/turn.ts +106 -0
- package/evals/README.md +843 -0
- package/evals/src/calibration.ts +179 -0
- package/evals/src/citation-integrity.ts +98 -0
- package/evals/src/citations.ts +45 -0
- package/evals/src/compare-experiments.ts +153 -0
- package/evals/src/comparison.ts +230 -0
- package/evals/src/curate.ts +257 -0
- package/evals/src/dataset.ts +81 -0
- package/evals/src/erp-invariants.ts +163 -0
- package/evals/src/errors.ts +23 -0
- package/evals/src/experiment.ts +537 -0
- package/evals/src/failure-injection.ts +77 -0
- package/evals/src/feedback.ts +53 -0
- package/evals/src/index.ts +198 -0
- package/evals/src/injection.ts +247 -0
- package/evals/src/judge-panel.ts +109 -0
- package/evals/src/judge.ts +89 -0
- package/evals/src/limits.ts +50 -0
- package/evals/src/report-record.ts +47 -0
- package/evals/src/rubric-judge.ts +334 -0
- package/evals/src/scenario-runner.ts +317 -0
- package/evals/src/scenarios.ts +81 -0
- package/evals/src/score.ts +328 -0
- package/evals/src/scorer.ts +21 -0
- package/evals/src/state-match.ts +130 -0
- package/evals/src/stats.ts +635 -0
- package/evals/src/threshold.ts +117 -0
- package/evals/src/timeline.ts +38 -0
- package/evals/src/toolless-session.ts +33 -0
- package/evals/src/trace.ts +80 -0
- package/evals/src/trajectory.ts +623 -0
- package/evals/src/types.ts +672 -0
- package/evals/src/user-simulator.ts +101 -0
- package/evals/src/util.ts +207 -0
- package/headless/README.md +172 -0
- package/headless/src/answers.ts +91 -0
- package/headless/src/authority.ts +32 -0
- package/headless/src/errors.ts +36 -0
- package/headless/src/index.ts +17 -0
- package/headless/src/limits.ts +11 -0
- package/headless/src/pending.ts +16 -0
- package/headless/src/policy.ts +36 -0
- package/headless/src/resume.ts +103 -0
- package/headless/src/route.ts +153 -0
- package/headless/src/scheduler/clock.ts +22 -0
- package/headless/src/scheduler/cron.ts +19 -0
- package/headless/src/scheduler/firing.ts +58 -0
- package/headless/src/scheduler/index.ts +399 -0
- package/headless/src/scheduler/lease.ts +38 -0
- package/headless/src/scheduler/missed.ts +12 -0
- package/headless/src/scheduler/state.ts +132 -0
- package/host-builder/README.md +251 -0
- package/host-builder/bin/prism-host-builder.ts +169 -0
- package/host-builder/data/api.json +6197 -0
- package/host-builder/data/errors.json +558 -0
- package/host-builder/data/examples/acp.ts +63 -0
- package/host-builder/data/examples/adapters/conformance.ts +34 -0
- package/host-builder/data/examples/adapters/fixtures/rpc-server.json +26 -0
- package/host-builder/data/examples/adapters/fixtures/stream-cli.json +27 -0
- package/host-builder/data/examples/adapters/fixtures/workspace-config.json +28 -0
- package/host-builder/data/examples/adapters/rpc-server.dialect.ts +218 -0
- package/host-builder/data/examples/adapters/rpc-server.ts +309 -0
- package/host-builder/data/examples/adapters/stream-cli.dialect.ts +165 -0
- package/host-builder/data/examples/adapters/stream-cli.ts +256 -0
- package/host-builder/data/examples/adapters/workspace-config.dialect.ts +172 -0
- package/host-builder/data/examples/adapters/workspace-config.ts +251 -0
- package/host-builder/data/examples/advisor.ts +94 -0
- package/host-builder/data/examples/ag-ui-a2ui.ts +80 -0
- package/host-builder/data/examples/ag-ui-mcp-apps.ts +44 -0
- package/host-builder/data/examples/ag-ui-server.ts +118 -0
- package/host-builder/data/examples/agent-durable-approval.ts +43 -0
- package/host-builder/data/examples/api-key-auth.ts +23 -0
- package/host-builder/data/examples/approval.ts +92 -0
- package/host-builder/data/examples/attention-compiler.ts +81 -0
- package/host-builder/data/examples/autonomous-coding-loop.ts +343 -0
- package/host-builder/data/examples/behavior-evaluation.ts +303 -0
- package/host-builder/data/examples/build-workflow.ts +334 -0
- package/host-builder/data/examples/cache-aware-prompt-assembly.ts +139 -0
- package/host-builder/data/examples/caveman-ponytail.ts +197 -0
- package/host-builder/data/examples/cli.ts +31 -0
- package/host-builder/data/examples/coding-approval.ts +115 -0
- package/host-builder/data/examples/coding-browser-evaluation.ts +208 -0
- package/host-builder/data/examples/coding-compaction.ts +30 -0
- package/host-builder/data/examples/coding-goal-verify.ts +121 -0
- package/host-builder/data/examples/coding-tools-capability-gaps.ts +75 -0
- package/host-builder/data/examples/compaction.ts +36 -0
- package/host-builder/data/examples/connected-slack-mcp.ts +67 -0
- package/host-builder/data/examples/context.ts +29 -0
- package/host-builder/data/examples/custom-adapter.ts +256 -0
- package/host-builder/data/examples/custom-builders.ts +66 -0
- package/host-builder/data/examples/custom-loop.ts +89 -0
- package/host-builder/data/examples/custom-provider.ts +70 -0
- package/host-builder/data/examples/custom-session-store.ts +72 -0
- package/host-builder/data/examples/custom-tools-skills-context.ts +97 -0
- package/host-builder/data/examples/decision-models.ts +98 -0
- package/host-builder/data/examples/define-package.ts +188 -0
- package/host-builder/data/examples/delegate.ts +200 -0
- package/host-builder/data/examples/discover-skills.ts +65 -0
- package/host-builder/data/examples/drive-rag-sync.ts +44 -0
- package/host-builder/data/examples/durable-approval.ts +139 -0
- package/host-builder/data/examples/durable-investigation.ts +93 -0
- package/host-builder/data/examples/durable-loops-and-approvals.ts +94 -0
- package/host-builder/data/examples/enterprise-identity.ts +21 -0
- package/host-builder/data/examples/enterprise-policy-audit.ts +50 -0
- package/host-builder/data/examples/enterprise-work-connectors.ts +103 -0
- package/host-builder/data/examples/eval-injection.ts +73 -0
- package/host-builder/data/examples/eval-judges.ts +145 -0
- package/host-builder/data/examples/evals.ts +86 -0
- package/host-builder/data/examples/evaluation-gate.ts +40 -0
- package/host-builder/data/examples/execution-timeline.ts +173 -0
- package/host-builder/data/examples/external-agent.ts +541 -0
- package/host-builder/data/examples/external-app-db-backed.ts +344 -0
- package/host-builder/data/examples/governance-deny.ts +122 -0
- package/host-builder/data/examples/guardrail-packs.ts +240 -0
- package/host-builder/data/examples/headless-host.ts +245 -0
- package/host-builder/data/examples/hooks-audit-command.mjs +31 -0
- package/host-builder/data/examples/hooks-json.ts +87 -0
- package/host-builder/data/examples/host-builder-agent.ts +150 -0
- package/host-builder/data/examples/host-hooks.ts +71 -0
- package/host-builder/data/examples/host-step-loop-timeline.ts +212 -0
- package/host-builder/data/examples/hosted-sandbox.ts +48 -0
- package/host-builder/data/examples/instruction-injection.ts +127 -0
- package/host-builder/data/examples/jsonl-stores-branching.ts +49 -0
- package/host-builder/data/examples/long-term-memory.ts +158 -0
- package/host-builder/data/examples/manifest.ts +112 -0
- package/host-builder/data/examples/mcp-server.ts +48 -0
- package/host-builder/data/examples/mcp-trust.ts +173 -0
- package/host-builder/data/examples/memory-and-wiki.ts +315 -0
- package/host-builder/data/examples/memory-lifecycle.ts +302 -0
- package/host-builder/data/examples/memory-system.ts +255 -0
- package/host-builder/data/examples/messaging-agent.ts +70 -0
- package/host-builder/data/examples/minimal-host-app.ts +41 -0
- package/host-builder/data/examples/model-router-aggregate-budgets.ts +364 -0
- package/host-builder/data/examples/model-router.ts +106 -0
- package/host-builder/data/examples/obscura.ts +48 -0
- package/host-builder/data/examples/observability.ts +116 -0
- package/host-builder/data/examples/open-connector-sidecar.ts +105 -0
- package/host-builder/data/examples/openai-compatible.ts +70 -0
- package/host-builder/data/examples/package-skills.ts +85 -0
- package/host-builder/data/examples/phase9-coding-intelligence.ts +221 -0
- package/host-builder/data/examples/provider-registration.ts +29 -0
- package/host-builder/data/examples/provider-resolver.ts +39 -0
- package/host-builder/data/examples/rag.ts +40 -0
- package/host-builder/data/examples/remote-agent-server.ts +45 -0
- package/host-builder/data/examples/remote-agent.ts +124 -0
- package/host-builder/data/examples/research-ledger.ts +79 -0
- package/host-builder/data/examples/revocation-propagation.ts +287 -0
- package/host-builder/data/examples/run-feedback.ts +93 -0
- package/host-builder/data/examples/scanned-document-rag.ts +48 -0
- package/host-builder/data/examples/sdk-basics.ts +21 -0
- package/host-builder/data/examples/secure-agent.ts +55 -0
- package/host-builder/data/examples/semantic-memory.ts +52 -0
- package/host-builder/data/examples/serve-tools.ts +495 -0
- package/host-builder/data/examples/session-memory.ts +318 -0
- package/host-builder/data/examples/session-search.ts +131 -0
- package/host-builder/data/examples/session.ts +52 -0
- package/host-builder/data/examples/side-call.ts +68 -0
- package/host-builder/data/examples/signal-agent.ts +9 -0
- package/host-builder/data/examples/skills-progressive-disclosure.ts +88 -0
- package/host-builder/data/examples/skills.ts +19 -0
- package/host-builder/data/examples/sqlite-resume.ts +147 -0
- package/host-builder/data/examples/system-project-prompts.ts +74 -0
- package/host-builder/data/examples/system-prompts.ts +19 -0
- package/host-builder/data/examples/telegram-agent.ts +30 -0
- package/host-builder/data/examples/tool-narrowing-planes.ts +99 -0
- package/host-builder/data/examples/tools.ts +29 -0
- package/host-builder/data/examples/validator.ts +67 -0
- package/host-builder/data/examples/web-no-key.ts +85 -0
- package/host-builder/data/examples/web-research.ts +35 -0
- package/host-builder/data/examples/workflow-event-sink.ts +114 -0
- package/host-builder/data/examples/workflow-loop.ts +93 -0
- package/host-builder/data/examples/workflow-multimodal-document.ts +94 -0
- package/host-builder/data/examples/workflow-parallel-research.ts +111 -0
- package/host-builder/data/examples/workflow-postgres-resume.ts +75 -0
- package/host-builder/data/examples/workflow-research-and-review.ts +98 -0
- package/host-builder/data/examples/workflow-sqlite-resume.ts +163 -0
- package/host-builder/data/examples.json +130 -0
- package/host-builder/skills/prism-host-builder/SKILL.md +85 -0
- package/host-builder/skills/prism-host-builder/references/choosing.md +101 -0
- package/host-builder/skills/prism-host-builder/references/layout.md +52 -0
- package/host-builder/skills/prism-host-builder/references/pitfalls.md +50 -0
- package/host-builder/skills/prism-host-builder/references/recipes.md +129 -0
- package/host-builder/skills/prism-host-builder/references/security.md +52 -0
- package/host-builder/skills/prism-host-builder/references/upgrading.md +67 -0
- package/host-builder/skills/prism-host-builder/references/verification.md +108 -0
- package/host-builder/src/check/child.ts +108 -0
- package/host-builder/src/check/conformance.ts +13 -0
- package/host-builder/src/check/inspect.ts +20 -0
- package/host-builder/src/check/manifest.ts +23 -0
- package/host-builder/src/check/runner.ts +181 -0
- package/host-builder/src/check/targets.ts +65 -0
- package/host-builder/src/errors.ts +35 -0
- package/host-builder/src/index.ts +25 -0
- package/host-builder/src/indexes.ts +145 -0
- package/host-builder/src/install/install.ts +400 -0
- package/host-builder/src/install/targets.ts +50 -0
- package/host-builder/src/lookup/api.ts +127 -0
- package/host-builder/src/lookup/bound.ts +38 -0
- package/host-builder/src/lookup/docs.ts +238 -0
- package/host-builder/src/lookup/errors.ts +92 -0
- package/host-builder/src/lookup/examples.ts +117 -0
- package/host-builder/src/lookup/text.ts +60 -0
- package/host-builder/src/server.ts +300 -0
- package/host-builder/src/version.ts +38 -0
- package/mcp-server/README.md +219 -0
- package/mcp-server/src/bounds.ts +23 -0
- package/mcp-server/src/host.ts +31 -0
- package/mcp-server/src/index.ts +27 -0
- package/mcp-server/src/serve-tools.ts +408 -0
- package/mcp-server/src/serve.ts +329 -0
- package/mcp-server/src/server.ts +331 -0
- package/mcp-server/src/session-map.ts +47 -0
- package/mcp-server/src/skill-resources.ts +85 -0
- package/mcp-server/src/types.ts +215 -0
- package/package.json +130 -4
- package/remote/README.md +244 -0
- package/remote/src/attribution.ts +22 -0
- package/remote/src/auth.ts +30 -0
- package/remote/src/bun-module.d.ts +34 -0
- package/remote/src/channel.ts +86 -0
- package/remote/src/connect.ts +212 -0
- package/remote/src/dispatcher.ts +282 -0
- package/remote/src/errors.ts +59 -0
- package/remote/src/host-ui.ts +152 -0
- package/remote/src/http-gate.ts +43 -0
- package/remote/src/index.ts +53 -0
- package/remote/src/jsonl.ts +69 -0
- package/remote/src/limits.ts +43 -0
- package/remote/src/mirror.ts +90 -0
- package/remote/src/pending.ts +22 -0
- package/remote/src/protocol.ts +107 -0
- package/remote/src/serve.ts +560 -0
- package/remote/src/session-proxy.ts +219 -0
- package/remote/src/sse.ts +38 -0
- package/remote/src/stdio-client.ts +41 -0
- package/remote/src/testing-fixtures/serve-stdio.ts +32 -0
- package/remote/src/testing.ts +230 -0
- package/remote/src/transport.ts +139 -0
- package/remote/src/transports/client.ts +126 -0
- package/remote/src/transports/network.ts +268 -0
- package/remote/src/wire.ts +244 -0
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
import type { EvaluationTelemetry } from "@arnilo/prism-extensions/observability";
|
|
2
|
+
import type {
|
|
3
|
+
Agent,
|
|
4
|
+
AgentEventRecord,
|
|
5
|
+
ErrorInfo,
|
|
6
|
+
ModelConfig,
|
|
7
|
+
OwnershipScope,
|
|
8
|
+
EvaluationRecord,
|
|
9
|
+
EvaluationStore,
|
|
10
|
+
ExperimentReportStore,
|
|
11
|
+
RunRecord,
|
|
12
|
+
RunResult,
|
|
13
|
+
SecretRedactor,
|
|
14
|
+
ToolCallRecord,
|
|
15
|
+
Usage,
|
|
16
|
+
UsageRecord,
|
|
17
|
+
} from "@arnilo/prism";
|
|
18
|
+
|
|
19
|
+
/** JSON configuration; bind an agent with createUserSimulator before execution. */
|
|
20
|
+
export interface UserSimulatorSpec {
|
|
21
|
+
readonly persona: string;
|
|
22
|
+
readonly goal: string;
|
|
23
|
+
readonly maxTurns?: number;
|
|
24
|
+
readonly stop?: string;
|
|
25
|
+
readonly timeoutMs?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface UserSimulator extends UserSimulatorSpec {
|
|
29
|
+
readonly simulatorModel: Pick<ModelConfig, "provider" | "model">;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface UserSimulation {
|
|
33
|
+
readonly turns: readonly { readonly user: string; readonly assistant: string }[];
|
|
34
|
+
readonly stopReason: "goal_reached" | "max_turns" | "agent_stopped";
|
|
35
|
+
readonly simulatorModel: Pick<ModelConfig, "provider" | "model">;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type ScenarioInput = {
|
|
39
|
+
readonly kind: "scenario";
|
|
40
|
+
readonly maxTurns?: number;
|
|
41
|
+
readonly scoreTurns?: "last" | "each";
|
|
42
|
+
} & (
|
|
43
|
+
| { readonly turns: readonly (string | import("./scenario-runner.js").ScenarioTurn)[]; readonly user?: never }
|
|
44
|
+
| { readonly user: UserSimulatorSpec; readonly turns?: never }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export interface ExecutionStep {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly parentId?: string;
|
|
50
|
+
readonly kind: string;
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly order: number;
|
|
53
|
+
readonly status: string;
|
|
54
|
+
readonly startedAt: string;
|
|
55
|
+
readonly finishedAt?: string;
|
|
56
|
+
readonly durationMs?: number;
|
|
57
|
+
readonly input?: unknown;
|
|
58
|
+
readonly output?: unknown;
|
|
59
|
+
readonly error?: ErrorInfo;
|
|
60
|
+
readonly usage?: Usage;
|
|
61
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ExecutionTimeline {
|
|
65
|
+
readonly schemaVersion: 1;
|
|
66
|
+
readonly runId?: string;
|
|
67
|
+
readonly sessionId?: string;
|
|
68
|
+
readonly workflowId?: string;
|
|
69
|
+
readonly workflowRevision?: string;
|
|
70
|
+
readonly traceId?: string;
|
|
71
|
+
readonly status: string;
|
|
72
|
+
readonly startedAt: string;
|
|
73
|
+
readonly finishedAt?: string;
|
|
74
|
+
readonly input?: unknown;
|
|
75
|
+
readonly result?: unknown;
|
|
76
|
+
readonly usage?: Usage;
|
|
77
|
+
readonly steps: readonly ExecutionStep[];
|
|
78
|
+
readonly redacted?: boolean;
|
|
79
|
+
readonly content?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface TimelineFolder {
|
|
83
|
+
push(event: unknown): void;
|
|
84
|
+
snapshot(): ExecutionTimeline;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Score payload returned by a scorer. `score` must be finite and within `[0, 1]`. */
|
|
88
|
+
export interface ScoreResult {
|
|
89
|
+
readonly score: number;
|
|
90
|
+
readonly reason?: string;
|
|
91
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Input a scorer needs. Declared on the scorer, enforced by every entry point before a run. */
|
|
95
|
+
export type ScorerRequirement = "timeline" | "trace" | "environment";
|
|
96
|
+
|
|
97
|
+
/** Input passed to a scorer. Scorers receive results only — no credentials, tools, or workspace. */
|
|
98
|
+
export interface ScorerInput<TInput = unknown, TExpected = unknown> {
|
|
99
|
+
readonly result: RunResult;
|
|
100
|
+
readonly item?: DatasetItem<TInput, TExpected>;
|
|
101
|
+
readonly expected?: TExpected;
|
|
102
|
+
readonly signal?: AbortSignal;
|
|
103
|
+
readonly target?: EvaluationTarget;
|
|
104
|
+
readonly timeline?: ExecutionTimeline;
|
|
105
|
+
/** The step under evaluation when `forEach` is set; undefined for a whole-run score. */
|
|
106
|
+
readonly step?: ExecutionStep;
|
|
107
|
+
readonly environment?: unknown;
|
|
108
|
+
/**
|
|
109
|
+
* The entry point's resolved redactor (`redactor` or `secrets`), when the host configured one.
|
|
110
|
+
* Everything else here is raw: a scorer that sends `result`, `item` or `timeline` text out of the
|
|
111
|
+
* process (a judge prompt, a simulator turn) must redact it with this first.
|
|
112
|
+
*/
|
|
113
|
+
readonly redactor?: SecretRedactor;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Deterministic function scorer. */
|
|
117
|
+
export interface Scorer<TInput = unknown, TExpected = unknown> {
|
|
118
|
+
readonly id: string;
|
|
119
|
+
/** Known judge identity, used by panels to check model diversity before scoring. */
|
|
120
|
+
readonly judgeModel?: Pick<ModelConfig, "provider" | "model">;
|
|
121
|
+
readonly description?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Inputs this scorer cannot work without. An entry point that cannot supply one throws
|
|
124
|
+
* `EvalError` (`ERR_PRISM_EVAL_{TIMELINE,TRACE,ENVIRONMENT}_REQUIRED`) naming the scorer instead
|
|
125
|
+
* of scoring a missing input as an agent failure.
|
|
126
|
+
*/
|
|
127
|
+
readonly requires?: readonly ScorerRequirement[];
|
|
128
|
+
/**
|
|
129
|
+
* A hard invariant: the run is disqualified unless every record scores `1`. `scoreRun` stamps
|
|
130
|
+
* `metadata.invariant` on every record of such a scorer, so a throwing invariant still fails the gate.
|
|
131
|
+
* A `metadata.invariant` returned by `score` is ignored.
|
|
132
|
+
*/
|
|
133
|
+
readonly invariant?: boolean;
|
|
134
|
+
/** A scored record passes at or above this value in [0, 1]. Default: 1. */
|
|
135
|
+
readonly passThreshold?: number;
|
|
136
|
+
score(input: ScorerInput<TInput, TExpected>): ScoreResult | Promise<ScoreResult>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type Split = "dev" | "test" | "heldout";
|
|
140
|
+
|
|
141
|
+
/** One dataset row. */
|
|
142
|
+
export interface DatasetItem<TInput = unknown, TExpected = unknown> {
|
|
143
|
+
readonly id: string;
|
|
144
|
+
readonly input: TInput;
|
|
145
|
+
readonly expected?: TExpected;
|
|
146
|
+
readonly split?: Split;
|
|
147
|
+
readonly tags?: readonly string[];
|
|
148
|
+
readonly label?: {
|
|
149
|
+
readonly source: "human" | "model" | "curated" | "synthetic";
|
|
150
|
+
readonly adjudicated?: boolean;
|
|
151
|
+
readonly by?: string;
|
|
152
|
+
};
|
|
153
|
+
readonly expectedTrajectory?: readonly import("./trajectory.js").ToolCallSpec[];
|
|
154
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Immutable dataset snapshot. */
|
|
158
|
+
export interface Dataset<TInput = unknown, TExpected = unknown> {
|
|
159
|
+
readonly id: string;
|
|
160
|
+
readonly version?: string;
|
|
161
|
+
readonly canary?: string;
|
|
162
|
+
readonly contentHash: string;
|
|
163
|
+
readonly items: readonly DatasetItem<TInput, TExpected>[];
|
|
164
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface DefineScorerInput<TInput = unknown, TExpected = unknown> {
|
|
168
|
+
readonly id: string;
|
|
169
|
+
readonly judgeModel?: Scorer<TInput, TExpected>["judgeModel"];
|
|
170
|
+
readonly description?: string;
|
|
171
|
+
readonly requires?: readonly ScorerRequirement[];
|
|
172
|
+
readonly invariant?: boolean;
|
|
173
|
+
/** A scored record passes at or above this value in [0, 1]. Default: 1. */
|
|
174
|
+
readonly passThreshold?: number;
|
|
175
|
+
readonly score: Scorer<TInput, TExpected>["score"];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface DefineDatasetInput<TInput = unknown, TExpected = unknown> {
|
|
179
|
+
readonly id: string;
|
|
180
|
+
readonly version?: string;
|
|
181
|
+
readonly canary?: string;
|
|
182
|
+
readonly items: readonly DatasetItem<TInput, TExpected>[];
|
|
183
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Optional observer; exceptions never alter evaluation records. */
|
|
187
|
+
export interface EvaluationTelemetrySink {
|
|
188
|
+
handleEvaluation(evaluation: EvaluationTelemetry): void;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface EvaluationSamplingMetadata {
|
|
192
|
+
readonly stratum: string;
|
|
193
|
+
readonly probability: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface EvaluationSampling {
|
|
197
|
+
/** Default per-run inclusion probability in `[0, 1]`. Defaults to `1`. */
|
|
198
|
+
readonly rate?: number;
|
|
199
|
+
/** Optional classifier mapping a run result to its stratum name (called once per run). */
|
|
200
|
+
readonly strata?: (result: RunResult) => string;
|
|
201
|
+
/** Optional per-stratum inclusion probabilities in `[0, 1]`, overriding `rate`. */
|
|
202
|
+
readonly rates?: Readonly<Record<string, number>>;
|
|
203
|
+
/** Optional predicate forcing inclusion with `probability: 1` (e.g. failed or denied runs). */
|
|
204
|
+
readonly always?: (result: RunResult) => boolean;
|
|
205
|
+
/** Optional seed for per-run RNG (`mulberry32(hash32(seed, runId, 0))`). */
|
|
206
|
+
readonly seed?: number;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface EstimateOnlineOptions {
|
|
210
|
+
/** Scorer id to estimate; optional when all supplied records share one scorerId. */
|
|
211
|
+
readonly scorerId?: string;
|
|
212
|
+
/** Bootstrap seed, default 0. */
|
|
213
|
+
readonly seed?: number;
|
|
214
|
+
/** Bootstrap resamples, default 2,000, maximum HARD_STATS_RESAMPLES. */
|
|
215
|
+
readonly resamples?: number;
|
|
216
|
+
/** Interval coverage in (0, 1), default 0.95. */
|
|
217
|
+
readonly confidence?: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface OnlineEstimate {
|
|
221
|
+
readonly scorerId: string;
|
|
222
|
+
readonly n: number;
|
|
223
|
+
readonly effectiveN: number;
|
|
224
|
+
readonly mean: number;
|
|
225
|
+
readonly ci95: { readonly low: number; readonly high: number };
|
|
226
|
+
readonly byStratum: Readonly<
|
|
227
|
+
Record<
|
|
228
|
+
string,
|
|
229
|
+
{
|
|
230
|
+
readonly n: number;
|
|
231
|
+
readonly mean: number;
|
|
232
|
+
readonly weightSum: number;
|
|
233
|
+
}
|
|
234
|
+
>
|
|
235
|
+
>;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface ScoreRunOptions<TInput = unknown, TExpected = unknown> {
|
|
239
|
+
readonly result: RunResult;
|
|
240
|
+
readonly scorers: readonly Scorer<TInput, TExpected>[];
|
|
241
|
+
/** Stratified, weighted sampling configuration. Defaults to `rate: 1` when supplied. */
|
|
242
|
+
readonly sampling?: EvaluationSampling;
|
|
243
|
+
/** Seed for per-run RNG (`mulberry32(hash32(seed, runId, 0))`) when `random` is omitted. */
|
|
244
|
+
readonly seed?: number;
|
|
245
|
+
readonly store?: EvaluationStore;
|
|
246
|
+
readonly telemetry?: EvaluationTelemetrySink;
|
|
247
|
+
readonly ownership?: OwnershipScope;
|
|
248
|
+
readonly redactor?: SecretRedactor;
|
|
249
|
+
readonly secrets?: readonly (string | undefined)[];
|
|
250
|
+
readonly signal?: AbortSignal;
|
|
251
|
+
readonly datasetId?: string;
|
|
252
|
+
readonly itemId?: string;
|
|
253
|
+
readonly item?: DatasetItem<TInput, TExpected>;
|
|
254
|
+
readonly experimentId?: string;
|
|
255
|
+
readonly traceId?: string;
|
|
256
|
+
/** Optional explicit resolver; requires ownership, sessionId, and runId. */
|
|
257
|
+
readonly traceResolver?: TraceResolver;
|
|
258
|
+
readonly traceLimits?: TraceLimits;
|
|
259
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
260
|
+
/** Injectable RNG for deterministic sampling tests. Returns `[0, 1)`. */
|
|
261
|
+
/** Explicit RNG overrides `seed`. One shared stream, so decisions depend on completion order. */
|
|
262
|
+
readonly random?: () => number;
|
|
263
|
+
/** Hooks for the agent factory. With an `Agent` instance they throw: it cannot be reconfigured. */
|
|
264
|
+
readonly hooks?: import("@arnilo/prism").AgentConfig["hooks"];
|
|
265
|
+
/** Slots for the agent factory. With an `Agent` instance they throw: it cannot be reconfigured. */
|
|
266
|
+
readonly slots?: import("@arnilo/prism").AgentConfig["slots"];
|
|
267
|
+
/** Timeline projection mode. Defaults to "off". */
|
|
268
|
+
readonly timeline?: "off" | "metadata" | "redacted_io";
|
|
269
|
+
/** Injected timeline instance (bypasses trace projection when supplied). */
|
|
270
|
+
readonly injectedTimeline?: ExecutionTimeline;
|
|
271
|
+
/** Optional host-supplied environment state snapshot. */
|
|
272
|
+
readonly environment?: unknown;
|
|
273
|
+
/** Evaluate scorers per step matching kind rather than once per run. */
|
|
274
|
+
readonly forEach?: "tool" | "workflow_node";
|
|
275
|
+
/** Maximum step evaluations per run under forEach. Default 32, hard 128. */
|
|
276
|
+
readonly maxStepScores?: number;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export interface LiveScoreOptions<TInput = unknown, TExpected = unknown> extends Omit<ScoreRunOptions<TInput, TExpected>, "result"> {
|
|
280
|
+
readonly onError?: (error: unknown) => void;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface ExperimentItemResult<TInput = unknown, TExpected = unknown> {
|
|
284
|
+
readonly item: DatasetItem<TInput, TExpected>;
|
|
285
|
+
readonly result?: RunResult;
|
|
286
|
+
readonly trials: readonly {
|
|
287
|
+
readonly usage?: Usage;
|
|
288
|
+
readonly durationMs?: number;
|
|
289
|
+
readonly status: RunResult["status"];
|
|
290
|
+
/** Every observed provider attempt was priced in the same currency. */
|
|
291
|
+
readonly costComplete: boolean;
|
|
292
|
+
readonly simulation?: UserSimulation;
|
|
293
|
+
}[];
|
|
294
|
+
readonly evaluations: readonly EvaluationRecord[];
|
|
295
|
+
readonly error?: ErrorInfo;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface ScorerStats {
|
|
299
|
+
readonly items: number;
|
|
300
|
+
readonly records: number;
|
|
301
|
+
readonly mean: number;
|
|
302
|
+
readonly passRate: number;
|
|
303
|
+
/** Item-averaged reliability estimates; present only with multiple configured trials. */
|
|
304
|
+
readonly passAtK?: Readonly<Record<number, number>>;
|
|
305
|
+
readonly passHatK?: Readonly<Record<number, number>>;
|
|
306
|
+
/** Counts include dataset items with no scored trials; estimates omit k with zero eligible items. */
|
|
307
|
+
readonly passKCounts?: Readonly<Record<number, { readonly items: number; readonly excludedItems: number }>>;
|
|
308
|
+
readonly se?: number;
|
|
309
|
+
readonly ci95?: { readonly low: number; readonly high: number };
|
|
310
|
+
/** Fleiss’ κ over complete panel label rows; absent when undefined or unavailable. */
|
|
311
|
+
readonly judgeAgreement?: number;
|
|
312
|
+
readonly method: "single_item" | "wilson" | "cluster_bootstrap";
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface ExperimentAggregate {
|
|
316
|
+
readonly itemCount: number;
|
|
317
|
+
readonly scoredCount: number;
|
|
318
|
+
readonly skippedCount: number;
|
|
319
|
+
readonly failedCount: number;
|
|
320
|
+
readonly macroMean?: number;
|
|
321
|
+
/** Always produced by runExperiment; optional for externally constructed score-only reports. */
|
|
322
|
+
readonly cost?: Usage & {
|
|
323
|
+
readonly costComplete: boolean;
|
|
324
|
+
readonly meanPerItem: Usage & { readonly durationMs?: number };
|
|
325
|
+
/** Nearest-rank percentiles of measured trial run times, excluding scoring. */
|
|
326
|
+
readonly durationMs?: { readonly p50: number; readonly p95: number };
|
|
327
|
+
};
|
|
328
|
+
readonly scorers: Readonly<Record<string, ScorerStats>>;
|
|
329
|
+
readonly byTag?: Readonly<Record<string, { readonly scorers: Readonly<Record<string, ScorerStats>> }>>;
|
|
330
|
+
/** True when all hard invariant scorers passed with score 1.0. */
|
|
331
|
+
readonly invariantsPassed?: boolean;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export interface ExperimentTrials {
|
|
335
|
+
readonly count: number;
|
|
336
|
+
readonly seed?: number;
|
|
337
|
+
readonly sampleCount: number;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface ExperimentReport<TInput = unknown, TExpected = unknown> {
|
|
341
|
+
readonly experimentId: string;
|
|
342
|
+
readonly datasetId: string;
|
|
343
|
+
readonly datasetVersion?: string;
|
|
344
|
+
/** Present on reports produced by runExperiment; optional for external score-only reports. */
|
|
345
|
+
readonly datasetContentHash?: string;
|
|
346
|
+
readonly split?: Split | readonly Split[];
|
|
347
|
+
readonly canary?: string;
|
|
348
|
+
readonly status: "succeeded" | "failed" | "aborted";
|
|
349
|
+
readonly items: readonly ExperimentItemResult<TInput, TExpected>[];
|
|
350
|
+
readonly evaluations: readonly EvaluationRecord[];
|
|
351
|
+
readonly aggregate: ExperimentAggregate;
|
|
352
|
+
readonly manifest?: EvalManifest;
|
|
353
|
+
readonly trials?: ExperimentTrials;
|
|
354
|
+
readonly error?: ErrorInfo;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** Options for paired baseline-versus-candidate inference. */
|
|
358
|
+
export interface CompareExperimentsOptions {
|
|
359
|
+
/** Defaults to the union of observed scorer ids; each must score every paired item. */
|
|
360
|
+
readonly scorers?: readonly string[];
|
|
361
|
+
readonly byTag?: boolean;
|
|
362
|
+
readonly seed?: number;
|
|
363
|
+
/** Bootstrap default 2,000; permutation default 10,000. Maximum HARD_STATS_RESAMPLES. */
|
|
364
|
+
readonly resamples?: number;
|
|
365
|
+
/** BH-adjusted significance level, default 0.05. Does not change ci95 coverage. */
|
|
366
|
+
readonly alpha?: number;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export interface ExperimentComparison {
|
|
370
|
+
/** BH correction across all tag/scorer pairs; tags with fewer than two paired items are omitted. */
|
|
371
|
+
readonly byTag?: Readonly<Record<string, ExperimentComparison>>;
|
|
372
|
+
readonly pairedItems: number;
|
|
373
|
+
readonly scorers: Readonly<
|
|
374
|
+
Record<
|
|
375
|
+
string,
|
|
376
|
+
{
|
|
377
|
+
readonly baselineMean: number;
|
|
378
|
+
readonly candidateMean: number;
|
|
379
|
+
/** Candidate minus baseline. */
|
|
380
|
+
readonly difference: number;
|
|
381
|
+
readonly ci95: { readonly low: number; readonly high: number };
|
|
382
|
+
readonly pValue: number;
|
|
383
|
+
readonly qValue: number;
|
|
384
|
+
readonly test: "mcnemar" | "paired_permutation";
|
|
385
|
+
readonly significant: boolean;
|
|
386
|
+
}
|
|
387
|
+
>
|
|
388
|
+
>;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export interface TraceLimits {
|
|
392
|
+
readonly pageSize?: number;
|
|
393
|
+
readonly maxPages?: number;
|
|
394
|
+
readonly maxBytes?: number;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface EvaluationTrace {
|
|
398
|
+
readonly run: RunRecord;
|
|
399
|
+
readonly events: readonly AgentEventRecord[];
|
|
400
|
+
readonly toolCalls: readonly ToolCallRecord[];
|
|
401
|
+
readonly usage: readonly UsageRecord[];
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export interface EvaluationTarget {
|
|
405
|
+
readonly result: RunResult;
|
|
406
|
+
readonly trace?: EvaluationTrace;
|
|
407
|
+
readonly timeline?: ExecutionTimeline;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export interface TraceResolverInput extends OwnershipScope {
|
|
411
|
+
readonly sessionId: string;
|
|
412
|
+
readonly runId: string;
|
|
413
|
+
readonly limits?: TraceLimits;
|
|
414
|
+
readonly redactor?: SecretRedactor;
|
|
415
|
+
readonly secrets?: readonly (string | undefined)[];
|
|
416
|
+
readonly signal?: AbortSignal;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export type TraceResolver = (input: TraceResolverInput) => Promise<EvaluationTrace>;
|
|
420
|
+
|
|
421
|
+
export interface ModelJudgeRequest<TInput = unknown, TExpected = unknown> {
|
|
422
|
+
readonly rubric: string;
|
|
423
|
+
readonly rubricVersion: string;
|
|
424
|
+
readonly target: EvaluationTarget;
|
|
425
|
+
readonly item?: DatasetItem<TInput, TExpected>;
|
|
426
|
+
readonly signal: AbortSignal;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export interface ModelJudgeOptions<TInput = unknown, TExpected = unknown> {
|
|
430
|
+
readonly id: string;
|
|
431
|
+
readonly rubric: string;
|
|
432
|
+
readonly rubricVersion: string;
|
|
433
|
+
readonly judge: (request: ModelJudgeRequest<TInput, TExpected>) => Promise<ScoreResult>;
|
|
434
|
+
readonly timeoutMs?: number;
|
|
435
|
+
readonly maxAttempts?: number;
|
|
436
|
+
readonly maxOutputBytes?: number;
|
|
437
|
+
readonly maxInputBytes?: number;
|
|
438
|
+
readonly maxRubricBytes?: number;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export interface JudgeRubric {
|
|
442
|
+
readonly id: string;
|
|
443
|
+
readonly version: string;
|
|
444
|
+
readonly criteria: string;
|
|
445
|
+
readonly scale: readonly { readonly label: string; readonly score: number; readonly description: string }[];
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface RubricJudgeOptions<TInput = unknown, TExpected = unknown> {
|
|
449
|
+
/** Defaults to the rubric id. */
|
|
450
|
+
readonly id?: string;
|
|
451
|
+
/** Host-owned; the scorer closes each session, but never disposes the agent. */
|
|
452
|
+
readonly agent: Agent | (() => Agent | Promise<Agent>);
|
|
453
|
+
readonly rubric: JudgeRubric;
|
|
454
|
+
readonly reference?: (item: DatasetItem<TInput, TExpected>) => string | undefined;
|
|
455
|
+
readonly include?: "answer" | "answer+timeline";
|
|
456
|
+
/** Actual candidate model, including any run override. Missing identity fails closed unless allowed. */
|
|
457
|
+
readonly judgedModel?:
|
|
458
|
+
| Pick<ModelConfig, "provider" | "model">
|
|
459
|
+
| ((input: ScorerInput<TInput, TExpected>) => Pick<ModelConfig, "provider" | "model"> | undefined);
|
|
460
|
+
readonly allowSelfJudging?: boolean;
|
|
461
|
+
readonly maxAttempts?: number;
|
|
462
|
+
readonly timeoutMs?: number;
|
|
463
|
+
readonly maxInputBytes?: number;
|
|
464
|
+
readonly maxOutputBytes?: number;
|
|
465
|
+
readonly maxRubricBytes?: number;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export interface JudgePanelOptions<TInput = unknown, TExpected = unknown> {
|
|
469
|
+
readonly id: string;
|
|
470
|
+
readonly judges: readonly Scorer<TInput, TExpected>[];
|
|
471
|
+
readonly combine: "majority" | "mean" | "median";
|
|
472
|
+
/** Default true: every judge must declare a known, distinct judgeModel at construction. */
|
|
473
|
+
readonly requireDistinctModels?: boolean;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export interface PairwiseJudgeOptions<TInput = unknown, TExpected = unknown>
|
|
477
|
+
extends Omit<RubricJudgeOptions<TInput, TExpected>, "rubric" | "reference" | "include" | "judgedModel"> {
|
|
478
|
+
readonly rubric: Pick<JudgeRubric, "id" | "version" | "criteria">;
|
|
479
|
+
readonly allowTie?: boolean;
|
|
480
|
+
/** Actual models for both candidates, including run overrides. Missing identities fail closed unless allowed. */
|
|
481
|
+
readonly judgedModels?:
|
|
482
|
+
| { readonly left: Pick<ModelConfig, "provider" | "model">; readonly right: Pick<ModelConfig, "provider" | "model"> }
|
|
483
|
+
| ((
|
|
484
|
+
input: PairwiseScorerInput<TInput, TExpected>,
|
|
485
|
+
) => { readonly left: Pick<ModelConfig, "provider" | "model">; readonly right: Pick<ModelConfig, "provider" | "model"> } | undefined);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export type PairwisePreference = "left" | "right" | "tie";
|
|
489
|
+
export interface PairwiseScoreResult {
|
|
490
|
+
readonly preference: PairwisePreference;
|
|
491
|
+
readonly reason?: string;
|
|
492
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
493
|
+
}
|
|
494
|
+
export interface PairwiseScorerInput<TInput = unknown, TExpected = unknown> {
|
|
495
|
+
readonly left: { readonly name: string; readonly result: RunResult };
|
|
496
|
+
readonly right: { readonly name: string; readonly result: RunResult };
|
|
497
|
+
readonly item: DatasetItem<TInput, TExpected>;
|
|
498
|
+
/** Redact before sending candidate or item content to a judge. */
|
|
499
|
+
readonly redactor?: SecretRedactor;
|
|
500
|
+
readonly signal?: AbortSignal;
|
|
501
|
+
}
|
|
502
|
+
export interface PairwiseScorer<TInput = unknown, TExpected = unknown> {
|
|
503
|
+
readonly id: string;
|
|
504
|
+
score(input: PairwiseScorerInput<TInput, TExpected>): PairwiseScoreResult | Promise<PairwiseScoreResult>;
|
|
505
|
+
}
|
|
506
|
+
export type ComparisonCandidate<TInput = unknown, TExpected = unknown> = (
|
|
507
|
+
item: DatasetItem<TInput, TExpected>,
|
|
508
|
+
signal?: AbortSignal,
|
|
509
|
+
) => Promise<RunResult>;
|
|
510
|
+
export interface ComparisonRecord {
|
|
511
|
+
readonly trialIndex: number;
|
|
512
|
+
readonly itemId: string;
|
|
513
|
+
readonly scorerId: string;
|
|
514
|
+
readonly left: string;
|
|
515
|
+
readonly right: string;
|
|
516
|
+
readonly preference?: PairwisePreference;
|
|
517
|
+
readonly status: "scored" | "failed";
|
|
518
|
+
readonly reason?: string;
|
|
519
|
+
readonly error?: ErrorInfo;
|
|
520
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
521
|
+
}
|
|
522
|
+
export interface ComparisonReport {
|
|
523
|
+
/** Separate fit per scorer; null means unavailable evidence, never a confident rank. */
|
|
524
|
+
readonly ranking: readonly {
|
|
525
|
+
readonly scorerId: string;
|
|
526
|
+
readonly candidate: string;
|
|
527
|
+
readonly strength: number | null;
|
|
528
|
+
readonly ci95: readonly [number, number] | null;
|
|
529
|
+
readonly rank: number | null;
|
|
530
|
+
}[];
|
|
531
|
+
/** Consistent / successful swapped judgments; scorers without swap evidence are omitted. */
|
|
532
|
+
readonly positionConsistency: Readonly<Record<string, number>>;
|
|
533
|
+
readonly datasetId: string;
|
|
534
|
+
readonly datasetVersion?: string;
|
|
535
|
+
readonly candidates: readonly string[];
|
|
536
|
+
readonly records: readonly ComparisonRecord[];
|
|
537
|
+
readonly wins: Readonly<Record<string, number>>;
|
|
538
|
+
readonly ties: number;
|
|
539
|
+
readonly failures: number;
|
|
540
|
+
}
|
|
541
|
+
export interface RunComparisonOptions<TInput = unknown, TExpected = unknown> {
|
|
542
|
+
readonly trials?: number;
|
|
543
|
+
/** Seed for item-bootstrap intervals; does not seed host candidate or scorer calls. */
|
|
544
|
+
readonly seed?: number;
|
|
545
|
+
readonly dataset: Dataset<TInput, TExpected>;
|
|
546
|
+
readonly candidates: Readonly<Record<string, ComparisonCandidate<TInput, TExpected>>>;
|
|
547
|
+
readonly scorers: readonly PairwiseScorer<TInput, TExpected>[];
|
|
548
|
+
readonly concurrency?: number;
|
|
549
|
+
readonly maxCandidates?: number;
|
|
550
|
+
readonly maxCandidateBytes?: number;
|
|
551
|
+
readonly maxScorerOutputBytes?: number;
|
|
552
|
+
readonly redactor?: SecretRedactor;
|
|
553
|
+
readonly secrets?: readonly (string | undefined)[];
|
|
554
|
+
readonly signal?: AbortSignal;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export interface EvaluationThresholds {
|
|
558
|
+
readonly calibrations?: Readonly<
|
|
559
|
+
Record<
|
|
560
|
+
string,
|
|
561
|
+
{
|
|
562
|
+
readonly report: CalibrationReport;
|
|
563
|
+
readonly minimumKappa: number;
|
|
564
|
+
readonly minimumN?: number;
|
|
565
|
+
}
|
|
566
|
+
>
|
|
567
|
+
>;
|
|
568
|
+
readonly minimumMacroMean?: number;
|
|
569
|
+
readonly maximumFailures?: number;
|
|
570
|
+
readonly minimumByScorer?: Readonly<Record<string, number>>;
|
|
571
|
+
/** Require a valid 95% interval whose lower bound meets the minimum. Missing evidence fails. */
|
|
572
|
+
readonly minimumLowerBound?: Readonly<Record<string, number>>;
|
|
573
|
+
/** Gate candidate-minus-baseline drops using BH-adjusted significance against zero. */
|
|
574
|
+
readonly maximumRegression?: {
|
|
575
|
+
readonly baseline: ExperimentReport;
|
|
576
|
+
readonly delta?: number;
|
|
577
|
+
readonly alpha?: number;
|
|
578
|
+
readonly scorers?: readonly string[];
|
|
579
|
+
};
|
|
580
|
+
readonly minimumPassHatK?: Readonly<Record<string, { readonly k: number; readonly minimum: number }>>;
|
|
581
|
+
readonly minimumCandidateWins?: Readonly<Record<string, number>>;
|
|
582
|
+
/**
|
|
583
|
+
* If true, the report must contain invariant records and all of them must score `1`. Omitted, a
|
|
584
|
+
* present-but-failing invariant still fails; an absent one only fails when this is set.
|
|
585
|
+
*/
|
|
586
|
+
readonly requireInvariants?: boolean;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
export interface CalibrationItem<TInput = unknown, TExpected = unknown> {
|
|
590
|
+
readonly item: DatasetItem<TInput, TExpected>;
|
|
591
|
+
readonly result: RunResult;
|
|
592
|
+
readonly humanScore: number;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export interface CalibrationReport {
|
|
596
|
+
/** Successfully scored human/judge pairs; failures do not count toward minimumN. */
|
|
597
|
+
readonly n: number;
|
|
598
|
+
readonly judgeFailures: number;
|
|
599
|
+
readonly cohensKappa: number | null;
|
|
600
|
+
readonly weightedKappa?: number | null;
|
|
601
|
+
/** Nominal alpha, also when the optional kappa scale is ordinal. */
|
|
602
|
+
readonly krippendorffAlpha: number | null;
|
|
603
|
+
readonly spearman: number | null;
|
|
604
|
+
/** Rows are human scores; columns are judge scores. */
|
|
605
|
+
readonly confusion: { readonly labels: readonly number[]; readonly counts: readonly (readonly number[])[] };
|
|
606
|
+
readonly kappaCi95?: { readonly low: number; readonly high: number };
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export interface EvalManifest {
|
|
610
|
+
readonly promptId?: string;
|
|
611
|
+
readonly promptVersion?: string;
|
|
612
|
+
readonly toolFingerprint?: string;
|
|
613
|
+
readonly skillsRevision?: string;
|
|
614
|
+
readonly model?: string;
|
|
615
|
+
readonly policyRevision?: string;
|
|
616
|
+
readonly runtimeRevision: string;
|
|
617
|
+
readonly datasetVersion: string;
|
|
618
|
+
readonly datasetContentHash?: string;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export interface RunExperimentOptions<TInput = unknown, TExpected = unknown> {
|
|
622
|
+
readonly agent:
|
|
623
|
+
| import("@arnilo/prism").Agent
|
|
624
|
+
| ((
|
|
625
|
+
extra: Pick<import("@arnilo/prism").AgentConfig, "hooks" | "slots"> & { readonly item: DatasetItem<TInput, TExpected> },
|
|
626
|
+
) => Promise<import("@arnilo/prism").Agent>);
|
|
627
|
+
readonly dataset: Dataset<TInput, TExpected>;
|
|
628
|
+
readonly split?: Split | readonly Split[];
|
|
629
|
+
readonly allowHeldout?: boolean;
|
|
630
|
+
readonly scorers: readonly Scorer<TInput, TExpected>[];
|
|
631
|
+
readonly concurrency?: number;
|
|
632
|
+
readonly sampling?: EvaluationSampling;
|
|
633
|
+
readonly store?: EvaluationStore;
|
|
634
|
+
readonly telemetry?: EvaluationTelemetrySink;
|
|
635
|
+
readonly experimentStore?: ExperimentReportStore;
|
|
636
|
+
readonly ownership?: OwnershipScope;
|
|
637
|
+
readonly redactor?: SecretRedactor;
|
|
638
|
+
readonly secrets?: readonly (string | undefined)[];
|
|
639
|
+
readonly signal?: AbortSignal;
|
|
640
|
+
readonly experimentId?: string;
|
|
641
|
+
readonly traceId?: string;
|
|
642
|
+
readonly traceResolver?: TraceResolver;
|
|
643
|
+
readonly traceLimits?: TraceLimits;
|
|
644
|
+
readonly runOptions?: import("@arnilo/prism").RunOptions;
|
|
645
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
646
|
+
/** Explicit RNG overrides `seed`. One shared stream, so decisions depend on completion order. */
|
|
647
|
+
readonly random?: () => number;
|
|
648
|
+
/** Hooks for the agent factory. With an `Agent` instance they throw: it cannot be reconfigured. */
|
|
649
|
+
readonly hooks?: import("@arnilo/prism").AgentConfig["hooks"];
|
|
650
|
+
/** Slots for the agent factory. With an `Agent` instance they throw: it cannot be reconfigured. */
|
|
651
|
+
readonly slots?: import("@arnilo/prism").AgentConfig["slots"];
|
|
652
|
+
readonly onItem?: (item: ExperimentItemResult<TInput, TExpected>) => void | Promise<void>;
|
|
653
|
+
/** Convert dataset input into agent input. Defaults to string/Message passthrough or JSON.stringify. */
|
|
654
|
+
readonly toAgentInput?: (input: TInput) => string | import("@arnilo/prism").Message | readonly import("@arnilo/prism").Message[];
|
|
655
|
+
/** Timeline projection mode. Defaults to "off". */
|
|
656
|
+
readonly timeline?: "off" | "metadata" | "redacted_io";
|
|
657
|
+
/** Optional callback to resolve host-trusted environment snapshot per item. */
|
|
658
|
+
readonly toEnvironment?: (
|
|
659
|
+
item: DatasetItem<TInput, TExpected>,
|
|
660
|
+
result?: RunResult,
|
|
661
|
+
timeline?: ExecutionTimeline,
|
|
662
|
+
) => unknown | Promise<unknown>;
|
|
663
|
+
/** Repeated trials count. Defaults to 1, hard cap 16. */
|
|
664
|
+
readonly trials?: number;
|
|
665
|
+
/**
|
|
666
|
+
* Seed for per-trial RNG: each `(itemId, trialIndex)` gets `mulberry32(hash32(seed, itemId, trialIndex))`,
|
|
667
|
+
* so sampling decisions are the same at any concurrency. Not a claim of LLM determinism.
|
|
668
|
+
*/
|
|
669
|
+
readonly seed?: number;
|
|
670
|
+
/** Eval manifest binding runtime, dataset, model, and policy revisions. */
|
|
671
|
+
readonly manifest?: EvalManifest;
|
|
672
|
+
}
|