@thinkingai/ae-cli 6.0.60 → 6.0.62

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 (221) hide show
  1. package/README.md +6 -1
  2. package/README.zh.md +8 -1
  3. package/bin/runtime-capabilities.json +1 -1
  4. package/dist/{ai-monitor-FCXSLHAP.js → ai-monitor-X5GL44JT.js} +10 -9
  5. package/dist/ai-monitor.js +14 -13
  6. package/dist/{auth-ATK2SLEV.js → auth-SPQ46XQ3.js} +18 -10
  7. package/dist/{automation-FLCPFMN4.js → automation-7XC3VBZI.js} +87 -12
  8. package/dist/{capability-6KTSOI7L.js → capability-JZP4KXZC.js} +10 -9
  9. package/dist/{chunk-OAWPT7VP.js → chunk-2I5SZ5DS.js} +2 -2
  10. package/dist/{chunk-VRMGHQKE.js → chunk-2VKMHNUU.js} +11 -11
  11. package/dist/{chunk-2ETRY2CU.js → chunk-6HOM2FOJ.js} +19 -9
  12. package/dist/{chunk-KTJXD27G.js → chunk-AAN6KBUK.js} +3 -3
  13. package/dist/{chunk-4PSTYEG5.js → chunk-AMURHMS3.js} +11 -7
  14. package/dist/{chunk-6M7ZEDT2.js → chunk-BQFLABJQ.js} +11 -7
  15. package/dist/{chunk-BEYLCUZX.js → chunk-E457FREE.js} +3 -3
  16. package/dist/{chunk-CF6JTT2U.js → chunk-EFGUBGA6.js} +1 -1
  17. package/dist/{chunk-5M5LBRR3.js → chunk-ETQXIZFP.js} +15 -8
  18. package/dist/{chunk-72NJKS7O.js → chunk-F36ORPI6.js} +7 -32
  19. package/dist/{chunk-5E7MTTFN.js → chunk-F7TCQPQX.js} +23 -9
  20. package/dist/{chunk-AXTO4FTM.js → chunk-FGGEF7MI.js} +3 -3
  21. package/dist/{chunk-JEUXDY3B.js → chunk-HQED4YB4.js} +1 -1
  22. package/dist/{chunk-2F64AZYH.js → chunk-KA5WKR5P.js} +2 -2
  23. package/dist/{chunk-P7QDCWJ6.js → chunk-LFJ7N36I.js} +5 -1
  24. package/dist/chunk-N2MAYIRU.js +32 -0
  25. package/dist/chunk-NNK3JBH4.js +60 -0
  26. package/dist/{chunk-HTZ2MLYA.js → chunk-PLNS5J33.js} +11 -5
  27. package/dist/{chunk-HSZAIPUX.js → chunk-PRCHMOWT.js} +7 -5
  28. package/dist/chunk-PUSFEC6B.js +29 -0
  29. package/dist/{chunk-Z3Q2AEIN.js → chunk-R2SVAO4G.js} +14 -2
  30. package/dist/{chunk-SDKW6LYE.js → chunk-RYY5NJK3.js} +3 -3
  31. package/dist/{chunk-QVRIDN42.js → chunk-UCMO4LKL.js} +2 -2
  32. package/dist/{chunk-VJUXKVRE.js → chunk-VR2D54AA.js} +2 -2
  33. package/dist/{chunk-HVMCPKOZ.js → chunk-YIG3L4RC.js} +1 -1
  34. package/dist/{chunk-LOR4IA26.js → chunk-YJYC5PLL.js} +166 -188
  35. package/dist/{chunk-F2VFZUGG.js → chunk-ZVUXAHEV.js} +2 -2
  36. package/dist/{community-report-client-TJVCLZ3K.js → community-report-client-ULRNXLQV.js} +1 -1
  37. package/dist/{compat-check-XD2U7PZ2.js → compat-check-JD5D77ET.js} +5 -4
  38. package/dist/{config-U3GDWU6E.js → config-IIMRATTP.js} +7 -6
  39. package/dist/{context-YAQG6YQC.js → context-BXHIPIIX.js} +8 -6
  40. package/dist/{data-integration-QE37EQ3A.js → data-integration-VRJQ3HVK.js} +7 -6
  41. package/dist/{evaluation-2JSF4V47.js → evaluation-Q3AIGFOG.js} +5 -5
  42. package/dist/index.js +49 -43
  43. package/dist/{local-data-upload-client-KCMG6J62.js → local-data-upload-client-YTWMAAGE.js} +1 -1
  44. package/dist/{memory-WEB27VI6.js → memory-B44LY27L.js} +6 -7
  45. package/dist/{metadata-7FYE4234.js → metadata-ZVPG2MIA.js} +10 -9
  46. package/dist/{model-T7H7Q6BG.js → model-ANZBYVST.js} +4 -5
  47. package/dist/{personal-semantic-preference-O6VXM74A.js → personal-semantic-preference-YNCV4QG3.js} +45 -14
  48. package/dist/{project-semantic-2GGFJWW6.js → project-semantic-E7ZAQL5S.js} +9 -8
  49. package/dist/{sync-ULBB7WO5.js → sync-Y4OZRQAY.js} +9 -9
  50. package/dist/{te-agent-6RMF7LUV.js → te-agent-RKAUTYJZ.js} +303 -17
  51. package/dist/{te-analysis-HSYC7GNV.js → te-analysis-7N5VC4JB.js} +25 -20
  52. package/dist/{te-community-FLKZGQKB.js → te-community-SIA2UHTS.js} +13 -11
  53. package/dist/{te-dataops-OQQGTCUA.js → te-dataops-5MJQCODU.js} +13 -11
  54. package/dist/{te-engage-RIEBHL5T.js → te-engage-ZTLOMKO3.js} +73 -20
  55. package/dist/{te-kb-4HG2FMHJ.js → te-kb-LDL3MF2Y.js} +107 -25
  56. package/dist/{te-system-AL4B4XZL.js → te-system-473I5O53.js} +6 -7
  57. package/dist/{te-team-5O4UVUWE.js → te-team-JOWHCMZA.js} +92 -10
  58. package/dist/{things-TSJ64GBT.js → things-DOQ2L3O2.js} +9 -8
  59. package/dist/{update-Q5LURAWV.js → update-KUS6TCPB.js} +8 -6
  60. package/dist/{workspace-FF2HXJGR.js → workspace-MJFPIV7C.js} +6 -7
  61. package/package.json +6 -3
  62. package/skills/ae-agent/SKILL.md +19 -5
  63. package/skills/ae-agent/references/a2a.md +103 -0
  64. package/skills/ae-agent/references/command_index.md +11 -0
  65. package/skills/ae-analysis/SKILL.md +35 -23
  66. package/skills/ae-analysis/references/analysis_data_retrieval.md +1 -1
  67. package/skills/ae-analysis/references/asset_authentication_export.md +1 -1
  68. package/skills/ae-analysis/references/asset_authentication_update.md +6 -2
  69. package/skills/ae-analysis/references/bad_case_review.md +4 -4
  70. package/skills/ae-analysis/references/command_index.md +7 -7
  71. package/skills/ae-analysis/references/governance_recommendation_export.md +2 -2
  72. package/skills/ae-analysis/references/personal_semantic_preference_add.md +9 -1
  73. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +2 -0
  74. package/skills/ae-analysis/references/personal_semantic_preference_get.md +2 -0
  75. package/skills/ae-analysis/references/personal_semantic_preference_list.md +10 -2
  76. package/skills/ae-analysis/references/personal_semantic_preference_update.md +8 -0
  77. package/skills/ae-analysis/references/project_owner_update.md +5 -1
  78. package/skills/ae-analysis/references/scenario_evaluation.md +17 -1
  79. package/skills/ae-analysis/references/scenario_list.md +5 -6
  80. package/skills/ae-automation/SKILL.md +6 -2
  81. package/skills/ae-automation/references/cli.md +9 -3
  82. package/skills/ae-capability/SKILL.md +8 -4
  83. package/skills/ae-engage/SKILL.md +6 -1
  84. package/skills/ae-engage/references/common-metric.md +47 -1
  85. package/skills/ae-engage/references/flow-metric-update.md +1 -1
  86. package/skills/ae-engage/references/task-metric-update.md +1 -1
  87. package/skills/ae-kb/SKILL.md +11 -7
  88. package/skills/ae-kb/references/publication.md +45 -0
  89. package/skills/ae-kb/references/query-workflow.md +5 -1
  90. package/skills/ae-team/SKILL.md +7 -3
  91. package/skills/ae-team/references/copy-to-personal.md +7 -0
  92. package/skills/ae-team/references/promote.md +7 -0
  93. package/skills/ae-team/references/update.md +3 -3
  94. package/dist/chunk-Y74WTIKJ.js +0 -10
  95. package/skills/ae-tracking-matrix/SKILL.md +0 -170
  96. package/skills/ae-tracking-matrix/assets//345/237/213/347/202/271/346/250/241/347/211/210.xlsx +0 -0
  97. package/skills/ae-tracking-matrix/i18n.yaml +0 -12
  98. package/skills/ae-tracking-matrix/references/ae-capabilities.md +0 -93
  99. package/skills/ae-tracking-matrix/references/business-semantic-checks.md +0 -30
  100. package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +0 -256
  101. package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +0 -213
  102. package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +0 -407
  103. package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +0 -218
  104. package/skills/ae-tracking-matrix/references/categories/casual_music.md +0 -112
  105. package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +0 -301
  106. package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +0 -356
  107. package/skills/ae-tracking-matrix/references/categories/fishing.md +0 -775
  108. package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +0 -89
  109. package/skills/ae-tracking-matrix/references/categories/idle_card.md +0 -27
  110. package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +0 -415
  111. package/skills/ae-tracking-matrix/references/categories/interactive_video.md +0 -133
  112. package/skills/ae-tracking-matrix/references/categories/merge.md +0 -639
  113. package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +0 -406
  114. package/skills/ae-tracking-matrix/references/categories/mmo_web.md +0 -230
  115. package/skills/ae-tracking-matrix/references/categories/music.md +0 -137
  116. package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +0 -414
  117. package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +0 -199
  118. package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +0 -158
  119. package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +0 -546
  120. package/skills/ae-tracking-matrix/references/categories/rpg.md +0 -195
  121. package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +0 -115
  122. package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +0 -151
  123. package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +0 -260
  124. package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +0 -232
  125. package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +0 -359
  126. package/skills/ae-tracking-matrix/references/categories/tower_defense.md +0 -365
  127. package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +0 -211
  128. package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +0 -132
  129. package/skills/ae-tracking-matrix/references/category-registry.md +0 -77
  130. package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +0 -230
  131. package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +0 -406
  132. package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +0 -128
  133. package/skills/ae-tracking-matrix/references/eval-cases.md +0 -74
  134. package/skills/ae-tracking-matrix/references/naming-dict.md +0 -238
  135. package/skills/ae-tracking-matrix/references/optimization-checklist.md +0 -85
  136. package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +0 -142
  137. package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +0 -47
  138. package/skills/ae-tracking-matrix/references/plan-generation/reference.md +0 -794
  139. package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +0 -94
  140. package/skills/ae-tracking-matrix/references/scene-routing.md +0 -80
  141. package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +0 -3787
  142. package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +0 -827
  143. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +0 -655
  144. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +0 -953
  145. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +0 -1128
  146. package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +0 -714
  147. package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +0 -1268
  148. package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +0 -776
  149. package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +0 -182
  150. package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +0 -2755
  151. package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +0 -1182
  152. package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +0 -1300
  153. package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +0 -1369
  154. package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +0 -1692
  155. package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +0 -902
  156. package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +0 -763
  157. package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +0 -1107
  158. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +0 -1532
  159. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +0 -845
  160. package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +0 -228
  161. package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +0 -149
  162. package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +0 -407
  163. package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +0 -163
  164. package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +0 -149
  165. package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +0 -153
  166. package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +0 -232
  167. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +0 -314
  168. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +0 -117
  169. package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +0 -148
  170. package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +0 -645
  171. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +0 -307
  172. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +0 -347
  173. package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +0 -72
  174. package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +0 -264
  175. package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +0 -566
  176. package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +0 -409
  177. package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +0 -446
  178. package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +0 -557
  179. package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +0 -457
  180. package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +0 -490
  181. package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +0 -523
  182. package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +0 -484
  183. package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +0 -442
  184. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +0 -391
  185. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +0 -91
  186. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +0 -635
  187. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +0 -113
  188. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +0 -466
  189. package/skills/ae-tracking-matrix/references/standard-base/README.md +0 -22
  190. package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +0 -174
  191. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +0 -20
  192. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +0 -7
  193. package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +0 -14
  194. package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +0 -370
  195. package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +0 -47
  196. package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +0 -37
  197. package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +0 -27
  198. package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +0 -23
  199. package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +0 -14
  200. package/skills/ae-tracking-matrix/references/standard-base/user_data.md +0 -46
  201. package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +0 -13
  202. package/skills/ae-tracking-matrix/references/system-fields.md +0 -297
  203. package/skills/ae-tracking-matrix/references/te-field-translations.md +0 -1791
  204. package/skills/ae-tracking-matrix/references/workflows/data-verification.md +0 -232
  205. package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +0 -829
  206. package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +0 -355
  207. package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +0 -283
  208. package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +0 -168
  209. package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +0 -205
  210. package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +0 -75
  211. package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +0 -36
  212. package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +0 -107
  213. package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +0 -114
  214. package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +0 -53
  215. package/skills/ae-tracking-matrix/scripts/finalize_plan.py +0 -166
  216. package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +0 -674
  217. package/skills/ae-tracking-matrix/scripts/plan_contract.py +0 -200
  218. package/skills/ae-tracking-matrix/scripts/plan_types.py +0 -60
  219. package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +0 -169
  220. package/skills/ae-tracking-matrix/scripts/sync_plan.py +0 -296
  221. package/skills/ae-tracking-matrix/scripts/upload_plan.py +0 -340
@@ -3,7 +3,7 @@ import {
3
3
  logger,
4
4
  normalizeUrl,
5
5
  readExternalCliToken
6
- } from "./chunk-Z3Q2AEIN.js";
6
+ } from "./chunk-R2SVAO4G.js";
7
7
 
8
8
  // src/core/sandbox-runtime.ts
9
9
  import { homedir } from "os";
@@ -26,19 +26,22 @@ function getSandboxCliTokenFilePath() {
26
26
  return join(getSandboxAeConfigDir(), "cli-token.json");
27
27
  }
28
28
  function isAeSandboxRuntime() {
29
+ return getAeSandboxDetectionReason() !== "not_detected";
30
+ }
31
+ function getAeSandboxDetectionReason() {
29
32
  if (process.env.SANDBOX_RUNTIME_ROOT) {
30
- return true;
33
+ return "runtime_root_env";
31
34
  }
32
35
  if (process.platform !== "linux") {
33
- return false;
36
+ return "not_detected";
34
37
  }
35
38
  try {
36
39
  if (fs.existsSync(getSandboxCliTokenFilePath())) {
37
- return true;
40
+ return "cli_token_file";
38
41
  }
39
42
  } catch {
40
43
  }
41
- return false;
44
+ return "not_detected";
42
45
  }
43
46
 
44
47
  // src/core/config.ts
@@ -285,12 +288,13 @@ function getConfigDir() {
285
288
  }
286
289
 
287
290
  export {
291
+ getSandboxRuntimeRoot,
292
+ isAeSandboxRuntime,
293
+ getAeSandboxDetectionReason,
288
294
  safeJsonParse,
289
295
  safeReadJsonFile,
290
296
  stringifyJsonRequest,
291
297
  parseJsonRequest,
292
- getSandboxRuntimeRoot,
293
- isAeSandboxRuntime,
294
298
  readSandboxCliTokenEntry,
295
299
  getFallbackCliToken,
296
300
  loadConfig,
@@ -6,17 +6,19 @@ import {
6
6
  evalRequest,
7
7
  evaluationResponseStatus,
8
8
  resolveEvaluationHost
9
- } from "./chunk-P7QDCWJ6.js";
9
+ } from "./chunk-LFJ7N36I.js";
10
10
  import {
11
- getCliToken
12
- } from "./chunk-HTZ2MLYA.js";
11
+ getCliToken,
12
+ internalCallSourceHeaders
13
+ } from "./chunk-PLNS5J33.js";
13
14
  import {
14
15
  isAeSandboxRuntime
15
- } from "./chunk-4PSTYEG5.js";
16
+ } from "./chunk-AMURHMS3.js";
16
17
  import {
17
18
  CliValidationError,
18
- externalCliTokenRequestOptions
19
- } from "./chunk-Z3Q2AEIN.js";
19
+ externalCliTokenRequestOptions,
20
+ readExternalCliToken
21
+ } from "./chunk-R2SVAO4G.js";
20
22
 
21
23
  // src/core/eval-session.ts
22
24
  var SESSION_PATH = "/api/sandbox/agent/evaluation/session";
@@ -30,7 +32,7 @@ async function requestSandboxEvaluationSession(host, cliToken, teProjectId, fetc
30
32
  response = await fetchImpl(url, {
31
33
  ...credentialOptions,
32
34
  method: "POST",
33
- headers: { Accept: "application/json", "Content-Type": "application/json", "cli-token": cliToken },
35
+ headers: { Accept: "application/json", "Content-Type": "application/json", "cli-token": cliToken, ...internalCallSourceHeaders() },
34
36
  body: JSON.stringify(teProjectId ? { te_project_id: teProjectId } : {}),
35
37
  redirect: "error",
36
38
  signal
@@ -113,6 +115,8 @@ function evalHeaders(environment = process.env, onboarding) {
113
115
  return { Authorization: `Bearer ${accessToken}` };
114
116
  }
115
117
  async function resolveEvalHeaders(ctx, environment = process.env, teProjectId) {
118
+ if (readExternalCliToken(ctx.host())?.taskContext && environment.AE_EVAL_ACCESS_TOKEN?.trim())
119
+ throw new CliValidationError("Managed executions must use the current user evaluation session, not AE_EVAL_ACCESS_TOKEN.", { code: "EVAL_MANAGED_TOKEN_OVERRIDE" });
116
120
  if (environment.AE_EVAL_ACCESS_TOKEN?.trim()) return evalHeaders(environment);
117
121
  if (!isAeSandboxRuntime()) {
118
122
  const baseUrl = resolveEvalBaseUrl(ctx, environment);
@@ -4,15 +4,15 @@ import {
4
4
  } from "./chunk-AWW2T2WL.js";
5
5
  import {
6
6
  withOutputMetadata
7
- } from "./chunk-VJUXKVRE.js";
7
+ } from "./chunk-VR2D54AA.js";
8
8
  import {
9
9
  dryRunCapabilityWithEnvelope,
10
10
  executeCapabilityWithEnvelope,
11
11
  validateCapabilityWithEnvelope
12
- } from "./chunk-2ETRY2CU.js";
12
+ } from "./chunk-6HOM2FOJ.js";
13
13
  import {
14
14
  CliValidationError
15
- } from "./chunk-Z3Q2AEIN.js";
15
+ } from "./chunk-R2SVAO4G.js";
16
16
 
17
17
  // src/core/capability-command.ts
18
18
  import { randomBytes } from "crypto";
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  CliValidationError
4
- } from "./chunk-Z3Q2AEIN.js";
4
+ } from "./chunk-R2SVAO4G.js";
5
5
 
6
6
  // src/core/capability-risk.ts
7
7
  var HIGH_RISK_LEVELS = /* @__PURE__ */ new Set(["high-risk-write"]);
@@ -1,20 +1,18 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
+ getCliToken,
3
4
  internalCallSourceHeaders
4
- } from "./chunk-Y74WTIKJ.js";
5
- import {
6
- getCliToken
7
- } from "./chunk-HTZ2MLYA.js";
5
+ } from "./chunk-PLNS5J33.js";
8
6
  import {
9
7
  getActiveHost,
10
8
  getSandboxRuntimeRoot
11
- } from "./chunk-4PSTYEG5.js";
9
+ } from "./chunk-AMURHMS3.js";
12
10
  import {
13
11
  PermissionError,
14
12
  externalCliTokenRequestOptions,
15
13
  isApiErrorType,
16
14
  readExternalCliToken
17
- } from "./chunk-Z3Q2AEIN.js";
15
+ } from "./chunk-R2SVAO4G.js";
18
16
 
19
17
  // src/core/te-agent-credentials.ts
20
18
  import { readFileSync } from "fs";
@@ -202,7 +200,7 @@ function teClaudeBaseFromActiveHost(hostOverride) {
202
200
  async function signRequest(method, path2, hostOverride, includeJsonContentType = true, authMode = "auto") {
203
201
  const external = readExternalCliToken(hostOverride);
204
202
  const configuredHost = hostOverride || getActiveHost();
205
- const sandboxOnly = !hostOverride && (/* @__PURE__ */ new Set([
203
+ const sandboxEndpoint = (/* @__PURE__ */ new Set([
206
204
  "/api/sandbox/models",
207
205
  "/api/sandbox/models/select",
208
206
  "/api/sandbox/sync/push",
@@ -210,9 +208,11 @@ async function signRequest(method, path2, hostOverride, includeJsonContentType =
210
208
  "/api/sandbox/sync/pull",
211
209
  "/api/sandbox/sync/pull/candidates"
212
210
  ])).has(path2.split("?")[0]);
211
+ const sandboxOnly = !hostOverride && sandboxEndpoint;
213
212
  const sandboxCred = external || configuredHost && !sandboxOnly ? null : tryLoadTeAgentSandboxCredentials();
214
213
  if (authMode === "auto" && !hostOverride && sandboxCred && sandboxCred.sandboxId && sandboxCred.sandboxSecretKey) {
215
214
  const headers = {
215
+ ...internalCallSourceHeaders(),
216
216
  "X-Sandbox-Id": sandboxCred.sandboxId,
217
217
  "X-Sandbox-Secret-Key": sandboxCred.sandboxSecretKey
218
218
  };
@@ -239,6 +239,12 @@ async function signRequest(method, path2, hostOverride, includeJsonContentType =
239
239
  url: `${baseUrl.replace(/\/$/, "")}${path2}`,
240
240
  headers: {
241
241
  "cli-token": cliToken,
242
+ ...sandboxEndpoint && external?.taskContext ? {
243
+ "X-Task-CLI-Grant": external.taskContext.grant,
244
+ "X-Task-CLI-Execution": external.taskContext.executionId,
245
+ "X-Task-CLI-Company": external.taskContext.companyId,
246
+ "X-Task-CLI-Sandbox": external.taskContext.sandboxId
247
+ } : {},
242
248
  ...internalCallSourceHeaders(),
243
249
  ...contentTypeHeader
244
250
  },
@@ -307,13 +313,14 @@ async function parseResponse(response, defaultErrorPrefix) {
307
313
  }
308
314
  return parsed;
309
315
  }
310
- async function postToMainApp(path2, body, hostOverride, authMode = "auto") {
316
+ async function postToMainApp(path2, body, hostOverride, authMode = "auto", headers) {
311
317
  const rawBody = JSON.stringify(body);
312
318
  const response = await fetchSigned({
313
319
  method: "POST",
314
320
  path: path2,
315
321
  body: rawBody,
316
322
  hostOverride,
323
+ headers,
317
324
  authMode
318
325
  });
319
326
  return parseResponse(response, "Main app returned");
@@ -1,20 +1,23 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  require_lib
4
- } from "./chunk-QVRIDN42.js";
4
+ } from "./chunk-UCMO4LKL.js";
5
5
  import {
6
6
  require_archiver,
7
7
  require_string_decoder
8
- } from "./chunk-OAWPT7VP.js";
8
+ } from "./chunk-2I5SZ5DS.js";
9
9
  import {
10
10
  require_inherits,
11
11
  require_node
12
- } from "./chunk-JEUXDY3B.js";
12
+ } from "./chunk-HQED4YB4.js";
13
+ import {
14
+ detectCliLocale
15
+ } from "./chunk-N2MAYIRU.js";
13
16
  import {
14
17
  __commonJS,
15
18
  __require,
16
19
  __toESM
17
- } from "./chunk-Z3Q2AEIN.js";
20
+ } from "./chunk-R2SVAO4G.js";
18
21
 
19
22
  // node_modules/exceljs/lib/utils/under-dash.js
20
23
  var require_under_dash = __commonJS({
@@ -23710,33 +23713,6 @@ var require_excel = __commonJS({
23710
23713
  // src/tracking/xlsx/write.ts
23711
23714
  var import_exceljs = __toESM(require_excel(), 1);
23712
23715
 
23713
- // src/tracking/i18n/locale.ts
23714
- var VALID_LOCALES = /* @__PURE__ */ new Set(["zh", "en", "ja", "ko"]);
23715
- function normalize(raw) {
23716
- const lower = raw.trim().toLowerCase();
23717
- if (lower.startsWith("zh") || lower.startsWith("cn")) return "zh";
23718
- if (lower.startsWith("ja") || lower.startsWith("jp")) return "ja";
23719
- if (lower.startsWith("ko") || lower.startsWith("kr")) return "ko";
23720
- if (lower.startsWith("en")) return "en";
23721
- if (VALID_LOCALES.has(lower)) return lower;
23722
- return "en";
23723
- }
23724
- var _cliLocale;
23725
- function detectCliLocale() {
23726
- if (_cliLocale) return _cliLocale;
23727
- if (process.env.AE_LANG) {
23728
- _cliLocale = normalize(process.env.AE_LANG);
23729
- return _cliLocale;
23730
- }
23731
- const sys = (process.env.LANG || process.env.LC_ALL || process.env.LANGUAGE || "").toLowerCase();
23732
- if (sys) {
23733
- _cliLocale = normalize(sys);
23734
- return _cliLocale;
23735
- }
23736
- _cliLocale = "en";
23737
- return _cliLocale;
23738
- }
23739
-
23740
23716
  // src/tracking/i18n/resources/xlsx/sheets.ts
23741
23717
  var SHEET_NAMES = {
23742
23718
  event_data: {
@@ -51749,7 +51725,6 @@ export {
51749
51725
  require_styles_xform,
51750
51726
  require_worksheet_reader,
51751
51727
  require_excel,
51752
- detectCliLocale,
51753
51728
  allSheetNames,
51754
51729
  allHeaderNames,
51755
51730
  displayToType,
@@ -1,21 +1,23 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  CapabilityGatewayError
4
- } from "./chunk-2ETRY2CU.js";
4
+ } from "./chunk-6HOM2FOJ.js";
5
5
  import {
6
6
  SecureStoreAuthError,
7
- getCliToken
8
- } from "./chunk-HTZ2MLYA.js";
7
+ getCliToken,
8
+ internalCallSourceHeaders
9
+ } from "./chunk-PLNS5J33.js";
9
10
  import {
10
11
  safeJsonParse
11
- } from "./chunk-4PSTYEG5.js";
12
+ } from "./chunk-AMURHMS3.js";
12
13
  import {
13
14
  PermissionError,
14
15
  externalCliTokenRequestOptions,
15
16
  isKbQueryPath,
16
17
  kbReadHeaders,
18
+ readExternalCliToken,
17
19
  readKbExecutionContext
18
- } from "./chunk-Z3Q2AEIN.js";
20
+ } from "./chunk-R2SVAO4G.js";
19
21
 
20
22
  // src/core/mcp-access.ts
21
23
  function buildUrl(host, path, params = {}) {
@@ -174,6 +176,7 @@ function parseKbResponse(resp, text, options = {}) {
174
176
  async function fetchWithCliToken(input, init, cliToken, options = {}) {
175
177
  const headers = new Headers(init.headers);
176
178
  headers.set("cli-token", cliToken);
179
+ for (const [name, value] of Object.entries(internalCallSourceHeaders())) headers.set(name, value);
177
180
  const resp = await fetch(input, { ...init, headers, ...externalCliTokenRequestOptions(input) });
178
181
  if (options.responseType === "empty" && resp.status === 204) return null;
179
182
  if (options.responseType === "bytes" && resp.ok) {
@@ -218,19 +221,20 @@ async function requestWithCliToken(host, input, init, options) {
218
221
  }
219
222
  async function getAuthHeaders(ctx) {
220
223
  const cliToken = await getCliToken(ctx.host());
221
- return { "cli-token": cliToken };
224
+ return { "cli-token": cliToken, ...internalCallSourceHeaders() };
222
225
  }
223
226
  async function kbApi(ctx, method, path, params = {}, body, options = {}) {
224
227
  const upperMethod = method.toUpperCase();
228
+ const isAsk = upperMethod === "POST" && /^\/(?:agent\/)?api\/external\/knowledge-bases\/ask$/.test(path);
225
229
  const isQuery = isKbQueryPath(upperMethod, path);
226
230
  const execution = isQuery ? readKbExecutionContext() : void 0;
227
231
  const host = execution ? ctx.hostOverride?.() || execution.origin : ctx.host();
228
232
  const selectedHost = execution && !ctx.hostOverride ? ctx.host() : host;
229
233
  const url = buildUrl(selectedHost, path, params);
230
- const queryHeaders = isQuery ? kbReadHeaders(url, ctx.str("read-context")) : void 0;
234
+ const queryHeaders = isQuery || isAsk && ctx.str("read-context") ? kbReadHeaders(url, ctx.str("read-context")) : void 0;
231
235
  const init = {
232
236
  method: upperMethod,
233
- headers: { "Content-Type": "application/json", ...queryHeaders },
237
+ headers: { "Content-Type": "application/json", ...queryHeaders, ...internalCallSourceHeaders() },
234
238
  body: upperMethod === "GET" ? void 0 : JSON.stringify(body ?? {})
235
239
  };
236
240
  if (execution) {
@@ -240,13 +244,23 @@ async function kbApi(ctx, method, path, params = {}, body, options = {}) {
240
244
  let code = "KB_READ_CONTEXT_REQUEST_FAILED";
241
245
  try {
242
246
  const value = responseErrorMetadata(safeJsonParse(text)).code;
243
- if (value?.startsWith("KB_READ_CONTEXT_")) code = value;
247
+ if (value && /^KB_(READ_CONTEXT|CANDIDATE)_/.test(value)) code = value;
244
248
  } catch {
245
249
  }
246
250
  throw new KbHttpError(code, code, response.status);
247
251
  }
248
252
  return parseKbResponse(response, text, { ...options, redactErrorDetails: true });
249
253
  }
254
+ if (upperMethod === "POST" && /^\/(?:agent\/)?api\/external\/knowledge-bases\/(read|grep|index)$/.test(path)) {
255
+ const task = readExternalCliToken(host)?.taskContext;
256
+ if (task) init.headers = {
257
+ ...init.headers,
258
+ "X-Task-CLI-Grant": task.grant,
259
+ "X-Task-CLI-Execution": task.executionId,
260
+ "X-Task-CLI-Company": task.companyId,
261
+ "X-Task-CLI-Sandbox": task.sandboxId
262
+ };
263
+ }
250
264
  return requestWithCliToken(
251
265
  host,
252
266
  url,
@@ -1,17 +1,17 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createCapabilityCommand
4
- } from "./chunk-BEYLCUZX.js";
4
+ } from "./chunk-E457FREE.js";
5
5
  import {
6
6
  registerCapabilityGatewayRoute
7
7
  } from "./chunk-AWW2T2WL.js";
8
8
  import {
9
9
  executeCapabilityWithEnvelope
10
- } from "./chunk-2ETRY2CU.js";
10
+ } from "./chunk-6HOM2FOJ.js";
11
11
  import {
12
12
  CliApiError,
13
13
  CliValidationError
14
- } from "./chunk-Z3Q2AEIN.js";
14
+ } from "./chunk-R2SVAO4G.js";
15
15
 
16
16
  // src/commands/ai-monitor/shared.ts
17
17
  function createAiMonitorCapabilityCommand(config) {
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  __commonJS,
4
4
  __require
5
- } from "./chunk-Z3Q2AEIN.js";
5
+ } from "./chunk-R2SVAO4G.js";
6
6
 
7
7
  // node_modules/process-nextick-args/index.js
8
8
  var require_process_nextick_args = __commonJS({
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  getActiveHost
4
- } from "./chunk-4PSTYEG5.js";
4
+ } from "./chunk-AMURHMS3.js";
5
5
  import {
6
6
  normalizeUrl
7
- } from "./chunk-Z3Q2AEIN.js";
7
+ } from "./chunk-R2SVAO4G.js";
8
8
 
9
9
  // src/core/auth.ts
10
10
  function resolveHost(hostOverride) {
@@ -1,8 +1,11 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ internalCallSourceHeaders
4
+ } from "./chunk-PLNS5J33.js";
2
5
  import {
3
6
  CliValidationError,
4
7
  logger
5
- } from "./chunk-Z3Q2AEIN.js";
8
+ } from "./chunk-R2SVAO4G.js";
6
9
 
7
10
  // src/core/eval-endpoint.ts
8
11
  function resolveEvaluationHost(host) {
@@ -140,6 +143,7 @@ async function evalRequest(options) {
140
143
  const timeout = setTimeout(() => controller.abort(), timeoutMs);
141
144
  const headers = {
142
145
  ...options.headers,
146
+ ...internalCallSourceHeaders(),
143
147
  Accept: options.responseType === "bytes" ? "application/octet-stream, application/json" : "application/json"
144
148
  };
145
149
  const isMultipart = options.body instanceof FormData;
@@ -0,0 +1,32 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+
3
+ // src/tracking/i18n/locale.ts
4
+ var VALID_LOCALES = /* @__PURE__ */ new Set(["zh", "en", "ja", "ko"]);
5
+ function normalize(raw) {
6
+ const lower = raw.trim().toLowerCase();
7
+ if (lower.startsWith("zh") || lower.startsWith("cn")) return "zh";
8
+ if (lower.startsWith("ja") || lower.startsWith("jp")) return "ja";
9
+ if (lower.startsWith("ko") || lower.startsWith("kr")) return "ko";
10
+ if (lower.startsWith("en")) return "en";
11
+ if (VALID_LOCALES.has(lower)) return lower;
12
+ return "en";
13
+ }
14
+ var _cliLocale;
15
+ function detectCliLocale() {
16
+ if (_cliLocale) return _cliLocale;
17
+ if (process.env.AE_LANG) {
18
+ _cliLocale = normalize(process.env.AE_LANG);
19
+ return _cliLocale;
20
+ }
21
+ const sys = (process.env.LANG || process.env.LC_ALL || process.env.LANGUAGE || "").toLowerCase();
22
+ if (sys) {
23
+ _cliLocale = normalize(sys);
24
+ return _cliLocale;
25
+ }
26
+ _cliLocale = "en";
27
+ return _cliLocale;
28
+ }
29
+
30
+ export {
31
+ detectCliLocale
32
+ };
@@ -0,0 +1,60 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ getLocalCliPackageInfo
4
+ } from "./chunk-PUSFEC6B.js";
5
+ import {
6
+ getAeSandboxDetectionReason
7
+ } from "./chunk-AMURHMS3.js";
8
+ import {
9
+ logger
10
+ } from "./chunk-R2SVAO4G.js";
11
+
12
+ // src/core/source-logged-fetch.ts
13
+ import { randomUUID } from "crypto";
14
+ var CLI_REQUEST_ID_HEADER = "X-TA-CLI-Request-Id";
15
+ var localPackage = getLocalCliPackageInfo();
16
+ var MAX_LOG_VALUE_LENGTH = 256;
17
+ function bounded(value) {
18
+ return value.length > MAX_LOG_VALUE_LENGTH ? `${value.slice(0, MAX_LOG_VALUE_LENGTH)}...[truncated]` : value;
19
+ }
20
+ function sourceLoggedFetch(url, init) {
21
+ const requestId = randomUUID();
22
+ let headers;
23
+ if (init.headers instanceof Headers) {
24
+ headers = new Headers(init.headers);
25
+ headers.set(CLI_REQUEST_ID_HEADER, requestId);
26
+ } else if (Array.isArray(init.headers)) {
27
+ headers = [
28
+ ...init.headers.filter(([name]) => name.toLowerCase() !== CLI_REQUEST_ID_HEADER.toLowerCase()),
29
+ [CLI_REQUEST_ID_HEADER, requestId]
30
+ ];
31
+ } else {
32
+ headers = Object.fromEntries(Object.entries(init.headers ?? {}).filter(([name]) => name.toLowerCase() !== CLI_REQUEST_ID_HEADER.toLowerCase()));
33
+ headers[CLI_REQUEST_ID_HEADER] = requestId;
34
+ }
35
+ const request = { ...init, headers };
36
+ try {
37
+ const target = new URL(url);
38
+ const actualHeaders = new Headers(headers);
39
+ const source = actualHeaders.get("X-Source");
40
+ const sandboxDetection = getAeSandboxDetectionReason();
41
+ logger.info(`CLI_SOURCE_SEND ${JSON.stringify({
42
+ request_id: requestId,
43
+ method: init.method ?? "GET",
44
+ host: bounded(target.host),
45
+ path: bounded(target.pathname),
46
+ source: source === null ? null : bounded(source),
47
+ source_state: source === null ? "missing" : source === "" ? "empty" : source.includes(",") ? "multiple" : "present",
48
+ cli_package: localPackage.name,
49
+ cli_version: localPackage.version,
50
+ sandbox_detected: sandboxDetection !== "not_detected",
51
+ sandbox_detection: sandboxDetection
52
+ })}`);
53
+ } catch {
54
+ }
55
+ return fetch(url, request);
56
+ }
57
+
58
+ export {
59
+ sourceLoggedFetch
60
+ };
@@ -6,14 +6,19 @@ import {
6
6
  readSandboxCliTokenEntry,
7
7
  safeJsonParse,
8
8
  safeReadJsonFile
9
- } from "./chunk-4PSTYEG5.js";
9
+ } from "./chunk-AMURHMS3.js";
10
10
  import {
11
11
  PermissionError,
12
12
  externalCliTokenRequestOptions,
13
13
  logger,
14
14
  normalizeUrl,
15
15
  readExternalCliToken
16
- } from "./chunk-Z3Q2AEIN.js";
16
+ } from "./chunk-R2SVAO4G.js";
17
+
18
+ // src/core/internal-call-source.ts
19
+ function internalCallSourceHeaders() {
20
+ return {};
21
+ }
17
22
 
18
23
  // src/core/secure-store.ts
19
24
  import crypto from "crypto";
@@ -658,7 +663,7 @@ async function generateCliToken(hostUrl, accessToken) {
658
663
  const url = `${hostUrl.replace(/\/+$/, "")}${CLI_TOKEN_GENERATE_PATH}`;
659
664
  const resp = await fetch(url, {
660
665
  method: "GET",
661
- headers: { Authorization: `bearer ${accessToken}` }
666
+ headers: { Authorization: `bearer ${accessToken}`, ...internalCallSourceHeaders() }
662
667
  });
663
668
  if (!resp.ok) {
664
669
  if (resp.status === 403) {
@@ -699,7 +704,7 @@ async function validateCliTokenOnServer(hostUrl, cliToken) {
699
704
  try {
700
705
  resp = await fetch(url, {
701
706
  method: "GET",
702
- headers: { Accept: "application/json", "cli-token": cliToken },
707
+ headers: { Accept: "application/json", "cli-token": cliToken, ...internalCallSourceHeaders() },
703
708
  ...externalCliTokenRequestOptions(url)
704
709
  });
705
710
  } catch (error) {
@@ -743,7 +748,7 @@ async function renewCliTokenOnServer(hostUrl, cliToken, external = false, signal
743
748
  if (!external) url.searchParams.set("cli-token", cliToken);
744
749
  const resp = await fetch(url.toString(), {
745
750
  method: "GET",
746
- headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {} },
751
+ headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {}, ...internalCallSourceHeaders() },
747
752
  ...externalCliTokenRequestOptions(url.toString()),
748
753
  signal
749
754
  });
@@ -865,6 +870,7 @@ async function mintCliToken(hostUrl, accessToken) {
865
870
  }
866
871
 
867
872
  export {
873
+ internalCallSourceHeaders,
868
874
  assertCredentialsReadable,
869
875
  getActiveCredential,
870
876
  listCredentials,
@@ -2,22 +2,24 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  canManageGlobalSkills,
4
4
  fetchCliConfig,
5
- getLocalCliPackageInfo,
6
5
  isBusinessSkillContextCurrent,
7
6
  rememberBusinessConfig,
8
7
  reserveBusinessSkillContext,
9
8
  syncBusinessSkills
10
- } from "./chunk-LOR4IA26.js";
9
+ } from "./chunk-YJYC5PLL.js";
10
+ import {
11
+ getLocalCliPackageInfo
12
+ } from "./chunk-PUSFEC6B.js";
11
13
  import {
12
14
  peekCliToken
13
- } from "./chunk-HTZ2MLYA.js";
15
+ } from "./chunk-PLNS5J33.js";
14
16
  import {
15
17
  getActiveHost,
16
18
  getConfigDir
17
- } from "./chunk-4PSTYEG5.js";
19
+ } from "./chunk-AMURHMS3.js";
18
20
  import {
19
21
  normalizeUrl
20
- } from "./chunk-Z3Q2AEIN.js";
22
+ } from "./chunk-R2SVAO4G.js";
21
23
 
22
24
  // src/core/environment-refresh.ts
23
25
  import crypto from "crypto";
@@ -0,0 +1,29 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+
3
+ // src/core/package-info.ts
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import { fileURLToPath } from "url";
7
+ function getLocalCliPackageInfo() {
8
+ let dir = path.dirname(fileURLToPath(import.meta.url));
9
+ for (let i = 0; i < 8; i += 1) {
10
+ const candidate = path.join(dir, "package.json");
11
+ try {
12
+ if (fs.existsSync(candidate)) {
13
+ const pkg = JSON.parse(fs.readFileSync(candidate, "utf8"));
14
+ if (pkg.name && pkg.version && String(pkg.name).includes("ae-cli")) {
15
+ return { name: pkg.name, version: pkg.version, root: dir };
16
+ }
17
+ }
18
+ } catch {
19
+ }
20
+ const parent = path.dirname(dir);
21
+ if (parent === dir) break;
22
+ dir = parent;
23
+ }
24
+ return { name: "@tant/ae-cli", version: "0.0.0", root: "" };
25
+ }
26
+
27
+ export {
28
+ getLocalCliPackageInfo
29
+ };
@@ -232,15 +232,27 @@ function readExternalCliToken(hostOverride) {
232
232
  let data;
233
233
  try {
234
234
  const stat = fs2.statSync(file);
235
- if (!stat.isFile() || stat.size > 64 * 1024) throw new Error();
235
+ if (!stat.isFile() || stat.size > 96 * 1024) throw new Error();
236
236
  data = JSON.parse(fs2.readFileSync(file, "utf8"));
237
237
  } catch {
238
- throw new ExternalCliTokenError("The external CLI token file must be a readable JSON file no larger than 64 KiB.");
238
+ throw new ExternalCliTokenError("The external CLI token file must be a readable JSON file no larger than 96 KiB.");
239
239
  }
240
240
  if (!data || typeof data !== "object" || Array.isArray(data)) {
241
241
  throw new ExternalCliTokenError("The external CLI token file must contain an object with url and token.");
242
242
  }
243
+ if (data.blocked !== void 0) {
244
+ const code = ["PI_CLI_NOT_READY", "PI_CLI_AUTH_REQUIRED", "PI_CLI_PERMISSION_DENIED", "PI_CLI_TIMEOUT"].includes(data.blocked) ? data.blocked : "PI_CLI_NOT_READY";
245
+ throw new ExternalCliTokenError("The runtime could not prepare CLI credentials for this execution.", code);
246
+ }
243
247
  entry = credential(data.url, data.token ?? data["cli-token"], "file-cli-token");
248
+ if (data.taskContext !== void 0) {
249
+ const context = data.taskContext;
250
+ if (!context || typeof context !== "object" || Array.isArray(context) || context.version !== 1 || typeof context.grant !== "string" || context.grant.length > 65536 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(context.grant) || ["executionId", "sandboxId", "companyId"].some((key) => typeof context[key] !== "string" || !/^[^\s\x00-\x1f\x7f]{1,191}$/.test(context[key]))) {
251
+ throw new ExternalCliTokenError("The runtime CLI context is invalid.");
252
+ }
253
+ entry.taskContext = { version: 1, grant: context.grant, executionId: context.executionId, sandboxId: context.sandboxId, companyId: context.companyId };
254
+ diagnosticSecrets.add(context.grant);
255
+ }
244
256
  } else if (process.env.AE_CLI_TOKEN !== void 0) {
245
257
  entry = credential(process.env.AE_CLI_TOKEN_HOST, process.env.AE_CLI_TOKEN, "environment-cli-token");
246
258
  } else if (process.env.AE_CLI_TOKEN_HOST !== void 0) {