@mastra/spanner 1.2.0 → 1.2.1-alpha.1

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/index.js CHANGED
@@ -2967,6 +2967,10 @@ function rowToDataset(row) {
2967
2967
  targetIds: t.targetIds ?? null,
2968
2968
  scorerIds: t.scorerIds ?? null,
2969
2969
  version: Number(t.version ?? 0),
2970
+ organizationId: t.organizationId ?? null,
2971
+ projectId: t.projectId ?? null,
2972
+ candidateKey: t.candidateKey ?? null,
2973
+ candidateId: t.candidateId ?? null,
2970
2974
  createdAt: toDate(t.createdAt),
2971
2975
  updatedAt: toDate(t.updatedAt)
2972
2976
  };
@@ -2977,9 +2981,12 @@ function rowToItem(row) {
2977
2981
  id: String(t.id),
2978
2982
  datasetId: String(t.datasetId),
2979
2983
  datasetVersion: Number(t.datasetVersion),
2984
+ organizationId: t.organizationId ?? null,
2985
+ projectId: t.projectId ?? null,
2980
2986
  input: t.input,
2981
2987
  groundTruth: t.groundTruth ?? void 0,
2982
2988
  expectedTrajectory: t.expectedTrajectory ?? void 0,
2989
+ toolMocks: t.toolMocks ?? void 0,
2983
2990
  requestContext: t.requestContext ?? void 0,
2984
2991
  metadata: t.metadata ?? void 0,
2985
2992
  source: t.source ?? void 0,
@@ -3022,6 +3029,16 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3022
3029
  await this.db.createTable({ tableName: TABLE_DATASETS, schema: TABLE_SCHEMAS[TABLE_DATASETS] });
3023
3030
  await this.db.createTable({ tableName: TABLE_DATASET_ITEMS, schema: TABLE_SCHEMAS[TABLE_DATASET_ITEMS] });
3024
3031
  await this.db.createTable({ tableName: TABLE_DATASET_VERSIONS, schema: TABLE_SCHEMAS[TABLE_DATASET_VERSIONS] });
3032
+ await this.db.alterTable({
3033
+ tableName: TABLE_DATASETS,
3034
+ schema: TABLE_SCHEMAS[TABLE_DATASETS],
3035
+ ifNotExists: ["organizationId", "projectId", "candidateKey", "candidateId"]
3036
+ });
3037
+ await this.db.alterTable({
3038
+ tableName: TABLE_DATASET_ITEMS,
3039
+ schema: TABLE_SCHEMAS[TABLE_DATASET_ITEMS],
3040
+ ifNotExists: ["organizationId", "projectId"]
3041
+ });
3025
3042
  await this.createDefaultIndexes();
3026
3043
  await this.createCustomIndexes();
3027
3044
  }
@@ -3082,6 +3099,10 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3082
3099
  targetIds: input.targetIds ?? null,
3083
3100
  scorerIds: input.scorerIds ?? null,
3084
3101
  version: 0,
3102
+ organizationId: input.organizationId ?? null,
3103
+ projectId: input.projectId ?? null,
3104
+ candidateKey: input.candidateKey ?? null,
3105
+ candidateId: input.candidateId ?? null,
3085
3106
  createdAt: now,
3086
3107
  updatedAt: now
3087
3108
  };
@@ -3100,6 +3121,10 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3100
3121
  targetIds: record.targetIds,
3101
3122
  scorerIds: record.scorerIds,
3102
3123
  version: 0,
3124
+ organizationId: record.organizationId,
3125
+ projectId: record.projectId,
3126
+ candidateKey: record.candidateKey,
3127
+ candidateId: record.candidateId,
3103
3128
  createdAt: now,
3104
3129
  updatedAt: now
3105
3130
  }
@@ -3229,8 +3254,28 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3229
3254
  const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
3230
3255
  try {
3231
3256
  const tableName = quoteIdent(TABLE_DATASETS, "table name");
3257
+ const filterConditions = [];
3258
+ const filterParams = {};
3259
+ if (args.filters?.organizationId !== void 0) {
3260
+ filterConditions.push(`${quoteIdent("organizationId", "column name")} = @organizationId`);
3261
+ filterParams.organizationId = args.filters.organizationId;
3262
+ }
3263
+ if (args.filters?.projectId !== void 0) {
3264
+ filterConditions.push(`${quoteIdent("projectId", "column name")} = @projectId`);
3265
+ filterParams.projectId = args.filters.projectId;
3266
+ }
3267
+ if (args.filters?.candidateKey !== void 0) {
3268
+ filterConditions.push(`${quoteIdent("candidateKey", "column name")} = @candidateKey`);
3269
+ filterParams.candidateKey = args.filters.candidateKey;
3270
+ }
3271
+ if (args.filters?.candidateId !== void 0) {
3272
+ filterConditions.push(`${quoteIdent("candidateId", "column name")} = @candidateId`);
3273
+ filterParams.candidateId = args.filters.candidateId;
3274
+ }
3275
+ const whereClause = filterConditions.length > 0 ? `WHERE ${filterConditions.join(" AND ")}` : "";
3232
3276
  const [countRows] = await this.database.run({
3233
- sql: `SELECT COUNT(*) AS count FROM ${tableName}`,
3277
+ sql: `SELECT COUNT(*) AS count FROM ${tableName} ${whereClause}`,
3278
+ params: filterParams,
3234
3279
  json: true
3235
3280
  });
3236
3281
  const total = Number(countRows[0]?.count ?? 0);
@@ -3239,10 +3284,10 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3239
3284
  }
3240
3285
  const limit = perPageInput === false ? total : perPage;
3241
3286
  const [rows] = await this.database.run({
3242
- sql: `SELECT * FROM ${tableName}
3287
+ sql: `SELECT * FROM ${tableName} ${whereClause}
3243
3288
  ORDER BY ${quoteIdent("createdAt", "column name")} DESC, ${quoteIdent("id", "column name")} ASC
3244
3289
  LIMIT @limit OFFSET @offset`,
3245
- params: { limit, offset },
3290
+ params: { ...filterParams, limit, offset },
3246
3291
  json: true
3247
3292
  });
3248
3293
  const datasets = rows.map(rowToDataset);
@@ -3269,10 +3314,13 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3269
3314
  // ==========================================================================
3270
3315
  // SCD-2 helpers
3271
3316
  // ==========================================================================
3272
- /** Reads and increments the dataset version inside `tx`; throws if missing. */
3317
+ /** Reads and increments the dataset version inside `tx`; throws if missing. Also returns parent tenancy. */
3273
3318
  async bumpVersion(tx, datasetId, now) {
3274
3319
  const [rows] = await tx.run({
3275
- sql: `SELECT ${quoteIdent("version", "column name")} AS version FROM ${quoteIdent(TABLE_DATASETS, "table name")}
3320
+ sql: `SELECT ${quoteIdent("version", "column name")} AS version,
3321
+ ${quoteIdent("organizationId", "column name")} AS organizationId,
3322
+ ${quoteIdent("projectId", "column name")} AS projectId
3323
+ FROM ${quoteIdent(TABLE_DATASETS, "table name")}
3276
3324
  WHERE ${quoteIdent("id", "column name")} = @id LIMIT 1`,
3277
3325
  params: { id: datasetId },
3278
3326
  json: true
@@ -3296,7 +3344,7 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3296
3344
  params: { newVersion, now: now.toISOString(), id: datasetId },
3297
3345
  types: { now: "timestamp" }
3298
3346
  });
3299
- return newVersion;
3347
+ return { version: newVersion, organizationId: row.organizationId ?? null, projectId: row.projectId ?? null };
3300
3348
  }
3301
3349
  /** Inserts a dataset version snapshot row inside `tx`. */
3302
3350
  async insertVersionRow(tx, datasetId, version, now) {
@@ -3341,18 +3389,21 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3341
3389
  await this.db.runWithAbortRetry(
3342
3390
  () => this.database.runTransactionAsync(async (tx) => {
3343
3391
  try {
3344
- const newVersion = await this.bumpVersion(tx, args.datasetId, now);
3392
+ const { version: newVersion, organizationId, projectId } = await this.bumpVersion(tx, args.datasetId, now);
3345
3393
  await this.db.insert({
3346
3394
  tableName: TABLE_DATASET_ITEMS,
3347
3395
  record: {
3348
3396
  id: itemId,
3349
3397
  datasetId: args.datasetId,
3350
3398
  datasetVersion: newVersion,
3399
+ organizationId,
3400
+ projectId,
3351
3401
  validTo: null,
3352
3402
  isDeleted: false,
3353
3403
  input: args.input,
3354
3404
  groundTruth: args.groundTruth ?? null,
3355
3405
  expectedTrajectory: args.expectedTrajectory ?? null,
3406
+ toolMocks: args.toolMocks ?? null,
3356
3407
  requestContext: args.requestContext ?? null,
3357
3408
  metadata: args.metadata ?? null,
3358
3409
  source: args.source ?? null,
@@ -3367,9 +3418,12 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3367
3418
  id: itemId,
3368
3419
  datasetId: args.datasetId,
3369
3420
  datasetVersion: newVersion,
3421
+ organizationId,
3422
+ projectId,
3370
3423
  input: args.input,
3371
3424
  groundTruth: args.groundTruth,
3372
3425
  expectedTrajectory: args.expectedTrajectory,
3426
+ toolMocks: args.toolMocks,
3373
3427
  requestContext: args.requestContext,
3374
3428
  metadata: args.metadata,
3375
3429
  source: args.source,
@@ -3422,6 +3476,7 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3422
3476
  input: args.input !== void 0 ? args.input : existing.input,
3423
3477
  groundTruth: args.groundTruth !== void 0 ? args.groundTruth : existing.groundTruth,
3424
3478
  expectedTrajectory: args.expectedTrajectory !== void 0 ? args.expectedTrajectory : existing.expectedTrajectory,
3479
+ toolMocks: args.toolMocks !== void 0 ? args.toolMocks : existing.toolMocks,
3425
3480
  requestContext: args.requestContext !== void 0 ? args.requestContext : existing.requestContext,
3426
3481
  metadata: args.metadata !== void 0 ? args.metadata : existing.metadata,
3427
3482
  source: args.source !== void 0 ? args.source : existing.source
@@ -3431,7 +3486,7 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3431
3486
  await this.db.runWithAbortRetry(
3432
3487
  () => this.database.runTransactionAsync(async (tx) => {
3433
3488
  try {
3434
- const newVersion = await this.bumpVersion(tx, args.datasetId, now);
3489
+ const { version: newVersion, organizationId, projectId } = await this.bumpVersion(tx, args.datasetId, now);
3435
3490
  await this.closeCurrentRow(tx, args.id, newVersion);
3436
3491
  await this.db.insert({
3437
3492
  tableName: TABLE_DATASET_ITEMS,
@@ -3439,11 +3494,14 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3439
3494
  id: args.id,
3440
3495
  datasetId: args.datasetId,
3441
3496
  datasetVersion: newVersion,
3497
+ organizationId,
3498
+ projectId,
3442
3499
  validTo: null,
3443
3500
  isDeleted: false,
3444
3501
  input: merged.input,
3445
3502
  groundTruth: merged.groundTruth ?? null,
3446
3503
  expectedTrajectory: merged.expectedTrajectory ?? null,
3504
+ toolMocks: merged.toolMocks ?? null,
3447
3505
  requestContext: merged.requestContext ?? null,
3448
3506
  metadata: merged.metadata ?? null,
3449
3507
  source: merged.source ?? null,
@@ -3458,9 +3516,12 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3458
3516
  id: args.id,
3459
3517
  datasetId: args.datasetId,
3460
3518
  datasetVersion: newVersion,
3519
+ organizationId,
3520
+ projectId,
3461
3521
  input: merged.input,
3462
3522
  groundTruth: merged.groundTruth,
3463
3523
  expectedTrajectory: merged.expectedTrajectory,
3524
+ toolMocks: merged.toolMocks,
3464
3525
  requestContext: merged.requestContext,
3465
3526
  metadata: merged.metadata,
3466
3527
  source: merged.source,
@@ -3505,7 +3566,7 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3505
3566
  await this.db.runWithAbortRetry(
3506
3567
  () => this.database.runTransactionAsync(async (tx) => {
3507
3568
  try {
3508
- const newVersion = await this.bumpVersion(tx, args.datasetId, now);
3569
+ const { version: newVersion, organizationId, projectId } = await this.bumpVersion(tx, args.datasetId, now);
3509
3570
  await this.closeCurrentRow(tx, args.id, newVersion);
3510
3571
  await this.db.insert({
3511
3572
  tableName: TABLE_DATASET_ITEMS,
@@ -3513,11 +3574,14 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3513
3574
  id: args.id,
3514
3575
  datasetId: args.datasetId,
3515
3576
  datasetVersion: newVersion,
3577
+ organizationId,
3578
+ projectId,
3516
3579
  validTo: null,
3517
3580
  isDeleted: true,
3518
3581
  input: existing.input,
3519
3582
  groundTruth: existing.groundTruth ?? null,
3520
3583
  expectedTrajectory: existing.expectedTrajectory ?? null,
3584
+ toolMocks: existing.toolMocks ?? null,
3521
3585
  requestContext: existing.requestContext ?? null,
3522
3586
  metadata: existing.metadata ?? null,
3523
3587
  source: existing.source ?? null,
@@ -3555,6 +3619,14 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3555
3619
  try {
3556
3620
  const conditions = [`${quoteIdent("datasetId", "column name")} = @datasetId`];
3557
3621
  const params = { datasetId: args.datasetId };
3622
+ if (args.filters?.organizationId !== void 0) {
3623
+ conditions.push(`${quoteIdent("organizationId", "column name")} = @organizationId`);
3624
+ params.organizationId = args.filters.organizationId;
3625
+ }
3626
+ if (args.filters?.projectId !== void 0) {
3627
+ conditions.push(`${quoteIdent("projectId", "column name")} = @projectId`);
3628
+ params.projectId = args.filters.projectId;
3629
+ }
3558
3630
  if (args.version !== void 0) {
3559
3631
  conditions.push(`${quoteIdent("datasetVersion", "column name")} <= @version`);
3560
3632
  conditions.push(
@@ -3776,7 +3848,7 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3776
3848
  await this.db.runWithAbortRetry(
3777
3849
  () => this.database.runTransactionAsync(async (tx) => {
3778
3850
  try {
3779
- const newVersion = await this.bumpVersion(tx, input.datasetId, now);
3851
+ const { version: newVersion, organizationId, projectId } = await this.bumpVersion(tx, input.datasetId, now);
3780
3852
  for (const { id, item } of prepared) {
3781
3853
  await this.db.insert({
3782
3854
  tableName: TABLE_DATASET_ITEMS,
@@ -3784,11 +3856,14 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3784
3856
  id,
3785
3857
  datasetId: input.datasetId,
3786
3858
  datasetVersion: newVersion,
3859
+ organizationId,
3860
+ projectId,
3787
3861
  validTo: null,
3788
3862
  isDeleted: false,
3789
3863
  input: item.input,
3790
3864
  groundTruth: item.groundTruth ?? null,
3791
3865
  expectedTrajectory: item.expectedTrajectory ?? null,
3866
+ toolMocks: item.toolMocks ?? null,
3792
3867
  requestContext: item.requestContext ?? null,
3793
3868
  metadata: item.metadata ?? null,
3794
3869
  source: item.source ?? null,
@@ -3804,9 +3879,12 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3804
3879
  id,
3805
3880
  datasetId: input.datasetId,
3806
3881
  datasetVersion: newVersion,
3882
+ organizationId,
3883
+ projectId,
3807
3884
  input: item.input,
3808
3885
  groundTruth: item.groundTruth,
3809
3886
  expectedTrajectory: item.expectedTrajectory,
3887
+ toolMocks: item.toolMocks,
3810
3888
  requestContext: item.requestContext,
3811
3889
  metadata: item.metadata,
3812
3890
  source: item.source,
@@ -3846,7 +3924,7 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3846
3924
  await this.db.runWithAbortRetry(
3847
3925
  () => this.database.runTransactionAsync(async (tx) => {
3848
3926
  try {
3849
- const newVersion = await this.bumpVersion(tx, input.datasetId, now);
3927
+ const { version: newVersion, organizationId, projectId } = await this.bumpVersion(tx, input.datasetId, now);
3850
3928
  for (const existing of current) {
3851
3929
  await this.closeCurrentRow(tx, existing.id, newVersion);
3852
3930
  await this.db.insert({
@@ -3855,11 +3933,14 @@ var DatasetsSpanner = class _DatasetsSpanner extends DatasetsStorage {
3855
3933
  id: existing.id,
3856
3934
  datasetId: input.datasetId,
3857
3935
  datasetVersion: newVersion,
3936
+ organizationId,
3937
+ projectId,
3858
3938
  validTo: null,
3859
3939
  isDeleted: true,
3860
3940
  input: existing.input,
3861
3941
  groundTruth: existing.groundTruth ?? null,
3862
3942
  expectedTrajectory: existing.expectedTrajectory ?? null,
3943
+ toolMocks: existing.toolMocks ?? null,
3863
3944
  requestContext: existing.requestContext ?? null,
3864
3945
  metadata: existing.metadata ?? null,
3865
3946
  source: existing.source ?? null,
@@ -3904,6 +3985,8 @@ function rowToExperiment(row) {
3904
3985
  metadata: t.metadata ?? void 0,
3905
3986
  datasetId: t.datasetId ?? null,
3906
3987
  datasetVersion: t.datasetVersion == null ? null : Number(t.datasetVersion),
3988
+ organizationId: t.organizationId ?? null,
3989
+ projectId: t.projectId ?? null,
3907
3990
  targetType: t.targetType,
3908
3991
  targetId: String(t.targetId),
3909
3992
  status: t.status,
@@ -3925,6 +4008,8 @@ function rowToExperimentResult(row) {
3925
4008
  experimentId: String(t.experimentId),
3926
4009
  itemId: String(t.itemId),
3927
4010
  itemDatasetVersion: t.itemDatasetVersion == null ? null : Number(t.itemDatasetVersion),
4011
+ organizationId: t.organizationId ?? null,
4012
+ projectId: t.projectId ?? null,
3928
4013
  input: t.input ?? null,
3929
4014
  output: t.output ?? null,
3930
4015
  groundTruth: t.groundTruth ?? null,
@@ -3935,6 +4020,7 @@ function rowToExperimentResult(row) {
3935
4020
  traceId: t.traceId ?? null,
3936
4021
  status: t.status ?? null,
3937
4022
  tags: t.tags ?? null,
4023
+ toolMockReport: t.toolMockReport ?? null,
3938
4024
  createdAt: toDate2(t.createdAt)
3939
4025
  };
3940
4026
  }
@@ -3955,6 +4041,16 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
3955
4041
  async init() {
3956
4042
  await this.db.createTable({ tableName: TABLE_EXPERIMENTS, schema: TABLE_SCHEMAS[TABLE_EXPERIMENTS] });
3957
4043
  await this.db.createTable({ tableName: TABLE_EXPERIMENT_RESULTS, schema: TABLE_SCHEMAS[TABLE_EXPERIMENT_RESULTS] });
4044
+ await this.db.alterTable({
4045
+ tableName: TABLE_EXPERIMENTS,
4046
+ schema: TABLE_SCHEMAS[TABLE_EXPERIMENTS],
4047
+ ifNotExists: ["organizationId", "projectId"]
4048
+ });
4049
+ await this.db.alterTable({
4050
+ tableName: TABLE_EXPERIMENT_RESULTS,
4051
+ schema: TABLE_SCHEMAS[TABLE_EXPERIMENT_RESULTS],
4052
+ ifNotExists: ["organizationId", "projectId"]
4053
+ });
3958
4054
  await this.createDefaultIndexes();
3959
4055
  await this.createCustomIndexes();
3960
4056
  }
@@ -3976,6 +4072,17 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
3976
4072
  table: TABLE_EXPERIMENT_RESULTS,
3977
4073
  columns: ["experimentId", "itemId"],
3978
4074
  unique: true
4075
+ },
4076
+ // Tenancy: leading-tenant indexes for multi-tenant scans (parity with datasets domain).
4077
+ {
4078
+ name: "mastra_experiments_org_project_idx",
4079
+ table: TABLE_EXPERIMENTS,
4080
+ columns: ["organizationId", "projectId"]
4081
+ },
4082
+ {
4083
+ name: "mastra_experiment_results_org_project_idx",
4084
+ table: TABLE_EXPERIMENT_RESULTS,
4085
+ columns: ["organizationId", "projectId"]
3979
4086
  }
3980
4087
  ];
3981
4088
  }
@@ -4002,6 +4109,8 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
4002
4109
  metadata: input.metadata ?? void 0,
4003
4110
  datasetId: input.datasetId ?? null,
4004
4111
  datasetVersion: input.datasetVersion ?? null,
4112
+ organizationId: input.organizationId ?? null,
4113
+ projectId: input.projectId ?? null,
4005
4114
  targetType: input.targetType,
4006
4115
  targetId: input.targetId,
4007
4116
  status: "pending",
@@ -4024,6 +4133,8 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
4024
4133
  metadata: experiment.metadata ?? null,
4025
4134
  datasetId: experiment.datasetId,
4026
4135
  datasetVersion: experiment.datasetVersion,
4136
+ organizationId: experiment.organizationId,
4137
+ projectId: experiment.projectId,
4027
4138
  targetType: experiment.targetType,
4028
4139
  targetId: experiment.targetId,
4029
4140
  status: experiment.status,
@@ -4142,6 +4253,17 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
4142
4253
  conditions.push(`${quoteIdent("status", "column name")} = @status`);
4143
4254
  params.status = args.status;
4144
4255
  }
4256
+ if (args.filters) {
4257
+ const { organizationId, projectId } = args.filters;
4258
+ if (organizationId !== void 0) {
4259
+ conditions.push(`${quoteIdent("organizationId", "column name")} = @organizationId`);
4260
+ params.organizationId = organizationId;
4261
+ }
4262
+ if (projectId !== void 0) {
4263
+ conditions.push(`${quoteIdent("projectId", "column name")} = @projectId`);
4264
+ params.projectId = projectId;
4265
+ }
4266
+ }
4145
4267
  const whereSql = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
4146
4268
  const tableName = quoteIdent(TABLE_EXPERIMENTS, "table name");
4147
4269
  const [countRows] = await this.database.run({
@@ -4226,6 +4348,8 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
4226
4348
  experimentId: input.experimentId,
4227
4349
  itemId: input.itemId,
4228
4350
  itemDatasetVersion: input.itemDatasetVersion ?? null,
4351
+ organizationId: input.organizationId ?? null,
4352
+ projectId: input.projectId ?? null,
4229
4353
  input: input.input ?? null,
4230
4354
  output: input.output ?? null,
4231
4355
  groundTruth: input.groundTruth ?? null,
@@ -4236,6 +4360,7 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
4236
4360
  traceId: input.traceId ?? null,
4237
4361
  status: input.status ?? null,
4238
4362
  tags: input.tags ?? null,
4363
+ toolMockReport: input.toolMockReport ?? null,
4239
4364
  createdAt: now
4240
4365
  };
4241
4366
  await this.db.insert({
@@ -4245,6 +4370,8 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
4245
4370
  experimentId: result.experimentId,
4246
4371
  itemId: result.itemId,
4247
4372
  itemDatasetVersion: result.itemDatasetVersion,
4373
+ organizationId: result.organizationId,
4374
+ projectId: result.projectId,
4248
4375
  input: result.input,
4249
4376
  output: result.output,
4250
4377
  groundTruth: result.groundTruth,
@@ -4255,6 +4382,7 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
4255
4382
  traceId: result.traceId,
4256
4383
  status: result.status,
4257
4384
  tags: result.tags,
4385
+ toolMockReport: result.toolMockReport,
4258
4386
  createdAt: now
4259
4387
  }
4260
4388
  });
@@ -4377,6 +4505,17 @@ var ExperimentsSpanner = class _ExperimentsSpanner extends ExperimentsStorage {
4377
4505
  conditions.push(`${quoteIdent("status", "column name")} = @status`);
4378
4506
  params.status = args.status;
4379
4507
  }
4508
+ if (args.filters) {
4509
+ const { organizationId, projectId } = args.filters;
4510
+ if (organizationId !== void 0) {
4511
+ conditions.push(`${quoteIdent("organizationId", "column name")} = @organizationId`);
4512
+ params.organizationId = organizationId;
4513
+ }
4514
+ if (projectId !== void 0) {
4515
+ conditions.push(`${quoteIdent("projectId", "column name")} = @projectId`);
4516
+ params.projectId = projectId;
4517
+ }
4518
+ }
4380
4519
  const whereSql = `WHERE ${conditions.join(" AND ")}`;
4381
4520
  const tableName = quoteIdent(TABLE_EXPERIMENT_RESULTS, "table name");
4382
4521
  const [countRows] = await this.database.run({