@mastra/memory 1.10.0 → 1.10.1-alpha.1
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 +101 -0
- package/dist/{chunk-7A3UGAXY.js → chunk-2QSOQQPM.js} +6817 -6611
- package/dist/chunk-2QSOQQPM.js.map +1 -0
- package/dist/chunk-D4J4XPGM.cjs +111 -0
- package/dist/chunk-D4J4XPGM.cjs.map +1 -0
- package/dist/chunk-LSJJAJAF.js +105 -0
- package/dist/chunk-LSJJAJAF.js.map +1 -0
- package/dist/{chunk-EVBFYGDL.cjs → chunk-NS47X3OB.cjs} +6808 -6605
- package/dist/chunk-NS47X3OB.cjs.map +1 -0
- package/dist/constants-BDOITAO3.js +3 -0
- package/dist/constants-BDOITAO3.js.map +1 -0
- package/dist/constants-HXOCZPB7.cjs +28 -0
- package/dist/constants-HXOCZPB7.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +67 -61
- package/dist/docs/references/docs-memory-observational-memory.md +7 -5
- package/dist/docs/references/reference-memory-observational-memory.md +2 -2
- package/dist/index.cjs +207 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +52 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +200 -71
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-COYJCVX3.cjs → observational-memory-I5UTOG63.cjs} +46 -41
- package/dist/{observational-memory-COYJCVX3.cjs.map → observational-memory-I5UTOG63.cjs.map} +1 -1
- package/dist/observational-memory-WMCWT577.js +4 -0
- package/dist/{observational-memory-K2U3QQIO.js.map → observational-memory-WMCWT577.js.map} +1 -1
- package/dist/processors/index.cjs +44 -39
- package/dist/processors/index.js +2 -1
- package/dist/processors/observational-memory/buffering-coordinator.d.ts +61 -0
- package/dist/processors/observational-memory/buffering-coordinator.d.ts.map +1 -0
- package/dist/processors/observational-memory/constants.d.ts +62 -0
- package/dist/processors/observational-memory/constants.d.ts.map +1 -0
- package/dist/processors/observational-memory/debug.d.ts +3 -0
- package/dist/processors/observational-memory/debug.d.ts.map +1 -0
- package/dist/processors/observational-memory/index.d.ts +5 -2
- package/dist/processors/observational-memory/index.d.ts.map +1 -1
- package/dist/processors/observational-memory/message-utils.d.ts +69 -0
- package/dist/processors/observational-memory/message-utils.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts +33 -0
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/base.d.ts +102 -0
- package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/index.d.ts +7 -0
- package/dist/processors/observational-memory/observation-strategies/index.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts +39 -0
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts +35 -0
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/types.d.ts +55 -0
- package/dist/processors/observational-memory/observation-strategies/types.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/index.d.ts +4 -0
- package/dist/processors/observational-memory/observation-turn/index.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/step.d.ts +34 -0
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/turn.d.ts +84 -0
- package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/types.d.ts +38 -0
- package/dist/processors/observational-memory/observation-turn/types.d.ts.map +1 -0
- package/dist/processors/observational-memory/observational-memory.d.ts +388 -553
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-runner.d.ts +65 -0
- package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -0
- package/dist/processors/observational-memory/processor.d.ts +70 -0
- package/dist/processors/observational-memory/processor.d.ts.map +1 -0
- package/dist/processors/observational-memory/reflector-runner.d.ts +95 -0
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -0
- package/dist/processors/observational-memory/types.d.ts +157 -0
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-7A3UGAXY.js.map +0 -1
- package/dist/chunk-EVBFYGDL.cjs.map +0 -1
- package/dist/observational-memory-K2U3QQIO.js +0 -3
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { MastraDBMessage, MessageList } from '@mastra/core/agent';
|
|
2
|
+
import type { MessageHistory } from '@mastra/core/processors';
|
|
3
|
+
import type { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
+
import type { ObserverRunner } from '../observer-runner.js';
|
|
5
|
+
import type { ReflectorRunner } from '../reflector-runner.js';
|
|
6
|
+
import type { TokenCounter } from '../token-counter.js';
|
|
7
|
+
import type { ObservationDebugEvent, ObservationMarkerConfig, ResolvedObservationConfig, ResolvedReflectionConfig } from '../types.js';
|
|
8
|
+
import type { ObservationRunOpts, ObserverOutput, ProcessedObservation } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Dependencies injected into observation strategies.
|
|
11
|
+
* Built by the factory in index.ts from the ObservationalMemory instance.
|
|
12
|
+
*/
|
|
13
|
+
export interface StrategyDeps {
|
|
14
|
+
storage: MemoryStorage;
|
|
15
|
+
messageHistory: MessageHistory;
|
|
16
|
+
tokenCounter: TokenCounter;
|
|
17
|
+
observationConfig: ResolvedObservationConfig;
|
|
18
|
+
reflectionConfig: ResolvedReflectionConfig;
|
|
19
|
+
scope: 'thread' | 'resource';
|
|
20
|
+
retrieval: boolean;
|
|
21
|
+
observer: ObserverRunner;
|
|
22
|
+
reflector: ReflectorRunner;
|
|
23
|
+
observedMessageIds: Set<string>;
|
|
24
|
+
obscureThreadIds: boolean;
|
|
25
|
+
emitDebugEvent: (event: ObservationDebugEvent) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Abstract base class for observation strategies.
|
|
29
|
+
*
|
|
30
|
+
* Each strategy implements the phases of the observation lifecycle
|
|
31
|
+
* (prepare → observe → process → persist) while the base class handles
|
|
32
|
+
* the shared orchestration (lock guard, marker emission, reflection, error handling).
|
|
33
|
+
*/
|
|
34
|
+
export declare abstract class ObservationStrategy {
|
|
35
|
+
protected readonly deps: StrategyDeps;
|
|
36
|
+
protected readonly opts: ObservationRunOpts;
|
|
37
|
+
protected readonly storage: MemoryStorage;
|
|
38
|
+
protected readonly messageHistory: MessageHistory;
|
|
39
|
+
protected readonly tokenCounter: TokenCounter;
|
|
40
|
+
protected readonly observationConfig: ResolvedObservationConfig;
|
|
41
|
+
protected readonly reflectionConfig: ResolvedReflectionConfig;
|
|
42
|
+
protected readonly scope: 'thread' | 'resource';
|
|
43
|
+
protected readonly retrieval: boolean;
|
|
44
|
+
/** Select the right strategy based on scope and mode. Wired up by index.ts. */
|
|
45
|
+
static create: (om: unknown, opts: ObservationRunOpts) => ObservationStrategy;
|
|
46
|
+
constructor(deps: StrategyDeps, opts: ObservationRunOpts);
|
|
47
|
+
/** Run the full observation lifecycle. */
|
|
48
|
+
run(): Promise<void>;
|
|
49
|
+
protected generateCycleId(): string;
|
|
50
|
+
protected streamMarker(marker: {
|
|
51
|
+
type: string;
|
|
52
|
+
data: unknown;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
protected getObservationMarkerConfig(): ObservationMarkerConfig;
|
|
55
|
+
protected getMaxMessageTimestamp(messages: MastraDBMessage[]): Date;
|
|
56
|
+
/**
|
|
57
|
+
* Wrap observations in a thread attribution tag.
|
|
58
|
+
* In resource scope, thread IDs can be obscured via xxhash.
|
|
59
|
+
*/
|
|
60
|
+
protected wrapWithThreadTag(threadId: string, observations: string, messageRange?: string): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Create a message boundary delimiter with an ISO 8601 date.
|
|
63
|
+
* Used to separate observation chunks for cache stability.
|
|
64
|
+
*/
|
|
65
|
+
protected static createMessageBoundary(date: Date): string;
|
|
66
|
+
/**
|
|
67
|
+
* Wrap raw observations — in resource scope, wraps with thread tag and merges;
|
|
68
|
+
* in thread scope, simply appends with a message boundary delimiter.
|
|
69
|
+
*/
|
|
70
|
+
protected wrapObservations(rawObservations: string, existingObservations: string, threadId: string, lastObservedAt?: Date, messageRange?: string): Promise<string> | string;
|
|
71
|
+
protected replaceOrAppendThreadSection(existingObservations: string, _threadId: string, newThreadSection: string, lastObservedAt?: Date): string;
|
|
72
|
+
/**
|
|
73
|
+
* Persist a marker to the last assistant message in storage.
|
|
74
|
+
* Fetches messages directly from the DB so it works even when
|
|
75
|
+
* no MessageList is available (e.g. async buffering ops).
|
|
76
|
+
*/
|
|
77
|
+
protected persistMarkerToStorage(marker: {
|
|
78
|
+
type: string;
|
|
79
|
+
data: unknown;
|
|
80
|
+
}, threadId: string, resourceId?: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Persist a marker part on the last assistant message in a MessageList
|
|
83
|
+
* AND save the updated message to the DB.
|
|
84
|
+
*/
|
|
85
|
+
protected persistMarkerToMessage(marker: {
|
|
86
|
+
type: string;
|
|
87
|
+
data: unknown;
|
|
88
|
+
}, messageList: MessageList | undefined, threadId: string, resourceId?: string): Promise<void>;
|
|
89
|
+
abstract get needsLock(): boolean;
|
|
90
|
+
abstract get needsReflection(): boolean;
|
|
91
|
+
abstract prepare(): Promise<{
|
|
92
|
+
messages: MastraDBMessage[];
|
|
93
|
+
existingObservations: string;
|
|
94
|
+
}>;
|
|
95
|
+
abstract observe(existingObservations: string, messages: MastraDBMessage[]): Promise<ObserverOutput>;
|
|
96
|
+
abstract process(output: ObserverOutput, existingObservations: string): Promise<ProcessedObservation>;
|
|
97
|
+
abstract persist(processed: ProcessedObservation): Promise<void>;
|
|
98
|
+
abstract emitStartMarkers(cycleId: string): Promise<void>;
|
|
99
|
+
abstract emitEndMarkers(cycleId: string, processed: ProcessedObservation): Promise<void>;
|
|
100
|
+
abstract emitFailedMarkers(cycleId: string, error: unknown): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-strategies/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAKxF;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,aAAa,CAAC;IACvB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,yBAAyB,CAAC;IAC7C,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,KAAK,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,eAAe,CAAC;IAC3B,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACxD;AAED;;;;;;GAMG;AACH,8BAAsB,mBAAmB;IAarC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY;IACrC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB;IAb7C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAC1C,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAClD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAC9C,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,yBAAyB,CAAC;IAChE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,wBAAwB,CAAC;IAC9D,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,CAAC;IAChD,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAEtC,+EAA+E;IAC/E,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,KAAK,mBAAmB,CAAC;gBAGzD,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,kBAAkB;IAW7C,0CAA0C;IACpC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAoD1B,SAAS,CAAC,eAAe,IAAI,MAAM;cAInB,YAAY,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpF,SAAS,CAAC,0BAA0B,IAAI,uBAAuB;IAQ/D,SAAS,CAAC,sBAAsB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,IAAI;IAenE;;;OAGG;cACa,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYjH;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAI1D;;;OAGG;IACH,SAAS,CAAC,gBAAgB,CACxB,eAAe,EAAE,MAAM,EACvB,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,IAAI,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM;IAc3B,SAAS,CAAC,4BAA4B,CACpC,oBAAoB,EAAE,MAAM,EAC5B,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,IAAI,GACpB,MAAM;IA0DT;;;;OAIG;cACa,sBAAsB,CACpC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EACvC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IA8BhB;;;OAGG;cACa,sBAAsB,CACpC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EACvC,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IA6BhB,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC;IAClC,QAAQ,KAAK,eAAe,IAAI,OAAO,CAAC;IACxC,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;QAAC,oBAAoB,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1F,QAAQ,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IACpG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IACrG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAChE,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACzD,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IACxF,QAAQ,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC3E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ObservationStrategy } from './base.js';
|
|
2
|
+
export type { StrategyDeps } from './base.js';
|
|
3
|
+
export type { ObservationRunOpts, ObserverOutput, ProcessedObservation } from './types.js';
|
|
4
|
+
export { SyncObservationStrategy } from './sync.js';
|
|
5
|
+
export { AsyncBufferObservationStrategy } from './async-buffer.js';
|
|
6
|
+
export { ResourceScopedObservationStrategy } from './resource-scoped.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-strategies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MastraDBMessage } from '@mastra/core/agent';
|
|
2
|
+
import { ObservationStrategy } from './base.js';
|
|
3
|
+
import type { StrategyDeps } from './base.js';
|
|
4
|
+
import type { ObservationRunOpts, ObserverOutput, ProcessedObservation } from './types.js';
|
|
5
|
+
export declare class ResourceScopedObservationStrategy extends ObservationStrategy {
|
|
6
|
+
private readonly startedAt;
|
|
7
|
+
private cycleId?;
|
|
8
|
+
private readonly resourceId;
|
|
9
|
+
private threadsWithMessages;
|
|
10
|
+
private threadTokensToObserve;
|
|
11
|
+
private threadTokenCounts;
|
|
12
|
+
private threadOrder;
|
|
13
|
+
private messagesByThread;
|
|
14
|
+
private multiThreadResults;
|
|
15
|
+
private totalBatchUsage;
|
|
16
|
+
private observationResults;
|
|
17
|
+
private priorMetadataByThread;
|
|
18
|
+
constructor(deps: StrategyDeps, opts: ObservationRunOpts);
|
|
19
|
+
get needsLock(): boolean;
|
|
20
|
+
get needsReflection(): boolean;
|
|
21
|
+
prepare(): Promise<{
|
|
22
|
+
messages: MastraDBMessage[];
|
|
23
|
+
existingObservations: string;
|
|
24
|
+
}>;
|
|
25
|
+
emitStartMarkers(cycleId: string): Promise<void>;
|
|
26
|
+
observe(_existingObservations: string, _messages: MastraDBMessage[]): Promise<{
|
|
27
|
+
observations: string;
|
|
28
|
+
usage: {
|
|
29
|
+
inputTokens: number;
|
|
30
|
+
outputTokens: number;
|
|
31
|
+
totalTokens: number;
|
|
32
|
+
} | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
process(_output: ObserverOutput, existingObservations: string): Promise<ProcessedObservation>;
|
|
35
|
+
persist(processed: ProcessedObservation): Promise<void>;
|
|
36
|
+
emitEndMarkers(cycleId: string, processed: ProcessedObservation): Promise<void>;
|
|
37
|
+
emitFailedMarkers(cycleId: string, error: unknown): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=resource-scoped.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-scoped.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-strategies/resource-scoped.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAc1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAExF,qBAAa,iCAAkC,SAAQ,mBAAmB;IACxE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAEpC,OAAO,CAAC,mBAAmB,CAAwC;IACnE,OAAO,CAAC,qBAAqB,CAA6B;IAC1D,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,gBAAgB,CAAwC;IAChE,OAAO,CAAC,kBAAkB,CAGtB;IACJ,OAAO,CAAC,eAAe,CAAuD;IAC9E,OAAO,CAAC,kBAAkB,CAIlB;IACR,OAAO,CAAC,qBAAqB,CAGzB;gBAEQ,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,kBAAkB;IAKxD,IAAI,SAAS,YAEZ;IACD,IAAI,eAAe,YAElB;IAEK,OAAO;kBA+DgB,eAAe,EAAE;;;IA4DxC,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAwBhC,OAAO,CAAC,qBAAqB,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE;;;;;;;;IA6DnE,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA2E7F,OAAO,CAAC,SAAS,EAAE,oBAAoB;IAmDvC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAwB/D,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAkBxD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MastraDBMessage } from '@mastra/core/agent';
|
|
2
|
+
import { ObservationStrategy } from './base.js';
|
|
3
|
+
import type { StrategyDeps } from './base.js';
|
|
4
|
+
import type { ObservationRunOpts, ObserverOutput, ProcessedObservation } from './types.js';
|
|
5
|
+
export declare class SyncObservationStrategy extends ObservationStrategy {
|
|
6
|
+
private readonly startedAt;
|
|
7
|
+
private readonly lastMessage;
|
|
8
|
+
private cycleId?;
|
|
9
|
+
private tokensToObserve;
|
|
10
|
+
private observerResult;
|
|
11
|
+
constructor(deps: StrategyDeps, opts: ObservationRunOpts);
|
|
12
|
+
get needsLock(): boolean;
|
|
13
|
+
get needsReflection(): boolean;
|
|
14
|
+
prepare(): Promise<{
|
|
15
|
+
messages: MastraDBMessage[];
|
|
16
|
+
existingObservations: string;
|
|
17
|
+
}>;
|
|
18
|
+
emitStartMarkers(cycleId: string): Promise<void>;
|
|
19
|
+
observe(existingObservations: string, messages: MastraDBMessage[]): Promise<{
|
|
20
|
+
observations: string;
|
|
21
|
+
currentTask?: string;
|
|
22
|
+
suggestedContinuation?: string;
|
|
23
|
+
threadTitle?: string;
|
|
24
|
+
usage?: {
|
|
25
|
+
inputTokens?: number;
|
|
26
|
+
outputTokens?: number;
|
|
27
|
+
totalTokens?: number;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
process(output: ObserverOutput, existingObservations: string): Promise<ProcessedObservation>;
|
|
31
|
+
persist(processed: ProcessedObservation): Promise<void>;
|
|
32
|
+
emitEndMarkers(cycleId: string, processed: ProcessedObservation): Promise<void>;
|
|
33
|
+
emitFailedMarkers(cycleId: string, error: unknown): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-strategies/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAa1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAExF,qBAAa,uBAAwB,SAAQ,mBAAmB;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAC1D,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,cAAc,CAAkB;gBAE5B,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,kBAAkB;IAKxD,IAAI,SAAS,YAEZ;IACD,IAAI,eAAe,YAElB;IAEK,OAAO;;;;IAyCP,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAgBhC,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE;;;;;;uBAhBpC,CAAC;wBACrB,CAAA;uBACP,CAAC;;;IA6BH,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA8C5F,OAAO,CAAC,SAAS,EAAE,oBAAoB;IA6CvC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAmB/D,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAcxD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { MastraDBMessage } from '@mastra/core/agent';
|
|
2
|
+
import type { ProcessorStreamWriter } from '@mastra/core/processors';
|
|
3
|
+
import type { RequestContext } from '@mastra/core/request-context';
|
|
4
|
+
import type { ObservationalMemoryRecord } from '@mastra/core/storage';
|
|
5
|
+
import type { ObserveHooks } from '../types.js';
|
|
6
|
+
/** Parameters for running an observation via a strategy. */
|
|
7
|
+
export interface ObservationRunOpts {
|
|
8
|
+
record: ObservationalMemoryRecord;
|
|
9
|
+
threadId: string;
|
|
10
|
+
resourceId?: string;
|
|
11
|
+
messages: MastraDBMessage[];
|
|
12
|
+
/** Pre-generated cycle ID (async buffer only — sync/resource auto-generate). */
|
|
13
|
+
cycleId?: string;
|
|
14
|
+
/** Pre-captured start timestamp (async buffer only). */
|
|
15
|
+
startedAt?: string;
|
|
16
|
+
writer?: ProcessorStreamWriter;
|
|
17
|
+
abortSignal?: AbortSignal;
|
|
18
|
+
reflectionHooks?: Pick<ObserveHooks, 'onReflectionStart' | 'onReflectionEnd'>;
|
|
19
|
+
requestContext?: RequestContext;
|
|
20
|
+
}
|
|
21
|
+
/** Output from calling the observer agent. */
|
|
22
|
+
export interface ObserverOutput {
|
|
23
|
+
observations: string;
|
|
24
|
+
currentTask?: string;
|
|
25
|
+
suggestedContinuation?: string;
|
|
26
|
+
threadTitle?: string;
|
|
27
|
+
usage?: {
|
|
28
|
+
inputTokens?: number;
|
|
29
|
+
outputTokens?: number;
|
|
30
|
+
totalTokens?: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Processed observation ready for persistence. */
|
|
34
|
+
export interface ProcessedObservation {
|
|
35
|
+
observations: string;
|
|
36
|
+
observationTokens: number;
|
|
37
|
+
cycleObservationTokens: number;
|
|
38
|
+
observedMessageIds: string[];
|
|
39
|
+
lastObservedAt: Date;
|
|
40
|
+
threadMetadataUpdates?: Array<{
|
|
41
|
+
threadId: string;
|
|
42
|
+
lastObservedAt: string;
|
|
43
|
+
suggestedResponse?: string;
|
|
44
|
+
currentTask?: string;
|
|
45
|
+
threadTitle?: string;
|
|
46
|
+
lastObservedMessageCursor?: {
|
|
47
|
+
createdAt: string;
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
suggestedContinuation?: string;
|
|
52
|
+
currentTask?: string;
|
|
53
|
+
threadTitle?: string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-strategies/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,yBAAyB,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAE5B,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,eAAe,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,mBAAmB,GAAG,iBAAiB,CAAC,CAAC;IAC9E,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/E;AAED,mDAAmD;AACnD,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,cAAc,EAAE,IAAI,CAAC;IACrB,qBAAqB,CAAC,EAAE,KAAK,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,yBAAyB,CAAC,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/D,CAAC,CAAC;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-turn/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ObservationTurn } from './turn.js';
|
|
2
|
+
import type { StepContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a single step in the agentic loop within an observation turn.
|
|
5
|
+
*
|
|
6
|
+
* Created via `turn.step(stepNumber)`. Call `prepare()` before the agent generates.
|
|
7
|
+
* The previous step's output is finalized automatically when the next step is created
|
|
8
|
+
* or when `turn.end()` is called.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ObservationStep {
|
|
11
|
+
private readonly turn;
|
|
12
|
+
readonly stepNumber: number;
|
|
13
|
+
private _prepared;
|
|
14
|
+
private _context?;
|
|
15
|
+
constructor(turn: ObservationTurn, stepNumber: number);
|
|
16
|
+
/** Whether this step has been prepared. */
|
|
17
|
+
get prepared(): boolean;
|
|
18
|
+
/** Step context from prepare(). Throws if prepare() hasn't been called. */
|
|
19
|
+
get context(): StepContext;
|
|
20
|
+
/**
|
|
21
|
+
* Prepare this step for agent generation.
|
|
22
|
+
*
|
|
23
|
+
* For step 0: activates buffered chunks, checks reflection, builds system message, filters observed.
|
|
24
|
+
* For step > 0: checks thresholds, triggers buffer/observe, saves previous messages,
|
|
25
|
+
* builds system message, filters observed.
|
|
26
|
+
*/
|
|
27
|
+
prepare(): Promise<StepContext>;
|
|
28
|
+
/**
|
|
29
|
+
* Run the full threshold observation pipeline:
|
|
30
|
+
* waitForBuffering → re-check → activate → reflect → blockAfter gate → observe
|
|
31
|
+
*/
|
|
32
|
+
private runThresholdObservation;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-turn/step.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;GAMG;AACH,qBAAa,eAAe;IAKxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM;IAL7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAc;gBAGZ,IAAI,EAAE,eAAe,EAC7B,UAAU,EAAE,MAAM;IAG7B,2CAA2C;IAC3C,IAAI,QAAQ,YAEX;IAED,2EAA2E;IAC3E,IAAI,OAAO,IAAI,WAAW,CAGzB;IAED;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;IAiNrC;;;OAGG;YACW,uBAAuB;CAkEtC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { MessageList } from '@mastra/core/agent';
|
|
2
|
+
import type { ProcessorStreamWriter } from '@mastra/core/processors';
|
|
3
|
+
import type { RequestContext } from '@mastra/core/request-context';
|
|
4
|
+
import type { ObservationalMemoryRecord } from '@mastra/core/storage';
|
|
5
|
+
import type { ObservationalMemory } from '../observational-memory.js';
|
|
6
|
+
import type { MemoryContextProvider } from '../processor.js';
|
|
7
|
+
import { ObservationStep } from './step.js';
|
|
8
|
+
import type { TurnContext, TurnResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Represents a single turn in the agent conversation — one user message → agent response cycle.
|
|
11
|
+
*
|
|
12
|
+
* The turn manages record caching, context loading, and step lifecycle.
|
|
13
|
+
* Create via `om.beginTurn(...)`, then call `start()` to load context,
|
|
14
|
+
* `step(n)` to create steps, and `end()` to finalize.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const turn = om.beginTurn({ threadId, resourceId, messageList });
|
|
19
|
+
* await turn.start(memory);
|
|
20
|
+
*
|
|
21
|
+
* const step0 = turn.step(0);
|
|
22
|
+
* const ctx = await step0.prepare();
|
|
23
|
+
* // ... agent generates ...
|
|
24
|
+
*
|
|
25
|
+
* const step1 = turn.step(1); // finalizes step 0
|
|
26
|
+
* const ctx1 = await step1.prepare();
|
|
27
|
+
* // ... agent generates ...
|
|
28
|
+
*
|
|
29
|
+
* await turn.end(); // finalizes last step, cleanup
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class ObservationTurn {
|
|
33
|
+
readonly om: ObservationalMemory;
|
|
34
|
+
readonly threadId: string;
|
|
35
|
+
readonly resourceId: string | undefined;
|
|
36
|
+
readonly messageList: MessageList;
|
|
37
|
+
private _record?;
|
|
38
|
+
private _context?;
|
|
39
|
+
private _currentStep?;
|
|
40
|
+
private _started;
|
|
41
|
+
private _ended;
|
|
42
|
+
/** Generation count at turn start — used to detect if reflection happened during the turn. */
|
|
43
|
+
private _generationCountAtStart;
|
|
44
|
+
/** Memory context provider — set via start(). Used by steps for beforeBuffer persistence. */
|
|
45
|
+
memory?: MemoryContextProvider;
|
|
46
|
+
/** Optional stream writer for emitting markers. */
|
|
47
|
+
writer?: ProcessorStreamWriter;
|
|
48
|
+
/** Optional request context for observation calls. */
|
|
49
|
+
requestContext?: RequestContext;
|
|
50
|
+
constructor(om: ObservationalMemory, threadId: string, resourceId: string | undefined, messageList: MessageList);
|
|
51
|
+
/** The current cached record. Refreshed after mutations (activate/observe/reflect). */
|
|
52
|
+
get record(): ObservationalMemoryRecord;
|
|
53
|
+
/** The context loaded during start(). */
|
|
54
|
+
get context(): TurnContext;
|
|
55
|
+
/** The current step, if one exists. */
|
|
56
|
+
get currentStep(): ObservationStep | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Load context and cache the record. Call once at the start of the turn.
|
|
59
|
+
*
|
|
60
|
+
* If a MemoryContextProvider is passed, loads historical messages and adds
|
|
61
|
+
* them to the MessageList. Without a provider, only fetches/caches the record.
|
|
62
|
+
*/
|
|
63
|
+
start(memory?: MemoryContextProvider): Promise<TurnContext>;
|
|
64
|
+
/**
|
|
65
|
+
* Create a step handle. If a previous step exists, it is finalized
|
|
66
|
+
* (its output messages will be saved at the start of the new step's prepare()).
|
|
67
|
+
*/
|
|
68
|
+
step(stepNumber: number): ObservationStep;
|
|
69
|
+
/**
|
|
70
|
+
* Finalize the turn: save any remaining messages, await in-flight buffering, return final state.
|
|
71
|
+
*/
|
|
72
|
+
end(): Promise<TurnResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Refresh the cached record from storage. Called internally after mutations.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
refreshRecord(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Refresh cross-thread context for resource scope. Called per-step.
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
refreshOtherThreadsContext(): Promise<string | undefined>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=turn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-turn/turn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,eAAe;IAoBxB,QAAQ,CAAC,EAAE,EAAE,mBAAmB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW;IAtBnC,OAAO,CAAC,OAAO,CAAC,CAA4B;IAC5C,OAAO,CAAC,QAAQ,CAAC,CAAc;IAC/B,OAAO,CAAC,YAAY,CAAC,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IAEvB,8FAA8F;IAC9F,OAAO,CAAC,uBAAuB,CAAM;IAErC,6FAA6F;IAC7F,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAE/B,mDAAmD;IACnD,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAE/B,sDAAsD;IACtD,cAAc,CAAC,EAAE,cAAc,CAAC;gBAGrB,EAAE,EAAE,mBAAmB,EACvB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,WAAW;IAGnC,uFAAuF;IACvF,IAAI,MAAM,IAAI,yBAAyB,CAGtC;IAED,yCAAyC;IACzC,IAAI,OAAO,IAAI,WAAW,CAGzB;IAED,uCAAuC;IACvC,IAAI,WAAW,IAAI,eAAe,GAAG,SAAS,CAE7C;IAED;;;;;OAKG;IACG,KAAK,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC;IAsCjE;;;OAGG;IACH,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe;IAQzC;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAuChC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC;;;OAGG;IACG,0BAA0B,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAUhE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { MastraDBMessage } from '@mastra/core/agent';
|
|
2
|
+
import type { ObservationalMemoryRecord } from '@mastra/core/storage';
|
|
3
|
+
/** Returned by `turn.start()` — the loaded context for this turn. */
|
|
4
|
+
export interface TurnContext {
|
|
5
|
+
messages: MastraDBMessage[];
|
|
6
|
+
systemMessage: string | undefined;
|
|
7
|
+
continuation: MastraDBMessage | undefined;
|
|
8
|
+
otherThreadsContext: string | undefined;
|
|
9
|
+
record: ObservationalMemoryRecord;
|
|
10
|
+
}
|
|
11
|
+
/** Returned by `step.prepare()` — what the agent needs for this step. */
|
|
12
|
+
export interface StepContext {
|
|
13
|
+
/** System messages containing observations (one per cache-stable chunk). */
|
|
14
|
+
systemMessage: string[] | undefined;
|
|
15
|
+
/** Whether buffered chunks were activated in this step. */
|
|
16
|
+
activated: boolean;
|
|
17
|
+
/** Whether a sync observation was triggered in this step. */
|
|
18
|
+
observed: boolean;
|
|
19
|
+
/** Whether an async buffer was triggered in this step. */
|
|
20
|
+
buffered: boolean;
|
|
21
|
+
/** Whether reflection was triggered in this step. */
|
|
22
|
+
reflected: boolean;
|
|
23
|
+
/** Current status snapshot from getStatus(). */
|
|
24
|
+
status: {
|
|
25
|
+
pendingTokens: number;
|
|
26
|
+
threshold: number;
|
|
27
|
+
effectiveObservationTokensThreshold: number;
|
|
28
|
+
shouldObserve: boolean;
|
|
29
|
+
shouldBuffer: boolean;
|
|
30
|
+
shouldReflect: boolean;
|
|
31
|
+
canActivate: boolean;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Returned by `turn.end()` — final turn state. */
|
|
35
|
+
export interface TurnResult {
|
|
36
|
+
record: ObservationalMemoryRecord;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-turn/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,YAAY,EAAE,eAAe,GAAG,SAAS,CAAC;IAC1C,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,MAAM,EAAE,yBAAyB,CAAC;CACnC;AAED,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,aAAa,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACpC,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,QAAQ,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,QAAQ,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,SAAS,EAAE,OAAO,CAAC;IACnB,gDAAgD;IAChD,MAAM,EAAE;QACN,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,mCAAmC,EAAE,MAAM,CAAC;QAC5C,aAAa,EAAE,OAAO,CAAC;QACvB,YAAY,EAAE,OAAO,CAAC;QACtB,aAAa,EAAE,OAAO,CAAC;QACvB,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;CACH;AAED,mDAAmD;AACnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,yBAAyB,CAAC;CACnC"}
|