@thinkingai/ae-cli 1.0.18 → 1.0.20

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 (36) hide show
  1. package/dist/{auth-2UTBG5U3.js → auth-A4NV2VHD.js} +15 -6
  2. package/dist/{auth-ECD46NBA.js → auth-T3ILGJKW.js} +2 -2
  3. package/dist/{chunk-7QBNU44L.js → chunk-5CCFSPAF.js} +8 -30
  4. package/dist/{chunk-4KQ7H7DY.js → chunk-OVMQFFC2.js} +1 -1
  5. package/dist/{chunk-MR57UIKC.js → chunk-TMMUBSKW.js} +10 -0
  6. package/dist/{chunk-LAAS6ITR.js → chunk-TOXRLDUP.js} +2 -2
  7. package/dist/{client-O56G2SNJ.js → client-FPA76DGY.js} +3 -3
  8. package/dist/{config-BU5FHGGE.js → config-QZIEYXQZ.js} +2 -2
  9. package/dist/index.js +18 -13
  10. package/dist/{raw-A3VN2B6I.js → raw-MZIKHQH4.js} +3 -3
  11. package/dist/{te-analysis-UGKESPBE.js → te-analysis-CFQBXUCO.js} +93 -7
  12. package/dist/{te-audience-THZNVHYB.js → te-audience-WPBBWADL.js} +3 -3
  13. package/dist/{te-common-QZOUME3S.js → te-common-GL3KBZPD.js} +3 -3
  14. package/dist/{te-community-AZVW3NFX.js → te-community-3XEJNSQL.js} +3 -3
  15. package/dist/{te-dataops-OE5PX2K6.js → te-dataops-H4WSMCG5.js} +3 -3
  16. package/dist/{te-engage-RYGEQTYK.js → te-engage-2VFM37ZM.js} +3 -3
  17. package/dist/te-kb-U6SQUJVC.js +41 -0
  18. package/dist/{te-meta-MGO5BCMG.js → te-meta-BO45GW32.js} +7 -7
  19. package/package.json +2 -1
  20. package/skills/ae-analysis/SKILL.md +69 -37
  21. package/skills/ae-analysis/references/build_event_analysis_qp.md +132 -0
  22. package/skills/ae-analysis/references/build_funnel_analysis_qp.md +143 -0
  23. package/skills/ae-analysis/references/build_prop_analysis_qp.md +122 -0
  24. package/skills/ae-analysis/references/build_retention_analysis_qp.md +141 -0
  25. package/skills/ae-analysis/references/get_analysis_query_schema.md +22 -11
  26. package/skills/ae-analysis/references/get_metric.md +7 -1
  27. package/skills/ae-analysis/references/get_report_definition.md +4 -0
  28. package/skills/ae-analysis/references/list_dashboards.md +2 -0
  29. package/skills/ae-analysis/references/list_events.md +4 -1
  30. package/skills/ae-analysis/references/list_metrics.md +5 -0
  31. package/skills/ae-analysis/references/list_properties.md +6 -1
  32. package/skills/ae-analysis/references/list_reports.md +2 -0
  33. package/skills/ae-analysis/references/query_adhoc.md +71 -31
  34. package/skills/ae-community/SKILL.md +14 -101
  35. package/skills/ae-dataops/SKILL.md +13 -58
  36. package/skills/ae-engage/SKILL.md +15 -98
@@ -4,9 +4,10 @@ import {
4
4
  } from "./chunk-KM57HI5B.js";
5
5
  import {
6
6
  clearMcpToken,
7
+ loadMcpTokenStore,
7
8
  setMcpTokenManual,
8
9
  validateMcpToken
9
- } from "./chunk-7QBNU44L.js";
10
+ } from "./chunk-5CCFSPAF.js";
10
11
  import {
11
12
  clearToken,
12
13
  getAuthStatus,
@@ -14,11 +15,11 @@ import {
14
15
  resolveHost,
15
16
  setTokenManual,
16
17
  validateToken
17
- } from "./chunk-4KQ7H7DY.js";
18
+ } from "./chunk-OVMQFFC2.js";
18
19
  import {
19
20
  loadConfig,
20
21
  saveConfig
21
- } from "./chunk-MR57UIKC.js";
22
+ } from "./chunk-TMMUBSKW.js";
22
23
 
23
24
  // src/commands/auth.ts
24
25
  function registerAuth(program) {
@@ -70,14 +71,22 @@ function registerAuth(program) {
70
71
  `);
71
72
  printOutput({ saved: true, host, verified: true }, program.opts().format || "json");
72
73
  });
73
- auth.command("status").description("Show current authentication status").action(() => {
74
+ auth.command("status").description("Show current authentication status").action(async () => {
74
75
  const host = resolveHost(program.opts().host);
75
76
  if (!host) {
76
77
  printOutput({ authenticated: false, host: "(none)", hint: "Run: ae-cli config set-host" }, program.opts().format || "json");
77
78
  return;
78
79
  }
79
- const status = getAuthStatus(host);
80
- printOutput(status, program.opts().format || "json");
80
+ const tokenStatus = getAuthStatus(host);
81
+ const hasValidToken = tokenStatus.authenticated;
82
+ const mcpStore = loadMcpTokenStore();
83
+ const cachedMcpToken = mcpStore[host];
84
+ let hasValidMcpToken = false;
85
+ if (cachedMcpToken) {
86
+ hasValidMcpToken = await validateMcpToken(cachedMcpToken, host);
87
+ }
88
+ const authenticated = hasValidToken || hasValidMcpToken;
89
+ printOutput({ authenticated, host }, program.opts().format || "json");
81
90
  });
82
91
  auth.command("logout").description("Clear stored token for active host").action(() => {
83
92
  const host = resolveHost(program.opts().host);
@@ -7,8 +7,8 @@ import {
7
7
  saveToken,
8
8
  setTokenManual,
9
9
  validateToken
10
- } from "./chunk-4KQ7H7DY.js";
11
- import "./chunk-MR57UIKC.js";
10
+ } from "./chunk-OVMQFFC2.js";
11
+ import "./chunk-TMMUBSKW.js";
12
12
  export {
13
13
  clearToken,
14
14
  getAuthStatus,
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  getToken
3
- } from "./chunk-4KQ7H7DY.js";
3
+ } from "./chunk-OVMQFFC2.js";
4
4
  import {
5
+ forceMigrateFromFallback,
5
6
  getActiveHost,
6
7
  getConfigDir,
7
8
  safeJsonParse,
8
9
  safeReadJsonFile
9
- } from "./chunk-MR57UIKC.js";
10
+ } from "./chunk-TMMUBSKW.js";
10
11
 
11
12
  // src/core/mcp.ts
12
13
  import fs from "fs";
@@ -54,7 +55,6 @@ function genRequestId() {
54
55
  }
55
56
  var MCP_TOKEN_FILE = path.join(getConfigDir(), "mcp-tokens.json");
56
57
  var MCP_TOKEN_GENERATE_PATH = "/v1/ta/mcp/token/generate";
57
- var FALLBACK_MCP_TOKEN_FILE = "/data/app/te_agent_ta/.ae-config/mcp-token.json";
58
58
  function loadMcpTokenStore() {
59
59
  try {
60
60
  if (fs.existsSync(MCP_TOKEN_FILE)) {
@@ -69,23 +69,6 @@ function saveMcpTokenStore(store) {
69
69
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
70
70
  fs.writeFileSync(MCP_TOKEN_FILE, JSON.stringify(store, null, 2));
71
71
  }
72
- function getFallbackMcpToken(hostUrl) {
73
- try {
74
- if (!fs.existsSync(FALLBACK_MCP_TOKEN_FILE)) {
75
- return null;
76
- }
77
- const fallbackData = safeReadJsonFile(FALLBACK_MCP_TOKEN_FILE);
78
- if (fallbackData && typeof fallbackData === "object" && !Array.isArray(fallbackData)) {
79
- const url = fallbackData.url;
80
- const token = fallbackData["mcp-token"];
81
- if (url === hostUrl && token) {
82
- return token;
83
- }
84
- }
85
- } catch {
86
- }
87
- return null;
88
- }
89
72
  async function generateMcpToken(hostUrl) {
90
73
  const teToken = await getToken(hostUrl);
91
74
  const base = hostUrl.replace(/\/+$/, "");
@@ -196,15 +179,12 @@ async function mcpRequest(url, method, params = {}, hostOverride) {
196
179
  headers,
197
180
  body: JSON.stringify(body)
198
181
  });
199
- if (resp.status === 403) {
200
- const fallbackToken = getFallbackMcpToken(hostUrl);
201
- if (fallbackToken) {
202
- const store = loadMcpTokenStore();
203
- store[hostUrl] = fallbackToken;
204
- saveMcpTokenStore(store);
182
+ if (!resp.ok) {
183
+ const migrated = forceMigrateFromFallback();
184
+ if (migrated && migrated[hostUrl]) {
205
185
  process.stderr.write(`[ae-cli] MCP token refreshed from fallback for ${hostUrl}
206
186
  `);
207
- headers["mcp-token"] = fallbackToken;
187
+ headers["mcp-token"] = migrated[hostUrl];
208
188
  const retryResp = await fetch(url, {
209
189
  method: "POST",
210
190
  headers,
@@ -219,9 +199,6 @@ async function mcpRequest(url, method, params = {}, hostOverride) {
219
199
  }
220
200
  return retryData.result;
221
201
  }
222
- throw new Error(`MCP token expired or invalid. Please set a new MCP token: ae-cli auth set-mcp-token <token> --host ${hostUrl}`);
223
- }
224
- if (!resp.ok) {
225
202
  throw new Error(`MCP HTTP error: ${resp.status} ${resp.statusText}`);
226
203
  }
227
204
  const data = safeJsonParse(await resp.text());
@@ -264,6 +241,7 @@ function parseMcpResult(result) {
264
241
  export {
265
242
  registerMcpMappings,
266
243
  resolveMcpUrl,
244
+ loadMcpTokenStore,
267
245
  clearMcpToken,
268
246
  setMcpTokenManual,
269
247
  validateMcpToken,
@@ -4,7 +4,7 @@ import {
4
4
  getConfigDir,
5
5
  safeJsonParse,
6
6
  safeReadJsonFile
7
- } from "./chunk-MR57UIKC.js";
7
+ } from "./chunk-TMMUBSKW.js";
8
8
 
9
9
  // src/core/auth.ts
10
10
  import fs from "fs";
@@ -26,6 +26,15 @@ function migrateFromFallback() {
26
26
  if (!fs2.existsSync(FALLBACK_MCP_TOKEN_FILE) || fs2.existsSync(MCP_TOKENS_FILE)) {
27
27
  return null;
28
28
  }
29
+ return doMigrateFromFallback();
30
+ }
31
+ function forceMigrateFromFallback() {
32
+ if (!fs2.existsSync(FALLBACK_MCP_TOKEN_FILE)) {
33
+ return null;
34
+ }
35
+ return doMigrateFromFallback();
36
+ }
37
+ function doMigrateFromFallback() {
29
38
  try {
30
39
  const fallbackData = safeReadJsonFile(FALLBACK_MCP_TOKEN_FILE);
31
40
  const tokenStore = {};
@@ -156,6 +165,7 @@ function extractHostname(fullUrl) {
156
165
  export {
157
166
  safeJsonParse,
158
167
  safeReadJsonFile,
168
+ forceMigrateFromFallback,
159
169
  loadConfig,
160
170
  saveConfig,
161
171
  getActiveHost,
@@ -2,10 +2,10 @@ import {
2
2
  clearToken,
3
3
  getToken,
4
4
  resolveHost
5
- } from "./chunk-4KQ7H7DY.js";
5
+ } from "./chunk-OVMQFFC2.js";
6
6
  import {
7
7
  safeJsonParse
8
- } from "./chunk-MR57UIKC.js";
8
+ } from "./chunk-TMMUBSKW.js";
9
9
 
10
10
  // src/core/client.ts
11
11
  import WebSocket from "ws";
@@ -4,9 +4,9 @@ import {
4
4
  queryReportData,
5
5
  querySql,
6
6
  wsQuery
7
- } from "./chunk-LAAS6ITR.js";
8
- import "./chunk-4KQ7H7DY.js";
9
- import "./chunk-MR57UIKC.js";
7
+ } from "./chunk-TOXRLDUP.js";
8
+ import "./chunk-OVMQFFC2.js";
9
+ import "./chunk-TMMUBSKW.js";
10
10
  export {
11
11
  httpGet,
12
12
  httpPost,
@@ -4,14 +4,14 @@ import {
4
4
  getToken,
5
5
  loadToken,
6
6
  validateToken
7
- } from "./chunk-4KQ7H7DY.js";
7
+ } from "./chunk-OVMQFFC2.js";
8
8
  import {
9
9
  addHost,
10
10
  listHosts,
11
11
  removeHost,
12
12
  setActiveHost,
13
13
  updateHostLabel
14
- } from "./chunk-MR57UIKC.js";
14
+ } from "./chunk-TMMUBSKW.js";
15
15
 
16
16
  // src/commands/config.ts
17
17
  import * as readline from "readline";
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  getActiveHost,
7
7
  safeJsonParse
8
- } from "./chunk-MR57UIKC.js";
8
+ } from "./chunk-TMMUBSKW.js";
9
9
 
10
10
  // src/index.ts
11
11
  import { Command as CommanderCommand } from "commander";
@@ -62,7 +62,7 @@ function createRuntimeContext(cmd, opts, globalOpts) {
62
62
  let _clientModule = null;
63
63
  async function getClient() {
64
64
  if (!_clientModule) {
65
- _clientModule = await import("./client-O56G2SNJ.js");
65
+ _clientModule = await import("./client-FPA76DGY.js");
66
66
  }
67
67
  return _clientModule;
68
68
  }
@@ -105,7 +105,7 @@ function createRuntimeContext(cmd, opts, globalOpts) {
105
105
  return client.queryReportData(projectId, reportId, qp, eventModel, options, ctx.host());
106
106
  },
107
107
  async token() {
108
- const { getToken } = await import("./auth-ECD46NBA.js");
108
+ const { getToken } = await import("./auth-T3ILGJKW.js");
109
109
  return getToken(ctx.host());
110
110
  },
111
111
  host() {
@@ -210,59 +210,64 @@ program.name("ae-cli").version(version).description("CLI tool for ThinkingAI (AE
210
210
  async function loadCommands() {
211
211
  const commands = [];
212
212
  try {
213
- const teAnalysis = await import("./te-analysis-UGKESPBE.js");
213
+ const teAnalysis = await import("./te-analysis-CFQBXUCO.js");
214
214
  commands.push(...teAnalysis.default);
215
215
  } catch {
216
216
  }
217
217
  try {
218
- const teAudience = await import("./te-audience-THZNVHYB.js");
218
+ const teAudience = await import("./te-audience-WPBBWADL.js");
219
219
  commands.push(...teAudience.default);
220
220
  } catch {
221
221
  }
222
222
  try {
223
- const teMeta = await import("./te-meta-MGO5BCMG.js");
223
+ const teMeta = await import("./te-meta-BO45GW32.js");
224
224
  commands.push(...teMeta.default);
225
225
  } catch {
226
226
  }
227
227
  try {
228
- const teCommon = await import("./te-common-QZOUME3S.js");
228
+ const teCommon = await import("./te-common-GL3KBZPD.js");
229
229
  commands.push(...teCommon.default);
230
230
  } catch {
231
231
  }
232
232
  try {
233
- const engage = await import("./te-engage-RYGEQTYK.js");
233
+ const engage = await import("./te-engage-2VFM37ZM.js");
234
234
  commands.push(...engage.default);
235
235
  } catch {
236
236
  }
237
237
  try {
238
- const community = await import("./te-community-AZVW3NFX.js");
238
+ const community = await import("./te-community-3XEJNSQL.js");
239
239
  commands.push(...community.default);
240
240
  } catch {
241
241
  }
242
242
  try {
243
- const dataops = await import("./te-dataops-OE5PX2K6.js");
243
+ const dataops = await import("./te-dataops-H4WSMCG5.js");
244
244
  commands.push(...dataops.default);
245
245
  } catch {
246
246
  }
247
+ try {
248
+ const teKb = await import("./te-kb-U6SQUJVC.js");
249
+ commands.push(...teKb.default);
250
+ } catch {
251
+ }
247
252
  return commands;
248
253
  }
249
254
  async function registerAuthCommands() {
250
255
  try {
251
- const { registerAuth } = await import("./auth-2UTBG5U3.js");
256
+ const { registerAuth } = await import("./auth-A4NV2VHD.js");
252
257
  registerAuth(program);
253
258
  } catch {
254
259
  }
255
260
  }
256
261
  async function registerConfigCommands() {
257
262
  try {
258
- const { registerConfig } = await import("./config-BU5FHGGE.js");
263
+ const { registerConfig } = await import("./config-QZIEYXQZ.js");
259
264
  registerConfig(program);
260
265
  } catch {
261
266
  }
262
267
  }
263
268
  async function registerApiCommand() {
264
269
  try {
265
- const { registerApi } = await import("./raw-A3VN2B6I.js");
270
+ const { registerApi } = await import("./raw-MZIKHQH4.js");
266
271
  registerApi(program);
267
272
  } catch {
268
273
  }
@@ -5,13 +5,13 @@ import {
5
5
  import {
6
6
  httpGet,
7
7
  httpPost
8
- } from "./chunk-LAAS6ITR.js";
8
+ } from "./chunk-TOXRLDUP.js";
9
9
  import {
10
10
  resolveHost
11
- } from "./chunk-4KQ7H7DY.js";
11
+ } from "./chunk-OVMQFFC2.js";
12
12
  import {
13
13
  safeJsonParse
14
- } from "./chunk-MR57UIKC.js";
14
+ } from "./chunk-TMMUBSKW.js";
15
15
 
16
16
  // src/api/raw.ts
17
17
  function registerApi(program) {
@@ -2,9 +2,9 @@ import {
2
2
  callMcpTool,
3
3
  parseMcpResult,
4
4
  resolveMcpUrl
5
- } from "./chunk-7QBNU44L.js";
6
- import "./chunk-4KQ7H7DY.js";
7
- import "./chunk-MR57UIKC.js";
5
+ } from "./chunk-5CCFSPAF.js";
6
+ import "./chunk-OVMQFFC2.js";
7
+ import "./chunk-TMMUBSKW.js";
8
8
 
9
9
  // src/commands/te-analysis/shared.ts
10
10
  function createMcpCommand(config) {
@@ -476,16 +476,16 @@ var dashboard_default = commands3;
476
476
  // src/commands/te-analysis/model/query-adhoc.ts
477
477
  var queryAdhoc = createMcpCommand({
478
478
  command: "+query_adhoc",
479
- description: "Run ad hoc analysis for event, retention, funnel, distribution, attribution, heat map, interval, path, rank list, property analysis, or SQL models. Supports fields/limit/offset pagination.",
479
+ description: "Run ad hoc analysis with an already-built qp. For event, retention, funnel, and prop_analysis, call the matching +build_*_analysis_qp command first and pass its qp; do not handcraft qp or call get_analysis_query_schema/list_events/list_properties/list_metrics/get_metric before the builder. For distribution, attribution, heat_map, interval, path, rank_list, and sql, use the legacy schema/metadata path. Supports fields/limit/offset pagination.",
480
480
  flags: [
481
481
  { name: "project_id", type: "number", required: true, desc: "Project ID", alias: "p" },
482
482
  { name: "model_type", type: "string", required: true, desc: "Model type. Supported values: event, retention, funnel, distribution, attribution, heat_map, interval, path, rank_list, prop_analysis, sql." },
483
- { name: "qp", type: "json", required: true, desc: "Query parameter JSON. Call +get_analysis_query_schema first and keep the time calculation logic consistent with the schema." },
483
+ { name: "qp", type: "json", required: true, desc: "Query parameter JSON. For event/retention/funnel/prop_analysis, pass qp returned by the matching +build_*_analysis_qp command. Use +get_analysis_query_schema only for non-builder/manual model types." },
484
484
  { name: "request_id", type: "string", required: false, desc: "Optional unique request ID used for tracking and deduplication. Generated automatically if omitted." },
485
485
  { name: "use_cache", type: "boolean", required: false, desc: "Whether to use result cache. Default: true" },
486
486
  { name: "zone_offset", type: "number", required: false, desc: "Time zone offset in hours. For example, UTC+8 is 8 and UTC-5 is -5" },
487
487
  { name: "is_sort_by_columns", type: "boolean", required: false, desc: "Whether to sort query results by columns. Default: false" },
488
- { name: "resolve_recent_day", type: "boolean", required: false, desc: "Whether to resolve relative time expressions such as last 7 days. Default: false" },
488
+ { name: "resolve_recent_day", type: "boolean", required: false, desc: "Whether to resolve relative time expressions such as last 7 days. If omitted, the service auto-resolves when qp.eventView.recentDay exists and start/end time is incomplete; otherwise it defaults to false." },
489
489
  { name: "fields", type: "json", required: false, desc: "Optional fields to return. Must match column names in result." },
490
490
  { name: "limit", type: "number", required: false, desc: "Optional limit. Default: 20, maximum: 50." },
491
491
  { name: "offset", type: "number", required: false, desc: "Optional offset. Default: 0." },
@@ -508,6 +508,88 @@ var queryAdhoc = createMcpCommand({
508
508
  })
509
509
  });
510
510
 
511
+ // src/commands/te-analysis/model/build-event-analysis-qp.ts
512
+ var buildEventAnalysisQp = createMcpCommand({
513
+ command: "+build_event_analysis_qp",
514
+ description: "Build a validated event-analysis QP from structured intent. Call before query_adhoc for event ad-hoc analysis. Do not call get_analysis_query_schema/list_events/list_properties/list_metrics/get_metric first; the builder resolves events, properties, and saved metric names internally. For a saved metric, pass its name in metrics[].event. This command only builds qp and does not execute query_adhoc.",
515
+ flags: [
516
+ { name: "project_id", type: "number", required: true, desc: "Project ID", alias: "p" },
517
+ { name: "time_range", type: "json", required: true, desc: "Required time range JSON for event analysis." },
518
+ { name: "metrics", type: "json", required: true, desc: "Required event metrics JSON array." },
519
+ { name: "time_particle_size", type: "string", required: false, desc: "Optional time granularity. Default: total." },
520
+ { name: "groups", type: "json", required: false, desc: "Optional group-by dimensions JSON array." },
521
+ { name: "filters", type: "json", required: false, desc: "Optional global filters JSON array." },
522
+ { name: "relation", type: "string", required: false, desc: "Optional filter relation. Supported values: and, or. Default: and." }
523
+ ],
524
+ risk: "read",
525
+ buildArgs: (ctx) => ({
526
+ projectId: ctx.num("project_id"),
527
+ timeRange: ctx.json("time_range"),
528
+ metrics: ctx.json("metrics"),
529
+ timeParticleSize: ctx.str("time_particle_size") || void 0,
530
+ groups: optionalJson(ctx, "groups"),
531
+ filters: optionalJson(ctx, "filters"),
532
+ relation: ctx.str("relation") || void 0
533
+ })
534
+ });
535
+
536
+ // src/commands/te-analysis/model/build-retention-analysis-qp.ts
537
+ var buildRetentionAnalysisQp = createMcpCommand({
538
+ command: "+build_retention_analysis_qp",
539
+ description: "Build a validated retention-analysis QP from structured intent. Call before query_adhoc for retention ad-hoc analysis. Do not call get_analysis_query_schema/list_events/list_properties/list_metrics/get_metric first; the builder resolves events and properties internally. This command only builds qp and does not execute query_adhoc.",
540
+ flags: [
541
+ { name: "project_id", type: "number", required: true, desc: "Project ID", alias: "p" },
542
+ { name: "time_range", type: "json", required: true, desc: "Required time range JSON for retention analysis." },
543
+ { name: "retention", type: "json", required: true, desc: "Required retention intent JSON." },
544
+ { name: "relation", type: "string", required: false, desc: "Optional top-level retention filter relation. Supported values: and, or. Default: and." },
545
+ { name: "time_particle_size", type: "string", required: false, desc: "Optional time granularity. Supported values: day, week, month." }
546
+ ],
547
+ risk: "read",
548
+ buildArgs: (ctx) => ({
549
+ projectId: ctx.num("project_id"),
550
+ timeRange: ctx.json("time_range"),
551
+ retention: ctx.json("retention"),
552
+ relation: ctx.str("relation") || void 0,
553
+ timeParticleSize: ctx.str("time_particle_size") || void 0
554
+ })
555
+ });
556
+
557
+ // src/commands/te-analysis/model/build-funnel-analysis-qp.ts
558
+ var buildFunnelAnalysisQp = createMcpCommand({
559
+ command: "+build_funnel_analysis_qp",
560
+ description: "Build a validated funnel-analysis QP from structured intent. Call before query_adhoc for funnel ad-hoc analysis. Do not call get_analysis_query_schema/list_events/list_properties/list_metrics/get_metric first; the builder resolves events and properties internally. This command only builds qp and does not execute query_adhoc.",
561
+ flags: [
562
+ { name: "project_id", type: "number", required: true, desc: "Project ID", alias: "p" },
563
+ { name: "time_range", type: "json", required: true, desc: "Required time range JSON for funnel analysis." },
564
+ { name: "funnel", type: "json", required: true, desc: "Required funnel intent JSON." },
565
+ { name: "relation", type: "string", required: false, desc: "Optional top-level funnel filter relation. Supported values: and, or. Default: and." },
566
+ { name: "time_particle_size", type: "string", required: false, desc: "Optional time granularity. Supported values: day, week, month." }
567
+ ],
568
+ risk: "read",
569
+ buildArgs: (ctx) => ({
570
+ projectId: ctx.num("project_id"),
571
+ timeRange: ctx.json("time_range"),
572
+ funnel: ctx.json("funnel"),
573
+ relation: ctx.str("relation") || void 0,
574
+ timeParticleSize: ctx.str("time_particle_size") || void 0
575
+ })
576
+ });
577
+
578
+ // src/commands/te-analysis/model/build-prop-analysis-qp.ts
579
+ var buildPropAnalysisQp = createMcpCommand({
580
+ command: "+build_prop_analysis_qp",
581
+ description: "Build a validated prop-analysis QP from structured intent. Call before query_adhoc for prop_analysis ad-hoc analysis. Do not call get_analysis_query_schema/list_properties/list_metrics/get_metric first; the builder resolves user properties internally. This command only builds qp and does not execute query_adhoc.",
582
+ flags: [
583
+ { name: "project_id", type: "number", required: true, desc: "Project ID", alias: "p" },
584
+ { name: "prop_analysis", type: "json", required: true, desc: "Required user property analysis intent JSON." }
585
+ ],
586
+ risk: "read",
587
+ buildArgs: (ctx) => ({
588
+ projectId: ctx.num("project_id"),
589
+ propAnalysis: ctx.json("prop_analysis")
590
+ })
591
+ });
592
+
511
593
  // src/commands/te-analysis/model/drilldown-users.ts
512
594
  var drilldownUsers = createMcpCommand({
513
595
  command: "+drilldown_users",
@@ -709,6 +791,10 @@ var getTableColumns = createMcpCommand({
709
791
 
710
792
  // src/commands/te-analysis/model/index.ts
711
793
  var commands4 = [
794
+ buildEventAnalysisQp,
795
+ buildRetentionAnalysisQp,
796
+ buildFunnelAnalysisQp,
797
+ buildPropAnalysisQp,
712
798
  queryAdhoc,
713
799
  drilldownUsers,
714
800
  drilldownUserEvents,
@@ -854,7 +940,7 @@ var entity_default = commands5;
854
940
  // src/commands/te-analysis/schema/get-analysis-query-schema.ts
855
941
  var getAnalysisQuerySchema = createMcpCommand({
856
942
  command: "+get_analysis_query_schema",
857
- description: "Get the analysis query schema for the specified model type. Returns field definitions and usage examples. Core segment contains basic request structure + common CalcType (~13 operators) + common AggregateType (~10 metrics). For most queries, core alone is sufficient.",
943
+ description: "Get the analysis query schema for non-builder/manual model paths. Do not use this tool for natural-language event, retention, funnel, or prop_analysis ad-hoc analysis; use the matching +build_*_analysis_qp command then +query_adhoc. Returns field definitions and usage examples for low-level/manual QP construction.",
858
944
  flags: [
859
945
  { name: "model_type", type: "string", required: true, desc: "Model type. Supported values: event, retention, funnel, distribution, sql, interval, path, attribution, prop_analysis, rank_list, heat_map" },
860
946
  { name: "segments", type: "string", required: false, desc: "Schema segments to include (comma-separated). Options: core, filter_group, calctype, aggregatetype, examples, full. Empty/null \u2192 core only (recommended)." },
@@ -2,9 +2,9 @@ import {
2
2
  callMcpTool,
3
3
  parseMcpResult,
4
4
  resolveMcpUrl
5
- } from "./chunk-7QBNU44L.js";
6
- import "./chunk-4KQ7H7DY.js";
7
- import "./chunk-MR57UIKC.js";
5
+ } from "./chunk-5CCFSPAF.js";
6
+ import "./chunk-OVMQFFC2.js";
7
+ import "./chunk-TMMUBSKW.js";
8
8
 
9
9
  // src/commands/te-audience/shared.ts
10
10
  function createMcpCommand(config) {
@@ -2,9 +2,9 @@ import {
2
2
  callMcpTool,
3
3
  parseMcpResult,
4
4
  resolveMcpUrl
5
- } from "./chunk-7QBNU44L.js";
6
- import "./chunk-4KQ7H7DY.js";
7
- import "./chunk-MR57UIKC.js";
5
+ } from "./chunk-5CCFSPAF.js";
6
+ import "./chunk-OVMQFFC2.js";
7
+ import "./chunk-TMMUBSKW.js";
8
8
 
9
9
  // src/commands/te-common/shared.ts
10
10
  function createMcpCommand(config) {
@@ -3,9 +3,9 @@ import {
3
3
  parseMcpResult,
4
4
  registerMcpMappings,
5
5
  resolveMcpUrl
6
- } from "./chunk-7QBNU44L.js";
7
- import "./chunk-4KQ7H7DY.js";
8
- import "./chunk-MR57UIKC.js";
6
+ } from "./chunk-5CCFSPAF.js";
7
+ import "./chunk-OVMQFFC2.js";
8
+ import "./chunk-TMMUBSKW.js";
9
9
 
10
10
  // src/commands/te-community/get_channel_info.ts
11
11
  var getChannelInfo = {
@@ -3,9 +3,9 @@ import {
3
3
  parseMcpResult,
4
4
  registerMcpMappings,
5
5
  resolveMcpUrl
6
- } from "./chunk-7QBNU44L.js";
7
- import "./chunk-4KQ7H7DY.js";
8
- import "./chunk-MR57UIKC.js";
6
+ } from "./chunk-5CCFSPAF.js";
7
+ import "./chunk-OVMQFFC2.js";
8
+ import "./chunk-TMMUBSKW.js";
9
9
 
10
10
  // src/commands/te-dataops/datatable/list-tables-by-page.ts
11
11
  var listTablesByPage = {
@@ -3,9 +3,9 @@ import {
3
3
  parseMcpResult,
4
4
  registerMcpMappings,
5
5
  resolveMcpUrl
6
- } from "./chunk-7QBNU44L.js";
7
- import "./chunk-4KQ7H7DY.js";
8
- import "./chunk-MR57UIKC.js";
6
+ } from "./chunk-5CCFSPAF.js";
7
+ import "./chunk-OVMQFFC2.js";
8
+ import "./chunk-TMMUBSKW.js";
9
9
 
10
10
  // src/commands/te-engage/utils.ts
11
11
  function buildMcpDryRun(ctx, serviceName44, toolName44, args) {
@@ -0,0 +1,41 @@
1
+ // src/commands/te-kb/query.ts
2
+ var API_PATH = "/api/external/knowledge-bases/query";
3
+ function buildBody(ctx) {
4
+ const body = {
5
+ query: ctx.str("query"),
6
+ sources: ctx.json("sources")
7
+ };
8
+ const modelId = ctx.str("model-id");
9
+ if (modelId) body.modelId = modelId;
10
+ const maxTurnsRaw = ctx.str("max-turns");
11
+ if (maxTurnsRaw !== "") body.maxTurns = ctx.num("max-turns");
12
+ return body;
13
+ }
14
+ var query = {
15
+ service: "kb",
16
+ command: "+query",
17
+ description: "Query knowledge bases via /api/external/knowledge-bases/query.",
18
+ flags: [
19
+ { name: "query", type: "string", required: true, alias: "q", desc: "Natural language question to query against the knowledge bases" },
20
+ { name: "sources", type: "json", required: true, desc: 'JSON array of knowledge base refs, e.g. [{"scope":"company","name":"engineering-handbook"}]' },
21
+ { name: "model-id", type: "string", required: false, default: "AE-Auto", desc: "Model identifier (default: AE-Auto)" },
22
+ { name: "max-turns", type: "number", required: false, default: 6, desc: "Maximum reasoning turns (default: 6)" }
23
+ ],
24
+ risk: "read",
25
+ dryRun: (ctx) => ({
26
+ method: "POST",
27
+ url: `${ctx.host().replace(/\/$/, "")}${API_PATH}`,
28
+ body: buildBody(ctx)
29
+ }),
30
+ execute: async (ctx) => ctx.api("POST", API_PATH, {}, buildBody(ctx))
31
+ };
32
+
33
+ // src/commands/te-kb/index.ts
34
+ var commands = [
35
+ query
36
+ ];
37
+ var te_kb_default = commands;
38
+ export {
39
+ te_kb_default as default,
40
+ query
41
+ };
@@ -2,9 +2,9 @@ import {
2
2
  callMcpTool,
3
3
  parseMcpResult,
4
4
  resolveMcpUrl
5
- } from "./chunk-7QBNU44L.js";
6
- import "./chunk-4KQ7H7DY.js";
7
- import "./chunk-MR57UIKC.js";
5
+ } from "./chunk-5CCFSPAF.js";
6
+ import "./chunk-OVMQFFC2.js";
7
+ import "./chunk-TMMUBSKW.js";
8
8
 
9
9
  // src/commands/te-meta/shared.ts
10
10
  function createMcpCommand(config) {
@@ -58,7 +58,7 @@ function requiredJsonString(ctx, name) {
58
58
  // src/commands/te-meta/meta/list-events.ts
59
59
  var listEvents = createMcpCommand({
60
60
  command: "+list_events",
61
- description: "List events in the project. Query performs fuzzy matching on eventName, eventDesc and aiRemark. Supports fields/limit/offset payload governance.",
61
+ description: "List events in the project. Use for explicit metadata inspection, not as a pre-step for event/retention/funnel/prop_analysis ad-hoc builders; the builders resolve event names internally. Query performs fuzzy matching on eventName, eventDesc and aiRemark. Supports fields/limit/offset payload governance.",
62
62
  flags: [
63
63
  { name: "project_id", type: "number", required: true, desc: "Project ID", alias: "p" },
64
64
  { name: "query", type: "string", required: false, desc: "Optional keyword filter. Fuzzy match is applied to eventName, eventDesc, and aiRemark; if omitted, all events are returned.", alias: "q" },
@@ -79,7 +79,7 @@ var listEvents = createMcpCommand({
79
79
  // src/commands/te-meta/meta/list-properties.ts
80
80
  var listProperties = createMcpCommand({
81
81
  command: "+list_properties",
82
- description: "List properties in the project. Query performs fuzzy matching on propName, propDesc and aiRemark. Supports fields/limit/offset payload governance.",
82
+ description: "List properties in the project. Use for explicit metadata inspection, not as a pre-step for event/retention/funnel/prop_analysis ad-hoc builders; the builders resolve property names internally. Query performs fuzzy matching on propName, propDesc and aiRemark. Supports fields/limit/offset payload governance.",
83
83
  flags: [
84
84
  { name: "project_id", type: "number", required: true, desc: "Project ID", alias: "p" },
85
85
  { name: "scope", type: "string", required: false, desc: "Property scope: event or user" },
@@ -198,7 +198,7 @@ var createVirtualProperty = createMcpCommand({
198
198
  // src/commands/te-meta/meta/list-metrics.ts
199
199
  var listMetrics = createMcpCommand({
200
200
  command: "+list_metrics",
201
- description: "List metric metadata in the project. Query performs fuzzy matching on metricName, metricDesc, and metricRemark. Supports fields/limit/offset pagination.",
201
+ description: "List metric metadata in the project. Use for metric metadata inspection/management, not as a pre-step for event/retention/funnel/prop_analysis ad-hoc builders. For event saved metric queries, pass the metric name directly to +build_event_analysis_qp in metrics[].event. Query performs fuzzy matching on metricName, metricDesc, and metricRemark. Supports fields/limit/offset pagination.",
202
202
  flags: [
203
203
  { name: "project_id", type: "number", required: true, alias: "p", desc: "Project ID" },
204
204
  { name: "query", type: "string", required: false, alias: "q", desc: "Optional keyword filter. Fuzzy match on metricName, metricDesc, metricRemark." },
@@ -220,7 +220,7 @@ var listMetrics = createMcpCommand({
220
220
  // src/commands/te-meta/meta/get-metric.ts
221
221
  var getMetric = createMcpCommand({
222
222
  command: "+get_metric",
223
- description: "Get the definition details of a single metric",
223
+ description: "Get the definition details of a single metric. Use for metric metadata inspection/management, not as a pre-step for event ad-hoc builder; pass saved metric names directly to +build_event_analysis_qp in metrics[].event.",
224
224
  flags: [
225
225
  { name: "project_id", type: "number", required: true, alias: "p", desc: "Project ID" },
226
226
  { name: "metric_id", type: "number", required: true, alias: "m", desc: "Metric ID" }