@thinkingai/ae-cli 6.1.14 → 6.1.17
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 +5 -2
- package/README.zh.md +5 -2
- package/dist/{auth-GBMV6TEJ.js → auth-2WTQOP77.js} +3 -3
- package/dist/{auth-NDSXE54J.js → auth-77BUFLGC.js} +57 -13
- package/dist/{capability-TAMDRZYV.js → capability-72DTW5M2.js} +9 -9
- package/dist/{capability-U7TDEEEG.js → capability-PJHNI4GJ.js} +9 -9
- 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-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-JUW4AJXN.js → chunk-P3FGXJTU.js} +12 -7
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/{chunk-753BUTNZ.js → chunk-RGKJGKT7.js} +2 -2
- package/dist/{chunk-UIHQJK5E.js → chunk-SAU3QFIQ.js} +3 -3
- 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-QATA32VR.js → chunk-VR3LCBHW.js} +2 -2
- package/dist/{chunk-IBH3LDAH.js → chunk-YA6SMTXG.js} +3 -3
- 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-XQYB4X4F.js +3503 -0
- package/dist/index.js +68 -34
- 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-5MIMNIMT.js → metadata-UILXHBWF.js} +10 -9
- package/dist/{metadata-LERKDJN6.js → metadata-XXR34N5P.js} +10 -9
- 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-FCHRTNIY.js → te-analysis-O6DCO6BS.js} +36 -13
- package/dist/{te-analysis-QG7UKGDA.js → te-analysis-ZMNGOVNW.js} +36 -13
- 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-D6EG3NOR.js → te-engage-FGBGQ4IY.js} +9 -8
- package/dist/{te-engage-ZSMIJLUW.js → te-engage-RAK5PESW.js} +9 -8
- package/dist/{te-experiment-K5US7RMG.js → te-experiment-SO5MPDMJ.js} +9 -8
- package/dist/{te-experiment-WA7TFMEL.js → te-experiment-VZF7BT6G.js} +9 -8
- package/dist/{te-kb-OIH3T6CS.js → te-kb-SQCLHG6X.js} +250 -126
- 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 +14 -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 +27 -0
- package/skills/ae-analysis/references/analysis_gateway_assets.md +3 -2
- package/skills/ae-analysis/references/command_index.md +4 -1
- package/skills/ae-analysis/references/dashboard_get.md +8 -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/project_space_business_filter_upsert.md +17 -0
- package/skills/ae-analysis/references/user_tag_models.md +4 -4
- 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 +68 -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-generate-tracking-plan/SKILL.md +54 -3
- package/skills/ae-kb/SKILL.md +55 -50
- package/skills/ae-kb/references/query-workflow.md +112 -0
- package/skills/ae-kb-discovery/SKILL.md +105 -0
- package/skills/ae-metadata/SKILL.md +0 -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,62 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
kbApi,
|
|
3
3
|
kbUpload
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
query: ctx.str("query")
|
|
16
|
-
};
|
|
17
|
-
const sources = ctx.json("sources");
|
|
18
|
-
if (sources) body.sources = sources;
|
|
19
|
-
const topK = ctx.num("top-k");
|
|
20
|
-
if (topK) body.topK = topK;
|
|
21
|
-
const locale = ctx.str("locale");
|
|
22
|
-
if (locale) body.locale = locale;
|
|
23
|
-
return body;
|
|
24
|
-
}
|
|
25
|
-
var query = {
|
|
26
|
-
service: "kb",
|
|
27
|
-
command: "+query",
|
|
28
|
-
description: "Query knowledge bases via POST /agent/api/external/knowledge-bases/query. Returns ranked passages for a natural-language question.",
|
|
29
|
-
flags: [
|
|
30
|
-
{
|
|
31
|
-
name: "query",
|
|
32
|
-
type: "string",
|
|
33
|
-
required: true,
|
|
34
|
-
alias: "q",
|
|
35
|
-
desc: "Natural language question to query against the knowledge bases"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: "sources",
|
|
39
|
-
type: "json",
|
|
40
|
-
required: false,
|
|
41
|
-
desc: 'Optional JSON array of knowledge base refs to scope the query, e.g. [{"scope":"company","name":"engineering-handbook"}]. Omit to search all accessible knowledge bases.'
|
|
42
|
-
},
|
|
43
|
-
{ name: "top-k", type: "number", required: false, desc: "Max number of hits to return (1-10000, default 10)" },
|
|
44
|
-
{ name: "locale", type: "string", required: false, desc: "Optional locale: zh | en | ja | ko" }
|
|
45
|
-
],
|
|
46
|
-
risk: "read",
|
|
47
|
-
dryRun: (ctx) => ({
|
|
48
|
-
method: "POST",
|
|
49
|
-
url: `${ctx.host().replace(/\/$/, "")}${API_PATH}`,
|
|
50
|
-
body: buildBody(ctx)
|
|
51
|
-
}),
|
|
52
|
-
execute: async (ctx) => kbApi(ctx, "POST", API_PATH, {}, buildBody(ctx))
|
|
53
|
-
};
|
|
4
|
+
} from "./chunk-4KVPKXFX.js";
|
|
5
|
+
import {
|
|
6
|
+
printError
|
|
7
|
+
} from "./chunk-GT46FPXN.js";
|
|
8
|
+
import "./chunk-4SGZG4XY.js";
|
|
9
|
+
import "./chunk-ZZUOD757.js";
|
|
10
|
+
import {
|
|
11
|
+
PermissionError
|
|
12
|
+
} from "./chunk-UW5UN47B.js";
|
|
13
|
+
import "./chunk-LYVNONC4.js";
|
|
14
|
+
import "./chunk-QGM4M3NI.js";
|
|
54
15
|
|
|
55
16
|
// src/commands/te-kb/add.ts
|
|
56
17
|
import { promises as fs } from "fs";
|
|
57
18
|
import * as path from "path";
|
|
58
19
|
import TurndownService from "turndown";
|
|
59
|
-
var
|
|
20
|
+
var API_PATH = "/agent/api/external/knowledge-bases/sources/upload";
|
|
60
21
|
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
61
22
|
".md",
|
|
62
23
|
".markdown",
|
|
@@ -267,7 +228,7 @@ var add = {
|
|
|
267
228
|
const items = normalizeFilesInput(ctx.json("files"));
|
|
268
229
|
return {
|
|
269
230
|
method: "POST",
|
|
270
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
231
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH}`,
|
|
271
232
|
body: {
|
|
272
233
|
name: ctx.str("name"),
|
|
273
234
|
files: items.map((item) => ({ value: item, type: classifyInput(item) })),
|
|
@@ -279,7 +240,7 @@ var add = {
|
|
|
279
240
|
const name = ctx.str("name");
|
|
280
241
|
const files = await collectFiles(ctx);
|
|
281
242
|
const form = buildForm(name, files);
|
|
282
|
-
const result = await kbUpload(ctx,
|
|
243
|
+
const result = await kbUpload(ctx, API_PATH, form);
|
|
283
244
|
return {
|
|
284
245
|
uploaded: files.map((f) => ({ filename: f.filename, origin: f.origin, source: f.source })),
|
|
285
246
|
result
|
|
@@ -288,7 +249,7 @@ var add = {
|
|
|
288
249
|
};
|
|
289
250
|
|
|
290
251
|
// src/commands/te-kb/compile.ts
|
|
291
|
-
var
|
|
252
|
+
var API_PATH2 = "/agent/api/external/knowledge-bases/compile";
|
|
292
253
|
var VALID_MODES = /* @__PURE__ */ new Set(["incremental", "full"]);
|
|
293
254
|
function getMode(ctx) {
|
|
294
255
|
const mode = ctx.str("mode") || "incremental";
|
|
@@ -297,7 +258,7 @@ function getMode(ctx) {
|
|
|
297
258
|
}
|
|
298
259
|
return mode;
|
|
299
260
|
}
|
|
300
|
-
function
|
|
261
|
+
function buildBody(ctx) {
|
|
301
262
|
return {
|
|
302
263
|
name: ctx.str("name"),
|
|
303
264
|
mode: getMode(ctx)
|
|
@@ -317,15 +278,15 @@ var compile = {
|
|
|
317
278
|
},
|
|
318
279
|
dryRun: (ctx) => ({
|
|
319
280
|
method: "POST",
|
|
320
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
321
|
-
body:
|
|
281
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH2}`,
|
|
282
|
+
body: buildBody(ctx)
|
|
322
283
|
}),
|
|
323
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
284
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH2, {}, buildBody(ctx))
|
|
324
285
|
};
|
|
325
286
|
|
|
326
287
|
// src/commands/te-kb/remove.ts
|
|
327
|
-
var
|
|
328
|
-
function
|
|
288
|
+
var API_PATH3 = "/agent/api/external/knowledge-bases";
|
|
289
|
+
function buildBody2(ctx) {
|
|
329
290
|
return { name: ctx.str("name") };
|
|
330
291
|
}
|
|
331
292
|
var remove = {
|
|
@@ -338,14 +299,14 @@ var remove = {
|
|
|
338
299
|
risk: "high-risk-write",
|
|
339
300
|
dryRun: (ctx) => ({
|
|
340
301
|
method: "DELETE",
|
|
341
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
342
|
-
body:
|
|
302
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH3}`,
|
|
303
|
+
body: buildBody2(ctx)
|
|
343
304
|
}),
|
|
344
|
-
execute: async (ctx) => kbApi(ctx, "DELETE",
|
|
305
|
+
execute: async (ctx) => kbApi(ctx, "DELETE", API_PATH3, {}, buildBody2(ctx))
|
|
345
306
|
};
|
|
346
307
|
|
|
347
308
|
// src/commands/te-kb/create.ts
|
|
348
|
-
var
|
|
309
|
+
var API_PATH4 = "/agent/api/external/knowledge-bases/create";
|
|
349
310
|
var VALID_SCOPES = /* @__PURE__ */ new Set(["personal", "company"]);
|
|
350
311
|
function getScope(ctx) {
|
|
351
312
|
const scope = ctx.str("scope") || "company";
|
|
@@ -372,7 +333,7 @@ function normalizeTags(raw) {
|
|
|
372
333
|
}
|
|
373
334
|
return tags;
|
|
374
335
|
}
|
|
375
|
-
function
|
|
336
|
+
function buildBody3(ctx) {
|
|
376
337
|
const body = {
|
|
377
338
|
scope: getScope(ctx),
|
|
378
339
|
name: ctx.str("name")
|
|
@@ -406,15 +367,15 @@ var create = {
|
|
|
406
367
|
},
|
|
407
368
|
dryRun: (ctx) => ({
|
|
408
369
|
method: "POST",
|
|
409
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
410
|
-
body:
|
|
370
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH4}`,
|
|
371
|
+
body: buildBody3(ctx)
|
|
411
372
|
}),
|
|
412
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
373
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH4, {}, buildBody3(ctx))
|
|
413
374
|
};
|
|
414
375
|
|
|
415
376
|
// src/commands/te-kb/rm-source.ts
|
|
416
|
-
var
|
|
417
|
-
function
|
|
377
|
+
var API_PATH5 = "/agent/api/external/knowledge-bases/sources";
|
|
378
|
+
function buildBody4(ctx) {
|
|
418
379
|
return {
|
|
419
380
|
name: ctx.str("name"),
|
|
420
381
|
displayName: ctx.str("display-name")
|
|
@@ -431,15 +392,15 @@ var rmSource = {
|
|
|
431
392
|
risk: "write",
|
|
432
393
|
dryRun: (ctx) => ({
|
|
433
394
|
method: "DELETE",
|
|
434
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
435
|
-
body:
|
|
395
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH5}`,
|
|
396
|
+
body: buildBody4(ctx)
|
|
436
397
|
}),
|
|
437
|
-
execute: async (ctx) => kbApi(ctx, "DELETE",
|
|
398
|
+
execute: async (ctx) => kbApi(ctx, "DELETE", API_PATH5, {}, buildBody4(ctx))
|
|
438
399
|
};
|
|
439
400
|
|
|
440
401
|
// src/commands/te-kb/schema.ts
|
|
441
|
-
var
|
|
442
|
-
function
|
|
402
|
+
var API_PATH6 = "/agent/api/external/knowledge-bases/schema";
|
|
403
|
+
function buildBody5(ctx) {
|
|
443
404
|
const body = {
|
|
444
405
|
name: ctx.str("name")
|
|
445
406
|
};
|
|
@@ -460,15 +421,15 @@ var schema = {
|
|
|
460
421
|
risk: "write",
|
|
461
422
|
dryRun: (ctx) => ({
|
|
462
423
|
method: "POST",
|
|
463
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
464
|
-
body:
|
|
424
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH6}`,
|
|
425
|
+
body: buildBody5(ctx)
|
|
465
426
|
}),
|
|
466
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
427
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH6, {}, buildBody5(ctx))
|
|
467
428
|
};
|
|
468
429
|
|
|
469
430
|
// src/commands/te-kb/status.ts
|
|
470
|
-
var
|
|
471
|
-
function
|
|
431
|
+
var API_PATH7 = "/agent/api/external/knowledge-bases/status";
|
|
432
|
+
function buildBody6(ctx) {
|
|
472
433
|
return {
|
|
473
434
|
name: ctx.str("name")
|
|
474
435
|
};
|
|
@@ -483,15 +444,15 @@ var status = {
|
|
|
483
444
|
risk: "read",
|
|
484
445
|
dryRun: (ctx) => ({
|
|
485
446
|
method: "POST",
|
|
486
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
487
|
-
body:
|
|
447
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH7}`,
|
|
448
|
+
body: buildBody6(ctx)
|
|
488
449
|
}),
|
|
489
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
450
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH7, {}, buildBody6(ctx))
|
|
490
451
|
};
|
|
491
452
|
|
|
492
453
|
// src/commands/te-kb/kb-index.ts
|
|
493
|
-
var
|
|
494
|
-
function
|
|
454
|
+
var API_PATH8 = "/agent/api/external/knowledge-bases/index";
|
|
455
|
+
function buildBody7(ctx) {
|
|
495
456
|
const body = {};
|
|
496
457
|
const sources = ctx.json("sources");
|
|
497
458
|
if (sources) body.sources = sources;
|
|
@@ -515,19 +476,30 @@ var kbIndex = {
|
|
|
515
476
|
risk: "read",
|
|
516
477
|
dryRun: (ctx) => ({
|
|
517
478
|
method: "POST",
|
|
518
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
519
|
-
body:
|
|
479
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH8}`,
|
|
480
|
+
body: buildBody7(ctx)
|
|
520
481
|
}),
|
|
521
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
482
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH8, {}, buildBody7(ctx))
|
|
522
483
|
};
|
|
523
484
|
|
|
524
485
|
// src/commands/te-kb/kb-list.ts
|
|
525
|
-
var
|
|
486
|
+
var API_PATH9 = "/agent/api/external/knowledge-bases/list";
|
|
526
487
|
var DEFAULT_BUILD_STATUS = "compiled";
|
|
488
|
+
var VALID_BUILD_STATUSES = ["idle", "pending", "compiling", "compiled", "failed"];
|
|
527
489
|
function getBuildStatus(ctx) {
|
|
528
490
|
return ctx.str("build-status") || DEFAULT_BUILD_STATUS;
|
|
529
491
|
}
|
|
530
|
-
function
|
|
492
|
+
function validateBuildStatus(ctx) {
|
|
493
|
+
const value = ctx.str("build-status");
|
|
494
|
+
if (value && !VALID_BUILD_STATUSES.includes(value)) {
|
|
495
|
+
printError(
|
|
496
|
+
"validation",
|
|
497
|
+
`Invalid --build-status: ${value}. Valid values: ${VALID_BUILD_STATUSES.join(" | ")} (omit to default to ${DEFAULT_BUILD_STATUS}).`
|
|
498
|
+
);
|
|
499
|
+
process.exit(1);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function buildBody8(ctx) {
|
|
531
503
|
const body = {
|
|
532
504
|
buildStatus: getBuildStatus(ctx)
|
|
533
505
|
};
|
|
@@ -545,27 +517,30 @@ var kbList = {
|
|
|
545
517
|
type: "string",
|
|
546
518
|
required: false,
|
|
547
519
|
default: DEFAULT_BUILD_STATUS,
|
|
548
|
-
desc:
|
|
520
|
+
desc: `Filter by knowledge base build status: ${VALID_BUILD_STATUSES.join(" | ")} (default: ${DEFAULT_BUILD_STATUS} when omitted)`
|
|
549
521
|
},
|
|
550
522
|
{ name: "locale", type: "string", required: false, desc: "Optional locale: zh | en | ja | ko" }
|
|
551
523
|
],
|
|
552
524
|
risk: "read",
|
|
525
|
+
validate: (ctx) => {
|
|
526
|
+
validateBuildStatus(ctx);
|
|
527
|
+
},
|
|
553
528
|
dryRun: (ctx) => ({
|
|
554
529
|
method: "POST",
|
|
555
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
556
|
-
body:
|
|
530
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH9}`,
|
|
531
|
+
body: buildBody8(ctx)
|
|
557
532
|
}),
|
|
558
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
533
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH9, {}, buildBody8(ctx))
|
|
559
534
|
};
|
|
560
535
|
|
|
561
536
|
// src/commands/te-kb/kb-grep.ts
|
|
562
|
-
var
|
|
563
|
-
function
|
|
537
|
+
var API_PATH10 = "/agent/api/external/knowledge-bases/grep";
|
|
538
|
+
function buildBody9(ctx) {
|
|
564
539
|
const body = {
|
|
565
|
-
query: ctx.str("query")
|
|
540
|
+
query: ctx.str("query"),
|
|
541
|
+
sources: ctx.json("sources"),
|
|
542
|
+
paths: ctx.json("paths")
|
|
566
543
|
};
|
|
567
|
-
const sources = ctx.json("sources");
|
|
568
|
-
if (sources) body.sources = sources;
|
|
569
544
|
const topK = ctx.num("top-k");
|
|
570
545
|
if (topK) body.topK = topK;
|
|
571
546
|
const locale = ctx.str("locale");
|
|
@@ -575,7 +550,7 @@ function buildBody10(ctx) {
|
|
|
575
550
|
var kbGrep = {
|
|
576
551
|
service: "kb",
|
|
577
552
|
command: "+grep",
|
|
578
|
-
description: "Keyword-search knowledge base pages via POST /agent/api/external/knowledge-bases/grep. Returns matched lines with path, line number, breadcrumb and
|
|
553
|
+
description: "Keyword-search knowledge base pages via POST /agent/api/external/knowledge-bases/grep. Returns matched lines with path, line number, breadcrumb, context snippet, and the section line range (sectionStartLine/sectionEndLine) of each hit. Copy --paths from +index (wiki pages or subdirectories). Use +read with the hit range to open the section.",
|
|
579
554
|
flags: [
|
|
580
555
|
{
|
|
581
556
|
name: "query",
|
|
@@ -587,24 +562,30 @@ var kbGrep = {
|
|
|
587
562
|
{
|
|
588
563
|
name: "sources",
|
|
589
564
|
type: "json",
|
|
590
|
-
required:
|
|
591
|
-
desc: '
|
|
565
|
+
required: true,
|
|
566
|
+
desc: 'JSON array of knowledge base refs, e.g. [{"scope":"company","name":"engineering-handbook"}]'
|
|
592
567
|
},
|
|
593
|
-
{
|
|
568
|
+
{
|
|
569
|
+
name: "paths",
|
|
570
|
+
type: "json",
|
|
571
|
+
required: true,
|
|
572
|
+
desc: 'JSON array of wiki pages or subdirectories copied from +index, e.g. ["wiki/sandbox.md"] or ["wiki/guides"]'
|
|
573
|
+
},
|
|
574
|
+
{ name: "top-k", type: "number", required: false, desc: "Max number of hits to return (1-50, default 10)" },
|
|
594
575
|
{ name: "locale", type: "string", required: false, desc: "Optional locale: zh | en | ja | ko" }
|
|
595
576
|
],
|
|
596
577
|
risk: "read",
|
|
597
578
|
dryRun: (ctx) => ({
|
|
598
579
|
method: "POST",
|
|
599
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
600
|
-
body:
|
|
580
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH10}`,
|
|
581
|
+
body: buildBody9(ctx)
|
|
601
582
|
}),
|
|
602
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
583
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH10, {}, buildBody9(ctx))
|
|
603
584
|
};
|
|
604
585
|
|
|
605
586
|
// src/commands/te-kb/kb-read.ts
|
|
606
|
-
var
|
|
607
|
-
function
|
|
587
|
+
var API_PATH11 = "/agent/api/external/knowledge-bases/read";
|
|
588
|
+
function buildBody10(ctx) {
|
|
608
589
|
const body = {
|
|
609
590
|
source: ctx.json("source"),
|
|
610
591
|
path: ctx.str("path")
|
|
@@ -613,6 +594,7 @@ function buildBody11(ctx) {
|
|
|
613
594
|
if (offset) body.offset = offset;
|
|
614
595
|
const limit = ctx.num("limit");
|
|
615
596
|
if (limit) body.limit = limit;
|
|
597
|
+
if (ctx.bool("outline")) body.outline = true;
|
|
616
598
|
const locale = ctx.str("locale");
|
|
617
599
|
if (locale) body.locale = locale;
|
|
618
600
|
return body;
|
|
@@ -620,7 +602,7 @@ function buildBody11(ctx) {
|
|
|
620
602
|
var kbRead = {
|
|
621
603
|
service: "kb",
|
|
622
604
|
command: "+read",
|
|
623
|
-
description: "Read a full knowledge base page (or a line window) via POST /agent/api/external/knowledge-bases/read. Use after +index / +grep locate a candidate page.",
|
|
605
|
+
description: "Read a full knowledge base page (or a line window) via POST /agent/api/external/knowledge-bases/read. Use after +index / +grep locate a candidate page. Pass --outline to get only the page heading tree (no content) and pick a section to read.",
|
|
624
606
|
flags: [
|
|
625
607
|
{
|
|
626
608
|
name: "source",
|
|
@@ -636,19 +618,90 @@ var kbRead = {
|
|
|
636
618
|
},
|
|
637
619
|
{ name: "offset", type: "number", required: false, desc: "Start line (1-based). Omit to read from the beginning." },
|
|
638
620
|
{ name: "limit", type: "number", required: false, desc: "Max number of lines to return (1-10000)." },
|
|
621
|
+
{
|
|
622
|
+
name: "outline",
|
|
623
|
+
type: "boolean",
|
|
624
|
+
required: false,
|
|
625
|
+
desc: "Return only the page outline (headings with line numbers), no content. Use it to decide which section to read on long pages."
|
|
626
|
+
},
|
|
639
627
|
{ name: "locale", type: "string", required: false, desc: "Optional locale: zh | en | ja | ko" }
|
|
640
628
|
],
|
|
641
629
|
risk: "read",
|
|
642
630
|
dryRun: (ctx) => ({
|
|
643
631
|
method: "POST",
|
|
644
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
645
|
-
body:
|
|
632
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH11}`,
|
|
633
|
+
body: buildBody10(ctx)
|
|
646
634
|
}),
|
|
647
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
635
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH11, {}, buildBody10(ctx))
|
|
648
636
|
};
|
|
649
637
|
|
|
638
|
+
// src/commands/te-kb/ask-shared.ts
|
|
639
|
+
var ASK_API_PATH = "/agent/api/external/knowledge-bases/ask";
|
|
640
|
+
var ASK_POLL_INTERVAL_MS = 5e3;
|
|
641
|
+
var ASK_POLL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
642
|
+
var ASK_MAX_TRANSIENT_POLL_FAILURES = 3;
|
|
643
|
+
function isTransientAskPollError(error) {
|
|
644
|
+
if (error instanceof PermissionError) return false;
|
|
645
|
+
if (error instanceof TypeError) return true;
|
|
646
|
+
if (!(error instanceof Error)) return false;
|
|
647
|
+
if (/KB MCP token auth failed|unauthorized|Invalid access token/i.test(error.message)) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
return /fetch|network|socket|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|timeout/i.test(
|
|
651
|
+
error.message
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
async function pollUntilSettled(getStatus, executionId, options = {}) {
|
|
655
|
+
const intervalMs = options.intervalMs ?? ASK_POLL_INTERVAL_MS;
|
|
656
|
+
const timeoutMs = options.timeoutMs ?? ASK_POLL_TIMEOUT_MS;
|
|
657
|
+
const maxTransientFailures = options.maxTransientFailures ?? ASK_MAX_TRANSIENT_POLL_FAILURES;
|
|
658
|
+
const now = options.now ?? Date.now;
|
|
659
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
|
|
660
|
+
const startTime = now();
|
|
661
|
+
let transientFailures = 0;
|
|
662
|
+
while (true) {
|
|
663
|
+
const elapsed = now() - startTime;
|
|
664
|
+
if (elapsed > timeoutMs) {
|
|
665
|
+
throw new Error(
|
|
666
|
+
`Ask execution timeout after ${Math.floor(elapsed / 1e3)} seconds (executionId: ${executionId})`
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
let response;
|
|
670
|
+
try {
|
|
671
|
+
response = await getStatus(executionId);
|
|
672
|
+
transientFailures = 0;
|
|
673
|
+
} catch (err) {
|
|
674
|
+
if (!isTransientAskPollError(err) || ++transientFailures >= maxTransientFailures) {
|
|
675
|
+
throw err;
|
|
676
|
+
}
|
|
677
|
+
await sleep(intervalMs);
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
if (response.status !== "running") {
|
|
681
|
+
return response;
|
|
682
|
+
}
|
|
683
|
+
await sleep(intervalMs);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
function transformCompletedResponse(response) {
|
|
687
|
+
const result = {
|
|
688
|
+
executionId: response.executionId,
|
|
689
|
+
answer: response.answer ?? "",
|
|
690
|
+
sources: response.sources ?? []
|
|
691
|
+
};
|
|
692
|
+
if (response.modelId !== void 0) result.modelId = response.modelId;
|
|
693
|
+
if (response.modelUsage !== void 0) result.modelUsage = response.modelUsage;
|
|
694
|
+
if (response.toolCallCount !== void 0) result.toolCallCount = response.toolCallCount;
|
|
695
|
+
if (response.maxTurns !== void 0) result.maxTurns = response.maxTurns;
|
|
696
|
+
return result;
|
|
697
|
+
}
|
|
698
|
+
function buildFailedMessage(response) {
|
|
699
|
+
const type = response.error?.type || "unknown";
|
|
700
|
+
const message = response.error?.message || "Ask execution failed";
|
|
701
|
+
return `[${type}] ${message} (executionId: ${response.executionId})`;
|
|
702
|
+
}
|
|
703
|
+
|
|
650
704
|
// src/commands/te-kb/ask.ts
|
|
651
|
-
var API_PATH13 = "/agent/api/external/knowledge-bases/ask";
|
|
652
705
|
var VALID_LOCALES = /* @__PURE__ */ new Set(["zh", "en", "ja", "ko"]);
|
|
653
706
|
var MIN_QUESTION_LEN = 1;
|
|
654
707
|
var MAX_QUESTION_LEN = 2e3;
|
|
@@ -674,7 +727,7 @@ function validateMaxTurns(maxTurns) {
|
|
|
674
727
|
);
|
|
675
728
|
}
|
|
676
729
|
}
|
|
677
|
-
function
|
|
730
|
+
function buildBody11(ctx) {
|
|
678
731
|
const body = {
|
|
679
732
|
question: ctx.str("question")
|
|
680
733
|
};
|
|
@@ -691,7 +744,7 @@ function buildBody12(ctx) {
|
|
|
691
744
|
var ask = {
|
|
692
745
|
service: "kb",
|
|
693
746
|
command: "+ask",
|
|
694
|
-
description: "Ask knowledge bases via LLM-powered retrieval (POST /agent/api/external/knowledge-bases/ask). Consumes platform tokens. Prefer +index -> +grep -> +read for deterministic, token-free lookup.",
|
|
747
|
+
description: "Ask knowledge bases via LLM-powered retrieval (POST /agent/api/external/knowledge-bases/ask). Consumes platform tokens. Prefer +index -> +grep -> +read for deterministic, token-free lookup. By default, polls for completion; use --no-wait to return immediately with executionId.",
|
|
695
748
|
flags: [
|
|
696
749
|
{
|
|
697
750
|
name: "question",
|
|
@@ -718,7 +771,13 @@ var ask = {
|
|
|
718
771
|
required: false,
|
|
719
772
|
desc: "Optional agent turn limit (1-100, default 50 on server when omitted)."
|
|
720
773
|
},
|
|
721
|
-
{ name: "locale", type: "string", required: false, desc: "Optional locale: zh | en | ja | ko" }
|
|
774
|
+
{ name: "locale", type: "string", required: false, desc: "Optional locale: zh | en | ja | ko" },
|
|
775
|
+
{
|
|
776
|
+
name: "no-wait",
|
|
777
|
+
type: "boolean",
|
|
778
|
+
required: false,
|
|
779
|
+
desc: "Return immediately after submission with executionId, without polling for completion."
|
|
780
|
+
}
|
|
722
781
|
],
|
|
723
782
|
risk: "read",
|
|
724
783
|
validate: (ctx) => {
|
|
@@ -728,20 +787,85 @@ var ask = {
|
|
|
728
787
|
},
|
|
729
788
|
dryRun: (ctx) => ({
|
|
730
789
|
method: "POST",
|
|
731
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
732
|
-
body:
|
|
790
|
+
url: `${ctx.host().replace(/\/$/, "")}${ASK_API_PATH}`,
|
|
791
|
+
body: buildBody11(ctx)
|
|
792
|
+
}),
|
|
793
|
+
execute: async (ctx) => {
|
|
794
|
+
const noWait = ctx.bool("no-wait");
|
|
795
|
+
const submitResponse = await kbApi(ctx, "POST", ASK_API_PATH, {}, buildBody11(ctx));
|
|
796
|
+
if (!submitResponse.executionId) {
|
|
797
|
+
throw new Error("Invalid submit response: missing executionId");
|
|
798
|
+
}
|
|
799
|
+
const executionId = submitResponse.executionId;
|
|
800
|
+
if (noWait) {
|
|
801
|
+
return {
|
|
802
|
+
executionId,
|
|
803
|
+
status: submitResponse.status
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
const finalResponse = await pollUntilSettled(
|
|
807
|
+
(id) => kbApi(ctx, "GET", ASK_API_PATH, { executionId: id }),
|
|
808
|
+
executionId
|
|
809
|
+
);
|
|
810
|
+
if (finalResponse.status === "completed") {
|
|
811
|
+
return transformCompletedResponse(finalResponse);
|
|
812
|
+
}
|
|
813
|
+
if (finalResponse.status === "failed") {
|
|
814
|
+
throw new Error(buildFailedMessage(finalResponse));
|
|
815
|
+
}
|
|
816
|
+
throw new Error(`Unexpected execution status: ${finalResponse.status}`);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
// src/commands/te-kb/ask-status.ts
|
|
821
|
+
var MAX_EXECUTION_ID_LEN = 64;
|
|
822
|
+
function executionIdFrom(ctx) {
|
|
823
|
+
return ctx.str("execution-id").trim();
|
|
824
|
+
}
|
|
825
|
+
var askStatus = {
|
|
826
|
+
service: "kb",
|
|
827
|
+
command: "+ask-status",
|
|
828
|
+
description: "Query the status of an in-progress or completed knowledge base ask execution (GET /agent/api/external/knowledge-bases/ask?executionId=<id>). Does not poll; returns the current state.",
|
|
829
|
+
flags: [
|
|
830
|
+
{
|
|
831
|
+
name: "execution-id",
|
|
832
|
+
type: "string",
|
|
833
|
+
required: true,
|
|
834
|
+
minLength: 1,
|
|
835
|
+
maxLength: MAX_EXECUTION_ID_LEN,
|
|
836
|
+
desc: "The execution ID returned by kb +ask submission."
|
|
837
|
+
}
|
|
838
|
+
],
|
|
839
|
+
risk: "read",
|
|
840
|
+
validate: (ctx) => {
|
|
841
|
+
const executionId = executionIdFrom(ctx);
|
|
842
|
+
if (!executionId) {
|
|
843
|
+
throw new Error("Invalid --execution-id: must be non-empty.");
|
|
844
|
+
}
|
|
845
|
+
if (executionId.length > MAX_EXECUTION_ID_LEN) {
|
|
846
|
+
throw new Error(
|
|
847
|
+
`Invalid --execution-id length: ${executionId.length}. Must be at most ${MAX_EXECUTION_ID_LEN} characters.`
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
dryRun: (ctx) => ({
|
|
852
|
+
method: "GET",
|
|
853
|
+
url: `${ctx.host().replace(/\/$/, "")}${ASK_API_PATH}?executionId=${encodeURIComponent(executionIdFrom(ctx))}`
|
|
733
854
|
}),
|
|
734
|
-
execute: async (ctx) =>
|
|
855
|
+
execute: async (ctx) => {
|
|
856
|
+
const executionId = executionIdFrom(ctx);
|
|
857
|
+
return await kbApi(ctx, "GET", ASK_API_PATH, { executionId });
|
|
858
|
+
}
|
|
735
859
|
};
|
|
736
860
|
|
|
737
861
|
// src/commands/te-kb/url.ts
|
|
738
|
-
var
|
|
862
|
+
var API_PATH12 = "/agent/api/external/knowledge-bases/sources/url";
|
|
739
863
|
function validateUrl(url2) {
|
|
740
864
|
if (!/^https?:\/\//i.test(url2)) {
|
|
741
865
|
throw new Error(`Invalid --url: ${url2}. Must be an http(s) URL`);
|
|
742
866
|
}
|
|
743
867
|
}
|
|
744
|
-
function
|
|
868
|
+
function buildBody12(ctx) {
|
|
745
869
|
const body = {
|
|
746
870
|
name: ctx.str("name"),
|
|
747
871
|
url: ctx.str("url")
|
|
@@ -768,16 +892,16 @@ var url = {
|
|
|
768
892
|
},
|
|
769
893
|
dryRun: (ctx) => ({
|
|
770
894
|
method: "POST",
|
|
771
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
772
|
-
body:
|
|
895
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH12}`,
|
|
896
|
+
body: buildBody12(ctx)
|
|
773
897
|
}),
|
|
774
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
898
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH12, {}, buildBody12(ctx))
|
|
775
899
|
};
|
|
776
900
|
|
|
777
901
|
// src/commands/te-kb/index.ts
|
|
778
902
|
var commands = [
|
|
779
|
-
query,
|
|
780
903
|
ask,
|
|
904
|
+
askStatus,
|
|
781
905
|
add,
|
|
782
906
|
url,
|
|
783
907
|
compile,
|
|
@@ -795,6 +919,7 @@ var te_kb_default = commands;
|
|
|
795
919
|
export {
|
|
796
920
|
add,
|
|
797
921
|
ask,
|
|
922
|
+
askStatus,
|
|
798
923
|
compile,
|
|
799
924
|
create,
|
|
800
925
|
te_kb_default as default,
|
|
@@ -802,7 +927,6 @@ export {
|
|
|
802
927
|
kbIndex,
|
|
803
928
|
kbList,
|
|
804
929
|
kbRead,
|
|
805
|
-
query,
|
|
806
930
|
remove,
|
|
807
931
|
rmSource,
|
|
808
932
|
schema,
|
|
@@ -7,14 +7,17 @@ import {
|
|
|
7
7
|
putToMainApp,
|
|
8
8
|
tryLoadTeAgentSandboxCredentials,
|
|
9
9
|
uploadToMainApp
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UOUS37JQ.js";
|
|
11
|
+
import "./chunk-C4MGVGJW.js";
|
|
12
|
+
import "./chunk-4SGZG4XY.js";
|
|
11
13
|
import {
|
|
12
14
|
safeJsonParse
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ZZUOD757.js";
|
|
14
16
|
import {
|
|
15
17
|
CliValidationError
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-UW5UN47B.js";
|
|
19
|
+
import "./chunk-LYVNONC4.js";
|
|
20
|
+
import "./chunk-QGM4M3NI.js";
|
|
18
21
|
|
|
19
22
|
// src/commands/te-system/shared.ts
|
|
20
23
|
import { readFileSync } from "fs";
|