@kweaver-ai/kweaver-sdk 0.8.1 → 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 (183) hide show
  1. package/README.md +19 -5
  2. package/README.zh.md +19 -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/context-loader.d.ts +1 -0
  19. package/dist/api/semantic-search.d.ts +5 -0
  20. package/dist/api/semantic-search.js +5 -0
  21. package/dist/api/skills.d.ts +75 -2
  22. package/dist/api/skills.js +108 -12
  23. package/dist/api/trace.d.ts +5 -0
  24. package/dist/api/trace.js +4 -0
  25. package/dist/cli.js +7 -5
  26. package/dist/commands/agent/mode.d.ts +6 -0
  27. package/dist/commands/agent/mode.js +75 -0
  28. package/dist/commands/agent.js +101 -29
  29. package/dist/commands/context-loader.js +608 -38
  30. package/dist/commands/skill.d.ts +21 -1
  31. package/dist/commands/skill.js +389 -1
  32. package/dist/commands/trace.d.ts +26 -1
  33. package/dist/commands/trace.js +515 -15
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.js +1 -1
  36. package/dist/resources/bkn.d.ts +5 -0
  37. package/dist/resources/bkn.js +5 -0
  38. package/dist/resources/skills.d.ts +17 -1
  39. package/dist/resources/skills.js +32 -1
  40. package/dist/trace-ai/diagnose/agent-binding.d.ts +67 -0
  41. package/dist/trace-ai/diagnose/agent-binding.js +257 -0
  42. package/dist/trace-ai/diagnose/builtin-rules/tool-retry-intent-mismatch.yaml +68 -0
  43. package/dist/trace-ai/diagnose/index.d.ts +32 -0
  44. package/dist/trace-ai/diagnose/index.js +246 -0
  45. package/dist/trace-ai/diagnose/output-schema-converter.d.ts +24 -0
  46. package/dist/trace-ai/diagnose/output-schema-converter.js +81 -0
  47. package/dist/trace-ai/diagnose/query-extractor.d.ts +14 -0
  48. package/dist/trace-ai/diagnose/query-extractor.js +45 -0
  49. package/dist/trace-ai/diagnose/report-assembler.d.ts +31 -0
  50. package/dist/{trace-core → trace-ai}/diagnose/report-assembler.js +19 -9
  51. package/dist/trace-ai/diagnose/report-markdown.d.ts +18 -0
  52. package/dist/trace-ai/diagnose/report-markdown.js +192 -0
  53. package/dist/{trace-core → trace-ai}/diagnose/rule-loader.js +42 -8
  54. package/dist/{trace-core → trace-ai}/diagnose/schemas.d.ts +77 -2
  55. package/dist/trace-ai/diagnose/schemas.js +154 -0
  56. package/dist/trace-ai/diagnose/signal-probe.d.ts +17 -0
  57. package/dist/trace-ai/diagnose/signal-probe.js +39 -0
  58. package/dist/trace-ai/diagnose/synthesizer-agent.d.ts +40 -0
  59. package/dist/trace-ai/diagnose/synthesizer-agent.js +158 -0
  60. package/dist/{trace-core → trace-ai}/diagnose/trace-shaper.js +1 -0
  61. package/dist/{trace-core → trace-ai}/diagnose/types.d.ts +55 -6
  62. package/dist/trace-ai/eval-set/assertion-evaluator.d.ts +29 -0
  63. package/dist/trace-ai/eval-set/assertion-evaluator.js +100 -0
  64. package/dist/trace-ai/eval-set/builder.d.ts +36 -0
  65. package/dist/trace-ai/eval-set/builder.js +126 -0
  66. package/dist/trace-ai/eval-set/index.d.ts +15 -0
  67. package/dist/trace-ai/eval-set/index.js +10 -0
  68. package/dist/trace-ai/eval-set/output-writer.d.ts +27 -0
  69. package/dist/trace-ai/eval-set/output-writer.js +126 -0
  70. package/dist/trace-ai/eval-set/query-picker.d.ts +37 -0
  71. package/dist/trace-ai/eval-set/query-picker.js +147 -0
  72. package/dist/trace-ai/eval-set/redactor.d.ts +42 -0
  73. package/dist/trace-ai/eval-set/redactor.js +133 -0
  74. package/dist/trace-ai/eval-set/rubric-templates/answer-match-reference.prompt.md +19 -0
  75. package/dist/trace-ai/eval-set/schemas.d.ts +136 -0
  76. package/dist/trace-ai/eval-set/schemas.js +130 -0
  77. package/dist/trace-ai/eval-set/semantic-match-provider.d.ts +33 -0
  78. package/dist/trace-ai/eval-set/semantic-match-provider.js +51 -0
  79. package/dist/trace-ai/eval-set/test-runner.d.ts +34 -0
  80. package/dist/trace-ai/eval-set/test-runner.js +153 -0
  81. package/dist/trace-ai/eval-set/types.d.ts +46 -0
  82. package/dist/trace-ai/eval-set/types.js +8 -0
  83. package/dist/trace-ai/exp/bundle-writer.d.ts +10 -0
  84. package/dist/trace-ai/exp/bundle-writer.js +54 -0
  85. package/dist/trace-ai/exp/claude-binary.d.ts +5 -0
  86. package/dist/trace-ai/exp/claude-binary.js +30 -0
  87. package/dist/trace-ai/exp/coordinator.d.ts +45 -0
  88. package/dist/trace-ai/exp/coordinator.js +203 -0
  89. package/dist/trace-ai/exp/eval-runner.d.ts +14 -0
  90. package/dist/trace-ai/exp/eval-runner.js +47 -0
  91. package/dist/trace-ai/exp/exp-store/abort-signal.d.ts +3 -0
  92. package/dist/trace-ai/exp/exp-store/abort-signal.js +27 -0
  93. package/dist/trace-ai/exp/exp-store/candidate-lineage-yaml.d.ts +4 -0
  94. package/dist/trace-ai/exp/exp-store/candidate-lineage-yaml.js +37 -0
  95. package/dist/trace-ai/exp/exp-store/events-jsonl.d.ts +17 -0
  96. package/dist/trace-ai/exp/exp-store/events-jsonl.js +60 -0
  97. package/dist/trace-ai/exp/exp-store/exp-registry.d.ts +6 -0
  98. package/dist/trace-ai/exp/exp-store/exp-registry.js +41 -0
  99. package/dist/trace-ai/exp/exp-store/index.d.ts +46 -0
  100. package/dist/trace-ai/exp/exp-store/index.js +59 -0
  101. package/dist/trace-ai/exp/exp-store/lock.d.ts +3 -0
  102. package/dist/trace-ai/exp/exp-store/lock.js +73 -0
  103. package/dist/trace-ai/exp/exp-store/mission-md.d.ts +3 -0
  104. package/dist/trace-ai/exp/exp-store/mission-md.js +37 -0
  105. package/dist/trace-ai/exp/exp-store/readme-template.d.ts +5 -0
  106. package/dist/trace-ai/exp/exp-store/readme-template.js +25 -0
  107. package/dist/trace-ai/exp/exp-store/round-yaml.d.ts +3 -0
  108. package/dist/trace-ai/exp/exp-store/round-yaml.js +33 -0
  109. package/dist/trace-ai/exp/index.d.ts +8 -0
  110. package/dist/trace-ai/exp/index.js +238 -0
  111. package/dist/trace-ai/exp/info.d.ts +35 -0
  112. package/dist/trace-ai/exp/info.js +120 -0
  113. package/dist/trace-ai/exp/patch/agent-config.d.ts +1 -0
  114. package/dist/trace-ai/exp/patch/agent-config.js +26 -0
  115. package/dist/trace-ai/exp/patch/index.d.ts +2 -0
  116. package/dist/trace-ai/exp/patch/index.js +13 -0
  117. package/dist/trace-ai/exp/patch/skill.d.ts +1 -0
  118. package/dist/trace-ai/exp/patch/skill.js +24 -0
  119. package/dist/trace-ai/exp/providers/synthesizer-client.d.ts +14 -0
  120. package/dist/trace-ai/exp/providers/synthesizer-client.js +39 -0
  121. package/dist/trace-ai/exp/providers/triage-client.d.ts +19 -0
  122. package/dist/trace-ai/exp/providers/triage-client.js +51 -0
  123. package/dist/trace-ai/exp/schemas.d.ts +147 -0
  124. package/dist/trace-ai/exp/schemas.js +50 -0
  125. package/dist/trace-ai/exp/scoring.d.ts +2 -0
  126. package/dist/trace-ai/exp/scoring.js +46 -0
  127. package/dist/trace-ai/scan/aggregator.d.ts +20 -0
  128. package/dist/trace-ai/scan/aggregator.js +26 -0
  129. package/dist/trace-ai/scan/artifacts/paths.d.ts +12 -0
  130. package/dist/trace-ai/scan/artifacts/paths.js +18 -0
  131. package/dist/trace-ai/scan/artifacts/writer.d.ts +67 -0
  132. package/dist/trace-ai/scan/artifacts/writer.js +96 -0
  133. package/dist/trace-ai/scan/batched-rubric.d.ts +55 -0
  134. package/dist/trace-ai/scan/batched-rubric.js +159 -0
  135. package/dist/trace-ai/scan/cross-trace-synthesizer.d.ts +24 -0
  136. package/dist/trace-ai/scan/cross-trace-synthesizer.js +93 -0
  137. package/dist/trace-ai/scan/index.d.ts +31 -0
  138. package/dist/trace-ai/scan/index.js +390 -0
  139. package/dist/trace-ai/scan/prompts/builtin/cross-trace-synthesizer-v1.prompt.md +44 -0
  140. package/dist/trace-ai/scan/prompts/builtin/rubric-judge-batch-v1.prompt.md +44 -0
  141. package/dist/trace-ai/scan/runner.d.ts +25 -0
  142. package/dist/trace-ai/scan/runner.js +42 -0
  143. package/dist/trace-ai/scan/sampler.d.ts +18 -0
  144. package/dist/trace-ai/scan/sampler.js +81 -0
  145. package/dist/trace-ai/scan/scan-summary-markdown.d.ts +2 -0
  146. package/dist/trace-ai/scan/scan-summary-markdown.js +71 -0
  147. package/dist/trace-ai/scan/scan-summary-schema.d.ts +73 -0
  148. package/dist/trace-ai/scan/scan-summary-schema.js +61 -0
  149. package/dist/trace-ai/scan/single-agent-validator.d.ts +23 -0
  150. package/dist/trace-ai/scan/single-agent-validator.js +42 -0
  151. package/dist/trace-ai/scan/traces-list-parser.d.ts +15 -0
  152. package/dist/trace-ai/scan/traces-list-parser.js +46 -0
  153. package/package.json +2 -2
  154. package/dist/trace-core/diagnose/index.d.ts +0 -9
  155. package/dist/trace-core/diagnose/index.js +0 -104
  156. package/dist/trace-core/diagnose/report-assembler.d.ts +0 -12
  157. package/dist/trace-core/diagnose/schemas.js +0 -94
  158. package/dist/trace-core/diagnose/signal-probe.d.ts +0 -5
  159. package/dist/trace-core/diagnose/signal-probe.js +0 -21
  160. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.d.ts +0 -0
  161. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.js +0 -0
  162. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.yaml +0 -0
  163. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.d.ts +0 -0
  164. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.js +0 -0
  165. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.yaml +0 -0
  166. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/register.d.ts +0 -0
  167. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/register.js +0 -0
  168. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.d.ts +0 -0
  169. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.js +0 -0
  170. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.yaml +0 -0
  171. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.d.ts +0 -0
  172. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.js +0 -0
  173. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.yaml +0 -0
  174. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.d.ts +0 -0
  175. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.js +0 -0
  176. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.yaml +0 -0
  177. /package/dist/{trace-core → trace-ai}/diagnose/predicate-registry.d.ts +0 -0
  178. /package/dist/{trace-core → trace-ai}/diagnose/predicate-registry.js +0 -0
  179. /package/dist/{trace-core → trace-ai}/diagnose/rule-loader.d.ts +0 -0
  180. /package/dist/{trace-core → trace-ai}/diagnose/synthesizer-template.d.ts +0 -0
  181. /package/dist/{trace-core → trace-ai}/diagnose/synthesizer-template.js +0 -0
  182. /package/dist/{trace-core → trace-ai}/diagnose/trace-shaper.d.ts +0 -0
  183. /package/dist/{trace-core → trace-ai}/diagnose/types.js +0 -0
@@ -22,6 +22,11 @@ export async function semanticSearch(options) {
22
22
  }
23
23
  return body;
24
24
  }
25
+ /**
26
+ * @deprecated Use Context Loader `search_schema` for new schema discovery integrations.
27
+ * The HTTP `kn_search` endpoint is kept only as a compatibility entry point
28
+ * and may not receive new `search_schema` capabilities.
29
+ */
25
30
  export async function knSearchHttp(options) {
26
31
  const { baseUrl, accessToken, knId, query, businessDomain = "bd_public", onlySchema = false, } = options;
27
32
  const base = baseUrl.replace(/\/+$/, "");
@@ -1,11 +1,13 @@
1
1
  export type SkillStatus = "unpublish" | "published" | "offline";
2
2
  export type SkillFileType = "zip" | "content";
3
+ export type SkillEditableStatus = SkillStatus | "editing";
4
+ export type SkillCategory = "other_category" | "system";
3
5
  export interface SkillSummary {
4
6
  id: string;
5
7
  name: string;
6
8
  description?: string;
7
9
  version?: string;
8
- status?: SkillStatus;
10
+ status?: SkillEditableStatus;
9
11
  source?: string;
10
12
  create_user?: string;
11
13
  create_time?: number;
@@ -29,7 +31,7 @@ export interface SkillContentIndex {
29
31
  id: string;
30
32
  url: string;
31
33
  files: SkillFileSummary[];
32
- status?: SkillStatus;
34
+ status?: SkillEditableStatus;
33
35
  }
34
36
  export interface SkillFileReadResult {
35
37
  id: string;
@@ -54,6 +56,22 @@ export interface UpdateSkillStatusResult {
54
56
  id: string;
55
57
  status: SkillStatus;
56
58
  }
59
+ export interface UpdateSkillMetadataResult {
60
+ id: string;
61
+ version?: string;
62
+ status?: SkillEditableStatus;
63
+ }
64
+ export interface UpdateSkillPackageResult {
65
+ id: string;
66
+ version?: string;
67
+ status?: SkillEditableStatus;
68
+ }
69
+ export interface SkillReleaseHistoryInfo extends SkillSummary {
70
+ category?: SkillCategory;
71
+ release_desc?: string;
72
+ release_user?: string;
73
+ release_time?: number;
74
+ }
57
75
  export interface SkillListResult {
58
76
  total_count?: number;
59
77
  total?: number;
@@ -104,6 +122,23 @@ export interface RegisterSkillZipOptions extends SkillApiBaseOptions {
104
122
  source?: string;
105
123
  extendInfo?: Record<string, unknown>;
106
124
  }
125
+ export interface UpdateSkillMetadataOptions extends SkillApiBaseOptions {
126
+ skillId: string;
127
+ name: string;
128
+ description: string;
129
+ category: SkillCategory;
130
+ source?: string;
131
+ extendInfo?: Record<string, unknown>;
132
+ }
133
+ export interface UpdateSkillPackageContentOptions extends SkillApiBaseOptions {
134
+ skillId: string;
135
+ content: string;
136
+ }
137
+ export interface UpdateSkillPackageZipOptions extends SkillApiBaseOptions {
138
+ skillId: string;
139
+ filename: string;
140
+ bytes: Uint8Array;
141
+ }
107
142
  export interface UpdateSkillStatusOptions extends SkillApiBaseOptions {
108
143
  skillId: string;
109
144
  status: SkillStatus;
@@ -119,23 +154,61 @@ export interface DownloadedSkillArchive {
119
154
  fileName: string;
120
155
  bytes: Uint8Array;
121
156
  }
157
+ export interface SkillHistoryVersionOptions extends SkillApiBaseOptions {
158
+ skillId: string;
159
+ version: string;
160
+ }
122
161
  export interface InstallSkillArchiveOptions {
123
162
  bytes: Uint8Array;
124
163
  directory: string;
125
164
  force?: boolean;
126
165
  }
166
+ export interface SkillManagementContentData {
167
+ skill_id: string;
168
+ name: string;
169
+ description: string;
170
+ version: string;
171
+ status: SkillEditableStatus;
172
+ source: string;
173
+ file_type: "zip" | "content";
174
+ url?: string;
175
+ content?: string;
176
+ files: SkillFileSummary[];
177
+ }
178
+ export interface GetSkillManagementContentOptions extends SkillApiBaseOptions {
179
+ skillId: string;
180
+ responseMode?: "url" | "content";
181
+ }
182
+ export interface ReadSkillManagementFileOptions extends SkillApiBaseOptions {
183
+ skillId: string;
184
+ relPath: string;
185
+ }
186
+ export interface DownloadSkillManagementOptions extends SkillApiBaseOptions {
187
+ skillId: string;
188
+ responseMode?: "url" | "content";
189
+ }
127
190
  export declare function listSkills(options: ListSkillsOptions): Promise<SkillListResult>;
128
191
  export declare function listSkillMarket(options: ListSkillMarketOptions): Promise<SkillListResult>;
129
192
  export declare function getSkill(options: GetSkillOptions): Promise<SkillInfo>;
193
+ export declare function getSkillMarketDetail(options: GetSkillOptions): Promise<SkillInfo>;
130
194
  export declare function deleteSkill(options: GetSkillOptions): Promise<DeleteSkillResult>;
131
195
  export declare function updateSkillStatus(options: UpdateSkillStatusOptions): Promise<UpdateSkillStatusResult>;
196
+ export declare function updateSkillMetadata(options: UpdateSkillMetadataOptions): Promise<UpdateSkillMetadataResult>;
132
197
  export declare function registerSkillContent(options: RegisterSkillContentOptions): Promise<RegisterSkillResult>;
133
198
  export declare function registerSkillZip(options: RegisterSkillZipOptions): Promise<RegisterSkillResult>;
199
+ export declare function updateSkillPackageContent(options: UpdateSkillPackageContentOptions): Promise<UpdateSkillPackageResult>;
200
+ export declare function updateSkillPackageZip(options: UpdateSkillPackageZipOptions): Promise<UpdateSkillPackageResult>;
134
201
  export declare function getSkillContentIndex(options: GetSkillOptions): Promise<SkillContentIndex>;
135
202
  export declare function fetchSkillContent(options: GetSkillOptions): Promise<string>;
136
203
  export declare function readSkillFile(options: ReadSkillFileOptions): Promise<SkillFileReadResult>;
137
204
  export declare function fetchSkillFile(options: ReadSkillFileOptions): Promise<Uint8Array>;
138
205
  export declare function downloadSkill(options: DownloadSkillOptions): Promise<DownloadedSkillArchive>;
206
+ export declare function listSkillHistory(options: GetSkillOptions): Promise<SkillReleaseHistoryInfo[]>;
207
+ export declare function republishSkillHistory(options: SkillHistoryVersionOptions): Promise<UpdateSkillPackageResult>;
208
+ export declare function publishSkillHistory(options: SkillHistoryVersionOptions): Promise<UpdateSkillPackageResult>;
209
+ export declare function getSkillManagementContent(options: GetSkillManagementContentOptions): Promise<SkillManagementContentData>;
210
+ export declare function readSkillManagementFile(options: ReadSkillManagementFileOptions): Promise<SkillFileReadResult>;
211
+ export declare function downloadSkillManagementArchive(options: DownloadSkillManagementOptions): Promise<DownloadedSkillArchive>;
139
212
  export declare function installSkillArchive(options: InstallSkillArchiveOptions): {
140
213
  directory: string;
141
214
  };
@@ -87,6 +87,11 @@ export async function getSkill(options) {
87
87
  const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
88
88
  return normalizeSkillId(unwrapEnvelope(body));
89
89
  }
90
+ export async function getSkillMarketDetail(options) {
91
+ const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/market/${encodeURIComponent(options.skillId)}`);
92
+ const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
93
+ return normalizeSkillId(unwrapEnvelope(body));
94
+ }
90
95
  export async function deleteSkill(options) {
91
96
  const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}`);
92
97
  const { body } = await fetchTextOrThrow(url, { method: "DELETE", headers: baseHeaders(options) });
@@ -101,14 +106,49 @@ export async function updateSkillStatus(options) {
101
106
  });
102
107
  return normalizeSkillId(unwrapEnvelope(body));
103
108
  }
109
+ export async function updateSkillMetadata(options) {
110
+ const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/metadata`);
111
+ const payload = {
112
+ name: options.name,
113
+ description: options.description,
114
+ category: options.category,
115
+ };
116
+ if (options.source)
117
+ payload.source = options.source;
118
+ if (options.extendInfo)
119
+ payload.extend_info = options.extendInfo;
120
+ const { body } = await fetchTextOrThrow(url, {
121
+ method: "PUT",
122
+ headers: { ...baseHeaders(options), "content-type": "application/json" },
123
+ body: JSON.stringify(payload),
124
+ });
125
+ return normalizeSkillId(unwrapEnvelope(body));
126
+ }
104
127
  export async function registerSkillContent(options) {
128
+ // Backend's file_type=content path is half-implemented: it stores
129
+ // the markdown body but skips skill_file_index, so the skill is
130
+ // unreadable after publish (GET /skills/:id/content -> 404).
131
+ // Bundle the content into a 1-file SKILL.md zip and route through
132
+ // the zip path, which writes skill_file_index correctly.
133
+ const { default: JSZip } = await import("jszip");
134
+ const zip = new JSZip();
135
+ zip.file("SKILL.md", options.content);
136
+ const bytes = new Uint8Array(await zip.generateAsync({ type: "uint8array", compression: "DEFLATE" }));
137
+ return registerSkillZip({
138
+ baseUrl: options.baseUrl,
139
+ accessToken: options.accessToken,
140
+ businessDomain: options.businessDomain,
141
+ filename: "SKILL.md.zip",
142
+ bytes,
143
+ source: options.source,
144
+ extendInfo: options.extendInfo,
145
+ });
146
+ }
147
+ export async function registerSkillZip(options) {
105
148
  const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills`);
106
149
  const form = new FormData();
107
- form.set("file_type", "content");
108
- // Backend's gin form-binder rejects plain string field for `file`
109
- // (typed json.RawMessage); needs an actual multipart file part with
110
- // filename. See utils/gin.go GetBindMultipartFormRaw.
111
- form.set("file", new Blob([options.content], { type: "text/markdown" }), "SKILL.md");
150
+ form.set("file_type", "zip");
151
+ form.set("file", new Blob([Buffer.from(options.bytes)]), options.filename);
112
152
  if (options.source)
113
153
  form.set("source", options.source);
114
154
  if (options.extendInfo)
@@ -120,17 +160,22 @@ export async function registerSkillContent(options) {
120
160
  });
121
161
  return normalizeSkillId(unwrapEnvelope(body));
122
162
  }
123
- export async function registerSkillZip(options) {
124
- const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills`);
163
+ export async function updateSkillPackageContent(options) {
164
+ const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/package`);
165
+ const { body } = await fetchTextOrThrow(url, {
166
+ method: "PUT",
167
+ headers: { ...baseHeaders(options), "content-type": "application/json" },
168
+ body: JSON.stringify({ file_type: "content", file: options.content }),
169
+ });
170
+ return normalizeSkillId(unwrapEnvelope(body));
171
+ }
172
+ export async function updateSkillPackageZip(options) {
173
+ const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/package`);
125
174
  const form = new FormData();
126
175
  form.set("file_type", "zip");
127
176
  form.set("file", new Blob([Buffer.from(options.bytes)]), options.filename);
128
- if (options.source)
129
- form.set("source", options.source);
130
- if (options.extendInfo)
131
- form.set("extend_info", JSON.stringify(options.extendInfo));
132
177
  const { body } = await fetchTextOrThrow(url, {
133
- method: "POST",
178
+ method: "PUT",
134
179
  headers: baseHeaders(options),
135
180
  body: form,
136
181
  });
@@ -169,6 +214,57 @@ export async function downloadSkill(options) {
169
214
  bytes: body,
170
215
  };
171
216
  }
217
+ export async function listSkillHistory(options) {
218
+ const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/history`);
219
+ const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
220
+ return normalizeSkillId(unwrapEnvelope(body));
221
+ }
222
+ export async function republishSkillHistory(options) {
223
+ const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/history/republish`);
224
+ const { body } = await fetchTextOrThrow(url, {
225
+ method: "POST",
226
+ headers: { ...baseHeaders(options), "content-type": "application/json" },
227
+ body: JSON.stringify({ version: options.version }),
228
+ });
229
+ return normalizeSkillId(unwrapEnvelope(body));
230
+ }
231
+ export async function publishSkillHistory(options) {
232
+ const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/history/publish`);
233
+ const { body } = await fetchTextOrThrow(url, {
234
+ method: "POST",
235
+ headers: { ...baseHeaders(options), "content-type": "application/json" },
236
+ body: JSON.stringify({ version: options.version }),
237
+ });
238
+ return normalizeSkillId(unwrapEnvelope(body));
239
+ }
240
+ // ── Management Content (editing-state) API ───────────────────────────────────
241
+ export async function getSkillManagementContent(options) {
242
+ const url = new URL(buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/management/content`));
243
+ if (options.responseMode)
244
+ url.searchParams.set("response_mode", options.responseMode);
245
+ const { body } = await fetchTextOrThrow(url, { headers: baseHeaders(options) });
246
+ return unwrapEnvelope(body);
247
+ }
248
+ export async function readSkillManagementFile(options) {
249
+ const url = buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/management/files/read`);
250
+ const { body } = await fetchTextOrThrow(url, {
251
+ method: "POST",
252
+ headers: { ...baseHeaders(options), "content-type": "application/json" },
253
+ body: JSON.stringify({ rel_path: options.relPath }),
254
+ });
255
+ return normalizeSkillId(unwrapEnvelope(body));
256
+ }
257
+ export async function downloadSkillManagementArchive(options) {
258
+ const url = new URL(buildUrl(options.baseUrl, `${SKILL_API_PREFIX}/skills/${encodeURIComponent(options.skillId)}/management/download`));
259
+ if (options.responseMode)
260
+ url.searchParams.set("response_mode", options.responseMode);
261
+ const { response, body } = await fetchBytesOrThrow(url, { headers: baseHeaders(options) });
262
+ const serverName = parseContentDisposition(response.headers.get("content-disposition"));
263
+ return {
264
+ fileName: basename(serverName || `${options.skillId}.zip`),
265
+ bytes: body,
266
+ };
267
+ }
172
268
  export function installSkillArchive(options) {
173
269
  const targetDir = resolve(options.directory);
174
270
  const existed = existsSync(targetDir);
@@ -25,6 +25,11 @@ export interface RawSpan {
25
25
  code?: string;
26
26
  };
27
27
  attributes?: Record<string, unknown>;
28
+ events?: Array<{
29
+ name?: string;
30
+ time?: string;
31
+ attributes?: Record<string, unknown>;
32
+ }>;
28
33
  /** OTel traceId for the trace this span belongs to (when known). */
29
34
  traceId?: string;
30
35
  }
package/dist/api/trace.js CHANGED
@@ -48,6 +48,9 @@ function normalizeToRawSpan(source) {
48
48
  endTimeUnixNano = isoToNanos(source.endTime);
49
49
  const status = source.status;
50
50
  const attributes = source.attributes;
51
+ const events = Array.isArray(source.events)
52
+ ? source.events
53
+ : undefined;
51
54
  const name = typeof source.name === "string" ? source.name : undefined;
52
55
  const traceIdRaw = source.traceId ?? source.trace_id;
53
56
  const traceId = typeof traceIdRaw === "string" ? traceIdRaw : undefined;
@@ -59,6 +62,7 @@ function normalizeToRawSpan(source) {
59
62
  endTimeUnixNano,
60
63
  status,
61
64
  attributes,
65
+ events,
62
66
  traceId,
63
67
  };
64
68
  }
package/dist/cli.js CHANGED
@@ -108,8 +108,9 @@ Usage:
108
108
  kweaver config list-bd
109
109
  kweaver config show
110
110
 
111
- kweaver skill list|get|register|status|delete [options]
111
+ kweaver skill list|get|market-get|register|status|delete [options]
112
112
  kweaver skill market [options]
113
+ kweaver skill update-metadata|update-package|history|republish|publish-history [options]
113
114
  kweaver skill content <skill-id> [--raw] [--output file]
114
115
  kweaver skill read-file <skill-id> <rel-path> [--raw] [--output file]
115
116
  kweaver skill download|install <skill-id> [path] [options]
@@ -134,14 +135,15 @@ Usage:
134
135
  kweaver vega query execute|sql [options]
135
136
  kweaver vega connector-type list|get [options]
136
137
 
138
+ kweaver context-loader help <subcommand>
137
139
  kweaver context-loader config set|use|list|remove|show [options] (deprecated; not supported with --token)
138
140
  kweaver context-loader tools|resources|templates|prompts <kn-id> [--cursor]
139
141
  kweaver context-loader resource <kn-id> <uri>
140
142
  kweaver context-loader prompt <kn-id> <name> [--args json]
141
- kweaver context-loader search-schema <kn-id> <query> [--scope object,relation,action,metric] [--max N]
143
+ kweaver context-loader search-schema <kn-id> <query> [--scope object,relation,action,metric] [--concept-groups ids] [--max N]
142
144
  kweaver context-loader tool-call <kn-id> <name> --args '<json>'
143
- kweaver context-loader kn-search <kn-id> <query> [--only-schema] (compat HTTP)
144
- kweaver context-loader kn-schema-search <kn-id> <query> [--max N] (compat HTTP)
145
+ kweaver context-loader kn-search <kn-id> <query> [--only-schema] (deprecated; use search-schema)
146
+ kweaver context-loader kn-schema-search <kn-id> <query> [--max N] (deprecated; use search-schema)
145
147
  kweaver context-loader query-object-instance|query-instance-subgraph|get-logic-properties|get-action-info|find-skills <kn-id> ...
146
148
  (omit <kn-id> to fall back to deprecated saved config)
147
149
  (alias: kweaver context ...)
@@ -178,7 +180,7 @@ Commands:
178
180
  bkn Knowledge network (CRUD, build, validate, export, stats, push/pull,
179
181
  object-type, relation-type, subgraph, action-type, action-execution, action-log)
180
182
  config Per-platform configuration (business domain)
181
- skill Skill registry and market (register, search, progressive read, download/install)
183
+ skill Skill registry and market (register, edit, history, progressive read, download/install)
182
184
  toolbox Agent toolbox lifecycle (create, list, publish, delete, export, import)
183
185
  tool Tools inside a toolbox (upload OpenAPI spec, list, enable/disable)
184
186
  vega Vega observability (catalog, resource, query/sql, connector-type, health/stats/inspect)
@@ -0,0 +1,6 @@
1
+ export declare const AGENT_MODES: readonly ["default", "dolphin", "react"];
2
+ export type AgentMode = typeof AGENT_MODES[number];
3
+ export declare const AGENT_MODE_HELP = " --mode <mode> Agent mode: default, dolphin, react (default: default)\n\nAgent mode config:\n config.mode accepts \"default\", \"dolphin\", or \"react\".\n If --mode is provided, it overrides config.mode.\n If neither --mode nor config.mode is provided, the CLI sends config.mode=\"default\".\n\nReAct config:\n react_config is only valid when mode is \"react\".\n Provide it through --config or --config-path, for example:\n {\n \"mode\": \"react\",\n \"react_config\": {\n \"disable_history_in_a_conversation\": false,\n \"disable_llm_cache\": false\n }\n }";
4
+ export declare function parseAgentMode(value: string, flagName?: string): AgentMode;
5
+ export declare function normalizeAgentConfigInput(value: unknown): Record<string, unknown>;
6
+ export declare function applyAgentModeToConfig(config: Record<string, unknown>, explicitMode?: AgentMode): void;
@@ -0,0 +1,75 @@
1
+ export const AGENT_MODES = ["default", "dolphin", "react"];
2
+ const AGENT_MODE_SET = new Set(AGENT_MODES);
3
+ export const AGENT_MODE_HELP = ` --mode <mode> Agent mode: default, dolphin, react (default: default)
4
+
5
+ Agent mode config:
6
+ config.mode accepts "default", "dolphin", or "react".
7
+ If --mode is provided, it overrides config.mode.
8
+ If neither --mode nor config.mode is provided, the CLI sends config.mode="default".
9
+
10
+ ReAct config:
11
+ react_config is only valid when mode is "react".
12
+ Provide it through --config or --config-path, for example:
13
+ {
14
+ "mode": "react",
15
+ "react_config": {
16
+ "disable_history_in_a_conversation": false,
17
+ "disable_llm_cache": false
18
+ }
19
+ }`;
20
+ function formatModeValue(value) {
21
+ return typeof value === "string" ? value : JSON.stringify(value);
22
+ }
23
+ function isRecord(value) {
24
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25
+ }
26
+ function looksLikeAgentConfig(value) {
27
+ return [
28
+ "mode",
29
+ "input",
30
+ "output",
31
+ "llms",
32
+ "react_config",
33
+ "system_prompt",
34
+ "data_source",
35
+ "skills",
36
+ "memory",
37
+ "conversation_history_config",
38
+ ].some((field) => field in value);
39
+ }
40
+ export function parseAgentMode(value, flagName = "--mode") {
41
+ const mode = value.trim();
42
+ if (!AGENT_MODE_SET.has(mode)) {
43
+ throw new Error(`${flagName} must be one of: ${AGENT_MODES.join(", ")}`);
44
+ }
45
+ return mode;
46
+ }
47
+ export function normalizeAgentConfigInput(value) {
48
+ if (!isRecord(value)) {
49
+ throw new Error("Agent config file must contain a JSON object.");
50
+ }
51
+ const nestedConfig = value.config;
52
+ if (isRecord(nestedConfig) && !looksLikeAgentConfig(value)) {
53
+ return nestedConfig;
54
+ }
55
+ return value;
56
+ }
57
+ export function applyAgentModeToConfig(config, explicitMode) {
58
+ if (explicitMode) {
59
+ config.mode = explicitMode;
60
+ return;
61
+ }
62
+ const currentMode = config.mode;
63
+ if (currentMode === undefined || currentMode === null || currentMode === "") {
64
+ config.mode = "default";
65
+ return;
66
+ }
67
+ if (typeof currentMode !== "string") {
68
+ throw new Error(`config.mode must be one of: ${AGENT_MODES.join(", ")}; got ${formatModeValue(currentMode)}`);
69
+ }
70
+ const mode = currentMode.trim();
71
+ if (!AGENT_MODE_SET.has(mode)) {
72
+ throw new Error(`config.mode must be one of: ${AGENT_MODES.join(", ")}; got ${formatModeValue(currentMode)}`);
73
+ }
74
+ config.mode = mode;
75
+ }