@mastra/core 1.7.0-alpha.0 → 1.7.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 +119 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-HYU6AULN.cjs → chunk-2X66GWF5.cjs} +11 -3
- package/dist/chunk-2X66GWF5.cjs.map +1 -0
- package/dist/{chunk-WR5RUKVK.js → chunk-6OXW5E2O.js} +3 -3
- package/dist/{chunk-WR5RUKVK.js.map → chunk-6OXW5E2O.js.map} +1 -1
- package/dist/{chunk-S3JIVN4S.cjs → chunk-6QBN6MZY.cjs} +14 -14
- package/dist/{chunk-S3JIVN4S.cjs.map → chunk-6QBN6MZY.cjs.map} +1 -1
- package/dist/{chunk-OL4P6TXG.cjs → chunk-A72NTLFT.cjs} +5 -5
- package/dist/{chunk-OL4P6TXG.cjs.map → chunk-A72NTLFT.cjs.map} +1 -1
- package/dist/{chunk-T4KRCLC3.cjs → chunk-HB6T4554.cjs} +6 -6
- package/dist/{chunk-T4KRCLC3.cjs.map → chunk-HB6T4554.cjs.map} +1 -1
- package/dist/{chunk-HZ33YLNC.js → chunk-KUXNBWN7.js} +4 -4
- package/dist/{chunk-HZ33YLNC.js.map → chunk-KUXNBWN7.js.map} +1 -1
- package/dist/{chunk-6NRSTTAS.js → chunk-QSHV7GPT.js} +11 -3
- package/dist/chunk-QSHV7GPT.js.map +1 -0
- package/dist/{chunk-N435UBEN.cjs → chunk-QTAS3HND.cjs} +5 -5
- package/dist/{chunk-N435UBEN.cjs.map → chunk-QTAS3HND.cjs.map} +1 -1
- package/dist/{chunk-WBVBORCZ.js → chunk-QWTB53GS.js} +3 -3
- package/dist/{chunk-WBVBORCZ.js.map → chunk-QWTB53GS.js.map} +1 -1
- package/dist/{chunk-6RTFK6XW.js → chunk-R4N65TLG.js} +7 -7
- package/dist/{chunk-6RTFK6XW.js.map → chunk-R4N65TLG.js.map} +1 -1
- package/dist/{chunk-NAUBU4SI.cjs → chunk-RABITNTG.cjs} +46 -46
- package/dist/{chunk-NAUBU4SI.cjs.map → chunk-RABITNTG.cjs.map} +1 -1
- package/dist/{chunk-NHYSIYTD.js → chunk-T6GAM3SQ.js} +3 -3
- package/dist/{chunk-NHYSIYTD.js.map → chunk-T6GAM3SQ.js.map} +1 -1
- package/dist/datasets/index.cjs +11 -11
- package/dist/datasets/index.js +1 -1
- package/dist/evals/index.cjs +5 -5
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +3 -3
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/harness/index.cjs +2 -2
- package/dist/harness/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/processor-provider/index.cjs +10 -10
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +42 -42
- package/dist/processors/index.js +1 -1
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/package.json +7 -7
- package/dist/chunk-6NRSTTAS.js.map +0 -1
- package/dist/chunk-HYU6AULN.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,124 @@
|
|
|
1
1
|
# @mastra/core
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `getObservationalMemoryRecord()` method to the `Harness` class. Fixes #13392. ([#13395](https://github.com/mastra-ai/mastra/pull/13395))
|
|
8
|
+
|
|
9
|
+
This provides public access to the full `ObservationalMemoryRecord` for the current thread, including `activeObservations`, `generationCount`, and `observationTokenCount`. Previously, accessing raw observation text required bypassing the Harness abstraction by reaching into private storage internals.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const record = await harness.getObservationalMemoryRecord();
|
|
13
|
+
if (record) {
|
|
14
|
+
console.log(record.activeObservations);
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- Added `Workspace.setToolsConfig()` method for dynamically updating per-tool configuration at runtime without recreating the workspace instance. Passing `undefined` re-enables all tools. ([#13439](https://github.com/mastra-ai/mastra/pull/13439))
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const workspace = new Workspace({ filesystem, sandbox });
|
|
22
|
+
|
|
23
|
+
// Disable write tools (e.g., in plan/read-only mode)
|
|
24
|
+
workspace.setToolsConfig({
|
|
25
|
+
mastra_workspace_write_file: { enabled: false },
|
|
26
|
+
mastra_workspace_edit_file: { enabled: false },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Re-enable all tools
|
|
30
|
+
workspace.setToolsConfig(undefined);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- Added `HarnessDisplayState` so any UI can read a single state snapshot instead of handling 35+ individual events. ([#13427](https://github.com/mastra-ai/mastra/pull/13427))
|
|
34
|
+
|
|
35
|
+
**Why:** Previously, every UI (TUI, web, desktop) had to subscribe to dozens of granular Harness events and independently reconstruct what to display. This led to duplicated state tracking and inconsistencies across UI implementations. Now the Harness maintains a single canonical display state that any UI can read.
|
|
36
|
+
|
|
37
|
+
**Before:** UIs subscribed to raw events and built up display state locally:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
harness.subscribe((event) => {
|
|
41
|
+
if (event.type === 'agent_start') localState.isRunning = true;
|
|
42
|
+
if (event.type === 'agent_end') localState.isRunning = false;
|
|
43
|
+
if (event.type === 'tool_start') localState.tools.set(event.toolCallId, ...);
|
|
44
|
+
// ... 30+ more event types to handle
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**After:** UIs read a single snapshot from the Harness:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import type { HarnessDisplayState } from '@mastra/core/harness';
|
|
52
|
+
|
|
53
|
+
harness.subscribe(event => {
|
|
54
|
+
const ds: HarnessDisplayState = harness.getDisplayState();
|
|
55
|
+
// ds.isRunning, ds.tokenUsage, ds.omProgress, ds.activeTools, etc.
|
|
56
|
+
renderUI(ds);
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- Prompt blocks can now define their own variables schema (`requestContextSchema`), allowing you to create reusable prompt blocks with typed variable placeholders. The server now correctly computes and returns draft/published status for prompt blocks. Existing databases are automatically migrated when upgrading. ([#13351](https://github.com/mastra-ai/mastra/pull/13351))
|
|
61
|
+
|
|
62
|
+
- **Workspace instruction improvements** ([#13304](https://github.com/mastra-ai/mastra/pull/13304))
|
|
63
|
+
- Added `Workspace.getInstructions()`: agents now receive accurate workspace context that distinguishes sandbox-accessible paths from workspace-only paths.
|
|
64
|
+
- Added `WorkspaceInstructionsProcessor`: workspace context is injected directly into the agent system message instead of embedded in tool descriptions.
|
|
65
|
+
- Deprecated `Workspace.getPathContext()` in favour of `getInstructions()`.
|
|
66
|
+
|
|
67
|
+
Added `instructions` option to `LocalFilesystem` and `LocalSandbox`. Pass a string to fully replace default instructions, or a function to extend them with access to the current `requestContext` for per-request customization (e.g. by tenant or locale).
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const filesystem = new LocalFilesystem({
|
|
71
|
+
basePath: './workspace',
|
|
72
|
+
instructions: ({ defaultInstructions, requestContext }) => {
|
|
73
|
+
const locale = requestContext?.get('locale') ?? 'en';
|
|
74
|
+
return `${defaultInstructions}\nLocale: ${locale}`;
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- Added background process management to workspace sandboxes. ([#13293](https://github.com/mastra-ai/mastra/pull/13293))
|
|
80
|
+
|
|
81
|
+
You can now spawn, monitor, and manage long-running background processes (dev servers, watchers, REPLs) inside sandbox environments.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// Spawn a background process
|
|
85
|
+
const handle = await sandbox.processes.spawn('node server.js');
|
|
86
|
+
|
|
87
|
+
// Stream output and wait for exit
|
|
88
|
+
const result = await handle.wait({
|
|
89
|
+
onStdout: data => console.log(data),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// List and manage running processes
|
|
93
|
+
const procs = await sandbox.processes.list();
|
|
94
|
+
await sandbox.processes.kill(handle.pid);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- `SandboxProcessManager` abstract base class with `spawn()`, `list()`, `get(pid)`, `kill(pid)`
|
|
98
|
+
- `ProcessHandle` base class with stdout/stderr accumulation, streaming callbacks, and `wait()`
|
|
99
|
+
- `LocalProcessManager` implementation wrapping Node.js `child_process`
|
|
100
|
+
- Node.js stream interop via `handle.reader` / `handle.writer`
|
|
101
|
+
- Default `executeCommand` implementation built on process manager (spawn + wait)
|
|
102
|
+
|
|
103
|
+
- Added workspace tools for background process management and improved sandbox execution UI. ([#13309](https://github.com/mastra-ai/mastra/pull/13309))
|
|
104
|
+
- `execute_command` now supports `background: true` to spawn long-running processes and return a PID
|
|
105
|
+
- New `get_process_output` tool to check output/status of background processes (supports `wait` to block until exit)
|
|
106
|
+
- New `kill_process` tool to terminate background processes
|
|
107
|
+
- Output truncation helpers with configurable tail lines
|
|
108
|
+
- Sandbox execution badge UI: terminal-style output display with streaming, exit codes, killed status, and workspace metadata
|
|
109
|
+
|
|
110
|
+
### Patch Changes
|
|
111
|
+
|
|
112
|
+
- Fixed agents-as-tools failing with OpenAI when using the model router. The auto-injected `resumeData` field (from `z.any()`) produced a JSON Schema without a `type` key, which OpenAI rejects. Tool schemas are now post-processed to ensure all properties have valid type information. ([#13326](https://github.com/mastra-ai/mastra/pull/13326))
|
|
113
|
+
|
|
114
|
+
- Fixed `stopWhen` callback receiving empty `toolResults` on steps. `step.toolResults` now correctly reflects the tool results present in `step.content`. ([#13319](https://github.com/mastra-ai/mastra/pull/13319))
|
|
115
|
+
|
|
116
|
+
- Added `hasJudge` metadata to scorer records so the studio can distinguish code-based scorers (e.g., textual-difference, content-similarity) from LLM-based scorers. This metadata is now included in all four score-saving paths: `runEvals`, scorer hooks, trace scoring, and dataset experiments. ([#13386](https://github.com/mastra-ai/mastra/pull/13386))
|
|
117
|
+
|
|
118
|
+
- Fixed a bug where custom output processors could not emit stream events during final output processing. The `writer` object was always `undefined` when passed to output processors in the finish phase, preventing use cases like streaming moderation updates or custom UI events back to the client. ([#13454](https://github.com/mastra-ai/mastra/pull/13454))
|
|
119
|
+
|
|
120
|
+
- Added per-file write locking to workspace tools (edit_file, write_file, ast_edit, delete). Concurrent tool calls targeting the same file are now serialized, preventing race conditions where parallel edits could silently overwrite each other. ([#13302](https://github.com/mastra-ai/mastra/pull/13302))
|
|
121
|
+
|
|
3
122
|
## 1.7.0-alpha.0
|
|
4
123
|
|
|
5
124
|
### Minor Changes
|
package/dist/agent/index.cjs
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2X66GWF5_cjs = require('../chunk-2X66GWF5.cjs');
|
|
4
4
|
var chunkDB7U2C5B_cjs = require('../chunk-DB7U2C5B.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "Agent", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunk2X66GWF5_cjs.Agent; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "TripWire", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk2X66GWF5_cjs.TripWire; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "isSupportedLanguageModel", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunk2X66GWF5_cjs.isSupportedLanguageModel; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "resolveThreadIdFromArgs", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunk2X66GWF5_cjs.resolveThreadIdFromArgs; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "supportedLanguageModelSpecifications", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunk2X66GWF5_cjs.supportedLanguageModelSpecifications; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "tryGenerateWithJsonFallback", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunk2X66GWF5_cjs.tryGenerateWithJsonFallback; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "tryStreamWithJsonFallback", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunk2X66GWF5_cjs.tryStreamWithJsonFallback; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "MessageList", {
|
|
37
37
|
enumerable: true,
|
package/dist/agent/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Agent, TripWire, isSupportedLanguageModel, resolveThreadIdFromArgs, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback } from '../chunk-
|
|
1
|
+
export { Agent, TripWire, isSupportedLanguageModel, resolveThreadIdFromArgs, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback } from '../chunk-QSHV7GPT.js';
|
|
2
2
|
export { MessageList, TypeDetector, aiV5ModelMessageToV2PromptMessage, convertMessages } from '../chunk-IC5OUWKJ.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -3112,10 +3112,18 @@ var MastraModelOutput = class extends chunkRO47SMI7_cjs.MastraBase {
|
|
|
3112
3112
|
if (self.processorRunner && !self.#options.isLLMExecutionStep) {
|
|
3113
3113
|
const lastStep = self.#bufferedSteps[self.#bufferedSteps.length - 1];
|
|
3114
3114
|
const originalText = lastStep?.text || "";
|
|
3115
|
+
const outputResultWriter = {
|
|
3116
|
+
custom: async (data) => {
|
|
3117
|
+
self.#emitChunk(data);
|
|
3118
|
+
controller.enqueue(data);
|
|
3119
|
+
}
|
|
3120
|
+
};
|
|
3115
3121
|
self.messageList = await self.processorRunner.runOutputProcessors(
|
|
3116
3122
|
self.messageList,
|
|
3117
3123
|
options.tracingContext,
|
|
3118
|
-
self.#options.requestContext
|
|
3124
|
+
self.#options.requestContext,
|
|
3125
|
+
0,
|
|
3126
|
+
outputResultWriter
|
|
3119
3127
|
);
|
|
3120
3128
|
const responseMessages = self.messageList.get.response.aiV4.core();
|
|
3121
3129
|
const lastResponseMessage = responseMessages[responseMessages.length - 1];
|
|
@@ -25516,5 +25524,5 @@ exports.validateStepRequestContext = validateStepRequestContext;
|
|
|
25516
25524
|
exports.validateStepResumeData = validateStepResumeData;
|
|
25517
25525
|
exports.validateStepStateData = validateStepStateData;
|
|
25518
25526
|
exports.validateStepSuspendData = validateStepSuspendData;
|
|
25519
|
-
//# sourceMappingURL=chunk-
|
|
25520
|
-
//# sourceMappingURL=chunk-
|
|
25527
|
+
//# sourceMappingURL=chunk-2X66GWF5.cjs.map
|
|
25528
|
+
//# sourceMappingURL=chunk-2X66GWF5.cjs.map
|