@mastra/cloudflare 1.0.0-beta.0 → 1.0.0-beta.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 +19 -0
- package/dist/index.cjs +98 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +98 -116
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +5 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/test-utils.d.ts.map +1 -1
- package/package.json +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @mastra/cloudflare
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix message sorting in listMessages when using semantic recall (include parameter). Messages are now always sorted by createdAt instead of storage order, ensuring correct chronological ordering of conversation history. ([#10491](https://github.com/mastra-ai/mastra/pull/10491))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`21a15de`](https://github.com/mastra-ai/mastra/commit/21a15de369fe82aac26bb642ed7be73505475e8b), [`feb7ee4`](https://github.com/mastra-ai/mastra/commit/feb7ee4d09a75edb46c6669a3beaceec78811747), [`b0e2ea5`](https://github.com/mastra-ai/mastra/commit/b0e2ea5b52c40fae438b9e2f7baee6f0f89c5442), [`c456e01`](https://github.com/mastra-ai/mastra/commit/c456e0149e3c176afcefdbd9bb1d2c5917723725), [`ab035c2`](https://github.com/mastra-ai/mastra/commit/ab035c2ef6d8cc7bb25f06f1a38508bd9e6f126b), [`1a46a56`](https://github.com/mastra-ai/mastra/commit/1a46a566f45a3fcbadc1cf36bf86d351f264bfa3), [`3cf540b`](https://github.com/mastra-ai/mastra/commit/3cf540b9fbfea8f4fc8d3a2319a4e6c0b0cbfd52), [`1c6ce51`](https://github.com/mastra-ai/mastra/commit/1c6ce51f875915ab57fd36873623013699a2a65d), [`898a972`](https://github.com/mastra-ai/mastra/commit/898a9727d286c2510d6b702dfd367e6aaf5c6b0f), [`a97003a`](https://github.com/mastra-ai/mastra/commit/a97003aa1cf2f4022a41912324a1e77263b326b8), [`ccc141e`](https://github.com/mastra-ai/mastra/commit/ccc141ed27da0abc3a3fc28e9e5128152e8e37f4), [`fe3b897`](https://github.com/mastra-ai/mastra/commit/fe3b897c2ccbcd2b10e81b099438c7337feddf89), [`00123ba`](https://github.com/mastra-ai/mastra/commit/00123ba96dc9e5cd0b110420ebdba56d8f237b25), [`29c4309`](https://github.com/mastra-ai/mastra/commit/29c4309f818b24304c041bcb4a8f19b5f13f6b62), [`16785ce`](https://github.com/mastra-ai/mastra/commit/16785ced928f6f22638f4488cf8a125d99211799), [`de8239b`](https://github.com/mastra-ai/mastra/commit/de8239bdcb1d8c0cfa06da21f1569912a66bbc8a), [`b5e6cd7`](https://github.com/mastra-ai/mastra/commit/b5e6cd77fc8c8e64e0494c1d06cee3d84e795d1e), [`3759cb0`](https://github.com/mastra-ai/mastra/commit/3759cb064935b5f74c65ac2f52a1145f7352899d), [`651e772`](https://github.com/mastra-ai/mastra/commit/651e772eb1475fb13e126d3fcc01751297a88214), [`b61b93f`](https://github.com/mastra-ai/mastra/commit/b61b93f9e058b11dd2eec169853175d31dbdd567), [`bae33d9`](https://github.com/mastra-ai/mastra/commit/bae33d91a63fbb64d1e80519e1fc1acaed1e9013), [`c0b731f`](https://github.com/mastra-ai/mastra/commit/c0b731fb27d712dc8582e846df5c0332a6a0c5ba), [`43ca8f2`](https://github.com/mastra-ai/mastra/commit/43ca8f2c7334851cc7b4d3d2f037d8784bfbdd5f), [`2ca67cc`](https://github.com/mastra-ai/mastra/commit/2ca67cc3bb1f6a617353fdcab197d9efebe60d6f), [`9e67002`](https://github.com/mastra-ai/mastra/commit/9e67002b52c9be19936c420a489dbee9c5fd6a78), [`35edc49`](https://github.com/mastra-ai/mastra/commit/35edc49ac0556db609189641d6341e76771b81fc)]:
|
|
10
|
+
- @mastra/core@1.0.0-beta.5
|
|
11
|
+
|
|
12
|
+
## 1.0.0-beta.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Add restart method to workflow run that allows restarting an active workflow run ([#9750](https://github.com/mastra-ai/mastra/pull/9750))
|
|
17
|
+
Add status filter to `listWorkflowRuns`
|
|
18
|
+
Add automatic restart to restart active workflow runs when server starts
|
|
19
|
+
- Updated dependencies [[`2319326`](https://github.com/mastra-ai/mastra/commit/2319326f8c64e503a09bbcf14be2dd65405445e0), [`d629361`](https://github.com/mastra-ai/mastra/commit/d629361a60f6565b5bfb11976fdaf7308af858e2), [`08c31c1`](https://github.com/mastra-ai/mastra/commit/08c31c188ebccd598acaf55e888b6397d01f7eae), [`fd3d338`](https://github.com/mastra-ai/mastra/commit/fd3d338a2c362174ed5b383f1f011ad9fb0302aa), [`c30400a`](https://github.com/mastra-ai/mastra/commit/c30400a49b994b1b97256fe785eb6c906fc2b232), [`69e0a87`](https://github.com/mastra-ai/mastra/commit/69e0a878896a2da9494945d86e056a5f8f05b851), [`01f8878`](https://github.com/mastra-ai/mastra/commit/01f88783de25e4de048c1c8aace43e26373c6ea5), [`4c77209`](https://github.com/mastra-ai/mastra/commit/4c77209e6c11678808b365d545845918c40045c8), [`d827d08`](https://github.com/mastra-ai/mastra/commit/d827d0808ffe1f3553a84e975806cc989b9735dd), [`23c10a1`](https://github.com/mastra-ai/mastra/commit/23c10a1efdd9a693c405511ab2dc8a1236603162), [`676ccc7`](https://github.com/mastra-ai/mastra/commit/676ccc7fe92468d2d45d39c31a87825c89fd1ea0), [`c10398d`](https://github.com/mastra-ai/mastra/commit/c10398d5b88f1d4af556f4267ff06f1d11e89179), [`00c2387`](https://github.com/mastra-ai/mastra/commit/00c2387f5f04a365316f851e58666ac43f8c4edf), [`ad6250d`](https://github.com/mastra-ai/mastra/commit/ad6250dbdaad927e29f74a27b83f6c468b50a705), [`3a73998`](https://github.com/mastra-ai/mastra/commit/3a73998fa4ebeb7f3dc9301afe78095fc63e7999), [`e16d553`](https://github.com/mastra-ai/mastra/commit/e16d55338403c7553531cc568125c63d53653dff), [`4d59f58`](https://github.com/mastra-ai/mastra/commit/4d59f58de2d90d6e2810a19d4518e38ddddb9038), [`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365), [`351a11f`](https://github.com/mastra-ai/mastra/commit/351a11fcaf2ed1008977fa9b9a489fc422e51cd4)]:
|
|
20
|
+
- @mastra/core@1.0.0-beta.3
|
|
21
|
+
|
|
3
22
|
## 1.0.0-beta.0
|
|
4
23
|
|
|
5
24
|
### Major Changes
|
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,17 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
21
21
|
if (!metadata) return void 0;
|
|
22
22
|
return typeof metadata === "string" ? JSON.parse(metadata) : metadata;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Summarizes message content without exposing raw data (for logging).
|
|
26
|
+
* Returns type, length, and keys only to prevent PII leakage.
|
|
27
|
+
*/
|
|
28
|
+
summarizeMessageContent(content) {
|
|
29
|
+
if (!content) return { type: "undefined" };
|
|
30
|
+
if (typeof content === "string") return { type: "string", length: content.length };
|
|
31
|
+
if (Array.isArray(content)) return { type: "array", length: content.length };
|
|
32
|
+
if (typeof content === "object") return { type: "object", keys: Object.keys(content) };
|
|
33
|
+
return { type: typeof content };
|
|
34
|
+
}
|
|
24
35
|
async getThreadById({ threadId }) {
|
|
25
36
|
const thread = await this.operations.load({ tableName: storage.TABLE_THREADS, keys: { id: threadId } });
|
|
26
37
|
if (!thread) return null;
|
|
@@ -159,7 +170,7 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
159
170
|
return this.operations.getKey(storage.TABLE_MESSAGES, { threadId, id: messageId });
|
|
160
171
|
} catch (error) {
|
|
161
172
|
const message = error instanceof Error ? error.message : String(error);
|
|
162
|
-
this.logger
|
|
173
|
+
this.logger?.error(`Error getting message key for thread ${threadId} and message ${messageId}:`, { message });
|
|
163
174
|
throw error;
|
|
164
175
|
}
|
|
165
176
|
}
|
|
@@ -168,7 +179,7 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
168
179
|
return this.operations.getKey(storage.TABLE_MESSAGES, { threadId, id: "messages" });
|
|
169
180
|
} catch (error) {
|
|
170
181
|
const message = error instanceof Error ? error.message : String(error);
|
|
171
|
-
this.logger
|
|
182
|
+
this.logger?.error(`Error getting thread messages key for thread ${threadId}:`, { message });
|
|
172
183
|
throw error;
|
|
173
184
|
}
|
|
174
185
|
}
|
|
@@ -258,7 +269,7 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
258
269
|
});
|
|
259
270
|
} catch (error) {
|
|
260
271
|
const message = error instanceof Error ? error.message : String(error);
|
|
261
|
-
this.logger
|
|
272
|
+
this.logger?.error(`Error updating sorted order for key ${orderKey}:`, { message });
|
|
262
273
|
throw error;
|
|
263
274
|
} finally {
|
|
264
275
|
if (this.updateQueue.get(orderKey) === nextPromise) {
|
|
@@ -276,7 +287,7 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
276
287
|
const arr = JSON.parse(typeof raw === "string" ? raw : JSON.stringify(raw));
|
|
277
288
|
return Array.isArray(arr) ? arr : [];
|
|
278
289
|
} catch (e) {
|
|
279
|
-
this.logger
|
|
290
|
+
this.logger?.error(`Error parsing order data for key ${orderKey}:`, { e });
|
|
280
291
|
return [];
|
|
281
292
|
}
|
|
282
293
|
}
|
|
@@ -331,9 +342,11 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
331
342
|
const messageMigrationTasks = [];
|
|
332
343
|
for (const message of validatedMessages) {
|
|
333
344
|
const existingMessage = await this.findMessageInAnyThread(message.id);
|
|
334
|
-
|
|
345
|
+
this.logger?.debug(
|
|
346
|
+
`Checking message ${message.id}: existing=${existingMessage?.threadId}, new=${message.threadId}`
|
|
347
|
+
);
|
|
335
348
|
if (existingMessage && existingMessage.threadId && existingMessage.threadId !== message.threadId) {
|
|
336
|
-
|
|
349
|
+
this.logger?.debug(`Migrating message ${message.id} from ${existingMessage.threadId} to ${message.threadId}`);
|
|
337
350
|
messageMigrationTasks.push(this.migrateMessage(message.id, existingMessage.threadId, message.threadId));
|
|
338
351
|
}
|
|
339
352
|
}
|
|
@@ -362,10 +375,8 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
362
375
|
...cleanMessage,
|
|
363
376
|
createdAt: storage.serializeDate(cleanMessage.createdAt)
|
|
364
377
|
};
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
contentType: typeof serializedMessage.content,
|
|
368
|
-
isArray: Array.isArray(serializedMessage.content)
|
|
378
|
+
this.logger?.debug(`Saving message ${message.id}`, {
|
|
379
|
+
contentSummary: this.summarizeMessageContent(serializedMessage.content)
|
|
369
380
|
});
|
|
370
381
|
await this.operations.putKV({ tableName: storage.TABLE_MESSAGES, key, value: serializedMessage });
|
|
371
382
|
})
|
|
@@ -464,7 +475,7 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
464
475
|
const latestIds = await this.getLastN(threadMessagesKey, limit);
|
|
465
476
|
latestIds.forEach((id) => messageIds.add(id));
|
|
466
477
|
} catch {
|
|
467
|
-
|
|
478
|
+
this.logger?.debug(`No message order found for thread ${threadId}, skipping latest messages`);
|
|
468
479
|
}
|
|
469
480
|
}
|
|
470
481
|
async fetchAndParseMessagesFromMultipleThreads(messageIds, include, targetThreadId) {
|
|
@@ -495,15 +506,13 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
495
506
|
const data = await this.operations.getKV(storage.TABLE_MESSAGES, key);
|
|
496
507
|
if (!data) return null;
|
|
497
508
|
const parsed = typeof data === "string" ? JSON.parse(data) : data;
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
contentType: typeof parsed.content,
|
|
501
|
-
isArray: Array.isArray(parsed.content)
|
|
509
|
+
this.logger?.debug(`Retrieved message ${id} from thread ${threadId}`, {
|
|
510
|
+
contentSummary: this.summarizeMessageContent(parsed.content)
|
|
502
511
|
});
|
|
503
512
|
return parsed;
|
|
504
513
|
} catch (error) {
|
|
505
514
|
const message = error instanceof Error ? error.message : String(error);
|
|
506
|
-
this.logger
|
|
515
|
+
this.logger?.error(`Error retrieving message ${id}:`, { message });
|
|
507
516
|
return null;
|
|
508
517
|
}
|
|
509
518
|
})
|
|
@@ -569,69 +578,32 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
569
578
|
);
|
|
570
579
|
}
|
|
571
580
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
allIds.forEach((id) => messageIds.add(id));
|
|
579
|
-
} catch {
|
|
580
|
-
}
|
|
581
|
-
} else {
|
|
582
|
-
if (perPage > 0) {
|
|
583
|
-
try {
|
|
584
|
-
const threadMessagesKey = this.getThreadMessagesKey(threadId);
|
|
585
|
-
const fullOrder = await this.getFullOrder(threadMessagesKey);
|
|
586
|
-
const totalMessages = fullOrder.length;
|
|
587
|
-
let start;
|
|
588
|
-
let end;
|
|
589
|
-
if (direction === "ASC") {
|
|
590
|
-
start = offset;
|
|
591
|
-
end = Math.min(offset + perPage - 1, totalMessages - 1);
|
|
592
|
-
} else {
|
|
593
|
-
start = Math.max(totalMessages - offset - perPage, 0);
|
|
594
|
-
end = totalMessages - offset - 1;
|
|
595
|
-
}
|
|
596
|
-
const paginatedIds = await this.getRange(threadMessagesKey, start, end);
|
|
597
|
-
paginatedIds.forEach((id) => messageIds.add(id));
|
|
598
|
-
} catch {
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
if (include && include.length > 0) {
|
|
603
|
-
await this.getIncludedMessagesWithContext(threadId, include, messageIds);
|
|
581
|
+
const threadMessageIds = /* @__PURE__ */ new Set();
|
|
582
|
+
try {
|
|
583
|
+
const threadMessagesKey = this.getThreadMessagesKey(threadId);
|
|
584
|
+
const allIds = await this.getFullOrder(threadMessagesKey);
|
|
585
|
+
allIds.forEach((id) => threadMessageIds.add(id));
|
|
586
|
+
} catch {
|
|
604
587
|
}
|
|
605
|
-
const
|
|
606
|
-
Array.from(
|
|
607
|
-
|
|
608
|
-
|
|
588
|
+
const threadMessages = await this.fetchAndParseMessagesFromMultipleThreads(
|
|
589
|
+
Array.from(threadMessageIds),
|
|
590
|
+
void 0,
|
|
591
|
+
threadId
|
|
609
592
|
);
|
|
610
|
-
let
|
|
593
|
+
let filteredThreadMessages = threadMessages;
|
|
611
594
|
if (resourceId) {
|
|
612
|
-
|
|
595
|
+
filteredThreadMessages = filteredThreadMessages.filter((msg) => msg.resourceId === resourceId);
|
|
613
596
|
}
|
|
614
597
|
const dateRange = filter?.dateRange;
|
|
615
598
|
if (dateRange) {
|
|
616
|
-
|
|
599
|
+
filteredThreadMessages = filteredThreadMessages.filter((msg) => {
|
|
617
600
|
const messageDate = new Date(msg.createdAt);
|
|
618
601
|
if (dateRange.start && messageDate < new Date(dateRange.start)) return false;
|
|
619
602
|
if (dateRange.end && messageDate > new Date(dateRange.end)) return false;
|
|
620
603
|
return true;
|
|
621
604
|
});
|
|
622
605
|
}
|
|
623
|
-
|
|
624
|
-
if (hasFilters) {
|
|
625
|
-
total = filteredMessages.length;
|
|
626
|
-
} else {
|
|
627
|
-
try {
|
|
628
|
-
const threadMessagesKey = this.getThreadMessagesKey(threadId);
|
|
629
|
-
const fullOrder = await this.getFullOrder(threadMessagesKey);
|
|
630
|
-
total = fullOrder.length;
|
|
631
|
-
} catch {
|
|
632
|
-
total = filteredMessages.length;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
606
|
+
const total = filteredThreadMessages.length;
|
|
635
607
|
if (perPage === 0 && (!include || include.length === 0)) {
|
|
636
608
|
return {
|
|
637
609
|
messages: [],
|
|
@@ -641,45 +613,58 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
641
613
|
hasMore: offset < total
|
|
642
614
|
};
|
|
643
615
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
filteredMessages = filteredMessages.slice(start, end);
|
|
616
|
+
filteredThreadMessages.sort((a, b) => {
|
|
617
|
+
const timeA = new Date(a.createdAt).getTime();
|
|
618
|
+
const timeB = new Date(b.createdAt).getTime();
|
|
619
|
+
const timeDiff = direction === "ASC" ? timeA - timeB : timeB - timeA;
|
|
620
|
+
if (timeDiff === 0) {
|
|
621
|
+
return a.id.localeCompare(b.id);
|
|
651
622
|
}
|
|
623
|
+
return timeDiff;
|
|
624
|
+
});
|
|
625
|
+
let paginatedMessages;
|
|
626
|
+
if (perPage === 0) {
|
|
627
|
+
paginatedMessages = [];
|
|
628
|
+
} else if (perPage === Number.MAX_SAFE_INTEGER) {
|
|
629
|
+
paginatedMessages = filteredThreadMessages;
|
|
630
|
+
} else {
|
|
631
|
+
paginatedMessages = filteredThreadMessages.slice(offset, offset + perPage);
|
|
652
632
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
return timeDiff;
|
|
671
|
-
});
|
|
672
|
-
} catch {
|
|
673
|
-
filteredMessages.sort((a, b) => {
|
|
674
|
-
const timeA = new Date(a.createdAt).getTime();
|
|
675
|
-
const timeB = new Date(b.createdAt).getTime();
|
|
676
|
-
const timeDiff = direction === "ASC" ? timeA - timeB : timeB - timeA;
|
|
677
|
-
if (timeDiff === 0) {
|
|
678
|
-
return a.id.localeCompare(b.id);
|
|
679
|
-
}
|
|
680
|
-
return timeDiff;
|
|
681
|
-
});
|
|
633
|
+
let includedMessages = [];
|
|
634
|
+
if (include && include.length > 0) {
|
|
635
|
+
const includedMessageIds = /* @__PURE__ */ new Set();
|
|
636
|
+
await this.getIncludedMessagesWithContext(threadId, include, includedMessageIds);
|
|
637
|
+
const paginatedIds = new Set(paginatedMessages.map((m) => m.id));
|
|
638
|
+
const idsToFetch = Array.from(includedMessageIds).filter((id) => !paginatedIds.has(id));
|
|
639
|
+
if (idsToFetch.length > 0) {
|
|
640
|
+
includedMessages = await this.fetchAndParseMessagesFromMultipleThreads(idsToFetch, include, void 0);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
644
|
+
const allMessages = [];
|
|
645
|
+
for (const msg of paginatedMessages) {
|
|
646
|
+
if (!seenIds.has(msg.id)) {
|
|
647
|
+
allMessages.push(msg);
|
|
648
|
+
seenIds.add(msg.id);
|
|
649
|
+
}
|
|
682
650
|
}
|
|
651
|
+
for (const msg of includedMessages) {
|
|
652
|
+
if (!seenIds.has(msg.id)) {
|
|
653
|
+
allMessages.push(msg);
|
|
654
|
+
seenIds.add(msg.id);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
allMessages.sort((a, b) => {
|
|
658
|
+
const timeA = new Date(a.createdAt).getTime();
|
|
659
|
+
const timeB = new Date(b.createdAt).getTime();
|
|
660
|
+
const timeDiff = direction === "ASC" ? timeA - timeB : timeB - timeA;
|
|
661
|
+
if (timeDiff === 0) {
|
|
662
|
+
return a.id.localeCompare(b.id);
|
|
663
|
+
}
|
|
664
|
+
return timeDiff;
|
|
665
|
+
});
|
|
666
|
+
let filteredMessages = allMessages;
|
|
667
|
+
const paginatedCount = paginatedMessages.length;
|
|
683
668
|
if (total === 0 && filteredMessages.length === 0 && (!include || include.length === 0)) {
|
|
684
669
|
return {
|
|
685
670
|
messages: [],
|
|
@@ -712,14 +697,7 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
712
697
|
});
|
|
713
698
|
const returnedThreadMessageIds = new Set(finalMessages.filter((m) => m.threadId === threadId).map((m) => m.id));
|
|
714
699
|
const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
|
|
715
|
-
|
|
716
|
-
if (perPageInput === false || allThreadMessagesReturned) {
|
|
717
|
-
hasMore = false;
|
|
718
|
-
} else if (direction === "ASC") {
|
|
719
|
-
hasMore = offset + paginatedCount < total;
|
|
720
|
-
} else {
|
|
721
|
-
hasMore = total - offset - perPage > 0;
|
|
722
|
-
}
|
|
700
|
+
const hasMore = perPageInput !== false && !allThreadMessagesReturned && offset + paginatedCount < total;
|
|
723
701
|
return {
|
|
724
702
|
messages: finalMessages,
|
|
725
703
|
total,
|
|
@@ -1826,7 +1804,7 @@ var WorkflowsStorageCloudflare = class extends storage.WorkflowsStorage {
|
|
|
1826
1804
|
workflow_name: workflowName,
|
|
1827
1805
|
run_id: runId,
|
|
1828
1806
|
resourceId,
|
|
1829
|
-
snapshot:
|
|
1807
|
+
snapshot: JSON.stringify(snapshot),
|
|
1830
1808
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1831
1809
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1832
1810
|
}
|
|
@@ -1911,7 +1889,8 @@ var WorkflowsStorageCloudflare = class extends storage.WorkflowsStorage {
|
|
|
1911
1889
|
perPage = 20,
|
|
1912
1890
|
resourceId,
|
|
1913
1891
|
fromDate,
|
|
1914
|
-
toDate
|
|
1892
|
+
toDate,
|
|
1893
|
+
status
|
|
1915
1894
|
} = {}) {
|
|
1916
1895
|
try {
|
|
1917
1896
|
if (page < 0 || !Number.isInteger(page)) {
|
|
@@ -1942,10 +1921,11 @@ var WorkflowsStorageCloudflare = class extends storage.WorkflowsStorage {
|
|
|
1942
1921
|
if (!data) continue;
|
|
1943
1922
|
try {
|
|
1944
1923
|
if (resourceId && !keyResourceId) continue;
|
|
1924
|
+
const snapshotData = typeof data.snapshot === "string" ? JSON.parse(data.snapshot) : data.snapshot;
|
|
1925
|
+
if (status && snapshotData.status !== status) continue;
|
|
1945
1926
|
const createdAt = storage.ensureDate(data.createdAt);
|
|
1946
1927
|
if (fromDate && createdAt && createdAt < fromDate) continue;
|
|
1947
1928
|
if (toDate && createdAt && createdAt > toDate) continue;
|
|
1948
|
-
const snapshotData = typeof data.snapshot === "string" ? JSON.parse(data.snapshot) : data.snapshot;
|
|
1949
1929
|
const resourceIdToUse = keyResourceId || data.resourceId;
|
|
1950
1930
|
const run = this.parseWorkflowRun({
|
|
1951
1931
|
...data,
|
|
@@ -2196,7 +2176,8 @@ var CloudflareStore = class extends storage.MastraStorage {
|
|
|
2196
2176
|
page = 0,
|
|
2197
2177
|
resourceId,
|
|
2198
2178
|
fromDate,
|
|
2199
|
-
toDate
|
|
2179
|
+
toDate,
|
|
2180
|
+
status
|
|
2200
2181
|
} = {}) {
|
|
2201
2182
|
return this.stores.workflows.listWorkflowRuns({
|
|
2202
2183
|
workflowName,
|
|
@@ -2204,7 +2185,8 @@ var CloudflareStore = class extends storage.MastraStorage {
|
|
|
2204
2185
|
page,
|
|
2205
2186
|
resourceId,
|
|
2206
2187
|
fromDate,
|
|
2207
|
-
toDate
|
|
2188
|
+
toDate,
|
|
2189
|
+
status
|
|
2208
2190
|
});
|
|
2209
2191
|
}
|
|
2210
2192
|
async getWorkflowRunById({
|