mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. ⚠️⚠️⚠️⚠️⚠️⚠️ `main` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `main`. ⚠️⚠️⚠️⚠️⚠️⚠️ # Releases ## @mastra/core@1.84.0-alpha.6 ### Minor Changes - Knowledge storage can supply scope declarations, access rules included. ([#29428](https://github.com/mastra-ai/mastra/pull/29428)) A store returns declarations from `getScopeDeclarations()` (none by default). Knowledge merges them under its config's: the config wins on a key both declare, and a declaration that doesn't compile is skipped with a warning. When stored scopes come from a skipped declaration, the declaration check's error names that declaration and why it was skipped, so it can be fixed in the store. The store's answer is reused for 30 seconds and read again after `renameScopeDeclaration`, so a declaration the store adds, removes or changes (access rules included) applies within that window without a store read on every call. Revoking access through the store can therefore take up to 30 seconds to take effect. ```ts class ImportingKnowledgeStorage extends InMemoryKnowledgeStorage { override async getScopeDeclarations() { return { 'imports:$name': {}, 'linear:$account:$connection': { access: [{ principal: 'imports:all', role: 'viewer' }] }, }; } } ``` Runs that hold `imports:all` then read every Linear connection's pages. ## @mastra/platform@0.1.0-alpha.1 ### Minor Changes - Added `PlatformBrowser`, a Stagehand browser backed by a Mastra Platform browser session. By default it provisions a session with `POST /v1/browsers/sessions` on the Platform and connects to the returned CDP URL; pass `cdpUrl` to connect to a session you already provisioned, with no token or API call. The access token falls back to `MASTRA_PLATFORM_ACCESS_TOKEN` / `MASTRA_PLATFORM_SECRET_KEY`, the project to `MASTRA_PROJECT_ID`, and the API URL to `MASTRA_BROWSER_API_URL`. `@mastra/platform` now depends on `@mastra/stagehand` at runtime. ([#29428](https://github.com/mastra-ai/mastra/pull/29428)) ```ts import { PlatformBrowser } from '@mastra/platform'; const agent = new Agent({ name: 'browser-agent', model, browser: new PlatformBrowser() }); ``` - Added `@mastra/platform`: hosted Mastra Platform Memory and Knowledge clients, with Platform Sandbox and Filesystem re-exported from `@mastra/platform-workspace`. `PlatformMemory` is a drop-in `memory` for `Agent` that loads observations and recent messages from a Platform Memory instance and saves each turn back; observation and reflection run on the Platform. `PlatformMemoryClient` exposes the same API directly. Credentials fall back to `MASTRA_PLATFORM_ACCESS_TOKEN` / `MASTRA_PLATFORM_SECRET_KEY`. `PlatformMemory` uses `MASTRA_MEMORY_INSTANCE_ID`; `PlatformKnowledge` uses `MASTRA_KNOWLEDGE_INSTANCE_ID`. `PlatformKnowledge` takes every scope declaration and access rule from its instance, Memory's and Platform importers' included, and has no `scopes` option. Agents read imported pages when their runs hold the scope an importer's rule grants (for now `imports:all`). ([#29428](https://github.com/mastra-ai/mastra/pull/29428)) ```ts import { PlatformMemory, PlatformKnowledge, PlatformSandbox, PlatformFilesystem } from '@mastra/platform'; const agent = new Agent({ name: 'assistant', model, memory: new PlatformMemory() }); ``` ### Patch Changes - `PlatformKnowledge` now supports listing pins: `knowledge_pin` with `kind: 'list'` pins a page's listing on hosted Knowledge instead of refusing it as an old storage adapter. ([#29428](https://github.com/mastra-ai/mastra/pull/29428)) - `PlatformMemory` fixes for read-only runs and working memory: ([#29428](https://github.com/mastra-ai/mastra/pull/29428)) - A read-only run (`memory: { options: { readOnly: true } }`) now sees the thread's observations and unobserved messages, read through the Memory instance's read-only context route. Before, it got no stored context at all. It still saves nothing and starts no observation. - The `workingMemory` option now delivers what it says: `readonly` and `tool` add the resource's stored working memory to each run's prompt, read fresh each run; `tool` also tells the agent to update it with `updateWorkingMemory`; `off` leaves it out. Before, stored working memory never reached the prompt in any mode. - Updated dependencies [[`0eb407e`]( |
History
|
|
|---|---|---|
| .. | ||
| _test-utils | ||
| inngest | ||
| temporal | ||
| oxlint.config.ts | ||
| README.md | ||
Inngest Workflow Engine
Run Mastra workflows with Inngest.
Workflow and step execution functionality is exposed via serve from @mastra/inngest.
This is a wrapper that detects all Mastra workflows created to run with Inngest and registers them to the Inngest server.
Steps and workflows are created using the createStep and createWorkflow functions initialized with init() from @mastra/inngest.
This makes sure that all the steps are ready and able to connect with the Inngets runtime, publish events for watching, etc.
The Inngest runtime is horizontally scalable, with watching and eventing working through the @inngest/realtime package.
Usage
Running inngest dev server
docker run --rm -p 8288:8288 \
inngest/inngest \
inngest dev -u http://host.docker.internal:4111/inngest/api
Example
import { init, serve as inngestServe } from '@mastra/inngest';
import { PinoLogger } from '@mastra/loggers';
import { Inngest } from 'inngest';
import { z } from 'zod';
const inngest = new Inngest({
id: 'mastra',
baseUrl: `http://localhost:8288`, // if using local dev server
});
const { createWorkflow, createStep } = init(inngest);
const incrementStep = createStep({
id: 'increment',
inputSchema: z.object({
value: z.number(),
}),
outputSchema: z.object({
value: z.number(),
}),
execute: async ({ inputData }) => {
return { value: inputData.value + 1 };
},
});
const sideEffectStep = createStep({
id: 'side-effect',
inputSchema: z.object({
value: z.number(),
}),
outputSchema: z.object({
value: z.number(),
}),
execute: async ({ inputData }) => {
console.log('log', inputData.value);
return { value: inputData.value };
},
});
const finalStep = createStep({
id: 'final',
inputSchema: z.object({
value: z.number(),
}),
outputSchema: z.object({
value: z.number(),
}),
execute: async ({ inputData }) => {
return { value: inputData.value };
},
});
const incrementWorkflow = createWorkflow({
id: 'increment-workflow',
inputSchema: z.object({
value: z.number(),
}),
outputSchema: z.object({
value: z.number(),
}),
})
.dountil(
createWorkflow({
id: 'increment-subworkflow',
inputSchema: z.object({
value: z.number(),
}),
outputSchema: z.object({
value: z.number(),
}),
steps: [incrementStep, sideEffectStep],
})
.then(incrementStep)
.then(sideEffectStep)
.commit(),
async ({ inputData }) => inputData.value >= 10,
)
.then(finalStep)
.commit();
export const mastra = new Mastra({
vnext_workflows: {
incrementWorkflow,
},
server: {
host: '0.0.0.0',
apiRoutes: [
{
path: '/inngest/api', // this needs to match the path in inngest dev server (or production) config
method: 'ALL',
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
},
],
},
logger: new PinoLogger({
name: 'Mastra',
level: 'info',
}),
});