@t2000/engine 1.24.3 → 1.24.6
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 +27 -1
- package/dist/index.js +92 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -503,6 +503,7 @@ declare class SwapQuoteTracker {
|
|
|
503
503
|
amount: number;
|
|
504
504
|
}): boolean;
|
|
505
505
|
}
|
|
506
|
+
declare function extractTrustedAddressesFromResult(toolName: string, input: unknown, result: unknown, recentUserText: string, state: GuardRunnerState): void;
|
|
506
507
|
declare function guardArtifactPreview(result: unknown): GuardInjection | null;
|
|
507
508
|
declare function guardStaleData(toolFlags: ToolFlags): GuardInjection | null;
|
|
508
509
|
interface GuardRunnerState {
|
|
@@ -510,6 +511,19 @@ interface GuardRunnerState {
|
|
|
510
511
|
retryTracker: RetryTracker;
|
|
511
512
|
swapQuoteTracker: SwapQuoteTracker;
|
|
512
513
|
lastHealthFactor: number | null;
|
|
514
|
+
/**
|
|
515
|
+
* [S.121 Option C] Per-session set of normalized 0x addresses that
|
|
516
|
+
* identity-resolving read tools (`lookup_user`, `resolve_suins`)
|
|
517
|
+
* resolved from a user-typed identifier. Acts as the 4th trusted
|
|
518
|
+
* source for `guardAddressSource` so the LLM can pass the resolved
|
|
519
|
+
* 0x address to `send_transfer` without the guard demanding the user
|
|
520
|
+
* paste the raw address themselves.
|
|
521
|
+
*
|
|
522
|
+
* Persisted across turns within a session. Reset per-session by
|
|
523
|
+
* `createGuardRunnerState()`. Safety invariant: see
|
|
524
|
+
* `extractTrustedAddressesFromResult`.
|
|
525
|
+
*/
|
|
526
|
+
trustedAddresses: Set<string>;
|
|
513
527
|
}
|
|
514
528
|
declare function createGuardRunnerState(): GuardRunnerState;
|
|
515
529
|
declare function runGuards(tool: Tool, call: PendingToolCall, state: GuardRunnerState, config: GuardConfig, conversationContext: {
|
|
@@ -2696,6 +2710,18 @@ interface MicrocompactResult extends Array<Message> {
|
|
|
2696
2710
|
* later call with identical inputs gets replaced — necessary because
|
|
2697
2711
|
* their results depend on mutable on-chain state that writes invalidate.
|
|
2698
2712
|
*
|
|
2713
|
+
* [v1.24.6 / S.122] Tools whose `flags.mutating === true` are ALSO
|
|
2714
|
+
* implicitly non-cacheable. Each call to a write tool produces a NEW
|
|
2715
|
+
* on-chain transaction (different digest, different balance changes, real
|
|
2716
|
+
* state mutation) — replacing the second result with "[Same result as
|
|
2717
|
+
* call #N — identical inputs]" lies to the LLM, which then narrates
|
|
2718
|
+
* "transaction deduplicated" to the user even though the on-chain write
|
|
2719
|
+
* actually settled. Surfaced during S.121 smoke testing: a second
|
|
2720
|
+
* `send_transfer` with identical inputs produced a real on-chain tx but
|
|
2721
|
+
* the engine narrated as if it had been skipped. Explicit `cacheable`
|
|
2722
|
+
* still wins (a `cacheable: true` write would be a tool-author bug, but
|
|
2723
|
+
* we don't override it), so the rule is: mutating ⇒ default `false`.
|
|
2724
|
+
*
|
|
2699
2725
|
* Returns a new array — does not mutate the input. The returned array
|
|
2700
2726
|
* carries a `dedupedToolUseIds` property listing every tool-use ID whose
|
|
2701
2727
|
* tool_result block was replaced with a back-reference this pass.
|
|
@@ -4289,4 +4315,4 @@ declare function getTelemetrySink(): TelemetrySink;
|
|
|
4289
4315
|
/** Restore the default noop sink. Used by test teardowns. */
|
|
4290
4316
|
declare function resetTelemetrySink(): void;
|
|
4291
4317
|
|
|
4292
|
-
export { type AddressPortfolio, AnthropicProvider, type AnthropicProviderConfig, type AudricHistoryRecord, type AudricPortfolioResult, type AwaitOrFetchOpts, type BalancePrices, type BalanceResult, BalanceTracker, type BuildToolOptions, type BundleCompositionInput, 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, DEFAULT_TOOL_TTL_MS, 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 FormField, type FormFieldKind, type FormSchema, 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, MAX_BUNDLE_OPS, 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 PendingActionStep, type PendingInput, type PendingInputState, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionOperation, type PermissionResponse, type PermissionRule, type PortfolioCoin, type PositionEntry, type PreflightResult, type ProactiveMarker, type ProactiveType, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, REGENERATABLE_READ_TOOLS, type RatesResult, type Recipe, type RecipePrerequisite, RecipeRegistry, type RecipeStep, type RecipeStepOnError, type RegenerateFailure, type RegenerateResult, type RegenerateSuccess, type RegenerateTimelineEvent, 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, TOOL_TTL_MS, 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, VALID_PAIRS, WRITE_TOOLS, type WalletCacheEntry, type WalletCacheStore, type WalletCoin, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, addRecipientTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, bundleShortestTtl, checkValidPair, claimRewardsTool, clampThinkingForEffort, classifyEffort, clearPortfolioCache, clearPortfolioCacheFor, clearPriceMapCache, compactMessages, composeBundleFromToolResults, computeRegenerateFields, createGuardRunnerState, engineToSSE, estimateTokens, explainTxTool, extractAllProactiveMarkers, 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, isBundleableTool, loadRecipes, looksLikeSuiNs, microcompact, mppServicesTool, naviKey, normalizeAddressInput, parseEvalSummary, parseMcpJson, parseProactiveMarker, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, regenerateBundle, 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, stripProactiveMarkers, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, updateTodoTool, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
4318
|
+
export { type AddressPortfolio, AnthropicProvider, type AnthropicProviderConfig, type AudricHistoryRecord, type AudricPortfolioResult, type AwaitOrFetchOpts, type BalancePrices, type BalanceResult, BalanceTracker, type BuildToolOptions, type BundleCompositionInput, 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, DEFAULT_TOOL_TTL_MS, 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 FormField, type FormFieldKind, type FormSchema, 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, MAX_BUNDLE_OPS, 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 PendingActionStep, type PendingInput, type PendingInputState, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionOperation, type PermissionResponse, type PermissionRule, type PortfolioCoin, type PositionEntry, type PreflightResult, type ProactiveMarker, type ProactiveType, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, REGENERATABLE_READ_TOOLS, type RatesResult, type Recipe, type RecipePrerequisite, RecipeRegistry, type RecipeStep, type RecipeStepOnError, type RegenerateFailure, type RegenerateResult, type RegenerateSuccess, type RegenerateTimelineEvent, 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, TOOL_TTL_MS, 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, VALID_PAIRS, WRITE_TOOLS, type WalletCacheEntry, type WalletCacheStore, type WalletCoin, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, addRecipientTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, bundleShortestTtl, checkValidPair, claimRewardsTool, clampThinkingForEffort, classifyEffort, clearPortfolioCache, clearPortfolioCacheFor, clearPriceMapCache, compactMessages, composeBundleFromToolResults, computeRegenerateFields, createGuardRunnerState, engineToSSE, estimateTokens, explainTxTool, extractAllProactiveMarkers, extractConversationText, extractMcpText, extractTrustedAddressesFromResult, 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, isBundleableTool, loadRecipes, looksLikeSuiNs, microcompact, mppServicesTool, naviKey, normalizeAddressInput, parseEvalSummary, parseMcpJson, parseProactiveMarker, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, regenerateBundle, 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, stripProactiveMarkers, 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
|
@@ -6227,7 +6227,7 @@ function guardSwapPreview(tool, call, swapQuoteTracker) {
|
|
|
6227
6227
|
message: `swap_execute requires a recent matching swap_quote so the user sees an accurate preview. Call swap_quote({ from: "${from}", to: "${to}", amount: ${amount} }) first, then re-issue swap_execute with the same params. swap_quote is read-only and returns the real on-chain output, route, and price impact \u2014 never estimate from memory.`
|
|
6228
6228
|
};
|
|
6229
6229
|
}
|
|
6230
|
-
function guardAddressSource(tool, call, userText, contacts, walletAddress) {
|
|
6230
|
+
function guardAddressSource(tool, call, userText, contacts, walletAddress, trustedAddresses) {
|
|
6231
6231
|
if (tool.name !== "send_transfer") {
|
|
6232
6232
|
return { verdict: "pass", gate: "address_source", tier: "safety" };
|
|
6233
6233
|
}
|
|
@@ -6251,13 +6251,75 @@ function guardAddressSource(tool, call, userText, contacts, walletAddress) {
|
|
|
6251
6251
|
if (userText.toLowerCase().includes(normalizedTo)) {
|
|
6252
6252
|
return { verdict: "pass", gate: "address_source", tier: "safety" };
|
|
6253
6253
|
}
|
|
6254
|
+
if (trustedAddresses.has(normalizedTo)) {
|
|
6255
|
+
return { verdict: "pass", gate: "address_source", tier: "safety" };
|
|
6256
|
+
}
|
|
6254
6257
|
return {
|
|
6255
6258
|
verdict: "block",
|
|
6256
6259
|
gate: "address_source",
|
|
6257
6260
|
tier: "safety",
|
|
6258
|
-
message: `Safety check failed: the recipient address "${rawTo}" was not provided by the user (no saved contact matches, address is not the user's own wallet,
|
|
6261
|
+
message: `Safety check failed: the recipient address "${rawTo}" was not provided by the user (no saved contact matches, address is not the user's own wallet, address does not appear verbatim in the user's recent messages, and no identity-resolving tool call this session linked it to a user-named handle). For safety, addresses must be supplied directly by the user \u2014 never reconstructed from memory or partial recall. Ask the user to paste the destination address again exactly, or call lookup_user / resolve_suins with the user-typed handle.`
|
|
6259
6262
|
};
|
|
6260
6263
|
}
|
|
6264
|
+
var IDENTITY_RESOLVING_TOOLS = /* @__PURE__ */ new Set([
|
|
6265
|
+
"lookup_user",
|
|
6266
|
+
"resolve_suins"
|
|
6267
|
+
]);
|
|
6268
|
+
function collectAddressesFromResult(value, out) {
|
|
6269
|
+
if (value === null || value === void 0) return;
|
|
6270
|
+
if (typeof value === "string") {
|
|
6271
|
+
if (SUI_ADDRESS_REGEX2.test(value)) {
|
|
6272
|
+
out.add(normalizeAddress(value));
|
|
6273
|
+
}
|
|
6274
|
+
return;
|
|
6275
|
+
}
|
|
6276
|
+
if (Array.isArray(value)) {
|
|
6277
|
+
for (const item of value) collectAddressesFromResult(item, out);
|
|
6278
|
+
return;
|
|
6279
|
+
}
|
|
6280
|
+
if (typeof value === "object") {
|
|
6281
|
+
for (const v of Object.values(value)) {
|
|
6282
|
+
collectAddressesFromResult(v, out);
|
|
6283
|
+
}
|
|
6284
|
+
}
|
|
6285
|
+
}
|
|
6286
|
+
function collectInputStringValues(value, out) {
|
|
6287
|
+
if (value === null || value === void 0) return;
|
|
6288
|
+
if (typeof value === "string") {
|
|
6289
|
+
const trimmed = value.trim();
|
|
6290
|
+
if (trimmed.length > 0) out.push(trimmed);
|
|
6291
|
+
return;
|
|
6292
|
+
}
|
|
6293
|
+
if (Array.isArray(value)) {
|
|
6294
|
+
for (const item of value) collectInputStringValues(item, out);
|
|
6295
|
+
return;
|
|
6296
|
+
}
|
|
6297
|
+
if (typeof value === "object") {
|
|
6298
|
+
for (const v of Object.values(value)) {
|
|
6299
|
+
collectInputStringValues(v, out);
|
|
6300
|
+
}
|
|
6301
|
+
}
|
|
6302
|
+
}
|
|
6303
|
+
function extractTrustedAddressesFromResult(toolName, input, result, recentUserText, state) {
|
|
6304
|
+
if (!IDENTITY_RESOLVING_TOOLS.has(toolName)) return;
|
|
6305
|
+
if (input === null || input === void 0) return;
|
|
6306
|
+
if (result === null || result === void 0) return;
|
|
6307
|
+
const inputStrings = [];
|
|
6308
|
+
collectInputStringValues(input, inputStrings);
|
|
6309
|
+
if (inputStrings.length === 0) return;
|
|
6310
|
+
const normalizedUserText = recentUserText.toLowerCase();
|
|
6311
|
+
const inputMatchesUser = inputStrings.some((s) => {
|
|
6312
|
+
const norm = s.toLowerCase();
|
|
6313
|
+
if (SUI_ADDRESS_REGEX2.test(s)) return false;
|
|
6314
|
+
return normalizedUserText.includes(norm);
|
|
6315
|
+
});
|
|
6316
|
+
if (!inputMatchesUser) return;
|
|
6317
|
+
const found = /* @__PURE__ */ new Set();
|
|
6318
|
+
collectAddressesFromResult(result, found);
|
|
6319
|
+
for (const addr of found) {
|
|
6320
|
+
state.trustedAddresses.add(addr);
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6261
6323
|
var READ_TOOLS_WITH_ADDRESS_PARAM = /* @__PURE__ */ new Set([
|
|
6262
6324
|
"balance_check",
|
|
6263
6325
|
"portfolio_analysis",
|
|
@@ -6325,7 +6387,8 @@ function createGuardRunnerState() {
|
|
|
6325
6387
|
balanceTracker: new BalanceTracker(),
|
|
6326
6388
|
retryTracker: new RetryTracker(),
|
|
6327
6389
|
swapQuoteTracker: new SwapQuoteTracker(),
|
|
6328
|
-
lastHealthFactor: null
|
|
6390
|
+
lastHealthFactor: null,
|
|
6391
|
+
trustedAddresses: /* @__PURE__ */ new Set()
|
|
6329
6392
|
};
|
|
6330
6393
|
}
|
|
6331
6394
|
function runGuards(tool, call, state, config, conversationContext, onGuardFired, identity) {
|
|
@@ -6399,7 +6462,8 @@ function runGuards(tool, call, state, config, conversationContext, onGuardFired,
|
|
|
6399
6462
|
call,
|
|
6400
6463
|
conversationContext.recentUserText,
|
|
6401
6464
|
identity?.contacts ?? [],
|
|
6402
|
-
identity?.walletAddress
|
|
6465
|
+
identity?.walletAddress,
|
|
6466
|
+
state.trustedAddresses
|
|
6403
6467
|
)
|
|
6404
6468
|
);
|
|
6405
6469
|
}
|
|
@@ -6531,7 +6595,9 @@ function microcompact(messages, tools) {
|
|
|
6531
6595
|
const cacheableByName = /* @__PURE__ */ new Map();
|
|
6532
6596
|
if (tools) {
|
|
6533
6597
|
for (const t of tools) {
|
|
6534
|
-
|
|
6598
|
+
const explicit = t.cacheable;
|
|
6599
|
+
const isMutating = t.flags?.mutating === true;
|
|
6600
|
+
cacheableByName.set(t.name, explicit ?? !isMutating);
|
|
6535
6601
|
}
|
|
6536
6602
|
}
|
|
6537
6603
|
const dedupedToolUseIds = /* @__PURE__ */ new Set();
|
|
@@ -8094,6 +8160,7 @@ ${recipeCtx}`;
|
|
|
8094
8160
|
if (signal.aborted) {
|
|
8095
8161
|
dispatcher.abort();
|
|
8096
8162
|
}
|
|
8163
|
+
const earlyConvCtx = extractConversationText(this.messages);
|
|
8097
8164
|
for await (const earlyEvent of dispatcher.collectResults()) {
|
|
8098
8165
|
if (earlyEvent.type === "tool_result") {
|
|
8099
8166
|
if (!earlyEvent.isError) {
|
|
@@ -8123,6 +8190,15 @@ ${recipeCtx}`;
|
|
|
8123
8190
|
earlyEvent.isError,
|
|
8124
8191
|
this.guardState
|
|
8125
8192
|
);
|
|
8193
|
+
if (!earlyEvent.isError) {
|
|
8194
|
+
extractTrustedAddressesFromResult(
|
|
8195
|
+
earlyEvent.toolName,
|
|
8196
|
+
earlyInput,
|
|
8197
|
+
earlyEvent.result,
|
|
8198
|
+
earlyConvCtx.recentUserText,
|
|
8199
|
+
this.guardState
|
|
8200
|
+
);
|
|
8201
|
+
}
|
|
8126
8202
|
let enrichedResult = earlyEvent.result;
|
|
8127
8203
|
if (this.guardConfig && !earlyEvent.isError && tool) {
|
|
8128
8204
|
const artifactInj = this.guardConfig.artifactPreview !== false ? guardArtifactPreview(earlyEvent.result) : null;
|
|
@@ -8330,6 +8406,7 @@ ${recipeCtx}`;
|
|
|
8330
8406
|
} else {
|
|
8331
8407
|
guardedApproved.push(...approved);
|
|
8332
8408
|
}
|
|
8409
|
+
const runConvCtx = extractConversationText(this.messages);
|
|
8333
8410
|
for await (const toolEvent of runTools(guardedApproved, this.tools, context, this.txMutex)) {
|
|
8334
8411
|
if (toolEvent.type === "tool_result" && !toolEvent.isError) {
|
|
8335
8412
|
const warning = flagSuspiciousResult(toolEvent.toolName, toolEvent.result);
|
|
@@ -8359,6 +8436,15 @@ ${recipeCtx}`;
|
|
|
8359
8436
|
toolEvent.isError,
|
|
8360
8437
|
this.guardState
|
|
8361
8438
|
);
|
|
8439
|
+
if (!toolEvent.isError) {
|
|
8440
|
+
extractTrustedAddressesFromResult(
|
|
8441
|
+
toolEvent.toolName,
|
|
8442
|
+
originalCall?.input ?? null,
|
|
8443
|
+
toolEvent.result,
|
|
8444
|
+
runConvCtx.recentUserText,
|
|
8445
|
+
this.guardState
|
|
8446
|
+
);
|
|
8447
|
+
}
|
|
8362
8448
|
let enrichedResult = toolEvent.result;
|
|
8363
8449
|
if (this.guardConfig && !toolEvent.isError && tool) {
|
|
8364
8450
|
const artifactInj = this.guardConfig.artifactPreview !== false ? guardArtifactPreview(toolEvent.result) : null;
|
|
@@ -10150,6 +10236,6 @@ function sanitizeAnthropicMessages(messages) {
|
|
|
10150
10236
|
return merged;
|
|
10151
10237
|
}
|
|
10152
10238
|
|
|
10153
|
-
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, DEFAULT_TOOL_TTL_MS, EFFORT_THINKING_BUDGET_CAPS, EarlyToolDispatcher, InMemoryDefiCacheStore, InMemoryFetchLock, InMemoryNaviCacheStore, InMemoryWalletCacheStore, InvalidAddressError, MAX_BUNDLE_OPS, 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, REGENERATABLE_READ_TOOLS, RecipeRegistry, RetryTracker, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SuinsNotRegisteredError, SuinsRpcError, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, TOOL_TTL_MS, TxMutex, VALID_PAIRS, WRITE_TOOLS, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, addRecipientTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, bundleShortestTtl, checkValidPair, claimRewardsTool, clampThinkingForEffort, classifyEffort, clearPortfolioCache, clearPortfolioCacheFor, clearPriceMapCache, compactMessages, composeBundleFromToolResults, computeRegenerateFields, createGuardRunnerState, engineToSSE, estimateTokens, explainTxTool, extractAllProactiveMarkers, 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, isBundleableTool, loadRecipes, looksLikeSuiNs, microcompact, mppServicesTool, naviKey, normalizeAddressInput, parseEvalSummary, parseMcpJson, parseProactiveMarker, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, regenerateBundle, 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, stripProactiveMarkers, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, updateTodoTool, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
10239
|
+
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, DEFAULT_TOOL_TTL_MS, EFFORT_THINKING_BUDGET_CAPS, EarlyToolDispatcher, InMemoryDefiCacheStore, InMemoryFetchLock, InMemoryNaviCacheStore, InMemoryWalletCacheStore, InvalidAddressError, MAX_BUNDLE_OPS, 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, REGENERATABLE_READ_TOOLS, RecipeRegistry, RetryTracker, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SuinsNotRegisteredError, SuinsRpcError, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, TOOL_TTL_MS, TxMutex, VALID_PAIRS, WRITE_TOOLS, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, addRecipientTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, bundleShortestTtl, checkValidPair, claimRewardsTool, clampThinkingForEffort, classifyEffort, clearPortfolioCache, clearPortfolioCacheFor, clearPriceMapCache, compactMessages, composeBundleFromToolResults, computeRegenerateFields, createGuardRunnerState, engineToSSE, estimateTokens, explainTxTool, extractAllProactiveMarkers, extractConversationText, extractMcpText, extractTrustedAddressesFromResult, 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, isBundleableTool, loadRecipes, looksLikeSuiNs, microcompact, mppServicesTool, naviKey, normalizeAddressInput, parseEvalSummary, parseMcpJson, parseProactiveMarker, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, regenerateBundle, 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, stripProactiveMarkers, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, updateTodoTool, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
10154
10240
|
//# sourceMappingURL=index.js.map
|
|
10155
10241
|
//# sourceMappingURL=index.js.map
|