@agentstats/sdk 0.5.0 → 0.5.1
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 +10 -0
- package/dist/bots.cjs +1022 -0
- package/dist/bots.d.cts +265 -0
- package/dist/bots.d.ts +265 -0
- package/dist/bots.js +1010 -0
- package/dist/browser.iife.js +1 -1
- package/dist/index.cjs +3 -6
- package/dist/index.d.cts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +3 -6
- package/dist/lite.iife.js +1 -1
- package/dist/server.cjs +293 -204
- package/dist/server.d.cts +76 -18
- package/dist/server.d.ts +76 -18
- package/dist/server.js +293 -204
- package/package.json +21 -12
package/dist/bots.d.cts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agentstats/sdk/bots`: the bot catalogue behind `detectBot()`, for code that classifies user agents
|
|
3
|
+
* itself (log pipelines, dashboards): the same patterns, products and categories the server SDK uses.
|
|
4
|
+
* CURATED is the hand-checked list, matched first; CATCH_ALL the generic patterns ("bot", "crawler"…)
|
|
5
|
+
* that send unknown bots on to be classified.
|
|
6
|
+
*/
|
|
7
|
+
export type BotCategory = 'training' | 'search' | 'assistant' | 'agent' | 'search_engine' | 'other';
|
|
8
|
+
/** Categories that count as "AI traffic". Search engines and other bots are shown separately. */
|
|
9
|
+
export declare const AI_CATEGORIES: BotCategory[];
|
|
10
|
+
export declare const isAiCategory: (c: string) => boolean;
|
|
11
|
+
export interface BotProduct {
|
|
12
|
+
name: string;
|
|
13
|
+
operator: string;
|
|
14
|
+
}
|
|
15
|
+
/** Products group several bots from one vendor ("ChatGPT" = GPTBot + OAI-SearchBot + ChatGPT-User + ChatGPT agent). */
|
|
16
|
+
export declare const BOT_PRODUCTS: {
|
|
17
|
+
chatgpt: {
|
|
18
|
+
name: string;
|
|
19
|
+
operator: string;
|
|
20
|
+
};
|
|
21
|
+
claude: {
|
|
22
|
+
name: string;
|
|
23
|
+
operator: string;
|
|
24
|
+
};
|
|
25
|
+
perplexity: {
|
|
26
|
+
name: string;
|
|
27
|
+
operator: string;
|
|
28
|
+
};
|
|
29
|
+
gemini: {
|
|
30
|
+
name: string;
|
|
31
|
+
operator: string;
|
|
32
|
+
};
|
|
33
|
+
copilot: {
|
|
34
|
+
name: string;
|
|
35
|
+
operator: string;
|
|
36
|
+
};
|
|
37
|
+
meta: {
|
|
38
|
+
name: string;
|
|
39
|
+
operator: string;
|
|
40
|
+
};
|
|
41
|
+
apple: {
|
|
42
|
+
name: string;
|
|
43
|
+
operator: string;
|
|
44
|
+
};
|
|
45
|
+
amazon: {
|
|
46
|
+
name: string;
|
|
47
|
+
operator: string;
|
|
48
|
+
};
|
|
49
|
+
mistral: {
|
|
50
|
+
name: string;
|
|
51
|
+
operator: string;
|
|
52
|
+
};
|
|
53
|
+
deepseek: {
|
|
54
|
+
name: string;
|
|
55
|
+
operator: string;
|
|
56
|
+
};
|
|
57
|
+
bytedance: {
|
|
58
|
+
name: string;
|
|
59
|
+
operator: string;
|
|
60
|
+
};
|
|
61
|
+
xai: {
|
|
62
|
+
name: string;
|
|
63
|
+
operator: string;
|
|
64
|
+
};
|
|
65
|
+
duckduckgo: {
|
|
66
|
+
name: string;
|
|
67
|
+
operator: string;
|
|
68
|
+
};
|
|
69
|
+
commoncrawl: {
|
|
70
|
+
name: string;
|
|
71
|
+
operator: string;
|
|
72
|
+
};
|
|
73
|
+
cohere: {
|
|
74
|
+
name: string;
|
|
75
|
+
operator: string;
|
|
76
|
+
};
|
|
77
|
+
you: {
|
|
78
|
+
name: string;
|
|
79
|
+
operator: string;
|
|
80
|
+
};
|
|
81
|
+
qwen: {
|
|
82
|
+
name: string;
|
|
83
|
+
operator: string;
|
|
84
|
+
};
|
|
85
|
+
kimi: {
|
|
86
|
+
name: string;
|
|
87
|
+
operator: string;
|
|
88
|
+
};
|
|
89
|
+
baidu: {
|
|
90
|
+
name: string;
|
|
91
|
+
operator: string;
|
|
92
|
+
};
|
|
93
|
+
yandex: {
|
|
94
|
+
name: string;
|
|
95
|
+
operator: string;
|
|
96
|
+
};
|
|
97
|
+
huawei: {
|
|
98
|
+
name: string;
|
|
99
|
+
operator: string;
|
|
100
|
+
};
|
|
101
|
+
ai2: {
|
|
102
|
+
name: string;
|
|
103
|
+
operator: string;
|
|
104
|
+
};
|
|
105
|
+
brave: {
|
|
106
|
+
name: string;
|
|
107
|
+
operator: string;
|
|
108
|
+
};
|
|
109
|
+
kagi: {
|
|
110
|
+
name: string;
|
|
111
|
+
operator: string;
|
|
112
|
+
};
|
|
113
|
+
phind: {
|
|
114
|
+
name: string;
|
|
115
|
+
operator: string;
|
|
116
|
+
};
|
|
117
|
+
poe: {
|
|
118
|
+
name: string;
|
|
119
|
+
operator: string;
|
|
120
|
+
};
|
|
121
|
+
manus: {
|
|
122
|
+
name: string;
|
|
123
|
+
operator: string;
|
|
124
|
+
};
|
|
125
|
+
ai: {
|
|
126
|
+
name: string;
|
|
127
|
+
operator: string;
|
|
128
|
+
};
|
|
129
|
+
coding: {
|
|
130
|
+
name: string;
|
|
131
|
+
operator: string;
|
|
132
|
+
};
|
|
133
|
+
aidata: {
|
|
134
|
+
name: string;
|
|
135
|
+
operator: string;
|
|
136
|
+
};
|
|
137
|
+
google: {
|
|
138
|
+
name: string;
|
|
139
|
+
operator: string;
|
|
140
|
+
};
|
|
141
|
+
searchengines: {
|
|
142
|
+
name: string;
|
|
143
|
+
operator: string;
|
|
144
|
+
};
|
|
145
|
+
automation: {
|
|
146
|
+
name: string;
|
|
147
|
+
operator: string;
|
|
148
|
+
};
|
|
149
|
+
seo: {
|
|
150
|
+
name: string;
|
|
151
|
+
operator: string;
|
|
152
|
+
};
|
|
153
|
+
social: {
|
|
154
|
+
name: string;
|
|
155
|
+
operator: string;
|
|
156
|
+
};
|
|
157
|
+
monitor: {
|
|
158
|
+
name: string;
|
|
159
|
+
operator: string;
|
|
160
|
+
};
|
|
161
|
+
feeds: {
|
|
162
|
+
name: string;
|
|
163
|
+
operator: string;
|
|
164
|
+
};
|
|
165
|
+
security: {
|
|
166
|
+
name: string;
|
|
167
|
+
operator: string;
|
|
168
|
+
};
|
|
169
|
+
archive: {
|
|
170
|
+
name: string;
|
|
171
|
+
operator: string;
|
|
172
|
+
};
|
|
173
|
+
research: {
|
|
174
|
+
name: string;
|
|
175
|
+
operator: string;
|
|
176
|
+
};
|
|
177
|
+
ads: {
|
|
178
|
+
name: string;
|
|
179
|
+
operator: string;
|
|
180
|
+
};
|
|
181
|
+
tools: {
|
|
182
|
+
name: string;
|
|
183
|
+
operator: string;
|
|
184
|
+
};
|
|
185
|
+
other: {
|
|
186
|
+
name: string;
|
|
187
|
+
operator: string;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
export type BotProductId = keyof typeof BOT_PRODUCTS;
|
|
191
|
+
export interface BotPattern {
|
|
192
|
+
id: string;
|
|
193
|
+
name: string;
|
|
194
|
+
product: BotProductId;
|
|
195
|
+
category: BotCategory;
|
|
196
|
+
/** Matched against the User-Agent header. `null` = only identified another way (signature). */
|
|
197
|
+
pattern: RegExp | null;
|
|
198
|
+
/** Who runs it, when its product groups several vendors ("Other AI bots"). Else the product's operator. */
|
|
199
|
+
operator?: string;
|
|
200
|
+
}
|
|
201
|
+
/** Every bot this SDK recognises, in the order they're tried: the first match wins, catch-alls last. */
|
|
202
|
+
export declare const BOT_PATTERNS: BotPattern[];
|
|
203
|
+
/** The first bot in `list` whose pattern matches `ua` (trimmed, non-empty). Shared with the server's bigger catalogue. */
|
|
204
|
+
export declare function firstMatch(list: BotPattern[], s: string): BotPattern | null;
|
|
205
|
+
/** Identify a bot from its User-Agent. Returns null for (what looks like) a normal browser. */
|
|
206
|
+
export declare function classifyUserAgent(ua: string | null | undefined): BotPattern | null;
|
|
207
|
+
/** Hostnames of AI assistants that send people to websites, and the `utm_source` values they add. */
|
|
208
|
+
export declare const AI_REFERRERS: {
|
|
209
|
+
product: BotProductId;
|
|
210
|
+
hosts: RegExp;
|
|
211
|
+
utm?: RegExp;
|
|
212
|
+
}[];
|
|
213
|
+
/**
|
|
214
|
+
* Which AI assistant sent a human to this page, from the Referer header and/or
|
|
215
|
+
* the landing URL's `utm_source`. Returns the product id, or null.
|
|
216
|
+
*/
|
|
217
|
+
export declare function classifyReferral(referrer: string | null | undefined, url: string | null | undefined): BotProductId | null;
|
|
218
|
+
export interface BotDetection {
|
|
219
|
+
/** Any automated client: AI crawlers and agents, search engines, scripts, monitors, link previews. */
|
|
220
|
+
isBot: boolean;
|
|
221
|
+
/** An AI crawler, assistant fetch or agent (categories training, search, assistant, agent). */
|
|
222
|
+
isAI: boolean;
|
|
223
|
+
/** Stable id, e.g. `gptbot`, `claude-user`, `google-agent`. */
|
|
224
|
+
id: string | null;
|
|
225
|
+
/** Display name, e.g. `GPTBot`. */
|
|
226
|
+
name: string | null;
|
|
227
|
+
category: BotCategory | null;
|
|
228
|
+
/** Product it belongs to, e.g. `ChatGPT`. */
|
|
229
|
+
product: string | null;
|
|
230
|
+
/** Who runs it, e.g. `OpenAI`. */
|
|
231
|
+
operator: string | null;
|
|
232
|
+
/** Loads pages in a real browser, so it runs JavaScript and can call your WebMCP tools. */
|
|
233
|
+
browser: boolean;
|
|
234
|
+
/** Sent Web Bot Auth signature headers. Not checked here: the dashboard verifies the signature. */
|
|
235
|
+
signed: boolean;
|
|
236
|
+
/** For people (not bots): the AI assistant that sent them here, e.g. `ChatGPT`, from the Referer or utm_source. */
|
|
237
|
+
referral: string | null;
|
|
238
|
+
}
|
|
239
|
+
type HeaderSource = {
|
|
240
|
+
get: (name: string) => string | null;
|
|
241
|
+
} | Record<string, string | string[] | undefined>;
|
|
242
|
+
/** A fetch `Request`, a `Headers` object, a Node `IncomingMessage`, or anything with `headers` (and optionally `url`). */
|
|
243
|
+
export type DetectInput = Request | Headers | {
|
|
244
|
+
headers: HeaderSource;
|
|
245
|
+
url?: string;
|
|
246
|
+
} | null | undefined;
|
|
247
|
+
/**
|
|
248
|
+
* What kind of client sent this request, from its User-Agent, Web Bot Auth headers and referrer.
|
|
249
|
+
* Synchronous and dependency-free, so it works in any server, middleware or edge function.
|
|
250
|
+
*
|
|
251
|
+
* It reports who the client *claims* to be. Anyone can send `User-Agent: GPTBot`, so don't
|
|
252
|
+
* use it to grant access; your dashboard verifies each hit against the vendor's IP ranges,
|
|
253
|
+
* reverse DNS and signatures.
|
|
254
|
+
*
|
|
255
|
+
* detectBot(request) // fetch Request (Next, SvelteKit, Astro, Hono, Workers…)
|
|
256
|
+
* detectBot(await headers()) // Next.js server components
|
|
257
|
+
* detectBot(req) // Node / Express IncomingMessage
|
|
258
|
+
*/
|
|
259
|
+
export declare function detectBot(input: DetectInput): BotDetection;
|
|
260
|
+
/** `detectBot` over a header getter (used by the server adapters). */
|
|
261
|
+
export declare function detectFromHeaders(header: (name: string) => string | null | undefined, url: string | null): BotDetection;
|
|
262
|
+
export declare const CURATED: BotPattern[];
|
|
263
|
+
/** Matched last, after the generated lists: anything that still calls itself a bot, and no User-Agent at all. */
|
|
264
|
+
export declare const CATCH_ALL: BotPattern[];
|
|
265
|
+
export {};
|
package/dist/bots.d.ts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agentstats/sdk/bots`: the bot catalogue behind `detectBot()`, for code that classifies user agents
|
|
3
|
+
* itself (log pipelines, dashboards): the same patterns, products and categories the server SDK uses.
|
|
4
|
+
* CURATED is the hand-checked list, matched first; CATCH_ALL the generic patterns ("bot", "crawler"…)
|
|
5
|
+
* that send unknown bots on to be classified.
|
|
6
|
+
*/
|
|
7
|
+
export type BotCategory = 'training' | 'search' | 'assistant' | 'agent' | 'search_engine' | 'other';
|
|
8
|
+
/** Categories that count as "AI traffic". Search engines and other bots are shown separately. */
|
|
9
|
+
export declare const AI_CATEGORIES: BotCategory[];
|
|
10
|
+
export declare const isAiCategory: (c: string) => boolean;
|
|
11
|
+
export interface BotProduct {
|
|
12
|
+
name: string;
|
|
13
|
+
operator: string;
|
|
14
|
+
}
|
|
15
|
+
/** Products group several bots from one vendor ("ChatGPT" = GPTBot + OAI-SearchBot + ChatGPT-User + ChatGPT agent). */
|
|
16
|
+
export declare const BOT_PRODUCTS: {
|
|
17
|
+
chatgpt: {
|
|
18
|
+
name: string;
|
|
19
|
+
operator: string;
|
|
20
|
+
};
|
|
21
|
+
claude: {
|
|
22
|
+
name: string;
|
|
23
|
+
operator: string;
|
|
24
|
+
};
|
|
25
|
+
perplexity: {
|
|
26
|
+
name: string;
|
|
27
|
+
operator: string;
|
|
28
|
+
};
|
|
29
|
+
gemini: {
|
|
30
|
+
name: string;
|
|
31
|
+
operator: string;
|
|
32
|
+
};
|
|
33
|
+
copilot: {
|
|
34
|
+
name: string;
|
|
35
|
+
operator: string;
|
|
36
|
+
};
|
|
37
|
+
meta: {
|
|
38
|
+
name: string;
|
|
39
|
+
operator: string;
|
|
40
|
+
};
|
|
41
|
+
apple: {
|
|
42
|
+
name: string;
|
|
43
|
+
operator: string;
|
|
44
|
+
};
|
|
45
|
+
amazon: {
|
|
46
|
+
name: string;
|
|
47
|
+
operator: string;
|
|
48
|
+
};
|
|
49
|
+
mistral: {
|
|
50
|
+
name: string;
|
|
51
|
+
operator: string;
|
|
52
|
+
};
|
|
53
|
+
deepseek: {
|
|
54
|
+
name: string;
|
|
55
|
+
operator: string;
|
|
56
|
+
};
|
|
57
|
+
bytedance: {
|
|
58
|
+
name: string;
|
|
59
|
+
operator: string;
|
|
60
|
+
};
|
|
61
|
+
xai: {
|
|
62
|
+
name: string;
|
|
63
|
+
operator: string;
|
|
64
|
+
};
|
|
65
|
+
duckduckgo: {
|
|
66
|
+
name: string;
|
|
67
|
+
operator: string;
|
|
68
|
+
};
|
|
69
|
+
commoncrawl: {
|
|
70
|
+
name: string;
|
|
71
|
+
operator: string;
|
|
72
|
+
};
|
|
73
|
+
cohere: {
|
|
74
|
+
name: string;
|
|
75
|
+
operator: string;
|
|
76
|
+
};
|
|
77
|
+
you: {
|
|
78
|
+
name: string;
|
|
79
|
+
operator: string;
|
|
80
|
+
};
|
|
81
|
+
qwen: {
|
|
82
|
+
name: string;
|
|
83
|
+
operator: string;
|
|
84
|
+
};
|
|
85
|
+
kimi: {
|
|
86
|
+
name: string;
|
|
87
|
+
operator: string;
|
|
88
|
+
};
|
|
89
|
+
baidu: {
|
|
90
|
+
name: string;
|
|
91
|
+
operator: string;
|
|
92
|
+
};
|
|
93
|
+
yandex: {
|
|
94
|
+
name: string;
|
|
95
|
+
operator: string;
|
|
96
|
+
};
|
|
97
|
+
huawei: {
|
|
98
|
+
name: string;
|
|
99
|
+
operator: string;
|
|
100
|
+
};
|
|
101
|
+
ai2: {
|
|
102
|
+
name: string;
|
|
103
|
+
operator: string;
|
|
104
|
+
};
|
|
105
|
+
brave: {
|
|
106
|
+
name: string;
|
|
107
|
+
operator: string;
|
|
108
|
+
};
|
|
109
|
+
kagi: {
|
|
110
|
+
name: string;
|
|
111
|
+
operator: string;
|
|
112
|
+
};
|
|
113
|
+
phind: {
|
|
114
|
+
name: string;
|
|
115
|
+
operator: string;
|
|
116
|
+
};
|
|
117
|
+
poe: {
|
|
118
|
+
name: string;
|
|
119
|
+
operator: string;
|
|
120
|
+
};
|
|
121
|
+
manus: {
|
|
122
|
+
name: string;
|
|
123
|
+
operator: string;
|
|
124
|
+
};
|
|
125
|
+
ai: {
|
|
126
|
+
name: string;
|
|
127
|
+
operator: string;
|
|
128
|
+
};
|
|
129
|
+
coding: {
|
|
130
|
+
name: string;
|
|
131
|
+
operator: string;
|
|
132
|
+
};
|
|
133
|
+
aidata: {
|
|
134
|
+
name: string;
|
|
135
|
+
operator: string;
|
|
136
|
+
};
|
|
137
|
+
google: {
|
|
138
|
+
name: string;
|
|
139
|
+
operator: string;
|
|
140
|
+
};
|
|
141
|
+
searchengines: {
|
|
142
|
+
name: string;
|
|
143
|
+
operator: string;
|
|
144
|
+
};
|
|
145
|
+
automation: {
|
|
146
|
+
name: string;
|
|
147
|
+
operator: string;
|
|
148
|
+
};
|
|
149
|
+
seo: {
|
|
150
|
+
name: string;
|
|
151
|
+
operator: string;
|
|
152
|
+
};
|
|
153
|
+
social: {
|
|
154
|
+
name: string;
|
|
155
|
+
operator: string;
|
|
156
|
+
};
|
|
157
|
+
monitor: {
|
|
158
|
+
name: string;
|
|
159
|
+
operator: string;
|
|
160
|
+
};
|
|
161
|
+
feeds: {
|
|
162
|
+
name: string;
|
|
163
|
+
operator: string;
|
|
164
|
+
};
|
|
165
|
+
security: {
|
|
166
|
+
name: string;
|
|
167
|
+
operator: string;
|
|
168
|
+
};
|
|
169
|
+
archive: {
|
|
170
|
+
name: string;
|
|
171
|
+
operator: string;
|
|
172
|
+
};
|
|
173
|
+
research: {
|
|
174
|
+
name: string;
|
|
175
|
+
operator: string;
|
|
176
|
+
};
|
|
177
|
+
ads: {
|
|
178
|
+
name: string;
|
|
179
|
+
operator: string;
|
|
180
|
+
};
|
|
181
|
+
tools: {
|
|
182
|
+
name: string;
|
|
183
|
+
operator: string;
|
|
184
|
+
};
|
|
185
|
+
other: {
|
|
186
|
+
name: string;
|
|
187
|
+
operator: string;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
export type BotProductId = keyof typeof BOT_PRODUCTS;
|
|
191
|
+
export interface BotPattern {
|
|
192
|
+
id: string;
|
|
193
|
+
name: string;
|
|
194
|
+
product: BotProductId;
|
|
195
|
+
category: BotCategory;
|
|
196
|
+
/** Matched against the User-Agent header. `null` = only identified another way (signature). */
|
|
197
|
+
pattern: RegExp | null;
|
|
198
|
+
/** Who runs it, when its product groups several vendors ("Other AI bots"). Else the product's operator. */
|
|
199
|
+
operator?: string;
|
|
200
|
+
}
|
|
201
|
+
/** Every bot this SDK recognises, in the order they're tried: the first match wins, catch-alls last. */
|
|
202
|
+
export declare const BOT_PATTERNS: BotPattern[];
|
|
203
|
+
/** The first bot in `list` whose pattern matches `ua` (trimmed, non-empty). Shared with the server's bigger catalogue. */
|
|
204
|
+
export declare function firstMatch(list: BotPattern[], s: string): BotPattern | null;
|
|
205
|
+
/** Identify a bot from its User-Agent. Returns null for (what looks like) a normal browser. */
|
|
206
|
+
export declare function classifyUserAgent(ua: string | null | undefined): BotPattern | null;
|
|
207
|
+
/** Hostnames of AI assistants that send people to websites, and the `utm_source` values they add. */
|
|
208
|
+
export declare const AI_REFERRERS: {
|
|
209
|
+
product: BotProductId;
|
|
210
|
+
hosts: RegExp;
|
|
211
|
+
utm?: RegExp;
|
|
212
|
+
}[];
|
|
213
|
+
/**
|
|
214
|
+
* Which AI assistant sent a human to this page, from the Referer header and/or
|
|
215
|
+
* the landing URL's `utm_source`. Returns the product id, or null.
|
|
216
|
+
*/
|
|
217
|
+
export declare function classifyReferral(referrer: string | null | undefined, url: string | null | undefined): BotProductId | null;
|
|
218
|
+
export interface BotDetection {
|
|
219
|
+
/** Any automated client: AI crawlers and agents, search engines, scripts, monitors, link previews. */
|
|
220
|
+
isBot: boolean;
|
|
221
|
+
/** An AI crawler, assistant fetch or agent (categories training, search, assistant, agent). */
|
|
222
|
+
isAI: boolean;
|
|
223
|
+
/** Stable id, e.g. `gptbot`, `claude-user`, `google-agent`. */
|
|
224
|
+
id: string | null;
|
|
225
|
+
/** Display name, e.g. `GPTBot`. */
|
|
226
|
+
name: string | null;
|
|
227
|
+
category: BotCategory | null;
|
|
228
|
+
/** Product it belongs to, e.g. `ChatGPT`. */
|
|
229
|
+
product: string | null;
|
|
230
|
+
/** Who runs it, e.g. `OpenAI`. */
|
|
231
|
+
operator: string | null;
|
|
232
|
+
/** Loads pages in a real browser, so it runs JavaScript and can call your WebMCP tools. */
|
|
233
|
+
browser: boolean;
|
|
234
|
+
/** Sent Web Bot Auth signature headers. Not checked here: the dashboard verifies the signature. */
|
|
235
|
+
signed: boolean;
|
|
236
|
+
/** For people (not bots): the AI assistant that sent them here, e.g. `ChatGPT`, from the Referer or utm_source. */
|
|
237
|
+
referral: string | null;
|
|
238
|
+
}
|
|
239
|
+
type HeaderSource = {
|
|
240
|
+
get: (name: string) => string | null;
|
|
241
|
+
} | Record<string, string | string[] | undefined>;
|
|
242
|
+
/** A fetch `Request`, a `Headers` object, a Node `IncomingMessage`, or anything with `headers` (and optionally `url`). */
|
|
243
|
+
export type DetectInput = Request | Headers | {
|
|
244
|
+
headers: HeaderSource;
|
|
245
|
+
url?: string;
|
|
246
|
+
} | null | undefined;
|
|
247
|
+
/**
|
|
248
|
+
* What kind of client sent this request, from its User-Agent, Web Bot Auth headers and referrer.
|
|
249
|
+
* Synchronous and dependency-free, so it works in any server, middleware or edge function.
|
|
250
|
+
*
|
|
251
|
+
* It reports who the client *claims* to be. Anyone can send `User-Agent: GPTBot`, so don't
|
|
252
|
+
* use it to grant access; your dashboard verifies each hit against the vendor's IP ranges,
|
|
253
|
+
* reverse DNS and signatures.
|
|
254
|
+
*
|
|
255
|
+
* detectBot(request) // fetch Request (Next, SvelteKit, Astro, Hono, Workers…)
|
|
256
|
+
* detectBot(await headers()) // Next.js server components
|
|
257
|
+
* detectBot(req) // Node / Express IncomingMessage
|
|
258
|
+
*/
|
|
259
|
+
export declare function detectBot(input: DetectInput): BotDetection;
|
|
260
|
+
/** `detectBot` over a header getter (used by the server adapters). */
|
|
261
|
+
export declare function detectFromHeaders(header: (name: string) => string | null | undefined, url: string | null): BotDetection;
|
|
262
|
+
export declare const CURATED: BotPattern[];
|
|
263
|
+
/** Matched last, after the generated lists: anything that still calls itself a bot, and no User-Agent at all. */
|
|
264
|
+
export declare const CATCH_ALL: BotPattern[];
|
|
265
|
+
export {};
|