agent0-sdk 1.6.0 → 1.7.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/README.md +16 -19
- package/dist/core/a2a-client.d.ts +109 -0
- package/dist/core/a2a-client.d.ts.map +1 -0
- package/dist/core/a2a-client.js +792 -0
- package/dist/core/a2a-client.js.map +1 -0
- package/dist/core/a2a-summary-client.d.ts +28 -0
- package/dist/core/a2a-summary-client.d.ts.map +1 -0
- package/dist/core/a2a-summary-client.js +79 -0
- package/dist/core/a2a-summary-client.js.map +1 -0
- package/dist/core/agent.d.ts +65 -3
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +242 -7
- package/dist/core/agent.js.map +1 -1
- package/dist/core/contracts.d.ts +5 -0
- package/dist/core/contracts.d.ts.map +1 -1
- package/dist/core/contracts.js +11 -0
- package/dist/core/contracts.js.map +1 -1
- package/dist/core/endpoint-crawler.d.ts +10 -0
- package/dist/core/endpoint-crawler.d.ts.map +1 -1
- package/dist/core/endpoint-crawler.js +59 -4
- package/dist/core/endpoint-crawler.js.map +1 -1
- package/dist/core/sdk.d.ts +56 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +148 -16
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/viem-chain-client.d.ts.map +1 -1
- package/dist/core/viem-chain-client.js +5 -4
- package/dist/core/viem-chain-client.js.map +1 -1
- package/dist/core/x402-payment.d.ts +28 -0
- package/dist/core/x402-payment.d.ts.map +1 -0
- package/dist/core/x402-payment.js +242 -0
- package/dist/core/x402-payment.js.map +1 -0
- package/dist/core/x402-request.d.ts +33 -0
- package/dist/core/x402-request.d.ts.map +1 -0
- package/dist/core/x402-request.js +195 -0
- package/dist/core/x402-request.js.map +1 -0
- package/dist/core/x402-types.d.ts +147 -0
- package/dist/core/x402-types.d.ts.map +1 -0
- package/dist/core/x402-types.js +190 -0
- package/dist/core/x402-types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/models/a2a.d.ts +176 -0
- package/dist/models/a2a.d.ts.map +1 -0
- package/dist/models/a2a.js +5 -0
- package/dist/models/a2a.js.map +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -0
- package/dist/models/index.js.map +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* x402 payment-required types and 402 response parsing.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A single payment option from a 402 response (PAYMENT-REQUIRED header).
|
|
6
|
+
* Each entry has at least price and token; optional fields for network, scheme, etc.
|
|
7
|
+
*/
|
|
8
|
+
export interface X402Accept {
|
|
9
|
+
/** Amount in smallest units (e.g. USDC 6 decimals). May be string for large values. */
|
|
10
|
+
price: string;
|
|
11
|
+
/** Token contract address or symbol. */
|
|
12
|
+
token: string;
|
|
13
|
+
/** Chain id (number or string e.g. "base-sepolia", "eip155:84532"). */
|
|
14
|
+
network?: string;
|
|
15
|
+
scheme?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
/** Max amount required when variable. */
|
|
18
|
+
maxAmountRequired?: string;
|
|
19
|
+
/** Destination / pay-to address (recipient or verifying contract). */
|
|
20
|
+
destination?: string;
|
|
21
|
+
/** Asset address (alias for token in some 402 body shapes). */
|
|
22
|
+
asset?: string;
|
|
23
|
+
/** Additional fields from server (e.g. payTo, paymentRequirements). */
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Payment-required payload returned when the server responds with HTTP 402.
|
|
28
|
+
* Always includes accepts[]; when there is a single accept, convenience fields may be set.
|
|
29
|
+
*/
|
|
30
|
+
export interface X402Payment<T = unknown> {
|
|
31
|
+
/** Array of accepted payment options. Always present. */
|
|
32
|
+
accepts: X402Accept[];
|
|
33
|
+
/** x402 version from server's PAYMENT-REQUIRED header (e.g. 1 or 2). */
|
|
34
|
+
x402Version?: number;
|
|
35
|
+
/** V1/V2 human-readable error message from 402 response when present. */
|
|
36
|
+
error?: string;
|
|
37
|
+
/** V2 ResourceInfo from 402 response when present. */
|
|
38
|
+
resource?: ResourceInfo;
|
|
39
|
+
/** When single accept: convenience price (same as accepts[0].price). */
|
|
40
|
+
price?: string;
|
|
41
|
+
/** When single accept: convenience token (same as accepts[0].token). */
|
|
42
|
+
token?: string;
|
|
43
|
+
/** When single accept: convenience network (same as accepts[0].network). */
|
|
44
|
+
network?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Performs payment and retries the request.
|
|
47
|
+
* No arg = use single accept; number = accepts[index]; X402Accept = chosen option.
|
|
48
|
+
* Resolves to the same shape as a successful request (no x402Required).
|
|
49
|
+
*/
|
|
50
|
+
pay(accept?: X402Accept | number): Promise<T>;
|
|
51
|
+
/**
|
|
52
|
+
* When present (deps provided checkBalance): pays using the first accept for which
|
|
53
|
+
* the signer has sufficient token balance on that chain. Throws if none have sufficient balance.
|
|
54
|
+
*/
|
|
55
|
+
payFirst?(): Promise<T>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Options for the generic x402 HTTP request.
|
|
59
|
+
*/
|
|
60
|
+
export interface X402RequestOptions<T = unknown> {
|
|
61
|
+
url: string;
|
|
62
|
+
method: string;
|
|
63
|
+
headers?: Record<string, string>;
|
|
64
|
+
body?: string | ArrayBuffer | Uint8Array;
|
|
65
|
+
/**
|
|
66
|
+
* Optional parser for 2xx response body. If omitted, the body is parsed as JSON (res.json()).
|
|
67
|
+
*/
|
|
68
|
+
parseResponse?: (response: Response) => Promise<T>;
|
|
69
|
+
/**
|
|
70
|
+
* Optional payment to send with the first request (e.g. base64 PAYMENT-SIGNATURE payload).
|
|
71
|
+
* If provided and server returns 2xx, one round trip; if 402, normal x402 flow.
|
|
72
|
+
*/
|
|
73
|
+
payment?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Response when server returns HTTP 402. Caller checks x402Required and may call x402Payment.pay().
|
|
77
|
+
*/
|
|
78
|
+
export interface X402RequiredResponse<T> {
|
|
79
|
+
x402Required: true;
|
|
80
|
+
x402Payment: X402Payment<T>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Result of sdk.request(): either the parsed success value or the 402 response object.
|
|
84
|
+
* Success branch is typed with x402Required?: false so you can always read result.x402Required
|
|
85
|
+
* (undefined/false on success, true on 402) and use if (result.x402Required) to narrow.
|
|
86
|
+
*/
|
|
87
|
+
export type X402RequestResult<T> = (T & {
|
|
88
|
+
x402Required?: false;
|
|
89
|
+
}) | X402RequiredResponse<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Type guard: result is 402 response. Returns false for null/undefined.
|
|
92
|
+
*/
|
|
93
|
+
export declare function isX402Required<T>(result: X402RequestResult<T> | null | undefined): result is X402RequiredResponse<T>;
|
|
94
|
+
/** Filter accepts to EVM-only (Solana and other non-EVM options removed). Applied when building 402 response. */
|
|
95
|
+
export declare function filterEvmAccepts(accepts: X402Accept[]): X402Accept[];
|
|
96
|
+
/**
|
|
97
|
+
* Result of parsing PAYMENT-REQUIRED header (accepts + optional version, resource, error).
|
|
98
|
+
*/
|
|
99
|
+
export interface Parse402FromHeaderResult {
|
|
100
|
+
accepts: X402Accept[];
|
|
101
|
+
x402Version?: number;
|
|
102
|
+
/** V2 PaymentRequired top-level resource (ResourceInfo). Present when server sends it. */
|
|
103
|
+
resource?: ResourceInfo;
|
|
104
|
+
/** V1 PaymentRequirementsResponse human-readable error message. Present when server sends it. */
|
|
105
|
+
error?: string;
|
|
106
|
+
}
|
|
107
|
+
/** V2 ResourceInfo: url, optional description and mimeType (x402 spec §5.1). */
|
|
108
|
+
export interface ResourceInfo {
|
|
109
|
+
url?: string;
|
|
110
|
+
description?: string;
|
|
111
|
+
mimeType?: string;
|
|
112
|
+
}
|
|
113
|
+
/** Settlement response (SettlementResponse / SettleResponse) from PAYMENT-RESPONSE header or body after successful pay. */
|
|
114
|
+
export interface X402SettlementResponse {
|
|
115
|
+
success: boolean;
|
|
116
|
+
errorReason?: string;
|
|
117
|
+
transaction?: string;
|
|
118
|
+
network?: string;
|
|
119
|
+
payer?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Parse PAYMENT-REQUIRED header (x402 spec: base64-encoded JSON with accepts array).
|
|
123
|
+
* Returns accepts, x402Version, and when present resource (v2) and error (v1).
|
|
124
|
+
*/
|
|
125
|
+
export declare function parse402FromHeader(headerValue: string | null): Parse402FromHeaderResult;
|
|
126
|
+
/**
|
|
127
|
+
* Parse WWW-Authenticate header with x402 challenge (e.g. 402payment-test.com).
|
|
128
|
+
* Format: x402 address="0x...", amount="0.01", chainId="8453", token="0x..."
|
|
129
|
+
* Returns a single accept; amount is converted to atomic units if it looks like a decimal (USDC 6 decimals).
|
|
130
|
+
*/
|
|
131
|
+
export declare function parse402FromWWWAuthenticate(headerValue: string | null): Parse402FromHeaderResult;
|
|
132
|
+
/**
|
|
133
|
+
* Parse 402 response body (JSON with accepts array). Used when server sends payment options in body (e.g. httpay.xyz).
|
|
134
|
+
* Returns accepts, x402Version, and when present resource (v2) and error (v1).
|
|
135
|
+
*/
|
|
136
|
+
export declare function parse402FromBody(bodyText: string | null): Parse402FromHeaderResult;
|
|
137
|
+
/**
|
|
138
|
+
* Parse PAYMENT-REQUIRED header (x402 spec: base64-encoded JSON with accepts array).
|
|
139
|
+
* Server sends payment options in header; body may be empty. Returns [] if header missing/invalid.
|
|
140
|
+
*/
|
|
141
|
+
export declare function parse402AcceptsFromHeader(headerValue: string | null): X402Accept[];
|
|
142
|
+
/**
|
|
143
|
+
* Parse PAYMENT-RESPONSE header (base64-encoded JSON) after successful pay.
|
|
144
|
+
* Returns settlement info (success, transaction, network, payer) when present and valid.
|
|
145
|
+
*/
|
|
146
|
+
export declare function parse402SettlementFromHeader(headerValue: string | null): X402SettlementResponse | undefined;
|
|
147
|
+
//# sourceMappingURL=x402-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402-types.d.ts","sourceRoot":"","sources":["../../src/core/x402-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,uFAAuF;IACvF,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,yDAAyD;IACzD,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,GAAG,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACzB;AAED;;GAE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E,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2HAA2H;AAC3H,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,wBAAwB,CAkBvF;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,wBAAwB,CAqChG;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,wBAAwB,CAkBlF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,EAAE,CAElF;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,sBAAsB,GAAG,SAAS,CAe3G"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* x402 payment-required types and 402 response parsing.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Type guard: result is 402 response. Returns false for null/undefined.
|
|
6
|
+
*/
|
|
7
|
+
export function isX402Required(result) {
|
|
8
|
+
return typeof result === 'object' && result !== null && 'x402Required' in result && result.x402Required === true;
|
|
9
|
+
}
|
|
10
|
+
/** True if the accept is EVM (eip155:* or numeric network). Used to filter out Solana etc. */
|
|
11
|
+
function isEvmAccept(a) {
|
|
12
|
+
const n = a.network;
|
|
13
|
+
if (n == null || n === '')
|
|
14
|
+
return true;
|
|
15
|
+
const s = String(n);
|
|
16
|
+
return /^eip155:\d+$/.test(s) || /^\d+$/.test(s);
|
|
17
|
+
}
|
|
18
|
+
/** Filter accepts to EVM-only (Solana and other non-EVM options removed). Applied when building 402 response. */
|
|
19
|
+
export function filterEvmAccepts(accepts) {
|
|
20
|
+
return accepts.filter(isEvmAccept);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Normalize a single accept entry from PAYMENT-REQUIRED header (amount/asset/payTo → price/token/destination).
|
|
24
|
+
*/
|
|
25
|
+
function normalizeAcceptEntry(entry) {
|
|
26
|
+
const pr = entry.paymentRequirements || entry;
|
|
27
|
+
const price = pr.price ?? pr.amount ?? pr.maxAmountRequired ?? '0';
|
|
28
|
+
const token = pr.token ?? pr.asset ?? '';
|
|
29
|
+
return {
|
|
30
|
+
price: String(price),
|
|
31
|
+
token: String(token),
|
|
32
|
+
network: pr.network,
|
|
33
|
+
scheme: pr.scheme,
|
|
34
|
+
description: pr.description,
|
|
35
|
+
maxAmountRequired: pr.maxAmountRequired,
|
|
36
|
+
destination: pr.destination ?? pr.payTo,
|
|
37
|
+
asset: pr.asset,
|
|
38
|
+
...entry,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function decodeBase64(b64) {
|
|
42
|
+
if (typeof Buffer !== 'undefined') {
|
|
43
|
+
return Buffer.from(b64, 'base64').toString('utf8');
|
|
44
|
+
}
|
|
45
|
+
return atob(b64);
|
|
46
|
+
}
|
|
47
|
+
function parseResourceInfo(obj) {
|
|
48
|
+
if (obj == null || typeof obj !== 'object' || Array.isArray(obj))
|
|
49
|
+
return undefined;
|
|
50
|
+
const r = obj;
|
|
51
|
+
const url = typeof r.url === 'string' ? r.url : undefined;
|
|
52
|
+
if (url === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
return {
|
|
55
|
+
url,
|
|
56
|
+
description: typeof r.description === 'string' ? r.description : undefined,
|
|
57
|
+
mimeType: typeof r.mimeType === 'string' ? r.mimeType : undefined,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Parse PAYMENT-REQUIRED header (x402 spec: base64-encoded JSON with accepts array).
|
|
62
|
+
* Returns accepts, x402Version, and when present resource (v2) and error (v1).
|
|
63
|
+
*/
|
|
64
|
+
export function parse402FromHeader(headerValue) {
|
|
65
|
+
if (!headerValue || typeof headerValue !== 'string')
|
|
66
|
+
return { accepts: [] };
|
|
67
|
+
try {
|
|
68
|
+
const json = JSON.parse(decodeBase64(headerValue.trim()));
|
|
69
|
+
if (json == null || typeof json !== 'object')
|
|
70
|
+
return { accepts: [] };
|
|
71
|
+
const list = json.accepts;
|
|
72
|
+
const accepts = Array.isArray(list)
|
|
73
|
+
? list
|
|
74
|
+
.filter((e) => typeof e === 'object' && e !== null)
|
|
75
|
+
.map(normalizeAcceptEntry)
|
|
76
|
+
: [];
|
|
77
|
+
const x402Version = typeof json.x402Version === 'number' ? json.x402Version : undefined;
|
|
78
|
+
const resource = parseResourceInfo(json.resource);
|
|
79
|
+
const error = typeof json.error === 'string' ? json.error : undefined;
|
|
80
|
+
return { accepts, x402Version, resource, error };
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return { accepts: [] };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Parse WWW-Authenticate header with x402 challenge (e.g. 402payment-test.com).
|
|
88
|
+
* Format: x402 address="0x...", amount="0.01", chainId="8453", token="0x..."
|
|
89
|
+
* Returns a single accept; amount is converted to atomic units if it looks like a decimal (USDC 6 decimals).
|
|
90
|
+
*/
|
|
91
|
+
export function parse402FromWWWAuthenticate(headerValue) {
|
|
92
|
+
if (!headerValue || typeof headerValue !== 'string')
|
|
93
|
+
return { accepts: [] };
|
|
94
|
+
const x402Match = headerValue.match(/\bx402\s+(.+)/i);
|
|
95
|
+
if (!x402Match)
|
|
96
|
+
return { accepts: [] };
|
|
97
|
+
const rest = x402Match[1];
|
|
98
|
+
const pairs = {};
|
|
99
|
+
const re = /(\w+)\s*=\s*([^\s,]+|"[^"]*")/g;
|
|
100
|
+
let m;
|
|
101
|
+
while ((m = re.exec(rest)) !== null) {
|
|
102
|
+
const key = m[1].toLowerCase();
|
|
103
|
+
let val = m[2];
|
|
104
|
+
if (val.startsWith('"') && val.endsWith('"'))
|
|
105
|
+
val = val.slice(1, -1);
|
|
106
|
+
pairs[key] = val;
|
|
107
|
+
}
|
|
108
|
+
const address = pairs.address ?? pairs.payto;
|
|
109
|
+
const amount = pairs.amount ?? '0';
|
|
110
|
+
const chainId = pairs.chainid ?? pairs.chain_id ?? '';
|
|
111
|
+
const token = pairs.token ?? pairs.asset ?? '';
|
|
112
|
+
if (!address || !token)
|
|
113
|
+
return { accepts: [] };
|
|
114
|
+
// If amount looks like decimal (e.g. "0.01"), assume USDC 6 decimals for atomic units
|
|
115
|
+
let price = amount;
|
|
116
|
+
if (/^\d*\.\d+$/.test(amount)) {
|
|
117
|
+
const n = parseFloat(amount);
|
|
118
|
+
if (Number.isFinite(n))
|
|
119
|
+
price = String(Math.round(n * 1e6));
|
|
120
|
+
}
|
|
121
|
+
const networkStr = chainId ? (chainId.includes(':') ? chainId : `eip155:${chainId}`) : undefined;
|
|
122
|
+
const accept = {
|
|
123
|
+
price,
|
|
124
|
+
token,
|
|
125
|
+
destination: address,
|
|
126
|
+
payTo: address,
|
|
127
|
+
network: networkStr,
|
|
128
|
+
scheme: 'exact',
|
|
129
|
+
};
|
|
130
|
+
// Servers that advertise chainId (e.g. 402payment-test.com) often expect v2 (PAYMENT-SIGNATURE + CAIP-2).
|
|
131
|
+
const x402Version = networkStr && /^eip155:\d+$/.test(networkStr) ? 2 : 1;
|
|
132
|
+
return { accepts: [accept], x402Version };
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Parse 402 response body (JSON with accepts array). Used when server sends payment options in body (e.g. httpay.xyz).
|
|
136
|
+
* Returns accepts, x402Version, and when present resource (v2) and error (v1).
|
|
137
|
+
*/
|
|
138
|
+
export function parse402FromBody(bodyText) {
|
|
139
|
+
if (!bodyText || typeof bodyText !== 'string')
|
|
140
|
+
return { accepts: [] };
|
|
141
|
+
try {
|
|
142
|
+
const json = JSON.parse(bodyText.trim());
|
|
143
|
+
if (json == null || typeof json !== 'object')
|
|
144
|
+
return { accepts: [] };
|
|
145
|
+
const list = json.accepts;
|
|
146
|
+
const accepts = Array.isArray(list)
|
|
147
|
+
? list
|
|
148
|
+
.filter((e) => typeof e === 'object' && e !== null)
|
|
149
|
+
.map(normalizeAcceptEntry)
|
|
150
|
+
: [];
|
|
151
|
+
const x402Version = typeof json.x402Version === 'number' ? json.x402Version : undefined;
|
|
152
|
+
const resource = parseResourceInfo(json.resource);
|
|
153
|
+
const error = typeof json.error === 'string' ? json.error : undefined;
|
|
154
|
+
return { accepts, x402Version, resource, error };
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return { accepts: [] };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Parse PAYMENT-REQUIRED header (x402 spec: base64-encoded JSON with accepts array).
|
|
162
|
+
* Server sends payment options in header; body may be empty. Returns [] if header missing/invalid.
|
|
163
|
+
*/
|
|
164
|
+
export function parse402AcceptsFromHeader(headerValue) {
|
|
165
|
+
return parse402FromHeader(headerValue).accepts;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Parse PAYMENT-RESPONSE header (base64-encoded JSON) after successful pay.
|
|
169
|
+
* Returns settlement info (success, transaction, network, payer) when present and valid.
|
|
170
|
+
*/
|
|
171
|
+
export function parse402SettlementFromHeader(headerValue) {
|
|
172
|
+
if (!headerValue || typeof headerValue !== 'string')
|
|
173
|
+
return undefined;
|
|
174
|
+
try {
|
|
175
|
+
const json = JSON.parse(decodeBase64(headerValue.trim()));
|
|
176
|
+
if (json == null || typeof json !== 'object')
|
|
177
|
+
return undefined;
|
|
178
|
+
return {
|
|
179
|
+
success: json.success === true,
|
|
180
|
+
errorReason: typeof json.errorReason === 'string' ? json.errorReason : undefined,
|
|
181
|
+
transaction: typeof json.transaction === 'string' ? json.transaction : undefined,
|
|
182
|
+
network: typeof json.network === 'string' ? json.network : undefined,
|
|
183
|
+
payer: typeof json.payer === 'string' ? json.payer : undefined,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=x402-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402-types.js","sourceRoot":"","sources":["../../src/core/x402-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2FH;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,MAA+C;IAE/C,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,cAAc,IAAI,MAAM,IAAK,MAAkC,CAAC,YAAY,KAAK,IAAI,CAAC;AAChJ,CAAC;AAED,8FAA8F;AAC9F,SAAS,WAAW,CAAC,CAAa;IAChC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;IACpB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IACvC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,iHAAiH;AACjH,MAAM,UAAU,gBAAgB,CAAC,OAAqB;IACpD,OAAO,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,KAA8B;IAC1D,MAAM,EAAE,GAAI,KAAK,CAAC,mBAA2D,IAAI,KAAK,CAAC;IACvF,MAAM,KAAK,GACR,EAAE,CAAC,KAAgB,IAAK,EAAE,CAAC,MAAiB,IAAK,EAAE,C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AAI,OAAO,WAAW,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACtE,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAA4B,CAAC;QACrF,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAC/D,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO,KAAK,IAAI;YAC9B,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;YAChF,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;YAChF,OAAO,EAAE,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;YACpE,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SAC/D,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './utils/index.js';
|
|
|
7
7
|
export { SDK } from './core/sdk.js';
|
|
8
8
|
export type { SDKConfig } from './core/sdk.js';
|
|
9
9
|
export { Agent } from './core/agent.js';
|
|
10
|
+
export { A2AClientFromSummary } from './core/a2a-summary-client.js';
|
|
10
11
|
export { ViemChainClient } from './core/viem-chain-client.js';
|
|
11
12
|
export type { ChainClient, TransactionOptions } from './core/chain-client.js';
|
|
12
13
|
export { IPFSClient } from './core/ipfs-client.js';
|
|
@@ -19,4 +20,6 @@ export { AgentIndexer } from './core/indexer.js';
|
|
|
19
20
|
export { TransactionHandle } from './core/transaction-handle.js';
|
|
20
21
|
export type { TransactionMined, TransactionWaitOptions } from './core/transaction-handle.js';
|
|
21
22
|
export * from './core/contracts.js';
|
|
23
|
+
export type { X402Accept, X402Payment, X402RequestOptions, X402RequiredResponse, X402RequestResult, ResourceInfo, X402SettlementResponse, Parse402FromHeaderResult, } from './core/x402-types.js';
|
|
24
|
+
export { isX402Required, parse402AcceptsFromHeader, parse402FromBody, parse402FromHeader, parse402SettlementFromHeader, parse402FromWWWAuthenticate, } from './core/x402-types.js';
|
|
22
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,mBA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EACZ,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from './utils/index.js';
|
|
|
9
9
|
// Export core classes
|
|
10
10
|
export { SDK } from './core/sdk.js';
|
|
11
11
|
export { Agent } from './core/agent.js';
|
|
12
|
+
export { A2AClientFromSummary } from './core/a2a-summary-client.js';
|
|
12
13
|
export { ViemChainClient } from './core/viem-chain-client.js';
|
|
13
14
|
export { IPFSClient } from './core/ipfs-client.js';
|
|
14
15
|
export { SubgraphClient } from './core/subgraph-client.js';
|
|
@@ -18,4 +19,5 @@ export { AgentIndexer } from './core/indexer.js';
|
|
|
18
19
|
export { TransactionHandle } from './core/transaction-handle.js';
|
|
19
20
|
// Export contract definitions
|
|
20
21
|
export * from './core/contracts.js';
|
|
22
|
+
export { isX402Required, parse402AcceptsFromHeader, parse402FromBody, parse402FromHeader, parse402SettlementFromHeader, parse402FromWWWAuthenticate, } from './core/x402-types.js';
|
|
21
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gBAAgB;AAChB,cAAc,mBAAmB,CAAC;AAElC,mBAAmB;AACnB,cAAc,kBAAkB,CAAC;AAEjC,sBAAsB;AACtB,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAA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|
|
4
|
+
/** Credential as object; string is normalized to { apiKey: string }. */
|
|
5
|
+
export interface CredentialObject {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
bearer?: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
/** Options for messageA2A (blocking, contextId, taskId, credential, payment per §2.1, §4.2). */
|
|
11
|
+
export interface MessageA2AOptions {
|
|
12
|
+
blocking?: boolean;
|
|
13
|
+
contextId?: string;
|
|
14
|
+
taskId?: string;
|
|
15
|
+
/** When the agent's endpoint requires auth: string (→ apiKey) or object (e.g. { apiKey } or { bearer }). */
|
|
16
|
+
credential?: string | CredentialObject;
|
|
17
|
+
/** Optional payment payload (e.g. base64 PAYMENT-SIGNATURE) to send with the first request; if server accepts, 2xx and no 402. */
|
|
18
|
+
payment?: string;
|
|
19
|
+
/** SendMessageConfiguration: accepted output modes (e.g. stream, push). */
|
|
20
|
+
acceptedOutputModes?: string[];
|
|
21
|
+
/** SendMessageConfiguration: requested history length for the task. */
|
|
22
|
+
historyLength?: number;
|
|
23
|
+
/** SendMessageConfiguration: push notification config (v0.3 / v1). */
|
|
24
|
+
pushNotificationConfig?: Record<string, unknown>;
|
|
25
|
+
/** SendMessageConfiguration: return immediately without waiting (v1). */
|
|
26
|
+
returnImmediately?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** OpenAPI-style apiKey scheme: where to send the value and under what name. */
|
|
29
|
+
export interface SecuritySchemeApiKey {
|
|
30
|
+
type: 'apiKey';
|
|
31
|
+
in: 'header' | 'query' | 'cookie';
|
|
32
|
+
name: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
}
|
|
35
|
+
/** OpenAPI-style http (Bearer) scheme. */
|
|
36
|
+
export interface SecuritySchemeHttp {
|
|
37
|
+
type: 'http';
|
|
38
|
+
scheme: 'bearer' | 'basic';
|
|
39
|
+
bearerFormat?: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Supported A2A security scheme types (per spec §2.5). */
|
|
43
|
+
export type SecurityScheme = SecuritySchemeApiKey | SecuritySchemeHttp;
|
|
44
|
+
/** AgentCard auth shape: securitySchemes and which are required. */
|
|
45
|
+
export interface AgentCardAuth {
|
|
46
|
+
securitySchemes?: Record<string, SecurityScheme>;
|
|
47
|
+
security?: Array<Record<string, string[]>>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Part: smallest unit of content in a Message or Artifact.
|
|
51
|
+
* Per A2A Protocol: text, url, data, or raw.
|
|
52
|
+
*/
|
|
53
|
+
export interface Part {
|
|
54
|
+
text?: string;
|
|
55
|
+
url?: string;
|
|
56
|
+
data?: string;
|
|
57
|
+
raw?: string;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Direct message response from an A2A server (no task created).
|
|
62
|
+
* No `task` or `taskId`; discriminate from TaskResponse by 'task' in msg.
|
|
63
|
+
* Has x402Required?: false so you can use if (result.x402Required) to detect 402.
|
|
64
|
+
*/
|
|
65
|
+
export interface MessageResponse {
|
|
66
|
+
x402Required?: false;
|
|
67
|
+
content?: string;
|
|
68
|
+
parts?: Part[];
|
|
69
|
+
contextId?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Task state returned by task.query() or after cancel.
|
|
73
|
+
* Server-specific status values; common: open, working, completed, failed, canceled, rejected.
|
|
74
|
+
*/
|
|
75
|
+
export interface TaskState {
|
|
76
|
+
state?: string;
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* When an A2A request returns HTTP 402. Caller may call x402Payment.pay() to pay and retry.
|
|
81
|
+
* Compatible with X402RequiredResponse from core/x402-types (used by a2a-client).
|
|
82
|
+
*/
|
|
83
|
+
export interface A2APaymentRequired<T = unknown> {
|
|
84
|
+
x402Required: true;
|
|
85
|
+
x402Payment: {
|
|
86
|
+
pay(accept?: unknown): Promise<T>;
|
|
87
|
+
/** When present: pays using first accept with sufficient token balance. */
|
|
88
|
+
payFirst?(): Promise<T>;
|
|
89
|
+
accepts: unknown[];
|
|
90
|
+
price?: string;
|
|
91
|
+
token?: string;
|
|
92
|
+
network?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** Result of task.query(): state or 402. */
|
|
96
|
+
export type TaskQueryResult = {
|
|
97
|
+
taskId: string;
|
|
98
|
+
contextId: string;
|
|
99
|
+
status?: TaskState;
|
|
100
|
+
artifacts?: unknown[];
|
|
101
|
+
messages?: unknown[];
|
|
102
|
+
};
|
|
103
|
+
/** Result of task.cancel(): state or 402. */
|
|
104
|
+
export type TaskCancelResult = {
|
|
105
|
+
taskId: string;
|
|
106
|
+
contextId: string;
|
|
107
|
+
status?: TaskState;
|
|
108
|
+
};
|
|
109
|
+
/** Summary of a task returned by listTasks. */
|
|
110
|
+
export interface TaskSummary {
|
|
111
|
+
x402Required?: false;
|
|
112
|
+
taskId: string;
|
|
113
|
+
contextId: string;
|
|
114
|
+
status?: TaskState;
|
|
115
|
+
/** Optional message history when historyLength > 0. */
|
|
116
|
+
messages?: unknown[];
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
}
|
|
119
|
+
/** Options for listTasks (filter, historyLength, credential, payment per §2.3, §4.2). */
|
|
120
|
+
export interface ListTasksOptions {
|
|
121
|
+
filter?: {
|
|
122
|
+
contextId?: string;
|
|
123
|
+
status?: string;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
};
|
|
126
|
+
historyLength?: number;
|
|
127
|
+
credential?: string | CredentialObject;
|
|
128
|
+
/** Optional payment payload to send with the first request; if server accepts, 2xx and no 402. */
|
|
129
|
+
payment?: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Task handle: read-only taskId, contextId, and methods query, message, cancel.
|
|
133
|
+
* Returned by response.task and by agent.loadTask(taskId).
|
|
134
|
+
* Methods may return 402 (A2APaymentRequired); use pay() to retry.
|
|
135
|
+
*/
|
|
136
|
+
export interface AgentTask {
|
|
137
|
+
readonly taskId: string;
|
|
138
|
+
readonly contextId: string;
|
|
139
|
+
query(options?: {
|
|
140
|
+
historyLength?: number;
|
|
141
|
+
}): Promise<TaskQueryResult | A2APaymentRequired<TaskQueryResult>>;
|
|
142
|
+
message(content: string | {
|
|
143
|
+
parts: Part[];
|
|
144
|
+
}): Promise<MessageResponse | TaskResponse | A2APaymentRequired<MessageResponse | TaskResponse>>;
|
|
145
|
+
cancel(): Promise<TaskCancelResult | A2APaymentRequired<TaskCancelResult>>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Response when the server created a task.
|
|
149
|
+
* Discriminate from MessageResponse by 'task' in response.
|
|
150
|
+
* Has x402Required?: false so you can use if (result.x402Required) to detect 402.
|
|
151
|
+
*/
|
|
152
|
+
export interface TaskResponse {
|
|
153
|
+
x402Required?: false;
|
|
154
|
+
taskId: string;
|
|
155
|
+
contextId: string;
|
|
156
|
+
task: AgentTask;
|
|
157
|
+
/** Optional task snapshot from send response */
|
|
158
|
+
status?: TaskState;
|
|
159
|
+
}
|
|
160
|
+
/** Options for loadTask (credential, payment). */
|
|
161
|
+
export interface LoadTaskOptions {
|
|
162
|
+
credential?: string | CredentialObject;
|
|
163
|
+
payment?: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Interface for A2A-capable clients. Implemented by Agent and A2AClientFromSummary
|
|
167
|
+
* so that loaded agents and agent summaries can be used interchangeably for A2A.
|
|
168
|
+
*/
|
|
169
|
+
export interface A2AClient {
|
|
170
|
+
messageA2A(content: string | {
|
|
171
|
+
parts: Part[];
|
|
172
|
+
}, options?: MessageA2AOptions): Promise<MessageResponse | TaskResponse | A2APaymentRequired<MessageResponse | TaskResponse>>;
|
|
173
|
+
listTasks(options?: ListTasksOptions): Promise<TaskSummary[] | A2APaymentRequired<TaskSummary[]>>;
|
|
174
|
+
loadTask(taskId: string, options?: LoadTaskOptions): Promise<AgentTask | A2APaymentRequired<AgentTask>>;
|
|
175
|
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 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a.js","sourceRoot":"","sources":["../../src/models/a2a.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
|
package/dist/models/index.js
CHANGED
package/dist/models/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent0-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "TypeScript SDK for agent portability, discovery and trust based on ERC-8004",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,6 +26,14 @@
|
|
|
26
26
|
"test": "jest",
|
|
27
27
|
"test:watch": "jest --watch",
|
|
28
28
|
"test:coverage": "jest --coverage",
|
|
29
|
+
"x402-server": "node tests/x402-server/server.mjs",
|
|
30
|
+
"test:x402-integration": "RUN_X402_INTEGRATION=1 jest --testPathPattern=x402-integration",
|
|
31
|
+
"test:x402-anvil": "RUN_X402_ANVIL=1 jest --testPathPattern=x402-anvil",
|
|
32
|
+
"a2a-server": "node tests/a2a-server/server.mjs",
|
|
33
|
+
"test:a2a-integration": "RUN_A2A_INTEGRATION=1 jest --testPathPattern=a2a-integration",
|
|
34
|
+
"test:a2a-anvil": "RUN_A2A_ANVIL=1 jest --testPathPattern=a2a-anvil",
|
|
35
|
+
"forge:build": "forge build",
|
|
36
|
+
"anvil:node": "anvil --port 8545",
|
|
29
37
|
"lint": "eslint src",
|
|
30
38
|
"format": "prettier --write src",
|
|
31
39
|
"clean": "rm -rf dist"
|