@quackai/q402-mcp 0.8.15 → 0.8.16

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.
Files changed (2) hide show
  1. package/dist/index.js +66 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1092,6 +1092,53 @@ async function runPay(input) {
1092
1092
  }
1093
1093
  const data = await resp.json().catch(() => ({}));
1094
1094
  const txHash = data.txHash ?? "";
1095
+ const isSplit = data.split === true || Array.isArray(data.legs);
1096
+ if (isSplit) {
1097
+ const legs = Array.isArray(data.legs) ? data.legs : [];
1098
+ const status = data.status;
1099
+ const replayed = data.replayed === true;
1100
+ const settledCount = typeof data.settled === "number" ? data.settled : legs.filter((l) => typeof l.txHash === "string" && l.txHash.length > 0).length;
1101
+ const failedCount = typeof data.failed === "number" ? data.failed : legs.filter((l) => !l.txHash).length;
1102
+ const isComplete = status === "complete" && failedCount === 0;
1103
+ const isPartial = status === "partial" || resp.status === 207;
1104
+ const success2 = isComplete;
1105
+ const message2 = "message" in data ? data.message : "error" in data ? data.error : void 0;
1106
+ return {
1107
+ result: {
1108
+ success: success2,
1109
+ sandbox: false,
1110
+ // Top-level txHash mirrors the server's (first settled leg). Per-leg
1111
+ // hashes in `legs` remain authoritative.
1112
+ txHash,
1113
+ tokenAmount: input.amount,
1114
+ token: input.token,
1115
+ chain: chain.key,
1116
+ method: "eip7702",
1117
+ split: true,
1118
+ legs,
1119
+ settledLegs: settledCount,
1120
+ failedLegs: failedCount,
1121
+ ...isPartial && !isComplete ? { partial: true } : {},
1122
+ ...replayed ? { replayed: true } : {},
1123
+ explorerUrl: txHash ? void 0 : null
1124
+ },
1125
+ guardsApplied: [
1126
+ ...guardsApplied,
1127
+ "wallet=agentic-server",
1128
+ "mode=live",
1129
+ "settlement=split",
1130
+ `split_settled=${settledCount}`,
1131
+ `split_failed=${failedCount}`,
1132
+ `split_status=${status ?? "unknown"}`,
1133
+ ...replayed ? ["replayed=true"] : [],
1134
+ ...message2 ? [`server_message=${message2}`] : []
1135
+ ],
1136
+ senderWallet,
1137
+ ...isPartial && !isComplete ? {
1138
+ setupHint: `Split PARTIALLY settled: ${settledCount} leg(s) landed on-chain, ${failedCount} did NOT. The settled legs already moved funds \u2014 do NOT blindly retry the whole payment (a retry replays only the unsettled intent, it will not double-pay the settled legs). Inspect legs[] for which recipients received funds and which still need handling.`
1139
+ } : {}
1140
+ };
1141
+ }
1095
1142
  const isPending = resp.status === 202 || data.pending === true || data.status === "processing";
1096
1143
  if (isPending) {
1097
1144
  const retryAfter = typeof data.retryAfterSec === "number" ? data.retryAfterSec : 5;
@@ -2950,7 +2997,10 @@ var BridgeSendInputSchema = z11.object({
2950
2997
  walletId: z11.string().optional().describe("Agentic Wallet ID (from q402_agentic_info). Optional \u2014 defaults to the owner's default Agent Wallet."),
2951
2998
  feeToken: z11.enum(["LINK", "native"]).optional().describe("Fee token. Defaults to LINK (~10% cheaper than native)."),
2952
2999
  sandbox: z11.boolean().optional().describe("Sandbox mode (default true). Set to false for a live on-chain bridge."),
2953
- maxFeeRaw: z11.string().regex(/^\d+$/).optional().describe("Optional client-side fee cap in raw 18-dec wei. Server still clamps to its 10% slippage ceiling; clients may LOWER but not RAISE.")
3000
+ maxFeeRaw: z11.string().regex(/^\d+$/).optional().describe("Optional client-side fee cap in raw 18-dec wei. Server still clamps to its 10% slippage ceiling; clients may LOWER but not RAISE."),
3001
+ confirm: z11.boolean().optional().describe(
3002
+ "MUST be true to fire a LIVE bridge (ignored in sandbox). Set this only after the user has explicitly approved this exact bridge (src, dst, amount, feeToken) in the conversation. When omitted or false on a live call the tool previews the action and does NOT move any funds. Never set confirm:true on the user's behalf without approval."
3003
+ )
2954
3004
  }).refine((d) => d.src !== d.dst, {
2955
3005
  // Local Zod rejection saves a network round-trip + a Q402 backend log
2956
3006
  // entry. The bridge route also rejects same-chain bridges but the
@@ -2960,7 +3010,7 @@ var BridgeSendInputSchema = z11.object({
2960
3010
  });
2961
3011
  var BRIDGE_SEND_TOOL = {
2962
3012
  name: "q402_bridge_send",
2963
- description: "Execute a Chainlink CCIP USDC bridge across the 3-chain triangle (eth/avax/arbitrum) on behalf of the user's server-managed Agentic Wallet (Mode C). Sandbox-by-default \u2014 returns a synthetic messageId unless `sandbox: false` is passed AND Q402_ENABLE_REAL_PAYMENTS=1 AND a live Multichain API key is configured. The server signs ccipSend with the Agent Wallet's encrypted PK, auto-funds source-chain gas from the user's Gas Tank, and debits both the auto- fund cost and the CCIP fee per the bridge's settled receipt. Recommended flow: q402_bridge_quote first \u2192 confirm cost with the user \u2192 q402_bridge_send with sandbox: false. Live mode needs a Multichain subscription; trial keys are rejected. If the bridge returns AGENT_WALLET_DELEGATED, run q402_clear_delegation on the source chain first.",
3013
+ description: "Execute a Chainlink CCIP USDC bridge across the 3-chain triangle (eth/avax/arbitrum) on behalf of the user's server-managed Agentic Wallet (Mode C). Sandbox-by-default \u2014 returns a synthetic messageId unless `sandbox: false` is passed AND Q402_ENABLE_REAL_PAYMENTS=1 AND a live Multichain API key is configured. The server signs ccipSend with the Agent Wallet's encrypted PK, auto-funds source-chain gas from the user's Gas Tank, and debits both the auto- fund cost and the CCIP fee per the bridge's settled receipt. REQUIRES CONFIRMATION \u2014 like q402_pay and q402_yield_deposit, a LIVE bridge (sandbox: false) refuses to execute unless confirm: true is set. Call it first WITHOUT confirm to get a one-line preview (src, dst, amount, fee token); show that to the user, get explicit approval, THEN re-call with sandbox: false AND confirm: true. Never set confirm: true on the user's behalf. Recommended flow: q402_bridge_quote first \u2192 preview + confirm cost with the user \u2192 q402_bridge_send with sandbox: false, confirm: true. Live mode needs a Multichain subscription; trial keys are rejected. If the bridge returns AGENT_WALLET_DELEGATED, run q402_clear_delegation on the source chain first.",
2964
3014
  inputSchema: {
2965
3015
  type: "object",
2966
3016
  properties: {
@@ -2996,6 +3046,10 @@ var BRIDGE_SEND_TOOL = {
2996
3046
  type: "string",
2997
3047
  pattern: "^[0-9]+$",
2998
3048
  description: "Optional client-side fee cap in raw 18-dec wei."
3049
+ },
3050
+ confirm: {
3051
+ type: "boolean",
3052
+ description: "MUST be true to fire a LIVE bridge (ignored in sandbox) \u2014 set only after the user explicitly approved this exact bridge in chat. Omit (or false) on a live call to preview without moving funds."
2999
3053
  }
3000
3054
  },
3001
3055
  required: ["src", "dst", "amount"]
@@ -3025,6 +3079,16 @@ async function runBridgeSend(input) {
3025
3079
  }]
3026
3080
  };
3027
3081
  }
3082
+ if (input.confirm !== true) {
3083
+ const walletDesc = typeof input.walletId === "string" && input.walletId.length > 0 ? `wallet ${input.walletId.toLowerCase()}` : "your default Agent Wallet";
3084
+ const fee = input.feeToken === "native" ? "native" : "LINK";
3085
+ return {
3086
+ content: [{
3087
+ type: "text",
3088
+ text: `Will bridge ${input.amount} raw USDC units from ${input.src} \u2192 ${input.dst} via Chainlink CCIP from ${walletDesc} (fee paid in ${fee}). This MOVES FUNDS on-chain. Re-call with confirm:true to execute.`
3089
+ }]
3090
+ };
3091
+ }
3028
3092
  const resolved = resolveApiKey(input.src, "multichain");
3029
3093
  if (!resolved.apiKey) {
3030
3094
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quackai/q402-mcp",
3
- "version": "0.8.15",
3
+ "version": "0.8.16",
4
4
  "description": "MCP server for Q402 — gasless USDC/USDT/RLUSD payments on 10 EVM chains + Chainlink CCIP USDC bridge on the eth/avax/arbitrum triangle, callable from Claude (Desktop / Code), OpenAI Codex CLI, and any other Model Context Protocol client.",
5
5
  "mcpName": "io.github.bitgett/q402-mcp",
6
6
  "keywords": [