@mastra/mongodb 1.6.0 → 1.6.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
@@ -12,7 +12,7 @@ import { saveScorePayloadSchema } from '@mastra/core/evals';
12
12
 
13
13
  // package.json
14
14
  var package_default = {
15
- version: "1.6.0"};
15
+ version: "1.6.1-alpha.1"};
16
16
  var MongoDBFilterTranslator = class extends BaseFilterTranslator {
17
17
  getSupportedOperators() {
18
18
  return {
@@ -5784,8 +5784,11 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends MemoryStorage {
5784
5784
  const newTokenCount = existingTokenCount + activatedTokens;
5785
5785
  const existingPending = Number(doc.pendingMessageTokens || 0);
5786
5786
  const newPending = Math.max(0, existingPending - activatedMessageTokens);
5787
- await collection.updateOne(
5788
- { id: input.id },
5787
+ const updateResult = await collection.updateOne(
5788
+ {
5789
+ id: input.id,
5790
+ bufferedObservationChunks: { $exists: true, $ne: null, $not: { $size: 0 } }
5791
+ },
5789
5792
  {
5790
5793
  $set: {
5791
5794
  activeObservations: newActive,
@@ -5797,6 +5800,16 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends MemoryStorage {
5797
5800
  }
5798
5801
  }
5799
5802
  );
5803
+ if (updateResult.modifiedCount === 0) {
5804
+ return {
5805
+ chunksActivated: 0,
5806
+ messageTokensActivated: 0,
5807
+ observationTokensActivated: 0,
5808
+ messagesActivated: 0,
5809
+ activatedCycleIds: [],
5810
+ activatedMessageIds: []
5811
+ };
5812
+ }
5800
5813
  const latestChunkHints = activatedChunks[activatedChunks.length - 1];
5801
5814
  return {
5802
5815
  chunksActivated: activatedChunks.length,