@t2000/engine 0.53.4 → 0.54.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 +97 -7
- package/dist/index.js +173 -21
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -399,11 +399,19 @@ interface DefiSummary {
|
|
|
399
399
|
perProtocol: Partial<Record<DefiProtocol, number>>;
|
|
400
400
|
pricedAt: number;
|
|
401
401
|
/**
|
|
402
|
-
* `blockvision`
|
|
403
|
-
* `partial`
|
|
404
|
-
* `
|
|
402
|
+
* `blockvision` — every protocol in `DEFI_PROTOCOLS` responded successfully.
|
|
403
|
+
* `partial` — at least one protocol failed; total may under-count.
|
|
404
|
+
* `partial-stale` — fresh fetch returned degraded/partial-zero, but we have a
|
|
405
|
+
* positive value cached within the sticky window
|
|
406
|
+
* (`DEFI_STICKY_TTL_SEC`, default 30min). The numbers are
|
|
407
|
+
* real, just not freshly verified — UI should caveat with
|
|
408
|
+
* "last refresh Nm ago" so the user knows the provenance.
|
|
409
|
+
* Introduced in v0.54 to fix cross-instance SSOT divergence
|
|
410
|
+
* when BlockVision is bursting.
|
|
411
|
+
* `degraded` — no API key, or every protocol failed AND no sticky
|
|
412
|
+
* fallback exists; total = 0.
|
|
405
413
|
*/
|
|
406
|
-
source: 'blockvision' | 'partial' | 'degraded';
|
|
414
|
+
source: 'blockvision' | 'partial' | 'partial-stale' | 'degraded';
|
|
407
415
|
}
|
|
408
416
|
declare function fetchAddressDefiPortfolio(address: string, apiKey: string | undefined, priceHints?: Record<string, number>): Promise<DefiSummary>;
|
|
409
417
|
declare function clearPortfolioCache(): void;
|
|
@@ -1993,7 +2001,8 @@ declare const balanceCheckTool: Tool<{
|
|
|
1993
2001
|
gasReserve: number;
|
|
1994
2002
|
defi: number;
|
|
1995
2003
|
defiByProtocol: Partial<Record<"aftermath" | "bluefin" | "cetus" | "haedal" | "scallop" | "suilend" | "suins-staking" | "suistake" | "walrus", number>>;
|
|
1996
|
-
defiSource: "blockvision" | "partial" | "degraded";
|
|
2004
|
+
defiSource: "blockvision" | "partial" | "partial-stale" | "degraded";
|
|
2005
|
+
defiPricedAt: number;
|
|
1997
2006
|
total: number;
|
|
1998
2007
|
stables: number;
|
|
1999
2008
|
holdings: any[];
|
|
@@ -2265,6 +2274,20 @@ interface PortfolioResult {
|
|
|
2265
2274
|
totalValue: number;
|
|
2266
2275
|
walletValue: number;
|
|
2267
2276
|
savingsValue: number;
|
|
2277
|
+
/**
|
|
2278
|
+
* [Bug — 2026-04-28] Aggregated DeFi value across non-NAVI protocols
|
|
2279
|
+
* (Cetus LPs, Bluefin, Suilend, etc.) — same field that's been on
|
|
2280
|
+
* `balance_check` since v0.50. Pre-fix this tool ignored DeFi entirely:
|
|
2281
|
+
* a wallet with $1,569 in Cetus LPs reported a $228 totalValue
|
|
2282
|
+
* (wallet only), under-counting net worth by 87% and prompting the LLM
|
|
2283
|
+
* to misclassify the wallet as "concentrated in FAITH" when actually
|
|
2284
|
+
* the bulk was in liquidity pools. Same SSOT-divergence class the v0.54
|
|
2285
|
+
* cache work fixed for FullPortfolioCanvas, manifesting in a different
|
|
2286
|
+
* tool that was written before DeFi support was bolted on.
|
|
2287
|
+
*/
|
|
2288
|
+
defiValue: number;
|
|
2289
|
+
/** Provenance of the DeFi read — used by the UI card to caveat partial/degraded. */
|
|
2290
|
+
defiSource: DefiSummary['source'];
|
|
2268
2291
|
debtValue: number;
|
|
2269
2292
|
healthFactor: number | null;
|
|
2270
2293
|
allocations: AssetAllocation[];
|
|
@@ -2423,6 +2446,64 @@ interface WalletCoin {
|
|
|
2423
2446
|
*/
|
|
2424
2447
|
declare function fetchWalletCoins(address: string, rpcUrl?: string): Promise<WalletCoin[]>;
|
|
2425
2448
|
|
|
2449
|
+
/** Cache entry stored under each address key. */
|
|
2450
|
+
interface DefiCacheEntry {
|
|
2451
|
+
data: DefiSummary;
|
|
2452
|
+
/** Wall-clock ms when this was written — used by the fetcher to compute freshness. */
|
|
2453
|
+
pricedAt: number;
|
|
2454
|
+
}
|
|
2455
|
+
/**
|
|
2456
|
+
* Pluggable cache backend.
|
|
2457
|
+
*
|
|
2458
|
+
* All methods are async because Redis-backed implementations are
|
|
2459
|
+
* inherently async; the in-memory impl wraps in resolved promises.
|
|
2460
|
+
*
|
|
2461
|
+
* Implementations MUST tolerate transport errors gracefully — `get`
|
|
2462
|
+
* should return `null` (not throw) on backend failure so the fetcher
|
|
2463
|
+
* falls through to a fresh BlockVision read instead of erroring the
|
|
2464
|
+
* whole `balance_check` call. `set` should swallow errors (logging is
|
|
2465
|
+
* fine) so a Redis hiccup doesn't break a successful read.
|
|
2466
|
+
*/
|
|
2467
|
+
interface DefiCacheStore {
|
|
2468
|
+
/** Returns the cached entry, or `null` if not found / expired / backend error. */
|
|
2469
|
+
get(address: string): Promise<DefiCacheEntry | null>;
|
|
2470
|
+
/** Writes an entry with a TTL in seconds. Errors are swallowed (logged). */
|
|
2471
|
+
set(address: string, entry: DefiCacheEntry, ttlSec: number): Promise<void>;
|
|
2472
|
+
/** Removes the entry for an address. Errors are swallowed. */
|
|
2473
|
+
delete(address: string): Promise<void>;
|
|
2474
|
+
/** Removes all entries. Used by tests and `clearDefiCache()`. */
|
|
2475
|
+
clear(): Promise<void>;
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Process-local cache backed by a `Map`. Used as the default when no
|
|
2479
|
+
* other store has been injected via `setDefiCacheStore()`.
|
|
2480
|
+
*
|
|
2481
|
+
* NOT suitable for multi-instance deployments — each Vercel function
|
|
2482
|
+
* instance gets its own Map, which causes the SSOT divergence this
|
|
2483
|
+
* module exists to fix. Audric replaces this at engine init with an
|
|
2484
|
+
* Upstash-backed store; the CLI keeps it.
|
|
2485
|
+
*/
|
|
2486
|
+
declare class InMemoryDefiCacheStore implements DefiCacheStore {
|
|
2487
|
+
private readonly store;
|
|
2488
|
+
get(address: string): Promise<DefiCacheEntry | null>;
|
|
2489
|
+
set(address: string, entry: DefiCacheEntry, ttlSec: number): Promise<void>;
|
|
2490
|
+
delete(address: string): Promise<void>;
|
|
2491
|
+
clear(): Promise<void>;
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* Swap the active DeFi cache store. Call once at engine init from a
|
|
2495
|
+
* runtime that wants a non-default backend (e.g. Audric injecting
|
|
2496
|
+
* `RedisDefiCacheStore`). Idempotent — calling again replaces the
|
|
2497
|
+
* previous store, but does NOT migrate entries; warm cache is lost
|
|
2498
|
+
* on swap. Tests use this to inject a fake/spy store and `resetDefiCacheStore()`
|
|
2499
|
+
* to restore the in-memory default.
|
|
2500
|
+
*/
|
|
2501
|
+
declare function setDefiCacheStore(store: DefiCacheStore): void;
|
|
2502
|
+
/** Returns the currently active store. Used by `fetchAddressDefiPortfolio`. */
|
|
2503
|
+
declare function getDefiCacheStore(): DefiCacheStore;
|
|
2504
|
+
/** Restore the default in-memory store. Used by test teardowns. */
|
|
2505
|
+
declare function resetDefiCacheStore(): void;
|
|
2506
|
+
|
|
2426
2507
|
/**
|
|
2427
2508
|
* Resolve the audric API base URL from the engine's env shim, falling
|
|
2428
2509
|
* back to `process.env`. Returns `null` when no override is configured —
|
|
@@ -2441,12 +2522,21 @@ interface AudricPortfolioResult {
|
|
|
2441
2522
|
portfolio: AddressPortfolio;
|
|
2442
2523
|
/** NAVI lending positions, normalized to the engine's `ServerPositionData`. */
|
|
2443
2524
|
positions: ServerPositionData;
|
|
2444
|
-
/** Net worth derived audric-side (`wallet + savings - borrows`). */
|
|
2525
|
+
/** Net worth derived audric-side (`wallet + savings + defi - borrows`). */
|
|
2445
2526
|
netWorthUsd: number;
|
|
2446
2527
|
/** `savings * savingsRate / 365`, capped at 0. */
|
|
2447
2528
|
estimatedDailyYield: number;
|
|
2448
2529
|
/** Per-symbol balance map — convenient for adapters that already used `WalletBalances`. */
|
|
2449
2530
|
walletAllocations: Record<string, number>;
|
|
2531
|
+
/**
|
|
2532
|
+
* [Bug — 2026-04-28] Aggregated DeFi value (Cetus LPs, Bluefin, Suilend,
|
|
2533
|
+
* etc.) when available. `defiSource === 'degraded'` when audric's wire
|
|
2534
|
+
* didn't include the field — callers should treat that as "fall back to
|
|
2535
|
+
* a direct fetchAddressDefiPortfolio call" (same convention used
|
|
2536
|
+
* inside the audric web app's UI components).
|
|
2537
|
+
*/
|
|
2538
|
+
defiValueUsd: number;
|
|
2539
|
+
defiSource: DefiSummary['source'];
|
|
2450
2540
|
}
|
|
2451
2541
|
/**
|
|
2452
2542
|
* Fetch the canonical portfolio snapshot from audric. Returns `null` if
|
|
@@ -2483,4 +2573,4 @@ declare function fetchAudricHistory(address: string, opts: {
|
|
|
2483
2573
|
|
|
2484
2574
|
declare const DEFAULT_SYSTEM_PROMPT = "You are Audric \u2014 a financial agent on Sui. Audric is exactly five products: Audric Passport (the trust layer \u2014 Google sign-in, non-custodial wallet, tap-to-confirm consent, sponsored gas \u2014 wraps every other product), Audric Intelligence (you \u2014 the 5-system brain: Agent Harness with 34 tools, Reasoning Engine with 9 guards and 7 skill recipes, Silent Profile, Chain Memory, AdviceLog), Audric Finance (manage money on Sui \u2014 Save via NAVI lending at 3-8% APY USDC, Credit via NAVI borrowing with health factor, Swap via Cetus aggregator across 20+ DEXs at 0.1% fee, Charts for yield/health/portfolio viz), Audric Pay (move money \u2014 send USDC, receive via payment links / invoices / QR; free, global, instant on Sui), and Audric Store (creator marketplace, ships Phase 5 \u2014 say \"coming soon\" if asked). Save, swap, borrow, repay, withdraw, charts \u2192 Audric Finance. Send, receive, payment-link, invoice, QR \u2192 Audric Pay. Your silent context (profile, memory, chain facts, advice log) shapes your replies but never surfaces as a notification \u2014 you act only when the user asks, and every write waits on their tap-to-confirm via Passport. You can also call 41 paid APIs (music, image, research, translation, weather, fulfilment) via MPP micropayments using the pay_api tool \u2014 this is an internal capability, not a promoted product, so only mention it when the user asks for something that needs it.\n\n## Response rules\n- 1-2 sentences max. No bullet lists unless asked. No preambles.\n- Never say \"Would you like me to...\", \"Sure!\", \"Great question!\", \"Absolutely!\" \u2014 just do it or say you can't.\n- Present amounts as $1,234.56 and rates as X.XX% APY.\n- Show top 3 results unless asked for more. Summarize totals in one line.\n\n## Caption rules (after tool calls)\n- **When a canvas was rendered (`render_canvas` was called, or any tool that auto-renders a card like balance_check / portfolio_analysis / savings_info / health_check / transaction_history): the canvas IS the answer.** Your chat message must NOT restate wallet, savings, debt, holdings, or net-worth numbers \u2014 they are already on screen. Add at most ONE sentence of context, advice, or next step (e.g. \"Your USDC is idle \u2014 consider depositing for ~4.5% APY\"), or say nothing.\n- **When NO canvas was rendered:** lead with the result and quote the actual numbers from the tool. One sentence.\n- **NEVER describe a position as \"no\", \"none\", \"minimal\", \"zero\", or \"inactive\" if the tool result contains a positive value for that field.** The tool result is the source of truth \u2014 never your interior summary. If the canvas shows $100 in savings, you cannot say \"no active savings\" in the caption.\n- **NEVER claim \"no DeFi positions\" when the tool result says the DeFi slice is UNAVAILABLE.** When `balance_check` displayText contains \"DeFi positions: UNAVAILABLE\" or \"DeFi data source unreachable\", the slice is unknown \u2014 say \"DeFi data is currently unavailable\" or omit the mention. Only claim \"no DeFi positions\" when the displayText explicitly omits any DeFi line (i.e. the fetch succeeded with $0 across every covered protocol).\n\n## Execution rule\nOnly offer to execute actions you have tools for. If you retrieved a quote, data, or information but have no tool to act on it, give the user the result and tell them where to execute manually \u2014 in one sentence. Never say \"Would you like me to proceed?\" unless you have a tool that can actually proceed.\n\n## Before acting\n- ALWAYS call a read tool first before any write tool \u2014 balance_check before save/send/borrow, savings_info before withdraw.\n- Show real numbers from tools \u2014 never fabricate rates, amounts, or balances.\n- When user says \"all\" or an imprecise amount, call the read tool first to get the exact number.\n\n## Tool usage\n- Use tools proactively \u2014 don't refuse requests you can handle.\n- For real-world questions (weather, search, news, prices), use pay_api. Tell the user the cost first.\n- For NAVI lending APYs, use rates_info; for VOLO liquid staking stats, use volo_stats; for spot token prices, use token_prices.\n- For protocol-level due diligence (TVL, fees, audits, safety) on Sui DeFi protocols, use protocol_deep_dive with the slug.\n- Run multiple read-only tools in parallel when you need several data points.\n- If a tool errors, say what went wrong and what to try instead. One sentence.\n\n## Savings = USDC or USDsui (critical)\n- save_deposit and borrow accept ONLY USDC or USDsui. No other token can be deposited or borrowed.\n- USDC is the canonical default. USDsui is permitted because it has a productive NAVI pool (often a higher APY than USDC). All other holdings (GOLD, SUI, USDT, USDe, ETH, NAVX, WAL) are NOT saveable.\n- When asked \"how much can I save?\":\n - Report saveableUsdc from balance_check (the user's USDC wallet balance \u2014 canonical saveable).\n - If the user also holds USDsui in their wallet, report that separately as \"USDsui (saveable): X.XX\". Do NOT roll the two together \u2014 the LLM must keep the per-asset distinction so the user can pick.\n- When the user says \"save 10 USDC\" \u2192 call save_deposit with asset=\"USDC\". When they say \"save 10 USDsui\" \u2192 call with asset=\"USDsui\". Never silently substitute.\n- When the user says \"save 10\" (no asset) \u2192 call balance_check first and ask which stable they want, OR pick whichever they hold more of with a one-line explanation.\n- \"Best stable to save right now?\" \u2192 call rates_info to compare USDC vs USDsui APY on NAVI; let the user pick.\n- NEVER say a non-saveable token (GOLD, SUI, USDT, etc.) is \"in savings\" or \"earning APY in savings\". Wallet holdings \u2260 savings positions, even for stables we don't accept.\n- If user wants to save a non-saveable token, tell them to swap to USDC or USDsui first. Do NOT auto-chain swap + deposit.\n- Repay symmetry: a USDsui debt MUST be repaid with USDsui (and USDC debt with USDC). When calling repay_debt, pass asset=\"USDsui\" if the borrow is USDsui. If the user asks \"repay my debt\" and savings_info shows borrows in BOTH stables, list both and ask which to repay first. If the user holds the wrong stable, tell them to swap manually \u2014 do NOT auto-chain swap + repay.\n\n## Multi-step flows\n- \"How much X for Y?\": swap_quote first, then swap_execute if user confirms.\n- \"Swap then save\": swap_execute \u2192 balance_check \u2192 save_deposit. Confirm each step.\n- \"Buy $X of token\": token_prices \u2192 calculate amount \u2192 swap_execute.\n- \"Best yield on SUI\": compare rates_info (NAVI lending) + volo_stats (vSUI liquid staking).\n- withdraw supports legacy positions: USDC, USDe, USDsui, SUI. Pass asset param to withdraw a specific token.\n- \"Deposit SUI to earn yield\": volo_stake for SUI liquid staking. save_deposit only accepts USDC or USDsui.\n- \"Is protocol X safe?\" / \"Tell me about NAVI\": protocol_deep_dive with the slug.\n- \"Full account report\" / \"account summary\" / \"give me everything\" / \"complete overview\": triggers the `account_report` recipe \u2014 when the recipe block appears, follow EVERY step including all six tool calls. Each step renders a distinct rich card; skipping a step means a missing card.\n\n## Safety\n- Never encourage risky financial behavior.\n- Warn when health factor < 1.5.\n- All amounts in USDC unless stated otherwise.";
|
|
2485
2575
|
|
|
2486
|
-
export { type AddressPortfolio, AnthropicProvider, type AnthropicProviderConfig, type AudricHistoryRecord, type AudricPortfolioResult, 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_PERMISSION_CONFIG, DEFAULT_SYSTEM_PROMPT, type DefiProtocol, type DefiSummary, EarlyToolDispatcher, type EngineConfig, type EngineEvent, type GuardCheckResult, type GuardConfig, type GuardEvent, type GuardInjection, type GuardResult, type GuardRunnerState, type GuardTier, type GuardVerdict, type HealthFactorResult, type LLMProvider, type McpCallResult, McpClientManager, McpResponseCache, type McpServerConfig, type McpServerConnection, type McpToolAdapterConfig, type McpToolDescriptor, MemorySessionStore, type Message, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_SERVER_NAME, 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 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 WalletCoin, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, 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, getMcpManager, getModifiableFields, getToolFlags, getWalletAddress, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, microcompact, mppServicesTool, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resolvePermissionTier, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
2576
|
+
export { type AddressPortfolio, AnthropicProvider, type AnthropicProviderConfig, type AudricHistoryRecord, type AudricPortfolioResult, 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_PERMISSION_CONFIG, DEFAULT_SYSTEM_PROMPT, type DefiCacheEntry, type DefiCacheStore, type DefiProtocol, type DefiSummary, EarlyToolDispatcher, type EngineConfig, type EngineEvent, type GuardCheckResult, type GuardConfig, type GuardEvent, type GuardInjection, type GuardResult, type GuardRunnerState, type GuardTier, type GuardVerdict, type HealthFactorResult, InMemoryDefiCacheStore, type LLMProvider, type McpCallResult, McpClientManager, McpResponseCache, type McpServerConfig, type McpServerConnection, type McpToolAdapterConfig, type McpToolDescriptor, MemorySessionStore, type Message, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_SERVER_NAME, 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 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 WalletCoin, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, 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, getMcpManager, getModifiableFields, getToolFlags, getWalletAddress, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, microcompact, mppServicesTool, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resolvePermissionTier, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, setDefiCacheStore, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
package/dist/index.js
CHANGED
|
@@ -496,6 +496,42 @@ async function fetchWalletCoins(address, rpcUrl) {
|
|
|
496
496
|
});
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
+
// src/defi-cache.ts
|
|
500
|
+
var InMemoryDefiCacheStore = class {
|
|
501
|
+
store = /* @__PURE__ */ new Map();
|
|
502
|
+
async get(address) {
|
|
503
|
+
const slot = this.store.get(address.toLowerCase());
|
|
504
|
+
if (!slot) return null;
|
|
505
|
+
if (Date.now() >= slot.expiresAt) {
|
|
506
|
+
this.store.delete(address.toLowerCase());
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
return slot.entry;
|
|
510
|
+
}
|
|
511
|
+
async set(address, entry, ttlSec) {
|
|
512
|
+
this.store.set(address.toLowerCase(), {
|
|
513
|
+
entry,
|
|
514
|
+
expiresAt: Date.now() + ttlSec * 1e3
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
async delete(address) {
|
|
518
|
+
this.store.delete(address.toLowerCase());
|
|
519
|
+
}
|
|
520
|
+
async clear() {
|
|
521
|
+
this.store.clear();
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
var activeStore = new InMemoryDefiCacheStore();
|
|
525
|
+
function setDefiCacheStore(store) {
|
|
526
|
+
activeStore = store;
|
|
527
|
+
}
|
|
528
|
+
function getDefiCacheStore() {
|
|
529
|
+
return activeStore;
|
|
530
|
+
}
|
|
531
|
+
function resetDefiCacheStore() {
|
|
532
|
+
activeStore = new InMemoryDefiCacheStore();
|
|
533
|
+
}
|
|
534
|
+
|
|
499
535
|
// src/blockvision-prices.ts
|
|
500
536
|
var BLOCKVISION_BASE = "https://api.blockvision.org/v2/sui";
|
|
501
537
|
var PORTFOLIO_TIMEOUT_MS = 4e3;
|
|
@@ -723,8 +759,10 @@ function parseNumberOrNull(input) {
|
|
|
723
759
|
return Number.isFinite(n) ? n : null;
|
|
724
760
|
}
|
|
725
761
|
var DEFI_PORTFOLIO_TIMEOUT_MS = 4e3;
|
|
726
|
-
var
|
|
727
|
-
var
|
|
762
|
+
var DEFI_FRESH_TTL_MS_BLOCKVISION = 6e4;
|
|
763
|
+
var DEFI_FRESH_TTL_MS_PARTIAL = 15e3;
|
|
764
|
+
var DEFI_FRESH_TTL_MS_PARTIAL_STALE = 0;
|
|
765
|
+
var DEFI_STICKY_TTL_SEC = 30 * 60;
|
|
728
766
|
var DEFI_PROTOCOLS = [
|
|
729
767
|
"aftermath",
|
|
730
768
|
"bluefin",
|
|
@@ -741,8 +779,26 @@ var USDC_TYPE_FULL = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846
|
|
|
741
779
|
var BLUE_TYPE_FULL = "0xe1b45a0e641b9955a20aa0ad1c1f4ad86aad8afb07296d4085e349a50e90bdca::blue::BLUE";
|
|
742
780
|
var WAL_TYPE_FULL = "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL";
|
|
743
781
|
var NS_TYPE_FULL = "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS";
|
|
744
|
-
var defiCache = /* @__PURE__ */ new Map();
|
|
745
782
|
var defiInflight = /* @__PURE__ */ new Map();
|
|
783
|
+
function freshTtlForSource(source) {
|
|
784
|
+
switch (source) {
|
|
785
|
+
case "blockvision":
|
|
786
|
+
return DEFI_FRESH_TTL_MS_BLOCKVISION;
|
|
787
|
+
case "partial":
|
|
788
|
+
return DEFI_FRESH_TTL_MS_PARTIAL;
|
|
789
|
+
case "partial-stale":
|
|
790
|
+
return DEFI_FRESH_TTL_MS_PARTIAL_STALE;
|
|
791
|
+
case "degraded":
|
|
792
|
+
return 0;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
async function safeStoreSet(store, address, entry) {
|
|
796
|
+
try {
|
|
797
|
+
await store.set(address, entry, DEFI_STICKY_TTL_SEC);
|
|
798
|
+
} catch (err) {
|
|
799
|
+
console.warn("[defi] cache set failed (non-fatal):", err);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
746
802
|
var warnedMissingApiKey = false;
|
|
747
803
|
async function fetchAddressDefiPortfolio(address, apiKey, priceHints = {}) {
|
|
748
804
|
if (!apiKey || apiKey.trim().length === 0) {
|
|
@@ -754,9 +810,21 @@ async function fetchAddressDefiPortfolio(address, apiKey, priceHints = {}) {
|
|
|
754
810
|
}
|
|
755
811
|
return { totalUsd: 0, perProtocol: {}, pricedAt: Date.now(), source: "degraded" };
|
|
756
812
|
}
|
|
813
|
+
const store = getDefiCacheStore();
|
|
757
814
|
const now = Date.now();
|
|
758
|
-
|
|
759
|
-
|
|
815
|
+
let cachedEntry = null;
|
|
816
|
+
try {
|
|
817
|
+
cachedEntry = await store.get(address);
|
|
818
|
+
} catch (err) {
|
|
819
|
+
console.warn("[defi] cache get failed (continuing as cache miss):", err);
|
|
820
|
+
}
|
|
821
|
+
if (cachedEntry) {
|
|
822
|
+
const ageMs = now - cachedEntry.pricedAt;
|
|
823
|
+
const freshTtlMs = freshTtlForSource(cachedEntry.data.source);
|
|
824
|
+
if (ageMs < freshTtlMs) {
|
|
825
|
+
return cachedEntry.data;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
760
828
|
let inflight = defiInflight.get(address);
|
|
761
829
|
if (inflight) return inflight;
|
|
762
830
|
inflight = (async () => {
|
|
@@ -813,21 +881,28 @@ async function fetchAddressDefiPortfolio(address, apiKey, priceHints = {}) {
|
|
|
813
881
|
}
|
|
814
882
|
}
|
|
815
883
|
if (totalUsd < 0) totalUsd = 0;
|
|
884
|
+
const fetchedAt = Date.now();
|
|
816
885
|
const summary = {
|
|
817
886
|
totalUsd,
|
|
818
887
|
perProtocol,
|
|
819
|
-
pricedAt:
|
|
888
|
+
pricedAt: fetchedAt,
|
|
820
889
|
source: failures === DEFI_PROTOCOLS.length ? "degraded" : failures > 0 ? "partial" : "blockvision"
|
|
821
890
|
};
|
|
891
|
+
const cachedPositive = cachedEntry && cachedEntry.data.totalUsd > 0 && now - cachedEntry.pricedAt < DEFI_STICKY_TTL_SEC * 1e3;
|
|
822
892
|
if (summary.source === "blockvision") {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
893
|
+
await safeStoreSet(store, address, { data: summary, pricedAt: fetchedAt });
|
|
894
|
+
return summary;
|
|
895
|
+
}
|
|
896
|
+
if (summary.source === "partial" && summary.totalUsd > 0) {
|
|
897
|
+
await safeStoreSet(store, address, { data: summary, pricedAt: fetchedAt });
|
|
898
|
+
return summary;
|
|
899
|
+
}
|
|
900
|
+
if (cachedPositive) {
|
|
901
|
+
const stale = {
|
|
902
|
+
...cachedEntry.data,
|
|
903
|
+
source: "partial-stale"
|
|
904
|
+
};
|
|
905
|
+
return stale;
|
|
831
906
|
}
|
|
832
907
|
return summary;
|
|
833
908
|
} finally {
|
|
@@ -1168,7 +1243,14 @@ async function fetchAudricPortfolio(address, env, signal) {
|
|
|
1168
1243
|
positions,
|
|
1169
1244
|
netWorthUsd: json.netWorthUsd ?? portfolio.totalUsd + positions.savings - positions.borrows,
|
|
1170
1245
|
estimatedDailyYield: json.estimatedDailyYield ?? 0,
|
|
1171
|
-
walletAllocations: json.walletAllocations ?? {}
|
|
1246
|
+
walletAllocations: json.walletAllocations ?? {},
|
|
1247
|
+
// Default to 'degraded' (not 'partial') when the wire shape lacks
|
|
1248
|
+
// DeFi: 'partial' implies "we tried and got partial data" which is
|
|
1249
|
+
// misleading for a route that simply doesn't return the field.
|
|
1250
|
+
// Callers that need DeFi must fall back to a direct fetch on
|
|
1251
|
+
// 'degraded' — exactly the convention BalanceCard already uses.
|
|
1252
|
+
defiValueUsd: typeof json.defiValueUsd === "number" ? json.defiValueUsd : 0,
|
|
1253
|
+
defiSource: json.defiSource ?? "degraded"
|
|
1172
1254
|
};
|
|
1173
1255
|
} catch (err) {
|
|
1174
1256
|
console.warn(`[audric-api] portfolio ${address.slice(0, 10)} fetch failed:`, err);
|
|
@@ -1405,6 +1487,10 @@ var balanceCheckTool = buildTool({
|
|
|
1405
1487
|
defi: defi2.totalUsd,
|
|
1406
1488
|
defiByProtocol: defi2.perProtocol,
|
|
1407
1489
|
defiSource: defi2.source,
|
|
1490
|
+
// [v0.54] Forward the DeFi entry's pricedAt so the BalanceCard
|
|
1491
|
+
// can render "cached Nm ago" when source === 'partial-stale'.
|
|
1492
|
+
// Always populated; consumers ignore unless source is stale.
|
|
1493
|
+
defiPricedAt: defi2.pricedAt,
|
|
1408
1494
|
total: availableUsd + savings + gasReserveUsd2 + pendingRewardsUsd + defi2.totalUsd - debt,
|
|
1409
1495
|
stables: stablesUsd,
|
|
1410
1496
|
holdings: visibleHoldings,
|
|
@@ -1420,6 +1506,10 @@ var balanceCheckTool = buildTool({
|
|
|
1420
1506
|
if (defi2.source === "degraded") {
|
|
1421
1507
|
return ' DeFi positions (Bluefin / Suilend / Cetus / etc.): UNAVAILABLE \u2014 DeFi data source is currently unreachable. Do NOT assert "no DeFi positions"; tell the user this slice is temporarily unknown and the total above EXCLUDES DeFi.';
|
|
1422
1508
|
}
|
|
1509
|
+
if (defi2.source === "partial-stale" && defi2.totalUsd > 0) {
|
|
1510
|
+
const ageMin = Math.round((Date.now() - defi2.pricedAt) / 6e4);
|
|
1511
|
+
return ` Other DeFi positions (LPs/staking/lending across ${Object.keys(defi2.perProtocol).join("/")}): $${defi2.totalUsd.toFixed(2)} (last refresh ${ageMin}m ago \u2014 live BlockVision call failed, using cached value).`;
|
|
1512
|
+
}
|
|
1423
1513
|
if (defi2.totalUsd > 0) {
|
|
1424
1514
|
const partialNote = defi2.source === "partial" ? " (partial \u2014 one or more protocols failed; value may under-count)" : "";
|
|
1425
1515
|
return ` Other DeFi positions (LPs/staking/lending across ${Object.keys(defi2.perProtocol).join("/")}): $${defi2.totalUsd.toFixed(2)}${partialNote}.`;
|
|
@@ -1467,6 +1557,10 @@ var balanceCheckTool = buildTool({
|
|
|
1467
1557
|
if (defi.source === "degraded") {
|
|
1468
1558
|
return ' DeFi positions: UNAVAILABLE \u2014 data source unreachable. Do NOT claim "no DeFi positions"; report this slice as temporarily unknown and the total above EXCLUDES DeFi.';
|
|
1469
1559
|
}
|
|
1560
|
+
if (defi.source === "partial-stale" && defi.totalUsd > 0) {
|
|
1561
|
+
const ageMin = Math.round((Date.now() - defi.pricedAt) / 6e4);
|
|
1562
|
+
return ` Other DeFi positions (LPs/staking/lending across ${Object.keys(defi.perProtocol).join("/")}): $${defi.totalUsd.toFixed(2)} (last refresh ${ageMin}m ago \u2014 live BlockVision call failed, using cached value).`;
|
|
1563
|
+
}
|
|
1470
1564
|
if (defi.totalUsd > 0) {
|
|
1471
1565
|
const partialNote = defi.source === "partial" ? " (partial \u2014 one or more protocols failed; value may under-count)" : "";
|
|
1472
1566
|
return ` Other DeFi positions (LPs/staking/lending across ${Object.keys(defi.perProtocol).join("/")}): $${defi.totalUsd.toFixed(2)}${partialNote}.`;
|
|
@@ -1487,6 +1581,8 @@ var balanceCheckTool = buildTool({
|
|
|
1487
1581
|
defi: defi.totalUsd,
|
|
1488
1582
|
defiByProtocol: defi.perProtocol,
|
|
1489
1583
|
defiSource: defi.source,
|
|
1584
|
+
// [v0.54] Same staleness provenance as the MCP path above.
|
|
1585
|
+
defiPricedAt: defi.pricedAt,
|
|
1490
1586
|
total: sdkTotal,
|
|
1491
1587
|
stables: stablesTotal,
|
|
1492
1588
|
holdings: holdingsArr,
|
|
@@ -1843,10 +1939,25 @@ var STABLECOIN_SYMBOLS2 = /* @__PURE__ */ new Set([
|
|
|
1843
1939
|
function isStable(symbol) {
|
|
1844
1940
|
return STABLECOIN_SYMBOLS2.has(symbol.toLowerCase());
|
|
1845
1941
|
}
|
|
1942
|
+
var TOKEN_ALIASES = {
|
|
1943
|
+
usdt: ["usdt", "wusdt", "suiusdt"],
|
|
1944
|
+
usdc: ["usdc", "wusdc"],
|
|
1945
|
+
usde: ["usde", "suiusde", "sui_usde"],
|
|
1946
|
+
usdsui: ["usdsui"]
|
|
1947
|
+
};
|
|
1948
|
+
function expandAliases(symbols) {
|
|
1949
|
+
const out = /* @__PURE__ */ new Set();
|
|
1950
|
+
for (const s of symbols) {
|
|
1951
|
+
const norm = s.toLowerCase();
|
|
1952
|
+
const aliases = TOKEN_ALIASES[norm] ?? [norm];
|
|
1953
|
+
for (const a of aliases) out.add(a);
|
|
1954
|
+
}
|
|
1955
|
+
return out;
|
|
1956
|
+
}
|
|
1846
1957
|
function applyFilters(rates, opts) {
|
|
1847
1958
|
let entries = Object.entries(rates);
|
|
1848
1959
|
if (opts.assets && opts.assets.length) {
|
|
1849
|
-
const wanted =
|
|
1960
|
+
const wanted = expandAliases(opts.assets);
|
|
1850
1961
|
entries = entries.filter(([sym]) => wanted.has(sym.toLowerCase()));
|
|
1851
1962
|
} else if (opts.stableOnly) {
|
|
1852
1963
|
entries = entries.filter(([sym]) => isStable(sym));
|
|
@@ -3188,7 +3299,7 @@ var portfolioAnalysisTool = buildTool({
|
|
|
3188
3299
|
context.signal
|
|
3189
3300
|
);
|
|
3190
3301
|
const apiUrl = context.env?.AUDRIC_INTERNAL_API_URL;
|
|
3191
|
-
const [portfolio, positions, weekHistResult] = await Promise.all([
|
|
3302
|
+
const [portfolio, positions, weekHistResult, defiSummary] = await Promise.all([
|
|
3192
3303
|
audricSnapshot ? Promise.resolve(audricSnapshot.portfolio) : (async () => {
|
|
3193
3304
|
if (context.portfolioCache) {
|
|
3194
3305
|
const hit = context.portfolioCache.get(address);
|
|
@@ -3217,7 +3328,23 @@ var portfolioAnalysisTool = buildTool({
|
|
|
3217
3328
|
apiUrl ? fetch(
|
|
3218
3329
|
`${apiUrl}/api/analytics/portfolio-history?days=7`,
|
|
3219
3330
|
{ headers: { "x-sui-address": address }, signal: context.signal }
|
|
3220
|
-
).then((res) => res.ok ? res.json() : null).catch(() => null) : Promise.resolve(null)
|
|
3331
|
+
).then((res) => res.ok ? res.json() : null).catch(() => null) : Promise.resolve(null),
|
|
3332
|
+
// DeFi fetch — prefer the audric snapshot's already-computed value
|
|
3333
|
+
// (when present and not 'degraded'), otherwise call the engine's
|
|
3334
|
+
// direct aggregator. The 'degraded' check prevents the audric
|
|
3335
|
+
// path from masking a useful direct read when the audric route's
|
|
3336
|
+
// own DeFi field came back empty.
|
|
3337
|
+
audricSnapshot && audricSnapshot.defiSource !== "degraded" ? Promise.resolve({
|
|
3338
|
+
totalUsd: audricSnapshot.defiValueUsd,
|
|
3339
|
+
perProtocol: {},
|
|
3340
|
+
pricedAt: Date.now(),
|
|
3341
|
+
source: audricSnapshot.defiSource
|
|
3342
|
+
}) : fetchAddressDefiPortfolio(address, context.blockvisionApiKey).catch(
|
|
3343
|
+
(err) => {
|
|
3344
|
+
console.warn("[portfolio_analysis] defi fetch failed:", err);
|
|
3345
|
+
return { totalUsd: 0, perProtocol: {}, pricedAt: Date.now(), source: "degraded" };
|
|
3346
|
+
}
|
|
3347
|
+
)
|
|
3221
3348
|
]);
|
|
3222
3349
|
let walletValue = 0;
|
|
3223
3350
|
const allAllocations = [];
|
|
@@ -3247,7 +3374,18 @@ var portfolioAnalysisTool = buildTool({
|
|
|
3247
3374
|
if (weekHistResult?.change && weekHistResult.change.absoluteUsd !== 0) {
|
|
3248
3375
|
weekChange = weekHistResult.change;
|
|
3249
3376
|
}
|
|
3250
|
-
const
|
|
3377
|
+
const defiValue = defiSummary.totalUsd;
|
|
3378
|
+
if (defiSummary.source !== "degraded") {
|
|
3379
|
+
for (const [protocol, usdValue] of Object.entries(defiSummary.perProtocol)) {
|
|
3380
|
+
if (typeof usdValue === "number" && usdValue >= DUST_USD) {
|
|
3381
|
+
const label = protocol.charAt(0).toUpperCase() + protocol.slice(1) + " DeFi";
|
|
3382
|
+
allocations.push({ symbol: label, amount: 0, usdValue, percentage: 0 });
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
} else if (defiValue > 0) {
|
|
3386
|
+
allocations.push({ symbol: "DeFi (aggregate)", amount: 0, usdValue: defiValue, percentage: 0 });
|
|
3387
|
+
}
|
|
3388
|
+
const totalValue = walletValue + savingsValue + defiValue;
|
|
3251
3389
|
for (const a of allocations) {
|
|
3252
3390
|
a.percentage = totalValue > 0 ? a.usdValue / totalValue * 100 : 0;
|
|
3253
3391
|
}
|
|
@@ -3285,10 +3423,23 @@ var portfolioAnalysisTool = buildTool({
|
|
|
3285
3423
|
message: "Portfolio is concentrated in a single asset."
|
|
3286
3424
|
});
|
|
3287
3425
|
}
|
|
3426
|
+
if (defiSummary.source === "degraded") {
|
|
3427
|
+
insights.push({
|
|
3428
|
+
type: "warning",
|
|
3429
|
+
message: "DeFi positions could not be loaded \u2014 total may under-count any Cetus/Bluefin/Suilend value."
|
|
3430
|
+
});
|
|
3431
|
+
} else if (defiSummary.source === "partial") {
|
|
3432
|
+
insights.push({
|
|
3433
|
+
type: "warning",
|
|
3434
|
+
message: "DeFi data is partial \u2014 at least one protocol failed; total may under-count."
|
|
3435
|
+
});
|
|
3436
|
+
}
|
|
3288
3437
|
const result = {
|
|
3289
3438
|
totalValue,
|
|
3290
3439
|
walletValue,
|
|
3291
3440
|
savingsValue,
|
|
3441
|
+
defiValue,
|
|
3442
|
+
defiSource: defiSummary.source,
|
|
3292
3443
|
debtValue,
|
|
3293
3444
|
healthFactor,
|
|
3294
3445
|
allocations: allocations.slice(0, 10),
|
|
@@ -3299,7 +3450,8 @@ var portfolioAnalysisTool = buildTool({
|
|
|
3299
3450
|
weekChange,
|
|
3300
3451
|
priceSource: portfolio.source
|
|
3301
3452
|
};
|
|
3302
|
-
const
|
|
3453
|
+
const defiSegment = defiValue > 0 ? ` | DeFi: $${defiValue.toFixed(2)}${defiSummary.source === "partial" ? " (partial)" : ""}` : "";
|
|
3454
|
+
const topLine = `Total: $${totalValue.toFixed(2)} | Wallet: $${walletValue.toFixed(2)} | Savings: $${savingsValue.toFixed(2)}${defiSegment}`;
|
|
3303
3455
|
const insightLines = insights.map((i) => `${i.type === "warning" ? "\u26A0" : "\u2192"} ${i.message}`).join("\n");
|
|
3304
3456
|
return {
|
|
3305
3457
|
data: result,
|
|
@@ -7600,6 +7752,6 @@ function sanitizeAnthropicMessages(messages) {
|
|
|
7600
7752
|
return merged;
|
|
7601
7753
|
}
|
|
7602
7754
|
|
|
7603
|
-
export { AnthropicProvider, BalanceTracker, CANVAS_TEMPLATES, ContextBudget, CostTracker, DEFAULT_GUARD_CONFIG, DEFAULT_PERMISSION_CONFIG, DEFAULT_SYSTEM_PROMPT, EarlyToolDispatcher, McpClientManager, McpResponseCache, MemorySessionStore, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_SERVER_NAME, NaviTools, PERMISSION_PRESETS, QueryEngine, READ_TOOLS, RecipeRegistry, RetryTracker, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, TxMutex, WRITE_TOOLS, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, 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, getMcpManager, getModifiableFields, getToolFlags, getWalletAddress, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, microcompact, mppServicesTool, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resolvePermissionTier, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
7755
|
+
export { AnthropicProvider, BalanceTracker, CANVAS_TEMPLATES, ContextBudget, CostTracker, DEFAULT_GUARD_CONFIG, DEFAULT_PERMISSION_CONFIG, DEFAULT_SYSTEM_PROMPT, EarlyToolDispatcher, InMemoryDefiCacheStore, McpClientManager, McpResponseCache, MemorySessionStore, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_SERVER_NAME, NaviTools, PERMISSION_PRESETS, QueryEngine, READ_TOOLS, RecipeRegistry, RetryTracker, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, TxMutex, WRITE_TOOLS, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, 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, getMcpManager, getModifiableFields, getToolFlags, getWalletAddress, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, microcompact, mppServicesTool, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resolvePermissionTier, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, setDefiCacheStore, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
7604
7756
|
//# sourceMappingURL=index.js.map
|
|
7605
7757
|
//# sourceMappingURL=index.js.map
|