mem-os-python 1.6.27__py3-none-any.whl
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.
- mem_os_python-1.6.27.dist-info/METADATA +1032 -0
- mem_os_python-1.6.27.dist-info/RECORD +253 -0
- mem_os_python-1.6.27.dist-info/WHEEL +4 -0
- mem_os_python-1.6.27.dist-info/entry_points.txt +2 -0
- mem_os_python-1.6.27.dist-info/licenses/LICENSE +21 -0
- memos/__init__.py +16 -0
- memos/_js/adapters/anthropic.d.ts +279 -0
- memos/_js/adapters/anthropic.d.ts.map +1 -0
- memos/_js/adapters/anthropic.js +348 -0
- memos/_js/adapters/anthropic.js.map +1 -0
- memos/_js/adapters/base.d.ts +10 -0
- memos/_js/adapters/base.d.ts.map +1 -0
- memos/_js/adapters/base.js +2 -0
- memos/_js/adapters/base.js.map +1 -0
- memos/_js/adapters/openai.d.ts +264 -0
- memos/_js/adapters/openai.d.ts.map +1 -0
- memos/_js/adapters/openai.js +342 -0
- memos/_js/adapters/openai.js.map +1 -0
- memos/_js/apps/explorer.d.ts +244 -0
- memos/_js/apps/explorer.d.ts.map +1 -0
- memos/_js/apps/explorer.js +738 -0
- memos/_js/apps/explorer.js.map +1 -0
- memos/_js/citations.d.ts +65 -0
- memos/_js/citations.d.ts.map +1 -0
- memos/_js/citations.js +143 -0
- memos/_js/citations.js.map +1 -0
- memos/_js/cli-browse.d.ts +3 -0
- memos/_js/cli-browse.d.ts.map +1 -0
- memos/_js/cli-browse.js +129 -0
- memos/_js/cli-browse.js.map +1 -0
- memos/_js/cli-completion.d.ts +31 -0
- memos/_js/cli-completion.d.ts.map +1 -0
- memos/_js/cli-completion.js +340 -0
- memos/_js/cli-completion.js.map +1 -0
- memos/_js/cli-help.d.ts +18 -0
- memos/_js/cli-help.d.ts.map +1 -0
- memos/_js/cli-help.js +357 -0
- memos/_js/cli-help.js.map +1 -0
- memos/_js/cli.d.ts +28 -0
- memos/_js/cli.d.ts.map +1 -0
- memos/_js/cli.js +2880 -0
- memos/_js/cli.js.map +1 -0
- memos/_js/compression.d.ts +25 -0
- memos/_js/compression.d.ts.map +1 -0
- memos/_js/compression.js +319 -0
- memos/_js/compression.js.map +1 -0
- memos/_js/confidence-machine.d.ts +99 -0
- memos/_js/confidence-machine.d.ts.map +1 -0
- memos/_js/confidence-machine.js +222 -0
- memos/_js/confidence-machine.js.map +1 -0
- memos/_js/context-pack.d.ts +506 -0
- memos/_js/context-pack.d.ts.map +1 -0
- memos/_js/context-pack.js +1435 -0
- memos/_js/context-pack.js.map +1 -0
- memos/_js/contradictions.d.ts +160 -0
- memos/_js/contradictions.d.ts.map +1 -0
- memos/_js/contradictions.js +255 -0
- memos/_js/contradictions.js.map +1 -0
- memos/_js/dashboard.d.ts +30 -0
- memos/_js/dashboard.d.ts.map +1 -0
- memos/_js/dashboard.js +302 -0
- memos/_js/dashboard.js.map +1 -0
- memos/_js/ebbinghaus.d.ts +29 -0
- memos/_js/ebbinghaus.d.ts.map +1 -0
- memos/_js/ebbinghaus.js +32 -0
- memos/_js/ebbinghaus.js.map +1 -0
- memos/_js/embedding-queue.d.ts +190 -0
- memos/_js/embedding-queue.d.ts.map +1 -0
- memos/_js/embedding-queue.js +316 -0
- memos/_js/embedding-queue.js.map +1 -0
- memos/_js/embeddings.d.ts +187 -0
- memos/_js/embeddings.d.ts.map +1 -0
- memos/_js/embeddings.js +633 -0
- memos/_js/embeddings.js.map +1 -0
- memos/_js/entity-extraction.d.ts +54 -0
- memos/_js/entity-extraction.d.ts.map +1 -0
- memos/_js/entity-extraction.js +325 -0
- memos/_js/entity-extraction.js.map +1 -0
- memos/_js/entity-index.d.ts +93 -0
- memos/_js/entity-index.d.ts.map +1 -0
- memos/_js/entity-index.js +165 -0
- memos/_js/entity-index.js.map +1 -0
- memos/_js/event-memory.d.ts +147 -0
- memos/_js/event-memory.d.ts.map +1 -0
- memos/_js/event-memory.js +290 -0
- memos/_js/event-memory.js.map +1 -0
- memos/_js/external-import.d.ts +98 -0
- memos/_js/external-import.d.ts.map +1 -0
- memos/_js/external-import.js +669 -0
- memos/_js/external-import.js.map +1 -0
- memos/_js/fidelity.d.ts +367 -0
- memos/_js/fidelity.d.ts.map +1 -0
- memos/_js/fidelity.js +911 -0
- memos/_js/fidelity.js.map +1 -0
- memos/_js/graph-expansion.d.ts +119 -0
- memos/_js/graph-expansion.d.ts.map +1 -0
- memos/_js/graph-expansion.js +213 -0
- memos/_js/graph-expansion.js.map +1 -0
- memos/_js/graph-mermaid.d.ts +13 -0
- memos/_js/graph-mermaid.d.ts.map +1 -0
- memos/_js/graph-mermaid.js +32 -0
- memos/_js/graph-mermaid.js.map +1 -0
- memos/_js/graph.d.ts +170 -0
- memos/_js/graph.d.ts.map +1 -0
- memos/_js/graph.js +482 -0
- memos/_js/graph.js.map +1 -0
- memos/_js/harness.d.ts +63 -0
- memos/_js/harness.d.ts.map +1 -0
- memos/_js/harness.js +93 -0
- memos/_js/harness.js.map +1 -0
- memos/_js/importance.d.ts +118 -0
- memos/_js/importance.d.ts.map +1 -0
- memos/_js/importance.js +144 -0
- memos/_js/importance.js.map +1 -0
- memos/_js/index.d.ts +51 -0
- memos/_js/index.d.ts.map +1 -0
- memos/_js/index.js +53 -0
- memos/_js/index.js.map +1 -0
- memos/_js/mcp.d.ts +58 -0
- memos/_js/mcp.d.ts.map +1 -0
- memos/_js/mcp.js +1853 -0
- memos/_js/mcp.js.map +1 -0
- memos/_js/memory.d.ts +1762 -0
- memos/_js/memory.d.ts.map +1 -0
- memos/_js/memory.js +6283 -0
- memos/_js/memory.js.map +1 -0
- memos/_js/procedural.d.ts +74 -0
- memos/_js/procedural.d.ts.map +1 -0
- memos/_js/procedural.js +125 -0
- memos/_js/procedural.js.map +1 -0
- memos/_js/project-config.d.ts +68 -0
- memos/_js/project-config.d.ts.map +1 -0
- memos/_js/project-config.js +59 -0
- memos/_js/project-config.js.map +1 -0
- memos/_js/proof-of-forgetting.d.ts +57 -0
- memos/_js/proof-of-forgetting.d.ts.map +1 -0
- memos/_js/proof-of-forgetting.js +80 -0
- memos/_js/proof-of-forgetting.js.map +1 -0
- memos/_js/provenance.d.ts +122 -0
- memos/_js/provenance.d.ts.map +1 -0
- memos/_js/provenance.js +182 -0
- memos/_js/provenance.js.map +1 -0
- memos/_js/quarantine-commands.d.ts +23 -0
- memos/_js/quarantine-commands.d.ts.map +1 -0
- memos/_js/quarantine-commands.js +42 -0
- memos/_js/quarantine-commands.js.map +1 -0
- memos/_js/quarantine.d.ts +120 -0
- memos/_js/quarantine.d.ts.map +1 -0
- memos/_js/quarantine.js +873 -0
- memos/_js/quarantine.js.map +1 -0
- memos/_js/redact.d.ts +12 -0
- memos/_js/redact.d.ts.map +1 -0
- memos/_js/redact.js +26 -0
- memos/_js/redact.js.map +1 -0
- memos/_js/repl.d.ts +57 -0
- memos/_js/repl.d.ts.map +1 -0
- memos/_js/repl.js +295 -0
- memos/_js/repl.js.map +1 -0
- memos/_js/rerank-local.d.ts +61 -0
- memos/_js/rerank-local.d.ts.map +1 -0
- memos/_js/rerank-local.js +210 -0
- memos/_js/rerank-local.js.map +1 -0
- memos/_js/retain-filter.d.ts +98 -0
- memos/_js/retain-filter.d.ts.map +1 -0
- memos/_js/retain-filter.js +232 -0
- memos/_js/retain-filter.js.map +1 -0
- memos/_js/retrieval.d.ts +265 -0
- memos/_js/retrieval.d.ts.map +1 -0
- memos/_js/retrieval.js +1018 -0
- memos/_js/retrieval.js.map +1 -0
- memos/_js/revert.d.ts +77 -0
- memos/_js/revert.d.ts.map +1 -0
- memos/_js/revert.js +252 -0
- memos/_js/revert.js.map +1 -0
- memos/_js/scope.d.ts +30 -0
- memos/_js/scope.d.ts.map +1 -0
- memos/_js/scope.js +71 -0
- memos/_js/scope.js.map +1 -0
- memos/_js/semantic-screen.d.ts +152 -0
- memos/_js/semantic-screen.d.ts.map +1 -0
- memos/_js/semantic-screen.js +290 -0
- memos/_js/semantic-screen.js.map +1 -0
- memos/_js/session-hooks.d.ts +127 -0
- memos/_js/session-hooks.d.ts.map +1 -0
- memos/_js/session-hooks.js +482 -0
- memos/_js/session-hooks.js.map +1 -0
- memos/_js/storage/sqlite.d.ts +427 -0
- memos/_js/storage/sqlite.d.ts.map +1 -0
- memos/_js/storage/sqlite.js +2428 -0
- memos/_js/storage/sqlite.js.map +1 -0
- memos/_js/sync.d.ts +213 -0
- memos/_js/sync.d.ts.map +1 -0
- memos/_js/sync.js +389 -0
- memos/_js/sync.js.map +1 -0
- memos/_js/tamper-log.d.ts +98 -0
- memos/_js/tamper-log.d.ts.map +1 -0
- memos/_js/tamper-log.js +327 -0
- memos/_js/tamper-log.js.map +1 -0
- memos/_js/temporal.d.ts +92 -0
- memos/_js/temporal.d.ts.map +1 -0
- memos/_js/temporal.js +536 -0
- memos/_js/temporal.js.map +1 -0
- memos/_js/time-travel.d.ts +38 -0
- memos/_js/time-travel.d.ts.map +1 -0
- memos/_js/time-travel.js +46 -0
- memos/_js/time-travel.js.map +1 -0
- memos/_js/timestamp-format.d.ts +18 -0
- memos/_js/timestamp-format.d.ts.map +1 -0
- memos/_js/timestamp-format.js +52 -0
- memos/_js/timestamp-format.js.map +1 -0
- memos/_js/triple-extraction.d.ts +31 -0
- memos/_js/triple-extraction.d.ts.map +1 -0
- memos/_js/triple-extraction.js +116 -0
- memos/_js/triple-extraction.js.map +1 -0
- memos/_js/types.d.ts +2474 -0
- memos/_js/types.d.ts.map +1 -0
- memos/_js/types.js +20 -0
- memos/_js/types.js.map +1 -0
- memos/_js/updater.d.ts +95 -0
- memos/_js/updater.d.ts.map +1 -0
- memos/_js/updater.js +268 -0
- memos/_js/updater.js.map +1 -0
- memos/_js/version.d.ts +17 -0
- memos/_js/version.d.ts.map +1 -0
- memos/_js/version.js +34 -0
- memos/_js/version.js.map +1 -0
- memos/_js/vision/clip-query-cache.d.ts +58 -0
- memos/_js/vision/clip-query-cache.d.ts.map +1 -0
- memos/_js/vision/clip-query-cache.js +79 -0
- memos/_js/vision/clip-query-cache.js.map +1 -0
- memos/_js/vision/clip.d.ts +113 -0
- memos/_js/vision/clip.d.ts.map +1 -0
- memos/_js/vision/clip.js +224 -0
- memos/_js/vision/clip.js.map +1 -0
- memos/_js/vision/fake-clip.d.ts +55 -0
- memos/_js/vision/fake-clip.d.ts.map +1 -0
- memos/_js/vision/fake-clip.js +122 -0
- memos/_js/vision/fake-clip.js.map +1 -0
- memos/_js/vision/index.d.ts +15 -0
- memos/_js/vision/index.d.ts.map +1 -0
- memos/_js/vision/index.js +13 -0
- memos/_js/vision/index.js.map +1 -0
- memos/_js/vision/store.d.ts +137 -0
- memos/_js/vision/store.d.ts.map +1 -0
- memos/_js/vision/store.js +383 -0
- memos/_js/vision/store.js.map +1 -0
- memos/adapters/__init__.py +0 -0
- memos/adapters/crewai.py +385 -0
- memos/adapters/langchain.py +301 -0
- memos/adapters/ollama.py +396 -0
- memos/server/__init__.py +0 -0
- memos/server/main.py +547 -0
- memos/server/routes.py +360 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effective importance model for MemOS memory nodes.
|
|
3
|
+
*
|
|
4
|
+
* The stored `importance` field is the *base* score assigned at write time
|
|
5
|
+
* (or manually via `update`). It never changes on its own. This module
|
|
6
|
+
* derives an *effective* importance at read time by combining:
|
|
7
|
+
*
|
|
8
|
+
* 1. Recency decay — memories not accessed recently slide toward a
|
|
9
|
+
* configurable floor (never below `decayFloor` × the boosted base,
|
|
10
|
+
* so a memory can't vanish by aging alone). The age is measured
|
|
11
|
+
* from the first available of `lastAccessed` → `createdAt` →
|
|
12
|
+
* `updatedAt`, so imported rows that never recorded an access are
|
|
13
|
+
* not mistaken for ancient ones.
|
|
14
|
+
* 2. Access reinforcement — each retrieval adds a small, logarithmic
|
|
15
|
+
* boost (capped), so frequently-used memories outrank equally-aged
|
|
16
|
+
* ones that are never touched. The boost itself also decays, so a
|
|
17
|
+
* memory does not stay permanently fresh on reinforcement alone.
|
|
18
|
+
*
|
|
19
|
+
* The model is pure computation over node fields — it performs no writes.
|
|
20
|
+
* This deliberately keeps it compatible with the access-count debounce:
|
|
21
|
+
* effective importance is recomputed whenever eviction, archival, or
|
|
22
|
+
* ranking needs it, instead of being materialised back into the row.
|
|
23
|
+
*
|
|
24
|
+
* @module @memos/importance
|
|
25
|
+
*/
|
|
26
|
+
import type { MemoryNode } from "./types.js";
|
|
27
|
+
/** Tuning knobs for the effective importance model. */
|
|
28
|
+
export interface ImportanceConfig {
|
|
29
|
+
/**
|
|
30
|
+
* Half-life (in days) of the recency decay applied to the base
|
|
31
|
+
* importance. `0` disables decay. Default 30.
|
|
32
|
+
*/
|
|
33
|
+
halfLifeDays?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Floor for the decay factor — the multiplicative decay never drops
|
|
36
|
+
* the base importance below `decayFloor` × base. Default 0.5.
|
|
37
|
+
*/
|
|
38
|
+
decayFloor?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Reinforcement gained per `log2(1 + accessCount)` unit. Default 0.1.
|
|
41
|
+
*/
|
|
42
|
+
accessGain?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Upper bound on the total access boost. Default 0.3.
|
|
45
|
+
*/
|
|
46
|
+
accessCap?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Weight of EFFECTIVE importance in hybrid-search ranking (see
|
|
49
|
+
* {@link importanceRankFactor}). `0` keeps ranking on raw relevance
|
|
50
|
+
* and leaves the effective model to eviction/archival decisions only.
|
|
51
|
+
*
|
|
52
|
+
* Only consulted when the `importance` block itself is configured:
|
|
53
|
+
* an unset `importance` keeps ranking byte-identical to the
|
|
54
|
+
* pre-wiring pipeline. Default 0.25.
|
|
55
|
+
*/
|
|
56
|
+
rankingWeight?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Default weight of effective importance in hybrid-search ranking.
|
|
60
|
+
*
|
|
61
|
+
* 0.25 maps effective importance 0.5 (neutral) to a ×1.0 multiplier and
|
|
62
|
+
* the full [0,1] range to [0.75, 1.25] — strong enough to reorder
|
|
63
|
+
* near-tied candidates, never enough to beat a genuine relevance gap.
|
|
64
|
+
*/
|
|
65
|
+
export declare const DEFAULT_IMPORTANCE_RANK_WEIGHT = 0.25;
|
|
66
|
+
/** Resolved defaults for {@link ImportanceConfig}. */
|
|
67
|
+
export declare const DEFAULT_IMPORTANCE_CONFIG: Required<ImportanceConfig>;
|
|
68
|
+
/**
|
|
69
|
+
* Compute the effective importance of a node at a point in time.
|
|
70
|
+
*
|
|
71
|
+
* Formula:
|
|
72
|
+
* decay = decayFloor + (1 - decayFloor) · e^(−ageDays / halfLifeDays)
|
|
73
|
+
* accessBoost = min(accessCap, accessGain · log2(1 + accessCount))
|
|
74
|
+
* effective = clamp01((importance + accessBoost) · decay)
|
|
75
|
+
*
|
|
76
|
+
* `ageDays` is measured from the {@link recencyAnchor} chain
|
|
77
|
+
* (`lastAccessed` → `createdAt` → `updatedAt` → `now`), so a row whose
|
|
78
|
+
* `lastAccessed` was never set — imported, migrated, or externally
|
|
79
|
+
* supplied — decays from its write time instead of from the epoch.
|
|
80
|
+
*
|
|
81
|
+
* The decay multiplies the *boosted* total, so access reinforcement is
|
|
82
|
+
* no longer immune to aging: a heavily-read memory still outranks an
|
|
83
|
+
* equally-scored untouched one, but both slide toward the floor together.
|
|
84
|
+
*
|
|
85
|
+
* @param node — The memory node.
|
|
86
|
+
* @param now — Current time (Unix ms).
|
|
87
|
+
* @param cfg — Optional tuning overrides.
|
|
88
|
+
* @returns Effective importance in [0, 1].
|
|
89
|
+
*/
|
|
90
|
+
export declare function computeEffectiveImportance(node: Pick<MemoryNode, "importance" | "accessCount" | "lastAccessed" | "createdAt" | "updatedAt">, now: number, cfg?: ImportanceConfig): number;
|
|
91
|
+
/**
|
|
92
|
+
* Recency score for ranking boosts — pure exponential decay from the
|
|
93
|
+
* last access, in [0, 1] (1 = touched right now).
|
|
94
|
+
*
|
|
95
|
+
* The age anchor follows the same {@link recencyAnchor} fallback chain as
|
|
96
|
+
* {@link computeEffectiveImportance}, so a row that never recorded an
|
|
97
|
+
* access scores as fresh rather than as a zero.
|
|
98
|
+
*
|
|
99
|
+
* @param node — The memory node.
|
|
100
|
+
* @param now — Current time (Unix ms).
|
|
101
|
+
* @param halfLifeDays — Days for the score to halve. `0` returns 1 (disabled).
|
|
102
|
+
* @returns Recency score in [0, 1].
|
|
103
|
+
*/
|
|
104
|
+
export declare function recencyScore(node: Pick<MemoryNode, "lastAccessed" | "createdAt" | "updatedAt">, now: number, halfLifeDays?: number): number;
|
|
105
|
+
/**
|
|
106
|
+
* Multiplicative ranking factor derived from an effective-importance
|
|
107
|
+
* value.
|
|
108
|
+
*
|
|
109
|
+
* Maps `effective = 0.5` (neutral) to `1.0`, the full [0,1] range to
|
|
110
|
+
* `[1 - w, 1 + w]`, and clamps `weight` to [0,1]. Used by
|
|
111
|
+
* `hybridSearch`'s post-fusion chain so effective importance nudges the
|
|
112
|
+
* ranking without ever dominating pure relevance.
|
|
113
|
+
*
|
|
114
|
+
* @param effective — Output of {@link computeEffectiveImportance}.
|
|
115
|
+
* @param weight — `ImportanceConfig.rankingWeight` (default 0.25).
|
|
116
|
+
*/
|
|
117
|
+
export declare function importanceRankFactor(effective: number, weight?: number): number;
|
|
118
|
+
//# sourceMappingURL=importance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importance.d.ts","sourceRoot":"","sources":["../src/importance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD,sDAAsD;AACtD,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,gBAAgB,CAMhE,CAAC;AAyCF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,IAAI,CACR,UAAU,EACV,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,WAAW,GAAG,WAAW,CAC1E,EACD,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,gBAAqB,GACzB,MAAM,CAiBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,cAAc,GAAG,WAAW,GAAG,WAAW,CAAC,EAClE,GAAG,EAAE,MAAM,EACX,YAAY,SAAK,GAChB,MAAM,CAKR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAuC,GAC9C,MAAM,CAGR"}
|
memos/_js/importance.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effective importance model for MemOS memory nodes.
|
|
3
|
+
*
|
|
4
|
+
* The stored `importance` field is the *base* score assigned at write time
|
|
5
|
+
* (or manually via `update`). It never changes on its own. This module
|
|
6
|
+
* derives an *effective* importance at read time by combining:
|
|
7
|
+
*
|
|
8
|
+
* 1. Recency decay — memories not accessed recently slide toward a
|
|
9
|
+
* configurable floor (never below `decayFloor` × the boosted base,
|
|
10
|
+
* so a memory can't vanish by aging alone). The age is measured
|
|
11
|
+
* from the first available of `lastAccessed` → `createdAt` →
|
|
12
|
+
* `updatedAt`, so imported rows that never recorded an access are
|
|
13
|
+
* not mistaken for ancient ones.
|
|
14
|
+
* 2. Access reinforcement — each retrieval adds a small, logarithmic
|
|
15
|
+
* boost (capped), so frequently-used memories outrank equally-aged
|
|
16
|
+
* ones that are never touched. The boost itself also decays, so a
|
|
17
|
+
* memory does not stay permanently fresh on reinforcement alone.
|
|
18
|
+
*
|
|
19
|
+
* The model is pure computation over node fields — it performs no writes.
|
|
20
|
+
* This deliberately keeps it compatible with the access-count debounce:
|
|
21
|
+
* effective importance is recomputed whenever eviction, archival, or
|
|
22
|
+
* ranking needs it, instead of being materialised back into the row.
|
|
23
|
+
*
|
|
24
|
+
* @module @memos/importance
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Default weight of effective importance in hybrid-search ranking.
|
|
28
|
+
*
|
|
29
|
+
* 0.25 maps effective importance 0.5 (neutral) to a ×1.0 multiplier and
|
|
30
|
+
* the full [0,1] range to [0.75, 1.25] — strong enough to reorder
|
|
31
|
+
* near-tied candidates, never enough to beat a genuine relevance gap.
|
|
32
|
+
*/
|
|
33
|
+
export const DEFAULT_IMPORTANCE_RANK_WEIGHT = 0.25;
|
|
34
|
+
/** Resolved defaults for {@link ImportanceConfig}. */
|
|
35
|
+
export const DEFAULT_IMPORTANCE_CONFIG = {
|
|
36
|
+
halfLifeDays: 30,
|
|
37
|
+
decayFloor: 0.5,
|
|
38
|
+
accessGain: 0.1,
|
|
39
|
+
accessCap: 0.3,
|
|
40
|
+
rankingWeight: DEFAULT_IMPORTANCE_RANK_WEIGHT,
|
|
41
|
+
};
|
|
42
|
+
const MS_PER_DAY = 86_400_000;
|
|
43
|
+
function clamp01(value) {
|
|
44
|
+
return Math.min(1, Math.max(0, value));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the timestamp that recency decay is measured from.
|
|
48
|
+
*
|
|
49
|
+
* `lastAccessed` is optional on imported, migrated, and externally-supplied
|
|
50
|
+
* rows (`UpdateMemoryInput.lastAccessed?`, `src/types.ts:339`), and such rows
|
|
51
|
+
* commonly arrive with it unset or 0. Anchoring decay on it then makes
|
|
52
|
+
* `ageDays` explode to decades and halves every such memory. The anchor
|
|
53
|
+
* therefore falls back through the write-time fields:
|
|
54
|
+
*
|
|
55
|
+
* 1. `lastAccessed` — set by the normal write/read paths.
|
|
56
|
+
* 2. `createdAt` — when MemOS learned the fact.
|
|
57
|
+
* 3. `updatedAt` — last content modification.
|
|
58
|
+
* 4. `now` — nothing usable on the row: treat it as brand new
|
|
59
|
+
* rather than as ancient.
|
|
60
|
+
*
|
|
61
|
+
* Non-finite and non-positive values are skipped at every step.
|
|
62
|
+
*/
|
|
63
|
+
function recencyAnchor(node, now) {
|
|
64
|
+
for (const candidate of [node.lastAccessed, node.createdAt, node.updatedAt]) {
|
|
65
|
+
if (typeof candidate === "number" &&
|
|
66
|
+
Number.isFinite(candidate) &&
|
|
67
|
+
candidate > 0) {
|
|
68
|
+
return candidate;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return now;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Compute the effective importance of a node at a point in time.
|
|
75
|
+
*
|
|
76
|
+
* Formula:
|
|
77
|
+
* decay = decayFloor + (1 - decayFloor) · e^(−ageDays / halfLifeDays)
|
|
78
|
+
* accessBoost = min(accessCap, accessGain · log2(1 + accessCount))
|
|
79
|
+
* effective = clamp01((importance + accessBoost) · decay)
|
|
80
|
+
*
|
|
81
|
+
* `ageDays` is measured from the {@link recencyAnchor} chain
|
|
82
|
+
* (`lastAccessed` → `createdAt` → `updatedAt` → `now`), so a row whose
|
|
83
|
+
* `lastAccessed` was never set — imported, migrated, or externally
|
|
84
|
+
* supplied — decays from its write time instead of from the epoch.
|
|
85
|
+
*
|
|
86
|
+
* The decay multiplies the *boosted* total, so access reinforcement is
|
|
87
|
+
* no longer immune to aging: a heavily-read memory still outranks an
|
|
88
|
+
* equally-scored untouched one, but both slide toward the floor together.
|
|
89
|
+
*
|
|
90
|
+
* @param node — The memory node.
|
|
91
|
+
* @param now — Current time (Unix ms).
|
|
92
|
+
* @param cfg — Optional tuning overrides.
|
|
93
|
+
* @returns Effective importance in [0, 1].
|
|
94
|
+
*/
|
|
95
|
+
export function computeEffectiveImportance(node, now, cfg = {}) {
|
|
96
|
+
const { halfLifeDays, decayFloor, accessGain, accessCap } = {
|
|
97
|
+
...DEFAULT_IMPORTANCE_CONFIG,
|
|
98
|
+
...cfg,
|
|
99
|
+
};
|
|
100
|
+
const anchor = recencyAnchor(node, now);
|
|
101
|
+
const ageDays = Math.max(0, (now - anchor) / MS_PER_DAY);
|
|
102
|
+
const decay = halfLifeDays <= 0
|
|
103
|
+
? 1
|
|
104
|
+
: decayFloor + (1 - decayFloor) * Math.exp(-ageDays / halfLifeDays);
|
|
105
|
+
const accessBoost = Math.min(accessCap, accessGain * Math.log2(1 + node.accessCount));
|
|
106
|
+
return clamp01((node.importance + accessBoost) * decay);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Recency score for ranking boosts — pure exponential decay from the
|
|
110
|
+
* last access, in [0, 1] (1 = touched right now).
|
|
111
|
+
*
|
|
112
|
+
* The age anchor follows the same {@link recencyAnchor} fallback chain as
|
|
113
|
+
* {@link computeEffectiveImportance}, so a row that never recorded an
|
|
114
|
+
* access scores as fresh rather than as a zero.
|
|
115
|
+
*
|
|
116
|
+
* @param node — The memory node.
|
|
117
|
+
* @param now — Current time (Unix ms).
|
|
118
|
+
* @param halfLifeDays — Days for the score to halve. `0` returns 1 (disabled).
|
|
119
|
+
* @returns Recency score in [0, 1].
|
|
120
|
+
*/
|
|
121
|
+
export function recencyScore(node, now, halfLifeDays = 14) {
|
|
122
|
+
if (halfLifeDays <= 0)
|
|
123
|
+
return 1;
|
|
124
|
+
const anchor = recencyAnchor(node, now);
|
|
125
|
+
const ageDays = Math.max(0, (now - anchor) / MS_PER_DAY);
|
|
126
|
+
return Math.exp(-ageDays / halfLifeDays);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Multiplicative ranking factor derived from an effective-importance
|
|
130
|
+
* value.
|
|
131
|
+
*
|
|
132
|
+
* Maps `effective = 0.5` (neutral) to `1.0`, the full [0,1] range to
|
|
133
|
+
* `[1 - w, 1 + w]`, and clamps `weight` to [0,1]. Used by
|
|
134
|
+
* `hybridSearch`'s post-fusion chain so effective importance nudges the
|
|
135
|
+
* ranking without ever dominating pure relevance.
|
|
136
|
+
*
|
|
137
|
+
* @param effective — Output of {@link computeEffectiveImportance}.
|
|
138
|
+
* @param weight — `ImportanceConfig.rankingWeight` (default 0.25).
|
|
139
|
+
*/
|
|
140
|
+
export function importanceRankFactor(effective, weight = DEFAULT_IMPORTANCE_RANK_WEIGHT) {
|
|
141
|
+
const w = Math.min(1, Math.max(0, weight));
|
|
142
|
+
return 1 - w + 2 * w * clamp01(effective);
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=importance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importance.js","sourceRoot":"","sources":["../src/importance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAoCH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAEnD,sDAAsD;AACtD,MAAM,CAAC,MAAM,yBAAyB,GAA+B;IACnE,YAAY,EAAE,EAAE;IAChB,UAAU,EAAE,GAAG;IACf,UAAU,EAAE,GAAG;IACf,SAAS,EAAE,GAAG;IACd,aAAa,EAAE,8BAA8B;CAC9C,CAAC;AAEF,MAAM,UAAU,GAAG,UAAU,CAAC;AAE9B,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,aAAa,CACpB,IAAkE,EAClE,GAAW;IAEX,KAAK,MAAM,SAAS,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,EAAE,IAA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IAChC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAiB,EACjB,MAAM,GAAW,8BAA8B;IAE/C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5C,CAAC"}
|
memos/_js/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemOS — Universal memory layer for AI agents, LLM apps, and chatbots.
|
|
3
|
+
*
|
|
4
|
+
* This is the package entry point. Import `MemOS` to get started:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { MemOS } from "@mem-os/sdk";
|
|
8
|
+
*
|
|
9
|
+
* const memos = new MemOS();
|
|
10
|
+
* await memos.init();
|
|
11
|
+
*
|
|
12
|
+
* await memos.store("User likes dark mode", { type: "preference" });
|
|
13
|
+
* const results = await memos.search("dark mode");
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
* @module @mem-os/sdk
|
|
18
|
+
*/
|
|
19
|
+
export { MemOS, MemorySkippedError } from "./memory.js";
|
|
20
|
+
export { decideRetain, shouldRetain, scoreRetain, setRetainClassifier, type RetainInput, type RetainDecision, } from "./retain-filter.js";
|
|
21
|
+
export { getMcpTools, runMcpServer } from "./mcp.js";
|
|
22
|
+
export { detectRevertIntent, normalizeRevertTarget, parseRevertCliArgs, type RevertIntent, type RevertScopeKind, type RevertScopeInput, type ParsedRevertArgs, } from "./revert.js";
|
|
23
|
+
export { parseTemporal, parseDuration, addDuration, type ParsedTemporal, type TemporalDuration, type TemporalGrain, } from "./temporal.js";
|
|
24
|
+
export { detectEvent, detectEventUpdate, extractEventKind, splitRemindText, isScheduledEventNode, listReminders, type DetectedEvent, type EventMetadata, type EventStatus, type EventUpdate, type ReminderEntry, type ListRemindersOptions, type ReminderSource, } from "./event-memory.js";
|
|
25
|
+
export { GraphEngine, textSimilarity, generateId } from "./graph.js";
|
|
26
|
+
export { FIDELITY_LEVELS, FIDELITY_LEVEL_LABELS, FIDELITY_LEVEL_DESCRIPTIONS, hasFidelityCache, stampFidelityCache, levelText, fidelityL0, fidelityL1, fidelityL2, splitSentences, nodeEntities, rankSentencesByCentrality, nextFidelityLevel, clampFidelityLevel, parseFidelityLevel, routeFidelity, routerEntities, scoreLevelCorpus, resolveRecallLevels, fidelityStats, isInformationDense, queryDecisiveTokens, textHasDecisiveToken, fidelityLevelSufficient, shouldCompressFidelityItem, DEFAULT_MIN_FIDELITY_LEVEL, type FidelityLevel, type FidelitySignals, type FidelityRoute, type FidelityRecallOptions, type FidelityRecallResult, type CompactOptions, type CompactResult, type FidelityLevelStats, } from "./fidelity.js";
|
|
27
|
+
export { LocalHashEmbeddingProvider, OllamaEmbeddingProvider, OpenAICompatibleEmbeddingProvider, VoyageAIEmbeddingProvider, CohereEmbeddingProvider, FastEmbedEmbeddingProvider, cosineSimilarity, createEmbeddingProvider, normalizeVector, } from "./embeddings.js";
|
|
28
|
+
export { SQLiteStorage } from "./storage/sqlite.js";
|
|
29
|
+
export type { SemanticScanMode, SemanticScanStats } from "./storage/sqlite.js";
|
|
30
|
+
export { ClipEmbeddingProvider, ClipUnavailableError, DEFAULT_CLIP_MODEL, DEFAULT_CLIP_DIMENSIONS, FakeClipProvider, ClipQueryCache, DEFAULT_CLIP_QUERY_CACHE_MAX, } from "./vision/index.js";
|
|
31
|
+
export type { ClipEmbeddingProviderOptions } from "./vision/clip.js";
|
|
32
|
+
export type { FakeClipProviderOptions } from "./vision/fake-clip.js";
|
|
33
|
+
export { blobRoot, deleteRef, ImageRejectedError, kindFromMime, normalizeImageInput, purgeOrphanImages, readDimensions, readImage, refFor, resolveRef, sniffMime, writeImage, type StoredImage, } from "./vision/store.js";
|
|
34
|
+
export { imageAttachmentOf } from "./context-pack.js";
|
|
35
|
+
export { EmbeddingQueue, type EmbeddingJob, type EmbeddingJobStatus, type EmbeddingQueueConfig, type PersistEmbeddingFn, type EmbeddingStatusChangeFn, } from "./embedding-queue.js";
|
|
36
|
+
export { buildContextPack, CONTEXT_PACK_SCHEMA, packToToon, packToToonCompact, searchResultsToToon, searchResultsToToonCompact, serializeContextPack, parseToonCompact, encodeCompactId, decodeCompactId, type ContextPack, type ContextPackItem, type BuildContextPackOptions, type ContextPackFidelityMeta, } from "./context-pack.js";
|
|
37
|
+
export type { MemoryNode, MemoryEdge, MemoryType, MemorySource, ProvenanceTier, EdgeRelation, CreateMemoryInput, UpdateMemoryInput, CreateEdgeInput, SearchFilter, SemanticSearchOptions, ScoredMemory, GraphSnapshot, StorageAdapter, MemOSConfig, MemOSEvent, MemOSEventListener, ExportFormat, ExportOptions, ExportResult, ImportFormat, ImportOptions, ImportResult, HarnessCount, HarnessMergeNode, HarnessMergeOptions, HarnessMergeResult, ExperimentalConfig, EmbeddingProvider, EmbeddingVector, EmbeddingRuntimeInfo, EmbeddingRecordInfo, EmbeddingNodeStatus, EmbeddingNodeStatusInfo, EmbeddingQueueStatus, EmbeddingProviderKind, DedupeOptions, DedupeMerge, DedupeResult, ArchiveOptions, ArchiveMove, ArchiveResult, ConsolidateOptions, ConsolidateResult, ConversationMessage, ExtractedFact, ExtractFactsOptions, ExtractFactsResult, DiagnosticsResult, LessonOutcome, NewProceduralLesson, ProceduralLesson, RevertOptions, RevertResult, RevertTargetResolution, ImageKind, ImageSource, ImageAttachment, ImageMemoryMeta, ImageInput, AddImageMemoryOptions, AddImageMemoryResult, SearchImagesOptions, ListImagesOptions, ImageSearchResult, EmbedImageProvider, ClipStatus, ClipMeta, VisionConfig, } from "./types.js";
|
|
38
|
+
export { DEFAULT_TRUST_SCORES } from "./types.js";
|
|
39
|
+
export { applyEvidence, classifyEvidence, confidenceWeight, INITIAL_CONFIDENCE, CONFIDENCE_FLOOR, CONFIDENCE_CAP, } from "./confidence-machine.js";
|
|
40
|
+
export type { EvidenceOutcome, ConfidenceUpdate, } from "./confidence-machine.js";
|
|
41
|
+
export { fuseResults, DEFAULT_RRF_K, DEFAULT_KEYWORD_WEIGHT, DEFAULT_SEMANTIC_WEIGHT, DEFAULT_TRUST_FLOOR, DEFAULT_ENTITY_LEG_WEIGHT, } from "./retrieval.js";
|
|
42
|
+
export type { FusionOptions } from "./retrieval.js";
|
|
43
|
+
export { personalizedPageRank, type PersonalizedPageRankOptions, DEFAULT_PPR_DAMPING, DEFAULT_PPR_MAX_HOPS, DEFAULT_PPR_MAX_FANOUT, DEFAULT_PPR_MAX_NODES, DEFAULT_PPR_MAX_ITERATIONS, DEFAULT_PPR_TOLERANCE, DEFAULT_GRAPH_EXPANSION_ALPHA, DEFAULT_GRAPH_EXPANSION_SEEDS, DEFAULT_GRAPH_EXPANSION_HOPS, DEFAULT_PPR_MAX_INJECTED, DEFAULT_PPR_MIN_INJECT_SCORE, } from "./graph-expansion.js";
|
|
44
|
+
export { applyLessonOutcome, clampLessonScore, effectiveLessonScore, lessonCitationToken, lessonShortId, rankProceduralLessons, DEFAULT_LESSON_PACK_K, LESSON_DECAY_HALF_LIFE_DAYS, LESSON_FAILURE_STEP, LESSON_INITIAL_SCORE, LESSON_RELEVANCE_WEIGHT, LESSON_SCORE_CAP, LESSON_SCORE_FLOOR, LESSON_SCORE_WEIGHT, LESSON_SUCCESS_STEP, type RankedProceduralLesson, } from "./procedural.js";
|
|
45
|
+
export { assignCitationTokens, citationToken, citationTokenForHex, formatCitationResolution, parseCitationToken, shortCitationId, CITATION_MAX_HEX, CITATION_MIN_HEX, type CitationResolution, } from "./citations.js";
|
|
46
|
+
export { detectHarness, normalizeHarness, UNKNOWN_HARNESS, MEMOS_HARNESS_ENV, HARNESS_MARKERS, } from "./harness.js";
|
|
47
|
+
export { contentHash, parseExportDirectory, parseExternalMemoryExport, parseSlackExportDirectory, synthesizeImportInsights, type DetectedExportSource, type ExternalImportSource, type ExternalMemoryItem, type ParsedExternalExport, type SynthesizedInsight, type SynthesizedKind, } from "./external-import.js";
|
|
48
|
+
export { PROVENANCE_TIER_ORDER, LOW_TRUST_TIERS, PROVENANCE_TRUST, DEFAULT_PROVENANCE_WEIGHT_STRENGTH, QUARANTINE_RELEASED_METADATA_KEY, isProvenanceTier, defaultProvenanceForSource, resolveProvenance, compareProvenanceTier, isUntrustedForAgent, quarantineVisible, provenanceMultiplier, decorateTrustFlags, } from "./provenance.js";
|
|
49
|
+
export { screenWrite, QUARANTINE_FLAG_THRESHOLD, type QuarantineSignal, type QuarantineVerdict, } from "./quarantine.js";
|
|
50
|
+
export { EXPLORER_APP_URI, EXPLORER_URI_TEMPLATE, EXPLORER_NODE_CAP, EXPLORER_EDGE_CAP, EXPLORER_PROTOCOL, PROVENANCE_TIER_COLORS, EDGE_RELATION_COLORS, SUPPORTED_INTENTS, buildExplorerSnapshot, filterSnapshotAsOf, isNodeValidAt, isEdgeValidAt, resolveExplorerMode, probeHostAppsSupport, intentToToolCall, buildExplorerHtml, buildExplorerFallbackMarkdown, ExplorerUriTemplate, type ExplorerIntentName, type ExplorerMode, type ExplorerNode, type ExplorerEdge, type ExplorerSnapshot, type IntentToolCall, type IntentTranslation, } from "./apps/explorer.js";
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
memos/_js/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA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eAAe,EACf,gBAAgB,EAChB,kCAAkC,EAClC,gCAAgC,EAChC,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,6BAA6B,EAC7B,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC"}
|
memos/_js/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemOS — Universal memory layer for AI agents, LLM apps, and chatbots.
|
|
3
|
+
*
|
|
4
|
+
* This is the package entry point. Import `MemOS` to get started:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { MemOS } from "@mem-os/sdk";
|
|
8
|
+
*
|
|
9
|
+
* const memos = new MemOS();
|
|
10
|
+
* await memos.init();
|
|
11
|
+
*
|
|
12
|
+
* await memos.store("User likes dark mode", { type: "preference" });
|
|
13
|
+
* const results = await memos.search("dark mode");
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
* @module @mem-os/sdk
|
|
18
|
+
*/
|
|
19
|
+
export { MemOS, MemorySkippedError } from "./memory.js";
|
|
20
|
+
export { decideRetain, shouldRetain, scoreRetain, setRetainClassifier, } from "./retain-filter.js";
|
|
21
|
+
export { getMcpTools, runMcpServer } from "./mcp.js";
|
|
22
|
+
export { detectRevertIntent, normalizeRevertTarget, parseRevertCliArgs, } from "./revert.js";
|
|
23
|
+
export { parseTemporal, parseDuration, addDuration, } from "./temporal.js";
|
|
24
|
+
export { detectEvent, detectEventUpdate, extractEventKind, splitRemindText, isScheduledEventNode, listReminders, } from "./event-memory.js";
|
|
25
|
+
export { GraphEngine, textSimilarity, generateId } from "./graph.js";
|
|
26
|
+
export {
|
|
27
|
+
// Fidelity-level compaction (L0–L3): cheap representations of every
|
|
28
|
+
// memory, a query-adaptive router, and in-call escalation.
|
|
29
|
+
FIDELITY_LEVELS, FIDELITY_LEVEL_LABELS, FIDELITY_LEVEL_DESCRIPTIONS, hasFidelityCache, stampFidelityCache, levelText, fidelityL0, fidelityL1, fidelityL2, splitSentences, nodeEntities, rankSentencesByCentrality, nextFidelityLevel, clampFidelityLevel, parseFidelityLevel, routeFidelity, routerEntities, scoreLevelCorpus, resolveRecallLevels, fidelityStats, isInformationDense, queryDecisiveTokens, textHasDecisiveToken, fidelityLevelSufficient, shouldCompressFidelityItem, DEFAULT_MIN_FIDELITY_LEVEL, } from "./fidelity.js";
|
|
30
|
+
export { LocalHashEmbeddingProvider, OllamaEmbeddingProvider, OpenAICompatibleEmbeddingProvider, VoyageAIEmbeddingProvider, CohereEmbeddingProvider, FastEmbedEmbeddingProvider, cosineSimilarity, createEmbeddingProvider, normalizeVector, } from "./embeddings.js";
|
|
31
|
+
export { SQLiteStorage } from "./storage/sqlite.js";
|
|
32
|
+
export { ClipEmbeddingProvider, ClipUnavailableError, DEFAULT_CLIP_MODEL, DEFAULT_CLIP_DIMENSIONS, FakeClipProvider, ClipQueryCache, DEFAULT_CLIP_QUERY_CACHE_MAX, } from "./vision/index.js";
|
|
33
|
+
// Blob store + input normalization: exported so a host model can
|
|
34
|
+
// resolve an `[img:…]` ref from a context pack without going through
|
|
35
|
+
// a MemOS instance.
|
|
36
|
+
export { blobRoot, deleteRef, ImageRejectedError, kindFromMime, normalizeImageInput, purgeOrphanImages, readDimensions, readImage, refFor, resolveRef, sniffMime, writeImage, } from "./vision/store.js";
|
|
37
|
+
// The node-level image discriminator, shared by the pack builder and
|
|
38
|
+
// the fidelity renderer.
|
|
39
|
+
export { imageAttachmentOf } from "./context-pack.js";
|
|
40
|
+
export { EmbeddingQueue, } from "./embedding-queue.js";
|
|
41
|
+
export { buildContextPack, CONTEXT_PACK_SCHEMA, packToToon, packToToonCompact, searchResultsToToon, searchResultsToToonCompact, serializeContextPack, parseToonCompact, encodeCompactId, decodeCompactId, } from "./context-pack.js";
|
|
42
|
+
export { DEFAULT_TRUST_SCORES } from "./types.js";
|
|
43
|
+
export { applyEvidence, classifyEvidence, confidenceWeight, INITIAL_CONFIDENCE, CONFIDENCE_FLOOR, CONFIDENCE_CAP, } from "./confidence-machine.js";
|
|
44
|
+
export { fuseResults, DEFAULT_RRF_K, DEFAULT_KEYWORD_WEIGHT, DEFAULT_SEMANTIC_WEIGHT, DEFAULT_TRUST_FLOOR, DEFAULT_ENTITY_LEG_WEIGHT, } from "./retrieval.js";
|
|
45
|
+
export { personalizedPageRank, DEFAULT_PPR_DAMPING, DEFAULT_PPR_MAX_HOPS, DEFAULT_PPR_MAX_FANOUT, DEFAULT_PPR_MAX_NODES, DEFAULT_PPR_MAX_ITERATIONS, DEFAULT_PPR_TOLERANCE, DEFAULT_GRAPH_EXPANSION_ALPHA, DEFAULT_GRAPH_EXPANSION_SEEDS, DEFAULT_GRAPH_EXPANSION_HOPS, DEFAULT_PPR_MAX_INJECTED, DEFAULT_PPR_MIN_INJECT_SCORE, } from "./graph-expansion.js";
|
|
46
|
+
export { applyLessonOutcome, clampLessonScore, effectiveLessonScore, lessonCitationToken, lessonShortId, rankProceduralLessons, DEFAULT_LESSON_PACK_K, LESSON_DECAY_HALF_LIFE_DAYS, LESSON_FAILURE_STEP, LESSON_INITIAL_SCORE, LESSON_RELEVANCE_WEIGHT, LESSON_SCORE_CAP, LESSON_SCORE_FLOOR, LESSON_SCORE_WEIGHT, LESSON_SUCCESS_STEP, } from "./procedural.js";
|
|
47
|
+
export { assignCitationTokens, citationToken, citationTokenForHex, formatCitationResolution, parseCitationToken, shortCitationId, CITATION_MAX_HEX, CITATION_MIN_HEX, } from "./citations.js";
|
|
48
|
+
export { detectHarness, normalizeHarness, UNKNOWN_HARNESS, MEMOS_HARNESS_ENV, HARNESS_MARKERS, } from "./harness.js";
|
|
49
|
+
export { contentHash, parseExportDirectory, parseExternalMemoryExport, parseSlackExportDirectory, synthesizeImportInsights, } from "./external-import.js";
|
|
50
|
+
export { PROVENANCE_TIER_ORDER, LOW_TRUST_TIERS, PROVENANCE_TRUST, DEFAULT_PROVENANCE_WEIGHT_STRENGTH, QUARANTINE_RELEASED_METADATA_KEY, isProvenanceTier, defaultProvenanceForSource, resolveProvenance, compareProvenanceTier, isUntrustedForAgent, quarantineVisible, provenanceMultiplier, decorateTrustFlags, } from "./provenance.js";
|
|
51
|
+
export { screenWrite, QUARANTINE_FLAG_THRESHOLD, } from "./quarantine.js";
|
|
52
|
+
export { EXPLORER_APP_URI, EXPLORER_URI_TEMPLATE, EXPLORER_NODE_CAP, EXPLORER_EDGE_CAP, EXPLORER_PROTOCOL, PROVENANCE_TIER_COLORS, EDGE_RELATION_COLORS, SUPPORTED_INTENTS, buildExplorerSnapshot, filterSnapshotAsOf, isNodeValidAt, isEdgeValidAt, resolveExplorerMode, probeHostAppsSupport, intentToToolCall, buildExplorerHtml, buildExplorerFallbackMarkdown, ExplorerUriTemplate, } from "./apps/explorer.js";
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
memos/_js/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG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EACrB,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,GAOzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,kCAAkC,EAClC,gCAAgC,EAChC,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,yBAAyB,GAG1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,6BAA6B,EAC7B,mBAAmB,GAQpB,MAAM,oBAAoB,CAAC"}
|
memos/_js/mcp.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server for MemOS — Model Context Protocol 2026-07-28.
|
|
3
|
+
*
|
|
4
|
+
* Built on the official `@modelcontextprotocol/server` v2 SDK, which
|
|
5
|
+
* implements the 2026-07-28 spec (stateless core, `server/discover`,
|
|
6
|
+
* per-request `_meta` envelope, `ttlMs`/`cacheScope` on list results,
|
|
7
|
+
* `outputSchema` on tools). The SDK's `serveStdio` entry is dual-era:
|
|
8
|
+
* it speaks the modern 2026-07-28 protocol AND falls back to the legacy
|
|
9
|
+
* 2025-era `initialize` handshake for older clients.
|
|
10
|
+
*
|
|
11
|
+
* Transport: stdio only (the shipped transport). HTTP/SSE is deferred.
|
|
12
|
+
*/
|
|
13
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
14
|
+
import { MemOS } from "./memory.js";
|
|
15
|
+
import type { MemOSConfig } from "./types.js";
|
|
16
|
+
export interface McpToolAnnotations {
|
|
17
|
+
readOnlyHint: boolean;
|
|
18
|
+
destructiveHint: boolean;
|
|
19
|
+
idempotentHint: boolean;
|
|
20
|
+
openWorldHint: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Per-tool annotations, keyed by tool name. Shared by the live server
|
|
24
|
+
* registration (the wire path) and the static TOOL_METADATA below so the
|
|
25
|
+
* two can never disagree.
|
|
26
|
+
*/
|
|
27
|
+
export declare const TOOL_ANNOTATIONS: Record<string, McpToolAnnotations>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a fully-configured McpServer instance for MemOS.
|
|
30
|
+
* Exported for testing and advanced use cases.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createMcpServer(memos: MemOS): McpServer;
|
|
33
|
+
/**
|
|
34
|
+
* Run the MemOS MCP server over stdio.
|
|
35
|
+
*
|
|
36
|
+
* Speaks MCP protocol revision 2026-07-28 (modern stateless core with
|
|
37
|
+
* `server/discover`) and falls back to the legacy 2025-era `initialize`
|
|
38
|
+
* handshake for older clients. Blocks until the connection closes.
|
|
39
|
+
*/
|
|
40
|
+
export declare function runMcpServer(config?: MemOSConfig): Promise<void>;
|
|
41
|
+
export interface McpToolInfo {
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
annotations: McpToolAnnotations;
|
|
45
|
+
inputSchema: Record<string, unknown>;
|
|
46
|
+
outputSchema: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Return static metadata about the MCP tools exposed by MemOS.
|
|
50
|
+
* Useful for programmatic consumers and tests that need tool definitions
|
|
51
|
+
* without spinning up a live server connection.
|
|
52
|
+
*
|
|
53
|
+
* Kept in the SAME ORDER as the live `registerTools` registrations —
|
|
54
|
+
* the annotations test asserts the two surfaces match exactly, so a
|
|
55
|
+
* reorder here must be mirrored there.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getMcpTools(): readonly McpToolInfo[];
|
|
58
|
+
//# sourceMappingURL=mcp.d.ts.map
|
memos/_js/mcp.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAoB,MAAM,8BAA8B,CAAC;AAI3E,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAUpC,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,YAAY,CAAC;AA8G5D,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;CACxB;AAkBD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAuE/D,CAAC;AAq/CF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CA0BvD;AAMD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,MAAM,GAAE,WAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqC1E;AAMD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,kBAAkB,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AA+cD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,SAAS,WAAW,EAAE,CAEpD"}
|