@mastra/cloudflare 0.11.6 → 0.11.7

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.cjs CHANGED
@@ -733,6 +733,41 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
733
733
  return [];
734
734
  }
735
735
  }
736
+ async getMessagesById({
737
+ messageIds,
738
+ format
739
+ }) {
740
+ if (messageIds.length === 0) return [];
741
+ try {
742
+ const messages = (await Promise.all(messageIds.map((id) => this.findMessageInAnyThread(id)))).filter(
743
+ (result) => !!result
744
+ );
745
+ const prepared = messages.map(({ _index, ...message }) => ({
746
+ ...message,
747
+ ...message.type !== `v2` && { type: message.type },
748
+ createdAt: storage.ensureDate(message.createdAt)
749
+ }));
750
+ const list = new agent.MessageList().add(prepared, "memory");
751
+ if (format === `v1`) return list.get.all.v1();
752
+ return list.get.all.v2();
753
+ } catch (error$1) {
754
+ const mastraError = new error.MastraError(
755
+ {
756
+ id: "CLOUDFLARE_STORAGE_GET_MESSAGES_BY_ID_FAILED",
757
+ domain: error.ErrorDomain.STORAGE,
758
+ category: error.ErrorCategory.THIRD_PARTY,
759
+ text: `Error retrieving messages by ID`,
760
+ details: {
761
+ messageIds: JSON.stringify(messageIds)
762
+ }
763
+ },
764
+ error$1
765
+ );
766
+ this.logger?.trackException(mastraError);
767
+ this.logger?.error(mastraError.toString());
768
+ return [];
769
+ }
770
+ }
736
771
  async getMessagesPaginated(args) {
737
772
  try {
738
773
  const { threadId, selectBy, format = "v1" } = args;
@@ -2251,6 +2286,12 @@ var CloudflareStore = class extends storage.MastraStorage {
2251
2286
  }) {
2252
2287
  return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format });
2253
2288
  }
2289
+ async getMessagesById({
2290
+ messageIds,
2291
+ format
2292
+ }) {
2293
+ return this.stores.memory.getMessagesById({ messageIds, format });
2294
+ }
2254
2295
  async persistWorkflowSnapshot(params) {
2255
2296
  return this.stores.workflows.persistWorkflowSnapshot(params);
2256
2297
  }