shinjuku-shield 0.3.227 → 0.3.229
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 +173 -37
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.229. The command is `shinjuku`.
|
|
9
9
|
|
|
10
10
|
## Set up
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
npx -y shinjuku
|
|
13
|
+
npx -y shinjuku 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 --prefer-offline --no-audit --no-fund shinjuku-shield@0.3.
|
|
103
|
+
claude mcp add --scope user shinjuku -- npx -y --prefer-offline --no-audit --no-fund shinjuku-shield@0.3.229 mcp
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
`--prefer-offline` runs the copy of the wallet that npm saved. If npm has not saved it yet, that start asks
|
|
@@ -119,7 +119,7 @@ with the Releases table in
|
|
|
119
119
|
Versions are published from GitHub Actions with npm provenance.
|
|
120
120
|
|
|
121
121
|
`shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
|
|
122
|
-
0.3.
|
|
122
|
+
0.3.229, its older name, runs this package at the same version, so wallets
|
|
123
123
|
installed under that name keep updating. New installs use `shinjuku`.
|
|
124
124
|
|
|
125
125
|
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": "d1859cdae27b3112ecce9c30b41b832a39f01811e03dfb37270eb692e5ddbce2",
|
|
5
|
+
"bytes": 10368772,
|
|
6
|
+
"sourceCommit": "bc9e53c0e6262813cb57e818644f7ac92abbcae2",
|
|
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",
|
|
@@ -1968,5 +1968,5 @@
|
|
|
1968
1968
|
}
|
|
1969
1969
|
]
|
|
1970
1970
|
},
|
|
1971
|
-
"publishedAt": "2026-11-
|
|
1971
|
+
"publishedAt": "2026-11-13T00:32:13.475Z"
|
|
1972
1972
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.229",
|
|
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": "d1859cda",
|
|
7
|
+
"shinjukuSha256": "d1859cdae27b3112ecce9c30b41b832a39f01811e03dfb37270eb692e5ddbce2",
|
|
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
|
@@ -57969,11 +57969,11 @@ function updateCommandLine(words2, npmVersion) {
|
|
|
57969
57969
|
const version3 = knownNpmVersion(npmVersion);
|
|
57970
57970
|
return `take the newest version in the Releases table at ${RELEASES_URL} and run ${["npx", "-y", ...NPX_INSTALL_FLAGS, `${NPX_PACKAGE}@<that version>`, words2].filter(Boolean).join(" ")}` + (version3 ? ` (only a version newer than ${version3}, the one that runs now, is an update)` : "");
|
|
57971
57971
|
}
|
|
57972
|
-
function installCommandText(
|
|
57973
|
-
return ["npm", "install", "-g", ...NPX_INSTALL_FLAGS,
|
|
57972
|
+
function installCommandText() {
|
|
57973
|
+
return ["npm", "install", "-g", ...NPX_INSTALL_FLAGS, COMMAND_PACKAGE].join(" ");
|
|
57974
57974
|
}
|
|
57975
|
-
function terminalUseLines(
|
|
57976
|
-
return ["To type shinjuku balance and the other commands in a terminal, install the shinjuku command once:", ` ${installCommandText(
|
|
57975
|
+
function terminalUseLines() {
|
|
57976
|
+
return ["To type shinjuku balance and the other commands in a terminal, install the shinjuku command once:", ` ${installCommandText()}`];
|
|
57977
57977
|
}
|
|
57978
57978
|
function mcpServerEntry({ home, platform = process.platform, npmVersion, path, tor } = {}) {
|
|
57979
57979
|
const npx = ["npx", "-y", ...NPX_INSTALL_FLAGS, ...npmPrefixArgs(home, platform), npxPackageWord(npmVersion), "mcp"];
|
|
@@ -59976,7 +59976,7 @@ function agentCommandLine(words2, { npmVersion = ownNpmVersion(), code: code2 =
|
|
|
59976
59976
|
const other = installedCommand({ env, platform });
|
|
59977
59977
|
if (other?.version && other.name !== COMMAND_PACKAGE) return mark(oneTimeCommandLine(words2, npmVersion).trimEnd());
|
|
59978
59978
|
if (windowsNpmFolderOffPath({ env, platform })) return mark(oneTimeCommandLine(words2, npmVersion).trimEnd());
|
|
59979
|
-
return `${mark(installCommandText(
|
|
59979
|
+
return `${mark(installCommandText())} once (it installs the ${COMMAND_PACKAGE} command), then ${line}`;
|
|
59980
59980
|
}
|
|
59981
59981
|
function windowsNpmFolderOffPath({ env = process.env, platform = process.platform } = {}) {
|
|
59982
59982
|
if (platform !== "win32") return null;
|
|
@@ -59995,7 +59995,7 @@ function terminalUseLinesHere(npmVersion, options = {}) {
|
|
|
59995
59995
|
` ${oneTimeCommandLine("balance", npmVersion)}`
|
|
59996
59996
|
];
|
|
59997
59997
|
}
|
|
59998
|
-
if (!windowsNpmFolderOffPath(options)) return terminalUseLines(
|
|
59998
|
+
if (!windowsNpmFolderOffPath(options)) return terminalUseLines();
|
|
59999
59999
|
return [
|
|
60000
60000
|
"This Windows account does not find commands that npm installs, so type the longer command, for example:",
|
|
60001
60001
|
` ${oneTimeCommandLine("balance", npmVersion)}`
|
|
@@ -60074,7 +60074,7 @@ function olderInstalledCommand(npmVersion = ownNpmVersion(), options = {}) {
|
|
|
60074
60074
|
installed: found.version,
|
|
60075
60075
|
current: npmVersion,
|
|
60076
60076
|
plain,
|
|
60077
|
-
line: plain ? installCommandText(
|
|
60077
|
+
line: plain ? installCommandText() : oneTimeCommandLine("setup", npmVersion)
|
|
60078
60078
|
};
|
|
60079
60079
|
}
|
|
60080
60080
|
var versionSource, ownNpmVersion, runningNpmVersion, NPM_RUN_FOLDER, isRunnable, kept, keptSame, folderKey2, pathStepSaid, scriptsBlocked, OWN_PACKAGES, readPackage;
|
|
@@ -123369,6 +123369,9 @@ function refusalSay(a, tool, again, npmVersion) {
|
|
|
123369
123369
|
if (tool === "pay_for_service" && steps === 1) return firstFit(`${head} ${ask}; that call gets it ready and pays.`, `${head} ${ask}.`);
|
|
123370
123370
|
return firstFit(`${head} ${ask} until it ${tool === "wallet_unshield" ? "sends" : "pays"}.`, `${head} ${ask}.`);
|
|
123371
123371
|
}
|
|
123372
|
+
if ((code2 === PAY_BALANCE_EMPTY_CODE || code2 === "mcp_unshield_balance_empty") && a.blockedBy && typeof a.blockedBy === "object") {
|
|
123373
|
+
return blockedZeroSay(a, code2 === PAY_BALANCE_EMPTY_CODE ? "paid" : "sent");
|
|
123374
|
+
}
|
|
123372
123375
|
if ((code2 === PAY_BALANCE_EMPTY_CODE || code2 === "mcp_unshield_balance_empty") && zeroOnTheWay(a)) {
|
|
123373
123376
|
const way = zeroOnTheWay(a);
|
|
123374
123377
|
return `Nothing was ${code2 === PAY_BALANCE_EMPTY_CODE ? "paid" : "sent"}: your private balance is 0 USDC. ${way[0].toUpperCase()}${way.slice(1)}`;
|
|
@@ -123741,6 +123744,11 @@ function addFundsHeldSay(entries, have = "", updateOut = false, updateKnown = tr
|
|
|
123741
123744
|
if (entry.landed === true) continue;
|
|
123742
123745
|
if (entry.belowMinimum === true) continue;
|
|
123743
123746
|
if (blocked.includes(entry)) continue;
|
|
123747
|
+
if (entry.runnerDeposit === true) {
|
|
123748
|
+
nowAny = true;
|
|
123749
|
+
nowUnknown = true;
|
|
123750
|
+
continue;
|
|
123751
|
+
}
|
|
123744
123752
|
const amount = ATOMIC8.test(String(entry.heldAtomic ?? "")) ? BigInt(entry.heldAtomic) : 0n;
|
|
123745
123753
|
const left = Number.isSafeInteger(entry.privateInMinutes) ? entry.privateInMinutes : null;
|
|
123746
123754
|
if (entry.state === "shielding" && entry.startsAtNextRequest === true) {
|
|
@@ -123787,6 +123795,12 @@ function addFundsHeldSay(entries, have = "", updateOut = false, updateKnown = tr
|
|
|
123787
123795
|
}
|
|
123788
123796
|
function zeroOnTheWay(a) {
|
|
123789
123797
|
const of = (atomic5) => usdcText2(atomic5) ? ` of ${usdcText2(atomic5)} USDC` : "";
|
|
123798
|
+
if (a.blockedBy && typeof a.blockedBy === "object") {
|
|
123799
|
+
const held2 = usdcText2(a.blockedHeldAtomic);
|
|
123800
|
+
const waits = a.blockedBy.state === "awaiting_funds";
|
|
123801
|
+
if (positive(held2)) return waits ? `${held2} USDC waits at your add-funds address behind an earlier open one; ask me to close that.` : `${held2} USDC waits at your add-funds address until an earlier deposit finishes.`;
|
|
123802
|
+
return waits ? "an earlier add-funds address is still open and blocks deposits; ask me to close it." : "an earlier add-funds deposit must finish first.";
|
|
123803
|
+
}
|
|
123790
123804
|
if (Object.hasOwn(a, "depositWaitingAtomic")) return `your ${a.depositAddFunds === true ? "add-funds " : ""}deposit${of(a.depositWaitingAtomic)} still waits for USDC at its one-time address.`;
|
|
123791
123805
|
if (Object.hasOwn(a, "depositArrivingAtomic")) return `your deposit${of(a.depositArrivingAtomic)} is on its way; ask again once it arrives.`;
|
|
123792
123806
|
if (Object.hasOwn(a, "refundComingAtomic")) return `a refund${of(a.refundComingAtomic)} is on its way to it; ask again once it arrives.`;
|
|
@@ -123794,6 +123808,14 @@ function zeroOnTheWay(a) {
|
|
|
123794
123808
|
if (Object.hasOwn(a, "paymentWaitingAtomic")) return `a payment${of(a.paymentWaitingAtomic)} waits on its seller; asking again finishes it, else it comes back by itself.`;
|
|
123795
123809
|
return void 0;
|
|
123796
123810
|
}
|
|
123811
|
+
function blockedZeroSay(a, verb) {
|
|
123812
|
+
const held2 = usdcText2(a.blockedHeldAtomic);
|
|
123813
|
+
const waits = a.blockedBy.state === "awaiting_funds";
|
|
123814
|
+
if (positive(held2)) {
|
|
123815
|
+
return waits ? `Nothing was ${verb}. ${held2} USDC waits at your add-funds address; an earlier open address blocks it. Ask me to close it.` : `Nothing was ${verb}. ${held2} USDC waits at your add-funds address until an earlier deposit finishes; the shinjuku add-funds command finishes it.`;
|
|
123816
|
+
}
|
|
123817
|
+
return waits ? `Nothing was ${verb}: your private balance is 0. An earlier add-funds address is still open and blocks deposits; ask me to close it.` : `Nothing was ${verb}: your private balance is 0. An earlier add-funds deposit must finish first; the shinjuku add-funds command finishes it.`;
|
|
123818
|
+
}
|
|
123797
123819
|
function emptyUnshieldSay(a) {
|
|
123798
123820
|
const rows2 = Array.isArray(a.addFunds) ? a.addFunds.filter((row) => row && typeof row === "object") : [];
|
|
123799
123821
|
const blocked = rows2.find((row) => row.blockedBy && typeof row.blockedBy === "object");
|
|
@@ -123816,7 +123838,7 @@ function emptyUnshieldSay(a) {
|
|
|
123816
123838
|
if (start !== null) return `Nothing was sent. Your private balance is 0; ${what} arrived and becomes private by itself. Try again once it is private.`;
|
|
123817
123839
|
return `Nothing was sent. Your private balance is 0; ${what} is being made private. Try again ${minutes ? `in about ${minutesText(minutes)}` : "once your balance shows it"}.`;
|
|
123818
123840
|
}
|
|
123819
|
-
if (rows2.some((row) => row.state === "open" && row.heldAtomic === null)) {
|
|
123841
|
+
if (rows2.some((row) => row.state === "open" && row.runnerDeposit !== true && row.heldAtomic === null)) {
|
|
123820
123842
|
return "Nothing was sent. Your private balance is 0. I can check your balance in a minute; USDC at your add-funds address then becomes private.";
|
|
123821
123843
|
}
|
|
123822
123844
|
const open6 = rows2.find((row) => row.state === "open");
|
|
@@ -124017,7 +124039,7 @@ function balanceLine(a, room = SAY_MAX_WORDS) {
|
|
|
124017
124039
|
}
|
|
124018
124040
|
const refunds = positive(refundInFlight(a)) || positive(usdcText2(a.breakdown?.refundsNotCertainAtomic));
|
|
124019
124041
|
const waitsAt = Array.isArray(a.addFunds) ? a.addFunds.find((row) => row && row.state === "open" && row.landed !== true && row.heldAtomic === "0") : void 0;
|
|
124020
|
-
const unreadAt = Array.isArray(a.addFunds) ? a.addFunds.find((row) => row && row.state === "open" && row.landed !== true && row.heldAtomic === null) : void 0;
|
|
124042
|
+
const unreadAt = Array.isArray(a.addFunds) ? a.addFunds.find((row) => row && row.state === "open" && row.landed !== true && row.runnerDeposit !== true && row.heldAtomic === null) : void 0;
|
|
124021
124043
|
const dustRows = Array.isArray(a.addFunds) ? a.addFunds.filter((row) => row?.belowMinimum === true && ATOMIC8.test(String(row.heldAtomic ?? "")) && ATOMIC8.test(String(row.minimumAtomic ?? "")) && BigInt(row.minimumAtomic) > BigInt(row.heldAtomic)) : [];
|
|
124022
124044
|
const dust = dustRows.find((row) => row.state === "open") ?? (waitsAt || unreadAt ? void 0 : dustRows[0]);
|
|
124023
124045
|
if (balance === "0" && !pubPart && !refunds && dust) {
|
|
@@ -127501,7 +127523,7 @@ function writeProvenFloatStates(store, proven) {
|
|
|
127501
127523
|
if (knownSellerTransfer(record) !== null || !landed.landedTransaction) continue;
|
|
127502
127524
|
store.writeWal(name, { ...record, ...landed });
|
|
127503
127525
|
} else if (verdict2 === "refunded") {
|
|
127504
|
-
if (floatRecordState(record) !== "refund_pending"
|
|
127526
|
+
if (floatRecordState(record) !== "refund_pending") continue;
|
|
127505
127527
|
if (!SIGNATURE_TEXT.test(String(refundTransaction ?? "")) || SIGNATURE_TEXT.test(String(record.refundTransaction ?? ""))) continue;
|
|
127506
127528
|
store.writeWal(name, { ...record, refundTransaction, refundLandedAtMs: record.refundLandedAtMs ?? Date.now() });
|
|
127507
127529
|
} else if (verdict2 === "dead" && floatRecordState(record) === "submitted") {
|
|
@@ -142140,7 +142162,8 @@ function floatRefusal(error, overLimit, tool = "pay_for_service") {
|
|
|
142140
142162
|
// Lotus to-do 47 live check (2026-11-09): an agent may repeat the detail, so no field name ("balanceAtomic").
|
|
142141
142163
|
balance: "your private balance",
|
|
142142
142164
|
refundState: "wallet_receipts shows its state and, once sent, its refundTransaction",
|
|
142143
|
-
|
|
142165
|
+
// The refund's transaction shows once Shinjuku names it to this wallet (a live check on npm 0.3.227: a refunded row had none).
|
|
142166
|
+
result: `wallet_receipts shows the result (the refund, with its transaction once Shinjuku has named it, or that the ${inference ? "AI provider" : "seller"} kept it)`,
|
|
142144
142167
|
privateLeg: FLOAT_PRIVATE_LEG,
|
|
142145
142168
|
maxArg: "max_payment",
|
|
142146
142169
|
discover: " (find_paid_services finds one)",
|
|
@@ -144971,7 +144994,7 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
144971
144994
|
...short.received ? { receivedOnly: true } : short.short ? shortZeroFields(short.short) : {}
|
|
144972
144995
|
},
|
|
144973
144996
|
detail: (feeAtomic !== void 0 ? `the seller asks ${usdcText3(priceAtomic)} USDC as a standard USDC payment; Shinjuku pays it for you, privately, for a fee of ${usdcText3(feeAtomic)} USDC: ${usdcText3(totalAtomic)} USDC leave your balance${allowed}` : `the seller asks ${usdcText3(priceAtomic)} USDC as a private payment, which the wallet pays from your private balance${allowed}`) + requestSentence,
|
|
144974
|
-
next: short === void 0 ? asksOnce ? `Tell the user: this costs ${usdcText3(totalAtomic)} USDC, above the ${limitName} of ${usdcText3(launch)} USDC; when the user asks to buy it, the app first asks the user "Allow it once?", and nothing is paid without a yes. If the user wants it, ${payNext}` : payNext : short.old ? oldBalanceNext(`${usdcText3(totalAtomic)} USDC`, payNext) : short.received ? `Tell the user: this costs ${usdcText3(totalAtomic)} USDC. ${
|
|
144997
|
+
next: short === void 0 ? asksOnce ? `Tell the user: this costs ${usdcText3(totalAtomic)} USDC, above the ${limitName} of ${usdcText3(launch)} USDC; when the user asks to buy it, the app first asks the user "Allow it once?", and nothing is paid without a yes. If the user wants it, ${payNext}` : payNext : short.old ? oldBalanceNext(`${usdcText3(totalAtomic)} USDC`, payNext) : short.received ? `Tell the user: this costs ${usdcText3(totalAtomic)} USDC. ${shortSentences(short.short, { outcome: "none" }).join(" ")} So a payment now is refused and pays nothing. ${receivedStep(short.short, totalAtomic, payNext)}` : short.short ? `Tell the user: this costs ${usdcText3(totalAtomic)} USDC and the private balance is 0 USDC, so a payment now is refused and pays nothing. ${shortSentences(short.short).slice(1).join(" ")} ${shortZeroStep(short.short, payNext)}` : `Tell the user: this costs ${usdcText3(totalAtomic)} USDC and the private balance is ${usdcText3(short.balanceAtomic)} USDC, so a payment now is refused and pays nothing. Before any payment, ${ADD_FUNDS_STEP}; once wallet_balance shows at least ${usdcText3(totalAtomic)} USDC, ${payNext}`
|
|
144975
144998
|
});
|
|
144976
144999
|
}
|
|
144977
145000
|
};
|
|
@@ -145087,7 +145110,72 @@ ${canonical5}`;
|
|
|
145087
145110
|
const known = knownShort({ payment, maxAgeMs });
|
|
145088
145111
|
return known?.kind === "coming" ? known.short : void 0;
|
|
145089
145112
|
}
|
|
145090
|
-
|
|
145113
|
+
function planBlockNow(store) {
|
|
145114
|
+
let plan;
|
|
145115
|
+
try {
|
|
145116
|
+
plan = classifyBlockers(store, depositBlockers(store)).find((blocker) => blocker.kind === "plan");
|
|
145117
|
+
} catch {
|
|
145118
|
+
return void 0;
|
|
145119
|
+
}
|
|
145120
|
+
if (!plan) return void 0;
|
|
145121
|
+
let held2 = 0n;
|
|
145122
|
+
let seenAll = true;
|
|
145123
|
+
for (const record of listPayMe(store)) {
|
|
145124
|
+
if (record.state !== "open") continue;
|
|
145125
|
+
const seen = linkHeldSeen.get(record.id);
|
|
145126
|
+
if (!seen || Date.now() - seen.atMs >= LINK_HELD_FRESH_MS) {
|
|
145127
|
+
seenAll = false;
|
|
145128
|
+
continue;
|
|
145129
|
+
}
|
|
145130
|
+
held2 += BigInt(seen.held);
|
|
145131
|
+
}
|
|
145132
|
+
return { blockedBy: blockedByOf([plan]), heldAtomic: held2 > 0n ? held2.toString() : seenAll ? "0" : null };
|
|
145133
|
+
}
|
|
145134
|
+
const planBlockFor = (short) => {
|
|
145135
|
+
if (!short?.deposits?.some((deposit) => deposit.addFunds && deposit.state === "awaiting_funds")) return void 0;
|
|
145136
|
+
if (Object.hasOwn(short, "planBlock")) return short.planBlock ?? void 0;
|
|
145137
|
+
let block;
|
|
145138
|
+
try {
|
|
145139
|
+
block = planBlockNow(session.openStore());
|
|
145140
|
+
} catch {
|
|
145141
|
+
block = void 0;
|
|
145142
|
+
}
|
|
145143
|
+
try {
|
|
145144
|
+
Object.defineProperty(short, "planBlock", { value: block ?? null, enumerable: false, configurable: true });
|
|
145145
|
+
} catch {
|
|
145146
|
+
}
|
|
145147
|
+
return block;
|
|
145148
|
+
};
|
|
145149
|
+
const withoutPlan = (short) => planBlockFor(short) ? { ...short, deposits: short.deposits.filter((deposit) => !(deposit.addFunds && deposit.state === "awaiting_funds")) } : short;
|
|
145150
|
+
async function primePlanHeld() {
|
|
145151
|
+
let store;
|
|
145152
|
+
try {
|
|
145153
|
+
store = session.openStore();
|
|
145154
|
+
} catch {
|
|
145155
|
+
return;
|
|
145156
|
+
}
|
|
145157
|
+
try {
|
|
145158
|
+
if (!classifyBlockers(store, depositBlockers(store)).some((blocker) => blocker.kind === "plan")) return;
|
|
145159
|
+
} catch {
|
|
145160
|
+
return;
|
|
145161
|
+
}
|
|
145162
|
+
const reads = [...readOpenLinkHeld(store).values()].map((read) => Promise.resolve(read).catch(() => null));
|
|
145163
|
+
if (!reads.length) return;
|
|
145164
|
+
await Promise.race([Promise.all(reads), new Promise((resolve44) => {
|
|
145165
|
+
const timer = setTimeout(resolve44, PLAN_HELD_WAIT_MS);
|
|
145166
|
+
timer.unref?.();
|
|
145167
|
+
})]);
|
|
145168
|
+
}
|
|
145169
|
+
const shortSentences = (short, options) => {
|
|
145170
|
+
const block = planBlockFor(short);
|
|
145171
|
+
const sentences = shortBalanceSentences(withoutPlan(short), options);
|
|
145172
|
+
if (!block) return sentences;
|
|
145173
|
+
const words2 = planBlockWords(block.blockedBy, true);
|
|
145174
|
+
return [...sentences, /^[1-9][0-9]*$/.test(String(block.heldAtomic ?? "")) ? `${usdcText3(block.heldAtomic)} USDC is safe at your add-funds address but cannot go in yet: ${words2[0].toLowerCase()}${words2.slice(1)}, and it blocks new deposits.` : `${words2}, and it blocks new deposits.`];
|
|
145175
|
+
};
|
|
145176
|
+
const shortZeroFields = (shortAll) => {
|
|
145177
|
+
const block = planBlockFor(shortAll);
|
|
145178
|
+
const short = withoutPlan(shortAll);
|
|
145091
145179
|
const sum2 = (list) => list.every((deposit) => deposit.amountAtomic !== null) ? list.reduce((total, deposit) => total + BigInt(deposit.amountAtomic), 0n).toString() : null;
|
|
145092
145180
|
const waiting = short.deposits.filter((deposit) => deposit.state === "awaiting_funds");
|
|
145093
145181
|
const arriving = short.deposits.filter((deposit) => deposit.state !== "awaiting_funds");
|
|
@@ -145101,13 +145189,16 @@ ${canonical5}`;
|
|
|
145101
145189
|
...arriving.length ? { depositArrivingAtomic: sum2(arriving) } : {},
|
|
145102
145190
|
...refund ? { refundComingAtomic: refund } : {},
|
|
145103
145191
|
...mayCome ? { refundMayComeAtomic: mayCome } : {},
|
|
145104
|
-
...waitsOnSeller ? { paymentWaitingAtomic: waitsOnSeller } : {}
|
|
145192
|
+
...waitsOnSeller ? { paymentWaitingAtomic: waitsOnSeller } : {},
|
|
145193
|
+
...block ? { blockedBy: block.blockedBy, .../^[1-9][0-9]*$/.test(String(block.heldAtomic ?? "")) ? { blockedHeldAtomic: block.heldAtomic } : {} } : {}
|
|
145105
145194
|
};
|
|
145106
145195
|
};
|
|
145107
|
-
const shortZeroStep = (
|
|
145196
|
+
const shortZeroStep = (shortAll, then) => {
|
|
145197
|
+
const block = planBlockFor(shortAll);
|
|
145198
|
+
const short = withoutPlan(shortAll);
|
|
145108
145199
|
const waiting = short.deposits.filter((deposit) => deposit.state === "awaiting_funds");
|
|
145109
145200
|
const addFunds3 = waiting.some((deposit) => deposit.addFunds);
|
|
145110
|
-
return (waiting.length ? `The user sends USDC on Solana to the one-time address of that ${addFunds3 ? "add-funds " : ""}deposit${addFunds3 ? `; to see the address again, the user runs ${terminalCommand2("add-funds")} in a terminal (it continues the same deposit)` : ""}. If the user wants to add money, call wallet_add_funds: it gives a new address, or says why it cannot. ` : "") + (waiting.length < short.deposits.length || shortZeroFields(short).refundComingAtomic ? "What is on its way becomes private by itself. " : "") + `Later, ${SAFE_BALANCE_READ}; once it shows a private balance above 0, ${then}.`;
|
|
145201
|
+
return (block ? `${planBlockStep(block.blockedBy)}. Do not tell the user to send USDC to that earlier address, and do not ask for a new address. ` : "") + (waiting.length ? `The user sends USDC on Solana to the one-time address of that ${addFunds3 ? "add-funds " : ""}deposit${addFunds3 ? `; to see the address again, the user runs ${terminalCommand2("add-funds")} in a terminal (it continues the same deposit)` : ""}. If the user wants to add money, call wallet_add_funds: it gives a new address, or says why it cannot. ` : "") + (waiting.length < short.deposits.length || shortZeroFields(short).refundComingAtomic ? "What is on its way becomes private by itself. " : "") + `Later, ${SAFE_BALANCE_READ}; once it shows a private balance above 0, ${then}.`;
|
|
145111
145202
|
};
|
|
145112
145203
|
const receivedStep = (short, costAtomic, then) => {
|
|
145113
145204
|
const missing = ATOMIC_TEXT.test(String(costAtomic ?? "")) ? BigInt(costAtomic) - BigInt(short.spendableAtomic) : 0n;
|
|
@@ -145117,7 +145208,7 @@ ${canonical5}`;
|
|
|
145117
145208
|
function shortZeroStop(short, { tool, requestId, same: same2, costAtomic, beforeBox = false }) {
|
|
145118
145209
|
const send3 = tool === "wallet_unshield";
|
|
145119
145210
|
const received = !send3 && short.receivedOnly === true;
|
|
145120
|
-
const sentences =
|
|
145211
|
+
const sentences = shortSentences(short, send3 ? {} : { costAtomic }).join(" ");
|
|
145121
145212
|
log(`MCP_${send3 ? "UNSHIELD" : "PAY"}_BALANCE_SHORT ${requestId ? `requestId=${requestId} ` : ""}${received ? "receivedOnly=true" : `deposits=${short.deposits.length}`}`);
|
|
145122
145213
|
const again2 = `call ${tool} again with ${requestId ? `request_id "${requestId}" and ` : ""}${same2}${send3 ? "" : " (it never pays twice)"}`;
|
|
145123
145214
|
return refuse11(
|
|
@@ -145156,6 +145247,7 @@ ${canonical5}`;
|
|
|
145156
145247
|
const same2 = tool === "pay_for_service" ? "the same url, method, headers, and body" : "the same arguments";
|
|
145157
145248
|
const known = await afterFreshWalk((maxAgeMs) => knownShort({ payment: true, maxAgeMs }));
|
|
145158
145249
|
if (known?.kind === "plain") return zeroBalanceStop({ tool, requestId, same: same2 });
|
|
145250
|
+
if (known) await primePlanHeld();
|
|
145159
145251
|
return known ? shortZeroStop(known.short, { tool, requestId, same: same2, costAtomic, beforeBox: true }) : void 0;
|
|
145160
145252
|
};
|
|
145161
145253
|
function limitAfterYes(store, url, requestId, amountAtomic, { yes: yes2 = true } = {}) {
|
|
@@ -145633,6 +145725,7 @@ ${canonical5}`;
|
|
|
145633
145725
|
}
|
|
145634
145726
|
));
|
|
145635
145727
|
}
|
|
145728
|
+
if (code2 === "p03_merchant_respend_no_spendable_account") await primePlanHeld();
|
|
145636
145729
|
const failed = payFailure(error, requestId, "pay_for_service", join59, askUnshown);
|
|
145637
145730
|
const ready = readyInSecondsOf(error, code2);
|
|
145638
145731
|
return withRefundNotices(ready !== void 0 ? json4({ ...JSON.parse(failed.text), readyInSeconds: ready }) : failed);
|
|
@@ -146388,6 +146481,7 @@ ${canonical5}`;
|
|
|
146388
146481
|
}
|
|
146389
146482
|
const linkHeldSeen = /* @__PURE__ */ new Map();
|
|
146390
146483
|
const LINK_HELD_FRESH_MS = 6e4;
|
|
146484
|
+
const PLAN_HELD_WAIT_MS = 4e3;
|
|
146391
146485
|
const LINK_HELD_READS_MAX = 10;
|
|
146392
146486
|
const linkHeldRefused = /* @__PURE__ */ new Map();
|
|
146393
146487
|
const rememberHeld = (id, held2) => {
|
|
@@ -146556,7 +146650,7 @@ ${canonical5}`;
|
|
|
146556
146650
|
ownReadsAhead = void 0;
|
|
146557
146651
|
return ahead && Date.now() - ahead.atMs <= OWN_READS_AHEAD_MS && ahead.atMs > clearedAtLocal ? ahead : void 0;
|
|
146558
146652
|
}
|
|
146559
|
-
function addFundsRows(store, linkHeld = /* @__PURE__ */ new Map(), addFundsDeposits = /* @__PURE__ */ new Set()) {
|
|
146653
|
+
function addFundsRows(store, linkHeld = /* @__PURE__ */ new Map(), addFundsDeposits = /* @__PURE__ */ new Set(), { runnerRuns = false } = {}) {
|
|
146560
146654
|
let others;
|
|
146561
146655
|
const othersOnce = () => {
|
|
146562
146656
|
try {
|
|
@@ -146575,6 +146669,7 @@ ${canonical5}`;
|
|
|
146575
146669
|
}
|
|
146576
146670
|
const held2 = ATOMIC_TEXT.test(String(record.leftAtAddressAtomic ?? "")) ? String(record.leftAtAddressAtomic) : linkHeld.get(record.id) ?? null;
|
|
146577
146671
|
const startAt = record.state === "open" ? watcher?.startAtOf(linkKindOf(record.id), record.id) ?? null : null;
|
|
146672
|
+
const runnerDeposit = runnerRuns === true && record.state === "open" && held2 === null && startAt !== null && startAt <= Date.now();
|
|
146578
146673
|
let shieldingAtomic = null;
|
|
146579
146674
|
let depositSent = false;
|
|
146580
146675
|
let landed = false;
|
|
@@ -146598,6 +146693,7 @@ ${canonical5}`;
|
|
|
146598
146693
|
heldAtomic: held2,
|
|
146599
146694
|
...record.state === "shielding" ? { shieldingAtomic } : {},
|
|
146600
146695
|
...blockedBy ? { blockedBy } : {},
|
|
146696
|
+
...runnerDeposit ? { runnerDeposit: true } : {},
|
|
146601
146697
|
...landed ? { landed: true } : {},
|
|
146602
146698
|
...belowMinimum ? { belowMinimum: true } : {},
|
|
146603
146699
|
// The least an open address takes (the say line names it beside the step that sends USDC there).
|
|
@@ -146613,7 +146709,7 @@ ${canonical5}`;
|
|
|
146613
146709
|
// Not read in time (a live check 0.3.106 gate item 9): a host may end this process after the answer, so no read is promised
|
|
146614
146710
|
// here; the next wallet_balance reads the address again and starts the deposit when its USDC is there.
|
|
146615
146711
|
// Codex round 1 (2026-11-09): a read the RPC answered with an error is named as that answer, not as silence.
|
|
146616
|
-
...held2 === null ? { heldNote: linkHeldRefused.has(record.id) ? `not read: the chain read of this address failed, because ${rpcRefusalWords(linkHeldRefused.get(record.id))}. ${linkHeldRefused.get(record.id).unlikely ? `${RPC_REFUSAL_HINT}; then call` : "Call"} wallet_balance again: it reads the address again and starts the deposit if USDC is there` : `not read in time: the chain read of this address did not answer; call wallet_balance again: it reads the address again (up to ${LINK_READ_ANSWER_MS / 1e3} s) and starts the deposit if USDC is there` } : {}
|
|
146712
|
+
...held2 === null && !runnerDeposit ? { heldNote: linkHeldRefused.has(record.id) ? `not read: the chain read of this address failed, because ${rpcRefusalWords(linkHeldRefused.get(record.id))}. ${linkHeldRefused.get(record.id).unlikely ? `${RPC_REFUSAL_HINT}; then call` : "Call"} wallet_balance again: it reads the address again and starts the deposit if USDC is there` : `not read in time: the chain read of this address did not answer; call wallet_balance again: it reads the address again (up to ${LINK_READ_ANSWER_MS / 1e3} s) and starts the deposit if USDC is there` } : {}
|
|
146617
146713
|
};
|
|
146618
146714
|
});
|
|
146619
146715
|
}
|
|
@@ -146705,6 +146801,31 @@ ${canonical5}`;
|
|
|
146705
146801
|
return outcome;
|
|
146706
146802
|
});
|
|
146707
146803
|
}
|
|
146804
|
+
function landedLinksAtomic(store) {
|
|
146805
|
+
let outputs;
|
|
146806
|
+
try {
|
|
146807
|
+
outputs = readBalanceSnapshot(store)?.snapshot?.outputs ?? [];
|
|
146808
|
+
} catch {
|
|
146809
|
+
outputs = [];
|
|
146810
|
+
}
|
|
146811
|
+
const spentDigests = new Set(outputs.filter((output2) => output2.spendStatus !== "unspent").map((output2) => output2.digest));
|
|
146812
|
+
const unspentDigests = new Set(outputs.filter((output2) => output2.spendStatus === "unspent").map((output2) => output2.digest));
|
|
146813
|
+
let total = 0n;
|
|
146814
|
+
for (const record of listPayMe(store)) {
|
|
146815
|
+
if (record.state !== "shielding") continue;
|
|
146816
|
+
let deposit;
|
|
146817
|
+
try {
|
|
146818
|
+
deposit = store.readWal(`deposit-${record.depositId ?? payMeRoundDepositId(record.id, record.round ?? 1)}`);
|
|
146819
|
+
} catch {
|
|
146820
|
+
continue;
|
|
146821
|
+
}
|
|
146822
|
+
if (!depositLanded(deposit) || !/^[1-9][0-9]*$/.test(String(deposit.amountAtomic ?? ""))) continue;
|
|
146823
|
+
const digest2 = String(deposit.memoDigest ?? "").replace(/^0x/i, "").toLowerCase();
|
|
146824
|
+
if (digest2 && spentDigests.has(digest2) && !unspentDigests.has(digest2)) continue;
|
|
146825
|
+
total += BigInt(deposit.amountAtomic);
|
|
146826
|
+
}
|
|
146827
|
+
return total;
|
|
146828
|
+
}
|
|
146708
146829
|
function landedNotCounted(store, parts) {
|
|
146709
146830
|
let snapshot;
|
|
146710
146831
|
try {
|
|
@@ -147270,6 +147391,12 @@ ${canonical5}`;
|
|
|
147270
147391
|
landingParts.salesAtomic = 0n;
|
|
147271
147392
|
landingParts.recordFaultAtomic = 0n;
|
|
147272
147393
|
}
|
|
147394
|
+
if (landingAtomic === 0n && String(one.balanceAtomic) === "0") {
|
|
147395
|
+
try {
|
|
147396
|
+
landingAtomic = landedLinksAtomic(store);
|
|
147397
|
+
} catch {
|
|
147398
|
+
}
|
|
147399
|
+
}
|
|
147273
147400
|
if (landingAtomic === 0n && shieldedAtomic === null && !refresh.refreshError && finishedHere.length) {
|
|
147274
147401
|
for (const outcome of finishedHere) {
|
|
147275
147402
|
const id = outcome.record?.id;
|
|
@@ -147314,7 +147441,7 @@ ${canonical5}`;
|
|
|
147314
147441
|
let addFundsOpen = [];
|
|
147315
147442
|
const addFundsDeposits = /* @__PURE__ */ new Set();
|
|
147316
147443
|
try {
|
|
147317
|
-
addFundsOpen = addFundsRows(store, linkHeld, addFundsDeposits);
|
|
147444
|
+
addFundsOpen = addFundsRows(store, linkHeld, addFundsDeposits, { runnerRuns: await depositRunnerHolds().catch(() => false) });
|
|
147318
147445
|
} catch {
|
|
147319
147446
|
addFundsOpen = [];
|
|
147320
147447
|
}
|
|
@@ -147379,12 +147506,12 @@ ${canonical5}`;
|
|
|
147379
147506
|
}
|
|
147380
147507
|
}
|
|
147381
147508
|
const stoppedLinks = addFundsOpen.filter((link3) => link3.updateNeeded === true);
|
|
147382
|
-
const arrivingAny = addFundsOpen.filter((link3) => link3.landed !== true && link3.belowMinimum !== true && link3.updateNeeded !== true && (link3.state === "shielding" || /^[1-9][0-9]*$/.test(String(link3.heldAtomic ?? ""))));
|
|
147509
|
+
const arrivingAny = addFundsOpen.filter((link3) => link3.landed !== true && link3.belowMinimum !== true && link3.updateNeeded !== true && (link3.state === "shielding" || link3.runnerDeposit === true || /^[1-9][0-9]*$/.test(String(link3.heldAtomic ?? ""))));
|
|
147383
147510
|
const arrivingAll = arrivingAny.filter((link3) => !link3.blockedBy);
|
|
147384
147511
|
const arrivingBlocked = arrivingAny.filter((link3) => link3.blockedBy);
|
|
147385
147512
|
const least = usdcText3(PAY_ME_MIN_ATOMIC);
|
|
147386
147513
|
const belowLeast = addFundsOpen.filter((link3) => link3.belowMinimum === true);
|
|
147387
|
-
const addFundsWaiting = addFundsOpen.filter((link3) => link3.state === "open" && link3.landed !== true && link3.updateNeeded !== true && (link3.heldAtomic === null || link3.heldAtomic === "0"));
|
|
147514
|
+
const addFundsWaiting = addFundsOpen.filter((link3) => link3.state === "open" && link3.landed !== true && link3.updateNeeded !== true && link3.runnerDeposit !== true && (link3.heldAtomic === null || link3.heldAtomic === "0"));
|
|
147388
147515
|
const unreadLinks = addFundsWaiting.filter((link3) => link3.heldAtomic === null);
|
|
147389
147516
|
const blockedArrivingNext = (links) => {
|
|
147390
147517
|
const plan = links.find((link3) => link3.blockedBy.kind === "plan");
|
|
@@ -147392,7 +147519,7 @@ ${canonical5}`;
|
|
|
147392
147519
|
};
|
|
147393
147520
|
const arrivingLine = (arriving) => {
|
|
147394
147521
|
const amount = /^[1-9][0-9]*$/.test(String(arriving.shieldingAtomic ?? "")) ? `${usdcText3(arriving.shieldingAtomic)} USDC` : /^[1-9][0-9]*$/.test(String(arriving.heldAtomic ?? "")) ? `${usdcText3(arriving.heldAtomic)} USDC` : "USDC (an amount still being read)";
|
|
147395
|
-
const when = arriving.blockedBy ? arriving.blockedBy.kind === "plan" ? `cannot go in yet: ${planBlockWords(arriving.blockedBy)}, and it blocks new deposits` : "is safe there; it goes in after an earlier deposit of this wallet finishes" : arriving.state === "shielding" && !arriving.startsAtNextRequest ? "is becoming private now (its deposit transaction was sent)" : arriving.startsInMinutes > 0 ? `becomes private by itself: its deposit starts in about ${minutesText2(arriving.startsInMinutes)}` : depositsAfterRoots ? "becomes private by itself: its deposit starts when the wallet has finished starting; ask again for the balance in a minute" : "becomes private by itself: its deposit starts now";
|
|
147522
|
+
const when = arriving.blockedBy ? arriving.blockedBy.kind === "plan" ? `cannot go in yet: ${planBlockWords(arriving.blockedBy)}, and it blocks new deposits` : "is safe there; it goes in after an earlier deposit of this wallet finishes" : arriving.runnerDeposit === true ? "is becoming private now: the wallet's background process runs its deposit" : arriving.state === "shielding" && !arriving.startsAtNextRequest ? "is becoming private now (its deposit transaction was sent)" : arriving.startsInMinutes > 0 ? `becomes private by itself: its deposit starts in about ${minutesText2(arriving.startsInMinutes)}` : depositsAfterRoots ? "becomes private by itself: its deposit starts when the wallet has finished starting; ask again for the balance in a minute" : "becomes private by itself: its deposit starts now";
|
|
147396
147523
|
return `${amount} arrived at add-funds address "${arriving.requestId}" and ${when}`;
|
|
147397
147524
|
};
|
|
147398
147525
|
const inWait = (arriving) => !(arriving.state === "shielding" && !arriving.startsAtNextRequest) && arriving.startsInMinutes > 0;
|
|
@@ -147606,18 +147733,18 @@ ${canonical5}`;
|
|
|
147606
147733
|
const floatAnsweredAtMs = (record) => [record.answeredAtMs, record.sellerKeptAtMs, record.submittedAtMs].find(Number.isSafeInteger);
|
|
147607
147734
|
const staleRefundNames = (store) => staleFloatRefundNames(store);
|
|
147608
147735
|
async function correctFloatRecords(store, names2, untilMs, started = floatCorrectionReads(store, names2)) {
|
|
147609
|
-
const { states, proven, settled } = started;
|
|
147610
|
-
if (settled === void 0) return { states, written: 0 };
|
|
147736
|
+
const { states, proven, settled, answered: answered2 = /* @__PURE__ */ new Set() } = started;
|
|
147737
|
+
if (settled === void 0) return { states, written: 0, answered: answered2 };
|
|
147611
147738
|
const until = (ms) => new Promise((resolve44) => {
|
|
147612
147739
|
const timer = setTimeout(resolve44, Math.max(0, ms - Date.now()));
|
|
147613
147740
|
timer.unref?.();
|
|
147614
147741
|
});
|
|
147615
147742
|
await Promise.race([settled, until(untilMs)]);
|
|
147616
|
-
if (!proven.length) return { states, written: 0 };
|
|
147743
|
+
if (!proven.length) return { states, written: 0, answered: answered2 };
|
|
147617
147744
|
const writing = underLease((leased) => Date.now() >= untilMs ? 0 : writeProvenFloatStates(leased, proven));
|
|
147618
147745
|
const written = await Promise.race([writing.catch(() => 0), until(untilMs).then(() => 0)]);
|
|
147619
147746
|
if (written > 0) log(`MCP_FLOAT_RECORDS_CORRECTED records=${written}`);
|
|
147620
|
-
return { states, written };
|
|
147747
|
+
return { states, written, answered: answered2 };
|
|
147621
147748
|
}
|
|
147622
147749
|
function floatCorrectionReads(store, names2) {
|
|
147623
147750
|
const now = Date.now();
|
|
@@ -147653,11 +147780,13 @@ ${canonical5}`;
|
|
|
147653
147780
|
const states = new Map(finalRefundStates);
|
|
147654
147781
|
for (const [floatId, transaction] of finalTransfers) states.set(floatId, { floatState: "final", transaction });
|
|
147655
147782
|
const proven = [];
|
|
147656
|
-
|
|
147783
|
+
const answered2 = /* @__PURE__ */ new Set();
|
|
147784
|
+
if (!due.length && !transfers.length && !pendingReceipts.length) return { states, proven, settled: void 0, answered: answered2 };
|
|
147657
147785
|
due.sort((left, right) => floatEndedAtMs(right.record) - floatEndedAtMs(left.record));
|
|
147658
147786
|
transfers.sort((left, right) => floatAnsweredAtMs(right.record) - floatAnsweredAtMs(left.record));
|
|
147659
147787
|
const fetchImpl = ops.fetch ?? fetch;
|
|
147660
147788
|
const reads = due.slice(0, FLOAT_REFUND_READS).map(({ name, record }) => readFloatTransferState(record, fetchImpl).then((read) => {
|
|
147789
|
+
if (read !== void 0 && read.unserved !== true) answered2.add(record.floatId);
|
|
147661
147790
|
const state2 = floatRecordState(record);
|
|
147662
147791
|
if (state2 === "submitted" && read?.state === "landed" || read?.state === "final") {
|
|
147663
147792
|
states.set(record.floatId, { floatState: read.state, ...read.transaction ? { transaction: read.transaction } : {} });
|
|
@@ -147695,7 +147824,7 @@ ${canonical5}`;
|
|
|
147695
147824
|
proven.push({ name, from: record.state, transaction: read.transaction, fill: true });
|
|
147696
147825
|
}));
|
|
147697
147826
|
}
|
|
147698
|
-
return { states, proven, settled: Promise.all(reads).then(() => void 0, () => void 0) };
|
|
147827
|
+
return { states, proven, settled: Promise.all(reads).then(() => void 0, () => void 0), answered: answered2 };
|
|
147699
147828
|
}
|
|
147700
147829
|
async function correctFloatRecordsNow(store, started) {
|
|
147701
147830
|
try {
|
|
@@ -147775,7 +147904,7 @@ ${canonical5}`;
|
|
|
147775
147904
|
words: `the seller did not take this payment; ${amount} comes back to the private balance by itself`
|
|
147776
147905
|
};
|
|
147777
147906
|
}
|
|
147778
|
-
function paymentRows(store, names2, refundReads = /* @__PURE__ */ new Map()) {
|
|
147907
|
+
function paymentRows(store, names2, refundReads = /* @__PURE__ */ new Map(), answered2 = void 0) {
|
|
147779
147908
|
const floats = names2.filter((name) => name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)).map((name) => ({ name, record: store.readWal(name) }));
|
|
147780
147909
|
const ENDED = /* @__PURE__ */ new Set(["receipt", "refund_pending", "seller_kept", "submitted", "cancelled"]);
|
|
147781
147910
|
const neverLanded = (record) => floatNeverLanded(store, record);
|
|
@@ -147885,12 +148014,17 @@ ${canonical5}`;
|
|
|
147885
148014
|
const paid = ATOMIC_TEXT.test(String(record.paidAtomic ?? "")) ? String(record.paidAtomic) : null;
|
|
147886
148015
|
const shinjuku = refunded ? refundReads.get(record.floatId) : void 0;
|
|
147887
148016
|
const told = refunded ? refundWords(record, shinjuku, refundHeld, paid ? `${usdcText3(paid)} USDC` : void 0) : void 0;
|
|
148017
|
+
const refundTransaction = shinjuku?.refundTransaction ?? (SIGNATURE_TEXT2.test(String(record.refundTransaction ?? "")) ? record.refundTransaction : void 0);
|
|
147888
148018
|
const refund = !refunded ? {} : {
|
|
147889
148019
|
refundAtomic: paid,
|
|
147890
148020
|
refund: told.refund,
|
|
147891
148021
|
...FLOAT_ID2.test(String(record.floatId)) ? { floatId: record.floatId } : {},
|
|
147892
148022
|
...shinjuku?.floatState ? { refundState: refundStateWords(shinjuku.floatState) } : {},
|
|
147893
|
-
...
|
|
148023
|
+
...refundTransaction ? { refundTransaction } : {},
|
|
148024
|
+
...refundTransaction && Number.isFinite(record.refundLandedAtMs) ? { refundSeenAt: new Date(record.refundLandedAtMs).toISOString() } : {},
|
|
148025
|
+
// Only when this call read refunds (answered: wallet_receipts) and Shinjuku gave no answer for this one: a
|
|
148026
|
+
// refund Shinjuku has not sent yet has its refundState instead.
|
|
148027
|
+
...!refundTransaction && answered2 instanceof Set && !answered2.has(record.floatId) && !shinjuku && FLOAT_ID2.test(String(record.floatId)) && Date.now() - floatEndedAtMs(record) < FLOAT_REFUND_READ_AGE_MS ? { refundTransactionNote: "not read yet: this call got no answer from Shinjuku's refund status for it; wallet_receipts reads it again at the next call" } : {},
|
|
147894
148028
|
note: told.note
|
|
147895
148029
|
};
|
|
147896
148030
|
const landedTransaction = knownSellerTransfer(record) ?? (!refunded ? refundReads.get(record.floatId)?.transaction : void 0);
|
|
@@ -148282,7 +148416,7 @@ ${canonical5}`;
|
|
|
148282
148416
|
const receipts = {
|
|
148283
148417
|
name: "wallet_receipts",
|
|
148284
148418
|
title: "List recent receipts and wallet moves",
|
|
148285
|
-
description: `List this wallet's most recent receipts, newest first. Payments (kind x402 or inference): seller (the URL paid), sellerHost, item (what was bought), priceAtomic, feeAtomic, amountAtomic (the total), sellerTransaction, privateTransaction (this wallet's private payment), facilitator, answeredAt, paidFrom (agent app or terminal, when known), and transaction / host (the seller's when known). It lists payments from every app and chat that uses this wallet. pay.shinjukustaition.com is Shinjuku, the private payment service, never the seller. A payment the seller did not take shows state refund_pending (the refund is on its way; floatId, refundState: Shinjuku's refund step in words), refund_sent once Shinjuku sent it (refundTransaction; the balance counts it at a later read), then refunded once the balance holds it. A payment the seller has not served yet shows waiting_for_seller (or seller_paid_not_served once the transfer to the seller landed): call pay_for_service again with its requestId to get it. seller_refused (the seller refused it, sellerStatus) or outcome_not_certain (an earlier send got no clear answer): not certain yet whether the seller kept the payment; do not pay again until the row changes. never_landed: the payment never went through; nothing was paid and nothing comes back. sellerFailed: true (with httpStatus, sellerCode): paid, but the seller's service failed after it took the payment, so no data came back and no refund comes; never call pay_for_service again with its requestId (same error, nothing paid); a new payment is the user's choice, later. The wallet's own moves (kind shield, add-funds, unshield, private-send, token-transfer, or an older deposit kind): requestId, amountAtomic, state, transaction, at; a private-send row with smaller payments still to go shows partsAt (the time and state of each) and next (it is not stuck); a token-transfer row (an older wallet version's token sale and send) shows tokenMint, tokenAmountAtomic, usdcAtomic (what the sell gave) and sentAtomic; an add-funds row also shows heldAtomic, the USDC waiting at its address (it becomes private by itself: never close an address that holds USDC; belowMinimum: less than minimumAtomic waits there for a top-up). An add-funds row with via "cli" was made by the shinjuku add-funds command in a terminal: amountAtomic, state (done or not_finished), transaction; it has no requestId, and wallet_add_funds never continues it. An unshield row with via "cli" is this wallet's own send, made by the shinjuku unshield command in a terminal: amountAtomic, state (sent, not_finished, not_sent), transaction, and next (with unshieldId, the terminal's own id) when it is not finished; it has no requestId, and wallet_unshield never continues it. A received payment (kind received, a move): amountAtomic and state done; at is null and it sorts last (no sender, no time). A sale (kind sale, a move: a buyer paid this wallet): amountAtomic, at (when paid), note, state done (in the private balance), moving_in (it moves in by itself), checking, not_completed (no money comes from it) or stopped (it does not move in; reason and next: tell the user both). requestId is shown for payments made by this wallet process; older ones show requestKey (its SHA-256). kind "payments" or "moves" lists one group only.`,
|
|
148419
|
+
description: `List this wallet's most recent receipts, newest first. Payments (kind x402 or inference): seller (the URL paid), sellerHost, item (what was bought), priceAtomic, feeAtomic, amountAtomic (the total), sellerTransaction, privateTransaction (this wallet's private payment), facilitator, answeredAt, paidFrom (agent app or terminal, when known), and transaction / host (the seller's when known). It lists payments from every app and chat that uses this wallet. pay.shinjukustaition.com is Shinjuku, the private payment service, never the seller. A payment the seller did not take shows state refund_pending (the refund is on its way; floatId, refundState: Shinjuku's refund step in words), refund_sent once Shinjuku sent it (refundTransaction; the balance counts it at a later read), then refunded once the balance holds it (refundTransactionNote when its transaction was not read yet). A payment the seller has not served yet shows waiting_for_seller (or seller_paid_not_served once the transfer to the seller landed): call pay_for_service again with its requestId to get it. seller_refused (the seller refused it, sellerStatus) or outcome_not_certain (an earlier send got no clear answer): not certain yet whether the seller kept the payment; do not pay again until the row changes. never_landed: the payment never went through; nothing was paid and nothing comes back. sellerFailed: true (with httpStatus, sellerCode): paid, but the seller's service failed after it took the payment, so no data came back and no refund comes; never call pay_for_service again with its requestId (same error, nothing paid); a new payment is the user's choice, later. The wallet's own moves (kind shield, add-funds, unshield, private-send, token-transfer, or an older deposit kind): requestId, amountAtomic, state, transaction, at; a private-send row with smaller payments still to go shows partsAt (the time and state of each) and next (it is not stuck); a token-transfer row (an older wallet version's token sale and send) shows tokenMint, tokenAmountAtomic, usdcAtomic (what the sell gave) and sentAtomic; an add-funds row also shows heldAtomic, the USDC waiting at its address (it becomes private by itself: never close an address that holds USDC; belowMinimum: less than minimumAtomic waits there for a top-up). An add-funds row with via "cli" was made by the shinjuku add-funds command in a terminal: amountAtomic, state (done or not_finished), transaction; it has no requestId, and wallet_add_funds never continues it. An unshield row with via "cli" is this wallet's own send, made by the shinjuku unshield command in a terminal: amountAtomic, state (sent, not_finished, not_sent), transaction, and next (with unshieldId, the terminal's own id) when it is not finished; it has no requestId, and wallet_unshield never continues it. A received payment (kind received, a move): amountAtomic and state done; at is null and it sorts last (no sender, no time). A sale (kind sale, a move: a buyer paid this wallet): amountAtomic, at (when paid), note, state done (in the private balance), moving_in (it moves in by itself), checking, not_completed (no money comes from it) or stopped (it does not move in; reason and next: tell the user both). requestId is shown for payments made by this wallet process; older ones show requestKey (its SHA-256). kind "payments" or "moves" lists one group only.`,
|
|
148286
148420
|
inputSchema: {
|
|
148287
148421
|
type: "object",
|
|
148288
148422
|
properties: {
|
|
@@ -148333,7 +148467,7 @@ ${canonical5}`;
|
|
|
148333
148467
|
otherWorker = void 0;
|
|
148334
148468
|
}
|
|
148335
148469
|
}
|
|
148336
|
-
let payments = kind === "moves" ? [] : paymentRows(store, names2, refunds.states);
|
|
148470
|
+
let payments = kind === "moves" ? [] : paymentRows(store, names2, refunds.states, refunds.answered ?? /* @__PURE__ */ new Set());
|
|
148337
148471
|
const missing = (row) => row.state !== "never_landed" && row.state !== "cancelled" && row.privateTransaction === null && (row.scheme === "shielded-exact" || Boolean(row.facilitator));
|
|
148338
148472
|
const moves = kind === "payments" ? [] : moveRows(store, names2, linkHeld, { otherWorker });
|
|
148339
148473
|
const shownPayments = () => [...payments, ...moves].sort((left, right) => right.at - left.at).slice(0, limit).filter((row) => payments.includes(row));
|
|
@@ -148360,7 +148494,7 @@ ${canonical5}`;
|
|
|
148360
148494
|
const written = await bound(settled.catch(() => 0), Math.max(1e3, lookupEnd - Date.now()));
|
|
148361
148495
|
if (written > 0) {
|
|
148362
148496
|
store = session.openStore();
|
|
148363
|
-
payments = paymentRows(store, store.listWal(), refunds.states);
|
|
148497
|
+
payments = paymentRows(store, store.listWal(), refunds.states, refunds.answered ?? /* @__PURE__ */ new Set());
|
|
148364
148498
|
}
|
|
148365
148499
|
}
|
|
148366
148500
|
} catch {
|
|
@@ -150711,6 +150845,7 @@ ${canonical5}`;
|
|
|
150711
150845
|
}
|
|
150712
150846
|
const short = empty ? void 0 : await afterFreshWalk((maxAgeMs) => knownShortZero({ maxAgeMs }));
|
|
150713
150847
|
if (short) {
|
|
150848
|
+
await primePlanHeld();
|
|
150714
150849
|
return shortZeroStop(short, {
|
|
150715
150850
|
tool: "wallet_unshield",
|
|
150716
150851
|
beforeBox: true,
|
|
@@ -153434,7 +153569,7 @@ ${canonical5}`;
|
|
|
153434
153569
|
} else if (short.short) {
|
|
153435
153570
|
fields.balanceAtomic = short.balanceAtomic;
|
|
153436
153571
|
Object.assign(fields, short.received ? { receivedOnly: true } : shortZeroFields(short.short));
|
|
153437
|
-
steps.push(`Tell the user: ${
|
|
153572
|
+
steps.push(`Tell the user: ${shortSentences(short.short, { outcome: "none" }).join(" ")} So no question can be paid yet. ` + (short.received ? receivedStep(short.short, void 0, ask) : shortZeroStep(short.short, ask)));
|
|
153438
153573
|
} else {
|
|
153439
153574
|
fields.balanceAtomic = short.balanceAtomic;
|
|
153440
153575
|
steps.push(`Tell the user: the private balance is ${usdcText3(short.balanceAtomic)} USDC, less than one answer costs (the AI provider's price plus the 0.001 USDC Shinjuku fee), so no question can be paid yet. ${ADD_FUNDS_STEP[0].toUpperCase()}${ADD_FUNDS_STEP.slice(1)}; once wallet_balance shows it, ${ask}.`);
|
|
@@ -153811,6 +153946,7 @@ ${canonical5}`;
|
|
|
153811
153946
|
{ requestId, paid: false, ...over ? { totalAtomic: total, capAtomic: launch } : {}, ...facts }
|
|
153812
153947
|
);
|
|
153813
153948
|
}
|
|
153949
|
+
if (errorCode4(error, "") === "p03_merchant_respend_no_spendable_account") await primePlanHeld();
|
|
153814
153950
|
return withRefundNotices(inferenceRefusal(error, { requestId, ...facts }) ?? payFailure(error, requestId, "inference_chat"));
|
|
153815
153951
|
}
|
|
153816
153952
|
}
|
|
@@ -157856,7 +157992,7 @@ parentPort.once("message", () => { for (;;) {
|
|
|
157856
157992
|
installed: older.installed,
|
|
157857
157993
|
current: older.current,
|
|
157858
157994
|
command: older.line,
|
|
157859
|
-
detail: `Tell the user: the shinjuku command on this computer is version ${older.installed}, older than this wallet (${older.current}). To update it, run this once in a terminal${older.plain ? "" : " (it asks before it updates the command)"}:
|
|
157995
|
+
detail: `Tell the user: the shinjuku command on this computer is version ${older.installed}, older than this wallet (${older.current}). To update it${older.plain ? " to the newest stable version" : ""}, run this once in a terminal${older.plain ? "" : " (it asks before it updates the command)"}:
|
|
157860
157996
|
${older.line}`
|
|
157861
157997
|
});
|
|
157862
157998
|
LAUNCH_NOTICE_TOOLS = Object.freeze(["wallet_balance", "wallet_status"]);
|
|
@@ -174980,7 +175116,7 @@ function commandUseLinesOnly(npmVersion) {
|
|
|
174980
175116
|
if (!commandOnPath()) return terminalUseLinesHere(npmVersion);
|
|
174981
175117
|
const older = npmVersion ? olderInstalledCommand(npmVersion) : void 0;
|
|
174982
175118
|
if (!older) return ["In a terminal, run shinjuku help to see every command."];
|
|
174983
|
-
return [`The shinjuku command on this computer is version ${older.installed}; this wallet is version ${older.current}. To update the command, run${older.plain ? "" : " this (it asks before it updates the command)"}:`, ` ${older.line}`];
|
|
175119
|
+
return [`The shinjuku command on this computer is version ${older.installed}; this wallet is version ${older.current}. To update the command${older.plain ? " to the newest stable version" : ""}, run${older.plain ? "" : " this (it asks before it updates the command)"}:`, ` ${older.line}`];
|
|
174984
175120
|
}
|
|
174985
175121
|
var SETUP_WAIT_LINE = "Another setup of this wallet is running now (in another window or app). This setup waits for it to end, then goes on. If the other window waits for an answer, answer it there or close it.";
|
|
174986
175122
|
var SETUP_WAIT_TEXT = `${SETUP_WAIT_LINE} Press Ctrl+C to stop waiting.
|