@mastra/memory 1.32.0-alpha.0 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-processors-token-limiter-processor.md +15 -10
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +3 -1
- package/dist/processors/index.js +2 -2
- package/dist/processors/observational-memory/constants.d.ts +11 -0
- package/dist/processors/observational-memory/constants.d.ts.map +1 -1
- package/dist/processors/observational-memory/index.d.ts +1 -1
- package/dist/processors/observational-memory/index.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts +16 -11
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/dist/{src-2UN5fCQ5.js → src-B0ISVOJX.js} +106 -53
- package/dist/src-B0ISVOJX.js.map +1 -0
- package/dist/{src-DmZEArj1.cjs → src-C7u5SaET.cjs} +117 -52
- package/dist/src-C7u5SaET.cjs.map +1 -0
- package/dist/system-reminders.d.ts +3 -0
- package/dist/system-reminders.d.ts.map +1 -0
- package/package.json +7 -7
- package/dist/src-2UN5fCQ5.js.map +0 -1
- package/dist/src-DmZEArj1.cjs.map +0 -1
|
@@ -18355,7 +18355,9 @@ var constants_exports = /* @__PURE__ */ __exportAll({
|
|
|
18355
18355
|
OBSERVATIONAL_MEMORY_DEFAULTS: () => OBSERVATIONAL_MEMORY_DEFAULTS,
|
|
18356
18356
|
OBSERVATION_CONTEXT_INSTRUCTIONS: () => OBSERVATION_CONTEXT_INSTRUCTIONS,
|
|
18357
18357
|
OBSERVATION_CONTEXT_PROMPT: () => OBSERVATION_CONTEXT_PROMPT,
|
|
18358
|
+
OBSERVATION_CONTEXT_PROMPT_THREAD: () => OBSERVATION_CONTEXT_PROMPT_THREAD,
|
|
18358
18359
|
OBSERVATION_CONTINUATION_HINT: () => OBSERVATION_CONTINUATION_HINT,
|
|
18360
|
+
getObservationContextPrompt: () => getObservationContextPrompt,
|
|
18359
18361
|
getRetrievalInstructions: () => getRetrievalInstructions
|
|
18360
18362
|
});
|
|
18361
18363
|
/**
|
|
@@ -18405,6 +18407,19 @@ Any messages following this reminder are newer and should take priority.`;
|
|
|
18405
18407
|
*/
|
|
18406
18408
|
const OBSERVATION_CONTEXT_PROMPT = `The following observations block contains your memory of past conversations with this user.`;
|
|
18407
18409
|
/**
|
|
18410
|
+
* Preamble used when observations are thread-scoped: they describe earlier parts
|
|
18411
|
+
* of the current conversation, not other conversations.
|
|
18412
|
+
*/
|
|
18413
|
+
const OBSERVATION_CONTEXT_PROMPT_THREAD = `The following observations block contains your memory of earlier parts of this current conversation. Everything recorded here (including IDs, artifacts, and tool results) came from this conversation and is available for you to reuse.`;
|
|
18414
|
+
/**
|
|
18415
|
+
* Returns the observations preamble matching the memory scope.
|
|
18416
|
+
* - `'thread'`: observations are earlier parts of the current conversation.
|
|
18417
|
+
* - `'resource'`: observations span past conversations with this user.
|
|
18418
|
+
*/
|
|
18419
|
+
function getObservationContextPrompt(scope = "thread") {
|
|
18420
|
+
return scope === "resource" ? OBSERVATION_CONTEXT_PROMPT : OBSERVATION_CONTEXT_PROMPT_THREAD;
|
|
18421
|
+
}
|
|
18422
|
+
/**
|
|
18408
18423
|
* Instructions that tell the model how to interpret and use observations.
|
|
18409
18424
|
* Place AFTER the `<observations>` block so the model sees the data before the rules.
|
|
18410
18425
|
*/
|
|
@@ -18682,7 +18697,7 @@ async function applyExtractorHooks(opts) {
|
|
|
18682
18697
|
}
|
|
18683
18698
|
//#endregion
|
|
18684
18699
|
//#region src/processors/observational-memory/error.ts
|
|
18685
|
-
function isRecord$
|
|
18700
|
+
function isRecord$5(value) {
|
|
18686
18701
|
return typeof value === "object" && value !== null;
|
|
18687
18702
|
}
|
|
18688
18703
|
/** Keep provider diagnostics in streamed/persisted markers, not whole API request/response objects. */
|
|
@@ -18694,7 +18709,7 @@ function formatOmError(error) {
|
|
|
18694
18709
|
};
|
|
18695
18710
|
function collectErrorDetails(value, depth) {
|
|
18696
18711
|
if (depth > 5) return;
|
|
18697
|
-
if (!isRecord$
|
|
18712
|
+
if (!isRecord$5(value)) {
|
|
18698
18713
|
if (value !== void 0) add(String(value));
|
|
18699
18714
|
return;
|
|
18700
18715
|
}
|
|
@@ -18704,10 +18719,10 @@ function formatOmError(error) {
|
|
|
18704
18719
|
if (typeof value.statusCode === "number") add(`HTTP ${value.statusCode}`);
|
|
18705
18720
|
if (typeof value.responseBody === "string") try {
|
|
18706
18721
|
const body = JSON.parse(value.responseBody);
|
|
18707
|
-
if (isRecord$
|
|
18722
|
+
if (isRecord$5(body)) {
|
|
18708
18723
|
add(body.message);
|
|
18709
18724
|
add(body.detail);
|
|
18710
|
-
if (isRecord$
|
|
18725
|
+
if (isRecord$5(body.error)) add(body.error.message);
|
|
18711
18726
|
else add(body.error);
|
|
18712
18727
|
}
|
|
18713
18728
|
} catch {}
|
|
@@ -18813,6 +18828,21 @@ ${extractorInstructions}${priorLines.length > 0 ? `\n\n## Prior Extracted Values
|
|
|
18813
18828
|
};
|
|
18814
18829
|
}
|
|
18815
18830
|
//#endregion
|
|
18831
|
+
//#region src/system-reminders.ts
|
|
18832
|
+
const LEGACY_SYSTEM_REMINDER_METADATA_KEY = "dynamicAgentsMdReminder";
|
|
18833
|
+
function isRecord$4(value) {
|
|
18834
|
+
return typeof value === "object" && value !== null;
|
|
18835
|
+
}
|
|
18836
|
+
function isSystemReminderMessage(message) {
|
|
18837
|
+
if (!isRecord$4(message.content)) return false;
|
|
18838
|
+
const metadata = message.content.metadata;
|
|
18839
|
+
if (message.role === "signal") return isRecord$4(metadata) && isRecord$4(metadata.signal) && (metadata.signal.type === "system-reminder" || metadata.signal.type === "reactive");
|
|
18840
|
+
if (message.role !== "user") return false;
|
|
18841
|
+
if (isRecord$4(metadata) && (isRecord$4(metadata.systemReminder) || LEGACY_SYSTEM_REMINDER_METADATA_KEY in metadata)) return true;
|
|
18842
|
+
const firstTextPart = message.content.parts.find((part) => part.type === "text");
|
|
18843
|
+
return typeof firstTextPart?.text === "string" && firstTextPart.text.startsWith("<system-reminder");
|
|
18844
|
+
}
|
|
18845
|
+
//#endregion
|
|
18816
18846
|
//#region src/processors/observational-memory/anchor-ids.ts
|
|
18817
18847
|
const ANCHOR_ID_PATTERN = /^\[(O\d+(?:-N\d+)?)\]\s*/;
|
|
18818
18848
|
const OBSERVATION_DATE_HEADER_PATTERN = /^\s*Date:\s+/;
|
|
@@ -20309,11 +20339,23 @@ function formatObserverToolArguments(args, maxCharacters) {
|
|
|
20309
20339
|
if (args === void 0) return maybeTruncate("[arguments unavailable]", maxCharacters);
|
|
20310
20340
|
return formatToolArgumentsForObserver(args, { maxCharacters: maxCharacters || void 0 });
|
|
20311
20341
|
}
|
|
20342
|
+
/**
|
|
20343
|
+
* Labels signals and system reminders by their tag instead of as "User", so the Observer
|
|
20344
|
+
* does not record runtime instructions as things the user said (#22195).
|
|
20345
|
+
*/
|
|
20346
|
+
function getObserverMessageLabel(msg) {
|
|
20347
|
+
if (msg.role === "signal") {
|
|
20348
|
+
const signal = msg.content?.metadata?.signal;
|
|
20349
|
+
return signal?.type === "user" ? "User" : signal?.tagName ?? signal?.type ?? "Signal";
|
|
20350
|
+
}
|
|
20351
|
+
if (isSystemReminderMessage(msg)) return "system-reminder";
|
|
20352
|
+
return msg.role.charAt(0).toUpperCase() + msg.role.slice(1);
|
|
20353
|
+
}
|
|
20312
20354
|
function formatObserverMessage(msg, counter, toolFormatting, options) {
|
|
20313
20355
|
const maxLen = options?.maxPartLength;
|
|
20314
20356
|
const maxToolResultTokens = options?.maxToolResultTokens ?? 5e3;
|
|
20315
20357
|
const attachmentFilter = options?.attachmentFilter;
|
|
20316
|
-
const role =
|
|
20358
|
+
const role = getObserverMessageLabel(msg);
|
|
20317
20359
|
const attachments = [];
|
|
20318
20360
|
const messageCreatedAt = normalizeObserverCreatedAt(msg.createdAt);
|
|
20319
20361
|
let lines = [];
|
|
@@ -20487,7 +20529,36 @@ function buildMultiThreadObserverHistoryMessage(messagesByThread, threadOrder, o
|
|
|
20487
20529
|
content
|
|
20488
20530
|
};
|
|
20489
20531
|
}
|
|
20490
|
-
|
|
20532
|
+
/**
|
|
20533
|
+
* Build the Observer's single multi-thread request message: prior memory first, then the
|
|
20534
|
+
* thread histories, then the task. Keeping everything in one user message, with the task
|
|
20535
|
+
* after the history, stops the Observer from reading its own instructions as something
|
|
20536
|
+
* the user said (#22195).
|
|
20537
|
+
*/
|
|
20538
|
+
function buildMultiThreadObserverRequestMessage(existingObservations, messagesByThread, threadOrder, priorMetadataByThread, wasTruncated, includeThreadTitle, extractors = [], formatOptions) {
|
|
20539
|
+
return surroundObserverHistory(buildMultiThreadObserverHistoryMessage(messagesByThread, threadOrder, formatOptions), buildMultiThreadObserverContextPrompt(existingObservations, threadOrder, priorMetadataByThread, wasTruncated, includeThreadTitle, extractors), buildMultiThreadObserverTaskInstructions(includeThreadTitle));
|
|
20540
|
+
}
|
|
20541
|
+
function surroundObserverHistory(history, contextPrompt, taskInstructions) {
|
|
20542
|
+
const historyContent = history.content;
|
|
20543
|
+
return {
|
|
20544
|
+
role: "user",
|
|
20545
|
+
content: [
|
|
20546
|
+
...contextPrompt ? [{
|
|
20547
|
+
type: "text",
|
|
20548
|
+
text: contextPrompt
|
|
20549
|
+
}] : [],
|
|
20550
|
+
...historyContent,
|
|
20551
|
+
{
|
|
20552
|
+
type: "text",
|
|
20553
|
+
text: `\n\n---\n\n${taskInstructions}`
|
|
20554
|
+
}
|
|
20555
|
+
]
|
|
20556
|
+
};
|
|
20557
|
+
}
|
|
20558
|
+
function buildMultiThreadObserverTaskInstructions(includeThreadTitle) {
|
|
20559
|
+
return `## Your Task\n\nExtract new observations from each thread. Output your observations grouped by thread using <thread id="..."> tags inside your <observations> block. Each thread block should contain that thread's observations, current-task, suggested-response${includeThreadTitle ? ", and thread-title" : ""}, in the format specified in your instructions.`;
|
|
20560
|
+
}
|
|
20561
|
+
function buildMultiThreadObserverContextPrompt(existingObservations, threadOrder, priorMetadataByThread, wasTruncated, includeThreadTitle, extractors = []) {
|
|
20491
20562
|
let prompt = "";
|
|
20492
20563
|
if (existingObservations) {
|
|
20493
20564
|
prompt += `## Previous Observations\n\n${existingObservations}\n\n---\n\n`;
|
|
@@ -20513,25 +20584,6 @@ function buildMultiThreadObserverTaskPrompt(existingObservations, threadOrder, p
|
|
|
20513
20584
|
}
|
|
20514
20585
|
prompt += `Use each thread's prior current-task, suggested-response${includeThreadTitle ? ", and thread-title" : ""} as continuity hints, then update them based on that thread's new messages.\n\n---\n\n`;
|
|
20515
20586
|
}
|
|
20516
|
-
prompt += `## Your Task\n\n`;
|
|
20517
|
-
prompt += `Extract new observations from each thread. Output your observations grouped by thread using <thread id="..."> tags inside your <observations> block. Each thread block should contain that thread's observations, current-task, suggested-response${includeThreadTitle ? ", and thread-title" : ""}.\n\n`;
|
|
20518
|
-
prompt += `Example output format:\n`;
|
|
20519
|
-
prompt += `<observations>\n`;
|
|
20520
|
-
prompt += `<thread id="thread1">\n`;
|
|
20521
|
-
prompt += `Date: Dec 4, 2025\n`;
|
|
20522
|
-
prompt += `* 🔴 (14:30) User prefers direct answers\n`;
|
|
20523
|
-
prompt += `<current-task>Working on feature X</current-task>\n`;
|
|
20524
|
-
prompt += `<suggested-response>Continue with the implementation</suggested-response>\n`;
|
|
20525
|
-
if (includeThreadTitle) prompt += `<thread-title>Feature X implementation</thread-title>\n`;
|
|
20526
|
-
prompt += `</thread>\n`;
|
|
20527
|
-
prompt += `<thread id="thread2">\n`;
|
|
20528
|
-
prompt += `Date: Dec 5, 2025\n`;
|
|
20529
|
-
prompt += `* 🔴 (09:15) User asked about deployment\n`;
|
|
20530
|
-
prompt += `<current-task>Discussing deployment options</current-task>\n`;
|
|
20531
|
-
prompt += `<suggested-response>Explain the deployment process</suggested-response>\n`;
|
|
20532
|
-
if (includeThreadTitle) prompt += `<thread-title>Deployment setup</thread-title>\n`;
|
|
20533
|
-
prompt += `</thread>\n`;
|
|
20534
|
-
prompt += `</observations>`;
|
|
20535
20587
|
return prompt;
|
|
20536
20588
|
}
|
|
20537
20589
|
/**
|
|
@@ -20589,6 +20641,24 @@ function parseMultiThreadObserverOutput(output, extractors = []) {
|
|
|
20589
20641
|
};
|
|
20590
20642
|
}
|
|
20591
20643
|
function buildObserverTaskPrompt(existingObservations, options) {
|
|
20644
|
+
return buildObserverContextPrompt(existingObservations, options) + buildObserverTaskInstructions(options);
|
|
20645
|
+
}
|
|
20646
|
+
/**
|
|
20647
|
+
* Build the Observer's single request message: prior memory first, then the message
|
|
20648
|
+
* history, then the task. Keeping everything in one user message, with the task after
|
|
20649
|
+
* the history, stops the Observer from reading its own instructions as something the
|
|
20650
|
+
* user said (#22195).
|
|
20651
|
+
*/
|
|
20652
|
+
function buildObserverRequestMessage(existingObservations, messagesToObserve, options, formatOptions) {
|
|
20653
|
+
return surroundObserverHistory(buildObserverHistoryMessage(messagesToObserve, formatOptions), buildObserverContextPrompt(existingObservations, options), buildObserverTaskInstructions(options));
|
|
20654
|
+
}
|
|
20655
|
+
function buildObserverTaskInstructions(options) {
|
|
20656
|
+
let prompt = `## Your Task\n\n`;
|
|
20657
|
+
prompt += `Extract new observations from the message history above. Do not repeat observations that are already in the previous observations. Add your new observations in the format specified in your instructions.`;
|
|
20658
|
+
if (options?.skipContinuationHints) prompt += `\n\nOutput <observations> every time.`;
|
|
20659
|
+
return prompt;
|
|
20660
|
+
}
|
|
20661
|
+
function buildObserverContextPrompt(existingObservations, options) {
|
|
20592
20662
|
let prompt = "";
|
|
20593
20663
|
if (existingObservations) {
|
|
20594
20664
|
prompt += `## Previous Observations\n\n${existingObservations}\n\n---\n\n`;
|
|
@@ -20609,9 +20679,6 @@ function buildObserverTaskPrompt(existingObservations, options) {
|
|
|
20609
20679
|
const titleHint = options?.includeThreadTitle ? ", and thread-title" : "";
|
|
20610
20680
|
prompt += `Use the prior current-task, suggested-response${titleHint} as continuity hints, then update them based on the new messages.\n\n---\n\n`;
|
|
20611
20681
|
}
|
|
20612
|
-
prompt += `## Your Task\n\n`;
|
|
20613
|
-
prompt += `Extract new observations from the message history above. Do not repeat observations that are already in the previous observations. Add your new observations in the format specified in your instructions.`;
|
|
20614
|
-
if (options?.skipContinuationHints) prompt += `\n\nOutput <observations> every time.`;
|
|
20615
20682
|
return prompt;
|
|
20616
20683
|
}
|
|
20617
20684
|
/**
|
|
@@ -21250,14 +21317,11 @@ var ObserverRunner = class {
|
|
|
21250
21317
|
const agent = temporaryMemory ? this.createAgent(resolvedModel.model, false, temporaryMemory.memory, activeExtractors) : this.createAgent(resolvedModel.model, false, void 0, activeExtractors);
|
|
21251
21318
|
const internalRequestContext = withOmInternalThreadId(options?.requestContext, agent.id);
|
|
21252
21319
|
const attachmentFilter = this.resolveAttachmentFilter(resolvedModel.model, options?.requestContext);
|
|
21253
|
-
const observerMessages = [{
|
|
21254
|
-
|
|
21255
|
-
|
|
21256
|
-
|
|
21257
|
-
|
|
21258
|
-
extractors: activeExtractors
|
|
21259
|
-
})
|
|
21260
|
-
}, buildObserverHistoryMessage(messagesToObserve, { attachmentFilter })];
|
|
21320
|
+
const observerMessages = [buildObserverRequestMessage(existingObservations, messagesToObserve, {
|
|
21321
|
+
...options,
|
|
21322
|
+
includeThreadTitle: this.observationConfig.threadTitle,
|
|
21323
|
+
extractors: activeExtractors
|
|
21324
|
+
}, { attachmentFilter })];
|
|
21261
21325
|
const doGenerate = async () => {
|
|
21262
21326
|
return withRetry(() => withOmTracingSpan({
|
|
21263
21327
|
phase: "observer",
|
|
@@ -21457,10 +21521,7 @@ var ObserverRunner = class {
|
|
|
21457
21521
|
const agent = this.createAgent(resolvedModel.model, true, void 0, activeExtractors);
|
|
21458
21522
|
const internalRequestContext = withOmInternalThreadId(requestContext, agent.id);
|
|
21459
21523
|
const multiThreadAttachmentFilter = this.resolveAttachmentFilter(resolvedModel.model, requestContext);
|
|
21460
|
-
const observerMessages = [{
|
|
21461
|
-
role: "user",
|
|
21462
|
-
content: buildMultiThreadObserverTaskPrompt(existingObservations, threadOrder, priorMetadataByThread, void 0, this.observationConfig.threadTitle, activeExtractors)
|
|
21463
|
-
}, buildMultiThreadObserverHistoryMessage(messagesByThread, threadOrder, { attachmentFilter: multiThreadAttachmentFilter })];
|
|
21524
|
+
const observerMessages = [buildMultiThreadObserverRequestMessage(existingObservations, messagesByThread, threadOrder, priorMetadataByThread, void 0, this.observationConfig.threadTitle, activeExtractors, { attachmentFilter: multiThreadAttachmentFilter })];
|
|
21464
21525
|
for (const msgs of messagesByThread.values()) for (const msg of msgs) this.observedMessageIds.add(msg.id);
|
|
21465
21526
|
const doGenerate = async () => {
|
|
21466
21527
|
return withRetry(() => withOmTracingSpan({
|
|
@@ -29679,7 +29740,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
29679
29740
|
formatObservationsForContext(observations, currentTask, suggestedResponse, extractedValues, unobservedContextBlocks, currentDate, retrieval = false) {
|
|
29680
29741
|
let optimized = retrieval ? renderObservationGroupsForReflection(observations) ?? optimizeObservationsForContext(observations) : optimizeObservationsForContext(observations);
|
|
29681
29742
|
if (currentDate) optimized = addRelativeTimeToObservations(optimized, currentDate);
|
|
29682
|
-
const messages = [`${
|
|
29743
|
+
const messages = [`${getObservationContextPrompt(this.scope)}\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}${retrieval ? `\n\n${getRetrievalInstructions(this.retrievalScope, this.retrievalInstructions, this.retrievalSearch)}` : ""}`];
|
|
29683
29744
|
if (unobservedContextBlocks) messages.push(`The following content is from OTHER conversations different from the current conversation, they're here for reference, but they're not necessarily your focus:\nSTART_OTHER_CONVERSATIONS_BLOCK\n${unobservedContextBlocks}\nEND_OTHER_CONVERSATIONS_BLOCK`);
|
|
29684
29745
|
const observationChunks = this.splitObservationContextChunks(optimized);
|
|
29685
29746
|
if (observationChunks.length > 0) messages.push("<observations>", ...observationChunks);
|
|
@@ -31623,6 +31684,7 @@ var observational_memory_exports = /* @__PURE__ */ __exportAll({
|
|
|
31623
31684
|
OBSERVATIONAL_MEMORY_DEFAULTS: () => OBSERVATIONAL_MEMORY_DEFAULTS,
|
|
31624
31685
|
OBSERVATION_CONTEXT_INSTRUCTIONS: () => OBSERVATION_CONTEXT_INSTRUCTIONS,
|
|
31625
31686
|
OBSERVATION_CONTEXT_PROMPT: () => OBSERVATION_CONTEXT_PROMPT,
|
|
31687
|
+
OBSERVATION_CONTEXT_PROMPT_THREAD: () => OBSERVATION_CONTEXT_PROMPT_THREAD,
|
|
31626
31688
|
OBSERVATION_CONTINUATION_HINT: () => OBSERVATION_CONTINUATION_HINT,
|
|
31627
31689
|
OBSERVER_SYSTEM_PROMPT: () => OBSERVER_SYSTEM_PROMPT,
|
|
31628
31690
|
ObservationalMemory: () => ObservationalMemory,
|
|
@@ -31640,6 +31702,7 @@ var observational_memory_exports = /* @__PURE__ */ __exportAll({
|
|
|
31640
31702
|
deriveObservationGroupProvenance: () => deriveObservationGroupProvenance,
|
|
31641
31703
|
extractCurrentTask: () => extractCurrentTask,
|
|
31642
31704
|
formatMessagesForObserver: () => formatMessagesForObserver,
|
|
31705
|
+
getObservationContextPrompt: () => getObservationContextPrompt,
|
|
31643
31706
|
getObservationsAsOf: () => getObservationsAsOf,
|
|
31644
31707
|
hasCurrentTaskSection: () => hasCurrentTaskSection,
|
|
31645
31708
|
injectAnchorIds: () => injectAnchorIds,
|
|
@@ -31667,7 +31730,6 @@ var working_memory_state_exports = /* @__PURE__ */ __exportAll({
|
|
|
31667
31730
|
//#region src/index.ts
|
|
31668
31731
|
const WORKING_MEMORY_START_TAG = "<working_memory>";
|
|
31669
31732
|
const WORKING_MEMORY_END_TAG = "</working_memory>";
|
|
31670
|
-
const LEGACY_SYSTEM_REMINDER_METADATA_KEY = "dynamicAgentsMdReminder";
|
|
31671
31733
|
function isRecord(value) {
|
|
31672
31734
|
return typeof value === "object" && value !== null;
|
|
31673
31735
|
}
|
|
@@ -31711,15 +31773,6 @@ function extractWorkingMemoryContent(text) {
|
|
|
31711
31773
|
if (end === -1) return null;
|
|
31712
31774
|
return text.substring(contentStart, end);
|
|
31713
31775
|
}
|
|
31714
|
-
function isSystemReminderMessage(message) {
|
|
31715
|
-
if (!isRecord(message.content)) return false;
|
|
31716
|
-
const metadata = message.content.metadata;
|
|
31717
|
-
if (message.role === "signal") return isRecord(metadata) && isRecord(metadata.signal) && (metadata.signal.type === "system-reminder" || metadata.signal.type === "reactive");
|
|
31718
|
-
if (message.role !== "user") return false;
|
|
31719
|
-
if (isRecord(metadata) && (isRecord(metadata.systemReminder) || LEGACY_SYSTEM_REMINDER_METADATA_KEY in metadata)) return true;
|
|
31720
|
-
const firstTextPart = message.content.parts.find((part) => part.type === "text");
|
|
31721
|
-
return typeof firstTextPart?.text === "string" && firstTextPart.text.startsWith("<system-reminder");
|
|
31722
|
-
}
|
|
31723
31776
|
function isRecallSignalType(type) {
|
|
31724
31777
|
return type === "user" || type === "state" || type === "reactive" || type === "notification" || type === "user-message" || type === "system-reminder";
|
|
31725
31778
|
}
|
|
@@ -33957,6 +34010,6 @@ Notes:
|
|
|
33957
34010
|
}
|
|
33958
34011
|
};
|
|
33959
34012
|
//#endregion
|
|
33960
|
-
export { formatMessagesForObserver as A,
|
|
34013
|
+
export { formatMessagesForObserver as A, OBSERVATION_CONTEXT_PROMPT_THREAD as B, SUMMARIZE_THREAD_DEFAULTS as C, buildObserverPrompt as D, OBSERVER_SYSTEM_PROMPT as E, parseAnchorId as F, StaleKnowledgeSemanticIndexError as G, getObservationContextPrompt as H, stripEphemeralAnchorIds as I, SUBCONSCIOUS_ACTIVITY_STATE_ID as J, SubconsciousRemindExtractor as K, OBSERVATIONAL_MEMORY_DEFAULTS as L, optimizeObservationsForContext as M, parseObserverOutput as N, buildObserverSystemPrompt as O, injectAnchorIds as P, Extractor as Q, OBSERVATION_CONTEXT_INSTRUCTIONS as R, WorkingMemoryExtractor as S, TokenCounter as T, Subconscious as U, OBSERVATION_CONTINUATION_HINT as V, KnowledgeSemanticIndexCoordinator as W, publishSubconsciousActivity as X, buildSubconsciousActivitySnapshot as Y, renderSubconsciousActivity as Z, wrapInObservationGroup as _, extractWorkingMemoryContent as a, WorkingMemoryStateProcessor as b, getObservationsAsOf as c, combineObservationGroupRanges as d, deriveObservationGroupProvenance as f, stripObservationGroups as g, renderObservationGroupsForReflection as h, WorkingMemory as i, hasCurrentTaskSection as j, extractCurrentTask as k, ObservationalMemoryProcessor as l, reconcileObservationGroupsFromReflection as m, MessageHistory$1 as n, extractWorkingMemoryTags as o, parseObservationGroups as p, ModelByInputTokens as q, SemanticRecall as r, removeWorkingMemoryTags as s, Memory as t, ObservationalMemory as u, WORKING_MEMORY_STATE_ID as v, summarizeConversation as w, deepMergeWorkingMemory as x, WORKING_MEMORY_STATE_PROCESSOR_ID as y, OBSERVATION_CONTEXT_PROMPT as z };
|
|
33961
34014
|
|
|
33962
|
-
//# sourceMappingURL=src-
|
|
34015
|
+
//# sourceMappingURL=src-B0ISVOJX.js.map
|