@thinkingai/ae-cli 6.0.22 → 6.0.24
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-RDN6D5HU.js → auth-A2XXG5K4.js} +7 -11
- package/dist/auth-IDPKDFSY.js +13 -0
- package/dist/{chunk-4EUZRJPO.js → chunk-2OW2RENH.js} +40 -10
- package/dist/{chunk-H52CSLJW.js → chunk-4FQ36OGO.js} +4 -4
- package/dist/chunk-AKORWVHJ.js +59 -0
- package/dist/{chunk-E34XH4GW.js → chunk-F3ZDMC2W.js} +8 -8
- package/dist/chunk-FIT4CFIN.js +59 -0
- package/dist/{chunk-2W7HULUD.js → chunk-IDXW6MEJ.js} +2 -2
- package/dist/{chunk-5FBLRSMU.js → chunk-NGJDCOYA.js} +3 -3
- package/dist/chunk-NXJP4CES.js +209 -0
- package/dist/{chunk-FPE5LGVU.js → chunk-OCQPQYHZ.js} +2 -2
- package/dist/{chunk-YACCPUNQ.js → chunk-ONOA6DYB.js} +1 -1
- package/dist/{chunk-U6QPKCN3.js → chunk-PFJFZVCK.js} +8 -115
- package/dist/chunk-V5R5UIRM.js +195 -0
- package/dist/{chunk-XE2PI5DS.js → chunk-WXBCP6SD.js} +1 -1
- package/dist/{cli-token-6AGEDJF4.js → cli-token-OZXHC3U2.js} +3 -3
- package/dist/{client-VTJMUZ4O.js → client-7L735LVY.js} +3 -3
- package/dist/{config-2SDTLGOC.js → config-SXD2JKSL.js} +3 -3
- package/dist/index.js +27 -24
- package/dist/{metadata-JZ2OTWBK.js → metadata-QWUAX625.js} +56 -65
- package/dist/metadata-XWTEGEN2.js +411 -0
- package/dist/{model-ZYMRN4VS.js → model-3OVX42DA.js} +2 -2
- package/dist/{raw-NGYHAL3F.js → raw-IANB4AV5.js} +4 -4
- package/dist/{sync-JVLX6TGW.js → sync-4HQ3CXSK.js} +3 -3
- package/dist/{te-agent-QPZTLHPH.js → te-agent-OYNNTJDU.js} +2 -2
- package/dist/{te-analysis-WWX3Z6RP.js → te-analysis-CRPFK3LX.js} +1074 -340
- package/dist/te-analysis-JX3V76OI.js +2281 -0
- package/dist/{te-audience-UXGHUVBB.js → te-audience-77FGNG5E.js} +5 -5
- package/dist/te-audience-RO2IZOUC.js +599 -0
- package/dist/{te-common-7XXH73MF.js → te-common-4TRJPRC5.js} +5 -5
- package/dist/te-common-PUXBUPOL.js +130 -0
- package/dist/{te-community-QKE67HR2.js → te-community-NPDZQKMY.js} +5 -5
- package/dist/te-community-XKE526DS.js +687 -0
- package/dist/{te-dataops-6W7NNYST.js → te-dataops-6KWLFNV4.js} +5 -5
- package/dist/te-dataops-PW74WP76.js +1842 -0
- package/dist/{te-engage-NCFAQFX3.js → te-engage-HTLMUN7G.js} +5 -5
- package/dist/te-engage-YPQIVF5H.js +1510 -0
- package/dist/{te-kb-K5BQYUCM.js → te-kb-DOGDQIU4.js} +4 -4
- package/dist/{te-meta-LJZBOSMO.js → te-meta-5ESSQ5B3.js} +5 -5
- package/dist/te-meta-Z47X4VT3.js +595 -0
- package/dist/{te-team-DHK5R7MV.js → te-team-SOVKZIDD.js} +5 -5
- package/package.json +1 -1
- package/skills/ae-analysis/SKILL.md +51 -25
- package/skills/ae-analysis/references/analysis_gateway_assets.md +114 -0
- package/skills/ae-analysis/references/bi_panel_copy.md +15 -0
- package/skills/ae-analysis/references/bi_panel_create.md +15 -0
- package/skills/ae-analysis/references/bi_panel_delete.md +15 -0
- package/skills/ae-analysis/references/bi_panel_get.md +18 -0
- package/skills/ae-analysis/references/bi_panel_list.md +15 -0
- package/skills/ae-analysis/references/bi_panel_page_data_export.md +15 -0
- package/skills/ae-analysis/references/bi_panel_page_data_run.md +15 -0
- package/skills/ae-analysis/references/bi_panel_share.md +15 -0
- package/skills/ae-analysis/references/bi_panel_update.md +15 -0
- package/skills/ae-analysis/references/dashboard_abnormal_get.md +15 -0
- package/skills/ae-analysis/references/dashboard_copy.md +15 -0
- package/skills/ae-analysis/references/dashboard_create.md +15 -0
- package/skills/ae-analysis/references/dashboard_daily_report_send.md +15 -0
- package/skills/ae-analysis/references/dashboard_daily_report_update.md +15 -0
- package/skills/ae-analysis/references/dashboard_definition_export.md +15 -0
- package/skills/ae-analysis/references/dashboard_definition_import.md +15 -0
- package/skills/ae-analysis/references/dashboard_delete.md +15 -0
- package/skills/ae-analysis/references/dashboard_freeze.md +15 -0
- package/skills/ae-analysis/references/dashboard_get.md +15 -0
- package/skills/ae-analysis/references/dashboard_handover.md +15 -0
- package/skills/ae-analysis/references/dashboard_list.md +15 -0
- package/skills/ae-analysis/references/dashboard_report_data_export.md +15 -0
- package/skills/ae-analysis/references/dashboard_report_data_run.md +15 -0
- package/skills/ae-analysis/references/dashboard_share.md +15 -0
- package/skills/ae-analysis/references/dashboard_share_info.md +15 -0
- package/skills/ae-analysis/references/dashboard_task_status.md +15 -0
- package/skills/ae-analysis/references/dashboard_update.md +16 -0
- package/skills/ae-analysis/references/favorite_add.md +15 -0
- package/skills/ae-analysis/references/favorite_remove.md +15 -0
- package/skills/ae-analysis/references/folder_create.md +15 -0
- package/skills/ae-analysis/references/folder_delete.md +15 -0
- package/skills/ae-analysis/references/folder_members.md +15 -0
- package/skills/ae-analysis/references/folder_share.md +15 -0
- package/skills/ae-analysis/references/project_space_create.md +15 -0
- package/skills/ae-analysis/references/project_space_delete.md +15 -0
- package/skills/ae-analysis/references/project_space_get.md +18 -0
- package/skills/ae-analysis/references/project_space_list.md +15 -0
- package/skills/ae-analysis/references/project_space_members.md +15 -0
- package/skills/ae-analysis/references/project_space_share.md +15 -0
- package/skills/ae-analysis/references/public_link_create.md +15 -0
- package/skills/ae-analysis/references/public_link_delete.md +15 -0
- package/skills/ae-analysis/references/public_link_list.md +15 -0
- package/skills/ae-analysis/references/public_link_offline.md +15 -0
- package/skills/ae-analysis/references/public_link_update.md +15 -0
- package/skills/ae-analysis/references/query_cancel.md +15 -0
- package/skills/ae-metadata/references/metadata_data_table_csv_write.md +5 -3
- package/skills/ae-metadata/references/metadata_data_table_sql_write.md +5 -4
- package/skills/ae-metadata/references/metadata_property_dimension_table_create_and_bind_csv.md +5 -3
- package/dist/auth-I2G7OAU2.js +0 -19
- package/dist/{chunk-WPXHCP4A.js → chunk-65DKFJZB.js} +3 -3
|
@@ -2,13 +2,8 @@ import {
|
|
|
2
2
|
getActiveHost,
|
|
3
3
|
getConfigDir,
|
|
4
4
|
logger,
|
|
5
|
-
safeJsonParse
|
|
6
|
-
|
|
7
|
-
} from "./chunk-WPXHCP4A.js";
|
|
8
|
-
|
|
9
|
-
// src/core/auth.ts
|
|
10
|
-
import fs2 from "fs";
|
|
11
|
-
import path2 from "path";
|
|
5
|
+
safeJsonParse
|
|
6
|
+
} from "./chunk-65DKFJZB.js";
|
|
12
7
|
|
|
13
8
|
// src/core/secure-store.ts
|
|
14
9
|
import crypto from "crypto";
|
|
@@ -236,22 +231,6 @@ var SecureStoreAuthError = class extends Error {
|
|
|
236
231
|
};
|
|
237
232
|
|
|
238
233
|
// src/core/auth.ts
|
|
239
|
-
var TOKENS_FILE = path2.join(getConfigDir(), "tokens.json");
|
|
240
|
-
var LEGACY_MCP_TOKENS_FILE = path2.join(getConfigDir(), "mcp-tokens.json");
|
|
241
|
-
var LEGACY_DIR = path2.join(process.env.HOME || "", ".te-mcp");
|
|
242
|
-
(function removeLegacyMcpTokens() {
|
|
243
|
-
try {
|
|
244
|
-
if (fs2.existsSync(LEGACY_MCP_TOKENS_FILE)) {
|
|
245
|
-
fs2.rmSync(LEGACY_MCP_TOKENS_FILE);
|
|
246
|
-
logger.info("auth: removed legacy mcp-tokens.json (plaintext MCP token file)");
|
|
247
|
-
}
|
|
248
|
-
} catch {
|
|
249
|
-
}
|
|
250
|
-
})();
|
|
251
|
-
function ensureDir() {
|
|
252
|
-
const dir = getConfigDir();
|
|
253
|
-
if (!fs2.existsSync(dir)) fs2.mkdirSync(dir, { recursive: true });
|
|
254
|
-
}
|
|
255
234
|
function resolveHost(hostOverride) {
|
|
256
235
|
if (hostOverride) return hostOverride;
|
|
257
236
|
return getActiveHost();
|
|
@@ -270,89 +249,11 @@ async function validateToken(token, hostUrl) {
|
|
|
270
249
|
return false;
|
|
271
250
|
}
|
|
272
251
|
}
|
|
273
|
-
function
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const migrated = {};
|
|
279
|
-
for (const [key, val] of Object.entries(data)) {
|
|
280
|
-
const url = key.startsWith("http") ? key : `https://${key}`;
|
|
281
|
-
migrated[url] = val;
|
|
282
|
-
}
|
|
283
|
-
ensureDir();
|
|
284
|
-
fs2.writeFileSync(TOKENS_FILE, JSON.stringify(migrated, null, 2));
|
|
285
|
-
return migrated;
|
|
286
|
-
}
|
|
287
|
-
if (fs2.existsSync(TOKENS_FILE)) {
|
|
288
|
-
const data = safeReadJsonFile(TOKENS_FILE);
|
|
289
|
-
if (data && typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0) {
|
|
290
|
-
try {
|
|
291
|
-
fs2.unlinkSync(TOKENS_FILE);
|
|
292
|
-
} catch {
|
|
293
|
-
}
|
|
294
|
-
return {};
|
|
295
|
-
}
|
|
296
|
-
let needsMigration = false;
|
|
297
|
-
const migrated = {};
|
|
298
|
-
for (const [key, val] of Object.entries(data)) {
|
|
299
|
-
if (!key.startsWith("http")) {
|
|
300
|
-
migrated[`https://${key}`] = val;
|
|
301
|
-
needsMigration = true;
|
|
302
|
-
} else {
|
|
303
|
-
migrated[key] = val;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (needsMigration) {
|
|
307
|
-
fs2.writeFileSync(TOKENS_FILE, JSON.stringify(migrated, null, 2));
|
|
308
|
-
return migrated;
|
|
309
|
-
}
|
|
310
|
-
return data;
|
|
311
|
-
}
|
|
312
|
-
} catch {
|
|
313
|
-
}
|
|
314
|
-
return {};
|
|
315
|
-
}
|
|
316
|
-
function saveAllTokens(tokens) {
|
|
317
|
-
ensureDir();
|
|
318
|
-
if (Object.keys(tokens).length === 0) {
|
|
319
|
-
try {
|
|
320
|
-
fs2.unlinkSync(TOKENS_FILE);
|
|
321
|
-
} catch {
|
|
322
|
-
}
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
fs2.writeFileSync(TOKENS_FILE, JSON.stringify(tokens, null, 2));
|
|
326
|
-
try {
|
|
327
|
-
fs2.chmodSync(TOKENS_FILE, 384);
|
|
328
|
-
} catch {
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
function loadToken(hostUrl) {
|
|
332
|
-
const tokens = loadAllTokens();
|
|
333
|
-
const entry = tokens[hostUrl];
|
|
334
|
-
if (!entry || !entry.token) return null;
|
|
335
|
-
return { host: hostUrl, token: entry.token, updatedAt: entry.updatedAt };
|
|
336
|
-
}
|
|
337
|
-
function saveToken(token, hostUrl) {
|
|
338
|
-
const tokens = loadAllTokens();
|
|
339
|
-
tokens[hostUrl] = { token, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
340
|
-
saveAllTokens(tokens);
|
|
341
|
-
logger.info(`Token saved for ${hostUrl}`);
|
|
342
|
-
}
|
|
343
|
-
function clearToken(hostUrl) {
|
|
344
|
-
const tokens = loadAllTokens();
|
|
345
|
-
delete tokens[hostUrl];
|
|
346
|
-
saveAllTokens(tokens);
|
|
347
|
-
}
|
|
348
|
-
function getAuthStatus(hostUrl) {
|
|
349
|
-
const cached = loadToken(hostUrl);
|
|
350
|
-
if (cached) {
|
|
351
|
-
const ageMs = Date.now() - new Date(cached.updatedAt).getTime();
|
|
352
|
-
const hours = Math.round(ageMs / 36e5);
|
|
353
|
-
return { authenticated: true, host: hostUrl, tokenAge: `${hours}h ago`, source: "cache" };
|
|
354
|
-
}
|
|
355
|
-
return { authenticated: false, host: hostUrl };
|
|
252
|
+
function invalidateAccessTokenForRetry(hostUrl) {
|
|
253
|
+
const payload = load(hostUrl);
|
|
254
|
+
if (!payload) return;
|
|
255
|
+
save(hostUrl, { ...payload, accessExpiresAt: (/* @__PURE__ */ new Date(0)).toISOString() });
|
|
256
|
+
logger.info(`auth: marked access token stale for retry on ${hostUrl}`);
|
|
356
257
|
}
|
|
357
258
|
async function getToken(hostUrl) {
|
|
358
259
|
if (!hostUrl) {
|
|
@@ -361,11 +262,6 @@ async function getToken(hostUrl) {
|
|
|
361
262
|
Run: ae-cli config set-host <url>`
|
|
362
263
|
);
|
|
363
264
|
}
|
|
364
|
-
const cached = loadToken(hostUrl);
|
|
365
|
-
if (cached && cached.token) {
|
|
366
|
-
logger.info(`Using cached token for ${hostUrl}`);
|
|
367
|
-
return cached.token;
|
|
368
|
-
}
|
|
369
265
|
try {
|
|
370
266
|
const secureToken = await getValidAccessToken(hostUrl);
|
|
371
267
|
logger.info(`Using secure-store token for ${hostUrl}`);
|
|
@@ -391,9 +287,6 @@ export {
|
|
|
391
287
|
SecureStoreAuthError,
|
|
392
288
|
resolveHost,
|
|
393
289
|
validateToken,
|
|
394
|
-
|
|
395
|
-
saveToken,
|
|
396
|
-
clearToken,
|
|
397
|
-
getAuthStatus,
|
|
290
|
+
invalidateAccessTokenForRetry,
|
|
398
291
|
getToken
|
|
399
292
|
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PermissionError
|
|
3
|
+
} from "./chunk-NOO24N7W.js";
|
|
4
|
+
import {
|
|
5
|
+
clearCliToken,
|
|
6
|
+
getCliToken
|
|
7
|
+
} from "./chunk-OCQPQYHZ.js";
|
|
8
|
+
import {
|
|
9
|
+
logger,
|
|
10
|
+
safeJsonParse
|
|
11
|
+
} from "./chunk-65DKFJZB.js";
|
|
12
|
+
|
|
13
|
+
// src/core/capability-api.ts
|
|
14
|
+
import { readFile } from "fs/promises";
|
|
15
|
+
import { basename } from "path";
|
|
16
|
+
var CapabilityGatewayError = class extends Error {
|
|
17
|
+
constructor(message, code, httpStatus, hint) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.httpStatus = httpStatus;
|
|
21
|
+
this.hint = hint;
|
|
22
|
+
this.name = "CapabilityGatewayError";
|
|
23
|
+
}
|
|
24
|
+
code;
|
|
25
|
+
httpStatus;
|
|
26
|
+
hint;
|
|
27
|
+
};
|
|
28
|
+
function buildCapabilityGatewayUrl(host, domain, pathAfterV1, queryParams = {}) {
|
|
29
|
+
const base = host.replace(/\/+$/, "");
|
|
30
|
+
const cleanDomain = domain.replace(/^\/+|\/+$/g, "");
|
|
31
|
+
const cleanPath = pathAfterV1.replace(/^\/+|\/+$/g, "");
|
|
32
|
+
const gatewayPrefix = cleanDomain === "" ? "/api/cli/v1" : `/api/cli/${cleanDomain}/v1`;
|
|
33
|
+
const url = new URL(`${base}${gatewayPrefix}/${cleanPath}`);
|
|
34
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
35
|
+
if (value !== void 0 && value !== null) {
|
|
36
|
+
url.searchParams.set(key, String(value));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return url.toString();
|
|
40
|
+
}
|
|
41
|
+
async function permissionMessage(resp) {
|
|
42
|
+
const text = await resp.text().catch(() => "");
|
|
43
|
+
try {
|
|
44
|
+
const d = safeJsonParse(text);
|
|
45
|
+
const msg = d && (d.error?.message || (typeof d.error === "string" ? d.error : void 0) || d.message);
|
|
46
|
+
if (msg && typeof msg === "string") return msg;
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
return "Permission denied for this resource (HTTP 403)";
|
|
50
|
+
}
|
|
51
|
+
function parseCapabilityResponse(text) {
|
|
52
|
+
if (!text) return void 0;
|
|
53
|
+
try {
|
|
54
|
+
return safeJsonParse(text);
|
|
55
|
+
} catch {
|
|
56
|
+
return text;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function unwrapCapabilityEnvelope(body) {
|
|
60
|
+
if (body == null) {
|
|
61
|
+
throw new CapabilityGatewayError("Empty capability gateway response");
|
|
62
|
+
}
|
|
63
|
+
if (typeof body.ok === "boolean") {
|
|
64
|
+
if (body.ok) {
|
|
65
|
+
return body.data;
|
|
66
|
+
}
|
|
67
|
+
const err = body.error ?? {};
|
|
68
|
+
const code = nonEmptyString(err.code);
|
|
69
|
+
const message = nonEmptyString(err.message) ?? code ?? "Capability gateway request failed";
|
|
70
|
+
const hint = nonEmptyString(err.hint);
|
|
71
|
+
throw new CapabilityGatewayError(message, code, err.http_status ?? err.httpStatus, hint);
|
|
72
|
+
}
|
|
73
|
+
return body;
|
|
74
|
+
}
|
|
75
|
+
function nonEmptyString(value) {
|
|
76
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
77
|
+
}
|
|
78
|
+
function buildCapabilityHttpError(resp, body) {
|
|
79
|
+
const fallback = `Capability gateway HTTP error: ${resp.status} ${resp.statusText}`.trim();
|
|
80
|
+
if (body && typeof body === "object") {
|
|
81
|
+
const err = body.error ?? body.data?.error ?? body;
|
|
82
|
+
const code = nonEmptyString(err.code) ?? nonEmptyString(err.errorCode) ?? nonEmptyString(body.code);
|
|
83
|
+
const message = nonEmptyString(err.message) ?? nonEmptyString(body.message);
|
|
84
|
+
const hint = nonEmptyString(err.hint) ?? nonEmptyString(body.hint);
|
|
85
|
+
const details = [code, message, hint ? `Hint: ${hint}` : void 0].filter(Boolean);
|
|
86
|
+
if (details.length > 0) {
|
|
87
|
+
return new CapabilityGatewayError(message ?? fallback, code, resp.status, hint);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (typeof body === "string" && body.trim()) {
|
|
91
|
+
return new CapabilityGatewayError(`${fallback}: ${body.slice(0, 500)}`, void 0, resp.status);
|
|
92
|
+
}
|
|
93
|
+
return new CapabilityGatewayError(fallback, void 0, resp.status);
|
|
94
|
+
}
|
|
95
|
+
async function throwCapabilityHttpError(resp) {
|
|
96
|
+
const body = parseCapabilityResponse(await resp.text());
|
|
97
|
+
throw buildCapabilityHttpError(resp, body);
|
|
98
|
+
}
|
|
99
|
+
async function requestOnce(url, method, token, body) {
|
|
100
|
+
const headers = {
|
|
101
|
+
"cli-token": token,
|
|
102
|
+
"Accept": "application/json",
|
|
103
|
+
"X-Source": "ae-cli"
|
|
104
|
+
};
|
|
105
|
+
const init = { method, headers };
|
|
106
|
+
if (body !== void 0 && method !== "GET") {
|
|
107
|
+
headers["Content-Type"] = "application/json";
|
|
108
|
+
init.body = JSON.stringify(body);
|
|
109
|
+
}
|
|
110
|
+
return fetch(url, init);
|
|
111
|
+
}
|
|
112
|
+
async function requestMultipartOnce(url, token, form) {
|
|
113
|
+
return fetch(url, {
|
|
114
|
+
method: "POST",
|
|
115
|
+
headers: {
|
|
116
|
+
"cli-token": token,
|
|
117
|
+
"Accept": "application/json",
|
|
118
|
+
"X-Source": "ae-cli"
|
|
119
|
+
},
|
|
120
|
+
body: form
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async function callGateway(host, domain, pathAfterV1, method, body) {
|
|
124
|
+
const url = buildCapabilityGatewayUrl(host, domain, pathAfterV1);
|
|
125
|
+
const token = await getCliToken(host);
|
|
126
|
+
let resp = await requestOnce(url, method, token, body);
|
|
127
|
+
if (resp.status === 403) {
|
|
128
|
+
throw new PermissionError(await permissionMessage(resp));
|
|
129
|
+
}
|
|
130
|
+
if (resp.status === 401) {
|
|
131
|
+
logger.warn(`Capability gateway request failed (HTTP 401) for ${host}, refreshing CLI token`);
|
|
132
|
+
clearCliToken(host);
|
|
133
|
+
const newToken = await getCliToken(host);
|
|
134
|
+
process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
|
|
135
|
+
`);
|
|
136
|
+
resp = await requestOnce(url, method, newToken, body);
|
|
137
|
+
if (resp.status === 403) {
|
|
138
|
+
throw new PermissionError(await permissionMessage(resp));
|
|
139
|
+
}
|
|
140
|
+
if (!resp.ok) {
|
|
141
|
+
await throwCapabilityHttpError(resp);
|
|
142
|
+
}
|
|
143
|
+
} else if (!resp.ok) {
|
|
144
|
+
await throwCapabilityHttpError(resp);
|
|
145
|
+
}
|
|
146
|
+
return unwrapCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
|
|
147
|
+
}
|
|
148
|
+
async function executeCapability(host, domain, capabilityId, input = {}) {
|
|
149
|
+
return callGateway(host, domain, `capabilities/${capabilityId}/execute`, "POST", { input });
|
|
150
|
+
}
|
|
151
|
+
async function uploadInputFile(host, domain, projectId, purpose, filePath) {
|
|
152
|
+
const fileBytes = await readFile(filePath);
|
|
153
|
+
return uploadInputFileBytes(host, domain, projectId, purpose, fileBytes, basename(filePath));
|
|
154
|
+
}
|
|
155
|
+
async function uploadInputFileBytes(host, domain, projectId, purpose, bytes, filename, contentType = "application/octet-stream") {
|
|
156
|
+
const url = buildCapabilityGatewayUrl(host, domain, "input-files");
|
|
157
|
+
const fileBuffer = bytes instanceof ArrayBuffer ? bytes : bytes.buffer.slice(
|
|
158
|
+
bytes.byteOffset,
|
|
159
|
+
bytes.byteOffset + bytes.byteLength
|
|
160
|
+
);
|
|
161
|
+
const form = new FormData();
|
|
162
|
+
form.append("project_id", String(projectId));
|
|
163
|
+
form.append("purpose", purpose);
|
|
164
|
+
form.append("file", new Blob([fileBuffer], { type: contentType }), filename);
|
|
165
|
+
const token = await getCliToken(host);
|
|
166
|
+
let resp = await requestMultipartOnce(url, token, form);
|
|
167
|
+
if (resp.status === 403) {
|
|
168
|
+
throw new PermissionError(await permissionMessage(resp));
|
|
169
|
+
}
|
|
170
|
+
if (resp.status === 401) {
|
|
171
|
+
logger.warn(`Capability gateway request failed (HTTP 401) for ${host}, refreshing CLI token`);
|
|
172
|
+
clearCliToken(host);
|
|
173
|
+
const newToken = await getCliToken(host);
|
|
174
|
+
process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
|
|
175
|
+
`);
|
|
176
|
+
resp = await requestMultipartOnce(url, newToken, form);
|
|
177
|
+
if (resp.status === 403) {
|
|
178
|
+
throw new PermissionError(await permissionMessage(resp));
|
|
179
|
+
}
|
|
180
|
+
if (!resp.ok) {
|
|
181
|
+
await throwCapabilityHttpError(resp);
|
|
182
|
+
}
|
|
183
|
+
} else if (!resp.ok) {
|
|
184
|
+
await throwCapabilityHttpError(resp);
|
|
185
|
+
}
|
|
186
|
+
return unwrapCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export {
|
|
190
|
+
CapabilityGatewayError,
|
|
191
|
+
buildCapabilityGatewayUrl,
|
|
192
|
+
executeCapability,
|
|
193
|
+
uploadInputFile,
|
|
194
|
+
uploadInputFileBytes
|
|
195
|
+
};
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
getCliToken,
|
|
4
4
|
mintCliToken,
|
|
5
5
|
setCliTokenManual
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-OCQPQYHZ.js";
|
|
7
|
+
import "./chunk-PFJFZVCK.js";
|
|
8
|
+
import "./chunk-65DKFJZB.js";
|
|
9
9
|
export {
|
|
10
10
|
clearCliToken,
|
|
11
11
|
getCliToken,
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
queryReportData,
|
|
8
8
|
querySql,
|
|
9
9
|
wsQuery
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-F3ZDMC2W.js";
|
|
11
|
+
import "./chunk-PFJFZVCK.js";
|
|
12
|
+
import "./chunk-65DKFJZB.js";
|
|
13
13
|
export {
|
|
14
14
|
httpDelete,
|
|
15
15
|
httpGet,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
printError,
|
|
3
3
|
printOutput
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ONOA6DYB.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-WXBCP6SD.js";
|
|
12
12
|
import {
|
|
13
13
|
addHost,
|
|
14
14
|
loadConfig,
|
|
15
15
|
setActiveHost
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-65DKFJZB.js";
|
|
17
17
|
|
|
18
18
|
// src/commands/config.ts
|
|
19
19
|
function registerConfig(program) {
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TeAgentApiError,
|
|
3
3
|
TeAgentCredentialsError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4FQ36OGO.js";
|
|
5
5
|
import {
|
|
6
6
|
printError,
|
|
7
7
|
printOutput
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ONOA6DYB.js";
|
|
9
9
|
import {
|
|
10
|
+
CapabilityGatewayError,
|
|
10
11
|
executeCapability,
|
|
11
12
|
uploadInputFileBytes
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2OW2RENH.js";
|
|
13
14
|
import {
|
|
14
15
|
PermissionError
|
|
15
16
|
} from "./chunk-NOO24N7W.js";
|
|
16
17
|
import {
|
|
17
18
|
clearCliToken,
|
|
18
19
|
getCliToken
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-OCQPQYHZ.js";
|
|
20
21
|
import {
|
|
21
22
|
SecureStoreAuthError,
|
|
22
23
|
resolveHost
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-PFJFZVCK.js";
|
|
24
25
|
import {
|
|
25
26
|
getActiveHost,
|
|
26
27
|
getConfigDir,
|
|
27
28
|
logger,
|
|
28
29
|
safeJsonParse
|
|
29
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-65DKFJZB.js";
|
|
30
31
|
|
|
31
32
|
// src/index.ts
|
|
32
33
|
import { Command as CommanderCommand } from "commander";
|
|
@@ -90,6 +91,8 @@ async function runCommand(cmd, opts, globalOpts) {
|
|
|
90
91
|
printError("config", message, err.hint);
|
|
91
92
|
} else if (err instanceof PermissionError) {
|
|
92
93
|
printError("permission", message);
|
|
94
|
+
} else if (err instanceof CapabilityGatewayError) {
|
|
95
|
+
printError("api", message, err.hint, err.code);
|
|
93
96
|
} else if (err instanceof SecureStoreAuthError) {
|
|
94
97
|
printError("auth", message, "Run: ae-cli auth login");
|
|
95
98
|
} else if (err instanceof TeAgentApiError) {
|
|
@@ -117,7 +120,7 @@ function createRuntimeContext(cmd, opts, globalOpts) {
|
|
|
117
120
|
let _clientModule = null;
|
|
118
121
|
async function getClient() {
|
|
119
122
|
if (!_clientModule) {
|
|
120
|
-
_clientModule = await import("./client-
|
|
123
|
+
_clientModule = await import("./client-7L735LVY.js");
|
|
121
124
|
}
|
|
122
125
|
return _clientModule;
|
|
123
126
|
}
|
|
@@ -165,7 +168,7 @@ function createRuntimeContext(cmd, opts, globalOpts) {
|
|
|
165
168
|
return client.queryReportData(projectId, reportId, qp, eventModel, options, ctx.host());
|
|
166
169
|
},
|
|
167
170
|
async token() {
|
|
168
|
-
const { getToken } = await import("./auth-
|
|
171
|
+
const { getToken } = await import("./auth-IDPKDFSY.js");
|
|
169
172
|
return getToken(ctx.host());
|
|
170
173
|
},
|
|
171
174
|
host() {
|
|
@@ -2998,57 +3001,57 @@ program.name("ae-cli").version(version).description("CLI tool for ThinkingAI (AE
|
|
|
2998
3001
|
async function loadCommands() {
|
|
2999
3002
|
const commands = [];
|
|
3000
3003
|
try {
|
|
3001
|
-
const teAnalysis = await import("./te-analysis-
|
|
3004
|
+
const teAnalysis = await import("./te-analysis-CRPFK3LX.js");
|
|
3002
3005
|
commands.push(...teAnalysis.default);
|
|
3003
3006
|
} catch {
|
|
3004
3007
|
}
|
|
3005
3008
|
try {
|
|
3006
|
-
const teAudience = await import("./te-audience-
|
|
3009
|
+
const teAudience = await import("./te-audience-RO2IZOUC.js");
|
|
3007
3010
|
commands.push(...teAudience.default);
|
|
3008
3011
|
} catch {
|
|
3009
3012
|
}
|
|
3010
3013
|
try {
|
|
3011
|
-
const teMeta = await import("./te-meta-
|
|
3014
|
+
const teMeta = await import("./te-meta-5ESSQ5B3.js");
|
|
3012
3015
|
commands.push(...teMeta.default);
|
|
3013
3016
|
} catch {
|
|
3014
3017
|
}
|
|
3015
3018
|
try {
|
|
3016
|
-
const teCommon = await import("./te-common-
|
|
3019
|
+
const teCommon = await import("./te-common-PUXBUPOL.js");
|
|
3017
3020
|
commands.push(...teCommon.default);
|
|
3018
3021
|
} catch {
|
|
3019
3022
|
}
|
|
3020
3023
|
try {
|
|
3021
|
-
const engage = await import("./te-engage-
|
|
3024
|
+
const engage = await import("./te-engage-YPQIVF5H.js");
|
|
3022
3025
|
commands.push(...engage.default);
|
|
3023
3026
|
} catch {
|
|
3024
3027
|
}
|
|
3025
3028
|
try {
|
|
3026
|
-
const community = await import("./te-community-
|
|
3029
|
+
const community = await import("./te-community-NPDZQKMY.js");
|
|
3027
3030
|
commands.push(...community.default);
|
|
3028
3031
|
} catch {
|
|
3029
3032
|
}
|
|
3030
3033
|
try {
|
|
3031
|
-
const dataops = await import("./te-dataops-
|
|
3034
|
+
const dataops = await import("./te-dataops-6KWLFNV4.js");
|
|
3032
3035
|
commands.push(...dataops.default);
|
|
3033
3036
|
} catch {
|
|
3034
3037
|
}
|
|
3035
3038
|
try {
|
|
3036
|
-
const teKb = await import("./te-kb-
|
|
3039
|
+
const teKb = await import("./te-kb-DOGDQIU4.js");
|
|
3037
3040
|
commands.push(...teKb.default);
|
|
3038
3041
|
} catch {
|
|
3039
3042
|
}
|
|
3040
3043
|
try {
|
|
3041
|
-
const teTeam = await import("./te-team-
|
|
3044
|
+
const teTeam = await import("./te-team-SOVKZIDD.js");
|
|
3042
3045
|
commands.push(...teTeam.default);
|
|
3043
3046
|
} catch {
|
|
3044
3047
|
}
|
|
3045
3048
|
try {
|
|
3046
|
-
const teAgent = await import("./te-agent-
|
|
3049
|
+
const teAgent = await import("./te-agent-OYNNTJDU.js");
|
|
3047
3050
|
commands.push(...teAgent.default);
|
|
3048
3051
|
} catch {
|
|
3049
3052
|
}
|
|
3050
3053
|
try {
|
|
3051
|
-
const metadata = await import("./metadata-
|
|
3054
|
+
const metadata = await import("./metadata-XWTEGEN2.js");
|
|
3052
3055
|
commands.push(...metadata.default);
|
|
3053
3056
|
} catch {
|
|
3054
3057
|
}
|
|
@@ -3056,35 +3059,35 @@ async function loadCommands() {
|
|
|
3056
3059
|
}
|
|
3057
3060
|
async function registerAuthCommands() {
|
|
3058
3061
|
try {
|
|
3059
|
-
const { registerAuth } = await import("./auth-
|
|
3062
|
+
const { registerAuth } = await import("./auth-A2XXG5K4.js");
|
|
3060
3063
|
registerAuth(program);
|
|
3061
3064
|
} catch {
|
|
3062
3065
|
}
|
|
3063
3066
|
}
|
|
3064
3067
|
async function registerConfigCommands() {
|
|
3065
3068
|
try {
|
|
3066
|
-
const { registerConfig } = await import("./config-
|
|
3069
|
+
const { registerConfig } = await import("./config-SXD2JKSL.js");
|
|
3067
3070
|
registerConfig(program);
|
|
3068
3071
|
} catch {
|
|
3069
3072
|
}
|
|
3070
3073
|
}
|
|
3071
3074
|
async function registerApiCommand() {
|
|
3072
3075
|
try {
|
|
3073
|
-
const { registerApi } = await import("./raw-
|
|
3076
|
+
const { registerApi } = await import("./raw-IANB4AV5.js");
|
|
3074
3077
|
registerApi(program);
|
|
3075
3078
|
} catch {
|
|
3076
3079
|
}
|
|
3077
3080
|
}
|
|
3078
3081
|
async function registerSyncCommand() {
|
|
3079
3082
|
try {
|
|
3080
|
-
const { registerSync } = await import("./sync-
|
|
3083
|
+
const { registerSync } = await import("./sync-4HQ3CXSK.js");
|
|
3081
3084
|
registerSync(program);
|
|
3082
3085
|
} catch {
|
|
3083
3086
|
}
|
|
3084
3087
|
}
|
|
3085
3088
|
async function registerModelCommand() {
|
|
3086
3089
|
try {
|
|
3087
|
-
const { registerModel } = await import("./model-
|
|
3090
|
+
const { registerModel } = await import("./model-3OVX42DA.js");
|
|
3088
3091
|
registerModel(program);
|
|
3089
3092
|
} catch {
|
|
3090
3093
|
}
|