@t2000/engine 1.4.0 → 1.5.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 +112 -5
- package/dist/index.js +107 -38
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -393,7 +393,11 @@ interface AddressPortfolio {
|
|
|
393
393
|
* overwrite — preserves the original `pricedAt` so a UI can
|
|
394
394
|
* render "last refresh Nm ago".
|
|
395
395
|
*/
|
|
396
|
-
declare function fetchAddressPortfolio(address: string, apiKey: string | undefined, fallbackRpcUrl?: string
|
|
396
|
+
declare function fetchAddressPortfolio(address: string, apiKey: string | undefined, fallbackRpcUrl?: string, opts?: {
|
|
397
|
+
retryStats?: {
|
|
398
|
+
attemptCount: number;
|
|
399
|
+
};
|
|
400
|
+
}): Promise<AddressPortfolio>;
|
|
397
401
|
/**
|
|
398
402
|
* Multi-token price lookup. Returns a map of coinType → `{ price, change24h }`
|
|
399
403
|
* with the `change24h` field populated when BlockVision returns it.
|
|
@@ -404,7 +408,11 @@ declare function fetchAddressPortfolio(address: string, apiKey: string | undefin
|
|
|
404
408
|
* requested coins fetches only the missing 2 instead of throwing the
|
|
405
409
|
* whole map away.
|
|
406
410
|
*/
|
|
407
|
-
declare function fetchTokenPrices(coinTypes: string[], apiKey: string | undefined
|
|
411
|
+
declare function fetchTokenPrices(coinTypes: string[], apiKey: string | undefined, opts?: {
|
|
412
|
+
retryStats?: {
|
|
413
|
+
attemptCount: number;
|
|
414
|
+
};
|
|
415
|
+
}): Promise<Record<string, {
|
|
408
416
|
price: number;
|
|
409
417
|
change24h?: number;
|
|
410
418
|
}>>;
|
|
@@ -431,7 +439,11 @@ interface DefiSummary {
|
|
|
431
439
|
*/
|
|
432
440
|
source: 'blockvision' | 'partial' | 'partial-stale' | 'degraded';
|
|
433
441
|
}
|
|
434
|
-
declare function fetchAddressDefiPortfolio(address: string, apiKey: string | undefined, priceHints?: Record<string, number
|
|
442
|
+
declare function fetchAddressDefiPortfolio(address: string, apiKey: string | undefined, priceHints?: Record<string, number>, opts?: {
|
|
443
|
+
retryStats?: {
|
|
444
|
+
attemptCount: number;
|
|
445
|
+
};
|
|
446
|
+
}): Promise<DefiSummary>;
|
|
435
447
|
/**
|
|
436
448
|
* Wipe the wallet portfolio cache plus any in-flight promises.
|
|
437
449
|
*
|
|
@@ -701,6 +713,22 @@ type EngineEvent =
|
|
|
701
713
|
* UI affordances (e.g. a subtle "auto-refreshed" badge).
|
|
702
714
|
*/
|
|
703
715
|
wasPostWriteRefresh?: boolean;
|
|
716
|
+
/**
|
|
717
|
+
* [SPEC 8 v0.5.1 B3.2] Number of HTTP attempts the tool made before
|
|
718
|
+
* succeeding (or returning the final result). Surfaced when the tool
|
|
719
|
+
* went through one or more retries inside its retry wrapper
|
|
720
|
+
* (`fetchBlockVisionWithRetry` and equivalents). Set ONLY when N > 1
|
|
721
|
+
* — a successful first try leaves the field undefined to avoid
|
|
722
|
+
* header noise in the host's `ToolBlockView`. Hosts render
|
|
723
|
+
* "TOOL · attempt N · 1.4s" subtitle when present, hidden otherwise.
|
|
724
|
+
*
|
|
725
|
+
* Plumbing: engine sets a per-tool `retryStats: { attemptCount: 1 }`
|
|
726
|
+
* counter on `ToolContext`; the BlockVision retry wrapper increments
|
|
727
|
+
* it on every retry attempt; the engine reads it back after the tool
|
|
728
|
+
* returns and surfaces here when > 1. Tools that don't use a retry
|
|
729
|
+
* wrapper never emit a value.
|
|
730
|
+
*/
|
|
731
|
+
attemptCount?: number;
|
|
704
732
|
} | {
|
|
705
733
|
type: 'pending_action';
|
|
706
734
|
action: PendingAction;
|
|
@@ -785,7 +813,52 @@ type EngineEvent =
|
|
|
785
813
|
inputId: string;
|
|
786
814
|
/** Optional human-readable prompt the LLM wants the host to display above the form. */
|
|
787
815
|
prompt?: string;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* [SPEC 8 v0.5.1 B3.2] One-shot per-turn declaration of which adaptive
|
|
819
|
+
* harness shape this turn is running under. Emitted at the start of
|
|
820
|
+
* `submitMessage` BEFORE `agentLoop` begins (not on `resumeWithToolResult`
|
|
821
|
+
* — resume is a continuation of the same turn, not a new shape decision).
|
|
822
|
+
*
|
|
823
|
+
* Derived from `classifyEffort()` on the host side: `low → 'lean'`,
|
|
824
|
+
* `medium → 'standard'`, `high → 'rich'`, `max → 'max'`. Hosts use it
|
|
825
|
+
* to (a) pre-allocate UI affordances (todo surface for `rich+`),
|
|
826
|
+
* (b) stamp `TurnMetrics.harnessShape` for dashboard segmentation,
|
|
827
|
+
* and (c) gate optional features (e.g. forbid `update_todo` rendering
|
|
828
|
+
* on `lean` even if a misbehaving LLM emits one).
|
|
829
|
+
*
|
|
830
|
+
* If absent, hosts MUST default to `'legacy'` for telemetry purposes
|
|
831
|
+
* (existing engines that don't emit this event are pre-SPEC-8). The
|
|
832
|
+
* engine emits it ONLY when the host passes `harnessShape` into
|
|
833
|
+
* `submitMessage` options; hosts that don't classify won't see this
|
|
834
|
+
* event.
|
|
835
|
+
*/
|
|
836
|
+
| {
|
|
837
|
+
type: 'harness_shape';
|
|
838
|
+
shape: HarnessShape;
|
|
839
|
+
/**
|
|
840
|
+
* 1-line human-readable explanation of why this shape was picked.
|
|
841
|
+
* Examples: "matched recipe portfolio_rebalance → max",
|
|
842
|
+
* "session has prior writes + 'borrow' keyword → rich",
|
|
843
|
+
* "single-fact lookup → lean". Forwarded into telemetry verbatim.
|
|
844
|
+
*/
|
|
845
|
+
rationale: string;
|
|
788
846
|
};
|
|
847
|
+
/**
|
|
848
|
+
* [SPEC 8 v0.5.1 B3.2] Adaptive harness shape — driven by `classifyEffort()`,
|
|
849
|
+
* pinned per-turn at turn start. Each shape implies a different
|
|
850
|
+
* `thinking.budget_tokens` cap, soft block limit, and `update_todo`
|
|
851
|
+
* permission. See SPEC 8 § "Adaptive thresholds: harness shape gate"
|
|
852
|
+
* for the canonical mapping.
|
|
853
|
+
*/
|
|
854
|
+
type HarnessShape = 'lean' | 'standard' | 'rich' | 'max';
|
|
855
|
+
/**
|
|
856
|
+
* [SPEC 8 v0.5.1 B3.2] Maps the engine's `ThinkingEffort` to the host-facing
|
|
857
|
+
* harness shape. Single source of truth for the `low → lean`, `medium →
|
|
858
|
+
* standard`, `high → rich`, `max → max` mapping. Exported so hosts (and
|
|
859
|
+
* tests) get the mapping for free without re-implementing it.
|
|
860
|
+
*/
|
|
861
|
+
declare function harnessShapeForEffort(effort: ThinkingEffort): HarnessShape;
|
|
789
862
|
/**
|
|
790
863
|
* [SPEC 8 v0.5.1] One row in an `update_todo` payload. Mirrored from
|
|
791
864
|
* `packages/engine/src/tools/update-todo.ts`. Kept here so hosts that
|
|
@@ -920,6 +993,23 @@ interface ToolContext {
|
|
|
920
993
|
* primarily a fast-path optimisation rather than a correctness primitive.
|
|
921
994
|
*/
|
|
922
995
|
portfolioCache?: Map<string, AddressPortfolio>;
|
|
996
|
+
/**
|
|
997
|
+
* [SPEC 8 v0.5.1 B3.2] Per-tool-invocation HTTP attempt counter. The
|
|
998
|
+
* engine's tool dispatcher attaches a fresh `{ attemptCount: 1 }` to
|
|
999
|
+
* the context before calling each tool; retry wrappers
|
|
1000
|
+
* (`fetchBlockVisionWithRetry` and equivalents) bump
|
|
1001
|
+
* `retryStats.attemptCount` on every retry beyond the first attempt;
|
|
1002
|
+
* the dispatcher reads the final value back and surfaces it on the
|
|
1003
|
+
* `tool_result` event (only when > 1). Tools that don't use a retry
|
|
1004
|
+
* wrapper never observe a non-default value.
|
|
1005
|
+
*
|
|
1006
|
+
* The mutable-ref shape is deliberate — it lets retry wrappers deep
|
|
1007
|
+
* in the call stack record state without changing every caller's
|
|
1008
|
+
* return type.
|
|
1009
|
+
*/
|
|
1010
|
+
retryStats?: {
|
|
1011
|
+
attemptCount: number;
|
|
1012
|
+
};
|
|
923
1013
|
}
|
|
924
1014
|
interface ServerPositionData {
|
|
925
1015
|
savings: number;
|
|
@@ -1289,8 +1379,20 @@ declare class QueryEngine {
|
|
|
1289
1379
|
* `pending_action` event and the stream ends — no persistent connection needed.
|
|
1290
1380
|
* The caller should save messages + pendingAction to the session store, then
|
|
1291
1381
|
* call `resumeWithToolResult()` after the user approves/denies and executes.
|
|
1382
|
+
*
|
|
1383
|
+
* [SPEC 8 v0.5.1 B3.2] Optional `options.harnessShape` + `options.harnessRationale`
|
|
1384
|
+
* cause a one-shot `harness_shape` event to be yielded BEFORE the agent loop
|
|
1385
|
+
* begins. The engine itself doesn't classify — the host calls
|
|
1386
|
+
* `classifyEffort()` (host already does this for thinking-budget routing)
|
|
1387
|
+
* and maps via `harnessShapeForEffort()` before calling `submitMessage`.
|
|
1388
|
+
* Hosts that don't pass `harnessShape` won't see the event (existing
|
|
1389
|
+
* pre-SPEC-8 hosts continue to work; their `TurnMetrics.harnessShape`
|
|
1390
|
+
* defaults to `'legacy'`).
|
|
1292
1391
|
*/
|
|
1293
|
-
submitMessage(prompt: string
|
|
1392
|
+
submitMessage(prompt: string, options?: {
|
|
1393
|
+
harnessShape?: HarnessShape;
|
|
1394
|
+
harnessRationale?: string;
|
|
1395
|
+
}): AsyncGenerator<EngineEvent>;
|
|
1294
1396
|
/**
|
|
1295
1397
|
* Resume the conversation after a pending action is resolved.
|
|
1296
1398
|
* Called with the user's approval/denial and optional client-side execution result.
|
|
@@ -1417,6 +1519,7 @@ type SSEEvent = {
|
|
|
1417
1519
|
wasEarlyDispatched?: boolean;
|
|
1418
1520
|
resultDeduped?: boolean;
|
|
1419
1521
|
wasPostWriteRefresh?: boolean;
|
|
1522
|
+
attemptCount?: number;
|
|
1420
1523
|
} | {
|
|
1421
1524
|
type: 'pending_action';
|
|
1422
1525
|
action: PendingAction;
|
|
@@ -1453,6 +1556,10 @@ type SSEEvent = {
|
|
|
1453
1556
|
schema: unknown;
|
|
1454
1557
|
inputId: string;
|
|
1455
1558
|
prompt?: string;
|
|
1559
|
+
} | {
|
|
1560
|
+
type: 'harness_shape';
|
|
1561
|
+
shape: HarnessShape;
|
|
1562
|
+
rationale: string;
|
|
1456
1563
|
};
|
|
1457
1564
|
declare function serializeSSE(event: SSEEvent): string;
|
|
1458
1565
|
declare function parseSSE(raw: string): SSEEvent | null;
|
|
@@ -3231,4 +3338,4 @@ declare function getTelemetrySink(): TelemetrySink;
|
|
|
3231
3338
|
/** Restore the default noop sink. Used by test teardowns. */
|
|
3232
3339
|
declare function resetTelemetrySink(): void;
|
|
3233
3340
|
|
|
3234
|
-
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, EFFORT_THINKING_BUDGET_CAPS, EarlyToolDispatcher, type EngineConfig, type EngineEvent, type EvalSummaryParseResult, type EvaluationItem, type EvaluationStatus, 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 TodoItem$1 as TodoItem, type Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolFlags, type ToolJsonSchema, type ToolResult, TxMutex, type UpdateTodoInput, type TodoItem as UpdateTodoItem, 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, clampThinkingForEffort, 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, parseEvalSummary, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resetFetchLock, resetNaviCacheStore, resetTelemetrySink, resetWalletCacheStore, resolveAddressToSuinsViaRpc, 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, updateTodoTool, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
3341
|
+
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, EFFORT_THINKING_BUDGET_CAPS, EarlyToolDispatcher, type EngineConfig, type EngineEvent, type EvalSummaryParseResult, type EvaluationItem, type EvaluationStatus, type FetchLock, type GuardCheckResult, type GuardConfig, type GuardEvent, type GuardInjection, type GuardResult, type GuardRunnerState, type GuardTier, type GuardVerdict, type HarnessShape, 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 TodoItem$1 as TodoItem, type Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolFlags, type ToolJsonSchema, type ToolResult, TxMutex, type UpdateTodoInput, type TodoItem as UpdateTodoItem, 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, clampThinkingForEffort, 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, harnessShapeForEffort, hasNaviMcp, healthCheckTool, loadRecipes, looksLikeSuiNs, microcompact, mppServicesTool, naviKey, normalizeAddressInput, parseEvalSummary, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resetFetchLock, resetNaviCacheStore, resetTelemetrySink, resetWalletCacheStore, resolveAddressToSuinsViaRpc, 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, updateTodoTool, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,13 @@ var TxMutex = class {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
function withRetryStats(context) {
|
|
65
|
+
const retryStats = { attemptCount: 1 };
|
|
66
|
+
return {
|
|
67
|
+
context: { ...context, retryStats },
|
|
68
|
+
readAttemptCount: () => retryStats.attemptCount > 1 ? retryStats.attemptCount : void 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
64
71
|
async function* runTools(pending, tools, context, txMutex) {
|
|
65
72
|
const { reads, writes } = partitionToolCalls(pending, tools);
|
|
66
73
|
if (reads.length > 0) {
|
|
@@ -68,24 +75,36 @@ async function* runTools(pending, tools, context, txMutex) {
|
|
|
68
75
|
reads.map(async (call) => {
|
|
69
76
|
const tool = findTool(tools, call.name);
|
|
70
77
|
if (!tool) {
|
|
71
|
-
return {
|
|
78
|
+
return {
|
|
79
|
+
call,
|
|
80
|
+
result: { data: { error: `Unknown tool: ${call.name}` } },
|
|
81
|
+
isError: true,
|
|
82
|
+
attemptCount: void 0
|
|
83
|
+
};
|
|
72
84
|
}
|
|
73
|
-
const
|
|
85
|
+
const { context: toolCtx, readAttemptCount } = withRetryStats(context);
|
|
86
|
+
const execResult = await executeSingleTool(tool, call, toolCtx);
|
|
74
87
|
if (!execResult.isError) {
|
|
75
88
|
execResult.data = budgetToolResult(execResult.data, tool);
|
|
76
89
|
}
|
|
77
|
-
return {
|
|
90
|
+
return {
|
|
91
|
+
call,
|
|
92
|
+
result: execResult,
|
|
93
|
+
isError: execResult.isError,
|
|
94
|
+
attemptCount: readAttemptCount()
|
|
95
|
+
};
|
|
78
96
|
})
|
|
79
97
|
);
|
|
80
98
|
for (const settled of readResults) {
|
|
81
99
|
if (settled.status === "fulfilled") {
|
|
82
|
-
const { call, result, isError } = settled.value;
|
|
100
|
+
const { call, result, isError, attemptCount } = settled.value;
|
|
83
101
|
yield {
|
|
84
102
|
type: "tool_result",
|
|
85
103
|
toolName: call.name,
|
|
86
104
|
toolUseId: call.id,
|
|
87
105
|
result: result.data,
|
|
88
|
-
isError
|
|
106
|
+
isError,
|
|
107
|
+
...attemptCount !== void 0 ? { attemptCount } : {}
|
|
89
108
|
};
|
|
90
109
|
} else {
|
|
91
110
|
const idx = readResults.indexOf(settled);
|
|
@@ -114,16 +133,19 @@ async function* runTools(pending, tools, context, txMutex) {
|
|
|
114
133
|
}
|
|
115
134
|
await txMutex.acquire();
|
|
116
135
|
try {
|
|
117
|
-
const
|
|
136
|
+
const { context: toolCtx, readAttemptCount } = withRetryStats(context);
|
|
137
|
+
const result = await executeSingleTool(tool, call, toolCtx);
|
|
118
138
|
if (!result.isError) {
|
|
119
139
|
result.data = budgetToolResult(result.data, tool);
|
|
120
140
|
}
|
|
141
|
+
const attemptCount = readAttemptCount();
|
|
121
142
|
yield {
|
|
122
143
|
type: "tool_result",
|
|
123
144
|
toolName: call.name,
|
|
124
145
|
toolUseId: call.id,
|
|
125
146
|
result: result.data,
|
|
126
|
-
isError: result.isError
|
|
147
|
+
isError: result.isError,
|
|
148
|
+
...attemptCount !== void 0 ? { attemptCount } : {}
|
|
127
149
|
};
|
|
128
150
|
} catch (err) {
|
|
129
151
|
yield {
|
|
@@ -726,6 +748,7 @@ async function fetchBlockVisionWithRetry(url, init, opts = {}) {
|
|
|
726
748
|
let lastError = null;
|
|
727
749
|
let lastResponse = null;
|
|
728
750
|
for (let attempt = 0; attempt < BV_RETRY_MAX_ATTEMPTS; attempt++) {
|
|
751
|
+
if (opts.retryStats) opts.retryStats.attemptCount = attempt + 1;
|
|
729
752
|
if (attempt > 0) {
|
|
730
753
|
let waitMs = BV_RETRY_BASE_DELAY_MS * Math.pow(BV_RETRY_BACKOFF_FACTOR, attempt - 1);
|
|
731
754
|
const retryAfter = lastResponse?.headers.get("retry-after");
|
|
@@ -808,7 +831,7 @@ async function safeWalletStoreGet(store, address) {
|
|
|
808
831
|
return null;
|
|
809
832
|
}
|
|
810
833
|
}
|
|
811
|
-
async function fetchAddressPortfolio(address, apiKey, fallbackRpcUrl) {
|
|
834
|
+
async function fetchAddressPortfolio(address, apiKey, fallbackRpcUrl, opts = {}) {
|
|
812
835
|
const store = getWalletCacheStore();
|
|
813
836
|
const cachedEntry = await safeWalletStoreGet(store, address);
|
|
814
837
|
if (cachedEntry) {
|
|
@@ -841,7 +864,7 @@ async function fetchAddressPortfolio(address, apiKey, fallbackRpcUrl) {
|
|
|
841
864
|
}
|
|
842
865
|
}
|
|
843
866
|
if (apiKey && apiKey.trim().length > 0) {
|
|
844
|
-
const blockvision = await fetchPortfolioFromBlockVision(address, apiKey);
|
|
867
|
+
const blockvision = await fetchPortfolioFromBlockVision(address, apiKey, opts.retryStats);
|
|
845
868
|
if (blockvision) {
|
|
846
869
|
await safeWalletStoreSet(
|
|
847
870
|
store,
|
|
@@ -885,7 +908,7 @@ async function fetchAddressPortfolio(address, apiKey, fallbackRpcUrl) {
|
|
|
885
908
|
portfolioInflight.set(address, promise);
|
|
886
909
|
return promise;
|
|
887
910
|
}
|
|
888
|
-
async function fetchPortfolioFromBlockVision(address, apiKey) {
|
|
911
|
+
async function fetchPortfolioFromBlockVision(address, apiKey, retryStats) {
|
|
889
912
|
const url = `${BLOCKVISION_BASE}/account/coins?account=${encodeURIComponent(address)}`;
|
|
890
913
|
const signal = AbortSignal.timeout(PORTFOLIO_TIMEOUT_MS);
|
|
891
914
|
let res;
|
|
@@ -896,7 +919,7 @@ async function fetchPortfolioFromBlockVision(address, apiKey) {
|
|
|
896
919
|
headers: { "x-api-key": apiKey, accept: "application/json" },
|
|
897
920
|
signal
|
|
898
921
|
},
|
|
899
|
-
{ signal }
|
|
922
|
+
{ signal, retryStats }
|
|
900
923
|
);
|
|
901
924
|
} catch (err) {
|
|
902
925
|
console.warn("[blockvision-prices] portfolio fetch threw, degrading:", err);
|
|
@@ -982,7 +1005,7 @@ async function fetchPortfolioFromSuiRpc(address, apiKey, fallbackRpcUrl) {
|
|
|
982
1005
|
source: "sui-rpc-degraded"
|
|
983
1006
|
};
|
|
984
1007
|
}
|
|
985
|
-
async function fetchTokenPrices(coinTypes, apiKey) {
|
|
1008
|
+
async function fetchTokenPrices(coinTypes, apiKey, opts = {}) {
|
|
986
1009
|
if (coinTypes.length === 0) return {};
|
|
987
1010
|
const now = Date.now();
|
|
988
1011
|
const cacheValid = priceMapCache !== null && now - priceMapCache.ts < CACHE_TTL_MS;
|
|
@@ -1006,7 +1029,7 @@ async function fetchTokenPrices(coinTypes, apiKey) {
|
|
|
1006
1029
|
if (!apiKey || apiKey.trim().length === 0) {
|
|
1007
1030
|
return result;
|
|
1008
1031
|
}
|
|
1009
|
-
const fetched = await fetchPricesFromBlockVision(stillMissing, apiKey);
|
|
1032
|
+
const fetched = await fetchPricesFromBlockVision(stillMissing, apiKey, opts.retryStats);
|
|
1010
1033
|
Object.assign(result, fetched);
|
|
1011
1034
|
const cacheUpdates = {};
|
|
1012
1035
|
for (const [original, value] of Object.entries(fetched)) {
|
|
@@ -1016,7 +1039,7 @@ async function fetchTokenPrices(coinTypes, apiKey) {
|
|
|
1016
1039
|
priceMapCache = { prices: merged, ts: cacheValid ? priceMapCache.ts : now };
|
|
1017
1040
|
return result;
|
|
1018
1041
|
}
|
|
1019
|
-
async function fetchPricesFromBlockVision(coinTypes, apiKey) {
|
|
1042
|
+
async function fetchPricesFromBlockVision(coinTypes, apiKey, retryStats) {
|
|
1020
1043
|
const out = {};
|
|
1021
1044
|
const longToOriginal = /* @__PURE__ */ new Map();
|
|
1022
1045
|
for (const original of coinTypes) {
|
|
@@ -1037,7 +1060,7 @@ async function fetchPricesFromBlockVision(coinTypes, apiKey) {
|
|
|
1037
1060
|
headers: { "x-api-key": apiKey, accept: "application/json" },
|
|
1038
1061
|
signal
|
|
1039
1062
|
},
|
|
1040
|
-
{ signal }
|
|
1063
|
+
{ signal, retryStats }
|
|
1041
1064
|
);
|
|
1042
1065
|
} catch (err) {
|
|
1043
1066
|
console.warn("[blockvision-prices] price chunk threw, skipping:", err);
|
|
@@ -1123,7 +1146,7 @@ async function safeDefiStoreGet(store, address) {
|
|
|
1123
1146
|
}
|
|
1124
1147
|
}
|
|
1125
1148
|
var warnedMissingApiKey = false;
|
|
1126
|
-
async function fetchAddressDefiPortfolio(address, apiKey, priceHints = {}) {
|
|
1149
|
+
async function fetchAddressDefiPortfolio(address, apiKey, priceHints = {}, opts = {}) {
|
|
1127
1150
|
if (!apiKey || apiKey.trim().length === 0) {
|
|
1128
1151
|
if (!warnedMissingApiKey) {
|
|
1129
1152
|
warnedMissingApiKey = true;
|
|
@@ -1164,7 +1187,7 @@ async function fetchAddressDefiPortfolio(address, apiKey, priceHints = {}) {
|
|
|
1164
1187
|
const stickyBasis = recheck ?? cachedEntry;
|
|
1165
1188
|
const fanoutAt = Date.now();
|
|
1166
1189
|
const settled = await Promise.allSettled(
|
|
1167
|
-
DEFI_PROTOCOLS.map((p) => fetchOneDefiProtocol(address, p, apiKey))
|
|
1190
|
+
DEFI_PROTOCOLS.map((p) => fetchOneDefiProtocol(address, p, apiKey, opts.retryStats))
|
|
1168
1191
|
);
|
|
1169
1192
|
const seen = /* @__PURE__ */ new Set();
|
|
1170
1193
|
for (const s of settled) {
|
|
@@ -1259,7 +1282,7 @@ async function fetchAddressDefiPortfolio(address, apiKey, priceHints = {}) {
|
|
|
1259
1282
|
defiInflight.set(address, inflight);
|
|
1260
1283
|
return inflight;
|
|
1261
1284
|
}
|
|
1262
|
-
async function fetchOneDefiProtocol(address, protocol, apiKey) {
|
|
1285
|
+
async function fetchOneDefiProtocol(address, protocol, apiKey, retryStats) {
|
|
1263
1286
|
const url = `${BLOCKVISION_BASE}/account/defiPortfolio?address=${encodeURIComponent(address)}&protocol=${protocol}`;
|
|
1264
1287
|
const signal = AbortSignal.timeout(DEFI_PORTFOLIO_TIMEOUT_MS);
|
|
1265
1288
|
let res;
|
|
@@ -1270,7 +1293,7 @@ async function fetchOneDefiProtocol(address, protocol, apiKey) {
|
|
|
1270
1293
|
headers: { "x-api-key": apiKey, accept: "application/json" },
|
|
1271
1294
|
signal
|
|
1272
1295
|
},
|
|
1273
|
-
{ signal }
|
|
1296
|
+
{ signal, retryStats }
|
|
1274
1297
|
);
|
|
1275
1298
|
} catch (err) {
|
|
1276
1299
|
console.warn(`[defi] ${protocol} fetch threw:`, err);
|
|
@@ -1810,12 +1833,12 @@ async function applyVsuiPriceFallback(portfolio) {
|
|
|
1810
1833
|
portfolio.totalUsd = portfolio.totalUsd - previousUsd + usdValue;
|
|
1811
1834
|
}
|
|
1812
1835
|
}
|
|
1813
|
-
async function loadPortfolio(address, blockvisionApiKey, fallbackRpcUrl, cache) {
|
|
1836
|
+
async function loadPortfolio(address, blockvisionApiKey, fallbackRpcUrl, cache, retryStats) {
|
|
1814
1837
|
if (cache) {
|
|
1815
1838
|
const hit = cache.get(address);
|
|
1816
1839
|
if (hit) return hit;
|
|
1817
1840
|
}
|
|
1818
|
-
const portfolio = await fetchAddressPortfolio(address, blockvisionApiKey, fallbackRpcUrl);
|
|
1841
|
+
const portfolio = await fetchAddressPortfolio(address, blockvisionApiKey, fallbackRpcUrl, { retryStats });
|
|
1819
1842
|
if (cache) cache.set(address, portfolio);
|
|
1820
1843
|
return portfolio;
|
|
1821
1844
|
}
|
|
@@ -1874,7 +1897,8 @@ var balanceCheckTool = buildTool({
|
|
|
1874
1897
|
address,
|
|
1875
1898
|
context.blockvisionApiKey,
|
|
1876
1899
|
context.suiRpcUrl,
|
|
1877
|
-
context.portfolioCache
|
|
1900
|
+
context.portfolioCache,
|
|
1901
|
+
context.retryStats
|
|
1878
1902
|
).catch((err) => {
|
|
1879
1903
|
console.warn("[balance_check] portfolio fetch failed, returning empty:", err);
|
|
1880
1904
|
const fallback = {
|
|
@@ -1906,7 +1930,7 @@ var balanceCheckTool = buildTool({
|
|
|
1906
1930
|
// as defi.totalUsd === 0 and `source: 'degraded'`, leaving the
|
|
1907
1931
|
// rest of balance_check unaffected. The fetcher fills its own
|
|
1908
1932
|
// prices via fetchTokenPrices for any coin types it discovers.
|
|
1909
|
-
fetchAddressDefiPortfolio(address, context.blockvisionApiKey).catch((err) => {
|
|
1933
|
+
fetchAddressDefiPortfolio(address, context.blockvisionApiKey, {}, { retryStats: context.retryStats }).catch((err) => {
|
|
1910
1934
|
console.warn("[balance_check] defi fetch failed:", err);
|
|
1911
1935
|
const fallback = {
|
|
1912
1936
|
totalUsd: 0,
|
|
@@ -2023,7 +2047,7 @@ var balanceCheckTool = buildTool({
|
|
|
2023
2047
|
const fetchAddress = targetAddress ?? context.walletAddress;
|
|
2024
2048
|
const [balance, defi] = await Promise.all([
|
|
2025
2049
|
agent.balance(),
|
|
2026
|
-
fetchAddressDefiPortfolio(fetchAddress, context.blockvisionApiKey).catch((err) => {
|
|
2050
|
+
fetchAddressDefiPortfolio(fetchAddress, context.blockvisionApiKey, {}, { retryStats: context.retryStats }).catch((err) => {
|
|
2027
2051
|
console.warn("[balance_check] sdk-path defi fetch failed:", err);
|
|
2028
2052
|
const fallback = {
|
|
2029
2053
|
totalUsd: 0,
|
|
@@ -3986,7 +4010,8 @@ var portfolioAnalysisTool = buildTool({
|
|
|
3986
4010
|
const fresh = await fetchAddressPortfolio(
|
|
3987
4011
|
address,
|
|
3988
4012
|
context.blockvisionApiKey,
|
|
3989
|
-
context.suiRpcUrl
|
|
4013
|
+
context.suiRpcUrl,
|
|
4014
|
+
{ retryStats: context.retryStats }
|
|
3990
4015
|
);
|
|
3991
4016
|
context.portfolioCache?.set(address, fresh);
|
|
3992
4017
|
return fresh;
|
|
@@ -4036,7 +4061,7 @@ var portfolioAnalysisTool = buildTool({
|
|
|
4036
4061
|
perProtocol: {},
|
|
4037
4062
|
pricedAt: Date.now(),
|
|
4038
4063
|
source: audricSnapshot.defiSource
|
|
4039
|
-
}) : fetchAddressDefiPortfolio(address, context.blockvisionApiKey).catch(
|
|
4064
|
+
}) : fetchAddressDefiPortfolio(address, context.blockvisionApiKey, {}, { retryStats: context.retryStats }).catch(
|
|
4040
4065
|
(err) => {
|
|
4041
4066
|
console.warn("[portfolio_analysis] defi fetch failed:", err);
|
|
4042
4067
|
return { totalUsd: 0, perProtocol: {}, pricedAt: Date.now(), source: "degraded" };
|
|
@@ -5229,7 +5254,7 @@ var tokenPricesTool = buildTool({
|
|
|
5229
5254
|
},
|
|
5230
5255
|
isReadOnly: true,
|
|
5231
5256
|
async call(input, context) {
|
|
5232
|
-
const prices = await fetchTokenPrices(input.coinTypes, context.blockvisionApiKey);
|
|
5257
|
+
const prices = await fetchTokenPrices(input.coinTypes, context.blockvisionApiKey, { retryStats: context.retryStats });
|
|
5233
5258
|
const results = input.coinTypes.map((coinType) => {
|
|
5234
5259
|
const entry = prices[coinType];
|
|
5235
5260
|
const symbol = coinType.split("::").pop() ?? coinType;
|
|
@@ -6498,12 +6523,14 @@ var EarlyToolDispatcher = class {
|
|
|
6498
6523
|
call,
|
|
6499
6524
|
tool,
|
|
6500
6525
|
promise: Promise.resolve({ data: cached.result, isError: false }),
|
|
6501
|
-
deduped: true
|
|
6526
|
+
deduped: true,
|
|
6527
|
+
readAttemptCount: () => void 0
|
|
6502
6528
|
});
|
|
6503
6529
|
return true;
|
|
6504
6530
|
}
|
|
6505
6531
|
}
|
|
6506
|
-
const
|
|
6532
|
+
const baseChildContext = { ...this.context, signal: this.abortController.signal };
|
|
6533
|
+
const { context: childContext, readAttemptCount } = withRetryStats(baseChildContext);
|
|
6507
6534
|
const promise = executeTool(tool, call, childContext).then((result) => {
|
|
6508
6535
|
if (!result.isError && this.turnReadCache) {
|
|
6509
6536
|
const cacheKey = TurnReadCache.keyFor(call.name, call.input);
|
|
@@ -6514,7 +6541,7 @@ var EarlyToolDispatcher = class {
|
|
|
6514
6541
|
}
|
|
6515
6542
|
return result;
|
|
6516
6543
|
});
|
|
6517
|
-
this.entries.push({ call, tool, promise, deduped: false });
|
|
6544
|
+
this.entries.push({ call, tool, promise, deduped: false, readAttemptCount });
|
|
6518
6545
|
return true;
|
|
6519
6546
|
}
|
|
6520
6547
|
/** True if any tools have been dispatched. */
|
|
@@ -6543,6 +6570,7 @@ var EarlyToolDispatcher = class {
|
|
|
6543
6570
|
try {
|
|
6544
6571
|
const result = await entry.promise;
|
|
6545
6572
|
const budgeted = result.isError ? result.data : budgetToolResult(result.data, entry.tool);
|
|
6573
|
+
const attemptCount = entry.readAttemptCount();
|
|
6546
6574
|
yield {
|
|
6547
6575
|
type: "tool_result",
|
|
6548
6576
|
toolName: entry.call.name,
|
|
@@ -6550,7 +6578,8 @@ var EarlyToolDispatcher = class {
|
|
|
6550
6578
|
result: budgeted,
|
|
6551
6579
|
isError: result.isError,
|
|
6552
6580
|
wasEarlyDispatched: true,
|
|
6553
|
-
...entry.deduped ? { resultDeduped: true } : {}
|
|
6581
|
+
...entry.deduped ? { resultDeduped: true } : {},
|
|
6582
|
+
...attemptCount !== void 0 ? { attemptCount } : {}
|
|
6554
6583
|
};
|
|
6555
6584
|
} catch (err) {
|
|
6556
6585
|
yield {
|
|
@@ -6684,8 +6713,17 @@ var QueryEngine = class {
|
|
|
6684
6713
|
* `pending_action` event and the stream ends — no persistent connection needed.
|
|
6685
6714
|
* The caller should save messages + pendingAction to the session store, then
|
|
6686
6715
|
* call `resumeWithToolResult()` after the user approves/denies and executes.
|
|
6716
|
+
*
|
|
6717
|
+
* [SPEC 8 v0.5.1 B3.2] Optional `options.harnessShape` + `options.harnessRationale`
|
|
6718
|
+
* cause a one-shot `harness_shape` event to be yielded BEFORE the agent loop
|
|
6719
|
+
* begins. The engine itself doesn't classify — the host calls
|
|
6720
|
+
* `classifyEffort()` (host already does this for thinking-budget routing)
|
|
6721
|
+
* and maps via `harnessShapeForEffort()` before calling `submitMessage`.
|
|
6722
|
+
* Hosts that don't pass `harnessShape` won't see the event (existing
|
|
6723
|
+
* pre-SPEC-8 hosts continue to work; their `TurnMetrics.harnessShape`
|
|
6724
|
+
* defaults to `'legacy'`).
|
|
6687
6725
|
*/
|
|
6688
|
-
async *submitMessage(prompt) {
|
|
6726
|
+
async *submitMessage(prompt, options) {
|
|
6689
6727
|
if (this.costTracker.isOverBudget()) {
|
|
6690
6728
|
yield { type: "error", error: new Error("Session budget exceeded") };
|
|
6691
6729
|
return;
|
|
@@ -6697,6 +6735,13 @@ var QueryEngine = class {
|
|
|
6697
6735
|
role: "user",
|
|
6698
6736
|
content: [{ type: "text", text: prompt }]
|
|
6699
6737
|
});
|
|
6738
|
+
if (options?.harnessShape) {
|
|
6739
|
+
yield {
|
|
6740
|
+
type: "harness_shape",
|
|
6741
|
+
shape: options.harnessShape,
|
|
6742
|
+
rationale: options.harnessRationale && options.harnessRationale.trim().length > 0 ? options.harnessRationale : `host-classified ${options.harnessShape}`
|
|
6743
|
+
};
|
|
6744
|
+
}
|
|
6700
6745
|
this.turnPaused = false;
|
|
6701
6746
|
try {
|
|
6702
6747
|
yield* this.agentLoop(prompt, signal);
|
|
@@ -6823,11 +6868,19 @@ var QueryEngine = class {
|
|
|
6823
6868
|
isError: true,
|
|
6824
6869
|
data: {
|
|
6825
6870
|
error: `Post-write refresh: invalid input for ${tool.name}`
|
|
6826
|
-
}
|
|
6871
|
+
},
|
|
6872
|
+
attemptCount: void 0
|
|
6827
6873
|
};
|
|
6828
6874
|
}
|
|
6829
|
-
const
|
|
6830
|
-
|
|
6875
|
+
const { context: toolCtx, readAttemptCount } = withRetryStats(context);
|
|
6876
|
+
const result = await tool.call(parsed.data, toolCtx);
|
|
6877
|
+
return {
|
|
6878
|
+
tool,
|
|
6879
|
+
id,
|
|
6880
|
+
isError: false,
|
|
6881
|
+
data: result.data,
|
|
6882
|
+
attemptCount: readAttemptCount()
|
|
6883
|
+
};
|
|
6831
6884
|
} catch (err) {
|
|
6832
6885
|
return {
|
|
6833
6886
|
tool,
|
|
@@ -6835,7 +6888,8 @@ var QueryEngine = class {
|
|
|
6835
6888
|
isError: true,
|
|
6836
6889
|
data: {
|
|
6837
6890
|
error: err instanceof Error ? err.message : "Post-write refresh failed"
|
|
6838
|
-
}
|
|
6891
|
+
},
|
|
6892
|
+
attemptCount: void 0
|
|
6839
6893
|
};
|
|
6840
6894
|
}
|
|
6841
6895
|
})
|
|
@@ -6867,7 +6921,8 @@ var QueryEngine = class {
|
|
|
6867
6921
|
toolUseId: r.id,
|
|
6868
6922
|
result: r.data,
|
|
6869
6923
|
isError: r.isError,
|
|
6870
|
-
wasPostWriteRefresh: true
|
|
6924
|
+
wasPostWriteRefresh: true,
|
|
6925
|
+
...r.attemptCount !== void 0 ? { attemptCount: r.attemptCount } : {}
|
|
6871
6926
|
};
|
|
6872
6927
|
}
|
|
6873
6928
|
}
|
|
@@ -7702,6 +7757,20 @@ function flagSuspiciousResult(toolName, result) {
|
|
|
7702
7757
|
return null;
|
|
7703
7758
|
}
|
|
7704
7759
|
|
|
7760
|
+
// src/types.ts
|
|
7761
|
+
function harnessShapeForEffort(effort) {
|
|
7762
|
+
switch (effort) {
|
|
7763
|
+
case "low":
|
|
7764
|
+
return "lean";
|
|
7765
|
+
case "medium":
|
|
7766
|
+
return "standard";
|
|
7767
|
+
case "high":
|
|
7768
|
+
return "rich";
|
|
7769
|
+
case "max":
|
|
7770
|
+
return "max";
|
|
7771
|
+
}
|
|
7772
|
+
}
|
|
7773
|
+
|
|
7705
7774
|
// src/streaming.ts
|
|
7706
7775
|
function serializeSSE(event) {
|
|
7707
7776
|
const data = JSON.stringify(event);
|
|
@@ -8788,6 +8857,6 @@ function sanitizeAnthropicMessages(messages) {
|
|
|
8788
8857
|
return merged;
|
|
8789
8858
|
}
|
|
8790
8859
|
|
|
8791
|
-
export { AnthropicProvider, BalanceTracker, CANVAS_TEMPLATES, ContextBudget, CostTracker, DEFAULT_GUARD_CONFIG, DEFAULT_LEASE_SEC, DEFAULT_PERMISSION_CONFIG, DEFAULT_POLL_BUDGET_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_SYSTEM_PROMPT, EFFORT_THINKING_BUDGET_CAPS, EarlyToolDispatcher, InMemoryDefiCacheStore, InMemoryFetchLock, InMemoryNaviCacheStore, InMemoryWalletCacheStore, InvalidAddressError, McpClientManager, McpResponseCache, MemorySessionStore, NAVI_ADDR_TTL_SEC, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_RATES_TTL_SEC, NAVI_SERVER_NAME, NaviTools, PERMISSION_PRESETS, QueryEngine, READ_TOOLS, RecipeRegistry, RetryTracker, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SuinsNotRegisteredError, SuinsRpcError, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, TxMutex, WRITE_TOOLS, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, claimRewardsTool, clampThinkingForEffort, 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, parseEvalSummary, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resetFetchLock, resetNaviCacheStore, resetTelemetrySink, resetWalletCacheStore, resolveAddressToSuinsViaRpc, 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, updateTodoTool, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
8860
|
+
export { AnthropicProvider, BalanceTracker, CANVAS_TEMPLATES, ContextBudget, CostTracker, DEFAULT_GUARD_CONFIG, DEFAULT_LEASE_SEC, DEFAULT_PERMISSION_CONFIG, DEFAULT_POLL_BUDGET_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_SYSTEM_PROMPT, EFFORT_THINKING_BUDGET_CAPS, EarlyToolDispatcher, InMemoryDefiCacheStore, InMemoryFetchLock, InMemoryNaviCacheStore, InMemoryWalletCacheStore, InvalidAddressError, McpClientManager, McpResponseCache, MemorySessionStore, NAVI_ADDR_TTL_SEC, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_RATES_TTL_SEC, NAVI_SERVER_NAME, NaviTools, PERMISSION_PRESETS, QueryEngine, READ_TOOLS, RecipeRegistry, RetryTracker, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SuinsNotRegisteredError, SuinsRpcError, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, TxMutex, WRITE_TOOLS, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, claimRewardsTool, clampThinkingForEffort, 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, harnessShapeForEffort, hasNaviMcp, healthCheckTool, loadRecipes, looksLikeSuiNs, microcompact, mppServicesTool, naviKey, normalizeAddressInput, parseEvalSummary, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resetFetchLock, resetNaviCacheStore, resetTelemetrySink, resetWalletCacheStore, resolveAddressToSuinsViaRpc, 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, updateTodoTool, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
8792
8861
|
//# sourceMappingURL=index.js.map
|
|
8793
8862
|
//# sourceMappingURL=index.js.map
|