raindrop-ai 0.7.1 → 0.8.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/README.md +69 -1
- package/dist/{chunk-6WL655QL.mjs → chunk-22CNYHSA.mjs} +399 -110
- package/dist/{chunk-RMP6BZSY.mjs → chunk-EFATLUNL.mjs} +6 -4
- package/dist/{chunk-SHH4SYVY.mjs → chunk-EWHJ2YBW.mjs} +1 -1
- package/dist/evals/cli.js +207 -153
- package/dist/evals/cli.mjs +3 -3
- package/dist/{index-DuJkG47V.d.ts → index-gf1epf_P.d.mts} +186 -86
- package/dist/{index-DuJkG47V.d.mts → index-gf1epf_P.d.ts} +186 -86
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +466 -172
- package/dist/index.mjs +9 -3
- package/dist/{portable-runtime-MFVOVFPB.mjs → portable-runtime-6X2HHB4Y.mjs} +1 -1
- package/dist/tracing/index.d.mts +1 -1
- package/dist/tracing/index.d.ts +1 -1
- package/dist/tracing/index.js +1 -1
- package/dist/tracing/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3707,7 +3707,7 @@ var require_lodash = __commonJS({
|
|
|
3707
3707
|
if (fromIndex < 0) {
|
|
3708
3708
|
fromIndex = nativeMax(length + fromIndex, 0);
|
|
3709
3709
|
}
|
|
3710
|
-
return
|
|
3710
|
+
return isString2(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
|
|
3711
3711
|
}
|
|
3712
3712
|
var invokeMap = baseRest(function(collection, path, args) {
|
|
3713
3713
|
var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array2(collection.length) : [];
|
|
@@ -3775,7 +3775,7 @@ var require_lodash = __commonJS({
|
|
|
3775
3775
|
return 0;
|
|
3776
3776
|
}
|
|
3777
3777
|
if (isArrayLike(collection)) {
|
|
3778
|
-
return
|
|
3778
|
+
return isString2(collection) ? stringSize(collection) : collection.length;
|
|
3779
3779
|
}
|
|
3780
3780
|
var tag = getTag(collection);
|
|
3781
3781
|
if (tag == mapTag || tag == setTag) {
|
|
@@ -4101,7 +4101,7 @@ var require_lodash = __commonJS({
|
|
|
4101
4101
|
function isArrayLikeObject(value) {
|
|
4102
4102
|
return isObjectLike(value) && isArrayLike(value);
|
|
4103
4103
|
}
|
|
4104
|
-
function
|
|
4104
|
+
function isBoolean2(value) {
|
|
4105
4105
|
return value === true || value === false || isObjectLike(value) && baseGetTag(value) == boolTag;
|
|
4106
4106
|
}
|
|
4107
4107
|
var isBuffer = nativeIsBuffer || stubFalse;
|
|
@@ -4177,7 +4177,7 @@ var require_lodash = __commonJS({
|
|
|
4177
4177
|
return baseIsMatch(object, source, getMatchData(source), customizer);
|
|
4178
4178
|
}
|
|
4179
4179
|
function isNaN(value) {
|
|
4180
|
-
return
|
|
4180
|
+
return isNumber2(value) && value != +value;
|
|
4181
4181
|
}
|
|
4182
4182
|
function isNative(value) {
|
|
4183
4183
|
if (isMaskable(value)) {
|
|
@@ -4191,7 +4191,7 @@ var require_lodash = __commonJS({
|
|
|
4191
4191
|
function isNil(value) {
|
|
4192
4192
|
return value == null;
|
|
4193
4193
|
}
|
|
4194
|
-
function
|
|
4194
|
+
function isNumber2(value) {
|
|
4195
4195
|
return typeof value == "number" || isObjectLike(value) && baseGetTag(value) == numberTag;
|
|
4196
4196
|
}
|
|
4197
4197
|
function isPlainObject(value) {
|
|
@@ -4210,7 +4210,7 @@ var require_lodash = __commonJS({
|
|
|
4210
4210
|
return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
|
|
4211
4211
|
}
|
|
4212
4212
|
var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
|
|
4213
|
-
function
|
|
4213
|
+
function isString2(value) {
|
|
4214
4214
|
return typeof value == "string" || !isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag;
|
|
4215
4215
|
}
|
|
4216
4216
|
function isSymbol(value) {
|
|
@@ -4235,7 +4235,7 @@ var require_lodash = __commonJS({
|
|
|
4235
4235
|
return [];
|
|
4236
4236
|
}
|
|
4237
4237
|
if (isArrayLike(value)) {
|
|
4238
|
-
return
|
|
4238
|
+
return isString2(value) ? stringToArray(value) : copyArray(value);
|
|
4239
4239
|
}
|
|
4240
4240
|
if (symIterator && value[symIterator]) {
|
|
4241
4241
|
return iteratorToArray(value[symIterator]());
|
|
@@ -5243,7 +5243,7 @@ var require_lodash = __commonJS({
|
|
|
5243
5243
|
lodash.isArrayBuffer = isArrayBuffer;
|
|
5244
5244
|
lodash.isArrayLike = isArrayLike;
|
|
5245
5245
|
lodash.isArrayLikeObject = isArrayLikeObject;
|
|
5246
|
-
lodash.isBoolean =
|
|
5246
|
+
lodash.isBoolean = isBoolean2;
|
|
5247
5247
|
lodash.isBuffer = isBuffer;
|
|
5248
5248
|
lodash.isDate = isDate;
|
|
5249
5249
|
lodash.isElement = isElement;
|
|
@@ -5262,14 +5262,14 @@ var require_lodash = __commonJS({
|
|
|
5262
5262
|
lodash.isNative = isNative;
|
|
5263
5263
|
lodash.isNil = isNil;
|
|
5264
5264
|
lodash.isNull = isNull;
|
|
5265
|
-
lodash.isNumber =
|
|
5265
|
+
lodash.isNumber = isNumber2;
|
|
5266
5266
|
lodash.isObject = isObject;
|
|
5267
5267
|
lodash.isObjectLike = isObjectLike;
|
|
5268
5268
|
lodash.isPlainObject = isPlainObject;
|
|
5269
5269
|
lodash.isRegExp = isRegExp;
|
|
5270
5270
|
lodash.isSafeInteger = isSafeInteger;
|
|
5271
5271
|
lodash.isSet = isSet;
|
|
5272
|
-
lodash.isString =
|
|
5272
|
+
lodash.isString = isString2;
|
|
5273
5273
|
lodash.isSymbol = isSymbol;
|
|
5274
5274
|
lodash.isTypedArray = isTypedArray;
|
|
5275
5275
|
lodash.isUndefined = isUndefined;
|
|
@@ -5794,8 +5794,7 @@ function defineDataset(dataset) {
|
|
|
5794
5794
|
if (!id) throw new Error("Raindrop eval dataset ids cannot be empty");
|
|
5795
5795
|
if (!name) throw new Error("Raindrop eval dataset names cannot be empty");
|
|
5796
5796
|
if (!version) throw new Error("Raindrop eval dataset versions cannot be empty");
|
|
5797
|
-
if (dataset.rows.length === 0)
|
|
5798
|
-
throw new Error("Raindrop eval datasets require at least one row");
|
|
5797
|
+
if (dataset.rows.length === 0) throw new Error("Raindrop eval datasets require at least one row");
|
|
5799
5798
|
const ids = rows.map((entry) => entry.id);
|
|
5800
5799
|
if (ids.some((rowId) => !rowId)) throw new Error("Raindrop eval row ids cannot be empty");
|
|
5801
5800
|
if (new Set(ids).size !== ids.length) throw new Error("Raindrop eval row ids must be unique");
|
|
@@ -5878,7 +5877,10 @@ function defineEvalSuite(definition) {
|
|
|
5878
5877
|
if (typeof dataset !== "string")
|
|
5879
5878
|
throw new Error("A dataset version pin requires a published dataset slug");
|
|
5880
5879
|
}
|
|
5881
|
-
if (
|
|
5880
|
+
if (definition.agent !== void 0 && definition.run !== void 0) {
|
|
5881
|
+
throw new Error("An eval suite accepts either agent or run, not both");
|
|
5882
|
+
}
|
|
5883
|
+
if (definition.agent === void 0 && typeof definition.run !== "function") {
|
|
5882
5884
|
throw new Error("Raindrop eval suite run must be a function");
|
|
5883
5885
|
}
|
|
5884
5886
|
if (!Array.isArray(definition.evaluators) || definition.evaluators.length === 0) {
|
|
@@ -7003,13 +7005,13 @@ function rowTracePair(pair) {
|
|
|
7003
7005
|
const { caseId, ...evidence } = pair;
|
|
7004
7006
|
return { ...evidence, rowId: caseId };
|
|
7005
7007
|
}
|
|
7006
|
-
var import_quickjs_singlefile_cjs_release_sync, import_quickjs_emscripten_core,
|
|
7008
|
+
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;
|
|
7007
7009
|
var init_portable_runtime = __esm({
|
|
7008
7010
|
"src/evals/portable-runtime.ts"() {
|
|
7009
7011
|
"use strict";
|
|
7010
7012
|
import_quickjs_singlefile_cjs_release_sync = __toESM(require("@jitl/quickjs-singlefile-cjs-release-sync"));
|
|
7011
7013
|
import_quickjs_emscripten_core = require("quickjs-emscripten-core");
|
|
7012
|
-
|
|
7014
|
+
import_zod9 = require("zod");
|
|
7013
7015
|
init_portable();
|
|
7014
7016
|
DEFAULT_MEMORY_BYTES = 32 * 1024 * 1024;
|
|
7015
7017
|
DEFAULT_STACK_BYTES = 64 * 1024;
|
|
@@ -7019,11 +7021,11 @@ var init_portable_runtime = __esm({
|
|
|
7019
7021
|
DEFAULT_JUDGE_CONCURRENCY = 4;
|
|
7020
7022
|
DEFAULT_MAX_INPUT_BYTES = 4 * 1024 * 1024;
|
|
7021
7023
|
DEFAULT_MAX_OUTPUT_BYTES = 4 * 1024 * 1024;
|
|
7022
|
-
JudgeRequestSchema =
|
|
7023
|
-
type:
|
|
7024
|
-
requestId:
|
|
7025
|
-
traceId:
|
|
7026
|
-
rubric:
|
|
7024
|
+
JudgeRequestSchema = import_zod9.z.object({
|
|
7025
|
+
type: import_zod9.z.literal("judge_request"),
|
|
7026
|
+
requestId: import_zod9.z.string(),
|
|
7027
|
+
traceId: import_zod9.z.string(),
|
|
7028
|
+
rubric: import_zod9.z.string()
|
|
7027
7029
|
});
|
|
7028
7030
|
}
|
|
7029
7031
|
});
|
|
@@ -7135,67 +7137,67 @@ function canonicalJson2(value) {
|
|
|
7135
7137
|
if (Array.isArray(value)) return `[${value.map(canonicalJson2).join(",")}]`;
|
|
7136
7138
|
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson2(entry)}`).join(",")}}`;
|
|
7137
7139
|
}
|
|
7138
|
-
var
|
|
7140
|
+
var import_zod10, PortableEvalArtifactSchema, PortableEvalResultSchema;
|
|
7139
7141
|
var init_portable = __esm({
|
|
7140
7142
|
"src/evals/portable.ts"() {
|
|
7141
7143
|
"use strict";
|
|
7142
|
-
|
|
7144
|
+
import_zod10 = require("zod");
|
|
7143
7145
|
init_definition();
|
|
7144
7146
|
init_trace();
|
|
7145
|
-
PortableEvalArtifactSchema =
|
|
7146
|
-
format:
|
|
7147
|
-
formatVersion:
|
|
7148
|
-
runtimeAbi:
|
|
7149
|
-
evaluator:
|
|
7150
|
-
id:
|
|
7151
|
-
slug:
|
|
7152
|
-
programVersion:
|
|
7153
|
-
executionMode:
|
|
7154
|
-
outputType:
|
|
7155
|
-
scope:
|
|
7147
|
+
PortableEvalArtifactSchema = import_zod10.z.object({
|
|
7148
|
+
format: import_zod10.z.literal("raindrop.eval-program"),
|
|
7149
|
+
formatVersion: import_zod10.z.literal(1),
|
|
7150
|
+
runtimeAbi: import_zod10.z.literal("raindrop-eval-v2"),
|
|
7151
|
+
evaluator: import_zod10.z.object({
|
|
7152
|
+
id: import_zod10.z.string().uuid(),
|
|
7153
|
+
slug: import_zod10.z.string().min(1),
|
|
7154
|
+
programVersion: import_zod10.z.number().int().positive(),
|
|
7155
|
+
executionMode: import_zod10.z.enum(["deterministic", "judge"]),
|
|
7156
|
+
outputType: import_zod10.z.enum(["boolean", "score", "number"]),
|
|
7157
|
+
scope: import_zod10.z.literal("batch")
|
|
7156
7158
|
}).strict(),
|
|
7157
|
-
traceProjectionVersion:
|
|
7158
|
-
traceProjectionSha256:
|
|
7159
|
-
source:
|
|
7160
|
-
sha256:
|
|
7159
|
+
traceProjectionVersion: import_zod10.z.literal(1),
|
|
7160
|
+
traceProjectionSha256: import_zod10.z.string().regex(/^[a-f0-9]{64}$/),
|
|
7161
|
+
source: import_zod10.z.string().min(1),
|
|
7162
|
+
sha256: import_zod10.z.string().regex(/^[a-f0-9]{64}$/)
|
|
7161
7163
|
}).strict();
|
|
7162
|
-
PortableEvalResultSchema =
|
|
7163
|
-
outcomes:
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
state:
|
|
7167
|
-
traceId:
|
|
7168
|
-
pass:
|
|
7169
|
-
note:
|
|
7164
|
+
PortableEvalResultSchema = import_zod10.z.object({
|
|
7165
|
+
outcomes: import_zod10.z.array(
|
|
7166
|
+
import_zod10.z.union([
|
|
7167
|
+
import_zod10.z.object({
|
|
7168
|
+
state: import_zod10.z.literal("graded"),
|
|
7169
|
+
traceId: import_zod10.z.string(),
|
|
7170
|
+
pass: import_zod10.z.boolean(),
|
|
7171
|
+
note: import_zod10.z.string().optional()
|
|
7170
7172
|
}),
|
|
7171
|
-
|
|
7172
|
-
state:
|
|
7173
|
-
traceId:
|
|
7173
|
+
import_zod10.z.object({
|
|
7174
|
+
state: import_zod10.z.literal("graded"),
|
|
7175
|
+
traceId: import_zod10.z.string(),
|
|
7174
7176
|
score: EvalScoreSchema,
|
|
7175
|
-
note:
|
|
7177
|
+
note: import_zod10.z.string().optional()
|
|
7176
7178
|
}),
|
|
7177
|
-
|
|
7178
|
-
state:
|
|
7179
|
-
traceId:
|
|
7180
|
-
value:
|
|
7181
|
-
note:
|
|
7179
|
+
import_zod10.z.object({
|
|
7180
|
+
state: import_zod10.z.literal("graded"),
|
|
7181
|
+
traceId: import_zod10.z.string(),
|
|
7182
|
+
value: import_zod10.z.number().finite(),
|
|
7183
|
+
note: import_zod10.z.string().optional()
|
|
7182
7184
|
}),
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
state:
|
|
7186
|
-
traceId:
|
|
7187
|
-
reason:
|
|
7185
|
+
import_zod10.z.object({ state: import_zod10.z.literal("errored"), traceId: import_zod10.z.string(), message: import_zod10.z.string() }),
|
|
7186
|
+
import_zod10.z.object({
|
|
7187
|
+
state: import_zod10.z.literal("ungraded"),
|
|
7188
|
+
traceId: import_zod10.z.string(),
|
|
7189
|
+
reason: import_zod10.z.enum(["not sampled", "trace unavailable", "content unreadable"])
|
|
7188
7190
|
})
|
|
7189
7191
|
])
|
|
7190
7192
|
),
|
|
7191
|
-
failures:
|
|
7192
|
-
stats:
|
|
7193
|
-
traceCount:
|
|
7194
|
-
hydratedCount:
|
|
7195
|
-
judgeCalls:
|
|
7196
|
-
durationMs:
|
|
7197
|
-
skippedRows:
|
|
7198
|
-
skippedReason:
|
|
7193
|
+
failures: import_zod10.z.array(import_zod10.z.string()),
|
|
7194
|
+
stats: import_zod10.z.object({
|
|
7195
|
+
traceCount: import_zod10.z.number().int().nonnegative(),
|
|
7196
|
+
hydratedCount: import_zod10.z.number().int().nonnegative(),
|
|
7197
|
+
judgeCalls: import_zod10.z.number().int().nonnegative(),
|
|
7198
|
+
durationMs: import_zod10.z.number().nonnegative(),
|
|
7199
|
+
skippedRows: import_zod10.z.number().int().nonnegative(),
|
|
7200
|
+
skippedReason: import_zod10.z.literal("no trace").nullable()
|
|
7199
7201
|
})
|
|
7200
7202
|
});
|
|
7201
7203
|
}
|
|
@@ -7212,6 +7214,7 @@ __export(index_exports, {
|
|
|
7212
7214
|
EVAL_CORRELATION_ID_ATTRIBUTE: () => EVAL_CORRELATION_ID_ATTRIBUTE2,
|
|
7213
7215
|
EvalDatasetPublishConflictError: () => EvalDatasetPublishConflictError,
|
|
7214
7216
|
EvalDatasetRowInputSchema: () => EvalDatasetRowInputSchema,
|
|
7217
|
+
EvalParameterError: () => EvalParameterError,
|
|
7215
7218
|
EvalPublishError: () => EvalPublishError,
|
|
7216
7219
|
LocalBooleanVerdictSchema: () => LocalBooleanVerdictSchema,
|
|
7217
7220
|
LocalNumberVerdictSchema: () => LocalNumberVerdictSchema,
|
|
@@ -7230,10 +7233,12 @@ __export(index_exports, {
|
|
|
7230
7233
|
TraceSchema: () => TraceSchema,
|
|
7231
7234
|
claimReplay: () => claimReplay,
|
|
7232
7235
|
compareEvalRuns: () => compareEvalRuns,
|
|
7236
|
+
createEvalHandler: () => createEvalHandler,
|
|
7233
7237
|
createEvalSuiteRun: () => createEvalSuiteRun,
|
|
7234
7238
|
createReplay: () => createReplay,
|
|
7235
7239
|
currentEvalScope: () => currentEvalScope2,
|
|
7236
7240
|
default: () => index_default,
|
|
7241
|
+
defineAgent: () => defineAgent,
|
|
7237
7242
|
defineDataset: () => defineDataset,
|
|
7238
7243
|
defineEvalSuite: () => defineEvalSuite,
|
|
7239
7244
|
defineEvaluatorProgram: () => defineEvaluatorProgram,
|
|
@@ -9364,15 +9369,15 @@ var makeIssue = (params) => {
|
|
|
9364
9369
|
message: issueData.message
|
|
9365
9370
|
};
|
|
9366
9371
|
}
|
|
9367
|
-
let
|
|
9372
|
+
let errorMessage2 = "";
|
|
9368
9373
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
9369
9374
|
for (const map of maps) {
|
|
9370
|
-
|
|
9375
|
+
errorMessage2 = map(fullIssue, { data, defaultError: errorMessage2 }).message;
|
|
9371
9376
|
}
|
|
9372
9377
|
return {
|
|
9373
9378
|
...issueData,
|
|
9374
9379
|
path: fullPath,
|
|
9375
|
-
message:
|
|
9380
|
+
message: errorMessage2
|
|
9376
9381
|
};
|
|
9377
9382
|
};
|
|
9378
9383
|
var EMPTY_PATH = [];
|
|
@@ -12995,7 +13000,7 @@ var SignalEventSchema = external_exports.object({
|
|
|
12995
13000
|
// package.json
|
|
12996
13001
|
var package_default = {
|
|
12997
13002
|
name: "raindrop-ai",
|
|
12998
|
-
version: "0.
|
|
13003
|
+
version: "0.8.0",
|
|
12999
13004
|
main: "dist/index.js",
|
|
13000
13005
|
module: "dist/index.mjs",
|
|
13001
13006
|
types: "dist/index.d.ts",
|
|
@@ -15696,9 +15701,9 @@ var LiveInteraction = class {
|
|
|
15696
15701
|
span.setAttribute("traceloop.entity.duration_ms", durationMs);
|
|
15697
15702
|
}
|
|
15698
15703
|
if (error) {
|
|
15699
|
-
const
|
|
15700
|
-
span.setStatus({ code: import_api4.SpanStatusCode.ERROR, message:
|
|
15701
|
-
span.recordException(error instanceof Error ? error : new Error(
|
|
15704
|
+
const errorMessage2 = error instanceof Error ? error.message : String(error);
|
|
15705
|
+
span.setStatus({ code: import_api4.SpanStatusCode.ERROR, message: errorMessage2 });
|
|
15706
|
+
span.recordException(error instanceof Error ? error : new Error(errorMessage2));
|
|
15702
15707
|
} else {
|
|
15703
15708
|
span.setStatus({ code: import_api4.SpanStatusCode.OK });
|
|
15704
15709
|
}
|
|
@@ -15857,9 +15862,9 @@ var LiveTracer = class {
|
|
|
15857
15862
|
span.setAttribute("traceloop.entity.duration_ms", durationMs);
|
|
15858
15863
|
}
|
|
15859
15864
|
if (error) {
|
|
15860
|
-
const
|
|
15861
|
-
span.setStatus({ code: import_api5.SpanStatusCode.ERROR, message:
|
|
15862
|
-
span.recordException(error instanceof Error ? error : new Error(
|
|
15865
|
+
const errorMessage2 = error instanceof Error ? error.message : String(error);
|
|
15866
|
+
span.setStatus({ code: import_api5.SpanStatusCode.ERROR, message: errorMessage2 });
|
|
15867
|
+
span.recordException(error instanceof Error ? error : new Error(errorMessage2));
|
|
15863
15868
|
} else {
|
|
15864
15869
|
span.setStatus({ code: import_api5.SpanStatusCode.OK });
|
|
15865
15870
|
}
|
|
@@ -17071,7 +17076,7 @@ function replayIngestEndpoint(value, trustedUrl) {
|
|
|
17071
17076
|
|
|
17072
17077
|
// src/replay/index.ts
|
|
17073
17078
|
var DEFAULT_QUERY_URL = "https://query.raindrop.ai";
|
|
17074
|
-
var DEFAULT_TRACE_WAIT_MS =
|
|
17079
|
+
var DEFAULT_TRACE_WAIT_MS = 6e4;
|
|
17075
17080
|
var DEFAULT_EVAL_WAIT_MS = 10 * 6e4;
|
|
17076
17081
|
var DEFAULT_EVAL_POLL_INTERVAL_MS = 2e3;
|
|
17077
17082
|
var MAX_EVAL_STATUS_RETRIES = 2;
|
|
@@ -17683,6 +17688,9 @@ function validateEvalDatasetManifest(value) {
|
|
|
17683
17688
|
async function runReplay(client, handle, options) {
|
|
17684
17689
|
return (await runReplayRows(client, handle, options)).reading;
|
|
17685
17690
|
}
|
|
17691
|
+
async function runEvalReplay(client, handle, options) {
|
|
17692
|
+
return runReplayRows(client, handle, options);
|
|
17693
|
+
}
|
|
17686
17694
|
async function runReplayRows(client, handle, options) {
|
|
17687
17695
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
17688
17696
|
if (!Number.isSafeInteger((_a = options.concurrency) != null ? _a : DEFAULT_CONCURRENCY) || ((_b = options.concurrency) != null ? _b : DEFAULT_CONCURRENCY) < 1) {
|
|
@@ -17787,12 +17795,17 @@ async function runReplayRows(client, handle, options) {
|
|
|
17787
17795
|
}
|
|
17788
17796
|
}
|
|
17789
17797
|
};
|
|
17790
|
-
await Promise.
|
|
17798
|
+
const workers = await Promise.allSettled(
|
|
17791
17799
|
Array.from(
|
|
17792
17800
|
{ length: Math.min((_f = options.concurrency) != null ? _f : DEFAULT_CONCURRENCY, rows.length) },
|
|
17793
17801
|
() => worker()
|
|
17794
17802
|
)
|
|
17795
17803
|
);
|
|
17804
|
+
const failures = workers.flatMap(
|
|
17805
|
+
(result) => result.status === "rejected" ? [result.reason] : []
|
|
17806
|
+
);
|
|
17807
|
+
if (failures.length === 1) throw failures[0];
|
|
17808
|
+
if (failures.length > 1) throw new AggregateError(failures, "Replay row execution failed");
|
|
17796
17809
|
await client.forceFlush();
|
|
17797
17810
|
const traceEvidence = [];
|
|
17798
17811
|
for (const row of rows) {
|
|
@@ -18776,6 +18789,253 @@ function describeError(cause) {
|
|
|
18776
18789
|
return String(cause);
|
|
18777
18790
|
}
|
|
18778
18791
|
|
|
18792
|
+
// src/evals/agent.ts
|
|
18793
|
+
var import_zod6 = require("zod");
|
|
18794
|
+
var EvalParameterError = class extends Error {
|
|
18795
|
+
constructor(agent, issues) {
|
|
18796
|
+
super(
|
|
18797
|
+
`Invalid parameters for agent ${agent}: ${issues.map((issue) => `${issue.path.join(".") || "parameters"} ${issue.message}`).join("; ")}`
|
|
18798
|
+
);
|
|
18799
|
+
this.name = "EvalParameterError";
|
|
18800
|
+
}
|
|
18801
|
+
};
|
|
18802
|
+
var AgentMetadataSchema = import_zod6.z.object({
|
|
18803
|
+
slug: import_zod6.z.string().trim().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(64),
|
|
18804
|
+
name: import_zod6.z.string().trim().min(1).max(120),
|
|
18805
|
+
description: import_zod6.z.string().max(2e3).optional()
|
|
18806
|
+
});
|
|
18807
|
+
var PARAMETER_KEY = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
18808
|
+
var MAX_PARAMETERS = 50;
|
|
18809
|
+
function unwrapField(schema) {
|
|
18810
|
+
let inner = schema;
|
|
18811
|
+
let description;
|
|
18812
|
+
while (inner instanceof import_zod6.z.ZodDefault || inner instanceof import_zod6.z.ZodOptional) {
|
|
18813
|
+
description != null ? description : description = inner.description;
|
|
18814
|
+
inner = inner._def.innerType;
|
|
18815
|
+
}
|
|
18816
|
+
const omitted = schema.safeParse(void 0);
|
|
18817
|
+
return {
|
|
18818
|
+
inner,
|
|
18819
|
+
required: !omitted.success,
|
|
18820
|
+
defaultValue: omitted.success ? omitted.data : void 0,
|
|
18821
|
+
description: description != null ? description : inner.description
|
|
18822
|
+
};
|
|
18823
|
+
}
|
|
18824
|
+
function fieldDefault(key, value, guard) {
|
|
18825
|
+
if (value === void 0) return void 0;
|
|
18826
|
+
if (!guard(value)) throw new Error(`Parameter ${key} has a default of the wrong type`);
|
|
18827
|
+
return value;
|
|
18828
|
+
}
|
|
18829
|
+
var isString = (value) => typeof value === "string";
|
|
18830
|
+
var isNumber = (value) => typeof value === "number";
|
|
18831
|
+
var isBoolean = (value) => typeof value === "boolean";
|
|
18832
|
+
function describeParameterField(key, schema) {
|
|
18833
|
+
if (!PARAMETER_KEY.test(key)) throw new Error(`Parameter key ${key} must be an identifier`);
|
|
18834
|
+
const { inner, required, defaultValue, description } = unwrapField(schema);
|
|
18835
|
+
const base = { key, required, ...description === void 0 ? {} : { description } };
|
|
18836
|
+
if (inner instanceof import_zod6.z.ZodString) {
|
|
18837
|
+
const max = inner._def.checks.find((check) => check.kind === "max");
|
|
18838
|
+
return {
|
|
18839
|
+
...base,
|
|
18840
|
+
type: "string",
|
|
18841
|
+
default: fieldDefault(key, defaultValue, isString),
|
|
18842
|
+
...(max == null ? void 0 : max.kind) === "max" ? { maxLength: max.value } : {}
|
|
18843
|
+
};
|
|
18844
|
+
}
|
|
18845
|
+
if (inner instanceof import_zod6.z.ZodNumber) {
|
|
18846
|
+
const { minValue, maxValue } = inner;
|
|
18847
|
+
return {
|
|
18848
|
+
...base,
|
|
18849
|
+
type: "number",
|
|
18850
|
+
default: fieldDefault(key, defaultValue, isNumber),
|
|
18851
|
+
integer: inner.isInt,
|
|
18852
|
+
...minValue === null ? {} : { min: minValue },
|
|
18853
|
+
...maxValue === null ? {} : { max: maxValue }
|
|
18854
|
+
};
|
|
18855
|
+
}
|
|
18856
|
+
if (inner instanceof import_zod6.z.ZodBoolean) {
|
|
18857
|
+
return { ...base, type: "boolean", default: fieldDefault(key, defaultValue, isBoolean) };
|
|
18858
|
+
}
|
|
18859
|
+
if (inner instanceof import_zod6.z.ZodEnum) {
|
|
18860
|
+
const options = inner.options;
|
|
18861
|
+
return { ...base, type: "enum", default: fieldDefault(key, defaultValue, isString), options };
|
|
18862
|
+
}
|
|
18863
|
+
throw new Error(
|
|
18864
|
+
`Parameter ${key} must be a z.string(), z.number(), z.boolean(), or z.enum() schema`
|
|
18865
|
+
);
|
|
18866
|
+
}
|
|
18867
|
+
function defineAgent(definition) {
|
|
18868
|
+
var _a, _b;
|
|
18869
|
+
const { slug, name, description } = AgentMetadataSchema.parse({
|
|
18870
|
+
slug: definition.slug,
|
|
18871
|
+
name: (_a = definition.name) != null ? _a : definition.slug,
|
|
18872
|
+
description: definition.description
|
|
18873
|
+
});
|
|
18874
|
+
if (typeof definition.run !== "function") throw new Error("An agent requires a run function");
|
|
18875
|
+
const fields = (_b = definition.parameters) != null ? _b : {};
|
|
18876
|
+
const entries = Object.entries(fields);
|
|
18877
|
+
if (entries.length > MAX_PARAMETERS)
|
|
18878
|
+
throw new Error(`Agent ${slug} declares more than ${MAX_PARAMETERS} parameters`);
|
|
18879
|
+
const parameters = entries.map(([key, schema2]) => describeParameterField(key, schema2));
|
|
18880
|
+
const schema = import_zod6.z.object(fields).strict();
|
|
18881
|
+
return {
|
|
18882
|
+
slug,
|
|
18883
|
+
name,
|
|
18884
|
+
description,
|
|
18885
|
+
parameters,
|
|
18886
|
+
start(input) {
|
|
18887
|
+
const parsed = schema.safeParse(input);
|
|
18888
|
+
if (!parsed.success) throw new EvalParameterError(slug, parsed.error.issues);
|
|
18889
|
+
return startAgent(definition, parsed.data);
|
|
18890
|
+
}
|
|
18891
|
+
};
|
|
18892
|
+
}
|
|
18893
|
+
async function finishWith(execution, work) {
|
|
18894
|
+
let result;
|
|
18895
|
+
try {
|
|
18896
|
+
result = await work();
|
|
18897
|
+
} catch (error) {
|
|
18898
|
+
await execution.finish().catch(() => void 0);
|
|
18899
|
+
throw error;
|
|
18900
|
+
}
|
|
18901
|
+
await execution.finish();
|
|
18902
|
+
return result;
|
|
18903
|
+
}
|
|
18904
|
+
function startAgent(definition, parameters) {
|
|
18905
|
+
const active = /* @__PURE__ */ new Set();
|
|
18906
|
+
let finishing;
|
|
18907
|
+
const execution = (runRow, cleanup2) => ({
|
|
18908
|
+
run(row) {
|
|
18909
|
+
if (finishing !== void 0)
|
|
18910
|
+
return Promise.reject(new Error(`Agent ${definition.slug} has already finished`));
|
|
18911
|
+
const pending = runRow(row);
|
|
18912
|
+
active.add(pending);
|
|
18913
|
+
pending.catch(() => void 0).finally(() => active.delete(pending));
|
|
18914
|
+
return pending;
|
|
18915
|
+
},
|
|
18916
|
+
finish: () => finishing != null ? finishing : finishing = Promise.allSettled(active).then(cleanup2)
|
|
18917
|
+
});
|
|
18918
|
+
if (definition.setup === void 0) {
|
|
18919
|
+
const { run: run2, cleanup: cleanup2 } = definition;
|
|
18920
|
+
return execution(
|
|
18921
|
+
(row) => Promise.resolve().then(() => run2(row, { parameters })),
|
|
18922
|
+
async () => {
|
|
18923
|
+
await (cleanup2 == null ? void 0 : cleanup2());
|
|
18924
|
+
}
|
|
18925
|
+
);
|
|
18926
|
+
}
|
|
18927
|
+
const { setup, run, cleanup } = definition;
|
|
18928
|
+
let environment2;
|
|
18929
|
+
const ready = () => {
|
|
18930
|
+
if (environment2 === void 0) {
|
|
18931
|
+
environment2 = Promise.resolve().then(() => setup(parameters));
|
|
18932
|
+
environment2.catch(() => void 0);
|
|
18933
|
+
}
|
|
18934
|
+
return environment2;
|
|
18935
|
+
};
|
|
18936
|
+
return execution(
|
|
18937
|
+
async (row) => run(row, { parameters, environment: await ready() }),
|
|
18938
|
+
() => environment2 === void 0 ? Promise.resolve() : environment2.then(
|
|
18939
|
+
(built) => cleanup == null ? void 0 : cleanup(built),
|
|
18940
|
+
() => void 0
|
|
18941
|
+
)
|
|
18942
|
+
);
|
|
18943
|
+
}
|
|
18944
|
+
|
|
18945
|
+
// src/evals/server.ts
|
|
18946
|
+
var import_zod7 = require("zod");
|
|
18947
|
+
var InvocationSchema = import_zod7.z.object({
|
|
18948
|
+
runId: import_zod7.z.string().uuid(),
|
|
18949
|
+
agent: import_zod7.z.string().min(1).max(64),
|
|
18950
|
+
parameters: import_zod7.z.record(import_zod7.z.unknown()).default({})
|
|
18951
|
+
});
|
|
18952
|
+
var MAX_BODY_BYTES = 64 * 1024;
|
|
18953
|
+
async function parseInvocation(request) {
|
|
18954
|
+
var _a;
|
|
18955
|
+
if (Number((_a = request.headers.get("content-length")) != null ? _a : 0) > MAX_BODY_BYTES) return void 0;
|
|
18956
|
+
const body = await request.text().catch(() => "");
|
|
18957
|
+
if (new TextEncoder().encode(body).byteLength > MAX_BODY_BYTES) return void 0;
|
|
18958
|
+
try {
|
|
18959
|
+
const parsed = InvocationSchema.safeParse(JSON.parse(body));
|
|
18960
|
+
return parsed.success ? parsed.data : void 0;
|
|
18961
|
+
} catch (e) {
|
|
18962
|
+
return void 0;
|
|
18963
|
+
}
|
|
18964
|
+
}
|
|
18965
|
+
function startExecution(agent, parameters) {
|
|
18966
|
+
try {
|
|
18967
|
+
return agent.start(parameters);
|
|
18968
|
+
} catch (error) {
|
|
18969
|
+
if (error instanceof EvalParameterError)
|
|
18970
|
+
return Response.json({ error: error.message }, { status: 400 });
|
|
18971
|
+
throw error;
|
|
18972
|
+
}
|
|
18973
|
+
}
|
|
18974
|
+
function errorMessage(error) {
|
|
18975
|
+
return error instanceof Error ? error.message : "Eval execution failed";
|
|
18976
|
+
}
|
|
18977
|
+
function createEvalHandler(client, options) {
|
|
18978
|
+
if (options.queryUrl !== void 0) credentialEndpoint(options.queryUrl);
|
|
18979
|
+
if (options.replayIngestUrl !== void 0) credentialEndpoint(options.replayIngestUrl);
|
|
18980
|
+
const agents = new Map(options.agents.map((agent) => [agent.slug, agent]));
|
|
18981
|
+
if (agents.size !== options.agents.length)
|
|
18982
|
+
throw new Error("Registered agent slugs must be unique");
|
|
18983
|
+
const catalog = [...agents.values()].map(({ slug, name, description, parameters }) => ({
|
|
18984
|
+
slug,
|
|
18985
|
+
name,
|
|
18986
|
+
description,
|
|
18987
|
+
parameters
|
|
18988
|
+
}));
|
|
18989
|
+
return async (request) => {
|
|
18990
|
+
if (request.method === "GET") return Response.json({ agents: catalog });
|
|
18991
|
+
if (request.method !== "POST") {
|
|
18992
|
+
return Response.json(
|
|
18993
|
+
{ error: "Method not allowed" },
|
|
18994
|
+
{ status: 405, headers: { Allow: "GET, POST" } }
|
|
18995
|
+
);
|
|
18996
|
+
}
|
|
18997
|
+
const invocation = await parseInvocation(request);
|
|
18998
|
+
if (invocation === void 0) {
|
|
18999
|
+
return Response.json({ error: "Invalid eval request" }, { status: 400 });
|
|
19000
|
+
}
|
|
19001
|
+
const { runId, parameters } = invocation;
|
|
19002
|
+
const agent = agents.get(invocation.agent);
|
|
19003
|
+
if (agent === void 0) return Response.json({ error: "Unknown agent" }, { status: 404 });
|
|
19004
|
+
const execution = startExecution(agent, parameters);
|
|
19005
|
+
if (execution instanceof Response) return execution;
|
|
19006
|
+
try {
|
|
19007
|
+
const { replay: replay2 } = await readReplayDetails(client, runId, { queryUrl: options.queryUrl });
|
|
19008
|
+
if (replay2.status === "complete" || replay2.status === "failed") {
|
|
19009
|
+
return Response.json({ runId, status: replay2.status, counts: replay2.counts });
|
|
19010
|
+
}
|
|
19011
|
+
if (replay2.status !== "queued") {
|
|
19012
|
+
return Response.json({ error: "Run is already claimed" }, { status: 409 });
|
|
19013
|
+
}
|
|
19014
|
+
const handle = await claimReplay(client, runId, { queryUrl: options.queryUrl });
|
|
19015
|
+
if (handle.replayId !== runId) throw new Error("Raindrop claimed a different run");
|
|
19016
|
+
if (handle.ingestUrl === null) {
|
|
19017
|
+
return Response.json({ error: "Run is already claimed" }, { status: 409 });
|
|
19018
|
+
}
|
|
19019
|
+
const { reading, traceEvidence } = await finishWith(
|
|
19020
|
+
execution,
|
|
19021
|
+
() => runEvalReplay(client, handle, {
|
|
19022
|
+
run: execution.run,
|
|
19023
|
+
queryUrl: options.queryUrl,
|
|
19024
|
+
replayIngestUrl: options.replayIngestUrl
|
|
19025
|
+
})
|
|
19026
|
+
);
|
|
19027
|
+
return Response.json({
|
|
19028
|
+
runId: reading.replayId,
|
|
19029
|
+
status: reading.status,
|
|
19030
|
+
counts: reading.counts,
|
|
19031
|
+
traceEvidence
|
|
19032
|
+
});
|
|
19033
|
+
} catch (error) {
|
|
19034
|
+
return Response.json({ error: errorMessage(error) }, { status: 500 });
|
|
19035
|
+
}
|
|
19036
|
+
};
|
|
19037
|
+
}
|
|
19038
|
+
|
|
18779
19039
|
// src/evals/index.ts
|
|
18780
19040
|
init_definition();
|
|
18781
19041
|
|
|
@@ -18929,7 +19189,7 @@ function sleep2(ms) {
|
|
|
18929
19189
|
}
|
|
18930
19190
|
|
|
18931
19191
|
// src/evals/publish.ts
|
|
18932
|
-
var
|
|
19192
|
+
var import_zod8 = require("zod");
|
|
18933
19193
|
init_definition();
|
|
18934
19194
|
|
|
18935
19195
|
// src/evals/runs.ts
|
|
@@ -18979,19 +19239,19 @@ async function evaluateEvalRun(client, runId, options) {
|
|
|
18979
19239
|
}
|
|
18980
19240
|
|
|
18981
19241
|
// src/evals/publish.ts
|
|
18982
|
-
var EvaluatorIdentitySchema =
|
|
18983
|
-
id:
|
|
18984
|
-
slug:
|
|
18985
|
-
programVersion:
|
|
18986
|
-
outputType:
|
|
19242
|
+
var EvaluatorIdentitySchema = import_zod8.z.object({
|
|
19243
|
+
id: import_zod8.z.string().uuid(),
|
|
19244
|
+
slug: import_zod8.z.string(),
|
|
19245
|
+
programVersion: import_zod8.z.number().int().positive(),
|
|
19246
|
+
outputType: import_zod8.z.enum(["boolean", "score", "number"])
|
|
18987
19247
|
});
|
|
18988
19248
|
var EvaluatorSourceSchema = EvaluatorIdentitySchema.extend({
|
|
18989
|
-
name:
|
|
18990
|
-
description:
|
|
18991
|
-
intent:
|
|
18992
|
-
kind:
|
|
18993
|
-
programSource:
|
|
18994
|
-
rules:
|
|
19249
|
+
name: import_zod8.z.string(),
|
|
19250
|
+
description: import_zod8.z.string().nullable(),
|
|
19251
|
+
intent: import_zod8.z.string(),
|
|
19252
|
+
kind: import_zod8.z.enum(["judge", "deterministic"]),
|
|
19253
|
+
programSource: import_zod8.z.string(),
|
|
19254
|
+
rules: import_zod8.z.array(import_zod8.z.string())
|
|
18995
19255
|
});
|
|
18996
19256
|
var EvalPublishError = class extends Error {
|
|
18997
19257
|
constructor(status, message) {
|
|
@@ -19000,12 +19260,12 @@ var EvalPublishError = class extends Error {
|
|
|
19000
19260
|
this.name = "EvalPublishError";
|
|
19001
19261
|
}
|
|
19002
19262
|
};
|
|
19003
|
-
var ComparisonRunSchema =
|
|
19004
|
-
id:
|
|
19005
|
-
programVersion:
|
|
19263
|
+
var ComparisonRunSchema = import_zod8.z.object({
|
|
19264
|
+
id: import_zod8.z.string().uuid(),
|
|
19265
|
+
programVersion: import_zod8.z.number().int().positive()
|
|
19006
19266
|
});
|
|
19007
|
-
var ComparisonLinkSchema =
|
|
19008
|
-
url:
|
|
19267
|
+
var ComparisonLinkSchema = import_zod8.z.object({
|
|
19268
|
+
url: import_zod8.z.string().url(),
|
|
19009
19269
|
first: ComparisonRunSchema,
|
|
19010
19270
|
second: ComparisonRunSchema
|
|
19011
19271
|
});
|
|
@@ -19033,7 +19293,7 @@ async function compareEvalRuns(client, options) {
|
|
|
19033
19293
|
}
|
|
19034
19294
|
const before = selected.id;
|
|
19035
19295
|
const after = counterpart.id;
|
|
19036
|
-
const { data } =
|
|
19296
|
+
const { data } = import_zod8.z.object({ data: ComparisonLinkSchema }).parse(await evalRequest(client, `/v1/eval-runs/${before}/compare/${after}`, options));
|
|
19037
19297
|
if (data.first.id !== before || data.second.id !== after) {
|
|
19038
19298
|
throw new Error("Raindrop returned a different comparison pair");
|
|
19039
19299
|
}
|
|
@@ -19046,7 +19306,7 @@ async function compareEvalRuns(client, options) {
|
|
|
19046
19306
|
};
|
|
19047
19307
|
}
|
|
19048
19308
|
async function readEvaluator(client, slug, options = {}) {
|
|
19049
|
-
const { data } =
|
|
19309
|
+
const { data } = import_zod8.z.object({ data: EvaluatorSourceSchema }).parse(await evalRequest(client, `/v1/evals/${encodeURIComponent(slug)}`, options));
|
|
19050
19310
|
if (data.slug !== slug) throw new Error("Raindrop returned a different evaluator slug");
|
|
19051
19311
|
return defineEvaluatorProgram({
|
|
19052
19312
|
slug: data.slug,
|
|
@@ -19172,34 +19432,34 @@ init_trace();
|
|
|
19172
19432
|
init_portable();
|
|
19173
19433
|
|
|
19174
19434
|
// src/evals/pull.ts
|
|
19175
|
-
var
|
|
19435
|
+
var import_zod11 = require("zod");
|
|
19176
19436
|
init_definition();
|
|
19177
19437
|
init_portable();
|
|
19178
19438
|
var SNAPSHOT_VERSION = 1;
|
|
19179
|
-
var PulledEvaluatorSchema =
|
|
19180
|
-
slug:
|
|
19181
|
-
name:
|
|
19182
|
-
expectedSha256:
|
|
19183
|
-
artifact:
|
|
19439
|
+
var PulledEvaluatorSchema = import_zod11.z.object({
|
|
19440
|
+
slug: import_zod11.z.string().min(1),
|
|
19441
|
+
name: import_zod11.z.string().min(1),
|
|
19442
|
+
expectedSha256: import_zod11.z.string().regex(/^[a-f0-9]{64}$/),
|
|
19443
|
+
artifact: import_zod11.z.unknown()
|
|
19184
19444
|
});
|
|
19185
|
-
var EvalSnapshotSchema =
|
|
19186
|
-
schemaVersion:
|
|
19187
|
-
pulledAt:
|
|
19188
|
-
dataset:
|
|
19189
|
-
reference:
|
|
19190
|
-
datasetId:
|
|
19191
|
-
fingerprint:
|
|
19192
|
-
rows:
|
|
19193
|
-
|
|
19194
|
-
id:
|
|
19195
|
-
name:
|
|
19196
|
-
input:
|
|
19197
|
-
output:
|
|
19198
|
-
properties:
|
|
19445
|
+
var EvalSnapshotSchema = import_zod11.z.object({
|
|
19446
|
+
schemaVersion: import_zod11.z.literal(SNAPSHOT_VERSION),
|
|
19447
|
+
pulledAt: import_zod11.z.string().datetime(),
|
|
19448
|
+
dataset: import_zod11.z.object({
|
|
19449
|
+
reference: import_zod11.z.string().min(1),
|
|
19450
|
+
datasetId: import_zod11.z.string().uuid(),
|
|
19451
|
+
fingerprint: import_zod11.z.string().regex(/^[a-f0-9]{64}$/),
|
|
19452
|
+
rows: import_zod11.z.array(
|
|
19453
|
+
import_zod11.z.object({
|
|
19454
|
+
id: import_zod11.z.string(),
|
|
19455
|
+
name: import_zod11.z.string(),
|
|
19456
|
+
input: import_zod11.z.string().nullable(),
|
|
19457
|
+
output: import_zod11.z.string().nullable(),
|
|
19458
|
+
properties: import_zod11.z.record(import_zod11.z.string())
|
|
19199
19459
|
})
|
|
19200
19460
|
)
|
|
19201
19461
|
}),
|
|
19202
|
-
evaluators:
|
|
19462
|
+
evaluators: import_zod11.z.array(PulledEvaluatorSchema)
|
|
19203
19463
|
});
|
|
19204
19464
|
async function pullEval(client, options) {
|
|
19205
19465
|
var _a;
|
|
@@ -19264,11 +19524,11 @@ async function pullEvaluator(client, queryUrl, rawSlug) {
|
|
|
19264
19524
|
`Raindrop evaluator ${rawSlug} pull failed with ${response.status}: ${await response.text()}`
|
|
19265
19525
|
);
|
|
19266
19526
|
}
|
|
19267
|
-
const body =
|
|
19268
|
-
data:
|
|
19269
|
-
slug:
|
|
19270
|
-
name:
|
|
19271
|
-
artifact:
|
|
19527
|
+
const body = import_zod11.z.object({
|
|
19528
|
+
data: import_zod11.z.object({
|
|
19529
|
+
slug: import_zod11.z.string(),
|
|
19530
|
+
name: import_zod11.z.string(),
|
|
19531
|
+
artifact: import_zod11.z.unknown().nullable()
|
|
19272
19532
|
})
|
|
19273
19533
|
}).parse(await response.json());
|
|
19274
19534
|
if (!body.data.artifact)
|
|
@@ -19405,46 +19665,46 @@ function outputMismatch(name, output) {
|
|
|
19405
19665
|
init_portable();
|
|
19406
19666
|
|
|
19407
19667
|
// src/evals/workshop.ts
|
|
19408
|
-
var
|
|
19409
|
-
var WorkshopRunSchema =
|
|
19410
|
-
id:
|
|
19411
|
-
event_id:
|
|
19412
|
-
name:
|
|
19413
|
-
event_name:
|
|
19414
|
-
user_id:
|
|
19415
|
-
convo_id:
|
|
19416
|
-
started_at:
|
|
19417
|
-
last_updated_at:
|
|
19418
|
-
metadata:
|
|
19419
|
-
model:
|
|
19420
|
-
finished:
|
|
19668
|
+
var import_zod12 = require("zod");
|
|
19669
|
+
var WorkshopRunSchema = import_zod12.z.object({
|
|
19670
|
+
id: import_zod12.z.string(),
|
|
19671
|
+
event_id: import_zod12.z.string().nullable(),
|
|
19672
|
+
name: import_zod12.z.string().nullable(),
|
|
19673
|
+
event_name: import_zod12.z.string().nullable(),
|
|
19674
|
+
user_id: import_zod12.z.string().nullable(),
|
|
19675
|
+
convo_id: import_zod12.z.string().nullable(),
|
|
19676
|
+
started_at: import_zod12.z.number().nullable(),
|
|
19677
|
+
last_updated_at: import_zod12.z.number().nullable(),
|
|
19678
|
+
metadata: import_zod12.z.string().nullable(),
|
|
19679
|
+
model: import_zod12.z.string().nullable(),
|
|
19680
|
+
finished: import_zod12.z.number().nullable()
|
|
19421
19681
|
});
|
|
19422
|
-
var WorkshopSpanSchema =
|
|
19423
|
-
id:
|
|
19424
|
-
run_id:
|
|
19425
|
-
parent_span_id:
|
|
19426
|
-
name:
|
|
19427
|
-
span_type:
|
|
19428
|
-
status:
|
|
19429
|
-
input_payload:
|
|
19430
|
-
output_payload:
|
|
19431
|
-
start_time_ms:
|
|
19432
|
-
end_time_ms:
|
|
19433
|
-
duration_ms:
|
|
19434
|
-
model:
|
|
19435
|
-
provider:
|
|
19436
|
-
input_tokens:
|
|
19437
|
-
output_tokens:
|
|
19438
|
-
attributes:
|
|
19682
|
+
var WorkshopSpanSchema = import_zod12.z.object({
|
|
19683
|
+
id: import_zod12.z.string(),
|
|
19684
|
+
run_id: import_zod12.z.string(),
|
|
19685
|
+
parent_span_id: import_zod12.z.string().nullable(),
|
|
19686
|
+
name: import_zod12.z.string(),
|
|
19687
|
+
span_type: import_zod12.z.string().nullable(),
|
|
19688
|
+
status: import_zod12.z.string().nullable(),
|
|
19689
|
+
input_payload: import_zod12.z.string().nullable(),
|
|
19690
|
+
output_payload: import_zod12.z.string().nullable(),
|
|
19691
|
+
start_time_ms: import_zod12.z.number().nullable(),
|
|
19692
|
+
end_time_ms: import_zod12.z.number().nullable(),
|
|
19693
|
+
duration_ms: import_zod12.z.number().nullable(),
|
|
19694
|
+
model: import_zod12.z.string().nullable(),
|
|
19695
|
+
provider: import_zod12.z.string().nullable(),
|
|
19696
|
+
input_tokens: import_zod12.z.number().nullable(),
|
|
19697
|
+
output_tokens: import_zod12.z.number().nullable(),
|
|
19698
|
+
attributes: import_zod12.z.string().nullable()
|
|
19439
19699
|
});
|
|
19440
|
-
var WorkshopTraceEnvelopeSchema =
|
|
19441
|
-
status:
|
|
19442
|
-
correlationId:
|
|
19443
|
-
traceId:
|
|
19444
|
-
rootSpanId:
|
|
19445
|
-
spanCount:
|
|
19700
|
+
var WorkshopTraceEnvelopeSchema = import_zod12.z.object({
|
|
19701
|
+
status: import_zod12.z.literal("complete"),
|
|
19702
|
+
correlationId: import_zod12.z.string(),
|
|
19703
|
+
traceId: import_zod12.z.string(),
|
|
19704
|
+
rootSpanId: import_zod12.z.string(),
|
|
19705
|
+
spanCount: import_zod12.z.number().int().positive(),
|
|
19446
19706
|
run: WorkshopRunSchema,
|
|
19447
|
-
spans:
|
|
19707
|
+
spans: import_zod12.z.array(WorkshopSpanSchema).min(1)
|
|
19448
19708
|
});
|
|
19449
19709
|
async function readWorkshopTrace(input) {
|
|
19450
19710
|
if (!Number.isFinite(input.waitMs) || input.waitMs < 0)
|
|
@@ -19529,7 +19789,28 @@ function serializableOutput(value) {
|
|
|
19529
19789
|
// src/evals/run.ts
|
|
19530
19790
|
var DEFAULT_WORKSHOP_TRACE_WAIT_MS = 3e4;
|
|
19531
19791
|
function createEvalSuiteRun(client, definition, options) {
|
|
19792
|
+
var _a;
|
|
19532
19793
|
const validated = validateDefinition(definition);
|
|
19794
|
+
const execution = bindSuite(validated, (_a = options.parameters) != null ? _a : {});
|
|
19795
|
+
const session = createSuiteSession(client, validated, execution.run, options);
|
|
19796
|
+
let finishing;
|
|
19797
|
+
return {
|
|
19798
|
+
id: session.id,
|
|
19799
|
+
run: (selection) => session.run(selection),
|
|
19800
|
+
finish: () => finishing != null ? finishing : finishing = finishWith(execution, () => session.finish())
|
|
19801
|
+
};
|
|
19802
|
+
}
|
|
19803
|
+
function bindSuite(definition, parameters) {
|
|
19804
|
+
if (definition.agent === void 0) {
|
|
19805
|
+
const { run } = definition;
|
|
19806
|
+
return {
|
|
19807
|
+
run: (row) => Promise.resolve().then(() => run(row)),
|
|
19808
|
+
finish: () => Promise.resolve()
|
|
19809
|
+
};
|
|
19810
|
+
}
|
|
19811
|
+
return definition.agent.start(parameters);
|
|
19812
|
+
}
|
|
19813
|
+
function createSuiteSession(client, validated, run, options) {
|
|
19533
19814
|
if (validated.datasetVersionId && "selection" in options && options.selection.dataset.version.id !== validated.datasetVersionId) {
|
|
19534
19815
|
throw new Error("Selected dataset version does not match the published suite");
|
|
19535
19816
|
}
|
|
@@ -19557,6 +19838,7 @@ function createEvalSuiteRun(client, definition, options) {
|
|
|
19557
19838
|
return new RaindropRowEvalRun(
|
|
19558
19839
|
client,
|
|
19559
19840
|
validated,
|
|
19841
|
+
run,
|
|
19560
19842
|
options.destination,
|
|
19561
19843
|
options.selection.dataset,
|
|
19562
19844
|
selection.rowIds,
|
|
@@ -19581,19 +19863,26 @@ function createEvalSuiteRun(client, definition, options) {
|
|
|
19581
19863
|
return new WorkshopEvalRun(
|
|
19582
19864
|
client,
|
|
19583
19865
|
{ ...validated, dataset: validated.dataset },
|
|
19866
|
+
run,
|
|
19584
19867
|
options.destination
|
|
19585
19868
|
);
|
|
19586
19869
|
}
|
|
19587
19870
|
async function runEvalSuite(client, definition, options = {}) {
|
|
19871
|
+
var _a;
|
|
19872
|
+
const validated = validateDefinition(definition);
|
|
19873
|
+
const execution = bindSuite(validated, (_a = options.parameters) != null ? _a : {});
|
|
19874
|
+
return finishWith(execution, () => runSuite(client, validated, execution.run, options));
|
|
19875
|
+
}
|
|
19876
|
+
async function runSuite(client, definition, run, options) {
|
|
19588
19877
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19589
|
-
let validated =
|
|
19878
|
+
let validated = definition;
|
|
19590
19879
|
const destination = (_a = options.destination) != null ? _a : { kind: "raindrop" };
|
|
19591
19880
|
if (validated.datasetVersionId && ((_b = options.selection) == null ? void 0 : _b.dataset) && options.selection.dataset.version.id !== validated.datasetVersionId) {
|
|
19592
19881
|
throw new Error("Selected dataset version does not match the published suite");
|
|
19593
19882
|
}
|
|
19594
19883
|
if (destination.kind === "workshop") {
|
|
19595
19884
|
if (options.runId !== void 0) throw new Error("Queued runs are only supported in Raindrop");
|
|
19596
|
-
const session =
|
|
19885
|
+
const session = createSuiteSession(client, validated, run, { destination });
|
|
19597
19886
|
await session.run({ selection: options.selection, attempt: options.attempt });
|
|
19598
19887
|
return session.finish();
|
|
19599
19888
|
}
|
|
@@ -19627,7 +19916,7 @@ async function runEvalSuite(client, definition, options = {}) {
|
|
|
19627
19916
|
rowIds: (_h = (_g = options.selection) == null ? void 0 : _g.rowIds) != null ? _h : dataset.rows.map((entry) => entry.id)
|
|
19628
19917
|
});
|
|
19629
19918
|
if (!selection) throw new Error("Raindrop remote eval requires selected rows");
|
|
19630
|
-
const session =
|
|
19919
|
+
const session = createSuiteSession(client, validated, run, {
|
|
19631
19920
|
destination,
|
|
19632
19921
|
selection: { dataset, rowIds: selection.rowIds }
|
|
19633
19922
|
});
|
|
@@ -19661,7 +19950,7 @@ async function runEvalSuite(client, definition, options = {}) {
|
|
|
19661
19950
|
}
|
|
19662
19951
|
return finished;
|
|
19663
19952
|
}
|
|
19664
|
-
return runRaindropEval(client, validated, destination, options);
|
|
19953
|
+
return runRaindropEval(client, validated, run, destination, options);
|
|
19665
19954
|
}
|
|
19666
19955
|
function isRowScopedLocalEval(definition) {
|
|
19667
19956
|
return definition.evaluators.every(
|
|
@@ -19669,9 +19958,10 @@ function isRowScopedLocalEval(definition) {
|
|
|
19669
19958
|
);
|
|
19670
19959
|
}
|
|
19671
19960
|
var RaindropRowEvalRun = class {
|
|
19672
|
-
constructor(client, definition, destination, dataset, rowIds, evaluators) {
|
|
19961
|
+
constructor(client, definition, runRow, destination, dataset, rowIds, evaluators) {
|
|
19673
19962
|
this.client = client;
|
|
19674
19963
|
this.definition = definition;
|
|
19964
|
+
this.runRow = runRow;
|
|
19675
19965
|
this.destination = destination;
|
|
19676
19966
|
this.dataset = dataset;
|
|
19677
19967
|
this.rowIds = rowIds;
|
|
@@ -19721,7 +20011,7 @@ var RaindropRowEvalRun = class {
|
|
|
19721
20011
|
const attemptResult = await replay2.run({
|
|
19722
20012
|
rowId,
|
|
19723
20013
|
attempt,
|
|
19724
|
-
run: this.
|
|
20014
|
+
run: this.runRow,
|
|
19725
20015
|
traceWaitMs: this.definition.traceWaitMs
|
|
19726
20016
|
});
|
|
19727
20017
|
const configured = new Map(
|
|
@@ -19826,9 +20116,10 @@ function replayEvaluatorsFromVerdicts(verdicts) {
|
|
|
19826
20116
|
return [...evaluators.values()];
|
|
19827
20117
|
}
|
|
19828
20118
|
var WorkshopEvalRun = class {
|
|
19829
|
-
constructor(client, definition, destination) {
|
|
20119
|
+
constructor(client, definition, runRow, destination) {
|
|
19830
20120
|
this.client = client;
|
|
19831
20121
|
this.definition = definition;
|
|
20122
|
+
this.runRow = runRow;
|
|
19832
20123
|
this.destination = destination;
|
|
19833
20124
|
this.id = randomId();
|
|
19834
20125
|
this.startedAt = /* @__PURE__ */ new Date();
|
|
@@ -19958,7 +20249,7 @@ var WorkshopEvalRun = class {
|
|
|
19958
20249
|
() => {
|
|
19959
20250
|
var _a2;
|
|
19960
20251
|
const parent = (_a2 = import_api8.trace.getSpan(import_api8.context.active())) == null ? void 0 : _a2.spanContext();
|
|
19961
|
-
if (!parent) return this.
|
|
20252
|
+
if (!parent) return this.runRow(row);
|
|
19962
20253
|
return withReplayTraceDestination(
|
|
19963
20254
|
{
|
|
19964
20255
|
...destination,
|
|
@@ -19968,7 +20259,7 @@ var WorkshopEvalRun = class {
|
|
|
19968
20259
|
eventId: parent.traceId
|
|
19969
20260
|
}
|
|
19970
20261
|
},
|
|
19971
|
-
() => this.
|
|
20262
|
+
() => this.runRow(row)
|
|
19972
20263
|
);
|
|
19973
20264
|
}
|
|
19974
20265
|
)
|
|
@@ -20146,7 +20437,7 @@ var WorkshopEvalRun = class {
|
|
|
20146
20437
|
return current;
|
|
20147
20438
|
}
|
|
20148
20439
|
};
|
|
20149
|
-
async function runRaindropEval(client, definition, destination, options) {
|
|
20440
|
+
async function runRaindropEval(client, definition, run, destination, options) {
|
|
20150
20441
|
var _a, _b, _c, _d;
|
|
20151
20442
|
if (typeof definition.dataset !== "string") {
|
|
20152
20443
|
throw new Error(
|
|
@@ -20173,7 +20464,7 @@ async function runRaindropEval(client, definition, destination, options) {
|
|
|
20173
20464
|
dataset: pinnedDataset ? datasetToWire(pinnedDataset) : datasetReference,
|
|
20174
20465
|
evaluators: definition.evaluators.map((entry) => replayEvaluator(entry)),
|
|
20175
20466
|
evaluatorPins: hostedEvaluatorPins(definition.evaluators),
|
|
20176
|
-
run
|
|
20467
|
+
run,
|
|
20177
20468
|
concurrency: definition.concurrency,
|
|
20178
20469
|
traceWaitMs: definition.traceWaitMs,
|
|
20179
20470
|
evalWaitMs: definition.evalWaitMs,
|
|
@@ -21833,6 +22124,7 @@ var withEvalScope2 = withEvalScope;
|
|
|
21833
22124
|
EVAL_CORRELATION_ID_ATTRIBUTE,
|
|
21834
22125
|
EvalDatasetPublishConflictError,
|
|
21835
22126
|
EvalDatasetRowInputSchema,
|
|
22127
|
+
EvalParameterError,
|
|
21836
22128
|
EvalPublishError,
|
|
21837
22129
|
LocalBooleanVerdictSchema,
|
|
21838
22130
|
LocalNumberVerdictSchema,
|
|
@@ -21851,9 +22143,11 @@ var withEvalScope2 = withEvalScope;
|
|
|
21851
22143
|
TraceSchema,
|
|
21852
22144
|
claimReplay,
|
|
21853
22145
|
compareEvalRuns,
|
|
22146
|
+
createEvalHandler,
|
|
21854
22147
|
createEvalSuiteRun,
|
|
21855
22148
|
createReplay,
|
|
21856
22149
|
currentEvalScope,
|
|
22150
|
+
defineAgent,
|
|
21857
22151
|
defineDataset,
|
|
21858
22152
|
defineEvalSuite,
|
|
21859
22153
|
defineEvaluatorProgram,
|