siluzan-cso-cli 1.1.8-beta.5 → 1.1.8-beta.6
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 +91 -91
- package/dist/skill/_meta.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ siluzan-cso init -d /path/to/skills # 写入自定义目录
|
|
|
20
20
|
siluzan-cso init --force # 强制覆盖已存在文件
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
> **注意**:当前为测试版(1.1.8-beta.
|
|
23
|
+
> **注意**:当前为测试版(1.1.8-beta.6),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-cso-cli`。
|
|
24
24
|
|
|
25
25
|
| 助手 | 建议 `--ai` |
|
|
26
26
|
|------|-------------|
|
package/dist/index.js
CHANGED
|
@@ -2125,11 +2125,11 @@ import * as path3 from "path";
|
|
|
2125
2125
|
import * as os2 from "os";
|
|
2126
2126
|
import * as https from "https";
|
|
2127
2127
|
import * as http from "http";
|
|
2128
|
-
import * as os22 from "os";
|
|
2129
2128
|
import { randomUUID as _randomUUID } from "crypto";
|
|
2130
2129
|
import * as fs22 from "fs";
|
|
2131
2130
|
import * as path22 from "path";
|
|
2132
2131
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2132
|
+
import * as os22 from "os";
|
|
2133
2133
|
var SILUZAN_DIR = path3.join(os2.homedir(), ".siluzan");
|
|
2134
2134
|
var CONFIG_FILE = path3.join(SILUZAN_DIR, "config.json");
|
|
2135
2135
|
function readStr(raw, key) {
|
|
@@ -2242,6 +2242,96 @@ function rawRequest(url, options) {
|
|
|
2242
2242
|
req.end();
|
|
2243
2243
|
});
|
|
2244
2244
|
}
|
|
2245
|
+
function redactSensitive(input) {
|
|
2246
|
+
let output = input;
|
|
2247
|
+
output = output.replace(/(Bearer\s+)[^\s",]+/gi, "$1***");
|
|
2248
|
+
output = output.replace(
|
|
2249
|
+
/("?(?:apiKey|authToken|accessToken|refreshToken|token|authorization)"?\s*[:=]\s*"?)([^"\s,}]+)/gi,
|
|
2250
|
+
"$1***"
|
|
2251
|
+
);
|
|
2252
|
+
return output;
|
|
2253
|
+
}
|
|
2254
|
+
async function apiFetch(url, config, options = {}, verbose = false) {
|
|
2255
|
+
const method = options.method ?? "GET";
|
|
2256
|
+
const authHeaders = config.apiKey ? { "x-api-key": config.apiKey } : { Authorization: `Bearer ${config.authToken}` };
|
|
2257
|
+
const reqHeaders = {
|
|
2258
|
+
"Content-Type": "application/json",
|
|
2259
|
+
"Accept-Language": "zh-CN",
|
|
2260
|
+
...authHeaders,
|
|
2261
|
+
// dataPermission 仅 TSO 使用;CSO 未设置时为空字符串,服务端忽略该头
|
|
2262
|
+
Datapermission: config.dataPermission ?? "",
|
|
2263
|
+
...options.headers ?? {}
|
|
2264
|
+
};
|
|
2265
|
+
const body = typeof options.body === "string" ? options.body : void 0;
|
|
2266
|
+
const res = await rawRequest(url, {
|
|
2267
|
+
method,
|
|
2268
|
+
headers: reqHeaders,
|
|
2269
|
+
body
|
|
2270
|
+
});
|
|
2271
|
+
const text = res.text;
|
|
2272
|
+
if (res.status < 200 || res.status >= 300) {
|
|
2273
|
+
const detail = verbose ? `\uFF1A${redactSensitive(text).slice(0, 300)}` : "";
|
|
2274
|
+
throw new Error(`HTTP ${res.status}${detail}`);
|
|
2275
|
+
}
|
|
2276
|
+
if (!text.trim()) return null;
|
|
2277
|
+
try {
|
|
2278
|
+
return JSON.parse(text);
|
|
2279
|
+
} catch {
|
|
2280
|
+
if (verbose) {
|
|
2281
|
+
console.error(` \u26A0\uFE0F \u54CD\u5E94\u975E JSON\uFF0C\u539F\u59CB\u5185\u5BB9\uFF1A${redactSensitive(text).slice(0, 200)}`);
|
|
2282
|
+
}
|
|
2283
|
+
return text;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
function decodeJwtClaims(token) {
|
|
2287
|
+
try {
|
|
2288
|
+
const parts = token.split(".");
|
|
2289
|
+
if (parts.length < 2) return null;
|
|
2290
|
+
const payload = Buffer.from(parts[1], "base64url").toString("utf8");
|
|
2291
|
+
const parsed = JSON.parse(payload);
|
|
2292
|
+
return parsed.sub ? parsed : null;
|
|
2293
|
+
} catch {
|
|
2294
|
+
return null;
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
function isUUID(value) {
|
|
2298
|
+
if (typeof value !== "string") return false;
|
|
2299
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
2300
|
+
}
|
|
2301
|
+
var randomUUID = _randomUUID;
|
|
2302
|
+
function getCurrentVersion(importMetaUrl) {
|
|
2303
|
+
try {
|
|
2304
|
+
const __dirname2 = path22.dirname(fileURLToPath2(importMetaUrl));
|
|
2305
|
+
const pkgPath = path22.join(__dirname2, "..", "package.json");
|
|
2306
|
+
const pkg = JSON.parse(fs22.readFileSync(pkgPath, "utf8"));
|
|
2307
|
+
return pkg.version ?? "0.0.0";
|
|
2308
|
+
} catch {
|
|
2309
|
+
return "0.0.0";
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
function npmDistTagForBuildEnv(buildEnv) {
|
|
2313
|
+
return buildEnv === "test" ? "beta" : "latest";
|
|
2314
|
+
}
|
|
2315
|
+
function npmMinRequiredTagForBuildEnv(buildEnv) {
|
|
2316
|
+
return buildEnv === "test" ? "min-required-beta" : "min-required";
|
|
2317
|
+
}
|
|
2318
|
+
function isNewer(a, b) {
|
|
2319
|
+
return import_semver.default.gt(b, a) === true;
|
|
2320
|
+
}
|
|
2321
|
+
async function fetchNpmVersion(pkgName, tag, timeoutMs = 4e3) {
|
|
2322
|
+
try {
|
|
2323
|
+
const url = `https://registry.npmjs.org/${pkgName}/${tag}`;
|
|
2324
|
+
const controller = new AbortController();
|
|
2325
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
2326
|
+
const res = await fetch(url, { signal: controller.signal });
|
|
2327
|
+
clearTimeout(timer);
|
|
2328
|
+
if (!res.ok) return null;
|
|
2329
|
+
const data = await res.json();
|
|
2330
|
+
return data.version ?? null;
|
|
2331
|
+
} catch {
|
|
2332
|
+
return null;
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2245
2335
|
var DEFAULT_SENTRY_DSN = "https://bafcf42aab6fe7b485310619ae041b5e@o4510436169285632.ingest.us.sentry.io/4511103054708736";
|
|
2246
2336
|
function isSentryDisabled() {
|
|
2247
2337
|
return process.env.SILUZAN_SENTRY_DISABLED === "1" || process.env.SILUZAN_SENTRY_DISABLED === "true";
|
|
@@ -2482,96 +2572,6 @@ function refreshSiluzanUser(apiBase, config) {
|
|
|
2482
2572
|
}
|
|
2483
2573
|
})();
|
|
2484
2574
|
}
|
|
2485
|
-
function redactSensitive(input) {
|
|
2486
|
-
let output = input;
|
|
2487
|
-
output = output.replace(/(Bearer\s+)[^\s",]+/gi, "$1***");
|
|
2488
|
-
output = output.replace(
|
|
2489
|
-
/("?(?:apiKey|authToken|accessToken|refreshToken|token|authorization)"?\s*[:=]\s*"?)([^"\s,}]+)/gi,
|
|
2490
|
-
"$1***"
|
|
2491
|
-
);
|
|
2492
|
-
return output;
|
|
2493
|
-
}
|
|
2494
|
-
async function apiFetch(url, config, options = {}, verbose = false) {
|
|
2495
|
-
const method = options.method ?? "GET";
|
|
2496
|
-
const authHeaders = config.apiKey ? { "x-api-key": config.apiKey } : { Authorization: `Bearer ${config.authToken}` };
|
|
2497
|
-
const reqHeaders = {
|
|
2498
|
-
"Content-Type": "application/json",
|
|
2499
|
-
"Accept-Language": "zh-CN",
|
|
2500
|
-
...authHeaders,
|
|
2501
|
-
// dataPermission 仅 TSO 使用;CSO 未设置时为空字符串,服务端忽略该头
|
|
2502
|
-
Datapermission: config.dataPermission ?? "",
|
|
2503
|
-
...options.headers ?? {}
|
|
2504
|
-
};
|
|
2505
|
-
const body = typeof options.body === "string" ? options.body : void 0;
|
|
2506
|
-
const res = await rawRequest(url, {
|
|
2507
|
-
method,
|
|
2508
|
-
headers: reqHeaders,
|
|
2509
|
-
body
|
|
2510
|
-
});
|
|
2511
|
-
const text = res.text;
|
|
2512
|
-
if (res.status < 200 || res.status >= 300) {
|
|
2513
|
-
const detail = verbose ? `\uFF1A${redactSensitive(text).slice(0, 300)}` : "";
|
|
2514
|
-
throw new Error(`HTTP ${res.status}${detail}`);
|
|
2515
|
-
}
|
|
2516
|
-
if (!text.trim()) return null;
|
|
2517
|
-
try {
|
|
2518
|
-
return JSON.parse(text);
|
|
2519
|
-
} catch {
|
|
2520
|
-
if (verbose) {
|
|
2521
|
-
console.error(` \u26A0\uFE0F \u54CD\u5E94\u975E JSON\uFF0C\u539F\u59CB\u5185\u5BB9\uFF1A${redactSensitive(text).slice(0, 200)}`);
|
|
2522
|
-
}
|
|
2523
|
-
return text;
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
function decodeJwtClaims(token) {
|
|
2527
|
-
try {
|
|
2528
|
-
const parts = token.split(".");
|
|
2529
|
-
if (parts.length < 2) return null;
|
|
2530
|
-
const payload = Buffer.from(parts[1], "base64url").toString("utf8");
|
|
2531
|
-
const parsed = JSON.parse(payload);
|
|
2532
|
-
return parsed.sub ? parsed : null;
|
|
2533
|
-
} catch {
|
|
2534
|
-
return null;
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
function isUUID(value) {
|
|
2538
|
-
if (typeof value !== "string") return false;
|
|
2539
|
-
return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
2540
|
-
}
|
|
2541
|
-
var randomUUID = _randomUUID;
|
|
2542
|
-
function getCurrentVersion(importMetaUrl) {
|
|
2543
|
-
try {
|
|
2544
|
-
const __dirname2 = path22.dirname(fileURLToPath2(importMetaUrl));
|
|
2545
|
-
const pkgPath = path22.join(__dirname2, "..", "package.json");
|
|
2546
|
-
const pkg = JSON.parse(fs22.readFileSync(pkgPath, "utf8"));
|
|
2547
|
-
return pkg.version ?? "0.0.0";
|
|
2548
|
-
} catch {
|
|
2549
|
-
return "0.0.0";
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
function npmDistTagForBuildEnv(buildEnv) {
|
|
2553
|
-
return buildEnv === "test" ? "beta" : "latest";
|
|
2554
|
-
}
|
|
2555
|
-
function npmMinRequiredTagForBuildEnv(buildEnv) {
|
|
2556
|
-
return buildEnv === "test" ? "min-required-beta" : "min-required";
|
|
2557
|
-
}
|
|
2558
|
-
function isNewer(a, b) {
|
|
2559
|
-
return import_semver.default.gt(b, a) === true;
|
|
2560
|
-
}
|
|
2561
|
-
async function fetchNpmVersion(pkgName, tag, timeoutMs = 4e3) {
|
|
2562
|
-
try {
|
|
2563
|
-
const url = `https://registry.npmjs.org/${pkgName}/${tag}`;
|
|
2564
|
-
const controller = new AbortController();
|
|
2565
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
2566
|
-
const res = await fetch(url, { signal: controller.signal });
|
|
2567
|
-
clearTimeout(timer);
|
|
2568
|
-
if (!res.ok) return null;
|
|
2569
|
-
const data = await res.json();
|
|
2570
|
-
return data.version ?? null;
|
|
2571
|
-
} catch {
|
|
2572
|
-
return null;
|
|
2573
|
-
}
|
|
2574
|
-
}
|
|
2575
2575
|
|
|
2576
2576
|
// src/commands/login.ts
|
|
2577
2577
|
async function runLogin(opts = {}) {
|
package/dist/skill/_meta.json
CHANGED
package/package.json
CHANGED