recker 1.0.29 → 1.0.30
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/README.md +28 -1
- package/dist/ai/client-ai.d.ts +41 -0
- package/dist/ai/client-ai.js +391 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.js +2 -0
- package/dist/ai/memory.d.ts +35 -0
- package/dist/ai/memory.js +136 -0
- package/dist/browser/ai/client-ai.d.ts +41 -0
- package/dist/browser/ai/client-ai.js +391 -0
- package/dist/browser/ai/memory.d.ts +35 -0
- package/dist/browser/ai/memory.js +136 -0
- package/dist/browser/core/client.d.ts +6 -1
- package/dist/browser/core/client.js +18 -0
- package/dist/browser/transport/undici.js +11 -2
- package/dist/browser/types/ai-client.d.ts +32 -0
- package/dist/browser/types/ai-client.js +1 -0
- package/dist/browser/types/ai.d.ts +1 -1
- package/dist/cli/index.js +261 -1
- package/dist/cli/tui/scroll-buffer.js +4 -4
- package/dist/cli/tui/shell.d.ts +3 -0
- package/dist/cli/tui/shell.js +166 -19
- package/dist/core/client.d.ts +6 -1
- package/dist/core/client.js +18 -0
- package/dist/mcp/server.js +15 -0
- package/dist/mcp/tools/scrape.d.ts +3 -0
- package/dist/mcp/tools/scrape.js +156 -0
- package/dist/mcp/tools/security.d.ts +3 -0
- package/dist/mcp/tools/security.js +471 -0
- package/dist/mcp/tools/seo.d.ts +3 -0
- package/dist/mcp/tools/seo.js +427 -0
- package/dist/presets/anthropic.d.ts +3 -1
- package/dist/presets/anthropic.js +11 -1
- package/dist/presets/azure-openai.d.ts +3 -1
- package/dist/presets/azure-openai.js +11 -1
- package/dist/presets/cohere.d.ts +3 -1
- package/dist/presets/cohere.js +8 -2
- package/dist/presets/deepseek.d.ts +3 -1
- package/dist/presets/deepseek.js +8 -2
- package/dist/presets/fireworks.d.ts +3 -1
- package/dist/presets/fireworks.js +8 -2
- package/dist/presets/gemini.d.ts +3 -1
- package/dist/presets/gemini.js +8 -1
- package/dist/presets/groq.d.ts +3 -1
- package/dist/presets/groq.js +8 -2
- package/dist/presets/huggingface.d.ts +3 -1
- package/dist/presets/huggingface.js +8 -1
- package/dist/presets/mistral.d.ts +3 -1
- package/dist/presets/mistral.js +8 -2
- package/dist/presets/openai.d.ts +3 -1
- package/dist/presets/openai.js +9 -2
- package/dist/presets/perplexity.d.ts +3 -1
- package/dist/presets/perplexity.js +8 -2
- package/dist/presets/registry.d.ts +4 -0
- package/dist/presets/registry.js +48 -0
- package/dist/presets/replicate.d.ts +3 -1
- package/dist/presets/replicate.js +8 -1
- package/dist/presets/together.d.ts +3 -1
- package/dist/presets/together.js +8 -2
- package/dist/presets/xai.d.ts +3 -1
- package/dist/presets/xai.js +8 -2
- package/dist/scrape/spider.js +1 -1
- package/dist/transport/undici.js +11 -2
- package/dist/types/ai-client.d.ts +32 -0
- package/dist/types/ai-client.js +1 -0
- package/dist/types/ai.d.ts +1 -1
- package/dist/utils/colors.d.ts +2 -0
- package/dist/utils/colors.js +4 -0
- package/package.json +1 -1
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export function huggingface(options) {
|
|
2
|
+
const _aiConfig = {
|
|
3
|
+
provider: 'huggingface',
|
|
4
|
+
apiKey: options.apiKey,
|
|
5
|
+
model: options.model ?? 'meta-llama/Meta-Llama-3-70B-Instruct',
|
|
6
|
+
memory: { maxPairs: 12 },
|
|
7
|
+
};
|
|
2
8
|
return {
|
|
3
9
|
baseUrl: 'https://api-inference.huggingface.co',
|
|
4
10
|
headers: {
|
|
@@ -11,6 +17,7 @@ export function huggingface(options) {
|
|
|
11
17
|
backoff: 'exponential',
|
|
12
18
|
delay: 1000,
|
|
13
19
|
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
14
|
-
}
|
|
20
|
+
},
|
|
21
|
+
_aiConfig,
|
|
15
22
|
};
|
|
16
23
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
import type { ClientOptionsWithAI } from '../types/ai-client.js';
|
|
2
3
|
export interface MistralPresetOptions {
|
|
3
4
|
apiKey: string;
|
|
5
|
+
model?: string;
|
|
4
6
|
}
|
|
5
|
-
export declare function mistral(options: MistralPresetOptions): ClientOptions;
|
|
7
|
+
export declare function mistral(options: MistralPresetOptions): ClientOptions & ClientOptionsWithAI;
|
package/dist/presets/mistral.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export function mistral(options) {
|
|
2
|
+
const _aiConfig = {
|
|
3
|
+
provider: 'mistral',
|
|
4
|
+
apiKey: options.apiKey,
|
|
5
|
+
model: options.model ?? 'mistral-large-3',
|
|
6
|
+
memory: { maxPairs: 12 },
|
|
7
|
+
};
|
|
2
8
|
return {
|
|
3
9
|
baseUrl: 'https://api.mistral.ai/v1',
|
|
4
10
|
headers: {
|
|
5
11
|
'Authorization': `Bearer ${options.apiKey}`,
|
|
6
|
-
'Content-Type': 'application/json',
|
|
7
12
|
},
|
|
8
13
|
timeout: 5 * 60 * 1000,
|
|
9
14
|
retry: {
|
|
@@ -11,6 +16,7 @@ export function mistral(options) {
|
|
|
11
16
|
backoff: 'exponential',
|
|
12
17
|
delay: 1000,
|
|
13
18
|
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
14
|
-
}
|
|
19
|
+
},
|
|
20
|
+
_aiConfig,
|
|
15
21
|
};
|
|
16
22
|
}
|
package/dist/presets/openai.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
import type { ClientOptionsWithAI } from '../types/ai-client.js';
|
|
2
3
|
export interface OpenAIPresetOptions {
|
|
3
4
|
apiKey: string;
|
|
4
5
|
organization?: string;
|
|
5
6
|
project?: string;
|
|
7
|
+
model?: string;
|
|
6
8
|
}
|
|
7
|
-
export declare function openai(options: OpenAIPresetOptions): ClientOptions;
|
|
9
|
+
export declare function openai(options: OpenAIPresetOptions): ClientOptions & ClientOptionsWithAI;
|
package/dist/presets/openai.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export function openai(options) {
|
|
2
2
|
const headers = {
|
|
3
3
|
'Authorization': `Bearer ${options.apiKey}`,
|
|
4
|
-
'Content-Type': 'application/json'
|
|
5
4
|
};
|
|
6
5
|
if (options.organization) {
|
|
7
6
|
headers['OpenAI-Organization'] = options.organization;
|
|
@@ -9,6 +8,13 @@ export function openai(options) {
|
|
|
9
8
|
if (options.project) {
|
|
10
9
|
headers['OpenAI-Project'] = options.project;
|
|
11
10
|
}
|
|
11
|
+
const _aiConfig = {
|
|
12
|
+
provider: 'openai',
|
|
13
|
+
apiKey: options.apiKey,
|
|
14
|
+
model: options.model ?? 'gpt-5.1',
|
|
15
|
+
organization: options.organization,
|
|
16
|
+
memory: { maxPairs: 12 },
|
|
17
|
+
};
|
|
12
18
|
return {
|
|
13
19
|
baseUrl: 'https://api.openai.com/v1',
|
|
14
20
|
headers,
|
|
@@ -18,6 +24,7 @@ export function openai(options) {
|
|
|
18
24
|
backoff: 'exponential',
|
|
19
25
|
delay: 1000,
|
|
20
26
|
statusCodes: [408, 409, 429, 500, 502, 503, 504]
|
|
21
|
-
}
|
|
27
|
+
},
|
|
28
|
+
_aiConfig,
|
|
22
29
|
};
|
|
23
30
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
import type { ClientOptionsWithAI } from '../types/ai-client.js';
|
|
2
3
|
export interface PerplexityPresetOptions {
|
|
3
4
|
apiKey: string;
|
|
5
|
+
model?: string;
|
|
4
6
|
}
|
|
5
|
-
export declare function perplexity(options: PerplexityPresetOptions): ClientOptions;
|
|
7
|
+
export declare function perplexity(options: PerplexityPresetOptions): ClientOptions & ClientOptionsWithAI;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export function perplexity(options) {
|
|
2
|
+
const _aiConfig = {
|
|
3
|
+
provider: 'perplexity',
|
|
4
|
+
apiKey: options.apiKey,
|
|
5
|
+
model: options.model ?? 'sonar-pro',
|
|
6
|
+
memory: { maxPairs: 12 },
|
|
7
|
+
};
|
|
2
8
|
return {
|
|
3
9
|
baseUrl: 'https://api.perplexity.ai',
|
|
4
10
|
headers: {
|
|
5
11
|
'Authorization': `Bearer ${options.apiKey}`,
|
|
6
|
-
'Content-Type': 'application/json',
|
|
7
12
|
},
|
|
8
13
|
timeout: 5 * 60 * 1000,
|
|
9
14
|
retry: {
|
|
@@ -11,6 +16,7 @@ export function perplexity(options) {
|
|
|
11
16
|
backoff: 'exponential',
|
|
12
17
|
delay: 1000,
|
|
13
18
|
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
14
|
-
}
|
|
19
|
+
},
|
|
20
|
+
_aiConfig,
|
|
15
21
|
};
|
|
16
22
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
import type { AIProvider } from '../types/ai.js';
|
|
2
3
|
export type PresetFactory = (options: any) => ClientOptions;
|
|
3
4
|
export interface PresetInfo {
|
|
4
5
|
name: string;
|
|
@@ -8,6 +9,9 @@ export interface PresetInfo {
|
|
|
8
9
|
category: 'ai' | 'cloud' | 'saas' | 'devtools';
|
|
9
10
|
requiredAuth: string[];
|
|
10
11
|
docsUrl?: string;
|
|
12
|
+
aiProvider?: AIProvider;
|
|
13
|
+
defaultModel?: string;
|
|
14
|
+
chatEndpoint?: string;
|
|
11
15
|
}
|
|
12
16
|
export declare const presetRegistry: PresetInfo[];
|
|
13
17
|
export declare function detectPreset(url: string): PresetInfo | undefined;
|
package/dist/presets/registry.js
CHANGED
|
@@ -43,6 +43,9 @@ export const presetRegistry = [
|
|
|
43
43
|
category: 'ai',
|
|
44
44
|
requiredAuth: ['apiKey'],
|
|
45
45
|
docsUrl: 'https://platform.openai.com/docs',
|
|
46
|
+
aiProvider: 'openai',
|
|
47
|
+
defaultModel: 'gpt-4o',
|
|
48
|
+
chatEndpoint: '/chat/completions',
|
|
46
49
|
},
|
|
47
50
|
{
|
|
48
51
|
name: 'anthropic',
|
|
@@ -52,6 +55,9 @@ export const presetRegistry = [
|
|
|
52
55
|
category: 'ai',
|
|
53
56
|
requiredAuth: ['apiKey'],
|
|
54
57
|
docsUrl: 'https://docs.anthropic.com/',
|
|
58
|
+
aiProvider: 'anthropic',
|
|
59
|
+
defaultModel: 'claude-sonnet-4-20250514',
|
|
60
|
+
chatEndpoint: '/messages',
|
|
55
61
|
},
|
|
56
62
|
{
|
|
57
63
|
name: 'gemini',
|
|
@@ -61,6 +67,9 @@ export const presetRegistry = [
|
|
|
61
67
|
category: 'ai',
|
|
62
68
|
requiredAuth: ['apiKey'],
|
|
63
69
|
docsUrl: 'https://ai.google.dev/docs',
|
|
70
|
+
aiProvider: 'google',
|
|
71
|
+
defaultModel: 'gemini-2.0-flash',
|
|
72
|
+
chatEndpoint: '/models/{model}:generateContent',
|
|
64
73
|
},
|
|
65
74
|
{
|
|
66
75
|
name: 'cohere',
|
|
@@ -70,6 +79,9 @@ export const presetRegistry = [
|
|
|
70
79
|
category: 'ai',
|
|
71
80
|
requiredAuth: ['apiKey'],
|
|
72
81
|
docsUrl: 'https://docs.cohere.com/',
|
|
82
|
+
aiProvider: 'cohere',
|
|
83
|
+
defaultModel: 'command-r-plus',
|
|
84
|
+
chatEndpoint: '/chat',
|
|
73
85
|
},
|
|
74
86
|
{
|
|
75
87
|
name: 'mistral',
|
|
@@ -79,6 +91,9 @@ export const presetRegistry = [
|
|
|
79
91
|
category: 'ai',
|
|
80
92
|
requiredAuth: ['apiKey'],
|
|
81
93
|
docsUrl: 'https://docs.mistral.ai/',
|
|
94
|
+
aiProvider: 'mistral',
|
|
95
|
+
defaultModel: 'mistral-large-latest',
|
|
96
|
+
chatEndpoint: '/chat/completions',
|
|
82
97
|
},
|
|
83
98
|
{
|
|
84
99
|
name: 'groq',
|
|
@@ -88,6 +103,9 @@ export const presetRegistry = [
|
|
|
88
103
|
category: 'ai',
|
|
89
104
|
requiredAuth: ['apiKey'],
|
|
90
105
|
docsUrl: 'https://console.groq.com/docs',
|
|
106
|
+
aiProvider: 'groq',
|
|
107
|
+
defaultModel: 'llama-3.3-70b-versatile',
|
|
108
|
+
chatEndpoint: '/openai/v1/chat/completions',
|
|
91
109
|
},
|
|
92
110
|
{
|
|
93
111
|
name: 'together',
|
|
@@ -97,6 +115,9 @@ export const presetRegistry = [
|
|
|
97
115
|
category: 'ai',
|
|
98
116
|
requiredAuth: ['apiKey'],
|
|
99
117
|
docsUrl: 'https://docs.together.ai/',
|
|
118
|
+
aiProvider: 'together',
|
|
119
|
+
defaultModel: 'meta-llama/Llama-3.3-70B-Instruct-Turbo',
|
|
120
|
+
chatEndpoint: '/chat/completions',
|
|
100
121
|
},
|
|
101
122
|
{
|
|
102
123
|
name: 'replicate',
|
|
@@ -106,6 +127,9 @@ export const presetRegistry = [
|
|
|
106
127
|
category: 'ai',
|
|
107
128
|
requiredAuth: ['apiKey'],
|
|
108
129
|
docsUrl: 'https://replicate.com/docs',
|
|
130
|
+
aiProvider: 'replicate',
|
|
131
|
+
defaultModel: 'meta/llama-2-70b-chat',
|
|
132
|
+
chatEndpoint: '/predictions',
|
|
109
133
|
},
|
|
110
134
|
{
|
|
111
135
|
name: 'huggingface',
|
|
@@ -115,6 +139,9 @@ export const presetRegistry = [
|
|
|
115
139
|
category: 'ai',
|
|
116
140
|
requiredAuth: ['apiKey'],
|
|
117
141
|
docsUrl: 'https://huggingface.co/docs/api-inference',
|
|
142
|
+
aiProvider: 'huggingface',
|
|
143
|
+
defaultModel: 'meta-llama/Meta-Llama-3-70B-Instruct',
|
|
144
|
+
chatEndpoint: '/models/{model}',
|
|
118
145
|
},
|
|
119
146
|
{
|
|
120
147
|
name: 'perplexity',
|
|
@@ -124,6 +151,9 @@ export const presetRegistry = [
|
|
|
124
151
|
category: 'ai',
|
|
125
152
|
requiredAuth: ['apiKey'],
|
|
126
153
|
docsUrl: 'https://docs.perplexity.ai/',
|
|
154
|
+
aiProvider: 'perplexity',
|
|
155
|
+
defaultModel: 'llama-3.1-sonar-large-128k-online',
|
|
156
|
+
chatEndpoint: '/chat/completions',
|
|
127
157
|
},
|
|
128
158
|
{
|
|
129
159
|
name: 'deepseek',
|
|
@@ -133,6 +163,9 @@ export const presetRegistry = [
|
|
|
133
163
|
category: 'ai',
|
|
134
164
|
requiredAuth: ['apiKey'],
|
|
135
165
|
docsUrl: 'https://platform.deepseek.com/docs',
|
|
166
|
+
aiProvider: 'deepseek',
|
|
167
|
+
defaultModel: 'deepseek-chat',
|
|
168
|
+
chatEndpoint: '/chat/completions',
|
|
136
169
|
},
|
|
137
170
|
{
|
|
138
171
|
name: 'fireworks',
|
|
@@ -142,6 +175,9 @@ export const presetRegistry = [
|
|
|
142
175
|
category: 'ai',
|
|
143
176
|
requiredAuth: ['apiKey'],
|
|
144
177
|
docsUrl: 'https://docs.fireworks.ai/',
|
|
178
|
+
aiProvider: 'fireworks',
|
|
179
|
+
defaultModel: 'accounts/fireworks/models/llama-v3p1-70b-instruct',
|
|
180
|
+
chatEndpoint: '/inference/v1/chat/completions',
|
|
145
181
|
},
|
|
146
182
|
{
|
|
147
183
|
name: 'xai',
|
|
@@ -151,6 +187,9 @@ export const presetRegistry = [
|
|
|
151
187
|
category: 'ai',
|
|
152
188
|
requiredAuth: ['apiKey'],
|
|
153
189
|
docsUrl: 'https://docs.x.ai/',
|
|
190
|
+
aiProvider: 'xai',
|
|
191
|
+
defaultModel: 'grok-2',
|
|
192
|
+
chatEndpoint: '/v1/chat/completions',
|
|
154
193
|
},
|
|
155
194
|
{
|
|
156
195
|
name: 'grok',
|
|
@@ -160,6 +199,9 @@ export const presetRegistry = [
|
|
|
160
199
|
category: 'ai',
|
|
161
200
|
requiredAuth: ['apiKey'],
|
|
162
201
|
docsUrl: 'https://docs.x.ai/',
|
|
202
|
+
aiProvider: 'xai',
|
|
203
|
+
defaultModel: 'grok-2',
|
|
204
|
+
chatEndpoint: '/v1/chat/completions',
|
|
163
205
|
},
|
|
164
206
|
{
|
|
165
207
|
name: 'azure-openai',
|
|
@@ -169,6 +211,9 @@ export const presetRegistry = [
|
|
|
169
211
|
category: 'ai',
|
|
170
212
|
requiredAuth: ['resourceName', 'apiKey'],
|
|
171
213
|
docsUrl: 'https://learn.microsoft.com/en-us/azure/ai-services/openai/',
|
|
214
|
+
aiProvider: 'azure-openai',
|
|
215
|
+
defaultModel: 'gpt-4o',
|
|
216
|
+
chatEndpoint: '/openai/deployments/{deployment}/chat/completions',
|
|
172
217
|
},
|
|
173
218
|
{
|
|
174
219
|
name: 'cloudflare-workers-ai',
|
|
@@ -178,6 +223,9 @@ export const presetRegistry = [
|
|
|
178
223
|
category: 'ai',
|
|
179
224
|
requiredAuth: ['accountId', 'apiToken'],
|
|
180
225
|
docsUrl: 'https://developers.cloudflare.com/workers-ai/',
|
|
226
|
+
aiProvider: 'cloudflare-workers-ai',
|
|
227
|
+
defaultModel: '@cf/meta/llama-3-8b-instruct',
|
|
228
|
+
chatEndpoint: '/run/{model}',
|
|
181
229
|
},
|
|
182
230
|
{
|
|
183
231
|
name: 'aws',
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
import type { ClientOptionsWithAI } from '../types/ai-client.js';
|
|
2
3
|
export interface ReplicatePresetOptions {
|
|
3
4
|
apiKey: string;
|
|
5
|
+
model?: string;
|
|
4
6
|
}
|
|
5
|
-
export declare function replicate(options: ReplicatePresetOptions): ClientOptions;
|
|
7
|
+
export declare function replicate(options: ReplicatePresetOptions): ClientOptions & ClientOptionsWithAI;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export function replicate(options) {
|
|
2
|
+
const _aiConfig = {
|
|
3
|
+
provider: 'replicate',
|
|
4
|
+
apiKey: options.apiKey,
|
|
5
|
+
model: options.model ?? 'meta/llama-2-70b-chat',
|
|
6
|
+
memory: { maxPairs: 12 },
|
|
7
|
+
};
|
|
2
8
|
return {
|
|
3
9
|
baseUrl: 'https://api.replicate.com/v1',
|
|
4
10
|
headers: {
|
|
@@ -11,6 +17,7 @@ export function replicate(options) {
|
|
|
11
17
|
backoff: 'exponential',
|
|
12
18
|
delay: 2000,
|
|
13
19
|
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
14
|
-
}
|
|
20
|
+
},
|
|
21
|
+
_aiConfig,
|
|
15
22
|
};
|
|
16
23
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
import type { ClientOptionsWithAI } from '../types/ai-client.js';
|
|
2
3
|
export interface TogetherPresetOptions {
|
|
3
4
|
apiKey: string;
|
|
5
|
+
model?: string;
|
|
4
6
|
}
|
|
5
|
-
export declare function together(options: TogetherPresetOptions): ClientOptions;
|
|
7
|
+
export declare function together(options: TogetherPresetOptions): ClientOptions & ClientOptionsWithAI;
|
package/dist/presets/together.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export function together(options) {
|
|
2
|
+
const _aiConfig = {
|
|
3
|
+
provider: 'together',
|
|
4
|
+
apiKey: options.apiKey,
|
|
5
|
+
model: options.model ?? 'meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8',
|
|
6
|
+
memory: { maxPairs: 12 },
|
|
7
|
+
};
|
|
2
8
|
return {
|
|
3
9
|
baseUrl: 'https://api.together.xyz/v1',
|
|
4
10
|
headers: {
|
|
5
11
|
'Authorization': `Bearer ${options.apiKey}`,
|
|
6
|
-
'Content-Type': 'application/json',
|
|
7
12
|
},
|
|
8
13
|
timeout: 5 * 60 * 1000,
|
|
9
14
|
retry: {
|
|
@@ -11,6 +16,7 @@ export function together(options) {
|
|
|
11
16
|
backoff: 'exponential',
|
|
12
17
|
delay: 1000,
|
|
13
18
|
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
14
|
-
}
|
|
19
|
+
},
|
|
20
|
+
_aiConfig,
|
|
15
21
|
};
|
|
16
22
|
}
|
package/dist/presets/xai.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
import type { ClientOptionsWithAI } from '../types/ai-client.js';
|
|
2
3
|
export interface XAIPresetOptions {
|
|
3
4
|
apiKey: string;
|
|
5
|
+
model?: string;
|
|
4
6
|
}
|
|
5
|
-
export declare function xai(options: XAIPresetOptions): ClientOptions;
|
|
7
|
+
export declare function xai(options: XAIPresetOptions): ClientOptions & ClientOptionsWithAI;
|
|
6
8
|
export declare const grok: typeof xai;
|
package/dist/presets/xai.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export function xai(options) {
|
|
2
|
+
const _aiConfig = {
|
|
3
|
+
provider: 'xai',
|
|
4
|
+
apiKey: options.apiKey,
|
|
5
|
+
model: options.model ?? 'grok-4.1',
|
|
6
|
+
memory: { maxPairs: 12 },
|
|
7
|
+
};
|
|
2
8
|
return {
|
|
3
9
|
baseUrl: 'https://api.x.ai/v1',
|
|
4
10
|
headers: {
|
|
5
11
|
'Authorization': `Bearer ${options.apiKey}`,
|
|
6
|
-
'Content-Type': 'application/json',
|
|
7
12
|
},
|
|
8
13
|
timeout: 5 * 60 * 1000,
|
|
9
14
|
retry: {
|
|
@@ -11,7 +16,8 @@ export function xai(options) {
|
|
|
11
16
|
backoff: 'exponential',
|
|
12
17
|
delay: 1000,
|
|
13
18
|
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
14
|
-
}
|
|
19
|
+
},
|
|
20
|
+
_aiConfig,
|
|
15
21
|
};
|
|
16
22
|
}
|
|
17
23
|
export const grok = xai;
|
package/dist/scrape/spider.js
CHANGED
|
@@ -86,7 +86,7 @@ export class Spider {
|
|
|
86
86
|
pendingCount = 0;
|
|
87
87
|
constructor(options = {}) {
|
|
88
88
|
this.options = {
|
|
89
|
-
maxDepth: options.maxDepth ??
|
|
89
|
+
maxDepth: options.maxDepth ?? 5,
|
|
90
90
|
maxPages: options.maxPages ?? 100,
|
|
91
91
|
sameDomain: options.sameDomain ?? true,
|
|
92
92
|
concurrency: options.concurrency ?? 5,
|
package/dist/transport/undici.js
CHANGED
|
@@ -215,8 +215,17 @@ export class UndiciTransport {
|
|
|
215
215
|
const uploadTotal = contentLengthHeader ? parseInt(contentLengthHeader, 10) : undefined;
|
|
216
216
|
let currentUrl;
|
|
217
217
|
if (this.baseUrl) {
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
if (req.url.startsWith(this.baseUrl)) {
|
|
219
|
+
currentUrl = req.url;
|
|
220
|
+
}
|
|
221
|
+
else if (req.url.startsWith('http://') || req.url.startsWith('https://')) {
|
|
222
|
+
currentUrl = req.url;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const base = this.baseUrl.endsWith('/') ? this.baseUrl.slice(0, -1) : this.baseUrl;
|
|
226
|
+
const path = req.url.startsWith('/') ? req.url : '/' + req.url;
|
|
227
|
+
currentUrl = base + path;
|
|
228
|
+
}
|
|
220
229
|
}
|
|
221
230
|
else {
|
|
222
231
|
currentUrl = req.url;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AIResponse, AIStream, ChatMessage, AIProvider } from './ai.js';
|
|
2
|
+
export interface AIMemoryConfig {
|
|
3
|
+
maxPairs?: number;
|
|
4
|
+
systemPrompt?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PresetAIConfig {
|
|
7
|
+
provider: AIProvider;
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
model: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
memory?: AIMemoryConfig;
|
|
12
|
+
organization?: string;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
resourceName?: string;
|
|
15
|
+
deploymentName?: string;
|
|
16
|
+
apiVersion?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ClientAI {
|
|
19
|
+
chat(prompt: string): Promise<AIResponse>;
|
|
20
|
+
chatStream(prompt: string): Promise<AIStream>;
|
|
21
|
+
prompt(prompt: string): Promise<AIResponse>;
|
|
22
|
+
promptStream(prompt: string): Promise<AIStream>;
|
|
23
|
+
clearMemory(): void;
|
|
24
|
+
getMemory(): readonly ChatMessage[];
|
|
25
|
+
setMemoryConfig(config: Partial<AIMemoryConfig>): void;
|
|
26
|
+
getMemoryConfig(): AIMemoryConfig;
|
|
27
|
+
readonly provider: AIProvider;
|
|
28
|
+
readonly model: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ClientOptionsWithAI {
|
|
31
|
+
_aiConfig?: PresetAIConfig;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/ai.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type AIProvider = 'openai' | 'anthropic' | 'google' | 'replicate' | 'huggingface' | 'ollama' | 'custom';
|
|
1
|
+
export type AIProvider = 'openai' | 'anthropic' | 'google' | 'replicate' | 'huggingface' | 'ollama' | 'groq' | 'mistral' | 'cohere' | 'together' | 'perplexity' | 'deepseek' | 'fireworks' | 'xai' | 'azure-openai' | 'cloudflare-workers-ai' | 'custom';
|
|
2
2
|
export type MessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
3
3
|
export interface ChatMessage {
|
|
4
4
|
role: MessageRole;
|
package/dist/utils/colors.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const magenta: (s: string | number) => string;
|
|
|
9
9
|
export declare const cyan: (s: string | number) => string;
|
|
10
10
|
export declare const white: (s: string | number) => string;
|
|
11
11
|
export declare const gray: (s: string | number) => string;
|
|
12
|
+
export declare const orange: (s: string | number) => string;
|
|
12
13
|
export declare const bgBlack: (s: string | number) => string;
|
|
13
14
|
export declare const bgRed: (s: string | number) => string;
|
|
14
15
|
export declare const bgGreen: (s: string | number) => string;
|
|
@@ -29,6 +30,7 @@ declare const colors: {
|
|
|
29
30
|
cyan: (s: string | number) => string;
|
|
30
31
|
white: (s: string | number) => string;
|
|
31
32
|
gray: (s: string | number) => string;
|
|
33
|
+
orange: (s: string | number) => string;
|
|
32
34
|
bgBlack: (s: string | number) => string;
|
|
33
35
|
bgRed: (s: string | number) => string;
|
|
34
36
|
bgGreen: (s: string | number) => string;
|
package/dist/utils/colors.js
CHANGED
|
@@ -33,6 +33,9 @@ export const magenta = code(35, 39);
|
|
|
33
33
|
export const cyan = code(36, 39);
|
|
34
34
|
export const white = code(37, 39);
|
|
35
35
|
export const gray = code(90, 39);
|
|
36
|
+
export const orange = hasColors
|
|
37
|
+
? (s) => `\x1b[38;5;208m${String(s)}\x1b[39m`
|
|
38
|
+
: (s) => String(s);
|
|
36
39
|
export const bgBlack = code(40, 49);
|
|
37
40
|
export const bgRed = code(41, 49);
|
|
38
41
|
export const bgGreen = code(42, 49);
|
|
@@ -53,6 +56,7 @@ const colors = {
|
|
|
53
56
|
cyan,
|
|
54
57
|
white,
|
|
55
58
|
gray,
|
|
59
|
+
orange,
|
|
56
60
|
bgBlack,
|
|
57
61
|
bgRed,
|
|
58
62
|
bgGreen,
|