@t2000/engine 1.3.0 → 1.4.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/README.md +5 -2
- package/dist/index.d.ts +214 -3
- package/dist/index.js +212 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -261,8 +261,11 @@ The `submitMessage()` async generator yields `EngineEvent`:
|
|
|
261
261
|
| Event | Fields | When |
|
|
262
262
|
|-------|--------|------|
|
|
263
263
|
| `text_delta` | `text` | LLM streams a text chunk |
|
|
264
|
-
| `thinking_delta` | `text` | Extended thinking chunk (reasoning accordion) |
|
|
265
|
-
| `thinking_done` |
|
|
264
|
+
| `thinking_delta` | `text`, `blockIndex` | Extended thinking chunk (reasoning accordion). **`blockIndex`** identifies which thinking block this delta belongs to so hosts can render multi-block thinking chronologically (Anthropic streams ≥1 thinking blocks per turn at high effort). |
|
|
265
|
+
| `thinking_done` | `blockIndex`, `signature?`, `summaryMode?`, `evaluationItems?` | Extended thinking block complete. `blockIndex` matches the `thinking_delta` events for that block. **`summaryMode`** flips true and **`evaluationItems`** is populated when the block contained a parseable `<eval_summary>` marker — hosts render `HowIEvaluatedBlock` ("✦ HOW I EVALUATED THIS") from these fields. |
|
|
266
|
+
| `todo_update` | `items`, `toolUseId` | **[SPEC 8 v0.5.1]** Side-channel event paired to every `update_todo` tool call. `items` is the full `TodoItem[]` array; hosts unconditionally replace their rendered list (the tool is idempotent). `toolUseId` keys the render to the originating call. |
|
|
267
|
+
| `tool_progress` | `toolUseId`, `toolName`, `message`, `pct?` | **[SPEC 8 v0.5.1]** Mid-execution progress signal from long-running tools (Cetus swap, protocol_deep_dive, portfolio_analysis). Tools opt in via `context.progress?.(msg, pct?)`. Engine wiring lands with the Cetus SDK integration in a follow-on slice. |
|
|
268
|
+
| `pending_input` | `schema`, `inputId`, `prompt?` | **[SPEC 8 v0.5.1, D2]** Reserved for SPEC 9 v0.1.2 inline forms. Engine doesn't emit under SPEC 8 — host adds a no-op handler now to avoid crashing when SPEC 9 ships emission. |
|
|
266
269
|
| `tool_start` | `toolName`, `toolUseId`, `input` | Tool execution begins |
|
|
267
270
|
| `tool_result` | `toolName`, `toolUseId`, `result`, `isError` | Tool execution completes |
|
|
268
271
|
| `pending_action` | `action` (PendingAction with `attemptId`, `toolUseId`, `turnIndex`, `name`, `input`) | Write tool awaiting client-side execution. `attemptId` is a per-yield UUID — hosts persist it on TurnMetrics and key the resume `updateMany` on it (avoids ambiguous `(sessionId, turnIndex)` updates) |
|
package/dist/index.d.ts
CHANGED
|
@@ -584,6 +584,34 @@ declare function toolNameToOperation(toolName: string): PermissionOperation | un
|
|
|
584
584
|
*/
|
|
585
585
|
declare function resolveUsdValue(toolName: string, input: Record<string, unknown>, priceCache: Map<string, number>): number;
|
|
586
586
|
|
|
587
|
+
type EvaluationStatus = 'good' | 'warning' | 'critical' | 'info';
|
|
588
|
+
interface EvaluationItem {
|
|
589
|
+
label: string;
|
|
590
|
+
status: EvaluationStatus;
|
|
591
|
+
note?: string;
|
|
592
|
+
}
|
|
593
|
+
interface EvalSummaryParseResult {
|
|
594
|
+
/** Always true when this object is returned (vs null when absent). */
|
|
595
|
+
summaryMode: true;
|
|
596
|
+
/** The structured rows the host renders inside the trust card. */
|
|
597
|
+
evaluationItems: EvaluationItem[];
|
|
598
|
+
/** Count of markers detected — >1 indicates an LLM compliance violation. */
|
|
599
|
+
markerCount: number;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Scan a thinking-block text for one or more `<eval_summary>` markers.
|
|
603
|
+
*
|
|
604
|
+
* - Returns null when no marker is present, or when the first marker's
|
|
605
|
+
* JSON is malformed (host falls back to standard rendering).
|
|
606
|
+
* - Returns a parsed result when at least one marker contains valid JSON.
|
|
607
|
+
* `markerCount` reflects the total number of markers seen so the
|
|
608
|
+
* engine can emit a `evalSummaryViolationsCount` telemetry counter
|
|
609
|
+
* when N > 1 (LLM is supposed to emit at most one per turn).
|
|
610
|
+
*
|
|
611
|
+
* The function is pure — safe to call per-thinking-block.
|
|
612
|
+
*/
|
|
613
|
+
declare function parseEvalSummary(thinkingText: string): EvalSummaryParseResult | null;
|
|
614
|
+
|
|
587
615
|
type ContentBlock = {
|
|
588
616
|
type: 'text';
|
|
589
617
|
text: string;
|
|
@@ -609,12 +637,34 @@ interface Message {
|
|
|
609
637
|
role: 'user' | 'assistant';
|
|
610
638
|
content: ContentBlock[];
|
|
611
639
|
}
|
|
612
|
-
type EngineEvent =
|
|
640
|
+
type EngineEvent =
|
|
641
|
+
/**
|
|
642
|
+
* [SPEC 8 v0.5.1] `blockIndex` identifies which thinking block this delta
|
|
643
|
+
* belongs to. Anthropic streams multi-block thinking with rising indices
|
|
644
|
+
* across each turn (block 0, 1, 2, ...). Hosts use this to render
|
|
645
|
+
* chronologically interleaved thinking accordions instead of flattening
|
|
646
|
+
* every delta into one string. Backwards-compatible: older hosts that
|
|
647
|
+
* ignore the field still see deltas in emission order.
|
|
648
|
+
*/
|
|
649
|
+
{
|
|
613
650
|
type: 'thinking_delta';
|
|
614
651
|
text: string;
|
|
615
|
-
|
|
652
|
+
blockIndex: number;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* [SPEC 8 v0.5.1] When the thinking block contained a parseable
|
|
656
|
+
* `<eval_summary>...</eval_summary>` marker, `summaryMode` flips true
|
|
657
|
+
* and `evaluationItems` carries the structured rows. Hosts render the
|
|
658
|
+
* `HowIEvaluatedBlock` ("✦ HOW I EVALUATED THIS") trust card from
|
|
659
|
+
* these fields. Both undefined when the block had no marker (every
|
|
660
|
+
* read-only and most write turns).
|
|
661
|
+
*/
|
|
662
|
+
| {
|
|
616
663
|
type: 'thinking_done';
|
|
664
|
+
blockIndex: number;
|
|
617
665
|
signature?: string;
|
|
666
|
+
summaryMode?: boolean;
|
|
667
|
+
evaluationItems?: EvaluationItem[];
|
|
618
668
|
} | {
|
|
619
669
|
type: 'text_delta';
|
|
620
670
|
text: string;
|
|
@@ -682,7 +732,70 @@ type EngineEvent = {
|
|
|
682
732
|
*/
|
|
683
733
|
| {
|
|
684
734
|
type: 'compaction';
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* [SPEC 8 v0.5.1] Side-channel event paired to every `update_todo` tool
|
|
738
|
+
* call. Hosts render the persistent todo card from this event (NOT from
|
|
739
|
+
* the tool_result — see `tools/update-todo.ts` § "side-channel" for
|
|
740
|
+
* rationale). Carries the full items array so the host can
|
|
741
|
+
* unconditionally replace its rendered list (the tool is idempotent —
|
|
742
|
+
* each call replaces the previous state). `toolUseId` lets the host
|
|
743
|
+
* key the render cell to the originating tool call.
|
|
744
|
+
*/
|
|
745
|
+
| {
|
|
746
|
+
type: 'todo_update';
|
|
747
|
+
items: TodoItem$1[];
|
|
748
|
+
toolUseId: string;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* [SPEC 8 v0.5.1] Mid-execution progress signal from a long-running tool
|
|
752
|
+
* (Cetus swap_execute 2-5s, protocol_deep_dive 3-8s, portfolio_analysis
|
|
753
|
+
* 1-2s). Tools opt in by calling `context.progress?.(msg, pct?)` from
|
|
754
|
+
* inside their `call` implementation. Hosts render the message + bar
|
|
755
|
+
* inside the corresponding tool block's spinner — kills the dead-air
|
|
756
|
+
* static-spinner UX that's the explicit SPEC 8 v0.3 fix target.
|
|
757
|
+
*
|
|
758
|
+
* Engine wiring (queue-and-yield in the dispatcher) lands with the
|
|
759
|
+
* Cetus integration in a follow-on slice. SPEC 8 v0.5.1 reserves the
|
|
760
|
+
* event type now so hosts can pre-wire the renderer.
|
|
761
|
+
*
|
|
762
|
+
* `pct` is 0–100 when the tool can express progress quantitatively,
|
|
763
|
+
* undefined otherwise (free-text status only).
|
|
764
|
+
*/
|
|
765
|
+
| {
|
|
766
|
+
type: 'tool_progress';
|
|
767
|
+
toolUseId: string;
|
|
768
|
+
toolName: string;
|
|
769
|
+
message: string;
|
|
770
|
+
pct?: number;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* [SPEC 8 v0.5.1, D2] Inline-form structured input event reserved for
|
|
774
|
+
* SPEC 9 v0.1.2 (`pending_input` form primitive). The engine does NOT
|
|
775
|
+
* emit this event under SPEC 8 — the type is reserved so legacy hosts
|
|
776
|
+
* can add a no-op handler now and avoid crashing when SPEC 9 ships
|
|
777
|
+
* `pending_input` emission. See SPEC 8 § "v0.5 cross-spec coupling
|
|
778
|
+
* fixes" — gap D2 — for the forward-compat rationale.
|
|
779
|
+
*/
|
|
780
|
+
| {
|
|
781
|
+
type: 'pending_input';
|
|
782
|
+
/** Form schema (shape locked in SPEC 9 v0.1.2; engine treats it opaquely). */
|
|
783
|
+
schema: unknown;
|
|
784
|
+
/** Engine round-trip identifier — host posts the answer back keyed on this. */
|
|
785
|
+
inputId: string;
|
|
786
|
+
/** Optional human-readable prompt the LLM wants the host to display above the form. */
|
|
787
|
+
prompt?: string;
|
|
685
788
|
};
|
|
789
|
+
/**
|
|
790
|
+
* [SPEC 8 v0.5.1] One row in an `update_todo` payload. Mirrored from
|
|
791
|
+
* `packages/engine/src/tools/update-todo.ts`. Kept here so hosts that
|
|
792
|
+
* consume `EngineEvent` don't need to depend on the tool module.
|
|
793
|
+
*/
|
|
794
|
+
interface TodoItem$1 {
|
|
795
|
+
id: string;
|
|
796
|
+
label: string;
|
|
797
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
798
|
+
}
|
|
686
799
|
type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'max_turns' | 'error';
|
|
687
800
|
/**
|
|
688
801
|
* [v1.4 Item 6] Describes a single input field on a `PendingAction` that
|
|
@@ -1057,10 +1170,14 @@ interface ToolDefinition {
|
|
|
1057
1170
|
type ProviderEvent = {
|
|
1058
1171
|
type: 'thinking_delta';
|
|
1059
1172
|
text: string;
|
|
1173
|
+
blockIndex: number;
|
|
1060
1174
|
} | {
|
|
1061
1175
|
type: 'thinking_done';
|
|
1176
|
+
blockIndex: number;
|
|
1062
1177
|
thinking: string;
|
|
1063
1178
|
signature: string;
|
|
1179
|
+
summaryMode?: boolean;
|
|
1180
|
+
evaluationItems?: EvaluationItem[];
|
|
1064
1181
|
} | {
|
|
1065
1182
|
type: 'redacted_thinking';
|
|
1066
1183
|
data: string;
|
|
@@ -1276,9 +1393,13 @@ declare function findTool(tools: Tool[], name: string): Tool | undefined;
|
|
|
1276
1393
|
type SSEEvent = {
|
|
1277
1394
|
type: 'thinking_delta';
|
|
1278
1395
|
text: string;
|
|
1396
|
+
blockIndex: number;
|
|
1279
1397
|
} | {
|
|
1280
1398
|
type: 'thinking_done';
|
|
1399
|
+
blockIndex: number;
|
|
1281
1400
|
signature?: string;
|
|
1401
|
+
summaryMode?: boolean;
|
|
1402
|
+
evaluationItems?: EvaluationItem[];
|
|
1282
1403
|
} | {
|
|
1283
1404
|
type: 'text_delta';
|
|
1284
1405
|
text: string;
|
|
@@ -1317,6 +1438,21 @@ type SSEEvent = {
|
|
|
1317
1438
|
data: unknown;
|
|
1318
1439
|
title: string;
|
|
1319
1440
|
toolUseId: string;
|
|
1441
|
+
} | {
|
|
1442
|
+
type: 'todo_update';
|
|
1443
|
+
items: TodoItem$1[];
|
|
1444
|
+
toolUseId: string;
|
|
1445
|
+
} | {
|
|
1446
|
+
type: 'tool_progress';
|
|
1447
|
+
toolUseId: string;
|
|
1448
|
+
toolName: string;
|
|
1449
|
+
message: string;
|
|
1450
|
+
pct?: number;
|
|
1451
|
+
} | {
|
|
1452
|
+
type: 'pending_input';
|
|
1453
|
+
schema: unknown;
|
|
1454
|
+
inputId: string;
|
|
1455
|
+
prompt?: string;
|
|
1320
1456
|
};
|
|
1321
1457
|
declare function serializeSSE(event: SSEEvent): string;
|
|
1322
1458
|
declare function parseSSE(raw: string): SSEEvent | null;
|
|
@@ -1392,6 +1528,24 @@ declare function getToolFlags(name: string): ToolFlags;
|
|
|
1392
1528
|
*/
|
|
1393
1529
|
declare function classifyEffort(model: string, userMessage: string, matchedRecipe: Recipe | null, sessionWriteCount: number): ThinkingEffort;
|
|
1394
1530
|
|
|
1531
|
+
declare const EFFORT_THINKING_BUDGET_CAPS: Record<ThinkingEffort, number | null>;
|
|
1532
|
+
/**
|
|
1533
|
+
* Clamp a `ThinkingConfig` to the HARD cap for the given effort tier.
|
|
1534
|
+
*
|
|
1535
|
+
* - When `effort === 'low'`, returns `{ type: 'disabled' }` regardless of
|
|
1536
|
+
* input — LEAN tier is non-negotiable.
|
|
1537
|
+
* - When `config.type === 'enabled'` and `config.budgetTokens` exceeds
|
|
1538
|
+
* the cap, returns a copy with `budgetTokens` clamped down.
|
|
1539
|
+
* - When `config.type === 'adaptive'`, returns it unchanged — adaptive
|
|
1540
|
+
* mode is shape-agnostic by design (Anthropic decides per-turn).
|
|
1541
|
+
* - When `effort` is undefined, returns `config` unchanged — caller
|
|
1542
|
+
* hasn't classified the turn yet (back-compat for hosts that don't
|
|
1543
|
+
* route on effort).
|
|
1544
|
+
*
|
|
1545
|
+
* This function is pure and side-effect-free; safe to call per-turn.
|
|
1546
|
+
*/
|
|
1547
|
+
declare function clampThinkingForEffort(config: ThinkingConfig | undefined, effort: ThinkingEffort | undefined): ThinkingConfig | undefined;
|
|
1548
|
+
|
|
1395
1549
|
/**
|
|
1396
1550
|
* Build a cacheable system prompt array from static and dynamic parts.
|
|
1397
1551
|
*
|
|
@@ -2435,6 +2589,63 @@ declare const resolveSuinsTool: Tool<{
|
|
|
2435
2589
|
query: string;
|
|
2436
2590
|
}, ResolveSuinsResult>;
|
|
2437
2591
|
|
|
2592
|
+
declare const todoItemSchema: z.ZodObject<{
|
|
2593
|
+
id: z.ZodString;
|
|
2594
|
+
label: z.ZodString;
|
|
2595
|
+
status: z.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
2596
|
+
}, "strip", z.ZodTypeAny, {
|
|
2597
|
+
label: string;
|
|
2598
|
+
status: "pending" | "in_progress" | "completed";
|
|
2599
|
+
id: string;
|
|
2600
|
+
}, {
|
|
2601
|
+
label: string;
|
|
2602
|
+
status: "pending" | "in_progress" | "completed";
|
|
2603
|
+
id: string;
|
|
2604
|
+
}>;
|
|
2605
|
+
declare const inputSchema: z.ZodObject<{
|
|
2606
|
+
items: z.ZodArray<z.ZodObject<{
|
|
2607
|
+
id: z.ZodString;
|
|
2608
|
+
label: z.ZodString;
|
|
2609
|
+
status: z.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
2610
|
+
}, "strip", z.ZodTypeAny, {
|
|
2611
|
+
label: string;
|
|
2612
|
+
status: "pending" | "in_progress" | "completed";
|
|
2613
|
+
id: string;
|
|
2614
|
+
}, {
|
|
2615
|
+
label: string;
|
|
2616
|
+
status: "pending" | "in_progress" | "completed";
|
|
2617
|
+
id: string;
|
|
2618
|
+
}>, "many">;
|
|
2619
|
+
}, "strip", z.ZodTypeAny, {
|
|
2620
|
+
items: {
|
|
2621
|
+
label: string;
|
|
2622
|
+
status: "pending" | "in_progress" | "completed";
|
|
2623
|
+
id: string;
|
|
2624
|
+
}[];
|
|
2625
|
+
}, {
|
|
2626
|
+
items: {
|
|
2627
|
+
label: string;
|
|
2628
|
+
status: "pending" | "in_progress" | "completed";
|
|
2629
|
+
id: string;
|
|
2630
|
+
}[];
|
|
2631
|
+
}>;
|
|
2632
|
+
type TodoItem = z.infer<typeof todoItemSchema>;
|
|
2633
|
+
type UpdateTodoInput = z.infer<typeof inputSchema>;
|
|
2634
|
+
declare const updateTodoTool: Tool<{
|
|
2635
|
+
items: {
|
|
2636
|
+
label: string;
|
|
2637
|
+
status: "pending" | "in_progress" | "completed";
|
|
2638
|
+
id: string;
|
|
2639
|
+
}[];
|
|
2640
|
+
}, {
|
|
2641
|
+
__todoUpdate: boolean;
|
|
2642
|
+
items: {
|
|
2643
|
+
label: string;
|
|
2644
|
+
status: "pending" | "in_progress" | "completed";
|
|
2645
|
+
id: string;
|
|
2646
|
+
}[];
|
|
2647
|
+
}>;
|
|
2648
|
+
|
|
2438
2649
|
declare const tokenPricesTool: Tool<{
|
|
2439
2650
|
coinTypes: string[];
|
|
2440
2651
|
include24hChange?: boolean | undefined;
|
|
@@ -3020,4 +3231,4 @@ declare function getTelemetrySink(): TelemetrySink;
|
|
|
3020
3231
|
/** Restore the default noop sink. Used by test teardowns. */
|
|
3021
3232
|
declare function resetTelemetrySink(): void;
|
|
3022
3233
|
|
|
3023
|
-
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, EarlyToolDispatcher, type EngineConfig, type EngineEvent, 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 Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolFlags, type ToolJsonSchema, type ToolResult, TxMutex, 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, 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, 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, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -5104,6 +5104,107 @@ var resolveSuinsTool = buildTool({
|
|
|
5104
5104
|
}
|
|
5105
5105
|
}
|
|
5106
5106
|
});
|
|
5107
|
+
var todoStatusSchema = z.enum(["pending", "in_progress", "completed"]);
|
|
5108
|
+
var todoItemSchema = z.object({
|
|
5109
|
+
id: z.string().min(1, "id must be a non-empty string").max(40, "id must be \u226440 chars (use a slug, not a sentence)"),
|
|
5110
|
+
label: z.string().min(1, "label must be a non-empty string").max(80, "label must be \u226480 chars (the whole point of this tool is concision)"),
|
|
5111
|
+
status: todoStatusSchema
|
|
5112
|
+
});
|
|
5113
|
+
var inputSchema6 = z.object({
|
|
5114
|
+
items: z.array(todoItemSchema).min(1, "items must contain at least 1 entry").max(8, "items must contain at most 8 entries (SPEC 8 ceiling)")
|
|
5115
|
+
});
|
|
5116
|
+
var updateTodoTool = buildTool({
|
|
5117
|
+
name: "update_todo",
|
|
5118
|
+
description: "Declare or replace your plan for the current turn as a structured todo list. Call this when the user's ask is multi-step (\u22653 tools, \u22652 reasoning hops) so the user can see what you're doing as you do it. Each call replaces the entire list \u2014 the tool is idempotent. \n\nRules: 1\u20138 items, each label \u226480 chars, exactly 1 item must be `in_progress`. Use stable `id`s across calls within the same turn so the UI can track item transitions (e.g. `id: 'check-balance'` first as `pending`, later as `completed`). \n\nDO NOT call this for single-step asks ('balance', 'rate') \u2014 it's wasted tokens. DO call it before kicking off long flows where the user benefits from seeing the plan unfold ('save my idle USDC' \u2192 check balance \u2192 check rates \u2192 compute split \u2192 propose). \n\nThis call doesn't count against your turn budget \u2014 re-narrating the plan as items move from pending \u2192 in_progress \u2192 completed is encouraged.",
|
|
5119
|
+
inputSchema: inputSchema6,
|
|
5120
|
+
jsonSchema: {
|
|
5121
|
+
type: "object",
|
|
5122
|
+
properties: {
|
|
5123
|
+
items: {
|
|
5124
|
+
type: "array",
|
|
5125
|
+
minItems: 1,
|
|
5126
|
+
maxItems: 8,
|
|
5127
|
+
items: {
|
|
5128
|
+
type: "object",
|
|
5129
|
+
properties: {
|
|
5130
|
+
id: {
|
|
5131
|
+
type: "string",
|
|
5132
|
+
description: 'Stable identifier across calls within the same turn (e.g. "check-balance"). \u226440 chars.'
|
|
5133
|
+
},
|
|
5134
|
+
label: {
|
|
5135
|
+
type: "string",
|
|
5136
|
+
description: 'What this step is doing, \u226480 chars. Concrete (e.g. "Check USDC rate") not abstract ("Gather data").'
|
|
5137
|
+
},
|
|
5138
|
+
status: {
|
|
5139
|
+
type: "string",
|
|
5140
|
+
enum: ["pending", "in_progress", "completed"],
|
|
5141
|
+
description: "Lifecycle state. Exactly one item must be `in_progress` per call."
|
|
5142
|
+
}
|
|
5143
|
+
},
|
|
5144
|
+
required: ["id", "label", "status"]
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
},
|
|
5148
|
+
required: ["items"]
|
|
5149
|
+
},
|
|
5150
|
+
isReadOnly: true,
|
|
5151
|
+
// No I/O, just a pass-through that emits a side-channel event. Skip the
|
|
5152
|
+
// turn-read cache — every call is intentionally distinct (ids may match
|
|
5153
|
+
// but statuses change).
|
|
5154
|
+
cacheable: false,
|
|
5155
|
+
preflight: (input) => {
|
|
5156
|
+
const items = input.items ?? [];
|
|
5157
|
+
if (items.length === 0) {
|
|
5158
|
+
return { valid: false, error: "items must contain at least 1 entry" };
|
|
5159
|
+
}
|
|
5160
|
+
if (items.length > 8) {
|
|
5161
|
+
return { valid: false, error: `items must contain at most 8 entries, got ${items.length}` };
|
|
5162
|
+
}
|
|
5163
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
5164
|
+
let inProgressCount = 0;
|
|
5165
|
+
for (const item of items) {
|
|
5166
|
+
if (!item.id || item.id.trim().length === 0) {
|
|
5167
|
+
return { valid: false, error: "every item must have a non-empty id" };
|
|
5168
|
+
}
|
|
5169
|
+
if (item.id.length > 40) {
|
|
5170
|
+
return { valid: false, error: `item id "${item.id.slice(0, 30)}\u2026" exceeds 40 chars` };
|
|
5171
|
+
}
|
|
5172
|
+
if (seenIds.has(item.id)) {
|
|
5173
|
+
return { valid: false, error: `duplicate item id "${item.id}" \u2014 ids must be unique within a list` };
|
|
5174
|
+
}
|
|
5175
|
+
seenIds.add(item.id);
|
|
5176
|
+
if (!item.label || item.label.trim().length === 0) {
|
|
5177
|
+
return { valid: false, error: `item "${item.id}" has empty label` };
|
|
5178
|
+
}
|
|
5179
|
+
if (item.label.length > 80) {
|
|
5180
|
+
return { valid: false, error: `item "${item.id}" label exceeds 80 chars (got ${item.label.length})` };
|
|
5181
|
+
}
|
|
5182
|
+
if (item.status === "in_progress") {
|
|
5183
|
+
inProgressCount++;
|
|
5184
|
+
}
|
|
5185
|
+
}
|
|
5186
|
+
if (inProgressCount !== 1) {
|
|
5187
|
+
return {
|
|
5188
|
+
valid: false,
|
|
5189
|
+
error: `exactly 1 item must be in_progress, got ${inProgressCount}`
|
|
5190
|
+
};
|
|
5191
|
+
}
|
|
5192
|
+
return { valid: true };
|
|
5193
|
+
},
|
|
5194
|
+
async call(input) {
|
|
5195
|
+
return {
|
|
5196
|
+
// The `__todoUpdate` flag tells the engine's agent loop to emit a
|
|
5197
|
+
// `todo_update` side-channel event (mirrors the `__canvas` magic
|
|
5198
|
+
// flag pattern). The LLM still gets a normal `tool_result` keyed
|
|
5199
|
+
// to its `tool_use_id` so the Anthropic protocol stays satisfied.
|
|
5200
|
+
data: {
|
|
5201
|
+
__todoUpdate: true,
|
|
5202
|
+
items: input.items
|
|
5203
|
+
},
|
|
5204
|
+
displayText: `${input.items.length} step${input.items.length === 1 ? "" : "s"}: ${input.items.map((i) => `${i.status === "completed" ? "\u2713" : i.status === "in_progress" ? "\u2192" : "\xB7"} ${i.label}`).join(" / ")}`
|
|
5205
|
+
};
|
|
5206
|
+
}
|
|
5207
|
+
});
|
|
5107
5208
|
var tokenPricesTool = buildTool({
|
|
5108
5209
|
name: "token_prices",
|
|
5109
5210
|
description: 'Get current USD prices for Sui tokens, with optional 24h change. Accepts full coin type strings (e.g. "0x2::sui::SUI"). Returns price per token and (when requested) 24h change percentage. Use for "what is X worth?" or "did Y move today?". For balance + portfolio rendering, prefer balance_check / portfolio_analysis instead \u2014 they bundle the same prices into the standard cards.',
|
|
@@ -5350,6 +5451,29 @@ var CostTracker = class {
|
|
|
5350
5451
|
}
|
|
5351
5452
|
};
|
|
5352
5453
|
|
|
5454
|
+
// src/thinking-budget.ts
|
|
5455
|
+
var EFFORT_THINKING_BUDGET_CAPS = {
|
|
5456
|
+
// null = thinking force-disabled (LEAN tier — single-fact reads need
|
|
5457
|
+
// zero deliberation; a thinking block here adds ~300ms TTFVP for no
|
|
5458
|
+
// benefit — see SPEC 8 § "Decision 2: LEAN shape: zero thinking blocks")
|
|
5459
|
+
low: null,
|
|
5460
|
+
medium: 8e3,
|
|
5461
|
+
high: 16e3,
|
|
5462
|
+
max: 32e3
|
|
5463
|
+
};
|
|
5464
|
+
function clampThinkingForEffort(config, effort) {
|
|
5465
|
+
if (!config) return config;
|
|
5466
|
+
if (effort === void 0) return config;
|
|
5467
|
+
const cap = EFFORT_THINKING_BUDGET_CAPS[effort];
|
|
5468
|
+
if (cap === null) {
|
|
5469
|
+
return { type: "disabled" };
|
|
5470
|
+
}
|
|
5471
|
+
if (config.type === "enabled" && config.budgetTokens > cap) {
|
|
5472
|
+
return { ...config, budgetTokens: cap };
|
|
5473
|
+
}
|
|
5474
|
+
return config;
|
|
5475
|
+
}
|
|
5476
|
+
|
|
5353
5477
|
// src/guards.ts
|
|
5354
5478
|
function guardVerdictToAction(verdict) {
|
|
5355
5479
|
if (verdict === "pass" || verdict === "hint") return "allow";
|
|
@@ -6940,6 +7064,7 @@ ${recipeCtx}`;
|
|
|
6940
7064
|
];
|
|
6941
7065
|
}
|
|
6942
7066
|
}
|
|
7067
|
+
const cappedThinking = clampThinkingForEffort(this.thinking, this.outputConfig?.effort);
|
|
6943
7068
|
const stream = this.provider.chat({
|
|
6944
7069
|
messages: this.messages,
|
|
6945
7070
|
systemPrompt: effectivePrompt,
|
|
@@ -6948,7 +7073,7 @@ ${recipeCtx}`;
|
|
|
6948
7073
|
maxTokens: this.maxTokens,
|
|
6949
7074
|
temperature: this.temperature,
|
|
6950
7075
|
toolChoice: effectiveToolChoice,
|
|
6951
|
-
thinking:
|
|
7076
|
+
thinking: cappedThinking,
|
|
6952
7077
|
outputConfig: this.outputConfig,
|
|
6953
7078
|
signal
|
|
6954
7079
|
});
|
|
@@ -7029,6 +7154,13 @@ ${recipeCtx}`;
|
|
|
7029
7154
|
toolUseId: finalEvent.toolUseId
|
|
7030
7155
|
};
|
|
7031
7156
|
}
|
|
7157
|
+
if (r && r.__todoUpdate === true && Array.isArray(r.items)) {
|
|
7158
|
+
yield {
|
|
7159
|
+
type: "todo_update",
|
|
7160
|
+
items: r.items,
|
|
7161
|
+
toolUseId: finalEvent.toolUseId
|
|
7162
|
+
};
|
|
7163
|
+
}
|
|
7032
7164
|
}
|
|
7033
7165
|
earlyResultBlocks.push({
|
|
7034
7166
|
type: "tool_result",
|
|
@@ -7225,6 +7357,13 @@ ${recipeCtx}`;
|
|
|
7225
7357
|
toolUseId: finalEvent.toolUseId
|
|
7226
7358
|
};
|
|
7227
7359
|
}
|
|
7360
|
+
if (r && r.__todoUpdate === true && Array.isArray(r.items)) {
|
|
7361
|
+
yield {
|
|
7362
|
+
type: "todo_update",
|
|
7363
|
+
items: r.items,
|
|
7364
|
+
toolUseId: finalEvent.toolUseId
|
|
7365
|
+
};
|
|
7366
|
+
}
|
|
7228
7367
|
if (tool && !tool.isReadOnly && this.onAutoExecuted && this.permissionConfig && this.priceCache) {
|
|
7229
7368
|
const operation = toolNameToOperation(toolEvent.toolName);
|
|
7230
7369
|
if (operation && originalCall) {
|
|
@@ -7316,6 +7455,11 @@ ${recipeCtx}`;
|
|
|
7316
7455
|
}
|
|
7317
7456
|
this.messages.push({ role: "assistant", content: acc.assistantBlocks });
|
|
7318
7457
|
this.messages.push({ role: "user", content: toolResultBlocks });
|
|
7458
|
+
const toolUseBlocks = acc.assistantBlocks.filter((b) => b.type === "tool_use");
|
|
7459
|
+
const allUpdateTodo = toolUseBlocks.length > 0 && toolUseBlocks.every((b) => b.name === "update_todo");
|
|
7460
|
+
if (allUpdateTodo) {
|
|
7461
|
+
turns--;
|
|
7462
|
+
}
|
|
7319
7463
|
if (this.costTracker.isOverBudget()) {
|
|
7320
7464
|
yield { type: "error", error: new Error("Session budget exceeded") };
|
|
7321
7465
|
return;
|
|
@@ -7340,7 +7484,7 @@ ${recipeCtx}`;
|
|
|
7340
7484
|
*handleProviderEvent(event, acc, dispatcher) {
|
|
7341
7485
|
switch (event.type) {
|
|
7342
7486
|
case "thinking_delta": {
|
|
7343
|
-
yield { type: "thinking_delta", text: event.text };
|
|
7487
|
+
yield { type: "thinking_delta", text: event.text, blockIndex: event.blockIndex };
|
|
7344
7488
|
break;
|
|
7345
7489
|
}
|
|
7346
7490
|
case "thinking_done": {
|
|
@@ -7349,7 +7493,14 @@ ${recipeCtx}`;
|
|
|
7349
7493
|
thinking: event.thinking,
|
|
7350
7494
|
signature: event.signature
|
|
7351
7495
|
});
|
|
7352
|
-
yield {
|
|
7496
|
+
yield {
|
|
7497
|
+
type: "thinking_done",
|
|
7498
|
+
blockIndex: event.blockIndex,
|
|
7499
|
+
signature: event.signature,
|
|
7500
|
+
// [SPEC 8 v0.5.1] forward HowIEvaluated structured fields when
|
|
7501
|
+
// the provider parsed an <eval_summary> marker.
|
|
7502
|
+
...event.summaryMode && event.evaluationItems ? { summaryMode: true, evaluationItems: event.evaluationItems } : {}
|
|
7503
|
+
};
|
|
7353
7504
|
break;
|
|
7354
7505
|
}
|
|
7355
7506
|
case "redacted_thinking": {
|
|
@@ -7785,6 +7936,54 @@ function classifyEffort(model, userMessage, matchedRecipe, sessionWriteCount) {
|
|
|
7785
7936
|
return "medium";
|
|
7786
7937
|
}
|
|
7787
7938
|
|
|
7939
|
+
// src/eval-summary.ts
|
|
7940
|
+
var MARKER_REGEX = /<eval_summary>([\s\S]*?)<\/eval_summary>/g;
|
|
7941
|
+
var VALID_STATUSES = /* @__PURE__ */ new Set([
|
|
7942
|
+
"good",
|
|
7943
|
+
"warning",
|
|
7944
|
+
"critical",
|
|
7945
|
+
"info"
|
|
7946
|
+
]);
|
|
7947
|
+
function parseEvalSummary(thinkingText) {
|
|
7948
|
+
if (!thinkingText.includes("<eval_summary>")) return null;
|
|
7949
|
+
const matches = [];
|
|
7950
|
+
for (const match of thinkingText.matchAll(MARKER_REGEX)) {
|
|
7951
|
+
matches.push(match[1] ?? "");
|
|
7952
|
+
}
|
|
7953
|
+
if (matches.length === 0) return null;
|
|
7954
|
+
const firstPayload = matches[0].trim();
|
|
7955
|
+
let parsed;
|
|
7956
|
+
try {
|
|
7957
|
+
parsed = JSON.parse(firstPayload);
|
|
7958
|
+
} catch {
|
|
7959
|
+
return null;
|
|
7960
|
+
}
|
|
7961
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
7962
|
+
const items = parsed.items;
|
|
7963
|
+
if (!Array.isArray(items)) return null;
|
|
7964
|
+
const evaluationItems = [];
|
|
7965
|
+
for (const item of items) {
|
|
7966
|
+
if (!item || typeof item !== "object") continue;
|
|
7967
|
+
const i = item;
|
|
7968
|
+
if (typeof i.label !== "string" || i.label.trim().length === 0) continue;
|
|
7969
|
+
if (typeof i.status !== "string" || !VALID_STATUSES.has(i.status)) continue;
|
|
7970
|
+
const out = {
|
|
7971
|
+
label: i.label,
|
|
7972
|
+
status: i.status
|
|
7973
|
+
};
|
|
7974
|
+
if (typeof i.note === "string" && i.note.length > 0) {
|
|
7975
|
+
out.note = i.note;
|
|
7976
|
+
}
|
|
7977
|
+
evaluationItems.push(out);
|
|
7978
|
+
}
|
|
7979
|
+
if (evaluationItems.length === 0) return null;
|
|
7980
|
+
return {
|
|
7981
|
+
summaryMode: true,
|
|
7982
|
+
evaluationItems,
|
|
7983
|
+
markerCount: matches.length
|
|
7984
|
+
};
|
|
7985
|
+
}
|
|
7986
|
+
|
|
7788
7987
|
// src/prompt-cache.ts
|
|
7789
7988
|
function buildCachedSystemPrompt(staticParts, dynamicPart) {
|
|
7790
7989
|
const blocks = staticParts.map((text, i) => ({
|
|
@@ -8342,7 +8541,7 @@ var AnthropicProvider = class {
|
|
|
8342
8541
|
} else if (delta.type === "thinking_delta") {
|
|
8343
8542
|
const buf = thinkingBuffers.get(event.index);
|
|
8344
8543
|
if (buf?.type === "thinking") buf.text += delta.thinking ?? "";
|
|
8345
|
-
yield { type: "thinking_delta", text: delta.thinking ?? "" };
|
|
8544
|
+
yield { type: "thinking_delta", text: delta.thinking ?? "", blockIndex: event.index };
|
|
8346
8545
|
} else if (delta.type === "signature_delta") {
|
|
8347
8546
|
const buf = thinkingBuffers.get(event.index);
|
|
8348
8547
|
if (buf?.type === "thinking") buf.signature = delta.signature ?? "";
|
|
@@ -8368,7 +8567,14 @@ var AnthropicProvider = class {
|
|
|
8368
8567
|
}
|
|
8369
8568
|
const thinkBuf = thinkingBuffers.get(event.index);
|
|
8370
8569
|
if (thinkBuf?.type === "thinking") {
|
|
8371
|
-
|
|
8570
|
+
const summary = parseEvalSummary(thinkBuf.text);
|
|
8571
|
+
yield {
|
|
8572
|
+
type: "thinking_done",
|
|
8573
|
+
blockIndex: event.index,
|
|
8574
|
+
thinking: thinkBuf.text,
|
|
8575
|
+
signature: thinkBuf.signature,
|
|
8576
|
+
...summary ? { summaryMode: true, evaluationItems: summary.evaluationItems } : {}
|
|
8577
|
+
};
|
|
8372
8578
|
thinkingBuffers.delete(event.index);
|
|
8373
8579
|
} else if (thinkBuf?.type === "redacted_thinking") {
|
|
8374
8580
|
yield { type: "redacted_thinking", data: thinkBuf.data };
|
|
@@ -8582,6 +8788,6 @@ function sanitizeAnthropicMessages(messages) {
|
|
|
8582
8788
|
return merged;
|
|
8583
8789
|
}
|
|
8584
8790
|
|
|
8585
|
-
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, 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, 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, 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, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|
|
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 };
|
|
8586
8792
|
//# sourceMappingURL=index.js.map
|
|
8587
8793
|
//# sourceMappingURL=index.js.map
|