@threadbase-sh/streamer 1.21.0 → 1.22.1
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 +322 -292
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +25 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -13
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/cli.cjs
CHANGED
|
@@ -1484,6 +1484,12 @@ var require_main2 = __commonJS({
|
|
|
1484
1484
|
});
|
|
1485
1485
|
|
|
1486
1486
|
// src/auth.ts
|
|
1487
|
+
function configDir() {
|
|
1488
|
+
return process.env.THREADBASE_CONFIG_DIR ?? (0, import_path.join)((0, import_os.homedir)(), ".threadbase");
|
|
1489
|
+
}
|
|
1490
|
+
function configFile() {
|
|
1491
|
+
return (0, import_path.join)(configDir(), "server.yaml");
|
|
1492
|
+
}
|
|
1487
1493
|
function generateApiKey() {
|
|
1488
1494
|
return `tb_${(0, import_crypto.randomBytes)(16).toString("hex")}`;
|
|
1489
1495
|
}
|
|
@@ -1495,20 +1501,20 @@ function validateApiKey(provided, expected) {
|
|
|
1495
1501
|
}
|
|
1496
1502
|
function loadOrCreateApiKey() {
|
|
1497
1503
|
try {
|
|
1498
|
-
const content = (0, import_fs.readFileSync)(
|
|
1504
|
+
const content = (0, import_fs.readFileSync)(configFile(), "utf-8");
|
|
1499
1505
|
const match2 = content.match(/api_key:\s*(.+)/);
|
|
1500
1506
|
if (match2?.[1]) return match2[1].trim();
|
|
1501
1507
|
} catch {
|
|
1502
1508
|
}
|
|
1503
1509
|
const key = generateApiKey();
|
|
1504
|
-
(0, import_fs.mkdirSync)(
|
|
1505
|
-
(0, import_fs.writeFileSync)(
|
|
1510
|
+
(0, import_fs.mkdirSync)(configDir(), { recursive: true });
|
|
1511
|
+
(0, import_fs.writeFileSync)(configFile(), `api_key: ${key}
|
|
1506
1512
|
`, "utf-8");
|
|
1507
1513
|
return key;
|
|
1508
1514
|
}
|
|
1509
1515
|
function loadBrowseRoot() {
|
|
1510
1516
|
try {
|
|
1511
|
-
const content = (0, import_fs.readFileSync)(
|
|
1517
|
+
const content = (0, import_fs.readFileSync)(configFile(), "utf-8");
|
|
1512
1518
|
const match2 = content.match(/browse_root:\s*(.+)/);
|
|
1513
1519
|
if (match2?.[1]) return match2[1].trim();
|
|
1514
1520
|
} catch {
|
|
@@ -1517,7 +1523,7 @@ function loadBrowseRoot() {
|
|
|
1517
1523
|
}
|
|
1518
1524
|
function loadPublicUrl() {
|
|
1519
1525
|
try {
|
|
1520
|
-
const content = (0, import_fs.readFileSync)(
|
|
1526
|
+
const content = (0, import_fs.readFileSync)(configFile(), "utf-8");
|
|
1521
1527
|
const match2 = content.match(/public_url:\s*(.+)/);
|
|
1522
1528
|
if (match2?.[1]) return match2[1].trim();
|
|
1523
1529
|
} catch {
|
|
@@ -1526,7 +1532,7 @@ function loadPublicUrl() {
|
|
|
1526
1532
|
}
|
|
1527
1533
|
function loadCacheDir() {
|
|
1528
1534
|
try {
|
|
1529
|
-
const content = (0, import_fs.readFileSync)(
|
|
1535
|
+
const content = (0, import_fs.readFileSync)(configFile(), "utf-8");
|
|
1530
1536
|
const match2 = content.match(/cache_dir:\s*(.+)/);
|
|
1531
1537
|
if (match2?.[1]) return match2[1].trim();
|
|
1532
1538
|
} catch {
|
|
@@ -1535,7 +1541,7 @@ function loadCacheDir() {
|
|
|
1535
1541
|
}
|
|
1536
1542
|
function loadTailSize() {
|
|
1537
1543
|
try {
|
|
1538
|
-
const content = (0, import_fs.readFileSync)(
|
|
1544
|
+
const content = (0, import_fs.readFileSync)(configFile(), "utf-8");
|
|
1539
1545
|
const match2 = content.match(/tail_size:\s*(\d+)/);
|
|
1540
1546
|
if (match2?.[1]) return Number.parseInt(match2[1], 10);
|
|
1541
1547
|
} catch {
|
|
@@ -1565,10 +1571,11 @@ function stripTrailingSlash(url2) {
|
|
|
1565
1571
|
return url2.endsWith("/") ? url2.slice(0, -1) : url2;
|
|
1566
1572
|
}
|
|
1567
1573
|
function setApiKey(key) {
|
|
1568
|
-
|
|
1574
|
+
const file2 = configFile();
|
|
1575
|
+
(0, import_fs.mkdirSync)(configDir(), { recursive: true });
|
|
1569
1576
|
let content = "";
|
|
1570
1577
|
try {
|
|
1571
|
-
content = (0, import_fs.readFileSync)(
|
|
1578
|
+
content = (0, import_fs.readFileSync)(file2, "utf-8");
|
|
1572
1579
|
} catch (err) {
|
|
1573
1580
|
if (err.code !== "ENOENT") throw err;
|
|
1574
1581
|
}
|
|
@@ -1584,12 +1591,12 @@ function setApiKey(key) {
|
|
|
1584
1591
|
${apiKeyLine}
|
|
1585
1592
|
`;
|
|
1586
1593
|
}
|
|
1587
|
-
const tmpFile = `${
|
|
1594
|
+
const tmpFile = `${file2}.tmp`;
|
|
1588
1595
|
(0, import_fs.writeFileSync)(tmpFile, updated, { encoding: "utf-8", mode: 384 });
|
|
1589
1596
|
(0, import_fs.chmodSync)(tmpFile, 384);
|
|
1590
|
-
(0, import_fs.renameSync)(tmpFile,
|
|
1597
|
+
(0, import_fs.renameSync)(tmpFile, file2);
|
|
1591
1598
|
}
|
|
1592
|
-
var import_crypto, import_fs, import_os, import_path
|
|
1599
|
+
var import_crypto, import_fs, import_os, import_path;
|
|
1593
1600
|
var init_auth = __esm({
|
|
1594
1601
|
"src/auth.ts"() {
|
|
1595
1602
|
"use strict";
|
|
@@ -1597,8 +1604,6 @@ var init_auth = __esm({
|
|
|
1597
1604
|
import_fs = require("fs");
|
|
1598
1605
|
import_os = require("os");
|
|
1599
1606
|
import_path = require("path");
|
|
1600
|
-
CONFIG_DIR = (0, import_path.join)((0, import_os.homedir)(), ".threadbase");
|
|
1601
|
-
CONFIG_FILE = (0, import_path.join)(CONFIG_DIR, "server.yaml");
|
|
1602
1607
|
}
|
|
1603
1608
|
});
|
|
1604
1609
|
|
|
@@ -24089,6 +24094,27 @@ var init_zod = __esm({
|
|
|
24089
24094
|
}
|
|
24090
24095
|
});
|
|
24091
24096
|
|
|
24097
|
+
// src/lifecycle/constants.ts
|
|
24098
|
+
function installDir() {
|
|
24099
|
+
return process.env.THREADBASE_INSTALL_DIR ?? (0, import_node_path3.join)((0, import_node_os2.homedir)(), ".threadbase");
|
|
24100
|
+
}
|
|
24101
|
+
function markerPath() {
|
|
24102
|
+
return (0, import_node_path3.join)(installDir(), "prod-suspended.json");
|
|
24103
|
+
}
|
|
24104
|
+
function prefsPath() {
|
|
24105
|
+
return (0, import_node_path3.join)(installDir(), "dev-prefs.json");
|
|
24106
|
+
}
|
|
24107
|
+
var import_node_os2, import_node_path3, LAUNCHD_LABEL, TASK_NAME;
|
|
24108
|
+
var init_constants = __esm({
|
|
24109
|
+
"src/lifecycle/constants.ts"() {
|
|
24110
|
+
"use strict";
|
|
24111
|
+
import_node_os2 = require("os");
|
|
24112
|
+
import_node_path3 = require("path");
|
|
24113
|
+
LAUNCHD_LABEL = "com.ronen.threadbase";
|
|
24114
|
+
TASK_NAME = process.env.THREADBASE_TASK_NAME ?? "Threadbase";
|
|
24115
|
+
}
|
|
24116
|
+
});
|
|
24117
|
+
|
|
24092
24118
|
// node_modules/pino-std-serializers/lib/err-helpers.js
|
|
24093
24119
|
var require_err_helpers = __commonJS({
|
|
24094
24120
|
"node_modules/pino-std-serializers/lib/err-helpers.js"(exports2, module2) {
|
|
@@ -26078,7 +26104,7 @@ var require_thread_stream = __commonJS({
|
|
|
26078
26104
|
var { version: version2 } = require_package();
|
|
26079
26105
|
var { EventEmitter: EventEmitter6 } = require("events");
|
|
26080
26106
|
var { Worker: Worker2 } = require("worker_threads");
|
|
26081
|
-
var { join:
|
|
26107
|
+
var { join: join26 } = require("path");
|
|
26082
26108
|
var { pathToFileURL } = require("url");
|
|
26083
26109
|
var { wait } = require_wait();
|
|
26084
26110
|
var {
|
|
@@ -26129,7 +26155,7 @@ var require_thread_stream = __commonJS({
|
|
|
26129
26155
|
function createWorker(stream, opts) {
|
|
26130
26156
|
const { filename, workerData } = opts;
|
|
26131
26157
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
26132
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
26158
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join26(__dirname, "lib", "worker.js");
|
|
26133
26159
|
const worker = new Worker2(toExecute, {
|
|
26134
26160
|
...opts.workerOpts,
|
|
26135
26161
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -26597,7 +26623,7 @@ var require_transport = __commonJS({
|
|
|
26597
26623
|
var { createRequire } = require("module");
|
|
26598
26624
|
var { existsSync: existsSync11 } = require("fs");
|
|
26599
26625
|
var getCallers = require_caller();
|
|
26600
|
-
var { join:
|
|
26626
|
+
var { join: join26, isAbsolute: isAbsolute3, sep: sep2 } = require("path");
|
|
26601
26627
|
var { fileURLToPath: fileURLToPath3 } = require("url");
|
|
26602
26628
|
var sleep = require_atomic_sleep();
|
|
26603
26629
|
var onExit = require_on_exit_leak_free();
|
|
@@ -26750,7 +26776,7 @@ var require_transport = __commonJS({
|
|
|
26750
26776
|
throw new Error("only one of target or targets can be specified");
|
|
26751
26777
|
}
|
|
26752
26778
|
if (targets) {
|
|
26753
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
26779
|
+
target = bundlerOverrides["pino-worker"] || join26(__dirname, "worker.js");
|
|
26754
26780
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
26755
26781
|
return {
|
|
26756
26782
|
...dest,
|
|
@@ -26768,7 +26794,7 @@ var require_transport = __commonJS({
|
|
|
26768
26794
|
});
|
|
26769
26795
|
});
|
|
26770
26796
|
} else if (pipeline2) {
|
|
26771
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
26797
|
+
target = bundlerOverrides["pino-worker"] || join26(__dirname, "worker.js");
|
|
26772
26798
|
options.pipelines = [pipeline2.map((dest) => {
|
|
26773
26799
|
return {
|
|
26774
26800
|
...dest,
|
|
@@ -26791,7 +26817,7 @@ var require_transport = __commonJS({
|
|
|
26791
26817
|
return origin;
|
|
26792
26818
|
}
|
|
26793
26819
|
if (origin === "pino/file") {
|
|
26794
|
-
return
|
|
26820
|
+
return join26(__dirname, "..", "file.js");
|
|
26795
26821
|
}
|
|
26796
26822
|
let fixTarget2;
|
|
26797
26823
|
for (const filePath of callers) {
|
|
@@ -27772,7 +27798,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
27772
27798
|
return circularValue;
|
|
27773
27799
|
}
|
|
27774
27800
|
let res = "";
|
|
27775
|
-
let
|
|
27801
|
+
let join26 = ",";
|
|
27776
27802
|
const originalIndentation = indentation;
|
|
27777
27803
|
if (Array.isArray(value)) {
|
|
27778
27804
|
if (value.length === 0) {
|
|
@@ -27786,7 +27812,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
27786
27812
|
indentation += spacer;
|
|
27787
27813
|
res += `
|
|
27788
27814
|
${indentation}`;
|
|
27789
|
-
|
|
27815
|
+
join26 = `,
|
|
27790
27816
|
${indentation}`;
|
|
27791
27817
|
}
|
|
27792
27818
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -27794,13 +27820,13 @@ ${indentation}`;
|
|
|
27794
27820
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
27795
27821
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
27796
27822
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
27797
|
-
res +=
|
|
27823
|
+
res += join26;
|
|
27798
27824
|
}
|
|
27799
27825
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
27800
27826
|
res += tmp !== void 0 ? tmp : "null";
|
|
27801
27827
|
if (value.length - 1 > maximumBreadth) {
|
|
27802
27828
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
27803
|
-
res += `${
|
|
27829
|
+
res += `${join26}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
27804
27830
|
}
|
|
27805
27831
|
if (spacer !== "") {
|
|
27806
27832
|
res += `
|
|
@@ -27821,7 +27847,7 @@ ${originalIndentation}`;
|
|
|
27821
27847
|
let separator = "";
|
|
27822
27848
|
if (spacer !== "") {
|
|
27823
27849
|
indentation += spacer;
|
|
27824
|
-
|
|
27850
|
+
join26 = `,
|
|
27825
27851
|
${indentation}`;
|
|
27826
27852
|
whitespace = " ";
|
|
27827
27853
|
}
|
|
@@ -27835,13 +27861,13 @@ ${indentation}`;
|
|
|
27835
27861
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
27836
27862
|
if (tmp !== void 0) {
|
|
27837
27863
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
27838
|
-
separator =
|
|
27864
|
+
separator = join26;
|
|
27839
27865
|
}
|
|
27840
27866
|
}
|
|
27841
27867
|
if (keyLength > maximumBreadth) {
|
|
27842
27868
|
const removedKeys = keyLength - maximumBreadth;
|
|
27843
27869
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
27844
|
-
separator =
|
|
27870
|
+
separator = join26;
|
|
27845
27871
|
}
|
|
27846
27872
|
if (spacer !== "" && separator.length > 1) {
|
|
27847
27873
|
res = `
|
|
@@ -27882,7 +27908,7 @@ ${originalIndentation}`;
|
|
|
27882
27908
|
}
|
|
27883
27909
|
const originalIndentation = indentation;
|
|
27884
27910
|
let res = "";
|
|
27885
|
-
let
|
|
27911
|
+
let join26 = ",";
|
|
27886
27912
|
if (Array.isArray(value)) {
|
|
27887
27913
|
if (value.length === 0) {
|
|
27888
27914
|
return "[]";
|
|
@@ -27895,7 +27921,7 @@ ${originalIndentation}`;
|
|
|
27895
27921
|
indentation += spacer;
|
|
27896
27922
|
res += `
|
|
27897
27923
|
${indentation}`;
|
|
27898
|
-
|
|
27924
|
+
join26 = `,
|
|
27899
27925
|
${indentation}`;
|
|
27900
27926
|
}
|
|
27901
27927
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -27903,13 +27929,13 @@ ${indentation}`;
|
|
|
27903
27929
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
27904
27930
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
27905
27931
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
27906
|
-
res +=
|
|
27932
|
+
res += join26;
|
|
27907
27933
|
}
|
|
27908
27934
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
27909
27935
|
res += tmp !== void 0 ? tmp : "null";
|
|
27910
27936
|
if (value.length - 1 > maximumBreadth) {
|
|
27911
27937
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
27912
|
-
res += `${
|
|
27938
|
+
res += `${join26}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
27913
27939
|
}
|
|
27914
27940
|
if (spacer !== "") {
|
|
27915
27941
|
res += `
|
|
@@ -27922,7 +27948,7 @@ ${originalIndentation}`;
|
|
|
27922
27948
|
let whitespace = "";
|
|
27923
27949
|
if (spacer !== "") {
|
|
27924
27950
|
indentation += spacer;
|
|
27925
|
-
|
|
27951
|
+
join26 = `,
|
|
27926
27952
|
${indentation}`;
|
|
27927
27953
|
whitespace = " ";
|
|
27928
27954
|
}
|
|
@@ -27931,7 +27957,7 @@ ${indentation}`;
|
|
|
27931
27957
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
27932
27958
|
if (tmp !== void 0) {
|
|
27933
27959
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
27934
|
-
separator =
|
|
27960
|
+
separator = join26;
|
|
27935
27961
|
}
|
|
27936
27962
|
}
|
|
27937
27963
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -27989,20 +28015,20 @@ ${originalIndentation}`;
|
|
|
27989
28015
|
indentation += spacer;
|
|
27990
28016
|
let res2 = `
|
|
27991
28017
|
${indentation}`;
|
|
27992
|
-
const
|
|
28018
|
+
const join27 = `,
|
|
27993
28019
|
${indentation}`;
|
|
27994
28020
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
27995
28021
|
let i = 0;
|
|
27996
28022
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
27997
28023
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
27998
28024
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
27999
|
-
res2 +=
|
|
28025
|
+
res2 += join27;
|
|
28000
28026
|
}
|
|
28001
28027
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
28002
28028
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
28003
28029
|
if (value.length - 1 > maximumBreadth) {
|
|
28004
28030
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
28005
|
-
res2 += `${
|
|
28031
|
+
res2 += `${join27}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
28006
28032
|
}
|
|
28007
28033
|
res2 += `
|
|
28008
28034
|
${originalIndentation}`;
|
|
@@ -28018,16 +28044,16 @@ ${originalIndentation}`;
|
|
|
28018
28044
|
return '"[Object]"';
|
|
28019
28045
|
}
|
|
28020
28046
|
indentation += spacer;
|
|
28021
|
-
const
|
|
28047
|
+
const join26 = `,
|
|
28022
28048
|
${indentation}`;
|
|
28023
28049
|
let res = "";
|
|
28024
28050
|
let separator = "";
|
|
28025
28051
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
28026
28052
|
if (isTypedArrayWithEntries(value)) {
|
|
28027
|
-
res += stringifyTypedArray(value,
|
|
28053
|
+
res += stringifyTypedArray(value, join26, maximumBreadth);
|
|
28028
28054
|
keys = keys.slice(value.length);
|
|
28029
28055
|
maximumPropertiesToStringify -= value.length;
|
|
28030
|
-
separator =
|
|
28056
|
+
separator = join26;
|
|
28031
28057
|
}
|
|
28032
28058
|
if (deterministic) {
|
|
28033
28059
|
keys = sort(keys, comparator);
|
|
@@ -28038,13 +28064,13 @@ ${indentation}`;
|
|
|
28038
28064
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
28039
28065
|
if (tmp !== void 0) {
|
|
28040
28066
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
28041
|
-
separator =
|
|
28067
|
+
separator = join26;
|
|
28042
28068
|
}
|
|
28043
28069
|
}
|
|
28044
28070
|
if (keyLength > maximumBreadth) {
|
|
28045
28071
|
const removedKeys = keyLength - maximumBreadth;
|
|
28046
28072
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
28047
|
-
separator =
|
|
28073
|
+
separator = join26;
|
|
28048
28074
|
}
|
|
28049
28075
|
if (separator !== "") {
|
|
28050
28076
|
res = `
|
|
@@ -124397,27 +124423,6 @@ var require_semver2 = __commonJS({
|
|
|
124397
124423
|
}
|
|
124398
124424
|
});
|
|
124399
124425
|
|
|
124400
|
-
// src/lifecycle/constants.ts
|
|
124401
|
-
function installDir() {
|
|
124402
|
-
return process.env.THREADBASE_INSTALL_DIR ?? (0, import_node_path22.join)((0, import_node_os4.homedir)(), ".threadbase");
|
|
124403
|
-
}
|
|
124404
|
-
function markerPath() {
|
|
124405
|
-
return (0, import_node_path22.join)(installDir(), "prod-suspended.json");
|
|
124406
|
-
}
|
|
124407
|
-
function prefsPath() {
|
|
124408
|
-
return (0, import_node_path22.join)(installDir(), "dev-prefs.json");
|
|
124409
|
-
}
|
|
124410
|
-
var import_node_os4, import_node_path22, LAUNCHD_LABEL, TASK_NAME;
|
|
124411
|
-
var init_constants = __esm({
|
|
124412
|
-
"src/lifecycle/constants.ts"() {
|
|
124413
|
-
"use strict";
|
|
124414
|
-
import_node_os4 = require("os");
|
|
124415
|
-
import_node_path22 = require("path");
|
|
124416
|
-
LAUNCHD_LABEL = "com.ronen.threadbase";
|
|
124417
|
-
TASK_NAME = process.env.THREADBASE_TASK_NAME ?? "Threadbase";
|
|
124418
|
-
}
|
|
124419
|
-
});
|
|
124420
|
-
|
|
124421
124426
|
// src/lifecycle/launchd.ts
|
|
124422
124427
|
var launchd_exports = {};
|
|
124423
124428
|
__export(launchd_exports, {
|
|
@@ -124487,8 +124492,8 @@ function darwinPlistPath() {
|
|
|
124487
124492
|
return `${process.env.HOME}/Library/LaunchAgents/${resolveLoadedLabel()}.plist`;
|
|
124488
124493
|
}
|
|
124489
124494
|
function getLogPaths() {
|
|
124490
|
-
const dir = (0,
|
|
124491
|
-
return { stdout: (0,
|
|
124495
|
+
const dir = (0, import_node_path24.join)(installDir(), "logs");
|
|
124496
|
+
return { stdout: (0, import_node_path24.join)(dir, "stdout.log"), stderr: (0, import_node_path24.join)(dir, "stderr.log") };
|
|
124492
124497
|
}
|
|
124493
124498
|
function getAgentPid() {
|
|
124494
124499
|
try {
|
|
@@ -124508,12 +124513,12 @@ function getAgentPid() {
|
|
|
124508
124513
|
return null;
|
|
124509
124514
|
}
|
|
124510
124515
|
}
|
|
124511
|
-
var import_node_child_process4,
|
|
124516
|
+
var import_node_child_process4, import_node_path24, BREW_LAUNCHD_LABEL2;
|
|
124512
124517
|
var init_launchd = __esm({
|
|
124513
124518
|
"src/lifecycle/launchd.ts"() {
|
|
124514
124519
|
"use strict";
|
|
124515
124520
|
import_node_child_process4 = require("child_process");
|
|
124516
|
-
|
|
124521
|
+
import_node_path24 = require("path");
|
|
124517
124522
|
init_constants();
|
|
124518
124523
|
BREW_LAUNCHD_LABEL2 = "homebrew.mxcl.tb-streamer";
|
|
124519
124524
|
}
|
|
@@ -124538,9 +124543,9 @@ var init_marker_schema = __esm({
|
|
|
124538
124543
|
|
|
124539
124544
|
// src/lifecycle/marker.ts
|
|
124540
124545
|
function readMarker() {
|
|
124541
|
-
if (!(0,
|
|
124546
|
+
if (!(0, import_node_fs20.existsSync)(markerPath())) return null;
|
|
124542
124547
|
try {
|
|
124543
|
-
const raw2 = (0,
|
|
124548
|
+
const raw2 = (0, import_node_fs20.readFileSync)(markerPath(), "utf8");
|
|
124544
124549
|
const parsed = JSON.parse(raw2);
|
|
124545
124550
|
return MarkerSchema.parse(parsed);
|
|
124546
124551
|
} catch (err) {
|
|
@@ -124552,21 +124557,21 @@ function readMarker() {
|
|
|
124552
124557
|
}
|
|
124553
124558
|
function writeMarker(marker) {
|
|
124554
124559
|
MarkerSchema.parse(marker);
|
|
124555
|
-
(0,
|
|
124560
|
+
(0, import_node_fs20.mkdirSync)((0, import_node_path25.dirname)(markerPath()), { recursive: true });
|
|
124556
124561
|
const tmp = `${markerPath()}.tmp`;
|
|
124557
|
-
(0,
|
|
124562
|
+
(0, import_node_fs20.writeFileSync)(tmp, `${JSON.stringify(marker, null, 2)}
|
|
124558
124563
|
`, { mode: 384 });
|
|
124559
|
-
(0,
|
|
124564
|
+
(0, import_node_fs20.renameSync)(tmp, markerPath());
|
|
124560
124565
|
}
|
|
124561
124566
|
function clearMarker() {
|
|
124562
|
-
if ((0,
|
|
124567
|
+
if ((0, import_node_fs20.existsSync)(markerPath())) (0, import_node_fs20.rmSync)(markerPath());
|
|
124563
124568
|
}
|
|
124564
|
-
var
|
|
124569
|
+
var import_node_fs20, import_node_path25, log3;
|
|
124565
124570
|
var init_marker = __esm({
|
|
124566
124571
|
"src/lifecycle/marker.ts"() {
|
|
124567
124572
|
"use strict";
|
|
124568
|
-
|
|
124569
|
-
|
|
124573
|
+
import_node_fs20 = require("fs");
|
|
124574
|
+
import_node_path25 = require("path");
|
|
124570
124575
|
init_logger();
|
|
124571
124576
|
init_constants();
|
|
124572
124577
|
init_marker_schema();
|
|
@@ -124661,9 +124666,9 @@ var init_platform = __esm({
|
|
|
124661
124666
|
// src/lifecycle/prefs.ts
|
|
124662
124667
|
function readPrefs() {
|
|
124663
124668
|
const path2 = prefsPath();
|
|
124664
|
-
if (!(0,
|
|
124669
|
+
if (!(0, import_node_fs22.existsSync)(path2)) return { repos: {} };
|
|
124665
124670
|
try {
|
|
124666
|
-
return PrefsSchema.parse(JSON.parse((0,
|
|
124671
|
+
return PrefsSchema.parse(JSON.parse((0, import_node_fs22.readFileSync)(path2, "utf8")));
|
|
124667
124672
|
} catch (err) {
|
|
124668
124673
|
log5.warn(`prefs at ${path2} are malformed; treating as empty`, {
|
|
124669
124674
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -124673,11 +124678,11 @@ function readPrefs() {
|
|
|
124673
124678
|
}
|
|
124674
124679
|
function savePrefs(p2) {
|
|
124675
124680
|
const path2 = prefsPath();
|
|
124676
|
-
(0,
|
|
124681
|
+
(0, import_node_fs22.mkdirSync)((0, import_node_path26.dirname)(path2), { recursive: true });
|
|
124677
124682
|
const tmp = `${path2}.tmp`;
|
|
124678
|
-
(0,
|
|
124683
|
+
(0, import_node_fs22.writeFileSync)(tmp, `${JSON.stringify(p2, null, 2)}
|
|
124679
124684
|
`, { mode: 384 });
|
|
124680
|
-
(0,
|
|
124685
|
+
(0, import_node_fs22.renameSync)(tmp, path2);
|
|
124681
124686
|
}
|
|
124682
124687
|
function writePrefForRepo(repoToplevel, choice) {
|
|
124683
124688
|
const p2 = readPrefs();
|
|
@@ -124698,14 +124703,14 @@ function forgetRepo(repoToplevel) {
|
|
|
124698
124703
|
}
|
|
124699
124704
|
function forgetAll() {
|
|
124700
124705
|
const path2 = prefsPath();
|
|
124701
|
-
if ((0,
|
|
124706
|
+
if ((0, import_node_fs22.existsSync)(path2)) (0, import_node_fs22.rmSync)(path2);
|
|
124702
124707
|
}
|
|
124703
|
-
var
|
|
124708
|
+
var import_node_fs22, import_node_path26, log5, PrefsSchema;
|
|
124704
124709
|
var init_prefs = __esm({
|
|
124705
124710
|
"src/lifecycle/prefs.ts"() {
|
|
124706
124711
|
"use strict";
|
|
124707
|
-
|
|
124708
|
-
|
|
124712
|
+
import_node_fs22 = require("fs");
|
|
124713
|
+
import_node_path26 = require("path");
|
|
124709
124714
|
init_zod();
|
|
124710
124715
|
init_logger();
|
|
124711
124716
|
init_constants();
|
|
@@ -128384,6 +128389,23 @@ function loadUpdateConfig(opts = {}) {
|
|
|
128384
128389
|
return UpdateConfigSchema.parse(parsed);
|
|
128385
128390
|
}
|
|
128386
128391
|
|
|
128392
|
+
// src/devLog.ts
|
|
128393
|
+
var import_node_fs3 = require("fs");
|
|
128394
|
+
var import_node_path4 = require("path");
|
|
128395
|
+
init_constants();
|
|
128396
|
+
function devLogPath() {
|
|
128397
|
+
return (0, import_node_path4.join)(installDir(), "logs", "dev.log");
|
|
128398
|
+
}
|
|
128399
|
+
function appendDevSessionMarker() {
|
|
128400
|
+
try {
|
|
128401
|
+
const path2 = devLogPath();
|
|
128402
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path4.join)(installDir(), "logs"), { recursive: true });
|
|
128403
|
+
(0, import_node_fs3.appendFileSync)(path2, `=== dev session started ${(/* @__PURE__ */ new Date()).toISOString()} ===
|
|
128404
|
+
`, "utf8");
|
|
128405
|
+
} catch {
|
|
128406
|
+
}
|
|
128407
|
+
}
|
|
128408
|
+
|
|
128387
128409
|
// src/lan-url.ts
|
|
128388
128410
|
var import_os2 = require("os");
|
|
128389
128411
|
function resolveServerUrl({ publicUrl, port }) {
|
|
@@ -129428,7 +129450,7 @@ var sysPath2 = __toESM(require("path"), 1);
|
|
|
129428
129450
|
// node_modules/@threadbase-sh/scanner/node_modules/readdirp/esm/index.js
|
|
129429
129451
|
var import_promises = require("fs/promises");
|
|
129430
129452
|
var import_node_stream = require("stream");
|
|
129431
|
-
var
|
|
129453
|
+
var import_node_path5 = require("path");
|
|
129432
129454
|
var EntryTypes = {
|
|
129433
129455
|
FILE_TYPE: "files",
|
|
129434
129456
|
DIR_TYPE: "directories",
|
|
@@ -129503,7 +129525,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
129503
129525
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
129504
129526
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
129505
129527
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
129506
|
-
this._root = (0,
|
|
129528
|
+
this._root = (0, import_node_path5.resolve)(root);
|
|
129507
129529
|
this._isDirent = !opts.alwaysStat;
|
|
129508
129530
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
129509
129531
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
@@ -129574,8 +129596,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
129574
129596
|
let entry;
|
|
129575
129597
|
const basename9 = this._isDirent ? dirent.name : dirent;
|
|
129576
129598
|
try {
|
|
129577
|
-
const fullPath = (0,
|
|
129578
|
-
entry = { path: (0,
|
|
129599
|
+
const fullPath = (0, import_node_path5.resolve)((0, import_node_path5.join)(path2, basename9));
|
|
129600
|
+
entry = { path: (0, import_node_path5.relative)(this._root, fullPath), fullPath, basename: basename9 };
|
|
129579
129601
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
129580
129602
|
} catch (err) {
|
|
129581
129603
|
this._onError(err);
|
|
@@ -129609,7 +129631,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
129609
129631
|
}
|
|
129610
129632
|
if (entryRealPathStats.isDirectory()) {
|
|
129611
129633
|
const len = entryRealPath.length;
|
|
129612
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
129634
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path5.sep) {
|
|
129613
129635
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
129614
129636
|
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
129615
129637
|
return this._onError(recursiveError);
|
|
@@ -131406,8 +131428,8 @@ function writeSidecar(jsonlPath, sidecar) {
|
|
|
131406
131428
|
}
|
|
131407
131429
|
}
|
|
131408
131430
|
var PROFILES_FILE = "profiles.json";
|
|
131409
|
-
function resolveConfigDir(
|
|
131410
|
-
return
|
|
131431
|
+
function resolveConfigDir(configDir2) {
|
|
131432
|
+
return configDir2.replace(/^~/, (0, import_os4.homedir)());
|
|
131411
131433
|
}
|
|
131412
131434
|
function getProjectsDir(profile) {
|
|
131413
131435
|
return (0, import_path3.join)(resolveConfigDir(profile.configDir), "projects");
|
|
@@ -134045,7 +134067,7 @@ function readAgentConfig(env = process.env) {
|
|
|
134045
134067
|
|
|
134046
134068
|
// src/agent/conversation-writer.ts
|
|
134047
134069
|
var import_promises7 = require("fs/promises");
|
|
134048
|
-
var
|
|
134070
|
+
var import_node_path6 = require("path");
|
|
134049
134071
|
function createConversationWriter(opts) {
|
|
134050
134072
|
const { baseDir } = opts;
|
|
134051
134073
|
return {
|
|
@@ -134053,8 +134075,8 @@ function createConversationWriter(opts) {
|
|
|
134053
134075
|
if (!args.content || args.content.length === 0) {
|
|
134054
134076
|
throw new Error("ConversationWriter: refusing to write empty assistant turn");
|
|
134055
134077
|
}
|
|
134056
|
-
const file2 = (0,
|
|
134057
|
-
await (0, import_promises7.mkdir)((0,
|
|
134078
|
+
const file2 = (0, import_node_path6.join)(baseDir, `${args.sessionId}.jsonl`);
|
|
134079
|
+
await (0, import_promises7.mkdir)((0, import_node_path6.dirname)(file2), { recursive: true });
|
|
134058
134080
|
const record2 = {
|
|
134059
134081
|
role: "assistant",
|
|
134060
134082
|
turnId: args.turnId,
|
|
@@ -134253,8 +134275,8 @@ async function handleSendAgentInput(sessionId, body, deps) {
|
|
|
134253
134275
|
}
|
|
134254
134276
|
|
|
134255
134277
|
// src/agent/handle-start-agent-session.ts
|
|
134256
|
-
var
|
|
134257
|
-
var
|
|
134278
|
+
var import_node_fs4 = require("fs");
|
|
134279
|
+
var import_node_path7 = require("path");
|
|
134258
134280
|
function validateBody(body) {
|
|
134259
134281
|
if (body === null || body === void 0 || typeof body !== "object") {
|
|
134260
134282
|
return { ok: false };
|
|
@@ -134284,8 +134306,8 @@ async function handleStartAgentSession(body, deps) {
|
|
|
134284
134306
|
}
|
|
134285
134307
|
let conversationId = parsed.conversationId;
|
|
134286
134308
|
if (conversationId) {
|
|
134287
|
-
const jsonlPath = (0,
|
|
134288
|
-
if (!(0,
|
|
134309
|
+
const jsonlPath = (0, import_node_path7.join)(deps.conversationsDir, `${conversationId}.jsonl`);
|
|
134310
|
+
if (!(0, import_node_fs4.existsSync)(jsonlPath)) {
|
|
134289
134311
|
return {
|
|
134290
134312
|
status: 404,
|
|
134291
134313
|
body: agentErrorResponse(
|
|
@@ -136515,8 +136537,8 @@ var createConversationRoutes = (deps) => {
|
|
|
136515
136537
|
};
|
|
136516
136538
|
|
|
136517
136539
|
// src/version.ts
|
|
136518
|
-
var
|
|
136519
|
-
var
|
|
136540
|
+
var import_node_fs5 = require("fs");
|
|
136541
|
+
var import_node_path8 = require("path");
|
|
136520
136542
|
var cached2;
|
|
136521
136543
|
function getVersion() {
|
|
136522
136544
|
if (cached2 !== void 0) return cached2;
|
|
@@ -136525,22 +136547,22 @@ function getVersion() {
|
|
|
136525
136547
|
}
|
|
136526
136548
|
function resolveVersion() {
|
|
136527
136549
|
const scriptPath = process.argv[1] ?? "";
|
|
136528
|
-
const here = scriptPath ? (0,
|
|
136550
|
+
const here = scriptPath ? (0, import_node_path8.dirname)(scriptPath) : process.cwd();
|
|
136529
136551
|
let realHere = here;
|
|
136530
136552
|
try {
|
|
136531
|
-
realHere = (0,
|
|
136553
|
+
realHere = (0, import_node_path8.dirname)((0, import_node_fs5.realpathSync)(scriptPath));
|
|
136532
136554
|
} catch {
|
|
136533
136555
|
}
|
|
136534
|
-
const searchDirs = realHere === here ? [here, (0,
|
|
136556
|
+
const searchDirs = realHere === here ? [here, (0, import_node_path8.join)(here, "..")] : [here, (0, import_node_path8.join)(here, ".."), realHere, (0, import_node_path8.join)(realHere, "..")];
|
|
136535
136557
|
for (const dir of searchDirs) {
|
|
136536
136558
|
try {
|
|
136537
|
-
const v3 = (0,
|
|
136559
|
+
const v3 = (0, import_node_fs5.readFileSync)((0, import_node_path8.join)(dir, "version.txt"), "utf8").trim();
|
|
136538
136560
|
if (v3) return v3;
|
|
136539
136561
|
} catch {
|
|
136540
136562
|
}
|
|
136541
136563
|
}
|
|
136542
136564
|
try {
|
|
136543
|
-
const pkg = JSON.parse((0,
|
|
136565
|
+
const pkg = JSON.parse((0, import_node_fs5.readFileSync)((0, import_node_path8.join)(here, "..", "package.json"), "utf8"));
|
|
136544
136566
|
if (pkg.version) return `${pkg.version}+source`;
|
|
136545
136567
|
} catch {
|
|
136546
136568
|
}
|
|
@@ -139177,13 +139199,13 @@ function seal(plaintext, recipientPublicKeyBase64) {
|
|
|
139177
139199
|
|
|
139178
139200
|
// node_modules/chokidar/index.js
|
|
139179
139201
|
var import_node_events2 = require("events");
|
|
139180
|
-
var
|
|
139202
|
+
var import_node_fs7 = require("fs");
|
|
139181
139203
|
var import_promises11 = require("fs/promises");
|
|
139182
139204
|
var sp2 = __toESM(require("path"), 1);
|
|
139183
139205
|
|
|
139184
139206
|
// node_modules/readdirp/index.js
|
|
139185
139207
|
var import_promises9 = require("fs/promises");
|
|
139186
|
-
var
|
|
139208
|
+
var import_node_path9 = require("path");
|
|
139187
139209
|
var import_node_stream2 = require("stream");
|
|
139188
139210
|
var EntryTypes2 = {
|
|
139189
139211
|
FILE_TYPE: "files",
|
|
@@ -139273,7 +139295,7 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
|
|
|
139273
139295
|
this._wantsDir = type ? DIR_TYPES2.has(type) : false;
|
|
139274
139296
|
this._wantsFile = type ? FILE_TYPES2.has(type) : false;
|
|
139275
139297
|
this._wantsEverything = type === EntryTypes2.EVERYTHING_TYPE;
|
|
139276
|
-
this._root = (0,
|
|
139298
|
+
this._root = (0, import_node_path9.resolve)(root);
|
|
139277
139299
|
this._isDirent = !opts.alwaysStat;
|
|
139278
139300
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
139279
139301
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
@@ -139344,8 +139366,8 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
|
|
|
139344
139366
|
let entry;
|
|
139345
139367
|
const basename9 = this._isDirent ? dirent.name : dirent;
|
|
139346
139368
|
try {
|
|
139347
|
-
const fullPath = (0,
|
|
139348
|
-
entry = { path: (0,
|
|
139369
|
+
const fullPath = (0, import_node_path9.resolve)((0, import_node_path9.join)(path2, basename9));
|
|
139370
|
+
entry = { path: (0, import_node_path9.relative)(this._root, fullPath), fullPath, basename: basename9 };
|
|
139349
139371
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
139350
139372
|
} catch (err) {
|
|
139351
139373
|
this._onError(err);
|
|
@@ -139379,7 +139401,7 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
|
|
|
139379
139401
|
}
|
|
139380
139402
|
if (entryRealPathStats.isDirectory()) {
|
|
139381
139403
|
const len = entryRealPath.length;
|
|
139382
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
139404
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path9.sep) {
|
|
139383
139405
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
139384
139406
|
recursiveError.code = RECURSIVE_ERROR_CODE2;
|
|
139385
139407
|
return this._onError(recursiveError);
|
|
@@ -139415,9 +139437,9 @@ function readdirp2(root, options = {}) {
|
|
|
139415
139437
|
}
|
|
139416
139438
|
|
|
139417
139439
|
// node_modules/chokidar/handler.js
|
|
139418
|
-
var
|
|
139440
|
+
var import_node_fs6 = require("fs");
|
|
139419
139441
|
var import_promises10 = require("fs/promises");
|
|
139420
|
-
var
|
|
139442
|
+
var import_node_os3 = require("os");
|
|
139421
139443
|
var sp = __toESM(require("path"), 1);
|
|
139422
139444
|
var STR_DATA2 = "data";
|
|
139423
139445
|
var STR_END2 = "end";
|
|
@@ -139429,7 +139451,7 @@ var isWindows3 = pl2 === "win32";
|
|
|
139429
139451
|
var isMacos2 = pl2 === "darwin";
|
|
139430
139452
|
var isLinux2 = pl2 === "linux";
|
|
139431
139453
|
var isFreeBSD2 = pl2 === "freebsd";
|
|
139432
|
-
var isIBMi2 = (0,
|
|
139454
|
+
var isIBMi2 = (0, import_node_os3.type)() === "OS400";
|
|
139433
139455
|
var EVENTS2 = {
|
|
139434
139456
|
ALL: "all",
|
|
139435
139457
|
READY: "ready",
|
|
@@ -139753,7 +139775,7 @@ function createFsWatchInstance2(path2, options, listener, errHandler, emitRaw) {
|
|
|
139753
139775
|
}
|
|
139754
139776
|
};
|
|
139755
139777
|
try {
|
|
139756
|
-
return (0,
|
|
139778
|
+
return (0, import_node_fs6.watch)(path2, {
|
|
139757
139779
|
persistent: options.persistent
|
|
139758
139780
|
}, handleEvent);
|
|
139759
139781
|
} catch (error51) {
|
|
@@ -139836,7 +139858,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
|
|
|
139836
139858
|
let cont = FsWatchFileInstances2.get(fullPath);
|
|
139837
139859
|
const copts = cont && cont.options;
|
|
139838
139860
|
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
|
139839
|
-
(0,
|
|
139861
|
+
(0, import_node_fs6.unwatchFile)(fullPath);
|
|
139840
139862
|
cont = void 0;
|
|
139841
139863
|
}
|
|
139842
139864
|
if (cont) {
|
|
@@ -139847,7 +139869,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
|
|
|
139847
139869
|
listeners: listener,
|
|
139848
139870
|
rawEmitters: rawEmitter,
|
|
139849
139871
|
options,
|
|
139850
|
-
watcher: (0,
|
|
139872
|
+
watcher: (0, import_node_fs6.watchFile)(fullPath, options, (curr, prev) => {
|
|
139851
139873
|
foreach2(cont.rawEmitters, (rawEmitter2) => {
|
|
139852
139874
|
rawEmitter2(EV2.CHANGE, fullPath, { curr, prev });
|
|
139853
139875
|
});
|
|
@@ -139864,7 +139886,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
|
|
|
139864
139886
|
delFromSet2(cont, KEY_RAW2, rawEmitter);
|
|
139865
139887
|
if (isEmptySet2(cont.listeners)) {
|
|
139866
139888
|
FsWatchFileInstances2.delete(fullPath);
|
|
139867
|
-
(0,
|
|
139889
|
+
(0, import_node_fs6.unwatchFile)(fullPath);
|
|
139868
139890
|
cont.options = cont.watcher = void 0;
|
|
139869
139891
|
Object.freeze(cont);
|
|
139870
139892
|
}
|
|
@@ -140734,7 +140756,7 @@ var FSWatcher2 = class extends import_node_events2.EventEmitter {
|
|
|
140734
140756
|
const now = /* @__PURE__ */ new Date();
|
|
140735
140757
|
const writes = this._pendingWrites;
|
|
140736
140758
|
function awaitWriteFinishFn(prevStat) {
|
|
140737
|
-
(0,
|
|
140759
|
+
(0, import_node_fs7.stat)(fullPath, (err, curStat) => {
|
|
140738
140760
|
if (err || !writes.has(path2)) {
|
|
140739
140761
|
if (err && err.code !== "ENOENT")
|
|
140740
140762
|
awfEmit(err);
|
|
@@ -142602,10 +142624,17 @@ var StreamerServer = class {
|
|
|
142602
142624
|
});
|
|
142603
142625
|
}
|
|
142604
142626
|
rotateApiKey() {
|
|
142627
|
+
const oldKey = this.apiKey;
|
|
142605
142628
|
const newKey = generateApiKey();
|
|
142606
142629
|
const persisted = this.apiKeySource === "config";
|
|
142607
142630
|
if (persisted) setApiKey(newKey);
|
|
142608
142631
|
this.apiKey = newKey;
|
|
142632
|
+
this.log.info("API key rotated", {
|
|
142633
|
+
event: "auth.api_key_rotated",
|
|
142634
|
+
oldKeyMasked: `${oldKey.slice(0, 6)}\u2026`,
|
|
142635
|
+
newKeyMasked: `${newKey.slice(0, 6)}\u2026`,
|
|
142636
|
+
persisted
|
|
142637
|
+
});
|
|
142609
142638
|
return { newKey, persisted };
|
|
142610
142639
|
}
|
|
142611
142640
|
checkRateLimit(map2, key, limit, windowMs) {
|
|
@@ -144085,7 +144114,7 @@ async function checkForUpdate(opts) {
|
|
|
144085
144114
|
}
|
|
144086
144115
|
|
|
144087
144116
|
// src/updater/install.ts
|
|
144088
|
-
var
|
|
144117
|
+
var import_node_fs19 = require("fs");
|
|
144089
144118
|
|
|
144090
144119
|
// src/updater/active-sessions.ts
|
|
144091
144120
|
async function countActiveSessions(opts) {
|
|
@@ -144138,8 +144167,8 @@ function isBrewInstall(scriptPath = process.argv[1] ?? "") {
|
|
|
144138
144167
|
|
|
144139
144168
|
// src/updater/download.ts
|
|
144140
144169
|
var import_node_crypto4 = require("crypto");
|
|
144141
|
-
var
|
|
144142
|
-
var
|
|
144170
|
+
var import_node_fs8 = require("fs");
|
|
144171
|
+
var import_node_path10 = require("path");
|
|
144143
144172
|
var import_promises15 = require("stream/promises");
|
|
144144
144173
|
|
|
144145
144174
|
// src/updater/manifest.ts
|
|
@@ -144199,13 +144228,13 @@ async function downloadAndVerify(opts) {
|
|
|
144199
144228
|
`Manifest references ${artifact.filename} but it is not attached to the release`
|
|
144200
144229
|
);
|
|
144201
144230
|
}
|
|
144202
|
-
(0,
|
|
144231
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path10.dirname)(targetPath), { recursive: true });
|
|
144203
144232
|
const res = await fetch(asset.browserDownloadUrl);
|
|
144204
144233
|
if (!res.ok || !res.body) {
|
|
144205
144234
|
throw new Error(`Failed to download ${artifact.filename}: ${res.status} ${res.statusText}`);
|
|
144206
144235
|
}
|
|
144207
144236
|
const hash2 = (0, import_node_crypto4.createHash)("sha256");
|
|
144208
|
-
const out = (0,
|
|
144237
|
+
const out = (0, import_node_fs8.createWriteStream)(targetPath);
|
|
144209
144238
|
let bytes = 0;
|
|
144210
144239
|
const measured = new TransformStream({
|
|
144211
144240
|
transform(chunk, controller) {
|
|
@@ -144217,19 +144246,19 @@ async function downloadAndVerify(opts) {
|
|
|
144217
144246
|
try {
|
|
144218
144247
|
await (0, import_promises15.pipeline)(res.body.pipeThrough(measured), out);
|
|
144219
144248
|
} catch (err) {
|
|
144220
|
-
(0,
|
|
144249
|
+
(0, import_node_fs8.rmSync)(targetPath, { force: true });
|
|
144221
144250
|
throw err;
|
|
144222
144251
|
}
|
|
144223
144252
|
const actual = hash2.digest("hex");
|
|
144224
144253
|
if (actual !== artifact.sha256) {
|
|
144225
|
-
(0,
|
|
144254
|
+
(0, import_node_fs8.rmSync)(targetPath, { force: true });
|
|
144226
144255
|
throw new Error(
|
|
144227
144256
|
`sha256 mismatch for ${artifact.filename}: expected ${artifact.sha256}, got ${actual}`
|
|
144228
144257
|
);
|
|
144229
144258
|
}
|
|
144230
|
-
const stat10 = (0,
|
|
144259
|
+
const stat10 = (0, import_node_fs8.statSync)(targetPath);
|
|
144231
144260
|
if (stat10.size !== artifact.size) {
|
|
144232
|
-
(0,
|
|
144261
|
+
(0, import_node_fs8.rmSync)(targetPath, { force: true });
|
|
144233
144262
|
throw new Error(
|
|
144234
144263
|
`size mismatch for ${artifact.filename}: expected ${artifact.size}, got ${stat10.size}`
|
|
144235
144264
|
);
|
|
@@ -144238,17 +144267,17 @@ async function downloadAndVerify(opts) {
|
|
|
144238
144267
|
}
|
|
144239
144268
|
|
|
144240
144269
|
// src/updater/paths.ts
|
|
144241
|
-
var
|
|
144242
|
-
var
|
|
144243
|
-
var THREADBASE_ROOT = (0,
|
|
144244
|
-
var RELEASES_DIR = (0,
|
|
144245
|
-
var CURRENT_SYMLINK = (0,
|
|
144246
|
-
var DOWNLOAD_DIR = (0,
|
|
144270
|
+
var import_node_os4 = require("os");
|
|
144271
|
+
var import_node_path11 = require("path");
|
|
144272
|
+
var THREADBASE_ROOT = (0, import_node_path11.join)((0, import_node_os4.homedir)(), ".threadbase");
|
|
144273
|
+
var RELEASES_DIR = (0, import_node_path11.join)(THREADBASE_ROOT, "releases");
|
|
144274
|
+
var CURRENT_SYMLINK = (0, import_node_path11.join)(THREADBASE_ROOT, "current");
|
|
144275
|
+
var DOWNLOAD_DIR = (0, import_node_path11.join)(THREADBASE_ROOT, "releases", ".tmp");
|
|
144247
144276
|
function releaseDir(version2) {
|
|
144248
|
-
return (0,
|
|
144277
|
+
return (0, import_node_path11.join)(RELEASES_DIR, version2);
|
|
144249
144278
|
}
|
|
144250
144279
|
function downloadPath(version2, filename) {
|
|
144251
|
-
return (0,
|
|
144280
|
+
return (0, import_node_path11.join)(DOWNLOAD_DIR, `${version2}-${filename}`);
|
|
144252
144281
|
}
|
|
144253
144282
|
|
|
144254
144283
|
// src/updater/restart.ts
|
|
@@ -144329,75 +144358,75 @@ async function stopService(opts = {}) {
|
|
|
144329
144358
|
}
|
|
144330
144359
|
|
|
144331
144360
|
// src/updater/stamp-version.ts
|
|
144332
|
-
var
|
|
144333
|
-
var
|
|
144361
|
+
var import_node_fs9 = require("fs");
|
|
144362
|
+
var import_node_path12 = require("path");
|
|
144334
144363
|
function stampVersionTxt(destDir, version2) {
|
|
144335
|
-
const distDir = (0,
|
|
144336
|
-
(0,
|
|
144337
|
-
(0,
|
|
144364
|
+
const distDir = (0, import_node_path12.join)(destDir, "dist");
|
|
144365
|
+
(0, import_node_fs9.mkdirSync)(distDir, { recursive: true });
|
|
144366
|
+
(0, import_node_fs9.writeFileSync)((0, import_node_path12.join)(distDir, "version.txt"), `${version2}+update
|
|
144338
144367
|
`);
|
|
144339
144368
|
}
|
|
144340
144369
|
|
|
144341
144370
|
// src/updater/swap.ts
|
|
144342
|
-
var
|
|
144343
|
-
var
|
|
144371
|
+
var import_node_fs10 = require("fs");
|
|
144372
|
+
var import_node_path13 = require("path");
|
|
144344
144373
|
var import_semver2 = __toESM(require_semver2(), 1);
|
|
144345
144374
|
var KEEP_LAST_N = 2;
|
|
144346
144375
|
function swapCurrent(version2) {
|
|
144347
144376
|
const target = releaseDir(version2);
|
|
144348
|
-
if (!(0,
|
|
144377
|
+
if (!(0, import_node_fs10.existsSync)(target)) {
|
|
144349
144378
|
throw new Error(`Cannot swap to ${version2}: ${target} does not exist`);
|
|
144350
144379
|
}
|
|
144351
144380
|
if (process.platform === "win32") {
|
|
144352
144381
|
const tmp = `${CURRENT_SYMLINK}.new`;
|
|
144353
|
-
(0,
|
|
144354
|
-
(0,
|
|
144355
|
-
if ((0,
|
|
144356
|
-
(0,
|
|
144382
|
+
(0, import_node_fs10.rmSync)(tmp, { recursive: true, force: true });
|
|
144383
|
+
(0, import_node_fs10.cpSync)(target, tmp, { recursive: true });
|
|
144384
|
+
if ((0, import_node_fs10.existsSync)(CURRENT_SYMLINK)) {
|
|
144385
|
+
(0, import_node_fs10.rmSync)(CURRENT_SYMLINK, { recursive: true, force: true });
|
|
144357
144386
|
}
|
|
144358
|
-
(0,
|
|
144359
|
-
(0,
|
|
144387
|
+
(0, import_node_fs10.renameSync)(tmp, CURRENT_SYMLINK);
|
|
144388
|
+
(0, import_node_fs10.copyFileSync)((0, import_node_path13.join)(CURRENT_SYMLINK, "dist", "cli.cjs"), (0, import_node_path13.join)(THREADBASE_ROOT, "cli.js"));
|
|
144360
144389
|
return;
|
|
144361
144390
|
}
|
|
144362
144391
|
const tmpLink = `${CURRENT_SYMLINK}.new`;
|
|
144363
|
-
if ((0,
|
|
144364
|
-
(0,
|
|
144392
|
+
if ((0, import_node_fs10.existsSync)(tmpLink) || lstatSafeIsSymlink(tmpLink)) {
|
|
144393
|
+
(0, import_node_fs10.unlinkSync)(tmpLink);
|
|
144365
144394
|
}
|
|
144366
|
-
(0,
|
|
144367
|
-
(0,
|
|
144368
|
-
const cliJs = (0,
|
|
144395
|
+
(0, import_node_fs10.symlinkSync)(target, tmpLink);
|
|
144396
|
+
(0, import_node_fs10.renameSync)(tmpLink, CURRENT_SYMLINK);
|
|
144397
|
+
const cliJs = (0, import_node_path13.join)(THREADBASE_ROOT, "cli.js");
|
|
144369
144398
|
const tmpCliJs = `${cliJs}.new`;
|
|
144370
|
-
if ((0,
|
|
144371
|
-
(0,
|
|
144372
|
-
(0,
|
|
144399
|
+
if ((0, import_node_fs10.existsSync)(tmpCliJs) || lstatSafeIsSymlink(tmpCliJs)) (0, import_node_fs10.unlinkSync)(tmpCliJs);
|
|
144400
|
+
(0, import_node_fs10.symlinkSync)((0, import_node_path13.join)(target, "dist", "cli.cjs"), tmpCliJs);
|
|
144401
|
+
(0, import_node_fs10.renameSync)(tmpCliJs, cliJs);
|
|
144373
144402
|
}
|
|
144374
144403
|
function lstatSafeIsSymlink(path2) {
|
|
144375
144404
|
try {
|
|
144376
|
-
return (0,
|
|
144405
|
+
return (0, import_node_fs10.lstatSync)(path2).isSymbolicLink();
|
|
144377
144406
|
} catch {
|
|
144378
144407
|
return false;
|
|
144379
144408
|
}
|
|
144380
144409
|
}
|
|
144381
144410
|
function pruneOldReleases(activeVersion, keep = KEEP_LAST_N) {
|
|
144382
|
-
if (!(0,
|
|
144383
|
-
const entries = (0,
|
|
144411
|
+
if (!(0, import_node_fs10.existsSync)(RELEASES_DIR)) return [];
|
|
144412
|
+
const entries = (0, import_node_fs10.readdirSync)(RELEASES_DIR, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).filter((name) => import_semver2.default.valid(name) !== null);
|
|
144384
144413
|
const sorted = entries.sort((a, b2) => import_semver2.default.rcompare(a, b2));
|
|
144385
144414
|
const toKeep = new Set(sorted.slice(0, keep));
|
|
144386
144415
|
toKeep.add(activeVersion);
|
|
144387
144416
|
const removed = [];
|
|
144388
144417
|
for (const name of sorted) {
|
|
144389
144418
|
if (toKeep.has(name)) continue;
|
|
144390
|
-
(0,
|
|
144419
|
+
(0, import_node_fs10.rmSync)(releaseDir(name), { recursive: true, force: true });
|
|
144391
144420
|
removed.push(name);
|
|
144392
144421
|
}
|
|
144393
144422
|
return removed;
|
|
144394
144423
|
}
|
|
144395
144424
|
function ensureReleasesDir() {
|
|
144396
|
-
(0,
|
|
144425
|
+
(0, import_node_fs10.mkdirSync)(RELEASES_DIR, { recursive: true });
|
|
144397
144426
|
}
|
|
144398
144427
|
|
|
144399
144428
|
// src/updater/unpack.ts
|
|
144400
|
-
var
|
|
144429
|
+
var import_node_fs17 = require("fs");
|
|
144401
144430
|
|
|
144402
144431
|
// node_modules/tar/dist/esm/index.min.js
|
|
144403
144432
|
var import_events4 = __toESM(require("events"), 1);
|
|
@@ -144405,35 +144434,35 @@ var import_fs24 = __toESM(require("fs"), 1);
|
|
|
144405
144434
|
var import_node_events3 = require("events");
|
|
144406
144435
|
var import_node_stream3 = __toESM(require("stream"), 1);
|
|
144407
144436
|
var import_node_string_decoder = require("string_decoder");
|
|
144408
|
-
var
|
|
144409
|
-
var
|
|
144437
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
144438
|
+
var import_node_fs11 = __toESM(require("fs"), 1);
|
|
144410
144439
|
var import_path20 = require("path");
|
|
144411
144440
|
var import_events5 = require("events");
|
|
144412
144441
|
var import_assert = __toESM(require("assert"), 1);
|
|
144413
144442
|
var import_buffer = require("buffer");
|
|
144414
144443
|
var Ps = __toESM(require("zlib"), 1);
|
|
144415
144444
|
var import_zlib = __toESM(require("zlib"), 1);
|
|
144416
|
-
var
|
|
144417
|
-
var
|
|
144445
|
+
var import_node_path15 = require("path");
|
|
144446
|
+
var import_node_path16 = require("path");
|
|
144418
144447
|
var import_fs25 = __toESM(require("fs"), 1);
|
|
144419
144448
|
var import_fs26 = __toESM(require("fs"), 1);
|
|
144420
144449
|
var import_path21 = __toESM(require("path"), 1);
|
|
144421
|
-
var
|
|
144450
|
+
var import_node_path17 = require("path");
|
|
144422
144451
|
var import_path22 = __toESM(require("path"), 1);
|
|
144423
|
-
var
|
|
144452
|
+
var import_node_fs12 = __toESM(require("fs"), 1);
|
|
144424
144453
|
var import_node_assert = __toESM(require("assert"), 1);
|
|
144425
144454
|
var import_node_crypto5 = require("crypto");
|
|
144426
|
-
var import_node_fs12 = __toESM(require("fs"), 1);
|
|
144427
|
-
var import_node_path16 = __toESM(require("path"), 1);
|
|
144428
|
-
var import_fs27 = __toESM(require("fs"), 1);
|
|
144429
144455
|
var import_node_fs13 = __toESM(require("fs"), 1);
|
|
144430
|
-
var import_node_path17 = __toESM(require("path"), 1);
|
|
144431
|
-
var import_node_fs14 = __toESM(require("fs"), 1);
|
|
144432
|
-
var import_promises16 = __toESM(require("fs/promises"), 1);
|
|
144433
144456
|
var import_node_path18 = __toESM(require("path"), 1);
|
|
144434
|
-
var
|
|
144457
|
+
var import_fs27 = __toESM(require("fs"), 1);
|
|
144458
|
+
var import_node_fs14 = __toESM(require("fs"), 1);
|
|
144459
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
144435
144460
|
var import_node_fs15 = __toESM(require("fs"), 1);
|
|
144461
|
+
var import_promises16 = __toESM(require("fs/promises"), 1);
|
|
144436
144462
|
var import_node_path20 = __toESM(require("path"), 1);
|
|
144463
|
+
var import_node_path21 = require("path");
|
|
144464
|
+
var import_node_fs16 = __toESM(require("fs"), 1);
|
|
144465
|
+
var import_node_path22 = __toESM(require("path"), 1);
|
|
144437
144466
|
var zr = Object.defineProperty;
|
|
144438
144467
|
var Ur = (s3, t2) => {
|
|
144439
144468
|
for (var e in t2) zr(s3, e, { get: t2[e], enumerable: true });
|
|
@@ -145327,12 +145356,12 @@ var F2 = class {
|
|
|
145327
145356
|
}
|
|
145328
145357
|
};
|
|
145329
145358
|
var un = (s3, t2) => {
|
|
145330
|
-
let i = s3, r = "", n, o =
|
|
145359
|
+
let i = s3, r = "", n, o = import_node_path15.posix.parse(s3).root || ".";
|
|
145331
145360
|
if (Buffer.byteLength(i) < 100) n = [i, r, false];
|
|
145332
145361
|
else {
|
|
145333
|
-
r =
|
|
145362
|
+
r = import_node_path15.posix.dirname(i), i = import_node_path15.posix.basename(i);
|
|
145334
145363
|
do
|
|
145335
|
-
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t2 ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t2 ? n = [i.slice(0, 99), r, true] : (i =
|
|
145364
|
+
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t2 ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t2 ? n = [i.slice(0, 99), r, true] : (i = import_node_path15.posix.join(import_node_path15.posix.basename(r), i), r = import_node_path15.posix.dirname(r));
|
|
145336
145365
|
while (r !== o && n === void 0);
|
|
145337
145366
|
n || (n = [s3.slice(0, 99), "", true]);
|
|
145338
145367
|
}
|
|
@@ -145378,7 +145407,7 @@ var ft = class s {
|
|
|
145378
145407
|
if (t2 === "") return Buffer.allocUnsafe(0);
|
|
145379
145408
|
let e = Buffer.byteLength(t2), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
|
|
145380
145409
|
for (let n = 0; n < 512; n++) r[n] = 0;
|
|
145381
|
-
new F2({ path: ("PaxHeader/" + (0,
|
|
145410
|
+
new F2({ path: ("PaxHeader/" + (0, import_node_path16.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(t2, 512, e, "utf8");
|
|
145382
145411
|
for (let n = e + 512; n < r.length; n++) r[n] = 0;
|
|
145383
145412
|
return r;
|
|
145384
145413
|
}
|
|
@@ -145797,15 +145826,15 @@ var Qi = (s3, t2) => {
|
|
|
145797
145826
|
var Mn = (s3) => {
|
|
145798
145827
|
let t2 = new rt(s3), e = s3.file, i;
|
|
145799
145828
|
try {
|
|
145800
|
-
i =
|
|
145801
|
-
let r =
|
|
145829
|
+
i = import_node_fs11.default.openSync(e, "r");
|
|
145830
|
+
let r = import_node_fs11.default.fstatSync(i), n = s3.maxReadSize || 16 * 1024 * 1024;
|
|
145802
145831
|
if (r.size < n) {
|
|
145803
|
-
let o = Buffer.allocUnsafe(r.size), h =
|
|
145832
|
+
let o = Buffer.allocUnsafe(r.size), h = import_node_fs11.default.readSync(i, o, 0, r.size, 0);
|
|
145804
145833
|
t2.end(h === o.byteLength ? o : o.subarray(0, h));
|
|
145805
145834
|
} else {
|
|
145806
145835
|
let o = 0, h = Buffer.allocUnsafe(n);
|
|
145807
145836
|
for (; o < r.size; ) {
|
|
145808
|
-
let a =
|
|
145837
|
+
let a = import_node_fs11.default.readSync(i, h, 0, n, o);
|
|
145809
145838
|
if (a === 0) break;
|
|
145810
145839
|
o += a, t2.write(h.subarray(0, a));
|
|
145811
145840
|
}
|
|
@@ -145813,7 +145842,7 @@ var Mn = (s3) => {
|
|
|
145813
145842
|
}
|
|
145814
145843
|
} finally {
|
|
145815
145844
|
if (typeof i == "number") try {
|
|
145816
|
-
|
|
145845
|
+
import_node_fs11.default.closeSync(i);
|
|
145817
145846
|
} catch {
|
|
145818
145847
|
}
|
|
145819
145848
|
}
|
|
@@ -145821,7 +145850,7 @@ var Mn = (s3) => {
|
|
|
145821
145850
|
var Bn = (s3, t2) => {
|
|
145822
145851
|
let e = new rt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
|
|
145823
145852
|
return new Promise((o, h) => {
|
|
145824
|
-
e.on("error", h), e.on("end", o),
|
|
145853
|
+
e.on("error", h), e.on("end", o), import_node_fs11.default.stat(r, (a, l) => {
|
|
145825
145854
|
if (a) h(a);
|
|
145826
145855
|
else {
|
|
145827
145856
|
let c = new _t(r, { readSize: i, size: l.size });
|
|
@@ -145834,7 +145863,7 @@ var Ct = K2(Mn, Bn, (s3) => new rt(s3), (s3) => new rt(s3), (s3, t2) => {
|
|
|
145834
145863
|
t2?.length && Qi(s3, t2), s3.noResume || vn(s3);
|
|
145835
145864
|
});
|
|
145836
145865
|
var Ji = (s3, t2, e) => (s3 &= 4095, e && (s3 = (s3 | 384) & -19), t2 && (s3 & 256 && (s3 |= 64), s3 & 32 && (s3 |= 8), s3 & 4 && (s3 |= 1)), s3);
|
|
145837
|
-
var { isAbsolute: zn, parse: qs } =
|
|
145866
|
+
var { isAbsolute: zn, parse: qs } = import_node_path17.win32;
|
|
145838
145867
|
var ce = (s3) => {
|
|
145839
145868
|
let t2 = "", e = qs(s3);
|
|
145840
145869
|
for (; zn(s3) || e.root; ) {
|
|
@@ -146543,11 +146572,11 @@ var $n = (s3, t2) => {
|
|
|
146543
146572
|
};
|
|
146544
146573
|
var fr = (s3, t2) => {
|
|
146545
146574
|
t2.forEach((e) => {
|
|
146546
|
-
e.charAt(0) === "@" ? Ct({ file:
|
|
146575
|
+
e.charAt(0) === "@" ? Ct({ file: import_node_path14.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
146547
146576
|
}), s3.end();
|
|
146548
146577
|
};
|
|
146549
146578
|
var dr = async (s3, t2) => {
|
|
146550
|
-
for (let e of t2) e.charAt(0) === "@" ? await Ct({ file:
|
|
146579
|
+
for (let e of t2) e.charAt(0) === "@" ? await Ct({ file: import_node_path14.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
|
|
146551
146580
|
s3.add(i);
|
|
146552
146581
|
} }) : s3.add(e);
|
|
146553
146582
|
s3.end();
|
|
@@ -146574,29 +146603,29 @@ var ur = !Er && typeof mr == "number" ? mr | Sr | wr | yr : null;
|
|
|
146574
146603
|
var us = ur !== null ? () => ur : jn ? (s3) => s3 < to ? eo : "w" : () => "w";
|
|
146575
146604
|
var ps = (s3, t2, e) => {
|
|
146576
146605
|
try {
|
|
146577
|
-
return
|
|
146606
|
+
return import_node_fs14.default.lchownSync(s3, t2, e);
|
|
146578
146607
|
} catch (i) {
|
|
146579
146608
|
if (i?.code !== "ENOENT") throw i;
|
|
146580
146609
|
}
|
|
146581
146610
|
};
|
|
146582
146611
|
var Ei = (s3, t2, e, i) => {
|
|
146583
|
-
|
|
146612
|
+
import_node_fs14.default.lchown(s3, t2, e, (r) => {
|
|
146584
146613
|
i(r && r?.code !== "ENOENT" ? r : null);
|
|
146585
146614
|
});
|
|
146586
146615
|
};
|
|
146587
146616
|
var io = (s3, t2, e, i, r) => {
|
|
146588
|
-
if (t2.isDirectory()) Es(
|
|
146617
|
+
if (t2.isDirectory()) Es(import_node_path19.default.resolve(s3, t2.name), e, i, (n) => {
|
|
146589
146618
|
if (n) return r(n);
|
|
146590
|
-
let o =
|
|
146619
|
+
let o = import_node_path19.default.resolve(s3, t2.name);
|
|
146591
146620
|
Ei(o, e, i, r);
|
|
146592
146621
|
});
|
|
146593
146622
|
else {
|
|
146594
|
-
let n =
|
|
146623
|
+
let n = import_node_path19.default.resolve(s3, t2.name);
|
|
146595
146624
|
Ei(n, e, i, r);
|
|
146596
146625
|
}
|
|
146597
146626
|
};
|
|
146598
146627
|
var Es = (s3, t2, e, i) => {
|
|
146599
|
-
|
|
146628
|
+
import_node_fs14.default.readdir(s3, { withFileTypes: true }, (r, n) => {
|
|
146600
146629
|
if (r) {
|
|
146601
146630
|
if (r.code === "ENOENT") return i();
|
|
146602
146631
|
if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
|
|
@@ -146612,12 +146641,12 @@ var Es = (s3, t2, e, i) => {
|
|
|
146612
146641
|
});
|
|
146613
146642
|
};
|
|
146614
146643
|
var so = (s3, t2, e, i) => {
|
|
146615
|
-
t2.isDirectory() && ws(
|
|
146644
|
+
t2.isDirectory() && ws(import_node_path19.default.resolve(s3, t2.name), e, i), ps(import_node_path19.default.resolve(s3, t2.name), e, i);
|
|
146616
146645
|
};
|
|
146617
146646
|
var ws = (s3, t2, e) => {
|
|
146618
146647
|
let i;
|
|
146619
146648
|
try {
|
|
146620
|
-
i =
|
|
146649
|
+
i = import_node_fs14.default.readdirSync(s3, { withFileTypes: true });
|
|
146621
146650
|
} catch (r) {
|
|
146622
146651
|
let n = r;
|
|
146623
146652
|
if (n?.code === "ENOENT") return;
|
|
@@ -146651,32 +146680,32 @@ var St = class extends Error {
|
|
|
146651
146680
|
}
|
|
146652
146681
|
};
|
|
146653
146682
|
var no = (s3, t2) => {
|
|
146654
|
-
|
|
146683
|
+
import_node_fs15.default.stat(s3, (e, i) => {
|
|
146655
146684
|
(e || !i.isDirectory()) && (e = new Se(s3, e?.code || "ENOTDIR")), t2(e);
|
|
146656
146685
|
});
|
|
146657
146686
|
};
|
|
146658
146687
|
var gr = (s3, t2, e) => {
|
|
146659
146688
|
s3 = f(s3);
|
|
146660
146689
|
let i = t2.umask ?? 18, r = t2.mode | 448, n = (r & i) !== 0, o = t2.uid, h = t2.gid, a = typeof o == "number" && typeof h == "number" && (o !== t2.processUid || h !== t2.processGid), l = t2.preserve, c = t2.unlink, d = f(t2.cwd), S2 = (E2, x2) => {
|
|
146661
|
-
E2 ? e(E2) : x2 && a ? Es(x2, o, h, (Le) => S2(Le)) : n ?
|
|
146690
|
+
E2 ? e(E2) : x2 && a ? Es(x2, o, h, (Le) => S2(Le)) : n ? import_node_fs15.default.chmod(s3, r, e) : e();
|
|
146662
146691
|
};
|
|
146663
146692
|
if (s3 === d) return no(s3, S2);
|
|
146664
146693
|
if (l) return import_promises16.default.mkdir(s3, { mode: r, recursive: true }).then((E2) => S2(null, E2 ?? void 0), S2);
|
|
146665
|
-
let D2 = f(
|
|
146694
|
+
let D2 = f(import_node_path20.default.relative(d, s3)).split("/");
|
|
146666
146695
|
Ss(d, D2, r, c, d, void 0, S2);
|
|
146667
146696
|
};
|
|
146668
146697
|
var Ss = (s3, t2, e, i, r, n, o) => {
|
|
146669
146698
|
if (t2.length === 0) return o(null, n);
|
|
146670
|
-
let h = t2.shift(), a = f(
|
|
146671
|
-
|
|
146699
|
+
let h = t2.shift(), a = f(import_node_path20.default.resolve(s3 + "/" + h));
|
|
146700
|
+
import_node_fs15.default.mkdir(a, e, br(a, t2, e, i, r, n, o));
|
|
146672
146701
|
};
|
|
146673
146702
|
var br = (s3, t2, e, i, r, n, o) => (h) => {
|
|
146674
|
-
h ?
|
|
146703
|
+
h ? import_node_fs15.default.lstat(s3, (a, l) => {
|
|
146675
146704
|
if (a) a.path = a.path && f(a.path), o(a);
|
|
146676
146705
|
else if (l.isDirectory()) Ss(s3, t2, e, i, r, n, o);
|
|
146677
|
-
else if (i)
|
|
146706
|
+
else if (i) import_node_fs15.default.unlink(s3, (c) => {
|
|
146678
146707
|
if (c) return o(c);
|
|
146679
|
-
|
|
146708
|
+
import_node_fs15.default.mkdir(s3, e, br(s3, t2, e, i, r, n, o));
|
|
146680
146709
|
});
|
|
146681
146710
|
else {
|
|
146682
146711
|
if (l.isSymbolicLink()) return o(new St(s3, s3 + "/" + t2.join("/")));
|
|
@@ -146687,7 +146716,7 @@ var br = (s3, t2, e, i, r, n, o) => (h) => {
|
|
|
146687
146716
|
var oo = (s3) => {
|
|
146688
146717
|
let t2 = false, e;
|
|
146689
146718
|
try {
|
|
146690
|
-
t2 =
|
|
146719
|
+
t2 = import_node_fs15.default.statSync(s3).isDirectory();
|
|
146691
146720
|
} catch (i) {
|
|
146692
146721
|
e = i?.code;
|
|
146693
146722
|
} finally {
|
|
@@ -146697,20 +146726,20 @@ var oo = (s3) => {
|
|
|
146697
146726
|
var _r = (s3, t2) => {
|
|
146698
146727
|
s3 = f(s3);
|
|
146699
146728
|
let e = t2.umask ?? 18, i = t2.mode | 448, r = (i & e) !== 0, n = t2.uid, o = t2.gid, h = typeof n == "number" && typeof o == "number" && (n !== t2.processUid || o !== t2.processGid), a = t2.preserve, l = t2.unlink, c = f(t2.cwd), d = (E2) => {
|
|
146700
|
-
E2 && h && ws(E2, n, o), r &&
|
|
146729
|
+
E2 && h && ws(E2, n, o), r && import_node_fs15.default.chmodSync(s3, i);
|
|
146701
146730
|
};
|
|
146702
146731
|
if (s3 === c) return oo(c), d();
|
|
146703
|
-
if (a) return d(
|
|
146704
|
-
let T2 = f(
|
|
146732
|
+
if (a) return d(import_node_fs15.default.mkdirSync(s3, { mode: i, recursive: true }) ?? void 0);
|
|
146733
|
+
let T2 = f(import_node_path20.default.relative(c, s3)).split("/"), D2;
|
|
146705
146734
|
for (let E2 = T2.shift(), x2 = c; E2 && (x2 += "/" + E2); E2 = T2.shift()) {
|
|
146706
|
-
x2 = f(
|
|
146735
|
+
x2 = f(import_node_path20.default.resolve(x2));
|
|
146707
146736
|
try {
|
|
146708
|
-
|
|
146737
|
+
import_node_fs15.default.mkdirSync(x2, i), D2 = D2 || x2;
|
|
146709
146738
|
} catch {
|
|
146710
|
-
let Le =
|
|
146739
|
+
let Le = import_node_fs15.default.lstatSync(x2);
|
|
146711
146740
|
if (Le.isDirectory()) continue;
|
|
146712
146741
|
if (l) {
|
|
146713
|
-
|
|
146742
|
+
import_node_fs15.default.unlinkSync(x2), import_node_fs15.default.mkdirSync(x2, i), D2 = D2 || x2;
|
|
146714
146743
|
continue;
|
|
146715
146744
|
} else if (Le.isSymbolicLink()) return new St(x2, x2 + "/" + T2.join("/"));
|
|
146716
146745
|
}
|
|
@@ -146732,14 +146761,14 @@ var ho = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
|
146732
146761
|
var ao = ho === "win32";
|
|
146733
146762
|
var lo = (s3) => s3.split("/").slice(0, -1).reduce((e, i) => {
|
|
146734
146763
|
let r = e.at(-1);
|
|
146735
|
-
return r !== void 0 && (i = (0,
|
|
146764
|
+
return r !== void 0 && (i = (0, import_node_path21.join)(r, i)), e.push(i || "/"), e;
|
|
146736
146765
|
}, []);
|
|
146737
146766
|
var yi = class {
|
|
146738
146767
|
#t = /* @__PURE__ */ new Map();
|
|
146739
146768
|
#i = /* @__PURE__ */ new Map();
|
|
146740
146769
|
#s = /* @__PURE__ */ new Set();
|
|
146741
146770
|
reserve(t2, e) {
|
|
146742
|
-
t2 = ao ? ["win32 parallelization disabled"] : t2.map((r) => ut((0,
|
|
146771
|
+
t2 = ao ? ["win32 parallelization disabled"] : t2.map((r) => ut((0, import_node_path21.join)(Tr(r))));
|
|
146743
146772
|
let i = new Set(t2.map((r) => lo(r)).reduce((r, n) => r.concat(n)));
|
|
146744
146773
|
this.#i.set(e, { dirs: i, paths: t2 });
|
|
146745
146774
|
for (let r of t2) {
|
|
@@ -146829,17 +146858,17 @@ var fo = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
|
146829
146858
|
var Te = fo === "win32";
|
|
146830
146859
|
var mo = 1024;
|
|
146831
146860
|
var uo = (s3, t2) => {
|
|
146832
|
-
if (!Te) return
|
|
146861
|
+
if (!Te) return import_node_fs13.default.unlink(s3, t2);
|
|
146833
146862
|
let e = s3 + ".DELETE." + (0, import_node_crypto5.randomBytes)(16).toString("hex");
|
|
146834
|
-
|
|
146863
|
+
import_node_fs13.default.rename(s3, e, (i) => {
|
|
146835
146864
|
if (i) return t2(i);
|
|
146836
|
-
|
|
146865
|
+
import_node_fs13.default.unlink(e, t2);
|
|
146837
146866
|
});
|
|
146838
146867
|
};
|
|
146839
146868
|
var po = (s3) => {
|
|
146840
|
-
if (!Te) return
|
|
146869
|
+
if (!Te) return import_node_fs13.default.unlinkSync(s3);
|
|
146841
146870
|
let t2 = s3 + ".DELETE." + (0, import_node_crypto5.randomBytes)(16).toString("hex");
|
|
146842
|
-
|
|
146871
|
+
import_node_fs13.default.renameSync(s3, t2), import_node_fs13.default.unlinkSync(t2);
|
|
146843
146872
|
};
|
|
146844
146873
|
var vr = (s3, t2, e) => s3 !== void 0 && s3 === s3 >>> 0 ? s3 : t2 !== void 0 && t2 === t2 >>> 0 ? t2 : e;
|
|
146845
146874
|
var Xt = class extends rt {
|
|
@@ -146879,7 +146908,7 @@ var Xt = class extends rt {
|
|
|
146879
146908
|
if (t2.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
|
|
146880
146909
|
this.uid = t2.uid, this.gid = t2.gid, this.setOwner = true;
|
|
146881
146910
|
} else this.uid = void 0, this.gid = void 0, this.setOwner = false;
|
|
146882
|
-
this.preserveOwner = t2.preserveOwner === void 0 && typeof t2.uid != "number" ? process.getuid?.() === 0 : !!t2.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 t2.maxDepth == "number" ? t2.maxDepth : mo, this.forceChown = t2.forceChown === true, this.win32 = !!t2.win32 || Te, this.newer = !!t2.newer, this.keep = !!t2.keep, this.noMtime = !!t2.noMtime, this.preservePaths = !!t2.preservePaths, this.unlink = !!t2.unlink, this.cwd = f(
|
|
146911
|
+
this.preserveOwner = t2.preserveOwner === void 0 && typeof t2.uid != "number" ? process.getuid?.() === 0 : !!t2.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 t2.maxDepth == "number" ? t2.maxDepth : mo, this.forceChown = t2.forceChown === true, this.win32 = !!t2.win32 || Te, this.newer = !!t2.newer, this.keep = !!t2.keep, this.noMtime = !!t2.noMtime, this.preservePaths = !!t2.preservePaths, this.unlink = !!t2.unlink, this.cwd = f(import_node_path18.default.resolve(t2.cwd || process.cwd())), this.strip = Number(t2.strip) || 0, this.processUmask = this.chmod ? typeof t2.processUmask == "number" ? t2.processUmask : Lr() : 0, this.umask = typeof t2.umask == "number" ? t2.umask : this.processUmask, this.dmode = t2.dmode || 511 & ~this.umask, this.fmode = t2.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
|
|
146883
146912
|
}
|
|
146884
146913
|
warn(t2, e, i = {}) {
|
|
146885
146914
|
return (t2 === "TAR_BAD_ARCHIVE" || t2 === "TAR_ABORT") && (i.recoverable = false), super.warn(t2, e, i);
|
|
@@ -146893,7 +146922,7 @@ var Xt = class extends rt {
|
|
|
146893
146922
|
let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
|
|
146894
146923
|
if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
|
|
146895
146924
|
if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, { entry: t2, [e]: i }), false;
|
|
146896
|
-
let a =
|
|
146925
|
+
let a = import_node_path18.default.posix.dirname(t2.path), l = import_node_path18.default.posix.normalize(import_node_path18.default.posix.join(a, h.join("/")));
|
|
146897
146926
|
if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, { entry: t2, [e]: i }), false;
|
|
146898
146927
|
}
|
|
146899
146928
|
return n && (t2[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, { entry: t2, [e]: i })), true;
|
|
@@ -146911,12 +146940,12 @@ var Xt = class extends rt {
|
|
|
146911
146940
|
}
|
|
146912
146941
|
if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: t2, path: e, depth: i.length, maxDepth: this.maxDepth }), false;
|
|
146913
146942
|
if (!this[Rs](t2, "path") || !this[Rs](t2, "linkpath")) return false;
|
|
146914
|
-
if (t2.absolute =
|
|
146943
|
+
if (t2.absolute = import_node_path18.default.isAbsolute(t2.path) ? f(import_node_path18.default.resolve(t2.path)) : f(import_node_path18.default.resolve(this.cwd, t2.path)), !this.preservePaths && typeof t2.absolute == "string" && t2.absolute.indexOf(this.cwd + "/") !== 0 && t2.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t2, path: f(t2.path), resolvedPath: t2.absolute, cwd: this.cwd }), false;
|
|
146915
146944
|
if (t2.absolute === this.cwd && t2.type !== "Directory" && t2.type !== "GNUDumpDir") return false;
|
|
146916
146945
|
if (this.win32) {
|
|
146917
|
-
let { root: r } =
|
|
146946
|
+
let { root: r } = import_node_path18.default.win32.parse(String(t2.absolute));
|
|
146918
146947
|
t2.absolute = r + ts(String(t2.absolute).slice(r.length));
|
|
146919
|
-
let { root: n } =
|
|
146948
|
+
let { root: n } = import_node_path18.default.win32.parse(t2.path);
|
|
146920
146949
|
t2.path = n + ts(t2.path.slice(n.length));
|
|
146921
146950
|
}
|
|
146922
146951
|
return true;
|
|
@@ -146955,16 +146984,16 @@ var Xt = class extends rt {
|
|
|
146955
146984
|
[Ts](t2, e) {
|
|
146956
146985
|
let i = typeof t2.mode == "number" ? t2.mode & 4095 : this.fmode, r = new et(String(t2.absolute), { flags: us(t2.size), mode: i, autoClose: false });
|
|
146957
146986
|
r.on("error", (a) => {
|
|
146958
|
-
r.fd &&
|
|
146987
|
+
r.fd && import_node_fs13.default.close(r.fd, () => {
|
|
146959
146988
|
}), r.write = () => true, this[O2](a, t2), e();
|
|
146960
146989
|
});
|
|
146961
146990
|
let n = 1, o = (a) => {
|
|
146962
146991
|
if (a) {
|
|
146963
|
-
r.fd &&
|
|
146992
|
+
r.fd && import_node_fs13.default.close(r.fd, () => {
|
|
146964
146993
|
}), this[O2](a, t2), e();
|
|
146965
146994
|
return;
|
|
146966
146995
|
}
|
|
146967
|
-
--n === 0 && r.fd !== void 0 &&
|
|
146996
|
+
--n === 0 && r.fd !== void 0 && import_node_fs13.default.close(r.fd, (l) => {
|
|
146968
146997
|
l ? this[O2](l, t2) : this[$t](), e();
|
|
146969
146998
|
});
|
|
146970
146999
|
};
|
|
@@ -146973,12 +147002,12 @@ var Xt = class extends rt {
|
|
|
146973
147002
|
if (typeof l == "number" && t2.mtime && !this.noMtime) {
|
|
146974
147003
|
n++;
|
|
146975
147004
|
let c = t2.atime || /* @__PURE__ */ new Date(), d = t2.mtime;
|
|
146976
|
-
|
|
147005
|
+
import_node_fs13.default.futimes(l, c, d, (S2) => S2 ? import_node_fs13.default.utimes(a, c, d, (T2) => o(T2 && S2)) : o());
|
|
146977
147006
|
}
|
|
146978
147007
|
if (typeof l == "number" && this[ge](t2)) {
|
|
146979
147008
|
n++;
|
|
146980
147009
|
let c = this[be](t2), d = this[_e](t2);
|
|
146981
|
-
typeof c == "number" && typeof d == "number" &&
|
|
147010
|
+
typeof c == "number" && typeof d == "number" && import_node_fs13.default.fchown(l, c, d, (S2) => S2 ? import_node_fs13.default.chown(a, c, d, (T2) => o(T2 && S2)) : o());
|
|
146982
147011
|
}
|
|
146983
147012
|
o();
|
|
146984
147013
|
});
|
|
@@ -146997,20 +147026,20 @@ var Xt = class extends rt {
|
|
|
146997
147026
|
let n = 1, o = () => {
|
|
146998
147027
|
--n === 0 && (e(), this[$t](), t2.resume());
|
|
146999
147028
|
};
|
|
147000
|
-
t2.mtime && !this.noMtime && (n++,
|
|
147029
|
+
t2.mtime && !this.noMtime && (n++, import_node_fs13.default.utimes(String(t2.absolute), t2.atime || /* @__PURE__ */ new Date(), t2.mtime, o)), this[ge](t2) && (n++, import_node_fs13.default.chown(String(t2.absolute), Number(this[be](t2)), Number(this[_e](t2)), o)), o();
|
|
147001
147030
|
});
|
|
147002
147031
|
}
|
|
147003
147032
|
[Cr](t2) {
|
|
147004
147033
|
t2.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t2.type}`, { entry: t2 }), t2.resume();
|
|
147005
147034
|
}
|
|
147006
147035
|
[Ar](t2, e) {
|
|
147007
|
-
let i = f(
|
|
147036
|
+
let i = f(import_node_path18.default.relative(this.cwd, import_node_path18.default.resolve(import_node_path18.default.dirname(String(t2.absolute)), String(t2.linkpath)))).split("/");
|
|
147008
147037
|
this[Re](t2, this.cwd, i, () => this[gi](t2, String(t2.linkpath), "symlink", e), (r) => {
|
|
147009
147038
|
this[O2](r, t2), e();
|
|
147010
147039
|
});
|
|
147011
147040
|
}
|
|
147012
147041
|
[Ir](t2, e) {
|
|
147013
|
-
let i = f(
|
|
147042
|
+
let i = f(import_node_path18.default.resolve(this.cwd, String(t2.linkpath))), r = f(String(t2.linkpath)).split("/");
|
|
147014
147043
|
this[Re](t2, this.cwd, r, () => this[gi](t2, i, "link", e), (n) => {
|
|
147015
147044
|
this[O2](n, t2), e();
|
|
147016
147045
|
});
|
|
@@ -147018,10 +147047,10 @@ var Xt = class extends rt {
|
|
|
147018
147047
|
[Re](t2, e, i, r, n) {
|
|
147019
147048
|
let o = i.shift();
|
|
147020
147049
|
if (this.preservePaths || o === void 0) return r();
|
|
147021
|
-
let h =
|
|
147022
|
-
|
|
147050
|
+
let h = import_node_path18.default.resolve(e, o);
|
|
147051
|
+
import_node_fs13.default.lstat(h, (a, l) => {
|
|
147023
147052
|
if (a) return r();
|
|
147024
|
-
if (l?.isSymbolicLink()) return n(new St(h,
|
|
147053
|
+
if (l?.isSymbolicLink()) return n(new St(h, import_node_path18.default.resolve(h, i.join("/"))));
|
|
147025
147054
|
this[Re](t2, h, i, r, n);
|
|
147026
147055
|
});
|
|
147027
147056
|
}
|
|
@@ -147055,7 +147084,7 @@ var Xt = class extends rt {
|
|
|
147055
147084
|
});
|
|
147056
147085
|
}, n = () => {
|
|
147057
147086
|
if (t2.absolute !== this.cwd) {
|
|
147058
|
-
let h = f(
|
|
147087
|
+
let h = f(import_node_path18.default.dirname(String(t2.absolute)));
|
|
147059
147088
|
if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
|
|
147060
147089
|
if (a) {
|
|
147061
147090
|
this[O2](a, t2), i();
|
|
@@ -147066,7 +147095,7 @@ var Xt = class extends rt {
|
|
|
147066
147095
|
}
|
|
147067
147096
|
o();
|
|
147068
147097
|
}, o = () => {
|
|
147069
|
-
|
|
147098
|
+
import_node_fs13.default.lstat(String(t2.absolute), (h, a) => {
|
|
147070
147099
|
if (a && (this.keep || this.newer && a.mtime > (t2.mtime ?? a.mtime))) {
|
|
147071
147100
|
this[Ls](t2), i();
|
|
147072
147101
|
return;
|
|
@@ -147075,9 +147104,9 @@ var Xt = class extends rt {
|
|
|
147075
147104
|
if (a.isDirectory()) {
|
|
147076
147105
|
if (t2.type === "Directory") {
|
|
147077
147106
|
let l = this.chmod && t2.mode && (a.mode & 4095) !== t2.mode, c = (d) => this[P2](d ?? null, t2, i);
|
|
147078
|
-
return l ?
|
|
147107
|
+
return l ? import_node_fs13.default.chmod(String(t2.absolute), Number(t2.mode), c) : c();
|
|
147079
147108
|
}
|
|
147080
|
-
if (t2.absolute !== this.cwd) return
|
|
147109
|
+
if (t2.absolute !== this.cwd) return import_node_fs13.default.rmdir(String(t2.absolute), (l) => this[P2](l ?? null, t2, i));
|
|
147081
147110
|
}
|
|
147082
147111
|
if (t2.absolute === this.cwd) return this[P2](null, t2, i);
|
|
147083
147112
|
uo(String(t2.absolute), (l) => this[P2](l ?? null, t2, i));
|
|
@@ -147105,7 +147134,7 @@ var Xt = class extends rt {
|
|
|
147105
147134
|
}
|
|
147106
147135
|
}
|
|
147107
147136
|
[gi](t2, e, i, r) {
|
|
147108
|
-
|
|
147137
|
+
import_node_fs13.default[i](e, String(t2.absolute), (n) => {
|
|
147109
147138
|
n ? this[O2](n, t2) : (this[$t](), t2.resume()), r();
|
|
147110
147139
|
});
|
|
147111
147140
|
}
|
|
@@ -147130,23 +147159,23 @@ var xe = class extends Xt {
|
|
|
147130
147159
|
this[Oe] = true;
|
|
147131
147160
|
}
|
|
147132
147161
|
if (t2.absolute !== this.cwd) {
|
|
147133
|
-
let n = f(
|
|
147162
|
+
let n = f(import_node_path18.default.dirname(String(t2.absolute)));
|
|
147134
147163
|
if (n !== this.cwd) {
|
|
147135
147164
|
let o = this[yt](n, this.dmode);
|
|
147136
147165
|
if (o) return this[O2](o, t2);
|
|
147137
147166
|
}
|
|
147138
147167
|
}
|
|
147139
|
-
let [e, i] = ye(() =>
|
|
147168
|
+
let [e, i] = ye(() => import_node_fs13.default.lstatSync(String(t2.absolute)));
|
|
147140
147169
|
if (i && (this.keep || this.newer && i.mtime > (t2.mtime ?? i.mtime))) return this[Ls](t2);
|
|
147141
147170
|
if (e || this[Os](t2, i)) return this[P2](null, t2);
|
|
147142
147171
|
if (i.isDirectory()) {
|
|
147143
147172
|
if (t2.type === "Directory") {
|
|
147144
147173
|
let o = this.chmod && t2.mode && (i.mode & 4095) !== t2.mode, [h] = o ? ye(() => {
|
|
147145
|
-
|
|
147174
|
+
import_node_fs13.default.chmodSync(String(t2.absolute), Number(t2.mode));
|
|
147146
147175
|
}) : [];
|
|
147147
147176
|
return this[P2](h, t2);
|
|
147148
147177
|
}
|
|
147149
|
-
let [n] = ye(() =>
|
|
147178
|
+
let [n] = ye(() => import_node_fs13.default.rmdirSync(String(t2.absolute)));
|
|
147150
147179
|
this[P2](n, t2);
|
|
147151
147180
|
}
|
|
147152
147181
|
let [r] = t2.absolute === this.cwd ? [] : ye(() => po(String(t2.absolute)));
|
|
@@ -147156,21 +147185,21 @@ var xe = class extends Xt {
|
|
|
147156
147185
|
let i = typeof t2.mode == "number" ? t2.mode & 4095 : this.fmode, r = (h) => {
|
|
147157
147186
|
let a;
|
|
147158
147187
|
try {
|
|
147159
|
-
|
|
147188
|
+
import_node_fs13.default.closeSync(n);
|
|
147160
147189
|
} catch (l) {
|
|
147161
147190
|
a = l;
|
|
147162
147191
|
}
|
|
147163
147192
|
(h || a) && this[O2](h || a, t2), e();
|
|
147164
147193
|
}, n;
|
|
147165
147194
|
try {
|
|
147166
|
-
n =
|
|
147195
|
+
n = import_node_fs13.default.openSync(String(t2.absolute), us(t2.size), i);
|
|
147167
147196
|
} catch (h) {
|
|
147168
147197
|
return r(h);
|
|
147169
147198
|
}
|
|
147170
147199
|
let o = this.transform && this.transform(t2) || t2;
|
|
147171
147200
|
o !== t2 && (o.on("error", (h) => this[O2](h, t2)), t2.pipe(o)), o.on("data", (h) => {
|
|
147172
147201
|
try {
|
|
147173
|
-
|
|
147202
|
+
import_node_fs13.default.writeSync(n, h, 0, h.length);
|
|
147174
147203
|
} catch (a) {
|
|
147175
147204
|
r(a);
|
|
147176
147205
|
}
|
|
@@ -147179,10 +147208,10 @@ var xe = class extends Xt {
|
|
|
147179
147208
|
if (t2.mtime && !this.noMtime) {
|
|
147180
147209
|
let a = t2.atime || /* @__PURE__ */ new Date(), l = t2.mtime;
|
|
147181
147210
|
try {
|
|
147182
|
-
|
|
147211
|
+
import_node_fs13.default.futimesSync(n, a, l);
|
|
147183
147212
|
} catch (c) {
|
|
147184
147213
|
try {
|
|
147185
|
-
|
|
147214
|
+
import_node_fs13.default.utimesSync(String(t2.absolute), a, l);
|
|
147186
147215
|
} catch {
|
|
147187
147216
|
h = c;
|
|
147188
147217
|
}
|
|
@@ -147191,10 +147220,10 @@ var xe = class extends Xt {
|
|
|
147191
147220
|
if (this[ge](t2)) {
|
|
147192
147221
|
let a = this[be](t2), l = this[_e](t2);
|
|
147193
147222
|
try {
|
|
147194
|
-
|
|
147223
|
+
import_node_fs13.default.fchownSync(n, Number(a), Number(l));
|
|
147195
147224
|
} catch (c) {
|
|
147196
147225
|
try {
|
|
147197
|
-
|
|
147226
|
+
import_node_fs13.default.chownSync(String(t2.absolute), Number(a), Number(l));
|
|
147198
147227
|
} catch {
|
|
147199
147228
|
h = h || c;
|
|
147200
147229
|
}
|
|
@@ -147210,11 +147239,11 @@ var xe = class extends Xt {
|
|
|
147210
147239
|
return;
|
|
147211
147240
|
}
|
|
147212
147241
|
if (t2.mtime && !this.noMtime) try {
|
|
147213
|
-
|
|
147242
|
+
import_node_fs13.default.utimesSync(String(t2.absolute), t2.atime || /* @__PURE__ */ new Date(), t2.mtime);
|
|
147214
147243
|
} catch {
|
|
147215
147244
|
}
|
|
147216
147245
|
if (this[ge](t2)) try {
|
|
147217
|
-
|
|
147246
|
+
import_node_fs13.default.chownSync(String(t2.absolute), Number(this[be](t2)), Number(this[_e](t2)));
|
|
147218
147247
|
} catch {
|
|
147219
147248
|
}
|
|
147220
147249
|
e(), t2.resume();
|
|
@@ -147230,30 +147259,30 @@ var xe = class extends Xt {
|
|
|
147230
147259
|
if (this.preservePaths || i.length === 0) return r();
|
|
147231
147260
|
let o = e;
|
|
147232
147261
|
for (let h of i) {
|
|
147233
|
-
o =
|
|
147234
|
-
let [a, l] = ye(() =>
|
|
147262
|
+
o = import_node_path18.default.resolve(o, h);
|
|
147263
|
+
let [a, l] = ye(() => import_node_fs13.default.lstatSync(o));
|
|
147235
147264
|
if (a) return r();
|
|
147236
|
-
if (l.isSymbolicLink()) return n(new St(o,
|
|
147265
|
+
if (l.isSymbolicLink()) return n(new St(o, import_node_path18.default.resolve(e, i.join("/"))));
|
|
147237
147266
|
}
|
|
147238
147267
|
r();
|
|
147239
147268
|
}
|
|
147240
147269
|
[gi](t2, e, i, r) {
|
|
147241
147270
|
let n = `${i}Sync`;
|
|
147242
147271
|
try {
|
|
147243
|
-
|
|
147272
|
+
import_node_fs13.default[n](e, String(t2.absolute)), r(), t2.resume();
|
|
147244
147273
|
} catch (o) {
|
|
147245
147274
|
return this[O2](o, t2);
|
|
147246
147275
|
}
|
|
147247
147276
|
}
|
|
147248
147277
|
};
|
|
147249
147278
|
var Eo = (s3) => {
|
|
147250
|
-
let t2 = new xe(s3), e = s3.file, i =
|
|
147279
|
+
let t2 = new xe(s3), e = s3.file, i = import_node_fs12.default.statSync(e), r = s3.maxReadSize || 16 * 1024 * 1024;
|
|
147251
147280
|
new Be(e, { readSize: r, size: i.size }).pipe(t2);
|
|
147252
147281
|
};
|
|
147253
147282
|
var wo = (s3, t2) => {
|
|
147254
147283
|
let e = new Xt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
|
|
147255
147284
|
return new Promise((o, h) => {
|
|
147256
|
-
e.on("error", h), e.on("close", o),
|
|
147285
|
+
e.on("error", h), e.on("close", o), import_node_fs12.default.stat(r, (a, l) => {
|
|
147257
147286
|
if (a) h(a);
|
|
147258
147287
|
else {
|
|
147259
147288
|
let c = new _t(r, { readSize: i, size: l.size });
|
|
@@ -147269,15 +147298,15 @@ var yo = (s3, t2) => {
|
|
|
147269
147298
|
let e = new kt(s3), i = true, r, n;
|
|
147270
147299
|
try {
|
|
147271
147300
|
try {
|
|
147272
|
-
r =
|
|
147301
|
+
r = import_node_fs16.default.openSync(s3.file, "r+");
|
|
147273
147302
|
} catch (a) {
|
|
147274
|
-
if (a?.code === "ENOENT") r =
|
|
147303
|
+
if (a?.code === "ENOENT") r = import_node_fs16.default.openSync(s3.file, "w+");
|
|
147275
147304
|
else throw a;
|
|
147276
147305
|
}
|
|
147277
|
-
let o =
|
|
147306
|
+
let o = import_node_fs16.default.fstatSync(r), h = Buffer.alloc(512);
|
|
147278
147307
|
t: for (n = 0; n < o.size; n += 512) {
|
|
147279
147308
|
for (let c = 0, d = 0; c < 512; c += d) {
|
|
147280
|
-
if (d =
|
|
147309
|
+
if (d = import_node_fs16.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");
|
|
147281
147310
|
if (!d) break t;
|
|
147282
147311
|
}
|
|
147283
147312
|
let a = new F2(h);
|
|
@@ -147289,7 +147318,7 @@ var yo = (s3, t2) => {
|
|
|
147289
147318
|
i = false, Ro(s3, e, n, r, t2);
|
|
147290
147319
|
} finally {
|
|
147291
147320
|
if (i) try {
|
|
147292
|
-
|
|
147321
|
+
import_node_fs16.default.closeSync(r);
|
|
147293
147322
|
} catch {
|
|
147294
147323
|
}
|
|
147295
147324
|
}
|
|
@@ -147302,29 +147331,29 @@ var go = (s3, t2) => {
|
|
|
147302
147331
|
t2 = Array.from(t2);
|
|
147303
147332
|
let e = new wt(s3), i = (n, o, h) => {
|
|
147304
147333
|
let a = (T2, D2) => {
|
|
147305
|
-
T2 ?
|
|
147334
|
+
T2 ? import_node_fs16.default.close(n, (E2) => h(T2)) : h(null, D2);
|
|
147306
147335
|
}, l = 0;
|
|
147307
147336
|
if (o === 0) return a(null, 0);
|
|
147308
147337
|
let c = 0, d = Buffer.alloc(512), S2 = (T2, D2) => {
|
|
147309
147338
|
if (T2 || D2 === void 0) return a(T2);
|
|
147310
|
-
if (c += D2, c < 512 && D2) return
|
|
147339
|
+
if (c += D2, c < 512 && D2) return import_node_fs16.default.read(n, d, c, d.length - c, l + c, S2);
|
|
147311
147340
|
if (l === 0 && d[0] === 31 && d[1] === 139) return a(new Error("cannot append to compressed archives"));
|
|
147312
147341
|
if (c < 512) return a(null, l);
|
|
147313
147342
|
let E2 = new F2(d);
|
|
147314
147343
|
if (!E2.cksumValid) return a(null, l);
|
|
147315
147344
|
let x2 = 512 * Math.ceil((E2.size ?? 0) / 512);
|
|
147316
147345
|
if (l + x2 + 512 > o || (l += x2 + 512, l >= o)) return a(null, l);
|
|
147317
|
-
s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c = 0,
|
|
147346
|
+
s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c = 0, import_node_fs16.default.read(n, d, 0, 512, l, S2);
|
|
147318
147347
|
};
|
|
147319
|
-
|
|
147348
|
+
import_node_fs16.default.read(n, d, 0, 512, l, S2);
|
|
147320
147349
|
};
|
|
147321
147350
|
return new Promise((n, o) => {
|
|
147322
147351
|
e.on("error", o);
|
|
147323
147352
|
let h = "r+", a = (l, c) => {
|
|
147324
|
-
if (l && l.code === "ENOENT" && h === "r+") return h = "w+",
|
|
147353
|
+
if (l && l.code === "ENOENT" && h === "r+") return h = "w+", import_node_fs16.default.open(s3.file, h, a);
|
|
147325
147354
|
if (l || !c) return o(l);
|
|
147326
|
-
|
|
147327
|
-
if (d) return
|
|
147355
|
+
import_node_fs16.default.fstat(c, (d, S2) => {
|
|
147356
|
+
if (d) return import_node_fs16.default.close(c, () => o(d));
|
|
147328
147357
|
i(c, S2.size, (T2, D2) => {
|
|
147329
147358
|
if (T2) return o(T2);
|
|
147330
147359
|
let E2 = new et(s3.file, { fd: c, start: D2 });
|
|
@@ -147332,16 +147361,16 @@ var go = (s3, t2) => {
|
|
|
147332
147361
|
});
|
|
147333
147362
|
});
|
|
147334
147363
|
};
|
|
147335
|
-
|
|
147364
|
+
import_node_fs16.default.open(s3.file, h, a);
|
|
147336
147365
|
});
|
|
147337
147366
|
};
|
|
147338
147367
|
var bo = (s3, t2) => {
|
|
147339
147368
|
t2.forEach((e) => {
|
|
147340
|
-
e.charAt(0) === "@" ? Ct({ file:
|
|
147369
|
+
e.charAt(0) === "@" ? Ct({ file: import_node_path22.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
147341
147370
|
}), s3.end();
|
|
147342
147371
|
};
|
|
147343
147372
|
var _o = async (s3, t2) => {
|
|
147344
|
-
for (let e of t2) e.charAt(0) === "@" ? await Ct({ file:
|
|
147373
|
+
for (let e of t2) e.charAt(0) === "@" ? await Ct({ file: import_node_path22.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
147345
147374
|
s3.end();
|
|
147346
147375
|
};
|
|
147347
147376
|
var vt = K2(yo, go, () => {
|
|
@@ -147364,19 +147393,19 @@ var To = (s3) => {
|
|
|
147364
147393
|
// src/updater/unpack.ts
|
|
147365
147394
|
async function unpackTarball(opts) {
|
|
147366
147395
|
const { tarballPath, destDir } = opts;
|
|
147367
|
-
(0,
|
|
147368
|
-
(0,
|
|
147396
|
+
(0, import_node_fs17.rmSync)(destDir, { recursive: true, force: true });
|
|
147397
|
+
(0, import_node_fs17.mkdirSync)(destDir, { recursive: true });
|
|
147369
147398
|
await So({ file: tarballPath, cwd: destDir });
|
|
147370
147399
|
}
|
|
147371
147400
|
|
|
147372
147401
|
// src/updater/update-log.ts
|
|
147373
|
-
var
|
|
147374
|
-
var
|
|
147375
|
-
var LOG_PATH = (0,
|
|
147402
|
+
var import_node_fs18 = require("fs");
|
|
147403
|
+
var import_node_path23 = require("path");
|
|
147404
|
+
var LOG_PATH = (0, import_node_path23.join)(THREADBASE_ROOT, "update.log");
|
|
147376
147405
|
function appendUpdateLog(line) {
|
|
147377
147406
|
try {
|
|
147378
|
-
(0,
|
|
147379
|
-
(0,
|
|
147407
|
+
(0, import_node_fs18.mkdirSync)(THREADBASE_ROOT, { recursive: true });
|
|
147408
|
+
(0, import_node_fs18.appendFileSync)(LOG_PATH, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
147380
147409
|
`, "utf8");
|
|
147381
147410
|
} catch {
|
|
147382
147411
|
}
|
|
@@ -147447,7 +147476,7 @@ async function runInstall(opts) {
|
|
|
147447
147476
|
}
|
|
147448
147477
|
}
|
|
147449
147478
|
ensureReleasesDir();
|
|
147450
|
-
(0,
|
|
147479
|
+
(0, import_node_fs19.mkdirSync)(DOWNLOAD_DIR, { recursive: true });
|
|
147451
147480
|
const tarballPath = downloadPath(targetVersion, artifact.filename);
|
|
147452
147481
|
await downloadAndVerify({ manifest, assets: target.assets, targetPath: tarballPath });
|
|
147453
147482
|
const destDir = releaseDir(targetVersion);
|
|
@@ -147481,7 +147510,7 @@ async function runInstall(opts) {
|
|
|
147481
147510
|
|
|
147482
147511
|
// cli/prod.ts
|
|
147483
147512
|
var import_node_child_process6 = require("child_process");
|
|
147484
|
-
var
|
|
147513
|
+
var import_node_fs21 = require("fs");
|
|
147485
147514
|
init_constants();
|
|
147486
147515
|
init_launchd();
|
|
147487
147516
|
init_marker();
|
|
@@ -147567,7 +147596,7 @@ async function runProdDoctor(opts) {
|
|
|
147567
147596
|
return { findings, repairs };
|
|
147568
147597
|
}
|
|
147569
147598
|
var defaultSpawnTail = ({ files, lines, follow }) => {
|
|
147570
|
-
const existing = files.filter((f2) => (0,
|
|
147599
|
+
const existing = files.filter((f2) => (0, import_node_fs21.existsSync)(f2));
|
|
147571
147600
|
if (existing.length === 0) {
|
|
147572
147601
|
return Promise.resolve({
|
|
147573
147602
|
ok: false,
|
|
@@ -147621,8 +147650,8 @@ function registerProdCommands(program3) {
|
|
|
147621
147650
|
const prod = new Command("prod").description(
|
|
147622
147651
|
"Manage the launchd-supervised prod streamer"
|
|
147623
147652
|
);
|
|
147624
|
-
prod.command("start").description("Restore prod after a user-held suspension").option("--
|
|
147625
|
-
if (opts.
|
|
147653
|
+
prod.command("start").description("Restore prod after a user-held suspension").option("--clear-logs", "Clear existing stdout + stderr logs", false).action(async (opts) => {
|
|
147654
|
+
if (opts.clearLogs === true) clearSupervisorLogs();
|
|
147626
147655
|
const r = await runProdStart();
|
|
147627
147656
|
log4.info(r.message, void 0, "console");
|
|
147628
147657
|
if (!r.ok) process.exitCode = 1;
|
|
@@ -147640,10 +147669,10 @@ function registerProdCommands(program3) {
|
|
|
147640
147669
|
];
|
|
147641
147670
|
log4.info(parts.join("\n "), void 0, "console");
|
|
147642
147671
|
});
|
|
147643
|
-
prod.command("restart").description("Stop + restart the supervised streamer (re-reads service definition)").option("--
|
|
147672
|
+
prod.command("restart").description("Stop + restart the supervised streamer (re-reads service definition)").option("--clear-logs", "Clear existing stdout + stderr logs", false).action(async (opts) => {
|
|
147644
147673
|
const sup = getSupervisor();
|
|
147645
147674
|
const specPath = process.platform === "darwin" ? darwinPlistPath() : "";
|
|
147646
|
-
if (opts.
|
|
147675
|
+
if (opts.clearLogs === true) clearSupervisorLogs();
|
|
147647
147676
|
sup.bootoutAgent();
|
|
147648
147677
|
sup.bootstrapAgent(specPath);
|
|
147649
147678
|
const what = process.platform === "darwin" ? `agent restarted from ${specPath}` : `task '${TASK_NAME}' restarted`;
|
|
@@ -147697,6 +147726,7 @@ program2.command("serve").description("Start the streamer server").option("-p, -
|
|
|
147697
147726
|
const apiKey = opts.apiKey ?? loadOrCreateApiKey();
|
|
147698
147727
|
const publicUrl = opts.publicUrl ?? loadPublicUrl() ?? null;
|
|
147699
147728
|
const isProdInvocation = opts.prod === true || process.ppid === 1;
|
|
147729
|
+
if (!isProdInvocation) appendDevSessionMarker();
|
|
147700
147730
|
let resolvedPort = requestedPort;
|
|
147701
147731
|
if (!isProdInvocation) {
|
|
147702
147732
|
const { resolveDevPlan: resolveDevPlan2, detectProdActive: detectProdActive2, isPortInUse: isPortInUse2, findFreePort: findFreePort2, takeoverProd: takeoverProd2 } = await Promise.resolve().then(() => (init_dev_takeover(), dev_takeover_exports));
|
|
@@ -147787,8 +147817,8 @@ program2.command("cache").description("Manage the local SQLite conversation cach
|
|
|
147787
147817
|
`${process.env.HOME}/.threadbase/cache`
|
|
147788
147818
|
).action((opts) => {
|
|
147789
147819
|
const { rmSync: rmSync6, existsSync: existsSync11 } = require("fs");
|
|
147790
|
-
const { join:
|
|
147791
|
-
const dbPath =
|
|
147820
|
+
const { join: join26 } = require("path");
|
|
147821
|
+
const dbPath = join26(opts.cacheDir, "cache.db");
|
|
147792
147822
|
for (const suffix of ["", "-shm", "-wal"]) {
|
|
147793
147823
|
const f2 = dbPath + suffix;
|
|
147794
147824
|
if (existsSync11(f2)) {
|