@thinkingai/ae-cli 6.1.27 → 6.1.29

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 (177) hide show
  1. package/README.md +52 -6
  2. package/README.zh.md +52 -6
  3. package/bin/ae-cli.js +5 -0
  4. package/bin/runtime-capabilities.json +5 -0
  5. package/cli-installation-guide.md +24 -3
  6. package/dist/{auth-WA7YGGRT.js → auth-OBQ5KVQM.js} +175 -45
  7. package/dist/{automation-VAAQBM7Y.js → automation-NAR5DDGL.js} +94 -38
  8. package/dist/{capability-GAAYJ3IQ.js → capability-LFSVNI5B.js} +57 -28
  9. package/dist/chunk-2UW3Y463.js +2289 -0
  10. package/dist/{chunk-VZZNLV3I.js → chunk-3SDHJOCR.js} +68 -18
  11. package/dist/chunk-6HAUVWOQ.js +132 -0
  12. package/dist/{chunk-5XJYLEVC.js → chunk-72NJKS7O.js} +4 -4
  13. package/dist/{chunk-Q5US7JC5.js → chunk-7JAVT5TK.js} +3 -3
  14. package/dist/{chunk-7KU2WNQE.js → chunk-CVCTFLSO.js} +37 -15
  15. package/dist/{chunk-GHXZK54S.js → chunk-H3K5UGYC.js} +41 -13
  16. package/dist/{chunk-OP44TT4H.js → chunk-IN7KKL6K.js} +4 -2
  17. package/dist/{chunk-S6M42KND.js → chunk-JEUXDY3B.js} +1 -1
  18. package/dist/{chunk-ZL7SGNIA.js → chunk-JNVVJ273.js} +58 -46
  19. package/dist/chunk-N6XBLRB7.js +105 -0
  20. package/dist/{chunk-AP7YP2NX.js → chunk-OAWPT7VP.js} +2 -2
  21. package/dist/{chunk-AQJPNWZF.js → chunk-PWXDWMCW.js} +7 -7
  22. package/dist/{chunk-CT7QDJS6.js → chunk-QVRIDN42.js} +2 -2
  23. package/dist/chunk-QZLRHGVH.js +222 -0
  24. package/dist/{chunk-RPBOAQQQ.js → chunk-QZUVLFNR.js} +1 -1
  25. package/dist/{chunk-3YVEAZUN.js → chunk-RJHGDWSC.js} +32 -21
  26. package/dist/{chunk-MWIA43UJ.js → chunk-VCZE3IWO.js} +10 -8
  27. package/dist/chunk-YVG6QD3V.js +233 -0
  28. package/dist/{chunk-WNGFSIOB.js → chunk-Z3Q2AEIN.js} +237 -86
  29. package/dist/{community-report-client-PEERQCX2.js → community-report-client-TJVCLZ3K.js} +1 -1
  30. package/dist/compat-check-CII6B74E.js +32 -0
  31. package/dist/{config-JOD5DOPE.js → config-YZ6O2UQ2.js} +40 -7
  32. package/dist/{context-NGVFPCBK.js → context-F6FCGTF3.js} +4 -4
  33. package/dist/{data-integration-BCLQFTGU.js → data-integration-6UAZO4GG.js} +207 -24
  34. package/dist/evaluation-4LO2O4AF.js +3714 -0
  35. package/dist/index.js +352 -81
  36. package/dist/{local-data-upload-client-TWMHFLUA.js → local-data-upload-client-KCMG6J62.js} +1 -1
  37. package/dist/{memory-CQKH2JAV.js → memory-HHPX3NF2.js} +6 -6
  38. package/dist/{metadata-NR3PHR23.js → metadata-TIFY24LW.js} +17 -9
  39. package/dist/{model-VX5M2CJ6.js → model-7UHGWYVR.js} +4 -4
  40. package/dist/{personal-semantic-preference-2RAI36P3.js → personal-semantic-preference-WKJEGPTM.js} +7 -6
  41. package/dist/{project-semantic-3BUGP3ZM.js → project-semantic-EIQVZNHW.js} +11 -10
  42. package/dist/{sync-RZIAV37C.js → sync-RV3OPCTI.js} +8 -7
  43. package/dist/{te-agent-AORRE2FM.js → te-agent-5ENVZJUH.js} +757 -94
  44. package/dist/{te-analysis-GP7DSQ7Q.js → te-analysis-USIK6ZZG.js} +584 -100
  45. package/dist/{te-community-42M7ICDO.js → te-community-WE2UU4XV.js} +722 -228
  46. package/dist/{te-dataops-BNKNZ4F2.js → te-dataops-XNMO7MBF.js} +9 -6
  47. package/dist/{te-engage-2CO6LRCX.js → te-engage-6C3HCFQR.js} +13 -12
  48. package/dist/{te-experiment-652CLXMU.js → te-experiment-LVTRI3QK.js} +55 -21
  49. package/dist/{te-kb-ULATOTQ3.js → te-kb-TUPGMVBY.js} +409 -85
  50. package/dist/{te-system-UGHVKBVV.js → te-system-YM657FKO.js} +6 -6
  51. package/dist/{te-team-YA6SNOJ3.js → te-team-G4VEJJNL.js} +64 -41
  52. package/dist/{things-DTCOQIQB.js → things-22KQWC23.js} +7 -7
  53. package/dist/{update-ESNYKUVR.js → update-XX4ILU7X.js} +11 -7
  54. package/dist/{workspace-JEOHKFPX.js → workspace-LYDAP647.js} +6 -6
  55. package/package.json +26 -11
  56. package/skills/ae-agent/SKILL.md +22 -3
  57. package/skills/ae-agent/references/command_index.md +8 -0
  58. package/skills/ae-agent/references/resource-package.md +57 -0
  59. package/skills/ae-analysis/SKILL.md +23 -10
  60. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  61. package/skills/ae-analysis/references/agent_review_preflight.md +55 -10
  62. package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
  63. package/skills/ae-analysis/references/agent_review_submit_to_page.md +60 -24
  64. package/skills/ae-analysis/references/ai_models/event.md +58 -2
  65. package/skills/ae-analysis/references/ai_models/rank_list.md +1 -0
  66. package/skills/ae-analysis/references/ai_models/retention.md +2 -0
  67. package/skills/ae-analysis/references/ai_models/revenue.md +2 -0
  68. package/skills/ae-analysis/references/analysis_data_export.md +11 -1
  69. package/skills/ae-analysis/references/asset_batch_info_export.md +2 -2
  70. package/skills/ae-analysis/references/asset_batch_sql_export.md +2 -2
  71. package/skills/ae-analysis/references/asset_export.md +1 -1
  72. package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
  73. package/skills/ae-analysis/references/check_export.md +1 -1
  74. package/skills/ae-analysis/references/command_index.md +39 -26
  75. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  76. package/skills/ae-analysis/references/dashboard_report_get.md +6 -2
  77. package/skills/ae-analysis/references/dashboard_report_update.md +24 -5
  78. package/skills/ae-analysis/references/feedback_submit.md +1 -1
  79. package/skills/ae-analysis/references/governance_recommendation_export.md +40 -18
  80. package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
  81. package/skills/ae-analysis/references/live_data_export.md +1 -1
  82. package/skills/ae-analysis/references/metric_create.md +29 -0
  83. package/skills/ae-analysis/references/metric_get.md +2 -0
  84. package/skills/ae-analysis/references/metric_update.md +2 -0
  85. package/skills/ae-analysis/references/operation_record_export.md +1 -1
  86. package/skills/ae-analysis/references/plan_change_log_export.md +1 -1
  87. package/skills/ae-analysis/references/plan_export.md +1 -1
  88. package/skills/ae-analysis/references/project_info_get.md +4 -0
  89. package/skills/ae-analysis/references/project_member_group_add_members.md +35 -0
  90. package/skills/ae-analysis/references/project_member_group_create.md +25 -0
  91. package/skills/ae-analysis/references/project_member_group_delete.md +34 -0
  92. package/skills/ae-analysis/references/project_member_group_list.md +29 -0
  93. package/skills/ae-analysis/references/project_member_group_members.md +28 -0
  94. package/skills/ae-analysis/references/project_member_group_remove_members.md +35 -0
  95. package/skills/ae-analysis/references/project_member_group_rename.md +26 -0
  96. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
  97. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +6 -1
  98. package/skills/ae-analysis/references/report_data_export.md +1 -1
  99. package/skills/ae-analysis/references/scenario_append.md +31 -0
  100. package/skills/ae-analysis/references/scenario_begin.md +11 -0
  101. package/skills/ae-analysis/references/scenario_collect.md +43 -0
  102. package/skills/ae-analysis/references/scenario_evaluation.md +18 -0
  103. package/skills/ae-analysis/references/scenario_get.md +15 -0
  104. package/skills/ae-analysis/references/scenario_list.md +64 -0
  105. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +73 -4
  106. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
  107. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +5 -1
  108. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/execution-contract.mjs +173 -0
  109. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +109 -64
  110. package/skills/ae-automation/SKILL.md +2 -2
  111. package/skills/ae-automation/references/cli.md +18 -1
  112. package/skills/ae-capability/SKILL.md +7 -3
  113. package/skills/ae-community/SKILL.md +77 -27
  114. package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
  115. package/skills/ae-community/references/community-data-quality.md +68 -0
  116. package/skills/ae-community/references/community-query-evidence.md +85 -0
  117. package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
  118. package/skills/ae-community/references/community-weekly-report.md +6 -3
  119. package/skills/ae-community/references/get_channel_info.md +7 -4
  120. package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
  121. package/skills/ae-community/references/get_comments_summary.md +4 -4
  122. package/skills/ae-community/references/get_corpus_tags.md +3 -3
  123. package/skills/ae-community/references/get_daily_summary.md +3 -3
  124. package/skills/ae-community/references/get_hot_topics.md +3 -3
  125. package/skills/ae-community/references/get_livestream_analysis.md +3 -3
  126. package/skills/ae-community/references/get_livestream_detail.md +4 -4
  127. package/skills/ae-community/references/get_livestream_list.md +3 -3
  128. package/skills/ae-community/references/get_livestream_overview.md +3 -3
  129. package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
  130. package/skills/ae-community/references/get_livestream_rooms.md +3 -3
  131. package/skills/ae-community/references/get_overview_metrics.md +3 -3
  132. package/skills/ae-community/references/get_post_detail.md +4 -4
  133. package/skills/ae-community/references/get_risk_content.md +5 -5
  134. package/skills/ae-community/references/get_sentiment_overview.md +4 -4
  135. package/skills/ae-community/references/get_tag_trends.md +3 -3
  136. package/skills/ae-community/references/get_topic_detail.md +3 -3
  137. package/skills/ae-community/references/list_sources.md +28 -0
  138. package/skills/ae-community/references/list_spaces.md +39 -0
  139. package/skills/ae-community/references/search_posts.md +21 -7
  140. package/skills/ae-data-integration/SKILL.md +6 -4
  141. package/skills/ae-data-integration/references/error-handling.md +1 -0
  142. package/skills/ae-data-integration/references/handoff.md +1 -1
  143. package/skills/ae-data-integration/references/sink-upload.md +11 -0
  144. package/skills/ae-data-integration/references/source-inspect.md +2 -1
  145. package/skills/ae-data-integration/references/transform.md +1 -1
  146. package/skills/ae-data-integration/references/ue-mapping.md +1 -1
  147. package/skills/ae-evaluation/SKILL.md +83 -0
  148. package/skills/ae-evaluation/references/access-and-members.md +55 -0
  149. package/skills/ae-evaluation/references/connections.md +78 -0
  150. package/skills/ae-evaluation/references/datasets.md +57 -0
  151. package/skills/ae-evaluation/references/evaluators.md +81 -0
  152. package/skills/ae-evaluation/references/files.md +33 -0
  153. package/skills/ae-evaluation/references/integrations.md +39 -0
  154. package/skills/ae-evaluation/references/runs.md +160 -0
  155. package/skills/ae-evaluation/references/schedules.md +31 -0
  156. package/skills/ae-experiment/SKILL.md +7 -1
  157. package/skills/ae-experiment/references/manage_experiment.md +18 -1
  158. package/skills/ae-experiment/references/query_experiment_detail.md +7 -0
  159. package/skills/ae-experiment/references/save_experiment.md +76 -2
  160. package/skills/ae-experiment/references/save_submit_experiment.md +7 -0
  161. package/skills/ae-kb/SKILL.md +33 -7
  162. package/skills/ae-kb/references/publication.md +81 -0
  163. package/skills/ae-kb/references/query-workflow.md +14 -1
  164. package/skills/ae-metadata/SKILL.md +3 -2
  165. package/skills/ae-metadata/references/metadata_data_table_download.md +7 -1
  166. package/skills/ae-metadata/references/metadata_data_table_get.md +37 -0
  167. package/skills/ae-system/SKILL.md +1 -1
  168. package/skills/ae-team/SKILL.md +2 -2
  169. package/skills/ae-team/references/run-start.md +1 -0
  170. package/skills/ae-team/references/run-watch.md +7 -5
  171. package/skills/ae-things/SKILL.md +53 -51
  172. package/skills/ae-things/references/cli.md +56 -54
  173. package/skills/ae-things-progress/SKILL.md +20 -20
  174. package/skills/ae-things-review/SKILL.md +19 -19
  175. package/skills/ae-workspace/SKILL.md +1 -1
  176. package/dist/chunk-6VNIR4AP.js +0 -1422
  177. package/dist/chunk-CI24BDR2.js +0 -43
@@ -48,101 +48,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
48
48
  ));
49
49
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
50
50
 
51
- // src/core/logger.ts
52
- import fs from "fs";
53
- import path from "path";
54
- var LOG_DIR = path.join(process.env.HOME || "", ".ae-cli", "log");
55
- var Logger = class {
56
- logDir;
57
- date;
58
- constructor() {
59
- this.logDir = LOG_DIR;
60
- this.date = this.today();
61
- this.ensureDir();
62
- }
63
- today() {
64
- const d = /* @__PURE__ */ new Date();
65
- return `${d.getFullYear()}${String(d.getMonth() + 1).padStart(2, "0")}${String(d.getDate()).padStart(2, "0")}`;
66
- }
67
- timestamp() {
68
- return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").split(".")[0];
69
- }
70
- ensureDir() {
71
- if (!fs.existsSync(this.logDir)) {
72
- fs.mkdirSync(this.logDir, { recursive: true });
73
- }
74
- }
75
- filePath(level) {
76
- const today = this.today();
77
- if (today !== this.date) {
78
- this.date = today;
79
- }
80
- return path.join(this.logDir, `${this.date}_${level}.log`);
81
- }
82
- /**
83
- * Write a log entry to file (not printed to the console; console output is handled by existing process.stderr.write calls)
84
- */
85
- write(level, message) {
86
- const ts = this.timestamp();
87
- const line = `[${ts}] ${message}
88
- `;
89
- try {
90
- fs.appendFileSync(this.filePath(level), line);
91
- } catch {
92
- }
93
- }
94
- /** Informational log */
95
- info(message) {
96
- this.write("info", message);
97
- }
98
- /** Warning log */
99
- warn(message) {
100
- this.write("warning", message);
101
- }
102
- /** Error log */
103
- error(message) {
104
- this.write("error", message);
105
- }
106
- /** Log HTTP API request details */
107
- api(method, url, status, reqBody, respBody) {
108
- const parts = [`API ${method} ${url} \u2192 HTTP ${status}`];
109
- if (reqBody !== void 0 && reqBody !== null) {
110
- const s = typeof reqBody === "string" ? reqBody : JSON.stringify(reqBody);
111
- parts.push(`REQ: ${s.slice(0, 500)}`);
112
- }
113
- if (respBody !== void 0 && respBody !== null) {
114
- const s = typeof respBody === "string" ? respBody : JSON.stringify(respBody);
115
- parts.push(`RESP: ${s.slice(0, 500)}`);
116
- }
117
- this.info(parts.join(" | "));
118
- }
119
- /** Log command execution (sensitive flags redacted to ***) */
120
- command(name, args, sensitiveFlags = []) {
121
- const normalizeFlagName = (name2) => name2.toLowerCase().replace(/[-_]/g, "");
122
- const explicitSensitive = new Set(Array.from(sensitiveFlags, normalizeFlagName));
123
- const SENSITIVE = ["token", "apikey", "secret", "accesstoken", "headers"];
124
- const isSensitive = (k) => {
125
- const normalized = normalizeFlagName(k);
126
- return explicitSensitive.has(normalized) || SENSITIVE.some((s) => normalized.includes(s));
127
- };
128
- const filtered = Object.entries(args).filter(([, v]) => v !== void 0 && v !== null && v !== "").map(([k, v]) => `--${k}=${isSensitive(k) ? "***" : JSON.stringify(v)}`).join(" ");
129
- this.info(`CMD ${name}${filtered ? " " + filtered : ""}`);
130
- }
131
- };
132
- var logger = new Logger();
133
-
134
51
  // src/core/errors.ts
135
52
  var PermissionError = class extends Error {
136
- constructor(message, code, hint, details) {
53
+ constructor(message, code, hint, details, meta) {
137
54
  super(message);
138
55
  this.code = code;
139
56
  this.hint = hint;
140
57
  this.details = details;
58
+ this.meta = meta;
141
59
  this.name = "PermissionError";
142
60
  }
143
61
  code;
144
62
  hint;
145
63
  details;
64
+ meta;
146
65
  };
147
66
  function isApiErrorType(value) {
148
67
  return value === "auth" || value === "permission" || value === "validation" || value === "not_found" || value === "api";
@@ -212,6 +131,228 @@ var LocalDataUploadError = class extends Error {
212
131
  }
213
132
  };
214
133
 
134
+ // src/core/kb-read-context.ts
135
+ import fs from "fs";
136
+ var secrets = /* @__PURE__ */ new Set();
137
+ function fail(code) {
138
+ throw new CliValidationError(code, { code });
139
+ }
140
+ function kbExecutionContextRequired() {
141
+ return process.env.AE_KB_READ_CONTEXT_REQUIRED !== void 0 || process.env.AE_KB_READ_CONTEXT_FILE !== void 0;
142
+ }
143
+ function isKbQueryPath(method, pathname) {
144
+ return method === "POST" && /^\/(?:agent\/)?api\/external\/knowledge-bases\/(list|index|grep|read)$/.test(pathname);
145
+ }
146
+ function readKbExecutionContext() {
147
+ if (!kbExecutionContextRequired()) return void 0;
148
+ const file = process.env.AE_KB_READ_CONTEXT_FILE;
149
+ if (process.env.AE_KB_READ_CONTEXT_REQUIRED !== "1" || !file) fail("KB_READ_CONTEXT_REQUIRED");
150
+ let fd;
151
+ let data;
152
+ try {
153
+ fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
154
+ const stat = fs.fstatSync(fd);
155
+ if (!stat.isFile() || stat.size > 16384 || (stat.mode & 511) !== 384 || process.getuid && stat.uid !== process.getuid())
156
+ throw new Error();
157
+ data = JSON.parse(fs.readFileSync(fd, "utf8"));
158
+ if (!data || Array.isArray(data) || Object.keys(data).sort().join(",") !== "executionRef,expiresAt,formatVersion,origin,readContextId,required,token" || data.formatVersion !== 1 || data.required !== true || typeof data.executionRef !== "string" || !/^[^\s\0]{1,191}$/.test(data.executionRef) || typeof data.readContextId !== "string" || !/^[^\s\0]{1,191}$/.test(data.readContextId) || typeof data.token !== "string" || !/^cli_kbr_[A-Za-z0-9_-]{43,}$/.test(data.token) || typeof data.expiresAt !== "string" || !Number.isFinite(Date.parse(data.expiresAt)))
159
+ throw new Error();
160
+ const origin = new URL(data.origin);
161
+ if (!["http:", "https:"].includes(origin.protocol) || origin.username || origin.password || origin.origin !== data.origin)
162
+ throw new Error();
163
+ } catch {
164
+ fail("KB_READ_CONTEXT_REQUIRED");
165
+ } finally {
166
+ if (fd !== void 0) fs.closeSync(fd);
167
+ }
168
+ secrets.add(data.token);
169
+ if (Date.parse(data.expiresAt) <= Date.now()) fail("KB_READ_CONTEXT_EXPIRED");
170
+ return data;
171
+ }
172
+ function kbReadHeaders(url, explicitId) {
173
+ const context = readKbExecutionContext();
174
+ if (!context) return explicitId ? { "X-KB-Read-Context": explicitId } : void 0;
175
+ if (new URL(url).origin !== context.origin || explicitId && explicitId !== context.readContextId)
176
+ fail("KB_READ_CONTEXT_MISMATCH");
177
+ return { "cli-token": context.token, "X-KB-Read-Context": context.readContextId };
178
+ }
179
+ function redactKbReadCredential(value) {
180
+ for (const token of secrets) value = value.split(token).join("[REDACTED]");
181
+ return value.replace(/cli_kbr_[A-Za-z0-9_-]+/g, "[REDACTED]");
182
+ }
183
+
184
+ // src/core/url-utils.ts
185
+ function normalizeUrl(url) {
186
+ if (!url) return url;
187
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
188
+ url = `https://${url}`;
189
+ }
190
+ return url.replace(/\/$/, "");
191
+ }
192
+
193
+ // src/core/external-cli-token.ts
194
+ import fs2 from "fs";
195
+ var ExternalCliTokenError = class extends Error {
196
+ constructor(message, code = "EXTERNAL_CLI_TOKEN_INVALID") {
197
+ super(message);
198
+ this.code = code;
199
+ this.name = "ExternalCliTokenError";
200
+ }
201
+ code;
202
+ hint = "Set AE_CLI_TOKEN with AE_CLI_TOKEN_HOST, or use a JSON CLI token file containing url and token. Remove external token settings to use stored accounts.";
203
+ };
204
+ var explicitTokenFile;
205
+ var diagnosticSecrets = /* @__PURE__ */ new Set();
206
+ function setExternalCliTokenFile(file) {
207
+ explicitTokenFile = file;
208
+ }
209
+ function normalizedHost(value) {
210
+ if (typeof value !== "string" || !value.trim()) {
211
+ throw new ExternalCliTokenError("The external CLI token requires a host URL.");
212
+ }
213
+ try {
214
+ const url = new URL(value);
215
+ if (!["http:", "https:"].includes(url.protocol) || !url.hostname || url.username || url.password || url.search || url.hash || /\s/.test(value)) throw new Error();
216
+ return normalizeUrl(url.toString());
217
+ } catch {
218
+ throw new ExternalCliTokenError("The external CLI token host must be an HTTP(S) URL without credentials, query, or fragment.");
219
+ }
220
+ }
221
+ function credential(url, value, source) {
222
+ if (typeof value !== "string" || !/^cli_[!-~]+$/.test(value.trim())) {
223
+ throw new ExternalCliTokenError("The external CLI token must be a non-empty ASCII cli_ token without whitespace.");
224
+ }
225
+ return { url: normalizedHost(url), token: value.trim(), source };
226
+ }
227
+ function readExternalCliToken(hostOverride) {
228
+ let entry;
229
+ const file = explicitTokenFile ?? (process.env.AE_CLI_TOKEN === void 0 ? process.env.AE_CLI_TOKEN_FILE : void 0);
230
+ if (file !== void 0) {
231
+ if (!file.trim()) throw new ExternalCliTokenError("The external CLI token file path is empty.");
232
+ let data;
233
+ try {
234
+ const stat = fs2.statSync(file);
235
+ if (!stat.isFile() || stat.size > 64 * 1024) throw new Error();
236
+ data = JSON.parse(fs2.readFileSync(file, "utf8"));
237
+ } catch {
238
+ throw new ExternalCliTokenError("The external CLI token file must be a readable JSON file no larger than 64 KiB.");
239
+ }
240
+ if (!data || typeof data !== "object" || Array.isArray(data)) {
241
+ throw new ExternalCliTokenError("The external CLI token file must contain an object with url and token.");
242
+ }
243
+ entry = credential(data.url, data.token ?? data["cli-token"], "file-cli-token");
244
+ } else if (process.env.AE_CLI_TOKEN !== void 0) {
245
+ entry = credential(process.env.AE_CLI_TOKEN_HOST, process.env.AE_CLI_TOKEN, "environment-cli-token");
246
+ } else if (process.env.AE_CLI_TOKEN_HOST !== void 0) {
247
+ throw new ExternalCliTokenError("AE_CLI_TOKEN_HOST requires AE_CLI_TOKEN.");
248
+ }
249
+ if (entry && hostOverride && normalizedHost(hostOverride) !== entry.url) {
250
+ throw new ExternalCliTokenError("The selected host does not match the external CLI token host.");
251
+ }
252
+ if (entry) diagnosticSecrets.add(entry.token);
253
+ return entry;
254
+ }
255
+ function externalCliTokenRequestOptions(destination) {
256
+ const external = readExternalCliToken();
257
+ if (!external) return {};
258
+ if (new URL(destination).origin !== new URL(external.url).origin) {
259
+ throw new ExternalCliTokenError("The request destination does not match the external CLI token host.");
260
+ }
261
+ return { redirect: "error" };
262
+ }
263
+ function redactExternalCliToken(value) {
264
+ try {
265
+ readExternalCliToken();
266
+ } catch {
267
+ }
268
+ const forms = [...diagnosticSecrets].flatMap((token) => [token, JSON.stringify(token).slice(1, -1), encodeURIComponent(token)]);
269
+ for (const form of [...new Set(forms)].sort((a, b) => b.length - a.length)) value = value.split(form).join("[REDACTED]");
270
+ return redactKbReadCredential(value);
271
+ }
272
+
273
+ // src/core/logger.ts
274
+ import fs3 from "fs";
275
+ import path from "path";
276
+ var LOG_DIR = path.join(process.env.HOME || "", ".ae-cli", "log");
277
+ var Logger = class {
278
+ logDir;
279
+ date;
280
+ constructor() {
281
+ this.logDir = LOG_DIR;
282
+ this.date = this.today();
283
+ this.ensureDir();
284
+ }
285
+ today() {
286
+ const d = /* @__PURE__ */ new Date();
287
+ return `${d.getFullYear()}${String(d.getMonth() + 1).padStart(2, "0")}${String(d.getDate()).padStart(2, "0")}`;
288
+ }
289
+ timestamp() {
290
+ return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").split(".")[0];
291
+ }
292
+ ensureDir() {
293
+ if (!fs3.existsSync(this.logDir)) {
294
+ fs3.mkdirSync(this.logDir, { recursive: true });
295
+ }
296
+ }
297
+ filePath(level) {
298
+ const today = this.today();
299
+ if (today !== this.date) {
300
+ this.date = today;
301
+ }
302
+ return path.join(this.logDir, `${this.date}_${level}.log`);
303
+ }
304
+ /**
305
+ * Write a log entry to file (not printed to the console; console output is handled by existing process.stderr.write calls)
306
+ */
307
+ write(level, message) {
308
+ const ts = this.timestamp();
309
+ const line = `[${ts}] ${redactExternalCliToken(message)}
310
+ `;
311
+ try {
312
+ fs3.appendFileSync(this.filePath(level), line);
313
+ } catch {
314
+ }
315
+ }
316
+ /** Informational log */
317
+ info(message) {
318
+ this.write("info", message);
319
+ }
320
+ /** Warning log */
321
+ warn(message) {
322
+ this.write("warning", message);
323
+ }
324
+ /** Error log */
325
+ error(message) {
326
+ this.write("error", message);
327
+ }
328
+ /** Log HTTP API request details */
329
+ api(method, url, status, reqBody, respBody) {
330
+ const parts = [`API ${method} ${url} \u2192 HTTP ${status}`];
331
+ if (reqBody !== void 0 && reqBody !== null) {
332
+ const s = typeof reqBody === "string" ? reqBody : JSON.stringify(reqBody);
333
+ parts.push(`REQ: ${s.slice(0, 500)}`);
334
+ }
335
+ if (respBody !== void 0 && respBody !== null) {
336
+ const s = typeof respBody === "string" ? respBody : JSON.stringify(respBody);
337
+ parts.push(`RESP: ${s.slice(0, 500)}`);
338
+ }
339
+ this.info(parts.join(" | "));
340
+ }
341
+ /** Log command execution (sensitive flags redacted to ***) */
342
+ command(name, args, sensitiveFlags = []) {
343
+ const normalizeFlagName = (name2) => name2.toLowerCase().replace(/[-_]/g, "");
344
+ const explicitSensitive = new Set(Array.from(sensitiveFlags, normalizeFlagName));
345
+ const SENSITIVE = ["token", "apikey", "secret", "accesstoken", "headers"];
346
+ const isSensitive = (k) => {
347
+ const normalized = normalizeFlagName(k);
348
+ return explicitSensitive.has(normalized) || SENSITIVE.some((s) => normalized.includes(s));
349
+ };
350
+ const filtered = Object.entries(args).filter(([, v]) => v !== void 0 && v !== null && v !== "").map(([k, v]) => `--${k}=${isSensitive(k) ? "***" : JSON.stringify(v)}`).join(" ");
351
+ this.info(`CMD ${name}${filtered ? " " + filtered : ""}`);
352
+ }
353
+ };
354
+ var logger = new Logger();
355
+
215
356
  export {
216
357
  __require,
217
358
  __esm,
@@ -219,11 +360,21 @@ export {
219
360
  __export,
220
361
  __toESM,
221
362
  __toCommonJS,
222
- logger,
223
363
  PermissionError,
224
364
  isApiErrorType,
225
365
  CliValidationError,
226
366
  CliApiError,
227
367
  CommunityReportError,
228
- LocalDataUploadError
368
+ LocalDataUploadError,
369
+ kbExecutionContextRequired,
370
+ isKbQueryPath,
371
+ readKbExecutionContext,
372
+ kbReadHeaders,
373
+ normalizeUrl,
374
+ ExternalCliTokenError,
375
+ setExternalCliTokenFile,
376
+ readExternalCliToken,
377
+ externalCliTokenRequestOptions,
378
+ redactExternalCliToken,
379
+ logger
229
380
  };
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  CommunityReportError,
4
4
  logger
5
- } from "./chunk-WNGFSIOB.js";
5
+ } from "./chunk-Z3Q2AEIN.js";
6
6
 
7
7
  // src/core/community-report-client.ts
8
8
  var DEFAULT_TIMEOUT_MS = 3e4;
@@ -0,0 +1,32 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ fetchCliConfig,
4
+ formatCapabilityMissCompatHint,
5
+ getCachedCompatForHost,
6
+ getPendingHostCompatNotice,
7
+ getPendingUpdateNotice,
8
+ isCompatCacheStale,
9
+ isNonInteractiveOutput,
10
+ notifyIfHostCompat,
11
+ runHostCompatCheck,
12
+ shouldNotifyCompat,
13
+ shouldSkipAutoSync,
14
+ shouldSkipCompatCheck
15
+ } from "./chunk-2UW3Y463.js";
16
+ import "./chunk-H3K5UGYC.js";
17
+ import "./chunk-JNVVJ273.js";
18
+ import "./chunk-Z3Q2AEIN.js";
19
+ export {
20
+ fetchCliConfig,
21
+ formatCapabilityMissCompatHint,
22
+ getCachedCompatForHost,
23
+ getPendingHostCompatNotice,
24
+ getPendingUpdateNotice,
25
+ isCompatCacheStale,
26
+ isNonInteractiveOutput,
27
+ notifyIfHostCompat,
28
+ runHostCompatCheck,
29
+ shouldNotifyCompat,
30
+ shouldSkipAutoSync,
31
+ shouldSkipCompatCheck
32
+ };
@@ -1,4 +1,9 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ invalidateBusinessSkillSynchronization,
4
+ refreshEnvironmentAfterLogin,
5
+ refreshEnvironmentConfig
6
+ } from "./chunk-6HAUVWOQ.js";
2
7
  import {
3
8
  MultiselectCancelled,
4
9
  promptSingleSelect
@@ -8,26 +13,30 @@ import {
8
13
  missingAeHostHint
9
14
  } from "./chunk-6ZIQV5GW.js";
10
15
  import {
11
- fetchCliConfig,
12
16
  printError,
13
- printOutput,
17
+ printOutput
18
+ } from "./chunk-QZLRHGVH.js";
19
+ import {
20
+ fetchCliConfig,
21
+ readCurrentBusinessConfig,
14
22
  resolveKbAutoDiscoveryFeature
15
- } from "./chunk-6VNIR4AP.js";
23
+ } from "./chunk-2UW3Y463.js";
16
24
  import {
17
25
  peekCliToken
18
- } from "./chunk-GHXZK54S.js";
26
+ } from "./chunk-H3K5UGYC.js";
19
27
  import {
20
28
  addHost,
21
29
  getActiveHost,
22
30
  listHosts,
23
31
  loadConfig,
24
- normalizeUrl,
25
32
  removeHost,
26
33
  resolveHostSelector,
27
34
  setActiveHost,
28
35
  updateHostLabel
29
- } from "./chunk-ZL7SGNIA.js";
30
- import "./chunk-WNGFSIOB.js";
36
+ } from "./chunk-JNVVJ273.js";
37
+ import {
38
+ normalizeUrl
39
+ } from "./chunk-Z3Q2AEIN.js";
31
40
 
32
41
  // src/commands/config.ts
33
42
  import * as readline2 from "readline";
@@ -69,7 +78,9 @@ Already active: \x1B[1m${item.host.label}\x1B[0m
69
78
  `);
70
79
  return;
71
80
  }
81
+ invalidateBusinessSkillSynchronization();
72
82
  setActiveHost(item.host.url);
83
+ await refreshEnvironmentAfterLogin(item.host.url);
73
84
  process.stderr.write(`
74
85
  \x1B[32m\u2713\x1B[0m Active environment: \x1B[1m${item.host.label}\x1B[0m ${item.host.url}
75
86
  `);
@@ -103,6 +114,7 @@ async function promptAddEnvironment() {
103
114
  const labelInput = await ask(`Label [${defaultLabel}]: `);
104
115
  const label = labelInput || defaultLabel;
105
116
  try {
117
+ invalidateBusinessSkillSynchronization();
106
118
  addHost(url, label);
107
119
  const active = listHosts().find((host) => host.url === url)?.active;
108
120
  process.stderr.write(
@@ -111,6 +123,7 @@ async function promptAddEnvironment() {
111
123
  `
112
124
  );
113
125
  if (active) {
126
+ await refreshEnvironmentAfterLogin(url);
114
127
  process.stderr.write(` Authenticate if needed: ae-cli auth login --host ${url}
115
128
  `);
116
129
  }
@@ -155,11 +168,13 @@ async function promptRemoveEnvironment(host) {
155
168
  process.stderr.write("Cancelled.\n");
156
169
  return;
157
170
  }
171
+ invalidateBusinessSkillSynchronization();
158
172
  if (replacement) setActiveHost(replacement.url);
159
173
  removeHost(host.url);
160
174
  process.stderr.write(`\x1B[32m\u2713\x1B[0m Removed: ${host.label}
161
175
  `);
162
176
  if (replacement) {
177
+ await refreshEnvironmentAfterLogin(replacement.url);
163
178
  process.stderr.write(` Active environment: ${replacement.label} ${replacement.url}
164
179
  `);
165
180
  } else if (listHosts().length === 0) {
@@ -273,6 +288,16 @@ function registerConfig(program) {
273
288
  configCmd.command("current").description("Show the active AE environment").action(async () => {
274
289
  await printCurrentConfig(program);
275
290
  });
291
+ configCmd.command("refresh").description("Refresh business configuration and synchronize managed Skills for the active environment").action(async () => {
292
+ const host = program.opts().host || getActiveHost();
293
+ if (!host) {
294
+ failConfig("No active AE environment configured.", missingAeHostHint());
295
+ return;
296
+ }
297
+ const result = await refreshEnvironmentConfig(host, { synchronizeSkills: !program.opts().host });
298
+ await printOutput(result, program.opts().format || "json", program.opts().jq);
299
+ if (result.source === "unavailable" || ["failed", "partial", "busy"].includes(result.skills.status)) process.exitCode = 1;
300
+ });
276
301
  configCmd.command("show").description("Show effective configuration for the selected AE host and account").action(async () => {
277
302
  const host = program.opts().host || getActiveHost();
278
303
  const token = host ? peekCliToken(host) : null;
@@ -280,6 +305,7 @@ function registerConfig(program) {
280
305
  await printOutput(
281
306
  {
282
307
  host: host || null,
308
+ businesses: readCurrentBusinessConfig(host),
283
309
  routing: { knowledge_base: feature.enabled ? "auto" : "explicit" },
284
310
  source: feature.source
285
311
  },
@@ -303,8 +329,10 @@ function registerConfig(program) {
303
329
  try {
304
330
  const normalized = normalizeUrl(url);
305
331
  const label = opts.label || normalized;
332
+ invalidateBusinessSkillSynchronization();
306
333
  addHost(normalized, label);
307
334
  setActiveHost(normalized);
335
+ await refreshEnvironmentAfterLogin(normalized);
308
336
  await printOutput(
309
337
  { activeHost: normalized, label: label.trim() },
310
338
  program.opts().format || "json",
@@ -352,7 +380,9 @@ async function useConfigEnv(program, env) {
352
380
  failHostResolution(env, target);
353
381
  return;
354
382
  }
383
+ invalidateBusinessSkillSynchronization();
355
384
  setActiveHost(target.host.url);
385
+ await refreshEnvironmentAfterLogin(target.host.url);
356
386
  await printOutput({ activeHost: target.host.url, label: target.host.label }, program.opts().format || "json", program.opts().jq);
357
387
  }
358
388
  async function addConfigEnv(program, url, opts) {
@@ -366,8 +396,10 @@ async function addConfigEnv(program, url, opts) {
366
396
  return;
367
397
  }
368
398
  try {
399
+ invalidateBusinessSkillSynchronization();
369
400
  addHost(normalized, opts.label);
370
401
  if (opts.use) setActiveHost(normalized);
402
+ if (getActiveHost() === normalized) await refreshEnvironmentAfterLogin(normalized);
371
403
  const saved = loadConfig();
372
404
  await printOutput(
373
405
  {
@@ -431,6 +463,7 @@ async function removeConfigEnv(program, env, skipConfirmation) {
431
463
  return;
432
464
  }
433
465
  }
466
+ invalidateBusinessSkillSynchronization();
434
467
  removeHost(target.host.url);
435
468
  await printOutput(
436
469
  {
@@ -2,15 +2,15 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  TeAgentApiError,
4
4
  getFromMainApp
5
- } from "./chunk-3YVEAZUN.js";
5
+ } from "./chunk-RJHGDWSC.js";
6
6
  import "./chunk-Y74WTIKJ.js";
7
- import "./chunk-GHXZK54S.js";
7
+ import "./chunk-H3K5UGYC.js";
8
8
  import {
9
9
  safeJsonParse
10
- } from "./chunk-ZL7SGNIA.js";
10
+ } from "./chunk-JNVVJ273.js";
11
11
  import {
12
12
  CliValidationError
13
- } from "./chunk-WNGFSIOB.js";
13
+ } from "./chunk-Z3Q2AEIN.js";
14
14
 
15
15
  // src/core/current-page-context-client.ts
16
16
  async function readCurrentPageContext(path) {