@mastra/memory 1.1.0 → 1.2.0-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.
Files changed (95) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +30 -17
  3. package/dist/{chunk-FQJWVCDF.cjs → chunk-AWE2QQPI.cjs} +1884 -312
  4. package/dist/chunk-AWE2QQPI.cjs.map +1 -0
  5. package/dist/chunk-EQ4M72KU.js +439 -0
  6. package/dist/chunk-EQ4M72KU.js.map +1 -0
  7. package/dist/{chunk-O3CS4UGX.cjs → chunk-IDRQZVB4.cjs} +4 -4
  8. package/dist/{chunk-O3CS4UGX.cjs.map → chunk-IDRQZVB4.cjs.map} +1 -1
  9. package/dist/{chunk-YF4R74L2.js → chunk-RC6RZVYE.js} +4 -4
  10. package/dist/{chunk-YF4R74L2.js.map → chunk-RC6RZVYE.js.map} +1 -1
  11. package/dist/{chunk-6TXUWFIU.js → chunk-TYVPTNCP.js} +1885 -313
  12. package/dist/chunk-TYVPTNCP.js.map +1 -0
  13. package/dist/chunk-ZD3BKU5O.cjs +441 -0
  14. package/dist/chunk-ZD3BKU5O.cjs.map +1 -0
  15. package/dist/docs/SKILL.md +51 -50
  16. package/dist/docs/{SOURCE_MAP.json → assets/SOURCE_MAP.json} +22 -22
  17. package/dist/docs/{agents/03-agent-approval.md → references/docs-agents-agent-approval.md} +19 -19
  18. package/dist/docs/references/docs-agents-agent-memory.md +212 -0
  19. package/dist/docs/{agents/04-network-approval.md → references/docs-agents-network-approval.md} +13 -12
  20. package/dist/docs/{agents/02-networks.md → references/docs-agents-networks.md} +10 -12
  21. package/dist/docs/{memory/06-memory-processors.md → references/docs-memory-memory-processors.md} +6 -8
  22. package/dist/docs/{memory/03-message-history.md → references/docs-memory-message-history.md} +31 -20
  23. package/dist/docs/references/docs-memory-observational-memory.md +238 -0
  24. package/dist/docs/{memory/01-overview.md → references/docs-memory-overview.md} +8 -8
  25. package/dist/docs/{memory/05-semantic-recall.md → references/docs-memory-semantic-recall.md} +33 -17
  26. package/dist/docs/{memory/02-storage.md → references/docs-memory-storage.md} +29 -39
  27. package/dist/docs/{memory/04-working-memory.md → references/docs-memory-working-memory.md} +16 -27
  28. package/dist/docs/references/reference-core-getMemory.md +50 -0
  29. package/dist/docs/references/reference-core-listMemory.md +56 -0
  30. package/dist/docs/references/reference-memory-clone-utilities.md +199 -0
  31. package/dist/docs/references/reference-memory-cloneThread.md +130 -0
  32. package/dist/docs/references/reference-memory-createThread.md +68 -0
  33. package/dist/docs/references/reference-memory-getThreadById.md +24 -0
  34. package/dist/docs/references/reference-memory-listThreads.md +145 -0
  35. package/dist/docs/references/reference-memory-memory-class.md +147 -0
  36. package/dist/docs/references/reference-memory-observational-memory.md +528 -0
  37. package/dist/docs/{processors/01-reference.md → references/reference-processors-token-limiter-processor.md} +25 -12
  38. package/dist/docs/references/reference-storage-dynamodb.md +282 -0
  39. package/dist/docs/references/reference-storage-libsql.md +135 -0
  40. package/dist/docs/references/reference-storage-mongodb.md +262 -0
  41. package/dist/docs/references/reference-storage-postgresql.md +529 -0
  42. package/dist/docs/references/reference-storage-upstash.md +160 -0
  43. package/dist/docs/references/reference-vectors-libsql.md +305 -0
  44. package/dist/docs/references/reference-vectors-mongodb.md +295 -0
  45. package/dist/docs/references/reference-vectors-pg.md +408 -0
  46. package/dist/docs/references/reference-vectors-upstash.md +294 -0
  47. package/dist/index.cjs +919 -507
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +914 -502
  51. package/dist/index.js.map +1 -1
  52. package/dist/{observational-memory-3Q42SITP.cjs → observational-memory-3UO64HYD.cjs} +14 -14
  53. package/dist/{observational-memory-3Q42SITP.cjs.map → observational-memory-3UO64HYD.cjs.map} +1 -1
  54. package/dist/{observational-memory-VXLHOSDZ.js → observational-memory-TVHT3HP4.js} +3 -3
  55. package/dist/{observational-memory-VXLHOSDZ.js.map → observational-memory-TVHT3HP4.js.map} +1 -1
  56. package/dist/processors/index.cjs +12 -12
  57. package/dist/processors/index.js +1 -1
  58. package/dist/processors/observational-memory/index.d.ts +1 -1
  59. package/dist/processors/observational-memory/index.d.ts.map +1 -1
  60. package/dist/processors/observational-memory/observational-memory.d.ts +267 -1
  61. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  62. package/dist/processors/observational-memory/observer-agent.d.ts +3 -1
  63. package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
  64. package/dist/processors/observational-memory/reflector-agent.d.ts +10 -3
  65. package/dist/processors/observational-memory/reflector-agent.d.ts.map +1 -1
  66. package/dist/processors/observational-memory/types.d.ts +243 -19
  67. package/dist/processors/observational-memory/types.d.ts.map +1 -1
  68. package/dist/{token-6GSAFR2W-WGTMOPEU.js → token-APYSY3BW-2DN6RAUY.js} +11 -11
  69. package/dist/token-APYSY3BW-2DN6RAUY.js.map +1 -0
  70. package/dist/{token-6GSAFR2W-2B4WM6AQ.cjs → token-APYSY3BW-ZQ7TMBY7.cjs} +14 -14
  71. package/dist/token-APYSY3BW-ZQ7TMBY7.cjs.map +1 -0
  72. package/dist/token-util-RMHT2CPJ-6TGPE335.cjs +10 -0
  73. package/dist/token-util-RMHT2CPJ-6TGPE335.cjs.map +1 -0
  74. package/dist/token-util-RMHT2CPJ-RJEA3FAN.js +8 -0
  75. package/dist/token-util-RMHT2CPJ-RJEA3FAN.js.map +1 -0
  76. package/dist/tools/working-memory.d.ts.map +1 -1
  77. package/package.json +6 -7
  78. package/dist/chunk-6TXUWFIU.js.map +0 -1
  79. package/dist/chunk-FQJWVCDF.cjs.map +0 -1
  80. package/dist/chunk-WM6IIUQW.js +0 -250
  81. package/dist/chunk-WM6IIUQW.js.map +0 -1
  82. package/dist/chunk-ZSBBXHNM.cjs +0 -252
  83. package/dist/chunk-ZSBBXHNM.cjs.map +0 -1
  84. package/dist/docs/README.md +0 -36
  85. package/dist/docs/agents/01-agent-memory.md +0 -166
  86. package/dist/docs/core/01-reference.md +0 -114
  87. package/dist/docs/memory/07-reference.md +0 -687
  88. package/dist/docs/storage/01-reference.md +0 -1218
  89. package/dist/docs/vectors/01-reference.md +0 -942
  90. package/dist/token-6GSAFR2W-2B4WM6AQ.cjs.map +0 -1
  91. package/dist/token-6GSAFR2W-WGTMOPEU.js.map +0 -1
  92. package/dist/token-util-NEHG7TUY-TV2H7N56.js +0 -8
  93. package/dist/token-util-NEHG7TUY-TV2H7N56.js.map +0 -1
  94. package/dist/token-util-NEHG7TUY-WJZIPNNX.cjs +0 -10
  95. package/dist/token-util-NEHG7TUY-WJZIPNNX.cjs.map +0 -1
@@ -0,0 +1,441 @@
1
+ 'use strict';
2
+
3
+ var chunkIDRQZVB4_cjs = require('./chunk-IDRQZVB4.cjs');
4
+
5
+ // ../_vendored/ai_v6/dist/chunk-QCO6BNQA.js
6
+ var require_token_io = chunkIDRQZVB4_cjs.__commonJS({
7
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-io.js"(exports$1, module) {
8
+ var __create = Object.create;
9
+ var __defProp = Object.defineProperty;
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __getOwnPropNames = Object.getOwnPropertyNames;
12
+ var __getProtoOf = Object.getPrototypeOf;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+ var token_io_exports = {};
36
+ __export(token_io_exports, {
37
+ findRootDir: () => findRootDir,
38
+ getUserDataDir: () => getUserDataDir
39
+ });
40
+ module.exports = __toCommonJS(token_io_exports);
41
+ var import_path = __toESM(chunkIDRQZVB4_cjs.__require("path"));
42
+ var import_fs = __toESM(chunkIDRQZVB4_cjs.__require("fs"));
43
+ var import_os = __toESM(chunkIDRQZVB4_cjs.__require("os"));
44
+ var import_token_error = chunkIDRQZVB4_cjs.require_token_error();
45
+ function findRootDir() {
46
+ try {
47
+ let dir = process.cwd();
48
+ while (dir !== import_path.default.dirname(dir)) {
49
+ const pkgPath = import_path.default.join(dir, ".vercel");
50
+ if (import_fs.default.existsSync(pkgPath)) {
51
+ return dir;
52
+ }
53
+ dir = import_path.default.dirname(dir);
54
+ }
55
+ } catch (e) {
56
+ throw new import_token_error.VercelOidcTokenError(
57
+ "Token refresh only supported in node server environments"
58
+ );
59
+ }
60
+ return null;
61
+ }
62
+ function getUserDataDir() {
63
+ if (process.env.XDG_DATA_HOME) {
64
+ return process.env.XDG_DATA_HOME;
65
+ }
66
+ switch (import_os.default.platform()) {
67
+ case "darwin":
68
+ return import_path.default.join(import_os.default.homedir(), "Library/Application Support");
69
+ case "linux":
70
+ return import_path.default.join(import_os.default.homedir(), ".local/share");
71
+ case "win32":
72
+ if (process.env.LOCALAPPDATA) {
73
+ return process.env.LOCALAPPDATA;
74
+ }
75
+ return null;
76
+ default:
77
+ return null;
78
+ }
79
+ }
80
+ }
81
+ });
82
+ var require_auth_config = chunkIDRQZVB4_cjs.__commonJS({
83
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/auth-config.js"(exports$1, module) {
84
+ var __create = Object.create;
85
+ var __defProp = Object.defineProperty;
86
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
87
+ var __getOwnPropNames = Object.getOwnPropertyNames;
88
+ var __getProtoOf = Object.getPrototypeOf;
89
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
90
+ var __export = (target, all) => {
91
+ for (var name in all)
92
+ __defProp(target, name, { get: all[name], enumerable: true });
93
+ };
94
+ var __copyProps = (to, from, except, desc) => {
95
+ if (from && typeof from === "object" || typeof from === "function") {
96
+ for (let key of __getOwnPropNames(from))
97
+ if (!__hasOwnProp.call(to, key) && key !== except)
98
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
99
+ }
100
+ return to;
101
+ };
102
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
103
+ // If the importer is in node compatibility mode or this is not an ESM
104
+ // file that has been converted to a CommonJS file using a Babel-
105
+ // compatible transform (i.e. "__esModule" has not been set), then set
106
+ // "default" to the CommonJS "module.exports" for node compatibility.
107
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
108
+ mod
109
+ ));
110
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
111
+ var auth_config_exports = {};
112
+ __export(auth_config_exports, {
113
+ isValidAccessToken: () => isValidAccessToken,
114
+ readAuthConfig: () => readAuthConfig,
115
+ writeAuthConfig: () => writeAuthConfig
116
+ });
117
+ module.exports = __toCommonJS(auth_config_exports);
118
+ var fs = __toESM(chunkIDRQZVB4_cjs.__require("fs"));
119
+ var path = __toESM(chunkIDRQZVB4_cjs.__require("path"));
120
+ var import_token_util = require_token_util();
121
+ function getAuthConfigPath() {
122
+ const dataDir = (0, import_token_util.getVercelDataDir)();
123
+ if (!dataDir) {
124
+ throw new Error(
125
+ `Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`
126
+ );
127
+ }
128
+ return path.join(dataDir, "auth.json");
129
+ }
130
+ function readAuthConfig() {
131
+ try {
132
+ const authPath = getAuthConfigPath();
133
+ if (!fs.existsSync(authPath)) {
134
+ return null;
135
+ }
136
+ const content = fs.readFileSync(authPath, "utf8");
137
+ if (!content) {
138
+ return null;
139
+ }
140
+ return JSON.parse(content);
141
+ } catch (error) {
142
+ return null;
143
+ }
144
+ }
145
+ function writeAuthConfig(config) {
146
+ const authPath = getAuthConfigPath();
147
+ const authDir = path.dirname(authPath);
148
+ if (!fs.existsSync(authDir)) {
149
+ fs.mkdirSync(authDir, { mode: 504, recursive: true });
150
+ }
151
+ fs.writeFileSync(authPath, JSON.stringify(config, null, 2), { mode: 384 });
152
+ }
153
+ function isValidAccessToken(authConfig) {
154
+ if (!authConfig.token)
155
+ return false;
156
+ if (typeof authConfig.expiresAt !== "number")
157
+ return true;
158
+ const nowInSeconds = Math.floor(Date.now() / 1e3);
159
+ return authConfig.expiresAt >= nowInSeconds;
160
+ }
161
+ }
162
+ });
163
+ var require_oauth = chunkIDRQZVB4_cjs.__commonJS({
164
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/oauth.js"(exports$1, module) {
165
+ var __defProp = Object.defineProperty;
166
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
167
+ var __getOwnPropNames = Object.getOwnPropertyNames;
168
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
169
+ var __export = (target, all) => {
170
+ for (var name in all)
171
+ __defProp(target, name, { get: all[name], enumerable: true });
172
+ };
173
+ var __copyProps = (to, from, except, desc) => {
174
+ if (from && typeof from === "object" || typeof from === "function") {
175
+ for (let key of __getOwnPropNames(from))
176
+ if (!__hasOwnProp.call(to, key) && key !== except)
177
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
178
+ }
179
+ return to;
180
+ };
181
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
182
+ var oauth_exports = {};
183
+ __export(oauth_exports, {
184
+ processTokenResponse: () => processTokenResponse,
185
+ refreshTokenRequest: () => refreshTokenRequest
186
+ });
187
+ module.exports = __toCommonJS(oauth_exports);
188
+ var import_os = chunkIDRQZVB4_cjs.__require("os");
189
+ var VERCEL_ISSUER = "https://vercel.com";
190
+ var VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
191
+ var userAgent = `@vercel/oidc node-${process.version} ${(0, import_os.platform)()} (${(0, import_os.arch)()}) ${(0, import_os.hostname)()}`;
192
+ var _tokenEndpoint = null;
193
+ async function getTokenEndpoint() {
194
+ if (_tokenEndpoint) {
195
+ return _tokenEndpoint;
196
+ }
197
+ const discoveryUrl = `${VERCEL_ISSUER}/.well-known/openid-configuration`;
198
+ const response = await fetch(discoveryUrl, {
199
+ headers: { "user-agent": userAgent }
200
+ });
201
+ if (!response.ok) {
202
+ throw new Error("Failed to discover OAuth endpoints");
203
+ }
204
+ const metadata = await response.json();
205
+ if (!metadata || typeof metadata.token_endpoint !== "string") {
206
+ throw new Error("Invalid OAuth discovery response");
207
+ }
208
+ const endpoint = metadata.token_endpoint;
209
+ _tokenEndpoint = endpoint;
210
+ return endpoint;
211
+ }
212
+ async function refreshTokenRequest(options) {
213
+ const tokenEndpoint = await getTokenEndpoint();
214
+ return await fetch(tokenEndpoint, {
215
+ method: "POST",
216
+ headers: {
217
+ "Content-Type": "application/x-www-form-urlencoded",
218
+ "user-agent": userAgent
219
+ },
220
+ body: new URLSearchParams({
221
+ client_id: VERCEL_CLI_CLIENT_ID,
222
+ grant_type: "refresh_token",
223
+ ...options
224
+ })
225
+ });
226
+ }
227
+ async function processTokenResponse(response) {
228
+ const json = await response.json();
229
+ if (!response.ok) {
230
+ const errorMsg = typeof json === "object" && json && "error" in json ? String(json.error) : "Token refresh failed";
231
+ return [new Error(errorMsg)];
232
+ }
233
+ if (typeof json !== "object" || json === null) {
234
+ return [new Error("Invalid token response")];
235
+ }
236
+ if (typeof json.access_token !== "string") {
237
+ return [new Error("Missing access_token in response")];
238
+ }
239
+ if (json.token_type !== "Bearer") {
240
+ return [new Error("Invalid token_type in response")];
241
+ }
242
+ if (typeof json.expires_in !== "number") {
243
+ return [new Error("Missing expires_in in response")];
244
+ }
245
+ return [null, json];
246
+ }
247
+ }
248
+ });
249
+ var require_token_util = chunkIDRQZVB4_cjs.__commonJS({
250
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-util.js"(exports$1, module) {
251
+ var __create = Object.create;
252
+ var __defProp = Object.defineProperty;
253
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
254
+ var __getOwnPropNames = Object.getOwnPropertyNames;
255
+ var __getProtoOf = Object.getPrototypeOf;
256
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
257
+ var __export = (target, all) => {
258
+ for (var name in all)
259
+ __defProp(target, name, { get: all[name], enumerable: true });
260
+ };
261
+ var __copyProps = (to, from, except, desc) => {
262
+ if (from && typeof from === "object" || typeof from === "function") {
263
+ for (let key of __getOwnPropNames(from))
264
+ if (!__hasOwnProp.call(to, key) && key !== except)
265
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
266
+ }
267
+ return to;
268
+ };
269
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
270
+ // If the importer is in node compatibility mode or this is not an ESM
271
+ // file that has been converted to a CommonJS file using a Babel-
272
+ // compatible transform (i.e. "__esModule" has not been set), then set
273
+ // "default" to the CommonJS "module.exports" for node compatibility.
274
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
275
+ mod
276
+ ));
277
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
278
+ var token_util_exports = {};
279
+ __export(token_util_exports, {
280
+ assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,
281
+ findProjectInfo: () => findProjectInfo,
282
+ getTokenPayload: () => getTokenPayload,
283
+ getVercelCliToken: () => getVercelCliToken,
284
+ getVercelDataDir: () => getVercelDataDir,
285
+ getVercelOidcToken: () => getVercelOidcToken,
286
+ isExpired: () => isExpired,
287
+ loadToken: () => loadToken,
288
+ saveToken: () => saveToken
289
+ });
290
+ module.exports = __toCommonJS(token_util_exports);
291
+ var path = __toESM(chunkIDRQZVB4_cjs.__require("path"));
292
+ var fs = __toESM(chunkIDRQZVB4_cjs.__require("fs"));
293
+ var import_token_error = chunkIDRQZVB4_cjs.require_token_error();
294
+ var import_token_io = require_token_io();
295
+ var import_auth_config = require_auth_config();
296
+ var import_oauth = require_oauth();
297
+ function getVercelDataDir() {
298
+ const vercelFolder = "com.vercel.cli";
299
+ const dataDir = (0, import_token_io.getUserDataDir)();
300
+ if (!dataDir) {
301
+ return null;
302
+ }
303
+ return path.join(dataDir, vercelFolder);
304
+ }
305
+ async function getVercelCliToken() {
306
+ const authConfig = (0, import_auth_config.readAuthConfig)();
307
+ if (!authConfig) {
308
+ return null;
309
+ }
310
+ if ((0, import_auth_config.isValidAccessToken)(authConfig)) {
311
+ return authConfig.token || null;
312
+ }
313
+ if (!authConfig.refreshToken) {
314
+ (0, import_auth_config.writeAuthConfig)({});
315
+ return null;
316
+ }
317
+ try {
318
+ const tokenResponse = await (0, import_oauth.refreshTokenRequest)({
319
+ refresh_token: authConfig.refreshToken
320
+ });
321
+ const [tokensError, tokens] = await (0, import_oauth.processTokenResponse)(tokenResponse);
322
+ if (tokensError || !tokens) {
323
+ (0, import_auth_config.writeAuthConfig)({});
324
+ return null;
325
+ }
326
+ const updatedConfig = {
327
+ token: tokens.access_token,
328
+ expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in
329
+ };
330
+ if (tokens.refresh_token) {
331
+ updatedConfig.refreshToken = tokens.refresh_token;
332
+ }
333
+ (0, import_auth_config.writeAuthConfig)(updatedConfig);
334
+ return updatedConfig.token ?? null;
335
+ } catch (error) {
336
+ (0, import_auth_config.writeAuthConfig)({});
337
+ return null;
338
+ }
339
+ }
340
+ async function getVercelOidcToken(authToken, projectId, teamId) {
341
+ const url = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : ""}`;
342
+ const res = await fetch(url, {
343
+ method: "POST",
344
+ headers: {
345
+ Authorization: `Bearer ${authToken}`
346
+ }
347
+ });
348
+ if (!res.ok) {
349
+ throw new import_token_error.VercelOidcTokenError(
350
+ `Failed to refresh OIDC token: ${res.statusText}`
351
+ );
352
+ }
353
+ const tokenRes = await res.json();
354
+ assertVercelOidcTokenResponse(tokenRes);
355
+ return tokenRes;
356
+ }
357
+ function assertVercelOidcTokenResponse(res) {
358
+ if (!res || typeof res !== "object") {
359
+ throw new TypeError(
360
+ "Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again"
361
+ );
362
+ }
363
+ if (!("token" in res) || typeof res.token !== "string") {
364
+ throw new TypeError(
365
+ "Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again"
366
+ );
367
+ }
368
+ }
369
+ function findProjectInfo() {
370
+ const dir = (0, import_token_io.findRootDir)();
371
+ if (!dir) {
372
+ throw new import_token_error.VercelOidcTokenError(
373
+ "Unable to find project root directory. Have you linked your project with `vc link?`"
374
+ );
375
+ }
376
+ const prjPath = path.join(dir, ".vercel", "project.json");
377
+ if (!fs.existsSync(prjPath)) {
378
+ throw new import_token_error.VercelOidcTokenError(
379
+ "project.json not found, have you linked your project with `vc link?`"
380
+ );
381
+ }
382
+ const prj = JSON.parse(fs.readFileSync(prjPath, "utf8"));
383
+ if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
384
+ throw new TypeError(
385
+ "Expected a string-valued projectId property. Try running `vc link` to re-link your project."
386
+ );
387
+ }
388
+ return { projectId: prj.projectId, teamId: prj.orgId };
389
+ }
390
+ function saveToken(token, projectId) {
391
+ const dir = (0, import_token_io.getUserDataDir)();
392
+ if (!dir) {
393
+ throw new import_token_error.VercelOidcTokenError(
394
+ "Unable to find user data directory. Please reach out to Vercel support."
395
+ );
396
+ }
397
+ const tokenPath = path.join(dir, "com.vercel.token", `${projectId}.json`);
398
+ const tokenJson = JSON.stringify(token);
399
+ fs.mkdirSync(path.dirname(tokenPath), { mode: 504, recursive: true });
400
+ fs.writeFileSync(tokenPath, tokenJson);
401
+ fs.chmodSync(tokenPath, 432);
402
+ return;
403
+ }
404
+ function loadToken(projectId) {
405
+ const dir = (0, import_token_io.getUserDataDir)();
406
+ if (!dir) {
407
+ throw new import_token_error.VercelOidcTokenError(
408
+ "Unable to find user data directory. Please reach out to Vercel support."
409
+ );
410
+ }
411
+ const tokenPath = path.join(dir, "com.vercel.token", `${projectId}.json`);
412
+ if (!fs.existsSync(tokenPath)) {
413
+ return null;
414
+ }
415
+ const token = JSON.parse(fs.readFileSync(tokenPath, "utf8"));
416
+ assertVercelOidcTokenResponse(token);
417
+ return token;
418
+ }
419
+ function getTokenPayload(token) {
420
+ const tokenParts = token.split(".");
421
+ if (tokenParts.length !== 3) {
422
+ throw new import_token_error.VercelOidcTokenError(
423
+ "Invalid token. Please run `vc env pull` and try again"
424
+ );
425
+ }
426
+ const base64 = tokenParts[1].replace(/-/g, "+").replace(/_/g, "/");
427
+ const padded = base64.padEnd(
428
+ base64.length + (4 - base64.length % 4) % 4,
429
+ "="
430
+ );
431
+ return JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
432
+ }
433
+ function isExpired(token) {
434
+ return token.exp * 1e3 < Date.now();
435
+ }
436
+ }
437
+ });
438
+
439
+ exports.require_token_util = require_token_util;
440
+ //# sourceMappingURL=chunk-ZD3BKU5O.cjs.map
441
+ //# sourceMappingURL=chunk-ZD3BKU5O.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-io.js","../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/auth-config.js","../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/oauth.js","../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/token-util.js"],"names":["__commonJS","exports","__require","require_token_error"],"mappings":";;;;;AAAA,IAAA,mBAAAA,4BAAA,CAAA;AAAA,EAAA,2FAAA,CAAAC,WAAA,MAAA,EAAA;AACA,IAAA,IAAI,WAAW,MAAA,CAAO,MAAA;AACtB,IAAA,IAAI,YAAY,MAAA,CAAO,cAAA;AACvB,IAAA,IAAI,mBAAmB,MAAA,CAAO,wBAAA;AAC9B,IAAA,IAAI,oBAAoB,MAAA,CAAO,mBAAA;AAC/B,IAAA,IAAI,eAAe,MAAA,CAAO,cAAA;AAC1B,IAAA,IAAI,YAAA,GAAe,OAAO,SAAA,CAAU,cAAA;AACpC,IAAA,IAAI,QAAA,GAAW,CAAC,MAAA,EAAQ,GAAA,KAAQ;AAC9B,MAAA,KAAA,IAAS,IAAA,IAAQ,GAAA;AACf,QAAA,SAAA,CAAU,MAAA,EAAQ,MAAM,EAAE,GAAA,EAAK,IAAI,IAAI,CAAA,EAAG,UAAA,EAAY,IAAA,EAAM,CAAA;AAChE,IAAA,CAAA;AACA,IAAA,IAAI,WAAA,GAAc,CAAC,EAAA,EAAI,IAAA,EAAM,QAAQ,IAAA,KAAS;AAC5C,MAAA,IAAI,QAAQ,OAAO,IAAA,KAAS,QAAA,IAAY,OAAO,SAAS,UAAA,EAAY;AAClE,QAAA,KAAA,IAAS,GAAA,IAAO,kBAAkB,IAAI,CAAA;AACpC,UAAA,IAAI,CAAC,YAAA,CAAa,IAAA,CAAK,EAAA,EAAI,GAAG,KAAK,GAAA,KAAQ,MAAA;AACzC,YAAA,SAAA,CAAU,IAAI,GAAA,EAAK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,UAAA;AAAA,SAAA;AAEJ,MAAA;AACA,MAAA,MAAM,MAAA,GAAS,UAAA,CAAW,CAAC,CAAA,CAAE,OAAA,CAAQ,MAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA;AACjE,MAAA,MAAM,SAAS,MAAA,CAAO,MAAA;AACpB,QAAA,MAAA,CAAO,MAAA,GAAA,CAAU,CAAA,GAAI,MAAA,CAAO,MAAA,GAAS,CAAA,IAAK,CAAA;AAC1C,QAAA;AAAA,OAAA;AAEF,MAAA,OAAO,IAAA,CAAK,MAAM,MAAA,CAAO,IAAA,CAAK,QAAQ,QAAQ,CAAA,CAAE,QAAA,CAAS,MAAM,CAAC,CAAA;AAClE,IAAA;AACA,IAAA,SAAS,UAAU,KAAA,EAAO;AACxB,MAAA,OAAO,KAAA,CAAM,GAAA,GAAM,GAAA,GAAM,IAAA,CAAK,GAAA,EAAA;AAChC,IAAA;AAAA,EAAA;AAAA,CAAA","file":"chunk-ZD3BKU5O.cjs","sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_io_exports = {};\n__export(token_io_exports, {\n findRootDir: () => findRootDir,\n getUserDataDir: () => getUserDataDir\n});\nmodule.exports = __toCommonJS(token_io_exports);\nvar import_path = __toESM(require(\"path\"));\nvar import_fs = __toESM(require(\"fs\"));\nvar import_os = __toESM(require(\"os\"));\nvar import_token_error = require(\"./token-error\");\nfunction findRootDir() {\n try {\n let dir = process.cwd();\n while (dir !== import_path.default.dirname(dir)) {\n const pkgPath = import_path.default.join(dir, \".vercel\");\n if (import_fs.default.existsSync(pkgPath)) {\n return dir;\n }\n dir = import_path.default.dirname(dir);\n }\n } catch (e) {\n throw new import_token_error.VercelOidcTokenError(\n \"Token refresh only supported in node server environments\"\n );\n }\n return null;\n}\nfunction getUserDataDir() {\n if (process.env.XDG_DATA_HOME) {\n return process.env.XDG_DATA_HOME;\n }\n switch (import_os.default.platform()) {\n case \"darwin\":\n return import_path.default.join(import_os.default.homedir(), \"Library/Application Support\");\n case \"linux\":\n return import_path.default.join(import_os.default.homedir(), \".local/share\");\n case \"win32\":\n if (process.env.LOCALAPPDATA) {\n return process.env.LOCALAPPDATA;\n }\n return null;\n default:\n return null;\n }\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n findRootDir,\n getUserDataDir\n});\n","\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar auth_config_exports = {};\n__export(auth_config_exports, {\n isValidAccessToken: () => isValidAccessToken,\n readAuthConfig: () => readAuthConfig,\n writeAuthConfig: () => writeAuthConfig\n});\nmodule.exports = __toCommonJS(auth_config_exports);\nvar fs = __toESM(require(\"fs\"));\nvar path = __toESM(require(\"path\"));\nvar import_token_util = require(\"./token-util\");\nfunction getAuthConfigPath() {\n const dataDir = (0, import_token_util.getVercelDataDir)();\n if (!dataDir) {\n throw new Error(\n `Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`\n );\n }\n return path.join(dataDir, \"auth.json\");\n}\nfunction readAuthConfig() {\n try {\n const authPath = getAuthConfigPath();\n if (!fs.existsSync(authPath)) {\n return null;\n }\n const content = fs.readFileSync(authPath, \"utf8\");\n if (!content) {\n return null;\n }\n return JSON.parse(content);\n } catch (error) {\n return null;\n }\n}\nfunction writeAuthConfig(config) {\n const authPath = getAuthConfigPath();\n const authDir = path.dirname(authPath);\n if (!fs.existsSync(authDir)) {\n fs.mkdirSync(authDir, { mode: 504, recursive: true });\n }\n fs.writeFileSync(authPath, JSON.stringify(config, null, 2), { mode: 384 });\n}\nfunction isValidAccessToken(authConfig) {\n if (!authConfig.token)\n return false;\n if (typeof authConfig.expiresAt !== \"number\")\n return true;\n const nowInSeconds = Math.floor(Date.now() / 1e3);\n return authConfig.expiresAt >= nowInSeconds;\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n isValidAccessToken,\n readAuthConfig,\n writeAuthConfig\n});\n","\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar oauth_exports = {};\n__export(oauth_exports, {\n processTokenResponse: () => processTokenResponse,\n refreshTokenRequest: () => refreshTokenRequest\n});\nmodule.exports = __toCommonJS(oauth_exports);\nvar import_os = require(\"os\");\nconst VERCEL_ISSUER = \"https://vercel.com\";\nconst VERCEL_CLI_CLIENT_ID = \"cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp\";\nconst userAgent = `@vercel/oidc node-${process.version} ${(0, import_os.platform)()} (${(0, import_os.arch)()}) ${(0, import_os.hostname)()}`;\nlet _tokenEndpoint = null;\nasync function getTokenEndpoint() {\n if (_tokenEndpoint) {\n return _tokenEndpoint;\n }\n const discoveryUrl = `${VERCEL_ISSUER}/.well-known/openid-configuration`;\n const response = await fetch(discoveryUrl, {\n headers: { \"user-agent\": userAgent }\n });\n if (!response.ok) {\n throw new Error(\"Failed to discover OAuth endpoints\");\n }\n const metadata = await response.json();\n if (!metadata || typeof metadata.token_endpoint !== \"string\") {\n throw new Error(\"Invalid OAuth discovery response\");\n }\n const endpoint = metadata.token_endpoint;\n _tokenEndpoint = endpoint;\n return endpoint;\n}\nasync function refreshTokenRequest(options) {\n const tokenEndpoint = await getTokenEndpoint();\n return await fetch(tokenEndpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n \"user-agent\": userAgent\n },\n body: new URLSearchParams({\n client_id: VERCEL_CLI_CLIENT_ID,\n grant_type: \"refresh_token\",\n ...options\n })\n });\n}\nasync function processTokenResponse(response) {\n const json = await response.json();\n if (!response.ok) {\n const errorMsg = typeof json === \"object\" && json && \"error\" in json ? String(json.error) : \"Token refresh failed\";\n return [new Error(errorMsg)];\n }\n if (typeof json !== \"object\" || json === null) {\n return [new Error(\"Invalid token response\")];\n }\n if (typeof json.access_token !== \"string\") {\n return [new Error(\"Missing access_token in response\")];\n }\n if (json.token_type !== \"Bearer\") {\n return [new Error(\"Invalid token_type in response\")];\n }\n if (typeof json.expires_in !== \"number\") {\n return [new Error(\"Missing expires_in in response\")];\n }\n return [null, json];\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n processTokenResponse,\n refreshTokenRequest\n});\n","\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_util_exports = {};\n__export(token_util_exports, {\n assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,\n findProjectInfo: () => findProjectInfo,\n getTokenPayload: () => getTokenPayload,\n getVercelCliToken: () => getVercelCliToken,\n getVercelDataDir: () => getVercelDataDir,\n getVercelOidcToken: () => getVercelOidcToken,\n isExpired: () => isExpired,\n loadToken: () => loadToken,\n saveToken: () => saveToken\n});\nmodule.exports = __toCommonJS(token_util_exports);\nvar path = __toESM(require(\"path\"));\nvar fs = __toESM(require(\"fs\"));\nvar import_token_error = require(\"./token-error\");\nvar import_token_io = require(\"./token-io\");\nvar import_auth_config = require(\"./auth-config\");\nvar import_oauth = require(\"./oauth\");\nfunction getVercelDataDir() {\n const vercelFolder = \"com.vercel.cli\";\n const dataDir = (0, import_token_io.getUserDataDir)();\n if (!dataDir) {\n return null;\n }\n return path.join(dataDir, vercelFolder);\n}\nasync function getVercelCliToken() {\n const authConfig = (0, import_auth_config.readAuthConfig)();\n if (!authConfig) {\n return null;\n }\n if ((0, import_auth_config.isValidAccessToken)(authConfig)) {\n return authConfig.token || null;\n }\n if (!authConfig.refreshToken) {\n (0, import_auth_config.writeAuthConfig)({});\n return null;\n }\n try {\n const tokenResponse = await (0, import_oauth.refreshTokenRequest)({\n refresh_token: authConfig.refreshToken\n });\n const [tokensError, tokens] = await (0, import_oauth.processTokenResponse)(tokenResponse);\n if (tokensError || !tokens) {\n (0, import_auth_config.writeAuthConfig)({});\n return null;\n }\n const updatedConfig = {\n token: tokens.access_token,\n expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in\n };\n if (tokens.refresh_token) {\n updatedConfig.refreshToken = tokens.refresh_token;\n }\n (0, import_auth_config.writeAuthConfig)(updatedConfig);\n return updatedConfig.token ?? null;\n } catch (error) {\n (0, import_auth_config.writeAuthConfig)({});\n return null;\n }\n}\nasync function getVercelOidcToken(authToken, projectId, teamId) {\n const url = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : \"\"}`;\n const res = await fetch(url, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${authToken}`\n }\n });\n if (!res.ok) {\n throw new import_token_error.VercelOidcTokenError(\n `Failed to refresh OIDC token: ${res.statusText}`\n );\n }\n const tokenRes = await res.json();\n assertVercelOidcTokenResponse(tokenRes);\n return tokenRes;\n}\nfunction assertVercelOidcTokenResponse(res) {\n if (!res || typeof res !== \"object\") {\n throw new TypeError(\n \"Vercel OIDC token is malformed. Expected an object. Please run `vc env pull` and try again\"\n );\n }\n if (!(\"token\" in res) || typeof res.token !== \"string\") {\n throw new TypeError(\n \"Vercel OIDC token is malformed. Expected a string-valued token property. Please run `vc env pull` and try again\"\n );\n }\n}\nfunction findProjectInfo() {\n const dir = (0, import_token_io.findRootDir)();\n if (!dir) {\n throw new import_token_error.VercelOidcTokenError(\n \"Unable to find project root directory. Have you linked your project with `vc link?`\"\n );\n }\n const prjPath = path.join(dir, \".vercel\", \"project.json\");\n if (!fs.existsSync(prjPath)) {\n throw new import_token_error.VercelOidcTokenError(\n \"project.json not found, have you linked your project with `vc link?`\"\n );\n }\n const prj = JSON.parse(fs.readFileSync(prjPath, \"utf8\"));\n if (typeof prj.projectId !== \"string\" && typeof prj.orgId !== \"string\") {\n throw new TypeError(\n \"Expected a string-valued projectId property. Try running `vc link` to re-link your project.\"\n );\n }\n return { projectId: prj.projectId, teamId: prj.orgId };\n}\nfunction saveToken(token, projectId) {\n const dir = (0, import_token_io.getUserDataDir)();\n if (!dir) {\n throw new import_token_error.VercelOidcTokenError(\n \"Unable to find user data directory. Please reach out to Vercel support.\"\n );\n }\n const tokenPath = path.join(dir, \"com.vercel.token\", `${projectId}.json`);\n const tokenJson = JSON.stringify(token);\n fs.mkdirSync(path.dirname(tokenPath), { mode: 504, recursive: true });\n fs.writeFileSync(tokenPath, tokenJson);\n fs.chmodSync(tokenPath, 432);\n return;\n}\nfunction loadToken(projectId) {\n const dir = (0, import_token_io.getUserDataDir)();\n if (!dir) {\n throw new import_token_error.VercelOidcTokenError(\n \"Unable to find user data directory. Please reach out to Vercel support.\"\n );\n }\n const tokenPath = path.join(dir, \"com.vercel.token\", `${projectId}.json`);\n if (!fs.existsSync(tokenPath)) {\n return null;\n }\n const token = JSON.parse(fs.readFileSync(tokenPath, \"utf8\"));\n assertVercelOidcTokenResponse(token);\n return token;\n}\nfunction getTokenPayload(token) {\n const tokenParts = token.split(\".\");\n if (tokenParts.length !== 3) {\n throw new import_token_error.VercelOidcTokenError(\n \"Invalid token. Please run `vc env pull` and try again\"\n );\n }\n const base64 = tokenParts[1].replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = base64.padEnd(\n base64.length + (4 - base64.length % 4) % 4,\n \"=\"\n );\n return JSON.parse(Buffer.from(padded, \"base64\").toString(\"utf8\"));\n}\nfunction isExpired(token) {\n return token.exp * 1e3 < Date.now();\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n assertVercelOidcTokenResponse,\n findProjectInfo,\n getTokenPayload,\n getVercelCliToken,\n getVercelDataDir,\n getVercelOidcToken,\n isExpired,\n loadToken,\n saveToken\n});\n"]}
@@ -1,53 +1,54 @@
1
1
  ---
2
- name: mastra-memory-docs
3
- description: Documentation for @mastra/memory. Includes links to type definitions and readable implementation code in dist/.
2
+ name: mastra-memory
3
+ description: Documentation for @mastra/memory. Use when working with @mastra/memory APIs, configuration, or implementation.
4
+ metadata:
5
+ package: "@mastra/memory"
6
+ version: "1.2.0-alpha.0"
4
7
  ---
5
8
 
6
- # @mastra/memory Documentation
7
-
8
- > **Version**: 1.1.0
9
- > **Package**: @mastra/memory
10
-
11
- ## Quick Navigation
12
-
13
- Use SOURCE_MAP.json to find any export:
14
-
15
- ```bash
16
- cat docs/SOURCE_MAP.json
17
- ```
18
-
19
- Each export maps to:
20
- - **types**: `.d.ts` file with JSDoc and API signatures
21
- - **implementation**: `.js` chunk file with readable source
22
- - **docs**: Conceptual documentation in `docs/`
23
-
24
- ## Top Exports
25
-
26
- - OBSERVATIONAL_MEMORY_DEFAULTS: dist/processors/index.d.ts
27
- - OBSERVER_SYSTEM_PROMPT: dist/processors/index.d.ts
28
- - ObservationalMemory: dist/processors/index.d.ts
29
- - TokenCounter: dist/processors/index.d.ts
30
- - buildObserverPrompt: dist/processors/index.d.ts
31
- - buildObserverSystemPrompt: dist/processors/index.d.ts
32
- - extractCurrentTask: dist/processors/index.d.ts
33
- - formatMessagesForObserver: dist/processors/index.d.ts
34
- - hasCurrentTaskSection: dist/processors/index.d.ts
35
- - optimizeObservationsForContext: dist/processors/index.d.ts
36
- - parseObserverOutput: dist/processors/index.d.ts
37
- - extractWorkingMemoryContent: dist/index.d.ts
38
- - extractWorkingMemoryTags: dist/index.d.ts
39
- - removeWorkingMemoryTags: dist/index.d.ts
40
- - MessageHistory: dist/index.d.ts
41
- - SemanticRecall: dist/index.d.ts
42
- - WorkingMemory: dist/index.d.ts
43
-
44
- See SOURCE_MAP.json for the complete list.
45
-
46
- ## Available Topics
47
-
48
- - [Agents](agents/) - 4 file(s)
49
- - [Core](core/) - 2 file(s)
50
- - [Memory](memory/) - 12 file(s)
51
- - [Processors](processors/) - 1 file(s)
52
- - [Storage](storage/) - 5 file(s)
53
- - [Vectors](vectors/) - 4 file(s)
9
+ ## When to use
10
+
11
+ Use this skill whenever you are working with @mastra/memory to obtain the domain-specific knowledge.
12
+
13
+ ## How to use
14
+
15
+ Read the individual reference documents for detailed explanations and code examples.
16
+
17
+ ### Docs
18
+
19
+ - [Agent Approval](references/docs-agents-agent-approval.md) - Learn how to require approvals, suspend tool execution, and automatically resume suspended tools while keeping humans in control of agent workflows.
20
+ - [Agent Memory](references/docs-agents-agent-memory.md) - Learn how to add memory to agents to store message history and maintain context across interactions.
21
+ - [Network Approval](references/docs-agents-network-approval.md) - Learn how to require approvals, suspend execution, and resume suspended networks while keeping humans in control of agent network workflows.
22
+ - [Agent Networks](references/docs-agents-networks.md) - Learn how to coordinate multiple agents, workflows, and tools using agent networks for complex, non-deterministic task execution.
23
+ - [Memory Processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
24
+ - [Message History](references/docs-memory-message-history.md) - Learn how to configure message history in Mastra to store recent messages from the current conversation.
25
+ - [Observational Memory](references/docs-memory-observational-memory.md) - Learn how Observational Memory keeps your agent's context window small while preserving long-term memory across conversations.
26
+ - [Memory overview](references/docs-memory-overview.md) - Learn how Mastra's memory system works with working memory, message history, semantic recall, and observational memory.
27
+ - [Semantic Recall](references/docs-memory-semantic-recall.md) - Learn how to use semantic recall in Mastra to retrieve relevant messages from past conversations using vector search and embeddings.
28
+ - [Storage](references/docs-memory-storage.md) - Configure storage for Mastra's memory system to persist conversations, workflows, and traces.
29
+ - [Working Memory](references/docs-memory-working-memory.md) - Learn how to configure working memory in Mastra to store persistent user data, preferences.
30
+
31
+ ### Reference
32
+
33
+ - [Reference: Mastra.getMemory()](references/reference-core-getMemory.md) - Documentation for the `Mastra.getMemory()` method in Mastra, which retrieves a registered memory instance by its registry key.
34
+ - [Reference: Mastra.listMemory()](references/reference-core-listMemory.md) - Documentation for the `Mastra.listMemory()` method in Mastra, which returns all registered memory instances.
35
+ - [Reference: Cloned Thread Utilities](references/reference-memory-clone-utilities.md) - Documentation for utility methods to work with cloned threads in Mastra Memory.
36
+ - [Reference: Memory.cloneThread()](references/reference-memory-cloneThread.md) - Documentation for the `Memory.cloneThread()` method in Mastra, which creates a copy of a conversation thread with all its messages.
37
+ - [Reference: Memory.createThread()](references/reference-memory-createThread.md) - Documentation for the `Memory.createThread()` method in Mastra, which creates a new conversation thread in the memory system.
38
+ - [Reference: Memory.getThreadById()](references/reference-memory-getThreadById.md) - Documentation for the `Memory.getThreadById()` method in Mastra, which retrieves a specific thread by its ID.
39
+ - [Reference: Memory.listThreads()](references/reference-memory-listThreads.md) - Documentation for the `Memory.listThreads()` method in Mastra, which retrieves threads with optional filtering by resourceId and/or metadata.
40
+ - [Reference: Memory Class](references/reference-memory-memory-class.md) - Documentation for the `Memory` class in Mastra, which provides a robust system for managing conversation history and thread-based message storage.
41
+ - [Reference: Observational Memory](references/reference-memory-observational-memory.md) - API reference for Observational Memory in Mastra — a three-tier memory system that uses Observer and Reflector agents to maintain long-term memory across conversations.
42
+ - [Reference: Token Limiter Processor](references/reference-processors-token-limiter-processor.md) - Documentation for the TokenLimiterProcessor in Mastra, which limits the number of tokens in messages.
43
+ - [Reference: DynamoDB Storage](references/reference-storage-dynamodb.md) - Documentation for the DynamoDB storage implementation in Mastra, using a single-table design with ElectroDB.
44
+ - [Reference: libSQL Storage](references/reference-storage-libsql.md) - Documentation for the libSQL storage implementation in Mastra.
45
+ - [Reference: MongoDB Storage](references/reference-storage-mongodb.md) - Documentation for the MongoDB storage implementation in Mastra.
46
+ - [Reference: PostgreSQL Storage](references/reference-storage-postgresql.md) - Documentation for the PostgreSQL storage implementation in Mastra.
47
+ - [Reference: Upstash Storage](references/reference-storage-upstash.md) - Documentation for the Upstash storage implementation in Mastra.
48
+ - [Reference: libSQL Vector Store](references/reference-vectors-libsql.md) - Documentation for the LibSQLVector class in Mastra, which provides vector search using libSQL with vector extensions.
49
+ - [Reference: MongoDB Vector Store](references/reference-vectors-mongodb.md) - Documentation for the MongoDBVector class in Mastra, which provides vector search using MongoDB Atlas and Atlas Vector Search.
50
+ - [Reference: PG Vector Store](references/reference-vectors-pg.md) - Documentation for the PgVector class in Mastra, which provides vector search using PostgreSQL with pgvector extension.
51
+ - [Reference: Upstash Vector Store](references/reference-vectors-upstash.md) - Documentation for the UpstashVector class in Mastra, which provides vector search using Upstash Vector.
52
+
53
+
54
+ Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.