siluzan-cso-cli 1.1.30-beta.2 → 1.1.30-beta.3
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 +73 -36
- 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
|
@@ -54,7 +54,7 @@ siluzan-cso init -d /path/to/skills # 写入自定义目录
|
|
|
54
54
|
siluzan-cso init --force # 强制覆盖已存在文件
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
> **注意**:当前为测试版(1.1.30-beta.
|
|
57
|
+
> **注意**:当前为测试版(1.1.30-beta.3),供内部测试使用。正式发布后安装命令将改为 `npm install -g siluzan-cso-cli`。
|
|
58
58
|
|
|
59
59
|
| 助手 | 建议 `--ai` |
|
|
60
60
|
| ----------------------- | ------------------------------------ |
|
package/dist/index.js
CHANGED
|
@@ -2099,6 +2099,62 @@ function validateBaseUrl(raw) {
|
|
|
2099
2099
|
}
|
|
2100
2100
|
return null;
|
|
2101
2101
|
}
|
|
2102
|
+
function hasSiluzanAgentCredentials() {
|
|
2103
|
+
const apiKey = process.env.SILUZAN_API_KEY?.trim();
|
|
2104
|
+
const authToken = process.env.SILUZAN_AUTH_TOKEN?.trim();
|
|
2105
|
+
return Boolean(apiKey || authToken);
|
|
2106
|
+
}
|
|
2107
|
+
function isSiluzanAgentEnv() {
|
|
2108
|
+
const raw = process.env.IS_SILUZAN_AGENT_ENV?.trim().toLowerCase();
|
|
2109
|
+
return raw === "true" || raw === "1";
|
|
2110
|
+
}
|
|
2111
|
+
function skipAuthSetupInAgentEnv(commandLabel) {
|
|
2112
|
+
if (!isSiluzanAgentEnv()) return false;
|
|
2113
|
+
if (hasSiluzanAgentCredentials()) {
|
|
2114
|
+
console.log(
|
|
2115
|
+
`
|
|
2116
|
+
\u2139\uFE0F \u68C0\u6D4B\u5230 Siluzan Agent \u73AF\u5883\uFF08IS_SILUZAN_AGENT_ENV=true\uFF09\uFF0C\u51ED\u636E\u5DF2\u7531\u6C99\u7BB1\u6CE8\u5165\uFF0C\u65E0\u9700\u6267\u884C ${commandLabel}\u3002
|
|
2117
|
+
`
|
|
2118
|
+
);
|
|
2119
|
+
} else {
|
|
2120
|
+
console.log(
|
|
2121
|
+
`
|
|
2122
|
+
\u2139\uFE0F \u68C0\u6D4B\u5230 Siluzan Agent \u73AF\u5883\uFF08IS_SILUZAN_AGENT_ENV=true\uFF09\u3002
|
|
2123
|
+
${commandLabel} \u5DF2\u8DF3\u8FC7\uFF1B\u8BF7\u7531 Agent \u6C99\u7BB1\u6CE8\u5165 SILUZAN_API_KEY \u6216 SILUZAN_AUTH_TOKEN\u3002
|
|
2124
|
+
`
|
|
2125
|
+
);
|
|
2126
|
+
}
|
|
2127
|
+
return true;
|
|
2128
|
+
}
|
|
2129
|
+
function trimOrUndefined(value) {
|
|
2130
|
+
const trimmed = value?.trim();
|
|
2131
|
+
return trimmed ? trimmed : void 0;
|
|
2132
|
+
}
|
|
2133
|
+
function resolveAgentEnvCredentials() {
|
|
2134
|
+
const envToken = trimOrUndefined(process.env.SILUZAN_AUTH_TOKEN);
|
|
2135
|
+
if (envToken) return { authToken: envToken, apiKey: void 0 };
|
|
2136
|
+
const envApiKey = trimOrUndefined(process.env.SILUZAN_API_KEY);
|
|
2137
|
+
if (envApiKey) return { authToken: "", apiKey: envApiKey };
|
|
2138
|
+
return { authToken: "", apiKey: void 0 };
|
|
2139
|
+
}
|
|
2140
|
+
function resolveSiluzanCredentials(opts) {
|
|
2141
|
+
if (isSiluzanAgentEnv()) {
|
|
2142
|
+
return resolveAgentEnvCredentials();
|
|
2143
|
+
}
|
|
2144
|
+
const apiKey = trimOrUndefined(process.env.SILUZAN_API_KEY) ?? trimOrUndefined(opts.configApiKey);
|
|
2145
|
+
const authToken = trimOrUndefined(opts.tokenArg) ?? trimOrUndefined(process.env.SILUZAN_AUTH_TOKEN) ?? trimOrUndefined(opts.configAuthToken) ?? "";
|
|
2146
|
+
return { authToken, apiKey };
|
|
2147
|
+
}
|
|
2148
|
+
function resolveRequestAuth(config) {
|
|
2149
|
+
if (isSiluzanAgentEnv()) {
|
|
2150
|
+
return resolveAgentEnvCredentials();
|
|
2151
|
+
}
|
|
2152
|
+
return { authToken: config.authToken, apiKey: config.apiKey };
|
|
2153
|
+
}
|
|
2154
|
+
function buildSiluzanAuthHeaders(config) {
|
|
2155
|
+
const auth = resolveRequestAuth(config);
|
|
2156
|
+
return auth.apiKey ? { "x-api-key": auth.apiKey } : { Authorization: `Bearer ${auth.authToken}` };
|
|
2157
|
+
}
|
|
2102
2158
|
var DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
2103
2159
|
var MAX_RESPONSE_BYTES = 50 * 1024 * 1024;
|
|
2104
2160
|
var httpsAgent = new https.Agent({
|
|
@@ -2261,15 +2317,17 @@ function redactSensitive(input) {
|
|
|
2261
2317
|
);
|
|
2262
2318
|
return output;
|
|
2263
2319
|
}
|
|
2320
|
+
function buildAuthHeaders(config) {
|
|
2321
|
+
return buildSiluzanAuthHeaders(config);
|
|
2322
|
+
}
|
|
2264
2323
|
async function apiFetch(url, config, options = {}, verbose = false) {
|
|
2265
2324
|
const method = options.method ?? "GET";
|
|
2266
|
-
const authHeaders = config.apiKey ? { "x-api-key": config.apiKey } : { Authorization: `Bearer ${config.authToken}` };
|
|
2267
2325
|
const reqHeaders = {
|
|
2268
2326
|
"Content-Type": "application/json",
|
|
2269
2327
|
"Accept-Language": "zh-CN",
|
|
2270
2328
|
// 声明支持 gzip/deflate/br;服务端不支持则按 identity 返回,rawRequest 会原样收取
|
|
2271
2329
|
"Accept-Encoding": "gzip, deflate, br",
|
|
2272
|
-
...
|
|
2330
|
+
...buildAuthHeaders(config),
|
|
2273
2331
|
// dataPermission 仅 TSO 使用;CSO 未设置时为空字符串,服务端忽略该头
|
|
2274
2332
|
Datapermission: config.dataPermission ?? "",
|
|
2275
2333
|
...options.headers ?? {}
|
|
@@ -2798,33 +2856,6 @@ function installProcessHandlers() {
|
|
|
2798
2856
|
process.exit(1);
|
|
2799
2857
|
});
|
|
2800
2858
|
}
|
|
2801
|
-
function hasSiluzanAgentCredentials() {
|
|
2802
|
-
const apiKey = process.env.SILUZAN_API_KEY?.trim();
|
|
2803
|
-
const authToken = process.env.SILUZAN_AUTH_TOKEN?.trim();
|
|
2804
|
-
return Boolean(apiKey || authToken);
|
|
2805
|
-
}
|
|
2806
|
-
function isSiluzanAgentEnv() {
|
|
2807
|
-
const raw = process.env.IS_SILUZAN_AGENT_ENV?.trim().toLowerCase();
|
|
2808
|
-
return raw === "true" || raw === "1";
|
|
2809
|
-
}
|
|
2810
|
-
function skipAuthSetupInAgentEnv(commandLabel) {
|
|
2811
|
-
if (!isSiluzanAgentEnv()) return false;
|
|
2812
|
-
if (hasSiluzanAgentCredentials()) {
|
|
2813
|
-
console.log(
|
|
2814
|
-
`
|
|
2815
|
-
\u2139\uFE0F \u68C0\u6D4B\u5230 Siluzan Agent \u73AF\u5883\uFF08IS_SILUZAN_AGENT_ENV=true\uFF09\uFF0C\u51ED\u636E\u5DF2\u7531\u6C99\u7BB1\u6CE8\u5165\uFF0C\u65E0\u9700\u6267\u884C ${commandLabel}\u3002
|
|
2816
|
-
`
|
|
2817
|
-
);
|
|
2818
|
-
} else {
|
|
2819
|
-
console.log(
|
|
2820
|
-
`
|
|
2821
|
-
\u2139\uFE0F \u68C0\u6D4B\u5230 Siluzan Agent \u73AF\u5883\uFF08IS_SILUZAN_AGENT_ENV=true\uFF09\u3002
|
|
2822
|
-
${commandLabel} \u5DF2\u8DF3\u8FC7\uFF1B\u8BF7\u7531 Agent \u6C99\u7BB1\u6CE8\u5165 SILUZAN_API_KEY \u6216 SILUZAN_AUTH_TOKEN\u3002
|
|
2823
|
-
`
|
|
2824
|
-
);
|
|
2825
|
-
}
|
|
2826
|
-
return true;
|
|
2827
|
-
}
|
|
2828
2859
|
function printAuthMissingHelp(binName) {
|
|
2829
2860
|
if (isSiluzanAgentEnv()) {
|
|
2830
2861
|
console.error(
|
|
@@ -2940,7 +2971,7 @@ function parseMeResponse(text) {
|
|
|
2940
2971
|
async function fetchSiluzanCurrentUser(apiBase, config) {
|
|
2941
2972
|
const mainOrigin = deriveMainApiOrigin(apiBase);
|
|
2942
2973
|
const meUrl = `${mainOrigin.replace(/\/$/, "")}/query/account/me`;
|
|
2943
|
-
const authHeaders = config
|
|
2974
|
+
const authHeaders = buildSiluzanAuthHeaders(config);
|
|
2944
2975
|
try {
|
|
2945
2976
|
const res = await rawRequest(meUrl, {
|
|
2946
2977
|
method: "GET",
|
|
@@ -3771,8 +3802,11 @@ async function runUpdate(options) {
|
|
|
3771
3802
|
// src/utils/auth.ts
|
|
3772
3803
|
function loadConfig(tokenArg) {
|
|
3773
3804
|
const shared = readSharedConfig();
|
|
3774
|
-
const
|
|
3775
|
-
|
|
3805
|
+
const { authToken, apiKey } = resolveSiluzanCredentials({
|
|
3806
|
+
tokenArg,
|
|
3807
|
+
configApiKey: shared.apiKey,
|
|
3808
|
+
configAuthToken: shared.authToken
|
|
3809
|
+
});
|
|
3776
3810
|
if (!apiKey && !authToken) {
|
|
3777
3811
|
printAuthMissingHelp("siluzan-cso");
|
|
3778
3812
|
}
|
|
@@ -8125,10 +8159,13 @@ async function runRagList(options) {
|
|
|
8125
8159
|
import * as fs16 from "fs";
|
|
8126
8160
|
function cmdConfigShow() {
|
|
8127
8161
|
const shared = readSharedConfig();
|
|
8162
|
+
const { authToken: effectiveAuthToken, apiKey: effectiveApiKeyRaw } = resolveSiluzanCredentials({
|
|
8163
|
+
configApiKey: shared.apiKey,
|
|
8164
|
+
configAuthToken: shared.authToken
|
|
8165
|
+
});
|
|
8166
|
+
const effectiveApiKey = effectiveApiKeyRaw ?? "";
|
|
8128
8167
|
const envApiKey = process.env.SILUZAN_API_KEY;
|
|
8129
8168
|
const envAuthToken = process.env.SILUZAN_AUTH_TOKEN;
|
|
8130
|
-
const effectiveApiKey = envApiKey ?? shared.apiKey ?? "";
|
|
8131
|
-
const effectiveAuthToken = envAuthToken ?? shared.authToken ?? "";
|
|
8132
8169
|
if (!effectiveApiKey && !effectiveAuthToken) {
|
|
8133
8170
|
if (isSiluzanAgentEnv()) {
|
|
8134
8171
|
console.log(
|
|
@@ -8162,12 +8199,12 @@ function cmdConfigShow() {
|
|
|
8162
8199
|
console.log(` apiBaseUrl : ${apiBaseUrl}`);
|
|
8163
8200
|
console.log(` csoBaseUrl : ${csoBaseUrl}`);
|
|
8164
8201
|
if (effectiveApiKey) {
|
|
8165
|
-
const src = envApiKey ? "env:SILUZAN_API_KEY" : "config.json";
|
|
8202
|
+
const src = isSiluzanAgentEnv() ? "env:SILUZAN_API_KEY (agent)" : envApiKey ? "env:SILUZAN_API_KEY" : "config.json";
|
|
8166
8203
|
const active = " \u2190 \u5F53\u524D\u751F\u6548\uFF08X-Api-Key \u9274\u6743\uFF09";
|
|
8167
8204
|
console.log(` apiKey : ${maskSecret(effectiveApiKey)} [${src}]${active}`);
|
|
8168
8205
|
}
|
|
8169
8206
|
if (effectiveAuthToken) {
|
|
8170
|
-
const src = envAuthToken ? "env:SILUZAN_AUTH_TOKEN" : "config.json";
|
|
8207
|
+
const src = isSiluzanAgentEnv() ? "env:SILUZAN_AUTH_TOKEN (agent)" : envAuthToken ? "env:SILUZAN_AUTH_TOKEN" : "config.json";
|
|
8171
8208
|
const note = effectiveApiKey ? " \uFF08\u5DF2\u88AB apiKey \u8986\u76D6\uFF09" : " \u2190 \u5F53\u524D\u751F\u6548\uFF08Bearer \u9274\u6743\uFF09";
|
|
8172
8209
|
console.log(` authToken : ${maskSecret(effectiveAuthToken)} [${src}]${note}`);
|
|
8173
8210
|
}
|
package/dist/skill/_meta.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"slug": "siluzan-cso",
|
|
3
|
-
"version": "1.1.30-beta.
|
|
4
|
-
"publishedAt":
|
|
3
|
+
"version": "1.1.30-beta.3",
|
|
4
|
+
"publishedAt": 1782294306585,
|
|
5
5
|
"homepage": "https://www.siluzan.com",
|
|
6
6
|
"source": "https://dev.azure.com/jack4it/Sammamish/_git/siluzan-skill",
|
|
7
7
|
"requiredBinaries": [
|
|
@@ -9,7 +9,7 @@ $ErrorActionPreference = 'Stop'
|
|
|
9
9
|
# -- Package info (injected at build time) ------------------------------------
|
|
10
10
|
$PKG_NAME = 'siluzan-cso-cli'
|
|
11
11
|
# PKG_VERSION 锁定到与本脚本同批构建产物一致的版本,避免与 dist/skill 错位
|
|
12
|
-
$PKG_VERSION = '1.1.30-beta.
|
|
12
|
+
$PKG_VERSION = '1.1.30-beta.3'
|
|
13
13
|
$CLI_BIN = 'siluzan-cso'
|
|
14
14
|
$SKILL_LABEL = 'Siluzan CSO'
|
|
15
15
|
$INSTALL_CMD = 'npm install -g siluzan-cso-cli@beta'
|
|
@@ -9,7 +9,7 @@ set -euo pipefail
|
|
|
9
9
|
# -- Package info (injected at build time) ------------------------------------
|
|
10
10
|
readonly PKG_NAME="siluzan-cso-cli"
|
|
11
11
|
# PKG_VERSION 锁定到与本脚本同批构建产物一致的版本,避免与 dist/skill 错位
|
|
12
|
-
readonly PKG_VERSION="1.1.30-beta.
|
|
12
|
+
readonly PKG_VERSION="1.1.30-beta.3"
|
|
13
13
|
readonly CLI_BIN="siluzan-cso"
|
|
14
14
|
readonly SKILL_LABEL="Siluzan CSO"
|
|
15
15
|
readonly INSTALL_CMD="npm install -g siluzan-cso-cli@beta"
|
package/package.json
CHANGED