chat-recall 0.7.36 → 0.7.38
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/channel-detect.d.ts.map +1 -1
- package/dist/channel-detect.js +9 -0
- package/dist/channel-detect.js.map +1 -1
- package/dist/channel-state.d.ts.map +1 -1
- package/dist/channel-state.js +16 -2
- package/dist/channel-state.js.map +1 -1
- package/dist/cli.js +75 -6
- package/dist/mcp-relay.js +11 -1
- package/dist/mcp.js +1477 -612
- package/dist/message-hook.js +16 -4
- package/dist/sync-client.d.ts +17 -1
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +75 -3
- 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 +85 -8
- package/package.json +1 -1
package/dist/watch.js
CHANGED
|
@@ -15136,6 +15136,36 @@ var init_secret_precision = __esm({
|
|
|
15136
15136
|
}
|
|
15137
15137
|
});
|
|
15138
15138
|
|
|
15139
|
+
// src/walk-budget.ts
|
|
15140
|
+
function walkSessionLimit(env = process.env) {
|
|
15141
|
+
const raw = env.CHAT_RECALL_SYNC_WALK_MAX;
|
|
15142
|
+
if (raw === void 0 || raw.trim() === "") return DEFAULT_WALK_MAX_SESSIONS;
|
|
15143
|
+
const n = Number(raw);
|
|
15144
|
+
if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) return DEFAULT_WALK_MAX_SESSIONS;
|
|
15145
|
+
return n;
|
|
15146
|
+
}
|
|
15147
|
+
function orderRefsForWalk(refs, isAcked) {
|
|
15148
|
+
const fresh = [];
|
|
15149
|
+
const acked = [];
|
|
15150
|
+
for (const ref of refs) (isAcked(ref.prefixedId) ? acked : fresh).push(ref);
|
|
15151
|
+
return [...fresh, ...acked];
|
|
15152
|
+
}
|
|
15153
|
+
function shouldWalkFull(opts) {
|
|
15154
|
+
const { lastSuccessAt, now } = opts;
|
|
15155
|
+
const interval = opts.fullIntervalMs ?? FULL_WALK_INTERVAL_MS;
|
|
15156
|
+
if (typeof lastSuccessAt !== "number" || !Number.isFinite(lastSuccessAt) || lastSuccessAt <= 0) return true;
|
|
15157
|
+
if (lastSuccessAt > now) return true;
|
|
15158
|
+
return now - lastSuccessAt >= interval;
|
|
15159
|
+
}
|
|
15160
|
+
var DEFAULT_WALK_MAX_SESSIONS, FULL_WALK_INTERVAL_MS;
|
|
15161
|
+
var init_walk_budget = __esm({
|
|
15162
|
+
"src/walk-budget.ts"() {
|
|
15163
|
+
"use strict";
|
|
15164
|
+
DEFAULT_WALK_MAX_SESSIONS = 2e3;
|
|
15165
|
+
FULL_WALK_INTERVAL_MS = 6 * 60 * 6e4;
|
|
15166
|
+
}
|
|
15167
|
+
});
|
|
15168
|
+
|
|
15139
15169
|
// ../engine/dist/transcript/types.js
|
|
15140
15170
|
var TRANSCRIPT_VERSION;
|
|
15141
15171
|
var init_types = __esm({
|
|
@@ -27785,7 +27815,7 @@ var init_http = __esm({
|
|
|
27785
27815
|
CLI_VERSION = JSON.parse(readFileSync37(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
|
|
27786
27816
|
} catch {
|
|
27787
27817
|
try {
|
|
27788
|
-
if (true) CLI_VERSION = "0.7.
|
|
27818
|
+
if (true) CLI_VERSION = "0.7.38";
|
|
27789
27819
|
} catch {
|
|
27790
27820
|
}
|
|
27791
27821
|
}
|
|
@@ -28279,7 +28309,7 @@ var init_telemetry = __esm({
|
|
|
28279
28309
|
init_sync_client();
|
|
28280
28310
|
cliVersion = () => {
|
|
28281
28311
|
try {
|
|
28282
|
-
return true ? "0.7.
|
|
28312
|
+
return true ? "0.7.38" : "dev";
|
|
28283
28313
|
} catch {
|
|
28284
28314
|
return "dev";
|
|
28285
28315
|
}
|
|
@@ -28976,11 +29006,15 @@ function isStandingFailure(err) {
|
|
|
28976
29006
|
const c = taggedClass(err);
|
|
28977
29007
|
return c !== null && STANDING_FAILURE.has(c);
|
|
28978
29008
|
}
|
|
29009
|
+
function countsForBreaker(cls) {
|
|
29010
|
+
return cls !== "rate_limited" && cls !== "payload_too_large";
|
|
29011
|
+
}
|
|
28979
29012
|
function classifyError(msg, err) {
|
|
28980
29013
|
const tagged = taggedClass(err);
|
|
28981
29014
|
if (tagged) return tagged;
|
|
28982
29015
|
const m = msg.toLowerCase();
|
|
28983
29016
|
if (m.includes("429")) return "rate_limited";
|
|
29017
|
+
if (m.includes("body_too_large") || m.includes("payload too large") || m.includes("entity too large")) return "payload_too_large";
|
|
28984
29018
|
if (m.includes("402")) return "payment_required";
|
|
28985
29019
|
if (m.includes("401") || m.includes("403") || m.includes("token")) return "auth";
|
|
28986
29020
|
if (m.includes("timed out") || m.includes("etimedout") || m.includes("aborted due to timeout")) return "timeout";
|
|
@@ -29215,6 +29249,12 @@ async function syncSessions(opts = {}) {
|
|
|
29215
29249
|
const msg = e instanceof Error ? e.message : String(e);
|
|
29216
29250
|
errors.push(`${cred.serverUrl}: ${msg}`);
|
|
29217
29251
|
perTarget[cred.serverUrl] = { ok: false, error: msg, accepted: acceptedUploads.get(cred.serverUrl) ?? 0 };
|
|
29252
|
+
const cls = classifyError(msg, e);
|
|
29253
|
+
if (!countsForBreaker(cls)) {
|
|
29254
|
+
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`);
|
|
29255
|
+
record({ kind: "target_throttled", failures: 0, retryInMs: 0, errorClass: cls, local: isLocalHost(cred.serverUrl) ? 1 : 0 });
|
|
29256
|
+
continue;
|
|
29257
|
+
}
|
|
29218
29258
|
const next = noteTargetFailure(cred.serverUrl, msg);
|
|
29219
29259
|
const notice = breakerNotice(cred.serverUrl, next);
|
|
29220
29260
|
if (notice) console.error(`[sync] ${notice}`);
|
|
@@ -29227,7 +29267,7 @@ async function syncSessions(opts = {}) {
|
|
|
29227
29267
|
kind: next.tripped ? "breaker_trip" : "target_failure",
|
|
29228
29268
|
failures: next.failures,
|
|
29229
29269
|
retryInMs: next.retryInMs,
|
|
29230
|
-
errorClass:
|
|
29270
|
+
errorClass: cls,
|
|
29231
29271
|
local: isLocalHost(cred.serverUrl) ? 1 : 0
|
|
29232
29272
|
});
|
|
29233
29273
|
}
|
|
@@ -29252,6 +29292,11 @@ async function syncSessions(opts = {}) {
|
|
|
29252
29292
|
rssPeakMb: Math.round(process.memoryUsage().rss / 1048576)
|
|
29253
29293
|
});
|
|
29254
29294
|
}
|
|
29295
|
+
if (agg) {
|
|
29296
|
+
for (const t of targets) {
|
|
29297
|
+
if (!errors.some((e) => e.startsWith(`${t.serverUrl}:`))) noteWalkSuccess(t.serverUrl);
|
|
29298
|
+
}
|
|
29299
|
+
}
|
|
29255
29300
|
void flush().catch(() => {
|
|
29256
29301
|
});
|
|
29257
29302
|
if (!agg) throw new Error(`sync failed for all targets:
|
|
@@ -29260,6 +29305,32 @@ async function syncSessions(opts = {}) {
|
|
|
29260
29305
|
${errors.join("\n ")}`);
|
|
29261
29306
|
return { ...agg, perTarget };
|
|
29262
29307
|
}
|
|
29308
|
+
function walkStatePath() {
|
|
29309
|
+
return join47(getDataDir(), "walk-state.json");
|
|
29310
|
+
}
|
|
29311
|
+
function readWalkState() {
|
|
29312
|
+
try {
|
|
29313
|
+
const raw = JSON.parse(readFileSync41(walkStatePath(), "utf-8"));
|
|
29314
|
+
return raw && typeof raw === "object" ? raw : {};
|
|
29315
|
+
} catch {
|
|
29316
|
+
return {};
|
|
29317
|
+
}
|
|
29318
|
+
}
|
|
29319
|
+
function noteWalkSuccess(serverUrl) {
|
|
29320
|
+
try {
|
|
29321
|
+
const state2 = readWalkState();
|
|
29322
|
+
state2[serverUrl.replace(/\/+$/, "")] = Date.now();
|
|
29323
|
+
mkdirSync11(getDataDir(), { recursive: true });
|
|
29324
|
+
writeFileSync10(walkStatePath(), JSON.stringify(state2));
|
|
29325
|
+
} catch {
|
|
29326
|
+
}
|
|
29327
|
+
}
|
|
29328
|
+
function lastSuccessfulWalkAt(serverUrl) {
|
|
29329
|
+
const state2 = readWalkState();
|
|
29330
|
+
const key2 = serverUrl?.replace(/\/+$/, "");
|
|
29331
|
+
const stamps = key2 ? [state2[key2]] : Object.values(state2);
|
|
29332
|
+
return stamps.reduce((max, v) => Math.max(max, typeof v === "number" ? v : 0), 0);
|
|
29333
|
+
}
|
|
29263
29334
|
async function postFieldBatch(base3, token, rows) {
|
|
29264
29335
|
const headers = { "content-type": "application/json" };
|
|
29265
29336
|
if (token) headers.authorization = `Bearer ${token}`;
|
|
@@ -29762,7 +29833,9 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
29762
29833
|
}
|
|
29763
29834
|
};
|
|
29764
29835
|
let scanMs = 0, scanned = 0;
|
|
29765
|
-
const
|
|
29836
|
+
const walkMax = opts.limit ?? walkSessionLimit();
|
|
29837
|
+
const ordered = walkMax > 0 ? orderRefsForWalk(refs, (id) => Boolean(ledger?.get(id))) : refs;
|
|
29838
|
+
const slice = walkMax > 0 ? ordered.slice(0, walkMax) : ordered;
|
|
29766
29839
|
const trace = process.env.CHAT_RECALL_SYNC_TRACE === "1" ? (msg) => {
|
|
29767
29840
|
const m = process.memoryUsage();
|
|
29768
29841
|
console.error(`[sync-trace] ${msg} \xB7 heap=${(m.heapUsed / 1048576).toFixed(0)}MB rss=${(m.rss / 1048576).toFixed(0)}MB`);
|
|
@@ -30617,6 +30690,7 @@ var init_sync_client = __esm({
|
|
|
30617
30690
|
init_secret_precision();
|
|
30618
30691
|
init_settings();
|
|
30619
30692
|
init_paths();
|
|
30693
|
+
init_walk_budget();
|
|
30620
30694
|
init_tool_backend();
|
|
30621
30695
|
init_transcript();
|
|
30622
30696
|
init_claude();
|
|
@@ -30650,7 +30724,7 @@ var init_sync_client = __esm({
|
|
|
30650
30724
|
ownVersion = JSON.parse(readFileSync41(join47(dir, "../package.json"), "utf-8")).version || ownVersion;
|
|
30651
30725
|
} catch {
|
|
30652
30726
|
try {
|
|
30653
|
-
if (true) ownVersion = "0.7.
|
|
30727
|
+
if (true) ownVersion = "0.7.38";
|
|
30654
30728
|
} catch {
|
|
30655
30729
|
}
|
|
30656
30730
|
}
|
|
@@ -32456,7 +32530,7 @@ var init_intent_drain = __esm({
|
|
|
32456
32530
|
ownVersion2 = JSON.parse(readFileSync45(join53(dir, "../package.json"), "utf-8")).version || ownVersion2;
|
|
32457
32531
|
} catch {
|
|
32458
32532
|
try {
|
|
32459
|
-
if (true) ownVersion2 = "0.7.
|
|
32533
|
+
if (true) ownVersion2 = "0.7.38";
|
|
32460
32534
|
} catch {
|
|
32461
32535
|
}
|
|
32462
32536
|
}
|
|
@@ -34448,7 +34522,9 @@ async function shipToServer(trigger) {
|
|
|
34448
34522
|
if (syncInFlight) return;
|
|
34449
34523
|
syncInFlight = true;
|
|
34450
34524
|
try {
|
|
34451
|
-
const
|
|
34525
|
+
const recentSuccess = !shouldWalkFull({ lastSuccessAt: lastSuccessfulWalkAt(), now: Date.now() });
|
|
34526
|
+
const scope = trigger === "file-change" || trigger === "startup" && recentSuccess ? "changed" : "full";
|
|
34527
|
+
const result = await syncIncremental({ scope });
|
|
34452
34528
|
if (isSyncSkip(result)) {
|
|
34453
34529
|
if (result.skipped === "no-credentials") {
|
|
34454
34530
|
daemonLog.warn(`Sync skipped (${trigger}): not logged in \u2014 run \`chat-recall login\` to ship sessions to a server.`);
|
|
@@ -34792,6 +34868,7 @@ var init_indexer = __esm({
|
|
|
34792
34868
|
init_collector_health();
|
|
34793
34869
|
init_settings();
|
|
34794
34870
|
init_sync_client();
|
|
34871
|
+
init_walk_budget();
|
|
34795
34872
|
init_http();
|
|
34796
34873
|
init_intent_drain();
|
|
34797
34874
|
init_sync_client();
|
|
@@ -34805,7 +34882,7 @@ var init_indexer = __esm({
|
|
|
34805
34882
|
init_collector_migrate();
|
|
34806
34883
|
init_sync_ledger();
|
|
34807
34884
|
init_collector_health();
|
|
34808
|
-
CLI_VERSION3 = true ? "0.7.
|
|
34885
|
+
CLI_VERSION3 = true ? "0.7.38" : "0.0.0";
|
|
34809
34886
|
DEBOUNCE_MS = 5e3;
|
|
34810
34887
|
PLANS_DIR = claudeBackend.plansDir();
|
|
34811
34888
|
TASKS_DIR = claudeBackend.tasksDir();
|