plugin-x402-endpoints 0.2.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 +191 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -150
- package/dist/index.js +191 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.cts +0 -150
package/dist/index.d.ts
CHANGED
|
@@ -1,150 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 };
|
|
1
|
+
// Type stubs for plugin-x402-endpoints (runtime is JS; loaded by the ElizaOS host).
|
|
2
|
+
declare const x402Plugin: any;
|
|
3
|
+
export default x402Plugin;
|
|
4
|
+
export { x402Plugin };
|
|
5
|
+
export declare const catalog: any;
|
|
6
|
+
export declare const endpoints: any[];
|
|
7
|
+
export declare const ENDPOINT_COUNT: number;
|
|
8
|
+
export declare const x402CatalogProvider: any;
|
|
9
|
+
export declare function buildActions(...args: any[]): any[];
|
|
10
|
+
export declare function callEndpoint(...args: any[]): any;
|
|
11
|
+
export declare function resolveConfig(...args: any[]): any;
|
package/dist/index.js
CHANGED
|
@@ -1935,6 +1935,190 @@ var catalog_default = {
|
|
|
1935
1935
|
}
|
|
1936
1936
|
}
|
|
1937
1937
|
}
|
|
1938
|
+
},
|
|
1939
|
+
{
|
|
1940
|
+
tool: "agent_due_diligence",
|
|
1941
|
+
action: "X402_AGENT_DUE_DILIGENCE",
|
|
1942
|
+
path: "/agent/due-diligence",
|
|
1943
|
+
method: "POST",
|
|
1944
|
+
price: "$0.50",
|
|
1945
|
+
description: "Vet any company, crypto project, counterparty or domain before engaging: one call composes a risk DOSSIER \u2014 synthesis + detected signals + sources + 0-100 risk score + GO/CAUTION/STOP verdict + recommendation + a signed, offline-verifiable receipt. Is this entity a scam, fraud, sanctioned, or safe to deal with? Replaces 3-4 manual web searches plus the synthesis an agent would have to do itself, composed from live public web signals. Counterparty / vendor / project due-diligence for agents. Price: $0.50 per call (x402 payment, USDC on Base mainnet).",
|
|
1946
|
+
llm_usage_prompt: "Composed risk dossier on any entity/project/counterparty/domain: summary + signals + sources + 0-100 score + GO/CAUTION/STOP verdict + signed receipt. One call replaces 3-4 lookups. Input: target.",
|
|
1947
|
+
tags: [
|
|
1948
|
+
"due-diligence",
|
|
1949
|
+
"kyb",
|
|
1950
|
+
"counterparty-risk",
|
|
1951
|
+
"risk-dossier",
|
|
1952
|
+
"agent-decision"
|
|
1953
|
+
],
|
|
1954
|
+
inputSchema: {
|
|
1955
|
+
type: "object",
|
|
1956
|
+
properties: {
|
|
1957
|
+
target: {
|
|
1958
|
+
type: "string",
|
|
1959
|
+
description: "Entity / project / counterparty / domain to vet, e.g. 'Acme DeFi Labs'"
|
|
1960
|
+
},
|
|
1961
|
+
target_type: {
|
|
1962
|
+
type: "string",
|
|
1963
|
+
description: "Optional: entity | project | counterparty | domain | wallet"
|
|
1964
|
+
},
|
|
1965
|
+
context: {
|
|
1966
|
+
type: "string",
|
|
1967
|
+
description: "Optional: why you're engaging / what you're about to do"
|
|
1968
|
+
}
|
|
1969
|
+
},
|
|
1970
|
+
required: [
|
|
1971
|
+
"target"
|
|
1972
|
+
]
|
|
1973
|
+
}
|
|
1974
|
+
},
|
|
1975
|
+
{
|
|
1976
|
+
tool: "agent_analysis_report",
|
|
1977
|
+
action: "X402_AGENT_ANALYSIS_REPORT",
|
|
1978
|
+
path: "/agent/analysis-report",
|
|
1979
|
+
method: "POST",
|
|
1980
|
+
price: "$0.25",
|
|
1981
|
+
description: "Structured analysis report on any URL, company, product or subject in one call: positioning + strengths + risks + opportunities + 0-100 actionable score + STRONG/MODERATE/WEAK rating + recommendation + provenance + a signed receipt. A fixed-schema research report an agent can consume without re-parsing, composed from live public web signals. Competitive / investment / partnership analysis for agents. Price: $0.25 per call (x402 payment, USDC on Base mainnet).",
|
|
1982
|
+
llm_usage_prompt: "Fixed-schema analysis report on a URL/company/subject: positioning + strengths + risks + opportunities + 0-100 score + STRONG/MODERATE/WEAK + signed receipt. Input: input (+ optional focus).",
|
|
1983
|
+
tags: [
|
|
1984
|
+
"analysis-report",
|
|
1985
|
+
"market-analysis",
|
|
1986
|
+
"competitive",
|
|
1987
|
+
"research",
|
|
1988
|
+
"agent-decision"
|
|
1989
|
+
],
|
|
1990
|
+
inputSchema: {
|
|
1991
|
+
type: "object",
|
|
1992
|
+
properties: {
|
|
1993
|
+
input: {
|
|
1994
|
+
type: "string",
|
|
1995
|
+
description: "URL, company, product or subject, e.g. 'stripe.com'"
|
|
1996
|
+
},
|
|
1997
|
+
focus: {
|
|
1998
|
+
type: "string",
|
|
1999
|
+
description: "Optional: investment | competitive | partnership | security | general"
|
|
2000
|
+
}
|
|
2001
|
+
},
|
|
2002
|
+
required: [
|
|
2003
|
+
"input"
|
|
2004
|
+
]
|
|
2005
|
+
}
|
|
2006
|
+
},
|
|
2007
|
+
{
|
|
2008
|
+
tool: "agent_clearance",
|
|
2009
|
+
action: "X402_AGENT_CLEARANCE",
|
|
2010
|
+
path: "/agent/clearance",
|
|
2011
|
+
method: "POST",
|
|
2012
|
+
price: "$0.25",
|
|
2013
|
+
description: "Safety preflight before an agent runs a DESTRUCTIVE, costly or IRREVERSIBLE action (delete, deploy, transfer funds, publish, overwrite): risk assessment + reversibility check + timing + CLEAR/LIMIT/REVIEW/BLOCK verdict + a cryptographically SIGNED ClearancePacket (decision, approved amount, policy version, evidence hash, expiry, rationale) the agent keeps as proof of authorization. Should I run this action, or stop and ask a human? Stops a mistake far costlier than the call price. Agent action guardrail / clearance / human-in-the-loop gate. Price: $0.25 per call (x402 payment, USDC on Base mainnet).",
|
|
2014
|
+
llm_usage_prompt: "Preflight clearance before a destructive/costly/irreversible agent action: risk + reversibility + timing + CLEAR/LIMIT/REVIEW/BLOCK + a signed Ed25519 ClearancePacket. Input: action (+ action_type, amount_usd).",
|
|
2015
|
+
tags: [
|
|
2016
|
+
"preflight",
|
|
2017
|
+
"action-clearance",
|
|
2018
|
+
"reversibility",
|
|
2019
|
+
"agent-safety",
|
|
2020
|
+
"guardrail"
|
|
2021
|
+
],
|
|
2022
|
+
inputSchema: {
|
|
2023
|
+
type: "object",
|
|
2024
|
+
properties: {
|
|
2025
|
+
action: {
|
|
2026
|
+
type: "string",
|
|
2027
|
+
description: "Action about to run, e.g. 'delete the production users table'"
|
|
2028
|
+
},
|
|
2029
|
+
action_type: {
|
|
2030
|
+
type: "string",
|
|
2031
|
+
description: "Optional: delete|deploy|send|spend|transfer|publish|email|overwrite|approve|rotate|shutdown|other"
|
|
2032
|
+
},
|
|
2033
|
+
amount_usd: {
|
|
2034
|
+
type: "number",
|
|
2035
|
+
description: "Monetary stake in USD if applicable, e.g. 250"
|
|
2036
|
+
},
|
|
2037
|
+
reversible: {
|
|
2038
|
+
type: "boolean",
|
|
2039
|
+
description: "Optional caller hint: is the action reversible?"
|
|
2040
|
+
},
|
|
2041
|
+
target: {
|
|
2042
|
+
type: "string",
|
|
2043
|
+
description: "Optional target (table, address, repo, recipient)"
|
|
2044
|
+
},
|
|
2045
|
+
context: {
|
|
2046
|
+
type: "string",
|
|
2047
|
+
description: "Optional extra context (environment, prior approval)"
|
|
2048
|
+
}
|
|
2049
|
+
},
|
|
2050
|
+
required: [
|
|
2051
|
+
"action"
|
|
2052
|
+
]
|
|
2053
|
+
}
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
tool: "agent_output_qa",
|
|
2057
|
+
action: "X402_AGENT_OUTPUT_QA",
|
|
2058
|
+
path: "/agent/output-qa",
|
|
2059
|
+
method: "POST",
|
|
2060
|
+
price: "$0.10",
|
|
2061
|
+
description: "Review and improve an agent's outbound text (email, social post, customer reply) before sending: a multi-criteria scorecard (clarity, spam-safety, tone, length, personalization, CTA, compliance \u2014 each 0-100) + poor/fair/good/excellent rating + top suggestions + a ready-to-send IMPROVED REWRITE. Will this message land or get flagged as spam? One call scores and rewrites. Output review / spam check / copy QA for agents. Price: $0.10 per call (x402 payment, USDC on Base mainnet).",
|
|
2062
|
+
llm_usage_prompt: "Score an agent's outbound text on 7 criteria (clarity, spam-safety, tone, length, personalization, CTA, compliance) + rating + suggestions + improved rewrite. Input: output (+ format, goal).",
|
|
2063
|
+
tags: [
|
|
2064
|
+
"output-qa",
|
|
2065
|
+
"email-review",
|
|
2066
|
+
"content-scoring",
|
|
2067
|
+
"rewrite",
|
|
2068
|
+
"agent-decision"
|
|
2069
|
+
],
|
|
2070
|
+
inputSchema: {
|
|
2071
|
+
type: "object",
|
|
2072
|
+
properties: {
|
|
2073
|
+
output: {
|
|
2074
|
+
type: "string",
|
|
2075
|
+
description: "The agent's outbound text to review (email, post, reply)"
|
|
2076
|
+
},
|
|
2077
|
+
format: {
|
|
2078
|
+
type: "string",
|
|
2079
|
+
description: "Optional: email | social_post | customer_reply | other"
|
|
2080
|
+
},
|
|
2081
|
+
goal: {
|
|
2082
|
+
type: "string",
|
|
2083
|
+
description: "Optional intended goal, e.g. 'book a demo'"
|
|
2084
|
+
}
|
|
2085
|
+
},
|
|
2086
|
+
required: [
|
|
2087
|
+
"output"
|
|
2088
|
+
]
|
|
2089
|
+
}
|
|
2090
|
+
},
|
|
2091
|
+
{
|
|
2092
|
+
tool: "agent_content_scan",
|
|
2093
|
+
action: "X402_AGENT_CONTENT_SCAN",
|
|
2094
|
+
path: "/agent/content-scan",
|
|
2095
|
+
method: "POST",
|
|
2096
|
+
price: "$0.10",
|
|
2097
|
+
description: "Scan any external content before an agent INGESTS it (SKILL.md, web page, user input, tool output) for prompt-injection, data exfiltration, dangerous code execution, hidden/invisible unicode and instruction overrides: 0-100 risk score + SAFE/WARN/BLOCK verdict + structured findings with matched evidence. Is it safe to feed this content to my agent? A fast, cheap, deterministic, high-volume pre-ingest firewall. Prompt-injection / skill-audit / untrusted-content security check for agents. Price: $0.10 per call (x402 payment, USDC on Base mainnet).",
|
|
2098
|
+
llm_usage_prompt: "Deterministic pre-ingest scan for prompt-injection, exfiltration, dangerous exec, hidden unicode and instruction overrides: 0-100 risk score + SAFE/WARN/BLOCK + structured findings. Input: content.",
|
|
2099
|
+
tags: [
|
|
2100
|
+
"content-scan",
|
|
2101
|
+
"prompt-injection",
|
|
2102
|
+
"exfiltration",
|
|
2103
|
+
"agent-security",
|
|
2104
|
+
"safe-ingest"
|
|
2105
|
+
],
|
|
2106
|
+
inputSchema: {
|
|
2107
|
+
type: "object",
|
|
2108
|
+
properties: {
|
|
2109
|
+
content: {
|
|
2110
|
+
type: "string",
|
|
2111
|
+
description: "Raw content to scan before ingestion (SKILL.md, web page, user input, tool output)"
|
|
2112
|
+
},
|
|
2113
|
+
source_type: {
|
|
2114
|
+
type: "string",
|
|
2115
|
+
description: "Optional: skill | webpage | user_input | tool_output | document"
|
|
2116
|
+
}
|
|
2117
|
+
},
|
|
2118
|
+
required: [
|
|
2119
|
+
"content"
|
|
2120
|
+
]
|
|
2121
|
+
}
|
|
1938
2122
|
}
|
|
1939
2123
|
]
|
|
1940
2124
|
};
|
|
@@ -2034,12 +2218,15 @@ async function readBody(resp) {
|
|
|
2034
2218
|
}
|
|
2035
2219
|
}
|
|
2036
2220
|
async function callEndpoint(ep, params, cfg) {
|
|
2037
|
-
const
|
|
2038
|
-
const
|
|
2221
|
+
const method = (ep.method || "GET").toUpperCase();
|
|
2222
|
+
const isPost = method === "POST";
|
|
2223
|
+
const url = isPost ? `${cfg.baseUrl}${ep.path}` : buildUrl(cfg.baseUrl, ep.path, params);
|
|
2224
|
+
const headers = isPost ? { accept: "application/json", "content-type": "application/json" } : { accept: "application/json" };
|
|
2225
|
+
const reqInit = isPost ? { method, headers, body: JSON.stringify(params || {}) } : { method, headers };
|
|
2039
2226
|
const paidFetch = await getPaidFetch(cfg).catch(() => null);
|
|
2040
2227
|
if (paidFetch) {
|
|
2041
2228
|
try {
|
|
2042
|
-
const resp2 = await paidFetch(url,
|
|
2229
|
+
const resp2 = await paidFetch(url, reqInit);
|
|
2043
2230
|
const body2 = await readBody(resp2);
|
|
2044
2231
|
if (resp2.status === 200) return { kind: "data", status: 200, data: body2 };
|
|
2045
2232
|
if (resp2.status === 402) {
|
|
@@ -2057,7 +2244,7 @@ async function callEndpoint(ep, params, cfg) {
|
|
|
2057
2244
|
}
|
|
2058
2245
|
let resp;
|
|
2059
2246
|
try {
|
|
2060
|
-
resp = await fetch(url,
|
|
2247
|
+
resp = await fetch(url, reqInit);
|
|
2061
2248
|
} catch (err) {
|
|
2062
2249
|
return { kind: "error", message: "request failed", detail: `${err?.name}: ${err?.message}` };
|
|
2063
2250
|
}
|