@elisym/mcp 0.8.1 → 0.8.3
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.js +51 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { LIMITS, DEFAULT_KIND_OFFSET, SolanaPaymentStrategy, makeCensor, DEFAULT_REDACT_PATHS, validateAgentName, RELAYS, toDTag, formatAssetAmount, USDC_SOLANA_DEVNET, estimateSolFeeLamports, formatFeeBreakdown, resolveAssetFromPaymentRequest as resolveAssetFromPaymentRequest$1, parseAssetAmount, ElisymIdentity, ElisymClient, NATIVE_SOL, getProtocolProgramId, getProtocolConfig, assetKey, assetByKey,
|
|
2
|
+
import { LIMITS, DEFAULT_KIND_OFFSET, SolanaPaymentStrategy, makeCensor, DEFAULT_REDACT_PATHS, validateAgentName, RELAYS, toDTag, formatAssetAmount, USDC_SOLANA_DEVNET, estimateSolFeeLamports, formatFeeBreakdown, resolveAssetFromPaymentRequest as resolveAssetFromPaymentRequest$1, parseAssetAmount, ElisymIdentity, ElisymClient, NATIVE_SOL, resolveKnownAsset, getProtocolProgramId, getProtocolConfig, assetKey, assetByKey, KNOWN_ASSETS } from '@elisym/sdk';
|
|
3
3
|
import { listAgents, createAgentDir, writeYaml, writeSecrets, loadAgent, globalConfigPath } from '@elisym/sdk/agent-store';
|
|
4
4
|
import { loadGlobalConfig, writeGlobalConfig } from '@elisym/sdk/node';
|
|
5
5
|
import { getBase58Encoder, getBase58Decoder, generateKeyPairSigner, address, createSolanaRpcSubscriptions, sendAndConfirmTransactionFactory, getSignatureFromTransaction, pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, signTransactionMessageWithSigners, createKeyPairSignerFromBytes, createSolanaRpc, isAddress } from '@solana/kit';
|
|
@@ -289,10 +289,24 @@ function formatSolNumeric(lamports) {
|
|
|
289
289
|
const frac = abs % LAMPORTS_PER_SOL;
|
|
290
290
|
return `${sign}${whole}.${frac.toString().padStart(9, "0")}`;
|
|
291
291
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
function assetFromCardPayment(payment2) {
|
|
293
|
+
if (!payment2) {
|
|
294
|
+
return NATIVE_SOL;
|
|
295
|
+
}
|
|
296
|
+
const known = resolveKnownAsset(payment2.chain, payment2.token ?? "sol", payment2.mint);
|
|
297
|
+
if (known) {
|
|
298
|
+
return known;
|
|
299
|
+
}
|
|
300
|
+
if (payment2.token && payment2.symbol && typeof payment2.decimals === "number") {
|
|
301
|
+
return {
|
|
302
|
+
chain: payment2.chain,
|
|
303
|
+
token: payment2.token,
|
|
304
|
+
mint: payment2.mint,
|
|
305
|
+
symbol: payment2.symbol,
|
|
306
|
+
decimals: payment2.decimals
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return NATIVE_SOL;
|
|
296
310
|
}
|
|
297
311
|
function parseSolToLamports(s) {
|
|
298
312
|
const trimmed = s.trim();
|
|
@@ -1290,10 +1304,17 @@ function makePaymentFeedbackHandler(opts) {
|
|
|
1290
1304
|
);
|
|
1291
1305
|
return;
|
|
1292
1306
|
}
|
|
1307
|
+
let asset;
|
|
1308
|
+
try {
|
|
1309
|
+
asset = resolveAssetFromPaymentRequest(parsedRequest);
|
|
1310
|
+
} catch (e) {
|
|
1311
|
+
opts.rejectPayment(e instanceof Error ? e : new Error(String(e)));
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1293
1314
|
if (opts.maxPriceLamports === void 0 && signedAmount !== void 0) {
|
|
1294
1315
|
opts.rejectPayment(
|
|
1295
1316
|
new Error(
|
|
1296
|
-
`Payment of ${
|
|
1317
|
+
`Payment of ${formatAssetAmount(asset, BigInt(signedAmount))} required but no max_price_lamports set. Retry with max_price_lamports to approve.`
|
|
1297
1318
|
)
|
|
1298
1319
|
);
|
|
1299
1320
|
return;
|
|
@@ -1301,7 +1322,7 @@ function makePaymentFeedbackHandler(opts) {
|
|
|
1301
1322
|
if (opts.maxPriceLamports !== void 0 && signedAmount !== void 0 && signedAmount > opts.maxPriceLamports) {
|
|
1302
1323
|
opts.rejectPayment(
|
|
1303
1324
|
new Error(
|
|
1304
|
-
`Price ${
|
|
1325
|
+
`Price ${formatAssetAmount(asset, BigInt(signedAmount))} exceeds max ${formatAssetAmount(asset, BigInt(opts.maxPriceLamports))}`
|
|
1305
1326
|
)
|
|
1306
1327
|
);
|
|
1307
1328
|
return;
|
|
@@ -1309,12 +1330,11 @@ function makePaymentFeedbackHandler(opts) {
|
|
|
1309
1330
|
if (!opts.agent.solanaKeypair) {
|
|
1310
1331
|
opts.resolveNoWallet(
|
|
1311
1332
|
`Payment required but no Solana wallet configured.
|
|
1312
|
-
Amount: ${signedAmount !== void 0 ?
|
|
1333
|
+
Amount: ${signedAmount !== void 0 ? formatAssetAmount(asset, BigInt(signedAmount)) : "unknown"}
|
|
1313
1334
|
Payment request: ${paymentRequest}`
|
|
1314
1335
|
);
|
|
1315
1336
|
return;
|
|
1316
1337
|
}
|
|
1317
|
-
const asset = resolveAssetFromPaymentRequest(parsedRequest);
|
|
1318
1338
|
let reservedAmount;
|
|
1319
1339
|
if (signedAmount !== void 0) {
|
|
1320
1340
|
try {
|
|
@@ -1683,9 +1703,10 @@ ${result}`);
|
|
|
1683
1703
|
);
|
|
1684
1704
|
}
|
|
1685
1705
|
const price = card.payment?.job_price ?? 0;
|
|
1706
|
+
const cardAsset = assetFromCardPayment(card.payment);
|
|
1686
1707
|
if (input.max_price_lamports !== void 0 && price > input.max_price_lamports) {
|
|
1687
1708
|
return errorResult(
|
|
1688
|
-
`Price ${
|
|
1709
|
+
`Price ${formatAssetAmount(cardAsset, BigInt(price))} exceeds max ${formatAssetAmount(cardAsset, BigInt(input.max_price_lamports))}`
|
|
1689
1710
|
);
|
|
1690
1711
|
}
|
|
1691
1712
|
if (price > 0 && input.max_price_lamports === void 0) {
|
|
@@ -1693,7 +1714,7 @@ ${result}`);
|
|
|
1693
1714
|
content: [
|
|
1694
1715
|
{
|
|
1695
1716
|
type: "text",
|
|
1696
|
-
text: `Capability "${input.capability}" from "${provider.name || input.provider_npub}" costs ${
|
|
1717
|
+
text: `Capability "${input.capability}" from "${provider.name || input.provider_npub}" costs ${formatAssetAmount(cardAsset, BigInt(price))}.
|
|
1697
1718
|
|
|
1698
1719
|
To confirm, call buy_capability again with max_price_lamports set (e.g. ${price} or higher).`
|
|
1699
1720
|
}
|
|
@@ -1795,11 +1816,13 @@ var dashboardTools = [
|
|
|
1795
1816
|
);
|
|
1796
1817
|
const rows = filtered.map((a) => {
|
|
1797
1818
|
const mainCard = a.cards[0];
|
|
1819
|
+
const mainAsset = assetFromCardPayment(mainCard?.payment);
|
|
1820
|
+
const mainPrice = mainCard?.payment?.job_price;
|
|
1798
1821
|
return {
|
|
1799
1822
|
name: sanitizeField(a.name || mainCard?.name || "unknown", 30),
|
|
1800
1823
|
npub: a.npub,
|
|
1801
1824
|
capabilities: (mainCard?.capabilities ?? []).join(", "),
|
|
1802
|
-
price:
|
|
1825
|
+
price: mainPrice ? formatAssetAmount(mainAsset, BigInt(mainPrice)) : "free",
|
|
1803
1826
|
cards_count: a.cards.length
|
|
1804
1827
|
};
|
|
1805
1828
|
}).slice(0, input.top_n);
|
|
@@ -2023,15 +2046,22 @@ var discoveryTools = [
|
|
|
2023
2046
|
const results = filtered.map((a) => ({
|
|
2024
2047
|
npub: a.npub,
|
|
2025
2048
|
name: sanitizeField(a.name || "", 200),
|
|
2026
|
-
cards: a.cards.map((
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2049
|
+
cards: a.cards.map((card) => {
|
|
2050
|
+
const asset = assetFromCardPayment(card.payment);
|
|
2051
|
+
const price = card.payment?.job_price;
|
|
2052
|
+
return {
|
|
2053
|
+
name: sanitizeField(card.name || "", 200),
|
|
2054
|
+
description: sanitizeField(card.description || "", 500),
|
|
2055
|
+
capabilities: card.capabilities,
|
|
2056
|
+
job_price_subunits: price,
|
|
2057
|
+
price_display: price ? formatAssetAmount(asset, BigInt(price)) : "free",
|
|
2058
|
+
asset_token: asset.token,
|
|
2059
|
+
asset_symbol: asset.symbol,
|
|
2060
|
+
asset_mint: asset.mint,
|
|
2061
|
+
chain: card.payment?.chain,
|
|
2062
|
+
network: card.payment?.network
|
|
2063
|
+
};
|
|
2064
|
+
}),
|
|
2035
2065
|
supported_kinds: a.supportedKinds
|
|
2036
2066
|
}));
|
|
2037
2067
|
const { text } = sanitizeUntrusted(JSON.stringify(results, null, 2), "structured");
|