@mastra/azure 0.2.0-alpha.0 → 0.2.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 +46 -0
- package/README.md +79 -0
- package/dist/blob/blob-store/index.d.ts +84 -0
- package/dist/blob/blob-store/index.d.ts.map +1 -0
- package/dist/blob/index.cjs +11 -3
- package/dist/blob/index.d.ts +4 -3
- package/dist/blob/index.d.ts.map +1 -1
- package/dist/blob/index.js +1 -1
- package/dist/blob/provider.d.ts +3 -1
- package/dist/blob/provider.d.ts.map +1 -1
- package/dist/{chunk-VFZDLQDB.js → chunk-DBBJ2YM7.js} +189 -3
- package/dist/chunk-DBBJ2YM7.js.map +1 -0
- package/dist/{chunk-LLH5EI3J.cjs → chunk-JLBSGA65.cjs} +190 -2
- package/dist/chunk-JLBSGA65.cjs.map +1 -0
- package/dist/index.cjs +11 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-LLH5EI3J.cjs.map +0 -1
- package/dist/chunk-VFZDLQDB.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @mastra/azure
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add `@mastra/azure`, exporting an Azure Blob Storage `WorkspaceFilesystem` provider via `@mastra/azure/blob` with support for connection string, account key, SAS token, `DefaultAzureCredential`, and anonymous auth, plus prefix namespacing and read-only mode. ([#15217](https://github.com/mastra-ai/mastra/pull/15217))
|
|
8
|
+
|
|
9
|
+
- Added `AzureBlobStore`, a content-addressable blob store backed by Azure Blob Storage for skill versioning. Available alongside the existing `AzureBlobFilesystem` from `@mastra/azure/blob`. ([#15853](https://github.com/mastra-ai/mastra/pull/15853))
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { AzureBlobStore } from '@mastra/azure/blob';
|
|
13
|
+
|
|
14
|
+
const blobs = new AzureBlobStore({
|
|
15
|
+
container: 'my-skill-blobs',
|
|
16
|
+
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Supports the same authentication methods as `AzureBlobFilesystem`: connection string, account key, SAS token, `DefaultAzureCredential`, and anonymous access. A matching `azureBlobStoreProvider` descriptor is also exported for MastraEditor.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [[`28caa5b`](https://github.com/mastra-ai/mastra/commit/28caa5b032358545af2589ed90636eccb4dd9d2f), [`c1ae974`](https://github.com/mastra-ai/mastra/commit/c1ae97491f6e57378ce880c3a397778c42adcdf1), [`b510d36`](https://github.com/mastra-ai/mastra/commit/b510d368f73dab6be2e2c2bc99035aaef1fb7d7a), [`13b4d7c`](https://github.com/mastra-ai/mastra/commit/13b4d7c16de34dff9095d1cd80f22f544b6cfe75), [`7a7b313`](https://github.com/mastra-ai/mastra/commit/7a7b3138fb3bcf0b0c740eaea07971e43d330ef3), [`c04417b`](https://github.com/mastra-ai/mastra/commit/c04417ba0a2e4ded66da4352331ef29cd4bd1d79), [`cf25a03`](https://github.com/mastra-ai/mastra/commit/cf25a03132164b9dc1e5dccf7394824e33007c51), [`8a71261`](https://github.com/mastra-ai/mastra/commit/8a71261e3954ae617c6f8e25767b951f99438ab2), [`9e973b0`](https://github.com/mastra-ai/mastra/commit/9e973b010dacfa15ac82b0072897319f5234b90a), [`dd934a0`](https://github.com/mastra-ai/mastra/commit/dd934a0982ce0f78712fbd559e4f2410bf594b39), [`ba6b0c5`](https://github.com/mastra-ai/mastra/commit/ba6b0c51bfce358554fd33c7f2bcd5593633f2ff), [`a6dac0a`](https://github.com/mastra-ai/mastra/commit/a6dac0a40c7181161b1add4e8534f962bcbc9aa7), [`5a4b1ee`](https://github.com/mastra-ai/mastra/commit/5a4b1ee80212969621228104995589c0fa59e575), [`5a4b1ee`](https://github.com/mastra-ai/mastra/commit/5a4b1ee80212969621228104995589c0fa59e575), [`5a4b1ee`](https://github.com/mastra-ai/mastra/commit/5a4b1ee80212969621228104995589c0fa59e575), [`6c8c6c7`](https://github.com/mastra-ai/mastra/commit/6c8c6c71518394321a4692614aa4b11f3bb0a343), [`5a4b1ee`](https://github.com/mastra-ai/mastra/commit/5a4b1ee80212969621228104995589c0fa59e575), [`7d056b6`](https://github.com/mastra-ai/mastra/commit/7d056b6ecf603cacaa0f663ff1df025ed885b6c1), [`9cef83b`](https://github.com/mastra-ai/mastra/commit/9cef83b8a642b8098747772921e3523b492bafbc), [`d30e215`](https://github.com/mastra-ai/mastra/commit/d30e2156c746bc9fd791745cec1cc24377b66789), [`021a60f`](https://github.com/mastra-ai/mastra/commit/021a60f1f3e0135a70ef23c58be7a9b3aaffe6b4), [`73f2809`](https://github.com/mastra-ai/mastra/commit/73f2809721db24e98cdf122539652a455211b450), [`aedeea4`](https://github.com/mastra-ai/mastra/commit/aedeea48a94f728323f040478775076b9574be50), [`26f1f94`](https://github.com/mastra-ai/mastra/commit/26f1f9490574b864ba1ecedf2c9632e0767a23bd), [`8126d86`](https://github.com/mastra-ai/mastra/commit/8126d8638411eacfafdc29036ac998e8757ea66f), [`73b45fa`](https://github.com/mastra-ai/mastra/commit/73b45facdef4fbcb8af710c50f0646f18619dbaa), [`ae97520`](https://github.com/mastra-ai/mastra/commit/ae975206fdb0f6ef03c4d5bf94f7dc7c3f706c02), [`7a7b313`](https://github.com/mastra-ai/mastra/commit/7a7b3138fb3bcf0b0c740eaea07971e43d330ef3), [`441670a`](https://github.com/mastra-ai/mastra/commit/441670a02c9dc7731c52674f55481e7848a84523)]:
|
|
25
|
+
- @mastra/core@1.29.0
|
|
26
|
+
|
|
27
|
+
## 0.2.0-alpha.1
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- Added `AzureBlobStore`, a content-addressable blob store backed by Azure Blob Storage for skill versioning. Available alongside the existing `AzureBlobFilesystem` from `@mastra/azure/blob`. ([#15853](https://github.com/mastra-ai/mastra/pull/15853))
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { AzureBlobStore } from '@mastra/azure/blob';
|
|
35
|
+
|
|
36
|
+
const blobs = new AzureBlobStore({
|
|
37
|
+
container: 'my-skill-blobs',
|
|
38
|
+
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Supports the same authentication methods as `AzureBlobFilesystem`: connection string, account key, SAS token, `DefaultAzureCredential`, and anonymous access. A matching `azureBlobStoreProvider` descriptor is also exported for MastraEditor.
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`28caa5b`](https://github.com/mastra-ai/mastra/commit/28caa5b032358545af2589ed90636eccb4dd9d2f), [`7d056b6`](https://github.com/mastra-ai/mastra/commit/7d056b6ecf603cacaa0f663ff1df025ed885b6c1), [`26f1f94`](https://github.com/mastra-ai/mastra/commit/26f1f9490574b864ba1ecedf2c9632e0767a23bd)]:
|
|
47
|
+
- @mastra/core@1.29.0-alpha.5
|
|
48
|
+
|
|
3
49
|
## 0.2.0-alpha.0
|
|
4
50
|
|
|
5
51
|
### Minor Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @mastra/azure
|
|
2
|
+
|
|
3
|
+
Azure Blob Storage filesystem and content-addressable blob store provider for Mastra workspaces.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/azure
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Agent } from '@mastra/core/agent';
|
|
15
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
16
|
+
import { AzureBlobFilesystem } from '@mastra/azure/blob';
|
|
17
|
+
|
|
18
|
+
const workspace = new Workspace({
|
|
19
|
+
filesystem: new AzureBlobFilesystem({
|
|
20
|
+
container: 'my-container',
|
|
21
|
+
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const agent = new Agent({
|
|
26
|
+
name: 'my-agent',
|
|
27
|
+
model: 'anthropic/claude-opus-4-5',
|
|
28
|
+
workspace,
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Account key
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
const filesystem = new AzureBlobFilesystem({
|
|
36
|
+
container: 'my-container',
|
|
37
|
+
accountName: process.env.AZURE_STORAGE_ACCOUNT_NAME,
|
|
38
|
+
accountKey: process.env.AZURE_STORAGE_ACCOUNT_KEY,
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Shared access signature
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const filesystem = new AzureBlobFilesystem({
|
|
46
|
+
container: 'my-container',
|
|
47
|
+
accountName: process.env.AZURE_STORAGE_ACCOUNT_NAME,
|
|
48
|
+
sasToken: process.env.AZURE_STORAGE_SAS_TOKEN,
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### DefaultAzureCredential
|
|
53
|
+
|
|
54
|
+
Requires `@azure/identity` to be installed.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const filesystem = new AzureBlobFilesystem({
|
|
58
|
+
container: 'my-container',
|
|
59
|
+
accountName: process.env.AZURE_STORAGE_ACCOUNT_NAME,
|
|
60
|
+
useDefaultCredential: true,
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Blob Store
|
|
65
|
+
|
|
66
|
+
`AzureBlobStore` is a content-addressable blob store backed by Azure Blob Storage, used for skill versioning.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { AzureBlobStore } from '@mastra/azure/blob';
|
|
70
|
+
|
|
71
|
+
const blobs = new AzureBlobStore({
|
|
72
|
+
container: 'my-skill-blobs',
|
|
73
|
+
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Documentation
|
|
78
|
+
|
|
79
|
+
For more information, see the [Mastra Workspaces documentation](https://mastra.ai/docs/workspace/overview).
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BlobStore } from '@mastra/core/storage';
|
|
2
|
+
import type { StorageBlobEntry } from '@mastra/core/storage';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for AzureBlobStore.
|
|
5
|
+
*/
|
|
6
|
+
export interface AzureBlobStoreOptions {
|
|
7
|
+
/** Azure Blob container name */
|
|
8
|
+
container: string;
|
|
9
|
+
/** Storage account name (required unless using connectionString) */
|
|
10
|
+
accountName?: string;
|
|
11
|
+
/** Storage account key */
|
|
12
|
+
accountKey?: string;
|
|
13
|
+
/** SAS token for authentication */
|
|
14
|
+
sasToken?: string;
|
|
15
|
+
/** Full connection string (takes priority over accountName/accountKey) */
|
|
16
|
+
connectionString?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Use DefaultAzureCredential from @azure/identity for authentication.
|
|
19
|
+
* Requires @azure/identity to be installed as a peer dependency.
|
|
20
|
+
*/
|
|
21
|
+
useDefaultCredential?: boolean;
|
|
22
|
+
/** Custom endpoint URL (e.g. for the Azurite emulator) */
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Key prefix for all blob objects.
|
|
26
|
+
* Defaults to 'mastra_skill_blobs/'.
|
|
27
|
+
*/
|
|
28
|
+
prefix?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Azure Blob Storage-backed content-addressable blob store for skill versioning.
|
|
32
|
+
*
|
|
33
|
+
* Each blob is stored as a block blob keyed by its SHA-256 hash. Metadata
|
|
34
|
+
* (size, mimeType, createdAt) is stored as Azure blob metadata.
|
|
35
|
+
*
|
|
36
|
+
* Since blobs are content-addressable, writes are idempotent — the same hash
|
|
37
|
+
* always maps to the same content, so overwrites are safe and equivalent to
|
|
38
|
+
* a no-op.
|
|
39
|
+
*
|
|
40
|
+
* @example Connection string
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { AzureBlobStore } from '@mastra/azure/blob';
|
|
43
|
+
*
|
|
44
|
+
* const blobs = new AzureBlobStore({
|
|
45
|
+
* container: 'my-skill-blobs',
|
|
46
|
+
* connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING!,
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example Account key
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { AzureBlobStore } from '@mastra/azure/blob';
|
|
53
|
+
*
|
|
54
|
+
* const blobs = new AzureBlobStore({
|
|
55
|
+
* container: 'my-skill-blobs',
|
|
56
|
+
* accountName: process.env.AZURE_STORAGE_ACCOUNT_NAME!,
|
|
57
|
+
* accountKey: process.env.AZURE_STORAGE_ACCOUNT_KEY!,
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class AzureBlobStore extends BlobStore {
|
|
62
|
+
private readonly containerName;
|
|
63
|
+
private readonly accountName?;
|
|
64
|
+
private readonly accountKey?;
|
|
65
|
+
private readonly sasToken?;
|
|
66
|
+
private readonly connectionString?;
|
|
67
|
+
private readonly useDefaultCredential;
|
|
68
|
+
private readonly endpoint?;
|
|
69
|
+
private readonly prefix;
|
|
70
|
+
private _containerClient;
|
|
71
|
+
constructor(options: AzureBlobStoreOptions);
|
|
72
|
+
private getContainerClient;
|
|
73
|
+
private toKey;
|
|
74
|
+
init(): Promise<void>;
|
|
75
|
+
put(entry: StorageBlobEntry): Promise<void>;
|
|
76
|
+
get(hash: string): Promise<StorageBlobEntry | null>;
|
|
77
|
+
has(hash: string): Promise<boolean>;
|
|
78
|
+
delete(hash: string): Promise<boolean>;
|
|
79
|
+
putMany(entries: StorageBlobEntry[]): Promise<void>;
|
|
80
|
+
getMany(hashes: string[]): Promise<Map<string, StorageBlobEntry>>;
|
|
81
|
+
dangerouslyClearAll(): Promise<void>;
|
|
82
|
+
private deleteBlobBatch;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/blob/blob-store/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,cAAe,SAAQ,SAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,gBAAgB,CAAgC;gBAE5C,OAAO,EAAE,qBAAqB;YAY5B,kBAAkB;IA8ChC,OAAO,CAAC,KAAK;IAIP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB3C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAuBnD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAanC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOtC,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAajE,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;YAiB5B,eAAe;CAI9B"}
|
package/dist/blob/index.cjs
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJLBSGA65_cjs = require('../chunk-JLBSGA65.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "AzureBlobFilesystem", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkJLBSGA65_cjs.AzureBlobFilesystem; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "AzureBlobStore", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkJLBSGA65_cjs.AzureBlobStore; }
|
|
10
14
|
});
|
|
11
15
|
Object.defineProperty(exports, "azureBlobFilesystemProvider", {
|
|
12
16
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkJLBSGA65_cjs.azureBlobFilesystemProvider; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "azureBlobStoreProvider", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkJLBSGA65_cjs.azureBlobStoreProvider; }
|
|
14
22
|
});
|
|
15
23
|
//# sourceMappingURL=index.cjs.map
|
|
16
24
|
//# sourceMappingURL=index.cjs.map
|
package/dist/blob/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mastra/azure/blob - Azure Blob Storage Filesystem Provider
|
|
2
|
+
* @mastra/azure/blob - Azure Blob Storage Filesystem & Blob Store Provider
|
|
3
3
|
*
|
|
4
|
-
* A filesystem
|
|
4
|
+
* A filesystem and content-addressable blob store backed by Azure Blob Storage.
|
|
5
5
|
*/
|
|
6
6
|
export { AzureBlobFilesystem, type AzureBlobFilesystemOptions, type AzureBlobMountConfig } from './filesystem/index.js';
|
|
7
|
-
export {
|
|
7
|
+
export { AzureBlobStore, type AzureBlobStoreOptions } from './blob-store/index.js';
|
|
8
|
+
export { azureBlobFilesystemProvider, azureBlobStoreProvider } from './provider.js';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/blob/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blob/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,KAAK,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blob/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,KAAK,0BAA0B,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/blob/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AzureBlobFilesystem, azureBlobFilesystemProvider } from '../chunk-
|
|
1
|
+
export { AzureBlobFilesystem, AzureBlobStore, azureBlobFilesystemProvider, azureBlobStoreProvider } from '../chunk-DBBJ2YM7.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/blob/provider.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { FilesystemProvider } from '@mastra/core/editor';
|
|
1
|
+
import type { BlobStoreProvider, FilesystemProvider } from '@mastra/core/editor';
|
|
2
|
+
import type { AzureBlobStoreOptions } from './blob-store/index.js';
|
|
2
3
|
import type { AzureBlobFilesystemOptions } from './filesystem/index.js';
|
|
3
4
|
export declare const azureBlobFilesystemProvider: FilesystemProvider<AzureBlobFilesystemOptions>;
|
|
5
|
+
export declare const azureBlobStoreProvider: BlobStoreProvider<AzureBlobStoreOptions>;
|
|
4
6
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/blob/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/blob/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE/D,eAAO,MAAM,2BAA2B,EAAE,kBAAkB,CAAC,0BAA0B,CAwBtF,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,qBAAqB,CAuB3E,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BlobServiceClient, StorageSharedKeyCredential, BlobSASPermissions } from '@azure/storage-blob';
|
|
2
2
|
import { MastraFilesystem, PermissionError, FileNotFoundError, FileExistsError } from '@mastra/core/workspace';
|
|
3
|
+
import { BlobStore } from '@mastra/core/storage';
|
|
3
4
|
|
|
4
5
|
// src/blob/filesystem/index.ts
|
|
5
6
|
var MIME_TYPES = {
|
|
@@ -537,6 +538,167 @@ var AzureBlobFilesystem = class extends MastraFilesystem {
|
|
|
537
538
|
this._containerClient = null;
|
|
538
539
|
}
|
|
539
540
|
};
|
|
541
|
+
function trimSlashes2(s) {
|
|
542
|
+
let start = 0;
|
|
543
|
+
let end = s.length;
|
|
544
|
+
while (start < end && s[start] === "/") start++;
|
|
545
|
+
while (end > start && s[end - 1] === "/") end--;
|
|
546
|
+
return s.slice(start, end);
|
|
547
|
+
}
|
|
548
|
+
function isNotFoundError2(error) {
|
|
549
|
+
if (!error || typeof error !== "object") return false;
|
|
550
|
+
return error.statusCode === 404;
|
|
551
|
+
}
|
|
552
|
+
var BATCH_DELETE_SIZE = 256;
|
|
553
|
+
var AzureBlobStore = class extends BlobStore {
|
|
554
|
+
containerName;
|
|
555
|
+
accountName;
|
|
556
|
+
accountKey;
|
|
557
|
+
sasToken;
|
|
558
|
+
connectionString;
|
|
559
|
+
useDefaultCredential;
|
|
560
|
+
endpoint;
|
|
561
|
+
prefix;
|
|
562
|
+
_containerClient = null;
|
|
563
|
+
constructor(options) {
|
|
564
|
+
super();
|
|
565
|
+
this.containerName = options.container;
|
|
566
|
+
this.accountName = options.accountName;
|
|
567
|
+
this.accountKey = options.accountKey;
|
|
568
|
+
this.sasToken = options.sasToken;
|
|
569
|
+
this.connectionString = options.connectionString;
|
|
570
|
+
this.useDefaultCredential = options.useDefaultCredential ?? false;
|
|
571
|
+
this.endpoint = options.endpoint;
|
|
572
|
+
this.prefix = options.prefix ? trimSlashes2(options.prefix) + "/" : "mastra_skill_blobs/";
|
|
573
|
+
}
|
|
574
|
+
async getContainerClient() {
|
|
575
|
+
if (this._containerClient) return this._containerClient;
|
|
576
|
+
let serviceClient;
|
|
577
|
+
if (this.connectionString) {
|
|
578
|
+
serviceClient = BlobServiceClient.fromConnectionString(this.connectionString);
|
|
579
|
+
} else {
|
|
580
|
+
if (!this.endpoint && !this.accountName) {
|
|
581
|
+
throw new Error(
|
|
582
|
+
"Azure Blob Storage requires either a connectionString, or an accountName/endpoint. Provide at least one of: connectionString, accountName, or endpoint."
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
const baseUrl = this.endpoint ?? `https://${this.accountName}.blob.core.windows.net`;
|
|
586
|
+
if (this.accountName && this.accountKey) {
|
|
587
|
+
const credential = new StorageSharedKeyCredential(this.accountName, this.accountKey);
|
|
588
|
+
serviceClient = new BlobServiceClient(baseUrl, credential);
|
|
589
|
+
} else if (this.sasToken) {
|
|
590
|
+
const sas = this.sasToken.replace(/^\?+/, "");
|
|
591
|
+
const separator = baseUrl.includes("?") ? "&" : "?";
|
|
592
|
+
serviceClient = new BlobServiceClient(`${baseUrl}${separator}${sas}`);
|
|
593
|
+
} else if (this.useDefaultCredential) {
|
|
594
|
+
try {
|
|
595
|
+
const identity = await import('@azure/identity');
|
|
596
|
+
const credential = new identity.DefaultAzureCredential();
|
|
597
|
+
serviceClient = new BlobServiceClient(baseUrl, credential);
|
|
598
|
+
} catch {
|
|
599
|
+
throw new Error(
|
|
600
|
+
"DefaultAzureCredential requires @azure/identity to be installed. Install it with: npm install @azure/identity"
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
} else {
|
|
604
|
+
serviceClient = new BlobServiceClient(baseUrl);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
this._containerClient = serviceClient.getContainerClient(this.containerName);
|
|
608
|
+
return this._containerClient;
|
|
609
|
+
}
|
|
610
|
+
toKey(hash) {
|
|
611
|
+
return this.prefix + hash;
|
|
612
|
+
}
|
|
613
|
+
async init() {
|
|
614
|
+
}
|
|
615
|
+
async put(entry) {
|
|
616
|
+
const containerClient = await this.getContainerClient();
|
|
617
|
+
const blobClient = containerClient.getBlockBlobClient(this.toKey(entry.hash));
|
|
618
|
+
const now = entry.createdAt ?? /* @__PURE__ */ new Date();
|
|
619
|
+
const buffer = Buffer.from(entry.content, "utf-8");
|
|
620
|
+
await blobClient.uploadData(buffer, {
|
|
621
|
+
blobHTTPHeaders: {
|
|
622
|
+
blobContentType: entry.mimeType ?? "application/octet-stream"
|
|
623
|
+
},
|
|
624
|
+
metadata: {
|
|
625
|
+
size: String(entry.size),
|
|
626
|
+
createdat: now.toISOString(),
|
|
627
|
+
...entry.mimeType ? { mimetype: entry.mimeType } : {}
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
async get(hash) {
|
|
632
|
+
const containerClient = await this.getContainerClient();
|
|
633
|
+
const blobClient = containerClient.getBlockBlobClient(this.toKey(hash));
|
|
634
|
+
try {
|
|
635
|
+
const buffer = await blobClient.downloadToBuffer();
|
|
636
|
+
const properties = await blobClient.getProperties();
|
|
637
|
+
const metadata = properties.metadata ?? {};
|
|
638
|
+
const content = buffer.toString("utf-8");
|
|
639
|
+
return {
|
|
640
|
+
hash,
|
|
641
|
+
content,
|
|
642
|
+
size: metadata.size != null ? Number(metadata.size) : Buffer.byteLength(content, "utf-8"),
|
|
643
|
+
mimeType: metadata.mimetype || properties.contentType || void 0,
|
|
644
|
+
createdAt: metadata.createdat ? new Date(metadata.createdat) : /* @__PURE__ */ new Date()
|
|
645
|
+
};
|
|
646
|
+
} catch (error) {
|
|
647
|
+
if (isNotFoundError2(error)) return null;
|
|
648
|
+
throw error;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
async has(hash) {
|
|
652
|
+
const containerClient = await this.getContainerClient();
|
|
653
|
+
const blobClient = containerClient.getBlockBlobClient(this.toKey(hash));
|
|
654
|
+
try {
|
|
655
|
+
await blobClient.getProperties();
|
|
656
|
+
return true;
|
|
657
|
+
} catch (error) {
|
|
658
|
+
if (isNotFoundError2(error)) return false;
|
|
659
|
+
throw error;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
async delete(hash) {
|
|
663
|
+
const containerClient = await this.getContainerClient();
|
|
664
|
+
const blobClient = containerClient.getBlockBlobClient(this.toKey(hash));
|
|
665
|
+
const response = await blobClient.deleteIfExists();
|
|
666
|
+
return response.succeeded;
|
|
667
|
+
}
|
|
668
|
+
async putMany(entries) {
|
|
669
|
+
if (entries.length === 0) return;
|
|
670
|
+
await Promise.all(entries.map((entry) => this.put(entry)));
|
|
671
|
+
}
|
|
672
|
+
async getMany(hashes) {
|
|
673
|
+
const result = /* @__PURE__ */ new Map();
|
|
674
|
+
if (hashes.length === 0) return result;
|
|
675
|
+
const entries = await Promise.all(hashes.map((hash) => this.get(hash)));
|
|
676
|
+
for (const entry of entries) {
|
|
677
|
+
if (entry) {
|
|
678
|
+
result.set(entry.hash, entry);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return result;
|
|
682
|
+
}
|
|
683
|
+
async dangerouslyClearAll() {
|
|
684
|
+
const containerClient = await this.getContainerClient();
|
|
685
|
+
let batch = [];
|
|
686
|
+
for await (const blob of containerClient.listBlobsFlat({ prefix: this.prefix })) {
|
|
687
|
+
batch.push(blob.name);
|
|
688
|
+
if (batch.length >= BATCH_DELETE_SIZE) {
|
|
689
|
+
await this.deleteBlobBatch(containerClient, batch);
|
|
690
|
+
batch = [];
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (batch.length > 0) {
|
|
694
|
+
await this.deleteBlobBatch(containerClient, batch);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
async deleteBlobBatch(containerClient, blobNames) {
|
|
698
|
+
const blobClients = blobNames.map((name) => containerClient.getBlobClient(name));
|
|
699
|
+
await containerClient.getBlobBatchClient().deleteBlobs(blobClients);
|
|
700
|
+
}
|
|
701
|
+
};
|
|
540
702
|
|
|
541
703
|
// src/blob/provider.ts
|
|
542
704
|
var azureBlobFilesystemProvider = {
|
|
@@ -564,7 +726,31 @@ var azureBlobFilesystemProvider = {
|
|
|
564
726
|
},
|
|
565
727
|
createFilesystem: (config) => new AzureBlobFilesystem(config)
|
|
566
728
|
};
|
|
729
|
+
var azureBlobStoreProvider = {
|
|
730
|
+
id: "azure-blob",
|
|
731
|
+
name: "Azure Blob Store",
|
|
732
|
+
description: "Content-addressable blob storage backed by Azure Blob Storage",
|
|
733
|
+
configSchema: {
|
|
734
|
+
type: "object",
|
|
735
|
+
required: ["container"],
|
|
736
|
+
properties: {
|
|
737
|
+
container: { type: "string", description: "Azure Blob container name" },
|
|
738
|
+
accountName: { type: "string", description: "Storage account name" },
|
|
739
|
+
accountKey: { type: "string", description: "Storage account key" },
|
|
740
|
+
sasToken: { type: "string", description: "Shared Access Signature token" },
|
|
741
|
+
connectionString: { type: "string", description: "Full connection string (overrides other auth options)" },
|
|
742
|
+
useDefaultCredential: {
|
|
743
|
+
type: "boolean",
|
|
744
|
+
description: "Use DefaultAzureCredential (requires @azure/identity)",
|
|
745
|
+
default: false
|
|
746
|
+
},
|
|
747
|
+
prefix: { type: "string", description: "Key prefix for blob objects (default: mastra_skill_blobs/)" },
|
|
748
|
+
endpoint: { type: "string", description: "Custom endpoint URL (for Azurite emulator)" }
|
|
749
|
+
}
|
|
750
|
+
},
|
|
751
|
+
createBlobStore: (config) => new AzureBlobStore(config)
|
|
752
|
+
};
|
|
567
753
|
|
|
568
|
-
export { AzureBlobFilesystem, azureBlobFilesystemProvider };
|
|
569
|
-
//# sourceMappingURL=chunk-
|
|
570
|
-
//# sourceMappingURL=chunk-
|
|
754
|
+
export { AzureBlobFilesystem, AzureBlobStore, azureBlobFilesystemProvider, azureBlobStoreProvider };
|
|
755
|
+
//# sourceMappingURL=chunk-DBBJ2YM7.js.map
|
|
756
|
+
//# sourceMappingURL=chunk-DBBJ2YM7.js.map
|