@codemem/core 0.30.0 → 0.31.1
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/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +645 -445
- package/dist/index.js.map +1 -1
- package/dist/maintenance-jobs.d.ts.map +1 -1
- package/dist/project-scope-settings.d.ts +37 -1
- package/dist/project-scope-settings.d.ts.map +1 -1
- package/dist/ref-backfill.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2367,13 +2367,15 @@ function Wr(e, t) {
|
|
|
2367
2367
|
return Object.hasOwn(e, "metadata") ? e.metadata ? JSON.stringify(e.metadata) : null : t.metadata ? JSON.stringify(t.metadata) : null;
|
|
2368
2368
|
}
|
|
2369
2369
|
function Gr(e) {
|
|
2370
|
-
|
|
2370
|
+
if (!e) return null;
|
|
2371
|
+
let t = e.status === "completed" && e.progress_total != null ? e.progress_total : e.progress_current;
|
|
2372
|
+
return {
|
|
2371
2373
|
kind: e.kind,
|
|
2372
2374
|
title: e.title,
|
|
2373
2375
|
status: e.status,
|
|
2374
2376
|
message: e.message,
|
|
2375
2377
|
progress: {
|
|
2376
|
-
current:
|
|
2378
|
+
current: t,
|
|
2377
2379
|
total: e.progress_total,
|
|
2378
2380
|
unit: e.progress_unit
|
|
2379
2381
|
},
|
|
@@ -2382,7 +2384,7 @@ function Gr(e) {
|
|
|
2382
2384
|
updated_at: e.updated_at,
|
|
2383
2385
|
finished_at: e.finished_at,
|
|
2384
2386
|
error: e.error
|
|
2385
|
-
}
|
|
2387
|
+
};
|
|
2386
2388
|
}
|
|
2387
2389
|
function Q(e, t) {
|
|
2388
2390
|
return Br(e), Gr(e.prepare("SELECT * FROM maintenance_jobs WHERE kind = ?").get(t));
|
|
@@ -12271,7 +12273,7 @@ async function wh(e, t = {}) {
|
|
|
12271
12273
|
let t = Number(Ch(e).total_backfillable ?? l ?? u);
|
|
12272
12274
|
return Yr(e, xh, {
|
|
12273
12275
|
message: d > 0 ? `Dedup-key backfill complete (${d} skipped)` : "Dedup-key backfill complete",
|
|
12274
|
-
progressCurrent:
|
|
12276
|
+
progressCurrent: t,
|
|
12275
12277
|
progressTotal: t,
|
|
12276
12278
|
metadata: {
|
|
12277
12279
|
total_backfillable: t,
|
|
@@ -15051,17 +15053,76 @@ function Hv(e) {
|
|
|
15051
15053
|
return !e || e.scope_id === "local-default" ? !1 : e.authority_type === "local" ? e.kind === "team" || e.kind === "org" || e.kind === "client" : !0;
|
|
15052
15054
|
}
|
|
15053
15055
|
function Uv(e) {
|
|
15054
|
-
|
|
15056
|
+
let t = Rv(e)?.toLowerCase() ?? "";
|
|
15057
|
+
return new Set(t.match(/[a-z0-9][a-z0-9-]{1,}/g) ?? []);
|
|
15055
15058
|
}
|
|
15056
15059
|
function Wv(e) {
|
|
15060
|
+
let t = new Set([
|
|
15061
|
+
"domain",
|
|
15062
|
+
"sharing",
|
|
15063
|
+
"devices",
|
|
15064
|
+
"scope",
|
|
15065
|
+
"team",
|
|
15066
|
+
"org",
|
|
15067
|
+
"local"
|
|
15068
|
+
]), n = new Set([
|
|
15069
|
+
"client",
|
|
15070
|
+
"dev",
|
|
15071
|
+
"oss",
|
|
15072
|
+
"personal",
|
|
15073
|
+
"work"
|
|
15074
|
+
]), r = [...Uv(`${e.scope_id} ${e.label}`)].filter((e) => !t.has(e));
|
|
15075
|
+
return {
|
|
15076
|
+
generic: r.filter((e) => n.has(e)),
|
|
15077
|
+
specific: r.filter((e) => !n.has(e))
|
|
15078
|
+
};
|
|
15079
|
+
}
|
|
15080
|
+
function Gv(e) {
|
|
15081
|
+
let t = [];
|
|
15082
|
+
return e.git_remote && t.push({
|
|
15083
|
+
signal: "git_remote",
|
|
15084
|
+
text: e.git_remote
|
|
15085
|
+
}), e.cwd && t.push({
|
|
15086
|
+
signal: "cwd",
|
|
15087
|
+
text: e.cwd
|
|
15088
|
+
}), t.push({
|
|
15089
|
+
signal: "workspace_id",
|
|
15090
|
+
text: e.workspace_identity
|
|
15091
|
+
}), t;
|
|
15092
|
+
}
|
|
15093
|
+
function Kv(e, t) {
|
|
15094
|
+
if (e.resolution_reason !== "local_default" || e.workspace_identity.startsWith("unmapped:")) return null;
|
|
15095
|
+
for (let n of Gv(e)) {
|
|
15096
|
+
let e = Uv(n.text), [r, i] = t.filter((e) => e.scope_id !== "local-default" && e.scope_id !== "legacy-shared-review" && e.status === "active").flatMap((t) => {
|
|
15097
|
+
let n = Wv(t), r = n.specific.filter((t) => e.has(t)), i = n.generic.filter((n) => n === "personal" && e.has(n) && t.kind === n);
|
|
15098
|
+
return r.length === 0 && i.length === 0 ? [] : [{
|
|
15099
|
+
scope: t,
|
|
15100
|
+
matches: [...r, ...i],
|
|
15101
|
+
score: r.length * 10 + i.length
|
|
15102
|
+
}];
|
|
15103
|
+
}).toSorted((e, t) => t.score - e.score);
|
|
15104
|
+
if (!r || i && i.score === r.score) continue;
|
|
15105
|
+
let a = Bv(r.scope, r.scope.scope_id), o = n.signal === "git_remote" ? "git remote" : n.signal;
|
|
15106
|
+
return {
|
|
15107
|
+
scopeId: r.scope.scope_id,
|
|
15108
|
+
reason: `${a} is suggested because the ${o} contains ${r.matches.join(", ")}. Confirm before mapping; this does not grant peer access.`,
|
|
15109
|
+
signal: n.signal
|
|
15110
|
+
};
|
|
15111
|
+
}
|
|
15112
|
+
return null;
|
|
15113
|
+
}
|
|
15114
|
+
function qv(e) {
|
|
15115
|
+
return /[*?]/.test(e);
|
|
15116
|
+
}
|
|
15117
|
+
function Jv(e) {
|
|
15057
15118
|
let t = e.search(/[*?]/);
|
|
15058
15119
|
return (t >= 0 ? e.slice(0, t) : e).replace(/\/+$/, "");
|
|
15059
15120
|
}
|
|
15060
|
-
function
|
|
15061
|
-
let t =
|
|
15121
|
+
function Yv(e) {
|
|
15122
|
+
let t = Jv(e.replaceAll("\\", "/"));
|
|
15062
15123
|
return t === "~" || /^\/Users\/[^/]+$/i.test(t) || /^\/home\/[^/]+$/i.test(t) || /^\/var\/home\/[^/]+$/i.test(t) || /^[A-Z]:\/Users\/[^/]+$/i.test(t);
|
|
15063
15124
|
}
|
|
15064
|
-
function
|
|
15125
|
+
function Xv(e) {
|
|
15065
15126
|
let t = JSON.stringify({
|
|
15066
15127
|
code: e.code,
|
|
15067
15128
|
mapping_id: e.mapping_id ?? null,
|
|
@@ -15073,18 +15134,18 @@ function Kv(e) {
|
|
|
15073
15134
|
});
|
|
15074
15135
|
return `psg_${u("sha256").update(t).digest("hex").slice(0, 32)}`;
|
|
15075
15136
|
}
|
|
15076
|
-
function
|
|
15137
|
+
function Zv(e) {
|
|
15077
15138
|
return e.requires_confirmation ? {
|
|
15078
15139
|
...e,
|
|
15079
|
-
confirmation_token:
|
|
15140
|
+
confirmation_token: Xv(e)
|
|
15080
15141
|
} : e;
|
|
15081
15142
|
}
|
|
15082
|
-
function
|
|
15143
|
+
function Qv(e, t) {
|
|
15083
15144
|
if (e.workspace_identity) return [];
|
|
15084
15145
|
let n = zv(e.project_pattern) ?? e.project_pattern, r = t.get(e.scope_id);
|
|
15085
15146
|
if (!Hv(r)) return [];
|
|
15086
15147
|
let i = Bv(r, e.scope_id), a = [];
|
|
15087
|
-
return
|
|
15148
|
+
return qv(n) && a.push({
|
|
15088
15149
|
code: "broad_org_domain_pattern",
|
|
15089
15150
|
severity: "warning",
|
|
15090
15151
|
message: `Wildcard project pattern ${n} can catch multiple projects. Review before attaching it to ${i}.`,
|
|
@@ -15092,7 +15153,7 @@ function Jv(e, t) {
|
|
|
15092
15153
|
scope_id: e.scope_id,
|
|
15093
15154
|
mapping_id: e.id ?? null,
|
|
15094
15155
|
project_pattern: e.project_pattern
|
|
15095
|
-
}),
|
|
15156
|
+
}), Yv(n) && a.push({
|
|
15096
15157
|
code: "home_directory_org_domain_pattern",
|
|
15097
15158
|
severity: "warning",
|
|
15098
15159
|
message: `Home-directory project pattern ${n} can mix personal and work projects. Review before attaching it to ${i}.`,
|
|
@@ -15100,20 +15161,20 @@ function Jv(e, t) {
|
|
|
15100
15161
|
scope_id: e.scope_id,
|
|
15101
15162
|
mapping_id: e.id ?? null,
|
|
15102
15163
|
project_pattern: e.project_pattern
|
|
15103
|
-
}), a.map(
|
|
15164
|
+
}), a.map(Zv);
|
|
15104
15165
|
}
|
|
15105
|
-
function
|
|
15166
|
+
function $v(e) {
|
|
15106
15167
|
return (Rv(e.project) ?? Rv(e.display_project) ?? e.workspace_identity).toLowerCase();
|
|
15107
15168
|
}
|
|
15108
|
-
function
|
|
15169
|
+
function ey(e) {
|
|
15109
15170
|
let t = /* @__PURE__ */ new Map();
|
|
15110
15171
|
for (let n of e) {
|
|
15111
|
-
let e =
|
|
15172
|
+
let e = $v(n);
|
|
15112
15173
|
t.set(e, [...t.get(e) ?? [], n]);
|
|
15113
15174
|
}
|
|
15114
15175
|
return t;
|
|
15115
15176
|
}
|
|
15116
|
-
function
|
|
15177
|
+
function ty(e, t) {
|
|
15117
15178
|
let n = [];
|
|
15118
15179
|
e.resolution_reason === "local_default" && n.push({
|
|
15119
15180
|
code: "unknown_project_local_only",
|
|
@@ -15123,25 +15184,81 @@ function Zv(e, t) {
|
|
|
15123
15184
|
workspace_identity: e.workspace_identity,
|
|
15124
15185
|
scope_id: Ti
|
|
15125
15186
|
});
|
|
15126
|
-
let r = (t.get(
|
|
15187
|
+
let r = (t.get($v(e)) ?? []).filter((t) => t.workspace_identity !== e.workspace_identity);
|
|
15127
15188
|
return r.length > 0 && n.push({
|
|
15128
15189
|
code: "basename_collision_review",
|
|
15129
|
-
severity: "
|
|
15130
|
-
message: `Another
|
|
15190
|
+
severity: "info",
|
|
15191
|
+
message: `Another workspace is also named ${e.display_project}. Review the git remote or path before assigning a non-local Sharing domain.`,
|
|
15131
15192
|
requires_confirmation: !0,
|
|
15132
15193
|
workspace_identity: e.workspace_identity,
|
|
15133
15194
|
related_workspace_identities: r.map((e) => e.workspace_identity),
|
|
15134
15195
|
related_projects: r.map((e) => e.display_project)
|
|
15135
|
-
}), n.map(
|
|
15196
|
+
}), n.map(Zv);
|
|
15136
15197
|
}
|
|
15137
|
-
function
|
|
15138
|
-
let t =
|
|
15198
|
+
function ny(e) {
|
|
15199
|
+
let t = ey(e);
|
|
15139
15200
|
return e.map((e) => ({
|
|
15140
15201
|
...e,
|
|
15141
|
-
guardrail_warnings:
|
|
15202
|
+
guardrail_warnings: ty(e, t)
|
|
15142
15203
|
}));
|
|
15143
15204
|
}
|
|
15144
|
-
function
|
|
15205
|
+
function ry(e) {
|
|
15206
|
+
let t = /* @__PURE__ */ new Set();
|
|
15207
|
+
return e.resolved_scope_id === "local-default" && t.add("local_only"), e.resolved_scope_id === "legacy-shared-review" && t.add("legacy_review"), e.identity_source === "unmapped" && t.add("unmapped"), e.suggested_scope_id && e.suggested_scope_id !== e.resolved_scope_id && t.add("suggested"), e.mapping_id != null && t.add("explicitly_mapped"), (e.guardrail_warnings ?? []).some((e) => e.severity === "warning") && t.add("needs_attention"), [...t].sort();
|
|
15208
|
+
}
|
|
15209
|
+
function iy(e, t) {
|
|
15210
|
+
let n = Rv(t)?.toLowerCase();
|
|
15211
|
+
return n ? [
|
|
15212
|
+
e.display_project,
|
|
15213
|
+
e.project,
|
|
15214
|
+
e.cwd,
|
|
15215
|
+
e.git_remote,
|
|
15216
|
+
e.git_branch,
|
|
15217
|
+
e.workspace_identity,
|
|
15218
|
+
e.resolved_scope_id,
|
|
15219
|
+
e.suggested_scope_id
|
|
15220
|
+
].filter((e) => typeof e == "string" && e.length > 0).some((e) => e.toLowerCase().includes(n)) : !0;
|
|
15221
|
+
}
|
|
15222
|
+
function ay(e, t, n) {
|
|
15223
|
+
let r = ji({
|
|
15224
|
+
gitRemote: e.git_remote,
|
|
15225
|
+
gitBranch: e.git_branch,
|
|
15226
|
+
cwd: e.cwd,
|
|
15227
|
+
project: e.project,
|
|
15228
|
+
workspaceId: e.workspace_id
|
|
15229
|
+
}), i = Bi({
|
|
15230
|
+
gitRemote: e.git_remote,
|
|
15231
|
+
gitBranch: e.git_branch,
|
|
15232
|
+
cwd: e.cwd,
|
|
15233
|
+
project: e.project,
|
|
15234
|
+
workspaceId: e.workspace_id,
|
|
15235
|
+
mappings: t
|
|
15236
|
+
}), a = {
|
|
15237
|
+
workspace_identity: r.value,
|
|
15238
|
+
identity_source: r.source,
|
|
15239
|
+
display_project: r.displayProject ?? Rv(e.project) ?? Rv(e.cwd) ?? r.value,
|
|
15240
|
+
project: Rv(e.project),
|
|
15241
|
+
cwd: Rv(e.cwd),
|
|
15242
|
+
git_remote: Rv(e.git_remote),
|
|
15243
|
+
git_branch: Rv(e.git_branch),
|
|
15244
|
+
latest_session_at: e.started_at,
|
|
15245
|
+
resolved_scope_id: i.scopeId,
|
|
15246
|
+
resolution_reason: i.reason,
|
|
15247
|
+
mapping_id: i.mapping?.id ?? null,
|
|
15248
|
+
matched_pattern: i.matchedPattern,
|
|
15249
|
+
suggested_scope_id: null,
|
|
15250
|
+
suggestion_reason: null,
|
|
15251
|
+
suggestion_signal: null,
|
|
15252
|
+
guardrail_warnings: []
|
|
15253
|
+
}, o = Kv(a, n);
|
|
15254
|
+
return {
|
|
15255
|
+
...a,
|
|
15256
|
+
suggested_scope_id: o?.scopeId ?? null,
|
|
15257
|
+
suggestion_reason: o?.reason ?? null,
|
|
15258
|
+
suggestion_signal: o?.signal ?? null
|
|
15259
|
+
};
|
|
15260
|
+
}
|
|
15261
|
+
function oy(e) {
|
|
15145
15262
|
let t = /* @__PURE__ */ new Set();
|
|
15146
15263
|
return e.filter((e) => {
|
|
15147
15264
|
let n = [
|
|
@@ -15152,12 +15269,12 @@ function $v(e) {
|
|
|
15152
15269
|
e.related_workspace_identities?.join("|") ?? ""
|
|
15153
15270
|
].join("\0");
|
|
15154
15271
|
return t.has(n) ? !1 : (t.add(n), !0);
|
|
15155
|
-
}).map(
|
|
15272
|
+
}).map(Zv);
|
|
15156
15273
|
}
|
|
15157
|
-
function
|
|
15274
|
+
function sy(e, t) {
|
|
15158
15275
|
if (!e && !/[\\/:]/.test(t) && !(/[*?]/.test(t) && /[\\/:]/.test(t.replace(/[*?]/g, "")))) throw Error("project_pattern must use a canonical path, remote, or workspace pattern");
|
|
15159
15276
|
}
|
|
15160
|
-
function
|
|
15277
|
+
function cy(e) {
|
|
15161
15278
|
return {
|
|
15162
15279
|
scope_id: String(e.scope_id ?? ""),
|
|
15163
15280
|
label: String(e.label ?? ""),
|
|
@@ -15170,7 +15287,7 @@ function ty(e) {
|
|
|
15170
15287
|
updated_at: String(e.updated_at ?? "")
|
|
15171
15288
|
};
|
|
15172
15289
|
}
|
|
15173
|
-
function
|
|
15290
|
+
function ly(e) {
|
|
15174
15291
|
return {
|
|
15175
15292
|
id: Number(e.id ?? 0),
|
|
15176
15293
|
workspace_identity: zv(e.workspace_identity),
|
|
@@ -15183,33 +15300,34 @@ function ny(e) {
|
|
|
15183
15300
|
guardrail_warnings: []
|
|
15184
15301
|
};
|
|
15185
15302
|
}
|
|
15186
|
-
function
|
|
15187
|
-
return Tv(e), e.prepare("SELECT scope_id, label, kind, authority_type, coordinator_id, group_id,\n membership_epoch, status, updated_at\n FROM replication_scopes\n WHERE status = 'active'\n ORDER BY CASE WHEN scope_id = ? THEN 0 ELSE 1 END, label COLLATE NOCASE, scope_id").all(Ti).map((e) =>
|
|
15303
|
+
function uy(e) {
|
|
15304
|
+
return Tv(e), e.prepare("SELECT scope_id, label, kind, authority_type, coordinator_id, group_id,\n membership_epoch, status, updated_at\n FROM replication_scopes\n WHERE status = 'active'\n ORDER BY CASE WHEN scope_id = ? THEN 0 ELSE 1 END, label COLLATE NOCASE, scope_id").all(Ti).map((e) => cy(e));
|
|
15188
15305
|
}
|
|
15189
|
-
function
|
|
15306
|
+
function dy(e) {
|
|
15190
15307
|
Tv(e);
|
|
15191
|
-
let t = Vv(
|
|
15308
|
+
let t = Vv(uy(e));
|
|
15192
15309
|
return e.prepare("SELECT id, workspace_identity, project_pattern, scope_id, priority, source, created_at, updated_at\n FROM project_scope_mappings\n ORDER BY priority DESC, updated_at DESC, id DESC").all().map((e) => {
|
|
15193
|
-
let n =
|
|
15310
|
+
let n = ly(e);
|
|
15194
15311
|
return {
|
|
15195
15312
|
...n,
|
|
15196
|
-
guardrail_warnings:
|
|
15313
|
+
guardrail_warnings: Qv(n, t)
|
|
15197
15314
|
};
|
|
15198
15315
|
});
|
|
15199
15316
|
}
|
|
15200
|
-
function
|
|
15317
|
+
function fy(e, t) {
|
|
15201
15318
|
let n = e.prepare("SELECT id, workspace_identity, project_pattern, scope_id, priority, source, created_at, updated_at\n FROM project_scope_mappings\n WHERE id = ?\n LIMIT 1").get(t);
|
|
15202
|
-
return n ?
|
|
15319
|
+
return n ? ly(n) : null;
|
|
15203
15320
|
}
|
|
15204
|
-
function
|
|
15321
|
+
function py(e, t) {
|
|
15205
15322
|
let n = e.prepare("SELECT id, workspace_identity, project_pattern, scope_id, priority, source, created_at, updated_at\n FROM project_scope_mappings\n WHERE workspace_identity = ?\n ORDER BY priority DESC, updated_at DESC, id DESC\n LIMIT 1").get(t);
|
|
15206
|
-
return n ?
|
|
15323
|
+
return n ? ly(n) : null;
|
|
15207
15324
|
}
|
|
15208
|
-
function
|
|
15325
|
+
function my(e, t) {
|
|
15326
|
+
if (t === "legacy-shared-review") throw Error("legacy-shared-review is a review bucket, not an assignable Sharing domain");
|
|
15209
15327
|
if (!e.prepare("SELECT 1 FROM replication_scopes WHERE scope_id = ? AND status = 'active' LIMIT 1").get(t)) throw Error(`scope_id ${t} is not an active Sharing domain`);
|
|
15210
15328
|
}
|
|
15211
|
-
function
|
|
15212
|
-
let n = t.id == null ? null : Number(t.id), r = n && Number.isInteger(n) ?
|
|
15329
|
+
function hy(e, t) {
|
|
15330
|
+
let n = t.id == null ? null : Number(t.id), r = n && Number.isInteger(n) ? fy(e, n) : null, i = zv(t.workspace_identity) ?? r?.workspace_identity ?? null, a = i ? py(e, i) : null, o = r ?? a, s = Rv(t.project_pattern) ?? o?.project_pattern ?? i, c = t.priority == null ? o?.priority ?? 0 : Number(t.priority);
|
|
15213
15331
|
return {
|
|
15214
15332
|
existing: o,
|
|
15215
15333
|
workspaceIdentity: i,
|
|
@@ -15219,16 +15337,16 @@ function cy(e, t) {
|
|
|
15219
15337
|
source: Rv(t.source) ?? "user"
|
|
15220
15338
|
};
|
|
15221
15339
|
}
|
|
15222
|
-
function
|
|
15340
|
+
function gy(e, t) {
|
|
15223
15341
|
Tv(e);
|
|
15224
|
-
let n =
|
|
15225
|
-
n.projectPattern && n.scopeId && i.push(...
|
|
15342
|
+
let n = hy(e, t), r = Vv(uy(e)), i = [];
|
|
15343
|
+
n.projectPattern && n.scopeId && i.push(...Qv({
|
|
15226
15344
|
id: n.existing?.id ?? 0,
|
|
15227
15345
|
workspace_identity: n.workspaceIdentity,
|
|
15228
15346
|
project_pattern: n.projectPattern,
|
|
15229
15347
|
scope_id: n.scopeId
|
|
15230
15348
|
}, r));
|
|
15231
|
-
let a = n.workspaceIdentity ?
|
|
15349
|
+
let a = n.workspaceIdentity ? _y(e, { limit: null }).find((e) => e.workspace_identity === n.workspaceIdentity) : null, o = r.get(n.scopeId);
|
|
15232
15350
|
if (a && i.push(...a.guardrail_warnings.filter((e) => e.code !== "basename_collision_review" || Hv(o))), n.scopeId && n.existing && n.existing.scope_id !== n.scopeId) {
|
|
15233
15351
|
let e = Bv(r.get(n.existing.scope_id), n.existing.scope_id), t = Bv(r.get(n.scopeId), n.scopeId);
|
|
15234
15352
|
i.push({
|
|
@@ -15248,13 +15366,32 @@ function ly(e, t) {
|
|
|
15248
15366
|
requested_scope_id: n.scopeId,
|
|
15249
15367
|
requested_workspace_identity: n.workspaceIdentity,
|
|
15250
15368
|
requested_project_pattern: n.projectPattern,
|
|
15251
|
-
warnings:
|
|
15369
|
+
warnings: oy(i)
|
|
15252
15370
|
};
|
|
15253
15371
|
}
|
|
15254
|
-
function
|
|
15372
|
+
function _y(e, t = {}) {
|
|
15255
15373
|
Tv(e);
|
|
15256
|
-
let n = Math.max(1, Math.min(t.limit ?? 250, 1e3)), r =
|
|
15257
|
-
|
|
15374
|
+
let n = t.limit === null ? null : Math.max(1, Math.min(t.limit ?? 250, 1e3)), r = dy(e), i = uy(e), a = `SELECT
|
|
15375
|
+
s.id,
|
|
15376
|
+
s.started_at,
|
|
15377
|
+
s.cwd,
|
|
15378
|
+
s.project,
|
|
15379
|
+
s.git_remote,
|
|
15380
|
+
s.git_branch,
|
|
15381
|
+
(
|
|
15382
|
+
SELECT mi.workspace_id
|
|
15383
|
+
FROM memory_items mi
|
|
15384
|
+
WHERE mi.session_id = s.id
|
|
15385
|
+
AND mi.workspace_id IS NOT NULL
|
|
15386
|
+
AND TRIM(mi.workspace_id) <> ''
|
|
15387
|
+
ORDER BY mi.id DESC
|
|
15388
|
+
LIMIT 1
|
|
15389
|
+
) AS workspace_id
|
|
15390
|
+
FROM sessions s
|
|
15391
|
+
WHERE COALESCE(TRIM(s.git_remote), TRIM(s.cwd), TRIM(s.project), '') <> ''
|
|
15392
|
+
OR EXISTS (SELECT 1 FROM memory_items mi_candidate WHERE mi_candidate.session_id = s.id)
|
|
15393
|
+
ORDER BY s.started_at DESC, s.id DESC${n == null ? "" : "\n LIMIT ?"}`, o = n == null ? e.prepare(a).all() : e.prepare(a).all(n), s = /* @__PURE__ */ new Set(), c = [];
|
|
15394
|
+
for (let e of o) {
|
|
15258
15395
|
let t = ji({
|
|
15259
15396
|
gitRemote: e.git_remote,
|
|
15260
15397
|
gitBranch: e.git_branch,
|
|
@@ -15262,74 +15399,137 @@ function uy(e, t = {}) {
|
|
|
15262
15399
|
project: e.project,
|
|
15263
15400
|
workspaceId: e.workspace_id
|
|
15264
15401
|
});
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
resolution_reason: n.reason,
|
|
15286
|
-
mapping_id: n.mapping?.id ?? null,
|
|
15287
|
-
matched_pattern: n.matchedPattern,
|
|
15288
|
-
guardrail_warnings: []
|
|
15289
|
-
});
|
|
15402
|
+
s.has(t.value) || (s.add(t.value), c.push(ay(e, r, i)));
|
|
15403
|
+
}
|
|
15404
|
+
return ny(c.toSorted((e, t) => e.display_project.localeCompare(t.display_project) || e.workspace_identity.localeCompare(t.workspace_identity)));
|
|
15405
|
+
}
|
|
15406
|
+
function vy(e, t = {}) {
|
|
15407
|
+
Tv(e);
|
|
15408
|
+
let n = Math.max(1, Math.min(t.limit ?? 50, 250)), r = Math.max(0, t.offset ?? 0), i = dy(e), a = uy(e), o = e.prepare("SELECT\n s.id,\n MAX(s.started_at) AS started_at,\n s.cwd,\n s.project,\n s.git_remote,\n s.git_branch,\n (\n SELECT mi.workspace_id\n FROM memory_items mi\n WHERE mi.session_id = s.id\n AND mi.workspace_id IS NOT NULL\n AND TRIM(mi.workspace_id) <> ''\n ORDER BY mi.id DESC\n LIMIT 1\n ) AS workspace_id,\n COUNT(DISTINCT s.id) AS session_count,\n COUNT(mi_count.id) AS memory_count\n FROM sessions s\n LEFT JOIN memory_items mi_count ON mi_count.session_id = s.id\n WHERE COALESCE(TRIM(s.git_remote), TRIM(s.cwd), TRIM(s.project), '') <> ''\n OR mi_count.id IS NOT NULL\n GROUP BY s.id\n ORDER BY MAX(s.started_at) DESC, s.id DESC").all(), s = /* @__PURE__ */ new Map(), c = [];
|
|
15409
|
+
for (let e of o) {
|
|
15410
|
+
let t = ay(e, i, a), n = s.get(t.workspace_identity);
|
|
15411
|
+
if (n) {
|
|
15412
|
+
n.memory_count = (n.memory_count ?? 0) + Number(e.memory_count ?? 0), n.session_count += Number(e.session_count ?? 1);
|
|
15413
|
+
continue;
|
|
15414
|
+
}
|
|
15415
|
+
let r = {
|
|
15416
|
+
...t,
|
|
15417
|
+
memory_count: Number(e.memory_count ?? 0),
|
|
15418
|
+
session_count: Number(e.session_count ?? 1),
|
|
15419
|
+
statuses: []
|
|
15420
|
+
};
|
|
15421
|
+
s.set(t.workspace_identity, r), c.push(r);
|
|
15290
15422
|
}
|
|
15291
|
-
|
|
15423
|
+
for (let e of i) {
|
|
15424
|
+
if (!e.workspace_identity || s.has(e.workspace_identity)) continue;
|
|
15425
|
+
let t = {
|
|
15426
|
+
workspace_identity: e.workspace_identity,
|
|
15427
|
+
identity_source: "workspace_id",
|
|
15428
|
+
display_project: e.project_pattern || e.workspace_identity,
|
|
15429
|
+
project: e.project_pattern || null,
|
|
15430
|
+
cwd: null,
|
|
15431
|
+
git_remote: null,
|
|
15432
|
+
git_branch: null,
|
|
15433
|
+
latest_session_at: null,
|
|
15434
|
+
resolved_scope_id: e.scope_id,
|
|
15435
|
+
resolution_reason: "exact_mapping",
|
|
15436
|
+
mapping_id: e.id,
|
|
15437
|
+
matched_pattern: null,
|
|
15438
|
+
suggested_scope_id: null,
|
|
15439
|
+
suggestion_reason: null,
|
|
15440
|
+
suggestion_signal: null,
|
|
15441
|
+
guardrail_warnings: [],
|
|
15442
|
+
memory_count: 0,
|
|
15443
|
+
session_count: 0,
|
|
15444
|
+
statuses: []
|
|
15445
|
+
};
|
|
15446
|
+
s.set(e.workspace_identity, t), c.push(t);
|
|
15447
|
+
}
|
|
15448
|
+
let l = ny(c).map((e) => {
|
|
15449
|
+
let t = c.find((t) => t.workspace_identity === e.workspace_identity);
|
|
15450
|
+
return {
|
|
15451
|
+
...e,
|
|
15452
|
+
memory_count: t?.memory_count ?? null,
|
|
15453
|
+
session_count: t?.session_count ?? 0,
|
|
15454
|
+
statuses: ry(e)
|
|
15455
|
+
};
|
|
15456
|
+
}).filter((e) => iy(e, t.query)).filter((e) => !t.scopeId || e.resolved_scope_id === t.scopeId).filter((e) => !t.identitySource || e.identity_source === t.identitySource).filter((e) => !t.status || e.statuses.some((e) => e === t.status)).toSorted((e, t) => (e.latest_session_at == null ? 1 : t.latest_session_at == null ? -1 : 0) || String(t.latest_session_at ?? "").localeCompare(String(e.latest_session_at ?? "")) || e.display_project.localeCompare(t.display_project) || e.workspace_identity.localeCompare(t.workspace_identity));
|
|
15457
|
+
return {
|
|
15458
|
+
projects: l.slice(r, r + n),
|
|
15459
|
+
total: l.length,
|
|
15460
|
+
limit: n,
|
|
15461
|
+
offset: r,
|
|
15462
|
+
has_more: r + n < l.length
|
|
15463
|
+
};
|
|
15292
15464
|
}
|
|
15293
|
-
function
|
|
15465
|
+
function yy(e, t) {
|
|
15294
15466
|
Tv(e);
|
|
15295
|
-
let n =
|
|
15467
|
+
let n = zv(t.workspaceIdentity);
|
|
15468
|
+
if (!n) throw Error("workspace_identity must be a non-empty string");
|
|
15469
|
+
if (n.startsWith("unmapped:")) throw Error("unmapped projects cannot be reassigned until they have a stable identity");
|
|
15470
|
+
let r = Rv(t.project);
|
|
15471
|
+
if (!r) throw Error("project must be a non-empty string");
|
|
15472
|
+
let i = e.prepare("SELECT\n s.id,\n s.started_at,\n s.cwd,\n s.project,\n s.git_remote,\n s.git_branch,\n (\n SELECT mi.workspace_id\n FROM memory_items mi\n WHERE mi.session_id = s.id\n AND mi.workspace_id IS NOT NULL\n AND TRIM(mi.workspace_id) <> ''\n ORDER BY mi.id DESC\n LIMIT 1\n ) AS workspace_id,\n COUNT(mi_count.id) AS memory_count\n FROM sessions s\n LEFT JOIN memory_items mi_count ON mi_count.session_id = s.id\n WHERE COALESCE(TRIM(s.git_remote), TRIM(s.cwd), TRIM(s.project), '') <> ''\n OR mi_count.id IS NOT NULL\n GROUP BY s.id").all().filter((e) => ji({
|
|
15473
|
+
gitRemote: e.git_remote,
|
|
15474
|
+
gitBranch: e.git_branch,
|
|
15475
|
+
cwd: e.cwd,
|
|
15476
|
+
project: e.project,
|
|
15477
|
+
workspaceId: e.workspace_id
|
|
15478
|
+
}).value === n);
|
|
15479
|
+
if (i.length === 0) throw Error("project identity not found");
|
|
15480
|
+
let a = [...new Set(i.map((e) => Rv(e.project) ?? "").filter(Boolean))].sort(), o = i.reduce((e, t) => e + Number(t.memory_count ?? 0), 0), s = e.prepare("UPDATE sessions SET project = ? WHERE id = ?");
|
|
15481
|
+
return e.transaction(() => {
|
|
15482
|
+
for (let e of i) s.run(r, e.id);
|
|
15483
|
+
})(), {
|
|
15484
|
+
moved_memory_count: o,
|
|
15485
|
+
moved_session_count: i.length,
|
|
15486
|
+
previous_projects: a,
|
|
15487
|
+
project: r,
|
|
15488
|
+
workspace_identity: n
|
|
15489
|
+
};
|
|
15490
|
+
}
|
|
15491
|
+
function by(e, t) {
|
|
15492
|
+
Tv(e);
|
|
15493
|
+
let n = hy(e, t), r = n.scopeId;
|
|
15296
15494
|
if (!r) throw Error("scope_id must be a non-empty string");
|
|
15297
|
-
|
|
15298
|
-
let { existing: i, workspaceIdentity: a } = n
|
|
15495
|
+
my(e, r);
|
|
15496
|
+
let { existing: i, workspaceIdentity: a } = n;
|
|
15497
|
+
if (a?.startsWith("unmapped:")) throw Error("unmapped projects cannot be assigned to a Sharing domain");
|
|
15498
|
+
let o = n.projectPattern;
|
|
15299
15499
|
if (!o) throw Error("project_pattern or workspace_identity is required");
|
|
15300
|
-
|
|
15500
|
+
sy(a, o);
|
|
15301
15501
|
let s = n.priority;
|
|
15302
15502
|
if (!Number.isFinite(s) || !Number.isInteger(s)) throw Error("priority must be an integer");
|
|
15303
15503
|
let c = n.source, l = (/* @__PURE__ */ new Date()).toISOString();
|
|
15304
15504
|
if (i) {
|
|
15305
15505
|
e.prepare("UPDATE project_scope_mappings\n SET workspace_identity = ?, project_pattern = ?, scope_id = ?, priority = ?, source = ?, updated_at = ?\n WHERE id = ?").run(a, o, r, s, c, l, i.id);
|
|
15306
|
-
let t =
|
|
15506
|
+
let t = fy(e, i.id);
|
|
15307
15507
|
if (!t) throw Error("project_scope_mapping update returned no row");
|
|
15308
15508
|
return t;
|
|
15309
15509
|
}
|
|
15310
|
-
let u = e.prepare("INSERT INTO project_scope_mappings(\n workspace_identity, project_pattern, scope_id, priority, source, created_at, updated_at\n ) VALUES (?, ?, ?, ?, ?, ?, ?)").run(a, o, r, s, c, l, l), d =
|
|
15510
|
+
let u = e.prepare("INSERT INTO project_scope_mappings(\n workspace_identity, project_pattern, scope_id, priority, source, created_at, updated_at\n ) VALUES (?, ?, ?, ?, ?, ?, ?)").run(a, o, r, s, c, l, l), d = fy(e, Number(u.lastInsertRowid));
|
|
15311
15511
|
if (!d) throw Error("project_scope_mapping insert returned no row");
|
|
15312
15512
|
return d;
|
|
15313
15513
|
}
|
|
15314
|
-
function
|
|
15514
|
+
function xy(e, t) {
|
|
15315
15515
|
if (!Number.isInteger(t) || t <= 0) throw Error("id must be a positive integer");
|
|
15316
15516
|
let n = e.prepare("DELETE FROM project_scope_mappings WHERE id = ?").run(t);
|
|
15317
15517
|
return Number(n.changes ?? 0) > 0;
|
|
15318
15518
|
}
|
|
15319
15519
|
//#endregion
|
|
15320
15520
|
//#region src/raw-event-sweeper.ts
|
|
15321
|
-
var
|
|
15322
|
-
function
|
|
15521
|
+
var Sy = 60;
|
|
15522
|
+
function Cy(e, t) {
|
|
15323
15523
|
let n = process.env[e];
|
|
15324
15524
|
if (n == null) return t;
|
|
15325
15525
|
let r = Number.parseInt(n, 10);
|
|
15326
15526
|
return Number.isFinite(r) ? r : t;
|
|
15327
15527
|
}
|
|
15328
|
-
function
|
|
15528
|
+
function wy(e) {
|
|
15329
15529
|
let t = (process.env[e] ?? "1").trim().toLowerCase();
|
|
15330
15530
|
return t === "0" || t === "false" || t === "off";
|
|
15331
15531
|
}
|
|
15332
|
-
var
|
|
15532
|
+
var Ty = class {
|
|
15333
15533
|
store;
|
|
15334
15534
|
ingestOpts;
|
|
15335
15535
|
active = !1;
|
|
@@ -15347,7 +15547,7 @@ var gy = class {
|
|
|
15347
15547
|
this.store = e, this.ingestOpts = t;
|
|
15348
15548
|
}
|
|
15349
15549
|
enabled() {
|
|
15350
|
-
return !
|
|
15550
|
+
return !wy("CODEMEM_RAW_EVENTS_SWEEPER");
|
|
15351
15551
|
}
|
|
15352
15552
|
intervalMs() {
|
|
15353
15553
|
let e = process.env.CODEMEM_RAW_EVENTS_SWEEPER_INTERVAL_MS;
|
|
@@ -15359,31 +15559,31 @@ var gy = class {
|
|
|
15359
15559
|
return Number.isFinite(n) && n > 0 ? Math.max(1e3, n * 1e3) : 3e4;
|
|
15360
15560
|
}
|
|
15361
15561
|
idleMs() {
|
|
15362
|
-
return
|
|
15562
|
+
return Cy("CODEMEM_RAW_EVENTS_SWEEPER_IDLE_MS", 12e4);
|
|
15363
15563
|
}
|
|
15364
15564
|
limit() {
|
|
15365
|
-
return
|
|
15565
|
+
return Cy("CODEMEM_RAW_EVENTS_SWEEPER_LIMIT", 25);
|
|
15366
15566
|
}
|
|
15367
15567
|
workerMaxEvents() {
|
|
15368
|
-
let e =
|
|
15568
|
+
let e = Cy("CODEMEM_RAW_EVENTS_WORKER_MAX_EVENTS", 100);
|
|
15369
15569
|
return e <= 0 ? null : e;
|
|
15370
15570
|
}
|
|
15371
15571
|
retentionMs() {
|
|
15372
|
-
return
|
|
15572
|
+
return Cy("CODEMEM_RAW_EVENTS_RETENTION_MS", 0);
|
|
15373
15573
|
}
|
|
15374
15574
|
autoFlushEnabled() {
|
|
15375
15575
|
return (process.env.CODEMEM_RAW_EVENTS_AUTO_FLUSH ?? "").trim() === "1";
|
|
15376
15576
|
}
|
|
15377
15577
|
debounceMs() {
|
|
15378
|
-
return
|
|
15578
|
+
return Cy("CODEMEM_RAW_EVENTS_DEBOUNCE_MS", 6e4);
|
|
15379
15579
|
}
|
|
15380
15580
|
stuckBatchMs() {
|
|
15381
|
-
return
|
|
15581
|
+
return Cy("CODEMEM_RAW_EVENTS_STUCK_BATCH_MS", 3e5);
|
|
15382
15582
|
}
|
|
15383
15583
|
handleAuthError(e) {
|
|
15384
|
-
if (this.authBackoffUntil = Date.now() / 1e3 +
|
|
15584
|
+
if (this.authBackoffUntil = Date.now() / 1e3 + Sy, !this.authErrorLogged) {
|
|
15385
15585
|
this.authErrorLogged = !0;
|
|
15386
|
-
let t = `codemem: observer auth error — backing off for ${
|
|
15586
|
+
let t = `codemem: observer auth error — backing off for ${Sy}s. Refresh your provider credentials or update observer_provider in settings. (${e.message})`;
|
|
15387
15587
|
console.error(t);
|
|
15388
15588
|
}
|
|
15389
15589
|
}
|
|
@@ -15567,16 +15767,16 @@ var gy = class {
|
|
|
15567
15767
|
}
|
|
15568
15768
|
}
|
|
15569
15769
|
}
|
|
15570
|
-
},
|
|
15571
|
-
function
|
|
15770
|
+
}, Ey = "memory_ref_backfill", Dy = "mi.active = 1\n AND (\n (\n (\n (json_valid(mi.files_read) AND json_type(mi.files_read) = 'array' AND json_array_length(mi.files_read) > 0)\n OR\n (json_valid(mi.files_modified) AND json_type(mi.files_modified) = 'array' AND json_array_length(mi.files_modified) > 0)\n )\n AND NOT EXISTS (\n SELECT 1 FROM memory_file_refs mfr WHERE mfr.memory_id = mi.id\n )\n )\n OR\n (\n json_valid(mi.concepts)\n AND json_type(mi.concepts) = 'array'\n AND json_array_length(mi.concepts) > 0\n AND NOT EXISTS (\n SELECT 1 FROM memory_concept_refs mcr WHERE mcr.memory_id = mi.id\n )\n )\n )";
|
|
15771
|
+
function Oy(e) {
|
|
15572
15772
|
return e.prepare(`SELECT 1 FROM memory_items mi
|
|
15573
|
-
WHERE ${
|
|
15773
|
+
WHERE ${Dy}
|
|
15574
15774
|
LIMIT 1`).get() != null;
|
|
15575
15775
|
}
|
|
15576
|
-
function
|
|
15776
|
+
function ky(e) {
|
|
15577
15777
|
return Q(e, "memory_ref_backfill")?.metadata ?? {};
|
|
15578
15778
|
}
|
|
15579
|
-
function
|
|
15779
|
+
function Ay(e) {
|
|
15580
15780
|
if (!e) return null;
|
|
15581
15781
|
try {
|
|
15582
15782
|
let t = JSON.parse(e);
|
|
@@ -15584,84 +15784,84 @@ function xy(e) {
|
|
|
15584
15784
|
} catch {}
|
|
15585
15785
|
return null;
|
|
15586
15786
|
}
|
|
15587
|
-
async function
|
|
15588
|
-
let n = Q(e,
|
|
15787
|
+
async function jy(e, t = {}) {
|
|
15788
|
+
let n = Q(e, Ey), r = ky(e), i = Math.max(1, t.batchSize ?? 50), a = !n || n.status === "completed" || n.status === "failed", o = a ? 0 : Number(r.last_cursor_id ?? 0), s = e.prepare(`SELECT mi.id, mi.files_read, mi.files_modified, mi.concepts
|
|
15589
15789
|
FROM memory_items mi
|
|
15590
15790
|
WHERE mi.id > ?
|
|
15591
|
-
AND ${
|
|
15791
|
+
AND ${Dy}
|
|
15592
15792
|
ORDER BY mi.id ASC
|
|
15593
|
-
LIMIT ?`).all(
|
|
15594
|
-
if (
|
|
15793
|
+
LIMIT ?`).all(o, i);
|
|
15794
|
+
if (s.length === 0) {
|
|
15595
15795
|
if (n && n.status !== "completed") {
|
|
15596
15796
|
let t = Number(r.processed ?? 0);
|
|
15597
|
-
Yr(e,
|
|
15797
|
+
Yr(e, Ey, {
|
|
15598
15798
|
message: "Ref backfill complete",
|
|
15599
15799
|
progressCurrent: t,
|
|
15600
15800
|
progressTotal: Number(r.total_backfillable ?? t),
|
|
15601
15801
|
metadata: {
|
|
15602
15802
|
...r,
|
|
15603
15803
|
remaining: 0,
|
|
15604
|
-
last_cursor_id:
|
|
15804
|
+
last_cursor_id: o
|
|
15605
15805
|
}
|
|
15606
15806
|
});
|
|
15607
15807
|
}
|
|
15608
15808
|
return !1;
|
|
15609
15809
|
}
|
|
15610
|
-
let
|
|
15611
|
-
if (
|
|
15810
|
+
let c = a ? 0 : Number(r.processed ?? 0), l = Number(r.total_backfillable ?? 0);
|
|
15811
|
+
if (a) {
|
|
15612
15812
|
let t = e.prepare(`SELECT COUNT(*) AS cnt FROM memory_items mi
|
|
15613
|
-
WHERE ${
|
|
15813
|
+
WHERE ${Dy}`).get().cnt;
|
|
15614
15814
|
qr(e, {
|
|
15615
|
-
kind:
|
|
15815
|
+
kind: Ey,
|
|
15616
15816
|
title: "Backfilling memory file/concept refs",
|
|
15617
15817
|
message: `Backfilling refs for ${t} memories`,
|
|
15618
15818
|
progressTotal: t,
|
|
15619
15819
|
metadata: {
|
|
15620
15820
|
total_backfillable: t,
|
|
15621
|
-
processed:
|
|
15821
|
+
processed: c,
|
|
15622
15822
|
remaining: t,
|
|
15623
15823
|
last_cursor_id: 0
|
|
15624
15824
|
}
|
|
15625
|
-
}),
|
|
15825
|
+
}), l = t;
|
|
15626
15826
|
}
|
|
15627
|
-
let
|
|
15628
|
-
let t =
|
|
15629
|
-
if (t) for (let n of t) n &&
|
|
15630
|
-
if (n) for (let t of n) t &&
|
|
15827
|
+
let u = e.prepare("INSERT OR IGNORE INTO memory_file_refs (memory_id, file_path, relation) VALUES (?, ?, ?)"), d = e.prepare("INSERT OR IGNORE INTO memory_concept_refs (memory_id, concept) VALUES (?, ?)"), f = e.transaction((e) => {
|
|
15828
|
+
let t = Ay(e.files_read), n = Ay(e.files_modified), r = Ay(e.concepts);
|
|
15829
|
+
if (t) for (let n of t) n && u.run(e.id, n, "read");
|
|
15830
|
+
if (n) for (let t of n) t && u.run(e.id, t, "modified");
|
|
15631
15831
|
if (r) for (let t of r) {
|
|
15632
15832
|
let n = ma(t ?? "");
|
|
15633
|
-
n &&
|
|
15833
|
+
n && d.run(e.id, n);
|
|
15634
15834
|
}
|
|
15635
15835
|
});
|
|
15636
|
-
for (let e of
|
|
15637
|
-
let
|
|
15638
|
-
if (
|
|
15639
|
-
let t = Number(
|
|
15640
|
-
return Yr(e,
|
|
15836
|
+
for (let e of s) f(e);
|
|
15837
|
+
let p = c + s.length, m = s.length < i, h = s[s.length - 1].id;
|
|
15838
|
+
if (m) {
|
|
15839
|
+
let t = Number(ky(e).total_backfillable ?? l ?? p);
|
|
15840
|
+
return Yr(e, Ey, {
|
|
15641
15841
|
message: "Ref backfill complete",
|
|
15642
|
-
progressCurrent:
|
|
15842
|
+
progressCurrent: t,
|
|
15643
15843
|
progressTotal: t,
|
|
15644
15844
|
metadata: {
|
|
15645
15845
|
total_backfillable: t,
|
|
15646
|
-
processed:
|
|
15846
|
+
processed: p,
|
|
15647
15847
|
remaining: 0,
|
|
15648
|
-
last_cursor_id:
|
|
15848
|
+
last_cursor_id: h
|
|
15649
15849
|
}
|
|
15650
15850
|
}), !1;
|
|
15651
15851
|
}
|
|
15652
|
-
return Jr(e,
|
|
15653
|
-
message: `Backfilled refs for ${
|
|
15654
|
-
progressCurrent:
|
|
15655
|
-
progressTotal:
|
|
15852
|
+
return Jr(e, Ey, {
|
|
15853
|
+
message: `Backfilled refs for ${p} of ${l} memories`,
|
|
15854
|
+
progressCurrent: p,
|
|
15855
|
+
progressTotal: l,
|
|
15656
15856
|
metadata: {
|
|
15657
|
-
total_backfillable:
|
|
15658
|
-
processed:
|
|
15659
|
-
remaining: Math.max(
|
|
15660
|
-
last_cursor_id:
|
|
15857
|
+
total_backfillable: l,
|
|
15858
|
+
processed: p,
|
|
15859
|
+
remaining: Math.max(l - p, 0),
|
|
15860
|
+
last_cursor_id: h
|
|
15661
15861
|
}
|
|
15662
15862
|
}), !0;
|
|
15663
15863
|
}
|
|
15664
|
-
var
|
|
15864
|
+
var My = class {
|
|
15665
15865
|
dbPath;
|
|
15666
15866
|
signal;
|
|
15667
15867
|
batchSize;
|
|
@@ -15691,14 +15891,14 @@ var Cy = class {
|
|
|
15691
15891
|
if (!this.active || this.signal?.aborted) return;
|
|
15692
15892
|
let e = null;
|
|
15693
15893
|
try {
|
|
15694
|
-
e = Mn(this.dbPath), await
|
|
15894
|
+
e = Mn(this.dbPath), await jy(e, { batchSize: this.batchSize }) || (this.active = !1);
|
|
15695
15895
|
} catch (t) {
|
|
15696
|
-
e && Xr(e,
|
|
15896
|
+
e && Xr(e, Ey, t instanceof Error ? t.message : String(t)), console.warn("Ref backfill runner failed", t);
|
|
15697
15897
|
} finally {
|
|
15698
15898
|
e?.close();
|
|
15699
15899
|
}
|
|
15700
15900
|
}
|
|
15701
|
-
},
|
|
15901
|
+
}, Ny = "session_context_backfill", Py = [
|
|
15702
15902
|
"firstPrompt",
|
|
15703
15903
|
"promptCount",
|
|
15704
15904
|
"toolCount",
|
|
@@ -15706,20 +15906,20 @@ var Cy = class {
|
|
|
15706
15906
|
"filesModified",
|
|
15707
15907
|
"filesRead"
|
|
15708
15908
|
];
|
|
15709
|
-
function
|
|
15909
|
+
function Fy(e) {
|
|
15710
15910
|
let t = e.prepare("SELECT COUNT(*) AS c FROM sessions\n WHERE json_extract(metadata_json, '$.session_context.flusher') = 'raw_events'").get();
|
|
15711
15911
|
return Number(t?.c ?? 0);
|
|
15712
15912
|
}
|
|
15713
|
-
function
|
|
15913
|
+
function Iy(e, t, n) {
|
|
15714
15914
|
return e.prepare("SELECT\n s.id AS id,\n s.metadata_json AS metadata_json,\n os.source AS source,\n os.stream_id AS stream_id\n FROM sessions s\n LEFT JOIN (\n SELECT session_id, source, stream_id\n FROM opencode_sessions\n GROUP BY session_id\n ) os ON os.session_id = s.id\n WHERE s.id > ?\n AND json_extract(s.metadata_json, '$.session_context.flusher') = 'raw_events'\n ORDER BY s.id ASC\n LIMIT ?").all(t, n);
|
|
15715
15915
|
}
|
|
15716
|
-
function
|
|
15916
|
+
function Ly(e, t, n) {
|
|
15717
15917
|
return e.prepare("SELECT event_seq, event_type, ts_wall_ms, ts_mono_ms, payload_json, event_id\n FROM raw_events\n WHERE source = ? AND stream_id = ?\n ORDER BY event_seq ASC").all(t, n).map((e) => {
|
|
15718
15918
|
let t = JSON.parse(e.payload_json);
|
|
15719
15919
|
return t.type = t.type || e.event_type, t.timestamp_wall_ms = e.ts_wall_ms, t.timestamp_mono_ms = e.ts_mono_ms, t.event_seq = e.event_seq, t.event_id = e.event_id, t;
|
|
15720
15920
|
});
|
|
15721
15921
|
}
|
|
15722
|
-
function
|
|
15922
|
+
function Ry(e) {
|
|
15723
15923
|
if (!e) return {};
|
|
15724
15924
|
try {
|
|
15725
15925
|
let t = JSON.parse(e);
|
|
@@ -15727,42 +15927,42 @@ function ky(e) {
|
|
|
15727
15927
|
} catch {}
|
|
15728
15928
|
return {};
|
|
15729
15929
|
}
|
|
15730
|
-
function
|
|
15930
|
+
function zy(e) {
|
|
15731
15931
|
return Array.isArray(e) ? [...e].sort() : e ?? null;
|
|
15732
15932
|
}
|
|
15733
|
-
function
|
|
15734
|
-
for (let n of
|
|
15735
|
-
let r =
|
|
15933
|
+
function By(e, t) {
|
|
15934
|
+
for (let n of Py) {
|
|
15935
|
+
let r = zy(e[n]), i = zy(t[n]);
|
|
15736
15936
|
if (JSON.stringify(r) !== JSON.stringify(i)) return !0;
|
|
15737
15937
|
}
|
|
15738
15938
|
return !1;
|
|
15739
15939
|
}
|
|
15740
|
-
function
|
|
15940
|
+
function Vy(e, t) {
|
|
15741
15941
|
let n = { ...e };
|
|
15742
|
-
for (let e of
|
|
15942
|
+
for (let e of Py) {
|
|
15743
15943
|
let r = t[e];
|
|
15744
15944
|
r === void 0 ? delete n[e] : n[e] = r;
|
|
15745
15945
|
}
|
|
15746
15946
|
return n;
|
|
15747
15947
|
}
|
|
15748
|
-
function
|
|
15948
|
+
function Hy(e, t, n) {
|
|
15749
15949
|
let r = 0, i = 0, a = 0, o = 0, s = t.at(-1)?.id ?? 0, c = e.prepare("UPDATE sessions SET metadata_json = ? WHERE id = ?");
|
|
15750
15950
|
for (let n of t) {
|
|
15751
15951
|
if (s = n.id, !n.source || !n.stream_id) {
|
|
15752
15952
|
a += 1;
|
|
15753
15953
|
continue;
|
|
15754
15954
|
}
|
|
15755
|
-
let t =
|
|
15955
|
+
let t = Ly(e, n.source, n.stream_id);
|
|
15756
15956
|
if (t.length === 0) {
|
|
15757
15957
|
i += 1;
|
|
15758
15958
|
continue;
|
|
15759
15959
|
}
|
|
15760
|
-
let l = tv(S_(t)), u =
|
|
15761
|
-
if (!
|
|
15960
|
+
let l = tv(S_(t)), u = Ry(n.metadata_json), d = u.session_context, f = d && typeof d == "object" ? d : {};
|
|
15961
|
+
if (!By(f, l)) {
|
|
15762
15962
|
o += 1;
|
|
15763
15963
|
continue;
|
|
15764
15964
|
}
|
|
15765
|
-
let p =
|
|
15965
|
+
let p = Vy(f, l), m = {
|
|
15766
15966
|
...u,
|
|
15767
15967
|
session_context: p
|
|
15768
15968
|
};
|
|
@@ -15778,14 +15978,14 @@ function Ny(e, t, n) {
|
|
|
15778
15978
|
exhausted: t.length < n
|
|
15779
15979
|
};
|
|
15780
15980
|
}
|
|
15781
|
-
function
|
|
15782
|
-
return Q(e, "session_context_backfill")?.status === "completed" ? !1 :
|
|
15981
|
+
function Uy(e) {
|
|
15982
|
+
return Q(e, "session_context_backfill")?.status === "completed" ? !1 : Fy(e) > 0;
|
|
15783
15983
|
}
|
|
15784
|
-
async function
|
|
15785
|
-
let n = Math.max(1, t.batchSize ?? 100), r = Q(e,
|
|
15984
|
+
async function Wy(e, t = {}) {
|
|
15985
|
+
let n = Math.max(1, t.batchSize ?? 100), r = Q(e, Ny), i = r?.metadata ?? {}, a = !r || r.status === "completed" || r.status === "failed", o = a ? 0 : Number(i.last_cursor_id ?? 0), s = a ? Fy(e) : Number(i.total_candidates ?? Fy(e));
|
|
15786
15986
|
if (a && s <= 0) return !1;
|
|
15787
15987
|
a && qr(e, {
|
|
15788
|
-
kind:
|
|
15988
|
+
kind: Ny,
|
|
15789
15989
|
title: "Backfilling session context",
|
|
15790
15990
|
message: `Rebuilding session_context for ${s} raw-event sessions`,
|
|
15791
15991
|
progressTotal: s,
|
|
@@ -15799,11 +15999,11 @@ async function Fy(e, t = {}) {
|
|
|
15799
15999
|
unchanged_sessions: 0
|
|
15800
16000
|
}
|
|
15801
16001
|
});
|
|
15802
|
-
let c =
|
|
16002
|
+
let c = Iy(e, o, n);
|
|
15803
16003
|
if (c.length === 0) {
|
|
15804
16004
|
let t = Q(e, "session_context_backfill")?.metadata ?? {};
|
|
15805
|
-
return Yr(e,
|
|
15806
|
-
message:
|
|
16005
|
+
return Yr(e, Ny, {
|
|
16006
|
+
message: Gy(t),
|
|
15807
16007
|
progressCurrent: Number(t.processed_sessions ?? 0),
|
|
15808
16008
|
progressTotal: Number(t.total_candidates ?? t.processed_sessions ?? 0),
|
|
15809
16009
|
metadata: {
|
|
@@ -15812,7 +16012,7 @@ async function Fy(e, t = {}) {
|
|
|
15812
16012
|
}
|
|
15813
16013
|
}), !1;
|
|
15814
16014
|
}
|
|
15815
|
-
let l =
|
|
16015
|
+
let l = Hy(e, c, n), u = Q(e, "session_context_backfill")?.metadata ?? {}, d = Number(u.processed_sessions ?? 0) + l.processed, f = Number(u.rewritten_sessions ?? 0) + l.rewritten, p = Number(u.skipped_no_events ?? 0) + l.skippedNoEvents, m = Number(u.skipped_no_bridge ?? 0) + l.skippedNoBridge, h = Number(u.unchanged_sessions ?? 0) + l.unchanged, g = {
|
|
15816
16016
|
last_cursor_id: l.lastCursorId,
|
|
15817
16017
|
total_candidates: Number(u.total_candidates ?? s),
|
|
15818
16018
|
processed_sessions: d,
|
|
@@ -15821,12 +16021,12 @@ async function Fy(e, t = {}) {
|
|
|
15821
16021
|
skipped_no_bridge: m,
|
|
15822
16022
|
unchanged_sessions: h
|
|
15823
16023
|
};
|
|
15824
|
-
return l.exhausted ? (Yr(e,
|
|
15825
|
-
message:
|
|
16024
|
+
return l.exhausted ? (Yr(e, Ny, {
|
|
16025
|
+
message: Gy(g),
|
|
15826
16026
|
progressCurrent: d,
|
|
15827
16027
|
progressTotal: Number(g.total_candidates ?? d),
|
|
15828
16028
|
metadata: g
|
|
15829
|
-
}), !1) : (Jr(e,
|
|
16029
|
+
}), !1) : (Jr(e, Ny, {
|
|
15830
16030
|
status: "running",
|
|
15831
16031
|
message: `Rebuilt session_context for ${f} of ${d} scanned sessions`,
|
|
15832
16032
|
progressCurrent: d,
|
|
@@ -15834,11 +16034,11 @@ async function Fy(e, t = {}) {
|
|
|
15834
16034
|
metadata: g
|
|
15835
16035
|
}), !0);
|
|
15836
16036
|
}
|
|
15837
|
-
function
|
|
16037
|
+
function Gy(e) {
|
|
15838
16038
|
let t = Number(e.rewritten_sessions ?? 0), n = Number(e.processed_sessions ?? 0), r = Number(e.skipped_no_events ?? 0) + Number(e.skipped_no_bridge ?? 0);
|
|
15839
16039
|
return n === 0 ? "No raw-event sessions required session_context backfill" : t === 0 ? `Scanned ${n} sessions, no session_context rewrite required` : `Rebuilt session_context for ${t} of ${n} sessions${r > 0 ? ` (${r} skipped)` : ""}`;
|
|
15840
16040
|
}
|
|
15841
|
-
var
|
|
16041
|
+
var Ky = class {
|
|
15842
16042
|
dbPath;
|
|
15843
16043
|
signal;
|
|
15844
16044
|
batchSize;
|
|
@@ -15868,25 +16068,25 @@ var Ly = class {
|
|
|
15868
16068
|
if (!this.active || this.signal?.aborted) return;
|
|
15869
16069
|
let e = null;
|
|
15870
16070
|
try {
|
|
15871
|
-
e = Mn(this.dbPath), await
|
|
16071
|
+
e = Mn(this.dbPath), await Wy(e, { batchSize: this.batchSize }) || (this.active = !1);
|
|
15872
16072
|
} catch (t) {
|
|
15873
|
-
e && Xr(e,
|
|
16073
|
+
e && Xr(e, Ny, t instanceof Error ? t.message : String(t)), console.warn("Session-context backfill runner failed", t);
|
|
15874
16074
|
} finally {
|
|
15875
16075
|
e?.close();
|
|
15876
16076
|
}
|
|
15877
16077
|
}
|
|
15878
|
-
},
|
|
15879
|
-
function
|
|
16078
|
+
}, qy = "session_summary_dedup_backfill";
|
|
16079
|
+
function Jy(e) {
|
|
15880
16080
|
let t = e.prepare("SELECT COUNT(*) AS n FROM (\n SELECT session_id\n FROM memory_items\n WHERE active = 1\n AND kind = 'session_summary'\n AND json_extract(metadata_json, '$.source') = 'observer_summary'\n GROUP BY session_id\n HAVING COUNT(*) > 1\n )").get();
|
|
15881
16081
|
return Number(t?.n ?? 0);
|
|
15882
16082
|
}
|
|
15883
|
-
function
|
|
15884
|
-
return
|
|
16083
|
+
function Yy(e) {
|
|
16084
|
+
return Jy(e) > 0;
|
|
15885
16085
|
}
|
|
15886
|
-
function
|
|
16086
|
+
function Xy(e) {
|
|
15887
16087
|
return Q(e, "session_summary_dedup_backfill")?.metadata ?? {};
|
|
15888
16088
|
}
|
|
15889
|
-
function
|
|
16089
|
+
function Zy(e, t, n) {
|
|
15890
16090
|
let r = e.prepare("SELECT session_id\n FROM memory_items\n WHERE active = 1\n AND kind = 'session_summary'\n AND json_extract(metadata_json, '$.source') = 'observer_summary'\n AND session_id > ?\n GROUP BY session_id\n HAVING COUNT(*) > 1\n ORDER BY session_id ASC\n LIMIT ?").all(t, n);
|
|
15891
16091
|
if (r.length === 0) return [];
|
|
15892
16092
|
let i = e.prepare("SELECT id, rev, metadata_json, created_at\n FROM memory_items\n WHERE session_id = ?\n AND active = 1\n AND kind = 'session_summary'\n AND json_extract(metadata_json, '$.source') = 'observer_summary'\n ORDER BY created_at DESC, id DESC"), a = [];
|
|
@@ -15902,7 +16102,7 @@ function Hy(e, t, n) {
|
|
|
15902
16102
|
}
|
|
15903
16103
|
return a;
|
|
15904
16104
|
}
|
|
15905
|
-
function
|
|
16105
|
+
function Qy(e, t, n) {
|
|
15906
16106
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = e.prepare("UPDATE memory_items\n SET active = 0,\n deleted_at = ?,\n updated_at = ?,\n metadata_json = ?,\n rev = ?\n WHERE id = ?"), a = 0;
|
|
15907
16107
|
for (let o of t.superseded) {
|
|
15908
16108
|
let s = Un(o.metadata_json);
|
|
@@ -15918,9 +16118,9 @@ function Uy(e, t, n) {
|
|
|
15918
16118
|
}
|
|
15919
16119
|
return a;
|
|
15920
16120
|
}
|
|
15921
|
-
async function
|
|
15922
|
-
let n = Math.max(1, t.batchSize ?? 50), r = t.deviceId ?? "local", i = Q(e,
|
|
15923
|
-
if (c.length === 0) return i && i.status !== "completed" && Yr(e,
|
|
16121
|
+
async function $y(e, t = {}) {
|
|
16122
|
+
let n = Math.max(1, t.batchSize ?? 50), r = t.deviceId ?? "local", i = Q(e, qy), a = Xy(e), o = !i || i.status === "completed" || i.status === "failed", s = o ? 0 : Number(a.last_session_id ?? 0), c = Zy(e, s, n), l = o ? 0 : Number(a.processed_sessions ?? 0), u = o ? 0 : Number(a.superseded_rows ?? 0);
|
|
16123
|
+
if (c.length === 0) return i && i.status !== "completed" && Yr(e, qy, {
|
|
15924
16124
|
message: u > 0 ? `Session-summary dedup complete (${u} rows superseded)` : "Session-summary dedup complete",
|
|
15925
16125
|
progressCurrent: l,
|
|
15926
16126
|
progressTotal: Number(a.total_sessions ?? l),
|
|
@@ -15930,9 +16130,9 @@ async function Wy(e, t = {}) {
|
|
|
15930
16130
|
}
|
|
15931
16131
|
}), !1;
|
|
15932
16132
|
if (!i || i.status === "completed" || i.status === "failed") {
|
|
15933
|
-
let t =
|
|
16133
|
+
let t = Jy(e);
|
|
15934
16134
|
qr(e, {
|
|
15935
|
-
kind:
|
|
16135
|
+
kind: qy,
|
|
15936
16136
|
title: "Deduplicating historical session summaries",
|
|
15937
16137
|
message: `Cleaning up ${t} sessions with duplicate observer summaries`,
|
|
15938
16138
|
progressTotal: t,
|
|
@@ -15947,10 +16147,10 @@ async function Wy(e, t = {}) {
|
|
|
15947
16147
|
}
|
|
15948
16148
|
let d = 0, f = s;
|
|
15949
16149
|
e.transaction(() => {
|
|
15950
|
-
for (let t of c) d +=
|
|
16150
|
+
for (let t of c) d += Qy(e, t, r), t.session_id > f && (f = t.session_id);
|
|
15951
16151
|
})();
|
|
15952
|
-
let p = l + c.length, m = u + d, h =
|
|
15953
|
-
return h === 0 ? (Yr(e,
|
|
16152
|
+
let p = l + c.length, m = u + d, h = Jy(e), g = Math.max(Number(a.total_sessions ?? p), p + h);
|
|
16153
|
+
return h === 0 ? (Yr(e, qy, {
|
|
15954
16154
|
message: `Session-summary dedup complete (${m} rows superseded across ${p} sessions)`,
|
|
15955
16155
|
progressCurrent: p,
|
|
15956
16156
|
progressTotal: g,
|
|
@@ -15960,7 +16160,7 @@ async function Wy(e, t = {}) {
|
|
|
15960
16160
|
superseded_rows: m,
|
|
15961
16161
|
last_session_id: f
|
|
15962
16162
|
}
|
|
15963
|
-
}), !1) : (Jr(e,
|
|
16163
|
+
}), !1) : (Jr(e, qy, {
|
|
15964
16164
|
message: `Deduplicated ${p} of ${g} sessions (${m} rows superseded)`,
|
|
15965
16165
|
progressCurrent: p,
|
|
15966
16166
|
progressTotal: g,
|
|
@@ -15972,7 +16172,7 @@ async function Wy(e, t = {}) {
|
|
|
15972
16172
|
}
|
|
15973
16173
|
}), !0);
|
|
15974
16174
|
}
|
|
15975
|
-
var
|
|
16175
|
+
var eb = class {
|
|
15976
16176
|
dbPath;
|
|
15977
16177
|
signal;
|
|
15978
16178
|
batchSize;
|
|
@@ -16003,97 +16203,97 @@ var Gy = class {
|
|
|
16003
16203
|
if (!this.active || this.signal?.aborted) return;
|
|
16004
16204
|
let e = null;
|
|
16005
16205
|
try {
|
|
16006
|
-
e = Mn(this.dbPath), await
|
|
16206
|
+
e = Mn(this.dbPath), await $y(e, {
|
|
16007
16207
|
batchSize: this.batchSize,
|
|
16008
16208
|
deviceId: this.deviceId
|
|
16009
16209
|
}) || (this.active = !1);
|
|
16010
16210
|
} catch (t) {
|
|
16011
|
-
e && Xr(e,
|
|
16211
|
+
e && Xr(e, qy, t instanceof Error ? t.message : String(t)), console.warn("Summary-dedup backfill runner failed", t);
|
|
16012
16212
|
} finally {
|
|
16013
16213
|
e?.close();
|
|
16014
16214
|
}
|
|
16015
16215
|
}
|
|
16016
|
-
},
|
|
16216
|
+
}, tb = [
|
|
16017
16217
|
"unsupported",
|
|
16018
16218
|
"aware",
|
|
16019
16219
|
"enforcing"
|
|
16020
|
-
],
|
|
16220
|
+
], nb = "X-Codemem-Sync-Capability", rb = "aware", ib = {
|
|
16021
16221
|
unsupported: 0,
|
|
16022
16222
|
aware: 1,
|
|
16023
16223
|
enforcing: 2
|
|
16024
16224
|
};
|
|
16025
|
-
function
|
|
16225
|
+
function ab(e) {
|
|
16026
16226
|
if (typeof e != "string") return "unsupported";
|
|
16027
16227
|
let t = e.trim().toLowerCase();
|
|
16028
|
-
return
|
|
16228
|
+
return tb.includes(t) ? t : "unsupported";
|
|
16029
16229
|
}
|
|
16030
|
-
function
|
|
16031
|
-
let n =
|
|
16032
|
-
return
|
|
16230
|
+
function ob(e, t) {
|
|
16231
|
+
let n = ab(e), r = ab(t);
|
|
16232
|
+
return ib[n] <= ib[r] ? n : r;
|
|
16033
16233
|
}
|
|
16034
16234
|
//#endregion
|
|
16035
16235
|
//#region src/vector-migration.ts
|
|
16036
|
-
var
|
|
16037
|
-
function
|
|
16236
|
+
var sb = "vector_model_migration", cb = "sync_bootstrap", lb = "sync_incremental", ub = 6e4, db = null;
|
|
16237
|
+
function fb(e) {
|
|
16038
16238
|
return [...new Set(e.filter((e) => Number.isInteger(e) && e > 0))].sort((e, t) => e - t);
|
|
16039
16239
|
}
|
|
16040
|
-
function
|
|
16041
|
-
return Array.isArray(e) ?
|
|
16240
|
+
function pb(e) {
|
|
16241
|
+
return Array.isArray(e) ? fb(e.filter((e) => typeof e == "number")) : [];
|
|
16042
16242
|
}
|
|
16043
|
-
function
|
|
16044
|
-
let n = new Set(
|
|
16045
|
-
for (let e of
|
|
16046
|
-
for (let e of
|
|
16243
|
+
function mb(e, t) {
|
|
16244
|
+
let n = new Set(pb(e.pending_upsert_memory_ids)), r = new Set(pb(e.pending_delete_memory_ids));
|
|
16245
|
+
for (let e of fb(t.deleteMemoryIds)) n.delete(e), r.add(e);
|
|
16246
|
+
for (let e of fb(t.upsertMemoryIds)) r.delete(e), n.add(e);
|
|
16047
16247
|
return {
|
|
16048
16248
|
pending_upsert_memory_ids: [...n],
|
|
16049
16249
|
pending_delete_memory_ids: [...r]
|
|
16050
16250
|
};
|
|
16051
16251
|
}
|
|
16052
|
-
function
|
|
16252
|
+
function hb(e, t) {
|
|
16053
16253
|
if (t.length === 0) return;
|
|
16054
16254
|
let n = t.map(() => "?").join(", ");
|
|
16055
16255
|
e.prepare(`DELETE FROM memory_vectors WHERE memory_id IN (${n})`).run(...t);
|
|
16056
16256
|
}
|
|
16057
|
-
function
|
|
16058
|
-
return JSON.stringify(
|
|
16257
|
+
function gb(e, t) {
|
|
16258
|
+
return JSON.stringify(pb(e.pending_upsert_memory_ids)) === JSON.stringify(pb(t.pending_upsert_memory_ids)) && JSON.stringify(pb(e.pending_delete_memory_ids)) === JSON.stringify(pb(t.pending_delete_memory_ids));
|
|
16059
16259
|
}
|
|
16060
|
-
function
|
|
16061
|
-
|
|
16260
|
+
function _b() {
|
|
16261
|
+
db?.wake();
|
|
16062
16262
|
}
|
|
16063
|
-
function
|
|
16064
|
-
let n =
|
|
16263
|
+
function vb(e, t) {
|
|
16264
|
+
let n = mb({}, t);
|
|
16065
16265
|
if ((n.pending_upsert_memory_ids?.length ?? 0) === 0 && (n.pending_delete_memory_ids?.length ?? 0) === 0) return;
|
|
16066
|
-
let r = Q(e,
|
|
16266
|
+
let r = Q(e, sb), i = r && r.status !== "completed" && r.status !== "cancelled" ? r.metadata ?? {} : {}, a = {
|
|
16067
16267
|
...i,
|
|
16068
|
-
...
|
|
16069
|
-
trigger: i.trigger ??
|
|
16070
|
-
}, o =
|
|
16268
|
+
...mb(i, t),
|
|
16269
|
+
trigger: i.trigger ?? lb
|
|
16270
|
+
}, o = pb(a.pending_upsert_memory_ids).length + pb(a.pending_delete_memory_ids).length;
|
|
16071
16271
|
if (!r || r.status === "completed" || r.status === "cancelled") {
|
|
16072
16272
|
qr(e, {
|
|
16073
|
-
kind:
|
|
16273
|
+
kind: sb,
|
|
16074
16274
|
title: "Re-indexing memories",
|
|
16075
16275
|
status: "pending",
|
|
16076
16276
|
message: "Queued vector catch-up for incremental sync data",
|
|
16077
16277
|
progressTotal: null,
|
|
16078
16278
|
metadata: a
|
|
16079
|
-
}),
|
|
16279
|
+
}), _b();
|
|
16080
16280
|
return;
|
|
16081
16281
|
}
|
|
16082
|
-
Jr(e,
|
|
16282
|
+
Jr(e, sb, {
|
|
16083
16283
|
status: "pending",
|
|
16084
16284
|
message: "Queued vector catch-up for incremental sync data",
|
|
16085
16285
|
progressCurrent: r.status === "failed" ? 0 : Math.min(r.progress.current, o),
|
|
16086
16286
|
progressTotal: r.progress.total,
|
|
16087
16287
|
metadata: a
|
|
16088
|
-
}),
|
|
16288
|
+
}), _b();
|
|
16089
16289
|
}
|
|
16090
|
-
async function
|
|
16091
|
-
let a = t.metadata ?? {}, o =
|
|
16290
|
+
async function yb(e, t, n, r, i) {
|
|
16291
|
+
let a = t.metadata ?? {}, o = pb(a.pending_delete_memory_ids), s = pb(a.pending_upsert_memory_ids);
|
|
16092
16292
|
if (o.length === 0 && s.length === 0) return {
|
|
16093
16293
|
completed: !1,
|
|
16094
16294
|
metadata: a
|
|
16095
16295
|
};
|
|
16096
|
-
o.length > 0 &&
|
|
16296
|
+
o.length > 0 && hb(e, o);
|
|
16097
16297
|
let c = s.slice(0, r);
|
|
16098
16298
|
if (c.length > 0) {
|
|
16099
16299
|
if (await ks(e, {
|
|
@@ -16109,14 +16309,14 @@ async function ub(e, t, n, r, i) {
|
|
|
16109
16309
|
...a,
|
|
16110
16310
|
pending_delete_memory_ids: [],
|
|
16111
16311
|
pending_upsert_memory_ids: s.slice(c.length)
|
|
16112
|
-
}, u = Q(e, "vector_model_migration")?.metadata ?? {}, d =
|
|
16312
|
+
}, u = Q(e, "vector_model_migration")?.metadata ?? {}, d = gb(u, a) ? l : {
|
|
16113
16313
|
...u,
|
|
16114
|
-
...
|
|
16115
|
-
upsertMemoryIds:
|
|
16116
|
-
deleteMemoryIds:
|
|
16314
|
+
...mb(u, {
|
|
16315
|
+
upsertMemoryIds: pb(l.pending_upsert_memory_ids),
|
|
16316
|
+
deleteMemoryIds: pb(l.pending_delete_memory_ids)
|
|
16117
16317
|
})
|
|
16118
|
-
}, f =
|
|
16119
|
-
return f === 0 && p ? (Yr(e,
|
|
16318
|
+
}, f = pb(d.pending_delete_memory_ids).length + pb(d.pending_upsert_memory_ids).length, p = (a.trigger ?? lb) === lb && !a.source_model && !a.last_cursor_id && a.embeddable_total == null;
|
|
16319
|
+
return f === 0 && p ? (Yr(e, sb, {
|
|
16120
16320
|
message: "Finished vector catch-up for incremental sync data",
|
|
16121
16321
|
progressCurrent: 0,
|
|
16122
16322
|
progressTotal: null,
|
|
@@ -16124,7 +16324,7 @@ async function ub(e, t, n, r, i) {
|
|
|
16124
16324
|
}), {
|
|
16125
16325
|
completed: !0,
|
|
16126
16326
|
metadata: d
|
|
16127
|
-
}) : (Jr(e,
|
|
16327
|
+
}) : (Jr(e, sb, {
|
|
16128
16328
|
status: f > 0 ? "running" : t.status,
|
|
16129
16329
|
message: f > 0 ? `Queued vector catch-up has ${f} memory change(s) remaining` : t.message,
|
|
16130
16330
|
progressCurrent: 0,
|
|
@@ -16135,36 +16335,36 @@ async function ub(e, t, n, r, i) {
|
|
|
16135
16335
|
metadata: d
|
|
16136
16336
|
});
|
|
16137
16337
|
}
|
|
16138
|
-
function
|
|
16338
|
+
function bb(e, t = {}) {
|
|
16139
16339
|
let n = typeof t.embeddableTotal == "number" && t.embeddableTotal >= 0 ? t.embeddableTotal : null, r = {
|
|
16140
16340
|
last_cursor_id: 0,
|
|
16141
16341
|
processed_embeddable: 0,
|
|
16142
|
-
trigger:
|
|
16342
|
+
trigger: cb
|
|
16143
16343
|
};
|
|
16144
16344
|
n != null && (r.embeddable_total = n), qr(e, {
|
|
16145
|
-
kind:
|
|
16345
|
+
kind: sb,
|
|
16146
16346
|
title: "Re-indexing memories",
|
|
16147
16347
|
status: "pending",
|
|
16148
16348
|
message: "Queued vector catch-up for synced bootstrap data",
|
|
16149
16349
|
progressTotal: n,
|
|
16150
16350
|
metadata: r
|
|
16151
|
-
}),
|
|
16351
|
+
}), _b();
|
|
16152
16352
|
}
|
|
16153
|
-
function
|
|
16353
|
+
function xb(e) {
|
|
16154
16354
|
return e.prepare("SELECT model, COUNT(*) AS rows FROM memory_vectors GROUP BY model ORDER BY rows DESC, model ASC").all();
|
|
16155
16355
|
}
|
|
16156
|
-
function
|
|
16356
|
+
function Sb(e) {
|
|
16157
16357
|
let t = e.prepare("SELECT COUNT(*) AS c FROM memory_items\n WHERE active = 1\n AND TRIM(COALESCE(title, '') || COALESCE(body_text, '')) != ''").get();
|
|
16158
16358
|
return Number(t?.c ?? 0);
|
|
16159
16359
|
}
|
|
16160
|
-
function
|
|
16360
|
+
function Cb(e, t, n) {
|
|
16161
16361
|
return e.prepare("SELECT id, title, body_text\n FROM memory_items\n WHERE active = 1 AND id > ?\n ORDER BY id ASC\n LIMIT ?").all(t, n);
|
|
16162
16362
|
}
|
|
16163
|
-
function
|
|
16363
|
+
function wb(e) {
|
|
16164
16364
|
return `${e.title ?? ""}
|
|
16165
16365
|
${e.body_text ?? ""}`.trim().length > 0;
|
|
16166
16366
|
}
|
|
16167
|
-
function
|
|
16367
|
+
function Tb(e, t, n, r) {
|
|
16168
16368
|
let i = e?.metadata ?? {};
|
|
16169
16369
|
return {
|
|
16170
16370
|
source_model: t ?? i.source_model ?? null,
|
|
@@ -16174,39 +16374,39 @@ function gb(e, t, n, r) {
|
|
|
16174
16374
|
embeddable_total: Number(i.embeddable_total ?? r)
|
|
16175
16375
|
};
|
|
16176
16376
|
}
|
|
16177
|
-
function
|
|
16377
|
+
function Eb(e, t) {
|
|
16178
16378
|
let n = e.prepare("SELECT COUNT(*) AS c FROM memory_vectors WHERE model != ?").get(t), r = Number(n?.c ?? 0);
|
|
16179
16379
|
return r > 0 && e.prepare("DELETE FROM memory_vectors WHERE model != ?").run(t), r;
|
|
16180
16380
|
}
|
|
16181
|
-
function
|
|
16182
|
-
return
|
|
16381
|
+
function Db(e, t) {
|
|
16382
|
+
return xb(e).filter((e) => e.model !== t)[0]?.model ?? null;
|
|
16183
16383
|
}
|
|
16184
|
-
async function
|
|
16185
|
-
let n = Q(e,
|
|
16384
|
+
async function Ob(e, t = {}) {
|
|
16385
|
+
let n = Q(e, sb), r = n?.status === "running" || n?.status === "pending";
|
|
16186
16386
|
if (Ln()) {
|
|
16187
|
-
r && Xr(e,
|
|
16387
|
+
r && Xr(e, sb, "Embeddings are disabled", { message: "Vector re-indexing is waiting for embeddings to be enabled" });
|
|
16188
16388
|
return;
|
|
16189
16389
|
}
|
|
16190
16390
|
let i = await es();
|
|
16191
16391
|
if (!i) {
|
|
16192
|
-
r && Xr(e,
|
|
16392
|
+
r && Xr(e, sb, "Embedding client unavailable", { message: "Vector re-indexing is waiting for the embedding client" });
|
|
16193
16393
|
return;
|
|
16194
16394
|
}
|
|
16195
|
-
let a = i.model, o = Math.max(1, t.batchSize ?? 50), s = n?.metadata ?? {}, c =
|
|
16395
|
+
let a = i.model, o = Math.max(1, t.batchSize ?? 50), s = n?.metadata ?? {}, c = pb(s.pending_upsert_memory_ids).length + pb(s.pending_delete_memory_ids).length;
|
|
16196
16396
|
if (n?.status === "completed" && s.target_model === a && c === 0) return;
|
|
16197
16397
|
if (n) {
|
|
16198
|
-
let r = await
|
|
16398
|
+
let r = await yb(e, n, a, o, t.signal);
|
|
16199
16399
|
if (r.completed) return;
|
|
16200
|
-
let i =
|
|
16201
|
-
if ((r.metadata.trigger ??
|
|
16202
|
-
n = Q(e,
|
|
16400
|
+
let i = pb(r.metadata.pending_delete_memory_ids).length + pb(r.metadata.pending_upsert_memory_ids).length;
|
|
16401
|
+
if ((r.metadata.trigger ?? lb) === lb && i > 0) return;
|
|
16402
|
+
n = Q(e, sb);
|
|
16203
16403
|
}
|
|
16204
|
-
let l =
|
|
16205
|
-
if (!l && (d ===
|
|
16404
|
+
let l = Db(e, a), u = n?.status === "running" || n?.status === "pending" || n?.status === "failed", d = n?.metadata?.trigger;
|
|
16405
|
+
if (!l && (d === lb || d === cb) && u) {
|
|
16206
16406
|
let t = e.prepare("SELECT COUNT(*) AS c FROM memory_items\n WHERE active = 1\n AND id NOT IN (SELECT DISTINCT memory_id FROM memory_vectors WHERE model = ?)").get(a);
|
|
16207
16407
|
if (Number(t?.c ?? 0) <= 0) {
|
|
16208
|
-
let t = n?.metadata ?? {}, r =
|
|
16209
|
-
Yr(e,
|
|
16408
|
+
let t = n?.metadata ?? {}, r = Sb(e);
|
|
16409
|
+
Yr(e, sb, {
|
|
16210
16410
|
message: "Finished re-indexing memories",
|
|
16211
16411
|
progressCurrent: r,
|
|
16212
16412
|
progressTotal: r,
|
|
@@ -16221,9 +16421,9 @@ async function yb(e, t = {}) {
|
|
|
16221
16421
|
return;
|
|
16222
16422
|
}
|
|
16223
16423
|
}
|
|
16224
|
-
let f = n?.metadata ?? {}, p = (n?.status === "running" || n?.status === "pending") && f.embeddable_total ? Number(f.embeddable_total) :
|
|
16424
|
+
let f = n?.metadata ?? {}, p = (n?.status === "running" || n?.status === "pending") && f.embeddable_total ? Number(f.embeddable_total) : Sb(e);
|
|
16225
16425
|
if (p <= 0 && u && !l) {
|
|
16226
|
-
Yr(e,
|
|
16426
|
+
Yr(e, sb, {
|
|
16227
16427
|
message: "No embeddable memories to re-index",
|
|
16228
16428
|
progressCurrent: 0,
|
|
16229
16429
|
progressTotal: 0,
|
|
@@ -16237,9 +16437,9 @@ async function yb(e, t = {}) {
|
|
|
16237
16437
|
return;
|
|
16238
16438
|
}
|
|
16239
16439
|
if (l && p <= 0) {
|
|
16240
|
-
let t =
|
|
16440
|
+
let t = Eb(e, a);
|
|
16241
16441
|
qr(e, {
|
|
16242
|
-
kind:
|
|
16442
|
+
kind: sb,
|
|
16243
16443
|
title: "Re-indexing memories",
|
|
16244
16444
|
message: t > 0 ? `Removed ${t} stale vector rows` : "No embeddable memories to re-index",
|
|
16245
16445
|
progressTotal: 0,
|
|
@@ -16248,7 +16448,7 @@ async function yb(e, t = {}) {
|
|
|
16248
16448
|
target_model: a,
|
|
16249
16449
|
removed_stale_rows: t
|
|
16250
16450
|
}
|
|
16251
|
-
}), Yr(e,
|
|
16451
|
+
}), Yr(e, sb, {
|
|
16252
16452
|
progressCurrent: 0,
|
|
16253
16453
|
progressTotal: 0,
|
|
16254
16454
|
metadata: {
|
|
@@ -16259,15 +16459,15 @@ async function yb(e, t = {}) {
|
|
|
16259
16459
|
});
|
|
16260
16460
|
return;
|
|
16261
16461
|
}
|
|
16262
|
-
let m = n, h =
|
|
16462
|
+
let m = n, h = Tb(m, l, a, p);
|
|
16263
16463
|
(!m || m.status === "completed" || m.status === "failed") && qr(e, {
|
|
16264
|
-
kind:
|
|
16464
|
+
kind: sb,
|
|
16265
16465
|
title: "Re-indexing memories",
|
|
16266
16466
|
message: l ? `Building ${a} vectors while semantic search falls back to FTS-only` : `Building ${a} vectors`,
|
|
16267
16467
|
progressTotal: p,
|
|
16268
16468
|
metadata: h
|
|
16269
16469
|
});
|
|
16270
|
-
let g =
|
|
16470
|
+
let g = Cb(e, h.last_cursor_id ?? 0, o), _ = g.map((e) => e.id), v = g.filter(wb).length, y = g.at(-1)?.id ?? h.last_cursor_id ?? 0, b = Math.min(p, (h.processed_embeddable ?? 0) + v);
|
|
16271
16471
|
if (_.length > 0) {
|
|
16272
16472
|
if (await ks(e, {
|
|
16273
16473
|
memoryIds: _,
|
|
@@ -16275,8 +16475,8 @@ async function yb(e, t = {}) {
|
|
|
16275
16475
|
}), t.signal?.aborted) return;
|
|
16276
16476
|
if (g.length < o) {
|
|
16277
16477
|
e.transaction(() => {
|
|
16278
|
-
let t =
|
|
16279
|
-
Yr(e,
|
|
16478
|
+
let t = Eb(e, a);
|
|
16479
|
+
Yr(e, sb, {
|
|
16280
16480
|
message: t > 0 ? `Finished re-indexing and removed ${t} stale vector rows` : "Finished re-indexing memories",
|
|
16281
16481
|
progressCurrent: b,
|
|
16282
16482
|
progressTotal: p,
|
|
@@ -16291,7 +16491,7 @@ async function yb(e, t = {}) {
|
|
|
16291
16491
|
})();
|
|
16292
16492
|
return;
|
|
16293
16493
|
}
|
|
16294
|
-
Jr(e,
|
|
16494
|
+
Jr(e, sb, {
|
|
16295
16495
|
message: `Re-indexed ${b} of ${p} memories`,
|
|
16296
16496
|
progressCurrent: b,
|
|
16297
16497
|
progressTotal: p,
|
|
@@ -16305,8 +16505,8 @@ async function yb(e, t = {}) {
|
|
|
16305
16505
|
return;
|
|
16306
16506
|
}
|
|
16307
16507
|
h.last_cursor_id && h.last_cursor_id > 0 && e.transaction(() => {
|
|
16308
|
-
let t =
|
|
16309
|
-
Yr(e,
|
|
16508
|
+
let t = Eb(e, a);
|
|
16509
|
+
Yr(e, sb, {
|
|
16310
16510
|
message: t > 0 ? `Finished re-indexing and removed ${t} stale vector rows` : "Finished re-indexing memories",
|
|
16311
16511
|
progressCurrent: p,
|
|
16312
16512
|
progressTotal: p,
|
|
@@ -16319,7 +16519,7 @@ async function yb(e, t = {}) {
|
|
|
16319
16519
|
});
|
|
16320
16520
|
})();
|
|
16321
16521
|
}
|
|
16322
|
-
var
|
|
16522
|
+
var kb = class {
|
|
16323
16523
|
dbPath;
|
|
16324
16524
|
signal;
|
|
16325
16525
|
batchSize;
|
|
@@ -16330,13 +16530,13 @@ var bb = class {
|
|
|
16330
16530
|
currentRun = null;
|
|
16331
16531
|
lastTickWasIdle = !1;
|
|
16332
16532
|
constructor(e = {}) {
|
|
16333
|
-
this.dbPath = Dn(e.dbPath), this.signal = e.signal, this.batchSize = Math.max(1, e.batchSize ?? 50), this.intervalMs = Math.max(1e3, e.intervalMs ?? 5e3), this.idleIntervalMs = Math.max(1e3, e.idleIntervalMs ??
|
|
16533
|
+
this.dbPath = Dn(e.dbPath), this.signal = e.signal, this.batchSize = Math.max(1, e.batchSize ?? 50), this.intervalMs = Math.max(1e3, e.intervalMs ?? 5e3), this.idleIntervalMs = Math.max(1e3, e.idleIntervalMs ?? ub);
|
|
16334
16534
|
}
|
|
16335
16535
|
start() {
|
|
16336
|
-
this.active || (this.active = !0, this.lastTickWasIdle = !1,
|
|
16536
|
+
this.active || (this.active = !0, this.lastTickWasIdle = !1, db = this, this.schedule(100));
|
|
16337
16537
|
}
|
|
16338
16538
|
async stop() {
|
|
16339
|
-
this.active = !1,
|
|
16539
|
+
this.active = !1, db === this && (db = null), this.timer &&= (clearTimeout(this.timer), null), this.currentRun && await this.currentRun;
|
|
16340
16540
|
}
|
|
16341
16541
|
wake() {
|
|
16342
16542
|
this.active && (this.lastTickWasIdle = !1, this.timer && (clearTimeout(this.timer), this.timer = null, this.schedule(100)));
|
|
@@ -16356,28 +16556,28 @@ var bb = class {
|
|
|
16356
16556
|
if (!this.active || this.signal?.aborted) return;
|
|
16357
16557
|
let e = null;
|
|
16358
16558
|
try {
|
|
16359
|
-
e = Mn(this.dbPath), In(e), await
|
|
16559
|
+
e = Mn(this.dbPath), In(e), await Ob(e, {
|
|
16360
16560
|
batchSize: this.batchSize,
|
|
16361
16561
|
signal: this.signal
|
|
16362
16562
|
}), this.lastTickWasIdle = this.computeIdle(e);
|
|
16363
16563
|
} catch (t) {
|
|
16364
|
-
e && Xr(e,
|
|
16564
|
+
e && Xr(e, sb, t instanceof Error ? t.message : String(t)), this.lastTickWasIdle = !0, console.warn("Vector migration runner failed", t);
|
|
16365
16565
|
} finally {
|
|
16366
16566
|
e?.close();
|
|
16367
16567
|
}
|
|
16368
16568
|
}
|
|
16369
16569
|
computeIdle(e) {
|
|
16370
16570
|
if (Ln()) return !0;
|
|
16371
|
-
let t = Q(e,
|
|
16571
|
+
let t = Q(e, sb);
|
|
16372
16572
|
if (t) {
|
|
16373
16573
|
if (t.status === "running" || t.status === "pending") return !1;
|
|
16374
16574
|
let e = t.metadata ?? {};
|
|
16375
|
-
return !(
|
|
16575
|
+
return !(pb(e.pending_upsert_memory_ids).length + pb(e.pending_delete_memory_ids).length > 0);
|
|
16376
16576
|
}
|
|
16377
16577
|
let n = $o();
|
|
16378
16578
|
try {
|
|
16379
16579
|
let t = e.prepare("SELECT COUNT(*) AS c FROM memory_items\n WHERE active = 1\n AND TRIM(COALESCE(title, '') || COALESCE(body_text, '')) != ''\n AND id NOT IN (SELECT DISTINCT memory_id FROM memory_vectors WHERE model = ?)").get(n);
|
|
16380
|
-
return Number(t?.c ?? 0) > 0 ? !1 :
|
|
16580
|
+
return Number(t?.c ?? 0) > 0 ? !1 : Db(e, n) === null;
|
|
16381
16581
|
} catch (e) {
|
|
16382
16582
|
return console.warn("Vector migration runner idle peek failed", e), !1;
|
|
16383
16583
|
}
|
|
@@ -16385,7 +16585,7 @@ var bb = class {
|
|
|
16385
16585
|
};
|
|
16386
16586
|
//#endregion
|
|
16387
16587
|
//#region src/sync-bootstrap.ts
|
|
16388
|
-
async function
|
|
16588
|
+
async function Ab(e, t, n, r) {
|
|
16389
16589
|
let i = r?.pageSize ?? 200, a = r?.timeoutS ?? 10, o = r?.keysDir, s = r?.bootstrapGrantId?.trim() || void 0, c = r?.maxItems ?? 1e5, l = [], u = null, d = null;
|
|
16390
16590
|
for (;;) {
|
|
16391
16591
|
let r = new URLSearchParams({
|
|
@@ -16404,7 +16604,7 @@ async function xb(e, t, n, r) {
|
|
|
16404
16604
|
bootstrapGrantId: s,
|
|
16405
16605
|
keysDir: o
|
|
16406
16606
|
}),
|
|
16407
|
-
[
|
|
16607
|
+
[nb]: rb
|
|
16408
16608
|
},
|
|
16409
16609
|
timeoutS: a
|
|
16410
16610
|
});
|
|
@@ -16428,7 +16628,7 @@ async function xb(e, t, n, r) {
|
|
|
16428
16628
|
...d
|
|
16429
16629
|
};
|
|
16430
16630
|
}
|
|
16431
|
-
function
|
|
16631
|
+
function jb(e) {
|
|
16432
16632
|
if (!e.payload_json) return null;
|
|
16433
16633
|
try {
|
|
16434
16634
|
let t = JSON.parse(e.payload_json);
|
|
@@ -16437,23 +16637,23 @@ function Sb(e) {
|
|
|
16437
16637
|
return null;
|
|
16438
16638
|
}
|
|
16439
16639
|
}
|
|
16440
|
-
function
|
|
16640
|
+
function Mb(e) {
|
|
16441
16641
|
return `${typeof e.title == "string" ? e.title : ""}\n${typeof e.body_text == "string" ? e.body_text : ""}`.trim().length > 0;
|
|
16442
16642
|
}
|
|
16443
|
-
function
|
|
16643
|
+
function Nb(e) {
|
|
16444
16644
|
if (typeof e != "string") return null;
|
|
16445
16645
|
let t = e.trim();
|
|
16446
16646
|
return t.length > 0 ? t : null;
|
|
16447
16647
|
}
|
|
16448
|
-
function
|
|
16449
|
-
return t ||
|
|
16648
|
+
function Pb(e, t) {
|
|
16649
|
+
return t || Nb(e.scope_id);
|
|
16450
16650
|
}
|
|
16451
|
-
var
|
|
16452
|
-
function
|
|
16453
|
-
let r = n ?? "__none__", i =
|
|
16651
|
+
var Fb = /* @__PURE__ */ new Map();
|
|
16652
|
+
function Ib(e, t, n) {
|
|
16653
|
+
let r = n ?? "__none__", i = Fb.get(r);
|
|
16454
16654
|
if (i != null) return i;
|
|
16455
16655
|
let a = n ? `__sync_bootstrap__:${n}` : "__sync_bootstrap__", o = e.select({ id: U.id }).from(U).where(k(U.cwd, a)).limit(1).get();
|
|
16456
|
-
if (o) return
|
|
16656
|
+
if (o) return Fb.set(r, o.id), o.id;
|
|
16457
16657
|
let s = e.insert(U).values({
|
|
16458
16658
|
started_at: t,
|
|
16459
16659
|
cwd: a,
|
|
@@ -16461,25 +16661,25 @@ function Db(e, t, n) {
|
|
|
16461
16661
|
user: "sync",
|
|
16462
16662
|
tool_version: "bootstrap"
|
|
16463
16663
|
}).returning({ id: U.id }).all()[0]?.id ?? 0;
|
|
16464
|
-
return
|
|
16664
|
+
return Fb.set(r, s), s;
|
|
16465
16665
|
}
|
|
16466
|
-
function
|
|
16666
|
+
function Lb(e, t, n, r, i) {
|
|
16467
16667
|
let a = {
|
|
16468
16668
|
ok: !1,
|
|
16469
16669
|
applied: 0,
|
|
16470
16670
|
deleted: 0
|
|
16471
|
-
}, o = i ?? new dl(), s =
|
|
16671
|
+
}, o = i ?? new dl(), s = Nb(r.scope_id), c = s ? k(W.scope_id, s) : ve(pe(W.scope_id), k(W.scope_id, Su));
|
|
16472
16672
|
return e.transaction(() => {
|
|
16473
16673
|
let i = N(e, { schema: H }), l = 0;
|
|
16474
|
-
a.deleted = i.delete(W).where(O(fe(W.import_key), c, _e(M`COALESCE(${W.visibility}, '')`, "private"))).run().changes,
|
|
16674
|
+
a.deleted = i.delete(W).where(O(fe(W.import_key), c, _e(M`COALESCE(${W.visibility}, '')`, "private"))).run().changes, Fb.clear();
|
|
16475
16675
|
for (let e of n) {
|
|
16476
|
-
let t =
|
|
16676
|
+
let t = jb(e);
|
|
16477
16677
|
if (!t) continue;
|
|
16478
16678
|
gl(t, o);
|
|
16479
|
-
let n =
|
|
16679
|
+
let n = Pb(t, s), r = typeof t.project == "string" && t.project.trim() ? t.project.trim() : null, c = Ib(i, (/* @__PURE__ */ new Date()).toISOString(), r), u = t.metadata_json, d = u && typeof u == "object" && !Array.isArray(u) ? u : {};
|
|
16480
16680
|
d.clock_device_id = e.clock_device_id;
|
|
16481
16681
|
let f = e.op_type === "delete";
|
|
16482
|
-
!f &&
|
|
16682
|
+
!f && Mb(t) && l++, i.insert(W).values({
|
|
16483
16683
|
session_id: c,
|
|
16484
16684
|
kind: typeof t.kind == "string" ? t.kind : "discovery",
|
|
16485
16685
|
title: typeof t.title == "string" ? t.title : "",
|
|
@@ -16516,16 +16716,16 @@ function Ob(e, t, n, r, i) {
|
|
|
16516
16716
|
generation: r.generation,
|
|
16517
16717
|
snapshot_id: r.snapshot_id,
|
|
16518
16718
|
baseline_cursor: r.baseline_cursor
|
|
16519
|
-
}, r.scope_id),
|
|
16719
|
+
}, r.scope_id), bb(e, { embeddableTotal: l }), a.ok = !0;
|
|
16520
16720
|
}).immediate(), a;
|
|
16521
16721
|
}
|
|
16522
16722
|
//#endregion
|
|
16523
16723
|
//#region src/sync-discovery.ts
|
|
16524
|
-
var
|
|
16525
|
-
function
|
|
16724
|
+
var Rb = Ee(import.meta.url), zb = "_codemem._tcp.local.";
|
|
16725
|
+
function Bb(e) {
|
|
16526
16726
|
return e.mdns.length === 0 ? yl(e.stored, []) : yl(e.mdns, e.stored);
|
|
16527
16727
|
}
|
|
16528
|
-
function
|
|
16728
|
+
function Vb(e, t) {
|
|
16529
16729
|
let n = N(e, { schema: H }).select({ addresses_json: Y.addresses_json }).from(Y).where(k(Y.peer_device_id, t)).get();
|
|
16530
16730
|
if (!n?.addresses_json) return [];
|
|
16531
16731
|
try {
|
|
@@ -16535,8 +16735,8 @@ function Mb(e, t) {
|
|
|
16535
16735
|
return [];
|
|
16536
16736
|
}
|
|
16537
16737
|
}
|
|
16538
|
-
function
|
|
16539
|
-
let i = yl(
|
|
16738
|
+
function Hb(e, t, n, r) {
|
|
16739
|
+
let i = yl(Vb(e, t), n), a = (/* @__PURE__ */ new Date()).toISOString(), o = JSON.stringify(i);
|
|
16540
16740
|
return N(e, { schema: H }).insert(Y).values({
|
|
16541
16741
|
peer_device_id: t,
|
|
16542
16742
|
name: r?.name ?? null,
|
|
@@ -16556,7 +16756,7 @@ function Nb(e, t, n, r) {
|
|
|
16556
16756
|
}
|
|
16557
16757
|
}).run(), i;
|
|
16558
16758
|
}
|
|
16559
|
-
function
|
|
16759
|
+
function Ub(e, t, n) {
|
|
16560
16760
|
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
16561
16761
|
r.insert(ft).values({
|
|
16562
16762
|
peer_device_id: t,
|
|
@@ -16571,10 +16771,10 @@ function Pb(e, t, n) {
|
|
|
16571
16771
|
last_error: null
|
|
16572
16772
|
}).where(k(Y.peer_device_id, t)).run() : r.update(Y).set({ last_error: n.error ?? null }).where(k(Y.peer_device_id, t)).run();
|
|
16573
16773
|
}
|
|
16574
|
-
function
|
|
16774
|
+
function Wb(e, t, n) {
|
|
16575
16775
|
let r = _l(n ?? ""), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
16576
16776
|
return e.transaction((t, n, r) => {
|
|
16577
|
-
let i =
|
|
16777
|
+
let i = Vb(e, t), a = n ? i.filter((e) => _l(e) !== n) : i, o = n ? [n, ...a] : i;
|
|
16578
16778
|
return N(e, { schema: H }).update(Y).set({
|
|
16579
16779
|
addresses_json: JSON.stringify(o),
|
|
16580
16780
|
last_sync_at: r,
|
|
@@ -16583,18 +16783,18 @@ function Fb(e, t, n) {
|
|
|
16583
16783
|
}).where(k(Y.peer_device_id, t)).run(), o;
|
|
16584
16784
|
}).immediate(t, r, i);
|
|
16585
16785
|
}
|
|
16586
|
-
function
|
|
16786
|
+
function Gb(e, t, n) {
|
|
16587
16787
|
let r = n.include === null ? null : JSON.stringify(n.include), i = n.exclude === null ? null : JSON.stringify(n.exclude);
|
|
16588
16788
|
N(e, { schema: H }).update(Y).set({
|
|
16589
16789
|
projects_include_json: r,
|
|
16590
16790
|
projects_exclude_json: i
|
|
16591
16791
|
}).where(k(Y.peer_device_id, t)).run();
|
|
16592
16792
|
}
|
|
16593
|
-
function
|
|
16793
|
+
function Kb(e, t, n) {
|
|
16594
16794
|
N(e, { schema: H }).update(Y).set({ claimed_local_actor: +!!n }).where(k(Y.peer_device_id, t)).run();
|
|
16595
16795
|
}
|
|
16596
|
-
var
|
|
16597
|
-
function
|
|
16796
|
+
var qb = "codemem";
|
|
16797
|
+
function Jb() {
|
|
16598
16798
|
let e = process.env.CODEMEM_SYNC_MDNS;
|
|
16599
16799
|
if (e) return e === "1" || e.toLowerCase() === "true";
|
|
16600
16800
|
try {
|
|
@@ -16603,9 +16803,9 @@ function zb() {
|
|
|
16603
16803
|
return !1;
|
|
16604
16804
|
}
|
|
16605
16805
|
}
|
|
16606
|
-
function
|
|
16806
|
+
function Yb() {
|
|
16607
16807
|
try {
|
|
16608
|
-
let e =
|
|
16808
|
+
let e = Rb("bonjour-service"), t = e.Bonjour ?? e.default;
|
|
16609
16809
|
return t ? new t(void 0, (e) => {
|
|
16610
16810
|
console.warn("[codemem] mDNS runtime error (non-fatal):", e?.message ?? e);
|
|
16611
16811
|
}) : null;
|
|
@@ -16613,40 +16813,40 @@ function Bb() {
|
|
|
16613
16813
|
return null;
|
|
16614
16814
|
}
|
|
16615
16815
|
}
|
|
16616
|
-
var
|
|
16617
|
-
function
|
|
16618
|
-
if (
|
|
16619
|
-
let e =
|
|
16620
|
-
return e ? (
|
|
16816
|
+
var Xb = null, Zb = 0;
|
|
16817
|
+
function Qb() {
|
|
16818
|
+
if (Xb) return Zb += 1, Xb;
|
|
16819
|
+
let e = Yb();
|
|
16820
|
+
return e ? (Xb = e, Zb = 1, Xb) : null;
|
|
16621
16821
|
}
|
|
16622
|
-
function
|
|
16623
|
-
if (!
|
|
16624
|
-
let e =
|
|
16625
|
-
|
|
16822
|
+
function $b() {
|
|
16823
|
+
if (!Xb || (Zb = Math.max(0, Zb - 1), Zb > 0)) return;
|
|
16824
|
+
let e = Xb;
|
|
16825
|
+
Xb = null;
|
|
16626
16826
|
try {
|
|
16627
16827
|
e.destroy();
|
|
16628
16828
|
} catch {}
|
|
16629
16829
|
}
|
|
16630
|
-
function
|
|
16631
|
-
if (!
|
|
16632
|
-
let n =
|
|
16830
|
+
function ex(e, t) {
|
|
16831
|
+
if (!Jb() || !e || !t || !Number.isFinite(t)) return { close() {} };
|
|
16832
|
+
let n = Qb();
|
|
16633
16833
|
if (!n) return { close() {} };
|
|
16634
16834
|
let r = null;
|
|
16635
16835
|
try {
|
|
16636
16836
|
r = n.publish({
|
|
16637
16837
|
name: `codemem-${e.slice(0, 12)}`,
|
|
16638
|
-
type:
|
|
16838
|
+
type: qb,
|
|
16639
16839
|
port: t,
|
|
16640
16840
|
txt: { device_id: e }
|
|
16641
16841
|
});
|
|
16642
16842
|
} catch {
|
|
16643
|
-
return
|
|
16843
|
+
return $b(), { close() {} };
|
|
16644
16844
|
}
|
|
16645
16845
|
let i = !1;
|
|
16646
16846
|
return { close() {
|
|
16647
16847
|
if (i) return;
|
|
16648
16848
|
i = !0;
|
|
16649
|
-
let e = () =>
|
|
16849
|
+
let e = () => $b();
|
|
16650
16850
|
try {
|
|
16651
16851
|
r?.stop(() => e());
|
|
16652
16852
|
} catch {
|
|
@@ -16654,13 +16854,13 @@ function Gb(e, t) {
|
|
|
16654
16854
|
}
|
|
16655
16855
|
} };
|
|
16656
16856
|
}
|
|
16657
|
-
async function
|
|
16658
|
-
if (!
|
|
16659
|
-
let t =
|
|
16857
|
+
async function tx(e = 1500) {
|
|
16858
|
+
if (!Jb()) return [];
|
|
16859
|
+
let t = Qb();
|
|
16660
16860
|
if (!t) return [];
|
|
16661
16861
|
let n = [], r = /* @__PURE__ */ new Set(), i = !0, a = null;
|
|
16662
16862
|
try {
|
|
16663
|
-
a = t.find({ type:
|
|
16863
|
+
a = t.find({ type: qb }, (e) => {
|
|
16664
16864
|
if (!i) return;
|
|
16665
16865
|
let t = `${e.name}|${e.host ?? e.fqdn ?? ""}|${e.port}`;
|
|
16666
16866
|
if (r.has(t)) return;
|
|
@@ -16680,11 +16880,11 @@ async function Kb(e = 1500) {
|
|
|
16680
16880
|
try {
|
|
16681
16881
|
a?.stop();
|
|
16682
16882
|
} catch {}
|
|
16683
|
-
|
|
16883
|
+
$b();
|
|
16684
16884
|
}
|
|
16685
16885
|
return n;
|
|
16686
16886
|
}
|
|
16687
|
-
function
|
|
16887
|
+
function nx(e, t) {
|
|
16688
16888
|
let n = [];
|
|
16689
16889
|
for (let r of t) {
|
|
16690
16890
|
let t = r.properties ?? {}, i = t.device_id ?? t.device_id;
|
|
@@ -16698,56 +16898,56 @@ function qb(e, t) {
|
|
|
16698
16898
|
}
|
|
16699
16899
|
//#endregion
|
|
16700
16900
|
//#region src/sync-pass.ts
|
|
16701
|
-
var
|
|
16702
|
-
function
|
|
16901
|
+
var rx = 1048576, ix = !1, ax = 500, ox = 2e3, sx = "2";
|
|
16902
|
+
function cx(e, t) {
|
|
16703
16903
|
return !t || !t.includes("|") ? !1 : e ? t > e : !0;
|
|
16704
16904
|
}
|
|
16705
|
-
function
|
|
16905
|
+
function lx(e) {
|
|
16706
16906
|
if (!e) return null;
|
|
16707
16907
|
let t = e.error, n = e.reason;
|
|
16708
16908
|
return typeof t == "string" && typeof n == "string" ? `${t}:${n}` : typeof t == "string" ? t : null;
|
|
16709
16909
|
}
|
|
16710
|
-
function
|
|
16910
|
+
function ux(e) {
|
|
16711
16911
|
return e.length === 0 ? null : `all addresses failed | ${e.map((e) => `${e.address}: ${e.error}`).join(" || ")}`;
|
|
16712
16912
|
}
|
|
16713
|
-
function
|
|
16913
|
+
function dx(e) {
|
|
16714
16914
|
if (typeof e != "string") return null;
|
|
16715
16915
|
let t = e.trim();
|
|
16716
16916
|
return t.length > 0 ? t : null;
|
|
16717
16917
|
}
|
|
16718
|
-
function
|
|
16918
|
+
function fx(e) {
|
|
16719
16919
|
let t = e?.sync_reset;
|
|
16720
16920
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
16721
16921
|
let n = t;
|
|
16722
16922
|
if (!Number.isFinite(n.generation) || typeof n.snapshot_id != "string" || n.snapshot_id.trim().length === 0) return null;
|
|
16723
|
-
let r =
|
|
16923
|
+
let r = dx(n.baseline_cursor);
|
|
16724
16924
|
return {
|
|
16725
|
-
scope_id:
|
|
16925
|
+
scope_id: dx(n.scope_id),
|
|
16726
16926
|
generation: Number(n.generation),
|
|
16727
16927
|
snapshot_id: n.snapshot_id.trim(),
|
|
16728
16928
|
baseline_cursor: r,
|
|
16729
|
-
retained_floor_cursor:
|
|
16929
|
+
retained_floor_cursor: dx(n.retained_floor_cursor)
|
|
16730
16930
|
};
|
|
16731
16931
|
}
|
|
16732
|
-
function
|
|
16932
|
+
function px(e) {
|
|
16733
16933
|
return !(!e || e.reset_required !== !1 || !Number.isFinite(e.generation) || typeof e.snapshot_id != "string" || e.snapshot_id.trim().length === 0 || !(e.baseline_cursor == null || typeof e.baseline_cursor == "string") || !(e.retained_floor_cursor == null || typeof e.retained_floor_cursor == "string") || !Array.isArray(e.ops) || !(e.next_cursor == null || typeof e.next_cursor == "string") || !Number.isFinite(e.skipped));
|
|
16734
16934
|
}
|
|
16735
|
-
function
|
|
16736
|
-
let t =
|
|
16935
|
+
function mx(e) {
|
|
16936
|
+
let t = ab(e);
|
|
16737
16937
|
return {
|
|
16738
|
-
local:
|
|
16938
|
+
local: rb,
|
|
16739
16939
|
peer: t,
|
|
16740
|
-
negotiated:
|
|
16940
|
+
negotiated: ob(rb, t)
|
|
16741
16941
|
};
|
|
16742
16942
|
}
|
|
16743
|
-
function
|
|
16744
|
-
return { [
|
|
16943
|
+
function hx() {
|
|
16944
|
+
return { [nb]: rb };
|
|
16745
16945
|
}
|
|
16746
|
-
function
|
|
16747
|
-
return
|
|
16946
|
+
function gx() {
|
|
16947
|
+
return mx("unsupported");
|
|
16748
16948
|
}
|
|
16749
|
-
function
|
|
16750
|
-
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString(), a = n.capabilities ??
|
|
16949
|
+
function _x(e, t, n) {
|
|
16950
|
+
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString(), a = n.capabilities ?? gx();
|
|
16751
16951
|
r.insert(ft).values({
|
|
16752
16952
|
peer_device_id: t,
|
|
16753
16953
|
started_at: i,
|
|
@@ -16761,7 +16961,7 @@ function cx(e, t, n) {
|
|
|
16761
16961
|
negotiated_sync_capability: a.negotiated
|
|
16762
16962
|
}).run();
|
|
16763
16963
|
}
|
|
16764
|
-
function
|
|
16964
|
+
function vx(e, t, n, r) {
|
|
16765
16965
|
let i = N(e, { schema: H }), { replicationOps: a } = H, o;
|
|
16766
16966
|
if (t) {
|
|
16767
16967
|
let e = t.indexOf("|"), s = e >= 0 ? t.slice(0, e) : t, c = e >= 0 ? t.slice(e + 1) : "";
|
|
@@ -16773,12 +16973,12 @@ function lx(e, t, n, r) {
|
|
|
16773
16973
|
let c = `${s.created_at}|${s.op_id}`;
|
|
16774
16974
|
return [o, c];
|
|
16775
16975
|
}
|
|
16776
|
-
var
|
|
16777
|
-
async function
|
|
16976
|
+
var yx = 8;
|
|
16977
|
+
async function bx(e, t, n, r, i = 0) {
|
|
16778
16978
|
if (n.length === 0) return;
|
|
16779
16979
|
let a = {
|
|
16780
16980
|
ops: n,
|
|
16781
|
-
sync_capability:
|
|
16981
|
+
sync_capability: rb
|
|
16782
16982
|
}, o = Buffer.from(JSON.stringify(a), "utf-8"), [s, c] = await xl("POST", e, {
|
|
16783
16983
|
headers: {
|
|
16784
16984
|
..._r({
|
|
@@ -16788,28 +16988,28 @@ async function dx(e, t, n, r, i = 0) {
|
|
|
16788
16988
|
bodyBytes: o,
|
|
16789
16989
|
keysDir: r
|
|
16790
16990
|
}),
|
|
16791
|
-
...
|
|
16991
|
+
...hx()
|
|
16792
16992
|
},
|
|
16793
16993
|
body: a,
|
|
16794
16994
|
bodyBytes: o
|
|
16795
16995
|
});
|
|
16796
16996
|
if (s === 200 && c != null) return;
|
|
16797
|
-
let l =
|
|
16798
|
-
if (s === 413 && n.length > 1 && i <
|
|
16997
|
+
let l = lx(c);
|
|
16998
|
+
if (s === 413 && n.length > 1 && i < yx && (l === "payload_too_large" || l === "too_many_ops")) {
|
|
16799
16999
|
let a = Math.floor(n.length / 2);
|
|
16800
|
-
await
|
|
17000
|
+
await bx(e, t, n.slice(0, a), r, i + 1), await bx(e, t, n.slice(a), r, i + 1);
|
|
16801
17001
|
return;
|
|
16802
17002
|
}
|
|
16803
17003
|
let u = l ? ` (${s}: ${l})` : ` (${s})`;
|
|
16804
17004
|
throw Error(`peer ops push failed${u}`);
|
|
16805
17005
|
}
|
|
16806
|
-
function
|
|
17006
|
+
function xx(e) {
|
|
16807
17007
|
Hn(e), qd(e, 2e3), Jd(e, 200);
|
|
16808
17008
|
}
|
|
16809
|
-
async function
|
|
17009
|
+
async function Sx(e, t, n, r) {
|
|
16810
17010
|
Hn(e);
|
|
16811
|
-
let i = r?.limit ??
|
|
16812
|
-
!o && !
|
|
17011
|
+
let i = r?.limit ?? ax, a = r?.keysDir, o = r?.scanner;
|
|
17012
|
+
!o && !ix && (ix = !0, process.stderr.write("[codemem] sync apply running without explicit scanner — workspace-level secret rules will not apply to inbound peer content\n"));
|
|
16813
17013
|
let s = N(e, { schema: H }).select({ pinned_fingerprint: Y.pinned_fingerprint }).from(Y).where(k(Y.peer_device_id, t)).get()?.pinned_fingerprint ?? "";
|
|
16814
17014
|
if (!s) return {
|
|
16815
17015
|
ok: !1,
|
|
@@ -16823,7 +17023,7 @@ async function px(e, t, n, r) {
|
|
|
16823
17023
|
[u] = dr(e, { keysDir: a });
|
|
16824
17024
|
} catch (n) {
|
|
16825
17025
|
let r = `device identity unavailable: ${n instanceof Error ? n.message.trim() || n.constructor.name : "unknown"}`;
|
|
16826
|
-
return
|
|
17026
|
+
return _x(e, t, {
|
|
16827
17027
|
ok: !1,
|
|
16828
17028
|
error: r
|
|
16829
17029
|
}), {
|
|
@@ -16848,15 +17048,15 @@ async function px(e, t, n, r) {
|
|
|
16848
17048
|
bodyBytes: Buffer.alloc(0),
|
|
16849
17049
|
keysDir: a
|
|
16850
17050
|
}),
|
|
16851
|
-
...
|
|
17051
|
+
...hx()
|
|
16852
17052
|
} });
|
|
16853
17053
|
if (d !== 200 || !f) {
|
|
16854
|
-
let e =
|
|
17054
|
+
let e = lx(f), t = e ? ` (${d}: ${e})` : ` (${d})`;
|
|
16855
17055
|
throw Error(`peer status failed${t}`);
|
|
16856
17056
|
}
|
|
16857
17057
|
if (f.fingerprint !== s) throw Error("peer fingerprint mismatch");
|
|
16858
|
-
if (p =
|
|
16859
|
-
let m =
|
|
17058
|
+
if (p = mx(f.sync_capability), String(f.protocol_version ?? "") !== sx) throw Error(`peer protocol mismatch (expected ${sx}, got ${String(f.protocol_version ?? "missing")})`);
|
|
17059
|
+
let m = fx(f);
|
|
16860
17060
|
if (!m) throw Error("peer status missing sync_reset boundary");
|
|
16861
17061
|
if (c === null && l === null && Number(e.prepare("SELECT count(*) as n FROM memory_items WHERE import_key IS NOT NULL").get()?.n ?? 0) === 0) try {
|
|
16862
17062
|
let r = {
|
|
@@ -16867,11 +17067,11 @@ async function px(e, t, n, r) {
|
|
|
16867
17067
|
retained_floor_cursor: m.retained_floor_cursor ?? null,
|
|
16868
17068
|
reset_required: !0,
|
|
16869
17069
|
reason: "initial_bootstrap"
|
|
16870
|
-
}, { items: i } = await
|
|
17070
|
+
}, { items: i } = await Ab(n, r, u, {
|
|
16871
17071
|
keysDir: a,
|
|
16872
|
-
pageSize:
|
|
17072
|
+
pageSize: ox
|
|
16873
17073
|
}), s = Number(e.prepare("SELECT count(*) as n FROM memory_items WHERE import_key IS NOT NULL").get()?.n ?? 0);
|
|
16874
|
-
if (s > 0) return
|
|
17074
|
+
if (s > 0) return _x(e, t, {
|
|
16875
17075
|
ok: !1,
|
|
16876
17076
|
error: "needs_attention:shared_memories_appeared_during_bootstrap",
|
|
16877
17077
|
capabilities: p
|
|
@@ -16883,9 +17083,9 @@ async function px(e, t, n, r) {
|
|
|
16883
17083
|
opsOut: 0,
|
|
16884
17084
|
addressErrors: []
|
|
16885
17085
|
};
|
|
16886
|
-
let c =
|
|
17086
|
+
let c = Lb(e, t, i, r, o);
|
|
16887
17087
|
if (!c.ok) throw Error("initial bootstrap apply failed");
|
|
16888
|
-
return
|
|
17088
|
+
return Wb(e, t, n), _x(e, t, {
|
|
16889
17089
|
ok: !0,
|
|
16890
17090
|
opsIn: c.applied,
|
|
16891
17091
|
opsOut: 0,
|
|
@@ -16916,7 +17116,7 @@ async function px(e, t, n, r) {
|
|
|
16916
17116
|
bodyBytes: Buffer.alloc(0),
|
|
16917
17117
|
keysDir: a
|
|
16918
17118
|
}),
|
|
16919
|
-
...
|
|
17119
|
+
...hx()
|
|
16920
17120
|
} });
|
|
16921
17121
|
if (_ === 409 && v?.reset_required === !0) {
|
|
16922
17122
|
let r = ad(e), i = {
|
|
@@ -16928,7 +17128,7 @@ async function px(e, t, n, r) {
|
|
|
16928
17128
|
baseline_cursor: typeof v.baseline_cursor == "string" && v.baseline_cursor.trim() ? v.baseline_cursor.trim() : null,
|
|
16929
17129
|
retained_floor_cursor: typeof v.retained_floor_cursor == "string" && v.retained_floor_cursor.trim() ? v.retained_floor_cursor.trim() : null
|
|
16930
17130
|
};
|
|
16931
|
-
if (r.dirty) return
|
|
17131
|
+
if (r.dirty) return _x(e, t, {
|
|
16932
17132
|
ok: !1,
|
|
16933
17133
|
error: `needs_attention:local_unsynced_shared_memory:${r.count}`,
|
|
16934
17134
|
capabilities: p
|
|
@@ -16942,8 +17142,8 @@ async function px(e, t, n, r) {
|
|
|
16942
17142
|
resetRequired: i
|
|
16943
17143
|
};
|
|
16944
17144
|
try {
|
|
16945
|
-
let { items: r } = await
|
|
16946
|
-
if (s.dirty) return
|
|
17145
|
+
let { items: r } = await Ab(n, i, u, { keysDir: a }), s = ad(e);
|
|
17146
|
+
if (s.dirty) return _x(e, t, {
|
|
16947
17147
|
ok: !1,
|
|
16948
17148
|
error: `needs_attention:local_unsynced_shared_memory:${s.count}`,
|
|
16949
17149
|
capabilities: p
|
|
@@ -16956,9 +17156,9 @@ async function px(e, t, n, r) {
|
|
|
16956
17156
|
addressErrors: [],
|
|
16957
17157
|
resetRequired: i
|
|
16958
17158
|
};
|
|
16959
|
-
let c =
|
|
17159
|
+
let c = Lb(e, t, r, i, o);
|
|
16960
17160
|
if (!c.ok) throw Error("bootstrap apply failed");
|
|
16961
|
-
return
|
|
17161
|
+
return Wb(e, t, n), _x(e, t, {
|
|
16962
17162
|
ok: !0,
|
|
16963
17163
|
opsIn: c.applied,
|
|
16964
17164
|
opsOut: 0,
|
|
@@ -16972,7 +17172,7 @@ async function px(e, t, n, r) {
|
|
|
16972
17172
|
};
|
|
16973
17173
|
} catch (r) {
|
|
16974
17174
|
let a = r instanceof Error ? r.message : String(r);
|
|
16975
|
-
return
|
|
17175
|
+
return _x(e, t, {
|
|
16976
17176
|
ok: !1,
|
|
16977
17177
|
error: `bootstrap_failed:${a}`,
|
|
16978
17178
|
capabilities: p
|
|
@@ -16988,10 +17188,10 @@ async function px(e, t, n, r) {
|
|
|
16988
17188
|
}
|
|
16989
17189
|
}
|
|
16990
17190
|
if (_ !== 200 || v == null) {
|
|
16991
|
-
let e =
|
|
17191
|
+
let e = lx(v), t = e ? ` (${_}: ${e})` : ` (${_})`;
|
|
16992
17192
|
throw Error(`peer ops fetch failed${t}`);
|
|
16993
17193
|
}
|
|
16994
|
-
if (!
|
|
17194
|
+
if (!px(v)) throw Error("invalid ops response");
|
|
16995
17195
|
let y = Xu(v), b = y.find((e) => e.device_id !== t || e.clock_device_id !== t);
|
|
16996
17196
|
if (b) throw Error(`inbound op device mismatch:${b.op_id}`);
|
|
16997
17197
|
let x = p?.negotiated === "unsupported" ? {
|
|
@@ -17003,7 +17203,7 @@ async function px(e, t, n, r) {
|
|
|
17003
17203
|
throw Error(`inbound scope rejected:${e}`);
|
|
17004
17204
|
}
|
|
17005
17205
|
try {
|
|
17006
|
-
|
|
17206
|
+
vb(e, S.vectorWork);
|
|
17007
17207
|
} catch (t) {
|
|
17008
17208
|
let n = await Ds(e, S.vectorWork);
|
|
17009
17209
|
if (n.errors.length > 0) {
|
|
@@ -17011,15 +17211,15 @@ async function px(e, t, n, r) {
|
|
|
17011
17211
|
throw Error(`vector catch-up queue failed: ${t instanceof Error ? t.message : String(t)}; fallback failed: ${e}`);
|
|
17012
17212
|
}
|
|
17013
17213
|
}
|
|
17014
|
-
let C =
|
|
17015
|
-
|
|
17016
|
-
let [w, ee] =
|
|
17214
|
+
let C = dx(v.next_cursor);
|
|
17215
|
+
cx(c, C) && (Ju(e, t, { lastApplied: C }), c = C);
|
|
17216
|
+
let [w, ee] = vx(e, l, u, i), [T, te, ne] = Ad(e, w, t, { localDeviceId: u }), re = ne?.skipped_count ?? 0, ie = `${n}/v1/ops`;
|
|
17017
17217
|
if (T.length > 0) {
|
|
17018
|
-
let e = Uu(T,
|
|
17019
|
-
for (let t of e) await
|
|
17218
|
+
let e = Uu(T, rx);
|
|
17219
|
+
for (let t of e) await bx(ie, u, t, a);
|
|
17020
17220
|
}
|
|
17021
17221
|
let ae = te ?? ee;
|
|
17022
|
-
return ae &&
|
|
17222
|
+
return ae && cx(l, ae) && (Ju(e, t, { lastAcked: ae }), l = ae), Wb(e, t, n), _x(e, t, {
|
|
17023
17223
|
ok: !0,
|
|
17024
17224
|
opsIn: S.applied,
|
|
17025
17225
|
opsOut: T.length,
|
|
@@ -17042,8 +17242,8 @@ async function px(e, t, n, r) {
|
|
|
17042
17242
|
}
|
|
17043
17243
|
}
|
|
17044
17244
|
}
|
|
17045
|
-
let m =
|
|
17046
|
-
return f || (m = "no dialable peer addresses"), m ||= "sync failed without diagnostic detail",
|
|
17245
|
+
let m = ux(d);
|
|
17246
|
+
return f || (m = "no dialable peer addresses"), m ||= "sync failed without diagnostic detail", _x(e, t, {
|
|
17047
17247
|
ok: !1,
|
|
17048
17248
|
error: m,
|
|
17049
17249
|
capabilities: p
|
|
@@ -17055,15 +17255,15 @@ async function px(e, t, n, r) {
|
|
|
17055
17255
|
addressErrors: d
|
|
17056
17256
|
};
|
|
17057
17257
|
}
|
|
17058
|
-
async function
|
|
17258
|
+
async function Cx(e, t, n) {
|
|
17059
17259
|
let r = N(e, { schema: H }).select({ addresses_json: Y.addresses_json }).from(Y).where(k(Y.peer_device_id, t)).get(), i = [];
|
|
17060
17260
|
if (r?.addresses_json) try {
|
|
17061
17261
|
let e = JSON.parse(r.addresses_json);
|
|
17062
17262
|
Array.isArray(e) && (i = e.filter((e) => typeof e == "string"));
|
|
17063
17263
|
} catch {}
|
|
17064
|
-
return
|
|
17264
|
+
return Sx(e, t, i, n);
|
|
17065
17265
|
}
|
|
17066
|
-
var
|
|
17266
|
+
var wx = [
|
|
17067
17267
|
"no route to host",
|
|
17068
17268
|
"connection refused",
|
|
17069
17269
|
"network is unreachable",
|
|
@@ -17074,33 +17274,33 @@ var hx = [
|
|
|
17074
17274
|
"errno 61",
|
|
17075
17275
|
"errno 60",
|
|
17076
17276
|
"errno 111"
|
|
17077
|
-
],
|
|
17078
|
-
function
|
|
17277
|
+
], Tx = 120, Ex = 1800;
|
|
17278
|
+
function Dx(e) {
|
|
17079
17279
|
if (!e) return !1;
|
|
17080
17280
|
let t = e.toLowerCase();
|
|
17081
|
-
return
|
|
17281
|
+
return wx.some((e) => t.includes(e));
|
|
17082
17282
|
}
|
|
17083
|
-
function
|
|
17283
|
+
function Ox(e, t, n = 10) {
|
|
17084
17284
|
let r = N(e, { schema: H }).select({
|
|
17085
17285
|
ok: ft.ok,
|
|
17086
17286
|
error: ft.error
|
|
17087
17287
|
}).from(ft).where(k(ft.peer_device_id, t)).orderBy(ue(ft.started_at)).limit(n).all(), i = 0;
|
|
17088
17288
|
for (let e of r) {
|
|
17089
17289
|
if (e.ok) break;
|
|
17090
|
-
if (
|
|
17290
|
+
if (Dx(e.error)) i++;
|
|
17091
17291
|
else break;
|
|
17092
17292
|
}
|
|
17093
17293
|
return i;
|
|
17094
17294
|
}
|
|
17095
|
-
function
|
|
17295
|
+
function kx(e) {
|
|
17096
17296
|
if (e <= 1) return 0;
|
|
17097
17297
|
let t = Math.min(e - 1, 8);
|
|
17098
|
-
return Math.min(
|
|
17298
|
+
return Math.min(Tx * 2 ** (t - 1), Ex) * (.5 + Math.random() * .5);
|
|
17099
17299
|
}
|
|
17100
|
-
function
|
|
17101
|
-
let n =
|
|
17300
|
+
function Ax(e, t) {
|
|
17301
|
+
let n = Ox(e, t);
|
|
17102
17302
|
if (n < 2) return !1;
|
|
17103
|
-
let r =
|
|
17303
|
+
let r = kx(n);
|
|
17104
17304
|
if (r <= 0) return !1;
|
|
17105
17305
|
let i = N(e, { schema: H }).select({ started_at: ft.started_at }).from(ft).where(k(ft.peer_device_id, t)).orderBy(ue(ft.started_at)).limit(1).get();
|
|
17106
17306
|
if (!i?.started_at) return !1;
|
|
@@ -17113,7 +17313,7 @@ function xx(e, t) {
|
|
|
17113
17313
|
}
|
|
17114
17314
|
//#endregion
|
|
17115
17315
|
//#region src/sync-daemon.ts
|
|
17116
|
-
function
|
|
17316
|
+
function jx(e) {
|
|
17117
17317
|
let t = N(e, { schema: H }), n = (/* @__PURE__ */ new Date()).toISOString();
|
|
17118
17318
|
t.insert(mt).values({
|
|
17119
17319
|
id: 1,
|
|
@@ -17127,7 +17327,7 @@ function Sx(e) {
|
|
|
17127
17327
|
}
|
|
17128
17328
|
}).run();
|
|
17129
17329
|
}
|
|
17130
|
-
function
|
|
17330
|
+
function Mx(e, t, n) {
|
|
17131
17331
|
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
17132
17332
|
r.insert(mt).values({
|
|
17133
17333
|
id: 1,
|
|
@@ -17143,11 +17343,11 @@ function Cx(e, t, n) {
|
|
|
17143
17343
|
}
|
|
17144
17344
|
}).run();
|
|
17145
17345
|
}
|
|
17146
|
-
function
|
|
17346
|
+
function Nx(e) {
|
|
17147
17347
|
let t = N(e, { schema: H }).select({ phase: mt.phase }).from(mt).where(k(mt.id, 1)).get()?.phase;
|
|
17148
17348
|
return t === "needs_attention" ? t : null;
|
|
17149
17349
|
}
|
|
17150
|
-
function
|
|
17350
|
+
function Px(e, t) {
|
|
17151
17351
|
N(e, { schema: H }).insert(mt).values({
|
|
17152
17352
|
id: 1,
|
|
17153
17353
|
phase: t
|
|
@@ -17156,18 +17356,18 @@ function Tx(e, t) {
|
|
|
17156
17356
|
set: { phase: t }
|
|
17157
17357
|
}).run();
|
|
17158
17358
|
}
|
|
17159
|
-
async function
|
|
17359
|
+
async function Fx(e, t, n) {
|
|
17160
17360
|
let r = Al();
|
|
17161
17361
|
return jl(r) ? (await Nl({
|
|
17162
17362
|
db: e,
|
|
17163
17363
|
dbPath: t
|
|
17164
17364
|
}, r, { keysDir: n }), await hu(e, r), !0) : !1;
|
|
17165
17365
|
}
|
|
17166
|
-
async function
|
|
17366
|
+
async function Ix(e, t, n, r) {
|
|
17167
17367
|
let i = N(e, { schema: H }).select({ peer_device_id: Y.peer_device_id }).from(Y).all();
|
|
17168
17368
|
if (i.length === 0) return [];
|
|
17169
17369
|
let a = Al().syncOpsLimit;
|
|
17170
|
-
|
|
17370
|
+
xx(e);
|
|
17171
17371
|
let o = [];
|
|
17172
17372
|
for (let s of i) {
|
|
17173
17373
|
let i = s.peer_device_id;
|
|
@@ -17179,7 +17379,7 @@ async function Dx(e, t, n, r) {
|
|
|
17179
17379
|
});
|
|
17180
17380
|
continue;
|
|
17181
17381
|
}
|
|
17182
|
-
if (
|
|
17382
|
+
if (Ax(e, i)) {
|
|
17183
17383
|
o.push({
|
|
17184
17384
|
ok: !1,
|
|
17185
17385
|
skipped: !0,
|
|
@@ -17187,7 +17387,7 @@ async function Dx(e, t, n, r) {
|
|
|
17187
17387
|
});
|
|
17188
17388
|
continue;
|
|
17189
17389
|
}
|
|
17190
|
-
let c = await
|
|
17390
|
+
let c = await Cx(e, i, {
|
|
17191
17391
|
keysDir: t,
|
|
17192
17392
|
limit: a,
|
|
17193
17393
|
scanner: r
|
|
@@ -17201,13 +17401,13 @@ async function Dx(e, t, n, r) {
|
|
|
17201
17401
|
}
|
|
17202
17402
|
return o;
|
|
17203
17403
|
}
|
|
17204
|
-
async function
|
|
17404
|
+
async function Lx(e) {
|
|
17205
17405
|
let t = e?.intervalS ?? 120, n = Dn(e?.dbPath), r = e?.keysDir, i = e?.signal, a = e?.onPhaseChange, o = e?.scanner;
|
|
17206
17406
|
a?.("starting");
|
|
17207
17407
|
let s = Mn(n), c = null;
|
|
17208
17408
|
try {
|
|
17209
17409
|
let [t] = dr(s, { keysDir: r });
|
|
17210
|
-
|
|
17410
|
+
Jb() && e?.port && (c = ex(t, e.port));
|
|
17211
17411
|
} finally {
|
|
17212
17412
|
s.close();
|
|
17213
17413
|
}
|
|
@@ -17217,7 +17417,7 @@ async function Ox(e) {
|
|
|
17217
17417
|
}
|
|
17218
17418
|
return new Promise((e) => {
|
|
17219
17419
|
let s = !1, l = !1, u = () => {
|
|
17220
|
-
s || (s = !0,
|
|
17420
|
+
s || (s = !0, Rx(n, r, o).finally(() => {
|
|
17221
17421
|
s = !1, l || (l = !0, a?.("running"));
|
|
17222
17422
|
}));
|
|
17223
17423
|
}, d = setInterval(u, t * 1e3);
|
|
@@ -17234,38 +17434,38 @@ async function Ox(e) {
|
|
|
17234
17434
|
}
|
|
17235
17435
|
});
|
|
17236
17436
|
}
|
|
17237
|
-
async function
|
|
17437
|
+
async function Rx(e, t, n) {
|
|
17238
17438
|
let r = Mn(e);
|
|
17239
17439
|
try {
|
|
17240
17440
|
Hn(r);
|
|
17241
17441
|
try {
|
|
17242
|
-
await
|
|
17442
|
+
await Fx(r, e, t);
|
|
17243
17443
|
} catch {}
|
|
17244
|
-
(await
|
|
17444
|
+
(await Ix(r, t, await Rl(r, e, t), n)).some((e) => !e.ok && e.error?.includes("needs_attention")) ? Px(r, "needs_attention") : jx(r);
|
|
17245
17445
|
} catch (e) {
|
|
17246
|
-
|
|
17446
|
+
Mx(r, e instanceof Error ? e.message : String(e), e instanceof Error ? e.stack ?? "" : "");
|
|
17247
17447
|
} finally {
|
|
17248
17448
|
r.close();
|
|
17249
17449
|
}
|
|
17250
17450
|
}
|
|
17251
17451
|
//#endregion
|
|
17252
17452
|
//#region src/sync-retention-runner.ts
|
|
17253
|
-
function
|
|
17453
|
+
function zx(e) {
|
|
17254
17454
|
let t = String(e ?? "").trim();
|
|
17255
17455
|
return t.length > 0 ? t : Su;
|
|
17256
17456
|
}
|
|
17257
|
-
function
|
|
17457
|
+
function Bx(e) {
|
|
17258
17458
|
e.exec("\n CREATE TABLE IF NOT EXISTS sync_retention_state (\n id INTEGER PRIMARY KEY,\n last_run_at TEXT,\n last_duration_ms INTEGER,\n last_deleted_ops INTEGER NOT NULL DEFAULT 0,\n last_estimated_bytes_before INTEGER,\n last_estimated_bytes_after INTEGER,\n retained_floor_cursor TEXT,\n last_error TEXT,\n last_error_at TEXT\n );\n CREATE TABLE IF NOT EXISTS sync_retention_state_v2 (\n scope_id TEXT PRIMARY KEY NOT NULL,\n last_run_at TEXT,\n last_duration_ms INTEGER,\n last_deleted_ops INTEGER NOT NULL DEFAULT 0,\n last_estimated_bytes_before INTEGER,\n last_estimated_bytes_after INTEGER,\n retained_floor_cursor TEXT,\n last_error TEXT,\n last_error_at TEXT\n )\n ");
|
|
17259
17459
|
}
|
|
17260
|
-
function
|
|
17460
|
+
function Vx(e) {
|
|
17261
17461
|
let t = e.prepare("SELECT scope_id FROM (\n SELECT COALESCE(NULLIF(TRIM(scope_id), ''), ?) AS scope_id FROM replication_ops\n UNION\n SELECT COALESCE(NULLIF(TRIM(scope_id), ''), ?) AS scope_id FROM sync_reset_state_v2\n UNION\n SELECT COALESCE(NULLIF(TRIM(scope_id), ''), ?) AS scope_id FROM sync_retention_state_v2\n )\n ORDER BY CASE WHEN scope_id = ? THEN 0 ELSE 1 END, scope_id").all(Su, Su, Su, Su), n = new Set([Su]);
|
|
17262
17462
|
for (let e of t) {
|
|
17263
|
-
let t =
|
|
17463
|
+
let t = zx(e.scope_id);
|
|
17264
17464
|
n.add(t);
|
|
17265
17465
|
}
|
|
17266
17466
|
return Array.from(n);
|
|
17267
17467
|
}
|
|
17268
|
-
function
|
|
17468
|
+
function Hx(e, t, n, r) {
|
|
17269
17469
|
e.insert(vt).values({
|
|
17270
17470
|
scope_id: t,
|
|
17271
17471
|
...n
|
|
@@ -17280,7 +17480,7 @@ function Nx(e, t, n, r) {
|
|
|
17280
17480
|
set: n
|
|
17281
17481
|
}).run();
|
|
17282
17482
|
}
|
|
17283
|
-
function
|
|
17483
|
+
function Ux(e, t, n, r, i) {
|
|
17284
17484
|
let a = i === Su;
|
|
17285
17485
|
try {
|
|
17286
17486
|
let o = dd(e, i), s = sd(e, {
|
|
@@ -17292,7 +17492,7 @@ function Px(e, t, n, r, i) {
|
|
|
17292
17492
|
maxPasses: n.maxCatchUpPasses,
|
|
17293
17493
|
signal: n.signal
|
|
17294
17494
|
});
|
|
17295
|
-
|
|
17495
|
+
Hx(t, i, {
|
|
17296
17496
|
last_run_at: r,
|
|
17297
17497
|
last_duration_ms: Date.now() - Date.parse(r),
|
|
17298
17498
|
last_deleted_ops: s.totalDeleted,
|
|
@@ -17303,7 +17503,7 @@ function Px(e, t, n, r, i) {
|
|
|
17303
17503
|
last_error_at: null
|
|
17304
17504
|
}, a);
|
|
17305
17505
|
} catch (e) {
|
|
17306
|
-
|
|
17506
|
+
Hx(t, i, {
|
|
17307
17507
|
last_run_at: r,
|
|
17308
17508
|
last_duration_ms: Date.now() - Date.parse(r),
|
|
17309
17509
|
last_deleted_ops: 0,
|
|
@@ -17315,13 +17515,13 @@ function Px(e, t, n, r, i) {
|
|
|
17315
17515
|
}, a);
|
|
17316
17516
|
}
|
|
17317
17517
|
}
|
|
17318
|
-
async function
|
|
17518
|
+
async function Wx(e, t) {
|
|
17319
17519
|
if (!t.syncRetentionEnabled) return;
|
|
17320
|
-
|
|
17321
|
-
let n = N(e, { schema: H }), r = (/* @__PURE__ */ new Date()).toISOString(), i = t.scopeId === void 0 ?
|
|
17322
|
-
for (let a of i)
|
|
17520
|
+
Bx(e);
|
|
17521
|
+
let n = N(e, { schema: H }), r = (/* @__PURE__ */ new Date()).toISOString(), i = t.scopeId === void 0 ? Vx(e) : [zx(t.scopeId)];
|
|
17522
|
+
for (let a of i) Ux(e, n, t, r, a);
|
|
17323
17523
|
}
|
|
17324
|
-
var
|
|
17524
|
+
var Gx = class {
|
|
17325
17525
|
dbPath;
|
|
17326
17526
|
signal;
|
|
17327
17527
|
active = !1;
|
|
@@ -17349,7 +17549,7 @@ var Ix = class {
|
|
|
17349
17549
|
if (!this.active || this.signal?.aborted) return;
|
|
17350
17550
|
let e = Al(Rt()), t = Mn(this.dbPath);
|
|
17351
17551
|
try {
|
|
17352
|
-
await
|
|
17552
|
+
await Wx(t, {
|
|
17353
17553
|
...e,
|
|
17354
17554
|
signal: this.signal
|
|
17355
17555
|
});
|
|
@@ -17357,8 +17557,8 @@ var Ix = class {
|
|
|
17357
17557
|
t.close();
|
|
17358
17558
|
}
|
|
17359
17559
|
}
|
|
17360
|
-
},
|
|
17361
|
-
function
|
|
17560
|
+
}, Kx = "scope_id";
|
|
17561
|
+
function qx(e, t) {
|
|
17362
17562
|
return t ? typeof e == "string" && e.trim() ? {
|
|
17363
17563
|
ok: !1,
|
|
17364
17564
|
reason: "unsupported_scope"
|
|
@@ -17371,31 +17571,31 @@ function Rx(e, t) {
|
|
|
17371
17571
|
scope_id: null
|
|
17372
17572
|
};
|
|
17373
17573
|
}
|
|
17374
|
-
function
|
|
17574
|
+
function Jx(e, t) {
|
|
17375
17575
|
return {
|
|
17376
17576
|
...e,
|
|
17377
17577
|
scope_id: t
|
|
17378
17578
|
};
|
|
17379
17579
|
}
|
|
17380
|
-
function
|
|
17580
|
+
function Yx(e, t, n) {
|
|
17381
17581
|
return {
|
|
17382
17582
|
error: "reset_required",
|
|
17383
17583
|
reset_required: !0,
|
|
17384
17584
|
sync_capability: n,
|
|
17385
17585
|
reason: t,
|
|
17386
|
-
...
|
|
17586
|
+
...Jx(e, null)
|
|
17387
17587
|
};
|
|
17388
17588
|
}
|
|
17389
17589
|
//#endregion
|
|
17390
17590
|
//#region src/test-utils.ts
|
|
17391
|
-
function
|
|
17591
|
+
function Xx(e) {
|
|
17392
17592
|
hn(e);
|
|
17393
17593
|
}
|
|
17394
|
-
function
|
|
17594
|
+
function Zx(e) {
|
|
17395
17595
|
let t = (/* @__PURE__ */ new Date()).toISOString(), n = e.prepare("INSERT INTO sessions(started_at, cwd, project, user, tool_version) VALUES (?, ?, ?, ?, ?)").run(t, "/tmp/test", "test-project", "test-user", "test");
|
|
17396
17596
|
return Number(n.lastInsertRowid);
|
|
17397
17597
|
}
|
|
17398
|
-
function
|
|
17598
|
+
function Qx(e, t = "local") {
|
|
17399
17599
|
let n = "2026-04-01T00:00:00.000Z", r = "fixture-work-authorized", i = "fixture-oss-hidden", a = "mixedscopeleak";
|
|
17400
17600
|
e.prepare("INSERT OR IGNORE INTO sync_device(device_id, public_key, fingerprint, created_at) VALUES (?, ?, ?, ?)").run(t, "fixture-public-key", "fixture-fingerprint", n), e.prepare("INSERT OR REPLACE INTO replication_scopes(\n scope_id, label, kind, authority_type, coordinator_id, group_id,\n membership_epoch, status, created_at, updated_at\n ) VALUES (?, ?, 'team', 'coordinator', 'fixture-coordinator', 'fixture-group', 0, 'active', ?, ?)").run(r, "Authorized work fixture", n, n), e.prepare("INSERT OR REPLACE INTO replication_scopes(\n scope_id, label, kind, authority_type, coordinator_id, group_id,\n membership_epoch, status, created_at, updated_at\n ) VALUES (?, ?, 'team', 'coordinator', 'fixture-coordinator', 'fixture-group', 0, 'active', ?, ?)").run(i, "Hidden OSS fixture", n, n), e.prepare("INSERT OR REPLACE INTO scope_memberships(\n scope_id, device_id, role, status, membership_epoch,\n coordinator_id, group_id, updated_at\n ) VALUES (?, ?, 'member', 'active', 0, 'fixture-coordinator', 'fixture-group', ?)").run(r, t, n);
|
|
17401
17601
|
let o = e.prepare("INSERT INTO sessions(started_at, cwd, project, user, tool_version, metadata_json, import_key)\n VALUES (?, '/tmp/mixed-domain-fixture', 'mixed-domain-fixture', 'test-user', 'test', '{}', 'fixture-session')").run(n), s = Number(o.lastInsertRowid), c = (t) => {
|
|
@@ -17444,8 +17644,8 @@ function Ux(e, t = "local") {
|
|
|
17444
17644
|
}
|
|
17445
17645
|
//#endregion
|
|
17446
17646
|
//#region src/index.ts
|
|
17447
|
-
var
|
|
17647
|
+
var $x = "0.31.1";
|
|
17448
17648
|
//#endregion
|
|
17449
|
-
export { ke as Api, V as BetterSqliteCoordinatorStore, Ft as CODEMEM_CONFIG_ENV_OVERRIDES, xh as DEDUP_KEY_BACKFILL_JOB, R as DEFAULT_COORDINATOR_DB_PATH, En as DEFAULT_DB_PATH, Wl as DEFAULT_SCOPE_MEMBERSHIP_CACHE_MAX_AGE_MS, Ab as DEFAULT_SERVICE_TYPE, Su as DEFAULT_SYNC_SCOPE_ID, o as DEFAULT_TIME_WINDOW_S, Th as DedupKeyBackfillRunner, si as INJECTION_EVAL_SCENARIO_PACKS, yv as LEGACY_SHARED_REVIEW_SCOPE_ID, Ti as LOCAL_DEFAULT_SCOPE_ID, Jy as LOCAL_SYNC_CAPABILITY, zg as LOW_SIGNAL_TOOLS, Sr as MAPPABLE_CLAUDE_HOOK_EVENTS, Cn as MIN_COMPATIBLE_SCHEMA, Ae as MUTATING_TOOL_NAMES, bf as MemoryStore, yp as ObserverAuthAdapter, Hp as ObserverAuthError, pm as ObserverClient, _y as REF_BACKFILL_JOB, mg as RICH_TIER_DEFAULTS, gy as RawEventSweeper, Cy as RefBackfillRunner, Sn as SCHEMA_VERSION, bv as SCOPE_BACKFILL_JOB, n as SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, wy as SESSION_CONTEXT_BACKFILL_JOB, fr as SIGNATURE_VERSION, pg as SIMPLE_TIER_DEFAULTS, Ry as SUMMARY_DEDUP_BACKFILL_JOB, Ky as SYNC_CAPABILITIES, qy as SYNC_CAPABILITY_HEADER, Lx as SYNC_SCOPE_QUERY_PARAM, Iv as ScopeBackfillRunner, Ly as SessionContextBackfillRunner, Gy as SummaryDedupBackfillRunner, Ix as SyncRetentionRunner, p_ as TRIVIAL_REQUESTS, Qy as VECTOR_MODEL_MIGRATION_JOB, Wx as VERSION, bb as VectorModelMigrationRunner, Qo as _resetEmbeddingClient, zx as addSyncScopeToBoundary, vl as addressDedupeKey, Gb as advertiseMdns, Om as aiBackfillStructuredContent, ly as analyzeProjectScopeMappingChangeGuardrails, Ob as applyBootstrapSnapshot, Zd as applyReplicationOps, zn as assertSchemaReady, ep as backfillMemoryDedupKeys, Yf as backfillNarrativeFromBody, Jd as backfillReplicationOps, Mv as backfillScopeIds, zf as backfillTagsText, ks as backfillVectors, hn as bootstrapSchema, Zg as budgetToolEvents, _r as buildAuthHeaders, bl as buildBaseUrl, pr as buildCanonicalRequest, mp as buildCodexHeaders, Ji as buildFilterClauses, Yi as buildFilterClausesWithContext, Ih as buildImportKey, zr as buildIngestPayloadFromHook, qc as buildMemoryPack, Yc as buildMemoryPackAsync, Jc as buildMemoryPackTrace, Xc as buildMemoryPackTraceAsync, d_ as buildObserverPrompt, Rr as buildRawEventEnvelopeFromHook, tv as buildSessionContext, v_ as buildTranscript, cd as bulkPruneReplicationOpsByAgeCutoff, mi as canonicalMemoryKind, ji as canonicalWorkspaceIdentity, Uu as chunkOpsBySize, Xo as chunkText, Cv as classifyLegacyMemoryScope, J_ as cleanOrphanSessions, yr as cleanupNonces, ha as clearMemoryRefs, Zu as clockTuple, Af as compareMemoryRoleReports, Yr as completeMaintenanceJob, Mn as connect, Xe as connectCoordinator, yx as consecutiveConnectivityFailures, qm as coordinatorArchiveGroupAction, Gm as coordinatorCreateGroupAction, ch as coordinatorCreateInviteAction, Zm as coordinatorCreateScopeAction, ah as coordinatorDisableDeviceAction, oh as coordinatorEnableDeviceAction, jl as coordinatorEnabled, nh as coordinatorEnrollDeviceAction, eh as coordinatorGrantScopeMembershipAction, lh as coordinatorImportInviteAction, fh as coordinatorListBootstrapGrantsAction, rh as coordinatorListDevicesAction, Ym as coordinatorListGroupsAction, uh as coordinatorListJoinRequestsAction, $m as coordinatorListScopeMembershipsAction, Xm as coordinatorListScopesAction, sh as coordinatorRemoveDeviceAction, ih as coordinatorRenameDeviceAction, Km as coordinatorRenameGroupAction, dh as coordinatorReviewJoinRequestAction, ph as coordinatorRevokeBootstrapGrantAction, th as coordinatorRevokeScopeMembershipAction, Hl as coordinatorStatusSnapshot, Jm as coordinatorUnarchiveGroupAction, Qm as coordinatorUpdateScopeAction, br as createBetterSqliteCoordinatorApp, c as createCoordinatorApp, Bl as createCoordinatorReciprocalApproval, $b as cursorAdvances, Kf as deactivateLowSignalMemories, Gf as deactivateLowSignalObservations, Tg as decideExtractionReplayTier, s as decodeInvitePayload, qf as dedupNearDuplicateMemories, Wo as dedupeOrderedIds, bh as deleteCoordinatorGroupPreference, fy as deleteProjectScopeSettingsMapping, __ as deriveRequest, xu as deriveTags, Kb as discoverPeersViaMdns, ts as embedTexts, t as encodeInvitePayload, dr as ensureDeviceIdentity, Zr as ensureMaintenanceJobsSchema, yn as ensureSchemaBootstrapped, Tv as ensureScopeBackfillScopes, Xl as ensureScopeMembershipCacheStateTable, Bs as estimateTokens, dg as evaluateSessionExtractionItems, Wg as eventToToolEvent, Ga as expandQuery, Jo as explain, e as explainScopeMembershipRevocation, Gh as exportMemories, Kg as extractAdapterEvent, je as extractApplyPatchPaths, y_ as extractAssistantMessages, b_ as extractAssistantUsage, r as extractInvitePayload, Jf as extractNarrativeFromBody, lp as extractOAuthAccess, fp as extractOAuthAccountId, pp as extractOAuthExpires, x_ as extractPrompts, up as extractProviderApiKey, Xu as extractReplicationOps, Gg as extractToolEvents, Xr as failMaintenanceJob, xb as fetchAllSnapshotPages, Rl as fetchCoordinatorStalePeers, bu as fileTags, jd as filterReplicationOpsForSync, Ad as filterReplicationOpsForSyncWithStatus, va as findByConcept, _a as findByFile, i as fingerprintPublicKey, g_ as firstSentence, rv as flushRawEvents, Un as fromJson, Wn as fromJsonStrict, sr as generateKeypair, _u as getCachedScopeAuthorization, Lt as getCodememConfigPath, Ht as getCodememEnvOverrides, _h as getCoordinatorGroupPreference, es as getEmbeddingClient, rg as getExtractionBenchmarkProfile, oi as getInjectionEvalScenarioByPrompt, ci as getInjectionEvalScenarioPack, li as getInjectionEvalScenarioPrompts, Q as getMaintenanceJob, kf as getMemoryRoleReport, Wt as getOpenCodeProviderConfig, sn as getProviderApiKey, an as getProviderBaseUrl, on as getProviderHeaders, rn as getProviderOptions, ri as getRawEventRelinkPlan, ni as getRawEventRelinkReport, jf as getRawEventStatus, Nf as getReliabilityMetrics, qu as getReplicationCursor, Rn as getSchemaVersion, Cs as getSemanticIndexDiagnostics, fg as getSessionExtractionEval, ug as getSessionExtractionEvalScenario, di as getSummaryMetadata, wx as getSyncDaemonPhase, Ru as getSyncResetState, At as getWorkspaceCodememConfigPath, jt as getWorkspaceScopedCodememConfigPath, P_ as hasMeaningfulObservation, Sh as hasPendingDedupKeyBackfill, yy as hasPendingRefBackfill, kv as hasPendingScopeBackfill, Py as hasPendingSessionContextBackfill, By as hasPendingSummaryDedupBackfill, ad as hasUnsyncedSharedMemoryChanges, Yo as hashText, tg as importMemories, K_ as ingest, Y_ as ingestMain, ii as initDatabase, Vx as initTestSchema, Hx as insertTestSession, l as inviteLink, vx as isConnectivityError, Ln as isEmbeddingDisabled, Bg as isInternalMemoryTool, Hf as isLowSignalObservation, Qu as isNewerClock, Mg as isSensitiveFieldName, fi as isSummaryLikeMemory, h_ as isTrivialRequest, qa as kindBonus, gu as listCachedScopesForDevice, Jt as listConfiguredOpenCodeProviders, vh as listCoordinatorGroupPreferences, Ul as listCoordinatorJoinRequests, zl as listCoordinatorReciprocalApprovals, Gt as listCustomProviders, ig as listExtractionBenchmarkProfiles, Wd as listInboundScopeRejections, Kr as listMaintenanceJobs, Yt as listObserverProviderOptions, uy as listProjectScopeCandidates, iy as listProjectScopeSettingsMappings, ry as listSharingDomainSettingsScopes, id as loadMemorySnapshotPageForPeer, Vp as loadObserverConfig, Dt as loadOpenCodeConfig, op as loadOpenCodeOAuthCache, Mb as loadPeerAddresses, rr as loadPrivateKey, er as loadPrivateKeyKeychain, nr as loadPublicKey, rd as loadReplicationOpsForPeer, nd as loadReplicationOpsSince, In as loadSqliteVec, Pl as lookupCoordinatorPeers, Ir as mapClaudeHookPayload, qb as mdnsAddressesForPeer, zb as mdnsEnabled, yl as mergeAddresses, Lh as mergeSummaryMetadata, jn as migrateLegacyDbPath, qd as migrateLegacyImportKeys, Zy as negotiateSyncCapability, C_ as normalizeAdapterEvents, _l as normalizeAddress, ma as normalizeConcept, S_ as normalizeEventsForSessionContext, Vf as normalizeObservation, Dr as normalizeProjectLabel, m_ as normalizeRequestText, Xy as normalizeSyncCapability, yu as normalizeTag, Vg as normalizeToolName, N_ as parseObserverResponse, Sa as parsePositiveMemoryId, xa as parseStrictInteger, Rx as parseSyncScopeRequest, bx as peerBackoffSeconds, Sd as peerCanSyncPrivateOpByPersonalScopeGrant, yd as personalScopeGrantStatusForPeer, ld as planReplicationOpsAgePrune, ga as populateMemoryRefs, dp as probeAvailableCredentials, qg as projectAdapterToolEvent, yi as projectBasename, xi as projectClause, bi as projectColumnClause, Si as projectMatchesFilter, od as pruneReplicationOps, sd as pruneReplicationOpsUntilCaughtUp, Pf as rawEventsGate, gp as readAuthFile, Rt as readCodememConfigFile, zt as readCodememConfigFileAtPath, Al as readCoordinatorSyncConfig, Kh as readImportPayload, Pt as readWorkspaceCodememConfigFile, Ka as recencyScore, vr as recordNonce, Fb as recordPeerSuccess, $u as recordReplicationOp, Pb as recordSyncAttempt, rp as redactText, hu as refreshConfiguredScopeMembershipCache, mu as refreshScopeMembershipCache, Ll as refreshStoredCoordinatorPeerAddresses, Nl as registerCoordinatorPresence, Hd as rejectInboundScopeFailures, Cp as renderObserverHeaders, _v as replayBatchExtraction, vv as replayBatchExtractionWithTierRouting, xd as replicationOpRequiresPersonalScopeAuthorization, xl as requestJson, Lo as rerankResults, Zt as resolveBuiltInProviderDefaultModel, Xt as resolveBuiltInProviderFromModel, Qt as resolveBuiltInProviderModel, It as resolveCodememConfigPath, cn as resolveCustomProviderDefaultModel, $t as resolveCustomProviderFromModel, ln as resolveCustomProviderModel, Dn as resolveDbPath, Ar as resolveHookProject, tr as resolveKeyPaths, sp as resolveOAuthProvider, en as resolvePlaceholder, wi as resolveProject, Bi as resolveProjectScope, Mf as retryRawEventFailures, hp as runAuthCommand, wh as runDedupKeyBackfillPass, Sy as runRefBackfillPass, Fv as runScopeBackfillPass, Fy as runSessionContextBackfillPass, Wy as runSummaryDedupBackfillPass, Ox as runSyncDaemon, mx as runSyncPass, yb as runVectorMigrationPass, Fg as sanitizePayload, Rg as sanitizeToolOutput, Im as scanSecretsRetroactive, H as schema, a as scopeMembershipEpochStatus, Ro as search, Ux as seedMixedScopeFixture, jb as selectDialAddresses, As as semanticSearch, rs as serializeFloat32, Lb as setPeerLocalActorClaim, Ib as setPeerProjectFilter, Ju as setReplicationCursor, Cx as setSyncDaemonError, Sx as setSyncDaemonOk, Tx as setSyncDaemonPhase, zu as setSyncResetState, xx as shouldSkipOfflinePeer, mr as signRequest, qr as startMaintenanceJob, $n as storePrivateKeyKeychain, Os as storeVectors, Tt as stripJsonComments, kg as stripPrivate, Ng as stripPrivateObj, Et as stripTrailingCommas, Ud as summarizeInboundScopeRejections, Dx as syncDaemonTick, px as syncOnce, fx as syncPassPreflight, _d as syncProjectAllowedByFilters, Bx as syncScopeResetRequiredPayload, vd as syncVisibilityAllowed, X as tableExists, Ho as timeline, Z as toJson, Gn as toJsonNullable, Jr as updateMaintenanceJob, Nb as updatePeerAddresses, iu as upsertCachedScopeMemberships, yh as upsertCoordinatorGroupPreference, dy as upsertProjectScopeSettingsMapping, ai as vacuumDatabase, ur as validateExistingKeypair, hr as verifySignature, Bt as writeCodememConfigFile, Vt as writeWorkspaceCodememConfigFile };
|
|
17649
|
+
export { ke as Api, V as BetterSqliteCoordinatorStore, Ft as CODEMEM_CONFIG_ENV_OVERRIDES, xh as DEDUP_KEY_BACKFILL_JOB, R as DEFAULT_COORDINATOR_DB_PATH, En as DEFAULT_DB_PATH, Wl as DEFAULT_SCOPE_MEMBERSHIP_CACHE_MAX_AGE_MS, zb as DEFAULT_SERVICE_TYPE, Su as DEFAULT_SYNC_SCOPE_ID, o as DEFAULT_TIME_WINDOW_S, Th as DedupKeyBackfillRunner, si as INJECTION_EVAL_SCENARIO_PACKS, yv as LEGACY_SHARED_REVIEW_SCOPE_ID, Ti as LOCAL_DEFAULT_SCOPE_ID, rb as LOCAL_SYNC_CAPABILITY, zg as LOW_SIGNAL_TOOLS, Sr as MAPPABLE_CLAUDE_HOOK_EVENTS, Cn as MIN_COMPATIBLE_SCHEMA, Ae as MUTATING_TOOL_NAMES, bf as MemoryStore, yp as ObserverAuthAdapter, Hp as ObserverAuthError, pm as ObserverClient, Ey as REF_BACKFILL_JOB, mg as RICH_TIER_DEFAULTS, Ty as RawEventSweeper, My as RefBackfillRunner, Sn as SCHEMA_VERSION, bv as SCOPE_BACKFILL_JOB, n as SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, Ny as SESSION_CONTEXT_BACKFILL_JOB, fr as SIGNATURE_VERSION, pg as SIMPLE_TIER_DEFAULTS, qy as SUMMARY_DEDUP_BACKFILL_JOB, tb as SYNC_CAPABILITIES, nb as SYNC_CAPABILITY_HEADER, Kx as SYNC_SCOPE_QUERY_PARAM, Iv as ScopeBackfillRunner, Ky as SessionContextBackfillRunner, eb as SummaryDedupBackfillRunner, Gx as SyncRetentionRunner, p_ as TRIVIAL_REQUESTS, sb as VECTOR_MODEL_MIGRATION_JOB, $x as VERSION, kb as VectorModelMigrationRunner, Qo as _resetEmbeddingClient, Jx as addSyncScopeToBoundary, vl as addressDedupeKey, ex as advertiseMdns, Om as aiBackfillStructuredContent, gy as analyzeProjectScopeMappingChangeGuardrails, Lb as applyBootstrapSnapshot, Zd as applyReplicationOps, zn as assertSchemaReady, ep as backfillMemoryDedupKeys, Yf as backfillNarrativeFromBody, Jd as backfillReplicationOps, Mv as backfillScopeIds, zf as backfillTagsText, ks as backfillVectors, hn as bootstrapSchema, Zg as budgetToolEvents, _r as buildAuthHeaders, bl as buildBaseUrl, pr as buildCanonicalRequest, mp as buildCodexHeaders, Ji as buildFilterClauses, Yi as buildFilterClausesWithContext, Ih as buildImportKey, zr as buildIngestPayloadFromHook, qc as buildMemoryPack, Yc as buildMemoryPackAsync, Jc as buildMemoryPackTrace, Xc as buildMemoryPackTraceAsync, d_ as buildObserverPrompt, Rr as buildRawEventEnvelopeFromHook, tv as buildSessionContext, v_ as buildTranscript, cd as bulkPruneReplicationOpsByAgeCutoff, mi as canonicalMemoryKind, ji as canonicalWorkspaceIdentity, Uu as chunkOpsBySize, Xo as chunkText, Cv as classifyLegacyMemoryScope, J_ as cleanOrphanSessions, yr as cleanupNonces, ha as clearMemoryRefs, Zu as clockTuple, Af as compareMemoryRoleReports, Yr as completeMaintenanceJob, Mn as connect, Xe as connectCoordinator, Ox as consecutiveConnectivityFailures, qm as coordinatorArchiveGroupAction, Gm as coordinatorCreateGroupAction, ch as coordinatorCreateInviteAction, Zm as coordinatorCreateScopeAction, ah as coordinatorDisableDeviceAction, oh as coordinatorEnableDeviceAction, jl as coordinatorEnabled, nh as coordinatorEnrollDeviceAction, eh as coordinatorGrantScopeMembershipAction, lh as coordinatorImportInviteAction, fh as coordinatorListBootstrapGrantsAction, rh as coordinatorListDevicesAction, Ym as coordinatorListGroupsAction, uh as coordinatorListJoinRequestsAction, $m as coordinatorListScopeMembershipsAction, Xm as coordinatorListScopesAction, sh as coordinatorRemoveDeviceAction, ih as coordinatorRenameDeviceAction, Km as coordinatorRenameGroupAction, dh as coordinatorReviewJoinRequestAction, ph as coordinatorRevokeBootstrapGrantAction, th as coordinatorRevokeScopeMembershipAction, Hl as coordinatorStatusSnapshot, Jm as coordinatorUnarchiveGroupAction, Qm as coordinatorUpdateScopeAction, br as createBetterSqliteCoordinatorApp, c as createCoordinatorApp, Bl as createCoordinatorReciprocalApproval, cx as cursorAdvances, Kf as deactivateLowSignalMemories, Gf as deactivateLowSignalObservations, Tg as decideExtractionReplayTier, s as decodeInvitePayload, qf as dedupNearDuplicateMemories, Wo as dedupeOrderedIds, bh as deleteCoordinatorGroupPreference, xy as deleteProjectScopeSettingsMapping, __ as deriveRequest, xu as deriveTags, tx as discoverPeersViaMdns, ts as embedTexts, t as encodeInvitePayload, dr as ensureDeviceIdentity, Zr as ensureMaintenanceJobsSchema, yn as ensureSchemaBootstrapped, Tv as ensureScopeBackfillScopes, Xl as ensureScopeMembershipCacheStateTable, Bs as estimateTokens, dg as evaluateSessionExtractionItems, Wg as eventToToolEvent, Ga as expandQuery, Jo as explain, e as explainScopeMembershipRevocation, Gh as exportMemories, Kg as extractAdapterEvent, je as extractApplyPatchPaths, y_ as extractAssistantMessages, b_ as extractAssistantUsage, r as extractInvitePayload, Jf as extractNarrativeFromBody, lp as extractOAuthAccess, fp as extractOAuthAccountId, pp as extractOAuthExpires, x_ as extractPrompts, up as extractProviderApiKey, Xu as extractReplicationOps, Gg as extractToolEvents, Xr as failMaintenanceJob, Ab as fetchAllSnapshotPages, Rl as fetchCoordinatorStalePeers, bu as fileTags, jd as filterReplicationOpsForSync, Ad as filterReplicationOpsForSyncWithStatus, va as findByConcept, _a as findByFile, i as fingerprintPublicKey, g_ as firstSentence, rv as flushRawEvents, Un as fromJson, Wn as fromJsonStrict, sr as generateKeypair, _u as getCachedScopeAuthorization, Lt as getCodememConfigPath, Ht as getCodememEnvOverrides, _h as getCoordinatorGroupPreference, es as getEmbeddingClient, rg as getExtractionBenchmarkProfile, oi as getInjectionEvalScenarioByPrompt, ci as getInjectionEvalScenarioPack, li as getInjectionEvalScenarioPrompts, Q as getMaintenanceJob, kf as getMemoryRoleReport, Wt as getOpenCodeProviderConfig, sn as getProviderApiKey, an as getProviderBaseUrl, on as getProviderHeaders, rn as getProviderOptions, ri as getRawEventRelinkPlan, ni as getRawEventRelinkReport, jf as getRawEventStatus, Nf as getReliabilityMetrics, qu as getReplicationCursor, Rn as getSchemaVersion, Cs as getSemanticIndexDiagnostics, fg as getSessionExtractionEval, ug as getSessionExtractionEvalScenario, di as getSummaryMetadata, Nx as getSyncDaemonPhase, Ru as getSyncResetState, At as getWorkspaceCodememConfigPath, jt as getWorkspaceScopedCodememConfigPath, P_ as hasMeaningfulObservation, Sh as hasPendingDedupKeyBackfill, Oy as hasPendingRefBackfill, kv as hasPendingScopeBackfill, Uy as hasPendingSessionContextBackfill, Yy as hasPendingSummaryDedupBackfill, ad as hasUnsyncedSharedMemoryChanges, Yo as hashText, tg as importMemories, K_ as ingest, Y_ as ingestMain, ii as initDatabase, Xx as initTestSchema, Zx as insertTestSession, l as inviteLink, Dx as isConnectivityError, Ln as isEmbeddingDisabled, Bg as isInternalMemoryTool, Hf as isLowSignalObservation, Qu as isNewerClock, Mg as isSensitiveFieldName, fi as isSummaryLikeMemory, h_ as isTrivialRequest, qa as kindBonus, gu as listCachedScopesForDevice, Jt as listConfiguredOpenCodeProviders, vh as listCoordinatorGroupPreferences, Ul as listCoordinatorJoinRequests, zl as listCoordinatorReciprocalApprovals, Gt as listCustomProviders, ig as listExtractionBenchmarkProfiles, Wd as listInboundScopeRejections, Kr as listMaintenanceJobs, Yt as listObserverProviderOptions, _y as listProjectScopeCandidates, vy as listProjectScopeInventory, dy as listProjectScopeSettingsMappings, uy as listSharingDomainSettingsScopes, id as loadMemorySnapshotPageForPeer, Vp as loadObserverConfig, Dt as loadOpenCodeConfig, op as loadOpenCodeOAuthCache, Vb as loadPeerAddresses, rr as loadPrivateKey, er as loadPrivateKeyKeychain, nr as loadPublicKey, rd as loadReplicationOpsForPeer, nd as loadReplicationOpsSince, In as loadSqliteVec, Pl as lookupCoordinatorPeers, Ir as mapClaudeHookPayload, nx as mdnsAddressesForPeer, Jb as mdnsEnabled, yl as mergeAddresses, Lh as mergeSummaryMetadata, jn as migrateLegacyDbPath, qd as migrateLegacyImportKeys, ob as negotiateSyncCapability, C_ as normalizeAdapterEvents, _l as normalizeAddress, ma as normalizeConcept, S_ as normalizeEventsForSessionContext, Vf as normalizeObservation, Dr as normalizeProjectLabel, m_ as normalizeRequestText, ab as normalizeSyncCapability, yu as normalizeTag, Vg as normalizeToolName, N_ as parseObserverResponse, Sa as parsePositiveMemoryId, xa as parseStrictInteger, qx as parseSyncScopeRequest, kx as peerBackoffSeconds, Sd as peerCanSyncPrivateOpByPersonalScopeGrant, yd as personalScopeGrantStatusForPeer, ld as planReplicationOpsAgePrune, ga as populateMemoryRefs, dp as probeAvailableCredentials, qg as projectAdapterToolEvent, yi as projectBasename, xi as projectClause, bi as projectColumnClause, Si as projectMatchesFilter, od as pruneReplicationOps, sd as pruneReplicationOpsUntilCaughtUp, Pf as rawEventsGate, gp as readAuthFile, Rt as readCodememConfigFile, zt as readCodememConfigFileAtPath, Al as readCoordinatorSyncConfig, Kh as readImportPayload, Pt as readWorkspaceCodememConfigFile, yy as reassignProjectScopeInventoryProject, Ka as recencyScore, vr as recordNonce, Wb as recordPeerSuccess, $u as recordReplicationOp, Ub as recordSyncAttempt, rp as redactText, hu as refreshConfiguredScopeMembershipCache, mu as refreshScopeMembershipCache, Ll as refreshStoredCoordinatorPeerAddresses, Nl as registerCoordinatorPresence, Hd as rejectInboundScopeFailures, Cp as renderObserverHeaders, _v as replayBatchExtraction, vv as replayBatchExtractionWithTierRouting, xd as replicationOpRequiresPersonalScopeAuthorization, xl as requestJson, Lo as rerankResults, Zt as resolveBuiltInProviderDefaultModel, Xt as resolveBuiltInProviderFromModel, Qt as resolveBuiltInProviderModel, It as resolveCodememConfigPath, cn as resolveCustomProviderDefaultModel, $t as resolveCustomProviderFromModel, ln as resolveCustomProviderModel, Dn as resolveDbPath, Ar as resolveHookProject, tr as resolveKeyPaths, sp as resolveOAuthProvider, en as resolvePlaceholder, wi as resolveProject, Bi as resolveProjectScope, Mf as retryRawEventFailures, hp as runAuthCommand, wh as runDedupKeyBackfillPass, jy as runRefBackfillPass, Fv as runScopeBackfillPass, Wy as runSessionContextBackfillPass, $y as runSummaryDedupBackfillPass, Lx as runSyncDaemon, Cx as runSyncPass, Ob as runVectorMigrationPass, Fg as sanitizePayload, Rg as sanitizeToolOutput, Im as scanSecretsRetroactive, H as schema, a as scopeMembershipEpochStatus, Ro as search, Qx as seedMixedScopeFixture, Bb as selectDialAddresses, As as semanticSearch, rs as serializeFloat32, Kb as setPeerLocalActorClaim, Gb as setPeerProjectFilter, Ju as setReplicationCursor, Mx as setSyncDaemonError, jx as setSyncDaemonOk, Px as setSyncDaemonPhase, zu as setSyncResetState, Ax as shouldSkipOfflinePeer, mr as signRequest, qr as startMaintenanceJob, $n as storePrivateKeyKeychain, Os as storeVectors, Tt as stripJsonComments, kg as stripPrivate, Ng as stripPrivateObj, Et as stripTrailingCommas, Ud as summarizeInboundScopeRejections, Ix as syncDaemonTick, Sx as syncOnce, xx as syncPassPreflight, _d as syncProjectAllowedByFilters, Yx as syncScopeResetRequiredPayload, vd as syncVisibilityAllowed, X as tableExists, Ho as timeline, Z as toJson, Gn as toJsonNullable, Jr as updateMaintenanceJob, Hb as updatePeerAddresses, iu as upsertCachedScopeMemberships, yh as upsertCoordinatorGroupPreference, by as upsertProjectScopeSettingsMapping, ai as vacuumDatabase, ur as validateExistingKeypair, hr as verifySignature, Bt as writeCodememConfigFile, Vt as writeWorkspaceCodememConfigFile };
|
|
17450
17650
|
|
|
17451
17651
|
//# sourceMappingURL=index.js.map
|