@kweaver-ai/kweaver-sdk 0.4.12 → 0.4.14

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.
@@ -1,4 +1,15 @@
1
1
  import { type BknEncodingImportOptions } from "../utils/bkn-encoding.js";
2
+ export interface PollOptions<T> {
3
+ fn: () => Promise<{
4
+ done: boolean;
5
+ value: T;
6
+ }>;
7
+ interval: number;
8
+ timeout: number;
9
+ maxInterval?: number;
10
+ _sleep?: (ms: number) => Promise<void>;
11
+ }
12
+ export declare function pollWithBackoff<T>(opts: PollOptions<T>): Promise<T>;
2
13
  export interface KnListOptions {
3
14
  offset: number;
4
15
  limit: number;
@@ -14,6 +14,19 @@ import { downloadBkn, uploadBkn } from "../api/bkn-backend.js";
14
14
  import { formatCallOutput } from "./call.js";
15
15
  import { resolveBusinessDomain } from "../config/store.js";
16
16
  import { runDsImportCsv } from "./ds.js";
17
+ export async function pollWithBackoff(opts) {
18
+ const { fn, timeout, maxInterval = 15000, _sleep = (ms) => new Promise(r => setTimeout(r, ms)) } = opts;
19
+ let currentInterval = opts.interval;
20
+ const deadline = Date.now() + timeout;
21
+ while (Date.now() < deadline) {
22
+ const result = await fn();
23
+ if (result.done)
24
+ return result.value;
25
+ await _sleep(currentInterval);
26
+ currentInterval = Math.min(currentInterval * 2, maxInterval);
27
+ }
28
+ throw new Error(`Polling timed out after ${timeout}ms`);
29
+ }
17
30
  export function formatSimpleKnList(text, pretty, includeDetail = false) {
18
31
  const parsed = JSON.parse(text);
19
32
  const entries = Array.isArray(parsed.entries) ? parsed.entries : [];
@@ -27,7 +40,7 @@ export function formatSimpleKnList(text, pretty, includeDetail = false) {
27
40
  }
28
41
  export function parseKnListArgs(args) {
29
42
  let offset = 0;
30
- let limit = 50;
43
+ let limit = 30;
31
44
  let sort = "update_time";
32
45
  let direction = "desc";
33
46
  let businessDomain = "";
@@ -49,9 +62,9 @@ export function parseKnListArgs(args) {
49
62
  continue;
50
63
  }
51
64
  if (arg === "--limit") {
52
- limit = parseInt(args[i + 1] ?? "50", 10);
65
+ limit = parseInt(args[i + 1] ?? "30", 10);
53
66
  if (Number.isNaN(limit) || limit < 1)
54
- limit = 50;
67
+ limit = 30;
55
68
  i += 1;
56
69
  continue;
57
70
  }
@@ -582,7 +595,7 @@ export function parseKnObjectTypeQueryArgs(args) {
582
595
  body.search_after = searchAfter;
583
596
  }
584
597
  if (typeof body.limit !== "number" || !Number.isFinite(body.limit) || body.limit < 1) {
585
- body.limit = 30;
598
+ body.limit = 50;
586
599
  }
587
600
  if (!businessDomain)
588
601
  businessDomain = resolveBusinessDomain();
@@ -1126,7 +1139,7 @@ kweaver bkn object-type properties <kn-id> <ot-id> '<json>' [--pretty] [-bd valu
1126
1139
  list: List object types (schema) from ontology-manager.
1127
1140
  get: Get single object type details.
1128
1141
  create/update/delete: Schema CRUD (create requires dataview-id). update: merge flags (--add-property / --update-property / --remove-property, etc.) GET-merge-PUT; or full JSON as third arg.
1129
- query: Query via ontology-query API. Default limit is 30 if not specified. Use --search-after for pagination.
1142
+ query: Query via ontology-query API. Default limit is 50 if not specified. Use --search-after for pagination.
1130
1143
  properties: Query instance properties by primary key.
1131
1144
 
1132
1145
  properties JSON format: {"_instance_identities":[{"<primary-key>":"<value>"}],"properties":["prop1","prop2"]}`);
@@ -1719,26 +1732,35 @@ query/execute: Query or execute actions. execute has side effects - only use whe
1719
1732
  console.log(formatCallOutput(result, options.pretty));
1720
1733
  return 0;
1721
1734
  }
1722
- const deadline = Date.now() + options.timeout * 1000;
1723
1735
  let lastBody = result;
1724
- while (Date.now() < deadline) {
1725
- const status = extractStatus(lastBody);
1726
- if (TERMINAL_STATUSES.includes(status.toUpperCase())) {
1727
- console.log(formatCallOutput(lastBody, options.pretty));
1728
- return status.toUpperCase() === "SUCCESS" ? 0 : 1;
1729
- }
1730
- await new Promise((r) => setTimeout(r, 2000));
1731
- lastBody = await actionExecutionGet({
1732
- baseUrl: token.baseUrl,
1733
- accessToken: token.accessToken,
1734
- knId: options.knId,
1735
- executionId,
1736
- businessDomain: options.businessDomain,
1736
+ try {
1737
+ lastBody = await pollWithBackoff({
1738
+ fn: async () => {
1739
+ const status = extractStatus(lastBody);
1740
+ if (TERMINAL_STATUSES.includes(status.toUpperCase())) {
1741
+ return { done: true, value: lastBody };
1742
+ }
1743
+ lastBody = await actionExecutionGet({
1744
+ baseUrl: token.baseUrl,
1745
+ accessToken: token.accessToken,
1746
+ knId: options.knId,
1747
+ executionId,
1748
+ businessDomain: options.businessDomain,
1749
+ });
1750
+ return { done: false, value: lastBody };
1751
+ },
1752
+ interval: 2000,
1753
+ timeout: options.timeout * 1000,
1737
1754
  });
1738
1755
  }
1739
- console.error(`Action execution did not complete within ${options.timeout}s`);
1756
+ catch {
1757
+ console.error(`Action execution did not complete within ${options.timeout}s`);
1758
+ console.log(formatCallOutput(lastBody, options.pretty));
1759
+ return 1;
1760
+ }
1761
+ const finalStatus = extractStatus(lastBody);
1740
1762
  console.log(formatCallOutput(lastBody, options.pretty));
1741
- return 1;
1763
+ return finalStatus.toUpperCase() === "SUCCESS" ? 0 : 1;
1742
1764
  }
1743
1765
  catch (error) {
1744
1766
  console.error(formatHttpError(error));
@@ -1802,7 +1824,7 @@ Options for list: --limit, --need-total, --action-type-id, --status, --trigger-t
1802
1824
  }
1803
1825
  let pretty = true;
1804
1826
  let businessDomain = "";
1805
- let limit;
1827
+ let limit = 30;
1806
1828
  let needTotal;
1807
1829
  let actionTypeId;
1808
1830
  let status;
@@ -1955,7 +1977,7 @@ List business knowledge networks from the ontology-manager API.
1955
1977
 
1956
1978
  Options:
1957
1979
  --offset <n> Offset (default: 0)
1958
- --limit <n> Limit (default: 50)
1980
+ --limit <n> Limit (default: 30)
1959
1981
  --sort <key> Sort field (default: update_time)
1960
1982
  --direction <asc|desc> Sort direction (default: desc)
1961
1983
  --name-pattern <s> Filter by name pattern
@@ -2274,18 +2296,24 @@ async function runKnCreateFromDsCommand(args, sampleRows) {
2274
2296
  if (options.build) {
2275
2297
  console.error("Building ...");
2276
2298
  await buildKnowledgeNetwork({ ...base, knId });
2277
- const deadline = Date.now() + options.timeout * 1000;
2278
2299
  const TERMINAL = ["completed", "failed", "success"];
2279
- while (Date.now() < deadline) {
2280
- await new Promise((r) => setTimeout(r, 2000));
2281
- const statusBody = await getBuildStatus({ ...base, knId });
2282
- const statusParsed = JSON.parse(statusBody);
2283
- const jobs = Array.isArray(statusParsed) ? statusParsed : (statusParsed.entries ?? []);
2284
- const state = (jobs[0]?.state ?? "running").toLowerCase();
2285
- if (TERMINAL.includes(state)) {
2286
- statusStr = state;
2287
- break;
2288
- }
2300
+ try {
2301
+ statusStr = await pollWithBackoff({
2302
+ fn: async () => {
2303
+ const statusBody = await getBuildStatus({ ...base, knId });
2304
+ const statusParsed = JSON.parse(statusBody);
2305
+ const jobs = Array.isArray(statusParsed) ? statusParsed : (statusParsed.entries ?? []);
2306
+ const state = (jobs[0]?.state ?? "running").toLowerCase();
2307
+ if (TERMINAL.includes(state))
2308
+ return { done: true, value: state };
2309
+ return { done: false, value: "running" };
2310
+ },
2311
+ interval: 2000,
2312
+ timeout: options.timeout * 1000,
2313
+ });
2314
+ }
2315
+ catch {
2316
+ // timeout — statusStr remains "skipped"
2289
2317
  }
2290
2318
  }
2291
2319
  const output = {
@@ -2456,30 +2484,37 @@ async function runKnBuildCommand(args) {
2456
2484
  return 0;
2457
2485
  }
2458
2486
  console.error("Waiting for build to complete ...");
2459
- const deadline = Date.now() + options.timeout * 1000;
2460
- while (Date.now() < deadline) {
2461
- await new Promise((r) => setTimeout(r, 2000));
2462
- const body = await getBuildStatus({
2463
- baseUrl: token.baseUrl,
2464
- accessToken: token.accessToken,
2465
- knId: options.knId,
2466
- businessDomain: options.businessDomain,
2487
+ try {
2488
+ const { state, detail } = await pollWithBackoff({
2489
+ fn: async () => {
2490
+ const body = await getBuildStatus({
2491
+ baseUrl: token.baseUrl,
2492
+ accessToken: token.accessToken,
2493
+ knId: options.knId,
2494
+ businessDomain: options.businessDomain,
2495
+ });
2496
+ const parsed = JSON.parse(body);
2497
+ const jobs = Array.isArray(parsed) ? parsed : (parsed.entries ?? parsed.data ?? []);
2498
+ const job = jobs[0];
2499
+ const st = (job?.state ?? "running").toLowerCase();
2500
+ const dt = job?.state_detail;
2501
+ if (TERMINAL_STATES.includes(st))
2502
+ return { done: true, value: { state: st, detail: dt } };
2503
+ return { done: false, value: { state: st } };
2504
+ },
2505
+ interval: 2000,
2506
+ timeout: options.timeout * 1000,
2467
2507
  });
2468
- const parsed = JSON.parse(body);
2469
- const jobs = Array.isArray(parsed) ? parsed : (parsed.entries ?? parsed.data ?? []);
2470
- const job = jobs[0];
2471
- const state = (job?.state ?? "running").toLowerCase();
2472
- const detail = job?.state_detail;
2473
- if (TERMINAL_STATES.includes(state)) {
2474
- console.log(state);
2475
- if (detail) {
2476
- console.log(`Detail: ${detail}`);
2477
- }
2478
- return state === "failed" ? 1 : 0;
2508
+ console.log(state);
2509
+ if (detail) {
2510
+ console.log(`Detail: ${detail}`);
2479
2511
  }
2512
+ return state === "failed" ? 1 : 0;
2513
+ }
2514
+ catch {
2515
+ console.error(`Build did not complete within ${options.timeout}s`);
2516
+ return 1;
2480
2517
  }
2481
- console.error(`Build did not complete within ${options.timeout}s`);
2482
- return 1;
2483
2518
  }
2484
2519
  catch (error) {
2485
2520
  console.error(formatHttpError(error));
@@ -1,13 +1,17 @@
1
- import { getCurrentPlatform, resolveBusinessDomain, savePlatformBusinessDomain, loadPlatformBusinessDomain, } from "../config/store.js";
1
+ import { listBusinessDomains } from "../api/business-domains.js";
2
+ import { withTokenRetry } from "../auth/oauth.js";
3
+ import { getCurrentPlatform, loadPlatformBusinessDomain, resolveBusinessDomain, savePlatformBusinessDomain, } from "../config/store.js";
2
4
  const HELP = `kweaver config
3
5
 
4
6
  Subcommands:
5
7
  set-bd <value> Set the default business domain for the current platform
8
+ list-bd List business domains as JSON (requires login)
6
9
  show Show current config (platform, business domain)
7
10
  --help Show this message
8
11
 
9
12
  Examples:
10
13
  kweaver config set-bd 54308785-4438-43df-9490-a7fd11df5765
14
+ kweaver config list-bd
11
15
  kweaver config show`;
12
16
  export async function runConfigCommand(args) {
13
17
  const [sub, ...rest] = args;
@@ -46,6 +50,35 @@ export async function runConfigCommand(args) {
46
50
  console.log(`Business domain set to: ${value}`);
47
51
  return 0;
48
52
  }
53
+ if (sub === "list-bd") {
54
+ const platform = getCurrentPlatform();
55
+ if (!platform) {
56
+ console.error("No active platform. Run `kweaver auth login <url>` first.");
57
+ return 1;
58
+ }
59
+ try {
60
+ const rows = await withTokenRetry((token) => listBusinessDomains({
61
+ baseUrl: platform,
62
+ accessToken: token.accessToken,
63
+ tlsInsecure: token.tlsInsecure,
64
+ }));
65
+ const currentId = resolveBusinessDomain(platform);
66
+ const payload = {
67
+ currentId,
68
+ domains: rows.map((r) => ({
69
+ ...r,
70
+ current: r.id === currentId,
71
+ })),
72
+ };
73
+ console.log(JSON.stringify(payload, null, 2));
74
+ return 0;
75
+ }
76
+ catch (error) {
77
+ const message = error instanceof Error ? error.message : String(error);
78
+ console.error(`Failed to list business domains: ${message}`);
79
+ return 1;
80
+ }
81
+ }
49
82
  console.error(`Unknown config subcommand: ${sub}`);
50
83
  console.log(HELP);
51
84
  return 1;
@@ -1,6 +1,6 @@
1
1
  import { createInterface } from "node:readline";
2
2
  import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/oauth.js";
3
- import { deleteDataView, findDataView, getDataView, listDataViews, } from "../api/dataviews.js";
3
+ import { deleteDataView, findDataView, getDataView, listDataViews, queryDataView, } from "../api/dataviews.js";
4
4
  import { formatCallOutput } from "./call.js";
5
5
  import { resolveBusinessDomain } from "../config/store.js";
6
6
  function confirmYes(prompt) {
@@ -22,10 +22,12 @@ Subcommands:
22
22
  list [--datasource-id <id>] [--type <atomic|custom>] [--limit <n>] [-bd value] [--pretty]
23
23
  find --name <name> [--exact] [--datasource-id <id>] [--wait] [--no-wait] [--timeout <ms>] [-bd value] [--pretty]
24
24
  get <id> [-bd value] [--pretty]
25
+ query <id> [--sql <sql>] [--limit <n>] [--offset <n>] [--need-total] [-bd value] [--pretty]
25
26
  delete <id> [-y] [-bd value]
26
27
 
27
28
  list — list all data views (no keyword search)
28
- find — search by name; default fuzzy, --exact for strict match, --wait to poll`);
29
+ find — search by name; default fuzzy, --exact for strict match, --wait to poll
30
+ query — run SQL query against a data view (mdl-uniquery); omit --sql to use view default SQL`);
29
31
  return 0;
30
32
  }
31
33
  const dispatch = () => {
@@ -35,6 +37,8 @@ Subcommands:
35
37
  return runDataviewFindCommand(rest);
36
38
  if (subcommand === "get")
37
39
  return runDataviewGetCommand(rest);
40
+ if (subcommand === "query")
41
+ return runDataviewQueryCommand(rest);
38
42
  if (subcommand === "delete")
39
43
  return runDataviewDeleteCommand(rest);
40
44
  return Promise.resolve(-1);
@@ -204,6 +208,61 @@ async function runDataviewGetCommand(args) {
204
208
  console.log(formatCallOutput(JSON.stringify(view), pretty));
205
209
  return 0;
206
210
  }
211
+ async function runDataviewQueryCommand(args) {
212
+ const { businessDomain, pretty } = parseDataviewCommonArgs(args);
213
+ let sql;
214
+ let limit = 50;
215
+ let offset = 0;
216
+ let needTotal = false;
217
+ if (args.length === 0 || args[0].startsWith("-")) {
218
+ console.error("Usage: kweaver dataview query <id> [--sql <sql>] [--limit <n>] [--offset <n>] [--need-total] [-bd value] [--pretty]");
219
+ return 1;
220
+ }
221
+ const id = args[0];
222
+ const tail = args.slice(1);
223
+ for (let i = 0; i < tail.length; i += 1) {
224
+ const arg = tail[i];
225
+ if (arg === "-bd" || arg === "--biz-domain") {
226
+ i += 1;
227
+ continue;
228
+ }
229
+ if (arg === "--pretty")
230
+ continue;
231
+ if ((arg === "--sql" || arg === "-s") && tail[i + 1]) {
232
+ sql = tail[++i];
233
+ continue;
234
+ }
235
+ if (arg === "--limit" && tail[i + 1]) {
236
+ const n = Number.parseInt(tail[++i], 10);
237
+ if (!Number.isNaN(n))
238
+ limit = n;
239
+ continue;
240
+ }
241
+ if (arg === "--offset" && tail[i + 1]) {
242
+ const n = Number.parseInt(tail[++i], 10);
243
+ if (!Number.isNaN(n))
244
+ offset = n;
245
+ continue;
246
+ }
247
+ if (arg === "--need-total") {
248
+ needTotal = true;
249
+ continue;
250
+ }
251
+ }
252
+ const token = await ensureValidToken();
253
+ const result = await queryDataView({
254
+ baseUrl: token.baseUrl,
255
+ accessToken: token.accessToken,
256
+ businessDomain,
257
+ id,
258
+ sql,
259
+ offset,
260
+ limit,
261
+ needTotal,
262
+ });
263
+ console.log(formatCallOutput(JSON.stringify(result), pretty));
264
+ return 0;
265
+ }
207
266
  async function runDataviewDeleteCommand(args) {
208
267
  let id = "";
209
268
  let yes = false;
@@ -219,14 +219,14 @@ async function runCatalogList(args) {
219
219
 
220
220
  Options:
221
221
  --status <s> Filter by status
222
- --limit <n> Max results
222
+ --limit <n> Max results (default: 30)
223
223
  --offset <n> Offset
224
224
  -bd, --biz-domain Business domain (default: bd_public)
225
225
  --pretty Pretty-print JSON (default)`);
226
226
  return 0;
227
227
  }
228
228
  let status;
229
- let limit;
229
+ let limit = 30;
230
230
  let offset;
231
231
  const { remaining, businessDomain, pretty } = parseCommonFlags(args);
232
232
  for (let i = 0; i < remaining.length; i += 1) {
@@ -383,11 +383,11 @@ async function runCatalogResources(args) {
383
383
 
384
384
  Options:
385
385
  --category <s> Filter by category
386
- --limit <n> Max results`);
386
+ --limit <n> Max results (default: 30)`);
387
387
  return 0;
388
388
  }
389
389
  let category;
390
- let limit;
390
+ let limit = 30;
391
391
  const { remaining, businessDomain, pretty } = parseCommonFlags(args);
392
392
  const positionals = [];
393
393
  for (let i = 0; i < remaining.length; i += 1) {
@@ -458,7 +458,7 @@ Options:
458
458
  --catalog-id <s> Filter by catalog
459
459
  --category <s> Filter by category
460
460
  --status <s> Filter by status
461
- --limit <n> Max results
461
+ --limit <n> Max results (default: 30)
462
462
  --offset <n> Offset
463
463
  -bd, --biz-domain Business domain (default: bd_public)
464
464
  --pretty Pretty-print JSON (default)`);
@@ -467,7 +467,7 @@ Options:
467
467
  let catalogId;
468
468
  let category;
469
469
  let status;
470
- let limit;
470
+ let limit = 30;
471
471
  let offset;
472
472
  const { remaining, businessDomain, pretty } = parseCommonFlags(args);
473
473
  for (let i = 0; i < remaining.length; i += 1) {
@@ -579,7 +579,7 @@ async function runResourcePreview(args) {
579
579
  console.log(`kweaver vega resource preview <id> [--limit N]
580
580
 
581
581
  Options:
582
- --limit <n> Number of rows to preview (default: 10)`);
582
+ --limit <n> Number of rows to preview (default: 50)`);
583
583
  return 0;
584
584
  }
585
585
  let limit;
@@ -78,3 +78,11 @@ export declare function savePlatformBusinessDomain(baseUrl: string, businessDoma
78
78
  * If baseUrl is omitted, uses the current platform.
79
79
  */
80
80
  export declare function resolveBusinessDomain(baseUrl?: string): string;
81
+ /**
82
+ * Pick and persist a default business domain after login when none is configured.
83
+ * Skips API calls when KWEAVER_BUSINESS_DOMAIN is set or config already has businessDomain.
84
+ * Preference: bd_public if present in the list, else first item; empty list or failure → bd_public (not saved).
85
+ */
86
+ export declare function autoSelectBusinessDomain(baseUrl: string, accessToken: string, options?: {
87
+ tlsInsecure?: boolean;
88
+ }): Promise<string>;
@@ -1,6 +1,7 @@
1
1
  import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync, } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
+ import { listBusinessDomains } from "../api/business-domains.js";
4
5
  const MCP_PATH = "/api/agent-retrieval/v1/mcp";
5
6
  function buildMcpUrl(baseUrl) {
6
7
  return baseUrl.replace(/\/+$/, "") + MCP_PATH;
@@ -394,3 +395,41 @@ export function resolveBusinessDomain(baseUrl) {
394
395
  }
395
396
  return "bd_public";
396
397
  }
398
+ /**
399
+ * Pick and persist a default business domain after login when none is configured.
400
+ * Skips API calls when KWEAVER_BUSINESS_DOMAIN is set or config already has businessDomain.
401
+ * Preference: bd_public if present in the list, else first item; empty list or failure → bd_public (not saved).
402
+ */
403
+ export async function autoSelectBusinessDomain(baseUrl, accessToken, options) {
404
+ if (process.env.KWEAVER_BUSINESS_DOMAIN) {
405
+ return process.env.KWEAVER_BUSINESS_DOMAIN;
406
+ }
407
+ const configured = loadPlatformBusinessDomain(baseUrl);
408
+ if (configured) {
409
+ return configured;
410
+ }
411
+ try {
412
+ const list = await listBusinessDomains({
413
+ baseUrl,
414
+ accessToken,
415
+ tlsInsecure: options?.tlsInsecure,
416
+ });
417
+ let selected;
418
+ if (list.some((d) => d.id === "bd_public")) {
419
+ selected = "bd_public";
420
+ }
421
+ else if (list.length > 0 && list[0].id) {
422
+ selected = list[0].id;
423
+ }
424
+ else {
425
+ return "bd_public";
426
+ }
427
+ savePlatformBusinessDomain(baseUrl, selected);
428
+ return selected;
429
+ }
430
+ catch (error) {
431
+ const message = error instanceof Error ? error.message : String(error);
432
+ console.warn(`Could not fetch business domains: ${message}. Using bd_public.`);
433
+ return "bd_public";
434
+ }
435
+ }
package/dist/index.d.ts CHANGED
@@ -49,9 +49,11 @@ export type { AgentConfig, AgentInput, AgentInputField, AgentOutput, AgentLlmCon
49
49
  export { BknResource } from "./resources/bkn.js";
50
50
  export { ConversationsResource } from "./resources/conversations.js";
51
51
  export { ContextLoaderResource } from "./resources/context-loader.js";
52
- export type { ViewField, DataView, CreateDataViewOptions, GetDataViewOptions, ListDataViewsOptions, DeleteDataViewOptions, FindDataViewOptions, } from "./api/dataviews.js";
53
- export { parseDataView, createDataView, getDataView, listDataViews, deleteDataView, findDataView, } from "./api/dataviews.js";
52
+ export type { ViewField, DataView, CreateDataViewOptions, GetDataViewOptions, ListDataViewsOptions, DeleteDataViewOptions, FindDataViewOptions, QueryDataViewOptions, DataViewQueryResult, } from "./api/dataviews.js";
53
+ export { parseDataView, createDataView, getDataView, listDataViews, deleteDataView, findDataView, queryDataView, } from "./api/dataviews.js";
54
54
  export { DataViewsResource } from "./resources/dataviews.js";
55
+ export type { BusinessDomain, ListBusinessDomainsOptions } from "./api/business-domains.js";
56
+ export { listBusinessDomains } from "./api/business-domains.js";
55
57
  export { HttpError, NetworkRequestError, fetchTextOrThrow } from "./utils/http.js";
56
58
  export type { TokenConfig, ContextLoaderEntry, ContextLoaderConfig, } from "./config/store.js";
57
- export { getConfigDir, getCurrentPlatform } from "./config/store.js";
59
+ export { autoSelectBusinessDomain, getConfigDir, getCurrentPlatform } from "./config/store.js";
package/dist/index.js CHANGED
@@ -39,8 +39,9 @@ export { AgentsResource } from "./resources/agents.js";
39
39
  export { BknResource } from "./resources/bkn.js";
40
40
  export { ConversationsResource } from "./resources/conversations.js";
41
41
  export { ContextLoaderResource } from "./resources/context-loader.js";
42
- export { parseDataView, createDataView, getDataView, listDataViews, deleteDataView, findDataView, } from "./api/dataviews.js";
42
+ export { parseDataView, createDataView, getDataView, listDataViews, deleteDataView, findDataView, queryDataView, } from "./api/dataviews.js";
43
43
  export { DataViewsResource } from "./resources/dataviews.js";
44
+ export { listBusinessDomains } from "./api/business-domains.js";
44
45
  // ── HTTP utilities ────────────────────────────────────────────────────────────
45
46
  export { HttpError, NetworkRequestError, fetchTextOrThrow } from "./utils/http.js";
46
- export { getConfigDir, getCurrentPlatform } from "./config/store.js";
47
+ export { autoSelectBusinessDomain, getConfigDir, getCurrentPlatform } from "./config/store.js";
@@ -1,4 +1,4 @@
1
- import type { DataView } from "../api/dataviews.js";
1
+ import type { DataView, DataViewQueryResult } from "../api/dataviews.js";
2
2
  import type { ClientContext } from "../client.js";
3
3
  export declare class DataViewsResource {
4
4
  private readonly ctx;
@@ -25,4 +25,13 @@ export declare class DataViewsResource {
25
25
  timeoutMs?: number;
26
26
  }): Promise<DataView[]>;
27
27
  delete(id: string): Promise<void>;
28
+ query(id: string, opts?: {
29
+ sql?: string;
30
+ offset?: number;
31
+ limit?: number;
32
+ needTotal?: boolean;
33
+ outputFields?: string[];
34
+ filters?: Record<string, unknown>;
35
+ sort?: Array<Record<string, unknown>>;
36
+ }): Promise<DataViewQueryResult>;
28
37
  }
@@ -1,4 +1,4 @@
1
- import { createDataView, deleteDataView, findDataView, getDataView, listDataViews, } from "../api/dataviews.js";
1
+ import { createDataView, deleteDataView, findDataView, getDataView, listDataViews, queryDataView, } from "../api/dataviews.js";
2
2
  export class DataViewsResource {
3
3
  ctx;
4
4
  constructor(ctx) {
@@ -31,4 +31,17 @@ export class DataViewsResource {
31
31
  async delete(id) {
32
32
  await deleteDataView({ ...this.ctx.base(), id });
33
33
  }
34
+ async query(id, opts) {
35
+ return queryDataView({
36
+ ...this.ctx.base(),
37
+ id,
38
+ sql: opts?.sql,
39
+ offset: opts?.offset,
40
+ limit: opts?.limit,
41
+ needTotal: opts?.needTotal,
42
+ outputFields: opts?.outputFields,
43
+ filters: opts?.filters,
44
+ sort: opts?.sort,
45
+ });
46
+ }
34
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kweaver-ai/kweaver-sdk",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
4
4
  "description": "KWeaver TypeScript SDK — CLI tool and programmatic API for knowledge networks and Decision Agents.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",