jeopi-mnemopi 16.2.13

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 (135) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/README.md +107 -0
  3. package/dist/types/cli.d.ts +35 -0
  4. package/dist/types/config.d.ts +108 -0
  5. package/dist/types/core/aaak.d.ts +55 -0
  6. package/dist/types/core/annotations.d.ts +75 -0
  7. package/dist/types/core/banks.d.ts +33 -0
  8. package/dist/types/core/beam/consolidate.d.ts +32 -0
  9. package/dist/types/core/beam/helpers.d.ts +69 -0
  10. package/dist/types/core/beam/index.d.ts +59 -0
  11. package/dist/types/core/beam/recall.d.ts +32 -0
  12. package/dist/types/core/beam/schema.d.ts +2 -0
  13. package/dist/types/core/beam/store.d.ts +56 -0
  14. package/dist/types/core/beam/types.d.ts +245 -0
  15. package/dist/types/core/binary-vectors.d.ts +54 -0
  16. package/dist/types/core/chat-normalize.d.ts +13 -0
  17. package/dist/types/core/content-sanitizer.d.ts +18 -0
  18. package/dist/types/core/cost-log.d.ts +13 -0
  19. package/dist/types/core/embeddings.d.ts +54 -0
  20. package/dist/types/core/entities.d.ts +9 -0
  21. package/dist/types/core/episodic-graph.d.ts +89 -0
  22. package/dist/types/core/extraction/client.d.ts +35 -0
  23. package/dist/types/core/extraction/diagnostics.d.ts +51 -0
  24. package/dist/types/core/extraction/prompts.d.ts +2 -0
  25. package/dist/types/core/extraction.d.ts +7 -0
  26. package/dist/types/core/fastembed-model-cache.d.ts +2 -0
  27. package/dist/types/core/fastembed-runtime.d.ts +14 -0
  28. package/dist/types/core/index.d.ts +6 -0
  29. package/dist/types/core/llm-backends.d.ts +23 -0
  30. package/dist/types/core/local-llm.d.ts +20 -0
  31. package/dist/types/core/memory.d.ts +178 -0
  32. package/dist/types/core/migrations/e6-triplestore-split.d.ts +17 -0
  33. package/dist/types/core/migrations/index.d.ts +1 -0
  34. package/dist/types/core/mmr.d.ts +8 -0
  35. package/dist/types/core/orchestrator.d.ts +20 -0
  36. package/dist/types/core/patterns.d.ts +61 -0
  37. package/dist/types/core/plugins.d.ts +109 -0
  38. package/dist/types/core/polyphonic-recall.d.ts +66 -0
  39. package/dist/types/core/query-cache.d.ts +45 -0
  40. package/dist/types/core/query-intent.d.ts +20 -0
  41. package/dist/types/core/recall-diagnostics.d.ts +48 -0
  42. package/dist/types/core/runtime-options.d.ts +76 -0
  43. package/dist/types/core/shmr.d.ts +62 -0
  44. package/dist/types/core/streaming.d.ts +136 -0
  45. package/dist/types/core/synonyms.d.ts +46 -0
  46. package/dist/types/core/temporal-parser.d.ts +16 -0
  47. package/dist/types/core/token-counter.d.ts +8 -0
  48. package/dist/types/core/triples.d.ts +63 -0
  49. package/dist/types/core/typed-memory.d.ts +39 -0
  50. package/dist/types/core/vector-index.d.ts +16 -0
  51. package/dist/types/core/vector-math.d.ts +1 -0
  52. package/dist/types/core/veracity-consolidation.d.ts +60 -0
  53. package/dist/types/core/weibull.d.ts +96 -0
  54. package/dist/types/db.d.ts +16 -0
  55. package/dist/types/diagnose.d.ts +24 -0
  56. package/dist/types/dr/index.d.ts +1 -0
  57. package/dist/types/dr/recovery.d.ts +68 -0
  58. package/dist/types/index.d.ts +6 -0
  59. package/dist/types/mcp-server.d.ts +40 -0
  60. package/dist/types/mcp-tools.d.ts +484 -0
  61. package/dist/types/migrations/e6-triplestore-split.d.ts +1 -0
  62. package/dist/types/migrations/index.d.ts +1 -0
  63. package/dist/types/types.d.ts +145 -0
  64. package/dist/types/util/datetime.d.ts +8 -0
  65. package/dist/types/util/env.d.ts +10 -0
  66. package/dist/types/util/ids.d.ts +3 -0
  67. package/dist/types/util/lru.d.ts +12 -0
  68. package/dist/types/util/regex.d.ts +11 -0
  69. package/package.json +108 -0
  70. package/src/cli.ts +398 -0
  71. package/src/config.ts +373 -0
  72. package/src/core/aaak.ts +142 -0
  73. package/src/core/annotations.ts +457 -0
  74. package/src/core/banks.ts +133 -0
  75. package/src/core/beam/consolidate.ts +1068 -0
  76. package/src/core/beam/helpers.ts +831 -0
  77. package/src/core/beam/index.ts +358 -0
  78. package/src/core/beam/recall.ts +1173 -0
  79. package/src/core/beam/schema.ts +423 -0
  80. package/src/core/beam/store.ts +936 -0
  81. package/src/core/beam/types.ts +280 -0
  82. package/src/core/binary-vectors.ts +317 -0
  83. package/src/core/chat-normalize.ts +160 -0
  84. package/src/core/content-sanitizer.ts +136 -0
  85. package/src/core/cost-log.ts +103 -0
  86. package/src/core/embeddings.ts +531 -0
  87. package/src/core/entities.ts +263 -0
  88. package/src/core/episodic-graph.ts +708 -0
  89. package/src/core/extraction/client.ts +187 -0
  90. package/src/core/extraction/diagnostics.ts +193 -0
  91. package/src/core/extraction/prompts.ts +31 -0
  92. package/src/core/extraction.ts +338 -0
  93. package/src/core/fastembed-model-cache.ts +39 -0
  94. package/src/core/fastembed-runtime.ts +108 -0
  95. package/src/core/index.ts +38 -0
  96. package/src/core/llm-backends.ts +54 -0
  97. package/src/core/local-llm.ts +474 -0
  98. package/src/core/memory.ts +667 -0
  99. package/src/core/migrations/e6-triplestore-split.ts +211 -0
  100. package/src/core/migrations/index.ts +1 -0
  101. package/src/core/mmr.ts +71 -0
  102. package/src/core/orchestrator.ts +62 -0
  103. package/src/core/patterns.ts +484 -0
  104. package/src/core/plugins.ts +375 -0
  105. package/src/core/polyphonic-recall.ts +563 -0
  106. package/src/core/query-cache.ts +353 -0
  107. package/src/core/query-intent.ts +139 -0
  108. package/src/core/recall-diagnostics.ts +157 -0
  109. package/src/core/runtime-options.ts +130 -0
  110. package/src/core/shmr.ts +560 -0
  111. package/src/core/streaming.ts +419 -0
  112. package/src/core/synonyms.ts +197 -0
  113. package/src/core/temporal-parser.ts +363 -0
  114. package/src/core/token-counter.ts +30 -0
  115. package/src/core/triples.ts +452 -0
  116. package/src/core/typed-memory.ts +407 -0
  117. package/src/core/vector-index.ts +84 -0
  118. package/src/core/vector-math.ts +23 -0
  119. package/src/core/veracity-consolidation.ts +477 -0
  120. package/src/core/weibull.ts +124 -0
  121. package/src/db.ts +128 -0
  122. package/src/diagnose.ts +174 -0
  123. package/src/dr/index.ts +1 -0
  124. package/src/dr/recovery.ts +405 -0
  125. package/src/index.ts +33 -0
  126. package/src/mcp-server.ts +155 -0
  127. package/src/mcp-tools.ts +970 -0
  128. package/src/migrations/e6-triplestore-split.ts +1 -0
  129. package/src/migrations/index.ts +1 -0
  130. package/src/types.ts +157 -0
  131. package/src/util/datetime.ts +69 -0
  132. package/src/util/env.ts +65 -0
  133. package/src/util/ids.ts +19 -0
  134. package/src/util/lru.ts +48 -0
  135. package/src/util/regex.ts +165 -0
@@ -0,0 +1,60 @@
1
+ import type { Database } from "bun:sqlite";
2
+ import { type DatabasePath } from "../db";
3
+ export declare const VERACITY_WEIGHTS: Readonly<{
4
+ stated: 1;
5
+ inferred: 0.7;
6
+ tool: 0.5;
7
+ imported: 0.6;
8
+ unknown: 0.8;
9
+ }>;
10
+ export type Veracity = keyof typeof VERACITY_WEIGHTS;
11
+ export declare const VERACITY_ALLOWED: Record<Veracity, true>;
12
+ export interface ConsolidatedFact {
13
+ readonly subject: string;
14
+ readonly predicate: string;
15
+ readonly object: string;
16
+ readonly confidence: number;
17
+ readonly mention_count: number;
18
+ readonly first_seen: string | null;
19
+ readonly last_seen: string | null;
20
+ readonly sources: string[];
21
+ readonly veracity: string;
22
+ readonly superseded: boolean;
23
+ readonly id: string | null;
24
+ }
25
+ export interface Conflict {
26
+ readonly id: number;
27
+ readonly fact_a_id: string;
28
+ readonly fact_b_id: string;
29
+ readonly type: string | null;
30
+ readonly created_at: string | null;
31
+ }
32
+ export interface ConsolidationStats {
33
+ readonly active_facts: number;
34
+ readonly superseded_facts: number;
35
+ readonly unresolved_conflicts: number;
36
+ readonly avg_confidence: number;
37
+ readonly avg_mentions: number;
38
+ }
39
+ export declare function computeFactId(subject: string, predicate: string, object: string): string;
40
+ export declare function clampVeracity(raw: unknown, context?: string): Veracity;
41
+ export declare function aggregateVeracity(sourceVeracities: readonly string[] | null | undefined): Veracity;
42
+ export declare class VeracityConsolidator {
43
+ readonly conn: Database;
44
+ readonly dbPath: DatabasePath;
45
+ readonly ownsConnection: boolean;
46
+ constructor(dbPath?: DatabasePath, conn?: Database);
47
+ initTables(): void;
48
+ serializedWrite<T>(body: () => T): T;
49
+ bayesianUpdate(currentConfidence: number, veracity: string): number;
50
+ consolidateFact(subject: string, predicate: string, object: string, veracity?: string, source?: string | null): ConsolidatedFact;
51
+ recordConflict(factAId: string, factBId: string, conflictType: string, commit?: boolean): void;
52
+ resolveConflict(conflictId: number, winningFactId: string): void;
53
+ getConflicts(): Conflict[];
54
+ getConsolidatedFacts(subject?: string | null, minConfidence?: number): ConsolidatedFact[];
55
+ getHighConfidenceSummary(subject: string, threshold?: number): string;
56
+ runConsolidationPass(): void;
57
+ resolveConflictByFacts(winningId: string, losingId: string): void;
58
+ getStats(): ConsolidationStats;
59
+ close(): void;
60
+ }
@@ -0,0 +1,96 @@
1
+ export type MemoryType = keyof typeof WEIBULL_PARAMS;
2
+ export interface WeibullParams {
3
+ readonly k: number;
4
+ readonly eta: number;
5
+ }
6
+ export declare const WEIBULL_PARAMS: {
7
+ readonly profile: {
8
+ readonly k: 0.3;
9
+ readonly eta: 8760;
10
+ };
11
+ readonly preference: {
12
+ readonly k: 0.4;
13
+ readonly eta: 4380;
14
+ };
15
+ readonly relationship: {
16
+ readonly k: 0.35;
17
+ readonly eta: 8760;
18
+ };
19
+ readonly learning: {
20
+ readonly k: 0.7;
21
+ readonly eta: 1440;
22
+ };
23
+ readonly fact: {
24
+ readonly k: 0.8;
25
+ readonly eta: 720;
26
+ };
27
+ readonly entity: {
28
+ readonly k: 0.5;
29
+ readonly eta: 4380;
30
+ };
31
+ readonly setup: {
32
+ readonly k: 0.6;
33
+ readonly eta: 2160;
34
+ };
35
+ readonly pattern: {
36
+ readonly k: 0.6;
37
+ readonly eta: 1680;
38
+ };
39
+ readonly context: {
40
+ readonly k: 0.85;
41
+ readonly eta: 360;
42
+ };
43
+ readonly observation: {
44
+ readonly k: 0.9;
45
+ readonly eta: 480;
46
+ };
47
+ readonly artifact: {
48
+ readonly k: 0.75;
49
+ readonly eta: 2160;
50
+ };
51
+ readonly project: {
52
+ readonly k: 0.85;
53
+ readonly eta: 1080;
54
+ };
55
+ readonly goal: {
56
+ readonly k: 0.9;
57
+ readonly eta: 720;
58
+ };
59
+ readonly decision: {
60
+ readonly k: 1;
61
+ readonly eta: 336;
62
+ };
63
+ readonly commitment: {
64
+ readonly k: 1;
65
+ readonly eta: 240;
66
+ };
67
+ readonly event: {
68
+ readonly k: 1.2;
69
+ readonly eta: 168;
70
+ };
71
+ readonly instruction: {
72
+ readonly k: 0.9;
73
+ readonly eta: 480;
74
+ };
75
+ readonly error: {
76
+ readonly k: 1.1;
77
+ readonly eta: 336;
78
+ };
79
+ readonly issue: {
80
+ readonly k: 1.1;
81
+ readonly eta: 336;
82
+ };
83
+ readonly request: {
84
+ readonly k: 1.5;
85
+ readonly eta: 72;
86
+ };
87
+ readonly general: {
88
+ readonly k: 1;
89
+ readonly eta: 168;
90
+ };
91
+ };
92
+ export declare const DEFAULT_HALFLIFE_HOURS = 168;
93
+ type TimestampInput = string | Date | null | undefined;
94
+ export declare function weibullBoost(timestamp: TimestampInput, queryTime?: Date | null, memoryType?: string, halflifeHours?: number | null): number;
95
+ export declare function weibullDecayFactor(ageHours: number, memoryType?: string): number;
96
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Database } from "bun:sqlite";
2
+ export type DatabasePath = string | ":memory:";
3
+ export interface OpenDatabaseOptions {
4
+ readonly create?: boolean;
5
+ readonly readwrite?: boolean;
6
+ readonly strict?: boolean;
7
+ readonly loadExtension?: string | readonly string[];
8
+ readonly pragmas?: boolean;
9
+ }
10
+ export declare function openDatabase(path?: DatabasePath, options?: OpenDatabaseOptions): Database;
11
+ export declare function enablePragmas(db: Database, path?: DatabasePath): void;
12
+ export declare function loadExtensions(db: Database, extensions: string | readonly string[]): void;
13
+ export declare function transaction<T>(db: Database, fn: () => T): T;
14
+ export declare const deferredTransaction: typeof transaction;
15
+ export declare function transactionAsync<T>(db: Database, fn: () => Promise<T>): Promise<T>;
16
+ export declare function closeQuietly(db: Database | undefined | null): void;
@@ -0,0 +1,24 @@
1
+ import type { Database } from "bun:sqlite";
2
+ export interface DiagnosticEntry {
3
+ readonly ts: string;
4
+ readonly category: string;
5
+ readonly check: string;
6
+ readonly status: string;
7
+ readonly detail?: string;
8
+ }
9
+ export interface DiagnosticSummary {
10
+ readonly checks_total: number;
11
+ readonly checks_passed: number;
12
+ readonly checks_failed: number;
13
+ readonly key_findings: string[];
14
+ readonly entries: DiagnosticEntry[];
15
+ readonly database: string;
16
+ }
17
+ export interface DiagnosticOptions {
18
+ readonly db?: Database;
19
+ readonly dbPath?: string;
20
+ readonly dataDir?: string;
21
+ readonly initialize?: boolean;
22
+ }
23
+ export declare function inspectDatabase(options?: DiagnosticOptions): DiagnosticSummary;
24
+ export declare function runDiagnostics(options?: DiagnosticOptions): DiagnosticSummary;
@@ -0,0 +1 @@
1
+ export * from "./recovery";
@@ -0,0 +1,68 @@
1
+ import { type Env } from "../config";
2
+ export interface RecoveryPaths {
3
+ readonly dataDir: string;
4
+ readonly backupDir: string;
5
+ readonly dbPath: string;
6
+ }
7
+ export interface BackupMetadata {
8
+ readonly timestamp: string;
9
+ readonly original_size: number;
10
+ readonly backup_size: number;
11
+ readonly db_checksum: string;
12
+ readonly backup_checksum: string;
13
+ readonly compressed: true;
14
+ }
15
+ export interface BackupResult extends BackupMetadata {
16
+ readonly backup_path: string;
17
+ readonly metadata_path: string;
18
+ }
19
+ export interface RestoreResult {
20
+ readonly restored: true;
21
+ readonly backup_used: string;
22
+ readonly database_path: string;
23
+ readonly integrity_check: boolean;
24
+ }
25
+ export interface EmergencyRestoreResult {
26
+ readonly restored: true;
27
+ readonly backup_used: string;
28
+ readonly attempts: number;
29
+ }
30
+ export interface BackupInfo {
31
+ readonly file: string;
32
+ readonly name: string;
33
+ readonly size: number;
34
+ readonly modified: string;
35
+ readonly metadata?: BackupMetadata;
36
+ }
37
+ export interface RotateBackupsResult {
38
+ readonly total_backups: number;
39
+ readonly kept: number;
40
+ readonly deleted: number;
41
+ readonly deleted_files: string[];
42
+ }
43
+ export interface HealthCheckResult {
44
+ readonly database: {
45
+ readonly exists: boolean;
46
+ readonly valid: boolean;
47
+ readonly path: string;
48
+ readonly message: string;
49
+ };
50
+ readonly backups: {
51
+ readonly total: number;
52
+ readonly latest: string | null;
53
+ readonly directory: string;
54
+ };
55
+ readonly status: "healthy" | "unhealthy";
56
+ }
57
+ export declare function getDefaultPaths(env?: Env): RecoveryPaths;
58
+ export declare function createBackup(dbPath?: string | null, backupDir?: string | null): BackupResult;
59
+ export declare function restoreBackup(backupPath: string, dbPath?: string | null): RestoreResult;
60
+ export declare function emergencyRestore(backupDir?: string | null, dbPath?: string | null): EmergencyRestoreResult;
61
+ export declare function verifyIntegrity(dbPath?: string | null): boolean;
62
+ export declare function listBackups(backupDir?: string | null): BackupInfo[];
63
+ export declare function rotateBackups(backupDir?: string | null, keep?: number): RotateBackupsResult;
64
+ export declare function healthCheck(): HealthCheckResult;
65
+ export declare class FileNotFoundError extends Error {
66
+ constructor(message: string);
67
+ }
68
+ export declare function resetRecoveryForTests(): void;
@@ -0,0 +1,6 @@
1
+ export { configureRecallFeatures, type RecallFeatureFlags } from "./config";
2
+ export * from "./core/beam/index";
3
+ export * from "./core/embeddings";
4
+ export * from "./core/llm-backends";
5
+ export * from "./core/memory";
6
+ export { addMemory, flushExtractions, forget, get, getBank, getContext, getDefaultInstance, getStats, Mnemopi, query, recall, recallEnhanced, remember, resetDefaultInstanceForTests, resetMemoryForTests, resetModuleStateForTests, saveMemory, scratchpadClear, scratchpadRead, scratchpadWrite, search, setBank, sleep, sleepAllSessions, storeMemory, update, } from "./core/memory";
@@ -0,0 +1,40 @@
1
+ import { type ToolArguments, type ToolDefinition } from "./mcp-tools";
2
+ export interface JsonRpcRequest {
3
+ readonly jsonrpc?: string;
4
+ readonly id?: string | number | null;
5
+ readonly method?: string;
6
+ readonly params?: Record<string, unknown>;
7
+ }
8
+ export interface JsonRpcResponse {
9
+ readonly jsonrpc: "2.0";
10
+ readonly id: string | number | null;
11
+ readonly result?: unknown;
12
+ readonly error?: {
13
+ readonly code: number;
14
+ readonly message: string;
15
+ };
16
+ }
17
+ export interface ListToolsResponse {
18
+ readonly tools: readonly ToolDefinition[];
19
+ }
20
+ export interface CallToolContent {
21
+ readonly type: "text";
22
+ readonly text: string;
23
+ }
24
+ export interface CallToolResponse {
25
+ readonly content: readonly CallToolContent[];
26
+ readonly isError?: boolean;
27
+ }
28
+ export interface WritableOutput {
29
+ write(chunk: string): unknown;
30
+ }
31
+ export declare function listToolsJson(): ListToolsResponse;
32
+ export declare function callToolJson(name: string, args?: ToolArguments): Promise<CallToolResponse>;
33
+ export declare function handleJsonRpc(request: JsonRpcRequest): Promise<JsonRpcResponse | null>;
34
+ export declare function runStdio(input?: ReadableStream<Uint8Array>, output?: WritableOutput): Promise<void>;
35
+ export declare function runMcpServer(transport?: string, options?: {
36
+ port?: number;
37
+ bank?: string;
38
+ host?: string;
39
+ }): Promise<void>;
40
+ export declare function main(argv?: readonly string[]): Promise<void>;