@thinkingai/ae-cli 6.0.18 → 6.0.22

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 (110) hide show
  1. package/README.md +8 -10
  2. package/README.zh.md +9 -11
  3. package/dist/{auth-DYC2BGLM.js → auth-I2G7OAU2.js} +2 -4
  4. package/dist/{auth-GHBMJ5ZR.js → auth-RDN6D5HU.js} +32 -104
  5. package/dist/{chunk-5OC7CYCG.js → chunk-2W7HULUD.js} +14 -14
  6. package/dist/chunk-4EUZRJPO.js +163 -0
  7. package/dist/{chunk-DMMEPCST.js → chunk-5FBLRSMU.js} +25 -115
  8. package/dist/{chunk-BJX3GXWC.js → chunk-E34XH4GW.js} +2 -2
  9. package/dist/chunk-FPE5LGVU.js +105 -0
  10. package/dist/{chunk-I5CRVM2S.js → chunk-H52CSLJW.js} +44 -17
  11. package/dist/{chunk-RSHMZ3LG.js → chunk-U6QPKCN3.js} +6 -20
  12. package/dist/{chunk-6W4QOZAL.js → chunk-WPXHCP4A.js} +23 -13
  13. package/dist/{chunk-PN3OS34E.js → chunk-XE2PI5DS.js} +1 -1
  14. package/dist/{chunk-2DUEAXV3.js → chunk-YACCPUNQ.js} +1 -1
  15. package/dist/cli-token-6AGEDJF4.js +14 -0
  16. package/dist/{client-2UJ63MVQ.js → client-VTJMUZ4O.js} +3 -3
  17. package/dist/{config-NCUGK6NS.js → config-2SDTLGOC.js} +3 -3
  18. package/dist/index.js +314 -197
  19. package/dist/metadata-JZ2OTWBK.js +420 -0
  20. package/dist/{model-SJSOZTRS.js → model-ZYMRN4VS.js} +2 -2
  21. package/dist/{raw-7NVWSVJP.js → raw-NGYHAL3F.js} +4 -4
  22. package/dist/{sync-GRVO4K3U.js → sync-JVLX6TGW.js} +3 -3
  23. package/dist/{te-agent-KZRIEN4N.js → te-agent-QPZTLHPH.js} +545 -21
  24. package/dist/{te-analysis-VAR4KUOK.js → te-analysis-WWX3Z6RP.js} +352 -52
  25. package/dist/te-audience-UXGHUVBB.js +599 -0
  26. package/dist/{te-common-WNCZB7R7.js → te-common-7XXH73MF.js} +5 -4
  27. package/dist/{te-community-JEEFXPB3.js → te-community-QKE67HR2.js} +5 -4
  28. package/dist/te-dataops-6W7NNYST.js +1841 -0
  29. package/dist/{te-engage-4XHCTS6I.js → te-engage-NCFAQFX3.js} +5 -4
  30. package/dist/{te-kb-B62KFP2A.js → te-kb-K5BQYUCM.js} +50 -26
  31. package/dist/{te-meta-EPZGQN56.js → te-meta-LJZBOSMO.js} +48 -24
  32. package/dist/{te-team-YY24VORI.js → te-team-DHK5R7MV.js} +5 -6
  33. package/package.json +3 -2
  34. package/skills/ae-agent/SKILL.md +103 -4
  35. package/skills/ae-analysis/SKILL.md +75 -21
  36. package/skills/ae-analysis/references/build_attribution_analysis_qp.md +62 -0
  37. package/skills/ae-analysis/references/build_cluster_definition.md +62 -0
  38. package/skills/ae-analysis/references/build_distribution_analysis_qp.md +67 -0
  39. package/skills/ae-analysis/references/build_event_analysis_qp.md +2 -0
  40. package/skills/ae-analysis/references/build_funnel_analysis_qp.md +2 -0
  41. package/skills/ae-analysis/references/build_heat_map_analysis_qp.md +54 -0
  42. package/skills/ae-analysis/references/build_interval_analysis_qp.md +60 -0
  43. package/skills/ae-analysis/references/build_path_analysis_qp.md +53 -0
  44. package/skills/ae-analysis/references/build_prop_analysis_qp.md +2 -0
  45. package/skills/ae-analysis/references/build_rank_list_analysis_qp.md +63 -0
  46. package/skills/ae-analysis/references/build_retention_analysis_qp.md +2 -0
  47. package/skills/ae-analysis/references/build_tag_definition.md +65 -0
  48. package/skills/ae-analysis/references/cancel_query.md +2 -3
  49. package/skills/ae-analysis/references/copy_dashboard.md +33 -0
  50. package/skills/ae-analysis/references/create_id_cluster.md +40 -0
  51. package/skills/ae-analysis/references/create_id_tag.md +39 -0
  52. package/skills/ae-analysis/references/delete_alert.md +27 -0
  53. package/skills/ae-analysis/references/delete_cluster.md +27 -0
  54. package/skills/ae-analysis/references/delete_dashboard.md +30 -0
  55. package/skills/ae-analysis/references/delete_metric.md +27 -0
  56. package/skills/ae-analysis/references/delete_report.md +27 -0
  57. package/skills/ae-analysis/references/delete_tag.md +27 -0
  58. package/skills/ae-analysis/references/drilldown_user_events.md +4 -4
  59. package/skills/ae-analysis/references/drilldown_users.md +3 -3
  60. package/skills/ae-analysis/references/freeze_dashboards.md +29 -0
  61. package/skills/ae-analysis/references/get_table_columns.md +11 -12
  62. package/skills/ae-analysis/references/list_cluster_members.md +4 -4
  63. package/skills/ae-analysis/references/list_clusters.md +5 -3
  64. package/skills/ae-analysis/references/list_dashboards.md +3 -3
  65. package/skills/ae-analysis/references/list_entities.md +1 -1
  66. package/skills/ae-analysis/references/list_events.md +7 -4
  67. package/skills/ae-analysis/references/list_metrics.md +5 -3
  68. package/skills/ae-analysis/references/list_properties.md +6 -4
  69. package/skills/ae-analysis/references/list_reports.md +3 -3
  70. package/skills/ae-analysis/references/list_spaces.md +27 -0
  71. package/skills/ae-analysis/references/list_tag_members.md +4 -4
  72. package/skills/ae-analysis/references/list_tags.md +4 -2
  73. package/skills/ae-analysis/references/move_dashboard.md +33 -0
  74. package/skills/ae-analysis/references/query_adhoc.md +2 -2
  75. package/skills/ae-analysis/references/query_bi_panel_data.md +2 -2
  76. package/skills/ae-analysis/references/query_dashboard_report_data.md +4 -4
  77. package/skills/ae-analysis/references/query_entity_details.md +4 -4
  78. package/skills/ae-analysis/references/query_event_details.md +3 -3
  79. package/skills/ae-analysis/references/query_report_data.md +37 -3
  80. package/skills/ae-analysis/references/update_id_cluster.md +36 -0
  81. package/skills/ae-analysis/references/update_id_tag.md +37 -0
  82. package/skills/ae-analysis/references/update_report.md +35 -0
  83. package/skills/ae-analysis-intent/SKILL.md +1 -1
  84. package/skills/ae-dataops/SKILL.md +54 -522
  85. package/skills/ae-dataops/references/dataops-flow-create.md +78 -75
  86. package/skills/ae-dataops/references/dataops-flow-monitor.md +58 -51
  87. package/skills/ae-dataops/references/dataops-integration.md +80 -41
  88. package/skills/ae-dataops/references/dataops-query.md +54 -53
  89. package/skills/ae-dataops/references/dataops-table.md +28 -59
  90. package/skills/ae-generate-tracking-code/SKILL.md +68 -31
  91. package/skills/ae-generate-tracking-code/references/snippet-delivery.md +26 -1
  92. package/skills/ae-generate-tracking-code/references/te-api.md +47 -164
  93. package/skills/ae-generate-tracking-plan/SKILL.md +109 -32
  94. package/skills/ae-generate-tracking-plan/references/te-api.md +57 -27
  95. package/skills/ae-metadata/SKILL.md +90 -0
  96. package/skills/ae-metadata/references/metadata_data_table_csv_delete.md +15 -0
  97. package/skills/ae-metadata/references/metadata_data_table_csv_write.md +29 -0
  98. package/skills/ae-metadata/references/metadata_data_table_download.md +17 -0
  99. package/skills/ae-metadata/references/metadata_data_table_get.md +24 -0
  100. package/skills/ae-metadata/references/metadata_data_table_list.md +27 -0
  101. package/skills/ae-metadata/references/metadata_data_table_property_bindings_update.md +17 -0
  102. package/skills/ae-metadata/references/metadata_data_table_sql_delete.md +15 -0
  103. package/skills/ae-metadata/references/metadata_data_table_sql_write.md +31 -0
  104. package/skills/ae-metadata/references/metadata_event_get.md +52 -0
  105. package/skills/ae-metadata/references/metadata_input_file_upload.md +29 -0
  106. package/skills/ae-metadata/references/metadata_property_dimension_table_bind_existing.md +27 -0
  107. package/skills/ae-metadata/references/metadata_property_dimension_table_create_and_bind_csv.md +30 -0
  108. package/skills/ae-metadata/references/metadata_property_get.md +54 -0
  109. package/dist/te-audience-KMKYI2YJ.js +0 -400
  110. package/dist/te-dataops-GD3XBYCS.js +0 -1830
@@ -1,19 +1,18 @@
1
1
  import {
2
2
  getAnalysisMappingPathForClusterMode
3
- } from "./chunk-PN3OS34E.js";
3
+ } from "./chunk-XE2PI5DS.js";
4
4
  import {
5
5
  PermissionError
6
6
  } from "./chunk-NOO24N7W.js";
7
7
  import {
8
- getToken,
9
- loadMcpToken
10
- } from "./chunk-RSHMZ3LG.js";
8
+ clearCliToken,
9
+ getCliToken
10
+ } from "./chunk-FPE5LGVU.js";
11
11
  import {
12
12
  getActiveHost,
13
- getFallbackMcpToken,
14
13
  logger,
15
14
  safeJsonParse
16
- } from "./chunk-6W4QOZAL.js";
15
+ } from "./chunk-WPXHCP4A.js";
17
16
 
18
17
  // src/core/mcp.ts
19
18
  async function permissionMessage(resp) {
@@ -26,6 +25,9 @@ async function permissionMessage(resp) {
26
25
  }
27
26
  return "Permission denied for this resource (HTTP 403)";
28
27
  }
28
+ function isInvalidCliTokenMessage(message) {
29
+ return /\b(cli[-_\s]?token|token)\b.*\binvalid\b/i.test(message) || /\binvalid\b.*\b(cli[-_\s]?token|token)\b/i.test(message);
30
+ }
29
31
  var MCP_PROTOCOL_VERSION = "2025-11-25";
30
32
  var JSONRPC_VERSION = "2.0";
31
33
  var serviceMappingMap = /* @__PURE__ */ new Map();
@@ -70,104 +72,14 @@ var requestIdCounter = 1;
70
72
  function genRequestId() {
71
73
  return requestIdCounter++;
72
74
  }
73
- var MCP_TOKEN_GENERATE_PATH = "/v1/ta/mcp/token/generate";
74
- var _mcpTokenCache = /* @__PURE__ */ new Map();
75
- async function generateMcpToken(hostUrl) {
76
- const teToken = await getToken(hostUrl);
77
- const base = hostUrl.replace(/\/+$/, "");
78
- const url = `${base}${MCP_TOKEN_GENERATE_PATH}`;
79
- const resp = await fetch(url, {
80
- method: "GET",
81
- headers: {
82
- "Authorization": `bearer ${teToken}`
83
- }
84
- });
85
- if (!resp.ok) {
86
- throw new Error(`MCP token generate HTTP error: ${resp.status} ${resp.statusText}`);
87
- }
88
- const data = safeJsonParse(await resp.text());
89
- if (data.return_code !== 0) {
90
- throw new Error(`MCP token generate error: ${data.return_message || "unknown"} (code: ${data.return_code})`);
91
- }
92
- const mcpToken = data.data?.userSecret;
93
- if (!mcpToken) {
94
- throw new Error("MCP token generate error: empty userSecret in response");
95
- }
96
- return mcpToken;
97
- }
98
- async function getMcpToken(hostOverride) {
99
- const hostUrl = hostOverride || getActiveHost();
100
- const cached = _mcpTokenCache.get(hostUrl);
101
- if (cached) {
102
- return cached;
103
- }
104
- const storedToken = loadMcpToken(hostUrl);
105
- if (storedToken) {
106
- _mcpTokenCache.set(hostUrl, storedToken);
107
- logger.info(`Using persisted MCP token (secure-store) for ${hostUrl}`);
108
- return storedToken;
109
- }
110
- const fallbackToken = getFallbackMcpToken(hostUrl);
111
- if (fallbackToken) {
112
- _mcpTokenCache.set(hostUrl, fallbackToken);
113
- logger.info(`Using sandbox-provisioned MCP token (fallback file) for ${hostUrl}`);
114
- return fallbackToken;
115
- }
116
- logger.info(`Generating MCP token for ${hostUrl}`);
117
- const mcpToken = await generateMcpToken(hostUrl);
118
- _mcpTokenCache.set(hostUrl, mcpToken);
119
- logger.info(`MCP token generated and in-process cached for ${hostUrl}`);
120
- return mcpToken;
121
- }
122
- function clearMcpToken(hostUrl) {
123
- if (hostUrl) {
124
- _mcpTokenCache.delete(hostUrl);
125
- } else {
126
- _mcpTokenCache.clear();
127
- }
128
- }
129
- function setMcpTokenManual(token, hostUrl) {
130
- _mcpTokenCache.set(hostUrl, token);
131
- logger.info(`MCP token manually set (in-process) for ${hostUrl}`);
132
- }
133
- async function validateMcpToken(token, hostUrl) {
134
- const mapping = getMcpMapping("analysis");
135
- const base = hostUrl.replace(/\/+$/, "");
136
- const url = `${base}/mcp/${mapping.componentName}/http/${mapping.mappingPath}`;
137
- const requestId = 1;
138
- const body = {
139
- jsonrpc: JSONRPC_VERSION,
140
- id: requestId,
141
- method: "tools/list",
142
- params: { _meta: { progressToken: requestId } }
143
- };
144
- const headers = {
145
- "Content-Type": "application/json",
146
- "Accept": "application/json, text/event-stream",
147
- "mcp-protocol-version": MCP_PROTOCOL_VERSION,
148
- "mcp-token": token
75
+ function buildAuthHeaders(cliToken) {
76
+ return {
77
+ "cli-token": cliToken
149
78
  };
150
- try {
151
- const resp = await fetch(url, {
152
- method: "POST",
153
- headers,
154
- body: JSON.stringify(body)
155
- });
156
- if (!resp.ok) {
157
- return false;
158
- }
159
- const data = safeJsonParse(await resp.text());
160
- if (data.error) {
161
- return false;
162
- }
163
- return data.result?.tools !== void 0;
164
- } catch {
165
- return false;
166
- }
167
79
  }
168
80
  async function mcpRequest(url, method, params = {}, hostOverride) {
169
81
  const hostUrl = hostOverride || getActiveHost();
170
- const token = await getMcpToken(hostUrl);
82
+ const token = await getCliToken(hostUrl);
171
83
  const requestId = genRequestId();
172
84
  const paramsWithMeta = {
173
85
  ...params,
@@ -183,7 +95,7 @@ async function mcpRequest(url, method, params = {}, hostOverride) {
183
95
  "Content-Type": "application/json",
184
96
  "Accept": "application/json, text/event-stream",
185
97
  "mcp-protocol-version": MCP_PROTOCOL_VERSION,
186
- "mcp-token": token
98
+ ...buildAuthHeaders(token)
187
99
  };
188
100
  const resp = await fetch(url, {
189
101
  method: "POST",
@@ -191,19 +103,21 @@ async function mcpRequest(url, method, params = {}, hostOverride) {
191
103
  body: JSON.stringify(body)
192
104
  });
193
105
  if (!resp.ok) {
106
+ let permissionMsg;
194
107
  if (resp.status === 403) {
195
- throw new PermissionError(await permissionMessage(resp));
108
+ permissionMsg = await permissionMessage(resp);
109
+ if (!isInvalidCliTokenMessage(permissionMsg)) {
110
+ throw new PermissionError(permissionMsg);
111
+ }
196
112
  }
197
- if (resp.status === 401) {
198
- logger.warn(`MCP request failed (HTTP 401) for ${hostUrl}, re-minting token`);
199
- _mcpTokenCache.delete(hostUrl);
200
- const fallbackToken = getFallbackMcpToken(hostUrl);
201
- const newToken = fallbackToken ?? await generateMcpToken(hostUrl);
202
- _mcpTokenCache.set(hostUrl, newToken);
203
- logger.info(`MCP token re-minted for ${hostUrl}`);
204
- process.stderr.write(`[ae-cli] MCP token re-minted for ${hostUrl}
113
+ if (resp.status === 401 || resp.status === 403 && permissionMsg) {
114
+ logger.warn(`MCP request failed (${resp.status === 403 ? permissionMsg : "HTTP 401"}) for ${hostUrl}, refreshing CLI token`);
115
+ clearCliToken(hostUrl);
116
+ const newToken = await getCliToken(hostUrl);
117
+ logger.info(`CLI token refreshed for ${hostUrl}`);
118
+ process.stderr.write(`[ae-cli] CLI token refreshed for ${hostUrl}
205
119
  `);
206
- headers["mcp-token"] = newToken;
120
+ Object.assign(headers, buildAuthHeaders(newToken));
207
121
  const retryResp = await fetch(url, {
208
122
  method: "POST",
209
123
  headers,
@@ -289,10 +203,6 @@ function mcpResultErrorMessage(parsed) {
289
203
  export {
290
204
  registerMcpMappings,
291
205
  resolveMcpUrl,
292
- getMcpToken,
293
- clearMcpToken,
294
- setMcpTokenManual,
295
- validateMcpToken,
296
206
  callMcpTool,
297
207
  parseMcpResult
298
208
  };
@@ -3,11 +3,11 @@ import {
3
3
  clearToken,
4
4
  getToken,
5
5
  resolveHost
6
- } from "./chunk-RSHMZ3LG.js";
6
+ } from "./chunk-U6QPKCN3.js";
7
7
  import {
8
8
  logger,
9
9
  safeJsonParse
10
- } from "./chunk-6W4QOZAL.js";
10
+ } from "./chunk-WPXHCP4A.js";
11
11
 
12
12
  // src/core/client.ts
13
13
  import WebSocket from "ws";
@@ -0,0 +1,105 @@
1
+ import {
2
+ getToken,
3
+ load,
4
+ loadCliToken,
5
+ save
6
+ } from "./chunk-U6QPKCN3.js";
7
+ import {
8
+ getActiveHost,
9
+ getFallbackCliToken,
10
+ listHosts,
11
+ logger,
12
+ safeJsonParse
13
+ } from "./chunk-WPXHCP4A.js";
14
+
15
+ // src/core/cli-token.ts
16
+ var CLI_TOKEN_GENERATE_PATH = "/v1/ta/cli/token/generate";
17
+ var _cliTokenCache = /* @__PURE__ */ new Map();
18
+ async function generateCliToken(hostUrl) {
19
+ const accessToken = await getToken(hostUrl);
20
+ const base = hostUrl.replace(/\/+$/, "");
21
+ const url = `${base}${CLI_TOKEN_GENERATE_PATH}`;
22
+ const resp = await fetch(url, {
23
+ method: "GET",
24
+ headers: {
25
+ "Authorization": `bearer ${accessToken}`
26
+ }
27
+ });
28
+ if (!resp.ok) {
29
+ throw new Error(`CLI token generate HTTP error: ${resp.status} ${resp.statusText}`);
30
+ }
31
+ const data = safeJsonParse(await resp.text());
32
+ if (data.return_code !== 0) {
33
+ throw new Error(`CLI token generate error: ${data.return_message || "unknown"} (code: ${data.return_code})`);
34
+ }
35
+ const cliToken = data.data?.userSecret;
36
+ if (!cliToken) {
37
+ throw new Error("CLI token generate error: empty userSecret in response");
38
+ }
39
+ return cliToken;
40
+ }
41
+ function persistCliTokenIfPossible(hostUrl, cliToken) {
42
+ const existing = load(hostUrl);
43
+ if (!existing) {
44
+ logger.info(`cli-token: no secure-store session for ${hostUrl}, keeping token in-process only`);
45
+ return;
46
+ }
47
+ save(hostUrl, { ...existing, cliToken });
48
+ }
49
+ function clearPersistedCliToken(hostUrl) {
50
+ const existing = load(hostUrl);
51
+ if (existing?.cliToken) {
52
+ save(hostUrl, { ...existing, cliToken: void 0 });
53
+ }
54
+ }
55
+ async function getCliToken(hostOverride) {
56
+ const hostUrl = hostOverride || getActiveHost();
57
+ const cached = _cliTokenCache.get(hostUrl);
58
+ if (cached) {
59
+ return cached;
60
+ }
61
+ const storedToken = loadCliToken(hostUrl);
62
+ if (storedToken) {
63
+ _cliTokenCache.set(hostUrl, storedToken);
64
+ logger.info(`Using persisted CLI token (secure-store) for ${hostUrl}`);
65
+ return storedToken;
66
+ }
67
+ const fallbackToken = getFallbackCliToken(hostUrl);
68
+ if (fallbackToken) {
69
+ _cliTokenCache.set(hostUrl, fallbackToken);
70
+ logger.info(`Using sandbox-provisioned CLI token (fallback file) for ${hostUrl}`);
71
+ return fallbackToken;
72
+ }
73
+ return mintCliToken(hostUrl);
74
+ }
75
+ async function mintCliToken(hostUrl) {
76
+ logger.info(`Generating CLI token for ${hostUrl}`);
77
+ const cliToken = await generateCliToken(hostUrl);
78
+ _cliTokenCache.set(hostUrl, cliToken);
79
+ persistCliTokenIfPossible(hostUrl, cliToken);
80
+ logger.info(`CLI token generated, cached, and persisted for ${hostUrl}`);
81
+ return cliToken;
82
+ }
83
+ function clearCliToken(hostUrl) {
84
+ if (hostUrl) {
85
+ _cliTokenCache.delete(hostUrl);
86
+ clearPersistedCliToken(hostUrl);
87
+ return;
88
+ }
89
+ _cliTokenCache.clear();
90
+ for (const { url } of listHosts()) {
91
+ clearPersistedCliToken(url);
92
+ }
93
+ }
94
+ function setCliTokenManual(token, hostUrl) {
95
+ _cliTokenCache.set(hostUrl, token);
96
+ persistCliTokenIfPossible(hostUrl, token);
97
+ logger.info(`CLI token set for ${hostUrl}`);
98
+ }
99
+
100
+ export {
101
+ getCliToken,
102
+ mintCliToken,
103
+ clearCliToken,
104
+ setCliTokenManual
105
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getActiveHost,
3
3
  getSandboxRuntimeRoot
4
- } from "./chunk-6W4QOZAL.js";
4
+ } from "./chunk-WPXHCP4A.js";
5
5
 
6
6
  // src/core/te-agent-credentials.ts
7
7
  import { readFileSync } from "fs";
@@ -134,39 +134,66 @@ function teClaudeBaseFromActiveHost() {
134
134
  async function signRequest(method, path, rawBody) {
135
135
  const sandboxCred = tryLoadTeAgentSandboxCredentials();
136
136
  if (sandboxCred && sandboxCred.sandboxId && sandboxCred.sandboxSecretKey) {
137
- const headers2 = {
137
+ const headers = {
138
138
  "X-Sandbox-Id": sandboxCred.sandboxId,
139
139
  "X-Sandbox-Secret-Key": sandboxCred.sandboxSecretKey
140
140
  };
141
141
  if (method === "POST" || method === "PATCH") {
142
- headers2["Content-Type"] = "application/json";
142
+ headers["Content-Type"] = "application/json";
143
143
  }
144
144
  return {
145
145
  url: `${sandboxCred.url.replace(/\/$/, "")}${path}`,
146
- headers: headers2,
146
+ headers,
147
147
  rawBody
148
148
  };
149
149
  }
150
- const { getToken } = await import("./auth-DYC2BGLM.js");
150
+ const { getToken } = await import("./auth-I2G7OAU2.js");
151
+ const { getCliToken } = await import("./cli-token-6AGEDJF4.js");
151
152
  const baseUrl = sandboxCred?.url || teClaudeBaseFromActiveHost();
153
+ const hostForToken = getActiveHost() || baseUrl;
152
154
  if (!baseUrl) {
153
155
  throw new TeAgentCredentialsError(
154
156
  "Cannot determine the te-claude service URL",
155
157
  "Run ae-cli config set-host <url> to configure the service URL, or execute inside a te-agent sandbox"
156
158
  );
157
159
  }
158
- const accessToken = await getToken(getActiveHost() || baseUrl);
159
- const headers = {
160
- "Authorization": `bearer ${accessToken}`
161
- };
162
- if (method === "POST" || method === "PATCH") {
163
- headers["Content-Type"] = "application/json";
160
+ const contentTypeHeader = method === "POST" || method === "PATCH" ? { "Content-Type": "application/json" } : {};
161
+ let accessToken = null;
162
+ try {
163
+ accessToken = await getToken(hostForToken);
164
+ } catch {
165
+ accessToken = null;
164
166
  }
165
- return {
166
- url: `${baseUrl.replace(/\/$/, "")}${path}`,
167
- headers,
168
- rawBody
169
- };
167
+ if (accessToken) {
168
+ return {
169
+ url: `${baseUrl.replace(/\/$/, "")}${path}`,
170
+ headers: {
171
+ "Authorization": `bearer ${accessToken}`,
172
+ ...contentTypeHeader
173
+ },
174
+ rawBody
175
+ };
176
+ }
177
+ let cliToken = null;
178
+ try {
179
+ cliToken = await getCliToken(hostForToken);
180
+ } catch {
181
+ cliToken = null;
182
+ }
183
+ if (cliToken) {
184
+ return {
185
+ url: `${baseUrl.replace(/\/$/, "")}${path}`,
186
+ headers: {
187
+ "cli-token": cliToken,
188
+ ...contentTypeHeader
189
+ },
190
+ rawBody
191
+ };
192
+ }
193
+ throw new TeAgentCredentialsError(
194
+ "No te-claude credentials available",
195
+ "Run ae-cli auth login, or execute inside a te-agent sandbox"
196
+ );
170
197
  }
171
198
  async function parseResponse(response, defaultErrorPrefix) {
172
199
  const text = await response.text();
@@ -266,7 +293,7 @@ async function uploadToMainApp(path, formData) {
266
293
  "X-Sandbox-Secret-Key": sandboxCred.sandboxSecretKey
267
294
  };
268
295
  } else {
269
- const { getToken } = await import("./auth-DYC2BGLM.js");
296
+ const { getToken } = await import("./auth-I2G7OAU2.js");
270
297
  baseUrl = (sandboxCred?.url || teClaudeBaseFromActiveHost() || "").replace(/\/$/, "");
271
298
  if (!baseUrl) {
272
299
  throw new TeAgentCredentialsError(
@@ -4,7 +4,7 @@ import {
4
4
  logger,
5
5
  safeJsonParse,
6
6
  safeReadJsonFile
7
- } from "./chunk-6W4QOZAL.js";
7
+ } from "./chunk-WPXHCP4A.js";
8
8
 
9
9
  // src/core/auth.ts
10
10
  import fs2 from "fs";
@@ -170,15 +170,15 @@ async function getValidAccessToken(host) {
170
170
  if (payload.refreshToken) {
171
171
  logger.info(`secure-store: access token past local expiry for ${host}, refreshing\u2026`);
172
172
  const refreshed = await doRefresh(host, payload.refreshToken);
173
- save(host, { ...refreshed, mcpToken: payload.mcpToken });
173
+ save(host, { ...refreshed, cliToken: payload.cliToken });
174
174
  logger.info(`secure-store: token refreshed for ${host}`);
175
175
  return refreshed.accessToken;
176
176
  }
177
177
  logger.info(`secure-store: ${host} past static local expiry, no refresh token \u2014 returning stored token, server validates (lazy)`);
178
178
  return payload.accessToken;
179
179
  }
180
- function loadMcpToken(host) {
181
- return load(host)?.mcpToken ?? null;
180
+ function loadCliToken(host) {
181
+ return load(host)?.cliToken ?? null;
182
182
  }
183
183
  async function doRefresh(host, refreshToken) {
184
184
  const base = host.replace(/\/+$/, "");
@@ -345,13 +345,7 @@ function clearToken(hostUrl) {
345
345
  delete tokens[hostUrl];
346
346
  saveAllTokens(tokens);
347
347
  }
348
- function setTokenManual(token, hostUrl) {
349
- saveToken(token, hostUrl);
350
- }
351
348
  function getAuthStatus(hostUrl) {
352
- if (process.env.TE_TOKEN) {
353
- return { authenticated: true, host: hostUrl, source: "env:TE_TOKEN" };
354
- }
355
349
  const cached = loadToken(hostUrl);
356
350
  if (cached) {
357
351
  const ageMs = Date.now() - new Date(cached.updatedAt).getTime();
@@ -367,10 +361,6 @@ async function getToken(hostUrl) {
367
361
  Run: ae-cli config set-host <url>`
368
362
  );
369
363
  }
370
- if (process.env.TE_TOKEN) {
371
- logger.info("Using token from env:TE_TOKEN");
372
- return process.env.TE_TOKEN;
373
- }
374
364
  const cached = loadToken(hostUrl);
375
365
  if (cached && cached.token) {
376
366
  logger.info(`Using cached token for ${hostUrl}`);
@@ -389,10 +379,7 @@ Run: ae-cli config set-host <url>`
389
379
  }
390
380
  throw new Error(
391
381
  `Cannot obtain token for ${hostUrl}.
392
- Options:
393
- 1. ae-cli auth login (device code flow, cross-platform)
394
- 2. ae-cli auth set-token <token>
395
- 3. export TE_TOKEN=<token> (CI/headless)`
382
+ Run: ae-cli auth login (device code flow, cross-platform)`
396
383
  );
397
384
  }
398
385
 
@@ -400,14 +387,13 @@ export {
400
387
  save,
401
388
  load,
402
389
  clear,
403
- loadMcpToken,
390
+ loadCliToken,
404
391
  SecureStoreAuthError,
405
392
  resolveHost,
406
393
  validateToken,
407
394
  loadToken,
408
395
  saveToken,
409
396
  clearToken,
410
- setTokenManual,
411
397
  getAuthStatus,
412
398
  getToken
413
399
  };
@@ -108,8 +108,8 @@ function getSandboxRuntimeRoot() {
108
108
  function getSandboxAeConfigDir() {
109
109
  return join(getSandboxRuntimeRoot(), ".ae-config");
110
110
  }
111
- function getSandboxMcpTokenFilePath() {
112
- return join(getSandboxAeConfigDir(), "mcp-token.json");
111
+ function getSandboxCliTokenFilePath() {
112
+ return join(getSandboxAeConfigDir(), "cli-token.json");
113
113
  }
114
114
  function getSandboxClusterInfoFilePath() {
115
115
  return join(getSandboxAeConfigDir(), "cluster-info.json");
@@ -118,22 +118,22 @@ function getSandboxClusterInfoFilePath() {
118
118
  // src/core/config.ts
119
119
  var CONFIG_DIR = path2.join(process.env.HOME || "", ".ae-cli");
120
120
  var CONFIG_FILE = path2.join(CONFIG_DIR, "config.json");
121
- function sandboxMcpTokenCandidatePaths() {
122
- const paths = [getSandboxMcpTokenFilePath()];
123
- const homeFallback = path2.join(process.env.HOME || "", ".ae-config", "mcp-token.json");
121
+ function sandboxCliTokenCandidatePaths() {
122
+ const paths = [getSandboxCliTokenFilePath()];
123
+ const homeFallback = path2.join(process.env.HOME || "", ".ae-config", "cli-token.json");
124
124
  if (!paths.includes(homeFallback)) {
125
125
  paths.push(homeFallback);
126
126
  }
127
127
  return paths;
128
128
  }
129
- function readSandboxMcpTokenEntry() {
130
- for (const file of sandboxMcpTokenCandidatePaths()) {
129
+ function readSandboxCliTokenEntry() {
130
+ for (const file of sandboxCliTokenCandidatePaths()) {
131
131
  if (!fs3.existsSync(file)) continue;
132
132
  try {
133
133
  const data = safeReadJsonFile(file);
134
134
  if (data && typeof data === "object" && !Array.isArray(data)) {
135
135
  const url = data.url;
136
- const token = data["mcp-token"];
136
+ const token = data.token;
137
137
  if (url && token) {
138
138
  return { url, token };
139
139
  }
@@ -147,11 +147,11 @@ function ensureDir() {
147
147
  if (!fs3.existsSync(CONFIG_DIR)) fs3.mkdirSync(CONFIG_DIR, { recursive: true });
148
148
  }
149
149
  function forceMigrateFromFallback() {
150
- const entry = readSandboxMcpTokenEntry();
150
+ const entry = readSandboxCliTokenEntry();
151
151
  if (!entry) return null;
152
152
  return { [entry.url]: entry.token };
153
153
  }
154
- function getFallbackMcpToken(hostUrl) {
154
+ function getFallbackCliToken(hostUrl) {
155
155
  const store = forceMigrateFromFallback();
156
156
  if (!store) return null;
157
157
  if (hostUrl && store[hostUrl]) return store[hostUrl];
@@ -197,9 +197,10 @@ function saveConfig(config) {
197
197
  logger.info(`Config saved: activeHost=${config.activeHost}, hosts=${Object.keys(config.hosts).length}`);
198
198
  }
199
199
  function getActiveHost() {
200
+ const sandboxHost = readSandboxCliTokenEntry()?.url;
201
+ if (sandboxHost) return sandboxHost;
200
202
  const config = loadConfig();
201
- if (config.activeHost) return config.activeHost;
202
- return readSandboxMcpTokenEntry()?.url ?? "";
203
+ return config.activeHost || "";
203
204
  }
204
205
  function setActiveHost(url) {
205
206
  const config = loadConfig();
@@ -233,6 +234,14 @@ function removeHost(url) {
233
234
  }
234
235
  saveConfig(config);
235
236
  }
237
+ function listHosts() {
238
+ const config = loadConfig();
239
+ return Object.entries(config.hosts).map(([url, entry]) => ({
240
+ url,
241
+ label: entry.label,
242
+ active: url === config.activeHost
243
+ }));
244
+ }
236
245
  function getConfigDir() {
237
246
  return CONFIG_DIR;
238
247
  }
@@ -243,12 +252,13 @@ export {
243
252
  safeReadJsonFile,
244
253
  getSandboxRuntimeRoot,
245
254
  getSandboxClusterInfoFilePath,
246
- getFallbackMcpToken,
255
+ getFallbackCliToken,
247
256
  loadConfig,
248
257
  saveConfig,
249
258
  getActiveHost,
250
259
  setActiveHost,
251
260
  addHost,
252
261
  removeHost,
262
+ listHosts,
253
263
  getConfigDir
254
264
  };
@@ -2,7 +2,7 @@ import {
2
2
  getSandboxClusterInfoFilePath,
3
3
  logger,
4
4
  safeReadJsonFile
5
- } from "./chunk-6W4QOZAL.js";
5
+ } from "./chunk-WPXHCP4A.js";
6
6
 
7
7
  // src/core/cluster-info.ts
8
8
  import fs from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-6W4QOZAL.js";
3
+ } from "./chunk-WPXHCP4A.js";
4
4
 
5
5
  // src/framework/output.ts
6
6
  import Table from "cli-table3";
@@ -0,0 +1,14 @@
1
+ import {
2
+ clearCliToken,
3
+ getCliToken,
4
+ mintCliToken,
5
+ setCliTokenManual
6
+ } from "./chunk-FPE5LGVU.js";
7
+ import "./chunk-U6QPKCN3.js";
8
+ import "./chunk-WPXHCP4A.js";
9
+ export {
10
+ clearCliToken,
11
+ getCliToken,
12
+ mintCliToken,
13
+ setCliTokenManual
14
+ };
@@ -7,9 +7,9 @@ import {
7
7
  queryReportData,
8
8
  querySql,
9
9
  wsQuery
10
- } from "./chunk-BJX3GXWC.js";
11
- import "./chunk-RSHMZ3LG.js";
12
- import "./chunk-6W4QOZAL.js";
10
+ } from "./chunk-E34XH4GW.js";
11
+ import "./chunk-U6QPKCN3.js";
12
+ import "./chunk-WPXHCP4A.js";
13
13
  export {
14
14
  httpDelete,
15
15
  httpGet,
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  printError,
3
3
  printOutput
4
- } from "./chunk-2DUEAXV3.js";
4
+ } from "./chunk-YACCPUNQ.js";
5
5
  import {
6
6
  GLOBAL_QUERY_CONFIG_KEY,
7
7
  getAnalysisMappingPathForClusterMode,
8
8
  getClusterInfoFilePath,
9
9
  isGlobalQueryModeEnabled,
10
10
  setGlobalQueryModeEnabled
11
- } from "./chunk-PN3OS34E.js";
11
+ } from "./chunk-XE2PI5DS.js";
12
12
  import {
13
13
  addHost,
14
14
  loadConfig,
15
15
  setActiveHost
16
- } from "./chunk-6W4QOZAL.js";
16
+ } from "./chunk-WPXHCP4A.js";
17
17
 
18
18
  // src/commands/config.ts
19
19
  function registerConfig(program) {