@elisym/mcp 0.7.1 → 0.8.1
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 +21 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
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, resolveKnownAsset, 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
|
-
import { generateKeyPairSigner, address, createSolanaRpcSubscriptions, sendAndConfirmTransactionFactory, getSignatureFromTransaction, pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, signTransactionMessageWithSigners, createKeyPairSignerFromBytes, createSolanaRpc, isAddress } from '@solana/kit';
|
|
6
|
-
import bs58 from 'bs58';
|
|
5
|
+
import { getBase58Encoder, getBase58Decoder, generateKeyPairSigner, address, createSolanaRpcSubscriptions, sendAndConfirmTransactionFactory, getSignatureFromTransaction, pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, signTransactionMessageWithSigners, createKeyPairSignerFromBytes, createSolanaRpc, isAddress } from '@solana/kit';
|
|
7
6
|
import { Command } from 'commander';
|
|
8
7
|
import { generateSecretKey, nip19, getPublicKey } from 'nostr-tools';
|
|
9
8
|
import { readFile, writeFile, rename, unlink } from 'node:fs/promises';
|
|
@@ -675,6 +674,8 @@ function errorResult(text) {
|
|
|
675
674
|
}
|
|
676
675
|
|
|
677
676
|
// src/tools/agent.ts
|
|
677
|
+
var BASE58_ENCODER = getBase58Encoder();
|
|
678
|
+
var BASE58_DECODER = getBase58Decoder();
|
|
678
679
|
async function exportKeyPairBytes(signer) {
|
|
679
680
|
const { privateKey, publicKey } = signer.keyPair;
|
|
680
681
|
const [pkcs8, rawPub] = await Promise.all([
|
|
@@ -724,7 +725,7 @@ async function buildAgentInstance(name, config) {
|
|
|
724
725
|
let solanaKeypair;
|
|
725
726
|
if (config.solanaSecretKey) {
|
|
726
727
|
try {
|
|
727
|
-
const decoded =
|
|
728
|
+
const decoded = new Uint8Array(BASE58_ENCODER.encode(config.solanaSecretKey));
|
|
728
729
|
const signer = await createKeyPairSignerFromBytes(decoded);
|
|
729
730
|
solanaKeypair = {
|
|
730
731
|
publicKey: signer.address,
|
|
@@ -786,7 +787,7 @@ var agentTools = [
|
|
|
786
787
|
const solanaSigner = await generateKeyPairSigner(true);
|
|
787
788
|
const solanaSecretBytes = await exportKeyPairBytes(solanaSigner);
|
|
788
789
|
const nostrSecretHex = Buffer.from(nostrSecretKey).toString("hex");
|
|
789
|
-
const solanaSecretBase58 =
|
|
790
|
+
const solanaSecretBase58 = BASE58_DECODER.decode(solanaSecretBytes);
|
|
790
791
|
await saveAgentConfig(input.name, {
|
|
791
792
|
name: input.name,
|
|
792
793
|
description: input.description,
|
|
@@ -1815,7 +1816,6 @@ ${text}`);
|
|
|
1815
1816
|
}
|
|
1816
1817
|
})
|
|
1817
1818
|
];
|
|
1818
|
-
var LAST_SEEN_ONLINE_WINDOW_SECS = 10 * 60;
|
|
1819
1819
|
var SEARCH_PING_TIMEOUT_MS = 3e3;
|
|
1820
1820
|
var STOP_WORDS = /* @__PURE__ */ new Set([
|
|
1821
1821
|
"a",
|
|
@@ -1982,24 +1982,20 @@ var discoveryTools = [
|
|
|
1982
1982
|
)
|
|
1983
1983
|
);
|
|
1984
1984
|
}
|
|
1985
|
-
if (!include_offline) {
|
|
1986
|
-
const
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
}
|
|
2000
|
-
});
|
|
2001
|
-
filtered = survivors;
|
|
2002
|
-
}
|
|
1985
|
+
if (!include_offline && filtered.length > 0) {
|
|
1986
|
+
const probes = await Promise.allSettled(
|
|
1987
|
+
filtered.map(
|
|
1988
|
+
(candidate) => agent.client.ping.pingAgent(candidate.pubkey, SEARCH_PING_TIMEOUT_MS)
|
|
1989
|
+
)
|
|
1990
|
+
);
|
|
1991
|
+
const survivors = [];
|
|
1992
|
+
filtered.forEach((candidate, index) => {
|
|
1993
|
+
const probe = probes[index];
|
|
1994
|
+
if (probe?.status === "fulfilled" && probe.value.online) {
|
|
1995
|
+
survivors.push(candidate);
|
|
1996
|
+
}
|
|
1997
|
+
});
|
|
1998
|
+
filtered = survivors;
|
|
2003
1999
|
}
|
|
2004
2000
|
if (query) {
|
|
2005
2001
|
const isAscii = /^[\u0000-\u007F]*$/.test(query);
|
|
@@ -2791,6 +2787,7 @@ process.on("warning", (w) => {
|
|
|
2791
2787
|
}
|
|
2792
2788
|
console.warn(w);
|
|
2793
2789
|
});
|
|
2790
|
+
var BASE58_DECODER2 = getBase58Decoder();
|
|
2794
2791
|
function safe(fn) {
|
|
2795
2792
|
return async (...args) => {
|
|
2796
2793
|
try {
|
|
@@ -2927,7 +2924,7 @@ program.command("init [name]").description("Create a new agent identity").option
|
|
|
2927
2924
|
description: options.description,
|
|
2928
2925
|
relays: [...RELAYS],
|
|
2929
2926
|
nostrSecretKey: Buffer.from(nostrSecretKey).toString("hex"),
|
|
2930
|
-
solanaSecretKey:
|
|
2927
|
+
solanaSecretKey: BASE58_DECODER2.decode(solanaSecretBytes),
|
|
2931
2928
|
solanaAddress: solanaSigner.address,
|
|
2932
2929
|
network: "devnet",
|
|
2933
2930
|
security: { withdrawals_enabled: false, agent_switch_enabled: false },
|