@t2000/engine 1.9.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3056,7 +3056,7 @@ var transactionHistoryTool = buildTool({
3056
3056
  var SAVE_ASSETS = ["USDC", "USDsui"];
3057
3057
  var saveDepositTool = buildTool({
3058
3058
  name: "save_deposit",
3059
- description: 'Deposit USDC or USDsui into NAVI savings to earn yield. ONLY these two stables are accepted. If the user asks to save/deposit any other token (GOLD, SUI, USDT, USDe, ETH, etc.), do NOT call this tool and do NOT automatically swap their tokens and deposit. Instead, tell the user that only USDC and USDsui deposits are supported and ask if they would like to swap first. Let the user decide \u2014 never auto-chain swap + deposit. When the user says "save 10 USDC" pass asset="USDC". When they say "save 10 USDsui" pass asset="USDsui". When they say "save 10" with no asset, ALWAYS call balance_check first and ask which stable they want to deposit (or default to whichever they hold more of, with a one-line note). Never silently substitute USDsui for USDC or vice versa.',
3059
+ description: 'Deposit USDC or USDsui into NAVI savings to earn yield. ONLY these two stables are accepted. If the user asks to save/deposit any other token (GOLD, SUI, USDT, USDe, ETH, etc.), do NOT call this tool and do NOT automatically swap their tokens and deposit. Instead, tell the user that only USDC and USDsui deposits are supported and ask if they would like to swap first. Let the user decide \u2014 never auto-chain swap + deposit. When the user says "save 10 USDC" pass asset="USDC". When they say "save 10 USDsui" pass asset="USDsui". When they say "save 10" with no asset, ALWAYS call balance_check first and ask which stable they want to deposit (or default to whichever they hold more of, with a one-line note). Never silently substitute USDsui for USDC or vice versa. Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "swap to USDC and save"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.',
3060
3060
  inputSchema: z.object({
3061
3061
  amount: z.number().positive(),
3062
3062
  asset: z.enum(SAVE_ASSETS).optional().describe('"USDC" or "USDsui". Defaults to USDC when omitted.')
@@ -3109,7 +3109,7 @@ var saveDepositTool = buildTool({
3109
3109
  });
3110
3110
  var withdrawTool = buildTool({
3111
3111
  name: "withdraw",
3112
- description: "Withdraw from NAVI lending back to wallet. Defaults to USDC; also withdraws USDsui (the second active saveable stable). Legacy positions in other assets (USDe, SUI) can still be withdrawn if the user has them \u2014 but only USDC and USDsui are eligible to be re-deposited via save_deposit.",
3112
+ description: 'Withdraw from NAVI lending back to wallet. Defaults to USDC; also withdraws USDsui (the second active saveable stable). Legacy positions in other assets (USDe, SUI) can still be withdrawn if the user has them \u2014 but only USDC and USDsui are eligible to be re-deposited via save_deposit. Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "withdraw and send to Mom"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.',
3113
3113
  inputSchema: z.object({
3114
3114
  amount: z.number().positive(),
3115
3115
  asset: z.string().optional().describe("Asset to withdraw (default: USDC). Active: USDsui. Legacy positions: USDe, SUI.")
@@ -3152,7 +3152,7 @@ var withdrawTool = buildTool({
3152
3152
  var ASSET_LIST = ALL_NAVI_ASSETS.map((a) => String(a)).join(", ");
3153
3153
  var sendTransferTool = buildTool({
3154
3154
  name: "send_transfer",
3155
- description: `Send ANY supported token (${ASSET_LIST}) to another Sui address or contact name. Validates the address, checks balance, and executes the on-chain transfer. MUST set the \`asset\` field to the token symbol you want to send (case-insensitive). If \`asset\` is omitted, USDC is assumed \u2014 only do this when the user explicitly asks for USDC. When the user asks to send a token by name (SUI, USDT, etc.) or to send the proceeds of a just-completed swap, you MUST pass \`asset\` matching that token. Returns tx hash, gas cost, and updated balance.`,
3155
+ description: `Send ANY supported token (${ASSET_LIST}) to another Sui address or contact name. Validates the address, checks balance, and executes the on-chain transfer. MUST set the \`asset\` field to the token symbol you want to send (case-insensitive). If \`asset\` is omitted, USDC is assumed \u2014 only do this when the user explicitly asks for USDC. When the user asks to send a token by name (SUI, USDT, etc.) or to send the proceeds of a just-completed swap, you MUST pass \`asset\` matching that token. Returns tx hash, gas cost, and updated balance. Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "swap to USDC and send to Mom", "withdraw and send"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.`,
3156
3156
  inputSchema: z.object({
3157
3157
  to: z.string().min(1),
3158
3158
  amount: z.number().positive(),
@@ -3229,7 +3229,7 @@ var sendTransferTool = buildTool({
3229
3229
  var BORROW_ASSETS = ["USDC", "USDsui"];
3230
3230
  var borrowTool = buildTool({
3231
3231
  name: "borrow",
3232
- description: 'Borrow USDC or USDsui against savings collateral. ONLY these two stables are supported. Requires existing savings deposits as collateral. Checks max safe borrow and health factor. Returns tx hash, fee, asset borrowed, and post-borrow health factor. When the user says "borrow 10 USDC" pass asset="USDC". When they say "borrow 10 USDsui" pass asset="USDsui". When they say "borrow 10" with no asset, default to USDC unless the user has only USDsui collateral.',
3232
+ description: 'Borrow USDC or USDsui against savings collateral. ONLY these two stables are supported. Requires existing savings deposits as collateral. Checks max safe borrow and health factor. Returns tx hash, fee, asset borrowed, and post-borrow health factor. When the user says "borrow 10 USDC" pass asset="USDC". When they say "borrow 10 USDsui" pass asset="USDsui". When they say "borrow 10" with no asset, default to USDC unless the user has only USDsui collateral. Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "borrow $50 and send to Mom"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.',
3233
3233
  inputSchema: z.object({
3234
3234
  amount: z.number().positive(),
3235
3235
  asset: z.enum(BORROW_ASSETS).optional().describe('"USDC" or "USDsui". Defaults to USDC when omitted.')
@@ -3283,7 +3283,7 @@ var borrowTool = buildTool({
3283
3283
  var REPAY_ASSETS = ["USDC", "USDsui"];
3284
3284
  var repayDebtTool = buildTool({
3285
3285
  name: "repay_debt",
3286
- description: 'Repay outstanding USDC or USDsui debt. Always call balance_check first to know the debt amount + which asset is owed (savings_info shows per-asset borrow positions). Pass asset="USDC" or asset="USDsui" to target a specific debt. When omitted, repays the highest-APY borrow first. Important: a USDsui debt MUST be repaid with USDsui (and USDC debt with USDC) \u2014 the SDK fetches the correct coin type for the targeted asset, but the user must hold enough of that stable in their wallet. If the user has only the wrong stable, do NOT auto-swap \u2014 tell them to swap manually first. Returns tx hash, amount repaid, asset, and remaining debt.',
3286
+ description: 'Repay outstanding USDC or USDsui debt. Always call balance_check first to know the debt amount + which asset is owed (savings_info shows per-asset borrow positions). Pass asset="USDC" or asset="USDsui" to target a specific debt. When omitted, repays the highest-APY borrow first. Important: a USDsui debt MUST be repaid with USDsui (and USDC debt with USDC) \u2014 the SDK fetches the correct coin type for the targeted asset, but the user must hold enough of that stable in their wallet. If the user has only the wrong stable, do NOT auto-swap \u2014 tell them to swap manually first. Returns tx hash, amount repaid, asset, and remaining debt. Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "repay debt then withdraw the rest"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.',
3287
3287
  inputSchema: z.object({
3288
3288
  amount: z.number().positive(),
3289
3289
  asset: z.enum(REPAY_ASSETS).optional().describe('"USDC" or "USDsui". When omitted, repays the highest-APY borrow first.')
@@ -3340,7 +3340,7 @@ function formatAmount(amount) {
3340
3340
  }
3341
3341
  var claimRewardsTool = buildTool({
3342
3342
  name: "claim_rewards",
3343
- description: 'Claim all pending protocol rewards across lending adapters. Returns the claimed reward breakdown (per-asset symbol + amount), total USD value (best effort \u2014 may be 0 when oracle prices are unavailable), and the on-chain tx hash. When the rewards list is empty the response will explicitly say "no pending rewards"; when it is non-empty narrate the per-symbol amounts even if totalValueUsd is 0 (the on-chain credit still happened).',
3343
+ description: 'Claim all pending protocol rewards across lending adapters. Returns the claimed reward breakdown (per-asset symbol + amount), total USD value (best effort \u2014 may be 0 when oracle prices are unavailable), and the on-chain tx hash. When the rewards list is empty the response will explicitly say "no pending rewards"; when it is non-empty narrate the per-symbol amounts even if totalValueUsd is 0 (the on-chain credit still happened). Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "claim rewards and stake them"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.',
3344
3344
  inputSchema: z.object({}),
3345
3345
  jsonSchema: { type: "object", properties: {}, required: [] },
3346
3346
  isReadOnly: false,
@@ -3600,7 +3600,7 @@ var mppServicesTool = buildTool({
3600
3600
  });
3601
3601
  var swapExecuteTool = buildTool({
3602
3602
  name: "swap_execute",
3603
- description: "Swap tokens on Sui via Cetus Aggregator (20+ DEXs). Supports any token pair with liquidity. Use user-friendly names (SUI, USDC, CETUS, DEEP, etc.) or full coin types.",
3603
+ description: 'Swap tokens on Sui via Cetus Aggregator (20+ DEXs). Supports any token pair with liquidity. Use user-friendly names (SUI, USDC, CETUS, DEEP, etc.) or full coin types. Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "swap to USDC and save", "swap and send to Mom"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.',
3604
3604
  inputSchema: z.object({
3605
3605
  from: z.string().describe('Source token (e.g. "SUI", "USDC", or full coin type)'),
3606
3606
  to: z.string().describe('Target token (e.g. "USDC", "CETUS", or full coin type)'),
@@ -3689,7 +3689,7 @@ var swapQuoteTool = buildTool({
3689
3689
  });
3690
3690
  var voloStakeTool = buildTool({
3691
3691
  name: "volo_stake",
3692
- description: "Stake SUI for vSUI via VOLO liquid staking. Earn ~3-5% APY. Rewards compound automatically via exchange rate \u2014 no claiming needed. Minimum 1 SUI.",
3692
+ description: 'Stake SUI for vSUI via VOLO liquid staking. Earn ~3-5% APY. Rewards compound automatically via exchange rate \u2014 no claiming needed. Minimum 1 SUI. Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "swap USDC to SUI and stake"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.',
3693
3693
  inputSchema: z.object({
3694
3694
  amount: z.number().min(1).describe("Amount of SUI to stake (minimum 1)")
3695
3695
  }),
@@ -3720,7 +3720,7 @@ var voloStakeTool = buildTool({
3720
3720
  });
3721
3721
  var voloUnstakeTool = buildTool({
3722
3722
  name: "volo_unstake",
3723
- description: 'Unstake vSUI back to SUI. Returns SUI including accumulated yield. Use amount in vSUI units or "all" to unstake entire position.',
3723
+ description: 'Unstake vSUI back to SUI. Returns SUI including accumulated yield. Use amount in vSUI units or "all" to unstake entire position. Payment Stream: bundleable \u2014 when paired with another bundleable write in the same request (e.g. "unstake vSUI and send to Mom"), emit all calls in the same assistant turn so the engine collapses them into one atomic PTB the user signs once.',
3724
3724
  inputSchema: z.object({
3725
3725
  amount: z.union([z.number().positive(), z.literal("all")]).describe('Amount of vSUI to unstake, or "all"')
3726
3726
  }),
@@ -7290,6 +7290,7 @@ var QueryEngine = class {
7290
7290
  let turns = 0;
7291
7291
  let hasRetriedWithCleanHistory = false;
7292
7292
  let turnStartMs = Date.now();
7293
+ const turnReadToolResults = [];
7293
7294
  while (turns < this.maxTurns) {
7294
7295
  if (signal.aborted) {
7295
7296
  yield { type: "error", error: new Error("Aborted") };
@@ -7305,7 +7306,6 @@ var QueryEngine = class {
7305
7306
  pendingToolCalls: []
7306
7307
  };
7307
7308
  const dispatcher = new EarlyToolDispatcher(this.tools, context, this.turnReadCache);
7308
- const turnReadToolResults = [];
7309
7309
  try {
7310
7310
  const microcompacted = microcompact(this.messages, this.tools);
7311
7311
  this.messages = microcompacted;
@@ -8378,6 +8378,10 @@ var RecipeRegistry = class {
8378
8378
  recipe.description,
8379
8379
  "Follow these steps:"
8380
8380
  ];
8381
+ const bundleSteps = recipe.steps.filter((s) => s.bundle === true);
8382
+ const bundleStepNames = new Set(bundleSteps.map((s) => s.name));
8383
+ const showBundleHeader = bundleStepNames.size >= 2;
8384
+ let openedBundleHeader = false;
8381
8385
  for (let i = 0; i < recipe.steps.length; i++) {
8382
8386
  const step = recipe.steps[i];
8383
8387
  const num = i + 1;
@@ -8385,7 +8389,14 @@ var RecipeRegistry = class {
8385
8389
  const serviceNote = step.service ? ` (${step.service})` : "";
8386
8390
  const costNote = step.cost ? ` \u2014 ${step.cost}` : "";
8387
8391
  const gateNote = step.gate && step.gate !== "none" ? ` [GATE: ${step.gate}]` : "";
8388
- let line = `${num}. ${step.name}${toolNote}${serviceNote}${costNote}${gateNote}`;
8392
+ if (showBundleHeader && step.bundle === true && !openedBundleHeader) {
8393
+ lines.push(
8394
+ "PAYMENT STREAM \u2014 emit ALL the following bundleable writes as parallel `tool_use` blocks IN THE SAME ASSISTANT TURN. The engine collapses them into ONE atomic PTB the user signs once. Do NOT execute step-by-step across turns:"
8395
+ );
8396
+ openedBundleHeader = true;
8397
+ }
8398
+ const bundleTag = showBundleHeader && step.bundle === true ? " [PAYMENT STREAM]" : "";
8399
+ let line = `${num}. ${step.name}${toolNote}${serviceNote}${costNote}${gateNote}${bundleTag}`;
8389
8400
  if (step.gate_prompt) {
8390
8401
  line += ` \u2014 "${step.gate_prompt}"`;
8391
8402
  }