raindrop-ai 0.5.0-otelv2 → 0.6.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 CHANGED
@@ -67,6 +67,41 @@ On runtimes that lack a usable `AsyncLocalStorage.enterWith` (notably Cloudflare
67
67
 
68
68
  ## Eval mode
69
69
 
70
+ Run your agent locally and store eval results in hosted Raindrop. Workshop is not required. Define a reusable suite with `defineEvalSuite`, then run it with `runEvalSuite` or the `@raindrop-ai/vitest` adapter. Input-only datasets require the SDK release with optional-reference support and the matching Raindrop backend.
71
+
72
+ ```ts
73
+ import Raindrop, { defineEvalSuite, runEvalSuite } from "raindrop-ai";
74
+ import { supportAgent } from "./support-agent";
75
+
76
+ const client = new Raindrop({
77
+ apiKey: process.env.RAINDROP_QUERY_API_KEY,
78
+ projectId: process.env.RAINDROP_PROJECT_ID,
79
+ localWorkshopUrl: false,
80
+ });
81
+
82
+ const suite = defineEvalSuite({
83
+ name: "Support responses",
84
+ dataset: "support-cases",
85
+ run: ({ input }) => supportAgent(input ?? ""),
86
+ evaluators: [{ evaluator: "task-completed", threshold: { equals: true } }],
87
+ });
88
+
89
+ try {
90
+ const result = await runEvalSuite(client, suite, {
91
+ destination: { kind: "raindrop" },
92
+ });
93
+ console.log(result);
94
+ } finally {
95
+ await client.close();
96
+ }
97
+ ```
98
+
99
+ The dataset string names a published, project-scoped eval dataset, not an ordinary custom-upload dataset ID. Publish its immutable version with `publishEvalDataset`. Cases can contain only input and scenario properties; an optional reference must be a complete captured trace. Local evaluators can declare `requiresReference: true`, and hosted programs can export `const requiresReference = true`, to reject missing references before agent execution. A local `defineDataset` object does not publish itself and is not accepted by the hosted runner. See the [Vitest guide](../vitest/README.md) for publication, evaluator requirements, and credential setup.
100
+
101
+ The Query SDK organization `apiKey` authenticates evals, dataset publication/reads, and replay trace uploads. Browser login and production `writeKey` credentials do not replace it. The agent's model credentials and test environment are separate. Running locally describes where your callback executes, not where results are stored.
102
+
103
+ ### Trace correlation
104
+
70
105
  A replay calls your agent once per row and needs every span and event that call
71
106
  emits to land on that row. `withEvalScope` binds one opaque **correlation id**
72
107
  to the execution context, so it does, with no change to the agent:
@@ -115,9 +150,9 @@ Both limits are demonstrated by tests in `packages/core/src/eval-scope.test.ts`.
115
150
 
116
151
  ### Replaying a dataset
117
152
 
118
- `replay` is the loop that uses the scope. It asks Raindrop for the dataset's
119
- rows, calls your agent once per row inside that row's scope, says which rows
120
- failed, and waits for the traces to land:
153
+ `replay` is the lower-level loop used by hosted suite execution. It reads the
154
+ published dataset's immutable version, calls your agent once per row inside
155
+ that row's scope, reports failed rows, and waits for the traces to land:
121
156
 
122
157
  ```ts
123
158
  import Raindrop, { replay } from "raindrop-ai";
@@ -707,7 +707,7 @@ var EvalCaseTracePairSchema = z2.object({
707
707
  }),
708
708
  reference: EvalCaseTraceSchema.extend({
709
709
  trace: TraceSchema.extend({ origin: z2.literal("dataset") })
710
- })
710
+ }).optional()
711
711
  });
712
712
  function compareNanoseconds(left, right) {
713
713
  if (Number.isFinite(left) && Number.isFinite(right))
@@ -1007,7 +1007,7 @@ function traceOutput(trace) {
1007
1007
  function traceToolCalls(trace, name) {
1008
1008
  return trace.entries.filter((entry) => entry.type === "tool_call" && (name === void 0 || entry.name === name));
1009
1009
  }
1010
- var TRACE_PROJECTION_SHA256 = "8dab83087aa2def3d076324021d5e08911e37967b68597b58b793a80d54b5874";
1010
+ var TRACE_PROJECTION_SHA256 = "7d12eb03150b8f203e4404622f047676f50b3aa1e5442f0ed42d77d6002a33a6";
1011
1011
 
1012
1012
  // src/evals/portable.ts
1013
1013
  import { z as z3 } from "zod";
@@ -1095,7 +1095,7 @@ async function evaluatePortableEvaluator(evaluator, input) {
1095
1095
  const artifact = await verifyPortableEvalArtifact(evaluator.artifact, {
1096
1096
  expectedSha256: evaluator.expectedSha256
1097
1097
  });
1098
- const { runPortableEvaluator } = await import("./portable-runtime-GBE3SHBZ.mjs");
1098
+ const { runPortableEvaluator } = await import("./portable-runtime-QZKU2VXS.mjs");
1099
1099
  const cases = (_a = input.cases) != null ? _a : [];
1100
1100
  if (cases.length > 0 && (cases.length !== input.traces.length || cases.some(
1101
1101
  (entry, index) => {
@@ -1238,7 +1238,7 @@ installTracingSuppressionHook();
1238
1238
  // package.json
1239
1239
  var package_default = {
1240
1240
  name: "raindrop-ai",
1241
- version: "0.5.0",
1241
+ version: "0.6.0",
1242
1242
  main: "dist/index.js",
1243
1243
  module: "dist/index.mjs",
1244
1244
  types: "dist/index.d.ts",
@@ -1082,7 +1082,7 @@ declare const EvalDatasetCaseInputSchema: z.ZodObject<{
1082
1082
  name: z.ZodString;
1083
1083
  input: z.ZodNullable<z.ZodString>;
1084
1084
  properties: z.ZodRecord<z.ZodString, z.ZodString>;
1085
- referenceTrace: z.ZodEffects<z.ZodObject<{
1085
+ referenceTrace: z.ZodOptional<z.ZodEffects<z.ZodObject<{
1086
1086
  event: z.ZodObject<{
1087
1087
  id: z.ZodString;
1088
1088
  _raindropDatabaseId: z.ZodString;
@@ -5470,13 +5470,13 @@ declare const EvalDatasetCaseInputSchema: z.ZodObject<{
5470
5470
  end_timestamp: string;
5471
5471
  _inserted_at: string;
5472
5472
  }[];
5473
- }>;
5473
+ }>>;
5474
5474
  }, "strict", z.ZodTypeAny, {
5475
5475
  properties: Record<string, string>;
5476
5476
  input: string | null;
5477
5477
  name: string;
5478
5478
  id: string;
5479
- referenceTrace: {
5479
+ referenceTrace?: {
5480
5480
  event: {
5481
5481
  properties: Record<string, unknown> | null;
5482
5482
  timestamp: string;
@@ -5873,13 +5873,13 @@ declare const EvalDatasetCaseInputSchema: z.ZodObject<{
5873
5873
  end_timestamp: string;
5874
5874
  _inserted_at: string;
5875
5875
  }[];
5876
- };
5876
+ } | undefined;
5877
5877
  }, {
5878
5878
  properties: Record<string, string>;
5879
5879
  input: string | null;
5880
5880
  name: string;
5881
5881
  id: string;
5882
- referenceTrace: {
5882
+ referenceTrace?: {
5883
5883
  event: {
5884
5884
  properties: Record<string, unknown> | null;
5885
5885
  timestamp: string;
@@ -6276,7 +6276,7 @@ declare const EvalDatasetCaseInputSchema: z.ZodObject<{
6276
6276
  end_timestamp: string;
6277
6277
  _inserted_at: string;
6278
6278
  }[];
6279
- };
6279
+ } | undefined;
6280
6280
  }>;
6281
6281
  type EvalDatasetCaseInput = z.infer<typeof EvalDatasetCaseInputSchema>;
6282
6282
  declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
@@ -6289,7 +6289,7 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
6289
6289
  name: z.ZodString;
6290
6290
  input: z.ZodNullable<z.ZodString>;
6291
6291
  properties: z.ZodRecord<z.ZodString, z.ZodString>;
6292
- referenceTrace: z.ZodEffects<z.ZodObject<{
6292
+ referenceTrace: z.ZodOptional<z.ZodEffects<z.ZodObject<{
6293
6293
  event: z.ZodObject<{
6294
6294
  id: z.ZodString;
6295
6295
  _raindropDatabaseId: z.ZodString;
@@ -10677,13 +10677,13 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
10677
10677
  end_timestamp: string;
10678
10678
  _inserted_at: string;
10679
10679
  }[];
10680
- }>;
10680
+ }>>;
10681
10681
  }, "strict", z.ZodTypeAny, {
10682
10682
  properties: Record<string, string>;
10683
10683
  input: string | null;
10684
10684
  name: string;
10685
10685
  id: string;
10686
- referenceTrace: {
10686
+ referenceTrace?: {
10687
10687
  event: {
10688
10688
  properties: Record<string, unknown> | null;
10689
10689
  timestamp: string;
@@ -11080,13 +11080,13 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
11080
11080
  end_timestamp: string;
11081
11081
  _inserted_at: string;
11082
11082
  }[];
11083
- };
11083
+ } | undefined;
11084
11084
  }, {
11085
11085
  properties: Record<string, string>;
11086
11086
  input: string | null;
11087
11087
  name: string;
11088
11088
  id: string;
11089
- referenceTrace: {
11089
+ referenceTrace?: {
11090
11090
  event: {
11091
11091
  properties: Record<string, unknown> | null;
11092
11092
  timestamp: string;
@@ -11483,13 +11483,13 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
11483
11483
  end_timestamp: string;
11484
11484
  _inserted_at: string;
11485
11485
  }[];
11486
- };
11486
+ } | undefined;
11487
11487
  }>, "many">, {
11488
11488
  properties: Record<string, string>;
11489
11489
  input: string | null;
11490
11490
  name: string;
11491
11491
  id: string;
11492
- referenceTrace: {
11492
+ referenceTrace?: {
11493
11493
  event: {
11494
11494
  properties: Record<string, unknown> | null;
11495
11495
  timestamp: string;
@@ -11886,13 +11886,13 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
11886
11886
  end_timestamp: string;
11887
11887
  _inserted_at: string;
11888
11888
  }[];
11889
- };
11889
+ } | undefined;
11890
11890
  }[], {
11891
11891
  properties: Record<string, string>;
11892
11892
  input: string | null;
11893
11893
  name: string;
11894
11894
  id: string;
11895
- referenceTrace: {
11895
+ referenceTrace?: {
11896
11896
  event: {
11897
11897
  properties: Record<string, unknown> | null;
11898
11898
  timestamp: string;
@@ -12289,7 +12289,7 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
12289
12289
  end_timestamp: string;
12290
12290
  _inserted_at: string;
12291
12291
  }[];
12292
- };
12292
+ } | undefined;
12293
12293
  }[]>;
12294
12294
  }, "strict", z.ZodTypeAny, {
12295
12295
  name: string;
@@ -12301,7 +12301,7 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
12301
12301
  input: string | null;
12302
12302
  name: string;
12303
12303
  id: string;
12304
- referenceTrace: {
12304
+ referenceTrace?: {
12305
12305
  event: {
12306
12306
  properties: Record<string, unknown> | null;
12307
12307
  timestamp: string;
@@ -12698,7 +12698,7 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
12698
12698
  end_timestamp: string;
12699
12699
  _inserted_at: string;
12700
12700
  }[];
12701
- };
12701
+ } | undefined;
12702
12702
  }[];
12703
12703
  }, {
12704
12704
  name: string;
@@ -12710,7 +12710,7 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
12710
12710
  input: string | null;
12711
12711
  name: string;
12712
12712
  id: string;
12713
- referenceTrace: {
12713
+ referenceTrace?: {
12714
12714
  event: {
12715
12715
  properties: Record<string, unknown> | null;
12716
12716
  timestamp: string;
@@ -13107,7 +13107,7 @@ declare const PublishEvalDatasetVersionInputSchema: z.ZodObject<{
13107
13107
  end_timestamp: string;
13108
13108
  _inserted_at: string;
13109
13109
  }[];
13110
- };
13110
+ } | undefined;
13111
13111
  }[];
13112
13112
  }>;
13113
13113
  type PublishEvalDatasetVersionInput = z.infer<typeof PublishEvalDatasetVersionInputSchema>;
@@ -13138,7 +13138,7 @@ declare const EvalDatasetManifestSchema: z.ZodObject<{
13138
13138
  name: z.ZodString;
13139
13139
  input: z.ZodNullable<z.ZodString>;
13140
13140
  properties: z.ZodRecord<z.ZodString, z.ZodString>;
13141
- referenceTrace: z.ZodEffects<z.ZodObject<{
13141
+ referenceTrace: z.ZodOptional<z.ZodEffects<z.ZodObject<{
13142
13142
  event: z.ZodObject<{
13143
13143
  id: z.ZodString;
13144
13144
  _raindropDatabaseId: z.ZodString;
@@ -17526,15 +17526,15 @@ declare const EvalDatasetManifestSchema: z.ZodObject<{
17526
17526
  end_timestamp: string;
17527
17527
  _inserted_at: string;
17528
17528
  }[];
17529
- }>;
17529
+ }>>;
17530
17530
  } & {
17531
- referenceTraceSha256: z.ZodString;
17531
+ referenceTraceSha256: z.ZodOptional<z.ZodString>;
17532
17532
  }, "strict", z.ZodTypeAny, {
17533
17533
  properties: Record<string, string>;
17534
17534
  input: string | null;
17535
17535
  name: string;
17536
17536
  id: string;
17537
- referenceTrace: {
17537
+ referenceTrace?: {
17538
17538
  event: {
17539
17539
  properties: Record<string, unknown> | null;
17540
17540
  timestamp: string;
@@ -17931,14 +17931,14 @@ declare const EvalDatasetManifestSchema: z.ZodObject<{
17931
17931
  end_timestamp: string;
17932
17932
  _inserted_at: string;
17933
17933
  }[];
17934
- };
17935
- referenceTraceSha256: string;
17934
+ } | undefined;
17935
+ referenceTraceSha256?: string | undefined;
17936
17936
  }, {
17937
17937
  properties: Record<string, string>;
17938
17938
  input: string | null;
17939
17939
  name: string;
17940
17940
  id: string;
17941
- referenceTrace: {
17941
+ referenceTrace?: {
17942
17942
  event: {
17943
17943
  properties: Record<string, unknown> | null;
17944
17944
  timestamp: string;
@@ -18335,8 +18335,8 @@ declare const EvalDatasetManifestSchema: z.ZodObject<{
18335
18335
  end_timestamp: string;
18336
18336
  _inserted_at: string;
18337
18337
  }[];
18338
- };
18339
- referenceTraceSha256: string;
18338
+ } | undefined;
18339
+ referenceTraceSha256?: string | undefined;
18340
18340
  }>, "many">;
18341
18341
  createdAt: z.ZodString;
18342
18342
  }, "cases">, "strip", z.ZodTypeAny, {
@@ -18357,7 +18357,7 @@ declare const EvalDatasetManifestSchema: z.ZodObject<{
18357
18357
  name: z.ZodString;
18358
18358
  input: z.ZodNullable<z.ZodString>;
18359
18359
  properties: z.ZodRecord<z.ZodString, z.ZodString>;
18360
- referenceTrace: z.ZodEffects<z.ZodObject<{
18360
+ referenceTrace: z.ZodOptional<z.ZodEffects<z.ZodObject<{
18361
18361
  event: z.ZodObject<{
18362
18362
  id: z.ZodString;
18363
18363
  _raindropDatabaseId: z.ZodString;
@@ -22745,23 +22745,23 @@ declare const EvalDatasetManifestSchema: z.ZodObject<{
22745
22745
  end_timestamp: string;
22746
22746
  _inserted_at: string;
22747
22747
  }[];
22748
- }>;
22748
+ }>>;
22749
22749
  } & {
22750
- referenceTraceSha256: z.ZodString;
22750
+ referenceTraceSha256: z.ZodOptional<z.ZodString>;
22751
22751
  }, "properties" | "input" | "name" | "id"> & {
22752
- referenceTraceSha256: z.ZodString;
22752
+ referenceTraceSha256: z.ZodOptional<z.ZodString>;
22753
22753
  }, "strict", z.ZodTypeAny, {
22754
22754
  properties: Record<string, string>;
22755
22755
  input: string | null;
22756
22756
  name: string;
22757
22757
  id: string;
22758
- referenceTraceSha256: string;
22758
+ referenceTraceSha256?: string | undefined;
22759
22759
  }, {
22760
22760
  properties: Record<string, string>;
22761
22761
  input: string | null;
22762
22762
  name: string;
22763
22763
  id: string;
22764
- referenceTraceSha256: string;
22764
+ referenceTraceSha256?: string | undefined;
22765
22765
  }>, "many">;
22766
22766
  }, "strip", z.ZodTypeAny, {
22767
22767
  dataset: {
@@ -22775,7 +22775,7 @@ declare const EvalDatasetManifestSchema: z.ZodObject<{
22775
22775
  input: string | null;
22776
22776
  name: string;
22777
22777
  id: string;
22778
- referenceTraceSha256: string;
22778
+ referenceTraceSha256?: string | undefined;
22779
22779
  }[];
22780
22780
  version: {
22781
22781
  id: string;
@@ -22796,7 +22796,7 @@ declare const EvalDatasetManifestSchema: z.ZodObject<{
22796
22796
  input: string | null;
22797
22797
  name: string;
22798
22798
  id: string;
22799
- referenceTraceSha256: string;
22799
+ referenceTraceSha256?: string | undefined;
22800
22800
  }[];
22801
22801
  version: {
22802
22802
  id: string;
@@ -43264,7 +43264,7 @@ declare const EvalCaseTracePairSchema: z$1.ZodObject<{
43264
43264
  origin: "replay";
43265
43265
  };
43266
43266
  }>;
43267
- reference: z$1.ZodObject<{
43267
+ reference: z$1.ZodOptional<z$1.ZodObject<{
43268
43268
  snapshot: z$1.ZodEffects<z$1.ZodObject<{
43269
43269
  event: z$1.ZodObject<{
43270
43270
  id: z$1.ZodString;
@@ -54793,9 +54793,10 @@ declare const EvalCaseTracePairSchema: z$1.ZodObject<{
54793
54793
  })[];
54794
54794
  origin: "dataset";
54795
54795
  };
54796
- }>;
54796
+ }>>;
54797
54797
  }, "strip", z$1.ZodTypeAny, {
54798
- reference: {
54798
+ caseId: string;
54799
+ candidate: {
54799
54800
  snapshot: {
54800
54801
  event: {
54801
54802
  properties: Record<string, unknown> | null;
@@ -55818,11 +55819,10 @@ declare const EvalCaseTracePairSchema: z$1.ZodObject<{
55818
55819
  fromAgent: string;
55819
55820
  toAgent: string;
55820
55821
  })[];
55821
- origin: "dataset";
55822
+ origin: "replay";
55822
55823
  };
55823
55824
  };
55824
- caseId: string;
55825
- candidate: {
55825
+ reference?: {
55826
55826
  snapshot: {
55827
55827
  event: {
55828
55828
  properties: Record<string, unknown> | null;
@@ -56845,11 +56845,12 @@ declare const EvalCaseTracePairSchema: z$1.ZodObject<{
56845
56845
  fromAgent: string;
56846
56846
  toAgent: string;
56847
56847
  })[];
56848
- origin: "replay";
56848
+ origin: "dataset";
56849
56849
  };
56850
- };
56850
+ } | undefined;
56851
56851
  }, {
56852
- reference: {
56852
+ caseId: string;
56853
+ candidate: {
56853
56854
  snapshot: {
56854
56855
  event: {
56855
56856
  properties: Record<string, unknown> | null;
@@ -57872,11 +57873,10 @@ declare const EvalCaseTracePairSchema: z$1.ZodObject<{
57872
57873
  fromAgent: string;
57873
57874
  toAgent: string;
57874
57875
  })[];
57875
- origin: "dataset";
57876
+ origin: "replay";
57876
57877
  };
57877
57878
  };
57878
- caseId: string;
57879
- candidate: {
57879
+ reference?: {
57880
57880
  snapshot: {
57881
57881
  event: {
57882
57882
  properties: Record<string, unknown> | null;
@@ -58899,9 +58899,9 @@ declare const EvalCaseTracePairSchema: z$1.ZodObject<{
58899
58899
  fromAgent: string;
58900
58900
  toAgent: string;
58901
58901
  })[];
58902
- origin: "replay";
58902
+ origin: "dataset";
58903
58903
  };
58904
- };
58904
+ } | undefined;
58905
58905
  }>;
58906
58906
  type EvalCaseTracePair = z$1.infer<typeof EvalCaseTracePairSchema>;
58907
58907
  type TraceNanoseconds = number | string;
@@ -59769,6 +59769,8 @@ type LocalEvaluatorContext$1<AgentResult = unknown> = {
59769
59769
  type LocalJudge<AgentResult, Verdict> = (context: LocalEvaluatorContext$1<AgentResult>) => Verdict | Promise<Verdict>;
59770
59770
  /** A named evaluator whose implementation stays in the customer's process. */
59771
59771
  type LocalEvaluator<AgentResult = unknown> = {
59772
+ readonly requiresReference?: boolean;
59773
+ } & ({
59772
59774
  readonly slug: string;
59773
59775
  readonly name: string;
59774
59776
  readonly output: "boolean";
@@ -59783,7 +59785,7 @@ type LocalEvaluator<AgentResult = unknown> = {
59783
59785
  readonly name: string;
59784
59786
  readonly output: "number";
59785
59787
  readonly judge: LocalJudge<AgentResult, LocalNumberVerdict>;
59786
- };
59788
+ });
59787
59789
  type CreateReplayOptions = {
59788
59790
  /** A project-scoped dataset slug, or a manifest already pinned by discovery. */
59789
59791
  dataset: string | EvalDatasetManifest;
@@ -60113,6 +60115,8 @@ type LocalEvaluatorContext<AgentResult = unknown> = {
60113
60115
  readonly result: AgentResult;
60114
60116
  };
60115
60117
  type LocalEvaluatorBase<AgentResult, Output, Verdict> = {
60118
+ /** Reject input-only cases before the agent runs when this evaluator needs a baseline. */
60119
+ readonly requiresReference?: boolean;
60116
60120
  readonly slug: string;
60117
60121
  readonly name: string;
60118
60122
  readonly output: Output;
@@ -60176,7 +60180,7 @@ type PublishEvalDatasetOptions = {
60176
60180
  readonly slug: string;
60177
60181
  /** Display name. Publishing a new version does not rename an existing dataset. */
60178
60182
  readonly name: PublishEvalDatasetVersionInput["name"];
60179
- /** Ordered cases. Each reference is a complete captured trace snapshot. */
60183
+ /** Ordered scenarios. Supplied references must be complete captured trace snapshots. */
60180
60184
  readonly cases: readonly EvalDatasetCaseInput[];
60181
60185
  /** Omit or pass null to create. Pass the discovered current version when changing evidence. */
60182
60186
  readonly expectedCurrentVersionId?: string | null;