keyring-agent-core 0.3.24 → 0.4.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.ts CHANGED
@@ -3185,7 +3185,8 @@ interface AgentResponse {
3185
3185
  * User query
3186
3186
  * → Router (picks 0..N domain subagents)
3187
3187
  * → Subagent(s) (each runs its own ReAct loop over a narrow tool set, in parallel)
3188
- * → Synthesizer (merges subagent answers into the final reply)
3188
+ * → Synthesizer (merges answers when several subagents ran; a single
3189
+ * subagent's own answer is the final reply)
3189
3190
  *
3190
3191
  * Compared to a flat planner that sees every tool, this keeps per-call prompt
3191
3192
  * size bounded regardless of how many tools are registered.
@@ -3551,6 +3552,29 @@ interface WebsiteTrustKeyringAgentConfig {
3551
3552
  * reuse the agent for another context.
3552
3553
  */
3553
3554
  ecosystemContext?: string;
3555
+ /**
3556
+ * How long (ms) a result for a caller-trusted site (`isMarkOfficial: true`) is
3557
+ * reused for the same site + language. Defaults to 7 days
3558
+ * ({@link DEFAULT_OFFICIAL_CACHE_TTL_MS}); `0` disables caching for this mode.
3559
+ * The in-memory cache is shared by every agent instance, so building a fresh
3560
+ * agent per request still hits it.
3561
+ */
3562
+ officialCacheTtlMs?: number;
3563
+ /**
3564
+ * How long (ms) a phishing assessment (`isMarkOfficial: false`) is reused for
3565
+ * the same site + language. Defaults to 1 day ({@link DEFAULT_ASSESS_CACHE_TTL_MS})
3566
+ * — shorter than the official TTL because a verdict on an unvetted site goes
3567
+ * stale faster (new scam reports, a domain changing hands). `0` disables
3568
+ * caching for this mode.
3569
+ */
3570
+ assessCacheTtlMs?: number;
3571
+ /**
3572
+ * Persist the cache across restarts — Web: `localStorage`, React Native:
3573
+ * `AsyncStorage`. Omit to cache in memory only.
3574
+ */
3575
+ cacheStorage?: StorageProvider;
3576
+ /** Storage key for the persisted cache. Defaults to "keyring-website-trust-cache". */
3577
+ cacheStorageKey?: string;
3554
3578
  /** Enable debug logging. */
3555
3579
  debug?: boolean;
3556
3580
  }
@@ -3661,7 +3685,13 @@ declare class WebsiteTrustKeyringAgent {
3661
3685
  private readonly ownGeminiKey;
3662
3686
  /** True once the license has passed, so we only hash-check once. */
3663
3687
  private licenseChecked;
3688
+ /** Result cache, shared by both modes; each mode has its own TTL (0 = not cached). */
3689
+ private readonly cache;
3690
+ private readonly officialCacheTtlMs;
3691
+ private readonly assessCacheTtlMs;
3664
3692
  constructor(config?: WebsiteTrustKeyringAgentConfig);
3693
+ /** Drop every cached result (memory and persisted storage). */
3694
+ clearCache(): Promise<void>;
3665
3695
  /**
3666
3696
  * Validate the license key against the hash baked into this bundle at build
3667
3697
  * time (`__AGENT_LICENSE_HASH__`, set by tsup from `SECRET_KEY_HASH`). The
@@ -3676,6 +3706,13 @@ declare class WebsiteTrustKeyringAgent {
3676
3706
  */
3677
3707
  private assertLicense;
3678
3708
  chat(input: WebsiteTrustInput): Promise<WebsiteTrustResult>;
3709
+ /**
3710
+ * The uncached analysis behind {@link chat}. `cacheable` is false when a model
3711
+ * reply was unusable and the result was built from fallbacks — caching that
3712
+ * would pin a degraded (or, for an unanswered investigation, falsely "safe")
3713
+ * result for the whole TTL.
3714
+ */
3715
+ private analyze;
3679
3716
  /**
3680
3717
  * Derive the phishing verdict + raw (English) evidence reasons from the
3681
3718
  * investigation — pure logic, no AI, so the verdict is stable across runs.
@@ -5396,6 +5433,9 @@ interface TokenScoreResponse {
5396
5433
  updatedAt?: string | null;
5397
5434
  metrics?: TokenScoreMetrics;
5398
5435
  }
5436
+ type WalletTokenBalancesResponse = MoralisApiResponse<{
5437
+ result: TokenBalance[];
5438
+ }>;
5399
5439
  declare class MoralisService {
5400
5440
  private baseUrl;
5401
5441
  private v1BaseUrl;
@@ -5420,9 +5460,9 @@ declare class MoralisService {
5420
5460
  * filter — can pass `false` to skip the RPC entirely.
5421
5461
  */
5422
5462
  convertYieldValues?: boolean;
5423
- }): Promise<MoralisApiResponse<{
5424
- result: TokenBalance[];
5425
- }>>;
5463
+ }): Promise<WalletTokenBalancesResponse>;
5464
+ /** The uncached read behind {@link getWalletTokenBalances}. */
5465
+ private fetchWalletTokenBalances;
5426
5466
  /**
5427
5467
  * Get metadata + price for a single token by contract address.
5428
5468
  */
@@ -5851,7 +5891,7 @@ declare class TokenInfoTool extends BaseTool {
5851
5891
  research: string | null;
5852
5892
  } | {
5853
5893
  research: string | null;
5854
- searchResults?: TokenMetadata[] | undefined;
5894
+ searchResults?: Record<string, unknown>[] | undefined;
5855
5895
  _instructions: string;
5856
5896
  chain: string;
5857
5897
  userHoldsToken: boolean;
@@ -9910,9 +9950,11 @@ interface CreateTransportParameters<TType extends string = string> {
9910
9950
  request: EIP1193RequestFn;
9911
9951
  retryCount?: number;
9912
9952
  retryDelay?: number;
9953
+ /** @see BuildRequestParameters.maxRetryAfterMs */
9954
+ maxRetryAfterMs?: number;
9913
9955
  timeout?: number;
9914
9956
  }
9915
- declare function createTransport<TType extends string, TValue = unknown>({ key, name, type, request, retryCount, retryDelay, timeout }: CreateTransportParameters<TType>, value?: TValue): TransportInstance<TType, TValue>;
9957
+ declare function createTransport<TType extends string, TValue = unknown>({ key, name, type, request, retryCount, retryDelay, maxRetryAfterMs, timeout, }: CreateTransportParameters<TType>, value?: TValue): TransportInstance<TType, TValue>;
9916
9958
 
9917
9959
  /** Normalized, `fetch`-like response. `data` is the parsed body (JSON when possible). */
9918
9960
  interface ApiResponse<T = unknown> {
@@ -9996,6 +10038,11 @@ interface HttpTransportConfig {
9996
10038
  retryCount?: number;
9997
10039
  /** Base backoff in ms (default 150, doubling each attempt). */
9998
10040
  retryDelay?: number;
10041
+ /**
10042
+ * Fail instead of waiting when the endpoint's `Retry-After` exceeds this (ms),
10043
+ * so a fallback can try its next endpoint. Default: always wait.
10044
+ */
10045
+ maxRetryAfterMs?: number;
9999
10046
  /** Per-request timeout in ms (default 10_000). */
10000
10047
  timeout?: number;
10001
10048
  }