@agentcash/discovery 0.1.4 → 1.0.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/dist/cli.cjs +1047 -2169
- package/dist/cli.d.cts +2 -14
- package/dist/cli.d.ts +2 -14
- package/dist/cli.js +1047 -2169
- package/dist/index.cjs +1273 -2170
- package/dist/index.d.cts +263 -284
- package/dist/index.d.ts +263 -284
- package/dist/index.js +1260 -2162
- package/dist/schemas.cjs +78 -25
- package/dist/schemas.d.cts +584 -27
- package/dist/schemas.d.ts +584 -27
- package/dist/schemas.js +72 -19
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,238 @@
|
|
|
1
|
+
import { ResultAsync } from 'neverthrow';
|
|
1
2
|
import { CompatibilityMode } from './flags.js';
|
|
2
|
-
|
|
3
|
+
|
|
4
|
+
type TrustTier = 'unverified' | 'origin_hosted' | 'ownership_verified' | 'runtime_verified';
|
|
5
|
+
type AuthMode = 'paid' | 'siwx' | 'apiKey' | 'apiKey+paid' | 'unprotected';
|
|
6
|
+
type PricingMode = 'fixed' | 'range' | 'quote';
|
|
7
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE';
|
|
8
|
+
|
|
9
|
+
interface MppPaymentOption {
|
|
10
|
+
protocol: 'mpp';
|
|
11
|
+
/** Payment method identifier, e.g. "tempo" (Tempo protocol). */ paymentMethod: string;
|
|
12
|
+
/** Payment intent type, e.g. "charge". */
|
|
13
|
+
intent: string;
|
|
14
|
+
/** Server protection realm. */
|
|
15
|
+
realm: string;
|
|
16
|
+
/** CAIP-2 style network identifier, e.g. "tempo:4217". */ network: string;
|
|
17
|
+
/** Currency / token contract. */
|
|
18
|
+
asset: string;
|
|
19
|
+
/** Raw token-unit amount string. */
|
|
20
|
+
amount: string;
|
|
21
|
+
/** Token decimal places, used for display conversion. */
|
|
22
|
+
decimals?: number;
|
|
23
|
+
/** Recipient address. */
|
|
24
|
+
payTo?: string;
|
|
25
|
+
/** Human-readable description of the resource. */
|
|
26
|
+
description?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface X402V1PaymentOption {
|
|
30
|
+
protocol: 'x402';
|
|
31
|
+
version: 1;
|
|
32
|
+
/** Payment scheme, e.g. "exact". */
|
|
33
|
+
scheme?: string;
|
|
34
|
+
/** CAIP-2 network identifier, e.g. "eip155:8453". */
|
|
35
|
+
network: string;
|
|
36
|
+
/** Token contract address. */
|
|
37
|
+
asset: string;
|
|
38
|
+
/** Upper-bound token-unit amount string (v1 semantics). */
|
|
39
|
+
maxAmountRequired: string;
|
|
40
|
+
/** Recipient wallet address. */
|
|
41
|
+
payTo?: string;
|
|
42
|
+
maxTimeoutSeconds?: number;
|
|
43
|
+
}
|
|
44
|
+
interface X402V2PaymentOption {
|
|
45
|
+
protocol: 'x402';
|
|
46
|
+
version: 2;
|
|
47
|
+
/** Payment scheme, e.g. "exact". */
|
|
48
|
+
scheme?: string;
|
|
49
|
+
/** CAIP-2 network identifier, e.g. "eip155:8453". */
|
|
50
|
+
network: string;
|
|
51
|
+
/** Token contract address. */
|
|
52
|
+
asset: string;
|
|
53
|
+
/** Exact token-unit amount string (v2 semantics). */
|
|
54
|
+
amount: string;
|
|
55
|
+
/** Recipient wallet address. */
|
|
56
|
+
payTo?: string;
|
|
57
|
+
maxTimeoutSeconds?: number;
|
|
58
|
+
}
|
|
59
|
+
type X402PaymentOption = X402V1PaymentOption | X402V2PaymentOption;
|
|
60
|
+
type PaymentOption = X402PaymentOption | MppPaymentOption;
|
|
61
|
+
interface PricingHint {
|
|
62
|
+
pricingMode: PricingMode;
|
|
63
|
+
price?: string;
|
|
64
|
+
minPrice?: string;
|
|
65
|
+
maxPrice?: string;
|
|
66
|
+
}
|
|
67
|
+
interface OpenApiSource {
|
|
68
|
+
raw: Record<string, unknown>;
|
|
69
|
+
info: {
|
|
70
|
+
title: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
version: string;
|
|
73
|
+
};
|
|
74
|
+
routes: OpenApiRoute[];
|
|
75
|
+
/** Inline guidance text from `info.guidance` — no fetch needed. Happy path for L4. */
|
|
76
|
+
guidance?: string;
|
|
77
|
+
fetchedUrl: string;
|
|
78
|
+
}
|
|
79
|
+
interface OpenApiRoute {
|
|
80
|
+
path: string;
|
|
81
|
+
method: HttpMethod;
|
|
82
|
+
summary?: string;
|
|
83
|
+
authMode?: AuthMode;
|
|
84
|
+
protocols?: string[];
|
|
85
|
+
pricing?: PricingHint;
|
|
86
|
+
}
|
|
87
|
+
interface WellKnownSource {
|
|
88
|
+
raw: Record<string, unknown>;
|
|
89
|
+
routes: WellKnownRoute[];
|
|
90
|
+
instructions?: string;
|
|
91
|
+
fetchedUrl: string;
|
|
92
|
+
}
|
|
93
|
+
interface WellKnownRoute {
|
|
94
|
+
path: string;
|
|
95
|
+
method: HttpMethod;
|
|
96
|
+
}
|
|
97
|
+
interface ProbeResult {
|
|
98
|
+
path: string;
|
|
99
|
+
method: HttpMethod;
|
|
100
|
+
authHint: AuthMode;
|
|
101
|
+
protocols?: string[];
|
|
102
|
+
/** Raw 402 response body, present when the endpoint returned a payment challenge. */
|
|
103
|
+
paymentRequiredBody?: unknown;
|
|
104
|
+
/** Raw WWW-Authenticate header value from the 402 response. */
|
|
105
|
+
wwwAuthenticate?: string;
|
|
106
|
+
}
|
|
107
|
+
interface L2Result {
|
|
108
|
+
title?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
routes: L2Route[];
|
|
111
|
+
source: 'openapi' | 'well-known/x402' | null;
|
|
112
|
+
}
|
|
113
|
+
interface L2Route {
|
|
114
|
+
path: string;
|
|
115
|
+
method: HttpMethod;
|
|
116
|
+
summary: string;
|
|
117
|
+
authMode?: AuthMode;
|
|
118
|
+
price?: string;
|
|
119
|
+
protocols?: string[];
|
|
120
|
+
}
|
|
121
|
+
interface L3Result {
|
|
122
|
+
source: 'openapi' | 'probe';
|
|
123
|
+
summary?: string;
|
|
124
|
+
authMode?: AuthMode;
|
|
125
|
+
estimatedPrice?: string;
|
|
126
|
+
protocols?: string[];
|
|
127
|
+
inputSchema?: Record<string, unknown>;
|
|
128
|
+
outputSchema?: Record<string, unknown>;
|
|
129
|
+
/** Live payment options parsed from the 402 response. Only present on probe results. */
|
|
130
|
+
paymentOptions?: PaymentOption[];
|
|
131
|
+
}
|
|
132
|
+
interface L4Result {
|
|
133
|
+
guidance: string;
|
|
134
|
+
source: 'openapi' | 'well-known/x402';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare enum GuidanceMode {
|
|
138
|
+
/** Include guidance only when under the auto-include threshold (default). */
|
|
139
|
+
Auto = "auto",
|
|
140
|
+
/** Always include guidance, even if large. */
|
|
141
|
+
Always = "always",
|
|
142
|
+
/** Never include guidance; return discovery data only. */
|
|
143
|
+
Never = "never"
|
|
144
|
+
}
|
|
145
|
+
interface DiscoverOriginSchemaOptions {
|
|
146
|
+
target: string;
|
|
147
|
+
guidance?: GuidanceMode;
|
|
148
|
+
specificationOverrideUrl?: string;
|
|
149
|
+
headers?: Record<string, string>;
|
|
150
|
+
signal?: AbortSignal;
|
|
151
|
+
}
|
|
152
|
+
interface DiscoverOriginSchemaSuccess {
|
|
153
|
+
found: true;
|
|
154
|
+
origin: string;
|
|
155
|
+
/** Which discovery context source produced the endpoint list (e.g. `"openapi"`). */
|
|
156
|
+
source: string;
|
|
157
|
+
/** Metadata from the OpenAPI `info` block, when available. */
|
|
158
|
+
info?: {
|
|
159
|
+
title: string;
|
|
160
|
+
description?: string;
|
|
161
|
+
};
|
|
162
|
+
/** Discovered endpoints with advisory pricing and auth metadata. */
|
|
163
|
+
endpoints: L2Route[];
|
|
164
|
+
/** True when guidance text exists for this API. */
|
|
165
|
+
guidanceAvailable: boolean;
|
|
166
|
+
/** Estimated token count of the guidance text. Present when guidanceAvailable is true. */
|
|
167
|
+
guidanceTokens?: number;
|
|
168
|
+
/** Guidance text. Included when short enough (auto mode) or guidance='always'. */
|
|
169
|
+
guidance?: string;
|
|
170
|
+
}
|
|
171
|
+
interface DiscoverOriginSchemaNotFound {
|
|
172
|
+
found: false;
|
|
173
|
+
origin: string;
|
|
174
|
+
cause: 'not_found' | 'network' | 'timeout';
|
|
175
|
+
message?: string;
|
|
176
|
+
}
|
|
177
|
+
type DiscoverOriginSchemaResult = DiscoverOriginSchemaSuccess | DiscoverOriginSchemaNotFound;
|
|
178
|
+
interface CheckEndpointOptions {
|
|
179
|
+
/** Full endpoint URL (e.g. `"https://api.example.com/pay"`). */
|
|
180
|
+
url: string;
|
|
181
|
+
headers?: Record<string, string>;
|
|
182
|
+
signal?: AbortSignal;
|
|
183
|
+
/** Sample input body for the endpoint.
|
|
184
|
+
*
|
|
185
|
+
* Providing this will cause the endpoint to always be probed, and will return the exact
|
|
186
|
+
* PaymentOptions that would be returned by the live 402 response.
|
|
187
|
+
*
|
|
188
|
+
* The agent will use this to get an exact price quote for the body they are planning on sending
|
|
189
|
+
* with fetch.
|
|
190
|
+
*
|
|
191
|
+
*/
|
|
192
|
+
sampleInputBody?: Record<string, unknown>;
|
|
193
|
+
}
|
|
194
|
+
interface EndpointMethodAdvisory extends L3Result {
|
|
195
|
+
method: HttpMethod;
|
|
196
|
+
}
|
|
197
|
+
interface CheckEndpointSuccess {
|
|
198
|
+
found: true;
|
|
199
|
+
origin: string;
|
|
200
|
+
path: string;
|
|
201
|
+
advisories: EndpointMethodAdvisory[];
|
|
202
|
+
}
|
|
203
|
+
interface CheckEndpointNotFound {
|
|
204
|
+
found: false;
|
|
205
|
+
origin: string;
|
|
206
|
+
path: string;
|
|
207
|
+
cause: 'not_found' | 'network' | 'timeout';
|
|
208
|
+
message?: string;
|
|
209
|
+
}
|
|
210
|
+
type CheckEndpointResult = CheckEndpointSuccess | CheckEndpointNotFound;
|
|
211
|
+
|
|
212
|
+
declare function discoverOriginSchema(options: DiscoverOriginSchemaOptions): Promise<DiscoverOriginSchemaResult>;
|
|
213
|
+
|
|
214
|
+
declare function checkEndpointSchema(options: CheckEndpointOptions): Promise<CheckEndpointResult>;
|
|
215
|
+
|
|
216
|
+
interface FetchError {
|
|
217
|
+
cause: 'network' | 'timeout';
|
|
218
|
+
message: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare function getOpenAPI(origin: string, headers?: Record<string, string>, signal?: AbortSignal, specificationOverrideUrl?: string): ResultAsync<OpenApiSource | null, FetchError>;
|
|
222
|
+
|
|
223
|
+
declare function getWellKnown(origin: string, headers?: Record<string, string>, signal?: AbortSignal): ResultAsync<WellKnownSource | null, FetchError>;
|
|
224
|
+
|
|
225
|
+
declare function getProbe(url: string, headers?: Record<string, string>, signal?: AbortSignal, inputBody?: Record<string, unknown>): ResultAsync<ProbeResult[], FetchError>;
|
|
226
|
+
|
|
227
|
+
declare function checkL2ForOpenAPI(openApi: OpenApiSource): L2Result;
|
|
228
|
+
declare function checkL2ForWellknown(wellKnown: WellKnownSource): L2Result;
|
|
229
|
+
|
|
230
|
+
declare function getL3ForOpenAPI(openApi: OpenApiSource, path: string, method: HttpMethod): L3Result | null;
|
|
231
|
+
declare function getL3ForProbe(probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
|
|
232
|
+
declare function getL3(openApi: OpenApiSource | null, probe: ProbeResult[], path: string, method: HttpMethod): L3Result | null;
|
|
233
|
+
|
|
234
|
+
declare function checkL4ForOpenAPI(openApi: OpenApiSource): L4Result | null;
|
|
235
|
+
declare function checkL4ForWellknown(wellKnown: WellKnownSource): L4Result | null;
|
|
3
236
|
|
|
4
237
|
declare const VALIDATION_CODES: {
|
|
5
238
|
readonly COINBASE_SCHEMA_INVALID: "COINBASE_SCHEMA_INVALID";
|
|
@@ -85,292 +318,38 @@ declare function evaluateMetadataCompleteness(metadata: MetadataPreview): Valida
|
|
|
85
318
|
|
|
86
319
|
declare function validatePaymentRequiredDetailed(payload: unknown, options?: ValidatePaymentRequiredOptions): ValidatePaymentRequiredDetailedResult;
|
|
87
320
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
321
|
+
declare const AUDIT_CODES: {
|
|
322
|
+
readonly OPENAPI_NOT_FOUND: "OPENAPI_NOT_FOUND";
|
|
323
|
+
readonly WELLKNOWN_NOT_FOUND: "WELLKNOWN_NOT_FOUND";
|
|
324
|
+
readonly OPENAPI_NO_ROUTES: "OPENAPI_NO_ROUTES";
|
|
325
|
+
readonly L2_NO_ROUTES: "L2_NO_ROUTES";
|
|
326
|
+
readonly L2_ROUTE_COUNT_HIGH: "L2_ROUTE_COUNT_HIGH";
|
|
327
|
+
readonly L2_AUTH_MODE_MISSING: "L2_AUTH_MODE_MISSING";
|
|
328
|
+
readonly L2_PRICE_MISSING_ON_PAID: "L2_PRICE_MISSING_ON_PAID";
|
|
329
|
+
readonly L2_PROTOCOLS_MISSING_ON_PAID: "L2_PROTOCOLS_MISSING_ON_PAID";
|
|
330
|
+
readonly L3_NOT_FOUND: "L3_NOT_FOUND";
|
|
331
|
+
readonly L3_INPUT_SCHEMA_MISSING: "L3_INPUT_SCHEMA_MISSING";
|
|
332
|
+
readonly L3_AUTH_MODE_MISSING: "L3_AUTH_MODE_MISSING";
|
|
333
|
+
readonly L3_PROTOCOLS_MISSING_ON_PAID: "L3_PROTOCOLS_MISSING_ON_PAID";
|
|
334
|
+
readonly L4_GUIDANCE_MISSING: "L4_GUIDANCE_MISSING";
|
|
335
|
+
readonly L4_GUIDANCE_TOO_LONG: "L4_GUIDANCE_TOO_LONG";
|
|
336
|
+
};
|
|
337
|
+
type AuditCode = (typeof AUDIT_CODES)[keyof typeof AUDIT_CODES];
|
|
338
|
+
|
|
339
|
+
type AuditSeverity = 'error' | 'warn' | 'info';
|
|
340
|
+
interface AuditWarning {
|
|
95
341
|
code: string;
|
|
96
|
-
severity:
|
|
342
|
+
severity: AuditSeverity;
|
|
97
343
|
message: string;
|
|
98
344
|
hint?: string;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
interface PricingHint {
|
|
103
|
-
pricingMode: PricingMode;
|
|
104
|
-
price?: string;
|
|
105
|
-
minPrice?: string;
|
|
106
|
-
maxPrice?: string;
|
|
107
|
-
}
|
|
108
|
-
interface ResourceLinks {
|
|
109
|
-
openapiUrl?: string;
|
|
110
|
-
wellKnownUrl?: string;
|
|
111
|
-
discoveryUrl?: string;
|
|
112
|
-
llmsTxtUrl?: string;
|
|
113
|
-
}
|
|
114
|
-
interface DiscoveryResource {
|
|
115
|
-
resourceKey: string;
|
|
116
|
-
origin: string;
|
|
117
|
-
method: HttpMethod;
|
|
118
|
-
path: string;
|
|
119
|
-
source: DiscoveryStage;
|
|
120
|
-
verified: boolean;
|
|
121
|
-
protocolHints?: string[];
|
|
122
|
-
priceHint?: string;
|
|
123
|
-
pricing?: PricingHint;
|
|
124
|
-
authHint?: AuthMode;
|
|
125
|
-
summary?: string;
|
|
126
|
-
confidence?: number;
|
|
127
|
-
trustTier?: TrustTier;
|
|
128
|
-
links?: ResourceLinks;
|
|
129
|
-
}
|
|
130
|
-
interface StageTrace {
|
|
131
|
-
stage: DiscoveryStage;
|
|
132
|
-
attempted: boolean;
|
|
133
|
-
valid: boolean;
|
|
134
|
-
resourceCount: number;
|
|
135
|
-
durationMs: number;
|
|
136
|
-
warnings: DiscoveryWarning[];
|
|
137
|
-
links?: ResourceLinks;
|
|
138
|
-
}
|
|
139
|
-
interface RawSources {
|
|
140
|
-
openapi?: unknown;
|
|
141
|
-
llmsTxt?: string;
|
|
142
|
-
wellKnownX402?: unknown[];
|
|
143
|
-
dnsRecords?: string[];
|
|
144
|
-
interopMpp?: unknown;
|
|
145
|
-
}
|
|
146
|
-
interface DiscoverResult {
|
|
147
|
-
origin: string;
|
|
148
|
-
resources: DiscoveryResource[];
|
|
149
|
-
warnings: DiscoveryWarning[];
|
|
150
|
-
compatMode: CompatibilityMode;
|
|
151
|
-
upgradeSuggested: boolean;
|
|
152
|
-
upgradeReasons: string[];
|
|
153
|
-
selectedStage?: DiscoveryStage;
|
|
154
|
-
}
|
|
155
|
-
interface DiscoverDetailedResult extends DiscoverResult {
|
|
156
|
-
trace: StageTrace[];
|
|
157
|
-
resourceWarnings: Record<string, DiscoveryWarning[]>;
|
|
158
|
-
rawSources?: RawSources;
|
|
159
|
-
}
|
|
160
|
-
type DiscoveryFetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
161
|
-
type TxtResolver = (fqdn: string) => Promise<string[]>;
|
|
162
|
-
interface ProbeCandidate {
|
|
163
|
-
path: string;
|
|
164
|
-
methods?: HttpMethod[];
|
|
165
|
-
}
|
|
166
|
-
interface DiscoverOptions {
|
|
167
|
-
target: string;
|
|
168
|
-
compatMode?: CompatibilityMode;
|
|
169
|
-
overrideUrls?: string[];
|
|
170
|
-
fetcher?: DiscoveryFetcher;
|
|
171
|
-
txtResolver?: TxtResolver;
|
|
172
|
-
probeCandidates?: ProbeCandidate[];
|
|
173
|
-
headers?: Record<string, string>;
|
|
174
|
-
signal?: AbortSignal;
|
|
175
|
-
}
|
|
176
|
-
interface DiscoverDetailedOptions extends DiscoverOptions {
|
|
177
|
-
rawView?: 'none' | 'full';
|
|
178
|
-
includeInteropMpp?: boolean;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
type McpFailureCause = 'not_found' | 'network' | 'timeout' | 'parse';
|
|
182
|
-
type McpAuthMode = 'paid' | 'siwx' | 'apiKey' | 'unprotected';
|
|
183
|
-
interface McpOpenApiInfo {
|
|
184
|
-
title: string;
|
|
185
|
-
version?: string;
|
|
186
|
-
description?: string;
|
|
187
|
-
}
|
|
188
|
-
interface McpEndpointSummary {
|
|
189
|
-
path: string;
|
|
190
|
-
method: HttpMethod;
|
|
191
|
-
summary: string;
|
|
192
|
-
price?: string;
|
|
193
|
-
protocols?: string[];
|
|
194
|
-
authMode?: McpAuthMode;
|
|
195
|
-
}
|
|
196
|
-
interface McpGuidance {
|
|
197
|
-
guidanceAvailable: boolean;
|
|
198
|
-
guidanceTokens?: number;
|
|
199
|
-
guidance?: string;
|
|
200
|
-
}
|
|
201
|
-
interface DiscoverForMcpOptions {
|
|
202
|
-
target: string;
|
|
203
|
-
includeGuidance?: boolean;
|
|
204
|
-
guidanceAutoIncludeMaxTokens?: number;
|
|
205
|
-
compatMode?: CompatibilityMode;
|
|
206
|
-
fetcher?: DiscoveryFetcher;
|
|
207
|
-
headers?: Record<string, string>;
|
|
208
|
-
signal?: AbortSignal;
|
|
209
|
-
}
|
|
210
|
-
interface DiscoverForMcpSuccess extends McpGuidance {
|
|
211
|
-
found: true;
|
|
212
|
-
origin: string;
|
|
213
|
-
source: string;
|
|
214
|
-
info?: McpOpenApiInfo;
|
|
215
|
-
endpoints: McpEndpointSummary[];
|
|
216
|
-
warnings: DiscoveryWarning[];
|
|
217
|
-
}
|
|
218
|
-
interface DiscoverForMcpFailure {
|
|
219
|
-
found: false;
|
|
220
|
-
origin: string;
|
|
221
|
-
cause: McpFailureCause;
|
|
222
|
-
message?: string;
|
|
223
|
-
warnings: DiscoveryWarning[];
|
|
224
|
-
}
|
|
225
|
-
type DiscoverForMcpResult = DiscoverForMcpSuccess | DiscoverForMcpFailure;
|
|
226
|
-
interface EndpointMethodAdvisory {
|
|
227
|
-
method: HttpMethod;
|
|
228
|
-
summary?: string;
|
|
229
|
-
estimatedPrice?: string;
|
|
230
|
-
protocols?: string[];
|
|
231
|
-
authMode?: McpAuthMode;
|
|
232
|
-
inputSchema?: Record<string, unknown>;
|
|
233
|
-
operationSchema?: Record<string, unknown>;
|
|
234
|
-
}
|
|
235
|
-
interface InspectEndpointForMcpOptions {
|
|
236
|
-
target: string;
|
|
237
|
-
endpointUrl: string;
|
|
238
|
-
compatMode?: CompatibilityMode;
|
|
239
|
-
fetcher?: DiscoveryFetcher;
|
|
240
|
-
headers?: Record<string, string>;
|
|
241
|
-
signal?: AbortSignal;
|
|
242
|
-
}
|
|
243
|
-
interface InspectEndpointForMcpSuccess {
|
|
244
|
-
found: true;
|
|
245
|
-
origin: string;
|
|
246
|
-
path: string;
|
|
247
|
-
specMethods: HttpMethod[];
|
|
248
|
-
advisories: Partial<Record<HttpMethod, EndpointMethodAdvisory>>;
|
|
249
|
-
warnings: DiscoveryWarning[];
|
|
250
|
-
}
|
|
251
|
-
interface InspectEndpointForMcpFailure {
|
|
252
|
-
found: false;
|
|
253
|
-
origin: string;
|
|
254
|
-
path: string;
|
|
255
|
-
cause: McpFailureCause;
|
|
256
|
-
message?: string;
|
|
257
|
-
warnings: DiscoveryWarning[];
|
|
258
|
-
}
|
|
259
|
-
type InspectEndpointForMcpResult = InspectEndpointForMcpSuccess | InspectEndpointForMcpFailure;
|
|
260
|
-
declare function discoverForMcp(options: DiscoverForMcpOptions): Promise<DiscoverForMcpResult>;
|
|
261
|
-
declare function inspectEndpointForMcp(options: InspectEndpointForMcpOptions): Promise<InspectEndpointForMcpResult>;
|
|
262
|
-
|
|
263
|
-
declare const UPGRADE_WARNING_CODES: readonly ["LEGACY_WELL_KNOWN_USED", "LEGACY_DNS_USED", "LEGACY_DNS_PLAIN_URL", "LEGACY_INSTRUCTIONS_USED", "LEGACY_OWNERSHIP_PROOFS_USED", "OPENAPI_AUTH_MODE_MISSING", "OPENAPI_TOP_LEVEL_INVALID"];
|
|
264
|
-
declare function computeUpgradeSignal(warnings: DiscoveryWarning[]): {
|
|
265
|
-
upgradeSuggested: boolean;
|
|
266
|
-
upgradeReasons: string[];
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
type HarnessClientId = 'claude-code' | 'skill-cli' | 'generic-mcp' | 'generic';
|
|
270
|
-
interface HarnessClientProfile {
|
|
271
|
-
id: HarnessClientId;
|
|
272
|
-
label: string;
|
|
273
|
-
surface: 'mcp' | 'skill-cli' | 'generic';
|
|
274
|
-
defaultContextWindowTokens: number;
|
|
275
|
-
zeroHopBudgetPercent: number;
|
|
276
|
-
notes: string;
|
|
277
|
-
}
|
|
278
|
-
interface ContextHarnessL0 {
|
|
279
|
-
layer: 'L0';
|
|
280
|
-
intentTriggers: string[];
|
|
281
|
-
installCommand: string;
|
|
282
|
-
deliverySurfaces: string[];
|
|
283
|
-
summary: string;
|
|
284
|
-
estimatedTokens: number;
|
|
285
|
-
}
|
|
286
|
-
interface ContextHarnessL1 {
|
|
287
|
-
layer: 'L1';
|
|
288
|
-
domain: string;
|
|
289
|
-
domainClass: 'first-party' | 'ugc';
|
|
290
|
-
selectedDiscoveryStage: DiscoverResult['selectedStage'] | null;
|
|
291
|
-
summary: string;
|
|
292
|
-
fanoutCommands: string[];
|
|
293
|
-
estimatedTokens: number;
|
|
294
|
-
}
|
|
295
|
-
interface ContextHarnessL2Entry {
|
|
296
|
-
resourceKey: string;
|
|
297
|
-
method: DiscoveryResource['method'];
|
|
298
|
-
path: string;
|
|
299
|
-
source: DiscoveryResource['source'];
|
|
300
|
-
authMode: DiscoveryResource['authHint'] | null;
|
|
301
|
-
}
|
|
302
|
-
interface ContextHarnessL2 {
|
|
303
|
-
layer: 'L2';
|
|
304
|
-
command: string;
|
|
305
|
-
tokenLight: boolean;
|
|
306
|
-
resourceCount: number;
|
|
307
|
-
resources: ContextHarnessL2Entry[];
|
|
308
|
-
}
|
|
309
|
-
interface ContextHarnessL3 {
|
|
310
|
-
layer: 'L3';
|
|
311
|
-
command: string;
|
|
312
|
-
detailLevel: 'endpoint-schema-and-metadata';
|
|
313
|
-
countsByAuthMode: Record<'paid' | 'siwx' | 'apiKey' | 'unprotected' | 'unknown', number>;
|
|
314
|
-
countsBySource: Record<string, number>;
|
|
315
|
-
pricedResourceCount: number;
|
|
316
|
-
}
|
|
317
|
-
interface ContextHarnessL4 {
|
|
318
|
-
layer: 'L4';
|
|
319
|
-
guidanceSource: 'llms.txt' | 'none';
|
|
320
|
-
llmsTxtUrl: string | null;
|
|
321
|
-
llmsTxtTokenEstimate: number;
|
|
322
|
-
guidancePreview: string | null;
|
|
323
|
-
guidanceStatus: 'present' | 'advertised_but_unfetched' | 'missing' | 'not_advertised';
|
|
324
|
-
}
|
|
325
|
-
interface ContextHarnessL5 {
|
|
326
|
-
layer: 'L5';
|
|
327
|
-
status: 'out_of_scope';
|
|
328
|
-
note: string;
|
|
329
|
-
}
|
|
330
|
-
interface ContextHarnessBudget {
|
|
331
|
-
contextWindowTokens: number;
|
|
332
|
-
zeroHopBudgetTokens: number;
|
|
333
|
-
estimatedZeroHopTokens: number;
|
|
334
|
-
withinBudget: boolean;
|
|
335
|
-
}
|
|
336
|
-
interface ContextHarnessReport {
|
|
337
|
-
target: string;
|
|
338
|
-
origin: string;
|
|
339
|
-
client: HarnessClientProfile;
|
|
340
|
-
budget: ContextHarnessBudget;
|
|
341
|
-
levels: {
|
|
342
|
-
l0: ContextHarnessL0;
|
|
343
|
-
l1: ContextHarnessL1;
|
|
344
|
-
l2: ContextHarnessL2;
|
|
345
|
-
l3: ContextHarnessL3;
|
|
346
|
-
l4: ContextHarnessL4;
|
|
347
|
-
l5: ContextHarnessL5;
|
|
348
|
-
};
|
|
349
|
-
diagnostics: {
|
|
350
|
-
warningCount: number;
|
|
351
|
-
errorWarningCount: number;
|
|
352
|
-
selectedStage: DiscoverResult['selectedStage'] | null;
|
|
353
|
-
upgradeSuggested: boolean;
|
|
354
|
-
upgradeReasons: string[];
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
interface BuildContextHarnessReportOptions {
|
|
358
|
-
target: string;
|
|
359
|
-
result: DiscoverDetailedResult;
|
|
360
|
-
client?: HarnessClientId;
|
|
361
|
-
contextWindowTokens?: number;
|
|
362
|
-
}
|
|
363
|
-
interface AuditContextHarnessOptions extends Omit<DiscoverDetailedOptions, 'rawView'> {
|
|
364
|
-
client?: HarnessClientId;
|
|
365
|
-
contextWindowTokens?: number;
|
|
345
|
+
/** Dotted path to the field this warning refers to, when applicable. */
|
|
346
|
+
path?: string;
|
|
366
347
|
}
|
|
367
|
-
declare function getHarnessClientProfile(client?: HarnessClientId): HarnessClientProfile;
|
|
368
|
-
declare function listHarnessClientProfiles(): HarnessClientProfile[];
|
|
369
|
-
declare function buildContextHarnessReport(options: BuildContextHarnessReportOptions): ContextHarnessReport;
|
|
370
|
-
declare function auditContextHarness(options: AuditContextHarnessOptions): Promise<ContextHarnessReport>;
|
|
371
|
-
declare function defaultHarnessProbeCandidates(report: ContextHarnessReport): ProbeCandidate[];
|
|
372
348
|
|
|
373
|
-
declare function
|
|
374
|
-
declare function
|
|
349
|
+
declare function getWarningsForOpenAPI(openApi: OpenApiSource | null): AuditWarning[];
|
|
350
|
+
declare function getWarningsForWellKnown(wellKnown: WellKnownSource | null): AuditWarning[];
|
|
351
|
+
declare function getWarningsForL2(l2: L2Result): AuditWarning[];
|
|
352
|
+
declare function getWarningsForL3(l3: L3Result | null): AuditWarning[];
|
|
353
|
+
declare function getWarningsForL4(l4: L4Result | null): AuditWarning[];
|
|
375
354
|
|
|
376
|
-
export {
|
|
355
|
+
export { AUDIT_CODES, type AuditCode, type AuditSeverity, type AuditWarning, type AuthMode, type CheckEndpointNotFound, type CheckEndpointOptions, type CheckEndpointResult, type CheckEndpointSuccess, type DiscoverOriginSchemaNotFound, type DiscoverOriginSchemaOptions, type DiscoverOriginSchemaResult, type DiscoverOriginSchemaSuccess, type EndpointMethodAdvisory, GuidanceMode, type HttpMethod, type L2Result, type L2Route, type L3Result, type L4Result, type MetadataPreview, type MppPaymentOption, type NormalizedAccept, type NormalizedPaymentRequired, type OpenApiRoute, type OpenApiSource, type PaymentOption, type PricingMode, type ProbeResult, type TrustTier, VALIDATION_CODES, type ValidatePaymentRequiredDetailedResult, type ValidatePaymentRequiredOptions, type ValidationIssue, type ValidationSeverity, type ValidationStage, type ValidationSummary, type WellKnownRoute, type WellKnownSource, type X402PaymentOption, type X402V1PaymentOption, type X402V2PaymentOption, checkEndpointSchema, checkL2ForOpenAPI, checkL2ForWellknown, checkL4ForOpenAPI, checkL4ForWellknown, discoverOriginSchema, evaluateMetadataCompleteness, getL3, getL3ForOpenAPI, getL3ForProbe, getOpenAPI, getProbe, getWarningsForL2, getWarningsForL3, getWarningsForL4, getWarningsForOpenAPI, getWarningsForWellKnown, getWellKnown, validatePaymentRequiredDetailed };
|