@threadbase-sh/streamer 1.36.0 → 1.36.2
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.cjs +621 -372
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +328 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +313 -72
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -26158,7 +26158,7 @@ var require_thread_stream = __commonJS({
|
|
|
26158
26158
|
var { version: version2 } = require_package();
|
|
26159
26159
|
var { EventEmitter: EventEmitter5 } = require("events");
|
|
26160
26160
|
var { Worker } = require("worker_threads");
|
|
26161
|
-
var { join:
|
|
26161
|
+
var { join: join29 } = require("path");
|
|
26162
26162
|
var { pathToFileURL } = require("url");
|
|
26163
26163
|
var { wait } = require_wait();
|
|
26164
26164
|
var {
|
|
@@ -26209,7 +26209,7 @@ var require_thread_stream = __commonJS({
|
|
|
26209
26209
|
function createWorker(stream, opts) {
|
|
26210
26210
|
const { filename, workerData } = opts;
|
|
26211
26211
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
26212
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
26212
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join29(__dirname, "lib", "worker.js");
|
|
26213
26213
|
const worker = new Worker(toExecute, {
|
|
26214
26214
|
...opts.workerOpts,
|
|
26215
26215
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -26677,7 +26677,7 @@ var require_transport = __commonJS({
|
|
|
26677
26677
|
var { createRequire } = require("module");
|
|
26678
26678
|
var { existsSync: existsSync15 } = require("fs");
|
|
26679
26679
|
var getCallers = require_caller();
|
|
26680
|
-
var { join:
|
|
26680
|
+
var { join: join29, isAbsolute: isAbsolute2, sep: sep3 } = require("path");
|
|
26681
26681
|
var { fileURLToPath: fileURLToPath3 } = require("url");
|
|
26682
26682
|
var sleep = require_atomic_sleep();
|
|
26683
26683
|
var onExit = require_on_exit_leak_free();
|
|
@@ -26830,7 +26830,7 @@ var require_transport = __commonJS({
|
|
|
26830
26830
|
throw new Error("only one of target or targets can be specified");
|
|
26831
26831
|
}
|
|
26832
26832
|
if (targets) {
|
|
26833
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
26833
|
+
target = bundlerOverrides["pino-worker"] || join29(__dirname, "worker.js");
|
|
26834
26834
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
26835
26835
|
return {
|
|
26836
26836
|
...dest,
|
|
@@ -26848,7 +26848,7 @@ var require_transport = __commonJS({
|
|
|
26848
26848
|
});
|
|
26849
26849
|
});
|
|
26850
26850
|
} else if (pipeline2) {
|
|
26851
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
26851
|
+
target = bundlerOverrides["pino-worker"] || join29(__dirname, "worker.js");
|
|
26852
26852
|
options.pipelines = [pipeline2.map((dest) => {
|
|
26853
26853
|
return {
|
|
26854
26854
|
...dest,
|
|
@@ -26871,7 +26871,7 @@ var require_transport = __commonJS({
|
|
|
26871
26871
|
return origin;
|
|
26872
26872
|
}
|
|
26873
26873
|
if (origin === "pino/file") {
|
|
26874
|
-
return
|
|
26874
|
+
return join29(__dirname, "..", "file.js");
|
|
26875
26875
|
}
|
|
26876
26876
|
let fixTarget2;
|
|
26877
26877
|
for (const filePath of callers) {
|
|
@@ -27852,7 +27852,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
27852
27852
|
return circularValue;
|
|
27853
27853
|
}
|
|
27854
27854
|
let res = "";
|
|
27855
|
-
let
|
|
27855
|
+
let join29 = ",";
|
|
27856
27856
|
const originalIndentation = indentation;
|
|
27857
27857
|
if (Array.isArray(value)) {
|
|
27858
27858
|
if (value.length === 0) {
|
|
@@ -27866,7 +27866,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
27866
27866
|
indentation += spacer;
|
|
27867
27867
|
res += `
|
|
27868
27868
|
${indentation}`;
|
|
27869
|
-
|
|
27869
|
+
join29 = `,
|
|
27870
27870
|
${indentation}`;
|
|
27871
27871
|
}
|
|
27872
27872
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -27874,13 +27874,13 @@ ${indentation}`;
|
|
|
27874
27874
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
27875
27875
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
27876
27876
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
27877
|
-
res +=
|
|
27877
|
+
res += join29;
|
|
27878
27878
|
}
|
|
27879
27879
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
27880
27880
|
res += tmp !== void 0 ? tmp : "null";
|
|
27881
27881
|
if (value.length - 1 > maximumBreadth) {
|
|
27882
27882
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
27883
|
-
res += `${
|
|
27883
|
+
res += `${join29}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
27884
27884
|
}
|
|
27885
27885
|
if (spacer !== "") {
|
|
27886
27886
|
res += `
|
|
@@ -27901,7 +27901,7 @@ ${originalIndentation}`;
|
|
|
27901
27901
|
let separator = "";
|
|
27902
27902
|
if (spacer !== "") {
|
|
27903
27903
|
indentation += spacer;
|
|
27904
|
-
|
|
27904
|
+
join29 = `,
|
|
27905
27905
|
${indentation}`;
|
|
27906
27906
|
whitespace = " ";
|
|
27907
27907
|
}
|
|
@@ -27915,13 +27915,13 @@ ${indentation}`;
|
|
|
27915
27915
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
27916
27916
|
if (tmp !== void 0) {
|
|
27917
27917
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
27918
|
-
separator =
|
|
27918
|
+
separator = join29;
|
|
27919
27919
|
}
|
|
27920
27920
|
}
|
|
27921
27921
|
if (keyLength > maximumBreadth) {
|
|
27922
27922
|
const removedKeys = keyLength - maximumBreadth;
|
|
27923
27923
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
27924
|
-
separator =
|
|
27924
|
+
separator = join29;
|
|
27925
27925
|
}
|
|
27926
27926
|
if (spacer !== "" && separator.length > 1) {
|
|
27927
27927
|
res = `
|
|
@@ -27962,7 +27962,7 @@ ${originalIndentation}`;
|
|
|
27962
27962
|
}
|
|
27963
27963
|
const originalIndentation = indentation;
|
|
27964
27964
|
let res = "";
|
|
27965
|
-
let
|
|
27965
|
+
let join29 = ",";
|
|
27966
27966
|
if (Array.isArray(value)) {
|
|
27967
27967
|
if (value.length === 0) {
|
|
27968
27968
|
return "[]";
|
|
@@ -27975,7 +27975,7 @@ ${originalIndentation}`;
|
|
|
27975
27975
|
indentation += spacer;
|
|
27976
27976
|
res += `
|
|
27977
27977
|
${indentation}`;
|
|
27978
|
-
|
|
27978
|
+
join29 = `,
|
|
27979
27979
|
${indentation}`;
|
|
27980
27980
|
}
|
|
27981
27981
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -27983,13 +27983,13 @@ ${indentation}`;
|
|
|
27983
27983
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
27984
27984
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
27985
27985
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
27986
|
-
res +=
|
|
27986
|
+
res += join29;
|
|
27987
27987
|
}
|
|
27988
27988
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
27989
27989
|
res += tmp !== void 0 ? tmp : "null";
|
|
27990
27990
|
if (value.length - 1 > maximumBreadth) {
|
|
27991
27991
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
27992
|
-
res += `${
|
|
27992
|
+
res += `${join29}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
27993
27993
|
}
|
|
27994
27994
|
if (spacer !== "") {
|
|
27995
27995
|
res += `
|
|
@@ -28002,7 +28002,7 @@ ${originalIndentation}`;
|
|
|
28002
28002
|
let whitespace = "";
|
|
28003
28003
|
if (spacer !== "") {
|
|
28004
28004
|
indentation += spacer;
|
|
28005
|
-
|
|
28005
|
+
join29 = `,
|
|
28006
28006
|
${indentation}`;
|
|
28007
28007
|
whitespace = " ";
|
|
28008
28008
|
}
|
|
@@ -28011,7 +28011,7 @@ ${indentation}`;
|
|
|
28011
28011
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
28012
28012
|
if (tmp !== void 0) {
|
|
28013
28013
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
28014
|
-
separator =
|
|
28014
|
+
separator = join29;
|
|
28015
28015
|
}
|
|
28016
28016
|
}
|
|
28017
28017
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -28069,20 +28069,20 @@ ${originalIndentation}`;
|
|
|
28069
28069
|
indentation += spacer;
|
|
28070
28070
|
let res2 = `
|
|
28071
28071
|
${indentation}`;
|
|
28072
|
-
const
|
|
28072
|
+
const join30 = `,
|
|
28073
28073
|
${indentation}`;
|
|
28074
28074
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
28075
28075
|
let i = 0;
|
|
28076
28076
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
28077
28077
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
28078
28078
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
28079
|
-
res2 +=
|
|
28079
|
+
res2 += join30;
|
|
28080
28080
|
}
|
|
28081
28081
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
28082
28082
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
28083
28083
|
if (value.length - 1 > maximumBreadth) {
|
|
28084
28084
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
28085
|
-
res2 += `${
|
|
28085
|
+
res2 += `${join30}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
28086
28086
|
}
|
|
28087
28087
|
res2 += `
|
|
28088
28088
|
${originalIndentation}`;
|
|
@@ -28098,16 +28098,16 @@ ${originalIndentation}`;
|
|
|
28098
28098
|
return '"[Object]"';
|
|
28099
28099
|
}
|
|
28100
28100
|
indentation += spacer;
|
|
28101
|
-
const
|
|
28101
|
+
const join29 = `,
|
|
28102
28102
|
${indentation}`;
|
|
28103
28103
|
let res = "";
|
|
28104
28104
|
let separator = "";
|
|
28105
28105
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
28106
28106
|
if (isTypedArrayWithEntries(value)) {
|
|
28107
|
-
res += stringifyTypedArray(value,
|
|
28107
|
+
res += stringifyTypedArray(value, join29, maximumBreadth);
|
|
28108
28108
|
keys = keys.slice(value.length);
|
|
28109
28109
|
maximumPropertiesToStringify -= value.length;
|
|
28110
|
-
separator =
|
|
28110
|
+
separator = join29;
|
|
28111
28111
|
}
|
|
28112
28112
|
if (deterministic) {
|
|
28113
28113
|
keys = sort(keys, comparator);
|
|
@@ -28118,13 +28118,13 @@ ${indentation}`;
|
|
|
28118
28118
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
28119
28119
|
if (tmp !== void 0) {
|
|
28120
28120
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
28121
|
-
separator =
|
|
28121
|
+
separator = join29;
|
|
28122
28122
|
}
|
|
28123
28123
|
}
|
|
28124
28124
|
if (keyLength > maximumBreadth) {
|
|
28125
28125
|
const removedKeys = keyLength - maximumBreadth;
|
|
28126
28126
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
28127
|
-
separator =
|
|
28127
|
+
separator = join29;
|
|
28128
28128
|
}
|
|
28129
28129
|
if (separator !== "") {
|
|
28130
28130
|
res = `
|
|
@@ -100397,11 +100397,11 @@ var require_out = __commonJS({
|
|
|
100397
100397
|
async.read(path2, getSettings(optionsOrSettingsOrCallback), callback);
|
|
100398
100398
|
}
|
|
100399
100399
|
exports2.stat = stat7;
|
|
100400
|
-
function
|
|
100400
|
+
function statSync14(path2, optionsOrSettings) {
|
|
100401
100401
|
const settings = getSettings(optionsOrSettings);
|
|
100402
100402
|
return sync.read(path2, settings);
|
|
100403
100403
|
}
|
|
100404
|
-
exports2.statSync =
|
|
100404
|
+
exports2.statSync = statSync14;
|
|
100405
100405
|
function getSettings(settingsOrOptions = {}) {
|
|
100406
100406
|
if (settingsOrOptions instanceof settings_1.default) {
|
|
100407
100407
|
return settingsOrOptions;
|
|
@@ -135143,11 +135143,11 @@ async function search(query, options, scanner) {
|
|
|
135143
135143
|
|
|
135144
135144
|
// src/server.ts
|
|
135145
135145
|
var import_events2 = require("events");
|
|
135146
|
-
var
|
|
135146
|
+
var import_fs29 = require("fs");
|
|
135147
135147
|
var import_promises16 = require("fs/promises");
|
|
135148
135148
|
var import_http = require("http");
|
|
135149
|
-
var
|
|
135150
|
-
var
|
|
135149
|
+
var import_os12 = require("os");
|
|
135150
|
+
var import_path29 = require("path");
|
|
135151
135151
|
var import_readline4 = require("readline");
|
|
135152
135152
|
|
|
135153
135153
|
// src/agent/agent-client.ts
|
|
@@ -138354,8 +138354,8 @@ var createSessionRoutes = (deps) => {
|
|
|
138354
138354
|
await deps.handleStopSession(c.req.param("id"), c.env.outgoing);
|
|
138355
138355
|
return alreadyHandled6();
|
|
138356
138356
|
});
|
|
138357
|
-
app.get("/:id", (c) => {
|
|
138358
|
-
deps.handleGetSession(c.req.param("id"), c.env.outgoing);
|
|
138357
|
+
app.get("/:id", async (c) => {
|
|
138358
|
+
await deps.handleGetSession(c.req.param("id"), c.env.outgoing);
|
|
138359
138359
|
return alreadyHandled6();
|
|
138360
138360
|
});
|
|
138361
138361
|
return app;
|
|
@@ -141048,9 +141048,13 @@ var import_path22 = require("path");
|
|
|
141048
141048
|
init_logger();
|
|
141049
141049
|
|
|
141050
141050
|
// src/services/questions/detectPermissionGate.ts
|
|
141051
|
-
var
|
|
141051
|
+
var OSC_777_PERMISSION_RE = /\x1b\]777;notify;Claude Code;[^\x07\x1b]*needs your permission/;
|
|
141052
|
+
var OSC_777_WAITING_RE = /\x1b\]777;notify;Claude Code;[^\x07\x1b]*waiting for your input/;
|
|
141052
141053
|
function hasPermissionOsc(rawData) {
|
|
141053
|
-
return
|
|
141054
|
+
return OSC_777_PERMISSION_RE.test(rawData);
|
|
141055
|
+
}
|
|
141056
|
+
function hasWaitingForInputOsc(rawData) {
|
|
141057
|
+
return OSC_777_WAITING_RE.test(rawData);
|
|
141054
141058
|
}
|
|
141055
141059
|
var OPTION_RE = /^\s*(❯)?\s*(\d+)\.\s+(.+?)\s*$/;
|
|
141056
141060
|
var FOOTER_RE = /Enter to select|Esc to cancel|↑|↓|to navigate|to cancel/i;
|
|
@@ -141201,22 +141205,29 @@ function detectShellPrompt(lines) {
|
|
|
141201
141205
|
};
|
|
141202
141206
|
}
|
|
141203
141207
|
const lastNumberedIdx = (() => {
|
|
141204
|
-
|
|
141205
|
-
|
|
141208
|
+
let i = last.idx;
|
|
141209
|
+
if (!NUMBERED_RE.test(lines[i])) {
|
|
141210
|
+
if (i > 0 && (PRESS_ENTER_RE.test(lines[i].trim()) || CONTINUE_RE.test(lines[i].trim()))) {
|
|
141211
|
+
i--;
|
|
141212
|
+
} else {
|
|
141213
|
+
return -1;
|
|
141214
|
+
}
|
|
141206
141215
|
}
|
|
141207
|
-
|
|
141216
|
+
while (i >= 0 && !NUMBERED_RE.test(lines[i]) && lines[i].trim().length === 0) i--;
|
|
141217
|
+
return i >= 0 && NUMBERED_RE.test(lines[i]) ? i : -1;
|
|
141208
141218
|
})();
|
|
141209
141219
|
if (lastNumberedIdx >= 0) {
|
|
141210
141220
|
const options = [];
|
|
141211
|
-
|
|
141221
|
+
let firstRow = lastNumberedIdx;
|
|
141222
|
+
for (let i = lastNumberedIdx; i >= 0; i--) {
|
|
141212
141223
|
const m2 = NUMBERED_RE.exec(lines[i]);
|
|
141213
|
-
if (!m2)
|
|
141224
|
+
if (!m2) break;
|
|
141214
141225
|
const num = Number.parseInt(m2[1], 10);
|
|
141215
|
-
if (!Number.isFinite(num))
|
|
141216
|
-
options.
|
|
141226
|
+
if (!Number.isFinite(num)) break;
|
|
141227
|
+
options.unshift({ index: num, label: m2[2].trim(), answerKeys: `${num}${ENTER}` });
|
|
141228
|
+
firstRow = i;
|
|
141217
141229
|
}
|
|
141218
141230
|
if (options.length >= 2) {
|
|
141219
|
-
const firstRow = lines.findIndex((l) => NUMBERED_RE.test(l));
|
|
141220
141231
|
let prompt = "";
|
|
141221
141232
|
for (let i = firstRow - 1; i >= 0; i--) {
|
|
141222
141233
|
const t = lines[i].trim();
|
|
@@ -141785,12 +141796,13 @@ var PTYManager = class {
|
|
|
141785
141796
|
const session = this.sessions.get(sessionId);
|
|
141786
141797
|
if (!session) return;
|
|
141787
141798
|
const oscPermission = hasPermissionOsc(rawData);
|
|
141799
|
+
const oscWaitingForInput = hasWaitingForInputOsc(rawData);
|
|
141788
141800
|
const hasAskFooter = /Enter to select/i.test(stripped);
|
|
141789
141801
|
const hasPromptMarker = CLAUDE_PROMPT_MARKERS.some((m2) => stripped.includes(m2));
|
|
141790
141802
|
const hasShellPromptHint = /[[(]\s*y\s*\/\s*n\s*[\])]|press\s+(enter|return|any key)|\bcontinue\b\s*\?|^\s*(?:❯|>)?\s*\d+[.)]\s+\S/im.test(
|
|
141791
141803
|
stripped
|
|
141792
141804
|
);
|
|
141793
|
-
if (!oscPermission && !hasAskFooter && !hasShellPromptHint && !this.permissionOpen.has(sessionId) && !this.shellPromptOpen.has(sessionId) && !this.lastScreenQuestionKey.has(sessionId)) {
|
|
141805
|
+
if (!oscPermission && !oscWaitingForInput && !hasAskFooter && !hasShellPromptHint && !this.permissionOpen.has(sessionId) && !this.shellPromptOpen.has(sessionId) && !this.lastScreenQuestionKey.has(sessionId)) {
|
|
141794
141806
|
return;
|
|
141795
141807
|
}
|
|
141796
141808
|
const lines = await this.getOutputLines(sessionId, 60);
|
|
@@ -141813,11 +141825,11 @@ var PTYManager = class {
|
|
|
141813
141825
|
this.onPermissionChange?.(sessionId, gate ?? { options: [] });
|
|
141814
141826
|
} else if (this.permissionOpen.has(sessionId) && !askFooterOnScreen) {
|
|
141815
141827
|
const gate = scrapePermissionGate(lines);
|
|
141816
|
-
if (gate) {
|
|
141817
|
-
this.onPermissionChange?.(sessionId, gate);
|
|
141818
|
-
} else if (hasPromptMarker) {
|
|
141828
|
+
if (oscWaitingForInput || !gate && hasPromptMarker) {
|
|
141819
141829
|
this.permissionOpen.delete(sessionId);
|
|
141820
141830
|
this.onPermissionChange?.(sessionId, null);
|
|
141831
|
+
} else if (gate) {
|
|
141832
|
+
this.onPermissionChange?.(sessionId, gate);
|
|
141821
141833
|
}
|
|
141822
141834
|
}
|
|
141823
141835
|
if (askFooterOnScreen) {
|
|
@@ -142385,6 +142397,14 @@ function seal(plaintext, recipientPublicKeyBase64) {
|
|
|
142385
142397
|
};
|
|
142386
142398
|
}
|
|
142387
142399
|
|
|
142400
|
+
// src/services/cache/cacheMetadata.ts
|
|
142401
|
+
function getCacheMetadata(repo, key) {
|
|
142402
|
+
return repo.getCacheMetadata(key);
|
|
142403
|
+
}
|
|
142404
|
+
function setCacheMetadata(repo, key, value) {
|
|
142405
|
+
repo.setCacheMetadata(key, value);
|
|
142406
|
+
}
|
|
142407
|
+
|
|
142388
142408
|
// src/services/cache-integrity/cacheIntegrityMonitor.ts
|
|
142389
142409
|
var import_crypto10 = require("crypto");
|
|
142390
142410
|
var import_fs24 = require("fs");
|
|
@@ -142924,6 +142944,360 @@ function pruneAgentConversations(cache) {
|
|
|
142924
142944
|
return { scanned: rows.length, pruned, missing };
|
|
142925
142945
|
}
|
|
142926
142946
|
|
|
142947
|
+
// node_modules/date-fns/constants.js
|
|
142948
|
+
var daysInYear = 365.2425;
|
|
142949
|
+
var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
|
|
142950
|
+
var minTime = -maxTime;
|
|
142951
|
+
var millisecondsInMinute = 6e4;
|
|
142952
|
+
var millisecondsInHour = 36e5;
|
|
142953
|
+
var secondsInHour = 3600;
|
|
142954
|
+
var secondsInDay = secondsInHour * 24;
|
|
142955
|
+
var secondsInWeek = secondsInDay * 7;
|
|
142956
|
+
var secondsInYear = secondsInDay * daysInYear;
|
|
142957
|
+
var secondsInMonth = secondsInYear / 12;
|
|
142958
|
+
var secondsInQuarter = secondsInMonth * 3;
|
|
142959
|
+
var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
|
|
142960
|
+
|
|
142961
|
+
// node_modules/date-fns/constructFrom.js
|
|
142962
|
+
function constructFrom(date5, value) {
|
|
142963
|
+
if (typeof date5 === "function") return date5(value);
|
|
142964
|
+
if (date5 && typeof date5 === "object" && constructFromSymbol in date5)
|
|
142965
|
+
return date5[constructFromSymbol](value);
|
|
142966
|
+
if (date5 instanceof Date) return new date5.constructor(value);
|
|
142967
|
+
return new Date(value);
|
|
142968
|
+
}
|
|
142969
|
+
|
|
142970
|
+
// node_modules/date-fns/toDate.js
|
|
142971
|
+
function toDate(argument, context) {
|
|
142972
|
+
return constructFrom(context || argument, argument);
|
|
142973
|
+
}
|
|
142974
|
+
|
|
142975
|
+
// node_modules/date-fns/compareDesc.js
|
|
142976
|
+
function compareDesc(dateLeft, dateRight) {
|
|
142977
|
+
const diff = +toDate(dateLeft) - +toDate(dateRight);
|
|
142978
|
+
if (diff > 0) return -1;
|
|
142979
|
+
else if (diff < 0) return 1;
|
|
142980
|
+
return diff;
|
|
142981
|
+
}
|
|
142982
|
+
|
|
142983
|
+
// node_modules/date-fns/isDate.js
|
|
142984
|
+
function isDate(value) {
|
|
142985
|
+
return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
|
|
142986
|
+
}
|
|
142987
|
+
|
|
142988
|
+
// node_modules/date-fns/isValid.js
|
|
142989
|
+
function isValid(date5) {
|
|
142990
|
+
return !(!isDate(date5) && typeof date5 !== "number" || isNaN(+toDate(date5)));
|
|
142991
|
+
}
|
|
142992
|
+
|
|
142993
|
+
// node_modules/date-fns/parseISO.js
|
|
142994
|
+
function parseISO(argument, options) {
|
|
142995
|
+
const invalidDate = () => constructFrom(options?.in, NaN);
|
|
142996
|
+
const additionalDigits = options?.additionalDigits ?? 2;
|
|
142997
|
+
const dateStrings = splitDateString(argument);
|
|
142998
|
+
let date5;
|
|
142999
|
+
if (dateStrings.date) {
|
|
143000
|
+
const parseYearResult = parseYear(dateStrings.date, additionalDigits);
|
|
143001
|
+
date5 = parseDate(parseYearResult.restDateString, parseYearResult.year);
|
|
143002
|
+
}
|
|
143003
|
+
if (!date5 || isNaN(+date5)) return invalidDate();
|
|
143004
|
+
const timestamp2 = +date5;
|
|
143005
|
+
let time3 = 0;
|
|
143006
|
+
let offset;
|
|
143007
|
+
if (dateStrings.time) {
|
|
143008
|
+
time3 = parseTime(dateStrings.time);
|
|
143009
|
+
if (isNaN(time3)) return invalidDate();
|
|
143010
|
+
}
|
|
143011
|
+
if (dateStrings.timezone) {
|
|
143012
|
+
offset = parseTimezone(dateStrings.timezone);
|
|
143013
|
+
if (isNaN(offset)) return invalidDate();
|
|
143014
|
+
} else {
|
|
143015
|
+
const tmpDate = new Date(timestamp2 + time3);
|
|
143016
|
+
const result = toDate(0, options?.in);
|
|
143017
|
+
result.setFullYear(
|
|
143018
|
+
tmpDate.getUTCFullYear(),
|
|
143019
|
+
tmpDate.getUTCMonth(),
|
|
143020
|
+
tmpDate.getUTCDate()
|
|
143021
|
+
);
|
|
143022
|
+
result.setHours(
|
|
143023
|
+
tmpDate.getUTCHours(),
|
|
143024
|
+
tmpDate.getUTCMinutes(),
|
|
143025
|
+
tmpDate.getUTCSeconds(),
|
|
143026
|
+
tmpDate.getUTCMilliseconds()
|
|
143027
|
+
);
|
|
143028
|
+
return result;
|
|
143029
|
+
}
|
|
143030
|
+
return toDate(timestamp2 + time3 + offset, options?.in);
|
|
143031
|
+
}
|
|
143032
|
+
var patterns = {
|
|
143033
|
+
dateTimeDelimiter: /[T ]/,
|
|
143034
|
+
timeZoneDelimiter: /[Z ]/i,
|
|
143035
|
+
timezone: /([Z+-].*)$/
|
|
143036
|
+
};
|
|
143037
|
+
var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
|
|
143038
|
+
var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
|
|
143039
|
+
var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
143040
|
+
function splitDateString(dateString) {
|
|
143041
|
+
const dateStrings = {};
|
|
143042
|
+
const array2 = dateString.split(patterns.dateTimeDelimiter);
|
|
143043
|
+
let timeString;
|
|
143044
|
+
if (array2.length > 2) {
|
|
143045
|
+
return dateStrings;
|
|
143046
|
+
}
|
|
143047
|
+
if (/:/.test(array2[0])) {
|
|
143048
|
+
timeString = array2[0];
|
|
143049
|
+
} else {
|
|
143050
|
+
dateStrings.date = array2[0];
|
|
143051
|
+
timeString = array2[1];
|
|
143052
|
+
if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
|
|
143053
|
+
dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
|
|
143054
|
+
timeString = dateString.substr(
|
|
143055
|
+
dateStrings.date.length,
|
|
143056
|
+
dateString.length
|
|
143057
|
+
);
|
|
143058
|
+
}
|
|
143059
|
+
}
|
|
143060
|
+
if (timeString) {
|
|
143061
|
+
const token = patterns.timezone.exec(timeString);
|
|
143062
|
+
if (token) {
|
|
143063
|
+
dateStrings.time = timeString.replace(token[1], "");
|
|
143064
|
+
dateStrings.timezone = token[1];
|
|
143065
|
+
} else {
|
|
143066
|
+
dateStrings.time = timeString;
|
|
143067
|
+
}
|
|
143068
|
+
}
|
|
143069
|
+
return dateStrings;
|
|
143070
|
+
}
|
|
143071
|
+
function parseYear(dateString, additionalDigits) {
|
|
143072
|
+
const regex = new RegExp(
|
|
143073
|
+
"^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
|
|
143074
|
+
);
|
|
143075
|
+
const captures = dateString.match(regex);
|
|
143076
|
+
if (!captures) return { year: NaN, restDateString: "" };
|
|
143077
|
+
const year = captures[1] ? parseInt(captures[1]) : null;
|
|
143078
|
+
const century = captures[2] ? parseInt(captures[2]) : null;
|
|
143079
|
+
return {
|
|
143080
|
+
year: century === null ? year : century * 100,
|
|
143081
|
+
restDateString: dateString.slice((captures[1] || captures[2]).length)
|
|
143082
|
+
};
|
|
143083
|
+
}
|
|
143084
|
+
function parseDate(dateString, year) {
|
|
143085
|
+
if (year === null) return /* @__PURE__ */ new Date(NaN);
|
|
143086
|
+
const captures = dateString.match(dateRegex);
|
|
143087
|
+
if (!captures) return /* @__PURE__ */ new Date(NaN);
|
|
143088
|
+
const isWeekDate = !!captures[4];
|
|
143089
|
+
const dayOfYear = parseDateUnit(captures[1]);
|
|
143090
|
+
const month = parseDateUnit(captures[2]) - 1;
|
|
143091
|
+
const day = parseDateUnit(captures[3]);
|
|
143092
|
+
const week = parseDateUnit(captures[4]);
|
|
143093
|
+
const dayOfWeek = parseDateUnit(captures[5]) - 1;
|
|
143094
|
+
if (isWeekDate) {
|
|
143095
|
+
if (!validateWeekDate(year, week, dayOfWeek)) {
|
|
143096
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
143097
|
+
}
|
|
143098
|
+
return dayOfISOWeekYear(year, week, dayOfWeek);
|
|
143099
|
+
} else {
|
|
143100
|
+
const date5 = /* @__PURE__ */ new Date(0);
|
|
143101
|
+
if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
|
|
143102
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
143103
|
+
}
|
|
143104
|
+
date5.setUTCFullYear(year, month, Math.max(dayOfYear, day));
|
|
143105
|
+
return date5;
|
|
143106
|
+
}
|
|
143107
|
+
}
|
|
143108
|
+
function parseDateUnit(value) {
|
|
143109
|
+
return value ? parseInt(value) : 1;
|
|
143110
|
+
}
|
|
143111
|
+
function parseTime(timeString) {
|
|
143112
|
+
const captures = timeString.match(timeRegex);
|
|
143113
|
+
if (!captures) return NaN;
|
|
143114
|
+
const hours = parseTimeUnit(captures[1]);
|
|
143115
|
+
const minutes = parseTimeUnit(captures[2]);
|
|
143116
|
+
const seconds = parseTimeUnit(captures[3]);
|
|
143117
|
+
if (!validateTime(hours, minutes, seconds)) {
|
|
143118
|
+
return NaN;
|
|
143119
|
+
}
|
|
143120
|
+
return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
|
|
143121
|
+
}
|
|
143122
|
+
function parseTimeUnit(value) {
|
|
143123
|
+
return value && parseFloat(value.replace(",", ".")) || 0;
|
|
143124
|
+
}
|
|
143125
|
+
function parseTimezone(timezoneString) {
|
|
143126
|
+
if (timezoneString === "Z") return 0;
|
|
143127
|
+
const captures = timezoneString.match(timezoneRegex);
|
|
143128
|
+
if (!captures) return 0;
|
|
143129
|
+
const sign = captures[1] === "+" ? -1 : 1;
|
|
143130
|
+
const hours = parseInt(captures[2]);
|
|
143131
|
+
const minutes = captures[3] && parseInt(captures[3]) || 0;
|
|
143132
|
+
if (!validateTimezone(hours, minutes)) {
|
|
143133
|
+
return NaN;
|
|
143134
|
+
}
|
|
143135
|
+
return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
|
|
143136
|
+
}
|
|
143137
|
+
function dayOfISOWeekYear(isoWeekYear, week, day) {
|
|
143138
|
+
const date5 = /* @__PURE__ */ new Date(0);
|
|
143139
|
+
date5.setUTCFullYear(isoWeekYear, 0, 4);
|
|
143140
|
+
const fourthOfJanuaryDay = date5.getUTCDay() || 7;
|
|
143141
|
+
const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
|
|
143142
|
+
date5.setUTCDate(date5.getUTCDate() + diff);
|
|
143143
|
+
return date5;
|
|
143144
|
+
}
|
|
143145
|
+
var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
143146
|
+
function isLeapYearIndex(year) {
|
|
143147
|
+
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
|
|
143148
|
+
}
|
|
143149
|
+
function validateDate(year, month, date5) {
|
|
143150
|
+
return month >= 0 && month <= 11 && date5 >= 1 && date5 <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
|
|
143151
|
+
}
|
|
143152
|
+
function validateDayOfYearDate(year, dayOfYear) {
|
|
143153
|
+
return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
|
|
143154
|
+
}
|
|
143155
|
+
function validateWeekDate(_year, week, day) {
|
|
143156
|
+
return week >= 1 && week <= 53 && day >= 0 && day <= 6;
|
|
143157
|
+
}
|
|
143158
|
+
function validateTime(hours, minutes, seconds) {
|
|
143159
|
+
if (hours === 24) {
|
|
143160
|
+
return minutes === 0 && seconds === 0;
|
|
143161
|
+
}
|
|
143162
|
+
return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
|
|
143163
|
+
}
|
|
143164
|
+
function validateTimezone(_hours, minutes) {
|
|
143165
|
+
return minutes >= 0 && minutes <= 59;
|
|
143166
|
+
}
|
|
143167
|
+
|
|
143168
|
+
// src/utils/dates.ts
|
|
143169
|
+
function parseIsoDateOrNull(value) {
|
|
143170
|
+
if (!value) return null;
|
|
143171
|
+
const parsed = parseISO(value);
|
|
143172
|
+
return isValid(parsed) ? parsed : null;
|
|
143173
|
+
}
|
|
143174
|
+
function compareIsoDesc(a, b2) {
|
|
143175
|
+
const dateA = parseIsoDateOrNull(a);
|
|
143176
|
+
const dateB = parseIsoDateOrNull(b2);
|
|
143177
|
+
if (!dateA && !dateB) return 0;
|
|
143178
|
+
if (!dateA) return 1;
|
|
143179
|
+
if (!dateB) return -1;
|
|
143180
|
+
return compareDesc(dateA, dateB);
|
|
143181
|
+
}
|
|
143182
|
+
|
|
143183
|
+
// src/services/projects/ensureProjectsForConversations.ts
|
|
143184
|
+
function ensureProjectsForConversations(repo, conversations) {
|
|
143185
|
+
const conversationsByPath = /* @__PURE__ */ new Map();
|
|
143186
|
+
for (const conversation of conversations) {
|
|
143187
|
+
if (!conversation.projectPath) continue;
|
|
143188
|
+
const canonical = canonicalizeProjectPath(conversation.projectPath);
|
|
143189
|
+
if (!canonical) continue;
|
|
143190
|
+
const existing = conversationsByPath.get(canonical) ?? [];
|
|
143191
|
+
existing.push(conversation);
|
|
143192
|
+
conversationsByPath.set(canonical, existing);
|
|
143193
|
+
}
|
|
143194
|
+
const pathToProjectId = /* @__PURE__ */ new Map();
|
|
143195
|
+
for (const [path2, projectConversations] of conversationsByPath) {
|
|
143196
|
+
const latest = pickLatestConversation(projectConversations);
|
|
143197
|
+
const project = repo.upsertProjectByPath(path2, {
|
|
143198
|
+
lastConversationId: latest?.id ?? null,
|
|
143199
|
+
lastConversationCreatedAt: latest?.createdAt ?? null,
|
|
143200
|
+
latestMessageAt: latest?.latestMessageAt ?? null
|
|
143201
|
+
});
|
|
143202
|
+
pathToProjectId.set(path2, project.id);
|
|
143203
|
+
}
|
|
143204
|
+
return pathToProjectId;
|
|
143205
|
+
}
|
|
143206
|
+
function pickLatestConversation(conversations) {
|
|
143207
|
+
if (conversations.length === 0) return void 0;
|
|
143208
|
+
return [...conversations].sort((a, b2) => {
|
|
143209
|
+
const cmp = compareIsoDesc(a.latestMessageAt ?? null, b2.latestMessageAt ?? null);
|
|
143210
|
+
if (cmp !== 0) return cmp;
|
|
143211
|
+
return compareIsoDesc(a.createdAt ?? null, b2.createdAt ?? null);
|
|
143212
|
+
})[0];
|
|
143213
|
+
}
|
|
143214
|
+
|
|
143215
|
+
// src/services/conversations/refreshConversationCache.ts
|
|
143216
|
+
function refreshConversationCache(deps) {
|
|
143217
|
+
const { projectsRepo, conversationsRepo, cacheMetadataRepo } = deps;
|
|
143218
|
+
const conversations = conversationsRepo.listConversationsForProjectBackfill();
|
|
143219
|
+
const pathToProjectId = ensureProjectsForConversations(
|
|
143220
|
+
projectsRepo,
|
|
143221
|
+
conversations.map((c) => ({
|
|
143222
|
+
id: c.id,
|
|
143223
|
+
projectPath: c.projectPath,
|
|
143224
|
+
latestMessageAt: c.lastActivity ?? null,
|
|
143225
|
+
createdAt: c.lastActivity ?? null
|
|
143226
|
+
}))
|
|
143227
|
+
);
|
|
143228
|
+
let conversationsBackfilled = 0;
|
|
143229
|
+
for (const conversation of conversations) {
|
|
143230
|
+
if (!conversation.projectPath) continue;
|
|
143231
|
+
if (conversation.projectId) continue;
|
|
143232
|
+
const projectId = pathToProjectId.get(canonicalizeProjectPath(conversation.projectPath));
|
|
143233
|
+
if (!projectId) continue;
|
|
143234
|
+
conversationsRepo.updateConversationProjectId({
|
|
143235
|
+
conversationId: conversation.id,
|
|
143236
|
+
projectId
|
|
143237
|
+
});
|
|
143238
|
+
conversationsBackfilled += 1;
|
|
143239
|
+
}
|
|
143240
|
+
const latest = conversationsRepo.getLatestConversation();
|
|
143241
|
+
if (latest) {
|
|
143242
|
+
setCacheMetadata(cacheMetadataRepo, "last_conversation_id", latest.id);
|
|
143243
|
+
if (latest.lastActivity) {
|
|
143244
|
+
setCacheMetadata(cacheMetadataRepo, "last_conversation_created_at", latest.lastActivity);
|
|
143245
|
+
}
|
|
143246
|
+
}
|
|
143247
|
+
setCacheMetadata(cacheMetadataRepo, "conversations_last_indexed_at", (/* @__PURE__ */ new Date()).toISOString());
|
|
143248
|
+
return {
|
|
143249
|
+
projectsTouched: pathToProjectId.size,
|
|
143250
|
+
conversationsBackfilled,
|
|
143251
|
+
latestConversationId: latest?.id ?? null
|
|
143252
|
+
};
|
|
143253
|
+
}
|
|
143254
|
+
|
|
143255
|
+
// src/services/conversations/shouldRefreshProjectsFromHdd.ts
|
|
143256
|
+
var import_fs27 = require("fs");
|
|
143257
|
+
var import_os11 = require("os");
|
|
143258
|
+
var import_path27 = require("path");
|
|
143259
|
+
var DEFAULT_PROJECTS_DIR = (0, import_path27.join)((0, import_os11.homedir)(), ".claude", "projects");
|
|
143260
|
+
function maxProjectsTreeMtimeMs(projectsDir) {
|
|
143261
|
+
let maxMs;
|
|
143262
|
+
try {
|
|
143263
|
+
maxMs = (0, import_fs27.statSync)(projectsDir).mtimeMs;
|
|
143264
|
+
} catch {
|
|
143265
|
+
return null;
|
|
143266
|
+
}
|
|
143267
|
+
try {
|
|
143268
|
+
for (const ent of (0, import_fs27.readdirSync)(projectsDir, { withFileTypes: true })) {
|
|
143269
|
+
if (!ent.isDirectory()) continue;
|
|
143270
|
+
try {
|
|
143271
|
+
const childMs = (0, import_fs27.statSync)((0, import_path27.join)(projectsDir, ent.name)).mtimeMs;
|
|
143272
|
+
if (childMs > maxMs) maxMs = childMs;
|
|
143273
|
+
} catch {
|
|
143274
|
+
}
|
|
143275
|
+
}
|
|
143276
|
+
} catch {
|
|
143277
|
+
}
|
|
143278
|
+
return maxMs;
|
|
143279
|
+
}
|
|
143280
|
+
function shouldRefreshProjectsFromHdd(conversationsRepo, cacheMetadataRepo, opts = {}) {
|
|
143281
|
+
if (conversationsRepo.hasOrphanRows()) return true;
|
|
143282
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
143283
|
+
if (opts.projectsDirs) {
|
|
143284
|
+
for (const d of opts.projectsDirs) dirs.add(d);
|
|
143285
|
+
}
|
|
143286
|
+
dirs.add(opts.projectsDir ?? DEFAULT_PROJECTS_DIR);
|
|
143287
|
+
let newestMs = null;
|
|
143288
|
+
for (const dir of dirs) {
|
|
143289
|
+
const ms2 = maxProjectsTreeMtimeMs(dir);
|
|
143290
|
+
if (ms2 === null) continue;
|
|
143291
|
+
if (newestMs === null || ms2 > newestMs) newestMs = ms2;
|
|
143292
|
+
}
|
|
143293
|
+
if (newestMs === null) return false;
|
|
143294
|
+
const lastIndexedIso = getCacheMetadata(cacheMetadataRepo, "conversations_last_indexed_at");
|
|
143295
|
+
if (!lastIndexedIso) return true;
|
|
143296
|
+
const lastIndexedMs = Date.parse(lastIndexedIso);
|
|
143297
|
+
if (Number.isNaN(lastIndexedMs)) return true;
|
|
143298
|
+
return newestMs > lastIndexedMs;
|
|
143299
|
+
}
|
|
143300
|
+
|
|
142927
143301
|
// src/services/projectChats/deriveProjectChatTitle.ts
|
|
142928
143302
|
function deriveProjectChatTitle(input) {
|
|
142929
143303
|
const trimmed = input.title?.trim();
|
|
@@ -142935,6 +143309,32 @@ function deriveProjectChatTitle(input) {
|
|
|
142935
143309
|
return `Untitled \xB7 ${input.id.slice(0, 8)}`;
|
|
142936
143310
|
}
|
|
142937
143311
|
|
|
143312
|
+
// src/services/questions/parseStatusLine.ts
|
|
143313
|
+
var MODEL_RE = /(Opus|Sonnet|Haiku|Fable)\s+[\d.]+(?:\s*\([^)]*\))?/;
|
|
143314
|
+
var EFFORT_RE = /●\s*([A-Za-z]+)\s*·\s*\/effort/;
|
|
143315
|
+
var PERMISSION_MODE_RE = /⏵⏵\s*([^(·\n]+?)\s*(?:\(|·|$)/;
|
|
143316
|
+
function parseStatusLine(lines) {
|
|
143317
|
+
const info = {};
|
|
143318
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
143319
|
+
const line = lines[i];
|
|
143320
|
+
if (!line) continue;
|
|
143321
|
+
if (info.effort === void 0) {
|
|
143322
|
+
const m2 = EFFORT_RE.exec(line);
|
|
143323
|
+
if (m2) info.effort = m2[1];
|
|
143324
|
+
}
|
|
143325
|
+
if (info.permissionMode === void 0) {
|
|
143326
|
+
const m2 = PERMISSION_MODE_RE.exec(line);
|
|
143327
|
+
if (m2) info.permissionMode = m2[1].trim();
|
|
143328
|
+
}
|
|
143329
|
+
if (info.model === void 0) {
|
|
143330
|
+
const m2 = MODEL_RE.exec(line);
|
|
143331
|
+
if (m2) info.model = m2[0].replace(/\s+/g, " ").trim();
|
|
143332
|
+
}
|
|
143333
|
+
if (info.model && info.effort && info.permissionMode) break;
|
|
143334
|
+
}
|
|
143335
|
+
return info;
|
|
143336
|
+
}
|
|
143337
|
+
|
|
142938
143338
|
// src/services/questions/detectAskUserQuestion.ts
|
|
142939
143339
|
function normalizeContent2(raw2) {
|
|
142940
143340
|
if (Array.isArray(raw2)) return raw2;
|
|
@@ -143059,7 +143459,7 @@ function resolveAnswer(pending, body) {
|
|
|
143059
143459
|
}
|
|
143060
143460
|
|
|
143061
143461
|
// src/services/sessions/conversationBusy.ts
|
|
143062
|
-
var
|
|
143462
|
+
var import_fs28 = require("fs");
|
|
143063
143463
|
var RESUME_BUSY_WINDOW_MS = 12e4;
|
|
143064
143464
|
function resolveResumeBusyWindowMs(env = process.env) {
|
|
143065
143465
|
const raw2 = env.THREADBASE_RESUME_BUSY_WINDOW_MS;
|
|
@@ -143076,7 +143476,7 @@ function conversationBusy(input) {
|
|
|
143076
143476
|
let lastActivityMs = null;
|
|
143077
143477
|
if (input.jsonlPath) {
|
|
143078
143478
|
try {
|
|
143079
|
-
const mtimeMs = (0,
|
|
143479
|
+
const mtimeMs = (0, import_fs28.statSync)(input.jsonlPath).mtimeMs;
|
|
143080
143480
|
const age = now - mtimeMs;
|
|
143081
143481
|
lastActivityMs = Math.max(0, age);
|
|
143082
143482
|
const isSelfEcho = input.selfPtyEndedAt != null && mtimeMs <= input.selfPtyEndedAt + SELF_ACTIVITY_SKEW_MS;
|
|
@@ -143330,7 +143730,7 @@ function discoveredToResponse(d, conversationId) {
|
|
|
143330
143730
|
var import_crypto11 = require("crypto");
|
|
143331
143731
|
var import_promises15 = require("fs/promises");
|
|
143332
143732
|
var import_heic_convert = __toESM(require_heic_convert(), 1);
|
|
143333
|
-
var
|
|
143733
|
+
var import_path28 = require("path");
|
|
143334
143734
|
var UPLOAD_DIR_NAME = ".threadbase-uploads";
|
|
143335
143735
|
var MAX_BYTES = 25 * 1024 * 1024;
|
|
143336
143736
|
var HEIC_MIMES = /* @__PURE__ */ new Set(["image/heic", "image/heif"]);
|
|
@@ -143363,9 +143763,9 @@ async function saveUploadFile(input) {
|
|
|
143363
143763
|
}
|
|
143364
143764
|
const id = `up_${(0, import_crypto11.randomBytes)(8).toString("hex")}`;
|
|
143365
143765
|
const safeName = sanitizeFilename(originalName) || `file${MIME_TO_EXT[mimeType] ?? ""}`;
|
|
143366
|
-
const dir = (0,
|
|
143766
|
+
const dir = (0, import_path28.join)(input.projectPath, UPLOAD_DIR_NAME, input.sessionId);
|
|
143367
143767
|
await (0, import_promises15.mkdir)(dir, { recursive: true });
|
|
143368
|
-
const filePath = (0,
|
|
143768
|
+
const filePath = (0, import_path28.join)(dir, `${Date.now()}-${id}-${safeName}`);
|
|
143369
143769
|
await (0, import_promises15.writeFile)(filePath, buffer);
|
|
143370
143770
|
return {
|
|
143371
143771
|
id,
|
|
@@ -143475,226 +143875,6 @@ function computeConversationEtag({
|
|
|
143475
143875
|
return `"${digest}"`;
|
|
143476
143876
|
}
|
|
143477
143877
|
|
|
143478
|
-
// node_modules/date-fns/constants.js
|
|
143479
|
-
var daysInYear = 365.2425;
|
|
143480
|
-
var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
|
|
143481
|
-
var minTime = -maxTime;
|
|
143482
|
-
var millisecondsInMinute = 6e4;
|
|
143483
|
-
var millisecondsInHour = 36e5;
|
|
143484
|
-
var secondsInHour = 3600;
|
|
143485
|
-
var secondsInDay = secondsInHour * 24;
|
|
143486
|
-
var secondsInWeek = secondsInDay * 7;
|
|
143487
|
-
var secondsInYear = secondsInDay * daysInYear;
|
|
143488
|
-
var secondsInMonth = secondsInYear / 12;
|
|
143489
|
-
var secondsInQuarter = secondsInMonth * 3;
|
|
143490
|
-
var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
|
|
143491
|
-
|
|
143492
|
-
// node_modules/date-fns/constructFrom.js
|
|
143493
|
-
function constructFrom(date5, value) {
|
|
143494
|
-
if (typeof date5 === "function") return date5(value);
|
|
143495
|
-
if (date5 && typeof date5 === "object" && constructFromSymbol in date5)
|
|
143496
|
-
return date5[constructFromSymbol](value);
|
|
143497
|
-
if (date5 instanceof Date) return new date5.constructor(value);
|
|
143498
|
-
return new Date(value);
|
|
143499
|
-
}
|
|
143500
|
-
|
|
143501
|
-
// node_modules/date-fns/toDate.js
|
|
143502
|
-
function toDate(argument, context) {
|
|
143503
|
-
return constructFrom(context || argument, argument);
|
|
143504
|
-
}
|
|
143505
|
-
|
|
143506
|
-
// node_modules/date-fns/isDate.js
|
|
143507
|
-
function isDate(value) {
|
|
143508
|
-
return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
|
|
143509
|
-
}
|
|
143510
|
-
|
|
143511
|
-
// node_modules/date-fns/isValid.js
|
|
143512
|
-
function isValid(date5) {
|
|
143513
|
-
return !(!isDate(date5) && typeof date5 !== "number" || isNaN(+toDate(date5)));
|
|
143514
|
-
}
|
|
143515
|
-
|
|
143516
|
-
// node_modules/date-fns/parseISO.js
|
|
143517
|
-
function parseISO(argument, options) {
|
|
143518
|
-
const invalidDate = () => constructFrom(options?.in, NaN);
|
|
143519
|
-
const additionalDigits = options?.additionalDigits ?? 2;
|
|
143520
|
-
const dateStrings = splitDateString(argument);
|
|
143521
|
-
let date5;
|
|
143522
|
-
if (dateStrings.date) {
|
|
143523
|
-
const parseYearResult = parseYear(dateStrings.date, additionalDigits);
|
|
143524
|
-
date5 = parseDate(parseYearResult.restDateString, parseYearResult.year);
|
|
143525
|
-
}
|
|
143526
|
-
if (!date5 || isNaN(+date5)) return invalidDate();
|
|
143527
|
-
const timestamp2 = +date5;
|
|
143528
|
-
let time3 = 0;
|
|
143529
|
-
let offset;
|
|
143530
|
-
if (dateStrings.time) {
|
|
143531
|
-
time3 = parseTime(dateStrings.time);
|
|
143532
|
-
if (isNaN(time3)) return invalidDate();
|
|
143533
|
-
}
|
|
143534
|
-
if (dateStrings.timezone) {
|
|
143535
|
-
offset = parseTimezone(dateStrings.timezone);
|
|
143536
|
-
if (isNaN(offset)) return invalidDate();
|
|
143537
|
-
} else {
|
|
143538
|
-
const tmpDate = new Date(timestamp2 + time3);
|
|
143539
|
-
const result = toDate(0, options?.in);
|
|
143540
|
-
result.setFullYear(
|
|
143541
|
-
tmpDate.getUTCFullYear(),
|
|
143542
|
-
tmpDate.getUTCMonth(),
|
|
143543
|
-
tmpDate.getUTCDate()
|
|
143544
|
-
);
|
|
143545
|
-
result.setHours(
|
|
143546
|
-
tmpDate.getUTCHours(),
|
|
143547
|
-
tmpDate.getUTCMinutes(),
|
|
143548
|
-
tmpDate.getUTCSeconds(),
|
|
143549
|
-
tmpDate.getUTCMilliseconds()
|
|
143550
|
-
);
|
|
143551
|
-
return result;
|
|
143552
|
-
}
|
|
143553
|
-
return toDate(timestamp2 + time3 + offset, options?.in);
|
|
143554
|
-
}
|
|
143555
|
-
var patterns = {
|
|
143556
|
-
dateTimeDelimiter: /[T ]/,
|
|
143557
|
-
timeZoneDelimiter: /[Z ]/i,
|
|
143558
|
-
timezone: /([Z+-].*)$/
|
|
143559
|
-
};
|
|
143560
|
-
var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
|
|
143561
|
-
var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
|
|
143562
|
-
var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
143563
|
-
function splitDateString(dateString) {
|
|
143564
|
-
const dateStrings = {};
|
|
143565
|
-
const array2 = dateString.split(patterns.dateTimeDelimiter);
|
|
143566
|
-
let timeString;
|
|
143567
|
-
if (array2.length > 2) {
|
|
143568
|
-
return dateStrings;
|
|
143569
|
-
}
|
|
143570
|
-
if (/:/.test(array2[0])) {
|
|
143571
|
-
timeString = array2[0];
|
|
143572
|
-
} else {
|
|
143573
|
-
dateStrings.date = array2[0];
|
|
143574
|
-
timeString = array2[1];
|
|
143575
|
-
if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
|
|
143576
|
-
dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
|
|
143577
|
-
timeString = dateString.substr(
|
|
143578
|
-
dateStrings.date.length,
|
|
143579
|
-
dateString.length
|
|
143580
|
-
);
|
|
143581
|
-
}
|
|
143582
|
-
}
|
|
143583
|
-
if (timeString) {
|
|
143584
|
-
const token = patterns.timezone.exec(timeString);
|
|
143585
|
-
if (token) {
|
|
143586
|
-
dateStrings.time = timeString.replace(token[1], "");
|
|
143587
|
-
dateStrings.timezone = token[1];
|
|
143588
|
-
} else {
|
|
143589
|
-
dateStrings.time = timeString;
|
|
143590
|
-
}
|
|
143591
|
-
}
|
|
143592
|
-
return dateStrings;
|
|
143593
|
-
}
|
|
143594
|
-
function parseYear(dateString, additionalDigits) {
|
|
143595
|
-
const regex = new RegExp(
|
|
143596
|
-
"^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
|
|
143597
|
-
);
|
|
143598
|
-
const captures = dateString.match(regex);
|
|
143599
|
-
if (!captures) return { year: NaN, restDateString: "" };
|
|
143600
|
-
const year = captures[1] ? parseInt(captures[1]) : null;
|
|
143601
|
-
const century = captures[2] ? parseInt(captures[2]) : null;
|
|
143602
|
-
return {
|
|
143603
|
-
year: century === null ? year : century * 100,
|
|
143604
|
-
restDateString: dateString.slice((captures[1] || captures[2]).length)
|
|
143605
|
-
};
|
|
143606
|
-
}
|
|
143607
|
-
function parseDate(dateString, year) {
|
|
143608
|
-
if (year === null) return /* @__PURE__ */ new Date(NaN);
|
|
143609
|
-
const captures = dateString.match(dateRegex);
|
|
143610
|
-
if (!captures) return /* @__PURE__ */ new Date(NaN);
|
|
143611
|
-
const isWeekDate = !!captures[4];
|
|
143612
|
-
const dayOfYear = parseDateUnit(captures[1]);
|
|
143613
|
-
const month = parseDateUnit(captures[2]) - 1;
|
|
143614
|
-
const day = parseDateUnit(captures[3]);
|
|
143615
|
-
const week = parseDateUnit(captures[4]);
|
|
143616
|
-
const dayOfWeek = parseDateUnit(captures[5]) - 1;
|
|
143617
|
-
if (isWeekDate) {
|
|
143618
|
-
if (!validateWeekDate(year, week, dayOfWeek)) {
|
|
143619
|
-
return /* @__PURE__ */ new Date(NaN);
|
|
143620
|
-
}
|
|
143621
|
-
return dayOfISOWeekYear(year, week, dayOfWeek);
|
|
143622
|
-
} else {
|
|
143623
|
-
const date5 = /* @__PURE__ */ new Date(0);
|
|
143624
|
-
if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
|
|
143625
|
-
return /* @__PURE__ */ new Date(NaN);
|
|
143626
|
-
}
|
|
143627
|
-
date5.setUTCFullYear(year, month, Math.max(dayOfYear, day));
|
|
143628
|
-
return date5;
|
|
143629
|
-
}
|
|
143630
|
-
}
|
|
143631
|
-
function parseDateUnit(value) {
|
|
143632
|
-
return value ? parseInt(value) : 1;
|
|
143633
|
-
}
|
|
143634
|
-
function parseTime(timeString) {
|
|
143635
|
-
const captures = timeString.match(timeRegex);
|
|
143636
|
-
if (!captures) return NaN;
|
|
143637
|
-
const hours = parseTimeUnit(captures[1]);
|
|
143638
|
-
const minutes = parseTimeUnit(captures[2]);
|
|
143639
|
-
const seconds = parseTimeUnit(captures[3]);
|
|
143640
|
-
if (!validateTime(hours, minutes, seconds)) {
|
|
143641
|
-
return NaN;
|
|
143642
|
-
}
|
|
143643
|
-
return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
|
|
143644
|
-
}
|
|
143645
|
-
function parseTimeUnit(value) {
|
|
143646
|
-
return value && parseFloat(value.replace(",", ".")) || 0;
|
|
143647
|
-
}
|
|
143648
|
-
function parseTimezone(timezoneString) {
|
|
143649
|
-
if (timezoneString === "Z") return 0;
|
|
143650
|
-
const captures = timezoneString.match(timezoneRegex);
|
|
143651
|
-
if (!captures) return 0;
|
|
143652
|
-
const sign = captures[1] === "+" ? -1 : 1;
|
|
143653
|
-
const hours = parseInt(captures[2]);
|
|
143654
|
-
const minutes = captures[3] && parseInt(captures[3]) || 0;
|
|
143655
|
-
if (!validateTimezone(hours, minutes)) {
|
|
143656
|
-
return NaN;
|
|
143657
|
-
}
|
|
143658
|
-
return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
|
|
143659
|
-
}
|
|
143660
|
-
function dayOfISOWeekYear(isoWeekYear, week, day) {
|
|
143661
|
-
const date5 = /* @__PURE__ */ new Date(0);
|
|
143662
|
-
date5.setUTCFullYear(isoWeekYear, 0, 4);
|
|
143663
|
-
const fourthOfJanuaryDay = date5.getUTCDay() || 7;
|
|
143664
|
-
const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
|
|
143665
|
-
date5.setUTCDate(date5.getUTCDate() + diff);
|
|
143666
|
-
return date5;
|
|
143667
|
-
}
|
|
143668
|
-
var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
143669
|
-
function isLeapYearIndex(year) {
|
|
143670
|
-
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
|
|
143671
|
-
}
|
|
143672
|
-
function validateDate(year, month, date5) {
|
|
143673
|
-
return month >= 0 && month <= 11 && date5 >= 1 && date5 <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
|
|
143674
|
-
}
|
|
143675
|
-
function validateDayOfYearDate(year, dayOfYear) {
|
|
143676
|
-
return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
|
|
143677
|
-
}
|
|
143678
|
-
function validateWeekDate(_year, week, day) {
|
|
143679
|
-
return week >= 1 && week <= 53 && day >= 0 && day <= 6;
|
|
143680
|
-
}
|
|
143681
|
-
function validateTime(hours, minutes, seconds) {
|
|
143682
|
-
if (hours === 24) {
|
|
143683
|
-
return minutes === 0 && seconds === 0;
|
|
143684
|
-
}
|
|
143685
|
-
return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
|
|
143686
|
-
}
|
|
143687
|
-
function validateTimezone(_hours, minutes) {
|
|
143688
|
-
return minutes >= 0 && minutes <= 59;
|
|
143689
|
-
}
|
|
143690
|
-
|
|
143691
|
-
// src/utils/dates.ts
|
|
143692
|
-
function parseIsoDateOrNull(value) {
|
|
143693
|
-
if (!value) return null;
|
|
143694
|
-
const parsed = parseISO(value);
|
|
143695
|
-
return isValid(parsed) ? parsed : null;
|
|
143696
|
-
}
|
|
143697
|
-
|
|
143698
143878
|
// src/utils/isScannedSnapshotStale.ts
|
|
143699
143879
|
var STALENESS_TOLERANCE_MS = 1e3;
|
|
143700
143880
|
function isScannedSnapshotStale(snapshotTimestamp, fileMtimeMs) {
|
|
@@ -143995,13 +144175,13 @@ var StreamerServer = class {
|
|
|
143995
144175
|
this.disableDb = config2.disableDb ?? false;
|
|
143996
144176
|
this.scannerPersistenceDisabled = config2.scannerPersistent === false;
|
|
143997
144177
|
this.scanProfiles = config2.scanProfiles;
|
|
143998
|
-
this.codexRoots = config2.codexRoots ?? [(0,
|
|
144178
|
+
this.codexRoots = config2.codexRoots ?? [(0, import_path29.join)((0, import_os12.homedir)(), ".codex", "sessions")];
|
|
143999
144179
|
this.ptyGracePeriodMs = config2.ptyGracePeriodMs ?? DEFAULT_PTY_GRACE_PERIOD_MS;
|
|
144000
144180
|
this.defaultSystemPrompt = config2.defaultSystemPrompt ?? DEFAULT_SYSTEM_PROMPT;
|
|
144001
144181
|
this.defaultPermissionMode = config2.defaultPermissionMode ?? loadDefaultPermissionMode() ?? "acceptEdits";
|
|
144002
144182
|
this.defaultModel = config2.defaultModel ?? "sonnet";
|
|
144003
144183
|
this.defaultEffort = config2.defaultEffort ?? "low";
|
|
144004
|
-
this.cacheDir = config2.cacheDir ?? loadCacheDir() ?? (0,
|
|
144184
|
+
this.cacheDir = config2.cacheDir ?? loadCacheDir() ?? (0, import_path29.join)((0, import_os12.homedir)(), ".threadbase", "cache");
|
|
144005
144185
|
this.tailSize = config2.tailSize ?? loadTailSize() ?? 10;
|
|
144006
144186
|
this.directoryDebounceMs = parseDirScanDebounceEnv(process.env.THREADBASE_DIR_SCAN_DEBOUNCE_MS) ?? config2.directoryScanDebounceMs ?? 1e3;
|
|
144007
144187
|
this.markScannerStaleDebounced = debounce(() => {
|
|
@@ -144042,7 +144222,7 @@ var StreamerServer = class {
|
|
|
144042
144222
|
const seqs = cache.extendMessageIndex(
|
|
144043
144223
|
filePath,
|
|
144044
144224
|
spans,
|
|
144045
|
-
(0,
|
|
144225
|
+
(0, import_fs29.statSync)(filePath),
|
|
144046
144226
|
readFrom,
|
|
144047
144227
|
endOffset
|
|
144048
144228
|
);
|
|
@@ -144208,7 +144388,7 @@ var StreamerServer = class {
|
|
|
144208
144388
|
temporalClient,
|
|
144209
144389
|
taskQueue: agentConfig.temporal.taskQueue
|
|
144210
144390
|
});
|
|
144211
|
-
const conversationsBaseDir = agentConfig.conversationsDir || (0,
|
|
144391
|
+
const conversationsBaseDir = agentConfig.conversationsDir || (0, import_path29.join)((0, import_path29.dirname)(this.cacheDir), "conversations");
|
|
144212
144392
|
conversationWriter = createConversationWriter({
|
|
144213
144393
|
baseDir: conversationsBaseDir
|
|
144214
144394
|
});
|
|
@@ -144329,7 +144509,7 @@ var StreamerServer = class {
|
|
|
144329
144509
|
}
|
|
144330
144510
|
}
|
|
144331
144511
|
if (msg.type === "hold_session" && typeof msg.sessionId === "string") {
|
|
144332
|
-
this.startGraceTimer(msg.sessionId,
|
|
144512
|
+
this.startGraceTimer(msg.sessionId, this.ptyGracePeriodMs);
|
|
144333
144513
|
}
|
|
144334
144514
|
} catch {
|
|
144335
144515
|
}
|
|
@@ -144531,7 +144711,7 @@ var StreamerServer = class {
|
|
|
144531
144711
|
});
|
|
144532
144712
|
try {
|
|
144533
144713
|
this.cache = ConversationCache.open(
|
|
144534
|
-
(0,
|
|
144714
|
+
(0, import_path29.join)(this.cacheDir, "cache.db"),
|
|
144535
144715
|
this.tailSize,
|
|
144536
144716
|
void 0,
|
|
144537
144717
|
{
|
|
@@ -144576,7 +144756,7 @@ var StreamerServer = class {
|
|
|
144576
144756
|
this.fileWatcher.watchDirectory(dir);
|
|
144577
144757
|
}
|
|
144578
144758
|
for (const dir of this.codexRoots) {
|
|
144579
|
-
if (!(0,
|
|
144759
|
+
if (!(0, import_fs29.existsSync)(dir)) continue;
|
|
144580
144760
|
this.fileWatcher.watchDirectory(dir);
|
|
144581
144761
|
}
|
|
144582
144762
|
} catch (err) {
|
|
@@ -144657,6 +144837,20 @@ var StreamerServer = class {
|
|
|
144657
144837
|
count: pruned.length,
|
|
144658
144838
|
event: "cache.prune_ghosts"
|
|
144659
144839
|
});
|
|
144840
|
+
if (this.projectsRepo && this.conversationsRepo && this.cacheMetadataRepo) {
|
|
144841
|
+
refreshConversationCache({
|
|
144842
|
+
cache: this.cache,
|
|
144843
|
+
projectsRepo: this.projectsRepo,
|
|
144844
|
+
conversationsRepo: this.conversationsRepo,
|
|
144845
|
+
cacheMetadataRepo: this.cacheMetadataRepo
|
|
144846
|
+
});
|
|
144847
|
+
} else if (this.cacheMetadataRepo) {
|
|
144848
|
+
setCacheMetadata(
|
|
144849
|
+
this.cacheMetadataRepo,
|
|
144850
|
+
"conversations_last_indexed_at",
|
|
144851
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
144852
|
+
);
|
|
144853
|
+
}
|
|
144660
144854
|
}
|
|
144661
144855
|
}).catch((err) => {
|
|
144662
144856
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -144896,6 +145090,56 @@ var StreamerServer = class {
|
|
|
144896
145090
|
checkSessionInputRateLimit(sessionId) {
|
|
144897
145091
|
return this.checkRateLimit(this.sessionInputAttempts, sessionId, 500, 6e4);
|
|
144898
145092
|
}
|
|
145093
|
+
/** Project roots watched for conversation JSONLs (profiles or ~/.claude/projects). */
|
|
145094
|
+
projectsDirsForFreshnessCheck() {
|
|
145095
|
+
if (this.scanProfiles && this.scanProfiles.length > 0) {
|
|
145096
|
+
return this.scanProfiles.filter((p2) => p2.enabled).map((p2) => (0, import_path29.join)(p2.configDir, "projects"));
|
|
145097
|
+
}
|
|
145098
|
+
return [(0, import_path29.join)((0, import_os12.homedir)(), ".claude", "projects")];
|
|
145099
|
+
}
|
|
145100
|
+
/**
|
|
145101
|
+
* Full-glob scan + cache upsert/delete reconcile. Used by ?refresh=1 and by
|
|
145102
|
+
* the automatic freshness path when the directory watcher marked the scanner
|
|
145103
|
+
* stale or shouldRefreshProjectsFromHdd detected disk drift.
|
|
145104
|
+
*/
|
|
145105
|
+
async reconcileConversationsCacheFromDisk() {
|
|
145106
|
+
if (!this.cache) return;
|
|
145107
|
+
const scanner = await this.rescanForRefresh();
|
|
145108
|
+
const metas = [...scanner.getMetadataCache().values()];
|
|
145109
|
+
try {
|
|
145110
|
+
this.cache.upsertFromScannerMeta(metas);
|
|
145111
|
+
if (!this.cacheMonitor?.pending) {
|
|
145112
|
+
this.cache.reconcileDeletions(canonicalLivePathSet(metas));
|
|
145113
|
+
}
|
|
145114
|
+
if (this.projectsRepo && this.conversationsRepo && this.cacheMetadataRepo) {
|
|
145115
|
+
refreshConversationCache({
|
|
145116
|
+
cache: this.cache,
|
|
145117
|
+
projectsRepo: this.projectsRepo,
|
|
145118
|
+
conversationsRepo: this.conversationsRepo,
|
|
145119
|
+
cacheMetadataRepo: this.cacheMetadataRepo
|
|
145120
|
+
});
|
|
145121
|
+
} else if (this.cacheMetadataRepo) {
|
|
145122
|
+
setCacheMetadata(
|
|
145123
|
+
this.cacheMetadataRepo,
|
|
145124
|
+
"conversations_last_indexed_at",
|
|
145125
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
145126
|
+
);
|
|
145127
|
+
}
|
|
145128
|
+
} catch (err) {
|
|
145129
|
+
this.log.warn(
|
|
145130
|
+
`refresh reconcile failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
145131
|
+
{ event: "conversations.reconcile_failed" }
|
|
145132
|
+
);
|
|
145133
|
+
}
|
|
145134
|
+
}
|
|
145135
|
+
shouldAutoReconcileConversationList() {
|
|
145136
|
+
if (!this.cache) return false;
|
|
145137
|
+
if (this.scannerStale) return true;
|
|
145138
|
+
if (!this.conversationsRepo || !this.cacheMetadataRepo) return false;
|
|
145139
|
+
return shouldRefreshProjectsFromHdd(this.conversationsRepo, this.cacheMetadataRepo, {
|
|
145140
|
+
projectsDirs: this.projectsDirsForFreshnessCheck()
|
|
145141
|
+
});
|
|
145142
|
+
}
|
|
144899
145143
|
async handleListConversations(url2, res) {
|
|
144900
145144
|
if (this.rejectIfWarmingUp(res)) return;
|
|
144901
145145
|
const limit = intParam(url2, "limit", 50);
|
|
@@ -144904,19 +145148,14 @@ var StreamerServer = class {
|
|
|
144904
145148
|
const project = url2.searchParams.get("project") ?? void 0;
|
|
144905
145149
|
const providerFilter = url2.searchParams.get("provider") ?? void 0;
|
|
144906
145150
|
const bustCache = url2.searchParams.get("refresh") === "1";
|
|
144907
|
-
if (
|
|
144908
|
-
|
|
144909
|
-
|
|
144910
|
-
|
|
144911
|
-
|
|
144912
|
-
if (!this.cacheMonitor?.pending) {
|
|
144913
|
-
this.cache.reconcileDeletions(canonicalLivePathSet(metas2));
|
|
144914
|
-
}
|
|
144915
|
-
} catch (err) {
|
|
144916
|
-
this.log.warn(
|
|
144917
|
-
`refresh reconcile failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
144918
|
-
{ event: "conversations.reconcile_failed" }
|
|
145151
|
+
if (this.cache && (bustCache || this.shouldAutoReconcileConversationList())) {
|
|
145152
|
+
if (bustCache) {
|
|
145153
|
+
await this.withWarmup(
|
|
145154
|
+
"conversation_refresh",
|
|
145155
|
+
() => this.reconcileConversationsCacheFromDisk()
|
|
144919
145156
|
);
|
|
145157
|
+
} else {
|
|
145158
|
+
await this.reconcileConversationsCacheFromDisk();
|
|
144920
145159
|
}
|
|
144921
145160
|
}
|
|
144922
145161
|
if (this.cache) {
|
|
@@ -145178,22 +145417,22 @@ var StreamerServer = class {
|
|
|
145178
145417
|
*/
|
|
145179
145418
|
projectsDirs() {
|
|
145180
145419
|
if (this.scanProfiles && this.scanProfiles.length > 0) {
|
|
145181
|
-
return this.scanProfiles.filter((p2) => p2.enabled).map((p2) => (0,
|
|
145420
|
+
return this.scanProfiles.filter((p2) => p2.enabled).map((p2) => (0, import_path29.join)(p2.configDir, "projects"));
|
|
145182
145421
|
}
|
|
145183
|
-
return [(0,
|
|
145422
|
+
return [(0, import_path29.join)((0, import_os12.homedir)(), ".claude", "projects")];
|
|
145184
145423
|
}
|
|
145185
145424
|
findJsonlPath(uuid3) {
|
|
145186
145425
|
const filename = `${uuid3}.jsonl`;
|
|
145187
145426
|
for (const projectsDir of this.projectsDirs()) {
|
|
145188
|
-
if (!(0,
|
|
145189
|
-
for (const dir of (0,
|
|
145190
|
-
const fp = (0,
|
|
145191
|
-
if ((0,
|
|
145192
|
-
const projectDir = (0,
|
|
145427
|
+
if (!(0, import_fs29.existsSync)(projectsDir)) continue;
|
|
145428
|
+
for (const dir of (0, import_fs29.readdirSync)(projectsDir)) {
|
|
145429
|
+
const fp = (0, import_path29.join)(projectsDir, dir, filename);
|
|
145430
|
+
if ((0, import_fs29.existsSync)(fp)) return fp;
|
|
145431
|
+
const projectDir = (0, import_path29.join)(projectsDir, dir);
|
|
145193
145432
|
try {
|
|
145194
|
-
for (const sub of (0,
|
|
145195
|
-
const subagentPath = (0,
|
|
145196
|
-
if ((0,
|
|
145433
|
+
for (const sub of (0, import_fs29.readdirSync)(projectDir)) {
|
|
145434
|
+
const subagentPath = (0, import_path29.join)(projectDir, sub, "subagents", filename);
|
|
145435
|
+
if ((0, import_fs29.existsSync)(subagentPath)) return subagentPath;
|
|
145197
145436
|
}
|
|
145198
145437
|
} catch {
|
|
145199
145438
|
}
|
|
@@ -145203,7 +145442,7 @@ var StreamerServer = class {
|
|
|
145203
145442
|
}
|
|
145204
145443
|
async readCwdFromJsonl(filePath) {
|
|
145205
145444
|
return new Promise((resolve4) => {
|
|
145206
|
-
const rl = (0, import_readline4.createInterface)({ input: (0,
|
|
145445
|
+
const rl = (0, import_readline4.createInterface)({ input: (0, import_fs29.createReadStream)(filePath), crlfDelay: Infinity });
|
|
145207
145446
|
let found = false;
|
|
145208
145447
|
rl.on("line", (line) => {
|
|
145209
145448
|
if (found) return;
|
|
@@ -145293,7 +145532,7 @@ var StreamerServer = class {
|
|
|
145293
145532
|
if (this.isManagedTailPath(key)) return;
|
|
145294
145533
|
let mtimeMs;
|
|
145295
145534
|
try {
|
|
145296
|
-
mtimeMs = (0,
|
|
145535
|
+
mtimeMs = (0, import_fs29.statSync)(filePath).mtimeMs;
|
|
145297
145536
|
} catch {
|
|
145298
145537
|
return;
|
|
145299
145538
|
}
|
|
@@ -145475,7 +145714,7 @@ var StreamerServer = class {
|
|
|
145475
145714
|
if (!conv.filePath) return false;
|
|
145476
145715
|
let mtimeMs = null;
|
|
145477
145716
|
try {
|
|
145478
|
-
mtimeMs = (0,
|
|
145717
|
+
mtimeMs = (0, import_fs29.statSync)(conv.filePath).mtimeMs;
|
|
145479
145718
|
} catch {
|
|
145480
145719
|
return false;
|
|
145481
145720
|
}
|
|
@@ -145844,13 +146083,23 @@ var StreamerServer = class {
|
|
|
145844
146083
|
throw err;
|
|
145845
146084
|
}
|
|
145846
146085
|
}
|
|
145847
|
-
handleGetSession(sessionId, res) {
|
|
146086
|
+
async handleGetSession(sessionId, res) {
|
|
145848
146087
|
if (this.rejectIfWarmingUp(res)) return;
|
|
145849
146088
|
const session = this.sessionStore.get(sessionId, this.ptyAttachedIds());
|
|
145850
146089
|
if (session) {
|
|
145851
|
-
if (!(0,
|
|
146090
|
+
if (!(0, import_fs29.existsSync)(session.projectPath)) {
|
|
145852
146091
|
session.failureReason = `Project directory not found: ${session.projectPath}`;
|
|
145853
146092
|
}
|
|
146093
|
+
if (this.ptyManager.hasSession(sessionId)) {
|
|
146094
|
+
try {
|
|
146095
|
+
const lines = await this.ptyManager.getOutputLines(sessionId, 10);
|
|
146096
|
+
const status = parseStatusLine(lines);
|
|
146097
|
+
if (session.model == null && status.model) session.model = status.model;
|
|
146098
|
+
if (status.effort) session.effort = status.effort;
|
|
146099
|
+
if (status.permissionMode) session.permissionMode = status.permissionMode;
|
|
146100
|
+
} catch {
|
|
146101
|
+
}
|
|
146102
|
+
}
|
|
145854
146103
|
json2(res, 200, session);
|
|
145855
146104
|
return;
|
|
145856
146105
|
}
|
|
@@ -146309,7 +146558,7 @@ var StreamerServer = class {
|
|
|
146309
146558
|
const jsonlCwd = jsonlPath ? await this.readCwdFromJsonl(jsonlPath) : null;
|
|
146310
146559
|
if (jsonlCwd) {
|
|
146311
146560
|
projectPath = jsonlCwd;
|
|
146312
|
-
projectName = projectName || (0,
|
|
146561
|
+
projectName = projectName || (0, import_path29.basename)(jsonlCwd);
|
|
146313
146562
|
}
|
|
146314
146563
|
}
|
|
146315
146564
|
if (!projectPath) {
|
|
@@ -146385,7 +146634,7 @@ var StreamerServer = class {
|
|
|
146385
146634
|
sessionStore: this.sessionStore,
|
|
146386
146635
|
// biome-ignore lint/style/noNonNullAssertion: agentClient is set when agentConfig.enabled is true
|
|
146387
146636
|
agentClient: this.agentClient,
|
|
146388
|
-
conversationsDir: this.cacheDir ? (0,
|
|
146637
|
+
conversationsDir: this.cacheDir ? (0, import_path29.join)((0, import_path29.dirname)(this.cacheDir), "conversations") : "",
|
|
146389
146638
|
agentConfig: this.agentConfig
|
|
146390
146639
|
});
|
|
146391
146640
|
json2(res, result.status, result.body);
|
|
@@ -146529,7 +146778,7 @@ var StreamerServer = class {
|
|
|
146529
146778
|
// file isn't slurped in full.
|
|
146530
146779
|
readFirstLineSessionId(filePath) {
|
|
146531
146780
|
try {
|
|
146532
|
-
const content = (0,
|
|
146781
|
+
const content = (0, import_fs29.readFileSync)(filePath, "utf8");
|
|
146533
146782
|
const nl = content.indexOf("\n");
|
|
146534
146783
|
const firstLine = nl === -1 ? content : content.slice(0, nl);
|
|
146535
146784
|
if (!firstLine.trim()) return null;
|
|
@@ -146544,9 +146793,9 @@ var StreamerServer = class {
|
|
|
146544
146793
|
// was passed to Claude via --session-id so the filename matches from the start.
|
|
146545
146794
|
watchForJsonl(sessionId, projectPath) {
|
|
146546
146795
|
const encoded = projectPath.replace(/[/\\:.]/g, "-");
|
|
146547
|
-
const projectsDir = (0,
|
|
146796
|
+
const projectsDir = (0, import_path29.join)((0, import_os12.homedir)(), ".claude", "projects", encoded);
|
|
146548
146797
|
const expectedFile = `${sessionId}.jsonl`;
|
|
146549
|
-
const filePath = (0,
|
|
146798
|
+
const filePath = (0, import_path29.join)(projectsDir, expectedFile);
|
|
146550
146799
|
const deadline = Date.now() + 12e4;
|
|
146551
146800
|
let watcher = null;
|
|
146552
146801
|
const cleanup = () => {
|
|
@@ -146564,14 +146813,14 @@ var StreamerServer = class {
|
|
|
146564
146813
|
cleanup();
|
|
146565
146814
|
return;
|
|
146566
146815
|
}
|
|
146567
|
-
let resolvedFilePath = (0,
|
|
146568
|
-
if (!resolvedFilePath && (0,
|
|
146816
|
+
let resolvedFilePath = (0, import_fs29.existsSync)(filePath) ? filePath : null;
|
|
146817
|
+
if (!resolvedFilePath && (0, import_fs29.existsSync)(projectsDir)) {
|
|
146569
146818
|
try {
|
|
146570
146819
|
const now = Date.now();
|
|
146571
|
-
const match2 = (0,
|
|
146572
|
-
({ f: f2 }) => (0,
|
|
146820
|
+
const match2 = (0, import_fs29.readdirSync)(projectsDir).filter((f2) => f2.endsWith(".jsonl")).map((f2) => ({ f: f2, mtime: (0, import_fs29.statSync)((0, import_path29.join)(projectsDir, f2)).mtimeMs })).filter(({ mtime }) => now - mtime < 5e3).filter(
|
|
146821
|
+
({ f: f2 }) => (0, import_path29.basename)(f2, ".jsonl") === sessionId || this.readFirstLineSessionId((0, import_path29.join)(projectsDir, f2)) === sessionId
|
|
146573
146822
|
).sort((a, b2) => b2.mtime - a.mtime)[0];
|
|
146574
|
-
if (match2) resolvedFilePath = (0,
|
|
146823
|
+
if (match2) resolvedFilePath = (0, import_path29.join)(projectsDir, match2.f);
|
|
146575
146824
|
} catch {
|
|
146576
146825
|
}
|
|
146577
146826
|
}
|
|
@@ -146579,7 +146828,7 @@ var StreamerServer = class {
|
|
|
146579
146828
|
cleanup();
|
|
146580
146829
|
this.sessionFileMap.set(sessionId, resolvedFilePath);
|
|
146581
146830
|
try {
|
|
146582
|
-
const existing = (0,
|
|
146831
|
+
const existing = (0, import_fs29.readFileSync)(resolvedFilePath, "utf8").split("\n").filter(Boolean);
|
|
146583
146832
|
if (existing.length > 0) {
|
|
146584
146833
|
this.broadcastConversationLines(sessionId, existing);
|
|
146585
146834
|
}
|
|
@@ -146603,7 +146852,7 @@ var StreamerServer = class {
|
|
|
146603
146852
|
if (this.sessionFileMap.has(sessionId)) return;
|
|
146604
146853
|
try {
|
|
146605
146854
|
require("fs").mkdirSync(projectsDir, { recursive: true });
|
|
146606
|
-
watcher = (0,
|
|
146855
|
+
watcher = (0, import_fs29.watch)(projectsDir, tryWire);
|
|
146607
146856
|
watcher.on("error", cleanup);
|
|
146608
146857
|
} catch {
|
|
146609
146858
|
}
|
|
@@ -146619,7 +146868,7 @@ var StreamerServer = class {
|
|
|
146619
146868
|
watchForCodexRollout(sessionId, projectPath) {
|
|
146620
146869
|
const deadline = Date.now() + 12e4;
|
|
146621
146870
|
const now = /* @__PURE__ */ new Date();
|
|
146622
|
-
const dateDir = (0,
|
|
146871
|
+
const dateDir = (0, import_path29.join)(
|
|
146623
146872
|
String(now.getFullYear()),
|
|
146624
146873
|
String(now.getMonth() + 1).padStart(2, "0"),
|
|
146625
146874
|
String(now.getDate()).padStart(2, "0")
|
|
@@ -146632,7 +146881,7 @@ var StreamerServer = class {
|
|
|
146632
146881
|
};
|
|
146633
146882
|
const matchesProjectPath = (candidatePath) => {
|
|
146634
146883
|
try {
|
|
146635
|
-
const firstLine = (0,
|
|
146884
|
+
const firstLine = (0, import_fs29.readFileSync)(candidatePath, "utf8").split("\n", 1)[0];
|
|
146636
146885
|
if (!firstLine) return null;
|
|
146637
146886
|
const parsed = JSON.parse(firstLine);
|
|
146638
146887
|
if (parsed?.type !== "session_meta") return null;
|
|
@@ -146660,18 +146909,18 @@ var StreamerServer = class {
|
|
|
146660
146909
|
this.sessionStore.listManaged().filter((s3) => s3.id !== sessionId && s3.boundConversationId != null).map((s3) => s3.boundConversationId)
|
|
146661
146910
|
);
|
|
146662
146911
|
for (const root of this.codexRoots) {
|
|
146663
|
-
const sessionsDir = (0,
|
|
146664
|
-
if (!(0,
|
|
146912
|
+
const sessionsDir = (0, import_path29.join)(root, dateDir);
|
|
146913
|
+
if (!(0, import_fs29.existsSync)(sessionsDir)) continue;
|
|
146665
146914
|
let candidateFiles;
|
|
146666
146915
|
try {
|
|
146667
|
-
candidateFiles = (0,
|
|
146916
|
+
candidateFiles = (0, import_fs29.readdirSync)(sessionsDir).filter((f2) => f2.endsWith(".jsonl"));
|
|
146668
146917
|
} catch {
|
|
146669
146918
|
continue;
|
|
146670
146919
|
}
|
|
146671
146920
|
const nowMs = Date.now();
|
|
146672
|
-
const recentCandidates = candidateFiles.map((f2) => ({ f: f2, mtime: (0,
|
|
146921
|
+
const recentCandidates = candidateFiles.map((f2) => ({ f: f2, mtime: (0, import_fs29.statSync)((0, import_path29.join)(sessionsDir, f2)).mtimeMs })).filter(({ mtime }) => nowMs - mtime < 1e4).sort((a, b2) => b2.mtime - a.mtime);
|
|
146673
146922
|
for (const { f: f2 } of recentCandidates) {
|
|
146674
|
-
const candidatePath = (0,
|
|
146923
|
+
const candidatePath = (0, import_path29.join)(sessionsDir, f2);
|
|
146675
146924
|
const match2 = matchesProjectPath(candidatePath);
|
|
146676
146925
|
if (!match2) continue;
|
|
146677
146926
|
if (boundElsewhere.has(match2.id)) continue;
|
|
@@ -146681,7 +146930,7 @@ var StreamerServer = class {
|
|
|
146681
146930
|
this.sessionFileMap.set(sessionId, candidatePath);
|
|
146682
146931
|
this.fileWatcher.watch(candidatePath);
|
|
146683
146932
|
try {
|
|
146684
|
-
const existing = (0,
|
|
146933
|
+
const existing = (0, import_fs29.readFileSync)(candidatePath, "utf8").split("\n").filter(Boolean);
|
|
146685
146934
|
if (existing.length > 0) {
|
|
146686
146935
|
this.broadcastConversationLines(sessionId, existing);
|
|
146687
146936
|
}
|
|
@@ -146815,7 +147064,7 @@ async function waitForProcessExit(pid, timeoutMs, pollMs = ADOPT_KILL_POLL_MS) {
|
|
|
146815
147064
|
}
|
|
146816
147065
|
function classifyResumability(cwd) {
|
|
146817
147066
|
if (!cwd) return { resumable: true };
|
|
146818
|
-
if ((0,
|
|
147067
|
+
if ((0, import_fs29.existsSync)(cwd)) return { resumable: true };
|
|
146819
147068
|
const ranInWorktree = /\/\.worktrees\//.test(cwd) || /\/\.claude\/worktrees\//.test(cwd);
|
|
146820
147069
|
return {
|
|
146821
147070
|
resumable: false,
|
|
@@ -147485,13 +147734,13 @@ var import_node_fs18 = require("fs");
|
|
|
147485
147734
|
|
|
147486
147735
|
// node_modules/tar/dist/esm/index.min.js
|
|
147487
147736
|
var import_events3 = __toESM(require("events"), 1);
|
|
147488
|
-
var
|
|
147737
|
+
var import_fs30 = __toESM(require("fs"), 1);
|
|
147489
147738
|
var import_node_events3 = require("events");
|
|
147490
147739
|
var import_node_stream2 = __toESM(require("stream"), 1);
|
|
147491
147740
|
var import_node_string_decoder = require("string_decoder");
|
|
147492
147741
|
var import_node_path14 = __toESM(require("path"), 1);
|
|
147493
147742
|
var import_node_fs12 = __toESM(require("fs"), 1);
|
|
147494
|
-
var
|
|
147743
|
+
var import_path30 = require("path");
|
|
147495
147744
|
var import_events4 = require("events");
|
|
147496
147745
|
var import_assert = __toESM(require("assert"), 1);
|
|
147497
147746
|
var import_buffer2 = require("buffer");
|
|
@@ -147499,17 +147748,17 @@ var Ps = __toESM(require("zlib"), 1);
|
|
|
147499
147748
|
var import_zlib = __toESM(require("zlib"), 1);
|
|
147500
147749
|
var import_node_path15 = require("path");
|
|
147501
147750
|
var import_node_path16 = require("path");
|
|
147502
|
-
var import_fs30 = __toESM(require("fs"), 1);
|
|
147503
147751
|
var import_fs31 = __toESM(require("fs"), 1);
|
|
147504
|
-
var
|
|
147505
|
-
var import_node_path17 = require("path");
|
|
147752
|
+
var import_fs32 = __toESM(require("fs"), 1);
|
|
147506
147753
|
var import_path31 = __toESM(require("path"), 1);
|
|
147754
|
+
var import_node_path17 = require("path");
|
|
147755
|
+
var import_path32 = __toESM(require("path"), 1);
|
|
147507
147756
|
var import_node_fs13 = __toESM(require("fs"), 1);
|
|
147508
147757
|
var import_node_assert = __toESM(require("assert"), 1);
|
|
147509
147758
|
var import_node_crypto5 = require("crypto");
|
|
147510
147759
|
var import_node_fs14 = __toESM(require("fs"), 1);
|
|
147511
147760
|
var import_node_path18 = __toESM(require("path"), 1);
|
|
147512
|
-
var
|
|
147761
|
+
var import_fs33 = __toESM(require("fs"), 1);
|
|
147513
147762
|
var import_node_fs15 = __toESM(require("fs"), 1);
|
|
147514
147763
|
var import_node_path19 = __toESM(require("path"), 1);
|
|
147515
147764
|
var import_node_fs16 = __toESM(require("fs"), 1);
|
|
@@ -147861,7 +148110,7 @@ var A = class extends import_node_events3.EventEmitter {
|
|
|
147861
148110
|
return Wr;
|
|
147862
148111
|
}
|
|
147863
148112
|
};
|
|
147864
|
-
var Jr =
|
|
148113
|
+
var Jr = import_fs30.default.writev;
|
|
147865
148114
|
var ht = /* @__PURE__ */ Symbol("_autoClose");
|
|
147866
148115
|
var H2 = /* @__PURE__ */ Symbol("_close");
|
|
147867
148116
|
var te = /* @__PURE__ */ Symbol("_ended");
|
|
@@ -147916,7 +148165,7 @@ var _t = class extends A {
|
|
|
147916
148165
|
throw new TypeError("this is a readable stream");
|
|
147917
148166
|
}
|
|
147918
148167
|
[at]() {
|
|
147919
|
-
|
|
148168
|
+
import_fs30.default.open(this[U], "r", (t, e) => this[Ht](t, e));
|
|
147920
148169
|
}
|
|
147921
148170
|
[Ht](t, e) {
|
|
147922
148171
|
t ? this[Ut](t) : (this[u] = e, this.emit("open", e), this[zt]());
|
|
@@ -147929,7 +148178,7 @@ var _t = class extends A {
|
|
|
147929
148178
|
this[j] = true;
|
|
147930
148179
|
let t = this[vi]();
|
|
147931
148180
|
if (t.length === 0) return process.nextTick(() => this[Ii](null, 0, t));
|
|
147932
|
-
|
|
148181
|
+
import_fs30.default.read(this[u], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
|
|
147933
148182
|
}
|
|
147934
148183
|
}
|
|
147935
148184
|
[Ii](t, e, i) {
|
|
@@ -147938,7 +148187,7 @@ var _t = class extends A {
|
|
|
147938
148187
|
[H2]() {
|
|
147939
148188
|
if (this[ht] && typeof this[u] == "number") {
|
|
147940
148189
|
let t = this[u];
|
|
147941
|
-
this[u] = void 0,
|
|
148190
|
+
this[u] = void 0, import_fs30.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
147942
148191
|
}
|
|
147943
148192
|
}
|
|
147944
148193
|
[Ut](t) {
|
|
@@ -147966,7 +148215,7 @@ var Be = class extends _t {
|
|
|
147966
148215
|
[at]() {
|
|
147967
148216
|
let t = true;
|
|
147968
148217
|
try {
|
|
147969
|
-
this[Ht](null,
|
|
148218
|
+
this[Ht](null, import_fs30.default.openSync(this[U], "r")), t = false;
|
|
147970
148219
|
} finally {
|
|
147971
148220
|
t && this[H2]();
|
|
147972
148221
|
}
|
|
@@ -147977,7 +148226,7 @@ var Be = class extends _t {
|
|
|
147977
148226
|
if (!this[j]) {
|
|
147978
148227
|
this[j] = true;
|
|
147979
148228
|
do {
|
|
147980
|
-
let e = this[vi](), i = e.length === 0 ? 0 :
|
|
148229
|
+
let e = this[vi](), i = e.length === 0 ? 0 : import_fs30.default.readSync(this[u], e, 0, e.length, null);
|
|
147981
148230
|
if (!this[ki](i, e)) break;
|
|
147982
148231
|
} while (true);
|
|
147983
148232
|
this[j] = false;
|
|
@@ -147990,7 +148239,7 @@ var Be = class extends _t {
|
|
|
147990
148239
|
[H2]() {
|
|
147991
148240
|
if (this[ht] && typeof this[u] == "number") {
|
|
147992
148241
|
let t = this[u];
|
|
147993
|
-
this[u] = void 0,
|
|
148242
|
+
this[u] = void 0, import_fs30.default.closeSync(t), this.emit("close");
|
|
147994
148243
|
}
|
|
147995
148244
|
}
|
|
147996
148245
|
};
|
|
@@ -148032,7 +148281,7 @@ var et = class extends import_events3.default {
|
|
|
148032
148281
|
this[H2](), this[gt] = true, this.emit("error", t);
|
|
148033
148282
|
}
|
|
148034
148283
|
[at]() {
|
|
148035
|
-
|
|
148284
|
+
import_fs30.default.open(this[U], this[tt], this[ie], (t, e) => this[Ht](t, e));
|
|
148036
148285
|
}
|
|
148037
148286
|
[Ht](t, e) {
|
|
148038
148287
|
this[Me] && this[tt] === "r+" && t && t.code === "ENOENT" ? (this[tt] = "w", this[at]()) : t ? this[Ut](t) : (this[u] = e, this.emit("open", e), this[gt] || this[Ai]());
|
|
@@ -148044,7 +148293,7 @@ var et = class extends import_events3.default {
|
|
|
148044
148293
|
return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", new Error("write() after end()")), false) : this[u] === void 0 || this[gt] || this[Y2].length ? (this[Y2].push(t), this[ke] = true, false) : (this[gt] = true, this[ve](t), true);
|
|
148045
148294
|
}
|
|
148046
148295
|
[ve](t) {
|
|
148047
|
-
|
|
148296
|
+
import_fs30.default.write(this[u], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
|
|
148048
148297
|
}
|
|
148049
148298
|
[Pt](t, e) {
|
|
148050
148299
|
t ? this[Ut](t) : (this[ot] !== void 0 && typeof e == "number" && (this[ot] += e), this[Y2].length ? this[Ai]() : (this[gt] = false, this[te] && !this[Ni] ? (this[Ni] = true, this[H2](), this.emit("finish")) : this[ke] && (this[ke] = false, this.emit("drain"))));
|
|
@@ -148060,7 +148309,7 @@ var et = class extends import_events3.default {
|
|
|
148060
148309
|
[H2]() {
|
|
148061
148310
|
if (this[ht] && typeof this[u] == "number") {
|
|
148062
148311
|
let t = this[u];
|
|
148063
|
-
this[u] = void 0,
|
|
148312
|
+
this[u] = void 0, import_fs30.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
148064
148313
|
}
|
|
148065
148314
|
}
|
|
148066
148315
|
};
|
|
@@ -148068,24 +148317,24 @@ var Wt = class extends et {
|
|
|
148068
148317
|
[at]() {
|
|
148069
148318
|
let t;
|
|
148070
148319
|
if (this[Me] && this[tt] === "r+") try {
|
|
148071
|
-
t =
|
|
148320
|
+
t = import_fs30.default.openSync(this[U], this[tt], this[ie]);
|
|
148072
148321
|
} catch (e) {
|
|
148073
148322
|
if (e?.code === "ENOENT") return this[tt] = "w", this[at]();
|
|
148074
148323
|
throw e;
|
|
148075
148324
|
}
|
|
148076
|
-
else t =
|
|
148325
|
+
else t = import_fs30.default.openSync(this[U], this[tt], this[ie]);
|
|
148077
148326
|
this[Ht](null, t);
|
|
148078
148327
|
}
|
|
148079
148328
|
[H2]() {
|
|
148080
148329
|
if (this[ht] && typeof this[u] == "number") {
|
|
148081
148330
|
let t = this[u];
|
|
148082
|
-
this[u] = void 0,
|
|
148331
|
+
this[u] = void 0, import_fs30.default.closeSync(t), this.emit("close");
|
|
148083
148332
|
}
|
|
148084
148333
|
}
|
|
148085
148334
|
[ve](t) {
|
|
148086
148335
|
let e = true;
|
|
148087
148336
|
try {
|
|
148088
|
-
this[Pt](null,
|
|
148337
|
+
this[Pt](null, import_fs30.default.writeSync(this[u], t, 0, t.length, this[ot])), e = false;
|
|
148089
148338
|
} finally {
|
|
148090
148339
|
if (e) try {
|
|
148091
148340
|
this[H2]();
|
|
@@ -148868,11 +149117,11 @@ var vn = (s3) => {
|
|
|
148868
149117
|
};
|
|
148869
149118
|
var Qi = (s3, t) => {
|
|
148870
149119
|
let e = new Map(t.map((n) => [ut(n), true])), i = s3.filter, r = (n, o = "") => {
|
|
148871
|
-
let h = o || (0,
|
|
149120
|
+
let h = o || (0, import_path30.parse)(n).root || ".", a;
|
|
148872
149121
|
if (n === h) a = false;
|
|
148873
149122
|
else {
|
|
148874
149123
|
let l = e.get(n);
|
|
148875
|
-
a = l !== void 0 ? l : r((0,
|
|
149124
|
+
a = l !== void 0 ? l : r((0, import_path30.dirname)(n), h);
|
|
148876
149125
|
}
|
|
148877
149126
|
return e.set(n, a), a;
|
|
148878
149127
|
};
|
|
@@ -148992,7 +149241,7 @@ var de = class extends A {
|
|
|
148992
149241
|
let [o, h] = ce(this.path);
|
|
148993
149242
|
o && typeof h == "string" && (this.path = h, r = o);
|
|
148994
149243
|
}
|
|
148995
|
-
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute ||
|
|
149244
|
+
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t = t.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || import_path31.default.resolve(this.cwd, t)), this.path === "" && (this.path = "./"), r && this.warn("TAR_ENTRY_INFO", `stripping ${r} from absolute path`, { entry: this, path: r + this.path });
|
|
148996
149245
|
let n = this.statCache.get(this.absolute);
|
|
148997
149246
|
n ? this[si](n) : this[ss]();
|
|
148998
149247
|
}
|
|
@@ -149003,7 +149252,7 @@ var de = class extends A {
|
|
|
149003
149252
|
return t === "error" && (this.#t = true), super.emit(t, ...e);
|
|
149004
149253
|
}
|
|
149005
149254
|
[ss]() {
|
|
149006
|
-
|
|
149255
|
+
import_fs32.default.lstat(this.absolute, (t, e) => {
|
|
149007
149256
|
if (t) return this.emit("error", t);
|
|
149008
149257
|
this[si](e);
|
|
149009
149258
|
});
|
|
@@ -149041,7 +149290,7 @@ var de = class extends A {
|
|
|
149041
149290
|
this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
|
|
149042
149291
|
}
|
|
149043
149292
|
[is]() {
|
|
149044
|
-
|
|
149293
|
+
import_fs32.default.readlink(this.absolute, (t, e) => {
|
|
149045
149294
|
if (t) return this.emit("error", t);
|
|
149046
149295
|
this[ns](e);
|
|
149047
149296
|
});
|
|
@@ -149051,7 +149300,7 @@ var de = class extends A {
|
|
|
149051
149300
|
}
|
|
149052
149301
|
[sr](t) {
|
|
149053
149302
|
if (!this.stat) throw new Error("cannot create link entry without stat");
|
|
149054
|
-
this.type = "Link", this.linkpath = f(
|
|
149303
|
+
this.type = "Link", this.linkpath = f(import_path31.default.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
|
|
149055
149304
|
}
|
|
149056
149305
|
[er]() {
|
|
149057
149306
|
if (!this.stat) throw new Error("cannot create file entry without stat");
|
|
@@ -149064,7 +149313,7 @@ var de = class extends A {
|
|
|
149064
149313
|
this[os]();
|
|
149065
149314
|
}
|
|
149066
149315
|
[os]() {
|
|
149067
|
-
|
|
149316
|
+
import_fs32.default.open(this.absolute, "r", (t, e) => {
|
|
149068
149317
|
if (t) return this.emit("error", t);
|
|
149069
149318
|
this[hs](e);
|
|
149070
149319
|
});
|
|
@@ -149079,14 +149328,14 @@ var de = class extends A {
|
|
|
149079
149328
|
[ii]() {
|
|
149080
149329
|
let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
|
|
149081
149330
|
if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
|
|
149082
|
-
|
|
149331
|
+
import_fs32.default.read(t, e, i, r, n, (o, h) => {
|
|
149083
149332
|
if (o) return this[pt](() => this.emit("error", o));
|
|
149084
149333
|
this[rs](h);
|
|
149085
149334
|
});
|
|
149086
149335
|
}
|
|
149087
149336
|
[pt](t = () => {
|
|
149088
149337
|
}) {
|
|
149089
|
-
this.fd !== void 0 &&
|
|
149338
|
+
this.fd !== void 0 && import_fs32.default.close(this.fd, t);
|
|
149090
149339
|
}
|
|
149091
149340
|
[rs](t) {
|
|
149092
149341
|
if (t <= 0 && this.remain > 0) {
|
|
@@ -149121,20 +149370,20 @@ var de = class extends A {
|
|
|
149121
149370
|
var ni = class extends de {
|
|
149122
149371
|
sync = true;
|
|
149123
149372
|
[ss]() {
|
|
149124
|
-
this[si](
|
|
149373
|
+
this[si](import_fs32.default.lstatSync(this.absolute));
|
|
149125
149374
|
}
|
|
149126
149375
|
[is]() {
|
|
149127
|
-
this[ns](
|
|
149376
|
+
this[ns](import_fs32.default.readlinkSync(this.absolute));
|
|
149128
149377
|
}
|
|
149129
149378
|
[os]() {
|
|
149130
|
-
this[hs](
|
|
149379
|
+
this[hs](import_fs32.default.openSync(this.absolute, "r"));
|
|
149131
149380
|
}
|
|
149132
149381
|
[ii]() {
|
|
149133
149382
|
let t = true;
|
|
149134
149383
|
try {
|
|
149135
149384
|
let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
|
|
149136
149385
|
if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
|
|
149137
|
-
let h =
|
|
149386
|
+
let h = import_fs32.default.readSync(e, i, r, n, o);
|
|
149138
149387
|
this[rs](h), t = false;
|
|
149139
149388
|
} finally {
|
|
149140
149389
|
if (t) try {
|
|
@@ -149149,7 +149398,7 @@ var ni = class extends de {
|
|
|
149149
149398
|
}
|
|
149150
149399
|
[pt](t = () => {
|
|
149151
149400
|
}) {
|
|
149152
|
-
this.fd !== void 0 &&
|
|
149401
|
+
this.fd !== void 0 && import_fs32.default.closeSync(this.fd), t();
|
|
149153
149402
|
}
|
|
149154
149403
|
};
|
|
149155
149404
|
var oi = class extends A {
|
|
@@ -149465,7 +149714,7 @@ var wt = class extends A {
|
|
|
149465
149714
|
return typeof t == "string" ? this[ci](t) : this[or](t), this.flowing;
|
|
149466
149715
|
}
|
|
149467
149716
|
[or](t) {
|
|
149468
|
-
let e = f(
|
|
149717
|
+
let e = f(import_path32.default.resolve(this.cwd, t.path));
|
|
149469
149718
|
if (!this.filter(t.path, t)) t.resume();
|
|
149470
149719
|
else {
|
|
149471
149720
|
let i = new pi(t.path, e);
|
|
@@ -149474,13 +149723,13 @@ var wt = class extends A {
|
|
|
149474
149723
|
this[Ft]();
|
|
149475
149724
|
}
|
|
149476
149725
|
[ci](t) {
|
|
149477
|
-
let e = f(
|
|
149726
|
+
let e = f(import_path32.default.resolve(this.cwd, t));
|
|
149478
149727
|
this[W2].push(new pi(t, e)), this[Ft]();
|
|
149479
149728
|
}
|
|
149480
149729
|
[ds](t) {
|
|
149481
149730
|
t.pending = true, this[G] += 1;
|
|
149482
149731
|
let e = this.follow ? "stat" : "lstat";
|
|
149483
|
-
|
|
149732
|
+
import_fs31.default[e](t.absolute, (i, r) => {
|
|
149484
149733
|
t.pending = false, this[G] -= 1, i ? this.emit("error", i) : this[li](t, r);
|
|
149485
149734
|
});
|
|
149486
149735
|
}
|
|
@@ -149494,7 +149743,7 @@ var wt = class extends A {
|
|
|
149494
149743
|
this[Ft]();
|
|
149495
149744
|
}
|
|
149496
149745
|
[ms](t) {
|
|
149497
|
-
t.pending = true, this[G] += 1,
|
|
149746
|
+
t.pending = true, this[G] += 1, import_fs31.default.readdir(t.absolute, (e, i) => {
|
|
149498
149747
|
if (t.pending = false, this[G] -= 1, e) return this.emit("error", e);
|
|
149499
149748
|
this[fi](t, i);
|
|
149500
149749
|
});
|
|
@@ -149595,10 +149844,10 @@ var kt = class extends wt {
|
|
|
149595
149844
|
}
|
|
149596
149845
|
[ds](t) {
|
|
149597
149846
|
let e = this.follow ? "statSync" : "lstatSync";
|
|
149598
|
-
this[li](t,
|
|
149847
|
+
this[li](t, import_fs31.default[e](t.absolute));
|
|
149599
149848
|
}
|
|
149600
149849
|
[ms](t) {
|
|
149601
|
-
this[fi](t,
|
|
149850
|
+
this[fi](t, import_fs31.default.readdirSync(t.absolute));
|
|
149602
149851
|
}
|
|
149603
149852
|
[di](t) {
|
|
149604
149853
|
let e = t.entry, i = this.zip;
|
|
@@ -149649,8 +149898,8 @@ var Qn = K(Vn, $n, Xn, qn, (s3, t) => {
|
|
|
149649
149898
|
});
|
|
149650
149899
|
var Jn = process.env.__FAKE_PLATFORM__ || process.platform;
|
|
149651
149900
|
var Er = Jn === "win32";
|
|
149652
|
-
var { O_CREAT: wr, O_NOFOLLOW: mr, O_TRUNC: Sr, O_WRONLY: yr } =
|
|
149653
|
-
var Rr = Number(process.env.__FAKE_FS_O_FILENAME__) ||
|
|
149901
|
+
var { O_CREAT: wr, O_NOFOLLOW: mr, O_TRUNC: Sr, O_WRONLY: yr } = import_fs33.default.constants;
|
|
149902
|
+
var Rr = Number(process.env.__FAKE_FS_O_FILENAME__) || import_fs33.default.constants.UV_FS_O_FILEMAP || 0;
|
|
149654
149903
|
var jn = Er && !!Rr;
|
|
149655
149904
|
var to = 512 * 1024;
|
|
149656
149905
|
var eo = Rr | Sr | wr | yr;
|
|
@@ -150990,8 +151239,8 @@ program2.command("cache").description("Manage the local SQLite conversation cach
|
|
|
150990
151239
|
`${process.env.HOME}/.threadbase/cache`
|
|
150991
151240
|
).action((opts) => {
|
|
150992
151241
|
const { rmSync: rmSync6, existsSync: existsSync15 } = require("fs");
|
|
150993
|
-
const { join:
|
|
150994
|
-
const dbPath =
|
|
151242
|
+
const { join: join29 } = require("path");
|
|
151243
|
+
const dbPath = join29(opts.cacheDir, "cache.db");
|
|
150995
151244
|
for (const suffix of ["", "-shm", "-wal"]) {
|
|
150996
151245
|
const f2 = dbPath + suffix;
|
|
150997
151246
|
if (existsSync15(f2)) {
|