@thinkingai/ae-cli 6.0.60 → 6.0.61

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 (82) hide show
  1. package/README.md +4 -1
  2. package/README.zh.md +6 -1
  3. package/bin/runtime-capabilities.json +1 -1
  4. package/dist/{ai-monitor-FCXSLHAP.js → ai-monitor-NUKSJPLE.js} +10 -9
  5. package/dist/ai-monitor.js +14 -13
  6. package/dist/{auth-ATK2SLEV.js → auth-MVAEBGBP.js} +18 -10
  7. package/dist/{automation-FLCPFMN4.js → automation-6L6IAYRK.js} +6 -7
  8. package/dist/{capability-6KTSOI7L.js → capability-74N7AN5X.js} +10 -9
  9. package/dist/{chunk-OAWPT7VP.js → chunk-2I5SZ5DS.js} +2 -2
  10. package/dist/{chunk-5E7MTTFN.js → chunk-7WBCSJL6.js} +23 -9
  11. package/dist/{chunk-4PSTYEG5.js → chunk-AMURHMS3.js} +11 -7
  12. package/dist/{chunk-6M7ZEDT2.js → chunk-BQFLABJQ.js} +11 -7
  13. package/dist/{chunk-KTJXD27G.js → chunk-COOMXFUG.js} +3 -3
  14. package/dist/{chunk-CF6JTT2U.js → chunk-EFGUBGA6.js} +1 -1
  15. package/dist/{chunk-BEYLCUZX.js → chunk-H35VDOAE.js} +3 -3
  16. package/dist/{chunk-F2VFZUGG.js → chunk-HIMOBNEY.js} +2 -2
  17. package/dist/{chunk-JEUXDY3B.js → chunk-HQED4YB4.js} +1 -1
  18. package/dist/{chunk-AXTO4FTM.js → chunk-HRFYYEXR.js} +3 -3
  19. package/dist/{chunk-2ETRY2CU.js → chunk-JZY6WWAP.js} +9 -8
  20. package/dist/{chunk-2F64AZYH.js → chunk-KA5WKR5P.js} +2 -2
  21. package/dist/{chunk-P7QDCWJ6.js → chunk-LFJ7N36I.js} +5 -1
  22. package/dist/{chunk-SDKW6LYE.js → chunk-LPKIMGIU.js} +3 -3
  23. package/dist/chunk-NNK3JBH4.js +60 -0
  24. package/dist/{chunk-VJUXKVRE.js → chunk-OTZ4JQDU.js} +2 -2
  25. package/dist/{chunk-HTZ2MLYA.js → chunk-PLNS5J33.js} +11 -5
  26. package/dist/chunk-PUSFEC6B.js +29 -0
  27. package/dist/{chunk-Z3Q2AEIN.js → chunk-R2SVAO4G.js} +14 -2
  28. package/dist/{chunk-HSZAIPUX.js → chunk-RB26WNLM.js} +7 -5
  29. package/dist/{chunk-VRMGHQKE.js → chunk-SVNED423.js} +11 -11
  30. package/dist/{chunk-HVMCPKOZ.js → chunk-THTROEGD.js} +1 -1
  31. package/dist/{chunk-QVRIDN42.js → chunk-UCMO4LKL.js} +2 -2
  32. package/dist/{chunk-5M5LBRR3.js → chunk-VLOGOM7N.js} +13 -7
  33. package/dist/{chunk-LOR4IA26.js → chunk-XPARQSYS.js} +165 -186
  34. package/dist/{chunk-72NJKS7O.js → chunk-XZDKAR4N.js} +4 -4
  35. package/dist/{community-report-client-TJVCLZ3K.js → community-report-client-ULRNXLQV.js} +1 -1
  36. package/dist/{compat-check-XD2U7PZ2.js → compat-check-W4XC27RG.js} +5 -4
  37. package/dist/{config-U3GDWU6E.js → config-264GB6C7.js} +7 -6
  38. package/dist/{context-YAQG6YQC.js → context-SOQDFZIB.js} +8 -6
  39. package/dist/{data-integration-QE37EQ3A.js → data-integration-UNJ7EPW2.js} +6 -6
  40. package/dist/{evaluation-2JSF4V47.js → evaluation-Q3AIGFOG.js} +5 -5
  41. package/dist/index.js +46 -42
  42. package/dist/{local-data-upload-client-KCMG6J62.js → local-data-upload-client-YTWMAAGE.js} +1 -1
  43. package/dist/{memory-WEB27VI6.js → memory-ZLTTULZK.js} +6 -7
  44. package/dist/{metadata-7FYE4234.js → metadata-EN2IWCDI.js} +10 -9
  45. package/dist/{model-T7H7Q6BG.js → model-NAKQWK4W.js} +4 -5
  46. package/dist/{personal-semantic-preference-O6VXM74A.js → personal-semantic-preference-UGN67KTN.js} +45 -14
  47. package/dist/{project-semantic-2GGFJWW6.js → project-semantic-5OP3YPZD.js} +9 -8
  48. package/dist/{sync-ULBB7WO5.js → sync-LDJQZRQH.js} +9 -9
  49. package/dist/{te-agent-6RMF7LUV.js → te-agent-WNNAD4AJ.js} +303 -17
  50. package/dist/{te-analysis-HSYC7GNV.js → te-analysis-KIMH6AGU.js} +25 -20
  51. package/dist/{te-community-FLKZGQKB.js → te-community-P7NNBVCS.js} +13 -11
  52. package/dist/{te-dataops-OQQGTCUA.js → te-dataops-ZRKSG4R7.js} +13 -11
  53. package/dist/{te-engage-RIEBHL5T.js → te-engage-PVBVNRSU.js} +9 -8
  54. package/dist/{te-kb-4HG2FMHJ.js → te-kb-W7PRC7QN.js} +68 -17
  55. package/dist/{te-system-AL4B4XZL.js → te-system-F4ZU2HRQ.js} +6 -7
  56. package/dist/{te-team-5O4UVUWE.js → te-team-5ONMRGKF.js} +9 -8
  57. package/dist/{things-TSJ64GBT.js → things-PFENSIF4.js} +9 -8
  58. package/dist/{update-Q5LURAWV.js → update-EUZ4GNND.js} +8 -6
  59. package/dist/{workspace-FF2HXJGR.js → workspace-Z7L33OBQ.js} +6 -7
  60. package/package.json +5 -2
  61. package/skills/ae-agent/SKILL.md +19 -5
  62. package/skills/ae-agent/references/a2a.md +103 -0
  63. package/skills/ae-agent/references/command_index.md +11 -0
  64. package/skills/ae-analysis/SKILL.md +35 -23
  65. package/skills/ae-analysis/references/analysis_data_retrieval.md +1 -1
  66. package/skills/ae-analysis/references/asset_authentication_export.md +1 -1
  67. package/skills/ae-analysis/references/asset_authentication_update.md +6 -2
  68. package/skills/ae-analysis/references/bad_case_review.md +4 -4
  69. package/skills/ae-analysis/references/command_index.md +7 -7
  70. package/skills/ae-analysis/references/governance_recommendation_export.md +2 -2
  71. package/skills/ae-analysis/references/personal_semantic_preference_add.md +9 -1
  72. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +2 -0
  73. package/skills/ae-analysis/references/personal_semantic_preference_get.md +2 -0
  74. package/skills/ae-analysis/references/personal_semantic_preference_list.md +10 -2
  75. package/skills/ae-analysis/references/personal_semantic_preference_update.md +8 -0
  76. package/skills/ae-analysis/references/project_owner_update.md +5 -1
  77. package/skills/ae-analysis/references/scenario_evaluation.md +17 -1
  78. package/skills/ae-analysis/references/scenario_list.md +5 -6
  79. package/skills/ae-capability/SKILL.md +8 -4
  80. package/skills/ae-kb/SKILL.md +4 -2
  81. package/skills/ae-kb/references/publication.md +45 -0
  82. package/dist/chunk-Y74WTIKJ.js +0 -10
package/README.md CHANGED
@@ -123,7 +123,7 @@ The table covers every current root command individually. Use `ae-cli --help` fo
123
123
  | Analysis and projects | `analysis-governance` | Data-asset search, lineage, impact analysis, certification, and governance |
124
124
  | Analysis and projects | `project` | Project information, members, roles, permissions, entities, time zones, and handover settings |
125
125
  | Analysis and projects | `metadata` | Capability-backed data-table, property, and dimension-table binding operations |
126
- | Analysis and projects | `personal-semantic-preference` | Project-scoped lightweight semantic preferences for the current user |
126
+ | Analysis and projects | `personal-semantic-preference` | Current-user semantic preferences for a project or across projects (`--project-id -1`) |
127
127
  | Analysis and projects | `project-semantic` | Asset-package export for building a project knowledge base |
128
128
  | Observability | `ai-monitor` | Read traces, conversations, Bad Traces, metrics, cost, security and existing diagnosis reports; export verified ZIPs ([guide](skills/ae-ai-monitor/SKILL.md)) |
129
129
  | Data and tracking | `tracking` | Tracking plans, SDK samples, checks, ingestion diagnostics, code generation, and bundled wiki |
@@ -430,3 +430,6 @@ npm run verify:install
430
430
  ## License
431
431
 
432
432
  MIT
433
+
434
+
435
+ Use `ae-cli agent a2a +card --url <A2A-link>` to discover authorized workspaces and models, then pass `--space-id <id>` and `--model <id>` to `agent a2a +send`. Use `agent a2a list`, `cancel`, and `delete-context` to manage tasks and conversations. See the [A2A command reference](skills/ae-agent/references/a2a.md).
package/README.zh.md CHANGED
@@ -127,7 +127,7 @@ ae-cli capability list --domain analysis --jq '.capabilities[] | .id'
127
127
  | 分析与项目 | `analysis-governance` | 数据资产搜索、血缘、影响分析、认证和治理 |
128
128
  | 分析与项目 | `project` | 项目信息、成员、角色、权限、实体、时区和交接配置 |
129
129
  | 分析与项目 | `metadata` | 基于 Capability Gateway 的数据表、属性及维度表绑定 |
130
- | 分析与项目 | `personal-semantic-preference` | 当前用户按项目维护轻量个人语义偏好 |
130
+ | 分析与项目 | `personal-semantic-preference` | 当前用户的项目内或跨项目个人语义偏好(`--project-id -1`) |
131
131
  | 分析与项目 | `project-semantic` | 导出构建项目知识库所需的资产包 |
132
132
  | 可观测性 | `ai-monitor` | 查询 Trace、会话、Bad Trace、指标、成本、安全与已有诊断报告,导出校验后的 ZIP([指南](skills/ae-ai-monitor/SKILL.md)) |
133
133
  | 数据与埋点 | `tracking` | 埋点方案、SDK 示例、检查、采集诊断、代码生成和内置 Wiki |
@@ -431,3 +431,8 @@ npm run verify:install
431
431
  ## 许可证
432
432
 
433
433
  MIT
434
+
435
+
436
+ ### 通过 A2A 调用 Agent
437
+
438
+ 先登录目标部署,再用 `ae-cli agent a2a +card --url <A2A-link>` 查看可用空间和模型;调用 `agent a2a +send` 时可指定 `--space-id <id>` 和 `--model <id>`。用 `agent a2a +get` 查询结果,`list`、`cancel` 和 `delete-context` 管理任务及会话。CLI 自动使用当前用户的授权。详见 [A2A 命令参考](skills/ae-agent/references/a2a.md)。
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "protocol": "ae-cli-runtime-capabilities",
3
3
  "version": 1,
4
- "features": ["kb_read_context_v1"]
4
+ "features": ["kb_read_context_v1", "cli_direct_v1"]
5
5
  }
@@ -9,16 +9,17 @@ import {
9
9
  traceCount,
10
10
  traceGet,
11
11
  traceList
12
- } from "./chunk-AXTO4FTM.js";
13
- import "./chunk-BEYLCUZX.js";
12
+ } from "./chunk-HRFYYEXR.js";
13
+ import "./chunk-H35VDOAE.js";
14
14
  import "./chunk-AWW2T2WL.js";
15
- import "./chunk-VJUXKVRE.js";
16
- import "./chunk-2ETRY2CU.js";
17
- import "./chunk-Y74WTIKJ.js";
18
- import "./chunk-LOR4IA26.js";
19
- import "./chunk-HTZ2MLYA.js";
20
- import "./chunk-4PSTYEG5.js";
21
- import "./chunk-Z3Q2AEIN.js";
15
+ import "./chunk-OTZ4JQDU.js";
16
+ import "./chunk-JZY6WWAP.js";
17
+ import "./chunk-NNK3JBH4.js";
18
+ import "./chunk-XPARQSYS.js";
19
+ import "./chunk-PUSFEC6B.js";
20
+ import "./chunk-PLNS5J33.js";
21
+ import "./chunk-AMURHMS3.js";
22
+ import "./chunk-R2SVAO4G.js";
22
23
  export {
23
24
  conversationCount,
24
25
  conversationGet,
@@ -3,25 +3,26 @@ import {
3
3
  configureBusinessCommands,
4
4
  parseProgram,
5
5
  runCommand
6
- } from "./chunk-VRMGHQKE.js";
7
- import "./chunk-CF6JTT2U.js";
8
- import "./chunk-5M5LBRR3.js";
6
+ } from "./chunk-SVNED423.js";
7
+ import "./chunk-EFGUBGA6.js";
8
+ import "./chunk-VLOGOM7N.js";
9
9
  import {
10
10
  ai_monitor_default
11
- } from "./chunk-AXTO4FTM.js";
12
- import "./chunk-P7QDCWJ6.js";
13
- import "./chunk-BEYLCUZX.js";
11
+ } from "./chunk-HRFYYEXR.js";
12
+ import "./chunk-LFJ7N36I.js";
13
+ import "./chunk-H35VDOAE.js";
14
14
  import "./chunk-AWW2T2WL.js";
15
- import "./chunk-VJUXKVRE.js";
16
- import "./chunk-2ETRY2CU.js";
17
- import "./chunk-Y74WTIKJ.js";
18
- import "./chunk-LOR4IA26.js";
19
- import "./chunk-HTZ2MLYA.js";
20
- import "./chunk-4PSTYEG5.js";
15
+ import "./chunk-OTZ4JQDU.js";
16
+ import "./chunk-JZY6WWAP.js";
17
+ import "./chunk-NNK3JBH4.js";
18
+ import "./chunk-XPARQSYS.js";
19
+ import "./chunk-PUSFEC6B.js";
20
+ import "./chunk-PLNS5J33.js";
21
+ import "./chunk-AMURHMS3.js";
21
22
  import {
22
23
  readExternalCliToken,
23
24
  setExternalCliTokenFile
24
- } from "./chunk-Z3Q2AEIN.js";
25
+ } from "./chunk-R2SVAO4G.js";
25
26
 
26
27
  // src/ai-monitor.ts
27
28
  import { Command as CommanderCommand, Option } from "commander";
@@ -3,7 +3,7 @@ import {
3
3
  environmentRefreshOutput,
4
4
  invalidateBusinessSkillSynchronization,
5
5
  refreshEnvironmentAfterLogin
6
- } from "./chunk-HSZAIPUX.js";
6
+ } from "./chunk-RB26WNLM.js";
7
7
  import {
8
8
  MultiselectCancelled,
9
9
  promptSingleSelect
@@ -14,15 +14,17 @@ import {
14
14
  } from "./chunk-6ZIQV5GW.js";
15
15
  import {
16
16
  resolveHost
17
- } from "./chunk-2F64AZYH.js";
17
+ } from "./chunk-KA5WKR5P.js";
18
18
  import {
19
19
  printError,
20
20
  printOutput
21
- } from "./chunk-VJUXKVRE.js";
21
+ } from "./chunk-OTZ4JQDU.js";
22
22
  import {
23
- getLocalCliPackageInfo,
24
23
  runHostCompatCheck
25
- } from "./chunk-LOR4IA26.js";
24
+ } from "./chunk-XPARQSYS.js";
25
+ import {
26
+ getLocalCliPackageInfo
27
+ } from "./chunk-PUSFEC6B.js";
26
28
  import {
27
29
  CliTokenValidationUnavailableError,
28
30
  CredentialStoreUnreadableError,
@@ -32,25 +34,26 @@ import {
32
34
  clearAllCredentials,
33
35
  clearCliTokenCache,
34
36
  getActiveCredential,
37
+ internalCallSourceHeaders,
35
38
  listCredentials,
36
39
  mintCliToken,
37
40
  removeActiveCredential,
38
41
  saveCredential,
39
42
  updateCredentialMetadata,
40
43
  validateCliTokenOnServer
41
- } from "./chunk-HTZ2MLYA.js";
44
+ } from "./chunk-PLNS5J33.js";
42
45
  import {
43
46
  getFallbackCliToken,
44
47
  loadConfig,
45
48
  saveConfig
46
- } from "./chunk-4PSTYEG5.js";
49
+ } from "./chunk-AMURHMS3.js";
47
50
  import {
48
51
  ExternalCliTokenError,
49
52
  PermissionError,
50
53
  logger,
51
54
  normalizeUrl,
52
55
  readExternalCliToken
53
- } from "./chunk-Z3Q2AEIN.js";
56
+ } from "./chunk-R2SVAO4G.js";
54
57
 
55
58
  // src/core/device-auth.ts
56
59
  import { execFileSync } from "child_process";
@@ -103,7 +106,7 @@ async function authorizeDevice(host) {
103
106
  try {
104
107
  resp = await fetch(url, {
105
108
  method: "POST",
106
- headers: { "Content-Type": "application/json" }
109
+ headers: { "Content-Type": "application/json", ...internalCallSourceHeaders() }
107
110
  });
108
111
  } catch (e) {
109
112
  throw new Error(`Device authorize request failed: ${e.message}`);
@@ -134,7 +137,7 @@ async function pollDeviceToken(host, deviceCode) {
134
137
  try {
135
138
  resp = await fetch(url, {
136
139
  method: "POST",
137
- headers: { "Content-Type": "application/json" },
140
+ headers: { "Content-Type": "application/json", ...internalCallSourceHeaders() },
138
141
  body: JSON.stringify({ device_code: deviceCode })
139
142
  });
140
143
  } catch (e) {
@@ -283,6 +286,11 @@ async function validateExistingCliToken(host, cliToken, external = false) {
283
286
  return { valid: true, trusted: false, details: await validateCliTokenOnServer(host, cliToken) };
284
287
  } catch (error) {
285
288
  if (error instanceof CliTokenValidationUnavailableError) {
289
+ if (external && readExternalCliToken(host)?.taskContext) {
290
+ printError("auth", error.message, "Retry when the gateway is available; managed execution credentials cannot be trusted without validation.", "CLI_TOKEN_VALIDATION_UNAVAILABLE");
291
+ process.exitCode = 1;
292
+ return { valid: false, trusted: false, details: {} };
293
+ }
286
294
  logger.warn(`auth status: ${error.message}; trusting the stored CLI token for compatibility`);
287
295
  return { valid: true, trusted: true, details: {} };
288
296
  }
@@ -1,22 +1,21 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  resolveWorkspaceTarget
4
- } from "./chunk-KTJXD27G.js";
4
+ } from "./chunk-COOMXFUG.js";
5
5
  import {
6
6
  currentAgentSpaceId
7
7
  } from "./chunk-RK6GLDGI.js";
8
- import "./chunk-F2VFZUGG.js";
8
+ import "./chunk-HIMOBNEY.js";
9
9
  import {
10
10
  TeAgentApiError,
11
11
  deleteFromMainApp,
12
12
  getFromMainApp,
13
13
  patchToMainApp,
14
14
  postToMainApp
15
- } from "./chunk-5M5LBRR3.js";
16
- import "./chunk-Y74WTIKJ.js";
17
- import "./chunk-HTZ2MLYA.js";
18
- import "./chunk-4PSTYEG5.js";
19
- import "./chunk-Z3Q2AEIN.js";
15
+ } from "./chunk-VLOGOM7N.js";
16
+ import "./chunk-PLNS5J33.js";
17
+ import "./chunk-AMURHMS3.js";
18
+ import "./chunk-R2SVAO4G.js";
20
19
 
21
20
  // src/commands/automation/index.ts
22
21
  import { randomUUID } from "crypto";
@@ -1,12 +1,12 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  resolveHost
4
- } from "./chunk-2F64AZYH.js";
4
+ } from "./chunk-KA5WKR5P.js";
5
5
  import {
6
6
  confirmHighRiskWrite,
7
7
  normalizeRiskLevel,
8
8
  requiresConfirmation
9
- } from "./chunk-CF6JTT2U.js";
9
+ } from "./chunk-EFGUBGA6.js";
10
10
  import {
11
11
  findGatewayDomain,
12
12
  listCapabilityDiscoveryPrefixes,
@@ -17,7 +17,7 @@ import {
17
17
  printError,
18
18
  printOutput,
19
19
  withOutputMetadata
20
- } from "./chunk-VJUXKVRE.js";
20
+ } from "./chunk-OTZ4JQDU.js";
21
21
  import {
22
22
  CapabilityGatewayError,
23
23
  dryRunCapabilityWithEnvelope,
@@ -26,26 +26,27 @@ import {
26
26
  inspectCapabilityWithEnvelope,
27
27
  listCapabilitiesWithEnvelope,
28
28
  validateCapabilityWithEnvelope
29
- } from "./chunk-2ETRY2CU.js";
30
- import "./chunk-Y74WTIKJ.js";
29
+ } from "./chunk-JZY6WWAP.js";
30
+ import "./chunk-NNK3JBH4.js";
31
31
  import {
32
32
  assertBusinessEnabled,
33
33
  businessForCapability,
34
34
  readBusinessConfigForExecution,
35
35
  readCurrentBusinessConfig
36
- } from "./chunk-LOR4IA26.js";
36
+ } from "./chunk-XPARQSYS.js";
37
+ import "./chunk-PUSFEC6B.js";
37
38
  import {
38
39
  CredentialStoreUnreadableError,
39
40
  SecureStoreAuthError
40
- } from "./chunk-HTZ2MLYA.js";
41
+ } from "./chunk-PLNS5J33.js";
41
42
  import {
42
43
  parseJsonRequest
43
- } from "./chunk-4PSTYEG5.js";
44
+ } from "./chunk-AMURHMS3.js";
44
45
  import {
45
46
  CliValidationError,
46
47
  ExternalCliTokenError,
47
48
  PermissionError
48
- } from "./chunk-Z3Q2AEIN.js";
49
+ } from "./chunk-R2SVAO4G.js";
49
50
 
50
51
  // src/commands/capability/helpers.ts
51
52
  import { readFileSync } from "fs";
@@ -5,14 +5,14 @@ import {
5
5
  require_node,
6
6
  require_process_nextick_args,
7
7
  require_util
8
- } from "./chunk-JEUXDY3B.js";
8
+ } from "./chunk-HQED4YB4.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __esm,
12
12
  __export,
13
13
  __require,
14
14
  __toCommonJS
15
- } from "./chunk-Z3Q2AEIN.js";
15
+ } from "./chunk-R2SVAO4G.js";
16
16
 
17
17
  // node_modules/readdir-glob/node_modules/minimatch/lib/path.js
18
18
  var require_path = __commonJS({
@@ -1,21 +1,23 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  CapabilityGatewayError
4
- } from "./chunk-2ETRY2CU.js";
4
+ } from "./chunk-JZY6WWAP.js";
5
5
  import {
6
6
  SecureStoreAuthError,
7
- getCliToken
8
- } from "./chunk-HTZ2MLYA.js";
7
+ getCliToken,
8
+ internalCallSourceHeaders
9
+ } from "./chunk-PLNS5J33.js";
9
10
  import {
10
11
  safeJsonParse
11
- } from "./chunk-4PSTYEG5.js";
12
+ } from "./chunk-AMURHMS3.js";
12
13
  import {
13
14
  PermissionError,
14
15
  externalCliTokenRequestOptions,
15
16
  isKbQueryPath,
16
17
  kbReadHeaders,
18
+ readExternalCliToken,
17
19
  readKbExecutionContext
18
- } from "./chunk-Z3Q2AEIN.js";
20
+ } from "./chunk-R2SVAO4G.js";
19
21
 
20
22
  // src/core/mcp-access.ts
21
23
  function buildUrl(host, path, params = {}) {
@@ -174,6 +176,7 @@ function parseKbResponse(resp, text, options = {}) {
174
176
  async function fetchWithCliToken(input, init, cliToken, options = {}) {
175
177
  const headers = new Headers(init.headers);
176
178
  headers.set("cli-token", cliToken);
179
+ for (const [name, value] of Object.entries(internalCallSourceHeaders())) headers.set(name, value);
177
180
  const resp = await fetch(input, { ...init, headers, ...externalCliTokenRequestOptions(input) });
178
181
  if (options.responseType === "empty" && resp.status === 204) return null;
179
182
  if (options.responseType === "bytes" && resp.ok) {
@@ -218,19 +221,20 @@ async function requestWithCliToken(host, input, init, options) {
218
221
  }
219
222
  async function getAuthHeaders(ctx) {
220
223
  const cliToken = await getCliToken(ctx.host());
221
- return { "cli-token": cliToken };
224
+ return { "cli-token": cliToken, ...internalCallSourceHeaders() };
222
225
  }
223
226
  async function kbApi(ctx, method, path, params = {}, body, options = {}) {
224
227
  const upperMethod = method.toUpperCase();
228
+ const isAsk = upperMethod === "POST" && /^\/(?:agent\/)?api\/external\/knowledge-bases\/ask$/.test(path);
225
229
  const isQuery = isKbQueryPath(upperMethod, path);
226
230
  const execution = isQuery ? readKbExecutionContext() : void 0;
227
231
  const host = execution ? ctx.hostOverride?.() || execution.origin : ctx.host();
228
232
  const selectedHost = execution && !ctx.hostOverride ? ctx.host() : host;
229
233
  const url = buildUrl(selectedHost, path, params);
230
- const queryHeaders = isQuery ? kbReadHeaders(url, ctx.str("read-context")) : void 0;
234
+ const queryHeaders = isQuery || isAsk && ctx.str("read-context") ? kbReadHeaders(url, ctx.str("read-context")) : void 0;
231
235
  const init = {
232
236
  method: upperMethod,
233
- headers: { "Content-Type": "application/json", ...queryHeaders },
237
+ headers: { "Content-Type": "application/json", ...queryHeaders, ...internalCallSourceHeaders() },
234
238
  body: upperMethod === "GET" ? void 0 : JSON.stringify(body ?? {})
235
239
  };
236
240
  if (execution) {
@@ -240,13 +244,23 @@ async function kbApi(ctx, method, path, params = {}, body, options = {}) {
240
244
  let code = "KB_READ_CONTEXT_REQUEST_FAILED";
241
245
  try {
242
246
  const value = responseErrorMetadata(safeJsonParse(text)).code;
243
- if (value?.startsWith("KB_READ_CONTEXT_")) code = value;
247
+ if (value && /^KB_(READ_CONTEXT|CANDIDATE)_/.test(value)) code = value;
244
248
  } catch {
245
249
  }
246
250
  throw new KbHttpError(code, code, response.status);
247
251
  }
248
252
  return parseKbResponse(response, text, { ...options, redactErrorDetails: true });
249
253
  }
254
+ if (upperMethod === "POST" && /^\/(?:agent\/)?api\/external\/knowledge-bases\/(read|grep|index)$/.test(path)) {
255
+ const task = readExternalCliToken(host)?.taskContext;
256
+ if (task) init.headers = {
257
+ ...init.headers,
258
+ "X-Task-CLI-Grant": task.grant,
259
+ "X-Task-CLI-Execution": task.executionId,
260
+ "X-Task-CLI-Company": task.companyId,
261
+ "X-Task-CLI-Sandbox": task.sandboxId
262
+ };
263
+ }
250
264
  return requestWithCliToken(
251
265
  host,
252
266
  url,
@@ -3,7 +3,7 @@ import {
3
3
  logger,
4
4
  normalizeUrl,
5
5
  readExternalCliToken
6
- } from "./chunk-Z3Q2AEIN.js";
6
+ } from "./chunk-R2SVAO4G.js";
7
7
 
8
8
  // src/core/sandbox-runtime.ts
9
9
  import { homedir } from "os";
@@ -26,19 +26,22 @@ function getSandboxCliTokenFilePath() {
26
26
  return join(getSandboxAeConfigDir(), "cli-token.json");
27
27
  }
28
28
  function isAeSandboxRuntime() {
29
+ return getAeSandboxDetectionReason() !== "not_detected";
30
+ }
31
+ function getAeSandboxDetectionReason() {
29
32
  if (process.env.SANDBOX_RUNTIME_ROOT) {
30
- return true;
33
+ return "runtime_root_env";
31
34
  }
32
35
  if (process.platform !== "linux") {
33
- return false;
36
+ return "not_detected";
34
37
  }
35
38
  try {
36
39
  if (fs.existsSync(getSandboxCliTokenFilePath())) {
37
- return true;
40
+ return "cli_token_file";
38
41
  }
39
42
  } catch {
40
43
  }
41
- return false;
44
+ return "not_detected";
42
45
  }
43
46
 
44
47
  // src/core/config.ts
@@ -285,12 +288,13 @@ function getConfigDir() {
285
288
  }
286
289
 
287
290
  export {
291
+ getSandboxRuntimeRoot,
292
+ isAeSandboxRuntime,
293
+ getAeSandboxDetectionReason,
288
294
  safeJsonParse,
289
295
  safeReadJsonFile,
290
296
  stringifyJsonRequest,
291
297
  parseJsonRequest,
292
- getSandboxRuntimeRoot,
293
- isAeSandboxRuntime,
294
298
  readSandboxCliTokenEntry,
295
299
  getFallbackCliToken,
296
300
  loadConfig,
@@ -6,17 +6,19 @@ import {
6
6
  evalRequest,
7
7
  evaluationResponseStatus,
8
8
  resolveEvaluationHost
9
- } from "./chunk-P7QDCWJ6.js";
9
+ } from "./chunk-LFJ7N36I.js";
10
10
  import {
11
- getCliToken
12
- } from "./chunk-HTZ2MLYA.js";
11
+ getCliToken,
12
+ internalCallSourceHeaders
13
+ } from "./chunk-PLNS5J33.js";
13
14
  import {
14
15
  isAeSandboxRuntime
15
- } from "./chunk-4PSTYEG5.js";
16
+ } from "./chunk-AMURHMS3.js";
16
17
  import {
17
18
  CliValidationError,
18
- externalCliTokenRequestOptions
19
- } from "./chunk-Z3Q2AEIN.js";
19
+ externalCliTokenRequestOptions,
20
+ readExternalCliToken
21
+ } from "./chunk-R2SVAO4G.js";
20
22
 
21
23
  // src/core/eval-session.ts
22
24
  var SESSION_PATH = "/api/sandbox/agent/evaluation/session";
@@ -30,7 +32,7 @@ async function requestSandboxEvaluationSession(host, cliToken, teProjectId, fetc
30
32
  response = await fetchImpl(url, {
31
33
  ...credentialOptions,
32
34
  method: "POST",
33
- headers: { Accept: "application/json", "Content-Type": "application/json", "cli-token": cliToken },
35
+ headers: { Accept: "application/json", "Content-Type": "application/json", "cli-token": cliToken, ...internalCallSourceHeaders() },
34
36
  body: JSON.stringify(teProjectId ? { te_project_id: teProjectId } : {}),
35
37
  redirect: "error",
36
38
  signal
@@ -113,6 +115,8 @@ function evalHeaders(environment = process.env, onboarding) {
113
115
  return { Authorization: `Bearer ${accessToken}` };
114
116
  }
115
117
  async function resolveEvalHeaders(ctx, environment = process.env, teProjectId) {
118
+ if (readExternalCliToken(ctx.host())?.taskContext && environment.AE_EVAL_ACCESS_TOKEN?.trim())
119
+ throw new CliValidationError("Managed executions must use the current user evaluation session, not AE_EVAL_ACCESS_TOKEN.", { code: "EVAL_MANAGED_TOKEN_OVERRIDE" });
116
120
  if (environment.AE_EVAL_ACCESS_TOKEN?.trim()) return evalHeaders(environment);
117
121
  if (!isAeSandboxRuntime()) {
118
122
  const baseUrl = resolveEvalBaseUrl(ctx, environment);
@@ -9,15 +9,15 @@ import {
9
9
  postAgentApi,
10
10
  putAgentApi,
11
11
  uploadAgentApi
12
- } from "./chunk-F2VFZUGG.js";
12
+ } from "./chunk-HIMOBNEY.js";
13
13
  import {
14
14
  TeAgentApiError,
15
15
  createTeAgentApiError
16
- } from "./chunk-5M5LBRR3.js";
16
+ } from "./chunk-VLOGOM7N.js";
17
17
  import {
18
18
  CliValidationError,
19
19
  isApiErrorType
20
- } from "./chunk-Z3Q2AEIN.js";
20
+ } from "./chunk-R2SVAO4G.js";
21
21
 
22
22
  // src/commands/workspace/client.ts
23
23
  var DEFAULT_TE_CLAUDE_BASE_PATH = "/agent";
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  CliValidationError
4
- } from "./chunk-Z3Q2AEIN.js";
4
+ } from "./chunk-R2SVAO4G.js";
5
5
 
6
6
  // src/core/capability-risk.ts
7
7
  var HIGH_RISK_LEVELS = /* @__PURE__ */ new Set(["high-risk-write"]);
@@ -4,15 +4,15 @@ import {
4
4
  } from "./chunk-AWW2T2WL.js";
5
5
  import {
6
6
  withOutputMetadata
7
- } from "./chunk-VJUXKVRE.js";
7
+ } from "./chunk-OTZ4JQDU.js";
8
8
  import {
9
9
  dryRunCapabilityWithEnvelope,
10
10
  executeCapabilityWithEnvelope,
11
11
  validateCapabilityWithEnvelope
12
- } from "./chunk-2ETRY2CU.js";
12
+ } from "./chunk-JZY6WWAP.js";
13
13
  import {
14
14
  CliValidationError
15
- } from "./chunk-Z3Q2AEIN.js";
15
+ } from "./chunk-R2SVAO4G.js";
16
16
 
17
17
  // src/core/capability-command.ts
18
18
  import { randomBytes } from "crypto";
@@ -10,10 +10,10 @@ import {
10
10
  postToMainApp,
11
11
  putToMainApp,
12
12
  uploadToMainApp
13
- } from "./chunk-5M5LBRR3.js";
13
+ } from "./chunk-VLOGOM7N.js";
14
14
  import {
15
15
  clearCliTokenCache
16
- } from "./chunk-HTZ2MLYA.js";
16
+ } from "./chunk-PLNS5J33.js";
17
17
 
18
18
  // src/core/resource-package-client.ts
19
19
  function checkPath(path) {
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  __commonJS,
4
4
  __require
5
- } from "./chunk-Z3Q2AEIN.js";
5
+ } from "./chunk-R2SVAO4G.js";
6
6
 
7
7
  // node_modules/process-nextick-args/index.js
8
8
  var require_process_nextick_args = __commonJS({
@@ -1,17 +1,17 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createCapabilityCommand
4
- } from "./chunk-BEYLCUZX.js";
4
+ } from "./chunk-H35VDOAE.js";
5
5
  import {
6
6
  registerCapabilityGatewayRoute
7
7
  } from "./chunk-AWW2T2WL.js";
8
8
  import {
9
9
  executeCapabilityWithEnvelope
10
- } from "./chunk-2ETRY2CU.js";
10
+ } from "./chunk-JZY6WWAP.js";
11
11
  import {
12
12
  CliApiError,
13
13
  CliValidationError
14
- } from "./chunk-Z3Q2AEIN.js";
14
+ } from "./chunk-R2SVAO4G.js";
15
15
 
16
16
  // src/commands/ai-monitor/shared.ts
17
17
  function createAiMonitorCapabilityCommand(config) {
@@ -1,20 +1,21 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
- internalCallSourceHeaders
4
- } from "./chunk-Y74WTIKJ.js";
3
+ sourceLoggedFetch
4
+ } from "./chunk-NNK3JBH4.js";
5
5
  import {
6
6
  SecureStoreAuthError,
7
7
  clearCliTokenCache,
8
- getCliToken
9
- } from "./chunk-HTZ2MLYA.js";
8
+ getCliToken,
9
+ internalCallSourceHeaders
10
+ } from "./chunk-PLNS5J33.js";
10
11
  import {
11
12
  safeJsonParse,
12
13
  stringifyJsonRequest
13
- } from "./chunk-4PSTYEG5.js";
14
+ } from "./chunk-AMURHMS3.js";
14
15
  import {
15
16
  PermissionError,
16
17
  externalCliTokenRequestOptions
17
- } from "./chunk-Z3Q2AEIN.js";
18
+ } from "./chunk-R2SVAO4G.js";
18
19
 
19
20
  // src/core/cli-agent-context.ts
20
21
  import { readFileSync, statSync } from "fs";
@@ -435,10 +436,10 @@ async function requestOnce(url, method, token, body, accept = "application/json"
435
436
  headers["Content-Type"] = "application/json";
436
437
  init.body = stringifyJsonRequest(includeClientContextInBody ? withCliAgentContextBody(body, agentContext) : body);
437
438
  }
438
- return fetch(url, { ...init, ...externalCliTokenRequestOptions(url), signal });
439
+ return sourceLoggedFetch(url, { ...init, ...externalCliTokenRequestOptions(url), signal });
439
440
  }
440
441
  async function requestMultipartOnce(url, token, form) {
441
- return fetch(url, {
442
+ return sourceLoggedFetch(url, {
442
443
  method: "POST",
443
444
  ...externalCliTokenRequestOptions(url),
444
445
  headers: {
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  getActiveHost
4
- } from "./chunk-4PSTYEG5.js";
4
+ } from "./chunk-AMURHMS3.js";
5
5
  import {
6
6
  normalizeUrl
7
- } from "./chunk-Z3Q2AEIN.js";
7
+ } from "./chunk-R2SVAO4G.js";
8
8
 
9
9
  // src/core/auth.ts
10
10
  function resolveHost(hostOverride) {
@@ -1,8 +1,11 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ internalCallSourceHeaders
4
+ } from "./chunk-PLNS5J33.js";
2
5
  import {
3
6
  CliValidationError,
4
7
  logger
5
- } from "./chunk-Z3Q2AEIN.js";
8
+ } from "./chunk-R2SVAO4G.js";
6
9
 
7
10
  // src/core/eval-endpoint.ts
8
11
  function resolveEvaluationHost(host) {
@@ -140,6 +143,7 @@ async function evalRequest(options) {
140
143
  const timeout = setTimeout(() => controller.abort(), timeoutMs);
141
144
  const headers = {
142
145
  ...options.headers,
146
+ ...internalCallSourceHeaders(),
143
147
  Accept: options.responseType === "bytes" ? "application/octet-stream, application/json" : "application/json"
144
148
  };
145
149
  const isMultipart = options.body instanceof FormData;