@thinkingai/ae-cli 6.1.4 → 6.1.5
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.
- package/dist/{auth-MEJ642P4.js → auth-ENM3FE6L.js} +3 -2
- package/dist/{auth-7H3HAAJ3.js → auth-UPGUOKTW.js} +13 -6
- package/dist/{capability-QW4AVJHI.js → capability-AJC5CBRT.js} +49 -17
- package/dist/{capability-SCRFGODD.js → capability-TQ5KU5Q6.js} +49 -17
- package/dist/chunk-24BAVOX3.js +51 -0
- package/dist/{chunk-MDJGDI6K.js → chunk-3KI3RRXX.js} +5 -5
- package/dist/{chunk-PKRD2IEM.js → chunk-3P3562ZX.js} +9 -7
- package/dist/{chunk-R77JT7XD.js → chunk-4Q5TNP4Q.js} +4 -4
- package/dist/{chunk-7OLGDQQ2.js → chunk-6CHYBI64.js} +2 -2
- package/dist/{chunk-6LEYLOV3.js → chunk-CPVTECJ3.js} +9 -7
- package/dist/{chunk-KCA6BA5D.js → chunk-DB4Q3ANU.js} +5 -3
- package/dist/{chunk-2NDGFQHW.js → chunk-E7UXXHO3.js} +11 -3
- package/dist/{chunk-I4A62X3N.js → chunk-HQ2A7ITL.js} +23 -14
- package/dist/chunk-IMMGMU54.js +674 -0
- package/dist/{chunk-AJTH7LT3.js → chunk-IR4ZLVPW.js} +4 -2
- package/dist/{chunk-TBHBYKXZ.js → chunk-ISY6HMHM.js} +2 -2
- package/dist/{chunk-KGJQCYVC.js → chunk-LCXU3AAT.js} +4 -2
- package/dist/chunk-LYVNONC4.js +86 -0
- package/dist/{chunk-DYOS6YY7.js → chunk-RGXCNC4N.js} +23 -14
- package/dist/{chunk-YCLVYFK7.js → chunk-V6FR6WTW.js} +45 -87
- package/dist/chunk-VTWMIC5L.js +27 -0
- package/dist/{cli-token-TVQRSE46.js → cli-token-4SBMXAUK.js} +6 -3
- package/dist/{client-2643Z5AG.js → client-PP5FETMW.js} +4 -3
- package/dist/community-report-client-KK2QBANO.js +145 -0
- package/dist/{config-7UZWDE74.js → config-RCCGHHYA.js} +6 -3
- package/dist/index.js +506 -221
- package/dist/{metadata-BFDL6RUK.js → metadata-3M5F2AED.js} +14 -13
- package/dist/{metadata-FCLDBXX2.js → metadata-W2MEOI4Z.js} +14 -13
- package/dist/{model-T3KZJWLW.js → model-OYQLXCQY.js} +3 -2
- package/dist/{raw-CN542NGT.js → raw-TPB7KSZO.js} +6 -4
- package/dist/{sync-ERNHDPB5.js → sync-EFJKFZK2.js} +6 -3
- package/dist/{te-agent-FCCWUDTJ.js → te-agent-K2OWMZXT.js} +3 -2
- package/dist/{te-analysis-PUVF5IF4.js → te-analysis-I73ZS4NK.js} +903 -33
- package/dist/{te-analysis-UJDOKPAN.js → te-analysis-Q7AZCDU4.js} +903 -33
- package/dist/{te-common-XLAGWNIV.js → te-common-ST3QPSXJ.js} +7 -6
- package/dist/{te-common-VUX3VOXZ.js → te-common-WSLIKKPC.js} +7 -6
- package/dist/te-community-WXGB6IOX.js +1659 -0
- package/dist/te-community-X2AHXGCA.js +1659 -0
- package/dist/{te-dataops-ZNJBQ6VT.js → te-dataops-MJV54MNY.js} +10 -8
- package/dist/{te-dataops-F36T656A.js → te-dataops-OA7I6HBG.js} +10 -8
- package/dist/{te-engage-K4AEUPK5.js → te-engage-GJRVQMK3.js} +10 -9
- package/dist/{te-engage-QBCCME22.js → te-engage-JIXX3WBI.js} +10 -9
- package/dist/{te-experiment-JINSMHMW.js → te-experiment-JKX4FH6D.js} +7 -6
- package/dist/{te-experiment-NWNQHJS5.js → te-experiment-UMSHBBKI.js} +7 -6
- package/dist/{te-kb-AYCODNU6.js → te-kb-CIZXRWMO.js} +49 -6
- package/dist/{te-meta-ARDIW3YI.js → te-meta-Q4L6EE3Q.js} +7 -6
- package/dist/{te-meta-UUROEODR.js → te-meta-VHCN4Q62.js} +7 -6
- package/dist/{te-team-OKCOX7OE.js → te-team-PDKKW7Q5.js} +7 -6
- package/dist/tracking/i18n/resources/cli/en.json +4 -3
- package/dist/tracking/i18n/resources/cli/ja.json +4 -3
- package/dist/tracking/i18n/resources/cli/ko.json +4 -3
- package/dist/tracking/i18n/resources/cli/zh.json +4 -3
- package/package.json +6 -2
- package/skills/ae-agent/SKILL.md +2 -1
- package/skills/ae-analysis/SKILL.md +12 -1
- package/skills/ae-analysis/references/adhoc_export.md +2 -0
- package/skills/ae-analysis/references/adhoc_run.md +2 -0
- package/skills/ae-analysis/references/alert_create.md +25 -0
- package/skills/ae-analysis/references/alert_definition_schema_get.md +24 -0
- package/skills/ae-analysis/references/alert_delete.md +26 -0
- package/skills/ae-analysis/references/alert_detail_list.md +27 -0
- package/skills/ae-analysis/references/alert_get.md +25 -0
- package/skills/ae-analysis/references/alert_job_list.md +24 -0
- package/skills/ae-analysis/references/alert_list.md +27 -0
- package/skills/ae-analysis/references/alert_notice_config_list.md +24 -0
- package/skills/ae-analysis/references/alert_start.md +25 -0
- package/skills/ae-analysis/references/alert_stop.md +25 -0
- package/skills/ae-analysis/references/alert_update.md +26 -0
- package/skills/ae-analysis/references/bi_panel_create.md +3 -3
- package/skills/ae-analysis/references/check_delete.md +27 -0
- package/skills/ae-analysis/references/check_export.md +27 -0
- package/skills/ae-analysis/references/check_get.md +27 -0
- package/skills/ae-analysis/references/check_list.md +24 -0
- package/skills/ae-analysis/references/check_retry.md +27 -0
- package/skills/ae-analysis/references/check_run.md +25 -0
- package/skills/ae-analysis/references/command_index.md +61 -27
- package/skills/ae-analysis/references/dashboard_create.md +3 -3
- package/skills/ae-analysis/references/dashboard_daily_report_send.md +1 -0
- package/skills/ae-analysis/references/dashboard_daily_report_update.md +2 -0
- package/skills/ae-analysis/references/dashboard_report_data_export.md +3 -3
- package/skills/ae-analysis/references/dashboard_report_data_run.md +3 -3
- package/skills/ae-analysis/references/event_blacklist_add.md +25 -0
- package/skills/ae-analysis/references/event_blacklist_list.md +24 -0
- package/skills/ae-analysis/references/event_blacklist_update.md +26 -0
- package/skills/ae-analysis/references/ingest_error_list.md +27 -0
- package/skills/ae-analysis/references/ingest_summary.md +26 -0
- package/skills/ae-analysis/references/live_data_export.md +27 -0
- package/skills/ae-analysis/references/live_data_list.md +27 -0
- package/skills/ae-analysis/references/plan_change_log_export.md +27 -0
- package/skills/ae-analysis/references/plan_change_log_list.md +24 -0
- package/skills/ae-analysis/references/plan_delete_items.md +30 -0
- package/skills/ae-analysis/references/plan_export.md +26 -0
- package/skills/ae-analysis/references/plan_generate.md +27 -0
- package/skills/ae-analysis/references/plan_get.md +24 -0
- package/skills/ae-analysis/references/plan_import_excel.md +26 -0
- package/skills/ae-analysis/references/plan_save_items.md +27 -0
- package/skills/ae-analysis/references/plan_sync_from_meta.md +24 -0
- package/skills/ae-analysis/references/project_role_delete.md +4 -3
- package/skills/ae-analysis/references/project_role_get.md +4 -3
- package/skills/ae-analysis/references/project_role_user_list.md +4 -3
- package/skills/ae-analysis/references/query_create_result_cluster.md +2 -1
- package/skills/ae-analysis/references/report_data_export.md +3 -1
- package/skills/ae-analysis/references/report_data_run.md +12 -2
- package/skills/ae-analysis/references/sdk_sample_generate.md +24 -0
- package/skills/ae-analysis/references/user_cluster_create.md +2 -0
- package/skills/ae-analysis/references/user_cluster_create_id.md +2 -0
- package/skills/ae-analysis/references/user_cluster_update.md +2 -0
- package/skills/ae-analysis/references/user_cluster_update_id.md +2 -0
- package/skills/ae-analysis/references/user_tag_create.md +2 -0
- package/skills/ae-analysis/references/user_tag_create_id.md +2 -0
- package/skills/ae-analysis/references/user_tag_update.md +2 -0
- package/skills/ae-analysis/references/user_tag_update_id.md +2 -0
- package/skills/ae-analysis-global/SKILL.md +2 -0
- package/skills/ae-capability/SKILL.md +7 -5
- package/skills/ae-community/SKILL.md +72 -8
- package/skills/ae-community/references/community-chat-analysis.md +341 -0
- package/skills/ae-community/references/community-data-report.md +301 -0
- package/skills/ae-dataops/SKILL.md +2 -1
- package/skills/ae-engage/SKILL.md +2 -1
- package/skills/ae-generate-tracking-code/SKILL.md +4 -4
- package/skills/ae-generate-tracking-plan/SKILL.md +132 -11
- package/skills/ae-generate-tracking-plan/references/business-dimension-mapping.md +98 -33
- package/skills/ae-generate-tracking-plan/references/xlsx-schema.md +16 -14
- package/skills/ae-kb/SKILL.md +2 -1
- package/skills/ae-metadata/SKILL.md +2 -1
- package/skills/ae-team/SKILL.md +2 -1
- package/dist/chunk-NOO24N7W.js +0 -11
- package/dist/chunk-TNW2CI4W.js +0 -129
- package/dist/te-community-PEZ2VEF7.js +0 -687
- package/dist/te-community-TSKJ652U.js +0 -687
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/core/logger.ts
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
var LOG_DIR = path.join(process.env.HOME || "", ".ae-cli", "log");
|
|
5
|
+
var Logger = class {
|
|
6
|
+
logDir;
|
|
7
|
+
date;
|
|
8
|
+
constructor() {
|
|
9
|
+
this.logDir = LOG_DIR;
|
|
10
|
+
this.date = this.today();
|
|
11
|
+
this.ensureDir();
|
|
12
|
+
}
|
|
13
|
+
today() {
|
|
14
|
+
const d = /* @__PURE__ */ new Date();
|
|
15
|
+
return `${d.getFullYear()}${String(d.getMonth() + 1).padStart(2, "0")}${String(d.getDate()).padStart(2, "0")}`;
|
|
16
|
+
}
|
|
17
|
+
timestamp() {
|
|
18
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").split(".")[0];
|
|
19
|
+
}
|
|
20
|
+
ensureDir() {
|
|
21
|
+
if (!fs.existsSync(this.logDir)) {
|
|
22
|
+
fs.mkdirSync(this.logDir, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
filePath(level) {
|
|
26
|
+
const today = this.today();
|
|
27
|
+
if (today !== this.date) {
|
|
28
|
+
this.date = today;
|
|
29
|
+
}
|
|
30
|
+
return path.join(this.logDir, `${this.date}_${level}.log`);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Write a log entry to file (not printed to the console; console output is handled by existing process.stderr.write calls)
|
|
34
|
+
*/
|
|
35
|
+
write(level, message) {
|
|
36
|
+
const ts = this.timestamp();
|
|
37
|
+
const line = `[${ts}] ${message}
|
|
38
|
+
`;
|
|
39
|
+
try {
|
|
40
|
+
fs.appendFileSync(this.filePath(level), line);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Informational log */
|
|
45
|
+
info(message) {
|
|
46
|
+
this.write("info", message);
|
|
47
|
+
}
|
|
48
|
+
/** Warning log */
|
|
49
|
+
warn(message) {
|
|
50
|
+
this.write("warning", message);
|
|
51
|
+
}
|
|
52
|
+
/** Error log */
|
|
53
|
+
error(message) {
|
|
54
|
+
this.write("error", message);
|
|
55
|
+
}
|
|
56
|
+
/** Log HTTP API request details */
|
|
57
|
+
api(method, url, status, reqBody, respBody) {
|
|
58
|
+
const parts = [`API ${method} ${url} \u2192 HTTP ${status}`];
|
|
59
|
+
if (reqBody !== void 0 && reqBody !== null) {
|
|
60
|
+
const s = typeof reqBody === "string" ? reqBody : JSON.stringify(reqBody);
|
|
61
|
+
parts.push(`REQ: ${s.slice(0, 500)}`);
|
|
62
|
+
}
|
|
63
|
+
if (respBody !== void 0 && respBody !== null) {
|
|
64
|
+
const s = typeof respBody === "string" ? respBody : JSON.stringify(respBody);
|
|
65
|
+
parts.push(`RESP: ${s.slice(0, 500)}`);
|
|
66
|
+
}
|
|
67
|
+
this.info(parts.join(" | "));
|
|
68
|
+
}
|
|
69
|
+
/** Log command execution (sensitive flags redacted to ***) */
|
|
70
|
+
command(name, args, sensitiveFlags = []) {
|
|
71
|
+
const normalizeFlagName = (name2) => name2.toLowerCase().replace(/[-_]/g, "");
|
|
72
|
+
const explicitSensitive = new Set(Array.from(sensitiveFlags, normalizeFlagName));
|
|
73
|
+
const SENSITIVE = ["token", "apikey", "secret", "accesstoken", "headers"];
|
|
74
|
+
const isSensitive = (k) => {
|
|
75
|
+
const normalized = normalizeFlagName(k);
|
|
76
|
+
return explicitSensitive.has(normalized) || SENSITIVE.some((s) => normalized.includes(s));
|
|
77
|
+
};
|
|
78
|
+
const filtered = Object.entries(args).filter(([, v]) => v !== void 0 && v !== null && v !== "").map(([k, v]) => `--${k}=${isSensitive(k) ? "***" : JSON.stringify(v)}`).join(" ");
|
|
79
|
+
this.info(`CMD ${name}${filtered ? " " + filtered : ""}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var logger = new Logger();
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
logger
|
|
86
|
+
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PermissionError
|
|
3
|
-
} from "./chunk-NOO24N7W.js";
|
|
4
1
|
import {
|
|
5
2
|
clearCliToken,
|
|
6
3
|
getCliToken
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-E7UXXHO3.js";
|
|
8
5
|
import {
|
|
9
|
-
logger,
|
|
10
6
|
safeJsonParse
|
|
11
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-V6FR6WTW.js";
|
|
8
|
+
import {
|
|
9
|
+
PermissionError
|
|
10
|
+
} from "./chunk-24BAVOX3.js";
|
|
11
|
+
import {
|
|
12
|
+
logger
|
|
13
|
+
} from "./chunk-LYVNONC4.js";
|
|
12
14
|
|
|
13
15
|
// src/core/capability-api.ts
|
|
14
16
|
import { readFile } from "fs/promises";
|
|
@@ -147,11 +149,11 @@ async function requestMultipartOnce(url, token, form) {
|
|
|
147
149
|
body: form
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
|
-
async function callGateway(host, domain, pathAfterV1, method, body) {
|
|
151
|
-
return (await callGatewayWithEnvelope(host, domain, pathAfterV1, method, body)).data;
|
|
152
|
+
async function callGateway(host, domain, pathAfterV1, method, body, queryParams = {}) {
|
|
153
|
+
return (await callGatewayWithEnvelope(host, domain, pathAfterV1, method, body, queryParams)).data;
|
|
152
154
|
}
|
|
153
|
-
async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body) {
|
|
154
|
-
const url = buildCapabilityGatewayUrl(host, domain, pathAfterV1);
|
|
155
|
+
async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body, queryParams = {}) {
|
|
156
|
+
const url = buildCapabilityGatewayUrl(host, domain, pathAfterV1, queryParams);
|
|
155
157
|
const token = await getCliToken(host);
|
|
156
158
|
let resp = await requestOnce(url, method, token, body);
|
|
157
159
|
let permissionMsg;
|
|
@@ -212,11 +214,18 @@ async function requestCapabilityGatewayWithEnvelope(host, domain, pathAfterV1, m
|
|
|
212
214
|
const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
|
|
213
215
|
return parseCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
|
|
214
216
|
}
|
|
215
|
-
async function listCapabilities(host, domain) {
|
|
216
|
-
return callGateway(host, domain, "capabilities", "GET");
|
|
217
|
+
async function listCapabilities(host, domain, projectId) {
|
|
218
|
+
return callGateway(host, domain, "capabilities", "GET", void 0, { project_id: projectId });
|
|
217
219
|
}
|
|
218
|
-
async function inspectCapability(host, domain, capabilityId) {
|
|
219
|
-
return callGateway(
|
|
220
|
+
async function inspectCapability(host, domain, capabilityId, projectId) {
|
|
221
|
+
return callGateway(
|
|
222
|
+
host,
|
|
223
|
+
domain,
|
|
224
|
+
`capabilities/${capabilityId}`,
|
|
225
|
+
"GET",
|
|
226
|
+
void 0,
|
|
227
|
+
{ project_id: projectId }
|
|
228
|
+
);
|
|
220
229
|
}
|
|
221
230
|
async function executeCapability(host, domain, capabilityId, input = {}) {
|
|
222
231
|
return callGateway(host, domain, `capabilities/${capabilityId}/execute`, "POST", { input });
|
|
@@ -1,95 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-LYVNONC4.js";
|
|
4
|
+
|
|
5
|
+
// src/core/json-utils.ts
|
|
2
6
|
import fs from "fs";
|
|
3
|
-
import
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
today() {
|
|
14
|
-
const d = /* @__PURE__ */ new Date();
|
|
15
|
-
return `${d.getFullYear()}${String(d.getMonth() + 1).padStart(2, "0")}${String(d.getDate()).padStart(2, "0")}`;
|
|
16
|
-
}
|
|
17
|
-
timestamp() {
|
|
18
|
-
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").split(".")[0];
|
|
19
|
-
}
|
|
20
|
-
ensureDir() {
|
|
21
|
-
if (!fs.existsSync(this.logDir)) {
|
|
22
|
-
fs.mkdirSync(this.logDir, { recursive: true });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
filePath(level) {
|
|
26
|
-
const today = this.today();
|
|
27
|
-
if (today !== this.date) {
|
|
28
|
-
this.date = today;
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
var require2 = createRequire(import.meta.url);
|
|
9
|
+
var JSONbig = require2("json-bigint");
|
|
10
|
+
var jsonParser = JSONbig({ storeAsString: true });
|
|
11
|
+
var INTEGER_TOKEN = /^-?(?:0|[1-9]\d*)$/;
|
|
12
|
+
function normalizeParsedNumbers(lossless, native) {
|
|
13
|
+
if (typeof lossless === "string" && typeof native === "number") {
|
|
14
|
+
if (INTEGER_TOKEN.test(lossless) && !Number.isSafeInteger(native)) {
|
|
15
|
+
return lossless;
|
|
29
16
|
}
|
|
30
|
-
return
|
|
17
|
+
return native;
|
|
31
18
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
write(level, message) {
|
|
36
|
-
const ts = this.timestamp();
|
|
37
|
-
const line = `[${ts}] ${message}
|
|
38
|
-
`;
|
|
39
|
-
try {
|
|
40
|
-
fs.appendFileSync(this.filePath(level), line);
|
|
41
|
-
} catch {
|
|
19
|
+
if (Array.isArray(lossless) && Array.isArray(native)) {
|
|
20
|
+
for (let index = 0; index < lossless.length; index++) {
|
|
21
|
+
lossless[index] = normalizeParsedNumbers(lossless[index], native[index]);
|
|
42
22
|
}
|
|
23
|
+
return lossless;
|
|
43
24
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
/** Warning log */
|
|
49
|
-
warn(message) {
|
|
50
|
-
this.write("warning", message);
|
|
51
|
-
}
|
|
52
|
-
/** Error log */
|
|
53
|
-
error(message) {
|
|
54
|
-
this.write("error", message);
|
|
55
|
-
}
|
|
56
|
-
/** Log HTTP API request details */
|
|
57
|
-
api(method, url, status, reqBody, respBody) {
|
|
58
|
-
const parts = [`API ${method} ${url} \u2192 HTTP ${status}`];
|
|
59
|
-
if (reqBody !== void 0 && reqBody !== null) {
|
|
60
|
-
const s = typeof reqBody === "string" ? reqBody : JSON.stringify(reqBody);
|
|
61
|
-
parts.push(`REQ: ${s.slice(0, 500)}`);
|
|
62
|
-
}
|
|
63
|
-
if (respBody !== void 0 && respBody !== null) {
|
|
64
|
-
const s = typeof respBody === "string" ? respBody : JSON.stringify(respBody);
|
|
65
|
-
parts.push(`RESP: ${s.slice(0, 500)}`);
|
|
25
|
+
if (lossless !== null && native !== null && typeof lossless === "object" && typeof native === "object") {
|
|
26
|
+
for (const key of Object.keys(lossless)) {
|
|
27
|
+
lossless[key] = normalizeParsedNumbers(lossless[key], native[key]);
|
|
66
28
|
}
|
|
67
|
-
this.info(parts.join(" | "));
|
|
68
29
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const SENSITIVE = ["token", "apikey", "secret", "accesstoken", "headers"];
|
|
72
|
-
const isSensitive = (k) => {
|
|
73
|
-
const lk = k.toLowerCase();
|
|
74
|
-
return SENSITIVE.some((s) => lk.includes(s));
|
|
75
|
-
};
|
|
76
|
-
const filtered = Object.entries(args).filter(([, v]) => v !== void 0 && v !== null && v !== "").map(([k, v]) => `--${k}=${isSensitive(k) ? "***" : JSON.stringify(v)}`).join(" ");
|
|
77
|
-
this.info(`CMD ${name}${filtered ? " " + filtered : ""}`);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
var logger = new Logger();
|
|
81
|
-
|
|
82
|
-
// src/core/json-utils.ts
|
|
83
|
-
import fs2 from "fs";
|
|
84
|
-
import { createRequire } from "module";
|
|
85
|
-
var require2 = createRequire(import.meta.url);
|
|
86
|
-
var JSONbig = require2("json-bigint");
|
|
87
|
-
var jsonParser = JSONbig({ storeAsString: true });
|
|
30
|
+
return lossless;
|
|
31
|
+
}
|
|
88
32
|
function safeJsonParse(text) {
|
|
89
|
-
|
|
33
|
+
const lossless = jsonParser.parse(text);
|
|
34
|
+
return normalizeParsedNumbers(lossless, JSON.parse(text));
|
|
90
35
|
}
|
|
91
36
|
function safeReadJsonFile(filePath) {
|
|
92
|
-
const content =
|
|
37
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
93
38
|
return safeJsonParse(content);
|
|
94
39
|
}
|
|
95
40
|
|
|
@@ -104,11 +49,12 @@ function normalizeUrl(url) {
|
|
|
104
49
|
|
|
105
50
|
// src/core/config.ts
|
|
106
51
|
import fs3 from "fs";
|
|
107
|
-
import
|
|
52
|
+
import path from "path";
|
|
108
53
|
|
|
109
54
|
// src/core/sandbox-runtime.ts
|
|
110
55
|
import { homedir } from "os";
|
|
111
56
|
import { join } from "path";
|
|
57
|
+
import fs2 from "fs";
|
|
112
58
|
var LINUX_SANDBOX_RUNTIME_ROOT = "/home/ta/te_agent_ta";
|
|
113
59
|
function getDefaultSandboxRuntimeRoot() {
|
|
114
60
|
if (process.platform === "linux") {
|
|
@@ -128,13 +74,25 @@ function getSandboxCliTokenFilePath() {
|
|
|
128
74
|
function getSandboxClusterInfoFilePath() {
|
|
129
75
|
return join(getSandboxAeConfigDir(), "cluster-info.json");
|
|
130
76
|
}
|
|
77
|
+
function isAeSandboxRuntime() {
|
|
78
|
+
if (process.env.SANDBOX_RUNTIME_ROOT) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
if (fs2.existsSync(getSandboxCliTokenFilePath())) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
131
89
|
|
|
132
90
|
// src/core/config.ts
|
|
133
|
-
var CONFIG_DIR =
|
|
134
|
-
var CONFIG_FILE =
|
|
91
|
+
var CONFIG_DIR = path.join(process.env.HOME || "", ".ae-cli");
|
|
92
|
+
var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
135
93
|
function sandboxCliTokenCandidatePaths() {
|
|
136
94
|
const paths = [getSandboxCliTokenFilePath()];
|
|
137
|
-
const homeFallback =
|
|
95
|
+
const homeFallback = path.join(process.env.HOME || "", ".ae-config", "cli-token.json");
|
|
138
96
|
if (!paths.includes(homeFallback)) {
|
|
139
97
|
paths.push(homeFallback);
|
|
140
98
|
}
|
|
@@ -289,12 +247,12 @@ function getConfigDir() {
|
|
|
289
247
|
}
|
|
290
248
|
|
|
291
249
|
export {
|
|
292
|
-
logger,
|
|
293
250
|
safeJsonParse,
|
|
294
251
|
safeReadJsonFile,
|
|
295
252
|
normalizeUrl,
|
|
296
253
|
getSandboxRuntimeRoot,
|
|
297
254
|
getSandboxClusterInfoFilePath,
|
|
255
|
+
isAeSandboxRuntime,
|
|
298
256
|
getFallbackCliToken,
|
|
299
257
|
loadConfig,
|
|
300
258
|
saveConfig,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/core/package-info.ts
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
function getLocalCliPackageInfo() {
|
|
6
|
+
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
for (let i = 0; i < 8; i += 1) {
|
|
8
|
+
const candidate = path.join(dir, "package.json");
|
|
9
|
+
try {
|
|
10
|
+
if (fs.existsSync(candidate)) {
|
|
11
|
+
const pkg = JSON.parse(fs.readFileSync(candidate, "utf8"));
|
|
12
|
+
if (pkg.name && pkg.version && String(pkg.name).includes("ae-cli")) {
|
|
13
|
+
return { name: pkg.name, version: pkg.version };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
const parent = path.dirname(dir);
|
|
19
|
+
if (parent === dir) break;
|
|
20
|
+
dir = parent;
|
|
21
|
+
}
|
|
22
|
+
return { name: "@tant/ae-cli", version: "0.0.0" };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
getLocalCliPackageInfo
|
|
27
|
+
};
|
|
@@ -4,15 +4,18 @@ import {
|
|
|
4
4
|
getCliToken,
|
|
5
5
|
localRenewDate,
|
|
6
6
|
mintCliToken,
|
|
7
|
+
peekCliToken,
|
|
7
8
|
setCliTokenManual
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-E7UXXHO3.js";
|
|
10
|
+
import "./chunk-IR4ZLVPW.js";
|
|
11
|
+
import "./chunk-V6FR6WTW.js";
|
|
12
|
+
import "./chunk-LYVNONC4.js";
|
|
11
13
|
export {
|
|
12
14
|
_resetRenewMemoryForTest,
|
|
13
15
|
clearCliToken,
|
|
14
16
|
getCliToken,
|
|
15
17
|
localRenewDate,
|
|
16
18
|
mintCliToken,
|
|
19
|
+
peekCliToken,
|
|
17
20
|
setCliTokenManual
|
|
18
21
|
};
|
|
@@ -7,9 +7,10 @@ import {
|
|
|
7
7
|
queryReportData,
|
|
8
8
|
querySql,
|
|
9
9
|
wsQuery
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-DB4Q3ANU.js";
|
|
11
|
+
import "./chunk-IR4ZLVPW.js";
|
|
12
|
+
import "./chunk-V6FR6WTW.js";
|
|
13
|
+
import "./chunk-LYVNONC4.js";
|
|
13
14
|
export {
|
|
14
15
|
httpDelete,
|
|
15
16
|
httpGet,
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CommunityReportError
|
|
3
|
+
} from "./chunk-24BAVOX3.js";
|
|
4
|
+
import {
|
|
5
|
+
logger
|
|
6
|
+
} from "./chunk-LYVNONC4.js";
|
|
7
|
+
|
|
8
|
+
// src/core/community-report-client.ts
|
|
9
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
10
|
+
async function communityReport(endpoint, rawBody, options = {}) {
|
|
11
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
12
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
13
|
+
const requestBytes = Buffer.byteLength(rawBody, "utf8");
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
16
|
+
let response;
|
|
17
|
+
let responseText;
|
|
18
|
+
try {
|
|
19
|
+
response = await fetchImpl(endpoint, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: {
|
|
22
|
+
"Content-Type": "application/json",
|
|
23
|
+
"Accept": "application/json"
|
|
24
|
+
},
|
|
25
|
+
body: rawBody,
|
|
26
|
+
redirect: "error",
|
|
27
|
+
signal: controller.signal
|
|
28
|
+
});
|
|
29
|
+
responseText = await response.text();
|
|
30
|
+
} catch (error) {
|
|
31
|
+
const timedOut = controller.signal.aborted || isAbortError(error);
|
|
32
|
+
logCommunityReport(endpoint, response?.status ?? "unavailable", requestBytes, 0);
|
|
33
|
+
if (timedOut) {
|
|
34
|
+
throw new CommunityReportError(
|
|
35
|
+
`Community data report timed out after ${timeoutMs} ms. Delivery state is unknown.`,
|
|
36
|
+
{
|
|
37
|
+
code: "COMMUNITY_REPORT_TIMEOUT",
|
|
38
|
+
hint: "Check downstream query or storage before deciding whether to submit again. The CLI did not retry.",
|
|
39
|
+
meta: { persistence_verified: false, retry_attempted: false },
|
|
40
|
+
cause: error
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
throw new CommunityReportError("Community data report request failed before a response was received.", {
|
|
45
|
+
code: "COMMUNITY_REPORT_NETWORK_ERROR",
|
|
46
|
+
hint: "Verify the endpoint and network path. The CLI did not retry.",
|
|
47
|
+
meta: { persistence_verified: false, retry_attempted: false },
|
|
48
|
+
cause: error
|
|
49
|
+
});
|
|
50
|
+
} finally {
|
|
51
|
+
clearTimeout(timeout);
|
|
52
|
+
}
|
|
53
|
+
const responseBytes = Buffer.byteLength(responseText, "utf8");
|
|
54
|
+
logCommunityReport(endpoint, response.status, requestBytes, responseBytes);
|
|
55
|
+
const responseBody = parseResponseBody(responseText, response.status);
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
if (response.status === 400) {
|
|
58
|
+
const returnMessage = getReturnMessage(responseBody);
|
|
59
|
+
throw new CommunityReportError(returnMessage ?? "Iris rejected the community data report.", {
|
|
60
|
+
code: getReturnCode(responseBody) ?? "COMMUNITY_REPORT_HTTP_400",
|
|
61
|
+
httpStatus: response.status,
|
|
62
|
+
meta: safeResponseMeta(requestBytes, responseBytes)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
throw new CommunityReportError(`Iris sync endpoint returned HTTP ${response.status}.`, {
|
|
66
|
+
code: `COMMUNITY_REPORT_HTTP_${response.status}`,
|
|
67
|
+
httpStatus: response.status,
|
|
68
|
+
hint: response.status >= 500 ? "The server response was suppressed. Check Iris or gateway logs; the CLI did not retry." : void 0,
|
|
69
|
+
meta: safeResponseMeta(requestBytes, responseBytes)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (!isRecord(responseBody) || typeof responseBody.return_code !== "number") {
|
|
73
|
+
throw new CommunityReportError("Iris sync endpoint returned an invalid API response: missing numeric return_code.", {
|
|
74
|
+
code: "COMMUNITY_REPORT_INVALID_RESPONSE",
|
|
75
|
+
httpStatus: response.status,
|
|
76
|
+
meta: safeResponseMeta(requestBytes, responseBytes)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (responseBody.return_code !== 0) {
|
|
80
|
+
throw new CommunityReportError(
|
|
81
|
+
getReturnMessage(responseBody) ?? "Iris rejected the community data report.",
|
|
82
|
+
{
|
|
83
|
+
code: responseBody.return_code,
|
|
84
|
+
httpStatus: response.status,
|
|
85
|
+
meta: safeResponseMeta(requestBytes, responseBytes)
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
return_code: 0,
|
|
91
|
+
return_message: getReturnMessage(responseBody) ?? "success",
|
|
92
|
+
http_status: response.status,
|
|
93
|
+
request_bytes: requestBytes,
|
|
94
|
+
response_bytes: responseBytes
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function parseResponseBody(text, httpStatus) {
|
|
98
|
+
if (!text.trim()) {
|
|
99
|
+
if (httpStatus >= 500) return void 0;
|
|
100
|
+
throw new CommunityReportError("Iris sync endpoint returned an empty API response.", {
|
|
101
|
+
code: "COMMUNITY_REPORT_INVALID_RESPONSE",
|
|
102
|
+
httpStatus
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
return JSON.parse(text);
|
|
107
|
+
} catch {
|
|
108
|
+
if (httpStatus >= 500) return void 0;
|
|
109
|
+
throw new CommunityReportError("Iris sync endpoint returned a non-JSON API response.", {
|
|
110
|
+
code: "COMMUNITY_REPORT_INVALID_RESPONSE",
|
|
111
|
+
httpStatus
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function isRecord(value) {
|
|
116
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
117
|
+
}
|
|
118
|
+
function getReturnCode(value) {
|
|
119
|
+
if (!isRecord(value)) return void 0;
|
|
120
|
+
return typeof value.return_code === "number" || typeof value.return_code === "string" ? value.return_code : void 0;
|
|
121
|
+
}
|
|
122
|
+
function getReturnMessage(value) {
|
|
123
|
+
if (!isRecord(value)) return void 0;
|
|
124
|
+
return typeof value.return_message === "string" && value.return_message.trim() ? value.return_message.trim() : void 0;
|
|
125
|
+
}
|
|
126
|
+
function isAbortError(error) {
|
|
127
|
+
return error instanceof Error && error.name === "AbortError";
|
|
128
|
+
}
|
|
129
|
+
function safeResponseMeta(requestBytes, responseBytes) {
|
|
130
|
+
return {
|
|
131
|
+
request_bytes: requestBytes,
|
|
132
|
+
response_bytes: responseBytes,
|
|
133
|
+
persistence_verified: false,
|
|
134
|
+
retry_attempted: false
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function logCommunityReport(endpoint, status, requestBytes, responseBytes) {
|
|
138
|
+
logger.info(
|
|
139
|
+
`COMMUNITY_REPORT POST ${endpoint} status=${status} request_bytes=${requestBytes} response_bytes=${responseBytes}`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
CommunityReportError,
|
|
144
|
+
communityReport
|
|
145
|
+
};
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
printError,
|
|
3
3
|
printOutput
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IMMGMU54.js";
|
|
5
5
|
import {
|
|
6
6
|
GLOBAL_QUERY_CONFIG_KEY,
|
|
7
7
|
getAnalysisMappingPathForClusterMode,
|
|
8
8
|
getClusterInfoFilePath,
|
|
9
9
|
isGlobalQueryModeEnabled,
|
|
10
10
|
setGlobalQueryModeEnabled
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LCXU3AAT.js";
|
|
12
|
+
import "./chunk-E7UXXHO3.js";
|
|
13
|
+
import "./chunk-IR4ZLVPW.js";
|
|
12
14
|
import {
|
|
13
15
|
addHost,
|
|
14
16
|
loadConfig,
|
|
15
17
|
normalizeUrl,
|
|
16
18
|
setActiveHost
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-V6FR6WTW.js";
|
|
20
|
+
import "./chunk-LYVNONC4.js";
|
|
18
21
|
|
|
19
22
|
// src/commands/config.ts
|
|
20
23
|
function registerConfig(program) {
|