@bhooai/nexus-ai-client 2.0.12 → 2.0.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/package.json +22 -20
- package/src/client.ts +3 -0
- package/tests/ai-client.test.ts +10 -0
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bhooai/nexus-ai-client",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
6
|
-
},
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "./src/index.ts",
|
|
9
|
-
"types": "./src/index.ts",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc -p tsconfig.json",
|
|
12
|
-
"test": "vitest run"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@bhooai/nexus-ai-client",
|
|
3
|
+
"version": "2.0.15",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./src/index.ts",
|
|
9
|
+
"types": "./src/index.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc -p tsconfig.json",
|
|
12
|
+
"test": "vitest run"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@bhooai/nexus-crypto": "^2.0.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.5.0",
|
|
19
|
+
"typescript": "^5.6.2",
|
|
20
|
+
"vitest": "^2.1.1"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
} from './types.js';
|
|
15
15
|
import { AiError, isRetryable } from './errors.js';
|
|
16
16
|
import { parseSseStream } from './sse.js';
|
|
17
|
+
import { requireLicense } from '@bhooai/nexus-crypto';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Node client for the BhooAI Nexus AI server (Python FastAPI). OpenAI-compatible.
|
|
@@ -43,6 +44,8 @@ export class AiClient {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
private async request<T>(path: string, init: RequestInit, { stream = false } = {}): Promise<T> {
|
|
47
|
+
// Licensed feature: every AI call needs a master key (per-package key derived).
|
|
48
|
+
requireLicense('nexus-ai-client');
|
|
46
49
|
let lastErr: unknown;
|
|
47
50
|
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
48
51
|
const controller = new AbortController();
|
package/tests/ai-client.test.ts
CHANGED
|
@@ -44,6 +44,16 @@ afterEach(() => {
|
|
|
44
44
|
servers = [];
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
+
/** Licensed features need a master key — fixture, never a real secret. */
|
|
48
|
+
const PREV_LICENSE = process.env.NEXUS_LICENSE_KEY;
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
process.env.NEXUS_LICENSE_KEY = 'nxl_test_master_key_001';
|
|
51
|
+
});
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
if (PREV_LICENSE === undefined) delete process.env.NEXUS_LICENSE_KEY;
|
|
54
|
+
else process.env.NEXUS_LICENSE_KEY = PREV_LICENSE;
|
|
55
|
+
});
|
|
56
|
+
|
|
47
57
|
describe('AiClient', () => {
|
|
48
58
|
it('chat (non-stream) parses the response', async () => {
|
|
49
59
|
await withServer((_req, res, body) => {
|