@mastra/mongodb 1.5.1 → 1.5.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.5.1"};
15
+ version: "1.5.2-alpha.0"};
16
16
  var MongoDBFilterTranslator = class extends BaseFilterTranslator {
17
17
  getSupportedOperators() {
18
18
  return {
@@ -338,6 +338,15 @@ var MongoDBVector = class extends MastraVector {
338
338
  includeVector = false,
339
339
  documentFilter
340
340
  }) {
341
+ if (!queryVector) {
342
+ throw new MastraError({
343
+ id: createVectorErrorId("MONGODB", "QUERY", "MISSING_VECTOR"),
344
+ text: "queryVector is required for MongoDB queries. Metadata-only queries are not supported by this vector store.",
345
+ domain: ErrorDomain.STORAGE,
346
+ category: ErrorCategory.USER,
347
+ details: { indexName }
348
+ });
349
+ }
341
350
  try {
342
351
  const collection = await this.getCollection(indexName, true);
343
352
  const indexNameInternal = `${indexName}_vector_index`;
@@ -4177,12 +4186,14 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends MemoryStorage {
4177
4186
  const maxOvershoot = retentionFloor * 0.95;
4178
4187
  const overshoot = bestOverTokens - targetMessageTokens;
4179
4188
  const remainingAfterOver = input.currentPendingTokens - bestOverTokens;
4189
+ const remainingAfterUnder = input.currentPendingTokens - bestUnderTokens;
4190
+ const minRemaining = Math.min(1e3, retentionFloor);
4180
4191
  let chunksToActivate;
4181
- if (input.forceMaxActivation && bestOverBoundary > 0) {
4192
+ if (input.forceMaxActivation && bestOverBoundary > 0 && remainingAfterOver >= minRemaining) {
4182
4193
  chunksToActivate = bestOverBoundary;
4183
- } else if (bestOverBoundary > 0 && overshoot <= maxOvershoot && (remainingAfterOver >= 1e3 || retentionFloor === 0)) {
4194
+ } else if (bestOverBoundary > 0 && overshoot <= maxOvershoot && remainingAfterOver >= minRemaining) {
4184
4195
  chunksToActivate = bestOverBoundary;
4185
- } else if (bestUnderBoundary > 0) {
4196
+ } else if (bestUnderBoundary > 0 && remainingAfterUnder >= minRemaining) {
4186
4197
  chunksToActivate = bestUnderBoundary;
4187
4198
  } else if (bestOverBoundary > 0) {
4188
4199
  chunksToActivate = bestOverBoundary;