beautx-cli 1.0.6-beta.3 → 1.0.7-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.
Files changed (55) hide show
  1. package/README.md +30 -0
  2. package/dist/{analyze-Cq-Hmoqp.mjs → analyze-CcsdZtz9.mjs} +5 -5
  3. package/dist/{api-jIGM86TK.mjs → api-B5nQypBz.mjs} +1 -1
  4. package/dist/{audio-p2QCYFdq.mjs → audio-DVH0I5Zh.mjs} +3 -3
  5. package/dist/{beauty-plan-CgSmAhn8.mjs → beauty-plan-Cd88u5h0.mjs} +3 -3
  6. package/dist/cli.mjs +33 -18
  7. package/dist/{config-DAVi_CuD.mjs → config-BOuRZAk1.mjs} +3 -3
  8. package/dist/{consultant-CPecFRiS.mjs → consultant-C1uiuItn.mjs} +1 -1
  9. package/dist/{content-Bq_jEIl6.mjs → content-CpFANyPe.mjs} +2 -2
  10. package/dist/{current-D4fh-53q.mjs → current--kwV_-9S.mjs} +1 -1
  11. package/dist/{customer-DWG47eAT.mjs → customer-Chl1bGg9.mjs} +1 -1
  12. package/dist/{deal-analysis-Cn2wCaoU.mjs → deal-analysis-Bf6TwBmH.mjs} +3 -3
  13. package/dist/{doc-DwxREqki.mjs → doc-BtwmuoPs.mjs} +3 -3
  14. package/dist/env-vars-Dinhf5lt.mjs +212 -0
  15. package/dist/{fields-BGogOrgD.mjs → fields-MsjROq8O.mjs} +3 -3
  16. package/dist/{focus-BE8BT835.mjs → focus-CM6mZYRj.mjs} +1 -1
  17. package/dist/{get-BKCE22jj.mjs → get-Z_hTyubv.mjs} +2 -2
  18. package/dist/install-DP9xV1rY.mjs +50 -0
  19. package/dist/{kb-BsiBl_ul.mjs → kb-CjQXEOY5.mjs} +2 -2
  20. package/dist/{list-BmVWcUI7.mjs → list-B84PLHzp.mjs} +1 -1
  21. package/dist/list-BNZV4wei.mjs +77 -0
  22. package/dist/{list-Cnz5CuQB.mjs → list-BSR3H7_0.mjs} +4 -4
  23. package/dist/{list-Cs1kF7EB.mjs → list-BT0_KdNZ.mjs} +4 -4
  24. package/dist/{list-DJscF_8M.mjs → list-C0wn72hg.mjs} +4 -4
  25. package/dist/{list-DVy4Czfy.mjs → list-C6imhAfi.mjs} +4 -4
  26. package/dist/{list-BzmkW4Iq.mjs → list-CDi3ySyx.mjs} +4 -4
  27. package/dist/{list-BYLk3sNv.mjs → list-CGJa9z3d.mjs} +4 -4
  28. package/dist/{list-BcYy7Ejx.mjs → list-CJiei-hu.mjs} +4 -4
  29. package/dist/{list-BUYSLNqZ.mjs → list-D809kN14.mjs} +3 -1
  30. package/dist/{mcp-args-DK3IGaO1.mjs → mcp-args-B8InvGQc.mjs} +1 -1
  31. package/dist/{mcp-client-BTZH22b5.mjs → mcp-client-aS31KU6J.mjs} +3 -3
  32. package/dist/{mcp-result-De_0PPlD.mjs → mcp-result-Bl71pkOt.mjs} +1 -1
  33. package/dist/{portrait-tags-I57TgDAx.mjs → portrait-tags-BYded-6k.mjs} +3 -3
  34. package/dist/{project-K-HkeM57.mjs → project-DSO_7ofq.mjs} +3 -3
  35. package/dist/project-access-Cq8d1YTo.mjs +2 -0
  36. package/dist/{project-access-pTN7ry15.mjs → project-access-DlypxnQF.mjs} +3 -2
  37. package/dist/project-store-CYuTFefu.mjs +2 -0
  38. package/dist/{project-store-Dl35JzZr.mjs → project-store-D0UuLan2.mjs} +2 -207
  39. package/dist/{qa-gAtF6cSk.mjs → qa-CqUiXIZn.mjs} +5 -5
  40. package/dist/{resistance-DGU99Bwi.mjs → resistance-DiDDixVq.mjs} +1 -1
  41. package/dist/{search-C16CzRep.mjs → search-sjRwA-la.mjs} +5 -5
  42. package/dist/skill-DBpgezPV.mjs +15 -0
  43. package/dist/skill-client-D4_QGDkj.mjs +171 -0
  44. package/dist/{summary-DgpSsQh9.mjs → summary-C7lrTImW.mjs} +4 -4
  45. package/dist/{text-BIIl7PmC.mjs → text-BZo7B8mz.mjs} +4 -4
  46. package/dist/upload-D4wSmRqs.mjs +76 -0
  47. package/dist/{use-D_HBqdev.mjs → use-DQ_M0FOH.mjs} +2 -2
  48. package/dist/{visit-DnUPj-8i.mjs → visit-CxAYV6z6.mjs} +2 -2
  49. package/dist/{visit-evaluate-DM7oCk6R.mjs → visit-evaluate-BTKqc8fd.mjs} +3 -3
  50. package/dist/{visit-query-args-BD3Dw-9F.mjs → visit-query-args-BLwj26s6.mjs} +2 -2
  51. package/package.json +1 -1
  52. package/dist/project-access-Bf87OLJP.mjs +0 -2
  53. package/dist/project-store-DDVZ7T4t.mjs +0 -2
  54. /package/dist/{doctor-RwDPp4y3.mjs → doctor-DuGxP40X.mjs} +0 -0
  55. /package/dist/{util-Bko-nm_R.mjs → util-BtgWHKWv.mjs} +0 -0
package/README.md CHANGED
@@ -57,6 +57,36 @@ beautx-cli project current
57
57
  beautx-cli project use --project-id <项目ID>
58
58
  ```
59
59
 
60
+ ### Skill 中心
61
+
62
+ Skill 中心使用 Skill BFF REST 接口,不经过 MCP;请求由 CLI 自动携带沙箱双 Secret
63
+ 鉴权。`skill list` 和 `skill install` 默认使用当前激活项目,上传个人 Skill
64
+ 不要求当前项目,上传项目 Skill 时必须显式传入项目 ID。
65
+
66
+ ```bash
67
+ # 查看当前项目可见的 Skill(按 personal / tenant / project 分组)
68
+ beautx-cli skill list
69
+
70
+ # 按归属类型筛选
71
+ beautx-cli skill list --type personal
72
+ beautx-cli skill list --type tenant --project-id <项目ID>
73
+ beautx-cli skill list --type project --project-id <项目ID>
74
+
75
+ # 安装 Skill 包;默认写入 /home/wuying/jvscrew/.wangai-cli/skills/<skill-id>
76
+ beautx-cli skill install <skill-id>
77
+ beautx-cli skill install <skill-id> --dir <安装目录>
78
+
79
+ # 上传新 Skill;zip 内需要包含 SKILL.md
80
+ beautx-cli skill upload <skill.zip>
81
+ beautx-cli skill upload <skill.zip> --type tenant --project-id <项目ID>
82
+ beautx-cli skill upload <skill.zip> --type project --project-id <项目ID>
83
+
84
+ # 替换已有 Skill,并设置 tags
85
+ beautx-cli skill upload <skill.zip> \
86
+ --skill-id <skill-id> \
87
+ --tags '["医美","分析"]'
88
+ ```
89
+
60
90
  ### 顾问管理
61
91
 
62
92
  ```bash
@@ -1,9 +1,9 @@
1
- import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
1
+ import { c as requireActiveProject } from "./project-store-D0UuLan2.mjs";
2
2
  import { n as writeError, t as formatCliArg } from "./cli.mjs";
3
- import { n as mcpCall } from "./mcp-client-BTZH22b5.mjs";
4
- import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-DK3IGaO1.mjs";
5
- import { n as writeMcpDataResult } from "./mcp-result-De_0PPlD.mjs";
6
- import { t as csvToArray } from "./util-Bko-nm_R.mjs";
3
+ import { n as mcpCall } from "./mcp-client-aS31KU6J.mjs";
4
+ import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-B8InvGQc.mjs";
5
+ import { n as writeMcpDataResult } from "./mcp-result-Bl71pkOt.mjs";
6
+ import { t as csvToArray } from "./util-BtgWHKWv.mjs";
7
7
  import { defineCommand } from "citty";
8
8
  //#region src/commands/audio/analyze.ts
9
9
  /**
@@ -1,5 +1,5 @@
1
1
  import { n as writeError, r as writeResult, t as formatCliArg } from "./cli.mjs";
2
- import { n as mcpCall, t as MCP_SERVICE_CODE } from "./mcp-client-BTZH22b5.mjs";
2
+ import { n as mcpCall, t as MCP_SERVICE_CODE } from "./mcp-client-aS31KU6J.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  //#region src/commands/api.ts
5
5
  /**
@@ -6,9 +6,9 @@ var audio_default = defineCommand({
6
6
  description: "录音元数据分页 / 单条文本查询 / 全文批量分析"
7
7
  },
8
8
  subCommands: {
9
- list: () => import("./list-Cnz5CuQB.mjs").then((m) => m.default),
10
- text: () => import("./text-BIIl7PmC.mjs").then((m) => m.default),
11
- analyze: () => import("./analyze-Cq-Hmoqp.mjs").then((m) => m.default)
9
+ list: () => import("./list-BSR3H7_0.mjs").then((m) => m.default),
10
+ text: () => import("./text-BZo7B8mz.mjs").then((m) => m.default),
11
+ analyze: () => import("./analyze-CcsdZtz9.mjs").then((m) => m.default)
12
12
  }
13
13
  });
14
14
  //#endregion
@@ -1,7 +1,7 @@
1
- import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
1
+ import { c as requireActiveProject } from "./project-store-D0UuLan2.mjs";
2
2
  import { n as writeError } from "./cli.mjs";
3
- import { t as mcpCallPage } from "./mcp-result-De_0PPlD.mjs";
4
- import { n as visitBatchQueryCliArgs, t as buildVisitBatchQueryArgs } from "./visit-query-args-BD3Dw-9F.mjs";
3
+ import { t as mcpCallPage } from "./mcp-result-Bl71pkOt.mjs";
4
+ import { n as visitBatchQueryCliArgs, t as buildVisitBatchQueryArgs } from "./visit-query-args-BLwj26s6.mjs";
5
5
  import { defineCommand } from "citty";
6
6
  //#region src/commands/beauty-plan/index.ts
7
7
  /**
package/dist/cli.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { i as __toESM, r as __require, t as __commonJSMin } from "./rolldown-runtime-YLnNgb9a.mjs";
3
- import { C as MissingAccessTokenError, S as ConfigInvalidError, _ as readEnv, b as syncProcessEnv, g as readCredentials, h as needsRefresh, m as isTokenExpired, o as loadActiveProject, u as ENV_KEYS, v as requireUserId, x as AccessTokenExpiredError, y as resolveEndpoints } from "./project-store-Dl35JzZr.mjs";
4
- import { i as invalidateProjectAccessCache } from "./project-access-pTN7ry15.mjs";
3
+ import { a as isTokenExpired, c as readEnv, d as syncProcessEnv, f as AccessTokenExpiredError, h as MissingAccessTokenError, l as requireUserId, o as needsRefresh, p as ConfigInvalidError, s as readCredentials, t as ENV_KEYS, u as resolveEndpoints } from "./env-vars-Dinhf5lt.mjs";
4
+ import { i as invalidateProjectAccessCache } from "./project-access-DlypxnQF.mjs";
5
+ import { o as loadActiveProject } from "./project-store-D0UuLan2.mjs";
5
6
  import { appendFileSync, mkdirSync, readFileSync } from "node:fs";
6
7
  import { dirname, join } from "node:path";
7
8
  import { fileURLToPath } from "node:url";
@@ -180,7 +181,20 @@ function shouldRunPreflightGate(rawArgs) {
180
181
  }
181
182
  /** `project *` may establish current project — skip that one check only. */
182
183
  function shouldSkipCurrentProjectCheck(rawArgs) {
183
- return firstPositional(rawArgs) === "project";
184
+ const top = firstPositional(rawArgs);
185
+ if (top === "project") return true;
186
+ if (top === "skill") return positionalAfter(rawArgs, top) === "upload";
187
+ return false;
188
+ }
189
+ function positionalAfter(rawArgs, value) {
190
+ const index = rawArgs.indexOf(value);
191
+ if (index < 0) return null;
192
+ for (let i = index + 1; i < rawArgs.length; i += 1) {
193
+ const arg = rawArgs[i];
194
+ if (!arg || arg.startsWith("-")) continue;
195
+ return arg;
196
+ }
197
+ return null;
184
198
  }
185
199
  function firstPositional(rawArgs) {
186
200
  for (const arg of rawArgs) {
@@ -7635,21 +7649,22 @@ runMain(defineCommand({
7635
7649
  }
7636
7650
  },
7637
7651
  subCommands: {
7638
- config: () => import("./config-DAVi_CuD.mjs").then((m) => m.default),
7639
- project: () => import("./project-K-HkeM57.mjs").then((m) => m.default),
7640
- consultant: () => import("./consultant-CPecFRiS.mjs").then((m) => m.default),
7641
- audio: () => import("./audio-p2QCYFdq.mjs").then((m) => m.default),
7642
- customer: () => import("./customer-DWG47eAT.mjs").then((m) => m.default),
7643
- visit: () => import("./visit-DnUPj-8i.mjs").then((m) => m.default),
7644
- "visit-evaluate": () => import("./visit-evaluate-DM7oCk6R.mjs").then((m) => m.default),
7645
- "beauty-plan": () => import("./beauty-plan-CgSmAhn8.mjs").then((m) => m.default),
7646
- "deal-analysis": () => import("./deal-analysis-Cn2wCaoU.mjs").then((m) => m.default),
7647
- "portrait-tags": () => import("./portrait-tags-I57TgDAx.mjs").then((m) => m.default),
7648
- focus: () => import("./focus-BE8BT835.mjs").then((m) => m.default),
7649
- resistance: () => import("./resistance-DGU99Bwi.mjs").then((m) => m.default),
7650
- qa: () => import("./qa-gAtF6cSk.mjs").then((m) => m.default),
7651
- kb: () => import("./kb-BsiBl_ul.mjs").then((m) => m.default)
7652
+ config: () => import("./config-BOuRZAk1.mjs").then((m) => m.default),
7653
+ project: () => import("./project-DSO_7ofq.mjs").then((m) => m.default),
7654
+ skill: () => import("./skill-DBpgezPV.mjs").then((m) => m.default),
7655
+ consultant: () => import("./consultant-C1uiuItn.mjs").then((m) => m.default),
7656
+ audio: () => import("./audio-DVH0I5Zh.mjs").then((m) => m.default),
7657
+ customer: () => import("./customer-Chl1bGg9.mjs").then((m) => m.default),
7658
+ visit: () => import("./visit-CxAYV6z6.mjs").then((m) => m.default),
7659
+ "visit-evaluate": () => import("./visit-evaluate-BTKqc8fd.mjs").then((m) => m.default),
7660
+ "beauty-plan": () => import("./beauty-plan-Cd88u5h0.mjs").then((m) => m.default),
7661
+ "deal-analysis": () => import("./deal-analysis-Bf6TwBmH.mjs").then((m) => m.default),
7662
+ "portrait-tags": () => import("./portrait-tags-BYded-6k.mjs").then((m) => m.default),
7663
+ focus: () => import("./focus-CM6mZYRj.mjs").then((m) => m.default),
7664
+ resistance: () => import("./resistance-DiDDixVq.mjs").then((m) => m.default),
7665
+ qa: () => import("./qa-CqUiXIZn.mjs").then((m) => m.default),
7666
+ kb: () => import("./kb-CjQXEOY5.mjs").then((m) => m.default)
7652
7667
  }
7653
7668
  }));
7654
7669
  //#endregion
7655
- export { debugLogInfo as a, runPreflight as c, debugLogError as i, ensureAuth as l, writeError as n, debugLogPath as o, writeResult as r, isVerboseDebugEnabled as s, formatCliArg as t };
7670
+ export { debugLogInfo as a, runPreflight as c, buildSandboxProof as d, requireSandboxSecrets as f, debugLogError as i, ensureAuth as l, writeError as n, debugLogPath as o, requireTenantId as p, writeResult as r, isVerboseDebugEnabled as s, formatCliArg as t, WANGCLAW_AUTH_HEADER as u };
@@ -6,9 +6,9 @@ var config_default = defineCommand({
6
6
  description: "沙箱配置:list 只读诊断;doctor 自检;fields 客户字段字典"
7
7
  },
8
8
  subCommands: {
9
- list: () => import("./list-BUYSLNqZ.mjs").then((m) => m.default),
10
- doctor: () => import("./doctor-RwDPp4y3.mjs").then((m) => m.default),
11
- fields: () => import("./fields-BGogOrgD.mjs").then((m) => m.default)
9
+ list: () => import("./list-D809kN14.mjs").then((m) => m.default),
10
+ doctor: () => import("./doctor-DuGxP40X.mjs").then((m) => m.default),
11
+ fields: () => import("./fields-MsjROq8O.mjs").then((m) => m.default)
12
12
  }
13
13
  });
14
14
  //#endregion
@@ -5,7 +5,7 @@ var consultant_default = defineCommand({
5
5
  name: "consultant",
6
6
  description: "查询有权限的顾问列表"
7
7
  },
8
- subCommands: { list: () => import("./list-Cs1kF7EB.mjs").then((m) => m.default) }
8
+ subCommands: { list: () => import("./list-BT0_KdNZ.mjs").then((m) => m.default) }
9
9
  });
10
10
  //#endregion
11
11
  export { consultant_default as default };
@@ -1,6 +1,6 @@
1
1
  import { n as writeError, t as formatCliArg } from "./cli.mjs";
2
- import { n as mcpCall } from "./mcp-client-BTZH22b5.mjs";
3
- import { n as writeMcpDataResult } from "./mcp-result-De_0PPlD.mjs";
2
+ import { n as mcpCall } from "./mcp-client-aS31KU6J.mjs";
3
+ import { n as writeMcpDataResult } from "./mcp-result-Bl71pkOt.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  //#region src/commands/kb/doc/content.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
1
+ import { c as requireActiveProject } from "./project-store-D0UuLan2.mjs";
2
2
  import { n as writeError, r as writeResult, t as formatCliArg } from "./cli.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  //#region src/commands/project/current.ts
@@ -5,7 +5,7 @@ var customer_default = defineCommand({
5
5
  name: "customer",
6
6
  description: "客户画像分页查询"
7
7
  },
8
- subCommands: { list: () => import("./list-DJscF_8M.mjs").then((m) => m.default) }
8
+ subCommands: { list: () => import("./list-C0wn72hg.mjs").then((m) => m.default) }
9
9
  });
10
10
  //#endregion
11
11
  export { customer_default as default };
@@ -1,7 +1,7 @@
1
- import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
1
+ import { c as requireActiveProject } from "./project-store-D0UuLan2.mjs";
2
2
  import { n as writeError } from "./cli.mjs";
3
- import { t as mcpCallPage } from "./mcp-result-De_0PPlD.mjs";
4
- import { n as visitBatchQueryCliArgs, t as buildVisitBatchQueryArgs } from "./visit-query-args-BD3Dw-9F.mjs";
3
+ import { t as mcpCallPage } from "./mcp-result-Bl71pkOt.mjs";
4
+ import { n as visitBatchQueryCliArgs, t as buildVisitBatchQueryArgs } from "./visit-query-args-BLwj26s6.mjs";
5
5
  import { defineCommand } from "citty";
6
6
  //#region src/commands/deal-analysis/index.ts
7
7
  /**
@@ -6,9 +6,9 @@ var doc_default = defineCommand({
6
6
  description: "知识库文档列表 / 元数据 / 全文"
7
7
  },
8
8
  subCommands: {
9
- list: () => import("./list-BzmkW4Iq.mjs").then((m) => m.default),
10
- get: () => import("./get-BKCE22jj.mjs").then((m) => m.default),
11
- content: () => import("./content-Bq_jEIl6.mjs").then((m) => m.default)
9
+ list: () => import("./list-CDi3ySyx.mjs").then((m) => m.default),
10
+ get: () => import("./get-Z_hTyubv.mjs").then((m) => m.default),
11
+ content: () => import("./content-CpFANyPe.mjs").then((m) => m.default)
12
12
  }
13
13
  });
14
14
  //#endregion
@@ -0,0 +1,212 @@
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 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,7 +1,7 @@
1
- import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
1
+ import { c as requireActiveProject } from "./project-store-D0UuLan2.mjs";
2
2
  import { n as writeError, t as formatCliArg } from "./cli.mjs";
3
- import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-DK3IGaO1.mjs";
4
- import { t as mcpCallPage } from "./mcp-result-De_0PPlD.mjs";
3
+ import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-B8InvGQc.mjs";
4
+ import { t as mcpCallPage } from "./mcp-result-Bl71pkOt.mjs";
5
5
  import { defineCommand } from "citty";
6
6
  //#region src/commands/config/fields.ts
7
7
  /**
@@ -5,7 +5,7 @@ var focus_default = defineCommand({
5
5
  name: "focus",
6
6
  description: "客户关注点标签分页查询"
7
7
  },
8
- subCommands: { list: () => import("./list-BYLk3sNv.mjs").then((m) => m.default) }
8
+ subCommands: { list: () => import("./list-CGJa9z3d.mjs").then((m) => m.default) }
9
9
  });
10
10
  //#endregion
11
11
  export { focus_default as default };
@@ -1,6 +1,6 @@
1
1
  import { n as writeError, t as formatCliArg } from "./cli.mjs";
2
- import { n as mcpCall } from "./mcp-client-BTZH22b5.mjs";
3
- import { n as writeMcpDataResult } from "./mcp-result-De_0PPlD.mjs";
2
+ import { n as mcpCall } from "./mcp-client-aS31KU6J.mjs";
3
+ import { n as writeMcpDataResult } from "./mcp-result-Bl71pkOt.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  //#region src/commands/kb/doc/get.ts
6
6
  /**
@@ -0,0 +1,50 @@
1
+ import { c as requireActiveProject } from "./project-store-D0UuLan2.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-B8InvGQc.mjs";
4
+ import { i as skillInstallGrant, r as resolveSkillInstallDir, t as downloadSkillPackage } from "./skill-client-D4_QGDkj.mjs";
5
+ import { defineCommand } from "citty";
6
+ //#region src/commands/skill/install.ts
7
+ /**
8
+ * `beautx-cli skill install <id>` — request a package grant and download it.
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 };
@@ -6,8 +6,8 @@ var kb_default = defineCommand({
6
6
  description: "知识库检索与文档查询"
7
7
  },
8
8
  subCommands: {
9
- search: () => import("./search-C16CzRep.mjs").then((m) => m.default),
10
- doc: () => import("./doc-DwxREqki.mjs").then((m) => m.default)
9
+ search: () => import("./search-sjRwA-la.mjs").then((m) => m.default),
10
+ doc: () => import("./doc-BtwmuoPs.mjs").then((m) => m.default)
11
11
  }
12
12
  });
13
13
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { n as writeError, t as formatCliArg } from "./cli.mjs";
2
- import { t as mcpCallPage } from "./mcp-result-De_0PPlD.mjs";
2
+ import { t as mcpCallPage } from "./mcp-result-Bl71pkOt.mjs";
3
3
  import { defineCommand } from "citty";
4
4
  //#region src/commands/project/list.ts
5
5
  /**
@@ -0,0 +1,77 @@
1
+ import { c as requireActiveProject } from "./project-store-D0UuLan2.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-B8InvGQc.mjs";
4
+ import { a as skillList } from "./skill-client-D4_QGDkj.mjs";
5
+ import { defineCommand } from "citty";
6
+ //#region src/commands/skill/list.ts
7
+ /**
8
+ * `beautx-cli skill list` — list visible Skill packages from the Skill BFF.
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 raw = args.type?.trim().toLowerCase();
34
+ let type;
35
+ if (raw === "personal" || raw === "tenant" || raw === "project") type = raw;
36
+ else if (raw) 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 };
@@ -1,8 +1,8 @@
1
- import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
1
+ import { c as requireActiveProject } from "./project-store-D0UuLan2.mjs";
2
2
  import { n as writeError, t as formatCliArg } from "./cli.mjs";
3
- import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-DK3IGaO1.mjs";
4
- import { t as mcpCallPage } from "./mcp-result-De_0PPlD.mjs";
5
- import { i as toLocalDateTime, r as mergeUserIds, t as csvToArray } from "./util-Bko-nm_R.mjs";
3
+ import { n as resolveProjectId, t as projectIdCliArg } from "./mcp-args-B8InvGQc.mjs";
4
+ import { t as mcpCallPage } from "./mcp-result-Bl71pkOt.mjs";
5
+ import { i as toLocalDateTime, r as mergeUserIds, t as csvToArray } from "./util-BtgWHKWv.mjs";
6
6
  import { defineCommand } from "citty";
7
7
  //#region src/commands/audio/list.ts
8
8
  /**