@needmoretruth/nmts-cli 0.54.1 → 0.55.0
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/CHANGELOG.md +20 -0
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/dist/artifact-about.d.ts +1 -1
- package/dist/client-id.d.ts +1 -1
- package/dist/client-id.js +1 -1
- package/dist/commands/push.js +5 -1
- package/dist/commands/put-wallet.js +5 -1
- package/dist/commands/put.js +5 -1
- package/dist/manifest.js +3 -0
- package/dist/node-read.d.ts +2 -0
- package/dist/node-read.js +24 -0
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/read-race.d.ts +35 -0
- package/dist/read-race.js +91 -0
- package/dist/road-hosts.generated.d.ts +4 -0
- package/dist/road-hosts.generated.js +284 -0
- package/dist/shared/lib/upload/wallet-storage-estimate.d.ts +16 -0
- package/dist/shared/lib/upload/wallet-storage-estimate.js +44 -0
- package/dist/shared/lib/wallet/graphql-history.d.ts +7 -2
- package/dist/shared/lib/wallet/graphql-history.js +7 -2
- package/dist/shared/lib/walrus/credit-tip.d.ts +24 -0
- package/dist/shared/lib/walrus/credit-tip.js +61 -0
- package/dist/shared/lib/walrus/node-certificate.d.ts +18 -0
- package/dist/shared/lib/walrus/node-certificate.js +77 -0
- package/dist/shared/lib/walrus/node-quorum.d.ts +17 -0
- package/dist/shared/lib/walrus/node-quorum.js +103 -0
- package/dist/shared/lib/walrus/tip-config.d.ts +33 -0
- package/dist/shared/lib/walrus/tip-config.js +68 -0
- package/dist/upload-road.d.ts +55 -0
- package/dist/upload-road.js +155 -0
- package/dist/upload-steps.js +1 -0
- package/dist/upload-wallet-chain.d.ts +1 -1
- package/dist/upload-wallet-chain.js +17 -4
- package/dist/upload-wallet.js +1 -0
- package/dist/upload-wire.d.ts +7 -1
- package/dist/upload.js +5 -5
- package/dist/walrus-write.js +73 -6
- package/dist/walrus.d.ts +21 -2
- package/dist/walrus.js +116 -34
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/walrus.js
CHANGED
|
@@ -14,6 +14,8 @@ import { AGGREGATOR_ENV_VAR, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./env-vars.j
|
|
|
14
14
|
import { NmtsError } from "./errors.js";
|
|
15
15
|
import { host as runtime } from "./host.js";
|
|
16
16
|
import { reach, reachFetch } from "./reach.js";
|
|
17
|
+
import { raceHosts } from "./read-race.js";
|
|
18
|
+
import { REGISTRY_AGGREGATORS } from "./road-hosts.generated.js";
|
|
17
19
|
/**
|
|
18
20
|
* Curated Walrus aggregator (read) endpoints per network, preference order.
|
|
19
21
|
*
|
|
@@ -23,7 +25,7 @@ import { reach, reachFetch } from "./reach.js";
|
|
|
23
25
|
* provenance and the reason each host and not another; this copy exists because this package
|
|
24
26
|
* imports nothing from that tree, and `deploy/check-walrus-hosts.mjs` set-compares the two.
|
|
25
27
|
*/
|
|
26
|
-
export const
|
|
28
|
+
export const PINNED_AGGREGATOR_HOSTS = {
|
|
27
29
|
testnet: [
|
|
28
30
|
"https://aggregator.walrus-testnet.walrus.space",
|
|
29
31
|
"https://walrus-testnet-aggregator.nodeinfra.com",
|
|
@@ -33,6 +35,19 @@ export const AGGREGATOR_HOSTS = {
|
|
|
33
35
|
"https://sui-walrus-mainnet-aggregator.bwarelabs.com",
|
|
34
36
|
],
|
|
35
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* ⭐ D51: the two rows above, then every other aggregator in Walrus's operator registry that served
|
|
40
|
+
* the probe blob (`deploy/gen-roads.mjs`, the same generated list the browser and its CSP read).
|
|
41
|
+
* A read asks them as a staggered race, so a dead row costs a second and a half, not a timeout.
|
|
42
|
+
*/
|
|
43
|
+
export const AGGREGATOR_HOSTS = {
|
|
44
|
+
testnet: withRegistry("testnet"),
|
|
45
|
+
mainnet: withRegistry("mainnet"),
|
|
46
|
+
};
|
|
47
|
+
function withRegistry(network) {
|
|
48
|
+
const pinned = PINNED_AGGREGATOR_HOSTS[network] ?? [];
|
|
49
|
+
return [...pinned, ...REGISTRY_AGGREGATORS[network].filter((h) => !pinned.includes(h))];
|
|
50
|
+
}
|
|
36
51
|
/**
|
|
37
52
|
* Curated Walrus upload-relay (write) endpoints per network, preference order.
|
|
38
53
|
*
|
|
@@ -40,10 +55,20 @@ export const AGGREGATOR_HOSTS = {
|
|
|
40
55
|
* register transaction the server pays a tip in, so the bytes have to go to the SAME host the
|
|
41
56
|
* reservation was made for. That is why a write picks its host BEFORE the storage is bought and
|
|
42
57
|
* then never moves: failing over to a second relay would push bytes nobody paid that relay for.
|
|
58
|
+
*
|
|
59
|
+
* ⭐ THE SECOND ROW (D51, 2026-11-10) is Studio Mirai's public relay, an operator in Walrus's registry
|
|
60
|
+
* whose relay the registry does not list: found by asking each registry operator's relay-shaped
|
|
61
|
+
* name for `/v1/tip-config` (two of 366 answered, this one on both networks). Its tip is 3,000,000
|
|
62
|
+
* MIST plus 60 per encoded KiB, above Mysten's, so it is the second choice and only on a wallet
|
|
63
|
+
* upload (the person pays it and sees it first; the treasury pays only the relays the chain
|
|
64
|
+
* service allows). Picked once at the start of a run, like the roads after it (`upload-road.ts`).
|
|
65
|
+
*
|
|
66
|
+
* ⭐ THE LATER ROADS ARE NOT ROWS HERE (D50 · D51): the storage nodes, then NMTS's own no-tip relay,
|
|
67
|
+
* chosen once at the start of a run, before the price, only when no relay here answers.
|
|
43
68
|
*/
|
|
44
69
|
export const RELAY_HOSTS = {
|
|
45
|
-
testnet: ["https://upload-relay.testnet.walrus.space"],
|
|
46
|
-
mainnet: ["https://upload-relay.mainnet.walrus.space"],
|
|
70
|
+
testnet: ["https://upload-relay.testnet.walrus.space", "https://upload-relay.testnet.walrus.mirai.cloud"],
|
|
71
|
+
mainnet: ["https://upload-relay.mainnet.walrus.space", "https://upload-relay.mainnet.walrus.mirai.cloud"],
|
|
47
72
|
};
|
|
48
73
|
/**
|
|
49
74
|
* Sui node endpoints per network, spoken to over gRPC-web (`sui-rpc.ts`), first-that-answers.
|
|
@@ -59,14 +84,28 @@ export const RELAY_HOSTS = {
|
|
|
59
84
|
* (mainnet). Every host below answered chain id, a balance, an object and the gas price over
|
|
60
85
|
* gRPC-web that morning. Two operators per network — Suiscan and Mysten Labs — in the browser's
|
|
61
86
|
* order (`web/src/lib/walrus/network-hosts.ts` says why mainnet keeps Suiscan first). A test
|
|
62
|
-
* and `deploy/check-walrus-hosts.mjs` hold this table to the browser's.
|
|
87
|
+
* and `deploy/check-walrus-hosts.mjs` hold this table to the browser's. Since 2026-11-10 (D51)
|
|
88
|
+
* mainnet adds 01NODE and PublicNode (Allnodes) after those two, measured answering.
|
|
63
89
|
*/
|
|
64
90
|
export const SUI_RPC_HOSTS = {
|
|
65
91
|
testnet: ["https://fullnode.testnet.sui.io", "https://rpc-testnet.suiscan.xyz"],
|
|
66
|
-
mainnet: [
|
|
92
|
+
mainnet: [
|
|
93
|
+
"https://rpc-mainnet.suiscan.xyz",
|
|
94
|
+
"https://fullnode.mainnet.sui.io",
|
|
95
|
+
"https://sui.01.ro",
|
|
96
|
+
"https://sui-grpc-web.publicnode.com",
|
|
97
|
+
],
|
|
67
98
|
};
|
|
68
|
-
/** How long one host gets before
|
|
99
|
+
/** How long one host gets before it is given up. A read that stalls is a read that failed. */
|
|
69
100
|
export const READ_TIMEOUT_MS = 60_000;
|
|
101
|
+
/** How long the race waits for an answer before it asks the next host as well (D51). */
|
|
102
|
+
export const READ_HEDGE_MS = 1_500;
|
|
103
|
+
/** At most this many hosts waiting at once, hanging ones included. */
|
|
104
|
+
const READ_MAX_IN_FLIGHT = 12;
|
|
105
|
+
/** A host that sends no headers in this long is given up, so hanging hosts do not hold the race. */
|
|
106
|
+
const READ_HEADER_TIMEOUT_MS = 20_000;
|
|
107
|
+
/** This many 404s, and no other answer, mean the bytes are not there; asking dozens more says the same. */
|
|
108
|
+
const NOT_FOUND_QUORUM = 3;
|
|
70
109
|
// Re-exported so every caller still finds them here; the names themselves live in a module with no
|
|
71
110
|
// imports, because `nmts --help` prints them (`env-vars.ts`).
|
|
72
111
|
export { AGGREGATOR_ENV_VAR, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./env-vars.js";
|
|
@@ -152,13 +191,13 @@ function fromEnvironment() {
|
|
|
152
191
|
*/
|
|
153
192
|
function hostsFor(network, options) {
|
|
154
193
|
if (options.hosts !== undefined && options.hosts.length > 0)
|
|
155
|
-
return options.hosts;
|
|
194
|
+
return { hosts: options.hosts, named: true };
|
|
156
195
|
const asked = reach().aggregators;
|
|
157
196
|
if (asked !== undefined && asked.length > 0)
|
|
158
|
-
return asked;
|
|
197
|
+
return { hosts: asked, named: true };
|
|
159
198
|
const chosen = fromEnvironment();
|
|
160
199
|
if (chosen !== null)
|
|
161
|
-
return chosen;
|
|
200
|
+
return { hosts: chosen, named: true };
|
|
162
201
|
const known = AGGREGATOR_HOSTS[network];
|
|
163
202
|
if (known === undefined) {
|
|
164
203
|
throw new NmtsError(`No storage-network hosts are known for "${network}".`, {
|
|
@@ -166,28 +205,73 @@ function hostsFor(network, options) {
|
|
|
166
205
|
nextStep: "Use --network mainnet or --network testnet.",
|
|
167
206
|
});
|
|
168
207
|
}
|
|
169
|
-
return known;
|
|
208
|
+
return { hosts: known, named: false };
|
|
170
209
|
}
|
|
171
210
|
/**
|
|
172
|
-
* Fetch one stored object,
|
|
211
|
+
* Fetch one stored object: the hosts as a staggered race, then the storage nodes themselves (D51).
|
|
173
212
|
*
|
|
174
213
|
* ⛔ It reports what it tried. A read that fails everywhere is either a blob that is gone, a
|
|
175
214
|
* network that is wrong, or hosts that are all down, and those need different next steps — a
|
|
176
215
|
* bare "not found" would send somebody looking for the wrong one.
|
|
177
216
|
*/
|
|
178
|
-
async function readFrom(network, pathOf, what, options) {
|
|
179
|
-
const hosts = hostsFor(network, options);
|
|
217
|
+
async function readFrom(network, pathOf, what, options, node) {
|
|
218
|
+
const { hosts, named } = hostsFor(network, options);
|
|
180
219
|
const tried = [];
|
|
181
|
-
|
|
220
|
+
const raced = await readRace(hosts, pathOf, options, tried);
|
|
221
|
+
if (raced !== null)
|
|
222
|
+
return raced;
|
|
223
|
+
const notFound = tried.filter((t) => t.endsWith("→ 404")).length;
|
|
224
|
+
const sawOther = tried.length > notFound;
|
|
225
|
+
// ⭐ D51: the storage nodes, when no aggregator served the bytes for a reason other than "not
|
|
226
|
+
// found". Not when somebody named the hosts: naming them says "those", as above.
|
|
227
|
+
if (node !== undefined && !named && sawOther && options.signal?.aborted !== true) {
|
|
228
|
+
try {
|
|
229
|
+
const bytes = await (await import("./node-read.js")).readFromNodes(network, node.kind, node.id);
|
|
230
|
+
const range = options.range;
|
|
231
|
+
return range === undefined ? bytes : bytes.subarray(range.start, Math.min(range.end, bytes.length));
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
tried.push(`the storage nodes → ${error instanceof Error ? error.message : "no answer"}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
throw new NmtsError(`${what} could not be read from the ${network} storage network.`, {
|
|
238
|
+
exitCode: 5,
|
|
239
|
+
nextStep: `Tried: ${tried.join(" · ")}. If every host answered 404, either the bytes are gone or ` +
|
|
240
|
+
`this is the wrong network — the same identifier does not exist on both.`,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Ask every host for one object as a staggered race (`read-race.ts`) and return the first body.
|
|
245
|
+
*
|
|
246
|
+
* ⛔ The reason each host failed is kept, not flattened to "failed". A timeout and a refused
|
|
247
|
+
* connection mean different things, and the reasons are what the person reads.
|
|
248
|
+
*/
|
|
249
|
+
function readRace(hosts, pathOf, options, tried) {
|
|
250
|
+
const overall = AbortSignal.timeout(options.timeoutMs ?? READ_TIMEOUT_MS);
|
|
251
|
+
const reason = (error) => (error instanceof Error ? error.message : "no answer");
|
|
252
|
+
return raceHosts(hosts, async (host, signal) => {
|
|
182
253
|
const url = pathOf(host.replace(/\/$/, ""));
|
|
183
|
-
const timer = AbortSignal.timeout(options.timeoutMs ?? READ_TIMEOUT_MS);
|
|
184
|
-
const signal = options.signal === undefined ? timer : AbortSignal.any([timer, options.signal]);
|
|
185
254
|
try {
|
|
186
|
-
const response = await reachFetch(url, {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
255
|
+
const response = await reachFetch(url, {
|
|
256
|
+
signal: AbortSignal.any([signal, overall]),
|
|
257
|
+
redirect: "follow",
|
|
258
|
+
...headersFor(options),
|
|
259
|
+
});
|
|
260
|
+
if (response.ok)
|
|
261
|
+
return { response };
|
|
262
|
+
tried.push(`${host} → ${response.status}`);
|
|
263
|
+
void response.body?.cancel();
|
|
264
|
+
return response.status === 404 ? "not-found" : "failed";
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
// A host stopped because another one answered first is not a failure worth reporting.
|
|
268
|
+
if (!(signal.aborted && signal.reason instanceof DOMException && signal.reason.name === "AbortError")) {
|
|
269
|
+
tried.push(`${host} → ${reason(error)}`);
|
|
190
270
|
}
|
|
271
|
+
return "failed";
|
|
272
|
+
}
|
|
273
|
+
}, async (host, response) => {
|
|
274
|
+
try {
|
|
191
275
|
const body = new Uint8Array(await response.arrayBuffer());
|
|
192
276
|
const range = options.range;
|
|
193
277
|
if (range === undefined)
|
|
@@ -196,22 +280,20 @@ async function readFrom(network, pathOf, what, options) {
|
|
|
196
280
|
// A 206 already holds exactly the asked-for bytes; a 200 holds the object from byte zero.
|
|
197
281
|
if (body.length === want)
|
|
198
282
|
return body;
|
|
199
|
-
if (body.length < range.end)
|
|
200
|
-
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
283
|
+
if (body.length < range.end)
|
|
284
|
+
throw new Error(`answered ${body.length} bytes for a ${want}-byte range`);
|
|
203
285
|
return body.subarray(range.start, range.end);
|
|
204
286
|
}
|
|
205
287
|
catch (error) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
tried.push(`${host} → ${error instanceof Error ? error.message : "no answer"}`);
|
|
288
|
+
tried.push(`${host} → ${reason(error)}`);
|
|
289
|
+
throw error;
|
|
209
290
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
291
|
+
}, {
|
|
292
|
+
hedgeMs: READ_HEDGE_MS,
|
|
293
|
+
maxInFlight: READ_MAX_IN_FLIGHT,
|
|
294
|
+
headerTimeoutMs: READ_HEADER_TIMEOUT_MS,
|
|
295
|
+
notFoundQuorum: NOT_FOUND_QUORUM,
|
|
296
|
+
signal: options.signal,
|
|
215
297
|
});
|
|
216
298
|
}
|
|
217
299
|
/** The `Range` header for a partial read, or nothing at all for a whole one. */
|
|
@@ -224,7 +306,7 @@ function headersFor(options) {
|
|
|
224
306
|
}
|
|
225
307
|
/** Whole-blob read: `GET {aggregator}/v1/blobs/{blobId}`. */
|
|
226
308
|
export function readBlob(network, blobId, options = {}) {
|
|
227
|
-
return readFrom(network, (host) => `${host}/v1/blobs/${encodeURIComponent(blobId)}`, `Blob ${blobId}`, options);
|
|
309
|
+
return readFrom(network, (host) => `${host}/v1/blobs/${encodeURIComponent(blobId)}`, `Blob ${blobId}`, options, { kind: "blob", id: blobId });
|
|
228
310
|
}
|
|
229
311
|
/**
|
|
230
312
|
* Quilt-patch read: `GET {aggregator}/v1/blobs/by-quilt-patch-id/{patchId}`.
|
|
@@ -233,5 +315,5 @@ export function readBlob(network, blobId, options = {}) {
|
|
|
233
315
|
* under 64 MiB share a quilt, so this is the common path rather than the exotic one.
|
|
234
316
|
*/
|
|
235
317
|
export function readQuiltPatch(network, patchId, options = {}) {
|
|
236
|
-
return readFrom(network, (host) => `${host}/v1/blobs/by-quilt-patch-id/${encodeURIComponent(patchId)}`, `Quilt patch ${patchId}`, options);
|
|
318
|
+
return readFrom(network, (host) => `${host}/v1/blobs/by-quilt-patch-id/${encodeURIComponent(patchId)}`, `Quilt patch ${patchId}`, options, { kind: "patch", id: patchId });
|
|
237
319
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needmoretruth/nmts-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "Command-line and MCP access to NMTS (NeedMoreTruthStorage, https://nmts.me): open-source, end-to-end encrypted storage on the Walrus network. No fee to NMTS; you pay the network from your own wallet. For people and for their agents.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
package/server.json
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"url": "https://github.com/needmoretruth/nmts-cli",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.55.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
14
14
|
"identifier": "@needmoretruth/nmts-cli",
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.55.0",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|