npm-ai-hooks 2.0.1 → 2.0.3

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.
@@ -9,7 +9,7 @@ export declare class GeminiProvider extends BaseProvider {
9
9
  protected buildRequestConfig(prompt: string, model: string, apiKey: string): {
10
10
  url: string;
11
11
  headers: {};
12
- method?: import("axios").Method | string;
12
+ method?: (string & {}) | import("axios").Method;
13
13
  baseURL?: string;
14
14
  allowAbsoluteUrls?: boolean;
15
15
  transformRequest?: import("axios").AxiosRequestTransformer | import("axios").AxiosRequestTransformer[];
@@ -20,10 +20,10 @@ export declare class GeminiProvider extends BaseProvider {
20
20
  timeout?: number;
21
21
  timeoutErrorMessage?: string;
22
22
  withCredentials?: boolean;
23
- adapter?: (import("axios").AxiosAdapter | ("fetch" | "xhr" | "http" | (string & {}))) | (import("axios").AxiosAdapter | ("fetch" | "xhr" | "http" | (string & {})))[];
23
+ adapter?: (import("axios").AxiosAdapter | ((string & {}) | "xhr" | "http" | "fetch")) | (import("axios").AxiosAdapter | ((string & {}) | "xhr" | "http" | "fetch"))[];
24
24
  auth?: import("axios").AxiosBasicCredentials;
25
25
  responseType?: import("axios").ResponseType;
26
- responseEncoding?: import("axios").responseEncoding | string;
26
+ responseEncoding?: (string & {}) | import("axios").responseEncoding;
27
27
  xsrfCookieName?: string;
28
28
  xsrfHeaderName?: string;
29
29
  onUploadProgress?: (progressEvent: import("axios").AxiosProgressEvent) => void;
@@ -36,13 +36,18 @@ export declare class GeminiProvider extends BaseProvider {
36
36
  beforeRedirect?: (options: Record<string, any>, responseDetails: {
37
37
  headers: Record<string, string>;
38
38
  statusCode: import("axios").HttpStatusCode;
39
+ }, requestDetails: {
40
+ headers: Record<string, string>;
41
+ url: string;
42
+ method: string;
39
43
  }) => void;
40
44
  socketPath?: string | null;
45
+ allowedSocketPaths?: string | string[] | null;
41
46
  transport?: any;
42
47
  httpAgent?: any;
43
48
  httpsAgent?: any;
44
49
  proxy?: import("axios").AxiosProxyConfig | false;
45
- cancelToken?: import("axios").CancelToken;
50
+ cancelToken?: import("axios").CancelToken | undefined;
46
51
  decompress?: boolean;
47
52
  transitional?: import("axios").TransitionalOptions;
48
53
  signal?: import("axios").GenericAbortSignal;
@@ -57,8 +62,17 @@ export declare class GeminiProvider extends BaseProvider {
57
62
  family?: import("axios").AddressFamily;
58
63
  lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: import("axios").LookupAddress | import("axios").LookupAddress[], family?: import("axios").AddressFamily) => void) => void) | ((hostname: string, options: object) => Promise<[address: import("axios").LookupAddressEntry | import("axios").LookupAddressEntry[], family?: import("axios").AddressFamily] | import("axios").LookupAddress>);
59
64
  withXSRFToken?: boolean | ((config: import("axios").InternalAxiosRequestConfig) => boolean | undefined);
60
- parseReviver?: (this: any, key: string, value: any) => any;
65
+ parseReviver?: (this: any, key: string, value: any, context?: {
66
+ source?: string;
67
+ }) => any;
61
68
  fetchOptions?: Omit<RequestInit, "body" | "headers" | "method" | "signal"> | Record<string, any>;
69
+ httpVersion?: 1 | 2;
70
+ http2Options?: Record<string, any> & {
71
+ sessionTimeout?: number;
72
+ };
73
+ formDataHeaderPolicy?: "legacy" | "content-only";
74
+ redact?: string[];
75
+ sensitiveHeaders?: string[];
62
76
  };
63
77
  protected buildAuthHeaders(): Record<string, string>;
64
78
  }
@@ -7,5 +7,9 @@ export declare function getProvider(name?: Provider): {
7
7
  fn: ProviderFunction<any>;
8
8
  provider: Provider | "mock";
9
9
  };
10
+ export declare function getProviderChain(name?: Provider): Array<{
11
+ fn: ProviderFunction<any>;
12
+ provider: Provider;
13
+ }>;
10
14
  export { initAIHooks, addProvider, removeProvider, isInitialized, reset, UserProviderConfig, ProviderInitializationOptions };
11
15
  export { providerRegistry };
@@ -46,6 +46,15 @@ export declare function getProvider(name?: Provider): {
46
46
  fn: any;
47
47
  provider: Provider;
48
48
  };
49
+ /**
50
+ * Get the full ordered provider chain for fallback
51
+ * @param name - Optional preferred provider name (placed first)
52
+ * @returns Ordered array of {fn, provider} to try in sequence
53
+ */
54
+ export declare function getProviderChain(name?: Provider): Array<{
55
+ fn: any;
56
+ provider: Provider;
57
+ }>;
49
58
  /**
50
59
  * Check if AI hooks is initialized
51
60
  * @returns True if initialized
package/package.json CHANGED
@@ -1,94 +1,94 @@
1
- {
2
- "name": "npm-ai-hooks",
3
- "version": "2.0.1",
4
- "description": "Universal AI Hook Layer for Node.js and React – one wrapper for all AI providers. Inject LLM-like behavior into any JavaScript or TypeScript function with a single line, without writing prompts, handling SDKs, or locking into any provider.",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/esm/index.js",
12
- "require": "./dist/cjs/index.js"
13
- }
14
- },
15
- "files": [
16
- "dist",
17
- "Readme.md",
18
- "LICENSE"
19
- ],
20
- "scripts": {
21
- "dev": "ts-node src/index.ts",
22
- "clean": "rimraf dist",
23
- "build": "npm run clean && npm run build:esm && npm run build:cjs",
24
- "build:esm": "tsc --project tsconfig.esm.json",
25
- "build:cjs": "tsc --project tsconfig.cjs.json",
26
- "test": "jest --verbose",
27
- "test:watch": "jest --watch",
28
- "test:coverage": "jest --coverage",
29
- "test:ci": "jest --ci --coverage --watchAll=false",
30
- "test:providers": "jest tests/providers.test.ts --verbose",
31
- "test:tasks": "jest tests/tasks.test.ts --verbose",
32
- "test:errors": "jest tests/error-handling.test.ts --verbose",
33
- "test:integration": "jest tests/integration.test.ts --verbose",
34
- "test:performance": "jest tests/performance.test.ts --verbose",
35
- "test:env": "jest --testNamePattern=\"Real API|Environment-based\" --verbose",
36
- "test:mock": "jest --testNamePattern=\"Provider Detection|Task Tests\" --verbose",
37
- "lint": "eslint . --ext .ts",
38
- "format": "prettier --write .",
39
- "prepare": "npm run build",
40
- "demo": "npx ts-node examples/demo.ts",
41
- "setup:dev": "bash scripts/setup-dev.sh",
42
- "setup:dev:win": "scripts\\setup-dev.bat",
43
- "setup:dev:ps": "powershell -ExecutionPolicy Bypass -File scripts\\setup-dev.ps1"
44
- },
45
- "author": "AteebNoOne <ateebnoone@gmail.com>",
46
- "repository": {
47
- "type": "git",
48
- "url": "https://github.com/iTeebot/npm-ai-hooks.git"
49
- },
50
- "license": "MIT",
51
- "dependencies": {
52
- "axios": "^1.12.2"
53
- },
54
- "devDependencies": {
55
- "@types/jest": "^30.0.0",
56
- "@types/node": "^24.7.0",
57
- "dotenv": "^17.2.3",
58
- "eslint": "^9.37.0",
59
- "jest": "^30.2.0",
60
- "prettier": "^3.6.2",
61
- "rimraf": "^6.0.1",
62
- "ts-jest": "^29.4.4",
63
- "ts-node": "^10.9.2",
64
- "typescript": "^5.9.3"
65
- },
66
- "keywords": [
67
- "ai",
68
- "llm",
69
- "openai",
70
- "claude",
71
- "gemini",
72
- "groq",
73
- "openrouter",
74
- "deepseek",
75
- "mistral",
76
- "xai",
77
- "perplexity",
78
- "react",
79
- "vite",
80
- "express",
81
- "nodejs",
82
- "typescript",
83
- "hooks",
84
- "wrapper",
85
- "universal",
86
- "cross-platform"
87
- ],
88
- "engines": {
89
- "node": ">=18"
90
- },
91
- "publishConfig": {
92
- "access": "public"
93
- }
94
- }
1
+ {
2
+ "name": "npm-ai-hooks",
3
+ "version": "2.0.3",
4
+ "description": "Universal AI Hook Layer for Node.js and React – one wrapper for all AI providers. Inject LLM-like behavior into any JavaScript or TypeScript function with a single line, without writing prompts, handling SDKs, or locking into any provider.",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/cjs/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "Readme.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "dev": "ts-node src/index.ts",
22
+ "clean": "rimraf dist",
23
+ "build": "npm run clean && npm run build:esm && npm run build:cjs",
24
+ "build:esm": "tsc --project tsconfig.esm.json",
25
+ "build:cjs": "tsc --project tsconfig.cjs.json",
26
+ "test": "jest --verbose",
27
+ "test:watch": "jest --watch",
28
+ "test:coverage": "jest --coverage",
29
+ "test:ci": "jest --ci --coverage --watchAll=false",
30
+ "test:providers": "jest tests/providers.test.ts --verbose",
31
+ "test:tasks": "jest tests/tasks.test.ts --verbose",
32
+ "test:errors": "jest tests/error-handling.test.ts --verbose",
33
+ "test:integration": "jest tests/integration.test.ts --verbose",
34
+ "test:performance": "jest tests/performance.test.ts --verbose",
35
+ "test:env": "jest --testNamePattern=\"Real API|Environment-based\" --verbose",
36
+ "test:mock": "jest --testNamePattern=\"Provider Detection|Task Tests\" --verbose",
37
+ "lint": "eslint . --ext .ts",
38
+ "format": "prettier --write .",
39
+ "prepare": "npm run build",
40
+ "demo": "npx ts-node examples/demo.ts",
41
+ "setup:dev": "bash scripts/setup-dev.sh",
42
+ "setup:dev:win": "scripts\\setup-dev.bat",
43
+ "setup:dev:ps": "powershell -ExecutionPolicy Bypass -File scripts\\setup-dev.ps1"
44
+ },
45
+ "author": "AteebNoOne <ateebnoone@gmail.com>",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/iTeebot/npm-ai-hooks.git"
49
+ },
50
+ "license": "MIT",
51
+ "dependencies": {
52
+ "axios": "^1.12.2"
53
+ },
54
+ "devDependencies": {
55
+ "@types/jest": "^30.0.0",
56
+ "@types/node": "^24.7.0",
57
+ "dotenv": "^17.2.3",
58
+ "eslint": "^9.37.0",
59
+ "jest": "^30.2.0",
60
+ "prettier": "^3.6.2",
61
+ "rimraf": "^6.0.1",
62
+ "ts-jest": "^29.4.4",
63
+ "ts-node": "^10.9.2",
64
+ "typescript": "^5.9.3"
65
+ },
66
+ "keywords": [
67
+ "ai",
68
+ "llm",
69
+ "openai",
70
+ "claude",
71
+ "gemini",
72
+ "groq",
73
+ "openrouter",
74
+ "deepseek",
75
+ "mistral",
76
+ "xai",
77
+ "perplexity",
78
+ "react",
79
+ "vite",
80
+ "express",
81
+ "nodejs",
82
+ "typescript",
83
+ "hooks",
84
+ "wrapper",
85
+ "universal",
86
+ "cross-platform"
87
+ ],
88
+ "engines": {
89
+ "node": ">=18"
90
+ },
91
+ "publishConfig": {
92
+ "access": "public"
93
+ }
94
+ }