shinjuku-shield 0.3.122 → 0.3.123

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 CHANGED
@@ -6,19 +6,19 @@ answers privately, in a terminal chat or for your agent app. Its `mcp`
6
6
  command runs a local MCP server (stdio) for your agent. Your keys never
7
7
  leave your machine.
8
8
 
9
- This is version 0.3.122. The npm packages `shinjuku-shield` and
9
+ This is version 0.3.123. The npm packages `shinjuku-shield` and
10
10
  `shinjuku-shielded` hold the same files. The command is `shinjuku`.
11
11
 
12
12
  ## Set up
13
13
 
14
14
  ```sh
15
- npm install -g shinjuku@0.3.122
15
+ npm install -g shinjuku@0.3.123
16
16
  shinjuku setup
17
17
  ```
18
18
 
19
19
  Type the two lines as they are. `npx install shinjuku` does not work: npx
20
20
  reads `install` as the name of another npm package. To set up without
21
- installing, type `npx shinjuku@0.3.122 setup`.
21
+ installing, type `npx shinjuku@0.3.123 setup`.
22
22
 
23
23
  Setup makes the wallet on this machine, a private passphrase file, and the
24
24
  checked proof tools (about 191 MB), and writes `config.json`. It also writes
@@ -36,13 +36,13 @@ Every wallet command works after `shinjuku`, for example `shinjuku balance`,
36
36
  Claude Code:
37
37
 
38
38
  ```sh
39
- claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.122 mcp
39
+ claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.123 mcp
40
40
  ```
41
41
 
42
42
  Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
43
43
 
44
44
  ```json
45
- { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.122", "mcp"] } } }
45
+ { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.123", "mcp"] } } }
46
46
  ```
47
47
 
48
48
  On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
package/manifest.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schema": "carbon-shielded-wallet/bundle-manifest/v1",
3
3
  "file": "shinjuku-wallet.mjs",
4
- "sha256": "67cedf24617c4cd78d268b549ad4b346101b6de7338a5a3889df8f81a29c78a3",
5
- "bytes": 8472739,
6
- "sourceCommit": "31eb1a0d3a0f1a9d380e2b1bf046d8abcc5420cc",
4
+ "sha256": "916f76a4396c16a3e274e9644291fef6362b5ba89f462400859888f9d94f77f9",
5
+ "bytes": 8474565,
6
+ "sourceCommit": "51234a177dae9a65c677dd4716a7f386b2e8b2eb",
7
7
  "sourceDirty": false,
8
8
  "installRecordMatchesLockfile": true,
9
9
  "releaseRule": "valid only when two fresh npm ci --ignore-scripts builds on different OSes give the same sha256; installRecordMatchesLockfile true means every entry npm installed equals its package-lock.json entry and every entry not marked optional, devOptional included, is installed: an optional entry (a package for another platform) may be absent",
@@ -1037,5 +1037,5 @@
1037
1037
  "version": "1.8.0"
1038
1038
  }
1039
1039
  ],
1040
- "publishedAt": "2026-10-28T19:36:37.026Z"
1040
+ "publishedAt": "2026-10-28T20:30:28.766Z"
1041
1041
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shield",
3
- "version": "0.3.122",
3
+ "version": "0.3.123",
4
4
  "mcpName": "io.github.ShinjukuStaition/shinjuku-mcp",
5
5
  "description": "Shinjuku Shielded, the private x402 facilitator on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
6
- "shinjukuRelease": "67cedf24",
7
- "shinjukuSha256": "67cedf24617c4cd78d268b549ad4b346101b6de7338a5a3889df8f81a29c78a3",
6
+ "shinjukuRelease": "916f76a4",
7
+ "shinjukuSha256": "916f76a4396c16a3e274e9644291fef6362b5ba89f462400859888f9d94f77f9",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shielded",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
@@ -107110,7 +107110,10 @@ function refusalSay(a, tool, again, npmVersion) {
107110
107110
  const total2 = usdcText2(a.totalAtomic);
107111
107111
  const cap = usdcText2(a.capAtomic);
107112
107112
  const limit = /^[a-z0-9 -]{1,40}$/i.test(str(a.limitName)) ? a.limitName : "limit";
107113
- const over = total2 && cap ? `${total2} USDC above your ${cap} USDC ${limit}` : `this above your ${limit}`;
107113
+ const price = usdcText2(a.priceAtomic);
107114
+ const fee = usdcText2(a.feeAtomic);
107115
+ const split4 = price && positive(fee) ? ` (the price ${price} USDC plus Shinjuku's fee ${fee} USDC)` : "";
107116
+ const over = total2 && cap ? `${total2} USDC${split4} above your ${cap} USDC ${limit}` : `this above your ${limit}`;
107114
107117
  const head = `Nothing was ${verb}:`;
107115
107118
  const lines = {
107116
107119
  declined: [`${head} you chose not to allow ${over}.`],
@@ -108322,13 +108325,16 @@ async function payTurn({ session, target, method, headers, body, maxPrice, polic
108322
108325
  );
108323
108326
  }
108324
108327
  if (BigInt(price.amountAtomic) > BigInt(cap)) {
108328
+ const fee = price.rail === "exact" ? BigInt(price.amountAtomic) - BigInt(price.priceAtomic) : 0n;
108329
+ const split4 = fee > 0n ? { priceAtomic: String(price.priceAtomic), feeAtomic: fee.toString() } : {};
108325
108330
  throw new SpendRefusalError({
108326
108331
  ok: false,
108327
108332
  error: "spend_payment_cap_exceeded",
108328
- detail: `the price ${usdcWords(price.amountAtomic)} is above this call's cap ${usdcWords(cap)}; nothing was paid`,
108333
+ detail: `the price ${usdcWords(price.amountAtomic)}${fee > 0n ? ` (the seller's ${usdcWords(price.priceAtomic)} plus Shinjuku's fee ${usdcWords(fee)})` : ""} is above this call's cap ${usdcWords(cap)}; nothing was paid`,
108329
108334
  next: `pay only sellers priced at ${usdcWords(cap)} or less, or raise the limit per payment (maxPaymentAtomic)`,
108330
108335
  totalAtomic: String(price.amountAtomic),
108331
- capAtomic: String(cap)
108336
+ capAtomic: String(cap),
108337
+ ...split4
108332
108338
  });
108333
108339
  }
108334
108340
  if (store !== void 0 && price.floatConfig && standardResourceMatches(paymentRequired?.resource?.url, target)) {
@@ -110116,6 +110122,16 @@ var init_balanceNow = __esm({
110116
110122
  });
110117
110123
 
110118
110124
  // wallet/src/balance/emptyBalance.mjs
110125
+ function proofWalkHolds(store) {
110126
+ const last = lastProofRecovery(store);
110127
+ const recovered = last?.pool === store.state.pool && last.recovery?.narrowedByDigests !== true && Array.isArray(last.recovery?.recovered) ? last.recovery.recovered : void 0;
110128
+ if (!recovered) return void 0;
110129
+ const unspent = recovered.filter((entry) => entry?.spendStatus === "unspent");
110130
+ return {
110131
+ none: !recovered.some((entry) => entry?.spendStatus === "unspent" || entry?.spendStatus === "succession-movable"),
110132
+ receivedOnly: !unspent.some((entry) => entry.kind === "account") && unspent.some((entry) => entry.kind === "note")
110133
+ };
110134
+ }
110119
110135
  function knownEmptyBalance(store, { maxAgeMs } = {}) {
110120
110136
  try {
110121
110137
  const parts = balanceNow(store);
@@ -110136,6 +110152,7 @@ var init_emptyBalance = __esm({
110136
110152
  "wallet/src/balance/emptyBalance.mjs"() {
110137
110153
  "use strict";
110138
110154
  init_balanceNow();
110155
+ init_prepareRecoveredPayment();
110139
110156
  ABOVE_0 = /^0*[1-9]/;
110140
110157
  }
110141
110158
  });
@@ -126224,7 +126241,7 @@ function createWalletTools({
126224
126241
  const notAllowed = (why, { tool, requestId, numbers, flag: flag3 = payCapFlag(numbers.capAtomic), verb = "paid", more = false }, extra = {}) => {
126225
126242
  const answer = Object.hasOwn(NOT_ALLOWED_DETAIL, why) ? why : "error";
126226
126243
  const limitName = capName(flag3);
126227
- const amounts = `${usdcText3(numbers.totalAtomic)} USDC once, above the ${limitName} of ${usdcText3(numbers.capAtomic)} USDC`;
126244
+ const amounts = `${usdcText3(numbers.totalAtomic)} USDC${splitWords(floatSplitOf(extra), "the price")} once, above the ${limitName} of ${usdcText3(numbers.capAtomic)} USDC`;
126228
126245
  const nothing = `nothing ${more ? "more " : ""}was ${verb}`;
126229
126246
  const again2 = `call ${tool} again with request_id "${requestId}" and the same arguments: the wallet asks the user again`;
126230
126247
  const around = verb === "paid" ? "Do not change max_payment or the request to get around this." : "Do not split it into smaller amounts or change the amount to get around this.";
@@ -127397,15 +127414,8 @@ ${canonical5}`;
127397
127414
  const one = readBalance(store);
127398
127415
  const refunds = [one?.breakdown?.refundsInFlightAtomic, one?.breakdown?.refundsNotCertainAtomic].some((atomic4) => /^0*[1-9]/.test(String(atomic4 ?? "")));
127399
127416
  const known = knownEmptyBalance(store, { maxAgeMs: balanceNow(store)?.report?.status === "empty" ? void 0 : maxAgeMs });
127400
- const last = lastProofRecovery(store);
127401
- const recovered = last?.pool === store.state.pool && last.recovery?.narrowedByDigests !== true && Array.isArray(last.recovery?.recovered) ? last.recovery.recovered : void 0;
127402
- if (recovered) {
127403
- const unspent = recovered.filter((entry) => entry?.spendStatus === "unspent");
127404
- return {
127405
- receivedOnly: !unspent.some((entry) => entry.kind === "account") && unspent.some((entry) => entry.kind === "note"),
127406
- empty: !recovered.some((entry) => entry?.spendStatus === "unspent" || entry?.spendStatus === "succession-movable") && !refunds && known
127407
- };
127408
- }
127417
+ const walk = proofWalkHolds(store);
127418
+ if (walk) return { receivedOnly: walk.receivedOnly, empty: walk.none && !refunds && known };
127409
127419
  const receivedOnly = one?.receivedOnly === true;
127410
127420
  return { receivedOnly, empty: !receivedOnly && !refunds && known };
127411
127421
  } catch {
@@ -127606,7 +127616,7 @@ ${canonical5}`;
127606
127616
  const zero = await zeroBeforeAsk("x402_pay", requestId);
127607
127617
  if (zero) return zero;
127608
127618
  const numbers = { totalAtomic: total, capAtomic: launch };
127609
- const split4 = code2 === "p03_float_over_maximum" ? floatSplitOf(error) : void 0;
127619
+ const split4 = floatSplitOf(code2 === "p03_float_over_maximum" ? error : error?.refusal);
127610
127620
  const asked = await askLimit2({
127611
127621
  requestId,
127612
127622
  url: target.url,
@@ -135273,8 +135283,9 @@ var init_tools = __esm({
135273
135283
  JOIN_RETRY_BACKOFF_MS = Object.freeze([6e4, 2 * 6e4, 4 * 6e4, 8 * 6e4, 16 * 6e4, 30 * 6e4, 30 * 6e4]);
135274
135284
  WALLET_CAP_FIX = {
135275
135285
  // Functions: the command name is read at answer time (cli/commandName.mjs checks PATH then, 0.3.98).
135276
- wallet_spend_refused_per_payment_cap_exceeded: () => `the wallet file's per-payment cap; the owner removes it with ${terminalCommand2("limits --pool <pool> --max-payment none", { code: true })} (or a higher number in place of none)`,
135277
- wallet_spend_refused_cumulative_cap_exceeded: () => `the wallet file's total budget; the owner removes it with ${terminalCommand2("limits --pool <pool> --max-cumulative none", { code: true })} (or a higher number in place of none)`
135286
+ // The plain limits step, never a pool id or "removes it" (mcp6 live pass of npm 0.3.122, 2026-10-28; the CLI hint too).
135287
+ wallet_spend_refused_per_payment_cap_exceeded: () => `the limit for one payment; the owner changes it with ${terminalCommand2("limits", { code: true })} in a terminal (it shows the limits and asks for new ones)`,
135288
+ wallet_spend_refused_cumulative_cap_exceeded: () => `the limit for all payments together; the owner changes it with ${terminalCommand2("limits", { code: true })} in a terminal (it shows the limits and what was paid, and asks for new ones)`
135278
135289
  };
135279
135290
  MCP_CAP_FIX = {
135280
135291
  mcp_session_cap_exceeded: () => ` This is the 24-hour payment limit. ${capRaiseText("--max-session")} ${cheaperSellerText}`,
@@ -144698,7 +144709,15 @@ async function pocketFillGate(args, values, deps, io) {
144698
144709
  return index < 0 ? args : [...args.slice(0, index + 1), target, ...args.slice(index + 2)];
144699
144710
  }
144700
144711
  async function runCurl(values, deps) {
144701
- if (values.has("--max-payment")) return runCurlPaid(values, deps);
144712
+ if (values.has("--max-payment")) {
144713
+ const aboveLimits = capAboveLimitsLine(
144714
+ { maxPaymentAtomic: values.get("--max-payment") },
144715
+ cliUserLimits(values, deps),
144716
+ { again: `the same ${cli2()} curl command` }
144717
+ );
144718
+ if (aboveLimits) throw new PublicFailure(`${CAP_ABOVE_LIMIT_CODE}: ${aboveLimits}`);
144719
+ return runCurlPaid(values, deps);
144720
+ }
144702
144721
  if (!(deps.stdinIsTTY() && deps.stdoutIsTTY?.() === true)) {
144703
144722
  throw new UsageError("curl is missing --max-payment <usdc>: the most this request may pay, in USDC (0.02 = 2 cents); in a terminal, curl shows the seller's price and asks instead", COMMAND_BY_NAME.get("curl"));
144704
144723
  }
@@ -145164,7 +145183,15 @@ async function runInferServe(values, deps) {
145164
145183
  try {
145165
145184
  return await (deps.payAndFetch ?? payAndFetch)(session, url, init, { ...options, memoryOnly: true });
145166
145185
  } catch (error) {
145167
- throw inferFailure(error);
145186
+ const failure2 = inferFailure(error);
145187
+ if (localErrorCodes(error).includes("p03_merchant_respend_no_spendable_account")) {
145188
+ try {
145189
+ const store = session.openStore();
145190
+ if (proofWalkHolds(store)?.none === true && knownEmptyBalance(store)) failure2.knownZero = true;
145191
+ } catch {
145192
+ }
145193
+ }
145194
+ throw failure2;
145168
145195
  }
145169
145196
  };
145170
145197
  server = createInferenceServer2({
@@ -149820,7 +149847,6 @@ function serversOf(command, values, env = {}) {
149820
149847
  if (command.name.startsWith("privacy-cash ") && (values?.get("--via") ?? "sdk") !== "local") names.push("Privacy Cash's server (--via sdk)");
149821
149848
  return names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
149822
149849
  }
149823
- var capWallet = (values, pool2) => values?.has("--wallet") ? `--wallet ${values.get("--wallet")} --passphrase-file <file>` : `--pool ${pool2 ?? "<pool>"}`;
149824
149850
  function runBalanceParts(values, deps) {
149825
149851
  try {
149826
149852
  const walletPath2 = values.has("--wallet") ? resolve32(values.get("--wallet")) : deps.walletPath(values.get("--pool"));
@@ -149846,6 +149872,7 @@ function insufficientWords(cause, parts) {
149846
149872
  }
149847
149873
  }
149848
149874
  }
149875
+ var CAP_REFUSAL_CODES = ["spend_payment_cap_exceeded", "wallet_spend_refused_per_payment_cap_exceeded", "wallet_spend_refused_cumulative_cap_exceeded"];
149849
149876
  function failureHint(command, reason, deps, values, floatError) {
149850
149877
  const pool2 = values?.get("--pool");
149851
149878
  const historyHint = historyRpcHint(reason, { signsNothing: signsNothing(command, values) });
@@ -149924,7 +149951,7 @@ function failureHint(command, reason, deps, values, floatError) {
149924
149951
  if (/spend_payment_cap_exceeded|mcp_cap_argument_above_launch_cap/.test(reason)) {
149925
149952
  const total = floatError?.refusal?.totalAtomic;
149926
149953
  const over = /^[1-9][0-9]{0,30}$/.test(String(total ?? "")) ? cliOverLimitStep(values, deps, BigInt(total), { command }) : void 0;
149927
- return over ?? "nothing was paid: the seller's price (the line names it) is above --max-payment. If you agree to that price, rerun with a --max-payment at least as high; else pay a cheaper seller";
149954
+ return over ?? "if you agree to that price, rerun with a --max-payment at least as high; else pay a cheaper seller";
149928
149955
  }
149929
149956
  if (/spend_host_day_cap_exceeded/.test(reason)) {
149930
149957
  return "nothing was paid: this seller host would pass --max-per-host-day in the last 24 hours (unfinished payments count). Rerun later, or with a higher --max-per-host-day";
@@ -149961,11 +149988,15 @@ function failureHint(command, reason, deps, values, floatError) {
149961
149988
  if (/fetch_session_closed/.test(reason)) return "the payer session closed before this payment started; nothing new was paid. Rerun the same command (same --request-id)";
149962
149989
  if (/curl_binary_to_terminal/.test(reason)) return "add -o <file> with the same --request-id: the answer goes to that file, and a paid request is replayed, never paid twice";
149963
149990
  if (/wallet_passphrase_file_unreadable/.test(reason)) return `pass a --passphrase-file you can read (the passphrase alone in it), or export ${PASSPHRASE_ENV2}; nothing was sent`;
149964
- if (/wallet_spend_refused_per_payment_cap_exceeded/.test(reason)) {
149965
- return `nothing was paid: the price is above this wallet's limit for one payment (${cli2()} limits shows it). To remove the limit: ${cli2()} limits ${capWallet(values, pool2)} --max-payment none (or a higher number), then rerun the payment`;
149966
- }
149967
- if (/wallet_spend_refused_cumulative_cap_exceeded/.test(reason)) {
149968
- return `nothing was paid: this payment would pass the wallet's total payment budget (--max-cumulative; ${cli2()} limits shows it with usedAtomic). To remove the budget: ${cli2()} limits ${capWallet(values, pool2)} --max-cumulative none (or a higher number), then rerun the payment`;
149991
+ if (/wallet_spend_refused_(per_payment|cumulative)_cap_exceeded/.test(reason)) {
149992
+ const one = /wallet_spend_refused_per_payment/.test(reason);
149993
+ let limit;
149994
+ try {
149995
+ limit = one ? cliUserLimits(values, deps)?.maxPaymentAtomic : cliLimitRoom(values, deps)?.total?.limitAtomic;
149996
+ } catch {
149997
+ limit = void 0;
149998
+ }
149999
+ return `nothing was paid: ${one ? "this payment is above your limit for one payment" : "this payment would pass your limit for all payments together"}${limit === void 0 ? "" : ` (${usdcOr(limit)})`}. Run ${cli2()} limits: it shows your limits${one ? "" : " and what you paid so far"} and asks for new ones. Then run the same command again`;
149969
150000
  }
149970
150001
  if (/wallet_spend_refused_/.test(reason)) return "nothing was paid: the seller's price is not a positive amount; do not pay this seller";
149971
150002
  if (/p03_resource_payment_confidential_(retired|use_laneb_pay_url)/.test(reason)) {
@@ -150741,7 +150772,7 @@ This copy: ${walletVersionLine(deps.walletVersion())}
150741
150772
  const reason = failureReason(command, error, values);
150742
150773
  const codes = failureCodes(error, reason);
150743
150774
  writeRunResult(deps, command, 1, error, codes);
150744
- const plainCode = [NOT_SET_UP_CODE, EMPTY_BALANCE_CODE, OVER_LIMITS_CODE, CEILING_OVER_CAP_CODE].find((code2) => reason.startsWith(`${code2}: `));
150775
+ const plainCode = [NOT_SET_UP_CODE, EMPTY_BALANCE_CODE, OVER_LIMITS_CODE, CEILING_OVER_CAP_CODE, CAP_ABOVE_LIMIT_CODE].find((code2) => reason.startsWith(`${code2}: `));
150745
150776
  if (plainCode) {
150746
150777
  const plain = reason.slice(plainCode.length + 2);
150747
150778
  io.err(`${plain[0].toUpperCase()}${plain.slice(1)}
@@ -150780,6 +150811,13 @@ Next: fund that address, then rerun the same command; it continues where it stop
150780
150811
  }
150781
150812
  const floatError = { ...error?.cause && typeof error.cause === "object" ? error.cause : {}, ...error && typeof error === "object" ? error : {} };
150782
150813
  const hint = failureHint(command, codes.join(" "), deps, values, floatError);
150814
+ const capCode = CAP_REFUSAL_CODES.find((code2) => codes.includes(code2));
150815
+ if (capCode && hint) {
150816
+ const said = reason.startsWith(`${capCode}: `) ? reason.slice(capCode.length + 2) : "";
150817
+ io.err(`${[said, hint].filter(Boolean).map((text3) => `${text3[0].toUpperCase()}${text3.slice(1).replace(/[\s.;]+$/, "")}.`).join("\n")}
150818
+ `);
150819
+ return 1;
150820
+ }
150783
150821
  const blocking = error?.blockingRequestId ?? error?.cause?.blockingRequestId;
150784
150822
  const blockingLine = typeof blocking === "string" && /^[A-Za-z0-9._:-]{1,128}$/.test(blocking) ? `earlier payment: --request-id ${blocking}
150785
150823
  ` : "";