@leostera/evalkit 0.8.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 +46 -2
- 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 +220 -178
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/runner.d.mts +226 -168
- 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-LeGSyDD2.mjs → src-BrfIXfO2.mjs} +72 -54
- package/dist/{src-mm8L_IxM.mjs → src-CcdLZqFk.mjs} +422 -230
- package/dist/upgrade-60SIRius.mjs +110 -0
- package/package.json +1 -1
- package/dist/dashboard/assets/index-C12IeG2y.css +0 -2
- package/dist/dashboard/assets/index-xlVsW6ZR.js +0 -37
|
@@ -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,39 +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
|
-
const TrialMetadataSchema = Schema.Struct({
|
|
613
|
-
schemaVersion: Schema.Literal(2, 3, 4, 5),
|
|
614
|
-
runUri: resourceUriSchema("run"),
|
|
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,
|
|
639
|
+
})),
|
|
640
|
+
batch: Schema.optional(BatchSchema),
|
|
622
641
|
/** The effective snapshot ignore patterns: the project's, then the scenario's. */
|
|
623
642
|
workspaceIgnore: Schema.optional(Schema.mutable(Schema.Array(Schema.String))),
|
|
624
|
-
datasets: Schema.optional(Schema.mutable(Schema.Array(
|
|
625
|
-
id: Schema.String,
|
|
626
|
-
visibility: Schema.Literal("candidate", "evaluator"),
|
|
627
|
-
source: Schema.Literal("static", "computed"),
|
|
628
|
-
digest: Schema.String
|
|
629
|
-
}))))
|
|
643
|
+
datasets: Schema.optional(Schema.mutable(Schema.Array(RunDatasetSchema)))
|
|
630
644
|
});
|
|
631
|
-
/** On-disk manifests include a lifecycle status
|
|
645
|
+
/** On-disk manifests include a lifecycle status. */
|
|
632
646
|
const RunManifestSchema = Schema.Struct({
|
|
633
647
|
...RunMetadataSchema.fields,
|
|
634
648
|
status: Schema.optional(RunStatusSchema)
|
|
635
649
|
});
|
|
636
|
-
const TrialManifestSchema = Schema.Struct({
|
|
637
|
-
...TrialMetadataSchema.fields,
|
|
638
|
-
status: Schema.optional(RunStatusSchema)
|
|
639
|
-
});
|
|
640
650
|
const UsageSchema = Schema.Struct({
|
|
641
651
|
inputTokens: Schema.optional(Schema.Number),
|
|
642
652
|
outputTokens: Schema.optional(Schema.Number),
|
|
653
|
+
cachedInputTokens: Schema.optional(Schema.Number),
|
|
643
654
|
totalTokens: Schema.optional(Schema.Number)
|
|
644
655
|
});
|
|
645
656
|
const JudgeRunInfoSchema = Schema.Struct({
|
|
@@ -689,7 +700,7 @@ const MetricResultSchema = Schema.Struct({
|
|
|
689
700
|
builtIn: Schema.optional(Schema.Literal(true)),
|
|
690
701
|
error: Schema.optional(RecordedErrorSchema)
|
|
691
702
|
});
|
|
692
|
-
const
|
|
703
|
+
const RunScoringSchema = Schema.Struct({
|
|
693
704
|
results: Schema.mutable(Schema.Array(ScoreResultSchema)),
|
|
694
705
|
metrics: Schema.optional(Schema.mutable(Schema.Array(MetricResultSchema))),
|
|
695
706
|
checkpoints: Schema.optional(Schema.mutable(Schema.Array(CheckpointResultSchema))),
|
|
@@ -702,22 +713,18 @@ const ArtifactEntrySchema = Schema.Struct({
|
|
|
702
713
|
kind: Schema.Literal("file", "directory"),
|
|
703
714
|
size: Schema.optional(Schema.Number)
|
|
704
715
|
});
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
scoring: Schema.optional(TrialScoringSchema),
|
|
710
|
-
artifacts: Schema.optional(Schema.mutable(Schema.Array(ArtifactEntrySchema))),
|
|
711
|
-
error: Schema.optional(RecordedErrorSchema)
|
|
716
|
+
const AttachmentEntrySchema = Schema.Struct({
|
|
717
|
+
name: Schema.String,
|
|
718
|
+
size: Schema.Number,
|
|
719
|
+
truncatedFrom: Schema.optional(Schema.Number)
|
|
712
720
|
});
|
|
713
721
|
const RunSummarySchema = Schema.Struct({
|
|
714
722
|
status: RunStatusSchema,
|
|
715
723
|
endedAt: Schema.String,
|
|
716
724
|
durationMs: Schema.optional(Schema.Number),
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
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))),
|
|
721
728
|
error: Schema.optional(RecordedErrorSchema)
|
|
722
729
|
});
|
|
723
730
|
const autEvent = {
|
|
@@ -777,9 +784,9 @@ const autEvent = {
|
|
|
777
784
|
})
|
|
778
785
|
};
|
|
779
786
|
const runnerEvent = {
|
|
780
|
-
|
|
787
|
+
runStarted: Schema.Struct({
|
|
781
788
|
source: Schema.Literal("runner"),
|
|
782
|
-
kind: Schema.Literal("
|
|
789
|
+
kind: Schema.Literal("run-started"),
|
|
783
790
|
timestamp: Schema.String
|
|
784
791
|
}),
|
|
785
792
|
stepStarted: Schema.Struct({
|
|
@@ -843,9 +850,9 @@ const runnerEvent = {
|
|
|
843
850
|
error: RecordedErrorSchema,
|
|
844
851
|
timestamp: Schema.String
|
|
845
852
|
}),
|
|
846
|
-
|
|
853
|
+
runCompleted: Schema.Struct({
|
|
847
854
|
source: Schema.Literal("runner"),
|
|
848
|
-
kind: Schema.Literal("
|
|
855
|
+
kind: Schema.Literal("run-completed"),
|
|
849
856
|
timestamp: Schema.String
|
|
850
857
|
}),
|
|
851
858
|
error: Schema.Struct({
|
|
@@ -902,7 +909,7 @@ function expectToolCall(expected) {
|
|
|
902
909
|
};
|
|
903
910
|
}
|
|
904
911
|
/**
|
|
905
|
-
* 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
|
|
906
913
|
* matrix axis: `user(({ parameters }) => `Set up OCaml with ${parameters.toolchain}.`)`.
|
|
907
914
|
*/
|
|
908
915
|
function user(message) {
|
|
@@ -918,8 +925,8 @@ function agent(expectation) {
|
|
|
918
925
|
};
|
|
919
926
|
}
|
|
920
927
|
/**
|
|
921
|
-
* Marks a scorer as not applicable to this
|
|
922
|
-
* 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.
|
|
923
930
|
*/
|
|
924
931
|
function skip(reason) {
|
|
925
932
|
if (!reason.trim()) throw new Error("skip() needs a reason");
|
|
@@ -928,6 +935,7 @@ function skip(reason) {
|
|
|
928
935
|
reason
|
|
929
936
|
};
|
|
930
937
|
}
|
|
938
|
+
/** A scorer in code. Its `evidence` type carries through to `checkpoint(rule)`. */
|
|
931
939
|
function predicate(name, run, options = {}) {
|
|
932
940
|
if (!name.trim()) throw new Error("Predicate name must not be empty");
|
|
933
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}`);
|
|
@@ -938,6 +946,7 @@ function predicate(name, run, options = {}) {
|
|
|
938
946
|
...options
|
|
939
947
|
});
|
|
940
948
|
}
|
|
949
|
+
/** A built-in metric's name is a type error here, as well as at definition time. */
|
|
941
950
|
function metric(name, run, options = {}) {
|
|
942
951
|
if (!name.trim()) throw new Error("Metric name must not be empty");
|
|
943
952
|
return markDefinitionSite({
|
|
@@ -957,7 +966,7 @@ function judge(name, options) {
|
|
|
957
966
|
}
|
|
958
967
|
function defineEval(definition) {
|
|
959
968
|
authoringId(definition);
|
|
960
|
-
|
|
969
|
+
assertNoRemovedOptions(definition);
|
|
961
970
|
if (definition.metadata !== void 0) toJsonObject(definition.metadata, `${definition.id}.metadata`);
|
|
962
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)}`);
|
|
963
972
|
const datasetIds = /* @__PURE__ */ new Set();
|
|
@@ -1048,7 +1057,16 @@ function registerEvals(registrations) {
|
|
|
1048
1057
|
catalog: (options) => evals.map((evaluation) => catalogEntry(evaluation, suiteIdByEvalId.get(authoringId(evaluation)), options))
|
|
1049
1058
|
};
|
|
1050
1059
|
}
|
|
1051
|
-
/**
|
|
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
|
+
*/
|
|
1052
1070
|
const BUILT_IN_METRICS = [
|
|
1053
1071
|
"agent time",
|
|
1054
1072
|
"tokens",
|
|
@@ -1066,4 +1084,4 @@ function recordError(error) {
|
|
|
1066
1084
|
};
|
|
1067
1085
|
}
|
|
1068
1086
|
//#endregion
|
|
1069
|
-
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 };
|