New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@mastra/memory

Package Overview
Dependencies
Maintainers
7
Versions
1122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
This package has malicious versions linked to the ongoing "Mastra AI framework compromise" supply chain attack.

Affected versions:

1.20.4
View campaign page

@mastra/memory

Source
npmnpm
Version
1.27.1-alpha.0
Version published
Weekly downloads
456K
-36.06%
Maintainers
7
Weekly downloads
 
Created
Source

Mastra Memory

Memory management for Mastra agents. Visit the docs for more information.

Token counting for file parts

Observational Memory uses a built-in Token Counter to decide when to observe and reflect. You can attach an explicit estimate to an image or file part using providerMetadata.mastra.tokenEstimate:

const filePart = {
  type: 'file',
  data: 'storage://bucket/large-report.pdf',
  mimeType: 'application/pdf',
  filename: 'large-report.pdf',
  providerMetadata: {
    mastra: {
      tokenEstimate: {
        v: 0,
        source: 'client',
        key: 'client',
        tokens: 100_000,
      },
    },
  },
};

The Token Counter honors caller-supplied estimates verbatim on image and file parts. See Caller-supplied token estimates for file parts for details.

FAQs

Package last updated on 09 Sep 2026

Related posts