shinjuku-shield 0.3.239 → 0.3.240

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.240. 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.240 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.240, 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": "c3499a14d6d19dfc5ebdb191797c2e342d5221c731e7d45042375c8797f77122",
5
+ "bytes": 10585284,
6
+ "sourceCommit": "3347e1d553dc6de593533eebf37c31d183d3ebb6",
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-17T17:37:38.252Z"
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.240",
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": "c3499a14",
7
+ "shinjukuSha256": "c3499a14d6d19dfc5ebdb191797c2e342d5221c731e7d45042375c8797f77122",
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?.shieldOpen ? [["m", "finish making USDC private"]] : data?.publicUsdc?.step === "shield" ? [["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 = [];
@@ -163929,6 +164010,7 @@ var init_homeScreen = __esm({
163929
164010
  // 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
164011
  t: "talk with an AI, paid privately. it reads no news and no web.",
163931
164012
  i: "the address and key that give another app your private AI.",
164013
+ m: "make the USDC on your own address private. no SOL needed.",
163932
164014
  a: "get a one-time address, then send USDC on Solana to it.",
163933
164015
  u: "send money from your private balance to a Solana address.",
163934
164016
  p: "paste a link that asks for payment. it shows the price first.",
@@ -164055,7 +164137,7 @@ var init_homeScreen = __esm({
164055
164137
  randomKatakana = () => KATAKANA[Math.random() * KATAKANA.length | 0];
164056
164138
  MARK_TONES = { b: "brass", c: "crim", o: "crimdim" };
164057
164139
  PUBLIC_STEP = {
164058
- shield: 'ask your agent app: "make my public USDC private"',
164140
+ shield: "press m to make it private.",
164059
164141
  "below-least": "the least that can be made private is 0.01 USDC."
164060
164142
  };
164061
164143
  stackHeight = (blocks) => blocks.reduce((sum2, block) => sum2 + block.height, 0) + blocks.length - 1;
@@ -169618,6 +169700,75 @@ init_spendPolicy();
169618
169700
  init_usdcWords();
169619
169701
  init_stdioServer();
169620
169702
  init_tools();
169703
+ init_recoveryBundle();
169704
+
169705
+ // wallet/src/cli/terminalShield.mjs
169706
+ init_deposit();
169707
+ var SHIELD_PENDING = "terminal-shield-pending";
169708
+ var SHIELD_PENDING_SCHEMA = "shinjuku.terminal-shield-pending.v1";
169709
+ var ATOMIC15 = /^[1-9][0-9]{0,30}$/;
169710
+ var DEPOSIT_ID = /^[0-9a-zA-Z_.:-]{1,128}$/;
169711
+ function writePendingShield(store, depositId, amountAtomic, at) {
169712
+ store.writeWal(SHIELD_PENDING, { schema: SHIELD_PENDING_SCHEMA, depositId, amountAtomic: String(amountAtomic), startedAt: at });
169713
+ }
169714
+ function removePendingShield(store) {
169715
+ try {
169716
+ store.removeWal(SHIELD_PENDING);
169717
+ } catch {
169718
+ }
169719
+ }
169720
+ function shieldDepositOf(store, depositId) {
169721
+ let record;
169722
+ try {
169723
+ record = store.readWal(`deposit-${depositId}`);
169724
+ } catch {
169725
+ return void 0;
169726
+ }
169727
+ if (record?.schema !== DEPOSIT_WAL_SCHEMA || typeof record.state !== "string") return void 0;
169728
+ const signature2 = record.receipt?.signature;
169729
+ return { state: record.state, resolved: RESOLVED_STATES.has(record.state), transaction: typeof signature2 === "string" ? signature2 : null };
169730
+ }
169731
+ function pendingShield(store) {
169732
+ let record;
169733
+ try {
169734
+ record = store.readWal(SHIELD_PENDING);
169735
+ } catch {
169736
+ return void 0;
169737
+ }
169738
+ if (record?.schema !== SHIELD_PENDING_SCHEMA || !DEPOSIT_ID.test(String(record.depositId ?? "")) || !ATOMIC15.test(String(record.amountAtomic ?? ""))) {
169739
+ return void 0;
169740
+ }
169741
+ return { depositId: record.depositId, amountAtomic: record.amountAtomic, deposit: shieldDepositOf(store, record.depositId) };
169742
+ }
169743
+ function openOwnShield(store) {
169744
+ let names2;
169745
+ try {
169746
+ names2 = store.listWal();
169747
+ } catch {
169748
+ return void 0;
169749
+ }
169750
+ for (const name of names2) {
169751
+ if (!name.startsWith("deposit-")) continue;
169752
+ let record;
169753
+ try {
169754
+ record = store.readWal(name);
169755
+ } catch {
169756
+ continue;
169757
+ }
169758
+ if (record?.schema === DEPOSIT_WAL_SCHEMA && record.relay?.own === true && !RESOLVED_STATES.has(record.state) && ATOMIC15.test(String(record.amountAtomic ?? ""))) {
169759
+ return { depositId: name.slice("deposit-".length), amountAtomic: String(record.amountAtomic) };
169760
+ }
169761
+ }
169762
+ return void 0;
169763
+ }
169764
+ function unfinishedShield(store) {
169765
+ const open6 = openOwnShield(store);
169766
+ if (open6) return { amountAtomic: open6.amountAtomic };
169767
+ const pending = pendingShield(store);
169768
+ return pending?.deposit ? { amountAtomic: pending.amountAtomic } : null;
169769
+ }
169770
+
169771
+ // wallet/src/cli/shinjukuWallet.mjs
169621
169772
  init_config();
169622
169773
 
169623
169774
  // wallet/src/setup/setup.mjs
@@ -174507,6 +174658,11 @@ function readHomeData({ env = process.env, walletVersion: walletVersion2, torRun
174507
174658
  balance,
174508
174659
  balanceKnownAt: Number.isFinite(refreshedAt) ? refreshedAt : null,
174509
174660
  publicUsdc: setUp ? tryOr(null, () => publicUsdcOf(store)) : null,
174661
+ // A shield that did not finish (cli/terminalShield.mjs): [m] finishes it, also with no saved public read.
174662
+ shieldOpen: setUp ? tryOr(null, () => {
174663
+ const open6 = unfinishedShield(store);
174664
+ return open6 ? { amount: usdcWords(open6.amountAtomic) } : null;
174665
+ }) : null,
174510
174666
  addingFunds: setUp ? tryOr(null, () => addingFundsOf(parts, store)) : null,
174511
174667
  addingFundsNote: setUp ? tryOr(null, () => addingFundsNoteOf(store, nowMs)) : null,
174512
174668
  movingOut: setUp ? tryOr(null, () => movingOutOf(parts)) : null,
@@ -174594,7 +174750,7 @@ function hintForThisRun(text3, values) {
174594
174750
  if (service) hint = hint.split(GUIDE.facilitator).join(service);
174595
174751
  return hint;
174596
174752
  }
174597
- var REFUSED_ON_RETIRED_POOL = /* @__PURE__ */ new Set(["init", "add-funds", "deposit"]);
174753
+ var REFUSED_ON_RETIRED_POOL = /* @__PURE__ */ new Set(["init", "add-funds", "deposit", "shield"]);
174598
174754
  function retiredPoolGuard(command, values, io, npmVersion) {
174599
174755
  const fromWallet = /([1-9A-HJ-NP-Za-km-z]{32,44})[\\/]wallet\.json$/.exec(String(values.get("--wallet") ?? ""))?.[1];
174600
174756
  const pool2 = [values.get("--pool"), fromWallet].find((value2) => typeof value2 === "string" && RETIRED_POOLS[value2]);
@@ -174693,6 +174849,7 @@ var payerSessionFlags = () => [
174693
174849
  flag2("--memo-service", "<url>", "server that serves the encrypted memos (its origin is also the default RPC relay)", { required: true }),
174694
174850
  HISTORY_RPC_FLAG
174695
174851
  ];
174852
+ 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
174853
  var BALANCE_NEXT_SET_UP = `back up the wallet (${CLI_WORD} help backup-export); ${CLI_WORD} balance shows the private balance`;
174697
174854
  var BALANCE_NEXT = `${BALANCE_NEXT_SET_UP} (a wallet you name by flags, not set up: ${CLI_WORD} help balance)`;
174698
174855
  var SPEND_WALLET_FOLLOWED = /* @__PURE__ */ Symbol("spend wallet followed");
@@ -175612,6 +175769,26 @@ function questionEnds(text3, last) {
175612
175769
  const shown = part.join(" ").slice(0, 60);
175613
175770
  return words2.length > 6 ? last ? `...${shown}` : `${shown}...` : shown;
175614
175771
  }
175772
+ function typedLineWatch(input, output2) {
175773
+ const marks = armPasteMarks({ input, output: output2 });
175774
+ const clock2 = quickEnterClock();
175775
+ let pasted = false;
175776
+ let bareEnter = false;
175777
+ const onData = (data) => {
175778
+ const text3 = typeof data === "string" ? data : Buffer.from(data).toString("utf8");
175779
+ const quick = clock2.see(text3);
175780
+ bareEnter = /^(?:\r\n|\r|\n)$/.test(text3) && !quick && !marks.pasting();
175781
+ if (marks.pasting() || text3.includes("\x1B[200~") || quick || /[\r\n]/.test(text3) && !bareEnter) pasted = true;
175782
+ };
175783
+ input.prependListener("data", onData);
175784
+ return {
175785
+ typed: (rl) => bareEnter && !pasted && !marks.pasting() && !rl.line,
175786
+ off: () => {
175787
+ input.removeListener("data", onData);
175788
+ marks.off();
175789
+ }
175790
+ };
175791
+ }
175615
175792
  async function readTypedQuestion({ input = process.stdin, output: output2 = process.stderr } = {}) {
175616
175793
  output2.write("Type or paste your question, then press Enter on an empty line. Ctrl+C stops, and nothing is paid.\n");
175617
175794
  const rl = createInterface2({ input, output: output2, terminal: true, crlfDelay: Infinity, historySize: 0 });
@@ -179700,6 +179877,25 @@ var COMMANDS = [
179700
179877
  },
179701
179878
  run: (args, values, deps, io) => deps.fundsMain("funds-status", values, { ...deps, io })
179702
179879
  },
179880
+ {
179881
+ name: "shield",
179882
+ summary: "Make the USDC on your wallet's own public address private. Shinjuku pays every network fee, so the address needs no SOL.",
179883
+ env: [],
179884
+ flags: [
179885
+ 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"),
179886
+ // The tool's own session (runShield reads its proof files, program, memo service and RPC): config.json gives them.
179887
+ ...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)
179888
+ ],
179889
+ examples: [`${CLI_WORD} shield`, `${CLI_WORD} shield --amount 0.5`],
179890
+ notes: [
179891
+ "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.",
179892
+ SHIELD_PRIVACY_WORDS,
179893
+ "A shield that stopped (Ctrl+C, a closed window) continues when you run shield again: the same deposit never goes in twice."
179894
+ ],
179895
+ next: `see the private balance: ${CLI_WORD} balance`,
179896
+ validate: (values, env) => validatePayerSession("shield", values, env),
179897
+ run: (args, values, deps, io) => runShieldCommand(values, deps, io)
179898
+ },
179703
179899
  {
179704
179900
  name: "deposit",
179705
179901
  summary: "Move your own USDC into the shielded pool.",
@@ -182745,8 +182941,189 @@ function ownPublicLine(publicAtomic) {
182745
182941
  if (!/^[1-9][0-9]{0,30}$/.test(String(publicAtomic ?? ""))) return void 0;
182746
182942
  const head = `${usdcOr(publicAtomic)} is on this wallet's own public address and is not private yet.`;
182747
182943
  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}`;
182944
+ return `${head} To make it private, run: ${cli4()} shield`;
182945
+ }
182946
+ async function ownAddressUsdc(session, store) {
182947
+ const owner = walletOwnAddress(store);
182948
+ if (!owner) throw new PublicFailure("wallet_unreadable: this wallet's own address could not be read; nothing was moved");
182949
+ const account = getAssociatedTokenAddressSync(new import_web3139.PublicKey(store.state.asset), owner, false, TOKEN_PROGRAM_ID);
182950
+ return onOwnTorTag(async () => {
182951
+ try {
182952
+ return (await getAccount(session.connection, account, "finalized", TOKEN_PROGRAM_ID)).amount.toString();
182953
+ } catch (error) {
182954
+ if (error instanceof TokenAccountNotFoundError) return "0";
182955
+ throw error;
182956
+ }
182957
+ });
182958
+ }
182959
+ var SHIELD_STAGE_WORDS = {
182960
+ proving: "Preparing the private proof of the deposit (this can take a minute or two)...",
182961
+ submitting: "Shinjuku submits the deposit and pays every network fee...",
182962
+ sending: "Sending the deposit..."
182963
+ };
182964
+ async function confirmShield(question, deps, io, declined) {
182965
+ for (let attempt = 0; attempt < 3; attempt += 1) {
182966
+ const reply = await deps.ask(question, { typedOnly: true });
182967
+ const { answer, typed } = reply !== null && typeof reply === "object" ? reply : { answer: reply, typed: false };
182968
+ const yes2 = /^y(es)?$/i.test(String(answer ?? "").trim());
182969
+ if (yes2 && typed === true) return;
182970
+ if (!yes2) throw new AnswerDeclined("shield_declined", declined);
182971
+ 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");
182972
+ }
182973
+ throw new AnswerDeclined("shield_declined", declined);
182974
+ }
182975
+ async function runShieldCommand(values, deps, io) {
182976
+ const terminal = deps.stdinIsTTY() && deps.stdoutIsTTY?.() === true;
182977
+ const home = inHomeJob(deps.env);
182978
+ const again = home ? "press m again" : `run ${cli4()} shield again`;
182979
+ const typedAmount = values.get("--amount");
182980
+ if (!terminal && typedAmount === void 0) {
182981
+ throw new UsageError("shield needs --amount <usdc|all> when it runs without a terminal (in a terminal, shield asks)", COMMAND_BY_NAME.get("shield"));
182982
+ }
182983
+ if (typedAmount !== void 0 && !/^all$/i.test(typedAmount) && usdcToAtomic(typedAmount) === void 0) {
182984
+ throw new UsageError("--amount takes an amount of USDC like 0.5, or all", COMMAND_BY_NAME.get("shield"));
182985
+ }
182986
+ const session = await (deps.openPayerSession ?? openPayerSession)(payerSessionOptions(values, deps));
182987
+ let amountAtomic;
182988
+ let result;
182989
+ let earlier = false;
182990
+ let store;
182991
+ try {
182992
+ assertSessionPool(values, session.pool);
182993
+ store = session.openStore();
182994
+ const pending = pendingShield(store);
182995
+ if (pending?.deposit?.resolved) {
182996
+ ({ amountAtomic } = pending);
182997
+ result = { state: pending.deposit.state, transaction: pending.deposit.transaction };
182998
+ earlier = true;
182999
+ io.err(`Your earlier shield of ${usdcOr(amountAtomic)} finished before this run ended; no new deposit starts now.
183000
+ `);
183001
+ } else {
183002
+ if (pending && !pending.deposit) removePendingShield(store);
183003
+ const open6 = pending?.deposit ? pending : openOwnShield(store);
183004
+ let depositId;
183005
+ if (open6) {
183006
+ ({ depositId, amountAtomic } = open6);
183007
+ if (typedAmount !== void 0 && (/^all$/i.test(typedAmount) || BigInt(usdcToAtomic(typedAmount)) !== BigInt(amountAtomic))) {
183008
+ 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)}`}`);
183009
+ }
183010
+ io.err(`Your earlier shield of ${usdcOr(amountAtomic)} did not finish.
183011
+ `);
183012
+ if (terminal) {
183013
+ io.err(`${SHIELD_PRIVACY_WORDS}
183014
+ `);
183015
+ await confirmShield(
183016
+ `Finish making ${usdcOr(amountAtomic)} private? Shinjuku pays the network fees. [y/N] `,
183017
+ deps,
183018
+ io,
183019
+ `you did not type y, so nothing new was moved; the earlier shield of ${usdcOr(amountAtomic)} stays open. To finish it, ${again}`
183020
+ );
183021
+ }
183022
+ } else {
183023
+ io.err("Reading the USDC on your own address...\n");
183024
+ const held2 = await ownAddressUsdc(session, store);
183025
+ try {
183026
+ savePublicRead(store, held2, deps.now());
183027
+ } catch {
183028
+ }
183029
+ if (BigInt(held2) < SHIELD_MIN_ATOMIC2) {
183030
+ 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`);
183031
+ }
183032
+ if (typedAmount !== void 0) {
183033
+ amountAtomic = /^all$/i.test(typedAmount) ? held2 : usdcToAtomic(typedAmount);
183034
+ } else {
183035
+ for (let attempt = 0; attempt < 3 && amountAtomic === void 0; attempt += 1) {
183036
+ const text3 = String(await deps.ask(`How much USDC do you want to make private? (Enter = all ${usdcOr(held2)}): `)).trim();
183037
+ amountAtomic = !text3 || /^all$/i.test(text3) ? held2 : usdcToAtomic(text3);
183038
+ if (amountAtomic === void 0) io.err("Type an amount of USDC like 0.5, or press Enter for all of it.\n");
183039
+ }
183040
+ if (amountAtomic === void 0) throw new AnswerDeclined("shield_declined", `three answers were not usable, so nothing was moved. To make it private, ${again}`);
183041
+ }
183042
+ if (BigInt(amountAtomic) < SHIELD_MIN_ATOMIC2) {
183043
+ throw new PublicFailure(`shield_amount_too_small: the least that can be made private is ${usdcOr(SHIELD_MIN_ATOMIC2)}. Nothing was moved`);
183044
+ }
183045
+ if (BigInt(amountAtomic) > BigInt(held2)) {
183046
+ throw new PublicFailure(`shield_amount_too_large: your own address holds ${usdcOr(held2)}, less than ${usdcOr(amountAtomic)}. Nothing was moved`);
183047
+ }
183048
+ io.err(`${SHIELD_PRIVACY_WORDS}
183049
+ `);
183050
+ if (terminal) {
183051
+ await confirmShield(
183052
+ `Make ${usdcOr(amountAtomic)} private? Shinjuku pays the network fees. [y/N] `,
183053
+ deps,
183054
+ io,
183055
+ `you did not type y, so nothing was moved. To make it private, ${again}`
183056
+ );
183057
+ }
183058
+ depositId = `shield-${randomBytes48(8).toString("hex")}`;
183059
+ }
183060
+ writePendingShield(store, depositId, amountAtomic, new Date(deps.now()).toISOString());
183061
+ try {
183062
+ result = await runShield({ session, depositId, amountAtomic, onStage: (stage) => {
183063
+ if (SHIELD_STAGE_WORDS[stage]) io.err(`${SHIELD_STAGE_WORDS[stage]}
183064
+ `);
183065
+ } });
183066
+ } catch (error) {
183067
+ throw shieldRefusal(error, again);
183068
+ }
183069
+ }
183070
+ if (["published", "foreign_funded"].includes(result?.state)) {
183071
+ try {
183072
+ savePublicRead(store, await ownAddressUsdc(session, store), deps.now());
183073
+ } catch {
183074
+ try {
183075
+ clearPublicRead(store);
183076
+ } catch {
183077
+ }
183078
+ }
183079
+ }
183080
+ } finally {
183081
+ await session.close();
183082
+ }
183083
+ if (!["published", "foreign_funded"].includes(result?.state)) {
183084
+ 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.
183085
+ `);
183086
+ return;
183087
+ }
183088
+ io.out(`${usdcOr(amountAtomic)} is private now${result.transaction ? ` (transaction ${result.transaction})` : ""}.
183089
+ `);
183090
+ const read2 = await readBalanceFromChain(store, values, deps, "Reading your private balance from the chain...\n");
183091
+ 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`}).
183092
+ `);
183093
+ let release;
183094
+ try {
183095
+ const walletPath2 = commandWalletPath(values, deps);
183096
+ release = await acquireWalletProcessLease(walletLockPath(walletPath2));
183097
+ const passphrase2 = payerPassphrase(values, deps);
183098
+ writeAutoBackup({ walletPath: walletPath2, pool: store.state.pool, exportBundle: (destination) => exportWalletRecoveryBundle(walletPath2, passphrase2, destination) });
183099
+ io.out("An encrypted backup of the wallet was saved.\n");
183100
+ } catch {
183101
+ io.out("The automatic encrypted backup was not saved this time. The deposit is done; your recovery file still opens the wallet.\n");
183102
+ } finally {
183103
+ await release?.();
183104
+ }
183105
+ removePendingShield(commandStore(values, deps) ?? store);
183106
+ 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`));
183107
+ }
183108
+ function shieldRefusal(error, again) {
183109
+ const text3 = String(error?.message ?? "");
183110
+ if (/relay_amount_below_facilitator_minimum/.test(text3)) {
183111
+ const least = /^[1-9][0-9]*$/.test(String(error?.minimumAtomic ?? "")) ? usdcOr(error.minimumAtomic) : void 0;
183112
+ 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`);
183113
+ }
183114
+ if (/another_deposit_unresolved/.test(text3)) {
183115
+ 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");
183116
+ }
183117
+ if (/wallet_process_locked|wallet_locked/.test(text3)) {
183118
+ 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`);
183119
+ }
183120
+ if (/insufficient_token_balance|own_key_usdc_not_finalized/.test(text3)) {
183121
+ return new PublicFailure(`own_address_short: your own address does not hold that much final USDC yet. Nothing was moved; ${again} in a minute`);
183122
+ }
183123
+ if (/facilitator_underfunded/.test(text3)) {
183124
+ return new PublicFailure("relay_unavailable: Shinjuku cannot pay network fees right now. Nothing was spent; try again later");
183125
+ }
183126
+ return error;
182750
183127
  }
182751
183128
  async function runBalance(args, values, deps, io) {
182752
183129
  const mark = balanceMarks(values, deps);
@@ -183791,6 +184168,39 @@ function startHomeBalanceRead(argv2, env) {
183791
184168
  child.once("exit", (code2) => done(code2 ?? 1));
183792
184169
  });
183793
184170
  }
184171
+ var HOME_FACTS_REREAD_MS = 5e3;
184172
+ function homeFactsWatch(data, balanceRead, readData) {
184173
+ let current = data;
184174
+ const watch = (draw) => {
184175
+ const show = (next) => {
184176
+ current = next;
184177
+ draw(next);
184178
+ };
184179
+ const stopRead = balanceRead?.watch(show);
184180
+ let last = JSON.stringify(data);
184181
+ const timer = setInterval(() => {
184182
+ const reading2 = balanceRead?.data().balanceRead;
184183
+ if (reading2 === "reading" || reading2 === "slow") return;
184184
+ let next;
184185
+ try {
184186
+ next = readData();
184187
+ } catch {
184188
+ return;
184189
+ }
184190
+ if (balanceRead && (next?.balance === null || next?.balance === void 0)) next = { ...next, balanceRead: reading2 };
184191
+ const text3 = JSON.stringify(next);
184192
+ if (text3 === last) return;
184193
+ last = text3;
184194
+ show(next);
184195
+ }, HOME_FACTS_REREAD_MS);
184196
+ timer.unref?.();
184197
+ return () => {
184198
+ clearInterval(timer);
184199
+ stopRead?.();
184200
+ };
184201
+ };
184202
+ return { watch, current: () => current };
184203
+ }
183794
184204
  function homeBalanceRead(data, argv2, deps, readData) {
183795
184205
  if (data?.setUp !== true || data.balance !== null || data.walletIssue || data.restoreUnread || data.setupFilesMissing) return void 0;
183796
184206
  const ended2 = deps.homeBalanceRead(argv2, deps.env);
@@ -183945,9 +184355,10 @@ function defaultDependencies() {
183945
184355
  * at a question paused stdin with no answer, Node then printed "Detected unsettled top-level await" and nothing said
183946
184356
  * what happened. Ctrl-C, or an input that ends, now stops the command with QuestionCancelled (one plain line).
183947
184357
  */
183948
- ask: (question) => new Promise((resolveAnswer, rejectAnswer) => {
184358
+ ask: (question, { typedOnly = false } = {}) => new Promise((resolveAnswer, rejectAnswer) => {
183949
184359
  const releaseProgress = holdProgressLines(process.stderr);
183950
- const prompt = createInterface2({ input: process.stdin, output: process.stderr, terminal: true });
184360
+ const prompt = createInterface2({ input: process.stdin, output: process.stderr, terminal: true, ...typedOnly ? { historySize: 0 } : {} });
184361
+ const watch = typedOnly ? typedLineWatch(process.stdin, process.stderr) : void 0;
183951
184362
  let answered2 = false;
183952
184363
  let interrupted = false;
183953
184364
  prompt.on("SIGINT", () => {
@@ -183957,12 +184368,14 @@ function defaultDependencies() {
183957
184368
  });
183958
184369
  prompt.on("close", () => {
183959
184370
  releaseProgress();
184371
+ watch?.off();
183960
184372
  if (!answered2) rejectAnswer(new QuestionCancelled(interrupted));
183961
184373
  });
183962
184374
  prompt.question(question, (answer) => {
183963
184375
  answered2 = true;
184376
+ const typed = watch ? watch.typed(prompt) : void 0;
183964
184377
  prompt.close();
183965
- resolveAnswer(answer);
184378
+ resolveAnswer(watch ? { answer, typed } : answer);
183966
184379
  });
183967
184380
  }),
183968
184381
  /** claude with no output on the terminal (setup's probe of an old entry, and its remove); the exit status. */
@@ -184157,6 +184570,7 @@ Keep it offline and private: with it, anyone can spend your money.
184157
184570
  var HOME_JOB_TITLES = {
184158
184571
  t: "private AI chat",
184159
184572
  i: "private AI address",
184573
+ m: "make public USDC private",
184160
184574
  a: "add funds",
184161
184575
  u: "send money out",
184162
184576
  p: "pay a link",
@@ -184171,6 +184585,7 @@ var COMMAND_TITLES = {
184171
184585
  setup: "set up the wallet",
184172
184586
  balance: "private balance",
184173
184587
  "add-funds": "add funds",
184588
+ shield: "make public USDC private",
184174
184589
  unshield: "send money out",
184175
184590
  curl: "pay a link",
184176
184591
  pay: "pay",
@@ -184232,6 +184647,7 @@ async function homeKeyJob(key, { data, argv: argv2, deps }) {
184232
184647
  return await child(["chat"]);
184233
184648
  }
184234
184649
  if (key === "s") return await child(["setup"]);
184650
+ if (key === "m") return await child(["shield"]);
184235
184651
  if (key === "a") return await child(["add-funds"]);
184236
184652
  if (key === "u") return await child(["unshield"]);
184237
184653
  if (key === "l") return await deps.runHomeChild(["limits"], { ...deps.env, [NO_TOR_RUN_ENV]: "1" });
@@ -184352,7 +184768,8 @@ async function runHomeLoop(argv2, deps, { animation = true } = {}) {
184352
184768
  for (; ; ) {
184353
184769
  const data = readData();
184354
184770
  const balanceRead = homeBalanceRead(data, argv2, deps, readData);
184355
- const screen = await deps.homeScreen(balanceRead ? balanceRead.data() : data, deps.env, balanceRead?.watch, nextKey);
184771
+ const facts = homeFactsWatch(balanceRead ? balanceRead.data() : data, balanceRead, readData);
184772
+ const screen = await deps.homeScreen(facts.current(), deps.env, facts.watch, nextKey);
184356
184773
  nextKey = void 0;
184357
184774
  if (screen.outcome === "interrupted") {
184358
184775
  clearAfterJobs();
@@ -184374,7 +184791,8 @@ async function runHomeLoop(argv2, deps, { animation = true } = {}) {
184374
184791
  }
184375
184792
  await balanceRead?.finish(io);
184376
184793
  ranJob = true;
184377
- const view2 = await deps.homeJobView(HOME_JOB_TITLES[screen.key] ?? "wallet", () => homeKeyJob(screen.key, { data, argv: argv2, deps }));
184794
+ const shown = facts.current();
184795
+ const view2 = await deps.homeJobView(HOME_JOB_TITLES[screen.key] ?? "wallet", () => homeKeyJob(screen.key, { data: shown, argv: argv2, deps }));
184378
184796
  if (view2.next === "quit") return view2.code === 130 ? 130 : 0;
184379
184797
  nextKey = view2.key;
184380
184798
  }