@kweaver-ai/kweaver-sdk 0.4.13 → 0.4.15
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.
- package/README.md +13 -1
- package/README.zh.md +13 -0
- package/dist/api/business-domains.d.ts +20 -0
- package/dist/api/business-domains.js +54 -0
- package/dist/api/conversations.d.ts +6 -0
- package/dist/api/conversations.js +21 -0
- package/dist/api/vega.d.ts +76 -3
- package/dist/api/vega.js +145 -10
- package/dist/auth/oauth.d.ts +9 -0
- package/dist/auth/oauth.js +9 -0
- package/dist/cli.js +2 -1
- package/dist/commands/agent.d.ts +5 -0
- package/dist/commands/agent.js +74 -2
- package/dist/commands/auth.js +5 -1
- package/dist/commands/config.js +34 -1
- package/dist/commands/vega.js +640 -21
- package/dist/config/store.d.ts +8 -0
- package/dist/config/store.js +39 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/resources/vega.d.ts +17 -3
- package/dist/resources/vega.js +44 -4
- package/package.json +1 -1
package/dist/config/store.d.ts
CHANGED
|
@@ -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>;
|
package/dist/config/store.js
CHANGED
|
@@ -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
|
@@ -52,6 +52,8 @@ export { ContextLoaderResource } from "./resources/context-loader.js";
|
|
|
52
52
|
export type { ViewField, DataView, CreateDataViewOptions, GetDataViewOptions, ListDataViewsOptions, DeleteDataViewOptions, FindDataViewOptions, QueryDataViewOptions, DataViewQueryResult, } from "./api/dataviews.js";
|
|
53
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
|
@@ -41,6 +41,7 @@ export { ConversationsResource } from "./resources/conversations.js";
|
|
|
41
41
|
export { ContextLoaderResource } from "./resources/context-loader.js";
|
|
42
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";
|
package/dist/resources/vega.d.ts
CHANGED
|
@@ -9,6 +9,15 @@ export declare class VegaResource {
|
|
|
9
9
|
offset?: number;
|
|
10
10
|
}): Promise<unknown[]>;
|
|
11
11
|
getCatalog(id: string): Promise<unknown>;
|
|
12
|
+
createCatalog(data: {
|
|
13
|
+
name: string;
|
|
14
|
+
connector_type: string;
|
|
15
|
+
connector_config: Record<string, unknown>;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
description?: string;
|
|
18
|
+
}): Promise<unknown>;
|
|
19
|
+
updateCatalog(id: string, body: string): Promise<unknown>;
|
|
20
|
+
deleteCatalogs(ids: string): Promise<unknown>;
|
|
12
21
|
catalogHealthStatus(ids: string): Promise<unknown>;
|
|
13
22
|
testCatalogConnection(id: string): Promise<unknown>;
|
|
14
23
|
discoverCatalog(id: string, opts?: {
|
|
@@ -28,14 +37,19 @@ export declare class VegaResource {
|
|
|
28
37
|
}): Promise<unknown[]>;
|
|
29
38
|
getResource(id: string): Promise<unknown>;
|
|
30
39
|
queryResourceData(id: string, body: string): Promise<unknown>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
createResource(body: string): Promise<unknown>;
|
|
41
|
+
updateResource(id: string, body: string): Promise<unknown>;
|
|
42
|
+
deleteResources(ids: string): Promise<unknown>;
|
|
34
43
|
listConnectorTypes(): Promise<unknown[]>;
|
|
35
44
|
getConnectorType(type: string): Promise<unknown>;
|
|
45
|
+
registerConnectorType(body: string): Promise<unknown>;
|
|
46
|
+
updateConnectorType(type: string, body: string): Promise<unknown>;
|
|
47
|
+
deleteConnectorType(type: string): Promise<unknown>;
|
|
48
|
+
setConnectorTypeEnabled(type: string, enabled: boolean): Promise<unknown>;
|
|
36
49
|
listDiscoverTasks(opts?: {
|
|
37
50
|
status?: string;
|
|
38
51
|
limit?: number;
|
|
39
52
|
offset?: number;
|
|
40
53
|
}): Promise<unknown[]>;
|
|
54
|
+
getDiscoverTask(id: string): Promise<unknown>;
|
|
41
55
|
}
|
package/dist/resources/vega.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { vegaHealth, listVegaCatalogs, getVegaCatalog, vegaCatalogHealthStatus, testVegaCatalogConnection, discoverVegaCatalog, listVegaCatalogResources, listVegaResources, getVegaResource, queryVegaResourceData,
|
|
1
|
+
import { vegaHealth, listVegaCatalogs, getVegaCatalog, createVegaCatalog, updateVegaCatalog, deleteVegaCatalogs, vegaCatalogHealthStatus, testVegaCatalogConnection, discoverVegaCatalog, listVegaCatalogResources, listVegaResources, getVegaResource, queryVegaResourceData, createVegaResource, updateVegaResource, deleteVegaResources, listVegaConnectorTypes, getVegaConnectorType, registerVegaConnectorType, updateVegaConnectorType, deleteVegaConnectorType, setVegaConnectorTypeEnabled, listVegaDiscoverTasks, getVegaDiscoverTask, } from "../api/vega.js";
|
|
2
2
|
function unwrapArray(raw) {
|
|
3
3
|
const parsed = JSON.parse(raw);
|
|
4
4
|
if (Array.isArray(parsed))
|
|
@@ -30,6 +30,18 @@ export class VegaResource {
|
|
|
30
30
|
const raw = await getVegaCatalog({ ...this.ctx.base(), id });
|
|
31
31
|
return JSON.parse(raw);
|
|
32
32
|
}
|
|
33
|
+
async createCatalog(data) {
|
|
34
|
+
const raw = await createVegaCatalog({ ...this.ctx.base(), body: JSON.stringify(data) });
|
|
35
|
+
return raw ? JSON.parse(raw) : {};
|
|
36
|
+
}
|
|
37
|
+
async updateCatalog(id, body) {
|
|
38
|
+
const raw = await updateVegaCatalog({ ...this.ctx.base(), id, body });
|
|
39
|
+
return raw ? JSON.parse(raw) : {};
|
|
40
|
+
}
|
|
41
|
+
async deleteCatalogs(ids) {
|
|
42
|
+
const raw = await deleteVegaCatalogs({ ...this.ctx.base(), ids });
|
|
43
|
+
return raw ? JSON.parse(raw) : {};
|
|
44
|
+
}
|
|
33
45
|
async catalogHealthStatus(ids) {
|
|
34
46
|
const raw = await vegaCatalogHealthStatus({ ...this.ctx.base(), ids });
|
|
35
47
|
return JSON.parse(raw);
|
|
@@ -59,9 +71,17 @@ export class VegaResource {
|
|
|
59
71
|
const raw = await queryVegaResourceData({ ...this.ctx.base(), id, body });
|
|
60
72
|
return JSON.parse(raw);
|
|
61
73
|
}
|
|
62
|
-
async
|
|
63
|
-
const raw = await
|
|
64
|
-
return JSON.parse(raw);
|
|
74
|
+
async createResource(body) {
|
|
75
|
+
const raw = await createVegaResource({ ...this.ctx.base(), body });
|
|
76
|
+
return raw ? JSON.parse(raw) : {};
|
|
77
|
+
}
|
|
78
|
+
async updateResource(id, body) {
|
|
79
|
+
const raw = await updateVegaResource({ ...this.ctx.base(), id, body });
|
|
80
|
+
return raw ? JSON.parse(raw) : {};
|
|
81
|
+
}
|
|
82
|
+
async deleteResources(ids) {
|
|
83
|
+
const raw = await deleteVegaResources({ ...this.ctx.base(), ids });
|
|
84
|
+
return raw ? JSON.parse(raw) : {};
|
|
65
85
|
}
|
|
66
86
|
// ── Connector Types ─────────────────────────────────────────────────────────
|
|
67
87
|
async listConnectorTypes() {
|
|
@@ -72,9 +92,29 @@ export class VegaResource {
|
|
|
72
92
|
const raw = await getVegaConnectorType({ ...this.ctx.base(), type });
|
|
73
93
|
return JSON.parse(raw);
|
|
74
94
|
}
|
|
95
|
+
async registerConnectorType(body) {
|
|
96
|
+
const raw = await registerVegaConnectorType({ ...this.ctx.base(), body });
|
|
97
|
+
return JSON.parse(raw);
|
|
98
|
+
}
|
|
99
|
+
async updateConnectorType(type, body) {
|
|
100
|
+
const raw = await updateVegaConnectorType({ ...this.ctx.base(), type, body });
|
|
101
|
+
return raw ? JSON.parse(raw) : {};
|
|
102
|
+
}
|
|
103
|
+
async deleteConnectorType(type) {
|
|
104
|
+
const raw = await deleteVegaConnectorType({ ...this.ctx.base(), type });
|
|
105
|
+
return raw ? JSON.parse(raw) : {};
|
|
106
|
+
}
|
|
107
|
+
async setConnectorTypeEnabled(type, enabled) {
|
|
108
|
+
const raw = await setVegaConnectorTypeEnabled({ ...this.ctx.base(), type, enabled });
|
|
109
|
+
return raw ? JSON.parse(raw) : {};
|
|
110
|
+
}
|
|
75
111
|
// ── Discover Tasks ──────────────────────────────────────────────────────────
|
|
76
112
|
async listDiscoverTasks(opts = {}) {
|
|
77
113
|
const raw = await listVegaDiscoverTasks({ ...this.ctx.base(), ...opts });
|
|
78
114
|
return unwrapArray(raw);
|
|
79
115
|
}
|
|
116
|
+
async getDiscoverTask(id) {
|
|
117
|
+
const raw = await getVegaDiscoverTask({ ...this.ctx.base(), id });
|
|
118
|
+
return JSON.parse(raw);
|
|
119
|
+
}
|
|
80
120
|
}
|
package/package.json
CHANGED