@elisym/mcp 0.8.11 → 0.8.12
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 +38 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, resolveKnownAsset,
|
|
2
|
+
import { LIMITS, DEFAULT_KIND_OFFSET, SolanaPaymentStrategy, makeCensor, DEFAULT_REDACT_PATHS, validateAgentName, RELAYS, toDTag, formatAssetAmount, estimateNetworkBaseline, formatSol as formatSol$1, USDC_SOLANA_DEVNET, estimateSolFeeLamports, formatFeeBreakdown, resolveAssetFromPaymentRequest as resolveAssetFromPaymentRequest$1, parseAssetAmount, ElisymIdentity, ElisymClient, NATIVE_SOL, resolveKnownAsset, formatNetworkBaseline, getProtocolProgramId, getProtocolConfig, assetKey, assetByKey, KNOWN_ASSETS } from '@elisym/sdk';
|
|
3
3
|
import { listAgents, createAgentDir, writeYaml, writeSecrets, resolveAgent, loadAgent, globalConfigPath, writeFileAtomic as writeFileAtomic$1 } from '@elisym/sdk/agent-store';
|
|
4
4
|
import { loadGlobalConfig, writeGlobalConfig } from '@elisym/sdk/node';
|
|
5
|
-
import { getBase58Encoder, getBase58Decoder, generateKeyPairSigner, address, createSolanaRpcSubscriptions, sendAndConfirmTransactionFactory, getSignatureFromTransaction, pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, signTransactionMessageWithSigners, createKeyPairSignerFromBytes,
|
|
5
|
+
import { getBase58Encoder, getBase58Decoder, generateKeyPairSigner, createSolanaRpc, address, createSolanaRpcSubscriptions, sendAndConfirmTransactionFactory, getSignatureFromTransaction, pipe, createTransactionMessage, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, signTransactionMessageWithSigners, createKeyPairSignerFromBytes, isAddress } from '@solana/kit';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { generateSecretKey, nip19, getPublicKey } from 'nostr-tools';
|
|
8
8
|
import { readFile, writeFile, rename, unlink } from 'node:fs/promises';
|
|
@@ -2095,14 +2095,13 @@ var ContactSchema = z.object({
|
|
|
2095
2095
|
name: z.string().max(200).optional(),
|
|
2096
2096
|
addedAt: z.number().int().nonnegative(),
|
|
2097
2097
|
lastJobAt: z.number().int().nonnegative().optional(),
|
|
2098
|
-
jobCount: z.number().int().nonnegative(),
|
|
2099
2098
|
lastCapability: z.string().max(200).optional(),
|
|
2100
2099
|
note: z.string().max(500).optional()
|
|
2101
|
-
})
|
|
2100
|
+
});
|
|
2102
2101
|
var ContactsSchema = z.object({
|
|
2103
2102
|
version: z.literal(1),
|
|
2104
2103
|
contacts: z.array(ContactSchema)
|
|
2105
|
-
})
|
|
2104
|
+
});
|
|
2106
2105
|
var EMPTY2 = { version: 1, contacts: [] };
|
|
2107
2106
|
var writeLocks2 = /* @__PURE__ */ new Map();
|
|
2108
2107
|
function withLock2(path, fn) {
|
|
@@ -2157,8 +2156,7 @@ async function upsertContact(agentDir, input) {
|
|
|
2157
2156
|
name: input.name ?? existing.name,
|
|
2158
2157
|
note: input.note ?? existing.note,
|
|
2159
2158
|
lastJobAt: input.lastJobAt ?? existing.lastJobAt,
|
|
2160
|
-
lastCapability: input.lastCapability ?? existing.lastCapability
|
|
2161
|
-
jobCount: input.jobCount ?? existing.jobCount + 1
|
|
2159
|
+
lastCapability: input.lastCapability ?? existing.lastCapability
|
|
2162
2160
|
});
|
|
2163
2161
|
data.contacts[index] = merged;
|
|
2164
2162
|
} else {
|
|
@@ -2169,8 +2167,7 @@ async function upsertContact(agentDir, input) {
|
|
|
2169
2167
|
note: input.note,
|
|
2170
2168
|
addedAt: Date.now(),
|
|
2171
2169
|
lastJobAt: input.lastJobAt,
|
|
2172
|
-
lastCapability: input.lastCapability
|
|
2173
|
-
jobCount: input.jobCount ?? 0
|
|
2170
|
+
lastCapability: input.lastCapability
|
|
2174
2171
|
});
|
|
2175
2172
|
data.contacts.push(merged);
|
|
2176
2173
|
}
|
|
@@ -2418,12 +2415,38 @@ var discoveryTools = [
|
|
|
2418
2415
|
include_offline ? "No agents found matching those capabilities." : "No online agents found matching those capabilities. Retry shortly or pass include_offline=true to see unreachable matches."
|
|
2419
2416
|
);
|
|
2420
2417
|
}
|
|
2418
|
+
const needsAtaSeen = /* @__PURE__ */ new Set();
|
|
2419
|
+
for (const a of filtered) {
|
|
2420
|
+
for (const card of a.cards) {
|
|
2421
|
+
if ((card.payment?.chain ?? "solana") !== "solana") {
|
|
2422
|
+
continue;
|
|
2423
|
+
}
|
|
2424
|
+
if (!card.payment?.job_price) {
|
|
2425
|
+
continue;
|
|
2426
|
+
}
|
|
2427
|
+
needsAtaSeen.add(assetFromCardPayment(card.payment).mint !== void 0);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
const gasByAtaNeed = /* @__PURE__ */ new Map();
|
|
2431
|
+
if (needsAtaSeen.size > 0) {
|
|
2432
|
+
try {
|
|
2433
|
+
const rpc = createSolanaRpc(rpcUrlFor(agent.network));
|
|
2434
|
+
await Promise.all(
|
|
2435
|
+
Array.from(needsAtaSeen).map(async (needsAta) => {
|
|
2436
|
+
const baseline = await estimateNetworkBaseline(rpc, { includeAtaRent: needsAta });
|
|
2437
|
+
gasByAtaNeed.set(needsAta, formatSol$1(Number(baseline.totalLamports)));
|
|
2438
|
+
})
|
|
2439
|
+
);
|
|
2440
|
+
} catch {
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2421
2443
|
const results = filtered.map((a) => ({
|
|
2422
2444
|
npub: a.npub,
|
|
2423
2445
|
name: sanitizeField(a.name || "", 200),
|
|
2424
2446
|
cards: a.cards.map((card) => {
|
|
2425
2447
|
const asset = assetFromCardPayment(card.payment);
|
|
2426
2448
|
const price = card.payment?.job_price;
|
|
2449
|
+
const gasEstimate = price ? gasByAtaNeed.get(asset.mint !== void 0) : void 0;
|
|
2427
2450
|
return {
|
|
2428
2451
|
name: sanitizeField(card.name || "", 200),
|
|
2429
2452
|
description: sanitizeField(card.description || "", 500),
|
|
@@ -2434,7 +2457,8 @@ var discoveryTools = [
|
|
|
2434
2457
|
asset_symbol: asset.symbol,
|
|
2435
2458
|
asset_mint: asset.mint,
|
|
2436
2459
|
chain: card.payment?.chain,
|
|
2437
|
-
network: card.payment?.network
|
|
2460
|
+
network: card.payment?.network,
|
|
2461
|
+
network_fee_estimate_sol: gasEstimate
|
|
2438
2462
|
};
|
|
2439
2463
|
}),
|
|
2440
2464
|
supported_kinds: a.supportedKinds,
|
|
@@ -2571,7 +2595,7 @@ var feedbackContactsTools = [
|
|
|
2571
2595
|
}),
|
|
2572
2596
|
defineTool({
|
|
2573
2597
|
name: "add_contact",
|
|
2574
|
-
description: "Add a provider to the active agent's contacts list (.contacts.json). When the provider has prior jobs in the local history, the contact is enriched with
|
|
2598
|
+
description: "Add a provider to the active agent's contacts list (.contacts.json). When the provider has prior jobs in the local history, the contact is enriched with lastJobAt and lastCapability. Idempotent: re-calling with the same npub updates name/note in place without duplicating the entry.",
|
|
2575
2599
|
schema: AddContactSchema,
|
|
2576
2600
|
async handler(ctx, input) {
|
|
2577
2601
|
ctx.toolRateLimiter.check();
|
|
@@ -2599,14 +2623,12 @@ var feedbackContactsTools = [
|
|
|
2599
2623
|
name: cleanName ?? fallbackProviderName,
|
|
2600
2624
|
note: cleanNote,
|
|
2601
2625
|
lastJobAt: last?.completedAt,
|
|
2602
|
-
lastCapability: last?.capability
|
|
2603
|
-
jobCount: history.length
|
|
2626
|
+
lastCapability: last?.capability
|
|
2604
2627
|
});
|
|
2605
2628
|
const lines = [
|
|
2606
2629
|
`Saved contact ${contact.npub}.`,
|
|
2607
2630
|
contact.name ? ` name: ${contact.name}` : null,
|
|
2608
|
-
contact.lastCapability ? ` last capability: ${contact.lastCapability}` : null
|
|
2609
|
-
contact.jobCount > 0 ? ` prior jobs: ${contact.jobCount}` : null
|
|
2631
|
+
contact.lastCapability ? ` last capability: ${contact.lastCapability}` : null
|
|
2610
2632
|
].filter((line) => line !== null);
|
|
2611
2633
|
return textResult(lines.join("\n"));
|
|
2612
2634
|
}
|
|
@@ -2656,8 +2678,7 @@ var feedbackContactsTools = [
|
|
|
2656
2678
|
note: contact.note !== void 0 ? sanitizeField(contact.note, 500) : void 0,
|
|
2657
2679
|
added_at: contact.addedAt,
|
|
2658
2680
|
last_job_at: contact.lastJobAt,
|
|
2659
|
-
last_capability: contact.lastCapability !== void 0 ? sanitizeField(contact.lastCapability, 200) : void 0
|
|
2660
|
-
job_count: contact.jobCount
|
|
2681
|
+
last_capability: contact.lastCapability !== void 0 ? sanitizeField(contact.lastCapability, 200) : void 0
|
|
2661
2682
|
}));
|
|
2662
2683
|
const { text: wrapped } = sanitizeUntrusted(JSON.stringify(limited, null, 2), "structured");
|
|
2663
2684
|
return textResult(`${limited.length} contact(s):
|