@t2000/engine 1.2.1 → 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 +244 -10
- package/dist/index.js +292 -28
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1714,6 +1714,44 @@ async function resolveSuinsViaRpc(rawName, ctx = {}) {
|
|
|
1714
1714
|
}
|
|
1715
1715
|
return body.result ?? null;
|
|
1716
1716
|
}
|
|
1717
|
+
async function resolveAddressToSuinsViaRpc(rawAddress, ctx = {}) {
|
|
1718
|
+
const address = rawAddress.trim().toLowerCase();
|
|
1719
|
+
if (!SUI_ADDRESS_REGEX.test(address)) {
|
|
1720
|
+
throw new InvalidAddressError(rawAddress);
|
|
1721
|
+
}
|
|
1722
|
+
const url = ctx.suiRpcUrl || SUI_MAINNET_URL2;
|
|
1723
|
+
let res;
|
|
1724
|
+
try {
|
|
1725
|
+
res = await fetch(url, {
|
|
1726
|
+
method: "POST",
|
|
1727
|
+
headers: { "Content-Type": "application/json" },
|
|
1728
|
+
body: JSON.stringify({
|
|
1729
|
+
jsonrpc: "2.0",
|
|
1730
|
+
id: 1,
|
|
1731
|
+
method: "suix_resolveNameServiceNames",
|
|
1732
|
+
params: [address]
|
|
1733
|
+
}),
|
|
1734
|
+
signal: ctx.signal ?? AbortSignal.timeout(8e3)
|
|
1735
|
+
});
|
|
1736
|
+
} catch (err) {
|
|
1737
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1738
|
+
throw new SuinsRpcError(address, msg);
|
|
1739
|
+
}
|
|
1740
|
+
if (!res.ok) {
|
|
1741
|
+
throw new SuinsRpcError(address, `HTTP ${res.status}`);
|
|
1742
|
+
}
|
|
1743
|
+
let body;
|
|
1744
|
+
try {
|
|
1745
|
+
body = await res.json();
|
|
1746
|
+
} catch (err) {
|
|
1747
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1748
|
+
throw new SuinsRpcError(address, `JSON parse failed: ${msg}`);
|
|
1749
|
+
}
|
|
1750
|
+
if (body.error) {
|
|
1751
|
+
throw new SuinsRpcError(address, body.error.message);
|
|
1752
|
+
}
|
|
1753
|
+
return body.result?.data ?? [];
|
|
1754
|
+
}
|
|
1717
1755
|
async function normalizeAddressInput(value, ctx = {}) {
|
|
1718
1756
|
const trimmed = value.trim();
|
|
1719
1757
|
if (SUI_ADDRESS_REGEX.test(trimmed)) {
|
|
@@ -4986,63 +5024,184 @@ var activitySummaryTool = buildTool({
|
|
|
4986
5024
|
}
|
|
4987
5025
|
});
|
|
4988
5026
|
var inputSchema5 = z.object({
|
|
4989
|
-
|
|
4990
|
-
'
|
|
5027
|
+
query: z.string().describe(
|
|
5028
|
+
'Either a SuiNS name (e.g. "alex.sui", "team.alex.sui") to FORWARD-resolve to its 0x address, OR a Sui address (0x\u2026 64 hex chars) to REVERSE-resolve to its registered SuiNS name(s). The engine detects direction by input shape.'
|
|
4991
5029
|
)
|
|
4992
5030
|
});
|
|
4993
5031
|
var resolveSuinsTool = buildTool({
|
|
4994
5032
|
name: "resolve_suins",
|
|
4995
|
-
description: '
|
|
5033
|
+
description: 'Look up SuiNS records on-chain \u2014 works in BOTH directions. FORWARD: pass a SuiNS name (e.g. "alex.sui") to get the 0x address it resolves to. REVERSE: pass a Sui 0x address to get the SuiNS name(s) registered for it (returns the primary name + the full list). \n\nUse this WHENEVER the user mentions a `.sui` name OR asks "what\'s the SuiNS for 0x\u2026", "does 0x\u2026 have a name", "who is 0x\u2026". You MUST call this tool \u2014 never guess from saved contacts (a contact named "alex" is NOT the same as the SuiNS name "alex.sui"; verify on-chain). Never use `web_search` for SuiNS \u2014 web_search doesn\'t index the SuiNS registry, but this tool queries the canonical on-chain RPC. \n\nReturns `{ direction, address, registered }` for forward, `{ direction, names, primary }` for reverse. Empty `names: []` means the address has no SuiNS records. \n\nNOTE: For money-flow questions about a `.sui` name ("what\'s alex.sui\'s balance / portfolio / health / transactions"), call the relevant read tool directly with `address: "alex.sui"` \u2014 those tools normalize SuiNS internally, so an explicit `resolve_suins` round-trip is wasted.',
|
|
4996
5034
|
inputSchema: inputSchema5,
|
|
4997
5035
|
jsonSchema: {
|
|
4998
5036
|
type: "object",
|
|
4999
5037
|
properties: {
|
|
5000
|
-
|
|
5038
|
+
query: {
|
|
5001
5039
|
type: "string",
|
|
5002
|
-
description: 'A SuiNS name
|
|
5040
|
+
description: 'A SuiNS name (e.g. "alex.sui") for forward resolution, OR a 0x Sui address for reverse resolution.'
|
|
5003
5041
|
}
|
|
5004
5042
|
},
|
|
5005
|
-
required: ["
|
|
5043
|
+
required: ["query"]
|
|
5006
5044
|
},
|
|
5007
5045
|
isReadOnly: true,
|
|
5008
|
-
//
|
|
5009
|
-
//
|
|
5046
|
+
// Lookups map to (address|name) pairs on a per-block basis. Cheap and
|
|
5047
|
+
// deterministic for a given block — safe to dedupe within a turn.
|
|
5010
5048
|
cacheable: true,
|
|
5011
5049
|
preflight: (input) => {
|
|
5012
|
-
const trimmed = input.
|
|
5050
|
+
const trimmed = input.query?.trim().toLowerCase();
|
|
5013
5051
|
if (!trimmed) {
|
|
5014
|
-
return { valid: false, error: "
|
|
5052
|
+
return { valid: false, error: "query is required" };
|
|
5015
5053
|
}
|
|
5016
|
-
|
|
5054
|
+
const isAddress = SUI_ADDRESS_REGEX.test(trimmed);
|
|
5055
|
+
const isName = SUINS_NAME_REGEX.test(trimmed);
|
|
5056
|
+
if (!isAddress && !isName) {
|
|
5017
5057
|
return {
|
|
5018
5058
|
valid: false,
|
|
5019
|
-
error: `"${input.
|
|
5059
|
+
error: `"${input.query}" doesn't look like a SuiNS name or a Sui address. Pass either a name ending in .sui (e.g. alex.sui) or a 0x-prefixed hex address.`
|
|
5020
5060
|
};
|
|
5021
5061
|
}
|
|
5022
5062
|
return { valid: true };
|
|
5023
5063
|
},
|
|
5024
5064
|
async call(input, context) {
|
|
5025
|
-
const
|
|
5026
|
-
|
|
5065
|
+
const query = input.query.trim().toLowerCase();
|
|
5066
|
+
const isAddress = SUI_ADDRESS_REGEX.test(query);
|
|
5027
5067
|
try {
|
|
5028
|
-
|
|
5068
|
+
if (isAddress) {
|
|
5069
|
+
const names = await resolveAddressToSuinsViaRpc(query, {
|
|
5070
|
+
suiRpcUrl: context.suiRpcUrl,
|
|
5071
|
+
signal: context.signal
|
|
5072
|
+
});
|
|
5073
|
+
const primary = names[0] ?? null;
|
|
5074
|
+
const result2 = {
|
|
5075
|
+
direction: "reverse",
|
|
5076
|
+
query,
|
|
5077
|
+
names,
|
|
5078
|
+
primary
|
|
5079
|
+
};
|
|
5080
|
+
return {
|
|
5081
|
+
data: result2,
|
|
5082
|
+
displayText: primary ? `\`${query.slice(0, 10)}\u2026${query.slice(-6)}\` \u2192 ${primary}${names.length > 1 ? ` (+${names.length - 1} more)` : ""}` : `\`${query.slice(0, 10)}\u2026${query.slice(-6)}\` has no SuiNS name registered.`
|
|
5083
|
+
};
|
|
5084
|
+
}
|
|
5085
|
+
const address = await resolveSuinsViaRpc(query, {
|
|
5029
5086
|
suiRpcUrl: context.suiRpcUrl,
|
|
5030
5087
|
signal: context.signal
|
|
5031
5088
|
});
|
|
5089
|
+
const result = {
|
|
5090
|
+
direction: "forward",
|
|
5091
|
+
query,
|
|
5092
|
+
address,
|
|
5093
|
+
registered: address !== null
|
|
5094
|
+
};
|
|
5095
|
+
return {
|
|
5096
|
+
data: result,
|
|
5097
|
+
displayText: address ? `${query} \u2192 \`${address.slice(0, 10)}\u2026${address.slice(-6)}\`` : `${query} is not a registered SuiNS name.`
|
|
5098
|
+
};
|
|
5032
5099
|
} catch (err) {
|
|
5033
5100
|
if (err instanceof SuinsRpcError) {
|
|
5034
5101
|
throw err;
|
|
5035
5102
|
}
|
|
5036
5103
|
throw err;
|
|
5037
5104
|
}
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5105
|
+
}
|
|
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) {
|
|
5043
5195
|
return {
|
|
5044
|
-
|
|
5045
|
-
|
|
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(" / ")}`
|
|
5046
5205
|
};
|
|
5047
5206
|
}
|
|
5048
5207
|
});
|
|
@@ -5292,6 +5451,29 @@ var CostTracker = class {
|
|
|
5292
5451
|
}
|
|
5293
5452
|
};
|
|
5294
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
|
+
|
|
5295
5477
|
// src/guards.ts
|
|
5296
5478
|
function guardVerdictToAction(verdict) {
|
|
5297
5479
|
if (verdict === "pass" || verdict === "hint") return "allow";
|
|
@@ -6882,6 +7064,7 @@ ${recipeCtx}`;
|
|
|
6882
7064
|
];
|
|
6883
7065
|
}
|
|
6884
7066
|
}
|
|
7067
|
+
const cappedThinking = clampThinkingForEffort(this.thinking, this.outputConfig?.effort);
|
|
6885
7068
|
const stream = this.provider.chat({
|
|
6886
7069
|
messages: this.messages,
|
|
6887
7070
|
systemPrompt: effectivePrompt,
|
|
@@ -6890,7 +7073,7 @@ ${recipeCtx}`;
|
|
|
6890
7073
|
maxTokens: this.maxTokens,
|
|
6891
7074
|
temperature: this.temperature,
|
|
6892
7075
|
toolChoice: effectiveToolChoice,
|
|
6893
|
-
thinking:
|
|
7076
|
+
thinking: cappedThinking,
|
|
6894
7077
|
outputConfig: this.outputConfig,
|
|
6895
7078
|
signal
|
|
6896
7079
|
});
|
|
@@ -6971,6 +7154,13 @@ ${recipeCtx}`;
|
|
|
6971
7154
|
toolUseId: finalEvent.toolUseId
|
|
6972
7155
|
};
|
|
6973
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
|
+
}
|
|
6974
7164
|
}
|
|
6975
7165
|
earlyResultBlocks.push({
|
|
6976
7166
|
type: "tool_result",
|
|
@@ -7167,6 +7357,13 @@ ${recipeCtx}`;
|
|
|
7167
7357
|
toolUseId: finalEvent.toolUseId
|
|
7168
7358
|
};
|
|
7169
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
|
+
}
|
|
7170
7367
|
if (tool && !tool.isReadOnly && this.onAutoExecuted && this.permissionConfig && this.priceCache) {
|
|
7171
7368
|
const operation = toolNameToOperation(toolEvent.toolName);
|
|
7172
7369
|
if (operation && originalCall) {
|
|
@@ -7258,6 +7455,11 @@ ${recipeCtx}`;
|
|
|
7258
7455
|
}
|
|
7259
7456
|
this.messages.push({ role: "assistant", content: acc.assistantBlocks });
|
|
7260
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
|
+
}
|
|
7261
7463
|
if (this.costTracker.isOverBudget()) {
|
|
7262
7464
|
yield { type: "error", error: new Error("Session budget exceeded") };
|
|
7263
7465
|
return;
|
|
@@ -7282,7 +7484,7 @@ ${recipeCtx}`;
|
|
|
7282
7484
|
*handleProviderEvent(event, acc, dispatcher) {
|
|
7283
7485
|
switch (event.type) {
|
|
7284
7486
|
case "thinking_delta": {
|
|
7285
|
-
yield { type: "thinking_delta", text: event.text };
|
|
7487
|
+
yield { type: "thinking_delta", text: event.text, blockIndex: event.blockIndex };
|
|
7286
7488
|
break;
|
|
7287
7489
|
}
|
|
7288
7490
|
case "thinking_done": {
|
|
@@ -7291,7 +7493,14 @@ ${recipeCtx}`;
|
|
|
7291
7493
|
thinking: event.thinking,
|
|
7292
7494
|
signature: event.signature
|
|
7293
7495
|
});
|
|
7294
|
-
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
|
+
};
|
|
7295
7504
|
break;
|
|
7296
7505
|
}
|
|
7297
7506
|
case "redacted_thinking": {
|
|
@@ -7727,6 +7936,54 @@ function classifyEffort(model, userMessage, matchedRecipe, sessionWriteCount) {
|
|
|
7727
7936
|
return "medium";
|
|
7728
7937
|
}
|
|
7729
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
|
+
|
|
7730
7987
|
// src/prompt-cache.ts
|
|
7731
7988
|
function buildCachedSystemPrompt(staticParts, dynamicPart) {
|
|
7732
7989
|
const blocks = staticParts.map((text, i) => ({
|
|
@@ -8284,7 +8541,7 @@ var AnthropicProvider = class {
|
|
|
8284
8541
|
} else if (delta.type === "thinking_delta") {
|
|
8285
8542
|
const buf = thinkingBuffers.get(event.index);
|
|
8286
8543
|
if (buf?.type === "thinking") buf.text += delta.thinking ?? "";
|
|
8287
|
-
yield { type: "thinking_delta", text: delta.thinking ?? "" };
|
|
8544
|
+
yield { type: "thinking_delta", text: delta.thinking ?? "", blockIndex: event.index };
|
|
8288
8545
|
} else if (delta.type === "signature_delta") {
|
|
8289
8546
|
const buf = thinkingBuffers.get(event.index);
|
|
8290
8547
|
if (buf?.type === "thinking") buf.signature = delta.signature ?? "";
|
|
@@ -8310,7 +8567,14 @@ var AnthropicProvider = class {
|
|
|
8310
8567
|
}
|
|
8311
8568
|
const thinkBuf = thinkingBuffers.get(event.index);
|
|
8312
8569
|
if (thinkBuf?.type === "thinking") {
|
|
8313
|
-
|
|
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
|
+
};
|
|
8314
8578
|
thinkingBuffers.delete(event.index);
|
|
8315
8579
|
} else if (thinkBuf?.type === "redacted_thinking") {
|
|
8316
8580
|
yield { type: "redacted_thinking", data: thinkBuf.data };
|
|
@@ -8524,6 +8788,6 @@ function sanitizeAnthropicMessages(messages) {
|
|
|
8524
8788
|
return merged;
|
|
8525
8789
|
}
|
|
8526
8790
|
|
|
8527
|
-
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, 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 };
|
|
8528
8792
|
//# sourceMappingURL=index.js.map
|
|
8529
8793
|
//# sourceMappingURL=index.js.map
|