raindrop-ai 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/dist/evals/cli.js CHANGED
@@ -12,10 +12,6 @@ var __esm = (fn, res) => function __init() {
12
12
  var __commonJS = (cb, mod) => function __require() {
13
13
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
14
  };
15
- var __export = (target, all) => {
16
- for (var name in all)
17
- __defProp(target, name, { get: all[name], enumerable: true });
18
- };
19
15
  var __copyProps = (to, from, except, desc) => {
20
16
  if (from && typeof from === "object" || typeof from === "function") {
21
17
  for (let key of __getOwnPropNames(from))
@@ -723,11 +719,11 @@ var require_lodash = __commonJS({
723
719
  function unicodeWords(string) {
724
720
  return string.match(reUnicodeWord) || [];
725
721
  }
726
- var runInContext = (function runInContext2(context9) {
727
- context9 = context9 == null ? root : _.defaults(root.Object(), context9, _.pick(root, contextProps));
728
- var Array2 = context9.Array, Date2 = context9.Date, Error2 = context9.Error, Function2 = context9.Function, Math2 = context9.Math, Object2 = context9.Object, RegExp2 = context9.RegExp, String2 = context9.String, TypeError2 = context9.TypeError;
722
+ var runInContext = (function runInContext2(context8) {
723
+ context8 = context8 == null ? root : _.defaults(root.Object(), context8, _.pick(root, contextProps));
724
+ var Array2 = context8.Array, Date2 = context8.Date, Error2 = context8.Error, Function2 = context8.Function, Math2 = context8.Math, Object2 = context8.Object, RegExp2 = context8.RegExp, String2 = context8.String, TypeError2 = context8.TypeError;
729
725
  var arrayProto = Array2.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
730
- var coreJsData = context9["__core-js_shared__"];
726
+ var coreJsData = context8["__core-js_shared__"];
731
727
  var funcToString = funcProto.toString;
732
728
  var hasOwnProperty = objectProto.hasOwnProperty;
733
729
  var idCounter = 0;
@@ -741,7 +737,7 @@ var require_lodash = __commonJS({
741
737
  var reIsNative = RegExp2(
742
738
  "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
743
739
  );
744
- var Buffer2 = moduleExports ? context9.Buffer : undefined2, Symbol2 = context9.Symbol, Uint8Array2 = context9.Uint8Array, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : undefined2, getPrototype = overArg(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined2, symIterator = Symbol2 ? Symbol2.iterator : undefined2, symToStringTag = Symbol2 ? Symbol2.toStringTag : undefined2;
740
+ var Buffer2 = moduleExports ? context8.Buffer : undefined2, Symbol2 = context8.Symbol, Uint8Array2 = context8.Uint8Array, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : undefined2, getPrototype = overArg(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : undefined2, symIterator = Symbol2 ? Symbol2.iterator : undefined2, symToStringTag = Symbol2 ? Symbol2.toStringTag : undefined2;
745
741
  var defineProperty = (function() {
746
742
  try {
747
743
  var func = getNative(Object2, "defineProperty");
@@ -750,9 +746,9 @@ var require_lodash = __commonJS({
750
746
  } catch (e) {
751
747
  }
752
748
  })();
753
- var ctxClearTimeout = context9.clearTimeout !== root.clearTimeout && context9.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context9.setTimeout !== root.setTimeout && context9.setTimeout;
754
- var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite = context9.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context9.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
755
- var DataView = getNative(context9, "DataView"), Map2 = getNative(context9, "Map"), Promise2 = getNative(context9, "Promise"), Set2 = getNative(context9, "Set"), WeakMap2 = getNative(context9, "WeakMap"), nativeCreate = getNative(Object2, "create");
749
+ var ctxClearTimeout = context8.clearTimeout !== root.clearTimeout && context8.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context8.setTimeout !== root.setTimeout && context8.setTimeout;
750
+ var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : undefined2, nativeIsFinite = context8.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context8.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
751
+ var DataView = getNative(context8, "DataView"), Map2 = getNative(context8, "Map"), Promise2 = getNative(context8, "Promise"), Set2 = getNative(context8, "Set"), WeakMap2 = getNative(context8, "WeakMap"), nativeCreate = getNative(Object2, "create");
756
752
  var metaMap = WeakMap2 && new WeakMap2();
757
753
  var realNames = {};
758
754
  var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map2), promiseCtorString = toSource(Promise2), setCtorString = toSource(Set2), weakMapCtorString = toSource(WeakMap2);
@@ -5765,264 +5761,14 @@ var require_dist = __commonJS({
5765
5761
  }
5766
5762
  });
5767
5763
 
5768
- // src/evals/definition.ts
5769
- function defineDataset(dataset) {
5770
- var _a, _b;
5771
- const id = dataset.id.trim();
5772
- const name = dataset.name.trim();
5773
- const rows = dataset.rows.map((row) => {
5774
- var _a2;
5775
- const parsed = DatasetRowInputSchema.parse(row);
5776
- return {
5777
- id: parsed.id,
5778
- name: (_a2 = parsed.name) != null ? _a2 : parsed.id,
5779
- input: parsed.input,
5780
- output: parsed.output,
5781
- properties: parsed.properties
5782
- };
5783
- });
5784
- const version = (_b = (_a = dataset.version) == null ? void 0 : _a.trim()) != null ? _b : (0, import_node_crypto2.createHash)("sha256").update(
5785
- JSON.stringify(
5786
- rows.map((row) => ({
5787
- ...row,
5788
- properties: Object.fromEntries(
5789
- Object.keys(row.properties).sort().map((key) => [key, row.properties[key]])
5790
- )
5791
- }))
5792
- )
5793
- ).digest("hex");
5794
- if (!id) throw new Error("Raindrop eval dataset ids cannot be empty");
5795
- if (!name) throw new Error("Raindrop eval dataset names cannot be empty");
5796
- if (!version) throw new Error("Raindrop eval dataset versions cannot be empty");
5797
- if (dataset.rows.length === 0) throw new Error("Raindrop eval datasets require at least one row");
5798
- const ids = rows.map((entry) => entry.id);
5799
- if (ids.some((rowId) => !rowId)) throw new Error("Raindrop eval row ids cannot be empty");
5800
- if (new Set(ids).size !== ids.length) throw new Error("Raindrop eval row ids must be unique");
5801
- if (dataset.remote) {
5802
- if (!dataset.remote.reference.trim())
5803
- throw new Error("Raindrop remote dataset reference cannot be empty");
5804
- if (!/^[a-f0-9]{64}$/.test(dataset.remote.fingerprint)) {
5805
- throw new Error("Raindrop remote dataset fingerprint must be a SHA-256 digest");
5806
- }
5807
- }
5808
- const defined2 = {
5809
- ...dataset,
5810
- id,
5811
- name,
5812
- version,
5813
- rows,
5814
- [EVAL_DATASET]: true
5815
- };
5816
- Object.defineProperty(defined2, EVAL_DATASET, { enumerable: false });
5817
- return defined2;
5818
- }
5819
- function isEvalDataset(value) {
5820
- return typeof value === "object" && value !== null && EVAL_DATASET in value && value[EVAL_DATASET] === true;
5821
- }
5822
- function defineEvaluatorProgram(program) {
5823
- var _a, _b, _c, _d;
5824
- const slug = program.slug.trim();
5825
- const name = program.name.trim();
5826
- const source = program.source.trim();
5827
- const intent = program.intent.trim();
5828
- if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug) || slug.length > 64) {
5829
- throw new Error(
5830
- "Raindrop evaluator program slugs must use lowercase letters, numbers, and single hyphens"
5831
- );
5832
- }
5833
- if (!name || name.length > 120) {
5834
- throw new Error("Raindrop evaluator program names must be between 1 and 120 characters");
5835
- }
5836
- if (!source) throw new Error(`Raindrop evaluator program ${slug} source cannot be empty`);
5837
- if (!intent || intent.length > 1e4) {
5838
- throw new Error(
5839
- `Raindrop evaluator program ${slug} intent must be between 1 and 10000 characters`
5840
- );
5841
- }
5842
- if (program.description != null && program.description.trim().length > 2e3) {
5843
- throw new Error(`Raindrop evaluator program ${slug} description exceeds 2000 characters`);
5844
- }
5845
- const rules = (_b = (_a = program.rules) == null ? void 0 : _a.map((rule) => rule.trim())) != null ? _b : [];
5846
- if (rules.length > 12 || rules.some((rule) => !rule || rule.length > 2e3)) {
5847
- throw new Error(`Raindrop evaluator program ${slug} rules are invalid`);
5848
- }
5849
- if (program.expected && (!import_zod2.z.string().uuid().safeParse(program.expected.evalId).success || !Number.isInteger(program.expected.programVersion) || program.expected.programVersion <= 0)) {
5850
- throw new Error(`Raindrop evaluator program ${slug} expected identity is invalid`);
5851
- }
5852
- return {
5853
- ...program,
5854
- kind: "program",
5855
- scope: import_zod2.z.literal("batch").parse((_c = program.scope) != null ? _c : "batch"),
5856
- slug,
5857
- name,
5858
- source,
5859
- intent,
5860
- description: ((_d = program.description) == null ? void 0 : _d.trim()) || null,
5861
- rules
5862
- };
5863
- }
5864
- function defineEvalSuite(definition) {
5865
- const name = definition.name.trim();
5866
- if (name.length === 0) throw new Error("Raindrop eval suite names cannot be empty");
5867
- const dataset = typeof definition.dataset === "string" ? definition.dataset.trim() : defineDataset(definition.dataset);
5868
- if (typeof dataset === "string" && dataset.length === 0) {
5869
- throw new Error("Raindrop eval suite datasets cannot be empty");
5870
- }
5871
- if (definition.datasetVersionId !== void 0) {
5872
- import_zod2.z.string().uuid().parse(definition.datasetVersionId);
5873
- if (typeof dataset !== "string")
5874
- throw new Error("A dataset version pin requires a published dataset slug");
5875
- }
5876
- if (definition.agent !== void 0 && definition.run !== void 0) {
5877
- throw new Error("An eval suite accepts either agent or run, not both");
5878
- }
5879
- if (definition.agent === void 0 && typeof definition.run !== "function") {
5880
- throw new Error("Raindrop eval suite run must be a function");
5881
- }
5882
- if (!Array.isArray(definition.evaluators) || definition.evaluators.length === 0) {
5883
- throw new Error("Raindrop eval suites require at least one evaluator");
5884
- }
5885
- validateOptionalNumber("concurrency", definition.concurrency, true, false);
5886
- validateOptionalNumber("traceWaitMs", definition.traceWaitMs, false, true);
5887
- validateOptionalNumber("evalWaitMs", definition.evalWaitMs, false, true);
5888
- validateOptionalNumber("evalPollIntervalMs", definition.evalPollIntervalMs, false, false);
5889
- const evaluators = definition.evaluators.map((evaluator) => validateEvaluator(evaluator));
5890
- const evaluatorNames = evaluators.map((entry) => evaluatorName(entry));
5891
- if (new Set(evaluatorNames).size !== evaluatorNames.length) {
5892
- throw new Error("Raindrop eval suite evaluators must be unique");
5893
- }
5894
- const branded = {
5895
- ...definition,
5896
- [EVAL_DEFINITION]: true,
5897
- name,
5898
- dataset,
5899
- evaluators
5900
- };
5901
- Object.defineProperty(branded, EVAL_DEFINITION, { enumerable: false });
5902
- return branded;
5903
- }
5904
- function isEvalSuiteDefinition(value) {
5905
- return typeof value === "object" && value !== null && EVAL_DEFINITION in value && value[EVAL_DEFINITION] === true;
5906
- }
5907
- function isPublishedEvalSuite(definition) {
5908
- return typeof definition.dataset === "string" && definition.datasetVersionId !== void 0 && definition.evaluators.every(
5909
- ({ evaluator }) => typeof evaluator !== "string" && (!("kind" in evaluator) || evaluator.kind !== "program" || evaluator.expected !== void 0)
5910
- );
5911
- }
5912
- function evaluatorName(evaluator) {
5913
- return typeof evaluator.evaluator === "string" ? evaluator.evaluator.trim() : evaluator.evaluator.slug.trim();
5914
- }
5915
- function evaluatorOutput(evaluator) {
5916
- return typeof evaluator.evaluator === "string" ? void 0 : evaluator.evaluator.output;
5917
- }
5918
- function validateEvaluatorOutput(evaluator, rawOutput) {
5919
- const name = evaluatorName(evaluator);
5920
- const output = EvalOutputSchema.parse(rawOutput);
5921
- const localOutput = evaluatorOutput(evaluator);
5922
- if (localOutput !== void 0 && localOutput !== output) {
5923
- throw new Error(`Raindrop local evaluator ${name} expected ${localOutput}, received ${output}`);
5924
- }
5925
- switch (output) {
5926
- case "boolean":
5927
- parseBooleanThreshold(evaluator.threshold);
5928
- break;
5929
- case "score":
5930
- parseNumericThreshold(name, "score", evaluator.threshold);
5931
- break;
5932
- case "number":
5933
- parseNumericThreshold(name, "number", evaluator.threshold);
5934
- break;
5935
- }
5936
- }
5937
- function validateEvaluator(evaluator) {
5938
- if (typeof evaluator !== "object" || evaluator === null || !("evaluator" in evaluator)) {
5939
- throw new Error("Raindrop eval evaluator entries must name an evaluator");
5940
- }
5941
- if ("output" in evaluator) {
5942
- throw new Error(
5943
- "Raindrop eval evaluator entries do not accept output; the evaluator definition owns it"
5944
- );
5945
- }
5946
- if (typeof evaluator.evaluator !== "string" && (typeof evaluator.evaluator !== "object" || evaluator.evaluator === null || typeof evaluator.evaluator.slug !== "string" || typeof evaluator.evaluator.name !== "string")) {
5947
- throw new Error("Raindrop local eval evaluators require a slug, name, output, and judge");
5948
- }
5949
- const name = evaluatorName(evaluator);
5950
- if (name.length === 0) throw new Error("Raindrop eval evaluator names cannot be empty");
5951
- if (typeof evaluator.evaluator === "string") {
5952
- const threshold = evaluator.threshold;
5953
- if (threshold !== void 0) {
5954
- const boolean = BooleanThresholdSchema.safeParse(threshold);
5955
- const numeric = NumericThresholdSchema.safeParse(threshold);
5956
- if (!boolean.success && !numeric.success) {
5957
- throw new Error(`Raindrop hosted evaluator ${name} has an invalid threshold`);
5958
- }
5959
- }
5960
- return { ...evaluator, evaluator: name };
5961
- }
5962
- if ("kind" in evaluator.evaluator && evaluator.evaluator.kind === "portable") {
5963
- validateEvaluatorOutput(evaluator, evaluator.evaluator.output);
5964
- return evaluator;
5965
- }
5966
- if ("kind" in evaluator.evaluator && evaluator.evaluator.kind === "program") {
5967
- const program = defineEvaluatorProgram(evaluator.evaluator);
5968
- validateEvaluatorOutput({ ...evaluator, evaluator: program }, program.output);
5969
- return { ...evaluator, evaluator: program };
5970
- }
5971
- if (typeof evaluator.evaluator.judge !== "function") {
5972
- throw new Error(`Raindrop local evaluator ${name} judge must be a function`);
5973
- }
5974
- if (evaluator.evaluator.scope !== "row") {
5975
- throw new Error(`Raindrop local evaluator ${name} scope must be row`);
5976
- }
5977
- const output = EvalOutputSchema.parse(evaluator.evaluator.output);
5978
- validateEvaluatorOutput(evaluator, output);
5979
- return evaluator;
5980
- }
5981
- function validateOptionalNumber(name, value, integer, allowZero) {
5982
- if (value === void 0) return;
5983
- const valid = Number.isFinite(value) && (!integer || Number.isInteger(value)) && (allowZero ? value >= 0 : value > 0);
5984
- if (!valid) {
5985
- const kind = integer ? "a positive integer" : allowZero ? "non-negative" : "positive";
5986
- throw new Error(`Raindrop eval ${name} must be ${kind}`);
5987
- }
5988
- }
5989
- function parseBooleanThreshold(threshold) {
5990
- return threshold === void 0 ? void 0 : BooleanThresholdSchema.parse(threshold);
5991
- }
5992
- function parseNumericThreshold(name, output, threshold) {
5993
- const parsed = threshold === void 0 ? void 0 : NumericThresholdSchema.parse(threshold);
5994
- if (output === "score" && parsed) {
5995
- const lower = "gte" in parsed ? parsed.gte : void 0;
5996
- const inRange = (lower === void 0 || lower >= 1 && lower <= 5) && (parsed.lte === void 0 || parsed.lte >= 1 && parsed.lte <= 5);
5997
- if (!inRange)
5998
- throw new Error(`Raindrop score evaluator ${name} thresholds must be from 1 to 5`);
5999
- }
6000
- return parsed;
6001
- }
6002
- var import_node_crypto2, import_zod2, EvalScoreSchema, EVAL_DATASET, DatasetRowInputSchema, BooleanThresholdSchema, FiniteThresholdSchema, EvalOutputSchema, NumericThresholdSchema, EVAL_DEFINITION;
6003
- var init_definition = __esm({
6004
- "src/evals/definition.ts"() {
5764
+ // src/evals/generated/manifest.ts
5765
+ var import_zod2, BooleanThresholdSchema, FiniteThresholdSchema, NumericThresholdSchema, EvalSuiteManifestSchema;
5766
+ var init_manifest = __esm({
5767
+ "src/evals/generated/manifest.ts"() {
6005
5768
  "use strict";
6006
- import_node_crypto2 = require("crypto");
6007
5769
  import_zod2 = require("zod");
6008
- EvalScoreSchema = import_zod2.z.union([
6009
- import_zod2.z.literal(1),
6010
- import_zod2.z.literal(2),
6011
- import_zod2.z.literal(3),
6012
- import_zod2.z.literal(4),
6013
- import_zod2.z.literal(5)
6014
- ]);
6015
- EVAL_DATASET = /* @__PURE__ */ Symbol.for("raindrop.evalDataset");
6016
- DatasetRowInputSchema = import_zod2.z.object({
6017
- id: import_zod2.z.string().trim().min(1),
6018
- name: import_zod2.z.string().optional(),
6019
- input: import_zod2.z.string().nullable(),
6020
- output: import_zod2.z.string().nullable().default(null),
6021
- properties: import_zod2.z.record(import_zod2.z.string()).default({})
6022
- });
6023
5770
  BooleanThresholdSchema = import_zod2.z.object({ equals: import_zod2.z.boolean() }).strict();
6024
5771
  FiniteThresholdSchema = import_zod2.z.number().finite();
6025
- EvalOutputSchema = import_zod2.z.enum(["boolean", "score", "number"]);
6026
5772
  NumericThresholdSchema = import_zod2.z.union([
6027
5773
  import_zod2.z.object({ gte: FiniteThresholdSchema, lte: FiniteThresholdSchema.optional() }).strict(),
6028
5774
  import_zod2.z.object({ lte: FiniteThresholdSchema }).strict()
@@ -6030,250 +5776,45 @@ var init_definition = __esm({
6030
5776
  (threshold) => !("gte" in threshold) || threshold.lte === void 0 || threshold.gte <= threshold.lte,
6031
5777
  { message: "Lower threshold cannot exceed upper threshold" }
6032
5778
  );
6033
- EVAL_DEFINITION = /* @__PURE__ */ Symbol.for("raindrop.evalDefinition");
5779
+ EvalSuiteManifestSchema = import_zod2.z.object({
5780
+ name: import_zod2.z.string().trim().min(1),
5781
+ dataset: import_zod2.z.string().trim().min(1),
5782
+ datasetVersionId: import_zod2.z.string().uuid().optional(),
5783
+ evaluators: import_zod2.z.array(
5784
+ import_zod2.z.object({
5785
+ evaluator: import_zod2.z.string().trim().min(1),
5786
+ threshold: import_zod2.z.union([BooleanThresholdSchema, NumericThresholdSchema]).optional()
5787
+ }).strict()
5788
+ ).min(1),
5789
+ concurrency: import_zod2.z.number().int().positive().optional(),
5790
+ traceWaitMs: import_zod2.z.number().nonnegative().optional(),
5791
+ evalWaitMs: import_zod2.z.number().nonnegative().optional(),
5792
+ evalPollIntervalMs: import_zod2.z.number().positive().optional()
5793
+ }).strict();
6034
5794
  }
6035
5795
  });
6036
5796
 
6037
5797
  // src/evals/generated/trace.ts
6038
- function compareNanoseconds(left, right) {
6039
- if (Number.isFinite(left) && Number.isFinite(right))
6040
- return Number(left) - Number(right);
6041
- const leftNs = BigInt(left != null ? left : 0);
6042
- const rightNs = BigInt(right != null ? right : 0);
6043
- return leftNs < rightNs ? -1 : leftNs > rightNs ? 1 : 0;
6044
- }
6045
- function nanosecondsToRoundedMilliseconds(value) {
6046
- if (Number.isFinite(value))
6047
- return Math.round(Number(value) / 1e6);
6048
- return Number((BigInt(value != null ? value : 0) + BigInt(5e5)) / BigInt(1e6));
6049
- }
6050
- function isKnownAttributeKey(key) {
6051
- return KNOWN_ATTRIBUTE_PREFIXES.some((prefix) => key.startsWith(prefix));
6052
- }
6053
- function tokenizeKey(key) {
6054
- return key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^a-zA-Z0-9]+/).filter(Boolean).map((token) => token.toLowerCase());
6055
- }
6056
- function isSensitiveAttributeKey(key) {
6057
- const tokens = tokenizeKey(key);
6058
- if (tokens.some((token) => SENSITIVE_KEY_TOKENS.has(token)))
6059
- return true;
6060
- for (let index = 0; index < tokens.length - 1; index += 1) {
6061
- if (SENSITIVE_KEY_TOKEN_PAIRS.has(`${tokens[index]} ${tokens[index + 1]}`))
6062
- return true;
6063
- }
6064
- return false;
6065
- }
6066
- function extractCustomSpanAttributes(span) {
6067
- var _a, _b;
6068
- const attributes = {};
6069
- const strings = (_a = span.attributes_string) != null ? _a : {};
6070
- for (const [key, value] of Object.entries(strings)) {
6071
- if (Object.keys(attributes).length >= MAX_CUSTOM_ATTRIBUTES)
6072
- break;
6073
- if (isKnownAttributeKey(key) || isSensitiveAttributeKey(key)) {
6074
- continue;
6075
- }
6076
- attributes[key] = value.length > MAX_ATTRIBUTE_VALUE_CHARS ? `${value.slice(0, MAX_ATTRIBUTE_VALUE_CHARS)}\u2026` : value;
6077
- }
6078
- const numbers = (_b = span.attributes_num) != null ? _b : {};
6079
- for (const [key, value] of Object.entries(numbers)) {
6080
- if (Object.keys(attributes).length >= MAX_CUSTOM_ATTRIBUTES)
6081
- break;
6082
- if (isKnownAttributeKey(key) || isSensitiveAttributeKey(key)) {
6083
- continue;
6084
- }
6085
- attributes[key] = value;
6086
- }
6087
- return Object.keys(attributes).length > 0 ? attributes : void 0;
6088
- }
6089
- function extractFinishReason(span) {
6090
- var _a, _b, _c;
6091
- const strings = (_a = span.attributes_string) != null ? _a : {};
6092
- const value = (_c = (_b = strings["ai.response.finishReason"]) != null ? _b : strings["gen_ai.response.finish_reasons"]) != null ? _c : strings["llm.response.finish_reason"];
6093
- return value && value.length > 0 ? value : void 0;
6094
- }
6095
- function normalizePayload(value) {
6096
- return value != null ? value : void 0;
6097
- }
6098
- function buildTraceSteps(rawSpans, options = {}) {
6099
- var _a;
6100
- const includePayloads = (_a = options.includePayloads) != null ? _a : false;
6101
- const sorted = [...rawSpans].sort((left, right) => compareNanoseconds(left.start_unix_ns, right.start_unix_ns));
6102
- return sorted.map((span, index) => {
6103
- var _a2, _b;
6104
- const status = span.status === "OK" || span.status === "ERROR" ? span.status : "UNSET";
6105
- const step = {
6106
- step: index + 1,
6107
- type: span.span_type || "INTERNAL",
6108
- name: span.span_name || "unknown",
6109
- status,
6110
- duration_ms: nanosecondsToRoundedMilliseconds(span.duration_ns)
6111
- };
6112
- if (span.span_id)
6113
- step.span_id = span.span_id;
6114
- if (span.status === "ERROR" && span.output_payload) {
6115
- step.error = span.output_payload.slice(0, 500);
6116
- }
6117
- if (span.model)
6118
- step.model = span.model;
6119
- const finishReason = extractFinishReason(span);
6120
- if (finishReason)
6121
- step.finish_reason = finishReason;
6122
- if (((_a2 = span.input_tokens) != null ? _a2 : 0) > 0)
6123
- step.input_tokens = span.input_tokens;
6124
- if (((_b = span.output_tokens) != null ? _b : 0) > 0)
6125
- step.output_tokens = span.output_tokens;
6126
- if (includePayloads && step.type === "TOOL_CALL") {
6127
- const inputPayload = normalizePayload(span.input_payload);
6128
- const outputPayload = normalizePayload(span.output_payload);
6129
- if (inputPayload)
6130
- step.input_payload = inputPayload;
6131
- if (outputPayload)
6132
- step.output_payload = outputPayload;
6133
- }
6134
- const attributes = extractCustomSpanAttributes(span);
6135
- if (attributes)
6136
- step.attributes = attributes;
6137
- return step;
6138
- });
6139
- }
6140
- function boundEvalPayload(payload) {
6141
- var _a;
6142
- if (payload.raw === null)
6143
- return payload;
6144
- const sizeChars = (_a = payload.sizeChars) != null ? _a : payload.raw.length;
6145
- return {
6146
- ...payload,
6147
- raw: payload.raw.slice(0, MAX_EVAL_PAYLOAD_RAW_CHARS),
6148
- sizeChars,
6149
- truncated: payload.truncated || sizeChars > MAX_EVAL_PAYLOAD_RAW_CHARS
6150
- };
6151
- }
6152
- function boundEvalEntry(entry) {
6153
- switch (entry.type) {
6154
- case "system":
6155
- case "reasoning":
6156
- return {
6157
- ...entry,
6158
- content: {
6159
- ...entry.content,
6160
- text: entry.content.text.slice(0, MAX_EVAL_PAYLOAD_RAW_CHARS)
6161
- }
6162
- };
6163
- case "user_message":
6164
- case "assistant_text":
6165
- return {
6166
- ...entry,
6167
- content: entry.content.map((content) => content.type === "text" ? { ...content, text: content.text.slice(0, MAX_EVAL_PAYLOAD_RAW_CHARS) } : content.type === "json" && content.raw !== null ? { ...content, raw: content.raw.slice(0, MAX_EVAL_PAYLOAD_RAW_CHARS) } : content)
6168
- };
6169
- case "tool_call":
6170
- return {
6171
- ...entry,
6172
- input: boundEvalPayload(entry.input),
6173
- output: entry.output === null ? null : boundEvalPayload(entry.output),
6174
- error: entry.error === null ? null : boundEvalPayload(entry.error)
6175
- };
6176
- default:
6177
- return entry;
6178
- }
6179
- }
6180
- function createTrace(origin, event, entries) {
6181
- return TraceSchema.parse({ origin, event, entries });
6182
- }
6183
- function traceStepsToEntries(steps) {
6184
- return steps.map((step, index) => {
6185
- var _a;
6186
- const source = {
6187
- adapter: "raw_spans",
6188
- confidence: "medium",
6189
- spanIds: step.span_id ? [step.span_id] : [],
6190
- parentSpanIds: [],
6191
- attributeKeys: []
6192
- };
6193
- const common = {
6194
- id: (_a = step.span_id) != null ? _a : `raw-step-${index}`,
6195
- order: index,
6196
- startMs: null,
6197
- endMs: null,
6198
- source
6199
- };
6200
- if (step.type === "TOOL_CALL") {
6201
- const payload = (raw) => {
6202
- var _a2;
6203
- return boundEvalPayload({
6204
- kind: raw ? "text" : "empty",
6205
- raw: raw != null ? raw : null,
6206
- truncated: false,
6207
- sizeChars: (_a2 = raw == null ? void 0 : raw.length) != null ? _a2 : null
6208
- });
6209
- };
6210
- return {
6211
- ...common,
6212
- type: "tool_call",
6213
- callId: null,
6214
- name: step.name,
6215
- status: step.status === "ERROR" ? "error" : step.status === "OK" ? "completed" : "unknown",
6216
- durationMs: step.duration_ms,
6217
- input: payload(step.input_payload),
6218
- output: step.output_payload ? payload(step.output_payload) : null,
6219
- error: step.error ? payload(step.error) : null
6220
- };
6221
- }
6222
- return {
6223
- ...common,
6224
- type: "unknown_span",
6225
- spanType: step.type,
6226
- name: step.name,
6227
- hiddenByDefault: true
6228
- };
6229
- });
6230
- }
6231
- function projectWorkshopTrace(input) {
6232
- return createTrace(input.origin, input.event, traceStepsToEntries(buildTraceSteps([...input.spans], { includePayloads: true })).map(boundEvalEntry));
6233
- }
6234
- function projectCapturedEvent(input) {
6235
- var _a, _b, _c, _d, _e, _f;
6236
- const ordered = [...input.spans].sort((left, right) => compareNanoseconds(left.start_unix_ns, right.start_unix_ns));
6237
- const eventSpan = ordered.find((span) => span.span_id === `evt_${input.eventId}`);
6238
- const llmSpans = ordered.filter((span) => span.span_type === "LLM_GENERATION" || span.span_type === "LLM_GENERATION_STREAM");
6239
- const inputSpan = ((_a = eventSpan == null ? void 0 : eventSpan.input_payload) == null ? void 0 : _a.trim()) ? eventSpan : llmSpans.find((span) => {
6240
- var _a2;
6241
- return Boolean((_a2 = span.input_payload) == null ? void 0 : _a2.trim());
6242
- });
6243
- const reverseLlmSpans = [...llmSpans].reverse();
6244
- const outputSpan = (_c = ((_b = eventSpan == null ? void 0 : eventSpan.output_payload) == null ? void 0 : _b.trim()) ? eventSpan : void 0) != null ? _c : reverseLlmSpans.find((span) => {
6245
- var _a2;
6246
- return Boolean((_a2 = span.output_payload) == null ? void 0 : _a2.trim()) && extractFinishReason(span) !== "tool-calls";
6247
- });
6248
- const modelSpan = (eventSpan == null ? void 0 : eventSpan.model) ? eventSpan : reverseLlmSpans.find((span) => Boolean(span.model));
6249
- return AIAnalyticsEventSchema.parse({
6250
- id: input.eventId,
6251
- _raindropDatabaseId: input.internalEventId,
6252
- name: input.name,
6253
- timestamp: input.timestamp,
6254
- receivedAt: input.receivedAt,
6255
- userId: input.userId,
6256
- aiData: {
6257
- input: (_d = inputSpan == null ? void 0 : inputSpan.input_payload) != null ? _d : null,
6258
- output: (_e = outputSpan == null ? void 0 : outputSpan.output_payload) != null ? _e : null,
6259
- model: (_f = modelSpan == null ? void 0 : modelSpan.model) != null ? _f : null,
6260
- convoId: input.convoId
6261
- },
6262
- properties: input.properties
6263
- });
6264
- }
6265
- function traceOutput(trace8) {
6266
- var _a;
6267
- return (_a = trace8.event.aiData.output) != null ? _a : null;
5798
+ function traceOutput(trace8) {
5799
+ var _a;
5800
+ return (_a = trace8.event.aiData.output) != null ? _a : null;
6268
5801
  }
6269
5802
  function traceToolCalls(trace8, name) {
6270
5803
  return trace8.entries.filter((entry) => entry.type === "tool_call" && (name === void 0 || entry.name === name));
6271
5804
  }
6272
- var import_zod3, stringToJSONSchema, SignalPropertiesSchema, AIEventMetadataSchema, AnalyticsEventSchema, LensInfoSchema, AttachmentSchema2, SignalSchema, RichTextContentSchema, RichJsonContentSchema, RichMediaContentSchema, RichReferenceContentSchema, RichContentSchema, RichPayloadValueSchema, RichEntrySourceSchema, RichInteractionEntryBaseSchema, RichSystemEntrySchema, RichUserMessageEntrySchema, RichAssistantTextEntrySchema, RichReasoningEntrySchema, RichToolCallEntrySchema, RichUnknownSpanEntrySchema, RichSubAgentEntrySchema, RichDetachedSubAgentEntrySchema, RichAgentHandoffEntrySchema, RichInteractionEntrySchema, RichSpanSummarySchema, RichDiagnosticWarningSchema, RichInteractionStatsSchema, RichEventInteractionSchema, CoreEventSchema, AIAnalyticsEventSchema, SpanStatusSchema, SpanTypeSchema, TracesListPipe, UINT64_MAX, NANOSECONDS_PATTERN, NanosecondsStringSchema, ReplayTraceSnapshotSpanSchema, TraceSchema, CapturedTraceSpanSchema, EVAL_DATASET_MAX_SPANS_PER_TRACE, EvalDatasetCaseIdSchema, CapturedTraceSnapshotSchema, EvalCaseTraceSchema, EvalCaseTracePairSchema, MAX_CUSTOM_ATTRIBUTES, MAX_ATTRIBUTE_VALUE_CHARS, KNOWN_ATTRIBUTE_PREFIXES, SENSITIVE_KEY_TOKENS, SENSITIVE_KEY_TOKEN_PAIRS, MAX_EVAL_PAYLOAD_RAW_CHARS, TRACE_PROJECTION_SHA256;
5805
+ var import_zod3, JsonValueSchema, stringToJSONSchema, SignalPropertiesSchema, AIEventMetadataSchema, AnalyticsEventSchema, LensInfoSchema, AttachmentSchema2, SignalSchema, RichTextContentSchema, RichJsonContentSchema, RichMediaContentSchema, RichReferenceContentSchema, RichContentSchema, RichPayloadValueSchema, RichEntrySourceSchema, RichInteractionEntryBaseSchema, RichSystemEntrySchema, RichUserMessageEntrySchema, RichAssistantTextEntrySchema, RichReasoningEntrySchema, RichToolCallEntrySchema, RichUnknownSpanEntrySchema, RichSubAgentEntrySchema, RichDetachedSubAgentEntrySchema, RichAgentHandoffEntrySchema, RichInteractionEntrySchema, RichSpanSummarySchema, RichDiagnosticWarningSchema, RichInteractionStatsSchema, RichEventInteractionSchema, CoreEventSchema, AIAnalyticsEventSchema, SpanStatusSchema, SpanTypeSchema, TracesListPipe, UINT64_MAX, NANOSECONDS_PATTERN, NanosecondsStringSchema, ReplayTraceSnapshotSpanSchema, EvalDatasetCaseIdSchema, EvalCaseExpectationSchema, TraceSchema, CapturedTraceSpanSchema, EVAL_DATASET_MAX_SPANS_PER_TRACE, CapturedTraceSnapshotSchema, EvalCaseTraceSchema, EvalCaseTracePairSchema, MAX_EVAL_PAYLOAD_RAW_CHARS;
6273
5806
  var init_trace = __esm({
6274
5807
  "src/evals/generated/trace.ts"() {
6275
5808
  "use strict";
6276
5809
  import_zod3 = __toESM(require("zod"));
5810
+ JsonValueSchema = import_zod3.default.lazy(() => import_zod3.default.union([
5811
+ import_zod3.default.string(),
5812
+ import_zod3.default.number(),
5813
+ import_zod3.default.boolean(),
5814
+ import_zod3.default.null(),
5815
+ import_zod3.default.array(JsonValueSchema),
5816
+ import_zod3.default.record(JsonValueSchema)
5817
+ ]));
6277
5818
  stringToJSONSchema = import_zod3.default.string().transform((str, ctx) => {
6278
5819
  try {
6279
5820
  return JSON.parse(str);
@@ -6642,52 +6183,58 @@ var init_trace = __esm({
6642
6183
  duration_ns: NanosecondsStringSchema,
6643
6184
  _inserted_at: import_zod3.default.string().min(1)
6644
6185
  }).strict();
6186
+ EvalDatasetCaseIdSchema = import_zod3.default.string().min(1).max(512).refine((value) => value === value.trim(), "Case id cannot have surrounding whitespace");
6187
+ EvalCaseExpectationSchema = import_zod3.default.object({
6188
+ description: import_zod3.default.string().trim().min(1).max(1e4),
6189
+ basis: import_zod3.default.enum(["human", "policy", "code", "inferred"]).optional(),
6190
+ reference: import_zod3.default.string().trim().min(1).max(2e3).optional()
6191
+ }).strict();
6645
6192
  TraceSchema = import_zod3.default.object({
6646
6193
  origin: import_zod3.default.enum(["production", "dataset", "simulation", "replay"]),
6647
6194
  event: AIAnalyticsEventSchema,
6648
- entries: import_zod3.default.array(RichInteractionEntrySchema)
6195
+ entries: import_zod3.default.array(RichInteractionEntrySchema),
6196
+ caseContext: import_zod3.default.object({ caseId: EvalDatasetCaseIdSchema, expectation: EvalCaseExpectationSchema.optional() }).optional()
6649
6197
  });
6650
6198
  CapturedTraceSpanSchema = ReplayTraceSnapshotSpanSchema;
6651
6199
  EVAL_DATASET_MAX_SPANS_PER_TRACE = 500;
6652
- EvalDatasetCaseIdSchema = import_zod3.default.string().min(1).max(512).refine((value) => value === value.trim(), "Case id cannot have surrounding whitespace");
6653
6200
  CapturedTraceSnapshotSchema = import_zod3.default.object({
6654
6201
  event: AIAnalyticsEventSchema,
6655
6202
  spans: import_zod3.default.array(CapturedTraceSpanSchema).min(1).max(EVAL_DATASET_MAX_SPANS_PER_TRACE)
6656
- }).strict().superRefine(({ event, spans }, context9) => {
6203
+ }).strict().superRefine(({ event, spans }, context8) => {
6657
6204
  var _a;
6658
6205
  const spanIds = /* @__PURE__ */ new Set();
6659
6206
  const traceIds = /* @__PURE__ */ new Set();
6660
6207
  for (const [index, span] of spans.entries()) {
6661
6208
  if (!/^[0-9a-f]{32}$/.test(span.trace_id)) {
6662
- context9.addIssue({
6209
+ context8.addIssue({
6663
6210
  code: import_zod3.default.ZodIssueCode.custom,
6664
6211
  message: "Captured trace id must be a lowercase 32-character hexadecimal value",
6665
6212
  path: ["spans", index, "trace_id"]
6666
6213
  });
6667
6214
  }
6668
6215
  if (!/^[0-9a-f]{16}$/.test(span.span_id)) {
6669
- context9.addIssue({
6216
+ context8.addIssue({
6670
6217
  code: import_zod3.default.ZodIssueCode.custom,
6671
6218
  message: "Captured span id must be a lowercase 16-character hexadecimal value",
6672
6219
  path: ["spans", index, "span_id"]
6673
6220
  });
6674
6221
  }
6675
6222
  if (span.parent_span_id !== "" && !/^[0-9a-f]{16}$/.test(span.parent_span_id)) {
6676
- context9.addIssue({
6223
+ context8.addIssue({
6677
6224
  code: import_zod3.default.ZodIssueCode.custom,
6678
6225
  message: "Captured parent span id must be empty or lowercase hexadecimal",
6679
6226
  path: ["spans", index, "parent_span_id"]
6680
6227
  });
6681
6228
  }
6682
6229
  if (span.event_id.length === 0) {
6683
- context9.addIssue({
6230
+ context8.addIssue({
6684
6231
  code: import_zod3.default.ZodIssueCode.custom,
6685
6232
  message: "Captured event id cannot be empty",
6686
6233
  path: ["spans", index, "event_id"]
6687
6234
  });
6688
6235
  }
6689
6236
  if (spanIds.has(span.span_id)) {
6690
- context9.addIssue({
6237
+ context8.addIssue({
6691
6238
  code: import_zod3.default.ZodIssueCode.custom,
6692
6239
  message: `Duplicate span id ${span.span_id}`,
6693
6240
  path: ["spans", index, "span_id"]
@@ -6696,7 +6243,7 @@ var init_trace = __esm({
6696
6243
  spanIds.add(span.span_id);
6697
6244
  traceIds.add(span.trace_id);
6698
6245
  if (span.event_id !== event._raindropDatabaseId) {
6699
- context9.addIssue({
6246
+ context8.addIssue({
6700
6247
  code: import_zod3.default.ZodIssueCode.custom,
6701
6248
  message: "Span event identity does not match the captured event",
6702
6249
  path: ["spans", index, "event_id"]
@@ -6705,7 +6252,7 @@ var init_trace = __esm({
6705
6252
  const validStart = /^\d{1,20}$/.test(span.start_unix_ns);
6706
6253
  const validEnd = /^\d{1,20}$/.test(span.end_unix_ns);
6707
6254
  if (validStart && validEnd && (BigInt(span.start_unix_ns) === BigInt(0) || BigInt(span.end_unix_ns) < BigInt(span.start_unix_ns))) {
6708
- context9.addIssue({
6255
+ context8.addIssue({
6709
6256
  code: import_zod3.default.ZodIssueCode.custom,
6710
6257
  message: "A captured span must have an end time at or after its start time",
6711
6258
  path: ["spans", index, "end_unix_ns"]
@@ -6713,28 +6260,19 @@ var init_trace = __esm({
6713
6260
  }
6714
6261
  }
6715
6262
  if (traceIds.size !== 1) {
6716
- context9.addIssue({
6263
+ context8.addIssue({
6717
6264
  code: import_zod3.default.ZodIssueCode.custom,
6718
6265
  message: "A reference snapshot must contain exactly one trace id",
6719
6266
  path: ["spans"]
6720
6267
  });
6721
6268
  }
6722
- for (const [index, span] of spans.entries()) {
6723
- if (span.parent_span_id && !spanIds.has(span.parent_span_id)) {
6724
- context9.addIssue({
6725
- code: import_zod3.default.ZodIssueCode.custom,
6726
- message: `Missing parent span ${span.parent_span_id}`,
6727
- path: ["spans", index, "parent_span_id"]
6728
- });
6729
- }
6730
- }
6731
6269
  const parentBySpanId = new Map(spans.map((span) => [span.span_id, span.parent_span_id]));
6732
6270
  for (const [index, span] of spans.entries()) {
6733
6271
  const path = /* @__PURE__ */ new Set();
6734
6272
  let spanId = span.span_id;
6735
6273
  while (spanId !== "") {
6736
6274
  if (path.has(spanId)) {
6737
- context9.addIssue({
6275
+ context8.addIssue({
6738
6276
  code: import_zod3.default.ZodIssueCode.custom,
6739
6277
  message: "Captured span parent relationships cannot contain a cycle",
6740
6278
  path: ["spans", index, "parent_span_id"]
@@ -6752,367 +6290,289 @@ var init_trace = __esm({
6752
6290
  });
6753
6291
  EvalCaseTracePairSchema = import_zod3.default.object({
6754
6292
  caseId: EvalDatasetCaseIdSchema,
6293
+ output: JsonValueSchema.optional(),
6755
6294
  candidate: EvalCaseTraceSchema.extend({
6756
- trace: TraceSchema.extend({ origin: import_zod3.default.literal("replay") })
6295
+ trace: TraceSchema.extend({ origin: import_zod3.default.enum(["replay", "dataset"]) })
6757
6296
  }),
6758
6297
  reference: EvalCaseTraceSchema.extend({
6759
6298
  trace: TraceSchema.extend({ origin: import_zod3.default.literal("dataset") })
6760
6299
  }).optional()
6761
6300
  });
6762
- MAX_CUSTOM_ATTRIBUTES = 25;
6763
- MAX_ATTRIBUTE_VALUE_CHARS = 500;
6764
- KNOWN_ATTRIBUTE_PREFIXES = [
6765
- "ai.",
6766
- "gen_ai.",
6767
- "llm.",
6768
- "openinference.",
6769
- "traceloop.",
6770
- "raindrop.",
6771
- "otel.",
6772
- "telemetry.",
6773
- "service.",
6774
- "resource.",
6775
- "http.",
6776
- "net.",
6777
- "network.",
6778
- "server.",
6779
- "client.",
6780
- "url.",
6781
- "rpc.",
6782
- "db.",
6783
- "messaging.",
6784
- "code.",
6785
- "thread.",
6786
- "session.",
6787
- "user_agent.",
6788
- "process.",
6789
- "host.",
6790
- "os.",
6791
- "exception.",
6792
- "span."
6793
- ];
6794
- SENSITIVE_KEY_TOKENS = /* @__PURE__ */ new Set([
6795
- "secret",
6796
- "secrets",
6797
- "secretkey",
6798
- "password",
6799
- "passwd",
6800
- "pwd",
6801
- "token",
6802
- "tokens",
6803
- "auth",
6804
- "authorization",
6805
- "credential",
6806
- "credentials",
6807
- "bearer",
6808
- "cookie",
6809
- "cookies",
6810
- "apikey",
6811
- "accesskey",
6812
- "privatekey",
6813
- "sessionid"
6814
- ]);
6815
- SENSITIVE_KEY_TOKEN_PAIRS = /* @__PURE__ */ new Set([
6816
- "api key",
6817
- "access key",
6818
- "private key",
6819
- "secret key",
6820
- "session id",
6821
- "auth token",
6822
- "access token",
6823
- "refresh token"
6824
- ]);
6825
6301
  MAX_EVAL_PAYLOAD_RAW_CHARS = 16 * 1024;
6826
- TRACE_PROJECTION_SHA256 = "7d12eb03150b8f203e4404622f047676f50b3aa1e5442f0ed42d77d6002a33a6";
6827
6302
  }
6828
6303
  });
6829
6304
 
6830
- // src/evals/portable-runtime.ts
6831
- var portable_runtime_exports = {};
6832
- __export(portable_runtime_exports, {
6833
- runPortableEvaluator: () => runPortableEvaluator
6834
- });
6835
- async function runPortableEvaluator(evaluator, input) {
6836
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
6837
- const inputJson = JSON.stringify(input);
6838
- const maxInputBytes = (_b = (_a = evaluator.limits) == null ? void 0 : _a.maxInputBytes) != null ? _b : DEFAULT_MAX_INPUT_BYTES;
6839
- if (byteLength(inputJson) > maxInputBytes) {
6840
- throw new Error(`Raindrop portable evaluator input exceeds ${maxInputBytes} bytes`);
6841
- }
6842
- const QuickJS = await (0, import_quickjs_emscripten_core.newQuickJSWASMModuleFromVariant)(import_quickjs_singlefile_cjs_release_sync.default);
6843
- const runtime = QuickJS.newRuntime();
6844
- runtime.setMemoryLimit((_d = (_c = evaluator.limits) == null ? void 0 : _c.memoryBytes) != null ? _d : DEFAULT_MEMORY_BYTES);
6845
- runtime.setMaxStackSize((_f = (_e = evaluator.limits) == null ? void 0 : _e.stackBytes) != null ? _f : DEFAULT_STACK_BYTES);
6846
- const timeoutMs = (_h = (_g = evaluator.limits) == null ? void 0 : _g.timeoutMs) != null ? _h : evaluator.artifact.evaluator.executionMode === "judge" ? DEFAULT_JUDGE_TIMEOUT_MS : DEFAULT_TIMEOUT_MS;
6847
- const deadline = Date.now() + timeoutMs;
6848
- runtime.setInterruptHandler((0, import_quickjs_emscripten_core.shouldInterruptAfterDeadline)(deadline));
6849
- const context9 = runtime.newContext();
6850
- const deferreds = [];
6851
- const hostCalls = /* @__PURE__ */ new Set();
6852
- const tracesById = new Map(input.traces.map((trace8) => [trace8.event.id, trace8]));
6853
- const casesByTraceId = new Map(
6854
- input.cases.map((entry) => [entry.candidate.trace.event.id, entry])
6855
- );
6856
- let activeJudgeCalls = 0;
6857
- try {
6858
- const bridge = context9.newFunction("__raindrop_eval_judge", (requestHandle) => {
6859
- var _a2, _b2;
6860
- const deferred = context9.newPromise();
6861
- deferreds.push(deferred);
6862
- const requestJson = context9.getString(requestHandle);
6863
- const judgeConcurrency = (_b2 = (_a2 = evaluator.limits) == null ? void 0 : _a2.judgeConcurrency) != null ? _b2 : DEFAULT_JUDGE_CONCURRENCY;
6864
- let acquired = false;
6865
- const hostCall = resolveJudge(
6866
- evaluator,
6867
- requestJson,
6868
- Math.max(1, deadline - Date.now()),
6869
- tracesById,
6870
- casesByTraceId,
6871
- () => {
6872
- if (activeJudgeCalls >= judgeConcurrency) return false;
6873
- activeJudgeCalls += 1;
6874
- acquired = true;
6875
- return true;
6876
- }
6877
- ).then((responseJson) => {
6878
- const response = context9.newString(responseJson);
6879
- try {
6880
- deferred.resolve(response);
6881
- } finally {
6882
- response.dispose();
6883
- }
6884
- }).finally(() => {
6885
- if (acquired) activeJudgeCalls -= 1;
6886
- hostCalls.delete(hostCall);
6887
- });
6888
- hostCalls.add(hostCall);
6889
- return deferred.handle;
6890
- });
6891
- context9.setProp(context9.global, "__raindrop_eval_judge", bridge);
6892
- bridge.dispose();
6893
- const loaded = context9.evalCode(evaluator.artifact.source, "raindrop-evaluator.js");
6894
- context9.unwrapResult(loaded).dispose();
6895
- const entrypoint = context9.getProp(context9.global, "__raindrop_eval_run");
6896
- const inputHandle = context9.newString(inputJson);
6897
- let promiseHandle;
6898
- try {
6899
- promiseHandle = context9.unwrapResult(
6900
- context9.callFunction(entrypoint, context9.global, inputHandle)
6901
- );
6902
- } finally {
6903
- inputHandle.dispose();
6904
- entrypoint.dispose();
6905
- }
6906
- try {
6907
- const result = await drivePromise(runtime, context9, promiseHandle, deadline);
6908
- const outputHandle = context9.unwrapResult(result);
6909
- try {
6910
- const outputJson = context9.getString(outputHandle);
6911
- const maxOutputBytes = (_j = (_i = evaluator.limits) == null ? void 0 : _i.maxOutputBytes) != null ? _j : DEFAULT_MAX_OUTPUT_BYTES;
6912
- if (byteLength(outputJson) > maxOutputBytes) {
6913
- throw new Error(`Raindrop portable evaluator output exceeds ${maxOutputBytes} bytes`);
6914
- }
6915
- const envelope = JSON.parse(outputJson);
6916
- if (typeof envelope !== "object" || envelope === null || !("type" in envelope) || envelope.type !== "result" || !("result" in envelope)) {
6917
- throw new Error("Raindrop portable evaluator returned an invalid result envelope");
6918
- }
6919
- return parsePortableEvalResult(envelope.result);
6920
- } finally {
6921
- outputHandle.dispose();
6922
- }
6923
- } finally {
6924
- promiseHandle.dispose();
6925
- }
6926
- } catch (cause) {
6927
- const message = cause instanceof Error ? cause.message : String(cause);
6928
- if (Date.now() >= deadline || message.includes("interrupted")) {
6929
- throw new Error(`Raindrop portable evaluator exceeded ${timeoutMs}ms`);
6305
+ // src/evals/definition.ts
6306
+ function defineDataset(dataset) {
6307
+ var _a, _b;
6308
+ const id = dataset.id.trim();
6309
+ const name = dataset.name.trim();
6310
+ const rows = dataset.rows.map((row) => {
6311
+ var _a2;
6312
+ const parsed = DatasetRowInputSchema.parse(row);
6313
+ return {
6314
+ id: parsed.id,
6315
+ name: (_a2 = parsed.name) != null ? _a2 : parsed.id,
6316
+ input: parsed.input,
6317
+ output: parsed.output,
6318
+ properties: parsed.properties
6319
+ };
6320
+ });
6321
+ const version = (_b = (_a = dataset.version) == null ? void 0 : _a.trim()) != null ? _b : (0, import_node_crypto2.createHash)("sha256").update(
6322
+ JSON.stringify(
6323
+ rows.map((row) => ({
6324
+ ...row,
6325
+ properties: Object.fromEntries(
6326
+ Object.keys(row.properties).sort().map((key) => [key, row.properties[key]])
6327
+ )
6328
+ }))
6329
+ )
6330
+ ).digest("hex");
6331
+ if (!id) throw new Error("Raindrop eval dataset ids cannot be empty");
6332
+ if (!name) throw new Error("Raindrop eval dataset names cannot be empty");
6333
+ if (!version) throw new Error("Raindrop eval dataset versions cannot be empty");
6334
+ if (dataset.rows.length === 0) throw new Error("Raindrop eval datasets require at least one row");
6335
+ const ids = rows.map((entry) => entry.id);
6336
+ if (ids.some((rowId) => !rowId)) throw new Error("Raindrop eval row ids cannot be empty");
6337
+ if (new Set(ids).size !== ids.length) throw new Error("Raindrop eval row ids must be unique");
6338
+ if (dataset.remote) {
6339
+ if (!dataset.remote.reference.trim())
6340
+ throw new Error("Raindrop remote dataset reference cannot be empty");
6341
+ if (!/^[a-f0-9]{64}$/.test(dataset.remote.fingerprint)) {
6342
+ throw new Error("Raindrop remote dataset fingerprint must be a SHA-256 digest");
6930
6343
  }
6931
- throw new Error(`Raindrop portable evaluator failed: ${message}`);
6932
- } finally {
6933
- await Promise.allSettled([...hostCalls]);
6934
- for (const deferred of deferreds) deferred.dispose();
6935
- context9.dispose();
6936
- runtime.dispose();
6937
6344
  }
6345
+ const defined2 = {
6346
+ ...dataset,
6347
+ id,
6348
+ name,
6349
+ version,
6350
+ rows,
6351
+ [EVAL_DATASET]: true
6352
+ };
6353
+ Object.defineProperty(defined2, EVAL_DATASET, { enumerable: false });
6354
+ return defined2;
6938
6355
  }
6939
- async function drivePromise(runtime, context9, promise, deadline) {
6940
- while (true) {
6941
- runtime.executePendingJobs(100).unwrap();
6942
- const state2 = context9.getPromiseState(promise);
6943
- if (state2.type === "fulfilled") return { value: state2.value };
6944
- if (state2.type === "rejected") return { error: state2.error };
6945
- await new Promise((resolve3) => setTimeout(resolve3, 0));
6946
- if (Date.now() >= deadline) throw new Error("interrupted");
6947
- }
6356
+ function isEvalDataset(value) {
6357
+ return typeof value === "object" && value !== null && EVAL_DATASET in value && value[EVAL_DATASET] === true;
6948
6358
  }
6949
- async function resolveJudge(evaluator, rawRequest, remainingMs, tracesById, casesByTraceId, acquire) {
6950
- var _a, _b;
6951
- let requestId = "unknown";
6952
- try {
6953
- const request = JudgeRequestSchema.parse(JSON.parse(rawRequest));
6954
- requestId = request.requestId;
6955
- const trace8 = tracesById.get(request.traceId);
6956
- if (!trace8) throw new Error("Judge trace is outside this run");
6957
- if (!evaluator.judge) throw new Error("Judge unavailable");
6958
- if (!acquire()) throw new Error("Judge concurrency exceeded");
6959
- const controller = new AbortController();
6960
- const timeoutMs = Math.min(
6961
- (_b = (_a = evaluator.limits) == null ? void 0 : _a.judgeTimeoutMs) != null ? _b : DEFAULT_JUDGE_REQUEST_TIMEOUT_MS,
6962
- remainingMs
6359
+ function defineEvaluatorProgram(program) {
6360
+ var _a, _b, _c, _d;
6361
+ const slug = program.slug.trim();
6362
+ const name = program.name.trim();
6363
+ const source = program.source.trim();
6364
+ const intent = program.intent.trim();
6365
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug) || slug.length > 64) {
6366
+ throw new Error(
6367
+ "Raindrop evaluator program slugs must use lowercase letters, numbers, and single hyphens"
6963
6368
  );
6964
- const timeout = setTimeout(() => controller.abort(), timeoutMs);
6965
- const result = await Promise.race([
6966
- Promise.resolve().then(
6967
- () => {
6968
- var _a2;
6969
- return (_a2 = evaluator.judge) == null ? void 0 : _a2.call(evaluator, {
6970
- trace: trace8,
6971
- tracePair: rowTracePair(casesByTraceId.get(request.traceId)),
6972
- rubric: request.rubric.slice(0, 4e4),
6973
- signal: controller.signal
6974
- });
6975
- }
6976
- ),
6977
- new Promise((_resolve, reject) => {
6978
- controller.signal.addEventListener(
6979
- "abort",
6980
- () => reject(new Error(`Judge exceeded ${timeoutMs}ms`)),
6981
- { once: true }
6982
- );
6983
- })
6984
- ]).finally(() => clearTimeout(timeout));
6985
- if (typeof result !== "object" || result === null) throw new Error("invalid judge response");
6986
- return JSON.stringify({ type: "judge_response", requestId, status: "completed", result });
6987
- } catch (e) {
6988
- return JSON.stringify({
6989
- type: "judge_response",
6990
- requestId,
6991
- status: "unavailable",
6992
- message: "Judge unavailable"
6993
- });
6994
6369
  }
6370
+ if (!name || name.length > 120) {
6371
+ throw new Error("Raindrop evaluator program names must be between 1 and 120 characters");
6372
+ }
6373
+ if (!source) throw new Error(`Raindrop evaluator program ${slug} source cannot be empty`);
6374
+ if (!intent || intent.length > 1e4) {
6375
+ throw new Error(
6376
+ `Raindrop evaluator program ${slug} intent must be between 1 and 10000 characters`
6377
+ );
6378
+ }
6379
+ if (program.description != null && program.description.trim().length > 2e3) {
6380
+ throw new Error(`Raindrop evaluator program ${slug} description exceeds 2000 characters`);
6381
+ }
6382
+ const rules = (_b = (_a = program.rules) == null ? void 0 : _a.map((rule) => rule.trim())) != null ? _b : [];
6383
+ if (rules.length > 12 || rules.some((rule) => !rule || rule.length > 2e3)) {
6384
+ throw new Error(`Raindrop evaluator program ${slug} rules are invalid`);
6385
+ }
6386
+ if (program.expected && (!import_zod4.z.string().uuid().safeParse(program.expected.evalId).success || !Number.isInteger(program.expected.programVersion) || program.expected.programVersion <= 0)) {
6387
+ throw new Error(`Raindrop evaluator program ${slug} expected identity is invalid`);
6388
+ }
6389
+ return {
6390
+ ...program,
6391
+ kind: "program",
6392
+ scope: import_zod4.z.literal("batch").parse((_c = program.scope) != null ? _c : "batch"),
6393
+ slug,
6394
+ name,
6395
+ source,
6396
+ intent,
6397
+ description: ((_d = program.description) == null ? void 0 : _d.trim()) || null,
6398
+ rules
6399
+ };
6995
6400
  }
6996
- function byteLength(value) {
6997
- return new TextEncoder().encode(value).byteLength;
6998
- }
6999
- function rowTracePair(pair) {
7000
- if (!pair) return void 0;
7001
- const { caseId, ...evidence } = pair;
7002
- return { ...evidence, rowId: caseId };
6401
+ function defineEvalSuite(definition, binding) {
6402
+ if (binding) return createEvalSuite({ ...EvalSuiteManifestSchema.parse(definition), ...binding });
6403
+ if (!("run" in definition) && !("agent" in definition)) {
6404
+ throw new Error("Bind the eval manifest to your local run function or agent");
6405
+ }
6406
+ return createEvalSuite(definition);
7003
6407
  }
7004
- var import_quickjs_singlefile_cjs_release_sync, import_quickjs_emscripten_core, import_zod9, DEFAULT_MEMORY_BYTES, DEFAULT_STACK_BYTES, DEFAULT_TIMEOUT_MS, DEFAULT_JUDGE_TIMEOUT_MS, DEFAULT_JUDGE_REQUEST_TIMEOUT_MS, DEFAULT_JUDGE_CONCURRENCY, DEFAULT_MAX_INPUT_BYTES, DEFAULT_MAX_OUTPUT_BYTES, JudgeRequestSchema;
7005
- var init_portable_runtime = __esm({
7006
- "src/evals/portable-runtime.ts"() {
7007
- "use strict";
7008
- import_quickjs_singlefile_cjs_release_sync = __toESM(require("@jitl/quickjs-singlefile-cjs-release-sync"));
7009
- import_quickjs_emscripten_core = require("quickjs-emscripten-core");
7010
- import_zod9 = require("zod");
7011
- init_portable();
7012
- DEFAULT_MEMORY_BYTES = 32 * 1024 * 1024;
7013
- DEFAULT_STACK_BYTES = 64 * 1024;
7014
- DEFAULT_TIMEOUT_MS = 1e3;
7015
- DEFAULT_JUDGE_TIMEOUT_MS = 6e4;
7016
- DEFAULT_JUDGE_REQUEST_TIMEOUT_MS = 3e4;
7017
- DEFAULT_JUDGE_CONCURRENCY = 4;
7018
- DEFAULT_MAX_INPUT_BYTES = 4 * 1024 * 1024;
7019
- DEFAULT_MAX_OUTPUT_BYTES = 4 * 1024 * 1024;
7020
- JudgeRequestSchema = import_zod9.z.object({
7021
- type: import_zod9.z.literal("judge_request"),
7022
- requestId: import_zod9.z.string(),
7023
- traceId: import_zod9.z.string(),
7024
- rubric: import_zod9.z.string()
7025
- });
6408
+ function createEvalSuite(definition) {
6409
+ const name = definition.name.trim();
6410
+ if (name.length === 0) throw new Error("Raindrop eval suite names cannot be empty");
6411
+ const dataset = typeof definition.dataset === "string" ? definition.dataset.trim() : defineDataset(definition.dataset);
6412
+ if (typeof dataset === "string" && dataset.length === 0) {
6413
+ throw new Error("Raindrop eval suite datasets cannot be empty");
7026
6414
  }
7027
- });
7028
-
7029
- // src/evals/portable.ts
7030
- function parsePortableEvalResult(value) {
7031
- return PortableEvalResultSchema.parse(value);
6415
+ if (definition.datasetVersionId !== void 0) {
6416
+ import_zod4.z.string().uuid().parse(definition.datasetVersionId);
6417
+ if (typeof dataset !== "string")
6418
+ throw new Error("A dataset version pin requires a published dataset slug");
6419
+ }
6420
+ if (definition.agent !== void 0 && definition.run !== void 0) {
6421
+ throw new Error("An eval suite accepts either agent or run, not both");
6422
+ }
6423
+ if (definition.agent === void 0 && typeof definition.run !== "function") {
6424
+ throw new Error("Raindrop eval suite run must be a function");
6425
+ }
6426
+ if (!Array.isArray(definition.evaluators) || definition.evaluators.length === 0) {
6427
+ throw new Error("Raindrop eval suites require at least one evaluator");
6428
+ }
6429
+ validateOptionalNumber("concurrency", definition.concurrency, true, false);
6430
+ validateOptionalNumber("traceWaitMs", definition.traceWaitMs, false, true);
6431
+ validateOptionalNumber("evalWaitMs", definition.evalWaitMs, false, true);
6432
+ validateOptionalNumber("evalPollIntervalMs", definition.evalPollIntervalMs, false, false);
6433
+ const evaluators = definition.evaluators.map((evaluator) => validateEvaluator(evaluator));
6434
+ const evaluatorNames = evaluators.map((entry) => evaluatorName(entry));
6435
+ if (new Set(evaluatorNames).size !== evaluatorNames.length) {
6436
+ throw new Error("Raindrop eval suite evaluators must be unique");
6437
+ }
6438
+ const branded = {
6439
+ ...definition,
6440
+ [EVAL_DEFINITION]: true,
6441
+ name,
6442
+ dataset,
6443
+ evaluators
6444
+ };
6445
+ Object.defineProperty(branded, EVAL_DEFINITION, { enumerable: false });
6446
+ return branded;
7032
6447
  }
7033
- async function evaluatePortableEvaluator(evaluator, input) {
7034
- var _a;
7035
- const artifact = await verifyPortableEvalArtifact(evaluator.artifact, {
7036
- expectedSha256: evaluator.expectedSha256
7037
- });
7038
- const { runPortableEvaluator: runPortableEvaluator2 } = await Promise.resolve().then(() => (init_portable_runtime(), portable_runtime_exports));
7039
- const cases = ((_a = input.rows) != null ? _a : []).map(({ rowId, ...pair }) => ({ ...pair, caseId: rowId }));
7040
- if (cases.length > 0 && (cases.length !== input.traces.length || cases.some(
7041
- (entry, index) => {
7042
- var _a2;
7043
- return entry.candidate.trace.event.id !== ((_a2 = input.traces[index]) == null ? void 0 : _a2.event.id);
7044
- }
7045
- ))) {
7046
- throw new Error("Raindrop portable evaluator rows must match traces exactly, in slice order");
6448
+ function isEvalSuiteDefinition(value) {
6449
+ return typeof value === "object" && value !== null && EVAL_DEFINITION in value && value[EVAL_DEFINITION] === true;
6450
+ }
6451
+ function isPublishedEvalSuite(definition) {
6452
+ return typeof definition.dataset === "string" && definition.datasetVersionId !== void 0 && definition.evaluators.every(
6453
+ ({ evaluator }) => typeof evaluator !== "string" && (!("kind" in evaluator) || evaluator.kind !== "program" || evaluator.expected !== void 0)
6454
+ );
6455
+ }
6456
+ function evaluatorName(evaluator) {
6457
+ return typeof evaluator.evaluator === "string" ? evaluator.evaluator.trim() : evaluator.evaluator.slug.trim();
6458
+ }
6459
+ function evaluatorOutput(evaluator) {
6460
+ return typeof evaluator.evaluator === "string" ? void 0 : evaluator.evaluator.output;
6461
+ }
6462
+ function validateEvaluatorOutput(evaluator, rawOutput) {
6463
+ const name = evaluatorName(evaluator);
6464
+ const output = EvalOutputSchema.parse(rawOutput);
6465
+ const localOutput = evaluatorOutput(evaluator);
6466
+ if (localOutput !== void 0 && localOutput !== output) {
6467
+ throw new Error(`Raindrop local evaluator ${name} expected ${localOutput}, received ${output}`);
6468
+ }
6469
+ switch (output) {
6470
+ case "boolean":
6471
+ parseBooleanThreshold(evaluator.threshold);
6472
+ break;
6473
+ case "score":
6474
+ parseNumericThreshold(name, "score", evaluator.threshold);
6475
+ break;
6476
+ case "number":
6477
+ parseNumericThreshold(name, "number", evaluator.threshold);
6478
+ break;
7047
6479
  }
7048
- const { rows: _rows, ...runtimeInput } = input;
7049
- const result = await runPortableEvaluator2(evaluator, { ...runtimeInput, cases });
7050
- validatePortableResult(artifact, input.traces, result);
7051
- return result;
7052
6480
  }
7053
- async function verifyPortableEvalArtifact(rawArtifact, options = {}) {
7054
- const artifact = PortableEvalArtifactSchema.parse(rawArtifact);
7055
- if (artifact.traceProjectionSha256 !== TRACE_PROJECTION_SHA256) {
7056
- throw new Error(
7057
- `Raindrop portable evaluator ${artifact.evaluator.slug} targets a different trace projection`
7058
- );
6481
+ function validateEvaluator(evaluator) {
6482
+ if (typeof evaluator !== "object" || evaluator === null || !("evaluator" in evaluator)) {
6483
+ throw new Error("Raindrop eval evaluator entries must name an evaluator");
7059
6484
  }
7060
- const digest = await artifactDigest(artifact);
7061
- if (digest !== artifact.sha256) {
6485
+ if ("output" in evaluator) {
7062
6486
  throw new Error(
7063
- `Raindrop portable evaluator ${artifact.evaluator.slug} content digest is invalid`
6487
+ "Raindrop eval evaluator entries do not accept output; the evaluator definition owns it"
7064
6488
  );
7065
6489
  }
7066
- if (options.expectedSha256 && digest !== options.expectedSha256) {
7067
- throw new Error(
7068
- `Raindrop portable evaluator ${artifact.evaluator.slug} does not match expectedSha256`
7069
- );
6490
+ if (typeof evaluator.evaluator !== "string" && (typeof evaluator.evaluator !== "object" || evaluator.evaluator === null || typeof evaluator.evaluator.slug !== "string" || typeof evaluator.evaluator.name !== "string")) {
6491
+ throw new Error("Raindrop local eval evaluators require a slug, name, output, and judge");
7070
6492
  }
7071
- return artifact;
7072
- }
7073
- function validatePortableResult(artifact, traces, result) {
7074
- if (result.stats.traceCount !== traces.length) {
7075
- throw new Error("Raindrop portable evaluator returned an inconsistent trace count");
6493
+ const name = evaluatorName(evaluator);
6494
+ if (name.length === 0) throw new Error("Raindrop eval evaluator names cannot be empty");
6495
+ if (typeof evaluator.evaluator === "string") {
6496
+ const threshold = evaluator.threshold;
6497
+ if (threshold !== void 0) {
6498
+ const boolean = BooleanThresholdSchema.safeParse(threshold);
6499
+ const numeric = NumericThresholdSchema.safeParse(threshold);
6500
+ if (!boolean.success && !numeric.success) {
6501
+ throw new Error(`Raindrop hosted evaluator ${name} has an invalid threshold`);
6502
+ }
6503
+ }
6504
+ return { ...evaluator, evaluator: name };
7076
6505
  }
7077
- const expected = new Set(traces.map((trace8) => trace8.event.id));
7078
- if (expected.size !== traces.length) {
7079
- throw new Error("Raindrop portable evaluator input trace ids must be unique");
6506
+ if ("kind" in evaluator.evaluator && evaluator.evaluator.kind === "portable") {
6507
+ validateEvaluatorOutput(evaluator, evaluator.evaluator.output);
6508
+ return evaluator;
7080
6509
  }
7081
- const returned = /* @__PURE__ */ new Set();
7082
- for (const outcome of result.outcomes) {
7083
- if (!expected.has(outcome.traceId)) {
7084
- throw new Error(`Raindrop portable evaluator returned foreign trace ${outcome.traceId}`);
7085
- }
7086
- if (returned.has(outcome.traceId)) {
7087
- throw new Error(`Raindrop portable evaluator repeated trace ${outcome.traceId}`);
7088
- }
7089
- returned.add(outcome.traceId);
7090
- if (outcome.state !== "graded") continue;
7091
- const valid = artifact.evaluator.outputType === "boolean" ? "pass" in outcome : artifact.evaluator.outputType === "score" ? "score" in outcome : "value" in outcome;
7092
- if (!valid) {
7093
- throw new Error(
7094
- `Raindrop portable evaluator ${artifact.evaluator.slug} returned the wrong graded value`
7095
- );
7096
- }
6510
+ if ("kind" in evaluator.evaluator && evaluator.evaluator.kind === "program") {
6511
+ const program = defineEvaluatorProgram(evaluator.evaluator);
6512
+ validateEvaluatorOutput({ ...evaluator, evaluator: program }, program.output);
6513
+ return { ...evaluator, evaluator: program };
6514
+ }
6515
+ if (typeof evaluator.evaluator.judge !== "function") {
6516
+ throw new Error(`Raindrop local evaluator ${name} judge must be a function`);
6517
+ }
6518
+ if (evaluator.evaluator.scope !== "row") {
6519
+ throw new Error(`Raindrop local evaluator ${name} scope must be row`);
7097
6520
  }
7098
- const missing = [...expected].find((traceId) => !returned.has(traceId));
7099
- if (missing) throw new Error(`Raindrop portable evaluator omitted trace ${missing}`);
6521
+ const output = EvalOutputSchema.parse(evaluator.evaluator.output);
6522
+ validateEvaluatorOutput(evaluator, output);
6523
+ return evaluator;
7100
6524
  }
7101
- async function artifactDigest(artifact) {
7102
- var _a;
7103
- if (!((_a = globalThis.crypto) == null ? void 0 : _a.subtle)) {
7104
- throw new Error("Raindrop portable evaluator requires Web Crypto SHA-256 support");
6525
+ function validateOptionalNumber(name, value, integer, allowZero) {
6526
+ if (value === void 0) return;
6527
+ const valid = Number.isFinite(value) && (!integer || Number.isInteger(value)) && (allowZero ? value >= 0 : value > 0);
6528
+ if (!valid) {
6529
+ const kind = integer ? "a positive integer" : allowZero ? "non-negative" : "positive";
6530
+ throw new Error(`Raindrop eval ${name} must be ${kind}`);
7105
6531
  }
7106
- const { sha256: _digest, ...unsigned } = artifact;
7107
- const encoded = new TextEncoder().encode(canonicalJson2(unsigned));
7108
- const digest = await globalThis.crypto.subtle.digest("SHA-256", encoded);
7109
- return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
7110
6532
  }
7111
- function canonicalJson2(value) {
7112
- if (value === null || typeof value !== "object") return JSON.stringify(value);
7113
- if (Array.isArray(value)) return `[${value.map(canonicalJson2).join(",")}]`;
7114
- return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson2(entry)}`).join(",")}}`;
6533
+ function parseBooleanThreshold(threshold) {
6534
+ return threshold === void 0 ? void 0 : BooleanThresholdSchema.parse(threshold);
7115
6535
  }
6536
+ function parseNumericThreshold(name, output, threshold) {
6537
+ const parsed = threshold === void 0 ? void 0 : NumericThresholdSchema.parse(threshold);
6538
+ if (output === "score" && parsed) {
6539
+ const lower = "gte" in parsed ? parsed.gte : void 0;
6540
+ const inRange = (lower === void 0 || lower >= 1 && lower <= 5) && (parsed.lte === void 0 || parsed.lte >= 1 && parsed.lte <= 5);
6541
+ if (!inRange)
6542
+ throw new Error(`Raindrop score evaluator ${name} thresholds must be from 1 to 5`);
6543
+ }
6544
+ return parsed;
6545
+ }
6546
+ var import_node_crypto2, import_zod4, EvalScoreSchema, EVAL_DATASET, DatasetRowInputSchema, EvalOutputSchema, EVAL_DEFINITION;
6547
+ var init_definition = __esm({
6548
+ "src/evals/definition.ts"() {
6549
+ "use strict";
6550
+ import_node_crypto2 = require("crypto");
6551
+ import_zod4 = require("zod");
6552
+ init_manifest();
6553
+ init_trace();
6554
+ init_manifest();
6555
+ EvalScoreSchema = import_zod4.z.union([
6556
+ import_zod4.z.literal(1),
6557
+ import_zod4.z.literal(2),
6558
+ import_zod4.z.literal(3),
6559
+ import_zod4.z.literal(4),
6560
+ import_zod4.z.literal(5)
6561
+ ]);
6562
+ EVAL_DATASET = /* @__PURE__ */ Symbol.for("raindrop.evalDataset");
6563
+ DatasetRowInputSchema = import_zod4.z.object({
6564
+ id: import_zod4.z.string().trim().min(1),
6565
+ name: import_zod4.z.string().optional(),
6566
+ input: import_zod4.z.string().nullable(),
6567
+ output: JsonValueSchema.default(null),
6568
+ properties: import_zod4.z.record(import_zod4.z.string()).default({})
6569
+ });
6570
+ EvalOutputSchema = import_zod4.z.enum(["boolean", "score", "number"]);
6571
+ EVAL_DEFINITION = /* @__PURE__ */ Symbol.for("raindrop.evalDefinition");
6572
+ }
6573
+ });
6574
+
6575
+ // src/evals/portable.ts
7116
6576
  var import_zod10, PortableEvalArtifactSchema, PortableEvalResultSchema;
7117
6577
  var init_portable = __esm({
7118
6578
  "src/evals/portable.ts"() {
@@ -7183,7 +6643,7 @@ var init_portable = __esm({
7183
6643
  var import_node_path = require("path");
7184
6644
  var import_node_url = require("url");
7185
6645
  var import_node_util = require("util");
7186
- var import_zod13 = require("zod");
6646
+ var import_zod12 = require("zod");
7187
6647
 
7188
6648
  // src/lib/inject-als.ts
7189
6649
  var import_node_async_hooks = require("async_hooks");
@@ -8798,12 +8258,12 @@ installTracingSuppressionHook();
8798
8258
 
8799
8259
  // ../schemas/dist/chunk-HA2X6666.js
8800
8260
  var __defProp2 = Object.defineProperty;
8801
- var __export2 = (target, all) => {
8261
+ var __export = (target, all) => {
8802
8262
  for (var name in all)
8803
8263
  __defProp2(target, name, { get: all[name], enumerable: true });
8804
8264
  };
8805
8265
  var external_exports = {};
8806
- __export2(external_exports, {
8266
+ __export(external_exports, {
8807
8267
  BRAND: () => BRAND,
8808
8268
  DIRTY: () => DIRTY,
8809
8269
  EMPTY_PATH: () => EMPTY_PATH,
@@ -12913,7 +12373,7 @@ var SignalEventSchema = external_exports.object({
12913
12373
  // package.json
12914
12374
  var package_default = {
12915
12375
  name: "raindrop-ai",
12916
- version: "0.8.0",
12376
+ version: "0.9.0",
12917
12377
  main: "dist/index.js",
12918
12378
  module: "dist/index.mjs",
12919
12379
  types: "dist/index.d.ts",
@@ -13159,9 +12619,9 @@ function recordExportedSpan(destination, span) {
13159
12619
  if (typeof span !== "object" && typeof span !== "function" || span === null) return;
13160
12620
  const spanContext = span.spanContext;
13161
12621
  if (typeof spanContext !== "function") return;
13162
- const context9 = spanContext.call(span);
13163
- if (typeof (context9 == null ? void 0 : context9.spanId) === "string" && typeof context9.traceId === "string") {
13164
- recordReplayExportedSpan(destination, context9.spanId, context9.traceId);
12622
+ const context8 = spanContext.call(span);
12623
+ if (typeof (context8 == null ? void 0 : context8.spanId) === "string" && typeof context8.traceId === "string") {
12624
+ recordReplayExportedSpan(destination, context8.spanId, context8.traceId);
13165
12625
  }
13166
12626
  }
13167
12627
  function createReplayExporter(destination) {
@@ -14758,16 +14218,16 @@ var LiveSubagentRun = class {
14758
14218
  };
14759
14219
 
14760
14220
  // src/tracing/liveInteraction.ts
14761
- function getPropertiesFromContext(context9) {
14221
+ function getPropertiesFromContext(context8) {
14762
14222
  const properties = {
14763
- ...context9.userId && { user_id: context9.userId },
14764
- ...context9.convoId && { convo_id: context9.convoId },
14765
- ...context9.eventId && { event_id: context9.eventId },
14766
- ...context9.event && { event_name: context9.event },
14767
- ...context9.properties || {}
14223
+ ...context8.userId && { user_id: context8.userId },
14224
+ ...context8.convoId && { convo_id: context8.convoId },
14225
+ ...context8.eventId && { event_id: context8.eventId },
14226
+ ...context8.event && { event_name: context8.event },
14227
+ ...context8.properties || {}
14768
14228
  };
14769
- if (context9.attachments && context9.attachments.length > 0) {
14770
- properties.attachments = stringifyBounded(context9.attachments);
14229
+ if (context8.attachments && context8.attachments.length > 0) {
14230
+ properties.attachments = stringifyBounded(context8.attachments);
14771
14231
  }
14772
14232
  return properties;
14773
14233
  }
@@ -14787,12 +14247,12 @@ function serializeAssociationProperties(properties) {
14787
14247
  function serializeSpanValue(value) {
14788
14248
  return stringifyBounded(value);
14789
14249
  }
14790
- function getLocalDebuggerMetadata(context9) {
14250
+ function getLocalDebuggerMetadata(context8) {
14791
14251
  return {
14792
- ...context9.eventId ? { eventId: context9.eventId } : {},
14793
- ...context9.event ? { eventName: context9.event } : {},
14794
- ...context9.userId ? { userId: context9.userId } : {},
14795
- ...context9.convoId ? { convoId: context9.convoId } : {}
14252
+ ...context8.eventId ? { eventId: context8.eventId } : {},
14253
+ ...context8.event ? { eventName: context8.event } : {},
14254
+ ...context8.userId ? { userId: context8.userId } : {},
14255
+ ...context8.convoId ? { convoId: context8.convoId } : {}
14796
14256
  };
14797
14257
  }
14798
14258
  var LiveToolSpan = class {
@@ -14893,9 +14353,9 @@ var DirectToolSpan = class {
14893
14353
  }
14894
14354
  };
14895
14355
  var LiveInteraction = class {
14896
- constructor(context9, traceId, analytics, directShipper, routing) {
14356
+ constructor(context8, traceId, analytics, directShipper, routing) {
14897
14357
  this.usageEmitted = false;
14898
- this.context = context9;
14358
+ this.context = context8;
14899
14359
  this.analytics = analytics;
14900
14360
  this.tracer = import_api4.trace.getTracer("traceloop.tracer");
14901
14361
  this.traceId = traceId;
@@ -16855,33 +16315,49 @@ var AttachmentTypeSchema = import_zod.z.enum(["code", "text", "image", "iframe"]
16855
16315
 
16856
16316
  // src/replay/index.ts
16857
16317
  var import_api7 = require("@opentelemetry/api");
16858
- var import_zod5 = require("zod");
16318
+ var import_zod6 = require("zod");
16859
16319
  init_definition();
16860
16320
 
16861
16321
  // src/evals/generated/dataset.ts
16862
- var import_zod4 = require("zod");
16322
+ var import_zod5 = require("zod");
16863
16323
  init_trace();
16864
16324
  var EVAL_DATASET_MAX_CASES = 1e3;
16865
16325
  var EVAL_DATASET_MAX_REQUEST_BYTES = 4 * 1024 * 1024;
16866
16326
  var EVAL_DATASET_MAX_REFERENCE_BYTES = 1024 * 1024;
16867
- var EvalDatasetSlugSchema = import_zod4.z.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/);
16868
- var EvalDatasetFingerprintSchema = import_zod4.z.string().regex(/^[0-9a-f]{64}$/);
16869
- var EvalDatasetCaseInputSchema = import_zod4.z.object({
16327
+ var EvalDatasetSlugSchema = import_zod5.z.string().min(1).max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/);
16328
+ var EvalDatasetFingerprintSchema = import_zod5.z.string().regex(/^[0-9a-f]{64}$/);
16329
+ var EvalDatasetEventSourceSchema = import_zod5.z.object({
16330
+ sourceEventId: import_zod5.z.string().trim().min(1).max(512),
16331
+ sourceEventTimestamp: import_zod5.z.string().datetime({ offset: true }).optional()
16332
+ }).strict();
16333
+ var EvalDatasetCaptureRefSchema = EvalDatasetEventSourceSchema.extend({
16334
+ id: EvalDatasetFingerprintSchema
16335
+ }).strict();
16336
+ var EvalReferenceVerdictSchema = import_zod5.z.union([
16337
+ import_zod5.z.object({ pass: import_zod5.z.boolean() }).strict(),
16338
+ import_zod5.z.object({ score: import_zod5.z.number().int().min(1).max(5) }).strict(),
16339
+ import_zod5.z.object({ value: import_zod5.z.number().finite() }).strict()
16340
+ ]);
16341
+ var EvalDatasetCaseInputSchema = import_zod5.z.object({
16870
16342
  id: EvalDatasetCaseIdSchema,
16871
- name: import_zod4.z.string().trim().min(1).max(200),
16872
- input: import_zod4.z.string().nullable(),
16873
- properties: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.string()),
16874
- referenceTrace: CapturedTraceSnapshotSchema.optional()
16343
+ name: import_zod5.z.string().trim().min(1).max(200),
16344
+ input: import_zod5.z.string().nullable(),
16345
+ output: JsonValueSchema.optional(),
16346
+ properties: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.string()),
16347
+ referenceTrace: CapturedTraceSnapshotSchema.optional(),
16348
+ referenceCapture: EvalDatasetCaptureRefSchema.optional(),
16349
+ expectation: EvalCaseExpectationSchema.optional(),
16350
+ expectedVerdict: EvalReferenceVerdictSchema.optional()
16875
16351
  }).strict();
16876
16352
  var EvalDatasetVersionCaseSchema = EvalDatasetCaseInputSchema.extend({
16877
16353
  referenceTraceSha256: EvalDatasetFingerprintSchema.optional()
16878
16354
  });
16879
- var EvalDatasetCaseInputsSchema = import_zod4.z.array(EvalDatasetCaseInputSchema).min(1).max(EVAL_DATASET_MAX_CASES).superRefine((cases, context9) => {
16355
+ var EvalDatasetCaseInputsSchema = import_zod5.z.array(EvalDatasetCaseInputSchema).min(1).max(EVAL_DATASET_MAX_CASES).superRefine((cases, context8) => {
16880
16356
  const seen = /* @__PURE__ */ new Set();
16881
16357
  for (const [index, entry] of cases.entries()) {
16882
16358
  if (seen.has(entry.id)) {
16883
- context9.addIssue({
16884
- code: import_zod4.z.ZodIssueCode.custom,
16359
+ context8.addIssue({
16360
+ code: import_zod5.z.ZodIssueCode.custom,
16885
16361
  message: `Duplicate row id ${entry.id}`,
16886
16362
  path: [index, "id"]
16887
16363
  });
@@ -16889,40 +16365,59 @@ var EvalDatasetCaseInputsSchema = import_zod4.z.array(EvalDatasetCaseInputSchema
16889
16365
  seen.add(entry.id);
16890
16366
  }
16891
16367
  });
16892
- var PublishEvalDatasetVersionInputSchema = import_zod4.z.object({
16893
- name: import_zod4.z.string().trim().min(1).max(100),
16894
- requestKey: import_zod4.z.string().uuid(),
16895
- expectedCurrentVersionId: import_zod4.z.string().uuid().nullable(),
16368
+ var PublishEvalDatasetVersionInputSchema = import_zod5.z.object({
16369
+ name: import_zod5.z.string().trim().min(1).max(100),
16370
+ requestKey: import_zod5.z.string().uuid(),
16371
+ expectedCurrentVersionId: import_zod5.z.string().uuid().nullable(),
16896
16372
  fingerprint: EvalDatasetFingerprintSchema,
16897
16373
  cases: EvalDatasetCaseInputsSchema
16898
16374
  }).strict();
16899
- var EvalDatasetIdentitySchema = import_zod4.z.object({
16900
- id: import_zod4.z.string().uuid(),
16375
+ var CaptureEvalDatasetCaseSchema = EvalDatasetCaseInputSchema.pick({
16376
+ id: true,
16377
+ name: true,
16378
+ properties: true,
16379
+ expectation: true,
16380
+ expectedVerdict: true
16381
+ }).merge(EvalDatasetEventSourceSchema).strict();
16382
+ var CaptureEvalDatasetVersionInputSchema = PublishEvalDatasetVersionInputSchema.omit({
16383
+ cases: true,
16384
+ fingerprint: true
16385
+ }).extend({
16386
+ requestKey: import_zod5.z.string().uuid().optional(),
16387
+ expectedCurrentVersionId: import_zod5.z.string().uuid().nullable().optional(),
16388
+ cases: import_zod5.z.array(CaptureEvalDatasetCaseSchema).min(1).max(EVAL_DATASET_MAX_CASES).refine((cases) => new Set(cases.map((entry) => entry.id)).size === cases.length, "Case IDs must be unique")
16389
+ }).strict();
16390
+ var EvalDatasetIdentitySchema = import_zod5.z.object({
16391
+ id: import_zod5.z.string().uuid(),
16901
16392
  slug: EvalDatasetSlugSchema,
16902
- name: import_zod4.z.string().min(1).max(100),
16903
- currentVersionId: import_zod4.z.string().uuid().nullable()
16393
+ name: import_zod5.z.string().min(1).max(100),
16394
+ currentVersionId: import_zod5.z.string().uuid().nullable()
16904
16395
  });
16905
- var EvalDatasetVersionSchema = import_zod4.z.object({
16906
- id: import_zod4.z.string().uuid(),
16907
- datasetId: import_zod4.z.string().uuid(),
16908
- parentVersionId: import_zod4.z.string().uuid().nullable(),
16396
+ var EvalDatasetVersionSchema = import_zod5.z.object({
16397
+ id: import_zod5.z.string().uuid(),
16398
+ datasetId: import_zod5.z.string().uuid(),
16399
+ parentVersionId: import_zod5.z.string().uuid().nullable(),
16909
16400
  fingerprint: EvalDatasetFingerprintSchema,
16910
- cases: import_zod4.z.array(EvalDatasetVersionCaseSchema).min(1).max(EVAL_DATASET_MAX_CASES),
16911
- createdAt: import_zod4.z.string().datetime({ offset: true })
16401
+ cases: import_zod5.z.array(EvalDatasetVersionCaseSchema).min(1).max(EVAL_DATASET_MAX_CASES),
16402
+ createdAt: import_zod5.z.string().datetime({ offset: true })
16912
16403
  });
16913
- var EvalDatasetManifestSchema = import_zod4.z.object({
16404
+ var EvalDatasetManifestSchema = import_zod5.z.object({
16914
16405
  dataset: EvalDatasetIdentitySchema,
16915
16406
  version: EvalDatasetVersionSchema.omit({ cases: true }),
16916
- cases: import_zod4.z.array(EvalDatasetVersionCaseSchema.pick({
16407
+ cases: import_zod5.z.array(EvalDatasetVersionCaseSchema.pick({
16917
16408
  id: true,
16918
16409
  name: true,
16919
16410
  input: true,
16411
+ output: true,
16920
16412
  properties: true
16921
16413
  }).extend({
16922
- referenceTraceSha256: EvalDatasetFingerprintSchema.optional()
16414
+ referenceTraceSha256: EvalDatasetFingerprintSchema.optional(),
16415
+ referenceCapture: EvalDatasetCaptureRefSchema.optional(),
16416
+ expectation: EvalCaseExpectationSchema.optional(),
16417
+ expectedVerdict: EvalReferenceVerdictSchema.optional()
16923
16418
  }))
16924
16419
  });
16925
- function compareNanoseconds2(left, right) {
16420
+ function compareNanoseconds(left, right) {
16926
16421
  const leftValue = BigInt(left);
16927
16422
  const rightValue = BigInt(right);
16928
16423
  return leftValue < rightValue ? -1 : leftValue > rightValue ? 1 : 0;
@@ -16930,7 +16425,7 @@ function compareNanoseconds2(left, right) {
16930
16425
  function orderSnapshot(snapshot) {
16931
16426
  return {
16932
16427
  event: snapshot.event,
16933
- spans: [...snapshot.spans].sort((left, right) => compareNanoseconds2(left.start_unix_ns, right.start_unix_ns) || left.span_id.localeCompare(right.span_id))
16428
+ spans: [...snapshot.spans].sort((left, right) => compareNanoseconds(left.start_unix_ns, right.start_unix_ns) || left.span_id.localeCompare(right.span_id))
16934
16429
  };
16935
16430
  }
16936
16431
  function normalizeCasesForFingerprint(cases) {
@@ -17007,115 +16502,116 @@ function retryDelayMs(response, retry) {
17007
16502
  }
17008
16503
  return EVAL_RETRY_BASE_DELAY_MS * 2 ** retry;
17009
16504
  }
17010
- var ReplayRowSchema = import_zod5.z.object({
17011
- id: import_zod5.z.string(),
17012
- name: import_zod5.z.string(),
17013
- input: import_zod5.z.string().nullable(),
17014
- output: import_zod5.z.string().nullable(),
17015
- properties: import_zod5.z.record(import_zod5.z.string())
16505
+ var ReplayRowSchema = import_zod6.z.object({
16506
+ id: import_zod6.z.string(),
16507
+ name: import_zod6.z.string(),
16508
+ input: import_zod6.z.string().nullable(),
16509
+ output: JsonValueSchema,
16510
+ properties: import_zod6.z.record(import_zod6.z.string())
17016
16511
  });
17017
- var WireEvalManifestSchema = import_zod5.z.object({
17018
- dataset_id: import_zod5.z.string().uuid(),
17019
- fingerprint: import_zod5.z.string().regex(/^[a-f0-9]{64}$/),
17020
- rows: import_zod5.z.array(ReplayRowSchema.extend({ id: import_zod5.z.string().min(1) }))
16512
+ var WireEvalManifestSchema = import_zod6.z.object({
16513
+ dataset_id: import_zod6.z.string().uuid(),
16514
+ dataset_version_id: import_zod6.z.string().uuid().optional(),
16515
+ fingerprint: import_zod6.z.string().regex(/^[a-f0-9]{64}$/),
16516
+ rows: import_zod6.z.array(ReplayRowSchema.extend({ id: import_zod6.z.string().min(1) }))
17021
16517
  });
17022
- var ReplayCountsSchema = import_zod5.z.object({
17023
- total: import_zod5.z.number(),
17024
- pending: import_zod5.z.number(),
17025
- done: import_zod5.z.number(),
17026
- missing: import_zod5.z.number()
16518
+ var ReplayCountsSchema = import_zod6.z.object({
16519
+ total: import_zod6.z.number(),
16520
+ pending: import_zod6.z.number(),
16521
+ done: import_zod6.z.number(),
16522
+ missing: import_zod6.z.number()
17027
16523
  });
17028
- var ReplayEvaluatorCountsSchema = import_zod5.z.object({
17029
- traces: import_zod5.z.number(),
17030
- graded: import_zod5.z.number(),
17031
- errored: import_zod5.z.number(),
17032
- ungraded: import_zod5.z.number(),
17033
- pending: import_zod5.z.number()
16524
+ var ReplayEvaluatorCountsSchema = import_zod6.z.object({
16525
+ traces: import_zod6.z.number(),
16526
+ graded: import_zod6.z.number(),
16527
+ errored: import_zod6.z.number(),
16528
+ ungraded: import_zod6.z.number(),
16529
+ pending: import_zod6.z.number()
17034
16530
  });
17035
- var ReplayEvaluatorStatsSchema = import_zod5.z.object({
17036
- traceCount: import_zod5.z.number(),
17037
- hydratedCount: import_zod5.z.number(),
17038
- judgeCalls: import_zod5.z.number(),
17039
- durationMs: import_zod5.z.number(),
17040
- skippedRows: import_zod5.z.number(),
17041
- skippedReason: import_zod5.z.literal("no trace").nullable()
16531
+ var ReplayEvaluatorStatsSchema = import_zod6.z.object({
16532
+ traceCount: import_zod6.z.number(),
16533
+ hydratedCount: import_zod6.z.number(),
16534
+ judgeCalls: import_zod6.z.number(),
16535
+ durationMs: import_zod6.z.number(),
16536
+ skippedRows: import_zod6.z.number(),
16537
+ skippedReason: import_zod6.z.literal("no trace").nullable()
17042
16538
  });
17043
- var ReplayEvaluatorSummarySchema = import_zod5.z.discriminatedUnion("outputType", [
17044
- import_zod5.z.object({
17045
- outputType: import_zod5.z.literal("boolean"),
16539
+ var ReplayEvaluatorSummarySchema = import_zod6.z.discriminatedUnion("outputType", [
16540
+ import_zod6.z.object({
16541
+ outputType: import_zod6.z.literal("boolean"),
17046
16542
  counts: ReplayEvaluatorCountsSchema,
17047
16543
  stats: ReplayEvaluatorStatsSchema,
17048
- passed: import_zod5.z.number(),
17049
- failed: import_zod5.z.number(),
17050
- passRate: import_zod5.z.number().nullable()
16544
+ passed: import_zod6.z.number(),
16545
+ failed: import_zod6.z.number(),
16546
+ passRate: import_zod6.z.number().nullable()
17051
16547
  }),
17052
- import_zod5.z.object({
17053
- outputType: import_zod5.z.literal("score"),
16548
+ import_zod6.z.object({
16549
+ outputType: import_zod6.z.literal("score"),
17054
16550
  counts: ReplayEvaluatorCountsSchema,
17055
16551
  stats: ReplayEvaluatorStatsSchema,
17056
- mean: import_zod5.z.number().nullable(),
17057
- median: import_zod5.z.number().nullable(),
17058
- p10: import_zod5.z.number().nullable(),
17059
- p90: import_zod5.z.number().nullable(),
17060
- atLeast4Share: import_zod5.z.number().nullable(),
17061
- histogram: import_zod5.z.tuple([import_zod5.z.number(), import_zod5.z.number(), import_zod5.z.number(), import_zod5.z.number(), import_zod5.z.number()])
16552
+ mean: import_zod6.z.number().nullable(),
16553
+ median: import_zod6.z.number().nullable(),
16554
+ p10: import_zod6.z.number().nullable(),
16555
+ p90: import_zod6.z.number().nullable(),
16556
+ atLeast4Share: import_zod6.z.number().nullable(),
16557
+ histogram: import_zod6.z.tuple([import_zod6.z.number(), import_zod6.z.number(), import_zod6.z.number(), import_zod6.z.number(), import_zod6.z.number()])
17062
16558
  }),
17063
- import_zod5.z.object({
17064
- outputType: import_zod5.z.literal("number"),
16559
+ import_zod6.z.object({
16560
+ outputType: import_zod6.z.literal("number"),
17065
16561
  counts: ReplayEvaluatorCountsSchema,
17066
16562
  stats: ReplayEvaluatorStatsSchema,
17067
- median: import_zod5.z.number().nullable(),
17068
- p10: import_zod5.z.number().nullable(),
17069
- p90: import_zod5.z.number().nullable()
16563
+ median: import_zod6.z.number().nullable(),
16564
+ p10: import_zod6.z.number().nullable(),
16565
+ p90: import_zod6.z.number().nullable()
17070
16566
  })
17071
16567
  ]);
17072
- var ReplayVerdictIdentitySchema = import_zod5.z.object({
17073
- evaluator: import_zod5.z.string(),
17074
- runId: import_zod5.z.string(),
17075
- url: import_zod5.z.string()
16568
+ var ReplayVerdictIdentitySchema = import_zod6.z.object({
16569
+ evaluator: import_zod6.z.string(),
16570
+ runId: import_zod6.z.string(),
16571
+ url: import_zod6.z.string()
17076
16572
  });
17077
16573
  var ReplayVerdictGradedSchema = ReplayVerdictIdentitySchema.extend({
17078
- state: import_zod5.z.literal("graded"),
17079
- note: import_zod5.z.string().optional()
16574
+ state: import_zod6.z.literal("graded"),
16575
+ note: import_zod6.z.string().optional()
17080
16576
  });
17081
- var ReplayVerdictSchema = import_zod5.z.union([
17082
- ReplayVerdictGradedSchema.extend({ pass: import_zod5.z.boolean() }),
16577
+ var ReplayVerdictSchema = import_zod6.z.union([
16578
+ ReplayVerdictGradedSchema.extend({ pass: import_zod6.z.boolean() }),
17083
16579
  ReplayVerdictGradedSchema.extend({ score: EvalScoreSchema }),
17084
- ReplayVerdictGradedSchema.extend({ value: import_zod5.z.number().finite() }),
16580
+ ReplayVerdictGradedSchema.extend({ value: import_zod6.z.number().finite() }),
17085
16581
  ReplayVerdictIdentitySchema.extend({
17086
- state: import_zod5.z.literal("errored"),
17087
- message: import_zod5.z.string()
16582
+ state: import_zod6.z.literal("errored"),
16583
+ message: import_zod6.z.string()
17088
16584
  }),
17089
16585
  ReplayVerdictIdentitySchema.extend({
17090
- state: import_zod5.z.literal("ungraded"),
17091
- reason: import_zod5.z.enum(["not sampled", "trace unavailable", "content unreadable"])
16586
+ state: import_zod6.z.literal("ungraded"),
16587
+ reason: import_zod6.z.enum(["not sampled", "trace unavailable", "content unreadable"])
17092
16588
  })
17093
16589
  ]);
17094
16590
  var ReplayResultRowSchema = ReplayRowSchema.extend({
17095
- status: import_zod5.z.enum(["pending", "done", "missing"]),
17096
- traceId: import_zod5.z.string().nullable(),
17097
- error: import_zod5.z.string().nullable(),
17098
- verdicts: import_zod5.z.array(ReplayVerdictSchema)
16591
+ status: import_zod6.z.enum(["pending", "done", "missing"]),
16592
+ traceId: import_zod6.z.string().nullable(),
16593
+ error: import_zod6.z.string().nullable(),
16594
+ verdicts: import_zod6.z.array(ReplayVerdictSchema)
17099
16595
  });
17100
- var ReplayTraceEvidenceEntrySchema = import_zod5.z.object({
17101
- rowId: import_zod5.z.string().min(1).max(512),
17102
- traceId: import_zod5.z.string().regex(/^[a-f0-9]{32}$/),
17103
- spanIds: import_zod5.z.array(import_zod5.z.string().regex(/^[a-f0-9]{16}$/)).min(1).max(500)
17104
- }).superRefine((entry, context9) => {
16596
+ var ReplayTraceEvidenceEntrySchema = import_zod6.z.object({
16597
+ rowId: import_zod6.z.string().min(1).max(512),
16598
+ traceId: import_zod6.z.string().regex(/^[a-f0-9]{32}$/),
16599
+ spanIds: import_zod6.z.array(import_zod6.z.string().regex(/^[a-f0-9]{16}$/)).min(1).max(500)
16600
+ }).superRefine((entry, context8) => {
17105
16601
  if (new Set(entry.spanIds).size !== entry.spanIds.length) {
17106
- context9.addIssue({
17107
- code: import_zod5.z.ZodIssueCode.custom,
16602
+ context8.addIssue({
16603
+ code: import_zod6.z.ZodIssueCode.custom,
17108
16604
  message: "Replay trace evidence span ids must be unique",
17109
16605
  path: ["spanIds"]
17110
16606
  });
17111
16607
  }
17112
16608
  });
17113
- var ReplayTraceEvidenceSchema = import_zod5.z.array(ReplayTraceEvidenceEntrySchema).superRefine((entries, context9) => {
16609
+ var ReplayTraceEvidenceSchema = import_zod6.z.array(ReplayTraceEvidenceEntrySchema).superRefine((entries, context8) => {
17114
16610
  const seen = /* @__PURE__ */ new Set();
17115
16611
  for (const [index, entry] of entries.entries()) {
17116
16612
  if (seen.has(entry.rowId)) {
17117
- context9.addIssue({
17118
- code: import_zod5.z.ZodIssueCode.custom,
16613
+ context8.addIssue({
16614
+ code: import_zod6.z.ZodIssueCode.custom,
17119
16615
  message: "Replay trace evidence row ids must be unique",
17120
16616
  path: [index, "rowId"]
17121
16617
  });
@@ -17123,13 +16619,13 @@ var ReplayTraceEvidenceSchema = import_zod5.z.array(ReplayTraceEvidenceEntrySche
17123
16619
  seen.add(entry.rowId);
17124
16620
  }
17125
16621
  });
17126
- var LocalBooleanVerdictSchema = import_zod5.z.object({ pass: import_zod5.z.boolean(), note: import_zod5.z.string().trim().min(1).max(600).optional() }).strict();
17127
- var LocalScoreVerdictSchema = import_zod5.z.object({
16622
+ var LocalBooleanVerdictSchema = import_zod6.z.object({ pass: import_zod6.z.boolean(), note: import_zod6.z.string().trim().min(1).max(600).optional() }).strict();
16623
+ var LocalScoreVerdictSchema = import_zod6.z.object({
17128
16624
  score: EvalScoreSchema,
17129
- note: import_zod5.z.string().trim().min(1).max(600).optional()
16625
+ note: import_zod6.z.string().trim().min(1).max(600).optional()
17130
16626
  }).strict();
17131
- var LocalNumberVerdictSchema = import_zod5.z.object({ value: import_zod5.z.number().finite(), note: import_zod5.z.string().trim().min(1).max(600).optional() }).strict();
17132
- var LocalVerdictSchema = import_zod5.z.union([
16627
+ var LocalNumberVerdictSchema = import_zod6.z.object({ value: import_zod6.z.number().finite(), note: import_zod6.z.string().trim().min(1).max(600).optional() }).strict();
16628
+ var LocalVerdictSchema = import_zod6.z.union([
17133
16629
  LocalBooleanVerdictSchema,
17134
16630
  LocalScoreVerdictSchema,
17135
16631
  LocalNumberVerdictSchema
@@ -17205,50 +16701,50 @@ async function queryApi(request) {
17205
16701
  return parsed.data;
17206
16702
  }
17207
16703
  }
17208
- var ReplayStatusSchema = import_zod5.z.enum(["queued", "running", "complete", "failed"]);
17209
- var ReplayRowStatusSchema = import_zod5.z.enum(["pending", "done", "missing"]);
17210
- var WireReplaySchema = import_zod5.z.object({
17211
- id: import_zod5.z.string(),
16704
+ var ReplayStatusSchema = import_zod6.z.enum(["queued", "running", "complete", "failed"]);
16705
+ var ReplayRowStatusSchema = import_zod6.z.enum(["pending", "done", "missing"]);
16706
+ var WireReplaySchema = import_zod6.z.object({
16707
+ id: import_zod6.z.string(),
17212
16708
  status: ReplayStatusSchema,
17213
16709
  counts: ReplayCountsSchema,
17214
- traces_expire_at: import_zod5.z.string(),
17215
- traces_expired: import_zod5.z.boolean()
16710
+ traces_expire_at: import_zod6.z.string(),
16711
+ traces_expired: import_zod6.z.boolean()
17216
16712
  });
17217
- var WireRowSchema = import_zod5.z.object({
17218
- row_id: import_zod5.z.string(),
17219
- attempt: import_zod5.z.number().int().nonnegative(),
16713
+ var WireRowSchema = import_zod6.z.object({
16714
+ row_id: import_zod6.z.string(),
16715
+ attempt: import_zod6.z.number().int().nonnegative(),
17220
16716
  status: ReplayRowStatusSchema,
17221
- trace_id: import_zod5.z.string().nullable(),
17222
- error: import_zod5.z.string().nullable()
16717
+ trace_id: import_zod6.z.string().nullable(),
16718
+ error: import_zod6.z.string().nullable()
17223
16719
  });
17224
- var WirePlanSchema = import_zod5.z.object({
16720
+ var WirePlanSchema = import_zod6.z.object({
17225
16721
  replay: WireReplaySchema,
17226
- ingest_url: import_zod5.z.string().min(1).nullable(),
17227
- rows: import_zod5.z.array(
16722
+ ingest_url: import_zod6.z.string().min(1).nullable(),
16723
+ rows: import_zod6.z.array(
17228
16724
  ReplayRowSchema.omit({ id: true }).extend({
17229
- row_id: import_zod5.z.string(),
17230
- attempt: import_zod5.z.literal(0),
17231
- correlation_id: import_zod5.z.string()
16725
+ row_id: import_zod6.z.string(),
16726
+ attempt: import_zod6.z.literal(0),
16727
+ correlation_id: import_zod6.z.string()
17232
16728
  })
17233
16729
  )
17234
16730
  });
17235
- var WireReplayDetailSchema = import_zod5.z.object({
16731
+ var WireReplayDetailSchema = import_zod6.z.object({
17236
16732
  replay: WireReplaySchema,
17237
- rows: import_zod5.z.array(WireRowSchema)
16733
+ rows: import_zod6.z.array(WireRowSchema)
17238
16734
  });
17239
16735
  var EvalRunDetailSchema = WireReplayDetailSchema.extend({
17240
16736
  replay: WireReplaySchema.extend({
17241
- dataset_id: import_zod5.z.string().uuid(),
17242
- dataset_version_id: import_zod5.z.string().uuid().nullable()
16737
+ dataset_id: import_zod6.z.string().uuid(),
16738
+ dataset_version_id: import_zod6.z.string().uuid().nullable()
17243
16739
  }),
17244
- eval_runs: import_zod5.z.array(
17245
- import_zod5.z.object({
17246
- id: import_zod5.z.string().uuid(),
17247
- eval_id: import_zod5.z.string().uuid(),
17248
- program_version: import_zod5.z.number().int().positive(),
17249
- output_type: import_zod5.z.enum(["boolean", "score", "number"]),
17250
- executed_by: import_zod5.z.enum(["hosted", "local"]),
17251
- status: import_zod5.z.enum(["running", "completed", "failed"])
16740
+ eval_runs: import_zod6.z.array(
16741
+ import_zod6.z.object({
16742
+ id: import_zod6.z.string().uuid(),
16743
+ eval_id: import_zod6.z.string().uuid(),
16744
+ program_version: import_zod6.z.number().int().positive(),
16745
+ output_type: import_zod6.z.enum(["boolean", "score", "number"]),
16746
+ executed_by: import_zod6.z.enum(["hosted", "local"]),
16747
+ status: import_zod6.z.enum(["running", "completed", "failed"])
17252
16748
  })
17253
16749
  )
17254
16750
  });
@@ -17264,118 +16760,118 @@ async function readReplayDetails(client, runId, options = {}) {
17264
16760
  if (detail.replay.id !== runId) throw new Error("Raindrop returned a different run");
17265
16761
  return detail;
17266
16762
  }
17267
- var WireReportSchema = import_zod5.z.object({ status: import_zod5.z.string() });
17268
- var WireAttemptStartedSchema = import_zod5.z.object({
17269
- status: import_zod5.z.literal("pending"),
17270
- row: import_zod5.z.object({
17271
- row_id: import_zod5.z.string().min(1),
17272
- attempt: import_zod5.z.number().int().positive(),
17273
- correlation_id: import_zod5.z.string().min(1)
16763
+ var WireReportSchema = import_zod6.z.object({ status: import_zod6.z.string() });
16764
+ var WireAttemptStartedSchema = import_zod6.z.object({
16765
+ status: import_zod6.z.literal("pending"),
16766
+ row: import_zod6.z.object({
16767
+ row_id: import_zod6.z.string().min(1),
16768
+ attempt: import_zod6.z.number().int().positive(),
16769
+ correlation_id: import_zod6.z.string().min(1)
17274
16770
  })
17275
16771
  });
17276
- var WireLocalEvaluatorSchema = import_zod5.z.object({
17277
- data: import_zod5.z.object({
17278
- id: import_zod5.z.string().uuid(),
17279
- slug: import_zod5.z.string(),
17280
- name: import_zod5.z.string(),
17281
- output: import_zod5.z.enum(["boolean", "score", "number"]),
17282
- kind: import_zod5.z.literal("local"),
17283
- programVersion: import_zod5.z.number().int().positive()
16772
+ var WireLocalEvaluatorSchema = import_zod6.z.object({
16773
+ data: import_zod6.z.object({
16774
+ id: import_zod6.z.string().uuid(),
16775
+ slug: import_zod6.z.string(),
16776
+ name: import_zod6.z.string(),
16777
+ output: import_zod6.z.enum(["boolean", "score", "number"]),
16778
+ kind: import_zod6.z.literal("local"),
16779
+ programVersion: import_zod6.z.number().int().positive()
17284
16780
  })
17285
16781
  });
17286
- var WireStartedEvalRunSchema = import_zod5.z.object({
17287
- data: import_zod5.z.object({
17288
- runId: import_zod5.z.string(),
17289
- status: import_zod5.z.literal("running"),
17290
- url: import_zod5.z.string(),
17291
- evalId: import_zod5.z.string().uuid().optional(),
17292
- programVersion: import_zod5.z.number().int().positive().optional()
16782
+ var WireStartedEvalRunSchema = import_zod6.z.object({
16783
+ data: import_zod6.z.object({
16784
+ runId: import_zod6.z.string(),
16785
+ status: import_zod6.z.literal("running"),
16786
+ url: import_zod6.z.string(),
16787
+ evalId: import_zod6.z.string().uuid().optional(),
16788
+ programVersion: import_zod6.z.number().int().positive().optional()
17293
16789
  })
17294
16790
  });
17295
- var WireEvalRunSchema = import_zod5.z.object({
17296
- data: import_zod5.z.object({
17297
- id: import_zod5.z.string(),
17298
- evalSlug: import_zod5.z.string(),
17299
- status: import_zod5.z.enum(["running", "completed", "failed"]),
16791
+ var WireEvalRunSchema = import_zod6.z.object({
16792
+ data: import_zod6.z.object({
16793
+ id: import_zod6.z.string(),
16794
+ evalSlug: import_zod6.z.string(),
16795
+ status: import_zod6.z.enum(["running", "completed", "failed"]),
17300
16796
  summary: ReplayEvaluatorSummarySchema.nullable(),
17301
- error: import_zod5.z.string().nullable(),
17302
- traces: import_zod5.z.array(
17303
- import_zod5.z.union([
17304
- import_zod5.z.object({
17305
- state: import_zod5.z.literal("graded"),
17306
- traceId: import_zod5.z.string(),
17307
- pass: import_zod5.z.boolean(),
17308
- note: import_zod5.z.string().optional()
16797
+ error: import_zod6.z.string().nullable(),
16798
+ traces: import_zod6.z.array(
16799
+ import_zod6.z.union([
16800
+ import_zod6.z.object({
16801
+ state: import_zod6.z.literal("graded"),
16802
+ traceId: import_zod6.z.string(),
16803
+ pass: import_zod6.z.boolean(),
16804
+ note: import_zod6.z.string().optional()
17309
16805
  }),
17310
- import_zod5.z.object({
17311
- state: import_zod5.z.literal("graded"),
17312
- traceId: import_zod5.z.string(),
16806
+ import_zod6.z.object({
16807
+ state: import_zod6.z.literal("graded"),
16808
+ traceId: import_zod6.z.string(),
17313
16809
  score: EvalScoreSchema,
17314
- note: import_zod5.z.string().optional()
16810
+ note: import_zod6.z.string().optional()
17315
16811
  }),
17316
- import_zod5.z.object({
17317
- state: import_zod5.z.literal("graded"),
17318
- traceId: import_zod5.z.string(),
17319
- value: import_zod5.z.number().finite(),
17320
- note: import_zod5.z.string().optional()
16812
+ import_zod6.z.object({
16813
+ state: import_zod6.z.literal("graded"),
16814
+ traceId: import_zod6.z.string(),
16815
+ value: import_zod6.z.number().finite(),
16816
+ note: import_zod6.z.string().optional()
17321
16817
  }),
17322
- import_zod5.z.object({ state: import_zod5.z.literal("errored"), traceId: import_zod5.z.string(), message: import_zod5.z.string() }),
17323
- import_zod5.z.object({
17324
- state: import_zod5.z.literal("ungraded"),
17325
- traceId: import_zod5.z.string(),
17326
- reason: import_zod5.z.enum(["not sampled", "trace unavailable", "content unreadable"])
16818
+ import_zod6.z.object({ state: import_zod6.z.literal("errored"), traceId: import_zod6.z.string(), message: import_zod6.z.string() }),
16819
+ import_zod6.z.object({
16820
+ state: import_zod6.z.literal("ungraded"),
16821
+ traceId: import_zod6.z.string(),
16822
+ reason: import_zod6.z.enum(["not sampled", "trace unavailable", "content unreadable"])
17327
16823
  })
17328
16824
  ])
17329
16825
  )
17330
16826
  })
17331
16827
  });
17332
- var WireLocalEvalRunSchema = import_zod5.z.object({
17333
- data: WireEvalRunSchema.shape.data.extend({ status: import_zod5.z.literal("completed"), url: import_zod5.z.string() })
16828
+ var WireLocalEvalRunSchema = import_zod6.z.object({
16829
+ data: WireEvalRunSchema.shape.data.extend({ status: import_zod6.z.literal("completed"), url: import_zod6.z.string() })
17334
16830
  });
17335
- var WireLocalEvalRunStartedSchema = import_zod5.z.object({
17336
- data: WireEvalRunSchema.shape.data.omit({ traces: true }).extend({ status: import_zod5.z.literal("running"), url: import_zod5.z.string() })
16831
+ var WireLocalEvalRunStartedSchema = import_zod6.z.object({
16832
+ data: WireEvalRunSchema.shape.data.omit({ traces: true }).extend({ status: import_zod6.z.literal("running"), url: import_zod6.z.string() })
17337
16833
  });
17338
- var WireLocalEvalAttemptSchema = import_zod5.z.object({
17339
- data: import_zod5.z.object({
17340
- runId: import_zod5.z.string().uuid(),
17341
- requestId: import_zod5.z.string().uuid(),
17342
- rowId: import_zod5.z.string().min(1),
17343
- attempt: import_zod5.z.number().int().nonnegative(),
17344
- traceId: import_zod5.z.string().regex(/^[a-f0-9]{32}$/),
16834
+ var WireLocalEvalAttemptSchema = import_zod6.z.object({
16835
+ data: import_zod6.z.object({
16836
+ runId: import_zod6.z.string().uuid(),
16837
+ requestId: import_zod6.z.string().uuid(),
16838
+ rowId: import_zod6.z.string().min(1),
16839
+ attempt: import_zod6.z.number().int().nonnegative(),
16840
+ traceId: import_zod6.z.string().regex(/^[a-f0-9]{32}$/),
17345
16841
  outcome: WireEvalRunSchema.shape.data.shape.traces.element
17346
16842
  })
17347
16843
  });
17348
- var WireEvalCaseTracePairReadSchema = import_zod5.z.discriminatedUnion("state", [
16844
+ var WireEvalCaseTracePairReadSchema = import_zod6.z.discriminatedUnion("state", [
17349
16845
  EvalCaseTracePairSchema.extend({
17350
- state: import_zod5.z.literal("ready"),
17351
- attempt: import_zod5.z.number().int().nonnegative(),
17352
- datasetVersion: import_zod5.z.object({
17353
- id: import_zod5.z.string().uuid(),
16846
+ state: import_zod6.z.literal("ready"),
16847
+ attempt: import_zod6.z.number().int().nonnegative(),
16848
+ datasetVersion: import_zod6.z.object({
16849
+ id: import_zod6.z.string().uuid(),
17354
16850
  fingerprint: EvalDatasetFingerprintSchema
17355
16851
  })
17356
16852
  }),
17357
- import_zod5.z.object({
17358
- state: import_zod5.z.literal("pending"),
17359
- caseId: import_zod5.z.string().min(1),
17360
- attempt: import_zod5.z.number().int().nonnegative()
16853
+ import_zod6.z.object({
16854
+ state: import_zod6.z.literal("pending"),
16855
+ caseId: import_zod6.z.string().min(1),
16856
+ attempt: import_zod6.z.number().int().nonnegative()
17361
16857
  }),
17362
- import_zod5.z.object({
17363
- state: import_zod5.z.literal("missing"),
17364
- caseId: import_zod5.z.string().min(1),
17365
- attempt: import_zod5.z.number().int().nonnegative(),
17366
- reason: import_zod5.z.string()
16858
+ import_zod6.z.object({
16859
+ state: import_zod6.z.literal("missing"),
16860
+ caseId: import_zod6.z.string().min(1),
16861
+ attempt: import_zod6.z.number().int().nonnegative(),
16862
+ reason: import_zod6.z.string()
17367
16863
  }),
17368
- import_zod5.z.object({
17369
- state: import_zod5.z.literal("expired"),
17370
- caseId: import_zod5.z.string().min(1),
17371
- attempt: import_zod5.z.number().int().nonnegative(),
17372
- expiredAt: import_zod5.z.string().datetime({ offset: true })
16864
+ import_zod6.z.object({
16865
+ state: import_zod6.z.literal("expired"),
16866
+ caseId: import_zod6.z.string().min(1),
16867
+ attempt: import_zod6.z.number().int().nonnegative(),
16868
+ expiredAt: import_zod6.z.string().datetime({ offset: true })
17373
16869
  }),
17374
- import_zod5.z.object({
17375
- state: import_zod5.z.literal("errored"),
17376
- caseId: import_zod5.z.string().min(1),
17377
- attempt: import_zod5.z.number().int().nonnegative(),
17378
- reason: import_zod5.z.string()
16870
+ import_zod6.z.object({
16871
+ state: import_zod6.z.literal("errored"),
16872
+ caseId: import_zod6.z.string().min(1),
16873
+ attempt: import_zod6.z.number().int().nonnegative(),
16874
+ reason: import_zod6.z.string()
17379
16875
  })
17380
16876
  ]);
17381
16877
  var replayGitSnapshots = /* @__PURE__ */ new WeakMap();
@@ -17545,7 +17041,7 @@ async function readEvalDataset(client, dataset, options) {
17545
17041
  var _a;
17546
17042
  const slug = EvalDatasetSlugSchema.parse(dataset.trim());
17547
17043
  const versionId = options == null ? void 0 : options.versionId;
17548
- if (versionId !== void 0 && !import_zod5.z.string().uuid().safeParse(versionId).success) {
17044
+ if (versionId !== void 0 && !import_zod6.z.string().uuid().safeParse(versionId).success) {
17549
17045
  throw new Error("Raindrop eval dataset versionId must be a UUID");
17550
17046
  }
17551
17047
  const path = versionId ? `/v1/eval-datasets/${encodeURIComponent(slug)}/versions/${encodeURIComponent(versionId)}` : `/v1/eval-datasets/${encodeURIComponent(slug)}`;
@@ -17558,7 +17054,7 @@ async function readEvalDataset(client, dataset, options) {
17558
17054
  schema: EvalDatasetManifestSchema
17559
17055
  })
17560
17056
  );
17561
- if (manifest.dataset.slug !== slug) {
17057
+ if (manifest.dataset.slug !== slug && manifest.dataset.id !== slug) {
17562
17058
  throw new Error(`Raindrop eval dataset ${slug} returned mismatched dataset identity`);
17563
17059
  }
17564
17060
  if (versionId !== void 0 && manifest.version.id !== versionId) {
@@ -18151,7 +17647,7 @@ async function validateReferenceRequirements(client, dataset, rowIds, evaluators
18151
17647
  queryUrl,
18152
17648
  path: `/v1/evals/${encodeURIComponent(evaluator)}`,
18153
17649
  method: "GET",
18154
- schema: import_zod5.z.object({ data: import_zod5.z.object({ requiresReference: import_zod5.z.boolean() }) })
17650
+ schema: import_zod6.z.object({ data: import_zod6.z.object({ requiresReference: import_zod6.z.boolean() }) })
18155
17651
  })).data.requiresReference : evaluator.requiresReference === true;
18156
17652
  if (requiresReference) {
18157
17653
  const name = typeof evaluator === "string" ? evaluator : evaluator.slug;
@@ -18616,7 +18112,7 @@ function validateEvaluatorPins(evaluators, raw) {
18616
18112
  if (!allowed.has(slug)) {
18617
18113
  throw new Error(`Raindrop evaluator pin names unknown evaluator ${slug}`);
18618
18114
  }
18619
- if (!import_zod5.z.string().uuid().safeParse(pin.expectedEvalId).success) {
18115
+ if (!import_zod6.z.string().uuid().safeParse(pin.expectedEvalId).success) {
18620
18116
  throw new Error(`Raindrop evaluator ${slug} pin has an invalid evaluator id`);
18621
18117
  }
18622
18118
  if (!Number.isInteger(pin.expectedProgramVersion) || pin.expectedProgramVersion <= 0) {
@@ -18671,12 +18167,15 @@ function describeError(cause) {
18671
18167
  return String(cause);
18672
18168
  }
18673
18169
 
18170
+ // src/evals/index.ts
18171
+ init_manifest();
18172
+
18674
18173
  // src/evals/agent.ts
18675
- var import_zod6 = require("zod");
18676
- var AgentMetadataSchema = import_zod6.z.object({
18677
- slug: import_zod6.z.string().trim().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
18678
- name: import_zod6.z.string().trim().min(1).max(120),
18679
- description: import_zod6.z.string().max(2e3).optional()
18174
+ var import_zod7 = require("zod");
18175
+ var AgentMetadataSchema = import_zod7.z.object({
18176
+ slug: import_zod7.z.string().trim().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
18177
+ name: import_zod7.z.string().trim().min(1).max(120),
18178
+ description: import_zod7.z.string().max(2e3).optional()
18680
18179
  });
18681
18180
  async function finishWith(execution, work) {
18682
18181
  let result;
@@ -18691,11 +18190,11 @@ async function finishWith(execution, work) {
18691
18190
  }
18692
18191
 
18693
18192
  // src/evals/server.ts
18694
- var import_zod7 = require("zod");
18695
- var InvocationSchema = import_zod7.z.object({
18696
- runId: import_zod7.z.string().uuid(),
18697
- agent: import_zod7.z.string().min(1).max(64),
18698
- parameters: import_zod7.z.record(import_zod7.z.unknown()).default({})
18193
+ var import_zod8 = require("zod");
18194
+ var InvocationSchema = import_zod8.z.object({
18195
+ runId: import_zod8.z.string().uuid(),
18196
+ agent: import_zod8.z.string().min(1).max(64),
18197
+ parameters: import_zod8.z.record(import_zod8.z.unknown()).default({})
18699
18198
  });
18700
18199
  var MAX_BODY_BYTES = 64 * 1024;
18701
18200
 
@@ -18851,7 +18350,7 @@ function sleep2(ms) {
18851
18350
  }
18852
18351
 
18853
18352
  // src/evals/publish.ts
18854
- var import_zod8 = require("zod");
18353
+ var import_zod9 = require("zod");
18855
18354
  init_definition();
18856
18355
 
18857
18356
  // src/evals/runs.ts
@@ -18898,19 +18397,19 @@ async function readEvalRun(client, runId, options = {}) {
18898
18397
  }
18899
18398
 
18900
18399
  // src/evals/publish.ts
18901
- var EvaluatorIdentitySchema = import_zod8.z.object({
18902
- id: import_zod8.z.string().uuid(),
18903
- slug: import_zod8.z.string(),
18904
- programVersion: import_zod8.z.number().int().positive(),
18905
- outputType: import_zod8.z.enum(["boolean", "score", "number"])
18400
+ var EvaluatorIdentitySchema = import_zod9.z.object({
18401
+ id: import_zod9.z.string().uuid(),
18402
+ slug: import_zod9.z.string(),
18403
+ programVersion: import_zod9.z.number().int().positive(),
18404
+ outputType: import_zod9.z.enum(["boolean", "score", "number"])
18906
18405
  });
18907
18406
  var EvaluatorSourceSchema = EvaluatorIdentitySchema.extend({
18908
- name: import_zod8.z.string(),
18909
- description: import_zod8.z.string().nullable(),
18910
- intent: import_zod8.z.string(),
18911
- kind: import_zod8.z.enum(["judge", "deterministic"]),
18912
- programSource: import_zod8.z.string(),
18913
- rules: import_zod8.z.array(import_zod8.z.string())
18407
+ name: import_zod9.z.string(),
18408
+ description: import_zod9.z.string().nullable(),
18409
+ intent: import_zod9.z.string(),
18410
+ kind: import_zod9.z.enum(["judge", "deterministic"]),
18411
+ programSource: import_zod9.z.string(),
18412
+ rules: import_zod9.z.array(import_zod9.z.string())
18914
18413
  });
18915
18414
  var EvalPublishError = class extends Error {
18916
18415
  constructor(status, message) {
@@ -18919,12 +18418,12 @@ var EvalPublishError = class extends Error {
18919
18418
  this.name = "EvalPublishError";
18920
18419
  }
18921
18420
  };
18922
- var ComparisonRunSchema = import_zod8.z.object({
18923
- id: import_zod8.z.string().uuid(),
18924
- programVersion: import_zod8.z.number().int().positive()
18421
+ var ComparisonRunSchema = import_zod9.z.object({
18422
+ id: import_zod9.z.string().uuid(),
18423
+ programVersion: import_zod9.z.number().int().positive()
18925
18424
  });
18926
- var ComparisonLinkSchema = import_zod8.z.object({
18927
- url: import_zod8.z.string().url(),
18425
+ var ComparisonLinkSchema = import_zod9.z.object({
18426
+ url: import_zod9.z.string().url(),
18928
18427
  first: ComparisonRunSchema,
18929
18428
  second: ComparisonRunSchema
18930
18429
  });
@@ -18952,7 +18451,7 @@ async function compareEvalRuns(client, options) {
18952
18451
  }
18953
18452
  const before = selected.id;
18954
18453
  const after = counterpart.id;
18955
- const { data } = import_zod8.z.object({ data: ComparisonLinkSchema }).parse(await evalRequest(client, `/v1/eval-runs/${before}/compare/${after}`, options));
18454
+ const { data } = import_zod9.z.object({ data: ComparisonLinkSchema }).parse(await evalRequest(client, `/v1/eval-runs/${before}/compare/${after}`, options));
18956
18455
  if (data.first.id !== before || data.second.id !== after) {
18957
18456
  throw new Error("Raindrop returned a different comparison pair");
18958
18457
  }
@@ -18965,7 +18464,7 @@ async function compareEvalRuns(client, options) {
18965
18464
  };
18966
18465
  }
18967
18466
  async function readEvaluator(client, slug, options = {}) {
18968
- const { data } = import_zod8.z.object({ data: EvaluatorSourceSchema }).parse(await evalRequest(client, `/v1/evals/${encodeURIComponent(slug)}`, options));
18467
+ const { data } = import_zod9.z.object({ data: EvaluatorSourceSchema }).parse(await evalRequest(client, `/v1/evals/${encodeURIComponent(slug)}`, options));
18969
18468
  if (data.slug !== slug) throw new Error("Raindrop returned a different evaluator slug");
18970
18469
  return defineEvaluatorProgram({
18971
18470
  slug: data.slug,
@@ -18985,15 +18484,11 @@ async function publishEvalSuite(client, definition, options = {}) {
18985
18484
  const localDataset = isEvalDataset(suite.dataset) ? suite.dataset : void 0;
18986
18485
  const slug = EvalDatasetSlugSchema.parse(localDataset ? localDataset.id : suite.dataset);
18987
18486
  const rows = localDataset == null ? void 0 : localDataset.rows.map((row) => {
18988
- if (row.output !== null) {
18989
- throw new Error(
18990
- "Publish reference evidence with publishEvalDataset first; a local row output is not a reference trace"
18991
- );
18992
- }
18993
18487
  return EvalDatasetCaseInputSchema.parse({
18994
18488
  id: row.id,
18995
18489
  name: row.name,
18996
18490
  input: row.input,
18491
+ output: row.output === null ? void 0 : row.output,
18997
18492
  properties: row.properties
18998
18493
  });
18999
18494
  });
@@ -19040,7 +18535,7 @@ async function publishEvalSuite(client, definition, options = {}) {
19040
18535
  });
19041
18536
  return defineEvalSuite({
19042
18537
  ...suite,
19043
- dataset: slug,
18538
+ dataset: dataset.dataset.slug,
19044
18539
  datasetVersionId: dataset.version.id,
19045
18540
  evaluators
19046
18541
  });
@@ -19093,6 +18588,7 @@ init_portable();
19093
18588
  // src/evals/pull.ts
19094
18589
  var import_zod11 = require("zod");
19095
18590
  init_definition();
18591
+ init_trace();
19096
18592
  init_portable();
19097
18593
  var SNAPSHOT_VERSION = 1;
19098
18594
  var PulledEvaluatorSchema = import_zod11.z.object({
@@ -19113,7 +18609,7 @@ var EvalSnapshotSchema = import_zod11.z.object({
19113
18609
  id: import_zod11.z.string(),
19114
18610
  name: import_zod11.z.string(),
19115
18611
  input: import_zod11.z.string().nullable(),
19116
- output: import_zod11.z.string().nullable(),
18612
+ output: JsonValueSchema,
19117
18613
  properties: import_zod11.z.record(import_zod11.z.string())
19118
18614
  })
19119
18615
  )
@@ -19122,9 +18618,7 @@ var EvalSnapshotSchema = import_zod11.z.object({
19122
18618
  });
19123
18619
 
19124
18620
  // src/evals/run.ts
19125
- var import_api8 = require("@opentelemetry/api");
19126
18621
  init_definition();
19127
- init_trace();
19128
18622
 
19129
18623
  // src/evals/policy.ts
19130
18624
  init_definition();
@@ -19169,132 +18663,6 @@ function outputMismatch(name, output) {
19169
18663
  }
19170
18664
 
19171
18665
  // src/evals/run.ts
19172
- init_portable();
19173
-
19174
- // src/evals/workshop.ts
19175
- var import_zod12 = require("zod");
19176
- var WorkshopRunSchema = import_zod12.z.object({
19177
- id: import_zod12.z.string(),
19178
- event_id: import_zod12.z.string().nullable(),
19179
- name: import_zod12.z.string().nullable(),
19180
- event_name: import_zod12.z.string().nullable(),
19181
- user_id: import_zod12.z.string().nullable(),
19182
- convo_id: import_zod12.z.string().nullable(),
19183
- started_at: import_zod12.z.number().nullable(),
19184
- last_updated_at: import_zod12.z.number().nullable(),
19185
- metadata: import_zod12.z.string().nullable(),
19186
- model: import_zod12.z.string().nullable(),
19187
- finished: import_zod12.z.number().nullable()
19188
- });
19189
- var WorkshopSpanSchema = import_zod12.z.object({
19190
- id: import_zod12.z.string(),
19191
- run_id: import_zod12.z.string(),
19192
- parent_span_id: import_zod12.z.string().nullable(),
19193
- name: import_zod12.z.string(),
19194
- span_type: import_zod12.z.string().nullable(),
19195
- status: import_zod12.z.string().nullable(),
19196
- input_payload: import_zod12.z.string().nullable(),
19197
- output_payload: import_zod12.z.string().nullable(),
19198
- start_time_ms: import_zod12.z.number().nullable(),
19199
- end_time_ms: import_zod12.z.number().nullable(),
19200
- duration_ms: import_zod12.z.number().nullable(),
19201
- model: import_zod12.z.string().nullable(),
19202
- provider: import_zod12.z.string().nullable(),
19203
- input_tokens: import_zod12.z.number().nullable(),
19204
- output_tokens: import_zod12.z.number().nullable(),
19205
- attributes: import_zod12.z.string().nullable()
19206
- });
19207
- var WorkshopTraceEnvelopeSchema = import_zod12.z.object({
19208
- status: import_zod12.z.literal("complete"),
19209
- correlationId: import_zod12.z.string(),
19210
- traceId: import_zod12.z.string(),
19211
- rootSpanId: import_zod12.z.string(),
19212
- spanCount: import_zod12.z.number().int().positive(),
19213
- run: WorkshopRunSchema,
19214
- spans: import_zod12.z.array(WorkshopSpanSchema).min(1)
19215
- });
19216
- async function readWorkshopTrace(input) {
19217
- if (!Number.isFinite(input.waitMs) || input.waitMs < 0)
19218
- throw new Error("Workshop waitMs must be finite and non-negative");
19219
- const deadlineAt = Date.now() + input.waitMs;
19220
- if (input.expectedSpanIds.length === 0) {
19221
- throw new Error(`Workshop trace ${input.correlationId} exported no spans`);
19222
- }
19223
- const url = new URL(
19224
- `${credentialEndpoint(input.workshopUrl).href.replace(/\/+$/, "")}/v1/evals/traces/${encodeURIComponent(input.correlationId)}`
19225
- );
19226
- for (const spanId of input.expectedSpanIds) url.searchParams.append("expectedSpanId", spanId);
19227
- while (true) {
19228
- const response = await runWithTracingSuppressed(
19229
- () => fetch(url, {
19230
- redirect: "error",
19231
- signal: AbortSignal.timeout(
19232
- Math.min(3e4, Math.max(1, Math.ceil(deadlineAt - Date.now())))
19233
- )
19234
- })
19235
- );
19236
- if (response.ok) {
19237
- const parsed = WorkshopTraceEnvelopeSchema.safeParse(await response.json());
19238
- if (!parsed.success) {
19239
- throw new Error(`Workshop returned an invalid completed trace: ${parsed.error.message}`);
19240
- }
19241
- return parsed.data;
19242
- }
19243
- if (response.status !== 404 && response.status !== 409) {
19244
- throw new Error(
19245
- `Workshop trace read failed with ${response.status}: ${await response.text()}`
19246
- );
19247
- }
19248
- if (Date.now() >= deadlineAt) {
19249
- const state2 = response.status === 404 ? "missing" : "incomplete";
19250
- throw new Error(`Workshop trace ${input.correlationId} remained ${state2}`);
19251
- }
19252
- await new Promise(
19253
- (resolve3) => setTimeout(resolve3, Math.min(50, Math.max(0, deadlineAt - Date.now())))
19254
- );
19255
- }
19256
- }
19257
- async function writeWorkshopEvalRun(workshopUrl, packet) {
19258
- const normalized = {
19259
- ...packet,
19260
- cases: packet.cases.map((entry) => ({
19261
- ...entry,
19262
- task: entry.task.state === "completed" ? { ...entry.task, output: serializableOutput(entry.task.output) } : entry.task
19263
- }))
19264
- };
19265
- const response = await runWithTracingSuppressed(
19266
- () => fetch(`${credentialEndpoint(workshopUrl).href.replace(/\/+$/, "")}/v1/evals/runs`, {
19267
- method: "POST",
19268
- headers: { "content-type": "application/json" },
19269
- body: JSON.stringify(normalized),
19270
- redirect: "error",
19271
- signal: AbortSignal.timeout(3e4)
19272
- })
19273
- );
19274
- if (!response.ok) {
19275
- throw new Error(
19276
- `Workshop eval result write failed with ${response.status}: ${await response.text()}`
19277
- );
19278
- }
19279
- const body = await response.json();
19280
- if (typeof body !== "object" || body === null || !("id" in body) || typeof body.id !== "string") {
19281
- throw new Error("Workshop eval result write returned an invalid response");
19282
- }
19283
- return { id: body.id };
19284
- }
19285
- function serializableOutput(value) {
19286
- try {
19287
- const serialized = JSON.stringify(boundedClone(value, 64e3));
19288
- if (serialized === void 0) return null;
19289
- if (serialized.length > 64e3) return "[Output exceeds 64000 characters]";
19290
- return JSON.parse(serialized);
19291
- } catch (e) {
19292
- return "[Output could not be serialized]";
19293
- }
19294
- }
19295
-
19296
- // src/evals/run.ts
19297
- var DEFAULT_WORKSHOP_TRACE_WAIT_MS = 3e4;
19298
18666
  function bindSuite(definition, parameters) {
19299
18667
  if (definition.agent === void 0) {
19300
18668
  const { run } = definition;
@@ -19306,66 +18674,41 @@ function bindSuite(definition, parameters) {
19306
18674
  return definition.agent.start(parameters);
19307
18675
  }
19308
18676
  function createSuiteSession(client, validated, run, options) {
19309
- if (validated.datasetVersionId && "selection" in options && options.selection.dataset.version.id !== validated.datasetVersionId) {
18677
+ if (validated.datasetVersionId && options.selection.dataset.version.id !== validated.datasetVersionId) {
19310
18678
  throw new Error("Selected dataset version does not match the published suite");
19311
18679
  }
19312
- if (options.destination.kind === "raindrop") {
19313
- if (!("selection" in options)) {
19314
- throw new Error("Raindrop remote eval sessions require selected rows");
19315
- }
19316
- if (typeof validated.dataset !== "string") {
19317
- throw new Error("Raindrop remote eval sessions require a dataset slug");
19318
- }
19319
- if (options.selection.dataset.dataset.slug !== validated.dataset) {
19320
- throw new Error(
19321
- `Raindrop eval ${validated.name} pinned dataset ${options.selection.dataset.dataset.slug} does not match ${validated.dataset}`
19322
- );
19323
- }
19324
- const localEvaluators = validated.evaluators.flatMap((entry) => {
19325
- const evaluator = replayEvaluator(entry);
19326
- return typeof evaluator === "string" ? [] : [evaluator];
19327
- });
19328
- if (localEvaluators.length !== validated.evaluators.length) {
19329
- throw new Error("Raindrop row-scoped eval sessions support local evaluators only");
19330
- }
19331
- const selection = validateRemoteSelection(validated.dataset, options.selection);
19332
- if (!selection) throw new Error("Raindrop remote eval sessions require selected rows");
19333
- return new RaindropRowEvalRun(
19334
- client,
19335
- validated,
19336
- run,
19337
- options.destination,
19338
- options.selection.dataset,
19339
- selection.rowIds,
19340
- localEvaluators
19341
- );
19342
- }
19343
- if (!isEvalDataset(validated.dataset)) {
19344
- throw new Error("Workshop eval execution requires a pulled or local dataset snapshot");
19345
- }
19346
- credentialEndpoint(options.destination.url);
19347
- const hosted = validated.evaluators.find((entry) => typeof entry.evaluator === "string");
19348
- if (hosted && typeof hosted.evaluator === "string") {
19349
- throw new Error(`Workshop evaluator ${hosted.evaluator} must be pulled before local execution`);
18680
+ if (typeof validated.dataset !== "string") {
18681
+ throw new Error("Raindrop eval sessions require a dataset slug");
19350
18682
  }
19351
- if (validated.evaluators.some(
19352
- (entry) => typeof entry.evaluator !== "string" && "kind" in entry.evaluator && entry.evaluator.kind === "program"
19353
- )) {
18683
+ if (options.selection.dataset.dataset.id !== validated.dataset && options.selection.dataset.dataset.slug !== validated.dataset) {
19354
18684
  throw new Error(
19355
- "Workshop authored evaluator programs must be pulled as portable evaluators before local execution"
18685
+ `Raindrop eval ${validated.name} pinned dataset ${options.selection.dataset.dataset.slug} does not match ${validated.dataset}`
19356
18686
  );
19357
18687
  }
19358
- return new WorkshopEvalRun(
18688
+ const localEvaluators = validated.evaluators.flatMap((entry) => {
18689
+ const evaluator = replayEvaluator(entry);
18690
+ return typeof evaluator === "string" ? [] : [evaluator];
18691
+ });
18692
+ if (localEvaluators.length !== validated.evaluators.length) {
18693
+ throw new Error("Raindrop row-scoped eval sessions support local evaluators only");
18694
+ }
18695
+ const selection = validateRemoteSelection(validated.dataset, options.selection);
18696
+ if (!selection) throw new Error("Raindrop eval sessions require selected rows");
18697
+ return new RaindropRowEvalRun(
19359
18698
  client,
19360
- { ...validated, dataset: validated.dataset },
18699
+ validated,
19361
18700
  run,
19362
- options.destination
18701
+ options.destination,
18702
+ options.selection.dataset,
18703
+ selection.rowIds,
18704
+ localEvaluators
19363
18705
  );
19364
18706
  }
19365
18707
  async function runEvalSuite(client, definition, options = {}) {
19366
- var _a;
18708
+ var _a, _b;
18709
+ assertRaindropDestination((_a = options.destination) != null ? _a : { kind: "raindrop" });
19367
18710
  const validated = validateDefinition(definition);
19368
- const execution = bindSuite(validated, (_a = options.parameters) != null ? _a : {});
18711
+ const execution = bindSuite(validated, (_b = options.parameters) != null ? _b : {});
19369
18712
  return finishWith(execution, () => runSuite(client, validated, execution.run, options));
19370
18713
  }
19371
18714
  async function runSuite(client, definition, run, options) {
@@ -19375,12 +18718,6 @@ async function runSuite(client, definition, run, options) {
19375
18718
  if (validated.datasetVersionId && ((_b = options.selection) == null ? void 0 : _b.dataset) && options.selection.dataset.version.id !== validated.datasetVersionId) {
19376
18719
  throw new Error("Selected dataset version does not match the published suite");
19377
18720
  }
19378
- if (destination.kind === "workshop") {
19379
- if (options.runId !== void 0) throw new Error("Queued runs are only supported in Raindrop");
19380
- const session = createSuiteSession(client, validated, run, { destination });
19381
- await session.run({ selection: options.selection, attempt: options.attempt });
19382
- return session.finish();
19383
- }
19384
18721
  const alreadyPublished = isPublishedEvalSuite(validated);
19385
18722
  if (typeof validated.dataset === "string" && ((_c = options.selection) == null ? void 0 : _c.dataset)) {
19386
18723
  validateRemoteSelection(validated.dataset, options.selection);
@@ -19610,328 +18947,6 @@ function replayEvaluatorsFromVerdicts(verdicts) {
19610
18947
  }
19611
18948
  return [...evaluators.values()];
19612
18949
  }
19613
- var WorkshopEvalRun = class {
19614
- constructor(client, definition, runRow, destination) {
19615
- this.client = client;
19616
- this.definition = definition;
19617
- this.runRow = runRow;
19618
- this.destination = destination;
19619
- this.id = randomId();
19620
- this.startedAt = /* @__PURE__ */ new Date();
19621
- this.completed = [];
19622
- this.active = /* @__PURE__ */ new Set();
19623
- this.state = "open";
19624
- this.runningRows = 0;
19625
- this.rowWaiters = [];
19626
- }
19627
- async run(options = {}) {
19628
- if (this.state !== "open") throw new Error(`Raindrop eval run ${this.id} is already finishing`);
19629
- const operation = this.runOnce(options);
19630
- this.active.add(operation);
19631
- try {
19632
- return await operation;
19633
- } finally {
19634
- this.active.delete(operation);
19635
- }
19636
- }
19637
- async runOnce(options) {
19638
- var _a;
19639
- const rows = selectLocalRows(this.definition, options.selection);
19640
- const completed = await Promise.all(
19641
- rows.map((row) => this.withRowPermit(() => {
19642
- var _a2;
19643
- return this.executeRow(row, (_a2 = options.attempt) != null ? _a2 : 0);
19644
- }))
19645
- );
19646
- const graded = await this.applyPortableEvaluators(completed, (_a = options.attempt) != null ? _a : 0);
19647
- this.completed.push(...graded);
19648
- return workshopResult(
19649
- this.id,
19650
- this.definition.name,
19651
- graded.map((entry) => entry.result)
19652
- );
19653
- }
19654
- finish() {
19655
- if (this.finishPromise) return this.finishPromise;
19656
- this.state = "finishing";
19657
- this.finishPromise = this.finishOnce();
19658
- return this.finishPromise;
19659
- }
19660
- async finishOnce() {
19661
- await Promise.allSettled([...this.active]);
19662
- const result = workshopResult(
19663
- this.id,
19664
- this.definition.name,
19665
- this.completed.map((entry) => entry.result)
19666
- );
19667
- if (this.completed.length > 0) {
19668
- const packet = {
19669
- schemaVersion: 1,
19670
- run: {
19671
- id: this.id,
19672
- name: this.definition.name,
19673
- destination: "workshop",
19674
- startedAt: this.startedAt.toISOString(),
19675
- finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
19676
- dataset: {
19677
- id: this.definition.dataset.id,
19678
- name: this.definition.dataset.name,
19679
- version: this.definition.dataset.version
19680
- },
19681
- evaluators: this.definition.evaluators.map((entry) => {
19682
- if (typeof entry.evaluator === "string") {
19683
- throw new Error(
19684
- `Workshop evaluator ${entry.evaluator} must be pulled before local execution`
19685
- );
19686
- }
19687
- if (isPortableEvaluator(entry.evaluator)) {
19688
- return {
19689
- slug: entry.evaluator.slug,
19690
- name: entry.evaluator.name,
19691
- output: entry.evaluator.output,
19692
- execution: "portable",
19693
- version: entry.evaluator.artifact.evaluator.programVersion,
19694
- artifactSha256: entry.evaluator.artifact.sha256,
19695
- scope: entry.evaluator.scope,
19696
- threshold: entry.threshold
19697
- };
19698
- }
19699
- return {
19700
- slug: entry.evaluator.slug,
19701
- name: entry.evaluator.name,
19702
- output: entry.evaluator.output,
19703
- execution: "local",
19704
- scope: entry.evaluator.scope === "row" ? "case" : entry.evaluator.scope,
19705
- threshold: entry.threshold
19706
- };
19707
- })
19708
- },
19709
- cases: this.completed.map((entry) => entry.packet)
19710
- };
19711
- await writeWorkshopEvalRun(this.destination.url, packet);
19712
- }
19713
- this.state = "finished";
19714
- return result;
19715
- }
19716
- async executeRow(row, attempt) {
19717
- var _a, _b, _c;
19718
- const correlationId = randomId();
19719
- const exportedSpanIds = /* @__PURE__ */ new Set();
19720
- const startedAt = Date.now();
19721
- let completedAgent;
19722
- let taskError;
19723
- try {
19724
- const destination = {
19725
- kind: "workshop",
19726
- url: this.destination.url,
19727
- exportedSpanIds
19728
- };
19729
- const value = await withReplayTraceDestination(
19730
- destination,
19731
- () => withEvalScope(
19732
- { correlationId },
19733
- () => this.client.tracer().withSpan(
19734
- {
19735
- name: "raindrop.eval.case",
19736
- properties: {
19737
- "raindrop.eval.run_id": this.id,
19738
- "raindrop.eval.case_id": row.id,
19739
- "raindrop.eval.attempt": String(attempt)
19740
- },
19741
- inputParameters: [row],
19742
- traceContent: true
19743
- },
19744
- () => {
19745
- var _a2;
19746
- const parent = (_a2 = import_api8.trace.getSpan(import_api8.context.active())) == null ? void 0 : _a2.spanContext();
19747
- if (!parent) return this.runRow(row);
19748
- return withReplayTraceDestination(
19749
- {
19750
- ...destination,
19751
- parentSpanContext: {
19752
- traceIdB64: Buffer.from(parent.traceId, "hex").toString("base64"),
19753
- spanIdB64: Buffer.from(parent.spanId, "hex").toString("base64"),
19754
- eventId: parent.traceId
19755
- }
19756
- },
19757
- () => this.runRow(row)
19758
- );
19759
- }
19760
- )
19761
- )
19762
- );
19763
- completedAgent = { value };
19764
- } catch (cause) {
19765
- taskError = describeError2(cause);
19766
- }
19767
- const durationMs = Date.now() - startedAt;
19768
- const taskCompleted = completedAgent !== void 0;
19769
- let trace8;
19770
- let traceId = null;
19771
- let traceError;
19772
- try {
19773
- await this.client.forceFlush();
19774
- const envelope = await readWorkshopTrace({
19775
- workshopUrl: this.destination.url,
19776
- correlationId,
19777
- waitMs: (_a = this.definition.traceWaitMs) != null ? _a : DEFAULT_WORKSHOP_TRACE_WAIT_MS,
19778
- expectedSpanIds: [...exportedSpanIds]
19779
- });
19780
- traceId = envelope.traceId;
19781
- trace8 = canonicalWorkshopTrace(envelope);
19782
- } catch (cause) {
19783
- traceError = describeError2(cause);
19784
- }
19785
- const verdicts = [];
19786
- if (completedAgent && !traceError && trace8) {
19787
- const agentResult = completedAgent.value;
19788
- await Promise.all(
19789
- this.definition.evaluators.map(async (entry) => {
19790
- if (typeof entry.evaluator === "string") return;
19791
- if (isPortableEvaluator(entry.evaluator)) return;
19792
- if ("kind" in entry.evaluator && entry.evaluator.kind === "program") return;
19793
- try {
19794
- const verdict = parseLocalVerdict2(
19795
- entry.evaluator.output,
19796
- await entry.evaluator.judge({ trace: trace8, row, result: agentResult })
19797
- );
19798
- verdicts.push(
19799
- withVerdictIdentity(entry.evaluator.slug, this.id, this.destination.url, verdict)
19800
- );
19801
- } catch (cause) {
19802
- verdicts.push({
19803
- evaluator: entry.evaluator.slug,
19804
- runId: this.id,
19805
- url: workshopEvalUrl(this.destination.url, this.id),
19806
- state: "errored",
19807
- message: describeError2(cause)
19808
- });
19809
- }
19810
- })
19811
- );
19812
- }
19813
- if (taskCompleted && traceError) {
19814
- for (const entry of this.definition.evaluators) {
19815
- if (typeof entry.evaluator === "string") continue;
19816
- verdicts.push({
19817
- evaluator: entry.evaluator.slug,
19818
- runId: this.id,
19819
- url: workshopEvalUrl(this.destination.url, this.id),
19820
- state: "ungraded",
19821
- reason: "trace unavailable"
19822
- });
19823
- }
19824
- }
19825
- const assessments = verdicts.map((verdict) => {
19826
- const evaluator = this.definition.evaluators.find(
19827
- (entry) => evaluatorName(entry) === verdict.evaluator
19828
- );
19829
- if (!evaluator)
19830
- throw new Error(`Raindrop eval result included unknown evaluator ${verdict.evaluator}`);
19831
- return assessEvalVerdict(evaluator, verdict, evaluatorOutput(evaluator));
19832
- });
19833
- const error = (_b = taskError != null ? taskError : traceError) != null ? _b : null;
19834
- const result = {
19835
- ...row,
19836
- attempt,
19837
- status: error ? "missing" : "done",
19838
- traceId,
19839
- error,
19840
- verdicts: assessments
19841
- };
19842
- const packet = {
19843
- caseId: row.id,
19844
- caseName: row.name,
19845
- input: row.input,
19846
- ...row.output === null ? {} : { expected: row.output },
19847
- attempt,
19848
- traceId,
19849
- ...taskCompleted && traceError ? { traceError } : {},
19850
- task: taskError ? { state: "failed", error: taskError, durationMs } : { state: "completed", output: (_c = completedAgent == null ? void 0 : completedAgent.value) != null ? _c : null, durationMs },
19851
- verdicts: verdicts.map(workshopVerdict),
19852
- passed: error === null && assessments.every(
19853
- (assessment) => assessment.state === "passed" || assessment.state === "measurement"
19854
- )
19855
- };
19856
- return { result, packet, trace: trace8 };
19857
- }
19858
- async withRowPermit(run) {
19859
- var _a;
19860
- const limit = (_a = this.definition.concurrency) != null ? _a : 4;
19861
- if (this.runningRows >= limit) {
19862
- await new Promise((resolve3) => this.rowWaiters.push(resolve3));
19863
- } else {
19864
- this.runningRows += 1;
19865
- }
19866
- try {
19867
- return await run();
19868
- } finally {
19869
- const next = this.rowWaiters.shift();
19870
- if (next) next();
19871
- else this.runningRows -= 1;
19872
- }
19873
- }
19874
- async applyPortableEvaluators(completed, attempt) {
19875
- let current = completed;
19876
- for (const entry of this.definition.evaluators) {
19877
- if (typeof entry.evaluator === "string" || !isPortableEvaluator(entry.evaluator)) continue;
19878
- const portableEvaluator = entry.evaluator;
19879
- const traces = current.flatMap(
19880
- (item) => item.packet.task.state === "completed" && item.trace ? [item.trace] : []
19881
- );
19882
- if (traces.length === 0) continue;
19883
- let outcomes;
19884
- try {
19885
- const portable = await evaluatePortableEvaluator(portableEvaluator, {
19886
- traces,
19887
- seed: `${this.id}:${attempt}:${portableEvaluator.slug}`
19888
- });
19889
- const programFailure = portable.failures.join("; ");
19890
- outcomes = new Map(
19891
- portable.outcomes.map((outcome) => [
19892
- outcome.traceId,
19893
- programFailure ? {
19894
- state: "errored",
19895
- traceId: outcome.traceId,
19896
- message: programFailure
19897
- } : outcome
19898
- ])
19899
- );
19900
- } catch (cause) {
19901
- const message = describeError2(cause);
19902
- outcomes = new Map(
19903
- traces.map((trace8) => [
19904
- trace8.event.id,
19905
- { state: "errored", traceId: trace8.event.id, message }
19906
- ])
19907
- );
19908
- }
19909
- current = current.map((item) => {
19910
- if (item.packet.task.state !== "completed" || !item.trace) return item;
19911
- const outcome = outcomes.get(item.trace.event.id);
19912
- if (!outcome) return item;
19913
- const verdict = portableVerdict(
19914
- portableEvaluator.slug,
19915
- this.id,
19916
- this.destination.url,
19917
- outcome
19918
- );
19919
- const assessment = assessEvalVerdict(entry, verdict, portableEvaluator.output);
19920
- const verdicts = [...item.result.verdicts, assessment];
19921
- return {
19922
- ...item,
19923
- result: { ...item.result, verdicts },
19924
- packet: {
19925
- ...item.packet,
19926
- verdicts: [...item.packet.verdicts, workshopVerdict(verdict)],
19927
- passed: item.packet.passed && (assessment.state === "passed" || assessment.state === "measurement")
19928
- }
19929
- };
19930
- });
19931
- }
19932
- return current;
19933
- }
19934
- };
19935
18950
  async function runRaindropEval(client, definition, run, destination, options) {
19936
18951
  var _a, _b, _c, _d;
19937
18952
  if (typeof definition.dataset !== "string") {
@@ -19944,7 +18959,7 @@ async function runRaindropEval(client, definition, run, destination, options) {
19944
18959
  queryUrl: destination.queryUrl,
19945
18960
  versionId: definition.datasetVersionId
19946
18961
  }) : void 0;
19947
- if (pinnedDataset && pinnedDataset.dataset.slug !== datasetReference) {
18962
+ if (pinnedDataset && pinnedDataset.dataset.id !== datasetReference && pinnedDataset.dataset.slug !== datasetReference) {
19948
18963
  throw new Error(
19949
18964
  `Raindrop eval ${definition.name} pinned dataset ${pinnedDataset.dataset.slug} does not match ${datasetReference}`
19950
18965
  );
@@ -20073,20 +19088,6 @@ function validateDefinition(definition) {
20073
19088
  throw new Error("Raindrop runEvalSuite requires a definition created by defineEvalSuite");
20074
19089
  return definition;
20075
19090
  }
20076
- function selectLocalRows(definition, selection) {
20077
- if (!selection) return definition.dataset.rows;
20078
- if (selection.rowIds.length === 0)
20079
- throw new Error(`Raindrop eval ${definition.name} selection cannot be empty`);
20080
- if (new Set(selection.rowIds).size !== selection.rowIds.length)
20081
- throw new Error(`Raindrop eval ${definition.name} selection row ids must be unique`);
20082
- const byId = new Map(definition.dataset.rows.map((row) => [row.id, row]));
20083
- return selection.rowIds.map((id) => {
20084
- const row = byId.get(id);
20085
- if (!row)
20086
- throw new Error(`Raindrop eval ${definition.name} selection contains unknown row ${id}`);
20087
- return row;
20088
- });
20089
- }
20090
19091
  function validateRemoteSelection(dataset, selection) {
20091
19092
  var _a;
20092
19093
  if (!selection) return void 0;
@@ -20102,157 +19103,20 @@ function validateRemoteSelection(dataset, selection) {
20102
19103
  throw new Error(`Raindrop eval ${dataset} selection contains unknown row ${unknown}`);
20103
19104
  return { rowIds: selection.rowIds };
20104
19105
  }
20105
- function canonicalWorkshopTrace(envelope) {
20106
- var _a, _b, _c, _d, _e, _f;
20107
- const spans = envelope.spans.map(rawTraceSpan);
20108
- const timestamp = new Date((_a = envelope.run.started_at) != null ? _a : Date.now()).toISOString();
20109
- const event = projectCapturedEvent({
20110
- eventId: (_b = envelope.run.event_id) != null ? _b : envelope.traceId,
20111
- internalEventId: envelope.run.id,
20112
- name: (_d = (_c = envelope.run.event_name) != null ? _c : envelope.run.name) != null ? _d : "ai_generation",
20113
- timestamp,
20114
- receivedAt: new Date((_e = envelope.run.last_updated_at) != null ? _e : Date.now()).toISOString(),
20115
- userId: (_f = envelope.run.user_id) != null ? _f : "local-eval",
20116
- convoId: envelope.run.convo_id,
20117
- properties: parseAttributes(envelope.run.metadata),
20118
- spans
20119
- });
20120
- return projectWorkshopTrace({ origin: "replay", event, spans });
20121
- }
20122
- function rawTraceSpan(span) {
20123
- var _a, _b, _c, _d, _e, _f;
20124
- const attributes = parseAttributes(span.attributes);
20125
- return {
20126
- span_id: span.id,
20127
- parent_span_id: (_a = span.parent_span_id) != null ? _a : void 0,
20128
- span_name: span.name,
20129
- span_type: (_b = span.span_type) != null ? _b : void 0,
20130
- status: (_c = span.status) != null ? _c : void 0,
20131
- duration_ns: span.duration_ms === null ? void 0 : span.duration_ms * 1e6,
20132
- start_unix_ns: span.start_time_ms === null ? void 0 : span.start_time_ms * 1e6,
20133
- model: (_d = span.model) != null ? _d : void 0,
20134
- input_tokens: (_e = span.input_tokens) != null ? _e : void 0,
20135
- output_tokens: (_f = span.output_tokens) != null ? _f : void 0,
20136
- input_payload: span.input_payload,
20137
- output_payload: span.output_payload,
20138
- attributes_string: Object.fromEntries(
20139
- Object.entries(attributes).filter(
20140
- (entry) => typeof entry[1] === "string"
20141
- )
20142
- ),
20143
- attributes_num: Object.fromEntries(
20144
- Object.entries(attributes).filter(
20145
- (entry) => typeof entry[1] === "number"
20146
- )
20147
- )
20148
- };
20149
- }
20150
- function parseAttributes(raw) {
20151
- if (!raw) return {};
20152
- try {
20153
- const value = JSON.parse(raw);
20154
- return isAttributeRecord(value) ? value : {};
20155
- } catch (e) {
20156
- return {};
20157
- }
20158
- }
20159
- function isAttributeRecord(value) {
20160
- return typeof value === "object" && value !== null && !Array.isArray(value);
20161
- }
20162
- function parseLocalVerdict2(output, value) {
20163
- if (output === "boolean") return { state: "graded", ...LocalBooleanVerdictSchema.parse(value) };
20164
- if (output === "score") return { state: "graded", ...LocalScoreVerdictSchema.parse(value) };
20165
- return { state: "graded", ...LocalNumberVerdictSchema.parse(value) };
20166
- }
20167
- function withVerdictIdentity(evaluator, runId, workshopUrl, verdict) {
20168
- return {
20169
- evaluator,
20170
- runId,
20171
- url: workshopEvalUrl(workshopUrl, runId),
20172
- ...verdict
20173
- };
20174
- }
20175
- function workshopVerdict(assessment) {
20176
- const { evaluator, state: state2 } = assessment;
20177
- if (state2 === "errored") return { evaluator, state: state2, message: assessment.message };
20178
- if (state2 === "ungraded") return { evaluator, state: state2, reason: assessment.reason };
20179
- if ("pass" in assessment)
20180
- return {
20181
- evaluator,
20182
- state: state2,
20183
- pass: assessment.pass,
20184
- ...assessment.note ? { note: assessment.note } : {}
20185
- };
20186
- if ("score" in assessment)
20187
- return {
20188
- evaluator,
20189
- state: state2,
20190
- score: assessment.score,
20191
- ...assessment.note ? { note: assessment.note } : {}
20192
- };
20193
- return {
20194
- evaluator,
20195
- state: state2,
20196
- value: assessment.value,
20197
- ...assessment.note ? { note: assessment.note } : {}
20198
- };
20199
- }
20200
- function portableVerdict(evaluator, runId, workshopUrl, outcome) {
20201
- const identity = { evaluator, runId, url: workshopEvalUrl(workshopUrl, runId) };
20202
- if (outcome.state === "errored") {
20203
- return { ...identity, state: outcome.state, message: outcome.message };
20204
- }
20205
- if (outcome.state === "ungraded") {
20206
- return { ...identity, state: outcome.state, reason: outcome.reason };
20207
- }
20208
- if ("pass" in outcome)
20209
- return {
20210
- ...identity,
20211
- state: outcome.state,
20212
- pass: outcome.pass,
20213
- ...outcome.note ? { note: outcome.note } : {}
20214
- };
20215
- if ("score" in outcome)
20216
- return {
20217
- ...identity,
20218
- state: outcome.state,
20219
- score: outcome.score,
20220
- ...outcome.note ? { note: outcome.note } : {}
20221
- };
20222
- return {
20223
- ...identity,
20224
- state: outcome.state,
20225
- value: outcome.value,
20226
- ...outcome.note ? { note: outcome.note } : {}
20227
- };
20228
- }
20229
- function workshopResult(id, name, rows) {
20230
- const done = rows.filter((entry) => entry.status === "done").length;
20231
- const missing = rows.filter((entry) => entry.status === "missing").length;
20232
- return {
20233
- runId: id,
20234
- name,
20235
- status: missing > 0 ? "failed" : "complete",
20236
- counts: { total: rows.length, pending: 0, done, missing },
20237
- tracesExpireAt: null,
20238
- tracesExpired: false,
20239
- evaluators: [],
20240
- rows
20241
- };
20242
- }
20243
- function workshopEvalUrl(baseUrl, id) {
20244
- return `${baseUrl.replace(/\/+$/, "")}/evals/${encodeURIComponent(id)}`;
20245
- }
20246
19106
  function randomId() {
20247
19107
  var _a, _b, _c;
20248
19108
  return (_c = (_b = (_a = globalThis.crypto) == null ? void 0 : _a.randomUUID) == null ? void 0 : _b.call(_a)) != null ? _c : `eval-${Date.now()}-${Math.random().toString(16).slice(2)}`;
20249
19109
  }
20250
- function describeError2(cause) {
20251
- return cause instanceof Error ? cause.message : String(cause);
20252
- }
20253
19110
  function isPortableEvaluator(value) {
20254
19111
  return "kind" in value && value.kind === "portable";
20255
19112
  }
19113
+ function assertRaindropDestination(destination) {
19114
+ if (destination.kind !== "raindrop") {
19115
+ throw new Error(
19116
+ "Eval runs store results in Raindrop; Workshop is no longer an eval destination"
19117
+ );
19118
+ }
19119
+ }
20256
19120
 
20257
19121
  // src/index.ts
20258
19122
  function rawAppGitProperties(properties) {
@@ -20720,14 +19584,14 @@ var Raindrop = class {
20720
19584
  const description = buildSelfDiagnosticsDescription(signals, options.guidance);
20721
19585
  const inputSchema = buildSelfDiagnosticsInputSchema(signalKeys);
20722
19586
  const onMissingEventId = (_b = options.onMissingEventId) != null ? _b : "warn";
20723
- const execute = async (rawInput, context9) => {
19587
+ const execute = async (rawInput, context8) => {
20724
19588
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
20725
19589
  const input = isRecord(rawInput) ? rawInput : void 0;
20726
19590
  const fallbackCategory = (_a2 = signalKeys[0]) != null ? _a2 : "unknown";
20727
19591
  const categoryCandidate = normalizeEventId(input == null ? void 0 : input["category"]);
20728
19592
  const category = categoryCandidate && signalKeySet.has(categoryCandidate) ? categoryCandidate : fallbackCategory;
20729
19593
  const detail = (_b2 = normalizeEventId(input == null ? void 0 : input["detail"])) != null ? _b2 : "";
20730
- const eventId = (_l = (_k = (_i = (_g = (_f = (_e = (_d = normalizeEventId(context9 == null ? void 0 : context9.eventId)) != null ? _d : (_c = context9 == null ? void 0 : context9.interaction) == null ? void 0 : _c.getEventId()) != null ? _e : resolveEventIdFromMetadata(context9 == null ? void 0 : context9.metadata)) != null ? _f : normalizeEventId(input == null ? void 0 : input["event_id"])) != null ? _g : normalizeEventId(input == null ? void 0 : input["eventId"])) != null ? _i : (_h = options.interaction) == null ? void 0 : _h.getEventId()) != null ? _k : (_j = options.getEventId) == null ? void 0 : _j.call(options)) != null ? _l : normalizeEventId(options.eventId);
19594
+ const eventId = (_l = (_k = (_i = (_g = (_f = (_e = (_d = normalizeEventId(context8 == null ? void 0 : context8.eventId)) != null ? _d : (_c = context8 == null ? void 0 : context8.interaction) == null ? void 0 : _c.getEventId()) != null ? _e : resolveEventIdFromMetadata(context8 == null ? void 0 : context8.metadata)) != null ? _f : normalizeEventId(input == null ? void 0 : input["event_id"])) != null ? _g : normalizeEventId(input == null ? void 0 : input["eventId"])) != null ? _i : (_h = options.interaction) == null ? void 0 : _h.getEventId()) != null ? _k : (_j = options.getEventId) == null ? void 0 : _j.call(options)) != null ? _l : normalizeEventId(options.eventId);
20731
19595
  if (!eventId) {
20732
19596
  const message = "self diagnostics signal skipped: missing eventId. Pass eventId, interaction, or getEventId when creating or executing the tool.";
20733
19597
  if (onMissingEventId === "throw") {
@@ -20745,11 +19609,11 @@ var Raindrop = class {
20745
19609
  type: "agent",
20746
19610
  sentiment: signalDefinition == null ? void 0 : signalDefinition.sentiment,
20747
19611
  properties: {
20748
- source: (context9 == null ? void 0 : context9.source) || options.source || SELF_DIAGNOSTICS_SOURCE_DEFAULT,
19612
+ source: (context8 == null ? void 0 : context8.source) || options.source || SELF_DIAGNOSTICS_SOURCE_DEFAULT,
20749
19613
  category,
20750
19614
  signal_description: signalDefinition == null ? void 0 : signalDefinition.description,
20751
19615
  ...detail ? { detail } : {},
20752
- ...(_m = context9 == null ? void 0 : context9.properties) != null ? _m : {}
19616
+ ...(_m = context8 == null ? void 0 : context8.properties) != null ? _m : {}
20753
19617
  }
20754
19618
  });
20755
19619
  return { acknowledged: true, category, eventId };
@@ -21155,7 +20019,7 @@ var Raindrop = class {
21155
20019
  }
21156
20020
  getContext() {
21157
20021
  const runtime = detectRuntime();
21158
- const context9 = {
20022
+ const context8 = {
21159
20023
  library: {
21160
20024
  name: package_default.name,
21161
20025
  version: package_default.version
@@ -21165,9 +20029,9 @@ var Raindrop = class {
21165
20029
  }
21166
20030
  };
21167
20031
  if (runtime === "node") {
21168
- context9.metadata.nodeVersion = process.version;
20032
+ context8.metadata.nodeVersion = process.version;
21169
20033
  }
21170
- return context9;
20034
+ return context8;
21171
20035
  }
21172
20036
  formatZodError(error) {
21173
20037
  return error.issues.map((issue) => `(path: ${issue.path.join(".")}): ${issue.message}`).join(", ");
@@ -21609,8 +20473,8 @@ var index_default = Raindrop;
21609
20473
 
21610
20474
  // src/evals/cli.ts
21611
20475
  init_definition();
21612
- var SuiteModuleSchema = import_zod13.z.object({
21613
- default: import_zod13.z.custom(isEvalSuiteDefinition)
20476
+ var SuiteModuleSchema = import_zod12.z.object({
20477
+ default: import_zod12.z.custom(isEvalSuiteDefinition)
21614
20478
  });
21615
20479
  async function main() {
21616
20480
  var _a, _b;