@mastra/libsql 0.0.0-studio-cli-20260504022012 → 0.0.0-subconscious-alpha-20260901173138

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.
Files changed (94) hide show
  1. package/LICENSE.md +6 -4
  2. package/dist/docs/SKILL.md +30 -23
  3. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  4. package/dist/docs/references/{docs-agents-agent-approval.md → docs-agents-human-in-the-loop.md} +187 -14
  5. package/dist/docs/references/docs-agents-networks.md +10 -6
  6. package/dist/docs/references/docs-deployment-workers.md +388 -0
  7. package/dist/docs/references/docs-memory-memory-processors.md +83 -10
  8. package/dist/docs/references/docs-memory-message-history.md +92 -10
  9. package/dist/docs/references/docs-memory-multi-user-threads.md +210 -0
  10. package/dist/docs/references/docs-memory-overview.md +46 -18
  11. package/dist/docs/references/docs-memory-semantic-recall.md +137 -13
  12. package/dist/docs/references/docs-memory-working-memory.md +46 -12
  13. package/dist/docs/references/docs-storage.md +222 -0
  14. package/dist/docs/references/docs-studio-editor.md +353 -0
  15. package/dist/docs/references/docs-workflows-snapshots.md +21 -15
  16. package/dist/docs/references/integrations-channels-github.md +152 -0
  17. package/dist/docs/references/{reference-storage-dynamodb.md → integrations-databases-dynamodb.md} +15 -11
  18. package/dist/docs/references/{reference-storage-libsql.md → integrations-databases-libsql.md} +30 -4
  19. package/dist/docs/references/{guides-agent-frameworks-ai-sdk.md → reference-ai-sdk-overview.md} +7 -3
  20. package/dist/docs/references/reference-core-getMemory.md +4 -0
  21. package/dist/docs/references/reference-core-listMemory.md +4 -0
  22. package/dist/docs/references/reference-core-mastra-class.md +87 -6
  23. package/dist/docs/references/reference-file-based-agents-memory.md +62 -0
  24. package/dist/docs/references/reference-file-based-agents-storage.md +34 -0
  25. package/dist/docs/references/reference-memory-memory-class.md +16 -10
  26. package/dist/docs/references/{docs-rag-retrieval.md → reference-rag-retrieval.md} +171 -31
  27. package/dist/docs/references/reference-storage-composite.md +163 -9
  28. package/dist/docs/references/reference-storage-retention.md +250 -0
  29. package/dist/docs/references/reference-vectors-libsql.md +6 -2
  30. package/dist/index.cjs +14044 -11082
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +14007 -11052
  33. package/dist/index.js.map +1 -1
  34. package/dist/storage/db/client.d.ts +31 -0
  35. package/dist/storage/db/client.d.ts.map +1 -0
  36. package/dist/storage/db/index.d.ts +72 -1
  37. package/dist/storage/db/index.d.ts.map +1 -1
  38. package/dist/storage/db/utils.d.ts +17 -1
  39. package/dist/storage/db/utils.d.ts.map +1 -1
  40. package/dist/storage/db/write-lock.d.ts +8 -0
  41. package/dist/storage/db/write-lock.d.ts.map +1 -0
  42. package/dist/storage/domains/agents/index.d.ts.map +1 -1
  43. package/dist/storage/domains/background-tasks/index.d.ts +12 -1
  44. package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
  45. package/dist/storage/domains/blobs/index.d.ts.map +1 -1
  46. package/dist/storage/domains/channels/index.d.ts.map +1 -1
  47. package/dist/storage/domains/datasets/index.d.ts +7 -7
  48. package/dist/storage/domains/datasets/index.d.ts.map +1 -1
  49. package/dist/storage/domains/experiments/index.d.ts +25 -1
  50. package/dist/storage/domains/experiments/index.d.ts.map +1 -1
  51. package/dist/storage/domains/favorites/index.d.ts +17 -0
  52. package/dist/storage/domains/favorites/index.d.ts.map +1 -0
  53. package/dist/storage/domains/harness/index.d.ts +17 -0
  54. package/dist/storage/domains/harness/index.d.ts.map +1 -0
  55. package/dist/storage/domains/knowledge/index.d.ts +81 -0
  56. package/dist/storage/domains/knowledge/index.d.ts.map +1 -0
  57. package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -1
  58. package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -1
  59. package/dist/storage/domains/memory/index.d.ts +26 -4
  60. package/dist/storage/domains/memory/index.d.ts.map +1 -1
  61. package/dist/storage/domains/notifications/index.d.ts +23 -0
  62. package/dist/storage/domains/notifications/index.d.ts.map +1 -0
  63. package/dist/storage/domains/observability/index.d.ts +8 -1
  64. package/dist/storage/domains/observability/index.d.ts.map +1 -1
  65. package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -1
  66. package/dist/storage/domains/schedules/index.d.ts +9 -1
  67. package/dist/storage/domains/schedules/index.d.ts.map +1 -1
  68. package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -1
  69. package/dist/storage/domains/scores/index.d.ts +15 -5
  70. package/dist/storage/domains/scores/index.d.ts.map +1 -1
  71. package/dist/storage/domains/skills/index.d.ts.map +1 -1
  72. package/dist/storage/domains/thread-state/index.d.ts +38 -0
  73. package/dist/storage/domains/thread-state/index.d.ts.map +1 -0
  74. package/dist/storage/domains/tool-provider-connections/index.d.ts +14 -0
  75. package/dist/storage/domains/tool-provider-connections/index.d.ts.map +1 -0
  76. package/dist/storage/domains/utils.d.ts +34 -0
  77. package/dist/storage/domains/utils.d.ts.map +1 -0
  78. package/dist/storage/domains/workflow-definitions/index.d.ts +14 -0
  79. package/dist/storage/domains/workflow-definitions/index.d.ts.map +1 -0
  80. package/dist/storage/domains/workflows/index.d.ts +8 -1
  81. package/dist/storage/domains/workflows/index.d.ts.map +1 -1
  82. package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
  83. package/dist/storage/factory-storage.d.ts +28 -0
  84. package/dist/storage/factory-storage.d.ts.map +1 -0
  85. package/dist/storage/index.d.ts +76 -3
  86. package/dist/storage/index.d.ts.map +1 -1
  87. package/dist/storage/retention.d.ts +77 -0
  88. package/dist/storage/retention.d.ts.map +1 -0
  89. package/dist/vector/filter.d.ts.map +1 -1
  90. package/dist/vector/index.d.ts +6 -0
  91. package/dist/vector/index.d.ts.map +1 -1
  92. package/package.json +20 -19
  93. package/CHANGELOG.md +0 -4581
  94. package/dist/docs/references/docs-memory-storage.md +0 -260
@@ -1,260 +0,0 @@
1
- # Storage
2
-
3
- For agents to remember previous interactions, Mastra needs a storage adapter. Use one of the [supported providers](#supported-providers) and pass it to your Mastra instance.
4
-
5
- ```typescript
6
- import { Mastra } from '@mastra/core'
7
- import { LibSQLStore } from '@mastra/libsql'
8
-
9
- export const mastra = new Mastra({
10
- storage: new LibSQLStore({
11
- id: 'mastra-storage',
12
- url: 'file:./mastra.db',
13
- }),
14
- })
15
- ```
16
-
17
- > **Sharing the database with Studio:** When running `mastra dev` alongside your application (e.g., Next.js), use an absolute path to ensure both processes access the same database:
18
- >
19
- > ```typescript
20
- > url: 'file:/absolute/path/to/your/project/mastra.db'
21
- > ```
22
- >
23
- > Relative paths like `file:./mastra.db` resolve based on each process's working directory, which may differ.
24
-
25
- This configures instance-level storage, which all agents share by default. You can also configure [agent-level storage](#agent-level-storage) for isolated data boundaries.
26
-
27
- Mastra automatically initializes the necessary storage structures on first interaction. See [Storage Overview](https://mastra.ai/reference/storage/overview) for domain coverage and the schema used by the built-in database-backed domains.
28
-
29
- ## Supported providers
30
-
31
- Each provider page includes installation instructions, configuration parameters, and usage examples:
32
-
33
- - [libSQL](https://mastra.ai/reference/storage/libsql)
34
- - [PostgreSQL](https://mastra.ai/reference/storage/postgresql)
35
- - [MongoDB](https://mastra.ai/reference/storage/mongodb)
36
- - [Upstash](https://mastra.ai/reference/storage/upstash)
37
- - [Redis](https://mastra.ai/reference/storage/redis)
38
- - [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1)
39
- - [Cloudflare KV & Durable Objects](https://mastra.ai/reference/storage/cloudflare)
40
- - [Convex](https://mastra.ai/reference/storage/convex)
41
- - [DynamoDB](https://mastra.ai/reference/storage/dynamodb)
42
- - [LanceDB](https://mastra.ai/reference/storage/lance)
43
- - [Microsoft SQL Server](https://mastra.ai/reference/storage/mssql)
44
-
45
- > **Tip:** libSQL is the easiest way to get started because it doesn’t require running a separate database server.
46
-
47
- ## Configuration scope
48
-
49
- Storage can be configured at the instance level (shared by all agents) or at the agent level (isolated to a specific agent).
50
-
51
- ### Instance-level storage
52
-
53
- Add storage to your Mastra instance so all agents, workflows, observability traces, and scores share the same storage backend:
54
-
55
- ```typescript
56
- import { Mastra } from '@mastra/core'
57
- import { PostgresStore } from '@mastra/pg'
58
-
59
- export const mastra = new Mastra({
60
- storage: new PostgresStore({
61
- id: 'mastra-storage',
62
- connectionString: process.env.DATABASE_URL,
63
- }),
64
- })
65
-
66
- // Both agents inherit storage from the Mastra instance above
67
- const agent1 = new Agent({ id: 'agent-1', memory: new Memory() })
68
- const agent2 = new Agent({ id: 'agent-2', memory: new Memory() })
69
- ```
70
-
71
- This is useful when all primitives share the same storage backend and have similar performance, scaling, and operational requirements.
72
-
73
- #### Composite storage
74
-
75
- [Composite storage](https://mastra.ai/reference/storage/composite) is an alternative way to configure instance-level storage. Use `MastraCompositeStore` to route `memory` and any other [supported domains](https://mastra.ai/reference/storage/composite) to different storage providers.
76
-
77
- ```typescript
78
- import { Mastra } from '@mastra/core'
79
- import { MastraCompositeStore } from '@mastra/core/storage'
80
- import { MemoryLibSQL } from '@mastra/libsql'
81
- import { WorkflowsPG } from '@mastra/pg'
82
- import { ObservabilityStorageClickhouse } from '@mastra/clickhouse'
83
-
84
- export const mastra = new Mastra({
85
- storage: new MastraCompositeStore({
86
- id: 'composite',
87
- domains: {
88
- memory: new MemoryLibSQL({ url: 'file:./memory.db' }),
89
- workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
90
- observability: new ObservabilityStorageClickhouse({
91
- url: process.env.CLICKHOUSE_URL,
92
- username: process.env.CLICKHOUSE_USERNAME,
93
- password: process.env.CLICKHOUSE_PASSWORD,
94
- }),
95
- },
96
- }),
97
- })
98
- ```
99
-
100
- This is useful when different types of data have different performance or operational requirements, such as low-latency storage for memory, durable storage for workflows, and high-throughput storage for observability.
101
-
102
- ### Agent-level storage
103
-
104
- Agent-level storage overrides storage configured at the instance level. Add storage to a specific agent when you need to keep data separate or use different providers per agent.
105
-
106
- ```typescript
107
- import { Agent } from '@mastra/core/agent'
108
- import { Memory } from '@mastra/memory'
109
- import { PostgresStore } from '@mastra/pg'
110
-
111
- export const agent = new Agent({
112
- id: 'agent',
113
- memory: new Memory({
114
- storage: new PostgresStore({
115
- id: 'agent-storage',
116
- connectionString: process.env.AGENT_DATABASE_URL,
117
- }),
118
- }),
119
- })
120
- ```
121
-
122
- ## Threads and resources
123
-
124
- Mastra organizes conversations using two identifiers:
125
-
126
- - **Thread**: A conversation session containing a sequence of messages.
127
- - **Resource**: The entity that owns the thread, such as a user, organization, project, or any other domain entity in your application.
128
-
129
- Both identifiers are required for agents to store information:
130
-
131
- **.generate()**:
132
-
133
- ```typescript
134
- const response = await agent.generate('hello', {
135
- memory: {
136
- thread: 'conversation-abc-123',
137
- resource: 'user_123',
138
- },
139
- })
140
- ```
141
-
142
- **.stream()**:
143
-
144
- ```typescript
145
- const stream = await agent.stream('hello', {
146
- memory: {
147
- thread: 'conversation-abc-123',
148
- resource: 'user_123',
149
- },
150
- })
151
- ```
152
-
153
- > **Note:** [Studio](https://mastra.ai/docs/studio/overview) automatically generates a thread and resource ID for you. When calling `stream()` or `generate()` yourself, remember to provide these identifiers explicitly.
154
-
155
- ### Thread title generation
156
-
157
- Mastra can automatically generate descriptive thread titles based on the user's first message when `generateTitle` is enabled.
158
-
159
- Use this option when implementing a ChatGPT-style chat interface to render a title alongside each thread in the conversation list (for example, in a sidebar) derived from the thread’s initial user message.
160
-
161
- ```typescript
162
- export const agent = new Agent({
163
- id: 'agent',
164
- memory: new Memory({
165
- options: {
166
- generateTitle: true,
167
- },
168
- }),
169
- })
170
- ```
171
-
172
- Title generation runs asynchronously after the agent responds and doesn't affect response time.
173
-
174
- To optimize cost or behavior, provide a smaller [`model`](https://mastra.ai/models) and custom `instructions`:
175
-
176
- ```typescript
177
- export const agent = new Agent({
178
- id: 'agent',
179
- memory: new Memory({
180
- options: {
181
- generateTitle: {
182
- model: 'openai/gpt-5-mini',
183
- instructions: 'Generate a 1 word title',
184
- },
185
- },
186
- }),
187
- })
188
- ```
189
-
190
- ## Semantic recall
191
-
192
- Semantic recall has different storage requirements - it needs a vector database in addition to the standard storage adapter. See [Semantic recall](https://mastra.ai/docs/memory/semantic-recall) for setup and supported vector providers.
193
-
194
- ## Handling large attachments
195
-
196
- Some storage providers enforce record size limits that base64-encoded file attachments (such as images) can exceed:
197
-
198
- | Provider | Record size limit |
199
- | ------------------------------------------------------------------ | ----------------- |
200
- | [DynamoDB](https://mastra.ai/reference/storage/dynamodb) | 400 KB |
201
- | [Convex](https://mastra.ai/reference/storage/convex) | 1 MiB |
202
- | [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1) | 1 MiB |
203
-
204
- PostgreSQL, MongoDB, and libSQL have higher limits and are generally unaffected.
205
-
206
- To avoid this, use an input processor to upload attachments to external storage (S3, R2, GCS, [Convex file storage](https://docs.convex.dev/file-storage), etc.) and replace them with URL references before persistence.
207
-
208
- ```typescript
209
- import type { Processor } from '@mastra/core/processors'
210
- import type { MastraDBMessage } from '@mastra/core/memory'
211
-
212
- export class AttachmentUploader implements Processor {
213
- id = 'attachment-uploader'
214
-
215
- async processInput({ messages }: { messages: MastraDBMessage[] }) {
216
- return Promise.all(messages.map(msg => this.processMessage(msg)))
217
- }
218
-
219
- async processMessage(msg: MastraDBMessage) {
220
- const attachments = msg.content.experimental_attachments
221
- if (!attachments?.length) return msg
222
-
223
- const uploaded = await Promise.all(
224
- attachments.map(async att => {
225
- // Skip if already a URL
226
- if (!att.url?.startsWith('data:')) return att
227
-
228
- // Upload base64 data and replace with URL
229
- const url = await this.upload(att.url, att.contentType)
230
- return { ...att, url }
231
- }),
232
- )
233
-
234
- return { ...msg, content: { ...msg.content, experimental_attachments: uploaded } }
235
- }
236
-
237
- async upload(dataUri: string, contentType?: string): Promise<string> {
238
- const base64 = dataUri.split(',')[1]
239
- const buffer = Buffer.from(base64, 'base64')
240
-
241
- // Replace with your storage provider (S3, R2, GCS, Convex, etc.)
242
- // return await s3.upload(buffer, contentType);
243
- throw new Error('Implement upload() with your storage provider')
244
- }
245
- }
246
- ```
247
-
248
- Use the processor with your agent:
249
-
250
- ```typescript
251
- import { Agent } from '@mastra/core/agent'
252
- import { Memory } from '@mastra/memory'
253
- import { AttachmentUploader } from './processors/attachment-uploader'
254
-
255
- const agent = new Agent({
256
- id: 'my-agent',
257
- memory: new Memory({ storage: yourStorage }),
258
- inputProcessors: [new AttachmentUploader()],
259
- })
260
- ```