@mastra/platform 0.0.0 → 0.1.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/LICENSE.md +32 -0
- package/README.md +71 -4
- package/dist/browser/index.d.ts +18 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/index.cjs +709 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +695 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/index.d.ts +20 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/memory/client.d.ts +242 -0
- package/dist/memory/client.d.ts.map +1 -0
- package/dist/memory/index.d.ts +5 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/platform-memory.d.ts +86 -0
- package/dist/memory/platform-memory.d.ts.map +1 -0
- package/package.json +61 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
- `@mastra/core/auth/ee`
|
|
6
|
+
- `@mastra/core/agent-builder/ee`
|
|
7
|
+
- `@mastra/editor/ee`
|
|
8
|
+
|
|
9
|
+
is licensed under the license defined in [`ee/LICENSE`](https://github.com/mastra-ai/mastra/blob/main/ee/LICENSE).
|
|
10
|
+
|
|
11
|
+
- All third-party components incorporated into the Mastra Software are
|
|
12
|
+
licensed under the original license provided by the owner of the
|
|
13
|
+
applicable component.
|
|
14
|
+
|
|
15
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
16
|
+
available under the "Apache License 2.0" as defined below.
|
|
17
|
+
|
|
18
|
+
# Apache License 2.0
|
|
19
|
+
|
|
20
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
21
|
+
|
|
22
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
23
|
+
you may not use this file except in compliance with the License.
|
|
24
|
+
You may obtain a copy of the License at
|
|
25
|
+
|
|
26
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
|
|
28
|
+
Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
+
See the License for the specific language governing permissions and
|
|
32
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,9 +1,76 @@
|
|
|
1
|
-
# @mastra/platform
|
|
1
|
+
# @mastra/platform (experimental)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Hosted Mastra Platform clients for Memory, Knowledge, and Browser, with Sandbox and Filesystem re-exported from the `@mastra/platform-workspace` dependency.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
+
```sh
|
|
8
|
+
npm install @mastra/platform
|
|
7
9
|
```
|
|
8
|
-
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Set `MASTRA_PLATFORM_ACCESS_TOKEN` (or `MASTRA_PLATFORM_SECRET_KEY`). `PlatformMemory` also needs `MASTRA_MEMORY_INSTANCE_ID` and `PlatformKnowledge` needs `MASTRA_KNOWLEDGE_INSTANCE_ID`; the example below uses both, so set both IDs. Obtain your instance IDs and credentials from Mastra Platform.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Agent } from '@mastra/core/agent';
|
|
17
|
+
import { PlatformMemory, PlatformKnowledge } from '@mastra/platform';
|
|
18
|
+
|
|
19
|
+
const model = 'openai/gpt-4o-mini';
|
|
20
|
+
const agent = new Agent({
|
|
21
|
+
name: 'assistant',
|
|
22
|
+
model,
|
|
23
|
+
memory: new PlatformMemory(),
|
|
24
|
+
});
|
|
25
|
+
const knowledge = new PlatformKnowledge();
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`PlatformSandbox` and `PlatformFilesystem` are also available from `@mastra/platform`.
|
|
29
|
+
|
|
30
|
+
### Hosted browser
|
|
31
|
+
|
|
32
|
+
Create a hosted browser from your Mastra Platform project's browser page, then pass its CDP URL to `PlatformBrowser`. Treat the CDP URL as a secret: anyone holding it can connect to that browser. Keep it server-side, do not commit it, and use a secure environment variable such as `MASTRA_BROWSER_CDP_URL`.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { Agent } from '@mastra/core/agent';
|
|
36
|
+
import { PlatformBrowser } from '@mastra/platform';
|
|
37
|
+
|
|
38
|
+
const agent = new Agent({
|
|
39
|
+
name: 'browser-agent',
|
|
40
|
+
model: 'openai/gpt-4o-mini',
|
|
41
|
+
browser: new PlatformBrowser({ cdpUrl: process.env.MASTRA_BROWSER_CDP_URL! }),
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Alternatively, provide a Mastra Platform project ID and access token to provision a new Browserbase-backed session on demand. Browserbase credentials stay on the Platform server.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const browser = new PlatformBrowser({ projectId: 'your-project-id' });
|
|
9
49
|
```
|
|
50
|
+
|
|
51
|
+
`PlatformBrowser` uses `MASTRA_PLATFORM_ACCESS_TOKEN` or `MASTRA_PLATFORM_SECRET_KEY` and `MASTRA_PROJECT_ID` when the corresponding options are omitted for on-demand provisioning. It POSTs `{ projectId }` to `https://platform.mastra.ai/v1/browsers/sessions` (overridable with `apiUrl` or `MASTRA_BROWSER_API_URL`) and connects to the returned CDP URL with shared browser scope. A project access token must be authorized for that project. Supplying `cdpUrl` skips provisioning and does not require a Platform token or project ID.
|
|
52
|
+
|
|
53
|
+
### Knowledge transport contract
|
|
54
|
+
|
|
55
|
+
- `POST {apiUrl}/v1/knowledge/{instanceId}/operations/{operation}` with `Authorization: Bearer {accessToken}` and JSON body `{ input }`; returns `{ result }`.
|
|
56
|
+
- `instanceId` and `apiUrl` come from options or `MASTRA_KNOWLEDGE_INSTANCE_ID` and `MASTRA_KNOWLEDGE_API_URL`; `apiUrl` defaults to `https://knowledge-api.mastra.ai`. The service derives the authorized project from the instance and credential; `projectId` is accepted for compatibility but is not sent.
|
|
57
|
+
- `renameScopeDeclaration` is not forwarded and rejects with `KnowledgeUnsupportedCapabilityError`: its `check` callback cannot be sent to the hosted store.
|
|
58
|
+
- Credential priority: option `accessToken`, `MASTRA_PLATFORM_ACCESS_TOKEN`, `MASTRA_PLATFORM_SECRET_KEY`.
|
|
59
|
+
- The server checks that the instance belongs to the credential's organization and, for project-bound tokens, its project; it allowlists page-store operations and never accepts a connection string from the caller.
|
|
60
|
+
- Hosted Knowledge requires a core and PostgreSQL adapter release implementing the Knowledge pages-v4 contract; production release alignment remains pending.
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
`PlatformKnowledge` extends core `Knowledge` and delegates schema-v4 page-store operations to the hosted service. The provider, connection string, importer, and sync scheduler belong to Platform rather than this client. For general API concepts, see [Mastra documentation](https://mastra.ai/docs).
|
|
65
|
+
|
|
66
|
+
### Verification matrix
|
|
67
|
+
|
|
68
|
+
The same scenarios must run once with core `Knowledge` on local PostgreSQL and again with `PlatformKnowledge` against Compose-backed Platform: scope materialization and discovery; nested page create/update/move/delete; search and read; notes and links; pin visibility; editor/viewer access; agent tool attachment, including denial across scopes. Connect-backed source provisioning, import, and incremental re-sync require a separate linked-source scenario; host page writes alone do not prove this integration.
|
|
69
|
+
|
|
70
|
+
## Changelog
|
|
71
|
+
|
|
72
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/packages/platform/CHANGELOG.md).
|
|
73
|
+
|
|
74
|
+
## Support
|
|
75
|
+
|
|
76
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StagehandBrowser } from '@mastra/stagehand';
|
|
2
|
+
import type { StagehandBrowserConfig } from '@mastra/stagehand';
|
|
3
|
+
export interface PlatformBrowserOptions extends Omit<StagehandBrowserConfig, 'cdpUrl' | 'scope' | 'env' | 'apiKey' | 'projectId'> {
|
|
4
|
+
/** Existing Platform-provisioned CDP URL. When supplied, no API request or access token is needed. */
|
|
5
|
+
cdpUrl?: string;
|
|
6
|
+
/** Platform access token. Falls back to `MASTRA_PLATFORM_ACCESS_TOKEN`, then `MASTRA_PLATFORM_SECRET_KEY`. */
|
|
7
|
+
accessToken?: string;
|
|
8
|
+
/** Mastra Platform project ID. Falls back to `MASTRA_PROJECT_ID`. */
|
|
9
|
+
projectId?: string;
|
|
10
|
+
/** Browser provisioning API URL. Falls back to `MASTRA_BROWSER_API_URL`. */
|
|
11
|
+
apiUrl?: string;
|
|
12
|
+
fetch?: typeof fetch;
|
|
13
|
+
}
|
|
14
|
+
/** A Stagehand browser connected to a Platform-provisioned Browserbase session. */
|
|
15
|
+
export declare class PlatformBrowser extends StagehandBrowser {
|
|
16
|
+
constructor(options?: PlatformBrowserOptions);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,sBAAsB,EACtB,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,CACpD;IACC,sGAAsG;IACtG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8GAA8G;IAC9G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAUD,mFAAmF;AACnF,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD,YAAY,OAAO,GAAE,sBAA2B,EAwC/C;CACF"}
|