@leostera/evalkit 0.7.0 → 0.9.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/CHANGELOG.md +56 -1
- package/README.md +2 -2
- package/dist/cli.mjs +386 -365
- package/dist/dashboard/assets/index-By1SJ1on.js +66 -0
- package/dist/dashboard/assets/index-geXMXCx9.css +2 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/{files-C-U0-PWW.mjs → files-DkDQs2JL.mjs} +3 -0
- package/dist/{index-db-vbqEGFaU.mjs → index-db-BbVblaHz.mjs} +333 -51
- package/dist/index.d.mts +239 -178
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/runner.d.mts +246 -169
- package/dist/runner.d.mts.map +1 -1
- package/dist/runner.mjs +2 -2
- package/dist/share-worker.d.mts +10 -3
- package/dist/share-worker.d.mts.map +1 -1
- package/dist/share-worker.mjs +6 -3
- package/dist/share.d.mts +49 -7
- package/dist/share.d.mts.map +1 -1
- package/dist/share.mjs +4 -4
- package/dist/skills/evalkit/SKILL.md +3 -3
- package/dist/skills/evalkit-agents/SKILL.md +5 -3
- package/dist/skills/evalkit-datasets/SKILL.md +5 -5
- package/dist/skills/evalkit-evals/SKILL.md +5 -5
- package/dist/skills/evalkit-judges/SKILL.md +5 -3
- package/dist/skills/evalkit-matrices/SKILL.md +2 -2
- package/dist/skills/evalkit-results/SKILL.md +6 -6
- package/dist/{src-CZnDXP1K.mjs → src-Bn6fnZnF.mjs} +8 -3
- package/dist/{src-b2Wnmzbb.mjs → src-BrfIXfO2.mjs} +75 -54
- package/dist/{src-DhromKNu.mjs → src-CcdLZqFk.mjs} +487 -250
- package/dist/upgrade-60SIRius.mjs +110 -0
- package/package.json +1 -1
- package/dist/dashboard/assets/index-BEBo_81Y.js +0 -34
- package/dist/dashboard/assets/index-C24IquYZ.css +0 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { n as assertNoRemovedOptions } from "./upgrade-60SIRius.mjs";
|
|
1
2
|
import * as Schema from "effect/Schema";
|
|
2
3
|
//#region ../core/src/identity.ts
|
|
3
|
-
const ResourceKindSchema = Schema.Literal("run", "
|
|
4
|
+
const ResourceKindSchema = Schema.Literal("run", "artifact");
|
|
4
5
|
/** Human-authored project-local identifier; never a generated resource URI. */
|
|
5
6
|
function authorId(value) {
|
|
6
7
|
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)) throw new Error(`ID must be lowercase kebab-case: ${value}`);
|
|
@@ -8,7 +9,7 @@ function authorId(value) {
|
|
|
8
9
|
}
|
|
9
10
|
/** RFC 4122 textual UUID. EvalKit accepts v4/v7 and other valid UUID versions. */
|
|
10
11
|
const UuidSchema = Schema.String.pipe(Schema.pattern(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i));
|
|
11
|
-
const ResourceUriSchema = Schema.String.pipe(Schema.pattern(/^evalkit:(run|
|
|
12
|
+
const ResourceUriSchema = Schema.String.pipe(Schema.pattern(/^evalkit:(run|artifact):[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i));
|
|
12
13
|
function resourceUriSchema(kind) {
|
|
13
14
|
return Schema.String.pipe(Schema.pattern(new RegExp(`^evalkit:${kind}:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`, "i")));
|
|
14
15
|
}
|
|
@@ -16,7 +17,7 @@ function resourceUri(kind, uuid) {
|
|
|
16
17
|
return `evalkit:${kind}:${uuid}`;
|
|
17
18
|
}
|
|
18
19
|
function parseResourceUri(value, expectedKind) {
|
|
19
|
-
const match = /^evalkit:(run|
|
|
20
|
+
const match = /^evalkit:(run|artifact):(.+)$/.exec(value);
|
|
20
21
|
if (!match) throw new Error(`Invalid EvalKit resource URI: ${value}`);
|
|
21
22
|
const kind = match[1];
|
|
22
23
|
if (expectedKind && kind !== expectedKind) throw new Error(`Expected an EvalKit ${expectedKind} URI; received ${value}`);
|
|
@@ -101,10 +102,10 @@ function relativeDatasetPath(value, label) {
|
|
|
101
102
|
return parts.length ? parts.join("/") : ".";
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
|
-
* Declares named data that scenarios use: files placed in each
|
|
105
|
+
* Declares named data that scenarios use: files placed in each run's
|
|
105
106
|
* workspace, a value for the agent and scorers, or both. Static datasets give
|
|
106
107
|
* `files`, `value` or `valueFile`; computed datasets give `onLoad` (cached per
|
|
107
|
-
* process) and optionally `onRun` (per
|
|
108
|
+
* process) and optionally `onRun` (per run).
|
|
108
109
|
*/
|
|
109
110
|
function defineDataset(definition) {
|
|
110
111
|
return markDefinitionSite(checkedDataset(definition));
|
|
@@ -219,9 +220,8 @@ function catalogEntry(evaluation, suite, options = {}) {
|
|
|
219
220
|
agent: catalogAgent(evaluation.agent, at),
|
|
220
221
|
...judgeAgent ? { judgeAgent } : {},
|
|
221
222
|
datasets: (evaluation.datasets ?? []).map((dataset) => catalogDataset(dataset, at)),
|
|
222
|
-
|
|
223
|
+
repeat: evaluation.repeat ?? 1,
|
|
223
224
|
policy: {
|
|
224
|
-
trials: policy.trials ?? 1,
|
|
225
225
|
...policy.timeoutMs !== void 0 ? { timeoutMs: policy.timeoutMs } : {},
|
|
226
226
|
...policy.failfast !== void 0 ? { failfast: policy.failfast } : {}
|
|
227
227
|
},
|
|
@@ -317,6 +317,10 @@ function shapeOf(value) {
|
|
|
317
317
|
}
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region ../core/src/config.ts
|
|
320
|
+
const DEFAULT_ATTACHMENT_LIMITS = {
|
|
321
|
+
maxFileBytes: 5e6,
|
|
322
|
+
maxRunBytes: 2e7
|
|
323
|
+
};
|
|
320
324
|
/** Left out of candidate snapshots unless `artifacts.exclude` says otherwise. */
|
|
321
325
|
const DEFAULT_ARTIFACT_EXCLUDE = [
|
|
322
326
|
".git",
|
|
@@ -332,6 +336,18 @@ function defineConfig(configuration) {
|
|
|
332
336
|
return configuration;
|
|
333
337
|
}
|
|
334
338
|
//#endregion
|
|
339
|
+
//#region ../core/src/usage.ts
|
|
340
|
+
/**
|
|
341
|
+
* The tokens a turn counts toward the `tokens` metric: `inputTokens +
|
|
342
|
+
* outputTokens` (cached input included), or `totalTokens` when neither is
|
|
343
|
+
* reported. Undefined when the turn reported no usage.
|
|
344
|
+
*/
|
|
345
|
+
function turnTokens(usage) {
|
|
346
|
+
if (!usage) return void 0;
|
|
347
|
+
if (usage.inputTokens !== void 0 || usage.outputTokens !== void 0) return (usage.inputTokens ?? 0) + (usage.outputTokens ?? 0);
|
|
348
|
+
return usage.totalTokens;
|
|
349
|
+
}
|
|
350
|
+
//#endregion
|
|
335
351
|
//#region ../core/src/canonical-json.ts
|
|
336
352
|
/** Canonical JSON: keys sorted recursively, array order preserved. Rejects non-JSON inputs. */
|
|
337
353
|
function canonicalParameters(value) {
|
|
@@ -556,7 +572,9 @@ function turnResultEvents(result, turn, now) {
|
|
|
556
572
|
//#endregion
|
|
557
573
|
//#region ../core/src/schema.ts
|
|
558
574
|
/** Runtime schemas for serialized EvalKit report and API boundaries. */
|
|
559
|
-
const RunStatusSchema = Schema.Literal("running", "
|
|
575
|
+
const RunStatusSchema = Schema.Literal("running", "passed", "failed", "errored", "cancelled");
|
|
576
|
+
/** The report schema version this EvalKit writes and reads. */
|
|
577
|
+
const REPORT_SCHEMA_VERSION = 6;
|
|
560
578
|
const RecordedErrorSchema = Schema.Struct({
|
|
561
579
|
name: Schema.String,
|
|
562
580
|
message: Schema.String,
|
|
@@ -594,8 +612,19 @@ const RunSourceSchema = Schema.Struct({
|
|
|
594
612
|
url: Schema.optional(Schema.String)
|
|
595
613
|
}))
|
|
596
614
|
});
|
|
615
|
+
const BatchSchema = Schema.Struct({
|
|
616
|
+
id: Schema.String,
|
|
617
|
+
index: Schema.Number,
|
|
618
|
+
size: Schema.Number
|
|
619
|
+
});
|
|
620
|
+
const RunDatasetSchema = Schema.Struct({
|
|
621
|
+
id: Schema.String,
|
|
622
|
+
visibility: Schema.Literal("candidate", "evaluator"),
|
|
623
|
+
source: Schema.Literal("static", "computed"),
|
|
624
|
+
digest: Schema.String
|
|
625
|
+
});
|
|
597
626
|
const RunMetadataSchema = Schema.Struct({
|
|
598
|
-
schemaVersion: Schema.Literal(
|
|
627
|
+
schemaVersion: Schema.Literal(6),
|
|
599
628
|
runUri: resourceUriSchema("run"),
|
|
600
629
|
evalId: Schema.String,
|
|
601
630
|
suiteId: Schema.optional(Schema.String),
|
|
@@ -607,37 +636,21 @@ const RunMetadataSchema = Schema.Struct({
|
|
|
607
636
|
process: Schema.optional(Schema.Struct({
|
|
608
637
|
pid: Schema.Number,
|
|
609
638
|
hostname: Schema.String
|
|
610
|
-
}))
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
trialUri: resourceUriSchema("trial"),
|
|
616
|
-
trialIndex: Schema.Number,
|
|
617
|
-
evalId: Schema.String,
|
|
618
|
-
parameters: Schema.optional(ParametersSchema),
|
|
619
|
-
matrix: Schema.optional(MatrixCellSchema),
|
|
620
|
-
aut: Schema.optional(AutIdentitySchema),
|
|
621
|
-
startedAt: Schema.String,
|
|
622
|
-
datasets: Schema.optional(Schema.mutable(Schema.Array(Schema.Struct({
|
|
623
|
-
id: Schema.String,
|
|
624
|
-
visibility: Schema.Literal("candidate", "evaluator"),
|
|
625
|
-
source: Schema.Literal("static", "computed"),
|
|
626
|
-
digest: Schema.String
|
|
627
|
-
}))))
|
|
639
|
+
})),
|
|
640
|
+
batch: Schema.optional(BatchSchema),
|
|
641
|
+
/** The effective snapshot ignore patterns: the project's, then the scenario's. */
|
|
642
|
+
workspaceIgnore: Schema.optional(Schema.mutable(Schema.Array(Schema.String))),
|
|
643
|
+
datasets: Schema.optional(Schema.mutable(Schema.Array(RunDatasetSchema)))
|
|
628
644
|
});
|
|
629
|
-
/** On-disk manifests include a lifecycle status
|
|
645
|
+
/** On-disk manifests include a lifecycle status. */
|
|
630
646
|
const RunManifestSchema = Schema.Struct({
|
|
631
647
|
...RunMetadataSchema.fields,
|
|
632
648
|
status: Schema.optional(RunStatusSchema)
|
|
633
649
|
});
|
|
634
|
-
const TrialManifestSchema = Schema.Struct({
|
|
635
|
-
...TrialMetadataSchema.fields,
|
|
636
|
-
status: Schema.optional(RunStatusSchema)
|
|
637
|
-
});
|
|
638
650
|
const UsageSchema = Schema.Struct({
|
|
639
651
|
inputTokens: Schema.optional(Schema.Number),
|
|
640
652
|
outputTokens: Schema.optional(Schema.Number),
|
|
653
|
+
cachedInputTokens: Schema.optional(Schema.Number),
|
|
641
654
|
totalTokens: Schema.optional(Schema.Number)
|
|
642
655
|
});
|
|
643
656
|
const JudgeRunInfoSchema = Schema.Struct({
|
|
@@ -687,7 +700,7 @@ const MetricResultSchema = Schema.Struct({
|
|
|
687
700
|
builtIn: Schema.optional(Schema.Literal(true)),
|
|
688
701
|
error: Schema.optional(RecordedErrorSchema)
|
|
689
702
|
});
|
|
690
|
-
const
|
|
703
|
+
const RunScoringSchema = Schema.Struct({
|
|
691
704
|
results: Schema.mutable(Schema.Array(ScoreResultSchema)),
|
|
692
705
|
metrics: Schema.optional(Schema.mutable(Schema.Array(MetricResultSchema))),
|
|
693
706
|
checkpoints: Schema.optional(Schema.mutable(Schema.Array(CheckpointResultSchema))),
|
|
@@ -700,22 +713,18 @@ const ArtifactEntrySchema = Schema.Struct({
|
|
|
700
713
|
kind: Schema.Literal("file", "directory"),
|
|
701
714
|
size: Schema.optional(Schema.Number)
|
|
702
715
|
});
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
scoring: Schema.optional(TrialScoringSchema),
|
|
708
|
-
artifacts: Schema.optional(Schema.mutable(Schema.Array(ArtifactEntrySchema))),
|
|
709
|
-
error: Schema.optional(RecordedErrorSchema)
|
|
716
|
+
const AttachmentEntrySchema = Schema.Struct({
|
|
717
|
+
name: Schema.String,
|
|
718
|
+
size: Schema.Number,
|
|
719
|
+
truncatedFrom: Schema.optional(Schema.Number)
|
|
710
720
|
});
|
|
711
721
|
const RunSummarySchema = Schema.Struct({
|
|
712
722
|
status: RunStatusSchema,
|
|
713
723
|
endedAt: Schema.String,
|
|
714
724
|
durationMs: Schema.optional(Schema.Number),
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
cancelled: Schema.optional(Schema.Number),
|
|
725
|
+
scoring: Schema.optional(RunScoringSchema),
|
|
726
|
+
artifacts: Schema.optional(Schema.mutable(Schema.Array(ArtifactEntrySchema))),
|
|
727
|
+
attachments: Schema.optional(Schema.mutable(Schema.Array(AttachmentEntrySchema))),
|
|
719
728
|
error: Schema.optional(RecordedErrorSchema)
|
|
720
729
|
});
|
|
721
730
|
const autEvent = {
|
|
@@ -775,9 +784,9 @@ const autEvent = {
|
|
|
775
784
|
})
|
|
776
785
|
};
|
|
777
786
|
const runnerEvent = {
|
|
778
|
-
|
|
787
|
+
runStarted: Schema.Struct({
|
|
779
788
|
source: Schema.Literal("runner"),
|
|
780
|
-
kind: Schema.Literal("
|
|
789
|
+
kind: Schema.Literal("run-started"),
|
|
781
790
|
timestamp: Schema.String
|
|
782
791
|
}),
|
|
783
792
|
stepStarted: Schema.Struct({
|
|
@@ -841,9 +850,9 @@ const runnerEvent = {
|
|
|
841
850
|
error: RecordedErrorSchema,
|
|
842
851
|
timestamp: Schema.String
|
|
843
852
|
}),
|
|
844
|
-
|
|
853
|
+
runCompleted: Schema.Struct({
|
|
845
854
|
source: Schema.Literal("runner"),
|
|
846
|
-
kind: Schema.Literal("
|
|
855
|
+
kind: Schema.Literal("run-completed"),
|
|
847
856
|
timestamp: Schema.String
|
|
848
857
|
}),
|
|
849
858
|
error: Schema.Struct({
|
|
@@ -900,7 +909,7 @@ function expectToolCall(expected) {
|
|
|
900
909
|
};
|
|
901
910
|
}
|
|
902
911
|
/**
|
|
903
|
-
* A user message. Pass a function to compute it for each
|
|
912
|
+
* A user message. Pass a function to compute it for each run, e.g. from a
|
|
904
913
|
* matrix axis: `user(({ parameters }) => `Set up OCaml with ${parameters.toolchain}.`)`.
|
|
905
914
|
*/
|
|
906
915
|
function user(message) {
|
|
@@ -916,8 +925,8 @@ function agent(expectation) {
|
|
|
916
925
|
};
|
|
917
926
|
}
|
|
918
927
|
/**
|
|
919
|
-
* Marks a scorer as not applicable to this
|
|
920
|
-
* passes nor fails the
|
|
928
|
+
* Marks a scorer as not applicable to this run. A skipped result neither
|
|
929
|
+
* passes nor fails the run and is left out of score averages.
|
|
921
930
|
*/
|
|
922
931
|
function skip(reason) {
|
|
923
932
|
if (!reason.trim()) throw new Error("skip() needs a reason");
|
|
@@ -926,6 +935,7 @@ function skip(reason) {
|
|
|
926
935
|
reason
|
|
927
936
|
};
|
|
928
937
|
}
|
|
938
|
+
/** A scorer in code. Its `evidence` type carries through to `checkpoint(rule)`. */
|
|
929
939
|
function predicate(name, run, options = {}) {
|
|
930
940
|
if (!name.trim()) throw new Error("Predicate name must not be empty");
|
|
931
941
|
if (options.passAt !== void 0 && !(Number.isFinite(options.passAt) && options.passAt >= 0 && options.passAt <= 1)) throw new Error(`Predicate ${name} passAt must be a number from 0 to 1; received ${options.passAt}`);
|
|
@@ -936,6 +946,7 @@ function predicate(name, run, options = {}) {
|
|
|
936
946
|
...options
|
|
937
947
|
});
|
|
938
948
|
}
|
|
949
|
+
/** A built-in metric's name is a type error here, as well as at definition time. */
|
|
939
950
|
function metric(name, run, options = {}) {
|
|
940
951
|
if (!name.trim()) throw new Error("Metric name must not be empty");
|
|
941
952
|
return markDefinitionSite({
|
|
@@ -955,8 +966,9 @@ function judge(name, options) {
|
|
|
955
966
|
}
|
|
956
967
|
function defineEval(definition) {
|
|
957
968
|
authoringId(definition);
|
|
958
|
-
|
|
969
|
+
assertNoRemovedOptions(definition);
|
|
959
970
|
if (definition.metadata !== void 0) toJsonObject(definition.metadata, `${definition.id}.metadata`);
|
|
971
|
+
for (const [index, pattern] of (definition.workspace?.ignore ?? []).entries()) if (typeof pattern !== "string" || pattern.replace(/^!/, "").trim() === "") throw new Error(`Eval ${definition.id} workspace.ignore[${index}] must be a non-empty glob, got ${JSON.stringify(pattern)}`);
|
|
960
972
|
const datasetIds = /* @__PURE__ */ new Set();
|
|
961
973
|
for (const [index, dataset] of (definition.datasets ?? []).entries()) {
|
|
962
974
|
if (!isDataset(dataset)) throw new Error(`Eval ${definition.id} datasets[${index}] is not a dataset; create it with defineDataset(...)`);
|
|
@@ -1045,7 +1057,16 @@ function registerEvals(registrations) {
|
|
|
1045
1057
|
catalog: (options) => evals.map((evaluation) => catalogEntry(evaluation, suiteIdByEvalId.get(authoringId(evaluation)), options))
|
|
1046
1058
|
};
|
|
1047
1059
|
}
|
|
1048
|
-
/**
|
|
1060
|
+
/**
|
|
1061
|
+
* Metrics EvalKit records for every run; scenario metrics may not reuse
|
|
1062
|
+
* these names.
|
|
1063
|
+
*
|
|
1064
|
+
* - `agent time` (ms): from the run's first event to its last one before
|
|
1065
|
+
* final scoring.
|
|
1066
|
+
* - `tokens`: the sum of `turnTokens(usage)` over the turns that reported
|
|
1067
|
+
* usage, cached input included. Absent when no turn reported any.
|
|
1068
|
+
* - `tool calls`: the agent's `tool-call` events.
|
|
1069
|
+
*/
|
|
1049
1070
|
const BUILT_IN_METRICS = [
|
|
1050
1071
|
"agent time",
|
|
1051
1072
|
"tokens",
|
|
@@ -1063,4 +1084,4 @@ function recordError(error) {
|
|
|
1063
1084
|
};
|
|
1064
1085
|
}
|
|
1065
1086
|
//#endregion
|
|
1066
|
-
export {
|
|
1087
|
+
export { relativeDatasetPath as $, RunManifestSchema as A, turnResultEvents as B, CheckpointResultSchema as C, REPORT_SCHEMA_VERSION as D, MetricResultSchema as E, RunSummarySchema as F, DEFAULT_ATTACHMENT_LIMITS as G, canonicalParameters as H, ScoreResultSchema as I, NotJsonError as J, defineConfig as K, TrajectoryEventSchema as L, RunScoringSchema as M, RunSourceSchema as N, RecordedErrorSchema as O, RunStatusSchema as P, isDataset as Q, UsageSchema as R, BatchSchema as S, JudgeRunInfoSchema as T, turnTokens as U, defineEvalMatrix as V, DEFAULT_ARTIFACT_EXCLUDE as W, toJsonObject as X, toJson as Y, defineDataset as Z, parseTrajectoryJsonl as _, authoringId as a, parseResourceUri as at, AttachmentEntrySchema as b, defineSuite as c, resourceUuid as ct, metric as d, definitionSite as et, predicate as f, user as g, skip as h, agentRuntimes as i, authorId as it, RunMetadataSchema as j, RunDatasetSchema as k, expectToolCall as l, registerEvals as m, DEFAULT_AGENT_RUNTIMES as n, ResourceUriSchema as nt, defineAgent as o, resourceUri as ot, recordError as p, catalogEntry as q, agent as r, UuidSchema as rt, defineEval as s, resourceUriSchema as st, BUILT_IN_METRICS as t, ResourceKindSchema as tt, judge as u, ApiErrorSchema as v, JsonValueSchema as w, AutIdentitySchema as x, ArtifactEntrySchema as y, normalizeAutEvent as z };
|