@bhooai/nexus-ai-client 2.0.13 → 2.0.16

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 CHANGED
@@ -1,20 +1,22 @@
1
- {
2
- "name": "@bhooai/nexus-ai-client",
3
- "version": "2.0.13",
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
- "devDependencies": {
16
- "@types/node": "^22.5.0",
17
- "typescript": "^5.6.2",
18
- "vitest": "^2.1.1"
19
- }
20
- }
1
+ {
2
+ "name": "@bhooai/nexus-ai-client",
3
+ "version": "2.0.16",
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();
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, afterEach, beforeEach } from 'vitest';
1
+ import { describe, it, expect, afterEach, vi } from 'vitest';
2
2
  import { createServer, type Server, type IncomingMessage, type ServerResponse } from 'node:http';
3
3
  import { AiClient, AiError } from '../src/index.js';
4
4
  import type { ChatCompletionChunk } from '../src/index.js';
@@ -44,6 +44,13 @@ afterEach(() => {
44
44
  servers = [];
45
45
  });
46
46
 
47
+ // The license gate is verified at app boot (ensureLicense); these tests exercise
48
+ // the client itself, so stub the gate.
49
+ vi.mock('@bhooai/nexus-crypto', () => ({
50
+ requireLicense: () => {},
51
+ LicenseError: class LicenseError extends Error {},
52
+ }));
53
+
47
54
  describe('AiClient', () => {
48
55
  it('chat (non-stream) parses the response', async () => {
49
56
  await withServer((_req, res, body) => {