@thinkingai/ae-cli 6.0.55 → 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 (169) hide show
  1. package/README.md +35 -6
  2. package/README.zh.md +35 -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-RQBO6MTY.js → auth-YEIJLBFY.js} +61 -19
  7. package/dist/{automation-VAAQBM7Y.js → automation-NAR5DDGL.js} +94 -38
  8. package/dist/{capability-JRIFC4AJ.js → capability-P7DD4Q73.js} +50 -21
  9. package/dist/{chunk-5XJYLEVC.js → chunk-72NJKS7O.js} +4 -4
  10. package/dist/chunk-752BSLZC.js +222 -0
  11. package/dist/{chunk-RGYPSEYD.js → chunk-7ABK2PEJ.js} +3 -3
  12. package/dist/{chunk-Q5US7JC5.js → chunk-7JAVT5TK.js} +3 -3
  13. package/dist/{chunk-GHXZK54S.js → chunk-H3K5UGYC.js} +41 -13
  14. package/dist/{chunk-OP44TT4H.js → chunk-IN7KKL6K.js} +4 -2
  15. package/dist/{chunk-VZZNLV3I.js → chunk-JCWM2TYP.js} +61 -15
  16. package/dist/{chunk-S6M42KND.js → chunk-JEUXDY3B.js} +1 -1
  17. package/dist/{chunk-ZL7SGNIA.js → chunk-JNVVJ273.js} +58 -46
  18. package/dist/chunk-N6XBLRB7.js +105 -0
  19. package/dist/{chunk-AP7YP2NX.js → chunk-OAWPT7VP.js} +2 -2
  20. package/dist/{chunk-7KU2WNQE.js → chunk-QEMQKVHW.js} +37 -15
  21. package/dist/{chunk-CT7QDJS6.js → chunk-QVRIDN42.js} +2 -2
  22. package/dist/{chunk-RPBOAQQQ.js → chunk-QZUVLFNR.js} +1 -1
  23. package/dist/{chunk-3YVEAZUN.js → chunk-RJHGDWSC.js} +32 -21
  24. package/dist/{chunk-374V5R6N.js → chunk-TKVVACEJ.js} +6 -4
  25. package/dist/chunk-TULINOLS.js +2283 -0
  26. package/dist/chunk-YVG6QD3V.js +233 -0
  27. package/dist/{chunk-WNGFSIOB.js → chunk-Z3Q2AEIN.js} +237 -86
  28. package/dist/chunk-ZGIYG473.js +132 -0
  29. package/dist/{community-report-client-PEERQCX2.js → community-report-client-TJVCLZ3K.js} +1 -1
  30. package/dist/compat-check-PMEGUPZU.js +32 -0
  31. package/dist/{config-SICKWZ2A.js → config-VWVPR4WW.js} +43 -10
  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 +343 -79
  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-EMFGUI2W.js → metadata-HEQQEEG3.js} +17 -9
  39. package/dist/{model-VX5M2CJ6.js → model-7UHGWYVR.js} +4 -4
  40. package/dist/{personal-semantic-preference-SLWVVYZ4.js → personal-semantic-preference-V4L6ZWR2.js} +7 -6
  41. package/dist/{project-semantic-DPSZBKQD.js → project-semantic-NKHKJX6M.js} +7 -6
  42. package/dist/{sync-RZIAV37C.js → sync-ZJMXCRIN.js} +8 -7
  43. package/dist/{te-agent-AORRE2FM.js → te-agent-WBKIFEQD.js} +757 -94
  44. package/dist/{te-analysis-ISXKJKRT.js → te-analysis-ADX7RKO4.js} +578 -94
  45. package/dist/{te-community-42M7ICDO.js → te-community-PREDRXG3.js} +722 -228
  46. package/dist/{te-dataops-BNKNZ4F2.js → te-dataops-ITWJHO2U.js} +9 -6
  47. package/dist/{te-engage-BZE3MBKT.js → te-engage-VE2NUH5V.js} +7 -6
  48. package/dist/{te-kb-ULATOTQ3.js → te-kb-WSMOW7WS.js} +407 -83
  49. package/dist/{te-system-UGHVKBVV.js → te-system-YM657FKO.js} +6 -6
  50. package/dist/{te-team-YA6SNOJ3.js → te-team-T2WRLOOD.js} +64 -41
  51. package/dist/{things-DTCOQIQB.js → things-6QOMFXOG.js} +7 -7
  52. package/dist/{update-ESNYKUVR.js → update-I4MOUYOX.js} +11 -7
  53. package/dist/{workspace-JEOHKFPX.js → workspace-LYDAP647.js} +6 -6
  54. package/package.json +25 -11
  55. package/skills/ae-agent/SKILL.md +20 -3
  56. package/skills/ae-agent/references/command_index.md +8 -0
  57. package/skills/ae-agent/references/resource-package.md +57 -0
  58. package/skills/ae-analysis/SKILL.md +23 -10
  59. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  60. package/skills/ae-analysis/references/agent_review_preflight.md +55 -10
  61. package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
  62. package/skills/ae-analysis/references/agent_review_submit_to_page.md +60 -24
  63. package/skills/ae-analysis/references/ai_models/event.md +58 -2
  64. package/skills/ae-analysis/references/ai_models/rank_list.md +1 -0
  65. package/skills/ae-analysis/references/ai_models/retention.md +2 -0
  66. package/skills/ae-analysis/references/ai_models/revenue.md +2 -0
  67. package/skills/ae-analysis/references/analysis_data_export.md +11 -1
  68. package/skills/ae-analysis/references/asset_batch_info_export.md +2 -2
  69. package/skills/ae-analysis/references/asset_batch_sql_export.md +2 -2
  70. package/skills/ae-analysis/references/asset_export.md +1 -1
  71. package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
  72. package/skills/ae-analysis/references/check_export.md +1 -1
  73. package/skills/ae-analysis/references/command_index.md +39 -26
  74. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  75. package/skills/ae-analysis/references/dashboard_report_get.md +6 -2
  76. package/skills/ae-analysis/references/dashboard_report_update.md +24 -5
  77. package/skills/ae-analysis/references/feedback_submit.md +1 -1
  78. package/skills/ae-analysis/references/governance_recommendation_export.md +40 -18
  79. package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
  80. package/skills/ae-analysis/references/live_data_export.md +1 -1
  81. package/skills/ae-analysis/references/metric_create.md +29 -0
  82. package/skills/ae-analysis/references/metric_get.md +2 -0
  83. package/skills/ae-analysis/references/metric_update.md +2 -0
  84. package/skills/ae-analysis/references/operation_record_export.md +1 -1
  85. package/skills/ae-analysis/references/plan_change_log_export.md +1 -1
  86. package/skills/ae-analysis/references/plan_export.md +1 -1
  87. package/skills/ae-analysis/references/project_info_get.md +4 -0
  88. package/skills/ae-analysis/references/project_member_group_add_members.md +35 -0
  89. package/skills/ae-analysis/references/project_member_group_create.md +25 -0
  90. package/skills/ae-analysis/references/project_member_group_delete.md +34 -0
  91. package/skills/ae-analysis/references/project_member_group_list.md +29 -0
  92. package/skills/ae-analysis/references/project_member_group_members.md +28 -0
  93. package/skills/ae-analysis/references/project_member_group_remove_members.md +35 -0
  94. package/skills/ae-analysis/references/project_member_group_rename.md +26 -0
  95. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
  96. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +6 -1
  97. package/skills/ae-analysis/references/report_data_export.md +1 -1
  98. package/skills/ae-analysis/references/scenario_append.md +31 -0
  99. package/skills/ae-analysis/references/scenario_begin.md +11 -0
  100. package/skills/ae-analysis/references/scenario_collect.md +43 -0
  101. package/skills/ae-analysis/references/scenario_evaluation.md +18 -0
  102. package/skills/ae-analysis/references/scenario_get.md +15 -0
  103. package/skills/ae-analysis/references/scenario_list.md +64 -0
  104. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +73 -4
  105. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
  106. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +5 -1
  107. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/execution-contract.mjs +173 -0
  108. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +109 -64
  109. package/skills/ae-automation/SKILL.md +2 -2
  110. package/skills/ae-automation/references/cli.md +18 -1
  111. package/skills/ae-capability/SKILL.md +7 -3
  112. package/skills/ae-community/SKILL.md +77 -27
  113. package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
  114. package/skills/ae-community/references/community-data-quality.md +68 -0
  115. package/skills/ae-community/references/community-query-evidence.md +85 -0
  116. package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
  117. package/skills/ae-community/references/community-weekly-report.md +6 -3
  118. package/skills/ae-community/references/get_channel_info.md +7 -4
  119. package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
  120. package/skills/ae-community/references/get_comments_summary.md +4 -4
  121. package/skills/ae-community/references/get_corpus_tags.md +3 -3
  122. package/skills/ae-community/references/get_daily_summary.md +3 -3
  123. package/skills/ae-community/references/get_hot_topics.md +3 -3
  124. package/skills/ae-community/references/get_livestream_analysis.md +3 -3
  125. package/skills/ae-community/references/get_livestream_detail.md +4 -4
  126. package/skills/ae-community/references/get_livestream_list.md +3 -3
  127. package/skills/ae-community/references/get_livestream_overview.md +3 -3
  128. package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
  129. package/skills/ae-community/references/get_livestream_rooms.md +3 -3
  130. package/skills/ae-community/references/get_overview_metrics.md +3 -3
  131. package/skills/ae-community/references/get_post_detail.md +4 -4
  132. package/skills/ae-community/references/get_risk_content.md +5 -5
  133. package/skills/ae-community/references/get_sentiment_overview.md +4 -4
  134. package/skills/ae-community/references/get_tag_trends.md +3 -3
  135. package/skills/ae-community/references/get_topic_detail.md +3 -3
  136. package/skills/ae-community/references/list_sources.md +28 -0
  137. package/skills/ae-community/references/list_spaces.md +39 -0
  138. package/skills/ae-community/references/search_posts.md +21 -7
  139. package/skills/ae-data-integration/SKILL.md +6 -4
  140. package/skills/ae-data-integration/references/error-handling.md +1 -0
  141. package/skills/ae-data-integration/references/handoff.md +1 -1
  142. package/skills/ae-data-integration/references/sink-upload.md +11 -0
  143. package/skills/ae-data-integration/references/source-inspect.md +2 -1
  144. package/skills/ae-data-integration/references/transform.md +1 -1
  145. package/skills/ae-data-integration/references/ue-mapping.md +1 -1
  146. package/skills/ae-evaluation/SKILL.md +83 -0
  147. package/skills/ae-evaluation/references/access-and-members.md +55 -0
  148. package/skills/ae-evaluation/references/connections.md +78 -0
  149. package/skills/ae-evaluation/references/datasets.md +57 -0
  150. package/skills/ae-evaluation/references/evaluators.md +81 -0
  151. package/skills/ae-evaluation/references/files.md +33 -0
  152. package/skills/ae-evaluation/references/integrations.md +39 -0
  153. package/skills/ae-evaluation/references/runs.md +160 -0
  154. package/skills/ae-evaluation/references/schedules.md +31 -0
  155. package/skills/ae-kb/SKILL.md +33 -6
  156. package/skills/ae-kb/references/publication.md +81 -0
  157. package/skills/ae-kb/references/query-workflow.md +14 -1
  158. package/skills/ae-metadata/SKILL.md +3 -2
  159. package/skills/ae-metadata/references/metadata_data_table_download.md +7 -1
  160. package/skills/ae-metadata/references/metadata_data_table_get.md +37 -0
  161. package/skills/ae-team/SKILL.md +2 -2
  162. package/skills/ae-team/references/run-start.md +1 -0
  163. package/skills/ae-team/references/run-watch.md +7 -5
  164. package/skills/ae-things/SKILL.md +53 -51
  165. package/skills/ae-things/references/cli.md +56 -54
  166. package/skills/ae-things-progress/SKILL.md +20 -20
  167. package/skills/ae-things-review/SKILL.md +19 -19
  168. package/dist/chunk-6VNIR4AP.js +0 -1422
  169. package/dist/chunk-CI24BDR2.js +0 -43
package/dist/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ requiresConfirmation
4
+ } from "./chunk-AMBFK2K3.js";
2
5
  import {
3
6
  allHeaderNames,
4
7
  allSheetNames,
@@ -14,62 +17,75 @@ import {
14
17
  validateAndFix,
15
18
  validateDraft,
16
19
  writeDraftXlsx
17
- } from "./chunk-5XJYLEVC.js";
20
+ } from "./chunk-72NJKS7O.js";
21
+ import "./chunk-QVRIDN42.js";
18
22
  import {
19
- requiresConfirmation
20
- } from "./chunk-AMBFK2K3.js";
21
- import "./chunk-CT7QDJS6.js";
22
- import "./chunk-AP7YP2NX.js";
23
- import "./chunk-S6M42KND.js";
24
- import {
25
- resolveHost
26
- } from "./chunk-OP44TT4H.js";
23
+ EvalApiError
24
+ } from "./chunk-YVG6QD3V.js";
25
+ import "./chunk-OAWPT7VP.js";
26
+ import "./chunk-JEUXDY3B.js";
27
27
  import {
28
28
  TeAgentApiError,
29
29
  TeAgentCredentialsError
30
- } from "./chunk-3YVEAZUN.js";
30
+ } from "./chunk-RJHGDWSC.js";
31
31
  import {
32
32
  CapabilityGatewayError,
33
33
  executeCapability,
34
34
  uploadInputFileBytes
35
- } from "./chunk-VZZNLV3I.js";
35
+ } from "./chunk-JCWM2TYP.js";
36
36
  import {
37
+ resolveHost
38
+ } from "./chunk-IN7KKL6K.js";
39
+ import {
40
+ printError,
41
+ printOutput
42
+ } from "./chunk-752BSLZC.js";
43
+ import "./chunk-Y74WTIKJ.js";
44
+ import {
45
+ BusinessDisabledError,
46
+ assertBusinessEnabled,
47
+ businessForCommand,
37
48
  failInstallation,
38
49
  fetchCliConfig,
39
50
  formatCapabilityMissCompatHint,
40
51
  getLocalCliPackageInfo,
41
52
  installVersion,
42
53
  newInstallationReport,
43
- printError,
44
- printOutput,
54
+ readCurrentBusinessConfig,
45
55
  resolveKbAutoDiscoveryFeature,
46
56
  runHostCompatCheck,
47
57
  shouldSkipAutoSync
48
- } from "./chunk-6VNIR4AP.js";
49
- import "./chunk-Y74WTIKJ.js";
58
+ } from "./chunk-TULINOLS.js";
50
59
  import {
51
60
  CredentialStoreUnreadableError,
52
61
  SecureStoreAuthError,
53
62
  getCliToken,
54
63
  peekCliToken
55
- } from "./chunk-GHXZK54S.js";
64
+ } from "./chunk-H3K5UGYC.js";
56
65
  import {
57
66
  getActiveHost,
58
67
  getConfigDir,
59
68
  safeJsonParse
60
- } from "./chunk-ZL7SGNIA.js";
69
+ } from "./chunk-JNVVJ273.js";
61
70
  import {
62
71
  CliApiError,
63
72
  CliValidationError,
64
73
  CommunityReportError,
74
+ ExternalCliTokenError,
65
75
  LocalDataUploadError,
66
76
  PermissionError,
67
- logger
68
- } from "./chunk-WNGFSIOB.js";
77
+ externalCliTokenRequestOptions,
78
+ kbExecutionContextRequired,
79
+ logger,
80
+ readExternalCliToken,
81
+ readKbExecutionContext,
82
+ setExternalCliTokenFile
83
+ } from "./chunk-Z3Q2AEIN.js";
69
84
 
70
85
  // src/index.ts
71
86
  import { Command as CommanderCommand, Option } from "commander";
72
87
  import { createRequire } from "module";
88
+ import { constants as osConstants } from "os";
73
89
 
74
90
  // src/framework/runner.ts
75
91
  import * as readline from "readline";
@@ -128,7 +144,7 @@ async function runCommand(cmd, opts, globalOpts) {
128
144
  printError("validation", message, hint);
129
145
  process.exit(1);
130
146
  }
131
- if (cmd.validate) {
147
+ if (cmd.validate && cmd.service !== "community") {
132
148
  cmd.validate(ctx);
133
149
  }
134
150
  const LIMIT_FLAG_PATTERNS = [/limit/i, /page_size/i, /pagesize/i, /row_limit/i, /block_limit/i, /top[-_]?k/i];
@@ -142,6 +158,30 @@ async function runCommand(cmd, opts, globalOpts) {
142
158
  }
143
159
  continue;
144
160
  }
161
+ if (flag.type === "int64") {
162
+ if (val === void 0 || val === null || val === "") continue;
163
+ const raw = String(val);
164
+ if (!/^-?(?:0|[1-9]\d*)$/.test(raw)) {
165
+ printError("validation", `--${flag.name} must be a base-10 integer (got: ${val})`);
166
+ process.exit(1);
167
+ }
168
+ const parsed = BigInt(raw);
169
+ const minInt64 = -(1n << 63n);
170
+ const maxInt64 = (1n << 63n) - 1n;
171
+ if (parsed < minInt64 || parsed > maxInt64) {
172
+ printError("validation", `--${flag.name} must fit in a signed 64-bit integer (got: ${val})`);
173
+ process.exit(1);
174
+ }
175
+ if (flag.min !== void 0 && parsed < BigInt(flag.min)) {
176
+ printError("validation", `--${flag.name} must be at least ${flag.min} (got: ${val})`);
177
+ process.exit(1);
178
+ }
179
+ if (flag.max !== void 0 && parsed > BigInt(flag.max)) {
180
+ printError("validation", `--${flag.name} must be at most ${flag.max} (got: ${val})`);
181
+ process.exit(1);
182
+ }
183
+ continue;
184
+ }
145
185
  if (flag.type !== "number") continue;
146
186
  if (flag.variadic) continue;
147
187
  if (val === void 0 || val === null || val === "") continue;
@@ -150,7 +190,7 @@ async function runCommand(cmd, opts, globalOpts) {
150
190
  printError("validation", `--${flag.name} must be a number (got: ${val})`);
151
191
  process.exit(1);
152
192
  }
153
- const isLimitFlag = LIMIT_FLAG_PATTERNS.some((p) => p.test(flag.name));
193
+ const isLimitFlag = LIMIT_FLAG_PATTERNS.some((p) => p.test(flag.name)) || cmd.service === "community" && /page[-_]?(?:size|num)|row[-_]?limit/i.test(flag.name);
154
194
  if (isLimitFlag) {
155
195
  const min = flag.min ?? 1;
156
196
  const max = flag.max ?? 1e4;
@@ -180,6 +220,9 @@ async function runCommand(cmd, opts, globalOpts) {
180
220
  process.exit(1);
181
221
  }
182
222
  }
223
+ if (cmd.validate && cmd.service === "community") {
224
+ cmd.validate(ctx);
225
+ }
183
226
  if (globalOpts.validate && globalOpts.dryRun) {
184
227
  printError(
185
228
  "validation",
@@ -192,6 +235,10 @@ async function runCommand(cmd, opts, globalOpts) {
192
235
  if (cmd.validateInput) {
193
236
  const validateResult = await cmd.validateInput(ctx);
194
237
  await printOutput(validateResult, globalOpts.format, globalOpts.jq);
238
+ } else if (cmd.service === "community") {
239
+ throw new CliValidationError(`--validate is not supported for ${cmdName}`, {
240
+ hint: "Run without --validate, or inspect the underlying capability for server validation."
241
+ });
195
242
  } else {
196
243
  await printOutput(
197
244
  { message: "No --validate implementation for this command (capability gateway commands only)" },
@@ -204,6 +251,10 @@ async function runCommand(cmd, opts, globalOpts) {
204
251
  if (cmd.dryRun) {
205
252
  const dryResult = await cmd.dryRun(ctx);
206
253
  await printOutput(dryResult, globalOpts.format, globalOpts.jq);
254
+ } else if (cmd.service === "community") {
255
+ throw new CliValidationError(`--dry-run is not supported for ${cmdName}`, {
256
+ hint: "Run the read-only command without --dry-run; this command has no request preview."
257
+ });
207
258
  } else {
208
259
  await printOutput({ message: "No dry-run implementation for this command" }, globalOpts.format);
209
260
  }
@@ -236,7 +287,7 @@ async function runCommand(cmd, opts, globalOpts) {
236
287
  process.exit(1);
237
288
  }
238
289
  const message = err.message || String(err);
239
- if (!(err instanceof CommunityReportError)) {
290
+ if (!(err instanceof CommunityReportError) && !(err instanceof EvalApiError)) {
240
291
  if (!(err instanceof LocalDataUploadError)) logger.error(`Command failed: ${message}`);
241
292
  }
242
293
  if (err instanceof CliValidationError) {
@@ -250,7 +301,7 @@ async function runCommand(cmd, opts, globalOpts) {
250
301
  } else if (err instanceof TeAgentCredentialsError) {
251
302
  printError("config", message, err.hint);
252
303
  } else if (err instanceof PermissionError) {
253
- printError("permission", message, err.hint, err.code, void 0, { details: err.details });
304
+ printError("permission", message, err.hint, err.code, err.meta, { details: err.details });
254
305
  } else if (err instanceof CliApiError) {
255
306
  printError("api", message, err.hint, err.code, err.meta);
256
307
  } else if (err instanceof CapabilityGatewayError) {
@@ -259,8 +310,10 @@ async function runCommand(cmd, opts, globalOpts) {
259
310
  printError("api", message, err.hint, err.code, err.meta, { log: false });
260
311
  } else if (err instanceof LocalDataUploadError) {
261
312
  printError("api", message, err.hint, err.code, err.meta, { log: false });
262
- } else if (err instanceof CredentialStoreUnreadableError) {
313
+ } else if (err instanceof CredentialStoreUnreadableError || err instanceof ExternalCliTokenError) {
263
314
  printError("config", message, err.hint, err.code);
315
+ } else if (err instanceof EvalApiError) {
316
+ printError("api", message, err.hint, err.code, void 0, { log: false });
264
317
  } else if (err instanceof SecureStoreAuthError) {
265
318
  printError("auth", message, "Run: ae-cli auth login", err.code);
266
319
  } else if (err instanceof TeAgentApiError) {
@@ -326,14 +379,14 @@ function createRuntimeContext(cmd, opts, globalOpts) {
326
379
  let _communityReportModule = null;
327
380
  async function getCommunityReportClient() {
328
381
  if (!_communityReportModule) {
329
- _communityReportModule = await import("./community-report-client-PEERQCX2.js");
382
+ _communityReportModule = await import("./community-report-client-TJVCLZ3K.js");
330
383
  }
331
384
  return _communityReportModule;
332
385
  }
333
386
  let _localDataUploadModule = null;
334
387
  async function getLocalDataUploadClient() {
335
388
  if (!_localDataUploadModule) {
336
- _localDataUploadModule = await import("./local-data-upload-client-TWMHFLUA.js");
389
+ _localDataUploadModule = await import("./local-data-upload-client-KCMG6J62.js");
337
390
  }
338
391
  return _localDataUploadModule;
339
392
  }
@@ -353,9 +406,23 @@ function createRuntimeContext(cmd, opts, globalOpts) {
353
406
  if (val === void 0 || val === null || val === "") return void 0;
354
407
  return Number(val);
355
408
  },
409
+ int64(name) {
410
+ const val = opts[camelCase(name)];
411
+ if (val === void 0 || val === null || val === "") return 0n;
412
+ return BigInt(String(val));
413
+ },
414
+ optionalInt64(name) {
415
+ const val = opts[camelCase(name)];
416
+ if (val === void 0 || val === null || val === "") return void 0;
417
+ return BigInt(String(val));
418
+ },
356
419
  bool(name) {
357
420
  return Boolean(opts[camelCase(name)]);
358
421
  },
422
+ optionalBool(name) {
423
+ const val = opts[camelCase(name)];
424
+ return typeof val === "boolean" ? val : void 0;
425
+ },
359
426
  json(name) {
360
427
  const val = opts[camelCase(name)];
361
428
  if (val === void 0 || val === null) return void 0;
@@ -363,6 +430,11 @@ function createRuntimeContext(cmd, opts, globalOpts) {
363
430
  try {
364
431
  return safeJsonParse(String(val));
365
432
  } catch {
433
+ if (cmd.flags.some((flag) => flag.name === name && flag.sensitive)) {
434
+ throw new CliValidationError(`Invalid JSON for --${name}.`, {
435
+ hint: "Provide valid JSON with quoted keys and strings. Sensitive input is omitted from diagnostics."
436
+ });
437
+ }
366
438
  printError("validation", `Invalid JSON for --${name}: ${val}`);
367
439
  process.exit(1);
368
440
  }
@@ -385,6 +457,10 @@ function createRuntimeContext(cmd, opts, globalOpts) {
385
457
  return globalOpts.host;
386
458
  },
387
459
  host() {
460
+ if (cmd.service === "kb" && ["+list", "+index", "+grep", "+read"].includes(cmd.command)) {
461
+ const context = readKbExecutionContext();
462
+ if (context) return globalOpts.host || context.origin;
463
+ }
388
464
  if (globalOpts.host) return globalOpts.host;
389
465
  return getActiveHost();
390
466
  },
@@ -442,14 +518,21 @@ function registerCommands(program2, commands) {
442
518
  const sub = parent.command(cmd.command, { hidden: cmd.hidden === true }).description(cmd.description);
443
519
  for (const flag of cmd.flags) {
444
520
  const flagStr = buildFlagString(flag);
521
+ const description = flag.required ? `${flag.desc} (required)` : flag.desc;
445
522
  if (flag.variadic) {
446
- sub.option(flagStr, flag.desc, collectVariadic, []);
523
+ sub.option(flagStr, description, collectVariadic, []);
447
524
  } else if (flag.type === "boolean") {
448
- sub.option(flagStr, flag.desc, (value) => parseBooleanValue(value, flag.name));
525
+ const option = sub.createOption(flagStr, description);
526
+ if (flag.name.startsWith("no-")) {
527
+ option.negate = false;
528
+ option.attributeName = () => flag.name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
529
+ }
530
+ option.argParser((value) => parseBooleanValue(value, flag.name));
531
+ sub.addOption(option);
449
532
  } else if (flag.default !== void 0) {
450
- sub.option(flagStr, flag.desc, String(flag.default));
533
+ sub.option(flagStr, description, String(flag.default));
451
534
  } else {
452
- sub.option(flagStr, flag.desc);
535
+ sub.option(flagStr, description);
453
536
  }
454
537
  }
455
538
  if (cmd.usesAeHost !== false) {
@@ -509,6 +592,72 @@ function extractGlobalOptions(program2) {
509
592
  };
510
593
  }
511
594
 
595
+ // src/core/resume-command.ts
596
+ import childProcess from "child_process";
597
+ import fs from "fs";
598
+ import path from "path";
599
+ async function resumeSyncedCommand(entrypoint, args = process.argv.slice(2)) {
600
+ try {
601
+ if (!entrypoint || !path.isAbsolute(entrypoint)) return { status: "not-started" };
602
+ if (!fs.statSync(entrypoint).isFile()) return { status: "not-started" };
603
+ fs.accessSync(entrypoint, fs.constants.R_OK);
604
+ } catch {
605
+ return { status: "not-started" };
606
+ }
607
+ return new Promise((resolve3) => {
608
+ const isolateProcessGroup = process.platform !== "win32";
609
+ let child;
610
+ try {
611
+ child = childProcess.spawn(process.execPath, [entrypoint, ...args], {
612
+ cwd: process.cwd(),
613
+ stdio: "inherit",
614
+ // Terminal group signals must reach the child only through this parent.
615
+ detached: isolateProcessGroup,
616
+ env: { ...process.env, AE_CLI_NO_COMPAT_CHECK: "1" }
617
+ });
618
+ } catch {
619
+ resolve3({ status: "not-started" });
620
+ return;
621
+ }
622
+ let started = false;
623
+ const forward = (signal) => {
624
+ try {
625
+ if (isolateProcessGroup) {
626
+ if (child.pid && child.pid > 0) process.kill(-child.pid, signal);
627
+ } else child.kill(signal);
628
+ } catch {
629
+ }
630
+ };
631
+ const handlers = /* @__PURE__ */ new Map([
632
+ ["SIGINT", () => forward("SIGINT")],
633
+ ["SIGTERM", () => forward("SIGTERM")]
634
+ ]);
635
+ if (isolateProcessGroup) {
636
+ handlers.set("SIGHUP", () => forward("SIGHUP"));
637
+ handlers.set("SIGTSTP", () => {
638
+ forward("SIGSTOP");
639
+ process.kill(process.pid, "SIGSTOP");
640
+ });
641
+ handlers.set("SIGCONT", () => forward("SIGCONT"));
642
+ handlers.set("SIGWINCH", () => forward("SIGWINCH"));
643
+ }
644
+ for (const [signal, handler] of handlers) process.on(signal, handler);
645
+ const finish = (result) => {
646
+ for (const [signal, handler] of handlers) process.removeListener(signal, handler);
647
+ resolve3(result);
648
+ };
649
+ child.once("spawn", () => {
650
+ started = true;
651
+ });
652
+ child.on("error", () => {
653
+ if (!started) finish({ status: "not-started" });
654
+ });
655
+ child.once("close", (code, signal) => {
656
+ finish(signal ? { status: "signaled", signal } : { status: "exited", code: code ?? 1 });
657
+ });
658
+ });
659
+ }
660
+
512
661
  // src/core/feature-config-check.ts
513
662
  async function runFeatureConfigCheck(hostOverride, argv = process.argv) {
514
663
  if (shouldSkipAutoSync(argv) || argv.slice(2).some((arg) => arg === "--help" || arg === "-h" || arg === "--version" || arg === "-V")) return void 0;
@@ -525,7 +674,7 @@ async function runFeatureConfigCheck(hostOverride, argv = process.argv) {
525
674
 
526
675
  // src/commands/tracking/plan.ts
527
676
  import { readFile, writeFile, cp } from "fs/promises";
528
- import path2, { resolve as resolve2 } from "path";
677
+ import path3, { resolve as resolve2 } from "path";
529
678
 
530
679
  // src/core/tracking-client.ts
531
680
  var DEBUG_BASE = "/v1/ta/bury/manage/debug";
@@ -661,7 +810,7 @@ var TrackingClient = class {
661
810
  headers["content-type"] = "application/json";
662
811
  init.body = JSON.stringify(body);
663
812
  }
664
- const resp = await fetch(url, init);
813
+ const resp = await fetch(url, { ...init, ...externalCliTokenRequestOptions(url) });
665
814
  const env = safeJsonParse(await resp.text());
666
815
  logger.api(method, url, resp.status, body, env);
667
816
  if (resp.status === 401) {
@@ -722,8 +871,8 @@ var TrackingClient = class {
722
871
  }
723
872
  return env;
724
873
  }
725
- async debugGet(path4, params) {
726
- const data = await this.requestJson(`${DEBUG_BASE}${path4}`, { ...params, "@t": Date.now() });
874
+ async debugGet(path5, params) {
875
+ const data = await this.requestJson(`${DEBUG_BASE}${path5}`, { ...params, "@t": Date.now() });
727
876
  return data;
728
877
  }
729
878
  async listDevice(projectId) {
@@ -799,8 +948,8 @@ function normalize(data) {
799
948
  }
800
949
 
801
950
  // src/tracking/plan/draft.ts
802
- import fs from "fs";
803
- import path from "path";
951
+ import fs2 from "fs";
952
+ import path2 from "path";
804
953
 
805
954
  // src/tracking/plan/autotrack.ts
806
955
  var TAG = {
@@ -1170,23 +1319,23 @@ function resolveTrackingHost(program2, opts) {
1170
1319
  }
1171
1320
  return host;
1172
1321
  }
1173
- function isExistingDirectory(path4) {
1174
- if (!existsSync2(path4)) return false;
1322
+ function isExistingDirectory(path5) {
1323
+ if (!existsSync2(path5)) return false;
1175
1324
  try {
1176
- return statSync(path4).isDirectory();
1325
+ return statSync(path5).isDirectory();
1177
1326
  } catch {
1178
1327
  return false;
1179
1328
  }
1180
1329
  }
1181
- function assertOutputFilePath(path4, optionName = "--out") {
1182
- const trimmed = path4.trim();
1330
+ function assertOutputFilePath(path5, optionName = "--out") {
1331
+ const trimmed = path5.trim();
1183
1332
  if (trimmed.endsWith("/") || trimmed.endsWith("\\") || isExistingDirectory(trimmed)) {
1184
1333
  console.error(t("error.output_path_is_directory", { path: trimmed, option: optionName }));
1185
1334
  process.exit(1);
1186
1335
  }
1187
1336
  }
1188
- function assertInputFilePath(path4, optionName = "--in") {
1189
- const trimmed = path4.trim();
1337
+ function assertInputFilePath(path5, optionName = "--in") {
1338
+ const trimmed = path5.trim();
1190
1339
  if (!existsSync2(trimmed)) {
1191
1340
  console.error(t("error.input_path_not_found", { path: trimmed, option: optionName }));
1192
1341
  process.exit(1);
@@ -1337,7 +1486,7 @@ function registerPlan(cmd, rootProgram) {
1337
1486
  lastRes = await client.uploadProgramExcel({
1338
1487
  projectId: opts.project,
1339
1488
  file,
1340
- filename: path2.basename(opts.xlsx),
1489
+ filename: path3.basename(opts.xlsx),
1341
1490
  lang: locale
1342
1491
  });
1343
1492
  console.log(JSON.stringify(lastRes, null, 2));
@@ -1542,7 +1691,7 @@ async function detectProject(cwd) {
1542
1691
 
1543
1692
  // src/tracking/xlsx/read.ts
1544
1693
  import * as nodeFs from "fs";
1545
- import path3 from "path";
1694
+ import path4 from "path";
1546
1695
  var setXlsxFs = set_fs;
1547
1696
  if (typeof setXlsxFs === "function") {
1548
1697
  setXlsxFs(nodeFs);
@@ -1855,7 +2004,7 @@ async function readTemplateXlsx(filePath) {
1855
2004
  } catch (err) {
1856
2005
  throw new Error(t("error.xlsx_read_failed", { path: filePath, error: String(err) }));
1857
2006
  }
1858
- const planName = path3.basename(filePath, path3.extname(filePath));
2007
+ const planName = path4.basename(filePath, path4.extname(filePath));
1859
2008
  const source = "template";
1860
2009
  let events = [];
1861
2010
  let event_properties = [];
@@ -2305,7 +2454,12 @@ async function parseProgram(program2, argv = process.argv) {
2305
2454
  try {
2306
2455
  await program2.parseAsync(normalizeSubcommandVersionOption(program2, argv));
2307
2456
  } catch (error) {
2308
- if (!(error instanceof CredentialStoreUnreadableError)) throw error;
2457
+ if (error instanceof BusinessDisabledError) {
2458
+ printError("permission", error.message, error.hint, error.code);
2459
+ process.exitCode = 1;
2460
+ return;
2461
+ }
2462
+ if (!(error instanceof CredentialStoreUnreadableError) && !(error instanceof ExternalCliTokenError)) throw error;
2309
2463
  printError("config", error.message, error.hint, error.code);
2310
2464
  process.exitCode = 1;
2311
2465
  }
@@ -2410,12 +2564,63 @@ function registerInstall(program2) {
2410
2564
  });
2411
2565
  }
2412
2566
 
2567
+ // src/framework/business-filter.ts
2568
+ import { Help } from "commander";
2569
+ function commandPath(command) {
2570
+ const result = [];
2571
+ for (let current = command; current?.parent; current = current.parent) {
2572
+ result.unshift(current.name());
2573
+ }
2574
+ return result;
2575
+ }
2576
+ function configureBusinessCommands(program2, options = {}) {
2577
+ const readStates = options.readStates ?? (() => readCurrentBusinessConfig(options.hostOverride));
2578
+ const isVisible = (command) => {
2579
+ const business = businessForCommand(commandPath(command));
2580
+ return !business || readStates()[business] !== false;
2581
+ };
2582
+ const helpConfiguration = {
2583
+ visibleCommands(command) {
2584
+ return Help.prototype.visibleCommands.call(this, command).filter(isVisible);
2585
+ },
2586
+ formatHelp(command, helper) {
2587
+ if (!isVisible(command)) {
2588
+ const business = businessForCommand(commandPath(command));
2589
+ return `The '${business}' business is not enabled for the current environment.
2590
+ Run: ae-cli config refresh
2591
+ `;
2592
+ }
2593
+ return Help.prototype.formatHelp.call(this, command, helper);
2594
+ }
2595
+ };
2596
+ const configureHelp = (command) => {
2597
+ command.configureHelp(helpConfiguration);
2598
+ command.commands.forEach(configureHelp);
2599
+ };
2600
+ configureHelp(program2);
2601
+ program2.on("beforeAllHelp", (context) => {
2602
+ if (isVisible(context.command)) return;
2603
+ const business = businessForCommand(commandPath(context.command));
2604
+ context.write(`The '${business}' business is not enabled for the current environment.
2605
+ Run: ae-cli config refresh
2606
+ `);
2607
+ context.write = () => {
2608
+ };
2609
+ });
2610
+ program2.hook("preAction", async (_root, actionCommand) => {
2611
+ const business = businessForCommand(commandPath(actionCommand));
2612
+ if (!business) return;
2613
+ const opts = actionCommand.optsWithGlobals();
2614
+ await (options.assertEnabled ?? assertBusinessEnabled)(business, opts.host ?? options.hostOverride);
2615
+ });
2616
+ }
2617
+
2413
2618
  // src/index.ts
2414
2619
  var require2 = createRequire(import.meta.url);
2415
2620
  var pkg = require2("../package.json");
2416
2621
  var { version } = pkg;
2417
2622
  var program = new CommanderCommand();
2418
- program.name("ae-cli").version(version).description("CLI tool for ThinkingAI (AE) analytics platform").option("--host <url>", "Override active AE host URL (e.g., https://ta.thinkingdata.cn)").option("--mcp-url <url>", "Override MCP server URL (e.g., http://localhost/mcp/http/example)").option("--format <format>", "Output format: json | table", "json").option("--jq <expr>", "jq 1.8 filter over command payload (via jq-wasm), applied before output envelope").option(
2623
+ program.name("ae-cli").version(version).description("CLI tool for ThinkingAI (AE) analytics platform").option("--host <url>", "Override active AE host URL (e.g., https://ta.thinkingdata.cn)").option("--cli-token-file <path>", "Use a read-only JSON CLI token file containing url and token for this invocation").option("--mcp-url <url>", "Override MCP server URL (e.g., http://localhost/mcp/http/example)").option("--format <format>", "Output format: json | table", "json").option("--jq <expr>", "jq 1.8 filter over command payload (via jq-wasm), applied before output envelope").option(
2419
2624
  "--validate",
2420
2625
  "Optional: validate/normalize capability input only (gateway /validate). Use alone while fixing complex params/qp; do not stack with --dry-run",
2421
2626
  false
@@ -2435,108 +2640,114 @@ function warnLoadFailure(label, err) {
2435
2640
  async function loadCommands() {
2436
2641
  const commands = [];
2437
2642
  try {
2438
- const teAnalysis = await import("./te-analysis-ISXKJKRT.js");
2643
+ const teAnalysis = await import("./te-analysis-ADX7RKO4.js");
2439
2644
  commands.push(...teAnalysis.default);
2440
2645
  } catch (err) {
2441
2646
  warnLoadFailure("domain te-analysis", err);
2442
2647
  }
2443
2648
  try {
2444
- const engage = await import("./te-engage-BZE3MBKT.js");
2649
+ const engage = await import("./te-engage-VE2NUH5V.js");
2445
2650
  commands.push(...engage.default);
2446
2651
  } catch (err) {
2447
2652
  warnLoadFailure("domain te-engage", err);
2448
2653
  }
2449
2654
  try {
2450
- const community = await import("./te-community-42M7ICDO.js");
2655
+ const community = await import("./te-community-PREDRXG3.js");
2451
2656
  commands.push(...community.default);
2452
2657
  } catch (err) {
2453
2658
  warnLoadFailure("domain te-community", err);
2454
2659
  }
2455
2660
  try {
2456
- const dataops = await import("./te-dataops-BNKNZ4F2.js");
2661
+ const dataops = await import("./te-dataops-ITWJHO2U.js");
2457
2662
  commands.push(...dataops.default);
2458
2663
  } catch (err) {
2459
2664
  warnLoadFailure("domain te-dataops", err);
2460
2665
  }
2461
2666
  try {
2462
- const teKb = await import("./te-kb-ULATOTQ3.js");
2667
+ const teKb = await import("./te-kb-WSMOW7WS.js");
2463
2668
  commands.push(...teKb.default);
2464
2669
  } catch (err) {
2465
2670
  warnLoadFailure("domain te-kb", err);
2466
2671
  }
2467
2672
  try {
2468
- const teTeam = await import("./te-team-YA6SNOJ3.js");
2673
+ const teTeam = await import("./te-team-T2WRLOOD.js");
2469
2674
  commands.push(...teTeam.default);
2470
2675
  } catch (err) {
2471
2676
  warnLoadFailure("domain te-team", err);
2472
2677
  }
2473
2678
  try {
2474
- const teAgent = await import("./te-agent-AORRE2FM.js");
2679
+ const teAgent = await import("./te-agent-WBKIFEQD.js");
2475
2680
  commands.push(...teAgent.default);
2476
2681
  } catch (err) {
2477
2682
  warnLoadFailure("domain te-agent", err);
2478
2683
  }
2479
2684
  try {
2480
- const memory = await import("./memory-CQKH2JAV.js");
2685
+ const memory = await import("./memory-HHPX3NF2.js");
2481
2686
  commands.push(...memory.default);
2482
2687
  } catch (err) {
2483
2688
  warnLoadFailure("domain memory", err);
2484
2689
  }
2485
- const automation = await import("./automation-VAAQBM7Y.js");
2690
+ const automation = await import("./automation-NAR5DDGL.js");
2486
2691
  commands.push(...automation.default);
2487
2692
  try {
2488
- const things = await import("./things-DTCOQIQB.js");
2693
+ const things = await import("./things-6QOMFXOG.js");
2489
2694
  commands.push(...things.default);
2490
2695
  } catch (err) {
2491
2696
  warnLoadFailure("domain things", err);
2492
2697
  }
2493
2698
  try {
2494
- const workspace = await import("./workspace-JEOHKFPX.js");
2699
+ const workspace = await import("./workspace-LYDAP647.js");
2495
2700
  commands.push(...workspace.default);
2496
2701
  } catch (err) {
2497
2702
  warnLoadFailure("domain workspace", err);
2498
2703
  }
2499
2704
  try {
2500
- const teSystem = await import("./te-system-UGHVKBVV.js");
2705
+ const teSystem = await import("./te-system-YM657FKO.js");
2501
2706
  commands.push(...teSystem.default);
2502
2707
  } catch (err) {
2503
2708
  warnLoadFailure("domain te-system", err);
2504
2709
  }
2505
2710
  try {
2506
- const metadata = await import("./metadata-EMFGUI2W.js");
2711
+ const metadata = await import("./metadata-HEQQEEG3.js");
2507
2712
  commands.push(...metadata.default);
2508
2713
  } catch (err) {
2509
2714
  warnLoadFailure("domain metadata", err);
2510
2715
  }
2511
2716
  try {
2512
- const personalSemanticPreference = await import("./personal-semantic-preference-SLWVVYZ4.js");
2717
+ const personalSemanticPreference = await import("./personal-semantic-preference-V4L6ZWR2.js");
2513
2718
  commands.push(...personalSemanticPreference.default);
2514
2719
  } catch (err) {
2515
2720
  warnLoadFailure("domain personal-semantic-preference", err);
2516
2721
  }
2517
2722
  try {
2518
- const projectSemantic = await import("./project-semantic-DPSZBKQD.js");
2723
+ const projectSemantic = await import("./project-semantic-NKHKJX6M.js");
2519
2724
  commands.push(...projectSemantic.default);
2520
2725
  } catch (err) {
2521
2726
  warnLoadFailure("domain project-semantic", err);
2522
2727
  }
2523
2728
  try {
2524
- const dataIntegration = await import("./data-integration-BCLQFTGU.js");
2729
+ const dataIntegration = await import("./data-integration-6UAZO4GG.js");
2525
2730
  commands.push(...dataIntegration.default);
2526
2731
  } catch (err) {
2527
2732
  warnLoadFailure("domain data-integration", err);
2528
2733
  }
2529
2734
  try {
2530
- const context = await import("./context-NGVFPCBK.js");
2735
+ const context = await import("./context-F6FCGTF3.js");
2531
2736
  commands.push(...context.default);
2532
2737
  } catch (err) {
2533
2738
  warnLoadFailure("domain context", err);
2534
2739
  }
2740
+ try {
2741
+ const evaluation = await import("./evaluation-4LO2O4AF.js");
2742
+ commands.push(...evaluation.default);
2743
+ } catch (err) {
2744
+ warnLoadFailure("domain evaluation", err);
2745
+ }
2535
2746
  return commands;
2536
2747
  }
2537
2748
  async function registerAuthCommands() {
2538
2749
  try {
2539
- const { registerAuth } = await import("./auth-RQBO6MTY.js");
2750
+ const { registerAuth } = await import("./auth-YEIJLBFY.js");
2540
2751
  registerAuth(program);
2541
2752
  } catch (err) {
2542
2753
  warnLoadFailure("auth commands", err);
@@ -2544,7 +2755,7 @@ async function registerAuthCommands() {
2544
2755
  }
2545
2756
  async function registerConfigCommands() {
2546
2757
  try {
2547
- const { registerConfig } = await import("./config-SICKWZ2A.js");
2758
+ const { registerConfig } = await import("./config-VWVPR4WW.js");
2548
2759
  registerConfig(program);
2549
2760
  } catch (err) {
2550
2761
  warnLoadFailure("config commands", err);
@@ -2552,7 +2763,7 @@ async function registerConfigCommands() {
2552
2763
  }
2553
2764
  async function registerCapabilityCommands() {
2554
2765
  try {
2555
- const { registerCapability } = await import("./capability-JRIFC4AJ.js");
2766
+ const { registerCapability } = await import("./capability-P7DD4Q73.js");
2556
2767
  registerCapability(program);
2557
2768
  } catch (err) {
2558
2769
  warnLoadFailure("capability commands", err);
@@ -2560,7 +2771,7 @@ async function registerCapabilityCommands() {
2560
2771
  }
2561
2772
  async function registerSyncCommand() {
2562
2773
  try {
2563
- const { registerSync } = await import("./sync-RZIAV37C.js");
2774
+ const { registerSync } = await import("./sync-ZJMXCRIN.js");
2564
2775
  registerSync(program);
2565
2776
  } catch (err) {
2566
2777
  warnLoadFailure("sync commands", err);
@@ -2568,7 +2779,7 @@ async function registerSyncCommand() {
2568
2779
  }
2569
2780
  async function registerModelCommand() {
2570
2781
  try {
2571
- const { registerModel } = await import("./model-VX5M2CJ6.js");
2782
+ const { registerModel } = await import("./model-7UHGWYVR.js");
2572
2783
  registerModel(program);
2573
2784
  } catch (err) {
2574
2785
  warnLoadFailure("model commands", err);
@@ -2576,21 +2787,44 @@ async function registerModelCommand() {
2576
2787
  }
2577
2788
  async function registerUpdateCommand() {
2578
2789
  try {
2579
- const { registerUpdate } = await import("./update-ESNYKUVR.js");
2790
+ const { registerUpdate } = await import("./update-I4MOUYOX.js");
2580
2791
  registerUpdate(program);
2581
2792
  } catch (err) {
2582
2793
  warnLoadFailure("update commands", err);
2583
2794
  }
2584
2795
  }
2585
2796
  async function main() {
2797
+ const args = process.argv.slice(2);
2798
+ if (args.length === 1 && args[0] === "--runtime-capabilities") {
2799
+ process.stdout.write(JSON.stringify(require2("../bin/runtime-capabilities.json")) + "\n");
2800
+ return;
2801
+ }
2802
+ const kbIndex = args.indexOf("kb");
2803
+ const executionQuery = kbExecutionContextRequired() && kbIndex >= 0 && ["+list", "+index", "+grep", "+read"].includes(args[kbIndex + 1]);
2804
+ if (executionQuery) readKbExecutionContext();
2805
+ const helpRequested = isHelpInvocation(args);
2806
+ setExternalCliTokenFile(globalOptionValue(process.argv.slice(2), "--cli-token-file"));
2807
+ if (!executionQuery && !helpRequested && !process.argv.slice(2).some((arg) => ["--version", "-V"].includes(arg))) {
2808
+ readExternalCliToken(globalOptionValue(process.argv.slice(2), "--host"));
2809
+ }
2586
2810
  const pkgInfo = getLocalCliPackageInfo();
2587
- if (!isRootUpdateCommand(process.argv.slice(2))) {
2811
+ if (!executionQuery && !helpRequested && !isRootUpdateCommand(process.argv.slice(2))) {
2588
2812
  const compat = await runHostCompatCheck(
2589
2813
  pkgInfo,
2590
2814
  globalOptionValue(process.argv.slice(2), "--host")
2591
2815
  );
2592
2816
  if (compat.status === "synced") {
2593
- const message = compat.direction === "skills" ? `Skills were synchronized for ae-cli ${compat.expected}.` : `ae-cli changed from ${compat.current} to ${compat.expected} for this host.`;
2817
+ const resumed = await resumeSyncedCommand(compat.entrypoint);
2818
+ if (resumed.status === "exited") {
2819
+ process.exitCode = resumed.code;
2820
+ return;
2821
+ }
2822
+ if (resumed.status === "signaled") {
2823
+ process.exitCode = 128 + osConstants.signals[resumed.signal];
2824
+ process.kill(process.pid, resumed.signal);
2825
+ return;
2826
+ }
2827
+ const message = compat.direction === "skills" ? `Skills synchronization for ae-cli ${compat.expected} succeeded, but the synchronized CLI could not be started. The requested command was not executed.` : `CLI and Skills synchronization from ${compat.current} to ${compat.expected} succeeded, but the synchronized CLI could not be started. The requested command was not executed.`;
2594
2828
  printError(
2595
2829
  "config",
2596
2830
  message,
@@ -2601,6 +2835,8 @@ async function main() {
2601
2835
  expected: compat.expected,
2602
2836
  cluster: compat.cluster,
2603
2837
  direction: compat.direction,
2838
+ versionSyncSucceeded: true,
2839
+ originalCommandExecuted: false,
2604
2840
  retryOriginalCommand: true
2605
2841
  },
2606
2842
  { log: false }
@@ -2609,7 +2845,7 @@ async function main() {
2609
2845
  return;
2610
2846
  }
2611
2847
  }
2612
- await runFeatureConfigCheck(globalOptionValue(process.argv.slice(2), "--host"));
2848
+ if (!executionQuery && !helpRequested) await runFeatureConfigCheck(globalOptionValue(process.argv.slice(2), "--host"));
2613
2849
  const commands = await loadCommands();
2614
2850
  registerCommands(program, commands);
2615
2851
  await registerAuthCommands();
@@ -2620,10 +2856,30 @@ async function main() {
2620
2856
  await registerUpdateCommand();
2621
2857
  registerInstall(program);
2622
2858
  registerTracking(program);
2859
+ if (!executionQuery) configureBusinessCommands(program, { hostOverride: globalOptionValue(process.argv.slice(2), "--host") });
2623
2860
  rejectUnknownHelpCommandPath(program, process.argv.slice(2));
2624
2861
  await parseProgram(program);
2625
2862
  }
2626
- await main();
2863
+ function isHelpInvocation(args) {
2864
+ if (args.length === 0 || args.includes("--help") || args.includes("-h")) return true;
2865
+ for (let index = 0; index < args.length; index += 1) {
2866
+ const token = args[index];
2867
+ if (token === "--") return false;
2868
+ if (token.startsWith("-")) {
2869
+ if (optionConsumesValue(token)) index += 1;
2870
+ continue;
2871
+ }
2872
+ if (token === "help") return true;
2873
+ }
2874
+ return false;
2875
+ }
2876
+ try {
2877
+ await main();
2878
+ } catch (error) {
2879
+ if (!(error instanceof ExternalCliTokenError) && !(error instanceof CliValidationError)) throw error;
2880
+ printError(error instanceof ExternalCliTokenError ? "config" : "validation", error.message, error.hint, error.code);
2881
+ process.exitCode = 1;
2882
+ }
2627
2883
  function rejectUnknownHelpCommandPath(root, args) {
2628
2884
  if (!args.includes("--help") && !args.includes("-h")) {
2629
2885
  return;
@@ -2656,15 +2912,23 @@ function optionConsumesValue(token) {
2656
2912
  if (token.includes("=")) {
2657
2913
  return false;
2658
2914
  }
2659
- return token === "--host" || token === "--mcp-url" || token === "--format" || token === "--jq" || token === "--agent-context";
2915
+ return token === "--host" || token === "--cli-token-file" || token === "--mcp-url" || token === "--format" || token === "--jq" || token === "--agent-context";
2660
2916
  }
2661
2917
  function globalOptionValue(args, option) {
2918
+ let value;
2662
2919
  for (let i = 0; i < args.length; i += 1) {
2663
2920
  const token = args[i];
2664
- if (token === option) return args[i + 1];
2665
- if (token.startsWith(`${option}=`)) return token.slice(option.length + 1);
2921
+ if (token === "--") break;
2922
+ if (optionConsumesValue(token)) {
2923
+ const next = args[i + 1];
2924
+ if (next === void 0) {
2925
+ throw new CliValidationError(`${token} requires a value.`, { code: "MISSING_OPTION_VALUE" });
2926
+ }
2927
+ if (token === option) value = next;
2928
+ i += 1;
2929
+ } else if (token.startsWith(`${option}=`)) value = token.slice(option.length + 1);
2666
2930
  }
2667
- return void 0;
2931
+ return value;
2668
2932
  }
2669
2933
  function isRootUpdateCommand(args) {
2670
2934
  for (let i = 0; i < args.length; i += 1) {