@kirkelabs/agent-readiness-scan 0.1.0 → 0.2.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/src/index.js CHANGED
@@ -1,126 +1,127 @@
1
- /**
2
- * index.js — the scan orchestrator (public API).
3
- *
4
- * Programmatic entry point:
5
- * import { scan } from '@kirkelabs/agent-readiness-scan';
6
- * const result = await scan('https://example.com');
7
- *
8
- * Pre-fetches the target page + robots.txt + 7 .well-known/* paths in
9
- * parallel, then runs 8 pure check functions against the assembled
10
- * context. Each check is a synchronous module that exports
11
- * `meta` ({id, title, weight, why}) and `run(ctx)`.
12
- */
13
-
14
- import { load } from 'cheerio';
15
- import { fetchAsCrawler, fetchSibling } from './fetcher.js';
16
- import { generateCustomsDeclaration } from './generators.js';
17
-
18
- import * as c01 from './checks/01-per-bot-policy.js';
19
- import * as c02 from './checks/02-declared-use-signals.js';
20
- import * as c03 from './checks/03-bot-auth-readiness.js';
21
- import * as c04 from './checks/04-mcp-exposure.js';
22
- import * as c05 from './checks/05-agentic-commerce.js';
23
- import * as c06 from './checks/06-product-offer.js';
24
- import * as c07 from './checks/07-identity-corroboration.js';
25
- import * as c08 from './checks/08-source-regulatory.js';
26
-
27
- const CHECKS = [c01, c02, c03, c04, c05, c06, c07, c08];
28
-
29
- const WELL_KNOWN_PATHS = {
30
- securityTxt: '/.well-known/security.txt',
31
- mcpServerCard: '/.well-known/mcp/server-card.json',
32
- acpManifest: '/.well-known/acp/manifest.json',
33
- ucp: '/.well-known/ucp',
34
- botAuthDirectory: '/.well-known/http-message-signatures-directory',
35
- oauthProtectedResource: '/.well-known/oauth-protected-resource',
36
- oauthAuthorizationServer: '/.well-known/oauth-authorization-server',
37
- };
38
-
39
- async function fetchWellKnown(baseUrl, opts) {
40
- const entries = await Promise.all(
41
- Object.entries(WELL_KNOWN_PATHS).map(async ([key, path]) => {
42
- const res = await fetchSibling(baseUrl, path, opts);
43
- return [
44
- key,
45
- {
46
- found: res.ok && res.html && res.html.trim().length > 0,
47
- content: res.html,
48
- headers: res.headers,
49
- status: res.status,
50
- },
51
- ];
52
- }),
53
- );
54
- return Object.fromEntries(entries);
55
- }
56
-
57
- export async function scan(url, opts = {}) {
58
- const page = await fetchAsCrawler(url, opts);
59
- if (!page.ok && !page.html) {
60
- return {
61
- url,
62
- ok: false,
63
- error: page.error || `HTTP ${page.status}`,
64
- score: 0,
65
- grade: 'F',
66
- dimensions: [],
67
- };
68
- }
69
-
70
- const $ = load(page.html);
71
- const [robots, wellKnown] = await Promise.all([
72
- fetchSibling(url, '/robots.txt', opts),
73
- fetchWellKnown(url, opts),
74
- ]);
75
-
76
- const ctx = {
77
- $,
78
- html: page.html,
79
- finalUrl: page.finalUrl,
80
- headers: page.headers,
81
- robotsTxt: robots.ok ? robots.html : null,
82
- wellKnown,
83
- };
84
-
85
- const dimensions = [];
86
- let weightedSum = 0;
87
- let weightTotal = 0;
88
-
89
- for (const mod of CHECKS) {
90
- const res = mod.run(ctx);
91
- const w = mod.meta.weight;
92
- weightedSum += (res.score / res.max) * w;
93
- weightTotal += w;
94
- dimensions.push({
95
- id: mod.meta.id,
96
- title: mod.meta.title,
97
- why: mod.meta.why,
98
- weight: w,
99
- score: res.score,
100
- max: res.max,
101
- findings: res.findings,
102
- detail: res.detail || {},
103
- });
104
- }
105
-
106
- const score = Math.round((weightedSum / weightTotal) * 100);
107
- return {
108
- url,
109
- finalUrl: page.finalUrl,
110
- ok: true,
111
- status: page.status,
112
- scannedAt: new Date().toISOString(),
113
- score,
114
- grade: grade(score),
115
- dimensions,
116
- generated: generateCustomsDeclaration(ctx),
117
- };
118
- }
119
-
120
- export function grade(s) {
121
- if (s >= 90) return 'A';
122
- if (s >= 80) return 'B';
123
- if (s >= 65) return 'C';
124
- if (s >= 50) return 'D';
125
- return 'F';
126
- }
1
+ /**
2
+ * index.js — the scan orchestrator (public API).
3
+ *
4
+ * Programmatic entry point:
5
+ * import { scan } from '@kirkelabs/agent-readiness-scan';
6
+ * const result = await scan('https://example.com');
7
+ *
8
+ * Pre-fetches the target page + robots.txt + 8 .well-known/* paths in
9
+ * parallel, then runs 8 pure check functions against the assembled
10
+ * context. Each check is a synchronous module that exports
11
+ * `meta` ({id, title, weight, why}) and `run(ctx)`.
12
+ */
13
+
14
+ import { load } from 'cheerio';
15
+ import { fetchAsCrawler, fetchSibling } from './fetcher.js';
16
+ import { generateCustomsDeclaration } from './generators.js';
17
+
18
+ import * as c01 from './checks/01-per-bot-policy.js';
19
+ import * as c02 from './checks/02-declared-use-signals.js';
20
+ import * as c03 from './checks/03-bot-auth-readiness.js';
21
+ import * as c04 from './checks/04-mcp-exposure.js';
22
+ import * as c05 from './checks/05-agentic-commerce.js';
23
+ import * as c06 from './checks/06-product-offer.js';
24
+ import * as c07 from './checks/07-identity-corroboration.js';
25
+ import * as c08 from './checks/08-source-regulatory.js';
26
+
27
+ const CHECKS = [c01, c02, c03, c04, c05, c06, c07, c08];
28
+
29
+ const WELL_KNOWN_PATHS = {
30
+ securityTxt: '/.well-known/security.txt',
31
+ mcpServerCard: '/.well-known/mcp/server-card.json',
32
+ acpManifest: '/.well-known/acp/manifest.json',
33
+ ucp: '/.well-known/ucp',
34
+ agentAccess: '/.well-known/agent-access.json',
35
+ botAuthDirectory: '/.well-known/http-message-signatures-directory',
36
+ oauthProtectedResource: '/.well-known/oauth-protected-resource',
37
+ oauthAuthorizationServer: '/.well-known/oauth-authorization-server',
38
+ };
39
+
40
+ async function fetchWellKnown(baseUrl, opts) {
41
+ const entries = await Promise.all(
42
+ Object.entries(WELL_KNOWN_PATHS).map(async ([key, path]) => {
43
+ const res = await fetchSibling(baseUrl, path, opts);
44
+ return [
45
+ key,
46
+ {
47
+ found: res.ok && res.html && res.html.trim().length > 0,
48
+ content: res.html,
49
+ headers: res.headers,
50
+ status: res.status,
51
+ },
52
+ ];
53
+ }),
54
+ );
55
+ return Object.fromEntries(entries);
56
+ }
57
+
58
+ export async function scan(url, opts = {}) {
59
+ const page = await fetchAsCrawler(url, opts);
60
+ if (!page.ok && !page.html) {
61
+ return {
62
+ url,
63
+ ok: false,
64
+ error: page.error || `HTTP ${page.status}`,
65
+ score: 0,
66
+ grade: 'F',
67
+ dimensions: [],
68
+ };
69
+ }
70
+
71
+ const $ = load(page.html);
72
+ const [robots, wellKnown] = await Promise.all([
73
+ fetchSibling(url, '/robots.txt', opts),
74
+ fetchWellKnown(url, opts),
75
+ ]);
76
+
77
+ const ctx = {
78
+ $,
79
+ html: page.html,
80
+ finalUrl: page.finalUrl,
81
+ headers: page.headers,
82
+ robotsTxt: robots.ok ? robots.html : null,
83
+ wellKnown,
84
+ };
85
+
86
+ const dimensions = [];
87
+ let weightedSum = 0;
88
+ let weightTotal = 0;
89
+
90
+ for (const mod of CHECKS) {
91
+ const res = mod.run(ctx);
92
+ const w = mod.meta.weight;
93
+ weightedSum += (res.score / res.max) * w;
94
+ weightTotal += w;
95
+ dimensions.push({
96
+ id: mod.meta.id,
97
+ title: mod.meta.title,
98
+ why: mod.meta.why,
99
+ weight: w,
100
+ score: res.score,
101
+ max: res.max,
102
+ findings: res.findings,
103
+ detail: res.detail || {},
104
+ });
105
+ }
106
+
107
+ const score = Math.round((weightedSum / weightTotal) * 100);
108
+ return {
109
+ url,
110
+ finalUrl: page.finalUrl,
111
+ ok: true,
112
+ status: page.status,
113
+ scannedAt: new Date().toISOString(),
114
+ score,
115
+ grade: grade(score),
116
+ dimensions,
117
+ generated: generateCustomsDeclaration(ctx),
118
+ };
119
+ }
120
+
121
+ export function grade(s) {
122
+ if (s >= 90) return 'A';
123
+ if (s >= 80) return 'B';
124
+ if (s >= 65) return 'C';
125
+ if (s >= 50) return 'D';
126
+ return 'F';
127
+ }