@mastra/server 1.23.0-alpha.1 → 1.23.0-alpha.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.23.0-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed gateway memory client failing with 404 when MASTRA_GATEWAY_URL includes a /v1 suffix (e.g. https://gateway-api.mastra.ai/v1). The URL is now normalized before appending the memory base path, matching how the model router handles the same variable. ([#15054](https://github.com/mastra-ai/mastra/pull/15054))
8
+
9
+ - Updated dependencies:
10
+ - @mastra/core@1.23.0-alpha.2
11
+
3
12
  ## 1.23.0-alpha.1
4
13
 
5
14
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkWGB6F36S_cjs = require('./chunk-WGB6F36S.cjs');
4
- var chunkR474QJUF_cjs = require('./chunk-R474QJUF.cjs');
4
+ var chunkUZZDH3J2_cjs = require('./chunk-UZZDH3J2.cjs');
5
5
  var chunkZKMVCV4G_cjs = require('./chunk-ZKMVCV4G.cjs');
6
6
  var chunkEGSCXVMR_cjs = require('./chunk-EGSCXVMR.cjs');
7
7
  var chunkB34S64RC_cjs = require('./chunk-B34S64RC.cjs');
@@ -223,9 +223,9 @@ var GET_MEMORY_STATUS_ROUTE = chunkEGSCXVMR_cjs.createRoute({
223
223
  handler: async ({ mastra, agentId, resourceId, threadId, requestContext }) => {
224
224
  try {
225
225
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
226
- const isGateway = agent ? await chunkR474QJUF_cjs.isGatewayAgentAsync(agent) : false;
226
+ const isGateway = agent ? await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent) : false;
227
227
  if (agent && isGateway) {
228
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
228
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
229
229
  if (gwClient) {
230
230
  let omStatus;
231
231
  if (resourceId && threadId) {
@@ -308,7 +308,7 @@ var GET_MEMORY_CONFIG_ROUTE = chunkEGSCXVMR_cjs.createRoute({
308
308
  handler: async ({ mastra, agentId, requestContext }) => {
309
309
  try {
310
310
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
311
- if (agent && await chunkR474QJUF_cjs.isGatewayAgentAsync(agent) && chunkR474QJUF_cjs.getGatewayClient()) {
311
+ if (agent && await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent) && chunkUZZDH3J2_cjs.getGatewayClient()) {
312
312
  return {
313
313
  memoryType: "gateway",
314
314
  config: {
@@ -357,16 +357,16 @@ var GET_OBSERVATIONAL_MEMORY_ROUTE = chunkEGSCXVMR_cjs.createRoute({
357
357
  if (!agent) {
358
358
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Agent not found" });
359
359
  }
360
- if (await chunkR474QJUF_cjs.isGatewayAgentAsync(agent)) {
361
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
360
+ if (await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent)) {
361
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
362
362
  if (gwClient && resourceId && threadId) {
363
363
  const [recordResult, historyResult] = await Promise.all([
364
364
  gwClient.getObservationRecord(threadId, resourceId),
365
365
  gwClient.getObservationHistory(threadId, { resourceId, limit: 5 })
366
366
  ]);
367
367
  return {
368
- record: recordResult.record ? chunkR474QJUF_cjs.toLocalOMRecord(recordResult.record) : null,
369
- history: historyResult.records?.length > 0 ? historyResult.records.map(chunkR474QJUF_cjs.toLocalOMRecord) : void 0
368
+ record: recordResult.record ? chunkUZZDH3J2_cjs.toLocalOMRecord(recordResult.record) : null,
369
+ history: historyResult.records?.length > 0 ? historyResult.records.map(chunkUZZDH3J2_cjs.toLocalOMRecord) : void 0
370
370
  };
371
371
  }
372
372
  return { record: null, history: void 0 };
@@ -420,8 +420,8 @@ var AWAIT_BUFFER_STATUS_ROUTE = chunkEGSCXVMR_cjs.createRoute({
420
420
  if (!agent) {
421
421
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Agent not found" });
422
422
  }
423
- if (await chunkR474QJUF_cjs.isGatewayAgentAsync(agent)) {
424
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
423
+ if (await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent)) {
424
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
425
425
  if (gwClient && resourceId && threadId) {
426
426
  const maxWaitMs = 3e4;
427
427
  const pollIntervalMs = 1e3;
@@ -429,7 +429,7 @@ var AWAIT_BUFFER_STATUS_ROUTE = chunkEGSCXVMR_cjs.createRoute({
429
429
  let record2 = null;
430
430
  while (Date.now() < deadline) {
431
431
  const result = await gwClient.getObservationRecord(threadId, resourceId);
432
- record2 = result.record ? chunkR474QJUF_cjs.toLocalOMRecord(result.record) : null;
432
+ record2 = result.record ? chunkUZZDH3J2_cjs.toLocalOMRecord(result.record) : null;
433
433
  if (!record2 || !record2.isBufferingObservation && !record2.isBufferingReflection) {
434
434
  break;
435
435
  }
@@ -488,9 +488,9 @@ var LIST_THREADS_ROUTE = chunkEGSCXVMR_cjs.createRoute({
488
488
  try {
489
489
  const effectiveResourceId = chunkZKMVCV4G_cjs.getEffectiveResourceId(requestContext, resourceId);
490
490
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
491
- const isGateway = agent ? await chunkR474QJUF_cjs.isGatewayAgentAsync(agent) : false;
491
+ const isGateway = agent ? await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent) : false;
492
492
  if (agent && isGateway) {
493
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
493
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
494
494
  if (gwClient) {
495
495
  const effectivePage = page ?? 0;
496
496
  const effectivePerPage = perPage ?? 100;
@@ -501,7 +501,7 @@ var LIST_THREADS_ROUTE = chunkEGSCXVMR_cjs.createRoute({
501
501
  offset
502
502
  });
503
503
  return {
504
- threads: result.threads.map(chunkR474QJUF_cjs.toLocalThread),
504
+ threads: result.threads.map(chunkUZZDH3J2_cjs.toLocalThread),
505
505
  page: effectivePage,
506
506
  perPage: effectivePerPage,
507
507
  total: result.total,
@@ -562,9 +562,9 @@ var GET_THREAD_BY_ID_ROUTE = chunkEGSCXVMR_cjs.createRoute({
562
562
  const effectiveResourceId = chunkZKMVCV4G_cjs.getEffectiveResourceId(requestContext, resourceId);
563
563
  chunkZKMVCV4G_cjs.validateBody({ threadId: effectiveThreadId });
564
564
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
565
- const isGateway = agent ? await chunkR474QJUF_cjs.isGatewayAgentAsync(agent) : false;
565
+ const isGateway = agent ? await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent) : false;
566
566
  if (agent && isGateway) {
567
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
567
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
568
568
  if (gwClient) {
569
569
  const result = await gwClient.getThread(effectiveThreadId);
570
570
  if (!result) {
@@ -577,7 +577,7 @@ var GET_THREAD_BY_ID_ROUTE = chunkEGSCXVMR_cjs.createRoute({
577
577
  updatedAt: /* @__PURE__ */ new Date()
578
578
  };
579
579
  }
580
- const thread = chunkR474QJUF_cjs.toLocalThread(result.thread);
580
+ const thread = chunkUZZDH3J2_cjs.toLocalThread(result.thread);
581
581
  await chunkZKMVCV4G_cjs.validateThreadOwnership(thread, effectiveResourceId);
582
582
  return thread;
583
583
  }
@@ -640,12 +640,12 @@ var LIST_MESSAGES_ROUTE = chunkEGSCXVMR_cjs.createRoute({
640
640
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "No threadId found" });
641
641
  }
642
642
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
643
- if (agent && await chunkR474QJUF_cjs.isGatewayAgentAsync(agent)) {
644
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
643
+ if (agent && await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent)) {
644
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
645
645
  if (gwClient) {
646
646
  const threadResult = await gwClient.getThread(effectiveThreadId);
647
647
  if (threadResult) {
648
- await chunkZKMVCV4G_cjs.validateThreadOwnership(chunkR474QJUF_cjs.toLocalThread(threadResult.thread), effectiveResourceId);
648
+ await chunkZKMVCV4G_cjs.validateThreadOwnership(chunkUZZDH3J2_cjs.toLocalThread(threadResult.thread), effectiveResourceId);
649
649
  }
650
650
  const effectivePage = page ?? 0;
651
651
  const effectivePerPage = perPage ?? 100;
@@ -659,8 +659,8 @@ var LIST_MESSAGES_ROUTE = chunkEGSCXVMR_cjs.createRoute({
659
659
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Thread not found" });
660
660
  }
661
661
  return {
662
- messages: result.messages.map(chunkR474QJUF_cjs.toLocalMessage),
663
- uiMessages: result.messages.map(chunkR474QJUF_cjs.toLocalMessage)
662
+ messages: result.messages.map(chunkUZZDH3J2_cjs.toLocalMessage),
663
+ uiMessages: result.messages.map(chunkUZZDH3J2_cjs.toLocalMessage)
664
664
  };
665
665
  }
666
666
  }
@@ -726,7 +726,7 @@ var GET_WORKING_MEMORY_ROUTE = chunkEGSCXVMR_cjs.createRoute({
726
726
  const effectiveResourceId = chunkZKMVCV4G_cjs.getEffectiveResourceId(requestContext, resourceId);
727
727
  chunkZKMVCV4G_cjs.validateBody({ threadId: effectiveThreadId });
728
728
  const gwAgent = await getAgentFromContext({ mastra, agentId, requestContext });
729
- if (gwAgent && await chunkR474QJUF_cjs.isGatewayAgentAsync(gwAgent) && chunkR474QJUF_cjs.getGatewayClient()) {
729
+ if (gwAgent && await chunkUZZDH3J2_cjs.isGatewayAgentAsync(gwAgent) && chunkUZZDH3J2_cjs.getGatewayClient()) {
730
730
  return { workingMemory: null, source: "thread", workingMemoryTemplate: null, threadExists: true };
731
731
  }
732
732
  const memory = await getMemoryFromContext({ mastra, agentId, requestContext, allowMissingAgent: true });
@@ -823,8 +823,8 @@ var CREATE_THREAD_ROUTE = chunkEGSCXVMR_cjs.createRoute({
823
823
  try {
824
824
  const effectiveResourceId = chunkZKMVCV4G_cjs.getEffectiveResourceId(requestContext, resourceId);
825
825
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
826
- if (agent && await chunkR474QJUF_cjs.isGatewayAgentAsync(agent)) {
827
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
826
+ if (agent && await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent)) {
827
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
828
828
  if (gwClient) {
829
829
  chunkZKMVCV4G_cjs.validateBody({ resourceId: effectiveResourceId });
830
830
  const result2 = await gwClient.createThread({
@@ -833,7 +833,7 @@ var CREATE_THREAD_ROUTE = chunkEGSCXVMR_cjs.createRoute({
833
833
  title,
834
834
  metadata
835
835
  });
836
- return chunkR474QJUF_cjs.toLocalThread(result2.thread);
836
+ return chunkUZZDH3J2_cjs.toLocalThread(result2.thread);
837
837
  }
838
838
  }
839
839
  const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
@@ -871,18 +871,18 @@ var UPDATE_THREAD_ROUTE = chunkEGSCXVMR_cjs.createRoute({
871
871
  const effectiveResourceId = chunkZKMVCV4G_cjs.getEffectiveResourceId(requestContext, resourceId);
872
872
  chunkZKMVCV4G_cjs.validateBody({ threadId: effectiveThreadId });
873
873
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
874
- if (agent && await chunkR474QJUF_cjs.isGatewayAgentAsync(agent)) {
875
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
874
+ if (agent && await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent)) {
875
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
876
876
  if (gwClient) {
877
877
  const existing = await gwClient.getThread(effectiveThreadId);
878
878
  if (existing) {
879
- await chunkZKMVCV4G_cjs.validateThreadOwnership(chunkR474QJUF_cjs.toLocalThread(existing.thread), effectiveResourceId);
879
+ await chunkZKMVCV4G_cjs.validateThreadOwnership(chunkUZZDH3J2_cjs.toLocalThread(existing.thread), effectiveResourceId);
880
880
  }
881
881
  const result2 = await gwClient.updateThread(effectiveThreadId, { title, metadata });
882
882
  if (!result2) {
883
883
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Thread not found" });
884
884
  }
885
- return chunkR474QJUF_cjs.toLocalThread(result2.thread);
885
+ return chunkUZZDH3J2_cjs.toLocalThread(result2.thread);
886
886
  }
887
887
  }
888
888
  const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
@@ -931,12 +931,12 @@ var DELETE_THREAD_ROUTE = chunkEGSCXVMR_cjs.createRoute({
931
931
  const effectiveResourceId = chunkZKMVCV4G_cjs.getEffectiveResourceId(requestContext, resourceId);
932
932
  chunkZKMVCV4G_cjs.validateBody({ threadId: effectiveThreadId });
933
933
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
934
- if (agent && await chunkR474QJUF_cjs.isGatewayAgentAsync(agent)) {
935
- const gwClient = chunkR474QJUF_cjs.getGatewayClient();
934
+ if (agent && await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent)) {
935
+ const gwClient = chunkUZZDH3J2_cjs.getGatewayClient();
936
936
  if (gwClient) {
937
937
  const existing = await gwClient.getThread(effectiveThreadId);
938
938
  if (existing) {
939
- await chunkZKMVCV4G_cjs.validateThreadOwnership(chunkR474QJUF_cjs.toLocalThread(existing.thread), effectiveResourceId);
939
+ await chunkZKMVCV4G_cjs.validateThreadOwnership(chunkUZZDH3J2_cjs.toLocalThread(existing.thread), effectiveResourceId);
940
940
  }
941
941
  const deleteResult = await gwClient.deleteThread(effectiveThreadId);
942
942
  if (!deleteResult.ok) {
@@ -1020,7 +1020,7 @@ var UPDATE_WORKING_MEMORY_ROUTE = chunkEGSCXVMR_cjs.createRoute({
1020
1020
  const effectiveResourceId = chunkZKMVCV4G_cjs.getEffectiveResourceId(requestContext, resourceId);
1021
1021
  chunkZKMVCV4G_cjs.validateBody({ threadId: effectiveThreadId, workingMemory });
1022
1022
  const gwAgent = await getAgentFromContext({ mastra, agentId, requestContext });
1023
- if (gwAgent && await chunkR474QJUF_cjs.isGatewayAgentAsync(gwAgent) && chunkR474QJUF_cjs.getGatewayClient()) {
1023
+ if (gwAgent && await chunkUZZDH3J2_cjs.isGatewayAgentAsync(gwAgent) && chunkUZZDH3J2_cjs.getGatewayClient()) {
1024
1024
  return { success: true };
1025
1025
  }
1026
1026
  const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
@@ -1129,7 +1129,7 @@ var SEARCH_MEMORY_ROUTE = chunkEGSCXVMR_cjs.createRoute({
1129
1129
  const effectiveThreadId = chunkZKMVCV4G_cjs.getEffectiveThreadId(requestContext, threadId);
1130
1130
  chunkZKMVCV4G_cjs.validateBody({ searchQuery, resourceId: effectiveResourceId });
1131
1131
  const agent = await getAgentFromContext({ mastra, agentId, requestContext });
1132
- if (agent && await chunkR474QJUF_cjs.isGatewayAgentAsync(agent) && chunkR474QJUF_cjs.getGatewayClient()) {
1132
+ if (agent && await chunkUZZDH3J2_cjs.isGatewayAgentAsync(agent) && chunkUZZDH3J2_cjs.getGatewayClient()) {
1133
1133
  return {
1134
1134
  results: [],
1135
1135
  count: 0,
@@ -1392,5 +1392,5 @@ exports.UPDATE_THREAD_ROUTE = UPDATE_THREAD_ROUTE;
1392
1392
  exports.UPDATE_WORKING_MEMORY_ROUTE = UPDATE_WORKING_MEMORY_ROUTE;
1393
1393
  exports.getTextContent = getTextContent;
1394
1394
  exports.memory_exports = memory_exports;
1395
- //# sourceMappingURL=chunk-3I73HGCQ.cjs.map
1396
- //# sourceMappingURL=chunk-3I73HGCQ.cjs.map
1395
+ //# sourceMappingURL=chunk-2HTJTFFI.cjs.map
1396
+ //# sourceMappingURL=chunk-2HTJTFFI.cjs.map