beautx-cli 1.0.3 → 1.0.6-beta.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/README.md +48 -23
- package/dist/{analyze-CvS_0J0V.mjs → analyze-Djk9ehcL.mjs} +6 -6
- package/dist/{api-DP-wIyTj.mjs → api-BxZ6RH9a.mjs} +2 -2
- package/dist/{audio-CQnCHawp.mjs → audio-CTEQazMK.mjs} +3 -3
- package/dist/beauty-plan-T6oPTu3Y.mjs +36 -0
- package/dist/cli.mjs +7633 -12
- package/dist/config-Bp7zHinN.mjs +15 -0
- package/dist/{consultant-BmIiugMd.mjs → consultant-B7GAFHWs.mjs} +2 -2
- package/dist/{content-MoNCpuQm.mjs → content-B4D6j0vv.mjs} +3 -3
- package/dist/{current-DGIpz0Sk.mjs → current-BeoE1SK9.mjs} +3 -3
- package/dist/{customer-BD3EmzUY.mjs → customer-DqDTvC1N.mjs} +1 -1
- package/dist/deal-analysis-CwUKL9Ji.mjs +36 -0
- package/dist/{doc-rGIvfEfq.mjs → doc-D6G4Z_rv.mjs} +3 -3
- package/dist/doctor-RwDPp4y3.mjs +37 -0
- package/dist/{fields-Cc9Ze0al.mjs → fields-DJeLpaGd.mjs} +4 -4
- package/dist/{focus-B_RkLsqS.mjs → focus-LvkCcszr.mjs} +1 -1
- package/dist/{get-8Rvtj3wi.mjs → get-BBOaM5KU.mjs} +3 -3
- package/dist/{kb-_CgUDi4w.mjs → kb-Bhd58evq.mjs} +2 -2
- package/dist/{list-CkyG8gwL.mjs → list-B5DASwyK.mjs} +2 -2
- package/dist/{list-BRu7_LmY.mjs → list-B5hx_XTf.mjs} +5 -5
- package/dist/{list-DJwNQ8BL.mjs → list-C7Vq9L7R.mjs} +5 -5
- package/dist/{list-BSjslG8l.mjs → list-CabGBbim.mjs} +7 -7
- package/dist/{list-D8XgqSh0.mjs → list-CuINauZ_.mjs} +5 -5
- package/dist/{list-C8wT5sUn.mjs → list-DIiYjEZk.mjs} +5 -5
- package/dist/{list-BZINoVqm.mjs → list-tnh01ZMo.mjs} +5 -5
- package/dist/{list-qd6lQm03.mjs → list-utR_LRZN.mjs} +6 -6
- package/dist/list-yupPP25S.mjs +83 -0
- package/dist/{mcp-args-CYOCdClW.mjs → mcp-args-Cop-Gaha.mjs} +1 -1
- package/dist/{mcp-client-DI6jZo4q.mjs → mcp-client-BadcKqv9.mjs} +37 -76
- package/dist/{mcp-result-Bn-A5DcX.mjs → mcp-result-CBq8FqvE.mjs} +2 -2
- package/dist/portrait-tags-DvTmM5jj.mjs +43 -0
- package/dist/{project-B2qABEpp.mjs → project-BnO3fpfa.mjs} +3 -3
- package/dist/project-access-BeRtEUkG.mjs +2 -0
- package/dist/{project-access-BQZU6NdE.mjs → project-access-fgfgvJTL.mjs} +20 -30
- package/dist/project-store-8Cl4Sv5d.mjs +2 -0
- package/dist/project-store-CA7tRioX.mjs +424 -0
- package/dist/{qa-B57NEofR.mjs → qa-BY3EqJQm.mjs} +6 -6
- package/dist/{resistance-D_Y2Avxn.mjs → resistance-DTXXWAm5.mjs} +1 -1
- package/dist/{search-86OGS0Ym.mjs → search-B9MphR3s.mjs} +6 -6
- package/dist/{summary-B9x_AfxV.mjs → summary-C3ll-30H.mjs} +5 -5
- package/dist/{text-ACba5WuP.mjs → text--mtegj9C.mjs} +5 -5
- package/dist/{use-BAIQrxt7.mjs → use-xg62A9ri.mjs} +8 -6
- package/dist/{util-rFGZMvr6.mjs → util-Bko-nm_R.mjs} +5 -2
- package/dist/visit-evaluate-C23CuEiJ.mjs +30 -0
- package/dist/{visit-D5kebBRY.mjs → visit-l8rrEEtj.mjs} +2 -2
- package/dist/visit-query-args-CZogADi5.mjs +65 -0
- package/package.json +1 -1
- package/dist/config-BGrzWFQ8.mjs +0 -14
- package/dist/env-callback-CFDEremx.mjs +0 -349
- package/dist/env-vars-CXEHR_mk.mjs +0 -231
- package/dist/format-BNVLMAn6.mjs +0 -7253
- package/dist/list-RRLvFnug.mjs +0 -64
- package/dist/project-store-C_ufXzPf.mjs +0 -55
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
//#region src/core/config-errors.ts
|
|
2
|
-
/**
|
|
3
|
-
* Structured config errors for agent-facing hints.
|
|
4
|
-
*/
|
|
5
|
-
var MissingGatewayError = class extends Error {
|
|
6
|
-
code = "MISSING_GATEWAY";
|
|
7
|
-
hint = "由 Host 设置 ENV=test(或 prod),CLI 将使用内置网关地址";
|
|
8
|
-
constructor() {
|
|
9
|
-
super("缺少 MCP 网关地址");
|
|
10
|
-
this.name = "MissingGatewayError";
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
var MissingAccessTokenError = class extends Error {
|
|
14
|
-
code = "MISSING_ACCESS_TOKEN";
|
|
15
|
-
hint = "由 Host 在沙箱启动或 QA 开始时注入 MCP_TOKEN";
|
|
16
|
-
constructor() {
|
|
17
|
-
super("缺少 MCP access token");
|
|
18
|
-
this.name = "MissingAccessTokenError";
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var MissingRefreshTokenError = class extends Error {
|
|
22
|
-
code = "MISSING_REFRESH_TOKEN";
|
|
23
|
-
hint = "由 Host 在沙箱启动或 QA 开始时注入 REFRESH_TOKEN";
|
|
24
|
-
constructor() {
|
|
25
|
-
super("缺少 refresh_token");
|
|
26
|
-
this.name = "MissingRefreshTokenError";
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var AccessTokenExpiredError = class extends Error {
|
|
30
|
-
code = "ACCESS_TOKEN_EXPIRED";
|
|
31
|
-
hint = "由 Host 重新换票注入 MCP_TOKEN / REFRESH_TOKEN,或确保 REFRESH_TOKEN 可续期";
|
|
32
|
-
constructor() {
|
|
33
|
-
super("MCP access token 已过期");
|
|
34
|
-
this.name = "AccessTokenExpiredError";
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var RefreshFailedError = class extends Error {
|
|
38
|
-
code = "REFRESH_FAILED";
|
|
39
|
-
hint = "由 Host 重新换票后更新 MCP_TOKEN 与 REFRESH_TOKEN";
|
|
40
|
-
constructor(detail) {
|
|
41
|
-
super(detail ?? "refresh_token 续期失败");
|
|
42
|
-
this.name = "RefreshFailedError";
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var EnvCallbackFailedError = class extends Error {
|
|
46
|
-
code = "ENV_CALLBACK_FAILED";
|
|
47
|
-
hint = "Host 回调写 env 失败,请检查 USER_ID、TENANT_ID 与沙箱回调服务是否可用";
|
|
48
|
-
status;
|
|
49
|
-
upstreamCode;
|
|
50
|
-
details;
|
|
51
|
-
constructor(message, options) {
|
|
52
|
-
super(message);
|
|
53
|
-
this.name = "EnvCallbackFailedError";
|
|
54
|
-
this.status = options?.status;
|
|
55
|
-
this.upstreamCode = options?.upstreamCode;
|
|
56
|
-
this.details = options?.details;
|
|
57
|
-
if (options?.hint) this.hint = options.hint;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var ConfigInvalidError = class extends Error {
|
|
61
|
-
code = "CONFIG_INVALID";
|
|
62
|
-
hint;
|
|
63
|
-
constructor(message, hint) {
|
|
64
|
-
super(message);
|
|
65
|
-
this.name = "ConfigInvalidError";
|
|
66
|
-
this.hint = hint;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/core/endpoints.ts
|
|
71
|
-
/** Fallback when Host has not injected ENV (local dev via env.sh only). */
|
|
72
|
-
const DEFAULT_ENV = "test";
|
|
73
|
-
/** ENV value → MCP gateway / auth / Host callback base URLs. */
|
|
74
|
-
const PROFILES = {
|
|
75
|
-
test: {
|
|
76
|
-
gatewayUrl: "https://mcp.test.wangxiaobao.com",
|
|
77
|
-
authUrl: "https://mcp-auth.test.wangxiaobao.com",
|
|
78
|
-
callbackBaseUrl: "https://wangke.test.wangxiaobao.com"
|
|
79
|
-
},
|
|
80
|
-
prod: {
|
|
81
|
-
gatewayUrl: `https://mcp.wangxiaobao.com`,
|
|
82
|
-
authUrl: `https://mcp-auth.wangxiaobao.com`,
|
|
83
|
-
callbackBaseUrl: `https://wangke.wangxiaobao.com`
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
function isProfileUrlConfigured(url) {
|
|
87
|
-
return url.startsWith("https://");
|
|
88
|
-
}
|
|
89
|
-
function parseEnvName(raw) {
|
|
90
|
-
if (raw === "test" || raw === "prod") return raw;
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/core/config-store.ts
|
|
95
|
-
/**
|
|
96
|
-
* Shared config helpers (env-only mode; no file persistence).
|
|
97
|
-
*/
|
|
98
|
-
/** Decode JWT exp (seconds) → ms; returns null if not a JWT or no exp. */
|
|
99
|
-
function jwtExpMs(token) {
|
|
100
|
-
const parts = token.split(".");
|
|
101
|
-
if (parts.length < 2) return null;
|
|
102
|
-
try {
|
|
103
|
-
const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, "+").replace(/_/g, "/"), "base64url").toString("utf8"));
|
|
104
|
-
if (typeof payload.exp === "number") return payload.exp * 1e3;
|
|
105
|
-
} catch {}
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/core/env-vars.ts
|
|
110
|
-
/**
|
|
111
|
-
* Environment-variable backed CLI state (sandbox single source of truth).
|
|
112
|
-
*/
|
|
113
|
-
const ENV_KEYS = {
|
|
114
|
-
ESTATE_ID: "ESTATE_ID",
|
|
115
|
-
ESTATE_NAME: "ESTATE_NAME",
|
|
116
|
-
TENANT_ID: "TENANT_ID",
|
|
117
|
-
TENANT_NAME: "TENANT_NAME",
|
|
118
|
-
USER_ID: "USER_ID",
|
|
119
|
-
USER_NAME: "USER_NAME",
|
|
120
|
-
MCP_TOKEN: "MCP_TOKEN",
|
|
121
|
-
REFRESH_TOKEN: "REFRESH_TOKEN",
|
|
122
|
-
EXPIRES_TIMES: "EXPIRES_TIMES",
|
|
123
|
-
XB_APP_ID: "XB_APP_ID",
|
|
124
|
-
ENV: "ENV"
|
|
125
|
-
};
|
|
126
|
-
/** Refresh when remaining lifetime is below this threshold (ms). */
|
|
127
|
-
const REFRESH_BUFFER_MS = 12e4;
|
|
128
|
-
function readEnv(key) {
|
|
129
|
-
return process.env[key]?.trim() ?? "";
|
|
130
|
-
}
|
|
131
|
-
function syncProcessEnv(pairs) {
|
|
132
|
-
for (const [key, value] of Object.entries(pairs)) process.env[key] = value;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Resolve deployment env from Host-injected `ENV`.
|
|
136
|
-
* Missing ENV falls back to DEFAULT_ENV (local shell only); invalid values error out.
|
|
137
|
-
*/
|
|
138
|
-
function resolveDeploymentEnv() {
|
|
139
|
-
const raw = readEnv(ENV_KEYS.ENV);
|
|
140
|
-
if (!raw) return DEFAULT_ENV;
|
|
141
|
-
const parsed = parseEnvName(raw);
|
|
142
|
-
if (!parsed) throw new ConfigInvalidError(`无效 ENV: ${raw}`, "由 Host 注入 ENV=test 或 ENV=prod");
|
|
143
|
-
return parsed;
|
|
144
|
-
}
|
|
145
|
-
/** Whether Host injected ENV (vs CLI local default). */
|
|
146
|
-
function isEnvInjectedByHost() {
|
|
147
|
-
return Boolean(readEnv(ENV_KEYS.ENV));
|
|
148
|
-
}
|
|
149
|
-
function resolveEndpoints() {
|
|
150
|
-
const env = resolveDeploymentEnv();
|
|
151
|
-
const profile = PROFILES[env];
|
|
152
|
-
return {
|
|
153
|
-
env,
|
|
154
|
-
gatewayUrl: profile.gatewayUrl,
|
|
155
|
-
authUrl: profile.authUrl,
|
|
156
|
-
callbackBaseUrl: profile.callbackBaseUrl
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function assertEndpointsValid(endpoints) {
|
|
160
|
-
if (!isProfileUrlConfigured(endpoints.gatewayUrl)) throw new ConfigInvalidError(`环境 ${endpoints.env} 的网关 URL 尚未配置`, "由 Host 设置 ENV=test,或待 prod 域名就绪后设置 ENV=prod");
|
|
161
|
-
if (!isProfileUrlConfigured(endpoints.callbackBaseUrl)) throw new ConfigInvalidError(`环境 ${endpoints.env} 的回调 URL 尚未配置`, "由 Host 设置 ENV=test,或待 prod 域名就绪后设置 ENV=prod");
|
|
162
|
-
}
|
|
163
|
-
function requireUserId() {
|
|
164
|
-
const userId = readEnv(ENV_KEYS.USER_ID);
|
|
165
|
-
if (!userId) throw new ConfigInvalidError("缺少 USER_ID 环境变量", "由 Host 在沙箱启动或 QA 开始时注入 USER_ID");
|
|
166
|
-
return userId;
|
|
167
|
-
}
|
|
168
|
-
function readActiveProject() {
|
|
169
|
-
const projectId = readEnv(ENV_KEYS.ESTATE_ID);
|
|
170
|
-
if (!projectId) return null;
|
|
171
|
-
return {
|
|
172
|
-
tenantId: readEnv(ENV_KEYS.TENANT_ID),
|
|
173
|
-
tenantName: readEnv(ENV_KEYS.TENANT_NAME),
|
|
174
|
-
projectId,
|
|
175
|
-
projectName: readEnv(ENV_KEYS.ESTATE_NAME),
|
|
176
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
177
|
-
source: "env"
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
function readCredentials() {
|
|
181
|
-
const accessToken = readEnv(ENV_KEYS.MCP_TOKEN) || null;
|
|
182
|
-
const refreshToken = readEnv(ENV_KEYS.REFRESH_TOKEN) || null;
|
|
183
|
-
const expiresRaw = readEnv(ENV_KEYS.EXPIRES_TIMES);
|
|
184
|
-
let expiresAt = null;
|
|
185
|
-
if (expiresRaw) {
|
|
186
|
-
const parsed = Number(expiresRaw);
|
|
187
|
-
if (!Number.isNaN(parsed) && parsed > 0) expiresAt = parsed;
|
|
188
|
-
}
|
|
189
|
-
if (expiresAt == null && accessToken) expiresAt = jwtExpMs(accessToken);
|
|
190
|
-
return {
|
|
191
|
-
accessToken,
|
|
192
|
-
refreshToken,
|
|
193
|
-
expiresAt
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function credentialStatus(creds) {
|
|
197
|
-
if (!creds.accessToken) return {
|
|
198
|
-
configured: false,
|
|
199
|
-
status: "missing",
|
|
200
|
-
expiresAt: null,
|
|
201
|
-
expiresInSec: null
|
|
202
|
-
};
|
|
203
|
-
return buildExpiryView(creds, computeExpiryStatus(creds.expiresAt));
|
|
204
|
-
}
|
|
205
|
-
function buildExpiryView(creds, status) {
|
|
206
|
-
const expiresAt = creds.expiresAt;
|
|
207
|
-
const expiresInSec = expiresAt != null ? Math.max(0, Math.floor((expiresAt - Date.now()) / 1e3)) : null;
|
|
208
|
-
return {
|
|
209
|
-
configured: true,
|
|
210
|
-
status,
|
|
211
|
-
expiresAt: expiresAt ?? null,
|
|
212
|
-
expiresInSec
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function computeExpiryStatus(expiresAt) {
|
|
216
|
-
if (expiresAt == null) return "valid";
|
|
217
|
-
const remaining = expiresAt - Date.now();
|
|
218
|
-
if (remaining <= 0) return "expired";
|
|
219
|
-
if (remaining < 12e4) return "expiring";
|
|
220
|
-
return "valid";
|
|
221
|
-
}
|
|
222
|
-
function needsRefresh(expiresAt, force = false) {
|
|
223
|
-
if (force) return true;
|
|
224
|
-
if (expiresAt == null) return false;
|
|
225
|
-
return expiresAt - Date.now() < REFRESH_BUFFER_MS;
|
|
226
|
-
}
|
|
227
|
-
function isTokenExpired(expiresAt) {
|
|
228
|
-
return expiresAt != null && expiresAt <= Date.now();
|
|
229
|
-
}
|
|
230
|
-
//#endregion
|
|
231
|
-
export { MissingGatewayError as _, isTokenExpired as a, readCredentials as c, resolveEndpoints as d, syncProcessEnv as f, MissingAccessTokenError as g, EnvCallbackFailedError as h, isEnvInjectedByHost as i, readEnv as l, ConfigInvalidError as m, assertEndpointsValid as n, needsRefresh as o, AccessTokenExpiredError as p, credentialStatus as r, readActiveProject as s, ENV_KEYS as t, requireUserId as u, MissingRefreshTokenError as v, RefreshFailedError as y };
|