agent-customs 1.2.4 → 1.2.6
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 +24 -11
- package/bin/agent-customs.mjs +8 -1
- package/package.json +1 -1
- package/site/customs/inspect.js +81 -19
- package/site/customs/protocols.js +4 -0
- package/tools/mcp-server.mjs +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
<a href="https://github.com/montbaga/agent-customs/actions/workflows/pages.yml"><img alt="Tests and publish" src="https://github.com/montbaga/agent-customs/actions/workflows/pages.yml/badge.svg"></a>
|
|
25
25
|
<a href="#how-well-it-works"><img alt="Bench: 88.8% blocked, 0% false blocks" src="https://img.shields.io/badge/bench-88.8%25_blocked_%C2%B7_0%25_FP-c8f03c?labelColor=0c1d18"></a>
|
|
26
|
-
<a href="#try-it-yourself"><img alt="Tests:
|
|
26
|
+
<a href="#try-it-yourself"><img alt="Tests: 234 passing" src="https://img.shields.io/badge/tests-234_passing-ece4d3?labelColor=0c1d18"></a>
|
|
27
27
|
<a href="LICENSE.md"><img alt="License: Apache 2.0" src="https://img.shields.io/badge/license-Apache%202.0-c8f03c?labelColor=0c1d18"></a>
|
|
28
28
|
<img alt="Dependencies: none" src="https://img.shields.io/badge/dependencies-none-ece4d3?labelColor=0c1d18">
|
|
29
29
|
<a href="#lets-talk"><img alt="Built by Monty Bagati" src="https://img.shields.io/badge/say_hello-Monty_Bagati-c8f03c?labelColor=132d25"></a>
|
|
@@ -62,8 +62,8 @@ Pick one of four ways. Each works with any site made with Cognizant's `agentify-
|
|
|
62
62
|
|
|
63
63
|
```html
|
|
64
64
|
<script type="module"
|
|
65
|
-
src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.
|
|
66
|
-
integrity="sha384-
|
|
65
|
+
src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.6/dist/agent-customs.js"
|
|
66
|
+
integrity="sha384-WMl/1x9IOgwlSJuAl5nKo4CtY/x421qU9tkM8wWXyzImP1odffmefCeSm3lfLZgj"
|
|
67
67
|
crossorigin="anonymous"></script>
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -76,7 +76,7 @@ Pick one of four ways. Each works with any site made with Cognizant's `agentify-
|
|
|
76
76
|
```js
|
|
77
77
|
// At the top of site.js
|
|
78
78
|
import { installCustomsGuard }
|
|
79
|
-
from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.
|
|
79
|
+
from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.6/site/customs/guard.js";
|
|
80
80
|
|
|
81
81
|
// Right after boot()
|
|
82
82
|
installCustomsGuard(booted.engine, { strict: true });
|
|
@@ -173,16 +173,16 @@ Each way to add the guard, step by step. All of them work with any site built wi
|
|
|
173
173
|
**1. One line (easiest).** Paste this into your page, above your other `<script>` tags. The guard switches itself on when your assistant starts.
|
|
174
174
|
|
|
175
175
|
```html
|
|
176
|
-
<script type="module" src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.
|
|
176
|
+
<script type="module" src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.6/dist/agent-customs.js" integrity="sha384-WMl/1x9IOgwlSJuAl5nKo4CtY/x421qU9tkM8wWXyzImP1odffmefCeSm3lfLZgj" crossorigin="anonymous"></script>
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
`integrity` is the file's fingerprint. If the file were ever changed, on the CDN or on the way, the browser would refuse to run it. The whole guard is in this one file ([`dist/agent-customs.js`](dist/agent-customs.js), built by `npm run bundle`), so the fingerprint covers all of it. `@v1.2.
|
|
179
|
+
`integrity` is the file's fingerprint. If the file were ever changed, on the CDN or on the way, the browser would refuse to run it. The whole guard is in this one file ([`dist/agent-customs.js`](dist/agent-customs.js), built by `npm run bundle`), so the fingerprint covers all of it. `@v1.2.6` is a fixed version; to update, take the new line from the next release. Above the other tags, the browser runs it before your page starts the assistant, and chats wait until the guard is on. If your page has a `Content-Security-Policy` with `script-src`, add `https://cdn.jsdelivr.net` to it.
|
|
180
180
|
|
|
181
181
|
**2. Two lines, with your own settings.** Load the guard from the same release and pass any of the *Guard options* below. A browser cannot check a fingerprint on an `import`, so for that use option 3 or 4.
|
|
182
182
|
|
|
183
183
|
```js
|
|
184
184
|
// At the top of site.js
|
|
185
|
-
import { installCustomsGuard } from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.
|
|
185
|
+
import { installCustomsGuard } from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.6/site/customs/guard.js";
|
|
186
186
|
|
|
187
187
|
// Right after the boot(...) call
|
|
188
188
|
installCustomsGuard(booted.engine, { strict: true });
|
|
@@ -239,7 +239,7 @@ Three ways in, fastest first:
|
|
|
239
239
|
<strong>1 · The test suite</strong><br><br>
|
|
240
240
|
No browser and no API key:<br><br>
|
|
241
241
|
<code>npm test</code><br><br>
|
|
242
|
-
|
|
242
|
+
234 tests: the attack sentences, every frozen attack set, five batches of real MCP servers and A2A cards, the locks, the canary, the signed stamps, the benchmark, the command line tool, the MCP server, the extension, the practice site, the key vault, the one-line install and its one-file build.
|
|
243
243
|
</td>
|
|
244
244
|
<td width="33.3%" valign="top">
|
|
245
245
|
<strong>2 · The inspection desk (no key)</strong><br><br>
|
|
@@ -494,7 +494,7 @@ Needs Node 22 or newer and no npm packages.
|
|
|
494
494
|
```sh
|
|
495
495
|
git clone https://github.com/montbaga/agent-customs.git
|
|
496
496
|
cd agent-customs
|
|
497
|
-
npm test #
|
|
497
|
+
npm test # 234 tests
|
|
498
498
|
npm run bench -- --verbose # the benchmark, with every flagged case
|
|
499
499
|
npm run check && npm run check:practice # both networks pass Cognizant's build check
|
|
500
500
|
node bin/agent-customs.mjs check site/samples/mcp-poisoned --sarif
|
|
@@ -588,7 +588,7 @@ node tools/set-origins.mjs --range https://agent-customs-range.github.io
|
|
|
588
588
|
|
|
589
589
|
`npm run smoke` drives Edge or Chrome headlessly against the local servers and fails on any page error. It starts the key vault on port 8090 if it is not running (`npm run serve:vault`), since a page on this computer looks for the vault there.
|
|
590
590
|
|
|
591
|
-
`npm run vault:check` checks the key vault end to end in a headless browser, with a stand-in AI service on this computer: a Groq or Otari key picks its own card, the page never holds the key, every AI request comes from the vault with the key, *Remember key* stores it only encrypted, a new visit starts locked, a wrong password does not open it, and *Forget* removes it.
|
|
591
|
+
`npm run vault:check` checks the key vault end to end in a headless browser, with a stand-in AI service on this computer: a Groq or Otari key picks its own card, the page never holds the key, every AI request comes from the vault with the key, *Remember key* stores it only encrypted, a new visit starts locked, a wrong password does not open it, and *Forget* removes it. It also runs *Connect with Otari* against a stand-in for otari.ai: a blocked window, a closed window, a cancel and two forged replies save nothing, and an approval saves the new key for the visit and chats with it. A key left in the page's own storage by the practice site is pointed out with the settings folded, and removed with one click.
|
|
592
592
|
|
|
593
593
|
---
|
|
594
594
|
|
|
@@ -601,8 +601,21 @@ This round fixed a weakness in how the rules handled their own exceptions, and i
|
|
|
601
601
|
- Two more languages. Dutch and Indonesian requests for passwords and card numbers are now read word by word. Takeover, chat-leak and "download and run" orders are caught in 14 languages.
|
|
602
602
|
- Honest numbers. False alarms on tools never seen before dropped from about 1 in 10 to about 1 in 18. New attack sets written after the changes were measured once before they were used. The details are in [How well it works](#how-well-it-works) and the [paper](PAPER.md#5--results).
|
|
603
603
|
|
|
604
|
+
**The terminal command gets its own window, and failed checks name their protocol (1.2.6).** When a site answers but the browser can't read it, the report now shows the command in a small terminal window with a *Copy* button, under the message instead of inside it. Paste it into PowerShell on Windows or Terminal on a Mac (it needs Node.js). In the report's JSON, the command is `verdict.command`. A failed check on an A2A Agent Card or an MCP file now shows *Google A2A* or *MCP Catalog* as its protocol, not *Open Agentic Web*, and an address where nothing was found shows no protocol.
|
|
605
|
+
|
|
606
|
+
**"Could not inspect" now says why, and the command line runs everywhere (1.2.5).** When the page could not read an address, it listed three possible reasons. It now finds the real one and says what to do:
|
|
607
|
+
- The site answered, but it sends no CORS header, so the browser kept the answer from the page. The message gives the command that checks it from a terminal instead: `npx -y agent-customs check <address>`.
|
|
608
|
+
- The address is a live MCP server (it ends in `/mcp` or `/sse`), which only MCP apps can talk to. The message asks for the server's `server.json`, which Agent Customs can read.
|
|
609
|
+
- Nothing answered, or the site was too slow. The message says which.
|
|
610
|
+
|
|
611
|
+
The command line printed nothing when it was started through a link. That is how `npx` and global installs start it on macOS and Linux, and how `npx` starts it inside this repository on Windows. It now compares the real file paths, so `check`, `verify` and `mcp` run however they are started. A failed check also prints its reason under the result line.
|
|
612
|
+
|
|
604
613
|
**Private data sent to another site is caught in any wording (1.2.4).** A QA tester found that a hotel tool asking for the guest's passport number and sending it to an outside address was only *Held for review*, without the leak finding (C-EXFIL). The leak check matched a short list of phrases, such as "send it to". It now looks for the private data and an address on another site together, with any verb that moves data, in any order: "share it with …", "log it at …", "it is forwarded to …", "send … the passport number", "make a request to … with it". Private data here means identity documents, card and bank details, passwords, one-time codes and the conversation. Of 30 wordings written before the change, 10 were denied before and 29 are now (the 30th, "verify it via …", is still held). The 870 real-world MCP servers and A2A cards in [`tests/fixtures/realworld`](tests/fixtures/realworld/) get exactly the same findings as before, and the benchmark results are unchanged.
|
|
605
614
|
|
|
615
|
+
**Connect with Otari, without copying a key.** On the *Other* card, the key vault now has a *Connect with Otari* button. It opens otari.ai in a small window. You sign in there and approve a key for Agent Customs with a spending limit you choose (otari.ai suggests $5 for 30 days). The key goes straight back to the key vault, and Agent Customs starts with it. The page never sees the key or the sign-in: the vault itself asks otari.ai for the key, and the one-time code is useless without a secret the vault keeps (OAuth with PKCE). Pasting a key still works for every service. See [how it works](vault/README.md#connect-with-otari).
|
|
616
|
+
|
|
617
|
+
**Old keys are easier to spot.** The practice site, and versions from before the key vault, keep keys in the browser's storage for `montbaga.github.io`, outside the vault. When such a key is still there, the AI model settings now show a banner even while they are folded, and *Delete old key* removes it.
|
|
618
|
+
|
|
606
619
|
The desk also has a new switch under the address box: **AI double-check**. When it is on, your own AI reads every network the rules clear, and every partner the Officer is about to call. It can only make a verdict stricter. If your AI flags something, *Cleared* becomes *Held for review*; if it finds nothing, the verdict stays as it was. Networks the rules already stopped are never sent to it, so they cost no tokens. The switch is off until you turn it on and uses the key you set on the Officer tab. While it is on, the network's public text goes to your AI provider. When your AI has read a network, a round seal countersigns the verdict stamp, and a flag quotes the sentence that worried it (only words the network really wrote are shown).
|
|
607
620
|
|
|
608
621
|
**Adding the guard now takes one line.** Paste one `<script>` tag into your page and the guard switches itself on, or install it with `npm install agent-customs`. See [Add the guard to your site](#add-it-to-your-site). The line carries a fingerprint (Subresource Integrity), so a browser refuses the file if it was ever changed; the whole guard is one file, so the fingerprint covers all of it.
|
|
@@ -680,7 +693,7 @@ The full picture, with diagrams, is in [**How it works**](ARCHITECTURE.md).
|
|
|
680
693
|
| [`PAPER.md`](PAPER.md) | The research note: threat model, method, results and limits |
|
|
681
694
|
| [`LICENSE.md`](LICENSE.md) | The license in plain words, with the full text |
|
|
682
695
|
| [`tools/`](tools/) | The MCP server (`mcp-server.mjs`), the benchmark and its frozen sets, the stamp signer, the local server, the builders and the smoke test |
|
|
683
|
-
| [`tests/`](tests/) |
|
|
696
|
+
| [`tests/`](tests/) | 234 tests, the frozen attack sets and the five batches of real-world snapshots |
|
|
684
697
|
| [`vendor/agentify-website/`](vendor/agentify-website/) | Cognizant's kit scripts and templates, unmodified |
|
|
685
698
|
|
|
686
699
|
</details>
|
package/bin/agent-customs.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// agent-customs CLI: inspect agent networks, verify certificates, run benchmarks, or serve MCP.
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
3
4
|
import { readFile, writeFile } from "node:fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -122,6 +123,7 @@ async function cmdCheck(positionals, flags, log) {
|
|
|
122
123
|
} else {
|
|
123
124
|
for (const r of reports) {
|
|
124
125
|
log.out(`${r.verdict.code.padEnd(10)} ${r.target?.url || "unknown"} (${r.conformance?.passed}/${r.conformance?.total} checks, ${r.identity?.short || "no hash"})`);
|
|
126
|
+
if (r.failure && r.verdict.summary) log.out(` ${r.verdict.summary}`);
|
|
125
127
|
for (const f of r.findings || []) {
|
|
126
128
|
log.out(` [${f.severity}] ${f.rule}: ${f.title}`);
|
|
127
129
|
}
|
|
@@ -195,7 +197,12 @@ export async function runCli(argv = process.argv.slice(2), io = { out: console.l
|
|
|
195
197
|
return 2;
|
|
196
198
|
}
|
|
197
199
|
|
|
198
|
-
|
|
200
|
+
// npx and global installs start this file through a link.
|
|
201
|
+
function startedDirectly(argvPath) {
|
|
202
|
+
try { return realpathSync(argvPath) === realpathSync(fileURLToPath(import.meta.url)); } catch { return false; }
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (process.argv[1] && startedDirectly(process.argv[1])) {
|
|
199
206
|
const exitCode = await runCli();
|
|
200
207
|
if (exitCode) process.exit(exitCode);
|
|
201
208
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-customs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Border control for the Open Agentic Web: inspect any agent network before it runs in your browser.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Monty Bagati (https://github.com/montbaga)",
|
package/site/customs/inspect.js
CHANGED
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
import { parseHocon } from "../runtime/hocon.js";
|
|
9
9
|
import { AgentNetwork, validateNetwork } from "../runtime/kernel.js";
|
|
10
10
|
import { VERDICTS, analyzeNetwork, escalateReport } from "./analyze.js";
|
|
11
|
-
import { detectProtocol, foreignDiscoveryCandidates, normalizeForeignSpec } from "./protocols.js";
|
|
11
|
+
import { detectProtocol, foreignDiscoveryCandidates, normalizeForeignSpec, protocolFromUrl } from "./protocols.js";
|
|
12
12
|
|
|
13
13
|
const DEFAULT_TIMEOUT_MS = 15000;
|
|
14
14
|
const MAX_BYTES = 2 * 1024 * 1024;
|
|
15
15
|
const MAX_TRANSITIVE_CHILDREN = 6;
|
|
16
16
|
const DIRECT_FOREIGN_URL = /(?:\/\.well-known\/agent(?:-card)?\.json|\/agent(?:-card)?\.json|\/\.well-known\/mcp\.json|\/mcp\.json|\/tools\/list)$/i;
|
|
17
|
+
const LIVE_MCP_PATH = /\/(?:mcp|sse)\/?$/i;
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Work out the site base and network name from what a person pasted: a network URL,
|
|
@@ -95,13 +96,65 @@ async function fetchPublic(url, fetchImpl, timeoutMs) {
|
|
|
95
96
|
return { ok: resp.ok, status: resp.status, text, finalUrl: resp.url || url, redirected: !!resp.redirected };
|
|
96
97
|
} catch (error) {
|
|
97
98
|
if (error instanceof FileTooLarge) throw error;
|
|
98
|
-
if (error?.name === "AbortError")
|
|
99
|
-
|
|
99
|
+
if (error?.name === "AbortError") {
|
|
100
|
+
throw Object.assign(new Error(`No answer from ${hostOf(url)} within ${Math.round(timeoutMs / 1000)} s.`), { url, timedOut: true });
|
|
101
|
+
}
|
|
102
|
+
throw Object.assign(new Error(`Could not read ${url}: the server is down or unreachable, or it does not allow other sites to read it (no CORS header).`), { url });
|
|
103
|
+
} finally {
|
|
104
|
+
if (timer) clearTimeout(timer);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// A no-cors request reaches the server without reading the answer, so it fails only when nothing answered.
|
|
109
|
+
async function serverAnswered(url, fetchImpl, timeoutMs) {
|
|
110
|
+
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
111
|
+
const timer = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
112
|
+
try {
|
|
113
|
+
await fetchImpl(url, { mode: "no-cors", credentials: "omit", cache: "no-store", redirect: "follow", referrerPolicy: "no-referrer", signal: controller?.signal });
|
|
114
|
+
return true;
|
|
115
|
+
} catch {
|
|
116
|
+
return false;
|
|
100
117
|
} finally {
|
|
101
118
|
if (timer) clearTimeout(timer);
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
121
|
|
|
122
|
+
async function unreadableReason(error, input, { fetchImpl, timeoutMs, agenticSite }) {
|
|
123
|
+
const host = hostOf(error.url) || "this address";
|
|
124
|
+
if (error.timedOut) {
|
|
125
|
+
return { summary: `${error.message} The site may be slow or down. Try again later.`, title: "The site answers", detail: error.message, fix: "" };
|
|
126
|
+
}
|
|
127
|
+
if (!await serverAnswered(error.url, fetchImpl, timeoutMs)) {
|
|
128
|
+
return { summary: `Nothing answered at ${host}. Check the address for typos, or try again later if the site is down.`, title: "The site answers", detail: `Nothing answered at ${error.url}.`, fix: "" };
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
summary: agenticSite
|
|
132
|
+
? `${host} answered, but it doesn't let web pages read its files (it sends no CORS header), so your browser can't tell whether it publishes any agents. Most websites have none yet. If it does, agents on other websites can't call them either, because they run in their visitors' browsers too (spec sections 3.3 and 3.4).`
|
|
133
|
+
: `${host} answered, but it doesn't let web pages read this address (it sends no CORS header), so your browser kept the answer from this page.`,
|
|
134
|
+
command: `npx -y agent-customs check ${commandAddress(input)}`,
|
|
135
|
+
title: "Public files readable by other sites (CORS)",
|
|
136
|
+
detail: `${error.url} answered without an Access-Control-Allow-Origin header.`,
|
|
137
|
+
fix: agenticSite
|
|
138
|
+
? "If this is your site: serve agent-manifest.json, the network file and links.json with Access-Control-Allow-Origin: *."
|
|
139
|
+
: "If this is your site: serve this file with Access-Control-Allow-Origin: *.",
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function commandAddress(input) {
|
|
144
|
+
try {
|
|
145
|
+
const u = new URL(String(input).trim());
|
|
146
|
+
u.search = "";
|
|
147
|
+
u.hash = "";
|
|
148
|
+
return u.href;
|
|
149
|
+
} catch {
|
|
150
|
+
return String(input).trim();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function isLiveMcpAddress(input) {
|
|
155
|
+
try { return LIVE_MCP_PATH.test(new URL(String(input).trim()).pathname); } catch { return false; }
|
|
156
|
+
}
|
|
157
|
+
|
|
105
158
|
/**
|
|
106
159
|
* Inspect a network by URL.
|
|
107
160
|
*
|
|
@@ -134,6 +187,7 @@ export async function inspectNetworkUrl(input, options = {}) {
|
|
|
134
187
|
const redirects = [];
|
|
135
188
|
let manifestInfo = null;
|
|
136
189
|
let lastError = null;
|
|
190
|
+
let unreadError = null;
|
|
137
191
|
let unreachable = false;
|
|
138
192
|
let sawTooLarge = false;
|
|
139
193
|
let chosen = null;
|
|
@@ -174,11 +228,13 @@ export async function inspectNetworkUrl(input, options = {}) {
|
|
|
174
228
|
return failureReport(directUrl, "P-MANIFEST-FOUND", "Size", "File within 2 MB limit", error.message);
|
|
175
229
|
}
|
|
176
230
|
if (strictForeign) {
|
|
177
|
-
const
|
|
178
|
-
rep
|
|
231
|
+
const reason = await unreadableReason(error, input, { fetchImpl, timeoutMs, agenticSite: false });
|
|
232
|
+
const rep = failureReport(directUrl, "P-CORS", "Discovery", reason.title, reason.detail, reason.fix);
|
|
233
|
+
rep.verdict = { ...VERDICTS.UNREADABLE, summary: reason.summary, command: reason.command };
|
|
179
234
|
return rep;
|
|
180
235
|
}
|
|
181
236
|
lastError = error.message;
|
|
237
|
+
unreadError = error;
|
|
182
238
|
unreachable = true;
|
|
183
239
|
}
|
|
184
240
|
}
|
|
@@ -205,7 +261,7 @@ export async function inspectNetworkUrl(input, options = {}) {
|
|
|
205
261
|
if (error instanceof FileTooLarge) { lastError = error.message; unreachable = false; sawTooLarge = true; continue; }
|
|
206
262
|
// The browser could not read it at all: down, unreachable, or no CORS header.
|
|
207
263
|
// That says nothing about the network itself, so it gets its own verdict.
|
|
208
|
-
if (!lastError || unreachable) { lastError = error.message; unreachable = true; }
|
|
264
|
+
if (!lastError || unreachable) { lastError = error.message; unreadError = unreadError || error; unreachable = true; }
|
|
209
265
|
}
|
|
210
266
|
}
|
|
211
267
|
|
|
@@ -231,21 +287,27 @@ export async function inspectNetworkUrl(input, options = {}) {
|
|
|
231
287
|
if (!manifestInfo) {
|
|
232
288
|
const report = failureReport(String(input), "P-MANIFEST-FOUND", "3.2, 3.3", "agent-manifest.json is published", lastError || "No manifest found.",
|
|
233
289
|
"Publish agent-manifest.json in the folder of the network URL, with Access-Control-Allow-Origin: *.");
|
|
234
|
-
if (
|
|
235
|
-
report.
|
|
236
|
-
report.
|
|
237
|
-
|
|
290
|
+
if (isLiveMcpAddress(input)) {
|
|
291
|
+
report.protocol = "mcp";
|
|
292
|
+
report.verdict = { ...VERDICTS.UNREADABLE, summary: "This is the address of a live MCP server, which only MCP apps can talk to. Agent Customs reads the files a server publishes: paste the address of its server.json instead. Publishers usually keep it in their GitHub repository, such as https://raw.githubusercontent.com/github/github-mcp-server/main/server.json." };
|
|
293
|
+
report.conformance.checks[0] = { id: unreachable ? "P-CORS" : "P-MANIFEST-FOUND", section: "Discovery", title: "A published file to inspect", status: "fail",
|
|
294
|
+
detail: lastError, fix: "Paste the address of the server's server.json or mcp.json." };
|
|
295
|
+
} else if (unreachable) {
|
|
296
|
+
const reason = await unreadableReason(unreadError, input, { fetchImpl, timeoutMs, agenticSite: true });
|
|
297
|
+
report.verdict = { ...VERDICTS.UNREADABLE, summary: reason.summary, command: reason.command };
|
|
298
|
+
report.conformance.checks[0] = { id: "P-CORS", section: "3.3, 3.4", title: reason.title, status: "fail", detail: reason.detail, fix: reason.fix };
|
|
238
299
|
}
|
|
239
300
|
return report;
|
|
240
301
|
}
|
|
241
302
|
const { manifest } = manifestInfo;
|
|
303
|
+
const failed = (...args) => ({ ...failureReport(...args), protocol: "open-agentic-web" });
|
|
242
304
|
const networks = Array.isArray(manifest.networks) ? manifest.networks : [];
|
|
243
305
|
let name = chosen.name;
|
|
244
306
|
if (!name) {
|
|
245
307
|
if (networks.length === 1 && networks[0]?.name) name = networks[0].name;
|
|
246
308
|
else {
|
|
247
309
|
const names = networks.map((n) => n?.name).filter(Boolean);
|
|
248
|
-
return
|
|
310
|
+
return failed(`${chosen.base}/`, "P-PICK", "3.2", "One network chosen",
|
|
249
311
|
names.length ? `This site publishes ${names.length} networks. Inspect one of: ${names.map((n) => `${chosen.base}/${n}`).join(", ")}` : "The manifest lists no networks.",
|
|
250
312
|
"Use a network URL: the folder that holds agent-manifest.json, then the network name.", { choices: names.map((n) => `${chosen.base}/${n}`) });
|
|
251
313
|
}
|
|
@@ -253,22 +315,22 @@ export async function inspectNetworkUrl(input, options = {}) {
|
|
|
253
315
|
const networkUrl = `${chosen.base}/${name}`;
|
|
254
316
|
const entry = networks.find((n) => n && n.name === name);
|
|
255
317
|
if (!entry) {
|
|
256
|
-
return
|
|
318
|
+
return failed(networkUrl, "P-EXACT", "3.2", "The manifest publishes this exact network",
|
|
257
319
|
`No network named "${name}" at ${hostOf(networkUrl)}. A runtime must fail rather than run another one. Published: ${networks.map((n) => n?.name).filter(Boolean).join(", ") || "none"}.`,
|
|
258
320
|
"Check the network name: it is the last part of the URL and must match networks[].name exactly.");
|
|
259
321
|
}
|
|
260
322
|
if (typeof entry.hocon !== "string" || !entry.hocon) {
|
|
261
|
-
return
|
|
323
|
+
return failed(networkUrl, "P-HOCON", "3.3", "The manifest says where the network file is", "The entry has no hocon path.", "Add \"hocon\": \"./<network>.network.json\".");
|
|
262
324
|
}
|
|
263
325
|
const hoconUrl = resolveUrl(chosen.base, entry.hocon);
|
|
264
326
|
let file;
|
|
265
327
|
try {
|
|
266
328
|
file = await fetchPublic(hoconUrl, fetchImpl, timeoutMs);
|
|
267
329
|
} catch (error) {
|
|
268
|
-
return
|
|
330
|
+
return failed(networkUrl, "P-NETWORK-FOUND", "3.3", "The network file is published", error.message, "Publish the file the manifest names, with CORS.");
|
|
269
331
|
}
|
|
270
332
|
if (!file.ok) {
|
|
271
|
-
return
|
|
333
|
+
return failed(networkUrl, "P-NETWORK-FOUND", "3.3", "The network file is published", `${hoconUrl} answered HTTP ${file.status}.`, "Publish the file the manifest names.");
|
|
272
334
|
}
|
|
273
335
|
if (file.redirected) redirects.push({ from: hoconUrl, to: file.finalUrl, crossOrigin: originOf(file.finalUrl) !== originOf(hoconUrl) });
|
|
274
336
|
|
|
@@ -276,10 +338,10 @@ export async function inspectNetworkUrl(input, options = {}) {
|
|
|
276
338
|
try {
|
|
277
339
|
config = parseHocon(file.text);
|
|
278
340
|
} catch (error) {
|
|
279
|
-
return
|
|
341
|
+
return failed(networkUrl, "P-PARSE", "2, 2.2", "The network file parses", `${hoconUrl}: ${error.message}`, "Publish resolved JSON (or the runtime's HOCON subset) with no includes or substitutions.");
|
|
280
342
|
}
|
|
281
343
|
if (!config || typeof config !== "object" || !Array.isArray(config.tools)) {
|
|
282
|
-
return
|
|
344
|
+
return failed(networkUrl, "P-PARSE", "2.1", "The network file has a tools list", "No top-level tools array.", "Put the agents in a top-level \"tools\" array.");
|
|
283
345
|
}
|
|
284
346
|
|
|
285
347
|
// links.json, merged the way the runtime merges it.
|
|
@@ -305,7 +367,7 @@ export async function inspectNetworkUrl(input, options = {}) {
|
|
|
305
367
|
validation = validateNetwork(network);
|
|
306
368
|
try { frontMan = network.findFrontMan(); } catch { frontMan = null; }
|
|
307
369
|
} catch (error) {
|
|
308
|
-
return
|
|
370
|
+
return failed(networkUrl, "P-VALID", "3.1", "Network passes the runtime's validator", error.message, "Fix the network structure.");
|
|
309
371
|
}
|
|
310
372
|
|
|
311
373
|
const cors = !pageOrigin ? "unchecked" : originOf(networkUrl) === pageOrigin ? "same-origin" : "ok";
|
|
@@ -424,7 +486,7 @@ function failureReport(url, id, section, title, detail, fix = "", extra = {}) {
|
|
|
424
486
|
counts: { critical: 0, high: 0, medium: 0, low: 0, info: 0 },
|
|
425
487
|
conformance: { passed: 0, warned: 0, failed: 1, total: 1, score: 0, checks: [{ id, section, title, status: "fail", detail, fix }] },
|
|
426
488
|
findings: [], itinerary: [], privacy: [], budget: {}, drift: null, conditions: [], snapshot: null,
|
|
427
|
-
failure: true, ...extra,
|
|
489
|
+
protocol: protocolFromUrl(url), failure: true, ...extra,
|
|
428
490
|
};
|
|
429
491
|
}
|
|
430
492
|
|
|
@@ -46,6 +46,10 @@ export function detectProtocol(doc, url = "") {
|
|
|
46
46
|
if (doc.serverInfo || Array.isArray(doc.prompts) || Array.isArray(doc.resources) || Array.isArray(doc.result?.prompts)) {
|
|
47
47
|
return "mcp";
|
|
48
48
|
}
|
|
49
|
+
return protocolFromUrl(url);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function protocolFromUrl(url = "") {
|
|
49
53
|
if (/(?:\/\.well-known\/agent(?:-card)?\.json|\/agent(?:-card)?\.json)$/i.test(url)) return "a2a";
|
|
50
54
|
if (/(?:\/\.well-known\/mcp\.json|\/mcp\.json|\/tools\/list)$/i.test(url)) return "mcp";
|
|
51
55
|
return null;
|
package/tools/mcp-server.mjs
CHANGED
|
@@ -166,7 +166,7 @@ function resolveKnownSample(raw) {
|
|
|
166
166
|
|
|
167
167
|
function buildInstallSnippets() {
|
|
168
168
|
return {
|
|
169
|
-
oneLineScript: `<script type="module" src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v${PKG_VERSION}/dist/agent-customs.js" integrity="sha384-
|
|
169
|
+
oneLineScript: `<script type="module" src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v${PKG_VERSION}/dist/agent-customs.js" integrity="sha384-WMl/1x9IOgwlSJuAl5nKo4CtY/x421qU9tkM8wWXyzImP1odffmefCeSm3lfLZgj" crossorigin="anonymous"></script>`,
|
|
170
170
|
twoLines: `import { installCustomsGuard } from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v${PKG_VERSION}/site/customs/guard.js";\ninstallCustomsGuard(booted.engine, { strict: true });`,
|
|
171
171
|
npm: `npm install agent-customs\nimport { installCustomsGuard } from "agent-customs";\ninstallCustomsGuard(booted.engine);`,
|
|
172
172
|
cli: `npx agent-customs check https://your-site.example/\nnpx agent-customs check ./my-network --strict\nnpx agent-customs mcp`,
|