@puyinkai/xiaobao-cli 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/{admin-BOL_otwc.mjs → admin-P8LelYub.mjs} +2 -2
  2. package/dist/{analyze-mjHjOnz1.mjs → analyze-CmbVQDqC.mjs} +1 -1
  3. package/dist/{api-BaX_r5S5.mjs → api-_7z_Fgio.mjs} +1 -1
  4. package/dist/api-client-BebyDye_.mjs +128 -0
  5. package/dist/{audio-CDt1rpEL.mjs → audio-CNA0TaBz.mjs} +3 -3
  6. package/dist/{beautx-DytYVFvT.mjs → beautx-Co08xEOc.mjs} +4 -4
  7. package/dist/cli.mjs +18 -16
  8. package/dist/{config-GuXMTecJ.mjs → config-jn3N9DsG.mjs} +1 -1
  9. package/dist/{consultant-elv5arLG.mjs → consultant-CfuL1-Uu.mjs} +1 -1
  10. package/dist/{customer-CZ-nG9ku.mjs → customer-C_ojjf5a.mjs} +1 -1
  11. package/dist/{deal-analysis-Dqz34gLw.mjs → deal-analysis-DwqtomZD.mjs} +1 -1
  12. package/dist/{doc-CJT7BuhU.mjs → doc-BsRn2TaX.mjs} +1 -1
  13. package/dist/{doc-content-_SCykNvs.mjs → doc-content-DMF-a4YC.mjs} +1 -1
  14. package/dist/{docs-BHtwTAJ4.mjs → docs-Ce4TkZeo.mjs} +1 -1
  15. package/dist/{fields-BRE3oWMD.mjs → fields-Cco8H-4p.mjs} +1 -1
  16. package/dist/{focus-C4egr05X.mjs → focus-Bs3qqpTl.mjs} +1 -1
  17. package/dist/{follow-LwYQd9Bv.mjs → follow-D-51z9BP.mjs} +2 -2
  18. package/dist/{get-CbovJWSq.mjs → get-DcMz2swt.mjs} +1 -1
  19. package/dist/{kb-CyPqbezN.mjs → kb-CXBBbC_N.mjs} +4 -4
  20. package/dist/{list-CiNgcIXS.mjs → list-B2gkaQQF.mjs} +1 -1
  21. package/dist/{list-CT4t_FJs.mjs → list-BO4IL_tp.mjs} +1 -1
  22. package/dist/{list-2qqSxkDM.mjs → list-BTKZEhup.mjs} +1 -1
  23. package/dist/{list-FQpZk3vH.mjs → list-BoAIkKRp.mjs} +1 -1
  24. package/dist/{list-XIIj_ryX.mjs → list-BpbZHSO4.mjs} +1 -1
  25. package/dist/{list-OYeOGI0g.mjs → list-CJpEq6u4.mjs} +1 -1
  26. package/dist/{list-DWv6toPT.mjs → list-CNUQBB2l.mjs} +1 -1
  27. package/dist/{list-Ca5uJXDH.mjs → list-OvrNUjM8.mjs} +1 -1
  28. package/dist/{list-DXOlqJog.mjs → list-uusQMKfK.mjs} +1 -1
  29. package/dist/{plan-C35h8U-w.mjs → plan-oM0iPn4q.mjs} +1 -1
  30. package/dist/{portrait-BEDGkOx1.mjs → portrait-Ckz2Af0f.mjs} +2 -2
  31. package/dist/{portrait-tags-B9hPFDIF.mjs → portrait-tags-B7mHXpp0.mjs} +1 -1
  32. package/dist/{project-urShHaAN.mjs → project-CW4uEjIb.mjs} +1 -1
  33. package/dist/{qa-CaV_tDBc.mjs → qa-DbMd_iPm.mjs} +1 -1
  34. package/dist/{quantum-Ds7rlag3.mjs → quantum-BTOTuk_X.mjs} +1 -1
  35. package/dist/{resistance-DMesV4lG.mjs → resistance-DChhSmdw.mjs} +1 -1
  36. package/dist/{sales-report-BIfyfucO.mjs → sales-report-DTP3WBAx.mjs} +1 -1
  37. package/dist/{search-B0wA0YCI.mjs → search-lKk-wiFN.mjs} +1 -1
  38. package/dist/{shared-Bbxvn4ZI.mjs → shared-YIhF_DTb.mjs} +1 -1
  39. package/dist/{summary-BIx7F4AE.mjs → summary-CknPAx7J.mjs} +1 -1
  40. package/dist/{summary-BkxVcv8a.mjs → summary-Ds3sFDWE.mjs} +1 -1
  41. package/dist/{text-CqmsXzad.mjs → text-Cqz-DqQf.mjs} +1 -1
  42. package/dist/{token-usage-y46b3_7C.mjs → token-usage-DDWH_cxo.mjs} +1 -1
  43. package/dist/{visit-CmEtfs7n.mjs → visit-D2pk9wRw.mjs} +2 -2
  44. package/dist/{visit-evaluate-LdAg9iP5.mjs → visit-evaluate-BPA1X0oL.mjs} +1 -1
  45. package/package.json +1 -1
  46. package/dist/api-client-D3sCv6L3.mjs +0 -77
@@ -6,8 +6,8 @@ var admin_default = defineCommand({
6
6
  description: "super-admin 经营报表:公司经营数据(出库/回款)/ LLM token 用量(独立白名单)"
7
7
  },
8
8
  subCommands: {
9
- "sales-report": () => import("./sales-report-BIfyfucO.mjs").then((m) => m.default),
10
- "token-usage": () => import("./token-usage-y46b3_7C.mjs").then((m) => m.default)
9
+ "sales-report": () => import("./sales-report-DTP3WBAx.mjs").then((m) => m.default),
10
+ "token-usage": () => import("./token-usage-DDWH_cxo.mjs").then((m) => m.default)
11
11
  }
12
12
  });
13
13
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { t as loadActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -0,0 +1,128 @@
1
+ import { i as refreshToken } from "./device-flow-j10PFOQL.mjs";
2
+ import { a as isAccessTokenValid, l as writeToken, s as readToken } from "./token-store-BB7n-fwJ.mjs";
3
+ import { request } from "node:http";
4
+ import { request as request$1 } from "node:https";
5
+ //#region src/core/api-client.ts
6
+ /**
7
+ * HTTP client for wangxiaobao open API endpoints.
8
+ *
9
+ * Port of openclaw-xiaobao/src/core/api-client.ts. Difference: no
10
+ * workspaceDir param (CLI has a single global token, not per-agent
11
+ * isolation).
12
+ *
13
+ * Adds `Authorization: Bearer <accessToken>` automatically and retries once
14
+ * with a refreshed token on HTTP 401.
15
+ */
16
+ var NotAuthenticatedError = class extends Error {
17
+ code = "NOT_AUTHENTICATED";
18
+ hint = "运行 `xiaobao-cli auth login --no-wait` 发起登录,授权后运行 `xiaobao-cli auth login --resume` 完成。";
19
+ constructor() {
20
+ super("当前未登录或 token 已过期");
21
+ this.name = "NotAuthenticatedError";
22
+ }
23
+ };
24
+ async function ensureAccessToken(config) {
25
+ const cached = await readToken();
26
+ if (isAccessTokenValid(cached)) return cached.access_token;
27
+ if (cached?.refresh_token) return (await writeToken(await refreshToken(config, cached.refresh_token))).access_token;
28
+ throw new NotAuthenticatedError();
29
+ }
30
+ function buildUrl(apiBase, path, query) {
31
+ const url = new URL(path, apiBase);
32
+ if (query) for (const [k, v] of Object.entries(query)) url.searchParams.set(k, v);
33
+ return url.toString();
34
+ }
35
+ /**
36
+ * Single HTTP(S) request on Node's native http/https modules with
37
+ * `agent: false` — no connection pool, a fresh TCP connection per request,
38
+ * closed when the response ends (same behavior as curl). This avoids the
39
+ * intermittent "fetch failed" caused by undici's keep-alive pool reusing a
40
+ * connection the server has already half-closed.
41
+ */
42
+ function requestOnce(url, method, headers, body, timeoutMs) {
43
+ return new Promise((resolve, reject) => {
44
+ const u = new URL(url);
45
+ const req = (u.protocol === "http:" ? request : request$1)(u, {
46
+ method,
47
+ headers,
48
+ agent: false
49
+ }, (res) => {
50
+ const chunks = [];
51
+ res.on("data", (c) => chunks.push(c));
52
+ res.on("end", () => resolve({
53
+ status: res.statusCode ?? 0,
54
+ contentType: String(res.headers["content-type"] ?? ""),
55
+ text: Buffer.concat(chunks).toString("utf8")
56
+ }));
57
+ res.on("error", reject);
58
+ });
59
+ req.setTimeout(timeoutMs, () => {
60
+ const e = /* @__PURE__ */ new Error(`request timeout after ${timeoutMs}ms: ${method} ${url}`);
61
+ e.code = "XB_TIMEOUT";
62
+ req.destroy(e);
63
+ });
64
+ req.on("error", reject);
65
+ if (body != null) req.write(body);
66
+ req.end();
67
+ });
68
+ }
69
+ /**
70
+ * Retry transient network errors (ECONNRESET / EPIPE / connection refused…)
71
+ * with backoff 200ms → 400ms → 800ms, max 3 retries. Timeouts and HTTP error
72
+ * responses are NOT retried.
73
+ */
74
+ async function requestWithRetry(url, method, headers, body, timeoutMs) {
75
+ let lastErr;
76
+ for (let attempt = 0; attempt <= 3; attempt++) {
77
+ if (attempt > 0) await new Promise((r) => setTimeout(r, 200 * 2 ** (attempt - 1)));
78
+ try {
79
+ return await requestOnce(url, method, headers, body, timeoutMs);
80
+ } catch (err) {
81
+ lastErr = err;
82
+ if (err.code === "XB_TIMEOUT") throw err;
83
+ }
84
+ }
85
+ throw lastErr;
86
+ }
87
+ async function doFetch(url, method, token, opts) {
88
+ const headers = {
89
+ Accept: "application/json",
90
+ Authorization: `Bearer ${token}`,
91
+ ...opts.headers ?? {}
92
+ };
93
+ let body;
94
+ if (opts.body != null && method !== "GET" && method !== "DELETE") if (typeof opts.body === "string") body = opts.body;
95
+ else {
96
+ body = JSON.stringify(opts.body);
97
+ if (!headers["Content-Type"]) headers["Content-Type"] = "application/json";
98
+ }
99
+ const raw = await requestWithRetry(url, method, headers, body, opts.timeoutMs ?? 3e4);
100
+ const parsed = raw.contentType.includes("application/json") && raw.text ? JSON.parse(raw.text) : raw.text;
101
+ return {
102
+ status: raw.status,
103
+ ok: raw.status >= 200 && raw.status < 300,
104
+ parsed
105
+ };
106
+ }
107
+ /**
108
+ * Make an authenticated request to the wangxiaobao API. Refreshes on 401 once.
109
+ */
110
+ async function xbApiFetch(config, method, path, opts = {}) {
111
+ const url = buildUrl(config.apiBase, path, opts.query);
112
+ let token = await ensureAccessToken(config);
113
+ let result = await doFetch(url, method, token, opts);
114
+ if (result.status === 401) {
115
+ const cached = await readToken();
116
+ if (cached?.refresh_token) {
117
+ token = (await writeToken(await refreshToken(config, cached.refresh_token))).access_token;
118
+ result = await doFetch(url, method, token, opts);
119
+ }
120
+ }
121
+ return {
122
+ status: result.status,
123
+ ok: result.ok,
124
+ data: result.parsed
125
+ };
126
+ }
127
+ //#endregion
128
+ export { xbApiFetch as t };
@@ -6,9 +6,9 @@ var audio_default = defineCommand({
6
6
  description: "录音元数据分页 / 单条文本查询"
7
7
  },
8
8
  subCommands: {
9
- list: () => import("./list-CT4t_FJs.mjs").then((m) => m.default),
10
- text: () => import("./text-CqmsXzad.mjs").then((m) => m.default),
11
- analyze: () => import("./analyze-mjHjOnz1.mjs").then((m) => m.default)
9
+ list: () => import("./list-BO4IL_tp.mjs").then((m) => m.default),
10
+ text: () => import("./text-Cqz-DqQf.mjs").then((m) => m.default),
11
+ analyze: () => import("./analyze-CmbVQDqC.mjs").then((m) => m.default)
12
12
  }
13
13
  });
14
14
  //#endregion
@@ -6,10 +6,10 @@ var beautx_default = defineCommand({
6
6
  description: "医美:变美计划(plan) / 成交分析(deal-analysis) / 画像标签(portrait-tags) / 接诊评价(visit-evaluate)"
7
7
  },
8
8
  subCommands: {
9
- plan: () => import("./plan-C35h8U-w.mjs").then((m) => m.default),
10
- "deal-analysis": () => import("./deal-analysis-Dqz34gLw.mjs").then((m) => m.default),
11
- "portrait-tags": () => import("./portrait-tags-B9hPFDIF.mjs").then((m) => m.default),
12
- "visit-evaluate": () => import("./visit-evaluate-LdAg9iP5.mjs").then((m) => m.default)
9
+ plan: () => import("./plan-oM0iPn4q.mjs").then((m) => m.default),
10
+ "deal-analysis": () => import("./deal-analysis-DwqtomZD.mjs").then((m) => m.default),
11
+ "portrait-tags": () => import("./portrait-tags-B7mHXpp0.mjs").then((m) => m.default),
12
+ "visit-evaluate": () => import("./visit-evaluate-BPA1X0oL.mjs").then((m) => m.default)
13
13
  }
14
14
  });
15
15
  //#endregion
package/dist/cli.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { setDefaultResultOrder } from "node:dns";
2
3
  import { readFileSync } from "node:fs";
3
4
  import { dirname, join } from "node:path";
4
5
  import { fileURLToPath } from "node:url";
@@ -11,6 +12,7 @@ import { defineCommand, runMain } from "citty";
11
12
  * plus visit-summary, knowledge-base and quantum KPI stats — all proxied
12
13
  * through ai-open → wang-ai-mcp. See README for the full command map.
13
14
  */
15
+ setDefaultResultOrder("ipv4first");
14
16
  const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
15
17
  runMain(defineCommand({
16
18
  meta: {
@@ -20,23 +22,23 @@ runMain(defineCommand({
20
22
  },
21
23
  subCommands: {
22
24
  auth: () => import("./auth-sQwZSTNA.mjs").then((m) => m.default),
23
- project: () => import("./project-urShHaAN.mjs").then((m) => m.default),
24
- consultant: () => import("./consultant-elv5arLG.mjs").then((m) => m.default),
25
- audio: () => import("./audio-CDt1rpEL.mjs").then((m) => m.default),
26
- customer: () => import("./customer-CZ-nG9ku.mjs").then((m) => m.default),
27
- visit: () => import("./visit-CmEtfs7n.mjs").then((m) => m.default),
28
- focus: () => import("./focus-C4egr05X.mjs").then((m) => m.default),
29
- resistance: () => import("./resistance-DMesV4lG.mjs").then((m) => m.default),
30
- qa: () => import("./qa-CaV_tDBc.mjs").then((m) => m.default),
31
- kb: () => import("./kb-CyPqbezN.mjs").then((m) => m.default),
32
- quantum: () => import("./quantum-Ds7rlag3.mjs").then((m) => m.default),
33
- follow: () => import("./follow-LwYQd9Bv.mjs").then((m) => m.default),
34
- portrait: () => import("./portrait-BEDGkOx1.mjs").then((m) => m.default),
35
- config: () => import("./config-GuXMTecJ.mjs").then((m) => m.default),
36
- beautx: () => import("./beautx-DytYVFvT.mjs").then((m) => m.default),
25
+ project: () => import("./project-CW4uEjIb.mjs").then((m) => m.default),
26
+ consultant: () => import("./consultant-CfuL1-Uu.mjs").then((m) => m.default),
27
+ audio: () => import("./audio-CNA0TaBz.mjs").then((m) => m.default),
28
+ customer: () => import("./customer-C_ojjf5a.mjs").then((m) => m.default),
29
+ visit: () => import("./visit-D2pk9wRw.mjs").then((m) => m.default),
30
+ focus: () => import("./focus-Bs3qqpTl.mjs").then((m) => m.default),
31
+ resistance: () => import("./resistance-DChhSmdw.mjs").then((m) => m.default),
32
+ qa: () => import("./qa-DbMd_iPm.mjs").then((m) => m.default),
33
+ kb: () => import("./kb-CXBBbC_N.mjs").then((m) => m.default),
34
+ quantum: () => import("./quantum-BTOTuk_X.mjs").then((m) => m.default),
35
+ follow: () => import("./follow-D-51z9BP.mjs").then((m) => m.default),
36
+ portrait: () => import("./portrait-Ckz2Af0f.mjs").then((m) => m.default),
37
+ config: () => import("./config-jn3N9DsG.mjs").then((m) => m.default),
38
+ beautx: () => import("./beautx-Co08xEOc.mjs").then((m) => m.default),
37
39
  date: () => import("./date-BcQMKhIT.mjs").then((m) => m.default),
38
- admin: () => import("./admin-BOL_otwc.mjs").then((m) => m.default),
39
- api: () => import("./api-BaX_r5S5.mjs").then((m) => m.default)
40
+ admin: () => import("./admin-P8LelYub.mjs").then((m) => m.default),
41
+ api: () => import("./api-_7z_Fgio.mjs").then((m) => m.default)
40
42
  }
41
43
  }));
42
44
  //#endregion
@@ -5,7 +5,7 @@ var config_default = defineCommand({
5
5
  name: "config",
6
6
  description: "项目配置:客户字段配置(fields,解读 dynamic_tags 标签含义)"
7
7
  },
8
- subCommands: { fields: () => import("./fields-BRE3oWMD.mjs").then((m) => m.default) }
8
+ subCommands: { fields: () => import("./fields-Cco8H-4p.mjs").then((m) => m.default) }
9
9
  });
10
10
  //#endregion
11
11
  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-2qqSxkDM.mjs").then((m) => m.default) }
8
+ subCommands: { list: () => import("./list-BTKZEhup.mjs").then((m) => m.default) }
9
9
  });
10
10
  //#endregion
11
11
  export { consultant_default as default };
@@ -5,7 +5,7 @@ var customer_default = defineCommand({
5
5
  name: "customer",
6
6
  description: "客户画像分页查询"
7
7
  },
8
- subCommands: { list: () => import("./list-FQpZk3vH.mjs").then((m) => m.default) }
8
+ subCommands: { list: () => import("./list-BoAIkKRp.mjs").then((m) => m.default) }
9
9
  });
10
10
  //#endregion
11
11
  export { customer_default as default };
@@ -1,4 +1,4 @@
1
- import { t as defineBeautxCommand } from "./shared-Bbxvn4ZI.mjs";
1
+ import { t as defineBeautxCommand } from "./shared-YIhF_DTb.mjs";
2
2
  //#region src/commands/beautx/deal-analysis.ts
3
3
  var deal_analysis_default = defineBeautxCommand({
4
4
  name: "deal-analysis",
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -5,7 +5,7 @@ var focus_default = defineCommand({
5
5
  name: "focus",
6
6
  description: "客户关注点标签分页查询"
7
7
  },
8
- subCommands: { list: () => import("./list-OYeOGI0g.mjs").then((m) => m.default) }
8
+ subCommands: { list: () => import("./list-CJpEq6u4.mjs").then((m) => m.default) }
9
9
  });
10
10
  //#endregion
11
11
  export { focus_default as default };
@@ -6,8 +6,8 @@ var follow_default = defineCommand({
6
6
  description: "旺跟进:明细分页(list) / 电话微信指标汇总(summary)(聚合统计卡片用 quantum follow)"
7
7
  },
8
8
  subCommands: {
9
- list: () => import("./list-DXOlqJog.mjs").then((m) => m.default),
10
- summary: () => import("./summary-BkxVcv8a.mjs").then((m) => m.default)
9
+ list: () => import("./list-uusQMKfK.mjs").then((m) => m.default),
10
+ summary: () => import("./summary-Ds3sFDWE.mjs").then((m) => m.default)
11
11
  }
12
12
  });
13
13
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -6,10 +6,10 @@ var kb_default = defineCommand({
6
6
  description: "项目知识库:语义检索 / 文档列表 / 文档详情 / 文档正文分页"
7
7
  },
8
8
  subCommands: {
9
- search: () => import("./search-B0wA0YCI.mjs").then((m) => m.default),
10
- docs: () => import("./docs-BHtwTAJ4.mjs").then((m) => m.default),
11
- doc: () => import("./doc-CJT7BuhU.mjs").then((m) => m.default),
12
- "doc-content": () => import("./doc-content-_SCykNvs.mjs").then((m) => m.default)
9
+ search: () => import("./search-lKk-wiFN.mjs").then((m) => m.default),
10
+ docs: () => import("./docs-Ce4TkZeo.mjs").then((m) => m.default),
11
+ doc: () => import("./doc-BsRn2TaX.mjs").then((m) => m.default),
12
+ "doc-content": () => import("./doc-content-DMF-a4YC.mjs").then((m) => m.default)
13
13
  }
14
14
  });
15
15
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
4
4
  import { defineCommand } from "citty";
5
5
  //#region src/commands/project/list.ts
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,4 +1,4 @@
1
- import { t as defineBeautxCommand } from "./shared-Bbxvn4ZI.mjs";
1
+ import { t as defineBeautxCommand } from "./shared-YIhF_DTb.mjs";
2
2
  //#region src/commands/beautx/plan.ts
3
3
  var plan_default = defineBeautxCommand({
4
4
  name: "plan",
@@ -6,8 +6,8 @@ var portrait_default = defineCommand({
6
6
  description: "客户画像分布:字段清单(list) / 单字段饼图(get)(按画像筛客户用 customer list --portrait)"
7
7
  },
8
8
  subCommands: {
9
- list: () => import("./list-XIIj_ryX.mjs").then((m) => m.default),
10
- get: () => import("./get-CbovJWSq.mjs").then((m) => m.default)
9
+ list: () => import("./list-BpbZHSO4.mjs").then((m) => m.default),
10
+ get: () => import("./get-DcMz2swt.mjs").then((m) => m.default)
11
11
  }
12
12
  });
13
13
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as defineBeautxCommand } from "./shared-Bbxvn4ZI.mjs";
1
+ import { t as defineBeautxCommand } from "./shared-YIhF_DTb.mjs";
2
2
  //#region src/commands/beautx/portrait-tags.ts
3
3
  var portrait_tags_default = defineBeautxCommand({
4
4
  name: "portrait-tags",
@@ -6,7 +6,7 @@ var project_default = defineCommand({
6
6
  description: "查询 / 切换激活项目"
7
7
  },
8
8
  subCommands: {
9
- list: () => import("./list-Ca5uJXDH.mjs").then((m) => m.default),
9
+ list: () => import("./list-OvrNUjM8.mjs").then((m) => m.default),
10
10
  use: () => import("./use-rAR4OVC7.mjs").then((m) => m.default),
11
11
  current: () => import("./current-ABh6R3vp.mjs").then((m) => m.default)
12
12
  }
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -5,7 +5,7 @@ var resistance_default = defineCommand({
5
5
  name: "resistance",
6
6
  description: "客户抗性点标签分页查询"
7
7
  },
8
- subCommands: { list: () => import("./list-CiNgcIXS.mjs").then((m) => m.default) }
8
+ subCommands: { list: () => import("./list-B2gkaQQF.mjs").then((m) => m.default) }
9
9
  });
10
10
  //#endregion
11
11
  export { resistance_default as default };
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { t as loadActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { n as requireActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -1,5 +1,5 @@
1
1
  import { o as resolveConfig } from "./device-flow-j10PFOQL.mjs";
2
- import { t as xbApiFetch } from "./api-client-D3sCv6L3.mjs";
2
+ import { t as xbApiFetch } from "./api-client-BebyDye_.mjs";
3
3
  import { t as loadActiveProject } from "./project-store-CudTRvbA.mjs";
4
4
  import { t as tenantProjectHeaders } from "./headers-Dy5gROBB.mjs";
5
5
  import { n as writeResult, t as writeError } from "./format-DfVypHID.mjs";
@@ -6,8 +6,8 @@ var visit_default = defineCommand({
6
6
  description: "客户来访分页查询 / 来访接待总结"
7
7
  },
8
8
  subCommands: {
9
- list: () => import("./list-DWv6toPT.mjs").then((m) => m.default),
10
- summary: () => import("./summary-BIx7F4AE.mjs").then((m) => m.default)
9
+ list: () => import("./list-CNUQBB2l.mjs").then((m) => m.default),
10
+ summary: () => import("./summary-CknPAx7J.mjs").then((m) => m.default)
11
11
  }
12
12
  });
13
13
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as defineBeautxCommand } from "./shared-Bbxvn4ZI.mjs";
1
+ import { t as defineBeautxCommand } from "./shared-YIhF_DTb.mjs";
2
2
  //#region src/commands/beautx/visit-evaluate.ts
3
3
  var visit_evaluate_default = defineBeautxCommand({
4
4
  name: "visit-evaluate",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puyinkai/xiaobao-cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "旺小宝 CLI — host-agnostic 业务数据 / 问数 / 来访总结 / 知识库 能力 (openclaw-xiaobao plugin 的 CLI 等价物)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,77 +0,0 @@
1
- import { i as refreshToken } from "./device-flow-j10PFOQL.mjs";
2
- import { a as isAccessTokenValid, l as writeToken, s as readToken } from "./token-store-BB7n-fwJ.mjs";
3
- //#region src/core/api-client.ts
4
- /**
5
- * HTTP client for wangxiaobao open API endpoints.
6
- *
7
- * Port of openclaw-xiaobao/src/core/api-client.ts. Difference: no
8
- * workspaceDir param (CLI has a single global token, not per-agent
9
- * isolation).
10
- *
11
- * Adds `Authorization: Bearer <accessToken>` automatically and retries once
12
- * with a refreshed token on HTTP 401.
13
- */
14
- var NotAuthenticatedError = class extends Error {
15
- code = "NOT_AUTHENTICATED";
16
- hint = "运行 `xiaobao-cli auth login --no-wait` 发起登录,授权后运行 `xiaobao-cli auth login --resume` 完成。";
17
- constructor() {
18
- super("当前未登录或 token 已过期");
19
- this.name = "NotAuthenticatedError";
20
- }
21
- };
22
- async function ensureAccessToken(config) {
23
- const cached = await readToken();
24
- if (isAccessTokenValid(cached)) return cached.access_token;
25
- if (cached?.refresh_token) return (await writeToken(await refreshToken(config, cached.refresh_token))).access_token;
26
- throw new NotAuthenticatedError();
27
- }
28
- function buildUrl(apiBase, path, query) {
29
- const url = new URL(path, apiBase);
30
- if (query) for (const [k, v] of Object.entries(query)) url.searchParams.set(k, v);
31
- return url.toString();
32
- }
33
- async function doFetch(url, method, token, opts) {
34
- const headers = {
35
- Accept: "application/json",
36
- Authorization: `Bearer ${token}`,
37
- ...opts.headers ?? {}
38
- };
39
- let body;
40
- if (opts.body != null && method !== "GET" && method !== "DELETE") if (typeof opts.body === "string") body = opts.body;
41
- else {
42
- body = JSON.stringify(opts.body);
43
- if (!headers["Content-Type"]) headers["Content-Type"] = "application/json";
44
- }
45
- const resp = await fetch(url, {
46
- method,
47
- headers,
48
- body,
49
- signal: AbortSignal.timeout(opts.timeoutMs ?? 3e4)
50
- });
51
- return {
52
- resp,
53
- parsed: (resp.headers.get("content-type") || "").includes("application/json") ? await resp.json() : await resp.text()
54
- };
55
- }
56
- /**
57
- * Make an authenticated request to the wangxiaobao API. Refreshes on 401 once.
58
- */
59
- async function xbApiFetch(config, method, path, opts = {}) {
60
- const url = buildUrl(config.apiBase, path, opts.query);
61
- let token = await ensureAccessToken(config);
62
- let { resp, parsed } = await doFetch(url, method, token, opts);
63
- if (resp.status === 401) {
64
- const cached = await readToken();
65
- if (cached?.refresh_token) {
66
- token = (await writeToken(await refreshToken(config, cached.refresh_token))).access_token;
67
- ({resp, parsed} = await doFetch(url, method, token, opts));
68
- }
69
- }
70
- return {
71
- status: resp.status,
72
- ok: resp.ok,
73
- data: parsed
74
- };
75
- }
76
- //#endregion
77
- export { xbApiFetch as t };