@xapp/arachne-web-service 1.28.0 → 1.30.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/lib/ArachneWebService.d.ts +11 -0
- package/lib/ArachneWebService.js +71 -20
- package/lib/ArachneWebService.js.map +1 -1
- package/lib/contants.js +24 -0
- package/lib/contants.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/agenticProvider.d.ts +18 -0
- package/lib/utils/agenticProvider.js +114 -0
- package/lib/utils/agenticProvider.js.map +1 -0
- package/lib/utils/checkMcpServer.d.ts +43 -0
- package/lib/utils/checkMcpServer.js +297 -0
- package/lib/utils/checkMcpServer.js.map +1 -0
- package/lib/utils/getPrompt.js +1 -1
- package/lib/utils/getPrompt.js.map +1 -1
- package/lib/utils/pageAgenticSignals.d.ts +71 -0
- package/lib/utils/pageAgenticSignals.js +248 -0
- package/lib/utils/pageAgenticSignals.js.map +1 -0
- package/lib/utils/probeAgenticSignals.d.ts +23 -2
- package/lib/utils/probeAgenticSignals.js +94 -23
- package/lib/utils/probeAgenticSignals.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*! Copyright (c) 2026, XAPP AI */
|
|
2
|
+
/**
|
|
3
|
+
* - `live`: answered `initialize` as an MCP server
|
|
4
|
+
* - `auth-required`: answered 401/403, so it exists but wants credentials
|
|
5
|
+
* - `not-mcp`: answered, but not with JSON-RPC
|
|
6
|
+
* - `unreachable`: 404, 5xx, timeout or network error
|
|
7
|
+
* - `skipped`: not a public http(s) URL, so never contacted
|
|
8
|
+
*/
|
|
9
|
+
export type McpServerStatus = "live" | "auth-required" | "not-mcp" | "unreachable" | "skipped";
|
|
10
|
+
export interface McpServerCheck {
|
|
11
|
+
status: McpServerStatus;
|
|
12
|
+
/** ISO time of the check. */
|
|
13
|
+
checkedAt: string;
|
|
14
|
+
httpStatus?: number;
|
|
15
|
+
protocolVersion?: string;
|
|
16
|
+
serverInfo?: {
|
|
17
|
+
name?: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
};
|
|
20
|
+
/** Names and descriptions from `tools/list`. Tools are listed, never called. */
|
|
21
|
+
tools?: {
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
}[];
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface CheckMcpServerOptions {
|
|
28
|
+
/** Per-request timeout. Defaults to 5000ms. */
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
/** Resolves a hostname to its addresses. Defaults to `dns.lookup`; replaceable for tests. */
|
|
31
|
+
resolve?: (hostname: string) => Promise<string[]>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* True for an http(s) URL whose host is not obviously internal: a literal address or
|
|
35
|
+
* localhost name. `checkMcpServer` also resolves the hostname before connecting.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isPublicHttpUrl(value: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Checks whether a URL is a working MCP server over Streamable HTTP: sends `initialize`,
|
|
40
|
+
* then `tools/list`, then ends the session. It never calls a tool, so it cannot submit a
|
|
41
|
+
* lead or change anything on the server. Never throws.
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkMcpServer(url: string, options?: CheckMcpServerOptions): Promise<McpServerCheck>;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*! Copyright (c) 2026, XAPP AI */
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.isPublicHttpUrl = isPublicHttpUrl;
|
|
14
|
+
exports.checkMcpServer = checkMcpServer;
|
|
15
|
+
const promises_1 = require("dns/promises");
|
|
16
|
+
const net_1 = require("net");
|
|
17
|
+
const stentor_logger_1 = require("stentor-logger");
|
|
18
|
+
function resolveAll(hostname) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return (yield (0, promises_1.lookup)(hostname, { all: true })).map((a) => a.address);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const DEFAULT_TIMEOUT_MS = 5000;
|
|
24
|
+
const PROTOCOL_VERSION = "2025-06-18";
|
|
25
|
+
const MAX_TOOLS = 100;
|
|
26
|
+
const MAX_DESCRIPTION_LENGTH = 500;
|
|
27
|
+
/** Replies past this are not read further: a JSON-RPC reply with a tool list is a few KB. */
|
|
28
|
+
const MAX_BODY_BYTES = 256 * 1024;
|
|
29
|
+
/** A generic client identity, so the check does not name the crawler to the site. */
|
|
30
|
+
const CLIENT_INFO = { name: "mcp-client", version: "1.0.0" };
|
|
31
|
+
function isPrivateIPv4(ip) {
|
|
32
|
+
const [a, b] = ip.split(".").map(Number);
|
|
33
|
+
return (a === 10 ||
|
|
34
|
+
a === 127 ||
|
|
35
|
+
a === 0 ||
|
|
36
|
+
a >= 224 ||
|
|
37
|
+
(a === 192 && b === 0 && ip.split(".")[2] === "0") ||
|
|
38
|
+
(a === 198 && (b === 18 || b === 19)) ||
|
|
39
|
+
(a === 169 && b === 254) ||
|
|
40
|
+
(a === 172 && b >= 16 && b <= 31) ||
|
|
41
|
+
(a === 192 && b === 168) ||
|
|
42
|
+
(a === 100 && b >= 64 && b <= 127));
|
|
43
|
+
}
|
|
44
|
+
/** True for an IP literal outside the private, loopback and link-local ranges. */
|
|
45
|
+
function isPublicAddress(host) {
|
|
46
|
+
// `new URL` normalizes [::ffff:127.0.0.1] to [::ffff:7f00:1]; decode it back to IPv4.
|
|
47
|
+
const mapped = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(host);
|
|
48
|
+
if (mapped) {
|
|
49
|
+
const hi = parseInt(mapped[1], 16);
|
|
50
|
+
const lo = parseInt(mapped[2], 16);
|
|
51
|
+
return !isPrivateIPv4(`${hi >> 8}.${hi & 255}.${lo >> 8}.${lo & 255}`);
|
|
52
|
+
}
|
|
53
|
+
const dotted = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(host);
|
|
54
|
+
if (dotted) {
|
|
55
|
+
return !isPrivateIPv4(dotted[1]);
|
|
56
|
+
}
|
|
57
|
+
const version = (0, net_1.isIP)(host);
|
|
58
|
+
if (version === 4) {
|
|
59
|
+
return !isPrivateIPv4(host);
|
|
60
|
+
}
|
|
61
|
+
if (version === 6) {
|
|
62
|
+
return !(host === "::1" || host === "::" || /^f[cd]/.test(host) || /^fe[89a-f]/.test(host) || /^ff/.test(host));
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* True for an http(s) URL whose host is not obviously internal: a literal address or
|
|
68
|
+
* localhost name. `checkMcpServer` also resolves the hostname before connecting.
|
|
69
|
+
*/
|
|
70
|
+
function isPublicHttpUrl(value) {
|
|
71
|
+
let url;
|
|
72
|
+
try {
|
|
73
|
+
url = new URL(value);
|
|
74
|
+
}
|
|
75
|
+
catch (_a) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const host = url.hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
82
|
+
if (host === "localhost" || host.endsWith(".localhost") || host.endsWith(".internal")) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return isPublicAddress(host);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* True when every address the hostname resolves to is public, so a name pointed at 10.x or
|
|
89
|
+
* 127.0.0.1 (or a nip.io-style name) is refused. A rebinding resolver could still answer
|
|
90
|
+
* differently at connect time; this closes the plain case.
|
|
91
|
+
*/
|
|
92
|
+
function resolvesPublic(url, resolve) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const host = new URL(url).hostname.replace(/^\[|\]$/g, "");
|
|
95
|
+
if ((0, net_1.isIP)(host)) {
|
|
96
|
+
return true; // already checked as a literal
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const addresses = yield resolve(host);
|
|
100
|
+
return addresses.length > 0 && addresses.every((a) => isPublicAddress(a.toLowerCase()));
|
|
101
|
+
}
|
|
102
|
+
catch (_a) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
class HttpStatusError extends Error {
|
|
108
|
+
constructor(status) {
|
|
109
|
+
super(`HTTP ${status}`);
|
|
110
|
+
this.status = status;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** The body as text, or undefined once it passes MAX_BODY_BYTES. */
|
|
114
|
+
function readCapped(response) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
const reader = (_b = (_a = response.body) === null || _a === void 0 ? void 0 : _a.getReader) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
118
|
+
if (!reader) {
|
|
119
|
+
const text = yield response.text();
|
|
120
|
+
return text.length > MAX_BODY_BYTES ? undefined : text;
|
|
121
|
+
}
|
|
122
|
+
const chunks = [];
|
|
123
|
+
let size = 0;
|
|
124
|
+
for (;;) {
|
|
125
|
+
const { done, value } = yield reader.read();
|
|
126
|
+
if (done) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
size += value.byteLength;
|
|
130
|
+
if (size > MAX_BODY_BYTES) {
|
|
131
|
+
yield reader.cancel().catch(() => undefined);
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
chunks.push(value);
|
|
135
|
+
}
|
|
136
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/** The JSON-RPC message with `id` from a JSON or server-sent-events body. */
|
|
140
|
+
function parseRpcBody(text, contentType, id) {
|
|
141
|
+
const candidates = contentType.includes("text/event-stream")
|
|
142
|
+
? text
|
|
143
|
+
.split(/\r?\n/)
|
|
144
|
+
.filter((line) => line.startsWith("data:"))
|
|
145
|
+
.map((line) => line.slice(5).trim())
|
|
146
|
+
: [text];
|
|
147
|
+
for (const candidate of candidates) {
|
|
148
|
+
try {
|
|
149
|
+
const parsed = JSON.parse(candidate);
|
|
150
|
+
if (parsed && typeof parsed === "object" && parsed.jsonrpc === "2.0" && parsed.id === id) {
|
|
151
|
+
return parsed;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (_a) {
|
|
155
|
+
// not this one
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
function post(url, body, sessionId, timeoutMs) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
const controller = new AbortController();
|
|
164
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
165
|
+
try {
|
|
166
|
+
const headers = {
|
|
167
|
+
"Content-Type": "application/json",
|
|
168
|
+
Accept: "application/json, text/event-stream",
|
|
169
|
+
"MCP-Protocol-Version": PROTOCOL_VERSION,
|
|
170
|
+
};
|
|
171
|
+
if (sessionId) {
|
|
172
|
+
headers["Mcp-Session-Id"] = sessionId;
|
|
173
|
+
}
|
|
174
|
+
const response = yield fetch(url, {
|
|
175
|
+
method: "POST",
|
|
176
|
+
headers,
|
|
177
|
+
body: JSON.stringify(body),
|
|
178
|
+
signal: controller.signal,
|
|
179
|
+
// The URL came from an untrusted page and was vetted by isPublicHttpUrl; a redirect
|
|
180
|
+
// could point anywhere, so a 3xx counts as a failed check rather than being followed.
|
|
181
|
+
redirect: "manual",
|
|
182
|
+
});
|
|
183
|
+
const reply = {
|
|
184
|
+
status: response.status,
|
|
185
|
+
sessionId: (_a = response.headers.get("mcp-session-id")) !== null && _a !== void 0 ? _a : undefined,
|
|
186
|
+
};
|
|
187
|
+
if (!response.ok) {
|
|
188
|
+
throw new HttpStatusError(response.status);
|
|
189
|
+
}
|
|
190
|
+
if (typeof body.id === "number") {
|
|
191
|
+
const text = yield readCapped(response);
|
|
192
|
+
if (text !== undefined) {
|
|
193
|
+
reply.message = parseRpcBody(text, (_b = response.headers.get("content-type")) !== null && _b !== void 0 ? _b : "", body.id);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return reply;
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
clearTimeout(timer);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function asRecord(value) {
|
|
204
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
205
|
+
}
|
|
206
|
+
function toolsFrom(message) {
|
|
207
|
+
var _a;
|
|
208
|
+
const tools = (_a = asRecord(message === null || message === void 0 ? void 0 : message.result)) === null || _a === void 0 ? void 0 : _a.tools;
|
|
209
|
+
if (!Array.isArray(tools)) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
const out = [];
|
|
213
|
+
for (const raw of tools.slice(0, MAX_TOOLS)) {
|
|
214
|
+
const tool = asRecord(raw);
|
|
215
|
+
if (tool && typeof tool.name === "string") {
|
|
216
|
+
const entry = { name: tool.name };
|
|
217
|
+
if (typeof tool.description === "string") {
|
|
218
|
+
entry.description = tool.description.slice(0, MAX_DESCRIPTION_LENGTH);
|
|
219
|
+
}
|
|
220
|
+
out.push(entry);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return out;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Checks whether a URL is a working MCP server over Streamable HTTP: sends `initialize`,
|
|
227
|
+
* then `tools/list`, then ends the session. It never calls a tool, so it cannot submit a
|
|
228
|
+
* lead or change anything on the server. Never throws.
|
|
229
|
+
*/
|
|
230
|
+
function checkMcpServer(url_1) {
|
|
231
|
+
return __awaiter(this, arguments, void 0, function* (url, options = {}) {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
const timeoutMs = typeof options.timeoutMs === "number" ? options.timeoutMs : DEFAULT_TIMEOUT_MS;
|
|
234
|
+
const checkedAt = new Date().toISOString();
|
|
235
|
+
if (!isPublicHttpUrl(url) || !(yield resolvesPublic(url, (_a = options.resolve) !== null && _a !== void 0 ? _a : resolveAll))) {
|
|
236
|
+
return { status: "skipped", checkedAt };
|
|
237
|
+
}
|
|
238
|
+
let init;
|
|
239
|
+
try {
|
|
240
|
+
init = yield post(url, {
|
|
241
|
+
jsonrpc: "2.0",
|
|
242
|
+
id: 1,
|
|
243
|
+
method: "initialize",
|
|
244
|
+
params: { protocolVersion: PROTOCOL_VERSION, capabilities: {}, clientInfo: CLIENT_INFO },
|
|
245
|
+
}, undefined, timeoutMs);
|
|
246
|
+
}
|
|
247
|
+
catch (e) {
|
|
248
|
+
if (e instanceof HttpStatusError) {
|
|
249
|
+
const status = e.status === 401 || e.status === 403 ? "auth-required" : "unreachable";
|
|
250
|
+
return { status, checkedAt, httpStatus: e.status };
|
|
251
|
+
}
|
|
252
|
+
return { status: "unreachable", checkedAt, error: String(e).slice(0, 200) };
|
|
253
|
+
}
|
|
254
|
+
const result = asRecord((_b = init.message) === null || _b === void 0 ? void 0 : _b.result);
|
|
255
|
+
if (!result) {
|
|
256
|
+
return { status: "not-mcp", checkedAt, httpStatus: init.status };
|
|
257
|
+
}
|
|
258
|
+
const check = { status: "live", checkedAt, httpStatus: init.status };
|
|
259
|
+
if (typeof result.protocolVersion === "string") {
|
|
260
|
+
check.protocolVersion = result.protocolVersion;
|
|
261
|
+
}
|
|
262
|
+
const serverInfo = asRecord(result.serverInfo);
|
|
263
|
+
if (serverInfo) {
|
|
264
|
+
check.serverInfo = {
|
|
265
|
+
name: typeof serverInfo.name === "string" ? serverInfo.name : undefined,
|
|
266
|
+
version: typeof serverInfo.version === "string" ? serverInfo.version : undefined,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
const sessionId = init.sessionId;
|
|
270
|
+
try {
|
|
271
|
+
yield post(url, { jsonrpc: "2.0", method: "notifications/initialized" }, sessionId, timeoutMs);
|
|
272
|
+
const list = yield post(url, { jsonrpc: "2.0", id: 2, method: "tools/list", params: {} }, sessionId, timeoutMs);
|
|
273
|
+
const tools = toolsFrom(list.message);
|
|
274
|
+
if (tools) {
|
|
275
|
+
check.tools = tools;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch (e) {
|
|
279
|
+
(0, stentor_logger_1.log)().debug(`MCP tools/list failed for ${url}: ${e}`);
|
|
280
|
+
}
|
|
281
|
+
if (sessionId) {
|
|
282
|
+
// Best effort: let the server drop the session rather than wait for it to expire.
|
|
283
|
+
const controller = new AbortController();
|
|
284
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
285
|
+
yield fetch(url, {
|
|
286
|
+
method: "DELETE",
|
|
287
|
+
headers: { "Mcp-Session-Id": sessionId },
|
|
288
|
+
signal: controller.signal,
|
|
289
|
+
redirect: "manual",
|
|
290
|
+
})
|
|
291
|
+
.catch(() => undefined)
|
|
292
|
+
.finally(() => clearTimeout(timer));
|
|
293
|
+
}
|
|
294
|
+
return check;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=checkMcpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkMcpServer.js","sourceRoot":"","sources":["../../src/utils/checkMcpServer.ts"],"names":[],"mappings":";AAA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,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;YACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC,GAAG,EAAE;gBACb,MAAM,EAAE,QAAQ;gBAChB,OAAO,EAAE,EAAE,gBAAgB,EAAE,SAAS,EAAE;gBACxC,MAAM,EAAE,UAAU,CAAC,MAAM;gBACzB,QAAQ,EAAE,QAAQ;aACrB,CAAC;iBACG,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;iBACtB,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CAAA"}
|
package/lib/utils/getPrompt.js
CHANGED
|
@@ -88,7 +88,7 @@ function getIndustryCategoryOptions() {
|
|
|
88
88
|
* @param source What the content being analyzed is called, "website" or "page".
|
|
89
89
|
*/
|
|
90
90
|
function getLicensesInstruction(source) {
|
|
91
|
-
return `"licenses" - An array of state-issued contractor or trade license numbers found on the ${source}, along with the operating authority and state board license numbers other trades publish. Focus on licenses required to operate, for example: state contractor licenses, HVAC licenses, plumbing licenses, electrical licenses; for movers a USDOT number, an MC (motor carrier) number and state authority such as CAL-T or CPUC in California, a Florida IM number or a state DOT mover registration; for salons, spas and med spas state cosmetology, barber, esthetician, nail salon establishment or massage therapy licenses, and the medical director's license when a med spa publishes one. Do not include general business registrations, ISO certifications, or membership numbers. Use an object with keys: number (just the license number itself), type (the type of license such as HVAC, Plumbing, Electrical, General Contractor, Roofing, USDOT, MC, CAL-T, Cosmetology, Barber, Esthetician, Massage Therapy, Medical Director, etc), state (two-letter state code if identifiable from context, leave it out for federal numbers such as USDOT and MC), fullText (the complete license text exactly as shown on the ${source}).`;
|
|
91
|
+
return `"licenses" - An array of state-issued contractor or trade license numbers found on the ${source}, along with the operating authority and state board license numbers other trades publish. Focus on licenses required to operate, for example: state contractor licenses, HVAC licenses, plumbing licenses, electrical licenses; for movers a USDOT number, an MC (motor carrier) number and state authority such as CAL-T or CPUC in California, a Florida IM number or a state DOT mover registration; for salons, spas and med spas state cosmetology, barber, esthetician, nail salon establishment or massage therapy licenses, and the medical director's license when a med spa publishes one; for financial advisors and planners a FINRA CRD number (the firm's or the individual's, often shown beside a BrokerCheck link), an SEC file number such as 801-xxxxx or 8-xxxxx, an investment adviser representative (IARD) number, FINRA securities registrations by series (Series 7, 63, 65, 66), the CFP certification, and state insurance producer licenses. Do not include general business registrations, ISO certifications, or membership numbers. For financial firms do not include SIPC or FDIC membership, which every member states and which identifies nobody. Use an object with keys: number (just the license number itself), type (the type of license such as HVAC, Plumbing, Electrical, General Contractor, Roofing, USDOT, MC, CAL-T, Cosmetology, Barber, Esthetician, Massage Therapy, Medical Director, CRD, SEC File Number, IARD, Series 7, Series 65, CFP, Insurance Producer, etc), state (two-letter state code if identifiable from context, leave it out for federal numbers such as USDOT and MC), fullText (the complete license text exactly as shown on the ${source}).`;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Calculates the number of tokens in a prompt and the maximum tokens available for the response.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrompt.js","sourceRoot":"","sources":["../../src/utils/getPrompt.ts"],"names":[],"mappings":";;;AA6EA,gDAIC;AAyCD,8BAOC;AAED,oDAmCC;AASD,4CAuBC;AAED,kDAmBC;AA3ND,kCAAkC;AAClC,sCAAkE;AAElE,0CAA0C;AAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAE5C,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;;GAGG;AACU,QAAA,uBAAuB,GAAG,CAAC,iBAAiB,CAAU,CAAC;AAEpE;;;;;GAKG;AACU,QAAA,8BAA8B,GAGvC;IACA,qBAAqB,EACjB,6FAA6F;QAC7F,iFAAiF;IACrF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EAAE,GAAW;IAC9D,MAAM,MAAM,GAAG;0FACuE,GAAG;;;EAG3F,QAAQ;;;;;;;;;;;;;;;;;;;;EAoBR,0BAA0B,EAAE;EAC5B,sBAAsB,CAAC,SAAS,CAAC;CAClC,CAAC;IAEE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAEjC,uBACI,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,IAClB,MAAM,EACX;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,QAAgB,EAAE,GAAW;IAC1D,MAAM,MAAM,GAAG;0GACuF,GAAG;;;EAG3G,QAAQ;;;;;;;;;EASR,sBAAsB,CAAC,MAAM,CAAC;CAC/B,CAAC;IAEE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAEjC,uBACI,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,IAClB,MAAM,EACX;AACN,CAAC;AAED,SAAgB,mBAAmB,CAAC,IAAS,EAAE,GAAW;IACtD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAExC,MAAM,MAAM,GAAG;EACjB,UAAU;;kDAEsC,GAAG;;;CAGpD,CAAC;IAEE,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAE9B,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAElC,uBACI,MAAM,EAAE,OAAO,IACZ,MAAM,EACX;AACN,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*! Copyright (c) 2026, XAPP AI */
|
|
2
|
+
import { AgenticProvider } from "./agenticProvider";
|
|
3
|
+
import type { McpServerCheck } from "./checkMcpServer";
|
|
4
|
+
/**
|
|
5
|
+
* An MCP discovery tag in the rendered page, e.g. `<link rel="mcp-server" href="...">` or
|
|
6
|
+
* `<meta name="mcp-server" content="...">`. For a meta tag, `rel` is its name and `href` its content.
|
|
7
|
+
*/
|
|
8
|
+
export interface McpPageTag {
|
|
9
|
+
tag: "link" | "meta";
|
|
10
|
+
rel: string;
|
|
11
|
+
href: string;
|
|
12
|
+
}
|
|
13
|
+
/** A tool the page registered for in-browser agents through WebMCP (`modelContext`). */
|
|
14
|
+
export interface WebMcpTool {
|
|
15
|
+
/** Which object it was registered on: `document.modelContext` (the spec) or `navigator.modelContext`. */
|
|
16
|
+
api: "document" | "navigator";
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Where a site's MCP server was advertised. */
|
|
21
|
+
export type McpServerSource = "server-card" | "page-tag";
|
|
22
|
+
/** One MCP server a site points agents at. */
|
|
23
|
+
export interface McpServerRef {
|
|
24
|
+
url: string;
|
|
25
|
+
foundIn: McpServerSource[];
|
|
26
|
+
provider?: AgenticProvider;
|
|
27
|
+
/** Present only when the crawl asked for `checkMcpServers`. */
|
|
28
|
+
check?: McpServerCheck;
|
|
29
|
+
}
|
|
30
|
+
/** The window property the recorder writes to. Not enumerable, so page scripts iterating window miss it. */
|
|
31
|
+
export declare const WEBMCP_RECORDER_KEY = "__arachneWebMcp";
|
|
32
|
+
/**
|
|
33
|
+
* Finds MCP discovery tags in rendered HTML: any `<link>` with a rel token starting with
|
|
34
|
+
* "mcp" (mcp-server, mcp-manifest, mcp-server-card) and any `<meta>` whose name does.
|
|
35
|
+
* Pass the HTML from `page.content()` so tags a script injected (the XAPP chat widget
|
|
36
|
+
* does) are included.
|
|
37
|
+
*/
|
|
38
|
+
export declare function extractMcpPageTags(html: string, baseUrl: string): McpPageTag[];
|
|
39
|
+
/**
|
|
40
|
+
* Installs a stand-in `modelContext` on `document` and `navigator` that records every tool
|
|
41
|
+
* the page registers, so a crawl sees a site's WebMCP tools the way an in-browser agent
|
|
42
|
+
* would. A real `modelContext` is left untouched. Registering does nothing else: no tool is
|
|
43
|
+
* ever executed.
|
|
44
|
+
*
|
|
45
|
+
* Runs in the browser through `page.evaluateOnNewDocument`, so it must stay self-contained.
|
|
46
|
+
* The `scope` parameter exists for tests; in the page it is the window.
|
|
47
|
+
*/
|
|
48
|
+
export declare function webMcpRecorder(scope?: unknown): void;
|
|
49
|
+
/**
|
|
50
|
+
* Gives every `requestIdleCallback` a 2s deadline unless the page set one. Headless Chrome
|
|
51
|
+
* can go a whole crawl without an idle period on a busy page, so scripts deferred to idle
|
|
52
|
+
* time - Next.js `strategy="lazyOnload"`, which is how portao.one loads the XAPP chat
|
|
53
|
+
* widget - never run, although a person's browser runs them within a second or two.
|
|
54
|
+
*
|
|
55
|
+
* Runs in the browser through `page.evaluateOnNewDocument`, so it must stay self-contained.
|
|
56
|
+
*/
|
|
57
|
+
export declare function idleCallbackDeadline(scope?: unknown): void;
|
|
58
|
+
/** Validates, dedupes and bounds what the recorder captured. Undefined when nothing usable. */
|
|
59
|
+
export declare function sanitizeWebMcpTools(raw: unknown): WebMcpTool[] | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Every MCP server a site advertises - in its server card or with an `mcp-server` page tag -
|
|
62
|
+
* merged by URL. Manifest and server-card links are not servers and are skipped.
|
|
63
|
+
*/
|
|
64
|
+
export declare function collectMcpServers(signals: {
|
|
65
|
+
mcpServerCard?: {
|
|
66
|
+
sourceUrl: string;
|
|
67
|
+
endpointUrl?: string;
|
|
68
|
+
provider?: AgenticProvider;
|
|
69
|
+
};
|
|
70
|
+
mcpTags?: McpPageTag[];
|
|
71
|
+
}): McpServerRef[] | undefined;
|