@elisym/sdk 0.8.0 → 0.10.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/README.md +31 -10
- package/dist/agent-store.cjs +1 -2
- package/dist/agent-store.cjs.map +1 -1
- package/dist/agent-store.d.cts +19 -16
- package/dist/agent-store.d.ts +19 -16
- package/dist/agent-store.js +1 -2
- package/dist/agent-store.js.map +1 -1
- package/dist/assets-CMf-v55Z.d.cts +58 -0
- package/dist/assets-CMf-v55Z.d.ts +58 -0
- package/dist/global-schema-CddHP2nk.d.cts +62 -0
- package/dist/global-schema-CddHP2nk.d.ts +62 -0
- package/dist/index.cjs +642 -169
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +214 -117
- package/dist/index.d.ts +214 -117
- package/dist/index.js +636 -168
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +60 -0
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +21 -1
- package/dist/node.d.ts +21 -1
- package/dist/node.js +55 -1
- package/dist/node.js.map +1 -1
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +14 -0
- package/dist/runtime.d.ts +14 -0
- package/dist/runtime.js.map +1 -1
- package/dist/skills.cjs +123 -10
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.d.cts +17 -4
- package/dist/skills.d.ts +17 -4
- package/dist/skills.js +123 -10
- package/dist/skills.js.map +1 -1
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Address, TransactionSigner, Rpc, SolanaRpcApi } from '@solana/kit';
|
|
2
2
|
import { Filter, Event } from 'nostr-tools';
|
|
3
|
+
import { A as Asset } from './assets-CMf-v55Z.cjs';
|
|
4
|
+
export { C as Chain, K as KNOWN_ASSETS, N as NATIVE_SOL, U as USDC_SOLANA_DEVNET, a as assetByKey, b as assetKey, f as formatAssetAmount, p as parseAssetAmount, r as resolveAssetFromPaymentRequest, c as resolveKnownAsset } from './assets-CMf-v55Z.cjs';
|
|
3
5
|
import { z } from 'zod';
|
|
6
|
+
export { G as GlobalConfig, a as GlobalConfigSchema, S as SessionSpendLimitEntry, b as SessionSpendLimitEntrySchema } from './global-schema-CddHP2nk.cjs';
|
|
4
7
|
|
|
5
8
|
declare class ElisymIdentity {
|
|
6
9
|
private _secretKey;
|
|
@@ -36,8 +39,21 @@ interface PaymentInfo {
|
|
|
36
39
|
chain: string;
|
|
37
40
|
network: string;
|
|
38
41
|
address: string;
|
|
39
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Price in subunits of the payment asset (non-negative integer).
|
|
44
|
+
*
|
|
45
|
+
* Subunit = smallest indivisible unit: 1 lamport for SOL, 1 "cent" (1e-6 USDC)
|
|
46
|
+
* for USDC. When `token` is omitted, subunits are lamports (back-compat).
|
|
47
|
+
*/
|
|
40
48
|
job_price?: number;
|
|
49
|
+
/** Lowercase token id (e.g. 'sol', 'usdc'). Absent => native SOL. */
|
|
50
|
+
token?: string;
|
|
51
|
+
/** SPL mint / ERC-20 contract. Undefined for native coin. */
|
|
52
|
+
mint?: string;
|
|
53
|
+
/** Subunits per whole (9 for SOL, 6 for USDC). */
|
|
54
|
+
decimals?: number;
|
|
55
|
+
/** Display symbol (e.g. 'SOL', 'USDC'). */
|
|
56
|
+
symbol?: string;
|
|
41
57
|
}
|
|
42
58
|
/** Agent discovered from the network. */
|
|
43
59
|
interface Agent {
|
|
@@ -46,7 +62,16 @@ interface Agent {
|
|
|
46
62
|
cards: CapabilityCard[];
|
|
47
63
|
eventId: string;
|
|
48
64
|
supportedKinds: number[];
|
|
65
|
+
/** Newest network signal of any kind: capability publish, result event, or feedback event. */
|
|
49
66
|
lastSeen: number;
|
|
67
|
+
/** Unix seconds of the agent's most recent on-chain-verified paid job. Undefined if none. */
|
|
68
|
+
lastPaidJobAt?: number;
|
|
69
|
+
/** Solana tx signature of the verified paid job referenced by `lastPaidJobAt`. */
|
|
70
|
+
lastPaidJobTx?: string;
|
|
71
|
+
/** Count of `rating=1` feedback events targeting this agent (last 30 days). */
|
|
72
|
+
positiveCount?: number;
|
|
73
|
+
/** Count of all rated feedback events targeting this agent (last 30 days). */
|
|
74
|
+
totalRatingCount?: number;
|
|
50
75
|
picture?: string;
|
|
51
76
|
name?: string;
|
|
52
77
|
about?: string;
|
|
@@ -102,9 +127,26 @@ interface PingResult {
|
|
|
102
127
|
/** The identity used for the ping session - reuse for job submission so pubkeys match. */
|
|
103
128
|
identity: ElisymIdentity | null;
|
|
104
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Wire-shape reference to an asset inside a payment request.
|
|
132
|
+
*
|
|
133
|
+
* Same shape as `Asset` minus the display-only `symbol` field. Absent = native
|
|
134
|
+
* SOL (back-compat for payment requests published before multi-asset support).
|
|
135
|
+
*/
|
|
136
|
+
interface PaymentAssetRef {
|
|
137
|
+
chain: string;
|
|
138
|
+
token: string;
|
|
139
|
+
mint?: string;
|
|
140
|
+
decimals: number;
|
|
141
|
+
}
|
|
105
142
|
interface PaymentRequestData {
|
|
106
143
|
recipient: string;
|
|
107
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* Total amount in subunits of the payment asset (must be positive integer).
|
|
146
|
+
*
|
|
147
|
+
* - For native SOL (asset absent / `token: 'sol'`): lamports (1e-9 SOL).
|
|
148
|
+
* - For SPL USDC: 1e-6 USDC.
|
|
149
|
+
*/
|
|
108
150
|
amount: number;
|
|
109
151
|
reference: string;
|
|
110
152
|
description?: string;
|
|
@@ -114,6 +156,8 @@ interface PaymentRequestData {
|
|
|
114
156
|
created_at: number;
|
|
115
157
|
/** Expiry duration in seconds. */
|
|
116
158
|
expiry_secs: number;
|
|
159
|
+
/** Optional asset identifier. Absent => native SOL (back-compat). */
|
|
160
|
+
asset?: PaymentAssetRef;
|
|
117
161
|
}
|
|
118
162
|
interface VerifyResult {
|
|
119
163
|
verified: boolean;
|
|
@@ -125,7 +169,7 @@ interface VerifyOptions {
|
|
|
125
169
|
intervalMs?: number;
|
|
126
170
|
txSignature?: string;
|
|
127
171
|
}
|
|
128
|
-
type PaymentValidationCode = 'invalid_json' | 'invalid_amount' | 'missing_recipient' | 'invalid_recipient_address' | 'missing_reference' | 'invalid_reference_address' | 'recipient_mismatch' | 'expired' | 'future_timestamp' | 'fee_address_mismatch' | 'fee_amount_mismatch' | 'missing_fee' | 'invalid_fee_params';
|
|
172
|
+
type PaymentValidationCode = 'invalid_json' | 'invalid_amount' | 'missing_recipient' | 'invalid_recipient_address' | 'missing_reference' | 'invalid_reference_address' | 'recipient_mismatch' | 'expired' | 'future_timestamp' | 'fee_address_mismatch' | 'fee_amount_mismatch' | 'missing_fee' | 'invalid_fee_params' | 'invalid_asset';
|
|
129
173
|
interface PaymentValidationError {
|
|
130
174
|
code: PaymentValidationCode;
|
|
131
175
|
message: string;
|
|
@@ -290,9 +334,25 @@ declare class NostrPool {
|
|
|
290
334
|
|
|
291
335
|
/** Convert a capability name to its Nostr d-tag form (ASCII-only, lowercase, hyphen-separated). */
|
|
292
336
|
declare function toDTag(name: string): string;
|
|
337
|
+
/** Sort key derived from an Agent. Higher bucket / rate / lastPaidJobAt = ranks higher. */
|
|
338
|
+
interface RankKey {
|
|
339
|
+
/** Floor-to-minute timestamp of the agent's last verified paid job. `-Infinity` for cold start. */
|
|
340
|
+
bucket: number;
|
|
341
|
+
/** Positive review rate in `[0, 1]`. 0 when the agent has no rated feedback. */
|
|
342
|
+
rate: number;
|
|
343
|
+
/** Raw `lastPaidJobAt` (Unix sec) for tiebreak inside a bucket. 0 for cold start. */
|
|
344
|
+
lastPaidJobAt: number;
|
|
345
|
+
/** Final tiebreak; orders cold-start agents by NIP-89 freshness. */
|
|
346
|
+
lastSeen: number;
|
|
347
|
+
}
|
|
348
|
+
declare function computeRankKey(agent: Agent): RankKey;
|
|
349
|
+
declare function compareAgentsByRank(a: Agent, b: Agent): number;
|
|
293
350
|
declare class DiscoveryService {
|
|
294
351
|
private pool;
|
|
295
|
-
|
|
352
|
+
private defaultRpc?;
|
|
353
|
+
constructor(pool: NostrPool, defaultRpc?: Rpc<SolanaRpcApi> | undefined);
|
|
354
|
+
/** Configure the Solana RPC used for on-chain payment verification in `fetchAgents`. */
|
|
355
|
+
setRpc(rpc: Rpc<SolanaRpcApi> | undefined): void;
|
|
296
356
|
/** Count elisym agents (kind:31990 with "elisym" tag). */
|
|
297
357
|
fetchAllAgentCount(): Promise<number>;
|
|
298
358
|
/**
|
|
@@ -310,8 +370,21 @@ declare class DiscoveryService {
|
|
|
310
370
|
}>;
|
|
311
371
|
/** Enrich agents with kind:0 metadata (name, picture, about). Mutates in place and returns the same array. */
|
|
312
372
|
enrichWithMetadata(agents: Agent[]): Promise<Agent[]>;
|
|
313
|
-
/**
|
|
314
|
-
|
|
373
|
+
/**
|
|
374
|
+
* Fetch elisym agents filtered by network, ranked by verified paid-job recency.
|
|
375
|
+
*
|
|
376
|
+
* Ranking algorithm:
|
|
377
|
+
* 1. Bucket each agent into 1-minute slots by `lastPaidJobAt` (last on-chain
|
|
378
|
+
* verified payment). Cold-start agents (no verified paid job) go into a
|
|
379
|
+
* sentinel bucket below all populated buckets.
|
|
380
|
+
* 2. Within a bucket, sort by positive review rate descending.
|
|
381
|
+
* 3. Tiebreak by raw `lastPaidJobAt`, then `lastSeen` (NIP-89 freshness).
|
|
382
|
+
*
|
|
383
|
+
* On-chain verification uses {@link verifyJobPaymentQuick} - one-shot, cached.
|
|
384
|
+
* If `rpc` is not configured, all agents fall through to cold-start and order
|
|
385
|
+
* is determined by `lastSeen` only.
|
|
386
|
+
*/
|
|
387
|
+
fetchAgents(network?: Network, limit?: number, rpcOverride?: Rpc<SolanaRpcApi>): Promise<Agent[]>;
|
|
315
388
|
/**
|
|
316
389
|
* Publish a capability card (kind:31990) as a provider.
|
|
317
390
|
* Solana address is validated for Base58 format only - full decode
|
|
@@ -455,6 +528,11 @@ interface ElisymClientFullConfig extends ElisymClientConfig {
|
|
|
455
528
|
payment?: PaymentStrategy;
|
|
456
529
|
/** Custom upload URL for file uploads (defaults to nostr.build). */
|
|
457
530
|
uploadUrl?: string;
|
|
531
|
+
/**
|
|
532
|
+
* Solana RPC used by `discovery.fetchAgents` for on-chain payment verification.
|
|
533
|
+
* If omitted, ranking falls back to NIP-89 freshness only (no paid-job promotion).
|
|
534
|
+
*/
|
|
535
|
+
rpc?: Rpc<SolanaRpcApi>;
|
|
458
536
|
}
|
|
459
537
|
declare class ElisymClient {
|
|
460
538
|
readonly pool: NostrPool;
|
|
@@ -472,6 +550,7 @@ declare class SolanaPaymentStrategy implements PaymentStrategy {
|
|
|
472
550
|
calculateFee(amount: number, config: ProtocolConfigInput): number;
|
|
473
551
|
createPaymentRequest(recipientAddress: string, amount: number, config: ProtocolConfigInput, options?: {
|
|
474
552
|
expirySecs?: number;
|
|
553
|
+
asset?: Asset;
|
|
475
554
|
}): PaymentRequestData;
|
|
476
555
|
validatePaymentRequest(requestJson: string, config: ProtocolConfigInput, expectedRecipient?: string, options?: {
|
|
477
556
|
maxAmountLamports?: bigint;
|
|
@@ -490,16 +569,26 @@ declare class SolanaPaymentStrategy implements PaymentStrategy {
|
|
|
490
569
|
private _verifyByReference;
|
|
491
570
|
}
|
|
492
571
|
/**
|
|
493
|
-
* Build the
|
|
572
|
+
* Build the transfer instructions for a payment request.
|
|
573
|
+
*
|
|
574
|
+
* For native SOL (no `paymentRequest.asset` or asset=NATIVE_SOL), emits System
|
|
575
|
+
* program `TransferSol` instructions with the payment reference attached as a
|
|
576
|
+
* read-only, non-signer account so providers can detect the payment via
|
|
577
|
+
* `getSignaturesForAddress(reference)`.
|
|
494
578
|
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
579
|
+
* For SPL assets (USDC on Solana), emits:
|
|
580
|
+
* 1. `CreateAssociatedTokenIdempotent` for the recipient ATA (funded by payer);
|
|
581
|
+
* 2. `CreateAssociatedTokenIdempotent` for the treasury ATA if a protocol fee applies;
|
|
582
|
+
* 3. `TransferChecked` from payer ATA to recipient ATA, with `reference` as an
|
|
583
|
+
* extra read-only account (canonical Solana Pay pattern);
|
|
584
|
+
* 4. `TransferChecked` from payer ATA to treasury ATA if a fee applies.
|
|
585
|
+
*
|
|
586
|
+
* Async because SPL ATAs are PDAs and `findAssociatedTokenPda` is async.
|
|
498
587
|
*
|
|
499
588
|
* Caller is responsible for validating `paymentRequest` upstream;
|
|
500
589
|
* `buildTransaction` already does that before invoking this helper.
|
|
501
590
|
*/
|
|
502
|
-
declare function buildPaymentInstructions(paymentRequest: PaymentRequestData, payerSigner: Signer): readonly unknown[]
|
|
591
|
+
declare function buildPaymentInstructions(paymentRequest: PaymentRequestData, payerSigner: Signer): Promise<readonly unknown[]>;
|
|
503
592
|
/**
|
|
504
593
|
* Convenience wrapper: fetch the on-chain protocol config first, then build a
|
|
505
594
|
* payment request using its current fee/treasury values.
|
|
@@ -565,6 +654,74 @@ interface RecentPrioritizationFeeLike {
|
|
|
565
654
|
}
|
|
566
655
|
declare function pickPercentileFee(samples: readonly RecentPrioritizationFeeLike[], percentile: number): bigint;
|
|
567
656
|
|
|
657
|
+
/**
|
|
658
|
+
* SOL-denominated fee estimator for payment requests.
|
|
659
|
+
*
|
|
660
|
+
* For a USDC payment the user still spends SOL to cover the base signature fee,
|
|
661
|
+
* the priority fee, and (for first-time recipients) the ATA rent-exemption
|
|
662
|
+
* deposit. Before calling `send_payment` the customer wants to know whether
|
|
663
|
+
* their SOL balance is sufficient - that's what this helper answers.
|
|
664
|
+
*
|
|
665
|
+
* Browser-safe: no Node-specific imports. The web dashboard will use the same
|
|
666
|
+
* function.
|
|
667
|
+
*/
|
|
668
|
+
|
|
669
|
+
interface SolFeeEstimate {
|
|
670
|
+
/** Base per-signature fee. Currently 5000 lamports * 1 signature. */
|
|
671
|
+
baseFeeLamports: bigint;
|
|
672
|
+
/**
|
|
673
|
+
* Priority fee in lamports: `ceil(priorityFeeMicroLamports * computeUnitLimit
|
|
674
|
+
* / 1_000_000)`. Rounded up so we don't underestimate.
|
|
675
|
+
*/
|
|
676
|
+
priorityFeeLamports: bigint;
|
|
677
|
+
/**
|
|
678
|
+
* Rent-exemption deposit for ATAs that the tx creates.
|
|
679
|
+
*
|
|
680
|
+
* 0 for native SOL. For SPL, `rentPerAta * (# of missing ATAs)`: recipient
|
|
681
|
+
* ATA is missing iff the recipient has never received this token; treasury
|
|
682
|
+
* ATA is missing only on the first-ever protocol fee into this mint.
|
|
683
|
+
*/
|
|
684
|
+
rentLamports: bigint;
|
|
685
|
+
/** `baseFeeLamports + priorityFeeLamports + rentLamports`. */
|
|
686
|
+
totalLamports: bigint;
|
|
687
|
+
breakdown: {
|
|
688
|
+
numSignatures: number;
|
|
689
|
+
priorityFeeMicroLamports: bigint;
|
|
690
|
+
computeUnitLimit: number;
|
|
691
|
+
rentPerAtaLamports: bigint;
|
|
692
|
+
missingAtaCount: number;
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
interface EstimateSolFeeOptions {
|
|
696
|
+
/** Override the compute-unit limit used by `buildTransaction`. */
|
|
697
|
+
computeUnitLimit?: number;
|
|
698
|
+
/** Override the priority fee directly (skips RPC). */
|
|
699
|
+
priorityFeeMicroLamports?: bigint;
|
|
700
|
+
/**
|
|
701
|
+
* Percentile of the recent priority-fee distribution to charge when
|
|
702
|
+
* `priorityFeeMicroLamports` is not supplied. Defaults to 75.
|
|
703
|
+
*/
|
|
704
|
+
priorityFeePercentile?: number;
|
|
705
|
+
/** Override the number of signatures. Defaults to 1. */
|
|
706
|
+
numSignatures?: number;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Estimate the SOL cost (in lamports) to submit the transaction that would pay
|
|
710
|
+
* this payment request from `payerAddress`.
|
|
711
|
+
*
|
|
712
|
+
* Returns a breakdown and a total. Does not submit anything on-chain.
|
|
713
|
+
*/
|
|
714
|
+
declare function estimateSolFeeLamports(rpc: Rpc<SolanaRpcApi>, paymentRequest: PaymentRequestData, _payerAddress: string, options?: EstimateSolFeeOptions): Promise<SolFeeEstimate>;
|
|
715
|
+
/**
|
|
716
|
+
* Multi-line human-readable breakdown. Used by the MCP `estimate_payment_cost`
|
|
717
|
+
* tool and (in a future PR) by the web dashboard's pre-payment panel.
|
|
718
|
+
*
|
|
719
|
+
* We render lamports as raw integers and also show a SOL decimal with 9 places.
|
|
720
|
+
* The `@elisym/sdk` `formatAssetAmount` helper lives in assets.ts, but the
|
|
721
|
+
* formatter does not need to be identical; this stays dependency-free.
|
|
722
|
+
*/
|
|
723
|
+
declare function formatFeeBreakdown(estimate: SolFeeEstimate): string;
|
|
724
|
+
|
|
568
725
|
/**
|
|
569
726
|
* Wire-shape for a NIP-90 payment_request blob, as parsed via JSON.parse.
|
|
570
727
|
*
|
|
@@ -582,6 +739,22 @@ declare const PaymentRequestSchema: z.ZodObject<{
|
|
|
582
739
|
fee_amount: z.ZodOptional<z.ZodNumber>;
|
|
583
740
|
created_at: z.ZodNumber;
|
|
584
741
|
expiry_secs: z.ZodNumber;
|
|
742
|
+
asset: z.ZodOptional<z.ZodObject<{
|
|
743
|
+
chain: z.ZodString;
|
|
744
|
+
token: z.ZodString;
|
|
745
|
+
mint: z.ZodOptional<z.ZodString>;
|
|
746
|
+
decimals: z.ZodNumber;
|
|
747
|
+
}, "strip", z.ZodTypeAny, {
|
|
748
|
+
chain: string;
|
|
749
|
+
token: string;
|
|
750
|
+
decimals: number;
|
|
751
|
+
mint?: string | undefined;
|
|
752
|
+
}, {
|
|
753
|
+
chain: string;
|
|
754
|
+
token: string;
|
|
755
|
+
decimals: number;
|
|
756
|
+
mint?: string | undefined;
|
|
757
|
+
}>>;
|
|
585
758
|
}, "strip", z.ZodTypeAny, {
|
|
586
759
|
recipient: string;
|
|
587
760
|
amount: number;
|
|
@@ -591,6 +764,12 @@ declare const PaymentRequestSchema: z.ZodObject<{
|
|
|
591
764
|
description?: string | undefined;
|
|
592
765
|
fee_address?: string | undefined;
|
|
593
766
|
fee_amount?: number | undefined;
|
|
767
|
+
asset?: {
|
|
768
|
+
chain: string;
|
|
769
|
+
token: string;
|
|
770
|
+
decimals: number;
|
|
771
|
+
mint?: string | undefined;
|
|
772
|
+
} | undefined;
|
|
594
773
|
}, {
|
|
595
774
|
recipient: string;
|
|
596
775
|
amount: number;
|
|
@@ -600,6 +779,12 @@ declare const PaymentRequestSchema: z.ZodObject<{
|
|
|
600
779
|
description?: string | undefined;
|
|
601
780
|
fee_address?: string | undefined;
|
|
602
781
|
fee_amount?: number | undefined;
|
|
782
|
+
asset?: {
|
|
783
|
+
chain: string;
|
|
784
|
+
token: string;
|
|
785
|
+
decimals: number;
|
|
786
|
+
mint?: string | undefined;
|
|
787
|
+
} | undefined;
|
|
603
788
|
}>;
|
|
604
789
|
type ParsedPaymentRequest = z.infer<typeof PaymentRequestSchema>;
|
|
605
790
|
interface ParseOptions {
|
|
@@ -625,46 +810,25 @@ type ParseResult = {
|
|
|
625
810
|
declare function parsePaymentRequest(input: string, options?: ParseOptions): ParseResult;
|
|
626
811
|
|
|
627
812
|
/**
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
* `Asset` describes a currency a customer can spend: native coins (SOL, ETH, BTC)
|
|
631
|
-
* or tokens (SPL, ERC-20). `assetKey` produces a stable string id for Map lookups.
|
|
813
|
+
* Lightweight payment verifier used by discovery ranking.
|
|
632
814
|
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
|
|
637
|
-
type Chain = 'solana';
|
|
638
|
-
interface Asset {
|
|
639
|
-
chain: Chain;
|
|
640
|
-
/** Lowercase token id: 'sol', 'usdc', 'btc', 'eth'. */
|
|
641
|
-
token: string;
|
|
642
|
-
/** SPL mint / ERC-20 contract. Undefined for a native coin. */
|
|
643
|
-
mint?: string;
|
|
644
|
-
/** Subunits per whole (9 SOL, 6 USDC, 8 BTC, 18 ETH). */
|
|
645
|
-
decimals: number;
|
|
646
|
-
/** Display symbol: 'SOL', 'USDC'. */
|
|
647
|
-
symbol: string;
|
|
648
|
-
}
|
|
649
|
-
declare const NATIVE_SOL: Asset;
|
|
650
|
-
declare const KNOWN_ASSETS: readonly Asset[];
|
|
651
|
-
/** Stable Map key for `Asset`. Same shape regardless of Asset identity. */
|
|
652
|
-
declare function assetKey(a: Pick<Asset, 'chain' | 'token' | 'mint'>): string;
|
|
653
|
-
/** Find a known asset by (chain, token, mint). Returns undefined if unknown. */
|
|
654
|
-
declare function resolveKnownAsset(chain: string, token: string, mint?: string): Asset | undefined;
|
|
655
|
-
/** Reverse lookup: given an assetKey string, return the known asset or undefined. */
|
|
656
|
-
declare function assetByKey(key: string): Asset | undefined;
|
|
657
|
-
/**
|
|
658
|
-
* Parse a human amount string ("0.5", "1", "0.000001") into raw subunits (BigInt).
|
|
659
|
-
* Uses integer math to avoid float precision issues.
|
|
815
|
+
* Unlike `SolanaPaymentStrategy.verifyPayment`, this is a single-shot check
|
|
816
|
+
* with no retries: discovery cannot afford the 30-second confirmation budget
|
|
817
|
+
* the customer-side verifier uses. If the RPC has not seen the transaction
|
|
818
|
+
* yet, we treat the agent as "no verified paid job" rather than blocking.
|
|
660
819
|
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
820
|
+
* Positive results are cached forever (Solana txs are immutable once
|
|
821
|
+
* confirmed). Negative results expire after `NEGATIVE_CACHE_TTL_MS` so a
|
|
822
|
+
* just-confirmed tx will be picked up on the next discovery refresh.
|
|
664
823
|
*/
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
824
|
+
type QuickVerifyReason = 'not_found' | 'tx_failed' | 'recipient_mismatch' | 'rpc_error' | 'invalid_input';
|
|
825
|
+
interface QuickVerifyResult {
|
|
826
|
+
verified: boolean;
|
|
827
|
+
txSignature: string;
|
|
828
|
+
reason?: QuickVerifyReason;
|
|
829
|
+
}
|
|
830
|
+
declare function clearQuickVerifyCache(): void;
|
|
831
|
+
declare function verifyJobPaymentQuick(rpc: Rpc<SolanaRpcApi>, txSignature: string, expectedRecipient: Address): Promise<QuickVerifyResult>;
|
|
668
832
|
|
|
669
833
|
/**
|
|
670
834
|
* Snapshot of the on-chain elisym-config program state.
|
|
@@ -700,73 +864,6 @@ interface GetProtocolConfigOptions {
|
|
|
700
864
|
*/
|
|
701
865
|
declare function getProtocolConfig(rpc: Rpc<SolanaRpcApi>, programId: Address, options?: GetProtocolConfigOptions): Promise<ProtocolConfig>;
|
|
702
866
|
|
|
703
|
-
/**
|
|
704
|
-
* Global (not per-agent) config stored at `~/.elisym/config.yaml`.
|
|
705
|
-
*
|
|
706
|
-
* Currently holds only session-spend-limit overrides; other top-level fields
|
|
707
|
-
* may be added later. The loader tolerates a missing file (returns `{}`), but
|
|
708
|
-
* fails fast on malformed YAML or schema violations.
|
|
709
|
-
*/
|
|
710
|
-
|
|
711
|
-
declare const SessionSpendLimitEntrySchema: z.ZodObject<{
|
|
712
|
-
chain: z.ZodEnum<["solana"]>;
|
|
713
|
-
token: z.ZodString;
|
|
714
|
-
mint: z.ZodOptional<z.ZodString>;
|
|
715
|
-
amount: z.ZodNumber;
|
|
716
|
-
}, "strict", z.ZodTypeAny, {
|
|
717
|
-
amount: number;
|
|
718
|
-
chain: "solana";
|
|
719
|
-
token: string;
|
|
720
|
-
mint?: string | undefined;
|
|
721
|
-
}, {
|
|
722
|
-
amount: number;
|
|
723
|
-
chain: "solana";
|
|
724
|
-
token: string;
|
|
725
|
-
mint?: string | undefined;
|
|
726
|
-
}>;
|
|
727
|
-
declare const GlobalConfigSchema: z.ZodObject<{
|
|
728
|
-
session_spend_limits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
729
|
-
chain: z.ZodEnum<["solana"]>;
|
|
730
|
-
token: z.ZodString;
|
|
731
|
-
mint: z.ZodOptional<z.ZodString>;
|
|
732
|
-
amount: z.ZodNumber;
|
|
733
|
-
}, "strict", z.ZodTypeAny, {
|
|
734
|
-
amount: number;
|
|
735
|
-
chain: "solana";
|
|
736
|
-
token: string;
|
|
737
|
-
mint?: string | undefined;
|
|
738
|
-
}, {
|
|
739
|
-
amount: number;
|
|
740
|
-
chain: "solana";
|
|
741
|
-
token: string;
|
|
742
|
-
mint?: string | undefined;
|
|
743
|
-
}>, "many">>;
|
|
744
|
-
}, "strict", z.ZodTypeAny, {
|
|
745
|
-
session_spend_limits?: {
|
|
746
|
-
amount: number;
|
|
747
|
-
chain: "solana";
|
|
748
|
-
token: string;
|
|
749
|
-
mint?: string | undefined;
|
|
750
|
-
}[] | undefined;
|
|
751
|
-
}, {
|
|
752
|
-
session_spend_limits?: {
|
|
753
|
-
amount: number;
|
|
754
|
-
chain: "solana";
|
|
755
|
-
token: string;
|
|
756
|
-
mint?: string | undefined;
|
|
757
|
-
}[] | undefined;
|
|
758
|
-
}>;
|
|
759
|
-
type SessionSpendLimitEntry = z.infer<typeof SessionSpendLimitEntrySchema>;
|
|
760
|
-
type GlobalConfig = z.infer<typeof GlobalConfigSchema>;
|
|
761
|
-
/**
|
|
762
|
-
* Read and validate `~/.elisym/config.yaml`. Returns `{}` if missing. Throws
|
|
763
|
-
* on malformed YAML or schema violations — the MCP server treats these as fatal
|
|
764
|
-
* at startup rather than silently ignoring bad overrides.
|
|
765
|
-
*/
|
|
766
|
-
declare function loadGlobalConfig(path: string): Promise<GlobalConfig>;
|
|
767
|
-
/** Write the config YAML atomically. Validates via Zod before writing. */
|
|
768
|
-
declare function writeGlobalConfig(path: string, config: GlobalConfig): Promise<void>;
|
|
769
|
-
|
|
770
867
|
/** Encrypt plaintext using NIP-44 v2 (sender secret key + recipient public key). */
|
|
771
868
|
declare function nip44Encrypt(plaintext: string, senderSk: Uint8Array, recipientPubkey: string): string;
|
|
772
869
|
/** Decrypt ciphertext using NIP-44 v2 (receiver secret key + sender public key). */
|
|
@@ -919,7 +1016,7 @@ declare function getProtocolProgramId(cluster: ProtocolCluster): Address;
|
|
|
919
1016
|
/** Default values for timeouts, retries, and batch sizes. */
|
|
920
1017
|
declare const DEFAULTS: {
|
|
921
1018
|
readonly SUBSCRIPTION_TIMEOUT_MS: 120000;
|
|
922
|
-
readonly PING_TIMEOUT_MS:
|
|
1019
|
+
readonly PING_TIMEOUT_MS: 3000;
|
|
923
1020
|
readonly PING_RETRIES: 2;
|
|
924
1021
|
readonly PING_CACHE_TTL_MS: 30000;
|
|
925
1022
|
readonly PAYMENT_EXPIRY_SECS: 600;
|
|
@@ -945,4 +1042,4 @@ declare const LIMITS: {
|
|
|
945
1042
|
readonly MAX_CAPABILITY_LENGTH: 64;
|
|
946
1043
|
};
|
|
947
1044
|
|
|
948
|
-
export { type Agent,
|
|
1045
|
+
export { type Agent, Asset, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, 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, NostrPool, PROTOCOL_FEE_BPS, PROTOCOL_PROGRAM_ID_DEVNET, PROTOCOL_TREASURY, 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, 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 };
|