beautx-cli 1.1.0 → 1.1.1-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 +57 -4
- package/dist/{analyze-Cq-Hmoqp.mjs → analyze-CtxR02Xr.mjs} +5 -5
- package/dist/{api-jIGM86TK.mjs → api-BdaZkABF.mjs} +1 -1
- package/dist/{audio-p2QCYFdq.mjs → audio-DlgPatwd.mjs} +3 -3
- package/dist/beauty-plan-CmcNlyKk.mjs +51 -0
- package/dist/{beauty-plan-reminder-D-gVCeWO.mjs → beauty-plan-reminder-B7g7RRTs.mjs} +2 -2
- package/dist/capability-profile-yPTx4Mn4.mjs +61 -0
- package/dist/cli.mjs +22 -18
- package/dist/{config-V1amf6sh.mjs → config-BjsUQ9I-.mjs} +3 -3
- package/dist/{consultant-DZeIOYgS.mjs → consultant-vVraua0_.mjs} +1 -1
- package/dist/{content-DbZ_Oi9R.mjs → content-Ce7jKBol.mjs} +2 -2
- package/dist/{current-RoW9iRya.mjs → current-fzCrzKjn.mjs} +1 -1
- package/dist/{customer-Cgsj-Z2b.mjs → customer-CnAv26d0.mjs} +1 -1
- package/dist/{deal-analysis-Da8iNy64.mjs → deal-analysis-CX4IXbgk.mjs} +3 -3
- package/dist/detail-ZG7WTexq.mjs +44 -0
- package/dist/{doc-D0ZKCnFf.mjs → doc-DU2dYD57.mjs} +3 -3
- package/dist/env-vars-osVxvm7z.mjs +212 -0
- package/dist/{fields-F00auxKR.mjs → fields-DuAxLfSA.mjs} +3 -3
- package/dist/{focus-DlptSJrZ.mjs → focus-Dx1rT6QE.mjs} +1 -1
- package/dist/get-CCpn3m06.mjs +40 -0
- package/dist/{get-yHGUZY7o.mjs → get-HrCcvm-j.mjs} +2 -2
- package/dist/golden-sentence-DAM_YC7V.mjs +11 -0
- package/dist/install-B9_5ceYu.mjs +50 -0
- package/dist/{kb-Cg2RM9t6.mjs → kb-CygBF0br.mjs} +2 -2
- package/dist/{list-D7_yNqIG.mjs → list-6eMMquS2.mjs} +3 -1
- package/dist/{list-DPVEnWni.mjs → list-7ynSCgKJ.mjs} +4 -4
- package/dist/{list-Cnz5CuQB.mjs → list-Bt87oTfo.mjs} +4 -4
- package/dist/{list-Boz4Dr1p.mjs → list-Cc0bsWKY.mjs} +4 -4
- package/dist/{list-y471qVyN.mjs → list-DKbbBiI62.mjs} +4 -4
- package/dist/{list-DFjDJRhp.mjs → list-Dttn4hHn.mjs} +14 -4
- package/dist/list-DyAO08z92.mjs +77 -0
- package/dist/{list-CDQGoZi6.mjs → list-EcRLnxXY.mjs} +4 -4
- package/dist/{list-Cos_lkZq.mjs → list-e0tVlYwh.mjs} +4 -4
- package/dist/{list-Cws2iiW4.mjs → list-xjVc-39m.mjs} +1 -1
- package/dist/{mcp-args-DK3IGaO1.mjs → mcp-args-CG7OuBep.mjs} +1 -1
- package/dist/{mcp-client-BTZH22b5.mjs → mcp-client-huLKHRT3.mjs} +3 -3
- package/dist/{mcp-result-De_0PPlD.mjs → mcp-result-BzDGJUdM.mjs} +1 -1
- package/dist/panke-DY7IFcsN.mjs +14 -0
- package/dist/{portrait-tags-LVjDI8fY.mjs → portrait-tags-Dq0faG7k.mjs} +3 -3
- package/dist/{project-dVDXp2i-.mjs → project-BuF0FYZp.mjs} +3 -3
- package/dist/{project-access-pTN7ry15.mjs → project-access-ChmJv4Z4.mjs} +3 -2
- package/dist/project-access-D4b4oc5E.mjs +2 -0
- package/dist/{project-store-Dl35JzZr.mjs → project-store-DUlIIW51.mjs} +2 -207
- package/dist/project-store-DlbRmRAS.mjs +2 -0
- package/dist/{qa-N4VI4Tww.mjs → qa-MQphVELO.mjs} +5 -5
- package/dist/{resistance-BWjqdajn.mjs → resistance-CzNYvRYF.mjs} +1 -1
- package/dist/{search-BWhcg6ng.mjs → search-CnFRGjnD.mjs} +5 -5
- package/dist/skill-_PLQOZgT.mjs +15 -0
- package/dist/skill-client-CLXEQ0Hv.mjs +146 -0
- package/dist/staff-ZUbldU8P.mjs +11 -0
- package/dist/{summary-DAf0vaO8.mjs → summary-B12uZDGr.mjs} +4 -4
- package/dist/task-CAobpQXt.mjs +40 -0
- package/dist/{text-BIIl7PmC.mjs → text-CCxnry4V.mjs} +4 -4
- package/dist/upload-COReB487.mjs +76 -0
- package/dist/{use-B-mda_1X.mjs → use-e7Wzfw1k.mjs} +2 -2
- package/dist/{visit-sMAORsRa.mjs → visit-DPkOV48n.mjs} +2 -2
- package/dist/{visit-query-args-BsfU3CUz.mjs → visit-query-args-BVeYwlRt.mjs} +2 -2
- package/package.json +1 -1
- package/dist/beauty-plan-D1bqzOTP.mjs +0 -36
- package/dist/project-access-Bf87OLJP.mjs +0 -2
- package/dist/project-store-DDVZ7T4t.mjs +0 -2
- package/dist/visit-evaluate-DzuaUj0E.mjs +0 -30
- /package/dist/{doctor-DuGxP40X.mjs → doctor-BuiUn2Zy.mjs} +0 -0
- /package/dist/{util-Bko-nm_R.mjs → util-BtgWHKWv.mjs} +0 -0
|
@@ -6,9 +6,9 @@ var project_default = defineCommand({
|
|
|
6
6
|
description: "查询 / 切换激活项目"
|
|
7
7
|
},
|
|
8
8
|
subCommands: {
|
|
9
|
-
list: () => import("./list-
|
|
10
|
-
use: () => import("./use-
|
|
11
|
-
current: () => import("./current-
|
|
9
|
+
list: () => import("./list-xjVc-39m.mjs").then((m) => m.default),
|
|
10
|
+
use: () => import("./use-e7Wzfw1k.mjs").then((m) => m.default),
|
|
11
|
+
current: () => import("./current-fzCrzKjn.mjs").then((m) => m.default)
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as readEnv, l as requireUserId, p as ConfigInvalidError, t as ENV_KEYS, u as resolveEndpoints } from "./env-vars-osVxvm7z.mjs";
|
|
2
|
+
import { o as loadActiveProject, s as peekCachedActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
3
|
var InsufficientCreditError = class extends Error {
|
|
3
4
|
code = "INSUFFICIENT_CREDIT";
|
|
4
5
|
hint = "(该项目下)用户积分余额不足,无法继续查询;请告知用户联系管理员充值";
|
|
@@ -227,7 +228,7 @@ function normalizeProjectListPage(page) {
|
|
|
227
228
|
};
|
|
228
229
|
}
|
|
229
230
|
async function fetchProjectListPage(page, size) {
|
|
230
|
-
const { mcpCall, unwrapMcpToolEnvelope } = await import("./mcp-client-
|
|
231
|
+
const { mcpCall, unwrapMcpToolEnvelope } = await import("./mcp-client-huLKHRT3.mjs").then((n) => n.r);
|
|
231
232
|
const result = await mcpCall("project-list", { arguments: {
|
|
232
233
|
page,
|
|
233
234
|
size
|
|
@@ -1,209 +1,4 @@
|
|
|
1
|
-
|
|
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 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
|
-
},
|
|
64
|
-
prod: {
|
|
65
|
-
gatewayUrl: `https://mcp.wangxiaobao.com`,
|
|
66
|
-
authUrl: `https://mcp-auth.wangxiaobao.com`,
|
|
67
|
-
callbackBaseUrl: `https://wangke.wangxiaobao.com`
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
function isProfileUrlConfigured(url) {
|
|
71
|
-
return url.startsWith("https://");
|
|
72
|
-
}
|
|
73
|
-
function parseEnvName(raw) {
|
|
74
|
-
if (raw === "test" || raw === "prod") return raw;
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/core/config-store.ts
|
|
79
|
-
/**
|
|
80
|
-
* Shared config helpers (env-only mode; no file persistence).
|
|
81
|
-
*/
|
|
82
|
-
/** Decode JWT exp (seconds) → ms; returns null if not a JWT or no exp. */
|
|
83
|
-
function jwtExpMs(token) {
|
|
84
|
-
const parts = token.split(".");
|
|
85
|
-
if (parts.length < 2) return null;
|
|
86
|
-
try {
|
|
87
|
-
const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, "+").replace(/_/g, "/"), "base64url").toString("utf8"));
|
|
88
|
-
if (typeof payload.exp === "number") return payload.exp * 1e3;
|
|
89
|
-
} catch {}
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/core/env-vars.ts
|
|
94
|
-
/**
|
|
95
|
-
* Environment-variable backed CLI state (sandbox single source of truth).
|
|
96
|
-
*/
|
|
97
|
-
const ENV_KEYS = {
|
|
98
|
-
ESTATE_ID: "ESTATE_ID",
|
|
99
|
-
ESTATE_NAME: "ESTATE_NAME",
|
|
100
|
-
TENANT_ID: "TENANT_ID",
|
|
101
|
-
TENANT_NAME: "TENANT_NAME",
|
|
102
|
-
USER_ID: "USER_ID",
|
|
103
|
-
USER_NAME: "USER_NAME",
|
|
104
|
-
MCP_TOKEN: "MCP_TOKEN",
|
|
105
|
-
REFRESH_TOKEN: "REFRESH_TOKEN",
|
|
106
|
-
EXPIRES_TIMES: "EXPIRES_TIMES",
|
|
107
|
-
SESSION_ID: "SESSION_ID",
|
|
108
|
-
XB_APP_ID: "XB_APP_ID",
|
|
109
|
-
ENV: "ENV",
|
|
110
|
-
/** 沙箱只读:创建模板时注入,用于 Token Broker 等敏感请求 */
|
|
111
|
-
SANDBOX_TENANT_SECRET: "SANDBOX_TENANT_SECRET",
|
|
112
|
-
/** 沙箱只读:创建用户时注入 */
|
|
113
|
-
SANDBOX_USER_SECRET: "SANDBOX_USER_SECRET"
|
|
114
|
-
};
|
|
115
|
-
/** Refresh when remaining lifetime is below this threshold (ms). */
|
|
116
|
-
const REFRESH_BUFFER_MS = 12e4;
|
|
117
|
-
function readEnv(key) {
|
|
118
|
-
return process.env[key]?.trim() ?? "";
|
|
119
|
-
}
|
|
120
|
-
function syncProcessEnv(pairs) {
|
|
121
|
-
for (const [key, value] of Object.entries(pairs)) process.env[key] = value;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Resolve deployment env from Host-injected `ENV`.
|
|
125
|
-
* Missing ENV falls back to DEFAULT_ENV (local shell only); invalid values error out.
|
|
126
|
-
*/
|
|
127
|
-
function resolveDeploymentEnv() {
|
|
128
|
-
const raw = readEnv(ENV_KEYS.ENV);
|
|
129
|
-
if (!raw) return DEFAULT_ENV;
|
|
130
|
-
const parsed = parseEnvName(raw);
|
|
131
|
-
if (!parsed) throw new ConfigInvalidError(`无效 ENV: ${raw}`, "由 Host 注入 ENV=test 或 ENV=prod");
|
|
132
|
-
return parsed;
|
|
133
|
-
}
|
|
134
|
-
/** Whether Host injected ENV (vs CLI local default). */
|
|
135
|
-
function isEnvInjectedByHost() {
|
|
136
|
-
return Boolean(readEnv(ENV_KEYS.ENV));
|
|
137
|
-
}
|
|
138
|
-
function resolveEndpoints() {
|
|
139
|
-
const env = resolveDeploymentEnv();
|
|
140
|
-
const profile = PROFILES[env];
|
|
141
|
-
return {
|
|
142
|
-
env,
|
|
143
|
-
gatewayUrl: profile.gatewayUrl,
|
|
144
|
-
authUrl: profile.authUrl,
|
|
145
|
-
callbackBaseUrl: profile.callbackBaseUrl
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function assertEndpointsValid(endpoints) {
|
|
149
|
-
if (!isProfileUrlConfigured(endpoints.gatewayUrl)) throw new ConfigInvalidError(`环境 ${endpoints.env} 的网关 URL 尚未配置`, "由 Host 设置 ENV=test,或待 prod 域名就绪后设置 ENV=prod");
|
|
150
|
-
if (!isProfileUrlConfigured(endpoints.callbackBaseUrl)) throw new ConfigInvalidError(`环境 ${endpoints.env} 的回调 URL 尚未配置`, "由 Host 设置 ENV=test,或待 prod 域名就绪后设置 ENV=prod");
|
|
151
|
-
}
|
|
152
|
-
function requireUserId() {
|
|
153
|
-
const userId = readEnv(ENV_KEYS.USER_ID);
|
|
154
|
-
if (!userId) throw new ConfigInvalidError("缺少 USER_ID 环境变量", "由 QCA 在沙箱启动时注入 USER_ID");
|
|
155
|
-
return userId;
|
|
156
|
-
}
|
|
157
|
-
function readCredentials() {
|
|
158
|
-
const accessToken = readEnv(ENV_KEYS.MCP_TOKEN) || null;
|
|
159
|
-
const refreshToken = readEnv(ENV_KEYS.REFRESH_TOKEN) || null;
|
|
160
|
-
const expiresRaw = readEnv(ENV_KEYS.EXPIRES_TIMES);
|
|
161
|
-
let expiresAt = null;
|
|
162
|
-
if (expiresRaw) {
|
|
163
|
-
const parsed = Number(expiresRaw);
|
|
164
|
-
if (!Number.isNaN(parsed) && parsed > 0) expiresAt = parsed;
|
|
165
|
-
}
|
|
166
|
-
if (expiresAt == null && accessToken) expiresAt = jwtExpMs(accessToken);
|
|
167
|
-
return {
|
|
168
|
-
accessToken,
|
|
169
|
-
refreshToken,
|
|
170
|
-
expiresAt
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
function credentialStatus(creds) {
|
|
174
|
-
if (!creds.accessToken) return {
|
|
175
|
-
configured: false,
|
|
176
|
-
status: "missing",
|
|
177
|
-
expiresAt: null,
|
|
178
|
-
expiresInSec: null
|
|
179
|
-
};
|
|
180
|
-
return buildExpiryView(creds, computeExpiryStatus(creds.expiresAt));
|
|
181
|
-
}
|
|
182
|
-
function buildExpiryView(creds, status) {
|
|
183
|
-
const expiresAt = creds.expiresAt;
|
|
184
|
-
const expiresInSec = expiresAt != null ? Math.max(0, Math.floor((expiresAt - Date.now()) / 1e3)) : null;
|
|
185
|
-
return {
|
|
186
|
-
configured: true,
|
|
187
|
-
status,
|
|
188
|
-
expiresAt: expiresAt ?? null,
|
|
189
|
-
expiresInSec
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function computeExpiryStatus(expiresAt) {
|
|
193
|
-
if (expiresAt == null) return "valid";
|
|
194
|
-
const remaining = expiresAt - Date.now();
|
|
195
|
-
if (remaining <= 0) return "expired";
|
|
196
|
-
if (remaining < 12e4) return "expiring";
|
|
197
|
-
return "valid";
|
|
198
|
-
}
|
|
199
|
-
function needsRefresh(expiresAt, force = false) {
|
|
200
|
-
if (force) return true;
|
|
201
|
-
if (expiresAt == null) return false;
|
|
202
|
-
return expiresAt - Date.now() < REFRESH_BUFFER_MS;
|
|
203
|
-
}
|
|
204
|
-
function isTokenExpired(expiresAt) {
|
|
205
|
-
return expiresAt != null && expiresAt <= Date.now();
|
|
206
|
-
}
|
|
1
|
+
import { c as readEnv, l as requireUserId, m as CurrentProjectFailedError, t as ENV_KEYS, u as resolveEndpoints } from "./env-vars-osVxvm7z.mjs";
|
|
207
2
|
function requireTenantId() {
|
|
208
3
|
const tenantId = readEnv(ENV_KEYS.TENANT_ID);
|
|
209
4
|
if (!tenantId) throw new CurrentProjectFailedError("缺少 TENANT_ID 环境变量", { hint: "由 QCA 在沙箱启动时注入 TENANT_ID" });
|
|
@@ -421,4 +216,4 @@ function toActiveProject(remote) {
|
|
|
421
216
|
};
|
|
422
217
|
}
|
|
423
218
|
//#endregion
|
|
424
|
-
export {
|
|
219
|
+
export { isProjectSwitchAllowed as a, requireActiveProject as c, invalidateActiveProjectCache as i, switchActiveProjectViaCallback as l, ProjectSwitchNotAllowedError as n, loadActiveProject as o, assertProjectSwitchAllowed as r, peekCachedActiveProject as s, NoActiveProjectError as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as requireActiveProject } from "./project-store-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
2
|
import { n as writeError, t as formatCliArg } from "./cli.mjs";
|
|
3
|
-
import { n as mcpCall } from "./mcp-client-
|
|
4
|
-
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-
|
|
5
|
-
import { n as writeMcpDataResult } from "./mcp-result-
|
|
6
|
-
import { t as csvToArray } from "./util-
|
|
3
|
+
import { n as mcpCall } from "./mcp-client-huLKHRT3.mjs";
|
|
4
|
+
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-CG7OuBep.mjs";
|
|
5
|
+
import { n as writeMcpDataResult } from "./mcp-result-BzDGJUdM.mjs";
|
|
6
|
+
import { t as csvToArray } from "./util-BtgWHKWv.mjs";
|
|
7
7
|
import { defineCommand } from "citty";
|
|
8
8
|
//#region src/commands/qa.ts
|
|
9
9
|
/**
|
|
@@ -5,7 +5,7 @@ var resistance_default = defineCommand({
|
|
|
5
5
|
name: "resistance",
|
|
6
6
|
description: "客户抗性点标签分页查询"
|
|
7
7
|
},
|
|
8
|
-
subCommands: { list: () => import("./list-
|
|
8
|
+
subCommands: { list: () => import("./list-DKbbBiI62.mjs").then((m) => m.default) }
|
|
9
9
|
});
|
|
10
10
|
//#endregion
|
|
11
11
|
export { resistance_default as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as requireActiveProject } from "./project-store-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
2
|
import { n as writeError, t as formatCliArg } from "./cli.mjs";
|
|
3
|
-
import { n as mcpCall } from "./mcp-client-
|
|
4
|
-
import { i as tenantIdCliArg, n as resolveProjectId, r as resolveTenantId, t as projectIdCliArg } from "./mcp-args-
|
|
5
|
-
import { n as writeMcpDataResult } from "./mcp-result-
|
|
6
|
-
import { t as csvToArray } from "./util-
|
|
3
|
+
import { n as mcpCall } from "./mcp-client-huLKHRT3.mjs";
|
|
4
|
+
import { i as tenantIdCliArg, n as resolveProjectId, r as resolveTenantId, t as projectIdCliArg } from "./mcp-args-CG7OuBep.mjs";
|
|
5
|
+
import { n as writeMcpDataResult } from "./mcp-result-BzDGJUdM.mjs";
|
|
6
|
+
import { t as csvToArray } from "./util-BtgWHKWv.mjs";
|
|
7
7
|
import { defineCommand } from "citty";
|
|
8
8
|
//#region src/commands/kb/search.ts
|
|
9
9
|
/**
|
|
@@ -0,0 +1,15 @@
|
|
|
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-DyAO08z92.mjs").then((m) => m.default),
|
|
10
|
+
install: () => import("./install-B9_5ceYu.mjs").then((m) => m.default),
|
|
11
|
+
upload: () => import("./upload-COReB487.mjs").then((m) => m.default)
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { skill_default as default };
|
|
@@ -0,0 +1,146 @@
|
|
|
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 };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
//#region src/commands/staff/index.ts
|
|
3
|
+
var staff_default = defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "staff",
|
|
6
|
+
description: "员工能力查询"
|
|
7
|
+
},
|
|
8
|
+
subCommands: { "capability-profile": () => import("./capability-profile-yPTx4Mn4.mjs").then((m) => m.default) }
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { staff_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as requireActiveProject } from "./project-store-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
2
|
import { n as writeError, t as formatCliArg } from "./cli.mjs";
|
|
3
|
-
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-
|
|
4
|
-
import { t as mcpCallPage } from "./mcp-result-
|
|
5
|
-
import { i as toLocalDateTime } from "./util-
|
|
3
|
+
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-CG7OuBep.mjs";
|
|
4
|
+
import { t as mcpCallPage } from "./mcp-result-BzDGJUdM.mjs";
|
|
5
|
+
import { i as toLocalDateTime } from "./util-BtgWHKWv.mjs";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/visit/summary.ts
|
|
8
8
|
/**
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
|
+
import { n as writeError, t as formatCliArg } from "./cli.mjs";
|
|
3
|
+
import { n as mcpCall } from "./mcp-client-huLKHRT3.mjs";
|
|
4
|
+
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-CG7OuBep.mjs";
|
|
5
|
+
import { n as writeMcpDataResult } from "./mcp-result-BzDGJUdM.mjs";
|
|
6
|
+
import { defineCommand } from "citty";
|
|
7
|
+
//#region src/commands/panke/task.ts
|
|
8
|
+
function buildPankeTaskArgs(args, active) {
|
|
9
|
+
const pankeTaskId = String(args["panke-task-id"] || "").trim();
|
|
10
|
+
if (!/^[1-9]\d*$/.test(pankeTaskId)) throw new Error("--panke-task-id must be a positive task ID");
|
|
11
|
+
return {
|
|
12
|
+
project_id: resolveProjectId(args["project-id"], active),
|
|
13
|
+
panke_task_id: pankeTaskId
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
var task_default = defineCommand({
|
|
17
|
+
meta: {
|
|
18
|
+
name: "task",
|
|
19
|
+
description: "按小美盘客任务 ID 查询任务详情"
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
...projectIdCliArg,
|
|
23
|
+
"panke-task-id": {
|
|
24
|
+
type: "string",
|
|
25
|
+
required: true,
|
|
26
|
+
description: "小美待盘客页面 taskId"
|
|
27
|
+
},
|
|
28
|
+
format: formatCliArg
|
|
29
|
+
},
|
|
30
|
+
async run({ args }) {
|
|
31
|
+
try {
|
|
32
|
+
writeMcpDataResult(await mcpCall("panke-task-get", { arguments: buildPankeTaskArgs(args, await requireActiveProject()) }), args.format);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
writeError(err, args.format);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
//#endregion
|
|
40
|
+
export { task_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as requireActiveProject } from "./project-store-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-DUlIIW51.mjs";
|
|
2
2
|
import { n as writeError, t as formatCliArg } from "./cli.mjs";
|
|
3
|
-
import { n as mcpCall } from "./mcp-client-
|
|
4
|
-
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-
|
|
5
|
-
import { n as writeMcpDataResult } from "./mcp-result-
|
|
3
|
+
import { n as mcpCall } from "./mcp-client-huLKHRT3.mjs";
|
|
4
|
+
import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-CG7OuBep.mjs";
|
|
5
|
+
import { n as writeMcpDataResult } from "./mcp-result-BzDGJUdM.mjs";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/audio/text.ts
|
|
8
8
|
/**
|
|
@@ -0,0 +1,76 @@
|
|
|
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-CLXEQ0Hv.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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as resolveProjectForUse, i as invalidateProjectAccessCache } from "./project-access-ChmJv4Z4.mjs";
|
|
2
|
+
import { i as invalidateActiveProjectCache, l as switchActiveProjectViaCallback, r as assertProjectSwitchAllowed } from "./project-store-DUlIIW51.mjs";
|
|
3
3
|
import { n as writeError, r as writeResult, t as formatCliArg } from "./cli.mjs";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
//#region src/commands/project/use.ts
|
|
@@ -6,8 +6,8 @@ var visit_default = defineCommand({
|
|
|
6
6
|
description: "客户来访查询"
|
|
7
7
|
},
|
|
8
8
|
subCommands: {
|
|
9
|
-
list: () => import("./list-
|
|
10
|
-
summary: () => import("./summary-
|
|
9
|
+
list: () => import("./list-e0tVlYwh.mjs").then((m) => m.default),
|
|
10
|
+
summary: () => import("./summary-B12uZDGr.mjs").then((m) => m.default)
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
//#endregion
|
|
@@ -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-CG7OuBep.mjs";
|
|
3
|
+
import { i as toLocalDateTime, n as mergeIds, t as csvToArray } from "./util-BtgWHKWv.mjs";
|
|
4
4
|
//#region src/commands/common/visit-query-args.ts
|
|
5
5
|
const visitBatchQueryCliArgs = {
|
|
6
6
|
...projectIdCliArg,
|