@t2000/engine 1.1.2 → 1.2.1

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
@@ -2046,6 +2046,7 @@ declare const balanceCheckTool: Tool<{
2046
2046
  saveableUsdsui: number;
2047
2047
  address: string;
2048
2048
  isSelfQuery: boolean;
2049
+ suinsName: string | null;
2049
2050
  }>;
2050
2051
 
2051
2052
  declare const savingsInfoTool: Tool<{
@@ -2053,6 +2054,7 @@ declare const savingsInfoTool: Tool<{
2053
2054
  }, {
2054
2055
  address: string;
2055
2056
  isSelfQuery: boolean;
2057
+ suinsName: string | null;
2056
2058
  positions: PositionEntry[];
2057
2059
  earnings: {
2058
2060
  totalYieldEarned: number;
@@ -2080,6 +2082,7 @@ declare const healthCheckTool: Tool<{
2080
2082
  status: string;
2081
2083
  address: string;
2082
2084
  isSelfQuery: boolean;
2085
+ suinsName: string | null;
2083
2086
  }>;
2084
2087
 
2085
2088
  type RateMap = Record<string, {
@@ -2332,6 +2335,16 @@ interface PortfolioResult {
2332
2335
  dailyEarning?: number;
2333
2336
  weekChange?: WeekChange;
2334
2337
  priceSource: AddressPortfolio['source'];
2338
+ /** Resolved on-chain address (post SuiNS normalization). */
2339
+ address?: string;
2340
+ /** True when the resolved address matches the signed-in wallet. */
2341
+ isSelfQuery?: boolean;
2342
+ /**
2343
+ * Original SuiNS name when the user passed `address: "alex.sui"`,
2344
+ * otherwise null. Host cards use this to title the result with the
2345
+ * human-readable name instead of the truncated 0x address.
2346
+ */
2347
+ suinsName?: string | null;
2335
2348
  }
2336
2349
  declare const portfolioAnalysisTool: Tool<{
2337
2350
  address?: string | undefined;
@@ -2397,12 +2410,25 @@ interface ActivitySummary {
2397
2410
  yieldEarnedUsd: number;
2398
2411
  address?: string;
2399
2412
  isSelfQuery?: boolean;
2413
+ suinsName?: string | null;
2400
2414
  }
2401
2415
  declare const activitySummaryTool: Tool<{
2402
2416
  address?: string | undefined;
2403
2417
  period?: "month" | "year" | "all" | "week" | undefined;
2404
2418
  }, ActivitySummary>;
2405
2419
 
2420
+ interface ResolveSuinsResult {
2421
+ /** The lookup name, lowercased and trimmed. */
2422
+ name: string;
2423
+ /** The resolved 0x address, or null when the name isn't registered. */
2424
+ address: string | null;
2425
+ /** True when the name resolves to an address. */
2426
+ registered: boolean;
2427
+ }
2428
+ declare const resolveSuinsTool: Tool<{
2429
+ name: string;
2430
+ }, ResolveSuinsResult>;
2431
+
2406
2432
  declare const tokenPricesTool: Tool<{
2407
2433
  coinTypes: string[];
2408
2434
  include24hChange?: boolean | undefined;
@@ -2481,6 +2507,98 @@ interface WalletCoin {
2481
2507
  */
2482
2508
  declare function fetchWalletCoins(address: string, rpcUrl?: string): Promise<WalletCoin[]>;
2483
2509
 
2510
+ /**
2511
+ * Canonical 0x-address shape. Loose lower bound (>= 1 hex char) so
2512
+ * pre-v1.0 short addresses still validate; tools that need a full 64-hex
2513
+ * address can additionally check `length === 66`. Case-insensitive on
2514
+ * the `0x` prefix because some upstream callers (and historic tests)
2515
+ * uppercase the prefix as part of address normalization tests; the
2516
+ * normalizer always returns the lowercased canonical form regardless.
2517
+ */
2518
+ declare const SUI_ADDRESS_REGEX: RegExp;
2519
+ /**
2520
+ * Strict canonical 0x-address shape (66 chars total). Used by the
2521
+ * resolver's "looks like" check to disambiguate "user pasted an
2522
+ * address" vs "user typed a SuiNS name".
2523
+ */
2524
+ declare const SUI_ADDRESS_STRICT_REGEX: RegExp;
2525
+ /**
2526
+ * Mirrors the pattern in `audric/apps/web/lib/suins-resolver.ts` so the
2527
+ * host-side send executor and the engine-side read normalizer agree on
2528
+ * what counts as a SuiNS name. SuiNS allows nested labels (`team.alex.sui`)
2529
+ * but every label must use only `[a-z0-9-]`.
2530
+ */
2531
+ declare const SUINS_NAME_REGEX: RegExp;
2532
+ declare class InvalidAddressError extends Error {
2533
+ readonly raw: string;
2534
+ constructor(raw: string);
2535
+ }
2536
+ declare class SuinsNotRegisteredError extends Error {
2537
+ readonly name_: string;
2538
+ constructor(name_: string);
2539
+ }
2540
+ declare class SuinsRpcError extends Error {
2541
+ readonly name_: string;
2542
+ constructor(name_: string, detail: string);
2543
+ }
2544
+ /**
2545
+ * Returns true if `value` looks like a SuiNS name (case-insensitive).
2546
+ * Cheap synchronous check — use to avoid an unnecessary RPC round-trip
2547
+ * for inputs that obviously aren't names (0x addresses, contact handles).
2548
+ */
2549
+ declare function looksLikeSuiNs(value: string): boolean;
2550
+ /**
2551
+ * Resolve a SuiNS name to its on-chain Sui address via the public
2552
+ * `suix_resolveNameServiceAddress` JSON-RPC method. Returns `null` if
2553
+ * the name resolves to no address (= not registered or expired). Throws
2554
+ * `SuinsRpcError` on RPC/network failure.
2555
+ *
2556
+ * The host SHOULD pass a `rpcUrl` that includes any vendor key (e.g.
2557
+ * audric's BlockVision-keyed URL) so the call benefits from the host's
2558
+ * paid retry/cache budget. Falls back to the public mainnet endpoint.
2559
+ */
2560
+ declare function resolveSuinsViaRpc(rawName: string, ctx?: {
2561
+ suiRpcUrl?: string;
2562
+ signal?: AbortSignal;
2563
+ }): Promise<string | null>;
2564
+ interface NormalizedAddress {
2565
+ /**
2566
+ * Canonical 0x-prefixed lowercase hex address. Always set on success.
2567
+ * Tools should use this for any downstream query (BlockVision, NAVI,
2568
+ * positionFetcher, etc.) and for cache keys.
2569
+ */
2570
+ address: string;
2571
+ /**
2572
+ * The user-facing name when the input was resolved via SuiNS, otherwise
2573
+ * `null`. Tools should stamp this on result data so card titles can
2574
+ * render "Balance · obehi.sui" instead of "Balance · 0x1234…abcd".
2575
+ */
2576
+ suinsName: string | null;
2577
+ /**
2578
+ * The original input (pre-normalization). Useful for error narration —
2579
+ * "I tried to resolve `Obehi.Sui` and …" reads better than the
2580
+ * post-trim/lowercase form.
2581
+ */
2582
+ raw: string;
2583
+ }
2584
+ /**
2585
+ * Canonical normalizer. Accepts a 0x address OR a SuiNS name; returns
2586
+ * a structured `NormalizedAddress`. Throws:
2587
+ * - `InvalidAddressError` if the input matches neither shape.
2588
+ * - `SuinsNotRegisteredError` if the SuiNS name is well-formed but
2589
+ * resolves to null (= not registered).
2590
+ * - `SuinsRpcError` if the RPC fails.
2591
+ *
2592
+ * Every read tool that accepts a user-supplied `address` parameter MUST
2593
+ * call this helper before any downstream lookup. Doing the check inline
2594
+ * (1) duplicates the regex, (2) silently rejects SuiNS names, (3) makes
2595
+ * cache keys inconsistent across tools (some lowercase, some not).
2596
+ */
2597
+ declare function normalizeAddressInput(value: string, ctx?: {
2598
+ suiRpcUrl?: string;
2599
+ signal?: AbortSignal;
2600
+ }): Promise<NormalizedAddress>;
2601
+
2484
2602
  /** Cache entry stored under each address key. */
2485
2603
  interface DefiCacheEntry {
2486
2604
  data: DefiSummary;
@@ -2879,4 +2997,4 @@ declare function getTelemetrySink(): TelemetrySink;
2879
2997
  /** Restore the default noop sink. Used by test teardowns. */
2880
2998
  declare function resetTelemetrySink(): void;
2881
2999
 
2882
- export { type AddressPortfolio, AnthropicProvider, type AnthropicProviderConfig, type AudricHistoryRecord, type AudricPortfolioResult, type AwaitOrFetchOpts, type BalancePrices, type BalanceResult, BalanceTracker, type BuildToolOptions, CANVAS_TEMPLATES, type CanvasTemplate, type ChatParams, type CompactOptions, type ContentBlock, ContextBudget, type ContextBudgetConfig, type ConversationState, type ConversationStateStore, type CostSnapshot, CostTracker, type CostTrackerConfig, DEFAULT_GUARD_CONFIG, DEFAULT_LEASE_SEC, DEFAULT_PERMISSION_CONFIG, DEFAULT_POLL_BUDGET_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_SYSTEM_PROMPT, type DefiCacheEntry, type DefiCacheStore, type DefiProtocol, type DefiSummary, EarlyToolDispatcher, type EngineConfig, type EngineEvent, type FetchLock, type GuardCheckResult, type GuardConfig, type GuardEvent, type GuardInjection, type GuardResult, type GuardRunnerState, type GuardTier, type GuardVerdict, type HealthFactorResult, InMemoryDefiCacheStore, InMemoryFetchLock, InMemoryNaviCacheStore, InMemoryWalletCacheStore, type LLMProvider, type McpCallResult, McpClientManager, McpResponseCache, type McpServerConfig, type McpServerConnection, type McpToolAdapterConfig, type McpToolDescriptor, MemorySessionStore, type Message, NAVI_ADDR_TTL_SEC, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_RATES_TTL_SEC, NAVI_SERVER_NAME, type NaviCacheEntry, type NaviCacheStore, type NaviRawCoin, type NaviRawHealthFactor, type NaviRawPool, type NaviRawPosition, type NaviRawPositionsResponse, type NaviRawProtocolStats, type NaviRawRewardsResponse, type NaviReadOptions, NaviTools, type OutputConfig, PERMISSION_PRESETS, type PendingAction, type PendingActionModifiableField, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionOperation, type PermissionResponse, type PermissionRule, type PortfolioCoin, type PositionEntry, type PreflightResult, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, type RatesResult, type Recipe, type RecipePrerequisite, RecipeRegistry, type RecipeStep, type RecipeStepOnError, RetryTracker, type SSEEvent, type SavingsResult, type ServerPositionData, type SessionData, type SessionStore, type StateType, type StopReason, type SuiCoinBalance, type SystemBlock, type SystemPrompt, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, type TelemetrySink, type TelemetryTags, type ThinkingConfig, type ThinkingEffort, type Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolFlags, type ToolJsonSchema, type ToolResult, TxMutex, type UserFinancialProfile, type UserPermissionConfig, WRITE_TOOLS, type WalletCacheEntry, type WalletCacheStore, type WalletCoin, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, claimRewardsTool, classifyEffort, clearPortfolioCache, clearPortfolioCacheFor, clearPriceMapCache, compactMessages, createGuardRunnerState, engineToSSE, estimateTokens, explainTxTool, extractConversationText, extractMcpText, fetchAddressDefiPortfolio, fetchAddressPortfolio, fetchAudricHistory, fetchAudricPortfolio, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getAudricApiBase, getDefaultTools, getDefiCacheStore, getFetchLock, getMcpManager, getModifiableFields, getNaviCacheStore, getTelemetrySink, getToolFlags, getWalletAddress, getWalletCacheStore, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, microcompact, mppServicesTool, naviKey, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resetFetchLock, resetNaviCacheStore, resetTelemetrySink, resetWalletCacheStore, resolvePermissionTier, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, setDefiCacheStore, setFetchLock, setNaviCacheStore, setTelemetrySink, setWalletCacheStore, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
3000
+ export { type AddressPortfolio, AnthropicProvider, type AnthropicProviderConfig, type AudricHistoryRecord, type AudricPortfolioResult, type AwaitOrFetchOpts, type BalancePrices, type BalanceResult, BalanceTracker, type BuildToolOptions, CANVAS_TEMPLATES, type CanvasTemplate, type ChatParams, type CompactOptions, type ContentBlock, ContextBudget, type ContextBudgetConfig, type ConversationState, type ConversationStateStore, type CostSnapshot, CostTracker, type CostTrackerConfig, DEFAULT_GUARD_CONFIG, DEFAULT_LEASE_SEC, DEFAULT_PERMISSION_CONFIG, DEFAULT_POLL_BUDGET_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_SYSTEM_PROMPT, type DefiCacheEntry, type DefiCacheStore, type DefiProtocol, type DefiSummary, EarlyToolDispatcher, type EngineConfig, type EngineEvent, type FetchLock, type GuardCheckResult, type GuardConfig, type GuardEvent, type GuardInjection, type GuardResult, type GuardRunnerState, type GuardTier, type GuardVerdict, type HealthFactorResult, InMemoryDefiCacheStore, InMemoryFetchLock, InMemoryNaviCacheStore, InMemoryWalletCacheStore, InvalidAddressError, type LLMProvider, type McpCallResult, McpClientManager, McpResponseCache, type McpServerConfig, type McpServerConnection, type McpToolAdapterConfig, type McpToolDescriptor, MemorySessionStore, type Message, NAVI_ADDR_TTL_SEC, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_RATES_TTL_SEC, NAVI_SERVER_NAME, type NaviCacheEntry, type NaviCacheStore, type NaviRawCoin, type NaviRawHealthFactor, type NaviRawPool, type NaviRawPosition, type NaviRawPositionsResponse, type NaviRawProtocolStats, type NaviRawRewardsResponse, type NaviReadOptions, NaviTools, type NormalizedAddress, type OutputConfig, PERMISSION_PRESETS, type PendingAction, type PendingActionModifiableField, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionOperation, type PermissionResponse, type PermissionRule, type PortfolioCoin, type PositionEntry, type PreflightResult, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, type RatesResult, type Recipe, type RecipePrerequisite, RecipeRegistry, type RecipeStep, type RecipeStepOnError, RetryTracker, type SSEEvent, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, type SavingsResult, type ServerPositionData, type SessionData, type SessionStore, type StateType, type StopReason, type SuiCoinBalance, SuinsNotRegisteredError, SuinsRpcError, type SystemBlock, type SystemPrompt, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, type TelemetrySink, type TelemetryTags, type ThinkingConfig, type ThinkingEffort, type Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolFlags, type ToolJsonSchema, type ToolResult, TxMutex, type UserFinancialProfile, type UserPermissionConfig, WRITE_TOOLS, type WalletCacheEntry, type WalletCacheStore, type WalletCoin, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, claimRewardsTool, classifyEffort, clearPortfolioCache, clearPortfolioCacheFor, clearPriceMapCache, compactMessages, createGuardRunnerState, engineToSSE, estimateTokens, explainTxTool, extractConversationText, extractMcpText, fetchAddressDefiPortfolio, fetchAddressPortfolio, fetchAudricHistory, fetchAudricPortfolio, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getAudricApiBase, getDefaultTools, getDefiCacheStore, getFetchLock, getMcpManager, getModifiableFields, getNaviCacheStore, getTelemetrySink, getToolFlags, getWalletAddress, getWalletCacheStore, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, looksLikeSuiNs, microcompact, mppServicesTool, naviKey, normalizeAddressInput, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resetFetchLock, resetNaviCacheStore, resetTelemetrySink, resetWalletCacheStore, resolvePermissionTier, resolveSuinsTool, resolveSuinsViaRpc, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, setDefiCacheStore, setFetchLock, setNaviCacheStore, setTelemetrySink, setWalletCacheStore, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };