@thinkingai/ae-cli 6.0.56 → 6.0.58

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 (112) hide show
  1. package/README.md +12 -4
  2. package/README.zh.md +12 -4
  3. package/bin/ae-cli.js +5 -0
  4. package/bin/runtime-capabilities.json +5 -0
  5. package/cli-installation-guide.md +24 -3
  6. package/dist/{auth-U7MNUUEF.js → auth-A5OO4VS4.js} +30 -12
  7. package/dist/{automation-K32V2NKP.js → automation-FD2QZUP6.js} +6 -6
  8. package/dist/{capability-VV7RHB3B.js → capability-SKI4GHF4.js} +48 -20
  9. package/dist/{chunk-P6VFCH3P.js → chunk-2F64AZYH.js} +2 -2
  10. package/dist/{chunk-LMCYSVVA.js → chunk-4PSTYEG5.js} +50 -41
  11. package/dist/{chunk-KHS64JZQ.js → chunk-72NJKS7O.js} +4 -4
  12. package/dist/{chunk-GI5BMEZO.js → chunk-AWVZTN2B.js} +1 -1
  13. package/dist/{chunk-UUD5RB36.js → chunk-E25OSZLJ.js} +3 -3
  14. package/dist/{chunk-W2PTY5NN.js → chunk-EEARZNHE.js} +3 -3
  15. package/dist/chunk-GBSACKFB.js +2283 -0
  16. package/dist/{chunk-3TQA5RXE.js → chunk-HQCY3QCA.js} +6 -4
  17. package/dist/{chunk-T44M3PLZ.js → chunk-JEUXDY3B.js} +1 -1
  18. package/dist/{chunk-2UWS5CUP.js → chunk-JSBLCLFE.js} +3 -3
  19. package/dist/chunk-K2Z7QHDR.js +132 -0
  20. package/dist/{chunk-QSAR3GHY.js → chunk-OAWPT7VP.js} +2 -2
  21. package/dist/{chunk-2IYIYSUO.js → chunk-QVRIDN42.js} +2 -2
  22. package/dist/{chunk-F6NIPIT5.js → chunk-QWSA3EOD.js} +35 -14
  23. package/dist/{chunk-P7KL7IOH.js → chunk-SOSFRU3O.js} +2 -2
  24. package/dist/{chunk-MXV3PYC3.js → chunk-UYJMEHAF.js} +50 -12
  25. package/dist/{chunk-JJJIP2XQ.js → chunk-VDICGXCY.js} +2 -2
  26. package/dist/chunk-WMDO53YK.js +222 -0
  27. package/dist/{chunk-X7DRLE62.js → chunk-YVG6QD3V.js} +1 -1
  28. package/dist/{chunk-ZW4VMY5H.js → chunk-Z3Q2AEIN.js} +152 -98
  29. package/dist/{community-report-client-S2K3A3Q6.js → community-report-client-TJVCLZ3K.js} +1 -1
  30. package/dist/compat-check-WFEKVLTH.js +32 -0
  31. package/dist/{config-ASSAAIOI.js → config-U4I7X25P.js} +38 -6
  32. package/dist/{context-6RWLVOM5.js → context-CDB5H5PD.js} +4 -4
  33. package/dist/{data-integration-EXSUPUDZ.js → data-integration-QE37EQ3A.js} +207 -24
  34. package/dist/{evaluation-5YT4QLCL.js → evaluation-LR4YDYWL.js} +4 -4
  35. package/dist/index.js +291 -71
  36. package/dist/{local-data-upload-client-7HCPGIS3.js → local-data-upload-client-KCMG6J62.js} +1 -1
  37. package/dist/{memory-VCYLVPMI.js → memory-SNFR5M23.js} +6 -6
  38. package/dist/{metadata-TIWIOFTU.js → metadata-6QM6EED5.js} +16 -8
  39. package/dist/{model-DPJHSD73.js → model-KEVCEXWD.js} +4 -4
  40. package/dist/{personal-semantic-preference-SBKU2LOK.js → personal-semantic-preference-7VXQPP2N.js} +7 -6
  41. package/dist/{project-semantic-SKNWLH3I.js → project-semantic-PSEPYH2L.js} +7 -6
  42. package/dist/{sync-7PP6KQ75.js → sync-22ACDK5Z.js} +8 -7
  43. package/dist/{te-agent-L2BYNPHM.js → te-agent-BJ36B4QI.js} +11 -7
  44. package/dist/{te-analysis-RJB6VJC4.js → te-analysis-WQ6D6YG4.js} +179 -27
  45. package/dist/{te-community-QN3WMPNT.js → te-community-VRWMFGI6.js} +720 -228
  46. package/dist/{te-dataops-UKD2XN3E.js → te-dataops-YTLFTTW7.js} +6 -5
  47. package/dist/{te-engage-KPTN4N2U.js → te-engage-V2QW7TIC.js} +7 -6
  48. package/dist/{te-kb-SFZI3W5T.js → te-kb-4AQLISDR.js} +407 -83
  49. package/dist/{te-system-IE7NCKC3.js → te-system-CYWSK3UN.js} +6 -6
  50. package/dist/{te-team-4KHCFM2I.js → te-team-6ELNGBWT.js} +7 -6
  51. package/dist/{things-7JJUVAWL.js → things-HFWLGCUH.js} +7 -7
  52. package/dist/{update-AX66IFMJ.js → update-3CRVVHV5.js} +11 -7
  53. package/dist/{workspace-Q5NMEKEN.js → workspace-2CKQX2XL.js} +6 -6
  54. package/package.json +17 -7
  55. package/skills/ae-agent/SKILL.md +1 -1
  56. package/skills/ae-agent/references/resource-package.md +4 -0
  57. package/skills/ae-analysis/SKILL.md +14 -10
  58. package/skills/ae-analysis/references/agent_review_preflight.md +52 -11
  59. package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
  60. package/skills/ae-analysis/references/agent_review_submit_to_page.md +57 -25
  61. package/skills/ae-analysis/references/command_index.md +7 -3
  62. package/skills/ae-analysis/references/governance_recommendation_export.md +31 -17
  63. package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
  64. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
  65. package/skills/ae-analysis/references/scenario_append.md +6 -0
  66. package/skills/ae-analysis/references/scenario_begin.md +11 -0
  67. package/skills/ae-analysis/references/scenario_collect.md +10 -2
  68. package/skills/ae-analysis/references/scenario_evaluation.md +6 -18
  69. package/skills/ae-analysis/references/scenario_get.md +15 -0
  70. package/skills/ae-analysis/references/scenario_list.md +64 -0
  71. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
  72. package/skills/ae-community/SKILL.md +77 -27
  73. package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
  74. package/skills/ae-community/references/community-data-quality.md +68 -0
  75. package/skills/ae-community/references/community-query-evidence.md +85 -0
  76. package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
  77. package/skills/ae-community/references/community-weekly-report.md +6 -3
  78. package/skills/ae-community/references/get_channel_info.md +7 -4
  79. package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
  80. package/skills/ae-community/references/get_comments_summary.md +4 -4
  81. package/skills/ae-community/references/get_corpus_tags.md +3 -3
  82. package/skills/ae-community/references/get_daily_summary.md +3 -3
  83. package/skills/ae-community/references/get_hot_topics.md +3 -3
  84. package/skills/ae-community/references/get_livestream_analysis.md +3 -3
  85. package/skills/ae-community/references/get_livestream_detail.md +4 -4
  86. package/skills/ae-community/references/get_livestream_list.md +3 -3
  87. package/skills/ae-community/references/get_livestream_overview.md +3 -3
  88. package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
  89. package/skills/ae-community/references/get_livestream_rooms.md +3 -3
  90. package/skills/ae-community/references/get_overview_metrics.md +3 -3
  91. package/skills/ae-community/references/get_post_detail.md +4 -4
  92. package/skills/ae-community/references/get_risk_content.md +5 -5
  93. package/skills/ae-community/references/get_sentiment_overview.md +4 -4
  94. package/skills/ae-community/references/get_tag_trends.md +3 -3
  95. package/skills/ae-community/references/get_topic_detail.md +3 -3
  96. package/skills/ae-community/references/list_sources.md +28 -0
  97. package/skills/ae-community/references/list_spaces.md +39 -0
  98. package/skills/ae-community/references/search_posts.md +21 -7
  99. package/skills/ae-data-integration/SKILL.md +6 -4
  100. package/skills/ae-data-integration/references/error-handling.md +1 -0
  101. package/skills/ae-data-integration/references/handoff.md +1 -1
  102. package/skills/ae-data-integration/references/sink-upload.md +11 -0
  103. package/skills/ae-data-integration/references/source-inspect.md +2 -1
  104. package/skills/ae-data-integration/references/transform.md +1 -1
  105. package/skills/ae-data-integration/references/ue-mapping.md +1 -1
  106. package/skills/ae-kb/SKILL.md +37 -8
  107. package/skills/ae-kb/references/publication.md +81 -0
  108. package/skills/ae-kb/references/query-workflow.md +20 -6
  109. package/skills/ae-kb-discovery/SKILL.md +15 -6
  110. package/skills/ae-metadata/SKILL.md +2 -2
  111. package/skills/ae-metadata/references/metadata_data_table_get.md +35 -0
  112. package/dist/chunk-ELCR235M.js +0 -1429
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,53 +17,56 @@ import {
14
17
  validateAndFix,
15
18
  validateDraft,
16
19
  writeDraftXlsx
17
- } from "./chunk-KHS64JZQ.js";
18
- import "./chunk-2IYIYSUO.js";
20
+ } from "./chunk-72NJKS7O.js";
21
+ import "./chunk-QVRIDN42.js";
19
22
  import {
20
23
  EvalApiError
21
- } from "./chunk-X7DRLE62.js";
22
- import {
23
- requiresConfirmation
24
- } from "./chunk-AMBFK2K3.js";
25
- import "./chunk-QSAR3GHY.js";
26
- import "./chunk-T44M3PLZ.js";
27
- import {
28
- resolveHost
29
- } from "./chunk-P6VFCH3P.js";
24
+ } from "./chunk-YVG6QD3V.js";
25
+ import "./chunk-OAWPT7VP.js";
26
+ import "./chunk-JEUXDY3B.js";
30
27
  import {
31
28
  TeAgentApiError,
32
29
  TeAgentCredentialsError
33
- } from "./chunk-2UWS5CUP.js";
30
+ } from "./chunk-JSBLCLFE.js";
34
31
  import {
35
32
  CapabilityGatewayError,
36
33
  executeCapability,
37
34
  uploadInputFileBytes
38
- } from "./chunk-MXV3PYC3.js";
35
+ } from "./chunk-UYJMEHAF.js";
36
+ import {
37
+ resolveHost
38
+ } from "./chunk-2F64AZYH.js";
39
39
  import {
40
+ printError,
41
+ printOutput
42
+ } from "./chunk-WMDO53YK.js";
43
+ import "./chunk-Y74WTIKJ.js";
44
+ import {
45
+ BusinessDisabledError,
46
+ assertBusinessEnabled,
47
+ businessForCommand,
40
48
  failInstallation,
41
49
  fetchCliConfig,
42
50
  formatCapabilityMissCompatHint,
43
51
  getLocalCliPackageInfo,
44
52
  installVersion,
45
53
  newInstallationReport,
46
- printError,
47
- printOutput,
54
+ readCurrentBusinessConfig,
48
55
  resolveKbAutoDiscoveryFeature,
49
56
  runHostCompatCheck,
50
57
  shouldSkipAutoSync
51
- } from "./chunk-ELCR235M.js";
52
- import "./chunk-Y74WTIKJ.js";
58
+ } from "./chunk-GBSACKFB.js";
53
59
  import {
54
60
  CredentialStoreUnreadableError,
55
61
  SecureStoreAuthError,
56
62
  getCliToken,
57
63
  peekCliToken
58
- } from "./chunk-P7KL7IOH.js";
64
+ } from "./chunk-SOSFRU3O.js";
59
65
  import {
60
66
  getActiveHost,
61
67
  getConfigDir,
62
68
  safeJsonParse
63
- } from "./chunk-LMCYSVVA.js";
69
+ } from "./chunk-4PSTYEG5.js";
64
70
  import {
65
71
  CliApiError,
66
72
  CliValidationError,
@@ -69,14 +75,17 @@ import {
69
75
  LocalDataUploadError,
70
76
  PermissionError,
71
77
  externalCliTokenRequestOptions,
78
+ kbExecutionContextRequired,
72
79
  logger,
73
80
  readExternalCliToken,
81
+ readKbExecutionContext,
74
82
  setExternalCliTokenFile
75
- } from "./chunk-ZW4VMY5H.js";
83
+ } from "./chunk-Z3Q2AEIN.js";
76
84
 
77
85
  // src/index.ts
78
86
  import { Command as CommanderCommand, Option } from "commander";
79
87
  import { createRequire } from "module";
88
+ import { constants as osConstants } from "os";
80
89
 
81
90
  // src/framework/runner.ts
82
91
  import * as readline from "readline";
@@ -135,7 +144,7 @@ async function runCommand(cmd, opts, globalOpts) {
135
144
  printError("validation", message, hint);
136
145
  process.exit(1);
137
146
  }
138
- if (cmd.validate) {
147
+ if (cmd.validate && cmd.service !== "community") {
139
148
  cmd.validate(ctx);
140
149
  }
141
150
  const LIMIT_FLAG_PATTERNS = [/limit/i, /page_size/i, /pagesize/i, /row_limit/i, /block_limit/i, /top[-_]?k/i];
@@ -149,6 +158,30 @@ async function runCommand(cmd, opts, globalOpts) {
149
158
  }
150
159
  continue;
151
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
+ }
152
185
  if (flag.type !== "number") continue;
153
186
  if (flag.variadic) continue;
154
187
  if (val === void 0 || val === null || val === "") continue;
@@ -157,7 +190,7 @@ async function runCommand(cmd, opts, globalOpts) {
157
190
  printError("validation", `--${flag.name} must be a number (got: ${val})`);
158
191
  process.exit(1);
159
192
  }
160
- 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);
161
194
  if (isLimitFlag) {
162
195
  const min = flag.min ?? 1;
163
196
  const max = flag.max ?? 1e4;
@@ -187,6 +220,9 @@ async function runCommand(cmd, opts, globalOpts) {
187
220
  process.exit(1);
188
221
  }
189
222
  }
223
+ if (cmd.validate && cmd.service === "community") {
224
+ cmd.validate(ctx);
225
+ }
190
226
  if (globalOpts.validate && globalOpts.dryRun) {
191
227
  printError(
192
228
  "validation",
@@ -199,6 +235,10 @@ async function runCommand(cmd, opts, globalOpts) {
199
235
  if (cmd.validateInput) {
200
236
  const validateResult = await cmd.validateInput(ctx);
201
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
+ });
202
242
  } else {
203
243
  await printOutput(
204
244
  { message: "No --validate implementation for this command (capability gateway commands only)" },
@@ -211,6 +251,10 @@ async function runCommand(cmd, opts, globalOpts) {
211
251
  if (cmd.dryRun) {
212
252
  const dryResult = await cmd.dryRun(ctx);
213
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
+ });
214
258
  } else {
215
259
  await printOutput({ message: "No dry-run implementation for this command" }, globalOpts.format);
216
260
  }
@@ -335,14 +379,14 @@ function createRuntimeContext(cmd, opts, globalOpts) {
335
379
  let _communityReportModule = null;
336
380
  async function getCommunityReportClient() {
337
381
  if (!_communityReportModule) {
338
- _communityReportModule = await import("./community-report-client-S2K3A3Q6.js");
382
+ _communityReportModule = await import("./community-report-client-TJVCLZ3K.js");
339
383
  }
340
384
  return _communityReportModule;
341
385
  }
342
386
  let _localDataUploadModule = null;
343
387
  async function getLocalDataUploadClient() {
344
388
  if (!_localDataUploadModule) {
345
- _localDataUploadModule = await import("./local-data-upload-client-7HCPGIS3.js");
389
+ _localDataUploadModule = await import("./local-data-upload-client-KCMG6J62.js");
346
390
  }
347
391
  return _localDataUploadModule;
348
392
  }
@@ -362,9 +406,23 @@ function createRuntimeContext(cmd, opts, globalOpts) {
362
406
  if (val === void 0 || val === null || val === "") return void 0;
363
407
  return Number(val);
364
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
+ },
365
419
  bool(name) {
366
420
  return Boolean(opts[camelCase(name)]);
367
421
  },
422
+ optionalBool(name) {
423
+ const val = opts[camelCase(name)];
424
+ return typeof val === "boolean" ? val : void 0;
425
+ },
368
426
  json(name) {
369
427
  const val = opts[camelCase(name)];
370
428
  if (val === void 0 || val === null) return void 0;
@@ -399,6 +457,10 @@ function createRuntimeContext(cmd, opts, globalOpts) {
399
457
  return globalOpts.host;
400
458
  },
401
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
+ }
402
464
  if (globalOpts.host) return globalOpts.host;
403
465
  return getActiveHost();
404
466
  },
@@ -456,10 +518,11 @@ function registerCommands(program2, commands) {
456
518
  const sub = parent.command(cmd.command, { hidden: cmd.hidden === true }).description(cmd.description);
457
519
  for (const flag of cmd.flags) {
458
520
  const flagStr = buildFlagString(flag);
521
+ const description = flag.required ? `${flag.desc} (required)` : flag.desc;
459
522
  if (flag.variadic) {
460
- sub.option(flagStr, flag.desc, collectVariadic, []);
523
+ sub.option(flagStr, description, collectVariadic, []);
461
524
  } else if (flag.type === "boolean") {
462
- const option = sub.createOption(flagStr, flag.desc);
525
+ const option = sub.createOption(flagStr, description);
463
526
  if (flag.name.startsWith("no-")) {
464
527
  option.negate = false;
465
528
  option.attributeName = () => flag.name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
@@ -467,9 +530,9 @@ function registerCommands(program2, commands) {
467
530
  option.argParser((value) => parseBooleanValue(value, flag.name));
468
531
  sub.addOption(option);
469
532
  } else if (flag.default !== void 0) {
470
- sub.option(flagStr, flag.desc, String(flag.default));
533
+ sub.option(flagStr, description, String(flag.default));
471
534
  } else {
472
- sub.option(flagStr, flag.desc);
535
+ sub.option(flagStr, description);
473
536
  }
474
537
  }
475
538
  if (cmd.usesAeHost !== false) {
@@ -529,6 +592,72 @@ function extractGlobalOptions(program2) {
529
592
  };
530
593
  }
531
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
+
532
661
  // src/core/feature-config-check.ts
533
662
  async function runFeatureConfigCheck(hostOverride, argv = process.argv) {
534
663
  if (shouldSkipAutoSync(argv) || argv.slice(2).some((arg) => arg === "--help" || arg === "-h" || arg === "--version" || arg === "-V")) return void 0;
@@ -545,7 +674,7 @@ async function runFeatureConfigCheck(hostOverride, argv = process.argv) {
545
674
 
546
675
  // src/commands/tracking/plan.ts
547
676
  import { readFile, writeFile, cp } from "fs/promises";
548
- import path2, { resolve as resolve2 } from "path";
677
+ import path3, { resolve as resolve2 } from "path";
549
678
 
550
679
  // src/core/tracking-client.ts
551
680
  var DEBUG_BASE = "/v1/ta/bury/manage/debug";
@@ -742,8 +871,8 @@ var TrackingClient = class {
742
871
  }
743
872
  return env;
744
873
  }
745
- async debugGet(path4, params) {
746
- 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() });
747
876
  return data;
748
877
  }
749
878
  async listDevice(projectId) {
@@ -819,8 +948,8 @@ function normalize(data) {
819
948
  }
820
949
 
821
950
  // src/tracking/plan/draft.ts
822
- import fs from "fs";
823
- import path from "path";
951
+ import fs2 from "fs";
952
+ import path2 from "path";
824
953
 
825
954
  // src/tracking/plan/autotrack.ts
826
955
  var TAG = {
@@ -1190,23 +1319,23 @@ function resolveTrackingHost(program2, opts) {
1190
1319
  }
1191
1320
  return host;
1192
1321
  }
1193
- function isExistingDirectory(path4) {
1194
- if (!existsSync2(path4)) return false;
1322
+ function isExistingDirectory(path5) {
1323
+ if (!existsSync2(path5)) return false;
1195
1324
  try {
1196
- return statSync(path4).isDirectory();
1325
+ return statSync(path5).isDirectory();
1197
1326
  } catch {
1198
1327
  return false;
1199
1328
  }
1200
1329
  }
1201
- function assertOutputFilePath(path4, optionName = "--out") {
1202
- const trimmed = path4.trim();
1330
+ function assertOutputFilePath(path5, optionName = "--out") {
1331
+ const trimmed = path5.trim();
1203
1332
  if (trimmed.endsWith("/") || trimmed.endsWith("\\") || isExistingDirectory(trimmed)) {
1204
1333
  console.error(t("error.output_path_is_directory", { path: trimmed, option: optionName }));
1205
1334
  process.exit(1);
1206
1335
  }
1207
1336
  }
1208
- function assertInputFilePath(path4, optionName = "--in") {
1209
- const trimmed = path4.trim();
1337
+ function assertInputFilePath(path5, optionName = "--in") {
1338
+ const trimmed = path5.trim();
1210
1339
  if (!existsSync2(trimmed)) {
1211
1340
  console.error(t("error.input_path_not_found", { path: trimmed, option: optionName }));
1212
1341
  process.exit(1);
@@ -1357,7 +1486,7 @@ function registerPlan(cmd, rootProgram) {
1357
1486
  lastRes = await client.uploadProgramExcel({
1358
1487
  projectId: opts.project,
1359
1488
  file,
1360
- filename: path2.basename(opts.xlsx),
1489
+ filename: path3.basename(opts.xlsx),
1361
1490
  lang: locale
1362
1491
  });
1363
1492
  console.log(JSON.stringify(lastRes, null, 2));
@@ -1562,7 +1691,7 @@ async function detectProject(cwd) {
1562
1691
 
1563
1692
  // src/tracking/xlsx/read.ts
1564
1693
  import * as nodeFs from "fs";
1565
- import path3 from "path";
1694
+ import path4 from "path";
1566
1695
  var setXlsxFs = set_fs;
1567
1696
  if (typeof setXlsxFs === "function") {
1568
1697
  setXlsxFs(nodeFs);
@@ -1875,7 +2004,7 @@ async function readTemplateXlsx(filePath) {
1875
2004
  } catch (err) {
1876
2005
  throw new Error(t("error.xlsx_read_failed", { path: filePath, error: String(err) }));
1877
2006
  }
1878
- const planName = path3.basename(filePath, path3.extname(filePath));
2007
+ const planName = path4.basename(filePath, path4.extname(filePath));
1879
2008
  const source = "template";
1880
2009
  let events = [];
1881
2010
  let event_properties = [];
@@ -2325,6 +2454,11 @@ async function parseProgram(program2, argv = process.argv) {
2325
2454
  try {
2326
2455
  await program2.parseAsync(normalizeSubcommandVersionOption(program2, argv));
2327
2456
  } catch (error) {
2457
+ if (error instanceof BusinessDisabledError) {
2458
+ printError("permission", error.message, error.hint, error.code);
2459
+ process.exitCode = 1;
2460
+ return;
2461
+ }
2328
2462
  if (!(error instanceof CredentialStoreUnreadableError) && !(error instanceof ExternalCliTokenError)) throw error;
2329
2463
  printError("config", error.message, error.hint, error.code);
2330
2464
  process.exitCode = 1;
@@ -2430,6 +2564,57 @@ function registerInstall(program2) {
2430
2564
  });
2431
2565
  }
2432
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
+
2433
2618
  // src/index.ts
2434
2619
  var require2 = createRequire(import.meta.url);
2435
2620
  var pkg = require2("../package.json");
@@ -2455,105 +2640,105 @@ function warnLoadFailure(label, err) {
2455
2640
  async function loadCommands() {
2456
2641
  const commands = [];
2457
2642
  try {
2458
- const teAnalysis = await import("./te-analysis-RJB6VJC4.js");
2643
+ const teAnalysis = await import("./te-analysis-WQ6D6YG4.js");
2459
2644
  commands.push(...teAnalysis.default);
2460
2645
  } catch (err) {
2461
2646
  warnLoadFailure("domain te-analysis", err);
2462
2647
  }
2463
2648
  try {
2464
- const engage = await import("./te-engage-KPTN4N2U.js");
2649
+ const engage = await import("./te-engage-V2QW7TIC.js");
2465
2650
  commands.push(...engage.default);
2466
2651
  } catch (err) {
2467
2652
  warnLoadFailure("domain te-engage", err);
2468
2653
  }
2469
2654
  try {
2470
- const community = await import("./te-community-QN3WMPNT.js");
2655
+ const community = await import("./te-community-VRWMFGI6.js");
2471
2656
  commands.push(...community.default);
2472
2657
  } catch (err) {
2473
2658
  warnLoadFailure("domain te-community", err);
2474
2659
  }
2475
2660
  try {
2476
- const dataops = await import("./te-dataops-UKD2XN3E.js");
2661
+ const dataops = await import("./te-dataops-YTLFTTW7.js");
2477
2662
  commands.push(...dataops.default);
2478
2663
  } catch (err) {
2479
2664
  warnLoadFailure("domain te-dataops", err);
2480
2665
  }
2481
2666
  try {
2482
- const teKb = await import("./te-kb-SFZI3W5T.js");
2667
+ const teKb = await import("./te-kb-4AQLISDR.js");
2483
2668
  commands.push(...teKb.default);
2484
2669
  } catch (err) {
2485
2670
  warnLoadFailure("domain te-kb", err);
2486
2671
  }
2487
2672
  try {
2488
- const teTeam = await import("./te-team-4KHCFM2I.js");
2673
+ const teTeam = await import("./te-team-6ELNGBWT.js");
2489
2674
  commands.push(...teTeam.default);
2490
2675
  } catch (err) {
2491
2676
  warnLoadFailure("domain te-team", err);
2492
2677
  }
2493
2678
  try {
2494
- const teAgent = await import("./te-agent-L2BYNPHM.js");
2679
+ const teAgent = await import("./te-agent-BJ36B4QI.js");
2495
2680
  commands.push(...teAgent.default);
2496
2681
  } catch (err) {
2497
2682
  warnLoadFailure("domain te-agent", err);
2498
2683
  }
2499
2684
  try {
2500
- const memory = await import("./memory-VCYLVPMI.js");
2685
+ const memory = await import("./memory-SNFR5M23.js");
2501
2686
  commands.push(...memory.default);
2502
2687
  } catch (err) {
2503
2688
  warnLoadFailure("domain memory", err);
2504
2689
  }
2505
- const automation = await import("./automation-K32V2NKP.js");
2690
+ const automation = await import("./automation-FD2QZUP6.js");
2506
2691
  commands.push(...automation.default);
2507
2692
  try {
2508
- const things = await import("./things-7JJUVAWL.js");
2693
+ const things = await import("./things-HFWLGCUH.js");
2509
2694
  commands.push(...things.default);
2510
2695
  } catch (err) {
2511
2696
  warnLoadFailure("domain things", err);
2512
2697
  }
2513
2698
  try {
2514
- const workspace = await import("./workspace-Q5NMEKEN.js");
2699
+ const workspace = await import("./workspace-2CKQX2XL.js");
2515
2700
  commands.push(...workspace.default);
2516
2701
  } catch (err) {
2517
2702
  warnLoadFailure("domain workspace", err);
2518
2703
  }
2519
2704
  try {
2520
- const teSystem = await import("./te-system-IE7NCKC3.js");
2705
+ const teSystem = await import("./te-system-CYWSK3UN.js");
2521
2706
  commands.push(...teSystem.default);
2522
2707
  } catch (err) {
2523
2708
  warnLoadFailure("domain te-system", err);
2524
2709
  }
2525
2710
  try {
2526
- const metadata = await import("./metadata-TIWIOFTU.js");
2711
+ const metadata = await import("./metadata-6QM6EED5.js");
2527
2712
  commands.push(...metadata.default);
2528
2713
  } catch (err) {
2529
2714
  warnLoadFailure("domain metadata", err);
2530
2715
  }
2531
2716
  try {
2532
- const personalSemanticPreference = await import("./personal-semantic-preference-SBKU2LOK.js");
2717
+ const personalSemanticPreference = await import("./personal-semantic-preference-7VXQPP2N.js");
2533
2718
  commands.push(...personalSemanticPreference.default);
2534
2719
  } catch (err) {
2535
2720
  warnLoadFailure("domain personal-semantic-preference", err);
2536
2721
  }
2537
2722
  try {
2538
- const projectSemantic = await import("./project-semantic-SKNWLH3I.js");
2723
+ const projectSemantic = await import("./project-semantic-PSEPYH2L.js");
2539
2724
  commands.push(...projectSemantic.default);
2540
2725
  } catch (err) {
2541
2726
  warnLoadFailure("domain project-semantic", err);
2542
2727
  }
2543
2728
  try {
2544
- const dataIntegration = await import("./data-integration-EXSUPUDZ.js");
2729
+ const dataIntegration = await import("./data-integration-QE37EQ3A.js");
2545
2730
  commands.push(...dataIntegration.default);
2546
2731
  } catch (err) {
2547
2732
  warnLoadFailure("domain data-integration", err);
2548
2733
  }
2549
2734
  try {
2550
- const context = await import("./context-6RWLVOM5.js");
2735
+ const context = await import("./context-CDB5H5PD.js");
2551
2736
  commands.push(...context.default);
2552
2737
  } catch (err) {
2553
2738
  warnLoadFailure("domain context", err);
2554
2739
  }
2555
2740
  try {
2556
- const evaluation = await import("./evaluation-5YT4QLCL.js");
2741
+ const evaluation = await import("./evaluation-LR4YDYWL.js");
2557
2742
  commands.push(...evaluation.default);
2558
2743
  } catch (err) {
2559
2744
  warnLoadFailure("domain evaluation", err);
@@ -2562,7 +2747,7 @@ async function loadCommands() {
2562
2747
  }
2563
2748
  async function registerAuthCommands() {
2564
2749
  try {
2565
- const { registerAuth } = await import("./auth-U7MNUUEF.js");
2750
+ const { registerAuth } = await import("./auth-A5OO4VS4.js");
2566
2751
  registerAuth(program);
2567
2752
  } catch (err) {
2568
2753
  warnLoadFailure("auth commands", err);
@@ -2570,7 +2755,7 @@ async function registerAuthCommands() {
2570
2755
  }
2571
2756
  async function registerConfigCommands() {
2572
2757
  try {
2573
- const { registerConfig } = await import("./config-ASSAAIOI.js");
2758
+ const { registerConfig } = await import("./config-U4I7X25P.js");
2574
2759
  registerConfig(program);
2575
2760
  } catch (err) {
2576
2761
  warnLoadFailure("config commands", err);
@@ -2578,7 +2763,7 @@ async function registerConfigCommands() {
2578
2763
  }
2579
2764
  async function registerCapabilityCommands() {
2580
2765
  try {
2581
- const { registerCapability } = await import("./capability-VV7RHB3B.js");
2766
+ const { registerCapability } = await import("./capability-SKI4GHF4.js");
2582
2767
  registerCapability(program);
2583
2768
  } catch (err) {
2584
2769
  warnLoadFailure("capability commands", err);
@@ -2586,7 +2771,7 @@ async function registerCapabilityCommands() {
2586
2771
  }
2587
2772
  async function registerSyncCommand() {
2588
2773
  try {
2589
- const { registerSync } = await import("./sync-7PP6KQ75.js");
2774
+ const { registerSync } = await import("./sync-22ACDK5Z.js");
2590
2775
  registerSync(program);
2591
2776
  } catch (err) {
2592
2777
  warnLoadFailure("sync commands", err);
@@ -2594,7 +2779,7 @@ async function registerSyncCommand() {
2594
2779
  }
2595
2780
  async function registerModelCommand() {
2596
2781
  try {
2597
- const { registerModel } = await import("./model-DPJHSD73.js");
2782
+ const { registerModel } = await import("./model-KEVCEXWD.js");
2598
2783
  registerModel(program);
2599
2784
  } catch (err) {
2600
2785
  warnLoadFailure("model commands", err);
@@ -2602,25 +2787,44 @@ async function registerModelCommand() {
2602
2787
  }
2603
2788
  async function registerUpdateCommand() {
2604
2789
  try {
2605
- const { registerUpdate } = await import("./update-AX66IFMJ.js");
2790
+ const { registerUpdate } = await import("./update-3CRVVHV5.js");
2606
2791
  registerUpdate(program);
2607
2792
  } catch (err) {
2608
2793
  warnLoadFailure("update commands", err);
2609
2794
  }
2610
2795
  }
2611
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);
2612
2806
  setExternalCliTokenFile(globalOptionValue(process.argv.slice(2), "--cli-token-file"));
2613
- if (!process.argv.slice(2).some((arg) => ["--help", "-h", "--version", "-V"].includes(arg))) {
2807
+ if (!executionQuery && !helpRequested && !process.argv.slice(2).some((arg) => ["--version", "-V"].includes(arg))) {
2614
2808
  readExternalCliToken(globalOptionValue(process.argv.slice(2), "--host"));
2615
2809
  }
2616
2810
  const pkgInfo = getLocalCliPackageInfo();
2617
- if (!isRootUpdateCommand(process.argv.slice(2))) {
2811
+ if (!executionQuery && !helpRequested && !isRootUpdateCommand(process.argv.slice(2))) {
2618
2812
  const compat = await runHostCompatCheck(
2619
2813
  pkgInfo,
2620
2814
  globalOptionValue(process.argv.slice(2), "--host")
2621
2815
  );
2622
2816
  if (compat.status === "synced") {
2623
- 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.`;
2624
2828
  printError(
2625
2829
  "config",
2626
2830
  message,
@@ -2631,6 +2835,8 @@ async function main() {
2631
2835
  expected: compat.expected,
2632
2836
  cluster: compat.cluster,
2633
2837
  direction: compat.direction,
2838
+ versionSyncSucceeded: true,
2839
+ originalCommandExecuted: false,
2634
2840
  retryOriginalCommand: true
2635
2841
  },
2636
2842
  { log: false }
@@ -2639,7 +2845,7 @@ async function main() {
2639
2845
  return;
2640
2846
  }
2641
2847
  }
2642
- await runFeatureConfigCheck(globalOptionValue(process.argv.slice(2), "--host"));
2848
+ if (!executionQuery && !helpRequested) await runFeatureConfigCheck(globalOptionValue(process.argv.slice(2), "--host"));
2643
2849
  const commands = await loadCommands();
2644
2850
  registerCommands(program, commands);
2645
2851
  await registerAuthCommands();
@@ -2650,9 +2856,23 @@ async function main() {
2650
2856
  await registerUpdateCommand();
2651
2857
  registerInstall(program);
2652
2858
  registerTracking(program);
2859
+ if (!executionQuery) configureBusinessCommands(program, { hostOverride: globalOptionValue(process.argv.slice(2), "--host") });
2653
2860
  rejectUnknownHelpCommandPath(program, process.argv.slice(2));
2654
2861
  await parseProgram(program);
2655
2862
  }
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
+ }
2656
2876
  try {
2657
2877
  await main();
2658
2878
  } catch (error) {