#1 Persistent memory for AI coding agents based on real-world benchmarks
TypeScript agentmemoryagentsaiclaudeclaudecodecodexcopilotcursorgenaiharnesshermesmemoryompopenclawopencodepi
fix: iii-sdk v0.11 getContext crash — add logger shim, v0.8.11 (#146)
Rohit Ghumare0023af2c533a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 64889abb..5e07acb5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),## [Unreleased]+## [0.8.11] — 2026-04-15++**Fix**: `node dist/index.mjs` crashed on first import after the iii-sdk v0.11 migration (#116) merged. iii-sdk v0.11 dropped `getContext()`, but 32 `src/functions/*.ts` files still imported and called it. Added `src/logger.ts` (thin stderr shim with the same `.info/.warn/.error` signature) and mechanically replaced every `ctx.logger.*` call. Updated all 45 test mock blocks. Fixed `search.ts` `registerFunction` call to use the v0.11 string-ID API.++### Fixed++- **iii-sdk v0.11 getContext crash** ([#116](https://github.com/rohitg00/agentmemory/issues/116)) — `SyntaxError: The requested module 'iii-sdk' does not provide an export named 'getContext'` on startup. Removed all `getContext` imports from 32 function files, added `src/logger.ts` shim, updated 45 test mock blocks.+### Changed- Upgraded `iii-sdk` dependency from `^0.11.0-next.8` to stable `^0.11.0`.diff --git a/package.json b/package.jsonindex 14569303..729a9cf6 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "@agentmemory/agentmemory",- "version": "0.8.10",+ "version": "0.8.11","description": "Persistent memory for AI coding agents, powered by iii-engine's three primitives","type": "module","main": "dist/index.mjs",diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.jsonindex 28af4fd4..d7114962 100644--- a/plugin/.claude-plugin/plugin.json+++ b/plugin/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "agentmemory",- "version": "0.8.10",+ "version": "0.8.11","description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 43 MCP tools, 4 skills, real-time viewer.","author": {"name": "Rohit Ghumare",diff --git a/src/functions/access-tracker.ts b/src/functions/access-tracker.tsindex f7cf8dda..67914092 100644--- a/src/functions/access-tracker.ts+++ b/src/functions/access-tracker.ts@@ -1,7 +1,7 @@-import { getContext } from "iii-sdk";import { KV } from "../state/schema.js";import type { StateKV } from "../state/kv.js";import { withKeyedLock } from "../state/keyed-mutex.js";+import { logger } from "../logger.js";const RECENT_CAP = 20;@@ -71,8 +71,7 @@ export async function recordAccess(});} catch (err) {try {- const ctx = getContext();- ctx.logger.warn("recordAccess failed", {+ logger.warn("recordAccess failed", {memoryId,error: err instanceof Error ? err.message : String(err),});diff --git a/src/functions/audit.ts b/src/functions/audit.tsindex 228b7f37..5cb0e1a9 100644--- a/src/functions/audit.ts+++ b/src/functions/audit.ts@@ -1,7 +1,7 @@-import { getContext } from "iii-sdk";import type { AuditEntry } from "../types.js";import { KV, generateId } from "../state/schema.js";import type { StateKV } from "../state/kv.js";+import { logger } from "../logger.js";export async function recordAudit(kv: StateKV,@@ -39,8 +39,7 @@ export async function safeAudit(await recordAudit(kv, operation, functionId, targetIds, details, qualityScore, userId);} catch (err) {try {- const ctx = getContext();- ctx.logger.warn("audit write failed", {+ logger.warn("audit write failed", {functionId,operation,targetIds,diff --git a/src/functions/auto-forget.ts b/src/functions/auto-forget.tsindex f55171c1..1287c98b 100644--- a/src/functions/auto-forget.ts+++ b/src/functions/auto-forget.ts@@ -1,10 +1,10 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type { Memory, CompressedObservation, Session } from "../types.js";import { KV, jaccardSimilarity } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";import { deleteAccessLog } from "./access-tracker.js";+import { logger } from "../logger.js";const MS_PER_DAY = 24 * 60 * 60 * 1000;const CONTRADICTION_THRESHOLD = 0.9;@@ -23,7 +23,6 @@ interface AutoForgetResult {export function registerAutoForgetFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::auto-forget",async (data: { dryRun?: boolean }): Promise<AutoForgetResult> => {- const ctx = getContext();const dryRun = data?.dryRun ?? false;const now = Date.now();@@ -172,7 +171,7 @@ export function registerAutoForgetFunction(sdk: ISdk, kv: StateKV): void {}}- ctx.logger.info("Auto-forget complete", {+ logger.info("Auto-forget complete", {ttlExpired: result.ttlExpired.length,contradictions: result.contradictions.length,lowValueObs: result.lowValueObs.length,diff --git a/src/functions/claude-bridge.ts b/src/functions/claude-bridge.tsindex 667c141b..3aba76f5 100644--- a/src/functions/claude-bridge.ts+++ b/src/functions/claude-bridge.ts@@ -1,11 +1,11 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";import { dirname } from "node:path";import type { Memory, ClaudeBridgeConfig } from "../types.js";import { KV } from "../state/schema.js";import type { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";+import { logger } from "../logger.js";function parseMemoryMd(content: string): {sections: Map<string, string>;@@ -76,7 +76,6 @@ export function registerClaudeBridgeFunction(): void {sdk.registerFunction("mem::claude-bridge-read",async () => {- const ctx = getContext();if (!config.enabled || !config.memoryFilePath) {return { success: false, error: "Claude bridge not configured" };}@@ -99,14 +98,14 @@ export function registerClaudeBridgeFunction(lineCount: content.split("\n").length,});- ctx.logger.info("Claude bridge: read MEMORY.md", {+ logger.info("Claude bridge: read MEMORY.md", {path: config.memoryFilePath,lines: content.split("\n").length,});return { success: true, content, sections: Object.fromEntries(sections) };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Claude bridge read failed", { error: msg });+ logger.error("Claude bridge read failed", { error: msg });return { success: false, error: msg };}},@@ -114,7 +113,6 @@ export function registerClaudeBridgeFunction(sdk.registerFunction("mem::claude-bridge-sync",async () => {- const ctx = getContext();if (!config.enabled || !config.memoryFilePath) {return { success: false, error: "Claude bridge not configured" };}@@ -149,14 +147,14 @@ export function registerClaudeBridgeFunction(lines: md.split("\n").length,});- ctx.logger.info("Claude bridge: synced to MEMORY.md", {+ logger.info("Claude bridge: synced to MEMORY.md", {path: config.memoryFilePath,memories: latestMemories.length,});return { success: true, path: config.memoryFilePath, lines: md.split("\n").length };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Claude bridge sync failed", { error: msg });+ logger.error("Claude bridge sync failed", { error: msg });return { success: false, error: msg };}},diff --git a/src/functions/compress.ts b/src/functions/compress.tsindex c33e2376..44562065 100644--- a/src/functions/compress.ts+++ b/src/functions/compress.ts@@ -1,4 +1,4 @@-import { TriggerAction, getContext, type ISdk } from "iii-sdk";+import { TriggerAction, type ISdk } from "iii-sdk";import type {RawObservation,CompressedObservation,@@ -18,6 +18,7 @@ import { validateOutput } from "../eval/validator.js";import { scoreCompression } from "../eval/quality.js";import { compressWithRetry } from "../eval/self-correct.js";import type { MetricsStore } from "../eval/metrics-store.js";+import { logger } from "../logger.js";const VALID_TYPES = new Set<string>(["file_read",@@ -71,7 +72,6 @@ export function registerCompressFunction(sessionId: string;raw: RawObservation;}) => {- const ctx = getContext();const startMs = Date.now();const prompt = buildCompressionPrompt({hookType: data.raw.hookType,@@ -110,7 +110,7 @@ export function registerCompressFunction(if (metricsStore) {await metricsStore.record("mem::compress", latencyMs, false);}- ctx.logger.warn("Failed to parse compression XML", {+ logger.warn("Failed to parse compression XML", {obsId: data.observationId,retried,});@@ -163,7 +163,7 @@ export function registerCompressFunction(]);for (const result of streamResults) {if (result.status === "rejected") {- ctx.logger.warn("Non-fatal stream publish failure after compress", {+ logger.warn("Non-fatal stream publish failure after compress", {sessionId: data.sessionId,observationId: data.observationId,error:@@ -184,7 +184,7 @@ export function registerCompressFunction();}- ctx.logger.info("Observation compressed", {+ logger.info("Observation compressed", {obsId: data.observationId,type: compressed.type,importance: compressed.importance,@@ -199,7 +199,7 @@ export function registerCompressFunction(if (metricsStore) {await metricsStore.record("mem::compress", latencyMs, false);}- ctx.logger.error("Compression failed", {+ logger.error("Compression failed", {obsId: data.observationId,error: msg,});diff --git a/src/functions/consolidate.ts b/src/functions/consolidate.tsindex 7d56c2ae..9ee0b14c 100644--- a/src/functions/consolidate.ts+++ b/src/functions/consolidate.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {CompressedObservation,Memory,@@ -27,6 +26,7 @@ Output XML:</memory>`;import { getXmlTag, getXmlChildren } from "../prompts/xml.js";+import { logger } from "../logger.js";function parseMemoryXml(xml: string,@@ -69,7 +69,6 @@ export function registerConsolidateFunction(): void {sdk.registerFunction("mem::consolidate",async (data: { project?: string; minObservations?: number }) => {- const ctx = getContext();const minObs = data.minObservations ?? 10;const sessions = await kv.list<Session>(KV.sessions);@@ -209,14 +208,14 @@ export function registerConsolidateFunction(consolidated++;}} catch (err) {- ctx.logger.warn("Consolidation failed for concept", {+ logger.warn("Consolidation failed for concept", {concept,error: err instanceof Error ? err.message : String(err),});}}- ctx.logger.info("Consolidation complete", {+ logger.info("Consolidation complete", {consolidated,totalObs: allObs.length,});diff --git a/src/functions/consolidation-pipeline.ts b/src/functions/consolidation-pipeline.tsindex 2f8e6c1d..0c52a0cb 100644--- a/src/functions/consolidation-pipeline.ts+++ b/src/functions/consolidation-pipeline.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {SemanticMemory,ProceduralMemory,@@ -17,6 +16,7 @@ import {} from "../prompts/consolidation.js";import { recordAudit } from "./audit.js";import { getConsolidationDecayDays, isConsolidationEnabled } from "../config.js";+import { logger } from "../logger.js";function applyDecay(items: Array<{@@ -52,7 +52,6 @@ export function registerConsolidationPipelineFunction(if (!data?.force && !isConsolidationEnabled()) {return { success: false, skipped: true, reason: "CONSOLIDATION_ENABLED is not set to true" };}- const ctx = getContext();const tier = data?.tier || "all";const decayDays = getConsolidationDecayDays();const results: Record<string, unknown> = {};@@ -123,7 +122,7 @@ export function registerConsolidationPipelineFunction(results.semantic = { newFacts, totalSummaries: summaries.length };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Semantic consolidation failed", { error: msg });+ logger.error("Semantic consolidation failed", { error: msg });results.semantic = { error: msg };}} else {@@ -143,7 +142,7 @@ export function registerConsolidationPipelineFunction(results.reflect = reflectResult;} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.warn("Reflect tier failed", { error: msg });+ logger.warn("Reflect tier failed", { error: msg });results.reflect = { error: msg };}}@@ -218,7 +217,7 @@ export function registerConsolidationPipelineFunction(};} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Procedural extraction failed", { error: msg });+ logger.error("Procedural extraction failed", { error: msg });results.procedural = { error: msg };}} else {@@ -254,7 +253,7 @@ export function registerConsolidationPipelineFunction(results.obsidianExport = { success: true };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.warn("Obsidian auto-export failed", { error: msg });+ logger.warn("Obsidian auto-export failed", { error: msg });results.obsidianExport = { success: false, error: msg };}}@@ -264,7 +263,7 @@ export function registerConsolidationPipelineFunction(results,});- ctx.logger.info("Consolidation pipeline complete", { tier, results });+ logger.info("Consolidation pipeline complete", { tier, results });return { success: true, results };},);diff --git a/src/functions/context.ts b/src/functions/context.tsindex 798e9ff1..c258a45b 100644--- a/src/functions/context.ts+++ b/src/functions/context.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {Session,CompressedObservation,@@ -10,6 +9,7 @@ import type {import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAccessBatch } from "./access-tracker.js";+import { logger } from "../logger.js";function estimateTokens(text: string): number {return Math.ceil(text.length / 3);@@ -30,7 +30,6 @@ export function registerContextFunction(): void {sdk.registerFunction("mem::context",async (data: { sessionId: string; project: string; budget?: number }) => {- const ctx = getContext();const budget = data.budget || tokenBudget;const blocks: ContextBlock[] = [];@@ -161,12 +160,12 @@ export function registerContextFunction(}if (selected.length === 0) {- ctx.logger.info("No context available", { project: data.project });+ logger.info("No context available", { project: data.project });return { context: "", blocks: 0, tokens: 0 };}const result = `${header}\n${selected.join("\n\n")}\n${footer}`;- ctx.logger.info("Context generated", {+ logger.info("Context generated", {blocks: selected.length,tokens: usedTokens,});diff --git a/src/functions/enrich.ts b/src/functions/enrich.tsindex f853a7b1..38b6aac2 100644--- a/src/functions/enrich.ts+++ b/src/functions/enrich.ts@@ -1,8 +1,8 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type { Memory } from "../types.js";import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";+import { logger } from "../logger.js";const MAX_CONTEXT_LENGTH = 4000;@@ -23,7 +23,6 @@ export function registerEnrichFunction(sdk: ISdk, kv: StateKV): void {terms?: string[];toolName?: string;}) => {- const ctx = getContext();const parts: string[] = [];const fileContextPromise = sdk@@ -117,7 +116,7 @@ export function registerEnrichFunction(sdk: ISdk, kv: StateKV): void {truncated = true;}- ctx.logger.info("Enrichment completed", {+ logger.info("Enrichment completed", {sessionId: data.sessionId,fileCount: data.files.length,contextLength: context.length,diff --git a/src/functions/evict.ts b/src/functions/evict.tsindex 1035c55e..78579abd 100644--- a/src/functions/evict.ts+++ b/src/functions/evict.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {Session,CompressedObservation,@@ -10,6 +9,7 @@ import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";import { deleteAccessLog } from "./access-tracker.js";+import { logger } from "../logger.js";interface EvictionConfig {staleSessionDays: number;@@ -39,7 +39,6 @@ interface EvictionStats {export function registerEvictFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::evict",async (data: { dryRun?: boolean }): Promise<EvictionStats> => {- const ctx = getContext();const dryRun = data?.dryRun ?? false;const configOverride = await kv@@ -75,7 +74,7 @@ export function registerEvictFunction(sdk: ISdk, kv: StateKV): void {await kv.delete(KV.sessions, session.id);stats.staleSessions++;} catch (err) {- ctx.logger.warn("Eviction delete failed", {+ logger.warn("Eviction delete failed", {resource: "session",id: session.id,error: err instanceof Error ? err.message : String(err),@@ -113,7 +112,7 @@ export function registerEvictFunction(sdk: ISdk, kv: StateKV): void {await kv.delete(KV.observations(session.id), o.id);stats.lowImportanceObs++;} catch (err) {- ctx.logger.warn("Eviction delete failed", {+ logger.warn("Eviction delete failed", {resource: "observation",id: o.id,sessionId: session.id,@@ -154,7 +153,7 @@ export function registerEvictFunction(sdk: ISdk, kv: StateKV): void {await kv.delete(KV.observations(o.sessionId), o.id);stats.capEvictions++;} catch (err) {- ctx.logger.warn("Eviction delete failed", {+ logger.warn("Eviction delete failed", {resource: "observation",id: o.id,sessionId: o.sessionId,@@ -188,7 +187,7 @@ export function registerEvictFunction(sdk: ISdk, kv: StateKV): void {stats.expiredMemories++;evictedMemIds.add(mem.id);} catch (err) {- ctx.logger.warn("Eviction delete failed", {+ logger.warn("Eviction delete failed", {resource: "memory",id: mem.id,reason: "expired_memory",@@ -220,7 +219,7 @@ export function registerEvictFunction(sdk: ISdk, kv: StateKV): void {await kv.delete(KV.memories, mem.id);stats.nonLatestMemories++;} catch (err) {- ctx.logger.warn("Eviction delete failed", {+ logger.warn("Eviction delete failed", {resource: "memory",id: mem.id,reason: "old_non_latest_memory",@@ -239,7 +238,7 @@ export function registerEvictFunction(sdk: ISdk, kv: StateKV): void {}}- ctx.logger.info("Eviction complete", { stats });+ logger.info("Eviction complete", { stats });return stats;},);diff --git a/src/functions/export-import.ts b/src/functions/export-import.tsindex 4b26e727..05b24dcf 100644--- a/src/functions/export-import.ts+++ b/src/functions/export-import.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {Session,CompressedObservation,@@ -30,11 +29,11 @@ import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { VERSION } from "../version.js";import { recordAudit } from "./audit.js";+import { logger } from "../logger.js";export function registerExportImportFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::export",async (data?: { maxSessions?: number; offset?: number }) => {- const ctx = getContext();const rawMax = Number(data?.maxSessions);const maxSessions = Number.isFinite(rawMax) && rawMax > 0 ? Math.min(Math.floor(rawMax), 1000) : undefined;const rawOffset = Number(data?.offset);@@ -150,7 +149,7 @@ export function registerExportImportFunction(sdk: ISdk, kv: StateKV): void {(sum, arr) => sum + arr.length,0,);- ctx.logger.info("Export complete", {+ logger.info("Export complete", {sessions: paginatedSessions.length,totalSessions: allSessions.length,observations: totalObs,@@ -167,7 +166,6 @@ export function registerExportImportFunction(sdk: ISdk, kv: StateKV): void {exportData: ExportData;strategy?: "merge" | "replace" | "skip";}) => {- const ctx = getContext();if (!data?.exportData ||typeof data.exportData !== "object" ||@@ -178,7 +176,7 @@ export function registerExportImportFunction(sdk: ISdk, kv: StateKV): void {const strategy = data.strategy || "merge";const importData = data.exportData;- const supportedVersions = new Set(["0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.7.0", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7", "0.8.8", "0.8.9", "0.8.10"]);+ const supportedVersions = new Set(["0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.7.0", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7", "0.8.8", "0.8.9", "0.8.10", "0.8.11"]);if (!supportedVersions.has(importData.version)) {return {success: false,@@ -574,7 +572,7 @@ export function registerExportImportFunction(sdk: ISdk, kv: StateKV): void {}}- ctx.logger.info("Import complete", { strategy, ...stats });+ logger.info("Import complete", { strategy, ...stats });await recordAudit(kv, "import", "mem::import", [], {strategy,stats,diff --git a/src/functions/file-index.ts b/src/functions/file-index.tsindex cefb3f23..a5c50318 100644--- a/src/functions/file-index.ts+++ b/src/functions/file-index.ts@@ -1,10 +1,10 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type { CompressedObservation, Session } from "../types.js";import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";import { recordAccessBatch } from "./access-tracker.js";+import { logger } from "../logger.js";interface FileHistory {file: string;@@ -24,7 +24,6 @@ export function registerFileIndexFunction(sdk: ISdk, kv: StateKV): void {async (data: { sessionId?: string; files?: string[]; project?: string } | undefined,) => {- const ctx = getContext();const sessionId =data && typeof data.sessionId === "string" ? data.sessionId.trim() : "";const normalizedProject =@@ -125,7 +124,7 @@ export function registerFileIndexFunction(sdk: ISdk, kv: StateKV): void {void recordAccessBatch(kv, accessedIds);const context = lines.join("\n");- ctx.logger.info("File context generated", {+ logger.info("File context generated", {files: files.length,results: results.length,});diff --git a/src/functions/governance.ts b/src/functions/governance.tsindex 8b89a6d5..60813dd4 100644--- a/src/functions/governance.ts+++ b/src/functions/governance.ts@@ -1,15 +1,14 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type { Memory, GovernanceFilter, AuditEntry } from "../types.js";import { KV } from "../state/schema.js";import type { StateKV } from "../state/kv.js";import { recordAudit, safeAudit, queryAudit } from "./audit.js";import { deleteAccessLog } from "./access-tracker.js";+import { logger } from "../logger.js";export function registerGovernanceFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::governance-delete",async (data: { memoryIds: string[]; reason?: string }) => {- const ctx = getContext();if (!data.memoryIds ||!Array.isArray(data.memoryIds) ||@@ -39,7 +38,7 @@ export function registerGovernanceFunction(sdk: ISdk, kv: StateKV): void {},);- ctx.logger.info("Governance delete", {+ logger.info("Governance delete", {requested: data.memoryIds.length,deleted,});@@ -49,7 +48,6 @@ export function registerGovernanceFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::governance-bulk",async (data: GovernanceFilter & { dryRun?: boolean }) => {- const ctx = getContext();const hasFilter =(data.type && data.type.length > 0) ||@@ -116,7 +114,7 @@ export function registerGovernanceFunction(sdk: ISdk, kv: StateKV): void {if (result.status === "fulfilled") {successfulIds.push(mem.id);} else {- ctx.logger.warn("Governance bulk delete failed", {+ logger.warn("Governance bulk delete failed", {memoryId: mem.id,error:result.reason instanceof Error@@ -144,7 +142,7 @@ export function registerGovernanceFunction(sdk: ISdk, kv: StateKV): void {},);- ctx.logger.info("Governance bulk delete", {+ logger.info("Governance bulk delete", {deleted: successfulIds.length,failed: failures.length,});diff --git a/src/functions/graph.ts b/src/functions/graph.tsindex 84c295a2..b509016a 100644--- a/src/functions/graph.ts+++ b/src/functions/graph.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {GraphNode,GraphEdge,@@ -14,6 +13,7 @@ import {buildGraphExtractionPrompt,} from "../prompts/graph-extraction.js";import { recordAudit } from "./audit.js";+import { logger } from "../logger.js";function parseGraphXml(xml: string,@@ -86,7 +86,6 @@ export function registerGraphFunction(): void {sdk.registerFunction("mem::graph-extract",async (data: { observations: CompressedObservation[] }) => {- const ctx = getContext();if (!data.observations || data.observations.length === 0) {return { success: false, error: "No observations provided" };}@@ -155,7 +154,7 @@ export function registerGraphFunction(edgesExtracted: edges.length,});- ctx.logger.info("Graph extraction complete", {+ logger.info("Graph extraction complete", {nodes: nodes.length,edges: edges.length,});@@ -166,7 +165,7 @@ export function registerGraphFunction(};} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Graph extraction failed", { error: msg });+ logger.error("Graph extraction failed", { error: msg });return { success: false, error: msg };}},diff --git a/src/functions/migrate.ts b/src/functions/migrate.tsindex fc2a87c7..f9781500 100644--- a/src/functions/migrate.ts+++ b/src/functions/migrate.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import { resolve } from "node:path";import { homedir } from "node:os";import { KV, generateId } from "../state/schema.js";@@ -9,6 +8,7 @@ import type {CompressedObservation,SessionSummary,} from "../types.js";+import { logger } from "../logger.js";const ALLOWED_DIRS = [resolve(homedir(), ".agentmemory")];@@ -20,8 +20,7 @@ function isAllowedPath(dbPath: string): boolean {export function registerMigrateFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::migrate",async (data: { dbPath: string }) => {- const ctx = getContext();- ctx.logger.info("Migration started", { dbPath: data.dbPath });+ logger.info("Migration started", { dbPath: data.dbPath });if (!isAllowedPath(data.dbPath)) {return {@@ -85,7 +84,7 @@ export function registerMigrateFunction(sdk: ISdk, kv: StateKV): void {).all() as any[];} catch {- ctx.logger.warn("No observation tables found");+ logger.warn("No observation tables found");}}@@ -114,7 +113,7 @@ export function registerMigrateFunction(sdk: ISdk, kv: StateKV): void {.prepare("SELECT * FROM session_summaries").all() as any[];} catch {- ctx.logger.warn("No summaries table found");+ logger.warn("No summaries table found");}for (const row of summaries) {@@ -133,7 +132,7 @@ export function registerMigrateFunction(sdk: ISdk, kv: StateKV): void {summaryCount++;}- ctx.logger.info("Migration complete", {+ logger.info("Migration complete", {sessionCount,obsCount,summaryCount,@@ -141,7 +140,7 @@ export function registerMigrateFunction(sdk: ISdk, kv: StateKV): void {return { success: true, sessionCount, obsCount, summaryCount };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Migration failed", { error: msg });+ logger.error("Migration failed", { error: msg });return { success: false, error: "Migration failed" };} finally {try {diff --git a/src/functions/observe.ts b/src/functions/observe.tsindex f4d2a036..2043647c 100644--- a/src/functions/observe.ts+++ b/src/functions/observe.ts@@ -1,4 +1,4 @@-import { TriggerAction, getContext, type ISdk } from "iii-sdk";+import { TriggerAction, type ISdk } from "iii-sdk";import type { RawObservation, HookPayload } from "../types.js";import { KV, STREAM, generateId } from "../state/schema.js";import { StateKV } from "../state/kv.js";@@ -8,6 +8,7 @@ import { withKeyedLock } from "../state/keyed-mutex.js";import { isAutoCompressEnabled } from "../config.js";import { buildSyntheticCompression } from "./compress-synthetic.js";import { getSearchIndex } from "./search.js";+import { logger } from "../logger.js";export function registerObserveFunction(sdk: ISdk,@@ -17,7 +18,6 @@ export function registerObserveFunction(): void {sdk.registerFunction("mem::observe",async (payload: HookPayload) => {- const ctx = getContext();if (!payload?.sessionId ||@@ -185,7 +185,7 @@ export function registerObserveFunction(});}- ctx.logger.info("Observation captured", {+ logger.info("Observation captured", {obsId,sessionId: payload.sessionId,hook: payload.hookType,diff --git a/src/functions/patterns.ts b/src/functions/patterns.tsindex d540501e..8d1365fc 100644--- a/src/functions/patterns.ts+++ b/src/functions/patterns.ts@@ -1,8 +1,8 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type { CompressedObservation, Session } from "../types.js";import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";+import { logger } from "../logger.js";interface Pattern {type: "co_change" | "error_repeat" | "workflow";@@ -15,7 +15,6 @@ interface Pattern {export function registerPatternsFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::patterns",async (data: { project?: string }) => {- const ctx = getContext();const patterns: Pattern[] = [];const sessions = await kv.list<Session>(KV.sessions);@@ -97,7 +96,7 @@ export function registerPatternsFunction(sdk: ISdk, kv: StateKV): void {patterns.sort((a, b) => b.frequency - a.frequency);- ctx.logger.info("Pattern detection complete", {+ logger.info("Pattern detection complete", {patterns: patterns.length,sessions: filtered.length,});@@ -108,7 +107,6 @@ export function registerPatternsFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::generate-rules",async (data: { project?: string }) => {- const ctx = getContext();const result = await sdk.trigger<{ project?: string },{ patterns: Pattern[] }@@ -129,7 +127,7 @@ export function registerPatternsFunction(sdk: ISdk, kv: StateKV): void {}}- ctx.logger.info("Rules generated", { count: rules.length });+ logger.info("Rules generated", { count: rules.length });return { rules };},);diff --git a/src/functions/profile.ts b/src/functions/profile.tsindex 3769efe5..07881e92 100644--- a/src/functions/profile.ts+++ b/src/functions/profile.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {CompressedObservation,Session,@@ -8,11 +7,11 @@ import type {import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";+import { logger } from "../logger.js";export function registerProfileFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::profile",async (data: { project: string; refresh?: boolean } | undefined) => {- const ctx = getContext();if (!data || typeof data.project !== "string" || !data.project.trim()) {return { success: false, error: "project is required" };}@@ -116,7 +115,7 @@ export function registerProfileFunction(sdk: ISdk, kv: StateKV): void {totalObservations: totalObs,});- ctx.logger.info("Profile generated", {+ logger.info("Profile generated", {project,sessions: projectSessions.length,observations: totalObs,diff --git a/src/functions/query-expansion.ts b/src/functions/query-expansion.tsindex 10949628..00cfdf48 100644--- a/src/functions/query-expansion.ts+++ b/src/functions/query-expansion.ts@@ -1,6 +1,6 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type { MemoryProvider, QueryExpansion } from "../types.js";+import { logger } from "../logger.js";const QUERY_EXPANSION_SYSTEM = `You are a query expansion engine for a memory retrieval system. Given a user query, generate diverse reformulations to maximize recall.@@ -72,9 +72,8 @@ export function registerQueryExpansionFunction(): void {sdk.registerFunction("mem::expand-query",async (data: { query: string; maxReformulations?: number } | undefined) => {- const ctx = getContext();if (!data || typeof data.query !== "string" || !data.query.trim()) {- ctx.logger.warn("Invalid expand-query payload");+ logger.warn("Invalid expand-query payload");return { success: false, error: "query must be a non-empty string" };}const rawMaxR = Number(data.maxReformulations);@@ -91,7 +90,7 @@ export function registerQueryExpansionFunction(const parsed = parseExpansionXml(response);if (!parsed) {- ctx.logger.warn("Failed to parse query expansion");+ logger.warn("Failed to parse query expansion");return {success: true,expansion: {@@ -106,7 +105,7 @@ export function registerQueryExpansionFunction(parsed.original = query;parsed.reformulations = parsed.reformulations.slice(0, maxR);- ctx.logger.info("Query expanded", {+ logger.info("Query expanded", {original: query,reformulations: parsed.reformulations.length,entities: parsed.entityExtractions.length,@@ -115,7 +114,7 @@ export function registerQueryExpansionFunction(return { success: true, expansion: parsed };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Query expansion failed", { error: msg });+ logger.error("Query expansion failed", { error: msg });return {success: true,expansion: {diff --git a/src/functions/relations.ts b/src/functions/relations.tsindex 2636347b..7921a328 100644--- a/src/functions/relations.ts+++ b/src/functions/relations.ts@@ -1,11 +1,11 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type { Memory, MemoryRelation } from "../types.js";import { KV, generateId } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { withKeyedLock } from "../state/keyed-mutex.js";import { safeAudit } from "./audit.js";import { recordAccessBatch } from "./access-tracker.js";+import { logger } from "../logger.js";function computeConfidence(source: Memory,@@ -44,7 +44,6 @@ export function registerRelationsFunction(sdk: ISdk, kv: StateKV): void {type: MemoryRelation["type"];confidence?: number;}) => {- const ctx = getContext();const [firstId, secondId] = [data.sourceId, data.targetId].sort();const lockKey =firstId === secondId ? `mem:${firstId}` : `mem:${firstId}:${secondId}`;@@ -116,7 +115,7 @@ export function registerRelationsFunction(sdk: ISdk, kv: StateKV): void {);}- ctx.logger.info("Memory relation created", {+ logger.info("Memory relation created", {relationId,type: data.type,source: data.sourceId,@@ -133,7 +132,6 @@ export function registerRelationsFunction(sdk: ISdk, kv: StateKV): void {newContent: string;newTitle?: string;}) => {- const ctx = getContext();const existing = await kv.get<Memory>(KV.memories, data.memoryId);if (!existing) {@@ -185,7 +183,7 @@ export function registerRelationsFunction(sdk: ISdk, kv: StateKV): void {newId: evolved.id,});- ctx.logger.info("Memory evolved", {+ logger.info("Memory evolved", {oldId: existing.id,newId: evolved.id,version: evolved.version,@@ -200,7 +198,6 @@ export function registerRelationsFunction(sdk: ISdk, kv: StateKV): void {maxHops?: number;minConfidence?: number;}) => {- const ctx = getContext();const maxHops = Math.min(data.maxHops ?? 2, 5);const MAX_VISITED = 500;const rawMinConf = Number(data.minConfidence);@@ -271,7 +268,7 @@ export function registerRelationsFunction(sdk: ISdk, kv: StateKV): void {result.map((r) => r.memory.id),);- ctx.logger.info("Related memories retrieved", {+ logger.info("Related memories retrieved", {memoryId: data.memoryId,found: result.length,});diff --git a/src/functions/remember.ts b/src/functions/remember.tsindex 29290fb4..1300e779 100644--- a/src/functions/remember.ts+++ b/src/functions/remember.ts@@ -1,9 +1,10 @@-import { TriggerAction, getContext, type ISdk } from "iii-sdk";+import { TriggerAction, type ISdk } from "iii-sdk";import type { Memory } from "../types.js";import { KV, generateId, jaccardSimilarity } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { withKeyedLock } from "../state/keyed-mutex.js";import { deleteAccessLog } from "./access-tracker.js";+import { logger } from "../logger.js";export function registerRememberFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::remember",@@ -15,7 +16,6 @@ export function registerRememberFunction(sdk: ISdk, kv: StateKV): void {ttlDays?: number;sourceObservationIds?: string[];}) => {- const ctx = getContext();if (!data.content ||typeof data.content !== "string" ||@@ -106,7 +106,7 @@ export function registerRememberFunction(sdk: ISdk, kv: StateKV): void {});}- ctx.logger.info("Memory saved", {+ logger.info("Memory saved", {memId: memory.id,type: memory.type,});@@ -121,7 +121,6 @@ export function registerRememberFunction(sdk: ISdk, kv: StateKV): void {observationIds?: string[];memoryId?: string;}) => {- const ctx = getContext();let deleted = 0;if (data.memoryId) {@@ -158,7 +157,7 @@ export function registerRememberFunction(sdk: ISdk, kv: StateKV): void {deleted += 2;}- ctx.logger.info("Memory forgotten", { deleted });+ logger.info("Memory forgotten", { deleted });return { success: true, deleted };},);diff --git a/src/functions/retention.ts b/src/functions/retention.tsindex 5deb04b0..765b48be 100644--- a/src/functions/retention.ts+++ b/src/functions/retention.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {Memory,SemanticMemory,@@ -15,6 +14,7 @@ import {normalizeAccessLog,} from "./access-tracker.js";import { recordAudit } from "./audit.js";+import { logger } from "../logger.js";const DEFAULT_DECAY: DecayConfig = {lambda: 0.01,@@ -125,7 +125,6 @@ export function registerRetentionFunctions(): void {sdk.registerFunction("mem::retention-score",async (data: { config?: Partial<DecayConfig> }) => {- const ctx = getContext();const resolved = resolveDecayConfig(data?.config);if ("error" in resolved) {return { success: false, error: resolved.error };@@ -264,7 +263,7 @@ export function registerRetentionFunctions().length,};- ctx.logger.info("Retention scores computed", {+ logger.info("Retention scores computed", {total: scores.length,...tiers,});@@ -295,7 +294,6 @@ export function registerRetentionFunctions(dryRun?: boolean;maxEvict?: number;}) => {- const ctx = getContext();const threshold =typeof data?.threshold === "number" && Number.isFinite(data.threshold)? data.threshold@@ -384,7 +382,7 @@ export function registerRetentionFunctions(});}- ctx.logger.info("Retention-based eviction complete", {+ logger.info("Retention-based eviction complete", {evicted,evictedEpisodic,evictedSemantic,diff --git a/src/functions/search.ts b/src/functions/search.tsindex 298f829f..8d296e99 100644--- a/src/functions/search.ts+++ b/src/functions/search.ts@@ -1,10 +1,10 @@import type { ISdk } from 'iii-sdk'-import { getContext } from 'iii-sdk'import type { CompressedObservation, SearchResult, Session } from '../types.js'import { KV } from '../state/schema.js'import { StateKV } from '../state/kv.js'import { SearchIndex } from '../state/search-index.js'import { recordAccessBatch } from './access-tracker.js'+import { logger } from "../logger.js";let index: SearchIndex | null = null@@ -38,8 +38,7 @@ export async function rebuildIndex(kv: StateKV): Promise<number> {obsPerSession.push(...results)}if (failedSessions.length > 0) {- const ctx = getContext()- ctx.logger.warn('rebuildIndex: failed to load observations for sessions', { failedSessions })+ logger.warn('rebuildIndex: failed to load observations for sessions', { failedSessions })}for (const observations of obsPerSession) {for (const obs of observations) {@@ -54,9 +53,8 @@ export async function rebuildIndex(kv: StateKV): Promise<number> {export function registerSearchFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction(- { id: 'mem::search', description: 'Search observations by keyword' },+ 'mem::search',async (data: { query: string; limit?: number; project?: string; cwd?: string }) => {- const ctx = getContext()const idx = getSearchIndex()// Input validation / normalization.@@ -77,7 +75,7 @@ export function registerSearchFunction(sdk: ISdk, kv: StateKV): void {if (idx.size === 0) {const count = await rebuildIndex(kv)- ctx.logger.info('Search index rebuilt', { entries: count })+ logger.info('Search index rebuilt', { entries: count })}// When filtering by project/cwd, over-fetch from the index so the@@ -132,7 +130,7 @@ export function registerSearchFunction(sdk: ISdk, kv: StateKV): void {)// Avoid logging raw cwd/project (host paths). Log only that filters were active.- ctx.logger.info('Search completed', {+ logger.info('Search completed', {query,results: enriched.length,hasProjectFilter: !!projectFilter,diff --git a/src/functions/skill-extract.ts b/src/functions/skill-extract.tsindex c15d640d..d3bbbd37 100644--- a/src/functions/skill-extract.ts+++ b/src/functions/skill-extract.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {CompressedObservation,SessionSummary,@@ -10,6 +9,7 @@ import type {import { KV, generateId, fingerprintId } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";+import { logger } from "../logger.js";const SKILL_EXTRACT_SYSTEM = `You are a skill extraction engine. Given a completed multi-step task session, extract a reusable procedural skill document.@@ -107,7 +107,6 @@ export function registerSkillExtractFunctions(): void {sdk.registerFunction("mem::skill-extract",async (data: { sessionId: string }) => {- const ctx = getContext();if (!data?.sessionId) {return { success: false, error: "sessionId is required" };}@@ -148,7 +147,7 @@ export function registerSkillExtractFunctions(const parsed = parseSkillXml(response);if (!parsed) {- ctx.logger.info("No skill extracted — session was exploratory", {+ logger.info("No skill extracted — session was exploratory", {sessionId: data.sessionId,});return { success: true, extracted: false, reason: "no clear procedure found" };@@ -184,7 +183,7 @@ export function registerSkillExtractFunctions(});} catch {}- ctx.logger.info("Skill reinforced", {+ logger.info("Skill reinforced", {id: existing.id,name: parsed.title,});@@ -226,7 +225,7 @@ export function registerSkillExtractFunctions(});} catch {}- ctx.logger.info("Skill extracted", {+ logger.info("Skill extracted", {id: skill.id,title: parsed.title,steps: parsed.steps.length,@@ -235,7 +234,7 @@ export function registerSkillExtractFunctions(return { success: true, extracted: true, reinforced: false, skill };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Skill extraction failed", { error: msg });+ logger.error("Skill extraction failed", { error: msg });return { success: false, error: msg };}},diff --git a/src/functions/sliding-window.ts b/src/functions/sliding-window.tsindex 3a0d407e..1de03dfc 100644--- a/src/functions/sliding-window.ts+++ b/src/functions/sliding-window.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {CompressedObservation,EnrichedChunk,@@ -8,6 +7,7 @@ import type {import { KV, generateId } from "../state/schema.js";import type { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";+import { logger } from "../logger.js";const SLIDING_WINDOW_SYSTEM = `You are a contextual enrichment engine. Given a primary observation and its surrounding context window (previous and next observations from the same session), produce an enriched version.@@ -125,7 +125,6 @@ export function registerSlidingWindowFunction(lookback?: number;lookahead?: number;}) => {- const ctx = getContext();if (!data ||typeof data.sessionId !== "string" ||@@ -174,7 +173,7 @@ export function registerSlidingWindowFunction(const parsed = parseEnrichedXml(response);if (!parsed) {- ctx.logger.warn("Failed to parse enrichment XML", {+ logger.warn("Failed to parse enrichment XML", {obsId: data.observationId,});return { success: false, error: "parse_failed" };@@ -204,7 +203,7 @@ export function registerSlidingWindowFunction(observationId,});- ctx.logger.info("Observation enriched via sliding window", {+ logger.info("Observation enriched via sliding window", {obsId: observationId,entitiesResolved: Object.keys(parsed.resolvedEntities).length,preferencesFound: parsed.preferences.length,@@ -214,7 +213,7 @@ export function registerSlidingWindowFunction(return { success: true, enriched };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Sliding window enrichment failed", { error: msg });+ logger.error("Sliding window enrichment failed", { error: msg });return { success: false, error: msg };}},@@ -227,7 +226,6 @@ export function registerSlidingWindowFunction(lookahead?: number;minImportance?: number;}) => {- const ctx = getContext();if (!data || typeof data.sessionId !== "string" || !data.sessionId.trim()) {return { success: false, error: "sessionId is required" };}@@ -256,7 +254,7 @@ export function registerSlidingWindowFunction(}}- ctx.logger.info("Session enrichment complete", {+ logger.info("Session enrichment complete", {sessionId,total: toEnrich.length,enriched,diff --git a/src/functions/smart-search.ts b/src/functions/smart-search.tsindex 3e821bb8..fdeed273 100644--- a/src/functions/smart-search.ts+++ b/src/functions/smart-search.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {CompactSearchResult,CompressedObservation,@@ -8,6 +7,7 @@ import type {import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAccessBatch } from "./access-tracker.js";+import { logger } from "../logger.js";export function registerSmartSearchFunction(sdk: ISdk,@@ -20,7 +20,6 @@ export function registerSmartSearchFunction(expandIds?: Array<string | { obsId: string; sessionId: string }>;limit?: number;}) => {- const ctx = getContext();if (data.expandIds && data.expandIds.length > 0) {const raw = data.expandIds.slice(0, 20);@@ -55,7 +54,7 @@ export function registerSmartSearchFunction();const truncated = data.expandIds.length > raw.length;- ctx.logger.info("Smart search expanded", {+ logger.info("Smart search expanded", {requested: data.expandIds.length,attempted: raw.length,returned: expanded.length,@@ -85,7 +84,7 @@ export function registerSmartSearchFunction(compact.map((r) => r.obsId),);- ctx.logger.info("Smart search compact", {+ logger.info("Smart search compact", {query: data.query,results: compact.length,});diff --git a/src/functions/snapshot.ts b/src/functions/snapshot.tsindex 11731728..40430ce5 100644--- a/src/functions/snapshot.ts+++ b/src/functions/snapshot.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import { execFile } from "node:child_process";import { promisify } from "node:util";import { existsSync, mkdirSync, writeFileSync, readFileSync } from "node:fs";@@ -15,6 +14,7 @@ import { KV, generateId } from "../state/schema.js";import type { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";import { VERSION } from "../version.js";+import { logger } from "../logger.js";const COMMIT_HASH_RE = /^[0-9a-f]{7,40}$/i;@@ -43,7 +43,6 @@ export function registerSnapshotFunction(): void {sdk.registerFunction("mem::snapshot-create",async (data?: { message?: string }) => {- const ctx = getContext();try {await ensureGitRepo(snapshotDir);@@ -119,11 +118,11 @@ export function registerSnapshotFunction(stats: meta.stats,});- ctx.logger.info("Snapshot created", { commitHash });+ logger.info("Snapshot created", { commitHash });return { success: true, snapshot: meta };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Snapshot failed", { error: msg });+ logger.error("Snapshot failed", { error: msg });return { success: false, error: msg };}},@@ -156,7 +155,6 @@ export function registerSnapshotFunction(sdk.registerFunction("mem::snapshot-restore",async (data: { commitHash: string } | undefined) => {- const ctx = getContext();if (!data || typeof data.commitHash !== "string" || !data.commitHash.trim()) {return { success: false, error: "commitHash is required" };}@@ -220,13 +218,13 @@ export function registerSnapshotFunction(graphNodes: state.graphNodes?.length || 0,});- ctx.logger.info("Snapshot restored", {+ logger.info("Snapshot restored", {commitHash: data.commitHash,});return { success: true, commitHash: data.commitHash };} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Snapshot restore failed", { error: msg });+ logger.error("Snapshot restore failed", { error: msg });return { success: false, error: msg };}},diff --git a/src/functions/summarize.ts b/src/functions/summarize.tsindex 784ca651..7202e12b 100644--- a/src/functions/summarize.ts+++ b/src/functions/summarize.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {CompressedObservation,SessionSummary,@@ -15,6 +14,7 @@ import { validateOutput } from "../eval/validator.js";import { scoreSummary } from "../eval/quality.js";import type { MetricsStore } from "../eval/metrics-store.js";import { safeAudit } from "./audit.js";+import { logger } from "../logger.js";function parseSummaryXml(xml: string,@@ -46,7 +46,6 @@ export function registerSummarizeFunction(): void {sdk.registerFunction("mem::summarize",async (data: { sessionId: string } | undefined) => {- const ctx = getContext();const startMs = Date.now();if (!data || typeof data.sessionId !== "string" || !data.sessionId.trim()) {return { success: false, error: "sessionId is required" };@@ -55,7 +54,7 @@ export function registerSummarizeFunction(const session = await kv.get<Session>(KV.sessions, sessionId);if (!session) {- ctx.logger.warn("Session not found for summarize", {+ logger.warn("Session not found for summarize", {sessionId,});return { success: false, error: "session_not_found" };@@ -67,7 +66,7 @@ export function registerSummarizeFunction(const compressed = observations.filter((o) => o.title);if (compressed.length === 0) {- ctx.logger.info("No observations to summarize", {+ logger.info("No observations to summarize", {sessionId,});return { success: false, error: "no_observations" };@@ -88,7 +87,7 @@ export function registerSummarizeFunction(if (metricsStore) {await metricsStore.record("mem::summarize", latencyMs, false);}- ctx.logger.warn("Failed to parse summary XML", {+ logger.warn("Failed to parse summary XML", {sessionId,});return { success: false, error: "parse_failed" };@@ -112,7 +111,7 @@ export function registerSummarizeFunction(if (metricsStore) {await metricsStore.record("mem::summarize", latencyMs, false);}- ctx.logger.warn("Summary validation failed", {+ logger.warn("Summary validation failed", {sessionId,errors: validation.result.errors,});@@ -137,7 +136,7 @@ export function registerSummarizeFunction();}- ctx.logger.info("Session summarized", {+ logger.info("Session summarized", {sessionId,title: summary.title,decisions: summary.keyDecisions.length,@@ -152,7 +151,7 @@ export function registerSummarizeFunction(if (metricsStore) {await metricsStore.record("mem::summarize", latencyMs, false);}- ctx.logger.error("Summarize failed", {+ logger.error("Summarize failed", {sessionId,error: msg,});diff --git a/src/functions/team.ts b/src/functions/team.tsindex d4ffd237..a6461fe6 100644--- a/src/functions/team.ts+++ b/src/functions/team.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {TeamConfig,TeamSharedItem,@@ -9,6 +8,7 @@ import type {import { KV, generateId } from "../state/schema.js";import type { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";+import { logger } from "../logger.js";const VALID_ITEM_TYPES = new Set(["memory", "pattern", "observation"]);@@ -24,7 +24,6 @@ export function registerTeamFunction(sessionId?: string;project?: string;}) => {- const ctx = getContext();if (!data) {return { success: false, error: "payload required" };}@@ -69,7 +68,7 @@ export function registerTeamFunction(itemType: data.itemType,});- ctx.logger.info("Team share", {+ logger.info("Team share", {teamId: config.teamId,itemId: data.itemId,});diff --git a/src/functions/temporal-graph.ts b/src/functions/temporal-graph.tsindex ff298afb..1e8d1df1 100644--- a/src/functions/temporal-graph.ts+++ b/src/functions/temporal-graph.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {GraphNode,GraphEdge,@@ -10,6 +9,7 @@ import type {} from "../types.js";import { KV, generateId } from "../state/schema.js";import type { StateKV } from "../state/kv.js";+import { logger } from "../logger.js";const TEMPORAL_EXTRACTION_SYSTEM = `You are a temporal knowledge extraction engine. Given observations, extract entities AND their temporal relationships with full context metadata.@@ -166,7 +166,6 @@ export function registerTemporalGraphFunctions(timestamp: string;}>;}) => {- const ctx = getContext();if (!data.observations || data.observations.length === 0) {return { success: false, error: "No observations provided" };}@@ -258,7 +257,7 @@ export function registerTemporalGraphFunctions(existingEdges.push(edge);}- ctx.logger.info("Temporal graph extraction complete", {+ logger.info("Temporal graph extraction complete", {nodes: nodes.length,edges: edges.length,});@@ -269,7 +268,7 @@ export function registerTemporalGraphFunctions(};} catch (err) {const msg = err instanceof Error ? err.message : String(err);- ctx.logger.error("Temporal graph extraction failed", { error: msg });+ logger.error("Temporal graph extraction failed", { error: msg });return { success: false, error: msg };}},diff --git a/src/functions/timeline.ts b/src/functions/timeline.tsindex af707abd..e2244fe1 100644--- a/src/functions/timeline.ts+++ b/src/functions/timeline.ts@@ -1,5 +1,4 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type {CompressedObservation,Session,@@ -8,6 +7,7 @@ import type {import { KV } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAccessBatch } from "./access-tracker.js";+import { logger } from "../logger.js";export function registerTimelineFunction(sdk: ISdk, kv: StateKV): void {sdk.registerFunction("mem::timeline",@@ -17,7 +17,6 @@ export function registerTimelineFunction(sdk: ISdk, kv: StateKV): void {before?: number;after?: number;}) => {- const ctx = getContext();const before = Math.max(0, Math.floor(data.before ?? 5));const after = Math.max(0, Math.floor(data.after ?? 5));@@ -97,7 +96,7 @@ export function registerTimelineFunction(sdk: ISdk, kv: StateKV): void {entries.map((e) => e.observation.id),);- ctx.logger.info("Timeline retrieved", {+ logger.info("Timeline retrieved", {anchor: data.anchor,entries: entries.length,});diff --git a/src/functions/working-memory.ts b/src/functions/working-memory.tsindex 19668e0b..127195e5 100644--- a/src/functions/working-memory.ts+++ b/src/functions/working-memory.ts@@ -1,10 +1,10 @@import type { ISdk } from "iii-sdk";-import { getContext } from "iii-sdk";import type { Memory, CompressedObservation, ContextBlock } from "../types.js";import { KV, generateId } from "../state/schema.js";import { StateKV } from "../state/kv.js";import { recordAudit } from "./audit.js";import { recordAccessBatch } from "./access-tracker.js";+import { logger } from "../logger.js";const CORE_SCOPE = "mem:core-memory";@@ -99,7 +99,6 @@ export function registerWorkingMemoryFunctions(sdk.registerFunction("mem::working-context",async (data: { budget?: number }) => {- const ctx = getContext();const budget = data.budget || tokenBudget;const now = Date.now();let usedTokens = 0;@@ -172,7 +171,7 @@ export function registerWorkingMemoryFunctions(const context = sections.join("\n\n");- ctx.logger.info("Working context built", {+ logger.info("Working context built", {coreEntries: coreLines.length,archivalEntries: archivalLines.length,pagedOut,diff --git a/src/logger.ts b/src/logger.tsnew file mode 100644index 00000000..cd87760f--- /dev/null+++ b/src/logger.ts@@ -0,0 +1,61 @@+// Thin logging shim for agentmemory.+//+// iii-sdk v0.11 dropped `getContext()`, which had been the source of a+// contextual logger in every function handler (`getContext().logger`).+// Migrating directly to the v0.11 OTEL-based `getLogger()` would force+// every call site to care about the OTEL Logger API shape (`emit(...)`+// with severity numbers and attributes maps). Instead, this module+// exposes a single `logger` singleton with the same `.info/.warn/.error`+// signature the old code used, so the mechanical replacement across+// 30+ function files is: drop the `getContext` import, drop the+// `const ctx = getContext();` line, and rename `ctx.logger.*` to+// `logger.*`. Nothing else changes.+//+// Output goes to stderr as `[agentmemory] <level> <msg> <json-fields>`.+// The iii-engine's `iii-exec` worker runs the agentmemory binary as a+// child process and forwards stderr into `docker logs+// agentmemory-iii-engine-1`, so these lines end up next to the engine's+// own output without needing any OTEL wiring. If we later want+// structured OTEL logs, this file is the only thing that changes.+//+// See rohitg00/agentmemory#143 follow-up — the #116 migration updated+// test mocks but left the real `getContext()` imports in place, which+// passed `npm test` (tests mock iii-sdk) and `npm run build` (tsdown+// doesn't type-check) but crashed `node dist/index.mjs` on first+// import.++type Fields = Record<string, unknown> | undefined;++function fmt(level: string, msg: string, fields: Fields): string {+ if (!fields || Object.keys(fields).length === 0) {+ return `[agentmemory] ${level} ${msg}`;+ }+ try {+ return `[agentmemory] ${level} ${msg} ${JSON.stringify(fields)}`;+ } catch {+ // Fields contained a circular reference or a BigInt — fall back+ // to the plain message so a log line never throws.+ return `[agentmemory] ${level} ${msg}`;+ }+}++function emit(level: string, msg: string, fields: Fields): void {+ try {+ process.stderr.write(fmt(level, msg, fields) + "\n");+ } catch {+ // stderr is unavailable in some weird test/worker contexts — swallow+ // so no log line can ever crash a handler.+ }+}++export const logger = {+ info(msg: string, fields?: Fields): void {+ emit("info", msg, fields);+ },+ warn(msg: string, fields?: Fields): void {+ emit("warn", msg, fields);+ },+ error(msg: string, fields?: Fields): void {+ emit("error", msg, fields);+ },+};diff --git a/src/version.ts b/src/version.tsindex 510d9aa1..03f93d20 100644--- a/src/version.ts+++ b/src/version.ts@@ -1 +1 @@-export const VERSION: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" | "0.8.9" | "0.8.10" = "0.8.10";+export const VERSION: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0" | "0.7.2" | "0.7.3" | "0.7.4" | "0.7.5" | "0.7.6" | "0.8.1" | "0.8.2" | "0.8.3" | "0.8.4" | "0.8.5" | "0.8.6" | "0.8.7" | "0.8.8" | "0.8.9" | "0.8.10" | "0.8.11" = "0.8.11";diff --git a/test/access-tracker.test.ts b/test/access-tracker.test.tsindex 00fd6caa..35fca781 100644--- a/test/access-tracker.test.ts+++ b/test/access-tracker.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: () => {}, warn: () => {}, error: () => {} },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));function mockKV() {diff --git a/test/actions.test.ts b/test/actions.test.tsindex a4ee1a84..156ba795 100644--- a/test/actions.test.ts+++ b/test/actions.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerActionsFunction } from "../src/functions/actions.js";diff --git a/test/audit.test.ts b/test/audit.test.tsindex 12c1970c..12cb6610 100644--- a/test/audit.test.ts+++ b/test/audit.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { recordAudit, queryAudit } from "../src/functions/audit.js";diff --git a/test/auto-compress.test.ts b/test/auto-compress.test.tsindex f75f8c0e..fdcced8f 100644--- a/test/auto-compress.test.ts+++ b/test/auto-compress.test.ts@@ -1,15 +1,9 @@import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";import type { RawObservation } from "../src/types.js";-vi.mock("iii-sdk", async (importOriginal) => {- const actual = await importOriginal<typeof import("iii-sdk")>();- return {- ...actual,- getContext: () => ({- logger: { info: () => {}, warn: () => {}, error: () => {} },- }),- };-});+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },+}));function mockKV() {const store = new Map<string, Map<string, unknown>>();diff --git a/test/auto-forget.test.ts b/test/auto-forget.test.tsindex cda28354..367e6c59 100644--- a/test/auto-forget.test.ts+++ b/test/auto-forget.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerAutoForgetFunction } from "../src/functions/auto-forget.js";diff --git a/test/cascade.test.ts b/test/cascade.test.tsindex 38ec7090..8462abc7 100644--- a/test/cascade.test.ts+++ b/test/cascade.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerCascadeFunction } from "../src/functions/cascade.js";diff --git a/test/checkpoints.test.ts b/test/checkpoints.test.tsindex 8aab6ae4..4c6af904 100644--- a/test/checkpoints.test.ts+++ b/test/checkpoints.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerCheckpointsFunction } from "../src/functions/checkpoints.js";diff --git a/test/claude-bridge.test.ts b/test/claude-bridge.test.tsindex 4ce31cae..42f2b027 100644--- a/test/claude-bridge.test.ts+++ b/test/claude-bridge.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));vi.mock("node:fs", () => ({diff --git a/test/confidence.test.ts b/test/confidence.test.tsindex 1b4fa34e..74f0a6f3 100644--- a/test/confidence.test.ts+++ b/test/confidence.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerRelationsFunction } from "../src/functions/relations.js";diff --git a/test/consistency.test.ts b/test/consistency.test.tsindex c2a84524..172ca228 100644--- a/test/consistency.test.ts+++ b/test/consistency.test.ts@@ -2,10 +2,8 @@ import { describe, it, expect, vi } from "vitest";import { readFileSync } from "node:fs";import { join } from "node:path";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { getAllTools } from "../src/mcp/tools-registry.js";diff --git a/test/consolidation-pipeline.test.ts b/test/consolidation-pipeline.test.tsindex c05d5508..5f72090c 100644--- a/test/consolidation-pipeline.test.ts+++ b/test/consolidation-pipeline.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));vi.mock("../src/config.js", () => ({diff --git a/test/crystallize.test.ts b/test/crystallize.test.tsindex bb13272b..cbb29f59 100644--- a/test/crystallize.test.ts+++ b/test/crystallize.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerCrystallizeFunction } from "../src/functions/crystallize.js";diff --git a/test/diagnostics.test.ts b/test/diagnostics.test.tsindex bd1cbb9e..d2dc706e 100644--- a/test/diagnostics.test.ts+++ b/test/diagnostics.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerDiagnosticsFunction } from "../src/functions/diagnostics.js";diff --git a/test/enrich.test.ts b/test/enrich.test.tsindex 0ddb9afe..adfb31f8 100644--- a/test/enrich.test.ts+++ b/test/enrich.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerEnrichFunction } from "../src/functions/enrich.js";diff --git a/test/export-import.test.ts b/test/export-import.test.tsindex c478babd..7e2d8edb 100644--- a/test/export-import.test.ts+++ b/test/export-import.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerExportImportFunction } from "../src/functions/export-import.js";@@ -121,7 +119,7 @@ describe("Export/Import Functions", () => {it("export produces valid ExportData structure", async () => {const result = (await sdk.trigger("mem::export", {})) as ExportData;- expect(result.version).toBe("0.8.10");+ expect(result.version).toBe("0.8.11");expect(result.exportedAt).toBeDefined();expect(result.sessions.length).toBe(1);expect(result.sessions[0].id).toBe("ses_1");diff --git a/test/facets.test.ts b/test/facets.test.tsindex 9a29935c..f37d756e 100644--- a/test/facets.test.ts+++ b/test/facets.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerFacetsFunction } from "../src/functions/facets.js";diff --git a/test/frontier.test.ts b/test/frontier.test.tsindex 131c1e3a..2be7f5ce 100644--- a/test/frontier.test.ts+++ b/test/frontier.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerFrontierFunction } from "../src/functions/frontier.js";diff --git a/test/governance.test.ts b/test/governance.test.tsindex 5621fff5..22554164 100644--- a/test/governance.test.ts+++ b/test/governance.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerGovernanceFunction } from "../src/functions/governance.js";diff --git a/test/graph.test.ts b/test/graph.test.tsindex 9904f6ae..b4ebae17 100644--- a/test/graph.test.ts+++ b/test/graph.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerGraphFunction } from "../src/functions/graph.js";diff --git a/test/leases.test.ts b/test/leases.test.tsindex 8bceccb0..95f74b5b 100644--- a/test/leases.test.ts+++ b/test/leases.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerLeasesFunction } from "../src/functions/leases.js";diff --git a/test/lessons.test.ts b/test/lessons.test.tsindex 134bcce0..4a55003e 100644--- a/test/lessons.test.ts+++ b/test/lessons.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerLessonsFunctions } from "../src/functions/lessons.js";diff --git a/test/mcp-prompts.test.ts b/test/mcp-prompts.test.tsindex 53a5d468..67ebe71c 100644--- a/test/mcp-prompts.test.ts+++ b/test/mcp-prompts.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerMcpEndpoints } from "../src/mcp/server.js";diff --git a/test/mcp-resources.test.ts b/test/mcp-resources.test.tsindex fdda5c6a..87922e35 100644--- a/test/mcp-resources.test.ts+++ b/test/mcp-resources.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerMcpEndpoints } from "../src/mcp/server.js";diff --git a/test/mcp-standalone.test.ts b/test/mcp-standalone.test.tsindex f534fca4..81d7a7ff 100644--- a/test/mcp-standalone.test.ts+++ b/test/mcp-standalone.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));vi.mock("node:fs", () => ({diff --git a/test/mesh.test.ts b/test/mesh.test.tsindex a7d7b537..e08db078 100644--- a/test/mesh.test.ts+++ b/test/mesh.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerMeshFunction } from "../src/functions/mesh.js";diff --git a/test/obsidian-export.test.ts b/test/obsidian-export.test.tsindex f0199ab1..a02cc8a4 100644--- a/test/obsidian-export.test.ts+++ b/test/obsidian-export.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));const writtenFiles = new Map<string, string>();diff --git a/test/profile.test.ts b/test/profile.test.tsindex a1f7b4d9..fbc7b017 100644--- a/test/profile.test.ts+++ b/test/profile.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerProfileFunction } from "../src/functions/profile.js";diff --git a/test/query-expansion.test.ts b/test/query-expansion.test.tsindex 855012d8..73a5fb17 100644--- a/test/query-expansion.test.ts+++ b/test/query-expansion.test.ts@@ -1,14 +1,8 @@import { describe, it, expect, vi } from "vitest";import type { MemoryProvider } from "../src/types.js";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: {- info: () => {},- warn: () => {},- error: () => {},- },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));function mockSdk() {diff --git a/test/reflect.test.ts b/test/reflect.test.tsindex 143324ce..7ea163d5 100644--- a/test/reflect.test.ts+++ b/test/reflect.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerReflectFunctions } from "../src/functions/reflect.js";diff --git a/test/relations.test.ts b/test/relations.test.tsindex 22fa71d5..bf6025e7 100644--- a/test/relations.test.ts+++ b/test/relations.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerRelationsFunction } from "../src/functions/relations.js";diff --git a/test/retention-access.test.ts b/test/retention-access.test.tsindex fddda4b2..f6e28f71 100644--- a/test/retention-access.test.ts+++ b/test/retention-access.test.ts@@ -1,10 +1,8 @@import { describe, it, expect, vi } from "vitest";import type { Memory, SemanticMemory } from "../src/types.js";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: () => {}, warn: () => {}, error: () => {} },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));function mockKV(diff --git a/test/retention.test.ts b/test/retention.test.tsindex 6a44ae63..8acfda6b 100644--- a/test/retention.test.ts+++ b/test/retention.test.ts@@ -1,14 +1,8 @@import { describe, it, expect, vi } from "vitest";import type { Memory, SemanticMemory } from "../src/types.js";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: {- info: () => {},- warn: () => {},- error: () => {},- },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));function mockKV(diff --git a/test/routines.test.ts b/test/routines.test.tsindex 5f6b119f..f5a66a71 100644--- a/test/routines.test.ts+++ b/test/routines.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerRoutinesFunction } from "../src/functions/routines.js";diff --git a/test/sentinels.test.ts b/test/sentinels.test.tsindex 1be91c94..39c19a77 100644--- a/test/sentinels.test.ts+++ b/test/sentinels.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerSentinelsFunction } from "../src/functions/sentinels.js";diff --git a/test/signals.test.ts b/test/signals.test.tsindex 145e9339..3554a7f2 100644--- a/test/signals.test.ts+++ b/test/signals.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerSignalsFunction } from "../src/functions/signals.js";diff --git a/test/sketches.test.ts b/test/sketches.test.tsindex ba00ed2c..ce72b628 100644--- a/test/sketches.test.ts+++ b/test/sketches.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerSketchesFunction } from "../src/functions/sketches.js";diff --git a/test/skill-extract.test.ts b/test/skill-extract.test.tsindex cc18f87b..b28fce63 100644--- a/test/skill-extract.test.ts+++ b/test/skill-extract.test.ts@@ -17,10 +17,8 @@ const mockProvider = {summarize: vi.fn(),};-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));vi.mock("../src/functions/audit.js", () => ({diff --git a/test/sliding-window.test.ts b/test/sliding-window.test.tsindex 52849931..9f3a75ed 100644--- a/test/sliding-window.test.ts+++ b/test/sliding-window.test.ts@@ -76,14 +76,8 @@ function mockProvider(response: string): MemoryProvider {};}-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: {- info: () => {},- warn: () => {},- error: () => {},- },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));describe("SlidingWindow", () => {diff --git a/test/smart-search.test.ts b/test/smart-search.test.tsindex 6d65eae7..4f22d1a9 100644--- a/test/smart-search.test.ts+++ b/test/smart-search.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerSmartSearchFunction } from "../src/functions/smart-search.js";diff --git a/test/snapshot.test.ts b/test/snapshot.test.tsindex 33b4aab1..198774d2 100644--- a/test/snapshot.test.ts+++ b/test/snapshot.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));vi.mock("node:child_process", () => ({diff --git a/test/team.test.ts b/test/team.test.tsindex 684a2d04..b2aa1c69 100644--- a/test/team.test.ts+++ b/test/team.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerTeamFunction } from "../src/functions/team.js";diff --git a/test/temporal-graph.test.ts b/test/temporal-graph.test.tsindex aed0491d..55ef301d 100644--- a/test/temporal-graph.test.ts+++ b/test/temporal-graph.test.ts@@ -1,14 +1,8 @@import { describe, it, expect, vi } from "vitest";import type { GraphNode, GraphEdge, MemoryProvider } from "../src/types.js";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: {- info: () => {},- warn: () => {},- error: () => {},- },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));function mockKV(diff --git a/test/timeline.test.ts b/test/timeline.test.tsindex f726c12e..22273bc2 100644--- a/test/timeline.test.ts+++ b/test/timeline.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerTimelineFunction } from "../src/functions/timeline.js";diff --git a/test/verify.test.ts b/test/verify.test.tsindex 36581e50..9af433c7 100644--- a/test/verify.test.ts+++ b/test/verify.test.ts@@ -1,9 +1,7 @@import { describe, it, expect, beforeEach, vi } from "vitest";-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));import { registerVerifyFunction } from "../src/functions/verify.js";diff --git a/test/working-memory.test.ts b/test/working-memory.test.tsindex 2a90973a..446438d1 100644--- a/test/working-memory.test.ts+++ b/test/working-memory.test.ts@@ -11,10 +11,8 @@ const mockSdk = {registerFunction: vi.fn(),};-vi.mock("iii-sdk", () => ({- getContext: () => ({- logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },- }),+vi.mock("../src/logger.js", () => ({+ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },}));vi.mock("../src/functions/audit.js", () => ({