@mastra/upstash 0.10.3-alpha.1 → 0.10.3-alpha.3

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
@@ -361,36 +361,36 @@ var init_version = __esm({
361
361
  }
362
362
  });
363
363
 
364
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js
364
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js
365
365
  var init_SemanticAttributes = __esm({
366
- "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js"() {
366
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js"() {
367
367
  }
368
368
  });
369
369
 
370
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js
370
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js
371
371
  var init_trace = __esm({
372
- "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js"() {
372
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js"() {
373
373
  init_SemanticAttributes();
374
374
  }
375
375
  });
376
376
 
377
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
377
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
378
378
  var init_SemanticResourceAttributes = __esm({
379
- "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js"() {
379
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js"() {
380
380
  }
381
381
  });
382
382
 
383
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js
383
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js
384
384
  var init_resource = __esm({
385
- "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js"() {
385
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js"() {
386
386
  init_SemanticResourceAttributes();
387
387
  }
388
388
  });
389
389
 
390
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
390
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
391
391
  var ATTR_TELEMETRY_SDK_LANGUAGE, TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_VERSION;
392
392
  var init_stable_attributes = __esm({
393
- "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js"() {
393
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js"() {
394
394
  ATTR_TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language";
395
395
  TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS = "nodejs";
396
396
  ATTR_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
@@ -398,15 +398,15 @@ var init_stable_attributes = __esm({
398
398
  }
399
399
  });
400
400
 
401
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js
401
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js
402
402
  var init_stable_metrics = __esm({
403
- "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js"() {
403
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js"() {
404
404
  }
405
405
  });
406
406
 
407
- // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
407
+ // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
408
408
  var init_esm2 = __esm({
409
- "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.34.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js"() {
409
+ "../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.33.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js"() {
410
410
  init_trace();
411
411
  init_resource();
412
412
  init_stable_attributes();
@@ -1695,9 +1695,9 @@ var require_pool = __commonJS({
1695
1695
  }
1696
1696
  });
1697
1697
 
1698
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/util/longbits.js
1698
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/util/longbits.js
1699
1699
  var require_longbits = __commonJS({
1700
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/util/longbits.js"(exports2, module2) {
1700
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/util/longbits.js"(exports2, module2) {
1701
1701
  module2.exports = LongBits;
1702
1702
  var util = require_minimal();
1703
1703
  function LongBits(lo, hi) {
@@ -1796,9 +1796,9 @@ var require_longbits = __commonJS({
1796
1796
  }
1797
1797
  });
1798
1798
 
1799
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/util/minimal.js
1799
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/util/minimal.js
1800
1800
  var require_minimal = __commonJS({
1801
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/util/minimal.js"(exports2) {
1801
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/util/minimal.js"(exports2) {
1802
1802
  var util = exports2;
1803
1803
  util.asPromise = require_aspromise();
1804
1804
  util.base64 = require_base64();
@@ -1970,9 +1970,9 @@ var require_minimal = __commonJS({
1970
1970
  }
1971
1971
  });
1972
1972
 
1973
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/writer.js
1973
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/writer.js
1974
1974
  var require_writer = __commonJS({
1975
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/writer.js"(exports2, module2) {
1975
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/writer.js"(exports2, module2) {
1976
1976
  module2.exports = Writer;
1977
1977
  var util = require_minimal();
1978
1978
  var BufferWriter;
@@ -2160,9 +2160,9 @@ var require_writer = __commonJS({
2160
2160
  }
2161
2161
  });
2162
2162
 
2163
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/writer_buffer.js
2163
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/writer_buffer.js
2164
2164
  var require_writer_buffer = __commonJS({
2165
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/writer_buffer.js"(exports2, module2) {
2165
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/writer_buffer.js"(exports2, module2) {
2166
2166
  module2.exports = BufferWriter;
2167
2167
  var Writer = require_writer();
2168
2168
  (BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
@@ -2209,9 +2209,9 @@ var require_writer_buffer = __commonJS({
2209
2209
  }
2210
2210
  });
2211
2211
 
2212
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/reader.js
2212
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/reader.js
2213
2213
  var require_reader = __commonJS({
2214
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/reader.js"(exports2, module2) {
2214
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/reader.js"(exports2, module2) {
2215
2215
  module2.exports = Reader;
2216
2216
  var util = require_minimal();
2217
2217
  var BufferReader;
@@ -2432,9 +2432,9 @@ var require_reader = __commonJS({
2432
2432
  }
2433
2433
  });
2434
2434
 
2435
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/reader_buffer.js
2435
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/reader_buffer.js
2436
2436
  var require_reader_buffer = __commonJS({
2437
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/reader_buffer.js"(exports2, module2) {
2437
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/reader_buffer.js"(exports2, module2) {
2438
2438
  module2.exports = BufferReader;
2439
2439
  var Reader = require_reader();
2440
2440
  (BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
@@ -2454,9 +2454,9 @@ var require_reader_buffer = __commonJS({
2454
2454
  }
2455
2455
  });
2456
2456
 
2457
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/rpc/service.js
2457
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/rpc/service.js
2458
2458
  var require_service = __commonJS({
2459
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/rpc/service.js"(exports2, module2) {
2459
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/rpc/service.js"(exports2, module2) {
2460
2460
  module2.exports = Service;
2461
2461
  var util = require_minimal();
2462
2462
  (Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service;
@@ -2528,24 +2528,24 @@ var require_service = __commonJS({
2528
2528
  }
2529
2529
  });
2530
2530
 
2531
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/rpc.js
2531
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/rpc.js
2532
2532
  var require_rpc = __commonJS({
2533
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/rpc.js"(exports2) {
2533
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/rpc.js"(exports2) {
2534
2534
  var rpc = exports2;
2535
2535
  rpc.Service = require_service();
2536
2536
  }
2537
2537
  });
2538
2538
 
2539
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/roots.js
2539
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/roots.js
2540
2540
  var require_roots = __commonJS({
2541
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/roots.js"(exports2, module2) {
2541
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/roots.js"(exports2, module2) {
2542
2542
  module2.exports = {};
2543
2543
  }
2544
2544
  });
2545
2545
 
2546
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/index-minimal.js
2546
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/index-minimal.js
2547
2547
  var require_index_minimal = __commonJS({
2548
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/src/index-minimal.js"(exports2) {
2548
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/src/index-minimal.js"(exports2) {
2549
2549
  var protobuf = exports2;
2550
2550
  protobuf.build = "minimal";
2551
2551
  protobuf.Writer = require_writer();
@@ -2565,9 +2565,9 @@ var require_index_minimal = __commonJS({
2565
2565
  }
2566
2566
  });
2567
2567
 
2568
- // ../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/minimal.js
2568
+ // ../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/minimal.js
2569
2569
  var require_minimal2 = __commonJS({
2570
- "../../node_modules/.pnpm/protobufjs@7.5.3/node_modules/protobufjs/minimal.js"(exports2, module2) {
2570
+ "../../node_modules/.pnpm/protobufjs@7.4.0/node_modules/protobufjs/minimal.js"(exports2, module2) {
2571
2571
  module2.exports = require_index_minimal();
2572
2572
  }
2573
2573
  });
@@ -12226,16 +12226,16 @@ var require_chunk_LABUWBKX = __commonJS({
12226
12226
  }
12227
12227
  });
12228
12228
 
12229
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/Types.js
12229
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/Types.js
12230
12230
  var require_Types = __commonJS({
12231
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/Types.js"(exports2) {
12231
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/Types.js"(exports2) {
12232
12232
  Object.defineProperty(exports2, "__esModule", { value: true });
12233
12233
  }
12234
12234
  });
12235
12235
 
12236
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseAnyOf.js
12236
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseAnyOf.js
12237
12237
  var require_parseAnyOf = __commonJS({
12238
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseAnyOf.js"(exports2) {
12238
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseAnyOf.js"(exports2) {
12239
12239
  Object.defineProperty(exports2, "__esModule", { value: true });
12240
12240
  exports2.parseAnyOf = void 0;
12241
12241
  var parseSchema_js_1 = require_parseSchema();
@@ -12249,9 +12249,9 @@ var require_parseAnyOf = __commonJS({
12249
12249
  }
12250
12250
  });
12251
12251
 
12252
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseBoolean.js
12252
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseBoolean.js
12253
12253
  var require_parseBoolean = __commonJS({
12254
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseBoolean.js"(exports2) {
12254
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseBoolean.js"(exports2) {
12255
12255
  Object.defineProperty(exports2, "__esModule", { value: true });
12256
12256
  exports2.parseBoolean = void 0;
12257
12257
  var parseBoolean = (_schema) => {
@@ -12261,9 +12261,9 @@ var require_parseBoolean = __commonJS({
12261
12261
  }
12262
12262
  });
12263
12263
 
12264
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseDefault.js
12264
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseDefault.js
12265
12265
  var require_parseDefault = __commonJS({
12266
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseDefault.js"(exports2) {
12266
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseDefault.js"(exports2) {
12267
12267
  Object.defineProperty(exports2, "__esModule", { value: true });
12268
12268
  exports2.parseDefault = void 0;
12269
12269
  var parseDefault = (_schema) => {
@@ -12273,22 +12273,22 @@ var require_parseDefault = __commonJS({
12273
12273
  }
12274
12274
  });
12275
12275
 
12276
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseMultipleType.js
12276
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseMultipleType.js
12277
12277
  var require_parseMultipleType = __commonJS({
12278
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseMultipleType.js"(exports2) {
12278
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseMultipleType.js"(exports2) {
12279
12279
  Object.defineProperty(exports2, "__esModule", { value: true });
12280
12280
  exports2.parseMultipleType = void 0;
12281
12281
  var parseSchema_js_1 = require_parseSchema();
12282
12282
  var parseMultipleType = (schema, refs) => {
12283
- return `z.union([${schema.type.map((type) => (0, parseSchema_js_1.parseSchema)({ ...schema, type }, { ...refs, withoutDefaults: true })).join(", ")}])`;
12283
+ return `z.union([${schema.type.map((type) => (0, parseSchema_js_1.parseSchema)({ ...schema, type }, refs)).join(", ")}])`;
12284
12284
  };
12285
12285
  exports2.parseMultipleType = parseMultipleType;
12286
12286
  }
12287
12287
  });
12288
12288
 
12289
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNot.js
12289
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNot.js
12290
12290
  var require_parseNot = __commonJS({
12291
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNot.js"(exports2) {
12291
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNot.js"(exports2) {
12292
12292
  Object.defineProperty(exports2, "__esModule", { value: true });
12293
12293
  exports2.parseNot = void 0;
12294
12294
  var parseSchema_js_1 = require_parseSchema();
@@ -12302,9 +12302,9 @@ var require_parseNot = __commonJS({
12302
12302
  }
12303
12303
  });
12304
12304
 
12305
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNull.js
12305
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNull.js
12306
12306
  var require_parseNull = __commonJS({
12307
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNull.js"(exports2) {
12307
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNull.js"(exports2) {
12308
12308
  Object.defineProperty(exports2, "__esModule", { value: true });
12309
12309
  exports2.parseNull = void 0;
12310
12310
  var parseNull = (_schema) => {
@@ -12314,9 +12314,9 @@ var require_parseNull = __commonJS({
12314
12314
  }
12315
12315
  });
12316
12316
 
12317
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/utils/half.js
12317
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/utils/half.js
12318
12318
  var require_half = __commonJS({
12319
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/utils/half.js"(exports2) {
12319
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/utils/half.js"(exports2) {
12320
12320
  Object.defineProperty(exports2, "__esModule", { value: true });
12321
12321
  exports2.half = void 0;
12322
12322
  var half = (arr) => {
@@ -12326,9 +12326,9 @@ var require_half = __commonJS({
12326
12326
  }
12327
12327
  });
12328
12328
 
12329
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseAllOf.js
12329
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseAllOf.js
12330
12330
  var require_parseAllOf = __commonJS({
12331
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseAllOf.js"(exports2) {
12331
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseAllOf.js"(exports2) {
12332
12332
  Object.defineProperty(exports2, "__esModule", { value: true });
12333
12333
  exports2.parseAllOf = void 0;
12334
12334
  var parseSchema_js_1 = require_parseSchema();
@@ -12368,9 +12368,9 @@ var require_parseAllOf = __commonJS({
12368
12368
  }
12369
12369
  });
12370
12370
 
12371
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/utils/withMessage.js
12371
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/utils/withMessage.js
12372
12372
  var require_withMessage = __commonJS({
12373
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/utils/withMessage.js"(exports2) {
12373
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/utils/withMessage.js"(exports2) {
12374
12374
  Object.defineProperty(exports2, "__esModule", { value: true });
12375
12375
  exports2.withMessage = void 0;
12376
12376
  function withMessage(schema, key, get) {
@@ -12395,9 +12395,9 @@ var require_withMessage = __commonJS({
12395
12395
  }
12396
12396
  });
12397
12397
 
12398
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseArray.js
12398
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseArray.js
12399
12399
  var require_parseArray = __commonJS({
12400
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseArray.js"(exports2) {
12400
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseArray.js"(exports2) {
12401
12401
  Object.defineProperty(exports2, "__esModule", { value: true });
12402
12402
  exports2.parseArray = void 0;
12403
12403
  var withMessage_js_1 = require_withMessage();
@@ -12426,9 +12426,9 @@ var require_parseArray = __commonJS({
12426
12426
  }
12427
12427
  });
12428
12428
 
12429
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseConst.js
12429
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseConst.js
12430
12430
  var require_parseConst = __commonJS({
12431
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseConst.js"(exports2) {
12431
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseConst.js"(exports2) {
12432
12432
  Object.defineProperty(exports2, "__esModule", { value: true });
12433
12433
  exports2.parseConst = void 0;
12434
12434
  var parseConst = (schema) => {
@@ -12438,9 +12438,9 @@ var require_parseConst = __commonJS({
12438
12438
  }
12439
12439
  });
12440
12440
 
12441
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseEnum.js
12441
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseEnum.js
12442
12442
  var require_parseEnum = __commonJS({
12443
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseEnum.js"(exports2) {
12443
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseEnum.js"(exports2) {
12444
12444
  Object.defineProperty(exports2, "__esModule", { value: true });
12445
12445
  exports2.parseEnum = void 0;
12446
12446
  var parseEnum = (schema) => {
@@ -12458,9 +12458,9 @@ var require_parseEnum = __commonJS({
12458
12458
  }
12459
12459
  });
12460
12460
 
12461
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseIfThenElse.js
12461
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseIfThenElse.js
12462
12462
  var require_parseIfThenElse = __commonJS({
12463
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseIfThenElse.js"(exports2) {
12463
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseIfThenElse.js"(exports2) {
12464
12464
  Object.defineProperty(exports2, "__esModule", { value: true });
12465
12465
  exports2.parseIfThenElse = void 0;
12466
12466
  var parseSchema_js_1 = require_parseSchema();
@@ -12487,9 +12487,9 @@ var require_parseIfThenElse = __commonJS({
12487
12487
  }
12488
12488
  });
12489
12489
 
12490
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNumber.js
12490
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNumber.js
12491
12491
  var require_parseNumber = __commonJS({
12492
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNumber.js"(exports2) {
12492
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNumber.js"(exports2) {
12493
12493
  Object.defineProperty(exports2, "__esModule", { value: true });
12494
12494
  exports2.parseNumber = void 0;
12495
12495
  var withMessage_js_1 = require_withMessage();
@@ -12561,9 +12561,9 @@ var require_parseNumber = __commonJS({
12561
12561
  }
12562
12562
  });
12563
12563
 
12564
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseOneOf.js
12564
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseOneOf.js
12565
12565
  var require_parseOneOf = __commonJS({
12566
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseOneOf.js"(exports2) {
12566
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseOneOf.js"(exports2) {
12567
12567
  Object.defineProperty(exports2, "__esModule", { value: true });
12568
12568
  exports2.parseOneOf = void 0;
12569
12569
  var parseSchema_js_1 = require_parseSchema();
@@ -12598,9 +12598,9 @@ var require_parseOneOf = __commonJS({
12598
12598
  }
12599
12599
  });
12600
12600
 
12601
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/utils/jsdocs.js
12601
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/utils/jsdocs.js
12602
12602
  var require_jsdocs = __commonJS({
12603
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/utils/jsdocs.js"(exports2) {
12603
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/utils/jsdocs.js"(exports2) {
12604
12604
  Object.defineProperty(exports2, "__esModule", { value: true });
12605
12605
  exports2.addJsdocs = exports2.expandJsdocs = void 0;
12606
12606
  var expandJsdocs = (jsdocs) => {
@@ -12624,9 +12624,9 @@ ${(0, exports2.expandJsdocs)(description)}${parsed}`;
12624
12624
  }
12625
12625
  });
12626
12626
 
12627
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseObject.js
12627
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseObject.js
12628
12628
  var require_parseObject = __commonJS({
12629
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseObject.js"(exports2) {
12629
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseObject.js"(exports2) {
12630
12630
  Object.defineProperty(exports2, "__esModule", { value: true });
12631
12631
  exports2.parseObject = void 0;
12632
12632
  var parseAnyOf_js_1 = require_parseAnyOf();
@@ -12771,9 +12771,9 @@ var require_parseObject = __commonJS({
12771
12771
  }
12772
12772
  });
12773
12773
 
12774
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseString.js
12774
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseString.js
12775
12775
  var require_parseString = __commonJS({
12776
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseString.js"(exports2) {
12776
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseString.js"(exports2) {
12777
12777
  Object.defineProperty(exports2, "__esModule", { value: true });
12778
12778
  exports2.parseString = void 0;
12779
12779
  var withMessage_js_1 = require_withMessage();
@@ -12853,9 +12853,9 @@ var require_parseString = __commonJS({
12853
12853
  }
12854
12854
  });
12855
12855
 
12856
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/utils/omit.js
12856
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/utils/omit.js
12857
12857
  var require_omit = __commonJS({
12858
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/utils/omit.js"(exports2) {
12858
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/utils/omit.js"(exports2) {
12859
12859
  Object.defineProperty(exports2, "__esModule", { value: true });
12860
12860
  exports2.omit = void 0;
12861
12861
  var omit = (obj, ...keys) => Object.keys(obj).reduce((acc, key) => {
@@ -12868,9 +12868,9 @@ var require_omit = __commonJS({
12868
12868
  }
12869
12869
  });
12870
12870
 
12871
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNullable.js
12871
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNullable.js
12872
12872
  var require_parseNullable = __commonJS({
12873
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNullable.js"(exports2) {
12873
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseNullable.js"(exports2) {
12874
12874
  Object.defineProperty(exports2, "__esModule", { value: true });
12875
12875
  exports2.parseNullable = void 0;
12876
12876
  var omit_js_1 = require_omit();
@@ -12882,9 +12882,9 @@ var require_parseNullable = __commonJS({
12882
12882
  }
12883
12883
  });
12884
12884
 
12885
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseSchema.js
12885
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseSchema.js
12886
12886
  var require_parseSchema = __commonJS({
12887
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/parsers/parseSchema.js"(exports2) {
12887
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/parsers/parseSchema.js"(exports2) {
12888
12888
  Object.defineProperty(exports2, "__esModule", { value: true });
12889
12889
  exports2.its = exports2.parseSchema = void 0;
12890
12890
  var parseAnyOf_js_1 = require_parseAnyOf();
@@ -13013,9 +13013,9 @@ var require_parseSchema = __commonJS({
13013
13013
  }
13014
13014
  });
13015
13015
 
13016
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/jsonSchemaToZod.js
13016
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/jsonSchemaToZod.js
13017
13017
  var require_jsonSchemaToZod = __commonJS({
13018
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/jsonSchemaToZod.js"(exports2) {
13018
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/jsonSchemaToZod.js"(exports2) {
13019
13019
  Object.defineProperty(exports2, "__esModule", { value: true });
13020
13020
  exports2.jsonSchemaToZod = void 0;
13021
13021
  var parseSchema_js_1 = require_parseSchema();
@@ -13062,9 +13062,9 @@ ${result}`;
13062
13062
  }
13063
13063
  });
13064
13064
 
13065
- // ../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/index.js
13065
+ // ../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/index.js
13066
13066
  var require_cjs = __commonJS({
13067
- "../../node_modules/.pnpm/json-schema-to-zod@2.6.1/node_modules/json-schema-to-zod/dist/cjs/index.js"(exports2) {
13067
+ "../../node_modules/.pnpm/json-schema-to-zod@2.6.0/node_modules/json-schema-to-zod/dist/cjs/index.js"(exports2) {
13068
13068
  var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
13069
13069
  if (k2 === void 0) k2 = k;
13070
13070
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -31170,9 +31170,9 @@ var require_chunk_QVROTSA5 = __commonJS({
31170
31170
  }
31171
31171
  });
31172
31172
 
31173
- // ../../packages/core/dist/chunk-H5IRI46R.cjs
31174
- var require_chunk_H5IRI46R = __commonJS({
31175
- "../../packages/core/dist/chunk-H5IRI46R.cjs"(exports2) {
31173
+ // ../../packages/core/dist/chunk-XUODQRSL.cjs
31174
+ var require_chunk_XUODQRSL = __commonJS({
31175
+ "../../packages/core/dist/chunk-XUODQRSL.cjs"(exports2) {
31176
31176
  var chunkQVROTSA5_cjs = require_chunk_QVROTSA5();
31177
31177
  var crypto2 = __require("crypto");
31178
31178
  var ai = require_dist4();
@@ -31744,7 +31744,7 @@ ${JSON.stringify(message, null, 2)}`
31744
31744
  }
31745
31745
  const latestMessagePartType = latestMessage?.content?.parts?.filter((p) => p.type !== `step-start`)?.at?.(-1)?.type;
31746
31746
  const newMessageFirstPartType = messageV2.content.parts.filter((p) => p.type !== `step-start`).at(0)?.type;
31747
- const shouldAppendToLastAssistantMessage = latestMessage?.role === "assistant" && messageV2.role === "assistant";
31747
+ const shouldAppendToLastAssistantMessage = latestMessage?.role === "assistant" && messageV2.role === "assistant" && latestMessage.threadId === messageV2.threadId;
31748
31748
  const shouldAppendToLastAssistantMessageParts = shouldAppendToLastAssistantMessage && newMessageFirstPartType && (newMessageFirstPartType === `tool-invocation` && latestMessagePartType !== `text` || newMessageFirstPartType === latestMessagePartType);
31749
31749
  if (
31750
31750
  // backwards compat check!
@@ -31822,7 +31822,11 @@ ${JSON.stringify(message, null, 2)}`
31822
31822
  return this;
31823
31823
  }
31824
31824
  inputToMastraMessageV2(message, messageSource) {
31825
- if (`threadId` in message && message.threadId && this.memoryInfo && message.threadId !== this.memoryInfo.threadId) {
31825
+ if (
31826
+ // we can't throw if the threadId doesn't match and this message came from memory
31827
+ // this is because per-user semantic recall can retrieve messages from other threads
31828
+ messageSource !== `memory` && `threadId` in message && message.threadId && this.memoryInfo && message.threadId !== this.memoryInfo.threadId
31829
+ ) {
31826
31830
  throw new Error(
31827
31831
  `Received input message with wrong threadId. Input ${message.threadId}, expected ${this.memoryInfo.threadId}`
31828
31832
  );
@@ -34703,7 +34707,7 @@ var init_es5m = __esm({
34703
34707
  }
34704
34708
  });
34705
34709
 
34706
- // ../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/dev/dist/xstate-dev.esm.js
34710
+ // ../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/dev/dist/xstate-dev.esm.js
34707
34711
  function getGlobal() {
34708
34712
  if (typeof globalThis !== "undefined") {
34709
34713
  return globalThis;
@@ -34727,7 +34731,7 @@ function getDevTools() {
34727
34731
  }
34728
34732
  var devToolsAdapter;
34729
34733
  var init_xstate_dev_esm = __esm({
34730
- "../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/dev/dist/xstate-dev.esm.js"() {
34734
+ "../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/dev/dist/xstate-dev.esm.js"() {
34731
34735
  devToolsAdapter = (service) => {
34732
34736
  if (typeof window === "undefined") {
34733
34737
  return;
@@ -34740,7 +34744,7 @@ var init_xstate_dev_esm = __esm({
34740
34744
  }
34741
34745
  });
34742
34746
 
34743
- // ../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/dist/raise-3e01e82a.esm.js
34747
+ // ../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/dist/raise-c17ec2bc.esm.js
34744
34748
  function createAfterEvent(delayRef, id) {
34745
34749
  return {
34746
34750
  type: `xstate.after.${delayRef}.${id}`
@@ -36218,21 +36222,6 @@ function cloneMachineSnapshot(snapshot, config = {}) {
36218
36222
  ...config
36219
36223
  }, snapshot.machine);
36220
36224
  }
36221
- function serializeHistoryValue(historyValue) {
36222
- if (typeof historyValue !== "object" || historyValue === null) {
36223
- return {};
36224
- }
36225
- const result = {};
36226
- for (const key in historyValue) {
36227
- const value = historyValue[key];
36228
- if (Array.isArray(value)) {
36229
- result[key] = value.map((item) => ({
36230
- id: item.id
36231
- }));
36232
- }
36233
- }
36234
- return result;
36235
- }
36236
36225
  function getPersistedSnapshot(snapshot, options) {
36237
36226
  const {
36238
36227
  _nodes: nodes,
@@ -36260,8 +36249,7 @@ function getPersistedSnapshot(snapshot, options) {
36260
36249
  const persisted = {
36261
36250
  ...jsonValues,
36262
36251
  context: persistContext(context2),
36263
- children: childrenJson,
36264
- historyValue: serializeHistoryValue(jsonValues.historyValue)
36252
+ children: childrenJson
36265
36253
  };
36266
36254
  return persisted;
36267
36255
  }
@@ -36348,8 +36336,8 @@ function raise(eventOrExpr, options) {
36348
36336
  return raise2;
36349
36337
  }
36350
36338
  var Mailbox, STATE_DELIMITER, TARGETLESS_KEY, NULL_EVENT, STATE_IDENTIFIER, WILDCARD, XSTATE_INIT, XSTATE_ERROR, XSTATE_STOP, symbolObservable, idCounter, $$ACTOR_TYPE, ProcessingStatus, defaultOptions, Actor, interpret, stop, isAtomicStateNode, isStateId, machineSnapshotMatches, machineSnapshotHasTag, machineSnapshotCan, machineSnapshotToJSON, machineSnapshotGetMeta;
36351
- var init_raise_3e01e82a_esm = __esm({
36352
- "../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/dist/raise-3e01e82a.esm.js"() {
36339
+ var init_raise_c17ec2bc_esm = __esm({
36340
+ "../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/dist/raise-c17ec2bc.esm.js"() {
36353
36341
  init_xstate_dev_esm();
36354
36342
  Mailbox = class {
36355
36343
  constructor(_process) {
@@ -36991,7 +36979,7 @@ var init_raise_3e01e82a_esm = __esm({
36991
36979
  }
36992
36980
  });
36993
36981
 
36994
- // ../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/actors/dist/xstate-actors.esm.js
36982
+ // ../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/actors/dist/xstate-actors.esm.js
36995
36983
  function fromTransition(transition2, initialContext) {
36996
36984
  return {
36997
36985
  config: transition2,
@@ -37350,8 +37338,8 @@ function createEmptyActor() {
37350
37338
  }
37351
37339
  var instanceStates, XSTATE_OBSERVABLE_NEXT, XSTATE_OBSERVABLE_ERROR, XSTATE_OBSERVABLE_COMPLETE, XSTATE_PROMISE_RESOLVE, XSTATE_PROMISE_REJECT, controllerMap, emptyLogic;
37352
37340
  var init_xstate_actors_esm = __esm({
37353
- "../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/actors/dist/xstate-actors.esm.js"() {
37354
- init_raise_3e01e82a_esm();
37341
+ "../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/actors/dist/xstate-actors.esm.js"() {
37342
+ init_raise_c17ec2bc_esm();
37355
37343
  init_xstate_dev_esm();
37356
37344
  instanceStates = /* @__PURE__ */ new WeakMap();
37357
37345
  XSTATE_OBSERVABLE_NEXT = "xstate.observable.next";
@@ -37364,7 +37352,7 @@ var init_xstate_actors_esm = __esm({
37364
37352
  }
37365
37353
  });
37366
37354
 
37367
- // ../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/dist/log-655aa404.esm.js
37355
+ // ../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/dist/log-3d9d72a9.esm.js
37368
37356
  function createSpawner(actorScope, {
37369
37357
  machine,
37370
37358
  context: context2
@@ -37656,9 +37644,9 @@ function log(value = ({
37656
37644
  return log2;
37657
37645
  }
37658
37646
  var SpecialTargets;
37659
- var init_log_655aa404_esm = __esm({
37660
- "../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/dist/log-655aa404.esm.js"() {
37661
- init_raise_3e01e82a_esm();
37647
+ var init_log_3d9d72a9_esm = __esm({
37648
+ "../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/dist/log-3d9d72a9.esm.js"() {
37649
+ init_raise_c17ec2bc_esm();
37662
37650
  SpecialTargets = /* @__PURE__ */ function(SpecialTargets2) {
37663
37651
  SpecialTargets2["Parent"] = "#_parent";
37664
37652
  SpecialTargets2["Internal"] = "#_internal";
@@ -37667,7 +37655,7 @@ var init_log_655aa404_esm = __esm({
37667
37655
  }
37668
37656
  });
37669
37657
 
37670
- // ../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/dist/xstate.esm.js
37658
+ // ../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/dist/xstate.esm.js
37671
37659
  var xstate_esm_exports = {};
37672
37660
  __export(xstate_esm_exports, {
37673
37661
  Actor: () => Actor,
@@ -37876,12 +37864,12 @@ function waitFor(actorRef, predicate, options) {
37876
37864
  }
37877
37865
  var cache, EMPTY_OBJECT, toSerializableAction, StateNode, STATE_IDENTIFIER2, StateMachine, SimulatedClock, defaultWaitForOptions;
37878
37866
  var init_xstate_esm = __esm({
37879
- "../../node_modules/.pnpm/xstate@5.19.4/node_modules/xstate/dist/xstate.esm.js"() {
37867
+ "../../node_modules/.pnpm/xstate@5.19.2/node_modules/xstate/dist/xstate.esm.js"() {
37880
37868
  init_xstate_actors_esm();
37881
- init_raise_3e01e82a_esm();
37882
- init_raise_3e01e82a_esm();
37883
- init_log_655aa404_esm();
37884
- init_log_655aa404_esm();
37869
+ init_raise_c17ec2bc_esm();
37870
+ init_raise_c17ec2bc_esm();
37871
+ init_log_3d9d72a9_esm();
37872
+ init_log_3d9d72a9_esm();
37885
37873
  init_xstate_dev_esm();
37886
37874
  cache = /* @__PURE__ */ new WeakMap();
37887
37875
  EMPTY_OBJECT = {};
@@ -38143,10 +38131,11 @@ ${err.message}`);
38143
38131
  this.events = this.root.events;
38144
38132
  }
38145
38133
  /**
38146
- * Clones this state machine with the provided implementations.
38134
+ * Clones this state machine with the provided implementations and merges the
38135
+ * `context` (if provided).
38147
38136
  *
38148
- * @param implementations Options (`actions`, `guards`, `actors`, `delays`)
38149
- * to recursively merge with the existing options.
38137
+ * @param implementations Options (`actions`, `guards`, `actors`, `delays`,
38138
+ * `context`) to recursively merge with the existing options.
38150
38139
  * @returns A new `StateMachine` instance with the provided implementations.
38151
38140
  */
38152
38141
  provide(implementations) {
@@ -38308,39 +38297,10 @@ ${err.message}`);
38308
38297
  });
38309
38298
  children[actorId] = actorRef;
38310
38299
  });
38311
- function resolveHistoryReferencedState(root4, referenced) {
38312
- if (referenced instanceof StateNode) {
38313
- return referenced;
38314
- }
38315
- try {
38316
- return root4.machine.getStateNodeById(referenced.id);
38317
- } catch {
38318
- }
38319
- }
38320
- function reviveHistoryValue(root4, historyValue) {
38321
- if (!historyValue || typeof historyValue !== "object") {
38322
- return {};
38323
- }
38324
- const revived = {};
38325
- for (const key in historyValue) {
38326
- const arr = historyValue[key];
38327
- for (const item of arr) {
38328
- const resolved = resolveHistoryReferencedState(root4, item);
38329
- if (!resolved) {
38330
- continue;
38331
- }
38332
- revived[key] ??= [];
38333
- revived[key].push(resolved);
38334
- }
38335
- }
38336
- return revived;
38337
- }
38338
- const revivedHistoryValue = reviveHistoryValue(this.root, snapshot.historyValue);
38339
38300
  const restoredSnapshot = createMachineSnapshot({
38340
38301
  ...snapshot,
38341
38302
  children,
38342
- _nodes: Array.from(getAllStateNodes(getStateNodes(this.root, snapshot.value))),
38343
- historyValue: revivedHistoryValue
38303
+ _nodes: Array.from(getAllStateNodes(getStateNodes(this.root, snapshot.value)))
38344
38304
  }, this);
38345
38305
  const seen = /* @__PURE__ */ new Set();
38346
38306
  function reviveContext(contextPart, children2) {
@@ -38435,11 +38395,11 @@ ${err.message}`);
38435
38395
  }
38436
38396
  });
38437
38397
 
38438
- // ../../packages/core/dist/chunk-OKHKG5C7.cjs
38439
- var require_chunk_OKHKG5C7 = __commonJS({
38440
- "../../packages/core/dist/chunk-OKHKG5C7.cjs"(exports2) {
38398
+ // ../../packages/core/dist/chunk-ZWYZGIV3.cjs
38399
+ var require_chunk_ZWYZGIV3 = __commonJS({
38400
+ "../../packages/core/dist/chunk-ZWYZGIV3.cjs"(exports2) {
38441
38401
  var chunkJYLH5IY3_cjs = require_chunk_JYLH5IY3();
38442
- var chunkH5IRI46R_cjs = require_chunk_H5IRI46R();
38402
+ var chunkXUODQRSL_cjs = require_chunk_XUODQRSL();
38443
38403
  var chunkST5RMVLG_cjs = require_chunk_ST5RMVLG();
38444
38404
  var chunkRO5VPM3P_cjs = require_chunk_RO5VPM3P();
38445
38405
  var chunkZAXPU6F2_cjs = require_chunk_ZAXPU6F2();
@@ -38845,7 +38805,7 @@ var require_chunk_OKHKG5C7 = __commonJS({
38845
38805
  memoryConfig,
38846
38806
  resourceId,
38847
38807
  runId,
38848
- messageList = new chunkH5IRI46R_cjs.MessageList({
38808
+ messageList = new chunkXUODQRSL_cjs.MessageList({
38849
38809
  threadId,
38850
38810
  resourceId
38851
38811
  })
@@ -38860,14 +38820,11 @@ var require_chunk_OKHKG5C7 = __commonJS({
38860
38820
  threadId: threadId || ""
38861
38821
  };
38862
38822
  }
38863
- const allUIMessages = messageList.get.all.ui();
38864
- const currentUserMessages = allUIMessages.filter((m) => m.role === "user");
38865
- const lastUserMessageContent = currentUserMessages.at(-1)?.content ?? "";
38866
38823
  const [memoryMessages, memorySystemMessage] = threadId && memory ? await Promise.all([memory.rememberMessages({
38867
38824
  threadId,
38868
38825
  resourceId,
38869
38826
  config: memoryConfig,
38870
- vectorMessageSearch: lastUserMessageContent
38827
+ vectorMessageSearch: messageList.getLatestUserContent() || ""
38871
38828
  }).then((r) => r.messagesV2), memory.getSystemMessage({
38872
38829
  threadId,
38873
38830
  memoryConfig
@@ -39216,7 +39173,7 @@ var require_chunk_OKHKG5C7 = __commonJS({
39216
39173
  runId,
39217
39174
  runtimeContext
39218
39175
  });
39219
- const messageList = new chunkH5IRI46R_cjs.MessageList({
39176
+ const messageList = new chunkXUODQRSL_cjs.MessageList({
39220
39177
  threadId,
39221
39178
  resourceId,
39222
39179
  generateMessageId
@@ -39249,12 +39206,13 @@ var require_chunk_OKHKG5C7 = __commonJS({
39249
39206
  resourceId,
39250
39207
  memoryConfig
39251
39208
  });
39252
- const [memoryMessages, memorySystemMessage] = threadId && memory ? await Promise.all([memory.rememberMessages({
39209
+ let [memoryMessages, memorySystemMessage] = threadId && memory ? await Promise.all([memory.rememberMessages({
39253
39210
  threadId,
39254
39211
  resourceId,
39255
39212
  config: memoryConfig,
39256
- vectorMessageSearch: messageList.getLatestUserContent() || ""
39257
- }).then((r) => r.messages), memory.getSystemMessage({
39213
+ // The new user messages aren't in the list yet cause we add memory messages first to try to make sure ordering is correct (memory comes before new user messages)
39214
+ vectorMessageSearch: new chunkXUODQRSL_cjs.MessageList().add(messages, `user`).getLatestUserContent() || ""
39215
+ }).then((r) => r.messagesV2), memory.getSystemMessage({
39258
39216
  threadId,
39259
39217
  memoryConfig
39260
39218
  })]) : [[], null];
@@ -39263,10 +39221,28 @@ var require_chunk_OKHKG5C7 = __commonJS({
39263
39221
  runId,
39264
39222
  fetchedCount: memoryMessages.length
39265
39223
  });
39224
+ const resultsFromOtherThreads = memoryMessages.filter((m) => m.threadId !== threadId);
39225
+ if (resultsFromOtherThreads.length && !memorySystemMessage) {
39226
+ memorySystemMessage = ``;
39227
+ }
39228
+ if (resultsFromOtherThreads.length) {
39229
+ memorySystemMessage += `
39230
+ The following messages were remembered from a different conversation:
39231
+ <remembered_from_other_conversation>
39232
+ ${JSON.stringify(
39233
+ // get v1 since they're closer to CoreMessages (which get sent to the LLM) but also include timestamps
39234
+ new chunkXUODQRSL_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1()
39235
+ )}
39236
+ <end_remembered_from_other_conversation>`;
39237
+ }
39266
39238
  if (memorySystemMessage) {
39267
39239
  messageList.addSystem(memorySystemMessage, "memory");
39268
39240
  }
39269
- messageList.add(memoryMessages, "memory").add(messages, "user");
39241
+ messageList.add(
39242
+ memoryMessages.filter((m) => m.threadId === threadId),
39243
+ // filter out messages from other threads. those are added to system message above
39244
+ "memory"
39245
+ ).add(messages, "user");
39270
39246
  const systemMessage = messageList.getSystemMessages()?.map((m) => m.content)?.join(`
39271
39247
  `) ?? void 0;
39272
39248
  const processedMemoryMessages = memory.processMessages({
@@ -39278,7 +39254,7 @@ var require_chunk_OKHKG5C7 = __commonJS({
39278
39254
  systemMessage,
39279
39255
  memorySystemMessage: memorySystemMessage || void 0
39280
39256
  });
39281
- const processedList = new chunkH5IRI46R_cjs.MessageList({
39257
+ const processedList = new chunkXUODQRSL_cjs.MessageList({
39282
39258
  threadId,
39283
39259
  resourceId
39284
39260
  }).addSystem(instructions || `${this.instructions}.`).addSystem(memorySystemMessage).add(context2 || [], "context").add(processedMemoryMessages, "memory").add(messageList.get.input.v2(), "user").get.all.prompt();
@@ -42753,18 +42729,18 @@ var require_chunk_OKHKG5C7 = __commonJS({
42753
42729
  // ../../packages/core/dist/agent/index.cjs
42754
42730
  var require_agent = __commonJS({
42755
42731
  "../../packages/core/dist/agent/index.cjs"(exports2) {
42756
- var chunkOKHKG5C7_cjs = require_chunk_OKHKG5C7();
42757
- var chunkH5IRI46R_cjs = require_chunk_H5IRI46R();
42732
+ var chunkZWYZGIV3_cjs = require_chunk_ZWYZGIV3();
42733
+ var chunkXUODQRSL_cjs = require_chunk_XUODQRSL();
42758
42734
  Object.defineProperty(exports2, "Agent", {
42759
42735
  enumerable: true,
42760
42736
  get: function() {
42761
- return chunkOKHKG5C7_cjs.Agent;
42737
+ return chunkZWYZGIV3_cjs.Agent;
42762
42738
  }
42763
42739
  });
42764
42740
  Object.defineProperty(exports2, "MessageList", {
42765
42741
  enumerable: true,
42766
42742
  get: function() {
42767
- return chunkH5IRI46R_cjs.MessageList;
42743
+ return chunkXUODQRSL_cjs.MessageList;
42768
42744
  }
42769
42745
  });
42770
42746
  }
@@ -42781,6 +42757,11 @@ var UpstashStore = class extends MastraStorage {
42781
42757
  token: config.token
42782
42758
  });
42783
42759
  }
42760
+ get supports() {
42761
+ return {
42762
+ selectByIncludeResourceScope: true
42763
+ };
42764
+ }
42784
42765
  transformEvalRecord(record) {
42785
42766
  let result = record.result;
42786
42767
  if (typeof result === "string") {
@@ -42865,7 +42846,8 @@ var UpstashStore = class extends MastraStorage {
42865
42846
  return totalDeleted;
42866
42847
  }
42867
42848
  getMessageKey(threadId, messageId) {
42868
- return this.getKey(TABLE_MESSAGES, { threadId, id: messageId });
42849
+ const key = this.getKey(TABLE_MESSAGES, { threadId, id: messageId });
42850
+ return key;
42869
42851
  }
42870
42852
  getThreadMessagesKey(threadId) {
42871
42853
  return `thread:${threadId}:messages`;
@@ -42961,33 +42943,34 @@ var UpstashStore = class extends MastraStorage {
42961
42943
  return [];
42962
42944
  }
42963
42945
  }
42946
+ /**
42947
+ * @deprecated use getTracesPaginated instead
42948
+ */
42964
42949
  async getTraces(args) {
42965
- const {
42966
- name,
42967
- scope,
42968
- page,
42969
- perPage: perPageInput,
42970
- attributes,
42971
- filters,
42972
- fromDate,
42973
- toDate,
42974
- returnPaginationResults
42975
- } = args;
42976
- const perPage = perPageInput !== void 0 ? perPageInput : 100;
42950
+ if (args.fromDate || args.toDate) {
42951
+ args.dateRange = {
42952
+ start: args.fromDate,
42953
+ end: args.toDate
42954
+ };
42955
+ }
42956
+ const { traces } = await this.getTracesPaginated(args);
42957
+ return traces;
42958
+ }
42959
+ async getTracesPaginated(args) {
42960
+ const { name, scope, page = 0, perPage = 100, attributes, filters, dateRange } = args;
42961
+ const fromDate = dateRange?.start;
42962
+ const toDate = dateRange?.end;
42977
42963
  try {
42978
42964
  const pattern = `${TABLE_TRACES}:*`;
42979
42965
  const keys = await this.scanKeys(pattern);
42980
42966
  if (keys.length === 0) {
42981
- if (returnPaginationResults) {
42982
- return {
42983
- traces: [],
42984
- total: 0,
42985
- page,
42986
- perPage: perPage || 100,
42987
- hasMore: false
42988
- };
42989
- }
42990
- return [];
42967
+ return {
42968
+ traces: [],
42969
+ total: 0,
42970
+ page,
42971
+ perPage: perPage || 100,
42972
+ hasMore: false
42973
+ };
42991
42974
  }
42992
42975
  const pipeline = this.redis.pipeline();
42993
42976
  keys.forEach((key) => pipeline.get(key));
@@ -43047,29 +43030,22 @@ var UpstashStore = class extends MastraStorage {
43047
43030
  const end = start + resolvedPerPage;
43048
43031
  const paginatedTraces = transformedTraces.slice(start, end);
43049
43032
  const hasMore = end < total;
43050
- if (returnPaginationResults) {
43051
- return {
43052
- traces: paginatedTraces,
43053
- total,
43054
- page,
43055
- perPage: resolvedPerPage,
43056
- hasMore
43057
- };
43058
- } else {
43059
- return paginatedTraces;
43060
- }
43033
+ return {
43034
+ traces: paginatedTraces,
43035
+ total,
43036
+ page,
43037
+ perPage: resolvedPerPage,
43038
+ hasMore
43039
+ };
43061
43040
  } catch (error) {
43062
43041
  console.error("Failed to get traces:", error);
43063
- if (returnPaginationResults) {
43064
- return {
43065
- traces: [],
43066
- total: 0,
43067
- page,
43068
- perPage: perPage || 100,
43069
- hasMore: false
43070
- };
43071
- }
43072
- return [];
43042
+ return {
43043
+ traces: [],
43044
+ total: 0,
43045
+ page,
43046
+ perPage: perPage || 100,
43047
+ hasMore: false
43048
+ };
43073
43049
  }
43074
43050
  }
43075
43051
  async createTable({
@@ -43126,24 +43102,14 @@ var UpstashStore = class extends MastraStorage {
43126
43102
  metadata: typeof thread.metadata === "string" ? JSON.parse(thread.metadata) : thread.metadata
43127
43103
  };
43128
43104
  }
43129
- async getThreadsByResourceId(args) {
43130
- const resourceId = args.resourceId;
43131
- const page = args.page;
43132
- const perPage = page !== void 0 ? args.perPage !== void 0 ? args.perPage : 100 : 100;
43105
+ /**
43106
+ * @deprecated use getThreadsByResourceIdPaginated instead
43107
+ */
43108
+ async getThreadsByResourceId({ resourceId }) {
43133
43109
  try {
43134
43110
  const pattern = `${TABLE_THREADS}:*`;
43135
43111
  const keys = await this.scanKeys(pattern);
43136
43112
  if (keys.length === 0) {
43137
- if (page !== void 0) {
43138
- return {
43139
- threads: [],
43140
- total: 0,
43141
- page,
43142
- perPage,
43143
- // perPage is number here
43144
- hasMore: false
43145
- };
43146
- }
43147
43113
  return [];
43148
43114
  }
43149
43115
  const allThreads = [];
@@ -43162,37 +43128,39 @@ var UpstashStore = class extends MastraStorage {
43162
43128
  }
43163
43129
  }
43164
43130
  allThreads.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
43165
- if (page !== void 0) {
43166
- const total = allThreads.length;
43167
- const start = page * perPage;
43168
- const end = start + perPage;
43169
- const paginatedThreads = allThreads.slice(start, end);
43170
- const hasMore = end < total;
43171
- return {
43172
- threads: paginatedThreads,
43173
- total,
43174
- page,
43175
- perPage,
43176
- hasMore
43177
- };
43178
- } else {
43179
- return allThreads;
43180
- }
43131
+ return allThreads;
43181
43132
  } catch (error) {
43182
43133
  console.error("Error in getThreadsByResourceId:", error);
43183
- if (page !== void 0) {
43184
- return {
43185
- threads: [],
43186
- total: 0,
43187
- page,
43188
- perPage,
43189
- // perPage is number here
43190
- hasMore: false
43191
- };
43192
- }
43193
43134
  return [];
43194
43135
  }
43195
43136
  }
43137
+ async getThreadsByResourceIdPaginated(args) {
43138
+ const { resourceId, page = 0, perPage = 100 } = args;
43139
+ try {
43140
+ const allThreads = await this.getThreadsByResourceId({ resourceId });
43141
+ const total = allThreads.length;
43142
+ const start = page * perPage;
43143
+ const end = start + perPage;
43144
+ const paginatedThreads = allThreads.slice(start, end);
43145
+ const hasMore = end < total;
43146
+ return {
43147
+ threads: paginatedThreads,
43148
+ total,
43149
+ page,
43150
+ perPage,
43151
+ hasMore
43152
+ };
43153
+ } catch (error) {
43154
+ console.error("Error in getThreadsByResourceIdPaginated:", error);
43155
+ return {
43156
+ threads: [],
43157
+ total: 0,
43158
+ page,
43159
+ perPage,
43160
+ hasMore: false
43161
+ };
43162
+ }
43163
+ }
43196
43164
  async saveThread({ thread }) {
43197
43165
  await this.insert({
43198
43166
  tableName: TABLE_THREADS,
@@ -43238,6 +43206,14 @@ var UpstashStore = class extends MastraStorage {
43238
43206
  async saveMessages(args) {
43239
43207
  const { messages, format = "v1" } = args;
43240
43208
  if (messages.length === 0) return [];
43209
+ const threadId = messages[0]?.threadId;
43210
+ if (!threadId) {
43211
+ throw new Error("Thread ID is required");
43212
+ }
43213
+ const thread = await this.getThreadById({ threadId });
43214
+ if (!thread) {
43215
+ throw new Error(`Thread ${threadId} not found`);
43216
+ }
43241
43217
  const messagesWithIndex = messages.map((message, index) => ({
43242
43218
  ...message,
43243
43219
  _index: index
@@ -43248,7 +43224,8 @@ var UpstashStore = class extends MastraStorage {
43248
43224
  const pipeline = this.redis.pipeline();
43249
43225
  for (const message of batch) {
43250
43226
  const key = this.getMessageKey(message.threadId, message.id);
43251
- const score = message._index !== void 0 ? message._index : new Date(message.createdAt).getTime();
43227
+ const createdAtScore = new Date(message.createdAt).getTime();
43228
+ const score = message._index !== void 0 ? message._index : createdAtScore;
43252
43229
  pipeline.set(key, message);
43253
43230
  pipeline.zadd(this.getThreadMessagesKey(message.threadId), {
43254
43231
  score,
@@ -43261,79 +43238,50 @@ var UpstashStore = class extends MastraStorage {
43261
43238
  if (format === `v2`) return list.get.all.v2();
43262
43239
  return list.get.all.v1();
43263
43240
  }
43241
+ async _getIncludedMessages(threadId, selectBy) {
43242
+ const messageIds = /* @__PURE__ */ new Set();
43243
+ const messageIdToThreadIds = {};
43244
+ if (selectBy?.include?.length) {
43245
+ for (const item of selectBy.include) {
43246
+ messageIds.add(item.id);
43247
+ const itemThreadId = item.threadId || threadId;
43248
+ messageIdToThreadIds[item.id] = itemThreadId;
43249
+ const itemThreadMessagesKey = this.getThreadMessagesKey(itemThreadId);
43250
+ const rank = await this.redis.zrank(itemThreadMessagesKey, item.id);
43251
+ if (rank === null) continue;
43252
+ if (item.withPreviousMessages) {
43253
+ const start = Math.max(0, rank - item.withPreviousMessages);
43254
+ const prevIds = rank === 0 ? [] : await this.redis.zrange(itemThreadMessagesKey, start, rank - 1);
43255
+ prevIds.forEach((id) => {
43256
+ messageIds.add(id);
43257
+ messageIdToThreadIds[id] = itemThreadId;
43258
+ });
43259
+ }
43260
+ if (item.withNextMessages) {
43261
+ const nextIds = await this.redis.zrange(itemThreadMessagesKey, rank + 1, rank + item.withNextMessages);
43262
+ nextIds.forEach((id) => {
43263
+ messageIds.add(id);
43264
+ messageIdToThreadIds[id] = itemThreadId;
43265
+ });
43266
+ }
43267
+ }
43268
+ const pipeline = this.redis.pipeline();
43269
+ Array.from(messageIds).forEach((id) => {
43270
+ const tId = messageIdToThreadIds[id] || threadId;
43271
+ pipeline.get(this.getMessageKey(tId, id));
43272
+ });
43273
+ const results = await pipeline.exec();
43274
+ return results.filter((result) => result !== null);
43275
+ }
43276
+ return [];
43277
+ }
43264
43278
  async getMessages({
43265
43279
  threadId,
43266
43280
  selectBy,
43267
- format,
43268
- page,
43269
- perPage = 40,
43270
- fromDate,
43271
- toDate
43281
+ format
43272
43282
  }) {
43273
43283
  const threadMessagesKey = this.getThreadMessagesKey(threadId);
43274
43284
  const allMessageIds = await this.redis.zrange(threadMessagesKey, 0, -1);
43275
- if (page !== void 0) {
43276
- try {
43277
- if (allMessageIds.length === 0) {
43278
- return {
43279
- messages: [],
43280
- total: 0,
43281
- page,
43282
- perPage,
43283
- hasMore: false
43284
- };
43285
- }
43286
- const pipeline = this.redis.pipeline();
43287
- allMessageIds.forEach((id) => pipeline.get(this.getMessageKey(threadId, id)));
43288
- const results = await pipeline.exec();
43289
- let messages2 = results.map((result) => result).filter((msg) => msg !== null);
43290
- if (fromDate) {
43291
- messages2 = messages2.filter((msg) => msg && new Date(msg.createdAt).getTime() >= fromDate.getTime());
43292
- }
43293
- if (toDate) {
43294
- messages2 = messages2.filter((msg) => msg && new Date(msg.createdAt).getTime() <= toDate.getTime());
43295
- }
43296
- messages2.sort((a, b) => allMessageIds.indexOf(a.id) - allMessageIds.indexOf(b.id));
43297
- const total = messages2.length;
43298
- const start = page * perPage;
43299
- const end = start + perPage;
43300
- const hasMore = end < total;
43301
- const paginatedMessages = messages2.slice(start, end);
43302
- const prepared2 = paginatedMessages.filter((message) => message !== null && message !== void 0).map((message) => {
43303
- const { _index, ...messageWithoutIndex } = message;
43304
- return messageWithoutIndex;
43305
- });
43306
- if (format === "v2") {
43307
- const v2Messages = prepared2.map((msg) => ({
43308
- ...msg,
43309
- content: msg.content || { format: 2, parts: [{ type: "text", text: "" }] }
43310
- }));
43311
- return {
43312
- messages: v2Messages,
43313
- total,
43314
- page,
43315
- perPage,
43316
- hasMore
43317
- };
43318
- }
43319
- return {
43320
- messages: prepared2,
43321
- total,
43322
- page,
43323
- perPage,
43324
- hasMore
43325
- };
43326
- } catch (error) {
43327
- console.error("Failed to get paginated messages:", error);
43328
- return {
43329
- messages: [],
43330
- total: 0,
43331
- page,
43332
- perPage,
43333
- hasMore: false
43334
- };
43335
- }
43336
- }
43337
43285
  let limit;
43338
43286
  if (typeof selectBy?.last === "number") {
43339
43287
  limit = Math.max(0, selectBy.last);
@@ -43343,41 +43291,43 @@ var UpstashStore = class extends MastraStorage {
43343
43291
  limit = Number.MAX_SAFE_INTEGER;
43344
43292
  }
43345
43293
  const messageIds = /* @__PURE__ */ new Set();
43294
+ const messageIdToThreadIds = {};
43346
43295
  if (limit === 0 && !selectBy?.include) {
43347
43296
  return [];
43348
43297
  }
43349
- if (selectBy?.include?.length) {
43350
- for (const item of selectBy.include) {
43351
- messageIds.add(item.id);
43352
- if (item.withPreviousMessages || item.withNextMessages) {
43353
- const rank = await this.redis.zrank(threadMessagesKey, item.id);
43354
- if (rank === null) continue;
43355
- if (item.withPreviousMessages) {
43356
- const start = Math.max(0, rank - item.withPreviousMessages);
43357
- const prevIds = rank === 0 ? [] : await this.redis.zrange(threadMessagesKey, start, rank - 1);
43358
- prevIds.forEach((id) => messageIds.add(id));
43359
- }
43360
- if (item.withNextMessages) {
43361
- const nextIds = await this.redis.zrange(threadMessagesKey, rank + 1, rank + item.withNextMessages);
43362
- nextIds.forEach((id) => messageIds.add(id));
43363
- }
43364
- }
43365
- }
43366
- }
43367
43298
  if (limit === Number.MAX_SAFE_INTEGER) {
43368
43299
  const allIds = await this.redis.zrange(threadMessagesKey, 0, -1);
43369
- allIds.forEach((id) => messageIds.add(id));
43300
+ allIds.forEach((id) => {
43301
+ messageIds.add(id);
43302
+ messageIdToThreadIds[id] = threadId;
43303
+ });
43370
43304
  } else if (limit > 0) {
43371
43305
  const latestIds = await this.redis.zrange(threadMessagesKey, -limit, -1);
43372
- latestIds.forEach((id) => messageIds.add(id));
43306
+ latestIds.forEach((id) => {
43307
+ messageIds.add(id);
43308
+ messageIdToThreadIds[id] = threadId;
43309
+ });
43373
43310
  }
43374
- const messages = (await Promise.all(
43375
- Array.from(messageIds).map(
43376
- async (id) => this.redis.get(this.getMessageKey(threadId, id))
43377
- )
43378
- )).filter((msg) => msg !== null);
43311
+ const includedMessages = await this._getIncludedMessages(threadId, selectBy);
43312
+ const messages = [
43313
+ ...includedMessages,
43314
+ ...(await Promise.all(
43315
+ Array.from(messageIds).map(async (id) => {
43316
+ const tId = messageIdToThreadIds[id] || threadId;
43317
+ const byThreadId = await this.redis.get(this.getMessageKey(tId, id));
43318
+ if (byThreadId) return byThreadId;
43319
+ return null;
43320
+ })
43321
+ )).filter((msg) => msg !== null)
43322
+ ];
43379
43323
  messages.sort((a, b) => allMessageIds.indexOf(a.id) - allMessageIds.indexOf(b.id));
43380
- const prepared = messages.filter((message) => message !== null && message !== void 0).map((message) => {
43324
+ const seen = /* @__PURE__ */ new Set();
43325
+ const dedupedMessages = messages.filter((row) => {
43326
+ if (seen.has(row.id)) return false;
43327
+ seen.add(row.id);
43328
+ return true;
43329
+ });
43330
+ const prepared = dedupedMessages.filter((message) => message !== null && message !== void 0).map((message) => {
43381
43331
  const { _index, ...messageWithoutIndex } = message;
43382
43332
  return messageWithoutIndex;
43383
43333
  });
@@ -43389,6 +43339,63 @@ var UpstashStore = class extends MastraStorage {
43389
43339
  }
43390
43340
  return prepared;
43391
43341
  }
43342
+ async getMessagesPaginated(args) {
43343
+ const { threadId, selectBy, format } = args;
43344
+ const { page = 0, perPage = 40, dateRange } = selectBy?.pagination || {};
43345
+ const fromDate = dateRange?.start;
43346
+ const toDate = dateRange?.end;
43347
+ const threadMessagesKey = this.getThreadMessagesKey(threadId);
43348
+ const messages = [];
43349
+ const includedMessages = await this._getIncludedMessages(threadId, selectBy);
43350
+ messages.push(...includedMessages);
43351
+ try {
43352
+ const allMessageIds = await this.redis.zrange(threadMessagesKey, 0, -1);
43353
+ if (allMessageIds.length === 0) {
43354
+ return {
43355
+ messages: [],
43356
+ total: 0,
43357
+ page,
43358
+ perPage,
43359
+ hasMore: false
43360
+ };
43361
+ }
43362
+ const pipeline = this.redis.pipeline();
43363
+ allMessageIds.forEach((id) => pipeline.get(this.getMessageKey(threadId, id)));
43364
+ const results = await pipeline.exec();
43365
+ let messagesData = results.filter((msg) => msg !== null);
43366
+ if (fromDate) {
43367
+ messagesData = messagesData.filter((msg) => msg && new Date(msg.createdAt).getTime() >= fromDate.getTime());
43368
+ }
43369
+ if (toDate) {
43370
+ messagesData = messagesData.filter((msg) => msg && new Date(msg.createdAt).getTime() <= toDate.getTime());
43371
+ }
43372
+ messagesData.sort((a, b) => allMessageIds.indexOf(a.id) - allMessageIds.indexOf(b.id));
43373
+ const total = messagesData.length;
43374
+ const start = page * perPage;
43375
+ const end = start + perPage;
43376
+ const hasMore = end < total;
43377
+ const paginatedMessages = messagesData.slice(start, end);
43378
+ messages.push(...paginatedMessages);
43379
+ const list = new import_agent.MessageList().add(messages, "memory");
43380
+ const finalMessages = format === `v2` ? list.get.all.v2() : list.get.all.v1();
43381
+ return {
43382
+ messages: finalMessages,
43383
+ total,
43384
+ page,
43385
+ perPage,
43386
+ hasMore
43387
+ };
43388
+ } catch (error) {
43389
+ console.error("Failed to get paginated messages:", error);
43390
+ return {
43391
+ messages: [],
43392
+ total: 0,
43393
+ page,
43394
+ perPage,
43395
+ hasMore: false
43396
+ };
43397
+ }
43398
+ }
43392
43399
  async persistWorkflowSnapshot(params) {
43393
43400
  const { namespace = "workflows", workflowName, runId, snapshot } = params;
43394
43401
  await this.insert({
@@ -43421,18 +43428,17 @@ var UpstashStore = class extends MastraStorage {
43421
43428
  */
43422
43429
  async getEvals(options) {
43423
43430
  try {
43424
- const page = options?.page ?? 0;
43425
- const perPage = options?.perPage ?? 100;
43426
- const limit = options?.limit;
43427
- const offset = options?.offset;
43431
+ const { agentName, type, page = 0, perPage = 100, dateRange } = options || {};
43432
+ const fromDate = dateRange?.start;
43433
+ const toDate = dateRange?.end;
43428
43434
  const pattern = `${TABLE_EVALS}:*`;
43429
43435
  const keys = await this.scanKeys(pattern);
43430
43436
  if (keys.length === 0) {
43431
43437
  return {
43432
43438
  evals: [],
43433
43439
  total: 0,
43434
- page: options?.page ?? 0,
43435
- perPage: options?.perPage ?? 100,
43440
+ page,
43441
+ perPage,
43436
43442
  hasMore: false
43437
43443
  };
43438
43444
  }
@@ -43440,10 +43446,10 @@ var UpstashStore = class extends MastraStorage {
43440
43446
  keys.forEach((key) => pipeline.get(key));
43441
43447
  const results = await pipeline.exec();
43442
43448
  let filteredEvals = results.map((result) => result).filter((record) => record !== null && typeof record === "object");
43443
- if (options?.agentName) {
43444
- filteredEvals = filteredEvals.filter((record) => record.agent_name === options.agentName);
43449
+ if (agentName) {
43450
+ filteredEvals = filteredEvals.filter((record) => record.agent_name === agentName);
43445
43451
  }
43446
- if (options?.type === "test") {
43452
+ if (type === "test") {
43447
43453
  filteredEvals = filteredEvals.filter((record) => {
43448
43454
  if (!record.test_info) return false;
43449
43455
  try {
@@ -43456,7 +43462,7 @@ var UpstashStore = class extends MastraStorage {
43456
43462
  return false;
43457
43463
  }
43458
43464
  });
43459
- } else if (options?.type === "live") {
43465
+ } else if (type === "live") {
43460
43466
  filteredEvals = filteredEvals.filter((record) => {
43461
43467
  if (!record.test_info) return true;
43462
43468
  try {
@@ -43470,16 +43476,16 @@ var UpstashStore = class extends MastraStorage {
43470
43476
  }
43471
43477
  });
43472
43478
  }
43473
- if (options?.fromDate) {
43479
+ if (fromDate) {
43474
43480
  filteredEvals = filteredEvals.filter((record) => {
43475
43481
  const createdAt = new Date(record.created_at || record.createdAt || 0);
43476
- return createdAt.getTime() >= options.fromDate.getTime();
43482
+ return createdAt.getTime() >= fromDate.getTime();
43477
43483
  });
43478
43484
  }
43479
- if (options?.toDate) {
43485
+ if (toDate) {
43480
43486
  filteredEvals = filteredEvals.filter((record) => {
43481
43487
  const createdAt = new Date(record.created_at || record.createdAt || 0);
43482
- return createdAt.getTime() <= options.toDate.getTime();
43488
+ return createdAt.getTime() <= toDate.getTime();
43483
43489
  });
43484
43490
  }
43485
43491
  filteredEvals.sort((a, b) => {
@@ -43488,32 +43494,26 @@ var UpstashStore = class extends MastraStorage {
43488
43494
  return dateB - dateA;
43489
43495
  });
43490
43496
  const total = filteredEvals.length;
43491
- let paginatedEvals;
43492
- let hasMore = false;
43493
- if (limit !== void 0 && offset !== void 0) {
43494
- paginatedEvals = filteredEvals.slice(offset, offset + limit);
43495
- hasMore = offset + limit < total;
43496
- } else {
43497
- const start = page * perPage;
43498
- const end = start + perPage;
43499
- paginatedEvals = filteredEvals.slice(start, end);
43500
- hasMore = end < total;
43501
- }
43497
+ const start = page * perPage;
43498
+ const end = start + perPage;
43499
+ const paginatedEvals = filteredEvals.slice(start, end);
43500
+ const hasMore = end < total;
43502
43501
  const evals = paginatedEvals.map((record) => this.transformEvalRecord(record));
43503
43502
  return {
43504
43503
  evals,
43505
43504
  total,
43506
- page: limit !== void 0 ? void 0 : page,
43507
- perPage: limit !== void 0 ? void 0 : perPage,
43505
+ page,
43506
+ perPage,
43508
43507
  hasMore
43509
43508
  };
43510
43509
  } catch (error) {
43510
+ const { page = 0, perPage = 100 } = options || {};
43511
43511
  console.error("Failed to get evals:", error);
43512
43512
  return {
43513
43513
  evals: [],
43514
43514
  total: 0,
43515
- page: options?.page ?? 0,
43516
- perPage: options?.perPage ?? 100,
43515
+ page,
43516
+ perPage,
43517
43517
  hasMore: false
43518
43518
  };
43519
43519
  }