@codemem/mcp 0.44.1 → 0.44.2

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-DmdZAo6k.js","names":[],"sources":["../src/canonical-json.ts","../src/project-scope.ts","../src/content.ts","../src/schemas.ts","../src/tool-contracts.ts","../src/tools/distill.ts","../src/mcp-retrieval-ledger.ts","../src/memory-access.ts","../src/tools/items.ts","../src/tools/learn.ts","../src/tools/schema.ts","../src/tools/search.ts","../src/tools/timeline.ts","../src/server.ts"],"sourcesContent":["export function canonicalJson(value: unknown): string {\n\treturn (\n\t\tJSON.stringify(value, (_key, nestedValue) => {\n\t\t\tif (nestedValue === null || typeof nestedValue !== \"object\" || Array.isArray(nestedValue)) {\n\t\t\t\treturn nestedValue;\n\t\t\t}\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries(nestedValue as Record<string, unknown>).toSorted(([left], [right]) =>\n\t\t\t\t\tleft < right ? -1 : left > right ? 1 : 0,\n\t\t\t\t),\n\t\t\t);\n\t\t}) ?? \"undefined\"\n\t);\n}\n","import { type MemoryFilters, resolveProject } from \"@codemem/core\";\n\nfunction cleanProject(value: string | null | undefined): string | null {\n\tconst trimmed = value?.trim();\n\treturn trimmed ? trimmed : null;\n}\n\nexport function resolveDefaultProject(): string | null {\n\treturn cleanProject(process.env.CODEMEM_PROJECT) ?? resolveProject(process.cwd());\n}\n\nexport function resolveWriteProject(input: {\n\tproject?: string | null;\n\tenvProject?: string | null;\n}): string | null {\n\treturn cleanProject(input.project) ?? cleanProject(input.envProject) ?? null;\n}\n\nexport function buildFilters(\n\traw: Record<string, unknown>,\n\tdefaultProject = resolveDefaultProject(),\n): MemoryFilters | undefined {\n\tconst filters: MemoryFilters = {};\n\tlet hasAny = false;\n\n\tconst explicitProject = typeof raw.project === \"string\" ? cleanProject(raw.project) : undefined;\n\tconst resolvedProject = explicitProject || cleanProject(defaultProject) || undefined;\n\tif (resolvedProject) {\n\t\tfilters.project = resolvedProject;\n\t\thasAny = true;\n\t}\n\n\tfor (const key of [\n\t\t\"kind\",\n\t\t\"visibility\",\n\t\t\"scope_id\",\n\t\t\"include_scope_ids\",\n\t\t\"exclude_scope_ids\",\n\t\t\"include_visibility\",\n\t\t\"exclude_visibility\",\n\t\t\"include_workspace_ids\",\n\t\t\"exclude_workspace_ids\",\n\t\t\"include_workspace_kinds\",\n\t\t\"exclude_workspace_kinds\",\n\t\t\"include_actor_ids\",\n\t\t\"exclude_actor_ids\",\n\t\t\"include_trust_states\",\n\t\t\"exclude_trust_states\",\n\t\t\"ownership_scope\",\n\t\t\"personal_first\",\n\t\t\"trust_bias\",\n\t\t\"widen_shared_when_weak\",\n\t\t\"widen_shared_min_personal_results\",\n\t\t\"widen_shared_min_personal_score\",\n\t] as const) {\n\t\tconst val = raw[key];\n\t\tif (val !== undefined && val !== null) {\n\t\t\t(filters as Record<string, unknown>)[key] = val;\n\t\t\thasAny = true;\n\t\t}\n\t}\n\n\treturn hasAny ? filters : undefined;\n}\n","function parseStructuredObject(text: string): Record<string, unknown> {\n\tconst value: unknown = JSON.parse(text);\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new TypeError(\"MCP structured content must be a JSON object\");\n\t}\n\treturn value as Record<string, unknown>;\n}\n\nexport function jsonContent(data: unknown) {\n\tconst text = JSON.stringify(data);\n\tif (text === undefined) throw new TypeError(\"MCP structured content must be JSON serializable\");\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text }],\n\t\tstructuredContent: parseStructuredObject(text),\n\t};\n}\n\nexport function errorContent(message: string) {\n\treturn {\n\t\tcontent: [{ type: \"text\" as const, text: JSON.stringify({ error: message }) }],\n\t\tisError: true,\n\t};\n}\n","import { REMEMBER_MEMORY_KINDS } from \"@codemem/core\";\nimport { z } from \"zod\";\n\nconst scopeFilterSchema = {\n\tscope_id: z.string().optional().describe(\"Filter by a single sharing domain scope_id\"),\n\tinclude_scope_ids: z.array(z.string()).optional().describe(\"Sharing domain scope_ids to include\"),\n\texclude_scope_ids: z.array(z.string()).optional().describe(\"Sharing domain scope_ids to exclude\"),\n};\n\nexport const filterSchema = {\n\tkind: z.string().optional().describe(\"Filter by memory kind\"),\n\tproject: z.string().optional().describe(\"Filter by project scope (matches sessions.project)\"),\n\t...scopeFilterSchema,\n\tvisibility: z.array(z.string()).optional(),\n\tinclude_visibility: z.array(z.string()).optional(),\n\texclude_visibility: z.array(z.string()).optional(),\n\tinclude_workspace_ids: z.array(z.string()).optional(),\n\texclude_workspace_ids: z.array(z.string()).optional(),\n\tinclude_workspace_kinds: z.array(z.string()).optional(),\n\texclude_workspace_kinds: z.array(z.string()).optional(),\n\tinclude_actor_ids: z.array(z.string()).optional(),\n\texclude_actor_ids: z.array(z.string()).optional(),\n\tinclude_trust_states: z.array(z.string()).optional(),\n\texclude_trust_states: z.array(z.string()).optional(),\n\townership_scope: z.string().optional(),\n\tpersonal_first: z.union([z.boolean(), z.string()]).optional(),\n\ttrust_bias: z.string().optional(),\n\twiden_shared_when_weak: z.union([z.boolean(), z.string()]).optional(),\n\twiden_shared_min_personal_results: z.number().int().optional(),\n\twiden_shared_min_personal_score: z.number().optional(),\n};\n\nexport const memoryKindSchema = z.enum(REMEMBER_MEMORY_KINDS);\n\nexport const filterNames = Object.keys(filterSchema).toSorted();\n","import type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nconst metadataSchema = z.record(z.string(), z.unknown());\n// The column has a default but no NOT NULL constraint, and legacy rows can emit null.\nconst confidenceSchema = z.number().nullable();\n\nconst storedMemorySchema = z\n\t.object({\n\t\tid: z.number().int(),\n\t\tkind: z.string(),\n\t\ttitle: z.string(),\n\t\tbody_text: z.string(),\n\t\tsession_id: z.number().int().optional(),\n\t\tconfidence: confidenceSchema.optional(),\n\t\tcreated_at: z.string().optional(),\n\t\tupdated_at: z.string().optional(),\n\t\tmetadata_json: metadataSchema.optional(),\n\t})\n\t.passthrough();\n\nconst searchMemorySchema = z\n\t.object({\n\t\tid: z.number().int(),\n\t\tkind: z.string(),\n\t\ttitle: z.string(),\n\t\tbody: z.string(),\n\t\tconfidence: confidenceSchema.optional(),\n\t\tscore: z.number().optional(),\n\t\tsession_id: z.number().int().optional(),\n\t\tmetadata: metadataSchema.optional(),\n\t})\n\t.passthrough();\n\nconst indexMemorySchema = z\n\t.object({\n\t\tid: z.number().int(),\n\t\tkind: z.string(),\n\t\ttitle: z.string(),\n\t\tscore: z.number(),\n\t\tcreated_at: z.string(),\n\t\tsession_id: z.number().int(),\n\t\tmetadata: metadataSchema,\n\t})\n\t.passthrough();\n\nconst errorDetailSchema = z\n\t.object({\n\t\tcode: z.string(),\n\t\tfield: z.string(),\n\t\tmessage: z.string(),\n\t\tids: z.array(z.union([z.string(), z.number()])).optional(),\n\t})\n\t.passthrough();\n\nconst explainItemSchema = z\n\t.object({\n\t\tid: z.number().int(),\n\t\tkind: z.string(),\n\t\ttitle: z.string(),\n\t\tcreated_at: z.string(),\n\t\tproject: z.string().nullable(),\n\t\tretrieval: z.object({ source: z.string(), rank: z.number().int().nullable() }).passthrough(),\n\t\tscore: z\n\t\t\t.object({\n\t\t\t\ttotal: z.number().nullable(),\n\t\t\t\tcomponents: z\n\t\t\t\t\t.object({\n\t\t\t\t\t\tbase: z.number().nullable(),\n\t\t\t\t\t\trecency: z.number(),\n\t\t\t\t\t\tkind_bonus: z.number(),\n\t\t\t\t\t\tpersonal_bias: z.number(),\n\t\t\t\t\t\tsemantic_boost: z.number().nullable(),\n\t\t\t\t\t})\n\t\t\t\t\t.passthrough(),\n\t\t\t})\n\t\t\t.passthrough(),\n\t\trole: z.object({ inferred: z.string(), reason: z.string() }).passthrough(),\n\t\tmatches: z\n\t\t\t.object({ query_terms: z.array(z.string()), project_match: z.boolean().nullable() })\n\t\t\t.passthrough(),\n\t\tpack_context: z\n\t\t\t.object({ included: z.boolean().nullable(), section: z.string().nullable() })\n\t\t\t.passthrough()\n\t\t\t.nullable(),\n\t})\n\t.passthrough();\n\nconst packItemSchema = z\n\t.object({\n\t\tid: z.number().int(),\n\t\tkind: z.string(),\n\t\ttitle: z.string(),\n\t\tbody: z.string(),\n\t\tconfidence: confidenceSchema,\n\t\tmetadata: metadataSchema,\n\t})\n\t.passthrough();\n\nconst stringListSectionSchema = z\n\t.object({\n\t\twhen: z.array(z.string()),\n\t\thow: z.array(z.string()),\n\t\texamples: z.array(z.string()),\n\t})\n\t.passthrough();\n\nexport const toolOutputSchemas = {\n\tmemory_search: z.object({ items: z.array(searchMemorySchema) }),\n\tmemory_search_index: z.object({ items: z.array(indexMemorySchema) }),\n\tmemory_explain: z.object({\n\t\titems: z.array(explainItemSchema),\n\t\tmissing_ids: z.array(z.number().int()),\n\t\terrors: z.array(errorDetailSchema),\n\t\tmetadata: z\n\t\t\t.object({\n\t\t\t\tquery: z.string().nullable(),\n\t\t\t\tproject: z.string().nullable(),\n\t\t\t\trequested_ids_count: z.number().int(),\n\t\t\t\treturned_items_count: z.number().int(),\n\t\t\t\tinclude_pack_context: z.boolean(),\n\t\t\t\tsanitized_query: z.string().optional(),\n\t\t\t})\n\t\t\t.passthrough(),\n\t}),\n\tmemory_recent: z.object({ items: z.array(storedMemorySchema) }),\n\tmemory_pack: z.object({\n\t\tcontext: z.string(),\n\t\titems: z.array(packItemSchema),\n\t\titem_ids: z.array(z.number().int()),\n\t\tpack_text: z.string(),\n\t\tmetrics: z\n\t\t\t.object({\n\t\t\t\ttotal_items: z.number().int(),\n\t\t\t\tpack_tokens: z.number().int(),\n\t\t\t\tfallback_used: z.boolean(),\n\t\t\t\tlimit: z.number().int(),\n\t\t\t\tproject: z.string().nullable(),\n\t\t\t\tpack_item_ids: z.array(z.number().int()),\n\t\t\t})\n\t\t\t.passthrough(),\n\t}),\n\tmemory_timeline: z.object({ items: z.array(storedMemorySchema) }),\n\tmemory_expand: z.object({\n\t\tanchors: z.array(storedMemorySchema),\n\t\ttimeline: z.array(storedMemorySchema),\n\t\tobservations: z.array(storedMemorySchema),\n\t\tmissing_ids: z.array(z.number().int()),\n\t\terrors: z.array(errorDetailSchema),\n\t\tmetadata: z\n\t\t\t.object({\n\t\t\t\tproject: z.string().nullable(),\n\t\t\t\trequested_ids_count: z.number().int(),\n\t\t\t\treturned_anchor_count: z.number().int(),\n\t\t\t\ttimeline_count: z.number().int(),\n\t\t\t\tinclude_observations: z.boolean(),\n\t\t\t})\n\t\t\t.passthrough(),\n\t}),\n\tmemory_get: storedMemorySchema,\n\tmemory_get_observations: z.object({ items: z.array(storedMemorySchema) }),\n\tmemory_remember: z.object({ id: z.number().int() }),\n\tmemory_forget: z.object({ status: z.literal(\"ok\") }),\n\tmemory_distill_candidates: z.object({\n\t\tversion: z.literal(1),\n\t\tcandidates: z.array(\n\t\t\tz\n\t\t\t\t.object({\n\t\t\t\t\tscope: z.enum([\"project\", \"user\"]),\n\t\t\t\t\tsuggested_target: z.string().nullable(),\n\t\t\t\t\tscore: z.number(),\n\t\t\t\t\trecurrence: z.number().int(),\n\t\t\t\t\tprojects: z.array(z.string()),\n\t\t\t\t\tmember_ids: z.array(z.number().int()),\n\t\t\t\t\trepresentative_id: z.number().int(),\n\t\t\t\t\tconcepts: z.array(z.string()),\n\t\t\t\t\tartifact_kind: z.enum([\"context_fact\", \"skill\"]),\n\t\t\t\t\tevidence: z.array(z.string()),\n\t\t\t\t\tdraft_text: z.string().nullable(),\n\t\t\t\t})\n\t\t\t\t.passthrough(),\n\t\t),\n\t\tmetadata: z\n\t\t\t.object({\n\t\t\t\tcandidate_count: z.number().int(),\n\t\t\t\tcluster_count: z.number().int(),\n\t\t\t\tcontext_document_count: z.number().int(),\n\t\t\t\tcorpus_count: z.number().int(),\n\t\t\t\tcorpus_limit: z.number().int(),\n\t\t\t\tdocumented_cluster_count: z.number().int(),\n\t\t\t\tinclude_documented: z.boolean(),\n\t\t\t\tmin_recurrence: z.number().int(),\n\t\t\t})\n\t\t\t.passthrough(),\n\t}),\n\tmemory_schema: z.object({\n\t\tkinds: z.array(z.string()),\n\t\tkind_descriptions: z.record(z.string(), z.string()),\n\t\tfields: z.record(z.string(), z.string()),\n\t\tfilters: z.array(z.string()),\n\t}),\n\tmemory_learn: z.object({\n\t\tintro: z.string(),\n\t\tclient_hint: z.string(),\n\t\trecall: stringListSectionSchema,\n\t\tpersistence: stringListSectionSchema,\n\t\tforget: stringListSectionSchema,\n\t\tprompt_hint: z.string(),\n\t\trecommended_system_prompt: z.string(),\n\t}),\n} as const;\n\n// Incidental diagnostics and caches do not change the primary read operation.\nconst localReadAnnotations = {\n\treadOnlyHint: true,\n\topenWorldHint: false,\n} satisfies ToolAnnotations;\n\n// Pack/distill remain read-only while model loading or observer calls may access\n// entities outside the local store.\nconst externalReadAnnotations = {\n\treadOnlyHint: true,\n\topenWorldHint: true,\n} satisfies ToolAnnotations;\n\nexport const toolAnnotations = {\n\tmemory_search: localReadAnnotations,\n\tmemory_search_index: localReadAnnotations,\n\tmemory_explain: localReadAnnotations,\n\tmemory_recent: localReadAnnotations,\n\tmemory_pack: externalReadAnnotations,\n\tmemory_timeline: localReadAnnotations,\n\tmemory_expand: localReadAnnotations,\n\tmemory_get: localReadAnnotations,\n\tmemory_get_observations: localReadAnnotations,\n\t// Remember is additive, but embedding generation can load external model assets.\n\tmemory_remember: {\n\t\treadOnlyHint: false,\n\t\tdestructiveHint: false,\n\t\tidempotentHint: false,\n\t\topenWorldHint: true,\n\t},\n\t// Repeating a soft delete has no additional environmental effect.\n\tmemory_forget: {\n\t\treadOnlyHint: false,\n\t\tdestructiveHint: true,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false,\n\t},\n\tmemory_distill_candidates: externalReadAnnotations,\n\tmemory_schema: localReadAnnotations,\n\tmemory_learn: localReadAnnotations,\n} as const satisfies Record<keyof typeof toolOutputSchemas, ToolAnnotations>;\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport {\n\tbuildDistillReport,\n\ttype DistillContextDocument,\n\tjudgeDistillReport,\n\ttype MemoryFilters,\n\tObserverClient,\n\tprojectMatchesFilter,\n\tresolveProject,\n\tresolveProjectRoot,\n} from \"@codemem/core\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { errorContent, jsonContent } from \"../content.js\";\nimport { buildFilters } from \"../project-scope.js\";\nimport { filterSchema } from \"../schemas.js\";\nimport type { ToolRegistrationContext } from \"../tool-context.js\";\nimport { toolAnnotations, toolOutputSchemas } from \"../tool-contracts.js\";\n\nconst distillInputSchema = {\n\tlimit: z.number().int().min(1).max(50).default(10).describe(\"Max candidates\"),\n\tmin_recurrence: z\n\t\t.number()\n\t\t.int()\n\t\t.min(1)\n\t\t.max(50)\n\t\t.default(2)\n\t\t.describe(\"Minimum member count per candidate\"),\n\tall_projects: z.boolean().default(false).describe(\"Mine memories across all projects\"),\n\tinclude_documented: z\n\t\t.boolean()\n\t\t.default(false)\n\t\t.describe(\"Include candidates already represented in context files\"),\n\tmax_evidence_items: z\n\t\t.number()\n\t\t.int()\n\t\t.min(1)\n\t\t.max(20)\n\t\t.default(5)\n\t\t.describe(\"Evidence snippets per candidate\"),\n\tjudge: z\n\t\t.boolean()\n\t\t.default(true)\n\t\t.describe(\n\t\t\t\"Judge candidates with the observer model and drop routine-activity clusters (on by default; falls back to unjudged output when no observer model is configured)\",\n\t\t),\n\t...filterSchema,\n};\n\nfunction readContextFile(\n\tpath: string,\n\tdisplayPath: string,\n\tscope: DistillContextDocument[\"scope\"],\n): DistillContextDocument | null {\n\tif (!existsSync(path)) return null;\n\tconst text = readFileSync(path, \"utf8\");\n\treturn text.trim() ? { path: displayPath, text, scope } : null;\n}\n\nfunction loadDefaultContextDocuments(\n\tincludeProjectContext: boolean,\n\tcwd = process.cwd(),\n): DistillContextDocument[] {\n\t// The repo-root AGENTS.md describes the current repo (scope \"project\") and is\n\t// gated to current-project runs; the user-global context (scope \"user\")\n\t// always applies and never suppresses other projects' candidates. Resolve the\n\t// repo root so running from a subdirectory still finds the project context.\n\tconst projectRoot = resolveProjectRoot(cwd) ?? cwd;\n\tconst documents = [\n\t\tincludeProjectContext\n\t\t\t? readContextFile(join(projectRoot, \"AGENTS.md\"), \"AGENTS.md\", \"project\")\n\t\t\t: null,\n\t\treadContextFile(\n\t\t\tjoin(homedir(), \".config\", \"opencode\", \"AGENTS.md\"),\n\t\t\t\"~/.config/opencode/AGENTS.md\",\n\t\t\t\"user\",\n\t\t),\n\t];\n\treturn documents.filter((document): document is DistillContextDocument => document != null);\n}\n\nfunction shouldIncludeProjectContext(\n\targs: { all_projects?: boolean; project?: unknown },\n\tdefaultProject: string | null,\n): boolean {\n\tif (args.all_projects) return false;\n\tconst currentProject = resolveProject(process.cwd());\n\tif (!currentProject) return false;\n\tconst explicitProject = typeof args.project === \"string\" ? args.project.trim() : \"\";\n\t// Match the corpus filter: the cwd AGENTS.md is only valid when the mined\n\t// project (explicit arg or the server default project) is this repo.\n\tconst targetProject = explicitProject\n\t\t? resolveProject(process.cwd(), explicitProject)\n\t\t: defaultProject;\n\tif (!targetProject) return false;\n\treturn projectMatchesFilter(targetProject, currentProject);\n}\n\nfunction buildDistillFilters(\n\targs: { all_projects?: boolean } & Record<string, unknown>,\n\tdefaultProject: string | null,\n): MemoryFilters | undefined {\n\tif (args.all_projects && typeof args.project === \"string\" && args.project.trim()) {\n\t\tthrow new Error(\"project cannot be combined with all_projects\");\n\t}\n\treturn buildFilters(args, args.all_projects ? null : defaultProject);\n}\n\nexport function registerDistillTools(server: McpServer, context: ToolRegistrationContext): void {\n\tconst { defaultProject, store } = context;\n\n\tserver.registerTool(\n\t\t\"memory_distill_candidates\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Mine recurring memories into reviewable context candidates. Reads project/user context files without modifying them and can call the optional observer when judge=true.\",\n\t\t\tinputSchema: distillInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_distill_candidates,\n\t\t\tannotations: toolAnnotations.memory_distill_candidates,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tconst resolvedDefaultProject = defaultProject();\n\t\t\t\tconst filters = buildDistillFilters(args, resolvedDefaultProject);\n\t\t\t\tconst kinds = args.kind ? [args.kind] : undefined;\n\t\t\t\t// When judging, mine extra candidates so routine drops are backfilled\n\t\t\t\t// from the next-ranked clusters instead of shrinking the caller's limit.\n\t\t\t\tconst fetchLimit = args.judge ? Math.min(args.limit * 3, args.limit + 20) : args.limit;\n\t\t\t\tlet result = await buildDistillReport(store, {\n\t\t\t\t\tcandidate: {\n\t\t\t\t\t\tincludeDocumented: args.include_documented,\n\t\t\t\t\t\tmaxEvidenceItems: args.max_evidence_items,\n\t\t\t\t\t},\n\t\t\t\t\tcontextDocuments: loadDefaultContextDocuments(\n\t\t\t\t\t\tshouldIncludeProjectContext(args, resolvedDefaultProject),\n\t\t\t\t\t),\n\t\t\t\t\tcorpus: { filters: filters ?? null, kinds },\n\t\t\t\t\tlimit: fetchLimit,\n\t\t\t\t\tminRecurrence: args.min_recurrence,\n\t\t\t\t});\n\t\t\t\tif (args.judge) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst client = new ObserverClient();\n\t\t\t\t\t\tresult = await judgeDistillReport(result, async (system, user) => {\n\t\t\t\t\t\t\tconst response = await client.observe(system, user);\n\t\t\t\t\t\t\treturn response.raw;\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t// Fall back to unjudged output rather than failing the tool —\n\t\t\t\t\t\t// the caller sees judged:false + judge_error and can decide.\n\t\t\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\t\t\tresult = {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmetadata: { ...result.metadata, judged: false, judge_error: message },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tif (result.candidates.length > args.limit) {\n\t\t\t\t\t\tresult = {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tcandidates: result.candidates.slice(0, args.limit),\n\t\t\t\t\t\t\tmetadata: { ...result.metadata, candidate_count: args.limit },\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn jsonContent(result);\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n}\n","import { createHash, randomUUID } from \"node:crypto\";\nimport {\n\ttype MemoryFilters,\n\ttype RetrievalStatus,\n\ttype RetrievalSurface,\n\treconcileFailedRetrievalSurface,\n\trecordRetrievalSurface,\n} from \"@codemem/core\";\nimport { canonicalJson } from \"./canonical-json.js\";\nimport { errorContent, jsonContent } from \"./content.js\";\nimport type { ToolRegistrationContext } from \"./tool-context.js\";\n\nexport interface McpRetrievalResult<T> {\n\tvalue: T;\n\tmemoryIds: number[];\n\tcandidateCount?: number;\n\tfilters?: MemoryFilters;\n\tretrievalStatus?: RetrievalStatus;\n\terror?: string;\n}\n\ninterface McpRetrievalInput {\n\tsurface: RetrievalSurface;\n\ttoolName: string;\n\ttoolArguments: unknown;\n\tquery?: string | null;\n\tlimit?: number | null;\n\tresolveFilters?: () => MemoryFilters | undefined;\n\trequestId?: string | number;\n\tsourceSessionId?: string | null;\n\tinvocationIdentity?: object;\n}\n\nconst MCP_SESSION_RETRY_TTL_MS = 5 * 60 * 1000;\nconst MCP_SESSION_RETRY_MAX_ENTRIES = 2000;\n\ninterface InvocationLedgerIdentity {\n\tbaseRequestId: string | null;\n\trequestId: string | null;\n\tattemptId: string;\n}\n\ninterface PendingFailure {\n\tidentity: InvocationLedgerIdentity;\n\texpiresAt: number;\n\torder: number;\n}\n\ninterface SessionIdentityTracker {\n\tbyInvocation: WeakMap<object, InvocationLedgerIdentity>;\n\tactiveByRequest: Map<string, number>;\n\tpendingFailures: Map<string, PendingFailure[]>;\n\tpendingFailureCount: number;\n\tnextPendingFailureOrder: number;\n\tnextInvocationSequence: number;\n}\n\n// Track only live invocation objects and per-base FIFO failure queues. Pending\n// identities expire after five minutes and are capped at 2,000 entries total.\n// The outer WeakMap releases the whole tracker with its server registration context.\nconst sessionIdentityTrackers = new WeakMap<ToolRegistrationContext, SessionIdentityTracker>();\nlet fallbackAttemptSequence = 0;\n\nfunction recordMcpRetrieval(\n\tcontext: ToolRegistrationContext,\n\tinput: Parameters<typeof recordRetrievalSurface>[1],\n\treconcileTransientFailure: boolean,\n): void {\n\tif (!context.captureRetrievalLedger) return;\n\ttry {\n\t\tconst outcome = recordRetrievalSurface(context.store.db, input);\n\t\tif (\n\t\t\treconcileTransientFailure &&\n\t\t\t!outcome.ok &&\n\t\t\toutcome.reason === \"idempotency_conflict\" &&\n\t\t\t((input.retrievalStatus === \"succeeded\" && input.deliveryStatus === \"handed_off\") ||\n\t\t\t\t(input.retrievalStatus === \"no_results\" && input.deliveryStatus === \"not_attempted\"))\n\t\t) {\n\t\t\treconcileFailedRetrievalSurface(context.store.db, input);\n\t\t}\n\t} catch {\n\t\t// MCP responses must remain independent from local diagnostics.\n\t}\n}\n\nfunction requestAttemptId(requestId: string | null): string {\n\tif (requestId == null) return randomUUID();\n\tconst hex = requestId.slice(0, 32).split(\"\");\n\thex[12] = \"5\";\n\thex[16] = ((Number.parseInt(hex[16] ?? \"0\", 16) & 0x3) | 0x8).toString(16);\n\tconst value = hex.join(\"\");\n\treturn `${value.slice(0, 8)}-${value.slice(8, 12)}-${value.slice(12, 16)}-${value.slice(16, 20)}-${value.slice(20)}`;\n}\n\nfunction baseRequestIdentity(\n\tcontext: ToolRegistrationContext,\n\tinput: McpRetrievalInput,\n): string | null {\n\tif (input.requestId == null) return null;\n\tconst callContentDigest = createHash(\"sha256\")\n\t\t.update(\n\t\t\tcanonicalJson({\n\t\t\t\tmethod: \"tools/call\",\n\t\t\t\tparams: { name: input.toolName, arguments: input.toolArguments },\n\t\t\t}),\n\t\t)\n\t\t.digest(\"hex\");\n\treturn createHash(\"sha256\")\n\t\t.update(\n\t\t\tJSON.stringify([\n\t\t\t\tinput.sourceSessionId ?? context.retrievalLedgerScopeId,\n\t\t\t\tinput.requestId,\n\t\t\t\tcallContentDigest,\n\t\t\t]),\n\t\t)\n\t\t.digest(\"hex\");\n}\n\nfunction sessionIdentityTracker(context: ToolRegistrationContext): SessionIdentityTracker {\n\tlet tracker = sessionIdentityTrackers.get(context);\n\tif (!tracker) {\n\t\ttracker = {\n\t\t\tbyInvocation: new WeakMap(),\n\t\t\tactiveByRequest: new Map(),\n\t\t\tpendingFailures: new Map(),\n\t\t\tpendingFailureCount: 0,\n\t\t\tnextPendingFailureOrder: 0,\n\t\t\tnextInvocationSequence: 0,\n\t\t};\n\t\tsessionIdentityTrackers.set(context, tracker);\n\t}\n\treturn tracker;\n}\n\nfunction prunePendingFailures(tracker: SessionIdentityTracker, now: number): void {\n\tfor (const [requestId, pending] of tracker.pendingFailures) {\n\t\tconst retained = pending.filter((entry) => entry.expiresAt > now);\n\t\ttracker.pendingFailureCount -= pending.length - retained.length;\n\t\tif (retained.length === 0) tracker.pendingFailures.delete(requestId);\n\t\telse if (retained.length !== pending.length) tracker.pendingFailures.set(requestId, retained);\n\t}\n\twhile (tracker.pendingFailureCount > MCP_SESSION_RETRY_MAX_ENTRIES) {\n\t\tlet oldestRequestId: string | undefined;\n\t\tlet oldestOrder = Number.POSITIVE_INFINITY;\n\t\tfor (const [requestId, pending] of tracker.pendingFailures) {\n\t\t\tconst order = pending[0]?.order;\n\t\t\tif (order != null && order < oldestOrder) {\n\t\t\t\toldestRequestId = requestId;\n\t\t\t\toldestOrder = order;\n\t\t\t}\n\t\t}\n\t\tif (oldestRequestId === undefined) break;\n\t\tconst pending = tracker.pendingFailures.get(oldestRequestId);\n\t\tconst removed = pending?.shift();\n\t\tif (!pending || !removed) {\n\t\t\ttracker.pendingFailures.delete(oldestRequestId);\n\t\t\tcontinue;\n\t\t}\n\t\ttracker.pendingFailureCount -= 1;\n\t\tif (pending.length === 0) tracker.pendingFailures.delete(oldestRequestId);\n\t}\n}\n\nfunction takePendingFailure(\n\ttracker: SessionIdentityTracker,\n\tbaseRequestId: string,\n): InvocationLedgerIdentity | undefined {\n\tconst pending = tracker.pendingFailures.get(baseRequestId);\n\tif (!pending) return undefined;\n\tconst failure = pending.shift();\n\tif (!failure) return undefined;\n\ttracker.pendingFailureCount -= 1;\n\tif (pending.length === 0) tracker.pendingFailures.delete(baseRequestId);\n\treturn failure.identity;\n}\n\nfunction removePendingFailure(\n\ttracker: SessionIdentityTracker,\n\tbaseRequestId: string,\n\tattemptId: string,\n): void {\n\tconst pending = tracker.pendingFailures.get(baseRequestId);\n\tconst index = pending?.findIndex((entry) => entry.identity.attemptId === attemptId) ?? -1;\n\tif (!pending || index < 0) return;\n\tpending.splice(index, 1);\n\ttracker.pendingFailureCount -= 1;\n\tif (pending.length === 0) tracker.pendingFailures.delete(baseRequestId);\n}\n\nfunction enqueuePendingFailure(\n\ttracker: SessionIdentityTracker,\n\tbaseRequestId: string,\n\tidentity: InvocationLedgerIdentity,\n\tnow: number,\n): void {\n\tconst pending = tracker.pendingFailures.get(baseRequestId) ?? [];\n\tif (pending.some((entry) => entry.identity.attemptId === identity.attemptId)) return;\n\tpending.push({\n\t\tidentity,\n\t\texpiresAt: now + MCP_SESSION_RETRY_TTL_MS,\n\t\torder: tracker.nextPendingFailureOrder,\n\t});\n\ttracker.nextPendingFailureOrder += 1;\n\ttracker.pendingFailures.set(baseRequestId, pending);\n\ttracker.pendingFailureCount += 1;\n\tprunePendingFailures(tracker, now);\n}\n\nfunction fallbackInvocationIdentity(): InvocationLedgerIdentity {\n\ttry {\n\t\treturn { baseRequestId: null, requestId: null, attemptId: randomUUID() };\n\t} catch {\n\t\tconst timestamp = Date.now().toString(16).slice(-8).padStart(8, \"0\");\n\t\tconst sequence = fallbackAttemptSequence.toString(16).slice(-4).padStart(4, \"0\");\n\t\tfallbackAttemptSequence = (fallbackAttemptSequence + 1) % 0x1_0000;\n\t\treturn {\n\t\t\tbaseRequestId: null,\n\t\t\trequestId: null,\n\t\t\tattemptId: `00000000-0000-4000-8000-${timestamp}${sequence}`,\n\t\t};\n\t}\n}\n\nfunction beginInvocation(\n\tcontext: ToolRegistrationContext,\n\tinput: McpRetrievalInput,\n): InvocationLedgerIdentity {\n\tconst baseRequestId = baseRequestIdentity(context, input);\n\tif (context.retrievalLedgerIdentityMode === \"stateless\" || baseRequestId == null) {\n\t\treturn {\n\t\t\tbaseRequestId,\n\t\t\trequestId: baseRequestId,\n\t\t\tattemptId: requestAttemptId(baseRequestId),\n\t\t};\n\t}\n\n\tconst tracker = sessionIdentityTracker(context);\n\tprunePendingFailures(tracker, Date.now());\n\tconst candidateInvocation = input.invocationIdentity\n\t\t? tracker.byInvocation.get(input.invocationIdentity)\n\t\t: undefined;\n\tconst knownInvocation =\n\t\tcandidateInvocation?.baseRequestId === baseRequestId ? candidateInvocation : undefined;\n\tlet identity = knownInvocation;\n\tif (!identity) {\n\t\tconst activeCount = tracker.activeByRequest.get(baseRequestId) ?? 0;\n\t\tconst pending = activeCount === 0 ? takePendingFailure(tracker, baseRequestId) : undefined;\n\t\tif (pending) {\n\t\t\tidentity = pending;\n\t\t} else {\n\t\t\tconst invocationSequence = tracker.nextInvocationSequence;\n\t\t\ttracker.nextInvocationSequence += 1;\n\t\t\tconst requestId = createHash(\"sha256\")\n\t\t\t\t.update(JSON.stringify([baseRequestId, context.retrievalLedgerScopeId, invocationSequence]))\n\t\t\t\t.digest(\"hex\");\n\t\t\tidentity = {\n\t\t\t\tbaseRequestId,\n\t\t\t\trequestId,\n\t\t\t\tattemptId: requestAttemptId(requestId),\n\t\t\t};\n\t\t}\n\t\tif (input.invocationIdentity) tracker.byInvocation.set(input.invocationIdentity, identity);\n\t}\n\ttracker.activeByRequest.set(baseRequestId, (tracker.activeByRequest.get(baseRequestId) ?? 0) + 1);\n\treturn identity;\n}\n\nfunction safeBeginInvocation(\n\tcontext: ToolRegistrationContext,\n\tinput: McpRetrievalInput,\n): InvocationLedgerIdentity {\n\ttry {\n\t\treturn beginInvocation(context, input);\n\t} catch {\n\t\treturn fallbackInvocationIdentity();\n\t}\n}\n\nfunction completeInvocation(\n\tcontext: ToolRegistrationContext,\n\tidentity: InvocationLedgerIdentity,\n\tstatus: \"completed\" | \"failed\",\n): void {\n\tif (context.retrievalLedgerIdentityMode === \"stateless\" || identity.baseRequestId == null) return;\n\tconst tracker = sessionIdentityTracker(context);\n\tconst activeCount = tracker.activeByRequest.get(identity.baseRequestId) ?? 0;\n\tif (activeCount <= 1) tracker.activeByRequest.delete(identity.baseRequestId);\n\telse tracker.activeByRequest.set(identity.baseRequestId, activeCount - 1);\n\n\tif (status === \"failed\") {\n\t\tenqueuePendingFailure(tracker, identity.baseRequestId, identity, Date.now());\n\t} else {\n\t\tremovePendingFailure(tracker, identity.baseRequestId, identity.attemptId);\n\t}\n}\n\nfunction safeCompleteInvocation(\n\tcontext: ToolRegistrationContext,\n\tidentity: InvocationLedgerIdentity,\n\tstatus: \"completed\" | \"failed\",\n): void {\n\ttry {\n\t\tcompleteInvocation(context, identity, status);\n\t} catch {\n\t\t// Retrieval diagnostics must never alter the MCP tool result.\n\t}\n}\n\nexport async function withMcpRetrieval<T>(\n\tcontext: ToolRegistrationContext,\n\tinput: McpRetrievalInput,\n\tretrieve: (\n\t\tfilters: MemoryFilters | undefined,\n\t) => McpRetrievalResult<T> | Promise<McpRetrievalResult<T>>,\n) {\n\tconst invocation = safeBeginInvocation(context, input);\n\tconst ledgerRequestId = invocation.requestId;\n\tconst attemptId = invocation.attemptId;\n\tconst startedAt = new Date();\n\tlet filters: MemoryFilters | undefined;\n\ttry {\n\t\tfilters = input.resolveFilters?.();\n\t\tconst output = await retrieve(filters);\n\t\tconst completedAt = new Date();\n\t\tconst response = output.error ? errorContent(output.error) : jsonContent(output.value);\n\t\tconst streamId = input.sourceSessionId ?? context.retrievalLedgerScopeId;\n\t\tconst hasResults = output.memoryIds.length > 0;\n\t\tconst isNotFoundCompletion = output.error === \"not_found\" && !hasResults;\n\t\tconst isFailedResult =\n\t\t\t(output.error != null && !isNotFoundCompletion) ||\n\t\t\t(output.retrievalStatus === \"failed\" && !hasResults);\n\t\tconst recordedMemoryIds = isFailedResult ? [] : output.memoryIds;\n\t\tconst deliveredRetrievalStatus = output.retrievalStatus === \"unknown\" ? \"unknown\" : \"succeeded\";\n\t\trecordMcpRetrieval(\n\t\t\tcontext,\n\t\t\t{\n\t\t\t\tattemptId,\n\t\t\t\tsurface: input.surface,\n\t\t\t\ttrigger: \"explicit\",\n\t\t\t\tstartedAt: startedAt.toISOString(),\n\t\t\t\tcompletedAt: completedAt.toISOString(),\n\t\t\t\tretrievalStatus: isFailedResult\n\t\t\t\t\t? \"failed\"\n\t\t\t\t\t: hasResults\n\t\t\t\t\t\t? deliveredRetrievalStatus\n\t\t\t\t\t\t: \"no_results\",\n\t\t\t\tdeliveryStatus: isFailedResult || !hasResults ? \"not_attempted\" : \"handed_off\",\n\t\t\t\tcandidateIds: recordedMemoryIds,\n\t\t\t\tselectedIds: recordedMemoryIds,\n\t\t\t\tcandidateCount: hasResults && !isFailedResult ? output.candidateCount : 0,\n\t\t\t\trecorderVersion: \"mcp-retrieval-v1\",\n\t\t\t\tsource: \"mcp\",\n\t\t\t\tstreamId,\n\t\t\t\tsourceSessionId: input.sourceSessionId ?? null,\n\t\t\t\trequestId: ledgerRequestId,\n\t\t\t\tlatencyMs: Math.max(0, completedAt.getTime() - startedAt.getTime()),\n\t\t\t\tfilters: output.filters ?? filters,\n\t\t\t\tquery: input.query,\n\t\t\t\tlimitRequested: input.limit,\n\t\t\t\tfailureCode: isFailedResult ? \"tool_failed\" : undefined,\n\t\t\t\tfailureStage: isFailedResult ? \"retrieval\" : undefined,\n\t\t\t},\n\t\t\t!isFailedResult,\n\t\t);\n\t\tsafeCompleteInvocation(context, invocation, isFailedResult ? \"failed\" : \"completed\");\n\t\treturn response;\n\t} catch (error) {\n\t\tconst completedAt = new Date();\n\t\tconst streamId = input.sourceSessionId ?? context.retrievalLedgerScopeId;\n\t\trecordMcpRetrieval(\n\t\t\tcontext,\n\t\t\t{\n\t\t\t\tattemptId,\n\t\t\t\tsurface: input.surface,\n\t\t\t\ttrigger: \"explicit\",\n\t\t\t\tstartedAt: startedAt.toISOString(),\n\t\t\t\tcompletedAt: completedAt.toISOString(),\n\t\t\t\tretrievalStatus: \"failed\",\n\t\t\t\tdeliveryStatus: \"not_attempted\",\n\t\t\t\tcandidateIds: [],\n\t\t\t\tselectedIds: [],\n\t\t\t\trecorderVersion: \"mcp-retrieval-v1\",\n\t\t\t\tsource: \"mcp\",\n\t\t\t\tstreamId,\n\t\t\t\tsourceSessionId: input.sourceSessionId ?? null,\n\t\t\t\trequestId: ledgerRequestId,\n\t\t\t\tlatencyMs: Math.max(0, completedAt.getTime() - startedAt.getTime()),\n\t\t\t\tquery: input.query,\n\t\t\t\tlimitRequested: input.limit,\n\t\t\t\tfilters,\n\t\t\t\tfailureCode: \"tool_failed\",\n\t\t\t\tfailureStage: \"retrieval\",\n\t\t\t},\n\t\t\tfalse,\n\t\t);\n\t\tsafeCompleteInvocation(context, invocation, \"failed\");\n\t\treturn errorContent(error instanceof Error ? error.message : String(error));\n\t}\n}\n","import {\n\ttype MemoryFilters,\n\ttype MemoryItemResponse,\n\ttype MemoryStore,\n\ttoJson,\n} from \"@codemem/core\";\nimport { resolveWriteProject } from \"./project-scope.js\";\n\nexport function getMemoryForMcp(\n\tstore: MemoryStore,\n\tmemoryId: number,\n\tfilters?: MemoryFilters,\n): MemoryItemResponse | null {\n\tconst rows = store.timeline(null, memoryId, 0, 0, filters ?? null);\n\treturn rows.find((row) => row.id === memoryId) ?? null;\n}\n\nexport function getManyForMcp(\n\tstore: MemoryStore,\n\tids: number[],\n\tfilters?: MemoryFilters,\n): MemoryItemResponse[] {\n\tif (ids.length === 0) return [];\n\tconst results: MemoryItemResponse[] = [];\n\tfor (const id of ids) {\n\t\tconst item = getMemoryForMcp(store, id, filters);\n\t\tif (item) results.push(item);\n\t}\n\treturn results;\n}\n\nexport function forgetMemoryForMcp(\n\tstore: MemoryStore,\n\tmemoryId: number,\n\tfilters?: MemoryFilters,\n): boolean {\n\tconst item = getMemoryForMcp(store, memoryId, filters);\n\tif (!item) return false;\n\tstore.forget(memoryId);\n\treturn true;\n}\n\nexport interface RememberMemoryForMcpInput {\n\tkind: string;\n\ttitle: string;\n\tbody: string;\n\tconfidence: number;\n\tproject?: string | null;\n}\n\nexport interface RememberMemoryForMcpContext {\n\tcwd?: string;\n\tuser?: string;\n\tenvProject?: string | null;\n\tnow?: () => string;\n}\n\nexport function rememberMemoryForMcp(\n\tstore: MemoryStore,\n\tinput: RememberMemoryForMcpInput,\n\tcontext: RememberMemoryForMcpContext = {},\n): { memId: number; title: string; body: string } {\n\treturn store.db.transaction(() => {\n\t\tconst now = context.now?.() ?? new Date().toISOString();\n\t\tconst user = context.user ?? process.env.USER ?? \"unknown\";\n\t\tconst cwd = context.cwd ?? process.cwd();\n\t\tconst project = resolveWriteProject({\n\t\t\tproject: input.project,\n\t\t\tenvProject: context.envProject,\n\t\t});\n\n\t\tconst sessionInfo = store.db\n\t\t\t.prepare(\n\t\t\t\t`INSERT INTO sessions(started_at, ended_at, cwd, project, user, tool_version, metadata_json)\n\t\t\t\t VALUES (?, ?, ?, ?, ?, ?, ?)`,\n\t\t\t)\n\t\t\t.run(now, now, cwd, project, user, \"mcp-ts\", toJson({ mcp: true }));\n\t\tconst sessionId = Number(sessionInfo.lastInsertRowid);\n\n\t\tconst memId = store.remember(sessionId, input.kind, input.title, input.body, input.confidence);\n\t\tif (!getMemoryForMcp(store, memId)) {\n\t\t\tthrow new Error(\"unauthorized_scope\");\n\t\t}\n\n\t\tstore.db\n\t\t\t.prepare(\"UPDATE sessions SET ended_at = ?, metadata_json = ? WHERE id = ?\")\n\t\t\t.run(context.now?.() ?? new Date().toISOString(), toJson({ mcp: true }), sessionId);\n\n\t\treturn { memId, title: input.title, body: input.body };\n\t})();\n}\n","import { storeVectors } from \"@codemem/core\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { errorContent, jsonContent } from \"../content.js\";\nimport { withMcpRetrieval } from \"../mcp-retrieval-ledger.js\";\nimport {\n\tforgetMemoryForMcp,\n\tgetManyForMcp,\n\tgetMemoryForMcp,\n\trememberMemoryForMcp,\n} from \"../memory-access.js\";\nimport { buildFilters } from \"../project-scope.js\";\nimport { filterSchema, memoryKindSchema } from \"../schemas.js\";\nimport type { ToolRegistrationContext } from \"../tool-context.js\";\nimport { toolAnnotations, toolOutputSchemas } from \"../tool-contracts.js\";\n\nconst getInputSchema = {\n\tmemory_id: z.number().int().describe(\"Memory ID\"),\n\t...filterSchema,\n};\n\nconst getObservationsInputSchema = {\n\tids: z.array(z.number().int()).max(200).describe(\"Memory IDs to fetch\"),\n\t...filterSchema,\n};\n\nconst rememberInputSchema = {\n\tkind: memoryKindSchema.describe(\"Memory kind\"),\n\ttitle: z.string().describe(\"Short title\"),\n\tbody: z.string().describe(\"Body text (high-signal content)\"),\n\tconfidence: z.number().min(0).max(1).default(0.5).describe(\"Confidence 0-1\"),\n\tproject: z.string().optional().describe(\"Project identifier\"),\n};\n\nconst forgetInputSchema = {\n\tmemory_id: z.number().int().describe(\"Memory ID to forget\"),\n\t...filterSchema,\n};\n\nfunction registerGetTool(server: McpServer, context: ToolRegistrationContext): void {\n\tserver.registerTool(\n\t\t\"memory_get\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Fetch one memory by exact ID. Does not inherit the default project; optional filters constrain the lookup, and a mismatch returns not_found.\",\n\t\t\tinputSchema: getInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_get,\n\t\t\tannotations: toolAnnotations.memory_get,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\t// Direct-ID ops do not inherit the server default project. Callers already\n\t\t\t// have an exact ID; cwd/env should not silently scope the lookup.\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_get\",\n\t\t\t\t\ttoolName: \"memory_get\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tlimit: 1,\n\t\t\t\t\tresolveFilters: () => buildFilters(args, null),\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\t(filters) => {\n\t\t\t\t\tconst item = getMemoryForMcp(context.store, args.memory_id, filters);\n\t\t\t\t\treturn item\n\t\t\t\t\t\t? { value: item, memoryIds: [item.id], filters }\n\t\t\t\t\t\t: { value: null, memoryIds: [], error: \"not_found\", filters };\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n}\n\nfunction registerGetObservationsTool(server: McpServer, context: ToolRegistrationContext): void {\n\tserver.registerTool(\n\t\t\"memory_get_observations\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Fetch multiple memories by exact IDs. Does not inherit the default project. Missing or filtered-out IDs are omitted from results, not reported as not_found.\",\n\t\t\tinputSchema: getObservationsInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_get_observations,\n\t\t\tannotations: toolAnnotations.memory_get_observations,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_get_observations\",\n\t\t\t\t\ttoolName: \"memory_get_observations\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tlimit: args.ids.length,\n\t\t\t\t\tresolveFilters: () => buildFilters(args, null),\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\t(filters) => {\n\t\t\t\t\tconst items = getManyForMcp(context.store, args.ids, filters);\n\t\t\t\t\treturn { value: { items }, memoryIds: items.map((item) => item.id), filters };\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n}\n\nfunction registerRememberTool(server: McpServer, context: ToolRegistrationContext): void {\n\tserver.registerTool(\n\t\t\"memory_remember\",\n\t\t{\n\t\t\tdescription: \"Create a new memory. Use for milestones, decisions, and notable facts.\",\n\t\t\tinputSchema: rememberInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_remember,\n\t\t\tannotations: toolAnnotations.memory_remember,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\t// Writes never inherit the server default project. They only honor an\n\t\t\t\t// explicit `project` input or CODEMEM_PROJECT; otherwise project stays null.\n\t\t\t\tconst result = rememberMemoryForMcp(context.store, args, {\n\t\t\t\t\tenvProject: context.envProject(),\n\t\t\t\t});\n\n\t\t\t\ttry {\n\t\t\t\t\tawait storeVectors(context.store.db, result.memId, result.title, result.body);\n\t\t\t\t} catch {\n\t\t\t\t\t// Memory writes should succeed even if embeddings are unavailable.\n\t\t\t\t}\n\n\t\t\t\treturn jsonContent({ id: result.memId });\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n}\n\nfunction registerForgetTool(server: McpServer, context: ToolRegistrationContext): void {\n\tserver.registerTool(\n\t\t\"memory_forget\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Soft-delete a memory by exact ID so it no longer appears in normal retrieval; this is not secure erasure. Does not inherit the default project; optional filters must match or the tool returns not_found.\",\n\t\t\tinputSchema: forgetInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_forget,\n\t\t\tannotations: toolAnnotations.memory_forget,\n\t\t},\n\t\tasync (args) => {\n\t\t\ttry {\n\t\t\t\tif (!forgetMemoryForMcp(context.store, args.memory_id, buildFilters(args, null))) {\n\t\t\t\t\treturn errorContent(\"not_found\");\n\t\t\t\t}\n\t\t\t\treturn jsonContent({ status: \"ok\" });\n\t\t\t} catch (err) {\n\t\t\t\treturn errorContent(err instanceof Error ? err.message : String(err));\n\t\t\t}\n\t\t},\n\t);\n}\n\nexport function registerItemTools(server: McpServer, context: ToolRegistrationContext): void {\n\tregisterGetTool(server, context);\n\tregisterGetObservationsTool(server, context);\n\tregisterRememberTool(server, context);\n\tregisterForgetTool(server, context);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { jsonContent } from \"../content.js\";\nimport { toolAnnotations, toolOutputSchemas } from \"../tool-contracts.js\";\n\nconst MEMORY_LEARN_GUIDANCE = {\n\tintro: \"Use this tool when you're new to codemem or unsure when to recall/persist.\",\n\tclient_hint: \"If you are unfamiliar with codemem, call memory_learn first.\",\n\trecall: {\n\t\twhen: [\n\t\t\t\"Start of a task or when the user references prior work.\",\n\t\t\t\"When you need background context, decisions, or recent changes.\",\n\t\t],\n\t\thow: [\n\t\t\t\"Use memory_search or memory_search_index for exact terms and identifiers; memory_search returns bodies, while memory_search_index returns compact candidates.\",\n\t\t\t\"Use memory_pack for conceptually relevant context; it combines keyword and semantic search when embeddings are available and falls back to keyword search when they are not.\",\n\t\t\t\"Use memory_timeline to expand around a promising memory.\",\n\t\t\t\"Use memory_get or memory_get_observations for full details only when needed.\",\n\t\t\t\"Use the project filter unless the user requests cross-project context.\",\n\t\t\t\"Project, trust, and ownership filters organize and select memories; they are not authentication or tenant-isolation controls.\",\n\t\t],\n\t\texamples: [\n\t\t\t'memory_search_index(query=\"billing cache bug\", limit=5)',\n\t\t\t\"memory_timeline(memory_id=123)\",\n\t\t\t\"memory_get_observations(ids=[123, 456])\",\n\t\t],\n\t},\n\tpersistence: {\n\t\twhen: [\n\t\t\t\"Milestones (task done, key decision, new facts learned).\",\n\t\t\t\"Notable regressions or follow-ups that should be remembered.\",\n\t\t],\n\t\thow: [\n\t\t\t\"Use memory_remember with kind decision/discovery/change/exploration.\",\n\t\t\t\"Keep titles short and bodies high-signal.\",\n\t\t\t\"ALWAYS pass the project parameter if known.\",\n\t\t],\n\t\texamples: [\n\t\t\t'memory_remember(kind=\"decision\", title=\"Switch to async cache\", body=\"...why...\", project=\"my-service\")',\n\t\t\t'memory_remember(kind=\"change\", title=\"Fixed retry loop\", body=\"...impact...\", project=\"my-service\")',\n\t\t],\n\t},\n\tforget: {\n\t\twhen: [\n\t\t\t\"Obsolete or incorrect items that should no longer surface.\",\n\t\t\t\"Items that should be soft-deleted; soft deletion is not secure erasure.\",\n\t\t],\n\t\thow: [\n\t\t\t\"Call memory_forget(memory_id) to mark the item inactive.\",\n\t\t\t\"Optional filters constrain the exact-ID lookup; a filter mismatch returns not_found.\",\n\t\t\t\"Do not treat memory_forget as secure erasure or a user-data erasure guarantee.\",\n\t\t],\n\t\texamples: [\"memory_forget(memory_id=123)\"],\n\t},\n\tprompt_hint:\n\t\t\"At task start: call memory_search_index for exact terms or memory_pack for conceptual context; during work: memory_timeline + memory_get_observations; at milestones: memory_remember.\",\n\trecommended_system_prompt: [\n\t\t\"Trigger policy (1-liner): If the user references prior work or starts a task,\",\n\t\t\"call memory_search_index for exact terms or memory_pack for conceptual context; then use\",\n\t\t\"memory_timeline + memory_get_observations; at milestones, call memory_remember.\",\n\t\t\"\",\n\t\t\"System prompt:\",\n\t\t\"You have access to codemem MCP tools. If unfamiliar, call memory_learn first.\",\n\t\t\"\",\n\t\t\"Recall:\",\n\t\t\"- For exact terms or identifiers, use memory_search_index for compact candidates or memory_search for bodies.\",\n\t\t\"- For conceptually relevant context, use memory_pack; it falls back to keyword search without embeddings.\",\n\t\t'- If prior work is referenced (\"as before\", \"last time\", \"we already did…\", \"regression\"),',\n\t\t\" call memory_search_index, memory_pack, or memory_timeline as appropriate.\",\n\t\t\"- Use memory_get or memory_get_observations only after filtering IDs.\",\n\t\t\"- Prefer project-scoped queries unless the user asks for cross-project.\",\n\t\t\"- Project, trust, and ownership filters select memories; they do not authenticate or isolate tenants.\",\n\t\t\"\",\n\t\t\"Persistence:\",\n\t\t\"- On milestones (task done, key decision, new facts learned), call memory_remember.\",\n\t\t\"- Use kind=decision for tradeoffs, kind=change for outcomes, kind=discovery/exploration for useful findings.\",\n\t\t\"- Keep titles short and bodies high-signal.\",\n\t\t\"- ALWAYS pass the project parameter if known.\",\n\t\t\"\",\n\t\t\"Safety:\",\n\t\t\"- Use memory_forget(memory_id) to soft-delete incorrect or obsolete items; this is not secure erasure.\",\n\t\t\"\",\n\t\t\"Examples:\",\n\t\t'- memory_search_index(query=\"billing cache bug\")',\n\t\t\"- memory_timeline(memory_id=123)\",\n\t\t\"- memory_get_observations(ids=[123, 456])\",\n\t\t'- memory_remember(kind=\"decision\", title=\"Use async cache\", body=\"Chose async cache to avoid lock contention in X.\", project=\"my-service\")',\n\t\t'- memory_remember(kind=\"change\", title=\"Fixed retry loop\", body=\"Root cause was Y; added guard in Z.\", project=\"my-service\")',\n\t\t\"- memory_forget(memory_id=123)\",\n\t].join(\"\\n\"),\n} as const;\n\nexport function registerLearnTools(server: McpServer): void {\n\tserver.registerTool(\n\t\t\"memory_learn\",\n\t\t{\n\t\t\tdescription: \"Learn how to use codemem memory tools. Call this first if unfamiliar.\",\n\t\t\tinputSchema: {},\n\t\t\toutputSchema: toolOutputSchemas.memory_learn,\n\t\t\tannotations: toolAnnotations.memory_learn,\n\t\t},\n\t\tasync () => jsonContent(MEMORY_LEARN_GUIDANCE),\n\t);\n}\n","import type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { jsonContent } from \"../content.js\";\nimport { MEMORY_KINDS } from \"../memory-kinds.js\";\nimport { filterNames } from \"../schemas.js\";\nimport { toolAnnotations, toolOutputSchemas } from \"../tool-contracts.js\";\n\nexport function registerSchemaTools(server: McpServer): void {\n\tserver.registerTool(\n\t\t\"memory_schema\",\n\t\t{\n\t\t\tdescription: \"Return the memory schema — kinds, fields, and available filters.\",\n\t\t\tinputSchema: {},\n\t\t\toutputSchema: toolOutputSchemas.memory_schema,\n\t\t\tannotations: toolAnnotations.memory_schema,\n\t\t},\n\t\tasync () => {\n\t\t\treturn jsonContent({\n\t\t\t\tkinds: Object.keys(MEMORY_KINDS),\n\t\t\t\tkind_descriptions: MEMORY_KINDS,\n\t\t\t\tfields: {\n\t\t\t\t\ttitle: \"short text\",\n\t\t\t\t\tbody: \"long text\",\n\t\t\t\t\tsubtitle: \"short text\",\n\t\t\t\t\tfacts: \"list<string>\",\n\t\t\t\t\tnarrative: \"long text\",\n\t\t\t\t\tconcepts: \"list<string>\",\n\t\t\t\t\tfiles_read: \"list<string>\",\n\t\t\t\t\tfiles_modified: \"list<string>\",\n\t\t\t\t\tprompt_number: \"int\",\n\t\t\t\t},\n\t\t\t\tfilters: filterNames,\n\t\t\t});\n\t\t},\n\t);\n}\n","import type { MemoryResult } from \"@codemem/core\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { withMcpRetrieval } from \"../mcp-retrieval-ledger.js\";\nimport { buildFilters } from \"../project-scope.js\";\nimport { filterSchema } from \"../schemas.js\";\nimport type { ToolRegistrationContext } from \"../tool-context.js\";\nimport { toolAnnotations, toolOutputSchemas } from \"../tool-contracts.js\";\n\nconst searchInputSchema = {\n\tquery: z.string().describe(\"Search query\"),\n\tlimit: z.number().int().min(1).max(50).default(5).describe(\"Max results\"),\n\t...filterSchema,\n};\n\nconst searchIndexInputSchema = {\n\tquery: z.string().describe(\"Search query\"),\n\tlimit: z.number().int().min(1).max(50).default(8).describe(\"Max results\"),\n\t...filterSchema,\n};\n\nconst explainInputSchema = {\n\tquery: z.string().optional().describe(\"Search query\"),\n\tids: z.array(z.number().int()).max(200).optional().describe(\"Specific memory IDs to explain\"),\n\tlimit: z.number().int().min(1).max(50).default(10).describe(\"Max results\"),\n\tinclude_pack_context: z.boolean().default(false).describe(\"Include formatted pack context\"),\n\t...filterSchema,\n};\n\nconst recentInputSchema = {\n\tlimit: z.number().int().min(1).max(100).default(8).describe(\"Max results\"),\n\t...filterSchema,\n};\n\nconst packInputSchema = {\n\tcontext: z.string().describe(\"Context description to search for\"),\n\tlimit: z.number().int().min(1).max(50).optional().describe(\"Max items to include\"),\n\tcompact: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe(\n\t\t\t\"When true, render a scannable index of all items with full detail only for the top N (default 3). Saves tokens when broad overview matters more than per-item detail.\",\n\t\t),\n\tcompact_detail_count: z\n\t\t.number()\n\t\t.int()\n\t\t.min(0)\n\t\t.max(50)\n\t\t.optional()\n\t\t.describe(\"Number of items to show in full detail in compact mode (default 3)\"),\n\tcompression_mode: z\n\t\t.enum([\"off\", \"compact\", \"ids\"])\n\t\t.optional()\n\t\t.describe(\n\t\t\t\"Near-related compression mode: off disables it, compact applies only to compact rendering, ids applies in all modes. Defaults to CODEMEM_PACK_COMPRESSION or compact.\",\n\t\t),\n\t...filterSchema,\n};\n\nexport function registerSearchTools(server: McpServer, context: ToolRegistrationContext): void {\n\tconst { defaultProject, store } = context;\n\n\tserver.registerTool(\n\t\t\"memory_search\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Keyword-search memories when you know exact terms or identifiers. Returns full body text for each match; use memory_search_index when you only need compact candidates.\",\n\t\t\tinputSchema: searchInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_search,\n\t\t\tannotations: toolAnnotations.memory_search,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_search\",\n\t\t\t\t\ttoolName: \"memory_search\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tquery: args.query,\n\t\t\t\t\tlimit: args.limit,\n\t\t\t\t\tresolveFilters: () => buildFilters(args, defaultProject()),\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\t(filters) => {\n\t\t\t\t\tconst items = store.search(args.query, args.limit, filters);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\titems: items.map((m: MemoryResult) => ({\n\t\t\t\t\t\t\t\tid: m.id,\n\t\t\t\t\t\t\t\ttitle: m.title,\n\t\t\t\t\t\t\t\tkind: m.kind,\n\t\t\t\t\t\t\t\tbody: m.body_text,\n\t\t\t\t\t\t\t\tconfidence: m.confidence,\n\t\t\t\t\t\t\t\tscore: m.score,\n\t\t\t\t\t\t\t\tsession_id: m.session_id,\n\t\t\t\t\t\t\t\tmetadata: m.metadata,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmemoryIds: items.map((item) => item.id),\n\t\t\t\t\t\tfilters,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\tserver.registerTool(\n\t\t\"memory_search_index\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Keyword-search memories when you know exact terms or identifiers. Returns compact entries with IDs and titles, without bodies; expand selected IDs with memory_get or memory_get_observations.\",\n\t\t\tinputSchema: searchIndexInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_search_index,\n\t\t\tannotations: toolAnnotations.memory_search_index,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_search_index\",\n\t\t\t\t\ttoolName: \"memory_search_index\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tquery: args.query,\n\t\t\t\t\tlimit: args.limit,\n\t\t\t\t\tresolveFilters: () => buildFilters(args, defaultProject()),\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\t(filters) => {\n\t\t\t\t\tconst items = store.search(args.query, args.limit, filters);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\titems: items.map((m: MemoryResult) => ({\n\t\t\t\t\t\t\t\tid: m.id,\n\t\t\t\t\t\t\t\tkind: m.kind,\n\t\t\t\t\t\t\t\ttitle: m.title,\n\t\t\t\t\t\t\t\tscore: m.score,\n\t\t\t\t\t\t\t\tcreated_at: m.created_at,\n\t\t\t\t\t\t\t\tsession_id: m.session_id,\n\t\t\t\t\t\t\t\tmetadata: m.metadata,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmemoryIds: items.map((item) => item.id),\n\t\t\t\t\t\tfilters,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\tserver.registerTool(\n\t\t\"memory_explain\",\n\t\t{\n\t\t\tdescription: \"Explain search results with detailed scoring breakdown.\",\n\t\t\tinputSchema: explainInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_explain,\n\t\t\tannotations: toolAnnotations.memory_explain,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_explain\",\n\t\t\t\t\ttoolName: \"memory_explain\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tquery: args.query,\n\t\t\t\t\tlimit: args.limit,\n\t\t\t\t\tresolveFilters: () => buildFilters(args, defaultProject()),\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\t(filters) => {\n\t\t\t\t\tconst result = store.explain(args.query ?? null, args.ids ?? null, args.limit, filters, {\n\t\t\t\t\t\tincludePackContext: args.include_pack_context,\n\t\t\t\t\t});\n\t\t\t\t\tconst fatalInputError = result.errors.some(\n\t\t\t\t\t\t(error) => error.code === \"INVALID_ARGUMENT\" && error.field === \"query\",\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvalue: result,\n\t\t\t\t\t\tmemoryIds: result.items.map((item) => item.id),\n\t\t\t\t\t\tfilters,\n\t\t\t\t\t\tretrievalStatus: fatalInputError ? (\"failed\" as const) : undefined,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\tserver.registerTool(\n\t\t\"memory_recent\",\n\t\t{\n\t\t\tdescription: \"Return recent memories, newest first.\",\n\t\t\tinputSchema: recentInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_recent,\n\t\t\tannotations: toolAnnotations.memory_recent,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_recent\",\n\t\t\t\t\ttoolName: \"memory_recent\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tlimit: args.limit,\n\t\t\t\t\tresolveFilters: () => buildFilters(args, defaultProject()),\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\t(filters) => {\n\t\t\t\t\tconst items = store.recent(args.limit, filters);\n\t\t\t\t\treturn { value: { items }, memoryIds: items.map((item) => item.id), filters };\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\tserver.registerTool(\n\t\t\"memory_pack\",\n\t\t{\n\t\t\tdescription:\n\t\t\t\t\"Build a formatted context block for a concept or task using keyword and semantic search when embeddings are available, with automatic keyword-only fallback. Use for conceptually relevant context; use memory_search or memory_search_index for exact identifiers.\",\n\t\t\tinputSchema: packInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_pack,\n\t\t\tannotations: toolAnnotations.memory_pack,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_pack\",\n\t\t\t\t\ttoolName: \"memory_pack\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tquery: args.context,\n\t\t\t\t\tlimit: args.limit ?? null,\n\t\t\t\t\tresolveFilters: () => buildFilters(args, defaultProject()),\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\tasync (filters) => {\n\t\t\t\t\tconst renderOptions =\n\t\t\t\t\t\targs.compact || args.compact_detail_count != null || args.compression_mode != null\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tcompact: args.compact ?? (args.compact_detail_count != null ? true : undefined),\n\t\t\t\t\t\t\t\t\tcompactDetailCount: args.compact_detail_count,\n\t\t\t\t\t\t\t\t\tcompressionMode: args.compression_mode,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\tconst result = await store.buildMemoryPackAsync(\n\t\t\t\t\t\targs.context,\n\t\t\t\t\t\targs.limit ?? undefined,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tfilters,\n\t\t\t\t\t\trenderOptions,\n\t\t\t\t\t);\n\t\t\t\t\t// Renderer spans and fingerprints belong to automatic recall, not model context.\n\t\t\t\t\tconst { rendered_items: _renderedItems, ...value } = result;\n\t\t\t\t\treturn { value, memoryIds: result.item_ids, filters };\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n}\n","import { dedupeOrderedIds, type MemoryItemResponse, projectMatchesFilter } from \"@codemem/core\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { withMcpRetrieval } from \"../mcp-retrieval-ledger.js\";\nimport { getManyForMcp } from \"../memory-access.js\";\nimport { buildFilters } from \"../project-scope.js\";\nimport { filterSchema } from \"../schemas.js\";\nimport type { ToolRegistrationContext } from \"../tool-context.js\";\nimport { toolAnnotations, toolOutputSchemas } from \"../tool-contracts.js\";\n\nconst timelineInputSchema = {\n\tquery: z.string().optional().describe(\"Search query to find anchor\"),\n\tmemory_id: z.number().int().optional().describe(\"Anchor memory ID\"),\n\tdepth_before: z.number().int().min(0).default(3).describe(\"Items before anchor\"),\n\tdepth_after: z.number().int().min(0).default(3).describe(\"Items after anchor\"),\n\t...filterSchema,\n};\n\nconst expandInputSchema = {\n\tids: z\n\t\t.array(z.union([z.number(), z.string()]))\n\t\t.max(200)\n\t\t.describe(\"Memory IDs to expand\"),\n\tdepth_before: z.number().int().min(0).default(3).describe(\"Timeline items before\"),\n\tdepth_after: z.number().int().min(0).default(3).describe(\"Timeline items after\"),\n\tinclude_observations: z.boolean().default(false).describe(\"Include full observation details\"),\n\t...filterSchema,\n};\n\nexport function registerTimelineTools(server: McpServer, context: ToolRegistrationContext): void {\n\tconst { defaultProject, store } = context;\n\n\tserver.registerTool(\n\t\t\"memory_timeline\",\n\t\t{\n\t\t\tdescription: \"Get a chronological window of memories around an anchor (by ID or query).\",\n\t\t\tinputSchema: timelineInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_timeline,\n\t\t\tannotations: toolAnnotations.memory_timeline,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_timeline\",\n\t\t\t\t\ttoolName: \"memory_timeline\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tquery: args.query,\n\t\t\t\t\tlimit: args.depth_before + args.depth_after + 1,\n\t\t\t\t\tresolveFilters: () => buildFilters(args, defaultProject()),\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\t(filters) => {\n\t\t\t\t\tconst items = store.timeline(\n\t\t\t\t\t\targs.query ?? null,\n\t\t\t\t\t\targs.memory_id ?? null,\n\t\t\t\t\t\targs.depth_before,\n\t\t\t\t\t\targs.depth_after,\n\t\t\t\t\t\tfilters,\n\t\t\t\t\t);\n\t\t\t\t\treturn { value: { items }, memoryIds: items.map((item) => item.id), filters };\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n\n\tserver.registerTool(\n\t\t\"memory_expand\",\n\t\t{\n\t\t\tdescription: \"Fetch memories by ID with surrounding timeline context.\",\n\t\t\tinputSchema: expandInputSchema,\n\t\t\toutputSchema: toolOutputSchemas.memory_expand,\n\t\t\tannotations: toolAnnotations.memory_expand,\n\t\t},\n\t\tasync (args, extra) => {\n\t\t\treturn withMcpRetrieval(\n\t\t\t\tcontext,\n\t\t\t\t{\n\t\t\t\t\tsurface: \"mcp_expand\",\n\t\t\t\t\ttoolName: \"memory_expand\",\n\t\t\t\t\ttoolArguments: args,\n\t\t\t\t\tlimit: args.ids.length,\n\t\t\t\t\tresolveFilters: () => {\n\t\t\t\t\t\t// Explicit blank `project` clears scoping for cross-project expansion.\n\t\t\t\t\t\t// Only fall back to the server default when `project` is omitted entirely.\n\t\t\t\t\t\tconst filterDefaultProject =\n\t\t\t\t\t\t\targs.project !== undefined && !args.project.trim() ? null : defaultProject();\n\t\t\t\t\t\treturn buildFilters(args, filterDefaultProject);\n\t\t\t\t\t},\n\t\t\t\t\trequestId: extra?.requestId,\n\t\t\t\t\tsourceSessionId: extra?.sessionId,\n\t\t\t\t\tinvocationIdentity: extra?.signal,\n\t\t\t\t},\n\t\t\t\t(filters) => {\n\t\t\t\t\tconst resolvedProject = filters?.project ?? null;\n\t\t\t\t\tconst { ordered: orderedIds, invalid: invalidIds } = dedupeOrderedIds(args.ids);\n\t\t\t\t\tconst errors: Array<Record<string, unknown>> = [];\n\n\t\t\t\t\tif (invalidIds.length > 0) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\tcode: \"INVALID_ARGUMENT\",\n\t\t\t\t\t\t\tfield: \"ids\",\n\t\t\t\t\t\t\tmessage: \"some ids are not valid integers\",\n\t\t\t\t\t\t\tids: invalidIds,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tconst missingNotFound: number[] = [];\n\t\t\t\t\tconst missingProjectMismatch: number[] = [];\n\t\t\t\t\tconst missingFilterMismatch: number[] = [];\n\t\t\t\t\tconst anchors: MemoryItemResponse[] = [];\n\t\t\t\t\tconst timelineItems: MemoryItemResponse[] = [];\n\t\t\t\t\tconst timelineSeen = new Set<number>();\n\t\t\t\t\tconst sessionProjects = new Map<number, string | null>();\n\n\t\t\t\t\tfor (const memoryId of orderedIds) {\n\t\t\t\t\t\tconst item = store.get(memoryId);\n\t\t\t\t\t\tif (!item?.active) {\n\t\t\t\t\t\t\tmissingNotFound.push(memoryId);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst sessionId = item.session_id;\n\t\t\t\t\t\tif (resolvedProject && sessionId > 0) {\n\t\t\t\t\t\t\tif (!sessionProjects.has(sessionId)) {\n\t\t\t\t\t\t\t\tconst row = store.db\n\t\t\t\t\t\t\t\t\t.prepare(\"SELECT project FROM sessions WHERE id = ? LIMIT 1\")\n\t\t\t\t\t\t\t\t\t.get(sessionId) as { project: string | null } | undefined;\n\t\t\t\t\t\t\t\tsessionProjects.set(\n\t\t\t\t\t\t\t\t\tsessionId,\n\t\t\t\t\t\t\t\t\ttypeof row?.project === \"string\" ? row.project : null,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!projectMatchesFilter(resolvedProject, sessionProjects.get(sessionId) ?? null)) {\n\t\t\t\t\t\t\t\tmissingProjectMismatch.push(memoryId);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (resolvedProject && sessionId <= 0) {\n\t\t\t\t\t\t\tmissingProjectMismatch.push(memoryId);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst expanded = store.timeline(\n\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\tmemoryId,\n\t\t\t\t\t\t\targs.depth_before,\n\t\t\t\t\t\t\targs.depth_after,\n\t\t\t\t\t\t\tfilters,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst anchor = expanded.find((expandedItem) => expandedItem.id === memoryId);\n\t\t\t\t\t\tif (!anchor) {\n\t\t\t\t\t\t\tmissingFilterMismatch.push(memoryId);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tanchors.push(anchor);\n\t\t\t\t\t\tfor (const expandedItem of expanded) {\n\t\t\t\t\t\t\tconst expandedId = expandedItem.id;\n\t\t\t\t\t\t\tif (expandedId <= 0 || timelineSeen.has(expandedId)) continue;\n\t\t\t\t\t\t\ttimelineSeen.add(expandedId);\n\t\t\t\t\t\t\ttimelineItems.push(expandedItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (missingNotFound.length > 0) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\tcode: \"NOT_FOUND\",\n\t\t\t\t\t\t\tfield: \"ids\",\n\t\t\t\t\t\t\tmessage: \"some requested ids were not found\",\n\t\t\t\t\t\t\tids: missingNotFound,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (missingProjectMismatch.length > 0) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\tcode: \"PROJECT_MISMATCH\",\n\t\t\t\t\t\t\tfield: \"project\",\n\t\t\t\t\t\t\tmessage: \"some requested ids are outside the requested project scope\",\n\t\t\t\t\t\t\tids: missingProjectMismatch,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (missingFilterMismatch.length > 0) {\n\t\t\t\t\t\terrors.push({\n\t\t\t\t\t\t\tcode: \"FILTER_MISMATCH\",\n\t\t\t\t\t\t\tfield: \"filters\",\n\t\t\t\t\t\t\tmessage: \"some requested ids are outside the requested filters\",\n\t\t\t\t\t\t\tids: missingFilterMismatch,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tlet observations: MemoryItemResponse[] = [];\n\t\t\t\t\tif (args.include_observations) {\n\t\t\t\t\t\tconst observationSeen = new Set<number>();\n\t\t\t\t\t\tconst observationIds: number[] = [];\n\t\t\t\t\t\tfor (const item of [...anchors, ...timelineItems]) {\n\t\t\t\t\t\t\tif (item.id > 0 && !observationSeen.has(item.id)) {\n\t\t\t\t\t\t\t\tobservationSeen.add(item.id);\n\t\t\t\t\t\t\t\tobservationIds.push(item.id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tobservations = getManyForMcp(store, observationIds, filters);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst value = {\n\t\t\t\t\t\tanchors,\n\t\t\t\t\t\ttimeline: timelineItems,\n\t\t\t\t\t\tobservations,\n\t\t\t\t\t\tmissing_ids: orderedIds.filter(\n\t\t\t\t\t\t\t(memoryId: number) =>\n\t\t\t\t\t\t\t\tmissingNotFound.includes(memoryId) ||\n\t\t\t\t\t\t\t\tmissingProjectMismatch.includes(memoryId) ||\n\t\t\t\t\t\t\t\tmissingFilterMismatch.includes(memoryId),\n\t\t\t\t\t\t),\n\t\t\t\t\t\terrors,\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tproject: resolvedProject,\n\t\t\t\t\t\t\trequested_ids_count: orderedIds.length,\n\t\t\t\t\t\t\treturned_anchor_count: anchors.length,\n\t\t\t\t\t\t\ttimeline_count: timelineItems.length,\n\t\t\t\t\t\t\tinclude_observations: args.include_observations,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tconst memoryIds = [\n\t\t\t\t\t\t...new Set([...anchors, ...timelineItems, ...observations].map((item) => item.id)),\n\t\t\t\t\t];\n\t\t\t\t\treturn { value, memoryIds, filters };\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t);\n}\n","import { randomUUID } from \"node:crypto\";\nimport { type MemoryStore, VERSION } from \"@codemem/core\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { resolveDefaultProject } from \"./project-scope.js\";\nimport type { CodememMcpServerOptions, ToolRegistrationContext } from \"./tool-context.js\";\nimport { registerDistillTools } from \"./tools/distill.js\";\nimport { registerItemTools } from \"./tools/items.js\";\nimport { registerLearnTools } from \"./tools/learn.js\";\nimport { registerSchemaTools } from \"./tools/schema.js\";\nimport { registerSearchTools } from \"./tools/search.js\";\nimport { registerTimelineTools } from \"./tools/timeline.js\";\n\nexport function createCodememMcpServer(\n\tstore: MemoryStore,\n\toptions: CodememMcpServerOptions = {},\n): McpServer {\n\tconst server = new McpServer({ name: \"codemem\", version: VERSION });\n\tconst context: ToolRegistrationContext = {\n\t\tstore,\n\t\t// Resolve lazily per call so long-running servers pick up the current\n\t\t// CODEMEM_PROJECT / process.cwd() rather than the value at construction.\n\t\tdefaultProject: () => {\n\t\t\tif (options.resolveDefaultProject) return options.resolveDefaultProject();\n\t\t\tif (options.defaultProject !== undefined) return options.defaultProject;\n\t\t\treturn resolveDefaultProject();\n\t\t},\n\t\tenvProject: () =>\n\t\t\toptions.envProject !== undefined ? options.envProject : (process.env.CODEMEM_PROJECT ?? null),\n\t\tcaptureRetrievalLedger: options.captureRetrievalLedger !== false,\n\t\tretrievalLedgerScopeId: options.retrievalLedgerScopeId ?? randomUUID(),\n\t\tretrievalLedgerIdentityMode: options.retrievalLedgerIdentityMode ?? \"session\",\n\t};\n\n\tregisterSearchTools(server, context);\n\tregisterTimelineTools(server, context);\n\tregisterDistillTools(server, context);\n\tregisterItemTools(server, context);\n\tregisterSchemaTools(server);\n\tregisterLearnTools(server);\n\n\treturn server;\n}\n"],"mappings":";;;;;;;;AAAA,SAAgB,EAAc,GAAwB;CACrD,OACC,KAAK,UAAU,IAAQ,GAAM,MACA,OAAO,KAAgB,aAA/C,KAA2D,MAAM,QAAQ,CAAW,IAChF,IAED,OAAO,YACb,OAAO,QAAQ,CAAsC,CAAC,CAAC,UAAU,CAAC,IAAO,CAAC,OACzE,IAAO,IAAQ,KAAK,MAAO,EAC5B,CACD,CACA,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,IAAI,mBAAmB,OAArD,EAAQ;EAC5C,wBAAwB,EAAQ,2BAA2B;EAC3D,wBAAwB,EAAQ,0BAA0B,EAAW;EACrE,6BAA6B,EAAQ,+BAA+B;CACrE;CASA,OAPA,GAAoB,GAAQ,CAAO,GACnC,GAAsB,GAAQ,CAAO,GACrC,EAAqB,GAAQ,CAAO,GACpC,GAAkB,GAAQ,CAAO,GACjC,GAAoB,CAAM,GAC1B,GAAmB,CAAM,GAElB;AACR"}
package/dist/stdio.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as e } from "./server-D-jxqflv.js";
2
+ import { t as e } from "./server-DmdZAo6k.js";
3
3
  import { MemoryStore as t, probeCodememViewerLiveness as n, resolveDbPath as r } from "@codemem/core";
4
4
  import { existsSync as i } from "node:fs";
5
5
  import { dirname as a, join as o } from "node:path";
@@ -0,0 +1,324 @@
1
+ import { z } from "zod";
2
+ export declare const toolOutputSchemas: {
3
+ readonly memory_search: z.ZodObject<{
4
+ items: z.ZodArray<z.ZodObject<{
5
+ id: z.ZodNumber;
6
+ kind: z.ZodString;
7
+ title: z.ZodString;
8
+ body: z.ZodString;
9
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
10
+ score: z.ZodOptional<z.ZodNumber>;
11
+ session_id: z.ZodOptional<z.ZodNumber>;
12
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13
+ }, z.core.$loose>>;
14
+ }, z.core.$strip>;
15
+ readonly memory_search_index: z.ZodObject<{
16
+ items: z.ZodArray<z.ZodObject<{
17
+ id: z.ZodNumber;
18
+ kind: z.ZodString;
19
+ title: z.ZodString;
20
+ score: z.ZodNumber;
21
+ created_at: z.ZodString;
22
+ session_id: z.ZodNumber;
23
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
24
+ }, z.core.$loose>>;
25
+ }, z.core.$strip>;
26
+ readonly memory_explain: z.ZodObject<{
27
+ items: z.ZodArray<z.ZodObject<{
28
+ id: z.ZodNumber;
29
+ kind: z.ZodString;
30
+ title: z.ZodString;
31
+ created_at: z.ZodString;
32
+ project: z.ZodNullable<z.ZodString>;
33
+ retrieval: z.ZodObject<{
34
+ source: z.ZodString;
35
+ rank: z.ZodNullable<z.ZodNumber>;
36
+ }, z.core.$loose>;
37
+ score: z.ZodObject<{
38
+ total: z.ZodNullable<z.ZodNumber>;
39
+ components: z.ZodObject<{
40
+ base: z.ZodNullable<z.ZodNumber>;
41
+ recency: z.ZodNumber;
42
+ kind_bonus: z.ZodNumber;
43
+ personal_bias: z.ZodNumber;
44
+ semantic_boost: z.ZodNullable<z.ZodNumber>;
45
+ }, z.core.$loose>;
46
+ }, z.core.$loose>;
47
+ role: z.ZodObject<{
48
+ inferred: z.ZodString;
49
+ reason: z.ZodString;
50
+ }, z.core.$loose>;
51
+ matches: z.ZodObject<{
52
+ query_terms: z.ZodArray<z.ZodString>;
53
+ project_match: z.ZodNullable<z.ZodBoolean>;
54
+ }, z.core.$loose>;
55
+ pack_context: z.ZodNullable<z.ZodObject<{
56
+ included: z.ZodNullable<z.ZodBoolean>;
57
+ section: z.ZodNullable<z.ZodString>;
58
+ }, z.core.$loose>>;
59
+ }, z.core.$loose>>;
60
+ missing_ids: z.ZodArray<z.ZodNumber>;
61
+ errors: z.ZodArray<z.ZodObject<{
62
+ code: z.ZodString;
63
+ field: z.ZodString;
64
+ message: z.ZodString;
65
+ ids: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
66
+ }, z.core.$loose>>;
67
+ metadata: z.ZodObject<{
68
+ query: z.ZodNullable<z.ZodString>;
69
+ project: z.ZodNullable<z.ZodString>;
70
+ requested_ids_count: z.ZodNumber;
71
+ returned_items_count: z.ZodNumber;
72
+ include_pack_context: z.ZodBoolean;
73
+ sanitized_query: z.ZodOptional<z.ZodString>;
74
+ }, z.core.$loose>;
75
+ }, z.core.$strip>;
76
+ readonly memory_recent: z.ZodObject<{
77
+ items: z.ZodArray<z.ZodObject<{
78
+ id: z.ZodNumber;
79
+ kind: z.ZodString;
80
+ title: z.ZodString;
81
+ body_text: z.ZodString;
82
+ session_id: z.ZodOptional<z.ZodNumber>;
83
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
84
+ created_at: z.ZodOptional<z.ZodString>;
85
+ updated_at: z.ZodOptional<z.ZodString>;
86
+ metadata_json: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
87
+ }, z.core.$loose>>;
88
+ }, z.core.$strip>;
89
+ readonly memory_pack: z.ZodObject<{
90
+ context: z.ZodString;
91
+ items: z.ZodArray<z.ZodObject<{
92
+ id: z.ZodNumber;
93
+ kind: z.ZodString;
94
+ title: z.ZodString;
95
+ body: z.ZodString;
96
+ confidence: z.ZodNullable<z.ZodNumber>;
97
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
98
+ }, z.core.$loose>>;
99
+ item_ids: z.ZodArray<z.ZodNumber>;
100
+ pack_text: z.ZodString;
101
+ metrics: z.ZodObject<{
102
+ total_items: z.ZodNumber;
103
+ pack_tokens: z.ZodNumber;
104
+ fallback_used: z.ZodBoolean;
105
+ limit: z.ZodNumber;
106
+ project: z.ZodNullable<z.ZodString>;
107
+ pack_item_ids: z.ZodArray<z.ZodNumber>;
108
+ }, z.core.$loose>;
109
+ }, z.core.$strip>;
110
+ readonly memory_timeline: z.ZodObject<{
111
+ items: z.ZodArray<z.ZodObject<{
112
+ id: z.ZodNumber;
113
+ kind: z.ZodString;
114
+ title: z.ZodString;
115
+ body_text: z.ZodString;
116
+ session_id: z.ZodOptional<z.ZodNumber>;
117
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
118
+ created_at: z.ZodOptional<z.ZodString>;
119
+ updated_at: z.ZodOptional<z.ZodString>;
120
+ metadata_json: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
121
+ }, z.core.$loose>>;
122
+ }, z.core.$strip>;
123
+ readonly memory_expand: z.ZodObject<{
124
+ anchors: z.ZodArray<z.ZodObject<{
125
+ id: z.ZodNumber;
126
+ kind: z.ZodString;
127
+ title: z.ZodString;
128
+ body_text: z.ZodString;
129
+ session_id: z.ZodOptional<z.ZodNumber>;
130
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
131
+ created_at: z.ZodOptional<z.ZodString>;
132
+ updated_at: z.ZodOptional<z.ZodString>;
133
+ metadata_json: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
134
+ }, z.core.$loose>>;
135
+ timeline: z.ZodArray<z.ZodObject<{
136
+ id: z.ZodNumber;
137
+ kind: z.ZodString;
138
+ title: z.ZodString;
139
+ body_text: z.ZodString;
140
+ session_id: z.ZodOptional<z.ZodNumber>;
141
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
142
+ created_at: z.ZodOptional<z.ZodString>;
143
+ updated_at: z.ZodOptional<z.ZodString>;
144
+ metadata_json: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
145
+ }, z.core.$loose>>;
146
+ observations: z.ZodArray<z.ZodObject<{
147
+ id: z.ZodNumber;
148
+ kind: z.ZodString;
149
+ title: z.ZodString;
150
+ body_text: z.ZodString;
151
+ session_id: z.ZodOptional<z.ZodNumber>;
152
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
153
+ created_at: z.ZodOptional<z.ZodString>;
154
+ updated_at: z.ZodOptional<z.ZodString>;
155
+ metadata_json: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
156
+ }, z.core.$loose>>;
157
+ missing_ids: z.ZodArray<z.ZodNumber>;
158
+ errors: z.ZodArray<z.ZodObject<{
159
+ code: z.ZodString;
160
+ field: z.ZodString;
161
+ message: z.ZodString;
162
+ ids: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
163
+ }, z.core.$loose>>;
164
+ metadata: z.ZodObject<{
165
+ project: z.ZodNullable<z.ZodString>;
166
+ requested_ids_count: z.ZodNumber;
167
+ returned_anchor_count: z.ZodNumber;
168
+ timeline_count: z.ZodNumber;
169
+ include_observations: z.ZodBoolean;
170
+ }, z.core.$loose>;
171
+ }, z.core.$strip>;
172
+ readonly memory_get: z.ZodObject<{
173
+ id: z.ZodNumber;
174
+ kind: z.ZodString;
175
+ title: z.ZodString;
176
+ body_text: z.ZodString;
177
+ session_id: z.ZodOptional<z.ZodNumber>;
178
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
179
+ created_at: z.ZodOptional<z.ZodString>;
180
+ updated_at: z.ZodOptional<z.ZodString>;
181
+ metadata_json: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
182
+ }, z.core.$loose>;
183
+ readonly memory_get_observations: z.ZodObject<{
184
+ items: z.ZodArray<z.ZodObject<{
185
+ id: z.ZodNumber;
186
+ kind: z.ZodString;
187
+ title: z.ZodString;
188
+ body_text: z.ZodString;
189
+ session_id: z.ZodOptional<z.ZodNumber>;
190
+ confidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
191
+ created_at: z.ZodOptional<z.ZodString>;
192
+ updated_at: z.ZodOptional<z.ZodString>;
193
+ metadata_json: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
194
+ }, z.core.$loose>>;
195
+ }, z.core.$strip>;
196
+ readonly memory_remember: z.ZodObject<{
197
+ id: z.ZodNumber;
198
+ }, z.core.$strip>;
199
+ readonly memory_forget: z.ZodObject<{
200
+ status: z.ZodLiteral<"ok">;
201
+ }, z.core.$strip>;
202
+ readonly memory_distill_candidates: z.ZodObject<{
203
+ version: z.ZodLiteral<1>;
204
+ candidates: z.ZodArray<z.ZodObject<{
205
+ scope: z.ZodEnum<{
206
+ project: "project";
207
+ user: "user";
208
+ }>;
209
+ suggested_target: z.ZodNullable<z.ZodString>;
210
+ score: z.ZodNumber;
211
+ recurrence: z.ZodNumber;
212
+ projects: z.ZodArray<z.ZodString>;
213
+ member_ids: z.ZodArray<z.ZodNumber>;
214
+ representative_id: z.ZodNumber;
215
+ concepts: z.ZodArray<z.ZodString>;
216
+ artifact_kind: z.ZodEnum<{
217
+ context_fact: "context_fact";
218
+ skill: "skill";
219
+ }>;
220
+ evidence: z.ZodArray<z.ZodString>;
221
+ draft_text: z.ZodNullable<z.ZodString>;
222
+ }, z.core.$loose>>;
223
+ metadata: z.ZodObject<{
224
+ candidate_count: z.ZodNumber;
225
+ cluster_count: z.ZodNumber;
226
+ context_document_count: z.ZodNumber;
227
+ corpus_count: z.ZodNumber;
228
+ corpus_limit: z.ZodNumber;
229
+ documented_cluster_count: z.ZodNumber;
230
+ include_documented: z.ZodBoolean;
231
+ min_recurrence: z.ZodNumber;
232
+ }, z.core.$loose>;
233
+ }, z.core.$strip>;
234
+ readonly memory_schema: z.ZodObject<{
235
+ kinds: z.ZodArray<z.ZodString>;
236
+ kind_descriptions: z.ZodRecord<z.ZodString, z.ZodString>;
237
+ fields: z.ZodRecord<z.ZodString, z.ZodString>;
238
+ filters: z.ZodArray<z.ZodString>;
239
+ }, z.core.$strip>;
240
+ readonly memory_learn: z.ZodObject<{
241
+ intro: z.ZodString;
242
+ client_hint: z.ZodString;
243
+ recall: z.ZodObject<{
244
+ when: z.ZodArray<z.ZodString>;
245
+ how: z.ZodArray<z.ZodString>;
246
+ examples: z.ZodArray<z.ZodString>;
247
+ }, z.core.$loose>;
248
+ persistence: z.ZodObject<{
249
+ when: z.ZodArray<z.ZodString>;
250
+ how: z.ZodArray<z.ZodString>;
251
+ examples: z.ZodArray<z.ZodString>;
252
+ }, z.core.$loose>;
253
+ forget: z.ZodObject<{
254
+ when: z.ZodArray<z.ZodString>;
255
+ how: z.ZodArray<z.ZodString>;
256
+ examples: z.ZodArray<z.ZodString>;
257
+ }, z.core.$loose>;
258
+ prompt_hint: z.ZodString;
259
+ recommended_system_prompt: z.ZodString;
260
+ }, z.core.$strip>;
261
+ };
262
+ export declare const toolAnnotations: {
263
+ readonly memory_search: {
264
+ readOnlyHint: true;
265
+ openWorldHint: false;
266
+ };
267
+ readonly memory_search_index: {
268
+ readOnlyHint: true;
269
+ openWorldHint: false;
270
+ };
271
+ readonly memory_explain: {
272
+ readOnlyHint: true;
273
+ openWorldHint: false;
274
+ };
275
+ readonly memory_recent: {
276
+ readOnlyHint: true;
277
+ openWorldHint: false;
278
+ };
279
+ readonly memory_pack: {
280
+ readOnlyHint: true;
281
+ openWorldHint: true;
282
+ };
283
+ readonly memory_timeline: {
284
+ readOnlyHint: true;
285
+ openWorldHint: false;
286
+ };
287
+ readonly memory_expand: {
288
+ readOnlyHint: true;
289
+ openWorldHint: false;
290
+ };
291
+ readonly memory_get: {
292
+ readOnlyHint: true;
293
+ openWorldHint: false;
294
+ };
295
+ readonly memory_get_observations: {
296
+ readOnlyHint: true;
297
+ openWorldHint: false;
298
+ };
299
+ readonly memory_remember: {
300
+ readonly readOnlyHint: false;
301
+ readonly destructiveHint: false;
302
+ readonly idempotentHint: false;
303
+ readonly openWorldHint: true;
304
+ };
305
+ readonly memory_forget: {
306
+ readonly readOnlyHint: false;
307
+ readonly destructiveHint: true;
308
+ readonly idempotentHint: true;
309
+ readonly openWorldHint: false;
310
+ };
311
+ readonly memory_distill_candidates: {
312
+ readOnlyHint: true;
313
+ openWorldHint: true;
314
+ };
315
+ readonly memory_schema: {
316
+ readOnlyHint: true;
317
+ openWorldHint: false;
318
+ };
319
+ readonly memory_learn: {
320
+ readOnlyHint: true;
321
+ openWorldHint: false;
322
+ };
323
+ };
324
+ //# sourceMappingURL=tool-contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-contracts.d.ts","sourceRoot":"","sources":["../src/tool-contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA0GxB,eAAO,MAAM,iBAAiB;aAC7B,aAAa;;;;;;;;;;;;aACb,mBAAmB;;;;;;;;;;;aACnB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAed,aAAa;;;;;;;;;;;;;aACb,WAAW;;;;;;;;;;;;;;;;;;;;;aAgBX,eAAe;;;;;;;;;;;;;aACf,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAgBb,UAAU;;;;;;;;;;;aACV,uBAAuB;;;;;;;;;;;;;aACvB,eAAe;;;aACf,aAAa;;;aACb,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAgCzB,aAAa;;;;;;aAMb,YAAY;;;;;;;;;;;;;;;;;;;;;CASH,CAAC;AAeX,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAY1B,YAAY;iBACZ,eAAe;iBACf,cAAc;iBACd,aAAa;;;iBAIb,YAAY;iBACZ,eAAe;iBACf,cAAc;iBACd,aAAa;;;;;;;;;;;;;;CAK6D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"distill.d.ts","sourceRoot":"","sources":["../../src/tools/distill.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AA6DlE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAqF9F"}
1
+ {"version":3,"file":"distill.d.ts","sourceRoot":"","sources":["../../src/tools/distill.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AA4FlE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CA8D9F"}
@@ -1 +1 @@
1
- {"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../src/tools/items.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAYzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAgH3F"}
1
+ {"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../src/tools/items.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAYzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAoJlE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAK3F"}
@@ -1 +1 @@
1
- {"version":3,"file":"learn.d.ts","sourceRoot":"","sources":["../../src/tools/learn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA0F1D"}
1
+ {"version":3,"file":"learn.d.ts","sourceRoot":"","sources":["../../src/tools/learn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA2FzE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAW1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/tools/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAwB3D"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/tools/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4B3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAkO7F"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAqDlE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAiN7F"}
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/tools/timeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAiN/F"}
1
+ {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/tools/timeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAsBlE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CA0M/F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemem/mcp",
3
- "version": "0.44.1",
3
+ "version": "0.44.2",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -27,7 +27,7 @@
27
27
  "dist/"
28
28
  ],
29
29
  "dependencies": {
30
- "@codemem/core": "^0.44.1",
30
+ "@codemem/core": "^0.44.2",
31
31
  "@modelcontextprotocol/sdk": "^1.30.0",
32
32
  "express": "^5.2.1",
33
33
  "express-rate-limit": "^8.7.0",