@elisym/sdk 0.12.0 → 0.12.2

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.d.cts CHANGED
@@ -205,10 +205,10 @@ type Signer = TransactionSigner;
205
205
  /**
206
206
  * Protocol fee + treasury inputs for building a payment request.
207
207
  *
208
- * In Phase 2 the SDK no longer reads PROTOCOL_FEE_BPS / PROTOCOL_TREASURY
209
- * from constants. Callers supply this config so they can either pass
210
- * the bundled fallbacks or, in Phase 3, values fetched from the on-chain
211
- * elisym-config program.
208
+ * Callers must supply this config explicitly - the SDK does not bundle a
209
+ * fallback. The canonical source is `getProtocolConfig(rpc, programId)`,
210
+ * which reads the on-chain elisym-config program; tests and offline tools
211
+ * may pass fixture values directly.
212
212
  */
213
213
  interface ProtocolConfigInput {
214
214
  /** Protocol fee in basis points (300 = 3%). Must be a non-negative integer. */
@@ -404,6 +404,16 @@ declare class DiscoveryService {
404
404
  * provider.
405
405
  */
406
406
  fetchAgents(network?: Network, limit?: number): Promise<Agent[]>;
407
+ /**
408
+ * Fetch a single agent by pubkey, fully enriched (kind:0 metadata,
409
+ * cross-checked `lastPaidJobAt`, rating counters). Returns `null` if the
410
+ * pubkey has no surviving capability cards on the requested network.
411
+ *
412
+ * Use this when navigating directly to an agent's page; running
413
+ * `fetchAgents`/`streamAgents` for that case streams the entire marketplace
414
+ * just to find one author.
415
+ */
416
+ fetchAgent(network: Network, pubkey: string): Promise<Agent | null>;
407
417
  /**
408
418
  * Enrich an agent map with paid-job stats, feedback counters, and kind:0
409
419
  * metadata, then return them sorted by `compareAgentsByRank`. Mutates the
@@ -671,9 +681,8 @@ declare function assertLamports(value: number, field: string): void;
671
681
  * Calculate the protocol fee using basis-point math (no floats).
672
682
  * Returns ceil(amount * feeBps / 10000).
673
683
  *
674
- * The caller passes the current fee (in basis points). Phase 2 of the
675
- * Solana Kit migration removes the implicit dependency on PROTOCOL_FEE_BPS
676
- * so callers can supply on-chain or test values.
684
+ * The caller passes the current fee (in basis points), typically obtained
685
+ * from `getProtocolConfig` or supplied as a test fixture.
677
686
  */
678
687
  declare function calculateProtocolFee(amount: number, feeBps: number): number;
679
688
  /** Validate payment request timestamps. Returns error message or null if valid. */
@@ -1082,21 +1091,6 @@ declare function jobResultKind(offset: number): number;
1082
1091
  declare const KIND_PING = 20200;
1083
1092
  declare const KIND_PONG = 20201;
1084
1093
  declare const LAMPORTS_PER_SOL = 1000000000;
1085
- /**
1086
- * @deprecated Fallback only - use `getProtocolConfig(rpc, programId)` for live values.
1087
- *
1088
- * Protocol fee in basis points (300 = 3%). Bundled as a default for offline use
1089
- * and for first-call before the on-chain config has been fetched. The on-chain
1090
- * `elisym-config` program is the source of truth.
1091
- */
1092
- declare const PROTOCOL_FEE_BPS = 300;
1093
- /**
1094
- * @deprecated Fallback only - use `getProtocolConfig(rpc, programId)` for live values.
1095
- *
1096
- * Solana address of the protocol treasury. Bundled fallback; the on-chain
1097
- * `elisym-config` program is the source of truth and may rotate this address.
1098
- */
1099
- declare const PROTOCOL_TREASURY: Address;
1100
1094
  /**
1101
1095
  * Solana program ID for the elisym protocol config (devnet deployment).
1102
1096
  *
@@ -1151,4 +1145,4 @@ declare const LIMITS: {
1151
1145
  readonly MAX_CAPABILITY_LENGTH: 64;
1152
1146
  };
1153
1147
 
1154
- 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_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, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -205,10 +205,10 @@ type Signer = TransactionSigner;
205
205
  /**
206
206
  * Protocol fee + treasury inputs for building a payment request.
207
207
  *
208
- * In Phase 2 the SDK no longer reads PROTOCOL_FEE_BPS / PROTOCOL_TREASURY
209
- * from constants. Callers supply this config so they can either pass
210
- * the bundled fallbacks or, in Phase 3, values fetched from the on-chain
211
- * elisym-config program.
208
+ * Callers must supply this config explicitly - the SDK does not bundle a
209
+ * fallback. The canonical source is `getProtocolConfig(rpc, programId)`,
210
+ * which reads the on-chain elisym-config program; tests and offline tools
211
+ * may pass fixture values directly.
212
212
  */
213
213
  interface ProtocolConfigInput {
214
214
  /** Protocol fee in basis points (300 = 3%). Must be a non-negative integer. */
@@ -404,6 +404,16 @@ declare class DiscoveryService {
404
404
  * provider.
405
405
  */
406
406
  fetchAgents(network?: Network, limit?: number): Promise<Agent[]>;
407
+ /**
408
+ * Fetch a single agent by pubkey, fully enriched (kind:0 metadata,
409
+ * cross-checked `lastPaidJobAt`, rating counters). Returns `null` if the
410
+ * pubkey has no surviving capability cards on the requested network.
411
+ *
412
+ * Use this when navigating directly to an agent's page; running
413
+ * `fetchAgents`/`streamAgents` for that case streams the entire marketplace
414
+ * just to find one author.
415
+ */
416
+ fetchAgent(network: Network, pubkey: string): Promise<Agent | null>;
407
417
  /**
408
418
  * Enrich an agent map with paid-job stats, feedback counters, and kind:0
409
419
  * metadata, then return them sorted by `compareAgentsByRank`. Mutates the
@@ -671,9 +681,8 @@ declare function assertLamports(value: number, field: string): void;
671
681
  * Calculate the protocol fee using basis-point math (no floats).
672
682
  * Returns ceil(amount * feeBps / 10000).
673
683
  *
674
- * The caller passes the current fee (in basis points). Phase 2 of the
675
- * Solana Kit migration removes the implicit dependency on PROTOCOL_FEE_BPS
676
- * so callers can supply on-chain or test values.
684
+ * The caller passes the current fee (in basis points), typically obtained
685
+ * from `getProtocolConfig` or supplied as a test fixture.
677
686
  */
678
687
  declare function calculateProtocolFee(amount: number, feeBps: number): number;
679
688
  /** Validate payment request timestamps. Returns error message or null if valid. */
@@ -1082,21 +1091,6 @@ declare function jobResultKind(offset: number): number;
1082
1091
  declare const KIND_PING = 20200;
1083
1092
  declare const KIND_PONG = 20201;
1084
1093
  declare const LAMPORTS_PER_SOL = 1000000000;
1085
- /**
1086
- * @deprecated Fallback only - use `getProtocolConfig(rpc, programId)` for live values.
1087
- *
1088
- * Protocol fee in basis points (300 = 3%). Bundled as a default for offline use
1089
- * and for first-call before the on-chain config has been fetched. The on-chain
1090
- * `elisym-config` program is the source of truth.
1091
- */
1092
- declare const PROTOCOL_FEE_BPS = 300;
1093
- /**
1094
- * @deprecated Fallback only - use `getProtocolConfig(rpc, programId)` for live values.
1095
- *
1096
- * Solana address of the protocol treasury. Bundled fallback; the on-chain
1097
- * `elisym-config` program is the source of truth and may rotate this address.
1098
- */
1099
- declare const PROTOCOL_TREASURY: Address;
1100
1094
  /**
1101
1095
  * Solana program ID for the elisym protocol config (devnet deployment).
1102
1096
  *
@@ -1151,4 +1145,4 @@ declare const LIMITS: {
1151
1145
  readonly MAX_CAPABILITY_LENGTH: 64;
1152
1146
  };
1153
1147
 
1154
- 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_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, 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 };
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 };
package/dist/index.js CHANGED
@@ -37,8 +37,6 @@ function jobResultKind(offset) {
37
37
  var KIND_PING = 20200;
38
38
  var KIND_PONG = 20201;
39
39
  var LAMPORTS_PER_SOL = 1e9;
40
- var PROTOCOL_FEE_BPS = 300;
41
- var PROTOCOL_TREASURY = "GY7vnWMkKpftU4nQ16C2ATkj1JwrQpHhknkaBUn67VTy";
42
40
  var PROTOCOL_PROGRAM_ID_DEVNET = "BrX1CRkSgvcjxBvc2bgc3QqgWjinusofDmeP7ZVxvwrE";
43
41
  var ELISYM_PROTOCOL_TAG = "ELiZksgwDt41LaeuPDLkUfWgFXhGgVayTMP7L5nTSEL8";
44
42
  function getProtocolProgramId(cluster) {
@@ -1263,6 +1261,29 @@ var DiscoveryService = class {
1263
1261
  const agents = Array.from(agentMap.values());
1264
1262
  return this.runEnrichment(agents, agentMap, NEVER_ABORTED_SIGNAL);
1265
1263
  }
1264
+ /**
1265
+ * Fetch a single agent by pubkey, fully enriched (kind:0 metadata,
1266
+ * cross-checked `lastPaidJobAt`, rating counters). Returns `null` if the
1267
+ * pubkey has no surviving capability cards on the requested network.
1268
+ *
1269
+ * Use this when navigating directly to an agent's page; running
1270
+ * `fetchAgents`/`streamAgents` for that case streams the entire marketplace
1271
+ * just to find one author.
1272
+ */
1273
+ async fetchAgent(network, pubkey) {
1274
+ const events = await this.pool.querySync({
1275
+ kinds: [KIND_APP_HANDLER],
1276
+ "#t": ["elisym"],
1277
+ authors: [pubkey]
1278
+ });
1279
+ const agentMap = buildAgentsFromEvents(events, network);
1280
+ if (agentMap.size === 0) {
1281
+ return null;
1282
+ }
1283
+ const agents = Array.from(agentMap.values());
1284
+ await this.runEnrichment(agents, agentMap, NEVER_ABORTED_SIGNAL);
1285
+ return agentMap.get(pubkey) ?? null;
1286
+ }
1266
1287
  /**
1267
1288
  * Enrich an agent map with paid-job stats, feedback counters, and kind:0
1268
1289
  * metadata, then return them sorted by `compareAgentsByRank`. Mutates the
@@ -3341,6 +3362,6 @@ function makeCensor() {
3341
3362
  };
3342
3363
  }
3343
3364
 
3344
- 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_FEE_BPS, PROTOCOL_PROGRAM_ID_DEVNET, PROTOCOL_TREASURY, 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 };
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 };
3345
3366
  //# sourceMappingURL=index.js.map
3346
3367
  //# sourceMappingURL=index.js.map