plugin-x402-endpoints 0.1.0 → 0.3.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/dist/index.cjs +414 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -150
- package/dist/index.js +414 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/index.d.cts +0 -150
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plugin-x402-endpoints",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "ElizaOS plugin exposing the x402-endpoints catalogue (28 paid data endpoints: official EU/global registries + crypto pre-trade data) as native agent actions, billed per call via x402 (USDC on Base mainnet).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -87,4 +87,4 @@
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { Provider, Action, Plugin } from '@elizaos/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Types describing the x402 catalogue consumed by the plugin.
|
|
5
|
-
*
|
|
6
|
-
* The catalogue (src/catalog.json) is the single source of truth: one entry per
|
|
7
|
-
* deployed x402 endpoint. The plugin turns each entry into an ElizaOS Action and
|
|
8
|
-
* lists them in a Provider, so an Eliza agent discovers and calls them natively.
|
|
9
|
-
*/
|
|
10
|
-
interface CatalogInputSchema {
|
|
11
|
-
type: "object";
|
|
12
|
-
properties: Record<string, {
|
|
13
|
-
type: string;
|
|
14
|
-
description?: string;
|
|
15
|
-
pattern?: string;
|
|
16
|
-
}>;
|
|
17
|
-
required?: string[];
|
|
18
|
-
}
|
|
19
|
-
interface CatalogEndpoint {
|
|
20
|
-
/** Short tool id, e.g. "gleif_lei". */
|
|
21
|
-
tool: string;
|
|
22
|
-
/** ElizaOS action name, e.g. "X402_GLEIF_LEI". */
|
|
23
|
-
action: string;
|
|
24
|
-
/** API path, e.g. "/gleif/lei". */
|
|
25
|
-
path: string;
|
|
26
|
-
/** HTTP method (all GET today). */
|
|
27
|
-
method: string;
|
|
28
|
-
/** Human price label, e.g. "$0.01". */
|
|
29
|
-
price: string;
|
|
30
|
-
/** Authority-rich semantic description (drives discovery). */
|
|
31
|
-
description: string;
|
|
32
|
-
/** Dense usage prompt for LLM agents. */
|
|
33
|
-
llm_usage_prompt?: string;
|
|
34
|
-
/** Semantic tags. */
|
|
35
|
-
tags?: string[];
|
|
36
|
-
/** JSON Schema for the query parameters. */
|
|
37
|
-
inputSchema: CatalogInputSchema;
|
|
38
|
-
/** A real example response (helps the agent before paying). */
|
|
39
|
-
outputExample?: unknown;
|
|
40
|
-
/** Payment metadata (mirrors the global values). */
|
|
41
|
-
payTo?: string;
|
|
42
|
-
network?: string;
|
|
43
|
-
asset?: string;
|
|
44
|
-
}
|
|
45
|
-
interface Catalog {
|
|
46
|
-
name: string;
|
|
47
|
-
baseUrl: string;
|
|
48
|
-
network: string;
|
|
49
|
-
asset: string;
|
|
50
|
-
payTo: string;
|
|
51
|
-
facilitator: string;
|
|
52
|
-
endpoints: CatalogEndpoint[];
|
|
53
|
-
}
|
|
54
|
-
/** Result of a paid (or discovery) call to an endpoint. */
|
|
55
|
-
type CallResult = {
|
|
56
|
-
kind: "data";
|
|
57
|
-
status: number;
|
|
58
|
-
data: unknown;
|
|
59
|
-
} | {
|
|
60
|
-
kind: "payment_required";
|
|
61
|
-
terms: PaymentTerms;
|
|
62
|
-
} | {
|
|
63
|
-
kind: "error";
|
|
64
|
-
status?: number;
|
|
65
|
-
message: string;
|
|
66
|
-
detail?: string;
|
|
67
|
-
};
|
|
68
|
-
interface PaymentTerms {
|
|
69
|
-
x402PaymentRequired: true;
|
|
70
|
-
tool: string;
|
|
71
|
-
resource: string;
|
|
72
|
-
price: string;
|
|
73
|
-
network: string;
|
|
74
|
-
asset?: string;
|
|
75
|
-
payTo?: string;
|
|
76
|
-
scheme: string;
|
|
77
|
-
maxTimeoutSeconds: number;
|
|
78
|
-
howToPay: string;
|
|
79
|
-
exampleOutput?: unknown;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Loads and exposes the bundled x402 catalogue.
|
|
84
|
-
*
|
|
85
|
-
* catalog.json is embedded at build time (resolveJsonModule), so the published
|
|
86
|
-
* plugin is self-contained and never diverges from the deployed catalogue it was
|
|
87
|
-
* built from. Runtime settings can still override baseUrl/network if needed.
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
declare const catalog: Catalog;
|
|
91
|
-
declare const endpoints: CatalogEndpoint[];
|
|
92
|
-
declare const ENDPOINT_COUNT: number;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Provider that injects the x402 catalogue into the agent's context, so the agent
|
|
96
|
-
* is aware of every paid tool it can call (drives tool selection / discovery).
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
declare const x402CatalogProvider: Provider;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Builds one ElizaOS Action per catalogue endpoint.
|
|
103
|
-
*
|
|
104
|
-
* Each action:
|
|
105
|
-
* - is named after the endpoint (e.g. X402_GLEIF_LEI),
|
|
106
|
-
* - carries a dense, discovery-friendly description (+ price + usage prompt),
|
|
107
|
-
* - extracts call parameters from explicit options, structured content, or the
|
|
108
|
-
* natural-language message (via the runtime model), validating required fields,
|
|
109
|
-
* - calls the endpoint (auto-pay or discovery) and reports the result via callback.
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
declare function buildActions(): Action[];
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* x402 HTTP client for the plugin.
|
|
116
|
-
*
|
|
117
|
-
* Two modes, mirroring the MCP server:
|
|
118
|
-
* - auto-pay : a funded Base buyer key is configured -> pays the 402 and returns live data.
|
|
119
|
-
* - discovery : no key (or auto-pay disabled) -> returns the exact payment terms.
|
|
120
|
-
*
|
|
121
|
-
* x402-fetch + viem are imported lazily so an agent that never auto-pays does not
|
|
122
|
-
* need a signer at runtime.
|
|
123
|
-
*/
|
|
124
|
-
|
|
125
|
-
interface ClientConfig {
|
|
126
|
-
baseUrl: string;
|
|
127
|
-
network: string;
|
|
128
|
-
buyerPrivateKey?: string;
|
|
129
|
-
autoPay: boolean;
|
|
130
|
-
}
|
|
131
|
-
type GetSetting = (key: string) => unknown;
|
|
132
|
-
/** Resolve runtime config from agent settings, falling back to the bundled catalogue. */
|
|
133
|
-
declare function resolveConfig(getSetting: GetSetting): ClientConfig;
|
|
134
|
-
/** Call one endpoint. Auto-pays when configured and funded; otherwise returns terms. */
|
|
135
|
-
declare function callEndpoint(ep: CatalogEndpoint, params: Record<string, unknown>, cfg: ClientConfig): Promise<CallResult>;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @x402-endpoints/plugin-elizaos
|
|
139
|
-
*
|
|
140
|
-
* ElizaOS plugin exposing the x402-endpoints catalogue (28 paid data endpoints:
|
|
141
|
-
* official EU/global registries + crypto pre-trade data) as native Eliza actions,
|
|
142
|
-
* billed per call via the x402 protocol (USDC on Base mainnet).
|
|
143
|
-
*
|
|
144
|
-
* Configure X402_BUYER_PRIVATE_KEY (a funded Base wallet) to auto-pay and receive
|
|
145
|
-
* live data; otherwise actions return the exact payment terms (discovery).
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
declare const x402Plugin: Plugin;
|
|
149
|
-
|
|
150
|
-
export { type CallResult, type Catalog, type CatalogEndpoint, type CatalogInputSchema, ENDPOINT_COUNT, type PaymentTerms, buildActions, callEndpoint, catalog, x402Plugin as default, endpoints, resolveConfig, x402CatalogProvider, x402Plugin };
|