@thinkingai/ae-cli 6.1.27 → 6.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +52 -6
  2. package/README.zh.md +52 -6
  3. package/bin/ae-cli.js +5 -0
  4. package/bin/runtime-capabilities.json +5 -0
  5. package/cli-installation-guide.md +24 -3
  6. package/dist/{auth-WA7YGGRT.js → auth-OBQ5KVQM.js} +175 -45
  7. package/dist/{automation-VAAQBM7Y.js → automation-NAR5DDGL.js} +94 -38
  8. package/dist/{capability-GAAYJ3IQ.js → capability-LFSVNI5B.js} +57 -28
  9. package/dist/chunk-2UW3Y463.js +2289 -0
  10. package/dist/{chunk-VZZNLV3I.js → chunk-3SDHJOCR.js} +68 -18
  11. package/dist/chunk-6HAUVWOQ.js +132 -0
  12. package/dist/{chunk-5XJYLEVC.js → chunk-72NJKS7O.js} +4 -4
  13. package/dist/{chunk-Q5US7JC5.js → chunk-7JAVT5TK.js} +3 -3
  14. package/dist/{chunk-7KU2WNQE.js → chunk-CVCTFLSO.js} +37 -15
  15. package/dist/{chunk-GHXZK54S.js → chunk-H3K5UGYC.js} +41 -13
  16. package/dist/{chunk-OP44TT4H.js → chunk-IN7KKL6K.js} +4 -2
  17. package/dist/{chunk-S6M42KND.js → chunk-JEUXDY3B.js} +1 -1
  18. package/dist/{chunk-ZL7SGNIA.js → chunk-JNVVJ273.js} +58 -46
  19. package/dist/chunk-N6XBLRB7.js +105 -0
  20. package/dist/{chunk-AP7YP2NX.js → chunk-OAWPT7VP.js} +2 -2
  21. package/dist/{chunk-AQJPNWZF.js → chunk-PWXDWMCW.js} +7 -7
  22. package/dist/{chunk-CT7QDJS6.js → chunk-QVRIDN42.js} +2 -2
  23. package/dist/chunk-QZLRHGVH.js +222 -0
  24. package/dist/{chunk-RPBOAQQQ.js → chunk-QZUVLFNR.js} +1 -1
  25. package/dist/{chunk-3YVEAZUN.js → chunk-RJHGDWSC.js} +32 -21
  26. package/dist/{chunk-MWIA43UJ.js → chunk-VCZE3IWO.js} +10 -8
  27. package/dist/chunk-YVG6QD3V.js +233 -0
  28. package/dist/{chunk-WNGFSIOB.js → chunk-Z3Q2AEIN.js} +237 -86
  29. package/dist/{community-report-client-PEERQCX2.js → community-report-client-TJVCLZ3K.js} +1 -1
  30. package/dist/compat-check-CII6B74E.js +32 -0
  31. package/dist/{config-JOD5DOPE.js → config-YZ6O2UQ2.js} +40 -7
  32. package/dist/{context-NGVFPCBK.js → context-F6FCGTF3.js} +4 -4
  33. package/dist/{data-integration-BCLQFTGU.js → data-integration-6UAZO4GG.js} +207 -24
  34. package/dist/evaluation-4LO2O4AF.js +3714 -0
  35. package/dist/index.js +352 -81
  36. package/dist/{local-data-upload-client-TWMHFLUA.js → local-data-upload-client-KCMG6J62.js} +1 -1
  37. package/dist/{memory-CQKH2JAV.js → memory-HHPX3NF2.js} +6 -6
  38. package/dist/{metadata-NR3PHR23.js → metadata-TIFY24LW.js} +17 -9
  39. package/dist/{model-VX5M2CJ6.js → model-7UHGWYVR.js} +4 -4
  40. package/dist/{personal-semantic-preference-2RAI36P3.js → personal-semantic-preference-WKJEGPTM.js} +7 -6
  41. package/dist/{project-semantic-3BUGP3ZM.js → project-semantic-EIQVZNHW.js} +11 -10
  42. package/dist/{sync-RZIAV37C.js → sync-RV3OPCTI.js} +8 -7
  43. package/dist/{te-agent-AORRE2FM.js → te-agent-5ENVZJUH.js} +757 -94
  44. package/dist/{te-analysis-GP7DSQ7Q.js → te-analysis-USIK6ZZG.js} +584 -100
  45. package/dist/{te-community-42M7ICDO.js → te-community-WE2UU4XV.js} +722 -228
  46. package/dist/{te-dataops-BNKNZ4F2.js → te-dataops-XNMO7MBF.js} +9 -6
  47. package/dist/{te-engage-2CO6LRCX.js → te-engage-6C3HCFQR.js} +13 -12
  48. package/dist/{te-experiment-652CLXMU.js → te-experiment-LVTRI3QK.js} +55 -21
  49. package/dist/{te-kb-ULATOTQ3.js → te-kb-TUPGMVBY.js} +409 -85
  50. package/dist/{te-system-UGHVKBVV.js → te-system-YM657FKO.js} +6 -6
  51. package/dist/{te-team-YA6SNOJ3.js → te-team-G4VEJJNL.js} +64 -41
  52. package/dist/{things-DTCOQIQB.js → things-22KQWC23.js} +7 -7
  53. package/dist/{update-ESNYKUVR.js → update-XX4ILU7X.js} +11 -7
  54. package/dist/{workspace-JEOHKFPX.js → workspace-LYDAP647.js} +6 -6
  55. package/package.json +26 -11
  56. package/skills/ae-agent/SKILL.md +22 -3
  57. package/skills/ae-agent/references/command_index.md +8 -0
  58. package/skills/ae-agent/references/resource-package.md +57 -0
  59. package/skills/ae-analysis/SKILL.md +23 -10
  60. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  61. package/skills/ae-analysis/references/agent_review_preflight.md +55 -10
  62. package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
  63. package/skills/ae-analysis/references/agent_review_submit_to_page.md +60 -24
  64. package/skills/ae-analysis/references/ai_models/event.md +58 -2
  65. package/skills/ae-analysis/references/ai_models/rank_list.md +1 -0
  66. package/skills/ae-analysis/references/ai_models/retention.md +2 -0
  67. package/skills/ae-analysis/references/ai_models/revenue.md +2 -0
  68. package/skills/ae-analysis/references/analysis_data_export.md +11 -1
  69. package/skills/ae-analysis/references/asset_batch_info_export.md +2 -2
  70. package/skills/ae-analysis/references/asset_batch_sql_export.md +2 -2
  71. package/skills/ae-analysis/references/asset_export.md +1 -1
  72. package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
  73. package/skills/ae-analysis/references/check_export.md +1 -1
  74. package/skills/ae-analysis/references/command_index.md +39 -26
  75. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  76. package/skills/ae-analysis/references/dashboard_report_get.md +6 -2
  77. package/skills/ae-analysis/references/dashboard_report_update.md +24 -5
  78. package/skills/ae-analysis/references/feedback_submit.md +1 -1
  79. package/skills/ae-analysis/references/governance_recommendation_export.md +40 -18
  80. package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
  81. package/skills/ae-analysis/references/live_data_export.md +1 -1
  82. package/skills/ae-analysis/references/metric_create.md +29 -0
  83. package/skills/ae-analysis/references/metric_get.md +2 -0
  84. package/skills/ae-analysis/references/metric_update.md +2 -0
  85. package/skills/ae-analysis/references/operation_record_export.md +1 -1
  86. package/skills/ae-analysis/references/plan_change_log_export.md +1 -1
  87. package/skills/ae-analysis/references/plan_export.md +1 -1
  88. package/skills/ae-analysis/references/project_info_get.md +4 -0
  89. package/skills/ae-analysis/references/project_member_group_add_members.md +35 -0
  90. package/skills/ae-analysis/references/project_member_group_create.md +25 -0
  91. package/skills/ae-analysis/references/project_member_group_delete.md +34 -0
  92. package/skills/ae-analysis/references/project_member_group_list.md +29 -0
  93. package/skills/ae-analysis/references/project_member_group_members.md +28 -0
  94. package/skills/ae-analysis/references/project_member_group_remove_members.md +35 -0
  95. package/skills/ae-analysis/references/project_member_group_rename.md +26 -0
  96. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
  97. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +6 -1
  98. package/skills/ae-analysis/references/report_data_export.md +1 -1
  99. package/skills/ae-analysis/references/scenario_append.md +31 -0
  100. package/skills/ae-analysis/references/scenario_begin.md +11 -0
  101. package/skills/ae-analysis/references/scenario_collect.md +43 -0
  102. package/skills/ae-analysis/references/scenario_evaluation.md +18 -0
  103. package/skills/ae-analysis/references/scenario_get.md +15 -0
  104. package/skills/ae-analysis/references/scenario_list.md +64 -0
  105. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +73 -4
  106. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
  107. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +5 -1
  108. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/execution-contract.mjs +173 -0
  109. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +109 -64
  110. package/skills/ae-automation/SKILL.md +2 -2
  111. package/skills/ae-automation/references/cli.md +18 -1
  112. package/skills/ae-capability/SKILL.md +7 -3
  113. package/skills/ae-community/SKILL.md +77 -27
  114. package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
  115. package/skills/ae-community/references/community-data-quality.md +68 -0
  116. package/skills/ae-community/references/community-query-evidence.md +85 -0
  117. package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
  118. package/skills/ae-community/references/community-weekly-report.md +6 -3
  119. package/skills/ae-community/references/get_channel_info.md +7 -4
  120. package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
  121. package/skills/ae-community/references/get_comments_summary.md +4 -4
  122. package/skills/ae-community/references/get_corpus_tags.md +3 -3
  123. package/skills/ae-community/references/get_daily_summary.md +3 -3
  124. package/skills/ae-community/references/get_hot_topics.md +3 -3
  125. package/skills/ae-community/references/get_livestream_analysis.md +3 -3
  126. package/skills/ae-community/references/get_livestream_detail.md +4 -4
  127. package/skills/ae-community/references/get_livestream_list.md +3 -3
  128. package/skills/ae-community/references/get_livestream_overview.md +3 -3
  129. package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
  130. package/skills/ae-community/references/get_livestream_rooms.md +3 -3
  131. package/skills/ae-community/references/get_overview_metrics.md +3 -3
  132. package/skills/ae-community/references/get_post_detail.md +4 -4
  133. package/skills/ae-community/references/get_risk_content.md +5 -5
  134. package/skills/ae-community/references/get_sentiment_overview.md +4 -4
  135. package/skills/ae-community/references/get_tag_trends.md +3 -3
  136. package/skills/ae-community/references/get_topic_detail.md +3 -3
  137. package/skills/ae-community/references/list_sources.md +28 -0
  138. package/skills/ae-community/references/list_spaces.md +39 -0
  139. package/skills/ae-community/references/search_posts.md +21 -7
  140. package/skills/ae-data-integration/SKILL.md +6 -4
  141. package/skills/ae-data-integration/references/error-handling.md +1 -0
  142. package/skills/ae-data-integration/references/handoff.md +1 -1
  143. package/skills/ae-data-integration/references/sink-upload.md +11 -0
  144. package/skills/ae-data-integration/references/source-inspect.md +2 -1
  145. package/skills/ae-data-integration/references/transform.md +1 -1
  146. package/skills/ae-data-integration/references/ue-mapping.md +1 -1
  147. package/skills/ae-evaluation/SKILL.md +83 -0
  148. package/skills/ae-evaluation/references/access-and-members.md +55 -0
  149. package/skills/ae-evaluation/references/connections.md +78 -0
  150. package/skills/ae-evaluation/references/datasets.md +57 -0
  151. package/skills/ae-evaluation/references/evaluators.md +81 -0
  152. package/skills/ae-evaluation/references/files.md +33 -0
  153. package/skills/ae-evaluation/references/integrations.md +39 -0
  154. package/skills/ae-evaluation/references/runs.md +160 -0
  155. package/skills/ae-evaluation/references/schedules.md +31 -0
  156. package/skills/ae-experiment/SKILL.md +7 -1
  157. package/skills/ae-experiment/references/manage_experiment.md +18 -1
  158. package/skills/ae-experiment/references/query_experiment_detail.md +7 -0
  159. package/skills/ae-experiment/references/save_experiment.md +76 -2
  160. package/skills/ae-experiment/references/save_submit_experiment.md +7 -0
  161. package/skills/ae-kb/SKILL.md +33 -7
  162. package/skills/ae-kb/references/publication.md +81 -0
  163. package/skills/ae-kb/references/query-workflow.md +14 -1
  164. package/skills/ae-metadata/SKILL.md +3 -2
  165. package/skills/ae-metadata/references/metadata_data_table_download.md +7 -1
  166. package/skills/ae-metadata/references/metadata_data_table_get.md +37 -0
  167. package/skills/ae-system/SKILL.md +1 -1
  168. package/skills/ae-team/SKILL.md +2 -2
  169. package/skills/ae-team/references/run-start.md +1 -0
  170. package/skills/ae-team/references/run-watch.md +7 -5
  171. package/skills/ae-things/SKILL.md +53 -51
  172. package/skills/ae-things/references/cli.md +56 -54
  173. package/skills/ae-things-progress/SKILL.md +20 -20
  174. package/skills/ae-things-review/SKILL.md +19 -19
  175. package/skills/ae-workspace/SKILL.md +1 -1
  176. package/dist/chunk-6VNIR4AP.js +0 -1422
  177. package/dist/chunk-CI24BDR2.js +0 -43
@@ -1,15 +1,44 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
- logger
4
- } from "./chunk-WNGFSIOB.js";
3
+ logger,
4
+ normalizeUrl,
5
+ readExternalCliToken
6
+ } from "./chunk-Z3Q2AEIN.js";
5
7
 
6
- // src/core/url-utils.ts
7
- function normalizeUrl(url) {
8
- if (!url) return url;
9
- if (!url.startsWith("http://") && !url.startsWith("https://")) {
10
- url = `https://${url}`;
8
+ // src/core/sandbox-runtime.ts
9
+ import { homedir } from "os";
10
+ import { join } from "path";
11
+ import fs from "fs";
12
+ var LINUX_SANDBOX_RUNTIME_ROOT = "/home/ta/te_agent_ta";
13
+ function getDefaultSandboxRuntimeRoot() {
14
+ if (process.platform === "linux") {
15
+ return LINUX_SANDBOX_RUNTIME_ROOT;
11
16
  }
12
- return url.replace(/\/$/, "");
17
+ return homedir();
18
+ }
19
+ function getSandboxRuntimeRoot() {
20
+ return process.env.SANDBOX_RUNTIME_ROOT || getDefaultSandboxRuntimeRoot();
21
+ }
22
+ function getSandboxAeConfigDir() {
23
+ return join(getSandboxRuntimeRoot(), ".ae-config");
24
+ }
25
+ function getSandboxCliTokenFilePath() {
26
+ return join(getSandboxAeConfigDir(), "cli-token.json");
27
+ }
28
+ function isAeSandboxRuntime() {
29
+ if (process.env.SANDBOX_RUNTIME_ROOT) {
30
+ return true;
31
+ }
32
+ if (process.platform !== "linux") {
33
+ return false;
34
+ }
35
+ try {
36
+ if (fs.existsSync(getSandboxCliTokenFilePath())) {
37
+ return true;
38
+ }
39
+ } catch {
40
+ }
41
+ return false;
13
42
  }
14
43
 
15
44
  // src/core/config.ts
@@ -18,11 +47,17 @@ import path from "path";
18
47
  import os from "os";
19
48
 
20
49
  // src/core/json-utils.ts
21
- import fs from "fs";
50
+ import fs2 from "fs";
22
51
  import { createRequire } from "module";
23
52
  var require2 = createRequire(import.meta.url);
24
53
  var JSONbig = require2("json-bigint");
25
54
  var jsonParser = JSONbig({ storeAsString: true });
55
+ var requestJsonStringifier = JSONbig({ useNativeBigInt: true });
56
+ var requestJsonParser = JSONbig({
57
+ useNativeBigInt: true,
58
+ protoAction: "error",
59
+ constructorAction: "error"
60
+ });
26
61
  var INTEGER_TOKEN = /^-?(?:0|[1-9]\d*)$/;
27
62
  function normalizeParsedNumbers(lossless, native) {
28
63
  if (typeof lossless === "string" && typeof native === "number") {
@@ -49,50 +84,24 @@ function safeJsonParse(text) {
49
84
  return normalizeParsedNumbers(lossless, JSON.parse(text));
50
85
  }
51
86
  function safeReadJsonFile(filePath) {
52
- const content = fs.readFileSync(filePath, "utf-8");
87
+ const content = fs2.readFileSync(filePath, "utf-8");
53
88
  return safeJsonParse(content);
54
89
  }
55
-
56
- // src/core/sandbox-runtime.ts
57
- import { homedir } from "os";
58
- import { join } from "path";
59
- import fs2 from "fs";
60
- var LINUX_SANDBOX_RUNTIME_ROOT = "/home/ta/te_agent_ta";
61
- function getDefaultSandboxRuntimeRoot() {
62
- if (process.platform === "linux") {
63
- return LINUX_SANDBOX_RUNTIME_ROOT;
64
- }
65
- return homedir();
90
+ function stringifyJsonRequest(obj) {
91
+ return requestJsonStringifier.stringify(obj);
66
92
  }
67
- function getSandboxRuntimeRoot() {
68
- return process.env.SANDBOX_RUNTIME_ROOT || getDefaultSandboxRuntimeRoot();
69
- }
70
- function getSandboxAeConfigDir() {
71
- return join(getSandboxRuntimeRoot(), ".ae-config");
72
- }
73
- function getSandboxCliTokenFilePath() {
74
- return join(getSandboxAeConfigDir(), "cli-token.json");
75
- }
76
- function isAeSandboxRuntime() {
77
- if (process.env.SANDBOX_RUNTIME_ROOT) {
78
- return true;
79
- }
80
- if (process.platform !== "linux") {
81
- return false;
82
- }
83
- try {
84
- if (fs2.existsSync(getSandboxCliTokenFilePath())) {
85
- return true;
86
- }
87
- } catch {
88
- }
89
- return false;
93
+ function parseJsonRequest(text) {
94
+ return requestJsonParser.parse(text);
90
95
  }
91
96
 
92
97
  // src/core/config.ts
93
98
  var CONFIG_DIR = path.join(process.env.HOME || os.homedir(), ".ae-cli");
94
99
  var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
95
100
  function sandboxCliTokenCandidatePaths() {
101
+ if (process.env.TE_AGENT_CLI_CONFIG_DIR !== void 0) {
102
+ const directory = process.env.TE_AGENT_CLI_CONFIG_DIR;
103
+ return path.isAbsolute(directory) ? [path.join(directory, "cli-token.json")] : [];
104
+ }
96
105
  const paths = [getSandboxCliTokenFilePath()];
97
106
  const homeFallback = path.join(process.env.HOME || os.homedir(), ".ae-config", "cli-token.json");
98
107
  if (!paths.includes(homeFallback)) {
@@ -108,7 +117,7 @@ function readSandboxCliTokenEntry() {
108
117
  if (data && typeof data === "object" && !Array.isArray(data)) {
109
118
  const url = data.url;
110
119
  const token = data.token ?? data["cli-token"];
111
- if (url && token) {
120
+ if (typeof url === "string" && url && typeof token === "string" && token) {
112
121
  return { url, token };
113
122
  }
114
123
  }
@@ -196,6 +205,8 @@ function saveConfig(config) {
196
205
  logger.info(`Config saved: activeHost=${config.activeHost}, hosts=${Object.keys(config.hosts).length}`);
197
206
  }
198
207
  function getActiveHost() {
208
+ const externalHost = readExternalCliToken()?.url;
209
+ if (externalHost) return externalHost;
199
210
  const sandboxHost = readSandboxCliTokenEntry()?.url;
200
211
  if (sandboxHost) return sandboxHost;
201
212
  const config = loadConfig();
@@ -281,7 +292,8 @@ function getConfigDir() {
281
292
  export {
282
293
  safeJsonParse,
283
294
  safeReadJsonFile,
284
- normalizeUrl,
295
+ stringifyJsonRequest,
296
+ parseJsonRequest,
285
297
  getSandboxRuntimeRoot,
286
298
  isAeSandboxRuntime,
287
299
  readSandboxCliTokenEntry,
@@ -0,0 +1,105 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ TeAgentApiError,
4
+ deleteFromMainApp,
5
+ fetchSigned,
6
+ getBufferFromMainApp,
7
+ getFromMainApp,
8
+ parseResponse,
9
+ patchToMainApp,
10
+ postToMainApp,
11
+ putToMainApp,
12
+ uploadToMainApp
13
+ } from "./chunk-RJHGDWSC.js";
14
+ import {
15
+ clearCliTokenCache
16
+ } from "./chunk-H3K5UGYC.js";
17
+
18
+ // src/core/resource-package-client.ts
19
+ function checkPath(path) {
20
+ if (!path.startsWith("/api/resource-packages/")) {
21
+ throw new TypeError("Resource package requests must use /api/resource-packages/");
22
+ }
23
+ }
24
+ async function fetchResourcePackage(input) {
25
+ const request = () => fetchSigned({ ...input, hostOverride: input.host });
26
+ let response = await request();
27
+ if (response.status === 401) {
28
+ await response.body?.cancel();
29
+ clearCliTokenCache(input.host);
30
+ response = await request();
31
+ }
32
+ return response;
33
+ }
34
+ async function resourcePackageJson(input) {
35
+ checkPath(input.path);
36
+ const response = await fetchResourcePackage({
37
+ method: input.method,
38
+ path: input.path,
39
+ host: input.host,
40
+ includeJsonContentType: true,
41
+ body: input.body === void 0 ? void 0 : JSON.stringify(input.body)
42
+ });
43
+ return parseResponse(response, "Resource package service returned");
44
+ }
45
+ async function resourcePackageRaw(input) {
46
+ checkPath(input.path);
47
+ const response = await fetchResourcePackage({
48
+ ...input,
49
+ includeJsonContentType: false
50
+ });
51
+ if (!response.ok) await parseResponse(response, "Resource package service returned");
52
+ return response;
53
+ }
54
+
55
+ // src/commands/te-agent/api-client.ts
56
+ function getAgentApi(ctx, path) {
57
+ return getFromMainApp(path, ctx.host());
58
+ }
59
+ function postAgentApi(ctx, path, body) {
60
+ return postToMainApp(path, body, ctx.host());
61
+ }
62
+ function patchAgentApi(ctx, path, body) {
63
+ return patchToMainApp(path, body, ctx.host());
64
+ }
65
+ function putAgentApi(ctx, path, body) {
66
+ return putToMainApp(path, body, ctx.host());
67
+ }
68
+ function deleteAgentApi(ctx, path) {
69
+ return deleteFromMainApp(path, ctx.host());
70
+ }
71
+ function uploadAgentApi(ctx, path, formData) {
72
+ return uploadToMainApp(path, formData, ctx.host());
73
+ }
74
+ function getAgentBuffer(ctx, path) {
75
+ return getBufferFromMainApp(path, ctx.host());
76
+ }
77
+ function requestResourcePackageApi(ctx, method, path, body) {
78
+ return resourcePackageJson({ host: ctx.host(), method, path, body });
79
+ }
80
+ function requestResourcePackageRaw(ctx, method, path, options = {}) {
81
+ return resourcePackageRaw({ host: ctx.host(), method, path, ...options });
82
+ }
83
+ function isTransientResourcePackageError(error) {
84
+ return error instanceof TeAgentApiError && (error.status === 0 || error.status === 429 || error.status >= 500);
85
+ }
86
+ function resourcePackagePreflightChange(error) {
87
+ if (!(error instanceof TeAgentApiError) || error.code !== "PREFLIGHT_CHANGED") return void 0;
88
+ const body = error.body;
89
+ if (!body || typeof body !== "object" || !("preflight" in body)) return void 0;
90
+ return body.preflight;
91
+ }
92
+
93
+ export {
94
+ getAgentApi,
95
+ postAgentApi,
96
+ patchAgentApi,
97
+ putAgentApi,
98
+ deleteAgentApi,
99
+ uploadAgentApi,
100
+ getAgentBuffer,
101
+ requestResourcePackageApi,
102
+ requestResourcePackageRaw,
103
+ isTransientResourcePackageError,
104
+ resourcePackagePreflightChange
105
+ };
@@ -5,14 +5,14 @@ import {
5
5
  require_node,
6
6
  require_process_nextick_args,
7
7
  require_util
8
- } from "./chunk-S6M42KND.js";
8
+ } from "./chunk-JEUXDY3B.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __esm,
12
12
  __export,
13
13
  __require,
14
14
  __toCommonJS
15
- } from "./chunk-WNGFSIOB.js";
15
+ } from "./chunk-Z3Q2AEIN.js";
16
16
 
17
17
  // node_modules/readdir-glob/node_modules/minimatch/lib/path.js
18
18
  var require_path = __commonJS({
@@ -1,9 +1,4 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
- import {
3
- CapabilityGatewayError,
4
- fetchCapabilityGateway,
5
- requestCapabilityGateway
6
- } from "./chunk-VZZNLV3I.js";
7
2
  import {
8
3
  resolveGatewayDomain
9
4
  } from "./chunk-KPQY44JQ.js";
@@ -11,10 +6,15 @@ import {
11
6
  readOutputMetadata,
12
7
  unwrapOutputData,
13
8
  withOutputMetadata
14
- } from "./chunk-6VNIR4AP.js";
9
+ } from "./chunk-QZLRHGVH.js";
10
+ import {
11
+ CapabilityGatewayError,
12
+ fetchCapabilityGateway,
13
+ requestCapabilityGateway
14
+ } from "./chunk-3SDHJOCR.js";
15
15
  import {
16
16
  PermissionError
17
- } from "./chunk-WNGFSIOB.js";
17
+ } from "./chunk-Z3Q2AEIN.js";
18
18
 
19
19
  // src/core/analysis-async-artifact.ts
20
20
  import { randomBytes } from "crypto";
@@ -5,11 +5,11 @@ import {
5
5
  require_node,
6
6
  require_process_nextick_args,
7
7
  require_util
8
- } from "./chunk-S6M42KND.js";
8
+ } from "./chunk-JEUXDY3B.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __require
12
- } from "./chunk-WNGFSIOB.js";
12
+ } from "./chunk-Z3Q2AEIN.js";
13
13
 
14
14
  // node_modules/jszip/node_modules/readable-stream/lib/internal/streams/stream.js
15
15
  var require_stream = __commonJS({
@@ -0,0 +1,222 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ getPendingHostCompatNotice,
4
+ getPendingUpdateNotice
5
+ } from "./chunk-2UW3Y463.js";
6
+ import {
7
+ logger,
8
+ redactExternalCliToken
9
+ } from "./chunk-Z3Q2AEIN.js";
10
+
11
+ // src/framework/output.ts
12
+ import Table from "cli-table3";
13
+ import { JqError, json as jqJson } from "jq-wasm";
14
+ var KNOWN_ARRAY_FIELDS = [
15
+ "items",
16
+ "events",
17
+ "reports",
18
+ "dashboards",
19
+ "tags",
20
+ "clusters",
21
+ "flows",
22
+ "tasks",
23
+ "channels",
24
+ "nodes",
25
+ "members",
26
+ "records",
27
+ "entities",
28
+ "metrics",
29
+ "tables",
30
+ "columns",
31
+ "properties"
32
+ ];
33
+ var OUTPUT_METADATA = /* @__PURE__ */ Symbol("ae-cli-output-metadata");
34
+ function withOutputMetadata(data, meta) {
35
+ if (!meta || Object.keys(meta).length === 0) return data;
36
+ if (isOutputWithMetadata(data)) {
37
+ return {
38
+ [OUTPUT_METADATA]: true,
39
+ data: data.data,
40
+ meta: { ...data.meta, ...meta }
41
+ };
42
+ }
43
+ return {
44
+ [OUTPUT_METADATA]: true,
45
+ data,
46
+ meta
47
+ };
48
+ }
49
+ function isOutputWithMetadata(value) {
50
+ return Boolean(value?.[OUTPUT_METADATA]);
51
+ }
52
+ function unwrapOutputData(value) {
53
+ return isOutputWithMetadata(value) ? value.data : value;
54
+ }
55
+ function readOutputMetadata(value) {
56
+ return isOutputWithMetadata(value) ? value.meta : void 0;
57
+ }
58
+ function findArrayField(data) {
59
+ if (Array.isArray(data)) return { rows: data };
60
+ if (typeof data !== "object" || data === null) return null;
61
+ for (const key of KNOWN_ARRAY_FIELDS) {
62
+ if (Array.isArray(data[key])) return { key, rows: data[key] };
63
+ }
64
+ for (const key of Object.keys(data)) {
65
+ if (Array.isArray(data[key])) return { key, rows: data[key] };
66
+ }
67
+ return null;
68
+ }
69
+ function formatTable(data) {
70
+ if (Array.isArray(data?.title) && data.title.length > 0 && Array.isArray(data?.rows)) {
71
+ const headers = data.title.map((value) => String(value));
72
+ const table2 = new Table({ head: headers, wordWrap: true });
73
+ for (const row of data.rows) {
74
+ const values = Array.isArray(row) ? row : [row];
75
+ table2.push(headers.map((_header, index) => {
76
+ const value = values[index];
77
+ if (value === void 0 || value === null) return "";
78
+ if (typeof value === "object") return JSON.stringify(value);
79
+ return String(value);
80
+ }));
81
+ }
82
+ return table2.toString();
83
+ }
84
+ const arrayField = findArrayField(data);
85
+ if (!arrayField || arrayField.rows.length === 0) {
86
+ return JSON.stringify(data, null, 2);
87
+ }
88
+ const rows = arrayField.rows;
89
+ const allKeys = /* @__PURE__ */ new Set();
90
+ for (const row of rows) {
91
+ if (typeof row === "object" && row !== null) {
92
+ Object.keys(row).forEach((k) => allKeys.add(k));
93
+ }
94
+ }
95
+ const keys = Array.from(allKeys);
96
+ if (keys.length === 0) return JSON.stringify(rows, null, 2);
97
+ const table = new Table({ head: keys, wordWrap: true });
98
+ for (const row of rows) {
99
+ table.push(keys.map((k) => {
100
+ const v = row?.[k];
101
+ if (v === void 0 || v === null) return "";
102
+ if (typeof v === "object") return JSON.stringify(v);
103
+ return String(v);
104
+ }));
105
+ }
106
+ const sections = [];
107
+ if (arrayField.key && typeof data === "object" && data !== null) {
108
+ const summaryEntries = Object.entries(data).filter(([key]) => key !== arrayField.key);
109
+ if (summaryEntries.length > 0) {
110
+ const summary = new Table({ head: ["field", "value"], wordWrap: true });
111
+ for (const [key, value] of summaryEntries) {
112
+ summary.push([key, typeof value === "object" && value !== null ? JSON.stringify(value) : String(value ?? "")]);
113
+ }
114
+ sections.push(summary.toString());
115
+ }
116
+ }
117
+ sections.push(table.toString());
118
+ return sections.join("\n\n");
119
+ }
120
+ async function applyJq(data, expr) {
121
+ const trimmed = expr.trim();
122
+ if (!trimmed) return data;
123
+ let results;
124
+ try {
125
+ results = await jqJson(data ?? null, trimmed);
126
+ } catch (err) {
127
+ const message = err instanceof JqError ? err.message : err?.message || String(err);
128
+ const error = new Error(`Invalid --jq expression: ${message}`);
129
+ error.type = "validation";
130
+ error.code = "OUTPUT_PROJECTION_FAILED";
131
+ error.hint = "The command completed. Original data and metadata are preserved in stdout; fix the jq expression locally without executing the command again. --jq applies to the command data before envelope wrapping.";
132
+ throw error;
133
+ }
134
+ if (results.length === 0) return null;
135
+ if (results.length === 1) return results[0];
136
+ return results;
137
+ }
138
+ async function formatOutput(data, format, jqExpr) {
139
+ const outputData = isOutputWithMetadata(data) ? data.data : data;
140
+ const meta = isOutputWithMetadata(data) ? data.meta : void 0;
141
+ let processed = outputData;
142
+ if (jqExpr) {
143
+ processed = await applyJq(outputData, jqExpr);
144
+ }
145
+ if (format === "table") {
146
+ return redactExternalCliToken(formatTable(processed));
147
+ }
148
+ const hostCompat = getPendingHostCompatNotice();
149
+ const updateNotice = getPendingUpdateNotice();
150
+ const notices = {
151
+ ...updateNotice ? {} : hostCompat ? { host_compat: hostCompat } : {},
152
+ ...updateNotice ? { update: updateNotice } : {}
153
+ };
154
+ const envelope = {
155
+ ok: true,
156
+ data: processed,
157
+ ...meta ? { meta } : {},
158
+ // Soft tip lives only under _notice (not mirrored into meta) to avoid duplicate fields.
159
+ ...Object.keys(notices).length > 0 ? { _notice: notices } : {}
160
+ };
161
+ return redactExternalCliToken(JSON.stringify(envelope, null, 2));
162
+ }
163
+ function formatError(type, message, hint, code, meta, details) {
164
+ const envelope = {
165
+ ok: false,
166
+ error: { type, message, hint, code, ...details === void 0 ? {} : { details } },
167
+ ...meta && Object.keys(meta).length > 0 ? { meta } : {}
168
+ };
169
+ return redactExternalCliToken(JSON.stringify(envelope, null, 2));
170
+ }
171
+ function printError(type, message, hint, code, meta, options = {}) {
172
+ const formatted = formatError(type, message, hint, code, meta, options.details);
173
+ process.stderr.write(formatted + "\n");
174
+ if (options.log !== false) {
175
+ logger.error(`[${type}] ${message}${hint ? " | " + hint : ""}`);
176
+ }
177
+ }
178
+ function sensitiveRecoveryData(data) {
179
+ const safe = {};
180
+ const item = {};
181
+ if (typeof data?.item?.id === "string") item.id = data.item.id;
182
+ if (Number.isSafeInteger(data?.item?.contentRevision)) item.contentRevision = data.item.contentRevision;
183
+ if (Object.keys(item).length > 0) safe.item = item;
184
+ if (["markdown", "text"].includes(data?.contentFormat)) safe.contentFormat = data.contentFormat;
185
+ if (typeof data?.out === "string") safe.out = data.out;
186
+ return safe;
187
+ }
188
+ async function printOutput(data, format, jqExpr, options = {}) {
189
+ try {
190
+ process.stdout.write(await formatOutput(data, format, jqExpr) + "\n");
191
+ } catch (error) {
192
+ if (error?.code === "OUTPUT_PROJECTION_FAILED") {
193
+ if (options.redactErrors) {
194
+ error.message = "Invalid --jq expression: output projection failed; source content is omitted from diagnostics.";
195
+ error.hint = "The read completed. Fix --jq and explicitly run read-text again without --out, or inspect the file at data.out if present. This error result excludes source content.";
196
+ }
197
+ const recovery = JSON.parse(formatError(
198
+ "validation",
199
+ error.message,
200
+ error.hint,
201
+ error.code,
202
+ options.redactErrors ? void 0 : readOutputMetadata(data)
203
+ ));
204
+ const recoveryData = options.redactErrors ? sensitiveRecoveryData(unwrapOutputData(data)) : unwrapOutputData(data);
205
+ await new Promise((resolve, reject) => {
206
+ process.stdout.write(
207
+ redactExternalCliToken(JSON.stringify({ ...recovery, data: recoveryData }, null, 2)) + "\n",
208
+ (error2) => error2 ? reject(error2) : resolve()
209
+ );
210
+ });
211
+ }
212
+ throw error;
213
+ }
214
+ }
215
+
216
+ export {
217
+ withOutputMetadata,
218
+ unwrapOutputData,
219
+ readOutputMetadata,
220
+ printError,
221
+ printOutput
222
+ };
@@ -3,7 +3,7 @@ import {
3
3
  getAgentApi,
4
4
  patchAgentApi,
5
5
  postAgentApi
6
- } from "./chunk-CI24BDR2.js";
6
+ } from "./chunk-N6XBLRB7.js";
7
7
 
8
8
  // src/commands/memory/cli-client.ts
9
9
  var DEFAULT_TE_CLAUDE_BASE_PATH = "/agent";