This commit is contained in:
2026-05-17 12:43:53 -07:00
commit 7c8def0aaa
7507 changed files with 1419399 additions and 0 deletions

33
dist/tools/memory-api.js vendored Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
// =============================================================================
// Pure memory API. The in-process agent-runner collects memory updates into an
// array on the ToolContext (ctx.memoryUpdates) so the supervisor loop can
// persist them at end-of-turn. MCP clients don't share that array, so the MCP
// server keeps its own module-level store keyed by an optional sessionKey.
// =============================================================================
Object.defineProperty(exports, "__esModule", { value: true });
exports.toEntry = toEntry;
exports.saveMemoryToStore = saveMemoryToStore;
exports.listMemoryFromStore = listMemoryFromStore;
exports.clearMemoryStore = clearMemoryStore;
function toEntry(input) {
return { key: input.key, type: input.type, value: input.value };
}
// -------------------------------------------------------------------
// In-memory store used by the MCP server path (the in-process path
// appends directly to ctx.memoryUpdates and ignores this store).
// -------------------------------------------------------------------
const memoryStore = new Map();
function saveMemoryToStore(sessionKey, input) {
const entry = toEntry(input);
const list = memoryStore.get(sessionKey) ?? [];
list.push(entry);
memoryStore.set(sessionKey, list);
return { saved: true, entry };
}
function listMemoryFromStore(sessionKey) {
return [...(memoryStore.get(sessionKey) ?? [])];
}
function clearMemoryStore(sessionKey) {
memoryStore.delete(sessionKey);
}