@codemem/mcp 0.43.0 → 0.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http.js +1 -1
- package/dist/index.js +1 -1
- package/dist/memory-kinds.d.ts +5 -1
- package/dist/memory-kinds.d.ts.map +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/{server-BshtPXit.js → server-Kv95NnLs.js} +222 -241
- package/dist/server-Kv95NnLs.js.map +1 -0
- package/dist/stdio.js +1 -1
- package/package.json +2 -2
- package/dist/server-BshtPXit.js.map +0 -1
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { createHash as e, randomUUID as t } from "node:crypto";
|
|
2
|
-
import {
|
|
3
|
-
import { existsSync as
|
|
4
|
-
import { homedir as
|
|
5
|
-
import { join as
|
|
6
|
-
import { McpServer as
|
|
7
|
-
import { z as
|
|
2
|
+
import { MEMORY_KIND_DESCRIPTIONS as n, ObserverClient as r, REMEMBER_MEMORY_KINDS as i, VERSION as a, buildDistillReport as o, dedupeOrderedIds as s, judgeDistillReport as c, projectMatchesFilter as l, reconcileFailedRetrievalSurface as u, recordRetrievalSurface as d, resolveProject as f, resolveProjectRoot as p, storeVectors as m, toJson as h } from "@codemem/core";
|
|
3
|
+
import { existsSync as g, readFileSync as ee } from "node:fs";
|
|
4
|
+
import { homedir as _ } from "node:os";
|
|
5
|
+
import { join as v } from "node:path";
|
|
6
|
+
import { McpServer as y } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
import { z as b } from "zod";
|
|
8
8
|
//#region src/canonical-json.ts
|
|
9
|
-
function
|
|
9
|
+
function x(e) {
|
|
10
10
|
return JSON.stringify(e, (e, t) => typeof t != "object" || !t || Array.isArray(t) ? t : Object.fromEntries(Object.entries(t).toSorted(([e], [t]) => e < t ? -1 : +(e > t)))) ?? "undefined";
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/project-scope.ts
|
|
14
|
-
function
|
|
14
|
+
function S(e) {
|
|
15
15
|
return e?.trim() || null;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function C() {
|
|
18
|
+
return S(process.env.CODEMEM_PROJECT) ?? f(process.cwd());
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return
|
|
20
|
+
function w(e) {
|
|
21
|
+
return S(e.project) ?? S(e.envProject) ?? null;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
let n = {}, r = !1, i = (typeof e.project == "string" ?
|
|
23
|
+
function T(e, t = C()) {
|
|
24
|
+
let n = {}, r = !1, i = (typeof e.project == "string" ? S(e.project) : void 0) || S(t) || void 0;
|
|
25
25
|
i && (n.project = i, r = !0);
|
|
26
26
|
for (let t of [
|
|
27
27
|
"kind",
|
|
@@ -53,13 +53,13 @@ function w(e, t = S()) {
|
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/content.ts
|
|
56
|
-
function
|
|
56
|
+
function E(e) {
|
|
57
57
|
return { content: [{
|
|
58
58
|
type: "text",
|
|
59
59
|
text: JSON.stringify(e)
|
|
60
60
|
}] };
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function D(e) {
|
|
63
63
|
return { content: [{
|
|
64
64
|
type: "text",
|
|
65
65
|
text: JSON.stringify({ error: e })
|
|
@@ -67,95 +67,87 @@ function E(e) {
|
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/schemas.ts
|
|
70
|
-
var
|
|
71
|
-
scope_id:
|
|
72
|
-
include_scope_ids:
|
|
73
|
-
exclude_scope_ids:
|
|
74
|
-
},
|
|
75
|
-
kind:
|
|
76
|
-
project:
|
|
77
|
-
...
|
|
78
|
-
visibility:
|
|
79
|
-
include_visibility:
|
|
80
|
-
exclude_visibility:
|
|
81
|
-
include_workspace_ids:
|
|
82
|
-
exclude_workspace_ids:
|
|
83
|
-
include_workspace_kinds:
|
|
84
|
-
exclude_workspace_kinds:
|
|
85
|
-
include_actor_ids:
|
|
86
|
-
exclude_actor_ids:
|
|
87
|
-
include_trust_states:
|
|
88
|
-
exclude_trust_states:
|
|
89
|
-
ownership_scope:
|
|
90
|
-
personal_first:
|
|
91
|
-
trust_bias:
|
|
92
|
-
widen_shared_when_weak:
|
|
93
|
-
widen_shared_min_personal_results:
|
|
94
|
-
widen_shared_min_personal_score:
|
|
95
|
-
},
|
|
96
|
-
"discovery",
|
|
97
|
-
"change",
|
|
98
|
-
"feature",
|
|
99
|
-
"bugfix",
|
|
100
|
-
"refactor",
|
|
101
|
-
"decision",
|
|
102
|
-
"exploration"
|
|
103
|
-
]), k = Object.keys(D).toSorted();
|
|
70
|
+
var O = {
|
|
71
|
+
scope_id: b.string().optional().describe("Filter by a single sharing domain scope_id"),
|
|
72
|
+
include_scope_ids: b.array(b.string()).optional().describe("Sharing domain scope_ids to include"),
|
|
73
|
+
exclude_scope_ids: b.array(b.string()).optional().describe("Sharing domain scope_ids to exclude")
|
|
74
|
+
}, k = {
|
|
75
|
+
kind: b.string().optional().describe("Filter by memory kind"),
|
|
76
|
+
project: b.string().optional().describe("Filter by project scope (matches sessions.project)"),
|
|
77
|
+
...O,
|
|
78
|
+
visibility: b.array(b.string()).optional(),
|
|
79
|
+
include_visibility: b.array(b.string()).optional(),
|
|
80
|
+
exclude_visibility: b.array(b.string()).optional(),
|
|
81
|
+
include_workspace_ids: b.array(b.string()).optional(),
|
|
82
|
+
exclude_workspace_ids: b.array(b.string()).optional(),
|
|
83
|
+
include_workspace_kinds: b.array(b.string()).optional(),
|
|
84
|
+
exclude_workspace_kinds: b.array(b.string()).optional(),
|
|
85
|
+
include_actor_ids: b.array(b.string()).optional(),
|
|
86
|
+
exclude_actor_ids: b.array(b.string()).optional(),
|
|
87
|
+
include_trust_states: b.array(b.string()).optional(),
|
|
88
|
+
exclude_trust_states: b.array(b.string()).optional(),
|
|
89
|
+
ownership_scope: b.string().optional(),
|
|
90
|
+
personal_first: b.union([b.boolean(), b.string()]).optional(),
|
|
91
|
+
trust_bias: b.string().optional(),
|
|
92
|
+
widen_shared_when_weak: b.union([b.boolean(), b.string()]).optional(),
|
|
93
|
+
widen_shared_min_personal_results: b.number().int().optional(),
|
|
94
|
+
widen_shared_min_personal_score: b.number().optional()
|
|
95
|
+
}, A = b.enum(i), j = Object.keys(k).toSorted();
|
|
104
96
|
//#endregion
|
|
105
97
|
//#region src/tools/distill.ts
|
|
106
|
-
function
|
|
107
|
-
if (!
|
|
108
|
-
let r =
|
|
98
|
+
function M(e, t, n) {
|
|
99
|
+
if (!g(e)) return null;
|
|
100
|
+
let r = ee(e, "utf8");
|
|
109
101
|
return r.trim() ? {
|
|
110
102
|
path: t,
|
|
111
103
|
text: r,
|
|
112
104
|
scope: n
|
|
113
105
|
} : null;
|
|
114
106
|
}
|
|
115
|
-
function
|
|
116
|
-
let n =
|
|
117
|
-
return [e ?
|
|
107
|
+
function te(e, t = process.cwd()) {
|
|
108
|
+
let n = p(t) ?? t;
|
|
109
|
+
return [e ? M(v(n, "AGENTS.md"), "AGENTS.md", "project") : null, M(v(_(), ".config", "opencode", "AGENTS.md"), "~/.config/opencode/AGENTS.md", "user")].filter((e) => e != null);
|
|
118
110
|
}
|
|
119
|
-
function
|
|
111
|
+
function ne(e, t) {
|
|
120
112
|
if (e.all_projects) return !1;
|
|
121
|
-
let n =
|
|
113
|
+
let n = f(process.cwd());
|
|
122
114
|
if (!n) return !1;
|
|
123
|
-
let r = typeof e.project == "string" ? e.project.trim() : "", i = r ?
|
|
124
|
-
return i ?
|
|
115
|
+
let r = typeof e.project == "string" ? e.project.trim() : "", i = r ? f(process.cwd(), r) : t;
|
|
116
|
+
return i ? l(i, n) : !1;
|
|
125
117
|
}
|
|
126
|
-
function
|
|
118
|
+
function re(e, t) {
|
|
127
119
|
if (e.all_projects && typeof e.project == "string" && e.project.trim()) throw Error("project cannot be combined with all_projects");
|
|
128
|
-
return
|
|
120
|
+
return T(e, e.all_projects ? null : t);
|
|
129
121
|
}
|
|
130
|
-
function
|
|
131
|
-
let { defaultProject:
|
|
122
|
+
function ie(e, t) {
|
|
123
|
+
let { defaultProject: n, store: i } = t;
|
|
132
124
|
e.tool("memory_distill_candidates", "Mine recurring memories into reviewable context candidates. Read-only; does not modify context files.", {
|
|
133
|
-
limit:
|
|
134
|
-
min_recurrence:
|
|
135
|
-
all_projects:
|
|
136
|
-
include_documented:
|
|
137
|
-
max_evidence_items:
|
|
138
|
-
judge:
|
|
139
|
-
...
|
|
125
|
+
limit: b.number().int().min(1).max(50).default(10).describe("Max candidates"),
|
|
126
|
+
min_recurrence: b.number().int().min(1).max(50).default(2).describe("Minimum member count per candidate"),
|
|
127
|
+
all_projects: b.boolean().default(!1).describe("Mine memories across all projects"),
|
|
128
|
+
include_documented: b.boolean().default(!1).describe("Include candidates already represented in context files"),
|
|
129
|
+
max_evidence_items: b.number().int().min(1).max(20).default(5).describe("Evidence snippets per candidate"),
|
|
130
|
+
judge: b.boolean().default(!0).describe("Judge candidates with the observer model and drop routine-activity clusters (on by default; falls back to unjudged output when no observer model is configured)"),
|
|
131
|
+
...k
|
|
140
132
|
}, async (e) => {
|
|
141
133
|
try {
|
|
142
|
-
let t =
|
|
134
|
+
let t = n(), a = re(e, t), s = e.kind ? [e.kind] : void 0, l = e.judge ? Math.min(e.limit * 3, e.limit + 20) : e.limit, u = await o(i, {
|
|
143
135
|
candidate: {
|
|
144
136
|
includeDocumented: e.include_documented,
|
|
145
137
|
maxEvidenceItems: e.max_evidence_items
|
|
146
138
|
},
|
|
147
|
-
contextDocuments:
|
|
139
|
+
contextDocuments: te(ne(e, t)),
|
|
148
140
|
corpus: {
|
|
149
|
-
filters:
|
|
150
|
-
kinds:
|
|
141
|
+
filters: a ?? null,
|
|
142
|
+
kinds: s
|
|
151
143
|
},
|
|
152
144
|
limit: l,
|
|
153
145
|
minRecurrence: e.min_recurrence
|
|
154
146
|
});
|
|
155
147
|
if (e.judge) {
|
|
156
148
|
try {
|
|
157
|
-
let e = new
|
|
158
|
-
u = await
|
|
149
|
+
let e = new r();
|
|
150
|
+
u = await c(u, async (t, n) => (await e.observe(t, n)).raw);
|
|
159
151
|
} catch (e) {
|
|
160
152
|
let t = e instanceof Error ? e.message : String(e);
|
|
161
153
|
u = {
|
|
@@ -176,31 +168,31 @@ function te(e, t) {
|
|
|
176
168
|
}
|
|
177
169
|
});
|
|
178
170
|
}
|
|
179
|
-
return
|
|
171
|
+
return E(u);
|
|
180
172
|
} catch (e) {
|
|
181
|
-
return
|
|
173
|
+
return D(e instanceof Error ? e.message : String(e));
|
|
182
174
|
}
|
|
183
175
|
});
|
|
184
176
|
}
|
|
185
177
|
//#endregion
|
|
186
178
|
//#region src/mcp-retrieval-ledger.ts
|
|
187
|
-
var
|
|
188
|
-
function
|
|
179
|
+
var N = 300 * 1e3, P = 2e3, F = /* @__PURE__ */ new WeakMap(), I = 0;
|
|
180
|
+
function L(e, t, n) {
|
|
189
181
|
if (e.captureRetrievalLedger) try {
|
|
190
|
-
let r =
|
|
191
|
-
n && !r.ok && r.reason === "idempotency_conflict" && (t.retrievalStatus === "succeeded" && t.deliveryStatus === "handed_off" || t.retrievalStatus === "no_results" && t.deliveryStatus === "not_attempted") &&
|
|
182
|
+
let r = d(e.store.db, t);
|
|
183
|
+
n && !r.ok && r.reason === "idempotency_conflict" && (t.retrievalStatus === "succeeded" && t.deliveryStatus === "handed_off" || t.retrievalStatus === "no_results" && t.deliveryStatus === "not_attempted") && u(e.store.db, t);
|
|
192
184
|
} catch {}
|
|
193
185
|
}
|
|
194
|
-
function
|
|
186
|
+
function R(e) {
|
|
195
187
|
if (e == null) return t();
|
|
196
188
|
let n = e.slice(0, 32).split("");
|
|
197
189
|
n[12] = "5", n[16] = (Number.parseInt(n[16] ?? "0", 16) & 3 | 8).toString(16);
|
|
198
190
|
let r = n.join("");
|
|
199
191
|
return `${r.slice(0, 8)}-${r.slice(8, 12)}-${r.slice(12, 16)}-${r.slice(16, 20)}-${r.slice(20)}`;
|
|
200
192
|
}
|
|
201
|
-
function
|
|
193
|
+
function z(t, n) {
|
|
202
194
|
if (n.requestId == null) return null;
|
|
203
|
-
let r = e("sha256").update(
|
|
195
|
+
let r = e("sha256").update(x({
|
|
204
196
|
method: "tools/call",
|
|
205
197
|
params: {
|
|
206
198
|
name: n.toolName,
|
|
@@ -213,8 +205,8 @@ function R(t, n) {
|
|
|
213
205
|
r
|
|
214
206
|
])).digest("hex");
|
|
215
207
|
}
|
|
216
|
-
function
|
|
217
|
-
let t =
|
|
208
|
+
function B(e) {
|
|
209
|
+
let t = F.get(e);
|
|
218
210
|
return t || (t = {
|
|
219
211
|
byInvocation: /* @__PURE__ */ new WeakMap(),
|
|
220
212
|
activeByRequest: /* @__PURE__ */ new Map(),
|
|
@@ -222,14 +214,14 @@ function z(e) {
|
|
|
222
214
|
pendingFailureCount: 0,
|
|
223
215
|
nextPendingFailureOrder: 0,
|
|
224
216
|
nextInvocationSequence: 0
|
|
225
|
-
},
|
|
217
|
+
}, F.set(e, t)), t;
|
|
226
218
|
}
|
|
227
|
-
function
|
|
219
|
+
function V(e, t) {
|
|
228
220
|
for (let [n, r] of e.pendingFailures) {
|
|
229
221
|
let i = r.filter((e) => e.expiresAt > t);
|
|
230
222
|
e.pendingFailureCount -= r.length - i.length, i.length === 0 ? e.pendingFailures.delete(n) : i.length !== r.length && e.pendingFailures.set(n, i);
|
|
231
223
|
}
|
|
232
|
-
for (; e.pendingFailureCount >
|
|
224
|
+
for (; e.pendingFailureCount > P;) {
|
|
233
225
|
let t, n = Infinity;
|
|
234
226
|
for (let [r, i] of e.pendingFailures) {
|
|
235
227
|
let e = i[0]?.order;
|
|
@@ -244,25 +236,25 @@ function B(e, t) {
|
|
|
244
236
|
--e.pendingFailureCount, r.length === 0 && e.pendingFailures.delete(t);
|
|
245
237
|
}
|
|
246
238
|
}
|
|
247
|
-
function
|
|
239
|
+
function H(e, t) {
|
|
248
240
|
let n = e.pendingFailures.get(t);
|
|
249
241
|
if (!n) return;
|
|
250
242
|
let r = n.shift();
|
|
251
243
|
if (r) return --e.pendingFailureCount, n.length === 0 && e.pendingFailures.delete(t), r.identity;
|
|
252
244
|
}
|
|
253
|
-
function
|
|
245
|
+
function U(e, t, n) {
|
|
254
246
|
let r = e.pendingFailures.get(t), i = r?.findIndex((e) => e.identity.attemptId === n) ?? -1;
|
|
255
247
|
!r || i < 0 || (r.splice(i, 1), --e.pendingFailureCount, r.length === 0 && e.pendingFailures.delete(t));
|
|
256
248
|
}
|
|
257
|
-
function
|
|
249
|
+
function W(e, t, n, r) {
|
|
258
250
|
let i = e.pendingFailures.get(t) ?? [];
|
|
259
251
|
i.some((e) => e.identity.attemptId === n.attemptId) || (i.push({
|
|
260
252
|
identity: n,
|
|
261
|
-
expiresAt: r +
|
|
253
|
+
expiresAt: r + N,
|
|
262
254
|
order: e.nextPendingFailureOrder
|
|
263
|
-
}), e.nextPendingFailureOrder += 1, e.pendingFailures.set(t, i), e.pendingFailureCount += 1,
|
|
255
|
+
}), e.nextPendingFailureOrder += 1, e.pendingFailures.set(t, i), e.pendingFailureCount += 1, V(e, r));
|
|
264
256
|
}
|
|
265
|
-
function
|
|
257
|
+
function G() {
|
|
266
258
|
try {
|
|
267
259
|
return {
|
|
268
260
|
baseRequestId: null,
|
|
@@ -270,26 +262,26 @@ function W() {
|
|
|
270
262
|
attemptId: t()
|
|
271
263
|
};
|
|
272
264
|
} catch {
|
|
273
|
-
let e = Date.now().toString(16).slice(-8).padStart(8, "0"), t =
|
|
274
|
-
return
|
|
265
|
+
let e = Date.now().toString(16).slice(-8).padStart(8, "0"), t = I.toString(16).slice(-4).padStart(4, "0");
|
|
266
|
+
return I = (I + 1) % 65536, {
|
|
275
267
|
baseRequestId: null,
|
|
276
268
|
requestId: null,
|
|
277
269
|
attemptId: `00000000-0000-4000-8000-${e}${t}`
|
|
278
270
|
};
|
|
279
271
|
}
|
|
280
272
|
}
|
|
281
|
-
function
|
|
282
|
-
let r =
|
|
273
|
+
function K(t, n) {
|
|
274
|
+
let r = z(t, n);
|
|
283
275
|
if (t.retrievalLedgerIdentityMode === "stateless" || r == null) return {
|
|
284
276
|
baseRequestId: r,
|
|
285
277
|
requestId: r,
|
|
286
|
-
attemptId:
|
|
278
|
+
attemptId: R(r)
|
|
287
279
|
};
|
|
288
|
-
let i =
|
|
289
|
-
|
|
280
|
+
let i = B(t);
|
|
281
|
+
V(i, Date.now());
|
|
290
282
|
let a = n.invocationIdentity ? i.byInvocation.get(n.invocationIdentity) : void 0, o = a?.baseRequestId === r ? a : void 0;
|
|
291
283
|
if (!o) {
|
|
292
|
-
let a = (i.activeByRequest.get(r) ?? 0) === 0 ?
|
|
284
|
+
let a = (i.activeByRequest.get(r) ?? 0) === 0 ? H(i, r) : void 0;
|
|
293
285
|
if (a) o = a;
|
|
294
286
|
else {
|
|
295
287
|
let n = i.nextInvocationSequence;
|
|
@@ -302,36 +294,36 @@ function G(t, n) {
|
|
|
302
294
|
o = {
|
|
303
295
|
baseRequestId: r,
|
|
304
296
|
requestId: a,
|
|
305
|
-
attemptId:
|
|
297
|
+
attemptId: R(a)
|
|
306
298
|
};
|
|
307
299
|
}
|
|
308
300
|
n.invocationIdentity && i.byInvocation.set(n.invocationIdentity, o);
|
|
309
301
|
}
|
|
310
302
|
return i.activeByRequest.set(r, (i.activeByRequest.get(r) ?? 0) + 1), o;
|
|
311
303
|
}
|
|
312
|
-
function
|
|
304
|
+
function q(e, t) {
|
|
313
305
|
try {
|
|
314
|
-
return
|
|
306
|
+
return K(e, t);
|
|
315
307
|
} catch {
|
|
316
|
-
return
|
|
308
|
+
return G();
|
|
317
309
|
}
|
|
318
310
|
}
|
|
319
|
-
function
|
|
311
|
+
function J(e, t, n) {
|
|
320
312
|
if (e.retrievalLedgerIdentityMode === "stateless" || t.baseRequestId == null) return;
|
|
321
|
-
let r =
|
|
322
|
-
i <= 1 ? r.activeByRequest.delete(t.baseRequestId) : r.activeByRequest.set(t.baseRequestId, i - 1), n === "failed" ?
|
|
313
|
+
let r = B(e), i = r.activeByRequest.get(t.baseRequestId) ?? 0;
|
|
314
|
+
i <= 1 ? r.activeByRequest.delete(t.baseRequestId) : r.activeByRequest.set(t.baseRequestId, i - 1), n === "failed" ? W(r, t.baseRequestId, t, Date.now()) : U(r, t.baseRequestId, t.attemptId);
|
|
323
315
|
}
|
|
324
|
-
function
|
|
316
|
+
function Y(e, t, n) {
|
|
325
317
|
try {
|
|
326
|
-
|
|
318
|
+
J(e, t, n);
|
|
327
319
|
} catch {}
|
|
328
320
|
}
|
|
329
|
-
async function
|
|
330
|
-
let r =
|
|
321
|
+
async function X(e, t, n) {
|
|
322
|
+
let r = q(e, t), i = r.requestId, a = r.attemptId, o = /* @__PURE__ */ new Date(), s;
|
|
331
323
|
try {
|
|
332
324
|
s = t.resolveFilters?.();
|
|
333
|
-
let c = await n(s), l = /* @__PURE__ */ new Date(), u = c.error ?
|
|
334
|
-
return
|
|
325
|
+
let c = await n(s), l = /* @__PURE__ */ new Date(), u = c.error ? D(c.error) : E(c.value), d = t.sourceSessionId ?? e.retrievalLedgerScopeId, f = c.memoryIds.length > 0, p = c.error === "not_found" && !f, m = c.error != null && !p || c.retrievalStatus === "failed" && !f, h = m ? [] : c.memoryIds, g = c.retrievalStatus === "unknown" ? "unknown" : "succeeded";
|
|
326
|
+
return L(e, {
|
|
335
327
|
attemptId: a,
|
|
336
328
|
surface: t.surface,
|
|
337
329
|
trigger: "explicit",
|
|
@@ -353,10 +345,10 @@ async function Y(e, t, n) {
|
|
|
353
345
|
limitRequested: t.limit,
|
|
354
346
|
failureCode: m ? "tool_failed" : void 0,
|
|
355
347
|
failureStage: m ? "retrieval" : void 0
|
|
356
|
-
}, !m),
|
|
348
|
+
}, !m), Y(e, r, m ? "failed" : "completed"), u;
|
|
357
349
|
} catch (n) {
|
|
358
350
|
let c = /* @__PURE__ */ new Date(), l = t.sourceSessionId ?? e.retrievalLedgerScopeId;
|
|
359
|
-
return
|
|
351
|
+
return L(e, {
|
|
360
352
|
attemptId: a,
|
|
361
353
|
surface: t.surface,
|
|
362
354
|
trigger: "explicit",
|
|
@@ -377,34 +369,34 @@ async function Y(e, t, n) {
|
|
|
377
369
|
filters: s,
|
|
378
370
|
failureCode: "tool_failed",
|
|
379
371
|
failureStage: "retrieval"
|
|
380
|
-
}, !1),
|
|
372
|
+
}, !1), Y(e, r, "failed"), D(n instanceof Error ? n.message : String(n));
|
|
381
373
|
}
|
|
382
374
|
}
|
|
383
375
|
//#endregion
|
|
384
376
|
//#region src/memory-access.ts
|
|
385
|
-
function
|
|
377
|
+
function Z(e, t, n) {
|
|
386
378
|
return e.timeline(null, t, 0, 0, n ?? null).find((e) => e.id === t) ?? null;
|
|
387
379
|
}
|
|
388
|
-
function
|
|
380
|
+
function Q(e, t, n) {
|
|
389
381
|
if (t.length === 0) return [];
|
|
390
382
|
let r = [];
|
|
391
383
|
for (let i of t) {
|
|
392
|
-
let t =
|
|
384
|
+
let t = Z(e, i, n);
|
|
393
385
|
t && r.push(t);
|
|
394
386
|
}
|
|
395
387
|
return r;
|
|
396
388
|
}
|
|
397
|
-
function
|
|
398
|
-
return
|
|
389
|
+
function ae(e, t, n) {
|
|
390
|
+
return Z(e, t, n) ? (e.forget(t), !0) : !1;
|
|
399
391
|
}
|
|
400
|
-
function
|
|
392
|
+
function oe(e, t, n = {}) {
|
|
401
393
|
return e.db.transaction(() => {
|
|
402
|
-
let r = n.now?.() ?? (/* @__PURE__ */ new Date()).toISOString(), i = n.user ?? process.env.USER ?? "unknown", a = n.cwd ?? process.cwd(), o =
|
|
394
|
+
let r = n.now?.() ?? (/* @__PURE__ */ new Date()).toISOString(), i = n.user ?? process.env.USER ?? "unknown", a = n.cwd ?? process.cwd(), o = w({
|
|
403
395
|
project: t.project,
|
|
404
396
|
envProject: n.envProject
|
|
405
|
-
}), s = e.db.prepare("INSERT INTO sessions(started_at, ended_at, cwd, project, user, tool_version, metadata_json)\n VALUES (?, ?, ?, ?, ?, ?, ?)").run(r, r, a, o, i, "mcp-ts",
|
|
406
|
-
if (!
|
|
407
|
-
return e.db.prepare("UPDATE sessions SET ended_at = ?, metadata_json = ? WHERE id = ?").run(n.now?.() ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
397
|
+
}), s = e.db.prepare("INSERT INTO sessions(started_at, ended_at, cwd, project, user, tool_version, metadata_json)\n VALUES (?, ?, ?, ?, ?, ?, ?)").run(r, r, a, o, i, "mcp-ts", h({ mcp: !0 })), c = Number(s.lastInsertRowid), l = e.remember(c, t.kind, t.title, t.body, t.confidence);
|
|
398
|
+
if (!Z(e, l)) throw Error("unauthorized_scope");
|
|
399
|
+
return e.db.prepare("UPDATE sessions SET ended_at = ?, metadata_json = ? WHERE id = ?").run(n.now?.() ?? (/* @__PURE__ */ new Date()).toISOString(), h({ mcp: !0 }), c), {
|
|
408
400
|
memId: l,
|
|
409
401
|
title: t.title,
|
|
410
402
|
body: t.body
|
|
@@ -413,22 +405,22 @@ function ae(e, t, n = {}) {
|
|
|
413
405
|
}
|
|
414
406
|
//#endregion
|
|
415
407
|
//#region src/tools/items.ts
|
|
416
|
-
function
|
|
408
|
+
function se(e, t) {
|
|
417
409
|
let { envProject: n, store: r } = t;
|
|
418
410
|
e.tool("memory_get", "Fetch a single memory item by ID.", {
|
|
419
|
-
memory_id:
|
|
420
|
-
...
|
|
421
|
-
}, async (e, n) =>
|
|
411
|
+
memory_id: b.number().int().describe("Memory ID"),
|
|
412
|
+
...k
|
|
413
|
+
}, async (e, n) => X(t, {
|
|
422
414
|
surface: "mcp_get",
|
|
423
415
|
toolName: "memory_get",
|
|
424
416
|
toolArguments: e,
|
|
425
417
|
limit: 1,
|
|
426
|
-
resolveFilters: () =>
|
|
418
|
+
resolveFilters: () => T(e, null),
|
|
427
419
|
requestId: n?.requestId,
|
|
428
420
|
sourceSessionId: n?.sessionId,
|
|
429
421
|
invocationIdentity: n?.signal
|
|
430
422
|
}, (t) => {
|
|
431
|
-
let n =
|
|
423
|
+
let n = Z(r, e.memory_id, t);
|
|
432
424
|
return n ? {
|
|
433
425
|
value: n,
|
|
434
426
|
memoryIds: [n.id],
|
|
@@ -440,55 +432,55 @@ function oe(e, t) {
|
|
|
440
432
|
filters: t
|
|
441
433
|
};
|
|
442
434
|
})), e.tool("memory_get_observations", "Fetch multiple memory items by their IDs.", {
|
|
443
|
-
ids:
|
|
444
|
-
...
|
|
445
|
-
}, async (e, n) =>
|
|
435
|
+
ids: b.array(b.number().int()).max(200).describe("Memory IDs to fetch"),
|
|
436
|
+
...k
|
|
437
|
+
}, async (e, n) => X(t, {
|
|
446
438
|
surface: "mcp_get_observations",
|
|
447
439
|
toolName: "memory_get_observations",
|
|
448
440
|
toolArguments: e,
|
|
449
441
|
limit: e.ids.length,
|
|
450
|
-
resolveFilters: () =>
|
|
442
|
+
resolveFilters: () => T(e, null),
|
|
451
443
|
requestId: n?.requestId,
|
|
452
444
|
sourceSessionId: n?.sessionId,
|
|
453
445
|
invocationIdentity: n?.signal
|
|
454
446
|
}, (t) => {
|
|
455
|
-
let n =
|
|
447
|
+
let n = Q(r, e.ids, t);
|
|
456
448
|
return {
|
|
457
449
|
value: { items: n },
|
|
458
450
|
memoryIds: n.map((e) => e.id),
|
|
459
451
|
filters: t
|
|
460
452
|
};
|
|
461
453
|
})), e.tool("memory_remember", "Create a new memory. Use for milestones, decisions, and notable facts.", {
|
|
462
|
-
kind:
|
|
463
|
-
title:
|
|
464
|
-
body:
|
|
465
|
-
confidence:
|
|
466
|
-
project:
|
|
454
|
+
kind: A.describe("Memory kind"),
|
|
455
|
+
title: b.string().describe("Short title"),
|
|
456
|
+
body: b.string().describe("Body text (high-signal content)"),
|
|
457
|
+
confidence: b.number().min(0).max(1).default(.5).describe("Confidence 0-1"),
|
|
458
|
+
project: b.string().optional().describe("Project identifier")
|
|
467
459
|
}, async (e) => {
|
|
468
460
|
try {
|
|
469
|
-
let t =
|
|
461
|
+
let t = oe(r, e, { envProject: n() });
|
|
470
462
|
try {
|
|
471
|
-
await
|
|
463
|
+
await m(r.db, t.memId, t.title, t.body);
|
|
472
464
|
} catch {}
|
|
473
|
-
return
|
|
465
|
+
return E({ id: t.memId });
|
|
474
466
|
} catch (e) {
|
|
475
|
-
return
|
|
467
|
+
return D(e instanceof Error ? e.message : String(e));
|
|
476
468
|
}
|
|
477
469
|
}), e.tool("memory_forget", "Soft-delete a memory item. Use for incorrect or sensitive data.", {
|
|
478
|
-
memory_id:
|
|
479
|
-
...
|
|
470
|
+
memory_id: b.number().int().describe("Memory ID to forget"),
|
|
471
|
+
...k
|
|
480
472
|
}, async (e) => {
|
|
481
473
|
try {
|
|
482
|
-
return
|
|
474
|
+
return ae(r, e.memory_id, T(e, null)) ? E({ status: "ok" }) : D("not_found");
|
|
483
475
|
} catch (e) {
|
|
484
|
-
return
|
|
476
|
+
return D(e instanceof Error ? e.message : String(e));
|
|
485
477
|
}
|
|
486
478
|
});
|
|
487
479
|
}
|
|
488
480
|
//#endregion
|
|
489
481
|
//#region src/tools/learn.ts
|
|
490
|
-
function
|
|
491
|
-
e.tool("memory_learn", "Learn how to use codemem memory tools. Call this first if unfamiliar.", {}, async () =>
|
|
482
|
+
function ce(e) {
|
|
483
|
+
e.tool("memory_learn", "Learn how to use codemem memory tools. Call this first if unfamiliar.", {}, async () => E({
|
|
492
484
|
intro: "Use this tool when you're new to codemem or unsure when to recall/persist.",
|
|
493
485
|
client_hint: "If you are unfamiliar with codemem, call memory.learn first.",
|
|
494
486
|
recall: {
|
|
@@ -556,22 +548,11 @@ function se(e) {
|
|
|
556
548
|
}));
|
|
557
549
|
}
|
|
558
550
|
//#endregion
|
|
559
|
-
//#region src/memory-kinds.ts
|
|
560
|
-
var Q = {
|
|
561
|
-
discovery: "Something learned about the codebase, architecture, or tools",
|
|
562
|
-
change: "A code change that was made",
|
|
563
|
-
feature: "A new feature that was implemented",
|
|
564
|
-
bugfix: "A bug that was found and fixed",
|
|
565
|
-
refactor: "Code that was refactored or restructured",
|
|
566
|
-
decision: "A design or architecture decision",
|
|
567
|
-
exploration: "An experiment or investigation (may not have shipped)"
|
|
568
|
-
};
|
|
569
|
-
//#endregion
|
|
570
551
|
//#region src/tools/schema.ts
|
|
571
|
-
function
|
|
572
|
-
e.tool("memory_schema", "Return the memory schema — kinds, fields, and available filters.", {}, async () =>
|
|
573
|
-
kinds: Object.keys(
|
|
574
|
-
kind_descriptions:
|
|
552
|
+
function le(e) {
|
|
553
|
+
e.tool("memory_schema", "Return the memory schema — kinds, fields, and available filters.", {}, async () => E({
|
|
554
|
+
kinds: Object.keys(n),
|
|
555
|
+
kind_descriptions: n,
|
|
575
556
|
fields: {
|
|
576
557
|
title: "short text",
|
|
577
558
|
body: "long text",
|
|
@@ -583,24 +564,24 @@ function ce(e) {
|
|
|
583
564
|
files_modified: "list<string>",
|
|
584
565
|
prompt_number: "int"
|
|
585
566
|
},
|
|
586
|
-
filters:
|
|
567
|
+
filters: j
|
|
587
568
|
}));
|
|
588
569
|
}
|
|
589
570
|
//#endregion
|
|
590
571
|
//#region src/tools/search.ts
|
|
591
|
-
function
|
|
572
|
+
function $(e, t) {
|
|
592
573
|
let { defaultProject: n, store: r } = t;
|
|
593
574
|
e.tool("memory_search", "Search memories by text query. Returns full body text for each match.", {
|
|
594
|
-
query:
|
|
595
|
-
limit:
|
|
596
|
-
...
|
|
597
|
-
}, async (e, i) =>
|
|
575
|
+
query: b.string().describe("Search query"),
|
|
576
|
+
limit: b.number().int().min(1).max(50).default(5).describe("Max results"),
|
|
577
|
+
...k
|
|
578
|
+
}, async (e, i) => X(t, {
|
|
598
579
|
surface: "mcp_search",
|
|
599
580
|
toolName: "memory_search",
|
|
600
581
|
toolArguments: e,
|
|
601
582
|
query: e.query,
|
|
602
583
|
limit: e.limit,
|
|
603
|
-
resolveFilters: () =>
|
|
584
|
+
resolveFilters: () => T(e, n()),
|
|
604
585
|
requestId: i?.requestId,
|
|
605
586
|
sourceSessionId: i?.sessionId,
|
|
606
587
|
invocationIdentity: i?.signal
|
|
@@ -621,16 +602,16 @@ function le(e, t) {
|
|
|
621
602
|
filters: t
|
|
622
603
|
};
|
|
623
604
|
})), e.tool("memory_search_index", "Search memories by text query. Returns compact index entries (no body) for browsing.", {
|
|
624
|
-
query:
|
|
625
|
-
limit:
|
|
626
|
-
...
|
|
627
|
-
}, async (e, i) =>
|
|
605
|
+
query: b.string().describe("Search query"),
|
|
606
|
+
limit: b.number().int().min(1).max(50).default(8).describe("Max results"),
|
|
607
|
+
...k
|
|
608
|
+
}, async (e, i) => X(t, {
|
|
628
609
|
surface: "mcp_search_index",
|
|
629
610
|
toolName: "memory_search_index",
|
|
630
611
|
toolArguments: e,
|
|
631
612
|
query: e.query,
|
|
632
613
|
limit: e.limit,
|
|
633
|
-
resolveFilters: () =>
|
|
614
|
+
resolveFilters: () => T(e, n()),
|
|
634
615
|
requestId: i?.requestId,
|
|
635
616
|
sourceSessionId: i?.sessionId,
|
|
636
617
|
invocationIdentity: i?.signal
|
|
@@ -650,18 +631,18 @@ function le(e, t) {
|
|
|
650
631
|
filters: t
|
|
651
632
|
};
|
|
652
633
|
})), e.tool("memory_explain", "Explain search results with detailed scoring breakdown.", {
|
|
653
|
-
query:
|
|
654
|
-
ids:
|
|
655
|
-
limit:
|
|
656
|
-
include_pack_context:
|
|
657
|
-
...
|
|
658
|
-
}, async (e, i) =>
|
|
634
|
+
query: b.string().optional().describe("Search query"),
|
|
635
|
+
ids: b.array(b.number().int()).max(200).optional().describe("Specific memory IDs to explain"),
|
|
636
|
+
limit: b.number().int().min(1).max(50).default(10).describe("Max results"),
|
|
637
|
+
include_pack_context: b.boolean().default(!1).describe("Include formatted pack context"),
|
|
638
|
+
...k
|
|
639
|
+
}, async (e, i) => X(t, {
|
|
659
640
|
surface: "mcp_explain",
|
|
660
641
|
toolName: "memory_explain",
|
|
661
642
|
toolArguments: e,
|
|
662
643
|
query: e.query,
|
|
663
644
|
limit: e.limit,
|
|
664
|
-
resolveFilters: () =>
|
|
645
|
+
resolveFilters: () => T(e, n()),
|
|
665
646
|
requestId: i?.requestId,
|
|
666
647
|
sourceSessionId: i?.sessionId,
|
|
667
648
|
invocationIdentity: i?.signal
|
|
@@ -674,14 +655,14 @@ function le(e, t) {
|
|
|
674
655
|
retrievalStatus: i ? "failed" : void 0
|
|
675
656
|
};
|
|
676
657
|
})), e.tool("memory_recent", "Return recent memories, newest first.", {
|
|
677
|
-
limit:
|
|
678
|
-
...
|
|
679
|
-
}, async (e, i) =>
|
|
658
|
+
limit: b.number().int().min(1).max(100).default(8).describe("Max results"),
|
|
659
|
+
...k
|
|
660
|
+
}, async (e, i) => X(t, {
|
|
680
661
|
surface: "mcp_recent",
|
|
681
662
|
toolName: "memory_recent",
|
|
682
663
|
toolArguments: e,
|
|
683
664
|
limit: e.limit,
|
|
684
|
-
resolveFilters: () =>
|
|
665
|
+
resolveFilters: () => T(e, n()),
|
|
685
666
|
requestId: i?.requestId,
|
|
686
667
|
sourceSessionId: i?.sessionId,
|
|
687
668
|
invocationIdentity: i?.signal
|
|
@@ -693,23 +674,23 @@ function le(e, t) {
|
|
|
693
674
|
filters: t
|
|
694
675
|
};
|
|
695
676
|
})), e.tool("memory_pack", "Build a formatted memory pack from search results — quick one-shot context block.", {
|
|
696
|
-
context:
|
|
697
|
-
limit:
|
|
698
|
-
compact:
|
|
699
|
-
compact_detail_count:
|
|
700
|
-
compression_mode:
|
|
677
|
+
context: b.string().describe("Context description to search for"),
|
|
678
|
+
limit: b.number().int().min(1).max(50).optional().describe("Max items to include"),
|
|
679
|
+
compact: b.boolean().optional().describe("When true, render a scannable index of all items with full detail only for the top N (default 3). Saves tokens when broad overview matters more than per-item detail."),
|
|
680
|
+
compact_detail_count: b.number().int().min(0).max(50).optional().describe("Number of items to show in full detail in compact mode (default 3)"),
|
|
681
|
+
compression_mode: b.enum([
|
|
701
682
|
"off",
|
|
702
683
|
"compact",
|
|
703
684
|
"ids"
|
|
704
685
|
]).optional().describe("Near-related compression mode: off disables it, compact applies only to compact rendering, ids applies in all modes. Defaults to CODEMEM_PACK_COMPRESSION or compact."),
|
|
705
|
-
...
|
|
706
|
-
}, async (e, i) =>
|
|
686
|
+
...k
|
|
687
|
+
}, async (e, i) => X(t, {
|
|
707
688
|
surface: "mcp_pack",
|
|
708
689
|
toolName: "memory_pack",
|
|
709
690
|
toolArguments: e,
|
|
710
691
|
query: e.context,
|
|
711
692
|
limit: e.limit ?? null,
|
|
712
|
-
resolveFilters: () =>
|
|
693
|
+
resolveFilters: () => T(e, n()),
|
|
713
694
|
requestId: i?.requestId,
|
|
714
695
|
sourceSessionId: i?.sessionId,
|
|
715
696
|
invocationIdentity: i?.signal
|
|
@@ -728,21 +709,21 @@ function le(e, t) {
|
|
|
728
709
|
}
|
|
729
710
|
//#endregion
|
|
730
711
|
//#region src/tools/timeline.ts
|
|
731
|
-
function
|
|
712
|
+
function ue(e, t) {
|
|
732
713
|
let { defaultProject: n, store: r } = t;
|
|
733
714
|
e.tool("memory_timeline", "Get a chronological window of memories around an anchor (by ID or query).", {
|
|
734
|
-
query:
|
|
735
|
-
memory_id:
|
|
736
|
-
depth_before:
|
|
737
|
-
depth_after:
|
|
738
|
-
...
|
|
739
|
-
}, async (e, i) =>
|
|
715
|
+
query: b.string().optional().describe("Search query to find anchor"),
|
|
716
|
+
memory_id: b.number().int().optional().describe("Anchor memory ID"),
|
|
717
|
+
depth_before: b.number().int().min(0).default(3).describe("Items before anchor"),
|
|
718
|
+
depth_after: b.number().int().min(0).default(3).describe("Items after anchor"),
|
|
719
|
+
...k
|
|
720
|
+
}, async (e, i) => X(t, {
|
|
740
721
|
surface: "mcp_timeline",
|
|
741
722
|
toolName: "memory_timeline",
|
|
742
723
|
toolArguments: e,
|
|
743
724
|
query: e.query,
|
|
744
725
|
limit: e.depth_before + e.depth_after + 1,
|
|
745
|
-
resolveFilters: () =>
|
|
726
|
+
resolveFilters: () => T(e, n()),
|
|
746
727
|
requestId: i?.requestId,
|
|
747
728
|
sourceSessionId: i?.sessionId,
|
|
748
729
|
invocationIdentity: i?.signal
|
|
@@ -754,33 +735,33 @@ function $(e, t) {
|
|
|
754
735
|
filters: t
|
|
755
736
|
};
|
|
756
737
|
})), e.tool("memory_expand", "Fetch memories by ID with surrounding timeline context.", {
|
|
757
|
-
ids:
|
|
758
|
-
depth_before:
|
|
759
|
-
depth_after:
|
|
760
|
-
include_observations:
|
|
761
|
-
...
|
|
762
|
-
}, async (e, i) =>
|
|
738
|
+
ids: b.array(b.union([b.number(), b.string()])).max(200).describe("Memory IDs to expand"),
|
|
739
|
+
depth_before: b.number().int().min(0).default(3).describe("Timeline items before"),
|
|
740
|
+
depth_after: b.number().int().min(0).default(3).describe("Timeline items after"),
|
|
741
|
+
include_observations: b.boolean().default(!1).describe("Include full observation details"),
|
|
742
|
+
...k
|
|
743
|
+
}, async (e, i) => X(t, {
|
|
763
744
|
surface: "mcp_expand",
|
|
764
745
|
toolName: "memory_expand",
|
|
765
746
|
toolArguments: e,
|
|
766
747
|
limit: e.ids.length,
|
|
767
|
-
resolveFilters: () =>
|
|
748
|
+
resolveFilters: () => T(e, e.project !== void 0 && !e.project.trim() ? null : n()),
|
|
768
749
|
requestId: i?.requestId,
|
|
769
750
|
sourceSessionId: i?.sessionId,
|
|
770
751
|
invocationIdentity: i?.signal
|
|
771
752
|
}, (t) => {
|
|
772
|
-
let n = t?.project ?? null, { ordered: i, invalid:
|
|
773
|
-
|
|
753
|
+
let n = t?.project ?? null, { ordered: i, invalid: a } = s(e.ids), o = [];
|
|
754
|
+
a.length > 0 && o.push({
|
|
774
755
|
code: "INVALID_ARGUMENT",
|
|
775
756
|
field: "ids",
|
|
776
757
|
message: "some ids are not valid integers",
|
|
777
|
-
ids:
|
|
758
|
+
ids: a
|
|
778
759
|
});
|
|
779
|
-
let
|
|
760
|
+
let c = [], u = [], d = [], f = [], p = [], m = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
|
|
780
761
|
for (let a of i) {
|
|
781
762
|
let i = r.get(a);
|
|
782
763
|
if (!i?.active) {
|
|
783
|
-
|
|
764
|
+
c.push(a);
|
|
784
765
|
continue;
|
|
785
766
|
}
|
|
786
767
|
let o = i.session_id;
|
|
@@ -789,7 +770,7 @@ function $(e, t) {
|
|
|
789
770
|
let e = r.db.prepare("SELECT project FROM sessions WHERE id = ? LIMIT 1").get(o);
|
|
790
771
|
h.set(o, typeof e?.project == "string" ? e.project : null);
|
|
791
772
|
}
|
|
792
|
-
if (!
|
|
773
|
+
if (!l(n, h.get(o) ?? null)) {
|
|
793
774
|
u.push(a);
|
|
794
775
|
continue;
|
|
795
776
|
}
|
|
@@ -797,28 +778,28 @@ function $(e, t) {
|
|
|
797
778
|
u.push(a);
|
|
798
779
|
continue;
|
|
799
780
|
}
|
|
800
|
-
let
|
|
781
|
+
let s = r.timeline(null, a, e.depth_before, e.depth_after, t), g = s.find((e) => e.id === a);
|
|
801
782
|
if (!g) {
|
|
802
783
|
d.push(a);
|
|
803
784
|
continue;
|
|
804
785
|
}
|
|
805
786
|
f.push(g);
|
|
806
|
-
for (let e of
|
|
787
|
+
for (let e of s) {
|
|
807
788
|
let t = e.id;
|
|
808
789
|
t <= 0 || m.has(t) || (m.add(t), p.push(e));
|
|
809
790
|
}
|
|
810
791
|
}
|
|
811
|
-
|
|
792
|
+
c.length > 0 && o.push({
|
|
812
793
|
code: "NOT_FOUND",
|
|
813
794
|
field: "ids",
|
|
814
795
|
message: "some requested ids were not found",
|
|
815
|
-
ids:
|
|
816
|
-
}), u.length > 0 &&
|
|
796
|
+
ids: c
|
|
797
|
+
}), u.length > 0 && o.push({
|
|
817
798
|
code: "PROJECT_MISMATCH",
|
|
818
799
|
field: "project",
|
|
819
800
|
message: "some requested ids are outside the requested project scope",
|
|
820
801
|
ids: u
|
|
821
|
-
}), d.length > 0 &&
|
|
802
|
+
}), d.length > 0 && o.push({
|
|
822
803
|
code: "FILTER_MISMATCH",
|
|
823
804
|
field: "filters",
|
|
824
805
|
message: "some requested ids are outside the requested filters",
|
|
@@ -828,15 +809,15 @@ function $(e, t) {
|
|
|
828
809
|
if (e.include_observations) {
|
|
829
810
|
let e = /* @__PURE__ */ new Set(), n = [];
|
|
830
811
|
for (let t of [...f, ...p]) t.id > 0 && !e.has(t.id) && (e.add(t.id), n.push(t.id));
|
|
831
|
-
g =
|
|
812
|
+
g = Q(r, n, t);
|
|
832
813
|
}
|
|
833
814
|
return {
|
|
834
815
|
value: {
|
|
835
816
|
anchors: f,
|
|
836
817
|
timeline: p,
|
|
837
818
|
observations: g,
|
|
838
|
-
missing_ids: i.filter((e) =>
|
|
839
|
-
errors:
|
|
819
|
+
missing_ids: i.filter((e) => c.includes(e) || u.includes(e) || d.includes(e)),
|
|
820
|
+
errors: o,
|
|
840
821
|
metadata: {
|
|
841
822
|
project: n,
|
|
842
823
|
requested_ids_count: i.length,
|
|
@@ -856,21 +837,21 @@ function $(e, t) {
|
|
|
856
837
|
}
|
|
857
838
|
//#endregion
|
|
858
839
|
//#region src/server.ts
|
|
859
|
-
function
|
|
860
|
-
let
|
|
840
|
+
function de(e, n = {}) {
|
|
841
|
+
let r = new y({
|
|
861
842
|
name: "codemem",
|
|
862
|
-
version:
|
|
863
|
-
}),
|
|
843
|
+
version: a
|
|
844
|
+
}), i = {
|
|
864
845
|
store: e,
|
|
865
|
-
defaultProject: () => n.resolveDefaultProject ? n.resolveDefaultProject() : n.defaultProject === void 0 ?
|
|
846
|
+
defaultProject: () => n.resolveDefaultProject ? n.resolveDefaultProject() : n.defaultProject === void 0 ? C() : n.defaultProject,
|
|
866
847
|
envProject: () => n.envProject === void 0 ? process.env.CODEMEM_PROJECT ?? null : n.envProject,
|
|
867
848
|
captureRetrievalLedger: n.captureRetrievalLedger !== !1,
|
|
868
849
|
retrievalLedgerScopeId: n.retrievalLedgerScopeId ?? t(),
|
|
869
850
|
retrievalLedgerIdentityMode: n.retrievalLedgerIdentityMode ?? "session"
|
|
870
851
|
};
|
|
871
|
-
return
|
|
852
|
+
return $(r, i), ue(r, i), ie(r, i), se(r, i), le(r), ce(r), r;
|
|
872
853
|
}
|
|
873
854
|
//#endregion
|
|
874
|
-
export {
|
|
855
|
+
export { x as n, de as t };
|
|
875
856
|
|
|
876
|
-
//# sourceMappingURL=server-
|
|
857
|
+
//# sourceMappingURL=server-Kv95NnLs.js.map
|