beautx-cli 1.0.6-beta.2 → 1.0.6-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 +16 -17
- package/dist/{analyze-0SATHpUC.mjs → analyze-Cq-Hmoqp.mjs} +6 -6
- package/dist/{api-D3JyDoiw.mjs → api-jIGM86TK.mjs} +2 -2
- package/dist/{audio-BfNibfXF.mjs → audio-p2QCYFdq.mjs} +3 -3
- package/dist/{beauty-plan-DQl_OJNK.mjs → beauty-plan-CgSmAhn8.mjs} +4 -4
- package/dist/cli.mjs +7636 -19
- package/dist/config-DAVi_CuD.mjs +15 -0
- package/dist/{consultant-DbYBzHqQ.mjs → consultant-CPecFRiS.mjs} +1 -1
- package/dist/{content-BTHG2DCs.mjs → content-Bq_jEIl6.mjs} +3 -3
- package/dist/{current-BDH1xER9.mjs → current-D4fh-53q.mjs} +3 -3
- package/dist/{customer-D04eXm64.mjs → customer-DWG47eAT.mjs} +1 -1
- package/dist/{deal-analysis-Dpg9VGjK.mjs → deal-analysis-Cn2wCaoU.mjs} +4 -4
- package/dist/{doc-CWgdZ_Eh.mjs → doc-DwxREqki.mjs} +3 -3
- package/dist/doctor-RwDPp4y3.mjs +37 -0
- package/dist/{fields-D-iEk93w.mjs → fields-BGogOrgD.mjs} +4 -4
- package/dist/{focus-BMcnVGqT.mjs → focus-BE8BT835.mjs} +1 -1
- package/dist/{get-BLdqZ3XJ.mjs → get-BKCE22jj.mjs} +3 -3
- package/dist/{kb-BPy6E_uX.mjs → kb-BsiBl_ul.mjs} +2 -2
- package/dist/list-BUYSLNqZ.mjs +83 -0
- package/dist/{list-JL2fmylz.mjs → list-BYLk3sNv.mjs} +5 -5
- package/dist/{list-CB7YZTB4.mjs → list-BcYy7Ejx.mjs} +5 -5
- package/dist/{list-C73pWNBd.mjs → list-BmVWcUI7.mjs} +2 -2
- package/dist/{list-Ck_kx-iC.mjs → list-BzmkW4Iq.mjs} +5 -5
- package/dist/{list-DyePBi8K.mjs → list-Cnz5CuQB.mjs} +5 -5
- package/dist/{list-DqXRvhfS.mjs → list-Cs1kF7EB.mjs} +5 -5
- package/dist/{list-BMbWa85R.mjs → list-DJscF_8M.mjs} +5 -5
- package/dist/{list-DIvD8BvI.mjs → list-DVy4Czfy.mjs} +5 -5
- package/dist/{mcp-args-CYOCdClW.mjs → mcp-args-DK3IGaO1.mjs} +1 -1
- package/dist/{mcp-client-OuKd8iir.mjs → mcp-client-BTZH22b5.mjs} +37 -76
- package/dist/{mcp-result-B5HHO7ap.mjs → mcp-result-De_0PPlD.mjs} +2 -2
- package/dist/{portrait-tags-DRQi5JcR.mjs → portrait-tags-I57TgDAx.mjs} +4 -4
- package/dist/{project-CEmZCvSp.mjs → project-K-HkeM57.mjs} +3 -3
- package/dist/project-access-Bf87OLJP.mjs +2 -0
- package/dist/{project-access-O-VSqqVC.mjs → project-access-pTN7ry15.mjs} +20 -30
- package/dist/project-store-DDVZ7T4t.mjs +2 -0
- package/dist/project-store-Dl35JzZr.mjs +424 -0
- package/dist/{qa-B7WbwUts.mjs → qa-gAtF6cSk.mjs} +6 -6
- package/dist/{resistance-FtBtoEDl.mjs → resistance-DGU99Bwi.mjs} +1 -1
- package/dist/{search-BuMtyCiU.mjs → search-C16CzRep.mjs} +6 -6
- package/dist/{summary-Cg79V9oz.mjs → summary-DgpSsQh9.mjs} +5 -5
- package/dist/{text-CGOU6uh9.mjs → text-BIIl7PmC.mjs} +5 -5
- package/dist/{use-Bzhvb9I3.mjs → use-D_HBqdev.mjs} +8 -6
- package/dist/{visit-vaoFdiLr.mjs → visit-DnUPj-8i.mjs} +2 -2
- package/dist/{visit-evaluate-BQIyxZeM.mjs → visit-evaluate-DM7oCk6R.mjs} +4 -4
- package/dist/{visit-query-args-CDDQ9JJ8.mjs → visit-query-args-BD3Dw-9F.mjs} +3 -3
- package/package.json +1 -1
- package/dist/config-C8aqUXV7.mjs +0 -14
- package/dist/env-callback-CIXEvt0i.mjs +0 -349
- package/dist/env-vars-CXEHR_mk.mjs +0 -231
- package/dist/format-9T59sVxH.mjs +0 -7253
- package/dist/list-FCCClcl-.mjs +0 -64
- package/dist/project-store-DHqT0-nk.mjs +0 -55
- /package/dist/{util-BtgWHKWv.mjs → util-Bko-nm_R.mjs} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
//#region src/commands/config/index.ts
|
|
3
|
+
var config_default = defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "config",
|
|
6
|
+
description: "沙箱配置:list 只读诊断;doctor 自检;fields 客户字段字典"
|
|
7
|
+
},
|
|
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)
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { config_default as default };
|
|
@@ -5,7 +5,7 @@ var consultant_default = defineCommand({
|
|
|
5
5
|
name: "consultant",
|
|
6
6
|
description: "查询有权限的顾问列表"
|
|
7
7
|
},
|
|
8
|
-
subCommands: { list: () => import("./list-
|
|
8
|
+
subCommands: { list: () => import("./list-Cs1kF7EB.mjs").then((m) => m.default) }
|
|
9
9
|
});
|
|
10
10
|
//#endregion
|
|
11
11
|
export { consultant_default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { n as
|
|
3
|
-
import { n as writeMcpDataResult } from "./mcp-result-
|
|
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";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
//#region src/commands/kb/doc/content.ts
|
|
6
6
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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
5
|
/**
|
|
6
|
-
* `beautx-cli project current` — show the currently active project
|
|
6
|
+
* `beautx-cli project current` — show the currently active project (QCA current-project).
|
|
7
7
|
*/
|
|
8
8
|
var current_default = defineCommand({
|
|
9
9
|
meta: {
|
|
@@ -5,7 +5,7 @@ var customer_default = defineCommand({
|
|
|
5
5
|
name: "customer",
|
|
6
6
|
description: "客户画像分页查询"
|
|
7
7
|
},
|
|
8
|
-
subCommands: { list: () => import("./list-
|
|
8
|
+
subCommands: { list: () => import("./list-DJscF_8M.mjs").then((m) => m.default) }
|
|
9
9
|
});
|
|
10
10
|
//#endregion
|
|
11
11
|
export { customer_default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as visitBatchQueryCliArgs, t as buildVisitBatchQueryArgs } from "./visit-query-args-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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";
|
|
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-
|
|
10
|
-
get: () => import("./get-
|
|
11
|
-
content: () => import("./content-
|
|
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)
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
//#endregion
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { c as runPreflight, n as writeError, r as writeResult, t as formatCliArg } from "./cli.mjs";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
//#region src/commands/config/doctor.ts
|
|
4
|
+
/**
|
|
5
|
+
* `beautx-cli config doctor` — manual preflight (presence only; never prints secrets).
|
|
6
|
+
*/
|
|
7
|
+
var doctor_default = defineCommand({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "doctor",
|
|
10
|
+
description: "自检:检查 Host env 与当前项目/AT 是否已就绪(只报存在性,不打印密钥)"
|
|
11
|
+
},
|
|
12
|
+
args: { format: formatCliArg },
|
|
13
|
+
async run({ args }) {
|
|
14
|
+
const format = typeof args.format === "string" ? args.format : void 0;
|
|
15
|
+
try {
|
|
16
|
+
const report = await runPreflight();
|
|
17
|
+
writeResult({
|
|
18
|
+
ok: report.ok,
|
|
19
|
+
checks: report.checks.map((c) => ({
|
|
20
|
+
id: c.id,
|
|
21
|
+
ok: c.ok,
|
|
22
|
+
...c.ok ? {} : {
|
|
23
|
+
code: c.code,
|
|
24
|
+
message: c.message,
|
|
25
|
+
hint: c.hint
|
|
26
|
+
}
|
|
27
|
+
}))
|
|
28
|
+
}, format);
|
|
29
|
+
if (!report.ok) process.exit(1);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
writeError(err, format);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
//#endregion
|
|
37
|
+
export { doctor_default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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
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-
|
|
8
|
+
subCommands: { list: () => import("./list-BYLk3sNv.mjs").then((m) => m.default) }
|
|
9
9
|
});
|
|
10
10
|
//#endregion
|
|
11
11
|
export { focus_default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { n as
|
|
3
|
-
import { n as writeMcpDataResult } from "./mcp-result-
|
|
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";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
//#region src/commands/kb/doc/get.ts
|
|
6
6
|
/**
|
|
@@ -6,8 +6,8 @@ var kb_default = defineCommand({
|
|
|
6
6
|
description: "知识库检索与文档查询"
|
|
7
7
|
},
|
|
8
8
|
subCommands: {
|
|
9
|
-
search: () => import("./search-
|
|
10
|
-
doc: () => import("./doc-
|
|
9
|
+
search: () => import("./search-C16CzRep.mjs").then((m) => m.default),
|
|
10
|
+
doc: () => import("./doc-DwxREqki.mjs").then((m) => m.default)
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
//#endregion
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { _ as readEnv, a as isProjectSwitchAllowed, f as credentialStatus, g as readCredentials, o as loadActiveProject, p as isEnvInjectedByHost, u as ENV_KEYS, y as resolveEndpoints } from "./project-store-Dl35JzZr.mjs";
|
|
2
|
+
import { n as writeError, o as debugLogPath, r as writeResult, s as isVerboseDebugEnabled, t as formatCliArg } from "./cli.mjs";
|
|
3
|
+
import { defineCommand } from "citty";
|
|
4
|
+
//#region src/core/mask-env.ts
|
|
5
|
+
/**
|
|
6
|
+
* Mask env / secret values for agent-facing diagnostics.
|
|
7
|
+
* len <= 4 → as-is; else stars for the hidden prefix + last 4 chars.
|
|
8
|
+
* Never returns the full secret when length > 4.
|
|
9
|
+
*/
|
|
10
|
+
function maskEnvValue(value) {
|
|
11
|
+
const v = value?.trim() ?? "";
|
|
12
|
+
if (!v) return null;
|
|
13
|
+
if (v.length <= 4) return v;
|
|
14
|
+
return "*".repeat(v.length - 4) + v.slice(-4);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/commands/config/list.ts
|
|
18
|
+
/**
|
|
19
|
+
* `beautx-cli config list` — agent-facing env diagnostics (secrets redacted).
|
|
20
|
+
*/
|
|
21
|
+
var list_default = defineCommand({
|
|
22
|
+
meta: {
|
|
23
|
+
name: "list",
|
|
24
|
+
description: "列出当前配置(脱敏:星号+后四位;含凭据过期时间)"
|
|
25
|
+
},
|
|
26
|
+
args: { format: formatCliArg },
|
|
27
|
+
async run({ args }) {
|
|
28
|
+
try {
|
|
29
|
+
const endpoints = resolveEndpoints();
|
|
30
|
+
const creds = readCredentials();
|
|
31
|
+
const accessView = credentialStatus(creds);
|
|
32
|
+
const refreshConfigured = Boolean(creds.refreshToken);
|
|
33
|
+
const active = await loadActiveProject();
|
|
34
|
+
writeResult({
|
|
35
|
+
env: maskEnvValue(endpoints.env) ?? endpoints.env,
|
|
36
|
+
deploymentEnvManagedByHost: true,
|
|
37
|
+
envInjectedByHost: isEnvInjectedByHost(),
|
|
38
|
+
projectUseAllowed: isProjectSwitchAllowed(),
|
|
39
|
+
gatewayUrl: endpoints.gatewayUrl,
|
|
40
|
+
authUrl: endpoints.authUrl,
|
|
41
|
+
callbackBaseUrl: endpoints.callbackBaseUrl,
|
|
42
|
+
urlProfileSource: "src/core/endpoints.ts",
|
|
43
|
+
configSource: "environment",
|
|
44
|
+
credentialsManagedBy: "host",
|
|
45
|
+
credentials: {
|
|
46
|
+
accessToken: accessView,
|
|
47
|
+
refreshToken: { configured: refreshConfigured },
|
|
48
|
+
sandboxTenantSecret: {
|
|
49
|
+
configured: Boolean(readEnv(ENV_KEYS.SANDBOX_TENANT_SECRET)),
|
|
50
|
+
preview: maskEnvValue(readEnv(ENV_KEYS.SANDBOX_TENANT_SECRET))
|
|
51
|
+
},
|
|
52
|
+
sandboxUserSecret: {
|
|
53
|
+
configured: Boolean(readEnv(ENV_KEYS.SANDBOX_USER_SECRET)),
|
|
54
|
+
preview: maskEnvValue(readEnv(ENV_KEYS.SANDBOX_USER_SECRET))
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
user: {
|
|
58
|
+
userId: maskEnvValue(readEnv(ENV_KEYS.USER_ID)),
|
|
59
|
+
userName: maskEnvValue(readEnv(ENV_KEYS.USER_NAME))
|
|
60
|
+
},
|
|
61
|
+
activeProject: active ? {
|
|
62
|
+
configured: true,
|
|
63
|
+
tenantId: maskEnvValue(active.tenantId),
|
|
64
|
+
tenantName: maskEnvValue(active.tenantName),
|
|
65
|
+
projectId: maskEnvValue(active.projectId),
|
|
66
|
+
projectName: maskEnvValue(active.projectName),
|
|
67
|
+
source: active.source
|
|
68
|
+
} : { configured: false },
|
|
69
|
+
xbAppId: maskEnvValue(readEnv(ENV_KEYS.XB_APP_ID)),
|
|
70
|
+
debugLog: {
|
|
71
|
+
path: debugLogPath(),
|
|
72
|
+
errorsAlwaysLogged: true,
|
|
73
|
+
verboseTracing: isVerboseDebugEnabled()
|
|
74
|
+
}
|
|
75
|
+
}, args.format);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
writeError(err, args.format);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
//#endregion
|
|
83
|
+
export { list_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { i as toLocalDateTime, t as csvToArray } from "./util-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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, t as csvToArray } from "./util-Bko-nm_R.mjs";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/focus/list.ts
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { i as toLocalDateTime } from "./util-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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 } from "./util-Bko-nm_R.mjs";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/visit/list.ts
|
|
8
8
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as writeError, t as formatCliArg } from "./
|
|
2
|
-
import { t as mcpCallPage } from "./mcp-result-
|
|
1
|
+
import { n as writeError, t as formatCliArg } from "./cli.mjs";
|
|
2
|
+
import { t as mcpCallPage } from "./mcp-result-De_0PPlD.mjs";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
//#region src/commands/project/list.ts
|
|
5
5
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as writeError, t as formatCliArg } from "./
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
2
|
+
import { n as writeError, t as formatCliArg } from "./cli.mjs";
|
|
3
|
+
import { n as mcpCall } from "./mcp-client-BTZH22b5.mjs";
|
|
4
|
+
import { i as tenantIdCliArg, n as resolveProjectId, r as resolveTenantId, t as projectIdCliArg } from "./mcp-args-DK3IGaO1.mjs";
|
|
5
|
+
import { n as writeMcpDataResult } from "./mcp-result-De_0PPlD.mjs";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/kb/doc/list.ts
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { i as toLocalDateTime, r as mergeUserIds, t as csvToArray } from "./util-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/audio/list.ts
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as writeError, t as formatCliArg } from "./
|
|
3
|
-
import { n as
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/consultant/list.ts
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { i as toLocalDateTime } from "./util-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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 } from "./util-Bko-nm_R.mjs";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/customer/list.ts
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { i as toLocalDateTime, t as csvToArray } from "./util-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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, t as csvToArray } from "./util-Bko-nm_R.mjs";
|
|
6
6
|
import { defineCommand } from "citty";
|
|
7
7
|
//#region src/commands/resistance/list.ts
|
|
8
8
|
/**
|
|
@@ -1,65 +1,7 @@
|
|
|
1
1
|
import { n as __exportAll } from "./rolldown-runtime-YLnNgb9a.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { i as debugLogInfo, n as persistTokensToHost, r as debugLogError } from "./env-callback-CIXEvt0i.mjs";
|
|
2
|
+
import { C as MissingAccessTokenError, _ as readEnv, d as assertEndpointsValid, u as ENV_KEYS, w as MissingGatewayError, y as resolveEndpoints } from "./project-store-Dl35JzZr.mjs";
|
|
3
|
+
import { a as debugLogInfo, i as debugLogError, l as ensureAuth } from "./cli.mjs";
|
|
5
4
|
import { randomUUID } from "node:crypto";
|
|
6
|
-
//#region src/core/token-refresh.ts
|
|
7
|
-
/**
|
|
8
|
-
* Silent OAuth refresh_token grant — used by ensureAuth, not exposed as a command.
|
|
9
|
-
*/
|
|
10
|
-
async function refreshAccessToken(authUrl, refreshToken) {
|
|
11
|
-
const base = authUrl.replace(/\/$/, "");
|
|
12
|
-
const body = new URLSearchParams({
|
|
13
|
-
grant_type: "refresh_token",
|
|
14
|
-
refresh_token: refreshToken
|
|
15
|
-
});
|
|
16
|
-
const clientId = process.env.MCP_CLIENT_ID?.trim();
|
|
17
|
-
if (clientId) body.set("client_id", clientId);
|
|
18
|
-
const resp = await fetch(`${base}/oauth/token`, {
|
|
19
|
-
method: "POST",
|
|
20
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
21
|
-
body: body.toString(),
|
|
22
|
-
signal: AbortSignal.timeout(3e4)
|
|
23
|
-
});
|
|
24
|
-
const parsed = await resp.json().catch(() => ({}));
|
|
25
|
-
if (!resp.ok) {
|
|
26
|
-
const msg = parsed.error_description ?? parsed.error ?? resp.statusText;
|
|
27
|
-
throw new RefreshFailedError(String(msg));
|
|
28
|
-
}
|
|
29
|
-
const access = parsed.access_token;
|
|
30
|
-
if (typeof access !== "string" || !access) throw new RefreshFailedError("响应缺少 access_token");
|
|
31
|
-
return {
|
|
32
|
-
access_token: access,
|
|
33
|
-
refresh_token: typeof parsed.refresh_token === "string" ? parsed.refresh_token : void 0,
|
|
34
|
-
expires_in: typeof parsed.expires_in === "number" ? parsed.expires_in : void 0,
|
|
35
|
-
scope: typeof parsed.scope === "string" ? parsed.scope : void 0
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/core/ensure-auth.ts
|
|
40
|
-
/**
|
|
41
|
-
* Pre-MCP auth guard — refresh tokens via Host callback when expiring soon.
|
|
42
|
-
*/
|
|
43
|
-
/**
|
|
44
|
-
* Ensure MCP_TOKEN is valid before an MCP call.
|
|
45
|
-
* Refreshes via OAuth + Host env callback when within REFRESH_BUFFER_MS of expiry.
|
|
46
|
-
*/
|
|
47
|
-
async function ensureAuth(opts = {}) {
|
|
48
|
-
const endpoints = resolveEndpoints();
|
|
49
|
-
const creds = readCredentials();
|
|
50
|
-
if (!(opts.force === true) && creds.accessToken && !isTokenExpired(creds.expiresAt) && !needsRefresh(creds.expiresAt)) return;
|
|
51
|
-
if (!creds.refreshToken) {
|
|
52
|
-
if (!creds.accessToken) throw new MissingAccessTokenError();
|
|
53
|
-
if (isTokenExpired(creds.expiresAt)) throw new AccessTokenExpiredError();
|
|
54
|
-
throw new MissingRefreshTokenError();
|
|
55
|
-
}
|
|
56
|
-
if (!endpoints.authUrl?.trim()) throw new RefreshFailedError("缺少 auth_url");
|
|
57
|
-
const tokens = await refreshAccessToken(endpoints.authUrl, creds.refreshToken);
|
|
58
|
-
const expiresAtMs = tokens.expires_in != null ? Date.now() + tokens.expires_in * 1e3 : Date.now() + 9e5;
|
|
59
|
-
await persistTokensToHost(tokens.access_token, tokens.refresh_token ?? creds.refreshToken, expiresAtMs);
|
|
60
|
-
invalidateProjectAccessCache();
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
5
|
//#region src/core/config.ts
|
|
64
6
|
/**
|
|
65
7
|
* MCP gateway configuration — env-only resolution.
|
|
@@ -82,16 +24,21 @@ async function resolveMcpConfig() {
|
|
|
82
24
|
/**
|
|
83
25
|
* Normalize MCP tools/call arguments before they hit the gateway wire.
|
|
84
26
|
*
|
|
85
|
-
* - project-list: always attach
|
|
27
|
+
* - {@code project-list}: always attach default {@code project_id} (gateway billing),
|
|
86
28
|
* ignoring any CLI-supplied value.
|
|
87
|
-
* -
|
|
88
|
-
* audit / billing
|
|
29
|
+
* - All other tools: attach {@code project_id} from default when callers omit it
|
|
30
|
+
* (audit / billing on gateway even when application ignores the field).
|
|
31
|
+
*
|
|
32
|
+
* {@code defaultProjectId} comes from QCA `/out/v2/current-project` (not process.env).
|
|
89
33
|
*/
|
|
90
|
-
function augmentMcpWireArguments(toolName, args) {
|
|
91
|
-
const estateId =
|
|
34
|
+
function augmentMcpWireArguments(toolName, args, defaultProjectId) {
|
|
35
|
+
const estateId = defaultProjectId?.trim() || "";
|
|
92
36
|
if (toolName === "project-list") {
|
|
37
|
+
if (!estateId) {
|
|
38
|
+
const { project_id: _drop, ...rest } = args;
|
|
39
|
+
return rest;
|
|
40
|
+
}
|
|
93
41
|
const { project_id: _drop, ...rest } = args;
|
|
94
|
-
if (!estateId) return rest;
|
|
95
42
|
return {
|
|
96
43
|
...rest,
|
|
97
44
|
project_id: estateId
|
|
@@ -117,6 +64,7 @@ var mcp_client_exports = /* @__PURE__ */ __exportAll({
|
|
|
117
64
|
MCP_CALL_SOURCE: () => MCP_CALL_SOURCE,
|
|
118
65
|
MCP_SERVICE_CODE: () => MCP_SERVICE_CODE,
|
|
119
66
|
McpGatewayError: () => McpGatewayError,
|
|
67
|
+
buildMcpHttpHeaders: () => buildMcpHttpHeaders,
|
|
120
68
|
mcpCall: () => mcpCall,
|
|
121
69
|
unwrapMcpToolEnvelope: () => unwrapMcpToolEnvelope
|
|
122
70
|
});
|
|
@@ -150,9 +98,9 @@ function unwrapMcpToolEnvelope(mcpResult) {
|
|
|
150
98
|
return {};
|
|
151
99
|
}
|
|
152
100
|
const ERROR_HINTS = {
|
|
153
|
-
TOKEN_MISSING: "
|
|
154
|
-
TOKEN_INVALID: "
|
|
155
|
-
TOKEN_EXPIRED: "
|
|
101
|
+
TOKEN_MISSING: "向 /out/v2/mcp-token 借 AT:确认 SANDBOX_*_SECRET 已注入且 PC/App 已完成 MCP 凭证初始化",
|
|
102
|
+
TOKEN_INVALID: "重新调用 CLI 向 Token Broker 借新 AT",
|
|
103
|
+
TOKEN_EXPIRED: "重新调用 CLI 向 Token Broker 借新 AT",
|
|
156
104
|
TOKEN_AUD_MISMATCH: "确认 token 为 MCP 网关签发且 scope 含 mcp:invoke",
|
|
157
105
|
POLICY_DENIED: "无权访问该服务,请联系管理员确认 serviceCode 权限",
|
|
158
106
|
SERVICE_NOT_FOUND: "serviceCode 不存在,请确认网关侧已注册",
|
|
@@ -171,12 +119,29 @@ var McpGatewayError = class extends Error {
|
|
|
171
119
|
this.hint = ERROR_HINTS[code] ?? `MCP 网关错误: ${code}`;
|
|
172
120
|
}
|
|
173
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* Bearer token header stays live; the sandbox {@code SESSION_ID} (when present)
|
|
124
|
+
* is attached as {@code X-MCP-Session-Id} so the MCP gateway can correlate the
|
|
125
|
+
* originating session. Absent {@code SESSION_ID} → header omitted.
|
|
126
|
+
*/
|
|
127
|
+
function buildMcpHttpHeaders(token) {
|
|
128
|
+
const headers = {
|
|
129
|
+
Accept: "application/json, text/event-stream",
|
|
130
|
+
"Content-Type": "application/json",
|
|
131
|
+
Authorization: `Bearer ${token}`
|
|
132
|
+
};
|
|
133
|
+
const sessionId = readEnv(ENV_KEYS.SESSION_ID)?.trim();
|
|
134
|
+
if (sessionId) headers["X-MCP-Session-Id"] = sessionId;
|
|
135
|
+
return headers;
|
|
136
|
+
}
|
|
174
137
|
async function mcpCall(toolName, opts) {
|
|
175
|
-
const
|
|
138
|
+
const { loadActiveProject } = await import("./project-store-DDVZ7T4t.mjs");
|
|
139
|
+
const active = await loadActiveProject();
|
|
140
|
+
const wireArguments = augmentMcpWireArguments(toolName, opts.arguments ?? {}, active?.projectId);
|
|
176
141
|
if (toolName !== "project-list") {
|
|
177
142
|
const rawProjectId = wireArguments.project_id;
|
|
178
143
|
if (rawProjectId != null && String(rawProjectId).trim()) {
|
|
179
|
-
const { assertProjectAllowed } = await import("./project-access-
|
|
144
|
+
const { assertProjectAllowed } = await import("./project-access-Bf87OLJP.mjs");
|
|
180
145
|
await assertProjectAllowed(String(rawProjectId).trim());
|
|
181
146
|
}
|
|
182
147
|
}
|
|
@@ -204,11 +169,7 @@ async function mcpCallOnce(toolName, opts, retriedAfterRefresh) {
|
|
|
204
169
|
});
|
|
205
170
|
const resp = await fetch(url, {
|
|
206
171
|
method: "POST",
|
|
207
|
-
headers:
|
|
208
|
-
Accept: "application/json, text/event-stream",
|
|
209
|
-
"Content-Type": "application/json",
|
|
210
|
-
Authorization: `Bearer ${config.token}`
|
|
211
|
-
},
|
|
172
|
+
headers: buildMcpHttpHeaders(config.token),
|
|
212
173
|
body,
|
|
213
174
|
signal: AbortSignal.timeout(opts.timeoutMs ?? 3e4)
|
|
214
175
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as writeError, r as writeResult } from "./cli.mjs";
|
|
2
|
+
import { i as unwrapMcpToolEnvelope, n as mcpCall } from "./mcp-client-BTZH22b5.mjs";
|
|
3
3
|
//#region src/core/mcp-result.ts
|
|
4
4
|
/**
|
|
5
5
|
* Normalize MCP tool responses for agent-friendly stdout (TOON tabular arrays).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as visitBatchQueryCliArgs, t as buildVisitBatchQueryArgs } from "./visit-query-args-
|
|
1
|
+
import { c as requireActiveProject } from "./project-store-Dl35JzZr.mjs";
|
|
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";
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
//#region src/commands/portrait-tags/index.ts
|
|
7
7
|
/**
|
|
@@ -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-BmVWcUI7.mjs").then((m) => m.default),
|
|
10
|
+
use: () => import("./use-D_HBqdev.mjs").then((m) => m.default),
|
|
11
|
+
current: () => import("./current-D4fh-53q.mjs").then((m) => m.default)
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
//#endregion
|