milieu-cli 0.1.12 → 0.2.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 +32 -11
- package/dist/bridges/context/agents-json.d.ts +3 -0
- package/dist/bridges/context/agents-json.d.ts.map +1 -0
- package/dist/bridges/context/agents-json.js +17 -0
- package/dist/bridges/context/agents-json.js.map +1 -0
- package/dist/bridges/context/auth-clarity.d.ts +4 -0
- package/dist/bridges/context/auth-clarity.d.ts.map +1 -0
- package/dist/bridges/context/auth-clarity.js +30 -0
- package/dist/bridges/context/auth-clarity.js.map +1 -0
- package/dist/bridges/context/auth-legibility.d.ts +3 -0
- package/dist/bridges/context/auth-legibility.d.ts.map +1 -0
- package/dist/bridges/context/auth-legibility.js +68 -0
- package/dist/bridges/context/auth-legibility.js.map +1 -0
- package/dist/bridges/context/index.d.ts +3 -0
- package/dist/bridges/context/index.d.ts.map +1 -0
- package/dist/bridges/context/index.js +57 -0
- package/dist/bridges/context/index.js.map +1 -0
- package/dist/bridges/context/rate-limits.d.ts +3 -0
- package/dist/bridges/context/rate-limits.d.ts.map +1 -0
- package/dist/bridges/context/rate-limits.js +43 -0
- package/dist/bridges/context/rate-limits.js.map +1 -0
- package/dist/bridges/context/tos-contact.d.ts +5 -0
- package/dist/bridges/context/tos-contact.d.ts.map +1 -0
- package/dist/bridges/context/tos-contact.js +32 -0
- package/dist/bridges/context/tos-contact.js.map +1 -0
- package/dist/bridges/context/versioning.d.ts +4 -0
- package/dist/bridges/context/versioning.d.ts.map +1 -0
- package/dist/bridges/context/versioning.js +22 -0
- package/dist/bridges/context/versioning.js.map +1 -0
- package/dist/bridges/index.d.ts +2 -1
- package/dist/bridges/index.d.ts.map +1 -1
- package/dist/bridges/index.js +2 -2
- package/dist/bridges/index.js.map +1 -1
- package/dist/bridges/schema/descriptions.d.ts +4 -0
- package/dist/bridges/schema/descriptions.d.ts.map +1 -0
- package/dist/bridges/schema/descriptions.js +56 -0
- package/dist/bridges/schema/descriptions.js.map +1 -0
- package/dist/bridges/schema/error-schemas.d.ts +4 -0
- package/dist/bridges/schema/error-schemas.d.ts.map +1 -0
- package/dist/bridges/schema/error-schemas.js +30 -0
- package/dist/bridges/schema/error-schemas.js.map +1 -0
- package/dist/bridges/schema/index.d.ts +3 -0
- package/dist/bridges/schema/index.d.ts.map +1 -0
- package/dist/bridges/schema/index.js +55 -0
- package/dist/bridges/schema/index.js.map +1 -0
- package/dist/bridges/schema/oas-types.d.ts +77 -0
- package/dist/bridges/schema/oas-types.d.ts.map +1 -0
- package/dist/bridges/schema/oas-types.js +24 -0
- package/dist/bridges/schema/oas-types.js.map +1 -0
- package/dist/bridges/schema/operation-ids.d.ts +4 -0
- package/dist/bridges/schema/operation-ids.d.ts.map +1 -0
- package/dist/bridges/schema/operation-ids.js +18 -0
- package/dist/bridges/schema/operation-ids.js.map +1 -0
- package/dist/bridges/schema/required-fields.d.ts +4 -0
- package/dist/bridges/schema/required-fields.d.ts.map +1 -0
- package/dist/bridges/schema/required-fields.js +28 -0
- package/dist/bridges/schema/required-fields.js.map +1 -0
- package/dist/bridges/schema/schema-types.d.ts +4 -0
- package/dist/bridges/schema/schema-types.d.ts.map +1 -0
- package/dist/bridges/schema/schema-types.js +38 -0
- package/dist/bridges/schema/schema-types.js.map +1 -0
- package/dist/bridges/standards/a2a-agent-card.d.ts +3 -0
- package/dist/bridges/standards/a2a-agent-card.d.ts.map +1 -0
- package/dist/bridges/standards/a2a-agent-card.js +18 -0
- package/dist/bridges/standards/a2a-agent-card.js.map +1 -0
- package/dist/bridges/standards/index.d.ts +0 -16
- package/dist/bridges/standards/index.d.ts.map +1 -1
- package/dist/bridges/standards/index.js +16 -52
- package/dist/bridges/standards/index.js.map +1 -1
- package/dist/bridges/standards/openapi.d.ts +2 -0
- package/dist/bridges/standards/openapi.d.ts.map +1 -1
- package/dist/bridges/standards/openapi.js +6 -0
- package/dist/bridges/standards/openapi.js.map +1 -1
- package/dist/bridges/standards/webmcp.d.ts +3 -0
- package/dist/bridges/standards/webmcp.d.ts.map +1 -0
- package/dist/bridges/standards/webmcp.js +18 -0
- package/dist/bridges/standards/webmcp.js.map +1 -0
- package/dist/bridges/standards/well-known.d.ts +0 -7
- package/dist/bridges/standards/well-known.d.ts.map +1 -1
- package/dist/bridges/standards/well-known.js +0 -45
- package/dist/bridges/standards/well-known.js.map +1 -1
- package/dist/core/explanations.d.ts.map +1 -1
- package/dist/core/explanations.js +75 -4
- package/dist/core/explanations.js.map +1 -1
- package/dist/core/scan.d.ts.map +1 -1
- package/dist/core/scan.js +15 -49
- package/dist/core/scan.js.map +1 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/render/format-bridge.d.ts.map +1 -1
- package/dist/render/format-bridge.js +0 -6
- package/dist/render/format-bridge.js.map +1 -1
- package/package.json +1 -1
- package/dist/bridges/stubs.d.ts +0 -4
- package/dist/bridges/stubs.d.ts.map +0 -1
- package/dist/bridges/stubs.js +0 -25
- package/dist/bridges/stubs.js.map +0 -1
package/README.md
CHANGED
|
@@ -74,22 +74,39 @@ Milieu evaluates your product through five progressive bridges. Each one represe
|
|
|
74
74
|
| | Bridge | Question | What milieu checks | Score |
|
|
75
75
|
|---|---|---|---|---|
|
|
76
76
|
| 1 | **Reachability** | **Can agents reach you?** | HTTPS, HTTP status, robots.txt (RFC 9309), per-bot crawler policies (GPTBot, ClaudeBot, CCBot, Googlebot, Bingbot, PerplexityBot), meta robots, X-Robots-Tag | 0–100 |
|
|
77
|
-
| 2 | **Standards** | **Can agents read you?** | OpenAPI spec, GraphQL introspection, XML sitemap, markdown content negotiation, llms.txt, llms-full.txt, MCP endpoint, JSON-LD, Schema.org, security.txt,
|
|
77
|
+
| 2 | **Standards** | **Can agents read you?** | OpenAPI spec, GraphQL introspection, XML sitemap, markdown content negotiation, llms.txt, llms-full.txt, MCP endpoint, JSON-LD, Schema.org, security.txt, WebMCP, A2A Agent Card | 0–100 |
|
|
78
78
|
| 3 | **Separation** | **Can agents integrate with you?** | API endpoints, developer docs, SDK/package references, webhook support | Detection only* |
|
|
79
|
-
| 4 | **Schema** | **Can agents use
|
|
80
|
-
| 5 | **Context** | **Can agents trust
|
|
79
|
+
| 4 | **Schema** | **Can agents use your APIs correctly?** | Operation IDs, schema types, error response schemas, required fields, field descriptions | 0–100 |
|
|
80
|
+
| 5 | **Context** | **Can agents trust and operate your APIs?** | Rate-limit headers, auth clarity, auth legibility, Terms of Service, API versioning, contact info, agents.json | 0–100 |
|
|
81
81
|
|
|
82
82
|
*Bridge 3 reports what's present rather than scoring quality.
|
|
83
83
|
|
|
84
|
-
The bridges are progressive: there's no point checking your OpenAPI spec (Bridge 2) if agents can't even reach your product surface (Bridge 1). There's no point
|
|
84
|
+
The bridges are progressive: there's no point checking your OpenAPI spec (Bridge 2) if agents can't even reach your product surface (Bridge 1). There's no point evaluating schema quality (Bridge 4) if no spec was found (Bridge 2). Each bridge builds on the last.
|
|
85
85
|
|
|
86
86
|
**Bridge 1 — Reachability** is the front door. Can AI agents get to your content at all? Are you blocking specific crawlers without realizing it? This is the most actionable bridge for most products — many are unknowingly blocking GPTBot or ClaudeBot in their robots.txt.
|
|
87
87
|
|
|
88
|
-
**Bridge 2 — Standards** is the shared language. Do you speak the protocols AI agents understand? OpenAPI specs, GraphQL endpoints, XML sitemaps, markdown content negotiation, llms.txt, MCP endpoints, structured data — these are the machine-readable standards that let agents go beyond scraping your HTML. milieu also checks
|
|
88
|
+
**Bridge 2 — Standards** is the shared language. Do you speak the protocols AI agents understand? OpenAPI specs, GraphQL endpoints, XML sitemaps, markdown content negotiation, llms.txt, MCP endpoints, structured data — these are the machine-readable standards that let agents go beyond scraping your HTML. milieu also checks for [WebMCP](https://spec.modelcontextprotocol.io/) discovery at `/.well-known/mcp.json` and [A2A Agent Cards](https://google.github.io/A2A/) at `/.well-known/agent.json`.
|
|
89
89
|
|
|
90
90
|
**Bridge 3 — Separation** is the developer surface. Do you have a clear API boundary? Developer docs? SDKs? Webhooks? This is where agents look to determine if your product is something they can build with, not just read from.
|
|
91
91
|
|
|
92
|
-
**
|
|
92
|
+
**Bridge 4 — Schema** evaluates the quality of your OpenAPI spec from an agent's perspective. Having a spec is necessary (Bridge 2), but having a *good* spec is what lets agents actually call your API correctly. milieu checks whether your operations have `operationId` (the function name agents use), whether request/response schemas define types, whether error responses have structured schemas, whether required fields are declared, and whether fields have descriptions. When no spec is found, each check explains what the agent loses — for example, "without operation IDs, agents cannot map API capabilities to callable functions."
|
|
93
|
+
|
|
94
|
+
**Bridge 5 — Context** assesses the operational signals an agent needs to use your API reliably. This includes rate-limit headers (so agents can pace requests), API versioning (so agents can target a stable version), Terms of Service (so agents can verify permitted use), contact info, and `agents.json` at `/.well-known/`.
|
|
95
|
+
|
|
96
|
+
### Auth legibility
|
|
97
|
+
|
|
98
|
+
Bridge 5 introduces two checks that together answer: **how well does your API guide an unauthenticated agent toward successful authentication?**
|
|
99
|
+
|
|
100
|
+
An agent's first encounter with any API is unauthenticated. The agent discovers the spec, reads the auth requirements, obtains credentials, then makes authenticated calls. Milieu tests both sides of this:
|
|
101
|
+
|
|
102
|
+
- **Auth clarity** (spec-level): Are `securitySchemes` defined? Do they have descriptions? Are they applied to operations? This tells agents *how* to authenticate before they try.
|
|
103
|
+
|
|
104
|
+
- **Auth legibility** (runtime): When an agent hits a protected endpoint without credentials, how helpful is the 401/403 response? milieu checks for three signals:
|
|
105
|
+
- `WWW-Authenticate` header — tells the agent which auth scheme to use
|
|
106
|
+
- Structured JSON error body — the agent can parse the rejection
|
|
107
|
+
- Documentation URL in the error body — the agent can self-onboard
|
|
108
|
+
|
|
109
|
+
An API that returns `{"error": "unauthorized", "docs_url": "https://docs.example.com/auth"}` with a `WWW-Authenticate: Bearer` header scores full marks. An API that returns an HTML login page scores zero — the agent has no idea what to do next.
|
|
93
110
|
|
|
94
111
|
### Crawler policies
|
|
95
112
|
|
|
@@ -147,11 +164,15 @@ These explanations also appear in `--json` output as a `why` field on every chec
|
|
|
147
164
|
|
|
148
165
|
## How scoring works
|
|
149
166
|
|
|
150
|
-
The **overall score** is the average of scored bridges (
|
|
167
|
+
The **overall score** is the average of scored bridges (Bridges 1, 2, 4, and 5). Bridge 3 reports detection status only and is excluded from the average.
|
|
168
|
+
|
|
169
|
+
**Bridges 1, 2, and 4** use equal-weight scoring: each check contributes **pass = 1**, **partial = 0.5**, **fail = 0**. Bridge score = `(points / total_checks) * 100`. Thresholds: ≥80 = pass, ≥40 = partial, <40 = fail.
|
|
170
|
+
|
|
171
|
+
**Bridge 5** uses weighted scoring to reflect real-world importance to agents. Rate-limit headers and auth checks carry more weight than contact info. Thresholds are lower (≥60 = pass, ≥30 = partial) because governance signals are nascent — few sites implement all of them today.
|
|
151
172
|
|
|
152
|
-
|
|
173
|
+
A "partial" means the signal exists but is incomplete: an OpenAPI spec served as YAML (detected but not fully parseable), a 401 response with a JSON body but no `WWW-Authenticate` header, or a robots.txt with valid structure but no explicit allow/disallow rules.
|
|
153
174
|
|
|
154
|
-
|
|
175
|
+
Bridge 4 returns all-fail when no OpenAPI spec is detected, with a specific message per check explaining what the agent loses. Bridge 5 still runs most of its checks (rate limits, auth legibility, agents.json, versioning via headers) even without a spec — governance signals exist independently.
|
|
155
176
|
|
|
156
177
|
All checks are reproducible: same product surface state produces the same score every time.
|
|
157
178
|
|
|
@@ -169,12 +190,12 @@ const options: ScanOptions = {
|
|
|
169
190
|
|
|
170
191
|
const result = await scan("https://petstore.swagger.io", options);
|
|
171
192
|
|
|
172
|
-
console.log(result.overallScore); // number (average of
|
|
193
|
+
console.log(result.overallScore); // number (average of Bridges 1, 2, 4, 5)
|
|
173
194
|
console.log(result.overallScoreLabel); // "pass" | "partial" | "fail"
|
|
174
195
|
console.log(result.bridges); // 5-element tuple of BridgeResult
|
|
175
196
|
```
|
|
176
197
|
|
|
177
|
-
> **Note:** `result.bridges` always returns 5 elements. Bridges 1
|
|
198
|
+
> **Note:** `result.bridges` always returns 5 elements. Bridges 1, 2, 4, and 5 have numeric scores. Bridge 3 has `score: null` (detection inventory). Handle nulls when mapping:
|
|
178
199
|
>
|
|
179
200
|
> ```typescript
|
|
180
201
|
> const scoredBridges = result.bridges.filter(b => b.score !== null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-json.d.ts","sourceRoot":"","sources":["../../../src/bridges/context/agents-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGjD,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAYvF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { httpGet } from "../../utils/http-client.js";
|
|
2
|
+
export async function checkAgentsJson(baseUrl, timeout) {
|
|
3
|
+
const id = "context_agents_json";
|
|
4
|
+
const label = "agents.json";
|
|
5
|
+
const url = `${baseUrl}/.well-known/agents.json`;
|
|
6
|
+
const result = await httpGet(url, { timeout: Math.min(timeout ?? 10000, 3000), headers: { Accept: "application/json" } });
|
|
7
|
+
if (!result.ok)
|
|
8
|
+
return { id, label, status: "fail", detail: "No agents.json found at /.well-known/agents.json", data: { url, statusCode: result.error.statusCode ?? null } };
|
|
9
|
+
try {
|
|
10
|
+
JSON.parse(result.body);
|
|
11
|
+
return { id, label, status: "pass", detail: "agents.json found with valid JSON", data: { url, statusCode: result.status } };
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return { id, label, status: "partial", detail: "agents.json found but response is not valid JSON", data: { url, statusCode: result.status } };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=agents-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-json.js","sourceRoot":"","sources":["../../../src/bridges/context/agents-json.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;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,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,GAAG,KAAK,CA2B3E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { collectOperations } from "../schema/oas-types.js";
|
|
2
|
+
export function checkAuthClarity(spec) {
|
|
3
|
+
const id = "context_auth_clarity";
|
|
4
|
+
const label = "Auth Clarity";
|
|
5
|
+
if (!spec) {
|
|
6
|
+
return { id, label, status: "fail", detail: "No spec available — agents cannot discover how to authenticate without documented security schemes", data: { schemesCount: 0, withDescription: 0, securityApplied: false } };
|
|
7
|
+
}
|
|
8
|
+
const schemes = spec.components?.securitySchemes ?? spec.securityDefinitions ?? {};
|
|
9
|
+
const entries = Object.entries(schemes);
|
|
10
|
+
const schemesCount = entries.length;
|
|
11
|
+
if (schemesCount === 0) {
|
|
12
|
+
return { id, label, status: "fail", detail: "No security schemes defined in spec", data: { schemesCount: 0, withDescription: 0, securityApplied: false } };
|
|
13
|
+
}
|
|
14
|
+
const withDescription = entries.filter(([, s]) => typeof s.description === "string" && s.description.trim() !== "").length;
|
|
15
|
+
const hasGlobalSecurity = Array.isArray(spec.security) && spec.security.length > 0;
|
|
16
|
+
let hasPerOpSecurity = false;
|
|
17
|
+
if (!hasGlobalSecurity) {
|
|
18
|
+
const ops = collectOperations(spec);
|
|
19
|
+
hasPerOpSecurity = ops.some(([, , op]) => Array.isArray(op.security) && op.security.length > 0);
|
|
20
|
+
}
|
|
21
|
+
const securityApplied = hasGlobalSecurity || hasPerOpSecurity;
|
|
22
|
+
if (securityApplied && withDescription === schemesCount) {
|
|
23
|
+
return { id, label, status: "pass", detail: `${schemesCount} auth schemes defined, all with descriptions, security applied`, data: { schemesCount, withDescription, securityApplied } };
|
|
24
|
+
}
|
|
25
|
+
if (securityApplied && withDescription < schemesCount) {
|
|
26
|
+
return { id, label, status: "partial", detail: `${schemesCount} auth schemes defined but ${schemesCount - withDescription} lack descriptions`, data: { schemesCount, withDescription, securityApplied } };
|
|
27
|
+
}
|
|
28
|
+
return { id, label, status: "partial", detail: `${schemesCount} auth schemes defined but security not applied to operations`, data: { schemesCount, withDescription, securityApplied: false } };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=auth-clarity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-clarity.js","sourceRoot":"","sources":["../../../src/bridges/context/auth-clarity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,UAAU,gBAAgB,CAAC,IAAmC;IAClE,MAAM,EAAE,GAAG,sBAAsB,CAAC;IAClC,MAAM,KAAK,GAAG,cAAc,CAAC;IAC7B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,oGAAoG,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,CAAC;IAC5N,CAAC;IACD,MAAM,OAAO,GAA6C,IAAI,CAAC,UAAU,EAAE,eAAe,IAAI,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC;IAC7H,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IACpC,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,qCAAqC,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,CAAC;IAC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eAAe,EAAE,EAAE,CAAC;IAC5M,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,YAAY,8DAA8D,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,CAAC;AAClM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-legibility.d.ts","sourceRoot":"","sources":["../../../src/bridges/context/auth-legibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAsB9D,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAmC1E"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { httpGet } from "../../utils/http-client.js";
|
|
2
|
+
import { collectOperations } from "../schema/oas-types.js";
|
|
3
|
+
const DOCS_URL_KEYS = ["docs_url", "documentation_url", "help_url", "docs", "documentation", "help", "more_info"];
|
|
4
|
+
function findProtectedGetPath(spec) {
|
|
5
|
+
if (!spec)
|
|
6
|
+
return null;
|
|
7
|
+
const ops = collectOperations(spec);
|
|
8
|
+
for (const [path, method, op] of ops) {
|
|
9
|
+
if (method !== "get")
|
|
10
|
+
continue;
|
|
11
|
+
if (Array.isArray(op.security) && op.security.length > 0)
|
|
12
|
+
return path;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(spec.security) && spec.security.length > 0) {
|
|
15
|
+
for (const [path, method] of ops) {
|
|
16
|
+
if (method === "get")
|
|
17
|
+
return path;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export async function checkAuthLegibility(ctx) {
|
|
23
|
+
const id = "context_auth_legibility";
|
|
24
|
+
const label = "Auth Legibility";
|
|
25
|
+
const spec = ctx.shared.openApiSpec;
|
|
26
|
+
const protectedPath = findProtectedGetPath(spec);
|
|
27
|
+
const probeUrl = protectedPath ? `${ctx.baseUrl}${protectedPath}` : `${ctx.baseUrl}/api`;
|
|
28
|
+
const probeTimeout = Math.min(ctx.options.timeout ?? 10000, 5000);
|
|
29
|
+
const result = await httpGet(probeUrl, { timeout: probeTimeout });
|
|
30
|
+
if (!result.ok) {
|
|
31
|
+
return { id, label, status: "fail", detail: `Could not reach ${probeUrl} to test auth response quality`, data: { probeUrl, signals: [] } };
|
|
32
|
+
}
|
|
33
|
+
const status = result.status;
|
|
34
|
+
if (status >= 200 && status < 300) {
|
|
35
|
+
return { id, label, status: "partial", detail: "Endpoint does not require authentication — auth legibility could not be tested", data: { probeUrl, signals: ["no_auth_required"] } };
|
|
36
|
+
}
|
|
37
|
+
if (status === 401 || status === 403) {
|
|
38
|
+
const signals = [];
|
|
39
|
+
const contentType = (result.headers["content-type"] ?? "").split(";")[0].trim().toLowerCase();
|
|
40
|
+
if (result.headers["www-authenticate"])
|
|
41
|
+
signals.push("www-authenticate");
|
|
42
|
+
let isJson = false;
|
|
43
|
+
if (contentType === "application/json" || contentType === "application/problem+json") {
|
|
44
|
+
try {
|
|
45
|
+
JSON.parse(result.body);
|
|
46
|
+
isJson = true;
|
|
47
|
+
signals.push("json_error_body");
|
|
48
|
+
}
|
|
49
|
+
catch { /* invalid JSON */ }
|
|
50
|
+
}
|
|
51
|
+
if (isJson) {
|
|
52
|
+
try {
|
|
53
|
+
const parsed = JSON.parse(result.body);
|
|
54
|
+
const hasDocsUrl = Object.entries(parsed).some(([key, val]) => DOCS_URL_KEYS.includes(key.toLowerCase()) && typeof val === "string" && val.startsWith("http"));
|
|
55
|
+
if (hasDocsUrl)
|
|
56
|
+
signals.push("docs_url");
|
|
57
|
+
}
|
|
58
|
+
catch { /* already handled */ }
|
|
59
|
+
}
|
|
60
|
+
if (signals.length >= 3)
|
|
61
|
+
return { id, label, status: "pass", detail: `API guides unauthenticated agents toward auth: ${signals.join(", ")}`, data: { probeUrl, signals } };
|
|
62
|
+
if (signals.length >= 1)
|
|
63
|
+
return { id, label, status: "partial", detail: `API rejects with some guidance (${signals.join(", ")}) but missing: ${["www-authenticate", "json_error_body", "docs_url"].filter((s) => !signals.includes(s)).join(", ")}`, data: { probeUrl, signals } };
|
|
64
|
+
return { id, label, status: "fail", detail: "API returns opaque rejection with no guidance for agents", data: { probeUrl, signals: [] } };
|
|
65
|
+
}
|
|
66
|
+
return { id, label, status: "fail", detail: `Unexpected status ${status} — could not assess auth legibility`, data: { probeUrl, signals: [] } };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=auth-legibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-legibility.js","sourceRoot":"","sources":["../../../src/bridges/context/auth-legibility.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AAElH,SAAS,oBAAoB,CAAC,IAAmC;IAC/D,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,MAAM,KAAK,KAAK;YAAE,SAAS;QAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;IACxE,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,Q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ot":"","sources":["../../../src/bridges/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAS,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAgC5E,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAgC9E"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { checkRateLimitHeaders } from "./rate-limits.js";
|
|
2
|
+
import { checkAuthClarity } from "./auth-clarity.js";
|
|
3
|
+
import { checkAuthLegibility } from "./auth-legibility.js";
|
|
4
|
+
import { checkTosUrl, checkContactInfo } from "./tos-contact.js";
|
|
5
|
+
import { checkVersioningSignal } from "./versioning.js";
|
|
6
|
+
import { checkAgentsJson } from "./agents-json.js";
|
|
7
|
+
const CHECK_WEIGHTS = {
|
|
8
|
+
context_rate_limit_headers: 3,
|
|
9
|
+
context_auth_clarity: 3,
|
|
10
|
+
context_auth_legibility: 3,
|
|
11
|
+
context_tos_url: 2,
|
|
12
|
+
context_versioning_signal: 2,
|
|
13
|
+
context_contact_info: 1,
|
|
14
|
+
context_agents_json: 2,
|
|
15
|
+
};
|
|
16
|
+
const MAX_POINTS = 16;
|
|
17
|
+
function calculateWeightedScore(checks) {
|
|
18
|
+
let earned = 0;
|
|
19
|
+
for (const check of checks) {
|
|
20
|
+
const weight = CHECK_WEIGHTS[check.id] ?? 1;
|
|
21
|
+
if (check.status === "pass")
|
|
22
|
+
earned += weight;
|
|
23
|
+
else if (check.status === "partial")
|
|
24
|
+
earned += weight * 0.5;
|
|
25
|
+
}
|
|
26
|
+
const score = Math.round((earned / MAX_POINTS) * 100);
|
|
27
|
+
const scoreLabel = score >= 60 ? "pass" : score >= 30 ? "partial" : "fail";
|
|
28
|
+
return { score, scoreLabel };
|
|
29
|
+
}
|
|
30
|
+
export async function runContextBridge(ctx) {
|
|
31
|
+
const start = performance.now();
|
|
32
|
+
const spec = ctx.shared.openApiSpec;
|
|
33
|
+
const llmsTxtBody = ctx.shared.llmsTxtBody ?? null;
|
|
34
|
+
// Rate-limit probe first — populates ctx.shared.contextProbeHeaders
|
|
35
|
+
const rateLimitCheck = await checkRateLimitHeaders(ctx);
|
|
36
|
+
const contextProbeHeaders = ctx.shared.contextProbeHeaders ?? {};
|
|
37
|
+
// Auth legibility + agents.json probes in parallel
|
|
38
|
+
const [authLegibilityCheck, agentsJsonCheck] = await Promise.all([
|
|
39
|
+
checkAuthLegibility(ctx),
|
|
40
|
+
checkAgentsJson(ctx.baseUrl, ctx.options.timeout),
|
|
41
|
+
]);
|
|
42
|
+
// Synchronous checks
|
|
43
|
+
const authClarityCheck = checkAuthClarity(spec);
|
|
44
|
+
const tosCheck = checkTosUrl(spec, llmsTxtBody);
|
|
45
|
+
const versioningCheck = checkVersioningSignal(spec, contextProbeHeaders);
|
|
46
|
+
const contactCheck = checkContactInfo(spec);
|
|
47
|
+
const checks = [
|
|
48
|
+
rateLimitCheck, authClarityCheck, authLegibilityCheck,
|
|
49
|
+
tosCheck, versioningCheck, contactCheck, agentsJsonCheck,
|
|
50
|
+
];
|
|
51
|
+
const { score, scoreLabel } = calculateWeightedScore(checks);
|
|
52
|
+
return {
|
|
53
|
+
id: 5, name: "Context", status: "evaluated", score, scoreLabel, checks,
|
|
54
|
+
durationMs: Math.round(performance.now() - start),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridges/context/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,qBAAqB,E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appings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAmB9D,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAwB5E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { httpGet } from "../../utils/http-client.js";
|
|
2
|
+
import { collectOperations } from "../schema/oas-types.js";
|
|
3
|
+
const RATE_LIMIT_HEADERS = ["ratelimit-limit", "x-ratelimit-limit", "x-rate-limit-limit"];
|
|
4
|
+
const RETRY_AFTER = "retry-after";
|
|
5
|
+
function findSimpleGetPath(spec) {
|
|
6
|
+
if (!spec)
|
|
7
|
+
return null;
|
|
8
|
+
const ops = collectOperations(spec);
|
|
9
|
+
for (const [path, method, op] of ops) {
|
|
10
|
+
if (method !== "get")
|
|
11
|
+
continue;
|
|
12
|
+
const hasRequiredParams = op.parameters?.some((p) => p.required) ?? false;
|
|
13
|
+
if (!hasRequiredParams)
|
|
14
|
+
return path;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export async function checkRateLimitHeaders(ctx) {
|
|
19
|
+
const id = "context_rate_limit_headers";
|
|
20
|
+
const label = "Rate Limit Headers";
|
|
21
|
+
const spec = ctx.shared.openApiSpec;
|
|
22
|
+
const simplePath = findSimpleGetPath(spec);
|
|
23
|
+
const probeUrl = simplePath ? `${ctx.baseUrl}${simplePath}` : `${ctx.baseUrl}/api`;
|
|
24
|
+
const probeTimeout = Math.min(ctx.options.timeout ?? 10000, 5000);
|
|
25
|
+
const result = await httpGet(probeUrl, { timeout: probeTimeout });
|
|
26
|
+
if (!result.ok) {
|
|
27
|
+
ctx.shared.contextProbeHeaders = {};
|
|
28
|
+
return { id, label, status: "fail", detail: `Could not reach ${probeUrl} to check rate-limit headers`, data: { probeUrl, headerFound: null } };
|
|
29
|
+
}
|
|
30
|
+
ctx.shared.contextProbeHeaders = result.headers;
|
|
31
|
+
for (const header of RATE_LIMIT_HEADERS) {
|
|
32
|
+
const value = result.headers[header];
|
|
33
|
+
if (value !== undefined) {
|
|
34
|
+
return { id, label, status: "pass", detail: `Rate-limit header found: ${header}: ${value}`, data: { probeUrl, headerFound: header } };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const retryAfter = result.headers[RETRY_AFTER];
|
|
38
|
+
if (retryAfter !== undefined) {
|
|
39
|
+
return { id, label, status: "partial", detail: `Only retry-after header found (no rate ceiling): ${retryAfter}`, data: { probeUrl, headerFound: RETRY_AFTER } };
|
|
40
|
+
}
|
|
41
|
+
return { id, label, status: "fail", detail: "No rate-limit headers found in response", data: { probeUrl, headerFound: null } };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=rate-limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limits.js","sourceRoot":"","sources":["../../../src/bridges/context/rate-limits.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,kBAAkB,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;AAC1F,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,SAAS,iBAAiB,CAAC,IAAmC;IAC5D,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,MAAM,KAAK,KAAK;YAAE,SAAS;QAC/B,MAAM,iBAAiB,GAAG,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;QAC1E,IA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AE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,4BAA4B,MAAM,KAAK,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;QACxI,CAAC;IACH,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,oDAAoD,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC;IAClK,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,yCAAyC,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;AACjI,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Check } from "../../core/types.js";
|
|
2
|
+
import type { ParsedOpenApiSpec } from "../schema/oas-types.js";
|
|
3
|
+
export declare function checkTosUrl(spec: ParsedOpenApiSpec | undefined, llmsTxtBody: string | null): Check;
|
|
4
|
+
export declare function checkContactInfo(spec: ParsedOpenApiSpec | undefined): Check;
|
|
5
|
+
//# sourceMappingURL=tos-contact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tos-contact.d.ts","sourceRoot":"","sources":["../../../src/bridges/context/tos-contact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAalG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,GAAG,KAAK,CAa3E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function checkTosUrl(spec, llmsTxtBody) {
|
|
2
|
+
const id = "context_tos_url";
|
|
3
|
+
const label = "Terms of Service URL";
|
|
4
|
+
const specTos = spec?.info?.termsOfService;
|
|
5
|
+
if (typeof specTos === "string" && specTos.trim() !== "") {
|
|
6
|
+
return { id, label, status: "pass", detail: `Terms of Service URL found in spec: ${specTos}`, data: { source: "spec", url: specTos } };
|
|
7
|
+
}
|
|
8
|
+
if (llmsTxtBody) {
|
|
9
|
+
const urlPattern = /https?:\/\/\S+(?:terms|tos|legal)\S*/i;
|
|
10
|
+
const match = llmsTxtBody.match(urlPattern);
|
|
11
|
+
if (match)
|
|
12
|
+
return { id, label, status: "partial", detail: `Terms of Service URL found in llms.txt: ${match[0]}`, data: { source: "llms.txt", url: match[0] } };
|
|
13
|
+
}
|
|
14
|
+
return { id, label, status: "fail", detail: "No Terms of Service URL found", data: { source: null, url: null } };
|
|
15
|
+
}
|
|
16
|
+
export function checkContactInfo(spec) {
|
|
17
|
+
const id = "context_contact_info";
|
|
18
|
+
const label = "Contact Info";
|
|
19
|
+
const contact = spec?.info?.contact;
|
|
20
|
+
const email = typeof contact?.email === "string" && contact.email.trim() !== "" ? contact.email : null;
|
|
21
|
+
const url = typeof contact?.url === "string" && contact.url.trim() !== "" ? contact.url : null;
|
|
22
|
+
if (email || url) {
|
|
23
|
+
const parts = [];
|
|
24
|
+
if (email)
|
|
25
|
+
parts.push(`email: ${email}`);
|
|
26
|
+
if (url)
|
|
27
|
+
parts.push(`url: ${url}`);
|
|
28
|
+
return { id, label, status: "pass", detail: `Contact info found in spec: ${parts.join(", ")}`, data: { email, url } };
|
|
29
|
+
}
|
|
30
|
+
return { id, label, status: "fail", detail: "No contact info found in spec", data: { email: null, url: null } };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=tos-contact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tos-contact.js","sourceRoot":"","sources":["../../../src/bridges/context/tos-contact.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,WAAW,CAAC,IAAmC,EAAE,WAA0B;IACzF,MAAM,EAAE,GAAG,iBAAiB,CAAC;IAC7B,MAAM,KAAK,GAAG,sBAAsB,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC;IAC3C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,uCAAuC,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;IACzI,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,UAAU,GAAG,uCAAuC,CAAC;QAC3D,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,KAAK;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,2CAA2C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACjK,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,+BAA+B,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;AACnH,CAAC;AAED,MAAM,UAAU,gBA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"../schema/oas-types.js";
|
|
3
|
+
export declare function checkVersioningSignal(spec: ParsedOpenApiSpec | undefined, contextProbeHeaders: Record<string, string>): Check;
|
|
4
|
+
//# sourceMappingURL=versioning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../../../src/bridges/context/versioning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EAAE,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,KAAK,CAiB7H"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const VERSION_HEADERS = ["x-api-version", "api-version", "x-version"];
|
|
2
|
+
export function checkVersioningSignal(spec, contextProbeHeaders) {
|
|
3
|
+
const id = "context_versioning_signal";
|
|
4
|
+
const label = "Versioning Signal";
|
|
5
|
+
if (spec?.paths) {
|
|
6
|
+
for (const path of Object.keys(spec.paths)) {
|
|
7
|
+
if (/^\/v\d+\//.test(path))
|
|
8
|
+
return { id, label, status: "pass", detail: `Path-based versioning detected: ${path}`, data: { signal: "path", value: path } };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
for (const header of VERSION_HEADERS) {
|
|
12
|
+
const value = contextProbeHeaders[header];
|
|
13
|
+
if (value !== undefined)
|
|
14
|
+
return { id, label, status: "pass", detail: `Version header found: ${header}: ${value}`, data: { signal: "header", value: `${header}: ${value}` } };
|
|
15
|
+
}
|
|
16
|
+
const specVersion = spec?.info?.version;
|
|
17
|
+
if (typeof specVersion === "string" && specVersion.trim() !== "") {
|
|
18
|
+
return { id, label, status: "partial", detail: `Spec info.version found: ${specVersion}`, data: { signal: "spec_info", value: specVersion } };
|
|
19
|
+
}
|
|
20
|
+
return { id, label, status: "fail", detail: "No versioning signal found", data: { signal: null, value: null } };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=versioning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versioning.js","sourceRoot":"","sources":["../../../src/bridges/context/versioning.ts"],"names":[],"mappings":"AAGA,MAAM,eAAe,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAEtE,MAAM,UAAU,qBAAqB,CAAC,IAAmC,EAAE,mBAA2C;IACpH,MAAM,EAAE,GAAG,2BAA2B,CAAC;IACvC,MAAM,KAAK,GAAG,mBAAmB,CAAC;IAClC,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;QAChB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3C,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;gBAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,mCAAmC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;QAC7J,CAAC;IACH,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,yBAAyB,MAAM,KAAK,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,KAAK,EAAE,EAAE,EAAE,CAAC;IAC/K,CAAC;IACD,MAAM,WAAW,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;IACxC,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACjE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,4BAA4B,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC;IAChJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,4BAA4B,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;AAClH,CAAC"}
|
package/dist/bridges/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { runReachabilityBridge } from "./reachability/index.js";
|
|
2
2
|
export { runStandardsBridge } from "./standards/index.js";
|
|
3
3
|
export { runSeparationBridge } from "./separation/index.js";
|
|
4
|
-
export {
|
|
4
|
+
export { runSchemaBridge } from "./schema/index.js";
|
|
5
|
+
export { runContextBridge } from "./context/index.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/bridges/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Bridge check implementations (Phases 3-5)
|
|
2
1
|
export { runReachabilityBridge } from "./reachability/index.js";
|
|
3
2
|
export { runStandardsBridge } from "./standards/index.js";
|
|
4
3
|
export { runSeparationBridge } from "./separation/index.js";
|
|
5
|
-
export {
|
|
4
|
+
export { runSchemaBridge } from "./schema/index.js";
|
|
5
|
+
export { runContextBridge } from "./context/index.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptions.d.ts","sourceRoot":"","sources":["../../../src/bridges/schema/descriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,GAAG,KAAK,CA0C5E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { collectOperations } from "./oas-types.js";
|
|
2
|
+
export function checkDescriptions(spec) {
|
|
3
|
+
const id = "schema_descriptions";
|
|
4
|
+
const label = "Field Descriptions";
|
|
5
|
+
const ops = collectOperations(spec);
|
|
6
|
+
const items = [];
|
|
7
|
+
let queryCount = 0;
|
|
8
|
+
let bodySchemaCount = 0;
|
|
9
|
+
for (const [, , op] of ops) {
|
|
10
|
+
if (op.parameters) {
|
|
11
|
+
for (const param of op.parameters) {
|
|
12
|
+
if (param.in === "path") {
|
|
13
|
+
items.push({ hasDescription: typeof param.description === "string" && param.description.trim() !== "" });
|
|
14
|
+
}
|
|
15
|
+
else if (param.in === "query" && queryCount < 20) {
|
|
16
|
+
queryCount++;
|
|
17
|
+
items.push({ hasDescription: typeof param.description === "string" && param.description.trim() !== "" });
|
|
18
|
+
}
|
|
19
|
+
if (items.length >= 30)
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (items.length >= 30)
|
|
24
|
+
break;
|
|
25
|
+
if (op.requestBody?.content && bodySchemaCount < 3) {
|
|
26
|
+
for (const mediaType of Object.values(op.requestBody.content)) {
|
|
27
|
+
if (bodySchemaCount >= 3)
|
|
28
|
+
break;
|
|
29
|
+
const schema = mediaType?.schema;
|
|
30
|
+
if (!schema?.properties)
|
|
31
|
+
continue;
|
|
32
|
+
bodySchemaCount++;
|
|
33
|
+
for (const prop of Object.values(schema.properties)) {
|
|
34
|
+
items.push({ hasDescription: typeof prop.description === "string" && prop.description.trim() !== "" });
|
|
35
|
+
if (items.length >= 30)
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
if (items.length >= 30)
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (items.length >= 30)
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
const sampled = items.length;
|
|
46
|
+
if (sampled === 0)
|
|
47
|
+
return { id, label, status: "pass", detail: "No parameters or properties to evaluate", data: { sampled: 0, withDescription: 0 } };
|
|
48
|
+
const withDescription = items.filter((i) => i.hasDescription).length;
|
|
49
|
+
const ratio = withDescription / sampled;
|
|
50
|
+
if (ratio >= 0.8)
|
|
51
|
+
return { id, label, status: "pass", detail: `${withDescription} of ${sampled} sampled fields have descriptions`, data: { sampled, withDescription } };
|
|
52
|
+
if (ratio >= 0.4)
|
|
53
|
+
return { id, label, status: "partial", detail: `${withDescription} of ${sampled} sampled fields have descriptions`, data: { sampled, withDescription } };
|
|
54
|
+
return { id, label, status: "fail", detail: `Only ${withDescription} of ${sampled} sampled fields have descriptions`, data: { sampled, withDescription } };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=descriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../../../src/bridges/schema/descriptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,UAAU,iBAAiB,CAAC,IAAmC;IACnE,MAAM,EAAE,GAAG,qBAAqB,CAAC;IACjC,MAAM,KAAK,GAAG,oBAAoB,CAAC;IACnC,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,KAAK,GAAuC,EAAE,CAAC;IACrD,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,KAAK,MAAM,CAAC,EAAE,AAAD,EAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;QAC3B,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;YAClB,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;gBAClC,IAAI,KAAK,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;oBACxB,KAAK,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC3G,CAAC;qBAAM,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO,IAAI,UAAU,GAAG,EAAE,EAAE,CAAC;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