shinjuku-shield 0.3.101 → 0.3.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,13 +6,13 @@ answers privately, in a terminal chat or for your agent app. Its `mcp`
6
6
  command runs a local MCP server (stdio) for your agent. Your keys never
7
7
  leave your machine.
8
8
 
9
- This is version 0.3.101. The npm packages `shinjuku-shield` and
9
+ This is version 0.3.103. The npm packages `shinjuku-shield` and
10
10
  `shinjuku-shielded` hold the same files. The command is `shinjuku`.
11
11
 
12
12
  ## Set up
13
13
 
14
14
  ```sh
15
- npx -y --no-audit --no-fund shinjuku-shield@0.3.101 setup
15
+ npx -y --no-audit --no-fund shinjuku-shield@0.3.103 setup
16
16
  ```
17
17
 
18
18
  Setup makes the wallet on this machine, a private passphrase file, and the
@@ -24,7 +24,7 @@ server to that host's config.
24
24
  ## The `shinjuku` command
25
25
 
26
26
  ```sh
27
- npm install -g --no-audit --no-fund shinjuku@0.3.101
27
+ npm install -g --no-audit --no-fund shinjuku@0.3.103
28
28
  shinjuku help
29
29
  ```
30
30
 
@@ -36,13 +36,13 @@ Every wallet command works after `shinjuku`, for example `shinjuku balance`,
36
36
  Claude Code:
37
37
 
38
38
  ```sh
39
- claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.101 mcp
39
+ claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.103 mcp
40
40
  ```
41
41
 
42
42
  Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
43
43
 
44
44
  ```json
45
- { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.101", "mcp"] } } }
45
+ { "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.103", "mcp"] } } }
46
46
  ```
47
47
 
48
48
  On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
package/manifest.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schema": "carbon-shielded-wallet/bundle-manifest/v1",
3
3
  "file": "shinjuku-wallet.mjs",
4
- "sha256": "1c3d204e7ba114b9d80654035efb4a244ac607f038e1961f23663b7af9b45dc5",
5
- "bytes": 12794106,
6
- "sourceCommit": "9e761632116ec38e2adb92828c85cc1793b45c90",
4
+ "sha256": "b5da74cb566cf4df5a7381cbb3eb28797aff16377f170472b6fcefce230db2a2",
5
+ "bytes": 12800520,
6
+ "sourceCommit": "b5ed9d0ff1a26115297f6e4dc56473ca9b053446",
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",
@@ -1297,5 +1297,5 @@
1297
1297
  "version": "1.8.0"
1298
1298
  }
1299
1299
  ],
1300
- "publishedAt": "2026-10-24T13:59:01.418Z"
1300
+ "publishedAt": "2026-10-24T16:04:06.349Z"
1301
1301
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shield",
3
- "version": "0.3.101",
3
+ "version": "0.3.103",
4
4
  "mcpName": "io.github.ShinjukuStaition/shinjuku-mcp",
5
5
  "description": "Shinjuku Shielded, the private x402 facilitator on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
6
- "shinjukuRelease": "1c3d204e",
7
- "shinjukuSha256": "1c3d204e7ba114b9d80654035efb4a244ac607f038e1961f23663b7af9b45dc5",
6
+ "shinjukuRelease": "b5da74cb",
7
+ "shinjukuSha256": "b5da74cb566cf4df5a7381cbb3eb28797aff16377f170472b6fcefce230db2a2",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shielded",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
@@ -50123,6 +50123,7 @@ function whenRequestsSent(match, { count: count2 = 1, maxMs = 40, settled } = {}
50123
50123
  }
50124
50124
  }
50125
50125
  timer = setTimeout(() => done(false), maxMs);
50126
+ timer.unref?.();
50126
50127
  sent.subscribe(onSent);
50127
50128
  failed.subscribe(onFailed);
50128
50129
  settled?.then(() => done(false), () => done(false));
@@ -96324,8 +96325,12 @@ function returnArrivedFloatRefundBudgets(store, snapshot) {
96324
96325
  for (const name of store.listWal()) {
96325
96326
  if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX)) continue;
96326
96327
  const record = store.readWal(name);
96327
- if (record?.schema !== FLOAT_PAYMENT_SCHEMA) continue;
96328
- if (record.state !== "refund_pending" || typeof record.innerRequestId !== "string") continue;
96328
+ if (record?.schema !== FLOAT_PAYMENT_SCHEMA || typeof record.innerRequestId !== "string") continue;
96329
+ if (record.state === "submitted") {
96330
+ if (refundArrived(snapshot, record.refundTo)) releaseRefundedReservation({ store, requestId: record.innerRequestId });
96331
+ continue;
96332
+ }
96333
+ if (record.state !== "refund_pending") continue;
96329
96334
  const arrivedNow = refundArrived(snapshot, record.refundTo);
96330
96335
  if (arrivedNow) releaseRefundedReservation({ store, requestId: record.innerRequestId });
96331
96336
  const outcome = arrivedNow ? "refund_arrived" : record.refundOutcome === void 0 && refundCountStopped(record, refreshedAtMs, knowsRecipients) ? "refund_not_seen" : void 0;
@@ -105409,6 +105414,16 @@ function lazyProofEntry(store, name) {
105409
105414
  return String(read()?.state);
105410
105415
  } };
105411
105416
  }
105417
+ function floatRefundNoteHeld(snapshot, refundTo) {
105418
+ const outputs = Array.isArray(snapshot?.outputs) ? snapshot.outputs : [];
105419
+ let address5;
105420
+ try {
105421
+ address5 = decodeShieldedSolanaP03Address(String(refundTo));
105422
+ } catch {
105423
+ return false;
105424
+ }
105425
+ return outputs.some((output2) => output2?.kind === "note" && output2.diversifier === address5.diversifier.toString() && output2.recipientX === address5.recipientX.toString());
105426
+ }
105412
105427
  function classify(name, record) {
105413
105428
  const state = String(record?.state);
105414
105429
  if (name.startsWith("deposit-") && record?.schema === DEPOSIT_WAL_SCHEMA) {
@@ -105481,8 +105496,10 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
105481
105496
  ...entry.record.relay?.approvedOnChain ? { approvalStanding: true } : {}
105482
105497
  }));
105483
105498
  const receipts = records.filter((entry) => entry.type === "payment" && entry.phase === "done");
105484
- const refunded = new Set(records.filter((entry) => entry.type === "float-payment" && entry.state === "refund_pending").map((entry) => entry.record.innerRequestId).filter((id) => typeof id === "string"));
105485
- const paid = receipts.filter((entry) => !String(entry.record.url ?? "").startsWith(SELF_PAY_ORIGIN2) && !String(entry.record.url ?? "").includes(POOL_MOVE_PATH2) && !refunded.has(entry.record.requestId));
105499
+ const refunded = new Set(records.filter((entry) => entry.type === "float-payment" && (entry.state === "refund_pending" || entry.state === "submitted" && floatRefundNoteHeld(snapshotRead?.snapshot, entry.record.refundTo))).map((entry) => entry.record.innerRequestId).filter((id) => typeof id === "string"));
105500
+ const sellerReceipts = receipts.filter((entry) => !String(entry.record.url ?? "").startsWith(SELF_PAY_ORIGIN2) && !String(entry.record.url ?? "").includes(POOL_MOVE_PATH2));
105501
+ const paid = sellerReceipts.filter((entry) => !refunded.has(entry.record.requestId));
105502
+ const refundedPaid = sellerReceipts.filter((entry) => refunded.has(entry.record.requestId));
105486
105503
  const sum2 = (values) => values.reduce((total, value) => total + BigInt(value ?? "0"), 0n);
105487
105504
  const config = state.config ?? {};
105488
105505
  const capOrNone = (value) => String(value) === NO_LIMIT_ATOMIC2 ? "none" : value;
@@ -105506,6 +105523,8 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
105506
105523
  pendingDeposits,
105507
105524
  paidAtomic: sum2(paid.map((entry) => paymentAmount(entry.record))).toString(),
105508
105525
  paidReceipts: paid.length,
105526
+ refundedAtomic: sum2(refundedPaid.map((entry) => paymentAmount(entry.record))).toString(),
105527
+ refundedPayments: refundedPaid.length,
105509
105528
  unshieldedAtomic: sum2(records.filter((entry) => entry.type === "unshield" && entry.phase === "done" && !entry.name.startsWith(POCKET_FILL_RECORD) && !entry.name.startsWith(MERGE_RECORD)).map((entry) => entry.record.amountAtomic)).toString(),
105510
105529
  ...budget ? { budget } : {},
105511
105530
  lastRefresh: null
@@ -105833,6 +105852,7 @@ var init_balance = __esm({
105833
105852
  init_config();
105834
105853
  init_commandName();
105835
105854
  init_requestId();
105855
+ init_ShieldedSolanaP03QuoteCrypto();
105836
105856
  PAY_ME_WAL_SCHEMA = "carbon-shielded-wallet/pay-me/v1";
105837
105857
  BALANCE_SNAPSHOT_SCHEMA = "carbon-shielded-wallet/balance-snapshot/v1";
105838
105858
  BALANCE_SNAPSHOT_FILE = "balance-snapshot.json";
@@ -120441,7 +120461,7 @@ function paidMessage(error, code2, paid, requestId, key) {
120441
120461
  const floatId = error?.floatId ?? error?.cause?.floatId;
120442
120462
  const sellerSaid = error?.sellerReason ?? error?.cause?.sellerReason;
120443
120463
  const reason = code2 === "p03_float_seller_kept_payment" ? `The AI provider received the payment but did not serve the request${typeof sellerSaid === "string" ? ` (${JSON.stringify(sellerSaid)})` : ""}; no refund comes. ` : typeof sellerSaid === "string" ? `The AI provider refused the payment: ${JSON.stringify(sellerSaid)}. ` : "";
120444
- return `this call was paid ${usdcWords(paid)} and returned no answer${floatId ? ` (float ${floatId})` : ""}. Do not resend it without the same Idempotency-Key: a new request pays again. ${reason}Request id ${requestId}` + (key ? `; a resend with header Idempotency-Key: ${key} returns this same result and pays nothing more. ` : ". ") + (refund && ambiguous ? "An earlier send of it may have reached the seller; if it did not, Shinjuku refunds the amount in about 7 minutes. Check shinjuku balance" : refund ? "Shinjuku refunds the amount to the wallet by itself in about 7 minutes; shinjuku balance shows it back" : "Check the wallet with shinjuku balance");
120464
+ return `this call was paid ${usdcWords(paid)} and returned no answer${floatId ? ` (Shinjuku payment ${floatId})` : ""}. Do not resend it without the same Idempotency-Key: a new request pays again. ${reason}Request id ${requestId}` + (key ? `; a resend with header Idempotency-Key: ${key} returns this same result and pays nothing more. ` : ". ") + (refund && ambiguous ? "An earlier send of it may have reached the seller; if it did not, Shinjuku refunds the amount in about 7 minutes. Check shinjuku balance" : refund ? "Shinjuku refunds the amount to the wallet by itself in about 7 minutes; shinjuku balance shows it back" : "Check the wallet with shinjuku balance");
120445
120465
  }
120446
120466
  function unknownMessage(code2, counted, requestId, key) {
120447
120467
  return `request ${requestId} may already have paid (${code2 ?? "the payment failed with no code"}), and its outcome is not known yet. This server counted ${usdcWords(counted)} (its limit per request) of its limit per run for it. ` + (key ? `Do not send it as a new request: resend the same body with header Idempotency-Key: ${key} to finish that same payment; it never pays twice` : "This request had no Idempotency-Key, so infer serve cannot resume that payment, and a resend pays again. Check the wallet with shinjuku balance before you send it again, and send an Idempotency-Key header with each request so a resend finishes the same payment");
@@ -128665,7 +128685,9 @@ ${canonical5}`;
128665
128685
  const sellerTransaction = view2.sellerTransaction ?? knownSellerTransfer(record) ?? (SIGNATURE_TEXT.test(String(read ?? "")) ? read : null);
128666
128686
  row(name.slice(FLOAT_PAYMENT_WAL_PREFIX.length), record, { ...view2, sellerTransaction }, {
128667
128687
  scheme: "exact",
128668
- ...sellerTransaction === null ? { note: "the seller served this request, so it was paid and no refund comes; it sent no transfer signature, and Shinjuku has not reported the landed transfer yet (a later wallet_receipts shows it)" } : {}
128688
+ // RC1 (mcp56 pass of 0.3.102, hypernatt): this said "a later wallet_receipts shows it", but Shinjuku drops a final
128689
+ // row's link fields, landedTransaction too (float.mjs retain, owner decision 4), about 1 s after the settle.
128690
+ ...sellerTransaction === null ? { note: "the seller served this request, so it was paid and no refund comes; the seller sent no transfer signature, and Shinjuku keeps no link between this payment and its transfer once the payment is final, so this receipt has no seller transaction to show" } : {}
128669
128691
  });
128670
128692
  }
128671
128693
  for (const name of names) {
@@ -134319,7 +134341,7 @@ var init_tools = __esm({
134319
134341
  capRaiseText = (flag3) => {
134320
134342
  if (capFlagFromLaunchLine(flag3)) {
134321
134343
  const both = flag3 === "--max-payment" ? " (raise the 24-hour payment limit there too when it is below the new amount: the wallet does not start with it lower)" : "";
134322
- return `The ${capName(flag3)} is set in this app's wallet entry; only the user (your owner) can change it there${both}, with amounts in USDC like 0.5, then reconnect the wallet (restart the agent host). Where the entry is: Claude Desktop: claude_desktop_config.json; Cursor: ~/.cursor/mcp.json; Claude Code: claude mcp get shinjuku-shielded shows the entry, then claude mcp remove shinjuku-shielded and claude mcp add it again with the new value; Hermes: config.yaml. Running setup does not change this limit: the value in the entry wins over the limit setup records.`;
134344
+ return `The ${capName(flag3)} is set in this app's wallet entry; only the user (your owner) can change it there${both}, with amounts in USDC like 0.5, then reconnect the wallet (restart the agent host). Where the entry is: Claude Desktop: claude_desktop_config.json; Cursor: ~/.cursor/mcp.json; Claude Code: claude mcp get ${MCP_SERVER_NAME} shows the entry (an entry added by hand can have another name: claude mcp list shows it), then claude mcp remove ${MCP_SERVER_NAME} and claude mcp add it again with the new value; Hermes: config.yaml. Running setup does not change this limit: the value in the entry wins over the limit setup records.`;
134323
134345
  }
134324
134346
  return `The ${capName(flag3)} comes from the wallet's settings. To change it, the user runs ${terminalCommand2("limits")} in a terminal: it asks each limit as a question (amounts in USDC like 0.5, or Enter for no limit). Then the user restarts the agent host.`;
134325
134347
  };
@@ -136052,6 +136074,7 @@ __export(chat_exports, {
136052
136074
  DEFAULT_MODEL: () => DEFAULT_MODEL2,
136053
136075
  chatCaps: () => chatCaps,
136054
136076
  hideProgressLines: () => hideProgressLines,
136077
+ holdProgressLines: () => holdProgressLines,
136055
136078
  isProgressLine: () => isProgressLine,
136056
136079
  knownPrivateBalance: () => knownPrivateBalance,
136057
136080
  leastAnswerAtomic: () => leastAnswerAtomic,
@@ -136151,6 +136174,33 @@ function hideProgressLines(stream = process.stderr) {
136151
136174
  stream.write = original;
136152
136175
  };
136153
136176
  }
136177
+ function holdProgressLines(stream = process.stderr) {
136178
+ const original = stream.write;
136179
+ const held = [];
136180
+ stream.write = function write(chunk, encoding, callback) {
136181
+ const text3 = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString(typeof encoding === "string" ? encoding : "utf8");
136182
+ let passed = "";
136183
+ let kept2 = 0;
136184
+ for (const line of text3.split(/(?<=\n)/)) {
136185
+ if (line.endsWith("\n") && PROGRESS_LINE.test(line)) {
136186
+ held.push(line);
136187
+ kept2 += 1;
136188
+ } else passed += line;
136189
+ }
136190
+ if (kept2 === 0) return original.call(stream, chunk, encoding, callback);
136191
+ const done = typeof encoding === "function" ? encoding : callback;
136192
+ if (passed) return original.call(stream, passed, done);
136193
+ if (typeof done === "function") done();
136194
+ return true;
136195
+ };
136196
+ let released = false;
136197
+ return () => {
136198
+ if (released) return;
136199
+ released = true;
136200
+ stream.write = original;
136201
+ if (held.length) original.call(stream, held.join(""));
136202
+ };
136203
+ }
136154
136204
  function errorCodeOf(error) {
136155
136205
  if (error?.name === "InferenceError" && typeof error.code === "string") return error.code;
136156
136206
  if (error?.name === "SpendRefusalError" && typeof error.error === "string") return error.error;
@@ -136463,6 +136513,11 @@ async function runChat({ io, values, deps = {} }) {
136463
136513
  say6(`No AI provider serves ${turn.model} at this price right now. ${paidWords} Try another model (/model ${models.find((entry) => entry.id !== turn.model)?.id ?? DEFAULT_MODEL2}), or ${again} later.`);
136464
136514
  } else if (NO_ANSWER_CODES.test(code2 ?? "")) {
136465
136515
  say6(`The AI provider did not send a chat answer. ${paidWords} Wait a moment and ${again}, or try another model (/model).`);
136516
+ } else if (FLOAT_WAIT_WORDS[code2]) {
136517
+ state.pending = turn;
136518
+ const named = error?.retryAfterSeconds ?? error?.cause?.retryAfterSeconds;
136519
+ const seconds2 = Number.isFinite(named) && named > 0 ? Math.ceil(named) : FLOAT_WAIT_WORDS[code2].seconds;
136520
+ say6(`Nothing was paid: ${FLOAT_WAIT_WORDS[code2].what}. Ask again in about ${seconds2 >= 60 ? `${Math.round(seconds2 / 60)} minute${seconds2 >= 120 ? "s" : ""}` : `${seconds2} seconds`} (or /retry).`);
136466
136521
  } else if (WAIT_CODES.test(code2 ?? "")) {
136467
136522
  say6(`The payment did not finish yet (the wallet or the network is busy). ${paidWords} Wait a moment, then ${again}.`);
136468
136523
  } else {
@@ -136548,7 +136603,7 @@ async function runChat({ io, values, deps = {} }) {
136548
136603
  await session.close();
136549
136604
  }
136550
136605
  }
136551
- var DEFAULT_MODEL2, CHAT_DEFAULT_MODEL, CHAT_MAX_TOKENS, CHAT_SHORT_TOKENS, DEFAULT_ANSWER_CAP_ATOMIC, DEFAULT_CHAT_CAP_ATOMIC, CHEAPEST_MODEL, STILL_WAITING_MS, providerKept, higherCap, POSITIVE_ATOMIC9, SHINJUKU_FEE_ATOMIC, SHORT_QUESTION_TOKENS, PASTE_JOIN_MS, INSUFFICIENT2, CAP_CODES, WAIT_CODES, NO_ANSWER_CODES, NOTHING_PAID, CAP_FROM, PROGRESS_LINE, SHOWN_PROGRESS, SELF_PAY_LINE, isProgressLine, fail46, nothingPaid;
136606
+ var DEFAULT_MODEL2, CHAT_DEFAULT_MODEL, CHAT_MAX_TOKENS, CHAT_SHORT_TOKENS, DEFAULT_ANSWER_CAP_ATOMIC, DEFAULT_CHAT_CAP_ATOMIC, CHEAPEST_MODEL, STILL_WAITING_MS, providerKept, higherCap, POSITIVE_ATOMIC9, SHINJUKU_FEE_ATOMIC, SHORT_QUESTION_TOKENS, PASTE_JOIN_MS, INSUFFICIENT2, CAP_CODES, WAIT_CODES, NO_ANSWER_CODES, FLOAT_WAIT_WORDS, NOTHING_PAID, CAP_FROM, PROGRESS_LINE, SHOWN_PROGRESS, SELF_PAY_LINE, isProgressLine, fail46, nothingPaid;
136552
136607
  var init_chat = __esm({
136553
136608
  "wallet/src/inference/chat.mjs"() {
136554
136609
  "use strict";
@@ -136581,6 +136636,11 @@ var init_chat = __esm({
136581
136636
  CAP_CODES = /^(spend_payment_cap_exceeded|mcp_session_cap_exceeded|mcp_cap_argument_above_launch_cap|p03_float_over_maximum)$/;
136582
136637
  WAIT_CODES = /_retry_same_request$|_retry_same_payment$|_retry_later$|^wallet_locked$|another_request_unresolved$/;
136583
136638
  NO_ANSWER_CODES = /^inference_(upstream_failed|response_invalid)$/;
136639
+ FLOAT_WAIT_WORDS = Object.freeze({
136640
+ p03_float_not_ready_retry_later: { what: "Shinjuku's payment service is not ready right now", seconds: 60 },
136641
+ p03_float_busy_retry_later: { what: "Shinjuku's payment service is busy right now", seconds: 30 },
136642
+ p03_float_payment_in_flight_retry_later: { what: "an earlier quote for this answer is still open at Shinjuku", seconds: 60 }
136643
+ });
136584
136644
  NOTHING_PAID = /\bnothing was (?:sent or )?paid\b|\bnothing was paid or signed\b/i;
136585
136645
  CAP_FROM = { line: "from this command line", setup: "set in setup", default: "the default" };
136586
136646
  PROGRESS_LINE = /^(?:tor|rpc|history|memo service): |^reading \d+ memos? from the memo service|^reading your private balance again\b|^getting your balance ready: moving \S+ USDC of one deposit\b/;
@@ -161715,9 +161775,16 @@ async function addFunds(values, deps) {
161715
161775
  plan.status = { ...plan.status ?? { stage: currentStage(store, plan) }, ended: iso2(deps.now()) };
161716
161776
  save2();
161717
161777
  const view2 = fundsView(store, plan, { now: deps.now(), running: false });
161718
- io.err(`${ctx.quiet ? "add-funds stopped" : `add-funds ${plan.fundsId} stopped at ${view2.stage}`}: nothing is lost. Run the same command again to continue.
161778
+ if (ctx.quiet) {
161779
+ const waits = view2.stages.find((entry) => entry.stage === view2.stage)?.waitsFor;
161780
+ io.err(`add-funds stopped: nothing is lost.${waits ? ` It was waiting for ${waits}.` : ""} To continue, run:
161781
+ ${commandLine("add-funds")}
161719
161782
  `);
161720
- printEnd(deps, view2, ctx.terminal);
161783
+ } else {
161784
+ io.err(`add-funds ${plan.fundsId} stopped at ${view2.stage}: nothing is lost. Run the same command again to continue.
161785
+ `);
161786
+ printEnd(deps, view2, ctx.terminal);
161787
+ }
161721
161788
  } finally {
161722
161789
  process.off("SIGINT", onSignal);
161723
161790
  process.off("SIGTERM", onSignal);
@@ -162176,6 +162243,12 @@ var UsageError = class extends Error {
162176
162243
  };
162177
162244
  var PublicFailure = class extends Error {
162178
162245
  };
162246
+ var AnswerDeclined = class extends PublicFailure {
162247
+ constructor(code2, plain) {
162248
+ super(`${code2}: ${plain}`);
162249
+ this.plain = plain;
162250
+ }
162251
+ };
162179
162252
  var QuestionCancelled = class extends PublicFailure {
162180
162253
  // Every terminal question comes before a payment or a send, so this is true at each one.
162181
162254
  constructor(interrupted) {
@@ -162536,13 +162609,13 @@ async function runCurl(values, deps) {
162536
162609
  ${CURL_USEPOD_NEXT}`, { cause: error });
162537
162610
  else throw curlFailure(error);
162538
162611
  } finally {
162539
- await session.close();
162612
+ await closeTimed(session, "curl-price");
162540
162613
  }
162541
162614
  }
162542
162615
  if (response) return curlOutput(response, values, deps, probeId);
162543
162616
  const answer = String(await deps.ask(`Pay ${usdcText3(priceAtomic)} USDC for ${values.get("--url")}? [y/N] `)).trim();
162544
162617
  if (!/^y(es)?$/i.test(answer)) {
162545
- throw new PublicFailure("curl_payment_declined: you did not answer y, so nothing was paid. To pay, run the same command again and answer y");
162618
+ throw new AnswerDeclined("curl_payment_declined", "you did not answer y, so nothing was paid. To pay, run the same command again and answer y");
162546
162619
  }
162547
162620
  values.set("--max-payment", priceAtomic);
162548
162621
  return runCurlPaid(values, deps, { requestId });
@@ -162574,10 +162647,31 @@ ${CURL_USEPOD_NEXT}`, { cause: error });
162574
162647
  }
162575
162648
  throw curlFailure(error);
162576
162649
  }
162650
+ sessionMark(session)("curl-paid-returned");
162651
+ return await curlOutput(response, values, deps, requestId);
162577
162652
  } finally {
162578
- await session.close();
162653
+ await closeTimed(session, "curl");
162654
+ }
162655
+ }
162656
+ function sessionMark(session) {
162657
+ let mark = () => {
162658
+ };
162659
+ try {
162660
+ if (typeof session.timing === "function") mark = session.timing();
162661
+ } catch {
162579
162662
  }
162580
- return curlOutput(response, values, deps, requestId);
162663
+ return (phase) => {
162664
+ try {
162665
+ mark(phase);
162666
+ } catch {
162667
+ }
162668
+ };
162669
+ }
162670
+ async function closeTimed(session, what) {
162671
+ const mark = sessionMark(session);
162672
+ mark(`${what}-close-start`);
162673
+ await session.close();
162674
+ mark(`${what}-closed`);
162581
162675
  }
162582
162676
  async function curlOutput(response, values, deps, requestId) {
162583
162677
  const io = deps.io;
@@ -162622,8 +162716,18 @@ var INFER_STDIN_MAX_BYTES = 1024 * 1024;
162622
162716
  var INFER_STDIN_EXAMPLE = `echo "Summarize x402 in one line" | ${CLI_WORD} infer - --model qwen3-8-flash`;
162623
162717
  var CURL_USEPOD_NEXT = `use \`${CLI_WORD} infer\` for the AI provider: it sends the prompt only through --tor or --proxy`;
162624
162718
  function unshieldArgs(command2, args) {
162625
- if (args.length === 0 || args.includes("--amount") || !/^(all|[0-9]+(\.[0-9]+)?)$/i.test(args[0])) return args;
162626
- return ["--amount", /^all$/i.test(args[0]) ? "all" : args[0], ...args.slice(1)];
162719
+ if (args.includes("--amount")) return args;
162720
+ const known = new Map(command2.flags.map((entry) => [entry.name, entry]));
162721
+ for (let index = 0; index < args.length; index += 1) {
162722
+ const token = args[index];
162723
+ if (token.startsWith("--")) {
162724
+ if (known.has(token) && !known.get(token).boolean) index += 1;
162725
+ continue;
162726
+ }
162727
+ if (!/^(all|[0-9]+(\.[0-9]+)?)$/i.test(token)) return args;
162728
+ return ["--amount", /^all$/i.test(token) ? "all" : token, ...args.slice(0, index), ...args.slice(index + 1)];
162729
+ }
162730
+ return args;
162627
162731
  }
162628
162732
  function inferArgs(command2, args) {
162629
162733
  const known = new Map(command2.flags.map((entry) => [entry.name, entry]));
@@ -162790,11 +162894,19 @@ async function runInfer(values, deps) {
162790
162894
  }
162791
162895
  } catch (error) {
162792
162896
  if (quiet && !given && !NOTHING_PAID_TEXT.test(String(error?.message ?? ""))) values.set(INFER_STOPPED_ID, requestId);
162897
+ stopWatch();
162898
+ await closeTimed(session, "infer");
162793
162899
  throw error;
162900
+ }
162901
+ stopWatch();
162902
+ try {
162903
+ sessionMark(session)("infer-paid-returned");
162904
+ inferOutput(result, { values, io, model, quiet, requestId });
162794
162905
  } finally {
162795
- stopWatch();
162796
- await session.close();
162906
+ await closeTimed(session, "infer");
162797
162907
  }
162908
+ }
162909
+ function inferOutput(result, { values, io, model, quiet, requestId }) {
162798
162910
  const paid = String(result.paidAtomic ?? "?");
162799
162911
  const paidText = usdcOr(result.paidAtomic);
162800
162912
  const stopped = result.finishReason === "length" ? " (the answer stopped at --max-tokens)" : "";
@@ -163671,10 +163783,10 @@ function agentAppLines({ home, deps, npmVersion, skip = /* @__PURE__ */ new Set(
163671
163783
  }
163672
163784
  return lines.join("\n");
163673
163785
  }
163674
- function setupNextText({ home, deps, npmVersion, config, fundAsked, rerun, inferenceNow, targets = [], added = /* @__PURE__ */ new Set() }) {
163786
+ function setupNextText({ home, deps, npmVersion, config, fundAsked, rerun, targets = [], added = /* @__PURE__ */ new Set() }) {
163675
163787
  const parts = [];
163676
163788
  if (!fundAsked && !rerun) parts.push(fundingStepText());
163677
- if (!rerun || inferenceNow) parts.push(privateInferencePath(config));
163789
+ parts.push(privateInferencePath(config));
163678
163790
  if (targets.some((target) => !added.has(target))) {
163679
163791
  const byHand = hostConfigText({ home, env: deps.env, platform: deps.platform ?? process.platform, npmVersion, skip: added });
163680
163792
  if (byHand) parts.push(`Or add it by hand:
@@ -163682,8 +163794,7 @@ ${byHand}
163682
163794
  `);
163683
163795
  } else if (rerun && !targets.length) {
163684
163796
  parts.push([
163685
- "Your agent app keeps its MCP entry.",
163686
- "To add the wallet to another agent app, run one of these:",
163797
+ "To add the wallet to an agent app, run one of these:",
163687
163798
  ...HOST_TARGETS.map((target) => ` ${cli2()} setup --add-to ${target}`),
163688
163799
  ""
163689
163800
  ].join("\n"));
@@ -163723,10 +163834,21 @@ function recordOwnAddress(home, address5, deps) {
163723
163834
  return [` note your own address was not saved: ${why}`];
163724
163835
  }
163725
163836
  }
163726
- async function offerFundNow(deps, { tor }) {
163837
+ async function offerFundNow(deps, { tor, created }) {
163838
+ const io = deps.io;
163839
+ try {
163840
+ await askFundNow(deps, { tor, created });
163841
+ } catch (error) {
163842
+ if (!(error instanceof QuestionCancelled)) throw error;
163843
+ io.out(`Setup is done; no money was added. To add money later, ask your agent to add funds, or run:
163844
+ ${FUND_COMMAND}
163845
+ `);
163846
+ }
163847
+ }
163848
+ async function askFundNow(deps, { tor, created }) {
163727
163849
  const io = deps.io;
163728
163850
  for (let attempt = 0; attempt < 3; attempt += 1) {
163729
- const answer = String(await deps.ask(attempt === 0 ? "The wallet starts empty. Add money now? Amount in USDC, from 0.01 (press Enter to skip): " : "Add money now? Amount in USDC, from 0.01 (press Enter to skip): ")).trim();
163851
+ const answer = String(await deps.ask(attempt === 0 && created ? "The wallet starts empty. Add money now? Amount in USDC, from 0.01 (press Enter to skip): " : "Add money now? Amount in USDC, from 0.01 (press Enter to skip): ")).trim();
163730
163852
  if (!answer || /^(n|no|skip)$/i.test(answer)) break;
163731
163853
  const atomic4 = usdcToAtomic(answer);
163732
163854
  if (!atomic4 || BigInt(atomic4) < PAY_ME_MIN_ATOMIC) {
@@ -164158,7 +164280,7 @@ async function runSetupCommand(values, deps) {
164158
164280
 
164159
164281
  `);
164160
164282
  const config2 = setupConfigOf(home);
164161
- await offerFundNow(deps, { tor: config2?.tor === true });
164283
+ await offerFundNow(deps, { tor: config2?.tor === true, created: !old });
164162
164284
  const targets2 = values.get("--add-to") ?? [];
164163
164285
  io.out(setupNextText({
164164
164286
  home,
@@ -164167,7 +164289,6 @@ async function runSetupCommand(values, deps) {
164167
164289
  config: config2,
164168
164290
  fundAsked: true,
164169
164291
  rerun: values.get(SETUP_RERUN) === "settings",
164170
- inferenceNow: privateInference === true && (!old || old.inference?.enabled !== true),
164171
164292
  targets: targets2,
164172
164293
  added: new Set(targets2)
164173
164294
  }));
@@ -164228,15 +164349,14 @@ Copy it to two offline places now; it is the only way to restore this wallet.
164228
164349
  const targets = values.get("--add-to") ?? [];
164229
164350
  const added = targets.length ? addToHosts(targets, home, deps, { force: values.has("--force"), npmVersion }) : /* @__PURE__ */ new Set();
164230
164351
  const config = setupConfigOf(home);
164231
- const inferenceNow = summary.privateInference === true && (!rerun || old?.inference?.enabled !== true);
164232
164352
  if (inProxiedRun(deps.env) && deps.env[SETUP_NEXT_BY_PARENT_ENV] === "1") {
164233
164353
  if (targets.some((target) => !added.has(target))) {
164234
- io.out(setupNextText({ home, deps, npmVersion, config, fundAsked: true, rerun: true, inferenceNow: false, targets, added }));
164354
+ io.out(setupNextText({ home, deps, npmVersion, config, fundAsked: true, rerun: true, targets, added }));
164235
164355
  }
164236
164356
  return void 0;
164237
164357
  }
164238
- if (interactive) await offerFundNow(deps, { tor: config?.tor === true });
164239
- io.out(setupNextText({ home, deps, npmVersion, config, fundAsked: interactive, rerun, inferenceNow, targets, added }));
164358
+ if (interactive) await offerFundNow(deps, { tor: config?.tor === true, created: !old });
164359
+ io.out(setupNextText({ home, deps, npmVersion, config, fundAsked: interactive, rerun, targets, added }));
164240
164360
  }
164241
164361
  async function confirmAboveBalanceCap(deps, atomic4) {
164242
164362
  if (BigInt(atomic4) <= MAX_SHIELDED_BALANCE_ATOMIC) return true;
@@ -164881,6 +165001,8 @@ var COMMANDS = [
164881
165001
  flag2("--data-file", "<file>", "the request body from a file (POST)"),
164882
165002
  flag2("--out", "<file>", "-o: write the answer to this private file (mode 600) instead of stdout"),
164883
165003
  bool2("--include", "-i: print the HTTP status line and headers before the body (a paid answer has status 200 and the x-shinjuku-payment receipt header)"),
165004
+ // CU1 (mcp56, published 0.3.101): a terminal curl printed the 4-line "history: ..." paragraph before the pay question.
165005
+ bool2("--verbose", "in a terminal, also show the wallet's own progress lines (Tor, the RPC relay, the pool history, the memo reads); without it a terminal shows only the price question, the answer, and what it paid"),
164884
165006
  flag2("--request-id", "<id>", "your stable name for this request; default curl-<random>, printed on stderr before any payment. Rerun with the same id to resume a stopped run: it never pays twice"),
164885
165007
  ...payerSessionFlags()
164886
165008
  ],
@@ -164903,6 +165025,7 @@ var COMMANDS = [
164903
165025
  nextInOutput: true,
164904
165026
  normalizeArgs: curlArgs,
164905
165027
  validate: validateCurl,
165028
+ quietProgress: (values, deps) => terminalQuiet(values, deps),
164906
165029
  run: (args, values, deps, io) => deps.curlMain(values, { ...deps, io })
164907
165030
  },
164908
165031
  {
@@ -165171,8 +165294,10 @@ var COMMANDS = [
165171
165294
  next: SETUP_NEXT,
165172
165295
  // Printed as "Next: ..." after a run (the runner's label), as the help page prints it.
165173
165296
  nextLabel: "Next",
165174
- // A rerun of a complete setup (SETUP_RERUN): the agent app already has the entry.
165175
- nextAfterRun: (values) => values.get(SETUP_RERUN) === "settings" ? 'close and open your agent app so it starts the wallet with these settings, then ask "what is my balance".' : values.get(SETUP_RERUN) === "own-address" ? "ask your agent to send money to your own address: it sends without asking you each time." : SETUP_NEXT,
165297
+ // A rerun of a complete setup (SETUP_RERUN): it cannot tell whether an agent app has the entry (0.3.101 live pass).
165298
+ nextAfterRun: (values) => values.get(SETUP_RERUN) === "settings" ? `chat privately with an AI in this terminal:
165299
+ ${CLI_WORD} chat
165300
+ If an agent app already runs the wallet, close and open it so it reads these settings.` : values.get(SETUP_RERUN) === "own-address" ? "ask your agent to send money to your own address: it sends without asking you each time." : SETUP_NEXT,
165176
165301
  // In a terminal its progress lines (tor:, rpc:, history:) show only with --verbose; Tor trouble shows in plain words
165177
165302
  // (inference/chat.mjs hideProgressLines). Live run 2026-10-24 08:26 UTC (npm 0.3.97, laptop, Tor on): setup printed
165178
165303
  // the raw onion line "tor: the onion ... gave no answer (the stream failed); its requests move to ...". The Tor run's
@@ -166179,7 +166304,7 @@ async function askUnshield(args, values, deps) {
166179
166304
  deps.io.err(`${why}
166180
166305
  `);
166181
166306
  }
166182
- throw new PublicFailure(`unshield_declined: three answers were not usable, so nothing was sent. To send, run:
166307
+ throw new AnswerDeclined("unshield_declined", `three answers were not usable, so nothing was sent. To send, run:
166183
166308
  ${cli2()} unshield`);
166184
166309
  };
166185
166310
  const out = [...args];
@@ -166206,16 +166331,31 @@ async function askUnshield(args, values, deps) {
166206
166331
  }
166207
166332
  let whole;
166208
166333
  if (values.get("--amount") === "all") {
166334
+ const open4 = () => (deps.openWalletStore ?? openWalletStore)(resolve39(values.get("--wallet")), payerPassphrase(values, deps));
166335
+ let store;
166209
166336
  try {
166210
- whole = savedBalance((deps.openWalletStore ?? openWalletStore)(resolve39(values.get("--wallet")), payerPassphrase(values, deps)));
166337
+ store = open4();
166338
+ whole = savedBalance(store);
166211
166339
  } catch {
166212
166340
  whole = void 0;
166213
166341
  }
166342
+ const refreshArgs = !whole && store ? homeRefreshArgs(store, deps) : void 0;
166343
+ if (refreshArgs) {
166344
+ deps.io.err("Reading your private balance from the chain, so the question names the amount...\n");
166345
+ const silent = { out: () => {
166346
+ }, err: () => {
166347
+ } };
166348
+ try {
166349
+ if (await runShinjukuWallet(["balance", ...refreshArgs], { ...deps, io: silent }) === 0) whole = savedBalance(open4());
166350
+ } catch {
166351
+ whole = void 0;
166352
+ }
166353
+ }
166214
166354
  }
166215
- const wholeWords = !whole ? "" : whole.current ? ` (${usdcOr(whole.atomic.toString())})` : ` (about ${usdcOr(whole.atomic.toString())} at its last read)`;
166355
+ const wholeWords = !whole ? ` (its amount could not be read now; answer n and run ${cli2()} balance to see it)` : whole.current ? ` (${usdcOr(whole.atomic.toString())})` : ` (about ${usdcOr(whole.atomic.toString())} at its last read)`;
166216
166356
  const what = values.get("--amount") === "all" ? `your whole private balance${wholeWords}` : `${usdcText3(values.get("--amount"))} USDC`;
166217
166357
  const answer = String(await deps.ask(`Send ${what} to ${values.get("--to")}? [y/N] `)).trim();
166218
- if (!/^y(es)?$/i.test(answer)) throw new PublicFailure(`unshield_declined: you did not answer y, so nothing was sent. To send, run:
166358
+ if (!/^y(es)?$/i.test(answer)) throw new AnswerDeclined("unshield_declined", `you did not answer y, so nothing was sent. To send, run:
166219
166359
  ${cli2()} unshield`);
166220
166360
  return out;
166221
166361
  }
@@ -167651,8 +167791,8 @@ function floatFailureHint(reason, floatError) {
167651
167791
  if (/p03_float_answer_invalid_refund_pending/.test(reason)) {
167652
167792
  return "Shinjuku was paid, but its answer held no valid payment for this seller, so nothing went to the seller. Refund of the amount paid (price + fee) on the way (up to about 7 min). Nothing more to do";
167653
167793
  }
167654
- if (/p03_float_busy_retry_later/.test(reason)) return "nothing was paid: Shinjuku's shared float is busy right now. Rerun the same command in about 30 seconds";
167655
- if (/p03_float_not_ready_retry_later/.test(reason)) return "nothing was paid: Shinjuku's shared float is not ready yet (it is being filled). Rerun the same command in about a minute";
167794
+ if (/p03_float_busy_retry_later/.test(reason)) return "nothing was paid: Shinjuku's payment service is busy right now. Rerun the same command in about 30 seconds";
167795
+ if (/p03_float_not_ready_retry_later/.test(reason)) return "nothing was paid: Shinjuku's payment service is not ready right now. Rerun the same command in about a minute";
167656
167796
  if (/p03_float_payment_in_flight_retry_later/.test(reason)) return "nothing was paid: an earlier quote for this payment is still open at Shinjuku. Rerun the same command in about a minute";
167657
167797
  if (/p03_float_price_above_capacity/.test(reason)) {
167658
167798
  return `nothing was paid: the seller's price is above the largest price Shinjuku pays for one request now (largestAtomic in ${config}). Pay a cheaper seller, or try again later`;
@@ -167661,10 +167801,10 @@ function floatFailureHint(reason, floatError) {
167661
167801
  return `nothing was paid: the seller's price plus the Shinjuku fee (feeAtomic in ${config}; 1000 = 0.001 USDC) is above your maximum (--maximum-atomic or --max-payment). Rerun with a maximum of at least price + fee`;
167662
167802
  }
167663
167803
  if (/p03_float_seller_uses_our_facilitator/.test(reason)) {
167664
- return "nothing was paid: this seller's exact offer settles through Shinjuku's own pocket facilitator, which cannot take a payment from the shared float. Ask the seller for its shielded-exact offer: the wallet pays that one first";
167804
+ return "nothing was paid: this seller's exact offer settles through Shinjuku's own pocket facilitator, which cannot take a payment from Shinjuku's payment service. Ask the seller for its shielded-exact offer: the wallet pays that one first";
167665
167805
  }
167666
167806
  if (/p03_float_not_offered/.test(reason)) {
167667
- return "nothing was paid: the facilitator (--memo-service) does not run float pay, so a seller that takes only standard exact cannot be paid through it. Use the facilitator of this wallet's pool";
167807
+ return "nothing was paid: the facilitator (--memo-service) does not run Shinjuku's payment service, so a seller that takes only standard exact cannot be paid through it. Use the facilitator of this wallet's pool";
167668
167808
  }
167669
167809
  if (/p03_float_config_unreadable/.test(reason)) return `nothing was paid: ${config} did not answer, or its answer is not valid. Rerun the same command later`;
167670
167810
  if (/p03_float_config_mismatch/.test(reason)) return "nothing was paid: the facilitator's float runs on another network or token than this wallet's pool. Use the facilitator of this wallet's pool";
@@ -167840,6 +167980,7 @@ function defaultDependencies() {
167840
167980
  * what happened. Ctrl-C, or an input that ends, now stops the command with QuestionCancelled (one plain line).
167841
167981
  */
167842
167982
  ask: (question) => new Promise((resolveAnswer, rejectAnswer) => {
167983
+ const releaseProgress = holdProgressLines(process.stderr);
167843
167984
  const prompt = createInterface2({ input: process.stdin, output: process.stderr, terminal: true });
167844
167985
  let answered2 = false;
167845
167986
  let interrupted = false;
@@ -167849,6 +167990,7 @@ function defaultDependencies() {
167849
167990
  prompt.close();
167850
167991
  });
167851
167992
  prompt.on("close", () => {
167993
+ releaseProgress();
167852
167994
  if (!answered2) rejectAnswer(new QuestionCancelled(interrupted));
167853
167995
  });
167854
167996
  prompt.question(question, (answer) => {
@@ -167957,6 +168099,7 @@ function strayWordIn(command2, args) {
167957
168099
  }
167958
168100
  async function runShinjukuWallet(argv2, overrides = {}) {
167959
168101
  const deps = { ...defaultDependencies(), ...overrides };
168102
+ const endsProcess = Object.keys(overrides).length === 0;
167960
168103
  setCommandVersionSource(() => deps.walletVersion().npm);
167961
168104
  const rawIo = deps.io;
167962
168105
  deps.io = { ...rawIo, out: (text3) => rawIo.out(fillCommandWords(text3)), err: (text3) => rawIo.err(fillCommandWords(text3)) };
@@ -168080,6 +168223,8 @@ This copy: ${walletVersionLine(deps.walletVersion())}
168080
168223
  writeRunResult(deps, command2, 0);
168081
168224
  return 0;
168082
168225
  } catch (error) {
168226
+ if (endsProcess) showProgressAgain = () => {
168227
+ };
168083
168228
  if (error instanceof RanBehindTorFailed) return error.exitCode;
168084
168229
  if (error instanceof UsageError) {
168085
168230
  let setUp = false;
@@ -168108,6 +168253,11 @@ This copy: ${walletVersionLine(deps.walletVersion())}
168108
168253
  }
168109
168254
  if (error instanceof QuestionCancelled) {
168110
168255
  io.err(`${CLI} ${command2.name} ${error.message}
168256
+ `);
168257
+ return 1;
168258
+ }
168259
+ if (error instanceof AnswerDeclined) {
168260
+ io.err(`${CLI} ${command2.name} stopped: ${error.plain}
168111
168261
  `);
168112
168262
  return 1;
168113
168263
  }