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.2 ### Minor Changes - Added run metadata to background process callbacks. ([#30161](https://github.com/mastra-ai/mastra/pull/30161)) `backgroundProcesses` callbacks on `execute_command` now receive, when available, the `agentId`, `threadId`, `resourceId`, and `runId` of the call that started the process, so hosts can route exit notices to the right conversation. `onExit` also receives `killedByAbort`, which is `true` when the abort signal fired (the run's signal by default) and killed the process. ```ts backgroundProcesses: { onExit: ({ pid, exitCode, threadId, killedByAbort }) => { if (!killedByAbort) notifyThread(threadId, `Process ${pid} exited with code ${exitCode}`); }, }, ``` `truncateOutput` and `DEFAULT_TAIL_LINES` are now exported from `@mastra/core/workspace`, so hosts can trim process output the same way `execute_command` does. ### Patch Changes - Fixed retries in `dountil` and `dowhile` loops on the evented engine. Each iteration of a loop body now starts at `retryCount` 0 and gets the step's full `retries`, as on the default engine. Before, the count carried over from earlier iterations, so a body that failed once in a later iteration could run out of retries and fail the run. ([#30383](https://github.com/mastra-ai/mastra/pull/30383)) If your step code reads `retryCount` inside a loop body, it now gets the attempt within the current iteration. The loop condition receives the iteration number as `iterationCount`. To use it inside the body, pass it through the step's output or workflow state. - Fixed durable agent runs failing with `DURABLE_AGENT_EXECUTION_UNVERIFIED` when an ownership check took longer than the lease TTL (15 seconds by default) while the same process still held the run. These runs used to fail and lose their saved snapshots. They now keep running, and a step stops only when an ownership check fails, the claim can't be renewed before it expires, or another execution takes over the run. ([#30386](https://github.com/mastra-ai/mastra/pull/30386)) - Fixed workflow recovery restarting a run that is still executing, which ran its steps twice. `startAsync()` now takes the run's lease before it saves the first snapshot, so it resolves after the lease is taken and rejects if taking it fails. Runs of workflows whose `shouldPersistSnapshot` saves `waiting` but not `running` now hold a lease too, so recovery no longer restarts them while they execute or sleep. ([#30384](https://github.com/mastra-ai/mastra/pull/30384)) - `processToolResult` now sees and can rewrite a tool's `toModelOutput` result. Previously, when a tool mapped its result with `toModelOutput` (for example a file viewer returning images), output processors only saw and changed the raw result, and the mapped output, images included, still reached the next model call and stored history unchanged. ([#30401](https://github.com/mastra-ai/mastra/pull/30401)) The hook now receives `modelOutput`. To replace it, commit a `result`-state part that carries the new value in `providerMetadata.mastra.modelOutput`: ```ts processToolResult({ messageList, toolCallId, toolName, args, result, modelOutput }) { messageList.updateToolInvocation({ type: 'tool-invocation', toolInvocation: { state: 'result', toolCallId, toolName, args, result }, providerMetadata: { mastra: { modelOutput: shrinkImages(modelOutput) } }, }); } ``` A processor that replaces only `result`, or edits it in place, now has the new value mapped through `toModelOutput` again, so the model reads the mapping of the processed result rather than of the original. With several processors, each one receives the `modelOutput` the processor before it committed, so a later processor can't bring back an image an earlier one removed. This applies to both regular and durable agents. In durable agents, a `processToolResult` that throws now also keeps the unprocessed mapped output from the model, not only the raw result. ## @mastra/client-js@1.60.1-alpha.2 ### Patch Changes - Updated dependencies [[`7277766`]( |
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',
}),
});