@mastra/cloudflare 0.0.0-error-handler-fix-20251020202607 → 0.0.0-execa-dynamic-import-20260304221256
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 +1812 -3
- package/LICENSE.md +15 -0
- package/README.md +38 -16
- package/dist/docs/SKILL.md +22 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/reference-storage-cloudflare.md +88 -0
- package/dist/index.cjs +1499 -1762
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1468 -1734
- package/dist/index.js.map +1 -1
- package/dist/storage/{domains/operations → db}/index.d.ts +22 -26
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +60 -41
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +16 -28
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +18 -24
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +27 -217
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/test-utils.d.ts.map +1 -1
- package/dist/storage/types.d.ts +94 -8
- package/dist/storage/types.d.ts.map +1 -1
- package/package.json +19 -15
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -21
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
- package/dist/storage/domains/traces/index.d.ts +0 -18
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
package/LICENSE.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
1
16
|
# Apache License 2.0
|
|
2
17
|
|
|
3
18
|
Copyright (c) 2025 Kepler Software, Inc.
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install @mastra/cloudflare
|
|
|
11
11
|
## Prerequisites
|
|
12
12
|
|
|
13
13
|
- Cloudflare account with KV namespaces set up
|
|
14
|
-
- Node.js
|
|
14
|
+
- Node.js 22.13.0 or later
|
|
15
15
|
- (Optional) Cloudflare Worker for Workers API mode
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
@@ -25,7 +25,6 @@ const store = new CloudflareStore({
|
|
|
25
25
|
threads: THREADS_KV_NAMESPACE,
|
|
26
26
|
messages: MESSAGES_KV_NAMESPACE,
|
|
27
27
|
workflow_snapshot: WORKFLOW_KV_NAMESPACE,
|
|
28
|
-
evals: EVALS_KV_NAMESPACE,
|
|
29
28
|
traces: TRACES_KV_NAMESPACE,
|
|
30
29
|
},
|
|
31
30
|
keyPrefix: 'myapp_', // Optional
|
|
@@ -40,12 +39,13 @@ const store = new CloudflareStore({
|
|
|
40
39
|
|
|
41
40
|
// Save a thread
|
|
42
41
|
await store.saveThread({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
thread: {
|
|
43
|
+
id: 'thread-123',
|
|
44
|
+
resourceId: 'resource-456',
|
|
45
|
+
title: 'My Thread',
|
|
46
|
+
metadata: { key: 'value' },
|
|
47
|
+
createdAt: new Date(),
|
|
48
|
+
},
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
// Add messages
|
|
@@ -62,7 +62,7 @@ await store.saveMessages({
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
// Query messages
|
|
65
|
-
const messages = await store.
|
|
65
|
+
const messages = await store.listMessages({ threadId: 'thread-123' });
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
## Configuration
|
|
@@ -95,25 +95,47 @@ const messages = await store.getMessages({ threadId: 'thread-123' });
|
|
|
95
95
|
|
|
96
96
|
### Thread Operations
|
|
97
97
|
|
|
98
|
-
- `saveThread(thread)`: Create or update a thread
|
|
98
|
+
- `saveThread({ thread })`: Create or update a thread
|
|
99
99
|
- `getThreadById({ threadId })`: Get a thread by ID
|
|
100
|
-
- `
|
|
100
|
+
- `listThreadsByResourceId({ resourceId, offset, limit, orderBy? })`: List paginated threads for a resource
|
|
101
101
|
- `updateThread({ id, title, metadata })`: Update thread title and metadata
|
|
102
102
|
- `deleteThread({ threadId })`: Delete a thread and its messages
|
|
103
103
|
|
|
104
104
|
### Message Operations
|
|
105
105
|
|
|
106
106
|
- `saveMessages({ messages })`: Save multiple messages
|
|
107
|
-
- `
|
|
107
|
+
- `listMessages({ threadId, perPage?, page? })`: Get messages for a thread with pagination
|
|
108
|
+
- `listMessagesById({ messageIds })`: Get specific messages by their IDs
|
|
109
|
+
- `updateMessages({ messages })`: Update existing messages
|
|
110
|
+
|
|
111
|
+
### Resource Operations
|
|
112
|
+
|
|
113
|
+
- `getResourceById({ resourceId })`: Get a resource by ID
|
|
114
|
+
- `saveResource({ resource })`: Create or save a resource
|
|
115
|
+
- `updateResource({ resourceId, workingMemory })`: Update resource working memory
|
|
108
116
|
|
|
109
117
|
### Workflow Operations
|
|
110
118
|
|
|
111
|
-
- `persistWorkflowSnapshot({ workflowName, runId, snapshot })`: Save workflow state
|
|
112
|
-
- `loadWorkflowSnapshot({ workflowName, runId })`: Load
|
|
119
|
+
- `persistWorkflowSnapshot({ workflowName, runId, snapshot })`: Save workflow state
|
|
120
|
+
- `loadWorkflowSnapshot({ workflowName, runId })`: Load workflow state
|
|
121
|
+
- `listWorkflowRuns({ workflowName, pagination })`: List workflow runs with pagination
|
|
122
|
+
- `getWorkflowRunById({ workflowName, runId })`: Get a specific workflow run
|
|
123
|
+
- `updateWorkflowState({ workflowName, runId, state })`: Update workflow state
|
|
124
|
+
- `updateWorkflowResults({ workflowName, runId, results })`: Update workflow results
|
|
125
|
+
|
|
126
|
+
### Evaluation/Scoring Operations
|
|
127
|
+
|
|
128
|
+
- `getScoreById({ id })`: Get a score by ID
|
|
129
|
+
- `saveScore(score)`: Save an evaluation score
|
|
130
|
+
- `listScoresByScorerId({ scorerId, pagination })`: List scores by scorer with pagination
|
|
131
|
+
- `listScoresByRunId({ runId, pagination })`: List scores by run with pagination
|
|
132
|
+
- `listScoresByEntityId({ entityId, entityType, pagination })`: List scores by entity with pagination
|
|
133
|
+
- `listScoresBySpan({ traceId, spanId, pagination })`: List scores by span with pagination
|
|
113
134
|
|
|
114
|
-
###
|
|
135
|
+
### Operations Not Currently Supported
|
|
115
136
|
|
|
116
|
-
- `
|
|
137
|
+
- `deleteMessages(messageIds)`: Message deletion is not currently supported
|
|
138
|
+
- AI Observability (traces/spans): Not currently supported
|
|
117
139
|
|
|
118
140
|
### Utility
|
|
119
141
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mastra-cloudflare
|
|
3
|
+
description: Documentation for @mastra/cloudflare. Use when working with @mastra/cloudflare APIs, configuration, or implementation.
|
|
4
|
+
metadata:
|
|
5
|
+
package: "@mastra/cloudflare"
|
|
6
|
+
version: "0.0.0-execa-dynamic-import-20260304221256"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
|
|
11
|
+
Use this skill whenever you are working with @mastra/cloudflare 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
|
+
### Reference
|
|
18
|
+
|
|
19
|
+
- [Reference: Cloudflare Storage](references/reference-storage-cloudflare.md) - Documentation for the Cloudflare KV storage implementation in Mastra.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Cloudflare Storage
|
|
2
|
+
|
|
3
|
+
The Cloudflare KV storage implementation provides a globally distributed, serverless key-value store solution using Cloudflare Workers KV.
|
|
4
|
+
|
|
5
|
+
> **Observability Not Supported:** Cloudflare KV storage **does not support the observability domain**. Traces from the `DefaultExporter` cannot be persisted to KV, and Mastra Studio's observability features won't work with Cloudflare KV as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse or PostgreSQL.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @mastra/cloudflare@latest
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/cloudflare@latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/cloudflare@latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/cloudflare@latest
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { CloudflareStore } from '@mastra/cloudflare'
|
|
37
|
+
|
|
38
|
+
// --- Example 1: Using Workers Binding ---
|
|
39
|
+
const storageWorkers = new CloudflareStore({
|
|
40
|
+
id: 'cloudflare-workers-storage',
|
|
41
|
+
bindings: {
|
|
42
|
+
threads: THREADS_KV, // KVNamespace binding for threads table
|
|
43
|
+
messages: MESSAGES_KV, // KVNamespace binding for messages table
|
|
44
|
+
// Add other tables as needed
|
|
45
|
+
},
|
|
46
|
+
keyPrefix: 'dev_', // Optional: isolate keys per environment
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// --- Example 2: Using REST API ---
|
|
50
|
+
const storageRest = new CloudflareStore({
|
|
51
|
+
id: 'cloudflare-rest-storage',
|
|
52
|
+
accountId: process.env.CLOUDFLARE_ACCOUNT_ID!, // Cloudflare Account ID
|
|
53
|
+
apiToken: process.env.CLOUDFLARE_API_TOKEN!, // Cloudflare API Token
|
|
54
|
+
namespacePrefix: 'dev_', // Optional: isolate namespaces per environment
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Parameters
|
|
59
|
+
|
|
60
|
+
**id:** (`string`): Unique identifier for this storage instance.
|
|
61
|
+
|
|
62
|
+
**bindings?:** (`Record<string, KVNamespace>`): Cloudflare Workers KV bindings (for Workers runtime)
|
|
63
|
+
|
|
64
|
+
**accountId?:** (`string`): Cloudflare Account ID (for REST API)
|
|
65
|
+
|
|
66
|
+
**apiToken?:** (`string`): Cloudflare API Token (for REST API)
|
|
67
|
+
|
|
68
|
+
**namespacePrefix?:** (`string`): Optional prefix for all namespace names (useful for environment isolation)
|
|
69
|
+
|
|
70
|
+
**keyPrefix?:** (`string`): Optional prefix for all keys (useful for environment isolation)
|
|
71
|
+
|
|
72
|
+
### Additional Notes
|
|
73
|
+
|
|
74
|
+
### Schema Management
|
|
75
|
+
|
|
76
|
+
The storage implementation handles schema creation and updates automatically. It creates the following tables:
|
|
77
|
+
|
|
78
|
+
- `threads`: Stores conversation threads
|
|
79
|
+
- `messages`: Stores individual messages
|
|
80
|
+
- `metadata`: Stores additional metadata for threads and messages
|
|
81
|
+
|
|
82
|
+
### Consistency & Propagation
|
|
83
|
+
|
|
84
|
+
Cloudflare KV is an eventually consistent store, meaning that data may not be immediately available across all regions after a write.
|
|
85
|
+
|
|
86
|
+
### Key Structure & Namespacing
|
|
87
|
+
|
|
88
|
+
Keys in Cloudflare KV are structured as a combination of a configurable prefix and a table-specific format (e.g., `threads:threadId`). For Workers deployments, `keyPrefix` is used to isolate data within a namespace; for REST API deployments, `namespacePrefix` is used to isolate entire namespaces between environments or applications.
|