@thinkingai/ae-cli 6.1.28 → 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 (116) hide show
  1. package/README.md +24 -4
  2. package/README.zh.md +24 -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-NKD5Z5BQ.js → auth-OBQ5KVQM.js} +30 -12
  7. package/dist/{automation-K32V2NKP.js → automation-NAR5DDGL.js} +6 -6
  8. package/dist/{capability-4CGSL7PK.js → capability-LFSVNI5B.js} +54 -26
  9. package/dist/chunk-2UW3Y463.js +2289 -0
  10. package/dist/{chunk-QW3R6O7L.js → chunk-3SDHJOCR.js} +57 -15
  11. package/dist/chunk-6HAUVWOQ.js +132 -0
  12. package/dist/{chunk-KHS64JZQ.js → chunk-72NJKS7O.js} +4 -4
  13. package/dist/{chunk-UUD5RB36.js → chunk-7JAVT5TK.js} +3 -3
  14. package/dist/{chunk-GTPWDLTE.js → chunk-CVCTFLSO.js} +35 -14
  15. package/dist/{chunk-P7KL7IOH.js → chunk-H3K5UGYC.js} +2 -2
  16. package/dist/{chunk-P6VFCH3P.js → chunk-IN7KKL6K.js} +2 -2
  17. package/dist/{chunk-T44M3PLZ.js → chunk-JEUXDY3B.js} +1 -1
  18. package/dist/{chunk-LMCYSVVA.js → chunk-JNVVJ273.js} +51 -37
  19. package/dist/{chunk-JJJIP2XQ.js → chunk-N6XBLRB7.js} +2 -2
  20. package/dist/{chunk-QSAR3GHY.js → chunk-OAWPT7VP.js} +2 -2
  21. package/dist/{chunk-UF244C5C.js → chunk-PWXDWMCW.js} +7 -7
  22. package/dist/{chunk-2IYIYSUO.js → chunk-QVRIDN42.js} +2 -2
  23. package/dist/chunk-QZLRHGVH.js +222 -0
  24. package/dist/{chunk-GI5BMEZO.js → chunk-QZUVLFNR.js} +1 -1
  25. package/dist/{chunk-2UWS5CUP.js → chunk-RJHGDWSC.js} +3 -3
  26. package/dist/{chunk-UJ7UPRXK.js → chunk-VCZE3IWO.js} +10 -8
  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-CII6B74E.js +32 -0
  31. package/dist/{config-ASSAAIOI.js → config-YZ6O2UQ2.js} +38 -6
  32. package/dist/{context-6RWLVOM5.js → context-F6FCGTF3.js} +4 -4
  33. package/dist/{data-integration-EXSUPUDZ.js → data-integration-6UAZO4GG.js} +207 -24
  34. package/dist/{evaluation-5YT4QLCL.js → evaluation-4LO2O4AF.js} +4 -4
  35. package/dist/index.js +297 -70
  36. package/dist/{local-data-upload-client-7HCPGIS3.js → local-data-upload-client-KCMG6J62.js} +1 -1
  37. package/dist/{memory-VCYLVPMI.js → memory-HHPX3NF2.js} +6 -6
  38. package/dist/{metadata-YGI5M6OF.js → metadata-TIFY24LW.js} +16 -8
  39. package/dist/{model-DPJHSD73.js → model-7UHGWYVR.js} +4 -4
  40. package/dist/{personal-semantic-preference-76TBKAPY.js → personal-semantic-preference-WKJEGPTM.js} +7 -6
  41. package/dist/{project-semantic-XOEBO2Q5.js → project-semantic-EIQVZNHW.js} +11 -10
  42. package/dist/{sync-7PP6KQ75.js → sync-RV3OPCTI.js} +8 -7
  43. package/dist/{te-agent-PJVAPKBD.js → te-agent-5ENVZJUH.js} +11 -7
  44. package/dist/{te-analysis-OX62G5VD.js → te-analysis-USIK6ZZG.js} +185 -33
  45. package/dist/{te-community-QN3WMPNT.js → te-community-WE2UU4XV.js} +720 -228
  46. package/dist/{te-dataops-UKD2XN3E.js → te-dataops-XNMO7MBF.js} +6 -5
  47. package/dist/{te-engage-X3DIXPRA.js → te-engage-6C3HCFQR.js} +13 -12
  48. package/dist/{te-experiment-MEIIK3DP.js → te-experiment-LVTRI3QK.js} +55 -21
  49. package/dist/{te-kb-73EWDFDF.js → te-kb-TUPGMVBY.js} +409 -85
  50. package/dist/{te-system-IE7NCKC3.js → te-system-YM657FKO.js} +6 -6
  51. package/dist/{te-team-MGQ5CNRW.js → te-team-G4VEJJNL.js} +7 -6
  52. package/dist/{things-4JIBCA55.js → things-22KQWC23.js} +7 -7
  53. package/dist/{update-AX66IFMJ.js → update-XX4ILU7X.js} +11 -7
  54. package/dist/{workspace-Q5NMEKEN.js → workspace-LYDAP647.js} +6 -6
  55. package/package.json +17 -7
  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-experiment/SKILL.md +7 -1
  107. package/skills/ae-experiment/references/manage_experiment.md +18 -1
  108. package/skills/ae-experiment/references/query_experiment_detail.md +7 -0
  109. package/skills/ae-experiment/references/save_experiment.md +76 -2
  110. package/skills/ae-experiment/references/save_submit_experiment.md +7 -0
  111. package/skills/ae-kb/SKILL.md +33 -6
  112. package/skills/ae-kb/references/publication.md +81 -0
  113. package/skills/ae-kb/references/query-workflow.md +14 -1
  114. package/skills/ae-metadata/SKILL.md +2 -2
  115. package/skills/ae-metadata/references/metadata_data_table_get.md +35 -0
  116. package/dist/chunk-ELCR235M.js +0 -1429
package/dist/index.js CHANGED
@@ -17,50 +17,56 @@ import {
17
17
  validateAndFix,
18
18
  validateDraft,
19
19
  writeDraftXlsx
20
- } from "./chunk-KHS64JZQ.js";
21
- import "./chunk-2IYIYSUO.js";
20
+ } from "./chunk-72NJKS7O.js";
21
+ import "./chunk-QVRIDN42.js";
22
+ import "./chunk-OAWPT7VP.js";
23
+ import "./chunk-JEUXDY3B.js";
22
24
  import {
23
25
  EvalApiError
24
- } from "./chunk-X7DRLE62.js";
25
- import "./chunk-QSAR3GHY.js";
26
- import "./chunk-T44M3PLZ.js";
26
+ } from "./chunk-YVG6QD3V.js";
27
+ import {
28
+ resolveHost
29
+ } from "./chunk-IN7KKL6K.js";
27
30
  import {
28
31
  TeAgentApiError,
29
32
  TeAgentCredentialsError
30
- } from "./chunk-2UWS5CUP.js";
33
+ } from "./chunk-RJHGDWSC.js";
34
+ import {
35
+ printError,
36
+ printOutput
37
+ } from "./chunk-QZLRHGVH.js";
31
38
  import {
32
39
  CapabilityGatewayError,
33
40
  executeCapability,
34
41
  uploadInputFileBytes
35
- } from "./chunk-QW3R6O7L.js";
36
- import {
37
- resolveHost
38
- } from "./chunk-P6VFCH3P.js";
42
+ } from "./chunk-3SDHJOCR.js";
43
+ import "./chunk-Y74WTIKJ.js";
39
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-2UW3Y463.js";
53
59
  import {
54
60
  CredentialStoreUnreadableError,
55
61
  SecureStoreAuthError,
56
62
  getCliToken,
57
63
  peekCliToken
58
- } from "./chunk-P7KL7IOH.js";
64
+ } from "./chunk-H3K5UGYC.js";
59
65
  import {
60
66
  getActiveHost,
61
67
  getConfigDir,
62
68
  safeJsonParse
63
- } from "./chunk-LMCYSVVA.js";
69
+ } from "./chunk-JNVVJ273.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
  }
@@ -261,7 +305,14 @@ async function runCommand(cmd, opts, globalOpts) {
261
305
  } else if (err instanceof CliApiError) {
262
306
  printError("api", message, err.hint, err.code, err.meta);
263
307
  } else if (err instanceof CapabilityGatewayError) {
264
- 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
+ );
265
316
  } else if (err instanceof CommunityReportError) {
266
317
  printError("api", message, err.hint, err.code, err.meta, { log: false });
267
318
  } else if (err instanceof LocalDataUploadError) {
@@ -335,14 +386,14 @@ function createRuntimeContext(cmd, opts, globalOpts) {
335
386
  let _communityReportModule = null;
336
387
  async function getCommunityReportClient() {
337
388
  if (!_communityReportModule) {
338
- _communityReportModule = await import("./community-report-client-S2K3A3Q6.js");
389
+ _communityReportModule = await import("./community-report-client-TJVCLZ3K.js");
339
390
  }
340
391
  return _communityReportModule;
341
392
  }
342
393
  let _localDataUploadModule = null;
343
394
  async function getLocalDataUploadClient() {
344
395
  if (!_localDataUploadModule) {
345
- _localDataUploadModule = await import("./local-data-upload-client-7HCPGIS3.js");
396
+ _localDataUploadModule = await import("./local-data-upload-client-KCMG6J62.js");
346
397
  }
347
398
  return _localDataUploadModule;
348
399
  }
@@ -362,9 +413,23 @@ function createRuntimeContext(cmd, opts, globalOpts) {
362
413
  if (val === void 0 || val === null || val === "") return void 0;
363
414
  return Number(val);
364
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
+ },
365
426
  bool(name) {
366
427
  return Boolean(opts[camelCase(name)]);
367
428
  },
429
+ optionalBool(name) {
430
+ const val = opts[camelCase(name)];
431
+ return typeof val === "boolean" ? val : void 0;
432
+ },
368
433
  json(name) {
369
434
  const val = opts[camelCase(name)];
370
435
  if (val === void 0 || val === null) return void 0;
@@ -399,6 +464,10 @@ function createRuntimeContext(cmd, opts, globalOpts) {
399
464
  return globalOpts.host;
400
465
  },
401
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
+ }
402
471
  if (globalOpts.host) return globalOpts.host;
403
472
  return getActiveHost();
404
473
  },
@@ -456,10 +525,11 @@ function registerCommands(program2, commands) {
456
525
  const sub = parent.command(cmd.command, { hidden: cmd.hidden === true }).description(cmd.description);
457
526
  for (const flag of cmd.flags) {
458
527
  const flagStr = buildFlagString(flag);
528
+ const description = flag.required ? `${flag.desc} (required)` : flag.desc;
459
529
  if (flag.variadic) {
460
- sub.option(flagStr, flag.desc, collectVariadic, []);
530
+ sub.option(flagStr, description, collectVariadic, []);
461
531
  } else if (flag.type === "boolean") {
462
- const option = sub.createOption(flagStr, flag.desc);
532
+ const option = sub.createOption(flagStr, description);
463
533
  if (flag.name.startsWith("no-")) {
464
534
  option.negate = false;
465
535
  option.attributeName = () => flag.name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
@@ -467,9 +537,9 @@ function registerCommands(program2, commands) {
467
537
  option.argParser((value) => parseBooleanValue(value, flag.name));
468
538
  sub.addOption(option);
469
539
  } else if (flag.default !== void 0) {
470
- sub.option(flagStr, flag.desc, String(flag.default));
540
+ sub.option(flagStr, description, String(flag.default));
471
541
  } else {
472
- sub.option(flagStr, flag.desc);
542
+ sub.option(flagStr, description);
473
543
  }
474
544
  }
475
545
  if (cmd.usesAeHost !== false) {
@@ -529,6 +599,72 @@ function extractGlobalOptions(program2) {
529
599
  };
530
600
  }
531
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
+
532
668
  // src/core/feature-config-check.ts
533
669
  async function runFeatureConfigCheck(hostOverride, argv = process.argv) {
534
670
  if (shouldSkipAutoSync(argv) || argv.slice(2).some((arg) => arg === "--help" || arg === "-h" || arg === "--version" || arg === "-V")) return void 0;
@@ -545,7 +681,7 @@ async function runFeatureConfigCheck(hostOverride, argv = process.argv) {
545
681
 
546
682
  // src/commands/tracking/plan.ts
547
683
  import { readFile, writeFile, cp } from "fs/promises";
548
- import path2, { resolve as resolve2 } from "path";
684
+ import path3, { resolve as resolve2 } from "path";
549
685
 
550
686
  // src/core/tracking-client.ts
551
687
  var DEBUG_BASE = "/v1/ta/bury/manage/debug";
@@ -742,8 +878,8 @@ var TrackingClient = class {
742
878
  }
743
879
  return env;
744
880
  }
745
- async debugGet(path4, params) {
746
- 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() });
747
883
  return data;
748
884
  }
749
885
  async listDevice(projectId) {
@@ -819,8 +955,8 @@ function normalize(data) {
819
955
  }
820
956
 
821
957
  // src/tracking/plan/draft.ts
822
- import fs from "fs";
823
- import path from "path";
958
+ import fs2 from "fs";
959
+ import path2 from "path";
824
960
 
825
961
  // src/tracking/plan/autotrack.ts
826
962
  var TAG = {
@@ -1190,23 +1326,23 @@ function resolveTrackingHost(program2, opts) {
1190
1326
  }
1191
1327
  return host;
1192
1328
  }
1193
- function isExistingDirectory(path4) {
1194
- if (!existsSync2(path4)) return false;
1329
+ function isExistingDirectory(path5) {
1330
+ if (!existsSync2(path5)) return false;
1195
1331
  try {
1196
- return statSync(path4).isDirectory();
1332
+ return statSync(path5).isDirectory();
1197
1333
  } catch {
1198
1334
  return false;
1199
1335
  }
1200
1336
  }
1201
- function assertOutputFilePath(path4, optionName = "--out") {
1202
- const trimmed = path4.trim();
1337
+ function assertOutputFilePath(path5, optionName = "--out") {
1338
+ const trimmed = path5.trim();
1203
1339
  if (trimmed.endsWith("/") || trimmed.endsWith("\\") || isExistingDirectory(trimmed)) {
1204
1340
  console.error(t("error.output_path_is_directory", { path: trimmed, option: optionName }));
1205
1341
  process.exit(1);
1206
1342
  }
1207
1343
  }
1208
- function assertInputFilePath(path4, optionName = "--in") {
1209
- const trimmed = path4.trim();
1344
+ function assertInputFilePath(path5, optionName = "--in") {
1345
+ const trimmed = path5.trim();
1210
1346
  if (!existsSync2(trimmed)) {
1211
1347
  console.error(t("error.input_path_not_found", { path: trimmed, option: optionName }));
1212
1348
  process.exit(1);
@@ -1357,7 +1493,7 @@ function registerPlan(cmd, rootProgram) {
1357
1493
  lastRes = await client.uploadProgramExcel({
1358
1494
  projectId: opts.project,
1359
1495
  file,
1360
- filename: path2.basename(opts.xlsx),
1496
+ filename: path3.basename(opts.xlsx),
1361
1497
  lang: locale
1362
1498
  });
1363
1499
  console.log(JSON.stringify(lastRes, null, 2));
@@ -1562,7 +1698,7 @@ async function detectProject(cwd) {
1562
1698
 
1563
1699
  // src/tracking/xlsx/read.ts
1564
1700
  import * as nodeFs from "fs";
1565
- import path3 from "path";
1701
+ import path4 from "path";
1566
1702
  var setXlsxFs = set_fs;
1567
1703
  if (typeof setXlsxFs === "function") {
1568
1704
  setXlsxFs(nodeFs);
@@ -1875,7 +2011,7 @@ async function readTemplateXlsx(filePath) {
1875
2011
  } catch (err) {
1876
2012
  throw new Error(t("error.xlsx_read_failed", { path: filePath, error: String(err) }));
1877
2013
  }
1878
- const planName = path3.basename(filePath, path3.extname(filePath));
2014
+ const planName = path4.basename(filePath, path4.extname(filePath));
1879
2015
  const source = "template";
1880
2016
  let events = [];
1881
2017
  let event_properties = [];
@@ -2325,6 +2461,11 @@ async function parseProgram(program2, argv = process.argv) {
2325
2461
  try {
2326
2462
  await program2.parseAsync(normalizeSubcommandVersionOption(program2, argv));
2327
2463
  } catch (error) {
2464
+ if (error instanceof BusinessDisabledError) {
2465
+ printError("permission", error.message, error.hint, error.code);
2466
+ process.exitCode = 1;
2467
+ return;
2468
+ }
2328
2469
  if (!(error instanceof CredentialStoreUnreadableError) && !(error instanceof ExternalCliTokenError)) throw error;
2329
2470
  printError("config", error.message, error.hint, error.code);
2330
2471
  process.exitCode = 1;
@@ -2430,6 +2571,57 @@ function registerInstall(program2) {
2430
2571
  });
2431
2572
  }
2432
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
+
2433
2625
  // src/index.ts
2434
2626
  var require2 = createRequire(import.meta.url);
2435
2627
  var pkg = require2("../package.json");
@@ -2455,111 +2647,111 @@ function warnLoadFailure(label, err) {
2455
2647
  async function loadCommands() {
2456
2648
  const commands = [];
2457
2649
  try {
2458
- const teAnalysis = await import("./te-analysis-OX62G5VD.js");
2650
+ const teAnalysis = await import("./te-analysis-USIK6ZZG.js");
2459
2651
  commands.push(...teAnalysis.default);
2460
2652
  } catch (err) {
2461
2653
  warnLoadFailure("domain te-analysis", err);
2462
2654
  }
2463
2655
  try {
2464
- const engage = await import("./te-engage-X3DIXPRA.js");
2656
+ const engage = await import("./te-engage-6C3HCFQR.js");
2465
2657
  commands.push(...engage.default);
2466
2658
  } catch (err) {
2467
2659
  warnLoadFailure("domain te-engage", err);
2468
2660
  }
2469
2661
  try {
2470
- const experiment = await import("./te-experiment-MEIIK3DP.js");
2662
+ const experiment = await import("./te-experiment-LVTRI3QK.js");
2471
2663
  commands.push(...experiment.default);
2472
2664
  } catch (err) {
2473
2665
  warnLoadFailure("domain te-experiment", err);
2474
2666
  }
2475
2667
  try {
2476
- const community = await import("./te-community-QN3WMPNT.js");
2668
+ const community = await import("./te-community-WE2UU4XV.js");
2477
2669
  commands.push(...community.default);
2478
2670
  } catch (err) {
2479
2671
  warnLoadFailure("domain te-community", err);
2480
2672
  }
2481
2673
  try {
2482
- const dataops = await import("./te-dataops-UKD2XN3E.js");
2674
+ const dataops = await import("./te-dataops-XNMO7MBF.js");
2483
2675
  commands.push(...dataops.default);
2484
2676
  } catch (err) {
2485
2677
  warnLoadFailure("domain te-dataops", err);
2486
2678
  }
2487
2679
  try {
2488
- const teKb = await import("./te-kb-73EWDFDF.js");
2680
+ const teKb = await import("./te-kb-TUPGMVBY.js");
2489
2681
  commands.push(...teKb.default);
2490
2682
  } catch (err) {
2491
2683
  warnLoadFailure("domain te-kb", err);
2492
2684
  }
2493
2685
  try {
2494
- const teTeam = await import("./te-team-MGQ5CNRW.js");
2686
+ const teTeam = await import("./te-team-G4VEJJNL.js");
2495
2687
  commands.push(...teTeam.default);
2496
2688
  } catch (err) {
2497
2689
  warnLoadFailure("domain te-team", err);
2498
2690
  }
2499
2691
  try {
2500
- const teAgent = await import("./te-agent-PJVAPKBD.js");
2692
+ const teAgent = await import("./te-agent-5ENVZJUH.js");
2501
2693
  commands.push(...teAgent.default);
2502
2694
  } catch (err) {
2503
2695
  warnLoadFailure("domain te-agent", err);
2504
2696
  }
2505
2697
  try {
2506
- const memory = await import("./memory-VCYLVPMI.js");
2698
+ const memory = await import("./memory-HHPX3NF2.js");
2507
2699
  commands.push(...memory.default);
2508
2700
  } catch (err) {
2509
2701
  warnLoadFailure("domain memory", err);
2510
2702
  }
2511
- const automation = await import("./automation-K32V2NKP.js");
2703
+ const automation = await import("./automation-NAR5DDGL.js");
2512
2704
  commands.push(...automation.default);
2513
2705
  try {
2514
- const things = await import("./things-4JIBCA55.js");
2706
+ const things = await import("./things-22KQWC23.js");
2515
2707
  commands.push(...things.default);
2516
2708
  } catch (err) {
2517
2709
  warnLoadFailure("domain things", err);
2518
2710
  }
2519
2711
  try {
2520
- const workspace = await import("./workspace-Q5NMEKEN.js");
2712
+ const workspace = await import("./workspace-LYDAP647.js");
2521
2713
  commands.push(...workspace.default);
2522
2714
  } catch (err) {
2523
2715
  warnLoadFailure("domain workspace", err);
2524
2716
  }
2525
2717
  try {
2526
- const teSystem = await import("./te-system-IE7NCKC3.js");
2718
+ const teSystem = await import("./te-system-YM657FKO.js");
2527
2719
  commands.push(...teSystem.default);
2528
2720
  } catch (err) {
2529
2721
  warnLoadFailure("domain te-system", err);
2530
2722
  }
2531
2723
  try {
2532
- const metadata = await import("./metadata-YGI5M6OF.js");
2724
+ const metadata = await import("./metadata-TIFY24LW.js");
2533
2725
  commands.push(...metadata.default);
2534
2726
  } catch (err) {
2535
2727
  warnLoadFailure("domain metadata", err);
2536
2728
  }
2537
2729
  try {
2538
- const personalSemanticPreference = await import("./personal-semantic-preference-76TBKAPY.js");
2730
+ const personalSemanticPreference = await import("./personal-semantic-preference-WKJEGPTM.js");
2539
2731
  commands.push(...personalSemanticPreference.default);
2540
2732
  } catch (err) {
2541
2733
  warnLoadFailure("domain personal-semantic-preference", err);
2542
2734
  }
2543
2735
  try {
2544
- const projectSemantic = await import("./project-semantic-XOEBO2Q5.js");
2736
+ const projectSemantic = await import("./project-semantic-EIQVZNHW.js");
2545
2737
  commands.push(...projectSemantic.default);
2546
2738
  } catch (err) {
2547
2739
  warnLoadFailure("domain project-semantic", err);
2548
2740
  }
2549
2741
  try {
2550
- const dataIntegration = await import("./data-integration-EXSUPUDZ.js");
2742
+ const dataIntegration = await import("./data-integration-6UAZO4GG.js");
2551
2743
  commands.push(...dataIntegration.default);
2552
2744
  } catch (err) {
2553
2745
  warnLoadFailure("domain data-integration", err);
2554
2746
  }
2555
2747
  try {
2556
- const context = await import("./context-6RWLVOM5.js");
2748
+ const context = await import("./context-F6FCGTF3.js");
2557
2749
  commands.push(...context.default);
2558
2750
  } catch (err) {
2559
2751
  warnLoadFailure("domain context", err);
2560
2752
  }
2561
2753
  try {
2562
- const evaluation = await import("./evaluation-5YT4QLCL.js");
2754
+ const evaluation = await import("./evaluation-4LO2O4AF.js");
2563
2755
  commands.push(...evaluation.default);
2564
2756
  } catch (err) {
2565
2757
  warnLoadFailure("domain evaluation", err);
@@ -2568,7 +2760,7 @@ async function loadCommands() {
2568
2760
  }
2569
2761
  async function registerAuthCommands() {
2570
2762
  try {
2571
- const { registerAuth } = await import("./auth-NKD5Z5BQ.js");
2763
+ const { registerAuth } = await import("./auth-OBQ5KVQM.js");
2572
2764
  registerAuth(program);
2573
2765
  } catch (err) {
2574
2766
  warnLoadFailure("auth commands", err);
@@ -2576,7 +2768,7 @@ async function registerAuthCommands() {
2576
2768
  }
2577
2769
  async function registerConfigCommands() {
2578
2770
  try {
2579
- const { registerConfig } = await import("./config-ASSAAIOI.js");
2771
+ const { registerConfig } = await import("./config-YZ6O2UQ2.js");
2580
2772
  registerConfig(program);
2581
2773
  } catch (err) {
2582
2774
  warnLoadFailure("config commands", err);
@@ -2584,7 +2776,7 @@ async function registerConfigCommands() {
2584
2776
  }
2585
2777
  async function registerCapabilityCommands() {
2586
2778
  try {
2587
- const { registerCapability } = await import("./capability-4CGSL7PK.js");
2779
+ const { registerCapability } = await import("./capability-LFSVNI5B.js");
2588
2780
  registerCapability(program);
2589
2781
  } catch (err) {
2590
2782
  warnLoadFailure("capability commands", err);
@@ -2592,7 +2784,7 @@ async function registerCapabilityCommands() {
2592
2784
  }
2593
2785
  async function registerSyncCommand() {
2594
2786
  try {
2595
- const { registerSync } = await import("./sync-7PP6KQ75.js");
2787
+ const { registerSync } = await import("./sync-RV3OPCTI.js");
2596
2788
  registerSync(program);
2597
2789
  } catch (err) {
2598
2790
  warnLoadFailure("sync commands", err);
@@ -2600,7 +2792,7 @@ async function registerSyncCommand() {
2600
2792
  }
2601
2793
  async function registerModelCommand() {
2602
2794
  try {
2603
- const { registerModel } = await import("./model-DPJHSD73.js");
2795
+ const { registerModel } = await import("./model-7UHGWYVR.js");
2604
2796
  registerModel(program);
2605
2797
  } catch (err) {
2606
2798
  warnLoadFailure("model commands", err);
@@ -2608,25 +2800,44 @@ async function registerModelCommand() {
2608
2800
  }
2609
2801
  async function registerUpdateCommand() {
2610
2802
  try {
2611
- const { registerUpdate } = await import("./update-AX66IFMJ.js");
2803
+ const { registerUpdate } = await import("./update-XX4ILU7X.js");
2612
2804
  registerUpdate(program);
2613
2805
  } catch (err) {
2614
2806
  warnLoadFailure("update commands", err);
2615
2807
  }
2616
2808
  }
2617
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);
2618
2819
  setExternalCliTokenFile(globalOptionValue(process.argv.slice(2), "--cli-token-file"));
2619
- if (!process.argv.slice(2).some((arg) => ["--help", "-h", "--version", "-V"].includes(arg))) {
2820
+ if (!executionQuery && !helpRequested && !process.argv.slice(2).some((arg) => ["--version", "-V"].includes(arg))) {
2620
2821
  readExternalCliToken(globalOptionValue(process.argv.slice(2), "--host"));
2621
2822
  }
2622
2823
  const pkgInfo = getLocalCliPackageInfo();
2623
- if (!isRootUpdateCommand(process.argv.slice(2))) {
2824
+ if (!executionQuery && !helpRequested && !isRootUpdateCommand(process.argv.slice(2))) {
2624
2825
  const compat = await runHostCompatCheck(
2625
2826
  pkgInfo,
2626
2827
  globalOptionValue(process.argv.slice(2), "--host")
2627
2828
  );
2628
2829
  if (compat.status === "synced") {
2629
- 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.`;
2630
2841
  printError(
2631
2842
  "config",
2632
2843
  message,
@@ -2637,6 +2848,8 @@ async function main() {
2637
2848
  expected: compat.expected,
2638
2849
  cluster: compat.cluster,
2639
2850
  direction: compat.direction,
2851
+ versionSyncSucceeded: true,
2852
+ originalCommandExecuted: false,
2640
2853
  retryOriginalCommand: true
2641
2854
  },
2642
2855
  { log: false }
@@ -2645,7 +2858,7 @@ async function main() {
2645
2858
  return;
2646
2859
  }
2647
2860
  }
2648
- await runFeatureConfigCheck(globalOptionValue(process.argv.slice(2), "--host"));
2861
+ if (!executionQuery && !helpRequested) await runFeatureConfigCheck(globalOptionValue(process.argv.slice(2), "--host"));
2649
2862
  const commands = await loadCommands();
2650
2863
  registerCommands(program, commands);
2651
2864
  await registerAuthCommands();
@@ -2656,9 +2869,23 @@ async function main() {
2656
2869
  await registerUpdateCommand();
2657
2870
  registerInstall(program);
2658
2871
  registerTracking(program);
2872
+ if (!executionQuery) configureBusinessCommands(program, { hostOverride: globalOptionValue(process.argv.slice(2), "--host") });
2659
2873
  rejectUnknownHelpCommandPath(program, process.argv.slice(2));
2660
2874
  await parseProgram(program);
2661
2875
  }
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
+ }
2662
2889
  try {
2663
2890
  await main();
2664
2891
  } catch (error) {