@codemem/core 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +615 -417
- package/dist/index.js.map +1 -1
- package/dist/project-scope-settings.d.ts +37 -1
- package/dist/project-scope-settings.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15051,17 +15051,76 @@ function Hv(e) {
|
|
|
15051
15051
|
return !e || e.scope_id === "local-default" ? !1 : e.authority_type === "local" ? e.kind === "team" || e.kind === "org" || e.kind === "client" : !0;
|
|
15052
15052
|
}
|
|
15053
15053
|
function Uv(e) {
|
|
15054
|
-
|
|
15054
|
+
let t = Rv(e)?.toLowerCase() ?? "";
|
|
15055
|
+
return new Set(t.match(/[a-z0-9][a-z0-9-]{1,}/g) ?? []);
|
|
15055
15056
|
}
|
|
15056
15057
|
function Wv(e) {
|
|
15058
|
+
let t = new Set([
|
|
15059
|
+
"domain",
|
|
15060
|
+
"sharing",
|
|
15061
|
+
"devices",
|
|
15062
|
+
"scope",
|
|
15063
|
+
"team",
|
|
15064
|
+
"org",
|
|
15065
|
+
"local"
|
|
15066
|
+
]), n = new Set([
|
|
15067
|
+
"client",
|
|
15068
|
+
"dev",
|
|
15069
|
+
"oss",
|
|
15070
|
+
"personal",
|
|
15071
|
+
"work"
|
|
15072
|
+
]), r = [...Uv(`${e.scope_id} ${e.label}`)].filter((e) => !t.has(e));
|
|
15073
|
+
return {
|
|
15074
|
+
generic: r.filter((e) => n.has(e)),
|
|
15075
|
+
specific: r.filter((e) => !n.has(e))
|
|
15076
|
+
};
|
|
15077
|
+
}
|
|
15078
|
+
function Gv(e) {
|
|
15079
|
+
let t = [];
|
|
15080
|
+
return e.git_remote && t.push({
|
|
15081
|
+
signal: "git_remote",
|
|
15082
|
+
text: e.git_remote
|
|
15083
|
+
}), e.cwd && t.push({
|
|
15084
|
+
signal: "cwd",
|
|
15085
|
+
text: e.cwd
|
|
15086
|
+
}), t.push({
|
|
15087
|
+
signal: "workspace_id",
|
|
15088
|
+
text: e.workspace_identity
|
|
15089
|
+
}), t;
|
|
15090
|
+
}
|
|
15091
|
+
function Kv(e, t) {
|
|
15092
|
+
if (e.resolution_reason !== "local_default" || e.workspace_identity.startsWith("unmapped:")) return null;
|
|
15093
|
+
for (let n of Gv(e)) {
|
|
15094
|
+
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) => {
|
|
15095
|
+
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);
|
|
15096
|
+
return r.length === 0 && i.length === 0 ? [] : [{
|
|
15097
|
+
scope: t,
|
|
15098
|
+
matches: [...r, ...i],
|
|
15099
|
+
score: r.length * 10 + i.length
|
|
15100
|
+
}];
|
|
15101
|
+
}).toSorted((e, t) => t.score - e.score);
|
|
15102
|
+
if (!r || i && i.score === r.score) continue;
|
|
15103
|
+
let a = Bv(r.scope, r.scope.scope_id), o = n.signal === "git_remote" ? "git remote" : n.signal;
|
|
15104
|
+
return {
|
|
15105
|
+
scopeId: r.scope.scope_id,
|
|
15106
|
+
reason: `${a} is suggested because the ${o} contains ${r.matches.join(", ")}. Confirm before mapping; this does not grant peer access.`,
|
|
15107
|
+
signal: n.signal
|
|
15108
|
+
};
|
|
15109
|
+
}
|
|
15110
|
+
return null;
|
|
15111
|
+
}
|
|
15112
|
+
function qv(e) {
|
|
15113
|
+
return /[*?]/.test(e);
|
|
15114
|
+
}
|
|
15115
|
+
function Jv(e) {
|
|
15057
15116
|
let t = e.search(/[*?]/);
|
|
15058
15117
|
return (t >= 0 ? e.slice(0, t) : e).replace(/\/+$/, "");
|
|
15059
15118
|
}
|
|
15060
|
-
function
|
|
15061
|
-
let t =
|
|
15119
|
+
function Yv(e) {
|
|
15120
|
+
let t = Jv(e.replaceAll("\\", "/"));
|
|
15062
15121
|
return t === "~" || /^\/Users\/[^/]+$/i.test(t) || /^\/home\/[^/]+$/i.test(t) || /^\/var\/home\/[^/]+$/i.test(t) || /^[A-Z]:\/Users\/[^/]+$/i.test(t);
|
|
15063
15122
|
}
|
|
15064
|
-
function
|
|
15123
|
+
function Xv(e) {
|
|
15065
15124
|
let t = JSON.stringify({
|
|
15066
15125
|
code: e.code,
|
|
15067
15126
|
mapping_id: e.mapping_id ?? null,
|
|
@@ -15073,18 +15132,18 @@ function Kv(e) {
|
|
|
15073
15132
|
});
|
|
15074
15133
|
return `psg_${u("sha256").update(t).digest("hex").slice(0, 32)}`;
|
|
15075
15134
|
}
|
|
15076
|
-
function
|
|
15135
|
+
function Zv(e) {
|
|
15077
15136
|
return e.requires_confirmation ? {
|
|
15078
15137
|
...e,
|
|
15079
|
-
confirmation_token:
|
|
15138
|
+
confirmation_token: Xv(e)
|
|
15080
15139
|
} : e;
|
|
15081
15140
|
}
|
|
15082
|
-
function
|
|
15141
|
+
function Qv(e, t) {
|
|
15083
15142
|
if (e.workspace_identity) return [];
|
|
15084
15143
|
let n = zv(e.project_pattern) ?? e.project_pattern, r = t.get(e.scope_id);
|
|
15085
15144
|
if (!Hv(r)) return [];
|
|
15086
15145
|
let i = Bv(r, e.scope_id), a = [];
|
|
15087
|
-
return
|
|
15146
|
+
return qv(n) && a.push({
|
|
15088
15147
|
code: "broad_org_domain_pattern",
|
|
15089
15148
|
severity: "warning",
|
|
15090
15149
|
message: `Wildcard project pattern ${n} can catch multiple projects. Review before attaching it to ${i}.`,
|
|
@@ -15092,7 +15151,7 @@ function Jv(e, t) {
|
|
|
15092
15151
|
scope_id: e.scope_id,
|
|
15093
15152
|
mapping_id: e.id ?? null,
|
|
15094
15153
|
project_pattern: e.project_pattern
|
|
15095
|
-
}),
|
|
15154
|
+
}), Yv(n) && a.push({
|
|
15096
15155
|
code: "home_directory_org_domain_pattern",
|
|
15097
15156
|
severity: "warning",
|
|
15098
15157
|
message: `Home-directory project pattern ${n} can mix personal and work projects. Review before attaching it to ${i}.`,
|
|
@@ -15100,20 +15159,20 @@ function Jv(e, t) {
|
|
|
15100
15159
|
scope_id: e.scope_id,
|
|
15101
15160
|
mapping_id: e.id ?? null,
|
|
15102
15161
|
project_pattern: e.project_pattern
|
|
15103
|
-
}), a.map(
|
|
15162
|
+
}), a.map(Zv);
|
|
15104
15163
|
}
|
|
15105
|
-
function
|
|
15164
|
+
function $v(e) {
|
|
15106
15165
|
return (Rv(e.project) ?? Rv(e.display_project) ?? e.workspace_identity).toLowerCase();
|
|
15107
15166
|
}
|
|
15108
|
-
function
|
|
15167
|
+
function ey(e) {
|
|
15109
15168
|
let t = /* @__PURE__ */ new Map();
|
|
15110
15169
|
for (let n of e) {
|
|
15111
|
-
let e =
|
|
15170
|
+
let e = $v(n);
|
|
15112
15171
|
t.set(e, [...t.get(e) ?? [], n]);
|
|
15113
15172
|
}
|
|
15114
15173
|
return t;
|
|
15115
15174
|
}
|
|
15116
|
-
function
|
|
15175
|
+
function ty(e, t) {
|
|
15117
15176
|
let n = [];
|
|
15118
15177
|
e.resolution_reason === "local_default" && n.push({
|
|
15119
15178
|
code: "unknown_project_local_only",
|
|
@@ -15123,25 +15182,81 @@ function Zv(e, t) {
|
|
|
15123
15182
|
workspace_identity: e.workspace_identity,
|
|
15124
15183
|
scope_id: Ti
|
|
15125
15184
|
});
|
|
15126
|
-
let r = (t.get(
|
|
15185
|
+
let r = (t.get($v(e)) ?? []).filter((t) => t.workspace_identity !== e.workspace_identity);
|
|
15127
15186
|
return r.length > 0 && n.push({
|
|
15128
15187
|
code: "basename_collision_review",
|
|
15129
|
-
severity: "
|
|
15130
|
-
message: `Another
|
|
15188
|
+
severity: "info",
|
|
15189
|
+
message: `Another workspace is also named ${e.display_project}. Review the git remote or path before assigning a non-local Sharing domain.`,
|
|
15131
15190
|
requires_confirmation: !0,
|
|
15132
15191
|
workspace_identity: e.workspace_identity,
|
|
15133
15192
|
related_workspace_identities: r.map((e) => e.workspace_identity),
|
|
15134
15193
|
related_projects: r.map((e) => e.display_project)
|
|
15135
|
-
}), n.map(
|
|
15194
|
+
}), n.map(Zv);
|
|
15136
15195
|
}
|
|
15137
|
-
function
|
|
15138
|
-
let t =
|
|
15196
|
+
function ny(e) {
|
|
15197
|
+
let t = ey(e);
|
|
15139
15198
|
return e.map((e) => ({
|
|
15140
15199
|
...e,
|
|
15141
|
-
guardrail_warnings:
|
|
15200
|
+
guardrail_warnings: ty(e, t)
|
|
15142
15201
|
}));
|
|
15143
15202
|
}
|
|
15144
|
-
function
|
|
15203
|
+
function ry(e) {
|
|
15204
|
+
let t = /* @__PURE__ */ new Set();
|
|
15205
|
+
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();
|
|
15206
|
+
}
|
|
15207
|
+
function iy(e, t) {
|
|
15208
|
+
let n = Rv(t)?.toLowerCase();
|
|
15209
|
+
return n ? [
|
|
15210
|
+
e.display_project,
|
|
15211
|
+
e.project,
|
|
15212
|
+
e.cwd,
|
|
15213
|
+
e.git_remote,
|
|
15214
|
+
e.git_branch,
|
|
15215
|
+
e.workspace_identity,
|
|
15216
|
+
e.resolved_scope_id,
|
|
15217
|
+
e.suggested_scope_id
|
|
15218
|
+
].filter((e) => typeof e == "string" && e.length > 0).some((e) => e.toLowerCase().includes(n)) : !0;
|
|
15219
|
+
}
|
|
15220
|
+
function ay(e, t, n) {
|
|
15221
|
+
let r = ji({
|
|
15222
|
+
gitRemote: e.git_remote,
|
|
15223
|
+
gitBranch: e.git_branch,
|
|
15224
|
+
cwd: e.cwd,
|
|
15225
|
+
project: e.project,
|
|
15226
|
+
workspaceId: e.workspace_id
|
|
15227
|
+
}), i = Bi({
|
|
15228
|
+
gitRemote: e.git_remote,
|
|
15229
|
+
gitBranch: e.git_branch,
|
|
15230
|
+
cwd: e.cwd,
|
|
15231
|
+
project: e.project,
|
|
15232
|
+
workspaceId: e.workspace_id,
|
|
15233
|
+
mappings: t
|
|
15234
|
+
}), a = {
|
|
15235
|
+
workspace_identity: r.value,
|
|
15236
|
+
identity_source: r.source,
|
|
15237
|
+
display_project: r.displayProject ?? Rv(e.project) ?? Rv(e.cwd) ?? r.value,
|
|
15238
|
+
project: Rv(e.project),
|
|
15239
|
+
cwd: Rv(e.cwd),
|
|
15240
|
+
git_remote: Rv(e.git_remote),
|
|
15241
|
+
git_branch: Rv(e.git_branch),
|
|
15242
|
+
latest_session_at: e.started_at,
|
|
15243
|
+
resolved_scope_id: i.scopeId,
|
|
15244
|
+
resolution_reason: i.reason,
|
|
15245
|
+
mapping_id: i.mapping?.id ?? null,
|
|
15246
|
+
matched_pattern: i.matchedPattern,
|
|
15247
|
+
suggested_scope_id: null,
|
|
15248
|
+
suggestion_reason: null,
|
|
15249
|
+
suggestion_signal: null,
|
|
15250
|
+
guardrail_warnings: []
|
|
15251
|
+
}, o = Kv(a, n);
|
|
15252
|
+
return {
|
|
15253
|
+
...a,
|
|
15254
|
+
suggested_scope_id: o?.scopeId ?? null,
|
|
15255
|
+
suggestion_reason: o?.reason ?? null,
|
|
15256
|
+
suggestion_signal: o?.signal ?? null
|
|
15257
|
+
};
|
|
15258
|
+
}
|
|
15259
|
+
function oy(e) {
|
|
15145
15260
|
let t = /* @__PURE__ */ new Set();
|
|
15146
15261
|
return e.filter((e) => {
|
|
15147
15262
|
let n = [
|
|
@@ -15152,12 +15267,12 @@ function $v(e) {
|
|
|
15152
15267
|
e.related_workspace_identities?.join("|") ?? ""
|
|
15153
15268
|
].join("\0");
|
|
15154
15269
|
return t.has(n) ? !1 : (t.add(n), !0);
|
|
15155
|
-
}).map(
|
|
15270
|
+
}).map(Zv);
|
|
15156
15271
|
}
|
|
15157
|
-
function
|
|
15272
|
+
function sy(e, t) {
|
|
15158
15273
|
if (!e && !/[\\/:]/.test(t) && !(/[*?]/.test(t) && /[\\/:]/.test(t.replace(/[*?]/g, "")))) throw Error("project_pattern must use a canonical path, remote, or workspace pattern");
|
|
15159
15274
|
}
|
|
15160
|
-
function
|
|
15275
|
+
function cy(e) {
|
|
15161
15276
|
return {
|
|
15162
15277
|
scope_id: String(e.scope_id ?? ""),
|
|
15163
15278
|
label: String(e.label ?? ""),
|
|
@@ -15170,7 +15285,7 @@ function ty(e) {
|
|
|
15170
15285
|
updated_at: String(e.updated_at ?? "")
|
|
15171
15286
|
};
|
|
15172
15287
|
}
|
|
15173
|
-
function
|
|
15288
|
+
function ly(e) {
|
|
15174
15289
|
return {
|
|
15175
15290
|
id: Number(e.id ?? 0),
|
|
15176
15291
|
workspace_identity: zv(e.workspace_identity),
|
|
@@ -15183,33 +15298,34 @@ function ny(e) {
|
|
|
15183
15298
|
guardrail_warnings: []
|
|
15184
15299
|
};
|
|
15185
15300
|
}
|
|
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) =>
|
|
15301
|
+
function uy(e) {
|
|
15302
|
+
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
15303
|
}
|
|
15189
|
-
function
|
|
15304
|
+
function dy(e) {
|
|
15190
15305
|
Tv(e);
|
|
15191
|
-
let t = Vv(
|
|
15306
|
+
let t = Vv(uy(e));
|
|
15192
15307
|
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 =
|
|
15308
|
+
let n = ly(e);
|
|
15194
15309
|
return {
|
|
15195
15310
|
...n,
|
|
15196
|
-
guardrail_warnings:
|
|
15311
|
+
guardrail_warnings: Qv(n, t)
|
|
15197
15312
|
};
|
|
15198
15313
|
});
|
|
15199
15314
|
}
|
|
15200
|
-
function
|
|
15315
|
+
function fy(e, t) {
|
|
15201
15316
|
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 ?
|
|
15317
|
+
return n ? ly(n) : null;
|
|
15203
15318
|
}
|
|
15204
|
-
function
|
|
15319
|
+
function py(e, t) {
|
|
15205
15320
|
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 ?
|
|
15321
|
+
return n ? ly(n) : null;
|
|
15207
15322
|
}
|
|
15208
|
-
function
|
|
15323
|
+
function my(e, t) {
|
|
15324
|
+
if (t === "legacy-shared-review") throw Error("legacy-shared-review is a review bucket, not an assignable Sharing domain");
|
|
15209
15325
|
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
15326
|
}
|
|
15211
|
-
function
|
|
15212
|
-
let n = t.id == null ? null : Number(t.id), r = n && Number.isInteger(n) ?
|
|
15327
|
+
function hy(e, t) {
|
|
15328
|
+
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
15329
|
return {
|
|
15214
15330
|
existing: o,
|
|
15215
15331
|
workspaceIdentity: i,
|
|
@@ -15219,16 +15335,16 @@ function cy(e, t) {
|
|
|
15219
15335
|
source: Rv(t.source) ?? "user"
|
|
15220
15336
|
};
|
|
15221
15337
|
}
|
|
15222
|
-
function
|
|
15338
|
+
function gy(e, t) {
|
|
15223
15339
|
Tv(e);
|
|
15224
|
-
let n =
|
|
15225
|
-
n.projectPattern && n.scopeId && i.push(...
|
|
15340
|
+
let n = hy(e, t), r = Vv(uy(e)), i = [];
|
|
15341
|
+
n.projectPattern && n.scopeId && i.push(...Qv({
|
|
15226
15342
|
id: n.existing?.id ?? 0,
|
|
15227
15343
|
workspace_identity: n.workspaceIdentity,
|
|
15228
15344
|
project_pattern: n.projectPattern,
|
|
15229
15345
|
scope_id: n.scopeId
|
|
15230
15346
|
}, r));
|
|
15231
|
-
let a = n.workspaceIdentity ?
|
|
15347
|
+
let a = n.workspaceIdentity ? _y(e, { limit: null }).find((e) => e.workspace_identity === n.workspaceIdentity) : null, o = r.get(n.scopeId);
|
|
15232
15348
|
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
15349
|
let e = Bv(r.get(n.existing.scope_id), n.existing.scope_id), t = Bv(r.get(n.scopeId), n.scopeId);
|
|
15234
15350
|
i.push({
|
|
@@ -15248,13 +15364,32 @@ function ly(e, t) {
|
|
|
15248
15364
|
requested_scope_id: n.scopeId,
|
|
15249
15365
|
requested_workspace_identity: n.workspaceIdentity,
|
|
15250
15366
|
requested_project_pattern: n.projectPattern,
|
|
15251
|
-
warnings:
|
|
15367
|
+
warnings: oy(i)
|
|
15252
15368
|
};
|
|
15253
15369
|
}
|
|
15254
|
-
function
|
|
15370
|
+
function _y(e, t = {}) {
|
|
15255
15371
|
Tv(e);
|
|
15256
|
-
let n = Math.max(1, Math.min(t.limit ?? 250, 1e3)), r =
|
|
15257
|
-
|
|
15372
|
+
let n = t.limit === null ? null : Math.max(1, Math.min(t.limit ?? 250, 1e3)), r = dy(e), i = uy(e), a = `SELECT
|
|
15373
|
+
s.id,
|
|
15374
|
+
s.started_at,
|
|
15375
|
+
s.cwd,
|
|
15376
|
+
s.project,
|
|
15377
|
+
s.git_remote,
|
|
15378
|
+
s.git_branch,
|
|
15379
|
+
(
|
|
15380
|
+
SELECT mi.workspace_id
|
|
15381
|
+
FROM memory_items mi
|
|
15382
|
+
WHERE mi.session_id = s.id
|
|
15383
|
+
AND mi.workspace_id IS NOT NULL
|
|
15384
|
+
AND TRIM(mi.workspace_id) <> ''
|
|
15385
|
+
ORDER BY mi.id DESC
|
|
15386
|
+
LIMIT 1
|
|
15387
|
+
) AS workspace_id
|
|
15388
|
+
FROM sessions s
|
|
15389
|
+
WHERE COALESCE(TRIM(s.git_remote), TRIM(s.cwd), TRIM(s.project), '') <> ''
|
|
15390
|
+
OR EXISTS (SELECT 1 FROM memory_items mi_candidate WHERE mi_candidate.session_id = s.id)
|
|
15391
|
+
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 = [];
|
|
15392
|
+
for (let e of o) {
|
|
15258
15393
|
let t = ji({
|
|
15259
15394
|
gitRemote: e.git_remote,
|
|
15260
15395
|
gitBranch: e.git_branch,
|
|
@@ -15262,74 +15397,137 @@ function uy(e, t = {}) {
|
|
|
15262
15397
|
project: e.project,
|
|
15263
15398
|
workspaceId: e.workspace_id
|
|
15264
15399
|
});
|
|
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
|
-
});
|
|
15400
|
+
s.has(t.value) || (s.add(t.value), c.push(ay(e, r, i)));
|
|
15401
|
+
}
|
|
15402
|
+
return ny(c.toSorted((e, t) => e.display_project.localeCompare(t.display_project) || e.workspace_identity.localeCompare(t.workspace_identity)));
|
|
15403
|
+
}
|
|
15404
|
+
function vy(e, t = {}) {
|
|
15405
|
+
Tv(e);
|
|
15406
|
+
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 = [];
|
|
15407
|
+
for (let e of o) {
|
|
15408
|
+
let t = ay(e, i, a), n = s.get(t.workspace_identity);
|
|
15409
|
+
if (n) {
|
|
15410
|
+
n.memory_count = (n.memory_count ?? 0) + Number(e.memory_count ?? 0), n.session_count += Number(e.session_count ?? 1);
|
|
15411
|
+
continue;
|
|
15412
|
+
}
|
|
15413
|
+
let r = {
|
|
15414
|
+
...t,
|
|
15415
|
+
memory_count: Number(e.memory_count ?? 0),
|
|
15416
|
+
session_count: Number(e.session_count ?? 1),
|
|
15417
|
+
statuses: []
|
|
15418
|
+
};
|
|
15419
|
+
s.set(t.workspace_identity, r), c.push(r);
|
|
15290
15420
|
}
|
|
15291
|
-
|
|
15421
|
+
for (let e of i) {
|
|
15422
|
+
if (!e.workspace_identity || s.has(e.workspace_identity)) continue;
|
|
15423
|
+
let t = {
|
|
15424
|
+
workspace_identity: e.workspace_identity,
|
|
15425
|
+
identity_source: "workspace_id",
|
|
15426
|
+
display_project: e.project_pattern || e.workspace_identity,
|
|
15427
|
+
project: e.project_pattern || null,
|
|
15428
|
+
cwd: null,
|
|
15429
|
+
git_remote: null,
|
|
15430
|
+
git_branch: null,
|
|
15431
|
+
latest_session_at: null,
|
|
15432
|
+
resolved_scope_id: e.scope_id,
|
|
15433
|
+
resolution_reason: "exact_mapping",
|
|
15434
|
+
mapping_id: e.id,
|
|
15435
|
+
matched_pattern: null,
|
|
15436
|
+
suggested_scope_id: null,
|
|
15437
|
+
suggestion_reason: null,
|
|
15438
|
+
suggestion_signal: null,
|
|
15439
|
+
guardrail_warnings: [],
|
|
15440
|
+
memory_count: 0,
|
|
15441
|
+
session_count: 0,
|
|
15442
|
+
statuses: []
|
|
15443
|
+
};
|
|
15444
|
+
s.set(e.workspace_identity, t), c.push(t);
|
|
15445
|
+
}
|
|
15446
|
+
let l = ny(c).map((e) => {
|
|
15447
|
+
let t = c.find((t) => t.workspace_identity === e.workspace_identity);
|
|
15448
|
+
return {
|
|
15449
|
+
...e,
|
|
15450
|
+
memory_count: t?.memory_count ?? null,
|
|
15451
|
+
session_count: t?.session_count ?? 0,
|
|
15452
|
+
statuses: ry(e)
|
|
15453
|
+
};
|
|
15454
|
+
}).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));
|
|
15455
|
+
return {
|
|
15456
|
+
projects: l.slice(r, r + n),
|
|
15457
|
+
total: l.length,
|
|
15458
|
+
limit: n,
|
|
15459
|
+
offset: r,
|
|
15460
|
+
has_more: r + n < l.length
|
|
15461
|
+
};
|
|
15292
15462
|
}
|
|
15293
|
-
function
|
|
15463
|
+
function yy(e, t) {
|
|
15294
15464
|
Tv(e);
|
|
15295
|
-
let n =
|
|
15465
|
+
let n = zv(t.workspaceIdentity);
|
|
15466
|
+
if (!n) throw Error("workspace_identity must be a non-empty string");
|
|
15467
|
+
if (n.startsWith("unmapped:")) throw Error("unmapped projects cannot be reassigned until they have a stable identity");
|
|
15468
|
+
let r = Rv(t.project);
|
|
15469
|
+
if (!r) throw Error("project must be a non-empty string");
|
|
15470
|
+
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({
|
|
15471
|
+
gitRemote: e.git_remote,
|
|
15472
|
+
gitBranch: e.git_branch,
|
|
15473
|
+
cwd: e.cwd,
|
|
15474
|
+
project: e.project,
|
|
15475
|
+
workspaceId: e.workspace_id
|
|
15476
|
+
}).value === n);
|
|
15477
|
+
if (i.length === 0) throw Error("project identity not found");
|
|
15478
|
+
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 = ?");
|
|
15479
|
+
return e.transaction(() => {
|
|
15480
|
+
for (let e of i) s.run(r, e.id);
|
|
15481
|
+
})(), {
|
|
15482
|
+
moved_memory_count: o,
|
|
15483
|
+
moved_session_count: i.length,
|
|
15484
|
+
previous_projects: a,
|
|
15485
|
+
project: r,
|
|
15486
|
+
workspace_identity: n
|
|
15487
|
+
};
|
|
15488
|
+
}
|
|
15489
|
+
function by(e, t) {
|
|
15490
|
+
Tv(e);
|
|
15491
|
+
let n = hy(e, t), r = n.scopeId;
|
|
15296
15492
|
if (!r) throw Error("scope_id must be a non-empty string");
|
|
15297
|
-
|
|
15298
|
-
let { existing: i, workspaceIdentity: a } = n
|
|
15493
|
+
my(e, r);
|
|
15494
|
+
let { existing: i, workspaceIdentity: a } = n;
|
|
15495
|
+
if (a?.startsWith("unmapped:")) throw Error("unmapped projects cannot be assigned to a Sharing domain");
|
|
15496
|
+
let o = n.projectPattern;
|
|
15299
15497
|
if (!o) throw Error("project_pattern or workspace_identity is required");
|
|
15300
|
-
|
|
15498
|
+
sy(a, o);
|
|
15301
15499
|
let s = n.priority;
|
|
15302
15500
|
if (!Number.isFinite(s) || !Number.isInteger(s)) throw Error("priority must be an integer");
|
|
15303
15501
|
let c = n.source, l = (/* @__PURE__ */ new Date()).toISOString();
|
|
15304
15502
|
if (i) {
|
|
15305
15503
|
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 =
|
|
15504
|
+
let t = fy(e, i.id);
|
|
15307
15505
|
if (!t) throw Error("project_scope_mapping update returned no row");
|
|
15308
15506
|
return t;
|
|
15309
15507
|
}
|
|
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 =
|
|
15508
|
+
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
15509
|
if (!d) throw Error("project_scope_mapping insert returned no row");
|
|
15312
15510
|
return d;
|
|
15313
15511
|
}
|
|
15314
|
-
function
|
|
15512
|
+
function xy(e, t) {
|
|
15315
15513
|
if (!Number.isInteger(t) || t <= 0) throw Error("id must be a positive integer");
|
|
15316
15514
|
let n = e.prepare("DELETE FROM project_scope_mappings WHERE id = ?").run(t);
|
|
15317
15515
|
return Number(n.changes ?? 0) > 0;
|
|
15318
15516
|
}
|
|
15319
15517
|
//#endregion
|
|
15320
15518
|
//#region src/raw-event-sweeper.ts
|
|
15321
|
-
var
|
|
15322
|
-
function
|
|
15519
|
+
var Sy = 60;
|
|
15520
|
+
function Cy(e, t) {
|
|
15323
15521
|
let n = process.env[e];
|
|
15324
15522
|
if (n == null) return t;
|
|
15325
15523
|
let r = Number.parseInt(n, 10);
|
|
15326
15524
|
return Number.isFinite(r) ? r : t;
|
|
15327
15525
|
}
|
|
15328
|
-
function
|
|
15526
|
+
function wy(e) {
|
|
15329
15527
|
let t = (process.env[e] ?? "1").trim().toLowerCase();
|
|
15330
15528
|
return t === "0" || t === "false" || t === "off";
|
|
15331
15529
|
}
|
|
15332
|
-
var
|
|
15530
|
+
var Ty = class {
|
|
15333
15531
|
store;
|
|
15334
15532
|
ingestOpts;
|
|
15335
15533
|
active = !1;
|
|
@@ -15347,7 +15545,7 @@ var gy = class {
|
|
|
15347
15545
|
this.store = e, this.ingestOpts = t;
|
|
15348
15546
|
}
|
|
15349
15547
|
enabled() {
|
|
15350
|
-
return !
|
|
15548
|
+
return !wy("CODEMEM_RAW_EVENTS_SWEEPER");
|
|
15351
15549
|
}
|
|
15352
15550
|
intervalMs() {
|
|
15353
15551
|
let e = process.env.CODEMEM_RAW_EVENTS_SWEEPER_INTERVAL_MS;
|
|
@@ -15359,31 +15557,31 @@ var gy = class {
|
|
|
15359
15557
|
return Number.isFinite(n) && n > 0 ? Math.max(1e3, n * 1e3) : 3e4;
|
|
15360
15558
|
}
|
|
15361
15559
|
idleMs() {
|
|
15362
|
-
return
|
|
15560
|
+
return Cy("CODEMEM_RAW_EVENTS_SWEEPER_IDLE_MS", 12e4);
|
|
15363
15561
|
}
|
|
15364
15562
|
limit() {
|
|
15365
|
-
return
|
|
15563
|
+
return Cy("CODEMEM_RAW_EVENTS_SWEEPER_LIMIT", 25);
|
|
15366
15564
|
}
|
|
15367
15565
|
workerMaxEvents() {
|
|
15368
|
-
let e =
|
|
15566
|
+
let e = Cy("CODEMEM_RAW_EVENTS_WORKER_MAX_EVENTS", 100);
|
|
15369
15567
|
return e <= 0 ? null : e;
|
|
15370
15568
|
}
|
|
15371
15569
|
retentionMs() {
|
|
15372
|
-
return
|
|
15570
|
+
return Cy("CODEMEM_RAW_EVENTS_RETENTION_MS", 0);
|
|
15373
15571
|
}
|
|
15374
15572
|
autoFlushEnabled() {
|
|
15375
15573
|
return (process.env.CODEMEM_RAW_EVENTS_AUTO_FLUSH ?? "").trim() === "1";
|
|
15376
15574
|
}
|
|
15377
15575
|
debounceMs() {
|
|
15378
|
-
return
|
|
15576
|
+
return Cy("CODEMEM_RAW_EVENTS_DEBOUNCE_MS", 6e4);
|
|
15379
15577
|
}
|
|
15380
15578
|
stuckBatchMs() {
|
|
15381
|
-
return
|
|
15579
|
+
return Cy("CODEMEM_RAW_EVENTS_STUCK_BATCH_MS", 3e5);
|
|
15382
15580
|
}
|
|
15383
15581
|
handleAuthError(e) {
|
|
15384
|
-
if (this.authBackoffUntil = Date.now() / 1e3 +
|
|
15582
|
+
if (this.authBackoffUntil = Date.now() / 1e3 + Sy, !this.authErrorLogged) {
|
|
15385
15583
|
this.authErrorLogged = !0;
|
|
15386
|
-
let t = `codemem: observer auth error — backing off for ${
|
|
15584
|
+
let t = `codemem: observer auth error — backing off for ${Sy}s. Refresh your provider credentials or update observer_provider in settings. (${e.message})`;
|
|
15387
15585
|
console.error(t);
|
|
15388
15586
|
}
|
|
15389
15587
|
}
|
|
@@ -15567,16 +15765,16 @@ var gy = class {
|
|
|
15567
15765
|
}
|
|
15568
15766
|
}
|
|
15569
15767
|
}
|
|
15570
|
-
},
|
|
15571
|
-
function
|
|
15768
|
+
}, 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 )";
|
|
15769
|
+
function Oy(e) {
|
|
15572
15770
|
return e.prepare(`SELECT 1 FROM memory_items mi
|
|
15573
|
-
WHERE ${
|
|
15771
|
+
WHERE ${Dy}
|
|
15574
15772
|
LIMIT 1`).get() != null;
|
|
15575
15773
|
}
|
|
15576
|
-
function
|
|
15774
|
+
function ky(e) {
|
|
15577
15775
|
return Q(e, "memory_ref_backfill")?.metadata ?? {};
|
|
15578
15776
|
}
|
|
15579
|
-
function
|
|
15777
|
+
function Ay(e) {
|
|
15580
15778
|
if (!e) return null;
|
|
15581
15779
|
try {
|
|
15582
15780
|
let t = JSON.parse(e);
|
|
@@ -15584,17 +15782,17 @@ function xy(e) {
|
|
|
15584
15782
|
} catch {}
|
|
15585
15783
|
return null;
|
|
15586
15784
|
}
|
|
15587
|
-
async function
|
|
15588
|
-
let n = Q(e,
|
|
15785
|
+
async function jy(e, t = {}) {
|
|
15786
|
+
let n = Q(e, Ey), r = ky(e), i = Math.max(1, t.batchSize ?? 50), a = Number(r.last_cursor_id ?? 0), o = e.prepare(`SELECT mi.id, mi.files_read, mi.files_modified, mi.concepts
|
|
15589
15787
|
FROM memory_items mi
|
|
15590
15788
|
WHERE mi.id > ?
|
|
15591
|
-
AND ${
|
|
15789
|
+
AND ${Dy}
|
|
15592
15790
|
ORDER BY mi.id ASC
|
|
15593
15791
|
LIMIT ?`).all(a, i);
|
|
15594
15792
|
if (o.length === 0) {
|
|
15595
15793
|
if (n && n.status !== "completed") {
|
|
15596
15794
|
let t = Number(r.processed ?? 0);
|
|
15597
|
-
Yr(e,
|
|
15795
|
+
Yr(e, Ey, {
|
|
15598
15796
|
message: "Ref backfill complete",
|
|
15599
15797
|
progressCurrent: t,
|
|
15600
15798
|
progressTotal: Number(r.total_backfillable ?? t),
|
|
@@ -15610,9 +15808,9 @@ async function Sy(e, t = {}) {
|
|
|
15610
15808
|
let s = Number(r.processed ?? 0), c = Number(r.total_backfillable ?? 0);
|
|
15611
15809
|
if (!n || n.status === "completed" || n.status === "failed") {
|
|
15612
15810
|
let t = e.prepare(`SELECT COUNT(*) AS cnt FROM memory_items mi
|
|
15613
|
-
WHERE ${
|
|
15811
|
+
WHERE ${Dy}`).get().cnt;
|
|
15614
15812
|
qr(e, {
|
|
15615
|
-
kind:
|
|
15813
|
+
kind: Ey,
|
|
15616
15814
|
title: "Backfilling memory file/concept refs",
|
|
15617
15815
|
message: `Backfilling refs for ${t} memories`,
|
|
15618
15816
|
progressTotal: t,
|
|
@@ -15625,7 +15823,7 @@ async function Sy(e, t = {}) {
|
|
|
15625
15823
|
}), c = t;
|
|
15626
15824
|
}
|
|
15627
15825
|
let l = e.prepare("INSERT OR IGNORE INTO memory_file_refs (memory_id, file_path, relation) VALUES (?, ?, ?)"), u = e.prepare("INSERT OR IGNORE INTO memory_concept_refs (memory_id, concept) VALUES (?, ?)"), d = e.transaction((e) => {
|
|
15628
|
-
let t =
|
|
15826
|
+
let t = Ay(e.files_read), n = Ay(e.files_modified), r = Ay(e.concepts);
|
|
15629
15827
|
if (t) for (let n of t) n && l.run(e.id, n, "read");
|
|
15630
15828
|
if (n) for (let t of n) t && l.run(e.id, t, "modified");
|
|
15631
15829
|
if (r) for (let t of r) {
|
|
@@ -15636,8 +15834,8 @@ async function Sy(e, t = {}) {
|
|
|
15636
15834
|
for (let e of o) d(e);
|
|
15637
15835
|
let f = s + o.length, p = o.length < i, m = o[o.length - 1].id;
|
|
15638
15836
|
if (p) {
|
|
15639
|
-
let t = Number(
|
|
15640
|
-
return Yr(e,
|
|
15837
|
+
let t = Number(ky(e).total_backfillable ?? c ?? f);
|
|
15838
|
+
return Yr(e, Ey, {
|
|
15641
15839
|
message: "Ref backfill complete",
|
|
15642
15840
|
progressCurrent: f,
|
|
15643
15841
|
progressTotal: t,
|
|
@@ -15649,7 +15847,7 @@ async function Sy(e, t = {}) {
|
|
|
15649
15847
|
}
|
|
15650
15848
|
}), !1;
|
|
15651
15849
|
}
|
|
15652
|
-
return Jr(e,
|
|
15850
|
+
return Jr(e, Ey, {
|
|
15653
15851
|
message: `Backfilled refs for ${f} of ${c} memories`,
|
|
15654
15852
|
progressCurrent: f,
|
|
15655
15853
|
progressTotal: c,
|
|
@@ -15661,7 +15859,7 @@ async function Sy(e, t = {}) {
|
|
|
15661
15859
|
}
|
|
15662
15860
|
}), !0;
|
|
15663
15861
|
}
|
|
15664
|
-
var
|
|
15862
|
+
var My = class {
|
|
15665
15863
|
dbPath;
|
|
15666
15864
|
signal;
|
|
15667
15865
|
batchSize;
|
|
@@ -15691,14 +15889,14 @@ var Cy = class {
|
|
|
15691
15889
|
if (!this.active || this.signal?.aborted) return;
|
|
15692
15890
|
let e = null;
|
|
15693
15891
|
try {
|
|
15694
|
-
e = Mn(this.dbPath), await
|
|
15892
|
+
e = Mn(this.dbPath), await jy(e, { batchSize: this.batchSize }) || (this.active = !1);
|
|
15695
15893
|
} catch (t) {
|
|
15696
|
-
e && Xr(e,
|
|
15894
|
+
e && Xr(e, Ey, t instanceof Error ? t.message : String(t)), console.warn("Ref backfill runner failed", t);
|
|
15697
15895
|
} finally {
|
|
15698
15896
|
e?.close();
|
|
15699
15897
|
}
|
|
15700
15898
|
}
|
|
15701
|
-
},
|
|
15899
|
+
}, Ny = "session_context_backfill", Py = [
|
|
15702
15900
|
"firstPrompt",
|
|
15703
15901
|
"promptCount",
|
|
15704
15902
|
"toolCount",
|
|
@@ -15706,20 +15904,20 @@ var Cy = class {
|
|
|
15706
15904
|
"filesModified",
|
|
15707
15905
|
"filesRead"
|
|
15708
15906
|
];
|
|
15709
|
-
function
|
|
15907
|
+
function Fy(e) {
|
|
15710
15908
|
let t = e.prepare("SELECT COUNT(*) AS c FROM sessions\n WHERE json_extract(metadata_json, '$.session_context.flusher') = 'raw_events'").get();
|
|
15711
15909
|
return Number(t?.c ?? 0);
|
|
15712
15910
|
}
|
|
15713
|
-
function
|
|
15911
|
+
function Iy(e, t, n) {
|
|
15714
15912
|
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
15913
|
}
|
|
15716
|
-
function
|
|
15914
|
+
function Ly(e, t, n) {
|
|
15717
15915
|
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
15916
|
let t = JSON.parse(e.payload_json);
|
|
15719
15917
|
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
15918
|
});
|
|
15721
15919
|
}
|
|
15722
|
-
function
|
|
15920
|
+
function Ry(e) {
|
|
15723
15921
|
if (!e) return {};
|
|
15724
15922
|
try {
|
|
15725
15923
|
let t = JSON.parse(e);
|
|
@@ -15727,42 +15925,42 @@ function ky(e) {
|
|
|
15727
15925
|
} catch {}
|
|
15728
15926
|
return {};
|
|
15729
15927
|
}
|
|
15730
|
-
function
|
|
15928
|
+
function zy(e) {
|
|
15731
15929
|
return Array.isArray(e) ? [...e].sort() : e ?? null;
|
|
15732
15930
|
}
|
|
15733
|
-
function
|
|
15734
|
-
for (let n of
|
|
15735
|
-
let r =
|
|
15931
|
+
function By(e, t) {
|
|
15932
|
+
for (let n of Py) {
|
|
15933
|
+
let r = zy(e[n]), i = zy(t[n]);
|
|
15736
15934
|
if (JSON.stringify(r) !== JSON.stringify(i)) return !0;
|
|
15737
15935
|
}
|
|
15738
15936
|
return !1;
|
|
15739
15937
|
}
|
|
15740
|
-
function
|
|
15938
|
+
function Vy(e, t) {
|
|
15741
15939
|
let n = { ...e };
|
|
15742
|
-
for (let e of
|
|
15940
|
+
for (let e of Py) {
|
|
15743
15941
|
let r = t[e];
|
|
15744
15942
|
r === void 0 ? delete n[e] : n[e] = r;
|
|
15745
15943
|
}
|
|
15746
15944
|
return n;
|
|
15747
15945
|
}
|
|
15748
|
-
function
|
|
15946
|
+
function Hy(e, t, n) {
|
|
15749
15947
|
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
15948
|
for (let n of t) {
|
|
15751
15949
|
if (s = n.id, !n.source || !n.stream_id) {
|
|
15752
15950
|
a += 1;
|
|
15753
15951
|
continue;
|
|
15754
15952
|
}
|
|
15755
|
-
let t =
|
|
15953
|
+
let t = Ly(e, n.source, n.stream_id);
|
|
15756
15954
|
if (t.length === 0) {
|
|
15757
15955
|
i += 1;
|
|
15758
15956
|
continue;
|
|
15759
15957
|
}
|
|
15760
|
-
let l = tv(S_(t)), u =
|
|
15761
|
-
if (!
|
|
15958
|
+
let l = tv(S_(t)), u = Ry(n.metadata_json), d = u.session_context, f = d && typeof d == "object" ? d : {};
|
|
15959
|
+
if (!By(f, l)) {
|
|
15762
15960
|
o += 1;
|
|
15763
15961
|
continue;
|
|
15764
15962
|
}
|
|
15765
|
-
let p =
|
|
15963
|
+
let p = Vy(f, l), m = {
|
|
15766
15964
|
...u,
|
|
15767
15965
|
session_context: p
|
|
15768
15966
|
};
|
|
@@ -15778,14 +15976,14 @@ function Ny(e, t, n) {
|
|
|
15778
15976
|
exhausted: t.length < n
|
|
15779
15977
|
};
|
|
15780
15978
|
}
|
|
15781
|
-
function
|
|
15782
|
-
return Q(e, "session_context_backfill")?.status === "completed" ? !1 :
|
|
15979
|
+
function Uy(e) {
|
|
15980
|
+
return Q(e, "session_context_backfill")?.status === "completed" ? !1 : Fy(e) > 0;
|
|
15783
15981
|
}
|
|
15784
|
-
async function
|
|
15785
|
-
let n = Math.max(1, t.batchSize ?? 100), r = Q(e,
|
|
15982
|
+
async function Wy(e, t = {}) {
|
|
15983
|
+
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
15984
|
if (a && s <= 0) return !1;
|
|
15787
15985
|
a && qr(e, {
|
|
15788
|
-
kind:
|
|
15986
|
+
kind: Ny,
|
|
15789
15987
|
title: "Backfilling session context",
|
|
15790
15988
|
message: `Rebuilding session_context for ${s} raw-event sessions`,
|
|
15791
15989
|
progressTotal: s,
|
|
@@ -15799,11 +15997,11 @@ async function Fy(e, t = {}) {
|
|
|
15799
15997
|
unchanged_sessions: 0
|
|
15800
15998
|
}
|
|
15801
15999
|
});
|
|
15802
|
-
let c =
|
|
16000
|
+
let c = Iy(e, o, n);
|
|
15803
16001
|
if (c.length === 0) {
|
|
15804
16002
|
let t = Q(e, "session_context_backfill")?.metadata ?? {};
|
|
15805
|
-
return Yr(e,
|
|
15806
|
-
message:
|
|
16003
|
+
return Yr(e, Ny, {
|
|
16004
|
+
message: Gy(t),
|
|
15807
16005
|
progressCurrent: Number(t.processed_sessions ?? 0),
|
|
15808
16006
|
progressTotal: Number(t.total_candidates ?? t.processed_sessions ?? 0),
|
|
15809
16007
|
metadata: {
|
|
@@ -15812,7 +16010,7 @@ async function Fy(e, t = {}) {
|
|
|
15812
16010
|
}
|
|
15813
16011
|
}), !1;
|
|
15814
16012
|
}
|
|
15815
|
-
let l =
|
|
16013
|
+
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
16014
|
last_cursor_id: l.lastCursorId,
|
|
15817
16015
|
total_candidates: Number(u.total_candidates ?? s),
|
|
15818
16016
|
processed_sessions: d,
|
|
@@ -15821,12 +16019,12 @@ async function Fy(e, t = {}) {
|
|
|
15821
16019
|
skipped_no_bridge: m,
|
|
15822
16020
|
unchanged_sessions: h
|
|
15823
16021
|
};
|
|
15824
|
-
return l.exhausted ? (Yr(e,
|
|
15825
|
-
message:
|
|
16022
|
+
return l.exhausted ? (Yr(e, Ny, {
|
|
16023
|
+
message: Gy(g),
|
|
15826
16024
|
progressCurrent: d,
|
|
15827
16025
|
progressTotal: Number(g.total_candidates ?? d),
|
|
15828
16026
|
metadata: g
|
|
15829
|
-
}), !1) : (Jr(e,
|
|
16027
|
+
}), !1) : (Jr(e, Ny, {
|
|
15830
16028
|
status: "running",
|
|
15831
16029
|
message: `Rebuilt session_context for ${f} of ${d} scanned sessions`,
|
|
15832
16030
|
progressCurrent: d,
|
|
@@ -15834,11 +16032,11 @@ async function Fy(e, t = {}) {
|
|
|
15834
16032
|
metadata: g
|
|
15835
16033
|
}), !0);
|
|
15836
16034
|
}
|
|
15837
|
-
function
|
|
16035
|
+
function Gy(e) {
|
|
15838
16036
|
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
16037
|
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
16038
|
}
|
|
15841
|
-
var
|
|
16039
|
+
var Ky = class {
|
|
15842
16040
|
dbPath;
|
|
15843
16041
|
signal;
|
|
15844
16042
|
batchSize;
|
|
@@ -15868,25 +16066,25 @@ var Ly = class {
|
|
|
15868
16066
|
if (!this.active || this.signal?.aborted) return;
|
|
15869
16067
|
let e = null;
|
|
15870
16068
|
try {
|
|
15871
|
-
e = Mn(this.dbPath), await
|
|
16069
|
+
e = Mn(this.dbPath), await Wy(e, { batchSize: this.batchSize }) || (this.active = !1);
|
|
15872
16070
|
} catch (t) {
|
|
15873
|
-
e && Xr(e,
|
|
16071
|
+
e && Xr(e, Ny, t instanceof Error ? t.message : String(t)), console.warn("Session-context backfill runner failed", t);
|
|
15874
16072
|
} finally {
|
|
15875
16073
|
e?.close();
|
|
15876
16074
|
}
|
|
15877
16075
|
}
|
|
15878
|
-
},
|
|
15879
|
-
function
|
|
16076
|
+
}, qy = "session_summary_dedup_backfill";
|
|
16077
|
+
function Jy(e) {
|
|
15880
16078
|
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
16079
|
return Number(t?.n ?? 0);
|
|
15882
16080
|
}
|
|
15883
|
-
function
|
|
15884
|
-
return
|
|
16081
|
+
function Yy(e) {
|
|
16082
|
+
return Jy(e) > 0;
|
|
15885
16083
|
}
|
|
15886
|
-
function
|
|
16084
|
+
function Xy(e) {
|
|
15887
16085
|
return Q(e, "session_summary_dedup_backfill")?.metadata ?? {};
|
|
15888
16086
|
}
|
|
15889
|
-
function
|
|
16087
|
+
function Zy(e, t, n) {
|
|
15890
16088
|
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
16089
|
if (r.length === 0) return [];
|
|
15892
16090
|
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 +16100,7 @@ function Hy(e, t, n) {
|
|
|
15902
16100
|
}
|
|
15903
16101
|
return a;
|
|
15904
16102
|
}
|
|
15905
|
-
function
|
|
16103
|
+
function Qy(e, t, n) {
|
|
15906
16104
|
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
16105
|
for (let o of t.superseded) {
|
|
15908
16106
|
let s = Un(o.metadata_json);
|
|
@@ -15918,9 +16116,9 @@ function Uy(e, t, n) {
|
|
|
15918
16116
|
}
|
|
15919
16117
|
return a;
|
|
15920
16118
|
}
|
|
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,
|
|
16119
|
+
async function $y(e, t = {}) {
|
|
16120
|
+
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);
|
|
16121
|
+
if (c.length === 0) return i && i.status !== "completed" && Yr(e, qy, {
|
|
15924
16122
|
message: u > 0 ? `Session-summary dedup complete (${u} rows superseded)` : "Session-summary dedup complete",
|
|
15925
16123
|
progressCurrent: l,
|
|
15926
16124
|
progressTotal: Number(a.total_sessions ?? l),
|
|
@@ -15930,9 +16128,9 @@ async function Wy(e, t = {}) {
|
|
|
15930
16128
|
}
|
|
15931
16129
|
}), !1;
|
|
15932
16130
|
if (!i || i.status === "completed" || i.status === "failed") {
|
|
15933
|
-
let t =
|
|
16131
|
+
let t = Jy(e);
|
|
15934
16132
|
qr(e, {
|
|
15935
|
-
kind:
|
|
16133
|
+
kind: qy,
|
|
15936
16134
|
title: "Deduplicating historical session summaries",
|
|
15937
16135
|
message: `Cleaning up ${t} sessions with duplicate observer summaries`,
|
|
15938
16136
|
progressTotal: t,
|
|
@@ -15947,10 +16145,10 @@ async function Wy(e, t = {}) {
|
|
|
15947
16145
|
}
|
|
15948
16146
|
let d = 0, f = s;
|
|
15949
16147
|
e.transaction(() => {
|
|
15950
|
-
for (let t of c) d +=
|
|
16148
|
+
for (let t of c) d += Qy(e, t, r), t.session_id > f && (f = t.session_id);
|
|
15951
16149
|
})();
|
|
15952
|
-
let p = l + c.length, m = u + d, h =
|
|
15953
|
-
return h === 0 ? (Yr(e,
|
|
16150
|
+
let p = l + c.length, m = u + d, h = Jy(e), g = Math.max(Number(a.total_sessions ?? p), p + h);
|
|
16151
|
+
return h === 0 ? (Yr(e, qy, {
|
|
15954
16152
|
message: `Session-summary dedup complete (${m} rows superseded across ${p} sessions)`,
|
|
15955
16153
|
progressCurrent: p,
|
|
15956
16154
|
progressTotal: g,
|
|
@@ -15960,7 +16158,7 @@ async function Wy(e, t = {}) {
|
|
|
15960
16158
|
superseded_rows: m,
|
|
15961
16159
|
last_session_id: f
|
|
15962
16160
|
}
|
|
15963
|
-
}), !1) : (Jr(e,
|
|
16161
|
+
}), !1) : (Jr(e, qy, {
|
|
15964
16162
|
message: `Deduplicated ${p} of ${g} sessions (${m} rows superseded)`,
|
|
15965
16163
|
progressCurrent: p,
|
|
15966
16164
|
progressTotal: g,
|
|
@@ -15972,7 +16170,7 @@ async function Wy(e, t = {}) {
|
|
|
15972
16170
|
}
|
|
15973
16171
|
}), !0);
|
|
15974
16172
|
}
|
|
15975
|
-
var
|
|
16173
|
+
var eb = class {
|
|
15976
16174
|
dbPath;
|
|
15977
16175
|
signal;
|
|
15978
16176
|
batchSize;
|
|
@@ -16003,97 +16201,97 @@ var Gy = class {
|
|
|
16003
16201
|
if (!this.active || this.signal?.aborted) return;
|
|
16004
16202
|
let e = null;
|
|
16005
16203
|
try {
|
|
16006
|
-
e = Mn(this.dbPath), await
|
|
16204
|
+
e = Mn(this.dbPath), await $y(e, {
|
|
16007
16205
|
batchSize: this.batchSize,
|
|
16008
16206
|
deviceId: this.deviceId
|
|
16009
16207
|
}) || (this.active = !1);
|
|
16010
16208
|
} catch (t) {
|
|
16011
|
-
e && Xr(e,
|
|
16209
|
+
e && Xr(e, qy, t instanceof Error ? t.message : String(t)), console.warn("Summary-dedup backfill runner failed", t);
|
|
16012
16210
|
} finally {
|
|
16013
16211
|
e?.close();
|
|
16014
16212
|
}
|
|
16015
16213
|
}
|
|
16016
|
-
},
|
|
16214
|
+
}, tb = [
|
|
16017
16215
|
"unsupported",
|
|
16018
16216
|
"aware",
|
|
16019
16217
|
"enforcing"
|
|
16020
|
-
],
|
|
16218
|
+
], nb = "X-Codemem-Sync-Capability", rb = "aware", ib = {
|
|
16021
16219
|
unsupported: 0,
|
|
16022
16220
|
aware: 1,
|
|
16023
16221
|
enforcing: 2
|
|
16024
16222
|
};
|
|
16025
|
-
function
|
|
16223
|
+
function ab(e) {
|
|
16026
16224
|
if (typeof e != "string") return "unsupported";
|
|
16027
16225
|
let t = e.trim().toLowerCase();
|
|
16028
|
-
return
|
|
16226
|
+
return tb.includes(t) ? t : "unsupported";
|
|
16029
16227
|
}
|
|
16030
|
-
function
|
|
16031
|
-
let n =
|
|
16032
|
-
return
|
|
16228
|
+
function ob(e, t) {
|
|
16229
|
+
let n = ab(e), r = ab(t);
|
|
16230
|
+
return ib[n] <= ib[r] ? n : r;
|
|
16033
16231
|
}
|
|
16034
16232
|
//#endregion
|
|
16035
16233
|
//#region src/vector-migration.ts
|
|
16036
|
-
var
|
|
16037
|
-
function
|
|
16234
|
+
var sb = "vector_model_migration", cb = "sync_bootstrap", lb = "sync_incremental", ub = 6e4, db = null;
|
|
16235
|
+
function fb(e) {
|
|
16038
16236
|
return [...new Set(e.filter((e) => Number.isInteger(e) && e > 0))].sort((e, t) => e - t);
|
|
16039
16237
|
}
|
|
16040
|
-
function
|
|
16041
|
-
return Array.isArray(e) ?
|
|
16238
|
+
function pb(e) {
|
|
16239
|
+
return Array.isArray(e) ? fb(e.filter((e) => typeof e == "number")) : [];
|
|
16042
16240
|
}
|
|
16043
|
-
function
|
|
16044
|
-
let n = new Set(
|
|
16045
|
-
for (let e of
|
|
16046
|
-
for (let e of
|
|
16241
|
+
function mb(e, t) {
|
|
16242
|
+
let n = new Set(pb(e.pending_upsert_memory_ids)), r = new Set(pb(e.pending_delete_memory_ids));
|
|
16243
|
+
for (let e of fb(t.deleteMemoryIds)) n.delete(e), r.add(e);
|
|
16244
|
+
for (let e of fb(t.upsertMemoryIds)) r.delete(e), n.add(e);
|
|
16047
16245
|
return {
|
|
16048
16246
|
pending_upsert_memory_ids: [...n],
|
|
16049
16247
|
pending_delete_memory_ids: [...r]
|
|
16050
16248
|
};
|
|
16051
16249
|
}
|
|
16052
|
-
function
|
|
16250
|
+
function hb(e, t) {
|
|
16053
16251
|
if (t.length === 0) return;
|
|
16054
16252
|
let n = t.map(() => "?").join(", ");
|
|
16055
16253
|
e.prepare(`DELETE FROM memory_vectors WHERE memory_id IN (${n})`).run(...t);
|
|
16056
16254
|
}
|
|
16057
|
-
function
|
|
16058
|
-
return JSON.stringify(
|
|
16255
|
+
function gb(e, t) {
|
|
16256
|
+
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
16257
|
}
|
|
16060
|
-
function
|
|
16061
|
-
|
|
16258
|
+
function _b() {
|
|
16259
|
+
db?.wake();
|
|
16062
16260
|
}
|
|
16063
|
-
function
|
|
16064
|
-
let n =
|
|
16261
|
+
function vb(e, t) {
|
|
16262
|
+
let n = mb({}, t);
|
|
16065
16263
|
if ((n.pending_upsert_memory_ids?.length ?? 0) === 0 && (n.pending_delete_memory_ids?.length ?? 0) === 0) return;
|
|
16066
|
-
let r = Q(e,
|
|
16264
|
+
let r = Q(e, sb), i = r && r.status !== "completed" && r.status !== "cancelled" ? r.metadata ?? {} : {}, a = {
|
|
16067
16265
|
...i,
|
|
16068
|
-
...
|
|
16069
|
-
trigger: i.trigger ??
|
|
16070
|
-
}, o =
|
|
16266
|
+
...mb(i, t),
|
|
16267
|
+
trigger: i.trigger ?? lb
|
|
16268
|
+
}, o = pb(a.pending_upsert_memory_ids).length + pb(a.pending_delete_memory_ids).length;
|
|
16071
16269
|
if (!r || r.status === "completed" || r.status === "cancelled") {
|
|
16072
16270
|
qr(e, {
|
|
16073
|
-
kind:
|
|
16271
|
+
kind: sb,
|
|
16074
16272
|
title: "Re-indexing memories",
|
|
16075
16273
|
status: "pending",
|
|
16076
16274
|
message: "Queued vector catch-up for incremental sync data",
|
|
16077
16275
|
progressTotal: null,
|
|
16078
16276
|
metadata: a
|
|
16079
|
-
}),
|
|
16277
|
+
}), _b();
|
|
16080
16278
|
return;
|
|
16081
16279
|
}
|
|
16082
|
-
Jr(e,
|
|
16280
|
+
Jr(e, sb, {
|
|
16083
16281
|
status: "pending",
|
|
16084
16282
|
message: "Queued vector catch-up for incremental sync data",
|
|
16085
16283
|
progressCurrent: r.status === "failed" ? 0 : Math.min(r.progress.current, o),
|
|
16086
16284
|
progressTotal: r.progress.total,
|
|
16087
16285
|
metadata: a
|
|
16088
|
-
}),
|
|
16286
|
+
}), _b();
|
|
16089
16287
|
}
|
|
16090
|
-
async function
|
|
16091
|
-
let a = t.metadata ?? {}, o =
|
|
16288
|
+
async function yb(e, t, n, r, i) {
|
|
16289
|
+
let a = t.metadata ?? {}, o = pb(a.pending_delete_memory_ids), s = pb(a.pending_upsert_memory_ids);
|
|
16092
16290
|
if (o.length === 0 && s.length === 0) return {
|
|
16093
16291
|
completed: !1,
|
|
16094
16292
|
metadata: a
|
|
16095
16293
|
};
|
|
16096
|
-
o.length > 0 &&
|
|
16294
|
+
o.length > 0 && hb(e, o);
|
|
16097
16295
|
let c = s.slice(0, r);
|
|
16098
16296
|
if (c.length > 0) {
|
|
16099
16297
|
if (await ks(e, {
|
|
@@ -16109,14 +16307,14 @@ async function ub(e, t, n, r, i) {
|
|
|
16109
16307
|
...a,
|
|
16110
16308
|
pending_delete_memory_ids: [],
|
|
16111
16309
|
pending_upsert_memory_ids: s.slice(c.length)
|
|
16112
|
-
}, u = Q(e, "vector_model_migration")?.metadata ?? {}, d =
|
|
16310
|
+
}, u = Q(e, "vector_model_migration")?.metadata ?? {}, d = gb(u, a) ? l : {
|
|
16113
16311
|
...u,
|
|
16114
|
-
...
|
|
16115
|
-
upsertMemoryIds:
|
|
16116
|
-
deleteMemoryIds:
|
|
16312
|
+
...mb(u, {
|
|
16313
|
+
upsertMemoryIds: pb(l.pending_upsert_memory_ids),
|
|
16314
|
+
deleteMemoryIds: pb(l.pending_delete_memory_ids)
|
|
16117
16315
|
})
|
|
16118
|
-
}, f =
|
|
16119
|
-
return f === 0 && p ? (Yr(e,
|
|
16316
|
+
}, 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;
|
|
16317
|
+
return f === 0 && p ? (Yr(e, sb, {
|
|
16120
16318
|
message: "Finished vector catch-up for incremental sync data",
|
|
16121
16319
|
progressCurrent: 0,
|
|
16122
16320
|
progressTotal: null,
|
|
@@ -16124,7 +16322,7 @@ async function ub(e, t, n, r, i) {
|
|
|
16124
16322
|
}), {
|
|
16125
16323
|
completed: !0,
|
|
16126
16324
|
metadata: d
|
|
16127
|
-
}) : (Jr(e,
|
|
16325
|
+
}) : (Jr(e, sb, {
|
|
16128
16326
|
status: f > 0 ? "running" : t.status,
|
|
16129
16327
|
message: f > 0 ? `Queued vector catch-up has ${f} memory change(s) remaining` : t.message,
|
|
16130
16328
|
progressCurrent: 0,
|
|
@@ -16135,36 +16333,36 @@ async function ub(e, t, n, r, i) {
|
|
|
16135
16333
|
metadata: d
|
|
16136
16334
|
});
|
|
16137
16335
|
}
|
|
16138
|
-
function
|
|
16336
|
+
function bb(e, t = {}) {
|
|
16139
16337
|
let n = typeof t.embeddableTotal == "number" && t.embeddableTotal >= 0 ? t.embeddableTotal : null, r = {
|
|
16140
16338
|
last_cursor_id: 0,
|
|
16141
16339
|
processed_embeddable: 0,
|
|
16142
|
-
trigger:
|
|
16340
|
+
trigger: cb
|
|
16143
16341
|
};
|
|
16144
16342
|
n != null && (r.embeddable_total = n), qr(e, {
|
|
16145
|
-
kind:
|
|
16343
|
+
kind: sb,
|
|
16146
16344
|
title: "Re-indexing memories",
|
|
16147
16345
|
status: "pending",
|
|
16148
16346
|
message: "Queued vector catch-up for synced bootstrap data",
|
|
16149
16347
|
progressTotal: n,
|
|
16150
16348
|
metadata: r
|
|
16151
|
-
}),
|
|
16349
|
+
}), _b();
|
|
16152
16350
|
}
|
|
16153
|
-
function
|
|
16351
|
+
function xb(e) {
|
|
16154
16352
|
return e.prepare("SELECT model, COUNT(*) AS rows FROM memory_vectors GROUP BY model ORDER BY rows DESC, model ASC").all();
|
|
16155
16353
|
}
|
|
16156
|
-
function
|
|
16354
|
+
function Sb(e) {
|
|
16157
16355
|
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
16356
|
return Number(t?.c ?? 0);
|
|
16159
16357
|
}
|
|
16160
|
-
function
|
|
16358
|
+
function Cb(e, t, n) {
|
|
16161
16359
|
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
16360
|
}
|
|
16163
|
-
function
|
|
16361
|
+
function wb(e) {
|
|
16164
16362
|
return `${e.title ?? ""}
|
|
16165
16363
|
${e.body_text ?? ""}`.trim().length > 0;
|
|
16166
16364
|
}
|
|
16167
|
-
function
|
|
16365
|
+
function Tb(e, t, n, r) {
|
|
16168
16366
|
let i = e?.metadata ?? {};
|
|
16169
16367
|
return {
|
|
16170
16368
|
source_model: t ?? i.source_model ?? null,
|
|
@@ -16174,39 +16372,39 @@ function gb(e, t, n, r) {
|
|
|
16174
16372
|
embeddable_total: Number(i.embeddable_total ?? r)
|
|
16175
16373
|
};
|
|
16176
16374
|
}
|
|
16177
|
-
function
|
|
16375
|
+
function Eb(e, t) {
|
|
16178
16376
|
let n = e.prepare("SELECT COUNT(*) AS c FROM memory_vectors WHERE model != ?").get(t), r = Number(n?.c ?? 0);
|
|
16179
16377
|
return r > 0 && e.prepare("DELETE FROM memory_vectors WHERE model != ?").run(t), r;
|
|
16180
16378
|
}
|
|
16181
|
-
function
|
|
16182
|
-
return
|
|
16379
|
+
function Db(e, t) {
|
|
16380
|
+
return xb(e).filter((e) => e.model !== t)[0]?.model ?? null;
|
|
16183
16381
|
}
|
|
16184
|
-
async function
|
|
16185
|
-
let n = Q(e,
|
|
16382
|
+
async function Ob(e, t = {}) {
|
|
16383
|
+
let n = Q(e, sb), r = n?.status === "running" || n?.status === "pending";
|
|
16186
16384
|
if (Ln()) {
|
|
16187
|
-
r && Xr(e,
|
|
16385
|
+
r && Xr(e, sb, "Embeddings are disabled", { message: "Vector re-indexing is waiting for embeddings to be enabled" });
|
|
16188
16386
|
return;
|
|
16189
16387
|
}
|
|
16190
16388
|
let i = await es();
|
|
16191
16389
|
if (!i) {
|
|
16192
|
-
r && Xr(e,
|
|
16390
|
+
r && Xr(e, sb, "Embedding client unavailable", { message: "Vector re-indexing is waiting for the embedding client" });
|
|
16193
16391
|
return;
|
|
16194
16392
|
}
|
|
16195
|
-
let a = i.model, o = Math.max(1, t.batchSize ?? 50), s = n?.metadata ?? {}, c =
|
|
16393
|
+
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
16394
|
if (n?.status === "completed" && s.target_model === a && c === 0) return;
|
|
16197
16395
|
if (n) {
|
|
16198
|
-
let r = await
|
|
16396
|
+
let r = await yb(e, n, a, o, t.signal);
|
|
16199
16397
|
if (r.completed) return;
|
|
16200
|
-
let i =
|
|
16201
|
-
if ((r.metadata.trigger ??
|
|
16202
|
-
n = Q(e,
|
|
16398
|
+
let i = pb(r.metadata.pending_delete_memory_ids).length + pb(r.metadata.pending_upsert_memory_ids).length;
|
|
16399
|
+
if ((r.metadata.trigger ?? lb) === lb && i > 0) return;
|
|
16400
|
+
n = Q(e, sb);
|
|
16203
16401
|
}
|
|
16204
|
-
let l =
|
|
16205
|
-
if (!l && (d ===
|
|
16402
|
+
let l = Db(e, a), u = n?.status === "running" || n?.status === "pending" || n?.status === "failed", d = n?.metadata?.trigger;
|
|
16403
|
+
if (!l && (d === lb || d === cb) && u) {
|
|
16206
16404
|
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
16405
|
if (Number(t?.c ?? 0) <= 0) {
|
|
16208
|
-
let t = n?.metadata ?? {}, r =
|
|
16209
|
-
Yr(e,
|
|
16406
|
+
let t = n?.metadata ?? {}, r = Sb(e);
|
|
16407
|
+
Yr(e, sb, {
|
|
16210
16408
|
message: "Finished re-indexing memories",
|
|
16211
16409
|
progressCurrent: r,
|
|
16212
16410
|
progressTotal: r,
|
|
@@ -16221,9 +16419,9 @@ async function yb(e, t = {}) {
|
|
|
16221
16419
|
return;
|
|
16222
16420
|
}
|
|
16223
16421
|
}
|
|
16224
|
-
let f = n?.metadata ?? {}, p = (n?.status === "running" || n?.status === "pending") && f.embeddable_total ? Number(f.embeddable_total) :
|
|
16422
|
+
let f = n?.metadata ?? {}, p = (n?.status === "running" || n?.status === "pending") && f.embeddable_total ? Number(f.embeddable_total) : Sb(e);
|
|
16225
16423
|
if (p <= 0 && u && !l) {
|
|
16226
|
-
Yr(e,
|
|
16424
|
+
Yr(e, sb, {
|
|
16227
16425
|
message: "No embeddable memories to re-index",
|
|
16228
16426
|
progressCurrent: 0,
|
|
16229
16427
|
progressTotal: 0,
|
|
@@ -16237,9 +16435,9 @@ async function yb(e, t = {}) {
|
|
|
16237
16435
|
return;
|
|
16238
16436
|
}
|
|
16239
16437
|
if (l && p <= 0) {
|
|
16240
|
-
let t =
|
|
16438
|
+
let t = Eb(e, a);
|
|
16241
16439
|
qr(e, {
|
|
16242
|
-
kind:
|
|
16440
|
+
kind: sb,
|
|
16243
16441
|
title: "Re-indexing memories",
|
|
16244
16442
|
message: t > 0 ? `Removed ${t} stale vector rows` : "No embeddable memories to re-index",
|
|
16245
16443
|
progressTotal: 0,
|
|
@@ -16248,7 +16446,7 @@ async function yb(e, t = {}) {
|
|
|
16248
16446
|
target_model: a,
|
|
16249
16447
|
removed_stale_rows: t
|
|
16250
16448
|
}
|
|
16251
|
-
}), Yr(e,
|
|
16449
|
+
}), Yr(e, sb, {
|
|
16252
16450
|
progressCurrent: 0,
|
|
16253
16451
|
progressTotal: 0,
|
|
16254
16452
|
metadata: {
|
|
@@ -16259,15 +16457,15 @@ async function yb(e, t = {}) {
|
|
|
16259
16457
|
});
|
|
16260
16458
|
return;
|
|
16261
16459
|
}
|
|
16262
|
-
let m = n, h =
|
|
16460
|
+
let m = n, h = Tb(m, l, a, p);
|
|
16263
16461
|
(!m || m.status === "completed" || m.status === "failed") && qr(e, {
|
|
16264
|
-
kind:
|
|
16462
|
+
kind: sb,
|
|
16265
16463
|
title: "Re-indexing memories",
|
|
16266
16464
|
message: l ? `Building ${a} vectors while semantic search falls back to FTS-only` : `Building ${a} vectors`,
|
|
16267
16465
|
progressTotal: p,
|
|
16268
16466
|
metadata: h
|
|
16269
16467
|
});
|
|
16270
|
-
let g =
|
|
16468
|
+
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
16469
|
if (_.length > 0) {
|
|
16272
16470
|
if (await ks(e, {
|
|
16273
16471
|
memoryIds: _,
|
|
@@ -16275,8 +16473,8 @@ async function yb(e, t = {}) {
|
|
|
16275
16473
|
}), t.signal?.aborted) return;
|
|
16276
16474
|
if (g.length < o) {
|
|
16277
16475
|
e.transaction(() => {
|
|
16278
|
-
let t =
|
|
16279
|
-
Yr(e,
|
|
16476
|
+
let t = Eb(e, a);
|
|
16477
|
+
Yr(e, sb, {
|
|
16280
16478
|
message: t > 0 ? `Finished re-indexing and removed ${t} stale vector rows` : "Finished re-indexing memories",
|
|
16281
16479
|
progressCurrent: b,
|
|
16282
16480
|
progressTotal: p,
|
|
@@ -16291,7 +16489,7 @@ async function yb(e, t = {}) {
|
|
|
16291
16489
|
})();
|
|
16292
16490
|
return;
|
|
16293
16491
|
}
|
|
16294
|
-
Jr(e,
|
|
16492
|
+
Jr(e, sb, {
|
|
16295
16493
|
message: `Re-indexed ${b} of ${p} memories`,
|
|
16296
16494
|
progressCurrent: b,
|
|
16297
16495
|
progressTotal: p,
|
|
@@ -16305,8 +16503,8 @@ async function yb(e, t = {}) {
|
|
|
16305
16503
|
return;
|
|
16306
16504
|
}
|
|
16307
16505
|
h.last_cursor_id && h.last_cursor_id > 0 && e.transaction(() => {
|
|
16308
|
-
let t =
|
|
16309
|
-
Yr(e,
|
|
16506
|
+
let t = Eb(e, a);
|
|
16507
|
+
Yr(e, sb, {
|
|
16310
16508
|
message: t > 0 ? `Finished re-indexing and removed ${t} stale vector rows` : "Finished re-indexing memories",
|
|
16311
16509
|
progressCurrent: p,
|
|
16312
16510
|
progressTotal: p,
|
|
@@ -16319,7 +16517,7 @@ async function yb(e, t = {}) {
|
|
|
16319
16517
|
});
|
|
16320
16518
|
})();
|
|
16321
16519
|
}
|
|
16322
|
-
var
|
|
16520
|
+
var kb = class {
|
|
16323
16521
|
dbPath;
|
|
16324
16522
|
signal;
|
|
16325
16523
|
batchSize;
|
|
@@ -16330,13 +16528,13 @@ var bb = class {
|
|
|
16330
16528
|
currentRun = null;
|
|
16331
16529
|
lastTickWasIdle = !1;
|
|
16332
16530
|
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 ??
|
|
16531
|
+
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
16532
|
}
|
|
16335
16533
|
start() {
|
|
16336
|
-
this.active || (this.active = !0, this.lastTickWasIdle = !1,
|
|
16534
|
+
this.active || (this.active = !0, this.lastTickWasIdle = !1, db = this, this.schedule(100));
|
|
16337
16535
|
}
|
|
16338
16536
|
async stop() {
|
|
16339
|
-
this.active = !1,
|
|
16537
|
+
this.active = !1, db === this && (db = null), this.timer &&= (clearTimeout(this.timer), null), this.currentRun && await this.currentRun;
|
|
16340
16538
|
}
|
|
16341
16539
|
wake() {
|
|
16342
16540
|
this.active && (this.lastTickWasIdle = !1, this.timer && (clearTimeout(this.timer), this.timer = null, this.schedule(100)));
|
|
@@ -16356,28 +16554,28 @@ var bb = class {
|
|
|
16356
16554
|
if (!this.active || this.signal?.aborted) return;
|
|
16357
16555
|
let e = null;
|
|
16358
16556
|
try {
|
|
16359
|
-
e = Mn(this.dbPath), In(e), await
|
|
16557
|
+
e = Mn(this.dbPath), In(e), await Ob(e, {
|
|
16360
16558
|
batchSize: this.batchSize,
|
|
16361
16559
|
signal: this.signal
|
|
16362
16560
|
}), this.lastTickWasIdle = this.computeIdle(e);
|
|
16363
16561
|
} catch (t) {
|
|
16364
|
-
e && Xr(e,
|
|
16562
|
+
e && Xr(e, sb, t instanceof Error ? t.message : String(t)), this.lastTickWasIdle = !0, console.warn("Vector migration runner failed", t);
|
|
16365
16563
|
} finally {
|
|
16366
16564
|
e?.close();
|
|
16367
16565
|
}
|
|
16368
16566
|
}
|
|
16369
16567
|
computeIdle(e) {
|
|
16370
16568
|
if (Ln()) return !0;
|
|
16371
|
-
let t = Q(e,
|
|
16569
|
+
let t = Q(e, sb);
|
|
16372
16570
|
if (t) {
|
|
16373
16571
|
if (t.status === "running" || t.status === "pending") return !1;
|
|
16374
16572
|
let e = t.metadata ?? {};
|
|
16375
|
-
return !(
|
|
16573
|
+
return !(pb(e.pending_upsert_memory_ids).length + pb(e.pending_delete_memory_ids).length > 0);
|
|
16376
16574
|
}
|
|
16377
16575
|
let n = $o();
|
|
16378
16576
|
try {
|
|
16379
16577
|
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 :
|
|
16578
|
+
return Number(t?.c ?? 0) > 0 ? !1 : Db(e, n) === null;
|
|
16381
16579
|
} catch (e) {
|
|
16382
16580
|
return console.warn("Vector migration runner idle peek failed", e), !1;
|
|
16383
16581
|
}
|
|
@@ -16385,7 +16583,7 @@ var bb = class {
|
|
|
16385
16583
|
};
|
|
16386
16584
|
//#endregion
|
|
16387
16585
|
//#region src/sync-bootstrap.ts
|
|
16388
|
-
async function
|
|
16586
|
+
async function Ab(e, t, n, r) {
|
|
16389
16587
|
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
16588
|
for (;;) {
|
|
16391
16589
|
let r = new URLSearchParams({
|
|
@@ -16404,7 +16602,7 @@ async function xb(e, t, n, r) {
|
|
|
16404
16602
|
bootstrapGrantId: s,
|
|
16405
16603
|
keysDir: o
|
|
16406
16604
|
}),
|
|
16407
|
-
[
|
|
16605
|
+
[nb]: rb
|
|
16408
16606
|
},
|
|
16409
16607
|
timeoutS: a
|
|
16410
16608
|
});
|
|
@@ -16428,7 +16626,7 @@ async function xb(e, t, n, r) {
|
|
|
16428
16626
|
...d
|
|
16429
16627
|
};
|
|
16430
16628
|
}
|
|
16431
|
-
function
|
|
16629
|
+
function jb(e) {
|
|
16432
16630
|
if (!e.payload_json) return null;
|
|
16433
16631
|
try {
|
|
16434
16632
|
let t = JSON.parse(e.payload_json);
|
|
@@ -16437,23 +16635,23 @@ function Sb(e) {
|
|
|
16437
16635
|
return null;
|
|
16438
16636
|
}
|
|
16439
16637
|
}
|
|
16440
|
-
function
|
|
16638
|
+
function Mb(e) {
|
|
16441
16639
|
return `${typeof e.title == "string" ? e.title : ""}\n${typeof e.body_text == "string" ? e.body_text : ""}`.trim().length > 0;
|
|
16442
16640
|
}
|
|
16443
|
-
function
|
|
16641
|
+
function Nb(e) {
|
|
16444
16642
|
if (typeof e != "string") return null;
|
|
16445
16643
|
let t = e.trim();
|
|
16446
16644
|
return t.length > 0 ? t : null;
|
|
16447
16645
|
}
|
|
16448
|
-
function
|
|
16449
|
-
return t ||
|
|
16646
|
+
function Pb(e, t) {
|
|
16647
|
+
return t || Nb(e.scope_id);
|
|
16450
16648
|
}
|
|
16451
|
-
var
|
|
16452
|
-
function
|
|
16453
|
-
let r = n ?? "__none__", i =
|
|
16649
|
+
var Fb = /* @__PURE__ */ new Map();
|
|
16650
|
+
function Ib(e, t, n) {
|
|
16651
|
+
let r = n ?? "__none__", i = Fb.get(r);
|
|
16454
16652
|
if (i != null) return i;
|
|
16455
16653
|
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
|
|
16654
|
+
if (o) return Fb.set(r, o.id), o.id;
|
|
16457
16655
|
let s = e.insert(U).values({
|
|
16458
16656
|
started_at: t,
|
|
16459
16657
|
cwd: a,
|
|
@@ -16461,25 +16659,25 @@ function Db(e, t, n) {
|
|
|
16461
16659
|
user: "sync",
|
|
16462
16660
|
tool_version: "bootstrap"
|
|
16463
16661
|
}).returning({ id: U.id }).all()[0]?.id ?? 0;
|
|
16464
|
-
return
|
|
16662
|
+
return Fb.set(r, s), s;
|
|
16465
16663
|
}
|
|
16466
|
-
function
|
|
16664
|
+
function Lb(e, t, n, r, i) {
|
|
16467
16665
|
let a = {
|
|
16468
16666
|
ok: !1,
|
|
16469
16667
|
applied: 0,
|
|
16470
16668
|
deleted: 0
|
|
16471
|
-
}, o = i ?? new dl(), s =
|
|
16669
|
+
}, 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
16670
|
return e.transaction(() => {
|
|
16473
16671
|
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,
|
|
16672
|
+
a.deleted = i.delete(W).where(O(fe(W.import_key), c, _e(M`COALESCE(${W.visibility}, '')`, "private"))).run().changes, Fb.clear();
|
|
16475
16673
|
for (let e of n) {
|
|
16476
|
-
let t =
|
|
16674
|
+
let t = jb(e);
|
|
16477
16675
|
if (!t) continue;
|
|
16478
16676
|
gl(t, o);
|
|
16479
|
-
let n =
|
|
16677
|
+
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
16678
|
d.clock_device_id = e.clock_device_id;
|
|
16481
16679
|
let f = e.op_type === "delete";
|
|
16482
|
-
!f &&
|
|
16680
|
+
!f && Mb(t) && l++, i.insert(W).values({
|
|
16483
16681
|
session_id: c,
|
|
16484
16682
|
kind: typeof t.kind == "string" ? t.kind : "discovery",
|
|
16485
16683
|
title: typeof t.title == "string" ? t.title : "",
|
|
@@ -16516,16 +16714,16 @@ function Ob(e, t, n, r, i) {
|
|
|
16516
16714
|
generation: r.generation,
|
|
16517
16715
|
snapshot_id: r.snapshot_id,
|
|
16518
16716
|
baseline_cursor: r.baseline_cursor
|
|
16519
|
-
}, r.scope_id),
|
|
16717
|
+
}, r.scope_id), bb(e, { embeddableTotal: l }), a.ok = !0;
|
|
16520
16718
|
}).immediate(), a;
|
|
16521
16719
|
}
|
|
16522
16720
|
//#endregion
|
|
16523
16721
|
//#region src/sync-discovery.ts
|
|
16524
|
-
var
|
|
16525
|
-
function
|
|
16722
|
+
var Rb = Ee(import.meta.url), zb = "_codemem._tcp.local.";
|
|
16723
|
+
function Bb(e) {
|
|
16526
16724
|
return e.mdns.length === 0 ? yl(e.stored, []) : yl(e.mdns, e.stored);
|
|
16527
16725
|
}
|
|
16528
|
-
function
|
|
16726
|
+
function Vb(e, t) {
|
|
16529
16727
|
let n = N(e, { schema: H }).select({ addresses_json: Y.addresses_json }).from(Y).where(k(Y.peer_device_id, t)).get();
|
|
16530
16728
|
if (!n?.addresses_json) return [];
|
|
16531
16729
|
try {
|
|
@@ -16535,8 +16733,8 @@ function Mb(e, t) {
|
|
|
16535
16733
|
return [];
|
|
16536
16734
|
}
|
|
16537
16735
|
}
|
|
16538
|
-
function
|
|
16539
|
-
let i = yl(
|
|
16736
|
+
function Hb(e, t, n, r) {
|
|
16737
|
+
let i = yl(Vb(e, t), n), a = (/* @__PURE__ */ new Date()).toISOString(), o = JSON.stringify(i);
|
|
16540
16738
|
return N(e, { schema: H }).insert(Y).values({
|
|
16541
16739
|
peer_device_id: t,
|
|
16542
16740
|
name: r?.name ?? null,
|
|
@@ -16556,7 +16754,7 @@ function Nb(e, t, n, r) {
|
|
|
16556
16754
|
}
|
|
16557
16755
|
}).run(), i;
|
|
16558
16756
|
}
|
|
16559
|
-
function
|
|
16757
|
+
function Ub(e, t, n) {
|
|
16560
16758
|
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
16561
16759
|
r.insert(ft).values({
|
|
16562
16760
|
peer_device_id: t,
|
|
@@ -16571,10 +16769,10 @@ function Pb(e, t, n) {
|
|
|
16571
16769
|
last_error: null
|
|
16572
16770
|
}).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
16771
|
}
|
|
16574
|
-
function
|
|
16772
|
+
function Wb(e, t, n) {
|
|
16575
16773
|
let r = _l(n ?? ""), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
16576
16774
|
return e.transaction((t, n, r) => {
|
|
16577
|
-
let i =
|
|
16775
|
+
let i = Vb(e, t), a = n ? i.filter((e) => _l(e) !== n) : i, o = n ? [n, ...a] : i;
|
|
16578
16776
|
return N(e, { schema: H }).update(Y).set({
|
|
16579
16777
|
addresses_json: JSON.stringify(o),
|
|
16580
16778
|
last_sync_at: r,
|
|
@@ -16583,18 +16781,18 @@ function Fb(e, t, n) {
|
|
|
16583
16781
|
}).where(k(Y.peer_device_id, t)).run(), o;
|
|
16584
16782
|
}).immediate(t, r, i);
|
|
16585
16783
|
}
|
|
16586
|
-
function
|
|
16784
|
+
function Gb(e, t, n) {
|
|
16587
16785
|
let r = n.include === null ? null : JSON.stringify(n.include), i = n.exclude === null ? null : JSON.stringify(n.exclude);
|
|
16588
16786
|
N(e, { schema: H }).update(Y).set({
|
|
16589
16787
|
projects_include_json: r,
|
|
16590
16788
|
projects_exclude_json: i
|
|
16591
16789
|
}).where(k(Y.peer_device_id, t)).run();
|
|
16592
16790
|
}
|
|
16593
|
-
function
|
|
16791
|
+
function Kb(e, t, n) {
|
|
16594
16792
|
N(e, { schema: H }).update(Y).set({ claimed_local_actor: +!!n }).where(k(Y.peer_device_id, t)).run();
|
|
16595
16793
|
}
|
|
16596
|
-
var
|
|
16597
|
-
function
|
|
16794
|
+
var qb = "codemem";
|
|
16795
|
+
function Jb() {
|
|
16598
16796
|
let e = process.env.CODEMEM_SYNC_MDNS;
|
|
16599
16797
|
if (e) return e === "1" || e.toLowerCase() === "true";
|
|
16600
16798
|
try {
|
|
@@ -16603,9 +16801,9 @@ function zb() {
|
|
|
16603
16801
|
return !1;
|
|
16604
16802
|
}
|
|
16605
16803
|
}
|
|
16606
|
-
function
|
|
16804
|
+
function Yb() {
|
|
16607
16805
|
try {
|
|
16608
|
-
let e =
|
|
16806
|
+
let e = Rb("bonjour-service"), t = e.Bonjour ?? e.default;
|
|
16609
16807
|
return t ? new t(void 0, (e) => {
|
|
16610
16808
|
console.warn("[codemem] mDNS runtime error (non-fatal):", e?.message ?? e);
|
|
16611
16809
|
}) : null;
|
|
@@ -16613,40 +16811,40 @@ function Bb() {
|
|
|
16613
16811
|
return null;
|
|
16614
16812
|
}
|
|
16615
16813
|
}
|
|
16616
|
-
var
|
|
16617
|
-
function
|
|
16618
|
-
if (
|
|
16619
|
-
let e =
|
|
16620
|
-
return e ? (
|
|
16814
|
+
var Xb = null, Zb = 0;
|
|
16815
|
+
function Qb() {
|
|
16816
|
+
if (Xb) return Zb += 1, Xb;
|
|
16817
|
+
let e = Yb();
|
|
16818
|
+
return e ? (Xb = e, Zb = 1, Xb) : null;
|
|
16621
16819
|
}
|
|
16622
|
-
function
|
|
16623
|
-
if (!
|
|
16624
|
-
let e =
|
|
16625
|
-
|
|
16820
|
+
function $b() {
|
|
16821
|
+
if (!Xb || (Zb = Math.max(0, Zb - 1), Zb > 0)) return;
|
|
16822
|
+
let e = Xb;
|
|
16823
|
+
Xb = null;
|
|
16626
16824
|
try {
|
|
16627
16825
|
e.destroy();
|
|
16628
16826
|
} catch {}
|
|
16629
16827
|
}
|
|
16630
|
-
function
|
|
16631
|
-
if (!
|
|
16632
|
-
let n =
|
|
16828
|
+
function ex(e, t) {
|
|
16829
|
+
if (!Jb() || !e || !t || !Number.isFinite(t)) return { close() {} };
|
|
16830
|
+
let n = Qb();
|
|
16633
16831
|
if (!n) return { close() {} };
|
|
16634
16832
|
let r = null;
|
|
16635
16833
|
try {
|
|
16636
16834
|
r = n.publish({
|
|
16637
16835
|
name: `codemem-${e.slice(0, 12)}`,
|
|
16638
|
-
type:
|
|
16836
|
+
type: qb,
|
|
16639
16837
|
port: t,
|
|
16640
16838
|
txt: { device_id: e }
|
|
16641
16839
|
});
|
|
16642
16840
|
} catch {
|
|
16643
|
-
return
|
|
16841
|
+
return $b(), { close() {} };
|
|
16644
16842
|
}
|
|
16645
16843
|
let i = !1;
|
|
16646
16844
|
return { close() {
|
|
16647
16845
|
if (i) return;
|
|
16648
16846
|
i = !0;
|
|
16649
|
-
let e = () =>
|
|
16847
|
+
let e = () => $b();
|
|
16650
16848
|
try {
|
|
16651
16849
|
r?.stop(() => e());
|
|
16652
16850
|
} catch {
|
|
@@ -16654,13 +16852,13 @@ function Gb(e, t) {
|
|
|
16654
16852
|
}
|
|
16655
16853
|
} };
|
|
16656
16854
|
}
|
|
16657
|
-
async function
|
|
16658
|
-
if (!
|
|
16659
|
-
let t =
|
|
16855
|
+
async function tx(e = 1500) {
|
|
16856
|
+
if (!Jb()) return [];
|
|
16857
|
+
let t = Qb();
|
|
16660
16858
|
if (!t) return [];
|
|
16661
16859
|
let n = [], r = /* @__PURE__ */ new Set(), i = !0, a = null;
|
|
16662
16860
|
try {
|
|
16663
|
-
a = t.find({ type:
|
|
16861
|
+
a = t.find({ type: qb }, (e) => {
|
|
16664
16862
|
if (!i) return;
|
|
16665
16863
|
let t = `${e.name}|${e.host ?? e.fqdn ?? ""}|${e.port}`;
|
|
16666
16864
|
if (r.has(t)) return;
|
|
@@ -16680,11 +16878,11 @@ async function Kb(e = 1500) {
|
|
|
16680
16878
|
try {
|
|
16681
16879
|
a?.stop();
|
|
16682
16880
|
} catch {}
|
|
16683
|
-
|
|
16881
|
+
$b();
|
|
16684
16882
|
}
|
|
16685
16883
|
return n;
|
|
16686
16884
|
}
|
|
16687
|
-
function
|
|
16885
|
+
function nx(e, t) {
|
|
16688
16886
|
let n = [];
|
|
16689
16887
|
for (let r of t) {
|
|
16690
16888
|
let t = r.properties ?? {}, i = t.device_id ?? t.device_id;
|
|
@@ -16698,56 +16896,56 @@ function qb(e, t) {
|
|
|
16698
16896
|
}
|
|
16699
16897
|
//#endregion
|
|
16700
16898
|
//#region src/sync-pass.ts
|
|
16701
|
-
var
|
|
16702
|
-
function
|
|
16899
|
+
var rx = 1048576, ix = !1, ax = 500, ox = 2e3, sx = "2";
|
|
16900
|
+
function cx(e, t) {
|
|
16703
16901
|
return !t || !t.includes("|") ? !1 : e ? t > e : !0;
|
|
16704
16902
|
}
|
|
16705
|
-
function
|
|
16903
|
+
function lx(e) {
|
|
16706
16904
|
if (!e) return null;
|
|
16707
16905
|
let t = e.error, n = e.reason;
|
|
16708
16906
|
return typeof t == "string" && typeof n == "string" ? `${t}:${n}` : typeof t == "string" ? t : null;
|
|
16709
16907
|
}
|
|
16710
|
-
function
|
|
16908
|
+
function ux(e) {
|
|
16711
16909
|
return e.length === 0 ? null : `all addresses failed | ${e.map((e) => `${e.address}: ${e.error}`).join(" || ")}`;
|
|
16712
16910
|
}
|
|
16713
|
-
function
|
|
16911
|
+
function dx(e) {
|
|
16714
16912
|
if (typeof e != "string") return null;
|
|
16715
16913
|
let t = e.trim();
|
|
16716
16914
|
return t.length > 0 ? t : null;
|
|
16717
16915
|
}
|
|
16718
|
-
function
|
|
16916
|
+
function fx(e) {
|
|
16719
16917
|
let t = e?.sync_reset;
|
|
16720
16918
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
16721
16919
|
let n = t;
|
|
16722
16920
|
if (!Number.isFinite(n.generation) || typeof n.snapshot_id != "string" || n.snapshot_id.trim().length === 0) return null;
|
|
16723
|
-
let r =
|
|
16921
|
+
let r = dx(n.baseline_cursor);
|
|
16724
16922
|
return {
|
|
16725
|
-
scope_id:
|
|
16923
|
+
scope_id: dx(n.scope_id),
|
|
16726
16924
|
generation: Number(n.generation),
|
|
16727
16925
|
snapshot_id: n.snapshot_id.trim(),
|
|
16728
16926
|
baseline_cursor: r,
|
|
16729
|
-
retained_floor_cursor:
|
|
16927
|
+
retained_floor_cursor: dx(n.retained_floor_cursor)
|
|
16730
16928
|
};
|
|
16731
16929
|
}
|
|
16732
|
-
function
|
|
16930
|
+
function px(e) {
|
|
16733
16931
|
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
16932
|
}
|
|
16735
|
-
function
|
|
16736
|
-
let t =
|
|
16933
|
+
function mx(e) {
|
|
16934
|
+
let t = ab(e);
|
|
16737
16935
|
return {
|
|
16738
|
-
local:
|
|
16936
|
+
local: rb,
|
|
16739
16937
|
peer: t,
|
|
16740
|
-
negotiated:
|
|
16938
|
+
negotiated: ob(rb, t)
|
|
16741
16939
|
};
|
|
16742
16940
|
}
|
|
16743
|
-
function
|
|
16744
|
-
return { [
|
|
16941
|
+
function hx() {
|
|
16942
|
+
return { [nb]: rb };
|
|
16745
16943
|
}
|
|
16746
|
-
function
|
|
16747
|
-
return
|
|
16944
|
+
function gx() {
|
|
16945
|
+
return mx("unsupported");
|
|
16748
16946
|
}
|
|
16749
|
-
function
|
|
16750
|
-
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString(), a = n.capabilities ??
|
|
16947
|
+
function _x(e, t, n) {
|
|
16948
|
+
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString(), a = n.capabilities ?? gx();
|
|
16751
16949
|
r.insert(ft).values({
|
|
16752
16950
|
peer_device_id: t,
|
|
16753
16951
|
started_at: i,
|
|
@@ -16761,7 +16959,7 @@ function cx(e, t, n) {
|
|
|
16761
16959
|
negotiated_sync_capability: a.negotiated
|
|
16762
16960
|
}).run();
|
|
16763
16961
|
}
|
|
16764
|
-
function
|
|
16962
|
+
function vx(e, t, n, r) {
|
|
16765
16963
|
let i = N(e, { schema: H }), { replicationOps: a } = H, o;
|
|
16766
16964
|
if (t) {
|
|
16767
16965
|
let e = t.indexOf("|"), s = e >= 0 ? t.slice(0, e) : t, c = e >= 0 ? t.slice(e + 1) : "";
|
|
@@ -16773,12 +16971,12 @@ function lx(e, t, n, r) {
|
|
|
16773
16971
|
let c = `${s.created_at}|${s.op_id}`;
|
|
16774
16972
|
return [o, c];
|
|
16775
16973
|
}
|
|
16776
|
-
var
|
|
16777
|
-
async function
|
|
16974
|
+
var yx = 8;
|
|
16975
|
+
async function bx(e, t, n, r, i = 0) {
|
|
16778
16976
|
if (n.length === 0) return;
|
|
16779
16977
|
let a = {
|
|
16780
16978
|
ops: n,
|
|
16781
|
-
sync_capability:
|
|
16979
|
+
sync_capability: rb
|
|
16782
16980
|
}, o = Buffer.from(JSON.stringify(a), "utf-8"), [s, c] = await xl("POST", e, {
|
|
16783
16981
|
headers: {
|
|
16784
16982
|
..._r({
|
|
@@ -16788,28 +16986,28 @@ async function dx(e, t, n, r, i = 0) {
|
|
|
16788
16986
|
bodyBytes: o,
|
|
16789
16987
|
keysDir: r
|
|
16790
16988
|
}),
|
|
16791
|
-
...
|
|
16989
|
+
...hx()
|
|
16792
16990
|
},
|
|
16793
16991
|
body: a,
|
|
16794
16992
|
bodyBytes: o
|
|
16795
16993
|
});
|
|
16796
16994
|
if (s === 200 && c != null) return;
|
|
16797
|
-
let l =
|
|
16798
|
-
if (s === 413 && n.length > 1 && i <
|
|
16995
|
+
let l = lx(c);
|
|
16996
|
+
if (s === 413 && n.length > 1 && i < yx && (l === "payload_too_large" || l === "too_many_ops")) {
|
|
16799
16997
|
let a = Math.floor(n.length / 2);
|
|
16800
|
-
await
|
|
16998
|
+
await bx(e, t, n.slice(0, a), r, i + 1), await bx(e, t, n.slice(a), r, i + 1);
|
|
16801
16999
|
return;
|
|
16802
17000
|
}
|
|
16803
17001
|
let u = l ? ` (${s}: ${l})` : ` (${s})`;
|
|
16804
17002
|
throw Error(`peer ops push failed${u}`);
|
|
16805
17003
|
}
|
|
16806
|
-
function
|
|
17004
|
+
function xx(e) {
|
|
16807
17005
|
Hn(e), qd(e, 2e3), Jd(e, 200);
|
|
16808
17006
|
}
|
|
16809
|
-
async function
|
|
17007
|
+
async function Sx(e, t, n, r) {
|
|
16810
17008
|
Hn(e);
|
|
16811
|
-
let i = r?.limit ??
|
|
16812
|
-
!o && !
|
|
17009
|
+
let i = r?.limit ?? ax, a = r?.keysDir, o = r?.scanner;
|
|
17010
|
+
!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
17011
|
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
17012
|
if (!s) return {
|
|
16815
17013
|
ok: !1,
|
|
@@ -16823,7 +17021,7 @@ async function px(e, t, n, r) {
|
|
|
16823
17021
|
[u] = dr(e, { keysDir: a });
|
|
16824
17022
|
} catch (n) {
|
|
16825
17023
|
let r = `device identity unavailable: ${n instanceof Error ? n.message.trim() || n.constructor.name : "unknown"}`;
|
|
16826
|
-
return
|
|
17024
|
+
return _x(e, t, {
|
|
16827
17025
|
ok: !1,
|
|
16828
17026
|
error: r
|
|
16829
17027
|
}), {
|
|
@@ -16848,15 +17046,15 @@ async function px(e, t, n, r) {
|
|
|
16848
17046
|
bodyBytes: Buffer.alloc(0),
|
|
16849
17047
|
keysDir: a
|
|
16850
17048
|
}),
|
|
16851
|
-
...
|
|
17049
|
+
...hx()
|
|
16852
17050
|
} });
|
|
16853
17051
|
if (d !== 200 || !f) {
|
|
16854
|
-
let e =
|
|
17052
|
+
let e = lx(f), t = e ? ` (${d}: ${e})` : ` (${d})`;
|
|
16855
17053
|
throw Error(`peer status failed${t}`);
|
|
16856
17054
|
}
|
|
16857
17055
|
if (f.fingerprint !== s) throw Error("peer fingerprint mismatch");
|
|
16858
|
-
if (p =
|
|
16859
|
-
let m =
|
|
17056
|
+
if (p = mx(f.sync_capability), String(f.protocol_version ?? "") !== sx) throw Error(`peer protocol mismatch (expected ${sx}, got ${String(f.protocol_version ?? "missing")})`);
|
|
17057
|
+
let m = fx(f);
|
|
16860
17058
|
if (!m) throw Error("peer status missing sync_reset boundary");
|
|
16861
17059
|
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
17060
|
let r = {
|
|
@@ -16867,11 +17065,11 @@ async function px(e, t, n, r) {
|
|
|
16867
17065
|
retained_floor_cursor: m.retained_floor_cursor ?? null,
|
|
16868
17066
|
reset_required: !0,
|
|
16869
17067
|
reason: "initial_bootstrap"
|
|
16870
|
-
}, { items: i } = await
|
|
17068
|
+
}, { items: i } = await Ab(n, r, u, {
|
|
16871
17069
|
keysDir: a,
|
|
16872
|
-
pageSize:
|
|
17070
|
+
pageSize: ox
|
|
16873
17071
|
}), 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
|
|
17072
|
+
if (s > 0) return _x(e, t, {
|
|
16875
17073
|
ok: !1,
|
|
16876
17074
|
error: "needs_attention:shared_memories_appeared_during_bootstrap",
|
|
16877
17075
|
capabilities: p
|
|
@@ -16883,9 +17081,9 @@ async function px(e, t, n, r) {
|
|
|
16883
17081
|
opsOut: 0,
|
|
16884
17082
|
addressErrors: []
|
|
16885
17083
|
};
|
|
16886
|
-
let c =
|
|
17084
|
+
let c = Lb(e, t, i, r, o);
|
|
16887
17085
|
if (!c.ok) throw Error("initial bootstrap apply failed");
|
|
16888
|
-
return
|
|
17086
|
+
return Wb(e, t, n), _x(e, t, {
|
|
16889
17087
|
ok: !0,
|
|
16890
17088
|
opsIn: c.applied,
|
|
16891
17089
|
opsOut: 0,
|
|
@@ -16916,7 +17114,7 @@ async function px(e, t, n, r) {
|
|
|
16916
17114
|
bodyBytes: Buffer.alloc(0),
|
|
16917
17115
|
keysDir: a
|
|
16918
17116
|
}),
|
|
16919
|
-
...
|
|
17117
|
+
...hx()
|
|
16920
17118
|
} });
|
|
16921
17119
|
if (_ === 409 && v?.reset_required === !0) {
|
|
16922
17120
|
let r = ad(e), i = {
|
|
@@ -16928,7 +17126,7 @@ async function px(e, t, n, r) {
|
|
|
16928
17126
|
baseline_cursor: typeof v.baseline_cursor == "string" && v.baseline_cursor.trim() ? v.baseline_cursor.trim() : null,
|
|
16929
17127
|
retained_floor_cursor: typeof v.retained_floor_cursor == "string" && v.retained_floor_cursor.trim() ? v.retained_floor_cursor.trim() : null
|
|
16930
17128
|
};
|
|
16931
|
-
if (r.dirty) return
|
|
17129
|
+
if (r.dirty) return _x(e, t, {
|
|
16932
17130
|
ok: !1,
|
|
16933
17131
|
error: `needs_attention:local_unsynced_shared_memory:${r.count}`,
|
|
16934
17132
|
capabilities: p
|
|
@@ -16942,8 +17140,8 @@ async function px(e, t, n, r) {
|
|
|
16942
17140
|
resetRequired: i
|
|
16943
17141
|
};
|
|
16944
17142
|
try {
|
|
16945
|
-
let { items: r } = await
|
|
16946
|
-
if (s.dirty) return
|
|
17143
|
+
let { items: r } = await Ab(n, i, u, { keysDir: a }), s = ad(e);
|
|
17144
|
+
if (s.dirty) return _x(e, t, {
|
|
16947
17145
|
ok: !1,
|
|
16948
17146
|
error: `needs_attention:local_unsynced_shared_memory:${s.count}`,
|
|
16949
17147
|
capabilities: p
|
|
@@ -16956,9 +17154,9 @@ async function px(e, t, n, r) {
|
|
|
16956
17154
|
addressErrors: [],
|
|
16957
17155
|
resetRequired: i
|
|
16958
17156
|
};
|
|
16959
|
-
let c =
|
|
17157
|
+
let c = Lb(e, t, r, i, o);
|
|
16960
17158
|
if (!c.ok) throw Error("bootstrap apply failed");
|
|
16961
|
-
return
|
|
17159
|
+
return Wb(e, t, n), _x(e, t, {
|
|
16962
17160
|
ok: !0,
|
|
16963
17161
|
opsIn: c.applied,
|
|
16964
17162
|
opsOut: 0,
|
|
@@ -16972,7 +17170,7 @@ async function px(e, t, n, r) {
|
|
|
16972
17170
|
};
|
|
16973
17171
|
} catch (r) {
|
|
16974
17172
|
let a = r instanceof Error ? r.message : String(r);
|
|
16975
|
-
return
|
|
17173
|
+
return _x(e, t, {
|
|
16976
17174
|
ok: !1,
|
|
16977
17175
|
error: `bootstrap_failed:${a}`,
|
|
16978
17176
|
capabilities: p
|
|
@@ -16988,10 +17186,10 @@ async function px(e, t, n, r) {
|
|
|
16988
17186
|
}
|
|
16989
17187
|
}
|
|
16990
17188
|
if (_ !== 200 || v == null) {
|
|
16991
|
-
let e =
|
|
17189
|
+
let e = lx(v), t = e ? ` (${_}: ${e})` : ` (${_})`;
|
|
16992
17190
|
throw Error(`peer ops fetch failed${t}`);
|
|
16993
17191
|
}
|
|
16994
|
-
if (!
|
|
17192
|
+
if (!px(v)) throw Error("invalid ops response");
|
|
16995
17193
|
let y = Xu(v), b = y.find((e) => e.device_id !== t || e.clock_device_id !== t);
|
|
16996
17194
|
if (b) throw Error(`inbound op device mismatch:${b.op_id}`);
|
|
16997
17195
|
let x = p?.negotiated === "unsupported" ? {
|
|
@@ -17003,7 +17201,7 @@ async function px(e, t, n, r) {
|
|
|
17003
17201
|
throw Error(`inbound scope rejected:${e}`);
|
|
17004
17202
|
}
|
|
17005
17203
|
try {
|
|
17006
|
-
|
|
17204
|
+
vb(e, S.vectorWork);
|
|
17007
17205
|
} catch (t) {
|
|
17008
17206
|
let n = await Ds(e, S.vectorWork);
|
|
17009
17207
|
if (n.errors.length > 0) {
|
|
@@ -17011,15 +17209,15 @@ async function px(e, t, n, r) {
|
|
|
17011
17209
|
throw Error(`vector catch-up queue failed: ${t instanceof Error ? t.message : String(t)}; fallback failed: ${e}`);
|
|
17012
17210
|
}
|
|
17013
17211
|
}
|
|
17014
|
-
let C =
|
|
17015
|
-
|
|
17016
|
-
let [w, ee] =
|
|
17212
|
+
let C = dx(v.next_cursor);
|
|
17213
|
+
cx(c, C) && (Ju(e, t, { lastApplied: C }), c = C);
|
|
17214
|
+
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
17215
|
if (T.length > 0) {
|
|
17018
|
-
let e = Uu(T,
|
|
17019
|
-
for (let t of e) await
|
|
17216
|
+
let e = Uu(T, rx);
|
|
17217
|
+
for (let t of e) await bx(ie, u, t, a);
|
|
17020
17218
|
}
|
|
17021
17219
|
let ae = te ?? ee;
|
|
17022
|
-
return ae &&
|
|
17220
|
+
return ae && cx(l, ae) && (Ju(e, t, { lastAcked: ae }), l = ae), Wb(e, t, n), _x(e, t, {
|
|
17023
17221
|
ok: !0,
|
|
17024
17222
|
opsIn: S.applied,
|
|
17025
17223
|
opsOut: T.length,
|
|
@@ -17042,8 +17240,8 @@ async function px(e, t, n, r) {
|
|
|
17042
17240
|
}
|
|
17043
17241
|
}
|
|
17044
17242
|
}
|
|
17045
|
-
let m =
|
|
17046
|
-
return f || (m = "no dialable peer addresses"), m ||= "sync failed without diagnostic detail",
|
|
17243
|
+
let m = ux(d);
|
|
17244
|
+
return f || (m = "no dialable peer addresses"), m ||= "sync failed without diagnostic detail", _x(e, t, {
|
|
17047
17245
|
ok: !1,
|
|
17048
17246
|
error: m,
|
|
17049
17247
|
capabilities: p
|
|
@@ -17055,15 +17253,15 @@ async function px(e, t, n, r) {
|
|
|
17055
17253
|
addressErrors: d
|
|
17056
17254
|
};
|
|
17057
17255
|
}
|
|
17058
|
-
async function
|
|
17256
|
+
async function Cx(e, t, n) {
|
|
17059
17257
|
let r = N(e, { schema: H }).select({ addresses_json: Y.addresses_json }).from(Y).where(k(Y.peer_device_id, t)).get(), i = [];
|
|
17060
17258
|
if (r?.addresses_json) try {
|
|
17061
17259
|
let e = JSON.parse(r.addresses_json);
|
|
17062
17260
|
Array.isArray(e) && (i = e.filter((e) => typeof e == "string"));
|
|
17063
17261
|
} catch {}
|
|
17064
|
-
return
|
|
17262
|
+
return Sx(e, t, i, n);
|
|
17065
17263
|
}
|
|
17066
|
-
var
|
|
17264
|
+
var wx = [
|
|
17067
17265
|
"no route to host",
|
|
17068
17266
|
"connection refused",
|
|
17069
17267
|
"network is unreachable",
|
|
@@ -17074,33 +17272,33 @@ var hx = [
|
|
|
17074
17272
|
"errno 61",
|
|
17075
17273
|
"errno 60",
|
|
17076
17274
|
"errno 111"
|
|
17077
|
-
],
|
|
17078
|
-
function
|
|
17275
|
+
], Tx = 120, Ex = 1800;
|
|
17276
|
+
function Dx(e) {
|
|
17079
17277
|
if (!e) return !1;
|
|
17080
17278
|
let t = e.toLowerCase();
|
|
17081
|
-
return
|
|
17279
|
+
return wx.some((e) => t.includes(e));
|
|
17082
17280
|
}
|
|
17083
|
-
function
|
|
17281
|
+
function Ox(e, t, n = 10) {
|
|
17084
17282
|
let r = N(e, { schema: H }).select({
|
|
17085
17283
|
ok: ft.ok,
|
|
17086
17284
|
error: ft.error
|
|
17087
17285
|
}).from(ft).where(k(ft.peer_device_id, t)).orderBy(ue(ft.started_at)).limit(n).all(), i = 0;
|
|
17088
17286
|
for (let e of r) {
|
|
17089
17287
|
if (e.ok) break;
|
|
17090
|
-
if (
|
|
17288
|
+
if (Dx(e.error)) i++;
|
|
17091
17289
|
else break;
|
|
17092
17290
|
}
|
|
17093
17291
|
return i;
|
|
17094
17292
|
}
|
|
17095
|
-
function
|
|
17293
|
+
function kx(e) {
|
|
17096
17294
|
if (e <= 1) return 0;
|
|
17097
17295
|
let t = Math.min(e - 1, 8);
|
|
17098
|
-
return Math.min(
|
|
17296
|
+
return Math.min(Tx * 2 ** (t - 1), Ex) * (.5 + Math.random() * .5);
|
|
17099
17297
|
}
|
|
17100
|
-
function
|
|
17101
|
-
let n =
|
|
17298
|
+
function Ax(e, t) {
|
|
17299
|
+
let n = Ox(e, t);
|
|
17102
17300
|
if (n < 2) return !1;
|
|
17103
|
-
let r =
|
|
17301
|
+
let r = kx(n);
|
|
17104
17302
|
if (r <= 0) return !1;
|
|
17105
17303
|
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
17304
|
if (!i?.started_at) return !1;
|
|
@@ -17113,7 +17311,7 @@ function xx(e, t) {
|
|
|
17113
17311
|
}
|
|
17114
17312
|
//#endregion
|
|
17115
17313
|
//#region src/sync-daemon.ts
|
|
17116
|
-
function
|
|
17314
|
+
function jx(e) {
|
|
17117
17315
|
let t = N(e, { schema: H }), n = (/* @__PURE__ */ new Date()).toISOString();
|
|
17118
17316
|
t.insert(mt).values({
|
|
17119
17317
|
id: 1,
|
|
@@ -17127,7 +17325,7 @@ function Sx(e) {
|
|
|
17127
17325
|
}
|
|
17128
17326
|
}).run();
|
|
17129
17327
|
}
|
|
17130
|
-
function
|
|
17328
|
+
function Mx(e, t, n) {
|
|
17131
17329
|
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
17132
17330
|
r.insert(mt).values({
|
|
17133
17331
|
id: 1,
|
|
@@ -17143,11 +17341,11 @@ function Cx(e, t, n) {
|
|
|
17143
17341
|
}
|
|
17144
17342
|
}).run();
|
|
17145
17343
|
}
|
|
17146
|
-
function
|
|
17344
|
+
function Nx(e) {
|
|
17147
17345
|
let t = N(e, { schema: H }).select({ phase: mt.phase }).from(mt).where(k(mt.id, 1)).get()?.phase;
|
|
17148
17346
|
return t === "needs_attention" ? t : null;
|
|
17149
17347
|
}
|
|
17150
|
-
function
|
|
17348
|
+
function Px(e, t) {
|
|
17151
17349
|
N(e, { schema: H }).insert(mt).values({
|
|
17152
17350
|
id: 1,
|
|
17153
17351
|
phase: t
|
|
@@ -17156,18 +17354,18 @@ function Tx(e, t) {
|
|
|
17156
17354
|
set: { phase: t }
|
|
17157
17355
|
}).run();
|
|
17158
17356
|
}
|
|
17159
|
-
async function
|
|
17357
|
+
async function Fx(e, t, n) {
|
|
17160
17358
|
let r = Al();
|
|
17161
17359
|
return jl(r) ? (await Nl({
|
|
17162
17360
|
db: e,
|
|
17163
17361
|
dbPath: t
|
|
17164
17362
|
}, r, { keysDir: n }), await hu(e, r), !0) : !1;
|
|
17165
17363
|
}
|
|
17166
|
-
async function
|
|
17364
|
+
async function Ix(e, t, n, r) {
|
|
17167
17365
|
let i = N(e, { schema: H }).select({ peer_device_id: Y.peer_device_id }).from(Y).all();
|
|
17168
17366
|
if (i.length === 0) return [];
|
|
17169
17367
|
let a = Al().syncOpsLimit;
|
|
17170
|
-
|
|
17368
|
+
xx(e);
|
|
17171
17369
|
let o = [];
|
|
17172
17370
|
for (let s of i) {
|
|
17173
17371
|
let i = s.peer_device_id;
|
|
@@ -17179,7 +17377,7 @@ async function Dx(e, t, n, r) {
|
|
|
17179
17377
|
});
|
|
17180
17378
|
continue;
|
|
17181
17379
|
}
|
|
17182
|
-
if (
|
|
17380
|
+
if (Ax(e, i)) {
|
|
17183
17381
|
o.push({
|
|
17184
17382
|
ok: !1,
|
|
17185
17383
|
skipped: !0,
|
|
@@ -17187,7 +17385,7 @@ async function Dx(e, t, n, r) {
|
|
|
17187
17385
|
});
|
|
17188
17386
|
continue;
|
|
17189
17387
|
}
|
|
17190
|
-
let c = await
|
|
17388
|
+
let c = await Cx(e, i, {
|
|
17191
17389
|
keysDir: t,
|
|
17192
17390
|
limit: a,
|
|
17193
17391
|
scanner: r
|
|
@@ -17201,13 +17399,13 @@ async function Dx(e, t, n, r) {
|
|
|
17201
17399
|
}
|
|
17202
17400
|
return o;
|
|
17203
17401
|
}
|
|
17204
|
-
async function
|
|
17402
|
+
async function Lx(e) {
|
|
17205
17403
|
let t = e?.intervalS ?? 120, n = Dn(e?.dbPath), r = e?.keysDir, i = e?.signal, a = e?.onPhaseChange, o = e?.scanner;
|
|
17206
17404
|
a?.("starting");
|
|
17207
17405
|
let s = Mn(n), c = null;
|
|
17208
17406
|
try {
|
|
17209
17407
|
let [t] = dr(s, { keysDir: r });
|
|
17210
|
-
|
|
17408
|
+
Jb() && e?.port && (c = ex(t, e.port));
|
|
17211
17409
|
} finally {
|
|
17212
17410
|
s.close();
|
|
17213
17411
|
}
|
|
@@ -17217,7 +17415,7 @@ async function Ox(e) {
|
|
|
17217
17415
|
}
|
|
17218
17416
|
return new Promise((e) => {
|
|
17219
17417
|
let s = !1, l = !1, u = () => {
|
|
17220
|
-
s || (s = !0,
|
|
17418
|
+
s || (s = !0, Rx(n, r, o).finally(() => {
|
|
17221
17419
|
s = !1, l || (l = !0, a?.("running"));
|
|
17222
17420
|
}));
|
|
17223
17421
|
}, d = setInterval(u, t * 1e3);
|
|
@@ -17234,38 +17432,38 @@ async function Ox(e) {
|
|
|
17234
17432
|
}
|
|
17235
17433
|
});
|
|
17236
17434
|
}
|
|
17237
|
-
async function
|
|
17435
|
+
async function Rx(e, t, n) {
|
|
17238
17436
|
let r = Mn(e);
|
|
17239
17437
|
try {
|
|
17240
17438
|
Hn(r);
|
|
17241
17439
|
try {
|
|
17242
|
-
await
|
|
17440
|
+
await Fx(r, e, t);
|
|
17243
17441
|
} catch {}
|
|
17244
|
-
(await
|
|
17442
|
+
(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
17443
|
} catch (e) {
|
|
17246
|
-
|
|
17444
|
+
Mx(r, e instanceof Error ? e.message : String(e), e instanceof Error ? e.stack ?? "" : "");
|
|
17247
17445
|
} finally {
|
|
17248
17446
|
r.close();
|
|
17249
17447
|
}
|
|
17250
17448
|
}
|
|
17251
17449
|
//#endregion
|
|
17252
17450
|
//#region src/sync-retention-runner.ts
|
|
17253
|
-
function
|
|
17451
|
+
function zx(e) {
|
|
17254
17452
|
let t = String(e ?? "").trim();
|
|
17255
17453
|
return t.length > 0 ? t : Su;
|
|
17256
17454
|
}
|
|
17257
|
-
function
|
|
17455
|
+
function Bx(e) {
|
|
17258
17456
|
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
17457
|
}
|
|
17260
|
-
function
|
|
17458
|
+
function Vx(e) {
|
|
17261
17459
|
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
17460
|
for (let e of t) {
|
|
17263
|
-
let t =
|
|
17461
|
+
let t = zx(e.scope_id);
|
|
17264
17462
|
n.add(t);
|
|
17265
17463
|
}
|
|
17266
17464
|
return Array.from(n);
|
|
17267
17465
|
}
|
|
17268
|
-
function
|
|
17466
|
+
function Hx(e, t, n, r) {
|
|
17269
17467
|
e.insert(vt).values({
|
|
17270
17468
|
scope_id: t,
|
|
17271
17469
|
...n
|
|
@@ -17280,7 +17478,7 @@ function Nx(e, t, n, r) {
|
|
|
17280
17478
|
set: n
|
|
17281
17479
|
}).run();
|
|
17282
17480
|
}
|
|
17283
|
-
function
|
|
17481
|
+
function Ux(e, t, n, r, i) {
|
|
17284
17482
|
let a = i === Su;
|
|
17285
17483
|
try {
|
|
17286
17484
|
let o = dd(e, i), s = sd(e, {
|
|
@@ -17292,7 +17490,7 @@ function Px(e, t, n, r, i) {
|
|
|
17292
17490
|
maxPasses: n.maxCatchUpPasses,
|
|
17293
17491
|
signal: n.signal
|
|
17294
17492
|
});
|
|
17295
|
-
|
|
17493
|
+
Hx(t, i, {
|
|
17296
17494
|
last_run_at: r,
|
|
17297
17495
|
last_duration_ms: Date.now() - Date.parse(r),
|
|
17298
17496
|
last_deleted_ops: s.totalDeleted,
|
|
@@ -17303,7 +17501,7 @@ function Px(e, t, n, r, i) {
|
|
|
17303
17501
|
last_error_at: null
|
|
17304
17502
|
}, a);
|
|
17305
17503
|
} catch (e) {
|
|
17306
|
-
|
|
17504
|
+
Hx(t, i, {
|
|
17307
17505
|
last_run_at: r,
|
|
17308
17506
|
last_duration_ms: Date.now() - Date.parse(r),
|
|
17309
17507
|
last_deleted_ops: 0,
|
|
@@ -17315,13 +17513,13 @@ function Px(e, t, n, r, i) {
|
|
|
17315
17513
|
}, a);
|
|
17316
17514
|
}
|
|
17317
17515
|
}
|
|
17318
|
-
async function
|
|
17516
|
+
async function Wx(e, t) {
|
|
17319
17517
|
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)
|
|
17518
|
+
Bx(e);
|
|
17519
|
+
let n = N(e, { schema: H }), r = (/* @__PURE__ */ new Date()).toISOString(), i = t.scopeId === void 0 ? Vx(e) : [zx(t.scopeId)];
|
|
17520
|
+
for (let a of i) Ux(e, n, t, r, a);
|
|
17323
17521
|
}
|
|
17324
|
-
var
|
|
17522
|
+
var Gx = class {
|
|
17325
17523
|
dbPath;
|
|
17326
17524
|
signal;
|
|
17327
17525
|
active = !1;
|
|
@@ -17349,7 +17547,7 @@ var Ix = class {
|
|
|
17349
17547
|
if (!this.active || this.signal?.aborted) return;
|
|
17350
17548
|
let e = Al(Rt()), t = Mn(this.dbPath);
|
|
17351
17549
|
try {
|
|
17352
|
-
await
|
|
17550
|
+
await Wx(t, {
|
|
17353
17551
|
...e,
|
|
17354
17552
|
signal: this.signal
|
|
17355
17553
|
});
|
|
@@ -17357,8 +17555,8 @@ var Ix = class {
|
|
|
17357
17555
|
t.close();
|
|
17358
17556
|
}
|
|
17359
17557
|
}
|
|
17360
|
-
},
|
|
17361
|
-
function
|
|
17558
|
+
}, Kx = "scope_id";
|
|
17559
|
+
function qx(e, t) {
|
|
17362
17560
|
return t ? typeof e == "string" && e.trim() ? {
|
|
17363
17561
|
ok: !1,
|
|
17364
17562
|
reason: "unsupported_scope"
|
|
@@ -17371,31 +17569,31 @@ function Rx(e, t) {
|
|
|
17371
17569
|
scope_id: null
|
|
17372
17570
|
};
|
|
17373
17571
|
}
|
|
17374
|
-
function
|
|
17572
|
+
function Jx(e, t) {
|
|
17375
17573
|
return {
|
|
17376
17574
|
...e,
|
|
17377
17575
|
scope_id: t
|
|
17378
17576
|
};
|
|
17379
17577
|
}
|
|
17380
|
-
function
|
|
17578
|
+
function Yx(e, t, n) {
|
|
17381
17579
|
return {
|
|
17382
17580
|
error: "reset_required",
|
|
17383
17581
|
reset_required: !0,
|
|
17384
17582
|
sync_capability: n,
|
|
17385
17583
|
reason: t,
|
|
17386
|
-
...
|
|
17584
|
+
...Jx(e, null)
|
|
17387
17585
|
};
|
|
17388
17586
|
}
|
|
17389
17587
|
//#endregion
|
|
17390
17588
|
//#region src/test-utils.ts
|
|
17391
|
-
function
|
|
17589
|
+
function Xx(e) {
|
|
17392
17590
|
hn(e);
|
|
17393
17591
|
}
|
|
17394
|
-
function
|
|
17592
|
+
function Zx(e) {
|
|
17395
17593
|
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
17594
|
return Number(n.lastInsertRowid);
|
|
17397
17595
|
}
|
|
17398
|
-
function
|
|
17596
|
+
function Qx(e, t = "local") {
|
|
17399
17597
|
let n = "2026-04-01T00:00:00.000Z", r = "fixture-work-authorized", i = "fixture-oss-hidden", a = "mixedscopeleak";
|
|
17400
17598
|
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
17599
|
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 +17642,8 @@ function Ux(e, t = "local") {
|
|
|
17444
17642
|
}
|
|
17445
17643
|
//#endregion
|
|
17446
17644
|
//#region src/index.ts
|
|
17447
|
-
var
|
|
17645
|
+
var $x = "0.31.0";
|
|
17448
17646
|
//#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 };
|
|
17647
|
+
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
17648
|
|
|
17451
17649
|
//# sourceMappingURL=index.js.map
|