@agentcash/discovery 0.1.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.
@@ -0,0 +1,24 @@
1
+ # CLAUDE.md
2
+
3
+ This package is the canonical discovery runtime for agentcash.
4
+
5
+ ## Core decisions
6
+
7
+ - OpenAPI is canonical machine discovery source.
8
+ - Discovery order: override -> OpenAPI -> `/.well-known/x402` -> DNS `_x402` -> probe.
9
+ - `discover` is progressive and token-light.
10
+ - `discoverDetailed` is full-waterfall with trace.
11
+ - Compatibility adapters are isolated and removable.
12
+ - `llms.txt` is unstructured guidance only; OpenAPI carries machine metadata.
13
+
14
+ ## Important defaults
15
+
16
+ - `compatMode = on` (until legacy sunset window ends).
17
+ - `verified = false` in advisory output.
18
+ - `trustTier` values: `unverified | origin_hosted | ownership_verified | runtime_verified`.
19
+
20
+ ## Do not do
21
+
22
+ - Do not leak legacy branches into canonical parser logic.
23
+ - Do not introduce hidden fallback passes.
24
+ - Do not change warning codes without a breaking version decision.
package/AGENTS.md ADDED
@@ -0,0 +1,23 @@
1
+ # AGENTS.md
2
+
3
+ ## Purpose
4
+
5
+ This repo implements canonical discovery logic for the agentcash ecosystem.
6
+
7
+ ## Hard Constraints
8
+
9
+ 1. Keep canonical core and compatibility modules physically separate.
10
+ 2. Avoid legacy conditionals in `src/core/*`.
11
+ 3. Preserve stable warning codes.
12
+ 4. Keep `discover` token-light and deterministic.
13
+ 5. Keep compatibility removable via a single top-level mode.
14
+
15
+ ## Module Boundaries
16
+
17
+ - `src/core/*`: canonical OpenAPI-first discovery.
18
+ - `src/compat/legacy-x402scan/*`: `/.well-known/x402` + DNS `_x402` compatibility.
19
+ - `src/compat/interop-mpp/*`: optional registry interop adapter.
20
+
21
+ ## Result Contract
22
+
23
+ Resource identity is always `origin + method + path`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Merit Systems
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,115 @@
1
+ # @agentcash/discovery
2
+
3
+ Canonical discovery library for the agentcash ecosystem.
4
+
5
+ ## What It Solves
6
+
7
+ - One deterministic discovery contract across `agentcash`, `agentcash-router`, `the-stables`, and scanners.
8
+ - OpenAPI-first discovery with explicit compatibility fallbacks.
9
+ - Progressive runtime output (`discover`) and full debug/indexer output (`discoverDetailed`).
10
+
11
+ ## Discovery Order
12
+
13
+ Default order is:
14
+
15
+ 1. explicit override URLs (if provided)
16
+ 2. OpenAPI (`/openapi.json`, then `/.well-known/openapi.json`)
17
+ 3. `/.well-known/x402` (compat path)
18
+ 4. DNS TXT `_x402` pointers (compat path)
19
+ 5. live probe fallback (only when probe candidates are provided)
20
+
21
+ `discover` stops on the first valid non-empty stage.
22
+
23
+ `discoverDetailed` runs the full waterfall and merges deterministically.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ pnpm add @agentcash/discovery
29
+ ```
30
+
31
+ CLI audit:
32
+
33
+ ```bash
34
+ npx @agentcash/discovery stabletravel.dev
35
+ npx @agentcash/discovery stabletravel.dev -v
36
+ npx @agentcash/discovery stabletravel.dev --json
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```ts
42
+ import { discover, discoverDetailed } from '@agentcash/discovery';
43
+
44
+ const result = await discover({
45
+ target: 'https://api.example.com',
46
+ compatMode: 'on',
47
+ });
48
+
49
+ const detailed = await discoverDetailed({
50
+ target: 'api.example.com',
51
+ compatMode: 'strict',
52
+ rawView: 'full',
53
+ includeInteropMpp: true,
54
+ txtResolver: async (fqdn) => {
55
+ // Provide DNS TXT lookup in your runtime.
56
+ return [];
57
+ },
58
+ });
59
+ ```
60
+
61
+ ## Key API
62
+
63
+ - `discover(options)`: token-light, progressive, first-valid-non-empty.
64
+ - `discoverDetailed(options)`: full trace/details, merge across stages, optional raw artifacts.
65
+ - Both results include:
66
+ - `upgradeSuggested` (`boolean`)
67
+ - `upgradeReasons` (`string[]` warning-code reasons such as legacy-path usage)
68
+
69
+ ## Compatibility Controls
70
+
71
+ - `compatMode: 'on'` (default): enable legacy adapters.
72
+ - `compatMode: 'off'`: disable all legacy adapters.
73
+ - `compatMode: 'strict'`: enable legacy adapters and escalate legacy warnings to errors.
74
+
75
+ ## Internal Registry Audit Harness
76
+
77
+ Use this to benchmark compatibility against the x402scan registry dataset.
78
+
79
+ ```bash
80
+ SCAN_DATABASE_URL='postgresql://...' pnpm audit:registry
81
+ ```
82
+
83
+ Quick sample mode:
84
+
85
+ ```bash
86
+ SCAN_DATABASE_URL='postgresql://...' pnpm audit:registry:quick
87
+ ```
88
+
89
+ Outputs are written to:
90
+
91
+ - `audit/registry-audit-<timestamp>.json`
92
+ - `audit/registry-audit-latest.json`
93
+
94
+ ## Canonical Contract
95
+
96
+ Each normalized resource key is:
97
+
98
+ ```text
99
+ ${origin} ${method} ${path}
100
+ ```
101
+
102
+ Required per-resource fields:
103
+
104
+ - `resourceKey`
105
+ - `origin`
106
+ - `method`
107
+ - `path`
108
+ - `source`
109
+ - `verified` (defaults to `false`)
110
+
111
+ ## Philosophy Boundary
112
+
113
+ - Machine-parsable discovery metadata lives in OpenAPI.
114
+ - `llms.txt` is unstructured, optional domain guidance.
115
+ - Discovery is advisory. Runtime challenge/probe is authoritative.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { main } from '../dist/cli.js';
4
+
5
+ const exitCode = await main(process.argv.slice(2));
6
+ process.exit(exitCode);