@t2000/engine 0.31.3 → 0.32.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 +316 -16
- package/dist/index.js +800 -32
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,116 @@ import { Tool as Tool$1 } from '@modelcontextprotocol/sdk/types.js';
|
|
|
5
5
|
import * as _t2000_sdk from '@t2000/sdk';
|
|
6
6
|
import { T2000 } from '@t2000/sdk';
|
|
7
7
|
|
|
8
|
+
interface PendingToolCall {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
input: unknown;
|
|
12
|
+
}
|
|
13
|
+
declare class TxMutex {
|
|
14
|
+
private queue;
|
|
15
|
+
private locked;
|
|
16
|
+
acquire(): Promise<void>;
|
|
17
|
+
release(): void;
|
|
18
|
+
}
|
|
19
|
+
declare function runTools(pending: PendingToolCall[], tools: Tool[], context: ToolContext, txMutex: TxMutex): AsyncGenerator<EngineEvent>;
|
|
20
|
+
|
|
21
|
+
type GuardVerdict = 'pass' | 'hint' | 'warn' | 'block';
|
|
22
|
+
type GuardTier = 'safety' | 'financial' | 'ux';
|
|
23
|
+
interface GuardResult {
|
|
24
|
+
verdict: GuardVerdict;
|
|
25
|
+
gate: string;
|
|
26
|
+
tier: GuardTier;
|
|
27
|
+
message?: string;
|
|
28
|
+
}
|
|
29
|
+
interface GuardInjection {
|
|
30
|
+
_gate: string;
|
|
31
|
+
_hint?: string;
|
|
32
|
+
_warning?: string;
|
|
33
|
+
_error?: string;
|
|
34
|
+
}
|
|
35
|
+
interface GuardCheckResult {
|
|
36
|
+
blocked: boolean;
|
|
37
|
+
blockReason?: string;
|
|
38
|
+
blockGate?: string;
|
|
39
|
+
injections: GuardInjection[];
|
|
40
|
+
events: GuardEvent[];
|
|
41
|
+
}
|
|
42
|
+
interface GuardEvent {
|
|
43
|
+
timestamp: number;
|
|
44
|
+
toolName: string;
|
|
45
|
+
toolUseId: string;
|
|
46
|
+
gate: string;
|
|
47
|
+
verdict: GuardVerdict;
|
|
48
|
+
tier: GuardTier;
|
|
49
|
+
message?: string;
|
|
50
|
+
}
|
|
51
|
+
interface GuardConfig {
|
|
52
|
+
balanceValidation?: boolean;
|
|
53
|
+
healthFactor?: {
|
|
54
|
+
warnBelow: number;
|
|
55
|
+
blockBelow: number;
|
|
56
|
+
} | false;
|
|
57
|
+
largeTransfer?: {
|
|
58
|
+
warnAbove: number;
|
|
59
|
+
strongWarnAbove: number;
|
|
60
|
+
} | false;
|
|
61
|
+
slippage?: boolean;
|
|
62
|
+
staleData?: boolean;
|
|
63
|
+
irreversibility?: boolean;
|
|
64
|
+
artifactPreview?: boolean;
|
|
65
|
+
costWarning?: boolean;
|
|
66
|
+
retryProtection?: boolean;
|
|
67
|
+
inputValidation?: boolean;
|
|
68
|
+
}
|
|
69
|
+
declare const DEFAULT_GUARD_CONFIG: GuardConfig;
|
|
70
|
+
declare class BalanceTracker {
|
|
71
|
+
private lastBalanceAt;
|
|
72
|
+
private lastWriteAt;
|
|
73
|
+
recordRead(): void;
|
|
74
|
+
recordWrite(): void;
|
|
75
|
+
isStale(): boolean;
|
|
76
|
+
hasEverRead(): boolean;
|
|
77
|
+
}
|
|
78
|
+
declare class RetryTracker {
|
|
79
|
+
private executed;
|
|
80
|
+
private key;
|
|
81
|
+
record(toolName: string, input: unknown, result: unknown): void;
|
|
82
|
+
isBlocked(toolName: string, input: unknown): {
|
|
83
|
+
blocked: boolean;
|
|
84
|
+
previousResult?: unknown;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
declare function guardArtifactPreview(result: unknown): GuardInjection | null;
|
|
88
|
+
declare function guardStaleData(toolFlags: ToolFlags): GuardInjection | null;
|
|
89
|
+
interface GuardRunnerState {
|
|
90
|
+
balanceTracker: BalanceTracker;
|
|
91
|
+
retryTracker: RetryTracker;
|
|
92
|
+
lastHealthFactor: number | null;
|
|
93
|
+
}
|
|
94
|
+
declare function createGuardRunnerState(): GuardRunnerState;
|
|
95
|
+
declare function runGuards(tool: Tool, call: PendingToolCall, state: GuardRunnerState, config: GuardConfig, conversationContext: {
|
|
96
|
+
fullText: string;
|
|
97
|
+
lastAssistantText: string;
|
|
98
|
+
}): GuardCheckResult;
|
|
99
|
+
declare function updateGuardStateAfterToolResult(toolName: string, tool: Tool | undefined, input: unknown, result: unknown, isError: boolean, state: GuardRunnerState): void;
|
|
100
|
+
declare function extractConversationText(messages: Array<{
|
|
101
|
+
role: string;
|
|
102
|
+
content: unknown;
|
|
103
|
+
}>): {
|
|
104
|
+
fullText: string;
|
|
105
|
+
lastAssistantText: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
8
108
|
type ContentBlock = {
|
|
9
109
|
type: 'text';
|
|
10
110
|
text: string;
|
|
111
|
+
} | {
|
|
112
|
+
type: 'thinking';
|
|
113
|
+
thinking: string;
|
|
114
|
+
signature: string;
|
|
115
|
+
} | {
|
|
116
|
+
type: 'redacted_thinking';
|
|
117
|
+
data: string;
|
|
11
118
|
} | {
|
|
12
119
|
type: 'tool_use';
|
|
13
120
|
id: string;
|
|
@@ -24,6 +131,12 @@ interface Message {
|
|
|
24
131
|
content: ContentBlock[];
|
|
25
132
|
}
|
|
26
133
|
type EngineEvent = {
|
|
134
|
+
type: 'thinking_delta';
|
|
135
|
+
text: string;
|
|
136
|
+
} | {
|
|
137
|
+
type: 'thinking_done';
|
|
138
|
+
signature?: string;
|
|
139
|
+
} | {
|
|
27
140
|
type: 'text_delta';
|
|
28
141
|
text: string;
|
|
29
142
|
} | {
|
|
@@ -78,6 +191,12 @@ interface PendingAction {
|
|
|
78
191
|
content: string;
|
|
79
192
|
isError: boolean;
|
|
80
193
|
}>;
|
|
194
|
+
/** Guard injections (hints/warnings) from pre-execution checks. */
|
|
195
|
+
guardInjections?: Array<{
|
|
196
|
+
_gate: string;
|
|
197
|
+
_hint?: string;
|
|
198
|
+
_warning?: string;
|
|
199
|
+
}>;
|
|
81
200
|
}
|
|
82
201
|
/**
|
|
83
202
|
* Response from the client when resolving a pending action.
|
|
@@ -132,6 +251,21 @@ interface ToolJsonSchema {
|
|
|
132
251
|
properties: Record<string, unknown>;
|
|
133
252
|
required?: string[];
|
|
134
253
|
}
|
|
254
|
+
interface ToolFlags {
|
|
255
|
+
mutating?: boolean;
|
|
256
|
+
requiresBalance?: boolean;
|
|
257
|
+
affectsHealth?: boolean;
|
|
258
|
+
irreversible?: boolean;
|
|
259
|
+
producesArtifact?: boolean;
|
|
260
|
+
costAware?: boolean;
|
|
261
|
+
maxRetries?: number;
|
|
262
|
+
}
|
|
263
|
+
type PreflightResult = {
|
|
264
|
+
valid: true;
|
|
265
|
+
} | {
|
|
266
|
+
valid: false;
|
|
267
|
+
error: string;
|
|
268
|
+
};
|
|
135
269
|
interface Tool<TInput = unknown, TOutput = unknown> {
|
|
136
270
|
name: string;
|
|
137
271
|
description: string;
|
|
@@ -141,7 +275,31 @@ interface Tool<TInput = unknown, TOutput = unknown> {
|
|
|
141
275
|
isConcurrencySafe: boolean;
|
|
142
276
|
isReadOnly: boolean;
|
|
143
277
|
permissionLevel: PermissionLevel;
|
|
278
|
+
flags: ToolFlags;
|
|
279
|
+
preflight?: (input: unknown) => PreflightResult;
|
|
280
|
+
}
|
|
281
|
+
type ThinkingEffort = 'low' | 'medium' | 'high' | 'max';
|
|
282
|
+
type ThinkingConfig = {
|
|
283
|
+
type: 'disabled';
|
|
284
|
+
} | {
|
|
285
|
+
type: 'adaptive';
|
|
286
|
+
display?: 'summarized' | 'omitted';
|
|
287
|
+
} | {
|
|
288
|
+
type: 'enabled';
|
|
289
|
+
budgetTokens: number;
|
|
290
|
+
display?: 'summarized' | 'omitted';
|
|
291
|
+
};
|
|
292
|
+
interface OutputConfig {
|
|
293
|
+
effort?: ThinkingEffort;
|
|
144
294
|
}
|
|
295
|
+
interface SystemBlock {
|
|
296
|
+
type: 'text';
|
|
297
|
+
text: string;
|
|
298
|
+
cache_control?: {
|
|
299
|
+
type: 'ephemeral';
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
type SystemPrompt = string | SystemBlock[];
|
|
145
303
|
interface EngineConfig {
|
|
146
304
|
provider: LLMProvider;
|
|
147
305
|
agent?: unknown;
|
|
@@ -152,13 +310,15 @@ interface EngineConfig {
|
|
|
152
310
|
/** Fresh on-chain position reader — called per tool invocation, bypasses MCP caching. */
|
|
153
311
|
positionFetcher?: (address: string) => Promise<ServerPositionData>;
|
|
154
312
|
tools?: Tool[];
|
|
155
|
-
systemPrompt?:
|
|
313
|
+
systemPrompt?: SystemPrompt;
|
|
156
314
|
model?: string;
|
|
157
315
|
maxTurns?: number;
|
|
158
316
|
maxTokens?: number;
|
|
159
317
|
temperature?: number;
|
|
160
318
|
/** Force tool usage on the first LLM turn (prevents text-only refusals). */
|
|
161
319
|
toolChoice?: ToolChoice;
|
|
320
|
+
thinking?: ThinkingConfig;
|
|
321
|
+
outputConfig?: OutputConfig;
|
|
162
322
|
/** Environment variables forwarded to tool context (API keys, URLs). */
|
|
163
323
|
env?: Record<string, string>;
|
|
164
324
|
costTracker?: {
|
|
@@ -166,6 +326,8 @@ interface EngineConfig {
|
|
|
166
326
|
inputCostPerToken?: number;
|
|
167
327
|
outputCostPerToken?: number;
|
|
168
328
|
};
|
|
329
|
+
/** Guard runner configuration (RE-2.2). Omit to disable guards. */
|
|
330
|
+
guards?: GuardConfig;
|
|
169
331
|
}
|
|
170
332
|
interface LLMProvider {
|
|
171
333
|
chat(params: ChatParams): AsyncGenerator<ProviderEvent>;
|
|
@@ -176,12 +338,14 @@ type ToolChoice = 'auto' | 'any' | {
|
|
|
176
338
|
};
|
|
177
339
|
interface ChatParams {
|
|
178
340
|
messages: Message[];
|
|
179
|
-
systemPrompt:
|
|
341
|
+
systemPrompt: SystemPrompt;
|
|
180
342
|
tools: ToolDefinition[];
|
|
181
343
|
model?: string;
|
|
182
344
|
maxTokens?: number;
|
|
183
345
|
temperature?: number;
|
|
184
346
|
toolChoice?: ToolChoice;
|
|
347
|
+
thinking?: ThinkingConfig;
|
|
348
|
+
outputConfig?: OutputConfig;
|
|
185
349
|
signal?: AbortSignal;
|
|
186
350
|
}
|
|
187
351
|
interface ToolDefinition {
|
|
@@ -190,6 +354,16 @@ interface ToolDefinition {
|
|
|
190
354
|
input_schema: ToolJsonSchema;
|
|
191
355
|
}
|
|
192
356
|
type ProviderEvent = {
|
|
357
|
+
type: 'thinking_delta';
|
|
358
|
+
text: string;
|
|
359
|
+
} | {
|
|
360
|
+
type: 'thinking_done';
|
|
361
|
+
thinking: string;
|
|
362
|
+
signature: string;
|
|
363
|
+
} | {
|
|
364
|
+
type: 'redacted_thinking';
|
|
365
|
+
data: string;
|
|
366
|
+
} | {
|
|
193
367
|
type: 'text_delta';
|
|
194
368
|
text: string;
|
|
195
369
|
} | {
|
|
@@ -258,6 +432,8 @@ declare class QueryEngine {
|
|
|
258
432
|
private readonly maxTokens;
|
|
259
433
|
private readonly temperature;
|
|
260
434
|
private readonly toolChoice;
|
|
435
|
+
private readonly thinking;
|
|
436
|
+
private readonly outputConfig;
|
|
261
437
|
private readonly agent;
|
|
262
438
|
private readonly mcpManager;
|
|
263
439
|
private readonly walletAddress;
|
|
@@ -267,8 +443,11 @@ declare class QueryEngine {
|
|
|
267
443
|
private readonly env;
|
|
268
444
|
private readonly txMutex;
|
|
269
445
|
private readonly costTracker;
|
|
446
|
+
private readonly guardConfig;
|
|
447
|
+
private readonly guardState;
|
|
270
448
|
private messages;
|
|
271
449
|
private abortController;
|
|
450
|
+
private guardEvents;
|
|
272
451
|
constructor(config: EngineConfig);
|
|
273
452
|
/**
|
|
274
453
|
* Submit a user message and stream engine events.
|
|
@@ -289,6 +468,7 @@ declare class QueryEngine {
|
|
|
289
468
|
interrupt(): void;
|
|
290
469
|
getMessages(): readonly Message[];
|
|
291
470
|
reset(): void;
|
|
471
|
+
getGuardEvents(): readonly GuardEvent[];
|
|
292
472
|
loadMessages(messages: Message[]): void;
|
|
293
473
|
setServerPositions(data: EngineConfig['serverPositions']): void;
|
|
294
474
|
getUsage(): CostSnapshot;
|
|
@@ -321,6 +501,8 @@ interface BuildToolOptions<TInput, TOutput> {
|
|
|
321
501
|
call: (input: TInput, context: ToolContext) => Promise<ToolResult<TOutput>>;
|
|
322
502
|
isReadOnly?: boolean;
|
|
323
503
|
permissionLevel?: PermissionLevel;
|
|
504
|
+
flags?: ToolFlags;
|
|
505
|
+
preflight?: (input: TInput) => PreflightResult;
|
|
324
506
|
}
|
|
325
507
|
declare function buildTool<TInput, TOutput>(opts: BuildToolOptions<TInput, TOutput>): Tool<TInput, TOutput>;
|
|
326
508
|
declare function toolsToDefinitions(tools: Tool[]): {
|
|
@@ -330,20 +512,13 @@ declare function toolsToDefinitions(tools: Tool[]): {
|
|
|
330
512
|
}[];
|
|
331
513
|
declare function findTool(tools: Tool[], name: string): Tool | undefined;
|
|
332
514
|
|
|
333
|
-
interface PendingToolCall {
|
|
334
|
-
id: string;
|
|
335
|
-
name: string;
|
|
336
|
-
input: unknown;
|
|
337
|
-
}
|
|
338
|
-
declare class TxMutex {
|
|
339
|
-
private queue;
|
|
340
|
-
private locked;
|
|
341
|
-
acquire(): Promise<void>;
|
|
342
|
-
release(): void;
|
|
343
|
-
}
|
|
344
|
-
declare function runTools(pending: PendingToolCall[], tools: Tool[], context: ToolContext, txMutex: TxMutex): AsyncGenerator<EngineEvent>;
|
|
345
|
-
|
|
346
515
|
type SSEEvent = {
|
|
516
|
+
type: 'thinking_delta';
|
|
517
|
+
text: string;
|
|
518
|
+
} | {
|
|
519
|
+
type: 'thinking_done';
|
|
520
|
+
signature?: string;
|
|
521
|
+
} | {
|
|
347
522
|
type: 'text_delta';
|
|
348
523
|
text: string;
|
|
349
524
|
} | {
|
|
@@ -418,6 +593,131 @@ declare class MemorySessionStore implements SessionStore {
|
|
|
418
593
|
private evictExpired;
|
|
419
594
|
}
|
|
420
595
|
|
|
596
|
+
/**
|
|
597
|
+
* Central registry of tool flags for the guard runner (RE-2.2).
|
|
598
|
+
*
|
|
599
|
+
* Flags are declarative metadata that guards read to decide what checks to run.
|
|
600
|
+
* Read-only tools have no flags by default (empty object).
|
|
601
|
+
*
|
|
602
|
+
* Flag meanings:
|
|
603
|
+
* mutating — changes on-chain state (deposit, swap, send, borrow)
|
|
604
|
+
* requiresBalance — needs sufficient funds to execute
|
|
605
|
+
* affectsHealth — can change borrow health factor
|
|
606
|
+
* irreversible — physical mail, external transfers — can't undo
|
|
607
|
+
* producesArtifact — returns images, documents, generated content
|
|
608
|
+
* costAware — has a monetary cost the user should know about
|
|
609
|
+
* maxRetries — max calls with same input (default: unlimited for reads, 1 for writes)
|
|
610
|
+
*/
|
|
611
|
+
declare const TOOL_FLAGS: Record<string, ToolFlags>;
|
|
612
|
+
/**
|
|
613
|
+
* Apply flags from the central registry to a tool array.
|
|
614
|
+
* Tools not in the registry get empty flags (read-only tools).
|
|
615
|
+
*/
|
|
616
|
+
declare function applyToolFlags<T extends Tool>(tools: T[]): T[];
|
|
617
|
+
/**
|
|
618
|
+
* Get flags for a tool by name. Returns empty flags if not registered.
|
|
619
|
+
*/
|
|
620
|
+
declare function getToolFlags(name: string): ToolFlags;
|
|
621
|
+
|
|
622
|
+
interface Recipe {
|
|
623
|
+
name: string;
|
|
624
|
+
steps: unknown[];
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Routes each turn to the appropriate thinking effort level based on
|
|
628
|
+
* message content, matched recipe, and session write history.
|
|
629
|
+
*
|
|
630
|
+
* Heuristics only — no LLM call. Cost per session becomes proportional
|
|
631
|
+
* to actual query complexity rather than a fixed budget.
|
|
632
|
+
*/
|
|
633
|
+
declare function classifyEffort(model: string, userMessage: string, matchedRecipe: Recipe | null, sessionWriteCount: number): ThinkingEffort;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Build a cacheable system prompt array from static and dynamic parts.
|
|
637
|
+
*
|
|
638
|
+
* Anthropic caches system prompt blocks marked with `cache_control: { type: 'ephemeral' }`.
|
|
639
|
+
* Static blocks (identity, tool descriptions) are cached across turns. Dynamic blocks
|
|
640
|
+
* (user profile, positions, state) change per-turn and are NOT cached.
|
|
641
|
+
*
|
|
642
|
+
* Cache breakpoints are placed at the end of each static block — Anthropic caches
|
|
643
|
+
* from the start of the prompt up to the last cache_control marker.
|
|
644
|
+
*/
|
|
645
|
+
declare function buildCachedSystemPrompt(staticParts: string[], dynamicPart?: string): SystemBlock[];
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Intelligence Layer prompt builders (F1, F2, F5).
|
|
649
|
+
* Pure functions — no DB or Redis dependencies.
|
|
650
|
+
* Consumed by the host app's dynamic context assembly.
|
|
651
|
+
*/
|
|
652
|
+
interface UserFinancialProfile {
|
|
653
|
+
userId: string;
|
|
654
|
+
riskAppetite: 'conservative' | 'moderate' | 'aggressive';
|
|
655
|
+
financialLiteracy: 'novice' | 'intermediate' | 'advanced';
|
|
656
|
+
prefersBriefResponses: boolean;
|
|
657
|
+
prefersExplainers: boolean;
|
|
658
|
+
currencyFraming: 'usdc' | 'fiat';
|
|
659
|
+
primaryGoals: string[];
|
|
660
|
+
knownPatterns: string[];
|
|
661
|
+
riskConfidence: number;
|
|
662
|
+
literacyConfidence: number;
|
|
663
|
+
lastInferredAt: Date | null;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Build system prompt context from a user's financial profile.
|
|
667
|
+
* Returns empty string if profile is absent or confidence is too low.
|
|
668
|
+
* Takes the profile object directly — no DB query.
|
|
669
|
+
*/
|
|
670
|
+
declare function buildProfileContext(profile: UserFinancialProfile | null): string;
|
|
671
|
+
declare function buildProactivenessInstructions(profile: UserFinancialProfile | null): string;
|
|
672
|
+
declare function buildSelfEvaluationInstruction(): string;
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Conversation State Machine — F4 of the Intelligence Layer.
|
|
676
|
+
*
|
|
677
|
+
* Types, pure context builder, and a generic state manager interface.
|
|
678
|
+
* The Redis implementation lives in the host app (audric) since it depends on @upstash/redis.
|
|
679
|
+
*/
|
|
680
|
+
type ConversationState = {
|
|
681
|
+
type: 'idle';
|
|
682
|
+
} | {
|
|
683
|
+
type: 'mid_recipe';
|
|
684
|
+
recipeName: string;
|
|
685
|
+
currentStep: number;
|
|
686
|
+
totalSteps: number;
|
|
687
|
+
completedStepOutputs: Record<string, Record<string, string | number>>;
|
|
688
|
+
startedAt: number;
|
|
689
|
+
} | {
|
|
690
|
+
type: 'awaiting_confirmation';
|
|
691
|
+
action: string;
|
|
692
|
+
amount?: number;
|
|
693
|
+
recipient?: string;
|
|
694
|
+
proposedAt: number;
|
|
695
|
+
expiresAt: number;
|
|
696
|
+
} | {
|
|
697
|
+
type: 'post_error';
|
|
698
|
+
failedAction: string;
|
|
699
|
+
errorMessage: string;
|
|
700
|
+
occurredAt: number;
|
|
701
|
+
partialState?: string;
|
|
702
|
+
} | {
|
|
703
|
+
type: 'post_liquidation_warning';
|
|
704
|
+
healthFactor: number;
|
|
705
|
+
warnedAt: number;
|
|
706
|
+
} | {
|
|
707
|
+
type: 'onboarding';
|
|
708
|
+
sessionNumber: number;
|
|
709
|
+
hasBalance: boolean;
|
|
710
|
+
hasSavedBefore: boolean;
|
|
711
|
+
};
|
|
712
|
+
type StateType = ConversationState['type'];
|
|
713
|
+
interface ConversationStateStore {
|
|
714
|
+
get(): Promise<ConversationState>;
|
|
715
|
+
set(state: ConversationState): Promise<void>;
|
|
716
|
+
transition(to: ConversationState): Promise<void>;
|
|
717
|
+
reset(): Promise<void>;
|
|
718
|
+
}
|
|
719
|
+
declare function buildStateContext(state: ConversationState): string;
|
|
720
|
+
|
|
421
721
|
/** Rough token count for a message array. */
|
|
422
722
|
declare function estimateTokens(messages: Message[]): number;
|
|
423
723
|
interface CompactOptions {
|
|
@@ -1246,4 +1546,4 @@ declare function clearPriceCache(): void;
|
|
|
1246
1546
|
|
|
1247
1547
|
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.";
|
|
1248
1548
|
|
|
1249
|
-
export { AnthropicProvider, type AnthropicProviderConfig, type BalancePrices, type BalanceResult, type BuildToolOptions, CANVAS_TEMPLATES, type CanvasTemplate, type ChatParams, type CompactOptions, type ContentBlock, type CostSnapshot, CostTracker, type CostTrackerConfig, DEFAULT_SYSTEM_PROMPT, type EngineConfig, type EngineEvent, 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 PendingAction, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionResponse, type PositionEntry, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, type RatesResult, type SSEEvent, type SavingsResult, type ServerPositionData, type SessionData, type SessionStore, type StopReason, type SuiCoinBalance, type Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolJsonSchema, type ToolResult, TxMutex, WRITE_TOOLS, type WalletCoin, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, balanceCheckTool, borrowTool, buildMcpTools, buildTool, claimRewardsTool, clearPriceCache, compactMessages, defillamaChainTvlTool, defillamaPriceChangeTool, defillamaProtocolFeesTool, defillamaProtocolInfoTool, defillamaSuiProtocolsTool, defillamaTokenPricesTool, defillamaYieldPoolsTool, engineToSSE, estimateTokens, explainTxTool, extractMcpText, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getDefaultTools, getMcpManager, getWalletAddress, hasNaviMcp, healthCheckTool, mppServicesTool, parseMcpJson, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
1549
|
+
export { AnthropicProvider, type AnthropicProviderConfig, type BalancePrices, type BalanceResult, BalanceTracker, type BuildToolOptions, CANVAS_TEMPLATES, type CanvasTemplate, type ChatParams, type CompactOptions, type ContentBlock, type ConversationState, type ConversationStateStore, type CostSnapshot, CostTracker, type CostTrackerConfig, DEFAULT_GUARD_CONFIG, DEFAULT_SYSTEM_PROMPT, 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, type PendingAction, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionResponse, type PositionEntry, type PreflightResult, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, type RatesResult, 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, WRITE_TOOLS, type WalletCoin, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, balanceCheckTool, borrowTool, 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, mppServicesTool, parseMcpJson, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|