chat-recall 0.7.37 → 0.7.39
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/cli.js +283 -94
- package/dist/cli.js.map +1 -1
- package/dist/kit-store.d.ts +4 -3
- package/dist/kit-store.d.ts.map +1 -1
- package/dist/kit-store.js +4 -4
- package/dist/kit-store.js.map +1 -1
- package/dist/mcp-relay.js +1 -1
- package/dist/mcp.js +111 -20
- package/dist/message-hook.js +1 -1
- package/dist/scan-worker.js +8 -5
- package/dist/service-installer.d.ts +13 -0
- package/dist/service-installer.d.ts.map +1 -1
- package/dist/service-installer.js +19 -7
- package/dist/service-installer.js.map +1 -1
- package/dist/sync-client.d.ts +33 -3
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +117 -7
- package/dist/sync-client.js.map +1 -1
- package/dist/walk-budget.d.ts +52 -0
- package/dist/walk-budget.d.ts.map +1 -0
- package/dist/walk-budget.js +68 -0
- package/dist/walk-budget.js.map +1 -0
- package/dist/watch.js +120 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2034,7 +2034,7 @@ var require_thread_stream = __commonJS({
|
|
|
2034
2034
|
var { version: version2 } = require_package();
|
|
2035
2035
|
var { EventEmitter } = __require("events");
|
|
2036
2036
|
var { Worker: Worker2 } = __require("worker_threads");
|
|
2037
|
-
var { join:
|
|
2037
|
+
var { join: join72 } = __require("path");
|
|
2038
2038
|
var { pathToFileURL } = __require("url");
|
|
2039
2039
|
var { wait } = require_wait();
|
|
2040
2040
|
var {
|
|
@@ -2077,7 +2077,7 @@ var require_thread_stream = __commonJS({
|
|
|
2077
2077
|
function createWorker(stream, opts) {
|
|
2078
2078
|
const { filename, workerData } = opts;
|
|
2079
2079
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
2080
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
2080
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join72(__dirname, "lib", "worker.js");
|
|
2081
2081
|
const worker = new Worker2(toExecute, {
|
|
2082
2082
|
...opts.workerOpts,
|
|
2083
2083
|
trackUnmanagedFds: false,
|
|
@@ -2480,7 +2480,7 @@ var require_transport = __commonJS({
|
|
|
2480
2480
|
"use strict";
|
|
2481
2481
|
var { createRequire: createRequire4 } = __require("module");
|
|
2482
2482
|
var getCallers = require_caller();
|
|
2483
|
-
var { join:
|
|
2483
|
+
var { join: join72, isAbsolute: isAbsolute5, sep: sep5 } = __require("node:path");
|
|
2484
2484
|
var sleep2 = require_atomic_sleep();
|
|
2485
2485
|
var onExit = require_on_exit_leak_free();
|
|
2486
2486
|
var ThreadStream = require_thread_stream();
|
|
@@ -2543,7 +2543,7 @@ var require_transport = __commonJS({
|
|
|
2543
2543
|
throw new Error("only one of target or targets can be specified");
|
|
2544
2544
|
}
|
|
2545
2545
|
if (targets) {
|
|
2546
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
2546
|
+
target = bundlerOverrides["pino-worker"] || join72(__dirname, "worker.js");
|
|
2547
2547
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
2548
2548
|
return {
|
|
2549
2549
|
...dest,
|
|
@@ -2561,7 +2561,7 @@ var require_transport = __commonJS({
|
|
|
2561
2561
|
});
|
|
2562
2562
|
});
|
|
2563
2563
|
} else if (pipeline) {
|
|
2564
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
2564
|
+
target = bundlerOverrides["pino-worker"] || join72(__dirname, "worker.js");
|
|
2565
2565
|
options.pipelines = [pipeline.map((dest) => {
|
|
2566
2566
|
return {
|
|
2567
2567
|
...dest,
|
|
@@ -2583,7 +2583,7 @@ var require_transport = __commonJS({
|
|
|
2583
2583
|
return origin;
|
|
2584
2584
|
}
|
|
2585
2585
|
if (origin === "pino/file") {
|
|
2586
|
-
return
|
|
2586
|
+
return join72(__dirname, "..", "file.js");
|
|
2587
2587
|
}
|
|
2588
2588
|
let fixTarget2;
|
|
2589
2589
|
for (const filePath of callers) {
|
|
@@ -3572,7 +3572,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
3572
3572
|
return circularValue;
|
|
3573
3573
|
}
|
|
3574
3574
|
let res = "";
|
|
3575
|
-
let
|
|
3575
|
+
let join72 = ",";
|
|
3576
3576
|
const originalIndentation = indentation;
|
|
3577
3577
|
if (Array.isArray(value)) {
|
|
3578
3578
|
if (value.length === 0) {
|
|
@@ -3586,7 +3586,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
3586
3586
|
indentation += spacer;
|
|
3587
3587
|
res += `
|
|
3588
3588
|
${indentation}`;
|
|
3589
|
-
|
|
3589
|
+
join72 = `,
|
|
3590
3590
|
${indentation}`;
|
|
3591
3591
|
}
|
|
3592
3592
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -3594,13 +3594,13 @@ ${indentation}`;
|
|
|
3594
3594
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3595
3595
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
3596
3596
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
3597
|
-
res +=
|
|
3597
|
+
res += join72;
|
|
3598
3598
|
}
|
|
3599
3599
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
3600
3600
|
res += tmp !== void 0 ? tmp : "null";
|
|
3601
3601
|
if (value.length - 1 > maximumBreadth) {
|
|
3602
3602
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3603
|
-
res += `${
|
|
3603
|
+
res += `${join72}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3604
3604
|
}
|
|
3605
3605
|
if (spacer !== "") {
|
|
3606
3606
|
res += `
|
|
@@ -3621,7 +3621,7 @@ ${originalIndentation}`;
|
|
|
3621
3621
|
let separator = "";
|
|
3622
3622
|
if (spacer !== "") {
|
|
3623
3623
|
indentation += spacer;
|
|
3624
|
-
|
|
3624
|
+
join72 = `,
|
|
3625
3625
|
${indentation}`;
|
|
3626
3626
|
whitespace = " ";
|
|
3627
3627
|
}
|
|
@@ -3635,13 +3635,13 @@ ${indentation}`;
|
|
|
3635
3635
|
const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
|
|
3636
3636
|
if (tmp !== void 0) {
|
|
3637
3637
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
3638
|
-
separator =
|
|
3638
|
+
separator = join72;
|
|
3639
3639
|
}
|
|
3640
3640
|
}
|
|
3641
3641
|
if (keyLength > maximumBreadth) {
|
|
3642
3642
|
const removedKeys = keyLength - maximumBreadth;
|
|
3643
3643
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
3644
|
-
separator =
|
|
3644
|
+
separator = join72;
|
|
3645
3645
|
}
|
|
3646
3646
|
if (spacer !== "" && separator.length > 1) {
|
|
3647
3647
|
res = `
|
|
@@ -3682,7 +3682,7 @@ ${originalIndentation}`;
|
|
|
3682
3682
|
}
|
|
3683
3683
|
const originalIndentation = indentation;
|
|
3684
3684
|
let res = "";
|
|
3685
|
-
let
|
|
3685
|
+
let join72 = ",";
|
|
3686
3686
|
if (Array.isArray(value)) {
|
|
3687
3687
|
if (value.length === 0) {
|
|
3688
3688
|
return "[]";
|
|
@@ -3695,7 +3695,7 @@ ${originalIndentation}`;
|
|
|
3695
3695
|
indentation += spacer;
|
|
3696
3696
|
res += `
|
|
3697
3697
|
${indentation}`;
|
|
3698
|
-
|
|
3698
|
+
join72 = `,
|
|
3699
3699
|
${indentation}`;
|
|
3700
3700
|
}
|
|
3701
3701
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -3703,13 +3703,13 @@ ${indentation}`;
|
|
|
3703
3703
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3704
3704
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
3705
3705
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
3706
|
-
res +=
|
|
3706
|
+
res += join72;
|
|
3707
3707
|
}
|
|
3708
3708
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
3709
3709
|
res += tmp !== void 0 ? tmp : "null";
|
|
3710
3710
|
if (value.length - 1 > maximumBreadth) {
|
|
3711
3711
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3712
|
-
res += `${
|
|
3712
|
+
res += `${join72}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3713
3713
|
}
|
|
3714
3714
|
if (spacer !== "") {
|
|
3715
3715
|
res += `
|
|
@@ -3722,7 +3722,7 @@ ${originalIndentation}`;
|
|
|
3722
3722
|
let whitespace = "";
|
|
3723
3723
|
if (spacer !== "") {
|
|
3724
3724
|
indentation += spacer;
|
|
3725
|
-
|
|
3725
|
+
join72 = `,
|
|
3726
3726
|
${indentation}`;
|
|
3727
3727
|
whitespace = " ";
|
|
3728
3728
|
}
|
|
@@ -3731,7 +3731,7 @@ ${indentation}`;
|
|
|
3731
3731
|
const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
|
|
3732
3732
|
if (tmp !== void 0) {
|
|
3733
3733
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
3734
|
-
separator =
|
|
3734
|
+
separator = join72;
|
|
3735
3735
|
}
|
|
3736
3736
|
}
|
|
3737
3737
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -3789,20 +3789,20 @@ ${originalIndentation}`;
|
|
|
3789
3789
|
indentation += spacer;
|
|
3790
3790
|
let res2 = `
|
|
3791
3791
|
${indentation}`;
|
|
3792
|
-
const
|
|
3792
|
+
const join73 = `,
|
|
3793
3793
|
${indentation}`;
|
|
3794
3794
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
3795
3795
|
let i = 0;
|
|
3796
3796
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3797
3797
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
3798
3798
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
3799
|
-
res2 +=
|
|
3799
|
+
res2 += join73;
|
|
3800
3800
|
}
|
|
3801
3801
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
3802
3802
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
3803
3803
|
if (value.length - 1 > maximumBreadth) {
|
|
3804
3804
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3805
|
-
res2 += `${
|
|
3805
|
+
res2 += `${join73}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3806
3806
|
}
|
|
3807
3807
|
res2 += `
|
|
3808
3808
|
${originalIndentation}`;
|
|
@@ -3818,16 +3818,16 @@ ${originalIndentation}`;
|
|
|
3818
3818
|
return '"[Object]"';
|
|
3819
3819
|
}
|
|
3820
3820
|
indentation += spacer;
|
|
3821
|
-
const
|
|
3821
|
+
const join72 = `,
|
|
3822
3822
|
${indentation}`;
|
|
3823
3823
|
let res = "";
|
|
3824
3824
|
let separator = "";
|
|
3825
3825
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
3826
3826
|
if (isTypedArrayWithEntries(value)) {
|
|
3827
|
-
res += stringifyTypedArray(value,
|
|
3827
|
+
res += stringifyTypedArray(value, join72, maximumBreadth);
|
|
3828
3828
|
keys = keys.slice(value.length);
|
|
3829
3829
|
maximumPropertiesToStringify -= value.length;
|
|
3830
|
-
separator =
|
|
3830
|
+
separator = join72;
|
|
3831
3831
|
}
|
|
3832
3832
|
if (deterministic) {
|
|
3833
3833
|
keys = sort(keys, comparator);
|
|
@@ -3838,13 +3838,13 @@ ${indentation}`;
|
|
|
3838
3838
|
const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
|
|
3839
3839
|
if (tmp !== void 0) {
|
|
3840
3840
|
res += `${separator}${strEscape(key3)}: ${tmp}`;
|
|
3841
|
-
separator =
|
|
3841
|
+
separator = join72;
|
|
3842
3842
|
}
|
|
3843
3843
|
}
|
|
3844
3844
|
if (keyLength > maximumBreadth) {
|
|
3845
3845
|
const removedKeys = keyLength - maximumBreadth;
|
|
3846
3846
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
3847
|
-
separator =
|
|
3847
|
+
separator = join72;
|
|
3848
3848
|
}
|
|
3849
3849
|
if (separator !== "") {
|
|
3850
3850
|
res = `
|
|
@@ -9826,11 +9826,11 @@ async function archiveRawSession(store, sessionId) {
|
|
|
9826
9826
|
return await store.putRawSession(sessionId, exp.tool, Math.floor(exp.mtime), gz, size);
|
|
9827
9827
|
}
|
|
9828
9828
|
function detectForkPredecessor(sessionPath) {
|
|
9829
|
-
const { readFileSync:
|
|
9830
|
-
const { dirname: dirname31, join:
|
|
9829
|
+
const { readFileSync: readFileSync58, readdirSync: readdirSync36 } = requireFs();
|
|
9830
|
+
const { dirname: dirname31, join: join72, basename: basename30 } = requirePath();
|
|
9831
9831
|
let text;
|
|
9832
9832
|
try {
|
|
9833
|
-
text =
|
|
9833
|
+
text = readFileSync58(sessionPath, "utf-8");
|
|
9834
9834
|
} catch {
|
|
9835
9835
|
return null;
|
|
9836
9836
|
}
|
|
@@ -9864,7 +9864,7 @@ function detectForkPredecessor(sessionPath) {
|
|
|
9864
9864
|
if (!f.endsWith(".jsonl") || f === self || f === "sessions-index.json")
|
|
9865
9865
|
continue;
|
|
9866
9866
|
try {
|
|
9867
|
-
if (
|
|
9867
|
+
if (readFileSync58(join72(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
|
|
9868
9868
|
return basename30(f, ".jsonl");
|
|
9869
9869
|
}
|
|
9870
9870
|
} catch {
|
|
@@ -10598,15 +10598,18 @@ var init_opencode = __esm({
|
|
|
10598
10598
|
FROM part p JOIN (SELECT id, data FROM message WHERE session_id = ?) m ON p.message_id = m.id
|
|
10599
10599
|
WHERE p.session_id = ?
|
|
10600
10600
|
ORDER BY p.time_created ASC, p.id ASC
|
|
10601
|
-
`)
|
|
10602
|
-
const
|
|
10603
|
-
|
|
10604
|
-
|
|
10601
|
+
`);
|
|
10602
|
+
const chunks = [Buffer.from(`${JSON.stringify({ kind: "session", row: session })}
|
|
10603
|
+
`, "utf-8")];
|
|
10604
|
+
for (const r of rows.iterate(realId, realId)) {
|
|
10605
|
+
chunks.push(Buffer.from(`${JSON.stringify({ kind: "part", row: r })}
|
|
10606
|
+
`, "utf-8"));
|
|
10607
|
+
}
|
|
10605
10608
|
const mtime = session.time_updated || session.time_created || Date.now();
|
|
10606
10609
|
return {
|
|
10607
10610
|
tool: "opencode",
|
|
10608
10611
|
mtime: Number(mtime),
|
|
10609
|
-
files: [{ name: `${realId}.dump.jsonl`, bytes: Buffer.
|
|
10612
|
+
files: [{ name: `${realId}.dump.jsonl`, bytes: Buffer.concat(chunks) }]
|
|
10610
10613
|
};
|
|
10611
10614
|
} catch {
|
|
10612
10615
|
return null;
|
|
@@ -16056,6 +16059,29 @@ var init_secret_precision = __esm({
|
|
|
16056
16059
|
}
|
|
16057
16060
|
});
|
|
16058
16061
|
|
|
16062
|
+
// src/walk-budget.ts
|
|
16063
|
+
function walkSessionLimit(env = process.env) {
|
|
16064
|
+
const raw = env.CHAT_RECALL_SYNC_WALK_MAX;
|
|
16065
|
+
if (raw === void 0 || raw.trim() === "") return DEFAULT_WALK_MAX_SESSIONS;
|
|
16066
|
+
const n = Number(raw);
|
|
16067
|
+
if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) return DEFAULT_WALK_MAX_SESSIONS;
|
|
16068
|
+
return n;
|
|
16069
|
+
}
|
|
16070
|
+
function orderRefsForWalk(refs, isAcked) {
|
|
16071
|
+
const fresh = [];
|
|
16072
|
+
const acked = [];
|
|
16073
|
+
for (const ref of refs) (isAcked(ref.prefixedId) ? acked : fresh).push(ref);
|
|
16074
|
+
return [...fresh, ...acked];
|
|
16075
|
+
}
|
|
16076
|
+
var DEFAULT_WALK_MAX_SESSIONS, FULL_WALK_INTERVAL_MS;
|
|
16077
|
+
var init_walk_budget = __esm({
|
|
16078
|
+
"src/walk-budget.ts"() {
|
|
16079
|
+
"use strict";
|
|
16080
|
+
DEFAULT_WALK_MAX_SESSIONS = 2e3;
|
|
16081
|
+
FULL_WALK_INTERVAL_MS = 6 * 60 * 6e4;
|
|
16082
|
+
}
|
|
16083
|
+
});
|
|
16084
|
+
|
|
16059
16085
|
// ../engine/dist/transcript/types.js
|
|
16060
16086
|
var TRANSCRIPT_VERSION;
|
|
16061
16087
|
var init_types = __esm({
|
|
@@ -28318,7 +28344,7 @@ var init_http = __esm({
|
|
|
28318
28344
|
CLI_VERSION = JSON.parse(readFileSync36(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
|
|
28319
28345
|
} catch {
|
|
28320
28346
|
try {
|
|
28321
|
-
if (true) CLI_VERSION = "0.7.
|
|
28347
|
+
if (true) CLI_VERSION = "0.7.39";
|
|
28322
28348
|
} catch {
|
|
28323
28349
|
}
|
|
28324
28350
|
}
|
|
@@ -28816,7 +28842,7 @@ var init_telemetry = __esm({
|
|
|
28816
28842
|
init_sync_client();
|
|
28817
28843
|
cliVersion2 = () => {
|
|
28818
28844
|
try {
|
|
28819
|
-
return true ? "0.7.
|
|
28845
|
+
return true ? "0.7.39" : "dev";
|
|
28820
28846
|
} catch {
|
|
28821
28847
|
return "dev";
|
|
28822
28848
|
}
|
|
@@ -29664,8 +29690,11 @@ __export(sync_client_exports, {
|
|
|
29664
29690
|
buildConversationTail: () => buildConversationTail,
|
|
29665
29691
|
classedError: () => classedError,
|
|
29666
29692
|
classifyError: () => classifyError,
|
|
29693
|
+
countsForBreaker: () => countsForBreaker,
|
|
29694
|
+
exportByteLength: () => exportByteLength,
|
|
29667
29695
|
isStandingFailure: () => isStandingFailure,
|
|
29668
29696
|
isSyncSkip: () => isSyncSkip,
|
|
29697
|
+
lastSuccessfulWalkAt: () => lastSuccessfulWalkAt,
|
|
29669
29698
|
loadAllCredentials: () => loadAllCredentials,
|
|
29670
29699
|
loadCredentials: () => loadCredentials,
|
|
29671
29700
|
reapStaleScanDirs: () => reapStaleScanDirs,
|
|
@@ -29700,11 +29729,15 @@ function isStandingFailure(err) {
|
|
|
29700
29729
|
const c = taggedClass(err);
|
|
29701
29730
|
return c !== null && STANDING_FAILURE.has(c);
|
|
29702
29731
|
}
|
|
29732
|
+
function countsForBreaker(cls) {
|
|
29733
|
+
return cls !== "rate_limited" && cls !== "payload_too_large";
|
|
29734
|
+
}
|
|
29703
29735
|
function classifyError(msg, err) {
|
|
29704
29736
|
const tagged = taggedClass(err);
|
|
29705
29737
|
if (tagged) return tagged;
|
|
29706
29738
|
const m = msg.toLowerCase();
|
|
29707
29739
|
if (m.includes("429")) return "rate_limited";
|
|
29740
|
+
if (m.includes("body_too_large") || m.includes("payload too large") || m.includes("entity too large")) return "payload_too_large";
|
|
29708
29741
|
if (m.includes("402")) return "payment_required";
|
|
29709
29742
|
if (m.includes("401") || m.includes("403") || m.includes("token")) return "auth";
|
|
29710
29743
|
if (m.includes("timed out") || m.includes("etimedout") || m.includes("aborted due to timeout")) return "timeout";
|
|
@@ -29973,6 +30006,12 @@ async function syncSessions(opts = {}) {
|
|
|
29973
30006
|
const msg = e instanceof Error ? e.message : String(e);
|
|
29974
30007
|
errors.push(`${cred.serverUrl}: ${msg}`);
|
|
29975
30008
|
perTarget[cred.serverUrl] = { ok: false, error: msg, accepted: acceptedUploads.get(cred.serverUrl) ?? 0 };
|
|
30009
|
+
const cls = classifyError(msg, e);
|
|
30010
|
+
if (!countsForBreaker(cls)) {
|
|
30011
|
+
console.error(`[sync] ${cred.serverUrl}: ${cls === "rate_limited" ? "asked to slow down" : "refused one oversized body"}; the target stays out of cooldown and the next walk retries`);
|
|
30012
|
+
record({ kind: "target_throttled", failures: 0, retryInMs: 0, errorClass: cls, local: isLocalHost(cred.serverUrl) ? 1 : 0 });
|
|
30013
|
+
continue;
|
|
30014
|
+
}
|
|
29976
30015
|
const next = noteTargetFailure(cred.serverUrl, msg);
|
|
29977
30016
|
const notice = breakerNotice(cred.serverUrl, next);
|
|
29978
30017
|
if (notice) console.error(`[sync] ${notice}`);
|
|
@@ -29985,7 +30024,7 @@ async function syncSessions(opts = {}) {
|
|
|
29985
30024
|
kind: next.tripped ? "breaker_trip" : "target_failure",
|
|
29986
30025
|
failures: next.failures,
|
|
29987
30026
|
retryInMs: next.retryInMs,
|
|
29988
|
-
errorClass:
|
|
30027
|
+
errorClass: cls,
|
|
29989
30028
|
local: isLocalHost(cred.serverUrl) ? 1 : 0
|
|
29990
30029
|
});
|
|
29991
30030
|
}
|
|
@@ -30010,6 +30049,11 @@ async function syncSessions(opts = {}) {
|
|
|
30010
30049
|
rssPeakMb: Math.round(process.memoryUsage().rss / 1048576)
|
|
30011
30050
|
});
|
|
30012
30051
|
}
|
|
30052
|
+
if (agg) {
|
|
30053
|
+
for (const t of targets) {
|
|
30054
|
+
if (!errors.some((e) => e.startsWith(`${t.serverUrl}:`))) noteWalkSuccess(t.serverUrl);
|
|
30055
|
+
}
|
|
30056
|
+
}
|
|
30013
30057
|
void flush().catch(() => {
|
|
30014
30058
|
});
|
|
30015
30059
|
if (!agg) throw new Error(`sync failed for all targets:
|
|
@@ -30018,6 +30062,32 @@ async function syncSessions(opts = {}) {
|
|
|
30018
30062
|
${errors.join("\n ")}`);
|
|
30019
30063
|
return { ...agg, perTarget };
|
|
30020
30064
|
}
|
|
30065
|
+
function walkStatePath() {
|
|
30066
|
+
return join47(getDataDir(), "walk-state.json");
|
|
30067
|
+
}
|
|
30068
|
+
function readWalkState() {
|
|
30069
|
+
try {
|
|
30070
|
+
const raw = JSON.parse(readFileSync41(walkStatePath(), "utf-8"));
|
|
30071
|
+
return raw && typeof raw === "object" ? raw : {};
|
|
30072
|
+
} catch {
|
|
30073
|
+
return {};
|
|
30074
|
+
}
|
|
30075
|
+
}
|
|
30076
|
+
function noteWalkSuccess(serverUrl) {
|
|
30077
|
+
try {
|
|
30078
|
+
const state2 = readWalkState();
|
|
30079
|
+
state2[serverUrl.replace(/\/+$/, "")] = Date.now();
|
|
30080
|
+
mkdirSync11(getDataDir(), { recursive: true });
|
|
30081
|
+
writeFileSync10(walkStatePath(), JSON.stringify(state2));
|
|
30082
|
+
} catch {
|
|
30083
|
+
}
|
|
30084
|
+
}
|
|
30085
|
+
function lastSuccessfulWalkAt(serverUrl) {
|
|
30086
|
+
const state2 = readWalkState();
|
|
30087
|
+
const key2 = serverUrl?.replace(/\/+$/, "");
|
|
30088
|
+
const stamps = key2 ? [state2[key2]] : Object.values(state2);
|
|
30089
|
+
return stamps.reduce((max, v) => Math.max(max, typeof v === "number" ? v : 0), 0);
|
|
30090
|
+
}
|
|
30021
30091
|
async function postFieldBatch(base4, token, rows) {
|
|
30022
30092
|
const headers = { "content-type": "application/json" };
|
|
30023
30093
|
if (token) headers.authorization = `Bearer ${token}`;
|
|
@@ -30547,7 +30617,9 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
30547
30617
|
}
|
|
30548
30618
|
};
|
|
30549
30619
|
let scanMs = 0, scanned = 0;
|
|
30550
|
-
const
|
|
30620
|
+
const walkMax = opts.limit ?? walkSessionLimit();
|
|
30621
|
+
const ordered = walkMax > 0 ? orderRefsForWalk(refs, (id) => Boolean(ledger?.get(id))) : refs;
|
|
30622
|
+
const slice = walkMax > 0 ? ordered.slice(0, walkMax) : ordered;
|
|
30551
30623
|
const trace = process.env.CHAT_RECALL_SYNC_TRACE === "1" ? (msg) => {
|
|
30552
30624
|
const m = process.memoryUsage();
|
|
30553
30625
|
console.error(`[sync-trace] ${msg} \xB7 heap=${(m.heapUsed / 1048576).toFixed(0)}MB rss=${(m.rss / 1048576).toFixed(0)}MB`);
|
|
@@ -30941,6 +31013,10 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
30941
31013
|
scanMs: Math.round(scanMs)
|
|
30942
31014
|
};
|
|
30943
31015
|
}
|
|
31016
|
+
function exportByteLength(exp) {
|
|
31017
|
+
if (!exp) return 0;
|
|
31018
|
+
return exp.files.reduce((n, f) => n + f.bytes.length, 0);
|
|
31019
|
+
}
|
|
30944
31020
|
async function scanTranscriptFindingsChunked(ref, tenantRules) {
|
|
30945
31021
|
const backend = getBackendForId(ref.prefixedId);
|
|
30946
31022
|
const findings = [];
|
|
@@ -31011,7 +31087,20 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
31011
31087
|
const backend = getBackendForId(ref.prefixedId) ?? getBackend("claude");
|
|
31012
31088
|
const exp = backend.exportRawSession(ref.prefixedId);
|
|
31013
31089
|
let built;
|
|
31014
|
-
|
|
31090
|
+
const exportBytes = exportByteLength(exp);
|
|
31091
|
+
const overCeiling = exportBytes > FULL_BUILD_MAX_BYTES;
|
|
31092
|
+
if (exp && overCeiling) {
|
|
31093
|
+
console.error(`[sync] ${ref.prefixedId} export is ${(exportBytes / 1048576).toFixed(0)}MB (over the ${(FULL_BUILD_MAX_BYTES / 1048576).toFixed(0)}MB ceiling) \u2014 parsing it in place, no container copy, no shadow merge, no raw archive`);
|
|
31094
|
+
record({
|
|
31095
|
+
kind: "oversized_session",
|
|
31096
|
+
mb: Math.round(exportBytes / 1048576),
|
|
31097
|
+
tool: ref.toolId,
|
|
31098
|
+
dedupeKey: stableMark(ref.prefixedId)
|
|
31099
|
+
});
|
|
31100
|
+
includeRaw = false;
|
|
31101
|
+
includeMeta = false;
|
|
31102
|
+
}
|
|
31103
|
+
if (exp && !overCeiling) {
|
|
31015
31104
|
try {
|
|
31016
31105
|
built = buildRawContainer(exp);
|
|
31017
31106
|
srcHash = containerSrcHash(built);
|
|
@@ -31035,7 +31124,7 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
31035
31124
|
includeMeta = false;
|
|
31036
31125
|
}
|
|
31037
31126
|
}
|
|
31038
|
-
const shadow = updateShadow(ref.rawId, exp, built);
|
|
31127
|
+
const shadow = overCeiling ? { container: null, status: "skipped", recovered: 0 } : updateShadow(ref.rawId, exp, built);
|
|
31039
31128
|
if (shadow.container) {
|
|
31040
31129
|
fullestContainer = shadow.container;
|
|
31041
31130
|
if (shadow.status === "rewrite-merged" && shadow.recovered > 0) {
|
|
@@ -31402,6 +31491,7 @@ var init_sync_client = __esm({
|
|
|
31402
31491
|
init_secret_precision();
|
|
31403
31492
|
init_settings();
|
|
31404
31493
|
init_paths();
|
|
31494
|
+
init_walk_budget();
|
|
31405
31495
|
init_tool_backend();
|
|
31406
31496
|
init_transcript();
|
|
31407
31497
|
init_claude2();
|
|
@@ -31435,7 +31525,7 @@ var init_sync_client = __esm({
|
|
|
31435
31525
|
ownVersion = JSON.parse(readFileSync41(join47(dir, "../package.json"), "utf-8")).version || ownVersion;
|
|
31436
31526
|
} catch {
|
|
31437
31527
|
try {
|
|
31438
|
-
if (true) ownVersion = "0.7.
|
|
31528
|
+
if (true) ownVersion = "0.7.39";
|
|
31439
31529
|
} catch {
|
|
31440
31530
|
}
|
|
31441
31531
|
}
|
|
@@ -32913,6 +33003,26 @@ function piAgentDir2(home) {
|
|
|
32913
33003
|
const override = process.env.CHAT_RECALL_PI_HOME?.trim() || loadSourceSettings().piHome || process.env.PI_CODING_AGENT_DIR?.trim();
|
|
32914
33004
|
return override ? expandTildePath(override) : join54(home, ".pi", "agent");
|
|
32915
33005
|
}
|
|
33006
|
+
function launchCommand(spec) {
|
|
33007
|
+
if (!spec.command)
|
|
33008
|
+
throw new Error("an MCP entry needs a url or a command");
|
|
33009
|
+
return spec.command;
|
|
33010
|
+
}
|
|
33011
|
+
function remoteMcpServersEntry(id, spec) {
|
|
33012
|
+
const headers = spec.authorization ? { headers: { Authorization: spec.authorization } } : {};
|
|
33013
|
+
switch (id) {
|
|
33014
|
+
// Claude Code is the one that runs a command for the header at every start,
|
|
33015
|
+
// so the token stays out of the config file it writes.
|
|
33016
|
+
case "claude":
|
|
33017
|
+
return { type: "http", url: spec.url, ...spec.headersHelper ? { headersHelper: spec.headersHelper } : headers };
|
|
33018
|
+
case "agy":
|
|
33019
|
+
return { httpUrl: spec.url, ...headers };
|
|
33020
|
+
case "cursor":
|
|
33021
|
+
return { url: spec.url, ...headers };
|
|
33022
|
+
default:
|
|
33023
|
+
return { url: spec.url };
|
|
33024
|
+
}
|
|
33025
|
+
}
|
|
32916
33026
|
function envHome(varName, fallback) {
|
|
32917
33027
|
const v = process.env[varName];
|
|
32918
33028
|
return v && v.trim() ? v.trim() : fallback;
|
|
@@ -32938,8 +33048,18 @@ function registerMcpServersJson(target, path, spec) {
|
|
|
32938
33048
|
}
|
|
32939
33049
|
const servers = cfg.mcpServers || {};
|
|
32940
33050
|
const existing = servers[MCP_SERVER_NAME];
|
|
33051
|
+
if (spec.url) {
|
|
33052
|
+
const wanted = remoteMcpServersEntry(target.id, spec);
|
|
33053
|
+
const isCurrent2 = !!existing && !existing.disabled && Object.entries(wanted).every(([k, v]) => JSON.stringify(existing[k] ?? null) === JSON.stringify(v));
|
|
33054
|
+
if (isCurrent2)
|
|
33055
|
+
return { id: target.id, label: target.label, path, state: "current" };
|
|
33056
|
+
servers[MCP_SERVER_NAME] = wanted;
|
|
33057
|
+
cfg.mcpServers = servers;
|
|
33058
|
+
writeFileMkdir(path, JSON.stringify(cfg, null, 2) + "\n");
|
|
33059
|
+
return { id: target.id, label: target.label, path, state: existing ? "repaired" : "created" };
|
|
33060
|
+
}
|
|
32941
33061
|
const entry = {
|
|
32942
|
-
command: spec
|
|
33062
|
+
command: launchCommand(spec),
|
|
32943
33063
|
...spec.args ? { args: spec.args } : {}
|
|
32944
33064
|
};
|
|
32945
33065
|
if (spec.alwaysAllow)
|
|
@@ -32969,7 +33089,17 @@ function registerOpencodeJson(path, spec) {
|
|
|
32969
33089
|
cfg.$schema = "https://opencode.ai/config.json";
|
|
32970
33090
|
const mcp = cfg.mcp || {};
|
|
32971
33091
|
const existing = mcp[MCP_SERVER_NAME];
|
|
32972
|
-
|
|
33092
|
+
if (spec.url) {
|
|
33093
|
+
const wanted = { type: "remote", url: spec.url, enabled: true };
|
|
33094
|
+
const isCurrent2 = !!existing && existing.type === "remote" && existing.enabled === true && existing.url === spec.url;
|
|
33095
|
+
if (isCurrent2)
|
|
33096
|
+
return { id, label, path, state: "current" };
|
|
33097
|
+
mcp[MCP_SERVER_NAME] = wanted;
|
|
33098
|
+
cfg.mcp = mcp;
|
|
33099
|
+
writeFileMkdir(path, JSON.stringify(cfg, null, 2) + "\n");
|
|
33100
|
+
return { id, label, path, state: existing ? "repaired" : "created" };
|
|
33101
|
+
}
|
|
33102
|
+
const argv = [launchCommand(spec), ...spec.args ?? []];
|
|
32973
33103
|
const entry = { type: "local", command: argv, enabled: true };
|
|
32974
33104
|
if (spec.env)
|
|
32975
33105
|
entry.environment = { ...existing?.environment, ...spec.env };
|
|
@@ -32982,7 +33112,9 @@ function registerOpencodeJson(path, spec) {
|
|
|
32982
33112
|
return { id, label, path, state: existing ? "repaired" : "created" };
|
|
32983
33113
|
}
|
|
32984
33114
|
function codexBlock(spec) {
|
|
32985
|
-
|
|
33115
|
+
if (spec.url)
|
|
33116
|
+
return [CODEX_HEADER, `url = ${JSON.stringify(spec.url)}`].join("\n") + "\n";
|
|
33117
|
+
const lines = [CODEX_HEADER, `command = ${JSON.stringify(launchCommand(spec))}`];
|
|
32986
33118
|
if (spec.args?.length)
|
|
32987
33119
|
lines.push(`args = [${spec.args.map((a) => JSON.stringify(a)).join(", ")}]`);
|
|
32988
33120
|
const env = Object.entries(spec.env ?? {});
|
|
@@ -33385,7 +33517,7 @@ function relayCommand(bundleDir) {
|
|
|
33385
33517
|
const bin = resolveOnPath("chat-recall-mcp");
|
|
33386
33518
|
return bin ? [bin] : [process.execPath, join55(bundleDir, "mcp-relay.js")];
|
|
33387
33519
|
}
|
|
33388
|
-
function registerRelay(server,
|
|
33520
|
+
function registerRelay(server, _bundleDir, host, env = process.env) {
|
|
33389
33521
|
if (env.CHAT_RECALL_MCP_REGISTRATION?.trim().toLowerCase() === "own") return [];
|
|
33390
33522
|
const kit = optionalKit(env);
|
|
33391
33523
|
if (!kit) return [];
|
|
@@ -33394,8 +33526,7 @@ function registerRelay(server, bundleDir, host, env = process.env) {
|
|
|
33394
33526
|
if (clients.length === 0) return [];
|
|
33395
33527
|
return kit.addMcpServer(machine, clients, {
|
|
33396
33528
|
name: MCP_NAME,
|
|
33397
|
-
url: `${server.replace(/\/+$/, "")}/mcp
|
|
33398
|
-
command: relayCommand(bundleDir)
|
|
33529
|
+
url: `${server.replace(/\/+$/, "")}/mcp`
|
|
33399
33530
|
}).outcomes;
|
|
33400
33531
|
}
|
|
33401
33532
|
var OwnLoginError, LoginError, MCP_NAME, CLI_CLIENT_ID, RUN_TIMEOUT_MS, secretStoreOf;
|
|
@@ -37459,7 +37590,7 @@ var init_intent_drain = __esm({
|
|
|
37459
37590
|
ownVersion2 = JSON.parse(readFileSync52(join65(dir, "../package.json"), "utf-8")).version || ownVersion2;
|
|
37460
37591
|
} catch {
|
|
37461
37592
|
try {
|
|
37462
|
-
if (true) ownVersion2 = "0.7.
|
|
37593
|
+
if (true) ownVersion2 = "0.7.39";
|
|
37463
37594
|
} catch {
|
|
37464
37595
|
}
|
|
37465
37596
|
}
|
|
@@ -38878,6 +39009,7 @@ var init_task_hook = __esm({
|
|
|
38878
39009
|
var service_installer_exports = {};
|
|
38879
39010
|
__export(service_installer_exports, {
|
|
38880
39011
|
ServiceInstallError: () => ServiceInstallError,
|
|
39012
|
+
WATCH_HEAP_MB: () => WATCH_HEAP_MB,
|
|
38881
39013
|
installService: () => installService,
|
|
38882
39014
|
isServiceRunning: () => isServiceRunning,
|
|
38883
39015
|
platformName: () => platformName,
|
|
@@ -38988,9 +39120,8 @@ function renderSystemdUnit(watchJs, node, logFile) {
|
|
|
38988
39120
|
// Bounded heap: the daemon does bursty batch work (transcript parse,
|
|
38989
39121
|
// base64 payloads); V8's default old-space on a big-RAM box is ~4GB and
|
|
38990
39122
|
// GC only gets aggressive near the ceiling — observed as a multi-GB RSS
|
|
38991
|
-
// sawtooth.
|
|
38992
|
-
|
|
38993
|
-
`ExecStart=${node} --max-old-space-size=1536 ${watchJs}`,
|
|
39123
|
+
// sawtooth. The ceiling below is measured, not guessed: see WATCH_HEAP_MB.
|
|
39124
|
+
`ExecStart=${node} --max-old-space-size=${WATCH_HEAP_MB} ${watchJs}`,
|
|
38994
39125
|
// ALWAYS: the collector never ends its own work, so any exit systemd did
|
|
38995
39126
|
// not ask for is a fault. Under on-failure a clean exit left it dead: on
|
|
38996
39127
|
// 2026-09-16 the unit went "inactive (dead) … status=0/SUCCESS" and stayed
|
|
@@ -39063,7 +39194,7 @@ function renderLaunchdPlist(watchJs, node, logFile, label = "com.chat-recall.wat
|
|
|
39063
39194
|
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
|
|
39064
39195
|
'<plist version="1.0"><dict>',
|
|
39065
39196
|
` <key>Label</key><string>${label}</string>`,
|
|
39066
|
-
` <key>ProgramArguments</key><array><string>${node}</string><string>--max-old-space-size
|
|
39197
|
+
` <key>ProgramArguments</key><array><string>${node}</string><string>--max-old-space-size=${WATCH_HEAP_MB}</string><string>${watchJs}</string></array>`,
|
|
39067
39198
|
" <key>RunAtLoad</key><true/>",
|
|
39068
39199
|
" <key>KeepAlive</key><true/>",
|
|
39069
39200
|
` <key>StandardOutPath</key><string>${logFile}</string>`,
|
|
@@ -39074,7 +39205,7 @@ function renderLaunchdPlist(watchJs, node, logFile, label = "com.chat-recall.wat
|
|
|
39074
39205
|
}
|
|
39075
39206
|
function installWindowsTask(watchJs, node, logFile) {
|
|
39076
39207
|
const taskName = "chat-recall-watch";
|
|
39077
|
-
const tr = `cmd /c \\"\\"${node}\\" --max-old-space-size
|
|
39208
|
+
const tr = `cmd /c \\"\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\" >> \\"${logFile}\\" 2>&1\\"`;
|
|
39078
39209
|
try {
|
|
39079
39210
|
execSync5(`schtasks /create /tn "${taskName}" /tr "${tr}" /sc onlogon /rl LIMITED /f`, { stdio: "inherit" });
|
|
39080
39211
|
try {
|
|
@@ -39087,7 +39218,7 @@ function installWindowsTask(watchJs, node, logFile) {
|
|
|
39087
39218
|
return { definitionPath: null, logFile };
|
|
39088
39219
|
}
|
|
39089
39220
|
function renderWindowsTaskCommand(watchJs, node, taskName = "chat-recall-watch", logFile) {
|
|
39090
|
-
const tr = logFile ? `cmd /c \\"\\"${node}\\" --max-old-space-size
|
|
39221
|
+
const tr = logFile ? `cmd /c \\"\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\" >> \\"${logFile}\\" 2>&1\\"` : `\\"${node}\\" --max-old-space-size=${WATCH_HEAP_MB} \\"${watchJs}\\"`;
|
|
39091
39222
|
return `schtasks /create /tn "${taskName}" /tr "${tr}" /sc onlogon /rl LIMITED /f`;
|
|
39092
39223
|
}
|
|
39093
39224
|
function uninstallService() {
|
|
@@ -39138,10 +39269,11 @@ function platformName() {
|
|
|
39138
39269
|
if (process.platform === "win32") return "Scheduled Task";
|
|
39139
39270
|
return process.platform;
|
|
39140
39271
|
}
|
|
39141
|
-
var ServiceInstallError;
|
|
39272
|
+
var WATCH_HEAP_MB, ServiceInstallError;
|
|
39142
39273
|
var init_service_installer = __esm({
|
|
39143
39274
|
"src/service-installer.ts"() {
|
|
39144
39275
|
"use strict";
|
|
39276
|
+
WATCH_HEAP_MB = 640;
|
|
39145
39277
|
ServiceInstallError = class extends Error {
|
|
39146
39278
|
hint;
|
|
39147
39279
|
constructor(message, hint) {
|
|
@@ -39196,6 +39328,47 @@ var init_install_report = __esm({
|
|
|
39196
39328
|
}
|
|
39197
39329
|
});
|
|
39198
39330
|
|
|
39331
|
+
// ../engine/dist/core/remote-target.js
|
|
39332
|
+
var remote_target_exports = {};
|
|
39333
|
+
__export(remote_target_exports, {
|
|
39334
|
+
recallTarget: () => recallTarget
|
|
39335
|
+
});
|
|
39336
|
+
import { readFileSync as readFileSync56 } from "node:fs";
|
|
39337
|
+
import { join as join70 } from "node:path";
|
|
39338
|
+
function recallTarget() {
|
|
39339
|
+
const fromEnv = envCredentials();
|
|
39340
|
+
if (fromEnv)
|
|
39341
|
+
return { base: fromEnv.serverUrl, token: fromEnv.token };
|
|
39342
|
+
try {
|
|
39343
|
+
const raw = readFileSync56(join70(getDataDir(), "credentials.json"), "utf-8");
|
|
39344
|
+
const parsed = JSON.parse(raw);
|
|
39345
|
+
if (Array.isArray(parsed.targets) && parsed.targets.length) {
|
|
39346
|
+
const valid = parsed.targets.filter((t) => t?.serverUrl);
|
|
39347
|
+
if (!valid.length)
|
|
39348
|
+
return null;
|
|
39349
|
+
const norm = (u) => u.replace(/\/+$/, "");
|
|
39350
|
+
const isLocal = (u) => /\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/.test(u);
|
|
39351
|
+
const byUrl = (u) => u ? valid.find((t) => norm(t.serverUrl) === norm(u)) : void 0;
|
|
39352
|
+
const remotes = valid.filter((t) => !isLocal(t.serverUrl));
|
|
39353
|
+
const pick = byUrl(process.env.CHAT_RECALL_SERVER) ?? byUrl(parsed.primary) ?? remotes[0] ?? valid[0];
|
|
39354
|
+
return pick?.serverUrl ? { base: norm(pick.serverUrl), token: targetToken(pick) } : null;
|
|
39355
|
+
}
|
|
39356
|
+
if (parsed.serverUrl)
|
|
39357
|
+
return { base: parsed.serverUrl.replace(/\/+$/, ""), token: parsed.token || "" };
|
|
39358
|
+
return null;
|
|
39359
|
+
} catch {
|
|
39360
|
+
return null;
|
|
39361
|
+
}
|
|
39362
|
+
}
|
|
39363
|
+
var init_remote_target = __esm({
|
|
39364
|
+
"../engine/dist/core/remote-target.js"() {
|
|
39365
|
+
"use strict";
|
|
39366
|
+
init_credentials_env();
|
|
39367
|
+
init_data_dir();
|
|
39368
|
+
init_stored_token();
|
|
39369
|
+
}
|
|
39370
|
+
});
|
|
39371
|
+
|
|
39199
39372
|
// src/bulk-delete.ts
|
|
39200
39373
|
var bulk_delete_exports = {};
|
|
39201
39374
|
__export(bulk_delete_exports, {
|
|
@@ -39494,9 +39667,9 @@ init_project_resolver();
|
|
|
39494
39667
|
import { config } from "dotenv";
|
|
39495
39668
|
import { Command } from "commander";
|
|
39496
39669
|
import chalk2 from "chalk";
|
|
39497
|
-
import { existsSync as existsSync61, readFileSync as
|
|
39670
|
+
import { existsSync as existsSync61, readFileSync as readFileSync57, writeFileSync as writeFileSync25 } from "fs";
|
|
39498
39671
|
import { homedir as homedir25 } from "os";
|
|
39499
|
-
import { join as
|
|
39672
|
+
import { join as join71, resolve as resolve2, dirname as dirname30, basename as basename29 } from "path";
|
|
39500
39673
|
|
|
39501
39674
|
// ../engine/dist/core/score-tier.js
|
|
39502
39675
|
var STRONG_RATIO = 0.85;
|
|
@@ -39740,13 +39913,13 @@ async function serverDelete(path, body2) {
|
|
|
39740
39913
|
}
|
|
39741
39914
|
var pkgEngines = (() => {
|
|
39742
39915
|
try {
|
|
39743
|
-
return JSON.parse(
|
|
39916
|
+
return JSON.parse(readFileSync57(new URL("../package.json", import.meta.url), "utf-8")).engines?.node ?? "";
|
|
39744
39917
|
} catch {
|
|
39745
39918
|
return "";
|
|
39746
39919
|
}
|
|
39747
39920
|
})();
|
|
39748
39921
|
var pkgVersion = JSON.parse(
|
|
39749
|
-
|
|
39922
|
+
readFileSync57(new URL("../package.json", import.meta.url), "utf-8")
|
|
39750
39923
|
).version;
|
|
39751
39924
|
var DEFAULT_SERVER = (process.env.CHAT_RECALL_DEFAULT_SERVER || "https://chatrecall.dev").replace(/\/+$/, "");
|
|
39752
39925
|
var DEFAULT_ALLOW = [
|
|
@@ -39926,10 +40099,10 @@ program.command("init").description("Set up chat-recall: connect to your server,
|
|
|
39926
40099
|
} else if (target) {
|
|
39927
40100
|
}
|
|
39928
40101
|
if (!options.skipMcp) {
|
|
39929
|
-
const projectRoot =
|
|
40102
|
+
const projectRoot = join71(import.meta.dirname, "..");
|
|
39930
40103
|
let mcpBinOnPath = false;
|
|
39931
40104
|
mcpBinOnPath = isOnPath("chat-recall-mcp");
|
|
39932
|
-
const launch = mcpBinOnPath ? { command: "chat-recall-mcp" } : { command: "node", args: [
|
|
40105
|
+
const launch = mcpBinOnPath ? { command: "chat-recall-mcp" } : { command: "node", args: [join71(projectRoot, "dist", "mcp-relay.js")] };
|
|
39933
40106
|
const MCP_ENV = { NODE_OPTIONS: "--max-old-space-size=1024" };
|
|
39934
40107
|
const { registerMcpEverywhere: registerMcpEverywhere2 } = await Promise.resolve().then(() => (init_mcp_clients(), mcp_clients_exports));
|
|
39935
40108
|
const MCP_CLIENT_FOR_BIN = {
|
|
@@ -39950,8 +40123,15 @@ program.command("init").description("Set up chat-recall: connect to your server,
|
|
|
39950
40123
|
} catch (e) {
|
|
39951
40124
|
rep.warn(chalk2.yellow(`could not register chat-recall-mcp with the kit: ${e instanceof Error ? e.message : e}`));
|
|
39952
40125
|
}
|
|
40126
|
+
const hosted = options.server ?? target?.base;
|
|
40127
|
+
const hostedBase = hosted?.replace(/\/+$/, "");
|
|
40128
|
+
const stored = target && hostedBase && hostedBase === target.base.replace(/\/+$/, "") ? target : null;
|
|
39953
40129
|
const results = registerMcpEverywhere2(
|
|
39954
|
-
|
|
40130
|
+
hostedBase ? {
|
|
40131
|
+
url: `${hostedBase}/mcp`,
|
|
40132
|
+
authorization: stored?.token ? `Bearer ${stored.token}` : void 0,
|
|
40133
|
+
headersHelper: stored ? "chat-recall token --header" : void 0
|
|
40134
|
+
} : { ...launch, env: MCP_ENV, alwaysAllow: DEFAULT_ALLOW },
|
|
39955
40135
|
{ extraIds: detectedClients, skipIds: kitDone.has("claude") ? ["claude"] : [] }
|
|
39956
40136
|
);
|
|
39957
40137
|
const ok = results.filter((r) => r.state !== "unparseable");
|
|
@@ -39980,7 +40160,7 @@ program.command("init").description("Set up chat-recall: connect to your server,
|
|
|
39980
40160
|
const detected = checkCodeindexStatus2();
|
|
39981
40161
|
if (detected.installed && !forceInstall) {
|
|
39982
40162
|
if (!options.skipMcp) {
|
|
39983
|
-
const mcpJsonPath =
|
|
40163
|
+
const mcpJsonPath = join71(homedir25(), ".mcp.json");
|
|
39984
40164
|
const reg = registerCodeindexMcp2(mcpJsonPath, detected.path);
|
|
39985
40165
|
}
|
|
39986
40166
|
} else if (forceInstall) {
|
|
@@ -39989,7 +40169,7 @@ program.command("init").description("Set up chat-recall: connect to your server,
|
|
|
39989
40169
|
if (result.installed) {
|
|
39990
40170
|
const sizeMb = result.size ? `${(result.size / 1024 / 1024).toFixed(1)} MB` : "?";
|
|
39991
40171
|
if (!options.skipMcp) {
|
|
39992
|
-
const mcpJsonPath =
|
|
40172
|
+
const mcpJsonPath = join71(homedir25(), ".mcp.json");
|
|
39993
40173
|
const reg = registerCodeindexMcp2(mcpJsonPath, CODEINDEX_BIN_PATH2);
|
|
39994
40174
|
}
|
|
39995
40175
|
} else if (!result.prebuiltAvailable) {
|
|
@@ -40446,7 +40626,7 @@ memory.command("wake-up").description("Generate wake-up context (high-importance
|
|
|
40446
40626
|
const identityFile = getIdentityFilePath();
|
|
40447
40627
|
let identity = "AI coding assistant";
|
|
40448
40628
|
if (existsSync61(identityFile)) {
|
|
40449
|
-
identity =
|
|
40629
|
+
identity = readFileSync57(identityFile, "utf-8").trim();
|
|
40450
40630
|
}
|
|
40451
40631
|
const lines = [
|
|
40452
40632
|
chalk2.bold("# Wake-Up Context"),
|
|
@@ -40546,7 +40726,7 @@ program.command("feedback").argument("<message...>", "what you want to say \u201
|
|
|
40546
40726
|
}
|
|
40547
40727
|
});
|
|
40548
40728
|
program.command("doctor").description("Quick health check across login, server, credentials, hooks, MCP server, and codeindex").option("--purge-local", "Remove the legacy local index (cache.db + vector/KG files) left by pre-thin-collector versions \u2014 storage is server-side now. Requires login; keeps credentials, sync ledger, identity, and the audit log.").action(async (opts) => {
|
|
40549
|
-
const { existsSync: existsSync62, readFileSync:
|
|
40729
|
+
const { existsSync: existsSync62, readFileSync: readFileSync58, statSync: statSync49 } = await import("fs");
|
|
40550
40730
|
const { execSync: execSync6 } = await import("child_process");
|
|
40551
40731
|
const rows = [];
|
|
40552
40732
|
const note = (ok, label, detail) => rows.push({ ok, label, detail });
|
|
@@ -40609,7 +40789,7 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40609
40789
|
}
|
|
40610
40790
|
}
|
|
40611
40791
|
}
|
|
40612
|
-
const credFile =
|
|
40792
|
+
const credFile = join71(getDataDir(), "credentials.json");
|
|
40613
40793
|
if (!existsSync62(credFile)) {
|
|
40614
40794
|
note(false, "Credentials file", `missing \u2014 run \`chat-recall login <server-url>\``);
|
|
40615
40795
|
} else {
|
|
@@ -40629,14 +40809,14 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40629
40809
|
const label = `Claude hooks (${profile})`;
|
|
40630
40810
|
let hooks;
|
|
40631
40811
|
try {
|
|
40632
|
-
hooks = existsSync62(settingsFile) ? JSON.parse(
|
|
40812
|
+
hooks = existsSync62(settingsFile) ? JSON.parse(readFileSync58(settingsFile, "utf-8")).hooks || {} : {};
|
|
40633
40813
|
} catch {
|
|
40634
40814
|
note(false, label, `${settingsFile} is not valid JSON, so no hook in it runs`);
|
|
40635
40815
|
continue;
|
|
40636
40816
|
}
|
|
40637
|
-
const legacy =
|
|
40817
|
+
const legacy = join71(dirname30(settingsFile), "hooks.json");
|
|
40638
40818
|
try {
|
|
40639
|
-
const stranded = existsSync62(legacy) ? Object.values(JSON.parse(
|
|
40819
|
+
const stranded = existsSync62(legacy) ? Object.values(JSON.parse(readFileSync58(legacy, "utf-8")).hooks || {}).flat().filter(isOurEntry2).length : 0;
|
|
40640
40820
|
if (stranded) note(false, `Old hook file (${profile})`, `${stranded} chat-recall entr${stranded === 1 ? "y" : "ies"} in ${legacy}, which Claude Code does not read \u2014 run \`chat-recall install-hooks\` to move them`);
|
|
40641
40821
|
} catch {
|
|
40642
40822
|
}
|
|
@@ -40671,7 +40851,7 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40671
40851
|
}
|
|
40672
40852
|
let registered = false;
|
|
40673
40853
|
try {
|
|
40674
|
-
const cfg = JSON.parse(
|
|
40854
|
+
const cfg = JSON.parse(readFileSync58(target2.configPath, "utf-8"));
|
|
40675
40855
|
registered = JSON.stringify(cfg).includes("chat_recall_guard");
|
|
40676
40856
|
} catch {
|
|
40677
40857
|
}
|
|
@@ -40689,7 +40869,7 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40689
40869
|
let registered = existsSync62(target2.configPath);
|
|
40690
40870
|
if (registered) {
|
|
40691
40871
|
try {
|
|
40692
|
-
const text =
|
|
40872
|
+
const text = readFileSync58(target2.configPath, "utf-8");
|
|
40693
40873
|
registered = text.includes("chat_recall_messages_") || reg.isOurPluginSource(text);
|
|
40694
40874
|
} catch {
|
|
40695
40875
|
registered = false;
|
|
@@ -40704,7 +40884,7 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40704
40884
|
try {
|
|
40705
40885
|
if (existsSync62(opencodeConfigDir())) {
|
|
40706
40886
|
const path = tuiConfigPath();
|
|
40707
|
-
const present = existsSync62(path) && hasTuiPluginEntry(
|
|
40887
|
+
const present = existsSync62(path) && hasTuiPluginEntry(readFileSync58(path, "utf-8"), tuiPluginEntry());
|
|
40708
40888
|
note(
|
|
40709
40889
|
present,
|
|
40710
40890
|
"Messages \u2014 OpenCode TUI",
|
|
@@ -40719,7 +40899,7 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40719
40899
|
const want = bundledSkillNames2().length;
|
|
40720
40900
|
for (const t of skillTargets2()) {
|
|
40721
40901
|
if (!t.available) continue;
|
|
40722
|
-
const have = want === 0 ? 0 : bundledSkillNames2().filter((n) => existsSync62(
|
|
40902
|
+
const have = want === 0 ? 0 : bundledSkillNames2().filter((n) => existsSync62(join71(t.dir, n, ".chat-recall-managed"))).length;
|
|
40723
40903
|
note(
|
|
40724
40904
|
have === want,
|
|
40725
40905
|
`Skills \u2014 ${t.label}`,
|
|
@@ -40794,12 +40974,12 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
40794
40974
|
note(watchRunning, "Watch daemon", watchRunning ? "running" : "not running (run `chat-recall watch --install-service` to keep collection running)");
|
|
40795
40975
|
const dataDir = getDataDir();
|
|
40796
40976
|
const legacyPaths = [
|
|
40797
|
-
|
|
40798
|
-
|
|
40799
|
-
|
|
40800
|
-
|
|
40801
|
-
|
|
40802
|
-
|
|
40977
|
+
join71(dataDir, "cache.db"),
|
|
40978
|
+
join71(dataDir, "cache.db-wal"),
|
|
40979
|
+
join71(dataDir, "cache.db-shm"),
|
|
40980
|
+
join71(dataDir, "index", "lancedb"),
|
|
40981
|
+
join71(dataDir, "index", "knowledge_graph.db"),
|
|
40982
|
+
join71(dataDir, "index", "metadata.db")
|
|
40803
40983
|
];
|
|
40804
40984
|
const legacyPresent = legacyPaths.filter((p) => existsSync62(p));
|
|
40805
40985
|
if (opts.purgeLocal) {
|
|
@@ -40872,7 +41052,7 @@ companions.command("install").description("Install codeindex (downloads from mun
|
|
|
40872
41052
|
if (result.installed) {
|
|
40873
41053
|
const sizeMb = result.size ? `${(result.size / 1024 / 1024).toFixed(1)} MB` : "?";
|
|
40874
41054
|
console.log(chalk2.green(`\u2713 codeindex installed (${sizeMb}) \u2192 ${result.path}`));
|
|
40875
|
-
const mcpJsonPath =
|
|
41055
|
+
const mcpJsonPath = join71(homedir25(), ".mcp.json");
|
|
40876
41056
|
const reg = registerCodeindexMcp2(mcpJsonPath, CODEINDEX_BIN_PATH2);
|
|
40877
41057
|
if (reg.added) console.log(chalk2.dim(` Registered as MCP server in ${mcpJsonPath}`));
|
|
40878
41058
|
else console.log(chalk2.dim(` Already registered as MCP server`));
|
|
@@ -40894,7 +41074,7 @@ companions.command("uninstall").description("Remove the codeindex binary chat-re
|
|
|
40894
41074
|
const r = uninstallCodeindex2();
|
|
40895
41075
|
if (r.removed) console.log(chalk2.green(`\u2713 Removed ${r.path}`));
|
|
40896
41076
|
else console.log(chalk2.dim(` Nothing to remove at ${r.path}`));
|
|
40897
|
-
const mcpJsonPath =
|
|
41077
|
+
const mcpJsonPath = join71(homedir25(), ".mcp.json");
|
|
40898
41078
|
const u = unregisterCodeindexMcp2(mcpJsonPath);
|
|
40899
41079
|
if (u.removed) console.log(chalk2.dim(` Unregistered MCP server from ${mcpJsonPath}`));
|
|
40900
41080
|
});
|
|
@@ -41446,10 +41626,10 @@ tasks.command("pull [dir]").description("Write TEAM_TASKS.md for your tasks in t
|
|
|
41446
41626
|
try {
|
|
41447
41627
|
const { resolveProjectId: resolveProjectId2 } = await Promise.resolve().then(() => (init_project_resolver(), project_resolver_exports));
|
|
41448
41628
|
const { renderTeamTasksMd: renderTeamTasksMd2, parseTeamTasksFile: parseTeamTasksFile2 } = await Promise.resolve().then(() => (init_project_tasks(), project_tasks_exports));
|
|
41449
|
-
const { writeFileSync: writeFileSync26, readFileSync:
|
|
41450
|
-
const { join:
|
|
41451
|
-
const file =
|
|
41452
|
-
if (!opts.force && existsSync62(file) && parseTeamTasksFile2(
|
|
41629
|
+
const { writeFileSync: writeFileSync26, readFileSync: readFileSync58, existsSync: existsSync62 } = await import("node:fs");
|
|
41630
|
+
const { join: join72 } = await import("node:path");
|
|
41631
|
+
const file = join72(cwd, "TEAM_TASKS.md");
|
|
41632
|
+
if (!opts.force && existsSync62(file) && parseTeamTasksFile2(readFileSync58(file, "utf8")).length > 0) {
|
|
41453
41633
|
console.error(chalk2.red("TEAM_TASKS.md has unpushed edits."), "Run", chalk2.bold("chat-recall tasks push"), "first, or", chalk2.bold("tasks pull --force"), "to discard.");
|
|
41454
41634
|
process.exit(1);
|
|
41455
41635
|
}
|
|
@@ -41468,14 +41648,14 @@ tasks.command("push [dir]").description("Push TEAM_TASKS.md status edits back to
|
|
|
41468
41648
|
const cwd = dir || process.cwd();
|
|
41469
41649
|
try {
|
|
41470
41650
|
const { parseTeamTasksFile: parseTeamTasksFile2 } = await Promise.resolve().then(() => (init_project_tasks(), project_tasks_exports));
|
|
41471
|
-
const { readFileSync:
|
|
41472
|
-
const { join:
|
|
41473
|
-
const file =
|
|
41651
|
+
const { readFileSync: readFileSync58, existsSync: existsSync62 } = await import("node:fs");
|
|
41652
|
+
const { join: join72 } = await import("node:path");
|
|
41653
|
+
const file = join72(cwd, "TEAM_TASKS.md");
|
|
41474
41654
|
if (!existsSync62(file)) {
|
|
41475
41655
|
console.error(chalk2.red("no TEAM_TASKS.md here \u2014"), "run", chalk2.bold("chat-recall tasks pull"), "first");
|
|
41476
41656
|
process.exit(1);
|
|
41477
41657
|
}
|
|
41478
|
-
const edits = parseTeamTasksFile2(
|
|
41658
|
+
const edits = parseTeamTasksFile2(readFileSync58(file, "utf8"));
|
|
41479
41659
|
let n = 0;
|
|
41480
41660
|
for (const e of edits) {
|
|
41481
41661
|
await serverPatch(`/api/tasks/${encodeURIComponent(e.id)}`, { status: e.intent });
|
|
@@ -41581,8 +41761,8 @@ team.command("publish <type> <name> <file>").description("Publish a local file a
|
|
|
41581
41761
|
console.error(chalk2.red(`Invalid tool: ${opts.tool}. Must be one of: ${validTools.join(", ")}`));
|
|
41582
41762
|
process.exit(1);
|
|
41583
41763
|
}
|
|
41584
|
-
const { readFileSync:
|
|
41585
|
-
const body2 =
|
|
41764
|
+
const { readFileSync: readFileSync58 } = await import("fs");
|
|
41765
|
+
const body2 = readFileSync58(file);
|
|
41586
41766
|
const { teamPublish: teamPublish2 } = await Promise.resolve().then(() => (init_team_client(), team_client_exports));
|
|
41587
41767
|
const a = await teamPublish2({
|
|
41588
41768
|
type,
|
|
@@ -42493,6 +42673,15 @@ exclude.command("remove <value>").description("Remove an exclusion (tool name or
|
|
|
42493
42673
|
console.log(chalk2.green(`\u2713 Removed ${value}`));
|
|
42494
42674
|
});
|
|
42495
42675
|
program.command("login [server-url]").description(`Log in (device flow), mint a sync device token, keep it in sealkeep, the OS keyring or a file only you can read, and register chat-recall-mcp in your AI tools. Defaults to ${DEFAULT_SERVER}.`).option("--token <token>", "Self-host: skip OIDC and save this device token directly").option("--check", "Report-only: exit 0 if a working credential for this server exists, 1 otherwise (never interactive)").option("--issuer <url>", "OIDC issuer URL (default: learned from the server via /api/capabilities)").option("--client-id <id>", "OIDC client id (default: chat-recall-web)").option("--team <slug>", "Team to mint the device token for (default: your only team)").option("--device-id <id>", "Device id for this machine (default: hostname)").option("--prompt-json", "Print the device prompt as one JSON line on stdout, then wait for approval", false).option("--skip-mcp", "Do not register chat-recall-mcp in the AI tools of this machine").action((serverUrl, opts) => runLogin(serverUrl || DEFAULT_SERVER, opts));
|
|
42676
|
+
program.command("token").description("Print the credential of this machine, for a client that runs a header helper instead of a sign-in").option("--header", "Print the whole Authorization header value").action(async (opts) => {
|
|
42677
|
+
const { recallTarget: recallTarget2 } = await Promise.resolve().then(() => (init_remote_target(), remote_target_exports));
|
|
42678
|
+
const target = recallTarget2();
|
|
42679
|
+
if (!target?.token) {
|
|
42680
|
+
console.error(chalk2.red("No stored credential.") + chalk2.dim(" Run `chat-recall login` first."));
|
|
42681
|
+
process.exit(1);
|
|
42682
|
+
}
|
|
42683
|
+
console.log(opts.header ? `Bearer ${target.token}` : target.token);
|
|
42684
|
+
});
|
|
42496
42685
|
program.command("logout <server-url>").description("Remove one sync target (other targets keep syncing)").action(async (serverUrl) => {
|
|
42497
42686
|
const { removeCredentials: removeCredentials2, loadAllCredentials: loadAllCredentials2 } = await Promise.resolve().then(() => (init_sync_client(), sync_client_exports));
|
|
42498
42687
|
if (removeCredentials2(serverUrl)) {
|