shinjuku-shield 0.3.206 → 0.3.207
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 +4 -4
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +81 -9
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ web services and AI answers from your private balance, so the payment does
|
|
|
5
5
|
not show who paid. It works inside your AI app (Claude, Cursor, Codex) and in
|
|
6
6
|
a terminal. Only you hold the keys: they never leave your computer.
|
|
7
7
|
|
|
8
|
-
This is version 0.3.
|
|
8
|
+
This is version 0.3.207. The command is `shinjuku`.
|
|
9
9
|
|
|
10
10
|
## Set up
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
npx -y shinjuku@0.3.
|
|
13
|
+
npx -y shinjuku@0.3.207 setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Setup does every step for you:
|
|
@@ -100,7 +100,7 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
|
|
|
100
100
|
Claude Code:
|
|
101
101
|
|
|
102
102
|
```sh
|
|
103
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
103
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.207 mcp
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
## For builders: check what you install
|
|
@@ -116,7 +116,7 @@ with the Releases table in
|
|
|
116
116
|
Versions are published from GitHub Actions with npm provenance.
|
|
117
117
|
|
|
118
118
|
`shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
|
|
119
|
-
0.3.
|
|
119
|
+
0.3.207, its older name, runs this package at the same version, so wallets
|
|
120
120
|
installed under that name keep updating. New installs use `shinjuku`.
|
|
121
121
|
|
|
122
122
|
The full guide is
|
package/manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "carbon-shielded-wallet/bundle-manifest/v1",
|
|
3
3
|
"file": "shinjuku-wallet.mjs",
|
|
4
|
-
"sha256": "
|
|
5
|
-
"bytes":
|
|
6
|
-
"sourceCommit": "
|
|
4
|
+
"sha256": "cb3d8f7da30834d0d6bb95942a06afe07b394be9ad6f48bc19fff3718d4a05cc",
|
|
5
|
+
"bytes": 9504181,
|
|
6
|
+
"sourceCommit": "33356a03d0762d4617688d52566d63099ca90f39",
|
|
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",
|
|
@@ -1932,5 +1932,5 @@
|
|
|
1932
1932
|
}
|
|
1933
1933
|
]
|
|
1934
1934
|
},
|
|
1935
|
-
"publishedAt": "2026-11-
|
|
1935
|
+
"publishedAt": "2026-11-10T08:03:21.693Z"
|
|
1936
1936
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.207",
|
|
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": "
|
|
7
|
-
"shinjukuSha256": "
|
|
6
|
+
"shinjukuRelease": "cb3d8f7d",
|
|
7
|
+
"shinjukuSha256": "cb3d8f7da30834d0d6bb95942a06afe07b394be9ad6f48bc19fff3718d4a05cc",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shield",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -48437,6 +48437,20 @@ function relayLimitWords(state2 = relayLimitNow(), { now = Date.now(), ownRpc }
|
|
|
48437
48437
|
}[state2.reason];
|
|
48438
48438
|
return `Shinjuku's free Solana chain reader ${what}. It did not pass this step's request to the Solana network.` + (ownRpc ? ` To go on now, ${ownRpc}.` : "");
|
|
48439
48439
|
}
|
|
48440
|
+
function relayLimitStateOf(error, now = Date.now()) {
|
|
48441
|
+
for (let link3 = error, depth = 0; link3 && depth < 8; depth += 1) {
|
|
48442
|
+
if (REASONS.has(link3.relayReason) && Number.isSafeInteger(link3.opensAtMs) && link3.opensAtMs > now) return { reason: link3.relayReason, opensAtMs: link3.opensAtMs };
|
|
48443
|
+
link3 = link3 instanceof Error ? link3.cause : void 0;
|
|
48444
|
+
}
|
|
48445
|
+
return relayLimitNow(now);
|
|
48446
|
+
}
|
|
48447
|
+
function relayLimitShortWords(state2 = relayLimitNow(), { now = Date.now() } = {}) {
|
|
48448
|
+
if (!state2) return void 0;
|
|
48449
|
+
const left = waitWords(state2.opensAtMs - now);
|
|
48450
|
+
if (state2.reason === "relay_budget_unavailable") return `Shinjuku's free Solana chain reader could not count its use for a moment. Ask again in about ${left}.`;
|
|
48451
|
+
const when = state2.reason === "relay_daily_limit" ? "today" : "this hour";
|
|
48452
|
+
return `Shinjuku's free Solana chain reader is full for ${when}. It opens again at ${clockWords(state2.opensAtMs)} (in about ${left}). Ask again then.`;
|
|
48453
|
+
}
|
|
48440
48454
|
function relayLimitError(state2, now) {
|
|
48441
48455
|
const seconds2 = Math.max(1, Math.ceil((state2.opensAtMs - now) / 1e3));
|
|
48442
48456
|
return Object.assign(
|
|
@@ -48451,7 +48465,7 @@ function isRelayLimitError(error) {
|
|
|
48451
48465
|
}
|
|
48452
48466
|
return false;
|
|
48453
48467
|
}
|
|
48454
|
-
var REASONS, RELAY_BUDGET_RETRY_MAX_SECONDS, fallbackSeconds, BUDGET_PAUSE_MAX_SECONDS, closed, waitWords, clockWords;
|
|
48468
|
+
var REASONS, RELAY_BUDGET_RETRY_MAX_SECONDS, fallbackSeconds, BUDGET_PAUSE_MAX_SECONDS, closed, waitWords, clockWords, relayLimitSeconds;
|
|
48455
48469
|
var init_relayLimit = __esm({
|
|
48456
48470
|
"wallet/src/net/relayLimit.mjs"() {
|
|
48457
48471
|
"use strict";
|
|
@@ -48470,6 +48484,7 @@ var init_relayLimit = __esm({
|
|
|
48470
48484
|
return minutes >= 60 ? `${Math.floor(minutes / 60)} h ${minutes % 60} min` : `${minutes} min`;
|
|
48471
48485
|
};
|
|
48472
48486
|
clockWords = (ms) => `${new Date(Math.ceil(ms / 6e4) * 6e4).toISOString().slice(11, 16)} UTC`;
|
|
48487
|
+
relayLimitSeconds = (state2, now = Date.now()) => state2 ? Math.max(1, Math.ceil((state2.opensAtMs - now) / 1e3)) : void 0;
|
|
48473
48488
|
}
|
|
48474
48489
|
});
|
|
48475
48490
|
|
|
@@ -113310,10 +113325,10 @@ async function everyAccountHeld({ store, connection, programId, serviceUrl: serv
|
|
|
113310
113325
|
function assertAccountsNotSplit({ accounts, account, notes, allNotes = notes, amountAtomic }) {
|
|
113311
113326
|
const atomicOf = (entries, key) => entries.reduce((sum2, entry) => sum2 + BigInt(entry[key].b), 0n);
|
|
113312
113327
|
if (accounts.length > 1 && BigInt(account.account.b) + atomicOf(notes, "note") < BigInt(amountAtomic) && atomicOf(accounts, "account") + atomicOf(allNotes, "note") >= BigInt(amountAtomic)) {
|
|
113313
|
-
throw new Error(
|
|
113328
|
+
throw Object.assign(new Error(
|
|
113314
113329
|
"p03_merchant_respend_insufficient_recovered_value",
|
|
113315
113330
|
{ cause: new Error("p03_merchant_respend_accounts_split_merge_first") }
|
|
113316
|
-
);
|
|
113331
|
+
), { splitAmountAtomic: BigInt(amountAtomic).toString() });
|
|
113317
113332
|
}
|
|
113318
113333
|
}
|
|
113319
113334
|
async function prepareRecoveredPayment({
|
|
@@ -116365,8 +116380,8 @@ function refusalSay(a, tool, again, npmVersion) {
|
|
|
116365
116380
|
const Seller = `${seller[0].toUpperCase()}${seller.slice(1)}`;
|
|
116366
116381
|
const data = tool === "inference_chat" ? "answer" : "data";
|
|
116367
116382
|
if (/^rpc_relay_limit\b/.test(code2)) {
|
|
116368
|
-
const
|
|
116369
|
-
return
|
|
116383
|
+
const state2 = Number.isSafeInteger(a.relayOpensAtMs) && typeof a.relayReason === "string" ? { reason: a.relayReason, opensAtMs: a.relayOpensAtMs } : relayLimitNow();
|
|
116384
|
+
return relayLimitShortWords(state2) ?? "Shinjuku's free Solana chain reader reached its limit for now. Ask again later.";
|
|
116370
116385
|
}
|
|
116371
116386
|
if (code2 === "mcp_max_payment_not_usdc") {
|
|
116372
116387
|
const cap = usdcText2(a.capAtomic);
|
|
@@ -125273,6 +125288,28 @@ function joinPlanSize(outputs, exitReserved = /* @__PURE__ */ new Set(), held2)
|
|
|
125273
125288
|
})];
|
|
125274
125289
|
}
|
|
125275
125290
|
}
|
|
125291
|
+
function oneSpendCovers(store, amountAtomic) {
|
|
125292
|
+
try {
|
|
125293
|
+
const snapshotRead = readBalanceSnapshot(store);
|
|
125294
|
+
const snapshot = snapshotRead.snapshot;
|
|
125295
|
+
if (!snapshot || snapshot.pool !== store.state.pool || !Array.isArray(snapshot.outputs)) return false;
|
|
125296
|
+
const sendHeld = savedSendHold({ store, snapshotRead });
|
|
125297
|
+
if (sendHeld === null) return false;
|
|
125298
|
+
const key = (commitment) => BigInt(commitment).toString();
|
|
125299
|
+
const joinHeld = /* @__PURE__ */ new Set();
|
|
125300
|
+
for (const { record } of mergeRecords(store)) {
|
|
125301
|
+
if (!openJoin(record)) continue;
|
|
125302
|
+
joinHeld.add(key(record.mergeAccountCommitment));
|
|
125303
|
+
for (const note of record.mergeNoteCommitments ?? []) joinHeld.add(key(note));
|
|
125304
|
+
}
|
|
125305
|
+
const exitReserved = exitReservedNoteCommitments(store);
|
|
125306
|
+
const free = snapshot.outputs.filter((output2) => output2.spendStatus === "unspent" && !joinHeld.has(key(output2.commitment)) && !(output2.kind === "account" ? sendHeld.accounts : sendHeld.notes).has(String(output2.commitment)) && !(output2.kind === "note" && exitReserved.has(key(output2.commitment))));
|
|
125307
|
+
const most = largestOneSpend(free);
|
|
125308
|
+
return most !== void 0 && most >= BigInt(amountAtomic);
|
|
125309
|
+
} catch {
|
|
125310
|
+
return false;
|
|
125311
|
+
}
|
|
125312
|
+
}
|
|
125276
125313
|
function joinParts(store, snapshotRead) {
|
|
125277
125314
|
try {
|
|
125278
125315
|
const read = snapshotRead ?? readBalanceSnapshot(store);
|
|
@@ -138951,12 +138988,18 @@ ${canonical5}`;
|
|
|
138951
138988
|
return void 0;
|
|
138952
138989
|
}
|
|
138953
138990
|
const readyInSecondsOf = (error, code2) => FLOAT_BUSY_CODES.has(code2) ? Number.isFinite(error?.retryAfterSeconds) && error.retryAfterSeconds > 0 ? Math.ceil(error.retryAfterSeconds) : code2 === "p03_float_busy_retry_later" ? 30 : 60 : code2 === "p03_float_config_unreadable" ? 60 : void 0;
|
|
138991
|
+
function splitAmountOf(error) {
|
|
138992
|
+
for (let at = error, depth = 0; at && depth < 6; at = at.cause, depth += 1) {
|
|
138993
|
+
if (ATOMIC_TEXT.test(String(at.splitAmountAtomic ?? ""))) return String(at.splitAmountAtomic);
|
|
138994
|
+
}
|
|
138995
|
+
return void 0;
|
|
138996
|
+
}
|
|
138954
138997
|
function joinHolds(error, code2) {
|
|
138955
138998
|
if (insufficientCause(describeError(error, { fallback: "mcp_payment_failed", safeText: SAFE_TEXT })) === "split") return true;
|
|
138956
138999
|
const blocking = error?.blockingRequestId ?? error?.cause?.blockingRequestId;
|
|
138957
139000
|
return /another_request_unresolved$/.test(code2) && typeof blocking === "string" && /^unshield-merge-/.test(blocking);
|
|
138958
139001
|
}
|
|
138959
|
-
async function payJoin2({ requestId, calledAt, progress: progress2, canProgress, signal }) {
|
|
139002
|
+
async function payJoin2({ requestId, calledAt, progress: progress2, canProgress, signal, amountAtomic }) {
|
|
138960
139003
|
const asked = joiner.request({ key: sha256Hex2(Buffer.from(`x402_pay:${requestId}`, "utf8")) });
|
|
138961
139004
|
if (!asked.joining) return { join: { joining: false } };
|
|
138962
139005
|
if (asked.first && canProgress) return { join: { joining: true, first: true } };
|
|
@@ -138968,6 +139011,15 @@ ${canonical5}`;
|
|
|
138968
139011
|
let end2;
|
|
138969
139012
|
try {
|
|
138970
139013
|
end2 = await joinLoop({ until, signal, onReady: () => true, each: () => {
|
|
139014
|
+
if (amountAtomic !== void 0) {
|
|
139015
|
+
let store;
|
|
139016
|
+
try {
|
|
139017
|
+
store = session.openStore();
|
|
139018
|
+
} catch {
|
|
139019
|
+
store = void 0;
|
|
139020
|
+
}
|
|
139021
|
+
if (store && oneSpendCovers(store, amountAtomic)) return { stop: "covered" };
|
|
139022
|
+
}
|
|
138971
139023
|
try {
|
|
138972
139024
|
progress2("getting your balance ready to pay, then the payment; nothing was paid yet");
|
|
138973
139025
|
} catch {
|
|
@@ -138982,8 +139034,9 @@ ${canonical5}`;
|
|
|
138982
139034
|
seen.moved ||= joinCounts.final > before.final || joinCounts.sent > before.sent;
|
|
138983
139035
|
payJoinSeen.set(requestId, seen);
|
|
138984
139036
|
const late2 = end2.end === "stop" && canProgress && Date.now() + PAY_AFTER_JOIN_MS > calledAt + joinCallMaxMs;
|
|
138985
|
-
|
|
138986
|
-
|
|
139037
|
+
const covered = end2.end === "stop" && end2.value === "covered";
|
|
139038
|
+
line(end2.end === "stop" ? `${late2 ? "ready-late" : "ready"}${covered ? " covered=1" : ""}` : end2.end);
|
|
139039
|
+
if (end2.end === "stop" && !late2) return { ready: true, covered };
|
|
138987
139040
|
return { join: {
|
|
138988
139041
|
joining: true,
|
|
138989
139042
|
joinsDone: seen.joinsDone,
|
|
@@ -139094,6 +139147,7 @@ ${canonical5}`;
|
|
|
139094
139147
|
let askUnshown = false;
|
|
139095
139148
|
let retriedInCall = false;
|
|
139096
139149
|
let joinedInCall = false;
|
|
139150
|
+
let coveredJoin = false;
|
|
139097
139151
|
for (let attempt = 0; response === void 0; attempt += 1) {
|
|
139098
139152
|
try {
|
|
139099
139153
|
response = await (attempt === 0 && first ? first : payOnce());
|
|
@@ -139155,7 +139209,9 @@ ${canonical5}`;
|
|
|
139155
139209
|
if (replaced) return replaced;
|
|
139156
139210
|
let join51;
|
|
139157
139211
|
if (joinHolds(error, code2)) {
|
|
139158
|
-
const
|
|
139212
|
+
const again2 = joinedInCall && coveredJoin;
|
|
139213
|
+
const joined = joinedInCall && !again2 ? { join: { joining: true } } : await payJoin2({ requestId, calledAt, progress: progress2, canProgress, signal, amountAtomic: again2 ? void 0 : splitAmountOf(error) });
|
|
139214
|
+
coveredJoin = !again2 && joined.covered === true;
|
|
139159
139215
|
joinedInCall = true;
|
|
139160
139216
|
if (joined.ready) {
|
|
139161
139217
|
payJoinSeen.delete(requestId);
|
|
@@ -139862,6 +139918,22 @@ ${canonical5}`;
|
|
|
139862
139918
|
next = "nothing was paid. Tell the user this seller's price terms are in an older or broken form this wallet cannot read. Do not retry this URL unchanged; find_paid_services finds sellers this wallet can pay";
|
|
139863
139919
|
} else if (code2.startsWith("wallet_quote_refused_") || code2.startsWith("fetch_")) {
|
|
139864
139920
|
next = inference ? "nothing was paid; do not call inference_chat again unchanged" : code2.startsWith("wallet_quote_refused_") ? "nothing was paid; do not pay this URL. Pay a different seller (find_paid_services finds one)" : "nothing was paid; do not retry this URL unchanged";
|
|
139921
|
+
} else if (code2 === "rpc_relay_limit" || isRelayLimitError(error)) {
|
|
139922
|
+
const state2 = relayLimitStateOf(error);
|
|
139923
|
+
const seconds2 = relayLimitSeconds(state2);
|
|
139924
|
+
const short = relayLimitShortWords(state2) ?? "Shinjuku's free Solana chain reader reached its limit for now. Ask again later.";
|
|
139925
|
+
const again2 = inference ? resume : `call ${tool} again with request_id "${requestId}" (it never pays twice)`;
|
|
139926
|
+
return refuse11(
|
|
139927
|
+
"rpc_relay_limit",
|
|
139928
|
+
`the payment did not finish: ${relayLimitWords(state2) ?? reasonOf("rpc_relay_limit")}`,
|
|
139929
|
+
`The free chain reader stopped this step before it reached the Solana network. Tell the user: ${short} Do not call ${tool} again before then${seconds2 ? ` (wait at least ${seconds2} s)` : ""}: a call before then meets the same limit. Then ${again2}, or close an unsent payment with wallet_cancel request_id "${requestId}"; wallet_receipts lists it if it was paid`,
|
|
139930
|
+
{
|
|
139931
|
+
requestId,
|
|
139932
|
+
...fields,
|
|
139933
|
+
...seconds2 ? { readyInSeconds: seconds2 } : {},
|
|
139934
|
+
...state2 ? { relayReason: state2.reason, relayOpensAtMs: state2.opensAtMs } : {}
|
|
139935
|
+
}
|
|
139936
|
+
);
|
|
139865
139937
|
} else {
|
|
139866
139938
|
next = inference ? `the outcome is not known to be final: ${resume}. Or close an unsent payment with wallet_cancel request_id "${requestId}"; wallet_receipts lists it if it was paid` : `the outcome is not known to be final: call pay_for_service again with request_id "${requestId}" (it never pays twice), or close an unsent payment with wallet_cancel request_id "${requestId}"; wallet_receipts lists it if it was paid`;
|
|
139867
139939
|
}
|