@t2000/engine 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/index.d.ts +325 -7
- package/dist/index.js +318 -43
- 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
|
@@ -393,7 +393,11 @@ interface AddressPortfolio {
|
|
|
393
393
|
* overwrite — preserves the original `pricedAt` so a UI can
|
|
394
394
|
* render "last refresh Nm ago".
|
|
395
395
|
*/
|
|
396
|
-
declare function fetchAddressPortfolio(address: string, apiKey: string | undefined, fallbackRpcUrl?: string
|
|
396
|
+
declare function fetchAddressPortfolio(address: string, apiKey: string | undefined, fallbackRpcUrl?: string, opts?: {
|
|
397
|
+
retryStats?: {
|
|
398
|
+
attemptCount: number;
|
|
399
|
+
};
|
|
400
|
+
}): Promise<AddressPortfolio>;
|
|
397
401
|
/**
|
|
398
402
|
* Multi-token price lookup. Returns a map of coinType → `{ price, change24h }`
|
|
399
403
|
* with the `change24h` field populated when BlockVision returns it.
|
|
@@ -404,7 +408,11 @@ declare function fetchAddressPortfolio(address: string, apiKey: string | undefin
|
|
|
404
408
|
* requested coins fetches only the missing 2 instead of throwing the
|
|
405
409
|
* whole map away.
|
|
406
410
|
*/
|
|
407
|
-
declare function fetchTokenPrices(coinTypes: string[], apiKey: string | undefined
|
|
411
|
+
declare function fetchTokenPrices(coinTypes: string[], apiKey: string | undefined, opts?: {
|
|
412
|
+
retryStats?: {
|
|
413
|
+
attemptCount: number;
|
|
414
|
+
};
|
|
415
|
+
}): Promise<Record<string, {
|
|
408
416
|
price: number;
|
|
409
417
|
change24h?: number;
|
|
410
418
|
}>>;
|
|
@@ -431,7 +439,11 @@ interface DefiSummary {
|
|
|
431
439
|
*/
|
|
432
440
|
source: 'blockvision' | 'partial' | 'partial-stale' | 'degraded';
|
|
433
441
|
}
|
|
434
|
-
declare function fetchAddressDefiPortfolio(address: string, apiKey: string | undefined, priceHints?: Record<string, number
|
|
442
|
+
declare function fetchAddressDefiPortfolio(address: string, apiKey: string | undefined, priceHints?: Record<string, number>, opts?: {
|
|
443
|
+
retryStats?: {
|
|
444
|
+
attemptCount: number;
|
|
445
|
+
};
|
|
446
|
+
}): Promise<DefiSummary>;
|
|
435
447
|
/**
|
|
436
448
|
* Wipe the wallet portfolio cache plus any in-flight promises.
|
|
437
449
|
*
|
|
@@ -584,6 +596,34 @@ declare function toolNameToOperation(toolName: string): PermissionOperation | un
|
|
|
584
596
|
*/
|
|
585
597
|
declare function resolveUsdValue(toolName: string, input: Record<string, unknown>, priceCache: Map<string, number>): number;
|
|
586
598
|
|
|
599
|
+
type EvaluationStatus = 'good' | 'warning' | 'critical' | 'info';
|
|
600
|
+
interface EvaluationItem {
|
|
601
|
+
label: string;
|
|
602
|
+
status: EvaluationStatus;
|
|
603
|
+
note?: string;
|
|
604
|
+
}
|
|
605
|
+
interface EvalSummaryParseResult {
|
|
606
|
+
/** Always true when this object is returned (vs null when absent). */
|
|
607
|
+
summaryMode: true;
|
|
608
|
+
/** The structured rows the host renders inside the trust card. */
|
|
609
|
+
evaluationItems: EvaluationItem[];
|
|
610
|
+
/** Count of markers detected — >1 indicates an LLM compliance violation. */
|
|
611
|
+
markerCount: number;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Scan a thinking-block text for one or more `<eval_summary>` markers.
|
|
615
|
+
*
|
|
616
|
+
* - Returns null when no marker is present, or when the first marker's
|
|
617
|
+
* JSON is malformed (host falls back to standard rendering).
|
|
618
|
+
* - Returns a parsed result when at least one marker contains valid JSON.
|
|
619
|
+
* `markerCount` reflects the total number of markers seen so the
|
|
620
|
+
* engine can emit a `evalSummaryViolationsCount` telemetry counter
|
|
621
|
+
* when N > 1 (LLM is supposed to emit at most one per turn).
|
|
622
|
+
*
|
|
623
|
+
* The function is pure — safe to call per-thinking-block.
|
|
624
|
+
*/
|
|
625
|
+
declare function parseEvalSummary(thinkingText: string): EvalSummaryParseResult | null;
|
|
626
|
+
|
|
587
627
|
type ContentBlock = {
|
|
588
628
|
type: 'text';
|
|
589
629
|
text: string;
|
|
@@ -609,12 +649,34 @@ interface Message {
|
|
|
609
649
|
role: 'user' | 'assistant';
|
|
610
650
|
content: ContentBlock[];
|
|
611
651
|
}
|
|
612
|
-
type EngineEvent =
|
|
652
|
+
type EngineEvent =
|
|
653
|
+
/**
|
|
654
|
+
* [SPEC 8 v0.5.1] `blockIndex` identifies which thinking block this delta
|
|
655
|
+
* belongs to. Anthropic streams multi-block thinking with rising indices
|
|
656
|
+
* across each turn (block 0, 1, 2, ...). Hosts use this to render
|
|
657
|
+
* chronologically interleaved thinking accordions instead of flattening
|
|
658
|
+
* every delta into one string. Backwards-compatible: older hosts that
|
|
659
|
+
* ignore the field still see deltas in emission order.
|
|
660
|
+
*/
|
|
661
|
+
{
|
|
613
662
|
type: 'thinking_delta';
|
|
614
663
|
text: string;
|
|
615
|
-
|
|
664
|
+
blockIndex: number;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* [SPEC 8 v0.5.1] When the thinking block contained a parseable
|
|
668
|
+
* `<eval_summary>...</eval_summary>` marker, `summaryMode` flips true
|
|
669
|
+
* and `evaluationItems` carries the structured rows. Hosts render the
|
|
670
|
+
* `HowIEvaluatedBlock` ("✦ HOW I EVALUATED THIS") trust card from
|
|
671
|
+
* these fields. Both undefined when the block had no marker (every
|
|
672
|
+
* read-only and most write turns).
|
|
673
|
+
*/
|
|
674
|
+
| {
|
|
616
675
|
type: 'thinking_done';
|
|
676
|
+
blockIndex: number;
|
|
617
677
|
signature?: string;
|
|
678
|
+
summaryMode?: boolean;
|
|
679
|
+
evaluationItems?: EvaluationItem[];
|
|
618
680
|
} | {
|
|
619
681
|
type: 'text_delta';
|
|
620
682
|
text: string;
|
|
@@ -651,6 +713,22 @@ type EngineEvent = {
|
|
|
651
713
|
* UI affordances (e.g. a subtle "auto-refreshed" badge).
|
|
652
714
|
*/
|
|
653
715
|
wasPostWriteRefresh?: boolean;
|
|
716
|
+
/**
|
|
717
|
+
* [SPEC 8 v0.5.1 B3.2] Number of HTTP attempts the tool made before
|
|
718
|
+
* succeeding (or returning the final result). Surfaced when the tool
|
|
719
|
+
* went through one or more retries inside its retry wrapper
|
|
720
|
+
* (`fetchBlockVisionWithRetry` and equivalents). Set ONLY when N > 1
|
|
721
|
+
* — a successful first try leaves the field undefined to avoid
|
|
722
|
+
* header noise in the host's `ToolBlockView`. Hosts render
|
|
723
|
+
* "TOOL · attempt N · 1.4s" subtitle when present, hidden otherwise.
|
|
724
|
+
*
|
|
725
|
+
* Plumbing: engine sets a per-tool `retryStats: { attemptCount: 1 }`
|
|
726
|
+
* counter on `ToolContext`; the BlockVision retry wrapper increments
|
|
727
|
+
* it on every retry attempt; the engine reads it back after the tool
|
|
728
|
+
* returns and surfaces here when > 1. Tools that don't use a retry
|
|
729
|
+
* wrapper never emit a value.
|
|
730
|
+
*/
|
|
731
|
+
attemptCount?: number;
|
|
654
732
|
} | {
|
|
655
733
|
type: 'pending_action';
|
|
656
734
|
action: PendingAction;
|
|
@@ -682,7 +760,115 @@ type EngineEvent = {
|
|
|
682
760
|
*/
|
|
683
761
|
| {
|
|
684
762
|
type: 'compaction';
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* [SPEC 8 v0.5.1] Side-channel event paired to every `update_todo` tool
|
|
766
|
+
* call. Hosts render the persistent todo card from this event (NOT from
|
|
767
|
+
* the tool_result — see `tools/update-todo.ts` § "side-channel" for
|
|
768
|
+
* rationale). Carries the full items array so the host can
|
|
769
|
+
* unconditionally replace its rendered list (the tool is idempotent —
|
|
770
|
+
* each call replaces the previous state). `toolUseId` lets the host
|
|
771
|
+
* key the render cell to the originating tool call.
|
|
772
|
+
*/
|
|
773
|
+
| {
|
|
774
|
+
type: 'todo_update';
|
|
775
|
+
items: TodoItem$1[];
|
|
776
|
+
toolUseId: string;
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* [SPEC 8 v0.5.1] Mid-execution progress signal from a long-running tool
|
|
780
|
+
* (Cetus swap_execute 2-5s, protocol_deep_dive 3-8s, portfolio_analysis
|
|
781
|
+
* 1-2s). Tools opt in by calling `context.progress?.(msg, pct?)` from
|
|
782
|
+
* inside their `call` implementation. Hosts render the message + bar
|
|
783
|
+
* inside the corresponding tool block's spinner — kills the dead-air
|
|
784
|
+
* static-spinner UX that's the explicit SPEC 8 v0.3 fix target.
|
|
785
|
+
*
|
|
786
|
+
* Engine wiring (queue-and-yield in the dispatcher) lands with the
|
|
787
|
+
* Cetus integration in a follow-on slice. SPEC 8 v0.5.1 reserves the
|
|
788
|
+
* event type now so hosts can pre-wire the renderer.
|
|
789
|
+
*
|
|
790
|
+
* `pct` is 0–100 when the tool can express progress quantitatively,
|
|
791
|
+
* undefined otherwise (free-text status only).
|
|
792
|
+
*/
|
|
793
|
+
| {
|
|
794
|
+
type: 'tool_progress';
|
|
795
|
+
toolUseId: string;
|
|
796
|
+
toolName: string;
|
|
797
|
+
message: string;
|
|
798
|
+
pct?: number;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* [SPEC 8 v0.5.1, D2] Inline-form structured input event reserved for
|
|
802
|
+
* SPEC 9 v0.1.2 (`pending_input` form primitive). The engine does NOT
|
|
803
|
+
* emit this event under SPEC 8 — the type is reserved so legacy hosts
|
|
804
|
+
* can add a no-op handler now and avoid crashing when SPEC 9 ships
|
|
805
|
+
* `pending_input` emission. See SPEC 8 § "v0.5 cross-spec coupling
|
|
806
|
+
* fixes" — gap D2 — for the forward-compat rationale.
|
|
807
|
+
*/
|
|
808
|
+
| {
|
|
809
|
+
type: 'pending_input';
|
|
810
|
+
/** Form schema (shape locked in SPEC 9 v0.1.2; engine treats it opaquely). */
|
|
811
|
+
schema: unknown;
|
|
812
|
+
/** Engine round-trip identifier — host posts the answer back keyed on this. */
|
|
813
|
+
inputId: string;
|
|
814
|
+
/** Optional human-readable prompt the LLM wants the host to display above the form. */
|
|
815
|
+
prompt?: string;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* [SPEC 8 v0.5.1 B3.2] One-shot per-turn declaration of which adaptive
|
|
819
|
+
* harness shape this turn is running under. Emitted at the start of
|
|
820
|
+
* `submitMessage` BEFORE `agentLoop` begins (not on `resumeWithToolResult`
|
|
821
|
+
* — resume is a continuation of the same turn, not a new shape decision).
|
|
822
|
+
*
|
|
823
|
+
* Derived from `classifyEffort()` on the host side: `low → 'lean'`,
|
|
824
|
+
* `medium → 'standard'`, `high → 'rich'`, `max → 'max'`. Hosts use it
|
|
825
|
+
* to (a) pre-allocate UI affordances (todo surface for `rich+`),
|
|
826
|
+
* (b) stamp `TurnMetrics.harnessShape` for dashboard segmentation,
|
|
827
|
+
* and (c) gate optional features (e.g. forbid `update_todo` rendering
|
|
828
|
+
* on `lean` even if a misbehaving LLM emits one).
|
|
829
|
+
*
|
|
830
|
+
* If absent, hosts MUST default to `'legacy'` for telemetry purposes
|
|
831
|
+
* (existing engines that don't emit this event are pre-SPEC-8). The
|
|
832
|
+
* engine emits it ONLY when the host passes `harnessShape` into
|
|
833
|
+
* `submitMessage` options; hosts that don't classify won't see this
|
|
834
|
+
* event.
|
|
835
|
+
*/
|
|
836
|
+
| {
|
|
837
|
+
type: 'harness_shape';
|
|
838
|
+
shape: HarnessShape;
|
|
839
|
+
/**
|
|
840
|
+
* 1-line human-readable explanation of why this shape was picked.
|
|
841
|
+
* Examples: "matched recipe portfolio_rebalance → max",
|
|
842
|
+
* "session has prior writes + 'borrow' keyword → rich",
|
|
843
|
+
* "single-fact lookup → lean". Forwarded into telemetry verbatim.
|
|
844
|
+
*/
|
|
845
|
+
rationale: string;
|
|
685
846
|
};
|
|
847
|
+
/**
|
|
848
|
+
* [SPEC 8 v0.5.1 B3.2] Adaptive harness shape — driven by `classifyEffort()`,
|
|
849
|
+
* pinned per-turn at turn start. Each shape implies a different
|
|
850
|
+
* `thinking.budget_tokens` cap, soft block limit, and `update_todo`
|
|
851
|
+
* permission. See SPEC 8 § "Adaptive thresholds: harness shape gate"
|
|
852
|
+
* for the canonical mapping.
|
|
853
|
+
*/
|
|
854
|
+
type HarnessShape = 'lean' | 'standard' | 'rich' | 'max';
|
|
855
|
+
/**
|
|
856
|
+
* [SPEC 8 v0.5.1 B3.2] Maps the engine's `ThinkingEffort` to the host-facing
|
|
857
|
+
* harness shape. Single source of truth for the `low → lean`, `medium →
|
|
858
|
+
* standard`, `high → rich`, `max → max` mapping. Exported so hosts (and
|
|
859
|
+
* tests) get the mapping for free without re-implementing it.
|
|
860
|
+
*/
|
|
861
|
+
declare function harnessShapeForEffort(effort: ThinkingEffort): HarnessShape;
|
|
862
|
+
/**
|
|
863
|
+
* [SPEC 8 v0.5.1] One row in an `update_todo` payload. Mirrored from
|
|
864
|
+
* `packages/engine/src/tools/update-todo.ts`. Kept here so hosts that
|
|
865
|
+
* consume `EngineEvent` don't need to depend on the tool module.
|
|
866
|
+
*/
|
|
867
|
+
interface TodoItem$1 {
|
|
868
|
+
id: string;
|
|
869
|
+
label: string;
|
|
870
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
871
|
+
}
|
|
686
872
|
type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'max_turns' | 'error';
|
|
687
873
|
/**
|
|
688
874
|
* [v1.4 Item 6] Describes a single input field on a `PendingAction` that
|
|
@@ -807,6 +993,23 @@ interface ToolContext {
|
|
|
807
993
|
* primarily a fast-path optimisation rather than a correctness primitive.
|
|
808
994
|
*/
|
|
809
995
|
portfolioCache?: Map<string, AddressPortfolio>;
|
|
996
|
+
/**
|
|
997
|
+
* [SPEC 8 v0.5.1 B3.2] Per-tool-invocation HTTP attempt counter. The
|
|
998
|
+
* engine's tool dispatcher attaches a fresh `{ attemptCount: 1 }` to
|
|
999
|
+
* the context before calling each tool; retry wrappers
|
|
1000
|
+
* (`fetchBlockVisionWithRetry` and equivalents) bump
|
|
1001
|
+
* `retryStats.attemptCount` on every retry beyond the first attempt;
|
|
1002
|
+
* the dispatcher reads the final value back and surfaces it on the
|
|
1003
|
+
* `tool_result` event (only when > 1). Tools that don't use a retry
|
|
1004
|
+
* wrapper never observe a non-default value.
|
|
1005
|
+
*
|
|
1006
|
+
* The mutable-ref shape is deliberate — it lets retry wrappers deep
|
|
1007
|
+
* in the call stack record state without changing every caller's
|
|
1008
|
+
* return type.
|
|
1009
|
+
*/
|
|
1010
|
+
retryStats?: {
|
|
1011
|
+
attemptCount: number;
|
|
1012
|
+
};
|
|
810
1013
|
}
|
|
811
1014
|
interface ServerPositionData {
|
|
812
1015
|
savings: number;
|
|
@@ -1057,10 +1260,14 @@ interface ToolDefinition {
|
|
|
1057
1260
|
type ProviderEvent = {
|
|
1058
1261
|
type: 'thinking_delta';
|
|
1059
1262
|
text: string;
|
|
1263
|
+
blockIndex: number;
|
|
1060
1264
|
} | {
|
|
1061
1265
|
type: 'thinking_done';
|
|
1266
|
+
blockIndex: number;
|
|
1062
1267
|
thinking: string;
|
|
1063
1268
|
signature: string;
|
|
1269
|
+
summaryMode?: boolean;
|
|
1270
|
+
evaluationItems?: EvaluationItem[];
|
|
1064
1271
|
} | {
|
|
1065
1272
|
type: 'redacted_thinking';
|
|
1066
1273
|
data: string;
|
|
@@ -1172,8 +1379,20 @@ declare class QueryEngine {
|
|
|
1172
1379
|
* `pending_action` event and the stream ends — no persistent connection needed.
|
|
1173
1380
|
* The caller should save messages + pendingAction to the session store, then
|
|
1174
1381
|
* call `resumeWithToolResult()` after the user approves/denies and executes.
|
|
1382
|
+
*
|
|
1383
|
+
* [SPEC 8 v0.5.1 B3.2] Optional `options.harnessShape` + `options.harnessRationale`
|
|
1384
|
+
* cause a one-shot `harness_shape` event to be yielded BEFORE the agent loop
|
|
1385
|
+
* begins. The engine itself doesn't classify — the host calls
|
|
1386
|
+
* `classifyEffort()` (host already does this for thinking-budget routing)
|
|
1387
|
+
* and maps via `harnessShapeForEffort()` before calling `submitMessage`.
|
|
1388
|
+
* Hosts that don't pass `harnessShape` won't see the event (existing
|
|
1389
|
+
* pre-SPEC-8 hosts continue to work; their `TurnMetrics.harnessShape`
|
|
1390
|
+
* defaults to `'legacy'`).
|
|
1175
1391
|
*/
|
|
1176
|
-
submitMessage(prompt: string
|
|
1392
|
+
submitMessage(prompt: string, options?: {
|
|
1393
|
+
harnessShape?: HarnessShape;
|
|
1394
|
+
harnessRationale?: string;
|
|
1395
|
+
}): AsyncGenerator<EngineEvent>;
|
|
1177
1396
|
/**
|
|
1178
1397
|
* Resume the conversation after a pending action is resolved.
|
|
1179
1398
|
* Called with the user's approval/denial and optional client-side execution result.
|
|
@@ -1276,9 +1495,13 @@ declare function findTool(tools: Tool[], name: string): Tool | undefined;
|
|
|
1276
1495
|
type SSEEvent = {
|
|
1277
1496
|
type: 'thinking_delta';
|
|
1278
1497
|
text: string;
|
|
1498
|
+
blockIndex: number;
|
|
1279
1499
|
} | {
|
|
1280
1500
|
type: 'thinking_done';
|
|
1501
|
+
blockIndex: number;
|
|
1281
1502
|
signature?: string;
|
|
1503
|
+
summaryMode?: boolean;
|
|
1504
|
+
evaluationItems?: EvaluationItem[];
|
|
1282
1505
|
} | {
|
|
1283
1506
|
type: 'text_delta';
|
|
1284
1507
|
text: string;
|
|
@@ -1296,6 +1519,7 @@ type SSEEvent = {
|
|
|
1296
1519
|
wasEarlyDispatched?: boolean;
|
|
1297
1520
|
resultDeduped?: boolean;
|
|
1298
1521
|
wasPostWriteRefresh?: boolean;
|
|
1522
|
+
attemptCount?: number;
|
|
1299
1523
|
} | {
|
|
1300
1524
|
type: 'pending_action';
|
|
1301
1525
|
action: PendingAction;
|
|
@@ -1317,6 +1541,25 @@ type SSEEvent = {
|
|
|
1317
1541
|
data: unknown;
|
|
1318
1542
|
title: string;
|
|
1319
1543
|
toolUseId: string;
|
|
1544
|
+
} | {
|
|
1545
|
+
type: 'todo_update';
|
|
1546
|
+
items: TodoItem$1[];
|
|
1547
|
+
toolUseId: string;
|
|
1548
|
+
} | {
|
|
1549
|
+
type: 'tool_progress';
|
|
1550
|
+
toolUseId: string;
|
|
1551
|
+
toolName: string;
|
|
1552
|
+
message: string;
|
|
1553
|
+
pct?: number;
|
|
1554
|
+
} | {
|
|
1555
|
+
type: 'pending_input';
|
|
1556
|
+
schema: unknown;
|
|
1557
|
+
inputId: string;
|
|
1558
|
+
prompt?: string;
|
|
1559
|
+
} | {
|
|
1560
|
+
type: 'harness_shape';
|
|
1561
|
+
shape: HarnessShape;
|
|
1562
|
+
rationale: string;
|
|
1320
1563
|
};
|
|
1321
1564
|
declare function serializeSSE(event: SSEEvent): string;
|
|
1322
1565
|
declare function parseSSE(raw: string): SSEEvent | null;
|
|
@@ -1392,6 +1635,24 @@ declare function getToolFlags(name: string): ToolFlags;
|
|
|
1392
1635
|
*/
|
|
1393
1636
|
declare function classifyEffort(model: string, userMessage: string, matchedRecipe: Recipe | null, sessionWriteCount: number): ThinkingEffort;
|
|
1394
1637
|
|
|
1638
|
+
declare const EFFORT_THINKING_BUDGET_CAPS: Record<ThinkingEffort, number | null>;
|
|
1639
|
+
/**
|
|
1640
|
+
* Clamp a `ThinkingConfig` to the HARD cap for the given effort tier.
|
|
1641
|
+
*
|
|
1642
|
+
* - When `effort === 'low'`, returns `{ type: 'disabled' }` regardless of
|
|
1643
|
+
* input — LEAN tier is non-negotiable.
|
|
1644
|
+
* - When `config.type === 'enabled'` and `config.budgetTokens` exceeds
|
|
1645
|
+
* the cap, returns a copy with `budgetTokens` clamped down.
|
|
1646
|
+
* - When `config.type === 'adaptive'`, returns it unchanged — adaptive
|
|
1647
|
+
* mode is shape-agnostic by design (Anthropic decides per-turn).
|
|
1648
|
+
* - When `effort` is undefined, returns `config` unchanged — caller
|
|
1649
|
+
* hasn't classified the turn yet (back-compat for hosts that don't
|
|
1650
|
+
* route on effort).
|
|
1651
|
+
*
|
|
1652
|
+
* This function is pure and side-effect-free; safe to call per-turn.
|
|
1653
|
+
*/
|
|
1654
|
+
declare function clampThinkingForEffort(config: ThinkingConfig | undefined, effort: ThinkingEffort | undefined): ThinkingConfig | undefined;
|
|
1655
|
+
|
|
1395
1656
|
/**
|
|
1396
1657
|
* Build a cacheable system prompt array from static and dynamic parts.
|
|
1397
1658
|
*
|
|
@@ -2435,6 +2696,63 @@ declare const resolveSuinsTool: Tool<{
|
|
|
2435
2696
|
query: string;
|
|
2436
2697
|
}, ResolveSuinsResult>;
|
|
2437
2698
|
|
|
2699
|
+
declare const todoItemSchema: z.ZodObject<{
|
|
2700
|
+
id: z.ZodString;
|
|
2701
|
+
label: z.ZodString;
|
|
2702
|
+
status: z.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
2703
|
+
}, "strip", z.ZodTypeAny, {
|
|
2704
|
+
label: string;
|
|
2705
|
+
status: "pending" | "in_progress" | "completed";
|
|
2706
|
+
id: string;
|
|
2707
|
+
}, {
|
|
2708
|
+
label: string;
|
|
2709
|
+
status: "pending" | "in_progress" | "completed";
|
|
2710
|
+
id: string;
|
|
2711
|
+
}>;
|
|
2712
|
+
declare const inputSchema: z.ZodObject<{
|
|
2713
|
+
items: z.ZodArray<z.ZodObject<{
|
|
2714
|
+
id: z.ZodString;
|
|
2715
|
+
label: z.ZodString;
|
|
2716
|
+
status: z.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
2717
|
+
}, "strip", z.ZodTypeAny, {
|
|
2718
|
+
label: string;
|
|
2719
|
+
status: "pending" | "in_progress" | "completed";
|
|
2720
|
+
id: string;
|
|
2721
|
+
}, {
|
|
2722
|
+
label: string;
|
|
2723
|
+
status: "pending" | "in_progress" | "completed";
|
|
2724
|
+
id: string;
|
|
2725
|
+
}>, "many">;
|
|
2726
|
+
}, "strip", z.ZodTypeAny, {
|
|
2727
|
+
items: {
|
|
2728
|
+
label: string;
|
|
2729
|
+
status: "pending" | "in_progress" | "completed";
|
|
2730
|
+
id: string;
|
|
2731
|
+
}[];
|
|
2732
|
+
}, {
|
|
2733
|
+
items: {
|
|
2734
|
+
label: string;
|
|
2735
|
+
status: "pending" | "in_progress" | "completed";
|
|
2736
|
+
id: string;
|
|
2737
|
+
}[];
|
|
2738
|
+
}>;
|
|
2739
|
+
type TodoItem = z.infer<typeof todoItemSchema>;
|
|
2740
|
+
type UpdateTodoInput = z.infer<typeof inputSchema>;
|
|
2741
|
+
declare const updateTodoTool: Tool<{
|
|
2742
|
+
items: {
|
|
2743
|
+
label: string;
|
|
2744
|
+
status: "pending" | "in_progress" | "completed";
|
|
2745
|
+
id: string;
|
|
2746
|
+
}[];
|
|
2747
|
+
}, {
|
|
2748
|
+
__todoUpdate: boolean;
|
|
2749
|
+
items: {
|
|
2750
|
+
label: string;
|
|
2751
|
+
status: "pending" | "in_progress" | "completed";
|
|
2752
|
+
id: string;
|
|
2753
|
+
}[];
|
|
2754
|
+
}>;
|
|
2755
|
+
|
|
2438
2756
|
declare const tokenPricesTool: Tool<{
|
|
2439
2757
|
coinTypes: string[];
|
|
2440
2758
|
include24hChange?: boolean | undefined;
|
|
@@ -3020,4 +3338,4 @@ declare function getTelemetrySink(): TelemetrySink;
|
|
|
3020
3338
|
/** Restore the default noop sink. Used by test teardowns. */
|
|
3021
3339
|
declare function resetTelemetrySink(): void;
|
|
3022
3340
|
|
|
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 };
|
|
3341
|
+
export { type AddressPortfolio, AnthropicProvider, type AnthropicProviderConfig, type AudricHistoryRecord, type AudricPortfolioResult, type AwaitOrFetchOpts, type BalancePrices, type BalanceResult, BalanceTracker, type BuildToolOptions, CANVAS_TEMPLATES, type CanvasTemplate, type ChatParams, type CompactOptions, type ContentBlock, ContextBudget, type ContextBudgetConfig, type ConversationState, type ConversationStateStore, type CostSnapshot, CostTracker, type CostTrackerConfig, DEFAULT_GUARD_CONFIG, DEFAULT_LEASE_SEC, DEFAULT_PERMISSION_CONFIG, DEFAULT_POLL_BUDGET_MS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_SYSTEM_PROMPT, type DefiCacheEntry, type DefiCacheStore, type DefiProtocol, type DefiSummary, EFFORT_THINKING_BUDGET_CAPS, EarlyToolDispatcher, type EngineConfig, type EngineEvent, type EvalSummaryParseResult, type EvaluationItem, type EvaluationStatus, type FetchLock, type GuardCheckResult, type GuardConfig, type GuardEvent, type GuardInjection, type GuardResult, type GuardRunnerState, type GuardTier, type GuardVerdict, type HarnessShape, type HealthFactorResult, InMemoryDefiCacheStore, InMemoryFetchLock, InMemoryNaviCacheStore, InMemoryWalletCacheStore, InvalidAddressError, type LLMProvider, type McpCallResult, McpClientManager, McpResponseCache, type McpServerConfig, type McpServerConnection, type McpToolAdapterConfig, type McpToolDescriptor, MemorySessionStore, type Message, NAVI_ADDR_TTL_SEC, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_RATES_TTL_SEC, NAVI_SERVER_NAME, type NaviCacheEntry, type NaviCacheStore, type NaviRawCoin, type NaviRawHealthFactor, type NaviRawPool, type NaviRawPosition, type NaviRawPositionsResponse, type NaviRawProtocolStats, type NaviRawRewardsResponse, type NaviReadOptions, NaviTools, type NormalizedAddress, type OutputConfig, PERMISSION_PRESETS, type PendingAction, type PendingActionModifiableField, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionOperation, type PermissionResponse, type PermissionRule, type PortfolioCoin, type PositionEntry, type PreflightResult, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, type RatesResult, type Recipe, type RecipePrerequisite, RecipeRegistry, type RecipeStep, type RecipeStepOnError, RetryTracker, type SSEEvent, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, type SavingsResult, type ServerPositionData, type SessionData, type SessionStore, type StateType, type StopReason, type SuiCoinBalance, SuinsNotRegisteredError, SuinsRpcError, type SystemBlock, type SystemPrompt, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, type TelemetrySink, type TelemetryTags, type ThinkingConfig, type ThinkingEffort, type TodoItem$1 as TodoItem, type Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolFlags, type ToolJsonSchema, type ToolResult, TxMutex, type UpdateTodoInput, type TodoItem as UpdateTodoItem, type UserFinancialProfile, type UserPermissionConfig, WRITE_TOOLS, type WalletCacheEntry, type WalletCacheStore, type WalletCoin, _resetNaviCircuitBreaker, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, awaitOrFetch, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, claimRewardsTool, clampThinkingForEffort, classifyEffort, clearPortfolioCache, clearPortfolioCacheFor, clearPriceMapCache, compactMessages, createGuardRunnerState, engineToSSE, estimateTokens, explainTxTool, extractConversationText, extractMcpText, fetchAddressDefiPortfolio, fetchAddressPortfolio, fetchAudricHistory, fetchAudricPortfolio, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getAudricApiBase, getDefaultTools, getDefiCacheStore, getFetchLock, getMcpManager, getModifiableFields, getNaviCacheStore, getTelemetrySink, getToolFlags, getWalletAddress, getWalletCacheStore, guardArtifactPreview, guardStaleData, harnessShapeForEffort, hasNaviMcp, healthCheckTool, loadRecipes, looksLikeSuiNs, microcompact, mppServicesTool, naviKey, normalizeAddressInput, parseEvalSummary, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resetDefiCacheStore, resetFetchLock, resetNaviCacheStore, resetTelemetrySink, resetWalletCacheStore, resolveAddressToSuinsViaRpc, resolvePermissionTier, resolveSuinsTool, resolveSuinsViaRpc, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, setDefiCacheStore, setFetchLock, setNaviCacheStore, setTelemetrySink, setWalletCacheStore, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, updateTodoTool, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
|