@thinkingai/ae-cli 6.1.17 → 6.1.19

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.
Files changed (126) hide show
  1. package/README.md +2 -0
  2. package/README.zh.md +6 -0
  3. package/dist/{auth-77BUFLGC.js → auth-QPEVVBKT.js} +20 -15
  4. package/dist/auth-UMJAA72O.js +15 -0
  5. package/dist/{capability-72DTW5M2.js → capability-ASI62I4A.js} +53 -15
  6. package/dist/{chunk-UW5UN47B.js → chunk-533JK3YX.js} +2 -0
  7. package/dist/{chunk-UOUS37JQ.js → chunk-6QK7SYYY.js} +5 -4
  8. package/dist/{chunk-TUKQZTMI.js → chunk-7K24F7T2.js} +2 -0
  9. package/dist/{chunk-OO6XR6LK.js → chunk-AMBFK2K3.js} +2 -0
  10. package/dist/{sync-DAVKYVMW.js → chunk-B5HMQAOM.js} +31 -540
  11. package/dist/{chunk-VR3LCBHW.js → chunk-DKEXH6Q5.js} +6 -5
  12. package/dist/{chunk-VTWMIC5L.js → chunk-E2JKXMVO.js} +2 -0
  13. package/dist/{chunk-LYVNONC4.js → chunk-FR2EDAQM.js} +36 -0
  14. package/dist/{chunk-ILIU36SU.js → chunk-GJXRF7Y6.js} +6 -5
  15. package/dist/{chunk-DWO43OIB.js → chunk-JQ3ENZZH.js} +2 -0
  16. package/dist/chunk-JYMGHGCE.js +191 -0
  17. package/dist/{chunk-GT46FPXN.js → chunk-KEWVSO64.js} +18 -8
  18. package/dist/chunk-KZ6ZHF5J.js +294 -0
  19. package/dist/chunk-O6K2ODUE.js +318 -0
  20. package/dist/chunk-QL6R6TSK.js +25215 -0
  21. package/dist/{chunk-4SGZG4XY.js → chunk-RWXIXOZG.js} +28 -13
  22. package/dist/{chunk-YA6SMTXG.js → chunk-S5PONFBM.js} +5 -4
  23. package/dist/{chunk-4NN5IWVN.js → chunk-T6OSFQZD.js} +2 -0
  24. package/dist/{chunk-PTE56QPL.js → chunk-TKHSULJT.js} +6 -0
  25. package/dist/{chunk-6EIJSNBD.js → chunk-Y74WTIKJ.js} +2 -0
  26. package/dist/{client-TKG4WBHN.js → client-N7NGZUNI.js} +6 -4
  27. package/dist/{community-report-client-FI4LNVYS.js → community-report-client-6OL6GBQW.js} +3 -3
  28. package/dist/{config-RE6CMGPK.js → config-XNMACCKX.js} +10 -8
  29. package/dist/{data-integration-XQYB4X4F.js → data-integration-4NZGZ45E.js} +2502 -272
  30. package/dist/index.js +137 -1245
  31. package/dist/{local-data-upload-client-BWHSUQQK.js → local-data-upload-client-EFHDLXFG.js} +3 -3
  32. package/dist/{memory-YK33G4T7.js → memory-HBJQ2GC5.js} +8 -7
  33. package/dist/{metadata-UILXHBWF.js → metadata-62EWBEIG.js} +12 -11
  34. package/dist/{model-NR3JHFSJ.js → model-BHLJ2QMT.js} +10 -9
  35. package/dist/personal-semantic-preference-JBVMAI7L.js +240 -0
  36. package/dist/project-semantic-BQ4MPUS5.js +1115 -0
  37. package/dist/sync-MUWPRM5I.js +522 -0
  38. package/dist/{te-agent-4BKBODMF.js → te-agent-WQZTMEK4.js} +12 -10
  39. package/dist/{te-analysis-O6DCO6BS.js → te-analysis-MNCG65LU.js} +534 -48
  40. package/dist/{te-community-HLC43QKH.js → te-community-BNE6KREL.js} +8 -7
  41. package/dist/{te-dataops-EJP56W3K.js → te-dataops-TXLKM2W6.js} +469 -68
  42. package/dist/{te-engage-FGBGQ4IY.js → te-engage-TPKLRVTL.js} +84 -10
  43. package/dist/{te-experiment-SO5MPDMJ.js → te-experiment-6BYKTCY7.js} +303 -12
  44. package/dist/{te-kb-SQCLHG6X.js → te-kb-BUD6N3NI.js} +312 -25
  45. package/dist/{te-system-YARIK4S5.js → te-system-44LZJDTQ.js} +573 -37
  46. package/dist/{te-team-EFKWYKMK.js → te-team-XMP47YXE.js} +10 -7
  47. package/dist/{update-OGPSZM5A.js → update-UODFOZ4P.js} +9 -7
  48. package/package.json +18 -9
  49. package/skills/ae-agent/SKILL.md +3 -4
  50. package/skills/ae-agent/references/edit-skill.md +3 -0
  51. package/skills/ae-agent/references/get-skill-content.md +1 -1
  52. package/skills/ae-agent/references/rescan-skills.md +15 -13
  53. package/skills/ae-agent/references/upload-skill.md +7 -4
  54. package/skills/ae-analysis/SKILL.md +45 -4
  55. package/skills/ae-analysis/metadata_resolution.md +38 -4
  56. package/skills/ae-analysis/references/analysis_data_retrieval.md +29 -0
  57. package/skills/ae-analysis/references/analysis_gateway_assets.md +1 -1
  58. package/skills/ae-analysis/references/asset_authentication_export.md +22 -0
  59. package/skills/ae-analysis/references/asset_authentication_list.md +18 -14
  60. package/skills/ae-analysis/references/asset_authentication_update.md +29 -14
  61. package/skills/ae-analysis/references/audience_models.md +18 -0
  62. package/skills/ae-analysis/references/command_index.md +19 -11
  63. package/skills/ae-analysis/references/dashboard_get.md +18 -1
  64. package/skills/ae-analysis/references/dashboard_update.md +3 -0
  65. package/skills/ae-analysis/references/personal_semantic_preference_add.md +23 -0
  66. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +17 -0
  67. package/skills/ae-analysis/references/personal_semantic_preference_get.md +19 -0
  68. package/skills/ae-analysis/references/personal_semantic_preference_list.md +21 -0
  69. package/skills/ae-analysis/references/personal_semantic_preference_update.md +19 -0
  70. package/skills/ae-analysis/references/project_timezone_update.md +13 -4
  71. package/skills/ae-analysis/references/property_create.md +2 -0
  72. package/skills/ae-analysis/references/super_metadata_batch_create.md +2 -0
  73. package/skills/ae-analysis/references/user_cluster_models.md +2 -0
  74. package/skills/ae-analysis/references/user_cluster_update.md +8 -4
  75. package/skills/ae-analysis/references/user_tag_create.md +7 -1
  76. package/skills/ae-analysis/references/user_tag_models.md +8 -2
  77. package/skills/ae-data-integration/SKILL.md +24 -4
  78. package/skills/ae-data-integration/references/custom-layer.md +93 -0
  79. package/skills/ae-data-integration/references/error-handling.md +145 -0
  80. package/skills/ae-data-integration/references/handoff.md +77 -18
  81. package/skills/ae-data-integration/references/local-analysis.md +1 -1
  82. package/skills/ae-data-integration/references/reuse.md +9 -5
  83. package/skills/ae-data-integration/references/sink-upload.md +1 -1
  84. package/skills/ae-data-integration/references/source-inspect.md +35 -13
  85. package/skills/ae-data-integration/references/tracking-plan.md +7 -5
  86. package/skills/ae-data-integration/references/transform.md +12 -10
  87. package/skills/ae-data-integration/references/ue-mapping.md +33 -11
  88. package/skills/ae-data-integration/references/ue-routing.md +23 -0
  89. package/skills/ae-dataops/SKILL.md +11 -1
  90. package/skills/ae-dataops/references/dataops-backfill.md +135 -0
  91. package/skills/ae-engage/SKILL.md +5 -0
  92. package/skills/ae-engage/references/build-task-save-guide.md +14 -1
  93. package/skills/ae-engage/references/save-flow.md +37 -1
  94. package/skills/ae-engage/references/save-task.md +88 -0
  95. package/skills/ae-experiment/SKILL.md +14 -4
  96. package/skills/ae-experiment/references/manage_feature_whitelist.md +66 -0
  97. package/skills/ae-experiment/references/manage_guardrail_metrics.md +26 -0
  98. package/skills/ae-experiment/references/save_experiment.md +1 -1
  99. package/skills/ae-experiment/references/save_metric.md +20 -8
  100. package/skills/ae-kb/SKILL.md +121 -10
  101. package/skills/ae-project-semantic/SKILL.md +193 -0
  102. package/skills/ae-project-semantic/references/query-routing-v5.md +165 -0
  103. package/skills/ae-project-semantic/references/recommendation-quality.md +68 -0
  104. package/skills/ae-system/SKILL.md +28 -30
  105. package/skills/ae-system/references/channel-management.md +303 -0
  106. package/dist/auth-2WTQOP77.js +0 -14
  107. package/dist/capability-PJHNI4GJ.js +0 -315
  108. package/dist/chunk-4KVPKXFX.js +0 -98
  109. package/dist/chunk-C4MGVGJW.js +0 -13
  110. package/dist/chunk-P3FGXJTU.js +0 -349
  111. package/dist/chunk-QGM4M3NI.js +0 -37
  112. package/dist/chunk-RGKJGKT7.js +0 -71
  113. package/dist/chunk-SAU3QFIQ.js +0 -556
  114. package/dist/chunk-VPKZ7I72.js +0 -509
  115. package/dist/chunk-ZZUOD757.js +0 -598
  116. package/dist/memory-CHRU2F7W.js +0 -893
  117. package/dist/metadata-XXR34N5P.js +0 -339
  118. package/dist/model-K3KLWIW6.js +0 -139
  119. package/dist/sync-FCKOVWWS.js +0 -10261
  120. package/dist/te-agent-HLW4VTQK.js +0 -3893
  121. package/dist/te-analysis-ZMNGOVNW.js +0 -8958
  122. package/dist/te-community-6HPBWJUZ.js +0 -1859
  123. package/dist/te-dataops-HDRUXY4K.js +0 -2208
  124. package/dist/te-engage-RAK5PESW.js +0 -4898
  125. package/dist/te-experiment-VZF7BT6G.js +0 -770
  126. package/dist/te-system-Z77IKZFN.js +0 -2213
@@ -1,17 +1,23 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
1
2
  import {
2
3
  kbApi,
3
4
  kbUpload
4
- } from "./chunk-4KVPKXFX.js";
5
+ } from "./chunk-JYMGHGCE.js";
5
6
  import {
6
7
  printError
7
- } from "./chunk-GT46FPXN.js";
8
- import "./chunk-4SGZG4XY.js";
9
- import "./chunk-ZZUOD757.js";
8
+ } from "./chunk-KEWVSO64.js";
10
9
  import {
10
+ CapabilityGatewayError
11
+ } from "./chunk-GJXRF7Y6.js";
12
+ import "./chunk-Y74WTIKJ.js";
13
+ import "./chunk-RWXIXOZG.js";
14
+ import "./chunk-O6K2ODUE.js";
15
+ import "./chunk-KZ6ZHF5J.js";
16
+ import {
17
+ CliValidationError,
11
18
  PermissionError
12
- } from "./chunk-UW5UN47B.js";
13
- import "./chunk-LYVNONC4.js";
14
- import "./chunk-QGM4M3NI.js";
19
+ } from "./chunk-533JK3YX.js";
20
+ import "./chunk-FR2EDAQM.js";
15
21
 
16
22
  // src/commands/te-kb/add.ts
17
23
  import { promises as fs } from "fs";
@@ -375,27 +381,41 @@ var create = {
375
381
 
376
382
  // src/commands/te-kb/rm-source.ts
377
383
  var API_PATH5 = "/agent/api/external/knowledge-bases/sources";
384
+ function sourceSelector(ctx) {
385
+ const id = ctx.str("id").trim();
386
+ if (id) return { id };
387
+ const displayName = ctx.str("display-name").trim();
388
+ if (displayName) return { displayName };
389
+ throw new CliValidationError("One of --id or --display-name is required.");
390
+ }
378
391
  function buildBody4(ctx) {
379
392
  return {
380
393
  name: ctx.str("name"),
381
- displayName: ctx.str("display-name")
394
+ ...sourceSelector(ctx)
382
395
  };
383
396
  }
384
397
  var rmSource = {
385
398
  service: "kb",
386
399
  command: "+rm-source",
387
- description: "Delete a single source file inside a knowledge.",
400
+ description: "Delete one source from a knowledge base by ID or exact display name.",
388
401
  flags: [
389
402
  { name: "name", type: "string", required: true, desc: "Knowledge base name (looked up personal \u2192 company)" },
390
- { name: "display-name", type: "string", required: true, desc: "Source file display name as uploaded (e.g. kb-1780046712-foo.md)" }
403
+ { name: "id", type: "string", required: false, desc: "Source ID copied from +list-sources (preferred)" },
404
+ { name: "display-name", type: "string", required: false, desc: "Exact source display name for legacy compatibility" }
391
405
  ],
392
- risk: "write",
406
+ risk: "high-risk-write",
407
+ validate: (ctx) => {
408
+ sourceSelector(ctx);
409
+ },
393
410
  dryRun: (ctx) => ({
394
411
  method: "DELETE",
395
412
  url: `${ctx.host().replace(/\/$/, "")}${API_PATH5}`,
396
413
  body: buildBody4(ctx)
397
414
  }),
398
- execute: async (ctx) => kbApi(ctx, "DELETE", API_PATH5, {}, buildBody4(ctx))
415
+ execute: async (ctx) => kbApi(ctx, "DELETE", API_PATH5, {}, buildBody4(ctx), {
416
+ preserveErrorMetadata: true,
417
+ retryUnauthorized: true
418
+ })
399
419
  };
400
420
 
401
421
  // src/commands/te-kb/schema.ts
@@ -407,8 +427,15 @@ function buildBody5(ctx) {
407
427
  if (ctx.bool("force")) body.force = true;
408
428
  const model = ctx.str("model");
409
429
  if (model) body.model = model;
430
+ const customInstructions = ctx.str("custom-instructions");
431
+ if (customInstructions) body.customInstructions = customInstructions;
410
432
  return body;
411
433
  }
434
+ async function executeSchema(ctx, api = kbApi) {
435
+ return api(ctx, "POST", API_PATH6, {}, buildBody5(ctx), {
436
+ preserveBusinessErrorCode: true
437
+ });
438
+ }
412
439
  var schema = {
413
440
  service: "kb",
414
441
  command: "+schema",
@@ -416,7 +443,14 @@ var schema = {
416
443
  flags: [
417
444
  { name: "name", type: "string", required: true, desc: "Knowledge base name (looked up personal \u2192 company)" },
418
445
  { name: "force", type: "boolean", required: false, desc: "Preempt generation even when status is `generating` (use only for stuck recovery)" },
419
- { name: "model", type: "string", required: false, desc: "Optional model displayName to use for schema generation" }
446
+ { name: "model", type: "string", required: false, desc: "Optional model displayName to use for schema generation" },
447
+ {
448
+ name: "custom-instructions",
449
+ type: "string",
450
+ required: false,
451
+ sensitive: true,
452
+ desc: "Optional per-run instructions for generating this knowledge base schema"
453
+ }
420
454
  ],
421
455
  risk: "write",
422
456
  dryRun: (ctx) => ({
@@ -424,7 +458,7 @@ var schema = {
424
458
  url: `${ctx.host().replace(/\/$/, "")}${API_PATH6}`,
425
459
  body: buildBody5(ctx)
426
460
  }),
427
- execute: async (ctx) => kbApi(ctx, "POST", API_PATH6, {}, buildBody5(ctx))
461
+ execute: executeSchema
428
462
  };
429
463
 
430
464
  // src/commands/te-kb/status.ts
@@ -533,8 +567,59 @@ var kbList = {
533
567
  execute: async (ctx) => kbApi(ctx, "POST", API_PATH9, {}, buildBody8(ctx))
534
568
  };
535
569
 
570
+ // src/commands/te-kb/list-sources.ts
571
+ var API_PATH10 = "/agent/api/external/knowledge-bases/sources";
572
+ var MAX_KNOWLEDGE_BASE_NAME_LENGTH = 200;
573
+ function knowledgeBaseName(ctx) {
574
+ return ctx.str("name").trim();
575
+ }
576
+ function buildUrl(ctx) {
577
+ const url2 = new URL(`${ctx.host().replace(/\/$/, "")}${API_PATH10}`);
578
+ url2.searchParams.set("name", knowledgeBaseName(ctx));
579
+ return url2.toString();
580
+ }
581
+ var listSources = {
582
+ service: "kb",
583
+ command: "+list-sources",
584
+ description: "List source metadata for a knowledge base via GET /agent/api/external/knowledge-bases/sources?name=<name>. Copy the stable source ID from this output before using +rm-source.",
585
+ flags: [
586
+ {
587
+ name: "name",
588
+ type: "string",
589
+ required: true,
590
+ minLength: 1,
591
+ maxLength: MAX_KNOWLEDGE_BASE_NAME_LENGTH,
592
+ desc: "Knowledge base name"
593
+ }
594
+ ],
595
+ risk: "read",
596
+ validate: (ctx) => {
597
+ const name = knowledgeBaseName(ctx);
598
+ if (!name) {
599
+ throw new CliValidationError("Invalid --name: must be non-empty.");
600
+ }
601
+ if (name.length > MAX_KNOWLEDGE_BASE_NAME_LENGTH) {
602
+ throw new CliValidationError(
603
+ `Invalid --name length: ${name.length}. Must be at most ${MAX_KNOWLEDGE_BASE_NAME_LENGTH} characters.`
604
+ );
605
+ }
606
+ },
607
+ dryRun: (ctx) => ({
608
+ method: "GET",
609
+ url: buildUrl(ctx)
610
+ }),
611
+ execute: async (ctx) => kbApi(
612
+ ctx,
613
+ "GET",
614
+ API_PATH10,
615
+ { name: knowledgeBaseName(ctx) },
616
+ void 0,
617
+ { preserveErrorMetadata: true, retryUnauthorized: true }
618
+ )
619
+ };
620
+
536
621
  // src/commands/te-kb/kb-grep.ts
537
- var API_PATH10 = "/agent/api/external/knowledge-bases/grep";
622
+ var API_PATH11 = "/agent/api/external/knowledge-bases/grep";
538
623
  function buildBody9(ctx) {
539
624
  const body = {
540
625
  query: ctx.str("query"),
@@ -577,14 +662,14 @@ var kbGrep = {
577
662
  risk: "read",
578
663
  dryRun: (ctx) => ({
579
664
  method: "POST",
580
- url: `${ctx.host().replace(/\/$/, "")}${API_PATH10}`,
665
+ url: `${ctx.host().replace(/\/$/, "")}${API_PATH11}`,
581
666
  body: buildBody9(ctx)
582
667
  }),
583
- execute: async (ctx) => kbApi(ctx, "POST", API_PATH10, {}, buildBody9(ctx))
668
+ execute: async (ctx) => kbApi(ctx, "POST", API_PATH11, {}, buildBody9(ctx))
584
669
  };
585
670
 
586
671
  // src/commands/te-kb/kb-read.ts
587
- var API_PATH11 = "/agent/api/external/knowledge-bases/read";
672
+ var API_PATH12 = "/agent/api/external/knowledge-bases/read";
588
673
  function buildBody10(ctx) {
589
674
  const body = {
590
675
  source: ctx.json("source"),
@@ -629,10 +714,10 @@ var kbRead = {
629
714
  risk: "read",
630
715
  dryRun: (ctx) => ({
631
716
  method: "POST",
632
- url: `${ctx.host().replace(/\/$/, "")}${API_PATH11}`,
717
+ url: `${ctx.host().replace(/\/$/, "")}${API_PATH12}`,
633
718
  body: buildBody10(ctx)
634
719
  }),
635
- execute: async (ctx) => kbApi(ctx, "POST", API_PATH11, {}, buildBody10(ctx))
720
+ execute: async (ctx) => kbApi(ctx, "POST", API_PATH12, {}, buildBody10(ctx))
636
721
  };
637
722
 
638
723
  // src/commands/te-kb/ask-shared.ts
@@ -859,7 +944,7 @@ var askStatus = {
859
944
  };
860
945
 
861
946
  // src/commands/te-kb/url.ts
862
- var API_PATH12 = "/agent/api/external/knowledge-bases/sources/url";
947
+ var API_PATH13 = "/agent/api/external/knowledge-bases/sources/url";
863
948
  function validateUrl(url2) {
864
949
  if (!/^https?:\/\//i.test(url2)) {
865
950
  throw new Error(`Invalid --url: ${url2}. Must be an http(s) URL`);
@@ -884,7 +969,7 @@ var url = {
884
969
  { name: "name", type: "string", required: true, desc: "Knowledge base name" },
885
970
  { name: "url", type: "string", required: true, desc: "Source URL to upload" },
886
971
  { name: "display-name", type: "string", required: false, desc: "Optional display name for the URL source" },
887
- { name: "parse-instruction", type: "string", required: false, desc: "Optional parsing instruction for the URL source" }
972
+ { name: "parse-instruction", type: "string", required: false, desc: "Optional parsing instruction for the URL source; ignored for Lark/Feishu doc URLs (the server applies its own Feishu parsing)" }
888
973
  ],
889
974
  risk: "write",
890
975
  validate: (ctx) => {
@@ -892,10 +977,206 @@ var url = {
892
977
  },
893
978
  dryRun: (ctx) => ({
894
979
  method: "POST",
895
- url: `${ctx.host().replace(/\/$/, "")}${API_PATH12}`,
980
+ url: `${ctx.host().replace(/\/$/, "")}${API_PATH13}`,
896
981
  body: buildBody12(ctx)
897
982
  }),
898
- execute: async (ctx) => kbApi(ctx, "POST", API_PATH12, {}, buildBody12(ctx))
983
+ execute: async (ctx) => kbApi(ctx, "POST", API_PATH13, {}, buildBody12(ctx))
984
+ };
985
+
986
+ // src/commands/te-kb/import.ts
987
+ import { promises as fs2 } from "fs";
988
+ import path2 from "path";
989
+ var API_PATH14 = "/agent/api/external/knowledge-bases/import";
990
+ var MAX_SNAPSHOT_ARCHIVE_BYTES = 50 * 1024 * 1024;
991
+ function normalizeTags2(raw) {
992
+ if (raw === void 0 || raw === null) return [];
993
+ if (!Array.isArray(raw)) {
994
+ throw new Error(
995
+ `--tags must be a JSON array of strings, e.g. '["docs","product"]'`
996
+ );
997
+ }
998
+ const tags = [];
999
+ for (const value of raw) {
1000
+ if (typeof value !== "string") {
1001
+ throw new Error(
1002
+ `--tags entries must be strings (got: ${JSON.stringify(value)})`
1003
+ );
1004
+ }
1005
+ const tag = value.trim();
1006
+ if (tag && !tags.includes(tag)) tags.push(tag);
1007
+ }
1008
+ if (tags.length > 2) throw new Error("--tags accepts at most 2 unique tags");
1009
+ if (tags.some((tag) => tag.length > 15)) {
1010
+ throw new Error("--tags entries must be at most 15 characters");
1011
+ }
1012
+ return tags;
1013
+ }
1014
+ function validateArchivePath(filePath) {
1015
+ if (path2.extname(filePath).toLocaleLowerCase("en-US") !== ".zip") {
1016
+ throw new Error("--file must point to a .zip archive");
1017
+ }
1018
+ }
1019
+ async function readArchive(filePath) {
1020
+ validateArchivePath(filePath);
1021
+ const absolutePath = path2.resolve(filePath);
1022
+ let stat;
1023
+ try {
1024
+ stat = await fs2.stat(absolutePath);
1025
+ } catch {
1026
+ throw new Error(`File not found: ${filePath}`);
1027
+ }
1028
+ if (!stat.isFile())
1029
+ throw new Error(`--file must point to a file: ${filePath}`);
1030
+ if (stat.size === 0) throw new Error(`ZIP archive is empty: ${filePath}`);
1031
+ if (stat.size > MAX_SNAPSHOT_ARCHIVE_BYTES) {
1032
+ throw new Error("--file must not exceed 50 MB");
1033
+ }
1034
+ return { absolutePath, bytes: await fs2.readFile(absolutePath) };
1035
+ }
1036
+ function appendOptionalFields(ctx, form) {
1037
+ const description = ctx.str("description").trim();
1038
+ if (description) form.append("description", description);
1039
+ for (const tag of normalizeTags2(ctx.json("tags"))) form.append("tags", tag);
1040
+ const projectId = ctx.str("project-id").trim();
1041
+ if (projectId) form.append("projectId", projectId);
1042
+ }
1043
+ var importSnapshot = {
1044
+ service: "kb",
1045
+ command: "+import",
1046
+ description: "Import a compiled Markdown ZIP snapshot as a personal read-only knowledge base.",
1047
+ flags: [
1048
+ {
1049
+ name: "file",
1050
+ type: "string",
1051
+ required: true,
1052
+ desc: "Local .zip snapshot containing root index.md and wiki/**/*.md"
1053
+ },
1054
+ {
1055
+ name: "name",
1056
+ type: "string",
1057
+ required: true,
1058
+ maxLength: 30,
1059
+ desc: "Personal knowledge base name (max 30 characters)"
1060
+ },
1061
+ {
1062
+ name: "description",
1063
+ type: "string",
1064
+ required: false,
1065
+ maxLength: 200,
1066
+ desc: "Optional description (max 200 characters)"
1067
+ },
1068
+ {
1069
+ name: "tags",
1070
+ type: "json",
1071
+ required: false,
1072
+ desc: "Optional JSON array of tags (max 2, each max 15 characters)"
1073
+ },
1074
+ {
1075
+ name: "project-id",
1076
+ type: "string",
1077
+ required: false,
1078
+ maxLength: 128,
1079
+ desc: "Optional project ID to bind"
1080
+ }
1081
+ ],
1082
+ risk: "write",
1083
+ validate: (ctx) => {
1084
+ validateArchivePath(ctx.str("file"));
1085
+ normalizeTags2(ctx.json("tags"));
1086
+ },
1087
+ execute: async (ctx) => {
1088
+ const archive = await readArchive(ctx.str("file"));
1089
+ const form = new FormData();
1090
+ form.append(
1091
+ "file",
1092
+ new Blob([Uint8Array.from(archive.bytes)], { type: "application/zip" }),
1093
+ path2.basename(archive.absolutePath)
1094
+ );
1095
+ form.append("name", ctx.str("name").trim());
1096
+ appendOptionalFields(ctx, form);
1097
+ try {
1098
+ return await kbUpload(
1099
+ ctx,
1100
+ API_PATH14,
1101
+ form,
1102
+ {},
1103
+ { preserveErrorMetadata: true, retryUnauthorized: true }
1104
+ );
1105
+ } catch (error) {
1106
+ const hint = "If a requestId was returned, run ae-cli kb +import-status --request-id <requestId>; otherwise run ae-cli kb +list before retrying the same name.";
1107
+ if (error instanceof CapabilityGatewayError) {
1108
+ throw new CapabilityGatewayError(
1109
+ `${error.message} ${hint}`,
1110
+ error.code,
1111
+ error.httpStatus,
1112
+ error.hint ?? hint,
1113
+ error.meta
1114
+ );
1115
+ }
1116
+ if (error instanceof Error) {
1117
+ error.message = `${error.message} ${hint}`;
1118
+ throw error;
1119
+ }
1120
+ throw new Error(`${String(error)} ${hint}`);
1121
+ }
1122
+ }
1123
+ };
1124
+
1125
+ // src/commands/te-kb/import-status.ts
1126
+ var API_PATH15 = "/agent/api/external/knowledge-bases/import";
1127
+ var MAX_REQUEST_ID_LENGTH = 191;
1128
+ function requestIdFrom(ctx) {
1129
+ return ctx.str("request-id").trim();
1130
+ }
1131
+ var importStatus = {
1132
+ service: "kb",
1133
+ command: "+import-status",
1134
+ description: "Query one asynchronous knowledge-base snapshot import by its request ID without polling.",
1135
+ flags: [
1136
+ {
1137
+ name: "request-id",
1138
+ type: "string",
1139
+ required: true,
1140
+ minLength: 1,
1141
+ maxLength: MAX_REQUEST_ID_LENGTH,
1142
+ desc: "The requestId returned by kb +import."
1143
+ }
1144
+ ],
1145
+ risk: "read",
1146
+ validate: (ctx) => {
1147
+ const requestId = requestIdFrom(ctx);
1148
+ if (!requestId) throw new Error("Invalid --request-id: must be non-empty.");
1149
+ if (requestId.length > MAX_REQUEST_ID_LENGTH) {
1150
+ throw new Error(
1151
+ `Invalid --request-id length: ${requestId.length}. Must be at most ${MAX_REQUEST_ID_LENGTH} characters.`
1152
+ );
1153
+ }
1154
+ },
1155
+ dryRun: (ctx) => ({
1156
+ method: "GET",
1157
+ url: `${ctx.host().replace(/\/$/, "")}${API_PATH15}?requestId=${encodeURIComponent(requestIdFrom(ctx))}`
1158
+ }),
1159
+ execute: async (ctx) => {
1160
+ try {
1161
+ return await kbApi(
1162
+ ctx,
1163
+ "GET",
1164
+ API_PATH15,
1165
+ { requestId: requestIdFrom(ctx) },
1166
+ void 0,
1167
+ { preserveErrorMetadata: true, retryUnauthorized: true }
1168
+ );
1169
+ } catch (error) {
1170
+ if (!(error instanceof CapabilityGatewayError) || error.hint) throw error;
1171
+ throw new CapabilityGatewayError(
1172
+ error.message,
1173
+ error.code,
1174
+ error.httpStatus,
1175
+ "Verify the request ID and that the server supports kb +import-status. Do not retry the import until its status is known.",
1176
+ error.meta
1177
+ );
1178
+ }
1179
+ }
899
1180
  };
900
1181
 
901
1182
  // src/commands/te-kb/index.ts
@@ -907,13 +1188,16 @@ var commands = [
907
1188
  compile,
908
1189
  remove,
909
1190
  create,
1191
+ listSources,
910
1192
  rmSource,
911
1193
  schema,
912
1194
  status,
913
1195
  kbList,
914
1196
  kbIndex,
915
1197
  kbGrep,
916
- kbRead
1198
+ kbRead,
1199
+ importSnapshot,
1200
+ importStatus
917
1201
  ];
918
1202
  var te_kb_default = commands;
919
1203
  export {
@@ -923,10 +1207,13 @@ export {
923
1207
  compile,
924
1208
  create,
925
1209
  te_kb_default as default,
1210
+ importSnapshot,
1211
+ importStatus,
926
1212
  kbGrep,
927
1213
  kbIndex,
928
1214
  kbList,
929
1215
  kbRead,
1216
+ listSources,
930
1217
  remove,
931
1218
  rmSource,
932
1219
  schema,