@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
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";
18
- import "./chunk-CT7QDJS6.js";
20
+ } from "./chunk-72NJKS7O.js";
21
+ import "./chunk-QVRIDN42.js";
22
+ import "./chunk-OAWPT7VP.js";
23
+ import "./chunk-JEUXDY3B.js";
19
24
  import {
20
- requiresConfirmation
21
- } from "./chunk-AMBFK2K3.js";
22
- import "./chunk-AP7YP2NX.js";
23
- import "./chunk-S6M42KND.js";
25
+ EvalApiError
26
+ } from "./chunk-YVG6QD3V.js";
27
+ import {
28
+ resolveHost
29
+ } from "./chunk-IN7KKL6K.js";
24
30
  import {
25
31
  TeAgentApiError,
26
32
  TeAgentCredentialsError
27
- } from "./chunk-3YVEAZUN.js";
33
+ } from "./chunk-RJHGDWSC.js";
34
+ import {
35
+ printError,
36
+ printOutput
37
+ } from "./chunk-QZLRHGVH.js";
28
38
  import {
29
39
  CapabilityGatewayError,
30
40
  executeCapability,
31
41
  uploadInputFileBytes
32
- } from "./chunk-VZZNLV3I.js";
33
- import {
34
- resolveHost
35
- } from "./chunk-OP44TT4H.js";
42
+ } from "./chunk-3SDHJOCR.js";
43
+ import "./chunk-Y74WTIKJ.js";
36
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-2UW3Y463.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,17 +301,26 @@ 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) {
257
- printError(err.type, message, err.hint ?? capabilityGatewayHint(err), err.code, err.meta);
308
+ printError(
309
+ err.type,
310
+ message,
311
+ err.hint ?? capabilityGatewayHint(err),
312
+ err.code,
313
+ err.meta,
314
+ { details: err.details }
315
+ );
258
316
  } else if (err instanceof CommunityReportError) {
259
317
  printError("api", message, err.hint, err.code, err.meta, { log: false });
260
318
  } else if (err instanceof LocalDataUploadError) {
261
319
  printError("api", message, err.hint, err.code, err.meta, { log: false });
262
- } else if (err instanceof CredentialStoreUnreadableError) {
320
+ } else if (err instanceof CredentialStoreUnreadableError || err instanceof ExternalCliTokenError) {
263
321
  printError("config", message, err.hint, err.code);
322
+ } else if (err instanceof EvalApiError) {
323
+ printError("api", message, err.hint, err.code, void 0, { log: false });
264
324
  } else if (err instanceof SecureStoreAuthError) {
265
325
  printError("auth", message, "Run: ae-cli auth login", err.code);
266
326
  } else if (err instanceof TeAgentApiError) {
@@ -326,14 +386,14 @@ function createRuntimeContext(cmd, opts, globalOpts) {
326
386
  let _communityReportModule = null;
327
387
  async function getCommunityReportClient() {
328
388
  if (!_communityReportModule) {
329
- _communityReportModule = await import("./community-report-client-PEERQCX2.js");
389
+ _communityReportModule = await import("./community-report-client-TJVCLZ3K.js");
330
390
  }
331
391
  return _communityReportModule;
332
392
  }
333
393
  let _localDataUploadModule = null;
334
394
  async function getLocalDataUploadClient() {
335
395
  if (!_localDataUploadModule) {
336
- _localDataUploadModule = await import("./local-data-upload-client-TWMHFLUA.js");
396
+ _localDataUploadModule = await import("./local-data-upload-client-KCMG6J62.js");
337
397
  }
338
398
  return _localDataUploadModule;
339
399
  }
@@ -353,9 +413,23 @@ function createRuntimeContext(cmd, opts, globalOpts) {
353
413
  if (val === void 0 || val === null || val === "") return void 0;
354
414
  return Number(val);
355
415
  },
416
+ int64(name) {
417
+ const val = opts[camelCase(name)];
418
+ if (val === void 0 || val === null || val === "") return 0n;
419
+ return BigInt(String(val));
420
+ },
421
+ optionalInt64(name) {
422
+ const val = opts[camelCase(name)];
423
+ if (val === void 0 || val === null || val === "") return void 0;
424
+ return BigInt(String(val));
425
+ },
356
426
  bool(name) {
357
427
  return Boolean(opts[camelCase(name)]);
358
428
  },
429
+ optionalBool(name) {
430
+ const val = opts[camelCase(name)];
431
+ return typeof val === "boolean" ? val : void 0;
432
+ },
359
433
  json(name) {
360
434
  const val = opts[camelCase(name)];
361
435
  if (val === void 0 || val === null) return void 0;
@@ -363,6 +437,11 @@ function createRuntimeContext(cmd, opts, globalOpts) {
363
437
  try {
364
438
  return safeJsonParse(String(val));
365
439
  } catch {
440
+ if (cmd.flags.some((flag) => flag.name === name && flag.sensitive)) {
441
+ throw new CliValidationError(`Invalid JSON for --${name}.`, {
442
+ hint: "Provide valid JSON with quoted keys and strings. Sensitive input is omitted from diagnostics."
443
+ });
444
+ }
366
445
  printError("validation", `Invalid JSON for --${name}: ${val}`);
367
446
  process.exit(1);
368
447
  }
@@ -385,6 +464,10 @@ function createRuntimeContext(cmd, opts, globalOpts) {
385
464
  return globalOpts.host;
386
465
  },
387
466
  host() {
467
+ if (cmd.service === "kb" && ["+list", "+index", "+grep", "+read"].includes(cmd.command)) {
468
+ const context = readKbExecutionContext();
469
+ if (context) return globalOpts.host || context.origin;
470
+ }
388
471
  if (globalOpts.host) return globalOpts.host;
389
472
  return getActiveHost();
390
473
  },
@@ -442,14 +525,21 @@ function registerCommands(program2, commands) {
442
525
  const sub = parent.command(cmd.command, { hidden: cmd.hidden === true }).description(cmd.description);
443
526
  for (const flag of cmd.flags) {
444
527
  const flagStr = buildFlagString(flag);
528
+ const description = flag.required ? `${flag.desc} (required)` : flag.desc;
445
529
  if (flag.variadic) {
446
- sub.option(flagStr, flag.desc, collectVariadic, []);
530
+ sub.option(flagStr, description, collectVariadic, []);
447
531
  } else if (flag.type === "boolean") {
448
- sub.option(flagStr, flag.desc, (value) => parseBooleanValue(value, flag.name));
532
+ const option = sub.createOption(flagStr, description);
533
+ if (flag.name.startsWith("no-")) {
534
+ option.negate = false;
535
+ option.attributeName = () => flag.name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
536
+ }
537
+ option.argParser((value) => parseBooleanValue(value, flag.name));
538
+ sub.addOption(option);
449
539
  } else if (flag.default !== void 0) {
450
- sub.option(flagStr, flag.desc, String(flag.default));
540
+ sub.option(flagStr, description, String(flag.default));
451
541
  } else {
452
- sub.option(flagStr, flag.desc);
542
+ sub.option(flagStr, description);
453
543
  }
454
544
  }
455
545
  if (cmd.usesAeHost !== false) {
@@ -509,6 +599,72 @@ function extractGlobalOptions(program2) {
509
599
  };
510
600
  }
511
601
 
602
+ // src/core/resume-command.ts
603
+ import childProcess from "child_process";
604
+ import fs from "fs";
605
+ import path from "path";
606
+ async function resumeSyncedCommand(entrypoint, args = process.argv.slice(2)) {
607
+ try {
608
+ if (!entrypoint || !path.isAbsolute(entrypoint)) return { status: "not-started" };
609
+ if (!fs.statSync(entrypoint).isFile()) return { status: "not-started" };
610
+ fs.accessSync(entrypoint, fs.constants.R_OK);
611
+ } catch {
612
+ return { status: "not-started" };
613
+ }
614
+ return new Promise((resolve3) => {
615
+ const isolateProcessGroup = process.platform !== "win32";
616
+ let child;
617
+ try {
618
+ child = childProcess.spawn(process.execPath, [entrypoint, ...args], {
619
+ cwd: process.cwd(),
620
+ stdio: "inherit",
621
+ // Terminal group signals must reach the child only through this parent.
622
+ detached: isolateProcessGroup,
623
+ env: { ...process.env, AE_CLI_NO_COMPAT_CHECK: "1" }
624
+ });
625
+ } catch {
626
+ resolve3({ status: "not-started" });
627
+ return;
628
+ }
629
+ let started = false;
630
+ const forward = (signal) => {
631
+ try {
632
+ if (isolateProcessGroup) {
633
+ if (child.pid && child.pid > 0) process.kill(-child.pid, signal);
634
+ } else child.kill(signal);
635
+ } catch {
636
+ }
637
+ };
638
+ const handlers = /* @__PURE__ */ new Map([
639
+ ["SIGINT", () => forward("SIGINT")],
640
+ ["SIGTERM", () => forward("SIGTERM")]
641
+ ]);
642
+ if (isolateProcessGroup) {
643
+ handlers.set("SIGHUP", () => forward("SIGHUP"));
644
+ handlers.set("SIGTSTP", () => {
645
+ forward("SIGSTOP");
646
+ process.kill(process.pid, "SIGSTOP");
647
+ });
648
+ handlers.set("SIGCONT", () => forward("SIGCONT"));
649
+ handlers.set("SIGWINCH", () => forward("SIGWINCH"));
650
+ }
651
+ for (const [signal, handler] of handlers) process.on(signal, handler);
652
+ const finish = (result) => {
653
+ for (const [signal, handler] of handlers) process.removeListener(signal, handler);
654
+ resolve3(result);
655
+ };
656
+ child.once("spawn", () => {
657
+ started = true;
658
+ });
659
+ child.on("error", () => {
660
+ if (!started) finish({ status: "not-started" });
661
+ });
662
+ child.once("close", (code, signal) => {
663
+ finish(signal ? { status: "signaled", signal } : { status: "exited", code: code ?? 1 });
664
+ });
665
+ });
666
+ }
667
+
512
668
  // src/core/feature-config-check.ts
513
669
  async function runFeatureConfigCheck(hostOverride, argv = process.argv) {
514
670
  if (shouldSkipAutoSync(argv) || argv.slice(2).some((arg) => arg === "--help" || arg === "-h" || arg === "--version" || arg === "-V")) return void 0;
@@ -525,7 +681,7 @@ async function runFeatureConfigCheck(hostOverride, argv = process.argv) {
525
681
 
526
682
  // src/commands/tracking/plan.ts
527
683
  import { readFile, writeFile, cp } from "fs/promises";
528
- import path2, { resolve as resolve2 } from "path";
684
+ import path3, { resolve as resolve2 } from "path";
529
685
 
530
686
  // src/core/tracking-client.ts
531
687
  var DEBUG_BASE = "/v1/ta/bury/manage/debug";
@@ -661,7 +817,7 @@ var TrackingClient = class {
661
817
  headers["content-type"] = "application/json";
662
818
  init.body = JSON.stringify(body);
663
819
  }
664
- const resp = await fetch(url, init);
820
+ const resp = await fetch(url, { ...init, ...externalCliTokenRequestOptions(url) });
665
821
  const env = safeJsonParse(await resp.text());
666
822
  logger.api(method, url, resp.status, body, env);
667
823
  if (resp.status === 401) {
@@ -722,8 +878,8 @@ var TrackingClient = class {
722
878
  }
723
879
  return env;
724
880
  }
725
- async debugGet(path4, params) {
726
- const data = await this.requestJson(`${DEBUG_BASE}${path4}`, { ...params, "@t": Date.now() });
881
+ async debugGet(path5, params) {
882
+ const data = await this.requestJson(`${DEBUG_BASE}${path5}`, { ...params, "@t": Date.now() });
727
883
  return data;
728
884
  }
729
885
  async listDevice(projectId) {
@@ -799,8 +955,8 @@ function normalize(data) {
799
955
  }
800
956
 
801
957
  // src/tracking/plan/draft.ts
802
- import fs from "fs";
803
- import path from "path";
958
+ import fs2 from "fs";
959
+ import path2 from "path";
804
960
 
805
961
  // src/tracking/plan/autotrack.ts
806
962
  var TAG = {
@@ -1170,23 +1326,23 @@ function resolveTrackingHost(program2, opts) {
1170
1326
  }
1171
1327
  return host;
1172
1328
  }
1173
- function isExistingDirectory(path4) {
1174
- if (!existsSync2(path4)) return false;
1329
+ function isExistingDirectory(path5) {
1330
+ if (!existsSync2(path5)) return false;
1175
1331
  try {
1176
- return statSync(path4).isDirectory();
1332
+ return statSync(path5).isDirectory();
1177
1333
  } catch {
1178
1334
  return false;
1179
1335
  }
1180
1336
  }
1181
- function assertOutputFilePath(path4, optionName = "--out") {
1182
- const trimmed = path4.trim();
1337
+ function assertOutputFilePath(path5, optionName = "--out") {
1338
+ const trimmed = path5.trim();
1183
1339
  if (trimmed.endsWith("/") || trimmed.endsWith("\\") || isExistingDirectory(trimmed)) {
1184
1340
  console.error(t("error.output_path_is_directory", { path: trimmed, option: optionName }));
1185
1341
  process.exit(1);
1186
1342
  }
1187
1343
  }
1188
- function assertInputFilePath(path4, optionName = "--in") {
1189
- const trimmed = path4.trim();
1344
+ function assertInputFilePath(path5, optionName = "--in") {
1345
+ const trimmed = path5.trim();
1190
1346
  if (!existsSync2(trimmed)) {
1191
1347
  console.error(t("error.input_path_not_found", { path: trimmed, option: optionName }));
1192
1348
  process.exit(1);
@@ -1337,7 +1493,7 @@ function registerPlan(cmd, rootProgram) {
1337
1493
  lastRes = await client.uploadProgramExcel({
1338
1494
  projectId: opts.project,
1339
1495
  file,
1340
- filename: path2.basename(opts.xlsx),
1496
+ filename: path3.basename(opts.xlsx),
1341
1497
  lang: locale
1342
1498
  });
1343
1499
  console.log(JSON.stringify(lastRes, null, 2));
@@ -1542,7 +1698,7 @@ async function detectProject(cwd) {
1542
1698
 
1543
1699
  // src/tracking/xlsx/read.ts
1544
1700
  import * as nodeFs from "fs";
1545
- import path3 from "path";
1701
+ import path4 from "path";
1546
1702
  var setXlsxFs = set_fs;
1547
1703
  if (typeof setXlsxFs === "function") {
1548
1704
  setXlsxFs(nodeFs);
@@ -1855,7 +2011,7 @@ async function readTemplateXlsx(filePath) {
1855
2011
  } catch (err) {
1856
2012
  throw new Error(t("error.xlsx_read_failed", { path: filePath, error: String(err) }));
1857
2013
  }
1858
- const planName = path3.basename(filePath, path3.extname(filePath));
2014
+ const planName = path4.basename(filePath, path4.extname(filePath));
1859
2015
  const source = "template";
1860
2016
  let events = [];
1861
2017
  let event_properties = [];
@@ -2305,7 +2461,12 @@ async function parseProgram(program2, argv = process.argv) {
2305
2461
  try {
2306
2462
  await program2.parseAsync(normalizeSubcommandVersionOption(program2, argv));
2307
2463
  } catch (error) {
2308
- if (!(error instanceof CredentialStoreUnreadableError)) throw error;
2464
+ if (error instanceof BusinessDisabledError) {
2465
+ printError("permission", error.message, error.hint, error.code);
2466
+ process.exitCode = 1;
2467
+ return;
2468
+ }
2469
+ if (!(error instanceof CredentialStoreUnreadableError) && !(error instanceof ExternalCliTokenError)) throw error;
2309
2470
  printError("config", error.message, error.hint, error.code);
2310
2471
  process.exitCode = 1;
2311
2472
  }
@@ -2410,12 +2571,63 @@ function registerInstall(program2) {
2410
2571
  });
2411
2572
  }
2412
2573
 
2574
+ // src/framework/business-filter.ts
2575
+ import { Help } from "commander";
2576
+ function commandPath(command) {
2577
+ const result = [];
2578
+ for (let current = command; current?.parent; current = current.parent) {
2579
+ result.unshift(current.name());
2580
+ }
2581
+ return result;
2582
+ }
2583
+ function configureBusinessCommands(program2, options = {}) {
2584
+ const readStates = options.readStates ?? (() => readCurrentBusinessConfig(options.hostOverride));
2585
+ const isVisible = (command) => {
2586
+ const business = businessForCommand(commandPath(command));
2587
+ return !business || readStates()[business] !== false;
2588
+ };
2589
+ const helpConfiguration = {
2590
+ visibleCommands(command) {
2591
+ return Help.prototype.visibleCommands.call(this, command).filter(isVisible);
2592
+ },
2593
+ formatHelp(command, helper) {
2594
+ if (!isVisible(command)) {
2595
+ const business = businessForCommand(commandPath(command));
2596
+ return `The '${business}' business is not enabled for the current environment.
2597
+ Run: ae-cli config refresh
2598
+ `;
2599
+ }
2600
+ return Help.prototype.formatHelp.call(this, command, helper);
2601
+ }
2602
+ };
2603
+ const configureHelp = (command) => {
2604
+ command.configureHelp(helpConfiguration);
2605
+ command.commands.forEach(configureHelp);
2606
+ };
2607
+ configureHelp(program2);
2608
+ program2.on("beforeAllHelp", (context) => {
2609
+ if (isVisible(context.command)) return;
2610
+ const business = businessForCommand(commandPath(context.command));
2611
+ context.write(`The '${business}' business is not enabled for the current environment.
2612
+ Run: ae-cli config refresh
2613
+ `);
2614
+ context.write = () => {
2615
+ };
2616
+ });
2617
+ program2.hook("preAction", async (_root, actionCommand) => {
2618
+ const business = businessForCommand(commandPath(actionCommand));
2619
+ if (!business) return;
2620
+ const opts = actionCommand.optsWithGlobals();
2621
+ await (options.assertEnabled ?? assertBusinessEnabled)(business, opts.host ?? options.hostOverride);
2622
+ });
2623
+ }
2624
+
2413
2625
  // src/index.ts
2414
2626
  var require2 = createRequire(import.meta.url);
2415
2627
  var pkg = require2("../package.json");
2416
2628
  var { version } = pkg;
2417
2629
  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(
2630
+ 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
2631
  "--validate",
2420
2632
  "Optional: validate/normalize capability input only (gateway /validate). Use alone while fixing complex params/qp; do not stack with --dry-run",
2421
2633
  false
@@ -2435,114 +2647,120 @@ function warnLoadFailure(label, err) {
2435
2647
  async function loadCommands() {
2436
2648
  const commands = [];
2437
2649
  try {
2438
- const teAnalysis = await import("./te-analysis-GP7DSQ7Q.js");
2650
+ const teAnalysis = await import("./te-analysis-USIK6ZZG.js");
2439
2651
  commands.push(...teAnalysis.default);
2440
2652
  } catch (err) {
2441
2653
  warnLoadFailure("domain te-analysis", err);
2442
2654
  }
2443
2655
  try {
2444
- const engage = await import("./te-engage-2CO6LRCX.js");
2656
+ const engage = await import("./te-engage-6C3HCFQR.js");
2445
2657
  commands.push(...engage.default);
2446
2658
  } catch (err) {
2447
2659
  warnLoadFailure("domain te-engage", err);
2448
2660
  }
2449
2661
  try {
2450
- const experiment = await import("./te-experiment-652CLXMU.js");
2662
+ const experiment = await import("./te-experiment-LVTRI3QK.js");
2451
2663
  commands.push(...experiment.default);
2452
2664
  } catch (err) {
2453
2665
  warnLoadFailure("domain te-experiment", err);
2454
2666
  }
2455
2667
  try {
2456
- const community = await import("./te-community-42M7ICDO.js");
2668
+ const community = await import("./te-community-WE2UU4XV.js");
2457
2669
  commands.push(...community.default);
2458
2670
  } catch (err) {
2459
2671
  warnLoadFailure("domain te-community", err);
2460
2672
  }
2461
2673
  try {
2462
- const dataops = await import("./te-dataops-BNKNZ4F2.js");
2674
+ const dataops = await import("./te-dataops-XNMO7MBF.js");
2463
2675
  commands.push(...dataops.default);
2464
2676
  } catch (err) {
2465
2677
  warnLoadFailure("domain te-dataops", err);
2466
2678
  }
2467
2679
  try {
2468
- const teKb = await import("./te-kb-ULATOTQ3.js");
2680
+ const teKb = await import("./te-kb-TUPGMVBY.js");
2469
2681
  commands.push(...teKb.default);
2470
2682
  } catch (err) {
2471
2683
  warnLoadFailure("domain te-kb", err);
2472
2684
  }
2473
2685
  try {
2474
- const teTeam = await import("./te-team-YA6SNOJ3.js");
2686
+ const teTeam = await import("./te-team-G4VEJJNL.js");
2475
2687
  commands.push(...teTeam.default);
2476
2688
  } catch (err) {
2477
2689
  warnLoadFailure("domain te-team", err);
2478
2690
  }
2479
2691
  try {
2480
- const teAgent = await import("./te-agent-AORRE2FM.js");
2692
+ const teAgent = await import("./te-agent-5ENVZJUH.js");
2481
2693
  commands.push(...teAgent.default);
2482
2694
  } catch (err) {
2483
2695
  warnLoadFailure("domain te-agent", err);
2484
2696
  }
2485
2697
  try {
2486
- const memory = await import("./memory-CQKH2JAV.js");
2698
+ const memory = await import("./memory-HHPX3NF2.js");
2487
2699
  commands.push(...memory.default);
2488
2700
  } catch (err) {
2489
2701
  warnLoadFailure("domain memory", err);
2490
2702
  }
2491
- const automation = await import("./automation-VAAQBM7Y.js");
2703
+ const automation = await import("./automation-NAR5DDGL.js");
2492
2704
  commands.push(...automation.default);
2493
2705
  try {
2494
- const things = await import("./things-DTCOQIQB.js");
2706
+ const things = await import("./things-22KQWC23.js");
2495
2707
  commands.push(...things.default);
2496
2708
  } catch (err) {
2497
2709
  warnLoadFailure("domain things", err);
2498
2710
  }
2499
2711
  try {
2500
- const workspace = await import("./workspace-JEOHKFPX.js");
2712
+ const workspace = await import("./workspace-LYDAP647.js");
2501
2713
  commands.push(...workspace.default);
2502
2714
  } catch (err) {
2503
2715
  warnLoadFailure("domain workspace", err);
2504
2716
  }
2505
2717
  try {
2506
- const teSystem = await import("./te-system-UGHVKBVV.js");
2718
+ const teSystem = await import("./te-system-YM657FKO.js");
2507
2719
  commands.push(...teSystem.default);
2508
2720
  } catch (err) {
2509
2721
  warnLoadFailure("domain te-system", err);
2510
2722
  }
2511
2723
  try {
2512
- const metadata = await import("./metadata-NR3PHR23.js");
2724
+ const metadata = await import("./metadata-TIFY24LW.js");
2513
2725
  commands.push(...metadata.default);
2514
2726
  } catch (err) {
2515
2727
  warnLoadFailure("domain metadata", err);
2516
2728
  }
2517
2729
  try {
2518
- const personalSemanticPreference = await import("./personal-semantic-preference-2RAI36P3.js");
2730
+ const personalSemanticPreference = await import("./personal-semantic-preference-WKJEGPTM.js");
2519
2731
  commands.push(...personalSemanticPreference.default);
2520
2732
  } catch (err) {
2521
2733
  warnLoadFailure("domain personal-semantic-preference", err);
2522
2734
  }
2523
2735
  try {
2524
- const projectSemantic = await import("./project-semantic-3BUGP3ZM.js");
2736
+ const projectSemantic = await import("./project-semantic-EIQVZNHW.js");
2525
2737
  commands.push(...projectSemantic.default);
2526
2738
  } catch (err) {
2527
2739
  warnLoadFailure("domain project-semantic", err);
2528
2740
  }
2529
2741
  try {
2530
- const dataIntegration = await import("./data-integration-BCLQFTGU.js");
2742
+ const dataIntegration = await import("./data-integration-6UAZO4GG.js");
2531
2743
  commands.push(...dataIntegration.default);
2532
2744
  } catch (err) {
2533
2745
  warnLoadFailure("domain data-integration", err);
2534
2746
  }
2535
2747
  try {
2536
- const context = await import("./context-NGVFPCBK.js");
2748
+ const context = await import("./context-F6FCGTF3.js");
2537
2749
  commands.push(...context.default);
2538
2750
  } catch (err) {
2539
2751
  warnLoadFailure("domain context", err);
2540
2752
  }
2753
+ try {
2754
+ const evaluation = await import("./evaluation-4LO2O4AF.js");
2755
+ commands.push(...evaluation.default);
2756
+ } catch (err) {
2757
+ warnLoadFailure("domain evaluation", err);
2758
+ }
2541
2759
  return commands;
2542
2760
  }
2543
2761
  async function registerAuthCommands() {
2544
2762
  try {
2545
- const { registerAuth } = await import("./auth-WA7YGGRT.js");
2763
+ const { registerAuth } = await import("./auth-OBQ5KVQM.js");
2546
2764
  registerAuth(program);
2547
2765
  } catch (err) {
2548
2766
  warnLoadFailure("auth commands", err);
@@ -2550,7 +2768,7 @@ async function registerAuthCommands() {
2550
2768
  }
2551
2769
  async function registerConfigCommands() {
2552
2770
  try {
2553
- const { registerConfig } = await import("./config-JOD5DOPE.js");
2771
+ const { registerConfig } = await import("./config-YZ6O2UQ2.js");
2554
2772
  registerConfig(program);
2555
2773
  } catch (err) {
2556
2774
  warnLoadFailure("config commands", err);
@@ -2558,7 +2776,7 @@ async function registerConfigCommands() {
2558
2776
  }
2559
2777
  async function registerCapabilityCommands() {
2560
2778
  try {
2561
- const { registerCapability } = await import("./capability-GAAYJ3IQ.js");
2779
+ const { registerCapability } = await import("./capability-LFSVNI5B.js");
2562
2780
  registerCapability(program);
2563
2781
  } catch (err) {
2564
2782
  warnLoadFailure("capability commands", err);
@@ -2566,7 +2784,7 @@ async function registerCapabilityCommands() {
2566
2784
  }
2567
2785
  async function registerSyncCommand() {
2568
2786
  try {
2569
- const { registerSync } = await import("./sync-RZIAV37C.js");
2787
+ const { registerSync } = await import("./sync-RV3OPCTI.js");
2570
2788
  registerSync(program);
2571
2789
  } catch (err) {
2572
2790
  warnLoadFailure("sync commands", err);
@@ -2574,7 +2792,7 @@ async function registerSyncCommand() {
2574
2792
  }
2575
2793
  async function registerModelCommand() {
2576
2794
  try {
2577
- const { registerModel } = await import("./model-VX5M2CJ6.js");
2795
+ const { registerModel } = await import("./model-7UHGWYVR.js");
2578
2796
  registerModel(program);
2579
2797
  } catch (err) {
2580
2798
  warnLoadFailure("model commands", err);
@@ -2582,21 +2800,44 @@ async function registerModelCommand() {
2582
2800
  }
2583
2801
  async function registerUpdateCommand() {
2584
2802
  try {
2585
- const { registerUpdate } = await import("./update-ESNYKUVR.js");
2803
+ const { registerUpdate } = await import("./update-XX4ILU7X.js");
2586
2804
  registerUpdate(program);
2587
2805
  } catch (err) {
2588
2806
  warnLoadFailure("update commands", err);
2589
2807
  }
2590
2808
  }
2591
2809
  async function main() {
2810
+ const args = process.argv.slice(2);
2811
+ if (args.length === 1 && args[0] === "--runtime-capabilities") {
2812
+ process.stdout.write(JSON.stringify(require2("../bin/runtime-capabilities.json")) + "\n");
2813
+ return;
2814
+ }
2815
+ const kbIndex = args.indexOf("kb");
2816
+ const executionQuery = kbExecutionContextRequired() && kbIndex >= 0 && ["+list", "+index", "+grep", "+read"].includes(args[kbIndex + 1]);
2817
+ if (executionQuery) readKbExecutionContext();
2818
+ const helpRequested = isHelpInvocation(args);
2819
+ setExternalCliTokenFile(globalOptionValue(process.argv.slice(2), "--cli-token-file"));
2820
+ if (!executionQuery && !helpRequested && !process.argv.slice(2).some((arg) => ["--version", "-V"].includes(arg))) {
2821
+ readExternalCliToken(globalOptionValue(process.argv.slice(2), "--host"));
2822
+ }
2592
2823
  const pkgInfo = getLocalCliPackageInfo();
2593
- if (!isRootUpdateCommand(process.argv.slice(2))) {
2824
+ if (!executionQuery && !helpRequested && !isRootUpdateCommand(process.argv.slice(2))) {
2594
2825
  const compat = await runHostCompatCheck(
2595
2826
  pkgInfo,
2596
2827
  globalOptionValue(process.argv.slice(2), "--host")
2597
2828
  );
2598
2829
  if (compat.status === "synced") {
2599
- 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.`;
2830
+ const resumed = await resumeSyncedCommand(compat.entrypoint);
2831
+ if (resumed.status === "exited") {
2832
+ process.exitCode = resumed.code;
2833
+ return;
2834
+ }
2835
+ if (resumed.status === "signaled") {
2836
+ process.exitCode = 128 + osConstants.signals[resumed.signal];
2837
+ process.kill(process.pid, resumed.signal);
2838
+ return;
2839
+ }
2840
+ 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.`;
2600
2841
  printError(
2601
2842
  "config",
2602
2843
  message,
@@ -2607,6 +2848,8 @@ async function main() {
2607
2848
  expected: compat.expected,
2608
2849
  cluster: compat.cluster,
2609
2850
  direction: compat.direction,
2851
+ versionSyncSucceeded: true,
2852
+ originalCommandExecuted: false,
2610
2853
  retryOriginalCommand: true
2611
2854
  },
2612
2855
  { log: false }
@@ -2615,7 +2858,7 @@ async function main() {
2615
2858
  return;
2616
2859
  }
2617
2860
  }
2618
- await runFeatureConfigCheck(globalOptionValue(process.argv.slice(2), "--host"));
2861
+ if (!executionQuery && !helpRequested) await runFeatureConfigCheck(globalOptionValue(process.argv.slice(2), "--host"));
2619
2862
  const commands = await loadCommands();
2620
2863
  registerCommands(program, commands);
2621
2864
  await registerAuthCommands();
@@ -2626,10 +2869,30 @@ async function main() {
2626
2869
  await registerUpdateCommand();
2627
2870
  registerInstall(program);
2628
2871
  registerTracking(program);
2872
+ if (!executionQuery) configureBusinessCommands(program, { hostOverride: globalOptionValue(process.argv.slice(2), "--host") });
2629
2873
  rejectUnknownHelpCommandPath(program, process.argv.slice(2));
2630
2874
  await parseProgram(program);
2631
2875
  }
2632
- await main();
2876
+ function isHelpInvocation(args) {
2877
+ if (args.length === 0 || args.includes("--help") || args.includes("-h")) return true;
2878
+ for (let index = 0; index < args.length; index += 1) {
2879
+ const token = args[index];
2880
+ if (token === "--") return false;
2881
+ if (token.startsWith("-")) {
2882
+ if (optionConsumesValue(token)) index += 1;
2883
+ continue;
2884
+ }
2885
+ if (token === "help") return true;
2886
+ }
2887
+ return false;
2888
+ }
2889
+ try {
2890
+ await main();
2891
+ } catch (error) {
2892
+ if (!(error instanceof ExternalCliTokenError) && !(error instanceof CliValidationError)) throw error;
2893
+ printError(error instanceof ExternalCliTokenError ? "config" : "validation", error.message, error.hint, error.code);
2894
+ process.exitCode = 1;
2895
+ }
2633
2896
  function rejectUnknownHelpCommandPath(root, args) {
2634
2897
  if (!args.includes("--help") && !args.includes("-h")) {
2635
2898
  return;
@@ -2662,15 +2925,23 @@ function optionConsumesValue(token) {
2662
2925
  if (token.includes("=")) {
2663
2926
  return false;
2664
2927
  }
2665
- return token === "--host" || token === "--mcp-url" || token === "--format" || token === "--jq" || token === "--agent-context";
2928
+ return token === "--host" || token === "--cli-token-file" || token === "--mcp-url" || token === "--format" || token === "--jq" || token === "--agent-context";
2666
2929
  }
2667
2930
  function globalOptionValue(args, option) {
2931
+ let value;
2668
2932
  for (let i = 0; i < args.length; i += 1) {
2669
2933
  const token = args[i];
2670
- if (token === option) return args[i + 1];
2671
- if (token.startsWith(`${option}=`)) return token.slice(option.length + 1);
2934
+ if (token === "--") break;
2935
+ if (optionConsumesValue(token)) {
2936
+ const next = args[i + 1];
2937
+ if (next === void 0) {
2938
+ throw new CliValidationError(`${token} requires a value.`, { code: "MISSING_OPTION_VALUE" });
2939
+ }
2940
+ if (token === option) value = next;
2941
+ i += 1;
2942
+ } else if (token.startsWith(`${option}=`)) value = token.slice(option.length + 1);
2672
2943
  }
2673
- return void 0;
2944
+ return value;
2674
2945
  }
2675
2946
  function isRootUpdateCommand(args) {
2676
2947
  for (let i = 0; i < args.length; i += 1) {