@mastra/agentfs 0.1.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 +25 -0
- package/LICENSE.md +30 -0
- package/README.md +58 -0
- package/dist/filesystem/index.d.ts +109 -0
- package/dist/filesystem/index.d.ts.map +1 -0
- package/dist/index.cjs +524 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +516 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +16 -0
- package/dist/provider.d.ts.map +1 -0
- package/package.json +67 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @mastra/agentfs
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added AgentFSFilesystem workspace provider — a Turso/SQLite-backed filesystem via the agentfs-sdk that gives agents persistent, database-backed file storage across sessions. ([#13450](https://github.com/mastra-ai/mastra/pull/13450))
|
|
8
|
+
|
|
9
|
+
**Basic usage**
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
13
|
+
import { AgentFSFilesystem } from '@mastra/agentfs';
|
|
14
|
+
|
|
15
|
+
const workspace = new Workspace({
|
|
16
|
+
filesystem: new AgentFSFilesystem({
|
|
17
|
+
agentId: 'my-agent',
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [[`ea86967`](https://github.com/mastra-ai/mastra/commit/ea86967449426e0a3673253bd1c2c052a99d970d), [`db21c21`](https://github.com/mastra-ai/mastra/commit/db21c21a6ae5f33539262cc535342fa8757eb359), [`11f5dbe`](https://github.com/mastra-ai/mastra/commit/11f5dbe9a1e7ad8ef3b1ea34fb4a9fa3631d1587), [`6751354`](https://github.com/mastra-ai/mastra/commit/67513544d1a64be891d9de7624d40aadc895d56e), [`c958cd3`](https://github.com/mastra-ai/mastra/commit/c958cd36627c1eea122ec241b2b15492977a263a), [`86f2426`](https://github.com/mastra-ai/mastra/commit/86f242631d252a172d2f9f9a2ea0feb8647a76b0), [`950eb07`](https://github.com/mastra-ai/mastra/commit/950eb07b7e7354629630e218d49550fdd299c452)]:
|
|
25
|
+
- @mastra/core@1.13.0-alpha.0
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
|
|
16
|
+
# Apache License 2.0
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
19
|
+
|
|
20
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
you may not use this file except in compliance with the License.
|
|
22
|
+
You may obtain a copy of the License at
|
|
23
|
+
|
|
24
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
|
|
26
|
+
Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
See the License for the specific language governing permissions and
|
|
30
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @mastra/agentfs
|
|
2
|
+
|
|
3
|
+
AgentFS (Turso/SQLite-backed) filesystem provider for Mastra workspaces. Stores files in a local SQLite database via the agentfs-sdk, giving agents persistent storage that survives across sessions.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/agentfs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Agent } from '@mastra/core/agent';
|
|
15
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
16
|
+
import { AgentFSFilesystem } from '@mastra/agentfs';
|
|
17
|
+
|
|
18
|
+
const workspace = new Workspace({
|
|
19
|
+
filesystem: new AgentFSFilesystem({
|
|
20
|
+
agentId: 'my-agent', // stores at .agentfs/my-agent.db
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const agent = new Agent({
|
|
25
|
+
name: 'my-agent',
|
|
26
|
+
model: 'anthropic/claude-opus-4-5',
|
|
27
|
+
workspace,
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Using an explicit database path
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const workspace = new Workspace({
|
|
35
|
+
filesystem: new AgentFSFilesystem({
|
|
36
|
+
path: '/data/my-agent.db',
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Using a pre-opened AgentFS instance
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { AgentFS } from 'agentfs-sdk';
|
|
45
|
+
import { AgentFSFilesystem } from '@mastra/agentfs';
|
|
46
|
+
|
|
47
|
+
const agent = await AgentFS.open({ id: 'my-agent' });
|
|
48
|
+
|
|
49
|
+
const workspace = new Workspace({
|
|
50
|
+
filesystem: new AgentFSFilesystem({
|
|
51
|
+
agent, // caller manages open/close
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Documentation
|
|
57
|
+
|
|
58
|
+
For more information, see the [Mastra Workspaces documentation](https://mastra.ai/docs/workspace/overview).
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentFS Filesystem Provider
|
|
3
|
+
*
|
|
4
|
+
* Implements WorkspaceFilesystem backed by AgentFS (Turso/SQLite).
|
|
5
|
+
* Follows the same pattern as S3Filesystem.
|
|
6
|
+
*/
|
|
7
|
+
import type { FileContent, FileStat, FileEntry, ReadOptions, WriteOptions, ListOptions, RemoveOptions, CopyOptions, FilesystemIcon, FilesystemInfo, ProviderStatus, MastraFilesystemOptions } from '@mastra/core/workspace';
|
|
8
|
+
import { MastraFilesystem } from '@mastra/core/workspace';
|
|
9
|
+
import { AgentFS } from 'agentfs-sdk';
|
|
10
|
+
/**
|
|
11
|
+
* AgentFS filesystem provider configuration.
|
|
12
|
+
*/
|
|
13
|
+
export interface AgentFSFilesystemOptions extends MastraFilesystemOptions {
|
|
14
|
+
/** Unique identifier for this filesystem instance */
|
|
15
|
+
id?: string;
|
|
16
|
+
/** Agent ID — creates database at `.agentfs/<agentId>.db` */
|
|
17
|
+
agentId?: string;
|
|
18
|
+
/** Explicit database file path */
|
|
19
|
+
path?: string;
|
|
20
|
+
/** Pre-opened AgentFS instance (skips open/close — caller manages lifecycle) */
|
|
21
|
+
agent?: AgentFS;
|
|
22
|
+
/** Block write operations (default: false) */
|
|
23
|
+
readOnly?: boolean;
|
|
24
|
+
/** Human-friendly display name for the UI */
|
|
25
|
+
displayName?: string;
|
|
26
|
+
/** Icon identifier for the UI (default: 'database') */
|
|
27
|
+
icon?: FilesystemIcon;
|
|
28
|
+
/** Description shown in tooltips */
|
|
29
|
+
description?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* AgentFS filesystem implementation.
|
|
33
|
+
*
|
|
34
|
+
* Stores files in a Turso/SQLite database via the AgentFS SDK.
|
|
35
|
+
*
|
|
36
|
+
* @example Using agentId
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { AgentFSFilesystem } from '@mastra/agentfs';
|
|
39
|
+
*
|
|
40
|
+
* const fs = new AgentFSFilesystem({ agentId: 'my-agent' });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Using a pre-opened instance
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { AgentFS } from 'agentfs-sdk';
|
|
46
|
+
* import { AgentFSFilesystem } from '@mastra/agentfs';
|
|
47
|
+
*
|
|
48
|
+
* const agent = await AgentFS.open({ id: 'my-agent' });
|
|
49
|
+
* const fs = new AgentFSFilesystem({ agent });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare class AgentFSFilesystem extends MastraFilesystem {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly name = "AgentFSFilesystem";
|
|
55
|
+
readonly provider = "agentfs";
|
|
56
|
+
readonly readOnly?: boolean;
|
|
57
|
+
status: ProviderStatus;
|
|
58
|
+
readonly displayName?: string;
|
|
59
|
+
readonly icon: FilesystemIcon;
|
|
60
|
+
readonly description?: string;
|
|
61
|
+
private _agent;
|
|
62
|
+
private readonly _ownsAgent;
|
|
63
|
+
private readonly _agentId?;
|
|
64
|
+
private readonly _path?;
|
|
65
|
+
constructor(options: AgentFSFilesystemOptions);
|
|
66
|
+
/** The underlying AgentFS instance, or null if not yet initialized. */
|
|
67
|
+
get agent(): AgentFS | null;
|
|
68
|
+
getInfo(): FilesystemInfo<{
|
|
69
|
+
agentId?: string;
|
|
70
|
+
dbPath?: string;
|
|
71
|
+
}>;
|
|
72
|
+
getInstructions(): string;
|
|
73
|
+
init(): Promise<void>;
|
|
74
|
+
destroy(): Promise<void>;
|
|
75
|
+
private getAgent;
|
|
76
|
+
private assertWritable;
|
|
77
|
+
readFile(path: string, options?: ReadOptions): Promise<string | Buffer>;
|
|
78
|
+
writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void>;
|
|
79
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
80
|
+
deleteFile(path: string, options?: RemoveOptions): Promise<void>;
|
|
81
|
+
copyFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
82
|
+
moveFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
83
|
+
mkdir(path: string, options?: {
|
|
84
|
+
recursive?: boolean;
|
|
85
|
+
}): Promise<void>;
|
|
86
|
+
rmdir(path: string, options?: RemoveOptions): Promise<void>;
|
|
87
|
+
readdir(path: string, options?: ListOptions): Promise<FileEntry[]>;
|
|
88
|
+
exists(path: string): Promise<boolean>;
|
|
89
|
+
stat(path: string): Promise<FileStat>;
|
|
90
|
+
/**
|
|
91
|
+
* Check if the path points to a file.
|
|
92
|
+
* Returns `false` if the path doesn't exist.
|
|
93
|
+
*/
|
|
94
|
+
isFile(path: string): Promise<boolean>;
|
|
95
|
+
/**
|
|
96
|
+
* Check if the path points to a directory.
|
|
97
|
+
* Returns `false` if the path doesn't exist.
|
|
98
|
+
*/
|
|
99
|
+
isDirectory(path: string): Promise<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* Recursively create directories, ignoring EEXIST errors.
|
|
102
|
+
*/
|
|
103
|
+
private mkdirRecursive;
|
|
104
|
+
/**
|
|
105
|
+
* Recursively copy a directory tree.
|
|
106
|
+
*/
|
|
107
|
+
private copyDirRecursive;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filesystem/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,uBAAuB,EACxB,MAAM,wBAAwB,C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