@thinkingai/ae-cli 6.0.56 → 6.0.57
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 +12 -4
- package/README.zh.md +12 -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-U7MNUUEF.js → auth-YEIJLBFY.js} +30 -12
- package/dist/{automation-K32V2NKP.js → automation-NAR5DDGL.js} +6 -6
- package/dist/{capability-VV7RHB3B.js → capability-P7DD4Q73.js} +48 -20
- package/dist/{chunk-KHS64JZQ.js → chunk-72NJKS7O.js} +4 -4
- package/dist/chunk-752BSLZC.js +222 -0
- package/dist/{chunk-W2PTY5NN.js → chunk-7ABK2PEJ.js} +3 -3
- package/dist/{chunk-UUD5RB36.js → chunk-7JAVT5TK.js} +3 -3
- package/dist/{chunk-P7KL7IOH.js → chunk-H3K5UGYC.js} +2 -2
- package/dist/{chunk-P6VFCH3P.js → chunk-IN7KKL6K.js} +2 -2
- package/dist/{chunk-MXV3PYC3.js → chunk-JCWM2TYP.js} +50 -12
- package/dist/{chunk-T44M3PLZ.js → chunk-JEUXDY3B.js} +1 -1
- package/dist/{chunk-LMCYSVVA.js → chunk-JNVVJ273.js} +51 -37
- package/dist/{chunk-JJJIP2XQ.js → chunk-N6XBLRB7.js} +2 -2
- package/dist/{chunk-QSAR3GHY.js → chunk-OAWPT7VP.js} +2 -2
- package/dist/{chunk-F6NIPIT5.js → chunk-QEMQKVHW.js} +35 -14
- package/dist/{chunk-2IYIYSUO.js → chunk-QVRIDN42.js} +2 -2
- package/dist/{chunk-GI5BMEZO.js → chunk-QZUVLFNR.js} +1 -1
- package/dist/{chunk-2UWS5CUP.js → chunk-RJHGDWSC.js} +3 -3
- package/dist/{chunk-3TQA5RXE.js → chunk-TKVVACEJ.js} +6 -4
- package/dist/chunk-TULINOLS.js +2283 -0
- package/dist/{chunk-X7DRLE62.js → chunk-YVG6QD3V.js} +1 -1
- package/dist/{chunk-ZW4VMY5H.js → chunk-Z3Q2AEIN.js} +152 -98
- package/dist/chunk-ZGIYG473.js +132 -0
- package/dist/{community-report-client-S2K3A3Q6.js → community-report-client-TJVCLZ3K.js} +1 -1
- package/dist/compat-check-PMEGUPZU.js +32 -0
- package/dist/{config-ASSAAIOI.js → config-VWVPR4WW.js} +38 -6
- package/dist/{context-6RWLVOM5.js → context-F6FCGTF3.js} +4 -4
- package/dist/{data-integration-EXSUPUDZ.js → data-integration-6UAZO4GG.js} +207 -24
- package/dist/{evaluation-5YT4QLCL.js → evaluation-4LO2O4AF.js} +4 -4
- package/dist/index.js +291 -71
- package/dist/{local-data-upload-client-7HCPGIS3.js → local-data-upload-client-KCMG6J62.js} +1 -1
- package/dist/{memory-VCYLVPMI.js → memory-HHPX3NF2.js} +6 -6
- package/dist/{metadata-TIWIOFTU.js → metadata-HEQQEEG3.js} +16 -8
- package/dist/{model-DPJHSD73.js → model-7UHGWYVR.js} +4 -4
- package/dist/{personal-semantic-preference-SBKU2LOK.js → personal-semantic-preference-V4L6ZWR2.js} +7 -6
- package/dist/{project-semantic-SKNWLH3I.js → project-semantic-NKHKJX6M.js} +7 -6
- package/dist/{sync-7PP6KQ75.js → sync-ZJMXCRIN.js} +8 -7
- package/dist/{te-agent-L2BYNPHM.js → te-agent-WBKIFEQD.js} +11 -7
- package/dist/{te-analysis-RJB6VJC4.js → te-analysis-ADX7RKO4.js} +179 -27
- package/dist/{te-community-QN3WMPNT.js → te-community-PREDRXG3.js} +720 -228
- package/dist/{te-dataops-UKD2XN3E.js → te-dataops-ITWJHO2U.js} +6 -5
- package/dist/{te-engage-KPTN4N2U.js → te-engage-VE2NUH5V.js} +7 -6
- package/dist/{te-kb-SFZI3W5T.js → te-kb-WSMOW7WS.js} +407 -83
- package/dist/{te-system-IE7NCKC3.js → te-system-YM657FKO.js} +6 -6
- package/dist/{te-team-4KHCFM2I.js → te-team-T2WRLOOD.js} +7 -6
- package/dist/{things-7JJUVAWL.js → things-6QOMFXOG.js} +7 -7
- package/dist/{update-AX66IFMJ.js → update-I4MOUYOX.js} +11 -7
- package/dist/{workspace-Q5NMEKEN.js → workspace-LYDAP647.js} +6 -6
- package/package.json +17 -7
- package/skills/ae-agent/SKILL.md +1 -1
- 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-kb/SKILL.md +33 -6
- package/skills/ae-kb/references/publication.md +81 -0
- package/skills/ae-kb/references/query-workflow.md +14 -1
- 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
|
@@ -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-TULINOLS.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
|
+
};
|
|
@@ -6,15 +6,15 @@ import {
|
|
|
6
6
|
CapabilityGatewayError,
|
|
7
7
|
fetchCapabilityGateway,
|
|
8
8
|
requestCapabilityGateway
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JCWM2TYP.js";
|
|
10
10
|
import {
|
|
11
11
|
readOutputMetadata,
|
|
12
12
|
unwrapOutputData,
|
|
13
13
|
withOutputMetadata
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-752BSLZC.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";
|
|
@@ -9,15 +9,15 @@ import {
|
|
|
9
9
|
postAgentApi,
|
|
10
10
|
putAgentApi,
|
|
11
11
|
uploadAgentApi
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-N6XBLRB7.js";
|
|
13
13
|
import {
|
|
14
14
|
TeAgentApiError,
|
|
15
15
|
createTeAgentApiError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RJHGDWSC.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";
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
readSandboxCliTokenEntry,
|
|
7
7
|
safeJsonParse,
|
|
8
8
|
safeReadJsonFile
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JNVVJ273.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,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getActiveHost
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JNVVJ273.js";
|
|
5
5
|
import {
|
|
6
6
|
normalizeUrl
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
8
8
|
|
|
9
9
|
// src/core/auth.ts
|
|
10
10
|
function resolveHost(hostOverride) {
|
|
@@ -6,14 +6,15 @@ import {
|
|
|
6
6
|
SecureStoreAuthError,
|
|
7
7
|
clearCliTokenCache,
|
|
8
8
|
getCliToken
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-H3K5UGYC.js";
|
|
10
10
|
import {
|
|
11
|
-
safeJsonParse
|
|
12
|
-
|
|
11
|
+
safeJsonParse,
|
|
12
|
+
stringifyJsonRequest
|
|
13
|
+
} from "./chunk-JNVVJ273.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";
|
|
@@ -326,7 +327,10 @@ function parseCapabilityResponse(text) {
|
|
|
326
327
|
return text;
|
|
327
328
|
}
|
|
328
329
|
}
|
|
329
|
-
function
|
|
330
|
+
function isCommunityGatewayRequest(domain, pathAfterV1) {
|
|
331
|
+
return domain.replace(/^\/+|\/+$/g, "") === "community" || /^capabilities\/community\./.test(pathAfterV1.replace(/^\/+/, ""));
|
|
332
|
+
}
|
|
333
|
+
function parseCapabilityEnvelope(body, acceptCommunityLegacyEnvelope = false) {
|
|
330
334
|
if (body == null) {
|
|
331
335
|
throw new CapabilityGatewayError("Empty capability gateway response");
|
|
332
336
|
}
|
|
@@ -351,10 +355,32 @@ function parseCapabilityEnvelope(body) {
|
|
|
351
355
|
err.type === "validation" ? "validation" : "api"
|
|
352
356
|
);
|
|
353
357
|
}
|
|
358
|
+
const legacyReturnCode = acceptCommunityLegacyEnvelope ? body.return_code ?? body.returnCode : void 0;
|
|
359
|
+
if (legacyReturnCode !== void 0 && Number(legacyReturnCode) !== 0) {
|
|
360
|
+
const code = String(legacyReturnCode);
|
|
361
|
+
const rawMessage = nonEmptyString(body.return_message) ?? nonEmptyString(body.returnMessage) ?? nonEmptyString(body.message);
|
|
362
|
+
const message = safeLegacyErrorMessage(rawMessage, code);
|
|
363
|
+
throw new CapabilityGatewayError(
|
|
364
|
+
message,
|
|
365
|
+
code,
|
|
366
|
+
void 0,
|
|
367
|
+
"The community service returned a legacy error envelope. Verify that the capability gateway route is deployed on the current host.",
|
|
368
|
+
{ legacy_return_code: legacyReturnCode }
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
if (legacyReturnCode !== void 0 && Number(legacyReturnCode) === 0 && "data" in body) {
|
|
372
|
+
return { ok: true, data: body.data };
|
|
373
|
+
}
|
|
354
374
|
return { ok: true, data: body };
|
|
355
375
|
}
|
|
356
|
-
function
|
|
357
|
-
|
|
376
|
+
function safeLegacyErrorMessage(message, code) {
|
|
377
|
+
if (!message || /\n\s*at\s|stacktrace|\.java:\d+/i.test(message)) {
|
|
378
|
+
return `Capability service request failed (legacy return code ${code})`;
|
|
379
|
+
}
|
|
380
|
+
return message.slice(0, 500);
|
|
381
|
+
}
|
|
382
|
+
function unwrapCapabilityEnvelope(body, acceptCommunityLegacyEnvelope = false) {
|
|
383
|
+
return parseCapabilityEnvelope(body, acceptCommunityLegacyEnvelope).data;
|
|
358
384
|
}
|
|
359
385
|
function nonEmptyString(value) {
|
|
360
386
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
@@ -407,7 +433,7 @@ async function requestOnce(url, method, token, body, accept = "application/json"
|
|
|
407
433
|
const init = { method, headers };
|
|
408
434
|
if (body !== void 0 && method !== "GET") {
|
|
409
435
|
headers["Content-Type"] = "application/json";
|
|
410
|
-
init.body =
|
|
436
|
+
init.body = stringifyJsonRequest(includeClientContextInBody ? withCliAgentContextBody(body, agentContext) : body);
|
|
411
437
|
}
|
|
412
438
|
return fetch(url, { ...init, ...externalCliTokenRequestOptions(url) });
|
|
413
439
|
}
|
|
@@ -447,7 +473,10 @@ async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body,
|
|
|
447
473
|
if (!resp.ok) {
|
|
448
474
|
await throwCapabilityHttpError(resp);
|
|
449
475
|
}
|
|
450
|
-
return parseCapabilityEnvelope(
|
|
476
|
+
return parseCapabilityEnvelope(
|
|
477
|
+
parseCapabilityResponse(await resp.text()),
|
|
478
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
479
|
+
);
|
|
451
480
|
}
|
|
452
481
|
async function fetchCapabilityGateway(host, domain, pathAfterV1, method = "GET", body, accept = "application/json") {
|
|
453
482
|
const url = buildCapabilityGatewayUrl(host, domain, pathAfterV1);
|
|
@@ -467,11 +496,17 @@ async function fetchCapabilityGateway(host, domain, pathAfterV1, method = "GET",
|
|
|
467
496
|
}
|
|
468
497
|
async function requestCapabilityGateway(host, domain, pathAfterV1, method = "GET", body) {
|
|
469
498
|
const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
|
|
470
|
-
return unwrapCapabilityEnvelope(
|
|
499
|
+
return unwrapCapabilityEnvelope(
|
|
500
|
+
parseCapabilityResponse(await resp.text()),
|
|
501
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
502
|
+
);
|
|
471
503
|
}
|
|
472
504
|
async function requestCapabilityGatewayWithEnvelope(host, domain, pathAfterV1, method = "GET", body) {
|
|
473
505
|
const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
|
|
474
|
-
return parseCapabilityEnvelope(
|
|
506
|
+
return parseCapabilityEnvelope(
|
|
507
|
+
parseCapabilityResponse(await resp.text()),
|
|
508
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
509
|
+
);
|
|
475
510
|
}
|
|
476
511
|
async function listCapabilitiesWithEnvelope(host, domain, projectId) {
|
|
477
512
|
return callGatewayWithEnvelope(host, domain, "capabilities", "GET", void 0, { project_id: projectId });
|
|
@@ -552,7 +587,10 @@ async function uploadInputFileBytes(host, domain, projectId, purpose, bytes, fil
|
|
|
552
587
|
if (!resp.ok) {
|
|
553
588
|
await throwCapabilityHttpError(resp);
|
|
554
589
|
}
|
|
555
|
-
return unwrapCapabilityEnvelope(
|
|
590
|
+
return unwrapCapabilityEnvelope(
|
|
591
|
+
parseCapabilityResponse(await resp.text()),
|
|
592
|
+
isCommunityGatewayRequest(domain, "input-files")
|
|
593
|
+
);
|
|
556
594
|
}
|
|
557
595
|
async function callCapabilityApi(host, domain, action, method = "POST", params = {}, options = {}) {
|
|
558
596
|
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({
|
|
@@ -3,7 +3,43 @@ import {
|
|
|
3
3
|
logger,
|
|
4
4
|
normalizeUrl,
|
|
5
5
|
readExternalCliToken
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
7
|
+
|
|
8
|
+
// src/core/sandbox-runtime.ts
|
|
9
|
+
import { homedir } from "os";
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
import fs from "fs";
|
|
12
|
+
var LINUX_SANDBOX_RUNTIME_ROOT = "/home/ta/te_agent_ta";
|
|
13
|
+
function getDefaultSandboxRuntimeRoot() {
|
|
14
|
+
if (process.platform === "linux") {
|
|
15
|
+
return LINUX_SANDBOX_RUNTIME_ROOT;
|
|
16
|
+
}
|
|
17
|
+
return homedir();
|
|
18
|
+
}
|
|
19
|
+
function getSandboxRuntimeRoot() {
|
|
20
|
+
return process.env.SANDBOX_RUNTIME_ROOT || getDefaultSandboxRuntimeRoot();
|
|
21
|
+
}
|
|
22
|
+
function getSandboxAeConfigDir() {
|
|
23
|
+
return join(getSandboxRuntimeRoot(), ".ae-config");
|
|
24
|
+
}
|
|
25
|
+
function getSandboxCliTokenFilePath() {
|
|
26
|
+
return join(getSandboxAeConfigDir(), "cli-token.json");
|
|
27
|
+
}
|
|
28
|
+
function isAeSandboxRuntime() {
|
|
29
|
+
if (process.env.SANDBOX_RUNTIME_ROOT) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (process.platform !== "linux") {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
if (fs.existsSync(getSandboxCliTokenFilePath())) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
7
43
|
|
|
8
44
|
// src/core/config.ts
|
|
9
45
|
import fs3 from "fs";
|
|
@@ -11,11 +47,17 @@ import path from "path";
|
|
|
11
47
|
import os from "os";
|
|
12
48
|
|
|
13
49
|
// src/core/json-utils.ts
|
|
14
|
-
import
|
|
50
|
+
import fs2 from "fs";
|
|
15
51
|
import { createRequire } from "module";
|
|
16
52
|
var require2 = createRequire(import.meta.url);
|
|
17
53
|
var JSONbig = require2("json-bigint");
|
|
18
54
|
var jsonParser = JSONbig({ storeAsString: true });
|
|
55
|
+
var requestJsonStringifier = JSONbig({ useNativeBigInt: true });
|
|
56
|
+
var requestJsonParser = JSONbig({
|
|
57
|
+
useNativeBigInt: true,
|
|
58
|
+
protoAction: "error",
|
|
59
|
+
constructorAction: "error"
|
|
60
|
+
});
|
|
19
61
|
var INTEGER_TOKEN = /^-?(?:0|[1-9]\d*)$/;
|
|
20
62
|
function normalizeParsedNumbers(lossless, native) {
|
|
21
63
|
if (typeof lossless === "string" && typeof native === "number") {
|
|
@@ -42,44 +84,14 @@ function safeJsonParse(text) {
|
|
|
42
84
|
return normalizeParsedNumbers(lossless, JSON.parse(text));
|
|
43
85
|
}
|
|
44
86
|
function safeReadJsonFile(filePath) {
|
|
45
|
-
const content =
|
|
87
|
+
const content = fs2.readFileSync(filePath, "utf-8");
|
|
46
88
|
return safeJsonParse(content);
|
|
47
89
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
import { homedir } from "os";
|
|
51
|
-
import { join } from "path";
|
|
52
|
-
import fs2 from "fs";
|
|
53
|
-
var LINUX_SANDBOX_RUNTIME_ROOT = "/home/ta/te_agent_ta";
|
|
54
|
-
function getDefaultSandboxRuntimeRoot() {
|
|
55
|
-
if (process.platform === "linux") {
|
|
56
|
-
return LINUX_SANDBOX_RUNTIME_ROOT;
|
|
57
|
-
}
|
|
58
|
-
return homedir();
|
|
59
|
-
}
|
|
60
|
-
function getSandboxRuntimeRoot() {
|
|
61
|
-
return process.env.SANDBOX_RUNTIME_ROOT || getDefaultSandboxRuntimeRoot();
|
|
90
|
+
function stringifyJsonRequest(obj) {
|
|
91
|
+
return requestJsonStringifier.stringify(obj);
|
|
62
92
|
}
|
|
63
|
-
function
|
|
64
|
-
return
|
|
65
|
-
}
|
|
66
|
-
function getSandboxCliTokenFilePath() {
|
|
67
|
-
return join(getSandboxAeConfigDir(), "cli-token.json");
|
|
68
|
-
}
|
|
69
|
-
function isAeSandboxRuntime() {
|
|
70
|
-
if (process.env.SANDBOX_RUNTIME_ROOT) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
if (process.platform !== "linux") {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
if (fs2.existsSync(getSandboxCliTokenFilePath())) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
|
-
return false;
|
|
93
|
+
function parseJsonRequest(text) {
|
|
94
|
+
return requestJsonParser.parse(text);
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
// src/core/config.ts
|
|
@@ -280,6 +292,8 @@ function getConfigDir() {
|
|
|
280
292
|
export {
|
|
281
293
|
safeJsonParse,
|
|
282
294
|
safeReadJsonFile,
|
|
295
|
+
stringifyJsonRequest,
|
|
296
|
+
parseJsonRequest,
|
|
283
297
|
getSandboxRuntimeRoot,
|
|
284
298
|
isAeSandboxRuntime,
|
|
285
299
|
readSandboxCliTokenEntry,
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
postToMainApp,
|
|
11
11
|
putToMainApp,
|
|
12
12
|
uploadToMainApp
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RJHGDWSC.js";
|
|
14
14
|
import {
|
|
15
15
|
clearCliTokenCache
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-H3K5UGYC.js";
|
|
17
17
|
|
|
18
18
|
// src/core/resource-package-client.ts
|
|
19
19
|
function checkPath(path) {
|
|
@@ -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({
|
|
@@ -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-JCWM2TYP.js";
|
|
5
5
|
import {
|
|
6
6
|
SecureStoreAuthError,
|
|
7
7
|
getCliToken
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-H3K5UGYC.js";
|
|
9
9
|
import {
|
|
10
10
|
safeJsonParse
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JNVVJ273.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
|
}
|
|
@@ -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({
|