@tangle-network/agent-eval 0.80.0 → 0.81.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 +14 -0
- package/README.md +53 -152
- package/dist/adapters/http.d.ts +2 -2
- package/dist/adapters/langchain.d.ts +2 -2
- package/dist/adapters/otel.d.ts +4 -4
- package/dist/{agent-profile-aSEaJ9Pl.d.ts → agent-profile-D0PBIWlV.d.ts} +14 -2
- package/dist/analyst/index.d.ts +10 -10
- package/dist/analyst/index.js +3 -3
- package/dist/{analyst-t7zZS3TV.d.ts → analyst-C8HHvfJp.d.ts} +1 -1
- package/dist/belief-state/index.d.ts +344 -8
- package/dist/belief-state/index.js +1518 -142
- package/dist/belief-state/index.js.map +1 -1
- package/dist/benchmarks/index.d.ts +2 -2
- package/dist/campaign/index.d.ts +40 -120
- package/dist/campaign/index.js +129 -238
- package/dist/campaign/index.js.map +1 -1
- package/dist/{chunk-RPLZ4OIB.js → chunk-BABOZOSN.js} +7 -4
- package/dist/{chunk-RPLZ4OIB.js.map → chunk-BABOZOSN.js.map} +1 -1
- package/dist/{chunk-IHDHUN2X.js → chunk-CVVHBFGN.js} +3 -3
- package/dist/chunk-CVVHBFGN.js.map +1 -0
- package/dist/{chunk-B26KI423.js → chunk-FZWAFVAA.js} +2 -2
- package/dist/{chunk-ITBRCT73.js → chunk-IDVBLYCY.js} +2 -10
- package/dist/chunk-IDVBLYCY.js.map +1 -0
- package/dist/{chunk-5LVWPNS5.js → chunk-L5G7OUKD.js} +4 -4
- package/dist/{chunk-5LVWPNS5.js.map → chunk-L5G7OUKD.js.map} +1 -1
- package/dist/{chunk-GXHLRXDI.js → chunk-OTYQPHPL.js} +4 -4
- package/dist/{chunk-6REHLN5J.js → chunk-QS3RBQPI.js} +2 -2
- package/dist/{chunk-GWGO2K6Y.js → chunk-RBNA5AZT.js} +2 -2
- package/dist/chunk-S42AWHMP.js +697 -0
- package/dist/chunk-S42AWHMP.js.map +1 -0
- package/dist/chunk-VI2UW6B6.js +162 -0
- package/dist/chunk-VI2UW6B6.js.map +1 -0
- package/dist/{chunk-CF67I6QY.js → chunk-VIDQF3F5.js} +2 -2
- package/dist/{chunk-XXNIODOM.js → chunk-WJL2NJXN.js} +3 -3
- package/dist/{chunk-LB2UOI5F.js → chunk-YGYXHNAQ.js} +47 -160
- package/dist/chunk-YGYXHNAQ.js.map +1 -0
- package/dist/{chunk-KX6F6NCG.js → chunk-Z7VFTS2J.js} +2 -2
- package/dist/{chunk-ZPSKPT3V.js → chunk-ZZ2HOPME.js} +5 -2
- package/dist/chunk-ZZ2HOPME.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/code-agent-session-BRXmavYv.d.ts +80 -0
- package/dist/contract/index.d.ts +16 -15
- package/dist/contract/index.js +23 -6
- package/dist/contract/index.js.map +1 -1
- package/dist/{control-CehLtoET.d.ts → control-GeE8OhpN.d.ts} +1 -1
- package/dist/control.d.ts +2 -2
- package/dist/hosted/index.d.ts +4 -4
- package/dist/{index-B1RKber3.d.ts → index-DE3RXAXD.d.ts} +1 -1
- package/dist/index.d.ts +78 -287
- package/dist/index.js +87 -410
- package/dist/index.js.map +1 -1
- package/dist/{insight-report-dlpEzQDi.d.ts → insight-report-3ADTfClO.d.ts} +1 -1
- package/dist/{kind-factory-DqV2t1Xk.d.ts → kind-factory-CVecZZG_.d.ts} +2 -2
- package/dist/{llm-client-DbjLfz-K.d.ts → llm-client-CuUg2Mn3.d.ts} +1 -1
- package/dist/meta-eval/index.d.ts +2 -2
- package/dist/openapi.json +1 -1
- package/dist/pipelines/index.js +2 -2
- package/dist/{provenance-jG-Gngg8.d.ts → provenance-B9Q4886D.d.ts} +4 -4
- package/dist/{registry-BK0Zee01.d.ts → registry-DrEQ3Luj.d.ts} +1 -1
- package/dist/{release-report-CXXZlR8g.d.ts → release-report-hlNtD12q.d.ts} +2 -2
- package/dist/reporting.d.ts +5 -5
- package/dist/reporting.js +3 -3
- package/dist/{researcher-rInLj9De.d.ts → researcher-BLPHBbNV.d.ts} +3 -3
- package/dist/rl.d.ts +7 -7
- package/dist/rl.js +4 -4
- package/dist/{rubric-predictive-validity-CLPuwiUw.d.ts → rubric-predictive-validity-CnEl9Jc8.d.ts} +1 -1
- package/dist/{run-campaign-OVEZF24D.js → run-campaign-4Y5V5CN3.js} +3 -3
- package/dist/{run-improvement-loop-BAl_aVOZ.d.ts → run-improvement-loop-D6PZOoQL.d.ts} +2 -2
- package/dist/{run-record-sItO5ftF.d.ts → run-record-De9VarXR.d.ts} +1 -1
- package/dist/{semantic-concept-judge-qXEUV2w7.d.ts → semantic-concept-judge-DIEgr_6v.d.ts} +6 -6
- package/dist/{statistics-B7yCbi9i.d.ts → statistics-CnC1FMbx.d.ts} +3 -7
- package/dist/{store-GmBE2pZZ.d.ts → store-C1YxJDEK.d.ts} +1 -1
- package/dist/{summary-report-BTaXq1TS.d.ts → summary-report-Db0dDSWP.d.ts} +1 -1
- package/dist/traces.d.ts +5 -5
- package/dist/{types-DRvV0zRo.d.ts → types-Cu3u_x59.d.ts} +3 -3
- package/dist/{types-4mm2msnR.d.ts → types-D7lLRYe9.d.ts} +1 -1
- package/dist/wire/index.js +2 -2
- package/dist/workflow/index.d.ts +7 -7
- package/dist/workflow/index.js +1 -1
- package/docs/concepts.md +1 -0
- package/docs/research/belief-state-agent-eval-roadmap.md +39 -7
- package/docs/self-improvement-map.md +111 -0
- package/package.json +2 -2
- package/dist/chunk-IHDHUN2X.js.map +0 -1
- package/dist/chunk-ITBRCT73.js.map +0 -1
- package/dist/chunk-LB2UOI5F.js.map +0 -1
- package/dist/chunk-ZPSKPT3V.js.map +0 -1
- /package/dist/{chunk-B26KI423.js.map → chunk-FZWAFVAA.js.map} +0 -0
- /package/dist/{chunk-GXHLRXDI.js.map → chunk-OTYQPHPL.js.map} +0 -0
- /package/dist/{chunk-6REHLN5J.js.map → chunk-QS3RBQPI.js.map} +0 -0
- /package/dist/{chunk-GWGO2K6Y.js.map → chunk-RBNA5AZT.js.map} +0 -0
- /package/dist/{chunk-CF67I6QY.js.map → chunk-VIDQF3F5.js.map} +0 -0
- /package/dist/{chunk-XXNIODOM.js.map → chunk-WJL2NJXN.js.map} +0 -0
- /package/dist/{chunk-KX6F6NCG.js.map → chunk-Z7VFTS2J.js.map} +0 -0
- /package/dist/{run-campaign-OVEZF24D.js.map → run-campaign-4Y5V5CN3.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
MODEL_PRICING,
|
|
3
|
-
MetricsCollector,
|
|
4
|
-
TokenCounter,
|
|
5
2
|
agentProfileHash,
|
|
6
3
|
createLlmCorrectnessChecker,
|
|
7
|
-
|
|
8
|
-
estimateTokens,
|
|
4
|
+
createTokenRecallChecker,
|
|
9
5
|
extractProducedState,
|
|
10
|
-
isModelPriced,
|
|
11
6
|
parseCorrectnessResponse,
|
|
12
|
-
resolveModelPricing,
|
|
13
7
|
verifyCompletion
|
|
14
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YGYXHNAQ.js";
|
|
15
9
|
import {
|
|
16
10
|
HoldoutAuditor,
|
|
17
11
|
canaryLeakView,
|
|
@@ -42,12 +36,21 @@ import {
|
|
|
42
36
|
scoreRedTeamOutput,
|
|
43
37
|
surfaceContentHash,
|
|
44
38
|
toolNamesForRun
|
|
45
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-BABOZOSN.js";
|
|
46
40
|
import {
|
|
47
41
|
BackendIntegrityError,
|
|
48
42
|
assertRealBackend,
|
|
49
43
|
summarizeBackendIntegrity
|
|
50
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-ZZ2HOPME.js";
|
|
45
|
+
import {
|
|
46
|
+
MODEL_PRICING,
|
|
47
|
+
MetricsCollector,
|
|
48
|
+
TokenCounter,
|
|
49
|
+
estimateCost,
|
|
50
|
+
estimateTokens,
|
|
51
|
+
isModelPriced,
|
|
52
|
+
resolveModelPricing
|
|
53
|
+
} from "./chunk-VI2UW6B6.js";
|
|
51
54
|
import {
|
|
52
55
|
BENCHMARK_SPLIT_SEED,
|
|
53
56
|
benchmarks_exports,
|
|
@@ -60,7 +63,7 @@ import {
|
|
|
60
63
|
computeToolUseMetrics,
|
|
61
64
|
iqr,
|
|
62
65
|
welchsTTest
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-RBNA5AZT.js";
|
|
64
67
|
import {
|
|
65
68
|
exportTrainingData,
|
|
66
69
|
toNdjson
|
|
@@ -114,7 +117,7 @@ import {
|
|
|
114
117
|
diffFindings,
|
|
115
118
|
resetLockedAppendersForTesting,
|
|
116
119
|
runSemanticConceptJudge
|
|
117
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-L5G7OUKD.js";
|
|
118
121
|
import {
|
|
119
122
|
AnalystRegistry,
|
|
120
123
|
DEFAULT_TRACE_ANALYST_KINDS,
|
|
@@ -126,7 +129,7 @@ import {
|
|
|
126
129
|
createTraceAnalystKind,
|
|
127
130
|
makeFinding,
|
|
128
131
|
renderPriorFindings
|
|
129
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-VIDQF3F5.js";
|
|
130
133
|
import {
|
|
131
134
|
controlFailureClassFromVerification,
|
|
132
135
|
controlRunToRunRecord,
|
|
@@ -152,10 +155,10 @@ import {
|
|
|
152
155
|
evaluateReleaseConfidence,
|
|
153
156
|
judgeReplayGate,
|
|
154
157
|
renderReleaseReport
|
|
155
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-FZWAFVAA.js";
|
|
156
159
|
import {
|
|
157
160
|
runEvalCampaign
|
|
158
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-WJL2NJXN.js";
|
|
159
162
|
import {
|
|
160
163
|
LlmCallError,
|
|
161
164
|
LlmClient,
|
|
@@ -167,7 +170,7 @@ import {
|
|
|
167
170
|
isTransientLlmError,
|
|
168
171
|
probeLlm,
|
|
169
172
|
stripFencedJson
|
|
170
|
-
} from "./chunk-
|
|
173
|
+
} from "./chunk-CVVHBFGN.js";
|
|
171
174
|
import {
|
|
172
175
|
evaluateInterimReleaseConfidence,
|
|
173
176
|
pairedEvalueSequence
|
|
@@ -178,7 +181,7 @@ import {
|
|
|
178
181
|
paretoChart,
|
|
179
182
|
researchReport,
|
|
180
183
|
summaryTable
|
|
181
|
-
} from "./chunk-
|
|
184
|
+
} from "./chunk-Z7VFTS2J.js";
|
|
182
185
|
import {
|
|
183
186
|
benjaminiHochberg,
|
|
184
187
|
bonferroni,
|
|
@@ -205,7 +208,7 @@ import {
|
|
|
205
208
|
weightedComposite,
|
|
206
209
|
weightedMean,
|
|
207
210
|
wilcoxonSignedRank
|
|
208
|
-
} from "./chunk-
|
|
211
|
+
} from "./chunk-IDVBLYCY.js";
|
|
209
212
|
import {
|
|
210
213
|
FileSystemTraceStore,
|
|
211
214
|
InMemoryTraceStore,
|
|
@@ -2895,391 +2898,6 @@ var DualAgentBench = class {
|
|
|
2895
2898
|
}
|
|
2896
2899
|
};
|
|
2897
2900
|
|
|
2898
|
-
// src/experiment-tracker.ts
|
|
2899
|
-
var InMemoryExperimentStore = class {
|
|
2900
|
-
experiments = /* @__PURE__ */ new Map();
|
|
2901
|
-
runs = /* @__PURE__ */ new Map();
|
|
2902
|
-
async saveExperiment(exp) {
|
|
2903
|
-
this.experiments.set(exp.id, { ...exp });
|
|
2904
|
-
}
|
|
2905
|
-
async getExperiment(id) {
|
|
2906
|
-
const e = this.experiments.get(id);
|
|
2907
|
-
return e ? { ...e } : null;
|
|
2908
|
-
}
|
|
2909
|
-
async listExperiments() {
|
|
2910
|
-
return [...this.experiments.values()].sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
2911
|
-
}
|
|
2912
|
-
async saveRun(run) {
|
|
2913
|
-
this.runs.set(run.id, structuredClone(run));
|
|
2914
|
-
}
|
|
2915
|
-
async getRun(id) {
|
|
2916
|
-
const r = this.runs.get(id);
|
|
2917
|
-
return r ? structuredClone(r) : null;
|
|
2918
|
-
}
|
|
2919
|
-
async listRuns(experimentId) {
|
|
2920
|
-
return [...this.runs.values()].filter((r) => r.experimentId === experimentId).sort((a, b) => b.startedAt.localeCompare(a.startedAt)).map((r) => structuredClone(r));
|
|
2921
|
-
}
|
|
2922
|
-
};
|
|
2923
|
-
var ExperimentTracker = class {
|
|
2924
|
-
constructor(store) {
|
|
2925
|
-
this.store = store;
|
|
2926
|
-
}
|
|
2927
|
-
store;
|
|
2928
|
-
async startExperiment(name, metadata) {
|
|
2929
|
-
const exp = {
|
|
2930
|
-
id: `exp_${rand(8)}`,
|
|
2931
|
-
name,
|
|
2932
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2933
|
-
metadata
|
|
2934
|
-
};
|
|
2935
|
-
await this.store.saveExperiment(exp);
|
|
2936
|
-
return exp;
|
|
2937
|
-
}
|
|
2938
|
-
async startRun(config) {
|
|
2939
|
-
const exp = await this.store.getExperiment(config.experimentId);
|
|
2940
|
-
if (!exp) throw new Error(`Experiment ${config.experimentId} not found`);
|
|
2941
|
-
const run = {
|
|
2942
|
-
id: `run_${rand(10)}`,
|
|
2943
|
-
experimentId: config.experimentId,
|
|
2944
|
-
name: config.name,
|
|
2945
|
-
config,
|
|
2946
|
-
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2947
|
-
status: "running"
|
|
2948
|
-
};
|
|
2949
|
-
await this.store.saveRun(run);
|
|
2950
|
-
return run;
|
|
2951
|
-
}
|
|
2952
|
-
async completeRun(runId, report) {
|
|
2953
|
-
const run = await this.store.getRun(runId);
|
|
2954
|
-
if (!run) throw new Error(`Run ${runId} not found`);
|
|
2955
|
-
run.status = "completed";
|
|
2956
|
-
run.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2957
|
-
run.report = report;
|
|
2958
|
-
await this.store.saveRun(run);
|
|
2959
|
-
}
|
|
2960
|
-
async failRun(runId, error) {
|
|
2961
|
-
const run = await this.store.getRun(runId);
|
|
2962
|
-
if (!run) throw new Error(`Run ${runId} not found`);
|
|
2963
|
-
run.status = "failed";
|
|
2964
|
-
run.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2965
|
-
run.error = error;
|
|
2966
|
-
await this.store.saveRun(run);
|
|
2967
|
-
}
|
|
2968
|
-
/**
|
|
2969
|
-
* Diff two completed runs. Returns per-scenario deltas, aggregate delta,
|
|
2970
|
-
* and config changes that may explain the movement.
|
|
2971
|
-
*/
|
|
2972
|
-
async diff(runIdA, runIdB) {
|
|
2973
|
-
const [a, b] = await Promise.all([this.store.getRun(runIdA), this.store.getRun(runIdB)]);
|
|
2974
|
-
if (!a || !b) throw new Error("Both runs must exist");
|
|
2975
|
-
if (!a.report || !b.report) throw new Error("Both runs must be completed with reports");
|
|
2976
|
-
const byScenarioA = new Map(a.report.results.map((r) => [r.scenarioId, r.overallScore]));
|
|
2977
|
-
const byScenarioB = new Map(b.report.results.map((r) => [r.scenarioId, r.overallScore]));
|
|
2978
|
-
const scenarioIds = /* @__PURE__ */ new Set([...byScenarioA.keys(), ...byScenarioB.keys()]);
|
|
2979
|
-
const scenarios = [];
|
|
2980
|
-
for (const id of scenarioIds) {
|
|
2981
|
-
const aScore = byScenarioA.get(id);
|
|
2982
|
-
const bScore = byScenarioB.get(id);
|
|
2983
|
-
if (aScore === void 0) {
|
|
2984
|
-
scenarios.push({
|
|
2985
|
-
scenarioId: id,
|
|
2986
|
-
before: null,
|
|
2987
|
-
after: bScore,
|
|
2988
|
-
delta: null,
|
|
2989
|
-
status: "added"
|
|
2990
|
-
});
|
|
2991
|
-
} else if (bScore === void 0) {
|
|
2992
|
-
scenarios.push({
|
|
2993
|
-
scenarioId: id,
|
|
2994
|
-
before: aScore,
|
|
2995
|
-
after: null,
|
|
2996
|
-
delta: null,
|
|
2997
|
-
status: "removed"
|
|
2998
|
-
});
|
|
2999
|
-
} else {
|
|
3000
|
-
scenarios.push({
|
|
3001
|
-
scenarioId: id,
|
|
3002
|
-
before: aScore,
|
|
3003
|
-
after: bScore,
|
|
3004
|
-
delta: bScore - aScore,
|
|
3005
|
-
status: bScore > aScore ? "improved" : bScore < aScore ? "regressed" : "unchanged"
|
|
3006
|
-
});
|
|
3007
|
-
}
|
|
3008
|
-
}
|
|
3009
|
-
scenarios.sort((x, y) => (y.delta ?? 0) - (x.delta ?? 0));
|
|
3010
|
-
const aggregateDelta = b.report.summary.overallAvg - a.report.summary.overallAvg;
|
|
3011
|
-
const configChanges = {};
|
|
3012
|
-
const keys = /* @__PURE__ */ new Set([...Object.keys(a.config), ...Object.keys(b.config)]);
|
|
3013
|
-
const aCfg = a.config;
|
|
3014
|
-
const bCfg = b.config;
|
|
3015
|
-
for (const k of keys) {
|
|
3016
|
-
if (JSON.stringify(aCfg[k]) !== JSON.stringify(bCfg[k])) {
|
|
3017
|
-
configChanges[k] = { before: aCfg[k], after: bCfg[k] };
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
return {
|
|
3021
|
-
before: { runId: runIdA, name: a.name, startedAt: a.startedAt },
|
|
3022
|
-
after: { runId: runIdB, name: b.name, startedAt: b.startedAt },
|
|
3023
|
-
aggregateDelta,
|
|
3024
|
-
scenarios,
|
|
3025
|
-
configChanges
|
|
3026
|
-
};
|
|
3027
|
-
}
|
|
3028
|
-
/** Timeline of aggregate scores for an experiment. */
|
|
3029
|
-
async timeline(experimentId) {
|
|
3030
|
-
const runs = await this.store.listRuns(experimentId);
|
|
3031
|
-
return runs.slice().sort((a, b) => a.startedAt.localeCompare(b.startedAt)).map((r) => ({
|
|
3032
|
-
runId: r.id,
|
|
3033
|
-
startedAt: r.startedAt,
|
|
3034
|
-
overall: r.report?.summary.overallAvg ?? null
|
|
3035
|
-
}));
|
|
3036
|
-
}
|
|
3037
|
-
};
|
|
3038
|
-
function rand(bytes) {
|
|
3039
|
-
const arr = new Uint8Array(bytes);
|
|
3040
|
-
crypto.getRandomValues(arr);
|
|
3041
|
-
return Array.from(arr).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3042
|
-
}
|
|
3043
|
-
|
|
3044
|
-
// src/experiment-tracker-d1.ts
|
|
3045
|
-
var SCHEMA_VERSION = 1;
|
|
3046
|
-
var D1ExperimentStore = class {
|
|
3047
|
-
db;
|
|
3048
|
-
experimentsTable;
|
|
3049
|
-
runsTable;
|
|
3050
|
-
metaTable;
|
|
3051
|
-
schemaReady = false;
|
|
3052
|
-
constructor(options) {
|
|
3053
|
-
this.db = options.db;
|
|
3054
|
-
const prefix = options.tablePrefix ?? "agent_eval_";
|
|
3055
|
-
this.experimentsTable = `${prefix}experiments`;
|
|
3056
|
-
this.runsTable = `${prefix}runs`;
|
|
3057
|
-
this.metaTable = `${prefix}meta`;
|
|
3058
|
-
}
|
|
3059
|
-
/**
|
|
3060
|
-
* Idempotent schema setup. Safe to call before every operation; the second
|
|
3061
|
-
* call short-circuits via `schemaReady`. Most consumers will call it once
|
|
3062
|
-
* during Worker bootstrap.
|
|
3063
|
-
*/
|
|
3064
|
-
async ensureSchema() {
|
|
3065
|
-
if (this.schemaReady) return;
|
|
3066
|
-
const ddl = `
|
|
3067
|
-
CREATE TABLE IF NOT EXISTS ${this.experimentsTable} (
|
|
3068
|
-
id TEXT PRIMARY KEY,
|
|
3069
|
-
name TEXT NOT NULL,
|
|
3070
|
-
created_at TEXT NOT NULL,
|
|
3071
|
-
metadata_json TEXT
|
|
3072
|
-
);
|
|
3073
|
-
CREATE TABLE IF NOT EXISTS ${this.runsTable} (
|
|
3074
|
-
id TEXT PRIMARY KEY,
|
|
3075
|
-
experiment_id TEXT NOT NULL,
|
|
3076
|
-
name TEXT,
|
|
3077
|
-
status TEXT NOT NULL,
|
|
3078
|
-
started_at TEXT NOT NULL,
|
|
3079
|
-
completed_at TEXT,
|
|
3080
|
-
config_json TEXT NOT NULL,
|
|
3081
|
-
report_json TEXT,
|
|
3082
|
-
error TEXT
|
|
3083
|
-
);
|
|
3084
|
-
CREATE INDEX IF NOT EXISTS idx_${this.runsTable}_experiment ON ${this.runsTable}(experiment_id);
|
|
3085
|
-
CREATE INDEX IF NOT EXISTS idx_${this.runsTable}_started ON ${this.runsTable}(started_at);
|
|
3086
|
-
CREATE TABLE IF NOT EXISTS ${this.metaTable} (
|
|
3087
|
-
key TEXT PRIMARY KEY,
|
|
3088
|
-
value TEXT NOT NULL
|
|
3089
|
-
);
|
|
3090
|
-
INSERT OR REPLACE INTO ${this.metaTable}(key, value) VALUES ('schema_version', '${SCHEMA_VERSION}');
|
|
3091
|
-
`;
|
|
3092
|
-
await this.db.exec(ddl.trim().replace(/\s+/g, " "));
|
|
3093
|
-
this.schemaReady = true;
|
|
3094
|
-
}
|
|
3095
|
-
async saveExperiment(exp) {
|
|
3096
|
-
await this.ensureSchema();
|
|
3097
|
-
await this.db.prepare(
|
|
3098
|
-
`INSERT INTO ${this.experimentsTable}(id, name, created_at, metadata_json)
|
|
3099
|
-
VALUES (?1, ?2, ?3, ?4)
|
|
3100
|
-
ON CONFLICT(id) DO UPDATE SET
|
|
3101
|
-
name = excluded.name,
|
|
3102
|
-
created_at = excluded.created_at,
|
|
3103
|
-
metadata_json = excluded.metadata_json`
|
|
3104
|
-
).bind(exp.id, exp.name, exp.createdAt, exp.metadata ? JSON.stringify(exp.metadata) : null).run();
|
|
3105
|
-
}
|
|
3106
|
-
async getExperiment(id) {
|
|
3107
|
-
await this.ensureSchema();
|
|
3108
|
-
const row = await this.db.prepare(
|
|
3109
|
-
`SELECT id, name, created_at, metadata_json
|
|
3110
|
-
FROM ${this.experimentsTable}
|
|
3111
|
-
WHERE id = ?1`
|
|
3112
|
-
).bind(id).first();
|
|
3113
|
-
return row ? rowToExperiment(row) : null;
|
|
3114
|
-
}
|
|
3115
|
-
async listExperiments() {
|
|
3116
|
-
await this.ensureSchema();
|
|
3117
|
-
const { results } = await this.db.prepare(
|
|
3118
|
-
`SELECT id, name, created_at, metadata_json
|
|
3119
|
-
FROM ${this.experimentsTable}
|
|
3120
|
-
ORDER BY created_at DESC`
|
|
3121
|
-
).all();
|
|
3122
|
-
return results.map(rowToExperiment);
|
|
3123
|
-
}
|
|
3124
|
-
async saveRun(run) {
|
|
3125
|
-
await this.ensureSchema();
|
|
3126
|
-
await this.db.prepare(
|
|
3127
|
-
`INSERT INTO ${this.runsTable}(id, experiment_id, name, status, started_at, completed_at, config_json, report_json, error)
|
|
3128
|
-
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)
|
|
3129
|
-
ON CONFLICT(id) DO UPDATE SET
|
|
3130
|
-
experiment_id = excluded.experiment_id,
|
|
3131
|
-
name = excluded.name,
|
|
3132
|
-
status = excluded.status,
|
|
3133
|
-
started_at = excluded.started_at,
|
|
3134
|
-
completed_at = excluded.completed_at,
|
|
3135
|
-
config_json = excluded.config_json,
|
|
3136
|
-
report_json = excluded.report_json,
|
|
3137
|
-
error = excluded.error`
|
|
3138
|
-
).bind(
|
|
3139
|
-
run.id,
|
|
3140
|
-
run.experimentId,
|
|
3141
|
-
run.name ?? null,
|
|
3142
|
-
run.status,
|
|
3143
|
-
run.startedAt,
|
|
3144
|
-
run.completedAt ?? null,
|
|
3145
|
-
JSON.stringify(run.config),
|
|
3146
|
-
run.report ? JSON.stringify(run.report) : null,
|
|
3147
|
-
run.error ?? null
|
|
3148
|
-
).run();
|
|
3149
|
-
}
|
|
3150
|
-
async getRun(id) {
|
|
3151
|
-
await this.ensureSchema();
|
|
3152
|
-
const row = await this.db.prepare(
|
|
3153
|
-
`SELECT id, experiment_id, name, status, started_at, completed_at, config_json, report_json, error
|
|
3154
|
-
FROM ${this.runsTable}
|
|
3155
|
-
WHERE id = ?1`
|
|
3156
|
-
).bind(id).first();
|
|
3157
|
-
return row ? rowToRun(row) : null;
|
|
3158
|
-
}
|
|
3159
|
-
async listRuns(experimentId) {
|
|
3160
|
-
await this.ensureSchema();
|
|
3161
|
-
const { results } = await this.db.prepare(
|
|
3162
|
-
`SELECT id, experiment_id, name, status, started_at, completed_at, config_json, report_json, error
|
|
3163
|
-
FROM ${this.runsTable}
|
|
3164
|
-
WHERE experiment_id = ?1
|
|
3165
|
-
ORDER BY started_at DESC`
|
|
3166
|
-
).bind(experimentId).all();
|
|
3167
|
-
return results.map(rowToRun);
|
|
3168
|
-
}
|
|
3169
|
-
};
|
|
3170
|
-
function rowToExperiment(row) {
|
|
3171
|
-
return {
|
|
3172
|
-
id: row.id,
|
|
3173
|
-
name: row.name,
|
|
3174
|
-
createdAt: row.created_at,
|
|
3175
|
-
...row.metadata_json ? { metadata: JSON.parse(row.metadata_json) } : {}
|
|
3176
|
-
};
|
|
3177
|
-
}
|
|
3178
|
-
function rowToRun(row) {
|
|
3179
|
-
return {
|
|
3180
|
-
id: row.id,
|
|
3181
|
-
experimentId: row.experiment_id,
|
|
3182
|
-
...row.name ? { name: row.name } : {},
|
|
3183
|
-
status: row.status,
|
|
3184
|
-
startedAt: row.started_at,
|
|
3185
|
-
...row.completed_at ? { completedAt: row.completed_at } : {},
|
|
3186
|
-
config: JSON.parse(row.config_json),
|
|
3187
|
-
...row.report_json ? { report: JSON.parse(row.report_json) } : {},
|
|
3188
|
-
...row.error ? { error: row.error } : {}
|
|
3189
|
-
};
|
|
3190
|
-
}
|
|
3191
|
-
|
|
3192
|
-
// src/experiment-tracker-fs.ts
|
|
3193
|
-
var FileSystemExperimentStore = class {
|
|
3194
|
-
dir;
|
|
3195
|
-
maxBytes;
|
|
3196
|
-
index;
|
|
3197
|
-
loaded = false;
|
|
3198
|
-
constructor(options) {
|
|
3199
|
-
this.dir = options.dir;
|
|
3200
|
-
this.maxBytes = options.maxBytes ?? 32 * 1024 * 1024;
|
|
3201
|
-
}
|
|
3202
|
-
async saveExperiment(exp) {
|
|
3203
|
-
const idx = await this.load();
|
|
3204
|
-
await idx.saveExperiment(exp);
|
|
3205
|
-
await this.append("experiments", exp);
|
|
3206
|
-
}
|
|
3207
|
-
async getExperiment(id) {
|
|
3208
|
-
const idx = await this.load();
|
|
3209
|
-
return idx.getExperiment(id);
|
|
3210
|
-
}
|
|
3211
|
-
async listExperiments() {
|
|
3212
|
-
const idx = await this.load();
|
|
3213
|
-
return idx.listExperiments();
|
|
3214
|
-
}
|
|
3215
|
-
async saveRun(run) {
|
|
3216
|
-
const idx = await this.load();
|
|
3217
|
-
await idx.saveRun(run);
|
|
3218
|
-
await this.append("runs", run);
|
|
3219
|
-
}
|
|
3220
|
-
async getRun(id) {
|
|
3221
|
-
const idx = await this.load();
|
|
3222
|
-
return idx.getRun(id);
|
|
3223
|
-
}
|
|
3224
|
-
async listRuns(experimentId) {
|
|
3225
|
-
const idx = await this.load();
|
|
3226
|
-
return idx.listRuns(experimentId);
|
|
3227
|
-
}
|
|
3228
|
-
async ensureDir() {
|
|
3229
|
-
const fs2 = await import("fs/promises");
|
|
3230
|
-
await fs2.mkdir(this.dir, { recursive: true });
|
|
3231
|
-
}
|
|
3232
|
-
async append(name, record) {
|
|
3233
|
-
await this.ensureDir();
|
|
3234
|
-
const fs2 = await import("fs/promises");
|
|
3235
|
-
const path = await import("path");
|
|
3236
|
-
const active = path.join(this.dir, `${name}.ndjson`);
|
|
3237
|
-
try {
|
|
3238
|
-
const stat = await fs2.stat(active);
|
|
3239
|
-
if (stat.size >= this.maxBytes) {
|
|
3240
|
-
const rolled = path.join(this.dir, `${name}.${Date.now()}.ndjson`);
|
|
3241
|
-
await fs2.rename(active, rolled);
|
|
3242
|
-
}
|
|
3243
|
-
} catch {
|
|
3244
|
-
}
|
|
3245
|
-
await fs2.appendFile(active, `${JSON.stringify(record)}
|
|
3246
|
-
`, "utf8");
|
|
3247
|
-
}
|
|
3248
|
-
async load() {
|
|
3249
|
-
if (this.loaded && this.index) return this.index;
|
|
3250
|
-
const fs2 = await import("fs/promises");
|
|
3251
|
-
const path = await import("path");
|
|
3252
|
-
const store = new InMemoryExperimentStore();
|
|
3253
|
-
try {
|
|
3254
|
-
const entries = await fs2.readdir(this.dir);
|
|
3255
|
-
const sorted = entries.filter((f) => f.endsWith(".ndjson")).sort((a, b) => a.localeCompare(b));
|
|
3256
|
-
for (const file of sorted) {
|
|
3257
|
-
const full = path.join(this.dir, file);
|
|
3258
|
-
const content = await fs2.readFile(full, "utf8");
|
|
3259
|
-
const base = file.split(".")[0];
|
|
3260
|
-
for (const line of content.split("\n")) {
|
|
3261
|
-
if (!line.trim()) continue;
|
|
3262
|
-
let record;
|
|
3263
|
-
try {
|
|
3264
|
-
record = JSON.parse(line);
|
|
3265
|
-
} catch {
|
|
3266
|
-
continue;
|
|
3267
|
-
}
|
|
3268
|
-
if (base === "experiments") {
|
|
3269
|
-
await store.saveExperiment(record);
|
|
3270
|
-
} else if (base === "runs") {
|
|
3271
|
-
await store.saveRun(record);
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
} catch {
|
|
3276
|
-
}
|
|
3277
|
-
this.index = store;
|
|
3278
|
-
this.loaded = true;
|
|
3279
|
-
return store;
|
|
3280
|
-
}
|
|
3281
|
-
};
|
|
3282
|
-
|
|
3283
2901
|
// src/harness-optimizer.ts
|
|
3284
2902
|
var DEFAULT_HARNESS_OBJECTIVES = [
|
|
3285
2903
|
{ name: "aggregate", direction: "maximize", value: (r) => r.aggregateMean },
|
|
@@ -3387,6 +3005,67 @@ function meanRunScore(scores2) {
|
|
|
3387
3005
|
};
|
|
3388
3006
|
}
|
|
3389
3007
|
|
|
3008
|
+
// src/judge-ensemble.ts
|
|
3009
|
+
function aggregateJudgeVerdicts(verdicts, dimensionKeys, weights) {
|
|
3010
|
+
if (verdicts.length === 0) {
|
|
3011
|
+
throw new Error("aggregateJudgeVerdicts: no verdicts to aggregate");
|
|
3012
|
+
}
|
|
3013
|
+
if (dimensionKeys.length === 0) {
|
|
3014
|
+
throw new Error("aggregateJudgeVerdicts: dimensionKeys is empty");
|
|
3015
|
+
}
|
|
3016
|
+
const perJudge = {};
|
|
3017
|
+
const failedJudges = [];
|
|
3018
|
+
const dimAcc = {};
|
|
3019
|
+
for (const d of dimensionKeys) dimAcc[d] = [];
|
|
3020
|
+
let rationale = "";
|
|
3021
|
+
let costUsd = 0;
|
|
3022
|
+
for (const v of verdicts) {
|
|
3023
|
+
costUsd += v.costUsd ?? 0;
|
|
3024
|
+
if (!v.perDimension) {
|
|
3025
|
+
failedJudges.push(v.model);
|
|
3026
|
+
continue;
|
|
3027
|
+
}
|
|
3028
|
+
const dims = {};
|
|
3029
|
+
for (const d of dimensionKeys) dims[d] = clamp01(Number(v.perDimension[d]));
|
|
3030
|
+
perJudge[v.model] = dims;
|
|
3031
|
+
for (const d of dimensionKeys) dimAcc[d].push(dims[d]);
|
|
3032
|
+
if (!rationale && typeof v.rationale === "string" && v.rationale) rationale = v.rationale;
|
|
3033
|
+
}
|
|
3034
|
+
if (failedJudges.length === verdicts.length) {
|
|
3035
|
+
throw new Error(`aggregateJudgeVerdicts: all ${verdicts.length} judges failed`);
|
|
3036
|
+
}
|
|
3037
|
+
const perDimension = {};
|
|
3038
|
+
for (const d of dimensionKeys) {
|
|
3039
|
+
const vals = dimAcc[d];
|
|
3040
|
+
perDimension[d] = vals.length === 0 ? 0 : vals.reduce((s, x) => s + x, 0) / vals.length;
|
|
3041
|
+
}
|
|
3042
|
+
let maxDisagreement = 0;
|
|
3043
|
+
for (const d of dimensionKeys) {
|
|
3044
|
+
const vals = dimAcc[d];
|
|
3045
|
+
if (vals.length < 2) continue;
|
|
3046
|
+
const spread = Math.max(...vals) - Math.min(...vals);
|
|
3047
|
+
if (spread > maxDisagreement) maxDisagreement = spread;
|
|
3048
|
+
}
|
|
3049
|
+
const w = {};
|
|
3050
|
+
if (weights) {
|
|
3051
|
+
for (const [d, weight] of Object.entries(weights)) {
|
|
3052
|
+
if (weight !== void 0) w[d] = weight;
|
|
3053
|
+
}
|
|
3054
|
+
} else {
|
|
3055
|
+
for (const d of dimensionKeys) w[d] = 1 / dimensionKeys.length;
|
|
3056
|
+
}
|
|
3057
|
+
const composite = weightedComposite({ dims: perDimension, weights: w }).composite;
|
|
3058
|
+
return {
|
|
3059
|
+
perDimension,
|
|
3060
|
+
composite,
|
|
3061
|
+
perJudge,
|
|
3062
|
+
maxDisagreement,
|
|
3063
|
+
failedJudges,
|
|
3064
|
+
costUsd,
|
|
3065
|
+
rationale: rationale || "llm-judge"
|
|
3066
|
+
};
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3390
3069
|
// src/judge-runner.ts
|
|
3391
3070
|
var JudgeRunner = class {
|
|
3392
3071
|
driver;
|
|
@@ -6208,7 +5887,7 @@ function flowLayer(input) {
|
|
|
6208
5887
|
// src/intent-match-judge.ts
|
|
6209
5888
|
var INTENT_MATCH_JUDGE_VERSION = "intent-match-judge-v1-2026-04-24";
|
|
6210
5889
|
var DEFAULT_MODEL = "claude-sonnet-4-6";
|
|
6211
|
-
var DEFAULT_TIMEOUT =
|
|
5890
|
+
var DEFAULT_TIMEOUT = 3e5;
|
|
6212
5891
|
var DEFAULT_MAX_SOURCE = 25e3;
|
|
6213
5892
|
var DEFAULT_MAX_PER_FILE = 12e3;
|
|
6214
5893
|
var DEFAULT_MAX_HTML = 2e4;
|
|
@@ -7364,7 +7043,7 @@ function createDefaultReviewer(options) {
|
|
|
7364
7043
|
...options.softFailDefaults ?? {}
|
|
7365
7044
|
};
|
|
7366
7045
|
const promptBuilder = options.promptBuilder ?? buildReviewerPrompt;
|
|
7367
|
-
const timeoutMs = options.timeoutMs ??
|
|
7046
|
+
const timeoutMs = options.timeoutMs ?? 3e5;
|
|
7368
7047
|
return async (input) => {
|
|
7369
7048
|
const start = Date.now();
|
|
7370
7049
|
const { system, user } = promptBuilder(input);
|
|
@@ -7718,7 +7397,7 @@ function fmt(x) {
|
|
|
7718
7397
|
|
|
7719
7398
|
// src/judge-retry.ts
|
|
7720
7399
|
var DEFAULT_MAX_ATTEMPTS = 3;
|
|
7721
|
-
var DEFAULT_TIMEOUT_MS =
|
|
7400
|
+
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
7722
7401
|
function sleep(ms) {
|
|
7723
7402
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7724
7403
|
}
|
|
@@ -8620,7 +8299,6 @@ export {
|
|
|
8620
8299
|
ConvergenceTracker,
|
|
8621
8300
|
CostTracker,
|
|
8622
8301
|
CrossFamilyError,
|
|
8623
|
-
D1ExperimentStore,
|
|
8624
8302
|
DEFAULT_AGENT_SLOS,
|
|
8625
8303
|
DEFAULT_COMPLEXITY_WEIGHTS,
|
|
8626
8304
|
DEFAULT_RULES as DEFAULT_FAILURE_RULES,
|
|
@@ -8639,10 +8317,8 @@ export {
|
|
|
8639
8317
|
DockerSandboxDriver,
|
|
8640
8318
|
DualAgentBench,
|
|
8641
8319
|
ERROR_COUNT_PATTERNS,
|
|
8642
|
-
ExperimentTracker,
|
|
8643
8320
|
FAILURE_CLASSES,
|
|
8644
8321
|
FAILURE_MODE_KIND_SPEC,
|
|
8645
|
-
FileSystemExperimentStore,
|
|
8646
8322
|
FileSystemFeedbackTrajectoryStore,
|
|
8647
8323
|
FileSystemRawProviderSink,
|
|
8648
8324
|
FileSystemTraceStore,
|
|
@@ -8652,7 +8328,6 @@ export {
|
|
|
8652
8328
|
HoldoutLockedError,
|
|
8653
8329
|
IMPROVEMENT_KIND_SPEC,
|
|
8654
8330
|
INTENT_MATCH_JUDGE_VERSION,
|
|
8655
|
-
InMemoryExperimentStore,
|
|
8656
8331
|
InMemoryFeedbackTrajectoryStore,
|
|
8657
8332
|
InMemoryRawProviderSink,
|
|
8658
8333
|
InMemoryTraceStore,
|
|
@@ -8712,6 +8387,7 @@ export {
|
|
|
8712
8387
|
agentProfileCellHashMaterial,
|
|
8713
8388
|
agentProfileCellKey,
|
|
8714
8389
|
agentProfileHash,
|
|
8390
|
+
aggregateJudgeVerdicts,
|
|
8715
8391
|
aggregateLlm,
|
|
8716
8392
|
aggregatePrReviewScore,
|
|
8717
8393
|
aggregateRunScore,
|
|
@@ -8805,6 +8481,7 @@ export {
|
|
|
8805
8481
|
createReplayFetch,
|
|
8806
8482
|
createSandboxPool,
|
|
8807
8483
|
createSemanticConceptJudge,
|
|
8484
|
+
createTokenRecallChecker,
|
|
8808
8485
|
createTraceAnalystKind,
|
|
8809
8486
|
crossTraceDiff,
|
|
8810
8487
|
crowdingDistance,
|