@threadbase-sh/streamer 1.29.2 → 1.30.0
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 +801 -426
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +579 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +562 -178
- 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: EventEmitter6 } = require("events");
|
|
26160
26160
|
var { Worker } = require("worker_threads");
|
|
26161
|
-
var { join:
|
|
26161
|
+
var { join: join28 } = 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"] || join28(__dirname, "lib", "worker.js");
|
|
26213
26213
|
const worker = new Worker(toExecute, {
|
|
26214
26214
|
...opts.workerOpts,
|
|
26215
26215
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -26675,9 +26675,9 @@ var require_transport = __commonJS({
|
|
|
26675
26675
|
"node_modules/pino/lib/transport.js"(exports2, module2) {
|
|
26676
26676
|
"use strict";
|
|
26677
26677
|
var { createRequire } = require("module");
|
|
26678
|
-
var { existsSync:
|
|
26678
|
+
var { existsSync: existsSync13 } = require("fs");
|
|
26679
26679
|
var getCallers = require_caller();
|
|
26680
|
-
var { join:
|
|
26680
|
+
var { join: join28, isAbsolute: isAbsolute3, sep: sep2 } = 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();
|
|
@@ -26749,7 +26749,7 @@ var require_transport = __commonJS({
|
|
|
26749
26749
|
return false;
|
|
26750
26750
|
}
|
|
26751
26751
|
}
|
|
26752
|
-
return isAbsolute3(path2) && !
|
|
26752
|
+
return isAbsolute3(path2) && !existsSync13(path2);
|
|
26753
26753
|
}
|
|
26754
26754
|
function stripQuotes(value) {
|
|
26755
26755
|
const first = value[0];
|
|
@@ -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"] || join28(__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"] || join28(__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 join28(__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 join28 = ",";
|
|
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
|
+
join28 = `,
|
|
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 += join28;
|
|
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 += `${join28}"... ${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
|
+
join28 = `,
|
|
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 = join28;
|
|
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 = join28;
|
|
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 join28 = ",";
|
|
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
|
+
join28 = `,
|
|
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 += join28;
|
|
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 += `${join28}"... ${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
|
+
join28 = `,
|
|
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 = join28;
|
|
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 join29 = `,
|
|
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 += join29;
|
|
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 += `${join29}"... ${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 join28 = `,
|
|
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, join28, maximumBreadth);
|
|
28108
28108
|
keys = keys.slice(value.length);
|
|
28109
28109
|
maximumPropertiesToStringify -= value.length;
|
|
28110
|
-
separator =
|
|
28110
|
+
separator = join28;
|
|
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 = join28;
|
|
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 = join28;
|
|
28128
28128
|
}
|
|
28129
28129
|
if (separator !== "") {
|
|
28130
28130
|
res = `
|
|
@@ -35847,17 +35847,17 @@ var require_logger = __commonJS({
|
|
|
35847
35847
|
* Some optimizations are performed to avoid creating unnecessary objects and to keep runtime
|
|
35848
35848
|
* overhead associated with resolving metadata as low as possible.
|
|
35849
35849
|
*/
|
|
35850
|
-
static compose(
|
|
35851
|
-
if (
|
|
35852
|
-
const contributors = appendToChain(
|
|
35850
|
+
static compose(logger3, metaOrFunc) {
|
|
35851
|
+
if (logger3 instanceof _LoggerWithComposedMetadata) {
|
|
35852
|
+
const contributors = appendToChain(logger3.contributors, metaOrFunc);
|
|
35853
35853
|
if (contributors === void 0)
|
|
35854
|
-
return
|
|
35855
|
-
return new _LoggerWithComposedMetadata(
|
|
35854
|
+
return logger3;
|
|
35855
|
+
return new _LoggerWithComposedMetadata(logger3.parentLogger, contributors);
|
|
35856
35856
|
} else {
|
|
35857
35857
|
const contributors = appendToChain(void 0, metaOrFunc);
|
|
35858
35858
|
if (contributors === void 0)
|
|
35859
|
-
return
|
|
35860
|
-
return new _LoggerWithComposedMetadata(
|
|
35859
|
+
return logger3;
|
|
35860
|
+
return new _LoggerWithComposedMetadata(logger3, contributors);
|
|
35861
35861
|
}
|
|
35862
35862
|
}
|
|
35863
35863
|
constructor(parentLogger, contributors) {
|
|
@@ -36938,8 +36938,8 @@ var require_logging = __commonJS({
|
|
|
36938
36938
|
return _logger;
|
|
36939
36939
|
};
|
|
36940
36940
|
exports2.getLogger = getLogger3;
|
|
36941
|
-
var setLogger = (
|
|
36942
|
-
_logger =
|
|
36941
|
+
var setLogger = (logger3) => {
|
|
36942
|
+
_logger = logger3;
|
|
36943
36943
|
};
|
|
36944
36944
|
exports2.setLogger = setLogger;
|
|
36945
36945
|
var setLoggerVerbosity = (verbosity) => {
|
|
@@ -60048,8 +60048,8 @@ var require_src3 = __commonJS({
|
|
|
60048
60048
|
throw new Error("Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead");
|
|
60049
60049
|
};
|
|
60050
60050
|
exports2.load = load;
|
|
60051
|
-
var setLogger = (
|
|
60052
|
-
logging.setLogger(
|
|
60051
|
+
var setLogger = (logger3) => {
|
|
60052
|
+
logging.setLogger(logger3);
|
|
60053
60053
|
};
|
|
60054
60054
|
exports2.setLogger = setLogger;
|
|
60055
60055
|
var setLogVerbosity = (verbosity) => {
|
|
@@ -100406,11 +100406,11 @@ var require_out = __commonJS({
|
|
|
100406
100406
|
async.read(path2, getSettings(optionsOrSettingsOrCallback), callback);
|
|
100407
100407
|
}
|
|
100408
100408
|
exports2.stat = stat10;
|
|
100409
|
-
function
|
|
100409
|
+
function statSync11(path2, optionsOrSettings) {
|
|
100410
100410
|
const settings = getSettings(optionsOrSettings);
|
|
100411
100411
|
return sync.read(path2, settings);
|
|
100412
100412
|
}
|
|
100413
|
-
exports2.statSync =
|
|
100413
|
+
exports2.statSync = statSync11;
|
|
100414
100414
|
function getSettings(settingsOrOptions = {}) {
|
|
100415
100415
|
if (settingsOrOptions instanceof settings_1.default) {
|
|
100416
100416
|
return settingsOrOptions;
|
|
@@ -123538,8 +123538,8 @@ function darwinPlistPath() {
|
|
|
123538
123538
|
return `${process.env.HOME}/Library/LaunchAgents/${resolveLoadedLabel()}.plist`;
|
|
123539
123539
|
}
|
|
123540
123540
|
function getLogPaths() {
|
|
123541
|
-
const dir = (0,
|
|
123542
|
-
return { stdout: (0,
|
|
123541
|
+
const dir = (0, import_node_path25.join)(installDir(), "logs");
|
|
123542
|
+
return { stdout: (0, import_node_path25.join)(dir, "stdout.log"), stderr: (0, import_node_path25.join)(dir, "stderr.log") };
|
|
123543
123543
|
}
|
|
123544
123544
|
function getAgentPid() {
|
|
123545
123545
|
try {
|
|
@@ -123559,12 +123559,12 @@ function getAgentPid() {
|
|
|
123559
123559
|
return null;
|
|
123560
123560
|
}
|
|
123561
123561
|
}
|
|
123562
|
-
var import_node_child_process4,
|
|
123562
|
+
var import_node_child_process4, import_node_path25, BREW_LAUNCHD_LABEL2;
|
|
123563
123563
|
var init_launchd = __esm({
|
|
123564
123564
|
"src/lifecycle/launchd.ts"() {
|
|
123565
123565
|
"use strict";
|
|
123566
123566
|
import_node_child_process4 = require("child_process");
|
|
123567
|
-
|
|
123567
|
+
import_node_path25 = require("path");
|
|
123568
123568
|
init_constants();
|
|
123569
123569
|
BREW_LAUNCHD_LABEL2 = "homebrew.mxcl.tb-streamer";
|
|
123570
123570
|
}
|
|
@@ -123589,9 +123589,9 @@ var init_marker_schema = __esm({
|
|
|
123589
123589
|
|
|
123590
123590
|
// src/lifecycle/marker.ts
|
|
123591
123591
|
function readMarker() {
|
|
123592
|
-
if (!(0,
|
|
123592
|
+
if (!(0, import_node_fs21.existsSync)(markerPath())) return null;
|
|
123593
123593
|
try {
|
|
123594
|
-
const raw2 = (0,
|
|
123594
|
+
const raw2 = (0, import_node_fs21.readFileSync)(markerPath(), "utf8");
|
|
123595
123595
|
const parsed = JSON.parse(raw2);
|
|
123596
123596
|
return MarkerSchema.parse(parsed);
|
|
123597
123597
|
} catch (err) {
|
|
@@ -123603,21 +123603,21 @@ function readMarker() {
|
|
|
123603
123603
|
}
|
|
123604
123604
|
function writeMarker(marker) {
|
|
123605
123605
|
MarkerSchema.parse(marker);
|
|
123606
|
-
(0,
|
|
123606
|
+
(0, import_node_fs21.mkdirSync)((0, import_node_path26.dirname)(markerPath()), { recursive: true });
|
|
123607
123607
|
const tmp = `${markerPath()}.tmp`;
|
|
123608
|
-
(0,
|
|
123608
|
+
(0, import_node_fs21.writeFileSync)(tmp, `${JSON.stringify(marker, null, 2)}
|
|
123609
123609
|
`, { mode: 384 });
|
|
123610
|
-
(0,
|
|
123610
|
+
(0, import_node_fs21.renameSync)(tmp, markerPath());
|
|
123611
123611
|
}
|
|
123612
123612
|
function clearMarker() {
|
|
123613
|
-
if ((0,
|
|
123613
|
+
if ((0, import_node_fs21.existsSync)(markerPath())) (0, import_node_fs21.rmSync)(markerPath());
|
|
123614
123614
|
}
|
|
123615
|
-
var
|
|
123615
|
+
var import_node_fs21, import_node_path26, log3;
|
|
123616
123616
|
var init_marker = __esm({
|
|
123617
123617
|
"src/lifecycle/marker.ts"() {
|
|
123618
123618
|
"use strict";
|
|
123619
|
-
|
|
123620
|
-
|
|
123619
|
+
import_node_fs21 = require("fs");
|
|
123620
|
+
import_node_path26 = require("path");
|
|
123621
123621
|
init_logger();
|
|
123622
123622
|
init_constants();
|
|
123623
123623
|
init_marker_schema();
|
|
@@ -123818,9 +123818,9 @@ The supervised prod streamer is already holding port ${prodPort}.
|
|
|
123818
123818
|
// src/lifecycle/prefs.ts
|
|
123819
123819
|
function readPrefs() {
|
|
123820
123820
|
const path2 = prefsPath();
|
|
123821
|
-
if (!(0,
|
|
123821
|
+
if (!(0, import_node_fs23.existsSync)(path2)) return { repos: {} };
|
|
123822
123822
|
try {
|
|
123823
|
-
return PrefsSchema.parse(JSON.parse((0,
|
|
123823
|
+
return PrefsSchema.parse(JSON.parse((0, import_node_fs23.readFileSync)(path2, "utf8")));
|
|
123824
123824
|
} catch (err) {
|
|
123825
123825
|
log5.warn(`prefs at ${path2} are malformed; treating as empty`, {
|
|
123826
123826
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -123830,11 +123830,11 @@ function readPrefs() {
|
|
|
123830
123830
|
}
|
|
123831
123831
|
function savePrefs(p2) {
|
|
123832
123832
|
const path2 = prefsPath();
|
|
123833
|
-
(0,
|
|
123833
|
+
(0, import_node_fs23.mkdirSync)((0, import_node_path27.dirname)(path2), { recursive: true });
|
|
123834
123834
|
const tmp = `${path2}.tmp`;
|
|
123835
|
-
(0,
|
|
123835
|
+
(0, import_node_fs23.writeFileSync)(tmp, `${JSON.stringify(p2, null, 2)}
|
|
123836
123836
|
`, { mode: 384 });
|
|
123837
|
-
(0,
|
|
123837
|
+
(0, import_node_fs23.renameSync)(tmp, path2);
|
|
123838
123838
|
}
|
|
123839
123839
|
function writePrefForRepo(repoToplevel, choice) {
|
|
123840
123840
|
const p2 = readPrefs();
|
|
@@ -123855,14 +123855,14 @@ function forgetRepo(repoToplevel) {
|
|
|
123855
123855
|
}
|
|
123856
123856
|
function forgetAll() {
|
|
123857
123857
|
const path2 = prefsPath();
|
|
123858
|
-
if ((0,
|
|
123858
|
+
if ((0, import_node_fs23.existsSync)(path2)) (0, import_node_fs23.rmSync)(path2);
|
|
123859
123859
|
}
|
|
123860
|
-
var
|
|
123860
|
+
var import_node_fs23, import_node_path27, log5, PrefsSchema;
|
|
123861
123861
|
var init_prefs = __esm({
|
|
123862
123862
|
"src/lifecycle/prefs.ts"() {
|
|
123863
123863
|
"use strict";
|
|
123864
|
-
|
|
123865
|
-
|
|
123864
|
+
import_node_fs23 = require("fs");
|
|
123865
|
+
import_node_path27 = require("path");
|
|
123866
123866
|
init_zod();
|
|
123867
123867
|
init_logger();
|
|
123868
123868
|
init_constants();
|
|
@@ -130754,9 +130754,9 @@ var NodeFsHandler = class {
|
|
|
130754
130754
|
if (this.fsw.closed) {
|
|
130755
130755
|
return;
|
|
130756
130756
|
}
|
|
130757
|
-
const
|
|
130757
|
+
const dirname18 = sysPath.dirname(file2);
|
|
130758
130758
|
const basename12 = sysPath.basename(file2);
|
|
130759
|
-
const parent = this.fsw._getWatchedDir(
|
|
130759
|
+
const parent = this.fsw._getWatchedDir(dirname18);
|
|
130760
130760
|
let prevStats = stats;
|
|
130761
130761
|
if (parent.has(basename12))
|
|
130762
130762
|
return;
|
|
@@ -130783,7 +130783,7 @@ var NodeFsHandler = class {
|
|
|
130783
130783
|
prevStats = newStats2;
|
|
130784
130784
|
}
|
|
130785
130785
|
} catch (error51) {
|
|
130786
|
-
this.fsw._remove(
|
|
130786
|
+
this.fsw._remove(dirname18, basename12);
|
|
130787
130787
|
}
|
|
130788
130788
|
} else if (parent.has(basename12)) {
|
|
130789
130789
|
const at2 = newStats.atimeMs;
|
|
@@ -134993,11 +134993,11 @@ async function search(query, options, scanner) {
|
|
|
134993
134993
|
|
|
134994
134994
|
// src/server.ts
|
|
134995
134995
|
var import_events3 = require("events");
|
|
134996
|
-
var
|
|
134996
|
+
var import_fs26 = require("fs");
|
|
134997
134997
|
var import_promises19 = require("fs/promises");
|
|
134998
134998
|
var import_http = require("http");
|
|
134999
|
-
var
|
|
135000
|
-
var
|
|
134999
|
+
var import_os11 = require("os");
|
|
135000
|
+
var import_path23 = require("path");
|
|
135001
135001
|
var import_readline4 = require("readline");
|
|
135002
135002
|
|
|
135003
135003
|
// src/agent/agent-client.ts
|
|
@@ -137481,6 +137481,7 @@ function isLocalRequest(remoteAddr) {
|
|
|
137481
137481
|
return addr === "127.0.0.1" || addr === "::1" || addr === "::ffff:127.0.0.1";
|
|
137482
137482
|
}
|
|
137483
137483
|
var PUBLIC_PATHS = /* @__PURE__ */ new Set(["/healthz", "/ws"]);
|
|
137484
|
+
var LOCAL_ONLY_PATHS = /* @__PURE__ */ new Set(["/api/logs", "/api/logs/meta"]);
|
|
137484
137485
|
var PUBLIC_POST_PATHS = /* @__PURE__ */ new Set(["/api/pair/exchange", "/api/__update"]);
|
|
137485
137486
|
var PUBLIC_POST_PREFIXES = ["/internal/sessions/"];
|
|
137486
137487
|
var authMiddleware = (deps) => async (c, next) => {
|
|
@@ -137491,8 +137492,12 @@ var authMiddleware = (deps) => async (c, next) => {
|
|
|
137491
137492
|
await next();
|
|
137492
137493
|
return;
|
|
137493
137494
|
}
|
|
137495
|
+
const remoteAddr = c.env.incoming?.socket?.remoteAddress;
|
|
137496
|
+
if (LOCAL_ONLY_PATHS.has(path2) && isLocalRequest(remoteAddr)) {
|
|
137497
|
+
await next();
|
|
137498
|
+
return;
|
|
137499
|
+
}
|
|
137494
137500
|
if (deps.localNoAuth) {
|
|
137495
|
-
const remoteAddr = c.env.incoming?.socket?.remoteAddress;
|
|
137496
137501
|
if (isLocalRequest(remoteAddr)) {
|
|
137497
137502
|
await next();
|
|
137498
137503
|
return;
|
|
@@ -137659,6 +137664,126 @@ var createHealthRoutes = () => {
|
|
|
137659
137664
|
return app;
|
|
137660
137665
|
};
|
|
137661
137666
|
|
|
137667
|
+
// src/api/routes/logs.routes.ts
|
|
137668
|
+
var import_node_fs6 = require("fs");
|
|
137669
|
+
var import_node_path9 = require("path");
|
|
137670
|
+
init_constants();
|
|
137671
|
+
init_logger();
|
|
137672
|
+
var logger2 = getLogger("logs-api");
|
|
137673
|
+
function resolveLogPath(source) {
|
|
137674
|
+
return (0, import_node_path9.join)(installDir(), "logs", `${source}.log`);
|
|
137675
|
+
}
|
|
137676
|
+
function pickDefaultSource() {
|
|
137677
|
+
for (const source of ["stdout", "stderr", "dev"]) {
|
|
137678
|
+
const p2 = resolveLogPath(source);
|
|
137679
|
+
if ((0, import_node_fs6.existsSync)(p2) && (0, import_node_fs6.statSync)(p2).size > 0) return source;
|
|
137680
|
+
}
|
|
137681
|
+
return "stdout";
|
|
137682
|
+
}
|
|
137683
|
+
function readLogLines(filePath, sinceOffset, limit) {
|
|
137684
|
+
if (!(0, import_node_fs6.existsSync)(filePath)) {
|
|
137685
|
+
return { lines: [], offset: 0, total: 0 };
|
|
137686
|
+
}
|
|
137687
|
+
const fd = (0, import_node_fs6.openSync)(filePath, "r");
|
|
137688
|
+
try {
|
|
137689
|
+
const { size } = (0, import_node_fs6.fstatSync)(fd);
|
|
137690
|
+
if (size === 0) return { lines: [], offset: 0, total: 0 };
|
|
137691
|
+
const maxBytes = Math.min(size, 2 * 1024 * 1024);
|
|
137692
|
+
const start = size - maxBytes;
|
|
137693
|
+
const buf = Buffer.alloc(maxBytes);
|
|
137694
|
+
(0, import_node_fs6.readSync)(fd, buf, 0, maxBytes, start);
|
|
137695
|
+
let text = buf.toString("utf8");
|
|
137696
|
+
if (start > 0) {
|
|
137697
|
+
const firstNl = text.indexOf("\n");
|
|
137698
|
+
if (firstNl >= 0) text = text.slice(firstNl + 1);
|
|
137699
|
+
}
|
|
137700
|
+
const allLines = text.split("\n").filter((line) => line.trim() && !line.startsWith("==="));
|
|
137701
|
+
let lines;
|
|
137702
|
+
let newOffset;
|
|
137703
|
+
if (sinceOffset > 0 && sinceOffset < allLines.length) {
|
|
137704
|
+
lines = allLines.slice(sinceOffset, sinceOffset + limit);
|
|
137705
|
+
newOffset = sinceOffset + lines.length;
|
|
137706
|
+
} else if (sinceOffset >= allLines.length && sinceOffset > 0) {
|
|
137707
|
+
lines = [];
|
|
137708
|
+
newOffset = allLines.length;
|
|
137709
|
+
} else {
|
|
137710
|
+
lines = allLines.slice(-limit);
|
|
137711
|
+
newOffset = allLines.length;
|
|
137712
|
+
}
|
|
137713
|
+
return { lines, offset: newOffset, total: allLines.length };
|
|
137714
|
+
} finally {
|
|
137715
|
+
(0, import_node_fs6.closeSync)(fd);
|
|
137716
|
+
}
|
|
137717
|
+
}
|
|
137718
|
+
function createLogsRoutes() {
|
|
137719
|
+
const app = new Hono2();
|
|
137720
|
+
app.get("/", (c) => {
|
|
137721
|
+
try {
|
|
137722
|
+
const sourceParam = (c.req.query("source") || "").toLowerCase();
|
|
137723
|
+
const source = sourceParam === "stdout" || sourceParam === "stderr" || sourceParam === "dev" ? sourceParam : pickDefaultSource();
|
|
137724
|
+
const logPath = resolveLogPath(source);
|
|
137725
|
+
const sinceOffset = parseInt(c.req.query("since") || "0", 10);
|
|
137726
|
+
const limit = Math.min(parseInt(c.req.query("limit") || "100", 10) || 100, 1e3);
|
|
137727
|
+
if (!(0, import_node_fs6.existsSync)(logPath)) {
|
|
137728
|
+
return c.json({
|
|
137729
|
+
logs: [],
|
|
137730
|
+
message: `No log file found for source=${source}`,
|
|
137731
|
+
offset: 0,
|
|
137732
|
+
total: 0,
|
|
137733
|
+
source
|
|
137734
|
+
});
|
|
137735
|
+
}
|
|
137736
|
+
const { lines, offset, total } = readLogLines(logPath, sinceOffset, limit);
|
|
137737
|
+
const stats = (0, import_node_fs6.statSync)(logPath);
|
|
137738
|
+
return c.json({
|
|
137739
|
+
logs: lines,
|
|
137740
|
+
offset,
|
|
137741
|
+
total,
|
|
137742
|
+
hasMore: offset < total,
|
|
137743
|
+
source,
|
|
137744
|
+
fileSize: stats.size,
|
|
137745
|
+
fileModified: stats.mtime.toISOString()
|
|
137746
|
+
});
|
|
137747
|
+
} catch (error51) {
|
|
137748
|
+
logger2.error("Failed to read logs", { error: String(error51) });
|
|
137749
|
+
return c.json(
|
|
137750
|
+
{
|
|
137751
|
+
error: "Failed to read logs",
|
|
137752
|
+
logs: [],
|
|
137753
|
+
offset: 0,
|
|
137754
|
+
total: 0
|
|
137755
|
+
},
|
|
137756
|
+
500
|
|
137757
|
+
);
|
|
137758
|
+
}
|
|
137759
|
+
});
|
|
137760
|
+
app.get("/meta", (c) => {
|
|
137761
|
+
try {
|
|
137762
|
+
const sources = ["stdout", "stderr", "dev"].map((source) => {
|
|
137763
|
+
const logPath = resolveLogPath(source);
|
|
137764
|
+
if (!(0, import_node_fs6.existsSync)(logPath)) {
|
|
137765
|
+
return { source, exists: false, total: 0, fileSize: 0 };
|
|
137766
|
+
}
|
|
137767
|
+
const stats = (0, import_node_fs6.statSync)(logPath);
|
|
137768
|
+
return {
|
|
137769
|
+
source,
|
|
137770
|
+
exists: true,
|
|
137771
|
+
fileSize: stats.size,
|
|
137772
|
+
fileModified: stats.mtime.toISOString()
|
|
137773
|
+
};
|
|
137774
|
+
});
|
|
137775
|
+
return c.json({
|
|
137776
|
+
defaultSource: pickDefaultSource(),
|
|
137777
|
+
sources
|
|
137778
|
+
});
|
|
137779
|
+
} catch (error51) {
|
|
137780
|
+
logger2.error("Failed to read log metadata", { error: String(error51) });
|
|
137781
|
+
return c.json({ error: "Failed to read log metadata", exists: false }, 500);
|
|
137782
|
+
}
|
|
137783
|
+
});
|
|
137784
|
+
return app;
|
|
137785
|
+
}
|
|
137786
|
+
|
|
137662
137787
|
// src/api/routes/misc.routes.ts
|
|
137663
137788
|
var import_node_child_process2 = require("child_process");
|
|
137664
137789
|
var import_node_crypto = require("crypto");
|
|
@@ -138080,6 +138205,7 @@ var createHonoApp = (deps, upgradeWebSocket) => {
|
|
|
138080
138205
|
app.route("/api", createBrowseRoutes(deps));
|
|
138081
138206
|
app.route("/", createScannerRoutes(deps));
|
|
138082
138207
|
app.route("/internal", createProgressRoutes(deps));
|
|
138208
|
+
app.route("/api/logs", createLogsRoutes());
|
|
138083
138209
|
if (upgradeWebSocket) {
|
|
138084
138210
|
app.route("/", createWsRoutes(deps, upgradeWebSocket));
|
|
138085
138211
|
}
|
|
@@ -139741,13 +139867,13 @@ function handleListProjects(url2, res) {
|
|
|
139741
139867
|
}
|
|
139742
139868
|
|
|
139743
139869
|
// src/live-session-manager.ts
|
|
139744
|
-
var
|
|
139870
|
+
var import_path20 = require("path");
|
|
139745
139871
|
|
|
139746
139872
|
// src/codex-pty-runner.ts
|
|
139747
139873
|
var import_headless = __toESM(require_xterm_headless(), 1);
|
|
139748
139874
|
var import_crypto7 = require("crypto");
|
|
139749
|
-
var
|
|
139750
|
-
var
|
|
139875
|
+
var import_fs22 = require("fs");
|
|
139876
|
+
var import_path18 = require("path");
|
|
139751
139877
|
init_logger();
|
|
139752
139878
|
|
|
139753
139879
|
// src/platform.ts
|
|
@@ -139873,6 +139999,69 @@ function resolveCodexExe() {
|
|
|
139873
139999
|
return _codexExe;
|
|
139874
140000
|
}
|
|
139875
140001
|
|
|
140002
|
+
// src/services/questions/codexGateAnswers.ts
|
|
140003
|
+
var import_fs21 = require("fs");
|
|
140004
|
+
var import_os9 = require("os");
|
|
140005
|
+
var import_path17 = require("path");
|
|
140006
|
+
function gateAnswersPath() {
|
|
140007
|
+
const dir = process.env.THREADBASE_CONFIG_DIR ?? (0, import_path17.join)((0, import_os9.homedir)(), ".threadbase");
|
|
140008
|
+
return (0, import_path17.join)(dir, "gate-answers.json");
|
|
140009
|
+
}
|
|
140010
|
+
function loadGateAnswers() {
|
|
140011
|
+
try {
|
|
140012
|
+
const parsed = JSON.parse((0, import_fs21.readFileSync)(gateAnswersPath(), "utf-8"));
|
|
140013
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
140014
|
+
} catch {
|
|
140015
|
+
return {};
|
|
140016
|
+
}
|
|
140017
|
+
}
|
|
140018
|
+
function saveGateAnswer(key, value) {
|
|
140019
|
+
const path2 = gateAnswersPath();
|
|
140020
|
+
(0, import_fs21.mkdirSync)((0, import_path17.dirname)(path2), { recursive: true });
|
|
140021
|
+
(0, import_fs21.writeFileSync)(path2, `${JSON.stringify({ ...loadGateAnswers(), [key]: value }, null, 2)}
|
|
140022
|
+
`);
|
|
140023
|
+
}
|
|
140024
|
+
function rememberedGateDigit(gate) {
|
|
140025
|
+
const answers = loadGateAnswers();
|
|
140026
|
+
if (gate === "hooks") {
|
|
140027
|
+
if (answers.codexHooksGate === "trust_all") return "2";
|
|
140028
|
+
if (answers.codexHooksGate === "continue_untrusted") return "3";
|
|
140029
|
+
return null;
|
|
140030
|
+
}
|
|
140031
|
+
return answers.codexTrustGate === "yes" ? "1" : null;
|
|
140032
|
+
}
|
|
140033
|
+
|
|
140034
|
+
// src/utils/debounce.ts
|
|
140035
|
+
function debounce(fn, waitMs) {
|
|
140036
|
+
let timer = null;
|
|
140037
|
+
let lastArgs = null;
|
|
140038
|
+
const run2 = () => {
|
|
140039
|
+
timer = null;
|
|
140040
|
+
if (lastArgs) {
|
|
140041
|
+
const args = lastArgs;
|
|
140042
|
+
lastArgs = null;
|
|
140043
|
+
fn(...args);
|
|
140044
|
+
}
|
|
140045
|
+
};
|
|
140046
|
+
const debounced = (...args) => {
|
|
140047
|
+
lastArgs = args;
|
|
140048
|
+
if (timer) clearTimeout(timer);
|
|
140049
|
+
timer = setTimeout(run2, waitMs);
|
|
140050
|
+
};
|
|
140051
|
+
debounced.cancel = () => {
|
|
140052
|
+
if (timer) clearTimeout(timer);
|
|
140053
|
+
timer = null;
|
|
140054
|
+
lastArgs = null;
|
|
140055
|
+
};
|
|
140056
|
+
debounced.flush = () => {
|
|
140057
|
+
if (timer) {
|
|
140058
|
+
clearTimeout(timer);
|
|
140059
|
+
run2();
|
|
140060
|
+
}
|
|
140061
|
+
};
|
|
140062
|
+
return debounced;
|
|
140063
|
+
}
|
|
140064
|
+
|
|
139876
140065
|
// src/codex-pty-runner.ts
|
|
139877
140066
|
var OUTPUT_BUFFER_MAX = 65536;
|
|
139878
140067
|
var PTY_COLS = 120;
|
|
@@ -139880,6 +140069,9 @@ var PTY_ROWS = 40;
|
|
|
139880
140069
|
var SCREEN_SCROLLBACK = 1e3;
|
|
139881
140070
|
var CODEX_PROMPT_READY_TEXT = "Ready";
|
|
139882
140071
|
var CODEX_TRUST_GATE_REGEX = /trust the contents/i;
|
|
140072
|
+
var CODEX_HOOKS_GATE_REGEX = /hooks need review/i;
|
|
140073
|
+
var QUIET_DETECT_MS = 500;
|
|
140074
|
+
var CODEX_READY_FALLBACK_MS = 8e3;
|
|
139883
140075
|
var SUBMIT_BYTES = "\r";
|
|
139884
140076
|
var CODEX_SUBMIT_DELAY_MS = 16;
|
|
139885
140077
|
function digestBytes(s3) {
|
|
@@ -139887,6 +140079,40 @@ function digestBytes(s3) {
|
|
|
139887
140079
|
if (escaped.length <= 200) return escaped;
|
|
139888
140080
|
return `${escaped.slice(0, 100)}\u2026[${escaped.length - 200}B omitted]\u2026${escaped.slice(-100)}`;
|
|
139889
140081
|
}
|
|
140082
|
+
function gateCard(gate, lines) {
|
|
140083
|
+
if (gate === "hooks") {
|
|
140084
|
+
const countLine = lines.find((l) => /new or changed/i.test(l))?.trim();
|
|
140085
|
+
return {
|
|
140086
|
+
prompt: [
|
|
140087
|
+
"Hooks need review",
|
|
140088
|
+
countLine,
|
|
140089
|
+
"Hooks can run outside the sandbox after you trust them."
|
|
140090
|
+
].filter(Boolean).join(" \u2014 "),
|
|
140091
|
+
options: [
|
|
140092
|
+
{ index: 2, label: "Trust all and continue", answerKeys: "2\r" },
|
|
140093
|
+
{ index: 3, label: "Continue without trusting (hooks won't run)", answerKeys: "3\r" },
|
|
140094
|
+
{
|
|
140095
|
+
index: 4,
|
|
140096
|
+
label: "Trust all and continue (remember for all projects)",
|
|
140097
|
+
answerKeys: "4\r"
|
|
140098
|
+
},
|
|
140099
|
+
{
|
|
140100
|
+
index: 5,
|
|
140101
|
+
label: "Continue without trusting (remember for all projects)",
|
|
140102
|
+
answerKeys: "5\r"
|
|
140103
|
+
}
|
|
140104
|
+
]
|
|
140105
|
+
};
|
|
140106
|
+
}
|
|
140107
|
+
return {
|
|
140108
|
+
prompt: lines.find((l) => CODEX_TRUST_GATE_REGEX.test(l))?.trim() ?? "Do you trust the contents of this directory?",
|
|
140109
|
+
options: [
|
|
140110
|
+
{ index: 1, label: "Yes, continue", answerKeys: "1\r" },
|
|
140111
|
+
{ index: 2, label: "No, quit", answerKeys: "2\r" },
|
|
140112
|
+
{ index: 3, label: "Yes, continue (remember for all projects)", answerKeys: "3\r" }
|
|
140113
|
+
]
|
|
140114
|
+
};
|
|
140115
|
+
}
|
|
139890
140116
|
var pty = null;
|
|
139891
140117
|
async function loadPty() {
|
|
139892
140118
|
if (pty) return pty;
|
|
@@ -139913,8 +140139,8 @@ var CodexPtyRunner = class {
|
|
|
139913
140139
|
onOutput;
|
|
139914
140140
|
onStatusChange;
|
|
139915
140141
|
onReady;
|
|
139916
|
-
//
|
|
139917
|
-
//
|
|
140142
|
+
// Broadcasts Codex's blocking startup gates (directory trust, hooks review)
|
|
140143
|
+
// as question cards; null dismisses the card once the gate leaves the screen.
|
|
139918
140144
|
onPermissionChange;
|
|
139919
140145
|
onLiveQuestion;
|
|
139920
140146
|
onLiveQuestionGone;
|
|
@@ -139925,8 +140151,18 @@ var CodexPtyRunner = class {
|
|
|
139925
140151
|
// Inputs received via sendInput() while the session was still pendingReady.
|
|
139926
140152
|
// Flushed in arrival order once Codex reaches Ready.
|
|
139927
140153
|
queuedInputs = /* @__PURE__ */ new Map();
|
|
139928
|
-
//
|
|
139929
|
-
|
|
140154
|
+
// Gate currently on a session's screen (card broadcast, unanswered). While
|
|
140155
|
+
// set, queued-input flushes are held — a flushed digit would CONFIRM a
|
|
140156
|
+
// dialog option — and sendKeys() intercepts remember-variant digits.
|
|
140157
|
+
openGate = /* @__PURE__ */ new Map();
|
|
140158
|
+
// `${sessionId}:${gate}` once a gate has been actioned (auto-answered or
|
|
140159
|
+
// card broadcast) — dedupes repaints of the same dialog.
|
|
140160
|
+
gateActioned = /* @__PURE__ */ new Set();
|
|
140161
|
+
// Per-session trailing debounce re-armed on every chunk; on quiet, re-runs
|
|
140162
|
+
// screen detection so a blocked/truncated boot still reaches ready.
|
|
140163
|
+
quietCheckers = /* @__PURE__ */ new Map();
|
|
140164
|
+
// Per-session flat backstop from spawn (CODEX_READY_FALLBACK_MS).
|
|
140165
|
+
readyFallbackTimers = /* @__PURE__ */ new Map();
|
|
139930
140166
|
// In-flight start()/startFresh() calls keyed by sessionId. A second
|
|
139931
140167
|
// concurrent resume for the same session (double-tap, client retry) awaits
|
|
139932
140168
|
// the first call's promise instead of spawning a duplicate PTY (CRITICAL #3).
|
|
@@ -139956,7 +140192,7 @@ var CodexPtyRunner = class {
|
|
|
139956
140192
|
}
|
|
139957
140193
|
async doStart(sessionId, options) {
|
|
139958
140194
|
const nodePty = await loadPty();
|
|
139959
|
-
const projectName = options.projectName ?? (0,
|
|
140195
|
+
const projectName = options.projectName ?? (0, import_path18.basename)(options.projectPath);
|
|
139960
140196
|
const proc = nodePty.spawn(
|
|
139961
140197
|
resolveCodexExe(),
|
|
139962
140198
|
["resume", sessionId, "--cd", options.projectPath, "--no-alt-screen"],
|
|
@@ -139985,6 +140221,7 @@ var CodexPtyRunner = class {
|
|
|
139985
140221
|
};
|
|
139986
140222
|
this.sessions.set(sessionId, session);
|
|
139987
140223
|
this.pendingReady.add(sessionId);
|
|
140224
|
+
this.armReadyFallback(sessionId);
|
|
139988
140225
|
proc.onData((data) => {
|
|
139989
140226
|
this.handleOutput(sessionId, data);
|
|
139990
140227
|
});
|
|
@@ -140001,7 +140238,7 @@ var CodexPtyRunner = class {
|
|
|
140001
140238
|
async startFresh(options) {
|
|
140002
140239
|
const nodePty = await loadPty();
|
|
140003
140240
|
const sessionId = (0, import_crypto7.randomUUID)();
|
|
140004
|
-
const projectName = options.projectName ?? (0,
|
|
140241
|
+
const projectName = options.projectName ?? (0, import_path18.basename)(options.projectPath);
|
|
140005
140242
|
const args = ["--cd", options.projectPath, "--no-alt-screen"];
|
|
140006
140243
|
if (options.systemPrompt) {
|
|
140007
140244
|
args.push(options.systemPrompt);
|
|
@@ -140030,6 +140267,7 @@ var CodexPtyRunner = class {
|
|
|
140030
140267
|
};
|
|
140031
140268
|
this.sessions.set(sessionId, session);
|
|
140032
140269
|
this.pendingReady.add(sessionId);
|
|
140270
|
+
this.armReadyFallback(sessionId);
|
|
140033
140271
|
proc.onData((data) => {
|
|
140034
140272
|
this.handleOutput(sessionId, data);
|
|
140035
140273
|
});
|
|
@@ -140039,6 +140277,21 @@ var CodexPtyRunner = class {
|
|
|
140039
140277
|
});
|
|
140040
140278
|
return toPublicSession(session);
|
|
140041
140279
|
}
|
|
140280
|
+
// Flat backstop: if neither the "Ready" marker nor the quiet-checker settled
|
|
140281
|
+
// the session within CODEX_READY_FALLBACK_MS of spawn, mark it ready anyway
|
|
140282
|
+
// so start requests resolve and mobile can watch the boot live. unref() so a
|
|
140283
|
+
// pending timer never holds the process open.
|
|
140284
|
+
armReadyFallback(sessionId) {
|
|
140285
|
+
const timer = setTimeout(() => {
|
|
140286
|
+
this.readyFallbackTimers.delete(sessionId);
|
|
140287
|
+
const session = this.sessions.get(sessionId);
|
|
140288
|
+
if (session?.status === "running" && this.pendingReady.has(sessionId)) {
|
|
140289
|
+
this.markReady(sessionId, session, "fallback:timeout");
|
|
140290
|
+
}
|
|
140291
|
+
}, CODEX_READY_FALLBACK_MS);
|
|
140292
|
+
timer.unref?.();
|
|
140293
|
+
this.readyFallbackTimers.set(sessionId, timer);
|
|
140294
|
+
}
|
|
140042
140295
|
// Write raw key bytes directly to the PTY, same as PTYManager.sendKeys.
|
|
140043
140296
|
sendKeys(sessionId, keys) {
|
|
140044
140297
|
const session = this.sessions.get(sessionId);
|
|
@@ -140050,13 +140303,47 @@ var CodexPtyRunner = class {
|
|
|
140050
140303
|
session.status = "running";
|
|
140051
140304
|
this.onStatusChange?.(toPublicSession(session));
|
|
140052
140305
|
}
|
|
140306
|
+
const gate = this.openGate.get(sessionId);
|
|
140307
|
+
const digit = gate ? /^([0-9])\r?$/.exec(keys)?.[1] : void 0;
|
|
140308
|
+
const out = gate && digit ? this.resolveGateAnswer(sessionId, gate, digit) : keys;
|
|
140053
140309
|
this.log.info(
|
|
140054
|
-
`[codex.keys.write] ${sessionId.slice(0, 8)} bytes=${
|
|
140055
|
-
{ event: "codex.keys_write", sessionId, byteLen:
|
|
140310
|
+
`[codex.keys.write] ${sessionId.slice(0, 8)} bytes=${out.length} digest=${digestBytes(out)}`,
|
|
140311
|
+
{ event: "codex.keys_write", sessionId, byteLen: out.length }
|
|
140056
140312
|
);
|
|
140057
|
-
session.process.write(
|
|
140313
|
+
session.process.write(out);
|
|
140058
140314
|
session.lastActivityAt = /* @__PURE__ */ new Date();
|
|
140059
140315
|
}
|
|
140316
|
+
// Map a gate-card digit to the PTY bytes that answer the real dialog,
|
|
140317
|
+
// persisting the choice when the digit was a synthetic "remember for all
|
|
140318
|
+
// projects" option (those numbers don't exist on the actual dialog and must
|
|
140319
|
+
// never reach codex). The trailing \r mobile sends is dropped: a digit alone
|
|
140320
|
+
// selects AND confirms (live-probe verified), and a stray Enter would land
|
|
140321
|
+
// on whatever screen follows.
|
|
140322
|
+
resolveGateAnswer(sessionId, gate, digit) {
|
|
140323
|
+
let real = digit;
|
|
140324
|
+
let remembered = false;
|
|
140325
|
+
if (gate === "hooks" && digit === "4") {
|
|
140326
|
+
saveGateAnswer("codexHooksGate", "trust_all");
|
|
140327
|
+
real = "2";
|
|
140328
|
+
remembered = true;
|
|
140329
|
+
} else if (gate === "hooks" && digit === "5") {
|
|
140330
|
+
saveGateAnswer("codexHooksGate", "continue_untrusted");
|
|
140331
|
+
real = "3";
|
|
140332
|
+
remembered = true;
|
|
140333
|
+
} else if (gate === "trust" && digit === "3") {
|
|
140334
|
+
saveGateAnswer("codexTrustGate", "yes");
|
|
140335
|
+
real = "1";
|
|
140336
|
+
remembered = true;
|
|
140337
|
+
}
|
|
140338
|
+
this.log.info(`[codex.gate_answer] ${sessionId.slice(0, 8)} ${gate} digit=${real}`, {
|
|
140339
|
+
event: "codex.gate_answer",
|
|
140340
|
+
sessionId,
|
|
140341
|
+
gate,
|
|
140342
|
+
digit: real,
|
|
140343
|
+
remembered
|
|
140344
|
+
});
|
|
140345
|
+
return real;
|
|
140346
|
+
}
|
|
140060
140347
|
sendInput(sessionId, input) {
|
|
140061
140348
|
const session = this.sessions.get(sessionId);
|
|
140062
140349
|
if (!session) throw new Error(`Session not found: ${sessionId}`);
|
|
@@ -140126,8 +140413,12 @@ var CodexPtyRunner = class {
|
|
|
140126
140413
|
}, CODEX_SUBMIT_DELAY_MS);
|
|
140127
140414
|
}
|
|
140128
140415
|
// Drain any inputs sent while the session was still pendingReady, writing
|
|
140129
|
-
// them in arrival order now that Codex is Ready.
|
|
140416
|
+
// them in arrival order now that Codex is Ready. No-op while a gate dialog
|
|
140417
|
+
// is open (a flushed digit would confirm a dialog option) or while still
|
|
140418
|
+
// pendingReady (markReady drains it) — the gate-close path re-drives it for
|
|
140419
|
+
// the ready-with-gate-open case.
|
|
140130
140420
|
flushQueuedInputs(sessionId) {
|
|
140421
|
+
if (this.openGate.has(sessionId) || this.pendingReady.has(sessionId)) return;
|
|
140131
140422
|
const queue = this.queuedInputs.get(sessionId);
|
|
140132
140423
|
if (!queue || queue.length === 0) return;
|
|
140133
140424
|
this.queuedInputs.delete(sessionId);
|
|
@@ -140172,7 +140463,7 @@ var CodexPtyRunner = class {
|
|
|
140172
140463
|
if (!session) return;
|
|
140173
140464
|
this.pendingReady.delete(sessionId);
|
|
140174
140465
|
this.queuedInputs.delete(sessionId);
|
|
140175
|
-
this.
|
|
140466
|
+
this.clearSessionDetectors(sessionId);
|
|
140176
140467
|
try {
|
|
140177
140468
|
session.process.kill("SIGINT");
|
|
140178
140469
|
} catch {
|
|
@@ -140183,6 +140474,21 @@ var CodexPtyRunner = class {
|
|
|
140183
140474
|
this.sessions.delete(sessionId);
|
|
140184
140475
|
this.onStatusChange?.(toPublicSession(session));
|
|
140185
140476
|
}
|
|
140477
|
+
// Drop a session's detection state: quiet-checker, ready-fallback timer,
|
|
140478
|
+
// gate bookkeeping — and dismiss a still-open gate card so mobile doesn't
|
|
140479
|
+
// keep rendering a question for a dead PTY.
|
|
140480
|
+
clearSessionDetectors(sessionId) {
|
|
140481
|
+
this.quietCheckers.get(sessionId)?.cancel();
|
|
140482
|
+
this.quietCheckers.delete(sessionId);
|
|
140483
|
+
const timer = this.readyFallbackTimers.get(sessionId);
|
|
140484
|
+
if (timer) clearTimeout(timer);
|
|
140485
|
+
this.readyFallbackTimers.delete(sessionId);
|
|
140486
|
+
if (this.openGate.delete(sessionId)) {
|
|
140487
|
+
this.onPermissionChange?.(sessionId, null);
|
|
140488
|
+
}
|
|
140489
|
+
this.gateActioned.delete(`${sessionId}:hooks`);
|
|
140490
|
+
this.gateActioned.delete(`${sessionId}:trust`);
|
|
140491
|
+
}
|
|
140186
140492
|
getOutput(sessionId) {
|
|
140187
140493
|
const session = this.sessions.get(sessionId);
|
|
140188
140494
|
if (!session) throw new Error(`Session not found: ${sessionId}`);
|
|
@@ -140222,10 +140528,19 @@ var CodexPtyRunner = class {
|
|
|
140222
140528
|
}
|
|
140223
140529
|
session.screen.dispose();
|
|
140224
140530
|
}
|
|
140531
|
+
for (const sessionId of Array.from(this.quietCheckers.keys())) {
|
|
140532
|
+
this.clearSessionDetectors(sessionId);
|
|
140533
|
+
}
|
|
140534
|
+
for (const timer of this.readyFallbackTimers.values()) {
|
|
140535
|
+
clearTimeout(timer);
|
|
140536
|
+
}
|
|
140225
140537
|
this.sessions.clear();
|
|
140226
140538
|
this.pendingReady.clear();
|
|
140227
140539
|
this.queuedInputs.clear();
|
|
140228
|
-
this.
|
|
140540
|
+
this.openGate.clear();
|
|
140541
|
+
this.gateActioned.clear();
|
|
140542
|
+
this.quietCheckers.clear();
|
|
140543
|
+
this.readyFallbackTimers.clear();
|
|
140229
140544
|
}
|
|
140230
140545
|
handleOutput(sessionId, data) {
|
|
140231
140546
|
const session = this.sessions.get(sessionId);
|
|
@@ -140240,44 +140555,92 @@ var CodexPtyRunner = class {
|
|
|
140240
140555
|
session.screen.write(data);
|
|
140241
140556
|
session.lastOutput = stripAnsi(data);
|
|
140242
140557
|
this.onOutput?.(sessionId, data);
|
|
140243
|
-
this.
|
|
140558
|
+
this.detectScreenState(sessionId, "chunk").catch((err) => {
|
|
140244
140559
|
this.log.warn("[codex.ready_detect] failed", {
|
|
140245
140560
|
event: "codex.ready_detect_failed",
|
|
140246
140561
|
sessionId,
|
|
140247
140562
|
err
|
|
140248
140563
|
});
|
|
140249
140564
|
});
|
|
140565
|
+
let quiet = this.quietCheckers.get(sessionId);
|
|
140566
|
+
if (!quiet) {
|
|
140567
|
+
quiet = debounce(() => {
|
|
140568
|
+
this.detectScreenState(sessionId, "quiet").catch((err) => {
|
|
140569
|
+
this.log.warn("[codex.ready_detect] failed", {
|
|
140570
|
+
event: "codex.ready_detect_failed",
|
|
140571
|
+
sessionId,
|
|
140572
|
+
err
|
|
140573
|
+
});
|
|
140574
|
+
});
|
|
140575
|
+
}, QUIET_DETECT_MS);
|
|
140576
|
+
this.quietCheckers.set(sessionId, quiet);
|
|
140577
|
+
}
|
|
140578
|
+
quiet();
|
|
140250
140579
|
}
|
|
140251
|
-
// Renders the session's headless screen and
|
|
140252
|
-
//
|
|
140253
|
-
//
|
|
140254
|
-
//
|
|
140255
|
-
//
|
|
140256
|
-
|
|
140257
|
-
|
|
140580
|
+
// Renders the session's headless screen and drives both detections:
|
|
140581
|
+
// - Gates (directory trust, hooks review) — checked on EVERY pass,
|
|
140582
|
+
// independent of pendingReady, so a gate appearing after ready is still
|
|
140583
|
+
// surfaced and a gate leaving the screen closes its card.
|
|
140584
|
+
// - Readiness — the "Ready" status-bar marker while pendingReady, plus the
|
|
140585
|
+
// quiet path: after QUIET_DETECT_MS of PTY silence a still-pending
|
|
140586
|
+
// session is marked ready anyway (`›` alone is NOT a marker — Phase 0 —
|
|
140587
|
+
// but a quiet boot screen is more useful to the user live than a
|
|
140588
|
+
// spinner, and "Ready" may be truncated off the 120-col status bar).
|
|
140589
|
+
async detectScreenState(sessionId, trigger) {
|
|
140590
|
+
const session = this.sessions.get(sessionId);
|
|
140591
|
+
if (!session || session.status === "idle") return;
|
|
140258
140592
|
const lines = await this.getOutputLines(sessionId, PTY_ROWS);
|
|
140259
140593
|
const screenText = lines.join("\n");
|
|
140260
|
-
|
|
140261
|
-
|
|
140262
|
-
|
|
140263
|
-
|
|
140264
|
-
|
|
140265
|
-
|
|
140266
|
-
});
|
|
140267
|
-
session.process.write("\r");
|
|
140268
|
-
}
|
|
140269
|
-
return;
|
|
140594
|
+
const gate = CODEX_HOOKS_GATE_REGEX.test(screenText) ? "hooks" : CODEX_TRUST_GATE_REGEX.test(screenText) ? "trust" : null;
|
|
140595
|
+
if (gate) {
|
|
140596
|
+
this.handleGate(sessionId, session, gate, lines);
|
|
140597
|
+
} else if (this.openGate.delete(sessionId)) {
|
|
140598
|
+
this.onPermissionChange?.(sessionId, null);
|
|
140599
|
+
this.flushQueuedInputs(sessionId);
|
|
140270
140600
|
}
|
|
140601
|
+
if (session.status !== "running" || !this.pendingReady.has(sessionId)) return;
|
|
140271
140602
|
const lastNonBlank2 = [...lines].reverse().find((l) => l.trim() !== "") ?? "";
|
|
140272
|
-
if (
|
|
140273
|
-
|
|
140603
|
+
if (lastNonBlank2.includes(CODEX_PROMPT_READY_TEXT)) {
|
|
140604
|
+
this.markReady(sessionId, session, `marker:${CODEX_PROMPT_READY_TEXT}`);
|
|
140605
|
+
} else if (trigger === "quiet") {
|
|
140606
|
+
this.markReady(sessionId, session, "quiet:timeout");
|
|
140607
|
+
}
|
|
140608
|
+
}
|
|
140609
|
+
// Answer a gate from the persisted remember-store, or surface it as a
|
|
140610
|
+
// question card over the permission transport. Actioned once per session and
|
|
140611
|
+
// gate type — repaints of the same dialog neither re-write nor re-broadcast.
|
|
140612
|
+
handleGate(sessionId, session, gate, lines) {
|
|
140613
|
+
const key = `${sessionId}:${gate}`;
|
|
140614
|
+
if (this.gateActioned.has(key)) return;
|
|
140615
|
+
this.gateActioned.add(key);
|
|
140616
|
+
const remembered = rememberedGateDigit(gate);
|
|
140617
|
+
if (remembered) {
|
|
140618
|
+
this.log.info(`[codex.gate_auto_answer] ${sessionId.slice(0, 8)} ${gate} \u2192 ${remembered}`, {
|
|
140619
|
+
event: "codex.gate_auto_answer",
|
|
140620
|
+
sessionId,
|
|
140621
|
+
gate,
|
|
140622
|
+
digit: remembered
|
|
140623
|
+
});
|
|
140624
|
+
session.process.write(remembered);
|
|
140625
|
+
return;
|
|
140626
|
+
}
|
|
140627
|
+
this.openGate.set(sessionId, gate);
|
|
140628
|
+
const card = gateCard(gate, lines);
|
|
140629
|
+
this.log.info(`[codex.gate_prompt] ${sessionId.slice(0, 8)} ${gate}`, {
|
|
140630
|
+
event: "codex.gate_prompt",
|
|
140631
|
+
sessionId,
|
|
140632
|
+
gate,
|
|
140633
|
+
prompt: card.prompt
|
|
140634
|
+
});
|
|
140635
|
+
this.onPermissionChange?.(sessionId, card);
|
|
140274
140636
|
}
|
|
140275
|
-
markReady(sessionId, session) {
|
|
140637
|
+
markReady(sessionId, session, reason) {
|
|
140276
140638
|
session.lastActivityAt = /* @__PURE__ */ new Date();
|
|
140277
140639
|
session.status = "waiting_input";
|
|
140278
|
-
this.log.info(`[codex.ready] ${sessionId.slice(0, 8)}`, {
|
|
140640
|
+
this.log.info(`[codex.ready] ${sessionId.slice(0, 8)} ${reason}`, {
|
|
140279
140641
|
event: "codex.ready",
|
|
140280
|
-
sessionId
|
|
140642
|
+
sessionId,
|
|
140643
|
+
reason
|
|
140281
140644
|
});
|
|
140282
140645
|
this.onStatusChange?.(toPublicSession(session));
|
|
140283
140646
|
if (this.pendingReady.has(sessionId)) {
|
|
@@ -140293,7 +140656,7 @@ var CodexPtyRunner = class {
|
|
|
140293
140656
|
session.status = "idle";
|
|
140294
140657
|
const elapsedMs = session.completedAt.getTime() - session.startedAt.getTime();
|
|
140295
140658
|
if (exitCode !== 0 && elapsedMs < 2e3 && session.lastOutput === "") {
|
|
140296
|
-
if (!(0,
|
|
140659
|
+
if (!(0, import_fs22.existsSync)(session.projectPath)) {
|
|
140297
140660
|
session.failureReason = `Project directory not found: ${session.projectPath}`;
|
|
140298
140661
|
} else {
|
|
140299
140662
|
session.failureReason = `Codex process exited immediately (code ${exitCode}).`;
|
|
@@ -140303,7 +140666,7 @@ var CodexPtyRunner = class {
|
|
|
140303
140666
|
session.screen.dispose();
|
|
140304
140667
|
this.sessions.delete(sessionId);
|
|
140305
140668
|
this.queuedInputs.delete(sessionId);
|
|
140306
|
-
this.
|
|
140669
|
+
this.clearSessionDetectors(sessionId);
|
|
140307
140670
|
}
|
|
140308
140671
|
};
|
|
140309
140672
|
function toPublicSession(s3) {
|
|
@@ -140330,8 +140693,8 @@ function stripAnsi(str) {
|
|
|
140330
140693
|
// src/pty-manager.ts
|
|
140331
140694
|
var import_headless2 = __toESM(require_xterm_headless(), 1);
|
|
140332
140695
|
var import_crypto8 = require("crypto");
|
|
140333
|
-
var
|
|
140334
|
-
var
|
|
140696
|
+
var import_fs23 = require("fs");
|
|
140697
|
+
var import_path19 = require("path");
|
|
140335
140698
|
init_logger();
|
|
140336
140699
|
|
|
140337
140700
|
// src/services/questions/detectPermissionGate.ts
|
|
@@ -140487,9 +140850,15 @@ function detectShellPrompt(lines) {
|
|
|
140487
140850
|
]
|
|
140488
140851
|
};
|
|
140489
140852
|
}
|
|
140490
|
-
|
|
140853
|
+
const lastNumberedIdx = (() => {
|
|
140854
|
+
for (let i = last.idx; i >= 0; i--) {
|
|
140855
|
+
if (NUMBERED_RE.test(lines[i])) return i;
|
|
140856
|
+
}
|
|
140857
|
+
return -1;
|
|
140858
|
+
})();
|
|
140859
|
+
if (lastNumberedIdx >= 0) {
|
|
140491
140860
|
const options = [];
|
|
140492
|
-
for (let i = 0; i <=
|
|
140861
|
+
for (let i = 0; i <= lastNumberedIdx; i++) {
|
|
140493
140862
|
const m2 = NUMBERED_RE.exec(lines[i]);
|
|
140494
140863
|
if (!m2) continue;
|
|
140495
140864
|
const num = Number.parseInt(m2[1], 10);
|
|
@@ -140517,37 +140886,6 @@ function detectShellPrompt(lines) {
|
|
|
140517
140886
|
return null;
|
|
140518
140887
|
}
|
|
140519
140888
|
|
|
140520
|
-
// src/utils/debounce.ts
|
|
140521
|
-
function debounce(fn, waitMs) {
|
|
140522
|
-
let timer = null;
|
|
140523
|
-
let lastArgs = null;
|
|
140524
|
-
const run2 = () => {
|
|
140525
|
-
timer = null;
|
|
140526
|
-
if (lastArgs) {
|
|
140527
|
-
const args = lastArgs;
|
|
140528
|
-
lastArgs = null;
|
|
140529
|
-
fn(...args);
|
|
140530
|
-
}
|
|
140531
|
-
};
|
|
140532
|
-
const debounced = (...args) => {
|
|
140533
|
-
lastArgs = args;
|
|
140534
|
-
if (timer) clearTimeout(timer);
|
|
140535
|
-
timer = setTimeout(run2, waitMs);
|
|
140536
|
-
};
|
|
140537
|
-
debounced.cancel = () => {
|
|
140538
|
-
if (timer) clearTimeout(timer);
|
|
140539
|
-
timer = null;
|
|
140540
|
-
lastArgs = null;
|
|
140541
|
-
};
|
|
140542
|
-
debounced.flush = () => {
|
|
140543
|
-
if (timer) {
|
|
140544
|
-
clearTimeout(timer);
|
|
140545
|
-
run2();
|
|
140546
|
-
}
|
|
140547
|
-
};
|
|
140548
|
-
return debounced;
|
|
140549
|
-
}
|
|
140550
|
-
|
|
140551
140889
|
// src/pty-manager.ts
|
|
140552
140890
|
var OUTPUT_BUFFER_MAX2 = 65536;
|
|
140553
140891
|
var PTY_COLS2 = 120;
|
|
@@ -140555,7 +140893,7 @@ var PTY_ROWS2 = 40;
|
|
|
140555
140893
|
var SCREEN_SCROLLBACK2 = 1e3;
|
|
140556
140894
|
var CLAUDE_PROMPT_MARKERS = ["\u256D", "\u276F"];
|
|
140557
140895
|
var PROMPT_MARKER_FALLBACK_MS = 1e4;
|
|
140558
|
-
var
|
|
140896
|
+
var QUIET_DETECT_MS2 = 500;
|
|
140559
140897
|
function buildPasteBytes(input) {
|
|
140560
140898
|
return `\x1B[200~${input}\x1B[201~`;
|
|
140561
140899
|
}
|
|
@@ -140683,7 +141021,7 @@ var PTYManager = class {
|
|
|
140683
141021
|
}
|
|
140684
141022
|
async doStart(sessionId, options) {
|
|
140685
141023
|
const nodePty = await loadPty2();
|
|
140686
|
-
const projectName = options.projectName ?? (0,
|
|
141024
|
+
const projectName = options.projectName ?? (0, import_path19.basename)(options.projectPath);
|
|
140687
141025
|
const proc = nodePty.spawn(
|
|
140688
141026
|
resolveClaudeExe(),
|
|
140689
141027
|
[
|
|
@@ -140734,7 +141072,7 @@ var PTYManager = class {
|
|
|
140734
141072
|
async startFresh(options) {
|
|
140735
141073
|
const nodePty = await loadPty2();
|
|
140736
141074
|
const sessionId = (0, import_crypto8.randomUUID)();
|
|
140737
|
-
const projectName = options.projectName ?? (0,
|
|
141075
|
+
const projectName = options.projectName ?? (0, import_path19.basename)(options.projectPath);
|
|
140738
141076
|
const args = [
|
|
140739
141077
|
"--permission-mode",
|
|
140740
141078
|
options.permissionMode ?? "acceptEdits",
|
|
@@ -141055,7 +141393,7 @@ var PTYManager = class {
|
|
|
141055
141393
|
});
|
|
141056
141394
|
let quiet = this.quietCheckers.get(sessionId);
|
|
141057
141395
|
if (!quiet) {
|
|
141058
|
-
quiet = debounce(() => this.handleQuiet(sessionId),
|
|
141396
|
+
quiet = debounce(() => this.handleQuiet(sessionId), QUIET_DETECT_MS2);
|
|
141059
141397
|
this.quietCheckers.set(sessionId, quiet);
|
|
141060
141398
|
}
|
|
141061
141399
|
quiet();
|
|
@@ -141178,7 +141516,7 @@ var PTYManager = class {
|
|
|
141178
141516
|
session.status = "idle";
|
|
141179
141517
|
const elapsedMs = session.completedAt.getTime() - session.startedAt.getTime();
|
|
141180
141518
|
if (exitCode !== 0 && elapsedMs < 2e3 && session.lastOutput === "") {
|
|
141181
|
-
if (!(0,
|
|
141519
|
+
if (!(0, import_fs23.existsSync)(session.projectPath)) {
|
|
141182
141520
|
session.failureReason = `Project directory not found: ${session.projectPath}`;
|
|
141183
141521
|
} else {
|
|
141184
141522
|
session.failureReason = `Process exited immediately (code ${exitCode}). Check that the Claude binary is installed and accessible.`;
|
|
@@ -141306,7 +141644,7 @@ var LiveSessionManager = class {
|
|
|
141306
141644
|
const runner = this.runners.get(provider);
|
|
141307
141645
|
if (runner) return runner;
|
|
141308
141646
|
const err = new Error(
|
|
141309
|
-
`Live ${provider} sessions are not implemented yet for ${(0,
|
|
141647
|
+
`Live ${provider} sessions are not implemented yet for ${(0, import_path20.basename)(projectPath)}`
|
|
141310
141648
|
);
|
|
141311
141649
|
err.statusCode = 501;
|
|
141312
141650
|
throw err;
|
|
@@ -141372,10 +141710,10 @@ var PairTokenStore = class {
|
|
|
141372
141710
|
|
|
141373
141711
|
// src/process-discovery.ts
|
|
141374
141712
|
var import_child_process2 = require("child_process");
|
|
141375
|
-
var
|
|
141376
|
-
var
|
|
141713
|
+
var import_os10 = require("os");
|
|
141714
|
+
var import_path21 = require("path");
|
|
141377
141715
|
async function discoverClaudeProcesses() {
|
|
141378
|
-
if ((0,
|
|
141716
|
+
if ((0, import_os10.platform)() === "win32") return discoverWindows();
|
|
141379
141717
|
return discoverUnix();
|
|
141380
141718
|
}
|
|
141381
141719
|
async function discoverUnix() {
|
|
@@ -141392,7 +141730,7 @@ async function discoverUnix() {
|
|
|
141392
141730
|
return {
|
|
141393
141731
|
pid,
|
|
141394
141732
|
projectPath: cwd,
|
|
141395
|
-
projectName: (0,
|
|
141733
|
+
projectName: (0, import_path21.basename)(cwd),
|
|
141396
141734
|
branch: await readGitBranch2(cwd),
|
|
141397
141735
|
conversationId,
|
|
141398
141736
|
startedAt
|
|
@@ -141414,7 +141752,7 @@ async function discoverWindows() {
|
|
|
141414
141752
|
return {
|
|
141415
141753
|
pid,
|
|
141416
141754
|
projectPath: info.cwd,
|
|
141417
|
-
projectName: (0,
|
|
141755
|
+
projectName: (0, import_path21.basename)(info.cwd),
|
|
141418
141756
|
branch: await readGitBranch2(info.cwd),
|
|
141419
141757
|
conversationId: extractResumeId(info.args),
|
|
141420
141758
|
startedAt: info.startedAt
|
|
@@ -141495,7 +141833,7 @@ async function getProcessInfoWindows(pid) {
|
|
|
141495
141833
|
const startedAt = /* @__PURE__ */ new Date(`${year}-${month}-${day}T${hour}:${min}:${sec}`);
|
|
141496
141834
|
if (Number.isNaN(startedAt.getTime())) return null;
|
|
141497
141835
|
const exePath = parts[3] ?? "";
|
|
141498
|
-
const cwd = exePath ? (0,
|
|
141836
|
+
const cwd = exePath ? (0, import_path21.dirname)(exePath) : "";
|
|
141499
141837
|
return { cwd, args, startedAt };
|
|
141500
141838
|
} catch {
|
|
141501
141839
|
return null;
|
|
@@ -141536,13 +141874,13 @@ function seal(plaintext, recipientPublicKeyBase64) {
|
|
|
141536
141874
|
|
|
141537
141875
|
// node_modules/chokidar/index.js
|
|
141538
141876
|
var import_node_events2 = require("events");
|
|
141539
|
-
var
|
|
141877
|
+
var import_node_fs8 = require("fs");
|
|
141540
141878
|
var import_promises16 = require("fs/promises");
|
|
141541
141879
|
var sp2 = __toESM(require("path"), 1);
|
|
141542
141880
|
|
|
141543
141881
|
// node_modules/readdirp/index.js
|
|
141544
141882
|
var import_promises14 = require("fs/promises");
|
|
141545
|
-
var
|
|
141883
|
+
var import_node_path10 = require("path");
|
|
141546
141884
|
var import_node_stream2 = require("stream");
|
|
141547
141885
|
var EntryTypes2 = {
|
|
141548
141886
|
FILE_TYPE: "files",
|
|
@@ -141632,7 +141970,7 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
|
|
|
141632
141970
|
this._wantsDir = type ? DIR_TYPES2.has(type) : false;
|
|
141633
141971
|
this._wantsFile = type ? FILE_TYPES2.has(type) : false;
|
|
141634
141972
|
this._wantsEverything = type === EntryTypes2.EVERYTHING_TYPE;
|
|
141635
|
-
this._root = (0,
|
|
141973
|
+
this._root = (0, import_node_path10.resolve)(root);
|
|
141636
141974
|
this._isDirent = !opts.alwaysStat;
|
|
141637
141975
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
141638
141976
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
@@ -141703,8 +142041,8 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
|
|
|
141703
142041
|
let entry;
|
|
141704
142042
|
const basename12 = this._isDirent ? dirent.name : dirent;
|
|
141705
142043
|
try {
|
|
141706
|
-
const fullPath = (0,
|
|
141707
|
-
entry = { path: (0,
|
|
142044
|
+
const fullPath = (0, import_node_path10.resolve)((0, import_node_path10.join)(path2, basename12));
|
|
142045
|
+
entry = { path: (0, import_node_path10.relative)(this._root, fullPath), fullPath, basename: basename12 };
|
|
141708
142046
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
141709
142047
|
} catch (err) {
|
|
141710
142048
|
this._onError(err);
|
|
@@ -141738,7 +142076,7 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
|
|
|
141738
142076
|
}
|
|
141739
142077
|
if (entryRealPathStats.isDirectory()) {
|
|
141740
142078
|
const len = entryRealPath.length;
|
|
141741
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
142079
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path10.sep) {
|
|
141742
142080
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
141743
142081
|
recursiveError.code = RECURSIVE_ERROR_CODE2;
|
|
141744
142082
|
return this._onError(recursiveError);
|
|
@@ -141774,7 +142112,7 @@ function readdirp2(root, options = {}) {
|
|
|
141774
142112
|
}
|
|
141775
142113
|
|
|
141776
142114
|
// node_modules/chokidar/handler.js
|
|
141777
|
-
var
|
|
142115
|
+
var import_node_fs7 = require("fs");
|
|
141778
142116
|
var import_promises15 = require("fs/promises");
|
|
141779
142117
|
var import_node_os3 = require("os");
|
|
141780
142118
|
var sp = __toESM(require("path"), 1);
|
|
@@ -142112,7 +142450,7 @@ function createFsWatchInstance2(path2, options, listener, errHandler, emitRaw) {
|
|
|
142112
142450
|
}
|
|
142113
142451
|
};
|
|
142114
142452
|
try {
|
|
142115
|
-
return (0,
|
|
142453
|
+
return (0, import_node_fs7.watch)(path2, {
|
|
142116
142454
|
persistent: options.persistent
|
|
142117
142455
|
}, handleEvent);
|
|
142118
142456
|
} catch (error51) {
|
|
@@ -142195,7 +142533,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
|
|
|
142195
142533
|
let cont = FsWatchFileInstances2.get(fullPath);
|
|
142196
142534
|
const copts = cont && cont.options;
|
|
142197
142535
|
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
|
142198
|
-
(0,
|
|
142536
|
+
(0, import_node_fs7.unwatchFile)(fullPath);
|
|
142199
142537
|
cont = void 0;
|
|
142200
142538
|
}
|
|
142201
142539
|
if (cont) {
|
|
@@ -142206,7 +142544,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
|
|
|
142206
142544
|
listeners: listener,
|
|
142207
142545
|
rawEmitters: rawEmitter,
|
|
142208
142546
|
options,
|
|
142209
|
-
watcher: (0,
|
|
142547
|
+
watcher: (0, import_node_fs7.watchFile)(fullPath, options, (curr, prev) => {
|
|
142210
142548
|
foreach2(cont.rawEmitters, (rawEmitter2) => {
|
|
142211
142549
|
rawEmitter2(EV2.CHANGE, fullPath, { curr, prev });
|
|
142212
142550
|
});
|
|
@@ -142223,7 +142561,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
|
|
|
142223
142561
|
delFromSet2(cont, KEY_RAW2, rawEmitter);
|
|
142224
142562
|
if (isEmptySet2(cont.listeners)) {
|
|
142225
142563
|
FsWatchFileInstances2.delete(fullPath);
|
|
142226
|
-
(0,
|
|
142564
|
+
(0, import_node_fs7.unwatchFile)(fullPath);
|
|
142227
142565
|
cont.options = cont.watcher = void 0;
|
|
142228
142566
|
Object.freeze(cont);
|
|
142229
142567
|
}
|
|
@@ -142279,9 +142617,9 @@ var NodeFsHandler2 = class {
|
|
|
142279
142617
|
if (this.fsw.closed) {
|
|
142280
142618
|
return;
|
|
142281
142619
|
}
|
|
142282
|
-
const
|
|
142620
|
+
const dirname18 = sp.dirname(file2);
|
|
142283
142621
|
const basename12 = sp.basename(file2);
|
|
142284
|
-
const parent = this.fsw._getWatchedDir(
|
|
142622
|
+
const parent = this.fsw._getWatchedDir(dirname18);
|
|
142285
142623
|
let prevStats = stats;
|
|
142286
142624
|
if (parent.has(basename12))
|
|
142287
142625
|
return;
|
|
@@ -142308,7 +142646,7 @@ var NodeFsHandler2 = class {
|
|
|
142308
142646
|
prevStats = newStats2;
|
|
142309
142647
|
}
|
|
142310
142648
|
} catch (error51) {
|
|
142311
|
-
this.fsw._remove(
|
|
142649
|
+
this.fsw._remove(dirname18, basename12);
|
|
142312
142650
|
}
|
|
142313
142651
|
} else if (parent.has(basename12)) {
|
|
142314
142652
|
const at2 = newStats.atimeMs;
|
|
@@ -143093,7 +143431,7 @@ var FSWatcher2 = class extends import_node_events2.EventEmitter {
|
|
|
143093
143431
|
const now = /* @__PURE__ */ new Date();
|
|
143094
143432
|
const writes = this._pendingWrites;
|
|
143095
143433
|
function awaitWriteFinishFn(prevStat) {
|
|
143096
|
-
(0,
|
|
143434
|
+
(0, import_node_fs8.stat)(fullPath, (err, curStat) => {
|
|
143097
143435
|
if (err || !writes.has(path2)) {
|
|
143098
143436
|
if (err && err.code !== "ENOENT")
|
|
143099
143437
|
awfEmit(err);
|
|
@@ -143267,7 +143605,7 @@ function watch2(paths, options = {}) {
|
|
|
143267
143605
|
var chokidar_default = { watch: watch2, FSWatcher: FSWatcher2 };
|
|
143268
143606
|
|
|
143269
143607
|
// src/services/conversations/conversationWatcher.ts
|
|
143270
|
-
var
|
|
143608
|
+
var import_fs24 = require("fs");
|
|
143271
143609
|
var import_promises17 = require("fs/promises");
|
|
143272
143610
|
var ConversationWatcher = class {
|
|
143273
143611
|
files = /* @__PURE__ */ new Map();
|
|
@@ -143290,7 +143628,7 @@ var ConversationWatcher = class {
|
|
|
143290
143628
|
if (this.files.has(filePath)) return;
|
|
143291
143629
|
let offset;
|
|
143292
143630
|
try {
|
|
143293
|
-
offset = (0,
|
|
143631
|
+
offset = (0, import_fs24.statSync)(filePath).size;
|
|
143294
143632
|
} catch {
|
|
143295
143633
|
offset = 0;
|
|
143296
143634
|
}
|
|
@@ -143465,14 +143803,14 @@ function findSearchTarget(messages, query) {
|
|
|
143465
143803
|
}
|
|
143466
143804
|
|
|
143467
143805
|
// src/services/conversations/pruneAgentConversations.ts
|
|
143468
|
-
var
|
|
143806
|
+
var import_fs25 = require("fs");
|
|
143469
143807
|
function pruneAgentConversations(cache) {
|
|
143470
143808
|
const db = cache.getDatabase();
|
|
143471
143809
|
const rows = db.prepare("SELECT id, file_path FROM conversation_meta").all();
|
|
143472
143810
|
let pruned = 0;
|
|
143473
143811
|
let missing = 0;
|
|
143474
143812
|
for (const row of rows) {
|
|
143475
|
-
if (!(0,
|
|
143813
|
+
if (!(0, import_fs25.existsSync)(row.file_path)) {
|
|
143476
143814
|
missing += 1;
|
|
143477
143815
|
continue;
|
|
143478
143816
|
}
|
|
@@ -143841,7 +144179,7 @@ function discoveredToResponse(d, conversationId) {
|
|
|
143841
144179
|
var import_crypto10 = require("crypto");
|
|
143842
144180
|
var import_promises18 = require("fs/promises");
|
|
143843
144181
|
var import_heic_convert = __toESM(require_heic_convert(), 1);
|
|
143844
|
-
var
|
|
144182
|
+
var import_path22 = require("path");
|
|
143845
144183
|
var UPLOAD_DIR_NAME = ".threadbase-uploads";
|
|
143846
144184
|
var MAX_BYTES = 25 * 1024 * 1024;
|
|
143847
144185
|
var HEIC_MIMES = /* @__PURE__ */ new Set(["image/heic", "image/heif"]);
|
|
@@ -143874,9 +144212,9 @@ async function saveUploadFile(input) {
|
|
|
143874
144212
|
}
|
|
143875
144213
|
const id = `up_${(0, import_crypto10.randomBytes)(8).toString("hex")}`;
|
|
143876
144214
|
const safeName = sanitizeFilename(originalName) || `file${MIME_TO_EXT[mimeType] ?? ""}`;
|
|
143877
|
-
const dir = (0,
|
|
144215
|
+
const dir = (0, import_path22.join)(input.projectPath, UPLOAD_DIR_NAME, input.sessionId);
|
|
143878
144216
|
await (0, import_promises18.mkdir)(dir, { recursive: true });
|
|
143879
|
-
const filePath = (0,
|
|
144217
|
+
const filePath = (0, import_path22.join)(dir, `${Date.now()}-${id}-${safeName}`);
|
|
143880
144218
|
await (0, import_promises18.writeFile)(filePath, buffer);
|
|
143881
144219
|
return {
|
|
143882
144220
|
id,
|
|
@@ -144347,7 +144685,7 @@ var DEFAULT_PTY_GRACE_PERIOD_MS = 27e4;
|
|
|
144347
144685
|
var DEFAULT_WS_AUTH_TIMEOUT_MS = 5e3;
|
|
144348
144686
|
var WS_CLOSE_UNAUTHORIZED = 4401;
|
|
144349
144687
|
var REFRESH_TTL_MS = 2e3;
|
|
144350
|
-
var START_READY_TIMEOUT_MS =
|
|
144688
|
+
var START_READY_TIMEOUT_MS = 1e4;
|
|
144351
144689
|
function parseIncludeAgentsEnv(raw2) {
|
|
144352
144690
|
if (raw2 === void 0) return false;
|
|
144353
144691
|
const v2 = raw2.trim().toLowerCase();
|
|
@@ -144481,12 +144819,12 @@ var StreamerServer = class {
|
|
|
144481
144819
|
this.disableDb = config2.disableDb ?? false;
|
|
144482
144820
|
this.scannerPersistenceDisabled = config2.scannerPersistent === false;
|
|
144483
144821
|
this.scanProfiles = config2.scanProfiles;
|
|
144484
|
-
this.codexRoots = config2.codexRoots ?? [(0,
|
|
144822
|
+
this.codexRoots = config2.codexRoots ?? [(0, import_path23.join)((0, import_os11.homedir)(), ".codex", "sessions")];
|
|
144485
144823
|
this.ptyGracePeriodMs = config2.ptyGracePeriodMs ?? DEFAULT_PTY_GRACE_PERIOD_MS;
|
|
144486
144824
|
this.wsAuthTimeoutMs = config2.wsAuthTimeoutMs ?? DEFAULT_WS_AUTH_TIMEOUT_MS;
|
|
144487
144825
|
this.defaultSystemPrompt = config2.defaultSystemPrompt ?? DEFAULT_SYSTEM_PROMPT;
|
|
144488
144826
|
this.defaultPermissionMode = config2.defaultPermissionMode ?? loadDefaultPermissionMode() ?? "acceptEdits";
|
|
144489
|
-
this.cacheDir = config2.cacheDir ?? loadCacheDir() ?? (0,
|
|
144827
|
+
this.cacheDir = config2.cacheDir ?? loadCacheDir() ?? (0, import_path23.join)((0, import_os11.homedir)(), ".threadbase", "cache");
|
|
144490
144828
|
this.tailSize = config2.tailSize ?? loadTailSize() ?? 10;
|
|
144491
144829
|
this.directoryDebounceMs = parseDirScanDebounceEnv(process.env.THREADBASE_DIR_SCAN_DEBOUNCE_MS) ?? config2.directoryScanDebounceMs ?? 1e3;
|
|
144492
144830
|
this.markScannerStaleDebounced = debounce(() => {
|
|
@@ -144527,7 +144865,7 @@ var StreamerServer = class {
|
|
|
144527
144865
|
const seqs = cache.extendMessageIndex(
|
|
144528
144866
|
filePath,
|
|
144529
144867
|
spans,
|
|
144530
|
-
(0,
|
|
144868
|
+
(0, import_fs26.statSync)(filePath),
|
|
144531
144869
|
readFrom,
|
|
144532
144870
|
endOffset
|
|
144533
144871
|
);
|
|
@@ -144688,7 +145026,7 @@ var StreamerServer = class {
|
|
|
144688
145026
|
temporalClient,
|
|
144689
145027
|
taskQueue: agentConfig.temporal.taskQueue
|
|
144690
145028
|
});
|
|
144691
|
-
const conversationsBaseDir = agentConfig.conversationsDir || (0,
|
|
145029
|
+
const conversationsBaseDir = agentConfig.conversationsDir || (0, import_path23.join)((0, import_path23.dirname)(this.cacheDir), "conversations");
|
|
144692
145030
|
conversationWriter = createConversationWriter({
|
|
144693
145031
|
baseDir: conversationsBaseDir
|
|
144694
145032
|
});
|
|
@@ -144786,6 +145124,38 @@ var StreamerServer = class {
|
|
|
144786
145124
|
const lines = await this.ptyManager.getOutputLines(msg.sessionId, 200);
|
|
144787
145125
|
ws2.send(JSON.stringify({ type: "terminal_replay", sessionId: msg.sessionId, lines }));
|
|
144788
145126
|
}
|
|
145127
|
+
const pendingGate = this.pendingPermission.get(msg.sessionId);
|
|
145128
|
+
if (pendingGate) {
|
|
145129
|
+
this.log.info(`[ws.replay_permission] ${msg.sessionId.slice(0, 8)}`, {
|
|
145130
|
+
event: "ws.replay_permission",
|
|
145131
|
+
sessionId: msg.sessionId
|
|
145132
|
+
});
|
|
145133
|
+
ws2.send(
|
|
145134
|
+
JSON.stringify({
|
|
145135
|
+
type: "permission",
|
|
145136
|
+
sessionId: msg.sessionId,
|
|
145137
|
+
...pendingGate.prompt ? { prompt: pendingGate.prompt } : {},
|
|
145138
|
+
...pendingGate.detail ? { detail: pendingGate.detail } : {},
|
|
145139
|
+
options: pendingGate.options,
|
|
145140
|
+
...pendingGate.cursor !== void 0 ? { cursor: pendingGate.cursor } : {}
|
|
145141
|
+
})
|
|
145142
|
+
);
|
|
145143
|
+
}
|
|
145144
|
+
const pendingQuestion = this.pendingQuestions.get(msg.sessionId);
|
|
145145
|
+
if (pendingQuestion) {
|
|
145146
|
+
this.log.info(`[ws.replay_question] ${msg.sessionId.slice(0, 8)}`, {
|
|
145147
|
+
event: "ws.replay_question",
|
|
145148
|
+
sessionId: msg.sessionId
|
|
145149
|
+
});
|
|
145150
|
+
ws2.send(
|
|
145151
|
+
JSON.stringify({
|
|
145152
|
+
type: "question",
|
|
145153
|
+
sessionId: msg.sessionId,
|
|
145154
|
+
toolUseId: pendingQuestion.toolUseId,
|
|
145155
|
+
questions: pendingQuestion.questions
|
|
145156
|
+
})
|
|
145157
|
+
);
|
|
145158
|
+
}
|
|
144789
145159
|
}
|
|
144790
145160
|
if (msg.type === "hold_session" && typeof msg.sessionId === "string") {
|
|
144791
145161
|
if (this.sessionSubscribers.get(msg.sessionId)?.has(ws2)) {
|
|
@@ -144956,7 +145326,7 @@ var StreamerServer = class {
|
|
|
144956
145326
|
});
|
|
144957
145327
|
try {
|
|
144958
145328
|
this.cache = ConversationCache.open(
|
|
144959
|
-
(0,
|
|
145329
|
+
(0, import_path23.join)(this.cacheDir, "cache.db"),
|
|
144960
145330
|
this.tailSize,
|
|
144961
145331
|
void 0,
|
|
144962
145332
|
{
|
|
@@ -144982,11 +145352,11 @@ var StreamerServer = class {
|
|
|
144982
145352
|
if (this.scanProfiles && this.scanProfiles.length > 0) {
|
|
144983
145353
|
for (const profile of this.scanProfiles) {
|
|
144984
145354
|
if (profile.enabled) {
|
|
144985
|
-
this.fileWatcher.watchDirectory((0,
|
|
145355
|
+
this.fileWatcher.watchDirectory((0, import_path23.join)(profile.configDir, "projects"));
|
|
144986
145356
|
}
|
|
144987
145357
|
}
|
|
144988
145358
|
} else {
|
|
144989
|
-
this.fileWatcher.watchDirectory((0,
|
|
145359
|
+
this.fileWatcher.watchDirectory((0, import_path23.join)((0, import_os11.homedir)(), ".claude", "projects"));
|
|
144990
145360
|
}
|
|
144991
145361
|
} catch (err) {
|
|
144992
145362
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -145571,17 +145941,17 @@ var StreamerServer = class {
|
|
|
145571
145941
|
return scanner;
|
|
145572
145942
|
}
|
|
145573
145943
|
findJsonlPath(uuid3) {
|
|
145574
|
-
const projectsDir = (0,
|
|
145575
|
-
if (!(0,
|
|
145944
|
+
const projectsDir = (0, import_path23.join)((0, import_os11.homedir)(), ".claude", "projects");
|
|
145945
|
+
if (!(0, import_fs26.existsSync)(projectsDir)) return null;
|
|
145576
145946
|
const filename = `${uuid3}.jsonl`;
|
|
145577
|
-
for (const dir of (0,
|
|
145578
|
-
const fp = (0,
|
|
145579
|
-
if ((0,
|
|
145580
|
-
const projectDir = (0,
|
|
145947
|
+
for (const dir of (0, import_fs26.readdirSync)(projectsDir)) {
|
|
145948
|
+
const fp = (0, import_path23.join)(projectsDir, dir, filename);
|
|
145949
|
+
if ((0, import_fs26.existsSync)(fp)) return fp;
|
|
145950
|
+
const projectDir = (0, import_path23.join)(projectsDir, dir);
|
|
145581
145951
|
try {
|
|
145582
|
-
for (const sub of (0,
|
|
145583
|
-
const subagentPath = (0,
|
|
145584
|
-
if ((0,
|
|
145952
|
+
for (const sub of (0, import_fs26.readdirSync)(projectDir)) {
|
|
145953
|
+
const subagentPath = (0, import_path23.join)(projectDir, sub, "subagents", filename);
|
|
145954
|
+
if ((0, import_fs26.existsSync)(subagentPath)) return subagentPath;
|
|
145585
145955
|
}
|
|
145586
145956
|
} catch {
|
|
145587
145957
|
}
|
|
@@ -145590,7 +145960,7 @@ var StreamerServer = class {
|
|
|
145590
145960
|
}
|
|
145591
145961
|
async readCwdFromJsonl(filePath) {
|
|
145592
145962
|
return new Promise((resolve6) => {
|
|
145593
|
-
const rl = (0, import_readline4.createInterface)({ input: (0,
|
|
145963
|
+
const rl = (0, import_readline4.createInterface)({ input: (0, import_fs26.createReadStream)(filePath), crlfDelay: Infinity });
|
|
145594
145964
|
let found = false;
|
|
145595
145965
|
rl.on("line", (line) => {
|
|
145596
145966
|
if (found) return;
|
|
@@ -145728,7 +146098,7 @@ var StreamerServer = class {
|
|
|
145728
146098
|
if (!conv.filePath) return false;
|
|
145729
146099
|
let mtimeMs = null;
|
|
145730
146100
|
try {
|
|
145731
|
-
mtimeMs = (0,
|
|
146101
|
+
mtimeMs = (0, import_fs26.statSync)(conv.filePath).mtimeMs;
|
|
145732
146102
|
} catch {
|
|
145733
146103
|
return false;
|
|
145734
146104
|
}
|
|
@@ -146096,7 +146466,7 @@ var StreamerServer = class {
|
|
|
146096
146466
|
handleGetSession(sessionId, res) {
|
|
146097
146467
|
const session = this.sessionStore.get(sessionId, this.ptyAttachedIds());
|
|
146098
146468
|
if (session) {
|
|
146099
|
-
if (!(0,
|
|
146469
|
+
if (!(0, import_fs26.existsSync)(session.projectPath)) {
|
|
146100
146470
|
session.failureReason = `Project directory not found: ${session.projectPath}`;
|
|
146101
146471
|
}
|
|
146102
146472
|
json2(res, 200, session);
|
|
@@ -146304,6 +146674,11 @@ var StreamerServer = class {
|
|
|
146304
146674
|
const answerKeys = sanitizeAnswerKeys(o.answerKeys);
|
|
146305
146675
|
return answerKeys === void 0 ? { index: o.index, label: o.label } : { ...o, answerKeys };
|
|
146306
146676
|
});
|
|
146677
|
+
const subscriberCount = this.sessionSubscribers.get(sessionId)?.size ?? 0;
|
|
146678
|
+
this.log.info(
|
|
146679
|
+
`[ws.broadcast_permission] ${sessionId.slice(0, 8)} subscribers=${subscriberCount}`,
|
|
146680
|
+
{ event: "ws.broadcast_permission", sessionId, subscriberCount }
|
|
146681
|
+
);
|
|
146307
146682
|
this.wsHub.broadcast({
|
|
146308
146683
|
type: "permission",
|
|
146309
146684
|
sessionId,
|
|
@@ -146496,7 +146871,7 @@ var StreamerServer = class {
|
|
|
146496
146871
|
sessionStore: this.sessionStore,
|
|
146497
146872
|
// biome-ignore lint/style/noNonNullAssertion: agentClient is set when agentConfig.enabled is true
|
|
146498
146873
|
agentClient: this.agentClient,
|
|
146499
|
-
conversationsDir: this.cacheDir ? (0,
|
|
146874
|
+
conversationsDir: this.cacheDir ? (0, import_path23.join)((0, import_path23.dirname)(this.cacheDir), "conversations") : "",
|
|
146500
146875
|
agentConfig: this.agentConfig
|
|
146501
146876
|
});
|
|
146502
146877
|
json2(res, result.status, result.body);
|
|
@@ -146637,9 +147012,9 @@ var StreamerServer = class {
|
|
|
146637
147012
|
// was passed to Claude via --session-id so the filename matches from the start.
|
|
146638
147013
|
watchForJsonl(sessionId, projectPath) {
|
|
146639
147014
|
const encoded = projectPath.replace(/[/\\:.]/g, "-");
|
|
146640
|
-
const projectsDir = (0,
|
|
147015
|
+
const projectsDir = (0, import_path23.join)((0, import_os11.homedir)(), ".claude", "projects", encoded);
|
|
146641
147016
|
const expectedFile = `${sessionId}.jsonl`;
|
|
146642
|
-
const filePath = (0,
|
|
147017
|
+
const filePath = (0, import_path23.join)(projectsDir, expectedFile);
|
|
146643
147018
|
const deadline = Date.now() + 12e4;
|
|
146644
147019
|
let watcher = null;
|
|
146645
147020
|
const cleanup = () => {
|
|
@@ -146657,12 +147032,12 @@ var StreamerServer = class {
|
|
|
146657
147032
|
cleanup();
|
|
146658
147033
|
return;
|
|
146659
147034
|
}
|
|
146660
|
-
let resolvedFilePath = (0,
|
|
146661
|
-
if (!resolvedFilePath && (0,
|
|
147035
|
+
let resolvedFilePath = (0, import_fs26.existsSync)(filePath) ? filePath : null;
|
|
147036
|
+
if (!resolvedFilePath && (0, import_fs26.existsSync)(projectsDir)) {
|
|
146662
147037
|
try {
|
|
146663
147038
|
const now = Date.now();
|
|
146664
|
-
const recent = (0,
|
|
146665
|
-
if (recent) resolvedFilePath = (0,
|
|
147039
|
+
const recent = (0, import_fs26.readdirSync)(projectsDir).filter((f2) => f2.endsWith(".jsonl")).map((f2) => ({ f: f2, mtime: (0, import_fs26.statSync)((0, import_path23.join)(projectsDir, f2)).mtimeMs })).filter(({ mtime }) => now - mtime < 5e3).sort((a, b2) => b2.mtime - a.mtime)[0];
|
|
147040
|
+
if (recent) resolvedFilePath = (0, import_path23.join)(projectsDir, recent.f);
|
|
146666
147041
|
} catch {
|
|
146667
147042
|
}
|
|
146668
147043
|
}
|
|
@@ -146671,7 +147046,7 @@ var StreamerServer = class {
|
|
|
146671
147046
|
this.sessionFileMap.set(sessionId, resolvedFilePath);
|
|
146672
147047
|
this.fileWatcher.watch(resolvedFilePath);
|
|
146673
147048
|
try {
|
|
146674
|
-
const existing = (0,
|
|
147049
|
+
const existing = (0, import_fs26.readFileSync)(resolvedFilePath, "utf8").split("\n").filter(Boolean);
|
|
146675
147050
|
if (existing.length > 0) {
|
|
146676
147051
|
this.broadcastConversationLines(sessionId, existing);
|
|
146677
147052
|
}
|
|
@@ -146694,7 +147069,7 @@ var StreamerServer = class {
|
|
|
146694
147069
|
if (this.sessionFileMap.has(sessionId)) return;
|
|
146695
147070
|
try {
|
|
146696
147071
|
require("fs").mkdirSync(projectsDir, { recursive: true });
|
|
146697
|
-
watcher = (0,
|
|
147072
|
+
watcher = (0, import_fs26.watch)(projectsDir, tryWire);
|
|
146698
147073
|
watcher.on("error", cleanup);
|
|
146699
147074
|
} catch {
|
|
146700
147075
|
}
|
|
@@ -146710,7 +147085,7 @@ var StreamerServer = class {
|
|
|
146710
147085
|
watchForCodexRollout(sessionId, projectPath) {
|
|
146711
147086
|
const deadline = Date.now() + 12e4;
|
|
146712
147087
|
const now = /* @__PURE__ */ new Date();
|
|
146713
|
-
const dateDir = (0,
|
|
147088
|
+
const dateDir = (0, import_path23.join)(
|
|
146714
147089
|
String(now.getFullYear()),
|
|
146715
147090
|
String(now.getMonth() + 1).padStart(2, "0"),
|
|
146716
147091
|
String(now.getDate()).padStart(2, "0")
|
|
@@ -146723,7 +147098,7 @@ var StreamerServer = class {
|
|
|
146723
147098
|
};
|
|
146724
147099
|
const matchesProjectPath = (candidatePath) => {
|
|
146725
147100
|
try {
|
|
146726
|
-
const firstLine = (0,
|
|
147101
|
+
const firstLine = (0, import_fs26.readFileSync)(candidatePath, "utf8").split("\n", 1)[0];
|
|
146727
147102
|
if (!firstLine) return null;
|
|
146728
147103
|
const parsed = JSON.parse(firstLine);
|
|
146729
147104
|
if (parsed?.type !== "session_meta") return null;
|
|
@@ -146751,18 +147126,18 @@ var StreamerServer = class {
|
|
|
146751
147126
|
this.sessionStore.listManaged().filter((s3) => s3.id !== sessionId && s3.boundConversationId != null).map((s3) => s3.boundConversationId)
|
|
146752
147127
|
);
|
|
146753
147128
|
for (const root of this.codexRoots) {
|
|
146754
|
-
const sessionsDir = (0,
|
|
146755
|
-
if (!(0,
|
|
147129
|
+
const sessionsDir = (0, import_path23.join)(root, dateDir);
|
|
147130
|
+
if (!(0, import_fs26.existsSync)(sessionsDir)) continue;
|
|
146756
147131
|
let candidateFiles;
|
|
146757
147132
|
try {
|
|
146758
|
-
candidateFiles = (0,
|
|
147133
|
+
candidateFiles = (0, import_fs26.readdirSync)(sessionsDir).filter((f2) => f2.endsWith(".jsonl"));
|
|
146759
147134
|
} catch {
|
|
146760
147135
|
continue;
|
|
146761
147136
|
}
|
|
146762
147137
|
const nowMs = Date.now();
|
|
146763
|
-
const recentCandidates = candidateFiles.map((f2) => ({ f: f2, mtime: (0,
|
|
147138
|
+
const recentCandidates = candidateFiles.map((f2) => ({ f: f2, mtime: (0, import_fs26.statSync)((0, import_path23.join)(sessionsDir, f2)).mtimeMs })).filter(({ mtime }) => nowMs - mtime < 1e4).sort((a, b2) => b2.mtime - a.mtime);
|
|
146764
147139
|
for (const { f: f2 } of recentCandidates) {
|
|
146765
|
-
const candidatePath = (0,
|
|
147140
|
+
const candidatePath = (0, import_path23.join)(sessionsDir, f2);
|
|
146766
147141
|
const match2 = matchesProjectPath(candidatePath);
|
|
146767
147142
|
if (!match2) continue;
|
|
146768
147143
|
if (boundElsewhere.has(match2.id)) continue;
|
|
@@ -146772,7 +147147,7 @@ var StreamerServer = class {
|
|
|
146772
147147
|
this.sessionFileMap.set(sessionId, candidatePath);
|
|
146773
147148
|
this.fileWatcher.watch(candidatePath);
|
|
146774
147149
|
try {
|
|
146775
|
-
const existing = (0,
|
|
147150
|
+
const existing = (0, import_fs26.readFileSync)(candidatePath, "utf8").split("\n").filter(Boolean);
|
|
146776
147151
|
if (existing.length > 0) {
|
|
146777
147152
|
this.broadcastConversationLines(sessionId, existing);
|
|
146778
147153
|
}
|
|
@@ -146894,7 +147269,7 @@ var StreamerServer = class {
|
|
|
146894
147269
|
};
|
|
146895
147270
|
function classifyResumability(cwd) {
|
|
146896
147271
|
if (!cwd) return { resumable: true };
|
|
146897
|
-
if ((0,
|
|
147272
|
+
if ((0, import_fs26.existsSync)(cwd)) return { resumable: true };
|
|
146898
147273
|
const ranInWorktree = /\/\.worktrees\//.test(cwd) || /\/\.claude\/worktrees\//.test(cwd);
|
|
146899
147274
|
return {
|
|
146900
147275
|
resumable: false,
|
|
@@ -147158,7 +147533,7 @@ async function checkForUpdate(opts) {
|
|
|
147158
147533
|
}
|
|
147159
147534
|
|
|
147160
147535
|
// src/updater/install.ts
|
|
147161
|
-
var
|
|
147536
|
+
var import_node_fs20 = require("fs");
|
|
147162
147537
|
|
|
147163
147538
|
// src/updater/active-sessions.ts
|
|
147164
147539
|
async function countActiveSessions(opts) {
|
|
@@ -147211,8 +147586,8 @@ function isBrewInstall(scriptPath = process.argv[1] ?? "") {
|
|
|
147211
147586
|
|
|
147212
147587
|
// src/updater/download.ts
|
|
147213
147588
|
var import_node_crypto4 = require("crypto");
|
|
147214
|
-
var
|
|
147215
|
-
var
|
|
147589
|
+
var import_node_fs9 = require("fs");
|
|
147590
|
+
var import_node_path11 = require("path");
|
|
147216
147591
|
var import_promises20 = require("stream/promises");
|
|
147217
147592
|
|
|
147218
147593
|
// src/updater/manifest.ts
|
|
@@ -147272,13 +147647,13 @@ async function downloadAndVerify(opts) {
|
|
|
147272
147647
|
`Manifest references ${artifact.filename} but it is not attached to the release`
|
|
147273
147648
|
);
|
|
147274
147649
|
}
|
|
147275
|
-
(0,
|
|
147650
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path11.dirname)(targetPath), { recursive: true });
|
|
147276
147651
|
const res = await fetch(asset.browserDownloadUrl);
|
|
147277
147652
|
if (!res.ok || !res.body) {
|
|
147278
147653
|
throw new Error(`Failed to download ${artifact.filename}: ${res.status} ${res.statusText}`);
|
|
147279
147654
|
}
|
|
147280
147655
|
const hash2 = (0, import_node_crypto4.createHash)("sha256");
|
|
147281
|
-
const out = (0,
|
|
147656
|
+
const out = (0, import_node_fs9.createWriteStream)(targetPath);
|
|
147282
147657
|
let bytes = 0;
|
|
147283
147658
|
const measured = new TransformStream({
|
|
147284
147659
|
transform(chunk, controller) {
|
|
@@ -147290,19 +147665,19 @@ async function downloadAndVerify(opts) {
|
|
|
147290
147665
|
try {
|
|
147291
147666
|
await (0, import_promises20.pipeline)(res.body.pipeThrough(measured), out);
|
|
147292
147667
|
} catch (err) {
|
|
147293
|
-
(0,
|
|
147668
|
+
(0, import_node_fs9.rmSync)(targetPath, { force: true });
|
|
147294
147669
|
throw err;
|
|
147295
147670
|
}
|
|
147296
147671
|
const actual = hash2.digest("hex");
|
|
147297
147672
|
if (actual !== artifact.sha256) {
|
|
147298
|
-
(0,
|
|
147673
|
+
(0, import_node_fs9.rmSync)(targetPath, { force: true });
|
|
147299
147674
|
throw new Error(
|
|
147300
147675
|
`sha256 mismatch for ${artifact.filename}: expected ${artifact.sha256}, got ${actual}`
|
|
147301
147676
|
);
|
|
147302
147677
|
}
|
|
147303
|
-
const stat10 = (0,
|
|
147678
|
+
const stat10 = (0, import_node_fs9.statSync)(targetPath);
|
|
147304
147679
|
if (stat10.size !== artifact.size) {
|
|
147305
|
-
(0,
|
|
147680
|
+
(0, import_node_fs9.rmSync)(targetPath, { force: true });
|
|
147306
147681
|
throw new Error(
|
|
147307
147682
|
`size mismatch for ${artifact.filename}: expected ${artifact.size}, got ${stat10.size}`
|
|
147308
147683
|
);
|
|
@@ -147312,16 +147687,16 @@ async function downloadAndVerify(opts) {
|
|
|
147312
147687
|
|
|
147313
147688
|
// src/updater/paths.ts
|
|
147314
147689
|
var import_node_os4 = require("os");
|
|
147315
|
-
var
|
|
147316
|
-
var THREADBASE_ROOT = (0,
|
|
147317
|
-
var RELEASES_DIR = (0,
|
|
147318
|
-
var CURRENT_SYMLINK = (0,
|
|
147319
|
-
var DOWNLOAD_DIR = (0,
|
|
147690
|
+
var import_node_path12 = require("path");
|
|
147691
|
+
var THREADBASE_ROOT = (0, import_node_path12.join)((0, import_node_os4.homedir)(), ".threadbase");
|
|
147692
|
+
var RELEASES_DIR = (0, import_node_path12.join)(THREADBASE_ROOT, "releases");
|
|
147693
|
+
var CURRENT_SYMLINK = (0, import_node_path12.join)(THREADBASE_ROOT, "current");
|
|
147694
|
+
var DOWNLOAD_DIR = (0, import_node_path12.join)(THREADBASE_ROOT, "releases", ".tmp");
|
|
147320
147695
|
function releaseDir(version2) {
|
|
147321
|
-
return (0,
|
|
147696
|
+
return (0, import_node_path12.join)(RELEASES_DIR, version2);
|
|
147322
147697
|
}
|
|
147323
147698
|
function downloadPath(version2, filename) {
|
|
147324
|
-
return (0,
|
|
147699
|
+
return (0, import_node_path12.join)(DOWNLOAD_DIR, `${version2}-${filename}`);
|
|
147325
147700
|
}
|
|
147326
147701
|
|
|
147327
147702
|
// src/updater/restart.ts
|
|
@@ -147402,111 +147777,111 @@ async function stopService(opts = {}) {
|
|
|
147402
147777
|
}
|
|
147403
147778
|
|
|
147404
147779
|
// src/updater/stamp-version.ts
|
|
147405
|
-
var
|
|
147406
|
-
var
|
|
147780
|
+
var import_node_fs10 = require("fs");
|
|
147781
|
+
var import_node_path13 = require("path");
|
|
147407
147782
|
function stampVersionTxt(destDir, version2) {
|
|
147408
|
-
const distDir = (0,
|
|
147409
|
-
(0,
|
|
147410
|
-
(0,
|
|
147783
|
+
const distDir = (0, import_node_path13.join)(destDir, "dist");
|
|
147784
|
+
(0, import_node_fs10.mkdirSync)(distDir, { recursive: true });
|
|
147785
|
+
(0, import_node_fs10.writeFileSync)((0, import_node_path13.join)(distDir, "version.txt"), `${version2}+update
|
|
147411
147786
|
`);
|
|
147412
147787
|
}
|
|
147413
147788
|
|
|
147414
147789
|
// src/updater/swap.ts
|
|
147415
|
-
var
|
|
147416
|
-
var
|
|
147790
|
+
var import_node_fs11 = require("fs");
|
|
147791
|
+
var import_node_path14 = require("path");
|
|
147417
147792
|
var import_semver2 = __toESM(require_semver2(), 1);
|
|
147418
147793
|
var KEEP_LAST_N = 2;
|
|
147419
147794
|
function swapCurrent(version2) {
|
|
147420
147795
|
const target = releaseDir(version2);
|
|
147421
|
-
if (!(0,
|
|
147796
|
+
if (!(0, import_node_fs11.existsSync)(target)) {
|
|
147422
147797
|
throw new Error(`Cannot swap to ${version2}: ${target} does not exist`);
|
|
147423
147798
|
}
|
|
147424
147799
|
if (process.platform === "win32") {
|
|
147425
147800
|
const tmp = `${CURRENT_SYMLINK}.new`;
|
|
147426
|
-
(0,
|
|
147427
|
-
(0,
|
|
147428
|
-
if ((0,
|
|
147429
|
-
(0,
|
|
147801
|
+
(0, import_node_fs11.rmSync)(tmp, { recursive: true, force: true });
|
|
147802
|
+
(0, import_node_fs11.cpSync)(target, tmp, { recursive: true });
|
|
147803
|
+
if ((0, import_node_fs11.existsSync)(CURRENT_SYMLINK)) {
|
|
147804
|
+
(0, import_node_fs11.rmSync)(CURRENT_SYMLINK, { recursive: true, force: true });
|
|
147430
147805
|
}
|
|
147431
|
-
(0,
|
|
147432
|
-
(0,
|
|
147806
|
+
(0, import_node_fs11.renameSync)(tmp, CURRENT_SYMLINK);
|
|
147807
|
+
(0, import_node_fs11.copyFileSync)((0, import_node_path14.join)(CURRENT_SYMLINK, "dist", "cli.cjs"), (0, import_node_path14.join)(THREADBASE_ROOT, "cli.js"));
|
|
147433
147808
|
return;
|
|
147434
147809
|
}
|
|
147435
147810
|
const tmpLink = `${CURRENT_SYMLINK}.new`;
|
|
147436
|
-
if ((0,
|
|
147437
|
-
(0,
|
|
147811
|
+
if ((0, import_node_fs11.existsSync)(tmpLink) || lstatSafeIsSymlink(tmpLink)) {
|
|
147812
|
+
(0, import_node_fs11.unlinkSync)(tmpLink);
|
|
147438
147813
|
}
|
|
147439
|
-
(0,
|
|
147440
|
-
(0,
|
|
147441
|
-
const cliJs = (0,
|
|
147814
|
+
(0, import_node_fs11.symlinkSync)(target, tmpLink);
|
|
147815
|
+
(0, import_node_fs11.renameSync)(tmpLink, CURRENT_SYMLINK);
|
|
147816
|
+
const cliJs = (0, import_node_path14.join)(THREADBASE_ROOT, "cli.js");
|
|
147442
147817
|
const tmpCliJs = `${cliJs}.new`;
|
|
147443
|
-
if ((0,
|
|
147444
|
-
(0,
|
|
147445
|
-
(0,
|
|
147818
|
+
if ((0, import_node_fs11.existsSync)(tmpCliJs) || lstatSafeIsSymlink(tmpCliJs)) (0, import_node_fs11.unlinkSync)(tmpCliJs);
|
|
147819
|
+
(0, import_node_fs11.symlinkSync)((0, import_node_path14.join)(target, "dist", "cli.cjs"), tmpCliJs);
|
|
147820
|
+
(0, import_node_fs11.renameSync)(tmpCliJs, cliJs);
|
|
147446
147821
|
}
|
|
147447
147822
|
function lstatSafeIsSymlink(path2) {
|
|
147448
147823
|
try {
|
|
147449
|
-
return (0,
|
|
147824
|
+
return (0, import_node_fs11.lstatSync)(path2).isSymbolicLink();
|
|
147450
147825
|
} catch {
|
|
147451
147826
|
return false;
|
|
147452
147827
|
}
|
|
147453
147828
|
}
|
|
147454
147829
|
function pruneOldReleases(activeVersion, keep = KEEP_LAST_N) {
|
|
147455
|
-
if (!(0,
|
|
147456
|
-
const entries = (0,
|
|
147830
|
+
if (!(0, import_node_fs11.existsSync)(RELEASES_DIR)) return [];
|
|
147831
|
+
const entries = (0, import_node_fs11.readdirSync)(RELEASES_DIR, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).filter((name) => import_semver2.default.valid(name) !== null);
|
|
147457
147832
|
const sorted = entries.sort((a, b2) => import_semver2.default.rcompare(a, b2));
|
|
147458
147833
|
const toKeep = new Set(sorted.slice(0, keep));
|
|
147459
147834
|
toKeep.add(activeVersion);
|
|
147460
147835
|
const removed = [];
|
|
147461
147836
|
for (const name of sorted) {
|
|
147462
147837
|
if (toKeep.has(name)) continue;
|
|
147463
|
-
(0,
|
|
147838
|
+
(0, import_node_fs11.rmSync)(releaseDir(name), { recursive: true, force: true });
|
|
147464
147839
|
removed.push(name);
|
|
147465
147840
|
}
|
|
147466
147841
|
return removed;
|
|
147467
147842
|
}
|
|
147468
147843
|
function ensureReleasesDir() {
|
|
147469
|
-
(0,
|
|
147844
|
+
(0, import_node_fs11.mkdirSync)(RELEASES_DIR, { recursive: true });
|
|
147470
147845
|
}
|
|
147471
147846
|
|
|
147472
147847
|
// src/updater/unpack.ts
|
|
147473
|
-
var
|
|
147848
|
+
var import_node_fs18 = require("fs");
|
|
147474
147849
|
|
|
147475
147850
|
// node_modules/tar/dist/esm/index.min.js
|
|
147476
147851
|
var import_events4 = __toESM(require("events"), 1);
|
|
147477
|
-
var
|
|
147852
|
+
var import_fs27 = __toESM(require("fs"), 1);
|
|
147478
147853
|
var import_node_events3 = require("events");
|
|
147479
147854
|
var import_node_stream3 = __toESM(require("stream"), 1);
|
|
147480
147855
|
var import_node_string_decoder = require("string_decoder");
|
|
147481
|
-
var
|
|
147482
|
-
var
|
|
147483
|
-
var
|
|
147856
|
+
var import_node_path15 = __toESM(require("path"), 1);
|
|
147857
|
+
var import_node_fs12 = __toESM(require("fs"), 1);
|
|
147858
|
+
var import_path24 = require("path");
|
|
147484
147859
|
var import_events5 = require("events");
|
|
147485
147860
|
var import_assert = __toESM(require("assert"), 1);
|
|
147486
147861
|
var import_buffer2 = require("buffer");
|
|
147487
147862
|
var Ps = __toESM(require("zlib"), 1);
|
|
147488
147863
|
var import_zlib = __toESM(require("zlib"), 1);
|
|
147489
|
-
var import_node_path15 = require("path");
|
|
147490
147864
|
var import_node_path16 = require("path");
|
|
147491
|
-
var import_fs27 = __toESM(require("fs"), 1);
|
|
147492
|
-
var import_fs28 = __toESM(require("fs"), 1);
|
|
147493
|
-
var import_path24 = __toESM(require("path"), 1);
|
|
147494
147865
|
var import_node_path17 = require("path");
|
|
147866
|
+
var import_fs28 = __toESM(require("fs"), 1);
|
|
147867
|
+
var import_fs29 = __toESM(require("fs"), 1);
|
|
147495
147868
|
var import_path25 = __toESM(require("path"), 1);
|
|
147496
|
-
var
|
|
147869
|
+
var import_node_path18 = require("path");
|
|
147870
|
+
var import_path26 = __toESM(require("path"), 1);
|
|
147871
|
+
var import_node_fs13 = __toESM(require("fs"), 1);
|
|
147497
147872
|
var import_node_assert = __toESM(require("assert"), 1);
|
|
147498
147873
|
var import_node_crypto5 = require("crypto");
|
|
147499
|
-
var import_node_fs13 = __toESM(require("fs"), 1);
|
|
147500
|
-
var import_node_path18 = __toESM(require("path"), 1);
|
|
147501
|
-
var import_fs29 = __toESM(require("fs"), 1);
|
|
147502
147874
|
var import_node_fs14 = __toESM(require("fs"), 1);
|
|
147503
147875
|
var import_node_path19 = __toESM(require("path"), 1);
|
|
147876
|
+
var import_fs30 = __toESM(require("fs"), 1);
|
|
147504
147877
|
var import_node_fs15 = __toESM(require("fs"), 1);
|
|
147505
|
-
var import_promises21 = __toESM(require("fs/promises"), 1);
|
|
147506
147878
|
var import_node_path20 = __toESM(require("path"), 1);
|
|
147507
|
-
var import_node_path21 = require("path");
|
|
147508
147879
|
var import_node_fs16 = __toESM(require("fs"), 1);
|
|
147509
|
-
var
|
|
147880
|
+
var import_promises21 = __toESM(require("fs/promises"), 1);
|
|
147881
|
+
var import_node_path21 = __toESM(require("path"), 1);
|
|
147882
|
+
var import_node_path22 = require("path");
|
|
147883
|
+
var import_node_fs17 = __toESM(require("fs"), 1);
|
|
147884
|
+
var import_node_path23 = __toESM(require("path"), 1);
|
|
147510
147885
|
var zr = Object.defineProperty;
|
|
147511
147886
|
var Ur = (s3, t) => {
|
|
147512
147887
|
for (var e in t) zr(s3, e, { get: t[e], enumerable: true });
|
|
@@ -147850,7 +148225,7 @@ var A = class extends import_node_events3.EventEmitter {
|
|
|
147850
148225
|
return Wr;
|
|
147851
148226
|
}
|
|
147852
148227
|
};
|
|
147853
|
-
var Jr =
|
|
148228
|
+
var Jr = import_fs27.default.writev;
|
|
147854
148229
|
var ht = /* @__PURE__ */ Symbol("_autoClose");
|
|
147855
148230
|
var H2 = /* @__PURE__ */ Symbol("_close");
|
|
147856
148231
|
var te = /* @__PURE__ */ Symbol("_ended");
|
|
@@ -147905,7 +148280,7 @@ var _t = class extends A {
|
|
|
147905
148280
|
throw new TypeError("this is a readable stream");
|
|
147906
148281
|
}
|
|
147907
148282
|
[at]() {
|
|
147908
|
-
|
|
148283
|
+
import_fs27.default.open(this[U], "r", (t, e) => this[Ht](t, e));
|
|
147909
148284
|
}
|
|
147910
148285
|
[Ht](t, e) {
|
|
147911
148286
|
t ? this[Ut](t) : (this[u] = e, this.emit("open", e), this[zt]());
|
|
@@ -147918,7 +148293,7 @@ var _t = class extends A {
|
|
|
147918
148293
|
this[j] = true;
|
|
147919
148294
|
let t = this[vi]();
|
|
147920
148295
|
if (t.length === 0) return process.nextTick(() => this[Ii](null, 0, t));
|
|
147921
|
-
|
|
148296
|
+
import_fs27.default.read(this[u], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
|
|
147922
148297
|
}
|
|
147923
148298
|
}
|
|
147924
148299
|
[Ii](t, e, i) {
|
|
@@ -147927,7 +148302,7 @@ var _t = class extends A {
|
|
|
147927
148302
|
[H2]() {
|
|
147928
148303
|
if (this[ht] && typeof this[u] == "number") {
|
|
147929
148304
|
let t = this[u];
|
|
147930
|
-
this[u] = void 0,
|
|
148305
|
+
this[u] = void 0, import_fs27.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
147931
148306
|
}
|
|
147932
148307
|
}
|
|
147933
148308
|
[Ut](t) {
|
|
@@ -147955,7 +148330,7 @@ var Be = class extends _t {
|
|
|
147955
148330
|
[at]() {
|
|
147956
148331
|
let t = true;
|
|
147957
148332
|
try {
|
|
147958
|
-
this[Ht](null,
|
|
148333
|
+
this[Ht](null, import_fs27.default.openSync(this[U], "r")), t = false;
|
|
147959
148334
|
} finally {
|
|
147960
148335
|
t && this[H2]();
|
|
147961
148336
|
}
|
|
@@ -147966,7 +148341,7 @@ var Be = class extends _t {
|
|
|
147966
148341
|
if (!this[j]) {
|
|
147967
148342
|
this[j] = true;
|
|
147968
148343
|
do {
|
|
147969
|
-
let e = this[vi](), i = e.length === 0 ? 0 :
|
|
148344
|
+
let e = this[vi](), i = e.length === 0 ? 0 : import_fs27.default.readSync(this[u], e, 0, e.length, null);
|
|
147970
148345
|
if (!this[ki](i, e)) break;
|
|
147971
148346
|
} while (true);
|
|
147972
148347
|
this[j] = false;
|
|
@@ -147979,7 +148354,7 @@ var Be = class extends _t {
|
|
|
147979
148354
|
[H2]() {
|
|
147980
148355
|
if (this[ht] && typeof this[u] == "number") {
|
|
147981
148356
|
let t = this[u];
|
|
147982
|
-
this[u] = void 0,
|
|
148357
|
+
this[u] = void 0, import_fs27.default.closeSync(t), this.emit("close");
|
|
147983
148358
|
}
|
|
147984
148359
|
}
|
|
147985
148360
|
};
|
|
@@ -148021,7 +148396,7 @@ var et = class extends import_events4.default {
|
|
|
148021
148396
|
this[H2](), this[gt] = true, this.emit("error", t);
|
|
148022
148397
|
}
|
|
148023
148398
|
[at]() {
|
|
148024
|
-
|
|
148399
|
+
import_fs27.default.open(this[U], this[tt], this[ie], (t, e) => this[Ht](t, e));
|
|
148025
148400
|
}
|
|
148026
148401
|
[Ht](t, e) {
|
|
148027
148402
|
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]());
|
|
@@ -148033,7 +148408,7 @@ var et = class extends import_events4.default {
|
|
|
148033
148408
|
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);
|
|
148034
148409
|
}
|
|
148035
148410
|
[ve](t) {
|
|
148036
|
-
|
|
148411
|
+
import_fs27.default.write(this[u], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
|
|
148037
148412
|
}
|
|
148038
148413
|
[Pt](t, e) {
|
|
148039
148414
|
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"))));
|
|
@@ -148049,7 +148424,7 @@ var et = class extends import_events4.default {
|
|
|
148049
148424
|
[H2]() {
|
|
148050
148425
|
if (this[ht] && typeof this[u] == "number") {
|
|
148051
148426
|
let t = this[u];
|
|
148052
|
-
this[u] = void 0,
|
|
148427
|
+
this[u] = void 0, import_fs27.default.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
|
|
148053
148428
|
}
|
|
148054
148429
|
}
|
|
148055
148430
|
};
|
|
@@ -148057,24 +148432,24 @@ var Wt = class extends et {
|
|
|
148057
148432
|
[at]() {
|
|
148058
148433
|
let t;
|
|
148059
148434
|
if (this[Me] && this[tt] === "r+") try {
|
|
148060
|
-
t =
|
|
148435
|
+
t = import_fs27.default.openSync(this[U], this[tt], this[ie]);
|
|
148061
148436
|
} catch (e) {
|
|
148062
148437
|
if (e?.code === "ENOENT") return this[tt] = "w", this[at]();
|
|
148063
148438
|
throw e;
|
|
148064
148439
|
}
|
|
148065
|
-
else t =
|
|
148440
|
+
else t = import_fs27.default.openSync(this[U], this[tt], this[ie]);
|
|
148066
148441
|
this[Ht](null, t);
|
|
148067
148442
|
}
|
|
148068
148443
|
[H2]() {
|
|
148069
148444
|
if (this[ht] && typeof this[u] == "number") {
|
|
148070
148445
|
let t = this[u];
|
|
148071
|
-
this[u] = void 0,
|
|
148446
|
+
this[u] = void 0, import_fs27.default.closeSync(t), this.emit("close");
|
|
148072
148447
|
}
|
|
148073
148448
|
}
|
|
148074
148449
|
[ve](t) {
|
|
148075
148450
|
let e = true;
|
|
148076
148451
|
try {
|
|
148077
|
-
this[Pt](null,
|
|
148452
|
+
this[Pt](null, import_fs27.default.writeSync(this[u], t, 0, t.length, this[ot])), e = false;
|
|
148078
148453
|
} finally {
|
|
148079
148454
|
if (e) try {
|
|
148080
148455
|
this[H2]();
|
|
@@ -148400,12 +148775,12 @@ var F = class {
|
|
|
148400
148775
|
}
|
|
148401
148776
|
};
|
|
148402
148777
|
var un = (s3, t) => {
|
|
148403
|
-
let i = s3, r = "", n, o =
|
|
148778
|
+
let i = s3, r = "", n, o = import_node_path16.posix.parse(s3).root || ".";
|
|
148404
148779
|
if (Buffer.byteLength(i) < 100) n = [i, r, false];
|
|
148405
148780
|
else {
|
|
148406
|
-
r =
|
|
148781
|
+
r = import_node_path16.posix.dirname(i), i = import_node_path16.posix.basename(i);
|
|
148407
148782
|
do
|
|
148408
|
-
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i =
|
|
148783
|
+
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i = import_node_path16.posix.join(import_node_path16.posix.basename(r), i), r = import_node_path16.posix.dirname(r));
|
|
148409
148784
|
while (r !== o && n === void 0);
|
|
148410
148785
|
n || (n = [s3.slice(0, 99), "", true]);
|
|
148411
148786
|
}
|
|
@@ -148451,7 +148826,7 @@ var ft = class s {
|
|
|
148451
148826
|
if (t === "") return Buffer.allocUnsafe(0);
|
|
148452
148827
|
let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
|
|
148453
148828
|
for (let n = 0; n < 512; n++) r[n] = 0;
|
|
148454
|
-
new F({ path: ("PaxHeader/" + (0,
|
|
148829
|
+
new F({ path: ("PaxHeader/" + (0, import_node_path17.basename)(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t, 512, e, "utf8");
|
|
148455
148830
|
for (let n = e + 512; n < r.length; n++) r[n] = 0;
|
|
148456
148831
|
return r;
|
|
148457
148832
|
}
|
|
@@ -148857,11 +149232,11 @@ var vn = (s3) => {
|
|
|
148857
149232
|
};
|
|
148858
149233
|
var Qi = (s3, t) => {
|
|
148859
149234
|
let e = new Map(t.map((n) => [ut(n), true])), i = s3.filter, r = (n, o = "") => {
|
|
148860
|
-
let h = o || (0,
|
|
149235
|
+
let h = o || (0, import_path24.parse)(n).root || ".", a;
|
|
148861
149236
|
if (n === h) a = false;
|
|
148862
149237
|
else {
|
|
148863
149238
|
let l = e.get(n);
|
|
148864
|
-
a = l !== void 0 ? l : r((0,
|
|
149239
|
+
a = l !== void 0 ? l : r((0, import_path24.dirname)(n), h);
|
|
148865
149240
|
}
|
|
148866
149241
|
return e.set(n, a), a;
|
|
148867
149242
|
};
|
|
@@ -148870,15 +149245,15 @@ var Qi = (s3, t) => {
|
|
|
148870
149245
|
var Mn = (s3) => {
|
|
148871
149246
|
let t = new rt(s3), e = s3.file, i;
|
|
148872
149247
|
try {
|
|
148873
|
-
i =
|
|
148874
|
-
let r =
|
|
149248
|
+
i = import_node_fs12.default.openSync(e, "r");
|
|
149249
|
+
let r = import_node_fs12.default.fstatSync(i), n = s3.maxReadSize || 16 * 1024 * 1024;
|
|
148875
149250
|
if (r.size < n) {
|
|
148876
|
-
let o = Buffer.allocUnsafe(r.size), h =
|
|
149251
|
+
let o = Buffer.allocUnsafe(r.size), h = import_node_fs12.default.readSync(i, o, 0, r.size, 0);
|
|
148877
149252
|
t.end(h === o.byteLength ? o : o.subarray(0, h));
|
|
148878
149253
|
} else {
|
|
148879
149254
|
let o = 0, h = Buffer.allocUnsafe(n);
|
|
148880
149255
|
for (; o < r.size; ) {
|
|
148881
|
-
let a =
|
|
149256
|
+
let a = import_node_fs12.default.readSync(i, h, 0, n, o);
|
|
148882
149257
|
if (a === 0) break;
|
|
148883
149258
|
o += a, t.write(h.subarray(0, a));
|
|
148884
149259
|
}
|
|
@@ -148886,7 +149261,7 @@ var Mn = (s3) => {
|
|
|
148886
149261
|
}
|
|
148887
149262
|
} finally {
|
|
148888
149263
|
if (typeof i == "number") try {
|
|
148889
|
-
|
|
149264
|
+
import_node_fs12.default.closeSync(i);
|
|
148890
149265
|
} catch {
|
|
148891
149266
|
}
|
|
148892
149267
|
}
|
|
@@ -148894,7 +149269,7 @@ var Mn = (s3) => {
|
|
|
148894
149269
|
var Bn = (s3, t) => {
|
|
148895
149270
|
let e = new rt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
|
|
148896
149271
|
return new Promise((o, h) => {
|
|
148897
|
-
e.on("error", h), e.on("end", o),
|
|
149272
|
+
e.on("error", h), e.on("end", o), import_node_fs12.default.stat(r, (a, l) => {
|
|
148898
149273
|
if (a) h(a);
|
|
148899
149274
|
else {
|
|
148900
149275
|
let c = new _t(r, { readSize: i, size: l.size });
|
|
@@ -148907,7 +149282,7 @@ var Ct = K(Mn, Bn, (s3) => new rt(s3), (s3) => new rt(s3), (s3, t) => {
|
|
|
148907
149282
|
t?.length && Qi(s3, t), s3.noResume || vn(s3);
|
|
148908
149283
|
});
|
|
148909
149284
|
var Ji = (s3, t, e) => (s3 &= 4095, e && (s3 = (s3 | 384) & -19), t && (s3 & 256 && (s3 |= 64), s3 & 32 && (s3 |= 8), s3 & 4 && (s3 |= 1)), s3);
|
|
148910
|
-
var { isAbsolute: zn, parse: qs } =
|
|
149285
|
+
var { isAbsolute: zn, parse: qs } = import_node_path18.win32;
|
|
148911
149286
|
var ce = (s3) => {
|
|
148912
149287
|
let t = "", e = qs(s3);
|
|
148913
149288
|
for (; zn(s3) || e.root; ) {
|
|
@@ -148981,7 +149356,7 @@ var de = class extends A {
|
|
|
148981
149356
|
let [o, h] = ce(this.path);
|
|
148982
149357
|
o && typeof h == "string" && (this.path = h, r = o);
|
|
148983
149358
|
}
|
|
148984
|
-
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 ||
|
|
149359
|
+
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_path25.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 });
|
|
148985
149360
|
let n = this.statCache.get(this.absolute);
|
|
148986
149361
|
n ? this[si](n) : this[ss]();
|
|
148987
149362
|
}
|
|
@@ -148992,7 +149367,7 @@ var de = class extends A {
|
|
|
148992
149367
|
return t === "error" && (this.#t = true), super.emit(t, ...e);
|
|
148993
149368
|
}
|
|
148994
149369
|
[ss]() {
|
|
148995
|
-
|
|
149370
|
+
import_fs29.default.lstat(this.absolute, (t, e) => {
|
|
148996
149371
|
if (t) return this.emit("error", t);
|
|
148997
149372
|
this[si](e);
|
|
148998
149373
|
});
|
|
@@ -149030,7 +149405,7 @@ var de = class extends A {
|
|
|
149030
149405
|
this.path.slice(-1) !== "/" && (this.path += "/"), this.stat.size = 0, this[fe](), this.end();
|
|
149031
149406
|
}
|
|
149032
149407
|
[is]() {
|
|
149033
|
-
|
|
149408
|
+
import_fs29.default.readlink(this.absolute, (t, e) => {
|
|
149034
149409
|
if (t) return this.emit("error", t);
|
|
149035
149410
|
this[ns](e);
|
|
149036
149411
|
});
|
|
@@ -149040,7 +149415,7 @@ var de = class extends A {
|
|
|
149040
149415
|
}
|
|
149041
149416
|
[sr](t) {
|
|
149042
149417
|
if (!this.stat) throw new Error("cannot create link entry without stat");
|
|
149043
|
-
this.type = "Link", this.linkpath = f(
|
|
149418
|
+
this.type = "Link", this.linkpath = f(import_path25.default.relative(this.cwd, t)), this.stat.size = 0, this[fe](), this.end();
|
|
149044
149419
|
}
|
|
149045
149420
|
[er]() {
|
|
149046
149421
|
if (!this.stat) throw new Error("cannot create file entry without stat");
|
|
@@ -149053,7 +149428,7 @@ var de = class extends A {
|
|
|
149053
149428
|
this[os]();
|
|
149054
149429
|
}
|
|
149055
149430
|
[os]() {
|
|
149056
|
-
|
|
149431
|
+
import_fs29.default.open(this.absolute, "r", (t, e) => {
|
|
149057
149432
|
if (t) return this.emit("error", t);
|
|
149058
149433
|
this[hs](e);
|
|
149059
149434
|
});
|
|
@@ -149068,14 +149443,14 @@ var de = class extends A {
|
|
|
149068
149443
|
[ii]() {
|
|
149069
149444
|
let { fd: t, buf: e, offset: i, length: r, pos: n } = this;
|
|
149070
149445
|
if (t === void 0 || e === void 0) throw new Error("cannot read file without first opening");
|
|
149071
|
-
|
|
149446
|
+
import_fs29.default.read(t, e, i, r, n, (o, h) => {
|
|
149072
149447
|
if (o) return this[pt](() => this.emit("error", o));
|
|
149073
149448
|
this[rs](h);
|
|
149074
149449
|
});
|
|
149075
149450
|
}
|
|
149076
149451
|
[pt](t = () => {
|
|
149077
149452
|
}) {
|
|
149078
|
-
this.fd !== void 0 &&
|
|
149453
|
+
this.fd !== void 0 && import_fs29.default.close(this.fd, t);
|
|
149079
149454
|
}
|
|
149080
149455
|
[rs](t) {
|
|
149081
149456
|
if (t <= 0 && this.remain > 0) {
|
|
@@ -149110,20 +149485,20 @@ var de = class extends A {
|
|
|
149110
149485
|
var ni = class extends de {
|
|
149111
149486
|
sync = true;
|
|
149112
149487
|
[ss]() {
|
|
149113
|
-
this[si](
|
|
149488
|
+
this[si](import_fs29.default.lstatSync(this.absolute));
|
|
149114
149489
|
}
|
|
149115
149490
|
[is]() {
|
|
149116
|
-
this[ns](
|
|
149491
|
+
this[ns](import_fs29.default.readlinkSync(this.absolute));
|
|
149117
149492
|
}
|
|
149118
149493
|
[os]() {
|
|
149119
|
-
this[hs](
|
|
149494
|
+
this[hs](import_fs29.default.openSync(this.absolute, "r"));
|
|
149120
149495
|
}
|
|
149121
149496
|
[ii]() {
|
|
149122
149497
|
let t = true;
|
|
149123
149498
|
try {
|
|
149124
149499
|
let { fd: e, buf: i, offset: r, length: n, pos: o } = this;
|
|
149125
149500
|
if (e === void 0 || i === void 0) throw new Error("fd and buf must be set in READ method");
|
|
149126
|
-
let h =
|
|
149501
|
+
let h = import_fs29.default.readSync(e, i, r, n, o);
|
|
149127
149502
|
this[rs](h), t = false;
|
|
149128
149503
|
} finally {
|
|
149129
149504
|
if (t) try {
|
|
@@ -149138,7 +149513,7 @@ var ni = class extends de {
|
|
|
149138
149513
|
}
|
|
149139
149514
|
[pt](t = () => {
|
|
149140
149515
|
}) {
|
|
149141
|
-
this.fd !== void 0 &&
|
|
149516
|
+
this.fd !== void 0 && import_fs29.default.closeSync(this.fd), t();
|
|
149142
149517
|
}
|
|
149143
149518
|
};
|
|
149144
149519
|
var oi = class extends A {
|
|
@@ -149454,7 +149829,7 @@ var wt = class extends A {
|
|
|
149454
149829
|
return typeof t == "string" ? this[ci](t) : this[or](t), this.flowing;
|
|
149455
149830
|
}
|
|
149456
149831
|
[or](t) {
|
|
149457
|
-
let e = f(
|
|
149832
|
+
let e = f(import_path26.default.resolve(this.cwd, t.path));
|
|
149458
149833
|
if (!this.filter(t.path, t)) t.resume();
|
|
149459
149834
|
else {
|
|
149460
149835
|
let i = new pi(t.path, e);
|
|
@@ -149463,13 +149838,13 @@ var wt = class extends A {
|
|
|
149463
149838
|
this[Ft]();
|
|
149464
149839
|
}
|
|
149465
149840
|
[ci](t) {
|
|
149466
|
-
let e = f(
|
|
149841
|
+
let e = f(import_path26.default.resolve(this.cwd, t));
|
|
149467
149842
|
this[W2].push(new pi(t, e)), this[Ft]();
|
|
149468
149843
|
}
|
|
149469
149844
|
[ds](t) {
|
|
149470
149845
|
t.pending = true, this[G] += 1;
|
|
149471
149846
|
let e = this.follow ? "stat" : "lstat";
|
|
149472
|
-
|
|
149847
|
+
import_fs28.default[e](t.absolute, (i, r) => {
|
|
149473
149848
|
t.pending = false, this[G] -= 1, i ? this.emit("error", i) : this[li](t, r);
|
|
149474
149849
|
});
|
|
149475
149850
|
}
|
|
@@ -149483,7 +149858,7 @@ var wt = class extends A {
|
|
|
149483
149858
|
this[Ft]();
|
|
149484
149859
|
}
|
|
149485
149860
|
[ms](t) {
|
|
149486
|
-
t.pending = true, this[G] += 1,
|
|
149861
|
+
t.pending = true, this[G] += 1, import_fs28.default.readdir(t.absolute, (e, i) => {
|
|
149487
149862
|
if (t.pending = false, this[G] -= 1, e) return this.emit("error", e);
|
|
149488
149863
|
this[fi](t, i);
|
|
149489
149864
|
});
|
|
@@ -149584,10 +149959,10 @@ var kt = class extends wt {
|
|
|
149584
149959
|
}
|
|
149585
149960
|
[ds](t) {
|
|
149586
149961
|
let e = this.follow ? "statSync" : "lstatSync";
|
|
149587
|
-
this[li](t,
|
|
149962
|
+
this[li](t, import_fs28.default[e](t.absolute));
|
|
149588
149963
|
}
|
|
149589
149964
|
[ms](t) {
|
|
149590
|
-
this[fi](t,
|
|
149965
|
+
this[fi](t, import_fs28.default.readdirSync(t.absolute));
|
|
149591
149966
|
}
|
|
149592
149967
|
[di](t) {
|
|
149593
149968
|
let e = t.entry, i = this.zip;
|
|
@@ -149616,11 +149991,11 @@ var $n = (s3, t) => {
|
|
|
149616
149991
|
};
|
|
149617
149992
|
var fr = (s3, t) => {
|
|
149618
149993
|
t.forEach((e) => {
|
|
149619
|
-
e.charAt(0) === "@" ? Ct({ file:
|
|
149994
|
+
e.charAt(0) === "@" ? Ct({ file: import_node_path15.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
149620
149995
|
}), s3.end();
|
|
149621
149996
|
};
|
|
149622
149997
|
var dr = async (s3, t) => {
|
|
149623
|
-
for (let e of t) e.charAt(0) === "@" ? await Ct({ file:
|
|
149998
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path15.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
|
|
149624
149999
|
s3.add(i);
|
|
149625
150000
|
} }) : s3.add(e);
|
|
149626
150001
|
s3.end();
|
|
@@ -149638,8 +150013,8 @@ var Qn = K(Vn, $n, Xn, qn, (s3, t) => {
|
|
|
149638
150013
|
});
|
|
149639
150014
|
var Jn = process.env.__FAKE_PLATFORM__ || process.platform;
|
|
149640
150015
|
var Er = Jn === "win32";
|
|
149641
|
-
var { O_CREAT: wr, O_NOFOLLOW: mr, O_TRUNC: Sr, O_WRONLY: yr } =
|
|
149642
|
-
var Rr = Number(process.env.__FAKE_FS_O_FILENAME__) ||
|
|
150016
|
+
var { O_CREAT: wr, O_NOFOLLOW: mr, O_TRUNC: Sr, O_WRONLY: yr } = import_fs30.default.constants;
|
|
150017
|
+
var Rr = Number(process.env.__FAKE_FS_O_FILENAME__) || import_fs30.default.constants.UV_FS_O_FILEMAP || 0;
|
|
149643
150018
|
var jn = Er && !!Rr;
|
|
149644
150019
|
var to = 512 * 1024;
|
|
149645
150020
|
var eo = Rr | Sr | wr | yr;
|
|
@@ -149647,29 +150022,29 @@ var ur = !Er && typeof mr == "number" ? mr | Sr | wr | yr : null;
|
|
|
149647
150022
|
var us = ur !== null ? () => ur : jn ? (s3) => s3 < to ? eo : "w" : () => "w";
|
|
149648
150023
|
var ps = (s3, t, e) => {
|
|
149649
150024
|
try {
|
|
149650
|
-
return
|
|
150025
|
+
return import_node_fs15.default.lchownSync(s3, t, e);
|
|
149651
150026
|
} catch (i) {
|
|
149652
150027
|
if (i?.code !== "ENOENT") throw i;
|
|
149653
150028
|
}
|
|
149654
150029
|
};
|
|
149655
150030
|
var Ei = (s3, t, e, i) => {
|
|
149656
|
-
|
|
150031
|
+
import_node_fs15.default.lchown(s3, t, e, (r) => {
|
|
149657
150032
|
i(r && r?.code !== "ENOENT" ? r : null);
|
|
149658
150033
|
});
|
|
149659
150034
|
};
|
|
149660
150035
|
var io = (s3, t, e, i, r) => {
|
|
149661
|
-
if (t.isDirectory()) Es(
|
|
150036
|
+
if (t.isDirectory()) Es(import_node_path20.default.resolve(s3, t.name), e, i, (n) => {
|
|
149662
150037
|
if (n) return r(n);
|
|
149663
|
-
let o =
|
|
150038
|
+
let o = import_node_path20.default.resolve(s3, t.name);
|
|
149664
150039
|
Ei(o, e, i, r);
|
|
149665
150040
|
});
|
|
149666
150041
|
else {
|
|
149667
|
-
let n =
|
|
150042
|
+
let n = import_node_path20.default.resolve(s3, t.name);
|
|
149668
150043
|
Ei(n, e, i, r);
|
|
149669
150044
|
}
|
|
149670
150045
|
};
|
|
149671
150046
|
var Es = (s3, t, e, i) => {
|
|
149672
|
-
|
|
150047
|
+
import_node_fs15.default.readdir(s3, { withFileTypes: true }, (r, n) => {
|
|
149673
150048
|
if (r) {
|
|
149674
150049
|
if (r.code === "ENOENT") return i();
|
|
149675
150050
|
if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
|
|
@@ -149685,12 +150060,12 @@ var Es = (s3, t, e, i) => {
|
|
|
149685
150060
|
});
|
|
149686
150061
|
};
|
|
149687
150062
|
var so = (s3, t, e, i) => {
|
|
149688
|
-
t.isDirectory() && ws(
|
|
150063
|
+
t.isDirectory() && ws(import_node_path20.default.resolve(s3, t.name), e, i), ps(import_node_path20.default.resolve(s3, t.name), e, i);
|
|
149689
150064
|
};
|
|
149690
150065
|
var ws = (s3, t, e) => {
|
|
149691
150066
|
let i;
|
|
149692
150067
|
try {
|
|
149693
|
-
i =
|
|
150068
|
+
i = import_node_fs15.default.readdirSync(s3, { withFileTypes: true });
|
|
149694
150069
|
} catch (r) {
|
|
149695
150070
|
let n = r;
|
|
149696
150071
|
if (n?.code === "ENOENT") return;
|
|
@@ -149724,32 +150099,32 @@ var St = class extends Error {
|
|
|
149724
150099
|
}
|
|
149725
150100
|
};
|
|
149726
150101
|
var no = (s3, t) => {
|
|
149727
|
-
|
|
150102
|
+
import_node_fs16.default.stat(s3, (e, i) => {
|
|
149728
150103
|
(e || !i.isDirectory()) && (e = new Se(s3, e?.code || "ENOTDIR")), t(e);
|
|
149729
150104
|
});
|
|
149730
150105
|
};
|
|
149731
150106
|
var gr = (s3, t, e) => {
|
|
149732
150107
|
s3 = f(s3);
|
|
149733
150108
|
let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, h = t.gid, a = typeof o == "number" && typeof h == "number" && (o !== t.processUid || h !== t.processGid), l = t.preserve, c = t.unlink, d = f(t.cwd), S2 = (E, x) => {
|
|
149734
|
-
E ? e(E) : x && a ? Es(x, o, h, (Le) => S2(Le)) : n ?
|
|
150109
|
+
E ? e(E) : x && a ? Es(x, o, h, (Le) => S2(Le)) : n ? import_node_fs16.default.chmod(s3, r, e) : e();
|
|
149735
150110
|
};
|
|
149736
150111
|
if (s3 === d) return no(s3, S2);
|
|
149737
150112
|
if (l) return import_promises21.default.mkdir(s3, { mode: r, recursive: true }).then((E) => S2(null, E ?? void 0), S2);
|
|
149738
|
-
let D = f(
|
|
150113
|
+
let D = f(import_node_path21.default.relative(d, s3)).split("/");
|
|
149739
150114
|
Ss(d, D, r, c, d, void 0, S2);
|
|
149740
150115
|
};
|
|
149741
150116
|
var Ss = (s3, t, e, i, r, n, o) => {
|
|
149742
150117
|
if (t.length === 0) return o(null, n);
|
|
149743
|
-
let h = t.shift(), a = f(
|
|
149744
|
-
|
|
150118
|
+
let h = t.shift(), a = f(import_node_path21.default.resolve(s3 + "/" + h));
|
|
150119
|
+
import_node_fs16.default.mkdir(a, e, br(a, t, e, i, r, n, o));
|
|
149745
150120
|
};
|
|
149746
150121
|
var br = (s3, t, e, i, r, n, o) => (h) => {
|
|
149747
|
-
h ?
|
|
150122
|
+
h ? import_node_fs16.default.lstat(s3, (a, l) => {
|
|
149748
150123
|
if (a) a.path = a.path && f(a.path), o(a);
|
|
149749
150124
|
else if (l.isDirectory()) Ss(s3, t, e, i, r, n, o);
|
|
149750
|
-
else if (i)
|
|
150125
|
+
else if (i) import_node_fs16.default.unlink(s3, (c) => {
|
|
149751
150126
|
if (c) return o(c);
|
|
149752
|
-
|
|
150127
|
+
import_node_fs16.default.mkdir(s3, e, br(s3, t, e, i, r, n, o));
|
|
149753
150128
|
});
|
|
149754
150129
|
else {
|
|
149755
150130
|
if (l.isSymbolicLink()) return o(new St(s3, s3 + "/" + t.join("/")));
|
|
@@ -149760,7 +150135,7 @@ var br = (s3, t, e, i, r, n, o) => (h) => {
|
|
|
149760
150135
|
var oo = (s3) => {
|
|
149761
150136
|
let t = false, e;
|
|
149762
150137
|
try {
|
|
149763
|
-
t =
|
|
150138
|
+
t = import_node_fs16.default.statSync(s3).isDirectory();
|
|
149764
150139
|
} catch (i) {
|
|
149765
150140
|
e = i?.code;
|
|
149766
150141
|
} finally {
|
|
@@ -149770,20 +150145,20 @@ var oo = (s3) => {
|
|
|
149770
150145
|
var _r = (s3, t) => {
|
|
149771
150146
|
s3 = f(s3);
|
|
149772
150147
|
let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, h = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), a = t.preserve, l = t.unlink, c = f(t.cwd), d = (E) => {
|
|
149773
|
-
E && h && ws(E, n, o), r &&
|
|
150148
|
+
E && h && ws(E, n, o), r && import_node_fs16.default.chmodSync(s3, i);
|
|
149774
150149
|
};
|
|
149775
150150
|
if (s3 === c) return oo(c), d();
|
|
149776
|
-
if (a) return d(
|
|
149777
|
-
let T2 = f(
|
|
150151
|
+
if (a) return d(import_node_fs16.default.mkdirSync(s3, { mode: i, recursive: true }) ?? void 0);
|
|
150152
|
+
let T2 = f(import_node_path21.default.relative(c, s3)).split("/"), D;
|
|
149778
150153
|
for (let E = T2.shift(), x = c; E && (x += "/" + E); E = T2.shift()) {
|
|
149779
|
-
x = f(
|
|
150154
|
+
x = f(import_node_path21.default.resolve(x));
|
|
149780
150155
|
try {
|
|
149781
|
-
|
|
150156
|
+
import_node_fs16.default.mkdirSync(x, i), D = D || x;
|
|
149782
150157
|
} catch {
|
|
149783
|
-
let Le =
|
|
150158
|
+
let Le = import_node_fs16.default.lstatSync(x);
|
|
149784
150159
|
if (Le.isDirectory()) continue;
|
|
149785
150160
|
if (l) {
|
|
149786
|
-
|
|
150161
|
+
import_node_fs16.default.unlinkSync(x), import_node_fs16.default.mkdirSync(x, i), D = D || x;
|
|
149787
150162
|
continue;
|
|
149788
150163
|
} else if (Le.isSymbolicLink()) return new St(x, x + "/" + T2.join("/"));
|
|
149789
150164
|
}
|
|
@@ -149805,14 +150180,14 @@ var ho = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
|
149805
150180
|
var ao = ho === "win32";
|
|
149806
150181
|
var lo = (s3) => s3.split("/").slice(0, -1).reduce((e, i) => {
|
|
149807
150182
|
let r = e.at(-1);
|
|
149808
|
-
return r !== void 0 && (i = (0,
|
|
150183
|
+
return r !== void 0 && (i = (0, import_node_path22.join)(r, i)), e.push(i || "/"), e;
|
|
149809
150184
|
}, []);
|
|
149810
150185
|
var yi = class {
|
|
149811
150186
|
#t = /* @__PURE__ */ new Map();
|
|
149812
150187
|
#i = /* @__PURE__ */ new Map();
|
|
149813
150188
|
#s = /* @__PURE__ */ new Set();
|
|
149814
150189
|
reserve(t, e) {
|
|
149815
|
-
t = ao ? ["win32 parallelization disabled"] : t.map((r) => ut((0,
|
|
150190
|
+
t = ao ? ["win32 parallelization disabled"] : t.map((r) => ut((0, import_node_path22.join)(Tr(r))));
|
|
149816
150191
|
let i = new Set(t.map((r) => lo(r)).reduce((r, n) => r.concat(n)));
|
|
149817
150192
|
this.#i.set(e, { dirs: i, paths: t });
|
|
149818
150193
|
for (let r of t) {
|
|
@@ -149902,17 +150277,17 @@ var fo = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
|
149902
150277
|
var Te = fo === "win32";
|
|
149903
150278
|
var mo = 1024;
|
|
149904
150279
|
var uo = (s3, t) => {
|
|
149905
|
-
if (!Te) return
|
|
150280
|
+
if (!Te) return import_node_fs14.default.unlink(s3, t);
|
|
149906
150281
|
let e = s3 + ".DELETE." + (0, import_node_crypto5.randomBytes)(16).toString("hex");
|
|
149907
|
-
|
|
150282
|
+
import_node_fs14.default.rename(s3, e, (i) => {
|
|
149908
150283
|
if (i) return t(i);
|
|
149909
|
-
|
|
150284
|
+
import_node_fs14.default.unlink(e, t);
|
|
149910
150285
|
});
|
|
149911
150286
|
};
|
|
149912
150287
|
var po = (s3) => {
|
|
149913
|
-
if (!Te) return
|
|
150288
|
+
if (!Te) return import_node_fs14.default.unlinkSync(s3);
|
|
149914
150289
|
let t = s3 + ".DELETE." + (0, import_node_crypto5.randomBytes)(16).toString("hex");
|
|
149915
|
-
|
|
150290
|
+
import_node_fs14.default.renameSync(s3, t), import_node_fs14.default.unlinkSync(t);
|
|
149916
150291
|
};
|
|
149917
150292
|
var vr = (s3, t, e) => s3 !== void 0 && s3 === s3 >>> 0 ? s3 : t !== void 0 && t === t >>> 0 ? t : e;
|
|
149918
150293
|
var Xt = class extends rt {
|
|
@@ -149952,7 +150327,7 @@ var Xt = class extends rt {
|
|
|
149952
150327
|
if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
|
|
149953
150328
|
this.uid = t.uid, this.gid = t.gid, this.setOwner = true;
|
|
149954
150329
|
} else this.uid = void 0, this.gid = void 0, this.setOwner = false;
|
|
149955
|
-
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : mo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(
|
|
150330
|
+
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : mo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(import_node_path19.default.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Lr() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
|
|
149956
150331
|
}
|
|
149957
150332
|
warn(t, e, i = {}) {
|
|
149958
150333
|
return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = false), super.warn(t, e, i);
|
|
@@ -149966,7 +150341,7 @@ var Xt = class extends rt {
|
|
|
149966
150341
|
let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
|
|
149967
150342
|
if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
|
|
149968
150343
|
if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, { entry: t, [e]: i }), false;
|
|
149969
|
-
let a =
|
|
150344
|
+
let a = import_node_path19.default.posix.dirname(t.path), l = import_node_path19.default.posix.normalize(import_node_path19.default.posix.join(a, h.join("/")));
|
|
149970
150345
|
if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, { entry: t, [e]: i }), false;
|
|
149971
150346
|
}
|
|
149972
150347
|
return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, { entry: t, [e]: i })), true;
|
|
@@ -149984,12 +150359,12 @@ var Xt = class extends rt {
|
|
|
149984
150359
|
}
|
|
149985
150360
|
if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: t, path: e, depth: i.length, maxDepth: this.maxDepth }), false;
|
|
149986
150361
|
if (!this[Rs](t, "path") || !this[Rs](t, "linkpath")) return false;
|
|
149987
|
-
if (t.absolute =
|
|
150362
|
+
if (t.absolute = import_node_path19.default.isAbsolute(t.path) ? f(import_node_path19.default.resolve(t.path)) : f(import_node_path19.default.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t, path: f(t.path), resolvedPath: t.absolute, cwd: this.cwd }), false;
|
|
149988
150363
|
if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return false;
|
|
149989
150364
|
if (this.win32) {
|
|
149990
|
-
let { root: r } =
|
|
150365
|
+
let { root: r } = import_node_path19.default.win32.parse(String(t.absolute));
|
|
149991
150366
|
t.absolute = r + ts(String(t.absolute).slice(r.length));
|
|
149992
|
-
let { root: n } =
|
|
150367
|
+
let { root: n } = import_node_path19.default.win32.parse(t.path);
|
|
149993
150368
|
t.path = n + ts(t.path.slice(n.length));
|
|
149994
150369
|
}
|
|
149995
150370
|
return true;
|
|
@@ -150028,16 +150403,16 @@ var Xt = class extends rt {
|
|
|
150028
150403
|
[Ts](t, e) {
|
|
150029
150404
|
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new et(String(t.absolute), { flags: us(t.size), mode: i, autoClose: false });
|
|
150030
150405
|
r.on("error", (a) => {
|
|
150031
|
-
r.fd &&
|
|
150406
|
+
r.fd && import_node_fs14.default.close(r.fd, () => {
|
|
150032
150407
|
}), r.write = () => true, this[O](a, t), e();
|
|
150033
150408
|
});
|
|
150034
150409
|
let n = 1, o = (a) => {
|
|
150035
150410
|
if (a) {
|
|
150036
|
-
r.fd &&
|
|
150411
|
+
r.fd && import_node_fs14.default.close(r.fd, () => {
|
|
150037
150412
|
}), this[O](a, t), e();
|
|
150038
150413
|
return;
|
|
150039
150414
|
}
|
|
150040
|
-
--n === 0 && r.fd !== void 0 &&
|
|
150415
|
+
--n === 0 && r.fd !== void 0 && import_node_fs14.default.close(r.fd, (l) => {
|
|
150041
150416
|
l ? this[O](l, t) : this[$t](), e();
|
|
150042
150417
|
});
|
|
150043
150418
|
};
|
|
@@ -150046,12 +150421,12 @@ var Xt = class extends rt {
|
|
|
150046
150421
|
if (typeof l == "number" && t.mtime && !this.noMtime) {
|
|
150047
150422
|
n++;
|
|
150048
150423
|
let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
|
|
150049
|
-
|
|
150424
|
+
import_node_fs14.default.futimes(l, c, d, (S2) => S2 ? import_node_fs14.default.utimes(a, c, d, (T2) => o(T2 && S2)) : o());
|
|
150050
150425
|
}
|
|
150051
150426
|
if (typeof l == "number" && this[ge](t)) {
|
|
150052
150427
|
n++;
|
|
150053
150428
|
let c = this[be](t), d = this[_e](t);
|
|
150054
|
-
typeof c == "number" && typeof d == "number" &&
|
|
150429
|
+
typeof c == "number" && typeof d == "number" && import_node_fs14.default.fchown(l, c, d, (S2) => S2 ? import_node_fs14.default.chown(a, c, d, (T2) => o(T2 && S2)) : o());
|
|
150055
150430
|
}
|
|
150056
150431
|
o();
|
|
150057
150432
|
});
|
|
@@ -150070,20 +150445,20 @@ var Xt = class extends rt {
|
|
|
150070
150445
|
let n = 1, o = () => {
|
|
150071
150446
|
--n === 0 && (e(), this[$t](), t.resume());
|
|
150072
150447
|
};
|
|
150073
|
-
t.mtime && !this.noMtime && (n++,
|
|
150448
|
+
t.mtime && !this.noMtime && (n++, import_node_fs14.default.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[ge](t) && (n++, import_node_fs14.default.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
|
|
150074
150449
|
});
|
|
150075
150450
|
}
|
|
150076
150451
|
[Cr](t) {
|
|
150077
150452
|
t.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
|
|
150078
150453
|
}
|
|
150079
150454
|
[Ar](t, e) {
|
|
150080
|
-
let i = f(
|
|
150455
|
+
let i = f(import_node_path19.default.relative(this.cwd, import_node_path19.default.resolve(import_node_path19.default.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
|
|
150081
150456
|
this[Re](t, this.cwd, i, () => this[gi](t, String(t.linkpath), "symlink", e), (r) => {
|
|
150082
150457
|
this[O](r, t), e();
|
|
150083
150458
|
});
|
|
150084
150459
|
}
|
|
150085
150460
|
[Ir](t, e) {
|
|
150086
|
-
let i = f(
|
|
150461
|
+
let i = f(import_node_path19.default.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
|
|
150087
150462
|
this[Re](t, this.cwd, r, () => this[gi](t, i, "link", e), (n) => {
|
|
150088
150463
|
this[O](n, t), e();
|
|
150089
150464
|
});
|
|
@@ -150091,10 +150466,10 @@ var Xt = class extends rt {
|
|
|
150091
150466
|
[Re](t, e, i, r, n) {
|
|
150092
150467
|
let o = i.shift();
|
|
150093
150468
|
if (this.preservePaths || o === void 0) return r();
|
|
150094
|
-
let h =
|
|
150095
|
-
|
|
150469
|
+
let h = import_node_path19.default.resolve(e, o);
|
|
150470
|
+
import_node_fs14.default.lstat(h, (a, l) => {
|
|
150096
150471
|
if (a) return r();
|
|
150097
|
-
if (l?.isSymbolicLink()) return n(new St(h,
|
|
150472
|
+
if (l?.isSymbolicLink()) return n(new St(h, import_node_path19.default.resolve(h, i.join("/"))));
|
|
150098
150473
|
this[Re](t, h, i, r, n);
|
|
150099
150474
|
});
|
|
150100
150475
|
}
|
|
@@ -150128,7 +150503,7 @@ var Xt = class extends rt {
|
|
|
150128
150503
|
});
|
|
150129
150504
|
}, n = () => {
|
|
150130
150505
|
if (t.absolute !== this.cwd) {
|
|
150131
|
-
let h = f(
|
|
150506
|
+
let h = f(import_node_path19.default.dirname(String(t.absolute)));
|
|
150132
150507
|
if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
|
|
150133
150508
|
if (a) {
|
|
150134
150509
|
this[O](a, t), i();
|
|
@@ -150139,7 +150514,7 @@ var Xt = class extends rt {
|
|
|
150139
150514
|
}
|
|
150140
150515
|
o();
|
|
150141
150516
|
}, o = () => {
|
|
150142
|
-
|
|
150517
|
+
import_node_fs14.default.lstat(String(t.absolute), (h, a) => {
|
|
150143
150518
|
if (a && (this.keep || this.newer && a.mtime > (t.mtime ?? a.mtime))) {
|
|
150144
150519
|
this[Ls](t), i();
|
|
150145
150520
|
return;
|
|
@@ -150148,9 +150523,9 @@ var Xt = class extends rt {
|
|
|
150148
150523
|
if (a.isDirectory()) {
|
|
150149
150524
|
if (t.type === "Directory") {
|
|
150150
150525
|
let l = this.chmod && t.mode && (a.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
|
|
150151
|
-
return l ?
|
|
150526
|
+
return l ? import_node_fs14.default.chmod(String(t.absolute), Number(t.mode), c) : c();
|
|
150152
150527
|
}
|
|
150153
|
-
if (t.absolute !== this.cwd) return
|
|
150528
|
+
if (t.absolute !== this.cwd) return import_node_fs14.default.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
150154
150529
|
}
|
|
150155
150530
|
if (t.absolute === this.cwd) return this[P](null, t, i);
|
|
150156
150531
|
uo(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
@@ -150178,7 +150553,7 @@ var Xt = class extends rt {
|
|
|
150178
150553
|
}
|
|
150179
150554
|
}
|
|
150180
150555
|
[gi](t, e, i, r) {
|
|
150181
|
-
|
|
150556
|
+
import_node_fs14.default[i](e, String(t.absolute), (n) => {
|
|
150182
150557
|
n ? this[O](n, t) : (this[$t](), t.resume()), r();
|
|
150183
150558
|
});
|
|
150184
150559
|
}
|
|
@@ -150203,23 +150578,23 @@ var xe = class extends Xt {
|
|
|
150203
150578
|
this[Oe] = true;
|
|
150204
150579
|
}
|
|
150205
150580
|
if (t.absolute !== this.cwd) {
|
|
150206
|
-
let n = f(
|
|
150581
|
+
let n = f(import_node_path19.default.dirname(String(t.absolute)));
|
|
150207
150582
|
if (n !== this.cwd) {
|
|
150208
150583
|
let o = this[yt](n, this.dmode);
|
|
150209
150584
|
if (o) return this[O](o, t);
|
|
150210
150585
|
}
|
|
150211
150586
|
}
|
|
150212
|
-
let [e, i] = ye(() =>
|
|
150587
|
+
let [e, i] = ye(() => import_node_fs14.default.lstatSync(String(t.absolute)));
|
|
150213
150588
|
if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ls](t);
|
|
150214
150589
|
if (e || this[Os](t, i)) return this[P](null, t);
|
|
150215
150590
|
if (i.isDirectory()) {
|
|
150216
150591
|
if (t.type === "Directory") {
|
|
150217
150592
|
let o = this.chmod && t.mode && (i.mode & 4095) !== t.mode, [h] = o ? ye(() => {
|
|
150218
|
-
|
|
150593
|
+
import_node_fs14.default.chmodSync(String(t.absolute), Number(t.mode));
|
|
150219
150594
|
}) : [];
|
|
150220
150595
|
return this[P](h, t);
|
|
150221
150596
|
}
|
|
150222
|
-
let [n] = ye(() =>
|
|
150597
|
+
let [n] = ye(() => import_node_fs14.default.rmdirSync(String(t.absolute)));
|
|
150223
150598
|
this[P](n, t);
|
|
150224
150599
|
}
|
|
150225
150600
|
let [r] = t.absolute === this.cwd ? [] : ye(() => po(String(t.absolute)));
|
|
@@ -150229,21 +150604,21 @@ var xe = class extends Xt {
|
|
|
150229
150604
|
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (h) => {
|
|
150230
150605
|
let a;
|
|
150231
150606
|
try {
|
|
150232
|
-
|
|
150607
|
+
import_node_fs14.default.closeSync(n);
|
|
150233
150608
|
} catch (l) {
|
|
150234
150609
|
a = l;
|
|
150235
150610
|
}
|
|
150236
150611
|
(h || a) && this[O](h || a, t), e();
|
|
150237
150612
|
}, n;
|
|
150238
150613
|
try {
|
|
150239
|
-
n =
|
|
150614
|
+
n = import_node_fs14.default.openSync(String(t.absolute), us(t.size), i);
|
|
150240
150615
|
} catch (h) {
|
|
150241
150616
|
return r(h);
|
|
150242
150617
|
}
|
|
150243
150618
|
let o = this.transform && this.transform(t) || t;
|
|
150244
150619
|
o !== t && (o.on("error", (h) => this[O](h, t)), t.pipe(o)), o.on("data", (h) => {
|
|
150245
150620
|
try {
|
|
150246
|
-
|
|
150621
|
+
import_node_fs14.default.writeSync(n, h, 0, h.length);
|
|
150247
150622
|
} catch (a) {
|
|
150248
150623
|
r(a);
|
|
150249
150624
|
}
|
|
@@ -150252,10 +150627,10 @@ var xe = class extends Xt {
|
|
|
150252
150627
|
if (t.mtime && !this.noMtime) {
|
|
150253
150628
|
let a = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
|
|
150254
150629
|
try {
|
|
150255
|
-
|
|
150630
|
+
import_node_fs14.default.futimesSync(n, a, l);
|
|
150256
150631
|
} catch (c) {
|
|
150257
150632
|
try {
|
|
150258
|
-
|
|
150633
|
+
import_node_fs14.default.utimesSync(String(t.absolute), a, l);
|
|
150259
150634
|
} catch {
|
|
150260
150635
|
h = c;
|
|
150261
150636
|
}
|
|
@@ -150264,10 +150639,10 @@ var xe = class extends Xt {
|
|
|
150264
150639
|
if (this[ge](t)) {
|
|
150265
150640
|
let a = this[be](t), l = this[_e](t);
|
|
150266
150641
|
try {
|
|
150267
|
-
|
|
150642
|
+
import_node_fs14.default.fchownSync(n, Number(a), Number(l));
|
|
150268
150643
|
} catch (c) {
|
|
150269
150644
|
try {
|
|
150270
|
-
|
|
150645
|
+
import_node_fs14.default.chownSync(String(t.absolute), Number(a), Number(l));
|
|
150271
150646
|
} catch {
|
|
150272
150647
|
h = h || c;
|
|
150273
150648
|
}
|
|
@@ -150283,11 +150658,11 @@ var xe = class extends Xt {
|
|
|
150283
150658
|
return;
|
|
150284
150659
|
}
|
|
150285
150660
|
if (t.mtime && !this.noMtime) try {
|
|
150286
|
-
|
|
150661
|
+
import_node_fs14.default.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
|
|
150287
150662
|
} catch {
|
|
150288
150663
|
}
|
|
150289
150664
|
if (this[ge](t)) try {
|
|
150290
|
-
|
|
150665
|
+
import_node_fs14.default.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
|
|
150291
150666
|
} catch {
|
|
150292
150667
|
}
|
|
150293
150668
|
e(), t.resume();
|
|
@@ -150303,30 +150678,30 @@ var xe = class extends Xt {
|
|
|
150303
150678
|
if (this.preservePaths || i.length === 0) return r();
|
|
150304
150679
|
let o = e;
|
|
150305
150680
|
for (let h of i) {
|
|
150306
|
-
o =
|
|
150307
|
-
let [a, l] = ye(() =>
|
|
150681
|
+
o = import_node_path19.default.resolve(o, h);
|
|
150682
|
+
let [a, l] = ye(() => import_node_fs14.default.lstatSync(o));
|
|
150308
150683
|
if (a) return r();
|
|
150309
|
-
if (l.isSymbolicLink()) return n(new St(o,
|
|
150684
|
+
if (l.isSymbolicLink()) return n(new St(o, import_node_path19.default.resolve(e, i.join("/"))));
|
|
150310
150685
|
}
|
|
150311
150686
|
r();
|
|
150312
150687
|
}
|
|
150313
150688
|
[gi](t, e, i, r) {
|
|
150314
150689
|
let n = `${i}Sync`;
|
|
150315
150690
|
try {
|
|
150316
|
-
|
|
150691
|
+
import_node_fs14.default[n](e, String(t.absolute)), r(), t.resume();
|
|
150317
150692
|
} catch (o) {
|
|
150318
150693
|
return this[O](o, t);
|
|
150319
150694
|
}
|
|
150320
150695
|
}
|
|
150321
150696
|
};
|
|
150322
150697
|
var Eo = (s3) => {
|
|
150323
|
-
let t = new xe(s3), e = s3.file, i =
|
|
150698
|
+
let t = new xe(s3), e = s3.file, i = import_node_fs13.default.statSync(e), r = s3.maxReadSize || 16 * 1024 * 1024;
|
|
150324
150699
|
new Be(e, { readSize: r, size: i.size }).pipe(t);
|
|
150325
150700
|
};
|
|
150326
150701
|
var wo = (s3, t) => {
|
|
150327
150702
|
let e = new Xt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
|
|
150328
150703
|
return new Promise((o, h) => {
|
|
150329
|
-
e.on("error", h), e.on("close", o),
|
|
150704
|
+
e.on("error", h), e.on("close", o), import_node_fs13.default.stat(r, (a, l) => {
|
|
150330
150705
|
if (a) h(a);
|
|
150331
150706
|
else {
|
|
150332
150707
|
let c = new _t(r, { readSize: i, size: l.size });
|
|
@@ -150342,15 +150717,15 @@ var yo = (s3, t) => {
|
|
|
150342
150717
|
let e = new kt(s3), i = true, r, n;
|
|
150343
150718
|
try {
|
|
150344
150719
|
try {
|
|
150345
|
-
r =
|
|
150720
|
+
r = import_node_fs17.default.openSync(s3.file, "r+");
|
|
150346
150721
|
} catch (a) {
|
|
150347
|
-
if (a?.code === "ENOENT") r =
|
|
150722
|
+
if (a?.code === "ENOENT") r = import_node_fs17.default.openSync(s3.file, "w+");
|
|
150348
150723
|
else throw a;
|
|
150349
150724
|
}
|
|
150350
|
-
let o =
|
|
150725
|
+
let o = import_node_fs17.default.fstatSync(r), h = Buffer.alloc(512);
|
|
150351
150726
|
t: for (n = 0; n < o.size; n += 512) {
|
|
150352
150727
|
for (let c = 0, d = 0; c < 512; c += d) {
|
|
150353
|
-
if (d =
|
|
150728
|
+
if (d = import_node_fs17.default.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139) throw new Error("cannot append to compressed archives");
|
|
150354
150729
|
if (!d) break t;
|
|
150355
150730
|
}
|
|
150356
150731
|
let a = new F(h);
|
|
@@ -150362,7 +150737,7 @@ var yo = (s3, t) => {
|
|
|
150362
150737
|
i = false, Ro(s3, e, n, r, t);
|
|
150363
150738
|
} finally {
|
|
150364
150739
|
if (i) try {
|
|
150365
|
-
|
|
150740
|
+
import_node_fs17.default.closeSync(r);
|
|
150366
150741
|
} catch {
|
|
150367
150742
|
}
|
|
150368
150743
|
}
|
|
@@ -150375,29 +150750,29 @@ var go = (s3, t) => {
|
|
|
150375
150750
|
t = Array.from(t);
|
|
150376
150751
|
let e = new wt(s3), i = (n, o, h) => {
|
|
150377
150752
|
let a = (T2, D) => {
|
|
150378
|
-
T2 ?
|
|
150753
|
+
T2 ? import_node_fs17.default.close(n, (E) => h(T2)) : h(null, D);
|
|
150379
150754
|
}, l = 0;
|
|
150380
150755
|
if (o === 0) return a(null, 0);
|
|
150381
150756
|
let c = 0, d = Buffer.alloc(512), S2 = (T2, D) => {
|
|
150382
150757
|
if (T2 || D === void 0) return a(T2);
|
|
150383
|
-
if (c += D, c < 512 && D) return
|
|
150758
|
+
if (c += D, c < 512 && D) return import_node_fs17.default.read(n, d, c, d.length - c, l + c, S2);
|
|
150384
150759
|
if (l === 0 && d[0] === 31 && d[1] === 139) return a(new Error("cannot append to compressed archives"));
|
|
150385
150760
|
if (c < 512) return a(null, l);
|
|
150386
150761
|
let E = new F(d);
|
|
150387
150762
|
if (!E.cksumValid) return a(null, l);
|
|
150388
150763
|
let x = 512 * Math.ceil((E.size ?? 0) / 512);
|
|
150389
150764
|
if (l + x + 512 > o || (l += x + 512, l >= o)) return a(null, l);
|
|
150390
|
-
s3.mtimeCache && E.mtime && s3.mtimeCache.set(String(E.path), E.mtime), c = 0,
|
|
150765
|
+
s3.mtimeCache && E.mtime && s3.mtimeCache.set(String(E.path), E.mtime), c = 0, import_node_fs17.default.read(n, d, 0, 512, l, S2);
|
|
150391
150766
|
};
|
|
150392
|
-
|
|
150767
|
+
import_node_fs17.default.read(n, d, 0, 512, l, S2);
|
|
150393
150768
|
};
|
|
150394
150769
|
return new Promise((n, o) => {
|
|
150395
150770
|
e.on("error", o);
|
|
150396
150771
|
let h = "r+", a = (l, c) => {
|
|
150397
|
-
if (l && l.code === "ENOENT" && h === "r+") return h = "w+",
|
|
150772
|
+
if (l && l.code === "ENOENT" && h === "r+") return h = "w+", import_node_fs17.default.open(s3.file, h, a);
|
|
150398
150773
|
if (l || !c) return o(l);
|
|
150399
|
-
|
|
150400
|
-
if (d) return
|
|
150774
|
+
import_node_fs17.default.fstat(c, (d, S2) => {
|
|
150775
|
+
if (d) return import_node_fs17.default.close(c, () => o(d));
|
|
150401
150776
|
i(c, S2.size, (T2, D) => {
|
|
150402
150777
|
if (T2) return o(T2);
|
|
150403
150778
|
let E = new et(s3.file, { fd: c, start: D });
|
|
@@ -150405,16 +150780,16 @@ var go = (s3, t) => {
|
|
|
150405
150780
|
});
|
|
150406
150781
|
});
|
|
150407
150782
|
};
|
|
150408
|
-
|
|
150783
|
+
import_node_fs17.default.open(s3.file, h, a);
|
|
150409
150784
|
});
|
|
150410
150785
|
};
|
|
150411
150786
|
var bo = (s3, t) => {
|
|
150412
150787
|
t.forEach((e) => {
|
|
150413
|
-
e.charAt(0) === "@" ? Ct({ file:
|
|
150788
|
+
e.charAt(0) === "@" ? Ct({ file: import_node_path23.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
150414
150789
|
}), s3.end();
|
|
150415
150790
|
};
|
|
150416
150791
|
var _o = async (s3, t) => {
|
|
150417
|
-
for (let e of t) e.charAt(0) === "@" ? await Ct({ file:
|
|
150792
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path23.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
150418
150793
|
s3.end();
|
|
150419
150794
|
};
|
|
150420
150795
|
var vt = K(yo, go, () => {
|
|
@@ -150437,19 +150812,19 @@ var To = (s3) => {
|
|
|
150437
150812
|
// src/updater/unpack.ts
|
|
150438
150813
|
async function unpackTarball(opts) {
|
|
150439
150814
|
const { tarballPath, destDir } = opts;
|
|
150440
|
-
(0,
|
|
150441
|
-
(0,
|
|
150815
|
+
(0, import_node_fs18.rmSync)(destDir, { recursive: true, force: true });
|
|
150816
|
+
(0, import_node_fs18.mkdirSync)(destDir, { recursive: true });
|
|
150442
150817
|
await So({ file: tarballPath, cwd: destDir });
|
|
150443
150818
|
}
|
|
150444
150819
|
|
|
150445
150820
|
// src/updater/update-log.ts
|
|
150446
|
-
var
|
|
150447
|
-
var
|
|
150448
|
-
var LOG_PATH = (0,
|
|
150821
|
+
var import_node_fs19 = require("fs");
|
|
150822
|
+
var import_node_path24 = require("path");
|
|
150823
|
+
var LOG_PATH = (0, import_node_path24.join)(THREADBASE_ROOT, "update.log");
|
|
150449
150824
|
function appendUpdateLog(line) {
|
|
150450
150825
|
try {
|
|
150451
|
-
(0,
|
|
150452
|
-
(0,
|
|
150826
|
+
(0, import_node_fs19.mkdirSync)(THREADBASE_ROOT, { recursive: true });
|
|
150827
|
+
(0, import_node_fs19.appendFileSync)(LOG_PATH, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
150453
150828
|
`, "utf8");
|
|
150454
150829
|
} catch {
|
|
150455
150830
|
}
|
|
@@ -150520,7 +150895,7 @@ async function runInstall(opts) {
|
|
|
150520
150895
|
}
|
|
150521
150896
|
}
|
|
150522
150897
|
ensureReleasesDir();
|
|
150523
|
-
(0,
|
|
150898
|
+
(0, import_node_fs20.mkdirSync)(DOWNLOAD_DIR, { recursive: true });
|
|
150524
150899
|
const tarballPath = downloadPath(targetVersion, artifact.filename);
|
|
150525
150900
|
await downloadAndVerify({ manifest, assets: target.assets, targetPath: tarballPath });
|
|
150526
150901
|
const destDir = releaseDir(targetVersion);
|
|
@@ -150554,7 +150929,7 @@ async function runInstall(opts) {
|
|
|
150554
150929
|
|
|
150555
150930
|
// cli/prod.ts
|
|
150556
150931
|
var import_node_child_process6 = require("child_process");
|
|
150557
|
-
var
|
|
150932
|
+
var import_node_fs22 = require("fs");
|
|
150558
150933
|
init_constants();
|
|
150559
150934
|
init_launchd();
|
|
150560
150935
|
init_marker();
|
|
@@ -150640,7 +151015,7 @@ async function runProdDoctor(opts) {
|
|
|
150640
151015
|
return { findings, repairs };
|
|
150641
151016
|
}
|
|
150642
151017
|
var defaultSpawnTail = ({ files, lines, follow }) => {
|
|
150643
|
-
const existing = files.filter((f2) => (0,
|
|
151018
|
+
const existing = files.filter((f2) => (0, import_node_fs22.existsSync)(f2));
|
|
150644
151019
|
if (existing.length === 0) {
|
|
150645
151020
|
return Promise.resolve({
|
|
150646
151021
|
ok: false,
|
|
@@ -150912,12 +151287,12 @@ program2.command("cache").description("Manage the local SQLite conversation cach
|
|
|
150912
151287
|
"Cache directory (default: ~/.threadbase/cache)",
|
|
150913
151288
|
`${process.env.HOME}/.threadbase/cache`
|
|
150914
151289
|
).action((opts) => {
|
|
150915
|
-
const { rmSync: rmSync6, existsSync:
|
|
150916
|
-
const { join:
|
|
150917
|
-
const dbPath =
|
|
151290
|
+
const { rmSync: rmSync6, existsSync: existsSync13 } = require("fs");
|
|
151291
|
+
const { join: join28 } = require("path");
|
|
151292
|
+
const dbPath = join28(opts.cacheDir, "cache.db");
|
|
150918
151293
|
for (const suffix of ["", "-shm", "-wal"]) {
|
|
150919
151294
|
const f2 = dbPath + suffix;
|
|
150920
|
-
if (
|
|
151295
|
+
if (existsSync13(f2)) {
|
|
150921
151296
|
rmSync6(f2);
|
|
150922
151297
|
log7.info(`Deleted ${f2}`, { path: f2 }, "console");
|
|
150923
151298
|
}
|