@kweaver-ai/kweaver-sdk 0.8.2 → 0.8.4

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 (107) hide show
  1. package/README.md +26 -52
  2. package/README.zh.md +27 -46
  3. package/dist/api/agent-chat.d.ts +10 -2
  4. package/dist/api/agent-chat.js +19 -5
  5. package/dist/api/datasources.d.ts +14 -0
  6. package/dist/api/datasources.js +14 -0
  7. package/dist/api/resources.d.ts +94 -0
  8. package/dist/api/resources.js +166 -0
  9. package/dist/cli.js +103 -23
  10. package/dist/client.d.ts +10 -4
  11. package/dist/client.js +12 -6
  12. package/dist/commands/agent-members.js +27 -11
  13. package/dist/commands/agent.js +383 -272
  14. package/dist/commands/auth.js +184 -71
  15. package/dist/commands/bkn-metric.js +37 -16
  16. package/dist/commands/bkn-ops.d.ts +1 -1
  17. package/dist/commands/bkn-ops.js +192 -93
  18. package/dist/commands/bkn-query.js +99 -31
  19. package/dist/commands/bkn-schema.d.ts +3 -3
  20. package/dist/commands/bkn-schema.js +127 -86
  21. package/dist/commands/bkn.js +158 -116
  22. package/dist/commands/call.js +23 -13
  23. package/dist/commands/config.js +22 -12
  24. package/dist/commands/context-loader.js +98 -92
  25. package/dist/commands/dataflow.js +14 -6
  26. package/dist/commands/ds.d.ts +0 -31
  27. package/dist/commands/ds.js +18 -426
  28. package/dist/commands/explore-bkn.d.ts +7 -1
  29. package/dist/commands/explore-bkn.js +32 -3
  30. package/dist/commands/explore.js +18 -15
  31. package/dist/commands/model.js +53 -42
  32. package/dist/commands/resource.d.ts +1 -0
  33. package/dist/commands/{dataview.js → resource.js} +62 -84
  34. package/dist/commands/skill.js +201 -65
  35. package/dist/commands/token.js +11 -0
  36. package/dist/commands/tool.js +46 -29
  37. package/dist/commands/toolbox.js +31 -15
  38. package/dist/commands/vega.js +466 -250
  39. package/dist/help/format.d.ts +65 -0
  40. package/dist/help/format.js +141 -0
  41. package/dist/index.d.ts +3 -3
  42. package/dist/index.js +2 -2
  43. package/dist/resources/datasources.d.ts +7 -0
  44. package/dist/resources/datasources.js +7 -0
  45. package/dist/resources/{dataviews.d.ts → resources.d.ts} +10 -11
  46. package/dist/resources/{dataviews.js → resources.js} +12 -13
  47. package/dist/templates/explorer/bkn.js +860 -9
  48. package/dist/templates/explorer/index.html +1 -0
  49. package/dist/templates/explorer/style.css +225 -0
  50. package/dist/templates/explorer/vendor/g6.min.js +68 -0
  51. package/dist/trace-ai/eval-set/schemas.d.ts +1 -0
  52. package/dist/trace-ai/eval-set/schemas.js +4 -0
  53. package/dist/trace-ai/eval-set/types.d.ts +2 -0
  54. package/dist/trace-ai/exp/capture-fingerprint.d.ts +10 -0
  55. package/dist/trace-ai/exp/capture-fingerprint.js +12 -0
  56. package/dist/trace-ai/exp/context/context-assembler.d.ts +18 -0
  57. package/dist/trace-ai/exp/context/context-assembler.js +42 -0
  58. package/dist/trace-ai/exp/context/failure-analyzer.d.ts +22 -0
  59. package/dist/trace-ai/exp/context/failure-analyzer.js +59 -0
  60. package/dist/trace-ai/exp/context/kn-data-prober.d.ts +13 -0
  61. package/dist/trace-ai/exp/context/kn-data-prober.js +38 -0
  62. package/dist/trace-ai/exp/context/kn-schema-client.d.ts +14 -0
  63. package/dist/trace-ai/exp/context/kn-schema-client.js +41 -0
  64. package/dist/trace-ai/exp/context/retrieval-health.d.ts +32 -0
  65. package/dist/trace-ai/exp/context/retrieval-health.js +138 -0
  66. package/dist/trace-ai/exp/context/vega-catalog-client.d.ts +14 -0
  67. package/dist/trace-ai/exp/context/vega-catalog-client.js +15 -0
  68. package/dist/trace-ai/exp/coordinator.d.ts +34 -21
  69. package/dist/trace-ai/exp/coordinator.js +246 -24
  70. package/dist/trace-ai/exp/eval-runner.js +4 -2
  71. package/dist/trace-ai/exp/exp-store/events-jsonl.d.ts +1 -0
  72. package/dist/trace-ai/exp/exp-store/events-jsonl.js +18 -0
  73. package/dist/trace-ai/exp/exp-store/expected-fingerprint.d.ts +3 -0
  74. package/dist/trace-ai/exp/exp-store/expected-fingerprint.js +31 -0
  75. package/dist/trace-ai/exp/exp-store/index.d.ts +63 -2
  76. package/dist/trace-ai/exp/exp-store/index.js +2 -1
  77. package/dist/trace-ai/exp/exp-store/rollback-yaml.d.ts +12 -0
  78. package/dist/trace-ai/exp/exp-store/rollback-yaml.js +29 -0
  79. package/dist/trace-ai/exp/index.d.ts +2 -0
  80. package/dist/trace-ai/exp/index.js +68 -3
  81. package/dist/trace-ai/exp/info.js +1 -1
  82. package/dist/trace-ai/exp/patch/index.d.ts +13 -2
  83. package/dist/trace-ai/exp/patch/index.js +65 -10
  84. package/dist/trace-ai/exp/patch/kn-api-client.d.ts +40 -0
  85. package/dist/trace-ai/exp/patch/kn-api-client.js +14 -0
  86. package/dist/trace-ai/exp/patch/kn.d.ts +8 -0
  87. package/dist/trace-ai/exp/patch/kn.js +36 -0
  88. package/dist/trace-ai/exp/patch/skill-api-client.d.ts +17 -0
  89. package/dist/trace-ai/exp/patch/skill-api-client.js +14 -0
  90. package/dist/trace-ai/exp/patch/skill-content.d.ts +9 -0
  91. package/dist/trace-ai/exp/patch/skill-content.js +12 -0
  92. package/dist/trace-ai/exp/preflight.d.ts +77 -0
  93. package/dist/trace-ai/exp/preflight.js +148 -0
  94. package/dist/trace-ai/exp/providers/synthesizer-client.d.ts +3 -14
  95. package/dist/trace-ai/exp/providers/synthesizer-client.js +53 -35
  96. package/dist/trace-ai/exp/providers/triage-client.d.ts +15 -2
  97. package/dist/trace-ai/exp/providers/triage-client.js +143 -28
  98. package/dist/trace-ai/exp/run-preflight.d.ts +19 -0
  99. package/dist/trace-ai/exp/run-preflight.js +56 -0
  100. package/dist/trace-ai/exp/schemas.d.ts +402 -44
  101. package/dist/trace-ai/exp/schemas.js +131 -18
  102. package/dist/utils/deprecation.d.ts +1 -0
  103. package/dist/utils/deprecation.js +18 -0
  104. package/package.json +2 -1
  105. package/dist/api/dataviews.d.ts +0 -117
  106. package/dist/api/dataviews.js +0 -265
  107. package/dist/commands/dataview.d.ts +0 -8
package/dist/cli.js CHANGED
@@ -7,16 +7,93 @@ import { runCallCommand } from "./commands/call.js";
7
7
  import { runConfigCommand } from "./commands/config.js";
8
8
  import { runContextLoaderCommand } from "./commands/context-loader.js";
9
9
  import { runDataflowCommand } from "./commands/dataflow.js";
10
- import { runDsCommand } from "./commands/ds.js";
11
10
  import { runExploreCommand } from "./commands/explore.js";
12
- import { runDataviewCommand } from "./commands/dataview.js";
11
+ import { runResourceCommand } from "./commands/resource.js";
13
12
  import { runModelCommand } from "./commands/model.js";
14
13
  import { runSkillCommand } from "./commands/skill.js";
15
14
  import { runTokenCommand } from "./commands/token.js";
16
15
  import { runToolboxCommand } from "./commands/toolbox.js";
17
16
  import { runToolCommand } from "./commands/tool.js";
18
17
  import { runVegaCommand } from "./commands/vega.js";
18
+ import { renderHelp } from "./help/format.js";
19
19
  function printHelp() {
20
+ console.log(renderHelp({
21
+ tagline: "KWeaver SDK — operate KWeaver platform from CLI",
22
+ usage: [
23
+ "kweaver [global flags] <command> <subcommand> [flags]",
24
+ "kweaver --version | -V",
25
+ "kweaver --help | -h",
26
+ ],
27
+ sections: [
28
+ {
29
+ title: "AUTHENTICATION & CONFIG",
30
+ items: [
31
+ { name: "auth", desc: "Login / switch / list saved platform credentials" },
32
+ { name: "token", desc: "Print current access token (auto-refresh)" },
33
+ { name: "config", desc: "Per-platform business-domain config" },
34
+ ],
35
+ },
36
+ {
37
+ title: "DECISION AGENT",
38
+ items: [
39
+ { name: "agent", desc: "Agent CRUD, chat, sessions, publish" },
40
+ { name: "toolbox", desc: "Agent toolbox lifecycle" },
41
+ { name: "tool", desc: "Tools inside toolbox" },
42
+ ],
43
+ },
44
+ {
45
+ title: "AI DATA PLATFORM",
46
+ items: [
47
+ { name: "bkn", desc: "Knowledge network — build, query, action, metric" },
48
+ { name: "resource (res)", desc: "Resources — list, find, get, query, delete" },
49
+ { name: "dataflow", desc: "Dataflow document workflows (run, runs, logs)" },
50
+ { name: "vega", desc: "Vega observability — catalog, resource, query" },
51
+ { name: "context-loader (context)", desc: "MCP/HTTP context loader (reads BKN schema/instances)" },
52
+ ],
53
+ },
54
+ {
55
+ title: "TRACE AI",
56
+ items: [
57
+ { name: "trace", desc: "Diagnose conversations / build eval-sets / schema validate" },
58
+ ],
59
+ },
60
+ {
61
+ title: "FOUNDATION",
62
+ items: [
63
+ { name: "call (curl)", desc: "curl-style API call with auto-injected auth headers" },
64
+ { name: "explore", desc: "Interactive web UI" },
65
+ { name: "model", desc: "Model factory — LLM / small-model CRUD + chat" },
66
+ { name: "skill", desc: "Skill registry / market" },
67
+ { name: "help", desc: "Show help — use `help all` for full signatures" },
68
+ ],
69
+ },
70
+ ],
71
+ flags: [
72
+ { name: "--base-url <url>", desc: "Override platform URL (env: KWEAVER_BASE_URL)" },
73
+ { name: "--token <value>", desc: "Override access token (env: KWEAVER_TOKEN; disables write commands)" },
74
+ { name: "--user <id|name>", desc: "Use specific user credentials (env: KWEAVER_USER)" },
75
+ { name: "--pretty", desc: "Pretty-print JSON output (default)" },
76
+ { name: "--compact", desc: "Compact JSON output (pipeline-friendly)" },
77
+ { name: "--help, -h", desc: "Show help" },
78
+ { name: "--version, -V", desc: "Show version" },
79
+ ],
80
+ environment: [
81
+ { name: "KWEAVER_PROFILE", desc: "Isolate active-platform/user state per shell" },
82
+ { name: "KWEAVERC_CONFIG_DIR", desc: "Override config root (~/.kweaver)" },
83
+ ],
84
+ examples: [
85
+ "kweaver auth https://platform.example.com",
86
+ "kweaver agent chat <agent_id> -m \"hello\"",
87
+ "kweaver bkn build <kn-id> --wait",
88
+ ],
89
+ learnMore: [
90
+ "Use `kweaver <command> --help` for command-specific help",
91
+ "Use `kweaver help all` for full command signatures (migration fallback)",
92
+ "For agents/multi-terminal: prefer `--user <id>` over `auth switch`",
93
+ ],
94
+ }));
95
+ }
96
+ function printHelpFull() {
20
97
  console.log(`kweaver
21
98
 
22
99
  Usage:
@@ -56,13 +133,6 @@ Usage:
56
133
  kweaver agent publish <agent_id> [-bd value]
57
134
  kweaver agent unpublish <agent_id> [-bd value]
58
135
 
59
- kweaver ds list [--keyword X] [--type T] [-bd value]
60
- kweaver ds get <id>
61
- kweaver ds delete <id> [-y]
62
- kweaver ds tables <id> [--keyword X]
63
- kweaver ds connect <db_type> <host> <port> <database> --account X --password Y [--schema S] [--name N]
64
- [--reuse-existing|--force-new]
65
-
66
136
  kweaver dataflow templates [--json]
67
137
  kweaver dataflow create-dataset --template <name> --set "key=value" [--json] [-bd value]
68
138
  kweaver dataflow create-bkn --template <name> --set "key=value" [--json] [-bd value]
@@ -76,17 +146,18 @@ Usage:
76
146
  kweaver model small list|get|add|edit|delete|test|embeddings|rerank|--template ...
77
147
  kweaver model --help
78
148
 
79
- kweaver dataview list [--datasource-id id] [--type atomic|custom] [--limit n] [-bd value]
80
- kweaver dataview find --name <name> [--exact] [--datasource-id id] [--wait] [--timeout ms] [-bd value]
81
- kweaver dataview get <id> [-bd value]
82
- kweaver dataview query <id> [--sql sql] [--limit n] [--offset n] [--need-total] [--raw-sql] [-bd value]
83
- kweaver dataview delete <id> [-y] [-bd value]
149
+ kweaver resource list [--datasource-id id] [--type table|logicview] [--limit n] [-bd value]
150
+ kweaver resource find --name <name> [--exact] [--datasource-id id] [--wait] [--timeout ms] [-bd value]
151
+ kweaver resource get <id> [-bd value]
152
+ kweaver resource query <id> [--limit n] [--offset n] [--need-total] [-bd value]
153
+ kweaver resource delete <id> [-y] [-bd value]
84
154
 
85
155
  kweaver bkn list [options]
86
156
  kweaver bkn get <kn-id> [options]
87
157
  kweaver bkn search <kn-id> <query> [--max-concepts N] [--mode M] [-bd value]
88
158
  kweaver bkn create [options]
89
- kweaver bkn create-from-ds [options]
159
+ kweaver bkn create-from-catalog [options]
160
+ [deprecated] kweaver bkn create-from-ds [options] (alias for create-from-catalog)
90
161
  kweaver bkn update <kn-id> [options]
91
162
  kweaver bkn delete <kn-id> [-y]
92
163
  kweaver bkn build <kn-id> [--wait] [--no-wait] [--timeout N]
@@ -173,10 +244,9 @@ Commands:
173
244
  token Print the current access token, refreshing it first if needed
174
245
  call (curl) Call an API with curl-style flags and auto-injected token headers
175
246
  agent Agent CRUD, chat, sessions, history, publish/unpublish
176
- ds Manage datasources (list, get, delete, tables, connect)
177
247
  dataflow Dataflow document workflows (list, run, runs, logs)
178
248
  model Model factory: LLM/small-model CRUD (manager) and llm chat (OpenAI-compatible API)
179
- dataview|dv List, find, get, query (SQL), delete data views (atomic / custom)
249
+ resource|res List, find, get, query, delete vega-backend resources (table / logicview)
180
250
  bkn Knowledge network (CRUD, build, validate, export, stats, push/pull,
181
251
  object-type, relation-type, subgraph, action-type, action-execution, action-log)
182
252
  config Per-platform configuration (business domain)
@@ -238,27 +308,37 @@ export async function run(argv) {
238
308
  console.log(pkg.version);
239
309
  return 0;
240
310
  }
241
- if (argv.length === 0 || !command || command === "--help" || command === "-h" || command === "help") {
311
+ if (argv.length === 0 || !command || command === "--help" || command === "-h") {
242
312
  printHelp();
243
313
  return 0;
244
314
  }
315
+ if (command === "help") {
316
+ const topic = rest[0];
317
+ if (!topic) {
318
+ printHelp();
319
+ return 0;
320
+ }
321
+ if (topic === "all") {
322
+ printHelpFull();
323
+ return 0;
324
+ }
325
+ // `help <command>` → forward to `<command> --help`
326
+ return run([...rest, "--help"]);
327
+ }
245
328
  if (command === "auth") {
246
329
  return runAuthCommand(rest);
247
330
  }
248
331
  if (command === "call" || command === "curl") {
249
332
  return runCallCommand(rest);
250
333
  }
251
- if (command === "ds") {
252
- return runDsCommand(rest);
253
- }
254
334
  if (command === "dataflow") {
255
335
  return runDataflowCommand(rest);
256
336
  }
257
337
  if (command === "model") {
258
338
  return runModelCommand(rest);
259
339
  }
260
- if (command === "dataview" || command === "dv") {
261
- return runDataviewCommand(rest);
340
+ if (command === "resource" || command === "res") {
341
+ return runResourceCommand(rest);
262
342
  }
263
343
  if (command === "token") {
264
344
  return runTokenCommand(rest);
package/dist/client.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ConversationsResource } from "./resources/conversations.js";
3
3
  import { ContextLoaderResource } from "./resources/context-loader.js";
4
4
  import { DataflowsResource } from "./resources/dataflows.js";
5
5
  import { DataSourcesResource } from "./resources/datasources.js";
6
- import { DataViewsResource } from "./resources/dataviews.js";
6
+ import { ResourcesResource } from "./resources/resources.js";
7
7
  import { KnowledgeNetworksResource } from "./resources/knowledge-networks.js";
8
8
  import { BknResource } from "./resources/bkn.js";
9
9
  import { SkillsResource } from "./resources/skills.js";
@@ -96,10 +96,16 @@ export declare class KWeaverClient implements ClientContext {
96
96
  readonly conversations: ConversationsResource;
97
97
  /** Dataflow DAG automation (create/run/poll/delete). */
98
98
  readonly dataflows: DataflowsResource;
99
- /** Data source management (connect, test, list tables). */
99
+ /**
100
+ * Data source management (connect, test, list tables).
101
+ *
102
+ * @deprecated Datasource is a legacy concept. Use `client.vega.catalogs` for
103
+ * catalog CRUD and `client.resources` for resource queries. This property is
104
+ * kept as a thin back-compat layer and may be removed in a future major release.
105
+ */
100
106
  readonly datasources: DataSourcesResource;
101
- /** Data view creation and retrieval. */
102
- readonly dataviews: DataViewsResource;
107
+ /** Vega-backend resource management (table/logicview resources under a catalog). */
108
+ readonly resources: ResourcesResource;
103
109
  /** Vega observability platform (catalogs, resources, connector types). */
104
110
  readonly vega: VegaResource;
105
111
  /** ADP/KWeaver skill registry, market, progressive read, and install helpers. */
package/dist/client.js CHANGED
@@ -8,7 +8,7 @@ import { ConversationsResource } from "./resources/conversations.js";
8
8
  import { ContextLoaderResource } from "./resources/context-loader.js";
9
9
  import { DataflowsResource } from "./resources/dataflows.js";
10
10
  import { DataSourcesResource } from "./resources/datasources.js";
11
- import { DataViewsResource } from "./resources/dataviews.js";
11
+ import { ResourcesResource } from "./resources/resources.js";
12
12
  import { KnowledgeNetworksResource } from "./resources/knowledge-networks.js";
13
13
  import { BknResource } from "./resources/bkn.js";
14
14
  import { SkillsResource } from "./resources/skills.js";
@@ -58,10 +58,16 @@ export class KWeaverClient {
58
58
  conversations;
59
59
  /** Dataflow DAG automation (create/run/poll/delete). */
60
60
  dataflows;
61
- /** Data source management (connect, test, list tables). */
61
+ /**
62
+ * Data source management (connect, test, list tables).
63
+ *
64
+ * @deprecated Datasource is a legacy concept. Use `client.vega.catalogs` for
65
+ * catalog CRUD and `client.resources` for resource queries. This property is
66
+ * kept as a thin back-compat layer and may be removed in a future major release.
67
+ */
62
68
  datasources;
63
- /** Data view creation and retrieval. */
64
- dataviews;
69
+ /** Vega-backend resource management (table/logicview resources under a catalog). */
70
+ resources;
65
71
  /** Vega observability platform (catalogs, resources, connector types). */
66
72
  vega;
67
73
  /** ADP/KWeaver skill registry, market, progressive read, and install helpers. */
@@ -100,7 +106,7 @@ export class KWeaverClient {
100
106
  this.conversations = new ConversationsResource(this);
101
107
  this.dataflows = new DataflowsResource(this);
102
108
  this.datasources = new DataSourcesResource(this);
103
- this.dataviews = new DataViewsResource(this);
109
+ this.resources = new ResourcesResource(this);
104
110
  this.vega = new VegaResource(this);
105
111
  this.skills = new SkillsResource(this);
106
112
  this.toolboxes = new ToolboxesResource(this);
@@ -156,7 +162,7 @@ export class KWeaverClient {
156
162
  this.conversations = new ConversationsResource(this);
157
163
  this.dataflows = new DataflowsResource(this);
158
164
  this.datasources = new DataSourcesResource(this);
159
- this.dataviews = new DataViewsResource(this);
165
+ this.resources = new ResourcesResource(this);
160
166
  this.vega = new VegaResource(this);
161
167
  this.skills = new SkillsResource(this);
162
168
  this.toolboxes = new ToolboxesResource(this);
@@ -6,6 +6,7 @@ import { getAgent, updateAgent } from "../api/agent-list.js";
6
6
  import { getSkill } from "../api/skills.js";
7
7
  import { ensureValidToken, formatHttpError } from "../auth/oauth.js";
8
8
  import { resolveBusinessDomain } from "../config/store.js";
9
+ import { renderHelp } from "../help/format.js";
9
10
  /** Deep-clone a JSON-serializable object so mutations don't leak to callers. */
10
11
  function clone(value) {
11
12
  return JSON.parse(JSON.stringify(value));
@@ -353,17 +354,32 @@ async function runSkillList(args) {
353
354
  export async function runAgentSkillCommand(args) {
354
355
  const [verb, ...rest] = args;
355
356
  if (!verb || verb === "--help" || verb === "-h") {
356
- console.log(`kweaver agent skill
357
-
358
- Subcommands:
359
- add <agent-id> <skill-id>... [--strict] [-bd <bd>] Attach skills to an agent
360
- remove <agent-id> <skill-id>... [-bd <bd>] Detach skills from an agent
361
- list <agent-id> [--pretty|--compact] [-bd <bd>] List skills attached to an agent
362
-
363
- Notes:
364
- --strict On add, reject skills that exist but are not in 'published' status.
365
- Default behaviour: warn and continue.
366
- Dedupe is automatic for add; remove silently skips not-attached ids.`);
357
+ console.log(renderHelp({
358
+ tagline: "Manage skills attached to an agent",
359
+ usage: "kweaver agent skill <subcommand> [flags]",
360
+ sections: [{
361
+ title: "AVAILABLE COMMANDS",
362
+ items: [
363
+ { name: "add", desc: "Attach skills to an agent" },
364
+ { name: "remove", desc: "Detach skills from an agent" },
365
+ { name: "list", desc: "List skills attached to an agent" },
366
+ ],
367
+ }],
368
+ flags: [
369
+ { name: "--strict", desc: "On add, reject skills that exist but are not in 'published' status. Default behaviour: warn and continue." },
370
+ { name: "-bd <bd>", desc: "Business domain" },
371
+ { name: "--pretty|--compact", desc: "Output formatting for list" },
372
+ ],
373
+ inheritedFlags: "--base-url, --token, --user, --help",
374
+ examples: [
375
+ "kweaver agent skill add <agent-id> <skill-id>... [--strict] [-bd <bd>]",
376
+ "kweaver agent skill remove <agent-id> <skill-id>... [-bd <bd>]",
377
+ "kweaver agent skill list <agent-id> [--pretty|--compact] [-bd <bd>]",
378
+ ],
379
+ learnMore: [
380
+ "Dedupe is automatic for add; remove silently skips not-attached ids.",
381
+ ],
382
+ }));
367
383
  return 0;
368
384
  }
369
385
  try {