@thinkingai/ae-cli 6.0.54 → 6.0.56

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 (118) hide show
  1. package/README.md +24 -3
  2. package/README.zh.md +24 -3
  3. package/dist/{auth-MBWRZTB6.js → auth-U7MNUUEF.js} +37 -13
  4. package/dist/{automation-NWWVLWG2.js → automation-K32V2NKP.js} +94 -38
  5. package/dist/{capability-7SSN6PNZ.js → capability-VV7RHB3B.js} +8 -7
  6. package/dist/{chunk-CT7QDJS6.js → chunk-2IYIYSUO.js} +2 -2
  7. package/dist/{chunk-PLE722AJ.js → chunk-2UWS5CUP.js} +62 -35
  8. package/dist/{chunk-ZIQWCZTS.js → chunk-3TQA5RXE.js} +3 -3
  9. package/dist/{chunk-KFNMQTZI.js → chunk-ELCR235M.js} +26 -19
  10. package/dist/{chunk-FMNNGNYO.js → chunk-F6NIPIT5.js} +7 -6
  11. package/dist/{chunk-D6ACFILC.js → chunk-GI5BMEZO.js} +1 -1
  12. package/dist/chunk-JJJIP2XQ.js +105 -0
  13. package/dist/{chunk-5XJYLEVC.js → chunk-KHS64JZQ.js} +4 -4
  14. package/dist/{chunk-UQ77JXYH.js → chunk-LMCYSVVA.js} +12 -13
  15. package/dist/{chunk-EOYSKMXN.js → chunk-MXV3PYC3.js} +14 -6
  16. package/dist/{chunk-7QXISROD.js → chunk-P6VFCH3P.js} +4 -2
  17. package/dist/{chunk-GIK6EDUG.js → chunk-P7KL7IOH.js} +41 -13
  18. package/dist/{chunk-AP7YP2NX.js → chunk-QSAR3GHY.js} +2 -2
  19. package/dist/{chunk-S6M42KND.js → chunk-T44M3PLZ.js} +1 -1
  20. package/dist/{chunk-HVHR4SCP.js → chunk-UUD5RB36.js} +3 -3
  21. package/dist/{chunk-HBLK3ZHW.js → chunk-W2PTY5NN.js} +3 -3
  22. package/dist/chunk-X7DRLE62.js +233 -0
  23. package/dist/{chunk-WNGFSIOB.js → chunk-ZW4VMY5H.js} +103 -6
  24. package/dist/{community-report-client-PEERQCX2.js → community-report-client-S2K3A3Q6.js} +1 -1
  25. package/dist/{config-FF6YVJKI.js → config-ASSAAIOI.js} +10 -9
  26. package/dist/{context-YAE3QXP3.js → context-6RWLVOM5.js} +4 -4
  27. package/dist/{data-integration-HESZET7E.js → data-integration-EXSUPUDZ.js} +6 -6
  28. package/dist/evaluation-5YT4QLCL.js +3714 -0
  29. package/dist/index.js +93 -49
  30. package/dist/{local-data-upload-client-TWMHFLUA.js → local-data-upload-client-7HCPGIS3.js} +1 -1
  31. package/dist/{memory-62BJOULV.js → memory-VCYLVPMI.js} +6 -6
  32. package/dist/{metadata-7CUMWIB4.js → metadata-TIWIOFTU.js} +8 -8
  33. package/dist/{model-SBV2JFJI.js → model-DPJHSD73.js} +4 -4
  34. package/dist/{personal-semantic-preference-6SRCYPGE.js → personal-semantic-preference-SBKU2LOK.js} +6 -6
  35. package/dist/{project-semantic-YYEM4OSU.js → project-semantic-SKNWLH3I.js} +6 -6
  36. package/dist/{sync-SU33KYX7.js → sync-7PP6KQ75.js} +7 -7
  37. package/dist/{te-agent-F5QBZSQA.js → te-agent-L2BYNPHM.js} +753 -94
  38. package/dist/{te-analysis-U4I2W2WC.js → te-analysis-RJB6VJC4.js} +411 -79
  39. package/dist/{te-community-PFLDLPP4.js → te-community-QN3WMPNT.js} +6 -4
  40. package/dist/{te-dataops-FOQSRIAZ.js → te-dataops-UKD2XN3E.js} +8 -6
  41. package/dist/{te-engage-ZX76CNAB.js → te-engage-KPTN4N2U.js} +6 -6
  42. package/dist/{te-kb-MHDOST62.js → te-kb-SFZI3W5T.js} +7 -7
  43. package/dist/{te-system-J2FQF5ER.js → te-system-IE7NCKC3.js} +10 -9
  44. package/dist/{te-team-5UOZPTU3.js → te-team-4KHCFM2I.js} +63 -41
  45. package/dist/{things-VPPXXLHB.js → things-7JJUVAWL.js} +7 -7
  46. package/dist/{update-EEUTEI6R.js → update-AX66IFMJ.js} +4 -4
  47. package/dist/{workspace-O3EEIYQM.js → workspace-Q5NMEKEN.js} +6 -6
  48. package/package.json +11 -7
  49. package/skills/ae-agent/SKILL.md +22 -3
  50. package/skills/ae-agent/references/command_index.md +8 -0
  51. package/skills/ae-agent/references/resource-package.md +53 -0
  52. package/skills/ae-analysis/SKILL.md +12 -3
  53. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  54. package/skills/ae-analysis/references/agent_review_preflight.md +4 -0
  55. package/skills/ae-analysis/references/agent_review_submit_to_page.md +4 -0
  56. package/skills/ae-analysis/references/ai_models/event.md +58 -2
  57. package/skills/ae-analysis/references/ai_models/rank_list.md +1 -0
  58. package/skills/ae-analysis/references/ai_models/retention.md +2 -0
  59. package/skills/ae-analysis/references/ai_models/revenue.md +2 -0
  60. package/skills/ae-analysis/references/analysis_data_export.md +11 -1
  61. package/skills/ae-analysis/references/asset_batch_info_export.md +2 -2
  62. package/skills/ae-analysis/references/asset_batch_sql_export.md +2 -2
  63. package/skills/ae-analysis/references/asset_export.md +1 -1
  64. package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
  65. package/skills/ae-analysis/references/check_export.md +1 -1
  66. package/skills/ae-analysis/references/command_index.md +34 -25
  67. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  68. package/skills/ae-analysis/references/dashboard_report_get.md +6 -2
  69. package/skills/ae-analysis/references/dashboard_report_update.md +24 -5
  70. package/skills/ae-analysis/references/feedback_submit.md +1 -1
  71. package/skills/ae-analysis/references/governance_recommendation_export.md +10 -2
  72. package/skills/ae-analysis/references/live_data_export.md +1 -1
  73. package/skills/ae-analysis/references/metric_create.md +29 -0
  74. package/skills/ae-analysis/references/metric_get.md +2 -0
  75. package/skills/ae-analysis/references/metric_update.md +2 -0
  76. package/skills/ae-analysis/references/operation_record_export.md +1 -1
  77. package/skills/ae-analysis/references/plan_change_log_export.md +1 -1
  78. package/skills/ae-analysis/references/plan_export.md +1 -1
  79. package/skills/ae-analysis/references/project_info_get.md +4 -0
  80. package/skills/ae-analysis/references/project_member_group_add_members.md +35 -0
  81. package/skills/ae-analysis/references/project_member_group_create.md +25 -0
  82. package/skills/ae-analysis/references/project_member_group_delete.md +34 -0
  83. package/skills/ae-analysis/references/project_member_group_list.md +29 -0
  84. package/skills/ae-analysis/references/project_member_group_members.md +28 -0
  85. package/skills/ae-analysis/references/project_member_group_remove_members.md +35 -0
  86. package/skills/ae-analysis/references/project_member_group_rename.md +26 -0
  87. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +6 -1
  88. package/skills/ae-analysis/references/report_data_export.md +1 -1
  89. package/skills/ae-analysis/references/scenario_append.md +25 -0
  90. package/skills/ae-analysis/references/scenario_collect.md +35 -0
  91. package/skills/ae-analysis/references/scenario_evaluation.md +30 -0
  92. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +73 -4
  93. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +5 -1
  94. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/execution-contract.mjs +173 -0
  95. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +109 -64
  96. package/skills/ae-automation/SKILL.md +2 -2
  97. package/skills/ae-automation/references/cli.md +18 -1
  98. package/skills/ae-capability/SKILL.md +7 -3
  99. package/skills/ae-evaluation/SKILL.md +83 -0
  100. package/skills/ae-evaluation/references/access-and-members.md +55 -0
  101. package/skills/ae-evaluation/references/connections.md +78 -0
  102. package/skills/ae-evaluation/references/datasets.md +57 -0
  103. package/skills/ae-evaluation/references/evaluators.md +81 -0
  104. package/skills/ae-evaluation/references/files.md +33 -0
  105. package/skills/ae-evaluation/references/integrations.md +39 -0
  106. package/skills/ae-evaluation/references/runs.md +160 -0
  107. package/skills/ae-evaluation/references/schedules.md +31 -0
  108. package/skills/ae-metadata/SKILL.md +2 -1
  109. package/skills/ae-metadata/references/metadata_data_table_download.md +7 -1
  110. package/skills/ae-metadata/references/metadata_data_table_get.md +2 -0
  111. package/skills/ae-team/SKILL.md +2 -2
  112. package/skills/ae-team/references/run-start.md +1 -0
  113. package/skills/ae-team/references/run-watch.md +7 -5
  114. package/skills/ae-things/SKILL.md +53 -51
  115. package/skills/ae-things/references/cli.md +56 -54
  116. package/skills/ae-things-progress/SKILL.md +20 -20
  117. package/skills/ae-things-review/SKILL.md +19 -19
  118. package/dist/chunk-4655PUNX.js +0 -43
@@ -4,15 +4,17 @@ import {
4
4
  } from "./chunk-Y74WTIKJ.js";
5
5
  import {
6
6
  getCliToken
7
- } from "./chunk-GIK6EDUG.js";
7
+ } from "./chunk-P7KL7IOH.js";
8
8
  import {
9
9
  getActiveHost,
10
10
  getSandboxRuntimeRoot
11
- } from "./chunk-UQ77JXYH.js";
11
+ } from "./chunk-LMCYSVVA.js";
12
12
  import {
13
13
  PermissionError,
14
- isApiErrorType
15
- } from "./chunk-WNGFSIOB.js";
14
+ externalCliTokenRequestOptions,
15
+ isApiErrorType,
16
+ readExternalCliToken
17
+ } from "./chunk-ZW4VMY5H.js";
16
18
 
17
19
  // src/core/te-agent-credentials.ts
18
20
  import { readFileSync } from "fs";
@@ -82,19 +84,27 @@ function readLegacyCredentials() {
82
84
  }
83
85
  }
84
86
  function tryLoadTeAgentSandboxCredentials() {
85
- const legacy = readLegacyCredentials();
86
- const persistent = readPersistentEnv();
87
- const url = process.env.TE_CLAUDE_BASE_URL || persistent?.TE_CLAUDE_BASE_URL || legacy?.url;
88
- if (typeof url !== "string" || !url) {
89
- return null;
87
+ const credentials = readSandboxCredentials();
88
+ return credentials.url ? { ...credentials, url: credentials.url } : null;
89
+ }
90
+ function readSandboxCredentials() {
91
+ let url = process.env.TE_CLAUDE_BASE_URL || null;
92
+ let sandboxId = process.env.SANDBOX_ID || null;
93
+ let sandboxSecretKey = process.env.SECRET_KEY || process.env.SANDBOX_SECRET_KEY || null;
94
+ if (!url || !sandboxId || !sandboxSecretKey) {
95
+ const persistent = readPersistentEnv();
96
+ url ||= persistent?.TE_CLAUDE_BASE_URL || null;
97
+ sandboxId ||= persistent?.SANDBOX_ID || null;
98
+ sandboxSecretKey ||= persistent?.SECRET_KEY || persistent?.SANDBOX_SECRET_KEY || null;
90
99
  }
91
- const sandboxId = process.env.SANDBOX_ID || persistent?.SANDBOX_ID || legacy?.sandboxId || null;
92
- const sandboxSecretKey = process.env.SECRET_KEY || process.env.SANDBOX_SECRET_KEY || persistent?.SECRET_KEY || persistent?.SANDBOX_SECRET_KEY || legacy?.sandboxSecretKey || legacy?.secretKey || null;
93
- return {
94
- url,
95
- sandboxId: typeof sandboxId === "string" ? sandboxId : null,
96
- sandboxSecretKey: typeof sandboxSecretKey === "string" ? sandboxSecretKey : null
97
- };
100
+ if (!url || !sandboxId || !sandboxSecretKey) {
101
+ const legacy = readLegacyCredentials();
102
+ url ||= typeof legacy?.url === "string" ? legacy.url : null;
103
+ sandboxId ||= typeof legacy?.sandboxId === "string" ? legacy.sandboxId : null;
104
+ const legacySecret = legacy?.sandboxSecretKey || legacy?.secretKey;
105
+ sandboxSecretKey ||= typeof legacySecret === "string" ? legacySecret : null;
106
+ }
107
+ return { url, sandboxId, sandboxSecretKey };
98
108
  }
99
109
  function getClaudeConfigDir() {
100
110
  const fromEnv = process.env.CLAUDE_CONFIG_DIR;
@@ -145,7 +155,7 @@ async function fetchWithTimeout(url, init, timeoutMs = DEFAULT_TIMEOUT_MS) {
145
155
  const controller = new AbortController();
146
156
  const timer = setTimeout(() => controller.abort(), timeoutMs);
147
157
  try {
148
- return await fetch(url, { ...init, signal: controller.signal });
158
+ return await fetch(url, { ...init, signal: controller.signal, ...externalCliTokenRequestOptions(url) });
149
159
  } catch (err) {
150
160
  if (err?.name === "AbortError") {
151
161
  throw new TeAgentApiError(
@@ -189,9 +199,19 @@ function teClaudeBaseFromActiveHost(hostOverride) {
189
199
  if (!h) return void 0;
190
200
  return resolveTeClaudeBaseUrl(h);
191
201
  }
192
- async function signRequest(method, path2, hostOverride, includeJsonContentType = true) {
193
- const sandboxCred = tryLoadTeAgentSandboxCredentials();
194
- if (!hostOverride && sandboxCred && sandboxCred.sandboxId && sandboxCred.sandboxSecretKey) {
202
+ async function signRequest(method, path2, hostOverride, includeJsonContentType = true, authMode = "auto") {
203
+ const external = readExternalCliToken(hostOverride);
204
+ const configuredHost = hostOverride || getActiveHost();
205
+ const sandboxOnly = !hostOverride && (/* @__PURE__ */ new Set([
206
+ "/api/sandbox/models",
207
+ "/api/sandbox/models/select",
208
+ "/api/sandbox/sync/push",
209
+ "/api/sandbox/sync/push/skill",
210
+ "/api/sandbox/sync/pull",
211
+ "/api/sandbox/sync/pull/candidates"
212
+ ])).has(path2.split("?")[0]);
213
+ const sandboxCred = external || configuredHost && !sandboxOnly ? null : tryLoadTeAgentSandboxCredentials();
214
+ if (authMode === "auto" && !hostOverride && sandboxCred && sandboxCred.sandboxId && sandboxCred.sandboxSecretKey) {
195
215
  const headers = {
196
216
  "X-Sandbox-Id": sandboxCred.sandboxId,
197
217
  "X-Sandbox-Secret-Key": sandboxCred.sandboxSecretKey
@@ -205,14 +225,14 @@ async function signRequest(method, path2, hostOverride, includeJsonContentType =
205
225
  authKind: "sandbox"
206
226
  };
207
227
  }
208
- const baseUrl = hostOverride ? teClaudeBaseFromActiveHost(hostOverride) : sandboxCred?.url || teClaudeBaseFromActiveHost();
228
+ const baseUrl = hostOverride || external ? teClaudeBaseFromActiveHost(hostOverride || external?.url) : sandboxCred?.url || teClaudeBaseFromActiveHost();
209
229
  if (!baseUrl) {
210
230
  throw new TeAgentCredentialsError(
211
231
  "Cannot determine the te-claude service URL",
212
232
  "Run ae-cli config set-host <url> to configure the service URL, or execute inside a te-agent sandbox"
213
233
  );
214
234
  }
215
- const hostForToken = hostOverride || getActiveHost() || baseUrl;
235
+ const hostForToken = configuredHost || baseUrl;
216
236
  const contentTypeHeader = includeJsonContentType && (method === "POST" || method === "PATCH" || method === "PUT") ? { "Content-Type": "application/json" } : {};
217
237
  const cliToken = await getCliToken(hostForToken);
218
238
  return {
@@ -231,13 +251,14 @@ async function fetchSigned(options) {
231
251
  options.method,
232
252
  options.path,
233
253
  options.hostOverride,
234
- options.includeJsonContentType
254
+ options.includeJsonContentType,
255
+ options.authMode
235
256
  );
236
257
  return fetchWithTimeout(
237
258
  signed.url,
238
259
  {
239
260
  method: options.method,
240
- headers: signed.headers,
261
+ headers: { ...Object.fromEntries(new Headers(options.headers).entries()), ...signed.headers },
241
262
  body: options.body
242
263
  },
243
264
  options.timeoutMs
@@ -246,7 +267,7 @@ async function fetchSigned(options) {
246
267
  function errorDetails(parsed, defaultErrorPrefix, status) {
247
268
  const nested = parsed && typeof parsed === "object" && parsed.error && typeof parsed.error === "object" ? parsed.error : parsed;
248
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}`;
249
- 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;
250
271
  const hint = typeof nested?.hint === "string" ? nested.hint : typeof parsed?.hint === "string" ? parsed.hint : void 0;
251
272
  const declaredType = isApiErrorType(nested?.type) ? nested.type : void 0;
252
273
  const type = status === 401 ? "auth" : status === 403 ? "permission" : declaredType ?? ([400, 413, 422].includes(status) ? "validation" : status === 404 ? "not_found" : "api");
@@ -286,21 +307,23 @@ async function parseResponse(response, defaultErrorPrefix) {
286
307
  }
287
308
  return parsed;
288
309
  }
289
- async function postToMainApp(path2, body, hostOverride) {
310
+ async function postToMainApp(path2, body, hostOverride, authMode = "auto") {
290
311
  const rawBody = JSON.stringify(body);
291
312
  const response = await fetchSigned({
292
313
  method: "POST",
293
314
  path: path2,
294
315
  body: rawBody,
295
- hostOverride
316
+ hostOverride,
317
+ authMode
296
318
  });
297
319
  return parseResponse(response, "Main app returned");
298
320
  }
299
- async function getFromMainApp(path2, hostOverride) {
321
+ async function getFromMainApp(path2, hostOverride, authMode = "auto") {
300
322
  const response = await fetchSigned({
301
323
  method: "GET",
302
324
  path: path2,
303
- hostOverride
325
+ hostOverride,
326
+ authMode
304
327
  });
305
328
  return parseResponse(response, "Main app returned");
306
329
  }
@@ -330,21 +353,23 @@ async function postSandboxSyncPull(args) {
330
353
  mode: "merge"
331
354
  });
332
355
  }
333
- async function deleteFromMainApp(path2, hostOverride) {
356
+ async function deleteFromMainApp(path2, hostOverride, authMode = "auto") {
334
357
  const response = await fetchSigned({
335
358
  method: "DELETE",
336
359
  path: path2,
337
- hostOverride
360
+ hostOverride,
361
+ authMode
338
362
  });
339
363
  return parseResponse(response, "Main app returned");
340
364
  }
341
- async function patchToMainApp(path2, body, hostOverride) {
365
+ async function patchToMainApp(path2, body, hostOverride, authMode = "auto") {
342
366
  const rawBody = JSON.stringify(body);
343
367
  const response = await fetchSigned({
344
368
  method: "PATCH",
345
369
  path: path2,
346
370
  body: rawBody,
347
- hostOverride
371
+ hostOverride,
372
+ authMode
348
373
  });
349
374
  return parseResponse(response, "Main app returned");
350
375
  }
@@ -430,7 +455,8 @@ async function downloadFromMainApp(requestPath, outputPath, hostOverride) {
430
455
  return await fetch(requestToSend.url, {
431
456
  method: "GET",
432
457
  headers: requestToSend.headers,
433
- signal: controller.signal
458
+ signal: controller.signal,
459
+ ...externalCliTokenRequestOptions(requestToSend.url)
434
460
  });
435
461
  } catch (error) {
436
462
  if (error?.name === "AbortError") {
@@ -499,11 +525,12 @@ async function uploadToMainApp(path2, formData, hostOverride) {
499
525
 
500
526
  export {
501
527
  TeAgentCredentialsError,
502
- tryLoadTeAgentSandboxCredentials,
503
528
  getClaudeConfigDir,
504
529
  resolveTeClaudeBaseUrl,
505
530
  TeAgentApiError,
531
+ fetchSigned,
506
532
  createTeAgentApiError,
533
+ parseResponse,
507
534
  postToMainApp,
508
535
  getFromMainApp,
509
536
  getSandboxModels,
@@ -6,13 +6,13 @@ import {
6
6
  dryRunCapability,
7
7
  executeCapabilityWithEnvelope,
8
8
  validateCapability
9
- } from "./chunk-EOYSKMXN.js";
9
+ } from "./chunk-MXV3PYC3.js";
10
10
  import {
11
11
  withOutputMetadata
12
- } from "./chunk-KFNMQTZI.js";
12
+ } from "./chunk-ELCR235M.js";
13
13
  import {
14
14
  CliValidationError
15
- } from "./chunk-WNGFSIOB.js";
15
+ } from "./chunk-ZW4VMY5H.js";
16
16
 
17
17
  // src/core/definition-intent.ts
18
18
  import { createHash } from "crypto";
@@ -1,16 +1,19 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  peekCliToken
4
- } from "./chunk-GIK6EDUG.js";
4
+ } from "./chunk-P7KL7IOH.js";
5
5
  import {
6
6
  getActiveHost,
7
7
  getConfigDir,
8
- isAeSandboxRuntime,
9
- normalizeUrl
10
- } from "./chunk-UQ77JXYH.js";
8
+ isAeSandboxRuntime
9
+ } from "./chunk-LMCYSVVA.js";
11
10
  import {
12
- logger
13
- } from "./chunk-WNGFSIOB.js";
11
+ externalCliTokenRequestOptions,
12
+ logger,
13
+ normalizeUrl,
14
+ readExternalCliToken,
15
+ redactExternalCliToken
16
+ } from "./chunk-ZW4VMY5H.js";
14
17
 
15
18
  // src/core/install-process.ts
16
19
  import spawn from "cross-spawn";
@@ -725,11 +728,13 @@ function recordVersionSyncResult(host, target, result) {
725
728
  store.hosts[key] = entry;
726
729
  writeSyncStore(store);
727
730
  }
728
- function isAutoSyncTargetEligible(version) {
731
+ function isRegularCliVersion(version) {
729
732
  const normalized = normalizeCliVersion(version);
730
- const parts = normalized.split("-")[0].split(".").map((part) => Number.parseInt(part, 10));
731
- if (parts.length < 3 || parts.some((part) => !Number.isFinite(part))) return false;
732
- const [major, minor, patch] = parts;
733
+ return /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(normalized) && normalized.split(".").every((part) => Number.isSafeInteger(Number(part)));
734
+ }
735
+ function isAutoSyncTargetEligible(version) {
736
+ if (!isRegularCliVersion(version)) return false;
737
+ const [major, minor, patch] = normalizeCliVersion(version).split(".").map(Number);
733
738
  if (major > 6) return true;
734
739
  if (major !== 6) return false;
735
740
  if (minor > 1) return true;
@@ -966,7 +971,7 @@ function rootCommand(argv) {
966
971
  const token = args[i];
967
972
  if (token === "--") return void 0;
968
973
  if (token.startsWith("-")) {
969
- if (!token.includes("=") && ["--host", "--mcp-url", "--format", "--jq"].includes(token)) {
974
+ if (!token.includes("=") && ["--host", "--cli-token-file", "--mcp-url", "--format", "--jq"].includes(token)) {
970
975
  i += 1;
971
976
  }
972
977
  continue;
@@ -981,13 +986,15 @@ function shouldSkipAutoSync(argv = process.argv) {
981
986
  }
982
987
  async function fetchCliConfig(host, cliToken) {
983
988
  const url = new URL(CLI_CONFIG_PATH, host.endsWith("/") ? host : `${host}/`);
984
- url.searchParams.set("cli-token", cliToken);
989
+ const external = readExternalCliToken(host)?.token === cliToken;
990
+ if (!external) url.searchParams.set("cli-token", cliToken);
985
991
  const controller = new AbortController();
986
992
  const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
987
993
  try {
988
994
  const resp = await fetch(url.toString(), {
989
995
  signal: controller.signal,
990
- headers: { Accept: "application/json" }
996
+ headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {} },
997
+ ...externalCliTokenRequestOptions(url.toString())
991
998
  });
992
999
  if (!resp.ok) return null;
993
1000
  const body = await resp.json();
@@ -1104,7 +1111,7 @@ async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
1104
1111
  entry.localVersion = pkg.version;
1105
1112
  entry.expectedVersion = expected;
1106
1113
  entry.clusterVersion = cluster || entry.clusterVersion;
1107
- const canAutoSync = allowAutoSync && isPublicAeCliPackage(pkg.name) && isAutoSyncTargetEligible(expected);
1114
+ const canAutoSync = allowAutoSync && isPublicAeCliPackage(pkg.name) && isRegularCliVersion(pkg.version) && isAutoSyncTargetEligible(expected);
1108
1115
  if (canAutoSync) {
1109
1116
  const confirmed = await fetchCliConfig(host, token);
1110
1117
  if (confirmed) rememberKbAutoDiscoveryFeature(host, token, confirmed.projectSemanticKbAutoDiscovery ?? false);
@@ -1307,7 +1314,7 @@ async function applyJq(data, expr) {
1307
1314
  if (!trimmed) return data;
1308
1315
  let results;
1309
1316
  try {
1310
- results = await jqJson(data, trimmed);
1317
+ results = await jqJson(data ?? null, trimmed);
1311
1318
  } catch (err) {
1312
1319
  const message = err instanceof JqError ? err.message : err?.message || String(err);
1313
1320
  const error = new Error(`Invalid --jq expression: ${message}`);
@@ -1328,7 +1335,7 @@ async function formatOutput(data, format, jqExpr) {
1328
1335
  processed = await applyJq(outputData, jqExpr);
1329
1336
  }
1330
1337
  if (format === "table") {
1331
- return formatTable(processed);
1338
+ return redactExternalCliToken(formatTable(processed));
1332
1339
  }
1333
1340
  const hostCompat = getPendingHostCompatNotice();
1334
1341
  const updateNotice = getPendingUpdateNotice();
@@ -1343,7 +1350,7 @@ async function formatOutput(data, format, jqExpr) {
1343
1350
  // Soft tip lives only under _notice (not mirrored into meta) to avoid duplicate fields.
1344
1351
  ...Object.keys(notices).length > 0 ? { _notice: notices } : {}
1345
1352
  };
1346
- return JSON.stringify(envelope, null, 2);
1353
+ return redactExternalCliToken(JSON.stringify(envelope, null, 2));
1347
1354
  }
1348
1355
  function formatError(type, message, hint, code, meta, details) {
1349
1356
  const envelope = {
@@ -1351,7 +1358,7 @@ function formatError(type, message, hint, code, meta, details) {
1351
1358
  error: { type, message, hint, code, ...details === void 0 ? {} : { details } },
1352
1359
  ...meta && Object.keys(meta).length > 0 ? { meta } : {}
1353
1360
  };
1354
- return JSON.stringify(envelope, null, 2);
1361
+ return redactExternalCliToken(JSON.stringify(envelope, null, 2));
1355
1362
  }
1356
1363
  function printError(type, message, hint, code, meta, options = {}) {
1357
1364
  const formatted = formatError(type, message, hint, code, meta, options.details);
@@ -1389,7 +1396,7 @@ async function printOutput(data, format, jqExpr, options = {}) {
1389
1396
  const recoveryData = options.redactErrors ? sensitiveRecoveryData(unwrapOutputData(data)) : unwrapOutputData(data);
1390
1397
  await new Promise((resolve, reject) => {
1391
1398
  process.stdout.write(
1392
- JSON.stringify({ ...recovery, data: recoveryData }, null, 2) + "\n",
1399
+ redactExternalCliToken(JSON.stringify({ ...recovery, data: recoveryData }, null, 2)) + "\n",
1393
1400
  (error2) => error2 ? reject(error2) : resolve()
1394
1401
  );
1395
1402
  });
@@ -1,17 +1,18 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  CapabilityGatewayError
4
- } from "./chunk-EOYSKMXN.js";
4
+ } from "./chunk-MXV3PYC3.js";
5
5
  import {
6
6
  SecureStoreAuthError,
7
7
  getCliToken
8
- } from "./chunk-GIK6EDUG.js";
8
+ } from "./chunk-P7KL7IOH.js";
9
9
  import {
10
10
  safeJsonParse
11
- } from "./chunk-UQ77JXYH.js";
11
+ } from "./chunk-LMCYSVVA.js";
12
12
  import {
13
- PermissionError
14
- } from "./chunk-WNGFSIOB.js";
13
+ PermissionError,
14
+ externalCliTokenRequestOptions
15
+ } from "./chunk-ZW4VMY5H.js";
15
16
 
16
17
  // src/core/mcp-access.ts
17
18
  function buildUrl(host, path, params = {}) {
@@ -170,7 +171,7 @@ function parseKbResponse(resp, text, options = {}) {
170
171
  async function fetchWithCliToken(input, init, cliToken, options = {}) {
171
172
  const headers = new Headers(init.headers);
172
173
  headers.set("cli-token", cliToken);
173
- const resp = await fetch(input, { ...init, headers });
174
+ const resp = await fetch(input, { ...init, headers, ...externalCliTokenRequestOptions(input) });
174
175
  if (options.responseType === "empty" && resp.status === 204) return null;
175
176
  if (options.responseType === "bytes" && resp.ok) {
176
177
  if (resp.headers.get("content-type")?.includes("application/json")) {
@@ -3,7 +3,7 @@ import {
3
3
  getAgentApi,
4
4
  patchAgentApi,
5
5
  postAgentApi
6
- } from "./chunk-4655PUNX.js";
6
+ } from "./chunk-JJJIP2XQ.js";
7
7
 
8
8
  // src/commands/memory/cli-client.ts
9
9
  var DEFAULT_TE_CLAUDE_BASE_PATH = "/agent";
@@ -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-2UWS5CUP.js";
14
+ import {
15
+ clearCliTokenCache
16
+ } from "./chunk-P7KL7IOH.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
+ };
@@ -1,20 +1,20 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  require_lib
4
- } from "./chunk-CT7QDJS6.js";
4
+ } from "./chunk-2IYIYSUO.js";
5
5
  import {
6
6
  require_archiver,
7
7
  require_string_decoder
8
- } from "./chunk-AP7YP2NX.js";
8
+ } from "./chunk-QSAR3GHY.js";
9
9
  import {
10
10
  require_inherits,
11
11
  require_node
12
- } from "./chunk-S6M42KND.js";
12
+ } from "./chunk-T44M3PLZ.js";
13
13
  import {
14
14
  __commonJS,
15
15
  __require,
16
16
  __toESM
17
- } from "./chunk-WNGFSIOB.js";
17
+ } from "./chunk-ZW4VMY5H.js";
18
18
 
19
19
  // node_modules/exceljs/lib/utils/under-dash.js
20
20
  var require_under_dash = __commonJS({
@@ -1,16 +1,9 @@
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";
5
-
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}`;
11
- }
12
- return url.replace(/\/$/, "");
13
- }
3
+ logger,
4
+ normalizeUrl,
5
+ readExternalCliToken
6
+ } from "./chunk-ZW4VMY5H.js";
14
7
 
15
8
  // src/core/config.ts
16
9
  import fs3 from "fs";
@@ -93,6 +86,10 @@ function isAeSandboxRuntime() {
93
86
  var CONFIG_DIR = path.join(process.env.HOME || os.homedir(), ".ae-cli");
94
87
  var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
95
88
  function sandboxCliTokenCandidatePaths() {
89
+ if (process.env.TE_AGENT_CLI_CONFIG_DIR !== void 0) {
90
+ const directory = process.env.TE_AGENT_CLI_CONFIG_DIR;
91
+ return path.isAbsolute(directory) ? [path.join(directory, "cli-token.json")] : [];
92
+ }
96
93
  const paths = [getSandboxCliTokenFilePath()];
97
94
  const homeFallback = path.join(process.env.HOME || os.homedir(), ".ae-config", "cli-token.json");
98
95
  if (!paths.includes(homeFallback)) {
@@ -108,7 +105,7 @@ function readSandboxCliTokenEntry() {
108
105
  if (data && typeof data === "object" && !Array.isArray(data)) {
109
106
  const url = data.url;
110
107
  const token = data.token ?? data["cli-token"];
111
- if (url && token) {
108
+ if (typeof url === "string" && url && typeof token === "string" && token) {
112
109
  return { url, token };
113
110
  }
114
111
  }
@@ -196,6 +193,8 @@ function saveConfig(config) {
196
193
  logger.info(`Config saved: activeHost=${config.activeHost}, hosts=${Object.keys(config.hosts).length}`);
197
194
  }
198
195
  function getActiveHost() {
196
+ const externalHost = readExternalCliToken()?.url;
197
+ if (externalHost) return externalHost;
199
198
  const sandboxHost = readSandboxCliTokenEntry()?.url;
200
199
  if (sandboxHost) return sandboxHost;
201
200
  const config = loadConfig();
@@ -281,9 +280,9 @@ function getConfigDir() {
281
280
  export {
282
281
  safeJsonParse,
283
282
  safeReadJsonFile,
284
- normalizeUrl,
285
283
  getSandboxRuntimeRoot,
286
284
  isAeSandboxRuntime,
285
+ readSandboxCliTokenEntry,
287
286
  getFallbackCliToken,
288
287
  loadConfig,
289
288
  saveConfig,
@@ -6,13 +6,14 @@ import {
6
6
  SecureStoreAuthError,
7
7
  clearCliTokenCache,
8
8
  getCliToken
9
- } from "./chunk-GIK6EDUG.js";
9
+ } from "./chunk-P7KL7IOH.js";
10
10
  import {
11
11
  safeJsonParse
12
- } from "./chunk-UQ77JXYH.js";
12
+ } from "./chunk-LMCYSVVA.js";
13
13
  import {
14
- PermissionError
15
- } from "./chunk-WNGFSIOB.js";
14
+ PermissionError,
15
+ externalCliTokenRequestOptions
16
+ } from "./chunk-ZW4VMY5H.js";
16
17
 
17
18
  // src/core/cli-agent-context.ts
18
19
  import { readFileSync, statSync } from "fs";
@@ -306,7 +307,13 @@ async function permissionError(resp) {
306
307
  const body = safeJsonParse(await codeResponse.text());
307
308
  const error = isRecord(body?.error) ? body.error : void 0;
308
309
  const code = nonEmptyString(error?.code) ?? nonEmptyString(body?.code);
309
- return new PermissionError(message, code);
310
+ return new PermissionError(
311
+ message,
312
+ code,
313
+ nonEmptyString(error?.hint),
314
+ void 0,
315
+ isRecord(body?.meta) ? body.meta : void 0
316
+ );
310
317
  }
311
318
  function isInvalidCliTokenMessage(message) {
312
319
  return /\byour token is invalid\b/i.test(message) || /\bcli[-_\s]?token\b.*\binvalid\b/i.test(message) || /\binvalid\b.*\bcli[-_\s]?token\b/i.test(message);
@@ -402,11 +409,12 @@ async function requestOnce(url, method, token, body, accept = "application/json"
402
409
  headers["Content-Type"] = "application/json";
403
410
  init.body = JSON.stringify(includeClientContextInBody ? withCliAgentContextBody(body, agentContext) : body);
404
411
  }
405
- return fetch(url, init);
412
+ return fetch(url, { ...init, ...externalCliTokenRequestOptions(url) });
406
413
  }
407
414
  async function requestMultipartOnce(url, token, form) {
408
415
  return fetch(url, {
409
416
  method: "POST",
417
+ ...externalCliTokenRequestOptions(url),
410
418
  headers: {
411
419
  "cli-token": token,
412
420
  "Accept": "application/json",
@@ -1,8 +1,10 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
- getActiveHost,
3
+ getActiveHost
4
+ } from "./chunk-LMCYSVVA.js";
5
+ import {
4
6
  normalizeUrl
5
- } from "./chunk-UQ77JXYH.js";
7
+ } from "./chunk-ZW4VMY5H.js";
6
8
 
7
9
  // src/core/auth.ts
8
10
  function resolveHost(hostOverride) {