beautx-cli 1.0.9-beta.1 → 1.1.1-beta.2
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 +40 -26
- package/dist/{analyze-CtxR02Xr.mjs → analyze-Cq-Hmoqp.mjs} +5 -5
- package/dist/{api-BdaZkABF.mjs → api-jIGM86TK.mjs} +1 -1
- package/dist/{audio-DlgPatwd.mjs → audio-p2QCYFdq.mjs} +3 -3
- package/dist/beauty-plan-D9B8kaf-.mjs +51 -0
- package/dist/beauty-plan-reminder-D-gVCeWO.mjs +79 -0
- package/dist/capability-profile-DxrzExct.mjs +61 -0
- package/dist/cli.mjs +21 -19
- package/dist/{config-DICowNg_.mjs → config-V1amf6sh.mjs} +2 -2
- package/dist/{consultant-Det5PdFh.mjs → consultant-DZeIOYgS.mjs} +1 -1
- package/dist/{content-BOTX5RjP.mjs → content-CfzyDYSy.mjs} +2 -2
- package/dist/{current-aBOk-h5x.mjs → current-xqaZxhbN.mjs} +1 -1
- package/dist/{customer-Dr_mISml.mjs → customer-iWrGhESH.mjs} +1 -1
- package/dist/{deal-analysis-K0jAibrc.mjs → deal-analysis-Da8iNy64.mjs} +3 -3
- package/dist/detail-BnUTSlRa.mjs +44 -0
- package/dist/{doc-BuvQ5-m4.mjs → doc-_TnZLbtD.mjs} +3 -3
- package/dist/{fields-CiWGp1Uy.mjs → fields-F00auxKR.mjs} +3 -3
- package/dist/{focus-c7Sx7x3t.mjs → focus-DlptSJrZ.mjs} +1 -1
- package/dist/{get-ByeAOvme.mjs → get-BDXbs-_c.mjs} +2 -2
- package/dist/get-ByAQXto5.mjs +40 -0
- package/dist/golden-sentence-CwT4AyLu.mjs +11 -0
- package/dist/{kb-DsyLK84W.mjs → kb-CBj6tJE9.mjs} +2 -2
- package/dist/{list-CGDMjHuN.mjs → list-BGjT1Ovk.mjs} +14 -4
- package/dist/{list-Cq9rAt2i.mjs → list-Boz4Dr1p.mjs} +4 -4
- package/dist/{list-u0XN5Mv3.mjs → list-CB-bwmRO2.mjs} +4 -4
- package/dist/{list-DD5SDjF3.mjs → list-CQOLK3Xu.mjs} +4 -4
- package/dist/{list-D4gnORuG.mjs → list-CnsJlbrZ.mjs} +1 -1
- package/dist/{list-Bt87oTfo.mjs → list-Cnz5CuQB.mjs} +4 -4
- package/dist/{list-BPBUK6SR.mjs → list-D7_yNqIG.mjs} +1 -3
- package/dist/{list-CDhdZByU.mjs → list-DMFhAeTT.mjs} +4 -4
- package/dist/{list-BTsFZamG.mjs → list-DPVEnWni.mjs} +4 -4
- package/dist/{mcp-args-CG7OuBep.mjs → mcp-args-DK3IGaO1.mjs} +1 -1
- package/dist/{mcp-client-huLKHRT3.mjs → mcp-client-BTZH22b5.mjs} +3 -3
- package/dist/{mcp-result-BzDGJUdM.mjs → mcp-result-De_0PPlD.mjs} +1 -1
- package/dist/panke-DmzQyQHt.mjs +14 -0
- package/dist/{portrait-tags-DDfhu52n.mjs → portrait-tags-c7OW_KzT.mjs} +3 -3
- package/dist/{project-CFjWR38i.mjs → project-DeLeVoA3.mjs} +3 -3
- package/dist/project-access-Bf87OLJP.mjs +2 -0
- package/dist/{project-access-ChmJv4Z4.mjs → project-access-pTN7ry15.mjs} +2 -3
- package/dist/project-store-DDVZ7T4t.mjs +2 -0
- package/dist/{project-store-DUlIIW51.mjs → project-store-Dl35JzZr.mjs} +207 -2
- package/dist/{qa-BvSY8aGf.mjs → qa-DIZmvMwE.mjs} +5 -5
- package/dist/{resistance-BsDf3Ywa.mjs → resistance-CC4cxxUk.mjs} +1 -1
- package/dist/{search-Chnn4fM0.mjs → search-eIzMHyPL.mjs} +5 -5
- package/dist/staff-BVu2Hmu1.mjs +11 -0
- package/dist/{summary-BBOsN5T9.mjs → summary-CYLljvrY.mjs} +4 -4
- package/dist/task-Fa1R-6DI.mjs +40 -0
- package/dist/{text-CCxnry4V.mjs → text-BIIl7PmC.mjs} +4 -4
- package/dist/{use-DAcv-VQ0.mjs → use-DIjJeiXP.mjs} +2 -2
- package/dist/{visit-B70PkDSX.mjs → visit-D-HS1jjx.mjs} +2 -2
- package/dist/{visit-evaluate-CaO2KvPG.mjs → visit-evaluate-COKpVvhv.mjs} +3 -3
- package/dist/{visit-query-args-DW3qNnoL.mjs → visit-query-args-BsfU3CUz.mjs} +2 -2
- package/package.json +1 -1
- package/dist/beauty-plan-DNsCkUJY.mjs +0 -36
- package/dist/env-vars-osVxvm7z.mjs +0 -212
- package/dist/install-DQmxrW3j.mjs +0 -50
- package/dist/list-SIx70dm2.mjs +0 -77
- package/dist/project-access-D4b4oc5E.mjs +0 -2
- package/dist/project-store-DlbRmRAS.mjs +0 -2
- package/dist/skill-7jpFz8M3.mjs +0 -15
- package/dist/skill-client-DEbjlHcX.mjs +0 -146
- package/dist/upload-BSwTTmow.mjs +0 -76
- /package/dist/{util-BtgWHKWv.mjs → util-Bko-nm_R.mjs} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as formatCliArg } from "./cli.mjs";
|
|
2
|
-
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-
|
|
3
|
-
import { i as toLocalDateTime, n as mergeIds, t as csvToArray } from "./util-
|
|
2
|
+
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-DK3IGaO1.mjs";
|
|
3
|
+
import { i as toLocalDateTime, n as mergeIds, t as csvToArray } from "./util-Bko-nm_R.mjs";
|
|
4
4
|
//#region src/commands/common/visit-query-args.ts
|
|
5
5
|
const visitBatchQueryCliArgs = {
|
|
6
6
|
...projectIdCliArg,
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { c as requireActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
|
-
import { n as writeError } from "./cli.mjs";
|
|
3
|
-
import { t as mcpCallPage } from "./mcp-result-BzDGJUdM.mjs";
|
|
4
|
-
import { n as visitBatchQueryCliArgs, t as buildVisitBatchQueryArgs } from "./visit-query-args-DW3qNnoL.mjs";
|
|
5
|
-
import { defineCommand } from "citty";
|
|
6
|
-
//#region src/commands/beauty-plan/index.ts
|
|
7
|
-
/**
|
|
8
|
-
* `beautx-cli beauty-plan` — page beautx beauty plans via MCP gateway.
|
|
9
|
-
*/
|
|
10
|
-
var beauty_plan_default = defineCommand({
|
|
11
|
-
meta: {
|
|
12
|
-
name: "beauty-plan",
|
|
13
|
-
description: "医美变美计划分页查询"
|
|
14
|
-
},
|
|
15
|
-
args: {
|
|
16
|
-
...visitBatchQueryCliArgs,
|
|
17
|
-
"latest-only": {
|
|
18
|
-
type: "boolean",
|
|
19
|
-
description: "按客户查询时是否只返回最近一次;不传则使用后端默认 true"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
async run({ args }) {
|
|
23
|
-
try {
|
|
24
|
-
await mcpCallPage("beauty-plan", buildVisitBatchQueryArgs(args, await requireActiveProject(), { latest_only: args["latest-only"] }), args.format, {
|
|
25
|
-
itemsKey: "beautyPlans",
|
|
26
|
-
defaultPage: Number(args.page),
|
|
27
|
-
defaultSize: Number(args.size)
|
|
28
|
-
});
|
|
29
|
-
} catch (err) {
|
|
30
|
-
writeError(err, args.format);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
//#endregion
|
|
36
|
-
export { beauty_plan_default as default };
|
|
@@ -1,212 +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 = "向 /out/v2/mcp-token 借 AT 失败:确认沙箱已注入 SANDBOX_*_SECRET,且 PC/App 已完成 MCP 凭证初始化";
|
|
16
|
-
constructor() {
|
|
17
|
-
super("缺少 MCP access token");
|
|
18
|
-
this.name = "MissingAccessTokenError";
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var AccessTokenExpiredError = class extends Error {
|
|
22
|
-
code = "ACCESS_TOKEN_EXPIRED";
|
|
23
|
-
hint = "重新调用 CLI(会向 Token Broker 借新 AT),或先在 PC/App 登录刷新凭证仓";
|
|
24
|
-
constructor() {
|
|
25
|
-
super("MCP access token 已过期");
|
|
26
|
-
this.name = "AccessTokenExpiredError";
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var CurrentProjectFailedError = class extends Error {
|
|
30
|
-
code = "CURRENT_PROJECT_FAILED";
|
|
31
|
-
hint = "读写当前项目失败,请检查 TENANT_ID、USER_ID 与 /out/v2/current-project 服务是否可用";
|
|
32
|
-
status;
|
|
33
|
-
upstreamCode;
|
|
34
|
-
details;
|
|
35
|
-
constructor(message, options) {
|
|
36
|
-
super(message);
|
|
37
|
-
this.name = "CurrentProjectFailedError";
|
|
38
|
-
this.status = options?.status;
|
|
39
|
-
this.upstreamCode = options?.upstreamCode;
|
|
40
|
-
this.details = options?.details;
|
|
41
|
-
if (options?.hint) this.hint = options.hint;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
var ConfigInvalidError = class extends Error {
|
|
45
|
-
code = "CONFIG_INVALID";
|
|
46
|
-
hint;
|
|
47
|
-
constructor(message, hint) {
|
|
48
|
-
super(message);
|
|
49
|
-
this.name = "ConfigInvalidError";
|
|
50
|
-
this.hint = hint;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/core/endpoints.ts
|
|
55
|
-
/** Fallback when Host has not injected ENV (local dev via env.sh only). */
|
|
56
|
-
const DEFAULT_ENV = "test";
|
|
57
|
-
/** ENV value → MCP gateway / auth / Host callback / Skill BFF base URLs. */
|
|
58
|
-
const PROFILES = {
|
|
59
|
-
test: {
|
|
60
|
-
gatewayUrl: "https://mcp.test.wangxiaobao.com",
|
|
61
|
-
authUrl: "https://mcp-auth.test.wangxiaobao.com",
|
|
62
|
-
callbackBaseUrl: "https://wangke.test.wangxiaobao.com",
|
|
63
|
-
skillBffUrl: "https://wangke.test.wangxiaobao.com/api/wc-skill"
|
|
64
|
-
},
|
|
65
|
-
prod: {
|
|
66
|
-
gatewayUrl: `https://mcp.wangxiaobao.com`,
|
|
67
|
-
authUrl: `https://mcp-auth.wangxiaobao.com`,
|
|
68
|
-
callbackBaseUrl: `https://wangke.wangxiaobao.com`,
|
|
69
|
-
skillBffUrl: "https://wangke.wangxiaobao.com/api/wc-skill"
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
function isProfileUrlConfigured(url) {
|
|
73
|
-
return url.startsWith("https://");
|
|
74
|
-
}
|
|
75
|
-
function parseEnvName(raw) {
|
|
76
|
-
if (raw === "test" || raw === "prod") return raw;
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region src/core/config-store.ts
|
|
81
|
-
/**
|
|
82
|
-
* Shared config helpers (env-only mode; no file persistence).
|
|
83
|
-
*/
|
|
84
|
-
/** Decode JWT exp (seconds) → ms; returns null if not a JWT or no exp. */
|
|
85
|
-
function jwtExpMs(token) {
|
|
86
|
-
const parts = token.split(".");
|
|
87
|
-
if (parts.length < 2) return null;
|
|
88
|
-
try {
|
|
89
|
-
const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, "+").replace(/_/g, "/"), "base64url").toString("utf8"));
|
|
90
|
-
if (typeof payload.exp === "number") return payload.exp * 1e3;
|
|
91
|
-
} catch {}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/core/env-vars.ts
|
|
96
|
-
/**
|
|
97
|
-
* Environment-variable backed CLI state (sandbox single source of truth).
|
|
98
|
-
*/
|
|
99
|
-
const ENV_KEYS = {
|
|
100
|
-
ESTATE_ID: "ESTATE_ID",
|
|
101
|
-
ESTATE_NAME: "ESTATE_NAME",
|
|
102
|
-
TENANT_ID: "TENANT_ID",
|
|
103
|
-
TENANT_NAME: "TENANT_NAME",
|
|
104
|
-
USER_ID: "USER_ID",
|
|
105
|
-
USER_NAME: "USER_NAME",
|
|
106
|
-
MCP_TOKEN: "MCP_TOKEN",
|
|
107
|
-
REFRESH_TOKEN: "REFRESH_TOKEN",
|
|
108
|
-
EXPIRES_TIMES: "EXPIRES_TIMES",
|
|
109
|
-
SESSION_ID: "SESSION_ID",
|
|
110
|
-
XB_APP_ID: "XB_APP_ID",
|
|
111
|
-
ENV: "ENV",
|
|
112
|
-
/** 沙箱只读:创建模板时注入,用于 Token Broker 等敏感请求 */
|
|
113
|
-
SANDBOX_TENANT_SECRET: "SANDBOX_TENANT_SECRET",
|
|
114
|
-
/** 沙箱只读:创建用户时注入 */
|
|
115
|
-
SANDBOX_USER_SECRET: "SANDBOX_USER_SECRET"
|
|
116
|
-
};
|
|
117
|
-
/** Refresh when remaining lifetime is below this threshold (ms). */
|
|
118
|
-
const REFRESH_BUFFER_MS = 12e4;
|
|
119
|
-
function readEnv(key) {
|
|
120
|
-
return process.env[key]?.trim() ?? "";
|
|
121
|
-
}
|
|
122
|
-
function syncProcessEnv(pairs) {
|
|
123
|
-
for (const [key, value] of Object.entries(pairs)) process.env[key] = value;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Resolve deployment env from Host-injected `ENV`.
|
|
127
|
-
* Missing ENV falls back to DEFAULT_ENV (local shell only); invalid values error out.
|
|
128
|
-
*/
|
|
129
|
-
function resolveDeploymentEnv() {
|
|
130
|
-
const raw = readEnv(ENV_KEYS.ENV);
|
|
131
|
-
if (!raw) return DEFAULT_ENV;
|
|
132
|
-
const parsed = parseEnvName(raw);
|
|
133
|
-
if (!parsed) throw new ConfigInvalidError(`无效 ENV: ${raw}`, "由 Host 注入 ENV=test 或 ENV=prod");
|
|
134
|
-
return parsed;
|
|
135
|
-
}
|
|
136
|
-
/** Whether Host injected ENV (vs CLI local default). */
|
|
137
|
-
function isEnvInjectedByHost() {
|
|
138
|
-
return Boolean(readEnv(ENV_KEYS.ENV));
|
|
139
|
-
}
|
|
140
|
-
function resolveEndpoints() {
|
|
141
|
-
const env = resolveDeploymentEnv();
|
|
142
|
-
const profile = PROFILES[env];
|
|
143
|
-
const skillBffOverride = process.env.SKILL_BFF_URL?.trim();
|
|
144
|
-
return {
|
|
145
|
-
env,
|
|
146
|
-
gatewayUrl: profile.gatewayUrl,
|
|
147
|
-
authUrl: profile.authUrl,
|
|
148
|
-
callbackBaseUrl: profile.callbackBaseUrl,
|
|
149
|
-
skillBffUrl: skillBffOverride || profile.skillBffUrl
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function assertEndpointsValid(endpoints) {
|
|
153
|
-
if (!isProfileUrlConfigured(endpoints.gatewayUrl)) throw new ConfigInvalidError(`环境 ${endpoints.env} 的网关 URL 尚未配置`, "由 Host 设置 ENV=test,或待 prod 域名就绪后设置 ENV=prod");
|
|
154
|
-
if (!isProfileUrlConfigured(endpoints.callbackBaseUrl)) throw new ConfigInvalidError(`环境 ${endpoints.env} 的回调 URL 尚未配置`, "由 Host 设置 ENV=test,或待 prod 域名就绪后设置 ENV=prod");
|
|
155
|
-
}
|
|
156
|
-
function requireUserId() {
|
|
157
|
-
const userId = readEnv(ENV_KEYS.USER_ID);
|
|
158
|
-
if (!userId) throw new ConfigInvalidError("缺少 USER_ID 环境变量", "由 QCA 在沙箱启动时注入 USER_ID");
|
|
159
|
-
return userId;
|
|
160
|
-
}
|
|
161
|
-
function readCredentials() {
|
|
162
|
-
const accessToken = readEnv(ENV_KEYS.MCP_TOKEN) || null;
|
|
163
|
-
const refreshToken = readEnv(ENV_KEYS.REFRESH_TOKEN) || null;
|
|
164
|
-
const expiresRaw = readEnv(ENV_KEYS.EXPIRES_TIMES);
|
|
165
|
-
let expiresAt = null;
|
|
166
|
-
if (expiresRaw) {
|
|
167
|
-
const parsed = Number(expiresRaw);
|
|
168
|
-
if (!Number.isNaN(parsed) && parsed > 0) expiresAt = parsed;
|
|
169
|
-
}
|
|
170
|
-
if (expiresAt == null && accessToken) expiresAt = jwtExpMs(accessToken);
|
|
171
|
-
return {
|
|
172
|
-
accessToken,
|
|
173
|
-
refreshToken,
|
|
174
|
-
expiresAt
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function credentialStatus(creds) {
|
|
178
|
-
if (!creds.accessToken) return {
|
|
179
|
-
configured: false,
|
|
180
|
-
status: "missing",
|
|
181
|
-
expiresAt: null,
|
|
182
|
-
expiresInSec: null
|
|
183
|
-
};
|
|
184
|
-
return buildExpiryView(creds, computeExpiryStatus(creds.expiresAt));
|
|
185
|
-
}
|
|
186
|
-
function buildExpiryView(creds, status) {
|
|
187
|
-
const expiresAt = creds.expiresAt;
|
|
188
|
-
const expiresInSec = expiresAt != null ? Math.max(0, Math.floor((expiresAt - Date.now()) / 1e3)) : null;
|
|
189
|
-
return {
|
|
190
|
-
configured: true,
|
|
191
|
-
status,
|
|
192
|
-
expiresAt: expiresAt ?? null,
|
|
193
|
-
expiresInSec
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function computeExpiryStatus(expiresAt) {
|
|
197
|
-
if (expiresAt == null) return "valid";
|
|
198
|
-
const remaining = expiresAt - Date.now();
|
|
199
|
-
if (remaining <= 0) return "expired";
|
|
200
|
-
if (remaining < 12e4) return "expiring";
|
|
201
|
-
return "valid";
|
|
202
|
-
}
|
|
203
|
-
function needsRefresh(expiresAt, force = false) {
|
|
204
|
-
if (force) return true;
|
|
205
|
-
if (expiresAt == null) return false;
|
|
206
|
-
return expiresAt - Date.now() < REFRESH_BUFFER_MS;
|
|
207
|
-
}
|
|
208
|
-
function isTokenExpired(expiresAt) {
|
|
209
|
-
return expiresAt != null && expiresAt <= Date.now();
|
|
210
|
-
}
|
|
211
|
-
//#endregion
|
|
212
|
-
export { isTokenExpired as a, readEnv as c, syncProcessEnv as d, AccessTokenExpiredError as f, MissingGatewayError as g, MissingAccessTokenError as h, isEnvInjectedByHost as i, requireUserId as l, CurrentProjectFailedError as m, assertEndpointsValid as n, needsRefresh as o, ConfigInvalidError as p, credentialStatus as r, readCredentials as s, ENV_KEYS as t, resolveEndpoints as u };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { c as requireActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
|
-
import { n as writeError, r as writeResult, t as formatCliArg } from "./cli.mjs";
|
|
3
|
-
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-CG7OuBep.mjs";
|
|
4
|
-
import { i as skillInstallGrant, r as resolveSkillInstallDir, t as downloadSkillPackage } from "./skill-client-DEbjlHcX.mjs";
|
|
5
|
-
import { defineCommand } from "citty";
|
|
6
|
-
//#region src/commands/skill/install.ts
|
|
7
|
-
/**
|
|
8
|
-
* `beautx-cli skill install <id>` — download a Skill package by id.
|
|
9
|
-
*/
|
|
10
|
-
var install_default = defineCommand({
|
|
11
|
-
meta: {
|
|
12
|
-
name: "install",
|
|
13
|
-
description: "按 Skill ID 下载安装包(默认使用当前激活项目做权限判定)"
|
|
14
|
-
},
|
|
15
|
-
args: {
|
|
16
|
-
id: {
|
|
17
|
-
type: "positional",
|
|
18
|
-
description: "Skill 数字 ID",
|
|
19
|
-
required: true
|
|
20
|
-
},
|
|
21
|
-
dir: {
|
|
22
|
-
type: "string",
|
|
23
|
-
description: `安装根目录(默认 ${resolveSkillInstallDir()},可由 SKILL_INSTALL_DIR 覆盖)`
|
|
24
|
-
},
|
|
25
|
-
...projectIdCliArg,
|
|
26
|
-
format: formatCliArg
|
|
27
|
-
},
|
|
28
|
-
async run({ args }) {
|
|
29
|
-
try {
|
|
30
|
-
const active = await requireActiveProject();
|
|
31
|
-
const projectId = resolveProjectId(args["project-id"], active);
|
|
32
|
-
const grant = await skillInstallGrant(args.id, projectId);
|
|
33
|
-
const { skillDir, zipPath } = await downloadSkillPackage(grant, args.dir?.trim() || resolveSkillInstallDir());
|
|
34
|
-
writeResult({
|
|
35
|
-
skillId: grant.skillId,
|
|
36
|
-
name: grant.name,
|
|
37
|
-
version: grant.version,
|
|
38
|
-
checksum: grant.checksum,
|
|
39
|
-
skillDir,
|
|
40
|
-
zipPath,
|
|
41
|
-
projectId
|
|
42
|
-
}, args.format);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
writeError(err, args.format);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
//#endregion
|
|
50
|
-
export { install_default as default };
|
package/dist/list-SIx70dm2.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { c as requireActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
|
-
import { n as writeError, r as writeResult, t as formatCliArg } from "./cli.mjs";
|
|
3
|
-
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-CG7OuBep.mjs";
|
|
4
|
-
import { a as skillList } from "./skill-client-DEbjlHcX.mjs";
|
|
5
|
-
import { defineCommand } from "citty";
|
|
6
|
-
//#region src/commands/skill/list.ts
|
|
7
|
-
/**
|
|
8
|
-
* `beautx-cli skill list` — list the Skill BFF catalog.
|
|
9
|
-
*/
|
|
10
|
-
function groupByOwnerType(items) {
|
|
11
|
-
return {
|
|
12
|
-
personal: items.filter((item) => item.ownerType === "personal"),
|
|
13
|
-
tenant: items.filter((item) => item.ownerType === "tenant"),
|
|
14
|
-
project: items.filter((item) => item.ownerType === "project"),
|
|
15
|
-
other: items.filter((item) => item.ownerType !== "personal" && item.ownerType !== "tenant" && item.ownerType !== "project")
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
var list_default = defineCommand({
|
|
19
|
-
meta: {
|
|
20
|
-
name: "list",
|
|
21
|
-
description: "列出可见 Skill(按归属分组;默认使用当前激活项目过滤)"
|
|
22
|
-
},
|
|
23
|
-
args: {
|
|
24
|
-
type: {
|
|
25
|
-
type: "string",
|
|
26
|
-
description: "personal | tenant | project;省略时按三种归属分组输出"
|
|
27
|
-
},
|
|
28
|
-
...projectIdCliArg,
|
|
29
|
-
format: formatCliArg
|
|
30
|
-
},
|
|
31
|
-
async run({ args }) {
|
|
32
|
-
try {
|
|
33
|
-
const rawType = args.type?.trim().toLowerCase();
|
|
34
|
-
let type;
|
|
35
|
-
if (rawType === "personal" || rawType === "tenant" || rawType === "project") type = rawType;
|
|
36
|
-
else if (rawType) throw new Error("type 仅支持 personal | tenant | project");
|
|
37
|
-
const active = await requireActiveProject();
|
|
38
|
-
const projectId = resolveProjectId(args["project-id"], active);
|
|
39
|
-
const items = await skillList(type, projectId);
|
|
40
|
-
if (type) {
|
|
41
|
-
writeResult({
|
|
42
|
-
items,
|
|
43
|
-
total: items.length,
|
|
44
|
-
type,
|
|
45
|
-
projectId
|
|
46
|
-
}, args.format);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const grouped = groupByOwnerType(items);
|
|
50
|
-
writeResult({
|
|
51
|
-
projectId,
|
|
52
|
-
personal: {
|
|
53
|
-
items: grouped.personal,
|
|
54
|
-
total: grouped.personal.length
|
|
55
|
-
},
|
|
56
|
-
tenant: {
|
|
57
|
-
items: grouped.tenant,
|
|
58
|
-
total: grouped.tenant.length
|
|
59
|
-
},
|
|
60
|
-
project: {
|
|
61
|
-
items: grouped.project,
|
|
62
|
-
total: grouped.project.length
|
|
63
|
-
},
|
|
64
|
-
...grouped.other.length ? { other: {
|
|
65
|
-
items: grouped.other,
|
|
66
|
-
total: grouped.other.length
|
|
67
|
-
} } : {},
|
|
68
|
-
total: items.length
|
|
69
|
-
}, args.format);
|
|
70
|
-
} catch (err) {
|
|
71
|
-
writeError(err, args.format);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
//#endregion
|
|
77
|
-
export { list_default as default };
|
package/dist/skill-7jpFz8M3.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
//#region src/commands/skill/index.ts
|
|
3
|
-
var skill_default = defineCommand({
|
|
4
|
-
meta: {
|
|
5
|
-
name: "skill",
|
|
6
|
-
description: "Skill 中心:列表 / 安装 / 上传(REST,沙箱双凭证)"
|
|
7
|
-
},
|
|
8
|
-
subCommands: {
|
|
9
|
-
list: () => import("./list-SIx70dm2.mjs").then((m) => m.default),
|
|
10
|
-
install: () => import("./install-DQmxrW3j.mjs").then((m) => m.default),
|
|
11
|
-
upload: () => import("./upload-BSwTTmow.mjs").then((m) => m.default)
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
//#endregion
|
|
15
|
-
export { skill_default as default };
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { l as requireUserId, u as resolveEndpoints } from "./env-vars-osVxvm7z.mjs";
|
|
2
|
-
import { d as buildSandboxProof, f as requireSandboxSecrets, p as requireTenantId, u as WANGCLAW_AUTH_HEADER } from "./cli.mjs";
|
|
3
|
-
import { createWriteStream } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { createHash } from "node:crypto";
|
|
6
|
-
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
|
-
import { Readable } from "node:stream";
|
|
8
|
-
import { pipeline } from "node:stream/promises";
|
|
9
|
-
//#region src/core/skill-client.ts
|
|
10
|
-
/**
|
|
11
|
-
* Skill BFF REST client.
|
|
12
|
-
*
|
|
13
|
-
* Requests use the Host-injected tenant/user ids and sandbox dual-secret proof.
|
|
14
|
-
* The proof is intentionally sent through X-Wangclaw-Authorization rather than
|
|
15
|
-
* Authorization so the gateway does not treat it as an OAuth JWT.
|
|
16
|
-
*/
|
|
17
|
-
const SUCCESS_CODE = "0";
|
|
18
|
-
function resolveSkillInstallDir() {
|
|
19
|
-
return process.env.SKILL_INSTALL_DIR?.trim() || "/home/wuying/jvscrew/.wangai-cli/skills";
|
|
20
|
-
}
|
|
21
|
-
function authContext() {
|
|
22
|
-
const tenantId = requireTenantId();
|
|
23
|
-
const userId = requireUserId();
|
|
24
|
-
const { tenantSecret, userSecret } = requireSandboxSecrets();
|
|
25
|
-
return {
|
|
26
|
-
tenantId,
|
|
27
|
-
userId,
|
|
28
|
-
proof: buildSandboxProof(tenantSecret, userSecret)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function buildUrl(path, tenantId, userId, extraQuery) {
|
|
32
|
-
const base = resolveEndpoints().skillBffUrl.replace(/\/$/, "");
|
|
33
|
-
const url = new URL(path, `${base}/`);
|
|
34
|
-
url.searchParams.set("tenantId", tenantId);
|
|
35
|
-
url.searchParams.set("userId", userId);
|
|
36
|
-
for (const [key, value] of Object.entries(extraQuery ?? {})) if (value != null && value !== "") url.searchParams.set(key, value);
|
|
37
|
-
return url;
|
|
38
|
-
}
|
|
39
|
-
async function skillFetch(method, path, options) {
|
|
40
|
-
const { tenantId, userId, proof } = authContext();
|
|
41
|
-
const url = buildUrl(path, tenantId, userId, options?.query);
|
|
42
|
-
const headers = {
|
|
43
|
-
Accept: "application/json",
|
|
44
|
-
[WANGCLAW_AUTH_HEADER]: proof
|
|
45
|
-
};
|
|
46
|
-
let body;
|
|
47
|
-
if (options?.body !== void 0) {
|
|
48
|
-
headers["Content-Type"] = "application/json";
|
|
49
|
-
body = JSON.stringify(options.body);
|
|
50
|
-
}
|
|
51
|
-
const response = await fetch(url, {
|
|
52
|
-
method,
|
|
53
|
-
headers,
|
|
54
|
-
body,
|
|
55
|
-
signal: AbortSignal.timeout(15e3)
|
|
56
|
-
});
|
|
57
|
-
const text = await response.text();
|
|
58
|
-
let envelope;
|
|
59
|
-
try {
|
|
60
|
-
envelope = JSON.parse(text);
|
|
61
|
-
} catch {
|
|
62
|
-
throw new Error(`skill-bff 返回非 JSON(HTTP ${response.status}): ${text.slice(0, 200)}`);
|
|
63
|
-
}
|
|
64
|
-
if (!response.ok || String(envelope.code) !== SUCCESS_CODE) {
|
|
65
|
-
const message = envelope.msg || envelope.error || text.slice(0, 200);
|
|
66
|
-
throw new Error(`skill-bff ${method} ${path} 失败: [${envelope.code ?? response.status}] ${message}`);
|
|
67
|
-
}
|
|
68
|
-
return envelope.data;
|
|
69
|
-
}
|
|
70
|
-
async function skillList(type, projectId) {
|
|
71
|
-
const normalizedProjectId = projectId?.trim();
|
|
72
|
-
if ((type === "tenant" || type === "project" || !type) && !normalizedProjectId) throw new Error(type ? `skill list --type ${type} 需要 projectId(可传 --project-id,或先 project use)` : "skill list 需要 projectId(可传 --project-id,或先 project use)");
|
|
73
|
-
return await skillFetch("GET", "out/skills", { query: {
|
|
74
|
-
type,
|
|
75
|
-
projectId: normalizedProjectId
|
|
76
|
-
} }) ?? [];
|
|
77
|
-
}
|
|
78
|
-
async function skillInstallGrant(skillId, projectId) {
|
|
79
|
-
const id = String(skillId).trim();
|
|
80
|
-
if (!/^\d+$/.test(id)) throw new Error("skill install 仅支持数字 ID");
|
|
81
|
-
const normalizedProjectId = projectId?.trim();
|
|
82
|
-
if (!normalizedProjectId) throw new Error("skill install 需要 projectId(可传 --project-id,或先 project use)");
|
|
83
|
-
return skillFetch("GET", `out/skills/${encodeURIComponent(id)}/package`, { query: { projectId: normalizedProjectId } });
|
|
84
|
-
}
|
|
85
|
-
async function skillUploadInitiate(input) {
|
|
86
|
-
const ownerType = (input?.ownerType?.trim() || "personal").toLowerCase();
|
|
87
|
-
if (ownerType !== "personal" && ownerType !== "tenant" && ownerType !== "project") throw new Error("ownerType 仅支持 personal | tenant | project");
|
|
88
|
-
const projectId = input?.projectId?.trim();
|
|
89
|
-
if (ownerType === "project" && !projectId) throw new Error("ownerType=project 需要 projectId");
|
|
90
|
-
const payload = {
|
|
91
|
-
ownerType,
|
|
92
|
-
projectId
|
|
93
|
-
};
|
|
94
|
-
if (input?.skillId != null && String(input.skillId).trim() !== "") payload.skillId = String(input.skillId).trim();
|
|
95
|
-
return skillFetch("POST", "out/skills/uploads/initiate", { body: payload });
|
|
96
|
-
}
|
|
97
|
-
async function skillUploadConfirm(input) {
|
|
98
|
-
return skillFetch("POST", "out/skills/uploads/confirm", { body: input });
|
|
99
|
-
}
|
|
100
|
-
/** Upload a zip to the presigned object-storage URL returned by initiate. */
|
|
101
|
-
async function putSkillZip(uploadUrl, zipBytes, uploadHeaders) {
|
|
102
|
-
const response = await fetch(uploadUrl, {
|
|
103
|
-
method: "PUT",
|
|
104
|
-
headers: {
|
|
105
|
-
"Content-Type": "application/zip",
|
|
106
|
-
...uploadHeaders ?? {}
|
|
107
|
-
},
|
|
108
|
-
body: zipBytes,
|
|
109
|
-
signal: AbortSignal.timeout(6e4)
|
|
110
|
-
});
|
|
111
|
-
if (!response.ok) {
|
|
112
|
-
const text = await response.text().catch(() => "");
|
|
113
|
-
throw new Error(`OSS PUT 失败(HTTP ${response.status}): ${text.slice(0, 200) || response.statusText}`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async function downloadSkillPackage(grant, installDir = resolveSkillInstallDir()) {
|
|
117
|
-
const skillId = String(grant.skillId).trim();
|
|
118
|
-
if (!/^\d+$/.test(skillId)) throw new Error("skill-bff 返回了无效的 Skill ID");
|
|
119
|
-
const skillDir = join(installDir, skillId);
|
|
120
|
-
await mkdir(skillDir, { recursive: true });
|
|
121
|
-
const zipPath = join(skillDir, "package.zip");
|
|
122
|
-
const response = await fetch(grant.downloadUrl, { signal: AbortSignal.timeout(6e4) });
|
|
123
|
-
if (!response.ok || !response.body) throw new Error(`下载 Skill 包失败(HTTP ${response.status})`);
|
|
124
|
-
await pipeline(Readable.fromWeb(response.body), createWriteStream(zipPath));
|
|
125
|
-
if (grant.checksum) {
|
|
126
|
-
const bytes = await readFile(zipPath);
|
|
127
|
-
const actual = createHash("sha256").update(bytes).digest("hex");
|
|
128
|
-
if (actual.toLowerCase() !== grant.checksum.toLowerCase()) {
|
|
129
|
-
await rm(zipPath, { force: true });
|
|
130
|
-
throw new Error(`checksum 不匹配: expected ${grant.checksum}, got ${actual}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
await writeFile(join(skillDir, "meta.json"), JSON.stringify({
|
|
134
|
-
skillId,
|
|
135
|
-
name: grant.name,
|
|
136
|
-
version: grant.version,
|
|
137
|
-
checksum: grant.checksum,
|
|
138
|
-
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
139
|
-
}, null, 2));
|
|
140
|
-
return {
|
|
141
|
-
skillDir,
|
|
142
|
-
zipPath
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
export { skillList as a, skillInstallGrant as i, putSkillZip as n, skillUploadConfirm as o, resolveSkillInstallDir as r, skillUploadInitiate as s, downloadSkillPackage as t };
|
package/dist/upload-BSwTTmow.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { n as writeError, r as writeResult, t as formatCliArg } from "./cli.mjs";
|
|
2
|
-
import { n as putSkillZip, o as skillUploadConfirm, s as skillUploadInitiate } from "./skill-client-DEbjlHcX.mjs";
|
|
3
|
-
import { defineCommand } from "citty";
|
|
4
|
-
import { readFile } from "node:fs/promises";
|
|
5
|
-
//#region src/commands/skill/upload.ts
|
|
6
|
-
/**
|
|
7
|
-
* `beautx-cli skill upload <zip>` — initiate, upload to OSS, then confirm.
|
|
8
|
-
*/
|
|
9
|
-
var upload_default = defineCommand({
|
|
10
|
-
meta: {
|
|
11
|
-
name: "upload",
|
|
12
|
-
description: "上传本地 Skill zip(initiate → PUT → confirm)"
|
|
13
|
-
},
|
|
14
|
-
args: {
|
|
15
|
-
path: {
|
|
16
|
-
type: "positional",
|
|
17
|
-
description: "本地 .zip 路径(压缩包内需包含 SKILL.md)",
|
|
18
|
-
required: true
|
|
19
|
-
},
|
|
20
|
-
type: {
|
|
21
|
-
type: "string",
|
|
22
|
-
description: "personal(默认)| tenant | project",
|
|
23
|
-
default: "personal"
|
|
24
|
-
},
|
|
25
|
-
"project-id": {
|
|
26
|
-
type: "string",
|
|
27
|
-
description: "项目 ID;type=project 时必填,type=tenant 时可选"
|
|
28
|
-
},
|
|
29
|
-
"skill-id": {
|
|
30
|
-
type: "string",
|
|
31
|
-
description: "已有 Skill ID;传入时替换现有包,省略时新建"
|
|
32
|
-
},
|
|
33
|
-
tags: {
|
|
34
|
-
type: "string",
|
|
35
|
-
description: "可选标签 JSON 数组,例如 '[\"a\",\"b\"]'"
|
|
36
|
-
},
|
|
37
|
-
format: formatCliArg
|
|
38
|
-
},
|
|
39
|
-
async run({ args }) {
|
|
40
|
-
try {
|
|
41
|
-
const type = args.type?.trim().toLowerCase() || "personal";
|
|
42
|
-
if (type !== "personal" && type !== "tenant" && type !== "project") throw new Error("type 仅支持 personal | tenant | project");
|
|
43
|
-
const projectId = args["project-id"]?.trim();
|
|
44
|
-
if (type === "project" && !projectId) throw new Error("type=project 需要 --project-id");
|
|
45
|
-
const zipBytes = await readFile(args.path.trim());
|
|
46
|
-
let skillId;
|
|
47
|
-
if (args["skill-id"]?.trim()) {
|
|
48
|
-
const rawId = args["skill-id"].trim();
|
|
49
|
-
if (!/^\d+$/.test(rawId)) throw new Error("skill-id 必须为数字");
|
|
50
|
-
skillId = rawId;
|
|
51
|
-
}
|
|
52
|
-
const token = await skillUploadInitiate({
|
|
53
|
-
skillId,
|
|
54
|
-
ownerType: type,
|
|
55
|
-
projectId
|
|
56
|
-
});
|
|
57
|
-
await putSkillZip(token.uploadUrl, zipBytes, token.uploadHeaders);
|
|
58
|
-
const skill = await skillUploadConfirm({
|
|
59
|
-
uploadToken: token.token,
|
|
60
|
-
tags: args.tags?.trim() || void 0
|
|
61
|
-
});
|
|
62
|
-
writeResult({
|
|
63
|
-
skillId: skill.id,
|
|
64
|
-
name: skill.name,
|
|
65
|
-
version: skill.version,
|
|
66
|
-
status: skill.status,
|
|
67
|
-
ownerType: skill.ownerType
|
|
68
|
-
}, args.format);
|
|
69
|
-
} catch (err) {
|
|
70
|
-
writeError(err, args.format);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
//#endregion
|
|
76
|
-
export { upload_default as default };
|
|
File without changes
|