@elisym/sdk 0.12.2 → 0.12.4
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/agent-store.cjs +3 -1
- package/dist/agent-store.cjs.map +1 -1
- package/dist/agent-store.js +3 -1
- package/dist/agent-store.js.map +1 -1
- package/dist/index.cjs +33 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -793,6 +793,41 @@ declare function estimateSolFeeLamports(rpc: Rpc<SolanaRpcApi>, paymentRequest:
|
|
|
793
793
|
* formatter does not need to be identical; this stays dependency-free.
|
|
794
794
|
*/
|
|
795
795
|
declare function formatFeeBreakdown(estimate: SolFeeEstimate): string;
|
|
796
|
+
interface NetworkBaselineEstimate {
|
|
797
|
+
baseFeeLamports: bigint;
|
|
798
|
+
priorityFeeMicroLamports: bigint;
|
|
799
|
+
computeUnitLimit: number;
|
|
800
|
+
priorityFeeLamports: bigint;
|
|
801
|
+
/** Present only when `includeAtaRent: true`. */
|
|
802
|
+
ataRentLamports?: bigint;
|
|
803
|
+
/** baseFeeLamports + priorityFeeLamports + (ataRentLamports ?? 0n). */
|
|
804
|
+
totalLamports: bigint;
|
|
805
|
+
}
|
|
806
|
+
interface NetworkBaselineOptions {
|
|
807
|
+
/** Add one ATA rent-exemption deposit to the total (USDC first-time payer). */
|
|
808
|
+
includeAtaRent?: boolean;
|
|
809
|
+
/** Override the priority-fee percentile (default 75). */
|
|
810
|
+
priorityFeePercentile?: number;
|
|
811
|
+
/** Override the compute-unit limit (default 200_000). */
|
|
812
|
+
computeUnitLimit?: number;
|
|
813
|
+
/** Override priority fee directly, skipping the RPC call. */
|
|
814
|
+
priorityFeeMicroLamports?: bigint;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Estimate the SOL cost of a typical payment transaction on the current
|
|
818
|
+
* cluster, without needing a concrete `payment_request`. Used by MCP
|
|
819
|
+
* confirmation messages (e.g. `buy_capability` price gate) to surface
|
|
820
|
+
* gas before the provider has issued a payment-required feedback.
|
|
821
|
+
*
|
|
822
|
+
* Reuses the priority-fee cache in `estimatePriorityFeeMicroLamports`
|
|
823
|
+
* (TTL 10s) so consecutive confirmations don't double-hit the RPC.
|
|
824
|
+
*/
|
|
825
|
+
declare function estimateNetworkBaseline(rpc: Rpc<SolanaRpcApi>, options?: NetworkBaselineOptions): Promise<NetworkBaselineEstimate>;
|
|
826
|
+
/**
|
|
827
|
+
* Single-line summary of a network baseline estimate, suitable for embedding
|
|
828
|
+
* inside MCP confirmation strings.
|
|
829
|
+
*/
|
|
830
|
+
declare function formatNetworkBaseline(estimate: NetworkBaselineEstimate): string;
|
|
796
831
|
|
|
797
832
|
/**
|
|
798
833
|
* Wire-shape for a NIP-90 payment_request blob, as parsed via JSON.parse.
|
|
@@ -1145,4 +1180,4 @@ declare const LIMITS: {
|
|
|
1145
1180
|
readonly MAX_CAPABILITY_LENGTH: 64;
|
|
1146
1181
|
};
|
|
1147
1182
|
|
|
1148
|
-
export { type Agent, type AggregateNetworkStatsOptions, Asset, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ELISYM_PROTOCOL_TAG, ElisymClient, type ElisymClientConfig, type ElisymClientFullConfig, ElisymIdentity, type EstimatePriorityFeeOptions, type EstimateSolFeeOptions, type GetProtocolConfigOptions, INPUT_REDACT_PATHS, type Job, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkStats, type NetworkStatsResult, NostrPool, PROTOCOL_PROGRAM_ID_DEVNET, type ParseOptions, type ParseResult, type ParsedPaymentRequest, type PaymentAssetRef, type PaymentInfo, type PaymentRequestData, PaymentRequestSchema, type PaymentStrategy, type PaymentValidationCode, type PaymentValidationError, type PingResult, PingService, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, type QuickVerifyReason, type QuickVerifyResult, RELAYS, type RankKey, type RateLimitDecision, SECRET_REDACT_PATHS, type Signer, type SlidingWindowLimiter, type SlidingWindowLimiterOptions, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, aggregateNetworkStats, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
|
|
1183
|
+
export { type Agent, type AggregateNetworkStatsOptions, Asset, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ELISYM_PROTOCOL_TAG, ElisymClient, type ElisymClientConfig, type ElisymClientFullConfig, ElisymIdentity, type EstimatePriorityFeeOptions, type EstimateSolFeeOptions, type GetProtocolConfigOptions, INPUT_REDACT_PATHS, type Job, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkBaselineEstimate, type NetworkBaselineOptions, type NetworkStats, type NetworkStatsResult, NostrPool, PROTOCOL_PROGRAM_ID_DEVNET, type ParseOptions, type ParseResult, type ParsedPaymentRequest, type PaymentAssetRef, type PaymentInfo, type PaymentRequestData, PaymentRequestSchema, type PaymentStrategy, type PaymentValidationCode, type PaymentValidationError, type PingResult, PingService, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, type QuickVerifyReason, type QuickVerifyResult, RELAYS, type RankKey, type RateLimitDecision, SECRET_REDACT_PATHS, type Signer, type SlidingWindowLimiter, type SlidingWindowLimiterOptions, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, aggregateNetworkStats, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatNetworkBaseline, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
|
package/dist/index.d.ts
CHANGED
|
@@ -793,6 +793,41 @@ declare function estimateSolFeeLamports(rpc: Rpc<SolanaRpcApi>, paymentRequest:
|
|
|
793
793
|
* formatter does not need to be identical; this stays dependency-free.
|
|
794
794
|
*/
|
|
795
795
|
declare function formatFeeBreakdown(estimate: SolFeeEstimate): string;
|
|
796
|
+
interface NetworkBaselineEstimate {
|
|
797
|
+
baseFeeLamports: bigint;
|
|
798
|
+
priorityFeeMicroLamports: bigint;
|
|
799
|
+
computeUnitLimit: number;
|
|
800
|
+
priorityFeeLamports: bigint;
|
|
801
|
+
/** Present only when `includeAtaRent: true`. */
|
|
802
|
+
ataRentLamports?: bigint;
|
|
803
|
+
/** baseFeeLamports + priorityFeeLamports + (ataRentLamports ?? 0n). */
|
|
804
|
+
totalLamports: bigint;
|
|
805
|
+
}
|
|
806
|
+
interface NetworkBaselineOptions {
|
|
807
|
+
/** Add one ATA rent-exemption deposit to the total (USDC first-time payer). */
|
|
808
|
+
includeAtaRent?: boolean;
|
|
809
|
+
/** Override the priority-fee percentile (default 75). */
|
|
810
|
+
priorityFeePercentile?: number;
|
|
811
|
+
/** Override the compute-unit limit (default 200_000). */
|
|
812
|
+
computeUnitLimit?: number;
|
|
813
|
+
/** Override priority fee directly, skipping the RPC call. */
|
|
814
|
+
priorityFeeMicroLamports?: bigint;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Estimate the SOL cost of a typical payment transaction on the current
|
|
818
|
+
* cluster, without needing a concrete `payment_request`. Used by MCP
|
|
819
|
+
* confirmation messages (e.g. `buy_capability` price gate) to surface
|
|
820
|
+
* gas before the provider has issued a payment-required feedback.
|
|
821
|
+
*
|
|
822
|
+
* Reuses the priority-fee cache in `estimatePriorityFeeMicroLamports`
|
|
823
|
+
* (TTL 10s) so consecutive confirmations don't double-hit the RPC.
|
|
824
|
+
*/
|
|
825
|
+
declare function estimateNetworkBaseline(rpc: Rpc<SolanaRpcApi>, options?: NetworkBaselineOptions): Promise<NetworkBaselineEstimate>;
|
|
826
|
+
/**
|
|
827
|
+
* Single-line summary of a network baseline estimate, suitable for embedding
|
|
828
|
+
* inside MCP confirmation strings.
|
|
829
|
+
*/
|
|
830
|
+
declare function formatNetworkBaseline(estimate: NetworkBaselineEstimate): string;
|
|
796
831
|
|
|
797
832
|
/**
|
|
798
833
|
* Wire-shape for a NIP-90 payment_request blob, as parsed via JSON.parse.
|
|
@@ -1145,4 +1180,4 @@ declare const LIMITS: {
|
|
|
1145
1180
|
readonly MAX_CAPABILITY_LENGTH: 64;
|
|
1146
1181
|
};
|
|
1147
1182
|
|
|
1148
|
-
export { type Agent, type AggregateNetworkStatsOptions, Asset, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ELISYM_PROTOCOL_TAG, ElisymClient, type ElisymClientConfig, type ElisymClientFullConfig, ElisymIdentity, type EstimatePriorityFeeOptions, type EstimateSolFeeOptions, type GetProtocolConfigOptions, INPUT_REDACT_PATHS, type Job, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkStats, type NetworkStatsResult, NostrPool, PROTOCOL_PROGRAM_ID_DEVNET, type ParseOptions, type ParseResult, type ParsedPaymentRequest, type PaymentAssetRef, type PaymentInfo, type PaymentRequestData, PaymentRequestSchema, type PaymentStrategy, type PaymentValidationCode, type PaymentValidationError, type PingResult, PingService, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, type QuickVerifyReason, type QuickVerifyResult, RELAYS, type RankKey, type RateLimitDecision, SECRET_REDACT_PATHS, type Signer, type SlidingWindowLimiter, type SlidingWindowLimiterOptions, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, aggregateNetworkStats, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
|
|
1183
|
+
export { type Agent, type AggregateNetworkStatsOptions, Asset, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ELISYM_PROTOCOL_TAG, ElisymClient, type ElisymClientConfig, type ElisymClientFullConfig, ElisymIdentity, type EstimatePriorityFeeOptions, type EstimateSolFeeOptions, type GetProtocolConfigOptions, INPUT_REDACT_PATHS, type Job, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkBaselineEstimate, type NetworkBaselineOptions, type NetworkStats, type NetworkStatsResult, NostrPool, PROTOCOL_PROGRAM_ID_DEVNET, type ParseOptions, type ParseResult, type ParsedPaymentRequest, type PaymentAssetRef, type PaymentInfo, type PaymentRequestData, PaymentRequestSchema, type PaymentStrategy, type PaymentValidationCode, type PaymentValidationError, type PingResult, PingService, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, type QuickVerifyReason, type QuickVerifyResult, RELAYS, type RankKey, type RateLimitDecision, SECRET_REDACT_PATHS, type Signer, type SlidingWindowLimiter, type SlidingWindowLimiterOptions, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, aggregateNetworkStats, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatNetworkBaseline, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
|
package/dist/index.js
CHANGED
|
@@ -3002,6 +3002,37 @@ function lamportsToSol(lamports) {
|
|
|
3002
3002
|
const frac = lamports % LAMPORTS_PER_SOL2;
|
|
3003
3003
|
return `${whole}.${frac.toString().padStart(9, "0")}`;
|
|
3004
3004
|
}
|
|
3005
|
+
async function estimateNetworkBaseline(rpc, options) {
|
|
3006
|
+
const computeUnitLimit = options?.computeUnitLimit ?? DEFAULT_COMPUTE_UNIT_LIMIT2;
|
|
3007
|
+
const priorityFeeMicroLamports = options?.priorityFeeMicroLamports ?? await estimatePriorityFeeMicroLamports(rpc, {
|
|
3008
|
+
percentile: options?.priorityFeePercentile ?? DEFAULT_PRIORITY_FEE_PERCENTILE2
|
|
3009
|
+
});
|
|
3010
|
+
const baseFeeLamports = BASE_FEE_LAMPORTS_PER_SIGNATURE;
|
|
3011
|
+
const priorityFeeLamports = ceilDiv(
|
|
3012
|
+
priorityFeeMicroLamports * BigInt(computeUnitLimit),
|
|
3013
|
+
1000000n
|
|
3014
|
+
);
|
|
3015
|
+
const ataRentLamports = options?.includeAtaRent ? await fetchAtaRent(rpc) : void 0;
|
|
3016
|
+
const totalLamports = baseFeeLamports + priorityFeeLamports + (ataRentLamports ?? 0n);
|
|
3017
|
+
return {
|
|
3018
|
+
baseFeeLamports,
|
|
3019
|
+
priorityFeeMicroLamports,
|
|
3020
|
+
computeUnitLimit,
|
|
3021
|
+
priorityFeeLamports,
|
|
3022
|
+
ataRentLamports,
|
|
3023
|
+
totalLamports
|
|
3024
|
+
};
|
|
3025
|
+
}
|
|
3026
|
+
function formatNetworkBaseline(estimate) {
|
|
3027
|
+
const total = lamportsToSol(estimate.totalLamports);
|
|
3028
|
+
const base = lamportsToSol(estimate.baseFeeLamports);
|
|
3029
|
+
const priority = lamportsToSol(estimate.priorityFeeLamports);
|
|
3030
|
+
const parts = [`base ${base}`, `priority ${priority}`];
|
|
3031
|
+
if (estimate.ataRentLamports !== void 0) {
|
|
3032
|
+
parts.push(`ATA rent ${lamportsToSol(estimate.ataRentLamports)}`);
|
|
3033
|
+
}
|
|
3034
|
+
return `Estimated network gas: ${total} SOL (${parts.join(" + ")}).`;
|
|
3035
|
+
}
|
|
3005
3036
|
var NEGATIVE_CACHE_TTL_MS = 6e4;
|
|
3006
3037
|
var verifyCache = /* @__PURE__ */ new Map();
|
|
3007
3038
|
function clearQuickVerifyCache() {
|
|
@@ -3362,6 +3393,6 @@ function makeCensor() {
|
|
|
3362
3393
|
};
|
|
3363
3394
|
}
|
|
3364
3395
|
|
|
3365
|
-
export { BoundedSet, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ELISYM_PROTOCOL_TAG, ElisymClient, ElisymIdentity, GlobalConfigSchema, INPUT_REDACT_PATHS, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, KNOWN_ASSETS, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, NATIVE_SOL, NostrPool, PROTOCOL_PROGRAM_ID_DEVNET, PaymentRequestSchema, PingService, RELAYS, SECRET_REDACT_PATHS, SessionSpendLimitEntrySchema, SolanaPaymentStrategy, USDC_SOLANA_DEVNET, aggregateNetworkStats, assertExpiry, assertLamports, assetByKey, assetKey, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatAssetAmount, formatFeeBreakdown, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parseAssetAmount, parsePaymentRequest, pickPercentileFee, resolveAssetFromPaymentRequest, resolveKnownAsset, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
|
|
3396
|
+
export { BoundedSet, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ELISYM_PROTOCOL_TAG, ElisymClient, ElisymIdentity, GlobalConfigSchema, INPUT_REDACT_PATHS, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, KNOWN_ASSETS, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, NATIVE_SOL, NostrPool, PROTOCOL_PROGRAM_ID_DEVNET, PaymentRequestSchema, PingService, RELAYS, SECRET_REDACT_PATHS, SessionSpendLimitEntrySchema, SolanaPaymentStrategy, USDC_SOLANA_DEVNET, aggregateNetworkStats, assertExpiry, assertLamports, assetByKey, assetKey, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatAssetAmount, formatFeeBreakdown, formatNetworkBaseline, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parseAssetAmount, parsePaymentRequest, pickPercentileFee, resolveAssetFromPaymentRequest, resolveKnownAsset, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
|
|
3366
3397
|
//# sourceMappingURL=index.js.map
|
|
3367
3398
|
//# sourceMappingURL=index.js.map
|