chat-recall 0.7.59 → 0.7.60
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 +326 -173
- package/dist/mcp.js +310 -159
- package/dist/scan-worker.js +8 -0
- package/dist/session-file-scan.d.ts +22 -0
- package/dist/session-file-scan.d.ts.map +1 -0
- package/dist/session-file-scan.js +108 -0
- package/dist/session-file-scan.js.map +1 -0
- package/dist/sync-client.d.ts +0 -7
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +41 -22
- package/dist/sync-client.js.map +1 -1
- package/dist/watch.js +322 -169
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9154,6 +9154,42 @@ var init_session = __esm({
|
|
|
9154
9154
|
}
|
|
9155
9155
|
});
|
|
9156
9156
|
|
|
9157
|
+
// ../engine/dist/transcript/trim.js
|
|
9158
|
+
function detach(s) {
|
|
9159
|
+
return JSON.parse(JSON.stringify(s));
|
|
9160
|
+
}
|
|
9161
|
+
function capPayload(v, capChars = SYNC_PAYLOAD_CAP) {
|
|
9162
|
+
if (v === void 0)
|
|
9163
|
+
return void 0;
|
|
9164
|
+
if (typeof v === "string") {
|
|
9165
|
+
return v.length > capChars ? detach(v.slice(0, capChars)) + `\u2026 [+${v.length - capChars} chars]` : v;
|
|
9166
|
+
}
|
|
9167
|
+
let s = "";
|
|
9168
|
+
try {
|
|
9169
|
+
s = JSON.stringify(v) ?? "";
|
|
9170
|
+
} catch {
|
|
9171
|
+
return void 0;
|
|
9172
|
+
}
|
|
9173
|
+
if (s.length <= capChars * 4)
|
|
9174
|
+
return v;
|
|
9175
|
+
if (Array.isArray(v))
|
|
9176
|
+
return detach(s.slice(0, capChars)) + `\u2026 [+${s.length - capChars} chars]`;
|
|
9177
|
+
if (v && typeof v === "object") {
|
|
9178
|
+
const o = {};
|
|
9179
|
+
for (const [k, val] of Object.entries(v))
|
|
9180
|
+
o[k] = capPayload(val, capChars);
|
|
9181
|
+
return o;
|
|
9182
|
+
}
|
|
9183
|
+
return v;
|
|
9184
|
+
}
|
|
9185
|
+
var SYNC_PAYLOAD_CAP;
|
|
9186
|
+
var init_trim = __esm({
|
|
9187
|
+
"../engine/dist/transcript/trim.js"() {
|
|
9188
|
+
"use strict";
|
|
9189
|
+
SYNC_PAYLOAD_CAP = 2e3;
|
|
9190
|
+
}
|
|
9191
|
+
});
|
|
9192
|
+
|
|
9157
9193
|
// ../engine/dist/transcript/claude.js
|
|
9158
9194
|
import { open, readdir, readFile, stat } from "fs/promises";
|
|
9159
9195
|
import { dirname as dirname8, join as join12, basename as basename7 } from "path";
|
|
@@ -9163,127 +9199,50 @@ function stripBanners2(text) {
|
|
|
9163
9199
|
out = out.replace(re, " ");
|
|
9164
9200
|
return out.replace(/[ \t]{2,}/g, " ").trim();
|
|
9165
9201
|
}
|
|
9166
|
-
async function parseClaudeTranscript(sessionPath) {
|
|
9167
|
-
return parseMessagesFromFile(sessionPath);
|
|
9202
|
+
async function parseClaudeTranscript(sessionPath, opts = {}) {
|
|
9203
|
+
return parseMessagesFromFile(sessionPath, opts);
|
|
9168
9204
|
}
|
|
9169
|
-
function parseClaudeTranscriptText(text) {
|
|
9170
|
-
const
|
|
9205
|
+
function parseClaudeTranscriptText(text, opts = {}) {
|
|
9206
|
+
const builder = new MessageBuilder(opts.payloadCap);
|
|
9171
9207
|
let lineNumber = 0;
|
|
9172
9208
|
for (const line of text.split("\n")) {
|
|
9173
9209
|
lineNumber++;
|
|
9174
9210
|
if (!line.trim())
|
|
9175
9211
|
continue;
|
|
9212
|
+
let obj2;
|
|
9176
9213
|
try {
|
|
9177
|
-
|
|
9214
|
+
obj2 = JSON.parse(line);
|
|
9178
9215
|
} catch {
|
|
9216
|
+
continue;
|
|
9179
9217
|
}
|
|
9218
|
+
builder.add(lineNumber, obj2);
|
|
9180
9219
|
}
|
|
9181
|
-
return
|
|
9220
|
+
return builder.messages;
|
|
9182
9221
|
}
|
|
9183
|
-
async function parseMessagesFromFile(sessionPath) {
|
|
9222
|
+
async function parseMessagesFromFile(sessionPath, opts) {
|
|
9184
9223
|
const file = await open(sessionPath);
|
|
9185
|
-
const
|
|
9224
|
+
const builder = new MessageBuilder(opts.payloadCap);
|
|
9186
9225
|
try {
|
|
9187
9226
|
let lineNumber = 0;
|
|
9188
9227
|
for await (const line of file.readLines()) {
|
|
9189
9228
|
lineNumber++;
|
|
9190
9229
|
if (!line.trim())
|
|
9191
9230
|
continue;
|
|
9231
|
+
let obj2;
|
|
9192
9232
|
try {
|
|
9193
|
-
|
|
9233
|
+
obj2 = JSON.parse(line);
|
|
9194
9234
|
} catch {
|
|
9195
9235
|
log2.debug({ line: lineNumber, file: sessionPath }, "skipped malformed transcript line");
|
|
9236
|
+
continue;
|
|
9196
9237
|
}
|
|
9238
|
+
builder.add(lineNumber, obj2);
|
|
9197
9239
|
}
|
|
9198
9240
|
} finally {
|
|
9199
9241
|
await file.close();
|
|
9200
9242
|
}
|
|
9201
|
-
return
|
|
9202
|
-
}
|
|
9203
|
-
function messagesFromRawLines(raw) {
|
|
9204
|
-
const toolResults = /* @__PURE__ */ new Map();
|
|
9205
|
-
for (const { obj: obj2 } of raw) {
|
|
9206
|
-
if (obj2?.type !== "user")
|
|
9207
|
-
continue;
|
|
9208
|
-
const content = obj2.message?.content;
|
|
9209
|
-
if (!Array.isArray(content))
|
|
9210
|
-
continue;
|
|
9211
|
-
for (const block of content) {
|
|
9212
|
-
if (block?.type === "tool_result" && block.tool_use_id) {
|
|
9213
|
-
toolResults.set(block.tool_use_id, {
|
|
9214
|
-
content: block.content,
|
|
9215
|
-
isError: block.is_error === true
|
|
9216
|
-
});
|
|
9217
|
-
}
|
|
9218
|
-
}
|
|
9219
|
-
}
|
|
9220
|
-
const messages = [];
|
|
9221
|
-
for (const { line, obj: obj2 } of raw) {
|
|
9222
|
-
if (!obj2 || typeof obj2 !== "object")
|
|
9223
|
-
continue;
|
|
9224
|
-
const timestamp = typeof obj2.timestamp === "string" ? obj2.timestamp : void 0;
|
|
9225
|
-
if (obj2.type === "user") {
|
|
9226
|
-
const content = obj2.message?.content;
|
|
9227
|
-
let text = "";
|
|
9228
|
-
if (typeof content === "string") {
|
|
9229
|
-
text = content;
|
|
9230
|
-
} else if (Array.isArray(content)) {
|
|
9231
|
-
text = content.filter((c) => c?.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
9232
|
-
}
|
|
9233
|
-
if (!text.trim())
|
|
9234
|
-
continue;
|
|
9235
|
-
const cleaned = stripBanners2(text);
|
|
9236
|
-
if (!cleaned)
|
|
9237
|
-
continue;
|
|
9238
|
-
const origin = userRecordOrigin(obj2, cleaned);
|
|
9239
|
-
messages.push({ line, role: "user", content: cleaned, timestamp, ...origin === "human" ? {} : { origin } });
|
|
9240
|
-
} else if (obj2.type === "attachment") {
|
|
9241
|
-
const queued = queuedCommandPrompt(obj2);
|
|
9242
|
-
if (!queued)
|
|
9243
|
-
continue;
|
|
9244
|
-
const cleaned = stripBanners2(queued.text);
|
|
9245
|
-
if (!cleaned)
|
|
9246
|
-
continue;
|
|
9247
|
-
messages.push({ line, role: "user", content: cleaned, timestamp, ...queued.origin === "human" ? {} : { origin: queued.origin } });
|
|
9248
|
-
} else if (obj2.type === "assistant") {
|
|
9249
|
-
const blocks = Array.isArray(obj2.message?.content) ? obj2.message.content : [];
|
|
9250
|
-
const thinkingBlock = blocks.find((c) => c?.type === "thinking");
|
|
9251
|
-
const textBlock = blocks.find((c) => c?.type === "text");
|
|
9252
|
-
const toolUses = blocks.filter((c) => c?.type === "tool_use");
|
|
9253
|
-
const toolCalls = toolUses.map((toolUse) => {
|
|
9254
|
-
const result = toolUse.id ? toolResults.get(toolUse.id) : void 0;
|
|
9255
|
-
return {
|
|
9256
|
-
name: toolUse.name || "unknown",
|
|
9257
|
-
input: toolUse.input,
|
|
9258
|
-
result: result?.content,
|
|
9259
|
-
isError: result?.isError
|
|
9260
|
-
};
|
|
9261
|
-
});
|
|
9262
|
-
const hasThinking = thinkingBlock !== void 0;
|
|
9263
|
-
const text = textBlock?.text ?? "";
|
|
9264
|
-
const thinking = thinkingBlock?.thinking ?? (hasThinking ? "" : void 0);
|
|
9265
|
-
if (!text && !hasThinking && toolCalls.length === 0)
|
|
9266
|
-
continue;
|
|
9267
|
-
messages.push({
|
|
9268
|
-
line,
|
|
9269
|
-
role: "assistant",
|
|
9270
|
-
content: text,
|
|
9271
|
-
thinking,
|
|
9272
|
-
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
9273
|
-
timestamp
|
|
9274
|
-
});
|
|
9275
|
-
} else if (obj2.type === "summary" && typeof obj2.summary === "string") {
|
|
9276
|
-
messages.push({ line, role: "summary", content: obj2.summary });
|
|
9277
|
-
} else if (obj2.type === "system" && obj2.subtype === "away_summary") {
|
|
9278
|
-
const c = obj2.content;
|
|
9279
|
-
const text = typeof c === "string" ? c : Array.isArray(c) ? c.filter((b) => b?.type === "text" && typeof b.text === "string").map((b) => b.text).join("\n") : "";
|
|
9280
|
-
if (text.trim())
|
|
9281
|
-
messages.push({ line, role: "summary", content: stripBanners2(text), timestamp });
|
|
9282
|
-
}
|
|
9283
|
-
}
|
|
9284
|
-
return messages;
|
|
9243
|
+
return builder.messages;
|
|
9285
9244
|
}
|
|
9286
|
-
async function parseClaudeSubagents(sessionPath) {
|
|
9245
|
+
async function parseClaudeSubagents(sessionPath, opts = {}) {
|
|
9287
9246
|
const sessionId = basename7(sessionPath).replace(/\.jsonl$/i, "");
|
|
9288
9247
|
const subagentsDir = join12(dirname8(sessionPath), sessionId, "subagents");
|
|
9289
9248
|
let entries;
|
|
@@ -9310,7 +9269,7 @@ async function parseClaudeSubagents(sessionPath) {
|
|
|
9310
9269
|
}
|
|
9311
9270
|
let messages = [];
|
|
9312
9271
|
try {
|
|
9313
|
-
messages = await parseMessagesFromFile(filePath);
|
|
9272
|
+
messages = await parseMessagesFromFile(filePath, opts);
|
|
9314
9273
|
} catch (e) {
|
|
9315
9274
|
log2.error({ err: e, filePath }, "Failed to parse subagent");
|
|
9316
9275
|
}
|
|
@@ -9335,12 +9294,13 @@ async function parseClaudeSubagents(sessionPath) {
|
|
|
9335
9294
|
}));
|
|
9336
9295
|
return subagents.map((s, i) => ({ s, mtime: stats[i] })).sort((a, b) => a.mtime - b.mtime).map(({ s }) => s);
|
|
9337
9296
|
}
|
|
9338
|
-
var log2, INJECTED_BANNERS2;
|
|
9297
|
+
var log2, INJECTED_BANNERS2, MessageBuilder;
|
|
9339
9298
|
var init_claude2 = __esm({
|
|
9340
9299
|
"../engine/dist/transcript/claude.js"() {
|
|
9341
9300
|
"use strict";
|
|
9342
9301
|
init_logger();
|
|
9343
9302
|
init_claude_prompt_origin();
|
|
9303
|
+
init_trim();
|
|
9344
9304
|
log2 = createLogger("transcript-claude");
|
|
9345
9305
|
INJECTED_BANNERS2 = [
|
|
9346
9306
|
/MCP issues detected\. ?Run \/mcp list for status\.?/g,
|
|
@@ -9359,6 +9319,104 @@ var init_claude2 = __esm({
|
|
|
9359
9319
|
// eslint-disable-next-line no-control-regex
|
|
9360
9320
|
/\[[0-9;]*m/g
|
|
9361
9321
|
];
|
|
9322
|
+
MessageBuilder = class {
|
|
9323
|
+
messages = [];
|
|
9324
|
+
cap;
|
|
9325
|
+
/** The calls of each tool_use id. */
|
|
9326
|
+
calls = /* @__PURE__ */ new Map();
|
|
9327
|
+
/** The last result of each tool_use id. */
|
|
9328
|
+
results = /* @__PURE__ */ new Map();
|
|
9329
|
+
constructor(payloadCap) {
|
|
9330
|
+
this.cap = payloadCap ? (v) => capPayload(v, payloadCap) : (v) => v;
|
|
9331
|
+
}
|
|
9332
|
+
add(line, obj2) {
|
|
9333
|
+
if (!obj2 || typeof obj2 !== "object")
|
|
9334
|
+
return;
|
|
9335
|
+
const timestamp = typeof obj2.timestamp === "string" ? obj2.timestamp : void 0;
|
|
9336
|
+
if (obj2.type === "user") {
|
|
9337
|
+
const content = obj2.message?.content;
|
|
9338
|
+
if (Array.isArray(content)) {
|
|
9339
|
+
for (const block of content) {
|
|
9340
|
+
if (block?.type === "tool_result" && block.tool_use_id) {
|
|
9341
|
+
this.addResult(block.tool_use_id, this.cap(block.content), block.is_error === true);
|
|
9342
|
+
}
|
|
9343
|
+
}
|
|
9344
|
+
}
|
|
9345
|
+
let text = "";
|
|
9346
|
+
if (typeof content === "string") {
|
|
9347
|
+
text = content;
|
|
9348
|
+
} else if (Array.isArray(content)) {
|
|
9349
|
+
text = content.filter((c) => c?.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
9350
|
+
}
|
|
9351
|
+
if (!text.trim())
|
|
9352
|
+
return;
|
|
9353
|
+
const cleaned = stripBanners2(text);
|
|
9354
|
+
if (!cleaned)
|
|
9355
|
+
return;
|
|
9356
|
+
const origin = userRecordOrigin(obj2, cleaned);
|
|
9357
|
+
this.messages.push({ line, role: "user", content: cleaned, timestamp, ...origin === "human" ? {} : { origin } });
|
|
9358
|
+
} else if (obj2.type === "attachment") {
|
|
9359
|
+
const queued = queuedCommandPrompt(obj2);
|
|
9360
|
+
if (!queued)
|
|
9361
|
+
return;
|
|
9362
|
+
const cleaned = stripBanners2(queued.text);
|
|
9363
|
+
if (!cleaned)
|
|
9364
|
+
return;
|
|
9365
|
+
this.messages.push({ line, role: "user", content: cleaned, timestamp, ...queued.origin === "human" ? {} : { origin: queued.origin } });
|
|
9366
|
+
} else if (obj2.type === "assistant") {
|
|
9367
|
+
const blocks = Array.isArray(obj2.message?.content) ? obj2.message.content : [];
|
|
9368
|
+
const thinkingBlock = blocks.find((c) => c?.type === "thinking");
|
|
9369
|
+
const textBlock = blocks.find((c) => c?.type === "text");
|
|
9370
|
+
const toolUses = blocks.filter((c) => c?.type === "tool_use");
|
|
9371
|
+
const toolCalls = toolUses.map((toolUse) => {
|
|
9372
|
+
const known = toolUse.id ? this.results.get(toolUse.id) : void 0;
|
|
9373
|
+
const call2 = {
|
|
9374
|
+
name: toolUse.name || "unknown",
|
|
9375
|
+
input: this.cap(toolUse.input),
|
|
9376
|
+
result: known?.content,
|
|
9377
|
+
isError: known?.isError
|
|
9378
|
+
};
|
|
9379
|
+
if (toolUse.id) {
|
|
9380
|
+
const list = this.calls.get(toolUse.id);
|
|
9381
|
+
if (list)
|
|
9382
|
+
list.push(call2);
|
|
9383
|
+
else
|
|
9384
|
+
this.calls.set(toolUse.id, [call2]);
|
|
9385
|
+
}
|
|
9386
|
+
return call2;
|
|
9387
|
+
});
|
|
9388
|
+
const hasThinking = thinkingBlock !== void 0;
|
|
9389
|
+
const text = textBlock?.text ?? "";
|
|
9390
|
+
const thinking = thinkingBlock?.thinking != null ? this.cap(thinkingBlock.thinking) : hasThinking ? "" : void 0;
|
|
9391
|
+
if (!text && !hasThinking && toolCalls.length === 0)
|
|
9392
|
+
return;
|
|
9393
|
+
this.messages.push({
|
|
9394
|
+
line,
|
|
9395
|
+
role: "assistant",
|
|
9396
|
+
content: text,
|
|
9397
|
+
thinking,
|
|
9398
|
+
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
9399
|
+
timestamp
|
|
9400
|
+
});
|
|
9401
|
+
} else if (obj2.type === "summary" && typeof obj2.summary === "string") {
|
|
9402
|
+
this.messages.push({ line, role: "summary", content: obj2.summary });
|
|
9403
|
+
} else if (obj2.type === "system" && obj2.subtype === "away_summary") {
|
|
9404
|
+
const c = obj2.content;
|
|
9405
|
+
const text = typeof c === "string" ? c : Array.isArray(c) ? c.filter((b) => b?.type === "text" && typeof b.text === "string").map((b) => b.text).join("\n") : "";
|
|
9406
|
+
if (text.trim())
|
|
9407
|
+
this.messages.push({ line, role: "summary", content: stripBanners2(text), timestamp });
|
|
9408
|
+
}
|
|
9409
|
+
}
|
|
9410
|
+
addResult(id, content, isError) {
|
|
9411
|
+
this.results.set(id, { content, isError });
|
|
9412
|
+
const list = this.calls.get(id);
|
|
9413
|
+
if (list)
|
|
9414
|
+
for (const call2 of list) {
|
|
9415
|
+
call2.result = content;
|
|
9416
|
+
call2.isError = isError;
|
|
9417
|
+
}
|
|
9418
|
+
}
|
|
9419
|
+
};
|
|
9362
9420
|
}
|
|
9363
9421
|
});
|
|
9364
9422
|
|
|
@@ -17009,10 +17067,12 @@ var init_opencode2 = __esm({
|
|
|
17009
17067
|
var transcript_exports = {};
|
|
17010
17068
|
__export(transcript_exports, {
|
|
17011
17069
|
RAW_PARSE_MAX_BYTES: () => RAW_PARSE_MAX_BYTES,
|
|
17070
|
+
SYNC_PAYLOAD_CAP: () => SYNC_PAYLOAD_CAP,
|
|
17012
17071
|
TRANSCRIPT_VERSION: () => TRANSCRIPT_VERSION,
|
|
17013
17072
|
archiveRawSession: () => archiveRawSession,
|
|
17014
17073
|
buildRawContainer: () => buildRawContainer,
|
|
17015
17074
|
canonicalEventsToMessages: () => canonicalEventsToMessages,
|
|
17075
|
+
capPayload: () => capPayload,
|
|
17016
17076
|
containerSrcHash: () => containerSrcHash,
|
|
17017
17077
|
detectForkPredecessor: () => detectForkPredecessor,
|
|
17018
17078
|
gunzipContainer: () => gunzipContainer,
|
|
@@ -17047,7 +17107,14 @@ __export(transcript_exports, {
|
|
|
17047
17107
|
writeTranscriptEnvelope: () => writeTranscriptEnvelope
|
|
17048
17108
|
});
|
|
17049
17109
|
import { statSync as statSync21 } from "fs";
|
|
17050
|
-
async function parseTranscript(sessionId) {
|
|
17110
|
+
async function parseTranscript(sessionId, opts = {}) {
|
|
17111
|
+
const t = await parseTranscriptUncut(sessionId, opts);
|
|
17112
|
+
const cap = opts.payloadCap;
|
|
17113
|
+
if (!t || !cap || t.payloadCap === cap)
|
|
17114
|
+
return t;
|
|
17115
|
+
return { ...t, ...trimTranscriptForSync(t, cap), payloadCap: cap };
|
|
17116
|
+
}
|
|
17117
|
+
async function parseTranscriptUncut(sessionId, opts) {
|
|
17051
17118
|
const tool = detectTool(sessionId);
|
|
17052
17119
|
if (tool === "claude") {
|
|
17053
17120
|
const groups = resolveSessionContentGroups(sessionId);
|
|
@@ -17058,9 +17125,10 @@ async function parseTranscript(sessionId) {
|
|
|
17058
17125
|
return null;
|
|
17059
17126
|
const primaryPath = mainGroup.paths[0];
|
|
17060
17127
|
const merged = readSessionGroupText(mainGroup);
|
|
17128
|
+
const cut = opts.payloadCap ? { payloadCap: opts.payloadCap } : {};
|
|
17061
17129
|
const [tail, allSubagents] = await Promise.all([
|
|
17062
|
-
Promise.resolve(parseClaudeTranscriptText(merged.text)),
|
|
17063
|
-
parseClaudeSubagents(primaryPath)
|
|
17130
|
+
Promise.resolve(parseClaudeTranscriptText(merged.text, cut)),
|
|
17131
|
+
parseClaudeSubagents(primaryPath, cut)
|
|
17064
17132
|
]);
|
|
17065
17133
|
const compacts = allSubagents.filter((s) => s.kind === "compact");
|
|
17066
17134
|
const subagents = allSubagents.filter((s) => s.kind !== "compact");
|
|
@@ -17077,7 +17145,7 @@ async function parseTranscript(sessionId) {
|
|
|
17077
17145
|
}
|
|
17078
17146
|
messages = [...stitched, ...tail].map((m, i) => ({ ...m, line: i + 1 }));
|
|
17079
17147
|
}
|
|
17080
|
-
return { messages, subagents, mtime: merged.mtime || safeMtime(primaryPath) };
|
|
17148
|
+
return { messages, subagents, mtime: merged.mtime || safeMtime(primaryPath), ...opts.payloadCap ? { payloadCap: opts.payloadCap } : {} };
|
|
17081
17149
|
}
|
|
17082
17150
|
if (tool === "opencode") {
|
|
17083
17151
|
const messages = await parseOpenCodeTranscript(sessionId);
|
|
@@ -17119,31 +17187,8 @@ function safeMtime(path) {
|
|
|
17119
17187
|
return 0;
|
|
17120
17188
|
}
|
|
17121
17189
|
}
|
|
17122
|
-
function trimTranscriptForSync(t, capChars =
|
|
17123
|
-
const cap = (v) =>
|
|
17124
|
-
if (v === void 0)
|
|
17125
|
-
return void 0;
|
|
17126
|
-
if (typeof v === "string") {
|
|
17127
|
-
return v.length > capChars ? v.slice(0, capChars) + `\u2026 [+${v.length - capChars} chars]` : v;
|
|
17128
|
-
}
|
|
17129
|
-
let s = "";
|
|
17130
|
-
try {
|
|
17131
|
-
s = JSON.stringify(v) ?? "";
|
|
17132
|
-
} catch {
|
|
17133
|
-
return void 0;
|
|
17134
|
-
}
|
|
17135
|
-
if (s.length <= capChars * 4)
|
|
17136
|
-
return v;
|
|
17137
|
-
if (Array.isArray(v))
|
|
17138
|
-
return s.slice(0, capChars) + `\u2026 [+${s.length - capChars} chars]`;
|
|
17139
|
-
if (v && typeof v === "object") {
|
|
17140
|
-
const o = {};
|
|
17141
|
-
for (const [k, val] of Object.entries(v))
|
|
17142
|
-
o[k] = cap(val);
|
|
17143
|
-
return o;
|
|
17144
|
-
}
|
|
17145
|
-
return v;
|
|
17146
|
-
};
|
|
17190
|
+
function trimTranscriptForSync(t, capChars = SYNC_PAYLOAD_CAP) {
|
|
17191
|
+
const cap = (v) => capPayload(v, capChars);
|
|
17147
17192
|
const trimMsg = (m) => ({
|
|
17148
17193
|
...m,
|
|
17149
17194
|
thinking: m.thinking !== void 0 ? cap(m.thinking) : void 0,
|
|
@@ -17175,7 +17220,9 @@ var init_transcript = __esm({
|
|
|
17175
17220
|
init_opencode2();
|
|
17176
17221
|
init_codex();
|
|
17177
17222
|
init_from_events();
|
|
17223
|
+
init_trim();
|
|
17178
17224
|
init_types();
|
|
17225
|
+
init_trim();
|
|
17179
17226
|
init_raw();
|
|
17180
17227
|
init_shadow();
|
|
17181
17228
|
init_claude2();
|
|
@@ -29429,8 +29476,100 @@ var init_collector_health = __esm({
|
|
|
29429
29476
|
}
|
|
29430
29477
|
});
|
|
29431
29478
|
|
|
29479
|
+
// src/session-file-scan.ts
|
|
29480
|
+
import { open as open3 } from "node:fs/promises";
|
|
29481
|
+
import { statSync as statSync39 } from "node:fs";
|
|
29482
|
+
function sessionGroupsBytes(groups) {
|
|
29483
|
+
let total = 0;
|
|
29484
|
+
for (const g of groups) {
|
|
29485
|
+
for (const p of g.paths) {
|
|
29486
|
+
try {
|
|
29487
|
+
total += statSync39(p).size;
|
|
29488
|
+
} catch {
|
|
29489
|
+
}
|
|
29490
|
+
}
|
|
29491
|
+
}
|
|
29492
|
+
return total;
|
|
29493
|
+
}
|
|
29494
|
+
async function* readLinePieces(path, pieceBytes = SCAN_PIECE_BYTES) {
|
|
29495
|
+
const fh = await open3(path, "r");
|
|
29496
|
+
try {
|
|
29497
|
+
const buf = Buffer.allocUnsafe(pieceBytes);
|
|
29498
|
+
let carry = Buffer.alloc(0);
|
|
29499
|
+
for (; ; ) {
|
|
29500
|
+
const { bytesRead } = await fh.read(buf, 0, pieceBytes, null);
|
|
29501
|
+
if (bytesRead === 0) break;
|
|
29502
|
+
const joined = carry.length ? Buffer.concat([carry, buf.subarray(0, bytesRead)]) : buf.subarray(0, bytesRead);
|
|
29503
|
+
const cut = joined.lastIndexOf(NEWLINE);
|
|
29504
|
+
if (cut < 0) {
|
|
29505
|
+
carry = Buffer.from(joined);
|
|
29506
|
+
continue;
|
|
29507
|
+
}
|
|
29508
|
+
const piece = joined.subarray(0, cut + 1);
|
|
29509
|
+
carry = Buffer.from(joined.subarray(cut + 1));
|
|
29510
|
+
yield { text: piece.toString("utf8"), newlines: countNewlines(piece) };
|
|
29511
|
+
}
|
|
29512
|
+
if (carry.length) yield { text: carry.toString("utf8"), newlines: 0 };
|
|
29513
|
+
} finally {
|
|
29514
|
+
await fh.close();
|
|
29515
|
+
}
|
|
29516
|
+
}
|
|
29517
|
+
function countNewlines(b) {
|
|
29518
|
+
let n = 0;
|
|
29519
|
+
for (let i = b.indexOf(NEWLINE); i >= 0; i = b.indexOf(NEWLINE, i + 1)) n++;
|
|
29520
|
+
return n;
|
|
29521
|
+
}
|
|
29522
|
+
async function scanSessionGroupsChunked(sessionId, groups, tenantRules, pieceBytes = SCAN_PIECE_BYTES) {
|
|
29523
|
+
const findings = [];
|
|
29524
|
+
let lineBase = 0;
|
|
29525
|
+
const scan = (text) => {
|
|
29526
|
+
try {
|
|
29527
|
+
for (const x of scanTextForFindings(text)) {
|
|
29528
|
+
findings.push({ session_id: sessionId, detector: "builtin", rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
29529
|
+
}
|
|
29530
|
+
} catch {
|
|
29531
|
+
}
|
|
29532
|
+
if (tenantRules && tenantRules.length > 0) {
|
|
29533
|
+
try {
|
|
29534
|
+
for (const x of scanTenantRules(text, tenantRules)) {
|
|
29535
|
+
findings.push({ session_id: sessionId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
29536
|
+
}
|
|
29537
|
+
} catch {
|
|
29538
|
+
}
|
|
29539
|
+
}
|
|
29540
|
+
};
|
|
29541
|
+
for (const group of groups) {
|
|
29542
|
+
if (group.paths.length === 1) {
|
|
29543
|
+
let any = false;
|
|
29544
|
+
for await (const piece of readLinePieces(group.paths[0], pieceBytes)) {
|
|
29545
|
+
any = true;
|
|
29546
|
+
scan(piece.text);
|
|
29547
|
+
lineBase += piece.newlines;
|
|
29548
|
+
}
|
|
29549
|
+
if (any) lineBase += 1;
|
|
29550
|
+
} else {
|
|
29551
|
+
const { text } = readSessionGroupText(group);
|
|
29552
|
+
if (!text) continue;
|
|
29553
|
+
scan(text);
|
|
29554
|
+
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
29555
|
+
}
|
|
29556
|
+
}
|
|
29557
|
+
return findings;
|
|
29558
|
+
}
|
|
29559
|
+
var SCAN_PIECE_BYTES, NEWLINE;
|
|
29560
|
+
var init_session_file_scan = __esm({
|
|
29561
|
+
"src/session-file-scan.ts"() {
|
|
29562
|
+
"use strict";
|
|
29563
|
+
init_secret_redactor();
|
|
29564
|
+
init_secret_scanner();
|
|
29565
|
+
init_live_session_scan();
|
|
29566
|
+
SCAN_PIECE_BYTES = 8 * 1024 * 1024;
|
|
29567
|
+
NEWLINE = 10;
|
|
29568
|
+
}
|
|
29569
|
+
});
|
|
29570
|
+
|
|
29432
29571
|
// src/raw-archive-parts.ts
|
|
29433
|
-
import { createReadStream as createReadStream4, createWriteStream, openSync as openSync10, readSync as readSync9, closeSync as closeSync10, rmSync as rmSync5, statSync as
|
|
29572
|
+
import { createReadStream as createReadStream4, createWriteStream, openSync as openSync10, readSync as readSync9, closeSync as closeSync10, rmSync as rmSync5, statSync as statSync40 } from "node:fs";
|
|
29434
29573
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
29435
29574
|
import { join as join46 } from "node:path";
|
|
29436
29575
|
import { randomBytes } from "node:crypto";
|
|
@@ -29498,7 +29637,7 @@ async function writeArchiveFile(source, meta, redact, dir = tmpdir2()) {
|
|
|
29498
29637
|
rmSync5(path, { force: true });
|
|
29499
29638
|
throw err;
|
|
29500
29639
|
}
|
|
29501
|
-
return { path, gzSize:
|
|
29640
|
+
return { path, gzSize: statSync40(path).size, size };
|
|
29502
29641
|
}
|
|
29503
29642
|
async function putPart(url, body2) {
|
|
29504
29643
|
let last;
|
|
@@ -29801,7 +29940,7 @@ __export(auto_update_exports, {
|
|
|
29801
29940
|
import { execSync as execSync2, execFileSync as execFileSync3 } from "node:child_process";
|
|
29802
29941
|
import { readFileSync as readFileSync41, existsSync as existsSync43 } from "node:fs";
|
|
29803
29942
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
29804
|
-
import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as
|
|
29943
|
+
import { writeFileSync as writeFileSync10, mkdtempSync as mkdtempSync3, rmSync as rmSync6, readdirSync as readdirSync31, statSync as statSync41, mkdirSync as mkdirSync10 } from "node:fs";
|
|
29805
29944
|
import { join as join47, dirname as dirname19, sep as sep2, posix as pathPosix, win32 as pathWin32 } from "node:path";
|
|
29806
29945
|
import { tmpdir as tmpdir3, homedir as homedir16 } from "node:os";
|
|
29807
29946
|
import { createHash as createHash10 } from "node:crypto";
|
|
@@ -29854,7 +29993,7 @@ function sweepStaleStaging(root = tmpdir3(), now = Date.now()) {
|
|
|
29854
29993
|
if (!MKDTEMP_SUFFIX.test(name)) continue;
|
|
29855
29994
|
const dir = join47(root, name);
|
|
29856
29995
|
try {
|
|
29857
|
-
const st =
|
|
29996
|
+
const st = statSync41(dir);
|
|
29858
29997
|
if (!st.isDirectory() || now - st.mtimeMs < COLD_MS) continue;
|
|
29859
29998
|
const inside = readdirSync31(dir);
|
|
29860
29999
|
if (inside.length > 1 || inside.length === 1 && inside[0] !== "chat-recall.tgz") continue;
|
|
@@ -30138,7 +30277,7 @@ __export(sync_client_exports, {
|
|
|
30138
30277
|
syncSessions: () => syncSessions
|
|
30139
30278
|
});
|
|
30140
30279
|
import { join as join48, dirname as dirname20, basename as basename22 } from "node:path";
|
|
30141
|
-
import { readFileSync as readFileSync42, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync4, unlinkSync as unlinkSync2, readdirSync as readdirSync32, statSync as
|
|
30280
|
+
import { readFileSync as readFileSync42, writeFileSync as writeFileSync11, mkdirSync as mkdirSync11, mkdtempSync as mkdtempSync4, rmSync as rmSync7, chmodSync as chmodSync4, unlinkSync as unlinkSync2, readdirSync as readdirSync32, statSync as statSync42 } from "node:fs";
|
|
30142
30281
|
import { tmpdir as tmpdir4, hostname as hostname2 } from "node:os";
|
|
30143
30282
|
import { createHash as createHash11 } from "node:crypto";
|
|
30144
30283
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -30615,7 +30754,7 @@ function reapStaleScanDirs(dir = tmpdir4(), maxAgeMs = 6 * 36e5, now = Date.now(
|
|
|
30615
30754
|
if (!name.startsWith("cr-batchscan-")) continue;
|
|
30616
30755
|
const p = join48(dir, name);
|
|
30617
30756
|
try {
|
|
30618
|
-
if (now -
|
|
30757
|
+
if (now - statSync42(p).mtimeMs < maxAgeMs) continue;
|
|
30619
30758
|
rmSync7(p, { recursive: true, force: true });
|
|
30620
30759
|
reaped++;
|
|
30621
30760
|
} catch {
|
|
@@ -31519,6 +31658,10 @@ function sessionFileBytes(ref) {
|
|
|
31519
31658
|
if (!backend?.isAppendOnly?.()) return 0;
|
|
31520
31659
|
return backend.fileSize?.(ref.prefixedId) ?? 0;
|
|
31521
31660
|
}
|
|
31661
|
+
function syncTranscript(t) {
|
|
31662
|
+
const cut = t.payloadCap ? { messages: t.messages, subagents: t.subagents } : trimTranscriptForSync(t);
|
|
31663
|
+
return { messages: cut.messages, subagents: cut.subagents.map((s) => ({ ...s, filePath: "" })) };
|
|
31664
|
+
}
|
|
31522
31665
|
function sessionBuildBytes(ref) {
|
|
31523
31666
|
const main = sessionFileBytes(ref);
|
|
31524
31667
|
if (main === 0) return 0;
|
|
@@ -31555,11 +31698,14 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
31555
31698
|
} else {
|
|
31556
31699
|
try {
|
|
31557
31700
|
const backend = getBackendForId(ref.prefixedId) ?? getBackend("claude");
|
|
31558
|
-
const
|
|
31701
|
+
const streamGroups = ref.toolId === "claude" ? resolveSessionContentGroups(ref.rawId) : [];
|
|
31702
|
+
const streamedBytes = sessionGroupsBytes(streamGroups);
|
|
31703
|
+
const streamed = streamedBytes > FULL_BUILD_MAX_BYTES;
|
|
31704
|
+
const exp = streamed ? null : backend.exportRawSession(ref.prefixedId);
|
|
31559
31705
|
let built;
|
|
31560
|
-
const exportBytes = exportByteLength(exp);
|
|
31706
|
+
const exportBytes = streamed ? streamedBytes : exportByteLength(exp);
|
|
31561
31707
|
const overCeiling = exportBytes > FULL_BUILD_MAX_BYTES;
|
|
31562
|
-
if (exp && overCeiling) {
|
|
31708
|
+
if ((exp || streamed) && overCeiling) {
|
|
31563
31709
|
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`);
|
|
31564
31710
|
record({
|
|
31565
31711
|
kind: "oversized_session",
|
|
@@ -31570,25 +31716,29 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
31570
31716
|
includeRaw = false;
|
|
31571
31717
|
includeMeta = false;
|
|
31572
31718
|
exportOverCeiling = true;
|
|
31573
|
-
|
|
31574
|
-
|
|
31575
|
-
|
|
31576
|
-
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
}
|
|
31581
|
-
} catch {
|
|
31582
|
-
}
|
|
31583
|
-
if (opts.tenantRules && opts.tenantRules.length > 0) {
|
|
31719
|
+
if (streamed) {
|
|
31720
|
+
overCeilingFindings = await scanSessionGroupsChunked(ref.prefixedId, streamGroups, opts.tenantRules);
|
|
31721
|
+
} else if (exp) {
|
|
31722
|
+
overCeilingFindings = [];
|
|
31723
|
+
let lineBase = 0;
|
|
31724
|
+
for (const f of exp.files) {
|
|
31725
|
+
const text = f.bytes.toString("utf8");
|
|
31584
31726
|
try {
|
|
31585
|
-
for (const x of
|
|
31586
|
-
overCeilingFindings.push({ session_id: ref.prefixedId, detector:
|
|
31727
|
+
for (const x of scanTextForFindings(text)) {
|
|
31728
|
+
overCeilingFindings.push({ session_id: ref.prefixedId, detector: "builtin", rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
31587
31729
|
}
|
|
31588
31730
|
} catch {
|
|
31589
31731
|
}
|
|
31732
|
+
if (opts.tenantRules && opts.tenantRules.length > 0) {
|
|
31733
|
+
try {
|
|
31734
|
+
for (const x of scanTenantRules(text, opts.tenantRules)) {
|
|
31735
|
+
overCeilingFindings.push({ session_id: ref.prefixedId, detector: x.detector, rule: x.rule, line: x.line + lineBase, preview: x.preview });
|
|
31736
|
+
}
|
|
31737
|
+
} catch {
|
|
31738
|
+
}
|
|
31739
|
+
}
|
|
31740
|
+
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
31590
31741
|
}
|
|
31591
|
-
lineBase += (text.match(/\n/g)?.length ?? 0) + 1;
|
|
31592
31742
|
}
|
|
31593
31743
|
}
|
|
31594
31744
|
if (exp && !overCeiling) {
|
|
@@ -31628,7 +31778,7 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
31628
31778
|
}
|
|
31629
31779
|
if (!transcript) {
|
|
31630
31780
|
try {
|
|
31631
|
-
const t = await parseTranscript(ref.prefixedId);
|
|
31781
|
+
const t = await parseTranscript(ref.prefixedId, { payloadCap: SYNC_PAYLOAD_CAP });
|
|
31632
31782
|
if (t && (t.messages.length > 0 || t.subagents.length > 0)) transcript = t;
|
|
31633
31783
|
} catch {
|
|
31634
31784
|
}
|
|
@@ -31641,7 +31791,9 @@ async function buildConversationSync(ref, mtime, opts = {}) {
|
|
|
31641
31791
|
if (isInternalToolPrompt(firstUser?.content)) return null;
|
|
31642
31792
|
const count = { redactions: 0 };
|
|
31643
31793
|
const envelope = redactDeep(
|
|
31644
|
-
|
|
31794
|
+
// A transcript the parser already cut is not cut again: the cut is not idempotent.
|
|
31795
|
+
// The path of a subagent file on this machine does not leave it: the container parse gives ''.
|
|
31796
|
+
{ v: TRANSCRIPT_VERSION, ...syncTranscript(transcript) },
|
|
31645
31797
|
count
|
|
31646
31798
|
);
|
|
31647
31799
|
let projectPath = ref.projectPath;
|
|
@@ -32013,6 +32165,7 @@ var init_sync_client = __esm({
|
|
|
32013
32165
|
init_telemetry();
|
|
32014
32166
|
init_collector_health();
|
|
32015
32167
|
init_live_session_scan();
|
|
32168
|
+
init_session_file_scan();
|
|
32016
32169
|
init_raw_archive_parts();
|
|
32017
32170
|
init_backends();
|
|
32018
32171
|
ownVersion = "0.0.0";
|
|
@@ -32174,11 +32327,11 @@ var init_update_notice = __esm({
|
|
|
32174
32327
|
});
|
|
32175
32328
|
|
|
32176
32329
|
// ../engine/dist/core/which.js
|
|
32177
|
-
import { existsSync as existsSync44, statSync as
|
|
32330
|
+
import { existsSync as existsSync44, statSync as statSync43, accessSync, constants } from "node:fs";
|
|
32178
32331
|
import { join as join50, isAbsolute as isAbsolute3, delimiter as delimiter2, sep as sep3 } from "node:path";
|
|
32179
32332
|
function executable(p) {
|
|
32180
32333
|
try {
|
|
32181
|
-
if (!
|
|
32334
|
+
if (!statSync43(p).isFile())
|
|
32182
32335
|
return false;
|
|
32183
32336
|
} catch {
|
|
32184
32337
|
return false;
|
|
@@ -33395,14 +33548,14 @@ var init_opencode_tui_config = __esm({
|
|
|
33395
33548
|
return this.array(t);
|
|
33396
33549
|
throw new SyntaxError(`unexpected "${t.v}" at ${t.start}`);
|
|
33397
33550
|
}
|
|
33398
|
-
object(
|
|
33551
|
+
object(open4) {
|
|
33399
33552
|
this.i += 1;
|
|
33400
33553
|
const props = [];
|
|
33401
33554
|
for (; ; ) {
|
|
33402
33555
|
const k = this.at();
|
|
33403
33556
|
if (this.isP(k, "}")) {
|
|
33404
33557
|
this.i += 1;
|
|
33405
|
-
return { k: "obj", start:
|
|
33558
|
+
return { k: "obj", start: open4.start, end: k.end, closeStart: k.start, props };
|
|
33406
33559
|
}
|
|
33407
33560
|
if (!k || k.t !== "s")
|
|
33408
33561
|
throw new SyntaxError(`expected a key at ${k ? k.start : "end"}`);
|
|
@@ -33421,7 +33574,7 @@ var init_opencode_tui_config = __esm({
|
|
|
33421
33574
|
throw new SyntaxError(`expected "," or "}" at ${n ? n.start : "end"}`);
|
|
33422
33575
|
}
|
|
33423
33576
|
}
|
|
33424
|
-
array(
|
|
33577
|
+
array(open4) {
|
|
33425
33578
|
this.i += 1;
|
|
33426
33579
|
const items = [];
|
|
33427
33580
|
const commas = [];
|
|
@@ -33429,7 +33582,7 @@ var init_opencode_tui_config = __esm({
|
|
|
33429
33582
|
const n = this.at();
|
|
33430
33583
|
if (this.isP(n, "]")) {
|
|
33431
33584
|
this.i += 1;
|
|
33432
|
-
return { k: "arr", start:
|
|
33585
|
+
return { k: "arr", start: open4.start, end: n.end, closeStart: n.start, items, commas };
|
|
33433
33586
|
}
|
|
33434
33587
|
items.push(this.value());
|
|
33435
33588
|
const c = this.at();
|
|
@@ -34347,7 +34500,7 @@ __export(companions_exports, {
|
|
|
34347
34500
|
uninstallCodeindex: () => uninstallCodeindex,
|
|
34348
34501
|
unregisterCodeindexMcp: () => unregisterCodeindexMcp
|
|
34349
34502
|
});
|
|
34350
|
-
import { existsSync as existsSync49, mkdirSync as mkdirSync15, statSync as
|
|
34503
|
+
import { existsSync as existsSync49, mkdirSync as mkdirSync15, statSync as statSync44, chmodSync as chmodSync6, unlinkSync as unlinkSync3, renameSync as renameSync7, createWriteStream as createWriteStream2, readFileSync as readFileSync47, writeFileSync as writeFileSync17 } from "node:fs";
|
|
34351
34504
|
import { homedir as homedir21 } from "node:os";
|
|
34352
34505
|
import { join as join59 } from "node:path";
|
|
34353
34506
|
import { execSync as execSync3 } from "node:child_process";
|
|
@@ -34398,7 +34551,7 @@ function checkCodeindexStatus() {
|
|
|
34398
34551
|
status.installed = true;
|
|
34399
34552
|
status.path = foundPath;
|
|
34400
34553
|
try {
|
|
34401
|
-
status.size =
|
|
34554
|
+
status.size = statSync44(foundPath).size;
|
|
34402
34555
|
} catch {
|
|
34403
34556
|
}
|
|
34404
34557
|
try {
|
|
@@ -34548,7 +34701,7 @@ __export(install_skills_exports, {
|
|
|
34548
34701
|
skillsSourceDir: () => skillsSourceDir,
|
|
34549
34702
|
uninstallSkills: () => uninstallSkills
|
|
34550
34703
|
});
|
|
34551
|
-
import { readdirSync as readdirSync33, existsSync as existsSync50, mkdirSync as mkdirSync16, rmSync as rmSync8, cpSync, writeFileSync as writeFileSync18, readFileSync as readFileSync48, statSync as
|
|
34704
|
+
import { readdirSync as readdirSync33, existsSync as existsSync50, mkdirSync as mkdirSync16, rmSync as rmSync8, cpSync, writeFileSync as writeFileSync18, readFileSync as readFileSync48, statSync as statSync45, realpathSync as realpathSync5 } from "fs";
|
|
34552
34705
|
import { createHash as createHash14 } from "crypto";
|
|
34553
34706
|
import { join as join60, basename as basename23 } from "path";
|
|
34554
34707
|
function skillsSourceDir() {
|
|
@@ -35563,11 +35716,11 @@ __export(toolkit_pull_exports, {
|
|
|
35563
35716
|
platformRefusal: () => platformRefusal,
|
|
35564
35717
|
portableCommand: () => portableCommand
|
|
35565
35718
|
});
|
|
35566
|
-
import { existsSync as existsSync52, mkdirSync as mkdirSync18, statSync as
|
|
35719
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync18, statSync as statSync46, writeFileSync as writeFileSync20 } from "node:fs";
|
|
35567
35720
|
import { dirname as dirname26, join as join63, basename as basename26, isAbsolute as isAbsolute4 } from "node:path";
|
|
35568
35721
|
function isExecutableFile(p) {
|
|
35569
35722
|
try {
|
|
35570
|
-
return
|
|
35723
|
+
return statSync46(p).isFile();
|
|
35571
35724
|
} catch {
|
|
35572
35725
|
return false;
|
|
35573
35726
|
}
|
|
@@ -37976,7 +38129,7 @@ __export(project_tasks_exports, {
|
|
|
37976
38129
|
pushProjectTaskStatuses: () => pushProjectTaskStatuses,
|
|
37977
38130
|
renderTeamTasksMd: () => renderTeamTasksMd
|
|
37978
38131
|
});
|
|
37979
|
-
import { existsSync as existsSync56, readFileSync as readFileSync53, writeFileSync as writeFileSync22, mkdirSync as mkdirSync20, statSync as
|
|
38132
|
+
import { existsSync as existsSync56, readFileSync as readFileSync53, writeFileSync as writeFileSync22, mkdirSync as mkdirSync20, statSync as statSync47 } from "node:fs";
|
|
37980
38133
|
import { join as join67, dirname as dirname28 } from "node:path";
|
|
37981
38134
|
import { homedir as homedir24 } from "node:os";
|
|
37982
38135
|
function isTeamTaskStatus(v) {
|
|
@@ -37989,7 +38142,7 @@ function isValidStatus(kind, v) {
|
|
|
37989
38142
|
return kind === "secret" ? isSecretTaskStatus(v) : kind === "team" ? isTeamTaskStatus(v) : isCodeTaskStatus(v);
|
|
37990
38143
|
}
|
|
37991
38144
|
function reconcile(kind, was, token, checked) {
|
|
37992
|
-
const
|
|
38145
|
+
const open4 = defaultWas(kind);
|
|
37993
38146
|
const done = kind === "secret" ? "rotated" : "done";
|
|
37994
38147
|
if (token && token !== was) return token;
|
|
37995
38148
|
if (kind === "team") {
|
|
@@ -37997,8 +38150,8 @@ function reconcile(kind, was, token, checked) {
|
|
|
37997
38150
|
if (!checked && was === "done") return "todo";
|
|
37998
38151
|
return token ?? was;
|
|
37999
38152
|
}
|
|
38000
|
-
if (checked && was ===
|
|
38001
|
-
if (!checked && was !==
|
|
38153
|
+
if (checked && was === open4) return done;
|
|
38154
|
+
if (!checked && was !== open4) return open4;
|
|
38002
38155
|
return token ?? was;
|
|
38003
38156
|
}
|
|
38004
38157
|
function parseAnchorLine(line) {
|
|
@@ -38065,7 +38218,7 @@ async function pushProjectTaskStatuses(base4, authHeaders, opts = {}) {
|
|
|
38065
38218
|
if (!existsSync56(file)) continue;
|
|
38066
38219
|
let mtime;
|
|
38067
38220
|
try {
|
|
38068
|
-
mtime =
|
|
38221
|
+
mtime = statSync47(file).mtimeMs;
|
|
38069
38222
|
} catch {
|
|
38070
38223
|
continue;
|
|
38071
38224
|
}
|
|
@@ -38578,7 +38731,7 @@ var team_merge_exports = {};
|
|
|
38578
38731
|
__export(team_merge_exports, {
|
|
38579
38732
|
mergePullResult: () => mergePullResult
|
|
38580
38733
|
});
|
|
38581
|
-
import { existsSync as existsSync58, mkdirSync as mkdirSync22, readFileSync as readFileSync55, rmSync as rmSync11, writeFileSync as writeFileSync24, statSync as
|
|
38734
|
+
import { existsSync as existsSync58, mkdirSync as mkdirSync22, readFileSync as readFileSync55, rmSync as rmSync11, writeFileSync as writeFileSync24, statSync as statSync48 } from "fs";
|
|
38582
38735
|
import { dirname as dirname30, join as join69 } from "path";
|
|
38583
38736
|
import { createHash as createHash17 } from "crypto";
|
|
38584
38737
|
function installPathFor(art, tool) {
|
|
@@ -38715,7 +38868,7 @@ function readFileIfExists(path) {
|
|
|
38715
38868
|
try {
|
|
38716
38869
|
if (!existsSync58(path))
|
|
38717
38870
|
return null;
|
|
38718
|
-
const s =
|
|
38871
|
+
const s = statSync48(path);
|
|
38719
38872
|
if (!s.isFile())
|
|
38720
38873
|
return null;
|
|
38721
38874
|
return readFileSync55(path);
|
|
@@ -38799,7 +38952,7 @@ var init_vault_crypto = __esm({
|
|
|
38799
38952
|
});
|
|
38800
38953
|
|
|
38801
38954
|
// ../engine/dist/core/vault-source.js
|
|
38802
|
-
import { existsSync as existsSync59, readdirSync as readdirSync35, statSync as
|
|
38955
|
+
import { existsSync as existsSync59, readdirSync as readdirSync35, statSync as statSync49 } from "fs";
|
|
38803
38956
|
import { extname, join as join70 } from "path";
|
|
38804
38957
|
function* walkVaultSources() {
|
|
38805
38958
|
const t = loadSettings().team.vault;
|
|
@@ -38815,7 +38968,7 @@ function* walkVaultSources() {
|
|
|
38815
38968
|
}
|
|
38816
38969
|
function safeStat(path) {
|
|
38817
38970
|
try {
|
|
38818
|
-
const s =
|
|
38971
|
+
const s = statSync49(path);
|
|
38819
38972
|
if (!s.isFile())
|
|
38820
38973
|
return null;
|
|
38821
38974
|
return { mtimeMs: s.mtimeMs, size: s.size };
|
|
@@ -38918,7 +39071,7 @@ function* walkAgy() {
|
|
|
38918
39071
|
for (const rawId of sessionDirs) {
|
|
38919
39072
|
const sessionPath = join70(brainDir, rawId);
|
|
38920
39073
|
try {
|
|
38921
|
-
if (!
|
|
39074
|
+
if (!statSync49(sessionPath).isDirectory())
|
|
38922
39075
|
continue;
|
|
38923
39076
|
} catch {
|
|
38924
39077
|
continue;
|
|
@@ -41521,7 +41674,7 @@ program.command("feedback").argument("<message...>", "what you want to say \u201
|
|
|
41521
41674
|
}
|
|
41522
41675
|
});
|
|
41523
41676
|
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) => {
|
|
41524
|
-
const { existsSync: existsSync63, readFileSync: readFileSync60, statSync:
|
|
41677
|
+
const { existsSync: existsSync63, readFileSync: readFileSync60, statSync: statSync50 } = await import("fs");
|
|
41525
41678
|
const { execSync: execSync6 } = await import("child_process");
|
|
41526
41679
|
const rows = [];
|
|
41527
41680
|
const note = (ok, label, detail) => rows.push({ ok, label, detail });
|
|
@@ -41589,7 +41742,7 @@ program.command("doctor").description("Quick health check across login, server,
|
|
|
41589
41742
|
note(false, "Credentials file", `missing \u2014 run \`chat-recall login <server-url>\``);
|
|
41590
41743
|
} else {
|
|
41591
41744
|
try {
|
|
41592
|
-
const mode =
|
|
41745
|
+
const mode = statSync50(credFile).mode & 511;
|
|
41593
41746
|
const isWin = process.platform === "win32";
|
|
41594
41747
|
const safe = isWin || (mode & 63) === 0;
|
|
41595
41748
|
note(safe, "Credentials file", isWin ? `${credFile} (Windows ACL \u2014 POSIX mode does not apply)` : `${credFile} (mode ${mode.toString(8).padStart(3, "0")}${safe ? "" : " \u2014 should be 600"})`);
|