@kweaver-ai/kweaver-sdk 0.7.4 → 0.8.2

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 (190) hide show
  1. package/README.md +39 -5
  2. package/README.zh.md +37 -5
  3. package/dist/agent-providers/index.d.ts +7 -0
  4. package/dist/agent-providers/index.js +5 -0
  5. package/dist/agent-providers/prompt-template.d.ts +62 -0
  6. package/dist/agent-providers/prompt-template.js +105 -0
  7. package/dist/agent-providers/prompts/rubric-judge-v1.prompt.md +51 -0
  8. package/dist/agent-providers/prompts/within-trace-synthesizer-v1.prompt.md +60 -0
  9. package/dist/agent-providers/providers/claude-code-subprocess.d.ts +74 -0
  10. package/dist/agent-providers/providers/claude-code-subprocess.js +259 -0
  11. package/dist/agent-providers/providers/stub.d.ts +47 -0
  12. package/dist/agent-providers/providers/stub.js +77 -0
  13. package/dist/agent-providers/registry.d.ts +45 -0
  14. package/dist/agent-providers/registry.js +77 -0
  15. package/dist/agent-providers/types.d.ts +91 -0
  16. package/dist/agent-providers/types.js +25 -0
  17. package/dist/api/agent-chat.js +8 -6
  18. package/dist/api/agent-observability.d.ts +51 -0
  19. package/dist/api/agent-observability.js +108 -0
  20. package/dist/api/context-loader.d.ts +1 -0
  21. package/dist/api/conversations.d.ts +4 -8
  22. package/dist/api/conversations.js +16 -58
  23. package/dist/api/datasources.d.ts +2 -20
  24. package/dist/api/datasources.js +7 -123
  25. package/dist/api/semantic-search.d.ts +5 -0
  26. package/dist/api/semantic-search.js +5 -0
  27. package/dist/api/skills.d.ts +75 -2
  28. package/dist/api/skills.js +108 -12
  29. package/dist/api/trace.d.ts +49 -0
  30. package/dist/api/trace.js +85 -0
  31. package/dist/api/vega.d.ts +53 -0
  32. package/dist/api/vega.js +144 -0
  33. package/dist/cli.js +12 -5
  34. package/dist/commands/agent/mode.d.ts +6 -0
  35. package/dist/commands/agent/mode.js +75 -0
  36. package/dist/commands/agent.js +101 -29
  37. package/dist/commands/bkn-ops.js +12 -6
  38. package/dist/commands/bkn-utils.d.ts +9 -0
  39. package/dist/commands/bkn-utils.js +17 -0
  40. package/dist/commands/context-loader.js +608 -38
  41. package/dist/commands/ds.js +7 -2
  42. package/dist/commands/skill.d.ts +21 -1
  43. package/dist/commands/skill.js +389 -1
  44. package/dist/commands/trace.d.ts +39 -0
  45. package/dist/commands/trace.js +668 -0
  46. package/dist/index.d.ts +2 -2
  47. package/dist/index.js +1 -1
  48. package/dist/resources/bkn.d.ts +5 -0
  49. package/dist/resources/bkn.js +5 -0
  50. package/dist/resources/datasources.js +2 -1
  51. package/dist/resources/skills.d.ts +17 -1
  52. package/dist/resources/skills.js +32 -1
  53. package/dist/trace-ai/diagnose/agent-binding.d.ts +67 -0
  54. package/dist/trace-ai/diagnose/agent-binding.js +257 -0
  55. package/dist/trace-ai/diagnose/builtin-rules/excessive-tool-calls-per-turn.d.ts +2 -0
  56. package/dist/trace-ai/diagnose/builtin-rules/excessive-tool-calls-per-turn.js +15 -0
  57. package/dist/trace-ai/diagnose/builtin-rules/excessive-tool-calls-per-turn.yaml +16 -0
  58. package/dist/trace-ai/diagnose/builtin-rules/llm-response-truncated-no-continue.d.ts +2 -0
  59. package/dist/trace-ai/diagnose/builtin-rules/llm-response-truncated-no-continue.js +44 -0
  60. package/dist/trace-ai/diagnose/builtin-rules/llm-response-truncated-no-continue.yaml +15 -0
  61. package/dist/trace-ai/diagnose/builtin-rules/register.d.ts +1 -0
  62. package/dist/trace-ai/diagnose/builtin-rules/register.js +11 -0
  63. package/dist/trace-ai/diagnose/builtin-rules/retrieval-empty-no-fallback.d.ts +2 -0
  64. package/dist/trace-ai/diagnose/builtin-rules/retrieval-empty-no-fallback.js +29 -0
  65. package/dist/trace-ai/diagnose/builtin-rules/retrieval-empty-no-fallback.yaml +15 -0
  66. package/dist/trace-ai/diagnose/builtin-rules/tool-error-swallowed.d.ts +2 -0
  67. package/dist/trace-ai/diagnose/builtin-rules/tool-error-swallowed.js +45 -0
  68. package/dist/trace-ai/diagnose/builtin-rules/tool-error-swallowed.yaml +15 -0
  69. package/dist/trace-ai/diagnose/builtin-rules/tool-loop-no-state-change.d.ts +2 -0
  70. package/dist/trace-ai/diagnose/builtin-rules/tool-loop-no-state-change.js +38 -0
  71. package/dist/trace-ai/diagnose/builtin-rules/tool-loop-no-state-change.yaml +16 -0
  72. package/dist/trace-ai/diagnose/builtin-rules/tool-retry-intent-mismatch.yaml +68 -0
  73. package/dist/trace-ai/diagnose/index.d.ts +32 -0
  74. package/dist/trace-ai/diagnose/index.js +246 -0
  75. package/dist/trace-ai/diagnose/output-schema-converter.d.ts +24 -0
  76. package/dist/trace-ai/diagnose/output-schema-converter.js +81 -0
  77. package/dist/trace-ai/diagnose/predicate-registry.d.ts +7 -0
  78. package/dist/trace-ai/diagnose/predicate-registry.js +30 -0
  79. package/dist/trace-ai/diagnose/query-extractor.d.ts +14 -0
  80. package/dist/trace-ai/diagnose/query-extractor.js +45 -0
  81. package/dist/trace-ai/diagnose/report-assembler.d.ts +31 -0
  82. package/dist/trace-ai/diagnose/report-assembler.js +100 -0
  83. package/dist/trace-ai/diagnose/report-markdown.d.ts +18 -0
  84. package/dist/trace-ai/diagnose/report-markdown.js +192 -0
  85. package/dist/trace-ai/diagnose/rule-loader.d.ts +11 -0
  86. package/dist/trace-ai/diagnose/rule-loader.js +120 -0
  87. package/dist/trace-ai/diagnose/schemas.d.ts +184 -0
  88. package/dist/trace-ai/diagnose/schemas.js +154 -0
  89. package/dist/trace-ai/diagnose/signal-probe.d.ts +17 -0
  90. package/dist/trace-ai/diagnose/signal-probe.js +39 -0
  91. package/dist/trace-ai/diagnose/synthesizer-agent.d.ts +40 -0
  92. package/dist/trace-ai/diagnose/synthesizer-agent.js +158 -0
  93. package/dist/trace-ai/diagnose/synthesizer-template.d.ts +2 -0
  94. package/dist/trace-ai/diagnose/synthesizer-template.js +49 -0
  95. package/dist/trace-ai/diagnose/trace-shaper.d.ts +3 -0
  96. package/dist/trace-ai/diagnose/trace-shaper.js +73 -0
  97. package/dist/trace-ai/diagnose/types.d.ts +173 -0
  98. package/dist/trace-ai/diagnose/types.js +1 -0
  99. package/dist/trace-ai/eval-set/assertion-evaluator.d.ts +29 -0
  100. package/dist/trace-ai/eval-set/assertion-evaluator.js +100 -0
  101. package/dist/trace-ai/eval-set/builder.d.ts +36 -0
  102. package/dist/trace-ai/eval-set/builder.js +126 -0
  103. package/dist/trace-ai/eval-set/index.d.ts +15 -0
  104. package/dist/trace-ai/eval-set/index.js +10 -0
  105. package/dist/trace-ai/eval-set/output-writer.d.ts +27 -0
  106. package/dist/trace-ai/eval-set/output-writer.js +126 -0
  107. package/dist/trace-ai/eval-set/query-picker.d.ts +37 -0
  108. package/dist/trace-ai/eval-set/query-picker.js +147 -0
  109. package/dist/trace-ai/eval-set/redactor.d.ts +42 -0
  110. package/dist/trace-ai/eval-set/redactor.js +133 -0
  111. package/dist/trace-ai/eval-set/rubric-templates/answer-match-reference.prompt.md +19 -0
  112. package/dist/trace-ai/eval-set/schemas.d.ts +136 -0
  113. package/dist/trace-ai/eval-set/schemas.js +130 -0
  114. package/dist/trace-ai/eval-set/semantic-match-provider.d.ts +33 -0
  115. package/dist/trace-ai/eval-set/semantic-match-provider.js +51 -0
  116. package/dist/trace-ai/eval-set/test-runner.d.ts +34 -0
  117. package/dist/trace-ai/eval-set/test-runner.js +153 -0
  118. package/dist/trace-ai/eval-set/types.d.ts +46 -0
  119. package/dist/trace-ai/eval-set/types.js +8 -0
  120. package/dist/trace-ai/exp/bundle-writer.d.ts +10 -0
  121. package/dist/trace-ai/exp/bundle-writer.js +54 -0
  122. package/dist/trace-ai/exp/claude-binary.d.ts +5 -0
  123. package/dist/trace-ai/exp/claude-binary.js +30 -0
  124. package/dist/trace-ai/exp/coordinator.d.ts +45 -0
  125. package/dist/trace-ai/exp/coordinator.js +203 -0
  126. package/dist/trace-ai/exp/eval-runner.d.ts +14 -0
  127. package/dist/trace-ai/exp/eval-runner.js +47 -0
  128. package/dist/trace-ai/exp/exp-store/abort-signal.d.ts +3 -0
  129. package/dist/trace-ai/exp/exp-store/abort-signal.js +27 -0
  130. package/dist/trace-ai/exp/exp-store/candidate-lineage-yaml.d.ts +4 -0
  131. package/dist/trace-ai/exp/exp-store/candidate-lineage-yaml.js +37 -0
  132. package/dist/trace-ai/exp/exp-store/events-jsonl.d.ts +17 -0
  133. package/dist/trace-ai/exp/exp-store/events-jsonl.js +60 -0
  134. package/dist/trace-ai/exp/exp-store/exp-registry.d.ts +6 -0
  135. package/dist/trace-ai/exp/exp-store/exp-registry.js +41 -0
  136. package/dist/trace-ai/exp/exp-store/index.d.ts +46 -0
  137. package/dist/trace-ai/exp/exp-store/index.js +59 -0
  138. package/dist/trace-ai/exp/exp-store/lock.d.ts +3 -0
  139. package/dist/trace-ai/exp/exp-store/lock.js +73 -0
  140. package/dist/trace-ai/exp/exp-store/mission-md.d.ts +3 -0
  141. package/dist/trace-ai/exp/exp-store/mission-md.js +37 -0
  142. package/dist/trace-ai/exp/exp-store/readme-template.d.ts +5 -0
  143. package/dist/trace-ai/exp/exp-store/readme-template.js +25 -0
  144. package/dist/trace-ai/exp/exp-store/round-yaml.d.ts +3 -0
  145. package/dist/trace-ai/exp/exp-store/round-yaml.js +33 -0
  146. package/dist/trace-ai/exp/index.d.ts +8 -0
  147. package/dist/trace-ai/exp/index.js +238 -0
  148. package/dist/trace-ai/exp/info.d.ts +35 -0
  149. package/dist/trace-ai/exp/info.js +120 -0
  150. package/dist/trace-ai/exp/patch/agent-config.d.ts +1 -0
  151. package/dist/trace-ai/exp/patch/agent-config.js +26 -0
  152. package/dist/trace-ai/exp/patch/index.d.ts +2 -0
  153. package/dist/trace-ai/exp/patch/index.js +13 -0
  154. package/dist/trace-ai/exp/patch/skill.d.ts +1 -0
  155. package/dist/trace-ai/exp/patch/skill.js +24 -0
  156. package/dist/trace-ai/exp/providers/synthesizer-client.d.ts +14 -0
  157. package/dist/trace-ai/exp/providers/synthesizer-client.js +39 -0
  158. package/dist/trace-ai/exp/providers/triage-client.d.ts +19 -0
  159. package/dist/trace-ai/exp/providers/triage-client.js +51 -0
  160. package/dist/trace-ai/exp/schemas.d.ts +147 -0
  161. package/dist/trace-ai/exp/schemas.js +50 -0
  162. package/dist/trace-ai/exp/scoring.d.ts +2 -0
  163. package/dist/trace-ai/exp/scoring.js +46 -0
  164. package/dist/trace-ai/scan/aggregator.d.ts +20 -0
  165. package/dist/trace-ai/scan/aggregator.js +26 -0
  166. package/dist/trace-ai/scan/artifacts/paths.d.ts +12 -0
  167. package/dist/trace-ai/scan/artifacts/paths.js +18 -0
  168. package/dist/trace-ai/scan/artifacts/writer.d.ts +67 -0
  169. package/dist/trace-ai/scan/artifacts/writer.js +96 -0
  170. package/dist/trace-ai/scan/batched-rubric.d.ts +55 -0
  171. package/dist/trace-ai/scan/batched-rubric.js +159 -0
  172. package/dist/trace-ai/scan/cross-trace-synthesizer.d.ts +24 -0
  173. package/dist/trace-ai/scan/cross-trace-synthesizer.js +93 -0
  174. package/dist/trace-ai/scan/index.d.ts +31 -0
  175. package/dist/trace-ai/scan/index.js +390 -0
  176. package/dist/trace-ai/scan/prompts/builtin/cross-trace-synthesizer-v1.prompt.md +44 -0
  177. package/dist/trace-ai/scan/prompts/builtin/rubric-judge-batch-v1.prompt.md +44 -0
  178. package/dist/trace-ai/scan/runner.d.ts +25 -0
  179. package/dist/trace-ai/scan/runner.js +42 -0
  180. package/dist/trace-ai/scan/sampler.d.ts +18 -0
  181. package/dist/trace-ai/scan/sampler.js +81 -0
  182. package/dist/trace-ai/scan/scan-summary-markdown.d.ts +2 -0
  183. package/dist/trace-ai/scan/scan-summary-markdown.js +71 -0
  184. package/dist/trace-ai/scan/scan-summary-schema.d.ts +73 -0
  185. package/dist/trace-ai/scan/scan-summary-schema.js +61 -0
  186. package/dist/trace-ai/scan/single-agent-validator.d.ts +23 -0
  187. package/dist/trace-ai/scan/single-agent-validator.js +42 -0
  188. package/dist/trace-ai/scan/traces-list-parser.d.ts +15 -0
  189. package/dist/trace-ai/scan/traces-list-parser.js +46 -0
  190. package/package.json +14 -4
@@ -3,9 +3,11 @@ import { statSync } from "node:fs";
3
3
  import { glob } from "node:fs/promises";
4
4
  import { resolve as resolvePath } from "node:path";
5
5
  import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/oauth.js";
6
- import { testDatasource, createDatasource, listDatasources, getDatasource, deleteDatasource, listTablesWithColumns, scanMetadata, } from "../api/datasources.js";
6
+ import { testDatasource, createDatasource, listDatasources, getDatasource, deleteDatasource, } from "../api/datasources.js";
7
+ import { listTablesWithColumns, scanMetadata } from "../api/vega.js";
7
8
  import { formatCallOutput } from "./call.js";
8
9
  import { resolveBusinessDomain } from "../config/store.js";
10
+ import { assertVegaCatalogId } from "./bkn-utils.js";
9
11
  import { parseCsvFile, buildTableName, splitBatches, buildFieldMappings, buildDagBody, } from "./import-csv.js";
10
12
  import { executeDataflow } from "../api/dataflow.js";
11
13
  function confirmYes(prompt) {
@@ -196,9 +198,12 @@ async function runDsTablesCommand(args) {
196
198
  id = arg;
197
199
  }
198
200
  if (!id) {
199
- console.error("Usage: kweaver ds tables <id> [--keyword X]");
201
+ console.error("Usage: kweaver ds tables <vega-catalog-id> [--keyword X]\n" +
202
+ " <vega-catalog-id> is a vega catalog id (use `kweaver vega catalog list` to find one;\n" +
203
+ " legacy data-connection datasource UUIDs are no longer accepted).");
200
204
  return 1;
201
205
  }
206
+ assertVegaCatalogId(id);
202
207
  const token = await ensureValidToken();
203
208
  const body = await listTablesWithColumns({
204
209
  baseUrl: token.baseUrl,
@@ -1,4 +1,4 @@
1
- import { type SkillStatus } from "../api/skills.js";
1
+ import { type SkillCategory, type SkillStatus } from "../api/skills.js";
2
2
  interface BaseOptions {
3
3
  businessDomain: string;
4
4
  pretty: boolean;
@@ -20,7 +20,27 @@ interface RegisterOptions extends BaseOptions {
20
20
  source?: string;
21
21
  extendInfo?: Record<string, unknown>;
22
22
  }
23
+ interface UpdateMetadataOptions extends BaseOptions {
24
+ skillId: string;
25
+ name: string;
26
+ description: string;
27
+ category: SkillCategory;
28
+ source?: string;
29
+ extendInfo?: Record<string, unknown>;
30
+ }
31
+ interface UpdatePackageOptions extends BaseOptions {
32
+ skillId: string;
33
+ contentFile?: string;
34
+ zipFile?: string;
35
+ }
36
+ interface HistoryVersionOptions extends BaseOptions {
37
+ skillId: string;
38
+ version: string;
39
+ }
23
40
  export declare function parseSkillListArgs(args: string[]): ListOptions;
24
41
  export declare function parseSkillRegisterArgs(args: string[]): RegisterOptions;
42
+ export declare function parseSkillUpdateMetadataArgs(args: string[]): UpdateMetadataOptions;
43
+ export declare function parseSkillUpdatePackageArgs(args: string[]): UpdatePackageOptions;
44
+ export declare function parseSkillHistoryVersionArgs(args: string[], commandName: string): HistoryVersionOptions;
25
45
  export declare function runSkillCommand(args: string[]): Promise<number>;
26
46
  export {};
@@ -2,7 +2,7 @@ import { mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
2
2
  import { basename, dirname, resolve } from "node:path";
3
3
  import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/oauth.js";
4
4
  import { resolveBusinessDomain } from "../config/store.js";
5
- import { deleteSkill, downloadSkill, fetchSkillContent, fetchSkillFile, getSkill, getSkillContentIndex, installSkillArchive, listSkillMarket, listSkills, readSkillFile, registerSkillZip, updateSkillStatus, } from "../api/skills.js";
5
+ import { deleteSkill, downloadSkill, downloadSkillManagementArchive, fetchSkillContent, fetchSkillFile, getSkill, getSkillMarketDetail, getSkillContentIndex, getSkillManagementContent, installSkillArchive, listSkillMarket, listSkillHistory, listSkills, publishSkillHistory, readSkillFile, readSkillManagementFile, republishSkillHistory, registerSkillZip, updateSkillMetadata, updateSkillPackageContent, updateSkillPackageZip, updateSkillStatus, } from "../api/skills.js";
6
6
  import { bundleSkillDirectoryToZip, bundleSkillFileToZip } from "../utils/skill-bundle.js";
7
7
  function printSkillHelp(subcommand) {
8
8
  if (subcommand === "list") {
@@ -19,6 +19,10 @@ function printSkillHelp(subcommand) {
19
19
  console.log("kweaver skill get <skill-id> [-bd value] [--pretty|--compact]");
20
20
  return;
21
21
  }
22
+ if (subcommand === "market-get") {
23
+ console.log("kweaver skill market-get <skill-id> [-bd value] [--pretty|--compact]");
24
+ return;
25
+ }
22
26
  if (subcommand === "register") {
23
27
  console.log(`kweaver skill register (--content-file <path> | --zip-file <path>)
24
28
  [--source src] [--extend-info json] [-bd value] [--pretty|--compact]
@@ -40,6 +44,28 @@ function printSkillHelp(subcommand) {
40
44
  console.log("kweaver skill delete <skill-id> [-y|--yes] [-bd value] [--pretty|--compact]");
41
45
  return;
42
46
  }
47
+ if (subcommand === "update-metadata") {
48
+ console.log(`kweaver skill update-metadata <skill-id> --name <name> --description <text> --category <other_category|system>
49
+ [--source <custom|internal>] [--extend-info json] [-bd value] [--pretty|--compact]`);
50
+ return;
51
+ }
52
+ if (subcommand === "update-package") {
53
+ console.log(`kweaver skill update-package <skill-id> (--content-file <path> | --zip-file <path>)
54
+ [-bd value] [--pretty|--compact]`);
55
+ return;
56
+ }
57
+ if (subcommand === "history") {
58
+ console.log("kweaver skill history <skill-id> [-bd value] [--pretty|--compact]");
59
+ return;
60
+ }
61
+ if (subcommand === "republish") {
62
+ console.log("kweaver skill republish <skill-id> --version <version> [-bd value] [--pretty|--compact]");
63
+ return;
64
+ }
65
+ if (subcommand === "publish-history") {
66
+ console.log("kweaver skill publish-history <skill-id> --version <version> [-bd value] [--pretty|--compact]");
67
+ return;
68
+ }
43
69
  if (subcommand === "content") {
44
70
  console.log("kweaver skill content <skill-id> [--raw] [--output file] [-bd value] [--pretty|--compact]");
45
71
  return;
@@ -56,24 +82,48 @@ function printSkillHelp(subcommand) {
56
82
  console.log("kweaver skill install <skill-id> [directory] [--force] [-bd value] [--pretty|--compact]");
57
83
  return;
58
84
  }
85
+ if (subcommand === "management-content") {
86
+ console.log("kweaver skill management-content <skill-id> [--raw] [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]");
87
+ return;
88
+ }
89
+ if (subcommand === "management-read-file") {
90
+ console.log("kweaver skill management-read-file <skill-id> <rel-path> [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]");
91
+ return;
92
+ }
93
+ if (subcommand === "management-download") {
94
+ console.log("kweaver skill management-download <skill-id> [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]");
95
+ return;
96
+ }
59
97
  console.log(`kweaver skill
60
98
 
61
99
  Subcommands:
62
100
  list [--name kw] [--status status] [--page N] [--page-size N] [-bd value]
63
101
  market [--name kw] [--source src] [--page N] [--page-size N] [-bd value]
64
102
  get <skill-id> [-bd value]
103
+ market-get <skill-id> [-bd value]
65
104
  register --content-file <path> | --zip-file <path> [--source src] [--extend-info json]
66
105
  (--content-file accepts a file named SKILL.md or a directory; both auto-zip)
67
106
  set-status <skill-id> <unpublish|published|offline> [-bd value]
68
107
  delete <skill-id> [-y] [-bd value]
108
+ update-metadata <skill-id> --name <name> --description <text> --category <other_category|system> [--source <custom|internal>] [--extend-info json]
109
+ update-package <skill-id> (--content-file <path> | --zip-file <path>) [-bd value]
110
+ history <skill-id> [-bd value]
111
+ republish <skill-id> --version <version> [-bd value]
112
+ publish-history <skill-id> --version <version> [-bd value]
69
113
  content <skill-id> [--raw] [--output file] [-bd value]
70
114
  read-file <skill-id> <rel-path> [--raw] [--output file] [-bd value]
71
115
  download <skill-id> [--output file] [-bd value]
72
116
  install <skill-id> [directory] [--force] [-bd value]
117
+ management-content <skill-id> [--raw] [--response-mode url|content] [--output file] [-bd value]
118
+ management-read-file <skill-id> <rel-path> [--response-mode url|content] [--output file] [-bd value]
119
+ management-download <skill-id> [--response-mode url|content] [--output file] [-bd value]
73
120
 
74
121
  Examples:
75
122
  kweaver skill list --name kweaver
76
123
  kweaver skill register --zip-file ./demo-skill.zip --source upload_zip
124
+ kweaver skill update-metadata skill-123 --name "Demo" --description "Demo skill" --category system
125
+ kweaver skill update-package skill-123 --content-file ./SKILL.md
126
+ kweaver skill history skill-123
77
127
  kweaver skill content skill-123 --raw
78
128
  kweaver skill read-file skill-123 references/guide.md --output ./guide.md
79
129
  kweaver skill install skill-123 ./skills/demo-skill --force`);
@@ -276,6 +326,108 @@ function parseSkillGetArgs(args) {
276
326
  }
277
327
  return { ...base.opts, skillId };
278
328
  }
329
+ export function parseSkillUpdateMetadataArgs(args) {
330
+ const skillId = args[0];
331
+ if (!skillId || skillId.startsWith("-"))
332
+ throw new Error("Missing skill-id");
333
+ let name;
334
+ let description;
335
+ let category;
336
+ let source;
337
+ let extendInfo;
338
+ const base = parseBaseArgs(args, 1);
339
+ for (let i = 1; i < base.args.length; i += 1) {
340
+ const arg = base.args[i];
341
+ if (arg === "--help" || arg === "-h")
342
+ throw new Error("help");
343
+ if (arg === "--name") {
344
+ name = base.args[i + 1];
345
+ i += 1;
346
+ continue;
347
+ }
348
+ if (arg === "--description") {
349
+ description = base.args[i + 1];
350
+ i += 1;
351
+ continue;
352
+ }
353
+ if (arg === "--category") {
354
+ const value = base.args[i + 1];
355
+ if (value !== "other_category" && value !== "system") {
356
+ throw new Error("Invalid --category. Expected other_category|system");
357
+ }
358
+ category = value;
359
+ i += 1;
360
+ continue;
361
+ }
362
+ if (arg === "--source") {
363
+ source = base.args[i + 1];
364
+ i += 1;
365
+ continue;
366
+ }
367
+ if (arg === "--extend-info") {
368
+ extendInfo = parseJsonFlag(base.args[i + 1], "--extend-info");
369
+ i += 1;
370
+ continue;
371
+ }
372
+ throw new Error(`Unsupported skill update-metadata argument: ${arg}`);
373
+ }
374
+ if (!name)
375
+ throw new Error("Missing --name");
376
+ if (!description)
377
+ throw new Error("Missing --description");
378
+ if (!category)
379
+ throw new Error("Missing --category");
380
+ return { ...base.opts, skillId, name, description, category, source, extendInfo };
381
+ }
382
+ export function parseSkillUpdatePackageArgs(args) {
383
+ const skillId = args[0];
384
+ if (!skillId || skillId.startsWith("-"))
385
+ throw new Error("Missing skill-id");
386
+ let contentFile;
387
+ let zipFile;
388
+ const base = parseBaseArgs(args, 1);
389
+ for (let i = 1; i < base.args.length; i += 1) {
390
+ const arg = base.args[i];
391
+ if (arg === "--help" || arg === "-h")
392
+ throw new Error("help");
393
+ if (arg === "--content-file") {
394
+ contentFile = base.args[i + 1];
395
+ i += 1;
396
+ continue;
397
+ }
398
+ if (arg === "--zip-file") {
399
+ zipFile = base.args[i + 1];
400
+ i += 1;
401
+ continue;
402
+ }
403
+ throw new Error(`Unsupported skill update-package argument: ${arg}`);
404
+ }
405
+ if ((contentFile ? 1 : 0) + (zipFile ? 1 : 0) !== 1) {
406
+ throw new Error("Use exactly one of --content-file or --zip-file");
407
+ }
408
+ return { ...base.opts, skillId, contentFile, zipFile };
409
+ }
410
+ export function parseSkillHistoryVersionArgs(args, commandName) {
411
+ const skillId = args[0];
412
+ if (!skillId || skillId.startsWith("-"))
413
+ throw new Error("Missing skill-id");
414
+ let version;
415
+ const base = parseBaseArgs(args, 1);
416
+ for (let i = 1; i < base.args.length; i += 1) {
417
+ const arg = base.args[i];
418
+ if (arg === "--help" || arg === "-h")
419
+ throw new Error("help");
420
+ if (arg === "--version") {
421
+ version = base.args[i + 1];
422
+ i += 1;
423
+ continue;
424
+ }
425
+ throw new Error(`Unsupported skill ${commandName} argument: ${arg}`);
426
+ }
427
+ if (!version)
428
+ throw new Error("Missing --version");
429
+ return { ...base.opts, skillId, version };
430
+ }
279
431
  function parseSkillReadFileArgs(args) {
280
432
  const skillId = args[0];
281
433
  const relPath = args[1];
@@ -325,6 +477,101 @@ function parseSkillInstallArgs(args) {
325
477
  }
326
478
  return { ...base.opts, skillId, directory, force };
327
479
  }
480
+ function parseManagementContentArgs(args) {
481
+ const skillId = args[0];
482
+ if (!skillId || skillId.startsWith("-"))
483
+ throw new Error("Missing skill-id");
484
+ let responseMode;
485
+ let fetchRaw = false;
486
+ let output;
487
+ const base = parseBaseArgs(args, 1);
488
+ for (let i = 1; i < base.args.length; i += 1) {
489
+ const arg = base.args[i];
490
+ if (arg === "--help" || arg === "-h")
491
+ throw new Error("help");
492
+ if (arg === "--raw") {
493
+ fetchRaw = true;
494
+ continue;
495
+ }
496
+ if (arg === "--response-mode") {
497
+ const value = base.args[i + 1];
498
+ if (value !== "url" && value !== "content") {
499
+ throw new Error("Invalid --response-mode. Expected url|content");
500
+ }
501
+ responseMode = value;
502
+ i += 1;
503
+ continue;
504
+ }
505
+ if (arg === "--output" || arg === "-o") {
506
+ output = base.args[i + 1];
507
+ i += 1;
508
+ continue;
509
+ }
510
+ throw new Error(`Unsupported skill management-content argument: ${arg}`);
511
+ }
512
+ return { ...base.opts, skillId, responseMode, fetchRaw, output };
513
+ }
514
+ function parseManagementReadFileArgs(args) {
515
+ const skillId = args[0];
516
+ const relPath = args[1];
517
+ if (!skillId || skillId.startsWith("-"))
518
+ throw new Error("Missing skill-id");
519
+ if (!relPath || relPath.startsWith("-"))
520
+ throw new Error("Missing rel-path");
521
+ let responseMode;
522
+ let output;
523
+ const base = parseBaseArgs(args, 2);
524
+ for (let i = 2; i < base.args.length; i += 1) {
525
+ const arg = base.args[i];
526
+ if (arg === "--help" || arg === "-h")
527
+ throw new Error("help");
528
+ if (arg === "--response-mode") {
529
+ const value = base.args[i + 1];
530
+ if (value !== "url" && value !== "content") {
531
+ throw new Error("Invalid --response-mode. Expected url|content");
532
+ }
533
+ responseMode = value;
534
+ i += 1;
535
+ continue;
536
+ }
537
+ if (arg === "--output" || arg === "-o") {
538
+ output = base.args[i + 1];
539
+ i += 1;
540
+ continue;
541
+ }
542
+ throw new Error(`Unsupported skill management-read-file argument: ${arg}`);
543
+ }
544
+ return { ...base.opts, skillId, relPath, responseMode, output };
545
+ }
546
+ function parseManagementDownloadArgs(args) {
547
+ const skillId = args[0];
548
+ if (!skillId || skillId.startsWith("-"))
549
+ throw new Error("Missing skill-id");
550
+ let responseMode;
551
+ let output;
552
+ const base = parseBaseArgs(args, 1);
553
+ for (let i = 1; i < base.args.length; i += 1) {
554
+ const arg = base.args[i];
555
+ if (arg === "--help" || arg === "-h")
556
+ throw new Error("help");
557
+ if (arg === "--response-mode") {
558
+ const value = base.args[i + 1];
559
+ if (value !== "url" && value !== "content") {
560
+ throw new Error("Invalid --response-mode. Expected url|content");
561
+ }
562
+ responseMode = value;
563
+ i += 1;
564
+ continue;
565
+ }
566
+ if (arg === "--output" || arg === "-o") {
567
+ output = base.args[i + 1];
568
+ i += 1;
569
+ continue;
570
+ }
571
+ throw new Error(`Unsupported skill management-download argument: ${arg}`);
572
+ }
573
+ return { ...base.opts, skillId, responseMode, output };
574
+ }
328
575
  function parseStatusArgs(args) {
329
576
  const skillId = args[0];
330
577
  const status = args[1];
@@ -401,6 +648,16 @@ export async function runSkillCommand(args) {
401
648
  console.log(format(result, opts.pretty));
402
649
  return 0;
403
650
  }
651
+ if (subcommand === "market-get") {
652
+ const opts = parseSkillGetArgs(rest);
653
+ const result = await getSkillMarketDetail({
654
+ ...token,
655
+ businessDomain: opts.businessDomain,
656
+ skillId: opts.skillId,
657
+ });
658
+ console.log(format(result, opts.pretty));
659
+ return 0;
660
+ }
404
661
  if (subcommand === "register") {
405
662
  const opts = parseSkillRegisterArgs(rest);
406
663
  if (opts.contentFile) {
@@ -463,6 +720,79 @@ export async function runSkillCommand(args) {
463
720
  console.log(format(result, opts.pretty));
464
721
  return 0;
465
722
  }
723
+ if (subcommand === "update-metadata") {
724
+ const opts = parseSkillUpdateMetadataArgs(rest);
725
+ const result = await updateSkillMetadata({
726
+ ...token,
727
+ businessDomain: opts.businessDomain,
728
+ skillId: opts.skillId,
729
+ name: opts.name,
730
+ description: opts.description,
731
+ category: opts.category,
732
+ source: opts.source,
733
+ extendInfo: opts.extendInfo,
734
+ });
735
+ console.log(format(result, opts.pretty));
736
+ return 0;
737
+ }
738
+ if (subcommand === "update-package") {
739
+ const opts = parseSkillUpdatePackageArgs(rest);
740
+ if (opts.contentFile) {
741
+ const content = readFileSync(resolve(opts.contentFile), "utf8");
742
+ const result = await updateSkillPackageContent({
743
+ ...token,
744
+ businessDomain: opts.businessDomain,
745
+ skillId: opts.skillId,
746
+ content,
747
+ });
748
+ console.log(format(result, opts.pretty));
749
+ return 0;
750
+ }
751
+ if (opts.zipFile) {
752
+ const bytes = new Uint8Array(readFileSync(resolve(opts.zipFile)));
753
+ const result = await updateSkillPackageZip({
754
+ ...token,
755
+ businessDomain: opts.businessDomain,
756
+ skillId: opts.skillId,
757
+ filename: basename(resolve(opts.zipFile)),
758
+ bytes,
759
+ });
760
+ console.log(format(result, opts.pretty));
761
+ return 0;
762
+ }
763
+ }
764
+ if (subcommand === "history") {
765
+ const opts = parseSkillGetArgs(rest);
766
+ const result = await listSkillHistory({
767
+ ...token,
768
+ businessDomain: opts.businessDomain,
769
+ skillId: opts.skillId,
770
+ });
771
+ console.log(format(result, opts.pretty));
772
+ return 0;
773
+ }
774
+ if (subcommand === "republish") {
775
+ const opts = parseSkillHistoryVersionArgs(rest, "republish");
776
+ const result = await republishSkillHistory({
777
+ ...token,
778
+ businessDomain: opts.businessDomain,
779
+ skillId: opts.skillId,
780
+ version: opts.version,
781
+ });
782
+ console.log(format(result, opts.pretty));
783
+ return 0;
784
+ }
785
+ if (subcommand === "publish-history") {
786
+ const opts = parseSkillHistoryVersionArgs(rest, "publish-history");
787
+ const result = await publishSkillHistory({
788
+ ...token,
789
+ businessDomain: opts.businessDomain,
790
+ skillId: opts.skillId,
791
+ version: opts.version,
792
+ });
793
+ console.log(format(result, opts.pretty));
794
+ return 0;
795
+ }
466
796
  if (subcommand === "content") {
467
797
  const opts = parseSkillContentArgs(rest);
468
798
  if (opts.fetchRaw || opts.output) {
@@ -533,6 +863,64 @@ export async function runSkillCommand(args) {
533
863
  console.log(`Installed ${opts.skillId} to ${result.directory}`);
534
864
  return 0;
535
865
  }
866
+ if (subcommand === "management-content") {
867
+ const opts = parseManagementContentArgs(rest);
868
+ if (opts.fetchRaw || opts.responseMode === "content" || opts.output) {
869
+ const result = await getSkillManagementContent({
870
+ ...token,
871
+ businessDomain: opts.businessDomain,
872
+ skillId: opts.skillId,
873
+ responseMode: opts.responseMode,
874
+ });
875
+ if (opts.output && result.content) {
876
+ ensureDirectoryForFile(resolve(opts.output));
877
+ writeFileSync(resolve(opts.output), result.content, "utf8");
878
+ console.log(`Saved ${opts.skillId} management content to ${resolve(opts.output)}`);
879
+ }
880
+ else if (opts.fetchRaw && result.content) {
881
+ process.stdout.write(result.content);
882
+ if (!result.content.endsWith("\n"))
883
+ process.stdout.write("\n");
884
+ }
885
+ else {
886
+ console.log(format(result, opts.pretty));
887
+ }
888
+ return 0;
889
+ }
890
+ const result = await getSkillManagementContent({
891
+ ...token,
892
+ businessDomain: opts.businessDomain,
893
+ skillId: opts.skillId,
894
+ responseMode: opts.responseMode,
895
+ });
896
+ console.log(format(result, opts.pretty));
897
+ return 0;
898
+ }
899
+ if (subcommand === "management-read-file") {
900
+ const opts = parseManagementReadFileArgs(rest);
901
+ const result = await readSkillManagementFile({
902
+ ...token,
903
+ businessDomain: opts.businessDomain,
904
+ skillId: opts.skillId,
905
+ relPath: opts.relPath,
906
+ });
907
+ console.log(format(result, opts.pretty));
908
+ return 0;
909
+ }
910
+ if (subcommand === "management-download") {
911
+ const opts = parseManagementDownloadArgs(rest);
912
+ const result = await downloadSkillManagementArchive({
913
+ ...token,
914
+ businessDomain: opts.businessDomain,
915
+ skillId: opts.skillId,
916
+ responseMode: opts.responseMode,
917
+ });
918
+ const output = resolve(opts.output ?? result.fileName);
919
+ ensureDirectoryForFile(output);
920
+ writeFileSync(output, result.bytes);
921
+ console.log(`Saved ${opts.skillId} management archive to ${output}`);
922
+ return 0;
923
+ }
536
924
  console.error(`Unknown skill subcommand: ${subcommand}`);
537
925
  return 1;
538
926
  });
@@ -0,0 +1,39 @@
1
+ export interface ParsedTraceArgs {
2
+ subcommand: "diagnose" | "rules-validate" | "eval-set-build" | "eval-set-test" | "schema-validate" | "help";
3
+ mode?: "single" | "batch";
4
+ conversationId?: string;
5
+ traces?: string;
6
+ rulePath?: string;
7
+ out: string | null;
8
+ rulesDir: string | null;
9
+ noBuiltin: boolean;
10
+ noLlm: boolean;
11
+ noArtifacts: boolean;
12
+ maxParallel: number;
13
+ format: 'yaml' | 'markdown' | 'both' | null;
14
+ lang: 'en' | 'zh' | null;
15
+ baseUrl: string | null;
16
+ token: string | null;
17
+ businessDomain: string | null;
18
+ queriesPath?: string;
19
+ diagnosisPath?: string;
20
+ onConflict?: "fail" | "skip" | "overwrite";
21
+ redactionRules?: string;
22
+ evalSetId?: string;
23
+ schemaValidatePath?: string;
24
+ schemaKind?: string;
25
+ evalSetPath?: string;
26
+ candidateAgentId?: string;
27
+ candidateAgentVersion?: string;
28
+ }
29
+ export declare function parseTraceArgs(argv: string[]): ParsedTraceArgs;
30
+ export declare function runTraceCommand(rest: string[]): Promise<number>;
31
+ export declare class SchemaKindRequiredError extends Error {
32
+ constructor(filePath: string);
33
+ }
34
+ export declare function inferKind(filePath: string): string | null;
35
+ export interface RunSchemaValidateOpts {
36
+ filePath: string;
37
+ kind: string | undefined;
38
+ }
39
+ export declare function runSchemaValidate(opts: RunSchemaValidateOpts): Promise<number>;