@insumermodel/plugin-eliza 2.0.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/LICENSE +21 -0
- package/README.md +253 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1377 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1377 @@
|
|
|
1
|
+
// src/utils/api.ts
|
|
2
|
+
var API_BASE = "https://api.insumermodel.com/v1";
|
|
3
|
+
async function apiCall(apiKey, method, path, body) {
|
|
4
|
+
const url = `${API_BASE}${path}`;
|
|
5
|
+
const res = await fetch(url, {
|
|
6
|
+
method,
|
|
7
|
+
headers: {
|
|
8
|
+
"Content-Type": "application/json",
|
|
9
|
+
"X-API-Key": apiKey
|
|
10
|
+
},
|
|
11
|
+
body: body ? JSON.stringify(body) : void 0
|
|
12
|
+
});
|
|
13
|
+
return res.json();
|
|
14
|
+
}
|
|
15
|
+
async function publicApiCall(method, path, body) {
|
|
16
|
+
const url = `${API_BASE}${path}`;
|
|
17
|
+
const res = await fetch(url, {
|
|
18
|
+
method,
|
|
19
|
+
headers: { "Content-Type": "application/json" },
|
|
20
|
+
body: body ? JSON.stringify(body) : void 0
|
|
21
|
+
});
|
|
22
|
+
return res.json();
|
|
23
|
+
}
|
|
24
|
+
function formatAttestResult(data) {
|
|
25
|
+
const attestation = data.attestation;
|
|
26
|
+
const id = attestation?.id;
|
|
27
|
+
const pass = attestation?.pass;
|
|
28
|
+
const results = attestation?.results || [];
|
|
29
|
+
const lines = [
|
|
30
|
+
`Attestation ${id}: ${pass ? "PASS" : "FAIL"}`,
|
|
31
|
+
""
|
|
32
|
+
];
|
|
33
|
+
for (const r of results) {
|
|
34
|
+
const icon = r.met ? "+" : "-";
|
|
35
|
+
const chain = r.chainId !== void 0 ? ` (chain ${r.chainId})` : "";
|
|
36
|
+
let extra = "";
|
|
37
|
+
if (r.ledgerIndex !== void 0) {
|
|
38
|
+
extra += ` | ledger ${r.ledgerIndex}`;
|
|
39
|
+
}
|
|
40
|
+
if (r.trustLineState?.frozen) {
|
|
41
|
+
extra += " | FROZEN trust line";
|
|
42
|
+
}
|
|
43
|
+
lines.push(` [${icon}] ${r.label || r.type}${chain}${extra}`);
|
|
44
|
+
}
|
|
45
|
+
const passCount = attestation?.passCount;
|
|
46
|
+
const failCount = attestation?.failCount;
|
|
47
|
+
lines.push("", `${passCount} passed, ${failCount} failed`);
|
|
48
|
+
if (attestation?.expiresAt) {
|
|
49
|
+
lines.push(`Expires: ${attestation.expiresAt}`);
|
|
50
|
+
}
|
|
51
|
+
if (data.jwt) {
|
|
52
|
+
lines.push("", `JWT: ${data.jwt}`);
|
|
53
|
+
}
|
|
54
|
+
return lines.join("\n");
|
|
55
|
+
}
|
|
56
|
+
function formatTrustResult(data) {
|
|
57
|
+
const trust = data.trust;
|
|
58
|
+
const id = trust?.id;
|
|
59
|
+
const dimensions = trust?.dimensions;
|
|
60
|
+
const summary = trust?.summary;
|
|
61
|
+
const lines = [`Trust Profile ${id}`, ""];
|
|
62
|
+
if (dimensions) {
|
|
63
|
+
for (const [name, dim] of Object.entries(dimensions)) {
|
|
64
|
+
lines.push(
|
|
65
|
+
` ${name}: ${dim.passCount}/${dim.total} passed`
|
|
66
|
+
);
|
|
67
|
+
for (const check of dim.checks) {
|
|
68
|
+
const icon = check.met ? "+" : "-";
|
|
69
|
+
lines.push(` [${icon}] ${check.label}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (summary) {
|
|
74
|
+
lines.push(
|
|
75
|
+
"",
|
|
76
|
+
`Overall: ${summary.totalPassed}/${summary.totalChecks} checks passed`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return lines.join("\n");
|
|
80
|
+
}
|
|
81
|
+
function formatBatchResult(data) {
|
|
82
|
+
const results = data.results || [];
|
|
83
|
+
const batchSummary = data.summary;
|
|
84
|
+
const lines = [`Batch Trust: ${results.length} profiles`, ""];
|
|
85
|
+
for (const result of results) {
|
|
86
|
+
if (result.error) {
|
|
87
|
+
const err = result.error;
|
|
88
|
+
lines.push(` ${err.wallet}: ERROR \u2014 ${err.message}`);
|
|
89
|
+
} else {
|
|
90
|
+
const trust = result.trust;
|
|
91
|
+
const summary = trust?.summary;
|
|
92
|
+
lines.push(
|
|
93
|
+
` ${trust?.wallet}: ${summary?.totalPassed ?? "?"}/${summary?.totalChecks ?? "?"} checks passed (${trust?.id})`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (batchSummary) {
|
|
98
|
+
lines.push("", `${batchSummary.succeeded}/${batchSummary.requested} succeeded`);
|
|
99
|
+
}
|
|
100
|
+
return lines.join("\n");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/utils/templates.ts
|
|
104
|
+
var verifyTemplate = `You are extracting on-chain verification parameters from the conversation.
|
|
105
|
+
|
|
106
|
+
Recent messages:
|
|
107
|
+
{{recentMessages}}
|
|
108
|
+
|
|
109
|
+
Extract the following as a JSON object:
|
|
110
|
+
- wallet: EVM address (0x...) if present
|
|
111
|
+
- solanaWallet: Solana address (base58) if present
|
|
112
|
+
- xrplWallet: XRPL address (r...) if present
|
|
113
|
+
- bitcoinWallet: Bitcoin address (1..., 3..., bc1q..., or bc1p...) if present
|
|
114
|
+
- format: "jwt" if the user asks for a JWT token, bearer token, Wallet Auth token, or JWT format. Omit otherwise.
|
|
115
|
+
- conditions: array of conditions to check, each with:
|
|
116
|
+
- type: "token_balance", "nft_ownership", "eas_attestation", or "farcaster_id"
|
|
117
|
+
- contractAddress: token/NFT contract address (use the reference table below)
|
|
118
|
+
- chainId: chain ID number or "solana" or "xrpl"
|
|
119
|
+
- threshold: minimum balance (for token_balance)
|
|
120
|
+
- decimals: token decimals (for token_balance)
|
|
121
|
+
- currency: XRPL trust line currency code (e.g. "RLUSD", "USDC"). Required for XRPL trust line tokens.
|
|
122
|
+
- taxon: XRPL NFT taxon number (optional, for nft_ownership on XRPL only)
|
|
123
|
+
- label: human-readable description
|
|
124
|
+
- template: compliance template name (for eas_attestation)
|
|
125
|
+
|
|
126
|
+
Chain ID reference (33 supported chains):
|
|
127
|
+
Ethereum = 1, BNB Chain = 56, Base = 8453, Avalanche = 43114,
|
|
128
|
+
Polygon = 137, Arbitrum = 42161, Optimism = 10, Chiliz = 88888,
|
|
129
|
+
Soneium = 1868, Plume = 98866, World Chain = 480,
|
|
130
|
+
Sonic = 146, Gnosis = 100, Mantle = 5000, Scroll = 534352,
|
|
131
|
+
Linea = 59144, zkSync Era = 324, Blast = 81457, Taiko = 167000,
|
|
132
|
+
Ronin = 2020, Celo = 42220, Moonbeam = 1284, Moonriver = 1285,
|
|
133
|
+
Viction = 88, opBNB = 204, Unichain = 130, Ink = 57073,
|
|
134
|
+
Sei = 1329, Berachain = 80094, ApeChain = 33139,
|
|
135
|
+
Solana = "solana", XRPL = "xrpl", Bitcoin = "bitcoin"
|
|
136
|
+
|
|
137
|
+
Well-known contracts (Ethereum mainnet unless noted):
|
|
138
|
+
USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 (6 decimals)
|
|
139
|
+
USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7 (6 decimals)
|
|
140
|
+
UNI = 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 (18 decimals)
|
|
141
|
+
AAVE = 0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9 (18 decimals)
|
|
142
|
+
LINK = 0x514910771AF9Ca656af840dff83E8264EcF986CA (18 decimals)
|
|
143
|
+
WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 (18 decimals)
|
|
144
|
+
BAYC = 0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D (NFT)
|
|
145
|
+
USDC on Base = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (6 decimals)
|
|
146
|
+
USDC on Polygon = 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 (6 decimals)
|
|
147
|
+
USDC on Arbitrum = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 (6 decimals)
|
|
148
|
+
USDC on Optimism = 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85 (6 decimals)
|
|
149
|
+
USDC on BNB Chain = 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d (18 decimals)
|
|
150
|
+
USDC on Avalanche = 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E (6 decimals)
|
|
151
|
+
USDC on Solana = EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v (6 decimals)
|
|
152
|
+
|
|
153
|
+
XRPL tokens (use chainId "xrpl"):
|
|
154
|
+
XRP native = contractAddress "native"
|
|
155
|
+
RLUSD = contractAddress "rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De", currency "RLUSD"
|
|
156
|
+
USDC on XRPL = contractAddress "rGm7WCVp9gb4jZHWTEtGUr4dd74z2XuWhE", currency "USDC"
|
|
157
|
+
|
|
158
|
+
Compliance templates (for eas_attestation, no contractAddress needed):
|
|
159
|
+
"coinbase_verified_account" \u2014 KYC on Base
|
|
160
|
+
"coinbase_verified_country" \u2014 country verification on Base
|
|
161
|
+
"coinbase_one" \u2014 Coinbase One membership on Base
|
|
162
|
+
"gitcoin_passport_score" \u2014 Gitcoin Passport score on Optimism
|
|
163
|
+
"gitcoin_passport_active" \u2014 active Gitcoin Passport on Optimism
|
|
164
|
+
|
|
165
|
+
If the user says "check if they hold UNI", create a token_balance condition with the UNI contract, chainId 1, threshold 1, decimals 18.
|
|
166
|
+
If the user says "verify KYC", use template "coinbase_verified_account".
|
|
167
|
+
If the user says "check RLUSD balance", use chainId "xrpl", contractAddress "rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De", currency "RLUSD".
|
|
168
|
+
|
|
169
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
170
|
+
var trustTemplate = `You are extracting wallet trust profile parameters from the conversation.
|
|
171
|
+
|
|
172
|
+
Recent messages:
|
|
173
|
+
{{recentMessages}}
|
|
174
|
+
|
|
175
|
+
Extract the following as a JSON object:
|
|
176
|
+
- wallet: EVM address (0x...) \u2014 required
|
|
177
|
+
- solanaWallet: Solana address (base58) if mentioned
|
|
178
|
+
- xrplWallet: XRPL address (r...) if mentioned
|
|
179
|
+
- bitcoinWallet: Bitcoin address (1..., 3..., bc1q..., or bc1p...) if mentioned
|
|
180
|
+
|
|
181
|
+
The trust profile automatically checks 17+ dimensions (stablecoins, governance tokens, NFTs, staking) for the EVM wallet. Adding solanaWallet, xrplWallet, or bitcoinWallet extends the profile with additional checks.
|
|
182
|
+
|
|
183
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
184
|
+
var batchTrustTemplate = `You are extracting multiple wallet addresses for batch trust profiling from the conversation.
|
|
185
|
+
|
|
186
|
+
Recent messages:
|
|
187
|
+
{{recentMessages}}
|
|
188
|
+
|
|
189
|
+
Extract the following as a JSON object:
|
|
190
|
+
- wallets: array of wallet objects, each with:
|
|
191
|
+
- wallet: EVM address (0x...) \u2014 required
|
|
192
|
+
- solanaWallet: Solana address (base58) if mentioned for this wallet
|
|
193
|
+
- xrplWallet: XRPL address (r...) if mentioned for this wallet
|
|
194
|
+
- bitcoinWallet: Bitcoin address (1..., 3..., bc1q..., or bc1p...) if mentioned for this wallet
|
|
195
|
+
|
|
196
|
+
Maximum 10 wallets. Each wallet gets an independent trust profile.
|
|
197
|
+
|
|
198
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
199
|
+
var buyKeyTemplate = `You are extracting API key purchase parameters from the conversation.
|
|
200
|
+
|
|
201
|
+
Recent messages:
|
|
202
|
+
{{recentMessages}}
|
|
203
|
+
|
|
204
|
+
Extract the following as a JSON object:
|
|
205
|
+
- txHash: the USDC/USDT/BTC transaction hash
|
|
206
|
+
- chainId: chain where crypto was sent (number, "solana", or "bitcoin")
|
|
207
|
+
- amount: amount sent (number, minimum 5 USD equivalent)
|
|
208
|
+
- appName: name for the API key
|
|
209
|
+
|
|
210
|
+
Chain IDs for payments:
|
|
211
|
+
Ethereum = 1, Base = 8453, Polygon = 137, Arbitrum = 42161,
|
|
212
|
+
Optimism = 10, BNB Chain = 56, Avalanche = 43114, Solana = "solana",
|
|
213
|
+
Bitcoin = "bitcoin"
|
|
214
|
+
|
|
215
|
+
Platform wallets:
|
|
216
|
+
EVM: 0xAd982CB19aCCa2923Df8F687C0614a7700255a23
|
|
217
|
+
Solana: 6a1mLjefhvSJX1sEX8PTnionbE9DqoYjU6F6bNkT4Ydr
|
|
218
|
+
Bitcoin: bc1qg7qnerdhlmdn899zemtez5tcx2a2snc0dt9dt0
|
|
219
|
+
|
|
220
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
221
|
+
var createMerchantTemplate = `You are extracting merchant creation parameters from the conversation.
|
|
222
|
+
|
|
223
|
+
Recent messages:
|
|
224
|
+
{{recentMessages}}
|
|
225
|
+
|
|
226
|
+
Extract the following as a JSON object:
|
|
227
|
+
- companyName: display name for the merchant (required)
|
|
228
|
+
- companyId: unique alphanumeric ID with dashes/underscores (required, e.g. "acme-coffee")
|
|
229
|
+
- location: city or region (optional)
|
|
230
|
+
|
|
231
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
232
|
+
var configureTokensTemplate = `You are extracting token tier configuration parameters from the conversation.
|
|
233
|
+
|
|
234
|
+
Recent messages:
|
|
235
|
+
{{recentMessages}}
|
|
236
|
+
|
|
237
|
+
Extract the following as a JSON object:
|
|
238
|
+
- merchantId: the merchant ID to configure tokens for (required)
|
|
239
|
+
- ownToken: the merchant's own token config (or null), with:
|
|
240
|
+
- symbol: token symbol (e.g. "USDC", "UNI")
|
|
241
|
+
- chainId: chain ID number
|
|
242
|
+
- contractAddress: token contract address
|
|
243
|
+
- decimals: token decimals (6 for USDC, 18 for most ERC-20)
|
|
244
|
+
- currency: XRPL trust line currency code (e.g. "RLUSD", "USDC") \u2014 only for XRPL tokens
|
|
245
|
+
- tiers: array of 1-4 tiers, each with:
|
|
246
|
+
- name: tier name (e.g. "Bronze", "Silver", "Gold")
|
|
247
|
+
- threshold: minimum token balance for this tier
|
|
248
|
+
- discount: discount percentage (1-50)
|
|
249
|
+
- partnerTokens: array of additional token configs (same structure as ownToken), default []
|
|
250
|
+
|
|
251
|
+
Onboarding chain IDs (26 EVM chains + Solana + XRPL supported for token config):
|
|
252
|
+
Ethereum = 1, BNB Chain = 56, Base = 8453, Avalanche = 43114,
|
|
253
|
+
Polygon = 137, Arbitrum = 42161, Optimism = 10, Chiliz = 88888,
|
|
254
|
+
Soneium = 1868, Plume = 98866, World Chain = 480,
|
|
255
|
+
Sonic = 146, Gnosis = 100, Mantle = 5000, Scroll = 534352,
|
|
256
|
+
Linea = 59144, zkSync Era = 324, Blast = 81457, Celo = 42220,
|
|
257
|
+
Moonbeam = 1284, opBNB = 204, Unichain = 130, Ink = 57073,
|
|
258
|
+
Sei = 1329, Berachain = 80094, ApeChain = 33139,
|
|
259
|
+
Solana = "solana", XRPL = "xrpl", Bitcoin = "bitcoin"
|
|
260
|
+
|
|
261
|
+
Well-known contracts:
|
|
262
|
+
USDC on Ethereum = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 (6 decimals)
|
|
263
|
+
USDC on Base = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (6 decimals)
|
|
264
|
+
UNI = 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 (18 decimals)
|
|
265
|
+
|
|
266
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
267
|
+
var addCreditsTemplate = `You are extracting merchant credit purchase parameters from the conversation.
|
|
268
|
+
|
|
269
|
+
Recent messages:
|
|
270
|
+
{{recentMessages}}
|
|
271
|
+
|
|
272
|
+
Extract the following as a JSON object:
|
|
273
|
+
- merchantId: the merchant ID to add credits to (required)
|
|
274
|
+
- txHash: the USDC transaction hash (required)
|
|
275
|
+
- chainId: chain where USDC was sent (number or "solana")
|
|
276
|
+
- amount: USDC amount sent (number, minimum 5)
|
|
277
|
+
- updateWallet: true only if the user explicitly wants to change their registered wallet (default false)
|
|
278
|
+
|
|
279
|
+
Chain IDs for payments:
|
|
280
|
+
Ethereum = 1, Base = 8453, Polygon = 137, Arbitrum = 42161,
|
|
281
|
+
Optimism = 10, BNB Chain = 56, Avalanche = 43114, Solana = "solana",
|
|
282
|
+
Bitcoin = "bitcoin"
|
|
283
|
+
|
|
284
|
+
Platform wallets:
|
|
285
|
+
EVM: 0xAd982CB19aCCa2923Df8F687C0614a7700255a23
|
|
286
|
+
Solana: 6a1mLjefhvSJX1sEX8PTnionbE9DqoYjU6F6bNkT4Ydr
|
|
287
|
+
Bitcoin: bc1qg7qnerdhlmdn899zemtez5tcx2a2snc0dt9dt0
|
|
288
|
+
|
|
289
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
290
|
+
var acpDiscountTemplate = `You are extracting ACP discount check parameters from the conversation.
|
|
291
|
+
|
|
292
|
+
Recent messages:
|
|
293
|
+
{{recentMessages}}
|
|
294
|
+
|
|
295
|
+
Extract the following as a JSON object:
|
|
296
|
+
- merchantId: the merchant ID (required)
|
|
297
|
+
- wallet: EVM address (0x...) if present
|
|
298
|
+
- solanaWallet: Solana address (base58) if present
|
|
299
|
+
- xrplWallet: XRPL address (r...) if present
|
|
300
|
+
- items: optional array of line items, each with:
|
|
301
|
+
- path: JSONPath reference (e.g. "$.line_items[0]")
|
|
302
|
+
- amount: item price in cents
|
|
303
|
+
|
|
304
|
+
At least one wallet address is required.
|
|
305
|
+
|
|
306
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
307
|
+
var ucpDiscountTemplate = `You are extracting UCP discount check parameters from the conversation.
|
|
308
|
+
|
|
309
|
+
Recent messages:
|
|
310
|
+
{{recentMessages}}
|
|
311
|
+
|
|
312
|
+
Extract the following as a JSON object:
|
|
313
|
+
- merchantId: the merchant ID (required)
|
|
314
|
+
- wallet: EVM address (0x...) if present
|
|
315
|
+
- solanaWallet: Solana address (base58) if present
|
|
316
|
+
- xrplWallet: XRPL address (r...) if present
|
|
317
|
+
- items: optional array of line items, each with:
|
|
318
|
+
- path: JSONPath reference (e.g. "$.line_items[0]")
|
|
319
|
+
- amount: item price in cents
|
|
320
|
+
|
|
321
|
+
At least one wallet address is required.
|
|
322
|
+
|
|
323
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
324
|
+
var confirmPaymentTemplate = `You are extracting payment confirmation parameters from the conversation.
|
|
325
|
+
|
|
326
|
+
Recent messages:
|
|
327
|
+
{{recentMessages}}
|
|
328
|
+
|
|
329
|
+
Extract the following as a JSON object:
|
|
330
|
+
- code: the discount code (INSR-XXXXX format, required)
|
|
331
|
+
- txHash: the USDC transaction hash (required)
|
|
332
|
+
- chainId: chain where USDC was sent (number or "solana")
|
|
333
|
+
- amount: USDC amount sent (number or string)
|
|
334
|
+
|
|
335
|
+
Chain IDs for USDC payments:
|
|
336
|
+
Ethereum = 1, Base = 8453, Polygon = 137, Arbitrum = 42161,
|
|
337
|
+
Optimism = 10, BNB Chain = 56, Avalanche = 43114, Solana = "solana"
|
|
338
|
+
|
|
339
|
+
Respond with ONLY the JSON object, no explanation.`;
|
|
340
|
+
|
|
341
|
+
// src/actions/verify.ts
|
|
342
|
+
var verifyWalletAction = {
|
|
343
|
+
name: "VERIFY_WALLET",
|
|
344
|
+
description: "Verify on-chain token balances, NFT ownership, EAS attestations, or Farcaster identity for a wallet across 33 blockchains. Returns ECDSA-signed privacy-preserving booleans \u2014 never exposes actual balances. Supports EVM, Solana, XRPL, and Bitcoin.",
|
|
345
|
+
similes: [
|
|
346
|
+
"CHECK_WALLET",
|
|
347
|
+
"VERIFY_TOKENS",
|
|
348
|
+
"CHECK_TOKEN_BALANCE",
|
|
349
|
+
"VERIFY_NFT",
|
|
350
|
+
"ATTEST_WALLET",
|
|
351
|
+
"ON_CHAIN_VERIFY",
|
|
352
|
+
"CHECK_HOLDINGS",
|
|
353
|
+
"WALLET_ATTESTATION"
|
|
354
|
+
],
|
|
355
|
+
examples: [
|
|
356
|
+
[
|
|
357
|
+
{
|
|
358
|
+
name: "user",
|
|
359
|
+
content: {
|
|
360
|
+
text: "Can you check if 0x1234567890abcdef1234567890abcdef12345678 holds at least 100 UNI?"
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "assistant",
|
|
365
|
+
content: {
|
|
366
|
+
text: "I'll verify the UNI holdings for that wallet now.",
|
|
367
|
+
actions: ["VERIFY_WALLET"]
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
[
|
|
372
|
+
{
|
|
373
|
+
name: "user",
|
|
374
|
+
content: {
|
|
375
|
+
text: "Verify if 6a1mLjefhvSJX1sEX8PTnionbE9DqoYjU6F6bNkT4Ydr has USDC on Solana"
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "assistant",
|
|
380
|
+
content: {
|
|
381
|
+
text: "Checking USDC balance on Solana for that wallet.",
|
|
382
|
+
actions: ["VERIFY_WALLET"]
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
],
|
|
386
|
+
[
|
|
387
|
+
{
|
|
388
|
+
name: "user",
|
|
389
|
+
content: {
|
|
390
|
+
text: "Does 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 have a Coinbase KYC attestation?"
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
name: "assistant",
|
|
395
|
+
content: {
|
|
396
|
+
text: "I'll check for a Coinbase verified account attestation on Base.",
|
|
397
|
+
actions: ["VERIFY_WALLET"]
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
],
|
|
401
|
+
[
|
|
402
|
+
{
|
|
403
|
+
name: "user",
|
|
404
|
+
content: {
|
|
405
|
+
text: "Check if ra8xqX4QhcogFfxpMxMByvFnXyxw9E8rzY holds at least 10 RLUSD on XRPL"
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
name: "assistant",
|
|
410
|
+
content: {
|
|
411
|
+
text: "I'll verify RLUSD holdings on XRP Ledger for that wallet.",
|
|
412
|
+
actions: ["VERIFY_WALLET"]
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
],
|
|
417
|
+
validate: async (runtime, _message) => {
|
|
418
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
419
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
420
|
+
},
|
|
421
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
422
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
423
|
+
if (!state) {
|
|
424
|
+
state = await runtime.composeState(message, []);
|
|
425
|
+
}
|
|
426
|
+
const prompt = verifyTemplate.replace(
|
|
427
|
+
"{{recentMessages}}",
|
|
428
|
+
state.text || message.content.text || ""
|
|
429
|
+
);
|
|
430
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
431
|
+
prompt,
|
|
432
|
+
stopSequences: []
|
|
433
|
+
});
|
|
434
|
+
let params;
|
|
435
|
+
try {
|
|
436
|
+
params = JSON.parse(extracted);
|
|
437
|
+
} catch {
|
|
438
|
+
if (callback) {
|
|
439
|
+
await callback({
|
|
440
|
+
text: "I couldn't extract the verification parameters from the conversation. Please specify a wallet address and what to check (e.g., token balance, NFT ownership, KYC attestation)."
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
return { success: false, text: "Failed to parse verification parameters" };
|
|
444
|
+
}
|
|
445
|
+
if (!params.wallet && !params.solanaWallet && !params.xrplWallet && !params.bitcoinWallet) {
|
|
446
|
+
if (callback) {
|
|
447
|
+
await callback({
|
|
448
|
+
text: "Please provide a wallet address to verify (EVM 0x..., Solana base58, XRPL r-address, or Bitcoin bc1.../1.../3...)."
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
return { success: false, text: "No wallet address provided" };
|
|
452
|
+
}
|
|
453
|
+
if (!params.conditions || params.conditions.length === 0) {
|
|
454
|
+
if (callback) {
|
|
455
|
+
await callback({
|
|
456
|
+
text: "Please specify what to verify (e.g., token balance, NFT ownership, KYC attestation)."
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
return { success: false, text: "No conditions provided" };
|
|
460
|
+
}
|
|
461
|
+
const result = await apiCall(apiKey, "POST", "/attest", params);
|
|
462
|
+
if (!result.ok) {
|
|
463
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
464
|
+
if (callback) {
|
|
465
|
+
await callback({ text: `Verification failed: ${errMsg}` });
|
|
466
|
+
}
|
|
467
|
+
return { success: false, text: errMsg };
|
|
468
|
+
}
|
|
469
|
+
const formatted = formatAttestResult(result.data);
|
|
470
|
+
if (callback) {
|
|
471
|
+
await callback({ text: formatted });
|
|
472
|
+
}
|
|
473
|
+
return { success: true, text: formatted, data: result.data };
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// src/actions/trust.ts
|
|
478
|
+
var checkTrustAction = {
|
|
479
|
+
name: "CHECK_TRUST",
|
|
480
|
+
description: "Generate an ECDSA-signed wallet trust profile with 17+ checks across stablecoins, governance tokens, NFTs, and staking positions. Returns per-dimension pass/fail counts \u2014 no scores, no opinions, just cryptographically verifiable evidence. Supports cross-chain profiles with optional Solana and XRPL wallets. Costs 3 credits.",
|
|
481
|
+
similes: [
|
|
482
|
+
"TRUST_PROFILE",
|
|
483
|
+
"WALLET_TRUST",
|
|
484
|
+
"WALLET_REPUTATION",
|
|
485
|
+
"AGENT_TRUST",
|
|
486
|
+
"WALLET_PROFILE",
|
|
487
|
+
"CHECK_WALLET_TRUST"
|
|
488
|
+
],
|
|
489
|
+
examples: [
|
|
490
|
+
[
|
|
491
|
+
{
|
|
492
|
+
name: "user",
|
|
493
|
+
content: {
|
|
494
|
+
text: "What's the trust profile for 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045?"
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
name: "assistant",
|
|
499
|
+
content: {
|
|
500
|
+
text: "I'll generate a trust profile for that wallet now.",
|
|
501
|
+
actions: ["CHECK_TRUST"]
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
],
|
|
505
|
+
[
|
|
506
|
+
{
|
|
507
|
+
name: "user",
|
|
508
|
+
content: {
|
|
509
|
+
text: "Check trust for 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B with Solana wallet 6a1mLjefhvSJX1sEX8PTnionbE9DqoYjU6F6bNkT4Ydr"
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
name: "assistant",
|
|
514
|
+
content: {
|
|
515
|
+
text: "Generating a cross-chain trust profile for those wallets.",
|
|
516
|
+
actions: ["CHECK_TRUST"]
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
],
|
|
521
|
+
validate: async (runtime, _message) => {
|
|
522
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
523
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
524
|
+
},
|
|
525
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
526
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
527
|
+
if (!state) {
|
|
528
|
+
state = await runtime.composeState(message, []);
|
|
529
|
+
}
|
|
530
|
+
const prompt = trustTemplate.replace(
|
|
531
|
+
"{{recentMessages}}",
|
|
532
|
+
state.text || message.content.text || ""
|
|
533
|
+
);
|
|
534
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
535
|
+
prompt,
|
|
536
|
+
stopSequences: []
|
|
537
|
+
});
|
|
538
|
+
let params;
|
|
539
|
+
try {
|
|
540
|
+
params = JSON.parse(extracted);
|
|
541
|
+
} catch {
|
|
542
|
+
if (callback) {
|
|
543
|
+
await callback({
|
|
544
|
+
text: "I couldn't extract the wallet address from the conversation. Please provide an EVM wallet address (0x...)."
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
return { success: false, text: "Failed to parse trust parameters" };
|
|
548
|
+
}
|
|
549
|
+
if (!params.wallet) {
|
|
550
|
+
if (callback) {
|
|
551
|
+
await callback({
|
|
552
|
+
text: "Please provide an EVM wallet address (0x...) to generate a trust profile."
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return { success: false, text: "No wallet address provided" };
|
|
556
|
+
}
|
|
557
|
+
const result = await apiCall(apiKey, "POST", "/trust", params);
|
|
558
|
+
if (!result.ok) {
|
|
559
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
560
|
+
if (callback) {
|
|
561
|
+
await callback({ text: `Trust profile failed: ${errMsg}` });
|
|
562
|
+
}
|
|
563
|
+
return { success: false, text: errMsg };
|
|
564
|
+
}
|
|
565
|
+
const formatted = formatTrustResult(result.data);
|
|
566
|
+
if (callback) {
|
|
567
|
+
await callback({ text: formatted });
|
|
568
|
+
}
|
|
569
|
+
return { success: true, text: formatted, data: result.data };
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
// src/actions/batch.ts
|
|
574
|
+
var checkTrustBatchAction = {
|
|
575
|
+
name: "CHECK_TRUST_BATCH",
|
|
576
|
+
description: "Generate trust profiles for up to 10 wallets in a single request. Shared block fetches make this 5-8x faster than sequential calls. Each wallet gets an independently ECDSA-signed profile. Supports partial success. Costs 3 credits per successful wallet.",
|
|
577
|
+
similes: [
|
|
578
|
+
"BATCH_TRUST",
|
|
579
|
+
"BULK_TRUST_CHECK",
|
|
580
|
+
"MULTI_WALLET_TRUST",
|
|
581
|
+
"CHECK_MULTIPLE_WALLETS"
|
|
582
|
+
],
|
|
583
|
+
examples: [
|
|
584
|
+
[
|
|
585
|
+
{
|
|
586
|
+
name: "user",
|
|
587
|
+
content: {
|
|
588
|
+
text: "Check trust profiles for these three wallets: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045, 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, and 0x1234567890abcdef1234567890abcdef12345678"
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
name: "assistant",
|
|
593
|
+
content: {
|
|
594
|
+
text: "I'll generate trust profiles for all three wallets in a single batch.",
|
|
595
|
+
actions: ["CHECK_TRUST_BATCH"]
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
]
|
|
599
|
+
],
|
|
600
|
+
validate: async (runtime, _message) => {
|
|
601
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
602
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
603
|
+
},
|
|
604
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
605
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
606
|
+
if (!state) {
|
|
607
|
+
state = await runtime.composeState(message, []);
|
|
608
|
+
}
|
|
609
|
+
const prompt = batchTrustTemplate.replace(
|
|
610
|
+
"{{recentMessages}}",
|
|
611
|
+
state.text || message.content.text || ""
|
|
612
|
+
);
|
|
613
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
614
|
+
prompt,
|
|
615
|
+
stopSequences: []
|
|
616
|
+
});
|
|
617
|
+
let params;
|
|
618
|
+
try {
|
|
619
|
+
params = JSON.parse(extracted);
|
|
620
|
+
} catch {
|
|
621
|
+
if (callback) {
|
|
622
|
+
await callback({
|
|
623
|
+
text: "I couldn't extract the wallet addresses from the conversation. Please list the EVM wallet addresses (0x...) you want to check."
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
return { success: false, text: "Failed to parse batch parameters" };
|
|
627
|
+
}
|
|
628
|
+
if (!params.wallets || params.wallets.length === 0) {
|
|
629
|
+
if (callback) {
|
|
630
|
+
await callback({
|
|
631
|
+
text: "Please provide at least one EVM wallet address (0x...) for batch trust profiling."
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
return { success: false, text: "No wallets provided" };
|
|
635
|
+
}
|
|
636
|
+
if (params.wallets.length > 10) {
|
|
637
|
+
params.wallets = params.wallets.slice(0, 10);
|
|
638
|
+
}
|
|
639
|
+
const result = await apiCall(apiKey, "POST", "/trust/batch", params);
|
|
640
|
+
if (!result.ok) {
|
|
641
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
642
|
+
if (callback) {
|
|
643
|
+
await callback({ text: `Batch trust check failed: ${errMsg}` });
|
|
644
|
+
}
|
|
645
|
+
return { success: false, text: errMsg };
|
|
646
|
+
}
|
|
647
|
+
const formatted = formatBatchResult(result.data);
|
|
648
|
+
if (callback) {
|
|
649
|
+
await callback({ text: formatted });
|
|
650
|
+
}
|
|
651
|
+
return { success: true, text: formatted, data: result.data };
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
// src/actions/buy_key.ts
|
|
656
|
+
var buyKeyAction = {
|
|
657
|
+
name: "BUY_API_KEY",
|
|
658
|
+
description: "Buy a new InsumerAPI key with USDC, USDT, or BTC. No existing API key required. Send crypto to the platform wallet, then provide the transaction hash. The sender wallet becomes the key's identity. One key per wallet. USDC/USDT auto-detected on EVM/Solana. BTC on Bitcoin (converted to USD at market rate).",
|
|
659
|
+
similes: [
|
|
660
|
+
"PURCHASE_API_KEY",
|
|
661
|
+
"GET_API_KEY",
|
|
662
|
+
"BUY_KEY",
|
|
663
|
+
"CREATE_API_KEY",
|
|
664
|
+
"ONBOARD_AGENT"
|
|
665
|
+
],
|
|
666
|
+
examples: [
|
|
667
|
+
[
|
|
668
|
+
{
|
|
669
|
+
name: "user",
|
|
670
|
+
content: {
|
|
671
|
+
text: "I sent 10 USDC on Base, tx hash 0xabc123. Get me an API key for my agent called 'TrustBot'. (Also accepts USDT or BTC)"
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
name: "assistant",
|
|
676
|
+
content: {
|
|
677
|
+
text: "I'll verify your payment and create your API key now.",
|
|
678
|
+
actions: ["BUY_API_KEY"]
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
]
|
|
682
|
+
],
|
|
683
|
+
validate: async (_runtime, _message) => {
|
|
684
|
+
return true;
|
|
685
|
+
},
|
|
686
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
687
|
+
if (!state) {
|
|
688
|
+
state = await runtime.composeState(message, []);
|
|
689
|
+
}
|
|
690
|
+
const prompt = buyKeyTemplate.replace(
|
|
691
|
+
"{{recentMessages}}",
|
|
692
|
+
state.text || message.content.text || ""
|
|
693
|
+
);
|
|
694
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
695
|
+
prompt,
|
|
696
|
+
stopSequences: []
|
|
697
|
+
});
|
|
698
|
+
let params;
|
|
699
|
+
try {
|
|
700
|
+
params = JSON.parse(extracted);
|
|
701
|
+
} catch {
|
|
702
|
+
if (callback) {
|
|
703
|
+
await callback({
|
|
704
|
+
text: "I couldn't extract the purchase parameters. Please provide: transaction hash, chain (e.g. Base, Ethereum, Solana, Bitcoin), amount (for stablecoins), and a name for your key."
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
return { success: false, text: "Failed to parse purchase parameters" };
|
|
708
|
+
}
|
|
709
|
+
if (!params.txHash) {
|
|
710
|
+
if (callback) {
|
|
711
|
+
await callback({ text: "Please provide the transaction hash." });
|
|
712
|
+
}
|
|
713
|
+
return { success: false, text: "No transaction hash provided" };
|
|
714
|
+
}
|
|
715
|
+
if (!params.appName) {
|
|
716
|
+
if (callback) {
|
|
717
|
+
await callback({ text: "Please provide a name for your API key." });
|
|
718
|
+
}
|
|
719
|
+
return { success: false, text: "No app name provided" };
|
|
720
|
+
}
|
|
721
|
+
const result = await publicApiCall("POST", "/keys/buy", params);
|
|
722
|
+
if (!result.ok) {
|
|
723
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
724
|
+
if (callback) {
|
|
725
|
+
await callback({ text: `Key purchase failed: ${errMsg}` });
|
|
726
|
+
}
|
|
727
|
+
return { success: false, text: errMsg };
|
|
728
|
+
}
|
|
729
|
+
const data = result.data;
|
|
730
|
+
const text = [
|
|
731
|
+
`API key created successfully!`,
|
|
732
|
+
``,
|
|
733
|
+
`Key: ${data.key}`,
|
|
734
|
+
`Name: ${data.name}`,
|
|
735
|
+
`Credits: ${data.creditsAdded}`,
|
|
736
|
+
`Wallet: ${data.registeredWallet}`,
|
|
737
|
+
``,
|
|
738
|
+
`Store this key securely \u2014 it is only shown once.`,
|
|
739
|
+
`Use it as your INSUMER_API_KEY to access all verification endpoints.`
|
|
740
|
+
].join("\n");
|
|
741
|
+
if (callback) {
|
|
742
|
+
await callback({ text });
|
|
743
|
+
}
|
|
744
|
+
return { success: true, text, data };
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
// src/actions/create_merchant.ts
|
|
749
|
+
var createMerchantAction = {
|
|
750
|
+
name: "CREATE_MERCHANT",
|
|
751
|
+
description: "Create a new merchant on InsumerAPI. The agent's API key becomes the merchant owner. Receives 100 free verification credits. Max 10 merchants per API key.",
|
|
752
|
+
similes: [
|
|
753
|
+
"NEW_MERCHANT",
|
|
754
|
+
"SETUP_MERCHANT",
|
|
755
|
+
"REGISTER_MERCHANT",
|
|
756
|
+
"ONBOARD_MERCHANT",
|
|
757
|
+
"CREATE_STORE"
|
|
758
|
+
],
|
|
759
|
+
examples: [
|
|
760
|
+
[
|
|
761
|
+
{
|
|
762
|
+
name: "user",
|
|
763
|
+
content: {
|
|
764
|
+
text: "Create a merchant called 'Acme Coffee' with ID acme-coffee, located in New York."
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
name: "assistant",
|
|
769
|
+
content: {
|
|
770
|
+
text: "I'll create the Acme Coffee merchant now.",
|
|
771
|
+
actions: ["CREATE_MERCHANT"]
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
]
|
|
775
|
+
],
|
|
776
|
+
validate: async (runtime, _message) => {
|
|
777
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
778
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
779
|
+
},
|
|
780
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
781
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
782
|
+
if (!state) {
|
|
783
|
+
state = await runtime.composeState(message, []);
|
|
784
|
+
}
|
|
785
|
+
const prompt = createMerchantTemplate.replace(
|
|
786
|
+
"{{recentMessages}}",
|
|
787
|
+
state.text || message.content.text || ""
|
|
788
|
+
);
|
|
789
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
790
|
+
prompt,
|
|
791
|
+
stopSequences: []
|
|
792
|
+
});
|
|
793
|
+
let params;
|
|
794
|
+
try {
|
|
795
|
+
params = JSON.parse(extracted);
|
|
796
|
+
} catch {
|
|
797
|
+
if (callback) {
|
|
798
|
+
await callback({
|
|
799
|
+
text: "I couldn't extract the merchant details. Please provide a company name and a unique ID (alphanumeric, dashes, underscores)."
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
return { success: false, text: "Failed to parse merchant parameters" };
|
|
803
|
+
}
|
|
804
|
+
if (!params.companyName || !params.companyId) {
|
|
805
|
+
if (callback) {
|
|
806
|
+
await callback({
|
|
807
|
+
text: "Please provide both a company name and a unique company ID (e.g. 'acme-coffee')."
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
return { success: false, text: "Missing required merchant fields" };
|
|
811
|
+
}
|
|
812
|
+
const result = await apiCall(apiKey, "POST", "/merchants", params);
|
|
813
|
+
if (!result.ok) {
|
|
814
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
815
|
+
if (callback) {
|
|
816
|
+
await callback({ text: `Merchant creation failed: ${errMsg}` });
|
|
817
|
+
}
|
|
818
|
+
return { success: false, text: errMsg };
|
|
819
|
+
}
|
|
820
|
+
const data = result.data;
|
|
821
|
+
const text = [
|
|
822
|
+
`Merchant created successfully!`,
|
|
823
|
+
``,
|
|
824
|
+
`ID: ${data.id}`,
|
|
825
|
+
`Name: ${data.companyName}`,
|
|
826
|
+
`Credits: ${data.credits} (free starter credits)`,
|
|
827
|
+
``,
|
|
828
|
+
`Next steps: configure token tiers with CONFIGURE_TOKENS, then add credits with ADD_CREDITS.`
|
|
829
|
+
].join("\n");
|
|
830
|
+
if (callback) {
|
|
831
|
+
await callback({ text });
|
|
832
|
+
}
|
|
833
|
+
return { success: true, text, data };
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
// src/actions/configure_tokens.ts
|
|
838
|
+
var configureTokensAction = {
|
|
839
|
+
name: "CONFIGURE_TOKENS",
|
|
840
|
+
description: "Configure which tokens gate access to merchant discounts and set tier thresholds. Supports own token + up to 7 partner tokens with 1-4 discount tiers each. All 26 EVM chains + Solana + XRPL supported.",
|
|
841
|
+
similes: [
|
|
842
|
+
"SET_TOKEN_TIERS",
|
|
843
|
+
"CONFIGURE_TOKEN_GATING",
|
|
844
|
+
"SETUP_TOKENS",
|
|
845
|
+
"TOKEN_TIERS",
|
|
846
|
+
"SET_DISCOUNTS"
|
|
847
|
+
],
|
|
848
|
+
examples: [
|
|
849
|
+
[
|
|
850
|
+
{
|
|
851
|
+
name: "user",
|
|
852
|
+
content: {
|
|
853
|
+
text: "Set up USDC token gating for merchant acme-coffee: Bronze at 100 USDC (5% off), Silver at 1000 (10%), Gold at 10000 (15%) on Ethereum."
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
name: "assistant",
|
|
858
|
+
content: {
|
|
859
|
+
text: "I'll configure the USDC token tiers for acme-coffee now.",
|
|
860
|
+
actions: ["CONFIGURE_TOKENS"]
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
]
|
|
864
|
+
],
|
|
865
|
+
validate: async (runtime, _message) => {
|
|
866
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
867
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
868
|
+
},
|
|
869
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
870
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
871
|
+
if (!state) {
|
|
872
|
+
state = await runtime.composeState(message, []);
|
|
873
|
+
}
|
|
874
|
+
const prompt = configureTokensTemplate.replace(
|
|
875
|
+
"{{recentMessages}}",
|
|
876
|
+
state.text || message.content.text || ""
|
|
877
|
+
);
|
|
878
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
879
|
+
prompt,
|
|
880
|
+
stopSequences: []
|
|
881
|
+
});
|
|
882
|
+
let params;
|
|
883
|
+
try {
|
|
884
|
+
params = JSON.parse(extracted);
|
|
885
|
+
} catch {
|
|
886
|
+
if (callback) {
|
|
887
|
+
await callback({
|
|
888
|
+
text: "I couldn't extract the token configuration. Please specify a merchant ID, token symbol, chain, contract address, and discount tiers."
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
return { success: false, text: "Failed to parse token configuration" };
|
|
892
|
+
}
|
|
893
|
+
if (!params.merchantId) {
|
|
894
|
+
if (callback) {
|
|
895
|
+
await callback({ text: "Please provide the merchant ID to configure tokens for." });
|
|
896
|
+
}
|
|
897
|
+
return { success: false, text: "No merchant ID provided" };
|
|
898
|
+
}
|
|
899
|
+
const { merchantId, ...body } = params;
|
|
900
|
+
const result = await apiCall(apiKey, "PUT", `/merchants/${merchantId}/tokens`, body);
|
|
901
|
+
if (!result.ok) {
|
|
902
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
903
|
+
if (callback) {
|
|
904
|
+
await callback({ text: `Token configuration failed: ${errMsg}` });
|
|
905
|
+
}
|
|
906
|
+
return { success: false, text: errMsg };
|
|
907
|
+
}
|
|
908
|
+
const data = result.data;
|
|
909
|
+
const text = [
|
|
910
|
+
`Token tiers configured for ${merchantId}!`,
|
|
911
|
+
``,
|
|
912
|
+
`Total tokens: ${data.totalTokens}/${data.maxTokens}`
|
|
913
|
+
].join("\n");
|
|
914
|
+
if (callback) {
|
|
915
|
+
await callback({ text });
|
|
916
|
+
}
|
|
917
|
+
return { success: true, text, data };
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
// src/actions/add_credits.ts
|
|
922
|
+
var addCreditsAction = {
|
|
923
|
+
name: "ADD_CREDITS",
|
|
924
|
+
description: "Buy merchant verification credits with USDC, USDT, or BTC. Send crypto to the platform wallet, then provide the tx hash. USDC/USDT auto-detected on EVM/Solana. BTC on Bitcoin (converted to USD at market rate). Credits are consumed by discount code generation (POST /v1/verify, ACP, UCP). Volume discounts apply.",
|
|
925
|
+
similes: [
|
|
926
|
+
"BUY_MERCHANT_CREDITS",
|
|
927
|
+
"TOP_UP_CREDITS",
|
|
928
|
+
"ADD_MERCHANT_CREDITS",
|
|
929
|
+
"PURCHASE_CREDITS"
|
|
930
|
+
],
|
|
931
|
+
examples: [
|
|
932
|
+
[
|
|
933
|
+
{
|
|
934
|
+
name: "user",
|
|
935
|
+
content: {
|
|
936
|
+
text: "I sent 20 USDC on Base (tx 0xabc123) to top up credits for merchant acme-coffee."
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
name: "assistant",
|
|
941
|
+
content: {
|
|
942
|
+
text: "I'll verify the payment and add credits to acme-coffee now.",
|
|
943
|
+
actions: ["ADD_CREDITS"]
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
]
|
|
947
|
+
],
|
|
948
|
+
validate: async (runtime, _message) => {
|
|
949
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
950
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
951
|
+
},
|
|
952
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
953
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
954
|
+
if (!state) {
|
|
955
|
+
state = await runtime.composeState(message, []);
|
|
956
|
+
}
|
|
957
|
+
const prompt = addCreditsTemplate.replace(
|
|
958
|
+
"{{recentMessages}}",
|
|
959
|
+
state.text || message.content.text || ""
|
|
960
|
+
);
|
|
961
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
962
|
+
prompt,
|
|
963
|
+
stopSequences: []
|
|
964
|
+
});
|
|
965
|
+
let params;
|
|
966
|
+
try {
|
|
967
|
+
params = JSON.parse(extracted);
|
|
968
|
+
} catch {
|
|
969
|
+
if (callback) {
|
|
970
|
+
await callback({
|
|
971
|
+
text: "I couldn't extract the credit purchase details. Please provide: merchant ID, transaction hash, chain, and amount (for stablecoins)."
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
return { success: false, text: "Failed to parse credit purchase parameters" };
|
|
975
|
+
}
|
|
976
|
+
if (!params.merchantId || !params.txHash) {
|
|
977
|
+
if (callback) {
|
|
978
|
+
await callback({ text: "Please provide the merchant ID and transaction hash." });
|
|
979
|
+
}
|
|
980
|
+
return { success: false, text: "Missing merchant ID or tx hash" };
|
|
981
|
+
}
|
|
982
|
+
const { merchantId, ...body } = params;
|
|
983
|
+
const result = await apiCall(apiKey, "POST", `/merchants/${merchantId}/credits`, body);
|
|
984
|
+
if (!result.ok) {
|
|
985
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
986
|
+
if (callback) {
|
|
987
|
+
await callback({ text: `Credit purchase failed: ${errMsg}` });
|
|
988
|
+
}
|
|
989
|
+
return { success: false, text: errMsg };
|
|
990
|
+
}
|
|
991
|
+
const data = result.data;
|
|
992
|
+
const isBtc = data.btcPaid !== void 0;
|
|
993
|
+
const paymentLine = isBtc ? `BTC paid: ${data.btcPaid} (\u2248$${data.usdEquivalent} at $${data.btcPrice})` : `USDC paid: ${data.usdcPaid}`;
|
|
994
|
+
const text = [
|
|
995
|
+
`Credits added to ${merchantId}!`,
|
|
996
|
+
``,
|
|
997
|
+
`Credits added: ${data.creditsAdded}`,
|
|
998
|
+
`Total credits: ${data.totalCredits}`,
|
|
999
|
+
paymentLine,
|
|
1000
|
+
`Chain: ${data.chainName}`
|
|
1001
|
+
].join("\n");
|
|
1002
|
+
if (callback) {
|
|
1003
|
+
await callback({ text });
|
|
1004
|
+
}
|
|
1005
|
+
return { success: true, text, data };
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
// src/actions/acp_discount.ts
|
|
1010
|
+
var acpDiscountAction = {
|
|
1011
|
+
name: "ACP_DISCOUNT",
|
|
1012
|
+
description: "Check discount eligibility in OpenAI/Stripe Agentic Commerce Protocol (ACP) format. Returns coupon objects, allocations, and a signed verification code. Costs 1 merchant credit.",
|
|
1013
|
+
similes: [
|
|
1014
|
+
"ACP_CHECK",
|
|
1015
|
+
"OPENAI_DISCOUNT",
|
|
1016
|
+
"STRIPE_DISCOUNT",
|
|
1017
|
+
"AGENTIC_COMMERCE_DISCOUNT",
|
|
1018
|
+
"CHECK_ACP_DISCOUNT"
|
|
1019
|
+
],
|
|
1020
|
+
examples: [
|
|
1021
|
+
[
|
|
1022
|
+
{
|
|
1023
|
+
name: "user",
|
|
1024
|
+
content: {
|
|
1025
|
+
text: "Check ACP discount for wallet 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 at merchant acme-coffee."
|
|
1026
|
+
}
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
name: "assistant",
|
|
1030
|
+
content: {
|
|
1031
|
+
text: "I'll check the ACP discount eligibility now.",
|
|
1032
|
+
actions: ["ACP_DISCOUNT"]
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
]
|
|
1036
|
+
],
|
|
1037
|
+
validate: async (runtime, _message) => {
|
|
1038
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
1039
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
1040
|
+
},
|
|
1041
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
1042
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
1043
|
+
if (!state) {
|
|
1044
|
+
state = await runtime.composeState(message, []);
|
|
1045
|
+
}
|
|
1046
|
+
const prompt = acpDiscountTemplate.replace(
|
|
1047
|
+
"{{recentMessages}}",
|
|
1048
|
+
state.text || message.content.text || ""
|
|
1049
|
+
);
|
|
1050
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
1051
|
+
prompt,
|
|
1052
|
+
stopSequences: []
|
|
1053
|
+
});
|
|
1054
|
+
let params;
|
|
1055
|
+
try {
|
|
1056
|
+
params = JSON.parse(extracted);
|
|
1057
|
+
} catch {
|
|
1058
|
+
if (callback) {
|
|
1059
|
+
await callback({
|
|
1060
|
+
text: "I couldn't extract the discount parameters. Please provide a merchant ID and wallet address."
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
return { success: false, text: "Failed to parse ACP discount parameters" };
|
|
1064
|
+
}
|
|
1065
|
+
if (!params.merchantId) {
|
|
1066
|
+
if (callback) {
|
|
1067
|
+
await callback({ text: "Please provide the merchant ID." });
|
|
1068
|
+
}
|
|
1069
|
+
return { success: false, text: "No merchant ID provided" };
|
|
1070
|
+
}
|
|
1071
|
+
if (!params.wallet && !params.solanaWallet && !params.xrplWallet) {
|
|
1072
|
+
if (callback) {
|
|
1073
|
+
await callback({ text: "Please provide a wallet address to check discount eligibility." });
|
|
1074
|
+
}
|
|
1075
|
+
return { success: false, text: "No wallet address provided" };
|
|
1076
|
+
}
|
|
1077
|
+
const result = await apiCall(apiKey, "POST", "/acp/discount", params);
|
|
1078
|
+
if (!result.ok) {
|
|
1079
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
1080
|
+
if (callback) {
|
|
1081
|
+
await callback({ text: `ACP discount check failed: ${errMsg}` });
|
|
1082
|
+
}
|
|
1083
|
+
return { success: false, text: errMsg };
|
|
1084
|
+
}
|
|
1085
|
+
const data = result.data;
|
|
1086
|
+
const discounts = data.discounts;
|
|
1087
|
+
const codes = discounts?.codes || [];
|
|
1088
|
+
const applied = discounts?.applied || [];
|
|
1089
|
+
const verification = data.verification;
|
|
1090
|
+
const lines = [`ACP Discount Result`, ``];
|
|
1091
|
+
if (codes.length > 0) {
|
|
1092
|
+
lines.push(`Discount code: ${codes[0]}`);
|
|
1093
|
+
}
|
|
1094
|
+
if (applied.length > 0) {
|
|
1095
|
+
const coupon = applied[0].coupon;
|
|
1096
|
+
if (coupon?.percent_off) {
|
|
1097
|
+
lines.push(`Discount: ${coupon.percent_off}%`);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
if (verification) {
|
|
1101
|
+
lines.push(`Verification code: ${verification.code}`);
|
|
1102
|
+
}
|
|
1103
|
+
if (codes.length === 0 && !verification) {
|
|
1104
|
+
lines.push(`No discount eligible for this wallet at this merchant.`);
|
|
1105
|
+
}
|
|
1106
|
+
const text = lines.join("\n");
|
|
1107
|
+
if (callback) {
|
|
1108
|
+
await callback({ text });
|
|
1109
|
+
}
|
|
1110
|
+
return { success: true, text, data };
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
// src/actions/ucp_discount.ts
|
|
1115
|
+
var ucpDiscountAction = {
|
|
1116
|
+
name: "UCP_DISCOUNT",
|
|
1117
|
+
description: "Check discount eligibility in Google Universal Commerce Protocol (UCP) format. Returns title-based discounts, allocations, and a signed verification code. Costs 1 merchant credit.",
|
|
1118
|
+
similes: [
|
|
1119
|
+
"UCP_CHECK",
|
|
1120
|
+
"GOOGLE_DISCOUNT",
|
|
1121
|
+
"UNIVERSAL_COMMERCE_DISCOUNT",
|
|
1122
|
+
"CHECK_UCP_DISCOUNT"
|
|
1123
|
+
],
|
|
1124
|
+
examples: [
|
|
1125
|
+
[
|
|
1126
|
+
{
|
|
1127
|
+
name: "user",
|
|
1128
|
+
content: {
|
|
1129
|
+
text: "Check UCP discount for wallet 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 at merchant acme-coffee."
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
name: "assistant",
|
|
1134
|
+
content: {
|
|
1135
|
+
text: "I'll check the UCP discount eligibility now.",
|
|
1136
|
+
actions: ["UCP_DISCOUNT"]
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
]
|
|
1140
|
+
],
|
|
1141
|
+
validate: async (runtime, _message) => {
|
|
1142
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
1143
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
1144
|
+
},
|
|
1145
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
1146
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
1147
|
+
if (!state) {
|
|
1148
|
+
state = await runtime.composeState(message, []);
|
|
1149
|
+
}
|
|
1150
|
+
const prompt = ucpDiscountTemplate.replace(
|
|
1151
|
+
"{{recentMessages}}",
|
|
1152
|
+
state.text || message.content.text || ""
|
|
1153
|
+
);
|
|
1154
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
1155
|
+
prompt,
|
|
1156
|
+
stopSequences: []
|
|
1157
|
+
});
|
|
1158
|
+
let params;
|
|
1159
|
+
try {
|
|
1160
|
+
params = JSON.parse(extracted);
|
|
1161
|
+
} catch {
|
|
1162
|
+
if (callback) {
|
|
1163
|
+
await callback({
|
|
1164
|
+
text: "I couldn't extract the discount parameters. Please provide a merchant ID and wallet address."
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
return { success: false, text: "Failed to parse UCP discount parameters" };
|
|
1168
|
+
}
|
|
1169
|
+
if (!params.merchantId) {
|
|
1170
|
+
if (callback) {
|
|
1171
|
+
await callback({ text: "Please provide the merchant ID." });
|
|
1172
|
+
}
|
|
1173
|
+
return { success: false, text: "No merchant ID provided" };
|
|
1174
|
+
}
|
|
1175
|
+
if (!params.wallet && !params.solanaWallet && !params.xrplWallet) {
|
|
1176
|
+
if (callback) {
|
|
1177
|
+
await callback({ text: "Please provide a wallet address to check discount eligibility." });
|
|
1178
|
+
}
|
|
1179
|
+
return { success: false, text: "No wallet address provided" };
|
|
1180
|
+
}
|
|
1181
|
+
const result = await apiCall(apiKey, "POST", "/ucp/discount", params);
|
|
1182
|
+
if (!result.ok) {
|
|
1183
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
1184
|
+
if (callback) {
|
|
1185
|
+
await callback({ text: `UCP discount check failed: ${errMsg}` });
|
|
1186
|
+
}
|
|
1187
|
+
return { success: false, text: errMsg };
|
|
1188
|
+
}
|
|
1189
|
+
const data = result.data;
|
|
1190
|
+
const discounts = data.discounts;
|
|
1191
|
+
const codes = discounts?.codes || [];
|
|
1192
|
+
const applied = discounts?.applied || [];
|
|
1193
|
+
const verification = data.verification;
|
|
1194
|
+
const lines = [`UCP Discount Result`, ``];
|
|
1195
|
+
if (codes.length > 0) {
|
|
1196
|
+
lines.push(`Discount code: ${codes[0]}`);
|
|
1197
|
+
}
|
|
1198
|
+
if (applied.length > 0) {
|
|
1199
|
+
const discount = applied[0];
|
|
1200
|
+
if (discount.title) {
|
|
1201
|
+
lines.push(`Discount: ${discount.title}`);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
if (verification) {
|
|
1205
|
+
lines.push(`Verification code: ${verification.code}`);
|
|
1206
|
+
}
|
|
1207
|
+
if (codes.length === 0 && !verification) {
|
|
1208
|
+
lines.push(`No discount eligible for this wallet at this merchant.`);
|
|
1209
|
+
}
|
|
1210
|
+
const text = lines.join("\n");
|
|
1211
|
+
if (callback) {
|
|
1212
|
+
await callback({ text });
|
|
1213
|
+
}
|
|
1214
|
+
return { success: true, text, data };
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1218
|
+
// src/actions/confirm_payment.ts
|
|
1219
|
+
var confirmPaymentAction = {
|
|
1220
|
+
name: "CONFIRM_PAYMENT",
|
|
1221
|
+
description: "Confirm that a USDC payment was made on-chain for a discount code. Verifies the transaction receipt to ensure USDC arrived at the merchant address. Use after ACP_DISCOUNT or UCP_DISCOUNT.",
|
|
1222
|
+
similes: [
|
|
1223
|
+
"VERIFY_PAYMENT",
|
|
1224
|
+
"CONFIRM_USDC",
|
|
1225
|
+
"PAYMENT_CONFIRMATION",
|
|
1226
|
+
"CHECK_PAYMENT"
|
|
1227
|
+
],
|
|
1228
|
+
examples: [
|
|
1229
|
+
[
|
|
1230
|
+
{
|
|
1231
|
+
name: "user",
|
|
1232
|
+
content: {
|
|
1233
|
+
text: "Confirm payment for code INSR-A7K3M. I sent 25 USDC on Base, tx hash 0xdef456."
|
|
1234
|
+
}
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
name: "assistant",
|
|
1238
|
+
content: {
|
|
1239
|
+
text: "I'll verify the USDC payment for that discount code now.",
|
|
1240
|
+
actions: ["CONFIRM_PAYMENT"]
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
]
|
|
1244
|
+
],
|
|
1245
|
+
validate: async (runtime, _message) => {
|
|
1246
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
1247
|
+
return typeof apiKey === "string" && apiKey.startsWith("insr_live_");
|
|
1248
|
+
},
|
|
1249
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
1250
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
1251
|
+
if (!state) {
|
|
1252
|
+
state = await runtime.composeState(message, []);
|
|
1253
|
+
}
|
|
1254
|
+
const prompt = confirmPaymentTemplate.replace(
|
|
1255
|
+
"{{recentMessages}}",
|
|
1256
|
+
state.text || message.content.text || ""
|
|
1257
|
+
);
|
|
1258
|
+
const extracted = await runtime.useModel("TEXT_SMALL", {
|
|
1259
|
+
prompt,
|
|
1260
|
+
stopSequences: []
|
|
1261
|
+
});
|
|
1262
|
+
let params;
|
|
1263
|
+
try {
|
|
1264
|
+
params = JSON.parse(extracted);
|
|
1265
|
+
} catch {
|
|
1266
|
+
if (callback) {
|
|
1267
|
+
await callback({
|
|
1268
|
+
text: "I couldn't extract the payment details. Please provide: discount code (INSR-XXXXX), transaction hash, chain, and USDC amount."
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
return { success: false, text: "Failed to parse payment parameters" };
|
|
1272
|
+
}
|
|
1273
|
+
if (!params.code || !params.txHash) {
|
|
1274
|
+
if (callback) {
|
|
1275
|
+
await callback({ text: "Please provide the discount code (INSR-XXXXX) and transaction hash." });
|
|
1276
|
+
}
|
|
1277
|
+
return { success: false, text: "Missing code or tx hash" };
|
|
1278
|
+
}
|
|
1279
|
+
const result = await apiCall(apiKey, "POST", "/payment/confirm", params);
|
|
1280
|
+
if (!result.ok) {
|
|
1281
|
+
const errMsg = result.error?.message || "Unknown API error";
|
|
1282
|
+
if (callback) {
|
|
1283
|
+
await callback({ text: `Payment confirmation failed: ${errMsg}` });
|
|
1284
|
+
}
|
|
1285
|
+
return { success: false, text: errMsg };
|
|
1286
|
+
}
|
|
1287
|
+
const data = result.data;
|
|
1288
|
+
const confirmed = data.confirmed;
|
|
1289
|
+
const text = confirmed ? [
|
|
1290
|
+
`Payment confirmed!`,
|
|
1291
|
+
``,
|
|
1292
|
+
`Code: ${data.code}`,
|
|
1293
|
+
`Amount verified: ${data.amountVerified} USDC`,
|
|
1294
|
+
`Chain: ${data.chainName}`,
|
|
1295
|
+
`Confirmed at: ${data.confirmedAt}`
|
|
1296
|
+
].join("\n") : `Payment not confirmed. The transaction could not be verified.`;
|
|
1297
|
+
if (callback) {
|
|
1298
|
+
await callback({ text });
|
|
1299
|
+
}
|
|
1300
|
+
return { success: true, text, data };
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
// src/providers/credentials.ts
|
|
1305
|
+
var EVM_REGEX = /\b0x[a-fA-F0-9]{40}\b/g;
|
|
1306
|
+
var SOLANA_REGEX = /\b[1-9A-HJ-NP-Za-km-z]{32,44}\b/g;
|
|
1307
|
+
var XRPL_REGEX = /\br[1-9A-HJ-NP-Za-km-z]{24,34}\b/g;
|
|
1308
|
+
var BITCOIN_REGEX = /\b(1[a-km-zA-HJ-NP-Z1-9]{25,34}|3[a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-z0-9]{39,59}|bc1p[a-z0-9]{58})\b/g;
|
|
1309
|
+
function isSolanaAddress(candidate) {
|
|
1310
|
+
return candidate.length >= 32 && candidate.length <= 44;
|
|
1311
|
+
}
|
|
1312
|
+
var walletCredentialsProvider = {
|
|
1313
|
+
name: "WALLET_CREDENTIALS",
|
|
1314
|
+
description: "Detects wallet addresses in conversation and signals that InsumerAPI verification actions are available.",
|
|
1315
|
+
dynamic: true,
|
|
1316
|
+
get: async (runtime, message) => {
|
|
1317
|
+
const apiKey = runtime.getSetting("INSUMER_API_KEY");
|
|
1318
|
+
if (!apiKey || typeof apiKey !== "string" || !apiKey.startsWith("insr_live_")) {
|
|
1319
|
+
return { text: "" };
|
|
1320
|
+
}
|
|
1321
|
+
const text = message.content.text || "";
|
|
1322
|
+
const evmWallets = text.match(EVM_REGEX) || [];
|
|
1323
|
+
const solanaMatches = (text.match(SOLANA_REGEX) || []).filter(isSolanaAddress);
|
|
1324
|
+
const xrplWallets = text.match(XRPL_REGEX) || [];
|
|
1325
|
+
const bitcoinWallets = text.match(BITCOIN_REGEX) || [];
|
|
1326
|
+
const evmSet = new Set(evmWallets);
|
|
1327
|
+
const xrplSet = new Set(xrplWallets);
|
|
1328
|
+
const btcSet = new Set(bitcoinWallets);
|
|
1329
|
+
const solanaWallets = solanaMatches.filter(
|
|
1330
|
+
(s) => !evmSet.has(s) && !xrplSet.has(s) && !btcSet.has(s)
|
|
1331
|
+
);
|
|
1332
|
+
const detected = [];
|
|
1333
|
+
if (evmWallets.length > 0) {
|
|
1334
|
+
detected.push(`EVM: ${evmWallets.join(", ")}`);
|
|
1335
|
+
}
|
|
1336
|
+
if (solanaWallets.length > 0) {
|
|
1337
|
+
detected.push(`Solana: ${solanaWallets.join(", ")}`);
|
|
1338
|
+
}
|
|
1339
|
+
if (xrplWallets.length > 0) {
|
|
1340
|
+
detected.push(`XRPL: ${xrplWallets.join(", ")}`);
|
|
1341
|
+
}
|
|
1342
|
+
if (bitcoinWallets.length > 0) {
|
|
1343
|
+
detected.push(`Bitcoin: ${bitcoinWallets.join(", ")}`);
|
|
1344
|
+
}
|
|
1345
|
+
if (detected.length === 0) {
|
|
1346
|
+
return { text: "" };
|
|
1347
|
+
}
|
|
1348
|
+
return {
|
|
1349
|
+
text: `InsumerAPI is available for on-chain verification. Detected wallets: ${detected.join("; ")}. You can use VERIFY_WALLET to check token balances/NFTs/attestations, or CHECK_TRUST for a full trust profile.`
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
// src/index.ts
|
|
1355
|
+
var insumerPlugin = {
|
|
1356
|
+
name: "insumer",
|
|
1357
|
+
description: "Full autonomous agent lifecycle for token-gated commerce across 33 blockchains. 10 actions: buy API key, create merchant, configure token tiers, add credits, verify wallets, trust profiles, ACP/UCP commerce, confirm payments. ECDSA-signed results, never exposes balances.",
|
|
1358
|
+
actions: [
|
|
1359
|
+
verifyWalletAction,
|
|
1360
|
+
checkTrustAction,
|
|
1361
|
+
checkTrustBatchAction,
|
|
1362
|
+
buyKeyAction,
|
|
1363
|
+
createMerchantAction,
|
|
1364
|
+
configureTokensAction,
|
|
1365
|
+
addCreditsAction,
|
|
1366
|
+
acpDiscountAction,
|
|
1367
|
+
ucpDiscountAction,
|
|
1368
|
+
confirmPaymentAction
|
|
1369
|
+
],
|
|
1370
|
+
providers: [walletCredentialsProvider]
|
|
1371
|
+
};
|
|
1372
|
+
var index_default = insumerPlugin;
|
|
1373
|
+
export {
|
|
1374
|
+
index_default as default,
|
|
1375
|
+
insumerPlugin
|
|
1376
|
+
};
|
|
1377
|
+
//# sourceMappingURL=index.js.map
|