@thinkingai/ae-cli 6.1.23 → 6.1.25

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 (142) hide show
  1. package/README.md +7 -1
  2. package/README.zh.md +7 -1
  3. package/dist/{auth-XZNXFRJS.js → auth-LHM7NQPR.js} +167 -7
  4. package/dist/{capability-FYTU3X6L.js → capability-SJI5KOCK.js} +11 -6
  5. package/dist/{chunk-CCS66K4K.js → chunk-2FJM4HRV.js} +3 -3
  6. package/dist/{chunk-57RRFUEZ.js → chunk-5XRQ3CZR.js} +4 -4
  7. package/dist/{chunk-EQ255HKO.js → chunk-7WZACOAI.js} +2 -2
  8. package/dist/{chunk-DX5CDO34.js → chunk-BW7JUDEI.js} +84 -19
  9. package/dist/{chunk-7XGFSUOM.js → chunk-DU72X2IO.js} +271 -76
  10. package/dist/{chunk-V2NUHPXF.js → chunk-GK7WDY7E.js} +1 -1
  11. package/dist/{chunk-7FTTULED.js → chunk-IG3DYEIR.js} +4 -1
  12. package/dist/{chunk-HBGADCKA.js → chunk-KJDOTPYU.js} +3 -3
  13. package/dist/{chunk-4NRCTUZJ.js → chunk-KS4DE3MX.js} +4 -4
  14. package/dist/{chunk-JOCDD4ON.js → chunk-N4BLPJC7.js} +1 -1
  15. package/dist/{chunk-HFGZGYCG.js → chunk-QYXDJOLA.js} +252 -6
  16. package/dist/{chunk-DVMLWQD4.js → chunk-SO5LKIWP.js} +2 -2
  17. package/dist/{chunk-VYXXOKYS.js → chunk-XKIW3QMF.js} +7 -4
  18. package/dist/{chunk-MAPZ7VB6.js → chunk-YVGXGTD6.js} +13 -0
  19. package/dist/{community-report-client-CU22W53K.js → community-report-client-6VJDDMJJ.js} +1 -1
  20. package/dist/{config-XO3LI3SA.js → config-XQWOPDHN.js} +25 -6
  21. package/dist/{context-IFJI3LIT.js → context-M3HDGEIR.js} +4 -4
  22. package/dist/{data-integration-HNGUKFIC.js → data-integration-XBTCGXQT.js} +6 -6
  23. package/dist/index.js +78 -41
  24. package/dist/{local-data-upload-client-GTRIT64F.js → local-data-upload-client-3P7NIVQ4.js} +1 -1
  25. package/dist/{memory-QGPSNCQS.js → memory-6APEB2JB.js} +4 -4
  26. package/dist/{metadata-DI5BMYFU.js → metadata-JRYKNUS5.js} +7 -7
  27. package/dist/{model-RNPQXIBI.js → model-ZS7HVGKN.js} +4 -4
  28. package/dist/{personal-semantic-preference-5C3WUXFI.js → personal-semantic-preference-IDE2GE5T.js} +8 -6
  29. package/dist/project-semantic-36KOCYN7.js +356 -0
  30. package/dist/{sync-O45NXEQY.js → sync-EQLSTUS7.js} +7 -7
  31. package/dist/{te-agent-K5MSPNHJ.js → te-agent-Z3HCTKR7.js} +348 -55
  32. package/dist/{te-analysis-AISWCOOZ.js → te-analysis-5ZZ6YHVH.js} +940 -144
  33. package/dist/{te-community-4OYU3BDA.js → te-community-Z7JACGF3.js} +3 -3
  34. package/dist/{te-dataops-NFIPB6FX.js → te-dataops-F7GQOIS6.js} +644 -276
  35. package/dist/{te-engage-BAM3GBFX.js → te-engage-RNRMYDO3.js} +6 -6
  36. package/dist/{te-experiment-GUTZXZ5Z.js → te-experiment-BTAC2UNK.js} +6 -6
  37. package/dist/{te-kb-3TS73NO6.js → te-kb-QJLJEX5K.js} +323 -181
  38. package/dist/{te-system-STMHLS5J.js → te-system-IXC43QHZ.js} +6 -6
  39. package/dist/{te-team-3I5AOX3N.js → te-team-BIZIKIHZ.js} +6 -6
  40. package/dist/{update-RZXLPCRH.js → update-W2SGQNKT.js} +4 -4
  41. package/package.json +11 -4
  42. package/skills/ae-agent/SKILL.md +9 -4
  43. package/skills/ae-agent/references/notification.md +40 -0
  44. package/skills/ae-analysis/SKILL.md +44 -21
  45. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  46. package/skills/ae-analysis/references/adhoc_run.md +1 -1
  47. package/skills/ae-analysis/references/agent_review_submit_to_page.md +3 -1
  48. package/skills/ae-analysis/references/ai_models/event.md +6 -1
  49. package/skills/ae-analysis/references/ai_models/funnel.md +7 -1
  50. package/skills/ae-analysis/references/ai_models/heat_map.md +23 -0
  51. package/skills/ae-analysis/references/ai_models/interval.md +24 -0
  52. package/skills/ae-analysis/references/ai_models/path.md +20 -0
  53. package/skills/ae-analysis/references/ai_models/prop_analysis.md +2 -0
  54. package/skills/ae-analysis/references/ai_models/rank_list.md +30 -0
  55. package/skills/ae-analysis/references/ai_models/retention.md +45 -1
  56. package/skills/ae-analysis/references/ai_models/revenue.md +20 -2
  57. package/skills/ae-analysis/references/ai_models/session.md +76 -0
  58. package/skills/ae-analysis/references/ai_models/tag.md +2 -0
  59. package/skills/ae-analysis/references/ai_models.md +76 -6
  60. package/skills/ae-analysis/references/analysis_data_retrieval.md +4 -0
  61. package/skills/ae-analysis/references/analysis_drilldown_contract.md +4 -1
  62. package/skills/ae-analysis/references/asset_batch_info_export.md +10 -0
  63. package/skills/ae-analysis/references/asset_batch_sql_export.md +13 -1
  64. package/skills/ae-analysis/references/asset_export.md +12 -1
  65. package/skills/ae-analysis/references/asset_list.md +1 -0
  66. package/skills/ae-analysis/references/asset_search.md +11 -5
  67. package/skills/ae-analysis/references/bi_panel_list.md +1 -1
  68. package/skills/ae-analysis/references/catalog_list.md +1 -1
  69. package/skills/ae-analysis/references/collaboration.md +48 -0
  70. package/skills/ae-analysis/references/command_index.md +19 -17
  71. package/skills/ae-analysis/references/dashboard_list.md +4 -4
  72. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  73. package/skills/ae-analysis/references/drilldown_session_details_run.md +41 -0
  74. package/skills/ae-analysis/references/event_export.md +3 -1
  75. package/skills/ae-analysis/references/governance_recommendation_auto_review.md +77 -0
  76. package/skills/ae-analysis/references/governance_recommendation_export.md +11 -0
  77. package/skills/ae-analysis/references/metadata_resolution.md +3 -3
  78. package/skills/ae-analysis/references/metric_export.md +3 -1
  79. package/skills/ae-analysis/references/metric_list.md +1 -1
  80. package/skills/ae-analysis/references/operation_record_export.md +10 -0
  81. package/skills/ae-analysis/references/personal_semantic_preference_add.md +2 -2
  82. package/skills/ae-analysis/references/personal_semantic_preference_get.md +4 -4
  83. package/skills/ae-analysis/references/personal_semantic_preference_list.md +4 -4
  84. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +30 -12
  85. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +59 -0
  86. package/skills/ae-analysis/references/property_export.md +3 -1
  87. package/skills/ae-analysis/references/report_create.md +5 -1
  88. package/skills/ae-analysis/references/report_data_export.md +6 -0
  89. package/skills/ae-analysis/references/report_get.md +2 -0
  90. package/skills/ae-analysis/references/report_list.md +5 -5
  91. package/skills/ae-analysis/references/report_update.md +7 -1
  92. package/skills/ae-analysis/references/sql_table_columns.md +4 -4
  93. package/skills/ae-analysis/references/sql_table_list.md +5 -5
  94. package/skills/ae-analysis/references/user_cluster_models.md +8 -0
  95. package/skills/ae-analysis/references/user_tag_create.md +7 -1
  96. package/skills/ae-analysis/references/user_tag_get.md +1 -1
  97. package/skills/ae-analysis/references/user_tag_models.md +18 -2
  98. package/skills/ae-analysis/references/user_tag_refresh.md +1 -1
  99. package/skills/ae-analysis/references/user_tag_update.md +2 -2
  100. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +337 -12
  101. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +8 -3
  102. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +284 -24
  103. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/package-wiki-source-zip.mjs +185 -22
  104. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/precompiled-source.mjs +46 -2
  105. package/skills/ae-capability/SKILL.md +63 -1
  106. package/skills/ae-capability/references/collaboration.md +48 -0
  107. package/skills/ae-community/SKILL.md +5 -1
  108. package/skills/ae-community/references/collaboration.md +48 -0
  109. package/skills/ae-data-integration/SKILL.md +4 -0
  110. package/skills/ae-data-integration/references/collaboration.md +48 -0
  111. package/skills/ae-data-integration-helper/references/cpp_server_sdk_faq.md +2 -2
  112. package/skills/ae-data-integration-helper/references/logbus2_parser_plugin.md +6 -6
  113. package/skills/ae-data-integration-helper/references/sdk_log_guide.md +4 -4
  114. package/skills/ae-dataops/SKILL.md +54 -74
  115. package/skills/ae-dataops/references/collaboration.md +48 -0
  116. package/skills/ae-dataops/references/dataops-backfill.md +23 -18
  117. package/skills/ae-dataops/references/dataops-flow-create.md +74 -23
  118. package/skills/ae-dataops/references/dataops-flow-monitor.md +45 -13
  119. package/skills/ae-dataops/references/dataops-integration.md +57 -30
  120. package/skills/ae-dataops/references/dataops-query.md +21 -4
  121. package/skills/ae-dataops/references/dataops-table.md +143 -11
  122. package/skills/ae-engage/SKILL.md +21 -6
  123. package/skills/ae-engage/references/add-channel.md +3 -3
  124. package/skills/ae-engage/references/channel-mgmt.md +3 -3
  125. package/skills/ae-engage/references/collaboration.md +48 -0
  126. package/skills/ae-engage/references/common-metric.md +2 -2
  127. package/skills/ae-engage/references/save-task.md +2 -2
  128. package/skills/ae-engage/references/scene-config-channel.md +4 -4
  129. package/skills/ae-generate-tracking-code/SKILL.md +1 -1
  130. package/skills/ae-generate-tracking-plan/SKILL.md +4 -0
  131. package/skills/ae-generate-tracking-plan/references/collaboration.md +48 -0
  132. package/skills/ae-kb/SKILL.md +9 -1
  133. package/skills/ae-kb/references/collaboration.md +48 -0
  134. package/skills/ae-kb/references/schema-import.md +30 -0
  135. package/skills/ae-kb-discovery/SKILL.md +7 -2
  136. package/skills/ae-kb-discovery/references/collaboration.md +48 -0
  137. package/skills/ae-metadata/SKILL.md +20 -12
  138. package/skills/ae-metadata/references/collaboration.md +48 -0
  139. package/dist/project-semantic-3LF6Q6JZ.js +0 -1119
  140. package/skills/ae-project-semantic/SKILL.md +0 -193
  141. package/skills/ae-project-semantic/references/query-routing-v5.md +0 -165
  142. package/skills/ae-project-semantic/references/recommendation-quality.md +0 -68
@@ -2,23 +2,27 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  kbApi,
4
4
  kbUpload
5
- } from "./chunk-57RRFUEZ.js";
5
+ } from "./chunk-5XRQ3CZR.js";
6
6
  import {
7
7
  TeAgentApiError
8
- } from "./chunk-HBGADCKA.js";
8
+ } from "./chunk-KJDOTPYU.js";
9
9
  import {
10
10
  CapabilityGatewayError
11
- } from "./chunk-HFGZGYCG.js";
11
+ } from "./chunk-QYXDJOLA.js";
12
12
  import {
13
13
  printError
14
- } from "./chunk-DX5CDO34.js";
14
+ } from "./chunk-BW7JUDEI.js";
15
15
  import "./chunk-Y74WTIKJ.js";
16
- import "./chunk-7XGFSUOM.js";
17
- import "./chunk-7FTTULED.js";
16
+ import "./chunk-DU72X2IO.js";
17
+ import "./chunk-IG3DYEIR.js";
18
18
  import {
19
19
  CliValidationError,
20
20
  PermissionError
21
- } from "./chunk-MAPZ7VB6.js";
21
+ } from "./chunk-YVGXGTD6.js";
22
+
23
+ // src/commands/te-kb/schema-import.ts
24
+ import { promises as fs } from "fs";
25
+ import path from "path";
22
26
 
23
27
  // src/commands/te-kb/target-scope.ts
24
28
  function getExternalKnowledgeBaseTargetScope(ctx) {
@@ -30,9 +34,131 @@ function getExternalKnowledgeBaseTargetScope(ctx) {
30
34
  );
31
35
  }
32
36
 
37
+ // src/commands/te-kb/schema-import.ts
38
+ var ROOT = "/agent/api/external/knowledge-bases/schema";
39
+ var options = { preserveBusinessErrorCode: true, preserveErrorMetadata: true };
40
+ var flag = (name, type, desc, required = false) => ({ name, type, desc, required });
41
+ var targetFlags = [flag("name", "string", "Knowledge base name", true), flag("scope", "string", "Exact scope: personal | company")];
42
+ var identityFlags = [flag("import-id", "string", "Stable import ID", true)];
43
+ var mutationFlags = [flag("revision", "number", "Expected candidate revision", true), flag("request-id", "string", "Idempotency key; reuse only for identical retries", true)];
44
+ var hashFlag = flag("hash", "string", "Expected candidate SHA256", true);
45
+ var fileFlag = { ...flag("file", "string", "Local UTF-8 Markdown file, at most 256 KiB", true), sensitive: true };
46
+ var waitFlags = [flag("wait", "boolean", "Poll until this task finishes; never abandon on timeout"), { ...flag("timeout", "number", "Wait timeout in seconds"), default: 300, min: 1, max: 3600 }];
47
+ var modelFlag = flag("model", "string", "Optional stable model reference");
48
+ function target(ctx) {
49
+ return { name: ctx.str("name"), scope: getExternalKnowledgeBaseTargetScope(ctx) };
50
+ }
51
+ function endpoint(ctx, action) {
52
+ if (action === "download") return ROOT;
53
+ if (action === "upload" || action === "list") return ROOT + "/imports";
54
+ const suffix = action === "status" ? "" : action === "save" ? "content" : action === "reject" ? "reject-optimization" : action;
55
+ return `${ROOT}/imports/${encodeURIComponent(ctx.str("import-id"))}${suffix ? "/" + suffix : ""}`;
56
+ }
57
+ function body(ctx, action) {
58
+ const result = { expectedRevision: ctx.num("revision"), requestId: ctx.str("request-id") };
59
+ if (["validate", "optimize", "apply"].includes(action)) result.contentHash = ctx.str("hash");
60
+ if (["validate", "optimize"].includes(action) && ctx.str("model")) result.model = ctx.str("model");
61
+ if (action === "optimize" && ctx.list("issue-id").length) result.issueIds = ctx.list("issue-id");
62
+ if (action === "apply") {
63
+ result.reportId = ctx.str("report-id");
64
+ result.expectedSchemaHash = ctx.bool("schema-absent") ? null : ctx.str("schema-hash");
65
+ }
66
+ return result;
67
+ }
68
+ function query(ctx, action) {
69
+ if (action === "download") return { ...target(ctx), download: "1" };
70
+ if (action === "list") return { ...target(ctx), limit: ctx.num("limit") || 20, cursor: ctx.str("cursor") || void 0 };
71
+ if (action === "content") return { target: ctx.str("target") || "current", download: ctx.str("output") ? "1" : void 0 };
72
+ if (action === "diff") return { baseline: ctx.str("baseline") || "current-schema" };
73
+ return {};
74
+ }
75
+ function validate(ctx, action) {
76
+ if (["upload", "list", "download"].includes(action)) getExternalKnowledgeBaseTargetScope(ctx);
77
+ for (const name of ["import-id", "request-id", "replaces-import-id"]) if (ctx.str(name) && !/^[A-Za-z0-9_-]{1,191}$/.test(ctx.str(name))) throw new CliValidationError(`Invalid --${name}`);
78
+ for (const name of ["hash", "schema-hash", "report-id"]) if (ctx.str(name) && !/^[a-f0-9]{64}$/.test(ctx.str(name))) throw new CliValidationError(`Invalid --${name}; expected SHA256`);
79
+ for (const name of ["revision", "replaced-revision"]) if (ctx.num(name) && (!Number.isInteger(ctx.num(name)) || ctx.num(name) < 1)) throw new CliValidationError(`Invalid --${name}`);
80
+ if (action === "apply" && Boolean(ctx.str("schema-hash")) === ctx.bool("schema-absent")) throw new CliValidationError("Specify exactly one of --schema-hash or --schema-absent");
81
+ if (action === "upload" && Boolean(ctx.str("replaces-import-id")) !== Boolean(ctx.num("replaced-revision"))) throw new CliValidationError("Replacement requires --replaces-import-id and --replaced-revision");
82
+ if (action === "content" && !["current", "original", "optimization-input", "optimized"].includes(ctx.str("target") || "current")) throw new CliValidationError("Invalid --target");
83
+ if (action === "diff" && !["original", "optimization-input", "current-schema"].includes(ctx.str("baseline") || "current-schema")) throw new CliValidationError("Invalid --baseline");
84
+ }
85
+ async function readMarkdown(ctx) {
86
+ const absolute = path.resolve(ctx.str("file")), stat = await fs.stat(absolute);
87
+ if (!stat.isFile() || stat.size > 262144 || path.extname(absolute).toLowerCase() !== ".md") throw new CliValidationError("--file must be a Markdown file of at most 256 KiB");
88
+ const bytes = await fs.readFile(absolute);
89
+ if (bytes.length > 262144) throw new CliValidationError("--file exceeds 256 KiB");
90
+ new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
91
+ return { absolute, bytes };
92
+ }
93
+ async function waitSchemaImport(ctx, initial, api = kbApi, sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms))) {
94
+ const deadline = Date.now() + (ctx.num("timeout") || 300) * 1e3;
95
+ let current = initial;
96
+ while (current.task && Date.now() < deadline) {
97
+ await sleep(Math.min(2e3, Math.max(1, deadline - Date.now())));
98
+ current = await api(ctx, "GET", `${ROOT}/imports/${encodeURIComponent(initial.id)}`, {}, void 0, options);
99
+ }
100
+ return { ...current, waitTimedOut: Boolean(current.task) };
101
+ }
102
+ async function executeSchemaImport(ctx, action, api = kbApi, upload = kbUpload) {
103
+ let result;
104
+ if (action === "upload") {
105
+ const { absolute, bytes } = await readMarkdown(ctx);
106
+ const form = new FormData();
107
+ form.set("file", new Blob([new Uint8Array(bytes)]), path.basename(absolute));
108
+ form.set("name", ctx.str("name"));
109
+ form.set("requestId", ctx.str("request-id"));
110
+ const scope = getExternalKnowledgeBaseTargetScope(ctx);
111
+ if (scope) form.set("scope", scope);
112
+ if (ctx.str("model")) form.set("model", ctx.str("model"));
113
+ if (ctx.str("replaces-import-id")) {
114
+ form.set("replacesImportId", ctx.str("replaces-import-id"));
115
+ form.set("expectedReplacedRevision", String(ctx.num("replaced-revision")));
116
+ }
117
+ result = await upload(ctx, endpoint(ctx, action), form, {}, options);
118
+ } else if (["download", "list", "status", "content", "diff"].includes(action)) {
119
+ const binary = action === "download" || action === "content" && Boolean(ctx.str("output"));
120
+ result = await api(ctx, "GET", endpoint(ctx, action), query(ctx, action), void 0, { ...options, ...binary ? { responseType: "bytes" } : {} });
121
+ if (binary) {
122
+ const output = path.resolve(ctx.str("output"));
123
+ const bytes = Buffer.from(result);
124
+ await fs.writeFile(output, bytes, { flag: "wx" });
125
+ return { output, sizeBytes: bytes.length };
126
+ }
127
+ if (action === "diff" && ctx.str("output")) {
128
+ const output = path.resolve(ctx.str("output"));
129
+ await fs.writeFile(output, result.diff, { flag: "wx" });
130
+ return { ...result, output };
131
+ }
132
+ } else {
133
+ const input = body(ctx, action);
134
+ if (action === "save") {
135
+ const { bytes } = await readMarkdown(ctx);
136
+ input.content = bytes.toString("utf8");
137
+ }
138
+ result = await api(ctx, action === "save" ? "PUT" : "POST", endpoint(ctx, action), {}, input, options);
139
+ }
140
+ return ctx.bool("wait") && result.task ? waitSchemaImport(ctx, result, api) : result;
141
+ }
142
+ function command(action, name, description, flags, risk) {
143
+ return { service: "kb", command: name, description, flags, risk, validate: (ctx) => validate(ctx, action), dryRun: (ctx) => ({ method: action === "save" ? "PUT" : ["upload", "validate", "optimize", "reject", "apply", "abandon"].includes(action) ? "POST" : "GET", url: ctx.host().replace(/\/$/, "") + endpoint(ctx, action), params: query(ctx, action), body: action === "upload" ? { ...target(ctx), requestId: ctx.str("request-id"), file: "[REDACTED]", model: ctx.str("model") || void 0, replacesImportId: ctx.str("replaces-import-id") || void 0, expectedReplacedRevision: ctx.num("replaced-revision") || void 0 } : ["save", "validate", "optimize", "reject", "apply", "abandon"].includes(action) ? { ...body(ctx, action), ...action === "save" ? { content: "[REDACTED]" } : {} } : void 0 }), execute: (ctx) => executeSchemaImport(ctx, action) };
144
+ }
145
+ var schemaDownload = command("download", "+schema-download", "Download formal schema bytes without rewriting.", [...targetFlags, flag("output", "string", "New destination file; never overwrite", true)], "read");
146
+ var schemaImport = command("upload", "+schema-import", "Upload a candidate and start validation; formal schema is unchanged.", [...targetFlags, fileFlag, flag("request-id", "string", "Upload idempotency key", true), modelFlag, flag("replaces-import-id", "string", "Explicit pending import to replace"), flag("replaced-revision", "number", "Expected revision of replaced import"), ...waitFlags], "write");
147
+ var schemaImportList = command("list", "+schema-import-list", "List your pending candidates.", [...targetFlags, { ...flag("limit", "number", "Page size, 1 to 100"), default: 20, min: 1, max: 100 }, flag("cursor", "string", "Continuation cursor")], "read");
148
+ var schemaImportStatus = command("status", "+schema-import-status", "Read candidate status, report and durable receipt.", [...identityFlags, ...waitFlags], "read");
149
+ var schemaImportContent = command("content", "+schema-import-content", "Read or download unmodified candidate bytes.", [...identityFlags, flag("target", "string", "current | original | optimization-input | optimized"), flag("output", "string", "Optional new destination file")], "read");
150
+ var schemaImportDiff = command("diff", "+schema-import-diff", "Read full actual diff and current formal hash.", [...identityFlags, flag("baseline", "string", "original | optimization-input | current-schema"), flag("output", "string", "Optional new diff file")], "read");
151
+ var schemaImportSave = command("save", "+schema-import-save", "Save edits without calling a model.", [...identityFlags, ...mutationFlags, fileFlag], "write");
152
+ var schemaImportValidate = command("validate", "+schema-import-validate", "Validate this exact saved revision.", [...identityFlags, ...mutationFlags, hashFlag, modelFlag, ...waitFlags], "write");
153
+ var schemaImportOptimize = command("optimize", "+schema-import-optimize", "Repair selected issues once and independently revalidate.", [...identityFlags, ...mutationFlags, hashFlag, modelFlag, { ...flag("issue-id", "string", "Repeat to select repairable issues"), variadic: true }, ...waitFlags], "write");
154
+ var schemaImportReject = command("reject", "+schema-import-reject", "Restore the most recent repair input.", [...identityFlags, ...mutationFlags], "write");
155
+ var schemaImportApply = command("apply", "+schema-import-apply", "Apply after reviewing full diff; BASE_CHANGED requires a new review.", [...identityFlags, ...mutationFlags, hashFlag, flag("report-id", "string", "Current passing report ID", true), flag("schema-hash", "string", "Formal hash from a recent diff"), flag("schema-absent", "boolean", "Explicitly confirm formal schema is absent")], "write");
156
+ var schemaImportAbandon = command("abandon", "+schema-import-abandon", "Abandon candidate and invalidate pending tasks.", [...identityFlags, ...mutationFlags], "high-risk-write");
157
+ var schemaImportCommands = [schemaDownload, schemaImport, schemaImportList, schemaImportStatus, schemaImportContent, schemaImportDiff, schemaImportSave, schemaImportValidate, schemaImportOptimize, schemaImportReject, schemaImportApply, schemaImportAbandon];
158
+
33
159
  // src/commands/te-kb/source-check-updates.ts
34
160
  var API_PATH = "/agent/api/external/knowledge-bases/sources/check-updates";
35
- function body(ctx) {
161
+ function body2(ctx) {
36
162
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
37
163
  return { name: ctx.str("name").trim(), sourceId: ctx.str("id").trim(), ...scope ? { scope } : {} };
38
164
  }
@@ -48,16 +174,16 @@ var sourceCheckUpdates = {
48
174
  { name: "scope", type: "string", desc: "Exact scope: personal | company (omit for personal then company lookup)" }
49
175
  ],
50
176
  validate: (ctx) => {
51
- for (const [flag, max] of [["name", 200], ["id", 191]]) {
52
- const value = ctx.str(flag).trim();
53
- if (!value || value.length > max) throw new CliValidationError(`Invalid --${flag}: expected 1-${max} characters.`);
177
+ for (const [flag2, max] of [["name", 200], ["id", 191]]) {
178
+ const value = ctx.str(flag2).trim();
179
+ if (!value || value.length > max) throw new CliValidationError(`Invalid --${flag2}: expected 1-${max} characters.`);
54
180
  }
55
181
  getExternalKnowledgeBaseTargetScope(ctx);
56
182
  },
57
- dryRun: (ctx) => ({ method: "POST", url: `${ctx.host().replace(/\/$/, "")}${API_PATH}`, body: body(ctx) }),
183
+ dryRun: (ctx) => ({ method: "POST", url: `${ctx.host().replace(/\/$/, "")}${API_PATH}`, body: body2(ctx) }),
58
184
  execute: async (ctx) => {
59
185
  try {
60
- return await kbApi(ctx, "POST", API_PATH, {}, body(ctx), { preserveErrorMetadata: true });
186
+ return await kbApi(ctx, "POST", API_PATH, {}, body2(ctx), { preserveErrorMetadata: true });
61
187
  } catch (error) {
62
188
  const hint = "Read kb +list-sources to confirm the current source state before retrying.";
63
189
  if (error instanceof PermissionError) {
@@ -85,13 +211,13 @@ var sourceCheckUpdates = {
85
211
  };
86
212
 
87
213
  // src/commands/te-kb/source-mutation.ts
88
- import { promises as fs } from "fs";
89
- import path from "path";
214
+ import { promises as fs2 } from "fs";
215
+ import path2 from "path";
90
216
  var API = "/agent/api/external/knowledge-bases";
91
217
  var apiOptions = { preserveErrorMetadata: true };
92
218
  var maxBytes = 50 * 1024 * 1024;
93
219
  var fileExtensions = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".csv", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".svg"]);
94
- var identityFlags = [
220
+ var identityFlags2 = [
95
221
  { name: "name", type: "string", required: true, desc: "Exact knowledge base name from kb +list" },
96
222
  { name: "scope", type: "string", required: true, desc: "Exact knowledge base scope: personal or company" },
97
223
  { name: "id", type: "string", required: true, desc: "Current stable source ID from kb +list-sources" }
@@ -100,24 +226,24 @@ var typeFlag = { name: "source-type", type: "string", required: true, desc: "Cur
100
226
  var revisionFlag = { name: "expected-revision", type: "number", required: true, min: 1, max: 2147483647, desc: "Current contentRevision from kb +list-sources; never automatically retry a conflict" };
101
227
  var previewFlag = { name: "preview-id", type: "string", required: true, desc: "Exact previewId returned by ZIP replace or restore" };
102
228
  function validateIdentity(ctx) {
103
- for (const [flag, max] of [["name", 200], ["id", 191], ["preview-id", 191]]) {
104
- const value = ctx.str(flag);
105
- if ((flag !== "preview-id" || value) && (!value.trim() || value.length > max || /[\x00-\x1f\x7f]/.test(value))) {
106
- throw new CliValidationError(`--${flag} must contain 1 to ${max} characters without control characters.`);
229
+ for (const [flag2, max] of [["name", 200], ["id", 191], ["preview-id", 191]]) {
230
+ const value = ctx.str(flag2);
231
+ if ((flag2 !== "preview-id" || value) && (!value.trim() || value.length > max || /[\x00-\x1f\x7f]/.test(value))) {
232
+ throw new CliValidationError(`--${flag2} must contain 1 to ${max} characters without control characters.`);
107
233
  }
108
234
  }
109
235
  if (!["personal", "company"].includes(ctx.str("scope"))) throw new CliValidationError("--scope must be personal or company.");
110
236
  }
111
- function positiveInteger(ctx, flag) {
112
- const value = ctx.num(flag);
113
- if (!Number.isSafeInteger(value) || value < 1 || value > 2147483647) throw new CliValidationError(`--${flag} must be an integer from 1 to 2147483647.`);
237
+ function positiveInteger(ctx, flag2) {
238
+ const value = ctx.num(flag2);
239
+ if (!Number.isSafeInteger(value) || value < 1 || value > 2147483647) throw new CliValidationError(`--${flag2} must be an integer from 1 to 2147483647.`);
114
240
  }
115
241
  function validateMutation(ctx) {
116
242
  validateIdentity(ctx);
117
243
  positiveInteger(ctx, "expected-revision");
118
244
  if (!["file", "zip"].includes(ctx.str("source-type"))) throw new CliValidationError("--source-type must be file or zip; URL sources cannot be replaced or restored.");
119
245
  }
120
- function query(ctx) {
246
+ function query2(ctx) {
121
247
  return { name: ctx.str("name").trim(), scope: ctx.str("scope") };
122
248
  }
123
249
  function sourceEndpoint(ctx, suffix) {
@@ -126,22 +252,22 @@ function sourceEndpoint(ctx, suffix) {
126
252
  function previewEndpoint(ctx) {
127
253
  return sourceEndpoint(ctx, `directory/previews/${encodeURIComponent(ctx.str("preview-id").trim())}`);
128
254
  }
129
- function dryRequest(ctx, method, endpoint2, body2) {
130
- return { method, url: `${ctx.host().replace(/\/$/, "")}${endpoint2}`, params: query(ctx), ...body2 === void 0 ? {} : { body: body2 } };
255
+ function dryRequest(ctx, method, endpoint3, body3) {
256
+ return { method, url: `${ctx.host().replace(/\/$/, "")}${endpoint3}`, params: query2(ctx), ...body3 === void 0 ? {} : { body: body3 } };
131
257
  }
132
258
  async function replacementFile(ctx, read) {
133
- const file = path.resolve(ctx.str("file"));
134
- const extension = path.extname(file).toLowerCase();
259
+ const file = path2.resolve(ctx.str("file"));
260
+ const extension = path2.extname(file).toLowerCase();
135
261
  if (ctx.str("source-type") === "zip" ? extension !== ".zip" : !fileExtensions.has(extension)) {
136
262
  throw new CliValidationError("--file must be a ZIP for a ZIP source, or a supported non-ZIP file for a file source. File sources must keep their original format.");
137
263
  }
138
- const handle = await fs.open(file, "r");
264
+ const handle = await fs2.open(file, "r");
139
265
  try {
140
266
  const stat = await handle.stat();
141
267
  if (!stat.isFile() || stat.size > maxBytes) throw new CliValidationError("--file must be a regular file of at most 50 MB.");
142
268
  const content = read ? await handle.readFile() : void 0;
143
269
  if (content && content.length > maxBytes) throw new CliValidationError("--file exceeds 50 MB.");
144
- return { file, filename: path.basename(file), sizeBytes: content?.length ?? stat.size, content };
270
+ return { file, filename: path2.basename(file), sizeBytes: content?.length ?? stat.size, content };
145
271
  } finally {
146
272
  await handle.close();
147
273
  }
@@ -158,7 +284,7 @@ var sourceReplace = {
158
284
  command: "replace",
159
285
  risk: "write",
160
286
  description: "Replace a file source draft, or prepare a ZIP archive replacement preview. ZIP changes require source commit. Does not compile or publish.",
161
- flags: [...identityFlags, typeFlag, revisionFlag, { name: "file", type: "string", required: true, desc: "Local replacement file, at most 50 MB; same format, different filename allowed" }],
287
+ flags: [...identityFlags2, typeFlag, revisionFlag, { name: "file", type: "string", required: true, desc: "Local replacement file, at most 50 MB; same format, different filename allowed" }],
162
288
  validate: (ctx) => {
163
289
  validateMutation(ctx);
164
290
  if (!ctx.str("file").trim()) throw new CliValidationError("--file is required.");
@@ -172,7 +298,7 @@ var sourceReplace = {
172
298
  const form = new FormData();
173
299
  form.append("file", new Blob([new Uint8Array(file.content)]), file.filename);
174
300
  for (const [key, value] of Object.entries(replaceFields(ctx))) form.append(key, String(value));
175
- return kbUpload(ctx, replaceEndpoint(ctx), form, query(ctx), { ...apiOptions, method: ctx.str("source-type") === "zip" ? "POST" : "PUT" });
301
+ return kbUpload(ctx, replaceEndpoint(ctx), form, query2(ctx), { ...apiOptions, method: ctx.str("source-type") === "zip" ? "POST" : "PUT" });
176
302
  }
177
303
  };
178
304
  function restoreEndpoint(ctx) {
@@ -188,7 +314,7 @@ var sourceRestore = {
188
314
  risk: "write",
189
315
  description: "Restore one current source draft from a published version. File sources restore immediately; ZIP source or child restores return a preview. Does not roll back the whole knowledge base or publish.",
190
316
  flags: [
191
- ...identityFlags,
317
+ ...identityFlags2,
192
318
  typeFlag,
193
319
  revisionFlag,
194
320
  { name: "version", type: "number", required: true, min: 1, max: 2147483647, desc: "Published version number from kb +versions; use the latest number to discard unpublished changes" },
@@ -203,7 +329,7 @@ var sourceRestore = {
203
329
  }
204
330
  },
205
331
  dryRun: (ctx) => dryRequest(ctx, "POST", restoreEndpoint(ctx), restoreBody(ctx)),
206
- execute: (ctx) => kbApi(ctx, "POST", restoreEndpoint(ctx), query(ctx), restoreBody(ctx), apiOptions)
332
+ execute: (ctx) => kbApi(ctx, "POST", restoreEndpoint(ctx), query2(ctx), restoreBody(ctx), apiOptions)
207
333
  };
208
334
  var sourcePreview = {
209
335
  service: "kb",
@@ -212,7 +338,7 @@ var sourcePreview = {
212
338
  risk: "read",
213
339
  description: "Read one page of a ZIP replacement or restore preview, including additions, modifications and deletions.",
214
340
  flags: [
215
- ...identityFlags,
341
+ ...identityFlags2,
216
342
  previewFlag,
217
343
  { name: "cursor", type: "string", desc: "Opaque nextCursor returned by the previous preview page" },
218
344
  { name: "limit", type: "number", default: 100, min: 1, max: 200, desc: "Preview page size from 1 to 200" }
@@ -222,8 +348,8 @@ var sourcePreview = {
222
348
  if (!Number.isInteger(ctx.num("limit")) || ctx.num("limit") < 1 || ctx.num("limit") > 200) throw new CliValidationError("--limit must be an integer from 1 to 200.");
223
349
  if (ctx.str("cursor").length > 4096) throw new CliValidationError("--cursor must be at most 4096 characters.");
224
350
  },
225
- dryRun: (ctx) => ({ ...dryRequest(ctx, "GET", previewEndpoint(ctx)), params: { ...query(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} } }),
226
- execute: (ctx) => kbApi(ctx, "GET", previewEndpoint(ctx), { ...query(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} }, void 0, apiOptions)
351
+ dryRun: (ctx) => ({ ...dryRequest(ctx, "GET", previewEndpoint(ctx)), params: { ...query2(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} } }),
352
+ execute: (ctx) => kbApi(ctx, "GET", previewEndpoint(ctx), { ...query2(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} }, void 0, apiOptions)
227
353
  };
228
354
  var sourceCommit = {
229
355
  service: "kb",
@@ -231,13 +357,13 @@ var sourceCommit = {
231
357
  command: "commit",
232
358
  risk: "high-risk-write",
233
359
  description: "Confirm a reviewed ZIP replacement or restore preview. May delete missing files; changes only the draft. On uncertain outcome, inspect state before any retry.",
234
- flags: [...identityFlags, previewFlag, revisionFlag],
360
+ flags: [...identityFlags2, previewFlag, revisionFlag],
235
361
  validate: (ctx) => {
236
362
  validateIdentity(ctx);
237
363
  positiveInteger(ctx, "expected-revision");
238
364
  },
239
365
  dryRun: (ctx) => dryRequest(ctx, "POST", `${previewEndpoint(ctx)}/commit`, { expectedRevision: ctx.num("expected-revision"), confirmed: true }),
240
- execute: (ctx) => kbApi(ctx, "POST", `${previewEndpoint(ctx)}/commit`, query(ctx), { expectedRevision: ctx.num("expected-revision"), confirmed: true }, apiOptions)
366
+ execute: (ctx) => kbApi(ctx, "POST", `${previewEndpoint(ctx)}/commit`, query2(ctx), { expectedRevision: ctx.num("expected-revision"), confirmed: true }, apiOptions)
241
367
  };
242
368
  var sourceCancel = {
243
369
  service: "kb",
@@ -245,18 +371,18 @@ var sourceCancel = {
245
371
  command: "cancel",
246
372
  risk: "high-risk-write",
247
373
  description: "Discard an uncommitted ZIP replacement or restore preview; leaves the source draft unchanged.",
248
- flags: [...identityFlags, previewFlag],
374
+ flags: [...identityFlags2, previewFlag],
249
375
  validate: validateIdentity,
250
376
  dryRun: (ctx) => dryRequest(ctx, "DELETE", previewEndpoint(ctx)),
251
377
  execute: async (ctx) => {
252
- await kbApi(ctx, "DELETE", previewEndpoint(ctx), query(ctx), void 0, { ...apiOptions, responseType: "empty" });
378
+ await kbApi(ctx, "DELETE", previewEndpoint(ctx), query2(ctx), void 0, { ...apiOptions, responseType: "empty" });
253
379
  return { previewId: ctx.str("preview-id"), cancelled: true };
254
380
  }
255
381
  };
256
382
 
257
383
  // src/commands/te-kb/add.ts
258
- import { promises as fs2 } from "fs";
259
- import * as path2 from "path";
384
+ import { promises as fs3 } from "fs";
385
+ import * as path3 from "path";
260
386
  import TurndownService from "turndown";
261
387
  var API_PATH2 = "/agent/api/external/knowledge-bases/sources/upload";
262
388
  var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
@@ -305,7 +431,7 @@ function sanitizeFilename(name) {
305
431
  return cleaned || "document";
306
432
  }
307
433
  function getMimeType(filename) {
308
- const ext = path2.extname(filename).toLowerCase();
434
+ const ext = path3.extname(filename).toLowerCase();
309
435
  switch (ext) {
310
436
  case ".zip":
311
437
  return "application/zip";
@@ -348,23 +474,23 @@ function getMimeType(filename) {
348
474
  }
349
475
  }
350
476
  async function readLocalFile(filePath) {
351
- const ext = path2.extname(filePath).toLowerCase();
477
+ const ext = path3.extname(filePath).toLowerCase();
352
478
  if (!SUPPORTED_EXTENSIONS.has(ext)) {
353
479
  throw new Error(`Unsupported file extension (${ext || "none"}): ${filePath}`);
354
480
  }
355
- const content = await fs2.readFile(filePath);
356
- const filename = path2.basename(filePath);
481
+ const content = await fs3.readFile(filePath);
482
+ const filename = path3.basename(filePath);
357
483
  return { filename, content, mimeType: getMimeType(filename), origin: "file", source: filePath };
358
484
  }
359
485
  async function readDirectory(dir) {
360
- const entries = await fs2.readdir(dir, { withFileTypes: true });
486
+ const entries = await fs3.readdir(dir, { withFileTypes: true });
361
487
  const files = [];
362
488
  for (const entry of entries) {
363
489
  if (!entry.isFile()) continue;
364
- const ext = path2.extname(entry.name).toLowerCase();
490
+ const ext = path3.extname(entry.name).toLowerCase();
365
491
  if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
366
- const full = path2.join(dir, entry.name);
367
- const content = await fs2.readFile(full);
492
+ const full = path3.join(dir, entry.name);
493
+ const content = await fs3.readFile(full);
368
494
  files.push({ filename: entry.name, content, mimeType: getMimeType(entry.name), origin: "dir", source: full });
369
495
  }
370
496
  if (files.length === 0) {
@@ -399,10 +525,10 @@ async function fetchAsMarkdown(rawUrl) {
399
525
  };
400
526
  }
401
527
  async function resolveLocalPath(p) {
402
- const abs = path2.resolve(p);
528
+ const abs = path3.resolve(p);
403
529
  let stat;
404
530
  try {
405
- stat = await fs2.stat(abs);
531
+ stat = await fs3.stat(abs);
406
532
  } catch {
407
533
  throw new Error(`Path not found: ${p}`);
408
534
  }
@@ -438,7 +564,7 @@ function dedupeByFilename(files) {
438
564
  const count = used.get(f.filename) ?? 0;
439
565
  used.set(f.filename, count + 1);
440
566
  if (count === 0) return f;
441
- const ext = path2.extname(f.filename);
567
+ const ext = path3.extname(f.filename);
442
568
  const stem = f.filename.slice(0, f.filename.length - ext.length);
443
569
  return { ...f, filename: `${stem}-${count}${ext}` };
444
570
  });
@@ -473,17 +599,17 @@ var add = {
473
599
  },
474
600
  dryRun: (ctx) => {
475
601
  const items = normalizeFilesInput(ctx.json("files"));
476
- const body2 = {
602
+ const body3 = {
477
603
  name: ctx.str("name")
478
604
  };
479
605
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
480
- if (scope) body2.scope = scope;
481
- body2.files = items.map((item) => ({ value: item, type: classifyInput(item) }));
482
- body2.contentType = "multipart/form-data";
606
+ if (scope) body3.scope = scope;
607
+ body3.files = items.map((item) => ({ value: item, type: classifyInput(item) }));
608
+ body3.contentType = "multipart/form-data";
483
609
  return {
484
610
  method: "POST",
485
611
  url: `${ctx.host().replace(/\/$/, "")}${API_PATH2}`,
486
- body: body2
612
+ body: body3
487
613
  };
488
614
  },
489
615
  execute: async (ctx) => {
@@ -510,15 +636,15 @@ function getMode(ctx) {
510
636
  return mode;
511
637
  }
512
638
  function buildBody(ctx) {
513
- const body2 = {
639
+ const body3 = {
514
640
  name: ctx.str("name"),
515
641
  mode: getMode(ctx)
516
642
  };
517
643
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
518
- if (scope) body2.scope = scope;
644
+ if (scope) body3.scope = scope;
519
645
  const model = ctx.str("model");
520
- if (model) body2.model = model;
521
- return body2;
646
+ if (model) body3.model = model;
647
+ return body3;
522
648
  }
523
649
  var compile = {
524
650
  service: "kb",
@@ -546,10 +672,10 @@ var compile = {
546
672
  // src/commands/te-kb/remove.ts
547
673
  var API_PATH4 = "/agent/api/external/knowledge-bases";
548
674
  function buildBody2(ctx) {
549
- const body2 = { name: ctx.str("name") };
675
+ const body3 = { name: ctx.str("name") };
550
676
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
551
- if (scope) body2.scope = scope;
552
- return body2;
677
+ if (scope) body3.scope = scope;
678
+ return body3;
553
679
  }
554
680
  var remove = {
555
681
  service: "kb",
@@ -600,19 +726,19 @@ function normalizeTags(raw) {
600
726
  return tags;
601
727
  }
602
728
  function buildBody3(ctx) {
603
- const body2 = {
729
+ const body3 = {
604
730
  scope: getScope(ctx),
605
731
  name: ctx.str("name")
606
732
  };
607
733
  const description = ctx.str("description");
608
- if (description) body2.description = description;
734
+ if (description) body3.description = description;
609
735
  const tags = normalizeTags(ctx.json("tags"));
610
- if (tags && tags.length > 0) body2.tags = tags;
736
+ if (tags && tags.length > 0) body3.tags = tags;
611
737
  const projectId = ctx.str("project-id");
612
- if (projectId) body2.projectId = projectId;
738
+ if (projectId) body3.projectId = projectId;
613
739
  const projectName = ctx.str("project-name");
614
- if (projectName) body2.projectName = projectName;
615
- return body2;
740
+ if (projectName) body3.projectName = projectName;
741
+ return body3;
616
742
  }
617
743
  var create = {
618
744
  service: "kb",
@@ -649,12 +775,12 @@ function sourceSelector(ctx) {
649
775
  throw new CliValidationError("One of --id or --display-name is required.");
650
776
  }
651
777
  function buildBody4(ctx) {
652
- const body2 = {
778
+ const body3 = {
653
779
  name: ctx.str("name")
654
780
  };
655
781
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
656
- if (scope) body2.scope = scope;
657
- return { ...body2, ...sourceSelector(ctx) };
782
+ if (scope) body3.scope = scope;
783
+ return { ...body3, ...sourceSelector(ctx) };
658
784
  }
659
785
  var rmSource = {
660
786
  service: "kb",
@@ -682,8 +808,8 @@ var rmSource = {
682
808
  };
683
809
 
684
810
  // src/commands/te-kb/schema.ts
685
- import fs3 from "fs";
686
- import path3 from "path";
811
+ import fs4 from "fs";
812
+ import path4 from "path";
687
813
  var API_PATH7 = "/agent/api/external/knowledge-bases/schema";
688
814
  var MAX_CUSTOM_INSTRUCTIONS_CHARS = 1e4;
689
815
  function getCustomInstructions(ctx) {
@@ -692,7 +818,7 @@ function getCustomInstructions(ctx) {
692
818
  if (inline && file) {
693
819
  throw new Error("Use either --custom-instructions or --custom-instructions-file, not both.");
694
820
  }
695
- const content = file ? fs3.readFileSync(path3.resolve(file), "utf8") : inline;
821
+ const content = file ? fs4.readFileSync(path4.resolve(file), "utf8") : inline;
696
822
  if (file && !content.trim()) {
697
823
  throw new Error("--custom-instructions-file is empty.");
698
824
  }
@@ -702,17 +828,17 @@ function getCustomInstructions(ctx) {
702
828
  return content;
703
829
  }
704
830
  function buildBody5(ctx) {
705
- const body2 = {
831
+ const body3 = {
706
832
  name: ctx.str("name")
707
833
  };
708
834
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
709
- if (scope) body2.scope = scope;
710
- if (ctx.bool("force")) body2.force = true;
835
+ if (scope) body3.scope = scope;
836
+ if (ctx.bool("force")) body3.force = true;
711
837
  const model = ctx.str("model");
712
- if (model) body2.model = model;
838
+ if (model) body3.model = model;
713
839
  const customInstructions = getCustomInstructions(ctx);
714
- if (customInstructions) body2.customInstructions = customInstructions;
715
- return body2;
840
+ if (customInstructions) body3.customInstructions = customInstructions;
841
+ return body3;
716
842
  }
717
843
  async function executeSchema(ctx, api = kbApi) {
718
844
  return api(ctx, "POST", API_PATH7, {}, buildBody5(ctx), {
@@ -759,12 +885,12 @@ var schema = {
759
885
  // src/commands/te-kb/status.ts
760
886
  var API_PATH8 = "/agent/api/external/knowledge-bases/status";
761
887
  function buildBody6(ctx) {
762
- const body2 = {
888
+ const body3 = {
763
889
  name: ctx.str("name")
764
890
  };
765
891
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
766
- if (scope) body2.scope = scope;
767
- return body2;
892
+ if (scope) body3.scope = scope;
893
+ return body3;
768
894
  }
769
895
  var status = {
770
896
  service: "kb",
@@ -789,12 +915,12 @@ var status = {
789
915
  // src/commands/te-kb/kb-index.ts
790
916
  var API_PATH9 = "/agent/api/external/knowledge-bases/index";
791
917
  function buildBody7(ctx) {
792
- const body2 = {};
918
+ const body3 = {};
793
919
  const sources = ctx.json("sources");
794
- if (sources) body2.sources = sources;
920
+ if (sources) body3.sources = sources;
795
921
  const locale = ctx.str("locale");
796
- if (locale) body2.locale = locale;
797
- return body2;
922
+ if (locale) body3.locale = locale;
923
+ return body3;
798
924
  }
799
925
  var kbIndex = {
800
926
  service: "kb",
@@ -836,12 +962,12 @@ function validateBuildStatus(ctx) {
836
962
  }
837
963
  }
838
964
  function buildBody8(ctx) {
839
- const body2 = {
965
+ const body3 = {
840
966
  buildStatus: getBuildStatus(ctx)
841
967
  };
842
968
  const locale = ctx.str("locale");
843
- if (locale) body2.locale = locale;
844
- return body2;
969
+ if (locale) body3.locale = locale;
970
+ return body3;
845
971
  }
846
972
  var kbList = {
847
973
  service: "kb",
@@ -933,16 +1059,16 @@ var listSources = {
933
1059
  // src/commands/te-kb/kb-grep.ts
934
1060
  var API_PATH12 = "/agent/api/external/knowledge-bases/grep";
935
1061
  function buildBody9(ctx) {
936
- const body2 = {
1062
+ const body3 = {
937
1063
  query: ctx.str("query"),
938
1064
  sources: ctx.json("sources"),
939
1065
  paths: ctx.json("paths")
940
1066
  };
941
1067
  const topK = ctx.optionalNum("top-k");
942
- if (topK !== void 0) body2.topK = topK;
1068
+ if (topK !== void 0) body3.topK = topK;
943
1069
  const locale = ctx.str("locale");
944
- if (locale) body2.locale = locale;
945
- return body2;
1070
+ if (locale) body3.locale = locale;
1071
+ return body3;
946
1072
  }
947
1073
  var kbGrep = {
948
1074
  service: "kb",
@@ -1005,20 +1131,20 @@ function readLimit(ctx) {
1005
1131
  return limit;
1006
1132
  }
1007
1133
  function buildBody10(ctx) {
1008
- const body2 = {
1134
+ const body3 = {
1009
1135
  source: ctx.json("source"),
1010
1136
  path: ctx.str("path")
1011
1137
  };
1012
1138
  const offset = ctx.optionalNum("offset");
1013
- if (offset !== void 0) body2.offset = offset;
1139
+ if (offset !== void 0) body3.offset = offset;
1014
1140
  const limit = ctx.optionalNum("limit");
1015
- if (limit !== void 0) body2.limit = limit;
1141
+ if (limit !== void 0) body3.limit = limit;
1016
1142
  const expand = readExpand(ctx);
1017
- if (expand) body2.expand = expand;
1018
- if (ctx.bool("outline")) body2.outline = true;
1143
+ if (expand) body3.expand = expand;
1144
+ if (ctx.bool("outline")) body3.outline = true;
1019
1145
  const locale = ctx.str("locale");
1020
- if (locale) body2.locale = locale;
1021
- return body2;
1146
+ if (locale) body3.locale = locale;
1147
+ return body3;
1022
1148
  }
1023
1149
  var kbRead = {
1024
1150
  service: "kb",
@@ -1081,12 +1207,12 @@ function isTransientAskPollError(error) {
1081
1207
  error.message
1082
1208
  );
1083
1209
  }
1084
- async function pollUntilSettled(getStatus, executionId, options = {}) {
1085
- const intervalMs = options.intervalMs ?? ASK_POLL_INTERVAL_MS;
1086
- const timeoutMs = options.timeoutMs ?? ASK_POLL_TIMEOUT_MS;
1087
- const maxTransientFailures = options.maxTransientFailures ?? ASK_MAX_TRANSIENT_POLL_FAILURES;
1088
- const now = options.now ?? Date.now;
1089
- const sleep = options.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
1210
+ async function pollUntilSettled(getStatus, executionId, options2 = {}) {
1211
+ const intervalMs = options2.intervalMs ?? ASK_POLL_INTERVAL_MS;
1212
+ const timeoutMs = options2.timeoutMs ?? ASK_POLL_TIMEOUT_MS;
1213
+ const maxTransientFailures = options2.maxTransientFailures ?? ASK_MAX_TRANSIENT_POLL_FAILURES;
1214
+ const now = options2.now ?? Date.now;
1215
+ const sleep = options2.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
1090
1216
  const startTime = now();
1091
1217
  let transientFailures = 0;
1092
1218
  while (true) {
@@ -1143,16 +1269,16 @@ function validateLocale(locale) {
1143
1269
  }
1144
1270
  }
1145
1271
  function buildBody11(ctx) {
1146
- const body2 = {
1272
+ const body3 = {
1147
1273
  question: ctx.str("question")
1148
1274
  };
1149
1275
  const sources = ctx.json("sources");
1150
- if (sources) body2.sources = sources;
1276
+ if (sources) body3.sources = sources;
1151
1277
  const modelId = ctx.str("model-id");
1152
- if (modelId) body2.modelId = modelId;
1278
+ if (modelId) body3.modelId = modelId;
1153
1279
  const locale = ctx.str("locale");
1154
- if (locale) body2.locale = locale;
1155
- return body2;
1280
+ if (locale) body3.locale = locale;
1281
+ return body3;
1156
1282
  }
1157
1283
  var ask = {
1158
1284
  service: "kb",
@@ -1279,17 +1405,17 @@ function validateUrl(url2) {
1279
1405
  }
1280
1406
  }
1281
1407
  function buildBody12(ctx) {
1282
- const body2 = {
1408
+ const body3 = {
1283
1409
  name: ctx.str("name"),
1284
1410
  url: ctx.str("url")
1285
1411
  };
1286
1412
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
1287
- if (scope) body2.scope = scope;
1413
+ if (scope) body3.scope = scope;
1288
1414
  const displayName = ctx.str("display-name");
1289
- if (displayName) body2.displayName = displayName;
1415
+ if (displayName) body3.displayName = displayName;
1290
1416
  const parseInstruction = ctx.str("parse-instruction");
1291
- if (parseInstruction) body2.parseInstruction = parseInstruction;
1292
- return body2;
1417
+ if (parseInstruction) body3.parseInstruction = parseInstruction;
1418
+ return body3;
1293
1419
  }
1294
1420
  var url = {
1295
1421
  service: "kb",
@@ -1316,8 +1442,8 @@ var url = {
1316
1442
  };
1317
1443
 
1318
1444
  // src/commands/te-kb/import.ts
1319
- import { promises as fs4 } from "fs";
1320
- import path4 from "path";
1445
+ import { promises as fs5 } from "fs";
1446
+ import path5 from "path";
1321
1447
  var API_PATH15 = "/agent/api/external/knowledge-bases/import";
1322
1448
  var MAX_SNAPSHOT_ARCHIVE_BYTES = 50 * 1024 * 1024;
1323
1449
  var VALID_SCOPES2 = /* @__PURE__ */ new Set(["personal", "company"]);
@@ -1354,16 +1480,16 @@ function normalizeTags2(raw) {
1354
1480
  return tags;
1355
1481
  }
1356
1482
  function validateArchivePath(filePath) {
1357
- if (path4.extname(filePath).toLocaleLowerCase("en-US") !== ".zip") {
1483
+ if (path5.extname(filePath).toLocaleLowerCase("en-US") !== ".zip") {
1358
1484
  throw new Error("--file must point to a .zip archive");
1359
1485
  }
1360
1486
  }
1361
1487
  async function readArchive(filePath) {
1362
1488
  validateArchivePath(filePath);
1363
- const absolutePath = path4.resolve(filePath);
1489
+ const absolutePath = path5.resolve(filePath);
1364
1490
  let stat;
1365
1491
  try {
1366
- stat = await fs4.stat(absolutePath);
1492
+ stat = await fs5.stat(absolutePath);
1367
1493
  } catch {
1368
1494
  throw new Error(`File not found: ${filePath}`);
1369
1495
  }
@@ -1373,7 +1499,7 @@ async function readArchive(filePath) {
1373
1499
  if (stat.size > MAX_SNAPSHOT_ARCHIVE_BYTES) {
1374
1500
  throw new Error("--file must not exceed 50 MB");
1375
1501
  }
1376
- return { absolutePath, bytes: await fs4.readFile(absolutePath) };
1502
+ return { absolutePath, bytes: await fs5.readFile(absolutePath) };
1377
1503
  }
1378
1504
  function appendOptionalFields(ctx, form) {
1379
1505
  const description = ctx.str("description").trim();
@@ -1440,7 +1566,7 @@ var importSnapshot = {
1440
1566
  form.append(
1441
1567
  "file",
1442
1568
  new Blob([Uint8Array.from(archive.bytes)], { type: "application/zip" }),
1443
- path4.basename(archive.absolutePath)
1569
+ path5.basename(archive.absolutePath)
1444
1570
  );
1445
1571
  form.append("name", ctx.str("name").trim());
1446
1572
  form.append("scope", getScope2(ctx));
@@ -1547,8 +1673,8 @@ var importStatus = {
1547
1673
  };
1548
1674
 
1549
1675
  // src/commands/te-kb/source-directory.ts
1550
- import { promises as fs5 } from "fs";
1551
- import path5 from "path";
1676
+ import { promises as fs6 } from "fs";
1677
+ import path6 from "path";
1552
1678
  var sourceFlags = [
1553
1679
  { name: "name", type: "string", required: true, desc: "Knowledge base name (personal then company)" },
1554
1680
  { name: "id", type: "string", required: true, desc: "ZIP source ID copied from +list-sources" }
@@ -1564,9 +1690,9 @@ var revisionFlag2 = {
1564
1690
  var apiOptions2 = { preserveErrorMetadata: true, retryUnauthorized: false };
1565
1691
  var maxFileBytes = 50 * 1024 * 1024;
1566
1692
  function validateIdentity2(ctx) {
1567
- for (const [flag, max] of [["name", 200], ["id", 191]]) {
1568
- const value = ctx.str(flag).trim();
1569
- if (!value || value.length > max) throw new CliValidationError(`Invalid --${flag}.`);
1693
+ for (const [flag2, max] of [["name", 200], ["id", 191]]) {
1694
+ const value = ctx.str(flag2).trim();
1695
+ if (!value || value.length > max) throw new CliValidationError(`Invalid --${flag2}.`);
1570
1696
  }
1571
1697
  }
1572
1698
  function relativePath(ctx, allowRoot = false) {
@@ -1584,14 +1710,14 @@ function validateMutation2(ctx) {
1584
1710
  throw new CliValidationError("--expected-revision must be a positive safe integer.");
1585
1711
  }
1586
1712
  }
1587
- function endpoint(ctx, suffix = "directory") {
1713
+ function endpoint2(ctx, suffix = "directory") {
1588
1714
  return `/agent/api/external/knowledge-bases/sources/${encodeURIComponent(ctx.str("id").trim())}/${suffix}`;
1589
1715
  }
1590
- function query2(ctx) {
1716
+ function query3(ctx) {
1591
1717
  return { name: ctx.str("name").trim(), path: ctx.str("path") };
1592
1718
  }
1593
- function preview(ctx, method, suffix = "directory", body2) {
1594
- return { method, url: `${ctx.host().replace(/\/$/, "")}${endpoint(ctx, suffix)}`, ...body2 ? { body: body2 } : { params: query2(ctx) } };
1719
+ function preview(ctx, method, suffix = "directory", body3) {
1720
+ return { method, url: `${ctx.host().replace(/\/$/, "")}${endpoint2(ctx, suffix)}`, ...body3 ? { body: body3 } : { params: query3(ctx) } };
1595
1721
  }
1596
1722
  function mutationBody(ctx, operation) {
1597
1723
  return { name: ctx.str("name").trim(), expectedRevision: ctx.num("expected-revision"), operations: [operation] };
@@ -1614,9 +1740,9 @@ var sourceLs = {
1614
1740
  throw new CliValidationError("--limit must be an integer from 1 to 200.");
1615
1741
  }
1616
1742
  },
1617
- dryRun: (ctx) => ({ ...preview(ctx, "GET"), params: { ...query2(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} } }),
1618
- execute: (ctx) => kbApi(ctx, "GET", endpoint(ctx), {
1619
- ...query2(ctx),
1743
+ dryRun: (ctx) => ({ ...preview(ctx, "GET"), params: { ...query3(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} } }),
1744
+ execute: (ctx) => kbApi(ctx, "GET", endpoint2(ctx), {
1745
+ ...query3(ctx),
1620
1746
  limit: ctx.num("limit"),
1621
1747
  ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {}
1622
1748
  }, void 0, apiOptions2)
@@ -1639,12 +1765,12 @@ var sourceRead = {
1639
1765
  },
1640
1766
  dryRun: (ctx) => preview(ctx, "GET", "raw"),
1641
1767
  execute: async (ctx) => {
1642
- const result = await kbApi(ctx, "GET", endpoint(ctx, "raw"), query2(ctx), void 0, { ...apiOptions2, responseType: "bytes" });
1768
+ const result = await kbApi(ctx, "GET", endpoint2(ctx, "raw"), query3(ctx), void 0, { ...apiOptions2, responseType: "bytes" });
1643
1769
  const bytes = Buffer.from(result.bytes);
1644
1770
  const metadata = { path: ctx.str("path"), sizeBytes: bytes.length, contentType: result.contentType };
1645
1771
  if (ctx.str("output")) {
1646
- const output = path5.resolve(ctx.str("output"));
1647
- await fs5.writeFile(output, bytes, { flag: "wx" });
1772
+ const output = path6.resolve(ctx.str("output"));
1773
+ await fs6.writeFile(output, bytes, { flag: "wx" });
1648
1774
  return { ...metadata, output };
1649
1775
  }
1650
1776
  if (ctx.str("encoding") === "base64") return { ...metadata, encoding: "base64", content: bytes.toString("base64") };
@@ -1656,8 +1782,8 @@ var sourceRead = {
1656
1782
  }
1657
1783
  };
1658
1784
  async function fileOperation(ctx, dryRun) {
1659
- const file = path5.resolve(ctx.str("file"));
1660
- const handle = await fs5.open(file, "r");
1785
+ const file = path6.resolve(ctx.str("file"));
1786
+ const handle = await fs6.open(file, "r");
1661
1787
  try {
1662
1788
  const stat = await handle.stat();
1663
1789
  if (!stat.isFile() || stat.size > maxFileBytes) throw new CliValidationError("--file must be a regular file of at most 50 MB.");
@@ -1692,7 +1818,7 @@ var sourcePut = {
1692
1818
  if (!["add", "replace"].includes(ctx.str("action"))) throw new CliValidationError("--action must be add or replace.");
1693
1819
  },
1694
1820
  dryRun: async (ctx) => preview(ctx, "POST", "directory", mutationBody(ctx, await fileOperation(ctx, true))),
1695
- execute: async (ctx) => kbApi(ctx, "POST", endpoint(ctx), {}, mutationBody(ctx, await fileOperation(ctx, false)), apiOptions2)
1821
+ execute: async (ctx) => kbApi(ctx, "POST", endpoint2(ctx), {}, mutationBody(ctx, await fileOperation(ctx, false)), apiOptions2)
1696
1822
  };
1697
1823
  function deleteOperation(ctx) {
1698
1824
  return { action: "delete", path: ctx.str("path"), confirmed: true, ...ctx.bool("recursive") ? { recursive: true } : {} };
@@ -1710,15 +1836,15 @@ var sourceRm = {
1710
1836
  ],
1711
1837
  validate: validateMutation2,
1712
1838
  dryRun: (ctx) => preview(ctx, "POST", "directory", mutationBody(ctx, deleteOperation(ctx))),
1713
- execute: (ctx) => kbApi(ctx, "POST", endpoint(ctx), {}, mutationBody(ctx, deleteOperation(ctx)), apiOptions2)
1839
+ execute: (ctx) => kbApi(ctx, "POST", endpoint2(ctx), {}, mutationBody(ctx, deleteOperation(ctx)), apiOptions2)
1714
1840
  };
1715
1841
 
1716
1842
  // src/commands/te-kb/version-management.ts
1717
- import { promises as fs6 } from "fs";
1718
- import path6 from "path";
1843
+ import { promises as fs7 } from "fs";
1844
+ import path7 from "path";
1719
1845
  var API2 = "/agent/api/external/knowledge-bases/versions";
1720
1846
  var apiOptions3 = { preserveErrorMetadata: true, retryUnauthorized: false };
1721
- var targetFlags = [
1847
+ var targetFlags2 = [
1722
1848
  { name: "name", type: "string", required: true, minLength: 1, maxLength: 200, desc: "Exact knowledge base name copied from +list" },
1723
1849
  { name: "scope", type: "string", desc: "Exact personal or company scope; omit for personal then company lookup" }
1724
1850
  ];
@@ -1729,9 +1855,9 @@ var pagingFlags = [
1729
1855
  { name: "limit", type: "number", default: 100, min: 1, max: 200, desc: "Page size from 1 to 200" }
1730
1856
  ];
1731
1857
  var pathFlag2 = { name: "path", type: "string", desc: "Exact path relative to the historical source directory" };
1732
- function positiveInteger2(ctx, flag) {
1733
- const value = ctx.num(flag);
1734
- if (!Number.isSafeInteger(value) || value < 1 || value > 2147483647) throw new CliValidationError(`--${flag} must be a positive integer no greater than 2147483647.`);
1858
+ function positiveInteger2(ctx, flag2) {
1859
+ const value = ctx.num(flag2);
1860
+ if (!Number.isSafeInteger(value) || value < 1 || value > 2147483647) throw new CliValidationError(`--${flag2} must be a positive integer no greater than 2147483647.`);
1735
1861
  return value;
1736
1862
  }
1737
1863
  function validateTarget(ctx) {
@@ -1760,12 +1886,12 @@ function validatePath(ctx, required = false) {
1760
1886
  throw new CliValidationError("--path must be a normalized relative path inside the historical source.");
1761
1887
  }
1762
1888
  }
1763
- function query3(ctx) {
1889
+ function query4(ctx) {
1764
1890
  const scope = getExternalKnowledgeBaseTargetScope(ctx);
1765
1891
  return { name: ctx.str("name").trim(), ...scope ? { scope } : {} };
1766
1892
  }
1767
1893
  function pageQuery(ctx) {
1768
- return { ...query3(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} };
1894
+ return { ...query4(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} };
1769
1895
  }
1770
1896
  function versionEndpoint(ctx, suffix = "") {
1771
1897
  return `${API2}/${positiveInteger2(ctx, "version")}${suffix}`;
@@ -1773,15 +1899,15 @@ function versionEndpoint(ctx, suffix = "") {
1773
1899
  function sourceEndpoint2(ctx, action) {
1774
1900
  return versionEndpoint(ctx, `/sources/${encodeURIComponent(ctx.str("id").trim())}/${action}`);
1775
1901
  }
1776
- function preview2(ctx, endpoint2, params, body2) {
1777
- return { method: body2 ? "POST" : "GET", url: `${ctx.host().replace(/\/$/, "")}${endpoint2}`, params, ...body2 ? { body: body2 } : {} };
1902
+ function preview2(ctx, endpoint3, params, body3) {
1903
+ return { method: body3 ? "POST" : "GET", url: `${ctx.host().replace(/\/$/, "")}${endpoint3}`, params, ...body3 ? { body: body3 } : {} };
1778
1904
  }
1779
1905
  var versions = {
1780
1906
  service: "kb",
1781
1907
  command: "+versions",
1782
1908
  risk: "read",
1783
1909
  description: "List immutable published versions and the latest version ID, one page at a time.",
1784
- flags: [...targetFlags, ...pagingFlags],
1910
+ flags: [...targetFlags2, ...pagingFlags],
1785
1911
  validate: (ctx) => {
1786
1912
  validateTarget(ctx);
1787
1913
  validatePage(ctx);
@@ -1795,17 +1921,17 @@ var versionShow = {
1795
1921
  command: "+version-show",
1796
1922
  risk: "read",
1797
1923
  description: "Read one published version summary without reading current sources.",
1798
- flags: [...targetFlags, versionFlag],
1924
+ flags: [...targetFlags2, versionFlag],
1799
1925
  validate: validateVersion,
1800
- dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx), query3(ctx)),
1801
- execute: (ctx) => kbApi(ctx, "GET", versionEndpoint(ctx), query3(ctx), void 0, apiOptions3)
1926
+ dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx), query4(ctx)),
1927
+ execute: (ctx) => kbApi(ctx, "GET", versionEndpoint(ctx), query4(ctx), void 0, apiOptions3)
1802
1928
  };
1803
1929
  var versionSources = {
1804
1930
  service: "kb",
1805
1931
  command: "+version-sources",
1806
1932
  risk: "read",
1807
1933
  description: "List historical sources and stable IDs from one immutable version.",
1808
- flags: [...targetFlags, versionFlag, ...pagingFlags, { name: "source-type", type: "string", desc: "Optional source type filter: file | url | zip" }],
1934
+ flags: [...targetFlags2, versionFlag, ...pagingFlags, { name: "source-type", type: "string", desc: "Optional source type filter: file | url | zip" }],
1809
1935
  validate: (ctx) => {
1810
1936
  validateVersion(ctx);
1811
1937
  validatePage(ctx);
@@ -1819,21 +1945,21 @@ var versionDiff = {
1819
1945
  command: "+version-diff",
1820
1946
  risk: "read",
1821
1947
  description: "Compare historical source additions, deletions, content, and metadata between two versions.",
1822
- flags: [...targetFlags, { ...versionFlag, name: "from", desc: "Before version number" }, { ...versionFlag, name: "to", desc: "After version number" }],
1948
+ flags: [...targetFlags2, { ...versionFlag, name: "from", desc: "Before version number" }, { ...versionFlag, name: "to", desc: "After version number" }],
1823
1949
  validate: (ctx) => {
1824
1950
  validateTarget(ctx);
1825
1951
  positiveInteger2(ctx, "from");
1826
1952
  positiveInteger2(ctx, "to");
1827
1953
  },
1828
- dryRun: (ctx) => preview2(ctx, `${API2}/compare`, { ...query3(ctx), from: ctx.num("from"), to: ctx.num("to") }),
1829
- execute: (ctx) => kbApi(ctx, "GET", `${API2}/compare`, { ...query3(ctx), from: ctx.num("from"), to: ctx.num("to") }, void 0, apiOptions3)
1954
+ dryRun: (ctx) => preview2(ctx, `${API2}/compare`, { ...query4(ctx), from: ctx.num("from"), to: ctx.num("to") }),
1955
+ execute: (ctx) => kbApi(ctx, "GET", `${API2}/compare`, { ...query4(ctx), from: ctx.num("from"), to: ctx.num("to") }, void 0, apiOptions3)
1830
1956
  };
1831
1957
  var versionTree = {
1832
1958
  service: "kb",
1833
1959
  command: "+version-tree",
1834
1960
  risk: "read",
1835
1961
  description: "List a historical ZIP or URL source directory without changing current files.",
1836
- flags: [...targetFlags, versionFlag, sourceFlag, pathFlag2, ...pagingFlags],
1962
+ flags: [...targetFlags2, versionFlag, sourceFlag, pathFlag2, ...pagingFlags],
1837
1963
  validate: (ctx) => {
1838
1964
  validateSource(ctx);
1839
1965
  validatePath(ctx);
@@ -1847,30 +1973,30 @@ var versionRead = {
1847
1973
  command: "+version-read",
1848
1974
  risk: "read",
1849
1975
  description: "Preview one historical directory child file; unsupported or oversized files return metadata only.",
1850
- flags: [...targetFlags, versionFlag, sourceFlag, { ...pathFlag2, required: true }],
1976
+ flags: [...targetFlags2, versionFlag, sourceFlag, { ...pathFlag2, required: true }],
1851
1977
  validate: (ctx) => {
1852
1978
  validateSource(ctx);
1853
1979
  validatePath(ctx, true);
1854
1980
  },
1855
- dryRun: (ctx) => preview2(ctx, sourceEndpoint2(ctx, "file"), { ...query3(ctx), path: ctx.str("path") }),
1856
- execute: (ctx) => kbApi(ctx, "GET", sourceEndpoint2(ctx, "file"), { ...query3(ctx), path: ctx.str("path") }, void 0, apiOptions3)
1981
+ dryRun: (ctx) => preview2(ctx, sourceEndpoint2(ctx, "file"), { ...query4(ctx), path: ctx.str("path") }),
1982
+ execute: (ctx) => kbApi(ctx, "GET", sourceEndpoint2(ctx, "file"), { ...query4(ctx), path: ctx.str("path") }, void 0, apiOptions3)
1857
1983
  };
1858
1984
  var versionDownload = {
1859
1985
  service: "kb",
1860
1986
  command: "+version-download",
1861
1987
  risk: "read",
1862
1988
  description: "Download one ordinary historical file source to a new local file. ZIP/URL directories cannot be downloaded.",
1863
- flags: [...targetFlags, versionFlag, sourceFlag, { name: "output", type: "string", required: true, desc: "New local output path; existing files are never overwritten" }],
1989
+ flags: [...targetFlags2, versionFlag, sourceFlag, { name: "output", type: "string", required: true, desc: "New local output path; existing files are never overwritten" }],
1864
1990
  validate: (ctx) => {
1865
1991
  validateSource(ctx);
1866
1992
  if (!ctx.str("output").trim()) throw new CliValidationError("--output is required.");
1867
1993
  },
1868
- dryRun: (ctx) => ({ ...preview2(ctx, sourceEndpoint2(ctx, "raw"), query3(ctx)), output: path6.resolve(ctx.str("output")) }),
1994
+ dryRun: (ctx) => ({ ...preview2(ctx, sourceEndpoint2(ctx, "raw"), query4(ctx)), output: path7.resolve(ctx.str("output")) }),
1869
1995
  execute: async (ctx) => {
1870
- const result = await kbApi(ctx, "GET", sourceEndpoint2(ctx, "raw"), query3(ctx), void 0, { ...apiOptions3, responseType: "bytes" });
1871
- const output = path6.resolve(ctx.str("output"));
1996
+ const result = await kbApi(ctx, "GET", sourceEndpoint2(ctx, "raw"), query4(ctx), void 0, { ...apiOptions3, responseType: "bytes" });
1997
+ const output = path7.resolve(ctx.str("output"));
1872
1998
  const bytes = Buffer.from(result.bytes);
1873
- await fs6.writeFile(output, bytes, { flag: "wx" });
1999
+ await fs7.writeFile(output, bytes, { flag: "wx" });
1874
2000
  return { versionNumber: ctx.num("version"), sourceId: ctx.str("id").trim(), sizeBytes: String(bytes.length), output };
1875
2001
  }
1876
2002
  };
@@ -1883,7 +2009,7 @@ var rollback = {
1883
2009
  risk: "high-risk-write",
1884
2010
  description: "Restore an earlier version as a new publication. Replace target-source drafts, delete other compiled sources, and preserve unpublished additions. Reuse request-id on network retries.",
1885
2011
  flags: [
1886
- ...targetFlags,
2012
+ ...targetFlags2,
1887
2013
  versionFlag,
1888
2014
  { name: "request-id", type: "string", required: true, maxLength: 191, desc: "Caller-generated stable ASCII request ID; reuse exactly for retries of this logical operation" },
1889
2015
  { name: "expected-latest-version-id", type: "string", required: true, maxLength: 191, desc: "latestVersionId returned by +versions; conflicts require fresh discovery and a new intentional request" }
@@ -1894,25 +2020,26 @@ var rollback = {
1894
2020
  const latest = ctx.str("expected-latest-version-id");
1895
2021
  if (!latest || latest.length > 191) throw new CliValidationError("--expected-latest-version-id must contain 1 to 191 characters.");
1896
2022
  },
1897
- dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx, "/rollback"), query3(ctx), rollbackBody(ctx)),
1898
- execute: (ctx) => kbApi(ctx, "POST", versionEndpoint(ctx, "/rollback"), query3(ctx), rollbackBody(ctx), apiOptions3)
2023
+ dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx, "/rollback"), query4(ctx), rollbackBody(ctx)),
2024
+ execute: (ctx) => kbApi(ctx, "POST", versionEndpoint(ctx, "/rollback"), query4(ctx), rollbackBody(ctx), apiOptions3)
1899
2025
  };
1900
2026
  var rollbackStatus = {
1901
2027
  service: "kb",
1902
2028
  command: "+rollback-status",
1903
2029
  risk: "read",
1904
2030
  description: "Read one persisted rollback operation without polling. A running operation with errorCode requires administrator review; never retry it as a new write.",
1905
- flags: [...targetFlags, { name: "operation-id", type: "string", required: true, minLength: 1, maxLength: 191, desc: "operationId returned by +rollback" }],
2031
+ flags: [...targetFlags2, { name: "operation-id", type: "string", required: true, minLength: 1, maxLength: 191, desc: "operationId returned by +rollback" }],
1906
2032
  validate: (ctx) => {
1907
2033
  validateTarget(ctx);
1908
2034
  if (!ctx.str("operation-id").trim() || ctx.str("operation-id").length > 191) throw new CliValidationError("--operation-id must contain 1 to 191 characters.");
1909
2035
  },
1910
- dryRun: (ctx) => preview2(ctx, `${API2}/operations/${encodeURIComponent(ctx.str("operation-id").trim())}`, query3(ctx)),
1911
- execute: (ctx) => kbApi(ctx, "GET", `${API2}/operations/${encodeURIComponent(ctx.str("operation-id").trim())}`, query3(ctx), void 0, apiOptions3)
2036
+ dryRun: (ctx) => preview2(ctx, `${API2}/operations/${encodeURIComponent(ctx.str("operation-id").trim())}`, query4(ctx)),
2037
+ execute: (ctx) => kbApi(ctx, "GET", `${API2}/operations/${encodeURIComponent(ctx.str("operation-id").trim())}`, query4(ctx), void 0, apiOptions3)
1912
2038
  };
1913
2039
 
1914
2040
  // src/commands/te-kb/index.ts
1915
2041
  var commands = [
2042
+ ...schemaImportCommands,
1916
2043
  sourceCheckUpdates,
1917
2044
  sourceReplace,
1918
2045
  sourceRestore,
@@ -1958,6 +2085,7 @@ export {
1958
2085
  compile,
1959
2086
  create,
1960
2087
  te_kb_default as default,
2088
+ executeSchemaImport,
1961
2089
  importSnapshot,
1962
2090
  importStatus,
1963
2091
  kbGrep,
@@ -1970,6 +2098,19 @@ export {
1970
2098
  rollback,
1971
2099
  rollbackStatus,
1972
2100
  schema,
2101
+ schemaDownload,
2102
+ schemaImport,
2103
+ schemaImportAbandon,
2104
+ schemaImportApply,
2105
+ schemaImportCommands,
2106
+ schemaImportContent,
2107
+ schemaImportDiff,
2108
+ schemaImportList,
2109
+ schemaImportOptimize,
2110
+ schemaImportReject,
2111
+ schemaImportSave,
2112
+ schemaImportStatus,
2113
+ schemaImportValidate,
1973
2114
  sourceCancel,
1974
2115
  sourceCheckUpdates,
1975
2116
  sourceCommit,
@@ -1988,5 +2129,6 @@ export {
1988
2129
  versionShow,
1989
2130
  versionSources,
1990
2131
  versionTree,
1991
- versions
2132
+ versions,
2133
+ waitSchemaImport
1992
2134
  };