@pyxmate/memory 1.17.19 → 1.18.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.
- package/dist/{chunk-T35ZOOES.mjs → chunk-ACFPMLNO.mjs} +1 -1
- package/dist/chunk-KVYCISUI.mjs +206 -0
- package/dist/{chunk-H6ZLMPZH.mjs → chunk-SLYCVO4C.mjs} +53 -201
- package/dist/cli/pyx-mem.mjs +478 -264
- package/dist/dashboard.mjs +3 -2
- package/dist/index.d.ts +63 -2
- package/dist/index.mjs +14 -4
- package/dist/react.mjs +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// ../shared/src/constants/defaults.ts
|
|
2
|
+
var DEFAULTS = {
|
|
3
|
+
DATA_DIR: "./data",
|
|
4
|
+
VECTOR_PROVIDER: "lancedb",
|
|
5
|
+
MEMORY_SERVER_PORT: 7822
|
|
6
|
+
};
|
|
7
|
+
var TAXONOMY_MAX_CATEGORIES = 10;
|
|
8
|
+
var TAXONOMY_MAX_TOP_ENTITIES = 15;
|
|
9
|
+
var TAXONOMY_MAX_SAMPLE_TOPICS = 8;
|
|
10
|
+
var TAXONOMY_MAX_PROJECTS = 8;
|
|
11
|
+
var MEMORY_PROJECT_LABEL_MAX_CHARS = 80;
|
|
12
|
+
|
|
13
|
+
// ../shared/src/document-source.ts
|
|
14
|
+
import { createHash } from "crypto";
|
|
15
|
+
function documentSource(prefix, documentKey) {
|
|
16
|
+
return `${prefix}:${createHash("sha256").update(documentKey).digest("hex")}`;
|
|
17
|
+
}
|
|
18
|
+
function documentGraphSource(documentKey) {
|
|
19
|
+
return documentSource("document-graph", documentKey);
|
|
20
|
+
}
|
|
21
|
+
function documentContentSource(documentKey) {
|
|
22
|
+
return documentSource("document-content", documentKey);
|
|
23
|
+
}
|
|
24
|
+
function documentImageSource(documentKey) {
|
|
25
|
+
return documentSource("document-image", documentKey);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ../shared/src/mcp/search-response.ts
|
|
29
|
+
var STRIPPED_ENTRY_FIELDS = /* @__PURE__ */ new Set(["contentHash", "embedding", "tenantId", "userId", "teamId"]);
|
|
30
|
+
function isRecord(value) {
|
|
31
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
32
|
+
}
|
|
33
|
+
function compactEntryForMcp(entry, vectorSimilarity) {
|
|
34
|
+
if (!isRecord(entry)) return entry;
|
|
35
|
+
const projected = {};
|
|
36
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
37
|
+
if (!STRIPPED_ENTRY_FIELDS.has(key)) projected[key] = value;
|
|
38
|
+
}
|
|
39
|
+
if (vectorSimilarity !== void 0) projected.vectorSimilarity = vectorSimilarity;
|
|
40
|
+
return projected;
|
|
41
|
+
}
|
|
42
|
+
function vectorSimilarityByEntryId(payload) {
|
|
43
|
+
const similarities = /* @__PURE__ */ new Map();
|
|
44
|
+
const scoredEntries = Array.isArray(payload.scoredEntries) ? payload.scoredEntries : [];
|
|
45
|
+
for (const scored of scoredEntries) {
|
|
46
|
+
if (!isRecord(scored) || !isRecord(scored.entry)) continue;
|
|
47
|
+
const id = scored.entry.id;
|
|
48
|
+
if (typeof id === "string" && typeof scored.vectorSimilarity === "number") {
|
|
49
|
+
similarities.set(id, scored.vectorSimilarity);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return similarities;
|
|
53
|
+
}
|
|
54
|
+
function projectSearchResultRecord(payload) {
|
|
55
|
+
const similarities = vectorSimilarityByEntryId(payload);
|
|
56
|
+
const projected = {};
|
|
57
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
58
|
+
if (key === "scoredEntries") continue;
|
|
59
|
+
if (key === "entries" && Array.isArray(value)) {
|
|
60
|
+
projected.entries = value.map(
|
|
61
|
+
(entry) => compactEntryForMcp(
|
|
62
|
+
entry,
|
|
63
|
+
isRecord(entry) && typeof entry.id === "string" ? similarities.get(entry.id) : void 0
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
projected[key] = value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return projected;
|
|
71
|
+
}
|
|
72
|
+
function projectSearchResponseForMcp(payload) {
|
|
73
|
+
if (!isRecord(payload)) return payload;
|
|
74
|
+
if (isRecord(payload.data) && ("entries" in payload.data || "scoredEntries" in payload.data)) {
|
|
75
|
+
return { ...payload, data: projectSearchResultRecord(payload.data) };
|
|
76
|
+
}
|
|
77
|
+
return projectSearchResultRecord(payload);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ../shared/src/mcp/secret-elevation-notice.ts
|
|
81
|
+
function isRecord2(value) {
|
|
82
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
83
|
+
}
|
|
84
|
+
function elevationMessage(credentialTypes) {
|
|
85
|
+
const types = credentialTypes.length > 0 ? credentialTypes.join(", ") : "unspecified";
|
|
86
|
+
return `Auto-classified sensitivity=secret because credential patterns were detected (credentialTypes: ${types}). Secret entries are invisible to hosted MCP reads \u2014 search, get and list all cap MCP callers at internal. When an encryption key is configured the content is also encrypted at rest and embedded as a placeholder, so REST callers lose semantic search recall for it too (REST list/get still return the row). If this is a false positive: delete the entry by id, or store it again under the same id with the credential-shaped notation rephrased \u2014 a same-id re-store re-classifies the content. A canonical entry carrying metadata.dbRef.revision must advance that revision on the re-store, or it fails with revision_reuse_conflict.`;
|
|
87
|
+
}
|
|
88
|
+
function secretElevationNoticeFor(entry) {
|
|
89
|
+
if (!isRecord2(entry) || entry.sensitivity !== "secret") return void 0;
|
|
90
|
+
const metadata = entry.metadata;
|
|
91
|
+
if (!isRecord2(metadata) || metadata.credentialsDetected !== true) return void 0;
|
|
92
|
+
const credentialTypes = Array.isArray(metadata.credentialTypes) ? metadata.credentialTypes.filter((type) => typeof type === "string") : [];
|
|
93
|
+
return { sensitivity: "secret", credentialTypes, message: elevationMessage(credentialTypes) };
|
|
94
|
+
}
|
|
95
|
+
function withSecretElevationNotice(payload) {
|
|
96
|
+
if (!isRecord2(payload)) return payload;
|
|
97
|
+
const entry = isRecord2(payload.data) ? payload.data : payload;
|
|
98
|
+
const notice = secretElevationNoticeFor(entry);
|
|
99
|
+
if (!notice) return payload;
|
|
100
|
+
const elevated = { ...entry, secretElevation: notice };
|
|
101
|
+
return entry === payload ? elevated : { ...payload, data: elevated };
|
|
102
|
+
}
|
|
103
|
+
function secretElevationAggregate(elevated) {
|
|
104
|
+
if (elevated.length === 0) return void 0;
|
|
105
|
+
const credentialTypes = [...new Set(elevated.flatMap((item) => item.notice.credentialTypes))];
|
|
106
|
+
return {
|
|
107
|
+
count: elevated.length,
|
|
108
|
+
entryIds: elevated.map((item) => item.entryId),
|
|
109
|
+
credentialTypes,
|
|
110
|
+
message: `${elevated.length} stored chunk(s) were auto-elevated. ${elevationMessage(credentialTypes)}`
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ../shared/src/types/isolation.ts
|
|
115
|
+
var NamespaceIsolation = {
|
|
116
|
+
SHARED: "shared",
|
|
117
|
+
STRICT: "strict"
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// ../shared/src/types/memory.ts
|
|
121
|
+
var MemoryType = {
|
|
122
|
+
SHORT_TERM: "short-term",
|
|
123
|
+
LONG_TERM: "long-term",
|
|
124
|
+
WORKING: "working",
|
|
125
|
+
EPISODIC: "episodic",
|
|
126
|
+
SUMMARY: "summary"
|
|
127
|
+
};
|
|
128
|
+
var SensitivityLevel = {
|
|
129
|
+
PUBLIC: "public",
|
|
130
|
+
INTERNAL: "internal",
|
|
131
|
+
SECRET: "secret"
|
|
132
|
+
};
|
|
133
|
+
var RAGStrategy = {
|
|
134
|
+
NAIVE: "naive",
|
|
135
|
+
GRAPH: "graph",
|
|
136
|
+
HYBRID: "hybrid"
|
|
137
|
+
};
|
|
138
|
+
var DEPRECATED_RAG_STRATEGIES = /* @__PURE__ */ new Map([
|
|
139
|
+
["agentic", "strategy.deprecated:agentic \u2014 removed in v0.26, use hybrid"]
|
|
140
|
+
]);
|
|
141
|
+
var VectorProvider = {
|
|
142
|
+
LANCEDB: "lancedb"
|
|
143
|
+
};
|
|
144
|
+
var EmbeddingProviderName = {
|
|
145
|
+
STUB: "stub",
|
|
146
|
+
/** @deprecated Vestigial — pyx-memory uses internal EmbeddingGemma embeddings. */
|
|
147
|
+
ANTHROPIC: "anthropic",
|
|
148
|
+
/** @deprecated Vestigial — pyx-memory uses internal EmbeddingGemma embeddings. */
|
|
149
|
+
OPENAI: "openai",
|
|
150
|
+
/** In-process ONNX model (default: EmbeddingGemma-300M). */
|
|
151
|
+
LOCAL: "local",
|
|
152
|
+
/** Remote OpenAI-compatible embedding service (pyx-cloud shared, custom, etc.). */
|
|
153
|
+
HTTP: "http"
|
|
154
|
+
};
|
|
155
|
+
var StoreTarget = {
|
|
156
|
+
SQLITE: "sqlite",
|
|
157
|
+
VECTOR: "vector",
|
|
158
|
+
GRAPH: "graph"
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// ../shared/src/types/move.ts
|
|
162
|
+
var MoveFailureReason = {
|
|
163
|
+
/** Entry not found in the caller's tenant. */
|
|
164
|
+
NOT_FOUND: "not_found",
|
|
165
|
+
/** Move would cross tenant boundary (always forbidden). */
|
|
166
|
+
CROSS_TENANT_FORBIDDEN: "cross_tenant_forbidden",
|
|
167
|
+
/** Target namespace ID does not exist in the caller's tenant. */
|
|
168
|
+
TARGET_NAMESPACE_NOT_FOUND: "target_namespace_not_found",
|
|
169
|
+
/** SQLite metadata update failed; no compensation needed. */
|
|
170
|
+
SQLITE_UPDATE_FAILED: "sqlite_update_failed",
|
|
171
|
+
/** Vector store metadata update failed; SQLite reverted. */
|
|
172
|
+
VECTOR_UPDATE_FAILED: "vector_update_failed",
|
|
173
|
+
/** Graph edge namespace update failed; SQLite + vector reverted. */
|
|
174
|
+
GRAPH_UPDATE_FAILED: "graph_update_failed",
|
|
175
|
+
/** Compensation itself failed — manual intervention required. */
|
|
176
|
+
COMPENSATION_FAILED: "compensation_failed"
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// ../shared/src/types/principal.ts
|
|
180
|
+
var SINGLE_TENANT_ID = "_single";
|
|
181
|
+
|
|
182
|
+
export {
|
|
183
|
+
DEFAULTS,
|
|
184
|
+
TAXONOMY_MAX_CATEGORIES,
|
|
185
|
+
TAXONOMY_MAX_TOP_ENTITIES,
|
|
186
|
+
TAXONOMY_MAX_SAMPLE_TOPICS,
|
|
187
|
+
TAXONOMY_MAX_PROJECTS,
|
|
188
|
+
MEMORY_PROJECT_LABEL_MAX_CHARS,
|
|
189
|
+
documentGraphSource,
|
|
190
|
+
documentContentSource,
|
|
191
|
+
documentImageSource,
|
|
192
|
+
projectSearchResponseForMcp,
|
|
193
|
+
secretElevationNoticeFor,
|
|
194
|
+
withSecretElevationNotice,
|
|
195
|
+
secretElevationAggregate,
|
|
196
|
+
NamespaceIsolation,
|
|
197
|
+
MemoryType,
|
|
198
|
+
SensitivityLevel,
|
|
199
|
+
RAGStrategy,
|
|
200
|
+
DEPRECATED_RAG_STRATEGIES,
|
|
201
|
+
VectorProvider,
|
|
202
|
+
EmbeddingProviderName,
|
|
203
|
+
StoreTarget,
|
|
204
|
+
MoveFailureReason,
|
|
205
|
+
SINGLE_TENANT_ID
|
|
206
|
+
};
|
|
@@ -1,185 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RAGStrategy
|
|
3
|
+
} from "./chunk-KVYCISUI.mjs";
|
|
1
4
|
import {
|
|
2
5
|
assertGraphExtractionPayload,
|
|
3
6
|
mergeExtractedEntities
|
|
4
7
|
} from "./chunk-3OLH3HYR.mjs";
|
|
5
8
|
|
|
6
|
-
// ../shared/src/constants/defaults.ts
|
|
7
|
-
var DEFAULTS = {
|
|
8
|
-
DATA_DIR: "./data",
|
|
9
|
-
VECTOR_PROVIDER: "lancedb",
|
|
10
|
-
MEMORY_SERVER_PORT: 7822
|
|
11
|
-
};
|
|
12
|
-
var TAXONOMY_MAX_CATEGORIES = 10;
|
|
13
|
-
|
|
14
|
-
// ../shared/src/document-source.ts
|
|
15
|
-
import { createHash } from "crypto";
|
|
16
|
-
function documentSource(prefix, documentKey) {
|
|
17
|
-
return `${prefix}:${createHash("sha256").update(documentKey).digest("hex")}`;
|
|
18
|
-
}
|
|
19
|
-
function documentGraphSource(documentKey) {
|
|
20
|
-
return documentSource("document-graph", documentKey);
|
|
21
|
-
}
|
|
22
|
-
function documentContentSource(documentKey) {
|
|
23
|
-
return documentSource("document-content", documentKey);
|
|
24
|
-
}
|
|
25
|
-
function documentImageSource(documentKey) {
|
|
26
|
-
return documentSource("document-image", documentKey);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ../shared/src/mcp/search-response.ts
|
|
30
|
-
var STRIPPED_ENTRY_FIELDS = /* @__PURE__ */ new Set(["contentHash", "embedding", "tenantId", "userId", "teamId"]);
|
|
31
|
-
function isRecord(value) {
|
|
32
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
33
|
-
}
|
|
34
|
-
function compactEntryForMcp(entry, vectorSimilarity) {
|
|
35
|
-
if (!isRecord(entry)) return entry;
|
|
36
|
-
const projected = {};
|
|
37
|
-
for (const [key, value] of Object.entries(entry)) {
|
|
38
|
-
if (!STRIPPED_ENTRY_FIELDS.has(key)) projected[key] = value;
|
|
39
|
-
}
|
|
40
|
-
if (vectorSimilarity !== void 0) projected.vectorSimilarity = vectorSimilarity;
|
|
41
|
-
return projected;
|
|
42
|
-
}
|
|
43
|
-
function vectorSimilarityByEntryId(payload) {
|
|
44
|
-
const similarities = /* @__PURE__ */ new Map();
|
|
45
|
-
const scoredEntries = Array.isArray(payload.scoredEntries) ? payload.scoredEntries : [];
|
|
46
|
-
for (const scored of scoredEntries) {
|
|
47
|
-
if (!isRecord(scored) || !isRecord(scored.entry)) continue;
|
|
48
|
-
const id = scored.entry.id;
|
|
49
|
-
if (typeof id === "string" && typeof scored.vectorSimilarity === "number") {
|
|
50
|
-
similarities.set(id, scored.vectorSimilarity);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return similarities;
|
|
54
|
-
}
|
|
55
|
-
function projectSearchResultRecord(payload) {
|
|
56
|
-
const similarities = vectorSimilarityByEntryId(payload);
|
|
57
|
-
const projected = {};
|
|
58
|
-
for (const [key, value] of Object.entries(payload)) {
|
|
59
|
-
if (key === "scoredEntries") continue;
|
|
60
|
-
if (key === "entries" && Array.isArray(value)) {
|
|
61
|
-
projected.entries = value.map(
|
|
62
|
-
(entry) => compactEntryForMcp(
|
|
63
|
-
entry,
|
|
64
|
-
isRecord(entry) && typeof entry.id === "string" ? similarities.get(entry.id) : void 0
|
|
65
|
-
)
|
|
66
|
-
);
|
|
67
|
-
} else {
|
|
68
|
-
projected[key] = value;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return projected;
|
|
72
|
-
}
|
|
73
|
-
function projectSearchResponseForMcp(payload) {
|
|
74
|
-
if (!isRecord(payload)) return payload;
|
|
75
|
-
if (isRecord(payload.data) && ("entries" in payload.data || "scoredEntries" in payload.data)) {
|
|
76
|
-
return { ...payload, data: projectSearchResultRecord(payload.data) };
|
|
77
|
-
}
|
|
78
|
-
return projectSearchResultRecord(payload);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// ../shared/src/mcp/secret-elevation-notice.ts
|
|
82
|
-
function isRecord2(value) {
|
|
83
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
84
|
-
}
|
|
85
|
-
function elevationMessage(credentialTypes) {
|
|
86
|
-
const types = credentialTypes.length > 0 ? credentialTypes.join(", ") : "unspecified";
|
|
87
|
-
return `Auto-classified sensitivity=secret because credential patterns were detected (credentialTypes: ${types}). Secret entries are invisible to hosted MCP reads \u2014 search, get and list all cap MCP callers at internal. When an encryption key is configured the content is also encrypted at rest and embedded as a placeholder, so REST callers lose semantic search recall for it too (REST list/get still return the row). If this is a false positive: delete the entry by id, or store it again under the same id with the credential-shaped notation rephrased \u2014 a same-id re-store re-classifies the content. A canonical entry carrying metadata.dbRef.revision must advance that revision on the re-store, or it fails with revision_reuse_conflict.`;
|
|
88
|
-
}
|
|
89
|
-
function secretElevationNoticeFor(entry) {
|
|
90
|
-
if (!isRecord2(entry) || entry.sensitivity !== "secret") return void 0;
|
|
91
|
-
const metadata = entry.metadata;
|
|
92
|
-
if (!isRecord2(metadata) || metadata.credentialsDetected !== true) return void 0;
|
|
93
|
-
const credentialTypes = Array.isArray(metadata.credentialTypes) ? metadata.credentialTypes.filter((type) => typeof type === "string") : [];
|
|
94
|
-
return { sensitivity: "secret", credentialTypes, message: elevationMessage(credentialTypes) };
|
|
95
|
-
}
|
|
96
|
-
function withSecretElevationNotice(payload) {
|
|
97
|
-
if (!isRecord2(payload)) return payload;
|
|
98
|
-
const entry = isRecord2(payload.data) ? payload.data : payload;
|
|
99
|
-
const notice = secretElevationNoticeFor(entry);
|
|
100
|
-
if (!notice) return payload;
|
|
101
|
-
const elevated = { ...entry, secretElevation: notice };
|
|
102
|
-
return entry === payload ? elevated : { ...payload, data: elevated };
|
|
103
|
-
}
|
|
104
|
-
function secretElevationAggregate(elevated) {
|
|
105
|
-
if (elevated.length === 0) return void 0;
|
|
106
|
-
const credentialTypes = [...new Set(elevated.flatMap((item) => item.notice.credentialTypes))];
|
|
107
|
-
return {
|
|
108
|
-
count: elevated.length,
|
|
109
|
-
entryIds: elevated.map((item) => item.entryId),
|
|
110
|
-
credentialTypes,
|
|
111
|
-
message: `${elevated.length} stored chunk(s) were auto-elevated. ${elevationMessage(credentialTypes)}`
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// ../shared/src/types/isolation.ts
|
|
116
|
-
var NamespaceIsolation = {
|
|
117
|
-
SHARED: "shared",
|
|
118
|
-
STRICT: "strict"
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// ../shared/src/types/memory.ts
|
|
122
|
-
var MemoryType = {
|
|
123
|
-
SHORT_TERM: "short-term",
|
|
124
|
-
LONG_TERM: "long-term",
|
|
125
|
-
WORKING: "working",
|
|
126
|
-
EPISODIC: "episodic",
|
|
127
|
-
SUMMARY: "summary"
|
|
128
|
-
};
|
|
129
|
-
var SensitivityLevel = {
|
|
130
|
-
PUBLIC: "public",
|
|
131
|
-
INTERNAL: "internal",
|
|
132
|
-
SECRET: "secret"
|
|
133
|
-
};
|
|
134
|
-
var RAGStrategy = {
|
|
135
|
-
NAIVE: "naive",
|
|
136
|
-
GRAPH: "graph",
|
|
137
|
-
HYBRID: "hybrid"
|
|
138
|
-
};
|
|
139
|
-
var DEPRECATED_RAG_STRATEGIES = /* @__PURE__ */ new Map([
|
|
140
|
-
["agentic", "strategy.deprecated:agentic \u2014 removed in v0.26, use hybrid"]
|
|
141
|
-
]);
|
|
142
|
-
var VectorProvider = {
|
|
143
|
-
LANCEDB: "lancedb"
|
|
144
|
-
};
|
|
145
|
-
var EmbeddingProviderName = {
|
|
146
|
-
STUB: "stub",
|
|
147
|
-
/** @deprecated Vestigial — pyx-memory uses internal EmbeddingGemma embeddings. */
|
|
148
|
-
ANTHROPIC: "anthropic",
|
|
149
|
-
/** @deprecated Vestigial — pyx-memory uses internal EmbeddingGemma embeddings. */
|
|
150
|
-
OPENAI: "openai",
|
|
151
|
-
/** In-process ONNX model (default: EmbeddingGemma-300M). */
|
|
152
|
-
LOCAL: "local",
|
|
153
|
-
/** Remote OpenAI-compatible embedding service (pyx-cloud shared, custom, etc.). */
|
|
154
|
-
HTTP: "http"
|
|
155
|
-
};
|
|
156
|
-
var StoreTarget = {
|
|
157
|
-
SQLITE: "sqlite",
|
|
158
|
-
VECTOR: "vector",
|
|
159
|
-
GRAPH: "graph"
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// ../shared/src/types/move.ts
|
|
163
|
-
var MoveFailureReason = {
|
|
164
|
-
/** Entry not found in the caller's tenant. */
|
|
165
|
-
NOT_FOUND: "not_found",
|
|
166
|
-
/** Move would cross tenant boundary (always forbidden). */
|
|
167
|
-
CROSS_TENANT_FORBIDDEN: "cross_tenant_forbidden",
|
|
168
|
-
/** Target namespace ID does not exist in the caller's tenant. */
|
|
169
|
-
TARGET_NAMESPACE_NOT_FOUND: "target_namespace_not_found",
|
|
170
|
-
/** SQLite metadata update failed; no compensation needed. */
|
|
171
|
-
SQLITE_UPDATE_FAILED: "sqlite_update_failed",
|
|
172
|
-
/** Vector store metadata update failed; SQLite reverted. */
|
|
173
|
-
VECTOR_UPDATE_FAILED: "vector_update_failed",
|
|
174
|
-
/** Graph edge namespace update failed; SQLite + vector reverted. */
|
|
175
|
-
GRAPH_UPDATE_FAILED: "graph_update_failed",
|
|
176
|
-
/** Compensation itself failed — manual intervention required. */
|
|
177
|
-
COMPENSATION_FAILED: "compensation_failed"
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
// ../shared/src/types/principal.ts
|
|
181
|
-
var SINGLE_TENANT_ID = "_single";
|
|
182
|
-
|
|
183
9
|
// ../client/src/disabled-memory.ts
|
|
184
10
|
var DEFAULT_PAGE_LIMIT = 20;
|
|
185
11
|
var DisabledMemory = class {
|
|
@@ -226,6 +52,46 @@ var DisabledMemory = class {
|
|
|
226
52
|
connected: false
|
|
227
53
|
};
|
|
228
54
|
}
|
|
55
|
+
async insights() {
|
|
56
|
+
return {
|
|
57
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
58
|
+
scope: "connected_memory",
|
|
59
|
+
coverage: {
|
|
60
|
+
retainedAdditions: {
|
|
61
|
+
state: "measured",
|
|
62
|
+
trackingSince: null,
|
|
63
|
+
trackedEntries: 0,
|
|
64
|
+
totalEntries: 0,
|
|
65
|
+
reason: null
|
|
66
|
+
},
|
|
67
|
+
projectLabels: { state: "measured" },
|
|
68
|
+
retrievalUsage: {
|
|
69
|
+
state: "partial",
|
|
70
|
+
reason: "Retrievals count entries returned by search; applied recalls count explicit reinforcement, not successful use."
|
|
71
|
+
},
|
|
72
|
+
tokenEfficiency: {
|
|
73
|
+
state: "not_instrumented",
|
|
74
|
+
reason: "Token savings are not instrumented by the memory store."
|
|
75
|
+
},
|
|
76
|
+
contextAccuracy: {
|
|
77
|
+
state: "not_instrumented",
|
|
78
|
+
reason: "Context accuracy requires outcome evaluation that is not instrumented."
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
summary: {
|
|
82
|
+
activeEntries: 0,
|
|
83
|
+
observedProjectLabels: 0,
|
|
84
|
+
retainedAdditions7d: 0,
|
|
85
|
+
trackedEntries: 0,
|
|
86
|
+
appliedRecalls: 0,
|
|
87
|
+
reinforcedEntries: 0,
|
|
88
|
+
retrievedEntries: 0,
|
|
89
|
+
retrievals: 0
|
|
90
|
+
},
|
|
91
|
+
projects: [],
|
|
92
|
+
other: null
|
|
93
|
+
};
|
|
94
|
+
}
|
|
229
95
|
async queryAsOf() {
|
|
230
96
|
return [];
|
|
231
97
|
}
|
|
@@ -243,7 +109,7 @@ var DisabledMemory = class {
|
|
|
243
109
|
};
|
|
244
110
|
|
|
245
111
|
// ../client/src/memory-client.ts
|
|
246
|
-
function
|
|
112
|
+
function isRecord(value) {
|
|
247
113
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
248
114
|
}
|
|
249
115
|
function normalizeRetryAfter(retryAfter, retryAfterSeconds) {
|
|
@@ -258,18 +124,18 @@ function normalizeRetryAfter(retryAfter, retryAfterSeconds) {
|
|
|
258
124
|
return Number.isSafeInteger(retryAfterSeconds) && retryAfterSeconds >= 0 ? { retryAfterSeconds } : {};
|
|
259
125
|
}
|
|
260
126
|
function structuralHttpStatus(error) {
|
|
261
|
-
if (!
|
|
127
|
+
if (!isRecord(error) || typeof error.status !== "number") return void 0;
|
|
262
128
|
return Number.isSafeInteger(error.status) && error.status >= 400 && error.status < 600 ? error.status : void 0;
|
|
263
129
|
}
|
|
264
130
|
function isFileIngestResult(value) {
|
|
265
|
-
if (!
|
|
131
|
+
if (!isRecord(value)) return false;
|
|
266
132
|
if (typeof value.filename !== "string" || typeof value.fileType !== "string" || typeof value.chunks !== "number" || !Number.isSafeInteger(value.chunks) || value.chunks < 0 || !Array.isArray(value.entryIds) || !value.entryIds.every((id) => typeof id === "string") || typeof value.totalCharacters !== "number" || !Number.isSafeInteger(value.totalCharacters) || value.totalCharacters < 0) {
|
|
267
133
|
return false;
|
|
268
134
|
}
|
|
269
135
|
if (value.graphAnchorEntryId !== void 0 && typeof value.graphAnchorEntryId !== "string") {
|
|
270
136
|
return false;
|
|
271
137
|
}
|
|
272
|
-
if (value.enrichment !== void 0 && !
|
|
138
|
+
if (value.enrichment !== void 0 && !isRecord(value.enrichment)) return false;
|
|
273
139
|
return true;
|
|
274
140
|
}
|
|
275
141
|
function hasEnrichmentCallback(callbacks) {
|
|
@@ -463,6 +329,11 @@ var MemoryClient = class {
|
|
|
463
329
|
const stats = await this.fetchApi(`/api/memory/stats${qs ? `?${qs}` : ""}`);
|
|
464
330
|
return { ...stats, connected: true };
|
|
465
331
|
}
|
|
332
|
+
async insights(options = {}) {
|
|
333
|
+
return this.fetchApi("/api/memory/insights", {
|
|
334
|
+
headers: this.authorityHeaders(options)
|
|
335
|
+
});
|
|
336
|
+
}
|
|
466
337
|
/**
|
|
467
338
|
* Fetch the running server's topology snapshot (build variant, declared
|
|
468
339
|
* role, embedding location, active model profile). Round-trips the
|
|
@@ -1023,7 +894,7 @@ var MemoryClient = class {
|
|
|
1023
894
|
return result;
|
|
1024
895
|
}
|
|
1025
896
|
ingestErrorEvent(error, stage, partialResult) {
|
|
1026
|
-
const structuralError =
|
|
897
|
+
const structuralError = isRecord(error) ? error : void 0;
|
|
1027
898
|
const status = error instanceof MemoryServerError ? error.status : error instanceof Error && error.name === "AbortError" ? 499 : structuralHttpStatus(error);
|
|
1028
899
|
const message = error instanceof Error ? error.message : String(error);
|
|
1029
900
|
const code = error instanceof MemoryServerError ? error.code : void 0;
|
|
@@ -1375,25 +1246,6 @@ var MemoryClient = class {
|
|
|
1375
1246
|
};
|
|
1376
1247
|
|
|
1377
1248
|
export {
|
|
1378
|
-
DEFAULTS,
|
|
1379
|
-
TAXONOMY_MAX_CATEGORIES,
|
|
1380
|
-
documentGraphSource,
|
|
1381
|
-
documentContentSource,
|
|
1382
|
-
documentImageSource,
|
|
1383
|
-
projectSearchResponseForMcp,
|
|
1384
|
-
secretElevationNoticeFor,
|
|
1385
|
-
withSecretElevationNotice,
|
|
1386
|
-
secretElevationAggregate,
|
|
1387
|
-
NamespaceIsolation,
|
|
1388
|
-
MemoryType,
|
|
1389
|
-
SensitivityLevel,
|
|
1390
|
-
RAGStrategy,
|
|
1391
|
-
DEPRECATED_RAG_STRATEGIES,
|
|
1392
|
-
VectorProvider,
|
|
1393
|
-
EmbeddingProviderName,
|
|
1394
|
-
StoreTarget,
|
|
1395
|
-
MoveFailureReason,
|
|
1396
|
-
SINGLE_TENANT_ID,
|
|
1397
1249
|
DisabledMemory,
|
|
1398
1250
|
MemoryServerError,
|
|
1399
1251
|
MemoryClient
|