@agentcash/discovery 0.1.0 → 0.1.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/AGENTS.md CHANGED
@@ -16,7 +16,6 @@ This repo implements canonical discovery logic for the agentcash ecosystem.
16
16
 
17
17
  - `src/core/*`: canonical OpenAPI-first discovery.
18
18
  - `src/compat/legacy-x402scan/*`: `/.well-known/x402` + DNS `_x402` compatibility.
19
- - `src/compat/interop-mpp/*`: optional registry interop adapter.
20
19
 
21
20
  ## Result Contract
22
21
 
package/README.md CHANGED
@@ -1,26 +1,26 @@
1
1
  # @agentcash/discovery
2
2
 
3
- Canonical discovery library for the agentcash ecosystem.
3
+ Canonical discovery runtime for the agentcash ecosystem.
4
4
 
5
- ## What It Solves
5
+ Use one library for CLI, server, and client so discovery behavior is identical everywhere.
6
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`).
7
+ ## Why One Library
10
8
 
11
- ## Discovery Order
9
+ - Same parsing logic across surfaces: no CLI/server/client drift.
10
+ - Same warning codes and precedence rules: fewer integration surprises.
11
+ - Same compatibility adapters in one place: legacy behavior is isolated and removable.
12
+ - Same L0-L5 harness model: easier context-budget auditing and rollout decisions.
12
13
 
13
- Default order is:
14
+ ## L0-L5 Mental Model
14
15
 
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.
16
+ - `L0` trigger layer: intents like `x402`, `pay for` should route to agentcash.
17
+ - `L1` installed domain index: which domains are installed and when to fan out.
18
+ - `L2` domain resources: token-light list (`discover <domain>`).
19
+ - `L3` resource details: schema and deep metadata (`discover <domain> --verbose`).
20
+ - `L4` domain guidance: unstructured guidance (`llms.txt`) when available.
21
+ - `L5` cross-domain composition: intentionally out of scope for discovery v1.
22
22
 
23
- `discoverDetailed` runs the full waterfall and merges deterministically.
23
+ Design rule: `L0` + `L1` are zero-hop critical. `L2+` should be fetched on demand.
24
24
 
25
25
  ## Install
26
26
 
@@ -28,88 +28,139 @@ Default order is:
28
28
  pnpm add @agentcash/discovery
29
29
  ```
30
30
 
31
- CLI audit:
31
+ ## CLI Usage
32
+
33
+ Quick audit:
32
34
 
33
35
  ```bash
34
36
  npx @agentcash/discovery stabletravel.dev
37
+ ```
38
+
39
+ Verbose matrices:
40
+
41
+ ```bash
35
42
  npx @agentcash/discovery stabletravel.dev -v
43
+ ```
44
+
45
+ Machine-readable output:
46
+
47
+ ```bash
36
48
  npx @agentcash/discovery stabletravel.dev --json
37
49
  ```
38
50
 
39
- ## Usage
51
+ L0-L5 context harness summary for a client:
40
52
 
41
- ```ts
42
- import { discover, discoverDetailed } from '@agentcash/discovery';
53
+ ```bash
54
+ npx @agentcash/discovery stabletravel.dev --harness --client claude-code
55
+ ```
56
+
57
+ L0-L5 harness verbose with explicit budget:
43
58
 
44
- const result = await discover({
45
- target: 'https://api.example.com',
59
+ ```bash
60
+ npx @agentcash/discovery stabletravel.dev --harness -v --client skill-cli --context-window-tokens 200000
61
+ ```
62
+
63
+ Useful flags:
64
+
65
+ - `--compat on|off|strict`
66
+ - `--probe`
67
+ - `--timeout-ms <ms>`
68
+ - `--no-truncate`
69
+ - `--no-color`
70
+
71
+ ## Programmatic Usage
72
+
73
+ ```ts
74
+ import {
75
+ auditContextHarness,
76
+ discover,
77
+ discoverDetailed,
78
+ type HarnessClientId,
79
+ } from '@agentcash/discovery';
80
+
81
+ const progressive = await discover({
82
+ target: 'stabletravel.dev',
46
83
  compatMode: 'on',
47
84
  });
48
85
 
49
86
  const detailed = await discoverDetailed({
50
- target: 'api.example.com',
87
+ target: 'stabletravel.dev',
51
88
  compatMode: 'strict',
52
89
  rawView: 'full',
53
- includeInteropMpp: true,
54
- txtResolver: async (fqdn) => {
55
- // Provide DNS TXT lookup in your runtime.
56
- return [];
57
- },
58
90
  });
59
- ```
60
-
61
- ## Key API
62
91
 
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
92
+ const client: HarnessClientId = 'claude-code';
93
+ const harness = await auditContextHarness({
94
+ target: 'stabletravel.dev',
95
+ client,
96
+ contextWindowTokens: 200000,
97
+ compatMode: 'on',
98
+ });
99
+ ```
70
100
 
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.
101
+ ## Discovery Waterfall
74
102
 
75
- ## Internal Registry Audit Harness
103
+ Default order:
76
104
 
77
- Use this to benchmark compatibility against the x402scan registry dataset.
78
-
79
- ```bash
80
- SCAN_DATABASE_URL='postgresql://...' pnpm audit:registry
81
- ```
105
+ 1. Explicit override URLs (if provided)
106
+ 2. OpenAPI (`/openapi.json`, then `/.well-known/openapi.json`)
107
+ 3. `/.well-known/x402` (compat)
108
+ 4. DNS TXT `_x402` pointers (compat)
109
+ 5. Probe fallback (only when probe candidates are provided)
82
110
 
83
- Quick sample mode:
111
+ Behavior:
84
112
 
85
- ```bash
86
- SCAN_DATABASE_URL='postgresql://...' pnpm audit:registry:quick
87
- ```
113
+ - `discover(...)` stops at first valid non-empty stage.
114
+ - `discoverDetailed(...)` runs full waterfall and merges deterministically.
88
115
 
89
- Outputs are written to:
116
+ ## Compatibility Modes
90
117
 
91
- - `audit/registry-audit-<timestamp>.json`
92
- - `audit/registry-audit-latest.json`
118
+ - `on` (default): legacy adapters enabled.
119
+ - `off`: canonical-only behavior.
120
+ - `strict`: legacy adapters enabled, selected warnings escalated.
93
121
 
94
- ## Canonical Contract
122
+ ## Contract Guarantees
95
123
 
96
- Each normalized resource key is:
124
+ Resource identity:
97
125
 
98
126
  ```text
99
127
  ${origin} ${method} ${path}
100
128
  ```
101
129
 
102
- Required per-resource fields:
130
+ Required normalized fields:
103
131
 
104
132
  - `resourceKey`
105
133
  - `origin`
106
134
  - `method`
107
135
  - `path`
108
136
  - `source`
109
- - `verified` (defaults to `false`)
137
+ - `verified` (default `false`)
138
+
139
+ Philosophy boundary:
140
+
141
+ - Machine-parsable discovery metadata belongs in OpenAPI.
142
+ - `llms.txt` is optional, unstructured guidance.
143
+ - Discovery is advisory. Runtime payment challenge/probe is authoritative.
144
+
145
+ ## Internal Registry Audit Harness
146
+
147
+ For x402scan registry benchmarking:
148
+
149
+ ```bash
150
+ SCAN_DATABASE_URL='postgresql://...' pnpm audit:registry
151
+ ```
152
+
153
+ Quick sample:
154
+
155
+ ```bash
156
+ SCAN_DATABASE_URL='postgresql://...' pnpm audit:registry:quick
157
+ ```
158
+
159
+ Output:
160
+
161
+ - `audit/registry-audit-<timestamp>.json`
162
+ - `audit/registry-audit-latest.json`
110
163
 
111
- ## Philosophy Boundary
164
+ ## Deeper Docs
112
165
 
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.
166
+ Architecture and planning artifacts live in `.claude/`.