@thinkingai/ae-cli 6.0.56 → 6.0.57

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 (111) hide show
  1. package/README.md +12 -4
  2. package/README.zh.md +12 -4
  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-U7MNUUEF.js → auth-YEIJLBFY.js} +30 -12
  7. package/dist/{automation-K32V2NKP.js → automation-NAR5DDGL.js} +6 -6
  8. package/dist/{capability-VV7RHB3B.js → capability-P7DD4Q73.js} +48 -20
  9. package/dist/{chunk-KHS64JZQ.js → chunk-72NJKS7O.js} +4 -4
  10. package/dist/chunk-752BSLZC.js +222 -0
  11. package/dist/{chunk-W2PTY5NN.js → chunk-7ABK2PEJ.js} +3 -3
  12. package/dist/{chunk-UUD5RB36.js → chunk-7JAVT5TK.js} +3 -3
  13. package/dist/{chunk-P7KL7IOH.js → chunk-H3K5UGYC.js} +2 -2
  14. package/dist/{chunk-P6VFCH3P.js → chunk-IN7KKL6K.js} +2 -2
  15. package/dist/{chunk-MXV3PYC3.js → chunk-JCWM2TYP.js} +50 -12
  16. package/dist/{chunk-T44M3PLZ.js → chunk-JEUXDY3B.js} +1 -1
  17. package/dist/{chunk-LMCYSVVA.js → chunk-JNVVJ273.js} +51 -37
  18. package/dist/{chunk-JJJIP2XQ.js → chunk-N6XBLRB7.js} +2 -2
  19. package/dist/{chunk-QSAR3GHY.js → chunk-OAWPT7VP.js} +2 -2
  20. package/dist/{chunk-F6NIPIT5.js → chunk-QEMQKVHW.js} +35 -14
  21. package/dist/{chunk-2IYIYSUO.js → chunk-QVRIDN42.js} +2 -2
  22. package/dist/{chunk-GI5BMEZO.js → chunk-QZUVLFNR.js} +1 -1
  23. package/dist/{chunk-2UWS5CUP.js → chunk-RJHGDWSC.js} +3 -3
  24. package/dist/{chunk-3TQA5RXE.js → chunk-TKVVACEJ.js} +6 -4
  25. package/dist/chunk-TULINOLS.js +2283 -0
  26. package/dist/{chunk-X7DRLE62.js → chunk-YVG6QD3V.js} +1 -1
  27. package/dist/{chunk-ZW4VMY5H.js → chunk-Z3Q2AEIN.js} +152 -98
  28. package/dist/chunk-ZGIYG473.js +132 -0
  29. package/dist/{community-report-client-S2K3A3Q6.js → community-report-client-TJVCLZ3K.js} +1 -1
  30. package/dist/compat-check-PMEGUPZU.js +32 -0
  31. package/dist/{config-ASSAAIOI.js → config-VWVPR4WW.js} +38 -6
  32. package/dist/{context-6RWLVOM5.js → context-F6FCGTF3.js} +4 -4
  33. package/dist/{data-integration-EXSUPUDZ.js → data-integration-6UAZO4GG.js} +207 -24
  34. package/dist/{evaluation-5YT4QLCL.js → evaluation-4LO2O4AF.js} +4 -4
  35. package/dist/index.js +291 -71
  36. package/dist/{local-data-upload-client-7HCPGIS3.js → local-data-upload-client-KCMG6J62.js} +1 -1
  37. package/dist/{memory-VCYLVPMI.js → memory-HHPX3NF2.js} +6 -6
  38. package/dist/{metadata-TIWIOFTU.js → metadata-HEQQEEG3.js} +16 -8
  39. package/dist/{model-DPJHSD73.js → model-7UHGWYVR.js} +4 -4
  40. package/dist/{personal-semantic-preference-SBKU2LOK.js → personal-semantic-preference-V4L6ZWR2.js} +7 -6
  41. package/dist/{project-semantic-SKNWLH3I.js → project-semantic-NKHKJX6M.js} +7 -6
  42. package/dist/{sync-7PP6KQ75.js → sync-ZJMXCRIN.js} +8 -7
  43. package/dist/{te-agent-L2BYNPHM.js → te-agent-WBKIFEQD.js} +11 -7
  44. package/dist/{te-analysis-RJB6VJC4.js → te-analysis-ADX7RKO4.js} +179 -27
  45. package/dist/{te-community-QN3WMPNT.js → te-community-PREDRXG3.js} +720 -228
  46. package/dist/{te-dataops-UKD2XN3E.js → te-dataops-ITWJHO2U.js} +6 -5
  47. package/dist/{te-engage-KPTN4N2U.js → te-engage-VE2NUH5V.js} +7 -6
  48. package/dist/{te-kb-SFZI3W5T.js → te-kb-WSMOW7WS.js} +407 -83
  49. package/dist/{te-system-IE7NCKC3.js → te-system-YM657FKO.js} +6 -6
  50. package/dist/{te-team-4KHCFM2I.js → te-team-T2WRLOOD.js} +7 -6
  51. package/dist/{things-7JJUVAWL.js → things-6QOMFXOG.js} +7 -7
  52. package/dist/{update-AX66IFMJ.js → update-I4MOUYOX.js} +11 -7
  53. package/dist/{workspace-Q5NMEKEN.js → workspace-LYDAP647.js} +6 -6
  54. package/package.json +17 -7
  55. package/skills/ae-agent/SKILL.md +1 -1
  56. package/skills/ae-agent/references/resource-package.md +4 -0
  57. package/skills/ae-analysis/SKILL.md +14 -10
  58. package/skills/ae-analysis/references/agent_review_preflight.md +52 -11
  59. package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
  60. package/skills/ae-analysis/references/agent_review_submit_to_page.md +57 -25
  61. package/skills/ae-analysis/references/command_index.md +7 -3
  62. package/skills/ae-analysis/references/governance_recommendation_export.md +31 -17
  63. package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
  64. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
  65. package/skills/ae-analysis/references/scenario_append.md +6 -0
  66. package/skills/ae-analysis/references/scenario_begin.md +11 -0
  67. package/skills/ae-analysis/references/scenario_collect.md +10 -2
  68. package/skills/ae-analysis/references/scenario_evaluation.md +6 -18
  69. package/skills/ae-analysis/references/scenario_get.md +15 -0
  70. package/skills/ae-analysis/references/scenario_list.md +64 -0
  71. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
  72. package/skills/ae-community/SKILL.md +77 -27
  73. package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
  74. package/skills/ae-community/references/community-data-quality.md +68 -0
  75. package/skills/ae-community/references/community-query-evidence.md +85 -0
  76. package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
  77. package/skills/ae-community/references/community-weekly-report.md +6 -3
  78. package/skills/ae-community/references/get_channel_info.md +7 -4
  79. package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
  80. package/skills/ae-community/references/get_comments_summary.md +4 -4
  81. package/skills/ae-community/references/get_corpus_tags.md +3 -3
  82. package/skills/ae-community/references/get_daily_summary.md +3 -3
  83. package/skills/ae-community/references/get_hot_topics.md +3 -3
  84. package/skills/ae-community/references/get_livestream_analysis.md +3 -3
  85. package/skills/ae-community/references/get_livestream_detail.md +4 -4
  86. package/skills/ae-community/references/get_livestream_list.md +3 -3
  87. package/skills/ae-community/references/get_livestream_overview.md +3 -3
  88. package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
  89. package/skills/ae-community/references/get_livestream_rooms.md +3 -3
  90. package/skills/ae-community/references/get_overview_metrics.md +3 -3
  91. package/skills/ae-community/references/get_post_detail.md +4 -4
  92. package/skills/ae-community/references/get_risk_content.md +5 -5
  93. package/skills/ae-community/references/get_sentiment_overview.md +4 -4
  94. package/skills/ae-community/references/get_tag_trends.md +3 -3
  95. package/skills/ae-community/references/get_topic_detail.md +3 -3
  96. package/skills/ae-community/references/list_sources.md +28 -0
  97. package/skills/ae-community/references/list_spaces.md +39 -0
  98. package/skills/ae-community/references/search_posts.md +21 -7
  99. package/skills/ae-data-integration/SKILL.md +6 -4
  100. package/skills/ae-data-integration/references/error-handling.md +1 -0
  101. package/skills/ae-data-integration/references/handoff.md +1 -1
  102. package/skills/ae-data-integration/references/sink-upload.md +11 -0
  103. package/skills/ae-data-integration/references/source-inspect.md +2 -1
  104. package/skills/ae-data-integration/references/transform.md +1 -1
  105. package/skills/ae-data-integration/references/ue-mapping.md +1 -1
  106. package/skills/ae-kb/SKILL.md +33 -6
  107. package/skills/ae-kb/references/publication.md +81 -0
  108. package/skills/ae-kb/references/query-workflow.md +14 -1
  109. package/skills/ae-metadata/SKILL.md +2 -2
  110. package/skills/ae-metadata/references/metadata_data_table_get.md +35 -0
  111. package/dist/chunk-ELCR235M.js +0 -1429
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  CliValidationError,
4
4
  logger
5
- } from "./chunk-ZW4VMY5H.js";
5
+ } from "./chunk-Z3Q2AEIN.js";
6
6
 
7
7
  // src/core/eval-endpoint.ts
8
8
  function resolveEvaluationHost(host) {
@@ -48,6 +48,139 @@ 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/errors.ts
52
+ var PermissionError = class extends Error {
53
+ constructor(message, code, hint, details, meta) {
54
+ super(message);
55
+ this.code = code;
56
+ this.hint = hint;
57
+ this.details = details;
58
+ this.meta = meta;
59
+ this.name = "PermissionError";
60
+ }
61
+ code;
62
+ hint;
63
+ details;
64
+ meta;
65
+ };
66
+ function isApiErrorType(value) {
67
+ return value === "auth" || value === "permission" || value === "validation" || value === "not_found" || value === "api";
68
+ }
69
+ var CliValidationError = class extends Error {
70
+ code;
71
+ hint;
72
+ location;
73
+ constructor(message, options = {}) {
74
+ super(message);
75
+ this.name = "CliValidationError";
76
+ this.code = options.code;
77
+ this.hint = options.hint;
78
+ if (options.location) {
79
+ const location = {};
80
+ if (typeof options.location.segment === "number" && Number.isFinite(options.location.segment)) {
81
+ location.segment = options.location.segment;
82
+ }
83
+ if (typeof options.location.record === "number" && Number.isFinite(options.location.record)) {
84
+ location.record = options.location.record;
85
+ }
86
+ if (typeof options.location.field === "string" && options.location.field.length > 0) {
87
+ location.field = options.location.field;
88
+ }
89
+ if (Object.keys(location).length > 0) this.location = location;
90
+ }
91
+ }
92
+ };
93
+ var CliApiError = class extends Error {
94
+ code;
95
+ hint;
96
+ meta;
97
+ constructor(message, options = {}) {
98
+ super(message);
99
+ this.name = "CliApiError";
100
+ this.code = options.code;
101
+ this.hint = options.hint;
102
+ this.meta = options.meta;
103
+ }
104
+ };
105
+ var CommunityReportError = class extends Error {
106
+ code;
107
+ httpStatus;
108
+ hint;
109
+ meta;
110
+ constructor(message, options = {}) {
111
+ super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
112
+ this.name = "CommunityReportError";
113
+ this.code = options.code;
114
+ this.httpStatus = options.httpStatus;
115
+ this.hint = options.hint;
116
+ this.meta = options.meta;
117
+ }
118
+ };
119
+ var LocalDataUploadError = class extends Error {
120
+ code;
121
+ httpStatus;
122
+ hint;
123
+ meta;
124
+ constructor(message, options = {}) {
125
+ super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
126
+ this.name = "LocalDataUploadError";
127
+ this.code = options.code;
128
+ this.httpStatus = options.httpStatus;
129
+ this.hint = options.hint;
130
+ this.meta = options.meta;
131
+ }
132
+ };
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
+
51
184
  // src/core/url-utils.ts
52
185
  function normalizeUrl(url) {
53
186
  if (!url) return url;
@@ -58,7 +191,7 @@ function normalizeUrl(url) {
58
191
  }
59
192
 
60
193
  // src/core/external-cli-token.ts
61
- import fs from "fs";
194
+ import fs2 from "fs";
62
195
  var ExternalCliTokenError = class extends Error {
63
196
  constructor(message, code = "EXTERNAL_CLI_TOKEN_INVALID") {
64
197
  super(message);
@@ -98,9 +231,9 @@ function readExternalCliToken(hostOverride) {
98
231
  if (!file.trim()) throw new ExternalCliTokenError("The external CLI token file path is empty.");
99
232
  let data;
100
233
  try {
101
- const stat = fs.statSync(file);
234
+ const stat = fs2.statSync(file);
102
235
  if (!stat.isFile() || stat.size > 64 * 1024) throw new Error();
103
- data = JSON.parse(fs.readFileSync(file, "utf8"));
236
+ data = JSON.parse(fs2.readFileSync(file, "utf8"));
104
237
  } catch {
105
238
  throw new ExternalCliTokenError("The external CLI token file must be a readable JSON file no larger than 64 KiB.");
106
239
  }
@@ -134,11 +267,11 @@ function redactExternalCliToken(value) {
134
267
  }
135
268
  const forms = [...diagnosticSecrets].flatMap((token) => [token, JSON.stringify(token).slice(1, -1), encodeURIComponent(token)]);
136
269
  for (const form of [...new Set(forms)].sort((a, b) => b.length - a.length)) value = value.split(form).join("[REDACTED]");
137
- return value;
270
+ return redactKbReadCredential(value);
138
271
  }
139
272
 
140
273
  // src/core/logger.ts
141
- import fs2 from "fs";
274
+ import fs3 from "fs";
142
275
  import path from "path";
143
276
  var LOG_DIR = path.join(process.env.HOME || "", ".ae-cli", "log");
144
277
  var Logger = class {
@@ -157,8 +290,8 @@ var Logger = class {
157
290
  return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").split(".")[0];
158
291
  }
159
292
  ensureDir() {
160
- if (!fs2.existsSync(this.logDir)) {
161
- fs2.mkdirSync(this.logDir, { recursive: true });
293
+ if (!fs3.existsSync(this.logDir)) {
294
+ fs3.mkdirSync(this.logDir, { recursive: true });
162
295
  }
163
296
  }
164
297
  filePath(level) {
@@ -176,7 +309,7 @@ var Logger = class {
176
309
  const line = `[${ts}] ${redactExternalCliToken(message)}
177
310
  `;
178
311
  try {
179
- fs2.appendFileSync(this.filePath(level), line);
312
+ fs3.appendFileSync(this.filePath(level), line);
180
313
  } catch {
181
314
  }
182
315
  }
@@ -220,89 +353,6 @@ var Logger = class {
220
353
  };
221
354
  var logger = new Logger();
222
355
 
223
- // src/core/errors.ts
224
- var PermissionError = class extends Error {
225
- constructor(message, code, hint, details, meta) {
226
- super(message);
227
- this.code = code;
228
- this.hint = hint;
229
- this.details = details;
230
- this.meta = meta;
231
- this.name = "PermissionError";
232
- }
233
- code;
234
- hint;
235
- details;
236
- meta;
237
- };
238
- function isApiErrorType(value) {
239
- return value === "auth" || value === "permission" || value === "validation" || value === "not_found" || value === "api";
240
- }
241
- var CliValidationError = class extends Error {
242
- code;
243
- hint;
244
- location;
245
- constructor(message, options = {}) {
246
- super(message);
247
- this.name = "CliValidationError";
248
- this.code = options.code;
249
- this.hint = options.hint;
250
- if (options.location) {
251
- const location = {};
252
- if (typeof options.location.segment === "number" && Number.isFinite(options.location.segment)) {
253
- location.segment = options.location.segment;
254
- }
255
- if (typeof options.location.record === "number" && Number.isFinite(options.location.record)) {
256
- location.record = options.location.record;
257
- }
258
- if (typeof options.location.field === "string" && options.location.field.length > 0) {
259
- location.field = options.location.field;
260
- }
261
- if (Object.keys(location).length > 0) this.location = location;
262
- }
263
- }
264
- };
265
- var CliApiError = class extends Error {
266
- code;
267
- hint;
268
- meta;
269
- constructor(message, options = {}) {
270
- super(message);
271
- this.name = "CliApiError";
272
- this.code = options.code;
273
- this.hint = options.hint;
274
- this.meta = options.meta;
275
- }
276
- };
277
- var CommunityReportError = class extends Error {
278
- code;
279
- httpStatus;
280
- hint;
281
- meta;
282
- constructor(message, options = {}) {
283
- super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
284
- this.name = "CommunityReportError";
285
- this.code = options.code;
286
- this.httpStatus = options.httpStatus;
287
- this.hint = options.hint;
288
- this.meta = options.meta;
289
- }
290
- };
291
- var LocalDataUploadError = class extends Error {
292
- code;
293
- httpStatus;
294
- hint;
295
- meta;
296
- constructor(message, options = {}) {
297
- super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
298
- this.name = "LocalDataUploadError";
299
- this.code = options.code;
300
- this.httpStatus = options.httpStatus;
301
- this.hint = options.hint;
302
- this.meta = options.meta;
303
- }
304
- };
305
-
306
356
  export {
307
357
  __require,
308
358
  __esm,
@@ -310,17 +360,21 @@ export {
310
360
  __export,
311
361
  __toESM,
312
362
  __toCommonJS,
363
+ PermissionError,
364
+ isApiErrorType,
365
+ CliValidationError,
366
+ CliApiError,
367
+ CommunityReportError,
368
+ LocalDataUploadError,
369
+ kbExecutionContextRequired,
370
+ isKbQueryPath,
371
+ readKbExecutionContext,
372
+ kbReadHeaders,
313
373
  normalizeUrl,
314
374
  ExternalCliTokenError,
315
375
  setExternalCliTokenFile,
316
376
  readExternalCliToken,
317
377
  externalCliTokenRequestOptions,
318
378
  redactExternalCliToken,
319
- logger,
320
- PermissionError,
321
- isApiErrorType,
322
- CliValidationError,
323
- CliApiError,
324
- CommunityReportError,
325
- LocalDataUploadError
379
+ logger
326
380
  };
@@ -0,0 +1,132 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ canManageGlobalSkills,
4
+ fetchCliConfig,
5
+ getLocalCliPackageInfo,
6
+ isBusinessSkillContextCurrent,
7
+ rememberBusinessConfig,
8
+ reserveBusinessSkillContext,
9
+ syncBusinessSkills
10
+ } from "./chunk-TULINOLS.js";
11
+ import {
12
+ peekCliToken
13
+ } from "./chunk-H3K5UGYC.js";
14
+ import {
15
+ getActiveHost,
16
+ getConfigDir
17
+ } from "./chunk-JNVVJ273.js";
18
+ import {
19
+ normalizeUrl
20
+ } from "./chunk-Z3Q2AEIN.js";
21
+
22
+ // src/core/environment-refresh.ts
23
+ import crypto from "crypto";
24
+ import fs from "fs";
25
+ import path from "path";
26
+ function cliTokenFingerprint(token) {
27
+ return crypto.createHash("sha256").update(token).digest("hex");
28
+ }
29
+ function invalidateBusinessSkillSynchronization() {
30
+ if (canManageGlobalSkills()) reserveBusinessSkillContext({});
31
+ }
32
+ async function refreshEnvironmentConfig(host, options = {}) {
33
+ const normalized = normalizeUrl(host);
34
+ const skipped = (reason) => ({
35
+ host: normalized,
36
+ businesses: {},
37
+ source: "unavailable",
38
+ skills: { status: "skipped", reason }
39
+ });
40
+ let token;
41
+ try {
42
+ token = peekCliToken(normalized);
43
+ } catch {
44
+ return skipped("Credentials could not be read. Sign in before refreshing Skills.");
45
+ }
46
+ if (!token) return skipped("Sign in to this environment before refreshing its business configuration.");
47
+ const fingerprint = cliTokenFingerprint(token);
48
+ const localActiveEnvironment = () => {
49
+ try {
50
+ return canManageGlobalSkills() && normalizeUrl(getActiveHost()) === normalized && cliTokenFingerprint(peekCliToken(normalized) ?? "") === fingerprint;
51
+ } catch {
52
+ return false;
53
+ }
54
+ };
55
+ const synchronize = options.synchronizeSkills !== false && localActiveEnvironment();
56
+ const generation = synchronize ? reserveBusinessSkillContext({ host: normalized, tokenFingerprint: fingerprint }) : void 0;
57
+ let config;
58
+ try {
59
+ config = await (options.fetchConfig ?? fetchCliConfig)(normalized, token);
60
+ } catch {
61
+ config = null;
62
+ }
63
+ if (!config) return skipped("CLI configuration is unavailable; existing Skills were preserved.");
64
+ if (generation && !isBusinessSkillContextCurrent({
65
+ host: normalized,
66
+ tokenFingerprint: fingerprint,
67
+ generation,
68
+ isCurrentContext: localActiveEnvironment
69
+ })) {
70
+ return {
71
+ host: normalized,
72
+ businesses: {},
73
+ source: "remote",
74
+ skills: { status: "skipped", reason: "A newer environment refresh superseded this response." }
75
+ };
76
+ }
77
+ rememberBusinessConfig(normalized, token, config.businesses);
78
+ const result = {
79
+ host: normalized,
80
+ businesses: config.businesses ?? {},
81
+ source: "remote",
82
+ skills: { status: "skipped", reason: "Only an explicitly refreshed active local environment changes global Skills." }
83
+ };
84
+ if (config.businesses === void 0) {
85
+ result.skills = { status: "skipped", reason: "This server does not provide business states; existing Skills were preserved." };
86
+ return result;
87
+ }
88
+ if (!synchronize || !localActiveEnvironment()) return result;
89
+ try {
90
+ const syncOptions = {
91
+ skillsDirectory: path.join(getLocalCliPackageInfo().root, "skills"),
92
+ host: normalized,
93
+ tokenFingerprint: fingerprint,
94
+ businesses: config.businesses,
95
+ packageVersion: getLocalCliPackageInfo().version,
96
+ generation,
97
+ isCurrentContext: localActiveEnvironment
98
+ };
99
+ if (!fs.existsSync(path.join(getConfigDir(), "business-skills.json"))) {
100
+ const adoption = syncBusinessSkills({ ...syncOptions, mode: "adopt" });
101
+ if (["failed", "busy", "stale"].includes(adoption.status)) {
102
+ result.skills = adoption;
103
+ return result;
104
+ }
105
+ }
106
+ result.skills = syncBusinessSkills(syncOptions);
107
+ } catch {
108
+ result.skills = { status: "failed", reason: "Skill synchronization could not complete. Retry: ae-cli config refresh" };
109
+ }
110
+ return result;
111
+ }
112
+ async function refreshEnvironmentAfterLogin(host) {
113
+ try {
114
+ const result = await refreshEnvironmentConfig(host);
115
+ if (!["success", "skipped"].includes(result.skills.status)) {
116
+ process.stderr.write("[ae-cli] Some Skills could not be synchronized. Run: ae-cli config refresh\n");
117
+ }
118
+ if (result.source === "unavailable") {
119
+ process.stderr.write("[ae-cli] Business configuration could not be refreshed. Sign in if needed, then run: ae-cli config refresh\n");
120
+ }
121
+ return result;
122
+ } catch {
123
+ process.stderr.write("[ae-cli] Business configuration could not be refreshed. Retry: ae-cli config refresh\n");
124
+ return void 0;
125
+ }
126
+ }
127
+
128
+ export {
129
+ invalidateBusinessSkillSynchronization,
130
+ refreshEnvironmentConfig,
131
+ refreshEnvironmentAfterLogin
132
+ };
@@ -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-ZW4VMY5H.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-TULINOLS.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-ZGIYG473.js";
2
7
  import {
3
8
  MultiselectCancelled,
4
9
  promptSingleSelect
@@ -8,14 +13,17 @@ 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-752BSLZC.js";
19
+ import {
20
+ fetchCliConfig,
21
+ readCurrentBusinessConfig,
14
22
  resolveKbAutoDiscoveryFeature
15
- } from "./chunk-ELCR235M.js";
23
+ } from "./chunk-TULINOLS.js";
16
24
  import {
17
25
  peekCliToken
18
- } from "./chunk-P7KL7IOH.js";
26
+ } from "./chunk-H3K5UGYC.js";
19
27
  import {
20
28
  addHost,
21
29
  getActiveHost,
@@ -25,10 +33,10 @@ import {
25
33
  resolveHostSelector,
26
34
  setActiveHost,
27
35
  updateHostLabel
28
- } from "./chunk-LMCYSVVA.js";
36
+ } from "./chunk-JNVVJ273.js";
29
37
  import {
30
38
  normalizeUrl
31
- } from "./chunk-ZW4VMY5H.js";
39
+ } from "./chunk-Z3Q2AEIN.js";
32
40
 
33
41
  // src/commands/config.ts
34
42
  import * as readline2 from "readline";
@@ -70,7 +78,9 @@ Already active: \x1B[1m${item.host.label}\x1B[0m
70
78
  `);
71
79
  return;
72
80
  }
81
+ invalidateBusinessSkillSynchronization();
73
82
  setActiveHost(item.host.url);
83
+ await refreshEnvironmentAfterLogin(item.host.url);
74
84
  process.stderr.write(`
75
85
  \x1B[32m\u2713\x1B[0m Active environment: \x1B[1m${item.host.label}\x1B[0m ${item.host.url}
76
86
  `);
@@ -104,6 +114,7 @@ async function promptAddEnvironment() {
104
114
  const labelInput = await ask(`Label [${defaultLabel}]: `);
105
115
  const label = labelInput || defaultLabel;
106
116
  try {
117
+ invalidateBusinessSkillSynchronization();
107
118
  addHost(url, label);
108
119
  const active = listHosts().find((host) => host.url === url)?.active;
109
120
  process.stderr.write(
@@ -112,6 +123,7 @@ async function promptAddEnvironment() {
112
123
  `
113
124
  );
114
125
  if (active) {
126
+ await refreshEnvironmentAfterLogin(url);
115
127
  process.stderr.write(` Authenticate if needed: ae-cli auth login --host ${url}
116
128
  `);
117
129
  }
@@ -156,11 +168,13 @@ async function promptRemoveEnvironment(host) {
156
168
  process.stderr.write("Cancelled.\n");
157
169
  return;
158
170
  }
171
+ invalidateBusinessSkillSynchronization();
159
172
  if (replacement) setActiveHost(replacement.url);
160
173
  removeHost(host.url);
161
174
  process.stderr.write(`\x1B[32m\u2713\x1B[0m Removed: ${host.label}
162
175
  `);
163
176
  if (replacement) {
177
+ await refreshEnvironmentAfterLogin(replacement.url);
164
178
  process.stderr.write(` Active environment: ${replacement.label} ${replacement.url}
165
179
  `);
166
180
  } else if (listHosts().length === 0) {
@@ -274,6 +288,16 @@ function registerConfig(program) {
274
288
  configCmd.command("current").description("Show the active AE environment").action(async () => {
275
289
  await printCurrentConfig(program);
276
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
+ });
277
301
  configCmd.command("show").description("Show effective configuration for the selected AE host and account").action(async () => {
278
302
  const host = program.opts().host || getActiveHost();
279
303
  const token = host ? peekCliToken(host) : null;
@@ -281,6 +305,7 @@ function registerConfig(program) {
281
305
  await printOutput(
282
306
  {
283
307
  host: host || null,
308
+ businesses: readCurrentBusinessConfig(host),
284
309
  routing: { knowledge_base: feature.enabled ? "auto" : "explicit" },
285
310
  source: feature.source
286
311
  },
@@ -304,8 +329,10 @@ function registerConfig(program) {
304
329
  try {
305
330
  const normalized = normalizeUrl(url);
306
331
  const label = opts.label || normalized;
332
+ invalidateBusinessSkillSynchronization();
307
333
  addHost(normalized, label);
308
334
  setActiveHost(normalized);
335
+ await refreshEnvironmentAfterLogin(normalized);
309
336
  await printOutput(
310
337
  { activeHost: normalized, label: label.trim() },
311
338
  program.opts().format || "json",
@@ -353,7 +380,9 @@ async function useConfigEnv(program, env) {
353
380
  failHostResolution(env, target);
354
381
  return;
355
382
  }
383
+ invalidateBusinessSkillSynchronization();
356
384
  setActiveHost(target.host.url);
385
+ await refreshEnvironmentAfterLogin(target.host.url);
357
386
  await printOutput({ activeHost: target.host.url, label: target.host.label }, program.opts().format || "json", program.opts().jq);
358
387
  }
359
388
  async function addConfigEnv(program, url, opts) {
@@ -367,8 +396,10 @@ async function addConfigEnv(program, url, opts) {
367
396
  return;
368
397
  }
369
398
  try {
399
+ invalidateBusinessSkillSynchronization();
370
400
  addHost(normalized, opts.label);
371
401
  if (opts.use) setActiveHost(normalized);
402
+ if (getActiveHost() === normalized) await refreshEnvironmentAfterLogin(normalized);
372
403
  const saved = loadConfig();
373
404
  await printOutput(
374
405
  {
@@ -432,6 +463,7 @@ async function removeConfigEnv(program, env, skipConfirmation) {
432
463
  return;
433
464
  }
434
465
  }
466
+ invalidateBusinessSkillSynchronization();
435
467
  removeHost(target.host.url);
436
468
  await printOutput(
437
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-2UWS5CUP.js";
5
+ } from "./chunk-RJHGDWSC.js";
6
6
  import "./chunk-Y74WTIKJ.js";
7
- import "./chunk-P7KL7IOH.js";
7
+ import "./chunk-H3K5UGYC.js";
8
8
  import {
9
9
  safeJsonParse
10
- } from "./chunk-LMCYSVVA.js";
10
+ } from "./chunk-JNVVJ273.js";
11
11
  import {
12
12
  CliValidationError
13
- } from "./chunk-ZW4VMY5H.js";
13
+ } from "./chunk-Z3Q2AEIN.js";
14
14
 
15
15
  // src/core/current-page-context-client.ts
16
16
  async function readCurrentPageContext(path) {