tt-help-cli-ycl 1.4.119 → 1.4.121
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/package.json +1 -1
- package/src/cli/explore.js +10 -18
- package/src/cli/refresh.js +4 -10
- package/src/cli/search.js +3 -10
- package/src/watchdog/agent.js +12 -3
package/package.json
CHANGED
package/src/cli/explore.js
CHANGED
|
@@ -27,7 +27,6 @@ import { showResourceUsage } from "../utils/index.js";
|
|
|
27
27
|
import { HealthChecker } from "../lib/browser/health-checker.js";
|
|
28
28
|
import { createApiClient } from "../lib/api-client.js";
|
|
29
29
|
import { createCDNHandler } from "../lib/cdn-handler.js";
|
|
30
|
-
import { requireClashOrExit } from "../clash/checker.js";
|
|
31
30
|
import path from "path";
|
|
32
31
|
import os from "os";
|
|
33
32
|
|
|
@@ -141,24 +140,17 @@ export async function handleExplore(options) {
|
|
|
141
140
|
cdpOptions.userDataDir = currentAccount.userDataDir;
|
|
142
141
|
}
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
console.error(`代理: ${detected} (自动发现)`);
|
|
154
|
-
} else {
|
|
155
|
-
cdpOptions.proxyServer = effectiveProxy;
|
|
156
|
-
console.error(
|
|
157
|
-
`代理: ${effectiveProxy}${exploreProxy ? " (命令行指定)" : " (配置文件)"}`,
|
|
158
|
-
);
|
|
159
|
-
}
|
|
143
|
+
// 配置了什么代理就用什么代理(--proxy > ~/.tt-help.json 的 proxy);
|
|
144
|
+
// 未配置则不注入 proxyServer,浏览器走系统默认代理。
|
|
145
|
+
// 本地地址不再自动解析/强制 requireClashOrExit(与 refresh-mini 一致)。
|
|
146
|
+
const resolvedProxy = exploreProxy || configuredProxy || null;
|
|
147
|
+
if (resolvedProxy) {
|
|
148
|
+
cdpOptions.proxyServer = resolvedProxy;
|
|
149
|
+
console.error(
|
|
150
|
+
`代理: ${resolvedProxy}${exploreProxy ? " (命令行指定)" : " (配置文件)"}`,
|
|
151
|
+
);
|
|
160
152
|
} else {
|
|
161
|
-
console.error(`代理:
|
|
153
|
+
console.error(`代理: 未配置(浏览器走系统默认代理)`);
|
|
162
154
|
}
|
|
163
155
|
|
|
164
156
|
console.error(`CDP 端口: ${cdpOptions.port}, 用户编号: ${userId}`);
|
package/src/cli/refresh.js
CHANGED
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
import { HealthChecker } from "../lib/browser/health-checker.js";
|
|
27
27
|
import { createApiClient } from "../lib/api-client.js";
|
|
28
28
|
import { createCDNHandler } from "../lib/cdn-handler.js";
|
|
29
|
-
import { requireClashOrExit } from "../clash/checker.js";
|
|
30
29
|
import path from "path";
|
|
31
30
|
import os from "os";
|
|
32
31
|
|
|
@@ -77,15 +76,10 @@ export async function handleRefresh(options) {
|
|
|
77
76
|
// 跳过用户信息、国家采样、关注/粉丝提取(最大耗时项)和商品详情抓取(由独立商品程序异步补抓),大幅提速。
|
|
78
77
|
const followEnabled = !exploreMini && exploreEnableFollow !== false;
|
|
79
78
|
const skipProduct = exploreMini || !!exploreNoProduct;
|
|
79
|
+
// 配置了什么代理就用什么代理(--proxy > ~/.tt-help.json 的 proxy);
|
|
80
|
+
// 未配置则不注入 proxyServer,浏览器走系统默认代理。
|
|
80
81
|
const effectiveProxy = exploreProxy || configuredProxy;
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
effectiveProxy &&
|
|
84
|
-
(effectiveProxy.includes("127.0.0.1") ||
|
|
85
|
-
effectiveProxy.includes("localhost"))
|
|
86
|
-
) {
|
|
87
|
-
resolvedProxy = await requireClashOrExit("Refresh");
|
|
88
|
-
}
|
|
82
|
+
const resolvedProxy = effectiveProxy || null;
|
|
89
83
|
|
|
90
84
|
let userId = exploreUserId || configuredUserId;
|
|
91
85
|
let browser = null;
|
|
@@ -138,7 +132,7 @@ export async function handleRefresh(options) {
|
|
|
138
132
|
console.error(`空闲间隔: ${exploreInterval || 30} 秒`);
|
|
139
133
|
if (resolvedProxy) {
|
|
140
134
|
console.error(
|
|
141
|
-
`代理: ${resolvedProxy}${
|
|
135
|
+
`代理: ${resolvedProxy}${exploreProxy ? " (命令行指定)" : " (配置文件)"}`,
|
|
142
136
|
);
|
|
143
137
|
}
|
|
144
138
|
if (exploreMaxUsers > 0) console.error(`上限: ${exploreMaxUsers} 个用户`);
|
package/src/cli/search.js
CHANGED
|
@@ -40,7 +40,6 @@ import {
|
|
|
40
40
|
} from "../scraper/modules/captcha-handler.js";
|
|
41
41
|
import { createApiClient } from "../lib/api-client.js";
|
|
42
42
|
import { HealthChecker } from "../lib/browser/health-checker.js";
|
|
43
|
-
import { requireClashOrExit } from "../clash/checker.js";
|
|
44
43
|
import {
|
|
45
44
|
server as cfgServer,
|
|
46
45
|
proxy as configuredProxy,
|
|
@@ -80,15 +79,9 @@ export async function handleSearch(parsed) {
|
|
|
80
79
|
proxy: cliProxy,
|
|
81
80
|
} = searchOpts || {};
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
effectiveProxy &&
|
|
87
|
-
(effectiveProxy.includes("127.0.0.1") ||
|
|
88
|
-
effectiveProxy.includes("localhost"))
|
|
89
|
-
) {
|
|
90
|
-
resolvedProxy = await requireClashOrExit("Search");
|
|
91
|
-
}
|
|
82
|
+
// 配置了什么代理就用什么代理(--proxy > ~/.tt-help.json 的 proxy);
|
|
83
|
+
// 未配置则不注入 proxyServer,浏览器走系统默认代理。
|
|
84
|
+
const resolvedProxy = cliProxy || configuredProxy || null;
|
|
92
85
|
|
|
93
86
|
const log = (...args) => process.stderr.write(args.join(" ") + "\n");
|
|
94
87
|
|
package/src/watchdog/agent.js
CHANGED
|
@@ -30,6 +30,7 @@ import { fileURLToPath } from "url";
|
|
|
30
30
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
31
31
|
const homeDir = homedir() || process.env.HOME || process.env.USERPROFILE || "";
|
|
32
32
|
const TT_HELP_CONFIG = join(homeDir, ".tt-help.json");
|
|
33
|
+
const IS_WIN = process.platform === "win32";
|
|
33
34
|
|
|
34
35
|
// ── 业务日志错误统计 → 触发节点切换 ──
|
|
35
36
|
// 识别采集程序日志里已有的错误分类标签(explore 等已打标),连续错误达标则切换出口节点
|
|
@@ -612,9 +613,17 @@ export class WatchdogAgent {
|
|
|
612
613
|
if (cfg.proxy) args.push("--proxy", cfg.proxy);
|
|
613
614
|
|
|
614
615
|
const { stdout, stderr, code } = await new Promise((resolve) => {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
616
|
+
// Windows 下 tt-help 是 .cmd 包装,必须 shell:true 才能被 cmd.exe 解析
|
|
617
|
+
// (与 process-manager.startCommand 的 Windows 处理保持一致)
|
|
618
|
+
const child = IS_WIN
|
|
619
|
+
? spawn([cmd, ...args].join(" "), {
|
|
620
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
621
|
+
shell: true,
|
|
622
|
+
windowsHide: true,
|
|
623
|
+
})
|
|
624
|
+
: spawn(cmd, args, {
|
|
625
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
626
|
+
});
|
|
618
627
|
let out = "",
|
|
619
628
|
err = "";
|
|
620
629
|
child.stdout.on("data", (d) => (out += d));
|