shinjuku-shield 0.3.220 → 0.3.221

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
@@ -5,12 +5,12 @@ web services and AI answers from your private balance, so the payment does
5
5
  not show who paid. It works inside your AI app (Claude, Cursor, Codex) and in
6
6
  a terminal. Only you hold the keys: they never leave your computer.
7
7
 
8
- This is version 0.3.220. The command is `shinjuku`.
8
+ This is version 0.3.221. The command is `shinjuku`.
9
9
 
10
10
  ## Set up
11
11
 
12
12
  ```sh
13
- npx -y shinjuku@0.3.220 setup
13
+ npx -y shinjuku@0.3.221 setup
14
14
  ```
15
15
 
16
16
  Setup does every step for you:
@@ -100,7 +100,7 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
100
100
  Claude Code:
101
101
 
102
102
  ```sh
103
- claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.220 mcp
103
+ claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.221 mcp
104
104
  ```
105
105
 
106
106
  ## For builders: check what you install
@@ -116,7 +116,7 @@ with the Releases table in
116
116
  Versions are published from GitHub Actions with npm provenance.
117
117
 
118
118
  `shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
119
- 0.3.220, its older name, runs this package at the same version, so wallets
119
+ 0.3.221, its older name, runs this package at the same version, so wallets
120
120
  installed under that name keep updating. New installs use `shinjuku`.
121
121
 
122
122
  The full guide is
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": "a910db1e1c876a207fdc040c809315913121206f32723a9d87192c8a75a7823c",
5
- "bytes": 10294711,
6
- "sourceCommit": "a4a5fa17d6f6c9ef6009c96dfdb3255bcd674e72",
4
+ "sha256": "52c863352dfca86ebd1266a905c55445c48cadc8b53b77d349725fd5062a2a62",
5
+ "bytes": 10298934,
6
+ "sourceCommit": "7411e830aea9ee9b7143b5c895a054606cfecaf8",
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",
@@ -1075,8 +1075,8 @@
1075
1075
  ],
1076
1076
  "seller": {
1077
1077
  "file": "shinjuku-seller.mjs",
1078
- "sha256": "7e40398886e63df2a3981ac6603e19ff0772b5c86162e65e64ac1f5c0a7dce32",
1079
- "bytes": 4182275,
1078
+ "sha256": "3fbd12397c06f6b157b183fafd86d9f0d72e708c0c97887833ead480da1aabe6",
1079
+ "bytes": 4182433,
1080
1080
  "entry": "wallet/src/seller/exact/index.mjs",
1081
1081
  "external": [
1082
1082
  "@x402/core/http",
@@ -1968,5 +1968,5 @@
1968
1968
  }
1969
1969
  ]
1970
1970
  },
1971
- "publishedAt": "2026-11-12T15:31:01.378Z"
1971
+ "publishedAt": "2026-11-12T16:14:06.249Z"
1972
1972
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shield",
3
- "version": "0.3.220",
3
+ "version": "0.3.221",
4
4
  "mcpName": "io.github.ShinjukuStaition/shinjuku-shield",
5
5
  "description": "Shinjuku Shield, private x402 payments 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": "a910db1e",
7
- "shinjukuSha256": "a910db1e1c876a207fdc040c809315913121206f32723a9d87192c8a75a7823c",
6
+ "shinjukuRelease": "52c86335",
7
+ "shinjukuSha256": "52c863352dfca86ebd1266a905c55445c48cadc8b53b77d349725fd5062a2a62",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shield",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
@@ -45162,6 +45162,8 @@ var init_errorCodes = __esm({
45162
45162
  // A damaged config.json (row 78): the setup-mode server repairs it and keeps the wallet (cli runMcpFirstRun).
45163
45163
  "mcp_config_damaged",
45164
45164
  "setup_tor_unavailable",
45165
+ // The agent-app setup's own Tor did not start before setup ran (cli mcpSetupBehindTor; nothing ran).
45166
+ "setup_tor_not_started",
45165
45167
  // The wallet server behind Tor that the setup server starts after a Tor setup (stdioServer.mjs startTorRelay).
45166
45168
  "setup_tor_wallet_ended",
45167
45169
  "setup_tor_wallet_slow",
@@ -79977,7 +79979,7 @@ async function installBundle(home, say) {
79977
79979
  say(`Getting Tor for the wallet (once, about ${pinned.mb} MB from the Tor Project, checked).`);
79978
79980
  let response;
79979
79981
  try {
79980
- response = await fetch(pinned.url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
79982
+ response = await fetch(pinned.url, { redirect: "error", signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
79981
79983
  } catch (error) {
79982
79984
  throw failure("the Tor download did not finish. Check the internet connection, then ask again", `the Tor download did not answer (${error?.name === "TimeoutError" ? "no answer in 5 minutes" : error?.cause?.code ?? error?.message ?? error})`);
79983
79985
  }
@@ -80865,6 +80865,8 @@ var init_errorCodes = __esm({
80865
80865
  // A damaged config.json (row 78): the setup-mode server repairs it and keeps the wallet (cli runMcpFirstRun).
80866
80866
  "mcp_config_damaged",
80867
80867
  "setup_tor_unavailable",
80868
+ // The agent-app setup's own Tor did not start before setup ran (cli mcpSetupBehindTor; nothing ran).
80869
+ "setup_tor_not_started",
80868
80870
  // The wallet server behind Tor that the setup server starts after a Tor setup (stdioServer.mjs startTorRelay).
80869
80871
  "setup_tor_wallet_ended",
80870
80872
  "setup_tor_wallet_slow",
@@ -123884,8 +123886,13 @@ function build(a, tool, npmVersion) {
123884
123886
  if (tool === "find_paid_services" || tool === void 0 && Array.isArray(a.results) && typeof a.query === "string") return discoverSay(a);
123885
123887
  if (a.paid === false && a.replayed === true) return "Here is the same answer as before. Nothing was paid: the earlier payment for it never went through.";
123886
123888
  if (a.paid === true) {
123887
- const unconfirmed = a.receiptFinality === "pending" ? " The chain does not show the payment to the seller yet." : "";
123888
- if (a.replayed === true) return `This request was already paid. Here is the same answer; nothing new was paid.${unconfirmed}`;
123889
+ const unconfirmed = a.receiptFinality === "pending" ? " This wallet has not seen the payment to the seller on the chain yet." : "";
123890
+ if (a.replayed === true) {
123891
+ return firstFit(
123892
+ `This request was already paid. Here is the same answer; nothing new was paid.${unconfirmed}`,
123893
+ `Already paid: here is the same answer, nothing new was paid.${unconfirmed}`
123894
+ );
123895
+ }
123889
123896
  if (tool === "inference_chat" || typeof a.model === "string" && Object.hasOwn(a, "content")) {
123890
123897
  const paid = usdcText2(a.paidAtomic);
123891
123898
  const price3 = usdcText2(a.priceAtomic);
@@ -123899,7 +123906,7 @@ function build(a, tool, npmVersion) {
123899
123906
  if (!total) return withBalance(`Paid. Here is the answer.${unconfirmed}`, a);
123900
123907
  if (price2 && positive(fee)) {
123901
123908
  const paid = `Paid ${total} USDC (${price2} price + ${fee} Shinjuku fee).`;
123902
- return withBalance([`${paid} Here is the answer.${unconfirmed}`, `${paid}${unconfirmed}`], a);
123909
+ return withBalance([`${paid} Here is the answer.${unconfirmed}`, `${paid}${unconfirmed}`].filter((line, index, all) => words(line) <= SAY_MAX_WORDS || index === all.length - 1), a);
123903
123910
  }
123904
123911
  return withBalance(`Paid ${total} USDC. Here is the answer.${unconfirmed}`, a);
123905
123912
  }
@@ -142109,7 +142116,7 @@ function leg1Transaction(store, float, requestId) {
142109
142116
  }
142110
142117
  function floatPaidNext({ transaction, shinjukuTransaction, pending = false }) {
142111
142118
  if (pending) {
142112
- return "the seller answered with its data, and this wallet's private payment to Shinjuku is done; Shinjuku's payment to the seller is not seen on the public chain yet. Tell the user: the data came; the payment is not confirmed on the chain yet; wallet_receipts shows its state. Tell the user the price (priceAtomic), the Shinjuku fee (feeAtomic; never a network fee) and the total (amountAtomic). Do not pay this again: it is one payment. wallet_balance shows the new balance";
142119
+ return "the seller answered with its data, and this wallet's private payment to Shinjuku is done; this wallet has not yet seen Shinjuku's payment to the seller on the public chain (a quick check; the chain can already hold it). Tell the user: the data came; this wallet has not seen the payment to the seller on the chain yet; wallet_receipts shows its state. Tell the user the price (priceAtomic), the Shinjuku fee (feeAtomic; never a network fee) and the total (amountAtomic). Do not pay this again: it is one payment. wallet_balance shows the new balance";
142113
142120
  }
142114
142121
  const ids = [
142115
142122
  transaction ? "the transaction (the seller's settle transaction)" : void 0,
@@ -145174,7 +145181,7 @@ ${canonical5}`;
145174
145181
  requestId,
145175
145182
  scheme: receipt.scheme ?? null,
145176
145183
  // AB249 live run 2 (echomarkets, 2026-11-07): a pending receipt named the seller's claimed signature as its
145177
- // transaction. Until the chain shows it, it is only sellerClaimedTransaction.
145184
+ // transaction. Until this wallet sees it confirmed, it is only sellerClaimedTransaction.
145178
145185
  ...floatPaid && receipt.receiptFinality === "pending" ? { transaction: null, ...transaction ? { sellerClaimedTransaction: transaction } : {} } : { transaction: unpaid ? null : transaction },
145179
145186
  ...amounts,
145180
145187
  replayed: receipt.replayed === true,
@@ -147346,7 +147353,7 @@ ${canonical5}`;
147346
147353
  scheme: "exact",
147347
147354
  state: "payment_not_confirmed",
147348
147355
  ...claimed ? { sellerClaimedTransaction: claimed } : {},
147349
- note: "the seller answered with its data, but the public chain does not show Shinjuku's payment to the seller yet. Each wallet_receipts call reads it again: when it lands, this row shows the seller's transaction; if it can never land, this row shows a refund. Do not pay for this again with a new request_id until then"
147356
+ note: "the seller answered with its data, but this wallet has not seen Shinjuku's payment to the seller on the public chain yet. Each wallet_receipts call reads it again: when it lands, this row shows the seller's transaction; if it can never land, this row shows a refund. Do not pay for this again with a new request_id until then"
147350
147357
  });
147351
147358
  continue;
147352
147359
  }
@@ -148141,7 +148148,7 @@ ${canonical5}`;
148141
148148
  const record = float ? void 0 : [paymentRecordName(target), `${POCKET_PAYMENT_WAL_PREFIX}${key}`].map((name) => store.readWal(name)).find((one) => one?.state === "receipt" && one.receiptFinality !== "never-finalized");
148142
148149
  if (float && floatReceiptPending(float)) {
148143
148150
  return json4({
148144
- say: "The seller already answered this payment, so there is nothing to cancel. The public chain does not show the payment to the seller yet; wallet_receipts shows it when it does.",
148151
+ say: "The seller already answered this payment, so there is nothing to cancel. This wallet has not seen the payment to the seller on the chain yet.",
148145
148152
  ok: true,
148146
148153
  requestId,
148147
148154
  kind: "payment",
@@ -148149,7 +148156,7 @@ ${canonical5}`;
148149
148156
  finished: true,
148150
148157
  transaction: null,
148151
148158
  receiptFinality: "pending",
148152
- detail: "the seller answered this payment, so there is nothing to cancel; the public chain does not show Shinjuku's payment to the seller yet",
148159
+ detail: "the seller answered this payment, so there is nothing to cancel; this wallet has not seen Shinjuku's payment to the seller on the public chain yet (wallet_receipts reads it again)",
148153
148160
  next: "Tell the user the seller already answered, so there is nothing to cancel; nothing was changed. Do not pay for it again. wallet_receipts shows whether the payment to the seller landed or a refund comes"
148154
148161
  });
148155
148162
  }
@@ -148166,7 +148173,7 @@ ${canonical5}`;
148166
148173
  finished: true,
148167
148174
  transaction,
148168
148175
  ...typeof record?.receiptFinality === "string" ? { receiptFinality: record.receiptFinality } : {},
148169
- detail: `this payment is finished and paid${transaction ? ` (transaction ${transaction})` : ""}${final ? "" : "; the seller answered and the chain has not made it final yet"}; there is nothing to cancel, and a payment a seller took cannot be taken back`,
148176
+ detail: `this payment is finished and paid${transaction ? ` (transaction ${transaction})` : ""}${final ? "" : "; the seller answered and this wallet has not seen it final on the chain yet"}; there is nothing to cancel, and a payment a seller took cannot be taken back`,
148170
148177
  next: "Tell the user the payment is finished and paid; nothing was changed. wallet_receipts lists it"
148171
148178
  });
148172
148179
  }
@@ -153852,6 +153859,25 @@ function createSetupTools({
153852
153859
  return out;
153853
153860
  }
153854
153861
  function statusOf(current, end2) {
153862
+ if (current.state === "failed" && current.ownTor === true && current.failure?.error === "setup_tor_not_started") {
153863
+ const recoveryFile = current.recoveryFile;
153864
+ end2();
153865
+ const reason = String(current.failure.detail ?? "").split("nothing was sent: ")[1]?.trim().replace(/\.$/, "") ?? "";
153866
+ const download3 = /^the Tor download/.test(reason);
153867
+ const what = download3 ? "the Tor download for the wallet did not finish" : "Tor did not start on this computer";
153868
+ return refuse11(
153869
+ "setup_tor_not_started",
153870
+ `the user chose Tor in the setup question, and the wallet's own Tor ${download3 ? "could not be downloaded" : "did not start"}${reason ? ` (${reason})` : ""}; ${recoveryFile ? "the wallet an earlier setup made stays as it is; nothing was paid" : "nothing was created or paid"}`,
153871
+ `Tell the user: ${reason ? `${reason[0].toUpperCase()}${reason.slice(1)}` : download3 ? "The wallet could not download Tor" : "Tor did not start on this computer"}. ` + (recoveryFile ? `Nothing was paid. The wallet was already made: tell the user to copy its recovery file (${recoveryFile}) to two offline places now. ` : "Nothing was created or paid. ") + `When the user asks again, call shinjuku_setup again: it tries Tor again (a Tor download that finished and passed its check is kept; an unfinished one starts again). Or, to set up without Tor, the user asks again and unticks "${SETUP_TOR_TITLE}" in the question`,
153872
+ recoveryFile ? { recoveryFile, say: fitSay([
153873
+ `Not set up: ${what}. Your wallet was made earlier: copy its recovery file ${recoveryFile} to two offline places now. Then ask me again, or set up without Tor.`,
153874
+ `Not set up: ${what}. Your wallet was made earlier: copy its recovery file (named below) to two offline places now. Then ask me again, or set up without Tor.`
153875
+ ]) } : { say: fitSay([
153876
+ `Not set up: ${what}. Nothing was created. Ask me again, or set up without Tor.`,
153877
+ `Not set up: ${download3 ? "the Tor download failed" : "Tor did not start"}. Ask me again, or set up without Tor.`
153878
+ ]) }
153879
+ );
153880
+ }
153855
153881
  if (current.state === "failed") {
153856
153882
  const { error, detail } = current.failure;
153857
153883
  const recoveryFile = current.recoveryFile;
@@ -154076,8 +154102,11 @@ function createSetupTools({
154076
154102
  answered2();
154077
154103
  return;
154078
154104
  }
154079
- if (answer.tor && !inTorRun()) {
154080
- const tunnel = await localTorCheck(TOR_HTTP_TUNNEL);
154105
+ const ownTor = setup.ownTor?.() === true;
154106
+ job.ownTor = ownTor && answer.tor && !inTorRun();
154107
+ if (answer.tor && !inTorRun() && !ownTor) {
154108
+ const probed = setup.torTunnel?.() ?? TOR_HTTP_TUNNEL;
154109
+ const tunnel = await localTorCheck(probed);
154081
154110
  if (tunnel.answer === "refused" || tunnel.answer === "too_old") {
154082
154111
  if (tunnel.answer === "refused") job.torBrowser = await localTorProof(TOR_BROWSER_PORT) !== "refused";
154083
154112
  else job.torTooOld = tunnel.version;
@@ -162136,7 +162165,7 @@ async function installBundle(home, say2) {
162136
162165
  say2(`Getting Tor for the wallet (once, about ${pinned.mb} MB from the Tor Project, checked).`);
162137
162166
  let response;
162138
162167
  try {
162139
- response = await fetch(pinned.url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
162168
+ response = await fetch(pinned.url, { redirect: "error", signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
162140
162169
  } catch (error) {
162141
162170
  throw failure2("the Tor download did not finish. Check the internet connection, then ask again", `the Tor download did not answer (${error?.name === "TimeoutError" ? "no answer in 5 minutes" : error?.cause?.code ?? error?.message ?? error})`);
162142
162171
  }
@@ -162521,6 +162550,15 @@ function ownPortOf(home) {
162521
162550
  return void 0;
162522
162551
  }
162523
162552
  }
162553
+ function isWalletOwnTunnel(home, tunnel) {
162554
+ const state2 = managedTorState(home);
162555
+ if (!state2) return false;
162556
+ try {
162557
+ return new URL(tunnel).origin === new URL(tunnelOf(state2.port)).origin;
162558
+ } catch {
162559
+ return false;
162560
+ }
162561
+ }
162524
162562
  async function setWalletTor(home, on, { say: say2 = () => {
162525
162563
  }, platform = process.platform } = {}) {
162526
162564
  let config;
@@ -172476,6 +172514,17 @@ function mcpSetupAdapter(values, home, deps) {
172476
172514
  return { ...platform, maxPaymentAtomic: caps.maxPayment, maxSessionAtomic: caps.maxSession };
172477
172515
  },
172478
172516
  missing: () => missingPieces(home, configOrNull(home)),
172517
+ // A "Use Tor?" yes: run() starts the wallet's own Tor first (mcpSetupBehindTor -> torTunnelReady -> ensureWalletTor)
172518
+ // when it applies, so the setup box probes no tunnel then (a live check on npm 0.3.219, a fresh computer, 2026-11-12 15:23:32 UTC: a
172519
+ // fresh home with nothing at 127.0.0.1:9080 stopped at tor_not_running with a terminal step before that start). The
172520
+ // rule: an own-Tor platform, and no recorded torTunnel, or the recorded one is the tunnel managed.json names (the Tor
172521
+ // this wallet started here; isWalletOwnTunnel). Any other recorded tunnel is the user's, and the box probes it.
172522
+ // torTunnel: the tunnel the probe checks otherwise (a Tor the user set, recorded in config.json; else the default).
172523
+ ownTor: () => {
172524
+ const recorded = configOrNull(home)?.torTunnel;
172525
+ return ownTorPlatform() && (recorded === void 0 || isWalletOwnTunnel(home, recorded));
172526
+ },
172527
+ torTunnel: () => configOrNull(home)?.torTunnel ?? TOR_HTTP_TUNNEL,
172479
172528
  // privateInference: the human ticked "Add a private AI tool to this app" (a yes, as setup --private-inference);
172480
172529
  // no tick keeps what config.json records. tor: the answer to "Use Tor?" (private inference turns it on). A server
172481
172530
  // already behind Tor (or an old caller with no answer) sets up in place.
@@ -172502,7 +172551,9 @@ async function mcpSetupBehindTor(values, home, deps, { privateInference, onStage
172502
172551
  const recorded = configOrNull(home)?.torTunnel;
172503
172552
  tunnel = await torTunnelReady(recorded ?? TOR_HTTP_TUNNEL, { explicit: recorded !== void 0 });
172504
172553
  } catch (error) {
172505
- throw new Error(`setup_tor_unavailable: ${String(error.message).replace(/^[a-z][a-z0-9_]*: /, "")}`);
172554
+ const made = configOrNull(home)?.recoveryFile;
172555
+ if (made && existsSync(made)) onStage("wallet-created", { recoveryFile: made });
172556
+ throw new Error(`${error?.managedTor ? "setup_tor_not_started" : "setup_tor_unavailable"}: ${String(error.message).replace(/^[a-z][a-z0-9_]*: /, "")}`);
172506
172557
  }
172507
172558
  const resultDir = mkdtempSync(join58(tmpdir8(), "shinjuku-setup-"));
172508
172559
  const prior = process.env[RESULT_FILE_ENV];