@kweaver-ai/kweaver-sdk 0.4.11 → 0.4.13
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 +59 -3
- package/README.zh.md +40 -1
- package/dist/api/dataflow.d.ts +2 -0
- package/dist/api/dataflow.js +5 -3
- package/dist/api/dataviews.d.ts +98 -1
- package/dist/api/dataviews.js +167 -14
- package/dist/api/vega.js +1 -1
- package/dist/auth/oauth.d.ts +21 -0
- package/dist/auth/oauth.js +226 -54
- package/dist/cli.js +13 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.js +16 -0
- package/dist/commands/agent.js +15 -15
- package/dist/commands/auth.js +80 -6
- package/dist/commands/bkn.d.ts +11 -0
- package/dist/commands/bkn.js +102 -59
- package/dist/commands/dataview.d.ts +1 -0
- package/dist/commands/dataview.js +303 -0
- package/dist/commands/vega.js +7 -7
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/resources/dataflows.d.ts +17 -0
- package/dist/resources/dataflows.js +22 -0
- package/dist/resources/datasources.d.ts +52 -0
- package/dist/resources/datasources.js +54 -0
- package/dist/resources/dataviews.d.ts +37 -0
- package/dist/resources/dataviews.js +47 -0
- package/dist/resources/vega.d.ts +41 -0
- package/dist/resources/vega.js +80 -0
- package/package.json +1 -1
package/dist/auth/oauth.js
CHANGED
|
@@ -5,6 +5,87 @@ const TOKEN_TTL_SECONDS = 3600;
|
|
|
5
5
|
const REFRESH_THRESHOLD_SEC = 60;
|
|
6
6
|
const DEFAULT_REDIRECT_PORT = 9010;
|
|
7
7
|
const DEFAULT_SCOPE = "openid offline all";
|
|
8
|
+
/** POSIX shell single-quote escaping for copy-paste commands. */
|
|
9
|
+
export function shellQuoteForShell(value) {
|
|
10
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build a one-line `kweaver auth login ...` command for headless / other machines.
|
|
14
|
+
* Omits `--client-secret` when empty (PKCE-only client); headless refresh may still require a confidential client.
|
|
15
|
+
*/
|
|
16
|
+
export function buildCopyCommand(baseUrl, clientId, clientSecret, refreshToken, tlsInsecure) {
|
|
17
|
+
const parts = ["kweaver", "auth", "login", shellQuoteForShell(normalizeBaseUrl(baseUrl)), "--client-id", shellQuoteForShell(clientId)];
|
|
18
|
+
if (clientSecret) {
|
|
19
|
+
parts.push("--client-secret", shellQuoteForShell(clientSecret));
|
|
20
|
+
}
|
|
21
|
+
if (refreshToken) {
|
|
22
|
+
parts.push("--refresh-token", shellQuoteForShell(refreshToken));
|
|
23
|
+
}
|
|
24
|
+
if (tlsInsecure) {
|
|
25
|
+
parts.push("--insecure");
|
|
26
|
+
}
|
|
27
|
+
return parts.join(" ");
|
|
28
|
+
}
|
|
29
|
+
function escapeHtml(value) {
|
|
30
|
+
return value
|
|
31
|
+
.replace(/&/g, "&")
|
|
32
|
+
.replace(/</g, "<")
|
|
33
|
+
.replace(/>/g, ">")
|
|
34
|
+
.replace(/"/g, """);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* HTML shown after successful OAuth callback with a copyable headless login command.
|
|
38
|
+
*/
|
|
39
|
+
export function buildCallbackHtml(copyCommand) {
|
|
40
|
+
const safeCmd = escapeHtml(copyCommand);
|
|
41
|
+
return `<!DOCTYPE html>
|
|
42
|
+
<html lang="en">
|
|
43
|
+
<head>
|
|
44
|
+
<meta charset="utf-8"/>
|
|
45
|
+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
46
|
+
<title>Login successful</title>
|
|
47
|
+
<style>
|
|
48
|
+
body { font-family: system-ui, sans-serif; max-width: 52rem; margin: 2rem auto; padding: 0 1rem; line-height: 1.5; }
|
|
49
|
+
pre { background: #f4f4f5; padding: 1rem; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
|
|
50
|
+
button { margin-top: 0.75rem; padding: 0.5rem 1rem; cursor: pointer; }
|
|
51
|
+
.warn { color: #b45309; margin-top: 1.5rem; font-size: 0.9rem; }
|
|
52
|
+
</style>
|
|
53
|
+
</head>
|
|
54
|
+
<body>
|
|
55
|
+
<h2>Login successful</h2>
|
|
56
|
+
<p>You can close this tab.</p>
|
|
57
|
+
<h3>Headless machine</h3>
|
|
58
|
+
<p>On the computer that has no browser (SSH server, CI runner, container), run:</p>
|
|
59
|
+
<pre id="kw-cmd">${safeCmd}</pre>
|
|
60
|
+
<button type="button" id="kw-copy">Copy command</button>
|
|
61
|
+
<p class="warn">Keep these credentials secure. Anyone with the refresh token and client secret can obtain new access tokens.</p>
|
|
62
|
+
<script>
|
|
63
|
+
(function () {
|
|
64
|
+
var btn = document.getElementById("kw-copy");
|
|
65
|
+
var pre = document.getElementById("kw-cmd");
|
|
66
|
+
if (btn && pre) {
|
|
67
|
+
btn.addEventListener("click", function () {
|
|
68
|
+
var text = pre.textContent || "";
|
|
69
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
70
|
+
navigator.clipboard.writeText(text.trim()).then(function () {
|
|
71
|
+
btn.textContent = "Copied";
|
|
72
|
+
setTimeout(function () { btn.textContent = "Copy command"; }, 2000);
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
window.prompt("Copy this command:", text.trim());
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
})();
|
|
80
|
+
</script>
|
|
81
|
+
</body>
|
|
82
|
+
</html>`;
|
|
83
|
+
}
|
|
84
|
+
function buildCallbackExchangeErrorHtml(message) {
|
|
85
|
+
return `<!DOCTYPE html>
|
|
86
|
+
<html lang="en"><head><meta charset="utf-8"/><title>Login error</title></head>
|
|
87
|
+
<body><h2>Login error</h2><pre>${escapeHtml(message)}</pre></body></html>`;
|
|
88
|
+
}
|
|
8
89
|
export function normalizeBaseUrl(value) {
|
|
9
90
|
return value.replace(/\/+$/, "");
|
|
10
91
|
}
|
|
@@ -96,35 +177,62 @@ export async function oauth2Login(baseUrl, options) {
|
|
|
96
177
|
authParams.set("code_challenge_method", "S256");
|
|
97
178
|
}
|
|
98
179
|
const authUrl = `${base}/oauth2/auth?${authParams.toString()}`;
|
|
99
|
-
// Step 4: Start local callback server,
|
|
100
|
-
const
|
|
180
|
+
// Step 4: Start local callback server; exchange code inside handler, then show credentials HTML
|
|
181
|
+
const token = await new Promise((resolve, reject) => {
|
|
182
|
+
let server;
|
|
101
183
|
const timeoutId = setTimeout(() => {
|
|
102
|
-
server
|
|
184
|
+
server?.close();
|
|
103
185
|
reject(new Error("OAuth2 login timed out (120s). No authorization code received."));
|
|
104
186
|
}, 120_000);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
187
|
+
server = createServer((req, res) => {
|
|
188
|
+
void (async () => {
|
|
189
|
+
try {
|
|
190
|
+
const url = new URL(req.url ?? "/", `http://127.0.0.1:${port}`);
|
|
191
|
+
if (url.pathname !== "/callback") {
|
|
192
|
+
res.writeHead(404);
|
|
193
|
+
res.end();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const receivedState = url.searchParams.get("state");
|
|
197
|
+
const receivedCode = url.searchParams.get("code");
|
|
198
|
+
if (receivedState !== state) {
|
|
199
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
200
|
+
res.end(buildCallbackExchangeErrorHtml("OAuth2 state mismatch — possible CSRF attack."));
|
|
201
|
+
clearTimeout(timeoutId);
|
|
202
|
+
server.close();
|
|
203
|
+
reject(new Error("OAuth2 state mismatch — possible CSRF attack."));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (!receivedCode) {
|
|
207
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
208
|
+
res.end(buildCallbackExchangeErrorHtml("No authorization code received in callback."));
|
|
209
|
+
clearTimeout(timeoutId);
|
|
210
|
+
server.close();
|
|
211
|
+
reject(new Error("No authorization code received in callback."));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const exchanged = await exchangeCodeForToken(base, receivedCode, client.clientId, client.clientSecret, redirectUri, pkce?.verifier, options?.tlsInsecure);
|
|
215
|
+
const copyCommand = buildCopyCommand(base, client.clientId, client.clientSecret, exchanged.refreshToken, options?.tlsInsecure);
|
|
216
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
217
|
+
res.end(buildCallbackHtml(copyCommand));
|
|
218
|
+
clearTimeout(timeoutId);
|
|
219
|
+
server.close();
|
|
220
|
+
resolve(exchanged);
|
|
116
221
|
}
|
|
117
|
-
|
|
118
|
-
|
|
222
|
+
catch (err) {
|
|
223
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
224
|
+
try {
|
|
225
|
+
res.writeHead(500, { "Content-Type": "text/html; charset=utf-8" });
|
|
226
|
+
res.end(buildCallbackExchangeErrorHtml(message));
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
/* response may already be sent */
|
|
230
|
+
}
|
|
231
|
+
clearTimeout(timeoutId);
|
|
232
|
+
server.close();
|
|
233
|
+
reject(err instanceof Error ? err : new Error(message));
|
|
119
234
|
}
|
|
120
|
-
|
|
121
|
-
resolve(receivedCode);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
res.writeHead(404);
|
|
126
|
-
res.end();
|
|
127
|
-
}
|
|
235
|
+
})();
|
|
128
236
|
});
|
|
129
237
|
server.listen(port, "127.0.0.1", () => {
|
|
130
238
|
// Step 5: Open browser (uses spawn with proper Windows quoting)
|
|
@@ -134,8 +242,6 @@ export async function oauth2Login(baseUrl, options) {
|
|
|
134
242
|
process.stderr.write(`If the wrong browser opens, copy this URL to your correct browser:\n ${authUrl}\n`);
|
|
135
243
|
});
|
|
136
244
|
});
|
|
137
|
-
// Step 6: Exchange code for tokens
|
|
138
|
-
const token = await exchangeCodeForToken(base, code, client.clientId, client.clientSecret, redirectUri, pkce?.verifier, options?.tlsInsecure);
|
|
139
245
|
setCurrentPlatform(base);
|
|
140
246
|
return token;
|
|
141
247
|
});
|
|
@@ -275,40 +381,70 @@ export async function playwrightLogin(baseUrl, options) {
|
|
|
275
381
|
product: "adp",
|
|
276
382
|
});
|
|
277
383
|
const authUrl = `${base}/oauth2/auth?${authParams.toString()}`;
|
|
278
|
-
// Step 4: Start local callback server
|
|
279
|
-
|
|
384
|
+
// Step 4: Start local callback server; exchange code inside handler, then show credentials HTML
|
|
385
|
+
let browser;
|
|
386
|
+
const token = await new Promise((resolve, reject) => {
|
|
280
387
|
const TIMEOUT_MS = hasCredentials ? 30_000 : 120_000;
|
|
388
|
+
let server;
|
|
281
389
|
const timeoutId = setTimeout(() => {
|
|
282
|
-
server
|
|
390
|
+
server?.close();
|
|
283
391
|
browser?.close();
|
|
284
392
|
reject(new Error(`OAuth2 login timed out (${TIMEOUT_MS / 1000}s). No authorization code received.`));
|
|
285
393
|
}, TIMEOUT_MS);
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
394
|
+
server = createServer((req, res) => {
|
|
395
|
+
void (async () => {
|
|
396
|
+
try {
|
|
397
|
+
const url = new URL(req.url ?? "/", `http://127.0.0.1:${port}`);
|
|
398
|
+
if (url.pathname !== "/callback") {
|
|
399
|
+
res.writeHead(404);
|
|
400
|
+
res.end();
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const receivedState = url.searchParams.get("state");
|
|
404
|
+
const receivedCode = url.searchParams.get("code");
|
|
405
|
+
if (receivedState !== state) {
|
|
406
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
407
|
+
res.end(buildCallbackExchangeErrorHtml("OAuth2 state mismatch — possible CSRF attack."));
|
|
408
|
+
clearTimeout(timeoutId);
|
|
409
|
+
server.close();
|
|
410
|
+
browser?.close();
|
|
411
|
+
reject(new Error("OAuth2 state mismatch — possible CSRF attack."));
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (!receivedCode) {
|
|
415
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
416
|
+
res.end(buildCallbackExchangeErrorHtml("No authorization code received in callback."));
|
|
417
|
+
clearTimeout(timeoutId);
|
|
418
|
+
server.close();
|
|
419
|
+
browser?.close();
|
|
420
|
+
reject(new Error("No authorization code received in callback."));
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const exchanged = await exchangeCodeForToken(base, receivedCode, client.clientId, client.clientSecret, redirectUri, undefined, options?.tlsInsecure);
|
|
424
|
+
const copyCommand = buildCopyCommand(base, client.clientId, client.clientSecret, exchanged.refreshToken, options?.tlsInsecure);
|
|
425
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
426
|
+
res.end(buildCallbackHtml(copyCommand));
|
|
427
|
+
clearTimeout(timeoutId);
|
|
428
|
+
server.close();
|
|
429
|
+
browser?.close();
|
|
430
|
+
resolve(exchanged);
|
|
301
431
|
}
|
|
302
|
-
|
|
303
|
-
|
|
432
|
+
catch (err) {
|
|
433
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
434
|
+
try {
|
|
435
|
+
res.writeHead(500, { "Content-Type": "text/html; charset=utf-8" });
|
|
436
|
+
res.end(buildCallbackExchangeErrorHtml(message));
|
|
437
|
+
}
|
|
438
|
+
catch {
|
|
439
|
+
/* response may already be sent */
|
|
440
|
+
}
|
|
441
|
+
clearTimeout(timeoutId);
|
|
442
|
+
server.close();
|
|
443
|
+
browser?.close();
|
|
444
|
+
reject(err instanceof Error ? err : new Error(message));
|
|
304
445
|
}
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
res.writeHead(404);
|
|
308
|
-
res.end();
|
|
309
|
-
}
|
|
446
|
+
})();
|
|
310
447
|
});
|
|
311
|
-
let browser;
|
|
312
448
|
server.listen(port, "127.0.0.1", async () => {
|
|
313
449
|
try {
|
|
314
450
|
browser = await chromium.launch({ headless: hasCredentials });
|
|
@@ -334,12 +470,48 @@ export async function playwrightLogin(baseUrl, options) {
|
|
|
334
470
|
}
|
|
335
471
|
});
|
|
336
472
|
});
|
|
337
|
-
|
|
338
|
-
|
|
473
|
+
if (hasCredentials) {
|
|
474
|
+
const copyCommand = buildCopyCommand(base, client.clientId, client.clientSecret, token.refreshToken, options?.tlsInsecure);
|
|
475
|
+
process.stderr.write("\nHeadless login: copy this command and run it on a machine without a browser, or use `kweaver auth export`:\n\n" +
|
|
476
|
+
copyCommand +
|
|
477
|
+
"\n\n");
|
|
478
|
+
}
|
|
339
479
|
setCurrentPlatform(base);
|
|
340
480
|
return token;
|
|
341
481
|
});
|
|
342
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Log in on a headless machine using OAuth2 client credentials and a refresh token (no browser).
|
|
485
|
+
* Exchanges the refresh token for a new access token and persists ~/.kweaver/ state.
|
|
486
|
+
*/
|
|
487
|
+
export async function refreshTokenLogin(baseUrl, options) {
|
|
488
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
489
|
+
const redirectUri = `http://127.0.0.1:${DEFAULT_REDIRECT_PORT}/callback`;
|
|
490
|
+
const client = {
|
|
491
|
+
baseUrl: base,
|
|
492
|
+
clientId: options.clientId,
|
|
493
|
+
clientSecret: options.clientSecret,
|
|
494
|
+
redirectUri,
|
|
495
|
+
logoutRedirectUri: redirectUri.replace("/callback", "/successful-logout"),
|
|
496
|
+
scope: DEFAULT_SCOPE,
|
|
497
|
+
lang: "zh-cn",
|
|
498
|
+
product: "adp",
|
|
499
|
+
xForwardedPrefix: "",
|
|
500
|
+
};
|
|
501
|
+
saveClientConfig(base, client);
|
|
502
|
+
const synthetic = {
|
|
503
|
+
baseUrl: base,
|
|
504
|
+
accessToken: "",
|
|
505
|
+
tokenType: "Bearer",
|
|
506
|
+
scope: "",
|
|
507
|
+
refreshToken: options.refreshToken,
|
|
508
|
+
obtainedAt: new Date().toISOString(),
|
|
509
|
+
...(options.tlsInsecure ? { tlsInsecure: true } : {}),
|
|
510
|
+
};
|
|
511
|
+
const token = await runWithTlsInsecure(options.tlsInsecure, () => refreshAccessToken(synthetic));
|
|
512
|
+
setCurrentPlatform(base);
|
|
513
|
+
return token;
|
|
514
|
+
}
|
|
343
515
|
function tokenNeedsRefresh(token) {
|
|
344
516
|
if (!token.expiresAt) {
|
|
345
517
|
return false;
|
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ import { runCallCommand } from "./commands/call.js";
|
|
|
6
6
|
import { runConfigCommand } from "./commands/config.js";
|
|
7
7
|
import { runContextLoaderCommand } from "./commands/context-loader.js";
|
|
8
8
|
import { runDsCommand } from "./commands/ds.js";
|
|
9
|
+
import { runDataviewCommand } from "./commands/dataview.js";
|
|
9
10
|
import { runTokenCommand } from "./commands/token.js";
|
|
10
11
|
import { runVegaCommand } from "./commands/vega.js";
|
|
11
12
|
function printHelp() {
|
|
@@ -17,6 +18,8 @@ Usage:
|
|
|
17
18
|
|
|
18
19
|
kweaver auth <platform-url> [--alias name] [-u user] [-p pass] [--playwright] [--insecure|-k]
|
|
19
20
|
kweaver auth login <platform-url> (alias for auth <url>)
|
|
21
|
+
kweaver auth login <url> --client-id ID --client-secret S --refresh-token T (run on host without browser)
|
|
22
|
+
kweaver auth export [platform-url|alias] [--json]
|
|
20
23
|
kweaver auth status [platform-url|alias]
|
|
21
24
|
kweaver auth list
|
|
22
25
|
kweaver auth use <platform-url|alias>
|
|
@@ -47,6 +50,12 @@ Usage:
|
|
|
47
50
|
kweaver ds tables <id> [--keyword X] [--pretty]
|
|
48
51
|
kweaver ds connect <db_type> <host> <port> <database> --account X --password Y [--schema S] [--name N]
|
|
49
52
|
|
|
53
|
+
kweaver dataview list [--datasource-id id] [--type atomic|custom] [--limit n] [-bd value] [--pretty]
|
|
54
|
+
kweaver dataview find --name <name> [--exact] [--datasource-id id] [--wait] [--timeout ms] [-bd value] [--pretty]
|
|
55
|
+
kweaver dataview get <id> [-bd value] [--pretty]
|
|
56
|
+
kweaver dataview query <id> [--sql sql] [--limit n] [--offset n] [--need-total] [-bd value] [--pretty]
|
|
57
|
+
kweaver dataview delete <id> [-y] [-bd value]
|
|
58
|
+
|
|
50
59
|
kweaver bkn list [options]
|
|
51
60
|
kweaver bkn get <kn-id> [options]
|
|
52
61
|
kweaver bkn search <kn-id> <query> [--max-concepts N] [--mode M] [--pretty] [-bd value]
|
|
@@ -90,6 +99,7 @@ Commands:
|
|
|
90
99
|
call (curl) Call an API with curl-style flags and auto-injected token headers
|
|
91
100
|
agent Agent CRUD, chat, sessions, history, publish/unpublish
|
|
92
101
|
ds Manage datasources (list, get, delete, tables, connect)
|
|
102
|
+
dataview|dv List, find, get, query (SQL), delete data views (atomic / custom)
|
|
93
103
|
bkn Knowledge network (CRUD, build, validate, export, stats, push/pull,
|
|
94
104
|
object-type, relation-type, subgraph, action-type, action-execution, action-log)
|
|
95
105
|
config Per-platform configuration (business domain)
|
|
@@ -120,6 +130,9 @@ export async function run(argv) {
|
|
|
120
130
|
if (command === "ds") {
|
|
121
131
|
return runDsCommand(rest);
|
|
122
132
|
}
|
|
133
|
+
if (command === "dataview" || command === "dv") {
|
|
134
|
+
return runDataviewCommand(rest);
|
|
135
|
+
}
|
|
123
136
|
if (command === "token") {
|
|
124
137
|
return runTokenCommand(rest);
|
|
125
138
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AgentsResource } from "./resources/agents.js";
|
|
2
2
|
import { ConversationsResource } from "./resources/conversations.js";
|
|
3
3
|
import { ContextLoaderResource } from "./resources/context-loader.js";
|
|
4
|
+
import { DataflowsResource } from "./resources/dataflows.js";
|
|
5
|
+
import { DataSourcesResource } from "./resources/datasources.js";
|
|
6
|
+
import { DataViewsResource } from "./resources/dataviews.js";
|
|
4
7
|
import { KnowledgeNetworksResource } from "./resources/knowledge-networks.js";
|
|
5
8
|
import { BknResource } from "./resources/bkn.js";
|
|
9
|
+
import { VegaResource } from "./resources/vega.js";
|
|
6
10
|
/**
|
|
7
11
|
* Shared credentials passed to every resource method.
|
|
8
12
|
* Internal — use KWeaverClient.
|
|
@@ -78,6 +82,14 @@ export declare class KWeaverClient implements ClientContext {
|
|
|
78
82
|
readonly bkn: BknResource;
|
|
79
83
|
/** Conversation and message history. */
|
|
80
84
|
readonly conversations: ConversationsResource;
|
|
85
|
+
/** Dataflow DAG automation (create/run/poll/delete). */
|
|
86
|
+
readonly dataflows: DataflowsResource;
|
|
87
|
+
/** Data source management (connect, test, list tables). */
|
|
88
|
+
readonly datasources: DataSourcesResource;
|
|
89
|
+
/** Data view creation and retrieval. */
|
|
90
|
+
readonly dataviews: DataViewsResource;
|
|
91
|
+
/** Vega observability platform (catalogs, resources, connector types). */
|
|
92
|
+
readonly vega: VegaResource;
|
|
81
93
|
constructor(opts?: KWeaverClientOptions);
|
|
82
94
|
/**
|
|
83
95
|
* Async factory that auto-refreshes expired or revoked tokens.
|
package/dist/client.js
CHANGED
|
@@ -4,8 +4,12 @@ import { ensureValidToken } from "./auth/oauth.js";
|
|
|
4
4
|
import { AgentsResource } from "./resources/agents.js";
|
|
5
5
|
import { ConversationsResource } from "./resources/conversations.js";
|
|
6
6
|
import { ContextLoaderResource } from "./resources/context-loader.js";
|
|
7
|
+
import { DataflowsResource } from "./resources/dataflows.js";
|
|
8
|
+
import { DataSourcesResource } from "./resources/datasources.js";
|
|
9
|
+
import { DataViewsResource } from "./resources/dataviews.js";
|
|
7
10
|
import { KnowledgeNetworksResource } from "./resources/knowledge-networks.js";
|
|
8
11
|
import { BknResource } from "./resources/bkn.js";
|
|
12
|
+
import { VegaResource } from "./resources/vega.js";
|
|
9
13
|
// ── KWeaverClient ─────────────────────────────────────────────────────────────
|
|
10
14
|
/**
|
|
11
15
|
* Main entry point for the KWeaver TypeScript SDK.
|
|
@@ -47,6 +51,14 @@ export class KWeaverClient {
|
|
|
47
51
|
bkn;
|
|
48
52
|
/** Conversation and message history. */
|
|
49
53
|
conversations;
|
|
54
|
+
/** Dataflow DAG automation (create/run/poll/delete). */
|
|
55
|
+
dataflows;
|
|
56
|
+
/** Data source management (connect, test, list tables). */
|
|
57
|
+
datasources;
|
|
58
|
+
/** Data view creation and retrieval. */
|
|
59
|
+
dataviews;
|
|
60
|
+
/** Vega observability platform (catalogs, resources, connector types). */
|
|
61
|
+
vega;
|
|
50
62
|
constructor(opts = {}) {
|
|
51
63
|
const envDomain = process.env.KWEAVER_BUSINESS_DOMAIN;
|
|
52
64
|
let baseUrl;
|
|
@@ -98,6 +110,10 @@ export class KWeaverClient {
|
|
|
98
110
|
this.agents = new AgentsResource(this);
|
|
99
111
|
this.bkn = new BknResource(this);
|
|
100
112
|
this.conversations = new ConversationsResource(this);
|
|
113
|
+
this.dataflows = new DataflowsResource(this);
|
|
114
|
+
this.datasources = new DataSourcesResource(this);
|
|
115
|
+
this.dataviews = new DataViewsResource(this);
|
|
116
|
+
this.vega = new VegaResource(this);
|
|
101
117
|
}
|
|
102
118
|
/**
|
|
103
119
|
* Async factory that auto-refreshes expired or revoked tokens.
|
package/dist/commands/agent.js
CHANGED
|
@@ -45,7 +45,7 @@ export function formatSimpleAgentList(text, pretty) {
|
|
|
45
45
|
export function parseAgentListArgs(args) {
|
|
46
46
|
let name = "";
|
|
47
47
|
let offset = 0;
|
|
48
|
-
let limit =
|
|
48
|
+
let limit = 30;
|
|
49
49
|
let category_id = "";
|
|
50
50
|
let custom_space_id = "";
|
|
51
51
|
let is_to_square = 1;
|
|
@@ -70,9 +70,9 @@ export function parseAgentListArgs(args) {
|
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
72
|
if (arg === "--limit") {
|
|
73
|
-
limit = parseInt(args[i + 1] ?? "
|
|
73
|
+
limit = parseInt(args[i + 1] ?? "30", 10);
|
|
74
74
|
if (Number.isNaN(limit) || limit < 1)
|
|
75
|
-
limit =
|
|
75
|
+
limit = 30;
|
|
76
76
|
i += 1;
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
@@ -134,7 +134,7 @@ export function parseAgentSessionsArgs(args) {
|
|
|
134
134
|
throw new Error("Missing agent_id");
|
|
135
135
|
}
|
|
136
136
|
let businessDomain = "";
|
|
137
|
-
let limit;
|
|
137
|
+
let limit = 30;
|
|
138
138
|
let pretty = true;
|
|
139
139
|
for (let i = 1; i < args.length; i += 1) {
|
|
140
140
|
const arg = args[i];
|
|
@@ -150,9 +150,9 @@ export function parseAgentSessionsArgs(args) {
|
|
|
150
150
|
continue;
|
|
151
151
|
}
|
|
152
152
|
if (arg === "--limit") {
|
|
153
|
-
limit = parseInt(args[i + 1] ?? "
|
|
153
|
+
limit = parseInt(args[i + 1] ?? "30", 10);
|
|
154
154
|
if (Number.isNaN(limit) || limit < 1)
|
|
155
|
-
limit =
|
|
155
|
+
limit = 30;
|
|
156
156
|
i += 1;
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
@@ -176,7 +176,7 @@ export function parseAgentHistoryArgs(args) {
|
|
|
176
176
|
throw new Error("Missing conversation_id");
|
|
177
177
|
}
|
|
178
178
|
let businessDomain = "";
|
|
179
|
-
let limit;
|
|
179
|
+
let limit = 30;
|
|
180
180
|
let pretty = true;
|
|
181
181
|
for (let i = 1; i < args.length; i += 1) {
|
|
182
182
|
const arg = args[i];
|
|
@@ -192,9 +192,9 @@ export function parseAgentHistoryArgs(args) {
|
|
|
192
192
|
continue;
|
|
193
193
|
}
|
|
194
194
|
if (arg === "--limit") {
|
|
195
|
-
limit = parseInt(args[i + 1] ?? "
|
|
195
|
+
limit = parseInt(args[i + 1] ?? "30", 10);
|
|
196
196
|
if (Number.isNaN(limit) || limit < 1)
|
|
197
|
-
limit =
|
|
197
|
+
limit = 30;
|
|
198
198
|
i += 1;
|
|
199
199
|
continue;
|
|
200
200
|
}
|
|
@@ -309,7 +309,7 @@ List published agents from the agent-factory API.
|
|
|
309
309
|
Options:
|
|
310
310
|
--name <text> Filter by name
|
|
311
311
|
--offset <n> Pagination offset (default: 0)
|
|
312
|
-
--limit <n> Max items to return (default:
|
|
312
|
+
--limit <n> Max items to return (default: 30)
|
|
313
313
|
--category-id <id> Filter by category
|
|
314
314
|
--custom-space-id <id> Filter by custom space
|
|
315
315
|
--is-to-square <0|1> Is to square (default: 1)
|
|
@@ -326,7 +326,7 @@ Options:
|
|
|
326
326
|
List all conversations for an agent.
|
|
327
327
|
|
|
328
328
|
Options:
|
|
329
|
-
--limit <n> Max conversations to return
|
|
329
|
+
--limit <n> Max conversations to return (default: 30)
|
|
330
330
|
-bd, --biz-domain <value> Business domain (default: bd_public)
|
|
331
331
|
--pretty Pretty-print JSON output (default)`);
|
|
332
332
|
return 0;
|
|
@@ -339,7 +339,7 @@ Options:
|
|
|
339
339
|
Show message history for a conversation.
|
|
340
340
|
|
|
341
341
|
Options:
|
|
342
|
-
--limit <n> Max messages to return
|
|
342
|
+
--limit <n> Max messages to return (default: 30)
|
|
343
343
|
-bd, --biz-domain <value> Business domain (default: bd_public)
|
|
344
344
|
--pretty Pretty-print JSON output (default)`);
|
|
345
345
|
return 0;
|
|
@@ -462,7 +462,7 @@ List published agents from the agent-factory API.
|
|
|
462
462
|
Options:
|
|
463
463
|
--name <text> Filter by name
|
|
464
464
|
--offset <n> Pagination offset (default: 0)
|
|
465
|
-
--limit <n> Max items to return (default:
|
|
465
|
+
--limit <n> Max items to return (default: 30)
|
|
466
466
|
--category-id <id> Filter by category
|
|
467
467
|
--custom-space-id <id> Filter by custom space
|
|
468
468
|
--is-to-square <0|1> Is to square (default: 1)
|
|
@@ -509,7 +509,7 @@ async function runAgentSessionsCommand(args) {
|
|
|
509
509
|
List all conversations for an agent.
|
|
510
510
|
|
|
511
511
|
Options:
|
|
512
|
-
--limit <n> Max conversations to return
|
|
512
|
+
--limit <n> Max conversations to return (default: 30)
|
|
513
513
|
-bd, --biz-domain <value> Business domain (default: bd_public)
|
|
514
514
|
--pretty Pretty-print JSON output (default)`);
|
|
515
515
|
return 0;
|
|
@@ -546,7 +546,7 @@ async function runAgentHistoryCommand(args) {
|
|
|
546
546
|
Show message history for a conversation.
|
|
547
547
|
|
|
548
548
|
Options:
|
|
549
|
-
--limit <n> Max messages to return
|
|
549
|
+
--limit <n> Max messages to return (default: 30)
|
|
550
550
|
-bd, --biz-domain <value> Business domain (default: bd_public)
|
|
551
551
|
--pretty Pretty-print JSON output (default)`);
|
|
552
552
|
return 0;
|