@mastra/cloudflare 1.0.0-beta.0 → 1.0.0-beta.1
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 +10 -0
- package/dist/index.cjs +34 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -21
- 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,15 @@
|
|
|
1
1
|
# @mastra/cloudflare
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add restart method to workflow run that allows restarting an active workflow run ([#9750](https://github.com/mastra-ai/mastra/pull/9750))
|
|
8
|
+
Add status filter to `listWorkflowRuns`
|
|
9
|
+
Add automatic restart to restart active workflow runs when server starts
|
|
10
|
+
- 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)]:
|
|
11
|
+
- @mastra/core@1.0.0-beta.3
|
|
12
|
+
|
|
3
13
|
## 1.0.0-beta.0
|
|
4
14
|
|
|
5
15
|
### 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
|
})
|
|
@@ -1826,7 +1835,7 @@ var WorkflowsStorageCloudflare = class extends storage.WorkflowsStorage {
|
|
|
1826
1835
|
workflow_name: workflowName,
|
|
1827
1836
|
run_id: runId,
|
|
1828
1837
|
resourceId,
|
|
1829
|
-
snapshot:
|
|
1838
|
+
snapshot: JSON.stringify(snapshot),
|
|
1830
1839
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1831
1840
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1832
1841
|
}
|
|
@@ -1911,7 +1920,8 @@ var WorkflowsStorageCloudflare = class extends storage.WorkflowsStorage {
|
|
|
1911
1920
|
perPage = 20,
|
|
1912
1921
|
resourceId,
|
|
1913
1922
|
fromDate,
|
|
1914
|
-
toDate
|
|
1923
|
+
toDate,
|
|
1924
|
+
status
|
|
1915
1925
|
} = {}) {
|
|
1916
1926
|
try {
|
|
1917
1927
|
if (page < 0 || !Number.isInteger(page)) {
|
|
@@ -1942,10 +1952,11 @@ var WorkflowsStorageCloudflare = class extends storage.WorkflowsStorage {
|
|
|
1942
1952
|
if (!data) continue;
|
|
1943
1953
|
try {
|
|
1944
1954
|
if (resourceId && !keyResourceId) continue;
|
|
1955
|
+
const snapshotData = typeof data.snapshot === "string" ? JSON.parse(data.snapshot) : data.snapshot;
|
|
1956
|
+
if (status && snapshotData.status !== status) continue;
|
|
1945
1957
|
const createdAt = storage.ensureDate(data.createdAt);
|
|
1946
1958
|
if (fromDate && createdAt && createdAt < fromDate) continue;
|
|
1947
1959
|
if (toDate && createdAt && createdAt > toDate) continue;
|
|
1948
|
-
const snapshotData = typeof data.snapshot === "string" ? JSON.parse(data.snapshot) : data.snapshot;
|
|
1949
1960
|
const resourceIdToUse = keyResourceId || data.resourceId;
|
|
1950
1961
|
const run = this.parseWorkflowRun({
|
|
1951
1962
|
...data,
|
|
@@ -2196,7 +2207,8 @@ var CloudflareStore = class extends storage.MastraStorage {
|
|
|
2196
2207
|
page = 0,
|
|
2197
2208
|
resourceId,
|
|
2198
2209
|
fromDate,
|
|
2199
|
-
toDate
|
|
2210
|
+
toDate,
|
|
2211
|
+
status
|
|
2200
2212
|
} = {}) {
|
|
2201
2213
|
return this.stores.workflows.listWorkflowRuns({
|
|
2202
2214
|
workflowName,
|
|
@@ -2204,7 +2216,8 @@ var CloudflareStore = class extends storage.MastraStorage {
|
|
|
2204
2216
|
page,
|
|
2205
2217
|
resourceId,
|
|
2206
2218
|
fromDate,
|
|
2207
|
-
toDate
|
|
2219
|
+
toDate,
|
|
2220
|
+
status
|
|
2208
2221
|
});
|
|
2209
2222
|
}
|
|
2210
2223
|
async getWorkflowRunById({
|