@thinkingai/ae-cli 6.1.28 → 6.1.30
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/README.md +24 -4
- package/README.zh.md +24 -4
- package/bin/ae-cli.js +5 -0
- package/bin/runtime-capabilities.json +5 -0
- package/cli-installation-guide.md +24 -3
- package/dist/{auth-NKD5Z5BQ.js → auth-ADZHUIJR.js} +30 -12
- package/dist/{automation-K32V2NKP.js → automation-FD2QZUP6.js} +6 -6
- package/dist/{capability-4CGSL7PK.js → capability-QXFRJYZD.js} +54 -26
- package/dist/{chunk-P6VFCH3P.js → chunk-2F64AZYH.js} +2 -2
- package/dist/{chunk-LMCYSVVA.js → chunk-4PSTYEG5.js} +50 -41
- package/dist/{chunk-KHS64JZQ.js → chunk-72NJKS7O.js} +4 -4
- package/dist/chunk-AVXDJAFC.js +132 -0
- package/dist/{chunk-GI5BMEZO.js → chunk-AWVZTN2B.js} +1 -1
- package/dist/chunk-CG773QXN.js +2289 -0
- package/dist/{chunk-UUD5RB36.js → chunk-E25OSZLJ.js} +3 -3
- package/dist/{chunk-UF244C5C.js → chunk-EUFP4M2A.js} +7 -7
- package/dist/{chunk-QW3R6O7L.js → chunk-HRUOV6EQ.js} +57 -15
- package/dist/{chunk-T44M3PLZ.js → chunk-JEUXDY3B.js} +1 -1
- package/dist/{chunk-2UWS5CUP.js → chunk-JSBLCLFE.js} +3 -3
- package/dist/{chunk-QSAR3GHY.js → chunk-OAWPT7VP.js} +2 -2
- package/dist/{chunk-2IYIYSUO.js → chunk-QVRIDN42.js} +2 -2
- package/dist/{chunk-P7KL7IOH.js → chunk-SOSFRU3O.js} +2 -2
- package/dist/{chunk-GTPWDLTE.js → chunk-TFORY6WY.js} +35 -14
- package/dist/{chunk-JJJIP2XQ.js → chunk-VDICGXCY.js} +2 -2
- package/dist/{chunk-UJ7UPRXK.js → chunk-Y3AM6LIO.js} +10 -8
- package/dist/chunk-YULUBP3R.js +222 -0
- package/dist/{chunk-X7DRLE62.js → chunk-YVG6QD3V.js} +1 -1
- package/dist/{chunk-ZW4VMY5H.js → chunk-Z3Q2AEIN.js} +152 -98
- package/dist/{community-report-client-S2K3A3Q6.js → community-report-client-TJVCLZ3K.js} +1 -1
- package/dist/compat-check-HERBTQZN.js +32 -0
- package/dist/{config-ASSAAIOI.js → config-E3KANXMK.js} +38 -6
- package/dist/{context-6RWLVOM5.js → context-CDB5H5PD.js} +4 -4
- package/dist/{data-integration-EXSUPUDZ.js → data-integration-QE37EQ3A.js} +207 -24
- package/dist/{evaluation-5YT4QLCL.js → evaluation-LR4YDYWL.js} +4 -4
- package/dist/index.js +297 -70
- package/dist/{local-data-upload-client-7HCPGIS3.js → local-data-upload-client-KCMG6J62.js} +1 -1
- package/dist/{memory-VCYLVPMI.js → memory-SNFR5M23.js} +6 -6
- package/dist/{metadata-YGI5M6OF.js → metadata-EXQYDZTH.js} +16 -8
- package/dist/{model-DPJHSD73.js → model-KEVCEXWD.js} +4 -4
- package/dist/{personal-semantic-preference-76TBKAPY.js → personal-semantic-preference-ETY3KU2O.js} +7 -6
- package/dist/{project-semantic-XOEBO2Q5.js → project-semantic-UHRMVOJF.js} +11 -10
- package/dist/{sync-7PP6KQ75.js → sync-XKEBXESC.js} +8 -7
- package/dist/{te-agent-PJVAPKBD.js → te-agent-S6UQR4IE.js} +11 -7
- package/dist/{te-analysis-OX62G5VD.js → te-analysis-WOFFCIBC.js} +185 -33
- package/dist/{te-community-QN3WMPNT.js → te-community-R7B6QYOO.js} +720 -228
- package/dist/{te-dataops-UKD2XN3E.js → te-dataops-KPILYVHA.js} +6 -5
- package/dist/{te-engage-X3DIXPRA.js → te-engage-IAUM6ONX.js} +13 -12
- package/dist/{te-experiment-MEIIK3DP.js → te-experiment-TMLRA7B3.js} +55 -21
- package/dist/{te-kb-73EWDFDF.js → te-kb-GKWPSLSY.js} +409 -85
- package/dist/{te-system-IE7NCKC3.js → te-system-CYWSK3UN.js} +6 -6
- package/dist/{te-team-MGQ5CNRW.js → te-team-ISN52YNG.js} +7 -6
- package/dist/{things-4JIBCA55.js → things-DDQ52Z3Q.js} +7 -7
- package/dist/{update-AX66IFMJ.js → update-CTLNTX35.js} +11 -7
- package/dist/{workspace-Q5NMEKEN.js → workspace-2CKQX2XL.js} +6 -6
- package/package.json +17 -7
- package/skills/ae-agent/references/resource-package.md +4 -0
- package/skills/ae-analysis/SKILL.md +14 -10
- package/skills/ae-analysis/references/agent_review_preflight.md +52 -11
- package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
- package/skills/ae-analysis/references/agent_review_submit_to_page.md +57 -25
- package/skills/ae-analysis/references/command_index.md +7 -3
- package/skills/ae-analysis/references/governance_recommendation_export.md +31 -17
- package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
- package/skills/ae-analysis/references/scenario_append.md +6 -0
- package/skills/ae-analysis/references/scenario_begin.md +11 -0
- package/skills/ae-analysis/references/scenario_collect.md +10 -2
- package/skills/ae-analysis/references/scenario_evaluation.md +6 -18
- package/skills/ae-analysis/references/scenario_get.md +15 -0
- package/skills/ae-analysis/references/scenario_list.md +64 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
- package/skills/ae-community/SKILL.md +77 -27
- package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
- package/skills/ae-community/references/community-data-quality.md +68 -0
- package/skills/ae-community/references/community-query-evidence.md +85 -0
- package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
- package/skills/ae-community/references/community-weekly-report.md +6 -3
- package/skills/ae-community/references/get_channel_info.md +7 -4
- package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
- package/skills/ae-community/references/get_comments_summary.md +4 -4
- package/skills/ae-community/references/get_corpus_tags.md +3 -3
- package/skills/ae-community/references/get_daily_summary.md +3 -3
- package/skills/ae-community/references/get_hot_topics.md +3 -3
- package/skills/ae-community/references/get_livestream_analysis.md +3 -3
- package/skills/ae-community/references/get_livestream_detail.md +4 -4
- package/skills/ae-community/references/get_livestream_list.md +3 -3
- package/skills/ae-community/references/get_livestream_overview.md +3 -3
- package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
- package/skills/ae-community/references/get_livestream_rooms.md +3 -3
- package/skills/ae-community/references/get_overview_metrics.md +3 -3
- package/skills/ae-community/references/get_post_detail.md +4 -4
- package/skills/ae-community/references/get_risk_content.md +5 -5
- package/skills/ae-community/references/get_sentiment_overview.md +4 -4
- package/skills/ae-community/references/get_tag_trends.md +3 -3
- package/skills/ae-community/references/get_topic_detail.md +3 -3
- package/skills/ae-community/references/list_sources.md +28 -0
- package/skills/ae-community/references/list_spaces.md +39 -0
- package/skills/ae-community/references/search_posts.md +21 -7
- package/skills/ae-data-integration/SKILL.md +6 -4
- package/skills/ae-data-integration/references/error-handling.md +1 -0
- package/skills/ae-data-integration/references/handoff.md +1 -1
- package/skills/ae-data-integration/references/sink-upload.md +11 -0
- package/skills/ae-data-integration/references/source-inspect.md +2 -1
- package/skills/ae-data-integration/references/transform.md +1 -1
- package/skills/ae-data-integration/references/ue-mapping.md +1 -1
- package/skills/ae-experiment/SKILL.md +7 -1
- package/skills/ae-experiment/references/manage_experiment.md +18 -1
- package/skills/ae-experiment/references/query_experiment_detail.md +7 -0
- package/skills/ae-experiment/references/save_experiment.md +76 -2
- package/skills/ae-experiment/references/save_submit_experiment.md +7 -0
- package/skills/ae-kb/SKILL.md +37 -8
- package/skills/ae-kb/references/publication.md +81 -0
- package/skills/ae-kb/references/query-workflow.md +20 -6
- package/skills/ae-kb-discovery/SKILL.md +15 -6
- package/skills/ae-metadata/SKILL.md +2 -2
- package/skills/ae-metadata/references/metadata_data_table_get.md +35 -0
- package/dist/chunk-ELCR235M.js +0 -1429
|
@@ -9,15 +9,15 @@ import {
|
|
|
9
9
|
postAgentApi,
|
|
10
10
|
putAgentApi,
|
|
11
11
|
uploadAgentApi
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VDICGXCY.js";
|
|
13
13
|
import {
|
|
14
14
|
TeAgentApiError,
|
|
15
15
|
createTeAgentApiError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JSBLCLFE.js";
|
|
17
17
|
import {
|
|
18
18
|
CliValidationError,
|
|
19
19
|
isApiErrorType
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
21
21
|
|
|
22
22
|
// src/commands/workspace/client.ts
|
|
23
23
|
var DEFAULT_TE_CLAUDE_BASE_PATH = "/agent";
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
CapabilityGatewayError,
|
|
4
|
-
fetchCapabilityGateway,
|
|
5
|
-
requestCapabilityGateway
|
|
6
|
-
} from "./chunk-QW3R6O7L.js";
|
|
7
2
|
import {
|
|
8
3
|
resolveGatewayDomain
|
|
9
4
|
} from "./chunk-KPQY44JQ.js";
|
|
@@ -11,10 +6,15 @@ import {
|
|
|
11
6
|
readOutputMetadata,
|
|
12
7
|
unwrapOutputData,
|
|
13
8
|
withOutputMetadata
|
|
14
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YULUBP3R.js";
|
|
10
|
+
import {
|
|
11
|
+
CapabilityGatewayError,
|
|
12
|
+
fetchCapabilityGateway,
|
|
13
|
+
requestCapabilityGateway
|
|
14
|
+
} from "./chunk-HRUOV6EQ.js";
|
|
15
15
|
import {
|
|
16
16
|
PermissionError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
18
18
|
|
|
19
19
|
// src/core/analysis-async-artifact.ts
|
|
20
20
|
import { randomBytes } from "crypto";
|
|
@@ -6,14 +6,15 @@ import {
|
|
|
6
6
|
SecureStoreAuthError,
|
|
7
7
|
clearCliTokenCache,
|
|
8
8
|
getCliToken
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SOSFRU3O.js";
|
|
10
10
|
import {
|
|
11
|
-
safeJsonParse
|
|
12
|
-
|
|
11
|
+
safeJsonParse,
|
|
12
|
+
stringifyJsonRequest
|
|
13
|
+
} from "./chunk-4PSTYEG5.js";
|
|
13
14
|
import {
|
|
14
15
|
PermissionError,
|
|
15
16
|
externalCliTokenRequestOptions
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
17
18
|
|
|
18
19
|
// src/core/cli-agent-context.ts
|
|
19
20
|
import { readFileSync, statSync } from "fs";
|
|
@@ -263,13 +264,14 @@ function isPlainRecord(value) {
|
|
|
263
264
|
import { readFile } from "fs/promises";
|
|
264
265
|
import { basename } from "path";
|
|
265
266
|
var CapabilityGatewayError = class extends Error {
|
|
266
|
-
constructor(message, code, httpStatus, hint, meta, type = "api") {
|
|
267
|
+
constructor(message, code, httpStatus, hint, meta, type = "api", details) {
|
|
267
268
|
super(message);
|
|
268
269
|
this.code = code;
|
|
269
270
|
this.httpStatus = httpStatus;
|
|
270
271
|
this.hint = hint;
|
|
271
272
|
this.meta = meta;
|
|
272
273
|
this.type = type;
|
|
274
|
+
this.details = details;
|
|
273
275
|
this.name = "CapabilityGatewayError";
|
|
274
276
|
}
|
|
275
277
|
code;
|
|
@@ -277,6 +279,7 @@ var CapabilityGatewayError = class extends Error {
|
|
|
277
279
|
hint;
|
|
278
280
|
meta;
|
|
279
281
|
type;
|
|
282
|
+
details;
|
|
280
283
|
};
|
|
281
284
|
function buildCapabilityGatewayUrl(host, domain, pathAfterV1, queryParams = {}, apiVersion = "v1") {
|
|
282
285
|
const base = host.replace(/\/+$/, "");
|
|
@@ -326,7 +329,10 @@ function parseCapabilityResponse(text) {
|
|
|
326
329
|
return text;
|
|
327
330
|
}
|
|
328
331
|
}
|
|
329
|
-
function
|
|
332
|
+
function isCommunityGatewayRequest(domain, pathAfterV1) {
|
|
333
|
+
return domain.replace(/^\/+|\/+$/g, "") === "community" || /^capabilities\/community\./.test(pathAfterV1.replace(/^\/+/, ""));
|
|
334
|
+
}
|
|
335
|
+
function parseCapabilityEnvelope(body, acceptCommunityLegacyEnvelope = false) {
|
|
330
336
|
if (body == null) {
|
|
331
337
|
throw new CapabilityGatewayError("Empty capability gateway response");
|
|
332
338
|
}
|
|
@@ -348,13 +354,36 @@ function parseCapabilityEnvelope(body) {
|
|
|
348
354
|
err.http_status ?? err.httpStatus,
|
|
349
355
|
hint,
|
|
350
356
|
isRecord(body.meta) ? body.meta : void 0,
|
|
351
|
-
err.type === "validation" ? "validation" : "api"
|
|
357
|
+
err.type === "validation" ? "validation" : "api",
|
|
358
|
+
isRecord(err.details) ? err.details : void 0
|
|
352
359
|
);
|
|
353
360
|
}
|
|
361
|
+
const legacyReturnCode = acceptCommunityLegacyEnvelope ? body.return_code ?? body.returnCode : void 0;
|
|
362
|
+
if (legacyReturnCode !== void 0 && Number(legacyReturnCode) !== 0) {
|
|
363
|
+
const code = String(legacyReturnCode);
|
|
364
|
+
const rawMessage = nonEmptyString(body.return_message) ?? nonEmptyString(body.returnMessage) ?? nonEmptyString(body.message);
|
|
365
|
+
const message = safeLegacyErrorMessage(rawMessage, code);
|
|
366
|
+
throw new CapabilityGatewayError(
|
|
367
|
+
message,
|
|
368
|
+
code,
|
|
369
|
+
void 0,
|
|
370
|
+
"The community service returned a legacy error envelope. Verify that the capability gateway route is deployed on the current host.",
|
|
371
|
+
{ legacy_return_code: legacyReturnCode }
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
if (legacyReturnCode !== void 0 && Number(legacyReturnCode) === 0 && "data" in body) {
|
|
375
|
+
return { ok: true, data: body.data };
|
|
376
|
+
}
|
|
354
377
|
return { ok: true, data: body };
|
|
355
378
|
}
|
|
356
|
-
function
|
|
357
|
-
|
|
379
|
+
function safeLegacyErrorMessage(message, code) {
|
|
380
|
+
if (!message || /\n\s*at\s|stacktrace|\.java:\d+/i.test(message)) {
|
|
381
|
+
return `Capability service request failed (legacy return code ${code})`;
|
|
382
|
+
}
|
|
383
|
+
return message.slice(0, 500);
|
|
384
|
+
}
|
|
385
|
+
function unwrapCapabilityEnvelope(body, acceptCommunityLegacyEnvelope = false) {
|
|
386
|
+
return parseCapabilityEnvelope(body, acceptCommunityLegacyEnvelope).data;
|
|
358
387
|
}
|
|
359
388
|
function nonEmptyString(value) {
|
|
360
389
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
@@ -377,7 +406,8 @@ function buildCapabilityHttpError(resp, body) {
|
|
|
377
406
|
resp.status,
|
|
378
407
|
hint,
|
|
379
408
|
isRecord(body.meta) ? body.meta : void 0,
|
|
380
|
-
err.type === "validation" ? "validation" : "api"
|
|
409
|
+
err.type === "validation" ? "validation" : "api",
|
|
410
|
+
isRecord(err.details) ? err.details : void 0
|
|
381
411
|
);
|
|
382
412
|
}
|
|
383
413
|
}
|
|
@@ -407,7 +437,7 @@ async function requestOnce(url, method, token, body, accept = "application/json"
|
|
|
407
437
|
const init = { method, headers };
|
|
408
438
|
if (body !== void 0 && method !== "GET") {
|
|
409
439
|
headers["Content-Type"] = "application/json";
|
|
410
|
-
init.body =
|
|
440
|
+
init.body = stringifyJsonRequest(includeClientContextInBody ? withCliAgentContextBody(body, agentContext) : body);
|
|
411
441
|
}
|
|
412
442
|
return fetch(url, { ...init, ...externalCliTokenRequestOptions(url) });
|
|
413
443
|
}
|
|
@@ -447,7 +477,10 @@ async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body,
|
|
|
447
477
|
if (!resp.ok) {
|
|
448
478
|
await throwCapabilityHttpError(resp);
|
|
449
479
|
}
|
|
450
|
-
return parseCapabilityEnvelope(
|
|
480
|
+
return parseCapabilityEnvelope(
|
|
481
|
+
parseCapabilityResponse(await resp.text()),
|
|
482
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
483
|
+
);
|
|
451
484
|
}
|
|
452
485
|
async function fetchCapabilityGateway(host, domain, pathAfterV1, method = "GET", body, accept = "application/json") {
|
|
453
486
|
const url = buildCapabilityGatewayUrl(host, domain, pathAfterV1);
|
|
@@ -467,11 +500,17 @@ async function fetchCapabilityGateway(host, domain, pathAfterV1, method = "GET",
|
|
|
467
500
|
}
|
|
468
501
|
async function requestCapabilityGateway(host, domain, pathAfterV1, method = "GET", body) {
|
|
469
502
|
const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
|
|
470
|
-
return unwrapCapabilityEnvelope(
|
|
503
|
+
return unwrapCapabilityEnvelope(
|
|
504
|
+
parseCapabilityResponse(await resp.text()),
|
|
505
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
506
|
+
);
|
|
471
507
|
}
|
|
472
508
|
async function requestCapabilityGatewayWithEnvelope(host, domain, pathAfterV1, method = "GET", body) {
|
|
473
509
|
const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
|
|
474
|
-
return parseCapabilityEnvelope(
|
|
510
|
+
return parseCapabilityEnvelope(
|
|
511
|
+
parseCapabilityResponse(await resp.text()),
|
|
512
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
513
|
+
);
|
|
475
514
|
}
|
|
476
515
|
async function listCapabilitiesWithEnvelope(host, domain, projectId) {
|
|
477
516
|
return callGatewayWithEnvelope(host, domain, "capabilities", "GET", void 0, { project_id: projectId });
|
|
@@ -552,7 +591,10 @@ async function uploadInputFileBytes(host, domain, projectId, purpose, bytes, fil
|
|
|
552
591
|
if (!resp.ok) {
|
|
553
592
|
await throwCapabilityHttpError(resp);
|
|
554
593
|
}
|
|
555
|
-
return unwrapCapabilityEnvelope(
|
|
594
|
+
return unwrapCapabilityEnvelope(
|
|
595
|
+
parseCapabilityResponse(await resp.text()),
|
|
596
|
+
isCommunityGatewayRequest(domain, "input-files")
|
|
597
|
+
);
|
|
556
598
|
}
|
|
557
599
|
async function callCapabilityApi(host, domain, action, method = "POST", params = {}, options = {}) {
|
|
558
600
|
const isGet = method === "GET";
|
|
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from 'node:module'; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
__commonJS,
|
|
4
4
|
__require
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
6
6
|
|
|
7
7
|
// node_modules/process-nextick-args/index.js
|
|
8
8
|
var require_process_nextick_args = __commonJS({
|
|
@@ -4,17 +4,17 @@ import {
|
|
|
4
4
|
} from "./chunk-Y74WTIKJ.js";
|
|
5
5
|
import {
|
|
6
6
|
getCliToken
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SOSFRU3O.js";
|
|
8
8
|
import {
|
|
9
9
|
getActiveHost,
|
|
10
10
|
getSandboxRuntimeRoot
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4PSTYEG5.js";
|
|
12
12
|
import {
|
|
13
13
|
PermissionError,
|
|
14
14
|
externalCliTokenRequestOptions,
|
|
15
15
|
isApiErrorType,
|
|
16
16
|
readExternalCliToken
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
18
18
|
|
|
19
19
|
// src/core/te-agent-credentials.ts
|
|
20
20
|
import { readFileSync } from "fs";
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
require_node,
|
|
6
6
|
require_process_nextick_args,
|
|
7
7
|
require_util
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JEUXDY3B.js";
|
|
9
9
|
import {
|
|
10
10
|
__commonJS,
|
|
11
11
|
__esm,
|
|
12
12
|
__export,
|
|
13
13
|
__require,
|
|
14
14
|
__toCommonJS
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
16
16
|
|
|
17
17
|
// node_modules/readdir-glob/node_modules/minimatch/lib/path.js
|
|
18
18
|
var require_path = __commonJS({
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
require_node,
|
|
6
6
|
require_process_nextick_args,
|
|
7
7
|
require_util
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JEUXDY3B.js";
|
|
9
9
|
import {
|
|
10
10
|
__commonJS,
|
|
11
11
|
__require
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
13
13
|
|
|
14
14
|
// node_modules/jszip/node_modules/readable-stream/lib/internal/streams/stream.js
|
|
15
15
|
var require_stream = __commonJS({
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
readSandboxCliTokenEntry,
|
|
7
7
|
safeJsonParse,
|
|
8
8
|
safeReadJsonFile
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4PSTYEG5.js";
|
|
10
10
|
import {
|
|
11
11
|
PermissionError,
|
|
12
12
|
externalCliTokenRequestOptions,
|
|
13
13
|
logger,
|
|
14
14
|
normalizeUrl,
|
|
15
15
|
readExternalCliToken
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
17
17
|
|
|
18
18
|
// src/core/secure-store.ts
|
|
19
19
|
import crypto from "crypto";
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
CapabilityGatewayError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HRUOV6EQ.js";
|
|
5
5
|
import {
|
|
6
6
|
SecureStoreAuthError,
|
|
7
7
|
getCliToken
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SOSFRU3O.js";
|
|
9
9
|
import {
|
|
10
10
|
safeJsonParse
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4PSTYEG5.js";
|
|
12
12
|
import {
|
|
13
13
|
PermissionError,
|
|
14
|
-
externalCliTokenRequestOptions
|
|
15
|
-
|
|
14
|
+
externalCliTokenRequestOptions,
|
|
15
|
+
isKbQueryPath,
|
|
16
|
+
kbReadHeaders,
|
|
17
|
+
readKbExecutionContext
|
|
18
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
16
19
|
|
|
17
20
|
// src/core/mcp-access.ts
|
|
18
21
|
function buildUrl(host, path, params = {}) {
|
|
@@ -218,18 +221,36 @@ async function getAuthHeaders(ctx) {
|
|
|
218
221
|
return { "cli-token": cliToken };
|
|
219
222
|
}
|
|
220
223
|
async function kbApi(ctx, method, path, params = {}, body, options = {}) {
|
|
221
|
-
const host = ctx.host();
|
|
222
224
|
const upperMethod = method.toUpperCase();
|
|
225
|
+
const isQuery = isKbQueryPath(upperMethod, path);
|
|
226
|
+
const execution = isQuery ? readKbExecutionContext() : void 0;
|
|
227
|
+
const host = execution ? ctx.hostOverride?.() || execution.origin : ctx.host();
|
|
228
|
+
const selectedHost = execution && !ctx.hostOverride ? ctx.host() : host;
|
|
229
|
+
const url = buildUrl(selectedHost, path, params);
|
|
230
|
+
const queryHeaders = isQuery ? kbReadHeaders(url, ctx.str("read-context")) : void 0;
|
|
231
|
+
const init = {
|
|
232
|
+
method: upperMethod,
|
|
233
|
+
headers: { "Content-Type": "application/json", ...queryHeaders },
|
|
234
|
+
body: upperMethod === "GET" ? void 0 : JSON.stringify(body ?? {})
|
|
235
|
+
};
|
|
236
|
+
if (execution) {
|
|
237
|
+
const response = await fetch(url, { ...init, redirect: "error" });
|
|
238
|
+
const text = await response.text();
|
|
239
|
+
if (!response.ok) {
|
|
240
|
+
let code = "KB_READ_CONTEXT_REQUEST_FAILED";
|
|
241
|
+
try {
|
|
242
|
+
const value = responseErrorMetadata(safeJsonParse(text)).code;
|
|
243
|
+
if (value?.startsWith("KB_READ_CONTEXT_")) code = value;
|
|
244
|
+
} catch {
|
|
245
|
+
}
|
|
246
|
+
throw new KbHttpError(code, code, response.status);
|
|
247
|
+
}
|
|
248
|
+
return parseKbResponse(response, text, { ...options, redactErrorDetails: true });
|
|
249
|
+
}
|
|
223
250
|
return requestWithCliToken(
|
|
224
251
|
host,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
method: upperMethod,
|
|
228
|
-
headers: {
|
|
229
|
-
"Content-Type": "application/json"
|
|
230
|
-
},
|
|
231
|
-
body: upperMethod === "GET" ? void 0 : JSON.stringify(body ?? {})
|
|
232
|
-
},
|
|
252
|
+
url,
|
|
253
|
+
init,
|
|
233
254
|
options
|
|
234
255
|
);
|
|
235
256
|
}
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
postToMainApp,
|
|
11
11
|
putToMainApp,
|
|
12
12
|
uploadToMainApp
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JSBLCLFE.js";
|
|
14
14
|
import {
|
|
15
15
|
clearCliTokenCache
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-SOSFRU3O.js";
|
|
17
17
|
|
|
18
18
|
// src/core/resource-package-client.ts
|
|
19
19
|
function checkPath(path) {
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
dryRunCapability,
|
|
4
|
-
executeCapabilityWithEnvelope,
|
|
5
|
-
validateCapability
|
|
6
|
-
} from "./chunk-QW3R6O7L.js";
|
|
7
2
|
import {
|
|
8
3
|
resolveGatewayDomain
|
|
9
4
|
} from "./chunk-KPQY44JQ.js";
|
|
10
5
|
import {
|
|
11
6
|
withOutputMetadata
|
|
12
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YULUBP3R.js";
|
|
8
|
+
import {
|
|
9
|
+
dryRunCapability,
|
|
10
|
+
executeCapabilityWithEnvelope,
|
|
11
|
+
validateCapability
|
|
12
|
+
} from "./chunk-HRUOV6EQ.js";
|
|
13
13
|
import {
|
|
14
14
|
CliValidationError
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
16
|
+
|
|
17
|
+
// src/core/capability-command.ts
|
|
18
|
+
import { randomBytes } from "crypto";
|
|
16
19
|
|
|
17
20
|
// src/core/definition-intent.ts
|
|
18
21
|
import { createHash } from "crypto";
|
|
@@ -83,7 +86,6 @@ function isRecord(value) {
|
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
// src/core/capability-command.ts
|
|
86
|
-
import { randomBytes } from "crypto";
|
|
87
89
|
function createCapabilityCommand(config) {
|
|
88
90
|
return {
|
|
89
91
|
service: config.cliService,
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
getPendingHostCompatNotice,
|
|
4
|
+
getPendingUpdateNotice
|
|
5
|
+
} from "./chunk-CG773QXN.js";
|
|
6
|
+
import {
|
|
7
|
+
logger,
|
|
8
|
+
redactExternalCliToken
|
|
9
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
10
|
+
|
|
11
|
+
// src/framework/output.ts
|
|
12
|
+
import Table from "cli-table3";
|
|
13
|
+
import { JqError, json as jqJson } from "jq-wasm";
|
|
14
|
+
var KNOWN_ARRAY_FIELDS = [
|
|
15
|
+
"items",
|
|
16
|
+
"events",
|
|
17
|
+
"reports",
|
|
18
|
+
"dashboards",
|
|
19
|
+
"tags",
|
|
20
|
+
"clusters",
|
|
21
|
+
"flows",
|
|
22
|
+
"tasks",
|
|
23
|
+
"channels",
|
|
24
|
+
"nodes",
|
|
25
|
+
"members",
|
|
26
|
+
"records",
|
|
27
|
+
"entities",
|
|
28
|
+
"metrics",
|
|
29
|
+
"tables",
|
|
30
|
+
"columns",
|
|
31
|
+
"properties"
|
|
32
|
+
];
|
|
33
|
+
var OUTPUT_METADATA = /* @__PURE__ */ Symbol("ae-cli-output-metadata");
|
|
34
|
+
function withOutputMetadata(data, meta) {
|
|
35
|
+
if (!meta || Object.keys(meta).length === 0) return data;
|
|
36
|
+
if (isOutputWithMetadata(data)) {
|
|
37
|
+
return {
|
|
38
|
+
[OUTPUT_METADATA]: true,
|
|
39
|
+
data: data.data,
|
|
40
|
+
meta: { ...data.meta, ...meta }
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
[OUTPUT_METADATA]: true,
|
|
45
|
+
data,
|
|
46
|
+
meta
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function isOutputWithMetadata(value) {
|
|
50
|
+
return Boolean(value?.[OUTPUT_METADATA]);
|
|
51
|
+
}
|
|
52
|
+
function unwrapOutputData(value) {
|
|
53
|
+
return isOutputWithMetadata(value) ? value.data : value;
|
|
54
|
+
}
|
|
55
|
+
function readOutputMetadata(value) {
|
|
56
|
+
return isOutputWithMetadata(value) ? value.meta : void 0;
|
|
57
|
+
}
|
|
58
|
+
function findArrayField(data) {
|
|
59
|
+
if (Array.isArray(data)) return { rows: data };
|
|
60
|
+
if (typeof data !== "object" || data === null) return null;
|
|
61
|
+
for (const key of KNOWN_ARRAY_FIELDS) {
|
|
62
|
+
if (Array.isArray(data[key])) return { key, rows: data[key] };
|
|
63
|
+
}
|
|
64
|
+
for (const key of Object.keys(data)) {
|
|
65
|
+
if (Array.isArray(data[key])) return { key, rows: data[key] };
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function formatTable(data) {
|
|
70
|
+
if (Array.isArray(data?.title) && data.title.length > 0 && Array.isArray(data?.rows)) {
|
|
71
|
+
const headers = data.title.map((value) => String(value));
|
|
72
|
+
const table2 = new Table({ head: headers, wordWrap: true });
|
|
73
|
+
for (const row of data.rows) {
|
|
74
|
+
const values = Array.isArray(row) ? row : [row];
|
|
75
|
+
table2.push(headers.map((_header, index) => {
|
|
76
|
+
const value = values[index];
|
|
77
|
+
if (value === void 0 || value === null) return "";
|
|
78
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
79
|
+
return String(value);
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
return table2.toString();
|
|
83
|
+
}
|
|
84
|
+
const arrayField = findArrayField(data);
|
|
85
|
+
if (!arrayField || arrayField.rows.length === 0) {
|
|
86
|
+
return JSON.stringify(data, null, 2);
|
|
87
|
+
}
|
|
88
|
+
const rows = arrayField.rows;
|
|
89
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
90
|
+
for (const row of rows) {
|
|
91
|
+
if (typeof row === "object" && row !== null) {
|
|
92
|
+
Object.keys(row).forEach((k) => allKeys.add(k));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const keys = Array.from(allKeys);
|
|
96
|
+
if (keys.length === 0) return JSON.stringify(rows, null, 2);
|
|
97
|
+
const table = new Table({ head: keys, wordWrap: true });
|
|
98
|
+
for (const row of rows) {
|
|
99
|
+
table.push(keys.map((k) => {
|
|
100
|
+
const v = row?.[k];
|
|
101
|
+
if (v === void 0 || v === null) return "";
|
|
102
|
+
if (typeof v === "object") return JSON.stringify(v);
|
|
103
|
+
return String(v);
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
const sections = [];
|
|
107
|
+
if (arrayField.key && typeof data === "object" && data !== null) {
|
|
108
|
+
const summaryEntries = Object.entries(data).filter(([key]) => key !== arrayField.key);
|
|
109
|
+
if (summaryEntries.length > 0) {
|
|
110
|
+
const summary = new Table({ head: ["field", "value"], wordWrap: true });
|
|
111
|
+
for (const [key, value] of summaryEntries) {
|
|
112
|
+
summary.push([key, typeof value === "object" && value !== null ? JSON.stringify(value) : String(value ?? "")]);
|
|
113
|
+
}
|
|
114
|
+
sections.push(summary.toString());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
sections.push(table.toString());
|
|
118
|
+
return sections.join("\n\n");
|
|
119
|
+
}
|
|
120
|
+
async function applyJq(data, expr) {
|
|
121
|
+
const trimmed = expr.trim();
|
|
122
|
+
if (!trimmed) return data;
|
|
123
|
+
let results;
|
|
124
|
+
try {
|
|
125
|
+
results = await jqJson(data ?? null, trimmed);
|
|
126
|
+
} catch (err) {
|
|
127
|
+
const message = err instanceof JqError ? err.message : err?.message || String(err);
|
|
128
|
+
const error = new Error(`Invalid --jq expression: ${message}`);
|
|
129
|
+
error.type = "validation";
|
|
130
|
+
error.code = "OUTPUT_PROJECTION_FAILED";
|
|
131
|
+
error.hint = "The command completed. Original data and metadata are preserved in stdout; fix the jq expression locally without executing the command again. --jq applies to the command data before envelope wrapping.";
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
if (results.length === 0) return null;
|
|
135
|
+
if (results.length === 1) return results[0];
|
|
136
|
+
return results;
|
|
137
|
+
}
|
|
138
|
+
async function formatOutput(data, format, jqExpr) {
|
|
139
|
+
const outputData = isOutputWithMetadata(data) ? data.data : data;
|
|
140
|
+
const meta = isOutputWithMetadata(data) ? data.meta : void 0;
|
|
141
|
+
let processed = outputData;
|
|
142
|
+
if (jqExpr) {
|
|
143
|
+
processed = await applyJq(outputData, jqExpr);
|
|
144
|
+
}
|
|
145
|
+
if (format === "table") {
|
|
146
|
+
return redactExternalCliToken(formatTable(processed));
|
|
147
|
+
}
|
|
148
|
+
const hostCompat = getPendingHostCompatNotice();
|
|
149
|
+
const updateNotice = getPendingUpdateNotice();
|
|
150
|
+
const notices = {
|
|
151
|
+
...updateNotice ? {} : hostCompat ? { host_compat: hostCompat } : {},
|
|
152
|
+
...updateNotice ? { update: updateNotice } : {}
|
|
153
|
+
};
|
|
154
|
+
const envelope = {
|
|
155
|
+
ok: true,
|
|
156
|
+
data: processed,
|
|
157
|
+
...meta ? { meta } : {},
|
|
158
|
+
// Soft tip lives only under _notice (not mirrored into meta) to avoid duplicate fields.
|
|
159
|
+
...Object.keys(notices).length > 0 ? { _notice: notices } : {}
|
|
160
|
+
};
|
|
161
|
+
return redactExternalCliToken(JSON.stringify(envelope, null, 2));
|
|
162
|
+
}
|
|
163
|
+
function formatError(type, message, hint, code, meta, details) {
|
|
164
|
+
const envelope = {
|
|
165
|
+
ok: false,
|
|
166
|
+
error: { type, message, hint, code, ...details === void 0 ? {} : { details } },
|
|
167
|
+
...meta && Object.keys(meta).length > 0 ? { meta } : {}
|
|
168
|
+
};
|
|
169
|
+
return redactExternalCliToken(JSON.stringify(envelope, null, 2));
|
|
170
|
+
}
|
|
171
|
+
function printError(type, message, hint, code, meta, options = {}) {
|
|
172
|
+
const formatted = formatError(type, message, hint, code, meta, options.details);
|
|
173
|
+
process.stderr.write(formatted + "\n");
|
|
174
|
+
if (options.log !== false) {
|
|
175
|
+
logger.error(`[${type}] ${message}${hint ? " | " + hint : ""}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function sensitiveRecoveryData(data) {
|
|
179
|
+
const safe = {};
|
|
180
|
+
const item = {};
|
|
181
|
+
if (typeof data?.item?.id === "string") item.id = data.item.id;
|
|
182
|
+
if (Number.isSafeInteger(data?.item?.contentRevision)) item.contentRevision = data.item.contentRevision;
|
|
183
|
+
if (Object.keys(item).length > 0) safe.item = item;
|
|
184
|
+
if (["markdown", "text"].includes(data?.contentFormat)) safe.contentFormat = data.contentFormat;
|
|
185
|
+
if (typeof data?.out === "string") safe.out = data.out;
|
|
186
|
+
return safe;
|
|
187
|
+
}
|
|
188
|
+
async function printOutput(data, format, jqExpr, options = {}) {
|
|
189
|
+
try {
|
|
190
|
+
process.stdout.write(await formatOutput(data, format, jqExpr) + "\n");
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error?.code === "OUTPUT_PROJECTION_FAILED") {
|
|
193
|
+
if (options.redactErrors) {
|
|
194
|
+
error.message = "Invalid --jq expression: output projection failed; source content is omitted from diagnostics.";
|
|
195
|
+
error.hint = "The read completed. Fix --jq and explicitly run read-text again without --out, or inspect the file at data.out if present. This error result excludes source content.";
|
|
196
|
+
}
|
|
197
|
+
const recovery = JSON.parse(formatError(
|
|
198
|
+
"validation",
|
|
199
|
+
error.message,
|
|
200
|
+
error.hint,
|
|
201
|
+
error.code,
|
|
202
|
+
options.redactErrors ? void 0 : readOutputMetadata(data)
|
|
203
|
+
));
|
|
204
|
+
const recoveryData = options.redactErrors ? sensitiveRecoveryData(unwrapOutputData(data)) : unwrapOutputData(data);
|
|
205
|
+
await new Promise((resolve, reject) => {
|
|
206
|
+
process.stdout.write(
|
|
207
|
+
redactExternalCliToken(JSON.stringify({ ...recovery, data: recoveryData }, null, 2)) + "\n",
|
|
208
|
+
(error2) => error2 ? reject(error2) : resolve()
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
withOutputMetadata,
|
|
218
|
+
unwrapOutputData,
|
|
219
|
+
readOutputMetadata,
|
|
220
|
+
printError,
|
|
221
|
+
printOutput
|
|
222
|
+
};
|