agent-json-validate 1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arcede
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,435 @@
1
+ # agent.json
2
+
3
+ **The open capability manifest for the agent internet.**
4
+
5
+ [![Spec Version](https://img.shields.io/badge/spec-v1.1-blue)](./SPECIFICATION.md)
6
+ [![Schema](https://img.shields.io/badge/schema-JSON%20Schema%202020--12-green)](./schema.json)
7
+ [![License: MIT](https://img.shields.io/badge/license-MIT-yellow)](./LICENSE)
8
+ [![npm](https://img.shields.io/npm/v/agent-json-validate)](https://www.npmjs.com/package/agent-json-validate)
9
+
10
+ `agent.json` is a machine-readable file that a service publishes to declare what it offers to AI agents — its capabilities, inputs, and payment terms.
11
+
12
+ Just as `robots.txt` tells search engines how to crawl a site, `agent.json` tells AI agents exactly how to interact with your service. It replaces the need for agents to blindly scrape pages or guess API endpoints.
13
+
14
+ ---
15
+
16
+ ## Table of Contents
17
+
18
+ - [Why does this exist?](#why-does-this-exist)
19
+ - [Quick Start](#quick-start)
20
+ - [Integration Tiers](#integration-tiers)
21
+ - [The Economics](#the-economics)
22
+ - [x402 Payment Discovery](#x402-payment-discovery)
23
+ - [Validator](#validator)
24
+ - [Examples](#examples)
25
+ - [Specification Summary](#specification-summary)
26
+ - [Extensions](#extensions)
27
+ - [Goals and Governance](#goals-and-governance)
28
+ - [Contributing](#contributing)
29
+ - [Further Reading](#further-reading)
30
+ - [License](#license)
31
+
32
+ ---
33
+
34
+ ## Why does this exist?
35
+
36
+ The web is evolving from only an internet of human users to a three-party internet where AI agents can act on behalf of human users. Currently, agents struggle to discover what a website can actually do, how to format requests, and who to pay.
37
+
38
+ This repository establishes a standardized, decentralized, open protocol to solve this:
39
+
40
+ - **For Service Providers (Websites, SaaS, Apps):** Make your service "agent-ready" in 5 minutes. Let agents interact with your product and get paid for it — without building and maintaining a custom agent API.
41
+ - **For AI Agent Builders (Runtimes):** Stop hardcoding brittle web scrapers or custom tool integrations. Fetch the `agent.json` and dynamically understand a site's capabilities, inputs, and payment terms instantly.
42
+
43
+ ---
44
+
45
+ ## Quick Start
46
+
47
+ ### 1. Create your manifest
48
+
49
+ ```json
50
+ {
51
+ "version": "1.1",
52
+ "origin": "yoursite.com",
53
+ "payout_address": "0xYOUR_WALLET_ADDRESS",
54
+ "display_name": "Your Service",
55
+ "description": "What your service does.",
56
+ "intents": [
57
+ {
58
+ "name": "search_products",
59
+ "description": "Search your catalog by keyword. Returns product names, prices, and availability.",
60
+ "parameters": {
61
+ "query": { "type": "string", "required": true }
62
+ }
63
+ }
64
+ ],
65
+ "bounty": {
66
+ "type": "cpa",
67
+ "rate": 2.00,
68
+ "currency": "USDC"
69
+ }
70
+ }
71
+ ```
72
+
73
+ ### 2. Host it
74
+
75
+ Serve the file at:
76
+
77
+ ```
78
+ https://yoursite.com/.well-known/agent.json
79
+ ```
80
+
81
+ That's it. Your service is now discoverable by any agent runtime that implements the spec. No single entity controls the registry.
82
+
83
+ ### 3. Validate it
84
+
85
+ ```bash
86
+ npx agent-json-validate https://yoursite.com/.well-known/agent.json
87
+ ```
88
+
89
+ Or validate a local file:
90
+
91
+ ```bash
92
+ npx agent-json-validate ./agent.json
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Integration Tiers
98
+
99
+ The protocol supports progressive integration. Start minimal, add detail as your integration matures.
100
+
101
+ | Tier | What you publish | What agents can do | Economics |
102
+ |------|------------------|--------------------|-------------|
103
+ | **1 — Minimal** | `version` + `origin` + `payout_address` | Interact via web automation | Pay bounties for routing |
104
+ | **2 — Structured** | Add `intents` with descriptions and parameters | Precise capability matching, better routing | Pay bounties + receive runtime incentives |
105
+ | **2+ — Direct API** | Add `endpoint` and `method` to intents | Agents call your API directly, no browser needed | Charge users prices + receive runtime incentives |
106
+ | **3 — Authenticated** | Add `identity` metadata | Runtime-specific trust policies and richer provider identity | All of the above + optional runtime-specific trust flows |
107
+
108
+ Start at Tier 1. Add detail as your integration matures. Each tier earns more because each tier provides more value to agents and their users.
109
+
110
+ ---
111
+
112
+ ## The Economics
113
+
114
+ ### How value flows
115
+
116
+ The `agent.json` establishes an economic layer for the agentic web — but it's important to understand how it works.
117
+
118
+ **The manifest is an open standard. The economics are opt-in.** Any runtime can read your `agent.json` and use your declared intents. Whether a provider pays bounties to attract runtimes, or a runtime pays incentives to reward providers, are independent decisions. Nothing in the protocol forces payment.
119
+
120
+ So why would a runtime (or a provider) pay?
121
+
122
+ Because the economics are mutually beneficial. Providers who receive *incentives* from runtimes invest in better structured access — faster APIs, richer data, higher reliability. Runtimes who receive *bounties* from providers are motivated to route their users to those services, increasing the provider's traffic and revenue. The economic layer isn't a tax — it's an open marketplace where both sides benefit from participation.
123
+
124
+ **The same dynamic drove the web's existing economics.** Search engines don't *have* to share revenue with publishers. Payment gateways don't *have* to share revenue with platforms. They do because the ecosystem is more valuable when value flows to the participants who create it.
125
+
126
+ ### The Economic Layers
127
+
128
+ #### 1. Bounties (Provider → Runtime)
129
+
130
+ Think of bounties as affiliate marketing or advertising for the agentic web. You, the provider, want agents to bring you paying users. So you declare a bounty:
131
+
132
+ ```json
133
+ "bounty": { "type": "cpa", "rate": 2.00, "currency": "USDC" }
134
+ ```
135
+
136
+ When an agent successfully completes a task at your service — a purchase, a booking — you (the provider) pay the runtime a `$2.00` bounty to their `payout_address`. This acts as an advertisement — a signal to agent runtimes that routing traffic here is economically rewarded.
137
+
138
+ #### 2. Compute Efficiency Incentives (Runtime → Provider)
139
+
140
+ Every agent interaction costs compute — AI inference, browser automation, network round-trips. These costs are real and measurable. When a provider publishes a structured `agent.json` with declared intents, agents can skip the expensive guesswork of navigating a website and go straight to the capability they need.
141
+
142
+ The difference is significant:
143
+
144
+ | Integration Level | Typical Cost | Typical Speed |
145
+ |------------------|-------------|---------------|
146
+ | No manifest (DOM automation) | 5–15 AI calls, 10–30 seconds | Slowest |
147
+ | Declared intents (Tier 2) | 2–8 AI calls, 5–15 seconds | Faster |
148
+ | Direct API endpoints (Tier 2+) | 0–1 AI calls, 1–3 seconds | Fast |
149
+ | Agent-native endpoints (Tier 3) | 0 AI calls, <1 second | Fastest |
150
+
151
+ A provider with a structured manifest can reduce agent compute costs by 10–100x compared to blind automation. This creates a natural economic incentive: runtimes that charge users for compute have reason to preferentially route to efficient providers.
152
+
153
+ A provider can optionally *suggest* an `incentive` in their manifest for providing this structured access:
154
+
155
+ ```json
156
+ "incentive": { "type": "cpa", "rate": 0.50, "currency": "USDC" }
157
+ ```
158
+
159
+ This is a purely opt-in economic framework:
160
+
161
+ 1. **Suggesting an incentive is optional.** A provider does not have to include an `incentive` field. A runtime might choose to pay a provider an incentive organically simply because their endpoint delivered excellent compute efficiency.
162
+ 2. **Runtimes can pay more.** A runtime isn't limited to the suggested rate. If a runtime's algorithm notices a provider offers exceptional privacy, speed, or accuracy, the runtime might choose to pay a higher incentive to ensure that provider stays well-resourced.
163
+ 3. **Incentives stack.** A runtime might decide to pay an incentive *on top of* a provider's required `price`, simply because the runtime wants to reward and encourage high-quality, privacy-oriented providers in the ecosystem.
164
+
165
+ The framework creates the conditions where efficiency and quality are visible, measurable, and economically rewarded by the open market.
166
+
167
+ #### 3. Payment Intents / Prices (User → Provider)
168
+
169
+ Some intents involve the user paying the provider directly — tips, purchases, subscriptions. These are independent of the bounty system and work regardless of whether the runtime participates in bounties. The `endpoint` field creates a payment flow through any payment rail:
170
+
171
+ ```json
172
+ {
173
+ "name": "tip_checkout",
174
+ "description": "Send a tip. Creates a hosted checkout session.",
175
+ "endpoint": "/api/checkout/tip",
176
+ "method": "POST",
177
+ "parameters": {
178
+ "amount": { "type": "number", "required": true, "description": "Tip amount in USD" }
179
+ },
180
+ "returns": {
181
+ "type": "object",
182
+ "properties": {
183
+ "url": { "type": "string", "description": "Checkout URL" }
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ Payment intents are **payment-rail agnostic** — fiat gateways, crypto commerce processors, direct wallet transfers. The manifest declares what's possible; your backend handles the settlement. See [the payment intent example](./examples/payment-intent-hosted.json).
190
+
191
+ #### 4. Paid Access (SaaS / API Pricing)
192
+
193
+ If your service charges for access — per API call, per unit of usage, or a flat fee — you can declare pricing directly on any intent using the `price` field:
194
+
195
+ ```json
196
+ {
197
+ "name": "analyze_document",
198
+ "description": "AI-powered document analysis. Extracts key clauses and generates a summary.",
199
+ "endpoint": "/api/v1/analyze",
200
+ "method": "POST",
201
+ "parameters": {
202
+ "document_url": { "type": "string", "required": true }
203
+ },
204
+ "price": {
205
+ "amount": 0.50,
206
+ "currency": "USDC",
207
+ "model": "per_call",
208
+ "network": ["base", "arbitrum"]
209
+ }
210
+ }
211
+ ```
212
+
213
+ This tells any agent runtime upfront: "this intent costs $0.50 per call, payable in USDC on Base or Arbitrum." The runtime can present this cost to the user, factor it into task planning, and obtain approval through its supervision layer before executing.
214
+
215
+ The `network` field accepts a single string (e.g., `"base"`) or an array of strings (e.g., `["base", "arbitrum"]`), enabling multi-chain providers to advertise all accepted settlement networks. Agents use this for routing — an agent with an Arbitrum wallet can immediately see that this provider accepts Arbitrum, without needing a round-trip request.
216
+
217
+ ### How the economic layers interact
218
+
219
+ | | `price` | `bounty` | `incentive` |
220
+ |--|---------|----------|-------------|
221
+ | **Direction** | User → Provider | Provider → Runtime | Runtime → Provider |
222
+ | **Purpose** | Gating access / buying goods | Advertising / routing acquisition | Performance / fulfillment reward |
223
+ | **Required** | Yes (provider blocks access without it) | No (provider's choice) | No (runtime's choice to honor) |
224
+
225
+ An intent can have any combination. A SaaS might charge $0.50 per call (`price`), offer a $0.10 advertising bonus to runtimes to bring them traffic (`bounty`), and request no performance bonus (`incentive`).
226
+
227
+ Supported pricing models:
228
+ - **`per_call`** — fixed cost per invocation (default)
229
+ - **`per_unit`** — cost scales with a parameter value (e.g., $0.10 x number of images generated)
230
+ - **`flat`** — one-time access fee
231
+
232
+ ---
233
+
234
+ ## x402 Payment Discovery
235
+
236
+ The [x402 protocol](https://www.x402.org/) builds on HTTP 402 (Payment Required) to enable structured payment challenges and proofs. The `x402` object in `agent.json` enables agents to discover payment capabilities *before* making a request — eliminating the need for a failed request to trigger payment negotiation.
237
+
238
+ ```json
239
+ {
240
+ "x402": {
241
+ "supported": true,
242
+ "networks": [
243
+ {
244
+ "network": "base",
245
+ "asset": "USDC",
246
+ "contract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
247
+ "facilitator": "https://x402.org/facilitator"
248
+ },
249
+ {
250
+ "network": "arbitrum",
251
+ "asset": "USDC",
252
+ "contract": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
253
+ "facilitator": "https://x402.org/facilitator"
254
+ }
255
+ ],
256
+ "recipient": "0xYOUR_ADDRESS"
257
+ }
258
+ }
259
+ ```
260
+
261
+ The `x402` object supports two forms:
262
+ - **Single-network (flat fields)** — for providers on one chain: `network`, `asset`, `contract`, `facilitator`
263
+ - **Multi-network (`networks` array)** — for providers on multiple chains, each entry bundles the per-network settlement details (contract address, facilitator URL)
264
+
265
+ Intent-level x402 overrides allow per-intent pricing with optional per-network differentiation:
266
+
267
+ ```json
268
+ {
269
+ "x402": {
270
+ "direct_price": 0.50,
271
+ "ticket_price": 0.40,
272
+ "network_pricing": [
273
+ { "network": "ethereum", "direct_price": 0.55, "ticket_price": 0.45 }
274
+ ]
275
+ }
276
+ }
277
+ ```
278
+
279
+ The `x402` field is entirely optional. It does not replace `price`, does not prevent other payment mechanisms, and does not make x402 the only supported payment rail. See [the x402 micropayments example](./examples/x402-micropayments.json) and [SPECIFICATION.md §4.8](./SPECIFICATION.md) for full details.
280
+
281
+ ---
282
+
283
+ ## Validator
284
+
285
+ ### CLI
286
+
287
+ ```bash
288
+ # From URL
289
+ npx agent-json-validate https://example.com/.well-known/agent.json
290
+
291
+ # From file
292
+ npx agent-json-validate ./my-manifest.json
293
+
294
+ # From stdin
295
+ cat agent.json | npx agent-json-validate --stdin
296
+
297
+ # JSON output
298
+ npx agent-json-validate ./agent.json --json
299
+ ```
300
+
301
+ Exit code `0` = valid, `1` = invalid.
302
+
303
+ ### Programmatic
304
+
305
+ ```javascript
306
+ const { validate } = require("agent-json-validate");
307
+
308
+ const result = validate({
309
+ version: "1.1",
310
+ origin: "example.com",
311
+ payout_address: "0xYOUR_WALLET_ADDRESS",
312
+ intents: [
313
+ {
314
+ name: "search_products",
315
+ description: "Search the product catalog by keyword.",
316
+ },
317
+ ],
318
+ });
319
+
320
+ console.log(result.valid); // true
321
+ console.log(result.tier); // 2
322
+ console.log(result.errors); // []
323
+ console.log(result.warnings); // []
324
+ ```
325
+
326
+ ### JSON Schema
327
+
328
+ Use `schema.json` with any JSON Schema validator:
329
+
330
+ ```javascript
331
+ import Ajv from "ajv";
332
+ import schema from "./schema.json";
333
+
334
+ const ajv = new Ajv();
335
+ const isValid = ajv.validate(schema, manifest);
336
+ ```
337
+
338
+ ---
339
+
340
+ ## Examples
341
+
342
+ | Example | Description |
343
+ |---------|-------------|
344
+ | [tier1-minimal.json](./examples/tier1-minimal.json) | Minimal three-field manifest |
345
+ | [tier2-ecommerce.json](./examples/tier2-ecommerce.json) | E-commerce with search, cart, and purchase intents |
346
+ | [tier2-saas.json](./examples/tier2-saas.json) | SaaS document platform with CRUD intents |
347
+ | [tier2-travel.json](./examples/tier2-travel.json) | Travel booking with flights, hotels, and reservations |
348
+ | [tier3-authenticated.json](./examples/tier3-authenticated.json) | Financial API with DID identity and extensions |
349
+ | [paid-saas-api.json](./examples/paid-saas-api.json) | Paid API with per-call and per-unit pricing |
350
+ | [payment-intent-hosted.json](./examples/payment-intent-hosted.json) | Hosted checkout and crypto tipping |
351
+ | [x402-micropayments.json](./examples/x402-micropayments.json) | Multi-network x402 micropayments with per-network pricing |
352
+
353
+ ---
354
+
355
+ ## Specification Summary
356
+
357
+ **Required fields:** `version`, `origin`, `payout_address`
358
+
359
+ **Optional fields:** `display_name`, `description`, `extensions`, `identity`, `intents`, `bounty`, `incentive`, `x402`
360
+
361
+ **Intent fields:** `name`, `description`, `extensions`, `endpoint`, `method`, `parameters`, `returns`, `price`, `bounty`, `incentive`, `x402`
362
+
363
+ **Hosting:** `https://{domain}/.well-known/agent.json` (preferred) or `https://{domain}/agent.json` (fallback)
364
+
365
+ **Discovery:** Agent runtimes fetch the manifest when first interacting with a domain. No registration needed — publishing the file is sufficient.
366
+
367
+ **Resolution orders:**
368
+ - **Bounty:** Intent-level bounty > Manifest-level bounty > No bounty
369
+ - **x402:** Intent-level x402 > Root-level x402 > No x402
370
+ - **x402 pricing:** `network_pricing[network]` > intent `direct_price`/`ticket_price` > `price.amount`
371
+ - **x402 networks:** `networks` array (if present) > flat fields (`network`, `asset`, `contract`, `facilitator`)
372
+
373
+ **Extensibility:** Vendor-specific metadata should live under an `extensions` object (e.g., `"extensions": { "air": { ... } }`). Legacy `x-` or `x_` prefixed fields are also tolerated. Runtimes must gracefully ignore unknown fields to ensure forward compatibility.
374
+
375
+ See [SPECIFICATION.md](./SPECIFICATION.md) for the complete reference.
376
+
377
+ ---
378
+
379
+ ## Extensions
380
+
381
+ The core manifest stays small on purpose. Runtime- or vendor-specific metadata should live under an `extensions` object, for example:
382
+
383
+ ```json
384
+ {
385
+ "extensions": {
386
+ "air": {
387
+ "custom_field": true
388
+ }
389
+ }
390
+ }
391
+ ```
392
+
393
+ Runtimes should ignore unknown extension namespaces. Signing and verification behavior are not standardized in the current spec; runtimes that support them should document that behavior in their own extension namespace.
394
+
395
+ ---
396
+
397
+ ## What's in this repo
398
+
399
+ | File | Description |
400
+ |------|-------------|
401
+ | [SPECIFICATION.md](./SPECIFICATION.md) | The full spec — schema, field reference, discovery protocol, security considerations |
402
+ | [schema.json](./schema.json) | JSON Schema (2020-12) for programmatic validation |
403
+ | [validate.js](./validate.js) | Zero-dependency CLI validator and Node.js library |
404
+ | [test.js](./test.js) | Test suite — 70 tests covering all schema features |
405
+ | [examples/](./examples/) | Example manifests for different industries and use cases |
406
+ | [CONTRIBUTING.md](./CONTRIBUTING.md) | Contribution guidelines |
407
+
408
+ ---
409
+
410
+ ## Goals and Governance
411
+
412
+ The goal of this repository is to establish a decentralized, open standard for agent capability discovery. The protocol is designed so that:
413
+
414
+ - Any service can participate by publishing a file. No registration, no gatekeeper.
415
+ - Any agent runtime can consume it. No single runtime is privileged.
416
+ - Multiple payment rails are supported. No single payment provider is required.
417
+ - The standard evolves through open contribution, not proprietary control.
418
+
419
+ ---
420
+
421
+ ## Contributing
422
+
423
+ We welcome contributions of all kinds — from typo fixes to new features. See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to get involved.
424
+
425
+ ---
426
+
427
+ ## Further Reading
428
+
429
+ If you want to understand the emerging agent internet more, including the research and philosophies underpinning this protocol, please refer to: [https://arcede.com/papers](https://arcede.com/papers)
430
+
431
+ ---
432
+
433
+ ## License
434
+
435
+ [MIT](./LICENSE)
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "agent-json-validate",
3
+ "version": "1.2.0",
4
+ "description": "Validator for the agent.json capability manifest specification",
5
+ "main": "validate.js",
6
+ "bin": {
7
+ "agent-json-validate": "validate.js"
8
+ },
9
+ "files": [
10
+ "validate.js",
11
+ "schema.json",
12
+ "LICENSE"
13
+ ],
14
+ "scripts": {
15
+ "test": "node test.js"
16
+ },
17
+ "keywords": [
18
+ "agent",
19
+ "agent-json",
20
+ "manifest",
21
+ "validator",
22
+ "agent-internet",
23
+ "capability",
24
+ "x402",
25
+ "payment",
26
+ "discovery",
27
+ "open-standard",
28
+ "multi-chain"
29
+ ],
30
+ "license": "MIT",
31
+ "homepage": "https://agentjson.org",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/FransDevelopment/agent-json.git"
35
+ }
36
+ }