@mastra/server 1.60.0-alpha.8 → 1.60.0-alpha.9
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 +7 -0
- package/dist/{dist-CpaK1qK1.cjs → dist-C2O8fRb-.cjs} +66 -7
- package/dist/dist-C2O8fRb-.cjs.map +1 -0
- package/dist/{dist-CpxQhZED.js → dist-DNaReo7-.js} +66 -7
- package/dist/{dist-CpxQhZED.js.map → dist-DNaReo7-.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/package.json +5 -5
- package/dist/dist-CpaK1qK1.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
+
## 1.60.0-alpha.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847)]:
|
|
8
|
+
- @mastra/core@1.60.0-alpha.9
|
|
9
|
+
|
|
3
10
|
## 1.60.0-alpha.8
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -4693,7 +4693,7 @@ function splitLines(text) {
|
|
|
4693
4693
|
return result;
|
|
4694
4694
|
}
|
|
4695
4695
|
//#endregion
|
|
4696
|
-
//#region ../memory/dist/src-
|
|
4696
|
+
//#region ../memory/dist/src-C-nmWgoF.js
|
|
4697
4697
|
var __defProp$3 = Object.defineProperty;
|
|
4698
4698
|
var __exportAll = (all, no_symbols) => {
|
|
4699
4699
|
let target = {};
|
|
@@ -26823,7 +26823,7 @@ var ObservationStep = class {
|
|
|
26823
26823
|
messageList.removeByIds(candidates.map((msg) => msg.id));
|
|
26824
26824
|
for (const msg of candidates) messageList.add(msg, "memory");
|
|
26825
26825
|
}
|
|
26826
|
-
om.buffer({
|
|
26826
|
+
om.trackBackgroundWork(om.buffer({
|
|
26827
26827
|
threadId,
|
|
26828
26828
|
resourceId,
|
|
26829
26829
|
messages: unobservedMessages,
|
|
@@ -26834,7 +26834,7 @@ var ObservationStep = class {
|
|
|
26834
26834
|
observabilityContext: this.turn.observabilityContext
|
|
26835
26835
|
}).catch((err) => {
|
|
26836
26836
|
omDebug(`[OM:buffer] fire-and-forget buffer failed: ${err?.message}`);
|
|
26837
|
-
});
|
|
26837
|
+
}));
|
|
26838
26838
|
buffered = true;
|
|
26839
26839
|
}
|
|
26840
26840
|
const willObserveNow = statusSnapshot.shouldObserve && !hasIncompleteToolCalls;
|
|
@@ -27200,7 +27200,7 @@ var ObservationTurn = class {
|
|
|
27200
27200
|
const allMessages = getObservableMessages(this.messageList);
|
|
27201
27201
|
const record = this._record;
|
|
27202
27202
|
const unobservedMessages = this.om.getUnobservedMessages(allMessages, record);
|
|
27203
|
-
if (unobservedMessages.length > 0) this.om.buffer({
|
|
27203
|
+
if (unobservedMessages.length > 0) this.om.trackBackgroundWork(this.om.buffer({
|
|
27204
27204
|
threadId: this.threadId,
|
|
27205
27205
|
resourceId: this.resourceId,
|
|
27206
27206
|
messages: unobservedMessages,
|
|
@@ -27214,7 +27214,7 @@ var ObservationTurn = class {
|
|
|
27214
27214
|
skipMinimumTokenCheck: true
|
|
27215
27215
|
}).catch((err) => {
|
|
27216
27216
|
omDebug(`[OM:turn.end] idle buffer failed: ${err?.message}`);
|
|
27217
|
-
});
|
|
27217
|
+
}));
|
|
27218
27218
|
}
|
|
27219
27219
|
return { record: this._record };
|
|
27220
27220
|
}
|
|
@@ -27694,6 +27694,8 @@ var ReflectorRunner = class {
|
|
|
27694
27694
|
};
|
|
27695
27695
|
let reflectedTokens = 0;
|
|
27696
27696
|
let attemptNumber = 0;
|
|
27697
|
+
/** Observations from the previous attempt, used to detect a no-progress ladder. */
|
|
27698
|
+
let previousObservations;
|
|
27697
27699
|
while (currentLevel <= maxLevel) {
|
|
27698
27700
|
attemptNumber++;
|
|
27699
27701
|
const isRetry = attemptNumber > 1;
|
|
@@ -27767,6 +27769,11 @@ var ReflectorRunner = class {
|
|
|
27767
27769
|
omDebug(`[OM:callReflector] degenerate output persists at maxLevel=${maxLevel}, breaking`);
|
|
27768
27770
|
break;
|
|
27769
27771
|
}
|
|
27772
|
+
if (!parsed.degenerate && previousObservations !== void 0 && parsed.observations === previousObservations) {
|
|
27773
|
+
omDebug(`[OM:callReflector] attempt #${attemptNumber} returned output identical to the previous attempt; escalating cannot help, stopping the ladder`);
|
|
27774
|
+
break;
|
|
27775
|
+
}
|
|
27776
|
+
previousObservations = parsed.observations;
|
|
27770
27777
|
if (streamContext?.writer) {
|
|
27771
27778
|
const failedMarker = createObservationFailedMarker({
|
|
27772
27779
|
cycleId: streamContext.cycleId,
|
|
@@ -28741,6 +28748,39 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
28741
28748
|
*/
|
|
28742
28749
|
recordInitializations = /* @__PURE__ */ new Map();
|
|
28743
28750
|
/**
|
|
28751
|
+
* In-flight fire-and-forget background cycles (buffered observation, reflection).
|
|
28752
|
+
* Tracked so callers can join them via `settled()` before closing a storage
|
|
28753
|
+
* connection they own — otherwise a background cycle's tail statements race the close.
|
|
28754
|
+
*/
|
|
28755
|
+
pendingBackgroundWork = /* @__PURE__ */ new Set();
|
|
28756
|
+
/**
|
|
28757
|
+
* Register fire-and-forget background work so `settled()` can join it.
|
|
28758
|
+
* Returns the original promise so callers keep their own rejection handling.
|
|
28759
|
+
*/
|
|
28760
|
+
trackBackgroundWork(work) {
|
|
28761
|
+
const tracked = work.catch(() => {}).finally(() => {
|
|
28762
|
+
this.pendingBackgroundWork.delete(tracked);
|
|
28763
|
+
});
|
|
28764
|
+
this.pendingBackgroundWork.add(tracked);
|
|
28765
|
+
return work;
|
|
28766
|
+
}
|
|
28767
|
+
/**
|
|
28768
|
+
* Resolve once all background observational-memory work started so far has finished.
|
|
28769
|
+
*
|
|
28770
|
+
* Background cycles enqueue further background work (a buffered observation can
|
|
28771
|
+
* trigger a reflection, which runs nested agent streams), so this drains repeatedly
|
|
28772
|
+
* until nothing is left rather than joining a single snapshot.
|
|
28773
|
+
*/
|
|
28774
|
+
async settled() {
|
|
28775
|
+
const maxDrainRounds = 100;
|
|
28776
|
+
for (let round = 0; round < maxDrainRounds; round++) {
|
|
28777
|
+
if (this.pendingBackgroundWork.size === 0) return;
|
|
28778
|
+
await Promise.allSettled([...this.pendingBackgroundWork]);
|
|
28779
|
+
}
|
|
28780
|
+
if (this.pendingBackgroundWork.size === 0) return;
|
|
28781
|
+
omError(`[OM:settled] background work still pending after ${maxDrainRounds} drain rounds; giving up waiting`);
|
|
28782
|
+
}
|
|
28783
|
+
/**
|
|
28744
28784
|
* Acquire a lock for the given key, execute the callback, then release.
|
|
28745
28785
|
* If a lock is already held, waits for it to be released before acquiring.
|
|
28746
28786
|
*/
|
|
@@ -29741,7 +29781,7 @@ ${formattedMessages}
|
|
|
29741
29781
|
if (!this.buffering.isAsyncObservationEnabled()) return false;
|
|
29742
29782
|
const lockKey = this.buffering.getLockKey(opts.threadId, opts.resourceId);
|
|
29743
29783
|
const shouldTrigger = this.buffering.shouldTriggerAsyncObservation(opts.pendingTokens, lockKey, opts.record, this.storage, opts.threshold);
|
|
29744
|
-
if (shouldTrigger) this.startAsyncBufferedObservation(opts.record, opts.threadId, opts.unobservedMessages, lockKey, opts.writer, opts.unbufferedPendingTokens, opts.requestContext);
|
|
29784
|
+
if (shouldTrigger) this.trackBackgroundWork(this.startAsyncBufferedObservation(opts.record, opts.threadId, opts.unobservedMessages, lockKey, opts.writer, opts.unbufferedPendingTokens, opts.requestContext));
|
|
29745
29785
|
return shouldTrigger;
|
|
29746
29786
|
}
|
|
29747
29787
|
isMessageList(value) {
|
|
@@ -31544,6 +31584,25 @@ var Memory = class extends _mastra_core_memory.MastraMemory {
|
|
|
31544
31584
|
trackVectorCleanup(cleanup) {
|
|
31545
31585
|
this.pendingVectorCleanup = Promise.allSettled([this.pendingVectorCleanup, cleanup]).then(() => void 0);
|
|
31546
31586
|
}
|
|
31587
|
+
/**
|
|
31588
|
+
* Resolve once all background work this Memory started has finished: observational-memory
|
|
31589
|
+
* cycles (buffered observation and reflection, including the nested agent runs they spawn)
|
|
31590
|
+
* and vector cleanup from `deleteThread` / `deleteMessages`.
|
|
31591
|
+
*
|
|
31592
|
+
* Callers that own the storage connection should await this before closing it, otherwise
|
|
31593
|
+
* background statements can race the close.
|
|
31594
|
+
*
|
|
31595
|
+
* ```ts
|
|
31596
|
+
* await agent.generate('hello', { memory: { thread, resource } });
|
|
31597
|
+
* await memory.settled();
|
|
31598
|
+
* await store.close();
|
|
31599
|
+
* ```
|
|
31600
|
+
*/
|
|
31601
|
+
async settled() {
|
|
31602
|
+
await this.pendingVectorCleanup;
|
|
31603
|
+
await (this._omEngine ? await this._omEngine : this._omEngineInstance)?.settled();
|
|
31604
|
+
await this.pendingVectorCleanup;
|
|
31605
|
+
}
|
|
31547
31606
|
/** The shared ObservationalMemory engine. Lazily created on first access. */
|
|
31548
31607
|
get omEngine() {
|
|
31549
31608
|
if (!this._omEngine) this._omEngine = this._initOMEngine().then((engine) => {
|
|
@@ -43690,4 +43749,4 @@ const agentBuilderWorkflows = {
|
|
|
43690
43749
|
//#endregion
|
|
43691
43750
|
exports.agentBuilderWorkflows = agentBuilderWorkflows;
|
|
43692
43751
|
|
|
43693
|
-
//# sourceMappingURL=dist-
|
|
43752
|
+
//# sourceMappingURL=dist-C2O8fRb-.cjs.map
|