@mastra/libsql 1.1.0-alpha.2 → 1.2.0-alpha.0
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 +186 -0
- package/dist/docs/README.md +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/SOURCE_MAP.json +1 -1
- package/dist/docs/memory/02-storage.md +10 -0
- package/dist/index.cjs +673 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +673 -15
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/agents/index.d.ts +2 -1
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +14 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,191 @@
|
|
|
1
1
|
# @mastra/libsql
|
|
2
2
|
|
|
3
|
+
## 1.2.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added Observational Memory — a new memory system that keeps your agent's context window small while preserving long-term memory across conversations. ([#12599](https://github.com/mastra-ai/mastra/pull/12599))
|
|
8
|
+
|
|
9
|
+
**Why:** Long conversations cause context rot and waste tokens. Observational Memory compresses conversation history into observations (5–40x compression) and periodically condenses those into reflections. Your agent stays fast and focused, even after thousands of messages.
|
|
10
|
+
|
|
11
|
+
**Usage:**
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Memory } from '@mastra/memory';
|
|
15
|
+
import { PostgresStore } from '@mastra/pg';
|
|
16
|
+
|
|
17
|
+
const memory = new Memory({
|
|
18
|
+
storage: new PostgresStore({ connectionString: process.env.DATABASE_URL }),
|
|
19
|
+
options: {
|
|
20
|
+
observationalMemory: true,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const agent = new Agent({
|
|
25
|
+
name: 'my-agent',
|
|
26
|
+
model: openai('gpt-4o'),
|
|
27
|
+
memory,
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**What's new:**
|
|
32
|
+
- `observationalMemory: true` enables the three-tier memory system (recent messages → observations → reflections)
|
|
33
|
+
- Thread-scoped (per-conversation) and resource-scoped (shared across all threads for a user) modes
|
|
34
|
+
- Manual `observe()` API for triggering observation outside the normal agent loop
|
|
35
|
+
- New OM storage methods for pg, libsql, and mongodb adapters (conditionally enabled)
|
|
36
|
+
- `Agent.findProcessor()` method for looking up processors by ID
|
|
37
|
+
- `processorStates` for persisting processor state across loop iterations
|
|
38
|
+
- Abort signal propagation to processors
|
|
39
|
+
- `ProcessorStreamWriter` for custom stream events from processors
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Created @mastra/editor package for managing and resolving stored agent configurations ([#12631](https://github.com/mastra-ai/mastra/pull/12631))
|
|
44
|
+
|
|
45
|
+
This major addition introduces the editor package, which provides a complete solution for storing, versioning, and instantiating agent configurations from a database. The editor seamlessly integrates with Mastra's storage layer to enable dynamic agent management.
|
|
46
|
+
|
|
47
|
+
**Key Features:**
|
|
48
|
+
- **Agent Storage & Retrieval**: Store complete agent configurations including instructions, model settings, tools, workflows, nested agents, scorers, processors, and memory configuration
|
|
49
|
+
- **Version Management**: Create and manage multiple versions of agents, with support for activating specific versions
|
|
50
|
+
- **Dependency Resolution**: Automatically resolves and instantiates all agent dependencies (tools, workflows, sub-agents, etc.) from the Mastra registry
|
|
51
|
+
- **Caching**: Built-in caching for improved performance when repeatedly accessing stored agents
|
|
52
|
+
- **Type Safety**: Full TypeScript support with proper typing for stored configurations
|
|
53
|
+
|
|
54
|
+
**Usage Example:**
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { MastraEditor } from '@mastra/editor';
|
|
58
|
+
import { Mastra } from '@mastra/core';
|
|
59
|
+
|
|
60
|
+
// Initialize editor with Mastra
|
|
61
|
+
const mastra = new Mastra({
|
|
62
|
+
/* config */
|
|
63
|
+
editor: new MastraEditor(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Store an agent configuration
|
|
67
|
+
const agentId = await mastra.storage.stores?.agents?.createAgent({
|
|
68
|
+
name: 'customer-support',
|
|
69
|
+
instructions: 'Help customers with inquiries',
|
|
70
|
+
model: { provider: 'openai', name: 'gpt-4' },
|
|
71
|
+
tools: ['search-kb', 'create-ticket'],
|
|
72
|
+
workflows: ['escalation-flow'],
|
|
73
|
+
memory: { vector: 'pinecone-db' },
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Retrieve and use the stored agent
|
|
77
|
+
const agent = await mastra.getEditor()?.getStoredAgentById(agentId);
|
|
78
|
+
const response = await agent?.generate('How do I reset my password?');
|
|
79
|
+
|
|
80
|
+
// List all stored agents
|
|
81
|
+
const agents = await mastra.getEditor()?.listStoredAgents({ pageSize: 10 });
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Storage Improvements:**
|
|
85
|
+
- Fixed JSONB handling in LibSQL, PostgreSQL, and MongoDB adapters
|
|
86
|
+
- Improved agent resolution queries to properly merge version data
|
|
87
|
+
- Enhanced type safety for serialized configurations
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [[`2770921`](https://github.com/mastra-ai/mastra/commit/2770921eec4d55a36b278d15c3a83f694e462ee5), [`b1695db`](https://github.com/mastra-ai/mastra/commit/b1695db2d7be0c329d499619c7881899649188d0), [`4133d48`](https://github.com/mastra-ai/mastra/commit/4133d48eaa354cdb45920dc6265732ffbc96788d), [`5dd01cc`](https://github.com/mastra-ai/mastra/commit/5dd01cce68d61874aa3ecbd91ee17884cfd5aca2), [`13e0a2a`](https://github.com/mastra-ai/mastra/commit/13e0a2a2bcec01ff4d701274b3727d5e907a6a01), [`c987384`](https://github.com/mastra-ai/mastra/commit/c987384d6c8ca844a9701d7778f09f5a88da7f9f), [`cb8cc12`](https://github.com/mastra-ai/mastra/commit/cb8cc12bfadd526aa95a01125076f1da44e4afa7), [`62f5d50`](https://github.com/mastra-ai/mastra/commit/62f5d5043debbba497dacb7ab008fe86b38b8de3)]:
|
|
90
|
+
- @mastra/core@1.2.0-alpha.1
|
|
91
|
+
|
|
92
|
+
## 1.1.0
|
|
93
|
+
|
|
94
|
+
### Minor Changes
|
|
95
|
+
|
|
96
|
+
- Restructured stored agents to use a thin metadata record with versioned configuration snapshots. ([#12488](https://github.com/mastra-ai/mastra/pull/12488))
|
|
97
|
+
|
|
98
|
+
The agent record now only stores metadata fields (id, status, activeVersionId, authorId, metadata, timestamps). All configuration fields (name, instructions, model, tools, etc.) live exclusively in version snapshot rows, enabling full version history and rollback.
|
|
99
|
+
|
|
100
|
+
**Key changes:**
|
|
101
|
+
- Stored Agent records are now thin metadata-only (StorageAgentType)
|
|
102
|
+
- All config lives in version snapshots (StorageAgentSnapshotType)
|
|
103
|
+
- New resolved type (StorageResolvedAgentType) merges agent record + active version config
|
|
104
|
+
- Renamed `ownerId` to `authorId` for multi-tenant filtering
|
|
105
|
+
- Changed `memory` field type from `string` to `Record<string, unknown>`
|
|
106
|
+
- Added `status` field ('draft' | 'published') to agent records
|
|
107
|
+
- Flattened CreateAgent/UpdateAgent input types (config fields at top level, no nested snapshot)
|
|
108
|
+
- Version config columns are top-level in the agent_versions table (no single snapshot jsonb column)
|
|
109
|
+
- List endpoints return resolved agents (thin record + active version config)
|
|
110
|
+
- Auto-versioning on update with retention limits and race condition handling
|
|
111
|
+
|
|
112
|
+
- Added dynamic agent management with CRUD operations and version tracking ([#12038](https://github.com/mastra-ai/mastra/pull/12038))
|
|
113
|
+
|
|
114
|
+
**New Features:**
|
|
115
|
+
- Create, edit, and delete agents directly from the Mastra Studio UI
|
|
116
|
+
- Full version history for agents with compare and restore capabilities
|
|
117
|
+
- Visual diff viewer to compare agent configurations across versions
|
|
118
|
+
- Agent creation modal with comprehensive configuration options (model selection, instructions, tools, workflows, sub-agents, memory)
|
|
119
|
+
- AI-powered instruction enhancement
|
|
120
|
+
|
|
121
|
+
**Storage:**
|
|
122
|
+
- New storage interfaces for stored agents and agent versions
|
|
123
|
+
- PostgreSQL, LibSQL, and MongoDB implementations included
|
|
124
|
+
- In-memory storage for development and testing
|
|
125
|
+
|
|
126
|
+
**API:**
|
|
127
|
+
- RESTful endpoints for agent CRUD operations
|
|
128
|
+
- Version management endpoints (create, list, activate, restore, delete, compare)
|
|
129
|
+
- Automatic versioning on agent updates when enabled
|
|
130
|
+
|
|
131
|
+
**Client SDK:**
|
|
132
|
+
- JavaScript client with full support for stored agents and versions
|
|
133
|
+
- Type-safe methods for all CRUD and version operations
|
|
134
|
+
|
|
135
|
+
**Usage Example:**
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// Server-side: Configure storage
|
|
139
|
+
import { Mastra } from '@mastra/core';
|
|
140
|
+
import { PgAgentsStorage } from '@mastra/pg';
|
|
141
|
+
|
|
142
|
+
const mastra = new Mastra({
|
|
143
|
+
agents: { agentOne },
|
|
144
|
+
storage: {
|
|
145
|
+
agents: new PgAgentsStorage({
|
|
146
|
+
connectionString: process.env.DATABASE_URL,
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Client-side: Use the SDK
|
|
152
|
+
import { MastraClient } from '@mastra/client-js';
|
|
153
|
+
|
|
154
|
+
const client = new MastraClient({ baseUrl: 'http://localhost:3000' });
|
|
155
|
+
|
|
156
|
+
// Create a stored agent
|
|
157
|
+
const agent = await client.createStoredAgent({
|
|
158
|
+
name: 'Customer Support Agent',
|
|
159
|
+
description: 'Handles customer inquiries',
|
|
160
|
+
model: { provider: 'ANTHROPIC', name: 'claude-sonnet-4-5' },
|
|
161
|
+
instructions: 'You are a helpful customer support agent...',
|
|
162
|
+
tools: ['search', 'email'],
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Create a version snapshot
|
|
166
|
+
await client.storedAgent(agent.id).createVersion({
|
|
167
|
+
name: 'v1.0 - Initial release',
|
|
168
|
+
changeMessage: 'First production version',
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Compare versions
|
|
172
|
+
const diff = await client.storedAgent(agent.id).compareVersions('version-1', 'version-2');
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Why:**
|
|
176
|
+
This feature enables teams to manage agents dynamically without code changes, making it easier to iterate on agent configurations and maintain a complete audit trail of changes.
|
|
177
|
+
|
|
178
|
+
- Added `status` field to `listTraces` response. The status field indicates the trace state: `success` (completed without error), `error` (has error), or `running` (still in progress). This makes it easier to filter and display traces by their current state without having to derive it from the `error` and `endedAt` fields. ([#12213](https://github.com/mastra-ai/mastra/pull/12213))
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- Stored agent edits no longer fail silently. PATCH requests now save changes correctly. ([#12504](https://github.com/mastra-ai/mastra/pull/12504))
|
|
183
|
+
|
|
184
|
+
- Fix PATCH request JSON-body handling in `@mastra/client-js` so stored agent edit flows work correctly. Fix stored agent schema migration in `@mastra/libsql` and `@mastra/pg` to drop and recreate the versions table when the old snapshot-based schema is detected, clean up stale draft records from partial create failures, and remove lingering legacy tables. Restores create and edit flows for stored agents. ([#12504](https://github.com/mastra-ai/mastra/pull/12504))
|
|
185
|
+
|
|
186
|
+
- Updated dependencies [[`90fc0e5`](https://github.com/mastra-ai/mastra/commit/90fc0e5717cb280c2d4acf4f0410b510bb4c0a72), [`1cf5d2e`](https://github.com/mastra-ai/mastra/commit/1cf5d2ea1b085be23e34fb506c80c80a4e6d9c2b), [`b99ceac`](https://github.com/mastra-ai/mastra/commit/b99ceace2c830dbdef47c8692d56a91954aefea2), [`deea43e`](https://github.com/mastra-ai/mastra/commit/deea43eb1366d03a864c5e597d16a48592b9893f), [`833ae96`](https://github.com/mastra-ai/mastra/commit/833ae96c3e34370e58a1e979571c41f39a720592), [`943772b`](https://github.com/mastra-ai/mastra/commit/943772b4378f625f0f4e19ea2b7c392bd8e71786), [`b5c711b`](https://github.com/mastra-ai/mastra/commit/b5c711b281dd1fb81a399a766bc9f86c55efc13e), [`3efbe5a`](https://github.com/mastra-ai/mastra/commit/3efbe5ae20864c4f3143457f4f3ee7dc2fa5ca76), [`1e49e7a`](https://github.com/mastra-ai/mastra/commit/1e49e7ab5f173582154cb26b29d424de67d09aef), [`751eaab`](https://github.com/mastra-ai/mastra/commit/751eaab4e0d3820a94e4c3d39a2ff2663ded3d91), [`69d8156`](https://github.com/mastra-ai/mastra/commit/69d81568bcf062557c24471ce26812446bec465d), [`60d9d89`](https://github.com/mastra-ai/mastra/commit/60d9d899e44b35bc43f1bcd967a74e0ce010b1af), [`5c544c8`](https://github.com/mastra-ai/mastra/commit/5c544c8d12b08ab40d64d8f37b3c4215bee95b87), [`771ad96`](https://github.com/mastra-ai/mastra/commit/771ad962441996b5c43549391a3e6a02c6ddedc2), [`2b0936b`](https://github.com/mastra-ai/mastra/commit/2b0936b0c9a43eeed9bef63e614d7e02ee803f7e), [`3b04f30`](https://github.com/mastra-ai/mastra/commit/3b04f3010604f3cdfc8a0674731700ad66471cee), [`97e26de`](https://github.com/mastra-ai/mastra/commit/97e26deaebd9836647a67b96423281d66421ca07), [`ac9ec66`](https://github.com/mastra-ai/mastra/commit/ac9ec6672779b2e6d4344e415481d1a6a7d4911a), [`10523f4`](https://github.com/mastra-ai/mastra/commit/10523f4882d9b874b40ce6e3715f66dbcd4947d2), [`cb72d20`](https://github.com/mastra-ai/mastra/commit/cb72d2069d7339bda8a0e76d4f35615debb07b84), [`42856b1`](https://github.com/mastra-ai/mastra/commit/42856b1c8aeea6371c9ee77ae2f5f5fe34400933), [`66f33ff`](https://github.com/mastra-ai/mastra/commit/66f33ff68620018513e499c394411d1d39b3aa5c), [`ab3c190`](https://github.com/mastra-ai/mastra/commit/ab3c1901980a99910ca9b96a7090c22e24060113), [`d4f06c8`](https://github.com/mastra-ai/mastra/commit/d4f06c85ffa5bb0da38fb82ebf3b040cc6b4ec4e), [`0350626`](https://github.com/mastra-ai/mastra/commit/03506267ec41b67add80d994c0c0fcce93bbc75f), [`bc9fa00`](https://github.com/mastra-ai/mastra/commit/bc9fa00859c5c4a796d53a0a5cae46ab4a3072e4), [`f46a478`](https://github.com/mastra-ai/mastra/commit/f46a4782f595949c696569e891f81c8d26338508), [`90fc0e5`](https://github.com/mastra-ai/mastra/commit/90fc0e5717cb280c2d4acf4f0410b510bb4c0a72), [`f05a3a5`](https://github.com/mastra-ai/mastra/commit/f05a3a5cf2b9a9c2d40c09cb8c762a4b6cd5d565), [`a291da9`](https://github.com/mastra-ai/mastra/commit/a291da9363efd92dafd8775dccb4f2d0511ece7a), [`c5d71da`](https://github.com/mastra-ai/mastra/commit/c5d71da1c680ce5640b1a7f8ca0e024a4ab1cfed), [`07042f9`](https://github.com/mastra-ai/mastra/commit/07042f9f89080f38b8f72713ba1c972d5b1905b8), [`0423442`](https://github.com/mastra-ai/mastra/commit/0423442b7be2dfacba95890bea8f4a810db4d603)]:
|
|
187
|
+
- @mastra/core@1.1.0
|
|
188
|
+
|
|
3
189
|
## 1.1.0-alpha.2
|
|
4
190
|
|
|
5
191
|
### Patch Changes
|
package/dist/docs/README.md
CHANGED
package/dist/docs/SKILL.md
CHANGED
|
@@ -15,6 +15,16 @@ export const mastra = new Mastra({
|
|
|
15
15
|
}),
|
|
16
16
|
});
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
> **Sharing the database with Mastra Studio**
|
|
20
|
+
When running `mastra dev` alongside your application (e.g., Next.js), use an absolute path to ensure both processes access the same database:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
url: "file:/absolute/path/to/your/project/mastra.db"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Relative paths like `file:./mastra.db` resolve based on each process's working directory, which may differ.
|
|
27
|
+
|
|
18
28
|
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.
|
|
19
29
|
|
|
20
30
|
Mastra automatically creates the necessary tables on first interaction. See the [core schema](https://mastra.ai/reference/storage/overview#core-schema) for details on what gets created, including tables for messages, threads, resources, workflows, traces, and evaluation datasets.
|