@codemem/core 0.30.0-alpha.4 → 0.30.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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +468 -454
- package/dist/index.js.map +1 -1
- package/dist/scope-backfill.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14845,9 +14845,9 @@ function Ov(e) {
|
|
|
14845
14845
|
}
|
|
14846
14846
|
function kv(e) {
|
|
14847
14847
|
if (e.prepare("SELECT 1\n FROM (SELECT ? AS scope_id UNION ALL SELECT ? AS scope_id) required\n WHERE NOT EXISTS (\n SELECT 1 FROM replication_scopes rs WHERE rs.scope_id = required.scope_id\n )\n LIMIT 1").get("local-default", "legacy-shared-review") || e.prepare("SELECT 1\n FROM memory_items\n WHERE scope_id IS NULL OR scope_id = ''\n LIMIT 1").get()) return !0;
|
|
14848
|
-
let t = Ov(e);
|
|
14848
|
+
let t = Ov(e), n = Q(e, bv);
|
|
14849
|
+
if (n?.status === "running") return !0;
|
|
14849
14850
|
if (t === 0) return !1;
|
|
14850
|
-
let n = Q(e, bv);
|
|
14851
14851
|
if (!n || n.status !== "completed") return !0;
|
|
14852
14852
|
let r = n.metadata ?? {}, i = r.unstamped_replication_ops_at_completion;
|
|
14853
14853
|
if (typeof i != "number" || t > i) return !0;
|
|
@@ -14858,12 +14858,9 @@ function Av(e, t) {
|
|
|
14858
14858
|
return e.prepare("SELECT\n mi.id,\n mi.visibility,\n mi.workspace_id,\n mi.workspace_kind,\n s.project,\n s.cwd,\n s.git_remote\n FROM memory_items AS mi INDEXED BY idx_memory_items_scope_backfill_pending\n LEFT JOIN sessions s ON s.id = mi.session_id\n WHERE mi.scope_id IS NULL OR mi.scope_id = ''\n ORDER BY mi.id ASC\n LIMIT ?").all(t);
|
|
14859
14859
|
}
|
|
14860
14860
|
function jv(e, t) {
|
|
14861
|
-
return e.prepare("SELECT op_id, entity_id, created_at\n FROM (\n SELECT ro.op_id, ro.entity_id, ro.created_at\n FROM replication_ops ro\n INNER JOIN memory_items mi ON mi.import_key = ro.entity_id\n WHERE ro.entity_type = 'memory_item'\n AND (ro.scope_id IS NULL OR ro.scope_id = '')\n AND mi.scope_id IS NOT NULL\n AND mi.scope_id != ''\n UNION\n SELECT ro.op_id, ro.entity_id, ro.created_at\n FROM replication_ops ro\n INNER JOIN memory_items mi ON mi.id = CAST(ro.entity_id AS INTEGER)\n WHERE ro.entity_type = 'memory_item'\n AND (ro.scope_id IS NULL OR ro.scope_id = '')\n AND mi.scope_id IS NOT NULL\n AND mi.scope_id != ''\n AND CAST(mi.id AS TEXT) = ro.entity_id\n )\n ORDER BY created_at ASC, op_id ASC\n LIMIT ?").all(t);
|
|
14861
|
+
return e.prepare("SELECT op_id, entity_id, scope_id, created_at\n FROM (\n SELECT ro.op_id, ro.entity_id, mi.scope_id, ro.created_at\n FROM replication_ops ro\n INNER JOIN memory_items mi ON mi.import_key = ro.entity_id\n WHERE ro.entity_type = 'memory_item'\n AND (ro.scope_id IS NULL OR ro.scope_id = '')\n AND mi.scope_id IS NOT NULL\n AND mi.scope_id != ''\n UNION ALL\n SELECT ro.op_id, ro.entity_id, mi.scope_id, ro.created_at\n FROM replication_ops ro\n INNER JOIN memory_items mi ON mi.id = CAST(ro.entity_id AS INTEGER)\n WHERE ro.entity_type = 'memory_item'\n AND (ro.scope_id IS NULL OR ro.scope_id = '')\n AND mi.scope_id IS NOT NULL\n AND mi.scope_id != ''\n AND CAST(mi.id AS TEXT) = ro.entity_id\n AND NOT EXISTS (\n SELECT 1\n FROM memory_items import_match\n WHERE import_match.import_key = ro.entity_id\n AND import_match.scope_id IS NOT NULL\n AND import_match.scope_id != ''\n LIMIT 1\n )\n )\n ORDER BY created_at ASC, op_id ASC\n LIMIT ?").all(t);
|
|
14862
14862
|
}
|
|
14863
|
-
function Mv(e, t) {
|
|
14864
|
-
return xv(e.prepare("SELECT scope_id\n FROM memory_items\n WHERE (import_key = ? OR CAST(id AS TEXT) = ?)\n AND scope_id IS NOT NULL\n AND scope_id != ''\n ORDER BY CASE WHEN import_key = ? THEN 0 ELSE 1 END, id ASC\n LIMIT 1").get(t, t, t)?.scope_id);
|
|
14865
|
-
}
|
|
14866
|
-
function Nv(e, t = {}) {
|
|
14863
|
+
function Mv(e, t = {}) {
|
|
14867
14864
|
let n = Math.max(1, t.memoryLimit ?? 250), r = Math.max(1, t.replicationOpLimit ?? n), i = Tv(e, t.now), a = Av(e, n), o = e.prepare("UPDATE memory_items\n SET scope_id = ?\n WHERE id = ?\n AND (scope_id IS NULL OR scope_id = '')"), s = e.prepare("UPDATE replication_ops\n SET scope_id = ?\n WHERE op_id = ?\n AND (scope_id IS NULL OR scope_id = '')"), c = e.transaction(() => {
|
|
14868
14865
|
let t = 0, i = 0, c = 0;
|
|
14869
14866
|
for (let e of a) {
|
|
@@ -14878,13 +14875,13 @@ function Nv(e, t = {}) {
|
|
|
14878
14875
|
t += Number(o.run(n.scopeId, e.id).changes ?? 0);
|
|
14879
14876
|
}
|
|
14880
14877
|
let l = a.length >= n ? [] : jv(e, r);
|
|
14881
|
-
for (let
|
|
14882
|
-
let
|
|
14883
|
-
if (!
|
|
14878
|
+
for (let e of l) {
|
|
14879
|
+
let t = xv(e.scope_id);
|
|
14880
|
+
if (!t) {
|
|
14884
14881
|
c += 1;
|
|
14885
14882
|
continue;
|
|
14886
14883
|
}
|
|
14887
|
-
i += Number(s.run(
|
|
14884
|
+
i += Number(s.run(t, e.op_id).changes ?? 0);
|
|
14888
14885
|
}
|
|
14889
14886
|
return {
|
|
14890
14887
|
checkedReplicationOps: l.length,
|
|
@@ -14904,35 +14901,42 @@ function Nv(e, t = {}) {
|
|
|
14904
14901
|
remainingReplicationOps: Ov(e)
|
|
14905
14902
|
};
|
|
14906
14903
|
}
|
|
14907
|
-
function
|
|
14904
|
+
function Nv(e) {
|
|
14908
14905
|
return Q(e, "scope_id_backfill")?.metadata ?? {};
|
|
14909
14906
|
}
|
|
14907
|
+
function Pv(e) {
|
|
14908
|
+
return Number(e.seeded_scopes ?? 0) + Number(e.processed_memories ?? 0) + Number(e.processed_replication_ops ?? 0);
|
|
14909
|
+
}
|
|
14910
14910
|
async function Fv(e, t = {}) {
|
|
14911
|
-
let n = Math.max(1, t.batchSize ?? 250), r = Q(e, bv), i =
|
|
14911
|
+
let n = Math.max(1, t.batchSize ?? 250), r = Q(e, bv), i = Nv(e), a = !r || r.status === "completed" || r.status === "failed", o = Ev(e), s = Ov(e), c = wv(e), l = o + s + c;
|
|
14912
14912
|
if (l <= 0) {
|
|
14913
14913
|
let t = !!i.exhausted_in_previous_pass;
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
14928
|
-
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
|
|
14934
|
-
|
|
14935
|
-
|
|
14914
|
+
if (r && r.status !== "completed") {
|
|
14915
|
+
let n = Pv(i);
|
|
14916
|
+
return t ? (Yr(e, bv, {
|
|
14917
|
+
message: "Sharing-domain backfill complete; future startup should be quieter",
|
|
14918
|
+
progressCurrent: n,
|
|
14919
|
+
progressTotal: n,
|
|
14920
|
+
metadata: {
|
|
14921
|
+
...i,
|
|
14922
|
+
remaining_memories: 0,
|
|
14923
|
+
remaining_replication_ops: 0,
|
|
14924
|
+
unstamped_replication_ops_at_completion: Ov(e),
|
|
14925
|
+
max_stamped_memory_id_at_completion: Dv(e)
|
|
14926
|
+
}
|
|
14927
|
+
}), !1) : (Jr(e, bv, {
|
|
14928
|
+
message: "Sharing-domain backfill quiescent — confirming on next tick",
|
|
14929
|
+
progressCurrent: n,
|
|
14930
|
+
progressTotal: n + 1,
|
|
14931
|
+
metadata: {
|
|
14932
|
+
...i,
|
|
14933
|
+
remaining_memories: 0,
|
|
14934
|
+
remaining_replication_ops: 0,
|
|
14935
|
+
exhausted_in_previous_pass: !0
|
|
14936
|
+
}
|
|
14937
|
+
}), !0);
|
|
14938
|
+
}
|
|
14939
|
+
return !1;
|
|
14936
14940
|
}
|
|
14937
14941
|
a && qr(e, {
|
|
14938
14942
|
kind: bv,
|
|
@@ -14950,10 +14954,10 @@ async function Fv(e, t = {}) {
|
|
|
14950
14954
|
remaining_replication_ops: s
|
|
14951
14955
|
}
|
|
14952
14956
|
});
|
|
14953
|
-
let u =
|
|
14957
|
+
let u = Mv(e, {
|
|
14954
14958
|
memoryLimit: n,
|
|
14955
14959
|
replicationOpLimit: n
|
|
14956
|
-
}), d = a ? {} : i, f = Number(d.seeded_scopes ?? 0) + u.seededScopes, p = Number(d.processed_memories ?? 0) + u.checkedMemoryItems, m = Number(d.updated_memories ?? 0) + u.updatedMemoryItems, h = Number(d.processed_replication_ops ?? 0) + u.checkedReplicationOps, g = Number(d.updated_replication_ops ?? 0) + u.updatedReplicationOps, _ = Number(d.skipped_replication_ops ?? 0) + u.skippedReplicationOps, v = u.remainingMemoryItems, y = u.checkedReplicationOps === 0, b = wv(e), x = v === 0 && y && b === 0, S = !!d.exhausted_in_previous_pass, C = x && S, w = Math.max(
|
|
14960
|
+
}), d = a ? {} : i, f = Number(d.seeded_scopes ?? 0) + u.seededScopes, p = Number(d.processed_memories ?? 0) + u.checkedMemoryItems, m = Number(d.updated_memories ?? 0) + u.updatedMemoryItems, h = Number(d.processed_replication_ops ?? 0) + u.checkedReplicationOps, g = Number(d.updated_replication_ops ?? 0) + u.updatedReplicationOps, _ = Number(d.skipped_replication_ops ?? 0) + u.skippedReplicationOps, v = u.remainingMemoryItems, y = u.checkedReplicationOps === 0, b = wv(e), x = v === 0 && y && b === 0, S = !!d.exhausted_in_previous_pass, C = x && S, w = f + p + h, ee = !C && v === 0 && u.remainingReplicationOps === 0 && b === 0, T = Math.max(w + v + u.remainingReplicationOps + b + +!!ee, w), te = {
|
|
14957
14961
|
seeded_scopes: f,
|
|
14958
14962
|
processed_memories: p,
|
|
14959
14963
|
updated_memories: m,
|
|
@@ -14966,18 +14970,18 @@ async function Fv(e, t = {}) {
|
|
|
14966
14970
|
};
|
|
14967
14971
|
return C ? (Yr(e, bv, {
|
|
14968
14972
|
message: "Sharing-domain backfill complete; future startup should be quieter",
|
|
14969
|
-
progressCurrent:
|
|
14970
|
-
progressTotal:
|
|
14973
|
+
progressCurrent: T,
|
|
14974
|
+
progressTotal: T,
|
|
14971
14975
|
metadata: {
|
|
14972
|
-
...
|
|
14976
|
+
...te,
|
|
14973
14977
|
unstamped_replication_ops_at_completion: Ov(e),
|
|
14974
14978
|
max_stamped_memory_id_at_completion: Dv(e)
|
|
14975
14979
|
}
|
|
14976
14980
|
}), !1) : (Jr(e, bv, {
|
|
14977
|
-
message: `Backfilled Sharing domains for ${w} of ${
|
|
14981
|
+
message: `Backfilled Sharing domains for ${w} of ${T} item(s), including memories and replication ops`,
|
|
14978
14982
|
progressCurrent: w,
|
|
14979
|
-
progressTotal:
|
|
14980
|
-
metadata:
|
|
14983
|
+
progressTotal: T,
|
|
14984
|
+
metadata: te
|
|
14981
14985
|
}), !0);
|
|
14982
14986
|
}
|
|
14983
14987
|
var Iv = class {
|
|
@@ -15012,42 +15016,52 @@ var Iv = class {
|
|
|
15012
15016
|
try {
|
|
15013
15017
|
e = Mn(this.dbPath), await Fv(e, { batchSize: this.batchSize }) || (this.active = !1);
|
|
15014
15018
|
} catch (t) {
|
|
15019
|
+
if (Lv(t)) {
|
|
15020
|
+
console.warn("Scope backfill runner deferred because the database is busy", t);
|
|
15021
|
+
return;
|
|
15022
|
+
}
|
|
15015
15023
|
e && Xr(e, bv, t instanceof Error ? t.message : String(t)), console.warn("Scope backfill runner failed", t);
|
|
15016
15024
|
} finally {
|
|
15017
15025
|
e?.close();
|
|
15018
15026
|
}
|
|
15019
15027
|
}
|
|
15020
15028
|
};
|
|
15029
|
+
function Lv(e) {
|
|
15030
|
+
let t = typeof e == "object" && e ? String(e.code ?? "") : "";
|
|
15031
|
+
if (t === "SQLITE_BUSY" || t === "SQLITE_LOCKED") return !0;
|
|
15032
|
+
let n = e instanceof Error ? e.message : String(e);
|
|
15033
|
+
return /database is (?:locked|busy)/i.test(n);
|
|
15034
|
+
}
|
|
15021
15035
|
//#endregion
|
|
15022
15036
|
//#region src/project-scope-settings.ts
|
|
15023
|
-
function
|
|
15037
|
+
function Rv(e) {
|
|
15024
15038
|
return e?.trim() || null;
|
|
15025
15039
|
}
|
|
15026
|
-
function
|
|
15027
|
-
let t =
|
|
15040
|
+
function zv(e) {
|
|
15041
|
+
let t = Rv(e);
|
|
15028
15042
|
return t ? t.replaceAll("\\", "/").replace(/\/+$/, "") || t : null;
|
|
15029
15043
|
}
|
|
15030
|
-
function
|
|
15044
|
+
function Bv(e, t) {
|
|
15031
15045
|
return e?.label || t;
|
|
15032
15046
|
}
|
|
15033
|
-
function
|
|
15047
|
+
function Vv(e) {
|
|
15034
15048
|
return new Map(e.map((e) => [e.scope_id, e]));
|
|
15035
15049
|
}
|
|
15036
|
-
function
|
|
15050
|
+
function Hv(e) {
|
|
15037
15051
|
return !e || e.scope_id === "local-default" ? !1 : e.authority_type === "local" ? e.kind === "team" || e.kind === "org" || e.kind === "client" : !0;
|
|
15038
15052
|
}
|
|
15039
|
-
function
|
|
15053
|
+
function Uv(e) {
|
|
15040
15054
|
return /[*?]/.test(e);
|
|
15041
15055
|
}
|
|
15042
|
-
function
|
|
15056
|
+
function Wv(e) {
|
|
15043
15057
|
let t = e.search(/[*?]/);
|
|
15044
15058
|
return (t >= 0 ? e.slice(0, t) : e).replace(/\/+$/, "");
|
|
15045
15059
|
}
|
|
15046
|
-
function
|
|
15047
|
-
let t =
|
|
15060
|
+
function Gv(e) {
|
|
15061
|
+
let t = Wv(e.replaceAll("\\", "/"));
|
|
15048
15062
|
return t === "~" || /^\/Users\/[^/]+$/i.test(t) || /^\/home\/[^/]+$/i.test(t) || /^\/var\/home\/[^/]+$/i.test(t) || /^[A-Z]:\/Users\/[^/]+$/i.test(t);
|
|
15049
15063
|
}
|
|
15050
|
-
function
|
|
15064
|
+
function Kv(e) {
|
|
15051
15065
|
let t = JSON.stringify({
|
|
15052
15066
|
code: e.code,
|
|
15053
15067
|
mapping_id: e.mapping_id ?? null,
|
|
@@ -15059,18 +15073,18 @@ function Gv(e) {
|
|
|
15059
15073
|
});
|
|
15060
15074
|
return `psg_${u("sha256").update(t).digest("hex").slice(0, 32)}`;
|
|
15061
15075
|
}
|
|
15062
|
-
function
|
|
15076
|
+
function qv(e) {
|
|
15063
15077
|
return e.requires_confirmation ? {
|
|
15064
15078
|
...e,
|
|
15065
|
-
confirmation_token:
|
|
15079
|
+
confirmation_token: Kv(e)
|
|
15066
15080
|
} : e;
|
|
15067
15081
|
}
|
|
15068
|
-
function
|
|
15082
|
+
function Jv(e, t) {
|
|
15069
15083
|
if (e.workspace_identity) return [];
|
|
15070
|
-
let n =
|
|
15071
|
-
if (!
|
|
15072
|
-
let i =
|
|
15073
|
-
return
|
|
15084
|
+
let n = zv(e.project_pattern) ?? e.project_pattern, r = t.get(e.scope_id);
|
|
15085
|
+
if (!Hv(r)) return [];
|
|
15086
|
+
let i = Bv(r, e.scope_id), a = [];
|
|
15087
|
+
return Uv(n) && a.push({
|
|
15074
15088
|
code: "broad_org_domain_pattern",
|
|
15075
15089
|
severity: "warning",
|
|
15076
15090
|
message: `Wildcard project pattern ${n} can catch multiple projects. Review before attaching it to ${i}.`,
|
|
@@ -15078,7 +15092,7 @@ function qv(e, t) {
|
|
|
15078
15092
|
scope_id: e.scope_id,
|
|
15079
15093
|
mapping_id: e.id ?? null,
|
|
15080
15094
|
project_pattern: e.project_pattern
|
|
15081
|
-
}),
|
|
15095
|
+
}), Gv(n) && a.push({
|
|
15082
15096
|
code: "home_directory_org_domain_pattern",
|
|
15083
15097
|
severity: "warning",
|
|
15084
15098
|
message: `Home-directory project pattern ${n} can mix personal and work projects. Review before attaching it to ${i}.`,
|
|
@@ -15086,20 +15100,20 @@ function qv(e, t) {
|
|
|
15086
15100
|
scope_id: e.scope_id,
|
|
15087
15101
|
mapping_id: e.id ?? null,
|
|
15088
15102
|
project_pattern: e.project_pattern
|
|
15089
|
-
}), a.map(
|
|
15090
|
-
}
|
|
15091
|
-
function Jv(e) {
|
|
15092
|
-
return (Lv(e.project) ?? Lv(e.display_project) ?? e.workspace_identity).toLowerCase();
|
|
15103
|
+
}), a.map(qv);
|
|
15093
15104
|
}
|
|
15094
15105
|
function Yv(e) {
|
|
15106
|
+
return (Rv(e.project) ?? Rv(e.display_project) ?? e.workspace_identity).toLowerCase();
|
|
15107
|
+
}
|
|
15108
|
+
function Xv(e) {
|
|
15095
15109
|
let t = /* @__PURE__ */ new Map();
|
|
15096
15110
|
for (let n of e) {
|
|
15097
|
-
let e =
|
|
15111
|
+
let e = Yv(n);
|
|
15098
15112
|
t.set(e, [...t.get(e) ?? [], n]);
|
|
15099
15113
|
}
|
|
15100
15114
|
return t;
|
|
15101
15115
|
}
|
|
15102
|
-
function
|
|
15116
|
+
function Zv(e, t) {
|
|
15103
15117
|
let n = [];
|
|
15104
15118
|
e.resolution_reason === "local_default" && n.push({
|
|
15105
15119
|
code: "unknown_project_local_only",
|
|
@@ -15109,7 +15123,7 @@ function Xv(e, t) {
|
|
|
15109
15123
|
workspace_identity: e.workspace_identity,
|
|
15110
15124
|
scope_id: Ti
|
|
15111
15125
|
});
|
|
15112
|
-
let r = (t.get(
|
|
15126
|
+
let r = (t.get(Yv(e)) ?? []).filter((t) => t.workspace_identity !== e.workspace_identity);
|
|
15113
15127
|
return r.length > 0 && n.push({
|
|
15114
15128
|
code: "basename_collision_review",
|
|
15115
15129
|
severity: "warning",
|
|
@@ -15118,16 +15132,16 @@ function Xv(e, t) {
|
|
|
15118
15132
|
workspace_identity: e.workspace_identity,
|
|
15119
15133
|
related_workspace_identities: r.map((e) => e.workspace_identity),
|
|
15120
15134
|
related_projects: r.map((e) => e.display_project)
|
|
15121
|
-
}), n.map(
|
|
15135
|
+
}), n.map(qv);
|
|
15122
15136
|
}
|
|
15123
|
-
function
|
|
15124
|
-
let t =
|
|
15137
|
+
function Qv(e) {
|
|
15138
|
+
let t = Xv(e);
|
|
15125
15139
|
return e.map((e) => ({
|
|
15126
15140
|
...e,
|
|
15127
|
-
guardrail_warnings:
|
|
15141
|
+
guardrail_warnings: Zv(e, t)
|
|
15128
15142
|
}));
|
|
15129
15143
|
}
|
|
15130
|
-
function
|
|
15144
|
+
function $v(e) {
|
|
15131
15145
|
let t = /* @__PURE__ */ new Set();
|
|
15132
15146
|
return e.filter((e) => {
|
|
15133
15147
|
let n = [
|
|
@@ -15138,28 +15152,28 @@ function Qv(e) {
|
|
|
15138
15152
|
e.related_workspace_identities?.join("|") ?? ""
|
|
15139
15153
|
].join("\0");
|
|
15140
15154
|
return t.has(n) ? !1 : (t.add(n), !0);
|
|
15141
|
-
}).map(
|
|
15155
|
+
}).map(qv);
|
|
15142
15156
|
}
|
|
15143
|
-
function
|
|
15157
|
+
function ey(e, t) {
|
|
15144
15158
|
if (!e && !/[\\/:]/.test(t) && !(/[*?]/.test(t) && /[\\/:]/.test(t.replace(/[*?]/g, "")))) throw Error("project_pattern must use a canonical path, remote, or workspace pattern");
|
|
15145
15159
|
}
|
|
15146
|
-
function
|
|
15160
|
+
function ty(e) {
|
|
15147
15161
|
return {
|
|
15148
15162
|
scope_id: String(e.scope_id ?? ""),
|
|
15149
15163
|
label: String(e.label ?? ""),
|
|
15150
15164
|
kind: String(e.kind ?? "user"),
|
|
15151
15165
|
authority_type: String(e.authority_type ?? "local"),
|
|
15152
|
-
coordinator_id:
|
|
15153
|
-
group_id:
|
|
15166
|
+
coordinator_id: Rv(e.coordinator_id),
|
|
15167
|
+
group_id: Rv(e.group_id),
|
|
15154
15168
|
membership_epoch: Number(e.membership_epoch ?? 0),
|
|
15155
15169
|
status: String(e.status ?? "active"),
|
|
15156
15170
|
updated_at: String(e.updated_at ?? "")
|
|
15157
15171
|
};
|
|
15158
15172
|
}
|
|
15159
|
-
function
|
|
15173
|
+
function ny(e) {
|
|
15160
15174
|
return {
|
|
15161
15175
|
id: Number(e.id ?? 0),
|
|
15162
|
-
workspace_identity:
|
|
15176
|
+
workspace_identity: zv(e.workspace_identity),
|
|
15163
15177
|
project_pattern: String(e.project_pattern ?? ""),
|
|
15164
15178
|
scope_id: String(e.scope_id ?? ""),
|
|
15165
15179
|
priority: Number(e.priority ?? 0),
|
|
@@ -15169,54 +15183,54 @@ function ty(e) {
|
|
|
15169
15183
|
guardrail_warnings: []
|
|
15170
15184
|
};
|
|
15171
15185
|
}
|
|
15172
|
-
function ny(e) {
|
|
15173
|
-
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) => ey(e));
|
|
15174
|
-
}
|
|
15175
15186
|
function ry(e) {
|
|
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) => ty(e));
|
|
15188
|
+
}
|
|
15189
|
+
function iy(e) {
|
|
15176
15190
|
Tv(e);
|
|
15177
|
-
let t =
|
|
15191
|
+
let t = Vv(ry(e));
|
|
15178
15192
|
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) => {
|
|
15179
|
-
let n =
|
|
15193
|
+
let n = ny(e);
|
|
15180
15194
|
return {
|
|
15181
15195
|
...n,
|
|
15182
|
-
guardrail_warnings:
|
|
15196
|
+
guardrail_warnings: Jv(n, t)
|
|
15183
15197
|
};
|
|
15184
15198
|
});
|
|
15185
15199
|
}
|
|
15186
|
-
function
|
|
15200
|
+
function ay(e, t) {
|
|
15187
15201
|
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);
|
|
15188
|
-
return n ?
|
|
15202
|
+
return n ? ny(n) : null;
|
|
15189
15203
|
}
|
|
15190
|
-
function
|
|
15204
|
+
function oy(e, t) {
|
|
15191
15205
|
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);
|
|
15192
|
-
return n ?
|
|
15206
|
+
return n ? ny(n) : null;
|
|
15193
15207
|
}
|
|
15194
|
-
function
|
|
15208
|
+
function sy(e, t) {
|
|
15195
15209
|
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`);
|
|
15196
15210
|
}
|
|
15197
|
-
function
|
|
15198
|
-
let n = t.id == null ? null : Number(t.id), r = n && Number.isInteger(n) ?
|
|
15211
|
+
function cy(e, t) {
|
|
15212
|
+
let n = t.id == null ? null : Number(t.id), r = n && Number.isInteger(n) ? ay(e, n) : null, i = zv(t.workspace_identity) ?? r?.workspace_identity ?? null, a = i ? oy(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);
|
|
15199
15213
|
return {
|
|
15200
15214
|
existing: o,
|
|
15201
15215
|
workspaceIdentity: i,
|
|
15202
15216
|
projectPattern: s,
|
|
15203
|
-
scopeId:
|
|
15217
|
+
scopeId: Rv(t.scope_id) ?? "",
|
|
15204
15218
|
priority: c,
|
|
15205
|
-
source:
|
|
15219
|
+
source: Rv(t.source) ?? "user"
|
|
15206
15220
|
};
|
|
15207
15221
|
}
|
|
15208
|
-
function
|
|
15222
|
+
function ly(e, t) {
|
|
15209
15223
|
Tv(e);
|
|
15210
|
-
let n =
|
|
15211
|
-
n.projectPattern && n.scopeId && i.push(...
|
|
15224
|
+
let n = cy(e, t), r = Vv(ry(e)), i = [];
|
|
15225
|
+
n.projectPattern && n.scopeId && i.push(...Jv({
|
|
15212
15226
|
id: n.existing?.id ?? 0,
|
|
15213
15227
|
workspace_identity: n.workspaceIdentity,
|
|
15214
15228
|
project_pattern: n.projectPattern,
|
|
15215
15229
|
scope_id: n.scopeId
|
|
15216
15230
|
}, r));
|
|
15217
|
-
let a = n.workspaceIdentity ?
|
|
15218
|
-
if (a && i.push(...a.guardrail_warnings.filter((e) => e.code !== "basename_collision_review" ||
|
|
15219
|
-
let e =
|
|
15231
|
+
let a = n.workspaceIdentity ? uy(e).find((e) => e.workspace_identity === n.workspaceIdentity) : null, o = r.get(n.scopeId);
|
|
15232
|
+
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
|
+
let e = Bv(r.get(n.existing.scope_id), n.existing.scope_id), t = Bv(r.get(n.scopeId), n.scopeId);
|
|
15220
15234
|
i.push({
|
|
15221
15235
|
code: "scope_reassignment_old_copies",
|
|
15222
15236
|
severity: "warning",
|
|
@@ -15234,12 +15248,12 @@ function cy(e, t) {
|
|
|
15234
15248
|
requested_scope_id: n.scopeId,
|
|
15235
15249
|
requested_workspace_identity: n.workspaceIdentity,
|
|
15236
15250
|
requested_project_pattern: n.projectPattern,
|
|
15237
|
-
warnings:
|
|
15251
|
+
warnings: $v(i)
|
|
15238
15252
|
};
|
|
15239
15253
|
}
|
|
15240
|
-
function
|
|
15254
|
+
function uy(e, t = {}) {
|
|
15241
15255
|
Tv(e);
|
|
15242
|
-
let n = Math.max(1, Math.min(t.limit ?? 250, 1e3)), r =
|
|
15256
|
+
let n = Math.max(1, Math.min(t.limit ?? 250, 1e3)), r = iy(e), 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 FROM sessions s\n WHERE COALESCE(TRIM(s.git_remote), TRIM(s.cwd), TRIM(s.project), '') <> ''\n OR EXISTS (SELECT 1 FROM memory_items mi_candidate WHERE mi_candidate.session_id = s.id)\n ORDER BY s.started_at DESC, s.id DESC\n LIMIT ?").all(n), a = /* @__PURE__ */ new Set(), o = [];
|
|
15243
15257
|
for (let e of i) {
|
|
15244
15258
|
let t = ji({
|
|
15245
15259
|
gitRemote: e.git_remote,
|
|
@@ -15261,11 +15275,11 @@ function ly(e, t = {}) {
|
|
|
15261
15275
|
o.push({
|
|
15262
15276
|
workspace_identity: t.value,
|
|
15263
15277
|
identity_source: t.source,
|
|
15264
|
-
display_project: t.displayProject ??
|
|
15265
|
-
project:
|
|
15266
|
-
cwd:
|
|
15267
|
-
git_remote:
|
|
15268
|
-
git_branch:
|
|
15278
|
+
display_project: t.displayProject ?? Rv(e.project) ?? Rv(e.cwd) ?? t.value,
|
|
15279
|
+
project: Rv(e.project),
|
|
15280
|
+
cwd: Rv(e.cwd),
|
|
15281
|
+
git_remote: Rv(e.git_remote),
|
|
15282
|
+
git_branch: Rv(e.git_branch),
|
|
15269
15283
|
latest_session_at: e.started_at,
|
|
15270
15284
|
resolved_scope_id: n.scopeId,
|
|
15271
15285
|
resolution_reason: n.reason,
|
|
@@ -15274,48 +15288,48 @@ function ly(e, t = {}) {
|
|
|
15274
15288
|
guardrail_warnings: []
|
|
15275
15289
|
});
|
|
15276
15290
|
}
|
|
15277
|
-
return
|
|
15291
|
+
return Qv(o.toSorted((e, t) => e.display_project.localeCompare(t.display_project) || e.workspace_identity.localeCompare(t.workspace_identity)));
|
|
15278
15292
|
}
|
|
15279
|
-
function
|
|
15293
|
+
function dy(e, t) {
|
|
15280
15294
|
Tv(e);
|
|
15281
|
-
let n =
|
|
15295
|
+
let n = cy(e, t), r = n.scopeId;
|
|
15282
15296
|
if (!r) throw Error("scope_id must be a non-empty string");
|
|
15283
|
-
|
|
15297
|
+
sy(e, r);
|
|
15284
15298
|
let { existing: i, workspaceIdentity: a } = n, o = n.projectPattern;
|
|
15285
15299
|
if (!o) throw Error("project_pattern or workspace_identity is required");
|
|
15286
|
-
|
|
15300
|
+
ey(a, o);
|
|
15287
15301
|
let s = n.priority;
|
|
15288
15302
|
if (!Number.isFinite(s) || !Number.isInteger(s)) throw Error("priority must be an integer");
|
|
15289
15303
|
let c = n.source, l = (/* @__PURE__ */ new Date()).toISOString();
|
|
15290
15304
|
if (i) {
|
|
15291
15305
|
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);
|
|
15292
|
-
let t =
|
|
15306
|
+
let t = ay(e, i.id);
|
|
15293
15307
|
if (!t) throw Error("project_scope_mapping update returned no row");
|
|
15294
15308
|
return t;
|
|
15295
15309
|
}
|
|
15296
|
-
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 =
|
|
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 = ay(e, Number(u.lastInsertRowid));
|
|
15297
15311
|
if (!d) throw Error("project_scope_mapping insert returned no row");
|
|
15298
15312
|
return d;
|
|
15299
15313
|
}
|
|
15300
|
-
function
|
|
15314
|
+
function fy(e, t) {
|
|
15301
15315
|
if (!Number.isInteger(t) || t <= 0) throw Error("id must be a positive integer");
|
|
15302
15316
|
let n = e.prepare("DELETE FROM project_scope_mappings WHERE id = ?").run(t);
|
|
15303
15317
|
return Number(n.changes ?? 0) > 0;
|
|
15304
15318
|
}
|
|
15305
15319
|
//#endregion
|
|
15306
15320
|
//#region src/raw-event-sweeper.ts
|
|
15307
|
-
var
|
|
15308
|
-
function
|
|
15321
|
+
var py = 60;
|
|
15322
|
+
function my(e, t) {
|
|
15309
15323
|
let n = process.env[e];
|
|
15310
15324
|
if (n == null) return t;
|
|
15311
15325
|
let r = Number.parseInt(n, 10);
|
|
15312
15326
|
return Number.isFinite(r) ? r : t;
|
|
15313
15327
|
}
|
|
15314
|
-
function
|
|
15328
|
+
function hy(e) {
|
|
15315
15329
|
let t = (process.env[e] ?? "1").trim().toLowerCase();
|
|
15316
15330
|
return t === "0" || t === "false" || t === "off";
|
|
15317
15331
|
}
|
|
15318
|
-
var
|
|
15332
|
+
var gy = class {
|
|
15319
15333
|
store;
|
|
15320
15334
|
ingestOpts;
|
|
15321
15335
|
active = !1;
|
|
@@ -15333,7 +15347,7 @@ var hy = class {
|
|
|
15333
15347
|
this.store = e, this.ingestOpts = t;
|
|
15334
15348
|
}
|
|
15335
15349
|
enabled() {
|
|
15336
|
-
return !
|
|
15350
|
+
return !hy("CODEMEM_RAW_EVENTS_SWEEPER");
|
|
15337
15351
|
}
|
|
15338
15352
|
intervalMs() {
|
|
15339
15353
|
let e = process.env.CODEMEM_RAW_EVENTS_SWEEPER_INTERVAL_MS;
|
|
@@ -15345,31 +15359,31 @@ var hy = class {
|
|
|
15345
15359
|
return Number.isFinite(n) && n > 0 ? Math.max(1e3, n * 1e3) : 3e4;
|
|
15346
15360
|
}
|
|
15347
15361
|
idleMs() {
|
|
15348
|
-
return
|
|
15362
|
+
return my("CODEMEM_RAW_EVENTS_SWEEPER_IDLE_MS", 12e4);
|
|
15349
15363
|
}
|
|
15350
15364
|
limit() {
|
|
15351
|
-
return
|
|
15365
|
+
return my("CODEMEM_RAW_EVENTS_SWEEPER_LIMIT", 25);
|
|
15352
15366
|
}
|
|
15353
15367
|
workerMaxEvents() {
|
|
15354
|
-
let e =
|
|
15368
|
+
let e = my("CODEMEM_RAW_EVENTS_WORKER_MAX_EVENTS", 100);
|
|
15355
15369
|
return e <= 0 ? null : e;
|
|
15356
15370
|
}
|
|
15357
15371
|
retentionMs() {
|
|
15358
|
-
return
|
|
15372
|
+
return my("CODEMEM_RAW_EVENTS_RETENTION_MS", 0);
|
|
15359
15373
|
}
|
|
15360
15374
|
autoFlushEnabled() {
|
|
15361
15375
|
return (process.env.CODEMEM_RAW_EVENTS_AUTO_FLUSH ?? "").trim() === "1";
|
|
15362
15376
|
}
|
|
15363
15377
|
debounceMs() {
|
|
15364
|
-
return
|
|
15378
|
+
return my("CODEMEM_RAW_EVENTS_DEBOUNCE_MS", 6e4);
|
|
15365
15379
|
}
|
|
15366
15380
|
stuckBatchMs() {
|
|
15367
|
-
return
|
|
15381
|
+
return my("CODEMEM_RAW_EVENTS_STUCK_BATCH_MS", 3e5);
|
|
15368
15382
|
}
|
|
15369
15383
|
handleAuthError(e) {
|
|
15370
|
-
if (this.authBackoffUntil = Date.now() / 1e3 +
|
|
15384
|
+
if (this.authBackoffUntil = Date.now() / 1e3 + py, !this.authErrorLogged) {
|
|
15371
15385
|
this.authErrorLogged = !0;
|
|
15372
|
-
let t = `codemem: observer auth error — backing off for ${
|
|
15386
|
+
let t = `codemem: observer auth error — backing off for ${py}s. Refresh your provider credentials or update observer_provider in settings. (${e.message})`;
|
|
15373
15387
|
console.error(t);
|
|
15374
15388
|
}
|
|
15375
15389
|
}
|
|
@@ -15553,16 +15567,16 @@ var hy = class {
|
|
|
15553
15567
|
}
|
|
15554
15568
|
}
|
|
15555
15569
|
}
|
|
15556
|
-
},
|
|
15557
|
-
function
|
|
15570
|
+
}, _y = "memory_ref_backfill", vy = "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 )";
|
|
15571
|
+
function yy(e) {
|
|
15558
15572
|
return e.prepare(`SELECT 1 FROM memory_items mi
|
|
15559
|
-
WHERE ${
|
|
15573
|
+
WHERE ${vy}
|
|
15560
15574
|
LIMIT 1`).get() != null;
|
|
15561
15575
|
}
|
|
15562
|
-
function
|
|
15576
|
+
function by(e) {
|
|
15563
15577
|
return Q(e, "memory_ref_backfill")?.metadata ?? {};
|
|
15564
15578
|
}
|
|
15565
|
-
function
|
|
15579
|
+
function xy(e) {
|
|
15566
15580
|
if (!e) return null;
|
|
15567
15581
|
try {
|
|
15568
15582
|
let t = JSON.parse(e);
|
|
@@ -15570,17 +15584,17 @@ function by(e) {
|
|
|
15570
15584
|
} catch {}
|
|
15571
15585
|
return null;
|
|
15572
15586
|
}
|
|
15573
|
-
async function
|
|
15574
|
-
let n = Q(e,
|
|
15587
|
+
async function Sy(e, t = {}) {
|
|
15588
|
+
let n = Q(e, _y), r = by(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
|
|
15575
15589
|
FROM memory_items mi
|
|
15576
15590
|
WHERE mi.id > ?
|
|
15577
|
-
AND ${
|
|
15591
|
+
AND ${vy}
|
|
15578
15592
|
ORDER BY mi.id ASC
|
|
15579
15593
|
LIMIT ?`).all(a, i);
|
|
15580
15594
|
if (o.length === 0) {
|
|
15581
15595
|
if (n && n.status !== "completed") {
|
|
15582
15596
|
let t = Number(r.processed ?? 0);
|
|
15583
|
-
Yr(e,
|
|
15597
|
+
Yr(e, _y, {
|
|
15584
15598
|
message: "Ref backfill complete",
|
|
15585
15599
|
progressCurrent: t,
|
|
15586
15600
|
progressTotal: Number(r.total_backfillable ?? t),
|
|
@@ -15596,9 +15610,9 @@ async function xy(e, t = {}) {
|
|
|
15596
15610
|
let s = Number(r.processed ?? 0), c = Number(r.total_backfillable ?? 0);
|
|
15597
15611
|
if (!n || n.status === "completed" || n.status === "failed") {
|
|
15598
15612
|
let t = e.prepare(`SELECT COUNT(*) AS cnt FROM memory_items mi
|
|
15599
|
-
WHERE ${
|
|
15613
|
+
WHERE ${vy}`).get().cnt;
|
|
15600
15614
|
qr(e, {
|
|
15601
|
-
kind:
|
|
15615
|
+
kind: _y,
|
|
15602
15616
|
title: "Backfilling memory file/concept refs",
|
|
15603
15617
|
message: `Backfilling refs for ${t} memories`,
|
|
15604
15618
|
progressTotal: t,
|
|
@@ -15611,7 +15625,7 @@ async function xy(e, t = {}) {
|
|
|
15611
15625
|
}), c = t;
|
|
15612
15626
|
}
|
|
15613
15627
|
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) => {
|
|
15614
|
-
let t =
|
|
15628
|
+
let t = xy(e.files_read), n = xy(e.files_modified), r = xy(e.concepts);
|
|
15615
15629
|
if (t) for (let n of t) n && l.run(e.id, n, "read");
|
|
15616
15630
|
if (n) for (let t of n) t && l.run(e.id, t, "modified");
|
|
15617
15631
|
if (r) for (let t of r) {
|
|
@@ -15622,8 +15636,8 @@ async function xy(e, t = {}) {
|
|
|
15622
15636
|
for (let e of o) d(e);
|
|
15623
15637
|
let f = s + o.length, p = o.length < i, m = o[o.length - 1].id;
|
|
15624
15638
|
if (p) {
|
|
15625
|
-
let t = Number(
|
|
15626
|
-
return Yr(e,
|
|
15639
|
+
let t = Number(by(e).total_backfillable ?? c ?? f);
|
|
15640
|
+
return Yr(e, _y, {
|
|
15627
15641
|
message: "Ref backfill complete",
|
|
15628
15642
|
progressCurrent: f,
|
|
15629
15643
|
progressTotal: t,
|
|
@@ -15635,7 +15649,7 @@ async function xy(e, t = {}) {
|
|
|
15635
15649
|
}
|
|
15636
15650
|
}), !1;
|
|
15637
15651
|
}
|
|
15638
|
-
return Jr(e,
|
|
15652
|
+
return Jr(e, _y, {
|
|
15639
15653
|
message: `Backfilled refs for ${f} of ${c} memories`,
|
|
15640
15654
|
progressCurrent: f,
|
|
15641
15655
|
progressTotal: c,
|
|
@@ -15647,7 +15661,7 @@ async function xy(e, t = {}) {
|
|
|
15647
15661
|
}
|
|
15648
15662
|
}), !0;
|
|
15649
15663
|
}
|
|
15650
|
-
var
|
|
15664
|
+
var Cy = class {
|
|
15651
15665
|
dbPath;
|
|
15652
15666
|
signal;
|
|
15653
15667
|
batchSize;
|
|
@@ -15677,14 +15691,14 @@ var Sy = class {
|
|
|
15677
15691
|
if (!this.active || this.signal?.aborted) return;
|
|
15678
15692
|
let e = null;
|
|
15679
15693
|
try {
|
|
15680
|
-
e = Mn(this.dbPath), await
|
|
15694
|
+
e = Mn(this.dbPath), await Sy(e, { batchSize: this.batchSize }) || (this.active = !1);
|
|
15681
15695
|
} catch (t) {
|
|
15682
|
-
e && Xr(e,
|
|
15696
|
+
e && Xr(e, _y, t instanceof Error ? t.message : String(t)), console.warn("Ref backfill runner failed", t);
|
|
15683
15697
|
} finally {
|
|
15684
15698
|
e?.close();
|
|
15685
15699
|
}
|
|
15686
15700
|
}
|
|
15687
|
-
},
|
|
15701
|
+
}, wy = "session_context_backfill", Ty = [
|
|
15688
15702
|
"firstPrompt",
|
|
15689
15703
|
"promptCount",
|
|
15690
15704
|
"toolCount",
|
|
@@ -15692,20 +15706,20 @@ var Sy = class {
|
|
|
15692
15706
|
"filesModified",
|
|
15693
15707
|
"filesRead"
|
|
15694
15708
|
];
|
|
15695
|
-
function
|
|
15709
|
+
function Ey(e) {
|
|
15696
15710
|
let t = e.prepare("SELECT COUNT(*) AS c FROM sessions\n WHERE json_extract(metadata_json, '$.session_context.flusher') = 'raw_events'").get();
|
|
15697
15711
|
return Number(t?.c ?? 0);
|
|
15698
15712
|
}
|
|
15699
|
-
function
|
|
15713
|
+
function Dy(e, t, n) {
|
|
15700
15714
|
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);
|
|
15701
15715
|
}
|
|
15702
|
-
function
|
|
15716
|
+
function Oy(e, t, n) {
|
|
15703
15717
|
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) => {
|
|
15704
15718
|
let t = JSON.parse(e.payload_json);
|
|
15705
15719
|
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;
|
|
15706
15720
|
});
|
|
15707
15721
|
}
|
|
15708
|
-
function
|
|
15722
|
+
function ky(e) {
|
|
15709
15723
|
if (!e) return {};
|
|
15710
15724
|
try {
|
|
15711
15725
|
let t = JSON.parse(e);
|
|
@@ -15713,42 +15727,42 @@ function Oy(e) {
|
|
|
15713
15727
|
} catch {}
|
|
15714
15728
|
return {};
|
|
15715
15729
|
}
|
|
15716
|
-
function
|
|
15730
|
+
function Ay(e) {
|
|
15717
15731
|
return Array.isArray(e) ? [...e].sort() : e ?? null;
|
|
15718
15732
|
}
|
|
15719
|
-
function
|
|
15720
|
-
for (let n of
|
|
15721
|
-
let r =
|
|
15733
|
+
function jy(e, t) {
|
|
15734
|
+
for (let n of Ty) {
|
|
15735
|
+
let r = Ay(e[n]), i = Ay(t[n]);
|
|
15722
15736
|
if (JSON.stringify(r) !== JSON.stringify(i)) return !0;
|
|
15723
15737
|
}
|
|
15724
15738
|
return !1;
|
|
15725
15739
|
}
|
|
15726
|
-
function
|
|
15740
|
+
function My(e, t) {
|
|
15727
15741
|
let n = { ...e };
|
|
15728
|
-
for (let e of
|
|
15742
|
+
for (let e of Ty) {
|
|
15729
15743
|
let r = t[e];
|
|
15730
15744
|
r === void 0 ? delete n[e] : n[e] = r;
|
|
15731
15745
|
}
|
|
15732
15746
|
return n;
|
|
15733
15747
|
}
|
|
15734
|
-
function
|
|
15748
|
+
function Ny(e, t, n) {
|
|
15735
15749
|
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 = ?");
|
|
15736
15750
|
for (let n of t) {
|
|
15737
15751
|
if (s = n.id, !n.source || !n.stream_id) {
|
|
15738
15752
|
a += 1;
|
|
15739
15753
|
continue;
|
|
15740
15754
|
}
|
|
15741
|
-
let t =
|
|
15755
|
+
let t = Oy(e, n.source, n.stream_id);
|
|
15742
15756
|
if (t.length === 0) {
|
|
15743
15757
|
i += 1;
|
|
15744
15758
|
continue;
|
|
15745
15759
|
}
|
|
15746
|
-
let l = tv(S_(t)), u =
|
|
15747
|
-
if (!
|
|
15760
|
+
let l = tv(S_(t)), u = ky(n.metadata_json), d = u.session_context, f = d && typeof d == "object" ? d : {};
|
|
15761
|
+
if (!jy(f, l)) {
|
|
15748
15762
|
o += 1;
|
|
15749
15763
|
continue;
|
|
15750
15764
|
}
|
|
15751
|
-
let p =
|
|
15765
|
+
let p = My(f, l), m = {
|
|
15752
15766
|
...u,
|
|
15753
15767
|
session_context: p
|
|
15754
15768
|
};
|
|
@@ -15764,14 +15778,14 @@ function My(e, t, n) {
|
|
|
15764
15778
|
exhausted: t.length < n
|
|
15765
15779
|
};
|
|
15766
15780
|
}
|
|
15767
|
-
function
|
|
15768
|
-
return Q(e, "session_context_backfill")?.status === "completed" ? !1 :
|
|
15781
|
+
function Py(e) {
|
|
15782
|
+
return Q(e, "session_context_backfill")?.status === "completed" ? !1 : Ey(e) > 0;
|
|
15769
15783
|
}
|
|
15770
|
-
async function
|
|
15771
|
-
let n = Math.max(1, t.batchSize ?? 100), r = Q(e,
|
|
15784
|
+
async function Fy(e, t = {}) {
|
|
15785
|
+
let n = Math.max(1, t.batchSize ?? 100), r = Q(e, wy), i = r?.metadata ?? {}, a = !r || r.status === "completed" || r.status === "failed", o = a ? 0 : Number(i.last_cursor_id ?? 0), s = a ? Ey(e) : Number(i.total_candidates ?? Ey(e));
|
|
15772
15786
|
if (a && s <= 0) return !1;
|
|
15773
15787
|
a && qr(e, {
|
|
15774
|
-
kind:
|
|
15788
|
+
kind: wy,
|
|
15775
15789
|
title: "Backfilling session context",
|
|
15776
15790
|
message: `Rebuilding session_context for ${s} raw-event sessions`,
|
|
15777
15791
|
progressTotal: s,
|
|
@@ -15785,11 +15799,11 @@ async function Py(e, t = {}) {
|
|
|
15785
15799
|
unchanged_sessions: 0
|
|
15786
15800
|
}
|
|
15787
15801
|
});
|
|
15788
|
-
let c =
|
|
15802
|
+
let c = Dy(e, o, n);
|
|
15789
15803
|
if (c.length === 0) {
|
|
15790
15804
|
let t = Q(e, "session_context_backfill")?.metadata ?? {};
|
|
15791
|
-
return Yr(e,
|
|
15792
|
-
message:
|
|
15805
|
+
return Yr(e, wy, {
|
|
15806
|
+
message: Iy(t),
|
|
15793
15807
|
progressCurrent: Number(t.processed_sessions ?? 0),
|
|
15794
15808
|
progressTotal: Number(t.total_candidates ?? t.processed_sessions ?? 0),
|
|
15795
15809
|
metadata: {
|
|
@@ -15798,7 +15812,7 @@ async function Py(e, t = {}) {
|
|
|
15798
15812
|
}
|
|
15799
15813
|
}), !1;
|
|
15800
15814
|
}
|
|
15801
|
-
let l =
|
|
15815
|
+
let l = Ny(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 = {
|
|
15802
15816
|
last_cursor_id: l.lastCursorId,
|
|
15803
15817
|
total_candidates: Number(u.total_candidates ?? s),
|
|
15804
15818
|
processed_sessions: d,
|
|
@@ -15807,12 +15821,12 @@ async function Py(e, t = {}) {
|
|
|
15807
15821
|
skipped_no_bridge: m,
|
|
15808
15822
|
unchanged_sessions: h
|
|
15809
15823
|
};
|
|
15810
|
-
return l.exhausted ? (Yr(e,
|
|
15811
|
-
message:
|
|
15824
|
+
return l.exhausted ? (Yr(e, wy, {
|
|
15825
|
+
message: Iy(g),
|
|
15812
15826
|
progressCurrent: d,
|
|
15813
15827
|
progressTotal: Number(g.total_candidates ?? d),
|
|
15814
15828
|
metadata: g
|
|
15815
|
-
}), !1) : (Jr(e,
|
|
15829
|
+
}), !1) : (Jr(e, wy, {
|
|
15816
15830
|
status: "running",
|
|
15817
15831
|
message: `Rebuilt session_context for ${f} of ${d} scanned sessions`,
|
|
15818
15832
|
progressCurrent: d,
|
|
@@ -15820,11 +15834,11 @@ async function Py(e, t = {}) {
|
|
|
15820
15834
|
metadata: g
|
|
15821
15835
|
}), !0);
|
|
15822
15836
|
}
|
|
15823
|
-
function
|
|
15837
|
+
function Iy(e) {
|
|
15824
15838
|
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);
|
|
15825
15839
|
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)` : ""}`;
|
|
15826
15840
|
}
|
|
15827
|
-
var
|
|
15841
|
+
var Ly = class {
|
|
15828
15842
|
dbPath;
|
|
15829
15843
|
signal;
|
|
15830
15844
|
batchSize;
|
|
@@ -15854,25 +15868,25 @@ var Iy = class {
|
|
|
15854
15868
|
if (!this.active || this.signal?.aborted) return;
|
|
15855
15869
|
let e = null;
|
|
15856
15870
|
try {
|
|
15857
|
-
e = Mn(this.dbPath), await
|
|
15871
|
+
e = Mn(this.dbPath), await Fy(e, { batchSize: this.batchSize }) || (this.active = !1);
|
|
15858
15872
|
} catch (t) {
|
|
15859
|
-
e && Xr(e,
|
|
15873
|
+
e && Xr(e, wy, t instanceof Error ? t.message : String(t)), console.warn("Session-context backfill runner failed", t);
|
|
15860
15874
|
} finally {
|
|
15861
15875
|
e?.close();
|
|
15862
15876
|
}
|
|
15863
15877
|
}
|
|
15864
|
-
},
|
|
15865
|
-
function
|
|
15878
|
+
}, Ry = "session_summary_dedup_backfill";
|
|
15879
|
+
function zy(e) {
|
|
15866
15880
|
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();
|
|
15867
15881
|
return Number(t?.n ?? 0);
|
|
15868
15882
|
}
|
|
15869
|
-
function zy(e) {
|
|
15870
|
-
return Ry(e) > 0;
|
|
15871
|
-
}
|
|
15872
15883
|
function By(e) {
|
|
15884
|
+
return zy(e) > 0;
|
|
15885
|
+
}
|
|
15886
|
+
function Vy(e) {
|
|
15873
15887
|
return Q(e, "session_summary_dedup_backfill")?.metadata ?? {};
|
|
15874
15888
|
}
|
|
15875
|
-
function
|
|
15889
|
+
function Hy(e, t, n) {
|
|
15876
15890
|
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);
|
|
15877
15891
|
if (r.length === 0) return [];
|
|
15878
15892
|
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 = [];
|
|
@@ -15888,7 +15902,7 @@ function Vy(e, t, n) {
|
|
|
15888
15902
|
}
|
|
15889
15903
|
return a;
|
|
15890
15904
|
}
|
|
15891
|
-
function
|
|
15905
|
+
function Uy(e, t, n) {
|
|
15892
15906
|
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;
|
|
15893
15907
|
for (let o of t.superseded) {
|
|
15894
15908
|
let s = Un(o.metadata_json);
|
|
@@ -15904,9 +15918,9 @@ function Hy(e, t, n) {
|
|
|
15904
15918
|
}
|
|
15905
15919
|
return a;
|
|
15906
15920
|
}
|
|
15907
|
-
async function
|
|
15908
|
-
let n = Math.max(1, t.batchSize ?? 50), r = t.deviceId ?? "local", i = Q(e,
|
|
15909
|
-
if (c.length === 0) return i && i.status !== "completed" && Yr(e,
|
|
15921
|
+
async function Wy(e, t = {}) {
|
|
15922
|
+
let n = Math.max(1, t.batchSize ?? 50), r = t.deviceId ?? "local", i = Q(e, Ry), a = Vy(e), o = !i || i.status === "completed" || i.status === "failed", s = o ? 0 : Number(a.last_session_id ?? 0), c = Hy(e, s, n), l = o ? 0 : Number(a.processed_sessions ?? 0), u = o ? 0 : Number(a.superseded_rows ?? 0);
|
|
15923
|
+
if (c.length === 0) return i && i.status !== "completed" && Yr(e, Ry, {
|
|
15910
15924
|
message: u > 0 ? `Session-summary dedup complete (${u} rows superseded)` : "Session-summary dedup complete",
|
|
15911
15925
|
progressCurrent: l,
|
|
15912
15926
|
progressTotal: Number(a.total_sessions ?? l),
|
|
@@ -15916,9 +15930,9 @@ async function Uy(e, t = {}) {
|
|
|
15916
15930
|
}
|
|
15917
15931
|
}), !1;
|
|
15918
15932
|
if (!i || i.status === "completed" || i.status === "failed") {
|
|
15919
|
-
let t =
|
|
15933
|
+
let t = zy(e);
|
|
15920
15934
|
qr(e, {
|
|
15921
|
-
kind:
|
|
15935
|
+
kind: Ry,
|
|
15922
15936
|
title: "Deduplicating historical session summaries",
|
|
15923
15937
|
message: `Cleaning up ${t} sessions with duplicate observer summaries`,
|
|
15924
15938
|
progressTotal: t,
|
|
@@ -15933,10 +15947,10 @@ async function Uy(e, t = {}) {
|
|
|
15933
15947
|
}
|
|
15934
15948
|
let d = 0, f = s;
|
|
15935
15949
|
e.transaction(() => {
|
|
15936
|
-
for (let t of c) d +=
|
|
15950
|
+
for (let t of c) d += Uy(e, t, r), t.session_id > f && (f = t.session_id);
|
|
15937
15951
|
})();
|
|
15938
|
-
let p = l + c.length, m = u + d, h =
|
|
15939
|
-
return h === 0 ? (Yr(e,
|
|
15952
|
+
let p = l + c.length, m = u + d, h = zy(e), g = Math.max(Number(a.total_sessions ?? p), p + h);
|
|
15953
|
+
return h === 0 ? (Yr(e, Ry, {
|
|
15940
15954
|
message: `Session-summary dedup complete (${m} rows superseded across ${p} sessions)`,
|
|
15941
15955
|
progressCurrent: p,
|
|
15942
15956
|
progressTotal: g,
|
|
@@ -15946,7 +15960,7 @@ async function Uy(e, t = {}) {
|
|
|
15946
15960
|
superseded_rows: m,
|
|
15947
15961
|
last_session_id: f
|
|
15948
15962
|
}
|
|
15949
|
-
}), !1) : (Jr(e,
|
|
15963
|
+
}), !1) : (Jr(e, Ry, {
|
|
15950
15964
|
message: `Deduplicated ${p} of ${g} sessions (${m} rows superseded)`,
|
|
15951
15965
|
progressCurrent: p,
|
|
15952
15966
|
progressTotal: g,
|
|
@@ -15958,7 +15972,7 @@ async function Uy(e, t = {}) {
|
|
|
15958
15972
|
}
|
|
15959
15973
|
}), !0);
|
|
15960
15974
|
}
|
|
15961
|
-
var
|
|
15975
|
+
var Gy = class {
|
|
15962
15976
|
dbPath;
|
|
15963
15977
|
signal;
|
|
15964
15978
|
batchSize;
|
|
@@ -15989,97 +16003,97 @@ var Wy = class {
|
|
|
15989
16003
|
if (!this.active || this.signal?.aborted) return;
|
|
15990
16004
|
let e = null;
|
|
15991
16005
|
try {
|
|
15992
|
-
e = Mn(this.dbPath), await
|
|
16006
|
+
e = Mn(this.dbPath), await Wy(e, {
|
|
15993
16007
|
batchSize: this.batchSize,
|
|
15994
16008
|
deviceId: this.deviceId
|
|
15995
16009
|
}) || (this.active = !1);
|
|
15996
16010
|
} catch (t) {
|
|
15997
|
-
e && Xr(e,
|
|
16011
|
+
e && Xr(e, Ry, t instanceof Error ? t.message : String(t)), console.warn("Summary-dedup backfill runner failed", t);
|
|
15998
16012
|
} finally {
|
|
15999
16013
|
e?.close();
|
|
16000
16014
|
}
|
|
16001
16015
|
}
|
|
16002
|
-
},
|
|
16016
|
+
}, Ky = [
|
|
16003
16017
|
"unsupported",
|
|
16004
16018
|
"aware",
|
|
16005
16019
|
"enforcing"
|
|
16006
|
-
],
|
|
16020
|
+
], qy = "X-Codemem-Sync-Capability", Jy = "aware", Yy = {
|
|
16007
16021
|
unsupported: 0,
|
|
16008
16022
|
aware: 1,
|
|
16009
16023
|
enforcing: 2
|
|
16010
16024
|
};
|
|
16011
|
-
function
|
|
16025
|
+
function Xy(e) {
|
|
16012
16026
|
if (typeof e != "string") return "unsupported";
|
|
16013
16027
|
let t = e.trim().toLowerCase();
|
|
16014
|
-
return
|
|
16028
|
+
return Ky.includes(t) ? t : "unsupported";
|
|
16015
16029
|
}
|
|
16016
|
-
function
|
|
16017
|
-
let n =
|
|
16018
|
-
return
|
|
16030
|
+
function Zy(e, t) {
|
|
16031
|
+
let n = Xy(e), r = Xy(t);
|
|
16032
|
+
return Yy[n] <= Yy[r] ? n : r;
|
|
16019
16033
|
}
|
|
16020
16034
|
//#endregion
|
|
16021
16035
|
//#region src/vector-migration.ts
|
|
16022
|
-
var
|
|
16023
|
-
function
|
|
16036
|
+
var Qy = "vector_model_migration", $y = "sync_bootstrap", eb = "sync_incremental", tb = 6e4, nb = null;
|
|
16037
|
+
function rb(e) {
|
|
16024
16038
|
return [...new Set(e.filter((e) => Number.isInteger(e) && e > 0))].sort((e, t) => e - t);
|
|
16025
16039
|
}
|
|
16026
|
-
function
|
|
16027
|
-
return Array.isArray(e) ?
|
|
16040
|
+
function ib(e) {
|
|
16041
|
+
return Array.isArray(e) ? rb(e.filter((e) => typeof e == "number")) : [];
|
|
16028
16042
|
}
|
|
16029
|
-
function
|
|
16030
|
-
let n = new Set(
|
|
16031
|
-
for (let e of
|
|
16032
|
-
for (let e of
|
|
16043
|
+
function ab(e, t) {
|
|
16044
|
+
let n = new Set(ib(e.pending_upsert_memory_ids)), r = new Set(ib(e.pending_delete_memory_ids));
|
|
16045
|
+
for (let e of rb(t.deleteMemoryIds)) n.delete(e), r.add(e);
|
|
16046
|
+
for (let e of rb(t.upsertMemoryIds)) r.delete(e), n.add(e);
|
|
16033
16047
|
return {
|
|
16034
16048
|
pending_upsert_memory_ids: [...n],
|
|
16035
16049
|
pending_delete_memory_ids: [...r]
|
|
16036
16050
|
};
|
|
16037
16051
|
}
|
|
16038
|
-
function
|
|
16052
|
+
function ob(e, t) {
|
|
16039
16053
|
if (t.length === 0) return;
|
|
16040
16054
|
let n = t.map(() => "?").join(", ");
|
|
16041
16055
|
e.prepare(`DELETE FROM memory_vectors WHERE memory_id IN (${n})`).run(...t);
|
|
16042
16056
|
}
|
|
16043
|
-
function
|
|
16044
|
-
return JSON.stringify(
|
|
16057
|
+
function sb(e, t) {
|
|
16058
|
+
return JSON.stringify(ib(e.pending_upsert_memory_ids)) === JSON.stringify(ib(t.pending_upsert_memory_ids)) && JSON.stringify(ib(e.pending_delete_memory_ids)) === JSON.stringify(ib(t.pending_delete_memory_ids));
|
|
16045
16059
|
}
|
|
16046
|
-
function
|
|
16047
|
-
|
|
16060
|
+
function cb() {
|
|
16061
|
+
nb?.wake();
|
|
16048
16062
|
}
|
|
16049
|
-
function
|
|
16050
|
-
let n =
|
|
16063
|
+
function lb(e, t) {
|
|
16064
|
+
let n = ab({}, t);
|
|
16051
16065
|
if ((n.pending_upsert_memory_ids?.length ?? 0) === 0 && (n.pending_delete_memory_ids?.length ?? 0) === 0) return;
|
|
16052
|
-
let r = Q(e,
|
|
16066
|
+
let r = Q(e, Qy), i = r && r.status !== "completed" && r.status !== "cancelled" ? r.metadata ?? {} : {}, a = {
|
|
16053
16067
|
...i,
|
|
16054
|
-
...
|
|
16055
|
-
trigger: i.trigger ??
|
|
16056
|
-
}, o =
|
|
16068
|
+
...ab(i, t),
|
|
16069
|
+
trigger: i.trigger ?? eb
|
|
16070
|
+
}, o = ib(a.pending_upsert_memory_ids).length + ib(a.pending_delete_memory_ids).length;
|
|
16057
16071
|
if (!r || r.status === "completed" || r.status === "cancelled") {
|
|
16058
16072
|
qr(e, {
|
|
16059
|
-
kind:
|
|
16073
|
+
kind: Qy,
|
|
16060
16074
|
title: "Re-indexing memories",
|
|
16061
16075
|
status: "pending",
|
|
16062
16076
|
message: "Queued vector catch-up for incremental sync data",
|
|
16063
16077
|
progressTotal: null,
|
|
16064
16078
|
metadata: a
|
|
16065
|
-
}),
|
|
16079
|
+
}), cb();
|
|
16066
16080
|
return;
|
|
16067
16081
|
}
|
|
16068
|
-
Jr(e,
|
|
16082
|
+
Jr(e, Qy, {
|
|
16069
16083
|
status: "pending",
|
|
16070
16084
|
message: "Queued vector catch-up for incremental sync data",
|
|
16071
16085
|
progressCurrent: r.status === "failed" ? 0 : Math.min(r.progress.current, o),
|
|
16072
16086
|
progressTotal: r.progress.total,
|
|
16073
16087
|
metadata: a
|
|
16074
|
-
}),
|
|
16088
|
+
}), cb();
|
|
16075
16089
|
}
|
|
16076
|
-
async function
|
|
16077
|
-
let a = t.metadata ?? {}, o =
|
|
16090
|
+
async function ub(e, t, n, r, i) {
|
|
16091
|
+
let a = t.metadata ?? {}, o = ib(a.pending_delete_memory_ids), s = ib(a.pending_upsert_memory_ids);
|
|
16078
16092
|
if (o.length === 0 && s.length === 0) return {
|
|
16079
16093
|
completed: !1,
|
|
16080
16094
|
metadata: a
|
|
16081
16095
|
};
|
|
16082
|
-
o.length > 0 &&
|
|
16096
|
+
o.length > 0 && ob(e, o);
|
|
16083
16097
|
let c = s.slice(0, r);
|
|
16084
16098
|
if (c.length > 0) {
|
|
16085
16099
|
if (await ks(e, {
|
|
@@ -16095,14 +16109,14 @@ async function lb(e, t, n, r, i) {
|
|
|
16095
16109
|
...a,
|
|
16096
16110
|
pending_delete_memory_ids: [],
|
|
16097
16111
|
pending_upsert_memory_ids: s.slice(c.length)
|
|
16098
|
-
}, u = Q(e, "vector_model_migration")?.metadata ?? {}, d =
|
|
16112
|
+
}, u = Q(e, "vector_model_migration")?.metadata ?? {}, d = sb(u, a) ? l : {
|
|
16099
16113
|
...u,
|
|
16100
|
-
...
|
|
16101
|
-
upsertMemoryIds:
|
|
16102
|
-
deleteMemoryIds:
|
|
16114
|
+
...ab(u, {
|
|
16115
|
+
upsertMemoryIds: ib(l.pending_upsert_memory_ids),
|
|
16116
|
+
deleteMemoryIds: ib(l.pending_delete_memory_ids)
|
|
16103
16117
|
})
|
|
16104
|
-
}, f =
|
|
16105
|
-
return f === 0 && p ? (Yr(e,
|
|
16118
|
+
}, f = ib(d.pending_delete_memory_ids).length + ib(d.pending_upsert_memory_ids).length, p = (a.trigger ?? eb) === eb && !a.source_model && !a.last_cursor_id && a.embeddable_total == null;
|
|
16119
|
+
return f === 0 && p ? (Yr(e, Qy, {
|
|
16106
16120
|
message: "Finished vector catch-up for incremental sync data",
|
|
16107
16121
|
progressCurrent: 0,
|
|
16108
16122
|
progressTotal: null,
|
|
@@ -16110,7 +16124,7 @@ async function lb(e, t, n, r, i) {
|
|
|
16110
16124
|
}), {
|
|
16111
16125
|
completed: !0,
|
|
16112
16126
|
metadata: d
|
|
16113
|
-
}) : (Jr(e,
|
|
16127
|
+
}) : (Jr(e, Qy, {
|
|
16114
16128
|
status: f > 0 ? "running" : t.status,
|
|
16115
16129
|
message: f > 0 ? `Queued vector catch-up has ${f} memory change(s) remaining` : t.message,
|
|
16116
16130
|
progressCurrent: 0,
|
|
@@ -16121,36 +16135,36 @@ async function lb(e, t, n, r, i) {
|
|
|
16121
16135
|
metadata: d
|
|
16122
16136
|
});
|
|
16123
16137
|
}
|
|
16124
|
-
function
|
|
16138
|
+
function db(e, t = {}) {
|
|
16125
16139
|
let n = typeof t.embeddableTotal == "number" && t.embeddableTotal >= 0 ? t.embeddableTotal : null, r = {
|
|
16126
16140
|
last_cursor_id: 0,
|
|
16127
16141
|
processed_embeddable: 0,
|
|
16128
|
-
trigger:
|
|
16142
|
+
trigger: $y
|
|
16129
16143
|
};
|
|
16130
16144
|
n != null && (r.embeddable_total = n), qr(e, {
|
|
16131
|
-
kind:
|
|
16145
|
+
kind: Qy,
|
|
16132
16146
|
title: "Re-indexing memories",
|
|
16133
16147
|
status: "pending",
|
|
16134
16148
|
message: "Queued vector catch-up for synced bootstrap data",
|
|
16135
16149
|
progressTotal: n,
|
|
16136
16150
|
metadata: r
|
|
16137
|
-
}),
|
|
16151
|
+
}), cb();
|
|
16138
16152
|
}
|
|
16139
|
-
function
|
|
16153
|
+
function fb(e) {
|
|
16140
16154
|
return e.prepare("SELECT model, COUNT(*) AS rows FROM memory_vectors GROUP BY model ORDER BY rows DESC, model ASC").all();
|
|
16141
16155
|
}
|
|
16142
|
-
function
|
|
16156
|
+
function pb(e) {
|
|
16143
16157
|
let t = e.prepare("SELECT COUNT(*) AS c FROM memory_items\n WHERE active = 1\n AND TRIM(COALESCE(title, '') || COALESCE(body_text, '')) != ''").get();
|
|
16144
16158
|
return Number(t?.c ?? 0);
|
|
16145
16159
|
}
|
|
16146
|
-
function
|
|
16160
|
+
function mb(e, t, n) {
|
|
16147
16161
|
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);
|
|
16148
16162
|
}
|
|
16149
|
-
function
|
|
16163
|
+
function hb(e) {
|
|
16150
16164
|
return `${e.title ?? ""}
|
|
16151
16165
|
${e.body_text ?? ""}`.trim().length > 0;
|
|
16152
16166
|
}
|
|
16153
|
-
function
|
|
16167
|
+
function gb(e, t, n, r) {
|
|
16154
16168
|
let i = e?.metadata ?? {};
|
|
16155
16169
|
return {
|
|
16156
16170
|
source_model: t ?? i.source_model ?? null,
|
|
@@ -16160,39 +16174,39 @@ function hb(e, t, n, r) {
|
|
|
16160
16174
|
embeddable_total: Number(i.embeddable_total ?? r)
|
|
16161
16175
|
};
|
|
16162
16176
|
}
|
|
16163
|
-
function
|
|
16177
|
+
function _b(e, t) {
|
|
16164
16178
|
let n = e.prepare("SELECT COUNT(*) AS c FROM memory_vectors WHERE model != ?").get(t), r = Number(n?.c ?? 0);
|
|
16165
16179
|
return r > 0 && e.prepare("DELETE FROM memory_vectors WHERE model != ?").run(t), r;
|
|
16166
16180
|
}
|
|
16167
|
-
function
|
|
16168
|
-
return
|
|
16181
|
+
function vb(e, t) {
|
|
16182
|
+
return fb(e).filter((e) => e.model !== t)[0]?.model ?? null;
|
|
16169
16183
|
}
|
|
16170
|
-
async function
|
|
16171
|
-
let n = Q(e,
|
|
16184
|
+
async function yb(e, t = {}) {
|
|
16185
|
+
let n = Q(e, Qy), r = n?.status === "running" || n?.status === "pending";
|
|
16172
16186
|
if (Ln()) {
|
|
16173
|
-
r && Xr(e,
|
|
16187
|
+
r && Xr(e, Qy, "Embeddings are disabled", { message: "Vector re-indexing is waiting for embeddings to be enabled" });
|
|
16174
16188
|
return;
|
|
16175
16189
|
}
|
|
16176
16190
|
let i = await es();
|
|
16177
16191
|
if (!i) {
|
|
16178
|
-
r && Xr(e,
|
|
16192
|
+
r && Xr(e, Qy, "Embedding client unavailable", { message: "Vector re-indexing is waiting for the embedding client" });
|
|
16179
16193
|
return;
|
|
16180
16194
|
}
|
|
16181
|
-
let a = i.model, o = Math.max(1, t.batchSize ?? 50), s = n?.metadata ?? {}, c =
|
|
16195
|
+
let a = i.model, o = Math.max(1, t.batchSize ?? 50), s = n?.metadata ?? {}, c = ib(s.pending_upsert_memory_ids).length + ib(s.pending_delete_memory_ids).length;
|
|
16182
16196
|
if (n?.status === "completed" && s.target_model === a && c === 0) return;
|
|
16183
16197
|
if (n) {
|
|
16184
|
-
let r = await
|
|
16198
|
+
let r = await ub(e, n, a, o, t.signal);
|
|
16185
16199
|
if (r.completed) return;
|
|
16186
|
-
let i =
|
|
16187
|
-
if ((r.metadata.trigger ??
|
|
16188
|
-
n = Q(e,
|
|
16200
|
+
let i = ib(r.metadata.pending_delete_memory_ids).length + ib(r.metadata.pending_upsert_memory_ids).length;
|
|
16201
|
+
if ((r.metadata.trigger ?? eb) === eb && i > 0) return;
|
|
16202
|
+
n = Q(e, Qy);
|
|
16189
16203
|
}
|
|
16190
|
-
let l =
|
|
16191
|
-
if (!l && (d ===
|
|
16204
|
+
let l = vb(e, a), u = n?.status === "running" || n?.status === "pending" || n?.status === "failed", d = n?.metadata?.trigger;
|
|
16205
|
+
if (!l && (d === eb || d === $y) && u) {
|
|
16192
16206
|
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);
|
|
16193
16207
|
if (Number(t?.c ?? 0) <= 0) {
|
|
16194
|
-
let t = n?.metadata ?? {}, r =
|
|
16195
|
-
Yr(e,
|
|
16208
|
+
let t = n?.metadata ?? {}, r = pb(e);
|
|
16209
|
+
Yr(e, Qy, {
|
|
16196
16210
|
message: "Finished re-indexing memories",
|
|
16197
16211
|
progressCurrent: r,
|
|
16198
16212
|
progressTotal: r,
|
|
@@ -16207,9 +16221,9 @@ async function vb(e, t = {}) {
|
|
|
16207
16221
|
return;
|
|
16208
16222
|
}
|
|
16209
16223
|
}
|
|
16210
|
-
let f = n?.metadata ?? {}, p = (n?.status === "running" || n?.status === "pending") && f.embeddable_total ? Number(f.embeddable_total) :
|
|
16224
|
+
let f = n?.metadata ?? {}, p = (n?.status === "running" || n?.status === "pending") && f.embeddable_total ? Number(f.embeddable_total) : pb(e);
|
|
16211
16225
|
if (p <= 0 && u && !l) {
|
|
16212
|
-
Yr(e,
|
|
16226
|
+
Yr(e, Qy, {
|
|
16213
16227
|
message: "No embeddable memories to re-index",
|
|
16214
16228
|
progressCurrent: 0,
|
|
16215
16229
|
progressTotal: 0,
|
|
@@ -16223,9 +16237,9 @@ async function vb(e, t = {}) {
|
|
|
16223
16237
|
return;
|
|
16224
16238
|
}
|
|
16225
16239
|
if (l && p <= 0) {
|
|
16226
|
-
let t =
|
|
16240
|
+
let t = _b(e, a);
|
|
16227
16241
|
qr(e, {
|
|
16228
|
-
kind:
|
|
16242
|
+
kind: Qy,
|
|
16229
16243
|
title: "Re-indexing memories",
|
|
16230
16244
|
message: t > 0 ? `Removed ${t} stale vector rows` : "No embeddable memories to re-index",
|
|
16231
16245
|
progressTotal: 0,
|
|
@@ -16234,7 +16248,7 @@ async function vb(e, t = {}) {
|
|
|
16234
16248
|
target_model: a,
|
|
16235
16249
|
removed_stale_rows: t
|
|
16236
16250
|
}
|
|
16237
|
-
}), Yr(e,
|
|
16251
|
+
}), Yr(e, Qy, {
|
|
16238
16252
|
progressCurrent: 0,
|
|
16239
16253
|
progressTotal: 0,
|
|
16240
16254
|
metadata: {
|
|
@@ -16245,15 +16259,15 @@ async function vb(e, t = {}) {
|
|
|
16245
16259
|
});
|
|
16246
16260
|
return;
|
|
16247
16261
|
}
|
|
16248
|
-
let m = n, h =
|
|
16262
|
+
let m = n, h = gb(m, l, a, p);
|
|
16249
16263
|
(!m || m.status === "completed" || m.status === "failed") && qr(e, {
|
|
16250
|
-
kind:
|
|
16264
|
+
kind: Qy,
|
|
16251
16265
|
title: "Re-indexing memories",
|
|
16252
16266
|
message: l ? `Building ${a} vectors while semantic search falls back to FTS-only` : `Building ${a} vectors`,
|
|
16253
16267
|
progressTotal: p,
|
|
16254
16268
|
metadata: h
|
|
16255
16269
|
});
|
|
16256
|
-
let g =
|
|
16270
|
+
let g = mb(e, h.last_cursor_id ?? 0, o), _ = g.map((e) => e.id), v = g.filter(hb).length, y = g.at(-1)?.id ?? h.last_cursor_id ?? 0, b = Math.min(p, (h.processed_embeddable ?? 0) + v);
|
|
16257
16271
|
if (_.length > 0) {
|
|
16258
16272
|
if (await ks(e, {
|
|
16259
16273
|
memoryIds: _,
|
|
@@ -16261,8 +16275,8 @@ async function vb(e, t = {}) {
|
|
|
16261
16275
|
}), t.signal?.aborted) return;
|
|
16262
16276
|
if (g.length < o) {
|
|
16263
16277
|
e.transaction(() => {
|
|
16264
|
-
let t =
|
|
16265
|
-
Yr(e,
|
|
16278
|
+
let t = _b(e, a);
|
|
16279
|
+
Yr(e, Qy, {
|
|
16266
16280
|
message: t > 0 ? `Finished re-indexing and removed ${t} stale vector rows` : "Finished re-indexing memories",
|
|
16267
16281
|
progressCurrent: b,
|
|
16268
16282
|
progressTotal: p,
|
|
@@ -16277,7 +16291,7 @@ async function vb(e, t = {}) {
|
|
|
16277
16291
|
})();
|
|
16278
16292
|
return;
|
|
16279
16293
|
}
|
|
16280
|
-
Jr(e,
|
|
16294
|
+
Jr(e, Qy, {
|
|
16281
16295
|
message: `Re-indexed ${b} of ${p} memories`,
|
|
16282
16296
|
progressCurrent: b,
|
|
16283
16297
|
progressTotal: p,
|
|
@@ -16291,8 +16305,8 @@ async function vb(e, t = {}) {
|
|
|
16291
16305
|
return;
|
|
16292
16306
|
}
|
|
16293
16307
|
h.last_cursor_id && h.last_cursor_id > 0 && e.transaction(() => {
|
|
16294
|
-
let t =
|
|
16295
|
-
Yr(e,
|
|
16308
|
+
let t = _b(e, a);
|
|
16309
|
+
Yr(e, Qy, {
|
|
16296
16310
|
message: t > 0 ? `Finished re-indexing and removed ${t} stale vector rows` : "Finished re-indexing memories",
|
|
16297
16311
|
progressCurrent: p,
|
|
16298
16312
|
progressTotal: p,
|
|
@@ -16305,7 +16319,7 @@ async function vb(e, t = {}) {
|
|
|
16305
16319
|
});
|
|
16306
16320
|
})();
|
|
16307
16321
|
}
|
|
16308
|
-
var
|
|
16322
|
+
var bb = class {
|
|
16309
16323
|
dbPath;
|
|
16310
16324
|
signal;
|
|
16311
16325
|
batchSize;
|
|
@@ -16316,13 +16330,13 @@ var yb = class {
|
|
|
16316
16330
|
currentRun = null;
|
|
16317
16331
|
lastTickWasIdle = !1;
|
|
16318
16332
|
constructor(e = {}) {
|
|
16319
|
-
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 ??
|
|
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 ?? tb);
|
|
16320
16334
|
}
|
|
16321
16335
|
start() {
|
|
16322
|
-
this.active || (this.active = !0, this.lastTickWasIdle = !1,
|
|
16336
|
+
this.active || (this.active = !0, this.lastTickWasIdle = !1, nb = this, this.schedule(100));
|
|
16323
16337
|
}
|
|
16324
16338
|
async stop() {
|
|
16325
|
-
this.active = !1,
|
|
16339
|
+
this.active = !1, nb === this && (nb = null), this.timer &&= (clearTimeout(this.timer), null), this.currentRun && await this.currentRun;
|
|
16326
16340
|
}
|
|
16327
16341
|
wake() {
|
|
16328
16342
|
this.active && (this.lastTickWasIdle = !1, this.timer && (clearTimeout(this.timer), this.timer = null, this.schedule(100)));
|
|
@@ -16342,28 +16356,28 @@ var yb = class {
|
|
|
16342
16356
|
if (!this.active || this.signal?.aborted) return;
|
|
16343
16357
|
let e = null;
|
|
16344
16358
|
try {
|
|
16345
|
-
e = Mn(this.dbPath), In(e), await
|
|
16359
|
+
e = Mn(this.dbPath), In(e), await yb(e, {
|
|
16346
16360
|
batchSize: this.batchSize,
|
|
16347
16361
|
signal: this.signal
|
|
16348
16362
|
}), this.lastTickWasIdle = this.computeIdle(e);
|
|
16349
16363
|
} catch (t) {
|
|
16350
|
-
e && Xr(e,
|
|
16364
|
+
e && Xr(e, Qy, t instanceof Error ? t.message : String(t)), this.lastTickWasIdle = !0, console.warn("Vector migration runner failed", t);
|
|
16351
16365
|
} finally {
|
|
16352
16366
|
e?.close();
|
|
16353
16367
|
}
|
|
16354
16368
|
}
|
|
16355
16369
|
computeIdle(e) {
|
|
16356
16370
|
if (Ln()) return !0;
|
|
16357
|
-
let t = Q(e,
|
|
16371
|
+
let t = Q(e, Qy);
|
|
16358
16372
|
if (t) {
|
|
16359
16373
|
if (t.status === "running" || t.status === "pending") return !1;
|
|
16360
16374
|
let e = t.metadata ?? {};
|
|
16361
|
-
return !(
|
|
16375
|
+
return !(ib(e.pending_upsert_memory_ids).length + ib(e.pending_delete_memory_ids).length > 0);
|
|
16362
16376
|
}
|
|
16363
16377
|
let n = $o();
|
|
16364
16378
|
try {
|
|
16365
16379
|
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);
|
|
16366
|
-
return Number(t?.c ?? 0) > 0 ? !1 :
|
|
16380
|
+
return Number(t?.c ?? 0) > 0 ? !1 : vb(e, n) === null;
|
|
16367
16381
|
} catch (e) {
|
|
16368
16382
|
return console.warn("Vector migration runner idle peek failed", e), !1;
|
|
16369
16383
|
}
|
|
@@ -16371,7 +16385,7 @@ var yb = class {
|
|
|
16371
16385
|
};
|
|
16372
16386
|
//#endregion
|
|
16373
16387
|
//#region src/sync-bootstrap.ts
|
|
16374
|
-
async function
|
|
16388
|
+
async function xb(e, t, n, r) {
|
|
16375
16389
|
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;
|
|
16376
16390
|
for (;;) {
|
|
16377
16391
|
let r = new URLSearchParams({
|
|
@@ -16390,7 +16404,7 @@ async function bb(e, t, n, r) {
|
|
|
16390
16404
|
bootstrapGrantId: s,
|
|
16391
16405
|
keysDir: o
|
|
16392
16406
|
}),
|
|
16393
|
-
[
|
|
16407
|
+
[qy]: Jy
|
|
16394
16408
|
},
|
|
16395
16409
|
timeoutS: a
|
|
16396
16410
|
});
|
|
@@ -16414,7 +16428,7 @@ async function bb(e, t, n, r) {
|
|
|
16414
16428
|
...d
|
|
16415
16429
|
};
|
|
16416
16430
|
}
|
|
16417
|
-
function
|
|
16431
|
+
function Sb(e) {
|
|
16418
16432
|
if (!e.payload_json) return null;
|
|
16419
16433
|
try {
|
|
16420
16434
|
let t = JSON.parse(e.payload_json);
|
|
@@ -16423,23 +16437,23 @@ function xb(e) {
|
|
|
16423
16437
|
return null;
|
|
16424
16438
|
}
|
|
16425
16439
|
}
|
|
16426
|
-
function
|
|
16440
|
+
function Cb(e) {
|
|
16427
16441
|
return `${typeof e.title == "string" ? e.title : ""}\n${typeof e.body_text == "string" ? e.body_text : ""}`.trim().length > 0;
|
|
16428
16442
|
}
|
|
16429
|
-
function
|
|
16443
|
+
function wb(e) {
|
|
16430
16444
|
if (typeof e != "string") return null;
|
|
16431
16445
|
let t = e.trim();
|
|
16432
16446
|
return t.length > 0 ? t : null;
|
|
16433
16447
|
}
|
|
16434
|
-
function
|
|
16435
|
-
return t ||
|
|
16448
|
+
function Tb(e, t) {
|
|
16449
|
+
return t || wb(e.scope_id);
|
|
16436
16450
|
}
|
|
16437
|
-
var
|
|
16438
|
-
function
|
|
16439
|
-
let r = n ?? "__none__", i =
|
|
16451
|
+
var Eb = /* @__PURE__ */ new Map();
|
|
16452
|
+
function Db(e, t, n) {
|
|
16453
|
+
let r = n ?? "__none__", i = Eb.get(r);
|
|
16440
16454
|
if (i != null) return i;
|
|
16441
16455
|
let a = n ? `__sync_bootstrap__:${n}` : "__sync_bootstrap__", o = e.select({ id: U.id }).from(U).where(k(U.cwd, a)).limit(1).get();
|
|
16442
|
-
if (o) return
|
|
16456
|
+
if (o) return Eb.set(r, o.id), o.id;
|
|
16443
16457
|
let s = e.insert(U).values({
|
|
16444
16458
|
started_at: t,
|
|
16445
16459
|
cwd: a,
|
|
@@ -16447,25 +16461,25 @@ function Eb(e, t, n) {
|
|
|
16447
16461
|
user: "sync",
|
|
16448
16462
|
tool_version: "bootstrap"
|
|
16449
16463
|
}).returning({ id: U.id }).all()[0]?.id ?? 0;
|
|
16450
|
-
return
|
|
16464
|
+
return Eb.set(r, s), s;
|
|
16451
16465
|
}
|
|
16452
|
-
function
|
|
16466
|
+
function Ob(e, t, n, r, i) {
|
|
16453
16467
|
let a = {
|
|
16454
16468
|
ok: !1,
|
|
16455
16469
|
applied: 0,
|
|
16456
16470
|
deleted: 0
|
|
16457
|
-
}, o = i ?? new dl(), s =
|
|
16471
|
+
}, o = i ?? new dl(), s = wb(r.scope_id), c = s ? k(W.scope_id, s) : ve(pe(W.scope_id), k(W.scope_id, Su));
|
|
16458
16472
|
return e.transaction(() => {
|
|
16459
16473
|
let i = N(e, { schema: H }), l = 0;
|
|
16460
|
-
a.deleted = i.delete(W).where(O(fe(W.import_key), c, _e(M`COALESCE(${W.visibility}, '')`, "private"))).run().changes,
|
|
16474
|
+
a.deleted = i.delete(W).where(O(fe(W.import_key), c, _e(M`COALESCE(${W.visibility}, '')`, "private"))).run().changes, Eb.clear();
|
|
16461
16475
|
for (let e of n) {
|
|
16462
|
-
let t =
|
|
16476
|
+
let t = Sb(e);
|
|
16463
16477
|
if (!t) continue;
|
|
16464
16478
|
gl(t, o);
|
|
16465
|
-
let n =
|
|
16479
|
+
let n = Tb(t, s), r = typeof t.project == "string" && t.project.trim() ? t.project.trim() : null, c = Db(i, (/* @__PURE__ */ new Date()).toISOString(), r), u = t.metadata_json, d = u && typeof u == "object" && !Array.isArray(u) ? u : {};
|
|
16466
16480
|
d.clock_device_id = e.clock_device_id;
|
|
16467
16481
|
let f = e.op_type === "delete";
|
|
16468
|
-
!f &&
|
|
16482
|
+
!f && Cb(t) && l++, i.insert(W).values({
|
|
16469
16483
|
session_id: c,
|
|
16470
16484
|
kind: typeof t.kind == "string" ? t.kind : "discovery",
|
|
16471
16485
|
title: typeof t.title == "string" ? t.title : "",
|
|
@@ -16502,16 +16516,16 @@ function Db(e, t, n, r, i) {
|
|
|
16502
16516
|
generation: r.generation,
|
|
16503
16517
|
snapshot_id: r.snapshot_id,
|
|
16504
16518
|
baseline_cursor: r.baseline_cursor
|
|
16505
|
-
}, r.scope_id),
|
|
16519
|
+
}, r.scope_id), db(e, { embeddableTotal: l }), a.ok = !0;
|
|
16506
16520
|
}).immediate(), a;
|
|
16507
16521
|
}
|
|
16508
16522
|
//#endregion
|
|
16509
16523
|
//#region src/sync-discovery.ts
|
|
16510
|
-
var
|
|
16511
|
-
function
|
|
16524
|
+
var kb = Ee(import.meta.url), Ab = "_codemem._tcp.local.";
|
|
16525
|
+
function jb(e) {
|
|
16512
16526
|
return e.mdns.length === 0 ? yl(e.stored, []) : yl(e.mdns, e.stored);
|
|
16513
16527
|
}
|
|
16514
|
-
function
|
|
16528
|
+
function Mb(e, t) {
|
|
16515
16529
|
let n = N(e, { schema: H }).select({ addresses_json: Y.addresses_json }).from(Y).where(k(Y.peer_device_id, t)).get();
|
|
16516
16530
|
if (!n?.addresses_json) return [];
|
|
16517
16531
|
try {
|
|
@@ -16521,8 +16535,8 @@ function jb(e, t) {
|
|
|
16521
16535
|
return [];
|
|
16522
16536
|
}
|
|
16523
16537
|
}
|
|
16524
|
-
function
|
|
16525
|
-
let i = yl(
|
|
16538
|
+
function Nb(e, t, n, r) {
|
|
16539
|
+
let i = yl(Mb(e, t), n), a = (/* @__PURE__ */ new Date()).toISOString(), o = JSON.stringify(i);
|
|
16526
16540
|
return N(e, { schema: H }).insert(Y).values({
|
|
16527
16541
|
peer_device_id: t,
|
|
16528
16542
|
name: r?.name ?? null,
|
|
@@ -16542,7 +16556,7 @@ function Mb(e, t, n, r) {
|
|
|
16542
16556
|
}
|
|
16543
16557
|
}).run(), i;
|
|
16544
16558
|
}
|
|
16545
|
-
function
|
|
16559
|
+
function Pb(e, t, n) {
|
|
16546
16560
|
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
16547
16561
|
r.insert(ft).values({
|
|
16548
16562
|
peer_device_id: t,
|
|
@@ -16557,10 +16571,10 @@ function Nb(e, t, n) {
|
|
|
16557
16571
|
last_error: null
|
|
16558
16572
|
}).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();
|
|
16559
16573
|
}
|
|
16560
|
-
function
|
|
16574
|
+
function Fb(e, t, n) {
|
|
16561
16575
|
let r = _l(n ?? ""), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
16562
16576
|
return e.transaction((t, n, r) => {
|
|
16563
|
-
let i =
|
|
16577
|
+
let i = Mb(e, t), a = n ? i.filter((e) => _l(e) !== n) : i, o = n ? [n, ...a] : i;
|
|
16564
16578
|
return N(e, { schema: H }).update(Y).set({
|
|
16565
16579
|
addresses_json: JSON.stringify(o),
|
|
16566
16580
|
last_sync_at: r,
|
|
@@ -16569,18 +16583,18 @@ function Pb(e, t, n) {
|
|
|
16569
16583
|
}).where(k(Y.peer_device_id, t)).run(), o;
|
|
16570
16584
|
}).immediate(t, r, i);
|
|
16571
16585
|
}
|
|
16572
|
-
function
|
|
16586
|
+
function Ib(e, t, n) {
|
|
16573
16587
|
let r = n.include === null ? null : JSON.stringify(n.include), i = n.exclude === null ? null : JSON.stringify(n.exclude);
|
|
16574
16588
|
N(e, { schema: H }).update(Y).set({
|
|
16575
16589
|
projects_include_json: r,
|
|
16576
16590
|
projects_exclude_json: i
|
|
16577
16591
|
}).where(k(Y.peer_device_id, t)).run();
|
|
16578
16592
|
}
|
|
16579
|
-
function
|
|
16593
|
+
function Lb(e, t, n) {
|
|
16580
16594
|
N(e, { schema: H }).update(Y).set({ claimed_local_actor: +!!n }).where(k(Y.peer_device_id, t)).run();
|
|
16581
16595
|
}
|
|
16582
|
-
var
|
|
16583
|
-
function
|
|
16596
|
+
var Rb = "codemem";
|
|
16597
|
+
function zb() {
|
|
16584
16598
|
let e = process.env.CODEMEM_SYNC_MDNS;
|
|
16585
16599
|
if (e) return e === "1" || e.toLowerCase() === "true";
|
|
16586
16600
|
try {
|
|
@@ -16589,9 +16603,9 @@ function Rb() {
|
|
|
16589
16603
|
return !1;
|
|
16590
16604
|
}
|
|
16591
16605
|
}
|
|
16592
|
-
function
|
|
16606
|
+
function Bb() {
|
|
16593
16607
|
try {
|
|
16594
|
-
let e =
|
|
16608
|
+
let e = kb("bonjour-service"), t = e.Bonjour ?? e.default;
|
|
16595
16609
|
return t ? new t(void 0, (e) => {
|
|
16596
16610
|
console.warn("[codemem] mDNS runtime error (non-fatal):", e?.message ?? e);
|
|
16597
16611
|
}) : null;
|
|
@@ -16599,40 +16613,40 @@ function zb() {
|
|
|
16599
16613
|
return null;
|
|
16600
16614
|
}
|
|
16601
16615
|
}
|
|
16602
|
-
var
|
|
16603
|
-
function Hb() {
|
|
16604
|
-
if (Bb) return Vb += 1, Bb;
|
|
16605
|
-
let e = zb();
|
|
16606
|
-
return e ? (Bb = e, Vb = 1, Bb) : null;
|
|
16607
|
-
}
|
|
16616
|
+
var Vb = null, Hb = 0;
|
|
16608
16617
|
function Ub() {
|
|
16609
|
-
if (
|
|
16610
|
-
let e = Bb;
|
|
16611
|
-
|
|
16618
|
+
if (Vb) return Hb += 1, Vb;
|
|
16619
|
+
let e = Bb();
|
|
16620
|
+
return e ? (Vb = e, Hb = 1, Vb) : null;
|
|
16621
|
+
}
|
|
16622
|
+
function Wb() {
|
|
16623
|
+
if (!Vb || (Hb = Math.max(0, Hb - 1), Hb > 0)) return;
|
|
16624
|
+
let e = Vb;
|
|
16625
|
+
Vb = null;
|
|
16612
16626
|
try {
|
|
16613
16627
|
e.destroy();
|
|
16614
16628
|
} catch {}
|
|
16615
16629
|
}
|
|
16616
|
-
function
|
|
16617
|
-
if (!
|
|
16618
|
-
let n =
|
|
16630
|
+
function Gb(e, t) {
|
|
16631
|
+
if (!zb() || !e || !t || !Number.isFinite(t)) return { close() {} };
|
|
16632
|
+
let n = Ub();
|
|
16619
16633
|
if (!n) return { close() {} };
|
|
16620
16634
|
let r = null;
|
|
16621
16635
|
try {
|
|
16622
16636
|
r = n.publish({
|
|
16623
16637
|
name: `codemem-${e.slice(0, 12)}`,
|
|
16624
|
-
type:
|
|
16638
|
+
type: Rb,
|
|
16625
16639
|
port: t,
|
|
16626
16640
|
txt: { device_id: e }
|
|
16627
16641
|
});
|
|
16628
16642
|
} catch {
|
|
16629
|
-
return
|
|
16643
|
+
return Wb(), { close() {} };
|
|
16630
16644
|
}
|
|
16631
16645
|
let i = !1;
|
|
16632
16646
|
return { close() {
|
|
16633
16647
|
if (i) return;
|
|
16634
16648
|
i = !0;
|
|
16635
|
-
let e = () =>
|
|
16649
|
+
let e = () => Wb();
|
|
16636
16650
|
try {
|
|
16637
16651
|
r?.stop(() => e());
|
|
16638
16652
|
} catch {
|
|
@@ -16640,13 +16654,13 @@ function Wb(e, t) {
|
|
|
16640
16654
|
}
|
|
16641
16655
|
} };
|
|
16642
16656
|
}
|
|
16643
|
-
async function
|
|
16644
|
-
if (!
|
|
16645
|
-
let t =
|
|
16657
|
+
async function Kb(e = 1500) {
|
|
16658
|
+
if (!zb()) return [];
|
|
16659
|
+
let t = Ub();
|
|
16646
16660
|
if (!t) return [];
|
|
16647
16661
|
let n = [], r = /* @__PURE__ */ new Set(), i = !0, a = null;
|
|
16648
16662
|
try {
|
|
16649
|
-
a = t.find({ type:
|
|
16663
|
+
a = t.find({ type: Rb }, (e) => {
|
|
16650
16664
|
if (!i) return;
|
|
16651
16665
|
let t = `${e.name}|${e.host ?? e.fqdn ?? ""}|${e.port}`;
|
|
16652
16666
|
if (r.has(t)) return;
|
|
@@ -16666,11 +16680,11 @@ async function Gb(e = 1500) {
|
|
|
16666
16680
|
try {
|
|
16667
16681
|
a?.stop();
|
|
16668
16682
|
} catch {}
|
|
16669
|
-
|
|
16683
|
+
Wb();
|
|
16670
16684
|
}
|
|
16671
16685
|
return n;
|
|
16672
16686
|
}
|
|
16673
|
-
function
|
|
16687
|
+
function qb(e, t) {
|
|
16674
16688
|
let n = [];
|
|
16675
16689
|
for (let r of t) {
|
|
16676
16690
|
let t = r.properties ?? {}, i = t.device_id ?? t.device_id;
|
|
@@ -16684,56 +16698,56 @@ function Kb(e, t) {
|
|
|
16684
16698
|
}
|
|
16685
16699
|
//#endregion
|
|
16686
16700
|
//#region src/sync-pass.ts
|
|
16687
|
-
var
|
|
16688
|
-
function
|
|
16701
|
+
var Jb = 1048576, Yb = !1, Xb = 500, Zb = 2e3, Qb = "2";
|
|
16702
|
+
function $b(e, t) {
|
|
16689
16703
|
return !t || !t.includes("|") ? !1 : e ? t > e : !0;
|
|
16690
16704
|
}
|
|
16691
|
-
function
|
|
16705
|
+
function ex(e) {
|
|
16692
16706
|
if (!e) return null;
|
|
16693
16707
|
let t = e.error, n = e.reason;
|
|
16694
16708
|
return typeof t == "string" && typeof n == "string" ? `${t}:${n}` : typeof t == "string" ? t : null;
|
|
16695
16709
|
}
|
|
16696
|
-
function
|
|
16710
|
+
function tx(e) {
|
|
16697
16711
|
return e.length === 0 ? null : `all addresses failed | ${e.map((e) => `${e.address}: ${e.error}`).join(" || ")}`;
|
|
16698
16712
|
}
|
|
16699
|
-
function
|
|
16713
|
+
function nx(e) {
|
|
16700
16714
|
if (typeof e != "string") return null;
|
|
16701
16715
|
let t = e.trim();
|
|
16702
16716
|
return t.length > 0 ? t : null;
|
|
16703
16717
|
}
|
|
16704
|
-
function
|
|
16718
|
+
function rx(e) {
|
|
16705
16719
|
let t = e?.sync_reset;
|
|
16706
16720
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
16707
16721
|
let n = t;
|
|
16708
16722
|
if (!Number.isFinite(n.generation) || typeof n.snapshot_id != "string" || n.snapshot_id.trim().length === 0) return null;
|
|
16709
|
-
let r =
|
|
16723
|
+
let r = nx(n.baseline_cursor);
|
|
16710
16724
|
return {
|
|
16711
|
-
scope_id:
|
|
16725
|
+
scope_id: nx(n.scope_id),
|
|
16712
16726
|
generation: Number(n.generation),
|
|
16713
16727
|
snapshot_id: n.snapshot_id.trim(),
|
|
16714
16728
|
baseline_cursor: r,
|
|
16715
|
-
retained_floor_cursor:
|
|
16729
|
+
retained_floor_cursor: nx(n.retained_floor_cursor)
|
|
16716
16730
|
};
|
|
16717
16731
|
}
|
|
16718
|
-
function
|
|
16732
|
+
function ix(e) {
|
|
16719
16733
|
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));
|
|
16720
16734
|
}
|
|
16721
|
-
function
|
|
16722
|
-
let t =
|
|
16735
|
+
function ax(e) {
|
|
16736
|
+
let t = Xy(e);
|
|
16723
16737
|
return {
|
|
16724
|
-
local:
|
|
16738
|
+
local: Jy,
|
|
16725
16739
|
peer: t,
|
|
16726
|
-
negotiated:
|
|
16740
|
+
negotiated: Zy(Jy, t)
|
|
16727
16741
|
};
|
|
16728
16742
|
}
|
|
16729
|
-
function ax() {
|
|
16730
|
-
return { [Ky]: qy };
|
|
16731
|
-
}
|
|
16732
16743
|
function ox() {
|
|
16733
|
-
return
|
|
16744
|
+
return { [qy]: Jy };
|
|
16745
|
+
}
|
|
16746
|
+
function sx() {
|
|
16747
|
+
return ax("unsupported");
|
|
16734
16748
|
}
|
|
16735
|
-
function
|
|
16736
|
-
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString(), a = n.capabilities ??
|
|
16749
|
+
function cx(e, t, n) {
|
|
16750
|
+
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString(), a = n.capabilities ?? sx();
|
|
16737
16751
|
r.insert(ft).values({
|
|
16738
16752
|
peer_device_id: t,
|
|
16739
16753
|
started_at: i,
|
|
@@ -16747,7 +16761,7 @@ function sx(e, t, n) {
|
|
|
16747
16761
|
negotiated_sync_capability: a.negotiated
|
|
16748
16762
|
}).run();
|
|
16749
16763
|
}
|
|
16750
|
-
function
|
|
16764
|
+
function lx(e, t, n, r) {
|
|
16751
16765
|
let i = N(e, { schema: H }), { replicationOps: a } = H, o;
|
|
16752
16766
|
if (t) {
|
|
16753
16767
|
let e = t.indexOf("|"), s = e >= 0 ? t.slice(0, e) : t, c = e >= 0 ? t.slice(e + 1) : "";
|
|
@@ -16759,12 +16773,12 @@ function cx(e, t, n, r) {
|
|
|
16759
16773
|
let c = `${s.created_at}|${s.op_id}`;
|
|
16760
16774
|
return [o, c];
|
|
16761
16775
|
}
|
|
16762
|
-
var
|
|
16763
|
-
async function
|
|
16776
|
+
var ux = 8;
|
|
16777
|
+
async function dx(e, t, n, r, i = 0) {
|
|
16764
16778
|
if (n.length === 0) return;
|
|
16765
16779
|
let a = {
|
|
16766
16780
|
ops: n,
|
|
16767
|
-
sync_capability:
|
|
16781
|
+
sync_capability: Jy
|
|
16768
16782
|
}, o = Buffer.from(JSON.stringify(a), "utf-8"), [s, c] = await xl("POST", e, {
|
|
16769
16783
|
headers: {
|
|
16770
16784
|
..._r({
|
|
@@ -16774,28 +16788,28 @@ async function ux(e, t, n, r, i = 0) {
|
|
|
16774
16788
|
bodyBytes: o,
|
|
16775
16789
|
keysDir: r
|
|
16776
16790
|
}),
|
|
16777
|
-
...
|
|
16791
|
+
...ox()
|
|
16778
16792
|
},
|
|
16779
16793
|
body: a,
|
|
16780
16794
|
bodyBytes: o
|
|
16781
16795
|
});
|
|
16782
16796
|
if (s === 200 && c != null) return;
|
|
16783
|
-
let l =
|
|
16784
|
-
if (s === 413 && n.length > 1 && i <
|
|
16797
|
+
let l = ex(c);
|
|
16798
|
+
if (s === 413 && n.length > 1 && i < ux && (l === "payload_too_large" || l === "too_many_ops")) {
|
|
16785
16799
|
let a = Math.floor(n.length / 2);
|
|
16786
|
-
await
|
|
16800
|
+
await dx(e, t, n.slice(0, a), r, i + 1), await dx(e, t, n.slice(a), r, i + 1);
|
|
16787
16801
|
return;
|
|
16788
16802
|
}
|
|
16789
16803
|
let u = l ? ` (${s}: ${l})` : ` (${s})`;
|
|
16790
16804
|
throw Error(`peer ops push failed${u}`);
|
|
16791
16805
|
}
|
|
16792
|
-
function
|
|
16806
|
+
function fx(e) {
|
|
16793
16807
|
Hn(e), qd(e, 2e3), Jd(e, 200);
|
|
16794
16808
|
}
|
|
16795
|
-
async function
|
|
16809
|
+
async function px(e, t, n, r) {
|
|
16796
16810
|
Hn(e);
|
|
16797
|
-
let i = r?.limit ??
|
|
16798
|
-
!o && !
|
|
16811
|
+
let i = r?.limit ?? Xb, a = r?.keysDir, o = r?.scanner;
|
|
16812
|
+
!o && !Yb && (Yb = !0, process.stderr.write("[codemem] sync apply running without explicit scanner — workspace-level secret rules will not apply to inbound peer content\n"));
|
|
16799
16813
|
let s = N(e, { schema: H }).select({ pinned_fingerprint: Y.pinned_fingerprint }).from(Y).where(k(Y.peer_device_id, t)).get()?.pinned_fingerprint ?? "";
|
|
16800
16814
|
if (!s) return {
|
|
16801
16815
|
ok: !1,
|
|
@@ -16809,7 +16823,7 @@ async function fx(e, t, n, r) {
|
|
|
16809
16823
|
[u] = dr(e, { keysDir: a });
|
|
16810
16824
|
} catch (n) {
|
|
16811
16825
|
let r = `device identity unavailable: ${n instanceof Error ? n.message.trim() || n.constructor.name : "unknown"}`;
|
|
16812
|
-
return
|
|
16826
|
+
return cx(e, t, {
|
|
16813
16827
|
ok: !1,
|
|
16814
16828
|
error: r
|
|
16815
16829
|
}), {
|
|
@@ -16834,15 +16848,15 @@ async function fx(e, t, n, r) {
|
|
|
16834
16848
|
bodyBytes: Buffer.alloc(0),
|
|
16835
16849
|
keysDir: a
|
|
16836
16850
|
}),
|
|
16837
|
-
...
|
|
16851
|
+
...ox()
|
|
16838
16852
|
} });
|
|
16839
16853
|
if (d !== 200 || !f) {
|
|
16840
|
-
let e =
|
|
16854
|
+
let e = ex(f), t = e ? ` (${d}: ${e})` : ` (${d})`;
|
|
16841
16855
|
throw Error(`peer status failed${t}`);
|
|
16842
16856
|
}
|
|
16843
16857
|
if (f.fingerprint !== s) throw Error("peer fingerprint mismatch");
|
|
16844
|
-
if (p =
|
|
16845
|
-
let m =
|
|
16858
|
+
if (p = ax(f.sync_capability), String(f.protocol_version ?? "") !== Qb) throw Error(`peer protocol mismatch (expected ${Qb}, got ${String(f.protocol_version ?? "missing")})`);
|
|
16859
|
+
let m = rx(f);
|
|
16846
16860
|
if (!m) throw Error("peer status missing sync_reset boundary");
|
|
16847
16861
|
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 {
|
|
16848
16862
|
let r = {
|
|
@@ -16853,11 +16867,11 @@ async function fx(e, t, n, r) {
|
|
|
16853
16867
|
retained_floor_cursor: m.retained_floor_cursor ?? null,
|
|
16854
16868
|
reset_required: !0,
|
|
16855
16869
|
reason: "initial_bootstrap"
|
|
16856
|
-
}, { items: i } = await
|
|
16870
|
+
}, { items: i } = await xb(n, r, u, {
|
|
16857
16871
|
keysDir: a,
|
|
16858
|
-
pageSize:
|
|
16872
|
+
pageSize: Zb
|
|
16859
16873
|
}), s = Number(e.prepare("SELECT count(*) as n FROM memory_items WHERE import_key IS NOT NULL").get()?.n ?? 0);
|
|
16860
|
-
if (s > 0) return
|
|
16874
|
+
if (s > 0) return cx(e, t, {
|
|
16861
16875
|
ok: !1,
|
|
16862
16876
|
error: "needs_attention:shared_memories_appeared_during_bootstrap",
|
|
16863
16877
|
capabilities: p
|
|
@@ -16869,9 +16883,9 @@ async function fx(e, t, n, r) {
|
|
|
16869
16883
|
opsOut: 0,
|
|
16870
16884
|
addressErrors: []
|
|
16871
16885
|
};
|
|
16872
|
-
let c =
|
|
16886
|
+
let c = Ob(e, t, i, r, o);
|
|
16873
16887
|
if (!c.ok) throw Error("initial bootstrap apply failed");
|
|
16874
|
-
return
|
|
16888
|
+
return Fb(e, t, n), cx(e, t, {
|
|
16875
16889
|
ok: !0,
|
|
16876
16890
|
opsIn: c.applied,
|
|
16877
16891
|
opsOut: 0,
|
|
@@ -16902,7 +16916,7 @@ async function fx(e, t, n, r) {
|
|
|
16902
16916
|
bodyBytes: Buffer.alloc(0),
|
|
16903
16917
|
keysDir: a
|
|
16904
16918
|
}),
|
|
16905
|
-
...
|
|
16919
|
+
...ox()
|
|
16906
16920
|
} });
|
|
16907
16921
|
if (_ === 409 && v?.reset_required === !0) {
|
|
16908
16922
|
let r = ad(e), i = {
|
|
@@ -16914,7 +16928,7 @@ async function fx(e, t, n, r) {
|
|
|
16914
16928
|
baseline_cursor: typeof v.baseline_cursor == "string" && v.baseline_cursor.trim() ? v.baseline_cursor.trim() : null,
|
|
16915
16929
|
retained_floor_cursor: typeof v.retained_floor_cursor == "string" && v.retained_floor_cursor.trim() ? v.retained_floor_cursor.trim() : null
|
|
16916
16930
|
};
|
|
16917
|
-
if (r.dirty) return
|
|
16931
|
+
if (r.dirty) return cx(e, t, {
|
|
16918
16932
|
ok: !1,
|
|
16919
16933
|
error: `needs_attention:local_unsynced_shared_memory:${r.count}`,
|
|
16920
16934
|
capabilities: p
|
|
@@ -16928,8 +16942,8 @@ async function fx(e, t, n, r) {
|
|
|
16928
16942
|
resetRequired: i
|
|
16929
16943
|
};
|
|
16930
16944
|
try {
|
|
16931
|
-
let { items: r } = await
|
|
16932
|
-
if (s.dirty) return
|
|
16945
|
+
let { items: r } = await xb(n, i, u, { keysDir: a }), s = ad(e);
|
|
16946
|
+
if (s.dirty) return cx(e, t, {
|
|
16933
16947
|
ok: !1,
|
|
16934
16948
|
error: `needs_attention:local_unsynced_shared_memory:${s.count}`,
|
|
16935
16949
|
capabilities: p
|
|
@@ -16942,9 +16956,9 @@ async function fx(e, t, n, r) {
|
|
|
16942
16956
|
addressErrors: [],
|
|
16943
16957
|
resetRequired: i
|
|
16944
16958
|
};
|
|
16945
|
-
let c =
|
|
16959
|
+
let c = Ob(e, t, r, i, o);
|
|
16946
16960
|
if (!c.ok) throw Error("bootstrap apply failed");
|
|
16947
|
-
return
|
|
16961
|
+
return Fb(e, t, n), cx(e, t, {
|
|
16948
16962
|
ok: !0,
|
|
16949
16963
|
opsIn: c.applied,
|
|
16950
16964
|
opsOut: 0,
|
|
@@ -16958,7 +16972,7 @@ async function fx(e, t, n, r) {
|
|
|
16958
16972
|
};
|
|
16959
16973
|
} catch (r) {
|
|
16960
16974
|
let a = r instanceof Error ? r.message : String(r);
|
|
16961
|
-
return
|
|
16975
|
+
return cx(e, t, {
|
|
16962
16976
|
ok: !1,
|
|
16963
16977
|
error: `bootstrap_failed:${a}`,
|
|
16964
16978
|
capabilities: p
|
|
@@ -16974,10 +16988,10 @@ async function fx(e, t, n, r) {
|
|
|
16974
16988
|
}
|
|
16975
16989
|
}
|
|
16976
16990
|
if (_ !== 200 || v == null) {
|
|
16977
|
-
let e =
|
|
16991
|
+
let e = ex(v), t = e ? ` (${_}: ${e})` : ` (${_})`;
|
|
16978
16992
|
throw Error(`peer ops fetch failed${t}`);
|
|
16979
16993
|
}
|
|
16980
|
-
if (!
|
|
16994
|
+
if (!ix(v)) throw Error("invalid ops response");
|
|
16981
16995
|
let y = Xu(v), b = y.find((e) => e.device_id !== t || e.clock_device_id !== t);
|
|
16982
16996
|
if (b) throw Error(`inbound op device mismatch:${b.op_id}`);
|
|
16983
16997
|
let x = p?.negotiated === "unsupported" ? {
|
|
@@ -16989,7 +17003,7 @@ async function fx(e, t, n, r) {
|
|
|
16989
17003
|
throw Error(`inbound scope rejected:${e}`);
|
|
16990
17004
|
}
|
|
16991
17005
|
try {
|
|
16992
|
-
|
|
17006
|
+
lb(e, S.vectorWork);
|
|
16993
17007
|
} catch (t) {
|
|
16994
17008
|
let n = await Ds(e, S.vectorWork);
|
|
16995
17009
|
if (n.errors.length > 0) {
|
|
@@ -16997,15 +17011,15 @@ async function fx(e, t, n, r) {
|
|
|
16997
17011
|
throw Error(`vector catch-up queue failed: ${t instanceof Error ? t.message : String(t)}; fallback failed: ${e}`);
|
|
16998
17012
|
}
|
|
16999
17013
|
}
|
|
17000
|
-
let C =
|
|
17001
|
-
|
|
17002
|
-
let [w, ee] =
|
|
17014
|
+
let C = nx(v.next_cursor);
|
|
17015
|
+
$b(c, C) && (Ju(e, t, { lastApplied: C }), c = C);
|
|
17016
|
+
let [w, ee] = lx(e, l, u, i), [T, te, ne] = Ad(e, w, t, { localDeviceId: u }), re = ne?.skipped_count ?? 0, ie = `${n}/v1/ops`;
|
|
17003
17017
|
if (T.length > 0) {
|
|
17004
|
-
let e = Uu(T,
|
|
17005
|
-
for (let t of e) await
|
|
17018
|
+
let e = Uu(T, Jb);
|
|
17019
|
+
for (let t of e) await dx(ie, u, t, a);
|
|
17006
17020
|
}
|
|
17007
17021
|
let ae = te ?? ee;
|
|
17008
|
-
return ae &&
|
|
17022
|
+
return ae && $b(l, ae) && (Ju(e, t, { lastAcked: ae }), l = ae), Fb(e, t, n), cx(e, t, {
|
|
17009
17023
|
ok: !0,
|
|
17010
17024
|
opsIn: S.applied,
|
|
17011
17025
|
opsOut: T.length,
|
|
@@ -17028,8 +17042,8 @@ async function fx(e, t, n, r) {
|
|
|
17028
17042
|
}
|
|
17029
17043
|
}
|
|
17030
17044
|
}
|
|
17031
|
-
let m =
|
|
17032
|
-
return f || (m = "no dialable peer addresses"), m ||= "sync failed without diagnostic detail",
|
|
17045
|
+
let m = tx(d);
|
|
17046
|
+
return f || (m = "no dialable peer addresses"), m ||= "sync failed without diagnostic detail", cx(e, t, {
|
|
17033
17047
|
ok: !1,
|
|
17034
17048
|
error: m,
|
|
17035
17049
|
capabilities: p
|
|
@@ -17041,15 +17055,15 @@ async function fx(e, t, n, r) {
|
|
|
17041
17055
|
addressErrors: d
|
|
17042
17056
|
};
|
|
17043
17057
|
}
|
|
17044
|
-
async function
|
|
17058
|
+
async function mx(e, t, n) {
|
|
17045
17059
|
let r = N(e, { schema: H }).select({ addresses_json: Y.addresses_json }).from(Y).where(k(Y.peer_device_id, t)).get(), i = [];
|
|
17046
17060
|
if (r?.addresses_json) try {
|
|
17047
17061
|
let e = JSON.parse(r.addresses_json);
|
|
17048
17062
|
Array.isArray(e) && (i = e.filter((e) => typeof e == "string"));
|
|
17049
17063
|
} catch {}
|
|
17050
|
-
return
|
|
17064
|
+
return px(e, t, i, n);
|
|
17051
17065
|
}
|
|
17052
|
-
var
|
|
17066
|
+
var hx = [
|
|
17053
17067
|
"no route to host",
|
|
17054
17068
|
"connection refused",
|
|
17055
17069
|
"network is unreachable",
|
|
@@ -17060,33 +17074,33 @@ var mx = [
|
|
|
17060
17074
|
"errno 61",
|
|
17061
17075
|
"errno 60",
|
|
17062
17076
|
"errno 111"
|
|
17063
|
-
],
|
|
17064
|
-
function
|
|
17077
|
+
], gx = 120, _x = 1800;
|
|
17078
|
+
function vx(e) {
|
|
17065
17079
|
if (!e) return !1;
|
|
17066
17080
|
let t = e.toLowerCase();
|
|
17067
|
-
return
|
|
17081
|
+
return hx.some((e) => t.includes(e));
|
|
17068
17082
|
}
|
|
17069
|
-
function
|
|
17083
|
+
function yx(e, t, n = 10) {
|
|
17070
17084
|
let r = N(e, { schema: H }).select({
|
|
17071
17085
|
ok: ft.ok,
|
|
17072
17086
|
error: ft.error
|
|
17073
17087
|
}).from(ft).where(k(ft.peer_device_id, t)).orderBy(ue(ft.started_at)).limit(n).all(), i = 0;
|
|
17074
17088
|
for (let e of r) {
|
|
17075
17089
|
if (e.ok) break;
|
|
17076
|
-
if (
|
|
17090
|
+
if (vx(e.error)) i++;
|
|
17077
17091
|
else break;
|
|
17078
17092
|
}
|
|
17079
17093
|
return i;
|
|
17080
17094
|
}
|
|
17081
|
-
function
|
|
17095
|
+
function bx(e) {
|
|
17082
17096
|
if (e <= 1) return 0;
|
|
17083
17097
|
let t = Math.min(e - 1, 8);
|
|
17084
|
-
return Math.min(
|
|
17098
|
+
return Math.min(gx * 2 ** (t - 1), _x) * (.5 + Math.random() * .5);
|
|
17085
17099
|
}
|
|
17086
|
-
function
|
|
17087
|
-
let n =
|
|
17100
|
+
function xx(e, t) {
|
|
17101
|
+
let n = yx(e, t);
|
|
17088
17102
|
if (n < 2) return !1;
|
|
17089
|
-
let r =
|
|
17103
|
+
let r = bx(n);
|
|
17090
17104
|
if (r <= 0) return !1;
|
|
17091
17105
|
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();
|
|
17092
17106
|
if (!i?.started_at) return !1;
|
|
@@ -17099,7 +17113,7 @@ function bx(e, t) {
|
|
|
17099
17113
|
}
|
|
17100
17114
|
//#endregion
|
|
17101
17115
|
//#region src/sync-daemon.ts
|
|
17102
|
-
function
|
|
17116
|
+
function Sx(e) {
|
|
17103
17117
|
let t = N(e, { schema: H }), n = (/* @__PURE__ */ new Date()).toISOString();
|
|
17104
17118
|
t.insert(mt).values({
|
|
17105
17119
|
id: 1,
|
|
@@ -17113,7 +17127,7 @@ function xx(e) {
|
|
|
17113
17127
|
}
|
|
17114
17128
|
}).run();
|
|
17115
17129
|
}
|
|
17116
|
-
function
|
|
17130
|
+
function Cx(e, t, n) {
|
|
17117
17131
|
let r = N(e, { schema: H }), i = (/* @__PURE__ */ new Date()).toISOString();
|
|
17118
17132
|
r.insert(mt).values({
|
|
17119
17133
|
id: 1,
|
|
@@ -17129,11 +17143,11 @@ function Sx(e, t, n) {
|
|
|
17129
17143
|
}
|
|
17130
17144
|
}).run();
|
|
17131
17145
|
}
|
|
17132
|
-
function
|
|
17146
|
+
function wx(e) {
|
|
17133
17147
|
let t = N(e, { schema: H }).select({ phase: mt.phase }).from(mt).where(k(mt.id, 1)).get()?.phase;
|
|
17134
17148
|
return t === "needs_attention" ? t : null;
|
|
17135
17149
|
}
|
|
17136
|
-
function
|
|
17150
|
+
function Tx(e, t) {
|
|
17137
17151
|
N(e, { schema: H }).insert(mt).values({
|
|
17138
17152
|
id: 1,
|
|
17139
17153
|
phase: t
|
|
@@ -17142,18 +17156,18 @@ function wx(e, t) {
|
|
|
17142
17156
|
set: { phase: t }
|
|
17143
17157
|
}).run();
|
|
17144
17158
|
}
|
|
17145
|
-
async function
|
|
17159
|
+
async function Ex(e, t, n) {
|
|
17146
17160
|
let r = Al();
|
|
17147
17161
|
return jl(r) ? (await Nl({
|
|
17148
17162
|
db: e,
|
|
17149
17163
|
dbPath: t
|
|
17150
17164
|
}, r, { keysDir: n }), await hu(e, r), !0) : !1;
|
|
17151
17165
|
}
|
|
17152
|
-
async function
|
|
17166
|
+
async function Dx(e, t, n, r) {
|
|
17153
17167
|
let i = N(e, { schema: H }).select({ peer_device_id: Y.peer_device_id }).from(Y).all();
|
|
17154
17168
|
if (i.length === 0) return [];
|
|
17155
17169
|
let a = Al().syncOpsLimit;
|
|
17156
|
-
|
|
17170
|
+
fx(e);
|
|
17157
17171
|
let o = [];
|
|
17158
17172
|
for (let s of i) {
|
|
17159
17173
|
let i = s.peer_device_id;
|
|
@@ -17165,7 +17179,7 @@ async function Ex(e, t, n, r) {
|
|
|
17165
17179
|
});
|
|
17166
17180
|
continue;
|
|
17167
17181
|
}
|
|
17168
|
-
if (
|
|
17182
|
+
if (xx(e, i)) {
|
|
17169
17183
|
o.push({
|
|
17170
17184
|
ok: !1,
|
|
17171
17185
|
skipped: !0,
|
|
@@ -17173,7 +17187,7 @@ async function Ex(e, t, n, r) {
|
|
|
17173
17187
|
});
|
|
17174
17188
|
continue;
|
|
17175
17189
|
}
|
|
17176
|
-
let c = await
|
|
17190
|
+
let c = await mx(e, i, {
|
|
17177
17191
|
keysDir: t,
|
|
17178
17192
|
limit: a,
|
|
17179
17193
|
scanner: r
|
|
@@ -17187,13 +17201,13 @@ async function Ex(e, t, n, r) {
|
|
|
17187
17201
|
}
|
|
17188
17202
|
return o;
|
|
17189
17203
|
}
|
|
17190
|
-
async function
|
|
17204
|
+
async function Ox(e) {
|
|
17191
17205
|
let t = e?.intervalS ?? 120, n = Dn(e?.dbPath), r = e?.keysDir, i = e?.signal, a = e?.onPhaseChange, o = e?.scanner;
|
|
17192
17206
|
a?.("starting");
|
|
17193
17207
|
let s = Mn(n), c = null;
|
|
17194
17208
|
try {
|
|
17195
17209
|
let [t] = dr(s, { keysDir: r });
|
|
17196
|
-
|
|
17210
|
+
zb() && e?.port && (c = Gb(t, e.port));
|
|
17197
17211
|
} finally {
|
|
17198
17212
|
s.close();
|
|
17199
17213
|
}
|
|
@@ -17203,7 +17217,7 @@ async function Dx(e) {
|
|
|
17203
17217
|
}
|
|
17204
17218
|
return new Promise((e) => {
|
|
17205
17219
|
let s = !1, l = !1, u = () => {
|
|
17206
|
-
s || (s = !0,
|
|
17220
|
+
s || (s = !0, kx(n, r, o).finally(() => {
|
|
17207
17221
|
s = !1, l || (l = !0, a?.("running"));
|
|
17208
17222
|
}));
|
|
17209
17223
|
}, d = setInterval(u, t * 1e3);
|
|
@@ -17220,38 +17234,38 @@ async function Dx(e) {
|
|
|
17220
17234
|
}
|
|
17221
17235
|
});
|
|
17222
17236
|
}
|
|
17223
|
-
async function
|
|
17237
|
+
async function kx(e, t, n) {
|
|
17224
17238
|
let r = Mn(e);
|
|
17225
17239
|
try {
|
|
17226
17240
|
Hn(r);
|
|
17227
17241
|
try {
|
|
17228
|
-
await
|
|
17242
|
+
await Ex(r, e, t);
|
|
17229
17243
|
} catch {}
|
|
17230
|
-
(await
|
|
17244
|
+
(await Dx(r, t, await Rl(r, e, t), n)).some((e) => !e.ok && e.error?.includes("needs_attention")) ? Tx(r, "needs_attention") : Sx(r);
|
|
17231
17245
|
} catch (e) {
|
|
17232
|
-
|
|
17246
|
+
Cx(r, e instanceof Error ? e.message : String(e), e instanceof Error ? e.stack ?? "" : "");
|
|
17233
17247
|
} finally {
|
|
17234
17248
|
r.close();
|
|
17235
17249
|
}
|
|
17236
17250
|
}
|
|
17237
17251
|
//#endregion
|
|
17238
17252
|
//#region src/sync-retention-runner.ts
|
|
17239
|
-
function
|
|
17253
|
+
function Ax(e) {
|
|
17240
17254
|
let t = String(e ?? "").trim();
|
|
17241
17255
|
return t.length > 0 ? t : Su;
|
|
17242
17256
|
}
|
|
17243
|
-
function
|
|
17257
|
+
function jx(e) {
|
|
17244
17258
|
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 ");
|
|
17245
17259
|
}
|
|
17246
|
-
function
|
|
17260
|
+
function Mx(e) {
|
|
17247
17261
|
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]);
|
|
17248
17262
|
for (let e of t) {
|
|
17249
|
-
let t =
|
|
17263
|
+
let t = Ax(e.scope_id);
|
|
17250
17264
|
n.add(t);
|
|
17251
17265
|
}
|
|
17252
17266
|
return Array.from(n);
|
|
17253
17267
|
}
|
|
17254
|
-
function
|
|
17268
|
+
function Nx(e, t, n, r) {
|
|
17255
17269
|
e.insert(vt).values({
|
|
17256
17270
|
scope_id: t,
|
|
17257
17271
|
...n
|
|
@@ -17266,7 +17280,7 @@ function Mx(e, t, n, r) {
|
|
|
17266
17280
|
set: n
|
|
17267
17281
|
}).run();
|
|
17268
17282
|
}
|
|
17269
|
-
function
|
|
17283
|
+
function Px(e, t, n, r, i) {
|
|
17270
17284
|
let a = i === Su;
|
|
17271
17285
|
try {
|
|
17272
17286
|
let o = dd(e, i), s = sd(e, {
|
|
@@ -17278,7 +17292,7 @@ function Nx(e, t, n, r, i) {
|
|
|
17278
17292
|
maxPasses: n.maxCatchUpPasses,
|
|
17279
17293
|
signal: n.signal
|
|
17280
17294
|
});
|
|
17281
|
-
|
|
17295
|
+
Nx(t, i, {
|
|
17282
17296
|
last_run_at: r,
|
|
17283
17297
|
last_duration_ms: Date.now() - Date.parse(r),
|
|
17284
17298
|
last_deleted_ops: s.totalDeleted,
|
|
@@ -17289,7 +17303,7 @@ function Nx(e, t, n, r, i) {
|
|
|
17289
17303
|
last_error_at: null
|
|
17290
17304
|
}, a);
|
|
17291
17305
|
} catch (e) {
|
|
17292
|
-
|
|
17306
|
+
Nx(t, i, {
|
|
17293
17307
|
last_run_at: r,
|
|
17294
17308
|
last_duration_ms: Date.now() - Date.parse(r),
|
|
17295
17309
|
last_deleted_ops: 0,
|
|
@@ -17301,13 +17315,13 @@ function Nx(e, t, n, r, i) {
|
|
|
17301
17315
|
}, a);
|
|
17302
17316
|
}
|
|
17303
17317
|
}
|
|
17304
|
-
async function
|
|
17318
|
+
async function Fx(e, t) {
|
|
17305
17319
|
if (!t.syncRetentionEnabled) return;
|
|
17306
|
-
|
|
17307
|
-
let n = N(e, { schema: H }), r = (/* @__PURE__ */ new Date()).toISOString(), i = t.scopeId === void 0 ?
|
|
17308
|
-
for (let a of i)
|
|
17320
|
+
jx(e);
|
|
17321
|
+
let n = N(e, { schema: H }), r = (/* @__PURE__ */ new Date()).toISOString(), i = t.scopeId === void 0 ? Mx(e) : [Ax(t.scopeId)];
|
|
17322
|
+
for (let a of i) Px(e, n, t, r, a);
|
|
17309
17323
|
}
|
|
17310
|
-
var
|
|
17324
|
+
var Ix = class {
|
|
17311
17325
|
dbPath;
|
|
17312
17326
|
signal;
|
|
17313
17327
|
active = !1;
|
|
@@ -17335,7 +17349,7 @@ var Fx = class {
|
|
|
17335
17349
|
if (!this.active || this.signal?.aborted) return;
|
|
17336
17350
|
let e = Al(Rt()), t = Mn(this.dbPath);
|
|
17337
17351
|
try {
|
|
17338
|
-
await
|
|
17352
|
+
await Fx(t, {
|
|
17339
17353
|
...e,
|
|
17340
17354
|
signal: this.signal
|
|
17341
17355
|
});
|
|
@@ -17343,8 +17357,8 @@ var Fx = class {
|
|
|
17343
17357
|
t.close();
|
|
17344
17358
|
}
|
|
17345
17359
|
}
|
|
17346
|
-
},
|
|
17347
|
-
function
|
|
17360
|
+
}, Lx = "scope_id";
|
|
17361
|
+
function Rx(e, t) {
|
|
17348
17362
|
return t ? typeof e == "string" && e.trim() ? {
|
|
17349
17363
|
ok: !1,
|
|
17350
17364
|
reason: "unsupported_scope"
|
|
@@ -17357,31 +17371,31 @@ function Lx(e, t) {
|
|
|
17357
17371
|
scope_id: null
|
|
17358
17372
|
};
|
|
17359
17373
|
}
|
|
17360
|
-
function
|
|
17374
|
+
function zx(e, t) {
|
|
17361
17375
|
return {
|
|
17362
17376
|
...e,
|
|
17363
17377
|
scope_id: t
|
|
17364
17378
|
};
|
|
17365
17379
|
}
|
|
17366
|
-
function
|
|
17380
|
+
function Bx(e, t, n) {
|
|
17367
17381
|
return {
|
|
17368
17382
|
error: "reset_required",
|
|
17369
17383
|
reset_required: !0,
|
|
17370
17384
|
sync_capability: n,
|
|
17371
17385
|
reason: t,
|
|
17372
|
-
...
|
|
17386
|
+
...zx(e, null)
|
|
17373
17387
|
};
|
|
17374
17388
|
}
|
|
17375
17389
|
//#endregion
|
|
17376
17390
|
//#region src/test-utils.ts
|
|
17377
|
-
function
|
|
17391
|
+
function Vx(e) {
|
|
17378
17392
|
hn(e);
|
|
17379
17393
|
}
|
|
17380
|
-
function
|
|
17394
|
+
function Hx(e) {
|
|
17381
17395
|
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");
|
|
17382
17396
|
return Number(n.lastInsertRowid);
|
|
17383
17397
|
}
|
|
17384
|
-
function
|
|
17398
|
+
function Ux(e, t = "local") {
|
|
17385
17399
|
let n = "2026-04-01T00:00:00.000Z", r = "fixture-work-authorized", i = "fixture-oss-hidden", a = "mixedscopeleak";
|
|
17386
17400
|
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);
|
|
17387
17401
|
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) => {
|
|
@@ -17430,8 +17444,8 @@ function Hx(e, t = "local") {
|
|
|
17430
17444
|
}
|
|
17431
17445
|
//#endregion
|
|
17432
17446
|
//#region src/index.ts
|
|
17433
|
-
var
|
|
17447
|
+
var Wx = "0.30.0";
|
|
17434
17448
|
//#endregion
|
|
17435
|
-
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, kb 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, qy 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, gy as REF_BACKFILL_JOB, mg as RICH_TIER_DEFAULTS, hy as RawEventSweeper, Sy as RefBackfillRunner, Sn as SCHEMA_VERSION, bv as SCOPE_BACKFILL_JOB, n as SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, Cy as SESSION_CONTEXT_BACKFILL_JOB, fr as SIGNATURE_VERSION, pg as SIMPLE_TIER_DEFAULTS, Ly as SUMMARY_DEDUP_BACKFILL_JOB, Gy as SYNC_CAPABILITIES, Ky as SYNC_CAPABILITY_HEADER, Ix as SYNC_SCOPE_QUERY_PARAM, Iv as ScopeBackfillRunner, Iy as SessionContextBackfillRunner, Wy as SummaryDedupBackfillRunner, Fx as SyncRetentionRunner, p_ as TRIVIAL_REQUESTS, Zy as VECTOR_MODEL_MIGRATION_JOB, Ux as VERSION, yb as VectorModelMigrationRunner, Qo as _resetEmbeddingClient, Rx as addSyncScopeToBoundary, vl as addressDedupeKey, Wb as advertiseMdns, Om as aiBackfillStructuredContent, cy as analyzeProjectScopeMappingChangeGuardrails, Db as applyBootstrapSnapshot, Zd as applyReplicationOps, zn as assertSchemaReady, ep as backfillMemoryDedupKeys, Yf as backfillNarrativeFromBody, Jd as backfillReplicationOps, Nv 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, vx 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, Qb as cursorAdvances, Kf as deactivateLowSignalMemories, Gf as deactivateLowSignalObservations, Tg as decideExtractionReplayTier, s as decodeInvitePayload, qf as dedupNearDuplicateMemories, Wo as dedupeOrderedIds, bh as deleteCoordinatorGroupPreference, dy as deleteProjectScopeSettingsMapping, __ as deriveRequest, xu as deriveTags, Gb 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, bb 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, Cx as getSyncDaemonPhase, Ru as getSyncResetState, At as getWorkspaceCodememConfigPath, jt as getWorkspaceScopedCodememConfigPath, P_ as hasMeaningfulObservation, Sh as hasPendingDedupKeyBackfill, vy as hasPendingRefBackfill, kv as hasPendingScopeBackfill, Ny as hasPendingSessionContextBackfill, zy as hasPendingSummaryDedupBackfill, ad as hasUnsyncedSharedMemoryChanges, Yo as hashText, tg as importMemories, K_ as ingest, Y_ as ingestMain, ii as initDatabase, Bx as initTestSchema, Vx as insertTestSession, l as inviteLink, _x 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, ly as listProjectScopeCandidates, ry as listProjectScopeSettingsMappings, ny as listSharingDomainSettingsScopes, id as loadMemorySnapshotPageForPeer, Vp as loadObserverConfig, Dt as loadOpenCodeConfig, op as loadOpenCodeOAuthCache, jb 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, Kb as mdnsAddressesForPeer, Rb as mdnsEnabled, yl as mergeAddresses, Lh as mergeSummaryMetadata, jn as migrateLegacyDbPath, qd as migrateLegacyImportKeys, Xy as negotiateSyncCapability, C_ as normalizeAdapterEvents, _l as normalizeAddress, ma as normalizeConcept, S_ as normalizeEventsForSessionContext, Vf as normalizeObservation, Dr as normalizeProjectLabel, m_ as normalizeRequestText, Yy as normalizeSyncCapability, yu as normalizeTag, Vg as normalizeToolName, N_ as parseObserverResponse, Sa as parsePositiveMemoryId, xa as parseStrictInteger, Lx as parseSyncScopeRequest, yx 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, Pb as recordPeerSuccess, $u as recordReplicationOp, Nb 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, xy as runRefBackfillPass, Fv as runScopeBackfillPass, Py as runSessionContextBackfillPass, Uy as runSummaryDedupBackfillPass, Dx as runSyncDaemon, px as runSyncPass, vb as runVectorMigrationPass, Fg as sanitizePayload, Rg as sanitizeToolOutput, Im as scanSecretsRetroactive, H as schema, a as scopeMembershipEpochStatus, Ro as search, Hx as seedMixedScopeFixture, Ab as selectDialAddresses, As as semanticSearch, rs as serializeFloat32, Ib as setPeerLocalActorClaim, Fb as setPeerProjectFilter, Ju as setReplicationCursor, Sx as setSyncDaemonError, xx as setSyncDaemonOk, wx as setSyncDaemonPhase, zu as setSyncResetState, bx 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, Ex as syncDaemonTick, fx as syncOnce, dx as syncPassPreflight, _d as syncProjectAllowedByFilters, zx as syncScopeResetRequiredPayload, vd as syncVisibilityAllowed, X as tableExists, Ho as timeline, Z as toJson, Gn as toJsonNullable, Jr as updateMaintenanceJob, Mb as updatePeerAddresses, iu as upsertCachedScopeMemberships, yh as upsertCoordinatorGroupPreference, uy as upsertProjectScopeSettingsMapping, ai as vacuumDatabase, ur as validateExistingKeypair, hr as verifySignature, Bt as writeCodememConfigFile, Vt as writeWorkspaceCodememConfigFile };
|
|
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 };
|
|
17436
17450
|
|
|
17437
17451
|
//# sourceMappingURL=index.js.map
|