@kweaver-ai/kweaver-sdk 0.4.1 → 0.4.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.
- package/dist/api/agent-list.d.ts +44 -0
- package/dist/api/agent-list.js +104 -14
- package/dist/api/bkn-backend.d.ts +16 -0
- package/dist/api/bkn-backend.js +46 -0
- package/dist/api/ontology-query.d.ts +1 -1
- package/dist/api/ontology-query.js +1 -0
- package/dist/api/vega.d.ts +110 -0
- package/dist/api/vega.js +254 -0
- package/dist/auth/oauth.d.ts +9 -73
- package/dist/auth/oauth.js +98 -342
- package/dist/cli.js +12 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.js +65 -13
- package/dist/commands/agent-chat.js +4 -1
- package/dist/commands/agent.js +343 -29
- package/dist/commands/auth.d.ts +0 -8
- package/dist/commands/auth.js +59 -80
- package/dist/commands/bkn.d.ts +16 -0
- package/dist/commands/bkn.js +422 -70
- package/dist/commands/call.js +43 -7
- package/dist/commands/config.d.ts +1 -0
- package/dist/commands/config.js +52 -0
- package/dist/commands/context-loader.js +46 -40
- package/dist/commands/ds.js +29 -13
- package/dist/commands/vega.d.ts +1 -0
- package/dist/commands/vega.js +684 -0
- package/dist/config/store.d.ts +12 -25
- package/dist/config/store.js +43 -42
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/resources/agents.d.ts +83 -9
- package/dist/resources/agents.js +46 -10
- package/dist/resources/knowledge-networks.js +2 -3
- package/package.json +10 -1
package/dist/commands/auth.js
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
|
-
import { clearPlatformSession, deletePlatform, getConfigDir, getCurrentPlatform, getPlatformAlias, hasPlatform, listPlatforms, resolvePlatformIdentifier, setCurrentPlatform, setPlatformAlias, } from "../config/store.js";
|
|
2
|
-
import {
|
|
3
|
-
export function getClientProvisioningMessage(created) {
|
|
4
|
-
return created ? "Registered a new OAuth client." : "Reusing existing OAuth client.";
|
|
5
|
-
}
|
|
6
|
-
export function formatAuthStatusSummary(input) {
|
|
7
|
-
const lines = [
|
|
8
|
-
`Config directory: ${getConfigDir()}`,
|
|
9
|
-
`Platform: ${input.client.baseUrl}`,
|
|
10
|
-
`Current platform: ${input.isCurrent ? "yes" : "no"}`,
|
|
11
|
-
`Client ID: ${input.client.clientId}`,
|
|
12
|
-
`Redirect URI: ${input.client.redirectUri}`,
|
|
13
|
-
`Token present: ${input.token ? "yes" : "no"}`,
|
|
14
|
-
`Callback recorded: ${input.callback ? "yes" : "no"}`,
|
|
15
|
-
];
|
|
16
|
-
if (input.client.product) {
|
|
17
|
-
lines.push(`Product: ${input.client.product}`);
|
|
18
|
-
}
|
|
19
|
-
if (input.client.lang) {
|
|
20
|
-
lines.push(`Lang: ${input.client.lang}`);
|
|
21
|
-
}
|
|
22
|
-
if (input.token?.expiresAt) {
|
|
23
|
-
lines.push(`Token expires at: ${input.token.expiresAt}`);
|
|
24
|
-
}
|
|
25
|
-
if (input.callback?.receivedAt) {
|
|
26
|
-
lines.push(`Last callback at: ${input.callback.receivedAt}`);
|
|
27
|
-
}
|
|
28
|
-
if (input.callback?.scope) {
|
|
29
|
-
lines.push(`Last callback scope: ${input.callback.scope}`);
|
|
30
|
-
}
|
|
31
|
-
return lines;
|
|
32
|
-
}
|
|
1
|
+
import { clearPlatformSession, deletePlatform, getConfigDir, getCurrentPlatform, getPlatformAlias, hasPlatform, listPlatforms, loadTokenConfig, resolvePlatformIdentifier, setCurrentPlatform, setPlatformAlias, } from "../config/store.js";
|
|
2
|
+
import { formatHttpError, normalizeBaseUrl, playwrightLogin, } from "../auth/oauth.js";
|
|
33
3
|
export async function runAuthCommand(args) {
|
|
34
4
|
const target = args[0];
|
|
35
5
|
const rest = args.slice(1);
|
|
6
|
+
if (!target || target === "--help" || target === "-h") {
|
|
7
|
+
console.log(`kweaver auth login <url> Login to a platform (browser login)
|
|
8
|
+
kweaver auth <url> Login (shorthand)
|
|
9
|
+
kweaver auth status [url] Show current auth status
|
|
10
|
+
kweaver auth list List saved platforms
|
|
11
|
+
kweaver auth use <url> Switch active platform
|
|
12
|
+
kweaver auth logout [url] Logout (clear local token)
|
|
13
|
+
kweaver auth delete <url> Delete saved credentials`);
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
36
16
|
if (target === "login") {
|
|
37
17
|
const url = rest[0];
|
|
38
18
|
if (!url) {
|
|
@@ -44,47 +24,34 @@ export async function runAuthCommand(args) {
|
|
|
44
24
|
if (target && target !== "status" && target !== "list" && target !== "use" && target !== "delete" && target !== "logout") {
|
|
45
25
|
try {
|
|
46
26
|
const normalizedTarget = normalizeBaseUrl(target);
|
|
47
|
-
const port = Number(readOption(args, "--port") ?? "9010");
|
|
48
|
-
const clientName = readOption(args, "--client-name") ?? "kweaver";
|
|
49
27
|
const alias = readOption(args, "--alias");
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
port,
|
|
60
|
-
clientName,
|
|
61
|
-
open,
|
|
62
|
-
forceRegister,
|
|
63
|
-
host,
|
|
64
|
-
redirectUriOverride,
|
|
65
|
-
lang,
|
|
66
|
-
product,
|
|
67
|
-
xForwardedPrefix,
|
|
68
|
-
});
|
|
28
|
+
const username = readOption(args, "--username") ?? readOption(args, "-u");
|
|
29
|
+
const password = readOption(args, "--password") ?? readOption(args, "-p");
|
|
30
|
+
if (username && password) {
|
|
31
|
+
console.log("Logging in (headless)...");
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log("Opening browser for login...");
|
|
35
|
+
}
|
|
36
|
+
const token = await playwrightLogin(normalizedTarget, username && password ? { username, password } : undefined);
|
|
69
37
|
if (alias) {
|
|
70
38
|
setPlatformAlias(normalizedTarget, alias);
|
|
71
39
|
}
|
|
72
40
|
console.log(`Config directory: ${getConfigDir()}`);
|
|
73
|
-
console.log(getClientProvisioningMessage(result.created));
|
|
74
|
-
console.log(`Client ID: ${result.client.clientId}`);
|
|
75
41
|
if (alias) {
|
|
76
42
|
console.log(`Alias: ${alias.toLowerCase()}`);
|
|
77
43
|
}
|
|
78
44
|
else {
|
|
79
|
-
const savedAlias = getPlatformAlias(
|
|
45
|
+
const savedAlias = getPlatformAlias(normalizedTarget);
|
|
80
46
|
if (savedAlias) {
|
|
81
47
|
console.log(`Alias: ${savedAlias}`);
|
|
82
48
|
}
|
|
83
49
|
}
|
|
84
|
-
console.log(`
|
|
85
|
-
console.log(`Callback received at: ${result.callback.receivedAt}`);
|
|
86
|
-
console.log(`Current platform: ${result.client.baseUrl}`);
|
|
50
|
+
console.log(`Current platform: ${normalizedTarget}`);
|
|
87
51
|
console.log(`Access token saved: yes`);
|
|
52
|
+
if (token.expiresAt) {
|
|
53
|
+
console.log(`Token expires at: ${token.expiresAt}`);
|
|
54
|
+
}
|
|
88
55
|
return 0;
|
|
89
56
|
}
|
|
90
57
|
catch (error) {
|
|
@@ -95,18 +62,35 @@ export async function runAuthCommand(args) {
|
|
|
95
62
|
if (target === "status") {
|
|
96
63
|
const resolvedTarget = args[1] ? resolvePlatformIdentifier(args[1]) : undefined;
|
|
97
64
|
const statusTarget = resolvedTarget && /^https?:\/\//.test(resolvedTarget) ? normalizeBaseUrl(resolvedTarget) : resolvedTarget ?? undefined;
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
100
|
-
console.error(
|
|
65
|
+
const platform = statusTarget ?? getCurrentPlatform();
|
|
66
|
+
if (!platform) {
|
|
67
|
+
console.error("No active platform. Run `kweaver auth login <platform-url>` first.");
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
const token = loadTokenConfig(platform);
|
|
71
|
+
if (!token) {
|
|
72
|
+
console.error(statusTarget ? `No saved token for ${statusTarget}.` : "No saved token found.");
|
|
101
73
|
return 1;
|
|
102
74
|
}
|
|
103
75
|
const currentPlatform = getCurrentPlatform();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
token
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
76
|
+
const lines = [
|
|
77
|
+
`Config directory: ${getConfigDir()}`,
|
|
78
|
+
`Platform: ${token.baseUrl}`,
|
|
79
|
+
`Current platform: ${token.baseUrl === currentPlatform ? "yes" : "no"}`,
|
|
80
|
+
`Token present: yes`,
|
|
81
|
+
];
|
|
82
|
+
if (token.expiresAt) {
|
|
83
|
+
const expiry = new Date(token.expiresAt);
|
|
84
|
+
const remainingMs = expiry.getTime() - Date.now();
|
|
85
|
+
if (remainingMs > 0) {
|
|
86
|
+
const remainingMin = Math.ceil(remainingMs / 60_000);
|
|
87
|
+
lines.push(`Token status: active (expires in ${remainingMin} min)`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
lines.push(`Token status: expired (run \`kweaver auth login ${token.baseUrl}\` again)`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const line of lines) {
|
|
110
94
|
console.log(line);
|
|
111
95
|
}
|
|
112
96
|
return 0;
|
|
@@ -134,7 +118,7 @@ export async function runAuthCommand(args) {
|
|
|
134
118
|
return 1;
|
|
135
119
|
}
|
|
136
120
|
if (!hasPlatform(useTarget)) {
|
|
137
|
-
console.error(`No saved
|
|
121
|
+
console.error(`No saved token for ${useTarget}. Run \`kweaver auth login ${useTarget}\` first.`);
|
|
138
122
|
return 1;
|
|
139
123
|
}
|
|
140
124
|
setCurrentPlatform(useTarget);
|
|
@@ -149,7 +133,7 @@ export async function runAuthCommand(args) {
|
|
|
149
133
|
return 1;
|
|
150
134
|
}
|
|
151
135
|
if (!hasPlatform(deleteTarget)) {
|
|
152
|
-
console.error(`No saved
|
|
136
|
+
console.error(`No saved token for ${deleteTarget}.`);
|
|
153
137
|
return 1;
|
|
154
138
|
}
|
|
155
139
|
const wasCurrent = getCurrentPlatform() === deleteTarget;
|
|
@@ -166,25 +150,20 @@ export async function runAuthCommand(args) {
|
|
|
166
150
|
const logoutTarget = resolvedTarget && /^https?:\/\//.test(resolvedTarget) ? normalizeBaseUrl(resolvedTarget) : resolvedTarget;
|
|
167
151
|
if (!logoutTarget) {
|
|
168
152
|
console.error("Usage: kweaver auth logout [platform-url|alias]");
|
|
169
|
-
console.error("No current platform. Specify a platform to logout
|
|
153
|
+
console.error("No current platform. Specify a platform to logout.");
|
|
170
154
|
return 1;
|
|
171
155
|
}
|
|
172
156
|
if (!hasPlatform(logoutTarget)) {
|
|
173
|
-
console.error(`No saved
|
|
157
|
+
console.error(`No saved token for ${logoutTarget}.`);
|
|
174
158
|
return 1;
|
|
175
159
|
}
|
|
176
|
-
const { client, token } = getStoredAuthSummary(logoutTarget);
|
|
177
|
-
if (client) {
|
|
178
|
-
await callLogoutEndpoint(client, token);
|
|
179
|
-
}
|
|
180
160
|
clearPlatformSession(logoutTarget);
|
|
181
161
|
console.log(`Logged out: ${logoutTarget}`);
|
|
182
|
-
console.log(`Run \`kweaver auth ${logoutTarget}\` to sign in again
|
|
162
|
+
console.log(`Run \`kweaver auth login ${logoutTarget}\` to sign in again.`);
|
|
183
163
|
return 0;
|
|
184
164
|
}
|
|
185
|
-
console.error("Usage: kweaver auth <platform-url>");
|
|
186
|
-
console.error(" kweaver auth
|
|
187
|
-
console.error(" kweaver auth <platform-url> [--alias <name>] [--no-open] [--host <host>] [--redirect-uri <uri>]");
|
|
165
|
+
console.error("Usage: kweaver auth login <platform-url>");
|
|
166
|
+
console.error(" kweaver auth <platform-url> [--alias <name>]");
|
|
188
167
|
console.error(" kweaver auth status [platform-url|alias]");
|
|
189
168
|
console.error(" kweaver auth list");
|
|
190
169
|
console.error(" kweaver auth use <platform-url|alias>");
|
package/dist/commands/bkn.d.ts
CHANGED
|
@@ -41,6 +41,20 @@ export interface KnDeleteOptions {
|
|
|
41
41
|
yes: boolean;
|
|
42
42
|
}
|
|
43
43
|
export declare function parseKnDeleteArgs(args: string[]): KnDeleteOptions;
|
|
44
|
+
export interface KnPushOptions {
|
|
45
|
+
directory: string;
|
|
46
|
+
branch: string;
|
|
47
|
+
businessDomain: string;
|
|
48
|
+
pretty: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare function parseKnPushArgs(args: string[]): KnPushOptions;
|
|
51
|
+
export interface KnPullOptions {
|
|
52
|
+
knId: string;
|
|
53
|
+
directory: string;
|
|
54
|
+
branch: string;
|
|
55
|
+
businessDomain: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function parseKnPullArgs(args: string[]): KnPullOptions;
|
|
44
58
|
export interface KnObjectTypeQueryOptions {
|
|
45
59
|
knId: string;
|
|
46
60
|
otId: string;
|
|
@@ -66,6 +80,8 @@ export declare function parseKnBuildArgs(args: string[]): {
|
|
|
66
80
|
timeout: number;
|
|
67
81
|
businessDomain: string;
|
|
68
82
|
};
|
|
83
|
+
export declare function packDirectoryToTar(dirPath: string): Buffer;
|
|
84
|
+
export declare function extractTarToDirectory(tarBuffer: Buffer, dirPath: string): void;
|
|
69
85
|
export declare function parseKnSearchArgs(args: string[]): {
|
|
70
86
|
knId: string;
|
|
71
87
|
query: string;
|