@hasna/mementos 0.11.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/cli/brains.d.ts +3 -0
  2. package/dist/cli/brains.d.ts.map +1 -0
  3. package/dist/cli/index.js +2104 -495
  4. package/dist/db/database.d.ts.map +1 -1
  5. package/dist/db/memories.d.ts.map +1 -1
  6. package/dist/db/tool-events.d.ts +27 -0
  7. package/dist/db/tool-events.d.ts.map +1 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +221 -4
  11. package/dist/lib/activation-matcher.d.ts +16 -0
  12. package/dist/lib/activation-matcher.d.ts.map +1 -0
  13. package/dist/lib/asmr/categorizer.d.ts +31 -0
  14. package/dist/lib/asmr/categorizer.d.ts.map +1 -0
  15. package/dist/lib/asmr/context-agent.d.ts +4 -0
  16. package/dist/lib/asmr/context-agent.d.ts.map +1 -0
  17. package/dist/lib/asmr/ensemble.d.ts +23 -0
  18. package/dist/lib/asmr/ensemble.d.ts.map +1 -0
  19. package/dist/lib/asmr/fact-agent.d.ts +4 -0
  20. package/dist/lib/asmr/fact-agent.d.ts.map +1 -0
  21. package/dist/lib/asmr/index.d.ts +7 -0
  22. package/dist/lib/asmr/index.d.ts.map +1 -0
  23. package/dist/lib/asmr/orchestrator.d.ts +4 -0
  24. package/dist/lib/asmr/orchestrator.d.ts.map +1 -0
  25. package/dist/lib/asmr/temporal-agent.d.ts +4 -0
  26. package/dist/lib/asmr/temporal-agent.d.ts.map +1 -0
  27. package/dist/lib/asmr/types.d.ts +27 -0
  28. package/dist/lib/asmr/types.d.ts.map +1 -0
  29. package/dist/lib/auto-inject-orchestrator.d.ts +57 -0
  30. package/dist/lib/auto-inject-orchestrator.d.ts.map +1 -0
  31. package/dist/lib/built-in-hooks.d.ts.map +1 -1
  32. package/dist/lib/channel-pusher.d.ts +39 -0
  33. package/dist/lib/channel-pusher.d.ts.map +1 -0
  34. package/dist/lib/connectors/files.d.ts +8 -0
  35. package/dist/lib/connectors/files.d.ts.map +1 -0
  36. package/dist/lib/connectors/github.d.ts +7 -0
  37. package/dist/lib/connectors/github.d.ts.map +1 -0
  38. package/dist/lib/connectors/index.d.ts +12 -0
  39. package/dist/lib/connectors/index.d.ts.map +1 -0
  40. package/dist/lib/connectors/notion.d.ts +7 -0
  41. package/dist/lib/connectors/notion.d.ts.map +1 -0
  42. package/dist/lib/connectors/types.d.ts +27 -0
  43. package/dist/lib/connectors/types.d.ts.map +1 -0
  44. package/dist/lib/context-extractor.d.ts +14 -0
  45. package/dist/lib/context-extractor.d.ts.map +1 -0
  46. package/dist/lib/extractors/audio.d.ts +8 -0
  47. package/dist/lib/extractors/audio.d.ts.map +1 -0
  48. package/dist/lib/extractors/index.d.ts +12 -0
  49. package/dist/lib/extractors/index.d.ts.map +1 -0
  50. package/dist/lib/extractors/ocr.d.ts +7 -0
  51. package/dist/lib/extractors/ocr.d.ts.map +1 -0
  52. package/dist/lib/extractors/pdf.d.ts +7 -0
  53. package/dist/lib/extractors/pdf.d.ts.map +1 -0
  54. package/dist/lib/extractors/types.d.ts +12 -0
  55. package/dist/lib/extractors/types.d.ts.map +1 -0
  56. package/dist/lib/gatherer.d.ts +16 -0
  57. package/dist/lib/gatherer.d.ts.map +1 -0
  58. package/dist/lib/injector.d.ts +48 -1
  59. package/dist/lib/injector.d.ts.map +1 -1
  60. package/dist/lib/matryoshka.d.ts +50 -0
  61. package/dist/lib/matryoshka.d.ts.map +1 -0
  62. package/dist/lib/model-config.d.ts +14 -0
  63. package/dist/lib/model-config.d.ts.map +1 -0
  64. package/dist/lib/procedural-extractor.d.ts +21 -0
  65. package/dist/lib/procedural-extractor.d.ts.map +1 -0
  66. package/dist/lib/profile-synthesizer.d.ts +20 -0
  67. package/dist/lib/profile-synthesizer.d.ts.map +1 -0
  68. package/dist/lib/session-processor.d.ts.map +1 -1
  69. package/dist/lib/session-registry.d.ts +47 -0
  70. package/dist/lib/session-registry.d.ts.map +1 -0
  71. package/dist/lib/session-start-briefing.d.ts +10 -0
  72. package/dist/lib/session-start-briefing.d.ts.map +1 -0
  73. package/dist/lib/session-watcher.d.ts +30 -0
  74. package/dist/lib/session-watcher.d.ts.map +1 -0
  75. package/dist/lib/tool-lesson-extractor.d.ts +24 -0
  76. package/dist/lib/tool-lesson-extractor.d.ts.map +1 -0
  77. package/dist/lib/tool-memory-synthesizer.d.ts +28 -0
  78. package/dist/lib/tool-memory-synthesizer.d.ts.map +1 -0
  79. package/dist/lib/topic-clusterer.d.ts +21 -0
  80. package/dist/lib/topic-clusterer.d.ts.map +1 -0
  81. package/dist/lib/when-to-use-generator.d.ts +22 -0
  82. package/dist/lib/when-to-use-generator.d.ts.map +1 -0
  83. package/dist/mcp/index.d.ts +3 -1
  84. package/dist/mcp/index.d.ts.map +1 -1
  85. package/dist/mcp/index.js +3912 -430
  86. package/dist/server/index.d.ts.map +1 -1
  87. package/dist/server/index.js +922 -5
  88. package/dist/types/index.d.ts +57 -0
  89. package/dist/types/index.d.ts.map +1 -1
  90. package/package.json +3 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Channel Pusher — pushes memory notifications into the Claude Code conversation
3
+ * via the experimental claude/channel MCP notification protocol.
4
+ *
5
+ * Requires: --dangerously-load-development-channels server:mementos
6
+ */
7
+ import type { Memory } from "../types/index.js";
8
+ export declare function setServerRef(server: any): void;
9
+ export declare function hasChannelCapability(): boolean;
10
+ /**
11
+ * Push a formatted memory notification into the conversation.
12
+ */
13
+ export declare function pushMemoryNotification(memories: Memory[], context: string, type?: "auto-inject" | "session-briefing" | "alert"): Promise<boolean>;
14
+ /**
15
+ * Push raw text as a channel notification.
16
+ */
17
+ export declare function pushRawNotification(text: string, type?: string): Promise<boolean>;
18
+ /**
19
+ * Push to a specific agent by name.
20
+ * Finds their session PID and pushes if they have mementos MCP loaded.
21
+ */
22
+ export declare function pushToAgent(agentName: string, content: string, type?: string): Promise<boolean>;
23
+ /**
24
+ * Push to all sessions in a project.
25
+ * Returns count of sessions pushed to.
26
+ */
27
+ export declare function pushToProject(projectName: string, content: string, type?: string): Promise<number>;
28
+ /**
29
+ * Push to all known sessions.
30
+ */
31
+ export declare function pushToAll(content: string, type?: string): Promise<number>;
32
+ export declare function formatBriefing(sections: {
33
+ profile?: string;
34
+ memories?: Memory[];
35
+ lastSession?: string;
36
+ flagged?: Memory[];
37
+ projectName?: string;
38
+ }): string;
39
+ //# sourceMappingURL=channel-pusher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-pusher.d.ts","sourceRoot":"","sources":["../../src/lib/channel-pusher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKhD,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAE9C;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,aAAa,GAAG,kBAAkB,GAAG,OAAuB,GACjE,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAe,GACpB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AA0BD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAOjH;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAWrH;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAI5F;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CA8BT"}
@@ -0,0 +1,8 @@
1
+ import { Database } from "bun:sqlite";
2
+ import type { ConnectorSyncResult, FilesConnectorConfig } from "./types.js";
3
+ /**
4
+ * Sync local files from configured paths into mementos memories.
5
+ * Tracks file mtime — only re-syncs when the file has been modified.
6
+ */
7
+ export declare function syncFiles(db: Database, projectId: string, config: FilesConnectorConfig): Promise<ConnectorSyncResult>;
8
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/files.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA6C5E;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,mBAAmB,CAAC,CAmG9B"}
@@ -0,0 +1,7 @@
1
+ import { Database } from "bun:sqlite";
2
+ import type { ConnectorSyncResult, GitHubConnectorConfig } from "./types.js";
3
+ /**
4
+ * Sync GitHub issues, PRs, and/or discussions into mementos memories.
5
+ */
6
+ export declare function syncGithub(db: Database, projectId: string, config: GitHubConnectorConfig): Promise<ConnectorSyncResult>;
7
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/github.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AA2C7E;;GAEG;AACH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CA6F9B"}
@@ -0,0 +1,12 @@
1
+ import { Database } from "bun:sqlite";
2
+ import type { ConnectorConfig, ConnectorSyncResult } from "./types.js";
3
+ export type { ConnectorConfig, ConnectorSyncResult, ConnectorType, GitHubConnectorConfig, NotionConnectorConfig, FilesConnectorConfig, } from "./types.js";
4
+ export { syncGithub } from "./github.js";
5
+ export { syncNotion } from "./notion.js";
6
+ export { syncFiles } from "./files.js";
7
+ /**
8
+ * Dispatch a sync operation to the correct connector based on config.type.
9
+ * Returns a ConnectorSyncResult with counts and any errors encountered.
10
+ */
11
+ export declare function syncConnector(db: Database, projectId: string, config: ConnectorConfig): Promise<ConnectorSyncResult>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EAIpB,MAAM,YAAY,CAAC;AAKpB,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,mBAAmB,CAAC,CA4B9B"}
@@ -0,0 +1,7 @@
1
+ import { Database } from "bun:sqlite";
2
+ import type { ConnectorSyncResult, NotionConnectorConfig } from "./types.js";
3
+ /**
4
+ * Sync Notion pages into mementos memories.
5
+ */
6
+ export declare function syncNotion(db: Database, projectId: string, config: NotionConnectorConfig): Promise<ConnectorSyncResult>;
7
+ //# sourceMappingURL=notion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notion.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/notion.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAiC7E;;GAEG;AACH,wBAAsB,UAAU,CAC9B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CA4G9B"}
@@ -0,0 +1,27 @@
1
+ export type ConnectorType = "github" | "notion" | "files";
2
+ export interface ConnectorConfig {
3
+ type: ConnectorType;
4
+ enabled: boolean;
5
+ config: Record<string, unknown>;
6
+ last_sync?: string;
7
+ }
8
+ export interface ConnectorSyncResult {
9
+ memories_created: number;
10
+ memories_updated: number;
11
+ errors: string[];
12
+ duration_ms: number;
13
+ }
14
+ export interface GitHubConnectorConfig {
15
+ owner: string;
16
+ repo: string;
17
+ types?: Array<"issues" | "prs" | "discussions">;
18
+ }
19
+ export interface NotionConnectorConfig {
20
+ database_id?: string;
21
+ page_ids?: string[];
22
+ }
23
+ export interface FilesConnectorConfig {
24
+ paths: string[];
25
+ extensions?: string[];
26
+ }
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/connectors/types.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,KAAK,GAAG,aAAa,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Context Extractor — parses session messages and extracts meaningful
3
+ * context strings for memory activation matching.
4
+ */
5
+ import type { SessionMessage } from "./session-watcher.js";
6
+ export interface ExtractedContext {
7
+ context_text: string;
8
+ tools_mentioned: string[];
9
+ is_significant: boolean;
10
+ source: "user" | "assistant" | "tool_result" | "tool_use";
11
+ }
12
+ export declare function extractContext(message: SessionMessage): ExtractedContext;
13
+ export declare function resetContext(): void;
14
+ //# sourceMappingURL=context-extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-extractor.d.ts","sourceRoot":"","sources":["../../src/lib/context-extractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC;CAC3D;AAmDD,wBAAgB,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB,CAmExE;AAED,wBAAgB,YAAY,IAAI,IAAI,CAEnC"}
@@ -0,0 +1,8 @@
1
+ import type { ExtractionResult } from "./types.js";
2
+ /**
3
+ * Transcribe an audio file using the OpenAI Whisper API.
4
+ * Requires the OPENAI_API_KEY environment variable.
5
+ * Returns empty result on failure — never throws.
6
+ */
7
+ export declare function transcribeAudio(filePath: string): Promise<ExtractionResult>;
8
+ //# sourceMappingURL=audio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/audio.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqBnD;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2EjF"}
@@ -0,0 +1,12 @@
1
+ import type { ExtractionResult } from "./types.js";
2
+ export type { ExtractionResult } from "./types.js";
3
+ export { emptyResult } from "./types.js";
4
+ export { extractPdf } from "./pdf.js";
5
+ export { extractImage } from "./ocr.js";
6
+ export { transcribeAudio } from "./audio.js";
7
+ /**
8
+ * Auto-detect file type by extension and route to the correct extractor.
9
+ * Returns an empty result for unsupported file types — never throws.
10
+ */
11
+ export declare function extractFile(filePath: string): Promise<ExtractionResult>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAa7C;;;GAGG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoB7E"}
@@ -0,0 +1,7 @@
1
+ import type { ExtractionResult } from "./types.js";
2
+ /**
3
+ * Extract text from an image file using Tesseract.js OCR.
4
+ * Returns empty result on failure — never throws.
5
+ */
6
+ export declare function extractImage(filePath: string): Promise<ExtractionResult>;
7
+ //# sourceMappingURL=ocr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ocr.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/ocr.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2B9E"}
@@ -0,0 +1,7 @@
1
+ import type { ExtractionResult } from "./types.js";
2
+ /**
3
+ * Extract text from a PDF file using pdf-parse.
4
+ * Returns empty result on failure — never throws.
5
+ */
6
+ export declare function extractPdf(filePath: string): Promise<ExtractionResult>;
7
+ //# sourceMappingURL=pdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/pdf.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;GAGG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2B5E"}
@@ -0,0 +1,12 @@
1
+ export interface ExtractionResult {
2
+ text: string;
3
+ metadata: Record<string, unknown>;
4
+ pages?: number;
5
+ confidence?: number;
6
+ }
7
+ /**
8
+ * Returns an empty extraction result — used as a safe fallback when
9
+ * extraction fails or the file type is unsupported.
10
+ */
11
+ export declare function emptyResult(metadata?: Record<string, unknown>): ExtractionResult;
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAMhF"}
@@ -0,0 +1,16 @@
1
+ type GatherTrainingDataFn = (options?: {
2
+ limit?: number;
3
+ since?: Date;
4
+ }) => Promise<{
5
+ source: string;
6
+ examples: Array<{
7
+ messages: Array<{
8
+ role: "system" | "user" | "assistant";
9
+ content: string;
10
+ }>;
11
+ }>;
12
+ count: number;
13
+ }>;
14
+ export declare const gatherTrainingData: GatherTrainingDataFn;
15
+ export {};
16
+ //# sourceMappingURL=gatherer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gatherer.d.ts","sourceRoot":"","sources":["../../src/lib/gatherer.ts"],"names":[],"mappings":"AAMA,KAAK,oBAAoB,GAAG,CAAC,OAAO,CAAC,EAAE;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,IAAI,CAAC;CACd,KAAK,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC7E,CAAC,CAAC;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAyEH,eAAO,MAAM,kBAAkB,EAAE,oBAgDhC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Database } from "bun:sqlite";
2
2
  import type { MemoryCategory, MementosConfig } from "../types/index.js";
3
- export type InjectionStrategy = "default" | "smart";
3
+ export type InjectionStrategy = "default" | "smart" | "smart-pipeline";
4
4
  export interface InjectionOptions {
5
5
  agent_id?: string;
6
6
  project_id?: string;
@@ -12,6 +12,37 @@ export interface InjectionOptions {
12
12
  query?: string;
13
13
  db?: Database;
14
14
  }
15
+ export interface SmartInjectionOptions {
16
+ /** Free-text description of what the agent is currently doing */
17
+ task_context: string;
18
+ /** Project to scope memories to */
19
+ project_id?: string;
20
+ /** Agent to scope private memories to */
21
+ agent_id?: string;
22
+ /** Session for working memory */
23
+ session_id?: string;
24
+ /** Max tokens for the entire output (~4 chars/token) */
25
+ max_tokens?: number;
26
+ /** Minimum importance threshold (before decay) */
27
+ min_importance?: number;
28
+ /** Force profile resynthesis even if cached */
29
+ force_profile_refresh?: boolean;
30
+ /** Optional DB handle */
31
+ db?: Database;
32
+ }
33
+ /** Structured result from the smart injection pipeline */
34
+ export interface SmartInjectionResult {
35
+ /** Formatted markdown string ready for system prompt */
36
+ output: string;
37
+ /** Token estimate of the output */
38
+ token_estimate: number;
39
+ /** Number of memories included */
40
+ memory_count: number;
41
+ /** Whether the profile was loaded from cache */
42
+ profile_from_cache: boolean;
43
+ /** Tool names detected in task_context */
44
+ detected_tools: string[];
45
+ }
15
46
  export declare class MemoryInjector {
16
47
  private config;
17
48
  private injectedIds;
@@ -36,4 +67,20 @@ export declare class MemoryInjector {
36
67
  */
37
68
  getInjectedCount(): number;
38
69
  }
70
+ /**
71
+ * Smart injection pipeline — the full-featured context injection strategy.
72
+ *
73
+ * Pipeline stages:
74
+ * 1. Parse task context — accept a task_context string describing what the agent is doing
75
+ * 2. Load or synthesize agent/project profile
76
+ * 3. Activation match — semantic search against task_context when embeddings exist
77
+ * 4. Tool guide retrieval — pull tool stats/lessons if task mentions tools
78
+ * 5. Decay scoring — apply forgetting curve to all candidate memories
79
+ * 6. Layer by type — Profile > Core Facts > Tool Guides > Procedural > Preferences > History
80
+ * 7. Token budgeting — fit into max_tokens, trimming lowest-relevance items first
81
+ *
82
+ * Falls back gracefully: no embeddings -> keyword matching, no profile -> skip section,
83
+ * no tool mentions -> skip tool guides.
84
+ */
85
+ export declare function smartInject(options: SmartInjectionOptions): Promise<SmartInjectionResult>;
39
86
  //# sourceMappingURL=injector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"injector.d.ts","sourceRoot":"","sources":["../../src/lib/injector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAU,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAShF,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,WAAW,CAA0B;gBAEjC,MAAM,CAAC,EAAE,cAAc;IAInC;;;;OAIG;IACH,mBAAmB,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM;IA0L3D;;;OAGG;IACG,wBAAwB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAuL/E;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,gBAAgB,IAAI,MAAM;CAG3B"}
1
+ {"version":3,"file":"injector.d.ts","sourceRoot":"","sources":["../../src/lib/injector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAU,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAYhF,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf;AAMD,MAAM,WAAW,qBAAqB;IACpC,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,yBAAyB;IACzB,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf;AAgBD,0DAA0D;AAC1D,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,kBAAkB,EAAE,OAAO,CAAC;IAC5B,0CAA0C;IAC1C,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,WAAW,CAA0B;gBAEjC,MAAM,CAAC,EAAE,cAAc;IAInC;;;;OAIG;IACH,mBAAmB,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM;IA0L3D;;;OAGG;IACG,wBAAwB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAuL/E;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,gBAAgB,IAAI,MAAM;CAG3B;AAoJD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAyQ/F"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Matryoshka Embedding Slicing — 2-stage retrieval using variable-dimension embedding slices.
3
+ *
4
+ * Key insight: OpenAI text-embedding-3-small supports native dimension reduction.
5
+ * Halving the dimension keeps quality nearly intact, so a 384-dim slice is 4x faster
6
+ * to compare but nearly as accurate for shortlisting. We use this for a 2-stage search:
7
+ * Stage 1: 384-dim slice → fast approximate shortlist (3x limit)
8
+ * Stage 2: Full 1536-dim → precise rerank → top limit results
9
+ */
10
+ import { Database } from "bun:sqlite";
11
+ import type { Memory } from "../types/index.js";
12
+ export interface MatryoshkaConfig {
13
+ /** Full embedding dimensions (1536 for text-embedding-3-small) */
14
+ full_dims: number;
15
+ /** Shortlist slice dimensions (1/4 of full for fast approximate search) */
16
+ shortlist_dims: number;
17
+ /** How many extra candidates to fetch in Stage 1 (multiplier of final limit) */
18
+ shortlist_multiplier: number;
19
+ }
20
+ export interface MatryoshkaSearchResult {
21
+ memory: Memory;
22
+ score: number;
23
+ shortlist_score: number;
24
+ }
25
+ /**
26
+ * Slice an embedding to the first `dims` dimensions.
27
+ * Exploits the Matryoshka property of text-embedding-3-small where
28
+ * leading dimensions carry the most information.
29
+ */
30
+ export declare function sliceEmbedding(embedding: number[], dims: number): number[];
31
+ /**
32
+ * L2 (Euclidean) normalize a vector to unit length.
33
+ * Required after slicing to ensure cosine similarity remains valid.
34
+ */
35
+ export declare function l2Normalize(embedding: number[]): number[];
36
+ /**
37
+ * 2-stage Matryoshka search:
38
+ * 1. Generate query embedding, slice to 384-dim, shortlist top N*3 candidates
39
+ * 2. Rerank shortlisted candidates using full 1536-dim embeddings
40
+ *
41
+ * Returns the top `limit` results ordered by full-dimension similarity.
42
+ */
43
+ export declare function matryoshkaSearch(db: Database, query: string, opts?: {
44
+ limit?: number;
45
+ project_id?: string;
46
+ agent_id?: string;
47
+ config?: MatryoshkaConfig;
48
+ threshold?: number;
49
+ }): Promise<MatryoshkaSearchResult[]>;
50
+ //# sourceMappingURL=matryoshka.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matryoshka.d.ts","sourceRoot":"","sources":["../../src/lib/matryoshka.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,cAAc,EAAE,MAAM,CAAC;IACvB,gFAAgF;IAChF,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;CACzB;AAYD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAG1E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAYzD;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE;IACL,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA+EnC"}
@@ -0,0 +1,14 @@
1
+ export declare const DEFAULT_MODEL = "gpt-4o-mini";
2
+ /**
3
+ * Returns the currently active fine-tuned model ID, or the default model.
4
+ */
5
+ export declare function getActiveModel(): string;
6
+ /**
7
+ * Sets the active fine-tuned model ID in ~/.mementos/config.json.
8
+ */
9
+ export declare function setActiveModel(modelId: string): void;
10
+ /**
11
+ * Clears the active fine-tuned model, reverting to the default.
12
+ */
13
+ export declare function clearActiveModel(): void;
14
+ //# sourceMappingURL=model-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/lib/model-config.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa,gBAAgB,CAAC;AA2B3C;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAGvC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * LLM-based procedural memory extractor from session transcripts.
3
+ * Extracts workflow patterns, step sequences, failure lessons, problem-solution pairs.
4
+ * Saves as chained procedural memories with when_to_use and sequence_group.
5
+ */
6
+ interface ExtractedProcedure {
7
+ title: string;
8
+ steps: {
9
+ action: string;
10
+ when_to_use: string;
11
+ }[];
12
+ failure_patterns: string[];
13
+ when_to_use: string;
14
+ }
15
+ export declare function extractProcedures(transcript: string, options?: {
16
+ agent_id?: string;
17
+ project_id?: string;
18
+ session_id?: string;
19
+ }): Promise<ExtractedProcedure[]>;
20
+ export {};
21
+ //# sourceMappingURL=procedural-extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedural-extractor.d.ts","sourceRoot":"","sources":["../../src/lib/procedural-extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAyF/B"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Profile Synthesizer — aggregates preference and fact memories into a coherent profile.
3
+ * Cached as a special pinned memory, auto-refreshed when preferences change.
4
+ */
5
+ export declare function getProfileKey(scope: string, id: string): string;
6
+ export declare function synthesizeProfile(options: {
7
+ project_id?: string;
8
+ agent_id?: string;
9
+ scope?: "agent" | "project" | "global";
10
+ force_refresh?: boolean;
11
+ }): Promise<{
12
+ profile: string;
13
+ memory_count: number;
14
+ from_cache: boolean;
15
+ } | null>;
16
+ /**
17
+ * Mark profile as stale. Called from PostMemorySave hook when a preference/fact is saved.
18
+ */
19
+ export declare function markProfileStale(projectId?: string, _agentId?: string): void;
20
+ //# sourceMappingURL=profile-synthesizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-synthesizer.d.ts","sourceRoot":"","sources":["../../src/lib/profile-synthesizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;IACvC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC,CA2EjF;AA2BD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAa5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"session-processor.d.ts","sourceRoot":"","sources":["../../src/lib/session-processor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAa3C,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAaD;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,SAAS,SAAO,EAChB,OAAO,SAAM,GACZ,MAAM,EAAE,CAeV;AAMD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,EACD,EAAE,CAAC,EAAE,QAAQ,GACZ,OAAO,CAAC,MAAM,CAAC,CAyHjB;AAMD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,EAAE,CAAC,EAAE,QAAQ,GACZ,OAAO,CAAC,gBAAgB,CAAC,CA+F3B"}
1
+ {"version":3,"file":"session-processor.d.ts","sourceRoot":"","sources":["../../src/lib/session-processor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAe3C,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAaD;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,SAAS,SAAO,EAChB,OAAO,SAAM,GACZ,MAAM,EAAE,CAeV;AAMD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,EACD,EAAE,CAAC,EAAE,QAAQ,GACZ,OAAO,CAAC,MAAM,CAAC,CAyHjB;AAMD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,EAAE,CAAC,EAAE,QAAQ,GACZ,OAAO,CAAC,gBAAgB,CAAC,CAqH3B"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Session Registry — shared registry of active Claude Code sessions.
3
+ * Designed to be reusable across the open-* ecosystem (mementos, todos, conversations).
4
+ *
5
+ * Uses a shared SQLite DB at ~/.open-sessions-registry.db.
6
+ * Each MCP server registers on connect, heartbeats, and can query peers.
7
+ * PID identifies the Claude Code process — all MCPs in same session share a PID.
8
+ */
9
+ export interface SessionInfo {
10
+ id: string;
11
+ pid: number;
12
+ cwd: string;
13
+ git_root: string | null;
14
+ agent_name: string | null;
15
+ project_name: string | null;
16
+ tty: string | null;
17
+ mcp_server: string;
18
+ metadata: Record<string, unknown>;
19
+ registered_at: string;
20
+ last_seen_at: string;
21
+ }
22
+ export interface SessionFilter {
23
+ project_name?: string;
24
+ git_root?: string;
25
+ mcp_server?: string;
26
+ agent_name?: string;
27
+ exclude_pid?: number;
28
+ }
29
+ export declare function registerSession(opts: {
30
+ mcp_server: string;
31
+ agent_name?: string;
32
+ project_name?: string;
33
+ cwd?: string;
34
+ git_root?: string;
35
+ tty?: string;
36
+ metadata?: Record<string, unknown>;
37
+ }): SessionInfo;
38
+ export declare function heartbeatSession(id: string): void;
39
+ export declare function unregisterSession(id: string): void;
40
+ export declare function getSession(id: string): SessionInfo | null;
41
+ export declare function listSessions(filter?: SessionFilter): SessionInfo[];
42
+ export declare function getSessionByAgent(agentName: string): SessionInfo | null;
43
+ export declare function getSessionsByProject(projectName: string): SessionInfo[];
44
+ export declare function cleanStaleSessions(): number;
45
+ export declare function updateSessionAgent(mcpServer: string, agentName: string): void;
46
+ export declare function closeRegistry(): void;
47
+ //# sourceMappingURL=session-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-registry.d.ts","sourceRoot":"","sources":["../../src/lib/session-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAwFD,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,GAAG,WAAW,CA8Cd;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAGjD;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAGlD;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAIzD;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,WAAW,EAAE,CAsClE;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAGvE;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,EAAE,CAEvE;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAW3C;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAO7E;AAMD,wBAAgB,aAAa,IAAI,IAAI,CAKpC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Session Start Briefing — pushes a project memory briefing when a new session begins.
3
+ * Includes: synthesized profile, top memories, last session summary, flagged items.
4
+ */
5
+ export declare function pushSessionBriefing(options: {
6
+ project_id?: string;
7
+ project_name?: string;
8
+ agent_id?: string;
9
+ }): Promise<boolean>;
10
+ //# sourceMappingURL=session-start-briefing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-start-briefing.d.ts","sourceRoot":"","sources":["../../src/lib/session-start-briefing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,CAqFnB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Session Watcher — watches the active Claude Code session JSONL file
3
+ * for new messages. Enables proactive memory injection by detecting
4
+ * what the agent is working on in real-time.
5
+ */
6
+ export interface SessionMessage {
7
+ role: "user" | "assistant" | "tool";
8
+ content: string | {
9
+ type: string;
10
+ text?: string;
11
+ name?: string;
12
+ input?: Record<string, unknown>;
13
+ }[];
14
+ tool_use?: {
15
+ name: string;
16
+ input: Record<string, unknown>;
17
+ }[];
18
+ timestamp: string;
19
+ }
20
+ export type MessageCallback = (message: SessionMessage) => void;
21
+ export declare function startSessionWatcher(cwd: string, callback: MessageCallback): {
22
+ sessionFile: string | null;
23
+ };
24
+ export declare function stopSessionWatcher(): void;
25
+ export declare function getWatcherStatus(): {
26
+ active: boolean;
27
+ watching_file: string | null;
28
+ last_offset: number;
29
+ };
30
+ //# sourceMappingURL=session-watcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-watcher.d.ts","sourceRoot":"","sources":["../../src/lib/session-watcher.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAC;IACpG,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAC;IAC9D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;AA+EhE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG;IAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAiC1G;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAYzC;AAED,wBAAgB,gBAAgB,IAAI;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,CAMA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * LLM-based tool lesson extraction from session transcripts.
3
+ * Analyzes tool call sequences in a session and extracts:
4
+ * - "Tool X works well for Y with params Z"
5
+ * - "Tool X fails when Y because Z, use alternative A"
6
+ * - "For best results with X, set param Y to Z"
7
+ * - "When X returns error Y, solution is Z"
8
+ *
9
+ * Saves both structured tool_events and qualitative memories.
10
+ */
11
+ interface ExtractedLesson {
12
+ tool_name: string;
13
+ lesson: string;
14
+ when_to_use: string;
15
+ success: boolean;
16
+ error_type?: string | null;
17
+ }
18
+ export declare function extractToolLessons(transcript: string, options?: {
19
+ agent_id?: string;
20
+ project_id?: string;
21
+ session_id?: string;
22
+ }): Promise<ExtractedLesson[]>;
23
+ export {};
24
+ //# sourceMappingURL=tool-lesson-extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-lesson-extractor.d.ts","sourceRoot":"","sources":["../../src/lib/tool-lesson-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAwBH,UAAU,eAAe;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IACR,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,eAAe,EAAE,CAAC,CA6E5B"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Tool Memory Synthesizer — periodic LLM consolidation of tool experience.
3
+ * For tools with 10+ events, synthesizes aggregated insights into a single
4
+ * high-importance guide memory. Archives individual low-importance tool memories.
5
+ * ReMe ToolSummarizer equivalent, but runs periodically rather than per-call.
6
+ */
7
+ interface SynthesisResult {
8
+ tool_name: string;
9
+ guide: string;
10
+ when_to_use: string;
11
+ lessons_consolidated: number;
12
+ }
13
+ export declare function synthesizeToolMemory(tool_name: string, options?: {
14
+ project_id?: string;
15
+ agent_id?: string;
16
+ min_events?: number;
17
+ }): Promise<SynthesisResult | null>;
18
+ /**
19
+ * Synthesize guides for all tools with enough events.
20
+ * Intended to be called periodically (e.g., by ALMA scheduler).
21
+ */
22
+ export declare function synthesizeAllToolMemories(options?: {
23
+ project_id?: string;
24
+ agent_id?: string;
25
+ min_events?: number;
26
+ }): Promise<SynthesisResult[]>;
27
+ export {};
28
+ //# sourceMappingURL=tool-memory-synthesizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-memory-synthesizer.d.ts","sourceRoot":"","sources":["../../src/lib/tool-memory-synthesizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,UAAU,eAAe;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoFjC;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,eAAe,EAAE,CAAC,CAY5B"}