@knownagents/sdk 1.10.0 → 2.0.0
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 +82 -43
- package/dist/KnownAgents.d.ts +74 -0
- package/dist/KnownAgents.d.ts.map +1 -0
- package/dist/KnownAgents.js +247 -0
- package/dist/commerce.d.ts +28 -0
- package/dist/commerce.d.ts.map +1 -0
- package/dist/commerce.js +51 -0
- package/dist/headers.d.ts +6 -0
- package/dist/headers.d.ts.map +1 -0
- package/dist/headers.js +54 -0
- package/dist/index.d.ts +2 -153
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -171
- package/dist/paths.d.ts +2 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +72 -0
- package/dist/types.d.ts +133 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/package.json +14 -1
- package/src/KnownAgents.ts +324 -0
- package/src/commerce.ts +68 -0
- package/src/headers.ts +56 -0
- package/src/index.ts +10 -263
- package/src/paths.ts +72 -0
- package/src/types.ts +139 -0
- package/tsconfig.json +0 -16
package/dist/headers.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFilteredHeaders = getFilteredHeaders;
|
|
4
|
+
exports.getIsMCPCall = getIsMCPCall;
|
|
5
|
+
exports.getIsUCPCall = getIsUCPCall;
|
|
6
|
+
exports.getIsProbablyACPCall = getIsProbablyACPCall;
|
|
7
|
+
const filteredHeaderNames = [
|
|
8
|
+
"authorization",
|
|
9
|
+
"proxy-authorization",
|
|
10
|
+
"cookie",
|
|
11
|
+
"set-cookie",
|
|
12
|
+
"x-api-key",
|
|
13
|
+
"api-key",
|
|
14
|
+
"apikey",
|
|
15
|
+
"x-auth-token",
|
|
16
|
+
"x-access-token",
|
|
17
|
+
"x-id-token",
|
|
18
|
+
"x-refresh-token",
|
|
19
|
+
"x-session-token",
|
|
20
|
+
"session-token",
|
|
21
|
+
"csrf-token",
|
|
22
|
+
"x-csrf-token",
|
|
23
|
+
"xsrf-token",
|
|
24
|
+
"x-xsrf-token",
|
|
25
|
+
"x-amz-security-token",
|
|
26
|
+
"x-goog-api-key",
|
|
27
|
+
"x-client-secret",
|
|
28
|
+
"client-secret",
|
|
29
|
+
"private-token"
|
|
30
|
+
];
|
|
31
|
+
function getFilteredHeaders(headers) {
|
|
32
|
+
const filteredHeaders = { ...headers };
|
|
33
|
+
Object.keys(filteredHeaders).forEach((key) => {
|
|
34
|
+
if (filteredHeaderNames.includes(key.toLowerCase())) {
|
|
35
|
+
delete filteredHeaders[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return filteredHeaders;
|
|
39
|
+
}
|
|
40
|
+
function getIsMCPCall(headers) {
|
|
41
|
+
return Object.keys(headers).some((key) => {
|
|
42
|
+
return key.toLowerCase() === "mcp-protocol-version";
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function getIsUCPCall(headers) {
|
|
46
|
+
return Object.keys(headers).some((key) => {
|
|
47
|
+
return key.toLowerCase() === "ucp-agent";
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function getIsProbablyACPCall(headers) {
|
|
51
|
+
return Object.keys(headers).some((key) => {
|
|
52
|
+
return key.toLowerCase() === "api-version";
|
|
53
|
+
});
|
|
54
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,154 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* A framework-agnostic HTTP request interface.
|
|
4
|
-
* Used as a convenience type for single-request methods.
|
|
5
|
-
*/
|
|
6
|
-
export interface Request {
|
|
7
|
-
/** The URL path and query string (e.g. "/about?foo=bar") */
|
|
8
|
-
path: string;
|
|
9
|
-
/** The HTTP method (e.g. "GET", "POST") */
|
|
10
|
-
method: string;
|
|
11
|
-
/** The HTTP request headers */
|
|
12
|
-
headers: Record<string, string | string[] | undefined>;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* A minimal HTTP response interface.
|
|
16
|
-
* Used as a convenience type for single-request methods.
|
|
17
|
-
*/
|
|
18
|
-
export interface Response {
|
|
19
|
-
/** The HTTP response status code (e.g. 200, 404) */
|
|
20
|
-
statusCode: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* A visit tracking request for the Known Agents API.
|
|
24
|
-
* Used for batch visit tracking with `trackVisits()`.
|
|
25
|
-
*/
|
|
26
|
-
export interface VisitRequest {
|
|
27
|
-
/** The URL path of the request (e.g. "/about?foo=bar") */
|
|
28
|
-
request_path: string;
|
|
29
|
-
/** The HTTP method (e.g. "GET", "POST") */
|
|
30
|
-
request_method: string;
|
|
31
|
-
/** The HTTP request headers */
|
|
32
|
-
request_headers: Record<string, string | string[] | undefined>;
|
|
33
|
-
/** The HTTP response status code (e.g. 200, 404) */
|
|
34
|
-
response_status_code?: number;
|
|
35
|
-
/** The HTTP response headers */
|
|
36
|
-
response_headers?: Record<string, string | string[] | undefined>;
|
|
37
|
-
/** The response duration in milliseconds */
|
|
38
|
-
response_duration_in_milliseconds?: number;
|
|
39
|
-
/** The timestamp when the visit occurred (ISO 8601 format) */
|
|
40
|
-
created?: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* An agent identification request for the Known Agents API.
|
|
44
|
-
* Used for batch agent identification with `identifyAgents()`.
|
|
45
|
-
*/
|
|
46
|
-
export interface IdentificationRequest {
|
|
47
|
-
/** An identifier that will be echoed back in the response to match requests with results */
|
|
48
|
-
id?: string;
|
|
49
|
-
/** The HTTP request headers */
|
|
50
|
-
request_headers: Record<string, string | string[] | undefined>;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The result of an agent identification request.
|
|
54
|
-
*/
|
|
55
|
-
export interface IdentificationResult {
|
|
56
|
-
/** The identifier from the request (if provided) */
|
|
57
|
-
id?: string;
|
|
58
|
-
/**
|
|
59
|
-
* The identification result:
|
|
60
|
-
* - "verified": The agent was identified and verified
|
|
61
|
-
* - "verification_failed": The agent was identified but failed verification (spoofed)
|
|
62
|
-
* - "unknown_agent": The request is from an unrecognized agent or human
|
|
63
|
-
* - "not_verifiable": The agent was identified but cannot be verified
|
|
64
|
-
*/
|
|
65
|
-
result: "verified" | "verification_failed" | "unknown_agent" | "not_verifiable";
|
|
66
|
-
/** The unique ID of the identified agent */
|
|
67
|
-
agent_id?: string;
|
|
68
|
-
/** The name of the identified agent (e.g. "Googlebot") */
|
|
69
|
-
agent_token?: string;
|
|
70
|
-
/** The documentation URL for the identified agent */
|
|
71
|
-
agent_url?: string;
|
|
72
|
-
/** The type of the identified agent (e.g. "AI Agent", "Search Engine Crawler") */
|
|
73
|
-
agent_type_name?: string;
|
|
74
|
-
/** The company behind the identified agent (e.g. "Google") */
|
|
75
|
-
operator_name?: string;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Agent types that can be controlled with robots.txt rules.
|
|
79
|
-
*/
|
|
80
|
-
export declare enum AgentType {
|
|
81
|
-
AIAgent = "AI Agent",
|
|
82
|
-
AIAssistant = "AI Assistant",
|
|
83
|
-
AICodingAgent = "AI Coding Agent",
|
|
84
|
-
AIDataProvider = "AI Data Provider",
|
|
85
|
-
AIDataScraper = "AI Data Scraper",
|
|
86
|
-
AISearchCrawler = "AI Search Crawler",
|
|
87
|
-
Archiver = "Archiver",
|
|
88
|
-
DeveloperHelper = "Developer Helper",
|
|
89
|
-
Fetcher = "Fetcher",
|
|
90
|
-
HeadlessAgent = "Headless Agent",
|
|
91
|
-
IntelligenceGatherer = "Intelligence Gatherer",
|
|
92
|
-
Scraper = "Scraper",
|
|
93
|
-
SEOCrawler = "SEO Crawler",
|
|
94
|
-
SearchEngineCrawler = "Search Engine Crawler",
|
|
95
|
-
SecurityScanner = "Security Scanner",
|
|
96
|
-
UndocumentedAIAgent = "Undocumented AI Agent"
|
|
97
|
-
}
|
|
98
|
-
export declare class KnownAgents {
|
|
99
|
-
private readonly accessToken;
|
|
100
|
-
/**
|
|
101
|
-
* Creates a new instance of the Known Agents client.
|
|
102
|
-
*
|
|
103
|
-
* @param accessToken - Your project's access token.
|
|
104
|
-
*/
|
|
105
|
-
constructor(accessToken: string);
|
|
106
|
-
/**
|
|
107
|
-
* Tracks a single agent visit for analytics.
|
|
108
|
-
* This method is non-blocking and handles errors internally.
|
|
109
|
-
*
|
|
110
|
-
* @param request - The incoming HTTP request (Request or Node.js IncomingMessage).
|
|
111
|
-
* @param response - The outgoing HTTP response (optional).
|
|
112
|
-
* @param responseDurationInMilliseconds - The time taken to process the request in milliseconds (optional).
|
|
113
|
-
*/
|
|
114
|
-
trackVisit(request: Request | IncomingMessage, response?: Response | ServerResponse, responseDurationInMilliseconds?: number): void;
|
|
115
|
-
/**
|
|
116
|
-
* Tracks multiple agent visits in a batch for analytics.
|
|
117
|
-
* This method is non-blocking and handles errors internally.
|
|
118
|
-
* Recommended for high-traffic websites - batch visits and send periodically (e.g. every 30 seconds).
|
|
119
|
-
*
|
|
120
|
-
* @param visits - An array of visit tracking requests.
|
|
121
|
-
*/
|
|
122
|
-
trackVisits(visits: VisitRequest[]): void;
|
|
123
|
-
/**
|
|
124
|
-
* Generates a robots.txt file that disallows the specified agent types.
|
|
125
|
-
* The generated file stays up-to-date with all current and future agents in the specified categories.
|
|
126
|
-
* Cache and serve the result at your website's `/robots.txt` endpoint.
|
|
127
|
-
*
|
|
128
|
-
* @param agentTypes - An array of agent types to disallow.
|
|
129
|
-
* @param disallow - The path to disallow (default: "/" for all paths).
|
|
130
|
-
* @returns A promise that resolves to the generated robots.txt content as a string.
|
|
131
|
-
* @throws {Error} If the API call fails or returns a non-200 status.
|
|
132
|
-
*/
|
|
133
|
-
generateRobotsTXT(agentTypes: AgentType[], disallow?: string): Promise<string>;
|
|
134
|
-
/**
|
|
135
|
-
* Identifies and verifies a single agent from an HTTP request.
|
|
136
|
-
* Uses Web Bot Auth (HTTP message signatures), IP matching, or other available methods.
|
|
137
|
-
*
|
|
138
|
-
* @param request - The incoming HTTP request (Request or Node.js IncomingMessage).
|
|
139
|
-
* @returns A promise that resolves to the identification result.
|
|
140
|
-
* @throws {Error} If the API call fails or returns a non-200 status.
|
|
141
|
-
*/
|
|
142
|
-
identifyAgent(request: Request | IncomingMessage): Promise<IdentificationResult>;
|
|
143
|
-
/**
|
|
144
|
-
* Identifies and verifies multiple agents from HTTP requests in a batch.
|
|
145
|
-
* Uses Web Bot Auth (HTTP message signatures), IP matching, or other available methods.
|
|
146
|
-
*
|
|
147
|
-
* @param requests - An array of identification requests.
|
|
148
|
-
* @returns A promise that resolves to an array of identification results.
|
|
149
|
-
* @throws {Error} If the API call fails or returns a non-200 status.
|
|
150
|
-
*/
|
|
151
|
-
identifyAgents(requests: IdentificationRequest[]): Promise<IdentificationResult[]>;
|
|
152
|
-
private filterHeaders;
|
|
153
|
-
}
|
|
1
|
+
export { KnownAgents } from "./KnownAgents";
|
|
2
|
+
export { AgentType, type IdentificationRequest, type IdentificationResult, type RESTACPResponseBody, type RESTUCPResponseBody, type TrackPageviewOrRESTCallOptions, type VisitRequest } from "./types";
|
|
154
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EACH,SAAS,EACT,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,YAAY,EACpB,MAAM,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,173 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(function (AgentType) {
|
|
9
|
-
AgentType["AIAgent"] = "AI Agent";
|
|
10
|
-
AgentType["AIAssistant"] = "AI Assistant";
|
|
11
|
-
AgentType["AICodingAgent"] = "AI Coding Agent";
|
|
12
|
-
AgentType["AIDataProvider"] = "AI Data Provider";
|
|
13
|
-
AgentType["AIDataScraper"] = "AI Data Scraper";
|
|
14
|
-
AgentType["AISearchCrawler"] = "AI Search Crawler";
|
|
15
|
-
AgentType["Archiver"] = "Archiver";
|
|
16
|
-
AgentType["DeveloperHelper"] = "Developer Helper";
|
|
17
|
-
AgentType["Fetcher"] = "Fetcher";
|
|
18
|
-
AgentType["HeadlessAgent"] = "Headless Agent";
|
|
19
|
-
AgentType["IntelligenceGatherer"] = "Intelligence Gatherer";
|
|
20
|
-
AgentType["Scraper"] = "Scraper";
|
|
21
|
-
AgentType["SEOCrawler"] = "SEO Crawler";
|
|
22
|
-
AgentType["SearchEngineCrawler"] = "Search Engine Crawler";
|
|
23
|
-
AgentType["SecurityScanner"] = "Security Scanner";
|
|
24
|
-
AgentType["UndocumentedAIAgent"] = "Undocumented AI Agent";
|
|
25
|
-
})(AgentType || (exports.AgentType = AgentType = {}));
|
|
26
|
-
class KnownAgents {
|
|
27
|
-
/**
|
|
28
|
-
* Creates a new instance of the Known Agents client.
|
|
29
|
-
*
|
|
30
|
-
* @param accessToken - Your project's access token.
|
|
31
|
-
*/
|
|
32
|
-
constructor(accessToken) {
|
|
33
|
-
this.accessToken = accessToken;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Tracks a single agent visit for analytics.
|
|
37
|
-
* This method is non-blocking and handles errors internally.
|
|
38
|
-
*
|
|
39
|
-
* @param request - The incoming HTTP request (Request or Node.js IncomingMessage).
|
|
40
|
-
* @param response - The outgoing HTTP response (optional).
|
|
41
|
-
* @param responseDurationInMilliseconds - The time taken to process the request in milliseconds (optional).
|
|
42
|
-
*/
|
|
43
|
-
trackVisit(request, response, responseDurationInMilliseconds) {
|
|
44
|
-
fetch("https://api.knownagents.com/visits", {
|
|
45
|
-
method: "POST",
|
|
46
|
-
headers: {
|
|
47
|
-
"Authorization": `Bearer ${this.accessToken}`,
|
|
48
|
-
"Content-Type": "application/json"
|
|
49
|
-
},
|
|
50
|
-
body: JSON.stringify({
|
|
51
|
-
request_path: "path" in request ? request.path : request.url,
|
|
52
|
-
request_method: request.method,
|
|
53
|
-
request_headers: this.filterHeaders(request.headers),
|
|
54
|
-
response_status_code: response?.statusCode,
|
|
55
|
-
response_duration_in_milliseconds: responseDurationInMilliseconds,
|
|
56
|
-
created: new Date().toISOString()
|
|
57
|
-
})
|
|
58
|
-
}).catch(error => {
|
|
59
|
-
console.error(`Known Agents failed to track visit: ${error.message}`);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Tracks multiple agent visits in a batch for analytics.
|
|
64
|
-
* This method is non-blocking and handles errors internally.
|
|
65
|
-
* Recommended for high-traffic websites - batch visits and send periodically (e.g. every 30 seconds).
|
|
66
|
-
*
|
|
67
|
-
* @param visits - An array of visit tracking requests.
|
|
68
|
-
*/
|
|
69
|
-
trackVisits(visits) {
|
|
70
|
-
fetch("https://api.knownagents.com/visits", {
|
|
71
|
-
method: "POST",
|
|
72
|
-
headers: {
|
|
73
|
-
"Authorization": `Bearer ${this.accessToken}`,
|
|
74
|
-
"Content-Type": "application/json"
|
|
75
|
-
},
|
|
76
|
-
body: JSON.stringify(visits)
|
|
77
|
-
}).catch(error => {
|
|
78
|
-
console.error(`Known Agents failed to track visits: ${error.message}`);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Generates a robots.txt file that disallows the specified agent types.
|
|
83
|
-
* The generated file stays up-to-date with all current and future agents in the specified categories.
|
|
84
|
-
* Cache and serve the result at your website's `/robots.txt` endpoint.
|
|
85
|
-
*
|
|
86
|
-
* @param agentTypes - An array of agent types to disallow.
|
|
87
|
-
* @param disallow - The path to disallow (default: "/" for all paths).
|
|
88
|
-
* @returns A promise that resolves to the generated robots.txt content as a string.
|
|
89
|
-
* @throws {Error} If the API call fails or returns a non-200 status.
|
|
90
|
-
*/
|
|
91
|
-
async generateRobotsTXT(agentTypes, disallow = "/") {
|
|
92
|
-
const response = await fetch("https://api.knownagents.com/robots-txts", {
|
|
93
|
-
method: "POST",
|
|
94
|
-
headers: {
|
|
95
|
-
"Authorization": `Bearer ${this.accessToken}`,
|
|
96
|
-
"Content-Type": "application/json"
|
|
97
|
-
},
|
|
98
|
-
body: JSON.stringify({
|
|
99
|
-
agent_types: agentTypes,
|
|
100
|
-
disallow: disallow
|
|
101
|
-
})
|
|
102
|
-
});
|
|
103
|
-
if (response.ok) {
|
|
104
|
-
return await response.text();
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
throw new Error(`Known Agents failed to generate robots.txt: ${response.status} ${response.statusText}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Identifies and verifies a single agent from an HTTP request.
|
|
112
|
-
* Uses Web Bot Auth (HTTP message signatures), IP matching, or other available methods.
|
|
113
|
-
*
|
|
114
|
-
* @param request - The incoming HTTP request (Request or Node.js IncomingMessage).
|
|
115
|
-
* @returns A promise that resolves to the identification result.
|
|
116
|
-
* @throws {Error} If the API call fails or returns a non-200 status.
|
|
117
|
-
*/
|
|
118
|
-
async identifyAgent(request) {
|
|
119
|
-
const response = await fetch("https://api.knownagents.com/agent-identifications", {
|
|
120
|
-
method: "POST",
|
|
121
|
-
headers: {
|
|
122
|
-
"Authorization": `Bearer ${this.accessToken}`,
|
|
123
|
-
"Content-Type": "application/json"
|
|
124
|
-
},
|
|
125
|
-
body: JSON.stringify({
|
|
126
|
-
request_headers: this.filterHeaders(request.headers)
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
if (response.ok) {
|
|
130
|
-
return await response.json();
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
throw new Error(`Known Agents failed to identify agent: ${response.status} ${response.statusText}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Identifies and verifies multiple agents from HTTP requests in a batch.
|
|
138
|
-
* Uses Web Bot Auth (HTTP message signatures), IP matching, or other available methods.
|
|
139
|
-
*
|
|
140
|
-
* @param requests - An array of identification requests.
|
|
141
|
-
* @returns A promise that resolves to an array of identification results.
|
|
142
|
-
* @throws {Error} If the API call fails or returns a non-200 status.
|
|
143
|
-
*/
|
|
144
|
-
async identifyAgents(requests) {
|
|
145
|
-
const response = await fetch("https://api.knownagents.com/agent-identifications", {
|
|
146
|
-
method: "POST",
|
|
147
|
-
headers: {
|
|
148
|
-
"Authorization": `Bearer ${this.accessToken}`,
|
|
149
|
-
"Content-Type": "application/json"
|
|
150
|
-
},
|
|
151
|
-
body: JSON.stringify(requests)
|
|
152
|
-
});
|
|
153
|
-
if (response.ok) {
|
|
154
|
-
return await response.json();
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
throw new Error(`Known Agents failed to identify agents: ${response.status} ${response.statusText}`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Helpers
|
|
161
|
-
filterHeaders(headers) {
|
|
162
|
-
const excludedHeaders = new Set([
|
|
163
|
-
"authorization",
|
|
164
|
-
"proxy-authorization",
|
|
165
|
-
"cookie",
|
|
166
|
-
"set-cookie"
|
|
167
|
-
]);
|
|
168
|
-
return Object.fromEntries(Object.entries(headers).filter(([key]) => {
|
|
169
|
-
return !excludedHeaders.has(key.toLowerCase());
|
|
170
|
-
}));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
exports.KnownAgents = KnownAgents;
|
|
3
|
+
exports.AgentType = exports.KnownAgents = void 0;
|
|
4
|
+
var KnownAgents_1 = require("./KnownAgents");
|
|
5
|
+
Object.defineProperty(exports, "KnownAgents", { enumerable: true, get: function () { return KnownAgents_1.KnownAgents; } });
|
|
6
|
+
var types_1 = require("./types");
|
|
7
|
+
Object.defineProperty(exports, "AgentType", { enumerable: true, get: function () { return types_1.AgentType; } });
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAuEvD"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIsPathExcluded = getIsPathExcluded;
|
|
4
|
+
function getIsPathExcluded(path) {
|
|
5
|
+
const pathWithoutQueryString = path.split(/[?#]/)[0];
|
|
6
|
+
const lowercasedPath = pathWithoutQueryString.toLowerCase();
|
|
7
|
+
const excludedPrefixes = [
|
|
8
|
+
"/_next/",
|
|
9
|
+
"/_nuxt/",
|
|
10
|
+
"/_astro/",
|
|
11
|
+
"/_app/",
|
|
12
|
+
"/__nextjs",
|
|
13
|
+
"/__vite_ping",
|
|
14
|
+
"/__webpack_hmr",
|
|
15
|
+
"/@vite/",
|
|
16
|
+
"/@fs/",
|
|
17
|
+
"/@id/",
|
|
18
|
+
"/@react-refresh",
|
|
19
|
+
"/node_modules/",
|
|
20
|
+
"/_vercel/",
|
|
21
|
+
"/sockjs-node/",
|
|
22
|
+
"/webpack-dev-server/",
|
|
23
|
+
];
|
|
24
|
+
const excludedSuffixes = [
|
|
25
|
+
".ico",
|
|
26
|
+
".png",
|
|
27
|
+
".jpg",
|
|
28
|
+
".jpeg",
|
|
29
|
+
".gif",
|
|
30
|
+
".webp",
|
|
31
|
+
".svg",
|
|
32
|
+
".bmp",
|
|
33
|
+
".tiff",
|
|
34
|
+
".avif",
|
|
35
|
+
".heic",
|
|
36
|
+
".heif",
|
|
37
|
+
".css",
|
|
38
|
+
".js",
|
|
39
|
+
".mjs",
|
|
40
|
+
".ts",
|
|
41
|
+
".jsx",
|
|
42
|
+
".tsx",
|
|
43
|
+
".map",
|
|
44
|
+
".wasm",
|
|
45
|
+
".woff",
|
|
46
|
+
".woff2",
|
|
47
|
+
".ttf",
|
|
48
|
+
".otf",
|
|
49
|
+
".eot",
|
|
50
|
+
".mp3",
|
|
51
|
+
".mp4",
|
|
52
|
+
".webm",
|
|
53
|
+
".wav",
|
|
54
|
+
".ogg",
|
|
55
|
+
".aac",
|
|
56
|
+
".m4a",
|
|
57
|
+
".flac",
|
|
58
|
+
".mov",
|
|
59
|
+
".avi",
|
|
60
|
+
".flv",
|
|
61
|
+
".m4v",
|
|
62
|
+
".webmanifest",
|
|
63
|
+
".pdf",
|
|
64
|
+
".zip",
|
|
65
|
+
".gz",
|
|
66
|
+
];
|
|
67
|
+
return excludedPrefixes.some((excludedPrefix) => {
|
|
68
|
+
return lowercasedPath.startsWith(excludedPrefix.toLowerCase());
|
|
69
|
+
}) || excludedSuffixes.some((excludedSuffix) => {
|
|
70
|
+
return lowercasedPath.endsWith(excludedSuffix.toLowerCase());
|
|
71
|
+
});
|
|
72
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders, OutgoingHttpHeaders } from "http";
|
|
2
|
+
/**
|
|
3
|
+
* ACP response details from a REST API call.
|
|
4
|
+
*/
|
|
5
|
+
export interface RESTACPResponseBody {
|
|
6
|
+
/** The response currency, usually an ISO 4217 code. */
|
|
7
|
+
currency?: string;
|
|
8
|
+
/** ACP totals returned by the REST endpoint. The "total" item is sent to Known Agents. */
|
|
9
|
+
totals?: {
|
|
10
|
+
type?: string;
|
|
11
|
+
amount?: number;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* UCP response details from a REST API call.
|
|
16
|
+
*/
|
|
17
|
+
export interface RESTUCPResponseBody {
|
|
18
|
+
/** The response currency, usually an ISO 4217 code. */
|
|
19
|
+
currency?: string;
|
|
20
|
+
/** UCP totals returned by the REST endpoint. The "total" item is sent to Known Agents. */
|
|
21
|
+
totals?: {
|
|
22
|
+
type?: string;
|
|
23
|
+
amount?: number;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Additional metadata to include when tracking a pageview or REST API call.
|
|
28
|
+
*/
|
|
29
|
+
export interface TrackPageviewOrRESTCallOptions {
|
|
30
|
+
/** ACP response body from the REST endpoint. */
|
|
31
|
+
restACPResponseBody?: RESTACPResponseBody;
|
|
32
|
+
/** UCP response body from the REST endpoint. */
|
|
33
|
+
restUCPResponseBody?: RESTUCPResponseBody;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A normalized visit payload for the Known Agents API.
|
|
37
|
+
* Use this with `trackVisits()` when batching requests yourself.
|
|
38
|
+
*/
|
|
39
|
+
export interface VisitRequest {
|
|
40
|
+
/** The URL path and query string of the request (e.g. "/about?foo=bar") */
|
|
41
|
+
request_path: string;
|
|
42
|
+
/** The HTTP method (e.g. "GET", "POST") */
|
|
43
|
+
request_method: string;
|
|
44
|
+
/** The HTTP request headers. Sensitive headers are removed before sending. */
|
|
45
|
+
request_headers: IncomingHttpHeaders;
|
|
46
|
+
/** The HTTP response status code (e.g. 200, 404) */
|
|
47
|
+
response_status_code?: number;
|
|
48
|
+
/** The HTTP response headers. Sensitive headers are removed before sending. */
|
|
49
|
+
response_headers?: OutgoingHttpHeaders;
|
|
50
|
+
/** The response duration in milliseconds */
|
|
51
|
+
response_duration_in_milliseconds?: number;
|
|
52
|
+
/** The MCP JSON-RPC request method */
|
|
53
|
+
mcp_request_method?: string;
|
|
54
|
+
/** The MCP request tool name */
|
|
55
|
+
mcp_request_tool_name?: string;
|
|
56
|
+
/** The MCP request client name */
|
|
57
|
+
mcp_request_client_info_name?: string;
|
|
58
|
+
/** The MCP request client version */
|
|
59
|
+
mcp_request_client_info_version?: string;
|
|
60
|
+
/** Whether the MCP response result is an error */
|
|
61
|
+
mcp_response_result_is_error?: boolean;
|
|
62
|
+
/** The MCP response error code */
|
|
63
|
+
mcp_response_error_code?: number;
|
|
64
|
+
/** The MCP response error message */
|
|
65
|
+
mcp_response_error_message?: string;
|
|
66
|
+
/** The ACP response currency */
|
|
67
|
+
acp_response_currency?: string;
|
|
68
|
+
/** The ACP response "total" amount */
|
|
69
|
+
acp_response_total_amount?: number;
|
|
70
|
+
/** The UCP response currency */
|
|
71
|
+
ucp_response_currency?: string;
|
|
72
|
+
/** The UCP response "total" amount */
|
|
73
|
+
ucp_response_total_amount?: number;
|
|
74
|
+
/** The timestamp when the visit occurred (ISO 8601 format) */
|
|
75
|
+
created?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* An agent identification request for the Known Agents API.
|
|
79
|
+
* Used for batch agent identification with `identifyAgents()`.
|
|
80
|
+
*/
|
|
81
|
+
export interface IdentificationRequest {
|
|
82
|
+
/** An identifier that will be echoed back in the response to match requests with results */
|
|
83
|
+
id?: string;
|
|
84
|
+
/** The HTTP request headers. Sensitive headers are removed before sending. */
|
|
85
|
+
request_headers: IncomingHttpHeaders;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The result of an agent identification request.
|
|
89
|
+
*/
|
|
90
|
+
export interface IdentificationResult {
|
|
91
|
+
/** The identifier from the request (if provided) */
|
|
92
|
+
id?: string;
|
|
93
|
+
/**
|
|
94
|
+
* The identification result:
|
|
95
|
+
* - "verified": The agent was identified and verified
|
|
96
|
+
* - "verification_failed": The agent was identified but failed verification (spoofed)
|
|
97
|
+
* - "unknown_agent": The request is from an unrecognized agent or human
|
|
98
|
+
* - "not_verifiable": The agent was identified but cannot be verified
|
|
99
|
+
*/
|
|
100
|
+
result: "verified" | "verification_failed" | "unknown_agent" | "not_verifiable";
|
|
101
|
+
/** The unique ID of the identified agent */
|
|
102
|
+
agent_id?: string;
|
|
103
|
+
/** The name of the identified agent (e.g. "Googlebot") */
|
|
104
|
+
agent_token?: string;
|
|
105
|
+
/** The documentation URL for the identified agent */
|
|
106
|
+
agent_url?: string;
|
|
107
|
+
/** The type of the identified agent (e.g. "AI Agent", "Search Engine Crawler") */
|
|
108
|
+
agent_type_name?: string;
|
|
109
|
+
/** The company behind the identified agent (e.g. "Google") */
|
|
110
|
+
operator_name?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Agent types that can be controlled with robots.txt rules.
|
|
114
|
+
*/
|
|
115
|
+
export declare enum AgentType {
|
|
116
|
+
AIAgent = "AI Agent",
|
|
117
|
+
AIAssistant = "AI Assistant",
|
|
118
|
+
AICodingAgent = "AI Coding Agent",
|
|
119
|
+
AIDataProvider = "AI Data Provider",
|
|
120
|
+
AIDataScraper = "AI Data Scraper",
|
|
121
|
+
AISearchCrawler = "AI Search Crawler",
|
|
122
|
+
Archiver = "Archiver",
|
|
123
|
+
AutomatedAgent = "Automated Agent",
|
|
124
|
+
DeveloperHelper = "Developer Helper",
|
|
125
|
+
Fetcher = "Fetcher",
|
|
126
|
+
IntelligenceGatherer = "Intelligence Gatherer",
|
|
127
|
+
Scraper = "Scraper",
|
|
128
|
+
SEOCrawler = "SEO Crawler",
|
|
129
|
+
SearchEngineCrawler = "Search Engine Crawler",
|
|
130
|
+
SecurityScanner = "Security Scanner",
|
|
131
|
+
UndocumentedAIAgent = "Undocumented AI Agent"
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAEpE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,0F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 -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Agent types that can be controlled with robots.txt rules.
|
|
6
|
+
*/
|
|
7
|
+
var AgentType;
|
|
8
|
+
(function (AgentType) {
|
|
9
|
+
AgentType["AIAgent"] = "AI Agent";
|
|
10
|
+
AgentType["AIAssistant"] = "AI Assistant";
|
|
11
|
+
AgentType["AICodingAgent"] = "AI Coding Agent";
|
|
12
|
+
AgentType["AIDataProvider"] = "AI Data Provider";
|
|
13
|
+
AgentType["AIDataScraper"] = "AI Data Scraper";
|
|
14
|
+
AgentType["AISearchCrawler"] = "AI Search Crawler";
|
|
15
|
+
AgentType["Archiver"] = "Archiver";
|
|
16
|
+
AgentType["AutomatedAgent"] = "Automated Agent";
|
|
17
|
+
AgentType["DeveloperHelper"] = "Developer Helper";
|
|
18
|
+
AgentType["Fetcher"] = "Fetcher";
|
|
19
|
+
AgentType["IntelligenceGatherer"] = "Intelligence Gatherer";
|
|
20
|
+
AgentType["Scraper"] = "Scraper";
|
|
21
|
+
AgentType["SEOCrawler"] = "SEO Crawler";
|
|
22
|
+
AgentType["SearchEngineCrawler"] = "Search Engine Crawler";
|
|
23
|
+
AgentType["SecurityScanner"] = "Security Scanner";
|
|
24
|
+
AgentType["UndocumentedAIAgent"] = "Undocumented AI Agent";
|
|
25
|
+
})(AgentType || (exports.AgentType = AgentType = {}));
|