@thinkingai/ae-cli 6.1.32 → 6.1.34

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 (119) hide show
  1. package/README.md +8 -5
  2. package/README.zh.md +10 -9
  3. package/bin/runtime-capabilities.json +1 -1
  4. package/cli-installation-guide.md +14 -4
  5. package/dist/{ai-monitor-MKMHSSNI.js → ai-monitor-TVRFVZBH.js} +11 -9
  6. package/dist/ai-monitor.js +18 -16
  7. package/dist/{auth-CZHHPZOQ.js → auth-JAXLMPBB.js} +33 -316
  8. package/dist/{automation-FLCPFMN4.js → automation-OQ647CSW.js} +7 -7
  9. package/dist/{capability-64KVJFIA.js → capability-2Z4ZXTPD.js} +19 -16
  10. package/dist/chunk-2H3SFJE3.js +344 -0
  11. package/dist/{chunk-TMQGS4TO.js → chunk-3PZNM5KN.js} +3 -3
  12. package/dist/chunk-3ZQY7SLZ.js +147 -0
  13. package/dist/chunk-6E6HCTP2.js +60 -0
  14. package/dist/{local-data-upload-client-KCMG6J62.js → chunk-6IUTXRAD.js} +32 -4
  15. package/dist/{chunk-5M5LBRR3.js → chunk-CYZV5AXW.js} +18 -9
  16. package/dist/{chunk-3ULDJJTZ.js → chunk-DE5XHQQ6.js} +2 -2
  17. package/dist/{chunk-FCAA7I2D.js → chunk-E5CJI7L3.js} +26 -10
  18. package/dist/{chunk-QVRIDN42.js → chunk-EQMGH32F.js} +2 -2
  19. package/dist/{chunk-DWBYNGSR.js → chunk-FNACCKQR.js} +372 -194
  20. package/dist/{chunk-OAWPT7VP.js → chunk-GD5JSAGV.js} +2 -2
  21. package/dist/{chunk-CF6JTT2U.js → chunk-GYODT7C4.js} +1 -1
  22. package/dist/chunk-HBI7IQH3.js +1207 -0
  23. package/dist/{chunk-4PSTYEG5.js → chunk-IGU3R2JD.js} +9 -5
  24. package/dist/{chunk-IDDWEZ7F.js → chunk-IWMDPHMI.js} +3 -3
  25. package/dist/{chunk-P7QDCWJ6.js → chunk-L7MT53VM.js} +8 -2
  26. package/dist/{chunk-F2VFZUGG.js → chunk-LXRALNNA.js} +2 -2
  27. package/dist/{chunk-6M7ZEDT2.js → chunk-M2OCZRVX.js} +14 -8
  28. package/dist/{chunk-Z3Q2AEIN.js → chunk-MTK4ZE7W.js} +17 -145
  29. package/dist/{chunk-T7WF4HYW.js → chunk-NK5PS5X7.js} +3 -3
  30. package/dist/{chunk-JEUXDY3B.js → chunk-NPH5J65M.js} +1 -1
  31. package/dist/chunk-PUSFEC6B.js +29 -0
  32. package/dist/{chunk-BNBCMCYN.js → chunk-Q764EZND.js} +78 -72
  33. package/dist/chunk-QOJXLXDJ.js +55 -0
  34. package/dist/{chunk-HVMCPKOZ.js → chunk-QPUPWGZ3.js} +1 -1
  35. package/dist/{chunk-72NJKS7O.js → chunk-RLPMXKDQ.js} +8921 -10119
  36. package/dist/{chunk-NLEXY2TM.js → chunk-S74XV3A6.js} +7 -5
  37. package/dist/{chunk-KTJXD27G.js → chunk-SHB7A2JE.js} +3 -3
  38. package/dist/{chunk-HTZ2MLYA.js → chunk-UWQXGF44.js} +25 -11
  39. package/dist/{data-integration-QE37EQ3A.js → chunk-V6UKLIM6.js} +160 -2258
  40. package/dist/{chunk-4XKTRCRK.js → chunk-VPLRZSMY.js} +22 -13
  41. package/dist/{chunk-2F64AZYH.js → chunk-Z6WSCIHM.js} +2 -2
  42. package/dist/{community-report-client-TJVCLZ3K.js → community-report-client-5VNT6HCV.js} +4 -2
  43. package/dist/{compat-check-ZJNCMNQV.js → compat-check-E7AQ7UCG.js} +6 -4
  44. package/dist/{config-FSH2NMNZ.js → config-PGSUWIK5.js} +16 -11
  45. package/dist/{context-YAQG6YQC.js → context-Y2A6QIS3.js} +9 -6
  46. package/dist/conversion-4FR3RA45.js +16 -0
  47. package/dist/data-integration-EIF5QHYF.js +2138 -0
  48. package/dist/{evaluation-2JSF4V47.js → evaluation-OZM54MES.js} +6 -5
  49. package/dist/index.js +79 -52
  50. package/dist/local-data-upload-client-2U3LFD7Z.js +16 -0
  51. package/dist/{memory-VEZZVAAP.js → memory-6QMZS4HF.js} +7 -7
  52. package/dist/{metadata-3IWHX3V4.js → metadata-7MZ3CJ2N.js} +11 -9
  53. package/dist/{model-T7H7Q6BG.js → model-LEYRQKOS.js} +8 -8
  54. package/dist/{personal-semantic-preference-YITU23SA.js → personal-semantic-preference-SWOUNDWJ.js} +46 -14
  55. package/dist/{project-semantic-MHEXJF3C.js → project-semantic-M2DDPAMD.js} +10 -8
  56. package/dist/{sync-AQHVCSPI.js → sync-PWC63JCO.js} +17 -16
  57. package/dist/{te-agent-RXI7WOH4.js → te-agent-S7UH657Z.js} +304 -16
  58. package/dist/{te-analysis-CZY74HVF.js → te-analysis-BK6PE333.js} +295 -223
  59. package/dist/{te-community-DKCYUBCM.js → te-community-OLNTKGCW.js} +17 -13
  60. package/dist/{te-dataops-QEH6VE56.js → te-dataops-XUWRIF5R.js} +18 -14
  61. package/dist/{te-engage-WK7WKDKF.js → te-engage-I3I4FJOM.js} +10 -8
  62. package/dist/{te-experiment-LH3RPIOE.js → te-experiment-XSDUL4KH.js} +216 -28
  63. package/dist/{te-kb-UPORIOVN.js → te-kb-QFH3YLFQ.js} +74 -21
  64. package/dist/{te-system-AL4B4XZL.js → te-system-DB5Z3LLF.js} +7 -7
  65. package/dist/{te-team-LLVTO2G4.js → te-team-UADF2HBO.js} +10 -8
  66. package/dist/{things-XLMLBYQR.js → things-G2QFXDK7.js} +10 -8
  67. package/dist/{update-7J5UQHSK.js → update-6I366ICW.js} +10 -9
  68. package/dist/web-runtime-3XFREWRF.js +2367 -0
  69. package/dist/{workspace-FF2HXJGR.js → workspace-RZESYB6T.js} +7 -7
  70. package/package.json +9 -5
  71. package/skills/ae-agent/SKILL.md +19 -5
  72. package/skills/ae-agent/references/a2a.md +103 -0
  73. package/skills/ae-agent/references/command_index.md +11 -0
  74. package/skills/ae-analysis/SKILL.md +35 -23
  75. package/skills/ae-analysis/references/analysis_data_retrieval.md +1 -1
  76. package/skills/ae-analysis/references/asset_authentication_export.md +1 -1
  77. package/skills/ae-analysis/references/asset_authentication_update.md +6 -2
  78. package/skills/ae-analysis/references/bad_case_review.md +4 -4
  79. package/skills/ae-analysis/references/command_index.md +7 -7
  80. package/skills/ae-analysis/references/governance_recommendation_export.md +2 -2
  81. package/skills/ae-analysis/references/personal_semantic_preference_add.md +9 -1
  82. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +2 -0
  83. package/skills/ae-analysis/references/personal_semantic_preference_get.md +2 -0
  84. package/skills/ae-analysis/references/personal_semantic_preference_list.md +10 -2
  85. package/skills/ae-analysis/references/personal_semantic_preference_update.md +8 -0
  86. package/skills/ae-analysis/references/project_owner_update.md +5 -1
  87. package/skills/ae-analysis/references/scenario_evaluation.md +17 -1
  88. package/skills/ae-analysis/references/scenario_list.md +5 -6
  89. package/skills/ae-capability/SKILL.md +8 -4
  90. package/skills/ae-data-integration/references/ue-mapping.md +2 -0
  91. package/skills/ae-experiment/SKILL.md +45 -16
  92. package/skills/ae-experiment/references/experiment_approval.md +87 -29
  93. package/skills/ae-experiment/references/manage_experiment.md +7 -3
  94. package/skills/ae-experiment/references/manage_traffic_domains.md +131 -0
  95. package/skills/ae-experiment/references/query_experiment_detail.md +8 -0
  96. package/skills/ae-experiment/references/query_experiment_list.md +6 -0
  97. package/skills/ae-experiment/references/save_experiment.md +39 -13
  98. package/skills/ae-experiment/references/save_metric.md +29 -2
  99. package/skills/ae-experiment/references/save_submit_experiment.md +11 -7
  100. package/skills/ae-experiment/references/save_submit_external_experiment.md +16 -14
  101. package/skills/ae-experiment/references/save_traffic_layer.md +17 -1
  102. package/skills/ae-kb/SKILL.md +4 -2
  103. package/skills/ae-kb/references/publication.md +45 -0
  104. package/skills/ae-onboarding/SKILL.md +64 -0
  105. package/skills/ae-onboarding/references/business-sdk.md +8 -0
  106. package/skills/ae-onboarding/references/demo-operations.md +79 -0
  107. package/skills/ae-onboarding/references/import.md +19 -0
  108. package/skills/ae-onboarding/references/onboarding_experiment_launch.md +12 -0
  109. package/skills/ae-onboarding/references/onboarding_experiment_plan.md +14 -0
  110. package/skills/ae-onboarding/references/onboarding_growth.md +36 -0
  111. package/skills/ae-onboarding/references/onboarding_run.md +11 -0
  112. package/skills/ae-onboarding/references/onboarding_status.md +5 -0
  113. package/skills/ae-onboarding/scripts/experiment-preset.json +252 -0
  114. package/skills/ae-onboarding/scripts/experiment-requests.mjs +120 -0
  115. package/skills/ae-onboarding/scripts/generate.mjs +170 -0
  116. package/skills/ae-onboarding/scripts/resolve-experiment-preset.mjs +26 -0
  117. package/skills/ae-onboarding/scripts/web-journey.mjs +39 -0
  118. package/dist/chunk-6ZIQV5GW.js +0 -26
  119. package/dist/chunk-Y74WTIKJ.js +0 -10
@@ -1,23 +1,29 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
+ getLocalCliPackageInfo
4
+ } from "./chunk-PUSFEC6B.js";
5
+ import {
6
+ internalCallSourceHeaders,
3
7
  peekCliToken
4
- } from "./chunk-HTZ2MLYA.js";
8
+ } from "./chunk-UWQXGF44.js";
5
9
  import {
6
10
  getActiveHost,
7
11
  getConfigDir,
8
12
  isAeSandboxRuntime,
9
13
  readSandboxCliTokenEntry
10
- } from "./chunk-4PSTYEG5.js";
14
+ } from "./chunk-IGU3R2JD.js";
11
15
  import {
12
- PermissionError,
13
16
  externalCliTokenRequestOptions,
14
17
  normalizeUrl,
15
18
  readExternalCliToken
16
- } from "./chunk-Z3Q2AEIN.js";
19
+ } from "./chunk-MTK4ZE7W.js";
20
+ import {
21
+ PermissionError
22
+ } from "./chunk-3ZQY7SLZ.js";
17
23
 
18
24
  // src/core/compat-check.ts
19
- import fs11 from "fs";
20
- import path11 from "path";
25
+ import fs10 from "fs";
26
+ import path10 from "path";
21
27
  import { createHash as createHash3 } from "crypto";
22
28
  import { Agent } from "undici";
23
29
 
@@ -307,45 +313,25 @@ function formatCompatNotice(verdict) {
307
313
  }
308
314
 
309
315
  // src/core/version-sync.ts
310
- import fs9 from "fs";
311
- import path9 from "path";
312
-
313
- // src/core/installation.ts
314
316
  import fs8 from "fs";
315
317
  import path8 from "path";
316
- import crypto3 from "crypto";
317
318
 
318
- // src/core/package-info.ts
319
- import fs2 from "fs";
320
- import path2 from "path";
321
- import { fileURLToPath } from "url";
322
- function getLocalCliPackageInfo() {
323
- let dir = path2.dirname(fileURLToPath(import.meta.url));
324
- for (let i = 0; i < 8; i += 1) {
325
- const candidate = path2.join(dir, "package.json");
326
- try {
327
- if (fs2.existsSync(candidate)) {
328
- const pkg = JSON.parse(fs2.readFileSync(candidate, "utf8"));
329
- if (pkg.name && pkg.version && String(pkg.name).includes("ae-cli")) {
330
- return { name: pkg.name, version: pkg.version, root: dir };
331
- }
332
- }
333
- } catch {
334
- }
335
- const parent = path2.dirname(dir);
336
- if (parent === dir) break;
337
- dir = parent;
338
- }
339
- return { name: "@tant/ae-cli", version: "0.0.0", root: "" };
340
- }
319
+ // src/core/installation.ts
320
+ import fs7 from "fs";
321
+ import path7 from "path";
322
+ import crypto3 from "crypto";
341
323
 
342
324
  // src/core/skills-install.ts
343
- import fs3 from "fs";
325
+ import fs2 from "fs";
344
326
  import os from "os";
345
- import path3 from "path";
327
+ import path2 from "path";
346
328
  import { parseDocument } from "yaml";
329
+ var ON_DEMAND_SKILLS = /* @__PURE__ */ new Set(["ae-onboarding"]);
330
+ function readInstallableSkills(directory, select) {
331
+ return readBundledSkills(directory, (name) => !ON_DEMAND_SKILLS.has(name) && (!select || select(name)));
332
+ }
347
333
  function globalSkillsDirectory() {
348
- return path3.join(os.homedir(), ".agents", "skills");
334
+ return path2.join(os.homedir(), ".agents", "skills");
349
335
  }
350
336
  function skillName(content) {
351
337
  const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
@@ -357,30 +343,30 @@ function skillName(content) {
357
343
  return data.name;
358
344
  }
359
345
  function readFiles(root, prefix = "", files = /* @__PURE__ */ new Map()) {
360
- for (const entry of fs3.readdirSync(path3.join(root, prefix), { withFileTypes: true })) {
346
+ for (const entry of fs2.readdirSync(path2.join(root, prefix), { withFileTypes: true })) {
361
347
  if (entry.name.startsWith(".") || ["metadata.json", "__pycache__", "__pypackages__"].includes(entry.name)) continue;
362
- const relative = path3.join(prefix, entry.name);
348
+ const relative = path2.join(prefix, entry.name);
363
349
  if (entry.isSymbolicLink()) throw new Error("Bundled Skills must contain regular files.");
364
350
  if (entry.isDirectory()) readFiles(root, relative, files);
365
- else if (entry.isFile()) files.set(relative, fs3.readFileSync(path3.join(root, relative)));
351
+ else if (entry.isFile()) files.set(relative, fs2.readFileSync(path2.join(root, relative)));
366
352
  }
367
353
  return files;
368
354
  }
369
355
  function readBundledSkills(directory, select) {
370
- const entries = fs3.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith("."));
356
+ const entries = fs2.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith("."));
371
357
  const names = /* @__PURE__ */ new Set();
372
358
  const skills = entries.flatMap((entry) => {
373
359
  try {
374
360
  let selectedName;
375
361
  if (select) {
376
- const header = path3.join(directory, entry.name, "SKILL.md");
377
- if (!fs3.lstatSync(header).isFile()) throw new Error("Bundled Skill metadata must be a regular file.");
378
- selectedName = skillName(fs3.readFileSync(header, "utf8"));
362
+ const header = path2.join(directory, entry.name, "SKILL.md");
363
+ if (!fs2.lstatSync(header).isFile()) throw new Error("Bundled Skill metadata must be a regular file.");
364
+ selectedName = skillName(fs2.readFileSync(header, "utf8"));
379
365
  if (names.has(selectedName)) throw new Error("Duplicate bundled Skill name.");
380
366
  names.add(selectedName);
381
367
  if (!select(selectedName)) return [];
382
368
  }
383
- const files = readFiles(path3.join(directory, entry.name));
369
+ const files = readFiles(path2.join(directory, entry.name));
384
370
  const name = skillName(files.get("SKILL.md").toString("utf8"));
385
371
  if (selectedName !== void 0 && selectedName !== name) throw new Error("Bundled Skill metadata changed.");
386
372
  return [{ name, files }];
@@ -398,12 +384,12 @@ function verifyGlobalSkills(skills, directory) {
398
384
  return skills.flatMap((skill) => {
399
385
  let reason = "";
400
386
  try {
401
- const target = path3.join(directory, skill.name);
402
- if (skillName(fs3.readFileSync(path3.join(target, "SKILL.md"), "utf8")) !== skill.name) {
387
+ const target = path2.join(directory, skill.name);
388
+ if (skillName(fs2.readFileSync(path2.join(target, "SKILL.md"), "utf8")) !== skill.name) {
403
389
  reason = "Installed Skill name does not match the bundled Skill.";
404
390
  } else {
405
391
  for (const [file, expected] of skill.files) {
406
- if (!fs3.readFileSync(path3.join(target, file)).equals(expected)) {
392
+ if (!fs2.readFileSync(path2.join(target, file)).equals(expected)) {
407
393
  reason = "Installed files do not match the CLI package version.";
408
394
  break;
409
395
  }
@@ -416,10 +402,127 @@ function verifyGlobalSkills(skills, directory) {
416
402
  });
417
403
  }
418
404
 
405
+ // src/core/onboarding/contracts.ts
406
+ var DEMO_CONTEXT = "project.plg_demo.context";
407
+ var DEMO_ENSURE = "project.plg_demo.ensure";
408
+ var DEMO_STATUS = "project.plg_demo.status";
409
+ var RUN_BUDGET_MS = 45e3;
410
+ var NETWORK_BUDGET_MS = 35e3;
411
+ var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
412
+ var DEMO_SAMPLE_IDS = ["star-island", "season-pass"];
413
+ var CHECKOUT_RECOVERY = "checkout-recovery";
414
+ function onboardingGrowthScenario(value) {
415
+ if (value === void 0 || value === "item-coupon") return "item-coupon";
416
+ if (value === CHECKOUT_RECOVERY) return CHECKOUT_RECOVERY;
417
+ throw new Error("Use --scenario item-coupon or checkout-recovery.");
418
+ }
419
+
420
+ // src/core/website-entry.ts
421
+ var LOGIN_PATHS = { jp: "/jp/experience-login/", kr: "/kr/experience-login/", us: "/en/experience-login/" };
422
+ var WEBSITE_MARKETS = Object.keys(LOGIN_PATHS);
423
+ var PRODUCTION_ISSUER = "https://thinkingai.io";
424
+ var PRODUCTION_BROWSER_ORIGIN = "https://www.thinkingai.io";
425
+ function isWebsiteMarket(market) {
426
+ return Object.hasOwn(LOGIN_PATHS, market);
427
+ }
428
+ function websiteEnvironment(value, env = process.env) {
429
+ const selected = value ?? env.AE_CLI_WEBSITE_ENV ?? "production";
430
+ if (selected !== "production") throw new Error("Website onboarding supports only the production environment.");
431
+ return "production";
432
+ }
433
+ function websiteOrigin(market, environment) {
434
+ websiteEnvironment(environment, {});
435
+ if (!isWebsiteMarket(market)) throw new Error("Website onboarding is available in Japan, Korea, and the United States. Use --region jp, kr, or us.");
436
+ return PRODUCTION_ISSUER;
437
+ }
438
+ function isProductionWebsiteOrigin(origin) {
439
+ return origin === PRODUCTION_ISSUER || origin === PRODUCTION_BROWSER_ORIGIN;
440
+ }
441
+ function environmentForWebsiteOrigin(origin) {
442
+ if (isProductionWebsiteOrigin(origin)) return "production";
443
+ throw new Error("Untrusted onboarding website.");
444
+ }
445
+ function cliEntrySource(source, env = process.env) {
446
+ const selected = source ?? (UUID_PATTERN.test(env.CODEX_THREAD_ID ?? "") ? "codex" : "other");
447
+ if (!["codex", "cursor", "claude-code", "other"].includes(selected)) throw new Error("Unsupported local AI tool source.");
448
+ return selected;
449
+ }
450
+ function cliToolReference(source, env = process.env) {
451
+ return source === "codex" && UUID_PATTERN.test(env.CODEX_THREAD_ID ?? "") ? env.CODEX_THREAD_ID : void 0;
452
+ }
453
+ function withCliEntryContext(value, source, market, toolReference) {
454
+ const url = new URL(value);
455
+ if (url.protocol !== "https:" || url.username || url.password) throw new Error("Untrusted website continuation URL.");
456
+ if ([...url.searchParams.keys()].some((key) => /^(device_code|poll_token|access_token|refresh_token|cli[_-]token|token)$/i.test(key))) {
457
+ throw new Error("The website returned a private credential in its public continuation URL.");
458
+ }
459
+ const references = url.searchParams.getAll("tool_reference");
460
+ if (references.length > 1 || references.some((reference) => !UUID_PATTERN.test(reference))) throw new Error("Invalid AI tool continuation reference.");
461
+ url.searchParams.set("entry", "cli");
462
+ url.searchParams.set("source", cliEntrySource(source));
463
+ if (market && !url.searchParams.has("market")) url.searchParams.set("market", market);
464
+ if (toolReference) {
465
+ if (source !== "codex" || !UUID_PATTERN.test(toolReference)) throw new Error("Invalid AI tool continuation reference.");
466
+ if (references.length && references[0] !== toolReference) throw new Error("The website returned a mismatched AI tool continuation reference.");
467
+ if (!url.searchParams.has("tool_reference")) url.searchParams.set("tool_reference", toolReference);
468
+ }
469
+ return url.toString();
470
+ }
471
+ function websiteLoginUrl(market, environment, source, toolReference) {
472
+ websiteEnvironment(environment, {});
473
+ if (!isWebsiteMarket(market)) throw new Error("Website onboarding is available in Japan, Korea, and the United States. Use --region jp, kr, or us.");
474
+ return withCliEntryContext(`${PRODUCTION_BROWSER_ORIGIN}${LOGIN_PATHS[market]}`, source, market, toolReference);
475
+ }
476
+
477
+ // src/core/host-guidance.ts
478
+ function normalizeRegistrationLanguage(value) {
479
+ const language = value.trim().toLowerCase().split(/[_.:@-]/)[0];
480
+ if (language === "zh" || language === "cn") return "zh-CN";
481
+ if (language === "ja" || language === "jp") return "ja-JP";
482
+ if (language === "ko" || language === "kr") return "ko-KR";
483
+ return language === "en" ? "en-US" : void 0;
484
+ }
485
+ function registrationLanguage(language, env = process.env) {
486
+ const value = language || env.AE_LANG || env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE || "";
487
+ return normalizeRegistrationLanguage(value) ?? "en-US";
488
+ }
489
+ function registrationMarket(language) {
490
+ return { "zh-CN": "cn", "en-US": "us", "ja-JP": "jp", "ko-KR": "kr" }[language];
491
+ }
492
+ function aeRegistrationUrl(language, env = process.env, source) {
493
+ const market = registrationMarket(registrationLanguage(language, env));
494
+ if (!isWebsiteMarket(market)) return AE_TRIAL_URL;
495
+ const tool = cliEntrySource(source, env);
496
+ return websiteLoginUrl(market, "production", tool, cliToolReference(tool, env));
497
+ }
498
+ var AE_TRIAL_URL = "https://thinkingai.cn/request-demo";
499
+ var AE_HOST_SETUP_COMMAND = "ae-cli config set-host <url>";
500
+ function missingAeHostHint(additionalAction) {
501
+ const registration = aeRegistrationUrl();
502
+ const actions = [
503
+ `If your organization already uses AgenticEngine, ask your administrator for its AE URL, then run: ${AE_HOST_SETUP_COMMAND} and ae-cli auth login --host <url>. Keep your existing account's environment.`,
504
+ registration === AE_TRIAL_URL ? `To request a trial, visit ${registration}.` : `To register or sign in, visit ${registration}, or run ae-cli analysis onboarding run for guided setup.`
505
+ ];
506
+ if (additionalAction) actions.push(additionalAction);
507
+ return actions.join(" ");
508
+ }
509
+ function missingAeHostGuidance() {
510
+ const registration = aeRegistrationUrl();
511
+ return {
512
+ configure_host: AE_HOST_SETUP_COMMAND,
513
+ existing_customer: "Use the original AE environment URL when known, or ask your administrator.",
514
+ request_trial_url: registration,
515
+ ...registration === AE_TRIAL_URL ? {} : {
516
+ registration_login_url: registration,
517
+ onboarding_command: "ae-cli analysis onboarding run"
518
+ }
519
+ };
520
+ }
521
+
419
522
  // src/core/business-config.ts
420
523
  import crypto2 from "crypto";
421
- import fs7 from "fs";
422
- import path7 from "path";
524
+ import fs6 from "fs";
525
+ import path6 from "path";
423
526
 
424
527
  // src/core/skill-businesses.json
425
528
  var skill_businesses_default = {
@@ -435,6 +538,7 @@ var skill_businesses_default = {
435
538
  "ae-generate-tracking-plan",
436
539
  "ae-metadata",
437
540
  "ae-migrate-tracking-code",
541
+ "ae-onboarding",
438
542
  "ae-tracking-matrix"
439
543
  ],
440
544
  dataops: [
@@ -605,19 +709,19 @@ function canManageGlobalSkills() {
605
709
 
606
710
  // src/core/business-skill-refresh.ts
607
711
  import crypto from "crypto";
608
- import fs6 from "fs";
609
- import path6 from "path";
712
+ import fs5 from "fs";
713
+ import path5 from "path";
610
714
 
611
715
  // src/core/business-skill-sync.ts
612
- import fs5 from "fs";
716
+ import fs4 from "fs";
613
717
  import os3 from "os";
614
- import path5 from "path";
718
+ import path4 from "path";
615
719
  import { createHash as createHash2, randomUUID } from "crypto";
616
720
 
617
721
  // src/core/skills-tool.ts
618
- import fs4 from "fs";
722
+ import fs3 from "fs";
619
723
  import os2 from "os";
620
- import path4 from "path";
724
+ import path3 from "path";
621
725
  import { createHash } from "crypto";
622
726
  import { createRequire, isBuiltin } from "module";
623
727
  import { pathToFileURL } from "url";
@@ -626,12 +730,12 @@ var MANAGED_SKILLS_TOOL_VERSION = "1.5.12";
626
730
  var TOOL_SOURCE_SHA256 = "5a2c18ddd70886d5367e39a0f88827ffd1024420e4d9db08149742386c088d2d";
627
731
  function skillPathIdentity(file) {
628
732
  try {
629
- const stat = fs4.lstatSync(file, { bigint: true });
733
+ const stat = fs3.lstatSync(file, { bigint: true });
630
734
  return {
631
735
  dev: String(stat.dev),
632
736
  ino: String(stat.ino),
633
737
  type: stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "directory" : stat.isFile() ? "file" : "other",
634
- ...stat.isSymbolicLink() ? { link: fs4.readlinkSync(file) } : {}
738
+ ...stat.isSymbolicLink() ? { link: fs3.readlinkSync(file) } : {}
635
739
  };
636
740
  } catch (error) {
637
741
  if (error.code === "ENOENT") return null;
@@ -640,28 +744,28 @@ function skillPathIdentity(file) {
640
744
  }
641
745
  function realSkillPath(file) {
642
746
  try {
643
- return fs4.realpathSync(file);
747
+ return fs3.realpathSync(file);
644
748
  } catch (error) {
645
749
  if (error.code !== "ENOENT") throw error;
646
- const parent = path4.dirname(file);
750
+ const parent = path3.dirname(file);
647
751
  if (parent === file) throw error;
648
- return path4.join(realSkillPath(parent), path4.basename(file));
752
+ return path3.join(realSkillPath(parent), path3.basename(file));
649
753
  }
650
754
  }
651
755
  function skillPathProblem(targetDirectory, skill, sourceRoot) {
652
756
  try {
653
- const target = realSkillPath(path4.resolve(targetDirectory, skill));
654
- const source = realSkillPath(path4.resolve(sourceRoot));
655
- const overlaps = (a, b) => a === b || a.startsWith(b + path4.sep);
757
+ const target = realSkillPath(path3.resolve(targetDirectory, skill));
758
+ const source = realSkillPath(path3.resolve(sourceRoot));
759
+ const overlaps = (a, b) => a === b || a.startsWith(b + path3.sep);
656
760
  if (overlaps(target, source) || overlaps(source, target)) return "package_source_overlap";
657
- let parent = path4.resolve(targetDirectory);
761
+ let parent = path3.resolve(targetDirectory);
658
762
  while (true) {
659
763
  try {
660
- if (fs4.lstatSync(parent).isSymbolicLink()) return "copy_parent_linked";
764
+ if (fs3.lstatSync(parent).isSymbolicLink()) return "copy_parent_linked";
661
765
  } catch (error) {
662
766
  if (error.code !== "ENOENT") throw error;
663
767
  }
664
- const next = path4.dirname(parent);
768
+ const next = path3.dirname(parent);
665
769
  if (next === parent) return null;
666
770
  parent = next;
667
771
  }
@@ -671,27 +775,27 @@ function skillPathProblem(targetDirectory, skill, sourceRoot) {
671
775
  }
672
776
  function skillCopyHash(directory, source = false) {
673
777
  try {
674
- if (!fs4.lstatSync(directory).isDirectory()) throw new Error("Not a regular Skill directory.");
778
+ if (!fs3.lstatSync(directory).isDirectory()) throw new Error("Not a regular Skill directory.");
675
779
  } catch (error) {
676
780
  if (error.code === "ENOENT") return null;
677
781
  throw error;
678
782
  }
679
783
  const hash = createHash("sha256");
680
784
  const visit = (relative) => {
681
- for (const name of fs4.readdirSync(path4.join(directory, relative)).sort()) {
785
+ for (const name of fs3.readdirSync(path3.join(directory, relative)).sort()) {
682
786
  if (name === ".DS_Store") continue;
683
- const child = path4.join(relative, name);
684
- const absolute = path4.join(directory, child);
685
- const stat = fs4.lstatSync(absolute);
787
+ const child = path3.join(relative, name);
788
+ const absolute = path3.join(directory, child);
789
+ const stat = fs3.lstatSync(absolute);
686
790
  if (source && (name === "metadata.json" || stat.isDirectory() && [".git", "__pycache__", "__pypackages__"].includes(name))) continue;
687
- const normalized = child.split(path4.sep).join("/");
791
+ const normalized = child.split(path3.sep).join("/");
688
792
  if (stat.isSymbolicLink()) throw new Error("Symbolic links are not managed Skill copies.");
689
793
  if (stat.isDirectory()) {
690
794
  hash.update(`directory:${normalized}\0`);
691
795
  visit(child);
692
796
  } else if (stat.isFile()) {
693
797
  hash.update(`file:${normalized}\0${stat.size}\0`);
694
- hash.update(fs4.readFileSync(absolute));
798
+ hash.update(fs3.readFileSync(absolute));
695
799
  } else throw new Error("Unsupported Skill file type.");
696
800
  }
697
801
  };
@@ -748,7 +852,7 @@ function adaptedToolSource(source, entry) {
748
852
  );
749
853
  source = replaceOnce(source, "main().finally(() => flushTelemetry().then(() => process.exit(0)));", "");
750
854
  const require2 = createRequire(entry);
751
- const resolveImport = (specifier) => isBuiltin(specifier) ? specifier : pathToFileURL(specifier.startsWith(".") ? path4.resolve(path4.dirname(entry), specifier) : require2.resolve(specifier)).href;
855
+ const resolveImport = (specifier) => isBuiltin(specifier) ? specifier : pathToFileURL(specifier.startsWith(".") ? path3.resolve(path3.dirname(entry), specifier) : require2.resolve(specifier)).href;
752
856
  source = source.replace(
753
857
  /\bfrom (['"])([^'"]+)\1/g,
754
858
  (_match, quote, specifier) => `from ${quote}${resolveImport(specifier)}${quote}`
@@ -958,19 +1062,19 @@ catch { process.stdout.write(JSON.stringify({ ok: false })); process.exitCode =
958
1062
  `;
959
1063
  function createPinnedSkillsTool(options = {}) {
960
1064
  const require2 = createRequire(import.meta.url);
961
- const packageFile = options.entry ? path4.join(path4.dirname(options.entry), "..", "package.json") : require2.resolve("skills/package.json");
962
- const entry = options.entry ?? path4.join(path4.dirname(packageFile), "dist", "cli.mjs");
963
- const metadata = JSON.parse(fs4.readFileSync(packageFile, "utf8"));
964
- const source = fs4.readFileSync(entry, "utf8");
1065
+ const packageFile = options.entry ? path3.join(path3.dirname(options.entry), "..", "package.json") : require2.resolve("skills/package.json");
1066
+ const entry = options.entry ?? path3.join(path3.dirname(packageFile), "dist", "cli.mjs");
1067
+ const metadata = JSON.parse(fs3.readFileSync(packageFile, "utf8"));
1068
+ const source = fs3.readFileSync(entry, "utf8");
965
1069
  if (metadata.version !== MANAGED_SKILLS_TOOL_VERSION || createHash("sha256").update(source).digest("hex") !== TOOL_SOURCE_SHA256) {
966
1070
  throw new Error("Managed Skill synchronization requires the verified skills@1.5.12 package.");
967
1071
  }
968
1072
  const script = adaptedToolSource(source, entry);
969
1073
  const run = (request) => {
970
- const directory = fs4.mkdtempSync(path4.join(os2.tmpdir(), "ae-cli-skills-tool-"));
971
- const worker = path4.join(directory, "adapter.mjs");
1074
+ const directory = fs3.mkdtempSync(path3.join(os2.tmpdir(), "ae-cli-skills-tool-"));
1075
+ const worker = path3.join(directory, "adapter.mjs");
972
1076
  try {
973
- fs4.writeFileSync(worker, script, { mode: 384 });
1077
+ fs3.writeFileSync(worker, script, { mode: 384 });
974
1078
  const result2 = spawn2.sync(process.execPath, [worker], {
975
1079
  input: JSON.stringify(request),
976
1080
  encoding: "utf8",
@@ -987,7 +1091,7 @@ function createPinnedSkillsTool(options = {}) {
987
1091
  } catch {
988
1092
  throw new Error("Skills adapter failed. Check the pinned package and directory permissions.");
989
1093
  } finally {
990
- fs4.rmSync(directory, { recursive: true, force: true });
1094
+ fs3.rmSync(directory, { recursive: true, force: true });
991
1095
  }
992
1096
  };
993
1097
  return {
@@ -1004,17 +1108,17 @@ var POLICY_HASH = createHash2("sha256").update(JSON.stringify({ removal_policy:
1004
1108
  function historicalCliSkills(options) {
1005
1109
  const env = options.env ?? process.env;
1006
1110
  const home = env.HOME || env.USERPROFILE || os3.homedir();
1007
- const file = env.XDG_STATE_HOME ? path5.join(env.XDG_STATE_HOME, "skills", ".skill-lock.json") : path5.join(home, ".agents", ".skill-lock.json");
1111
+ const file = env.XDG_STATE_HOME ? path4.join(env.XDG_STATE_HOME, "skills", ".skill-lock.json") : path4.join(home, ".agents", ".skill-lock.json");
1008
1112
  const names = /* @__PURE__ */ new Set();
1009
1113
  let content = "";
1010
1114
  const isCliSource = (value, type) => {
1011
1115
  if (typeof value !== "string") return false;
1012
- if (type === "local" && path5.isAbsolute(value)) {
1013
- const source2 = path5.resolve(value);
1014
- if (source2 === path5.resolve(options.skillsDirectory)) return true;
1015
- if (path5.basename(source2) !== "skills") return false;
1116
+ if (type === "local" && path4.isAbsolute(value)) {
1117
+ const source2 = path4.resolve(value);
1118
+ if (source2 === path4.resolve(options.skillsDirectory)) return true;
1119
+ if (path4.basename(source2) !== "skills") return false;
1016
1120
  try {
1017
- const pkg = JSON.parse(fs5.readFileSync(path5.join(source2, "..", "package.json"), "utf8"));
1121
+ const pkg = JSON.parse(fs4.readFileSync(path4.join(source2, "..", "package.json"), "utf8"));
1018
1122
  return ["@tant/ae-cli", "@thinkingai/ae-cli"].includes(pkg.name) && typeof pkg.bin?.["ae-cli"] === "string";
1019
1123
  } catch {
1020
1124
  return false;
@@ -1032,7 +1136,7 @@ function historicalCliSkills(options) {
1032
1136
  ].includes(source);
1033
1137
  };
1034
1138
  try {
1035
- content = fs5.readFileSync(file, "utf8");
1139
+ content = fs4.readFileSync(file, "utf8");
1036
1140
  const lock = JSON.parse(content);
1037
1141
  const mapped = new Set(Object.values(skill_businesses_default).flat());
1038
1142
  if (typeof lock.version === "number" && lock.skills && typeof lock.skills === "object") {
@@ -1049,11 +1153,11 @@ function historicalCliSkills(options) {
1049
1153
  function writeJson(file, value) {
1050
1154
  const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
1051
1155
  try {
1052
- fs5.writeFileSync(temporary, JSON.stringify(value, null, 2) + "\n", { mode: 384, flag: "wx" });
1053
- fs5.renameSync(temporary, file);
1156
+ fs4.writeFileSync(temporary, JSON.stringify(value, null, 2) + "\n", { mode: 384, flag: "wx" });
1157
+ fs4.renameSync(temporary, file);
1054
1158
  } finally {
1055
1159
  try {
1056
- fs5.unlinkSync(temporary);
1160
+ fs4.unlinkSync(temporary);
1057
1161
  } catch {
1058
1162
  }
1059
1163
  }
@@ -1073,15 +1177,15 @@ function contextIdentity(options) {
1073
1177
  }
1074
1178
  function reserveBusinessSkillContext(options) {
1075
1179
  const directory = options.stateDirectory ?? getConfigDir();
1076
- fs5.mkdirSync(directory, { recursive: true, mode: 448 });
1180
+ fs4.mkdirSync(directory, { recursive: true, mode: 448 });
1077
1181
  const generation = randomUUID();
1078
- writeJson(path5.join(directory, CONTEXT_FILE), { ...contextIdentity(options), generation });
1182
+ writeJson(path4.join(directory, CONTEXT_FILE), { ...contextIdentity(options), generation });
1079
1183
  return generation;
1080
1184
  }
1081
1185
  function currentContext(options, file, generation) {
1082
1186
  try {
1083
1187
  if (options.isCurrentContext && !options.isCurrentContext()) return false;
1084
- const active = JSON.parse(fs5.readFileSync(file, "utf8"));
1188
+ const active = JSON.parse(fs4.readFileSync(file, "utf8"));
1085
1189
  const identity = contextIdentity(options);
1086
1190
  return active.generation === generation && active.host === identity.host && active.token_fingerprint === identity.token_fingerprint;
1087
1191
  } catch {
@@ -1089,12 +1193,12 @@ function currentContext(options, file, generation) {
1089
1193
  }
1090
1194
  }
1091
1195
  function isBusinessSkillContextCurrent(options) {
1092
- return currentContext(options, path5.join(options.stateDirectory ?? getConfigDir(), CONTEXT_FILE), options.generation);
1196
+ return currentContext(options, path4.join(options.stateDirectory ?? getConfigDir(), CONTEXT_FILE), options.generation);
1093
1197
  }
1094
1198
  function takeLock(file) {
1095
1199
  const owner = randomUUID();
1096
1200
  const ownerName = `owner-${process.pid}-${owner}.json`;
1097
- const candidate = fs5.mkdtempSync(`${file}.candidate-`);
1201
+ const candidate = fs4.mkdtempSync(`${file}.candidate-`);
1098
1202
  const alive = (pid) => {
1099
1203
  try {
1100
1204
  process.kill(pid, 0);
@@ -1104,29 +1208,29 @@ function takeLock(file) {
1104
1208
  }
1105
1209
  };
1106
1210
  try {
1107
- fs5.chmodSync(candidate, 448);
1108
- fs5.writeFileSync(path5.join(candidate, ownerName), JSON.stringify({ pid: process.pid, owner }), { mode: 384 });
1211
+ fs4.chmodSync(candidate, 448);
1212
+ fs4.writeFileSync(path4.join(candidate, ownerName), JSON.stringify({ pid: process.pid, owner }), { mode: 384 });
1109
1213
  for (let attempt = 0; attempt < 4; attempt++) {
1110
1214
  try {
1111
- fs5.renameSync(candidate, file);
1215
+ fs4.renameSync(candidate, file);
1112
1216
  try {
1113
- fs5.unlinkSync(`${file}.reclaim`);
1217
+ fs4.unlinkSync(`${file}.reclaim`);
1114
1218
  } catch {
1115
1219
  }
1116
1220
  return () => {
1117
1221
  try {
1118
- fs5.unlinkSync(path5.join(file, ownerName));
1222
+ fs4.unlinkSync(path4.join(file, ownerName));
1119
1223
  } catch {
1120
1224
  }
1121
1225
  try {
1122
- fs5.rmdirSync(file);
1226
+ fs4.rmdirSync(file);
1123
1227
  } catch {
1124
1228
  }
1125
1229
  };
1126
1230
  } catch (error) {
1127
1231
  let stat;
1128
1232
  try {
1129
- stat = fs5.lstatSync(file);
1233
+ stat = fs4.lstatSync(file);
1130
1234
  } catch (cause) {
1131
1235
  if (cause.code === "ENOENT") continue;
1132
1236
  throw error;
@@ -1135,12 +1239,12 @@ function takeLock(file) {
1135
1239
  if (stat.isFile()) {
1136
1240
  let pid;
1137
1241
  try {
1138
- pid = JSON.parse(fs5.readFileSync(file, "utf8")).pid;
1242
+ pid = JSON.parse(fs4.readFileSync(file, "utf8")).pid;
1139
1243
  } catch {
1140
1244
  }
1141
1245
  if (typeof pid === "number" && Number.isInteger(pid) && pid > 0 && alive(pid)) return null;
1142
1246
  try {
1143
- fs5.unlinkSync(file);
1247
+ fs4.unlinkSync(file);
1144
1248
  } catch (cause) {
1145
1249
  if (!["ENOENT", "EISDIR", "EPERM"].includes(cause.code ?? "")) throw cause;
1146
1250
  }
@@ -1149,7 +1253,7 @@ function takeLock(file) {
1149
1253
  if (!stat.isDirectory()) return null;
1150
1254
  let names;
1151
1255
  try {
1152
- names = fs5.readdirSync(file);
1256
+ names = fs4.readdirSync(file);
1153
1257
  } catch (cause) {
1154
1258
  if (cause.code === "ENOENT") continue;
1155
1259
  throw cause;
@@ -1160,13 +1264,13 @@ function takeLock(file) {
1160
1264
  }
1161
1265
  for (const name of names) {
1162
1266
  try {
1163
- fs5.unlinkSync(path5.join(file, name));
1267
+ fs4.unlinkSync(path4.join(file, name));
1164
1268
  } catch (cause) {
1165
1269
  if (cause.code !== "ENOENT") throw cause;
1166
1270
  }
1167
1271
  }
1168
1272
  try {
1169
- fs5.rmdirSync(file);
1273
+ fs4.rmdirSync(file);
1170
1274
  } catch (cause) {
1171
1275
  if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(cause.code ?? "")) throw cause;
1172
1276
  }
@@ -1174,13 +1278,13 @@ function takeLock(file) {
1174
1278
  }
1175
1279
  return null;
1176
1280
  } finally {
1177
- fs5.rmSync(candidate, { recursive: true, force: true });
1281
+ fs4.rmSync(candidate, { recursive: true, force: true });
1178
1282
  }
1179
1283
  }
1180
1284
  function readLedger(file) {
1181
1285
  let value;
1182
1286
  try {
1183
- value = JSON.parse(fs5.readFileSync(file, "utf8"));
1287
+ value = JSON.parse(fs4.readFileSync(file, "utf8"));
1184
1288
  } catch (error) {
1185
1289
  if (error.code === "ENOENT") return { schema_version: 1, copies: {} };
1186
1290
  throw new Error("Managed Skill ledger is unreadable.");
@@ -1189,12 +1293,12 @@ function readLedger(file) {
1189
1293
  throw new Error("Managed Skill ledger has an unsupported format.");
1190
1294
  }
1191
1295
  for (const [filePath, copy] of Object.entries(value.copies)) {
1192
- if (!path5.isAbsolute(filePath) || !copy || typeof copy.skill !== "string" || typeof copy.agent !== "string" || !/^[a-f0-9]{64}$/.test(copy.hash) || typeof copy.package_version !== "string") throw new Error("Managed Skill ledger has an invalid copy.");
1296
+ if (!path4.isAbsolute(filePath) || !copy || typeof copy.skill !== "string" || typeof copy.agent !== "string" || !/^[a-f0-9]{64}$/.test(copy.hash) || typeof copy.package_version !== "string") throw new Error("Managed Skill ledger has an invalid copy.");
1193
1297
  }
1194
1298
  return value;
1195
1299
  }
1196
1300
  function result(skill, target, reason) {
1197
- return { skill, agent: target.agent, path: path5.join(target.directory, skill), ...reason ? { reason } : {} };
1301
+ return { skill, agent: target.agent, path: path4.join(target.directory, skill), ...reason ? { reason } : {} };
1198
1302
  }
1199
1303
  function directInstallerLink(file, target, text) {
1200
1304
  if (typeof text !== "string") return false;
@@ -1202,21 +1306,21 @@ function directInstallerLink(file, target, text) {
1202
1306
  if (process.platform === "win32") {
1203
1307
  if (value.toUpperCase().startsWith("\\\\?\\UNC\\")) value = "\\\\" + value.slice(8);
1204
1308
  else if (value.startsWith("\\\\?\\") || value.startsWith("\\??\\")) value = value.slice(4);
1205
- return [target, path5.relative(path5.dirname(file), target)].some((expected) => value.toLowerCase() === expected.toLowerCase());
1309
+ return [target, path4.relative(path4.dirname(file), target)].some((expected) => value.toLowerCase() === expected.toLowerCase());
1206
1310
  }
1207
- return value === target || value === path5.relative(path5.dirname(file), target);
1311
+ return value === target || value === path4.relative(path4.dirname(file), target);
1208
1312
  }
1209
1313
  function legacySkillLink(file, skill, sourceRoot, sourceHash, targets, ledger, removing = false) {
1210
1314
  const canonical = targets.find((target2) => target2.agent === "universal");
1211
1315
  if (!canonical) return;
1212
- const target = path5.join(canonical.directory, skill);
1316
+ const target = path4.join(canonical.directory, skill);
1213
1317
  const managed = ledger.copies[target];
1214
1318
  if (!managed || managed.skill !== skill || managed.agent !== canonical.agent || !removing && managed.hash !== sourceHash || skillPathProblem(canonical.directory, skill, sourceRoot)) return;
1215
1319
  try {
1216
- if (!fs5.lstatSync(file).isSymbolicLink()) return;
1217
- const text = fs5.readlinkSync(file);
1320
+ if (!fs4.lstatSync(file).isSymbolicLink()) return;
1321
+ const text = fs4.readlinkSync(file);
1218
1322
  if (!directInstallerLink(file, target, text)) return;
1219
- if (!removing && (skillCopyHash(target) !== sourceHash || fs5.realpathSync(file) !== fs5.realpathSync(target))) return;
1323
+ if (!removing && (skillCopyHash(target) !== sourceHash || fs4.realpathSync(file) !== fs4.realpathSync(target))) return;
1220
1324
  return { target, text };
1221
1325
  } catch {
1222
1326
  return;
@@ -1233,20 +1337,20 @@ function syncBusinessSkills(options) {
1233
1337
  managed_count: 0
1234
1338
  };
1235
1339
  const directory = options.stateDirectory ?? getConfigDir();
1236
- const contextFile = path5.join(directory, CONTEXT_FILE);
1340
+ const contextFile = path4.join(directory, CONTEXT_FILE);
1237
1341
  let unlock = null;
1238
1342
  try {
1239
1343
  if (options.isCurrentContext && !options.isCurrentContext()) {
1240
1344
  report.status = "stale";
1241
1345
  return report;
1242
1346
  }
1243
- fs5.mkdirSync(directory, { recursive: true, mode: 448 });
1347
+ fs4.mkdirSync(directory, { recursive: true, mode: 448 });
1244
1348
  const generation = options.generation ?? reserveBusinessSkillContext(options);
1245
1349
  if (!currentContext(options, contextFile, generation)) {
1246
1350
  report.status = "stale";
1247
1351
  return report;
1248
1352
  }
1249
- unlock = takeLock(path5.join(directory, LOCK_FILE));
1353
+ unlock = takeLock(path4.join(directory, LOCK_FILE));
1250
1354
  if (!unlock) {
1251
1355
  report.status = "busy";
1252
1356
  return report;
@@ -1255,7 +1359,7 @@ function syncBusinessSkills(options) {
1255
1359
  report.status = "stale";
1256
1360
  return report;
1257
1361
  }
1258
- const ledgerFile = path5.join(directory, LEDGER_FILE);
1362
+ const ledgerFile = path4.join(directory, LEDGER_FILE);
1259
1363
  const ledger = readLedger(ledgerFile);
1260
1364
  const packageVersion = options.packageVersion ?? "unknown";
1261
1365
  const history = historicalCliSkills(options);
@@ -1263,7 +1367,7 @@ function syncBusinessSkills(options) {
1263
1367
  ...contextIdentity(options),
1264
1368
  package_version: packageVersion,
1265
1369
  businesses: normalizeBusinesses(options.businesses),
1266
- source_root: fs5.realpathSync(options.skillsDirectory),
1370
+ source_root: fs4.realpathSync(options.skillsDirectory),
1267
1371
  policy_hash: POLICY_HASH,
1268
1372
  history_hash: history.hash
1269
1373
  };
@@ -1296,7 +1400,7 @@ function syncBusinessSkills(options) {
1296
1400
  writeJson(ledgerFile, ledger);
1297
1401
  }
1298
1402
  }
1299
- const bundled = readBundledSkills(options.skillsDirectory, select);
1403
+ const bundled = readInstallableSkills(options.skillsDirectory, select);
1300
1404
  const skills = new Set(bundled.map((skill) => skill.name));
1301
1405
  if (options.mode !== "adopt") {
1302
1406
  for (const name of [...history.names, ...Object.values(ledger.copies).map((copy) => copy.skill)]) {
@@ -1309,7 +1413,7 @@ function syncBusinessSkills(options) {
1309
1413
  for (const name of skills) {
1310
1414
  const state = getSkillBusinessState(name, options.businesses);
1311
1415
  if (options.mode !== "adopt" && state === void 0) continue;
1312
- const source = path5.join(options.skillsDirectory, name);
1416
+ const source = path4.join(options.skillsDirectory, name);
1313
1417
  const sourceHash = bundled.some((skill) => skill.name === name) ? skillCopyHash(source, true) : null;
1314
1418
  if (!sourceHash && options.mode === "adopt") throw new Error("Complete package Skill source is missing.");
1315
1419
  for (const target of targets) {
@@ -1334,7 +1438,7 @@ function syncBusinessSkills(options) {
1334
1438
  }
1335
1439
  const legacyLink2 = node.type === "symlink" ? legacySkillLink(item.path, name, options.skillsDirectory, sourceHash ?? "", targets, ledger, true) : void 0;
1336
1440
  const canonical = targets.find((copy) => copy.agent === "universal");
1337
- const historicalLink = node.type === "symlink" && canonical && directInstallerLink(item.path, path5.join(canonical.directory, name), node.link);
1441
+ const historicalLink = node.type === "symlink" && canonical && directInstallerLink(item.path, path4.join(canonical.directory, name), node.link);
1338
1442
  const historicalCopy = history.names.has(name) && (target.agent === "universal" && node.type !== "symlink" || historicalLink);
1339
1443
  if (!managed && (legacyLink2 || historicalCopy)) {
1340
1444
  ledger.copies[item.path] = {
@@ -1404,7 +1508,7 @@ function syncBusinessSkills(options) {
1404
1508
  if (managed) delete ledger.copies[item.path];
1405
1509
  continue;
1406
1510
  }
1407
- if (actualHash === null && !target.detected && !managed && !fs5.existsSync(target.directory)) continue;
1511
+ if (actualHash === null && !target.detected && !managed && !fs4.existsSync(target.directory)) continue;
1408
1512
  operations.push({
1409
1513
  action: "install",
1410
1514
  skill: name,
@@ -1497,8 +1601,8 @@ function syncRefreshedBusinessSkills(refresh, businesses) {
1497
1601
  if (!Object.keys(states).length) return;
1498
1602
  try {
1499
1603
  const pkg = getLocalCliPackageInfo();
1500
- const options = { ...refresh, skillsDirectory: path6.join(pkg.root, "skills"), businesses: states, packageVersion: pkg.version };
1501
- if (!fs6.existsSync(path6.join(getConfigDir(), "business-skills.json"))) {
1604
+ const options = { ...refresh, skillsDirectory: path5.join(pkg.root, "skills"), businesses: states, packageVersion: pkg.version };
1605
+ if (!fs5.existsSync(path5.join(getConfigDir(), "business-skills.json"))) {
1502
1606
  const adoption = syncBusinessSkills({ ...options, mode: "adopt" });
1503
1607
  if (["failed", "busy", "stale"].includes(adoption.status)) {
1504
1608
  if (adoption.status !== "stale") process.stderr.write("[ae-cli] Skills could not be synchronized. Retry: ae-cli config refresh\n");
@@ -1518,14 +1622,14 @@ function syncRefreshedBusinessSkills(refresh, businesses) {
1518
1622
  var BUSINESS_CONFIG_TTL_MS = 10 * 60 * 1e3;
1519
1623
  var UNAVAILABLE_TTL_MS = 5 * 60 * 1e3;
1520
1624
  function cachePath() {
1521
- return path7.join(getConfigDir(), "business-config.json");
1625
+ return path6.join(getConfigDir(), "business-config.json");
1522
1626
  }
1523
1627
  function cacheKey(host, token) {
1524
1628
  return `${normalizeUrl(host)}#${crypto2.createHash("sha256").update(token).digest("hex")}`;
1525
1629
  }
1526
1630
  function readStore() {
1527
1631
  try {
1528
- const value = JSON.parse(fs7.readFileSync(cachePath(), "utf8"));
1632
+ const value = JSON.parse(fs6.readFileSync(cachePath(), "utf8"));
1529
1633
  if (value?.entries && typeof value.entries === "object" && !Array.isArray(value.entries)) return value;
1530
1634
  } catch {
1531
1635
  }
@@ -1537,13 +1641,13 @@ function remember(host, token, entry) {
1537
1641
  const target = cachePath();
1538
1642
  const temporary = `${target}.${process.pid}.${crypto2.randomBytes(6).toString("hex")}.tmp`;
1539
1643
  try {
1540
- fs7.mkdirSync(path7.dirname(target), { recursive: true });
1541
- fs7.writeFileSync(temporary, JSON.stringify(store), { encoding: "utf8", mode: 384 });
1542
- fs7.renameSync(temporary, target);
1543
- fs7.chmodSync(target, 384);
1644
+ fs6.mkdirSync(path6.dirname(target), { recursive: true });
1645
+ fs6.writeFileSync(temporary, JSON.stringify(store), { encoding: "utf8", mode: 384 });
1646
+ fs6.renameSync(temporary, target);
1647
+ fs6.chmodSync(target, 384);
1544
1648
  } catch {
1545
1649
  try {
1546
- fs7.rmSync(temporary, { force: true });
1650
+ fs6.rmSync(temporary, { force: true });
1547
1651
  } catch {
1548
1652
  }
1549
1653
  }
@@ -1612,7 +1716,7 @@ async function readBusinessConfigForExecution(hostOverride, synchronizeSkills =
1612
1716
  const token = peekCliToken(host);
1613
1717
  if (!token) return {};
1614
1718
  return await resolveBusinessConfig(host, token, async () => {
1615
- const { fetchCliConfig: fetchCliConfig2 } = await import("./compat-check-ZJNCMNQV.js");
1719
+ const { fetchCliConfig: fetchCliConfig2 } = await import("./compat-check-E7AQ7UCG.js");
1616
1720
  return fetchCliConfig2(host, token);
1617
1721
  }, Date.now(), synchronizeSkills);
1618
1722
  } catch {
@@ -1660,7 +1764,7 @@ function failInstallation(report, stage, message, cause = "validation") {
1660
1764
  function installPlan(packageName, version, root = "<npm-root>") {
1661
1765
  const config = distribution(packageName);
1662
1766
  const target = exactVersion(version);
1663
- const executable = path8.join(root, packageName, "bin", "ae-cli.js");
1767
+ const executable = path7.join(root, packageName, "bin", "ae-cli.js");
1664
1768
  return [
1665
1769
  `npm install -g ${packageName}@${target} --registry=${config.registry}`,
1666
1770
  `node ${JSON.stringify(executable)} install`
@@ -1680,27 +1784,27 @@ function skipGlobalSkillReason() {
1680
1784
  }
1681
1785
  function readPackage(root) {
1682
1786
  try {
1683
- return JSON.parse(fs8.readFileSync(path8.join(root, "package.json"), "utf8"));
1787
+ return JSON.parse(fs7.readFileSync(path7.join(root, "package.json"), "utf8"));
1684
1788
  } catch {
1685
1789
  return null;
1686
1790
  }
1687
1791
  }
1688
1792
  function linked(root) {
1689
1793
  try {
1690
- return fs8.lstatSync(root).isSymbolicLink();
1794
+ return fs7.lstatSync(root).isSymbolicLink();
1691
1795
  } catch {
1692
1796
  return false;
1693
1797
  }
1694
1798
  }
1695
1799
  function cliBinBelongsToPackage(bin, packageRoot, platform) {
1696
- const entry = fs8.realpathSync(path8.join(packageRoot, "bin", "ae-cli.js"));
1697
- if (platform !== "win32") return fs8.realpathSync(bin) === entry;
1698
- const shim = fs8.readFileSync(bin, "utf8");
1800
+ const entry = fs7.realpathSync(path7.join(packageRoot, "bin", "ae-cli.js"));
1801
+ if (platform !== "win32") return fs7.realpathSync(bin) === entry;
1802
+ const shim = fs7.readFileSync(bin, "utf8");
1699
1803
  const targets = [...shim.matchAll(/"%(?:dp0%|~dp0)[\\/]([^"\r\n]+)"/gi)];
1700
1804
  return targets.some(([, relative]) => {
1701
1805
  try {
1702
- const target = path8.resolve(path8.dirname(bin), relative.replace(/\\/g, path8.sep));
1703
- return fs8.realpathSync(target).toLowerCase() === entry.toLowerCase();
1806
+ const target = path7.resolve(path7.dirname(bin), relative.replace(/\\/g, path7.sep));
1807
+ return fs7.realpathSync(target).toLowerCase() === entry.toLowerCase();
1704
1808
  } catch {
1705
1809
  return false;
1706
1810
  }
@@ -1741,9 +1845,9 @@ function runInstallation(options = {}) {
1741
1845
  const prefixResult = runner(npm, ["prefix", "-g"], 15e3);
1742
1846
  const globalRoot = rootResult.stdout.trim();
1743
1847
  const prefix = prefixResult.stdout.trim();
1744
- if (!commandSucceeded(rootResult) || !commandSucceeded(prefixResult) || !path8.isAbsolute(globalRoot) || !path8.isAbsolute(prefix) || /[\r\n]/.test(globalRoot + prefix)) return failInstallation(report, stage, "Cannot resolve npm global root and prefix. Check npm configuration.");
1745
- const packageRoot = path8.join(globalRoot, packageName);
1746
- const bin = platform === "win32" ? path8.join(prefix, "ae-cli.cmd") : path8.join(prefix, "bin", "ae-cli");
1848
+ if (!commandSucceeded(rootResult) || !commandSucceeded(prefixResult) || !path7.isAbsolute(globalRoot) || !path7.isAbsolute(prefix) || /[\r\n]/.test(globalRoot + prefix)) return failInstallation(report, stage, "Cannot resolve npm global root and prefix. Check npm configuration.");
1849
+ const packageRoot = path7.join(globalRoot, packageName);
1850
+ const bin = platform === "win32" ? path7.join(prefix, "ae-cli.cmd") : path7.join(prefix, "bin", "ae-cli");
1747
1851
  report.cli.path = bin;
1748
1852
  const env = options.env ?? process.env;
1749
1853
  const installedBefore = readPackage(packageRoot);
@@ -1766,10 +1870,10 @@ function runInstallation(options = {}) {
1766
1870
  };
1767
1871
  const generation = reserveBusinessSkillContext({ ...identity, stateDirectory });
1768
1872
  context = { ...identity, stateDirectory, generation, isCurrentContext };
1769
- if (!fs8.existsSync(path8.join(stateDirectory, "business-skills.json")) && installedBefore?.name === packageName) {
1770
- const previousSkills = path8.join(packageRoot, "skills");
1873
+ if (!fs7.existsSync(path7.join(stateDirectory, "business-skills.json")) && installedBefore?.name === packageName) {
1874
+ const previousSkills = path7.join(packageRoot, "skills");
1771
1875
  try {
1772
- readBundledSkills(previousSkills);
1876
+ readInstallableSkills(previousSkills);
1773
1877
  syncSkills({ ...context, skillsDirectory: previousSkills, businesses: {}, mode: "adopt", packageVersion: installedBefore.version });
1774
1878
  } catch {
1775
1879
  report.next_steps.push("Existing Skills could not be adopted from the previous package; unmatched copies will be preserved.");
@@ -1779,7 +1883,7 @@ function runInstallation(options = {}) {
1779
1883
  return failInstallation(report, "skills_local", "The active environment changed before installation. Re-run install or update for the current environment.");
1780
1884
  }
1781
1885
  }
1782
- if (options.skipCliInstall || installedBefore?.name === packageName && installedBefore.version === target && fs8.existsSync(bin)) {
1886
+ if (options.skipCliInstall || installedBefore?.name === packageName && installedBefore.version === target && fs7.existsSync(bin)) {
1783
1887
  report.cli.action = "skipped";
1784
1888
  progress("[ae-cli] [2/4] Verifying the existing CLI...");
1785
1889
  } else {
@@ -1792,16 +1896,16 @@ function runInstallation(options = {}) {
1792
1896
  stage = "package_validation";
1793
1897
  const installed = readPackage(packageRoot);
1794
1898
  if (installed?.name !== packageName || installed.version !== target) return failInstallation(report, stage, "Installed CLI package identity or version does not match the requested distribution.");
1795
- if (!fs8.existsSync(bin)) return failInstallation(report, stage, "npm did not create the global ae-cli executable. Enable npm bin-links, reinstall, and add the global executable directory to PATH.");
1899
+ if (!fs7.existsSync(bin)) return failInstallation(report, stage, "npm did not create the global ae-cli executable. Enable npm bin-links, reinstall, and add the global executable directory to PATH.");
1796
1900
  if (!cliBinBelongsToPackage(bin, packageRoot, platform)) return failInstallation(report, stage, "The global executable does not belong to the installed CLI package.");
1797
1901
  const versionResult = runner(bin, ["--version"], 15e3);
1798
1902
  if (!commandSucceeded(versionResult) || versionResult.stdout.trim() !== target) return failInstallation(report, stage, "ae-cli --version did not return the requested version. Refresh the shell command cache and check npm bin links.");
1799
- report.cli.entrypoint = fs8.realpathSync(path8.join(packageRoot, "bin", "ae-cli.js"));
1903
+ report.cli.entrypoint = fs7.realpathSync(path7.join(packageRoot, "bin", "ae-cli.js"));
1800
1904
  report.cli.verified = true;
1801
1905
  const pathKey = platform === "win32" ? Object.keys(env).find((key) => key.toLowerCase() === "path") : "PATH";
1802
- const installedPathBin = (env[pathKey ?? "PATH"] ?? "").split(platform === "win32" ? ";" : path8.delimiter).filter(Boolean).map((dir) => path8.join(dir.replace(/^"(.*)"$/, "$1"), platform === "win32" ? "ae-cli.cmd" : "ae-cli")).find((file) => fs8.existsSync(file) && !file.includes(`${path8.sep}_npx${path8.sep}`));
1803
- if (!installedPathBin || fs8.realpathSync(installedPathBin) !== fs8.realpathSync(bin)) {
1804
- report.cli.warnings.push(`Add ${path8.dirname(bin)} to the front of PATH and refresh the shell command cache. The absolute executable was verified.`);
1906
+ const installedPathBin = (env[pathKey ?? "PATH"] ?? "").split(platform === "win32" ? ";" : path7.delimiter).filter(Boolean).map((dir) => path7.join(dir.replace(/^"(.*)"$/, "$1"), platform === "win32" ? "ae-cli.cmd" : "ae-cli")).find((file) => fs7.existsSync(file) && !file.includes(`${path7.sep}_npx${path7.sep}`));
1907
+ if (!installedPathBin || fs7.realpathSync(installedPathBin) !== fs7.realpathSync(bin)) {
1908
+ report.cli.warnings.push(`Add ${path7.dirname(bin)} to the front of PATH and refresh the shell command cache. The absolute executable was verified.`);
1805
1909
  report.next_steps.push(`Use the verified executable at ${bin}, or correct PATH before invoking ae-cli.`);
1806
1910
  }
1807
1911
  if (skipSkills) {
@@ -1810,8 +1914,8 @@ function runInstallation(options = {}) {
1810
1914
  progress(`[ae-cli] [3/4] ${skipSkills}`);
1811
1915
  } else if (context) {
1812
1916
  stage = "skills_local";
1813
- const skillsPath = path8.join(packageRoot, "skills");
1814
- const skills = readBundledSkills(skillsPath);
1917
+ const skillsPath = path7.join(packageRoot, "skills");
1918
+ const skills = readInstallableSkills(skillsPath);
1815
1919
  if (!isBusinessSkillContextCurrent(context)) {
1816
1920
  return failInstallation(report, stage, "The active environment changed during CLI installation. Re-run install or update to synchronize its Skills.");
1817
1921
  }
@@ -1844,6 +1948,14 @@ function runInstallation(options = {}) {
1844
1948
  }
1845
1949
  }
1846
1950
  progress("[ae-cli] [4/4] Checking authentication guidance...");
1951
+ const guideAccountSetup = options.guideAccountSetup && report.skills.status === "success";
1952
+ if (guideAccountSetup && !report.auth.host && context?.host) {
1953
+ try {
1954
+ report.auth.host = installHost(context.host);
1955
+ } catch {
1956
+ report.auth.warnings.push("The configured AE host could not be used to check authentication.");
1957
+ }
1958
+ }
1847
1959
  if (report.auth.host) {
1848
1960
  const result2 = runner(bin, ["--no-update-check", "--format", "json", "auth", "status", "--host", report.auth.host], INSTALL_TIMEOUT_MS);
1849
1961
  try {
@@ -1854,9 +1966,44 @@ function runInstallation(options = {}) {
1854
1966
  report.auth.warnings.push("Authentication status could not be verified. Run auth status for this host.");
1855
1967
  }
1856
1968
  }
1857
- if (report.auth.authenticated !== true) {
1969
+ if (options.guideAccountSetup && !guideAccountSetup) {
1970
+ report.ok = true;
1971
+ return report;
1972
+ }
1973
+ const language = registrationLanguage(void 0, env);
1974
+ const market = registrationMarket(language);
1975
+ const websiteOnboarding = isWebsiteMarket(market);
1976
+ if (guideAccountSetup) {
1977
+ if (report.auth.authenticated === true) report.next_action = "continue_using_ae";
1978
+ else if (report.auth.warnings.length > 0) report.next_action = "check_authentication";
1979
+ else if (websiteOnboarding) report.next_action = "choose_account";
1980
+ }
1981
+ if (report.auth.authenticated === true) {
1982
+ report.next_steps.push("You are signed in. Continue your AE task in this AI tool using the existing environment.");
1983
+ } else if (report.next_action === "check_authentication") {
1984
+ const hostOption = report.auth.host ? ` --host ${report.auth.host}` : "";
1985
+ report.next_steps.push(`Check the configured AE environment with ae-cli auth status${hostOption} --format json. If it still cannot be verified, confirm the intended environment before starting signup or login.`);
1986
+ } else {
1987
+ const chooseAccount = report.next_action === "choose_account";
1988
+ if (chooseAccount) {
1989
+ report.next_steps.push("For an install-only request, report the verified result. If the user explicitly asked for AE onboarding, the new-user walkthrough, or signup, run the website onboarding command below in the same turn. If they asked to sign in to an existing account, follow the existing-account guidance below. Use the account picker only when the user wants to get started and has not chosen a route: offer \u201CCreate an account and get started\u201D and \u201CSign in to my existing account\u201D.");
1990
+ }
1991
+ if (websiteOnboarding && (chooseAccount || !report.auth.host)) {
1992
+ const source = cliEntrySource(void 0, env);
1993
+ const registration = aeRegistrationUrl(language, env, source);
1994
+ if (chooseAccount) {
1995
+ report.next_steps.push(`For website onboarding, run ae-cli analysis onboarding run --language ${language} --source ${source} --browser system --format json. Pass --region for the user's requested market. The CLI opens the system default browser. If it cannot open the page, share the returned login_url for that browser. Read the returned skill_path and continue with its session_id. For manual signup outside the guided session, use ${registration}.`);
1996
+ } else {
1997
+ report.next_steps.push(`New or returning website users: for guided website verification, run ae-cli analysis onboarding run --language ${language} --source ${source} --browser system. For manual registration or sign-in, use ${registration} in the system default browser.`);
1998
+ }
1999
+ report.next_steps.push(`The default new-account region is ${market}. Select another supported production market with --region jp|kr|us before registration. Language does not change an existing account's environment.`);
2000
+ } else if (!websiteOnboarding && !report.auth.host) {
2001
+ report.next_steps.push(`To request an AE trial in China, visit ${aeRegistrationUrl(language, env)}.`);
2002
+ }
2003
+ if (chooseAccount) report.next_steps.push("Existing AE users: confirm their original AE environment URL and use it for login. Ask for that URL if it is unknown.");
2004
+ else if (!report.auth.host) report.next_steps.push("Existing AE users: use your original environment URL, or ask your administrator.");
1858
2005
  report.next_steps.push(`ae-cli auth login --host ${report.auth.host ?? "<AE_HOST>"} --no-wait`);
1859
- report.next_steps.push("Complete browser authorization, then run ae-cli auth login --host <AE_HOST> --device-code <DEVICE_CODE>.");
2006
+ report.next_steps.push("Complete browser authorization, then resume the same login using its returned host and device code. Keep the private device code local.");
1860
2007
  }
1861
2008
  report.ok = true;
1862
2009
  return report;
@@ -1873,14 +2020,14 @@ var LOCK_STALE_MS = 10 * 60 * 1e3;
1873
2020
  var SYNC_STATE_FILE = "version-sync.json";
1874
2021
  var SYNC_LOCK_FILE = "version-sync.lock";
1875
2022
  function syncStatePath() {
1876
- return path9.join(getConfigDir(), SYNC_STATE_FILE);
2023
+ return path8.join(getConfigDir(), SYNC_STATE_FILE);
1877
2024
  }
1878
2025
  function syncLockPath() {
1879
- return path9.join(getConfigDir(), SYNC_LOCK_FILE);
2026
+ return path8.join(getConfigDir(), SYNC_LOCK_FILE);
1880
2027
  }
1881
2028
  function readSyncStore() {
1882
2029
  try {
1883
- const raw = JSON.parse(fs9.readFileSync(syncStatePath(), "utf8"));
2030
+ const raw = JSON.parse(fs8.readFileSync(syncStatePath(), "utf8"));
1884
2031
  if (raw && typeof raw === "object" && raw.hosts && typeof raw.hosts === "object") {
1885
2032
  return raw;
1886
2033
  }
@@ -1890,8 +2037,8 @@ function readSyncStore() {
1890
2037
  }
1891
2038
  function writeSyncStore(store) {
1892
2039
  try {
1893
- fs9.mkdirSync(getConfigDir(), { recursive: true });
1894
- fs9.writeFileSync(syncStatePath(), JSON.stringify(store, null, 2));
2040
+ fs8.mkdirSync(getConfigDir(), { recursive: true });
2041
+ fs8.writeFileSync(syncStatePath(), JSON.stringify(store, null, 2));
1895
2042
  } catch {
1896
2043
  }
1897
2044
  }
@@ -1995,20 +2142,20 @@ function friendlyVersionSyncFailure(result2) {
1995
2142
  return `Version synchronization failed at ${result2.stage}.`;
1996
2143
  }
1997
2144
  function acquireInstallLock(now) {
1998
- fs9.mkdirSync(getConfigDir(), { recursive: true });
2145
+ fs8.mkdirSync(getConfigDir(), { recursive: true });
1999
2146
  const file = syncLockPath();
2000
2147
  try {
2001
- return fs9.openSync(file, "wx");
2148
+ return fs8.openSync(file, "wx");
2002
2149
  } catch {
2003
2150
  try {
2004
- const age = now.getTime() - fs9.statSync(file).mtimeMs;
2151
+ const age = now.getTime() - fs8.statSync(file).mtimeMs;
2005
2152
  if (age >= LOCK_STALE_MS) {
2006
- fs9.unlinkSync(file);
2007
- return fs9.openSync(file, "wx");
2153
+ fs8.unlinkSync(file);
2154
+ return fs8.openSync(file, "wx");
2008
2155
  }
2009
2156
  } catch {
2010
2157
  try {
2011
- return fs9.openSync(file, "wx");
2158
+ return fs8.openSync(file, "wx");
2012
2159
  } catch {
2013
2160
  return null;
2014
2161
  }
@@ -2018,11 +2165,11 @@ function acquireInstallLock(now) {
2018
2165
  }
2019
2166
  function releaseInstallLock(fd) {
2020
2167
  try {
2021
- fs9.closeSync(fd);
2168
+ fs8.closeSync(fd);
2022
2169
  } catch {
2023
2170
  }
2024
2171
  try {
2025
- fs9.unlinkSync(syncLockPath());
2172
+ fs8.unlinkSync(syncLockPath());
2026
2173
  } catch {
2027
2174
  }
2028
2175
  }
@@ -2084,12 +2231,12 @@ function autoSyncDirection(current, expected) {
2084
2231
 
2085
2232
  // src/core/feature-config.ts
2086
2233
  import crypto4 from "crypto";
2087
- import fs10 from "fs";
2088
- import path10 from "path";
2234
+ import fs9 from "fs";
2235
+ import path9 from "path";
2089
2236
  var FEATURE_TTL_MS = 24 * 60 * 60 * 1e3;
2090
2237
  var UNAVAILABLE_TTL_MS2 = 5 * 60 * 1e3;
2091
2238
  function cachePath2() {
2092
- return path10.join(getConfigDir(), "feature-config.json");
2239
+ return path9.join(getConfigDir(), "feature-config.json");
2093
2240
  }
2094
2241
  function cacheKey2(host, token) {
2095
2242
  const fingerprint = crypto4.createHash("sha256").update(token).digest("hex");
@@ -2097,7 +2244,7 @@ function cacheKey2(host, token) {
2097
2244
  }
2098
2245
  function readStore2() {
2099
2246
  try {
2100
- const value = JSON.parse(fs10.readFileSync(cachePath2(), "utf8"));
2247
+ const value = JSON.parse(fs9.readFileSync(cachePath2(), "utf8"));
2101
2248
  return value?.entries && typeof value.entries === "object" ? value : { entries: {} };
2102
2249
  } catch {
2103
2250
  return { entries: {} };
@@ -2107,13 +2254,13 @@ function writeStore(store) {
2107
2254
  const target = cachePath2();
2108
2255
  const temp = `${target}.${process.pid}.${crypto4.randomBytes(6).toString("hex")}.tmp`;
2109
2256
  try {
2110
- fs10.mkdirSync(path10.dirname(target), { recursive: true });
2111
- fs10.writeFileSync(temp, JSON.stringify(store), { encoding: "utf8", mode: 384 });
2112
- fs10.renameSync(temp, target);
2113
- fs10.chmodSync(target, 384);
2257
+ fs9.mkdirSync(path9.dirname(target), { recursive: true });
2258
+ fs9.writeFileSync(temp, JSON.stringify(store), { encoding: "utf8", mode: 384 });
2259
+ fs9.renameSync(temp, target);
2260
+ fs9.chmodSync(target, 384);
2114
2261
  } catch {
2115
2262
  try {
2116
- fs10.rmSync(temp, { force: true });
2263
+ fs9.rmSync(temp, { force: true });
2117
2264
  } catch {
2118
2265
  }
2119
2266
  }
@@ -2160,13 +2307,13 @@ var NOTIFY_INTERVAL_MS = 24 * 60 * 60 * 1e3;
2160
2307
  var FETCH_TIMEOUT_MS = 3e3;
2161
2308
  var CLI_CONFIG_PATH = "/v1/ta/cli/config";
2162
2309
  function cacheFilePath() {
2163
- return path11.join(getConfigDir(), "compat-check.json");
2310
+ return path10.join(getConfigDir(), "compat-check.json");
2164
2311
  }
2165
2312
  function readStore3() {
2166
2313
  try {
2167
2314
  const file = cacheFilePath();
2168
- if (!fs11.existsSync(file)) return { hosts: {} };
2169
- const raw = JSON.parse(fs11.readFileSync(file, "utf8"));
2315
+ if (!fs10.existsSync(file)) return { hosts: {} };
2316
+ const raw = JSON.parse(fs10.readFileSync(file, "utf8"));
2170
2317
  if (!raw || typeof raw !== "object" || !raw.hosts) return { hosts: {} };
2171
2318
  return raw;
2172
2319
  } catch {
@@ -2176,8 +2323,8 @@ function readStore3() {
2176
2323
  function writeStore2(store) {
2177
2324
  try {
2178
2325
  const dir = getConfigDir();
2179
- if (!fs11.existsSync(dir)) fs11.mkdirSync(dir, { recursive: true });
2180
- fs11.writeFileSync(cacheFilePath(), JSON.stringify(store, null, 2));
2326
+ if (!fs10.existsSync(dir)) fs10.mkdirSync(dir, { recursive: true });
2327
+ fs10.writeFileSync(cacheFilePath(), JSON.stringify(store, null, 2));
2181
2328
  } catch {
2182
2329
  }
2183
2330
  }
@@ -2218,7 +2365,7 @@ function shouldSkipAutoSync(argv = process.argv) {
2218
2365
  const command = rootCommand(argv);
2219
2366
  return command === "update" || command === "install" || command === "auth" || command === "config";
2220
2367
  }
2221
- async function fetchCliConfig(host, cliToken) {
2368
+ async function fetchCliConfig(host, cliToken, signal) {
2222
2369
  const url = new URL(CLI_CONFIG_PATH, host.endsWith("/") ? host : `${host}/`);
2223
2370
  const external = readExternalCliToken(host)?.token === cliToken;
2224
2371
  if (!external) url.searchParams.set("cli-token", cliToken);
@@ -2227,6 +2374,12 @@ async function fetchCliConfig(host, cliToken) {
2227
2374
  let cleanup;
2228
2375
  const destroy = () => cleanup ??= dispatcher.destroy().catch(() => {
2229
2376
  });
2377
+ const abort = () => {
2378
+ controller.abort();
2379
+ void destroy();
2380
+ };
2381
+ signal?.addEventListener("abort", abort, { once: true });
2382
+ if (signal?.aborted) abort();
2230
2383
  const timer = setTimeout(() => {
2231
2384
  controller.abort();
2232
2385
  void destroy();
@@ -2236,8 +2389,9 @@ async function fetchCliConfig(host, cliToken) {
2236
2389
  const options = {
2237
2390
  dispatcher,
2238
2391
  signal: controller.signal,
2239
- headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {} },
2240
- ...externalCliTokenRequestOptions(url.toString())
2392
+ headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {}, ...internalCallSourceHeaders() },
2393
+ ...externalCliTokenRequestOptions(url.toString()),
2394
+ ...signal ? { redirect: "error" } : {}
2241
2395
  };
2242
2396
  resp = await fetch(url.toString(), options);
2243
2397
  if (!resp.ok) return null;
@@ -2254,8 +2408,10 @@ async function fetchCliConfig(host, cliToken) {
2254
2408
  ...typeof data.features?.projectSemanticKbAutoDiscovery === "boolean" ? { projectSemanticKbAutoDiscovery: data.features.projectSemanticKbAutoDiscovery } : {}
2255
2409
  };
2256
2410
  } catch {
2411
+ signal?.throwIfAborted();
2257
2412
  return null;
2258
2413
  } finally {
2414
+ signal?.removeEventListener("abort", abort);
2259
2415
  clearTimeout(timer);
2260
2416
  const destroyed = destroy();
2261
2417
  if (resp?.body && !resp.bodyUsed) await Promise.allSettled([resp.body.cancel(), destroyed]);
@@ -2502,7 +2658,29 @@ function notifyIfHostCompat(pkg, hostOverride) {
2502
2658
  export {
2503
2659
  exactVersion,
2504
2660
  installHost,
2505
- getLocalCliPackageInfo,
2661
+ DEMO_CONTEXT,
2662
+ DEMO_ENSURE,
2663
+ DEMO_STATUS,
2664
+ RUN_BUDGET_MS,
2665
+ NETWORK_BUDGET_MS,
2666
+ UUID_PATTERN,
2667
+ DEMO_SAMPLE_IDS,
2668
+ CHECKOUT_RECOVERY,
2669
+ onboardingGrowthScenario,
2670
+ WEBSITE_MARKETS,
2671
+ websiteEnvironment,
2672
+ websiteOrigin,
2673
+ isProductionWebsiteOrigin,
2674
+ environmentForWebsiteOrigin,
2675
+ cliEntrySource,
2676
+ withCliEntryContext,
2677
+ normalizeRegistrationLanguage,
2678
+ registrationLanguage,
2679
+ registrationMarket,
2680
+ aeRegistrationUrl,
2681
+ AE_TRIAL_URL,
2682
+ missingAeHostHint,
2683
+ missingAeHostGuidance,
2506
2684
  businessForCommand,
2507
2685
  businessForCapability,
2508
2686
  canManageGlobalSkills,