@kweaver-ai/kweaver-sdk 0.4.0
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/bin/kweaver.js +9 -0
- package/dist/api/agent-chat.d.ts +69 -0
- package/dist/api/agent-chat.js +379 -0
- package/dist/api/agent-list.d.ts +12 -0
- package/dist/api/agent-list.js +33 -0
- package/dist/api/context-loader.d.ts +115 -0
- package/dist/api/context-loader.js +259 -0
- package/dist/api/conversations.d.ts +24 -0
- package/dist/api/conversations.js +64 -0
- package/dist/api/knowledge-networks.d.ts +57 -0
- package/dist/api/knowledge-networks.js +158 -0
- package/dist/api/ontology-query.d.ts +75 -0
- package/dist/api/ontology-query.js +238 -0
- package/dist/api/semantic-search.d.ts +12 -0
- package/dist/api/semantic-search.js +34 -0
- package/dist/auth/oauth.d.ts +75 -0
- package/dist/auth/oauth.js +417 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +79 -0
- package/dist/client.d.ts +95 -0
- package/dist/client.js +104 -0
- package/dist/commands/agent-chat.d.ts +12 -0
- package/dist/commands/agent-chat.js +193 -0
- package/dist/commands/agent.d.ts +28 -0
- package/dist/commands/agent.js +431 -0
- package/dist/commands/auth.d.ts +9 -0
- package/dist/commands/auth.js +201 -0
- package/dist/commands/bkn.d.ts +70 -0
- package/dist/commands/bkn.js +1371 -0
- package/dist/commands/call.d.ts +14 -0
- package/dist/commands/call.js +151 -0
- package/dist/commands/context-loader.d.ts +1 -0
- package/dist/commands/context-loader.js +383 -0
- package/dist/commands/token.d.ts +2 -0
- package/dist/commands/token.js +24 -0
- package/dist/config/store.d.ts +77 -0
- package/dist/config/store.js +380 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +44 -0
- package/dist/kweaver.d.ts +146 -0
- package/dist/kweaver.js +184 -0
- package/dist/resources/agents.d.ts +37 -0
- package/dist/resources/agents.js +60 -0
- package/dist/resources/bkn.d.ts +45 -0
- package/dist/resources/bkn.js +86 -0
- package/dist/resources/context-loader.d.ts +15 -0
- package/dist/resources/context-loader.js +32 -0
- package/dist/resources/conversations.d.ts +11 -0
- package/dist/resources/conversations.js +17 -0
- package/dist/resources/knowledge-networks.d.ts +65 -0
- package/dist/resources/knowledge-networks.js +167 -0
- package/dist/ui/ChatApp.d.ts +16 -0
- package/dist/ui/ChatApp.js +248 -0
- package/dist/ui/MarkdownBlock.d.ts +5 -0
- package/dist/ui/MarkdownBlock.js +137 -0
- package/dist/ui/display-text.d.ts +1 -0
- package/dist/ui/display-text.js +1 -0
- package/dist/utils/browser.d.ts +1 -0
- package/dist/utils/browser.js +20 -0
- package/dist/utils/display-text.d.ts +3 -0
- package/dist/utils/display-text.js +46 -0
- package/dist/utils/http.d.ts +17 -0
- package/dist/utils/http.js +72 -0
- package/package.json +62 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class HttpError extends Error {
|
|
2
|
+
readonly status: number;
|
|
3
|
+
readonly statusText: string;
|
|
4
|
+
readonly body: string;
|
|
5
|
+
constructor(status: number, statusText: string, body: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class NetworkRequestError extends Error {
|
|
8
|
+
readonly method: string;
|
|
9
|
+
readonly url: string;
|
|
10
|
+
readonly causeMessage: string;
|
|
11
|
+
readonly hint: string;
|
|
12
|
+
constructor(method: string, url: string, causeMessage: string, hint: string);
|
|
13
|
+
}
|
|
14
|
+
export declare function fetchTextOrThrow(input: RequestInfo | URL, init?: RequestInit): Promise<{
|
|
15
|
+
response: Response;
|
|
16
|
+
body: string;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export class HttpError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
statusText;
|
|
4
|
+
body;
|
|
5
|
+
constructor(status, statusText, body) {
|
|
6
|
+
super(`HTTP ${status} ${statusText}`);
|
|
7
|
+
this.name = "HttpError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.statusText = statusText;
|
|
10
|
+
this.body = body;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class NetworkRequestError extends Error {
|
|
14
|
+
method;
|
|
15
|
+
url;
|
|
16
|
+
causeMessage;
|
|
17
|
+
hint;
|
|
18
|
+
constructor(method, url, causeMessage, hint) {
|
|
19
|
+
super(`Network request failed`);
|
|
20
|
+
this.name = "NetworkRequestError";
|
|
21
|
+
this.method = method;
|
|
22
|
+
this.url = url;
|
|
23
|
+
this.causeMessage = causeMessage;
|
|
24
|
+
this.hint = hint;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function buildNetworkHint(causeMessage) {
|
|
28
|
+
const normalized = causeMessage.toLowerCase();
|
|
29
|
+
if (normalized.includes("enotfound") ||
|
|
30
|
+
normalized.includes("eai_again") ||
|
|
31
|
+
normalized.includes("getaddrinfo")) {
|
|
32
|
+
return "DNS lookup failed. Check whether the domain is correct and reachable from your network.";
|
|
33
|
+
}
|
|
34
|
+
if (normalized.includes("certificate") ||
|
|
35
|
+
normalized.includes("self signed") ||
|
|
36
|
+
normalized.includes("hostname") ||
|
|
37
|
+
normalized.includes("tls")) {
|
|
38
|
+
return "TLS handshake failed. Check the HTTPS certificate and whether the host supports this domain.";
|
|
39
|
+
}
|
|
40
|
+
if (normalized.includes("econnrefused") ||
|
|
41
|
+
normalized.includes("econnreset") ||
|
|
42
|
+
normalized.includes("socket") ||
|
|
43
|
+
normalized.includes("network is unreachable")) {
|
|
44
|
+
return "The host could not be reached. Check connectivity, firewall rules, and whether the service is listening.";
|
|
45
|
+
}
|
|
46
|
+
return "Check whether the platform URL is correct and whether it exposes /oauth2/clients over HTTPS.";
|
|
47
|
+
}
|
|
48
|
+
export async function fetchTextOrThrow(input, init) {
|
|
49
|
+
let response;
|
|
50
|
+
try {
|
|
51
|
+
response = await fetch(input, init);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const url = typeof input === "string"
|
|
55
|
+
? input
|
|
56
|
+
: input instanceof URL
|
|
57
|
+
? input.toString()
|
|
58
|
+
: input.url;
|
|
59
|
+
const causeMessage = error instanceof Error && "cause" in error && error.cause instanceof Error
|
|
60
|
+
? error.cause.message
|
|
61
|
+
: error instanceof Error
|
|
62
|
+
? error.message
|
|
63
|
+
: String(error);
|
|
64
|
+
const method = init?.method ?? "GET";
|
|
65
|
+
throw new NetworkRequestError(method, url, causeMessage, buildNetworkHint(causeMessage));
|
|
66
|
+
}
|
|
67
|
+
const body = await response.text();
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
70
|
+
}
|
|
71
|
+
return { response, body };
|
|
72
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kweaver-ai/kweaver-sdk",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "KWeaver TypeScript SDK — CLI tool and programmatic API for knowledge networks and Decision Agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./kweaver": {
|
|
14
|
+
"import": "./dist/kweaver.js",
|
|
15
|
+
"types": "./dist/kweaver.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"kweaver": "bin/kweaver.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "tsx watch src/cli.ts",
|
|
27
|
+
"build": "tsc -p tsconfig.json",
|
|
28
|
+
"start": "node ./dist/cli.js",
|
|
29
|
+
"lint": "tsc --noEmit -p tsconfig.json",
|
|
30
|
+
"test": "node --import tsx --test test/**/*.test.ts",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"cli",
|
|
35
|
+
"typescript",
|
|
36
|
+
"kweaver"
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/kweaver-ai/kweaver-sdk.git"
|
|
41
|
+
},
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=22"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^24.6.0",
|
|
51
|
+
"@types/react": "^19.2.14",
|
|
52
|
+
"tsx": "^4.20.5",
|
|
53
|
+
"typescript": "^5.9.3"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"ink": "^6.8.0",
|
|
57
|
+
"ink-spinner": "^5.0.0",
|
|
58
|
+
"ink-text-input": "^6.0.0",
|
|
59
|
+
"marked": "^11.2.0",
|
|
60
|
+
"react": "^19.2.4"
|
|
61
|
+
}
|
|
62
|
+
}
|