agent-customs 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE.md +341 -0
  2. package/README.md +592 -2
  3. package/bin/agent-customs.mjs +194 -0
  4. package/package.json +77 -4
  5. package/site/.well-known/agent-customs-key.json +13 -0
  6. package/site/certificate.js +944 -0
  7. package/site/customs/analyze.js +1224 -0
  8. package/site/customs/auto.js +44 -0
  9. package/site/customs/canary.js +270 -0
  10. package/site/customs/canonical.js +123 -0
  11. package/site/customs/capabilities.js +387 -0
  12. package/site/customs/diff.js +236 -0
  13. package/site/customs/english-words.js +153 -0
  14. package/site/customs/guard-notice.js +226 -0
  15. package/site/customs/guard-ui.js +105 -0
  16. package/site/customs/guard.js +259 -0
  17. package/site/customs/inspect.js +446 -0
  18. package/site/customs/judge.js +208 -0
  19. package/site/customs/languages.js +826 -0
  20. package/site/customs/locks.js +967 -0
  21. package/site/customs/pins.js +119 -0
  22. package/site/customs/protocols.js +621 -0
  23. package/site/customs/receipts.js +154 -0
  24. package/site/customs/rules.js +1470 -0
  25. package/site/customs/unicode.js +361 -0
  26. package/site/runtime/LICENSE.txt +176 -0
  27. package/site/runtime/generated/graph.gen.mjs +83 -0
  28. package/site/runtime/generated/validation.gen.mjs +70 -0
  29. package/site/runtime/hocon.js +262 -0
  30. package/site/runtime/kernel.js +237 -0
  31. package/site/runtime/model.js +44 -0
  32. package/tests/fixtures/official/NOTICE +3 -0
  33. package/tests/fixtures/official/guesthouse_agentified/agent-manifest.json +86 -0
  34. package/tests/fixtures/official/guesthouse_agentified/links.json +6 -0
  35. package/tests/fixtures/official/guesthouse_agentified/tidewhistle_guesthouse.network.json +56 -0
  36. package/tests/fixtures/official/harbor_tours_agentified/agent-manifest.json +86 -0
  37. package/tests/fixtures/official/harbor_tours_agentified/links.json +6 -0
  38. package/tests/fixtures/official/harbor_tours_agentified/marrow_point_harbor_tours.network.json +56 -0
  39. package/tests/fixtures/official/pizza_restaurant_agentified/agent-manifest.json +78 -0
  40. package/tests/fixtures/official/pizza_restaurant_agentified/links.json +6 -0
  41. package/tests/fixtures/official/pizza_restaurant_agentified/pizza_restaurant_website_assistant.network.json +156 -0
  42. package/tools/bench.mjs +731 -0
  43. package/tools/external-heldout.mjs +337 -0
  44. package/tools/fs-fetch.mjs +19 -0
  45. package/tools/heldout-corpus.mjs +135 -0
  46. package/tools/inspect-local.mjs +88 -0
  47. package/tools/round2-corpus.mjs +395 -0
  48. package/tools/round3-corpus.mjs +192 -0
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env node
2
+ // agent-customs CLI: inspect agent networks in CI/local folders, verify certificates, or run benchmarks.
3
+ import { readFile, writeFile } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { verifyDroppedArtifact } from "../site/certificate.js";
7
+ import { inspectTarget, inspectWeb } from "../tools/inspect-local.mjs";
8
+ import { formatBenchReport, runBenchmark } from "../tools/bench.mjs";
9
+
10
+ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
11
+ const PUBLIC_KEY_FILE = path.join(ROOT, "site", ".well-known", "agent-customs-key.json");
12
+ const BENCH_OUT_FILE = path.join(ROOT, "site", "bench.json");
13
+
14
+ const SEVERITY_TO_SARIF = { critical: "error", high: "error", medium: "warning", low: "note", info: "note" };
15
+
16
+ /**
17
+ * Determine CI exit code from inspected reports (0 clear, 1 held, 2 denied/unreadable).
18
+ */
19
+ export function exitCodeForReports(reports, { strict = false, allowHold = false } = {}) {
20
+ let code = 0;
21
+ for (const r of reports) {
22
+ const v = r?.verdict?.code;
23
+ if (v === "DENIED" || v === "INVALID" || v === "UNREADABLE" || r?.failure) return 2;
24
+ if (v === "HOLD" && !allowHold) code = Math.max(code, strict ? 2 : 1);
25
+ if (v === "CONDITIONS" && strict) code = Math.max(code, 2);
26
+ }
27
+ return code;
28
+ }
29
+
30
+ /**
31
+ * Convert inspection reports into a SARIF v2.1.0 document for GitHub Code Scanning.
32
+ */
33
+ export function formatSarif(reports) {
34
+ const rules = new Map();
35
+ const results = [];
36
+ for (const r of reports) {
37
+ const uri = r.target?.url || "unknown";
38
+ for (const f of r.findings || []) {
39
+ const ruleId = f.rule || "AC-FINDING";
40
+ if (!rules.has(ruleId)) {
41
+ rules.set(ruleId, {
42
+ id: ruleId,
43
+ shortDescription: { text: f.title || ruleId },
44
+ defaultConfiguration: { level: SEVERITY_TO_SARIF[f.severity] || "warning" },
45
+ });
46
+ }
47
+ const where = [f.where?.agent, f.where?.field].filter(Boolean).join(".");
48
+ results.push({
49
+ ruleId,
50
+ level: SEVERITY_TO_SARIF[f.severity] || "warning",
51
+ message: { text: `${f.title}${where ? ` (${where})` : ""}: ${f.detail || f.evidence || r.verdict?.summary || ""}` },
52
+ locations: [{ physicalLocation: { artifactLocation: { uri } } }],
53
+ });
54
+ }
55
+ }
56
+ return {
57
+ $schema: "https://json.schemastore.org/sarif-2.1.0.json",
58
+ version: "2.1.0",
59
+ runs: [{
60
+ tool: { driver: { name: "Agent Customs", informationUri: "https://montbaga.github.io/agent-customs/", rules: [...rules.values()] } },
61
+ results,
62
+ }],
63
+ };
64
+ }
65
+
66
+ function parseFlags(args) {
67
+ const flags = new Set();
68
+ const values = new Map();
69
+ const positionals = [];
70
+ for (let i = 0; i < args.length; i += 1) {
71
+ const a = args[i];
72
+ if (a === "--out" || a === "--sarif-file") {
73
+ values.set(a, args[i + 1] || "");
74
+ i += 1;
75
+ } else if (a.startsWith("--")) {
76
+ flags.add(a);
77
+ } else {
78
+ positionals.push(a);
79
+ }
80
+ }
81
+ return { flags, values, positionals };
82
+ }
83
+
84
+ function helpText() {
85
+ return [
86
+ "Usage:",
87
+ " agent-customs check <url-or-path...> [--strict] [--allow-hold] [--transitive] [--json] [--sarif]",
88
+ " agent-customs verify <file> [--live] [--json]",
89
+ " agent-customs bench [--json] [--write]",
90
+ ].join("\n");
91
+ }
92
+
93
+ async function cmdCheck(positionals, flags, log) {
94
+ if (!positionals.length) {
95
+ log.error("Specify one or more URLs, local folders, or JSON manifests.");
96
+ return 2;
97
+ }
98
+ const strict = flags.has("--strict");
99
+ const allowHold = flags.has("--allow-hold");
100
+ const transitive = flags.has("--transitive");
101
+ const asJson = flags.has("--json");
102
+ const asSarif = flags.has("--sarif");
103
+
104
+ const reports = [];
105
+ for (const target of positionals) {
106
+ reports.push(await inspectTarget(target, { transitive }));
107
+ }
108
+
109
+ if (asSarif) {
110
+ log.out(JSON.stringify(formatSarif(reports), null, 2));
111
+ } else if (asJson) {
112
+ log.out(JSON.stringify(reports.map((r) => ({
113
+ target: r.target?.url,
114
+ protocol: r.protocol,
115
+ verdict: r.verdict,
116
+ fingerprint: r.identity?.hash || "",
117
+ conformance: { passed: r.conformance?.passed, total: r.conformance?.total, failed: r.conformance?.failed },
118
+ findings: (r.findings || []).map((f) => ({ severity: f.severity, rule: f.rule, title: f.title, where: f.where })),
119
+ })), null, 2));
120
+ } else {
121
+ for (const r of reports) {
122
+ log.out(`${r.verdict.code.padEnd(10)} ${r.target?.url || "unknown"} (${r.conformance?.passed}/${r.conformance?.total} checks, ${r.identity?.short || "no hash"})`);
123
+ for (const f of r.findings || []) {
124
+ log.out(` [${f.severity}] ${f.rule}: ${f.title}`);
125
+ }
126
+ }
127
+ }
128
+ return exitCodeForReports(reports, { strict, allowHold });
129
+ }
130
+
131
+ async function cmdVerify(positionals, flags, log) {
132
+ const file = positionals[0];
133
+ if (!file) {
134
+ log.error("Specify a certificate or receipt file (.svg, .json, .html, or .pdf).");
135
+ return 2;
136
+ }
137
+ const bytes = new Uint8Array(await readFile(path.resolve(file)));
138
+ const keyDoc = JSON.parse(await readFile(PUBLIC_KEY_FILE, "utf8"));
139
+ const initial = await verifyDroppedArtifact({ bytes, name: path.basename(file) }, {
140
+ fileName: path.basename(file),
141
+ publicJwk: keyDoc.publicKey,
142
+ });
143
+ let finalRes = initial;
144
+ if (flags.has("--live") && initial.ok && initial.status !== "tampered" && initial.artifact?.url) {
145
+ const liveReport = await inspectWeb(initial.artifact.url);
146
+ finalRes = await verifyDroppedArtifact({ bytes, name: path.basename(file) }, {
147
+ fileName: path.basename(file),
148
+ publicJwk: keyDoc.publicKey,
149
+ liveReport,
150
+ });
151
+ }
152
+ if (flags.has("--json")) {
153
+ log.out(JSON.stringify(finalRes, null, 2));
154
+ } else if (!finalRes.ok) {
155
+ log.out(`INVALID ${file}: ${finalRes.reason}`);
156
+ } else {
157
+ log.out(`${finalRes.status.toUpperCase().padEnd(9)} ${file}: ${finalRes.headline}`);
158
+ if (finalRes.liveSummary) log.out(` ${finalRes.liveSummary}`);
159
+ }
160
+ return !finalRes.ok || finalRes.status === "tampered" || finalRes.status === "changed" ? 2 : 0;
161
+ }
162
+
163
+ async function cmdBench(flags, values, log) {
164
+ const bench = await runBenchmark();
165
+ if (flags.has("--write") || values.get("--out")) {
166
+ const outPath = path.resolve(values.get("--out") || BENCH_OUT_FILE);
167
+ await writeFile(outPath, JSON.stringify(bench, null, 2) + "\n", "utf8");
168
+ }
169
+ if (flags.has("--json")) {
170
+ log.out(JSON.stringify(bench, null, 2));
171
+ } else {
172
+ log.out(formatBenchReport(bench));
173
+ }
174
+ return 0;
175
+ }
176
+
177
+ export async function runCli(argv = process.argv.slice(2), io = { out: console.log, error: console.error }) {
178
+ const [cmd, ...rest] = argv;
179
+ if (!cmd || cmd === "--help" || cmd === "-h") {
180
+ io.out(helpText());
181
+ return 0;
182
+ }
183
+ const { flags, values, positionals } = parseFlags(rest);
184
+ if (cmd === "check") return cmdCheck(positionals, flags, io);
185
+ if (cmd === "verify") return cmdVerify(positionals, flags, io);
186
+ if (cmd === "bench") return cmdBench(flags, values, io);
187
+ io.error(`Unknown command "${cmd}".\n${helpText()}`);
188
+ return 2;
189
+ }
190
+
191
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
192
+ const exitCode = await runCli();
193
+ if (exitCode) process.exit(exitCode);
194
+ }
package/package.json CHANGED
@@ -1,6 +1,79 @@
1
1
  {
2
2
  "name": "agent-customs",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Border control for the Open Agentic Web: inspect any agent network before it runs in your browser.",
5
+ "license": "Apache-2.0",
6
+ "author": "Monty Bagati (https://github.com/montbaga)",
7
+ "homepage": "https://montbaga.github.io/agent-customs/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/montbaga/agent-customs.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/montbaga/agent-customs/issues"
14
+ },
15
+ "keywords": [
16
+ "ai-agents",
17
+ "agent-security",
18
+ "mcp",
19
+ "model-context-protocol",
20
+ "a2a",
21
+ "prompt-injection",
22
+ "open-agentic-web",
23
+ "llm-security"
24
+ ],
25
+ "type": "module",
26
+ "exports": {
27
+ ".": "./site/customs/guard.js",
28
+ "./auto": "./site/customs/auto.js",
29
+ "./inspect": "./site/customs/inspect.js",
30
+ "./customs/*": "./site/customs/*"
31
+ },
32
+ "bin": {
33
+ "agent-customs": "bin/agent-customs.mjs"
34
+ },
35
+ "files": [
36
+ "site/customs/",
37
+ "site/runtime/hocon.js",
38
+ "site/runtime/kernel.js",
39
+ "site/runtime/model.js",
40
+ "site/runtime/generated/graph.gen.mjs",
41
+ "site/runtime/generated/validation.gen.mjs",
42
+ "site/runtime/LICENSE.txt",
43
+ "site/certificate.js",
44
+ "site/.well-known/agent-customs-key.json",
45
+ "bin/",
46
+ "tools/bench.mjs",
47
+ "tools/external-heldout.mjs",
48
+ "tools/fs-fetch.mjs",
49
+ "tools/heldout-corpus.mjs",
50
+ "tools/inspect-local.mjs",
51
+ "tools/round2-corpus.mjs",
52
+ "tools/round3-corpus.mjs",
53
+ "tests/fixtures/official/",
54
+ "LICENSE.md"
55
+ ],
56
+ "engines": {
57
+ "node": ">=22"
58
+ },
59
+ "scripts": {
60
+ "build": "node vendor/agentify-website/scripts/build_network.mjs site/agent_customs.hocon --manifest site/agent-manifest.json",
61
+ "check": "node vendor/agentify-website/scripts/build_network.mjs site/agent_customs.hocon --manifest site/agent-manifest.json --check",
62
+ "range": "node tools/make-range.mjs",
63
+ "practice": "node tools/make-practice.mjs",
64
+ "extension": "node tools/make-extension.mjs",
65
+ "vault": "node tools/make-vault.mjs",
66
+ "check:practice": "node vendor/agentify-website/scripts/build_network.mjs practice/main_street_guide.hocon --manifest practice/agent-manifest.json --check",
67
+ "test": "node --test \"tests/*.test.mjs\"",
68
+ "bench": "node tools/bench.mjs",
69
+ "serve": "node tools/serve.mjs site --port 8080",
70
+ "serve:vault": "node tools/serve.mjs vault --port 8090",
71
+ "serve:range": "node tools/serve.mjs range --port 8081 --log range-requests.jsonl",
72
+ "serve:practice": "node tools/serve.mjs practice --port 8082",
73
+ "smoke": "node tools/smoke.mjs --out screenshots",
74
+ "vault:check": "node tools/vault-check.mjs",
75
+ "shots": "node tools/readme-shots.mjs",
76
+ "inspect": "node tools/inspect-local.mjs",
77
+ "receipts": "node tools/receipts.mjs"
78
+ }
79
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "about": "Agent Customs' public key. Use it to check signed stamps (receipts).",
3
+ "issuer": "Agent Customs",
4
+ "site": "https://montbaga.github.io/agent-customs/",
5
+ "alg": "ES256",
6
+ "keyId": "-DC99sDa-qJjBp2N",
7
+ "publicKey": {
8
+ "crv": "P-256",
9
+ "kty": "EC",
10
+ "x": "Wzq2yNI2mFX6Iz-GBeV7LKacVokiI396oifQRocfzxo",
11
+ "y": "qdaCQ4K-07HN5yiq8CfFVUgRVtJm5uszNMsjuBqWQic"
12
+ }
13
+ }