@thinkingai/ae-cli 6.0.55 → 6.0.57

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 (169) hide show
  1. package/README.md +35 -6
  2. package/README.zh.md +35 -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-RQBO6MTY.js → auth-YEIJLBFY.js} +61 -19
  7. package/dist/{automation-VAAQBM7Y.js → automation-NAR5DDGL.js} +94 -38
  8. package/dist/{capability-JRIFC4AJ.js → capability-P7DD4Q73.js} +50 -21
  9. package/dist/{chunk-5XJYLEVC.js → chunk-72NJKS7O.js} +4 -4
  10. package/dist/chunk-752BSLZC.js +222 -0
  11. package/dist/{chunk-RGYPSEYD.js → chunk-7ABK2PEJ.js} +3 -3
  12. package/dist/{chunk-Q5US7JC5.js → chunk-7JAVT5TK.js} +3 -3
  13. package/dist/{chunk-GHXZK54S.js → chunk-H3K5UGYC.js} +41 -13
  14. package/dist/{chunk-OP44TT4H.js → chunk-IN7KKL6K.js} +4 -2
  15. package/dist/{chunk-VZZNLV3I.js → chunk-JCWM2TYP.js} +61 -15
  16. package/dist/{chunk-S6M42KND.js → chunk-JEUXDY3B.js} +1 -1
  17. package/dist/{chunk-ZL7SGNIA.js → chunk-JNVVJ273.js} +58 -46
  18. package/dist/chunk-N6XBLRB7.js +105 -0
  19. package/dist/{chunk-AP7YP2NX.js → chunk-OAWPT7VP.js} +2 -2
  20. package/dist/{chunk-7KU2WNQE.js → chunk-QEMQKVHW.js} +37 -15
  21. package/dist/{chunk-CT7QDJS6.js → chunk-QVRIDN42.js} +2 -2
  22. package/dist/{chunk-RPBOAQQQ.js → chunk-QZUVLFNR.js} +1 -1
  23. package/dist/{chunk-3YVEAZUN.js → chunk-RJHGDWSC.js} +32 -21
  24. package/dist/{chunk-374V5R6N.js → chunk-TKVVACEJ.js} +6 -4
  25. package/dist/chunk-TULINOLS.js +2283 -0
  26. package/dist/chunk-YVG6QD3V.js +233 -0
  27. package/dist/{chunk-WNGFSIOB.js → chunk-Z3Q2AEIN.js} +237 -86
  28. package/dist/chunk-ZGIYG473.js +132 -0
  29. package/dist/{community-report-client-PEERQCX2.js → community-report-client-TJVCLZ3K.js} +1 -1
  30. package/dist/compat-check-PMEGUPZU.js +32 -0
  31. package/dist/{config-SICKWZ2A.js → config-VWVPR4WW.js} +43 -10
  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 +343 -79
  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-EMFGUI2W.js → metadata-HEQQEEG3.js} +17 -9
  39. package/dist/{model-VX5M2CJ6.js → model-7UHGWYVR.js} +4 -4
  40. package/dist/{personal-semantic-preference-SLWVVYZ4.js → personal-semantic-preference-V4L6ZWR2.js} +7 -6
  41. package/dist/{project-semantic-DPSZBKQD.js → project-semantic-NKHKJX6M.js} +7 -6
  42. package/dist/{sync-RZIAV37C.js → sync-ZJMXCRIN.js} +8 -7
  43. package/dist/{te-agent-AORRE2FM.js → te-agent-WBKIFEQD.js} +757 -94
  44. package/dist/{te-analysis-ISXKJKRT.js → te-analysis-ADX7RKO4.js} +578 -94
  45. package/dist/{te-community-42M7ICDO.js → te-community-PREDRXG3.js} +722 -228
  46. package/dist/{te-dataops-BNKNZ4F2.js → te-dataops-ITWJHO2U.js} +9 -6
  47. package/dist/{te-engage-BZE3MBKT.js → te-engage-VE2NUH5V.js} +7 -6
  48. package/dist/{te-kb-ULATOTQ3.js → te-kb-WSMOW7WS.js} +407 -83
  49. package/dist/{te-system-UGHVKBVV.js → te-system-YM657FKO.js} +6 -6
  50. package/dist/{te-team-YA6SNOJ3.js → te-team-T2WRLOOD.js} +64 -41
  51. package/dist/{things-DTCOQIQB.js → things-6QOMFXOG.js} +7 -7
  52. package/dist/{update-ESNYKUVR.js → update-I4MOUYOX.js} +11 -7
  53. package/dist/{workspace-JEOHKFPX.js → workspace-LYDAP647.js} +6 -6
  54. package/package.json +25 -11
  55. package/skills/ae-agent/SKILL.md +20 -3
  56. package/skills/ae-agent/references/command_index.md +8 -0
  57. package/skills/ae-agent/references/resource-package.md +57 -0
  58. package/skills/ae-analysis/SKILL.md +23 -10
  59. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  60. package/skills/ae-analysis/references/agent_review_preflight.md +55 -10
  61. package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
  62. package/skills/ae-analysis/references/agent_review_submit_to_page.md +60 -24
  63. package/skills/ae-analysis/references/ai_models/event.md +58 -2
  64. package/skills/ae-analysis/references/ai_models/rank_list.md +1 -0
  65. package/skills/ae-analysis/references/ai_models/retention.md +2 -0
  66. package/skills/ae-analysis/references/ai_models/revenue.md +2 -0
  67. package/skills/ae-analysis/references/analysis_data_export.md +11 -1
  68. package/skills/ae-analysis/references/asset_batch_info_export.md +2 -2
  69. package/skills/ae-analysis/references/asset_batch_sql_export.md +2 -2
  70. package/skills/ae-analysis/references/asset_export.md +1 -1
  71. package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
  72. package/skills/ae-analysis/references/check_export.md +1 -1
  73. package/skills/ae-analysis/references/command_index.md +39 -26
  74. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  75. package/skills/ae-analysis/references/dashboard_report_get.md +6 -2
  76. package/skills/ae-analysis/references/dashboard_report_update.md +24 -5
  77. package/skills/ae-analysis/references/feedback_submit.md +1 -1
  78. package/skills/ae-analysis/references/governance_recommendation_export.md +40 -18
  79. package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
  80. package/skills/ae-analysis/references/live_data_export.md +1 -1
  81. package/skills/ae-analysis/references/metric_create.md +29 -0
  82. package/skills/ae-analysis/references/metric_get.md +2 -0
  83. package/skills/ae-analysis/references/metric_update.md +2 -0
  84. package/skills/ae-analysis/references/operation_record_export.md +1 -1
  85. package/skills/ae-analysis/references/plan_change_log_export.md +1 -1
  86. package/skills/ae-analysis/references/plan_export.md +1 -1
  87. package/skills/ae-analysis/references/project_info_get.md +4 -0
  88. package/skills/ae-analysis/references/project_member_group_add_members.md +35 -0
  89. package/skills/ae-analysis/references/project_member_group_create.md +25 -0
  90. package/skills/ae-analysis/references/project_member_group_delete.md +34 -0
  91. package/skills/ae-analysis/references/project_member_group_list.md +29 -0
  92. package/skills/ae-analysis/references/project_member_group_members.md +28 -0
  93. package/skills/ae-analysis/references/project_member_group_remove_members.md +35 -0
  94. package/skills/ae-analysis/references/project_member_group_rename.md +26 -0
  95. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
  96. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +6 -1
  97. package/skills/ae-analysis/references/report_data_export.md +1 -1
  98. package/skills/ae-analysis/references/scenario_append.md +31 -0
  99. package/skills/ae-analysis/references/scenario_begin.md +11 -0
  100. package/skills/ae-analysis/references/scenario_collect.md +43 -0
  101. package/skills/ae-analysis/references/scenario_evaluation.md +18 -0
  102. package/skills/ae-analysis/references/scenario_get.md +15 -0
  103. package/skills/ae-analysis/references/scenario_list.md +64 -0
  104. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +73 -4
  105. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
  106. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +5 -1
  107. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/execution-contract.mjs +173 -0
  108. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +109 -64
  109. package/skills/ae-automation/SKILL.md +2 -2
  110. package/skills/ae-automation/references/cli.md +18 -1
  111. package/skills/ae-capability/SKILL.md +7 -3
  112. package/skills/ae-community/SKILL.md +77 -27
  113. package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
  114. package/skills/ae-community/references/community-data-quality.md +68 -0
  115. package/skills/ae-community/references/community-query-evidence.md +85 -0
  116. package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
  117. package/skills/ae-community/references/community-weekly-report.md +6 -3
  118. package/skills/ae-community/references/get_channel_info.md +7 -4
  119. package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
  120. package/skills/ae-community/references/get_comments_summary.md +4 -4
  121. package/skills/ae-community/references/get_corpus_tags.md +3 -3
  122. package/skills/ae-community/references/get_daily_summary.md +3 -3
  123. package/skills/ae-community/references/get_hot_topics.md +3 -3
  124. package/skills/ae-community/references/get_livestream_analysis.md +3 -3
  125. package/skills/ae-community/references/get_livestream_detail.md +4 -4
  126. package/skills/ae-community/references/get_livestream_list.md +3 -3
  127. package/skills/ae-community/references/get_livestream_overview.md +3 -3
  128. package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
  129. package/skills/ae-community/references/get_livestream_rooms.md +3 -3
  130. package/skills/ae-community/references/get_overview_metrics.md +3 -3
  131. package/skills/ae-community/references/get_post_detail.md +4 -4
  132. package/skills/ae-community/references/get_risk_content.md +5 -5
  133. package/skills/ae-community/references/get_sentiment_overview.md +4 -4
  134. package/skills/ae-community/references/get_tag_trends.md +3 -3
  135. package/skills/ae-community/references/get_topic_detail.md +3 -3
  136. package/skills/ae-community/references/list_sources.md +28 -0
  137. package/skills/ae-community/references/list_spaces.md +39 -0
  138. package/skills/ae-community/references/search_posts.md +21 -7
  139. package/skills/ae-data-integration/SKILL.md +6 -4
  140. package/skills/ae-data-integration/references/error-handling.md +1 -0
  141. package/skills/ae-data-integration/references/handoff.md +1 -1
  142. package/skills/ae-data-integration/references/sink-upload.md +11 -0
  143. package/skills/ae-data-integration/references/source-inspect.md +2 -1
  144. package/skills/ae-data-integration/references/transform.md +1 -1
  145. package/skills/ae-data-integration/references/ue-mapping.md +1 -1
  146. package/skills/ae-evaluation/SKILL.md +83 -0
  147. package/skills/ae-evaluation/references/access-and-members.md +55 -0
  148. package/skills/ae-evaluation/references/connections.md +78 -0
  149. package/skills/ae-evaluation/references/datasets.md +57 -0
  150. package/skills/ae-evaluation/references/evaluators.md +81 -0
  151. package/skills/ae-evaluation/references/files.md +33 -0
  152. package/skills/ae-evaluation/references/integrations.md +39 -0
  153. package/skills/ae-evaluation/references/runs.md +160 -0
  154. package/skills/ae-evaluation/references/schedules.md +31 -0
  155. package/skills/ae-kb/SKILL.md +33 -6
  156. package/skills/ae-kb/references/publication.md +81 -0
  157. package/skills/ae-kb/references/query-workflow.md +14 -1
  158. package/skills/ae-metadata/SKILL.md +3 -2
  159. package/skills/ae-metadata/references/metadata_data_table_download.md +7 -1
  160. package/skills/ae-metadata/references/metadata_data_table_get.md +37 -0
  161. package/skills/ae-team/SKILL.md +2 -2
  162. package/skills/ae-team/references/run-start.md +1 -0
  163. package/skills/ae-team/references/run-watch.md +7 -5
  164. package/skills/ae-things/SKILL.md +53 -51
  165. package/skills/ae-things/references/cli.md +56 -54
  166. package/skills/ae-things-progress/SKILL.md +20 -20
  167. package/skills/ae-things-review/SKILL.md +19 -19
  168. package/dist/chunk-6VNIR4AP.js +0 -1422
  169. 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,17 +1,21 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  CapabilityGatewayError
4
- } from "./chunk-VZZNLV3I.js";
4
+ } from "./chunk-JCWM2TYP.js";
5
5
  import {
6
6
  SecureStoreAuthError,
7
7
  getCliToken
8
- } from "./chunk-GHXZK54S.js";
8
+ } from "./chunk-H3K5UGYC.js";
9
9
  import {
10
10
  safeJsonParse
11
- } from "./chunk-ZL7SGNIA.js";
11
+ } from "./chunk-JNVVJ273.js";
12
12
  import {
13
- PermissionError
14
- } from "./chunk-WNGFSIOB.js";
13
+ PermissionError,
14
+ externalCliTokenRequestOptions,
15
+ isKbQueryPath,
16
+ kbReadHeaders,
17
+ readKbExecutionContext
18
+ } from "./chunk-Z3Q2AEIN.js";
15
19
 
16
20
  // src/core/mcp-access.ts
17
21
  function buildUrl(host, path, params = {}) {
@@ -170,7 +174,7 @@ function parseKbResponse(resp, text, options = {}) {
170
174
  async function fetchWithCliToken(input, init, cliToken, options = {}) {
171
175
  const headers = new Headers(init.headers);
172
176
  headers.set("cli-token", cliToken);
173
- const resp = await fetch(input, { ...init, headers });
177
+ const resp = await fetch(input, { ...init, headers, ...externalCliTokenRequestOptions(input) });
174
178
  if (options.responseType === "empty" && resp.status === 204) return null;
175
179
  if (options.responseType === "bytes" && resp.ok) {
176
180
  if (resp.headers.get("content-type")?.includes("application/json")) {
@@ -217,18 +221,36 @@ async function getAuthHeaders(ctx) {
217
221
  return { "cli-token": cliToken };
218
222
  }
219
223
  async function kbApi(ctx, method, path, params = {}, body, options = {}) {
220
- const host = ctx.host();
221
224
  const upperMethod = method.toUpperCase();
225
+ const isQuery = isKbQueryPath(upperMethod, path);
226
+ const execution = isQuery ? readKbExecutionContext() : void 0;
227
+ const host = execution ? ctx.hostOverride?.() || execution.origin : ctx.host();
228
+ const selectedHost = execution && !ctx.hostOverride ? ctx.host() : host;
229
+ const url = buildUrl(selectedHost, path, params);
230
+ const queryHeaders = isQuery ? kbReadHeaders(url, ctx.str("read-context")) : void 0;
231
+ const init = {
232
+ method: upperMethod,
233
+ headers: { "Content-Type": "application/json", ...queryHeaders },
234
+ body: upperMethod === "GET" ? void 0 : JSON.stringify(body ?? {})
235
+ };
236
+ if (execution) {
237
+ const response = await fetch(url, { ...init, redirect: "error" });
238
+ const text = await response.text();
239
+ if (!response.ok) {
240
+ let code = "KB_READ_CONTEXT_REQUEST_FAILED";
241
+ try {
242
+ const value = responseErrorMetadata(safeJsonParse(text)).code;
243
+ if (value?.startsWith("KB_READ_CONTEXT_")) code = value;
244
+ } catch {
245
+ }
246
+ throw new KbHttpError(code, code, response.status);
247
+ }
248
+ return parseKbResponse(response, text, { ...options, redactErrorDetails: true });
249
+ }
222
250
  return requestWithCliToken(
223
251
  host,
224
- buildUrl(host, path, params),
225
- {
226
- method: upperMethod,
227
- headers: {
228
- "Content-Type": "application/json"
229
- },
230
- body: upperMethod === "GET" ? void 0 : JSON.stringify(body ?? {})
231
- },
252
+ url,
253
+ init,
232
254
  options
233
255
  );
234
256
  }
@@ -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({
@@ -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";
@@ -4,15 +4,17 @@ import {
4
4
  } from "./chunk-Y74WTIKJ.js";
5
5
  import {
6
6
  getCliToken
7
- } from "./chunk-GHXZK54S.js";
7
+ } from "./chunk-H3K5UGYC.js";
8
8
  import {
9
9
  getActiveHost,
10
10
  getSandboxRuntimeRoot
11
- } from "./chunk-ZL7SGNIA.js";
11
+ } from "./chunk-JNVVJ273.js";
12
12
  import {
13
13
  PermissionError,
14
- isApiErrorType
15
- } from "./chunk-WNGFSIOB.js";
14
+ externalCliTokenRequestOptions,
15
+ isApiErrorType,
16
+ readExternalCliToken
17
+ } from "./chunk-Z3Q2AEIN.js";
16
18
 
17
19
  // src/core/te-agent-credentials.ts
18
20
  import { readFileSync } from "fs";
@@ -153,7 +155,7 @@ async function fetchWithTimeout(url, init, timeoutMs = DEFAULT_TIMEOUT_MS) {
153
155
  const controller = new AbortController();
154
156
  const timer = setTimeout(() => controller.abort(), timeoutMs);
155
157
  try {
156
- return await fetch(url, { ...init, signal: controller.signal });
158
+ return await fetch(url, { ...init, signal: controller.signal, ...externalCliTokenRequestOptions(url) });
157
159
  } catch (err) {
158
160
  if (err?.name === "AbortError") {
159
161
  throw new TeAgentApiError(
@@ -197,7 +199,8 @@ function teClaudeBaseFromActiveHost(hostOverride) {
197
199
  if (!h) return void 0;
198
200
  return resolveTeClaudeBaseUrl(h);
199
201
  }
200
- async function signRequest(method, path2, hostOverride, includeJsonContentType = true) {
202
+ async function signRequest(method, path2, hostOverride, includeJsonContentType = true, authMode = "auto") {
203
+ const external = readExternalCliToken(hostOverride);
201
204
  const configuredHost = hostOverride || getActiveHost();
202
205
  const sandboxOnly = !hostOverride && (/* @__PURE__ */ new Set([
203
206
  "/api/sandbox/models",
@@ -207,8 +210,8 @@ async function signRequest(method, path2, hostOverride, includeJsonContentType =
207
210
  "/api/sandbox/sync/pull",
208
211
  "/api/sandbox/sync/pull/candidates"
209
212
  ])).has(path2.split("?")[0]);
210
- const sandboxCred = configuredHost && !sandboxOnly ? null : tryLoadTeAgentSandboxCredentials();
211
- if (!hostOverride && sandboxCred && sandboxCred.sandboxId && sandboxCred.sandboxSecretKey) {
213
+ const sandboxCred = external || configuredHost && !sandboxOnly ? null : tryLoadTeAgentSandboxCredentials();
214
+ if (authMode === "auto" && !hostOverride && sandboxCred && sandboxCred.sandboxId && sandboxCred.sandboxSecretKey) {
212
215
  const headers = {
213
216
  "X-Sandbox-Id": sandboxCred.sandboxId,
214
217
  "X-Sandbox-Secret-Key": sandboxCred.sandboxSecretKey
@@ -222,7 +225,7 @@ async function signRequest(method, path2, hostOverride, includeJsonContentType =
222
225
  authKind: "sandbox"
223
226
  };
224
227
  }
225
- const baseUrl = hostOverride ? teClaudeBaseFromActiveHost(hostOverride) : sandboxCred?.url || teClaudeBaseFromActiveHost();
228
+ const baseUrl = hostOverride || external ? teClaudeBaseFromActiveHost(hostOverride || external?.url) : sandboxCred?.url || teClaudeBaseFromActiveHost();
226
229
  if (!baseUrl) {
227
230
  throw new TeAgentCredentialsError(
228
231
  "Cannot determine the te-claude service URL",
@@ -248,13 +251,14 @@ async function fetchSigned(options) {
248
251
  options.method,
249
252
  options.path,
250
253
  options.hostOverride,
251
- options.includeJsonContentType
254
+ options.includeJsonContentType,
255
+ options.authMode
252
256
  );
253
257
  return fetchWithTimeout(
254
258
  signed.url,
255
259
  {
256
260
  method: options.method,
257
- headers: signed.headers,
261
+ headers: { ...Object.fromEntries(new Headers(options.headers).entries()), ...signed.headers },
258
262
  body: options.body
259
263
  },
260
264
  options.timeoutMs
@@ -263,7 +267,7 @@ async function fetchSigned(options) {
263
267
  function errorDetails(parsed, defaultErrorPrefix, status) {
264
268
  const nested = parsed && typeof parsed === "object" && parsed.error && typeof parsed.error === "object" ? parsed.error : parsed;
265
269
  const message = typeof parsed?.error === "string" ? parsed.error : typeof nested?.message === "string" ? nested.message : typeof parsed?.message === "string" ? parsed.message : typeof parsed?.return_message === "string" ? parsed.return_message : `${defaultErrorPrefix} ${status}`;
266
- const code = typeof nested?.code === "string" ? nested.code : typeof parsed?.code === "string" ? parsed.code : void 0;
270
+ const code = typeof nested?.code === "string" ? nested.code : typeof parsed?.code === "string" ? parsed.code : typeof parsed?.errorCode === "string" ? parsed.errorCode : void 0;
267
271
  const hint = typeof nested?.hint === "string" ? nested.hint : typeof parsed?.hint === "string" ? parsed.hint : void 0;
268
272
  const declaredType = isApiErrorType(nested?.type) ? nested.type : void 0;
269
273
  const type = status === 401 ? "auth" : status === 403 ? "permission" : declaredType ?? ([400, 413, 422].includes(status) ? "validation" : status === 404 ? "not_found" : "api");
@@ -303,21 +307,23 @@ async function parseResponse(response, defaultErrorPrefix) {
303
307
  }
304
308
  return parsed;
305
309
  }
306
- async function postToMainApp(path2, body, hostOverride) {
310
+ async function postToMainApp(path2, body, hostOverride, authMode = "auto") {
307
311
  const rawBody = JSON.stringify(body);
308
312
  const response = await fetchSigned({
309
313
  method: "POST",
310
314
  path: path2,
311
315
  body: rawBody,
312
- hostOverride
316
+ hostOverride,
317
+ authMode
313
318
  });
314
319
  return parseResponse(response, "Main app returned");
315
320
  }
316
- async function getFromMainApp(path2, hostOverride) {
321
+ async function getFromMainApp(path2, hostOverride, authMode = "auto") {
317
322
  const response = await fetchSigned({
318
323
  method: "GET",
319
324
  path: path2,
320
- hostOverride
325
+ hostOverride,
326
+ authMode
321
327
  });
322
328
  return parseResponse(response, "Main app returned");
323
329
  }
@@ -347,21 +353,23 @@ async function postSandboxSyncPull(args) {
347
353
  mode: "merge"
348
354
  });
349
355
  }
350
- async function deleteFromMainApp(path2, hostOverride) {
356
+ async function deleteFromMainApp(path2, hostOverride, authMode = "auto") {
351
357
  const response = await fetchSigned({
352
358
  method: "DELETE",
353
359
  path: path2,
354
- hostOverride
360
+ hostOverride,
361
+ authMode
355
362
  });
356
363
  return parseResponse(response, "Main app returned");
357
364
  }
358
- async function patchToMainApp(path2, body, hostOverride) {
365
+ async function patchToMainApp(path2, body, hostOverride, authMode = "auto") {
359
366
  const rawBody = JSON.stringify(body);
360
367
  const response = await fetchSigned({
361
368
  method: "PATCH",
362
369
  path: path2,
363
370
  body: rawBody,
364
- hostOverride
371
+ hostOverride,
372
+ authMode
365
373
  });
366
374
  return parseResponse(response, "Main app returned");
367
375
  }
@@ -447,7 +455,8 @@ async function downloadFromMainApp(requestPath, outputPath, hostOverride) {
447
455
  return await fetch(requestToSend.url, {
448
456
  method: "GET",
449
457
  headers: requestToSend.headers,
450
- signal: controller.signal
458
+ signal: controller.signal,
459
+ ...externalCliTokenRequestOptions(requestToSend.url)
451
460
  });
452
461
  } catch (error) {
453
462
  if (error?.name === "AbortError") {
@@ -519,7 +528,9 @@ export {
519
528
  getClaudeConfigDir,
520
529
  resolveTeClaudeBaseUrl,
521
530
  TeAgentApiError,
531
+ fetchSigned,
522
532
  createTeAgentApiError,
533
+ parseResponse,
523
534
  postToMainApp,
524
535
  getFromMainApp,
525
536
  getSandboxModels,
@@ -6,13 +6,16 @@ import {
6
6
  dryRunCapability,
7
7
  executeCapabilityWithEnvelope,
8
8
  validateCapability
9
- } from "./chunk-VZZNLV3I.js";
9
+ } from "./chunk-JCWM2TYP.js";
10
10
  import {
11
11
  withOutputMetadata
12
- } from "./chunk-6VNIR4AP.js";
12
+ } from "./chunk-752BSLZC.js";
13
13
  import {
14
14
  CliValidationError
15
- } from "./chunk-WNGFSIOB.js";
15
+ } from "./chunk-Z3Q2AEIN.js";
16
+
17
+ // src/core/capability-command.ts
18
+ import { randomBytes } from "crypto";
16
19
 
17
20
  // src/core/definition-intent.ts
18
21
  import { createHash } from "crypto";
@@ -83,7 +86,6 @@ function isRecord(value) {
83
86
  }
84
87
 
85
88
  // src/core/capability-command.ts
86
- import { randomBytes } from "crypto";
87
89
  function createCapabilityCommand(config) {
88
90
  return {
89
91
  service: config.cliService,