@thinkingai/ae-cli 6.0.41 → 6.0.44
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-GBMV6TEJ.js → auth-2WTQOP77.js} +3 -3
- package/dist/{auth-NDSXE54J.js → auth-77BUFLGC.js} +57 -13
- package/dist/{capability-CETVHGXF.js → capability-ENHWPMTG.js} +12 -12
- package/dist/{capability-ZSQBMNOE.js → capability-WA37LSIR.js} +12 -12
- package/dist/{chunk-AFXA7BRK.js → chunk-4KVPKXFX.js} +5 -5
- package/dist/chunk-4SGZG4XY.js +311 -0
- package/dist/chunk-6EIJSNBD.js +8 -0
- package/dist/chunk-C4MGVGJW.js +13 -0
- package/dist/{chunk-4E3DB4MM.js → chunk-EE45RGOO.js} +7 -7
- package/dist/{chunk-WZRX4KOH.js → chunk-GT46FPXN.js} +4 -6
- package/dist/{chunk-5XUSIK27.js → chunk-ILIU36SU.js} +10 -7
- package/dist/{chunk-JHENBQ5B.js → chunk-LYVNONC4.js} +0 -35
- package/dist/{chunk-WANVG6SY.js → chunk-MGU2N3HW.js} +7 -7
- package/dist/{chunk-JUW4AJXN.js → chunk-P3FGXJTU.js} +12 -7
- package/dist/{chunk-FNZA5RZA.js → chunk-QEFCIRNJ.js} +4 -4
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/{chunk-J2N4PB56.js → chunk-QI524WPY.js} +4 -4
- package/dist/{chunk-VLWOLBGZ.js → chunk-UOUS37JQ.js} +149 -161
- package/dist/{chunk-AXDXJTPC.js → chunk-UW5UN47B.js} +19 -2
- package/dist/chunk-VPKZ7I72.js +509 -0
- package/dist/chunk-ZZUOD757.js +598 -0
- package/dist/{client-L2YDMHQ6.js → client-TKG4WBHN.js} +4 -5
- package/dist/{community-report-client-M2RW4MXD.js → community-report-client-FI4LNVYS.js} +3 -2
- package/dist/{config-OL2LWGBV.js → config-RE6CMGPK.js} +7 -7
- package/dist/data-integration-2MYMANJI.js +3383 -0
- package/dist/index.js +74 -40
- package/dist/local-data-upload-client-BWHSUQQK.js +167 -0
- package/dist/{memory-MUP7PPL7.js → memory-CHRU2F7W.js} +7 -6
- package/dist/{memory-U4O5PMXH.js → memory-YK33G4T7.js} +7 -6
- package/dist/{metadata-UKZDNLLQ.js → metadata-AXVHAAZG.js} +22 -18
- package/dist/{metadata-XXMJFN2M.js → metadata-GGEHHPBE.js} +22 -18
- package/dist/{model-JTUEO5M4.js → model-K3KLWIW6.js} +7 -3
- package/dist/model-NR3JHFSJ.js +139 -0
- package/dist/{sync-MOSFNBVR.js → sync-DAVKYVMW.js} +8 -6
- package/dist/sync-FCKOVWWS.js +10261 -0
- package/dist/{te-agent-IFKZDHZI.js → te-agent-4BKBODMF.js} +686 -71
- package/dist/te-agent-HLW4VTQK.js +3893 -0
- package/dist/{te-analysis-3QLLS35K.js → te-analysis-WX7LRVAV.js} +86 -63
- package/dist/{te-analysis-YSK2DBVL.js → te-analysis-YKFDBMA6.js} +86 -63
- package/dist/{te-community-HNKVTERD.js → te-community-6HPBWJUZ.js} +24 -19
- package/dist/{te-community-IWE5B7W6.js → te-community-HLC43QKH.js} +24 -20
- package/dist/{te-dataops-KXCEB4CS.js → te-dataops-EJP56W3K.js} +57 -34
- package/dist/{te-dataops-KQPYNAE3.js → te-dataops-HDRUXY4K.js} +59 -34
- package/dist/{te-engage-6RNGK5GH.js → te-engage-UBHPAJCO.js} +401 -15
- package/dist/{te-engage-IRMHTSQK.js → te-engage-WLDTS5J5.js} +401 -15
- package/dist/{te-kb-OIH3T6CS.js → te-kb-APXBWBDY.js} +6 -6
- package/dist/{te-system-AZ3URMUO.js → te-system-YARIK4S5.js} +7 -4
- package/dist/te-system-Z77IKZFN.js +2213 -0
- package/dist/{te-team-GZPU6UWA.js → te-team-EFKWYKMK.js} +7 -7
- package/dist/{update-TOBFXF2V.js → update-OGPSZM5A.js} +7 -7
- package/package.json +13 -3
- package/skills/ae-agent/SKILL.md +21 -11
- package/skills/ae-agent/references/approval-effect.md +44 -0
- package/skills/ae-agent/references/approval-request.md +46 -0
- package/skills/ae-agent/references/approval-task.md +45 -0
- package/skills/ae-agent/references/approval-type.md +32 -0
- package/skills/ae-agent/references/command_index.md +19 -0
- package/skills/ae-analysis/SKILL.md +11 -7
- package/skills/ae-analysis/references/adhoc_run.md +2 -0
- package/skills/ae-analysis/references/ai_models.md +31 -1
- package/skills/ae-analysis/references/alert_list.md +2 -3
- package/skills/ae-analysis/references/analysis_gateway_assets.md +8 -7
- package/skills/ae-analysis/references/bi_panel_list.md +2 -2
- package/skills/ae-analysis/references/command_index.md +18 -15
- package/skills/ae-analysis/references/dashboard_get.md +8 -2
- package/skills/ae-analysis/references/dashboard_list.md +2 -2
- package/skills/ae-analysis/references/dashboard_report_data_run.md +3 -1
- package/skills/ae-analysis/references/dashboard_update.md +4 -1
- package/skills/ae-analysis/references/favorite_add.md +2 -2
- package/skills/ae-analysis/references/favorite_remove.md +2 -2
- package/skills/ae-analysis/references/metric_create.md +7 -8
- package/skills/ae-analysis/references/project_space_business_filter_upsert.md +17 -0
- package/skills/ae-analysis/references/project_space_list.md +2 -2
- package/skills/ae-analysis/references/public_link_list.md +2 -2
- package/skills/ae-analysis/references/report_list.md +3 -3
- package/skills/ae-analysis/references/report_list_export.md +2 -2
- package/skills/ae-analysis/references/sql_table_list.md +3 -2
- package/skills/ae-analysis/references/user_cluster_update.md +4 -2
- package/skills/ae-analysis/references/user_tag_models.md +4 -4
- package/skills/ae-analysis/references/user_tag_update.md +4 -2
- package/skills/ae-analysis/references/virtual_property_sql_rule_update.md +3 -3
- package/skills/ae-data-integration/SKILL.md +54 -0
- package/skills/ae-data-integration/references/handoff.md +43 -0
- package/skills/ae-data-integration/references/local-analysis.md +27 -0
- package/skills/ae-data-integration/references/reuse.md +41 -0
- package/skills/ae-data-integration/references/sink-upload.md +58 -0
- package/skills/ae-data-integration/references/source-inspect.md +55 -0
- package/skills/ae-data-integration/references/sync-json-upload.md +60 -0
- package/skills/ae-data-integration/references/tracking-plan.md +35 -0
- package/skills/ae-data-integration/references/transform.md +65 -0
- package/skills/ae-data-integration/references/ue-mapping.md +142 -0
- package/skills/ae-data-integration/references/ue-routing.md +35 -0
- package/skills/ae-data-integration-helper/SKILL.md +1 -1
- package/skills/ae-dataops/SKILL.md +1 -1
- package/skills/ae-dataops/references/dataops-query.md +4 -4
- package/skills/ae-engage/SKILL.md +10 -2
- package/skills/ae-engage/references/flow-metric-user.md +2 -1
- package/skills/ae-engage/references/flow-node-metric-user.md +2 -1
- package/skills/ae-engage/references/flow-node-user.md +2 -1
- package/skills/ae-engage/references/task-indicator-user.md +104 -0
- package/skills/ae-engage/references/task-user-detail-export.md +31 -0
- package/skills/ae-generate-tracking-plan/SKILL.md +54 -3
- package/skills/ae-metadata/SKILL.md +0 -1
- package/skills/ae-metadata/references/metadata_property_dimension_table_bind_existing.md +1 -1
- package/dist/chunk-3FY3RJ26.js +0 -293
- package/dist/chunk-S5NTSDBS.js +0 -198
- package/dist/chunk-ZQKDZXDO.js +0 -317
- package/dist/cli-token-4UPER74P.js +0 -21
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
printError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GT46FPXN.js";
|
|
4
|
+
import {
|
|
5
|
+
internalCallSourceHeaders
|
|
6
|
+
} from "./chunk-6EIJSNBD.js";
|
|
4
7
|
import {
|
|
5
8
|
clearCliToken,
|
|
6
9
|
getCliToken
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
resolveHost
|
|
10
|
-
} from "./chunk-ZQKDZXDO.js";
|
|
10
|
+
} from "./chunk-4SGZG4XY.js";
|
|
11
11
|
import {
|
|
12
|
+
resolveHost,
|
|
12
13
|
safeJsonParse
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZZUOD757.js";
|
|
14
15
|
import {
|
|
15
16
|
CliValidationError,
|
|
16
17
|
PermissionError
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UW5UN47B.js";
|
|
18
19
|
import {
|
|
19
20
|
logger
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-LYVNONC4.js";
|
|
22
|
+
import "./chunk-QGM4M3NI.js";
|
|
21
23
|
|
|
22
24
|
// src/commands/te-dataops/shared.ts
|
|
25
|
+
import { randomBytes } from "crypto";
|
|
26
|
+
import { createWriteStream } from "fs";
|
|
27
|
+
import { mkdir, rename, unlink } from "fs/promises";
|
|
28
|
+
import { basename, dirname, join, resolve } from "path";
|
|
29
|
+
import { Readable } from "stream";
|
|
30
|
+
import { pipeline } from "stream/promises";
|
|
23
31
|
var TOOL_API_MAP = {
|
|
24
32
|
repo_list_spaces: { method: "GET", path: "/api/cli/dataops/v1/gaia/repo/spaces" },
|
|
25
33
|
datatable_get_table_detail: { method: "GET", path: "/api/cli/dataops/v1/gaia/datatable/table-detail" },
|
|
@@ -110,16 +118,16 @@ function buildDataopsApiDryRun(ctx, toolName59, args = {}) {
|
|
|
110
118
|
body: params
|
|
111
119
|
};
|
|
112
120
|
}
|
|
113
|
-
async function downloadDataopsApi(ctx,
|
|
121
|
+
async function downloadDataopsApi(ctx, path, params, targetPath, retry = true) {
|
|
114
122
|
const host = resolveHost(ctx.host());
|
|
115
123
|
const token = await getCliToken(host);
|
|
116
|
-
const url = buildUrl(host,
|
|
124
|
+
const url = buildUrl(host, path, compactArgs(params));
|
|
117
125
|
const resp = await fetch(url, {
|
|
118
126
|
method: "GET",
|
|
119
127
|
headers: {
|
|
120
128
|
"cli-token": token,
|
|
121
129
|
"Accept": "*/*",
|
|
122
|
-
|
|
130
|
+
...internalCallSourceHeaders()
|
|
123
131
|
}
|
|
124
132
|
});
|
|
125
133
|
if (resp.status === 403) {
|
|
@@ -128,23 +136,44 @@ async function downloadDataopsApi(ctx, path2, params, retry = true) {
|
|
|
128
136
|
}
|
|
129
137
|
if (resp.status === 401 && retry) {
|
|
130
138
|
clearCliToken(host);
|
|
131
|
-
return downloadDataopsApi(ctx,
|
|
139
|
+
return downloadDataopsApi(ctx, path, params, targetPath, false);
|
|
132
140
|
}
|
|
133
141
|
if (!resp.ok) {
|
|
134
142
|
const data = parseResponseBody(await resp.text(), url, resp.status, true);
|
|
135
143
|
throw new Error(formatHttpError(resp.status, resp.statusText, data));
|
|
136
144
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
if (!resp.body) {
|
|
146
|
+
throw new Error("DataOps download response has no body.");
|
|
147
|
+
}
|
|
148
|
+
const outputPath = resolve(targetPath);
|
|
149
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
150
|
+
const tempPath = join(
|
|
151
|
+
dirname(outputPath),
|
|
152
|
+
`.${basename(outputPath)}.part-${process.pid}-${randomBytes(6).toString("hex")}`
|
|
153
|
+
);
|
|
154
|
+
let tempPresent = false;
|
|
155
|
+
try {
|
|
156
|
+
tempPresent = true;
|
|
157
|
+
await pipeline(
|
|
158
|
+
Readable.fromWeb(resp.body),
|
|
159
|
+
createWriteStream(tempPath, { flags: "wx" })
|
|
160
|
+
);
|
|
161
|
+
await rename(tempPath, outputPath);
|
|
162
|
+
tempPresent = false;
|
|
163
|
+
return outputPath;
|
|
164
|
+
} finally {
|
|
165
|
+
if (tempPresent) await unlink(tempPath).catch(() => void 0);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function dataopsRequest(ctx, method, path, params = {}, body, retry = true) {
|
|
140
169
|
const host = resolveHost(ctx.host());
|
|
141
170
|
const token = await getCliToken(host);
|
|
142
|
-
const url = buildUrl(host,
|
|
171
|
+
const url = buildUrl(host, path, params);
|
|
143
172
|
const headers = {
|
|
144
173
|
"cli-token": token,
|
|
145
174
|
"Accept": "application/json",
|
|
146
175
|
"Content-Type": "application/json",
|
|
147
|
-
|
|
176
|
+
...internalCallSourceHeaders()
|
|
148
177
|
};
|
|
149
178
|
const options = { method, headers };
|
|
150
179
|
if (method !== "GET") {
|
|
@@ -160,16 +189,16 @@ async function dataopsRequest(ctx, method, path2, params = {}, body, retry = tru
|
|
|
160
189
|
if (resp.status === 401 && retry) {
|
|
161
190
|
logger.warn(`DataOps request failed (HTTP 401) for ${host}, refreshing CLI token`);
|
|
162
191
|
clearCliToken(host);
|
|
163
|
-
return dataopsRequest(ctx, method,
|
|
192
|
+
return dataopsRequest(ctx, method, path, params, body, false);
|
|
164
193
|
}
|
|
165
194
|
if (!resp.ok) {
|
|
166
195
|
throw new Error(formatHttpError(resp.status, resp.statusText, data));
|
|
167
196
|
}
|
|
168
197
|
return unwrapDataResponse(data);
|
|
169
198
|
}
|
|
170
|
-
function buildUrl(host,
|
|
199
|
+
function buildUrl(host, path, params = {}) {
|
|
171
200
|
const base = host.replace(/\/+$/, "");
|
|
172
|
-
const normalizedPath =
|
|
201
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
173
202
|
const url = new URL(`${base}${normalizedPath}`);
|
|
174
203
|
for (const [key, value] of Object.entries(params)) {
|
|
175
204
|
if (value !== void 0 && value !== null) {
|
|
@@ -219,8 +248,8 @@ function permissionMessage(data) {
|
|
|
219
248
|
}
|
|
220
249
|
function formatHttpError(status, statusText, data) {
|
|
221
250
|
const detail = typeof data === "string" ? data : data?.message || data?.error || data?.return_message || data?.returnMessage;
|
|
222
|
-
const
|
|
223
|
-
return `AE API error: HTTP ${status} ${statusText}${detail ? ` - ${detail}` : ""}${
|
|
251
|
+
const path = data?.path ? ` path: ${data.path}` : "";
|
|
252
|
+
return `AE API error: HTTP ${status} ${statusText}${detail ? ` - ${detail}` : ""}${path}`;
|
|
224
253
|
}
|
|
225
254
|
|
|
226
255
|
// src/commands/te-dataops/datatable/get-table-detail.ts
|
|
@@ -1845,8 +1874,6 @@ var cancelSqlQuery = {
|
|
|
1845
1874
|
};
|
|
1846
1875
|
|
|
1847
1876
|
// src/commands/te-dataops/ide/get-sql-query-status.ts
|
|
1848
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
1849
|
-
import path from "path";
|
|
1850
1877
|
var toolName51 = "ide_get_sql_query_status";
|
|
1851
1878
|
var downloadPath = "/api/cli/dataops/v1/gaia/ide/sql-query-download";
|
|
1852
1879
|
function optionalString5(ctx, name) {
|
|
@@ -1865,24 +1892,20 @@ function isDownloadReady(data) {
|
|
|
1865
1892
|
}
|
|
1866
1893
|
async function downloadResult(ctx, data, targetPath) {
|
|
1867
1894
|
const params = data?.downloadParams ?? {};
|
|
1868
|
-
|
|
1895
|
+
return downloadDataopsApi(ctx, downloadPath, {
|
|
1869
1896
|
spaceCode: params.spaceCode,
|
|
1870
1897
|
taskId: params.taskId
|
|
1871
|
-
});
|
|
1872
|
-
const absPath = path.resolve(targetPath);
|
|
1873
|
-
await mkdir(path.dirname(absPath), { recursive: true });
|
|
1874
|
-
await writeFile(absPath, bytes);
|
|
1875
|
-
return absPath;
|
|
1898
|
+
}, targetPath);
|
|
1876
1899
|
}
|
|
1877
1900
|
var getSqlQueryStatus = {
|
|
1878
1901
|
service: "dataops_ide",
|
|
1879
1902
|
command: "+get_sql_query_status",
|
|
1880
|
-
description: "Poll a Gaia download-center task created by +submit_sql_query. Requires spaceCode and downloadTaskId. requestId is trace-only. Returns status and download metadata; --downloadTo
|
|
1903
|
+
description: "Poll a Gaia download-center task created by +submit_sql_query. Requires spaceCode and downloadTaskId. requestId is trace-only. Returns status and download metadata; --downloadTo streams the result zip to a local file after SUCCESS and adds localFile.",
|
|
1881
1904
|
flags: [
|
|
1882
1905
|
{ name: "spaceCode", type: "string", required: true, desc: "Space code returned by +submit_sql_query" },
|
|
1883
1906
|
{ name: "downloadTaskId", type: "number", required: true, desc: "Download task ID returned by +submit_sql_query" },
|
|
1884
1907
|
{ name: "requestId", type: "string", required: false, desc: "Optional request ID returned by +submit_sql_query, used only for trace display" },
|
|
1885
|
-
{ name: "downloadTo", type: "string", required: false, desc: "Optional local file path.
|
|
1908
|
+
{ name: "downloadTo", type: "string", required: false, desc: "Optional local file path. After SUCCESS, stream the result zip and replace this path only when the download completes; use a .zip suffix, for example ./result.zip." }
|
|
1886
1909
|
],
|
|
1887
1910
|
risk: "read",
|
|
1888
1911
|
dryRun: (ctx) => buildDataopsApiDryRun(ctx, toolName51, buildArgs47(ctx)),
|
|
@@ -2144,10 +2167,10 @@ function buildArgs54(ctx) {
|
|
|
2144
2167
|
var submitSqlQuery = {
|
|
2145
2168
|
service: "dataops_ide",
|
|
2146
2169
|
command: "+submit_sql_query",
|
|
2147
|
-
description: "Submit
|
|
2170
|
+
description: "Submit exactly one read-only IDE SQL query and create a Gaia download-center task. Optional repoCode/engineType default to te_etl/TASK_ENGINE_TRINO. Results are platform-bounded; Gaia returns downloadRowLimit when supported, and rows are never returned by MCP/CLI.",
|
|
2148
2171
|
flags: [
|
|
2149
2172
|
{ name: "spaceCode", type: "string", required: true, desc: "Space code" },
|
|
2150
|
-
{ name: "sql", type: "string", required: true, desc: "
|
|
2173
|
+
{ name: "sql", type: "string", required: true, desc: "Exactly one read-only SQL query" },
|
|
2151
2174
|
{ name: "repoCode", type: "string", required: false, desc: "Repository code. Defaults to te_etl." },
|
|
2152
2175
|
{ name: "engineType", type: "string", required: false, desc: "SQL execution engine. Defaults to TASK_ENGINE_TRINO. Optional: TASK_ENGINE_STARROCKS." }
|
|
2153
2176
|
],
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
printError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GT46FPXN.js";
|
|
4
|
+
import {
|
|
5
|
+
internalCallSourceHeaders
|
|
6
|
+
} from "./chunk-C4MGVGJW.js";
|
|
4
7
|
import {
|
|
5
8
|
clearCliToken,
|
|
6
9
|
getCliToken
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
resolveHost
|
|
10
|
-
} from "./chunk-ZQKDZXDO.js";
|
|
10
|
+
} from "./chunk-4SGZG4XY.js";
|
|
11
11
|
import {
|
|
12
|
+
resolveHost,
|
|
12
13
|
safeJsonParse
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZZUOD757.js";
|
|
14
15
|
import {
|
|
15
16
|
CliValidationError,
|
|
16
17
|
PermissionError
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UW5UN47B.js";
|
|
18
19
|
import {
|
|
19
20
|
logger
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-LYVNONC4.js";
|
|
22
|
+
import "./chunk-QGM4M3NI.js";
|
|
21
23
|
|
|
22
24
|
// src/commands/te-dataops/shared.ts
|
|
25
|
+
import { randomBytes } from "crypto";
|
|
26
|
+
import { createWriteStream } from "fs";
|
|
27
|
+
import { mkdir, rename, unlink } from "fs/promises";
|
|
28
|
+
import { basename, dirname, join, resolve } from "path";
|
|
29
|
+
import { Readable } from "stream";
|
|
30
|
+
import { pipeline } from "stream/promises";
|
|
23
31
|
var TOOL_API_MAP = {
|
|
24
32
|
repo_list_spaces: { method: "GET", path: "/api/cli/dataops/v1/gaia/repo/spaces" },
|
|
25
33
|
datatable_get_table_detail: { method: "GET", path: "/api/cli/dataops/v1/gaia/datatable/table-detail" },
|
|
@@ -110,15 +118,16 @@ function buildDataopsApiDryRun(ctx, toolName59, args = {}) {
|
|
|
110
118
|
body: params
|
|
111
119
|
};
|
|
112
120
|
}
|
|
113
|
-
async function downloadDataopsApi(ctx,
|
|
121
|
+
async function downloadDataopsApi(ctx, path, params, targetPath, retry = true) {
|
|
114
122
|
const host = resolveHost(ctx.host());
|
|
115
123
|
const token = await getCliToken(host);
|
|
116
|
-
const url = buildUrl(host,
|
|
124
|
+
const url = buildUrl(host, path, compactArgs(params));
|
|
117
125
|
const resp = await fetch(url, {
|
|
118
126
|
method: "GET",
|
|
119
127
|
headers: {
|
|
120
128
|
"cli-token": token,
|
|
121
|
-
"Accept": "*/*"
|
|
129
|
+
"Accept": "*/*",
|
|
130
|
+
...internalCallSourceHeaders()
|
|
122
131
|
}
|
|
123
132
|
});
|
|
124
133
|
if (resp.status === 403) {
|
|
@@ -127,22 +136,44 @@ async function downloadDataopsApi(ctx, path2, params, retry = true) {
|
|
|
127
136
|
}
|
|
128
137
|
if (resp.status === 401 && retry) {
|
|
129
138
|
clearCliToken(host);
|
|
130
|
-
return downloadDataopsApi(ctx,
|
|
139
|
+
return downloadDataopsApi(ctx, path, params, targetPath, false);
|
|
131
140
|
}
|
|
132
141
|
if (!resp.ok) {
|
|
133
142
|
const data = parseResponseBody(await resp.text(), url, resp.status, true);
|
|
134
143
|
throw new Error(formatHttpError(resp.status, resp.statusText, data));
|
|
135
144
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
145
|
+
if (!resp.body) {
|
|
146
|
+
throw new Error("DataOps download response has no body.");
|
|
147
|
+
}
|
|
148
|
+
const outputPath = resolve(targetPath);
|
|
149
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
150
|
+
const tempPath = join(
|
|
151
|
+
dirname(outputPath),
|
|
152
|
+
`.${basename(outputPath)}.part-${process.pid}-${randomBytes(6).toString("hex")}`
|
|
153
|
+
);
|
|
154
|
+
let tempPresent = false;
|
|
155
|
+
try {
|
|
156
|
+
tempPresent = true;
|
|
157
|
+
await pipeline(
|
|
158
|
+
Readable.fromWeb(resp.body),
|
|
159
|
+
createWriteStream(tempPath, { flags: "wx" })
|
|
160
|
+
);
|
|
161
|
+
await rename(tempPath, outputPath);
|
|
162
|
+
tempPresent = false;
|
|
163
|
+
return outputPath;
|
|
164
|
+
} finally {
|
|
165
|
+
if (tempPresent) await unlink(tempPath).catch(() => void 0);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function dataopsRequest(ctx, method, path, params = {}, body, retry = true) {
|
|
139
169
|
const host = resolveHost(ctx.host());
|
|
140
170
|
const token = await getCliToken(host);
|
|
141
|
-
const url = buildUrl(host,
|
|
171
|
+
const url = buildUrl(host, path, params);
|
|
142
172
|
const headers = {
|
|
143
173
|
"cli-token": token,
|
|
144
174
|
"Accept": "application/json",
|
|
145
|
-
"Content-Type": "application/json"
|
|
175
|
+
"Content-Type": "application/json",
|
|
176
|
+
...internalCallSourceHeaders()
|
|
146
177
|
};
|
|
147
178
|
const options = { method, headers };
|
|
148
179
|
if (method !== "GET") {
|
|
@@ -158,16 +189,16 @@ async function dataopsRequest(ctx, method, path2, params = {}, body, retry = tru
|
|
|
158
189
|
if (resp.status === 401 && retry) {
|
|
159
190
|
logger.warn(`DataOps request failed (HTTP 401) for ${host}, refreshing CLI token`);
|
|
160
191
|
clearCliToken(host);
|
|
161
|
-
return dataopsRequest(ctx, method,
|
|
192
|
+
return dataopsRequest(ctx, method, path, params, body, false);
|
|
162
193
|
}
|
|
163
194
|
if (!resp.ok) {
|
|
164
195
|
throw new Error(formatHttpError(resp.status, resp.statusText, data));
|
|
165
196
|
}
|
|
166
197
|
return unwrapDataResponse(data);
|
|
167
198
|
}
|
|
168
|
-
function buildUrl(host,
|
|
199
|
+
function buildUrl(host, path, params = {}) {
|
|
169
200
|
const base = host.replace(/\/+$/, "");
|
|
170
|
-
const normalizedPath =
|
|
201
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
171
202
|
const url = new URL(`${base}${normalizedPath}`);
|
|
172
203
|
for (const [key, value] of Object.entries(params)) {
|
|
173
204
|
if (value !== void 0 && value !== null) {
|
|
@@ -217,8 +248,8 @@ function permissionMessage(data) {
|
|
|
217
248
|
}
|
|
218
249
|
function formatHttpError(status, statusText, data) {
|
|
219
250
|
const detail = typeof data === "string" ? data : data?.message || data?.error || data?.return_message || data?.returnMessage;
|
|
220
|
-
const
|
|
221
|
-
return `AE API error: HTTP ${status} ${statusText}${detail ? ` - ${detail}` : ""}${
|
|
251
|
+
const path = data?.path ? ` path: ${data.path}` : "";
|
|
252
|
+
return `AE API error: HTTP ${status} ${statusText}${detail ? ` - ${detail}` : ""}${path}`;
|
|
222
253
|
}
|
|
223
254
|
|
|
224
255
|
// src/commands/te-dataops/datatable/get-table-detail.ts
|
|
@@ -1843,8 +1874,6 @@ var cancelSqlQuery = {
|
|
|
1843
1874
|
};
|
|
1844
1875
|
|
|
1845
1876
|
// src/commands/te-dataops/ide/get-sql-query-status.ts
|
|
1846
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
1847
|
-
import path from "path";
|
|
1848
1877
|
var toolName51 = "ide_get_sql_query_status";
|
|
1849
1878
|
var downloadPath = "/api/cli/dataops/v1/gaia/ide/sql-query-download";
|
|
1850
1879
|
function optionalString5(ctx, name) {
|
|
@@ -1863,24 +1892,20 @@ function isDownloadReady(data) {
|
|
|
1863
1892
|
}
|
|
1864
1893
|
async function downloadResult(ctx, data, targetPath) {
|
|
1865
1894
|
const params = data?.downloadParams ?? {};
|
|
1866
|
-
|
|
1895
|
+
return downloadDataopsApi(ctx, downloadPath, {
|
|
1867
1896
|
spaceCode: params.spaceCode,
|
|
1868
1897
|
taskId: params.taskId
|
|
1869
|
-
});
|
|
1870
|
-
const absPath = path.resolve(targetPath);
|
|
1871
|
-
await mkdir(path.dirname(absPath), { recursive: true });
|
|
1872
|
-
await writeFile(absPath, bytes);
|
|
1873
|
-
return absPath;
|
|
1898
|
+
}, targetPath);
|
|
1874
1899
|
}
|
|
1875
1900
|
var getSqlQueryStatus = {
|
|
1876
1901
|
service: "dataops_ide",
|
|
1877
1902
|
command: "+get_sql_query_status",
|
|
1878
|
-
description: "Poll a Gaia download-center task created by +submit_sql_query. Requires spaceCode and downloadTaskId. requestId is trace-only. Returns status and download metadata; --downloadTo
|
|
1903
|
+
description: "Poll a Gaia download-center task created by +submit_sql_query. Requires spaceCode and downloadTaskId. requestId is trace-only. Returns status and download metadata; --downloadTo streams the result zip to a local file after SUCCESS and adds localFile.",
|
|
1879
1904
|
flags: [
|
|
1880
1905
|
{ name: "spaceCode", type: "string", required: true, desc: "Space code returned by +submit_sql_query" },
|
|
1881
1906
|
{ name: "downloadTaskId", type: "number", required: true, desc: "Download task ID returned by +submit_sql_query" },
|
|
1882
1907
|
{ name: "requestId", type: "string", required: false, desc: "Optional request ID returned by +submit_sql_query, used only for trace display" },
|
|
1883
|
-
{ name: "downloadTo", type: "string", required: false, desc: "Optional local file path.
|
|
1908
|
+
{ name: "downloadTo", type: "string", required: false, desc: "Optional local file path. After SUCCESS, stream the result zip and replace this path only when the download completes; use a .zip suffix, for example ./result.zip." }
|
|
1884
1909
|
],
|
|
1885
1910
|
risk: "read",
|
|
1886
1911
|
dryRun: (ctx) => buildDataopsApiDryRun(ctx, toolName51, buildArgs47(ctx)),
|
|
@@ -2142,10 +2167,10 @@ function buildArgs54(ctx) {
|
|
|
2142
2167
|
var submitSqlQuery = {
|
|
2143
2168
|
service: "dataops_ide",
|
|
2144
2169
|
command: "+submit_sql_query",
|
|
2145
|
-
description: "Submit
|
|
2170
|
+
description: "Submit exactly one read-only IDE SQL query and create a Gaia download-center task. Optional repoCode/engineType default to te_etl/TASK_ENGINE_TRINO. Results are platform-bounded; Gaia returns downloadRowLimit when supported, and rows are never returned by MCP/CLI.",
|
|
2146
2171
|
flags: [
|
|
2147
2172
|
{ name: "spaceCode", type: "string", required: true, desc: "Space code" },
|
|
2148
|
-
{ name: "sql", type: "string", required: true, desc: "
|
|
2173
|
+
{ name: "sql", type: "string", required: true, desc: "Exactly one read-only SQL query" },
|
|
2149
2174
|
{ name: "repoCode", type: "string", required: false, desc: "Repository code. Defaults to te_etl." },
|
|
2150
2175
|
{ name: "engineType", type: "string", required: false, desc: "SQL execution engine. Defaults to TASK_ENGINE_TRINO. Optional: TASK_ENGINE_STARROCKS." }
|
|
2151
2176
|
],
|