@kweaver-ai/kweaver-sdk 0.8.1 → 0.8.3

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 (214) hide show
  1. package/README.md +40 -52
  2. package/README.zh.md +41 -46
  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/resources.d.ts +94 -0
  20. package/dist/api/resources.js +166 -0
  21. package/dist/api/semantic-search.d.ts +5 -0
  22. package/dist/api/semantic-search.js +5 -0
  23. package/dist/api/skills.d.ts +75 -2
  24. package/dist/api/skills.js +108 -12
  25. package/dist/api/trace.d.ts +5 -0
  26. package/dist/api/trace.js +4 -0
  27. package/dist/cli.js +109 -15
  28. package/dist/client.d.ts +3 -3
  29. package/dist/client.js +5 -5
  30. package/dist/commands/agent/mode.d.ts +6 -0
  31. package/dist/commands/agent/mode.js +75 -0
  32. package/dist/commands/agent-members.js +27 -11
  33. package/dist/commands/agent.js +469 -286
  34. package/dist/commands/auth.js +184 -71
  35. package/dist/commands/bkn-metric.js +37 -16
  36. package/dist/commands/bkn-ops.js +164 -86
  37. package/dist/commands/bkn-query.js +99 -31
  38. package/dist/commands/bkn-schema.d.ts +3 -3
  39. package/dist/commands/bkn-schema.js +127 -86
  40. package/dist/commands/bkn.js +153 -114
  41. package/dist/commands/call.js +23 -13
  42. package/dist/commands/config.js +22 -12
  43. package/dist/commands/context-loader.js +625 -49
  44. package/dist/commands/dataflow.js +14 -6
  45. package/dist/commands/ds.js +52 -30
  46. package/dist/commands/explore.js +18 -15
  47. package/dist/commands/model.js +53 -42
  48. package/dist/commands/resource.d.ts +1 -0
  49. package/dist/commands/{dataview.js → resource.js} +62 -84
  50. package/dist/commands/skill.d.ts +21 -1
  51. package/dist/commands/skill.js +567 -43
  52. package/dist/commands/token.js +11 -0
  53. package/dist/commands/tool.js +46 -29
  54. package/dist/commands/toolbox.js +31 -15
  55. package/dist/commands/trace.d.ts +26 -1
  56. package/dist/commands/trace.js +515 -15
  57. package/dist/commands/vega.js +466 -250
  58. package/dist/help/format.d.ts +65 -0
  59. package/dist/help/format.js +141 -0
  60. package/dist/index.d.ts +5 -5
  61. package/dist/index.js +3 -3
  62. package/dist/resources/bkn.d.ts +5 -0
  63. package/dist/resources/bkn.js +5 -0
  64. package/dist/resources/{dataviews.d.ts → resources.d.ts} +10 -11
  65. package/dist/resources/{dataviews.js → resources.js} +12 -13
  66. package/dist/resources/skills.d.ts +17 -1
  67. package/dist/resources/skills.js +32 -1
  68. package/dist/trace-ai/diagnose/agent-binding.d.ts +67 -0
  69. package/dist/trace-ai/diagnose/agent-binding.js +257 -0
  70. package/dist/trace-ai/diagnose/builtin-rules/tool-retry-intent-mismatch.yaml +68 -0
  71. package/dist/trace-ai/diagnose/index.d.ts +32 -0
  72. package/dist/trace-ai/diagnose/index.js +246 -0
  73. package/dist/trace-ai/diagnose/output-schema-converter.d.ts +24 -0
  74. package/dist/trace-ai/diagnose/output-schema-converter.js +81 -0
  75. package/dist/trace-ai/diagnose/query-extractor.d.ts +14 -0
  76. package/dist/trace-ai/diagnose/query-extractor.js +45 -0
  77. package/dist/trace-ai/diagnose/report-assembler.d.ts +31 -0
  78. package/dist/{trace-core → trace-ai}/diagnose/report-assembler.js +19 -9
  79. package/dist/trace-ai/diagnose/report-markdown.d.ts +18 -0
  80. package/dist/trace-ai/diagnose/report-markdown.js +192 -0
  81. package/dist/{trace-core → trace-ai}/diagnose/rule-loader.js +42 -8
  82. package/dist/{trace-core → trace-ai}/diagnose/schemas.d.ts +77 -2
  83. package/dist/trace-ai/diagnose/schemas.js +154 -0
  84. package/dist/trace-ai/diagnose/signal-probe.d.ts +17 -0
  85. package/dist/trace-ai/diagnose/signal-probe.js +39 -0
  86. package/dist/trace-ai/diagnose/synthesizer-agent.d.ts +40 -0
  87. package/dist/trace-ai/diagnose/synthesizer-agent.js +158 -0
  88. package/dist/{trace-core → trace-ai}/diagnose/trace-shaper.js +1 -0
  89. package/dist/{trace-core → trace-ai}/diagnose/types.d.ts +55 -6
  90. package/dist/trace-ai/eval-set/assertion-evaluator.d.ts +29 -0
  91. package/dist/trace-ai/eval-set/assertion-evaluator.js +100 -0
  92. package/dist/trace-ai/eval-set/builder.d.ts +36 -0
  93. package/dist/trace-ai/eval-set/builder.js +126 -0
  94. package/dist/trace-ai/eval-set/index.d.ts +15 -0
  95. package/dist/trace-ai/eval-set/index.js +10 -0
  96. package/dist/trace-ai/eval-set/output-writer.d.ts +27 -0
  97. package/dist/trace-ai/eval-set/output-writer.js +126 -0
  98. package/dist/trace-ai/eval-set/query-picker.d.ts +37 -0
  99. package/dist/trace-ai/eval-set/query-picker.js +147 -0
  100. package/dist/trace-ai/eval-set/redactor.d.ts +42 -0
  101. package/dist/trace-ai/eval-set/redactor.js +133 -0
  102. package/dist/trace-ai/eval-set/rubric-templates/answer-match-reference.prompt.md +19 -0
  103. package/dist/trace-ai/eval-set/schemas.d.ts +136 -0
  104. package/dist/trace-ai/eval-set/schemas.js +130 -0
  105. package/dist/trace-ai/eval-set/semantic-match-provider.d.ts +33 -0
  106. package/dist/trace-ai/eval-set/semantic-match-provider.js +51 -0
  107. package/dist/trace-ai/eval-set/test-runner.d.ts +34 -0
  108. package/dist/trace-ai/eval-set/test-runner.js +153 -0
  109. package/dist/trace-ai/eval-set/types.d.ts +46 -0
  110. package/dist/trace-ai/eval-set/types.js +8 -0
  111. package/dist/trace-ai/exp/bundle-writer.d.ts +10 -0
  112. package/dist/trace-ai/exp/bundle-writer.js +54 -0
  113. package/dist/trace-ai/exp/claude-binary.d.ts +5 -0
  114. package/dist/trace-ai/exp/claude-binary.js +30 -0
  115. package/dist/trace-ai/exp/coordinator.d.ts +45 -0
  116. package/dist/trace-ai/exp/coordinator.js +203 -0
  117. package/dist/trace-ai/exp/eval-runner.d.ts +14 -0
  118. package/dist/trace-ai/exp/eval-runner.js +47 -0
  119. package/dist/trace-ai/exp/exp-store/abort-signal.d.ts +3 -0
  120. package/dist/trace-ai/exp/exp-store/abort-signal.js +27 -0
  121. package/dist/trace-ai/exp/exp-store/candidate-lineage-yaml.d.ts +4 -0
  122. package/dist/trace-ai/exp/exp-store/candidate-lineage-yaml.js +37 -0
  123. package/dist/trace-ai/exp/exp-store/events-jsonl.d.ts +17 -0
  124. package/dist/trace-ai/exp/exp-store/events-jsonl.js +60 -0
  125. package/dist/trace-ai/exp/exp-store/exp-registry.d.ts +6 -0
  126. package/dist/trace-ai/exp/exp-store/exp-registry.js +41 -0
  127. package/dist/trace-ai/exp/exp-store/index.d.ts +46 -0
  128. package/dist/trace-ai/exp/exp-store/index.js +59 -0
  129. package/dist/trace-ai/exp/exp-store/lock.d.ts +3 -0
  130. package/dist/trace-ai/exp/exp-store/lock.js +73 -0
  131. package/dist/trace-ai/exp/exp-store/mission-md.d.ts +3 -0
  132. package/dist/trace-ai/exp/exp-store/mission-md.js +37 -0
  133. package/dist/trace-ai/exp/exp-store/readme-template.d.ts +5 -0
  134. package/dist/trace-ai/exp/exp-store/readme-template.js +25 -0
  135. package/dist/trace-ai/exp/exp-store/round-yaml.d.ts +3 -0
  136. package/dist/trace-ai/exp/exp-store/round-yaml.js +33 -0
  137. package/dist/trace-ai/exp/index.d.ts +8 -0
  138. package/dist/trace-ai/exp/index.js +238 -0
  139. package/dist/trace-ai/exp/info.d.ts +35 -0
  140. package/dist/trace-ai/exp/info.js +120 -0
  141. package/dist/trace-ai/exp/patch/agent-config.d.ts +1 -0
  142. package/dist/trace-ai/exp/patch/agent-config.js +26 -0
  143. package/dist/trace-ai/exp/patch/index.d.ts +2 -0
  144. package/dist/trace-ai/exp/patch/index.js +13 -0
  145. package/dist/trace-ai/exp/patch/skill.d.ts +1 -0
  146. package/dist/trace-ai/exp/patch/skill.js +24 -0
  147. package/dist/trace-ai/exp/providers/synthesizer-client.d.ts +14 -0
  148. package/dist/trace-ai/exp/providers/synthesizer-client.js +39 -0
  149. package/dist/trace-ai/exp/providers/triage-client.d.ts +19 -0
  150. package/dist/trace-ai/exp/providers/triage-client.js +51 -0
  151. package/dist/trace-ai/exp/schemas.d.ts +147 -0
  152. package/dist/trace-ai/exp/schemas.js +50 -0
  153. package/dist/trace-ai/exp/scoring.d.ts +2 -0
  154. package/dist/trace-ai/exp/scoring.js +46 -0
  155. package/dist/trace-ai/scan/aggregator.d.ts +20 -0
  156. package/dist/trace-ai/scan/aggregator.js +26 -0
  157. package/dist/trace-ai/scan/artifacts/paths.d.ts +12 -0
  158. package/dist/trace-ai/scan/artifacts/paths.js +18 -0
  159. package/dist/trace-ai/scan/artifacts/writer.d.ts +67 -0
  160. package/dist/trace-ai/scan/artifacts/writer.js +96 -0
  161. package/dist/trace-ai/scan/batched-rubric.d.ts +55 -0
  162. package/dist/trace-ai/scan/batched-rubric.js +159 -0
  163. package/dist/trace-ai/scan/cross-trace-synthesizer.d.ts +24 -0
  164. package/dist/trace-ai/scan/cross-trace-synthesizer.js +93 -0
  165. package/dist/trace-ai/scan/index.d.ts +31 -0
  166. package/dist/trace-ai/scan/index.js +390 -0
  167. package/dist/trace-ai/scan/prompts/builtin/cross-trace-synthesizer-v1.prompt.md +44 -0
  168. package/dist/trace-ai/scan/prompts/builtin/rubric-judge-batch-v1.prompt.md +44 -0
  169. package/dist/trace-ai/scan/runner.d.ts +25 -0
  170. package/dist/trace-ai/scan/runner.js +42 -0
  171. package/dist/trace-ai/scan/sampler.d.ts +18 -0
  172. package/dist/trace-ai/scan/sampler.js +81 -0
  173. package/dist/trace-ai/scan/scan-summary-markdown.d.ts +2 -0
  174. package/dist/trace-ai/scan/scan-summary-markdown.js +71 -0
  175. package/dist/trace-ai/scan/scan-summary-schema.d.ts +73 -0
  176. package/dist/trace-ai/scan/scan-summary-schema.js +61 -0
  177. package/dist/trace-ai/scan/single-agent-validator.d.ts +23 -0
  178. package/dist/trace-ai/scan/single-agent-validator.js +42 -0
  179. package/dist/trace-ai/scan/traces-list-parser.d.ts +15 -0
  180. package/dist/trace-ai/scan/traces-list-parser.js +46 -0
  181. package/package.json +2 -2
  182. package/dist/api/dataviews.d.ts +0 -117
  183. package/dist/api/dataviews.js +0 -265
  184. package/dist/commands/dataview.d.ts +0 -8
  185. package/dist/trace-core/diagnose/index.d.ts +0 -9
  186. package/dist/trace-core/diagnose/index.js +0 -104
  187. package/dist/trace-core/diagnose/report-assembler.d.ts +0 -12
  188. package/dist/trace-core/diagnose/schemas.js +0 -94
  189. package/dist/trace-core/diagnose/signal-probe.d.ts +0 -5
  190. package/dist/trace-core/diagnose/signal-probe.js +0 -21
  191. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.d.ts +0 -0
  192. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.js +0 -0
  193. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/excessive-tool-calls-per-turn.yaml +0 -0
  194. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.d.ts +0 -0
  195. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.js +0 -0
  196. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/llm-response-truncated-no-continue.yaml +0 -0
  197. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/register.d.ts +0 -0
  198. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/register.js +0 -0
  199. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.d.ts +0 -0
  200. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.js +0 -0
  201. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/retrieval-empty-no-fallback.yaml +0 -0
  202. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.d.ts +0 -0
  203. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.js +0 -0
  204. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-error-swallowed.yaml +0 -0
  205. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.d.ts +0 -0
  206. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.js +0 -0
  207. /package/dist/{trace-core → trace-ai}/diagnose/builtin-rules/tool-loop-no-state-change.yaml +0 -0
  208. /package/dist/{trace-core → trace-ai}/diagnose/predicate-registry.d.ts +0 -0
  209. /package/dist/{trace-core → trace-ai}/diagnose/predicate-registry.js +0 -0
  210. /package/dist/{trace-core → trace-ai}/diagnose/rule-loader.d.ts +0 -0
  211. /package/dist/{trace-core → trace-ai}/diagnose/synthesizer-template.d.ts +0 -0
  212. /package/dist/{trace-core → trace-ai}/diagnose/synthesizer-template.js +0 -0
  213. /package/dist/{trace-core → trace-ai}/diagnose/trace-shaper.d.ts +0 -0
  214. /package/dist/{trace-core → trace-ai}/diagnose/types.js +0 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Help text formatter for the kweaver CLI.
3
+ *
4
+ * All `--help` output must go through `renderHelp()` to keep a consistent
5
+ * gh-style layout. See `docs/cli_conventions.md` §8 for the spec.
6
+ */
7
+ export interface HelpItem {
8
+ name: string;
9
+ desc: string;
10
+ }
11
+ export interface HelpSection {
12
+ title: string;
13
+ items: HelpItem[];
14
+ }
15
+ export interface HelpFlag {
16
+ name: string;
17
+ desc: string;
18
+ }
19
+ export interface HelpFlagGroup {
20
+ title: string;
21
+ flags: HelpFlag[];
22
+ }
23
+ export interface RenderHelpOptions {
24
+ /** Optional one-line tagline shown at the very top. */
25
+ tagline?: string;
26
+ /** One or more USAGE lines (without the "USAGE" header). */
27
+ usage: string | string[];
28
+ /**
29
+ * Command / subcommand groupings (rendered as separate sections with
30
+ * two-column name:desc layout).
31
+ */
32
+ sections?: HelpSection[];
33
+ /**
34
+ * Flags. Either a flat list (rendered under "FLAGS") or grouped sub-blocks
35
+ * (each rendered under its own title, e.g. "Login options").
36
+ */
37
+ flags?: HelpFlag[] | HelpFlagGroup[];
38
+ /** One-line "INHERITED FLAGS" summary. Omitted if undefined. */
39
+ inheritedFlags?: string;
40
+ /** Environment variable docs. */
41
+ environment?: HelpFlag[];
42
+ /** Example invocations (prefix `$ ` added automatically if missing). */
43
+ examples?: string[];
44
+ /** Free-form "LEARN MORE" trailing lines. */
45
+ learnMore?: string[];
46
+ /** Override the wrap width (default 80). */
47
+ width?: number;
48
+ }
49
+ /**
50
+ * Render full help text per the §8 spec.
51
+ */
52
+ export declare function renderHelp(opts: RenderHelpOptions): string;
53
+ /**
54
+ * Render a two-column name:desc list.
55
+ *
56
+ * Width policy: left column = max(name length) + 2 (capped at half the wrap
57
+ * width). Description wraps onto continuation lines aligned to the right
58
+ * column. `indent` controls the leading whitespace (default: 2 spaces).
59
+ */
60
+ export declare function formatTwoColumn(items: HelpItem[], width?: number, indent?: string): string[];
61
+ /**
62
+ * Word-wrap a string at the given column. Preserves single newlines as
63
+ * explicit line breaks.
64
+ */
65
+ export declare function wrap(text: string, width: number): string[];
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Help text formatter for the kweaver CLI.
3
+ *
4
+ * All `--help` output must go through `renderHelp()` to keep a consistent
5
+ * gh-style layout. See `docs/cli_conventions.md` §8 for the spec.
6
+ */
7
+ const DEFAULT_WIDTH = 80;
8
+ const INDENT = " ";
9
+ /**
10
+ * Render full help text per the §8 spec.
11
+ */
12
+ export function renderHelp(opts) {
13
+ const width = opts.width ?? DEFAULT_WIDTH;
14
+ const out = [];
15
+ if (opts.tagline) {
16
+ out.push(opts.tagline);
17
+ out.push("");
18
+ }
19
+ const usageLines = Array.isArray(opts.usage) ? opts.usage : [opts.usage];
20
+ out.push("USAGE");
21
+ for (const line of usageLines) {
22
+ out.push(INDENT + line);
23
+ }
24
+ out.push("");
25
+ if (opts.sections && opts.sections.length > 0) {
26
+ for (const section of opts.sections) {
27
+ out.push(section.title.toUpperCase());
28
+ out.push(...formatTwoColumn(section.items, width));
29
+ out.push("");
30
+ }
31
+ }
32
+ if (opts.flags) {
33
+ if (isFlagGroupArray(opts.flags)) {
34
+ out.push("FLAGS");
35
+ for (const group of opts.flags) {
36
+ out.push(INDENT + group.title);
37
+ out.push(...formatTwoColumn(group.flags.map((f) => ({ name: f.name, desc: f.desc })), width, INDENT.repeat(2)));
38
+ out.push("");
39
+ }
40
+ }
41
+ else {
42
+ out.push("FLAGS");
43
+ out.push(...formatTwoColumn(opts.flags.map((f) => ({ name: f.name, desc: f.desc })), width));
44
+ out.push("");
45
+ }
46
+ }
47
+ if (opts.inheritedFlags) {
48
+ out.push("INHERITED FLAGS");
49
+ out.push(INDENT + opts.inheritedFlags);
50
+ out.push("");
51
+ }
52
+ if (opts.environment && opts.environment.length > 0) {
53
+ out.push("ENVIRONMENT");
54
+ out.push(...formatTwoColumn(opts.environment.map((e) => ({ name: e.name, desc: e.desc })), width));
55
+ out.push("");
56
+ }
57
+ if (opts.examples && opts.examples.length > 0) {
58
+ out.push("EXAMPLES");
59
+ for (const ex of opts.examples) {
60
+ const trimmed = ex.trimStart();
61
+ const line = trimmed.startsWith("$") ? trimmed : `$ ${trimmed}`;
62
+ out.push(INDENT + line);
63
+ }
64
+ out.push("");
65
+ }
66
+ if (opts.learnMore && opts.learnMore.length > 0) {
67
+ out.push("LEARN MORE");
68
+ for (const line of opts.learnMore) {
69
+ out.push(INDENT + line);
70
+ }
71
+ out.push("");
72
+ }
73
+ while (out.length > 0 && out[out.length - 1] === "")
74
+ out.pop();
75
+ return out.join("\n");
76
+ }
77
+ /**
78
+ * Render a two-column name:desc list.
79
+ *
80
+ * Width policy: left column = max(name length) + 2 (capped at half the wrap
81
+ * width). Description wraps onto continuation lines aligned to the right
82
+ * column. `indent` controls the leading whitespace (default: 2 spaces).
83
+ */
84
+ export function formatTwoColumn(items, width = DEFAULT_WIDTH, indent = INDENT) {
85
+ if (items.length === 0)
86
+ return [];
87
+ const maxName = items.reduce((m, i) => Math.max(m, i.name.length), 0);
88
+ const halfWidth = Math.floor(width / 2);
89
+ const colGap = Math.min(maxName + 2, halfWidth);
90
+ const descCol = indent.length + colGap;
91
+ const descWidth = Math.max(20, width - descCol);
92
+ const out = [];
93
+ for (const item of items) {
94
+ const namePadded = item.name.padEnd(colGap, " ");
95
+ const descLines = wrap(item.desc, descWidth);
96
+ if (descLines.length === 0) {
97
+ out.push(indent + item.name);
98
+ continue;
99
+ }
100
+ out.push(indent + namePadded + descLines[0]);
101
+ for (let i = 1; i < descLines.length; i++) {
102
+ out.push(" ".repeat(descCol) + descLines[i]);
103
+ }
104
+ }
105
+ return out;
106
+ }
107
+ /**
108
+ * Word-wrap a string at the given column. Preserves single newlines as
109
+ * explicit line breaks.
110
+ */
111
+ export function wrap(text, width) {
112
+ if (!text)
113
+ return [];
114
+ const result = [];
115
+ for (const para of text.split("\n")) {
116
+ if (para.length <= width) {
117
+ result.push(para);
118
+ continue;
119
+ }
120
+ const words = para.split(/\s+/);
121
+ let line = "";
122
+ for (const word of words) {
123
+ if (line.length === 0) {
124
+ line = word;
125
+ }
126
+ else if (line.length + 1 + word.length <= width) {
127
+ line += " " + word;
128
+ }
129
+ else {
130
+ result.push(line);
131
+ line = word;
132
+ }
133
+ }
134
+ if (line.length > 0)
135
+ result.push(line);
136
+ }
137
+ return result;
138
+ }
139
+ function isFlagGroupArray(v) {
140
+ return v.length > 0 && "flags" in v[0];
141
+ }
package/dist/index.d.ts CHANGED
@@ -57,11 +57,11 @@ export { SkillsResource } from "./resources/skills.js";
57
57
  export { ToolboxesResource } from "./resources/toolboxes.js";
58
58
  export type { InvokeToolArgs } from "./resources/toolboxes.js";
59
59
  export { ModelsResource, LlmModelsSubresource, SmallModelsSubresource, ModelInvocationSubresource, } from "./resources/models.js";
60
- export type { SkillStatus, SkillSummary, SkillInfo, SkillFileSummary, SkillContentIndex, SkillFileReadResult, RegisterSkillResult, DeleteSkillResult, UpdateSkillStatusResult, SkillListResult, ListSkillsOptions, ListSkillMarketOptions, GetSkillOptions, RegisterSkillContentOptions, RegisterSkillZipOptions, UpdateSkillStatusOptions, ReadSkillFileOptions, DownloadSkillOptions, DownloadedSkillArchive, } from "./api/skills.js";
61
- export { listSkills, listSkillMarket, getSkill, deleteSkill, updateSkillStatus, registerSkillContent, registerSkillZip, getSkillContentIndex, fetchSkillContent, readSkillFile, fetchSkillFile, downloadSkill, installSkillArchive, } from "./api/skills.js";
62
- export type { ViewField, DataView, CreateDataViewOptions, GetDataViewOptions, ListDataViewsOptions, DeleteDataViewOptions, FindDataViewOptions, QueryDataViewOptions, DataViewQueryResult, } from "./api/dataviews.js";
63
- export { parseDataView, createDataView, getDataView, listDataViews, deleteDataView, findDataView, queryDataView, } from "./api/dataviews.js";
64
- export { DataViewsResource } from "./resources/dataviews.js";
60
+ export type { SkillCategory, SkillEditableStatus, SkillStatus, SkillSummary, SkillInfo, SkillFileSummary, SkillContentIndex, SkillFileReadResult, RegisterSkillResult, DeleteSkillResult, UpdateSkillStatusResult, SkillListResult, ListSkillsOptions, ListSkillMarketOptions, GetSkillOptions, RegisterSkillContentOptions, RegisterSkillZipOptions, UpdateSkillMetadataOptions, UpdateSkillMetadataResult, UpdateSkillPackageContentOptions, UpdateSkillPackageZipOptions, UpdateSkillPackageResult, UpdateSkillStatusOptions, ReadSkillFileOptions, DownloadSkillOptions, DownloadedSkillArchive, SkillReleaseHistoryInfo, SkillHistoryVersionOptions, SkillManagementContentData, GetSkillManagementContentOptions, ReadSkillManagementFileOptions, DownloadSkillManagementOptions, } from "./api/skills.js";
61
+ export { listSkills, listSkillMarket, getSkill, getSkillMarketDetail, deleteSkill, updateSkillStatus, updateSkillMetadata, registerSkillContent, registerSkillZip, updateSkillPackageContent, updateSkillPackageZip, getSkillContentIndex, fetchSkillContent, readSkillFile, fetchSkillFile, downloadSkill, listSkillHistory, republishSkillHistory, publishSkillHistory, installSkillArchive, getSkillManagementContent, readSkillManagementFile, downloadSkillManagementArchive, } from "./api/skills.js";
62
+ export type { ViewField, Resource, CreateResourceOptions, GetResourceOptions, ListResourcesOptions, DeleteResourceOptions, FindResourceOptions, QueryResourceOptions, ResourceQueryResult, } from "./api/resources.js";
63
+ export { parseResource, createResource, getResource, listResources, deleteResource, findResource, queryResource, } from "./api/resources.js";
64
+ export { ResourcesResource } from "./resources/resources.js";
65
65
  export type { MfManagerBaseOptions, ListLlmModelsOptions, GetLlmModelOptions, AddLlmModelOptions, EditLlmModelOptions, DeleteLlmModelsOptions, TestLlmModelOptions, ListSmallModelsOptions, GetSmallModelOptions, AddSmallModelOptions, EditSmallModelOptions, DeleteSmallModelsOptions, TestSmallModelOptions, } from "./api/models.js";
66
66
  export { MF_MODEL_MANAGER_PATH_PREFIX, assertSmallModelConfigAdapterExclusive, assertSmallModelEditBody, listLlmModels, getLlmModel, addLlmModel, editLlmModel, deleteLlmModels, testLlmModel, listSmallModels, getSmallModel, addSmallModel, editSmallModel, deleteSmallModels, testSmallModel, } from "./api/models.js";
67
67
  export type { MfApiBaseOptions, ChatMessage, ModelChatCompletionsOptions, ModelChatResult, ModelEmbeddingOptions, ModelRerankOptions, } from "./api/model-invocation.js";
package/dist/index.js CHANGED
@@ -44,9 +44,9 @@ export { ContextLoaderResource } from "./resources/context-loader.js";
44
44
  export { SkillsResource } from "./resources/skills.js";
45
45
  export { ToolboxesResource } from "./resources/toolboxes.js";
46
46
  export { ModelsResource, LlmModelsSubresource, SmallModelsSubresource, ModelInvocationSubresource, } from "./resources/models.js";
47
- export { listSkills, listSkillMarket, getSkill, deleteSkill, updateSkillStatus, registerSkillContent, registerSkillZip, getSkillContentIndex, fetchSkillContent, readSkillFile, fetchSkillFile, downloadSkill, installSkillArchive, } from "./api/skills.js";
48
- export { parseDataView, createDataView, getDataView, listDataViews, deleteDataView, findDataView, queryDataView, } from "./api/dataviews.js";
49
- export { DataViewsResource } from "./resources/dataviews.js";
47
+ export { listSkills, listSkillMarket, getSkill, getSkillMarketDetail, deleteSkill, updateSkillStatus, updateSkillMetadata, registerSkillContent, registerSkillZip, updateSkillPackageContent, updateSkillPackageZip, getSkillContentIndex, fetchSkillContent, readSkillFile, fetchSkillFile, downloadSkill, listSkillHistory, republishSkillHistory, publishSkillHistory, installSkillArchive, getSkillManagementContent, readSkillManagementFile, downloadSkillManagementArchive, } from "./api/skills.js";
48
+ export { parseResource, createResource, getResource, listResources, deleteResource, findResource, queryResource, } from "./api/resources.js";
49
+ export { ResourcesResource } from "./resources/resources.js";
50
50
  export { MF_MODEL_MANAGER_PATH_PREFIX, assertSmallModelConfigAdapterExclusive, assertSmallModelEditBody, listLlmModels, getLlmModel, addLlmModel, editLlmModel, deleteLlmModels, testLlmModel, listSmallModels, getSmallModel, addSmallModel, editSmallModel, deleteSmallModels, testSmallModel, } from "./api/models.js";
51
51
  export { MF_MODEL_API_PATH_PREFIX, consumeOpenAiSseText, modelChatCompletions, modelEmbedding, modelEmbeddings, modelRerank, } from "./api/model-invocation.js";
52
52
  export { listBusinessDomains } from "./api/business-domains.js";
@@ -49,6 +49,11 @@ export declare class BknResource {
49
49
  /**
50
50
  * Search KN schema — finds matching object types, relation types, and action types.
51
51
  * Uses the public agent-retrieval HTTP compatibility endpoint.
52
+ *
53
+ * @deprecated Use `client.contextLoader(...).searchSchema(...)` for new
54
+ * schema discovery integrations. `knSearch` is kept only for compatibility
55
+ * with the legacy HTTP `kn_search` endpoint and may not receive new
56
+ * `search_schema` capabilities.
52
57
  */
53
58
  knSearch(knId: string, query: string, opts?: {
54
59
  onlySchema?: boolean;
@@ -90,6 +90,11 @@ export class BknResource {
90
90
  /**
91
91
  * Search KN schema — finds matching object types, relation types, and action types.
92
92
  * Uses the public agent-retrieval HTTP compatibility endpoint.
93
+ *
94
+ * @deprecated Use `client.contextLoader(...).searchSchema(...)` for new
95
+ * schema discovery integrations. `knSearch` is kept only for compatibility
96
+ * with the legacy HTTP `kn_search` endpoint and may not receive new
97
+ * `search_schema` capabilities.
93
98
  */
94
99
  async knSearch(knId, query, opts = {}) {
95
100
  const raw = await knSearchHttp({
@@ -1,6 +1,6 @@
1
- import type { DataView, DataViewQueryResult } from "../api/dataviews.js";
1
+ import type { Resource, ResourceQueryResult } from "../api/resources.js";
2
2
  import type { ClientContext } from "../client.js";
3
- export declare class DataViewsResource {
3
+ export declare class ResourcesResource {
4
4
  private readonly ctx;
5
5
  constructor(ctx: ClientContext);
6
6
  create(opts: {
@@ -12,26 +12,25 @@ export declare class DataViewsResource {
12
12
  type: string;
13
13
  }>;
14
14
  }): Promise<string>;
15
- get(id: string): Promise<DataView>;
15
+ get(id: string): Promise<Resource>;
16
16
  list(opts?: {
17
17
  datasourceId?: string;
18
- type?: string;
18
+ category?: string;
19
19
  limit?: number;
20
- }): Promise<DataView[]>;
20
+ }): Promise<Resource[]>;
21
21
  find(name: string, opts?: {
22
22
  datasourceId?: string;
23
23
  exact?: boolean;
24
24
  wait?: boolean;
25
25
  timeoutMs?: number;
26
- }): Promise<DataView[]>;
26
+ }): Promise<Resource[]>;
27
27
  delete(id: string): Promise<void>;
28
28
  query(id: string, opts?: {
29
- sql?: string;
30
29
  offset?: number;
31
30
  limit?: number;
32
31
  needTotal?: boolean;
33
- outputFields?: string[];
34
- filters?: Record<string, unknown>;
35
- sort?: Array<Record<string, unknown>>;
36
- }): Promise<DataViewQueryResult>;
32
+ filterCondition?: unknown;
33
+ sort?: string;
34
+ direction?: "asc" | "desc";
35
+ }): Promise<ResourceQueryResult>;
37
36
  }
@@ -1,25 +1,25 @@
1
- import { createDataView, deleteDataView, findDataView, getDataView, listDataViews, queryDataView, } from "../api/dataviews.js";
2
- export class DataViewsResource {
1
+ import { RESOURCE_LIST_DEFAULT_LIMIT, createResource, deleteResource, findResource, getResource, listResources, queryResource, } from "../api/resources.js";
2
+ export class ResourcesResource {
3
3
  ctx;
4
4
  constructor(ctx) {
5
5
  this.ctx = ctx;
6
6
  }
7
7
  async create(opts) {
8
- return createDataView({ ...this.ctx.base(), ...opts });
8
+ return createResource({ ...this.ctx.base(), ...opts });
9
9
  }
10
10
  async get(id) {
11
- return getDataView({ ...this.ctx.base(), id });
11
+ return getResource({ ...this.ctx.base(), id });
12
12
  }
13
13
  async list(opts = {}) {
14
- return listDataViews({
14
+ return listResources({
15
15
  ...this.ctx.base(),
16
16
  datasourceId: opts.datasourceId,
17
- type: opts.type,
18
- limit: opts.limit,
17
+ category: opts.category,
18
+ limit: opts.limit ?? RESOURCE_LIST_DEFAULT_LIMIT,
19
19
  });
20
20
  }
21
21
  async find(name, opts) {
22
- return findDataView({
22
+ return findResource({
23
23
  ...this.ctx.base(),
24
24
  name,
25
25
  datasourceId: opts?.datasourceId,
@@ -29,19 +29,18 @@ export class DataViewsResource {
29
29
  });
30
30
  }
31
31
  async delete(id) {
32
- await deleteDataView({ ...this.ctx.base(), id });
32
+ await deleteResource({ ...this.ctx.base(), id });
33
33
  }
34
34
  async query(id, opts) {
35
- return queryDataView({
35
+ return queryResource({
36
36
  ...this.ctx.base(),
37
37
  id,
38
- sql: opts?.sql,
39
38
  offset: opts?.offset,
40
39
  limit: opts?.limit,
41
40
  needTotal: opts?.needTotal,
42
- outputFields: opts?.outputFields,
43
- filters: opts?.filters,
41
+ filterCondition: opts?.filterCondition,
44
42
  sort: opts?.sort,
43
+ direction: opts?.direction,
45
44
  });
46
45
  }
47
46
  }
@@ -1,5 +1,5 @@
1
1
  import type { ClientContext } from "../client.js";
2
- import { type SkillListResult, type SkillStatus } from "../api/skills.js";
2
+ import { type SkillCategory, type SkillListResult, type SkillStatus } from "../api/skills.js";
3
3
  export declare class SkillsResource {
4
4
  private readonly ctx;
5
5
  constructor(ctx: ClientContext);
@@ -24,6 +24,7 @@ export declare class SkillsResource {
24
24
  source?: string;
25
25
  }): Promise<SkillListResult>;
26
26
  get(skillId: string): Promise<import("../api/skills.js").SkillInfo>;
27
+ getMarket(skillId: string): Promise<import("../api/skills.js").SkillInfo>;
27
28
  registerContent(content: string, opts?: {
28
29
  source?: string;
29
30
  extendInfo?: Record<string, unknown>;
@@ -34,6 +35,18 @@ export declare class SkillsResource {
34
35
  }): Promise<import("../api/skills.js").RegisterSkillResult>;
35
36
  delete(skillId: string): Promise<import("../api/skills.js").DeleteSkillResult>;
36
37
  updateStatus(skillId: string, status: SkillStatus): Promise<import("../api/skills.js").UpdateSkillStatusResult>;
38
+ updateMetadata(skillId: string, metadata: {
39
+ name: string;
40
+ description: string;
41
+ category: SkillCategory;
42
+ source?: string;
43
+ extendInfo?: Record<string, unknown>;
44
+ }): Promise<import("../api/skills.js").UpdateSkillMetadataResult>;
45
+ updatePackageContent(skillId: string, content: string): Promise<import("../api/skills.js").UpdateSkillPackageResult>;
46
+ updatePackageZip(skillId: string, filename: string, bytes: Uint8Array): Promise<import("../api/skills.js").UpdateSkillPackageResult>;
47
+ history(skillId: string): Promise<import("../api/skills.js").SkillReleaseHistoryInfo[]>;
48
+ republishHistory(skillId: string, version: string): Promise<import("../api/skills.js").UpdateSkillPackageResult>;
49
+ publishHistory(skillId: string, version: string): Promise<import("../api/skills.js").UpdateSkillPackageResult>;
37
50
  content(skillId: string): Promise<import("../api/skills.js").SkillContentIndex>;
38
51
  fetchContent(skillId: string): Promise<string>;
39
52
  readFile(skillId: string, relPath: string): Promise<import("../api/skills.js").SkillFileReadResult>;
@@ -44,4 +57,7 @@ export declare class SkillsResource {
44
57
  }): Promise<{
45
58
  directory: string;
46
59
  }>;
60
+ getManagementContent(skillId: string, responseMode?: "url" | "content"): Promise<import("../api/skills.js").SkillManagementContentData>;
61
+ readManagementFile(skillId: string, relPath: string): Promise<import("../api/skills.js").SkillFileReadResult>;
62
+ downloadManagementArchive(skillId: string, responseMode?: "url" | "content"): Promise<import("../api/skills.js").DownloadedSkillArchive>;
47
63
  }
@@ -1,4 +1,4 @@
1
- import { deleteSkill, downloadSkill, fetchSkillContent, fetchSkillFile, getSkill, getSkillContentIndex, installSkillArchive, listSkillMarket, listSkills, readSkillFile, registerSkillContent, registerSkillZip, updateSkillStatus, } from "../api/skills.js";
1
+ import { deleteSkill, downloadSkill, downloadSkillManagementArchive, fetchSkillContent, fetchSkillFile, getSkill, getSkillMarketDetail, getSkillContentIndex, getSkillManagementContent, installSkillArchive, listSkillMarket, listSkillHistory, listSkills, publishSkillHistory, readSkillFile, readSkillManagementFile, republishSkillHistory, registerSkillContent, registerSkillZip, updateSkillMetadata, updateSkillPackageContent, updateSkillPackageZip, updateSkillStatus, } from "../api/skills.js";
2
2
  export class SkillsResource {
3
3
  ctx;
4
4
  constructor(ctx) {
@@ -13,6 +13,9 @@ export class SkillsResource {
13
13
  async get(skillId) {
14
14
  return getSkill({ ...this.ctx.base(), skillId });
15
15
  }
16
+ async getMarket(skillId) {
17
+ return getSkillMarketDetail({ ...this.ctx.base(), skillId });
18
+ }
16
19
  async registerContent(content, opts = {}) {
17
20
  return registerSkillContent({ ...this.ctx.base(), content, ...opts });
18
21
  }
@@ -25,6 +28,24 @@ export class SkillsResource {
25
28
  async updateStatus(skillId, status) {
26
29
  return updateSkillStatus({ ...this.ctx.base(), skillId, status });
27
30
  }
31
+ async updateMetadata(skillId, metadata) {
32
+ return updateSkillMetadata({ ...this.ctx.base(), skillId, ...metadata });
33
+ }
34
+ async updatePackageContent(skillId, content) {
35
+ return updateSkillPackageContent({ ...this.ctx.base(), skillId, content });
36
+ }
37
+ async updatePackageZip(skillId, filename, bytes) {
38
+ return updateSkillPackageZip({ ...this.ctx.base(), skillId, filename, bytes });
39
+ }
40
+ async history(skillId) {
41
+ return listSkillHistory({ ...this.ctx.base(), skillId });
42
+ }
43
+ async republishHistory(skillId, version) {
44
+ return republishSkillHistory({ ...this.ctx.base(), skillId, version });
45
+ }
46
+ async publishHistory(skillId, version) {
47
+ return publishSkillHistory({ ...this.ctx.base(), skillId, version });
48
+ }
28
49
  async content(skillId) {
29
50
  return getSkillContentIndex({ ...this.ctx.base(), skillId });
30
51
  }
@@ -44,4 +65,14 @@ export class SkillsResource {
44
65
  const archive = await this.download(skillId);
45
66
  return installSkillArchive({ bytes: archive.bytes, directory, force: opts.force });
46
67
  }
68
+ // ── Management Content ───────────────────────────────────────────────────────
69
+ async getManagementContent(skillId, responseMode) {
70
+ return getSkillManagementContent({ ...this.ctx.base(), skillId, responseMode });
71
+ }
72
+ async readManagementFile(skillId, relPath) {
73
+ return readSkillManagementFile({ ...this.ctx.base(), skillId, relPath });
74
+ }
75
+ async downloadManagementArchive(skillId, responseMode) {
76
+ return downloadSkillManagementArchive({ ...this.ctx.base(), skillId, responseMode });
77
+ }
47
78
  }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Stage-2 — rubric judgments: resolve rubric.inputs against a TraceTree,
3
+ * render the prompt template, invoke the agent provider, and map the
4
+ * schema-validated output to a `Finding`.
5
+ *
6
+ * Why this layer exists separate from `signal-probe`:
7
+ * - Async / I/O-bound (subprocess or HTTP) vs. sync predicates
8
+ * - Per-rule provider lookup + skip-on-unavailable
9
+ * - Error semantics differ (skip + record vs. throw RuleProbeError)
10
+ *
11
+ * Convergence invariant (enforced upstream in schemas.ts): every rubric
12
+ * `output_schema.required` includes `first_violating_step_id`, so each
13
+ * rubric finding always points at a concrete span and can be correlated
14
+ * with symbolic findings on the same span by the synthesizer.
15
+ */
16
+ import type { Finding, Rule, RubricInputSpec, TraceTree } from "./types.js";
17
+ import type { AgentRegistry } from "../../agent-providers/registry.js";
18
+ import { PromptTemplateRegistry, type AgentOutputLang } from "../../agent-providers/prompt-template.js";
19
+ import type { ArtifactWriter } from "../scan/artifacts/writer.js";
20
+ export interface RubricEvaluateOpts {
21
+ rules: Rule[];
22
+ tree: TraceTree;
23
+ registry: AgentRegistry;
24
+ promptRegistry: PromptTemplateRegistry;
25
+ /** If true, all rubric rules are skipped with reason='no-llm-flag-set'. */
26
+ noLlm?: boolean;
27
+ /** Per-invocation timeout in ms; provider may apply its own ceiling. */
28
+ timeoutMs?: number;
29
+ /** Output locale for natural-language fields in the agent reply. Default 'en'. */
30
+ lang?: AgentOutputLang;
31
+ /** When provided, writes Stage-2 prompt/response artifacts per rule invocation. */
32
+ artifacts?: ArtifactWriter;
33
+ /** User query extracted from trace input.messages (2026-05-13). */
34
+ userQuery?: string | null;
35
+ /** Conversation/query ID for suggested_eval_case correlation (2026-05-13). */
36
+ queryId?: string | null;
37
+ }
38
+ export interface RubricEvaluateResult {
39
+ findings: Finding[];
40
+ skipped: {
41
+ ruleId: string;
42
+ reason: string;
43
+ }[];
44
+ }
45
+ /** Resolve one rubric input spec against the trace and return a value
46
+ * suitable for prompt interpolation. Pure for testability. */
47
+ export declare function resolveRubricInput(spec: RubricInputSpec, tree: TraceTree): unknown;
48
+ export declare class AgentBindingError extends Error {
49
+ constructor(message: string);
50
+ }
51
+ export declare function renderChangeTemplate(tpl: string, bindings: Record<string, unknown>): string;
52
+ /**
53
+ * Evaluate every rubric rule in `rules` and return findings + skip records.
54
+ *
55
+ * A rule is *skipped* (not failed) when:
56
+ * - `--no-llm` is set → reason: 'no-llm-flag-set'
57
+ * - rule's named provider isn't registered or `isAvailable()` is false
58
+ * → reason: `provider-not-available:<name>`
59
+ * - rule's prompt template isn't registered
60
+ * → reason: `prompt-template-missing:<ref>`
61
+ *
62
+ * Schema violations / transport errors from the provider are surfaced
63
+ * as `AgentBindingError` (let the CLI decide whether to fail the whole
64
+ * run or skip the single rule). Default callsite (`index.ts`) catches
65
+ * these and records them in `rules_skipped` rather than aborting.
66
+ */
67
+ export declare function evaluateRubricRules(opts: RubricEvaluateOpts): Promise<RubricEvaluateResult>;