shinjuku-shield 0.3.239 → 0.3.241

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
@@ -8,7 +8,7 @@ web services and AI answers from your private balance, so the payment does
8
8
  not show who paid. It works inside your AI app (Claude, Cursor, Codex) and in
9
9
  a terminal. Only you hold the keys: they never leave your computer.
10
10
 
11
- This is version 0.3.239. The command is `shinjuku`.
11
+ This is version 0.3.241. The command is `shinjuku`.
12
12
 
13
13
  ## Set up
14
14
 
@@ -112,7 +112,7 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
112
112
  Claude Code:
113
113
 
114
114
  ```sh
115
- claude mcp add --scope user shinjuku -- npx -y --prefer-offline --no-audit --no-fund shinjuku-shield@0.3.239 mcp
115
+ claude mcp add --scope user shinjuku -- npx -y --prefer-offline --no-audit --no-fund shinjuku-shield@0.3.241 mcp
116
116
  ```
117
117
 
118
118
  `--prefer-offline` runs the copy of the wallet that npm saved. If npm has not saved it yet, that start asks
@@ -131,7 +131,7 @@ with the Releases table in
131
131
  Versions are published from GitHub Actions with npm provenance.
132
132
 
133
133
  `shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
134
- 0.3.239, its older name, runs this package at the same version, so wallets
134
+ 0.3.241, its older name, runs this package at the same version, so wallets
135
135
  installed under that name keep updating. New installs use `shinjuku`.
136
136
 
137
137
  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": "dd60a30f807d02b8173861757e05e0854dd9715f4d3b70c023b9195b82ea236b",
5
- "bytes": 10564737,
6
- "sourceCommit": "bd027ad77574cb5ddf9adc20998b48facf32c3d3",
4
+ "sha256": "c2684fe19752934e1929cfda02af086706f98bcea3b3281b787e74e3e55f6d2d",
5
+ "bytes": 10590249,
6
+ "sourceCommit": "ca50f3c28b2fbc8e66c32d47fcecd5ad102d4ac8",
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",
@@ -2080,5 +2080,5 @@
2080
2080
  }
2081
2081
  ]
2082
2082
  },
2083
- "publishedAt": "2026-11-17T15:22:15.952Z"
2083
+ "publishedAt": "2026-11-17T18:57:15.643Z"
2084
2084
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shield",
3
- "version": "0.3.239",
3
+ "version": "0.3.241",
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": "dd60a30f",
7
- "shinjukuSha256": "dd60a30f807d02b8173861757e05e0854dd9715f4d3b70c023b9195b82ea236b",
6
+ "shinjukuRelease": "c2684fe1",
7
+ "shinjukuSha256": "c2684fe19752934e1929cfda02af086706f98bcea3b3281b787e74e3e55f6d2d",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shield",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
@@ -124493,8 +124493,8 @@ function refusalSay(a, tool, again, npmVersion) {
124493
124493
  }
124494
124494
  if (code2 === "mcp_unshield_cancel_done") {
124495
124495
  const amount = /send of ([0-9.]+) USDC/.exec(detail)?.[1];
124496
- if (a.sendState === "sent" || amount) return `Nothing was cancelled: your send of ${amount ? `${amount} USDC` : "your balance"} was already sent. Nothing changed.`;
124497
- return "Nothing was cancelled: every smaller payment of that send was already sent. Nothing changed.";
124496
+ if (a.sendState === "sent" || amount) return withBalance(`Nothing was cancelled: your send of ${amount ? `${amount} USDC` : "your balance"} was already sent. Nothing changed.`, a);
124497
+ return withBalance("Nothing was cancelled: every smaller payment of that send was already sent. Nothing changed.", a);
124498
124498
  }
124499
124499
  if (code2 === "mcp_unshield_cancel_not_found") return "Nothing to stop: this wallet has no such private send. Nothing was changed.";
124500
124500
  if (code2 === "transfer_already_done") {
@@ -125547,7 +125547,7 @@ function build(a, tool, npmVersion) {
125547
125547
  }
125548
125548
  if (a.replayed === true) {
125549
125549
  const ago = Number.isSafeInteger(a.finishedMinutesAgo) ? a.finishedMinutesAgo > 0 ? ` about ${minutesText(a.finishedMinutesAgo)} ago` : " less than a minute ago" : " earlier";
125550
- return `Already sent${ago}: ${what} to ${a.to}. This request moved nothing new.`;
125550
+ return withBalance(`Already sent${ago}: ${what} to ${a.to}. This request moved nothing new.`, a);
125551
125551
  }
125552
125552
  const took = Number.isSafeInteger(a.joinedParts) && a.joinedParts > 1 && Number.isSafeInteger(a.tookSeconds) && a.tookSeconds >= 0 ? ` It took about ${a.tookSeconds} s because the wallet first got your balance ready to send.` : "";
125553
125553
  if (typeof a.exitTransaction === "string" && a.privateSend === void 0) {
@@ -147620,12 +147620,12 @@ ${canonical5}`;
147620
147620
  const least = missing > PAY_ME_MIN_ATOMIC ? missing : PAY_ME_MIN_ATOMIC;
147621
147621
  return `To pay with it, the user adds funds once (at least ${usdcText3(least)} USDC); to add funds, ${ADD_FUNDS_STEP}. Later, ${SAFE_BALANCE_READ}; once it shows that a payment can use the private balance (largestPaymentAtomic above 0), ${then}.`;
147622
147622
  };
147623
- function shortZeroStop(short, { tool, requestId, same: same2, costAtomic, beforeBox = false }) {
147623
+ function shortZeroStop(short, { tool, requestId, same: same2, costAtomic, beforeBox = false, againText }) {
147624
147624
  const send3 = tool === "wallet_unshield";
147625
147625
  const received = !send3 && short.receivedOnly === true;
147626
147626
  const sentences = shortSentences(short, send3 ? {} : { costAtomic }).join(" ");
147627
147627
  log(`MCP_${send3 ? "UNSHIELD" : "PAY"}_BALANCE_SHORT ${requestId ? `requestId=${requestId} ` : ""}${received ? "receivedOnly=true" : `deposits=${short.deposits.length}`}`);
147628
- const again2 = `call ${tool} again with ${requestId ? `request_id "${requestId}" and ` : ""}${same2}${send3 ? "" : " (it never pays twice)"}`;
147628
+ const again2 = againText ?? (send3 && requestId && same2 === null ? sendAgain(requestId) : `call ${tool} again with ${requestId ? `request_id "${requestId}" and ` : ""}${same2}${send3 ? "" : " (it never pays twice)"}`);
147629
147629
  return refuse11(
147630
147630
  send3 ? "mcp_unshield_balance_empty" : received ? PAY_NOTHING_SPENDABLE_CODE : PAY_BALANCE_EMPTY_CODE,
147631
147631
  sentences,
@@ -150056,7 +150056,7 @@ ${canonical5}`;
150056
150056
  }
150057
150057
  const failingSends = privateSends.filter((send3) => send3.failedTries > 0);
150058
150058
  if (failingSends.length) {
150059
- next = `${next}. Tell the user: ${failingSends.map((send3) => `payment ${send3.nextPayment} of ${send3.payments} of ${sendWords(send3)} did not go through in ${send3.failedTries} ${send3.failedTries === 1 ? "try" : "tries"}${send3.lastTryMinutesAgo !== void 0 ? ` (the last ${agoWords(send3.lastTryMinutesAgo)})` : ""}: ${send3.lastReason}. It sent ${usdcText3(send3.sentAtomic)} USDC so far. The wallet tries that payment again by itself at its next start`).join(". ")}. ` + failingSends.map((send3) => `${send3.tool === OLD_TRANSFER_TOOL ? "It is an older token transfer's send: no call runs it sooner" : `To try it now: wallet_unshield with request_id "${send3.requestId}" and the same arguments`}; to stop the send and return the USDC not sent yet to the private balance: ${cancelCall(send3)} (${sendWords(send3)})`).join(". ");
150059
+ next = `${next}. Tell the user: ${failingSends.map((send3) => `payment ${send3.nextPayment} of ${send3.payments} of ${sendWords(send3)} did not go through in ${send3.failedTries} ${send3.failedTries === 1 ? "try" : "tries"}${send3.lastTryMinutesAgo !== void 0 ? ` (the last ${agoWords(send3.lastTryMinutesAgo)})` : ""}: ${send3.lastReason}. It sent ${usdcText3(send3.sentAtomic)} USDC so far. The wallet tries that payment again by itself at its next start`).join(". ")}. ` + failingSends.map((send3) => `${send3.tool === OLD_TRANSFER_TOOL ? "It is an older token transfer's send: no call runs it sooner" : `To try it now: wallet_unshield with request_id "${send3.requestId}" alone (the wallet keeps its amount and address)`}; to stop the send and return the USDC not sent yet to the private balance: ${cancelCall(send3)} (${sendWords(send3)})`).join(". ");
150060
150060
  }
150061
150061
  if (privateSends.length && one.largestPaymentAtomic === "0" && (one.changeSettling !== true || one.changeUpToAtomic !== void 0) && /^[1-9][0-9]*$/.test(String(one.balanceAtomic ?? ""))) {
150062
150062
  const soon = one.changeUpToAtomic === void 0 ? "" : `after the last payment settles${Number.isSafeInteger(one.changeReadyInSeconds) ? ` (about ${one.changeReadyInSeconds} s)` : ""}, one payment can use up to ${usdcText3(one.changeUpToAtomic)} USDC; ${one.changeRestOther === true ? "some of the rest waits" : "the rest waits"}, `;
@@ -150694,15 +150694,15 @@ ${canonical5}`;
150694
150694
  ...record.state === "exited" && started !== void 0 ? { startedAt: isoOf(started) } : {},
150695
150695
  ...idle === "not_sent" ? {
150696
150696
  reason: record.refusedCode === void 0 && endedReason ? endedReason : refusedReason(record),
150697
- next: ended2?.state === "gave_up" || record.refusedCode === "gave_up" || gone ? "nothing was sent; if the user still wants to send it, call wallet_unshield with a NEW request_id" : record.refusedCode === "mcp_unshield_wait_for_deposit" ? `nothing was sent yet; once wallet_balance shows the deposit as private, call wallet_unshield with request_id "${shown}", amount_atomic "${record.amountAtomic}", and to "${record.mcpTo}" to send it (it never sends twice)` : "nothing was sent; nothing to do"
150697
+ next: ended2?.state === "gave_up" || record.refusedCode === "gave_up" || gone ? "nothing was sent; if the user still wants to send it, call wallet_unshield with a NEW request_id" : record.refusedCode === "mcp_unshield_wait_for_deposit" ? `nothing was sent yet; once wallet_balance shows the deposit as private, call wallet_unshield with request_id "${shown}" alone (the wallet keeps its amount and address) to send it (it never sends twice)` : "nothing was sent; nothing to do"
150698
150698
  } : {},
150699
150699
  ...idle !== "not_sent" && endedReason && live !== "sending" ? { reason: endedReason } : {},
150700
150700
  ...idle === "not_known" ? { next: "not known yet: another wallet process is working now, and nothing of this send is signed; call wallet_receipts again in a minute" } : {},
150701
150701
  ...live === "sending" && record.state !== "exited" ? { next: 'being sent now; it cannot be cancelled. Tell the user it is on its way; this row shows state "sent" and the transaction once it ends; the wallet finishes it by itself: if it still shows sending, tell the user to ask again in a few minutes (not in a loop)' } : {},
150702
- ...retry ? { ...retry, next: `${retryWords(retry)}. Call wallet_unshield with request_id "${joining.requestId}", amount_atomic "${joining.amountAtomic}", and to "${joining.to}" to try now (it never sends twice)` } : {},
150702
+ ...retry ? { ...retry, next: `${retryWords(retry)}. Call wallet_unshield with request_id "${joining.requestId}" alone to try now (it never sends twice)` } : {},
150703
150703
  ...joining && !retry ? {
150704
150704
  ...joinStepsField(store),
150705
- next: `not sent yet: the wallet first gets the balance ready to send, then sends; each wallet request goes on with it. Call wallet_unshield with request_id "${joining.requestId}", amount_atomic "${joining.amountAtomic}", and to "${joining.to}" to see its progress (it never sends twice)`
150705
+ next: `not sent yet: the wallet first gets the balance ready to send, then sends; each wallet request goes on with it. Call wallet_unshield with request_id "${joining.requestId}" alone to see its progress (it never sends twice)`
150706
150706
  } : {}
150707
150707
  });
150708
150708
  } else if (name.startsWith(`${PRIVATE_SEND_WAL_PREFIX}mcp-`)) {
@@ -151236,8 +151236,9 @@ ${canonical5}`;
151236
151236
  return refuse11(
151237
151237
  "mcp_unshield_cancel_done",
151238
151238
  `${what} was already sent${sent.tx ? ` (transaction ${sent.tx})` : ""}; nothing was changed`,
151239
- sent.tx ? `Nothing to stop. Tell the user it was sent, with transaction ${sent.tx}` : `Nothing to stop. Tell the user it was sent; call wallet_receipts (kind moves) for its transaction and give the user that transaction${sent.conflict ? " (the wallet's two records of it disagree, so check wallet_receipts)" : ""}`,
151240
- { ...ids, sendState: "sent", ...txFields }
151239
+ sent.tx ? `Nothing to stop. Tell the user it was sent, with transaction ${sent.tx}, and the balance now (balanceAtomic)` : `Nothing to stop. Tell the user it was sent; call wallet_receipts (kind moves) for its transaction and give the user that transaction${sent.conflict ? " (the wallet's two records of it disagree, so check wallet_receipts)" : ""}`,
151240
+ // Row 35 (3): the balance now, so no older balance card stands as the last word after the send.
151241
+ { ...ids, sendState: "sent", ...txFields, ...exactBalanceFields() }
151241
151242
  );
151242
151243
  }
151243
151244
  if (state2 === "ended") {
@@ -151259,11 +151260,11 @@ ${canonical5}`;
151259
151260
  return refuse11(
151260
151261
  "mcp_unshield_cancel_sending",
151261
151262
  `the user confirmed ${what} and it is being sent now${sent.tx ? ` (transaction ${sent.tx}; the wallet confirms it)` : ""}; a confirmed send cannot be stopped; nothing was changed`,
151262
- `Nothing was stopped. Tell the user the send goes on and cannot be cancelled${sent.tx ? `, with transaction ${sent.tx}` : ""}. ` + sendRetryNext(job.requestId, sent, { amountAtomic: job.amountAtomic, to: job.to }),
151263
+ `Nothing was stopped. Tell the user the send goes on and cannot be cancelled${sent.tx ? `, with transaction ${sent.tx}` : ""}. ` + sendRetryNext(job.requestId, sent),
151263
151264
  { ...ids, sendState: "sending", ...txFields }
151264
151265
  );
151265
151266
  }
151266
- const sendRetryNext = (requestId, sent = {}, { amountAtomic, to } = {}) => `Then call wallet_unshield with request_id "${requestId}"${amountAtomic ? `, amount_atomic "${amountAtomic}"` : ""}${to ? `, and to "${to}"` : ""} (the same arguments: it reads this same send, finishes it after a restart, never asks again and never sends twice) until it answers done, and give the user its transaction${sent.conflict ? " (the wallet's two records of it disagree now: check wallet_receipts)" : ""}; do not offer the history in place of it. Do not call wallet_cancel with this request_id: for a send in parts that stops its unsent payments`;
151267
+ const sendRetryNext = (requestId, sent = {}) => `Then call wallet_unshield with request_id "${requestId}" alone (the wallet keeps its amount and address: it reads this same send, finishes it after a restart, never asks again and never sends twice) until it answers done, and give the user its transaction${sent.conflict ? " (the wallet's two records of it disagree now: check wallet_receipts)" : ""}; do not offer the history in place of it. Do not call wallet_cancel with this request_id: for a send in parts that stops its unsent payments`;
151267
151268
  function stageOrTimeout(job, ms, signal) {
151268
151269
  return new Promise((resolve45) => {
151269
151270
  let timer;
@@ -151815,7 +151816,61 @@ ${canonical5}`;
151815
151816
  );
151816
151817
  };
151817
151818
  const ownerNext = (detail) => `Nothing was moved. Do not retry and do not change the wallet's settings yourself. Tell the user: ${String(detail).replace(/[.;\s]+$/, "")}.`;
151818
- const again = (kind, job) => `call ${KINDS2[kind].tool} again with request_id "${job.requestId}", amount_atomic "${job.amountAtomic}"${job.to ? `, and to "${job.to}"` : ""}`;
151819
+ const sendAgain = (requestId) => `call wallet_unshield again with request_id "${requestId}" alone (the wallet keeps its amount and address; never pass another to for it)`;
151820
+ const again = (kind, job) => kind === "unshield" ? sendAgain(job.requestId) : `call ${KINDS2[kind].tool} again with request_id "${job.requestId}", amount_atomic "${job.amountAtomic}"`;
151821
+ const sendDestination = (to) => {
151822
+ if (typeof to !== "string" || to.length < 9) return "its address";
151823
+ let owned = [];
151824
+ try {
151825
+ owned = preApproved();
151826
+ } catch {
151827
+ owned = [];
151828
+ }
151829
+ const which = owned[0] === to ? " (the main wallet saved at setup)" : owned.includes(to) ? " (a wallet the user saved at setup)" : "";
151830
+ return `${to.slice(0, 4)}\u2026${to.slice(-4)}${which}`;
151831
+ };
151832
+ function jobScope() {
151833
+ let pool2;
151834
+ try {
151835
+ pool2 = session.openStore().state.pool;
151836
+ } catch {
151837
+ pool2 = void 0;
151838
+ }
151839
+ return { scopeWallet: session.walletPath, scopePool: pool2 };
151840
+ }
151841
+ function recordedSendArgs(requestId, rid) {
151842
+ const scope2 = jobScope();
151843
+ const job = jobs.get(`unshield:${rid}`);
151844
+ if (job && job.state !== "failed" && job.scopeWallet === scope2.scopeWallet && scope2.scopePool !== void 0 && job.scopePool === scope2.scopePool && ATOMIC_TEXT.test(String(job.amountAtomic ?? "")) && typeof job.to === "string") return { amountAtomic: job.amountAtomic, to: job.to };
151845
+ let store;
151846
+ try {
151847
+ store = session.openStore();
151848
+ } catch {
151849
+ return void 0;
151850
+ }
151851
+ const read2 = (name) => {
151852
+ try {
151853
+ return store.readWal(name);
151854
+ } catch {
151855
+ return void 0;
151856
+ }
151857
+ };
151858
+ for (const [record, schema] of [[read2(`self-pay-${moneyId(requestId)}`), SELF_PAY_WAL_SCHEMA], [read2(privateSendPlanName(moneyId(requestId))), PRIVATE_SEND_WAL_SCHEMA]]) {
151859
+ if (record?.schema === schema && typeof record.mcpTo === "string" && ATOMIC_TEXT.test(String(record.amountAtomic ?? ""))) {
151860
+ return { amountAtomic: String(record.amountAtomic), to: record.mcpTo };
151861
+ }
151862
+ }
151863
+ return void 0;
151864
+ }
151865
+ const freshSendAgain = (request) => {
151866
+ let main8;
151867
+ try {
151868
+ main8 = preApproved()[0];
151869
+ } catch {
151870
+ main8 = void 0;
151871
+ }
151872
+ return `call wallet_unshield again with request_id "${request.requestId}" and amount_atomic "${request.amountAtomic}", ` + (request.to === main8 ? "leaving to out (it goes to the main wallet saved at setup)" : `and to exactly as the user gave it (${sendDestination(request.to)}); never copy an address from an answer`);
151873
+ };
151819
151874
  function sendFacts(job) {
151820
151875
  if (!isSplitSend(job)) return {};
151821
151876
  try {
@@ -152190,7 +152245,7 @@ ${canonical5}`;
152190
152245
  const stop2 = JSON.parse(shortZeroStop(short, {
152191
152246
  tool: "wallet_unshield",
152192
152247
  requestId: job.requestId,
152193
- same: `amount_atomic "${job.amountAtomic}"${job.to ? ` and to "${job.to}"` : ""} (it never sends twice)`
152248
+ same: null
152194
152249
  }).text);
152195
152250
  const { ok: _ok, error: stopCode, detail: stopDetail, next: stopNext, requestId: _id, ...zeroShort } = stop2;
152196
152251
  return { code: stopCode, detail: stopDetail, next: stopNext, libraryCode: code2, zeroShort };
@@ -152516,7 +152571,7 @@ ${canonical5}`;
152516
152571
  const joinsDone = Number.isSafeInteger(intent?.joinsDone) ? intent.joinsDone : 0;
152517
152572
  const moved2 = joinsDone > 0 || Number.isSafeInteger(intent?.joinSentAtMs);
152518
152573
  const time = doneInWords(fields ?? joinStepsField());
152519
- const call2 = `Call wallet_unshield again with request_id "${job.requestId}", amount_atomic "${job.amountAtomic}", and to "${job.to}" until it sends: each call goes on with it (it never sends twice; a call that waits for it answers within about ${joinAnswerSeconds(joinCallMaxMs)} s with how far it got)`;
152574
+ const call2 = `Call wallet_unshield again with request_id "${job.requestId}" alone until it sends: each call goes on with it (it never sends twice; a call that waits for it answers within about ${joinAnswerSeconds(joinCallMaxMs)} s with how far it got)`;
152520
152575
  const keptOn = "It goes on in this wallet process and at each wallet request; the send is kept in the wallet, so a new wallet process continues the same one";
152521
152576
  if (moved2) {
152522
152577
  const steps = joinsDone > 0 ? `${joinsDone} step${joinsDone === 1 ? "" : "s"} of it ${joinsDone === 1 ? "is" : "are"} done` : "its first step is under way";
@@ -152547,7 +152602,7 @@ ${canonical5}`;
152547
152602
  ...answer,
152548
152603
  joinTellFirst: true,
152549
152604
  sendsAll,
152550
- next: `Nothing was sent yet. Write this to the user now: ${what}; the wallet first gets the whole balance ready to send (a private move inside the wallet, no fee), then sends${time ? `: ${time} in all` : ""}. Do not tell the user how the wallet stores the balance. Then, in the same reply and without waiting for the user, call wallet_unshield again with request_id "${job.requestId}", amount_atomic "${job.amountAtomic}", and to "${job.to}": that call gets the balance ready and sends. It answers when the send is done, or after about ${joinAnswerSeconds(joinCallMaxMs)} s with how far it got (what moved, and the same request_id to ask again); some apps show nothing until it answers. It never sends twice`
152605
+ next: `Nothing was sent yet. Write this to the user now: ${what}; the wallet first gets the whole balance ready to send (a private move inside the wallet, no fee), then sends${time ? `: ${time} in all` : ""}. Do not tell the user how the wallet stores the balance. Then, in the same reply and without waiting for the user, call wallet_unshield again with request_id "${job.requestId}" alone: that call gets the balance ready and sends. It answers when the send is done, or after about ${joinAnswerSeconds(joinCallMaxMs)} s with how far it got (what moved, and the same request_id to ask again); some apps show nothing until it answers. It never sends twice`
152551
152606
  });
152552
152607
  }
152553
152608
  async function joinLoop({ until, signal, each, onTick = () => {
@@ -152733,7 +152788,7 @@ ${canonical5}`;
152733
152788
  return refuse11(
152734
152789
  "mcp_unshield_join_failed",
152735
152790
  `nothing was sent: getting the balance ready to send failed (${code2}); nothing left the private balance, and the send stays kept in the wallet`,
152736
- `Nothing was sent. Tell the user: getting the balance ready to send failed; the wallet tries again at a wallet request after about ${minutesText2(minutes)}. Then call wallet_unshield again with request_id "${job.requestId}", amount_atomic "${job.amountAtomic}", and to "${job.to}" (it never sends twice). If it fails again, tell the user: the wallet could not get the balance ready to send, nothing was sent, and the user can run ${terminalCommand2("prepare")} once in a terminal to do that step`,
152791
+ `Nothing was sent. Tell the user: getting the balance ready to send failed; the wallet tries again at a wallet request after about ${minutesText2(minutes)}. Then call wallet_unshield again with request_id "${job.requestId}" alone (it never sends twice). If it fails again, tell the user: the wallet could not get the balance ready to send, nothing was sent, and the user can run ${terminalCommand2("prepare")} once in a terminal to do that step`,
152737
152792
  { requestId: job.requestId, amountAtomic: job.amountAtomic, to: job.to, done: false, stage: "joining", joinFailedCode: code2, retryInMinutes: minutes }
152738
152793
  );
152739
152794
  }
@@ -152772,6 +152827,16 @@ ${canonical5}`;
152772
152827
  ] };
152773
152828
  }
152774
152829
  const rid = recordId(requestId);
152830
+ if (kind === "unshield" && !probe) {
152831
+ const noAmount = (args.amount === void 0 || args.amount === null || args.amount === "") && (args.amount_atomic === void 0 || args.amount_atomic === null || args.amount_atomic === "");
152832
+ const noTo = args.to === void 0 || args.to === null || args.to === "";
152833
+ const recorded = noAmount || noTo ? recordedSendArgs(requestId, rid) : void 0;
152834
+ if (recorded) {
152835
+ const { amount: _amount, amount_atomic: _atomic, ...rest } = args;
152836
+ args = noAmount ? { ...rest, amount_atomic: recorded.amountAtomic } : args;
152837
+ if (noTo) args = { ...args, to: recorded.to };
152838
+ }
152839
+ }
152775
152840
  if (kind === "shield" && rid.startsWith("elsewhere-")) {
152776
152841
  return { refusal: [
152777
152842
  "mcp_argument_invalid",
@@ -153183,7 +153248,7 @@ ${canonical5}`;
153183
153248
  if (notice.outcome === "not-started" || notice.outcome === "stopped") {
153184
153249
  return {
153185
153250
  say: `${what}, and its last try ${notice.outcome === "stopped" ? "ended for good" : "was refused"} (${autoFinishReason(notice.code)}), so the wallet does not try it again by itself. Your receipts show its state.`,
153186
- next: `Do not tell the user whether money left before ${receipts2}. If the user wants the send of request_id "${notice.requestId}" tried again, call wallet_unshield with request_id "${notice.requestId}", amount_atomic "${notice.amountAtomic}" and to "${notice.to}" (it never sends twice).`
153251
+ next: `Do not tell the user whether money left before ${receipts2}. If the user wants the send of request_id "${notice.requestId}" tried again, call wallet_unshield with request_id "${notice.requestId}" alone (it never sends twice).`
153187
153252
  };
153188
153253
  }
153189
153254
  return {
@@ -153306,7 +153371,7 @@ ${canonical5}`;
153306
153371
  const reused = (detail) => refuse11(
153307
153372
  "mcp_request_id_reused",
153308
153373
  detail,
153309
- `read this one with the arguments it started with; if the user wants a new ${spec.noun}, start it with a NEW request_id such as "${freshId}" (or leave request_id out and the wallet makes one)`,
153374
+ `read this one with wallet_receipts and kind "moves" (a read; its row with requestId "${request.requestId}" shows it); if the user wants a new ${spec.noun}, start it with a NEW request_id such as "${freshId}" (or leave request_id out and the wallet makes one)`,
153310
153375
  { requestId: request.requestId }
153311
153376
  );
153312
153377
  const recording = kind === "unshield" ? jobs.get(key)?.stopRecording : void 0;
@@ -153341,7 +153406,7 @@ ${canonical5}`;
153341
153406
  const openState = (one) => sendStates.get(one.requestId) === "sending" ? "sending" : "joining";
153342
153407
  intent = intents2.find((one) => one.requestId === request.requestId);
153343
153408
  const openSend = (one) => `a send of ${usdcText3(one.amountAtomic)} USDC to ${one.to.slice(0, 4)}...${one.to.slice(-4)} (request_id "${one.requestId}")`;
153344
- const askNext = (one) => openState(one) === "sending" ? `Ask about that send: call wallet_receipts with kind "moves" (it starts no new send); its unshield row with requestId "${one.requestId}" shows its state and transaction` : `Ask about that send: call wallet_unshield with request_id "${one.requestId}", amount_atomic "${one.amountAtomic}", and to "${one.to}" (it continues the same send and never sends twice)`;
153409
+ const askNext = (one) => openState(one) === "sending" ? `Ask about that send: call wallet_receipts with kind "moves" (it starts no new send); its unshield row with requestId "${one.requestId}" shows its state and transaction` : `Ask about that send: call wallet_unshield with request_id "${one.requestId}" alone (it continues the same send and never sends twice)`;
153345
153410
  if (intent && (intent.to !== request.to || intent.amountAtomic !== request.amountAtomic || isSplitSend(request))) {
153346
153411
  return refuse11(
153347
153412
  "mcp_request_id_reused",
@@ -153361,6 +153426,13 @@ ${canonical5}`;
153361
153426
  }
153362
153427
  }
153363
153428
  const amountMayChange = kind === "elsewhere" && known?.state !== "running";
153429
+ const sendReused = (amountAtomic, to) => refuse11(
153430
+ "mcp_request_id_reused",
153431
+ `request_id "${request.requestId}" is a send of ${usdcText3(amountAtomic)} USDC to ${sendDestination(to)}; the wallet never sends it anywhere else; nothing new was moved`,
153432
+ `Nothing new was sent. To read that send, ${sendAgain(request.requestId)}. If the user wants a new send, start it with a NEW request_id such as "${freshId}" (or leave request_id out and the wallet makes one)`,
153433
+ { requestId: request.requestId }
153434
+ );
153435
+ if (kind === "unshield" && known && !sameRequest(known, request) && typeof known.to === "string") return sendReused(known.amountAtomic, known.to);
153364
153436
  if (known && !sameRequest(known, request) && !amountMayChange) return reused(`request_id "${request.requestId}" already names a ${spec.noun} with another amount_atomic${kind === "unshield" ? " or to" : ""}; nothing new was moved`);
153365
153437
  if (kind === "unshield") {
153366
153438
  if (known?.state === "failed" && known.error?.code === "mcp_unshield_other_wallet") return jobAnswer(kind, known);
@@ -153416,6 +153488,9 @@ ${canonical5}`;
153416
153488
  const schema = kind === "unshield" ? split4 ? PRIVATE_SEND_WAL_SCHEMA : SELF_PAY_WAL_SCHEMA : DEPOSIT_WAL_SCHEMA;
153417
153489
  const sourceOk = kind === "elsewhere" ? Boolean(record.relay) && record.relay.pocket === void 0 && record.relay.own === void 0 : !record.relay || record.relay.own === true;
153418
153490
  const amountOk = record.amountAtomic === request.amountAtomic || kind === "elsewhere" && record.state === "awaiting_funds";
153491
+ if (kind === "unshield" && record.schema === schema && typeof record.mcpTo === "string" && (!amountOk || record.mcpTo !== request.to)) {
153492
+ return sendReused(record.amountAtomic, record.mcpTo);
153493
+ }
153419
153494
  if (record.schema !== schema || !sourceOk || !amountOk || kind === "unshield" && record.mcpTo !== void 0 && record.mcpTo !== request.to) {
153420
153495
  return reused(`request_id "${request.requestId}" already names a ${spec.noun} in this wallet with another amount_atomic${kind === "unshield" ? " or to" : ""}; nothing new was moved`);
153421
153496
  }
@@ -153451,6 +153526,7 @@ ${canonical5}`;
153451
153526
  stage: "done",
153452
153527
  state: record.state,
153453
153528
  ...earlier,
153529
+ ...kind === "unshield" ? exactBalanceFields() : {},
153454
153530
  ...kind !== "unshield" ? { transaction: typeof record.receipt?.signature === "string" ? record.receipt.signature : null } : split4 ? sendHeadline(send3) : { selfPayTransaction: record.transaction ?? null, exitTransaction: record.exitTransaction ?? null },
153455
153531
  ...kind === "elsewhere" ? elsewhereFacts(request.requestId, record) : {},
153456
153532
  ...kind !== "unshield" && record.state === "foreign_funded" ? { fundedByThisWallet: false } : {},
@@ -153484,7 +153560,7 @@ ${canonical5}`;
153484
153560
  }
153485
153561
  }
153486
153562
  if (intent && joiner.request({ kept: true }).joining) {
153487
- const job2 = { kind, ...request, state: "failed", failedStage: "joining", startedAtMs: Date.now() };
153563
+ const job2 = { kind, ...request, state: "failed", failedStage: "joining", startedAtMs: Date.now(), ...jobScope() };
153488
153564
  jobs.set(key, job2);
153489
153565
  joiningStage(key, job2);
153490
153566
  return jobAnswer(kind, job2);
@@ -153566,7 +153642,7 @@ ${canonical5}`;
153566
153642
  return refuse11(
153567
153643
  "mcp_unshield_balance_empty",
153568
153644
  emptyUnshieldDetail(empty),
153569
- emptyUnshieldNext(empty, again(kind, request)),
153645
+ emptyUnshieldNext(empty, freshSendAgain(request)),
153570
153646
  { requestId: request.requestId, ...emptyUnshieldFields(empty) }
153571
153647
  );
153572
153648
  }
@@ -153576,7 +153652,8 @@ ${canonical5}`;
153576
153652
  return shortZeroStop(short, {
153577
153653
  tool: "wallet_unshield",
153578
153654
  beforeBox: true,
153579
- same: `amount_atomic "${request.amountAtomic}"${request.to ? ` and to "${request.to}"` : ""}`
153655
+ // No record yet: request_id and amount, and to left out or as the user gave it (freshSendAgain; row 35).
153656
+ againText: freshSendAgain(request)
153580
153657
  });
153581
153658
  }
153582
153659
  const switched = await switchGate(request.amountAtomic, request.requestId, "wallet_unshield", answerLeft());
@@ -153592,7 +153669,7 @@ ${canonical5}`;
153592
153669
  return refuse11(
153593
153670
  shortfall.error,
153594
153671
  promisedShortfallText(shortfall, request.amountAtomic).replace(/^[a-z_]+: /, ""),
153595
- held2 ? `Nothing was sent. ${heldByPrivateSendText(held2)} Then ${again(kind, request)} (it never sends twice)` : PROMISED_NEXT,
153672
+ held2 ? `Nothing was sent. ${heldByPrivateSendText(held2)} Then ${freshSendAgain(request)} (it never sends twice)` : PROMISED_NEXT,
153596
153673
  {
153597
153674
  requestId: request.requestId,
153598
153675
  ...shortfall.freeAtomic ? { freeAtomic: shortfall.freeAtomic, promisedAtomic: shortfall.pendingAtomic } : {},
@@ -153686,6 +153763,7 @@ ${canonical5}`;
153686
153763
  ...request,
153687
153764
  state: "running",
153688
153765
  startedAtMs: Date.now(),
153766
+ ...jobScope(),
153689
153767
  stage: needsConfirm || askFunding ? "confirming" : kind === "unshield" ? "queued" : kind === "elsewhere" ? "checking" : "starting",
153690
153768
  ...fundingAsk && !askFunding ? { fundingWalletNote: FUNDING_WALLET_SENTENCE } : {}
153691
153769
  };
@@ -154381,7 +154459,7 @@ ${canonical5}`;
154381
154459
  return void 0;
154382
154460
  }
154383
154461
  const what = `the send of ${usdcText3(record.amountAtomic)} USDC to ${record.mcpTo.slice(0, 4)}...${record.mcpTo.slice(-4)}`;
154384
- const call2 = `call wallet_unshield with request_id "${requestId}", amount_atomic "${record.amountAtomic}", and to "${record.mcpTo}"`;
154462
+ const call2 = `call wallet_unshield with request_id "${requestId}" alone`;
154385
154463
  const ask = `${call2} to see its progress (it never sends twice)`;
154386
154464
  const sent = state2 === "sent" || state2 === "sending" ? sendTransactionOf(requestId) : {};
154387
154465
  const txFields = sent.tx ? { exitTransaction: sent.tx } : {};
@@ -154389,8 +154467,8 @@ ${canonical5}`;
154389
154467
  return refuse11(
154390
154468
  "mcp_unshield_cancel_done",
154391
154469
  `${what} was already sent${sent.tx ? ` (transaction ${sent.tx})` : ""}; nothing was changed`,
154392
- sent.tx ? `Nothing to stop. Tell the user it was sent, with transaction ${sent.tx}` : `Nothing to stop. Tell the user it was sent; call wallet_receipts (kind moves) for its transaction and give the user that transaction${sent.conflict ? " (the wallet's two records of it disagree, so check wallet_receipts)" : ""}`,
154393
- { requestId, sendState: "sent", ...txFields }
154470
+ sent.tx ? `Nothing to stop. Tell the user it was sent, with transaction ${sent.tx}, and the balance now (balanceAtomic)` : `Nothing to stop. Tell the user it was sent; call wallet_receipts (kind moves) for its transaction and give the user that transaction${sent.conflict ? " (the wallet's two records of it disagree, so check wallet_receipts)" : ""}`,
154471
+ { requestId, sendState: "sent", ...txFields, ...exactBalanceFields() }
154394
154472
  );
154395
154473
  }
154396
154474
  const how = sendNowWords(state2, intent);
@@ -154452,8 +154530,8 @@ ${canonical5}`;
154452
154530
  return refuse11(
154453
154531
  "mcp_unshield_cancel_done",
154454
154532
  `every payment of the private send "${requestId}" was already sent; nothing was changed`,
154455
- "Nothing to stop. Call wallet_unshield with the same request_id to read each of its payments",
154456
- { requestId }
154533
+ `Nothing to stop. Call wallet_unshield with request_id "${requestId}" alone to read each of its payments`,
154534
+ { requestId, ...exactBalanceFields() }
154457
154535
  );
154458
154536
  }
154459
154537
  return refuse11(
@@ -154476,7 +154554,7 @@ ${canonical5}`;
154476
154554
  sentAtomic: status.sentAtomic,
154477
154555
  cancelledAtomic: status.cancelledAtomic,
154478
154556
  detail: finishing.length === 0 ? `stopped: ${floatAmountText(status.cancelledAtomic, "the rest")} was never sent and stays in the private balance; ${floatAmountText(status.sentAtomic, "some USDC")} was already sent` : `stopped: ${floatAmountText(status.cancelledAtomic, "the rest")} is never sent and stays in the private balance. Payment${finishing.length === 1 ? "" : "s"} ${finishing.join(", ")} already started and finish${finishing.length === 1 ? "es" : ""} (that value already left the balance for this send's recipient)`,
154479
- next: finishing.length === 0 ? `Tell the user: Stopped. ${back}${/^[1-9][0-9]*$/.test(String(status.sentAtomic ?? "")) ? `; ${floatAmountText(status.sentAtomic, "")} was already sent` : ""}. wallet_balance shows what the user can spend now` : `Tell the user: Stopped. ${back}; a payment that already started still goes (at the next wallet start if this process ends first). Call wallet_unshield with request_id "${requestId}" and the same arguments to read it`
154557
+ next: finishing.length === 0 ? `Tell the user: Stopped. ${back}${/^[1-9][0-9]*$/.test(String(status.sentAtomic ?? "")) ? `; ${floatAmountText(status.sentAtomic, "")} was already sent` : ""}. wallet_balance shows what the user can spend now` : `Tell the user: Stopped. ${back}; a payment that already started still goes (at the next wallet start if this process ends first). Call wallet_unshield with request_id "${requestId}" alone to read it (its plan keeps the amount and address)`
154480
154558
  });
154481
154559
  }
154482
154560
  function resumePrivateSends({ rescan = false } = {}) {
@@ -155151,7 +155229,7 @@ ${canonical5}`;
155151
155229
  name: "wallet_unshield",
155152
155230
  // UX130-13: a host that defers tools may show only the title: it says where a send goes by default.
155153
155231
  title: "Send USDC privately",
155154
- description: `Use this for "send 2 USDC to <address>" or "withdraw to my wallet" (for "my wallet" leave \`to\` out: it uses the address saved at setup, or says how to set one; do not ask the user for an address first): it sends amount (USDC, like "2"; or amount_atomic) from the PRIVATE balance as plain USDC to \`to\`, a public Solana address. BEFORE you call it to send all of the balance when wallet_balance showed balanceParts above 1, write to the user that the wallet first gets the balance ready to send (some apps show nothing until this call ends). Privately: the chain shows the pool paying the address, not which wallet paid. This wallet's own public address (ownAddress in wallet_balance: it holds the public USDC, wallet_shield deposits from it) is refused as \`to\`: an exit there would show on chain that the private balance is this wallet's (wallet_add_funds deposits come from one-time addresses, not from it; never tell the user they came from it). No SOL is needed. The user's saved own addresses (setup or this app's wallet entry) send at once. A wallet that added money here gets one question first (mcp_unshield_other_wallet: not sent, ask for another address; no question: tell the user privacyNote). Any other address needs the user's yes in a dialog of this app; a client that cannot ask is refused (mcp_unshield_to_not_allowed) and a decline sends nothing (mcp_unshield_declined). \`to\` must already be able to receive USDC: an address that cannot is refused before any dialog (mcp_unshield_to_invalid). It runs in steps and may wait for the pool's next anchor. Each call answers within about 20 s (at once when the send ends; a dialog may take longer) with ok: true and stage: confirming, queued, refreshing, self-pay = preparing, exit = sending, done; joining = the wallet first gets the balance ready, then sends; each call goes on with it (joinSteps: its steps, in order; doneInMinutesLow to doneInMinutesHigh: the time to say). Once it sends (self-pay, exit), read its result with wallet_receipts kind moves; before that, call wallet_unshield again with the SAME request_id, amount and to. When the balance must first be made ready, the FIRST call answers at once with stage joining and joinTellFirst: true; write its say to the user, then call again with the same request_id at once. One exception: when this app sends a progress token with that next call, the call gets the balance ready and then sends, with a progress line every ${JOIN_STEP_MS / 1e3} s ("getting your balance ready to send"; some apps show none, so the line is said before the call, as above). It answers when the send is done, or after about ${joinAnswerSeconds(JOIN_CALL_MAX_MS)} s with how far it got (joinsDone; sendState sending: the USDC is leaving, never say nothing moved, read it with wallet_receipts); else call again with the same request_id. Without a progress token it answers within about 20 s with stage joining: call again until it sends. The same request_id never sends twice, also after a restart. request_id is optional: without it the answer names the id it made; the same call again within 10 minutes after it ends reads that send. An optional unshield limit the user sets may bound each call and what this wallet sends in any 24 hours, from every app (mcp_unshield_cap_exceeded: tell the user). Other refusals: mcp_argument_invalid, mcp_request_id_reused, wallet_locked, mcp_tool_disabled, mcp_unshield_failed, and the unshield's own p03_* codes. A call the app stopped, rejected or interrupted, or one that failed, may still send: call wallet_cancel (no request_id) before you tell the user anything about that send; never say nothing was sent without it. A send is one payment to \`to\`. ${HOST_BLOCKED_LINE}`,
155232
+ description: `Use this for "send 2 USDC to <address>" or "withdraw to my wallet" (for "my wallet" leave \`to\` out: it uses the address saved at setup, or says how to set one; do not ask the user for an address first): it sends amount (USDC, like "2"; or amount_atomic) from the PRIVATE balance as plain USDC to \`to\`, a public Solana address. BEFORE you call it to send all of the balance when wallet_balance showed balanceParts above 1, write to the user that the wallet first gets the balance ready to send (some apps show nothing until this call ends). Privately: the chain shows the pool paying the address, not which wallet paid. This wallet's own public address (ownAddress in wallet_balance: it holds the public USDC, wallet_shield deposits from it) is refused as \`to\`: an exit there would show on chain that the private balance is this wallet's (wallet_add_funds deposits come from one-time addresses, not from it; never tell the user they came from it). No SOL is needed. The user's saved own addresses (setup or this app's wallet entry) send at once. A wallet that added money here gets one question first (mcp_unshield_other_wallet: not sent, ask for another address; no question: tell the user privacyNote). Any other address needs the user's yes in a dialog of this app; a client that cannot ask is refused (mcp_unshield_to_not_allowed) and a decline sends nothing (mcp_unshield_declined). \`to\` must already be able to receive USDC: an address that cannot is refused before any dialog (mcp_unshield_to_invalid). It runs in steps and may wait for the pool's next anchor. Each call answers within about 20 s (at once when the send ends; a dialog may take longer) with ok: true and stage: confirming, queued, refreshing, self-pay = preparing, exit = sending, done; joining = the wallet first gets the balance ready, then sends; each call goes on with it (joinSteps: its steps, in order; doneInMinutesLow to doneInMinutesHigh: the time to say). Once it sends (self-pay, exit), read its result with wallet_receipts kind moves; before that, call wallet_unshield again with the SAME request_id only. When the balance must first be made ready, the FIRST call answers at once with stage joining and joinTellFirst: true; write its say to the user, then call again with the same request_id at once. One exception: when this app sends a progress token with that next call, the call gets the balance ready and then sends, with a progress line every ${JOIN_STEP_MS / 1e3} s ("getting your balance ready to send"; some apps show none, so the line is said before the call, as above). It answers when the send is done, or after about ${joinAnswerSeconds(JOIN_CALL_MAX_MS)} s with how far it got (joinsDone; sendState sending: the USDC is leaving, never say nothing moved, read it with wallet_receipts); else call again with the same request_id. Without a progress token it answers within about 20 s with stage joining: call again until it sends. The same request_id never sends twice, also after a restart. request_id is optional: without it the answer names the id it made; the same call again within 10 minutes after it ends reads that send. An optional unshield limit the user sets may bound each call and what this wallet sends in any 24 hours, from every app (mcp_unshield_cap_exceeded: tell the user). Other refusals: mcp_argument_invalid, mcp_request_id_reused, wallet_locked, mcp_tool_disabled, mcp_unshield_failed, and the unshield's own p03_* codes. A call the app stopped, rejected or interrupted, or one that failed, may still send: call wallet_cancel (no request_id) before you tell the user anything about that send; never say nothing was sent without it. A send is one payment to \`to\`. ${HOST_BLOCKED_LINE}`,
155155
155233
  inputSchema: {
155156
155234
  type: "object",
155157
155235
  properties: {
@@ -158671,7 +158749,7 @@ var init_tools = __esm({
158671
158749
  KEPT_SEND_TRIES = () => JOIN_RETRY_BACKOFF_MS.length + 1;
158672
158750
  shownId = (agentId, rid) => typeof agentId === "string" && REQUEST_ID4.test(agentId) && toRecordId(agentId) === rid ? agentId : rid;
158673
158751
  isSplitSend = (request) => Boolean(request) && !(Number(request.parts ?? 1) === 1 && Number(request.maxDelayMinutes ?? 0) === 0);
158674
- PROMISED_NEXT = "Nothing was sent. Some of the private balance is promised to the unsent payments of a private send (wallet_balance privateSends names it, and its next names the call that stops it). A wait frees nothing, because that money leaves the wallet as its parts go: to send this amount, stop its unsent payments with that call, then call wallet_unshield again with the same arguments; or, if the user wants to send less now, send at most freeAtomic with a NEW request_id";
158752
+ PROMISED_NEXT = "Nothing was sent. Some of the private balance is promised to the unsent payments of a private send (wallet_balance privateSends names it, and its next names the call that stops it). A wait frees nothing, because that money leaves the wallet as its parts go: to send this amount, stop its unsent payments with that call, then call wallet_unshield again with the same request_id and amount, to left out for the main wallet saved at setup, else to as the user gave it (never copied from an answer); or, if the user wants to send less now, send at most freeAtomic with a NEW request_id";
158675
158753
  partFailReason = (code2) => INSUFFICIENT_CODE.test(String(code2 ?? "")) ? "the wallet could not pay that amount in one payment from the private balance as it is" : reasonOf(code2) ?? "the payment did not finish";
158676
158754
  sendAnswerOf = (status) => {
158677
158755
  const { nextPartLastTryAt: _clock, ...shown } = status;
@@ -162975,8 +163053,10 @@ var init_homeMark = __esm({
162975
163053
  function homeKeys(data) {
162976
163054
  const tor = data?.torToggle === true && (data.tor === true || data.tor === false) ? [["o", data.tor ? "turn tor off" : "turn tor on"]] : [];
162977
163055
  const setup = walletNotices(data ?? {}).some((notice) => notice.command) ? [["s", "finish setup"]] : [];
163056
+ const shield = setup.length || data?.setUp !== true ? [] : data?.shieldOpen ? [["m", "finish making USDC private"]] : [["m", "make public USDC private"]];
162978
163057
  return [
162979
163058
  ...setup,
163059
+ ...shield,
162980
163060
  ["t", "private AI chat"],
162981
163061
  ["i", "private AI address"],
162982
163062
  ["a", "add funds"],
@@ -163357,8 +163437,9 @@ function walletBlock(data, wide, w, compact = false) {
163357
163437
  const pub = publicRows(data, w);
163358
163438
  if (pub) rows2.push(pub.row);
163359
163439
  const note = clean4(data.addingFundsNote);
163360
- const noteLines = note ? wrap(note, w - 4) : [];
163361
- return rowsBlock(PANELS.wallet, state2, notices.length ? "mute" : "brass", rows2, [...extra, ...noteLines, ...pub?.step ?? []], "dim");
163440
+ const shieldNote = clean4(data.shieldOpen?.amount) ? `a shield of ${clean4(data.shieldOpen.amount)} did not finish. [m] finishes it.` : "";
163441
+ const noteLines = [...note ? wrap(note, w - 4) : [], ...shieldNote ? wrap(shieldNote, w - 4) : []];
163442
+ return rowsBlock(PANELS.wallet, state2, notices.length ? "mute" : "brass", rows2, [...extra, ...noteLines, ...shieldNote ? [] : pub?.step ?? []], "dim");
163362
163443
  }
163363
163444
  function privacyBlock(data) {
163364
163445
  const rows2 = [];
@@ -163764,12 +163845,15 @@ ${rule}
163764
163845
 
163765
163846
  `);
163766
163847
  let code2;
163848
+ let endWords;
163767
163849
  try {
163768
- code2 = await run2();
163850
+ const result = await run2();
163851
+ if (result !== null && typeof result === "object") ({ code: code2, ended: endWords } = result);
163852
+ else code2 = result;
163769
163853
  } catch {
163770
163854
  code2 = 1;
163771
163855
  }
163772
- const end2 = code2 === 0 ? [["\u25C6 ", "crim"], [`${clean4(title)}: done`, "bone"]] : code2 === 130 ? [["\u25C6 ", "crim"], [`${clean4(title)}: stopped (Ctrl+C)`, "bone"]] : [["\u25CB ", "mute"], [`${clean4(title)}: it stopped; its message is above`, "bone"]];
163856
+ const end2 = code2 === 0 ? [["\u25C6 ", "crim"], [`${clean4(title)}: ${endWords ? clean4(endWords) : "done"}`, "bone"]] : code2 === 130 ? [["\u25C6 ", "crim"], [`${clean4(title)}: stopped (Ctrl+C)`, "bone"]] : [["\u25CB ", "mute"], [`${clean4(title)}: it stopped; its message is above`, "bone"]];
163773
163857
  const gone = () => {
163774
163858
  try {
163775
163859
  return launcherGone();
@@ -163929,6 +164013,7 @@ var init_homeScreen = __esm({
163929
164013
  // The news: the owner's chat on 0.3.157 asked for it, and the model said its knowledge ended in 2024 (release review, 2026-11-03).
163930
164014
  t: "talk with an AI, paid privately. it reads no news and no web.",
163931
164015
  i: "the address and key that give another app your private AI.",
164016
+ m: "make the USDC on your own address private. no SOL needed.",
163932
164017
  a: "get a one-time address, then send USDC on Solana to it.",
163933
164018
  u: "send money from your private balance to a Solana address.",
163934
164019
  p: "paste a link that asks for payment. it shows the price first.",
@@ -164055,7 +164140,7 @@ var init_homeScreen = __esm({
164055
164140
  randomKatakana = () => KATAKANA[Math.random() * KATAKANA.length | 0];
164056
164141
  MARK_TONES = { b: "brass", c: "crim", o: "crimdim" };
164057
164142
  PUBLIC_STEP = {
164058
- shield: 'ask your agent app: "make my public USDC private"',
164143
+ shield: "press m to make it private.",
164059
164144
  "below-least": "the least that can be made private is 0.01 USDC."
164060
164145
  };
164061
164146
  stackHeight = (blocks) => blocks.reduce((sum2, block) => sum2 + block.height, 0) + blocks.length - 1;
@@ -169618,6 +169703,75 @@ init_spendPolicy();
169618
169703
  init_usdcWords();
169619
169704
  init_stdioServer();
169620
169705
  init_tools();
169706
+ init_recoveryBundle();
169707
+
169708
+ // wallet/src/cli/terminalShield.mjs
169709
+ init_deposit();
169710
+ var SHIELD_PENDING = "terminal-shield-pending";
169711
+ var SHIELD_PENDING_SCHEMA = "shinjuku.terminal-shield-pending.v1";
169712
+ var ATOMIC15 = /^[1-9][0-9]{0,30}$/;
169713
+ var DEPOSIT_ID = /^[0-9a-zA-Z_.:-]{1,128}$/;
169714
+ function writePendingShield(store, depositId, amountAtomic, at) {
169715
+ store.writeWal(SHIELD_PENDING, { schema: SHIELD_PENDING_SCHEMA, depositId, amountAtomic: String(amountAtomic), startedAt: at });
169716
+ }
169717
+ function removePendingShield(store) {
169718
+ try {
169719
+ store.removeWal(SHIELD_PENDING);
169720
+ } catch {
169721
+ }
169722
+ }
169723
+ function shieldDepositOf(store, depositId) {
169724
+ let record;
169725
+ try {
169726
+ record = store.readWal(`deposit-${depositId}`);
169727
+ } catch {
169728
+ return void 0;
169729
+ }
169730
+ if (record?.schema !== DEPOSIT_WAL_SCHEMA || typeof record.state !== "string") return void 0;
169731
+ const signature2 = record.receipt?.signature;
169732
+ return { state: record.state, resolved: RESOLVED_STATES.has(record.state), transaction: typeof signature2 === "string" ? signature2 : null };
169733
+ }
169734
+ function pendingShield(store) {
169735
+ let record;
169736
+ try {
169737
+ record = store.readWal(SHIELD_PENDING);
169738
+ } catch {
169739
+ return void 0;
169740
+ }
169741
+ if (record?.schema !== SHIELD_PENDING_SCHEMA || !DEPOSIT_ID.test(String(record.depositId ?? "")) || !ATOMIC15.test(String(record.amountAtomic ?? ""))) {
169742
+ return void 0;
169743
+ }
169744
+ return { depositId: record.depositId, amountAtomic: record.amountAtomic, deposit: shieldDepositOf(store, record.depositId) };
169745
+ }
169746
+ function openOwnShield(store) {
169747
+ let names2;
169748
+ try {
169749
+ names2 = store.listWal();
169750
+ } catch {
169751
+ return void 0;
169752
+ }
169753
+ for (const name of names2) {
169754
+ if (!name.startsWith("deposit-")) continue;
169755
+ let record;
169756
+ try {
169757
+ record = store.readWal(name);
169758
+ } catch {
169759
+ continue;
169760
+ }
169761
+ if (record?.schema === DEPOSIT_WAL_SCHEMA && record.relay?.own === true && !RESOLVED_STATES.has(record.state) && ATOMIC15.test(String(record.amountAtomic ?? ""))) {
169762
+ return { depositId: name.slice("deposit-".length), amountAtomic: String(record.amountAtomic) };
169763
+ }
169764
+ }
169765
+ return void 0;
169766
+ }
169767
+ function unfinishedShield(store) {
169768
+ const open6 = openOwnShield(store);
169769
+ if (open6) return { amountAtomic: open6.amountAtomic };
169770
+ const pending = pendingShield(store);
169771
+ return pending?.deposit ? { amountAtomic: pending.amountAtomic } : null;
169772
+ }
169773
+
169774
+ // wallet/src/cli/shinjukuWallet.mjs
169621
169775
  init_config();
169622
169776
 
169623
169777
  // wallet/src/setup/setup.mjs
@@ -174507,6 +174661,11 @@ function readHomeData({ env = process.env, walletVersion: walletVersion2, torRun
174507
174661
  balance,
174508
174662
  balanceKnownAt: Number.isFinite(refreshedAt) ? refreshedAt : null,
174509
174663
  publicUsdc: setUp ? tryOr(null, () => publicUsdcOf(store)) : null,
174664
+ // A shield that did not finish (cli/terminalShield.mjs): [m] finishes it, also with no saved public read.
174665
+ shieldOpen: setUp ? tryOr(null, () => {
174666
+ const open6 = unfinishedShield(store);
174667
+ return open6 ? { amount: usdcWords(open6.amountAtomic) } : null;
174668
+ }) : null,
174510
174669
  addingFunds: setUp ? tryOr(null, () => addingFundsOf(parts, store)) : null,
174511
174670
  addingFundsNote: setUp ? tryOr(null, () => addingFundsNoteOf(store, nowMs)) : null,
174512
174671
  movingOut: setUp ? tryOr(null, () => movingOutOf(parts)) : null,
@@ -174594,7 +174753,7 @@ function hintForThisRun(text3, values) {
174594
174753
  if (service) hint = hint.split(GUIDE.facilitator).join(service);
174595
174754
  return hint;
174596
174755
  }
174597
- var REFUSED_ON_RETIRED_POOL = /* @__PURE__ */ new Set(["init", "add-funds", "deposit"]);
174756
+ var REFUSED_ON_RETIRED_POOL = /* @__PURE__ */ new Set(["init", "add-funds", "deposit", "shield"]);
174598
174757
  function retiredPoolGuard(command, values, io, npmVersion) {
174599
174758
  const fromWallet = /([1-9A-HJ-NP-Za-km-z]{32,44})[\\/]wallet\.json$/.exec(String(values.get("--wallet") ?? ""))?.[1];
174600
174759
  const pool2 = [values.get("--pool"), fromWallet].find((value2) => typeof value2 === "string" && RETIRED_POOLS[value2]);
@@ -174634,6 +174793,12 @@ async function walletHolderRole(walletFile) {
174634
174793
  return void 0;
174635
174794
  }
174636
174795
  }
174796
+ var HomeJobFailure = class extends PublicFailure {
174797
+ constructor(code2, plain) {
174798
+ super(`${code2}: ${plain}`);
174799
+ this.plain = plain;
174800
+ }
174801
+ };
174637
174802
  var AnswerDeclined = class extends PublicFailure {
174638
174803
  constructor(code2, plain) {
174639
174804
  super(`${code2}: ${plain}`);
@@ -174693,6 +174858,7 @@ var payerSessionFlags = () => [
174693
174858
  flag2("--memo-service", "<url>", "server that serves the encrypted memos (its origin is also the default RPC relay)", { required: true }),
174694
174859
  HISTORY_RPC_FLAG
174695
174860
  ];
174861
+ var SHIELD_PRIVACY_WORDS = "Privacy: the chain shows your own address putting this amount into the private pool, and the wallet that sent the USDC to your own address stays linked to it on the chain. Later payments from your private balance do not show this wallet.";
174696
174862
  var BALANCE_NEXT_SET_UP = `back up the wallet (${CLI_WORD} help backup-export); ${CLI_WORD} balance shows the private balance`;
174697
174863
  var BALANCE_NEXT = `${BALANCE_NEXT_SET_UP} (a wallet you name by flags, not set up: ${CLI_WORD} help balance)`;
174698
174864
  var SPEND_WALLET_FOLLOWED = /* @__PURE__ */ Symbol("spend wallet followed");
@@ -175612,6 +175778,26 @@ function questionEnds(text3, last) {
175612
175778
  const shown = part.join(" ").slice(0, 60);
175613
175779
  return words2.length > 6 ? last ? `...${shown}` : `${shown}...` : shown;
175614
175780
  }
175781
+ function typedLineWatch(input, output2) {
175782
+ const marks = armPasteMarks({ input, output: output2 });
175783
+ const clock2 = quickEnterClock();
175784
+ let pasted = false;
175785
+ let bareEnter = false;
175786
+ const onData = (data) => {
175787
+ const text3 = typeof data === "string" ? data : Buffer.from(data).toString("utf8");
175788
+ const quick = clock2.see(text3);
175789
+ bareEnter = /^(?:\r\n|\r|\n)$/.test(text3) && !quick && !marks.pasting();
175790
+ if (marks.pasting() || text3.includes("\x1B[200~") || quick || /[\r\n]/.test(text3) && !bareEnter) pasted = true;
175791
+ };
175792
+ input.prependListener("data", onData);
175793
+ return {
175794
+ typed: (rl) => bareEnter && !pasted && !marks.pasting() && !rl.line,
175795
+ off: () => {
175796
+ input.removeListener("data", onData);
175797
+ marks.off();
175798
+ }
175799
+ };
175800
+ }
175615
175801
  async function readTypedQuestion({ input = process.stdin, output: output2 = process.stderr } = {}) {
175616
175802
  output2.write("Type or paste your question, then press Enter on an empty line. Ctrl+C stops, and nothing is paid.\n");
175617
175803
  const rl = createInterface2({ input, output: output2, terminal: true, crlfDelay: Infinity, historySize: 0 });
@@ -176512,6 +176698,67 @@ async function runInferStart(values, deps) {
176512
176698
  ""
176513
176699
  ].join("\n"));
176514
176700
  }
176701
+ async function homeStartLocalAi(walletFile, status, walletMaxPaymentAtomic, deps) {
176702
+ const io = deps.io;
176703
+ const appWords = 'If you use an AI app, you can also ask it: "Give my other AI app a private AI address."';
176704
+ if (!(deps.stdinIsTTY() && deps.stdoutIsTTY?.() === true)) {
176705
+ io.out(`No private AI address is running now. ${appWords} Then press i again to see its key.
176706
+ `);
176707
+ return void 0;
176708
+ }
176709
+ const torChosen = deps.env[HOME_TOR_CHOICE_ENV] === "1";
176710
+ io.out([
176711
+ "No private AI address is running now.",
176712
+ "It lets another app on this computer use the private AI: each answer is paid from your private balance, through Tor.",
176713
+ ...torChosen ? [] : ["This wallet runs without Tor now. A private AI address runs only through Tor (so the AI provider does not see your IP address): starting it starts Tor for the private AI address alone; the rest of the wallet stays without Tor."],
176714
+ `Caps when it starts: ${localAiCapsText(status.caps, status.limits)}.`
176715
+ ].join("\n") + "\n");
176716
+ if (!await typedYes("Start a private AI address on this computer now, through Tor? [y/N] ", deps, io)) {
176717
+ io.out(`Nothing was started. ${appWords}
176718
+ `);
176719
+ return void 0;
176720
+ }
176721
+ io.out("Starting your private AI address: it connects through Tor and opens your wallet first...\n");
176722
+ const env = { ...deps.env };
176723
+ delete env[NO_TOR_RUN_ENV];
176724
+ delete env[HOME_TOR_CHOICE_ENV];
176725
+ const answer = await (deps.startLocalAiServer ?? startLocalAiServer)({
176726
+ walletPath: walletFile,
176727
+ env,
176728
+ npmVersion: deps.walletVersion().npm,
176729
+ ...walletMaxPaymentAtomic !== void 0 ? { walletMaxPaymentAtomic } : {}
176730
+ });
176731
+ if (answer.state === "failed") {
176732
+ throw new HomeJobFailure("inference_server_not_started", `Your private AI address did not start: ${answer.detail}. Nothing was paid. Press i to try again.`);
176733
+ }
176734
+ return (deps.localAiServerStatus ?? localAiServerStatus)({ walletPath: walletFile, ...walletMaxPaymentAtomic !== void 0 ? { walletMaxPaymentAtomic } : {} });
176735
+ }
176736
+ async function homeStopLocalAi(walletFile, deps) {
176737
+ const io = deps.io;
176738
+ if (!(deps.stdinIsTTY() && deps.stdoutIsTTY?.() === true)) return;
176739
+ let yes2;
176740
+ try {
176741
+ yes2 = await typedYes("Stop the private AI address now? [y/N] ", deps, io);
176742
+ } catch (error) {
176743
+ if (!(error instanceof QuestionCancelled)) throw error;
176744
+ throw new HomeJobFailure("inference_server_stop_cancelled", "The stop was cancelled: your private AI address still runs. Press i to stop it.");
176745
+ }
176746
+ if (!yes2) return;
176747
+ const result = await (deps.stopLocalAiServer ?? stopLocalAiServer)({ walletPath: walletFile });
176748
+ if (!result.stopped) {
176749
+ if (result.running === false) {
176750
+ io.out("Your private AI address had already stopped. Press i to start it again.\n");
176751
+ return;
176752
+ }
176753
+ throw new HomeJobFailure("inference_server_stop_failed", `Your private AI address did not stop: ${result.detail}. It still runs. Press i to try again.`);
176754
+ }
176755
+ io.out([
176756
+ `Your private AI address stopped${result.forced ? `: ${result.detail}` : ""}.`,
176757
+ ...result.spentAtomic !== void 0 ? [`It paid ${usdcOr(result.spentAtomic)} for ${requestsWords(result.requests)}.`] : [],
176758
+ "Your agent app keeps base_url and the api key; press i to start it again with the same key.",
176759
+ ""
176760
+ ].join("\n"));
176761
+ }
176515
176762
  async function runInferStatus(values, deps) {
176516
176763
  const io = deps.io;
176517
176764
  const walletFile = localAiWalletOf(values);
@@ -176524,7 +176771,7 @@ async function runInferStatus(values, deps) {
176524
176771
  }
176525
176772
  const walletMaxPaymentAtomic = walletState?.config?.maxPaymentAtomic;
176526
176773
  const walletShort = walletState ? walletShortAddress(walletState) : void 0;
176527
- const status = await (deps.localAiServerStatus ?? localAiServerStatus)({
176774
+ let status = await (deps.localAiServerStatus ?? localAiServerStatus)({
176528
176775
  walletPath: walletFile,
176529
176776
  ...walletMaxPaymentAtomic !== void 0 ? { walletMaxPaymentAtomic } : {}
176530
176777
  });
@@ -176535,11 +176782,18 @@ async function runInferStatus(values, deps) {
176535
176782
  }
176536
176783
  const verbose = values.has("--verbose");
176537
176784
  const lines = [];
176538
- if (inHomeJob(deps.env) && status.state !== "listening") {
176539
- io.out(status.state === "starting" ? "Your private AI address is starting: it connects through Tor and opens your wallet first. Press i again in a few seconds to see its key.\n" : 'No private AI address is running now. To start one, ask your AI app: "Give my other AI app a private AI address." Then press i again to see its key.\n');
176540
- return;
176541
- }
176542
176785
  if (inHomeJob(deps.env)) {
176786
+ if (status.state === "stopped") {
176787
+ status = await homeStartLocalAi(walletFile, status, walletMaxPaymentAtomic, deps);
176788
+ if (!status) return;
176789
+ if (status.state === "stopped") {
176790
+ throw new HomeJobFailure("inference_server_not_started", `Your private AI address stopped right after its start${status.last?.state === "failed" && status.last.detail ? `: ${status.last.detail}` : ""}. Nothing was paid. Press i to try again.`);
176791
+ }
176792
+ }
176793
+ if (status.state === "starting") {
176794
+ io.out("Your private AI address is starting: it connects through Tor and opens your wallet first. Press i again in a few seconds to see its key.\n");
176795
+ return;
176796
+ }
176543
176797
  if (!walletShort) {
176544
176798
  io.out("This screen could not read which wallet it opened, so it shows no key. Ask your AI app again for the private AI address; it names the steps.\n");
176545
176799
  return;
@@ -176550,9 +176804,11 @@ async function runInferStatus(values, deps) {
176550
176804
  ...localAiPasteLines(status),
176551
176805
  `Caps: ${localAiCapsText(status.caps, status.limits)}. Paid so far: ${usdcOr(status.spentAtomic ?? "0")} for ${requestsWords(status.requests)}.`,
176552
176806
  ...await localAiFloorRaiseLines(status.caps, deps),
176553
- "It stops when the computer restarts; then ask your AI app again for a private AI address (the api key stays the same). To stop it now, ask your AI app to stop the private AI address."
176807
+ "It stops when the computer restarts; then press i to start it again (the api key stays the same).",
176808
+ "If you use an AI app, you can also ask it to stop the private AI address."
176554
176809
  ].join("\n")}
176555
176810
  `);
176811
+ await homeStopLocalAi(walletFile, deps);
176556
176812
  return;
176557
176813
  }
176558
176814
  if (walletShort) lines.push(`Wallet ${walletShort}.`);
@@ -176950,6 +177206,7 @@ function offlineTorRefusal(argv2) {
176950
177206
  return `${name} reads only files on this computer and never goes online, so it takes no --tor or --proxy. Nothing was sent. Run it again without ${argv2.includes("--tor") ? "--tor" : "--proxy"}`;
176951
177207
  }
176952
177208
  var NO_TOR_RUN_ENV = "SHINJUKU_WALLET_NO_TOR";
177209
+ var HOME_TOR_CHOICE_ENV = "SHINJUKU_WALLET_HOME_TOR";
176953
177210
  function homeJobTor(argv2, env) {
176954
177211
  if (runNetworkMode() !== null) return true;
176955
177212
  let job;
@@ -179144,12 +179401,9 @@ async function runSetupCommandHeld(values, deps) {
179144
179401
  // S2 (a live check on the published 0.3.99): the help's words (shortHelpText), not "x402 URLs".
179145
179402
  "Shinjuku Shield: your private wallet on this computer. It pays for AI answers and paid web services from your private balance.",
179146
179403
  readsBack ? "Setup keeps the restored wallet on this machine (your keys never leave it), downloads and checks the setup files, and writes config.json." : repairRun ? "Setup keeps your wallet on this machine as it is (your keys never leave it), downloads and checks the setup files, and writes config.json again." : "Setup makes the wallet on this machine (your keys never leave it), downloads and checks the setup files, and writes config.json.",
179147
- // 0.3.97 T4, live proof 2026-10-24: the command on its own line.
179148
- "An agent app then starts it with this command:",
179149
- // Row 25 rerun on 0.3.174 (check C): the line a user may copy into an app setup cannot add has the app entry's
179150
- // --prefix (npm reads no .npmrc of the folder the app starts in); a Windows home with a cmd sign, $ or ` gets none, as
179151
- // the entry. Quoted for the user's shell (hostShellWord: single quotes on POSIX; Codex round 1 on 1b3aaa99 item 2).
179152
- ` ${oneTimeCommandLine("mcp", npmVersion, { appLine: true, npmArgs: npmPrefixArgs(home, deps.platform ?? process.platform).map((word2) => hostShellWord(word2, deps.platform ?? process.platform)) })}`,
179404
+ // The agent app's start line is not shown here (a terminal run on npm 0.3.240: an internal line to a person who never
179405
+ // pastes it): setup writes it into each app it adds, and home [c] "another app" shows it with the app entry's
179406
+ // --prefix (row 25 rerun on 0.3.174, check C) where a person must paste it.
179153
179407
  ""
179154
179408
  ],
179155
179409
  // The status line too, when a terminal setup started this run and printed it (AB234's live run 2026-11-04 showed
@@ -179700,6 +179954,25 @@ var COMMANDS = [
179700
179954
  },
179701
179955
  run: (args, values, deps, io) => deps.fundsMain("funds-status", values, { ...deps, io })
179702
179956
  },
179957
+ {
179958
+ name: "shield",
179959
+ summary: "Make the USDC on your wallet's own public address private. Shinjuku pays every network fee, so the address needs no SOL.",
179960
+ env: [],
179961
+ flags: [
179962
+ flag2("--amount", "<usdc|all>", "how much to make private (from 0.01 USDC); all, or no --amount in a terminal, takes all the USDC on the own address"),
179963
+ // The tool's own session (runShield reads its proof files, program, memo service and RPC): config.json gives them.
179964
+ ...payerSessionFlags().map((spec) => spec.name === "--proof-tools" ? { ...spec, required: true, about: "the public proof-tools manifest that proves the deposit (setup saves it, and config.json names it)" } : spec)
179965
+ ],
179966
+ examples: [`${CLI_WORD} shield`, `${CLI_WORD} shield --amount 0.5`],
179967
+ notes: [
179968
+ "The same deposit as the agent app's shield: the wallet's key signs only an approval of the amount, and Shinjuku submits the deposit and pays every network fee and rent.",
179969
+ SHIELD_PRIVACY_WORDS,
179970
+ "A shield that stopped (Ctrl+C, a closed window) continues when you run shield again: the same deposit never goes in twice."
179971
+ ],
179972
+ next: `see the private balance: ${CLI_WORD} balance`,
179973
+ validate: (values, env) => validatePayerSession("shield", values, env),
179974
+ run: (args, values, deps, io) => runShieldCommand(values, deps, io)
179975
+ },
179703
179976
  {
179704
179977
  name: "deposit",
179705
179978
  summary: "Move your own USDC into the shielded pool.",
@@ -182745,8 +183018,197 @@ function ownPublicLine(publicAtomic) {
182745
183018
  if (!/^[1-9][0-9]{0,30}$/.test(String(publicAtomic ?? ""))) return void 0;
182746
183019
  const head = `${usdcOr(publicAtomic)} is on this wallet's own public address and is not private yet.`;
182747
183020
  if (BigInt(publicAtomic) < SHIELD_MIN_ATOMIC2) return `${head} It is below the ${usdcOr(SHIELD_MIN_ATOMIC2)} least that can be made private.`;
182748
- const ask = 'ask your agent app that runs this wallet: "make my public USDC private".';
182749
- return `${head} To make it private, ${ask}`;
183021
+ return `${head} To make it private, run: ${cli4()} shield`;
183022
+ }
183023
+ async function ownAddressUsdc(session, store) {
183024
+ const owner = walletOwnAddress(store);
183025
+ if (!owner) throw new PublicFailure("wallet_unreadable: this wallet's own address could not be read; nothing was moved");
183026
+ const account = getAssociatedTokenAddressSync(new import_web3139.PublicKey(store.state.asset), owner, false, TOKEN_PROGRAM_ID);
183027
+ return onOwnTorTag(async () => {
183028
+ try {
183029
+ return (await getAccount(session.connection, account, "finalized", TOKEN_PROGRAM_ID)).amount.toString();
183030
+ } catch (error) {
183031
+ if (error instanceof TokenAccountNotFoundError) return "0";
183032
+ throw error;
183033
+ }
183034
+ });
183035
+ }
183036
+ var SHIELD_STAGE_WORDS = {
183037
+ proving: "Preparing the private proof of the deposit (this can take a minute or two)...",
183038
+ submitting: "Shinjuku submits the deposit and pays every network fee...",
183039
+ sending: "Sending the deposit..."
183040
+ };
183041
+ async function confirmShield(question, deps, io, declined) {
183042
+ if (!await typedYes(question, deps, io)) throw new AnswerDeclined("shield_declined", declined);
183043
+ }
183044
+ async function typedYes(question, deps, io) {
183045
+ for (let attempt = 0; attempt < 3; attempt += 1) {
183046
+ const reply = await deps.ask(question, { typedOnly: true });
183047
+ const { answer, typed } = reply !== null && typeof reply === "object" ? reply : { answer: reply, typed: false };
183048
+ const yes2 = /^y(es)?$/i.test(String(answer ?? "").trim());
183049
+ if (yes2 && typed === true) return true;
183050
+ if (!yes2) return false;
183051
+ io.err("That y came in pasted text, or too fast after it, so it does not count. Type y yourself and press Enter, or press Enter to stop.\n");
183052
+ }
183053
+ return false;
183054
+ }
183055
+ async function runShieldCommand(values, deps, io) {
183056
+ const terminal = deps.stdinIsTTY() && deps.stdoutIsTTY?.() === true;
183057
+ const home = inHomeJob(deps.env);
183058
+ const again = home ? "press m again" : `run ${cli4()} shield again`;
183059
+ const typedAmount = values.get("--amount");
183060
+ if (!terminal && typedAmount === void 0) {
183061
+ throw new UsageError("shield needs --amount <usdc|all> when it runs without a terminal (in a terminal, shield asks)", COMMAND_BY_NAME.get("shield"));
183062
+ }
183063
+ if (typedAmount !== void 0 && !/^all$/i.test(typedAmount) && usdcToAtomic(typedAmount) === void 0) {
183064
+ throw new UsageError("--amount takes an amount of USDC like 0.5, or all", COMMAND_BY_NAME.get("shield"));
183065
+ }
183066
+ const session = await (deps.openPayerSession ?? openPayerSession)(payerSessionOptions(values, deps));
183067
+ let amountAtomic;
183068
+ let result;
183069
+ let earlier = false;
183070
+ let store;
183071
+ try {
183072
+ assertSessionPool(values, session.pool);
183073
+ store = session.openStore();
183074
+ const pending = pendingShield(store);
183075
+ if (pending?.deposit?.resolved) {
183076
+ ({ amountAtomic } = pending);
183077
+ result = { state: pending.deposit.state, transaction: pending.deposit.transaction };
183078
+ earlier = true;
183079
+ io.err(`Your earlier shield of ${usdcOr(amountAtomic)} finished before this run ended; no new deposit starts now.
183080
+ `);
183081
+ } else {
183082
+ if (pending && !pending.deposit) removePendingShield(store);
183083
+ const open6 = pending?.deposit ? pending : openOwnShield(store);
183084
+ let depositId;
183085
+ if (open6) {
183086
+ ({ depositId, amountAtomic } = open6);
183087
+ if (typedAmount !== void 0 && (/^all$/i.test(typedAmount) || BigInt(usdcToAtomic(typedAmount)) !== BigInt(amountAtomic))) {
183088
+ throw new PublicFailure(`shield_open_other_amount: an earlier shield of ${usdcOr(amountAtomic)} did not finish, and it finishes first (the same USDC never goes in twice). Nothing new was moved. To finish it, ${home ? "press m again" : `run ${cli4()} shield --amount ${usdcText4(amountAtomic)}`}`);
183089
+ }
183090
+ io.err(`Your earlier shield of ${usdcOr(amountAtomic)} did not finish.
183091
+ `);
183092
+ if (terminal) {
183093
+ io.err(`${SHIELD_PRIVACY_WORDS}
183094
+ `);
183095
+ await confirmShield(
183096
+ `Finish making ${usdcOr(amountAtomic)} private? Shinjuku pays the network fees. [y/N] `,
183097
+ deps,
183098
+ io,
183099
+ `you did not type y, so nothing new was moved; the earlier shield of ${usdcOr(amountAtomic)} stays open. To finish it, ${again}`
183100
+ );
183101
+ }
183102
+ } else {
183103
+ io.err("Reading the USDC on your own address...\n");
183104
+ const held2 = await ownAddressUsdc(session, store);
183105
+ try {
183106
+ savePublicRead(store, held2, deps.now());
183107
+ } catch {
183108
+ }
183109
+ if (BigInt(held2) < SHIELD_MIN_ATOMIC2) {
183110
+ if (home) {
183111
+ io.out(BigInt(held2) === 0n ? "Your own address holds 0 USDC, so nothing waits there to be made private. Nothing was moved.\n" : `Your own address holds ${usdcOr(held2)}; the least that can be made private is ${usdcOr(SHIELD_MIN_ATOMIC2)}. Nothing was moved.
183112
+ `);
183113
+ return;
183114
+ }
183115
+ throw new PublicFailure(`nothing_to_shield: your own address holds ${usdcOr(held2)}, and the least that can be made private is ${usdcOr(SHIELD_MIN_ATOMIC2)}. Nothing was moved`);
183116
+ }
183117
+ if (typedAmount !== void 0) {
183118
+ amountAtomic = /^all$/i.test(typedAmount) ? held2 : usdcToAtomic(typedAmount);
183119
+ } else {
183120
+ for (let attempt = 0; attempt < 3 && amountAtomic === void 0; attempt += 1) {
183121
+ const text3 = String(await deps.ask(`How much USDC do you want to make private? (Enter = all ${usdcOr(held2)}): `)).trim();
183122
+ amountAtomic = !text3 || /^all$/i.test(text3) ? held2 : usdcToAtomic(text3);
183123
+ if (amountAtomic === void 0) io.err("Type an amount of USDC like 0.5, or press Enter for all of it.\n");
183124
+ }
183125
+ if (amountAtomic === void 0) throw new AnswerDeclined("shield_declined", `three answers were not usable, so nothing was moved. To make it private, ${again}`);
183126
+ }
183127
+ if (BigInt(amountAtomic) < SHIELD_MIN_ATOMIC2) {
183128
+ throw new PublicFailure(`shield_amount_too_small: the least that can be made private is ${usdcOr(SHIELD_MIN_ATOMIC2)}. Nothing was moved`);
183129
+ }
183130
+ if (BigInt(amountAtomic) > BigInt(held2)) {
183131
+ throw new PublicFailure(`shield_amount_too_large: your own address holds ${usdcOr(held2)}, less than ${usdcOr(amountAtomic)}. Nothing was moved`);
183132
+ }
183133
+ io.err(`${SHIELD_PRIVACY_WORDS}
183134
+ `);
183135
+ if (terminal) {
183136
+ await confirmShield(
183137
+ `Make ${usdcOr(amountAtomic)} private? Shinjuku pays the network fees. [y/N] `,
183138
+ deps,
183139
+ io,
183140
+ `you did not type y, so nothing was moved. To make it private, ${again}`
183141
+ );
183142
+ }
183143
+ depositId = `shield-${randomBytes48(8).toString("hex")}`;
183144
+ }
183145
+ writePendingShield(store, depositId, amountAtomic, new Date(deps.now()).toISOString());
183146
+ try {
183147
+ result = await runShield({ session, depositId, amountAtomic, onStage: (stage) => {
183148
+ if (SHIELD_STAGE_WORDS[stage]) io.err(`${SHIELD_STAGE_WORDS[stage]}
183149
+ `);
183150
+ } });
183151
+ } catch (error) {
183152
+ throw shieldRefusal(error, again);
183153
+ }
183154
+ }
183155
+ if (["published", "foreign_funded"].includes(result?.state)) {
183156
+ try {
183157
+ savePublicRead(store, await ownAddressUsdc(session, store), deps.now());
183158
+ } catch {
183159
+ try {
183160
+ clearPublicRead(store);
183161
+ } catch {
183162
+ }
183163
+ }
183164
+ }
183165
+ } finally {
183166
+ await session.close();
183167
+ }
183168
+ if (!["published", "foreign_funded"].includes(result?.state)) {
183169
+ io.out(`The deposit of ${usdcOr(amountAtomic)} is sent but not finished yet${result?.transaction ? ` (transaction ${result.transaction})` : ""}. To finish it, ${again}: it continues it and never puts the USDC in twice.
183170
+ `);
183171
+ return;
183172
+ }
183173
+ io.out(`${usdcOr(amountAtomic)} is private now${result.transaction ? ` (transaction ${result.transaction})` : ""}.
183174
+ `);
183175
+ const read2 = await readBalanceFromChain(store, values, deps, "Reading your private balance from the chain...\n");
183176
+ if (read2 !== "read") io.out(`The wallet reads the new private balance at its next balance read (${home ? "this screen shows it soon" : `${cli4()} balance`}).
183177
+ `);
183178
+ let release;
183179
+ try {
183180
+ const walletPath2 = commandWalletPath(values, deps);
183181
+ release = await acquireWalletProcessLease(walletLockPath(walletPath2));
183182
+ const passphrase2 = payerPassphrase(values, deps);
183183
+ writeAutoBackup({ walletPath: walletPath2, pool: store.state.pool, exportBundle: (destination) => exportWalletRecoveryBundle(walletPath2, passphrase2, destination) });
183184
+ io.out("An encrypted backup of the wallet was saved.\n");
183185
+ } catch {
183186
+ io.out("The automatic encrypted backup was not saved this time. The deposit is done; your recovery file still opens the wallet.\n");
183187
+ } finally {
183188
+ await release?.();
183189
+ }
183190
+ removePendingShield(commandStore(values, deps) ?? store);
183191
+ if (earlier) io.out("Run shield again to make more USDC private.\n".replace("Run shield again", home ? "Press m again" : `Run ${cli4()} shield again`));
183192
+ }
183193
+ function shieldRefusal(error, again) {
183194
+ const text3 = String(error?.message ?? "");
183195
+ if (/relay_amount_below_facilitator_minimum/.test(text3)) {
183196
+ const least = /^[1-9][0-9]*$/.test(String(error?.minimumAtomic ?? "")) ? usdcOr(error.minimumAtomic) : void 0;
183197
+ return new PublicFailure(`shield_amount_too_small: ${least ? `one deposit must be at least ${least}` : "the amount is below the least Shinjuku makes private in one deposit"}. Nothing was moved`);
183198
+ }
183199
+ if (/another_deposit_unresolved/.test(text3)) {
183200
+ return new PublicFailure("another_deposit_open: another deposit of this wallet is not finished (an add-funds address, or a shield). Finish that one first; nothing new was moved");
183201
+ }
183202
+ if (/wallet_process_locked|wallet_locked/.test(text3)) {
183203
+ return new PublicFailure(`wallet_locked: another Shinjuku program uses this wallet now (an agent app or another window). Nothing new was moved; ${again} in a minute`);
183204
+ }
183205
+ if (/insufficient_token_balance|own_key_usdc_not_finalized/.test(text3)) {
183206
+ return new PublicFailure(`own_address_short: your own address does not hold that much final USDC yet. Nothing was moved; ${again} in a minute`);
183207
+ }
183208
+ if (/facilitator_underfunded/.test(text3)) {
183209
+ return new PublicFailure("relay_unavailable: Shinjuku cannot pay network fees right now. Nothing was spent; try again later");
183210
+ }
183211
+ return error;
182750
183212
  }
182751
183213
  async function runBalance(args, values, deps, io) {
182752
183214
  const mark = balanceMarks(values, deps);
@@ -183791,6 +184253,39 @@ function startHomeBalanceRead(argv2, env) {
183791
184253
  child.once("exit", (code2) => done(code2 ?? 1));
183792
184254
  });
183793
184255
  }
184256
+ var HOME_FACTS_REREAD_MS = 5e3;
184257
+ function homeFactsWatch(data, balanceRead, readData) {
184258
+ let current = data;
184259
+ const watch = (draw) => {
184260
+ const show = (next) => {
184261
+ current = next;
184262
+ draw(next);
184263
+ };
184264
+ const stopRead = balanceRead?.watch(show);
184265
+ let last = JSON.stringify(data);
184266
+ const timer = setInterval(() => {
184267
+ const reading2 = balanceRead?.data().balanceRead;
184268
+ if (reading2 === "reading" || reading2 === "slow") return;
184269
+ let next;
184270
+ try {
184271
+ next = readData();
184272
+ } catch {
184273
+ return;
184274
+ }
184275
+ if (balanceRead && (next?.balance === null || next?.balance === void 0)) next = { ...next, balanceRead: reading2 };
184276
+ const text3 = JSON.stringify(next);
184277
+ if (text3 === last) return;
184278
+ last = text3;
184279
+ show(next);
184280
+ }, HOME_FACTS_REREAD_MS);
184281
+ timer.unref?.();
184282
+ return () => {
184283
+ clearInterval(timer);
184284
+ stopRead?.();
184285
+ };
184286
+ };
184287
+ return { watch, current: () => current };
184288
+ }
183794
184289
  function homeBalanceRead(data, argv2, deps, readData) {
183795
184290
  if (data?.setUp !== true || data.balance !== null || data.walletIssue || data.restoreUnread || data.setupFilesMissing) return void 0;
183796
184291
  const ended2 = deps.homeBalanceRead(argv2, deps.env);
@@ -183945,9 +184440,10 @@ function defaultDependencies() {
183945
184440
  * at a question paused stdin with no answer, Node then printed "Detected unsettled top-level await" and nothing said
183946
184441
  * what happened. Ctrl-C, or an input that ends, now stops the command with QuestionCancelled (one plain line).
183947
184442
  */
183948
- ask: (question) => new Promise((resolveAnswer, rejectAnswer) => {
184443
+ ask: (question, { typedOnly = false } = {}) => new Promise((resolveAnswer, rejectAnswer) => {
183949
184444
  const releaseProgress = holdProgressLines(process.stderr);
183950
- const prompt = createInterface2({ input: process.stdin, output: process.stderr, terminal: true });
184445
+ const prompt = createInterface2({ input: process.stdin, output: process.stderr, terminal: true, ...typedOnly ? { historySize: 0 } : {} });
184446
+ const watch = typedOnly ? typedLineWatch(process.stdin, process.stderr) : void 0;
183951
184447
  let answered2 = false;
183952
184448
  let interrupted = false;
183953
184449
  prompt.on("SIGINT", () => {
@@ -183957,12 +184453,14 @@ function defaultDependencies() {
183957
184453
  });
183958
184454
  prompt.on("close", () => {
183959
184455
  releaseProgress();
184456
+ watch?.off();
183960
184457
  if (!answered2) rejectAnswer(new QuestionCancelled(interrupted));
183961
184458
  });
183962
184459
  prompt.question(question, (answer) => {
183963
184460
  answered2 = true;
184461
+ const typed = watch ? watch.typed(prompt) : void 0;
183964
184462
  prompt.close();
183965
- resolveAnswer(answer);
184463
+ resolveAnswer(watch ? { answer, typed } : answer);
183966
184464
  });
183967
184465
  }),
183968
184466
  /** claude with no output on the terminal (setup's probe of an old entry, and its remove); the exit status. */
@@ -184135,7 +184633,7 @@ ${places.map((place, index) => ` ${index + 1} ${place.label}`).join("\n")}
184135
184633
  const answer = String(await deps.ask("Type a number or a folder, or press Enter to stop (plug in a USB drive first to see it): ")).trim();
184136
184634
  if (!answer) {
184137
184635
  io.err("No backup was saved.\n");
184138
- return 0;
184636
+ return { code: 0, ended: "no backup was saved" };
184139
184637
  }
184140
184638
  const chosen = /^\d+$/.test(answer) ? places[Number(answer) - 1] : { path: answer, removable: void 0 };
184141
184639
  if (!chosen) {
@@ -184157,6 +184655,7 @@ Keep it offline and private: with it, anyone can spend your money.
184157
184655
  var HOME_JOB_TITLES = {
184158
184656
  t: "private AI chat",
184159
184657
  i: "private AI address",
184658
+ m: "make public USDC private",
184160
184659
  a: "add funds",
184161
184660
  u: "send money out",
184162
184661
  p: "pay a link",
@@ -184171,6 +184670,7 @@ var COMMAND_TITLES = {
184171
184670
  setup: "set up the wallet",
184172
184671
  balance: "private balance",
184173
184672
  "add-funds": "add funds",
184673
+ shield: "make public USDC private",
184174
184674
  unshield: "send money out",
184175
184675
  curl: "pay a link",
184176
184676
  pay: "pay",
@@ -184232,10 +184732,11 @@ async function homeKeyJob(key, { data, argv: argv2, deps }) {
184232
184732
  return await child(["chat"]);
184233
184733
  }
184234
184734
  if (key === "s") return await child(["setup"]);
184735
+ if (key === "m") return await child(["shield"]);
184235
184736
  if (key === "a") return await child(["add-funds"]);
184236
184737
  if (key === "u") return await child(["unshield"]);
184237
184738
  if (key === "l") return await deps.runHomeChild(["limits"], { ...deps.env, [NO_TOR_RUN_ENV]: "1" });
184238
- if (key === "i") return await deps.runHomeChild(["infer", "status"], { ...deps.env, [NO_TOR_RUN_ENV]: "1" });
184739
+ if (key === "i") return await deps.runHomeChild(["infer", "status"], { ...deps.env, [NO_TOR_RUN_ENV]: "1", [HOME_TOR_CHOICE_ENV]: data?.tor === true ? "1" : "0" });
184239
184740
  if (key === "o") return await deps.homeTorToggle(data, deps);
184240
184741
  if (key === "b") return await deps.homeBackup(data, deps);
184241
184742
  if (key === "r") {
@@ -184243,27 +184744,43 @@ async function homeKeyJob(key, { data, argv: argv2, deps }) {
184243
184744
  return file ? await child(["restore", "--recovery", file]) : 0;
184244
184745
  }
184245
184746
  if (key === "p") {
184246
- const link3 = String(await deps.ask("Paste the link to pay: ")).trim();
184747
+ io.err("Paste the full link of a paid web service, such as https://example.com/api/report (you see its price before anything is paid).\n");
184748
+ const link3 = String(await deps.ask("Link to pay (Enter alone = back): ")).trim();
184247
184749
  if (!link3) {
184248
184750
  io.err("No link given, so nothing was paid.\n");
184249
- return 0;
184751
+ return { code: 0, ended: "nothing was paid" };
184250
184752
  }
184251
184753
  return await child(["curl", "--url", link3]);
184252
184754
  }
184253
184755
  if (key !== "c") return 0;
184254
184756
  const hostNames = HOST_NAMES;
184757
+ const other = HOST_TARGETS.length + 1;
184255
184758
  io.err(`Which agent app gets the wallet?
184256
184759
  ${HOST_TARGETS.map((host, index) => ` ${index + 1} ${hostNames[host] ?? host}`).join("\n")}
184760
+ ${other} another app (not in this list)
184257
184761
  `);
184258
184762
  for (; ; ) {
184259
- const answer = String(await deps.ask(`Type its number (1 to ${HOST_TARGETS.length}), or press Enter to stop: `)).trim();
184763
+ const answer = String(await deps.ask(`Type its number (1 to ${other}), or press Enter to stop: `)).trim();
184260
184764
  if (!answer) {
184261
184765
  io.err("No agent app chosen, so nothing was changed.\n");
184766
+ return { code: 0, ended: "nothing was changed" };
184767
+ }
184768
+ if (answer === String(other)) {
184769
+ const platform = deps.platform ?? process.platform;
184770
+ io.out([
184771
+ `In your app's settings, add a new tool server (an app may call it an MCP server, type "command" or "stdio") that runs this command:`,
184772
+ ` ${oneTimeCommandLine("mcp", deps.walletVersion().npm, {
184773
+ appLine: true,
184774
+ npmArgs: npmPrefixArgs(setupHome(deps.env), platform).map((word2) => hostShellWord(word2, platform))
184775
+ })}`,
184776
+ 'Then restart the app and ask it "what is my balance".',
184777
+ ""
184778
+ ].join("\n"));
184262
184779
  return 0;
184263
184780
  }
184264
184781
  const host = /^[0-9]+$/.test(answer) ? HOST_TARGETS[Number(answer) - 1] : void 0;
184265
184782
  if (!host) {
184266
- io.err(`Type a number from 1 to ${HOST_TARGETS.length}.
184783
+ io.err(`Type a number from 1 to ${other}.
184267
184784
  `);
184268
184785
  continue;
184269
184786
  }
@@ -184352,7 +184869,8 @@ async function runHomeLoop(argv2, deps, { animation = true } = {}) {
184352
184869
  for (; ; ) {
184353
184870
  const data = readData();
184354
184871
  const balanceRead = homeBalanceRead(data, argv2, deps, readData);
184355
- const screen = await deps.homeScreen(balanceRead ? balanceRead.data() : data, deps.env, balanceRead?.watch, nextKey);
184872
+ const facts = homeFactsWatch(balanceRead ? balanceRead.data() : data, balanceRead, readData);
184873
+ const screen = await deps.homeScreen(facts.current(), deps.env, facts.watch, nextKey);
184356
184874
  nextKey = void 0;
184357
184875
  if (screen.outcome === "interrupted") {
184358
184876
  clearAfterJobs();
@@ -184374,7 +184892,8 @@ async function runHomeLoop(argv2, deps, { animation = true } = {}) {
184374
184892
  }
184375
184893
  await balanceRead?.finish(io);
184376
184894
  ranJob = true;
184377
- const view2 = await deps.homeJobView(HOME_JOB_TITLES[screen.key] ?? "wallet", () => homeKeyJob(screen.key, { data, argv: argv2, deps }));
184895
+ const shown = facts.current();
184896
+ const view2 = await deps.homeJobView(HOME_JOB_TITLES[screen.key] ?? "wallet", () => homeKeyJob(screen.key, { data: shown, argv: argv2, deps }));
184378
184897
  if (view2.next === "quit") return view2.code === 130 ? 130 : 0;
184379
184898
  nextKey = view2.key;
184380
184899
  }
@@ -184665,7 +185184,7 @@ ${step}; or ask with a lower --max-tokens or another --model, which costs less.
184665
185184
  `);
184666
185185
  return 1;
184667
185186
  }
184668
- if (error instanceof WalletInUse || error instanceof SellerRefusal) {
185187
+ if (error instanceof WalletInUse || error instanceof SellerRefusal || error instanceof HomeJobFailure) {
184669
185188
  io.err(`${error.plain}
184670
185189
  `);
184671
185190
  return 1;