@mastra/memory 0.0.0-error-handler-fix-20251020202607 → 0.0.0-esbuild-bundle-worker-20260807182016

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.
Files changed (169) hide show
  1. package/CHANGELOG.md +4656 -3
  2. package/LICENSE.md +15 -0
  3. package/README.md +26 -1
  4. package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +7450 -0
  5. package/dist/docs/SKILL.md +62 -0
  6. package/dist/docs/assets/SOURCE_MAP.json +11 -0
  7. package/dist/docs/references/docs-agents-agent-approval.md +664 -0
  8. package/dist/docs/references/docs-agents-networks.md +184 -0
  9. package/dist/docs/references/docs-capabilities-subagents.md +454 -0
  10. package/dist/docs/references/docs-evals-evals-with-memory.md +146 -0
  11. package/dist/docs/references/docs-long-running-agents-background-tasks.md +382 -0
  12. package/dist/docs/references/docs-long-running-agents-goals.md +118 -0
  13. package/dist/docs/references/docs-memory-memory-processors.md +385 -0
  14. package/dist/docs/references/docs-memory-message-history.md +348 -0
  15. package/dist/docs/references/docs-memory-multi-user-threads.md +208 -0
  16. package/dist/docs/references/docs-memory-observational-memory.md +835 -0
  17. package/dist/docs/references/docs-memory-overview.md +266 -0
  18. package/dist/docs/references/docs-memory-semantic-recall.md +401 -0
  19. package/dist/docs/references/docs-memory-working-memory.md +431 -0
  20. package/dist/docs/references/docs-storage-overview.md +214 -0
  21. package/dist/docs/references/reference-core-getMemory.md +51 -0
  22. package/dist/docs/references/reference-core-listMemory.md +57 -0
  23. package/dist/docs/references/reference-file-based-agents-memory.md +58 -0
  24. package/dist/docs/references/reference-memory-clone-utilities.md +203 -0
  25. package/dist/docs/references/reference-memory-cloneThread.md +173 -0
  26. package/dist/docs/references/reference-memory-createThread.md +70 -0
  27. package/dist/docs/references/reference-memory-getThreadById.md +26 -0
  28. package/dist/docs/references/reference-memory-listThreads.md +147 -0
  29. package/dist/docs/references/reference-memory-memory-class.md +148 -0
  30. package/dist/docs/references/reference-memory-observational-memory.md +877 -0
  31. package/dist/docs/references/reference-memory-summarizeConversation.md +99 -0
  32. package/dist/docs/references/reference-memory-summarizeThread.md +93 -0
  33. package/dist/docs/references/reference-processors-token-limiter-processor.md +158 -0
  34. package/dist/docs/references/reference-storage-dsql.md +430 -0
  35. package/dist/docs/references/reference-storage-dynamodb.md +284 -0
  36. package/dist/docs/references/reference-storage-libsql.md +143 -0
  37. package/dist/docs/references/reference-storage-mongodb.md +267 -0
  38. package/dist/docs/references/reference-storage-postgresql.md +531 -0
  39. package/dist/docs/references/reference-storage-redis.md +268 -0
  40. package/dist/docs/references/reference-storage-upstash.md +162 -0
  41. package/dist/docs/references/reference-vectors-libsql.md +307 -0
  42. package/dist/docs/references/reference-vectors-mongodb.md +567 -0
  43. package/dist/docs/references/reference-vectors-pg.md +430 -0
  44. package/dist/docs/references/reference-vectors-upstash.md +296 -0
  45. package/dist/index.cjs +35 -893
  46. package/dist/index.d.ts +465 -62
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +2 -887
  49. package/dist/processors/index.cjs +32 -165
  50. package/dist/processors/index.d.ts +1 -2
  51. package/dist/processors/index.d.ts.map +1 -1
  52. package/dist/processors/index.js +2 -158
  53. package/dist/processors/observational-memory/activation-ttl.d.ts +4 -0
  54. package/dist/processors/observational-memory/activation-ttl.d.ts.map +1 -0
  55. package/dist/processors/observational-memory/anchor-ids.d.ts +4 -0
  56. package/dist/processors/observational-memory/anchor-ids.d.ts.map +1 -0
  57. package/dist/processors/observational-memory/buffering-coordinator.d.ts +61 -0
  58. package/dist/processors/observational-memory/buffering-coordinator.d.ts.map +1 -0
  59. package/dist/processors/observational-memory/built-in-extractors.d.ts +15 -0
  60. package/dist/processors/observational-memory/built-in-extractors.d.ts.map +1 -0
  61. package/dist/processors/observational-memory/constants.d.ts +74 -0
  62. package/dist/processors/observational-memory/constants.d.ts.map +1 -0
  63. package/dist/processors/observational-memory/date-utils.d.ts +41 -0
  64. package/dist/processors/observational-memory/date-utils.d.ts.map +1 -0
  65. package/dist/processors/observational-memory/debug.d.ts +3 -0
  66. package/dist/processors/observational-memory/debug.d.ts.map +1 -0
  67. package/dist/processors/observational-memory/extracted-values.d.ts +44 -0
  68. package/dist/processors/observational-memory/extracted-values.d.ts.map +1 -0
  69. package/dist/processors/observational-memory/extraction-runner.d.ts +22 -0
  70. package/dist/processors/observational-memory/extraction-runner.d.ts.map +1 -0
  71. package/dist/processors/observational-memory/extractor.d.ts +76 -0
  72. package/dist/processors/observational-memory/extractor.d.ts.map +1 -0
  73. package/dist/processors/observational-memory/index.d.ts +30 -0
  74. package/dist/processors/observational-memory/index.d.ts.map +1 -0
  75. package/dist/processors/observational-memory/internal-request-context.d.ts +17 -0
  76. package/dist/processors/observational-memory/internal-request-context.d.ts.map +1 -0
  77. package/dist/processors/observational-memory/markers.d.ts +118 -0
  78. package/dist/processors/observational-memory/markers.d.ts.map +1 -0
  79. package/dist/processors/observational-memory/message-utils.d.ts +83 -0
  80. package/dist/processors/observational-memory/message-utils.d.ts.map +1 -0
  81. package/dist/processors/observational-memory/model-by-input-tokens.d.ts +14 -0
  82. package/dist/processors/observational-memory/model-by-input-tokens.d.ts.map +1 -0
  83. package/dist/processors/observational-memory/model-context.d.ts +2 -0
  84. package/dist/processors/observational-memory/model-context.d.ts.map +1 -0
  85. package/dist/processors/observational-memory/observation-groups.d.ts +15 -0
  86. package/dist/processors/observational-memory/observation-groups.d.ts.map +1 -0
  87. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts +39 -0
  88. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -0
  89. package/dist/processors/observational-memory/observation-strategies/base.d.ts +122 -0
  90. package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -0
  91. package/dist/processors/observational-memory/observation-strategies/index.d.ts +7 -0
  92. package/dist/processors/observational-memory/observation-strategies/index.d.ts.map +1 -0
  93. package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts +43 -0
  94. package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -0
  95. package/dist/processors/observational-memory/observation-strategies/sync.d.ts +41 -0
  96. package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -0
  97. package/dist/processors/observational-memory/observation-strategies/types.d.ts +103 -0
  98. package/dist/processors/observational-memory/observation-strategies/types.d.ts.map +1 -0
  99. package/dist/processors/observational-memory/observation-turn/index.d.ts +4 -0
  100. package/dist/processors/observational-memory/observation-turn/index.d.ts.map +1 -0
  101. package/dist/processors/observational-memory/observation-turn/load-memory-context.d.ts +9 -0
  102. package/dist/processors/observational-memory/observation-turn/load-memory-context.d.ts.map +1 -0
  103. package/dist/processors/observational-memory/observation-turn/step.d.ts +53 -0
  104. package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -0
  105. package/dist/processors/observational-memory/observation-turn/turn.d.ts +139 -0
  106. package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -0
  107. package/dist/processors/observational-memory/observation-turn/types.d.ts +46 -0
  108. package/dist/processors/observational-memory/observation-turn/types.d.ts.map +1 -0
  109. package/dist/processors/observational-memory/observation-utils.d.ts +16 -0
  110. package/dist/processors/observational-memory/observation-utils.d.ts.map +1 -0
  111. package/dist/processors/observational-memory/observational-memory.d.ts +930 -0
  112. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -0
  113. package/dist/processors/observational-memory/observer-agent.d.ts +190 -0
  114. package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -0
  115. package/dist/processors/observational-memory/observer-runner.d.ts +141 -0
  116. package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -0
  117. package/dist/processors/observational-memory/operation-registry.d.ts +14 -0
  118. package/dist/processors/observational-memory/operation-registry.d.ts.map +1 -0
  119. package/dist/processors/observational-memory/processor.d.ts +70 -0
  120. package/dist/processors/observational-memory/processor.d.ts.map +1 -0
  121. package/dist/processors/observational-memory/reflector-agent.d.ts +62 -0
  122. package/dist/processors/observational-memory/reflector-agent.d.ts.map +1 -0
  123. package/dist/processors/observational-memory/reflector-runner.d.ts +133 -0
  124. package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -0
  125. package/dist/processors/observational-memory/repro-capture.d.ts +33 -0
  126. package/dist/processors/observational-memory/repro-capture.d.ts.map +1 -0
  127. package/dist/processors/observational-memory/retry.d.ts +63 -0
  128. package/dist/processors/observational-memory/retry.d.ts.map +1 -0
  129. package/dist/processors/observational-memory/string-utils.d.ts +13 -0
  130. package/dist/processors/observational-memory/string-utils.d.ts.map +1 -0
  131. package/dist/processors/observational-memory/summarize.d.ts +92 -0
  132. package/dist/processors/observational-memory/summarize.d.ts.map +1 -0
  133. package/dist/processors/observational-memory/temporal-markers.d.ts +4 -0
  134. package/dist/processors/observational-memory/temporal-markers.d.ts.map +1 -0
  135. package/dist/processors/observational-memory/temporary-memory.d.ts +8 -0
  136. package/dist/processors/observational-memory/temporary-memory.d.ts.map +1 -0
  137. package/dist/processors/observational-memory/thresholds.d.ts +52 -0
  138. package/dist/processors/observational-memory/thresholds.d.ts.map +1 -0
  139. package/dist/processors/observational-memory/token-counter.d.ts +57 -0
  140. package/dist/processors/observational-memory/token-counter.d.ts.map +1 -0
  141. package/dist/processors/observational-memory/tool-result-helpers.d.ts +12 -0
  142. package/dist/processors/observational-memory/tool-result-helpers.d.ts.map +1 -0
  143. package/dist/processors/observational-memory/tracing.d.ts +17 -0
  144. package/dist/processors/observational-memory/tracing.d.ts.map +1 -0
  145. package/dist/processors/observational-memory/types.d.ts +997 -0
  146. package/dist/processors/observational-memory/types.d.ts.map +1 -0
  147. package/dist/processors/observational-memory/working-memory-extractor.d.ts +5 -0
  148. package/dist/processors/observational-memory/working-memory-extractor.d.ts.map +1 -0
  149. package/dist/processors/working-memory-state/index.d.ts +2 -0
  150. package/dist/processors/working-memory-state/index.d.ts.map +1 -0
  151. package/dist/processors/working-memory-state/processor.d.ts +53 -0
  152. package/dist/processors/working-memory-state/processor.d.ts.map +1 -0
  153. package/dist/src-C1tlhGeW.js +28559 -0
  154. package/dist/src-C1tlhGeW.js.map +1 -0
  155. package/dist/src-DqoifKIy.cjs +28813 -0
  156. package/dist/src-DqoifKIy.cjs.map +1 -0
  157. package/dist/tools/om-tools.d.ts +172 -0
  158. package/dist/tools/om-tools.d.ts.map +1 -0
  159. package/dist/tools/working-memory.d.ts +33 -28
  160. package/dist/tools/working-memory.d.ts.map +1 -1
  161. package/package.json +36 -28
  162. package/dist/index.cjs.map +0 -1
  163. package/dist/index.js.map +0 -1
  164. package/dist/processors/index.cjs.map +0 -1
  165. package/dist/processors/index.js.map +0 -1
  166. package/dist/processors/token-limiter.d.ts +0 -32
  167. package/dist/processors/token-limiter.d.ts.map +0 -1
  168. package/dist/processors/tool-call-filter.d.ts +0 -20
  169. package/dist/processors/tool-call-filter.d.ts.map +0 -1
@@ -0,0 +1,122 @@
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 { Memory } from '../../../index.js';
5
+ import type { ObserverRunner } from '../observer-runner.js';
6
+ import type { ReflectorRunner } from '../reflector-runner.js';
7
+ import type { TokenCounter } from '../token-counter.js';
8
+ import type { ObservationDebugEvent, ObservationMarkerConfig, ResolvedObservationConfig, ResolvedReflectionConfig } from '../types.js';
9
+ import type { ObservationRunOpts, ObservationRunResult, ObserverOutput, ProcessedObservation } from './types.js';
10
+ /**
11
+ * Dependencies injected into observation strategies.
12
+ * Built by the factory in index.ts from the ObservationalMemory instance.
13
+ */
14
+ export interface StrategyDeps {
15
+ storage: MemoryStorage;
16
+ memory?: Memory;
17
+ messageHistory: MessageHistory;
18
+ tokenCounter: TokenCounter;
19
+ observationConfig: ResolvedObservationConfig;
20
+ reflectionConfig: ResolvedReflectionConfig;
21
+ scope: 'thread' | 'resource';
22
+ retrieval: boolean;
23
+ observer: ObserverRunner;
24
+ reflector: ReflectorRunner;
25
+ observedMessageIds: Set<string>;
26
+ obscureThreadIds: boolean;
27
+ onIndexObservations?: (observation: {
28
+ text: string;
29
+ groupId: string;
30
+ range: string;
31
+ threadId: string;
32
+ resourceId: string;
33
+ observedAt?: Date;
34
+ }) => Promise<void>;
35
+ emitDebugEvent: (event: ObservationDebugEvent) => void;
36
+ }
37
+ /**
38
+ * Abstract base class for observation strategies.
39
+ *
40
+ * Each strategy implements the phases of the observation lifecycle
41
+ * (prepare → observe → process → persist) while the base class handles
42
+ * the shared orchestration (lock guard, marker emission, reflection, error handling).
43
+ */
44
+ export declare abstract class ObservationStrategy {
45
+ protected readonly deps: StrategyDeps;
46
+ protected readonly opts: ObservationRunOpts;
47
+ protected readonly storage: MemoryStorage;
48
+ protected readonly messageHistory: MessageHistory;
49
+ protected readonly tokenCounter: TokenCounter;
50
+ protected readonly observationConfig: ResolvedObservationConfig;
51
+ protected readonly reflectionConfig: ResolvedReflectionConfig;
52
+ protected readonly scope: 'thread' | 'resource';
53
+ protected readonly retrieval: boolean;
54
+ /** Select the right strategy based on scope and mode. Wired up by index.ts. */
55
+ static create: (om: unknown, opts: ObservationRunOpts) => ObservationStrategy;
56
+ constructor(deps: StrategyDeps, opts: ObservationRunOpts);
57
+ /**
58
+ * Run the full observation lifecycle.
59
+ * @returns Result with `observed` flag and optional `usage` from the observer LLM call.
60
+ * @throws On sync/resource-scoped observer failure after failed markers (same as pre–Option-A contract).
61
+ */
62
+ run(): Promise<ObservationRunResult>;
63
+ protected generateCycleId(): string;
64
+ protected streamMarker(marker: {
65
+ type: string;
66
+ data: unknown;
67
+ }): Promise<void>;
68
+ protected getObservationMarkerConfig(): ObservationMarkerConfig;
69
+ protected getMaxMessageTimestamp(messages: MastraDBMessage[]): Date;
70
+ /**
71
+ * Wrap observations in a thread attribution tag.
72
+ * In resource scope, thread IDs can be obscured via xxhash.
73
+ */
74
+ protected wrapWithThreadTag(threadId: string, observations: string, messageRange?: string): Promise<string>;
75
+ /**
76
+ * Create a message boundary delimiter with an ISO 8601 date.
77
+ * Used to separate observation chunks for cache stability.
78
+ */
79
+ protected static createMessageBoundary(date: Date): string;
80
+ /**
81
+ * Wrap raw observations — in resource scope, wraps with thread tag and merges;
82
+ * in thread scope, simply appends with a message boundary delimiter.
83
+ */
84
+ protected wrapObservations(rawObservations: string, existingObservations: string, threadId: string, lastObservedAt?: Date, messageRange?: string): Promise<string> | string;
85
+ protected replaceOrAppendThreadSection(existingObservations: string, _threadId: string, newThreadSection: string, lastObservedAt?: Date): string;
86
+ protected indexObservationGroups(observations: string, threadId: string, resourceId?: string, observedAt?: Date): Promise<void>;
87
+ /**
88
+ * Persist a marker to the last assistant message in storage.
89
+ * Fetches messages directly from the DB so it works even when
90
+ * no MessageList is available (e.g. async buffering ops).
91
+ */
92
+ protected persistMarkerToStorage(marker: {
93
+ type: string;
94
+ data: unknown;
95
+ }, threadId: string, resourceId?: string): Promise<void>;
96
+ /**
97
+ * Persist a marker part on the last assistant message in a MessageList
98
+ * AND save the updated message to the DB.
99
+ *
100
+ * @returns true when a marker was placed on an assistant message, false when
101
+ * no list was provided or the list contains no assistant message (caller
102
+ * should fall back to `persistMarkerToStorage`).
103
+ */
104
+ protected persistMarkerToMessage(marker: {
105
+ type: string;
106
+ data: unknown;
107
+ }, messageList: MessageList | undefined, threadId: string, resourceId?: string): Promise<boolean>;
108
+ abstract get needsLock(): boolean;
109
+ abstract get needsReflection(): boolean;
110
+ abstract get rethrowOnFailure(): boolean;
111
+ abstract prepare(): Promise<{
112
+ messages: MastraDBMessage[];
113
+ existingObservations: string;
114
+ }>;
115
+ abstract observe(existingObservations: string, messages: MastraDBMessage[]): Promise<ObserverOutput>;
116
+ abstract process(output: ObserverOutput, existingObservations: string): Promise<ProcessedObservation>;
117
+ abstract persist(processed: ProcessedObservation): Promise<void>;
118
+ abstract emitStartMarkers(cycleId: string): Promise<void>;
119
+ abstract emitEndMarkers(cycleId: string, processed: ProcessedObservation): Promise<void>;
120
+ abstract emitFailedMarkers(cycleId: string, error: unknown): Promise<void>;
121
+ }
122
+ //# 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;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIvC,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,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAK9G;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,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,mBAAmB,CAAC,EAAE,CAAC,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AW,GAAG,SAAS,EACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC;IA8BnB,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC;IAClC,QAAQ,KAAK,eAAe,IAAI,OAAO,CAAC;IACxC,QAAQ,KAAK,gBAAgB,IAAI,OAAO,CAAC;IACzC,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,43 @@
1
+ import type { MastraDBMessage } from '@mastra/core/agent';
2
+ import type { ProviderMetadata } from '@mastra/core/stream';
3
+ import { ObservationStrategy } from './base.js';
4
+ import type { StrategyDeps } from './base.js';
5
+ import type { ObservationRunOpts, ObserverOutput, ProcessedObservation } from './types.js';
6
+ export declare class ResourceScopedObservationStrategy extends ObservationStrategy {
7
+ private readonly startedAt;
8
+ private cycleId?;
9
+ private readonly resourceId;
10
+ private threadsWithMessages;
11
+ private threadTokensToObserve;
12
+ private threadTokenCounts;
13
+ private threadOrder;
14
+ private messagesByThread;
15
+ private multiThreadResults;
16
+ private totalBatchUsage;
17
+ private lastBatchProviderMetadata;
18
+ private observationResults;
19
+ private priorMetadataByThread;
20
+ constructor(deps: StrategyDeps, opts: ObservationRunOpts);
21
+ get needsLock(): boolean;
22
+ get needsReflection(): boolean;
23
+ get rethrowOnFailure(): boolean;
24
+ prepare(): Promise<{
25
+ messages: MastraDBMessage[];
26
+ existingObservations: string;
27
+ }>;
28
+ emitStartMarkers(cycleId: string): Promise<void>;
29
+ observe(_existingObservations: string, _messages: MastraDBMessage[]): Promise<{
30
+ observations: string;
31
+ usage: {
32
+ inputTokens: number;
33
+ outputTokens: number;
34
+ totalTokens: number;
35
+ } | undefined;
36
+ providerMetadata: ProviderMetadata | undefined;
37
+ }>;
38
+ process(_output: ObserverOutput, existingObservations: string): Promise<ProcessedObservation>;
39
+ persist(processed: ProcessedObservation): Promise<void>;
40
+ emitEndMarkers(cycleId: string, processed: ProcessedObservation): Promise<void>;
41
+ emitFailedMarkers(cycleId: string, error: unknown): Promise<void>;
42
+ }
43
+ //# 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;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAmB5D,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,CAWtB;IACJ,OAAO,CAAC,eAAe,CAAuD;IAC9E,OAAO,CAAC,yBAAyB,CAA+B;IAChE,OAAO,CAAC,kBAAkB,CAYlB;IACR,OAAO,CAAC,qBAAqB,CAAuC;gBAExD,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,kBAAkB;IAKxD,IAAI,SAAS,YAEZ;IACD,IAAI,eAAe,YAElB;IACD,IAAI,gBAAgB,YAEnB;IAEK,OAAO;kBA4DgB,eAAe,EAAE;;;IA4DxC,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAwBhC,OAAO,CAAC,qBAAqB,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE;;;;;;;;;IAkEnE,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAuG7F,OAAO,CAAC,SAAS,EAAE,oBAAoB;IAyEvC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IA0B/D,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAkBxD"}
@@ -0,0 +1,41 @@
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
+ private priorExtractedValues?;
12
+ constructor(deps: StrategyDeps, opts: ObservationRunOpts);
13
+ get needsLock(): boolean;
14
+ get needsReflection(): boolean;
15
+ get rethrowOnFailure(): boolean;
16
+ prepare(): Promise<{
17
+ messages: MastraDBMessage[];
18
+ existingObservations: string;
19
+ }>;
20
+ emitStartMarkers(cycleId: string): Promise<void>;
21
+ observe(existingObservations: string, messages: MastraDBMessage[]): Promise<{
22
+ extractedValues: Record<string, unknown> | undefined;
23
+ extractionFailures: import("../extracted-values").ExtractionFailure[] | undefined;
24
+ observations: string;
25
+ currentTask?: string;
26
+ suggestedContinuation?: string;
27
+ threadTitle?: string;
28
+ extractors?: readonly import("..").Extractor<any>[];
29
+ usage?: {
30
+ inputTokens?: number;
31
+ outputTokens?: number;
32
+ totalTokens?: number;
33
+ };
34
+ providerMetadata?: import("@mastra/core/stream").ProviderMetadata;
35
+ }>;
36
+ process(output: ObserverOutput, existingObservations: string): Promise<ProcessedObservation>;
37
+ persist(processed: ProcessedObservation): Promise<void>;
38
+ emitEndMarkers(cycleId: string, processed: ProcessedObservation): Promise<void>;
39
+ emitFailedMarkers(cycleId: string, error: unknown): Promise<void>;
40
+ }
41
+ //# 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;AAkB1D,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;IACxC,OAAO,CAAC,oBAAoB,CAAC,CAA0B;gBAE3C,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,kBAAkB;IAKxD,IAAI,SAAS,YAEZ;IACD,IAAI,eAAe,YAElB;IACD,IAAI,gBAAgB,YAEnB;IAEK,OAAO;;;;IAyCP,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAgBhC,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE;;;;;;;;;uBAuGN,CAAC;wBAAsB,CAAC;uBAC3E,CAAC;;;;IAlET,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiD5F,OAAO,CAAC,SAAS,EAAE,oBAAoB;IAwDvC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAqB/D,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAcxD"}
@@ -0,0 +1,103 @@
1
+ import type { MastraDBMessage, MessageList } from '@mastra/core/agent';
2
+ import type { ObservabilityContext } from '@mastra/core/observability';
3
+ import type { ProcessorContext, ProcessorStreamWriter } from '@mastra/core/processors';
4
+ import type { RequestContext } from '@mastra/core/request-context';
5
+ import type { ObservationalMemoryRecord } from '@mastra/core/storage';
6
+ import type { ProviderMetadata } from '@mastra/core/stream';
7
+ import type { Extractor } from '../extractor.js';
8
+ import type { ObservationModelContext, ObserveHooks } from '../types.js';
9
+ /** Parameters for running an observation via a strategy. */
10
+ export interface ObservationRunOpts {
11
+ record: ObservationalMemoryRecord;
12
+ threadId: string;
13
+ resourceId?: string;
14
+ messages: MastraDBMessage[];
15
+ /**
16
+ * Live MessageList for the in-flight agent turn, when observation runs inside
17
+ * an agent loop. Lets lifecycle markers land on the pending assistant response
18
+ * message before it reaches storage (see `streamMarker`).
19
+ */
20
+ messageList?: MessageList;
21
+ /** Pre-generated cycle ID (async buffer only — sync/resource auto-generate). */
22
+ cycleId?: string;
23
+ /** Pre-captured start timestamp (async buffer only). */
24
+ startedAt?: string;
25
+ writer?: ProcessorStreamWriter;
26
+ abortSignal?: AbortSignal;
27
+ reflectionHooks?: Pick<ObserveHooks, 'onReflectionStart' | 'onReflectionEnd'>;
28
+ agent?: ProcessorContext['agent'];
29
+ sendSignal?: ProcessorContext['sendSignal'];
30
+ requestContext?: RequestContext;
31
+ currentModel?: ObservationModelContext;
32
+ observabilityContext?: ObservabilityContext;
33
+ }
34
+ /** Output from calling the observer agent. */
35
+ export interface ObserverOutput {
36
+ observations: string;
37
+ currentTask?: string;
38
+ suggestedContinuation?: string;
39
+ threadTitle?: string;
40
+ extractedValues?: Record<string, unknown>;
41
+ extractionFailures?: Array<{
42
+ slug: string;
43
+ error: string;
44
+ }>;
45
+ extractors?: readonly Extractor<any>[];
46
+ usage?: {
47
+ inputTokens?: number;
48
+ outputTokens?: number;
49
+ totalTokens?: number;
50
+ };
51
+ providerMetadata?: ProviderMetadata;
52
+ }
53
+ /** Result returned from ObservationStrategy.run(). */
54
+ export interface ObservationRunResult {
55
+ observed: boolean;
56
+ usage?: {
57
+ inputTokens?: number;
58
+ outputTokens?: number;
59
+ totalTokens?: number;
60
+ };
61
+ providerMetadata?: ProviderMetadata;
62
+ /**
63
+ * The failure that ended the cycle, for strategies that swallow errors
64
+ * instead of rethrowing (async buffering). Lets callers report the failure
65
+ * (e.g. to ObserveHooks) even though the fire-and-forget path never throws.
66
+ */
67
+ error?: Error;
68
+ }
69
+ /** Processed observation ready for persistence. */
70
+ export interface ProcessedObservation {
71
+ observations: string;
72
+ observationTokens: number;
73
+ cycleObservationTokens: number;
74
+ observedMessageIds: string[];
75
+ lastObservedAt: Date;
76
+ threadMetadataUpdates?: Array<{
77
+ threadId: string;
78
+ lastObservedAt: string;
79
+ suggestedResponse?: string;
80
+ currentTask?: string;
81
+ threadTitle?: string;
82
+ extracted?: Record<string, unknown>;
83
+ extractionFailures?: Array<{
84
+ slug: string;
85
+ error: string;
86
+ }>;
87
+ extractors?: readonly Extractor<any>[];
88
+ lastObservedMessageCursor?: {
89
+ createdAt: string;
90
+ id: string;
91
+ };
92
+ }>;
93
+ suggestedContinuation?: string;
94
+ currentTask?: string;
95
+ threadTitle?: string;
96
+ extractedValues?: Record<string, unknown>;
97
+ extractionFailures?: Array<{
98
+ slug: string;
99
+ error: string;
100
+ }>;
101
+ extractors?: readonly Extractor<any>[];
102
+ }
103
+ //# 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,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtE,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;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B,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,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC5C,cAAc,CAAC,EAAE,cAAc,CAAC;IA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rB,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,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,kBAAkB,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC5D,UAAU,CAAC,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,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;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,kBAAkB,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,UAAU,CAAC,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;CACxC"}
@@ -0,0 +1,4 @@
1
+ export { ObservationTurn } from './turn.js';
2
+ export { ObservationStep } from './step.js';
3
+ export type { ObservationTurnHooks, RotateResponseMessageId, TurnContext, StepContext, TurnResult } from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,oBAAoB,EAAE,uBAAuB,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { MessageList } from '@mastra/core/agent';
2
+ import type { MemoryContextProvider } from '../processor.js';
3
+ export declare function loadMemoryContextMessages({ memory, messageList, threadId, resourceId, }: {
4
+ memory: MemoryContextProvider;
5
+ messageList: MessageList;
6
+ threadId: string;
7
+ resourceId?: string;
8
+ }): Promise<Awaited<ReturnType<MemoryContextProvider['getContext']>>>;
9
+ //# sourceMappingURL=load-memory-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-memory-context.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-turn/load-memory-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,wBAAsB,yBAAyB,CAAC,EAC9C,MAAM,EACN,WAAW,EACX,QAAQ,EACR,UAAU,GACX,EAAE;IACD,MAAM,EAAE,qBAAqB,CAAC;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAUpE"}
@@ -0,0 +1,53 @@
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
+ /**
16
+ * True when this step seeded an empty assistant response message for a step-0
17
+ * observation. While set, the response-id rotation hook must NOT run — rotating
18
+ * would orphan the seed (markers would sit on a message the agent never streams into).
19
+ */
20
+ private seededResponseMessage;
21
+ constructor(turn: ObservationTurn, stepNumber: number);
22
+ /** Whether this step has been prepared. */
23
+ get prepared(): boolean;
24
+ /**
25
+ * Serialize to a minimal, acyclic snapshot.
26
+ *
27
+ * The `turn` back-reference exists only so a step can read context off its parent turn at
28
+ * runtime. It closes the `ObservationTurn._currentStep -> ObservationStep.turn` cycle, so
29
+ * serializing it throws "Converting circular structure to JSON" (e.g. when a turn is stashed
30
+ * in processor state that flows into a processor-workflow snapshot). The parent turn fully
31
+ * owns the step, so omitting the back-reference is lossless.
32
+ */
33
+ toJSON(): {
34
+ stepNumber: number;
35
+ prepared: boolean;
36
+ };
37
+ /** Step context from prepare(). Throws if prepare() hasn't been called. */
38
+ get context(): StepContext;
39
+ /**
40
+ * Prepare this step for agent generation.
41
+ *
42
+ * For step 0: activates buffered chunks, checks reflection, builds system message, filters observed.
43
+ * For step > 0: checks thresholds, triggers buffer/observe, saves previous messages,
44
+ * builds system message, filters observed.
45
+ */
46
+ prepare(): Promise<StepContext>;
47
+ /**
48
+ * Run the full threshold observation pipeline:
49
+ * waitForBuffering → re-check → activate → reflect → blockAfter gate → observe
50
+ */
51
+ private runThresholdObservation;
52
+ }
53
+ //# 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;IAWxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM;IAX7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAc;IAC/B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB,CAAS;gBAGnB,IAAI,EAAE,eAAe,EAC7B,UAAU,EAAE,MAAM;IAG7B,2CAA2C;IAC3C,IAAI,QAAQ,YAEX;IAED;;;;;;;;OAQG;IACH,MAAM;;;;IAIN,2EAA2E;IAC3E,IAAI,OAAO,IAAI,WAAW,CAGzB;IAED;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;IAoTrC;;;OAGG;YACW,uBAAuB;CAwItC"}
@@ -0,0 +1,139 @@
1
+ import type { MessageList } from '@mastra/core/agent';
2
+ import type { ObservabilityContext } from '@mastra/core/observability';
3
+ import type { ProcessorContext, ProcessorStreamWriter } from '@mastra/core/processors';
4
+ import type { RequestContext } from '@mastra/core/request-context';
5
+ import type { ObservationalMemoryRecord } from '@mastra/core/storage';
6
+ import type { ObservationalMemory } from '../observational-memory.js';
7
+ import type { MemoryContextProvider } from '../processor.js';
8
+ import type { ObservationModelContext } from '../types.js';
9
+ import { ObservationStep } from './step.js';
10
+ import type { ObservationTurnHooks, TurnContext, TurnResult } from './types.js';
11
+ /**
12
+ * Represents a single turn in the agent conversation — one user message → agent response cycle.
13
+ *
14
+ * The turn manages record caching, context loading, and step lifecycle.
15
+ * Create via `om.beginTurn(...)`, then call `start()` to load context,
16
+ * `step(n)` to create steps, and `end()` to finalize.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const turn = om.beginTurn({ threadId, resourceId, messageList });
21
+ * await turn.start(memory);
22
+ *
23
+ * const step0 = turn.step(0);
24
+ * const ctx = await step0.prepare();
25
+ * // ... agent generates ...
26
+ *
27
+ * const step1 = turn.step(1); // finalizes step 0
28
+ * const ctx1 = await step1.prepare();
29
+ * // ... agent generates ...
30
+ *
31
+ * await turn.end(); // finalizes last step, cleanup
32
+ * ```
33
+ */
34
+ export declare class ObservationTurn {
35
+ private _record?;
36
+ private _context?;
37
+ private _currentStep?;
38
+ private _started;
39
+ private _ended;
40
+ /** Generation count at turn start — used to detect if reflection happened during the turn. */
41
+ private _generationCountAtStart;
42
+ /** Memory context provider — set via start(). Used by steps for beforeBuffer persistence. */
43
+ memory?: MemoryContextProvider;
44
+ /** Optional stream writer for emitting markers. */
45
+ writer?: ProcessorStreamWriter;
46
+ /** Optional request context for observation calls. */
47
+ requestContext?: RequestContext;
48
+ /** Optional observability context for nested OM spans. */
49
+ observabilityContext?: ObservabilityContext;
50
+ /** Optional agent that owns this processor turn. */
51
+ agent?: ProcessorContext['agent'];
52
+ /** Optional signal sender for processor-originated notifications. */
53
+ sendSignal?: (signal: Parameters<NonNullable<ProcessorContext['sendSignal']>>[0]) => ReturnType<NonNullable<ProcessorContext['sendSignal']>>;
54
+ /** Current actor model for this step. Updated by the processor before prepare(). */
55
+ actorModelContext?: ObservationModelContext;
56
+ /** The active assistant response message ID for this step. Updated by the processor before prepare(). */
57
+ responseMessageId?: string;
58
+ /** Processor-provided hooks for turn/step lifecycle integration. */
59
+ readonly hooks: ObservationTurnHooks;
60
+ constructor(opts: {
61
+ om: ObservationalMemory;
62
+ threadId: string;
63
+ resourceId?: string;
64
+ messageList: MessageList;
65
+ agent?: ProcessorContext['agent'];
66
+ sendSignal?: ProcessorContext['sendSignal'];
67
+ requestContext?: RequestContext;
68
+ observabilityContext?: ObservabilityContext;
69
+ hooks?: ObservationTurnHooks;
70
+ });
71
+ readonly om: ObservationalMemory;
72
+ readonly threadId: string;
73
+ readonly resourceId: string | undefined;
74
+ readonly messageList: MessageList;
75
+ /** The current cached record. Refreshed after mutations (activate/observe/reflect). */
76
+ get record(): ObservationalMemoryRecord;
77
+ /** The context loaded during start(). */
78
+ get context(): TurnContext;
79
+ /** The current step, if one exists. */
80
+ get currentStep(): ObservationStep | undefined;
81
+ addHooks(hooks?: ObservationTurnHooks): void;
82
+ /**
83
+ * Load context and cache the record. Call once at the start of the turn.
84
+ *
85
+ * If a MemoryContextProvider is passed, loads historical messages and adds
86
+ * them to the MessageList. Without a provider, only fetches/caches the record.
87
+ */
88
+ start(memory?: MemoryContextProvider): Promise<TurnContext>;
89
+ /**
90
+ * Create a step handle. If a previous step exists, it is finalized
91
+ * (its output messages will be saved at the start of the new step's prepare()).
92
+ */
93
+ step(stepNumber: number): ObservationStep;
94
+ /**
95
+ * Finalize the turn: save any remaining messages and return the current cached record.
96
+ *
97
+ * When async observation buffering is enabled and there are unobserved messages,
98
+ * a background buffer operation is kicked off so that observations are computed
99
+ * proactively while the agent is idle, rather than waiting for the next turn.
100
+ * The returned record does not wait for that background buffering pass to finish.
101
+ */
102
+ end(): Promise<TurnResult>;
103
+ /**
104
+ * Refresh the cached record from storage. Called internally after mutations.
105
+ * @internal
106
+ */
107
+ refreshRecord(): Promise<void>;
108
+ /**
109
+ * Refresh cross-thread context for resource scope. Called per-step.
110
+ * @internal
111
+ */
112
+ refreshOtherThreadsContext(): Promise<string | undefined>;
113
+ /**
114
+ * Serialize to a minimal, acyclic snapshot of the turn's identity and lifecycle.
115
+ *
116
+ * `ObservationTurn` is a request-scoped runtime orchestration object: it holds live
117
+ * references (the `ObservationalMemory` engine, the `MessageList`, the stream writer, the
118
+ * memory provider, lifecycle hooks) and a back-reference to its current `ObservationStep`,
119
+ * which points back at the turn — a cycle. None of that is persistable state. The turn is
120
+ * stashed in the shared processor-state map (`state.__omTurn`) only so the input and output
121
+ * OM processor instances can reach the *live* object within a single request; that map is
122
+ * also threaded into processor workflows, whose snapshots the storage layer serializes with
123
+ * `JSON.stringify`. Without this projection, that serialization throws "Converting circular
124
+ * structure to JSON" via `_currentStep` <-> `turn`.
125
+ *
126
+ * The projection is lossless: the dropped fields are live runtime objects that cannot and
127
+ * should not round-trip through storage, and OM never reads the turn back from a snapshot —
128
+ * it always reads the live `__omTurn` from the in-memory map and re-establishes a fresh turn
129
+ * when a deserialized `MessageList` no longer matches (see the processor's turn handling).
130
+ */
131
+ toJSON(): {
132
+ threadId: string;
133
+ resourceId: string | undefined;
134
+ started: boolean;
135
+ ended: boolean;
136
+ currentStepNumber: number | undefined;
137
+ };
138
+ }
139
+ //# 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,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAItE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,eAAe;IAC1B,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,qB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AAI,MAAM,IAAI,yBAAyB,CAGtC;IAED,yCAAyC;IACzC,IAAI,OAAO,IAAI,WAAW,CAGzB;IAED,uCAAuC;IACvC,IAAI,WAAW,IAAI,eAAe,GAAG,SAAS,CAE7C;IAED,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,GAAG,IAAI;IAK5C;;;;;OAKG;IACG,KAAK,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC;IAoCjE;;;OAGG;IACH,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe;IAQzC;;;;;;;OAOG;IACG,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IA6ChC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC;;;OAGG;IACG,0BAA0B,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAW/D;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM;;;;;;;CASP"}
@@ -0,0 +1,46 @@
1
+ import type { MastraDBMessage } from '@mastra/core/agent';
2
+ import type { ObservationalMemoryRecord } from '@mastra/core/storage';
3
+ import type { ObserverExchange } from '../observer-runner.js';
4
+ /** Returned by `turn.start()` — the loaded context for this turn. */
5
+ export interface TurnContext {
6
+ messages: MastraDBMessage[];
7
+ systemMessage: string | undefined;
8
+ continuation: MastraDBMessage | undefined;
9
+ otherThreadsContext: string | undefined;
10
+ record: ObservationalMemoryRecord;
11
+ }
12
+ export type RotateResponseMessageId = () => string;
13
+ export interface ObservationTurnHooks {
14
+ onBufferChunkSealed?: RotateResponseMessageId | (() => void | Promise<void>);
15
+ onSyncObservationComplete?: RotateResponseMessageId | (() => void | Promise<void>);
16
+ }
17
+ /** Returned by `step.prepare()` — what the agent needs for this step. */
18
+ export interface StepContext {
19
+ /** System messages containing observations (one per cache-stable chunk). */
20
+ systemMessage: string[] | undefined;
21
+ /** Observer exchange captured during this step for repro recording. */
22
+ observerExchange?: ObserverExchange;
23
+ /** Whether buffered chunks were activated in this step. */
24
+ activated: boolean;
25
+ /** Whether a sync observation was triggered in this step. */
26
+ observed: boolean;
27
+ /** Whether an async buffer was triggered in this step. */
28
+ buffered: boolean;
29
+ /** Whether reflection was triggered in this step. */
30
+ reflected: boolean;
31
+ /** Current status snapshot from getStatus(). */
32
+ status: {
33
+ pendingTokens: number;
34
+ threshold: number;
35
+ effectiveObservationTokensThreshold: number;
36
+ shouldObserve: boolean;
37
+ shouldBuffer: boolean;
38
+ shouldReflect: boolean;
39
+ canActivate: boolean;
40
+ };
41
+ }
42
+ /** Returned by `turn.end()` — final turn state. */
43
+ export interface TurnResult {
44
+ record: ObservationalMemoryRecord;
45
+ }
46
+ //# 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,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,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,MAAM,MAAM,uBAAuB,GAAG,MAAM,MAAM,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACnC,mBAAmB,CAAC,EAAE,uBAAuB,GAAG,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,yBAAyB,CAAC,EAAE,uBAAuB,GAAG,CAAC,MAAM,IAAI,GAAG,OAA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