@t2000/engine 0.35.2 → 0.36.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/README.md +43 -3
- package/dist/index.d.ts +47 -1
- package/dist/index.js +158 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -87,7 +87,7 @@ QueryEngine.submitMessage()
|
|
|
87
87
|
|
|
88
88
|
## Built-in Tools
|
|
89
89
|
|
|
90
|
-
### Read Tools (
|
|
90
|
+
### Read Tools (38 — parallel, auto-approved)
|
|
91
91
|
|
|
92
92
|
| Tool | Description |
|
|
93
93
|
|------|-------------|
|
|
@@ -120,8 +120,17 @@ QueryEngine.submitMessage()
|
|
|
120
120
|
| `toggle_allowance` | Pause or resume agent autonomous spending |
|
|
121
121
|
| `update_daily_limit` | Change the daily USDC spending cap |
|
|
122
122
|
| `update_permissions` | Update which service categories the agent can act on |
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
| `spending_analytics` | Spending breakdown by service/category over time period |
|
|
124
|
+
| `yield_summary` | Yield earned + projections with sparkline data |
|
|
125
|
+
| `activity_summary` | Activity breakdown by action type |
|
|
126
|
+
| `create_schedule` | Create a recurring scheduled action (DCA) |
|
|
127
|
+
| `list_schedules` | List scheduled actions with trust stage |
|
|
128
|
+
| `cancel_schedule` | Cancel a scheduled action |
|
|
129
|
+
| `render_canvas` | Generate interactive HTML canvas visualizations |
|
|
130
|
+
| `pattern_status` | View behavioral pattern proposals and trust stage |
|
|
131
|
+
| `record_advice` | Record financial advice given for outcome tracking |
|
|
132
|
+
|
|
133
|
+
### Write Tools (12 — serial, confirmation required)
|
|
125
134
|
|
|
126
135
|
| Tool | Description |
|
|
127
136
|
|------|-------------|
|
|
@@ -136,6 +145,34 @@ QueryEngine.submitMessage()
|
|
|
136
145
|
| `volo_stake` | Stake SUI for vSUI (VOLO liquid staking) |
|
|
137
146
|
| `volo_unstake` | Unstake vSUI back to SUI |
|
|
138
147
|
| `save_contact` | Save a contact name + address for quick sends |
|
|
148
|
+
| `pause_pattern` | Pause an autonomous behavioral pattern |
|
|
149
|
+
|
|
150
|
+
## Audric 2.0 Engine Features
|
|
151
|
+
|
|
152
|
+
### Streaming Tool Execution (Early Dispatch)
|
|
153
|
+
|
|
154
|
+
`EarlyToolDispatcher` dispatches read-only tools mid-stream before `message_stop`. Tools with `isReadOnly && isConcurrencySafe` fire as soon as their `tool_use` block completes. Write tools still go through the permission gate.
|
|
155
|
+
|
|
156
|
+
### Tool Result Budgeting
|
|
157
|
+
|
|
158
|
+
Tools can set `maxResultSizeChars` to cap output size. Results exceeding the limit are truncated with a hint to narrow parameters. Custom `summarizeOnTruncate` callbacks supported.
|
|
159
|
+
|
|
160
|
+
### Microcompact
|
|
161
|
+
|
|
162
|
+
`microcompact(messages)` deduplicates identical tool calls (same name + input) in conversation history, replacing repeated results with `[Same result as turn N]`.
|
|
163
|
+
|
|
164
|
+
### Granular Permissions (USD-aware)
|
|
165
|
+
|
|
166
|
+
Write tool permission resolved dynamically via `resolvePermissionTier(operation, amountUsd, config)`. Small amounts auto-execute; large amounts require confirmation. Three presets: `conservative`, `balanced`, `aggressive`.
|
|
167
|
+
|
|
168
|
+
### Reasoning Engine
|
|
169
|
+
|
|
170
|
+
- **Adaptive thinking** — routes queries to `low`/`medium`/`high` effort based on financial complexity
|
|
171
|
+
- **Guard runner** — 9 guards across 3 priority tiers (Safety > Financial > UX)
|
|
172
|
+
- **Skill recipes** — YAML recipe files with longest-trigger-match-wins
|
|
173
|
+
- **Context compaction** — 200k limit, 85% compact trigger, LLM summarizer fallback
|
|
174
|
+
- **Tool flags** — `mutating`, `requiresBalance`, `affectsHealth`, `irreversible` etc.
|
|
175
|
+
- **Preflight validation** — input validation on `send_transfer`, `swap_execute`, `pay_api`, `borrow`, `save_deposit`
|
|
139
176
|
|
|
140
177
|
## Configuration
|
|
141
178
|
|
|
@@ -165,9 +202,12 @@ The `submitMessage()` async generator yields `EngineEvent`:
|
|
|
165
202
|
| Event | Fields | When |
|
|
166
203
|
|-------|--------|------|
|
|
167
204
|
| `text_delta` | `text` | LLM streams a text chunk |
|
|
205
|
+
| `thinking_delta` | `text` | Extended thinking chunk (reasoning accordion) |
|
|
206
|
+
| `thinking_done` | — | Extended thinking complete |
|
|
168
207
|
| `tool_start` | `toolName`, `toolUseId`, `input` | Tool execution begins |
|
|
169
208
|
| `tool_result` | `toolName`, `toolUseId`, `result`, `isError` | Tool execution completes |
|
|
170
209
|
| `pending_action` | `action` (PendingAction) | Write tool awaiting client-side execution |
|
|
210
|
+
| `canvas` | `html` | Interactive HTML visualization from `render_canvas` |
|
|
171
211
|
| `turn_complete` | `stopReason` | Conversation turn finished |
|
|
172
212
|
| `usage` | `inputTokens`, `outputTokens`, `cacheReadTokens?`, `cacheWriteTokens?` | Token usage report |
|
|
173
213
|
| `error` | `error` | Unrecoverable error |
|
package/dist/index.d.ts
CHANGED
|
@@ -1719,6 +1719,52 @@ declare const activitySummaryTool: Tool<{
|
|
|
1719
1719
|
period?: "month" | "year" | "all" | "week" | undefined;
|
|
1720
1720
|
}, ActivitySummary>;
|
|
1721
1721
|
|
|
1722
|
+
declare const patternStatusTool: Tool<{}, {
|
|
1723
|
+
patterns: {
|
|
1724
|
+
id: string;
|
|
1725
|
+
actionType: string;
|
|
1726
|
+
amount: number;
|
|
1727
|
+
asset: string;
|
|
1728
|
+
cronExpr: string;
|
|
1729
|
+
enabled: boolean;
|
|
1730
|
+
nextRunAt: string;
|
|
1731
|
+
source: string;
|
|
1732
|
+
stage: number;
|
|
1733
|
+
patternType: string | null;
|
|
1734
|
+
confidence: number | null;
|
|
1735
|
+
pausedAt: string | null;
|
|
1736
|
+
totalExecutions: number;
|
|
1737
|
+
totalAmountUsdc: number;
|
|
1738
|
+
confirmationsCompleted: number;
|
|
1739
|
+
confirmationsRequired: number;
|
|
1740
|
+
}[];
|
|
1741
|
+
userCreated: {
|
|
1742
|
+
id: string;
|
|
1743
|
+
actionType: string;
|
|
1744
|
+
amount: number;
|
|
1745
|
+
asset: string;
|
|
1746
|
+
cronExpr: string;
|
|
1747
|
+
enabled: boolean;
|
|
1748
|
+
nextRunAt: string;
|
|
1749
|
+
source: string;
|
|
1750
|
+
stage: number;
|
|
1751
|
+
patternType: string | null;
|
|
1752
|
+
confidence: number | null;
|
|
1753
|
+
pausedAt: string | null;
|
|
1754
|
+
totalExecutions: number;
|
|
1755
|
+
totalAmountUsdc: number;
|
|
1756
|
+
confirmationsCompleted: number;
|
|
1757
|
+
confirmationsRequired: number;
|
|
1758
|
+
}[];
|
|
1759
|
+
} | null>;
|
|
1760
|
+
declare const pausePatternTool: Tool<{
|
|
1761
|
+
action: "pause" | "resume" | "disable";
|
|
1762
|
+
patternId: string;
|
|
1763
|
+
}, {
|
|
1764
|
+
id: string;
|
|
1765
|
+
action: "pause" | "resume" | "disable";
|
|
1766
|
+
} | null>;
|
|
1767
|
+
|
|
1722
1768
|
declare const defillamaYieldPoolsTool: Tool<{
|
|
1723
1769
|
limit?: number | undefined;
|
|
1724
1770
|
chain?: string | undefined;
|
|
@@ -1834,4 +1880,4 @@ declare function clearPriceCache(): void;
|
|
|
1834
1880
|
|
|
1835
1881
|
declare const DEFAULT_SYSTEM_PROMPT = "You are a financial agent on Sui. You manage money and access paid APIs via MPP micropayments.\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- Lead with the result. After tool calls, state the outcome with real numbers. Done.\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## 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 broad market data (yields across protocols, token prices, TVL, protocol comparisons), use defillama_* tools.\n- To discover Sui protocols, use defillama_sui_protocols first, then defillama_protocol_info 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 only (critical)\n- save_deposit accepts ONLY USDC. No other token can be deposited into savings.\n- When asked \"how much can I save?\", report only the user's USDC wallet balance (saveableUsdc field from balance_check). Other tokens like GOLD, SUI, USDT are NOT saveable and NOT savings positions \u2014 they are just wallet holdings.\n- NEVER say a non-USDC token is \"in savings\" or \"earning APY in savings\" unless it appears in the savings_info positions list. Wallet holdings \u2260 savings.\n- If user wants to save non-USDC tokens, tell them to swap to USDC first. Do NOT auto-chain swap + deposit.\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\": defillama_token_prices \u2192 calculate amount \u2192 swap_execute.\n- \"Best yield on SUI\": compare rates_info (NAVI lending) + defillama_yield_pools (broader) + volo_stats.\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 is USDC only.\n- \"What protocols are on Sui?\": defillama_sui_protocols \u2192 defillama_protocol_info for details.\n\n## Safety\n- Never encourage risky financial behavior.\n- Warn when health factor < 1.5.\n- All amounts in USDC unless stated otherwise.";
|
|
1836
1882
|
|
|
1837
|
-
export { AnthropicProvider, type AnthropicProviderConfig, 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, 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 PendingReward, type PendingToolCall, type PermissionLevel, type PermissionOperation, type PermissionResponse, type PermissionRule, 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, 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, clearPriceCache, compactMessages, createGuardRunnerState, defillamaChainTvlTool, defillamaPriceChangeTool, defillamaProtocolFeesTool, defillamaProtocolInfoTool, defillamaSuiProtocolsTool, defillamaTokenPricesTool, defillamaYieldPoolsTool, engineToSSE, estimateTokens, explainTxTool, extractConversationText, extractMcpText, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getDefaultTools, getMcpManager, 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, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
1883
|
+
export { AnthropicProvider, type AnthropicProviderConfig, 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, 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 PendingReward, type PendingToolCall, type PermissionLevel, type PermissionOperation, type PermissionResponse, type PermissionRule, 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, 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, clearPriceCache, compactMessages, createGuardRunnerState, defillamaChainTvlTool, defillamaPriceChangeTool, defillamaProtocolFeesTool, defillamaProtocolInfoTool, defillamaSuiProtocolsTool, defillamaTokenPricesTool, defillamaYieldPoolsTool, engineToSSE, estimateTokens, explainTxTool, extractConversationText, extractMcpText, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getDefaultTools, getMcpManager, getToolFlags, getWalletAddress, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, microcompact, mppServicesTool, parseMcpJson, parseRecipe, parseSSE, patternStatusTool, pausePatternTool, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resolvePermissionTier, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
package/dist/index.js
CHANGED
|
@@ -3220,6 +3220,130 @@ var cancelScheduleTool = buildTool({
|
|
|
3220
3220
|
}
|
|
3221
3221
|
}
|
|
3222
3222
|
});
|
|
3223
|
+
var STAGE_LABELS = {
|
|
3224
|
+
0: "Detected",
|
|
3225
|
+
1: "Proposed",
|
|
3226
|
+
2: "Confirmed (notifies)",
|
|
3227
|
+
3: "Fully autonomous"
|
|
3228
|
+
};
|
|
3229
|
+
var PATTERN_LABELS = {
|
|
3230
|
+
recurring_save: "Recurring Save",
|
|
3231
|
+
yield_reinvestment: "Yield Reinvestment",
|
|
3232
|
+
debt_discipline: "Debt Discipline",
|
|
3233
|
+
idle_usdc_tolerance: "Idle USDC Sweep",
|
|
3234
|
+
swap_pattern: "Regular Swap"
|
|
3235
|
+
};
|
|
3236
|
+
function getApiConfig2(context) {
|
|
3237
|
+
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
3238
|
+
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
3239
|
+
const address = context.walletAddress;
|
|
3240
|
+
return { apiUrl, internalKey, address };
|
|
3241
|
+
}
|
|
3242
|
+
var patternStatusTool = buildTool({
|
|
3243
|
+
name: "pattern_status",
|
|
3244
|
+
description: "Show all detected behavioral patterns and autonomous automations for this user. Includes pattern type, trust stage, execution count, and next scheduled run.",
|
|
3245
|
+
inputSchema: z.object({}),
|
|
3246
|
+
jsonSchema: { type: "object", properties: {}, required: [] },
|
|
3247
|
+
isReadOnly: true,
|
|
3248
|
+
permissionLevel: "auto",
|
|
3249
|
+
async call(_input, context) {
|
|
3250
|
+
const { apiUrl, internalKey, address } = getApiConfig2(context);
|
|
3251
|
+
if (!apiUrl || !address) {
|
|
3252
|
+
return { data: null, displayText: "Pattern status is not available." };
|
|
3253
|
+
}
|
|
3254
|
+
try {
|
|
3255
|
+
const res = await fetch(`${apiUrl}/api/scheduled-actions?address=${address}`, {
|
|
3256
|
+
headers: {
|
|
3257
|
+
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
3258
|
+
}
|
|
3259
|
+
});
|
|
3260
|
+
if (!res.ok) {
|
|
3261
|
+
return { data: null, displayText: "Failed to fetch pattern status." };
|
|
3262
|
+
}
|
|
3263
|
+
const { actions } = await res.json();
|
|
3264
|
+
const patterns = actions.filter((a) => a.source === "behavior_detected");
|
|
3265
|
+
const userCreated = actions.filter((a) => a.source !== "behavior_detected");
|
|
3266
|
+
if (patterns.length === 0 && userCreated.length === 0) {
|
|
3267
|
+
return {
|
|
3268
|
+
data: { patterns: [], userCreated: [] },
|
|
3269
|
+
displayText: "No automations or detected patterns yet. As you use Audric, I'll learn your financial patterns and suggest automations."
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
const lines = [];
|
|
3273
|
+
if (patterns.length > 0) {
|
|
3274
|
+
lines.push("**Detected Patterns:**");
|
|
3275
|
+
for (const p of patterns) {
|
|
3276
|
+
const label = PATTERN_LABELS[p.patternType ?? ""] ?? p.patternType ?? "Unknown";
|
|
3277
|
+
const stage = STAGE_LABELS[p.stage] ?? `Stage ${p.stage}`;
|
|
3278
|
+
const status = p.pausedAt ? "Paused" : !p.enabled ? "Disabled" : stage;
|
|
3279
|
+
const next = p.enabled && !p.pausedAt ? new Date(p.nextRunAt).toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" }) : "\u2014";
|
|
3280
|
+
lines.push(`\u2022 ${label}: auto-${p.actionType} $${p.amount} ${p.asset} \u2014 ${status} \u2014 ${p.totalExecutions} runs \u2014 next: ${next}`);
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
if (userCreated.length > 0) {
|
|
3284
|
+
lines.push("");
|
|
3285
|
+
lines.push("**User-Created Schedules:**");
|
|
3286
|
+
for (const a of userCreated) {
|
|
3287
|
+
const status = !a.enabled ? "paused" : a.confirmationsCompleted >= a.confirmationsRequired ? "autonomous" : `${a.confirmationsCompleted}/${a.confirmationsRequired} confirmed`;
|
|
3288
|
+
const next = new Date(a.nextRunAt).toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" });
|
|
3289
|
+
lines.push(`\u2022 ${a.actionType} $${a.amount} ${a.asset} \u2014 ${status} \u2014 next: ${next}`);
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
return {
|
|
3293
|
+
data: { patterns, userCreated },
|
|
3294
|
+
displayText: lines.join("\n")
|
|
3295
|
+
};
|
|
3296
|
+
} catch (err) {
|
|
3297
|
+
return { data: null, displayText: `Failed: ${err instanceof Error ? err.message : "unknown error"}` };
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
});
|
|
3301
|
+
var pausePatternTool = buildTool({
|
|
3302
|
+
name: "pause_pattern",
|
|
3303
|
+
description: "Pause, resume, or permanently disable a behavioral pattern automation. Requires user confirmation.",
|
|
3304
|
+
inputSchema: z.object({
|
|
3305
|
+
patternId: z.string().describe("ID of the pattern/scheduled action to modify"),
|
|
3306
|
+
action: z.enum(["pause", "resume", "disable"]).describe("pause, resume, or disable")
|
|
3307
|
+
}),
|
|
3308
|
+
jsonSchema: {
|
|
3309
|
+
type: "object",
|
|
3310
|
+
properties: {
|
|
3311
|
+
patternId: { type: "string", description: "Pattern ID" },
|
|
3312
|
+
action: { type: "string", enum: ["pause", "resume", "disable"], description: "pause, resume, or disable" }
|
|
3313
|
+
},
|
|
3314
|
+
required: ["patternId", "action"]
|
|
3315
|
+
},
|
|
3316
|
+
isReadOnly: false,
|
|
3317
|
+
permissionLevel: "confirm",
|
|
3318
|
+
async call(input, context) {
|
|
3319
|
+
const { apiUrl, internalKey, address } = getApiConfig2(context);
|
|
3320
|
+
if (!apiUrl || !address) {
|
|
3321
|
+
return { data: null, displayText: "Pattern management is not available." };
|
|
3322
|
+
}
|
|
3323
|
+
const patchAction = input.action === "pause" ? "pause_pattern" : input.action === "resume" ? "resume_pattern" : "delete";
|
|
3324
|
+
try {
|
|
3325
|
+
const res = await fetch(`${apiUrl}/api/scheduled-actions/${input.patternId}`, {
|
|
3326
|
+
method: "PATCH",
|
|
3327
|
+
headers: {
|
|
3328
|
+
"Content-Type": "application/json",
|
|
3329
|
+
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
3330
|
+
},
|
|
3331
|
+
body: JSON.stringify({ address, action: patchAction })
|
|
3332
|
+
});
|
|
3333
|
+
if (!res.ok) {
|
|
3334
|
+
const err = await res.json().catch(() => ({}));
|
|
3335
|
+
return { data: null, displayText: `Failed to ${input.action}: ${err.error ?? res.statusText}` };
|
|
3336
|
+
}
|
|
3337
|
+
const label = input.action === "pause" ? "Paused" : input.action === "resume" ? "Resumed" : "Disabled";
|
|
3338
|
+
return {
|
|
3339
|
+
data: { id: input.patternId, action: input.action },
|
|
3340
|
+
displayText: `${label} pattern ${input.patternId.slice(0, 8)}\u2026`
|
|
3341
|
+
};
|
|
3342
|
+
} catch (err) {
|
|
3343
|
+
return { data: null, displayText: `Failed: ${err instanceof Error ? err.message : "unknown error"}` };
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
});
|
|
3223
3347
|
var LLAMA_API2 = "https://api.llama.fi";
|
|
3224
3348
|
var YIELDS_API2 = "https://yields.llama.fi";
|
|
3225
3349
|
var COINS_API = "https://coins.llama.fi";
|
|
@@ -3541,7 +3665,8 @@ var READ_TOOLS = [
|
|
|
3541
3665
|
activitySummaryTool,
|
|
3542
3666
|
listSchedulesTool,
|
|
3543
3667
|
createScheduleTool,
|
|
3544
|
-
cancelScheduleTool
|
|
3668
|
+
cancelScheduleTool,
|
|
3669
|
+
patternStatusTool
|
|
3545
3670
|
];
|
|
3546
3671
|
var WRITE_TOOLS = [
|
|
3547
3672
|
saveDepositTool,
|
|
@@ -3554,7 +3679,8 @@ var WRITE_TOOLS = [
|
|
|
3554
3679
|
swapExecuteTool,
|
|
3555
3680
|
voloStakeTool,
|
|
3556
3681
|
voloUnstakeTool,
|
|
3557
|
-
saveContactTool
|
|
3682
|
+
saveContactTool,
|
|
3683
|
+
pausePatternTool
|
|
3558
3684
|
];
|
|
3559
3685
|
function getDefaultTools() {
|
|
3560
3686
|
return applyToolFlags([...READ_TOOLS, ...WRITE_TOOLS]);
|
|
@@ -4678,24 +4804,46 @@ ${recipeCtx}`;
|
|
|
4678
4804
|
continue;
|
|
4679
4805
|
}
|
|
4680
4806
|
}
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4807
|
+
const tool = findTool(this.tools, earlyEvent.toolName);
|
|
4808
|
+
updateGuardStateAfterToolResult(
|
|
4809
|
+
earlyEvent.toolName,
|
|
4810
|
+
tool,
|
|
4811
|
+
null,
|
|
4812
|
+
earlyEvent.result,
|
|
4813
|
+
earlyEvent.isError,
|
|
4814
|
+
this.guardState
|
|
4815
|
+
);
|
|
4816
|
+
let enrichedResult = earlyEvent.result;
|
|
4817
|
+
if (this.guardConfig && !earlyEvent.isError && tool) {
|
|
4818
|
+
const artifactInj = this.guardConfig.artifactPreview !== false ? guardArtifactPreview(earlyEvent.result) : null;
|
|
4819
|
+
const staleInj = this.guardConfig.staleData !== false ? guardStaleData(tool.flags) : null;
|
|
4820
|
+
const allInjections = [
|
|
4821
|
+
...artifactInj ? [artifactInj] : [],
|
|
4822
|
+
...staleInj ? [staleInj] : []
|
|
4823
|
+
];
|
|
4824
|
+
if (allInjections.length > 0 && typeof enrichedResult === "object" && enrichedResult) {
|
|
4825
|
+
enrichedResult = { ...enrichedResult, _guards: allInjections };
|
|
4826
|
+
}
|
|
4827
|
+
}
|
|
4828
|
+
const finalEvent = enrichedResult !== earlyEvent.result ? { ...earlyEvent, result: enrichedResult } : earlyEvent;
|
|
4829
|
+
yield finalEvent;
|
|
4830
|
+
if (!finalEvent.isError) {
|
|
4831
|
+
const r = finalEvent.result;
|
|
4684
4832
|
if (r && r.__canvas === true) {
|
|
4685
4833
|
yield {
|
|
4686
4834
|
type: "canvas",
|
|
4687
4835
|
template: String(r.template ?? ""),
|
|
4688
4836
|
title: String(r.title ?? ""),
|
|
4689
4837
|
data: r.templateData ?? null,
|
|
4690
|
-
toolUseId:
|
|
4838
|
+
toolUseId: finalEvent.toolUseId
|
|
4691
4839
|
};
|
|
4692
4840
|
}
|
|
4693
4841
|
}
|
|
4694
4842
|
earlyResultBlocks.push({
|
|
4695
4843
|
type: "tool_result",
|
|
4696
|
-
toolUseId:
|
|
4697
|
-
content: JSON.stringify(
|
|
4698
|
-
isError:
|
|
4844
|
+
toolUseId: finalEvent.toolUseId,
|
|
4845
|
+
content: JSON.stringify(finalEvent.result),
|
|
4846
|
+
isError: finalEvent.isError
|
|
4699
4847
|
});
|
|
4700
4848
|
}
|
|
4701
4849
|
}
|
|
@@ -6059,6 +6207,6 @@ function sanitizeAnthropicMessages(messages) {
|
|
|
6059
6207
|
return merged;
|
|
6060
6208
|
}
|
|
6061
6209
|
|
|
6062
|
-
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, TxMutex, WRITE_TOOLS, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, claimRewardsTool, classifyEffort, clearPriceCache, compactMessages, createGuardRunnerState, defillamaChainTvlTool, defillamaPriceChangeTool, defillamaProtocolFeesTool, defillamaProtocolInfoTool, defillamaSuiProtocolsTool, defillamaTokenPricesTool, defillamaYieldPoolsTool, engineToSSE, estimateTokens, explainTxTool, extractConversationText, extractMcpText, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getDefaultTools, getMcpManager, 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, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
6210
|
+
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, TxMutex, WRITE_TOOLS, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, claimRewardsTool, classifyEffort, clearPriceCache, compactMessages, createGuardRunnerState, defillamaChainTvlTool, defillamaPriceChangeTool, defillamaProtocolFeesTool, defillamaProtocolInfoTool, defillamaSuiProtocolsTool, defillamaTokenPricesTool, defillamaYieldPoolsTool, engineToSSE, estimateTokens, explainTxTool, extractConversationText, extractMcpText, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getDefaultTools, getMcpManager, getToolFlags, getWalletAddress, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, microcompact, mppServicesTool, parseMcpJson, parseRecipe, parseSSE, patternStatusTool, pausePatternTool, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resolvePermissionTier, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
6063
6211
|
//# sourceMappingURL=index.js.map
|
|
6064
6212
|
//# sourceMappingURL=index.js.map
|