@thinkingai/ae-cli 6.1.23 → 6.1.25

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 (142) hide show
  1. package/README.md +7 -1
  2. package/README.zh.md +7 -1
  3. package/dist/{auth-XZNXFRJS.js → auth-LHM7NQPR.js} +167 -7
  4. package/dist/{capability-FYTU3X6L.js → capability-SJI5KOCK.js} +11 -6
  5. package/dist/{chunk-CCS66K4K.js → chunk-2FJM4HRV.js} +3 -3
  6. package/dist/{chunk-57RRFUEZ.js → chunk-5XRQ3CZR.js} +4 -4
  7. package/dist/{chunk-EQ255HKO.js → chunk-7WZACOAI.js} +2 -2
  8. package/dist/{chunk-DX5CDO34.js → chunk-BW7JUDEI.js} +84 -19
  9. package/dist/{chunk-7XGFSUOM.js → chunk-DU72X2IO.js} +271 -76
  10. package/dist/{chunk-V2NUHPXF.js → chunk-GK7WDY7E.js} +1 -1
  11. package/dist/{chunk-7FTTULED.js → chunk-IG3DYEIR.js} +4 -1
  12. package/dist/{chunk-HBGADCKA.js → chunk-KJDOTPYU.js} +3 -3
  13. package/dist/{chunk-4NRCTUZJ.js → chunk-KS4DE3MX.js} +4 -4
  14. package/dist/{chunk-JOCDD4ON.js → chunk-N4BLPJC7.js} +1 -1
  15. package/dist/{chunk-HFGZGYCG.js → chunk-QYXDJOLA.js} +252 -6
  16. package/dist/{chunk-DVMLWQD4.js → chunk-SO5LKIWP.js} +2 -2
  17. package/dist/{chunk-VYXXOKYS.js → chunk-XKIW3QMF.js} +7 -4
  18. package/dist/{chunk-MAPZ7VB6.js → chunk-YVGXGTD6.js} +13 -0
  19. package/dist/{community-report-client-CU22W53K.js → community-report-client-6VJDDMJJ.js} +1 -1
  20. package/dist/{config-XO3LI3SA.js → config-XQWOPDHN.js} +25 -6
  21. package/dist/{context-IFJI3LIT.js → context-M3HDGEIR.js} +4 -4
  22. package/dist/{data-integration-HNGUKFIC.js → data-integration-XBTCGXQT.js} +6 -6
  23. package/dist/index.js +78 -41
  24. package/dist/{local-data-upload-client-GTRIT64F.js → local-data-upload-client-3P7NIVQ4.js} +1 -1
  25. package/dist/{memory-QGPSNCQS.js → memory-6APEB2JB.js} +4 -4
  26. package/dist/{metadata-DI5BMYFU.js → metadata-JRYKNUS5.js} +7 -7
  27. package/dist/{model-RNPQXIBI.js → model-ZS7HVGKN.js} +4 -4
  28. package/dist/{personal-semantic-preference-5C3WUXFI.js → personal-semantic-preference-IDE2GE5T.js} +8 -6
  29. package/dist/project-semantic-36KOCYN7.js +356 -0
  30. package/dist/{sync-O45NXEQY.js → sync-EQLSTUS7.js} +7 -7
  31. package/dist/{te-agent-K5MSPNHJ.js → te-agent-Z3HCTKR7.js} +348 -55
  32. package/dist/{te-analysis-AISWCOOZ.js → te-analysis-5ZZ6YHVH.js} +940 -144
  33. package/dist/{te-community-4OYU3BDA.js → te-community-Z7JACGF3.js} +3 -3
  34. package/dist/{te-dataops-NFIPB6FX.js → te-dataops-F7GQOIS6.js} +644 -276
  35. package/dist/{te-engage-BAM3GBFX.js → te-engage-RNRMYDO3.js} +6 -6
  36. package/dist/{te-experiment-GUTZXZ5Z.js → te-experiment-BTAC2UNK.js} +6 -6
  37. package/dist/{te-kb-3TS73NO6.js → te-kb-QJLJEX5K.js} +323 -181
  38. package/dist/{te-system-STMHLS5J.js → te-system-IXC43QHZ.js} +6 -6
  39. package/dist/{te-team-3I5AOX3N.js → te-team-BIZIKIHZ.js} +6 -6
  40. package/dist/{update-RZXLPCRH.js → update-W2SGQNKT.js} +4 -4
  41. package/package.json +11 -4
  42. package/skills/ae-agent/SKILL.md +9 -4
  43. package/skills/ae-agent/references/notification.md +40 -0
  44. package/skills/ae-analysis/SKILL.md +44 -21
  45. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  46. package/skills/ae-analysis/references/adhoc_run.md +1 -1
  47. package/skills/ae-analysis/references/agent_review_submit_to_page.md +3 -1
  48. package/skills/ae-analysis/references/ai_models/event.md +6 -1
  49. package/skills/ae-analysis/references/ai_models/funnel.md +7 -1
  50. package/skills/ae-analysis/references/ai_models/heat_map.md +23 -0
  51. package/skills/ae-analysis/references/ai_models/interval.md +24 -0
  52. package/skills/ae-analysis/references/ai_models/path.md +20 -0
  53. package/skills/ae-analysis/references/ai_models/prop_analysis.md +2 -0
  54. package/skills/ae-analysis/references/ai_models/rank_list.md +30 -0
  55. package/skills/ae-analysis/references/ai_models/retention.md +45 -1
  56. package/skills/ae-analysis/references/ai_models/revenue.md +20 -2
  57. package/skills/ae-analysis/references/ai_models/session.md +76 -0
  58. package/skills/ae-analysis/references/ai_models/tag.md +2 -0
  59. package/skills/ae-analysis/references/ai_models.md +76 -6
  60. package/skills/ae-analysis/references/analysis_data_retrieval.md +4 -0
  61. package/skills/ae-analysis/references/analysis_drilldown_contract.md +4 -1
  62. package/skills/ae-analysis/references/asset_batch_info_export.md +10 -0
  63. package/skills/ae-analysis/references/asset_batch_sql_export.md +13 -1
  64. package/skills/ae-analysis/references/asset_export.md +12 -1
  65. package/skills/ae-analysis/references/asset_list.md +1 -0
  66. package/skills/ae-analysis/references/asset_search.md +11 -5
  67. package/skills/ae-analysis/references/bi_panel_list.md +1 -1
  68. package/skills/ae-analysis/references/catalog_list.md +1 -1
  69. package/skills/ae-analysis/references/collaboration.md +48 -0
  70. package/skills/ae-analysis/references/command_index.md +19 -17
  71. package/skills/ae-analysis/references/dashboard_list.md +4 -4
  72. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  73. package/skills/ae-analysis/references/drilldown_session_details_run.md +41 -0
  74. package/skills/ae-analysis/references/event_export.md +3 -1
  75. package/skills/ae-analysis/references/governance_recommendation_auto_review.md +77 -0
  76. package/skills/ae-analysis/references/governance_recommendation_export.md +11 -0
  77. package/skills/ae-analysis/references/metadata_resolution.md +3 -3
  78. package/skills/ae-analysis/references/metric_export.md +3 -1
  79. package/skills/ae-analysis/references/metric_list.md +1 -1
  80. package/skills/ae-analysis/references/operation_record_export.md +10 -0
  81. package/skills/ae-analysis/references/personal_semantic_preference_add.md +2 -2
  82. package/skills/ae-analysis/references/personal_semantic_preference_get.md +4 -4
  83. package/skills/ae-analysis/references/personal_semantic_preference_list.md +4 -4
  84. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +30 -12
  85. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +59 -0
  86. package/skills/ae-analysis/references/property_export.md +3 -1
  87. package/skills/ae-analysis/references/report_create.md +5 -1
  88. package/skills/ae-analysis/references/report_data_export.md +6 -0
  89. package/skills/ae-analysis/references/report_get.md +2 -0
  90. package/skills/ae-analysis/references/report_list.md +5 -5
  91. package/skills/ae-analysis/references/report_update.md +7 -1
  92. package/skills/ae-analysis/references/sql_table_columns.md +4 -4
  93. package/skills/ae-analysis/references/sql_table_list.md +5 -5
  94. package/skills/ae-analysis/references/user_cluster_models.md +8 -0
  95. package/skills/ae-analysis/references/user_tag_create.md +7 -1
  96. package/skills/ae-analysis/references/user_tag_get.md +1 -1
  97. package/skills/ae-analysis/references/user_tag_models.md +18 -2
  98. package/skills/ae-analysis/references/user_tag_refresh.md +1 -1
  99. package/skills/ae-analysis/references/user_tag_update.md +2 -2
  100. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +337 -12
  101. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +8 -3
  102. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +284 -24
  103. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/package-wiki-source-zip.mjs +185 -22
  104. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/precompiled-source.mjs +46 -2
  105. package/skills/ae-capability/SKILL.md +63 -1
  106. package/skills/ae-capability/references/collaboration.md +48 -0
  107. package/skills/ae-community/SKILL.md +5 -1
  108. package/skills/ae-community/references/collaboration.md +48 -0
  109. package/skills/ae-data-integration/SKILL.md +4 -0
  110. package/skills/ae-data-integration/references/collaboration.md +48 -0
  111. package/skills/ae-data-integration-helper/references/cpp_server_sdk_faq.md +2 -2
  112. package/skills/ae-data-integration-helper/references/logbus2_parser_plugin.md +6 -6
  113. package/skills/ae-data-integration-helper/references/sdk_log_guide.md +4 -4
  114. package/skills/ae-dataops/SKILL.md +54 -74
  115. package/skills/ae-dataops/references/collaboration.md +48 -0
  116. package/skills/ae-dataops/references/dataops-backfill.md +23 -18
  117. package/skills/ae-dataops/references/dataops-flow-create.md +74 -23
  118. package/skills/ae-dataops/references/dataops-flow-monitor.md +45 -13
  119. package/skills/ae-dataops/references/dataops-integration.md +57 -30
  120. package/skills/ae-dataops/references/dataops-query.md +21 -4
  121. package/skills/ae-dataops/references/dataops-table.md +143 -11
  122. package/skills/ae-engage/SKILL.md +21 -6
  123. package/skills/ae-engage/references/add-channel.md +3 -3
  124. package/skills/ae-engage/references/channel-mgmt.md +3 -3
  125. package/skills/ae-engage/references/collaboration.md +48 -0
  126. package/skills/ae-engage/references/common-metric.md +2 -2
  127. package/skills/ae-engage/references/save-task.md +2 -2
  128. package/skills/ae-engage/references/scene-config-channel.md +4 -4
  129. package/skills/ae-generate-tracking-code/SKILL.md +1 -1
  130. package/skills/ae-generate-tracking-plan/SKILL.md +4 -0
  131. package/skills/ae-generate-tracking-plan/references/collaboration.md +48 -0
  132. package/skills/ae-kb/SKILL.md +9 -1
  133. package/skills/ae-kb/references/collaboration.md +48 -0
  134. package/skills/ae-kb/references/schema-import.md +30 -0
  135. package/skills/ae-kb-discovery/SKILL.md +7 -2
  136. package/skills/ae-kb-discovery/references/collaboration.md +48 -0
  137. package/skills/ae-metadata/SKILL.md +20 -12
  138. package/skills/ae-metadata/references/collaboration.md +48 -0
  139. package/dist/project-semantic-3LF6Q6JZ.js +0 -1119
  140. package/skills/ae-project-semantic/SKILL.md +0 -193
  141. package/skills/ae-project-semantic/references/query-routing-v5.md +0 -165
  142. package/skills/ae-project-semantic/references/recommendation-quality.md +0 -68
@@ -4,14 +4,253 @@ import {
4
4
  } from "./chunk-Y74WTIKJ.js";
5
5
  import {
6
6
  SecureStoreAuthError,
7
+ clearCliTokenCache,
7
8
  getCliToken
8
- } from "./chunk-7XGFSUOM.js";
9
+ } from "./chunk-DU72X2IO.js";
9
10
  import {
10
11
  safeJsonParse
11
- } from "./chunk-7FTTULED.js";
12
+ } from "./chunk-IG3DYEIR.js";
12
13
  import {
13
14
  PermissionError
14
- } from "./chunk-MAPZ7VB6.js";
15
+ } from "./chunk-YVGXGTD6.js";
16
+
17
+ // src/core/cli-agent-context.ts
18
+ import { readFileSync, statSync } from "fs";
19
+ import { dirname, join, parse, resolve } from "path";
20
+ var MAX_CONTEXT_FILE_BYTES = 64 * 1024;
21
+ var CONTEXT_FILE_ENV = "TA_CLI_CONTEXT_FILE";
22
+ var CONTEXT_ARG = "--agent-context";
23
+ var CONTEXT_ENCODING_HEADER = "X-TA-CLI-Context-Encoding";
24
+ var CONTEXT_HEADER_ENCODING = "base64url";
25
+ var WELL_KNOWN_CONTEXT_FILES = [
26
+ ".ta/cli-agent-context.json",
27
+ ".ae/cli-agent-context.json"
28
+ ];
29
+ var FIELDS = [
30
+ { key: "agent_client", env: "TA_CLI_AGENT_CLIENT", header: "X-TA-CLI-Agent-Client", maxLength: 64 },
31
+ { key: "agent_model", env: "TA_CLI_AGENT_MODEL", header: "X-TA-CLI-Agent-Model", maxLength: 128 },
32
+ { key: "agent_session_id", env: "TA_CLI_AGENT_SESSION_ID", header: "X-TA-CLI-Agent-Session-Id", maxLength: 191 },
33
+ { key: "agent_turn_id", env: "TA_CLI_AGENT_TURN_ID", header: "X-TA-CLI-Agent-Turn-Id", maxLength: 191 },
34
+ { key: "parent_turn_id", env: "TA_CLI_PARENT_TURN_ID", header: "X-TA-CLI-Parent-Turn-Id", maxLength: 191 },
35
+ { key: "intent_relation", env: "TA_CLI_INTENT_RELATION", header: "X-TA-CLI-Intent-Relation", maxLength: 64 },
36
+ { key: "intent_revision", env: "TA_CLI_INTENT_REVISION", header: "X-TA-CLI-Intent-Revision", maxLength: 64 },
37
+ { key: "runtime", env: "TA_CLI_RUNTIME", header: "X-TA-CLI-Runtime", maxLength: 64 },
38
+ { key: "intent_source", env: "TA_CLI_INTENT_SOURCE", header: "X-TA-CLI-Intent-Source", maxLength: 64 },
39
+ { key: "session_initial_intent", env: "TA_CLI_SESSION_INITIAL_INTENT", header: "X-TA-CLI-Session-Initial-Intent", maxLength: 2048 },
40
+ { key: "user_intent", env: "TA_CLI_USER_INTENT", header: "X-TA-CLI-User-Intent", maxLength: 2048 },
41
+ { key: "user_intent_hash", env: "TA_CLI_USER_INTENT_HASH", header: "X-TA-CLI-User-Intent-Hash", maxLength: 128 },
42
+ { key: "session_goal", env: "TA_CLI_SESSION_GOAL", header: "X-TA-CLI-Session-Goal", maxLength: 2048 },
43
+ { key: "context_capture_status", env: "TA_CLI_CONTEXT_CAPTURE_STATUS", header: "X-TA-CLI-Context-Capture-Status", maxLength: 32 }
44
+ ];
45
+ function readCliAgentContext() {
46
+ const context = {
47
+ ...inferRuntimeContext(),
48
+ ...readEnvContext(),
49
+ ...readArgumentContext(),
50
+ ...readFileContext()
51
+ };
52
+ return withCaptureStatus(context);
53
+ }
54
+ function cliAgentContextHeaders(context = readCliAgentContext()) {
55
+ const headers = {};
56
+ for (const field of FIELDS) {
57
+ if (!field.header) continue;
58
+ const value = context[field.key];
59
+ if (value) headers[field.header] = Buffer.from(value, "utf8").toString("base64url");
60
+ }
61
+ if (Object.keys(headers).length > 0) {
62
+ headers[CONTEXT_ENCODING_HEADER] = CONTEXT_HEADER_ENCODING;
63
+ }
64
+ return headers;
65
+ }
66
+ function withCliAgentContextBody(body, context = readCliAgentContext()) {
67
+ if (!hasContext(context) || !isPlainRecord(body)) {
68
+ return body;
69
+ }
70
+ return {
71
+ ...body,
72
+ client_context: context
73
+ };
74
+ }
75
+ function readEnvContext() {
76
+ const context = {};
77
+ for (const field of FIELDS) {
78
+ const value = cleanValue(process.env[field.env], field.maxLength);
79
+ if (value) context[field.key] = value;
80
+ }
81
+ return context;
82
+ }
83
+ function inferRuntimeContext() {
84
+ return inferCodexContext() ?? inferClaudeCodeContext() ?? inferWorkBuddyContext() ?? {};
85
+ }
86
+ function inferCodexContext() {
87
+ if (!process.env.CODEX_SESSION_ID && !process.env.CODEX_THREAD_ID && !process.env.CODEX_VERSION && !process.env.CODEX_SHELL) {
88
+ return void 0;
89
+ }
90
+ return compactContext({
91
+ agent_client: "codex",
92
+ agent_model: firstEnv("CODEX_MODEL", "OPENAI_MODEL"),
93
+ agent_session_id: firstEnv("CODEX_THREAD_ID", "CODEX_SESSION_ID"),
94
+ runtime: process.env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE ? "codex_desktop" : "codex_cli",
95
+ intent_source: "runtime_env"
96
+ });
97
+ }
98
+ function inferClaudeCodeContext() {
99
+ if (!firstEnv("CLAUDE_CODE_SESSION_ID", "CLAUDE_SESSION_ID", "CLAUDECODE", "CLAUDE_CODE")) {
100
+ return void 0;
101
+ }
102
+ return compactContext({
103
+ agent_client: "claude_code",
104
+ agent_model: firstEnv("CLAUDE_CODE_MODEL", "CLAUDE_MODEL", "ANTHROPIC_MODEL"),
105
+ agent_session_id: firstEnv("CLAUDE_CODE_SESSION_ID", "CLAUDE_SESSION_ID"),
106
+ runtime: "claude_code",
107
+ intent_source: "runtime_env"
108
+ });
109
+ }
110
+ function inferWorkBuddyContext() {
111
+ if (!firstEnv("WORKBUDDY_SESSION_ID", "WORKBUDDY_AGENT_ID", "WORKBUDDY_RUNTIME")) {
112
+ return void 0;
113
+ }
114
+ return compactContext({
115
+ agent_client: "workbuddy",
116
+ agent_model: firstEnv("WORKBUDDY_MODEL", "WORKBUDDY_AGENT_MODEL"),
117
+ agent_session_id: firstEnv("WORKBUDDY_SESSION_ID", "WORKBUDDY_CONVERSATION_ID"),
118
+ runtime: firstEnv("WORKBUDDY_RUNTIME") ?? "workbuddy",
119
+ intent_source: "runtime_env"
120
+ });
121
+ }
122
+ function compactContext(values) {
123
+ const context = {};
124
+ for (const field of FIELDS) {
125
+ const value = cleanValue(values[field.key], field.maxLength);
126
+ if (value) context[field.key] = value;
127
+ }
128
+ return context;
129
+ }
130
+ function firstEnv(...keys) {
131
+ for (const key of keys) {
132
+ const value = process.env[key]?.trim();
133
+ if (value) return value;
134
+ }
135
+ return void 0;
136
+ }
137
+ function readFileContext() {
138
+ const filePath = resolveContextFilePath();
139
+ if (!filePath) return {};
140
+ try {
141
+ const stat = statSync(filePath);
142
+ if (!stat.isFile() || stat.size > MAX_CONTEXT_FILE_BYTES) return {};
143
+ const parsed = JSON.parse(readFileSync(filePath, "utf8"));
144
+ const record = normalizeContextFileRecord(parsed);
145
+ if (!record) return {};
146
+ const context = {};
147
+ for (const field of FIELDS) {
148
+ const value = cleanValue(record[field.key], field.maxLength);
149
+ if (value) context[field.key] = value;
150
+ }
151
+ return context;
152
+ } catch {
153
+ return {};
154
+ }
155
+ }
156
+ function readArgumentContext() {
157
+ const raw = readContextArgument(process.argv.slice(2));
158
+ if (!raw) return {};
159
+ const parsed = parseContextArgument(raw);
160
+ if (!parsed) return {};
161
+ const context = contextFromRecord(parsed);
162
+ if (!hasContext(context)) return {};
163
+ return {
164
+ intent_source: "agent_argument",
165
+ ...context
166
+ };
167
+ }
168
+ function readContextArgument(args) {
169
+ for (let i = 0; i < args.length; i += 1) {
170
+ const token = args[i];
171
+ if (token === "--") return void 0;
172
+ if (token === CONTEXT_ARG) return args[i + 1];
173
+ if (token.startsWith(`${CONTEXT_ARG}=`)) return token.slice(CONTEXT_ARG.length + 1);
174
+ }
175
+ return void 0;
176
+ }
177
+ function parseContextArgument(raw) {
178
+ const text = raw.trim();
179
+ if (!text) return void 0;
180
+ const decoded = text.startsWith("{") ? text : decodeBase64Url(text);
181
+ if (!decoded) return void 0;
182
+ try {
183
+ const parsed = JSON.parse(decoded);
184
+ return normalizeContextFileRecord(parsed);
185
+ } catch {
186
+ return void 0;
187
+ }
188
+ }
189
+ function decodeBase64Url(value) {
190
+ try {
191
+ return Buffer.from(value, "base64url").toString("utf8");
192
+ } catch {
193
+ return void 0;
194
+ }
195
+ }
196
+ function resolveContextFilePath() {
197
+ const configured = process.env[CONTEXT_FILE_ENV]?.trim();
198
+ if (configured) return configured;
199
+ return findWellKnownContextFile(process.cwd());
200
+ }
201
+ function findWellKnownContextFile(startDir) {
202
+ let current = resolve(startDir);
203
+ const root = parse(current).root;
204
+ while (true) {
205
+ for (const fileName of WELL_KNOWN_CONTEXT_FILES) {
206
+ const candidate = join(current, fileName);
207
+ try {
208
+ const stat = statSync(candidate);
209
+ if (stat.isFile() && stat.size <= MAX_CONTEXT_FILE_BYTES) return candidate;
210
+ } catch {
211
+ }
212
+ }
213
+ if (current === root) return void 0;
214
+ current = dirname(current);
215
+ }
216
+ }
217
+ function normalizeContextFileRecord(value) {
218
+ if (!isPlainRecord(value)) return void 0;
219
+ if (isPlainRecord(value.client_context)) return value.client_context;
220
+ return value;
221
+ }
222
+ function contextFromRecord(record) {
223
+ const context = {};
224
+ for (const field of FIELDS) {
225
+ const value = cleanValue(record[field.key], field.maxLength);
226
+ if (value) context[field.key] = value;
227
+ }
228
+ return context;
229
+ }
230
+ function withCaptureStatus(context) {
231
+ if (!hasContext(context)) return {};
232
+ if (context.context_capture_status) return context;
233
+ const required = ["agent_client", "agent_session_id", "agent_turn_id", "user_intent"];
234
+ const complete = required.every((key) => Boolean(context[key]));
235
+ return {
236
+ ...context,
237
+ context_capture_status: complete ? "full" : "partial"
238
+ };
239
+ }
240
+ function hasContext(context) {
241
+ return Object.keys(context).some((key) => key !== "context_capture_status" && Boolean(context[key]));
242
+ }
243
+ function cleanValue(value, maxLength) {
244
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
245
+ return void 0;
246
+ }
247
+ const text = String(value).replace(/[\r\n\t]+/g, " ").trim();
248
+ if (!text) return void 0;
249
+ return text.length > maxLength ? text.slice(0, maxLength) : text;
250
+ }
251
+ function isPlainRecord(value) {
252
+ return value !== null && typeof value === "object" && !Array.isArray(value);
253
+ }
15
254
 
16
255
  // src/core/capability-api.ts
17
256
  import { readFile } from "fs/promises";
@@ -145,15 +384,17 @@ async function throwCapabilityHttpError(resp) {
145
384
  throw error;
146
385
  }
147
386
  async function requestOnce(url, method, token, body, accept = "application/json") {
387
+ const agentContext = readCliAgentContext();
148
388
  const headers = {
149
389
  "cli-token": token,
150
390
  "Accept": accept,
151
- ...internalCallSourceHeaders()
391
+ ...internalCallSourceHeaders(),
392
+ ...cliAgentContextHeaders(agentContext)
152
393
  };
153
394
  const init = { method, headers };
154
395
  if (body !== void 0 && method !== "GET") {
155
396
  headers["Content-Type"] = "application/json";
156
- init.body = JSON.stringify(body);
397
+ init.body = JSON.stringify(withCliAgentContextBody(body, agentContext));
157
398
  }
158
399
  return fetch(url, init);
159
400
  }
@@ -174,7 +415,12 @@ async function callGateway(host, domain, pathAfterV1, method, body, queryParams
174
415
  async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body, queryParams = {}, options = {}) {
175
416
  const url = buildCapabilityGatewayUrl(options.apiBaseUrl ?? host, domain, pathAfterV1, queryParams);
176
417
  const token = await getCliToken(host);
177
- const resp = await requestOnce(url, method, token, body);
418
+ let resp = await requestOnce(url, method, token, body);
419
+ if (resp.status === 401 && options.retryOnUnauthorized === true) {
420
+ await resp.body?.cancel();
421
+ clearCliTokenCache(host);
422
+ resp = await requestOnce(url, method, await getCliToken(host), body);
423
+ }
178
424
  if (resp.status === 403) {
179
425
  const error = await permissionError(resp);
180
426
  if (options.retryOnInvalidTokenForbidden !== false && isInvalidCliTokenMessage(error.message)) {
@@ -5,11 +5,11 @@ import {
5
5
  require_node,
6
6
  require_process_nextick_args,
7
7
  require_util
8
- } from "./chunk-V2NUHPXF.js";
8
+ } from "./chunk-GK7WDY7E.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __require
12
- } from "./chunk-MAPZ7VB6.js";
12
+ } from "./chunk-YVGXGTD6.js";
13
13
 
14
14
  // node_modules/jszip/node_modules/readable-stream/lib/internal/streams/stream.js
15
15
  var require_stream = __commonJS({
@@ -3,7 +3,7 @@ import {
3
3
  CapabilityGatewayError,
4
4
  fetchCapabilityGateway,
5
5
  requestCapabilityGateway
6
- } from "./chunk-HFGZGYCG.js";
6
+ } from "./chunk-QYXDJOLA.js";
7
7
  import {
8
8
  resolveGatewayDomain
9
9
  } from "./chunk-KPQY44JQ.js";
@@ -11,13 +11,14 @@ import {
11
11
  readOutputMetadata,
12
12
  unwrapOutputData,
13
13
  withOutputMetadata
14
- } from "./chunk-DX5CDO34.js";
14
+ } from "./chunk-BW7JUDEI.js";
15
15
  import {
16
16
  PermissionError
17
- } from "./chunk-MAPZ7VB6.js";
17
+ } from "./chunk-YVGXGTD6.js";
18
18
 
19
19
  // src/core/analysis-async-artifact.ts
20
20
  import { randomBytes } from "crypto";
21
+ import { once } from "events";
21
22
  import { createWriteStream } from "fs";
22
23
  import { access, link, mkdir, rename, stat, unlink } from "fs/promises";
23
24
  import { Readable } from "stream";
@@ -261,9 +262,11 @@ async function downloadAnalysisArtifact(host, runId, artifactId, output, options
261
262
  if (!response.body) {
262
263
  throw protocolError("Artifact download response has no body.", runId);
263
264
  }
265
+ const destination = createWriteStream(tempPath, { flags: "wx", mode: options.mode });
266
+ await once(destination, "open");
264
267
  tempPresent = true;
265
268
  const source = Readable.fromWeb(response.body);
266
- await pipeline(source, createWriteStream(tempPath, { flags: "wx", mode: options.mode }), {
269
+ await pipeline(source, destination, {
267
270
  signal: options.signal
268
271
  });
269
272
  const file = await stat(tempPath);
@@ -166,6 +166,18 @@ var CliValidationError = class extends Error {
166
166
  }
167
167
  }
168
168
  };
169
+ var CliApiError = class extends Error {
170
+ code;
171
+ hint;
172
+ meta;
173
+ constructor(message, options = {}) {
174
+ super(message);
175
+ this.name = "CliApiError";
176
+ this.code = options.code;
177
+ this.hint = options.hint;
178
+ this.meta = options.meta;
179
+ }
180
+ };
169
181
  var CommunityReportError = class extends Error {
170
182
  code;
171
183
  httpStatus;
@@ -205,6 +217,7 @@ export {
205
217
  logger,
206
218
  PermissionError,
207
219
  CliValidationError,
220
+ CliApiError,
208
221
  CommunityReportError,
209
222
  LocalDataUploadError
210
223
  };
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  CommunityReportError,
4
4
  logger
5
- } from "./chunk-MAPZ7VB6.js";
5
+ } from "./chunk-YVGXGTD6.js";
6
6
 
7
7
  // src/core/community-report-client.ts
8
8
  var DEFAULT_TIMEOUT_MS = 3e4;
@@ -8,12 +8,17 @@ import {
8
8
  missingAeHostHint
9
9
  } from "./chunk-6ZIQV5GW.js";
10
10
  import {
11
+ fetchCliConfig,
11
12
  printError,
12
- printOutput
13
- } from "./chunk-DX5CDO34.js";
14
- import "./chunk-7XGFSUOM.js";
13
+ printOutput,
14
+ resolveKbAutoDiscoveryFeature
15
+ } from "./chunk-BW7JUDEI.js";
16
+ import {
17
+ peekCliToken
18
+ } from "./chunk-DU72X2IO.js";
15
19
  import {
16
20
  addHost,
21
+ getActiveHost,
17
22
  listHosts,
18
23
  loadConfig,
19
24
  normalizeUrl,
@@ -21,8 +26,8 @@ import {
21
26
  resolveHostSelector,
22
27
  setActiveHost,
23
28
  updateHostLabel
24
- } from "./chunk-7FTTULED.js";
25
- import "./chunk-MAPZ7VB6.js";
29
+ } from "./chunk-IG3DYEIR.js";
30
+ import "./chunk-YVGXGTD6.js";
26
31
 
27
32
  // src/commands/config.ts
28
33
  import * as readline2 from "readline";
@@ -252,7 +257,7 @@ async function confirm(question) {
252
257
 
253
258
  // src/commands/config.ts
254
259
  function registerConfig(program) {
255
- const configCmd = program.command("config").description("Manage AE host environments interactively or with subcommands").action(async () => {
260
+ const configCmd = program.command("config").description("Manage AE host environments and read configuration values").action(async () => {
256
261
  if (!process.stdin.isTTY || !process.stderr.isTTY) {
257
262
  failConfig(
258
263
  "Interactive config requires a TTY.",
@@ -268,6 +273,20 @@ function registerConfig(program) {
268
273
  configCmd.command("current").description("Show the active AE environment").action(async () => {
269
274
  await printCurrentConfig(program);
270
275
  });
276
+ configCmd.command("show").description("Show effective configuration for the selected AE host and account").action(async () => {
277
+ const host = program.opts().host || getActiveHost();
278
+ const token = host ? peekCliToken(host) : null;
279
+ const feature = host && token ? await resolveKbAutoDiscoveryFeature(host, token, () => fetchCliConfig(host, token)) : { enabled: false, source: "unavailable" };
280
+ await printOutput(
281
+ {
282
+ host: host || null,
283
+ routing: { knowledge_base: feature.enabled ? "auto" : "explicit" },
284
+ source: feature.source
285
+ },
286
+ program.opts().format || "json",
287
+ program.opts().jq
288
+ );
289
+ });
271
290
  configCmd.command("use <env>").description("Switch active AE environment by exact URL or unique label").action(async (env) => {
272
291
  await useConfigEnv(program, env);
273
292
  });
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  getFromMainApp
4
- } from "./chunk-HBGADCKA.js";
4
+ } from "./chunk-KJDOTPYU.js";
5
5
  import "./chunk-Y74WTIKJ.js";
6
- import "./chunk-7XGFSUOM.js";
7
- import "./chunk-7FTTULED.js";
6
+ import "./chunk-DU72X2IO.js";
7
+ import "./chunk-IG3DYEIR.js";
8
8
  import {
9
9
  CliValidationError
10
- } from "./chunk-MAPZ7VB6.js";
10
+ } from "./chunk-YVGXGTD6.js";
11
11
 
12
12
  // src/commands/context/current.ts
13
13
  var CURRENT_PAGE_CONTEXT_PATH = "/api/sandbox/agent/context/current";
@@ -8,20 +8,20 @@ import {
8
8
  utils,
9
9
  validateAndFix,
10
10
  validateDraft
11
- } from "./chunk-4NRCTUZJ.js";
12
- import "./chunk-DVMLWQD4.js";
11
+ } from "./chunk-KS4DE3MX.js";
12
+ import "./chunk-SO5LKIWP.js";
13
13
  import {
14
14
  require_archiver
15
- } from "./chunk-EQ255HKO.js";
16
- import "./chunk-V2NUHPXF.js";
15
+ } from "./chunk-7WZACOAI.js";
16
+ import "./chunk-GK7WDY7E.js";
17
17
  import {
18
18
  getConfigDir
19
- } from "./chunk-7FTTULED.js";
19
+ } from "./chunk-IG3DYEIR.js";
20
20
  import {
21
21
  CliValidationError,
22
22
  LocalDataUploadError,
23
23
  __toESM
24
- } from "./chunk-MAPZ7VB6.js";
24
+ } from "./chunk-YVGXGTD6.js";
25
25
 
26
26
  // src/commands/data-integration/inspect.ts
27
27
  import { basename as basename3 } from "path";