siluzan-tso-cli 1.1.64-beta.3 → 1.1.64-beta.4
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/README.md +1 -1
- package/dist/index.js +97 -12
- package/dist/skill/_meta.json +2 -2
- package/dist/skill/scripts/install.ps1 +1 -1
- package/dist/skill/scripts/install.sh +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ siluzan-tso init -d /path/to/skills # 写入自定义目录
|
|
|
51
51
|
siluzan-tso init --force # 强制覆盖已存在文件
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
> **注意**:当前为测试版(1.1.64-beta.
|
|
54
|
+
> **注意**:当前为测试版(1.1.64-beta.4),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-tso-cli`。
|
|
55
55
|
|
|
56
56
|
| 助手 | 建议 `--ai` |
|
|
57
57
|
| ----------------------- | ------------------------------------ |
|
package/dist/index.js
CHANGED
|
@@ -2333,7 +2333,28 @@ function rawRequest(url, options) {
|
|
|
2333
2333
|
const perfOn = isPerfEnabled();
|
|
2334
2334
|
const t0 = perfOn ? performance.now() : 0;
|
|
2335
2335
|
const method = options.method ?? "GET";
|
|
2336
|
-
return new Promise((
|
|
2336
|
+
return new Promise((resolvePromise, rejectPromise) => {
|
|
2337
|
+
const signal = options.signal;
|
|
2338
|
+
if (signal?.aborted) {
|
|
2339
|
+
rejectPromise(new RequestAbortedError(method, url));
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
let settled = false;
|
|
2343
|
+
let onAbort;
|
|
2344
|
+
const settle = () => {
|
|
2345
|
+
settled = true;
|
|
2346
|
+
if (onAbort) signal?.removeEventListener("abort", onAbort);
|
|
2347
|
+
};
|
|
2348
|
+
const resolve52 = (value) => {
|
|
2349
|
+
if (settled) return;
|
|
2350
|
+
settle();
|
|
2351
|
+
resolvePromise(value);
|
|
2352
|
+
};
|
|
2353
|
+
const reject = (err) => {
|
|
2354
|
+
if (settled) return;
|
|
2355
|
+
settle();
|
|
2356
|
+
rejectPromise(err);
|
|
2357
|
+
};
|
|
2337
2358
|
const parsed = new URL(url);
|
|
2338
2359
|
const transport = parsed.protocol === "https:" ? https : http;
|
|
2339
2360
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
@@ -2380,6 +2401,7 @@ function rawRequest(url, options) {
|
|
|
2380
2401
|
if (failed) return;
|
|
2381
2402
|
failed = true;
|
|
2382
2403
|
res.destroy();
|
|
2404
|
+
if (settled) return;
|
|
2383
2405
|
if (perfOn) {
|
|
2384
2406
|
emitPerf({
|
|
2385
2407
|
method,
|
|
@@ -2451,6 +2473,7 @@ function rawRequest(url, options) {
|
|
|
2451
2473
|
reject(new Error(`\u8BF7\u6C42\u8D85\u65F6\uFF08${(timeoutMs / 1e3).toFixed(0)} \u79D2\uFF09\uFF1A${method} ${url}`));
|
|
2452
2474
|
});
|
|
2453
2475
|
req.on("error", (err) => {
|
|
2476
|
+
if (settled) return;
|
|
2454
2477
|
if (perfOn) {
|
|
2455
2478
|
emitPerf({
|
|
2456
2479
|
method,
|
|
@@ -2464,6 +2487,25 @@ function rawRequest(url, options) {
|
|
|
2464
2487
|
}
|
|
2465
2488
|
reject(err);
|
|
2466
2489
|
});
|
|
2490
|
+
if (signal) {
|
|
2491
|
+
onAbort = () => {
|
|
2492
|
+
if (settled) return;
|
|
2493
|
+
if (perfOn) {
|
|
2494
|
+
emitPerf({
|
|
2495
|
+
method,
|
|
2496
|
+
url,
|
|
2497
|
+
status: 0,
|
|
2498
|
+
elapsedMs: performance.now() - t0,
|
|
2499
|
+
bytes: 0,
|
|
2500
|
+
ok: false,
|
|
2501
|
+
error: "cancelled"
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
reject(new RequestAbortedError(method, url));
|
|
2505
|
+
req.destroy();
|
|
2506
|
+
};
|
|
2507
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
2508
|
+
}
|
|
2467
2509
|
if (options.body !== void 0) {
|
|
2468
2510
|
const payload = typeof options.body === "string" ? Buffer.from(options.body) : options.body;
|
|
2469
2511
|
if (!headers["Content-Length"] && !headers["content-length"]) {
|
|
@@ -2582,6 +2624,7 @@ async function parseApiResponse(status, text4, verbose) {
|
|
|
2582
2624
|
}
|
|
2583
2625
|
}
|
|
2584
2626
|
function isTransientNetworkError(err) {
|
|
2627
|
+
if (err instanceof RequestAbortedError) return false;
|
|
2585
2628
|
const msg = err instanceof Error ? err.message : String(err);
|
|
2586
2629
|
const code = err?.code;
|
|
2587
2630
|
if (typeof code === "string" && ["ECONNRESET", "EPIPE", "ETIMEDOUT", "ECONNABORTED"].includes(code)) {
|
|
@@ -2595,7 +2638,7 @@ async function requestWithReadRetry(url, options) {
|
|
|
2595
2638
|
try {
|
|
2596
2639
|
return await rawRequest(url, options);
|
|
2597
2640
|
} catch (err) {
|
|
2598
|
-
if (method !== "GET" || attempt >= GET_RETRY_DELAYS_MS.length || !isTransientNetworkError(err)) {
|
|
2641
|
+
if (method !== "GET" || options.signal?.aborted || attempt >= GET_RETRY_DELAYS_MS.length || !isTransientNetworkError(err)) {
|
|
2599
2642
|
throw err;
|
|
2600
2643
|
}
|
|
2601
2644
|
await new Promise((r) => setTimeout(r, GET_RETRY_DELAYS_MS[attempt]));
|
|
@@ -2618,7 +2661,8 @@ async function apiFetch(url, config, options = {}, verbose = false) {
|
|
|
2618
2661
|
const res = await requestWithReadRetry(url, {
|
|
2619
2662
|
method,
|
|
2620
2663
|
headers: reqHeaders,
|
|
2621
|
-
body
|
|
2664
|
+
body,
|
|
2665
|
+
signal: options.signal ?? void 0
|
|
2622
2666
|
});
|
|
2623
2667
|
return parseApiResponse(res.status, res.text, verbose);
|
|
2624
2668
|
}
|
|
@@ -2633,7 +2677,12 @@ async function apiFetchWithHeaders(url, config, options = {}, verbose = false) {
|
|
|
2633
2677
|
...options.headers ?? {}
|
|
2634
2678
|
};
|
|
2635
2679
|
const body = typeof options.body === "string" ? options.body : void 0;
|
|
2636
|
-
const res = await requestWithReadRetry(url, {
|
|
2680
|
+
const res = await requestWithReadRetry(url, {
|
|
2681
|
+
method,
|
|
2682
|
+
headers: reqHeaders,
|
|
2683
|
+
body,
|
|
2684
|
+
signal: options.signal ?? void 0
|
|
2685
|
+
});
|
|
2637
2686
|
const text4 = res.text;
|
|
2638
2687
|
if (res.status < 200 || res.status >= 300) {
|
|
2639
2688
|
throw new Error(formatHttpError(res.status, text4, { verbose }));
|
|
@@ -3921,7 +3970,7 @@ async function issueApiKeyWithPhoneCode(opts) {
|
|
|
3921
3970
|
});
|
|
3922
3971
|
return apiKey;
|
|
3923
3972
|
}
|
|
3924
|
-
var import_semver, SILUZAN_DIR, CONFIG_FILE, inProcessLockChain, ALLOWED_HOSTNAME_SUFFIXES, EXACT_ID_FIELD_NAMES, SILUZAN_AGENT_COMPANY_SOURCE_TYPE, DEERFLOW_AGENT_ENV, _clientProduct, _resolveVersion, DEFAULT_TIMEOUT_MS, httpsAgent, httpAgent, PERF_PREFIX, DEFAULT_DETAIL_MAX, VERBOSE_DETAIL_MAX, GET_RETRY_DELAYS_MS, TABLE_CELL_PIPE, ASCII_TABLE_CHARS, CLI_SNAPSHOT_MANIFEST_FILE, SCHEMA_VERSION, FALLBACK_FIELD_GUIDE_REFS, _cliPackage, _resolveCliVersion, _fieldGuideRefs, OUTLINE_AGENT_HINT, TS_LIKE_ARRAY_SAMPLE_MAX, MAX_INVOCATION_CHARS, currentInvocation, MAX_COMMIT_CHARS, WRITE_AUDIT_AGENT_AUTO_COMMIT, cliCommitOverride, WRITE_AUDIT_SCHEMA_VERSION, MUTATING, BEIJING_TZ, AUDIT_LOG_FILENAME_RE, DEFAULT_MAX_FILE_MB, MIN_SEGMENT_BYTES, MAX_SEGMENT_BYTES, DEFAULT_RETENTION_DAYS, MIN_RETENTION_DAYS, MAX_RETENTION_DAYS, PRUNE_THROTTLE_MS, lastPruneAtMs, MAX_BODY_CHARS, MAX_ERROR_CHARS, DEFAULT_FIND_AUDIT_MAX_DAYS, MAX_SNAPSHOT_FILE_BYTES, API_KEY_SERVICE_VALUES;
|
|
3973
|
+
var import_semver, SILUZAN_DIR, CONFIG_FILE, inProcessLockChain, ALLOWED_HOSTNAME_SUFFIXES, EXACT_ID_FIELD_NAMES, SILUZAN_AGENT_COMPANY_SOURCE_TYPE, DEERFLOW_AGENT_ENV, _clientProduct, _resolveVersion, DEFAULT_TIMEOUT_MS, httpsAgent, httpAgent, PERF_PREFIX, RequestAbortedError, DEFAULT_DETAIL_MAX, VERBOSE_DETAIL_MAX, GET_RETRY_DELAYS_MS, TABLE_CELL_PIPE, ASCII_TABLE_CHARS, CLI_SNAPSHOT_MANIFEST_FILE, SCHEMA_VERSION, FALLBACK_FIELD_GUIDE_REFS, _cliPackage, _resolveCliVersion, _fieldGuideRefs, OUTLINE_AGENT_HINT, TS_LIKE_ARRAY_SAMPLE_MAX, MAX_INVOCATION_CHARS, currentInvocation, MAX_COMMIT_CHARS, WRITE_AUDIT_AGENT_AUTO_COMMIT, cliCommitOverride, WRITE_AUDIT_SCHEMA_VERSION, MUTATING, BEIJING_TZ, AUDIT_LOG_FILENAME_RE, DEFAULT_MAX_FILE_MB, MIN_SEGMENT_BYTES, MAX_SEGMENT_BYTES, DEFAULT_RETENTION_DAYS, MIN_RETENTION_DAYS, MAX_RETENTION_DAYS, PRUNE_THROTTLE_MS, lastPruneAtMs, MAX_BODY_CHARS, MAX_ERROR_CHARS, DEFAULT_FIND_AUDIT_MAX_DAYS, MAX_SNAPSHOT_FILE_BYTES, API_KEY_SERVICE_VALUES;
|
|
3925
3974
|
var init_dist = __esm({
|
|
3926
3975
|
"../common/dist/index.js"() {
|
|
3927
3976
|
"use strict";
|
|
@@ -3986,6 +4035,13 @@ var init_dist = __esm({
|
|
|
3986
4035
|
scheduling: "lifo"
|
|
3987
4036
|
});
|
|
3988
4037
|
PERF_PREFIX = "[SILUZAN_HTTP_PERF]";
|
|
4038
|
+
RequestAbortedError = class extends Error {
|
|
4039
|
+
code = "SILUZAN_REQUEST_CANCELLED";
|
|
4040
|
+
constructor(method, url) {
|
|
4041
|
+
super(`\u8BF7\u6C42\u5DF2\u53D6\u6D88\uFF1A${method} ${url}`);
|
|
4042
|
+
this.name = "RequestAbortedError";
|
|
4043
|
+
}
|
|
4044
|
+
};
|
|
3989
4045
|
DEFAULT_DETAIL_MAX = 400;
|
|
3990
4046
|
VERBOSE_DETAIL_MAX = 800;
|
|
3991
4047
|
GET_RETRY_DELAYS_MS = [1e3, 3e3];
|
|
@@ -8341,20 +8397,27 @@ function sleep3(ms, signal) {
|
|
|
8341
8397
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
8342
8398
|
});
|
|
8343
8399
|
}
|
|
8344
|
-
async function withTaskTimeout(factory, timeoutMs, label2) {
|
|
8345
|
-
|
|
8400
|
+
async function withTaskTimeout(factory, timeoutMs, label2, parentSignal) {
|
|
8401
|
+
const controller = new AbortController();
|
|
8402
|
+
const abortFromParent = () => controller.abort();
|
|
8403
|
+
if (parentSignal?.aborted) controller.abort();
|
|
8404
|
+
else parentSignal?.addEventListener("abort", abortFromParent, { once: true });
|
|
8346
8405
|
let timer;
|
|
8347
8406
|
try {
|
|
8407
|
+
if (!timeoutMs || timeoutMs <= 0) return await factory(controller.signal);
|
|
8348
8408
|
return await Promise.race([
|
|
8349
|
-
factory(),
|
|
8409
|
+
factory(controller.signal),
|
|
8350
8410
|
new Promise((_, reject) => {
|
|
8351
8411
|
timer = setTimeout(() => {
|
|
8352
|
-
|
|
8412
|
+
const seconds = (timeoutMs / 1e3).toFixed(timeoutMs < 1e3 ? 1 : 0);
|
|
8413
|
+
reject(new Error(`\u8BF7\u6C42\u8D85\u65F6\uFF08${seconds} \u79D2\uFF09\uFF1A${label2}`));
|
|
8414
|
+
controller.abort();
|
|
8353
8415
|
}, timeoutMs);
|
|
8354
8416
|
})
|
|
8355
8417
|
]);
|
|
8356
8418
|
} finally {
|
|
8357
8419
|
if (timer) clearTimeout(timer);
|
|
8420
|
+
parentSignal?.removeEventListener("abort", abortFromParent);
|
|
8358
8421
|
}
|
|
8359
8422
|
}
|
|
8360
8423
|
async function fetchWithRetry(factory, options) {
|
|
@@ -8368,12 +8431,18 @@ async function fetchWithRetry(factory, options) {
|
|
|
8368
8431
|
});
|
|
8369
8432
|
}
|
|
8370
8433
|
try {
|
|
8371
|
-
return await withTaskTimeout(factory, policy.taskTimeoutMs, options.label);
|
|
8434
|
+
return await withTaskTimeout(factory, policy.taskTimeoutMs, options.label, options.signal);
|
|
8372
8435
|
} catch (raw) {
|
|
8373
8436
|
const err = raw instanceof Error ? raw : new Error(String(raw));
|
|
8374
8437
|
const cls = classifyError(err);
|
|
8375
8438
|
lastErr = err;
|
|
8376
8439
|
lastStatus = cls.status;
|
|
8440
|
+
if (options.signal?.aborted) {
|
|
8441
|
+
throw new AbortRunError({
|
|
8442
|
+
message: `\u4EFB\u52A1\u88AB\u5916\u90E8\u4FE1\u53F7\u4E2D\u6B62\uFF1A${options.label}`,
|
|
8443
|
+
cause: err
|
|
8444
|
+
});
|
|
8445
|
+
}
|
|
8377
8446
|
if (cls.class === "abort") {
|
|
8378
8447
|
throw new AbortRunError({
|
|
8379
8448
|
message: `Token \u5931\u6548\u6216\u81F4\u547D\u9519\u8BEF\uFF08${options.label}\uFF09\uFF1A${err.message}`,
|
|
@@ -103881,10 +103950,18 @@ async function fetchGoogleAnalysisHttp(label2, factory, http2) {
|
|
|
103881
103950
|
}
|
|
103882
103951
|
async function fetchJson(config, pathWithQuery, verbose, label2 = pathWithQuery, http2) {
|
|
103883
103952
|
const url = `${config.googleApiUrl}${pathWithQuery}`;
|
|
103884
|
-
return fetchGoogleAnalysisHttp(
|
|
103953
|
+
return fetchGoogleAnalysisHttp(
|
|
103954
|
+
label2,
|
|
103955
|
+
(signal) => apiFetch2(url, config, { signal }, verbose),
|
|
103956
|
+
http2
|
|
103957
|
+
);
|
|
103885
103958
|
}
|
|
103886
103959
|
async function fetchMainPlatformJson(url, config, verbose, label2, http2) {
|
|
103887
|
-
return fetchGoogleAnalysisHttp(
|
|
103960
|
+
return fetchGoogleAnalysisHttp(
|
|
103961
|
+
label2,
|
|
103962
|
+
(signal) => apiFetch2(url, config, { signal }, verbose),
|
|
103963
|
+
http2
|
|
103964
|
+
);
|
|
103888
103965
|
}
|
|
103889
103966
|
function deviceBidModifierLookupKey(campaignId, adGroupId, deviceType) {
|
|
103890
103967
|
return `${campaignId ?? ""}\0${adGroupId ?? ""}\0${deviceType ?? ""}`;
|
|
@@ -106393,6 +106470,14 @@ async function runBatch(opts) {
|
|
|
106393
106470
|
} catch (raw) {
|
|
106394
106471
|
const err = raw;
|
|
106395
106472
|
const durationMs = performance2.now() - t0;
|
|
106473
|
+
if (raw instanceof AbortRunError && raw.status !== 401 && aborterToken.signal.aborted) {
|
|
106474
|
+
await recordTaskTransition(opts.paths, inner, task, "failed_retryable", {
|
|
106475
|
+
attempts: raw.attempts,
|
|
106476
|
+
error: raw.message,
|
|
106477
|
+
durationMs
|
|
106478
|
+
});
|
|
106479
|
+
return;
|
|
106480
|
+
}
|
|
106396
106481
|
if (raw instanceof AbortRunError) {
|
|
106397
106482
|
tokenInvalidated = (raw.status ?? 0) === 401;
|
|
106398
106483
|
await recordTaskTransition(opts.paths, inner, task, "failed_permanent", {
|
package/dist/skill/_meta.json
CHANGED
|
@@ -9,7 +9,7 @@ $ErrorActionPreference = 'Stop'
|
|
|
9
9
|
# -- Package info (injected at build time) ------------------------------------
|
|
10
10
|
$PKG_NAME = 'siluzan-tso-cli'
|
|
11
11
|
# PKG_VERSION 锁定到与本脚本同批构建产物一致的版本,避免与 dist/skill 错位
|
|
12
|
-
$PKG_VERSION = '1.1.64-beta.
|
|
12
|
+
$PKG_VERSION = '1.1.64-beta.4'
|
|
13
13
|
$CLI_BIN = 'siluzan-tso'
|
|
14
14
|
$SKILL_LABEL = 'Siluzan TSO'
|
|
15
15
|
$INSTALL_CMD = 'npm install -g siluzan-tso-cli@beta'
|
|
@@ -9,7 +9,7 @@ set -euo pipefail
|
|
|
9
9
|
# -- Package info (injected at build time) ------------------------------------
|
|
10
10
|
readonly PKG_NAME="siluzan-tso-cli"
|
|
11
11
|
# PKG_VERSION 锁定到与本脚本同批构建产物一致的版本,避免与 dist/skill 错位
|
|
12
|
-
readonly PKG_VERSION="1.1.64-beta.
|
|
12
|
+
readonly PKG_VERSION="1.1.64-beta.4"
|
|
13
13
|
readonly CLI_BIN="siluzan-tso"
|
|
14
14
|
readonly SKILL_LABEL="Siluzan TSO"
|
|
15
15
|
readonly INSTALL_CMD="npm install -g siluzan-tso-cli@beta"
|