@elisym/sdk 0.21.0 → 0.22.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/dist/index.d.cts CHANGED
@@ -151,6 +151,13 @@ interface JobUpdateCallbacks {
151
151
  onFeedback?: (status: string, amount?: number, paymentRequest?: string, senderPubkey?: string) => void;
152
152
  onResult?: (content: string, eventId: string) => void;
153
153
  onError?: (error: string) => void;
154
+ /**
155
+ * Fired when the result wait window expires without a result - a distinct,
156
+ * structured signal from `onError`. When omitted, the timeout is delivered
157
+ * through `onError` as a "Timed out waiting..." string for backwards
158
+ * compatibility.
159
+ */
160
+ onTimeout?: (timeoutMs: number) => void;
154
161
  }
155
162
  interface JobSubscriptionOptions {
156
163
  jobEventId: string;
@@ -709,6 +716,17 @@ type JobErrorKind = 'agent-unavailable' | 'unknown';
709
716
  * `unknown` for everything else (timeouts, validation errors, transport).
710
717
  */
711
718
  declare function classifyJobError(message: string): JobErrorKind;
719
+ /**
720
+ * Signalled via `JobUpdateCallbacks.onTimeout` (and thrown by helpers that
721
+ * await a result) when the wait window expires without a result. This is a
722
+ * distinct, structured signal from a genuine provider/transport error, so
723
+ * callers can branch on the type instead of substring-matching "timed out"
724
+ * on a free-form error message (which masks real errors that happen to
725
+ * mention a timeout).
726
+ */
727
+ declare class JobWaitTimeoutError extends Error {
728
+ constructor(timeoutMs?: number);
729
+ }
712
730
 
713
731
  declare class SolanaPaymentStrategy implements PaymentStrategy {
714
732
  readonly chain = "solana";
@@ -1260,6 +1278,7 @@ declare const DEFAULTS: {
1260
1278
  declare const LIMITS: {
1261
1279
  readonly MAX_INPUT_LENGTH: 100000;
1262
1280
  readonly MAX_TIMEOUT_SECS: 600;
1281
+ readonly MAX_EXECUTION_SECS: 2147483;
1263
1282
  readonly MAX_CAPABILITIES: 20;
1264
1283
  readonly MAX_DESCRIPTION_LENGTH: 500;
1265
1284
  readonly MAX_AGENT_NAME_LENGTH: 64;
@@ -1272,4 +1291,4 @@ declare const LIMITS: {
1272
1291
  readonly MAX_POLICY_VERSION_LENGTH: 32;
1273
1292
  };
1274
1293
 
1275
- export { type Agent, type AgentPolicy, 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 JobErrorKind, 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_LONG_FORM_ARTICLE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkBaselineEstimate, type NetworkBaselineOptions, type NetworkStats, type NetworkStatsResult, NostrPool, type OnchainNetworkStats, POLICY_D_TAG_PREFIX, POLICY_TYPE_REGEX, POLICY_T_TAG, 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, PoliciesService, type PolicyInput, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, type QuickVerifyReason, type QuickVerifyResult, RELAYS, type RankKey, SECRET_REDACT_PATHS, type Signer, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, aggregateNetworkStats, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, classifyJobError, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatNetworkBaseline, formatSol, getNetworkStats, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
1294
+ export { type Agent, type AgentPolicy, 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 JobErrorKind, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, JobWaitTimeoutError, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_LONG_FORM_ARTICLE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkBaselineEstimate, type NetworkBaselineOptions, type NetworkStats, type NetworkStatsResult, NostrPool, type OnchainNetworkStats, POLICY_D_TAG_PREFIX, POLICY_TYPE_REGEX, POLICY_T_TAG, 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, PoliciesService, type PolicyInput, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, type QuickVerifyReason, type QuickVerifyResult, RELAYS, type RankKey, SECRET_REDACT_PATHS, type Signer, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, aggregateNetworkStats, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, classifyJobError, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatNetworkBaseline, formatSol, getNetworkStats, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
package/dist/index.d.ts CHANGED
@@ -151,6 +151,13 @@ interface JobUpdateCallbacks {
151
151
  onFeedback?: (status: string, amount?: number, paymentRequest?: string, senderPubkey?: string) => void;
152
152
  onResult?: (content: string, eventId: string) => void;
153
153
  onError?: (error: string) => void;
154
+ /**
155
+ * Fired when the result wait window expires without a result - a distinct,
156
+ * structured signal from `onError`. When omitted, the timeout is delivered
157
+ * through `onError` as a "Timed out waiting..." string for backwards
158
+ * compatibility.
159
+ */
160
+ onTimeout?: (timeoutMs: number) => void;
154
161
  }
155
162
  interface JobSubscriptionOptions {
156
163
  jobEventId: string;
@@ -709,6 +716,17 @@ type JobErrorKind = 'agent-unavailable' | 'unknown';
709
716
  * `unknown` for everything else (timeouts, validation errors, transport).
710
717
  */
711
718
  declare function classifyJobError(message: string): JobErrorKind;
719
+ /**
720
+ * Signalled via `JobUpdateCallbacks.onTimeout` (and thrown by helpers that
721
+ * await a result) when the wait window expires without a result. This is a
722
+ * distinct, structured signal from a genuine provider/transport error, so
723
+ * callers can branch on the type instead of substring-matching "timed out"
724
+ * on a free-form error message (which masks real errors that happen to
725
+ * mention a timeout).
726
+ */
727
+ declare class JobWaitTimeoutError extends Error {
728
+ constructor(timeoutMs?: number);
729
+ }
712
730
 
713
731
  declare class SolanaPaymentStrategy implements PaymentStrategy {
714
732
  readonly chain = "solana";
@@ -1260,6 +1278,7 @@ declare const DEFAULTS: {
1260
1278
  declare const LIMITS: {
1261
1279
  readonly MAX_INPUT_LENGTH: 100000;
1262
1280
  readonly MAX_TIMEOUT_SECS: 600;
1281
+ readonly MAX_EXECUTION_SECS: 2147483;
1263
1282
  readonly MAX_CAPABILITIES: 20;
1264
1283
  readonly MAX_DESCRIPTION_LENGTH: 500;
1265
1284
  readonly MAX_AGENT_NAME_LENGTH: 64;
@@ -1272,4 +1291,4 @@ declare const LIMITS: {
1272
1291
  readonly MAX_POLICY_VERSION_LENGTH: 32;
1273
1292
  };
1274
1293
 
1275
- export { type Agent, type AgentPolicy, 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 JobErrorKind, 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_LONG_FORM_ARTICLE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkBaselineEstimate, type NetworkBaselineOptions, type NetworkStats, type NetworkStatsResult, NostrPool, type OnchainNetworkStats, POLICY_D_TAG_PREFIX, POLICY_TYPE_REGEX, POLICY_T_TAG, 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, PoliciesService, type PolicyInput, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, type QuickVerifyReason, type QuickVerifyResult, RELAYS, type RankKey, SECRET_REDACT_PATHS, type Signer, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, aggregateNetworkStats, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, classifyJobError, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatNetworkBaseline, formatSol, getNetworkStats, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
1294
+ export { type Agent, type AgentPolicy, 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 JobErrorKind, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, JobWaitTimeoutError, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_LONG_FORM_ARTICLE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkBaselineEstimate, type NetworkBaselineOptions, type NetworkStats, type NetworkStatsResult, NostrPool, type OnchainNetworkStats, POLICY_D_TAG_PREFIX, POLICY_TYPE_REGEX, POLICY_T_TAG, 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, PoliciesService, type PolicyInput, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, type QuickVerifyReason, type QuickVerifyResult, RELAYS, type RankKey, SECRET_REDACT_PATHS, type Signer, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, aggregateNetworkStats, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, classifyJobError, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatNetworkBaseline, formatSol, getNetworkStats, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
package/dist/index.js CHANGED
@@ -73,6 +73,11 @@ var DEFAULTS = {
73
73
  var LIMITS = {
74
74
  MAX_INPUT_LENGTH: 1e5,
75
75
  MAX_TIMEOUT_SECS: 600,
76
+ // Upper bound for execution budgets (`max_execution_secs` / `execution_timeout_secs`).
77
+ // Distinct from MAX_TIMEOUT_SECS (the result-wait cap): execution budgets may be
78
+ // hours, so this exists only to keep `secs * 1000` within Node's setTimeout limit
79
+ // (2_147_483_647 ms) - a larger value overflows and fires the timer immediately.
80
+ MAX_EXECUTION_SECS: 2147483,
76
81
  MAX_CAPABILITIES: 20,
77
82
  MAX_DESCRIPTION_LENGTH: 500,
78
83
  MAX_AGENT_NAME_LENGTH: 64,
@@ -1991,7 +1996,11 @@ var MarketplaceService = class {
1991
1996
  if (!resolved) {
1992
1997
  done();
1993
1998
  try {
1994
- cb.onError?.(`Timed out waiting for response (${timeoutMs / 1e3}s).`);
1999
+ if (cb.onTimeout) {
2000
+ cb.onTimeout(timeoutMs);
2001
+ } else {
2002
+ cb.onError?.(`Timed out waiting for response (${timeoutMs / 1e3}s).`);
2003
+ }
1995
2004
  } catch {
1996
2005
  }
1997
2006
  }
@@ -3237,6 +3246,14 @@ function classifyJobError(message) {
3237
3246
  }
3238
3247
  return "unknown";
3239
3248
  }
3249
+ var JobWaitTimeoutError = class extends Error {
3250
+ constructor(timeoutMs) {
3251
+ super(
3252
+ timeoutMs === void 0 ? "Timed out waiting for job result" : `Timed out waiting for job result (${Math.round(timeoutMs / 1e3)}s)`
3253
+ );
3254
+ this.name = "JobWaitTimeoutError";
3255
+ }
3256
+ };
3240
3257
  var DEFAULT_COMPUTE_UNIT_LIMIT2 = 2e5;
3241
3258
  var DEFAULT_PRIORITY_FEE_PERCENTILE2 = 75;
3242
3259
  var BASE_FEE_LAMPORTS_PER_SIGNATURE = 5000n;
@@ -3762,6 +3779,6 @@ function makeCensor() {
3762
3779
  };
3763
3780
  }
3764
3781
 
3765
- 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_LONG_FORM_ARTICLE, KIND_PING, KIND_PONG, KNOWN_ASSETS, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, NATIVE_SOL, NostrPool, POLICY_D_TAG_PREFIX, POLICY_TYPE_REGEX, POLICY_T_TAG, PROTOCOL_PROGRAM_ID_DEVNET, PaymentRequestSchema, PingService, PoliciesService, RELAYS, SECRET_REDACT_PATHS, SessionSpendLimitEntrySchema, SolanaPaymentStrategy, USDC_SOLANA_DEVNET, aggregateNetworkStats, assertExpiry, assertLamports, assetByKey, assetKey, buildPaymentInstructions, calculateProtocolFee, classifyJobError, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatAssetAmount, formatFeeBreakdown, formatNetworkBaseline, formatSol, getNetworkStats, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parseAssetAmount, parsePaymentRequest, pickPercentileFee, resolveAssetFromPaymentRequest, resolveKnownAsset, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
3782
+ export { BoundedSet, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ELISYM_PROTOCOL_TAG, ElisymClient, ElisymIdentity, GlobalConfigSchema, INPUT_REDACT_PATHS, JobWaitTimeoutError, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_LONG_FORM_ARTICLE, KIND_PING, KIND_PONG, KNOWN_ASSETS, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, NATIVE_SOL, NostrPool, POLICY_D_TAG_PREFIX, POLICY_TYPE_REGEX, POLICY_T_TAG, PROTOCOL_PROGRAM_ID_DEVNET, PaymentRequestSchema, PingService, PoliciesService, RELAYS, SECRET_REDACT_PATHS, SessionSpendLimitEntrySchema, SolanaPaymentStrategy, USDC_SOLANA_DEVNET, aggregateNetworkStats, assertExpiry, assertLamports, assetByKey, assetKey, buildPaymentInstructions, calculateProtocolFee, classifyJobError, clearPriorityFeeCache, clearProtocolConfigCache, clearQuickVerifyCache, compareAgentsByRank, computeRankKey, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimateNetworkBaseline, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatAssetAmount, formatFeeBreakdown, formatNetworkBaseline, formatSol, getNetworkStats, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parseAssetAmount, parsePaymentRequest, pickPercentileFee, resolveAssetFromPaymentRequest, resolveKnownAsset, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry, verifyJobPaymentQuick };
3766
3783
  //# sourceMappingURL=index.js.map
3767
3784
  //# sourceMappingURL=index.js.map