chat-recall 0.7.62 → 0.7.64
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 +71 -67
- package/dist/mcp.js +71 -67
- package/dist/memory-guard.d.ts +7 -0
- package/dist/memory-guard.d.ts.map +1 -1
- package/dist/memory-guard.js +11 -0
- package/dist/memory-guard.js.map +1 -1
- package/dist/scan-worker.js +1 -0
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +4 -2
- package/dist/sync-client.js.map +1 -1
- package/dist/watch.js +71 -67
- package/package.json +1 -1
package/dist/watch.js
CHANGED
|
@@ -6572,7 +6572,7 @@ var init_claude = __esm({
|
|
|
6572
6572
|
// ../engine/dist/transcript/codex.js
|
|
6573
6573
|
import { open as open2, readdir as readdir2, stat as stat2 } from "fs/promises";
|
|
6574
6574
|
import { dirname as dirname6, join as join9, basename as basename4 } from "path";
|
|
6575
|
-
async function parseCodexSubagents(sessionPath) {
|
|
6575
|
+
async function parseCodexSubagents(sessionPath, opts = {}) {
|
|
6576
6576
|
const dayDir = dirname6(sessionPath);
|
|
6577
6577
|
const parentId = basename4(sessionPath).match(/([a-f0-9-]{36})\.jsonl$/i)?.[1];
|
|
6578
6578
|
if (!parentId)
|
|
@@ -6625,7 +6625,7 @@ async function parseCodexSubagents(sessionPath) {
|
|
|
6625
6625
|
const kind = role.includes("compact") ? "compact" : role.includes("aside") ? "aside" : role.includes("worker") || role.includes("explore") ? "explore" : "other";
|
|
6626
6626
|
let messages = [];
|
|
6627
6627
|
try {
|
|
6628
|
-
messages = await parseCodexTranscript(filePath);
|
|
6628
|
+
messages = await parseCodexTranscript(filePath, opts);
|
|
6629
6629
|
} catch (e) {
|
|
6630
6630
|
log3.error({ err: e, filePath }, "Failed to parse Codex sub-agent");
|
|
6631
6631
|
}
|
|
@@ -6667,80 +6667,77 @@ function isCodexInjectedWrapper(text) {
|
|
|
6667
6667
|
const trimmed = text.trim();
|
|
6668
6668
|
return trimmed.startsWith("<environment_context>") || trimmed.startsWith("<permissions instructions>") || trimmed.startsWith("<user_instructions>") || trimmed.startsWith("<system_prompt>");
|
|
6669
6669
|
}
|
|
6670
|
-
async function parseCodexTranscript(sessionPath) {
|
|
6671
|
-
const
|
|
6672
|
-
|
|
6670
|
+
async function parseCodexTranscript(sessionPath, opts = {}) {
|
|
6671
|
+
const fh = await open2(sessionPath);
|
|
6672
|
+
const messages = [];
|
|
6673
|
+
const add = codexLineHandler(messages, opts);
|
|
6674
|
+
try {
|
|
6675
|
+
let lineNum = 0;
|
|
6676
|
+
for await (const line of fh.readLines())
|
|
6677
|
+
add(++lineNum, line);
|
|
6678
|
+
} finally {
|
|
6679
|
+
await fh.close();
|
|
6680
|
+
}
|
|
6681
|
+
return messages;
|
|
6673
6682
|
}
|
|
6674
|
-
function parseCodexTranscriptText(text) {
|
|
6683
|
+
function parseCodexTranscriptText(text, opts = {}) {
|
|
6675
6684
|
const messages = [];
|
|
6685
|
+
const add = codexLineHandler(messages, opts);
|
|
6676
6686
|
let lineNum = 0;
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
line: lineNum,
|
|
6712
|
-
role: "assistant",
|
|
6713
|
-
content: "",
|
|
6714
|
-
thinking: summary,
|
|
6715
|
-
timestamp: obj.timestamp
|
|
6716
|
-
});
|
|
6717
|
-
} else if (obj.type === "response_item" && obj.payload?.type === "function_call") {
|
|
6718
|
-
let input = obj.payload.arguments || {};
|
|
6719
|
-
if (typeof input === "string") {
|
|
6720
|
-
try {
|
|
6721
|
-
input = JSON.parse(input);
|
|
6722
|
-
} catch {
|
|
6723
|
-
}
|
|
6687
|
+
for (const line of text.split("\n"))
|
|
6688
|
+
add(++lineNum, line);
|
|
6689
|
+
return messages;
|
|
6690
|
+
}
|
|
6691
|
+
function codexLineHandler(messages, opts) {
|
|
6692
|
+
const cap = opts.payloadCap ? (v) => capPayload(v, opts.payloadCap) : (v) => v;
|
|
6693
|
+
return (lineNum, line) => {
|
|
6694
|
+
if (!line.trim())
|
|
6695
|
+
return;
|
|
6696
|
+
try {
|
|
6697
|
+
const obj = JSON.parse(line);
|
|
6698
|
+
if (obj.type === "event_msg" && obj.payload?.type === "user_message") {
|
|
6699
|
+
const text = String(obj.payload.message || "").trim();
|
|
6700
|
+
if (!text || isCodexInjectedWrapper(text))
|
|
6701
|
+
return;
|
|
6702
|
+
messages.push({ line: lineNum, role: "user", content: text, timestamp: obj.timestamp });
|
|
6703
|
+
} else if (obj.type === "response_item" && obj.payload?.type === "message") {
|
|
6704
|
+
if (obj.payload.role !== "assistant")
|
|
6705
|
+
return;
|
|
6706
|
+
const text = flattenCodexContent(obj.payload.content);
|
|
6707
|
+
if (!text.trim())
|
|
6708
|
+
return;
|
|
6709
|
+
messages.push({ line: lineNum, role: "assistant", content: text, timestamp: obj.timestamp });
|
|
6710
|
+
} else if (obj.type === "response_item" && obj.payload?.type === "reasoning") {
|
|
6711
|
+
const summary = Array.isArray(obj.payload.summary) ? obj.payload.summary.map((s) => s?.text || "").filter(Boolean).join("\n") : "";
|
|
6712
|
+
if (!summary.trim())
|
|
6713
|
+
return;
|
|
6714
|
+
messages.push({ line: lineNum, role: "assistant", content: "", thinking: cap(summary), timestamp: obj.timestamp });
|
|
6715
|
+
} else if (obj.type === "response_item" && obj.payload?.type === "function_call") {
|
|
6716
|
+
let input = obj.payload.arguments || {};
|
|
6717
|
+
if (typeof input === "string") {
|
|
6718
|
+
try {
|
|
6719
|
+
input = JSON.parse(input);
|
|
6720
|
+
} catch {
|
|
6724
6721
|
}
|
|
6725
|
-
messages.push({
|
|
6726
|
-
line: lineNum,
|
|
6727
|
-
role: "assistant",
|
|
6728
|
-
content: "",
|
|
6729
|
-
toolCalls: [{ name: obj.payload.name || "", input }],
|
|
6730
|
-
timestamp: obj.timestamp
|
|
6731
|
-
});
|
|
6732
6722
|
}
|
|
6733
|
-
|
|
6723
|
+
messages.push({
|
|
6724
|
+
line: lineNum,
|
|
6725
|
+
role: "assistant",
|
|
6726
|
+
content: "",
|
|
6727
|
+
toolCalls: [{ name: obj.payload.name || "", input: cap(input) }],
|
|
6728
|
+
timestamp: obj.timestamp
|
|
6729
|
+
});
|
|
6734
6730
|
}
|
|
6731
|
+
} catch {
|
|
6735
6732
|
}
|
|
6736
|
-
}
|
|
6737
|
-
return messages;
|
|
6733
|
+
};
|
|
6738
6734
|
}
|
|
6739
6735
|
var log3;
|
|
6740
6736
|
var init_codex = __esm({
|
|
6741
6737
|
"../engine/dist/transcript/codex.js"() {
|
|
6742
6738
|
"use strict";
|
|
6743
6739
|
init_logger();
|
|
6740
|
+
init_trim();
|
|
6744
6741
|
log3 = createLogger("transcript-codex");
|
|
6745
6742
|
}
|
|
6746
6743
|
});
|
|
@@ -14136,6 +14133,11 @@ function cgroupCurrentMb(dir = cgroupDir()) {
|
|
|
14136
14133
|
function usedMb(rss = rssMb(), cgroup = cgroupCurrentMb()) {
|
|
14137
14134
|
return cgroup !== null && cgroup > rss ? cgroup : rss;
|
|
14138
14135
|
}
|
|
14136
|
+
function usedAfterRelief(measure = usedMb, release = releaseMemory, reclaim = reclaimCgroup) {
|
|
14137
|
+
release();
|
|
14138
|
+
reclaim();
|
|
14139
|
+
return measure();
|
|
14140
|
+
}
|
|
14139
14141
|
function startBudget(used = usedMb(), env = process.env) {
|
|
14140
14142
|
return { baselineMb: used, growthMb: growthLimitMb(env), hardMb: memoryLimitMb(env) };
|
|
14141
14143
|
}
|
|
@@ -16297,11 +16299,12 @@ async function parseTranscriptUncut(sessionId, opts) {
|
|
|
16297
16299
|
const loc = getBackend("codex").findSession(sessionId);
|
|
16298
16300
|
if (!loc)
|
|
16299
16301
|
return null;
|
|
16302
|
+
const cut = opts.payloadCap ? { payloadCap: opts.payloadCap } : {};
|
|
16300
16303
|
const [messages, subagents] = await Promise.all([
|
|
16301
|
-
parseCodexTranscript(loc.path),
|
|
16302
|
-
parseCodexSubagents(loc.path)
|
|
16304
|
+
parseCodexTranscript(loc.path, cut),
|
|
16305
|
+
parseCodexSubagents(loc.path, cut)
|
|
16303
16306
|
]);
|
|
16304
|
-
return { messages, subagents, mtime: loc.mtime || safeMtime(loc.path) };
|
|
16307
|
+
return { messages, subagents, mtime: loc.mtime || safeMtime(loc.path), ...opts.payloadCap ? { payloadCap: opts.payloadCap } : {} };
|
|
16305
16308
|
}
|
|
16306
16309
|
try {
|
|
16307
16310
|
const backend = getBackend(tool);
|
|
@@ -30530,7 +30533,8 @@ async function syncToTargetInScope(cred, opts = {}) {
|
|
|
30530
30533
|
for (const ref of slice) {
|
|
30531
30534
|
await new Promise((resolve3) => setImmediate(resolve3));
|
|
30532
30535
|
considered++;
|
|
30533
|
-
|
|
30536
|
+
let usedNow = usedMb();
|
|
30537
|
+
if (shouldPause(usedNow, memBudget, sessionsBuilt)) usedNow = usedAfterRelief();
|
|
30534
30538
|
if (shouldPause(usedNow, memBudget, sessionsBuilt)) {
|
|
30535
30539
|
releaseMemory();
|
|
30536
30540
|
reclaimCgroup();
|