@needmoretruth/nmts-cli 0.43.0 → 0.44.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/AGENTS.md +1 -1
- package/CHANGELOG.md +23 -0
- package/README.ko.md +8 -2
- package/README.md +8 -2
- package/dist/account.d.ts +7 -3
- package/dist/account.js +46 -19
- package/dist/arg-options.d.ts +16 -0
- package/dist/args.js +5 -2
- package/dist/artifact-about.d.ts +1 -1
- package/dist/commands/ai-account.d.ts +34 -0
- package/dist/commands/ai-account.js +260 -0
- package/dist/commands/balance.d.ts +68 -0
- package/dist/commands/balance.js +11 -1
- package/dist/commands/extend.d.ts +3 -0
- package/dist/commands/extend.js +1 -0
- package/dist/commands/login.js +2 -2
- package/dist/commands/push-wallet.js +4 -1
- package/dist/commands/push.d.ts +3 -0
- package/dist/commands/put-payer.d.ts +3 -1
- package/dist/commands/put-payer.js +13 -1
- package/dist/commands/put-wallet.d.ts +31 -0
- package/dist/commands/put-wallet.js +84 -10
- package/dist/commands/put.d.ts +5 -0
- package/dist/commands/whoami.d.ts +4 -0
- package/dist/commands/whoami.js +14 -1
- package/dist/crypto-surface.d.ts +11 -0
- package/dist/crypto-surface.js +6 -0
- package/dist/drive-edit/tree.d.ts +12 -0
- package/dist/drive-edit/tree.js +25 -4
- package/dist/drive-erase.d.ts +5 -3
- package/dist/drive-erase.js +7 -2
- package/dist/help-options.d.ts +2 -0
- package/dist/help-options.js +142 -0
- package/dist/help.js +10 -123
- package/dist/main.js +14 -19
- package/dist/mcp-tools/reads.js +4 -3
- package/dist/portable.d.ts +1 -1
- package/dist/portable.js +1 -1
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/refill-source.d.ts +69 -0
- package/dist/refill-source.js +143 -0
- package/dist/risk.d.ts +12 -0
- package/dist/risk.js +16 -0
- package/dist/shared/lib/wallet/activity.js +23 -1
- package/dist/standing-tip.d.ts +26 -0
- package/dist/standing-tip.js +31 -0
- package/dist/upload-wallet-plan.d.ts +8 -0
- package/dist/upload-wallet-plan.js +12 -3
- package/dist/walrus.d.ts +9 -1
- package/dist/walrus.js +17 -3
- package/docs/commands/ai-account.md +25 -0
- package/docs/commands/login.md +4 -3
- package/docs/commands/verify.md +1 -1
- package/docs/commands/whoami.md +4 -0
- package/examples/podman.sh +48 -0
- package/package.json +2 -1
- package/server.json +2 -2
- package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +42 -6
- package/vendor/nmts-crypto/nmts_crypto_wasm.js +105 -2
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +9 -4
package/dist/commands/balance.js
CHANGED
|
@@ -64,9 +64,19 @@ function asSummary(value) {
|
|
|
64
64
|
},
|
|
65
65
|
terms: { acceptance_required: isRecord(terms) && terms["acceptance_required"] === true },
|
|
66
66
|
ai_account: value["ai_account"] === true,
|
|
67
|
+
network_copy: value["network_copy"] === true,
|
|
67
68
|
deposits: depositRows(credits["deposits"]),
|
|
68
69
|
};
|
|
69
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* The narrow account read, typed — for the other commands that need one number out of it.
|
|
73
|
+
*
|
|
74
|
+
* ⛔ ONE READER OF THIS ROUTE. A second command that narrowed the answer itself would be a second
|
|
75
|
+
* opinion about which fields a server is allowed to be missing.
|
|
76
|
+
*/
|
|
77
|
+
export async function readAccountSummary(server, apiKey) {
|
|
78
|
+
return asSummary(await request(server, "/v1/account/summary", { token: apiKey }));
|
|
79
|
+
}
|
|
70
80
|
/**
|
|
71
81
|
* The per-file deposit rows, when the answer carries them.
|
|
72
82
|
*
|
|
@@ -96,7 +106,7 @@ function plural(n, one, many) {
|
|
|
96
106
|
export async function balance(options = {}) {
|
|
97
107
|
const say = options.write ?? ((line) => process.stdout.write(`${line}\n`));
|
|
98
108
|
const session = await openSession({ server: options.server, network: options.network });
|
|
99
|
-
const summary =
|
|
109
|
+
const summary = await readAccountSummary(session.server, session.apiKey);
|
|
100
110
|
if (options.json === true) {
|
|
101
111
|
say(JSON.stringify(summary));
|
|
102
112
|
return 0;
|
|
@@ -27,6 +27,9 @@ export interface ExtendOptions {
|
|
|
27
27
|
sign?: SignExtension;
|
|
28
28
|
/** The instant to measure against. Passed in so one run reports one moment. */
|
|
29
29
|
now?: number;
|
|
30
|
+
/** `--trust-server-tip-address`: let THIS SERVER name where the standing gift goes. Off unless
|
|
31
|
+
* typed, and only for a server the caller runs (`standing-tip.ts`). */
|
|
32
|
+
trustServerTipAddress?: boolean;
|
|
30
33
|
/** ⚠ SEAMS, NOT OPTIONS — the standing tip's own read and signature. No flag reaches them. */
|
|
31
34
|
tip?: Pick<StandingTipInput, "readDonation" | "sign">;
|
|
32
35
|
/** `--wallet N`: which wallet pays, this run only. Absent = the account's own number. */
|
package/dist/commands/extend.js
CHANGED
|
@@ -143,6 +143,7 @@ export async function extend(target, options = {}) {
|
|
|
143
143
|
wallet: plan.wallet,
|
|
144
144
|
paidWalFrost: budget.priceFrost,
|
|
145
145
|
say: options.json === true ? (line) => void process.stderr.write(`${line}\n`) : say,
|
|
146
|
+
trustServerAddress: options.trustServerTipAddress === true,
|
|
146
147
|
...(options.tip ?? {}),
|
|
147
148
|
});
|
|
148
149
|
return 0;
|
package/dist/commands/login.js
CHANGED
|
@@ -58,12 +58,12 @@ export async function login(options = {}) {
|
|
|
58
58
|
// line mode, where it echoes what is typed and swallows lines the next prompt never sees —
|
|
59
59
|
// and this command asks up to three things with a check in the middle.
|
|
60
60
|
const exit = await holdTerminal(async () => {
|
|
61
|
-
const
|
|
61
|
+
const typed = await readTheCode(options, server);
|
|
62
62
|
// ⛔ CHECKED BEFORE IT IS WRITTEN. The engine verifies the code's own check symbol offline, so
|
|
63
63
|
// a mistyped code fails here as "that is not a code" instead of being stored and coming
|
|
64
64
|
// back later as a sign-in failure indistinguishable from a wrong password or a suspended
|
|
65
65
|
// account.
|
|
66
|
-
await assertUsableCode(
|
|
66
|
+
const code = await assertUsableCode(typed);
|
|
67
67
|
if (options.env === true)
|
|
68
68
|
return printEnvForm(code, say);
|
|
69
69
|
// ⛔ THE KEY IS SETTLED BEFORE THE PASSPHRASE IS ASKED FOR, for the reason the code is checked
|
|
@@ -14,7 +14,7 @@ import { folderFor } from "./push.js";
|
|
|
14
14
|
/** The wallet rail, one file at a time, stopping at the first failure as the credit rail does. */
|
|
15
15
|
export async function pushWithWallet(session, options, run) {
|
|
16
16
|
const { say } = run;
|
|
17
|
-
const { uploadOneWithWallet } = await import("./put-wallet.js");
|
|
17
|
+
const { readNetworkCopy, uploadOneWithWallet } = await import("./put-wallet.js");
|
|
18
18
|
const ctx = {
|
|
19
19
|
code: session.code,
|
|
20
20
|
apiKey: session.apiKey,
|
|
@@ -31,6 +31,9 @@ export async function pushWithWallet(session, options, run) {
|
|
|
31
31
|
...options,
|
|
32
32
|
readActiveWallet: async () => activeWalletOf(run.settings),
|
|
33
33
|
}),
|
|
34
|
+
// ⛔ ONCE FOR THE WHOLE RUN, not per file: it decides one sentence in each review and a read
|
|
35
|
+
// per file would be one request per file for nothing. `--json` prints no review at all.
|
|
36
|
+
networkCopy: options.json === true ? false : await readNetworkCopy(session.server, session.apiKey),
|
|
34
37
|
progress: new Progress(options.json === true ? silentSink() : stderrSink(), "uploading"),
|
|
35
38
|
say,
|
|
36
39
|
json: options.json === true,
|
package/dist/commands/push.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ export interface PushOptions {
|
|
|
21
21
|
storage?: string | undefined;
|
|
22
22
|
/** `--pay wallet`: which of this key's wallets pays, this run only. Absent = the account's own. */
|
|
23
23
|
wallet?: string | undefined;
|
|
24
|
+
/** `--trust-server-tip-address`: let THIS SERVER name where the standing gift goes. Off unless
|
|
25
|
+
* typed, and only for a server the caller runs (`standing-tip.ts`). */
|
|
26
|
+
trustServerTipAddress?: boolean;
|
|
24
27
|
json?: boolean;
|
|
25
28
|
write?: (line: string) => void;
|
|
26
29
|
/**
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/** Who pays, or a refusal for a payer this tool does not know. */
|
|
2
2
|
export declare function payerOf(pay: string | undefined): "credits" | "wallet";
|
|
3
|
-
/** The
|
|
3
|
+
/** The options that only mean something when the wallet pays, refused when it does not. */
|
|
4
4
|
export declare function refuseWalletOnlyOptions(options: {
|
|
5
5
|
epochs?: string | number | undefined;
|
|
6
6
|
storage?: string | undefined;
|
|
7
7
|
wallet?: string | undefined;
|
|
8
|
+
trustServerTipAddress?: boolean;
|
|
9
|
+
from?: string | undefined;
|
|
8
10
|
}): void;
|
|
@@ -18,7 +18,7 @@ export function payerOf(pay) {
|
|
|
18
18
|
nextStep: `Nothing was sent. --pay wallet buys the storage from the wallet this NMTS key derives; without it credits pay.`,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
/** The
|
|
21
|
+
/** The options that only mean something when the wallet pays, refused when it does not. */
|
|
22
22
|
export function refuseWalletOnlyOptions(options) {
|
|
23
23
|
if (options.wallet !== undefined) {
|
|
24
24
|
throw new NmtsError("--wallet only applies with --pay wallet: credits are not held in a wallet.", {
|
|
@@ -38,4 +38,16 @@ export function refuseWalletOnlyOptions(options) {
|
|
|
38
38
|
nextStep: `Nothing was sent. Add --pay wallet to use a storage resource this wallet holds.`,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
+
if (options.from !== undefined) {
|
|
42
|
+
throw new NmtsError("--from only applies with --pay wallet: it is how a credit-paid file moves onto the wallet.", {
|
|
43
|
+
exitCode: 2,
|
|
44
|
+
nextStep: `Nothing was sent. Add --pay wallet, which is what the re-upload is for.`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (options.trustServerTipAddress === true) {
|
|
48
|
+
throw new NmtsError("--trust-server-tip-address only applies with --pay wallet: a standing gift follows a wallet payment.", {
|
|
49
|
+
exitCode: 2,
|
|
50
|
+
nextStep: `Nothing was sent. A credit-paid upload sends no gift, so there is no address to trust.`,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
41
53
|
}
|
|
@@ -15,6 +15,14 @@ export interface WalletPayOptions {
|
|
|
15
15
|
epochs?: string | number | undefined;
|
|
16
16
|
/** `fit`, `whole`, or a held resource's object id. Absent = buy new storage. */
|
|
17
17
|
storage?: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* `--from <drive path>`: re-upload a file the account's CREDITS paid for, on the wallet's money.
|
|
20
|
+
*
|
|
21
|
+
* ⛔ IT IS A DOWNLOAD, A RE-SEAL AND AN OVERWRITE, not a transfer: no chain call can move the
|
|
22
|
+
* treasury's storage object to somebody's own wallet (`refill-source.ts`). The new file takes
|
|
23
|
+
* the old one's name and folder, and the old one goes to the trash.
|
|
24
|
+
*/
|
|
25
|
+
from?: string | undefined;
|
|
18
26
|
/** `--wallet N`: which wallet pays, this run only. Absent = the account's own number. */
|
|
19
27
|
wallet?: string | undefined;
|
|
20
28
|
/** The instant the wallet agreement is measured against. */
|
|
@@ -26,6 +34,13 @@ export interface WalletPayOptions {
|
|
|
26
34
|
register: SignBlobRegister;
|
|
27
35
|
certify: SignBlobCertify;
|
|
28
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* `--trust-server-tip-address`: let THIS SERVER name where the standing gift goes.
|
|
39
|
+
*
|
|
40
|
+
* ⛔ UNLIKE `tip` BELOW, THIS ONE IS A FLAG. It is off unless somebody typed it, and it belongs
|
|
41
|
+
* to a server they run themselves — see `standing-tip.ts` for what it costs elsewhere.
|
|
42
|
+
*/
|
|
43
|
+
trustServerTipAddress?: boolean;
|
|
29
44
|
/** ⚠ SEAMS, NOT OPTIONS — the standing tip's own read and signature. No flag reaches them. */
|
|
30
45
|
tip?: Pick<StandingTipInput, "readDonation" | "sign">;
|
|
31
46
|
/** The storage-network protocol and the server calls — seams for the tests, as `upload.ts` has. */
|
|
@@ -58,6 +73,13 @@ export interface WalletUploadContext {
|
|
|
58
73
|
settings?: AccountSettings | undefined;
|
|
59
74
|
/** Which of this key's wallets pays (`wallet-pay-index.ts`). Read from the same list as above. */
|
|
60
75
|
wallet: number;
|
|
76
|
+
/**
|
|
77
|
+
* Does this account ask its uploads to carry the recovery list's storage-network copy?
|
|
78
|
+
*
|
|
79
|
+
* ⛔ IT ONLY CHANGES A SENTENCE IN THE REVIEW, never what is signed or sent — which is why a read
|
|
80
|
+
* that fails arrives here as `null` instead of stopping an upload (`readNetworkCopy`).
|
|
81
|
+
*/
|
|
82
|
+
networkCopy: boolean | null;
|
|
61
83
|
progress: Progress;
|
|
62
84
|
say: (line: string) => void;
|
|
63
85
|
json: boolean;
|
|
@@ -81,3 +103,12 @@ export declare function uploadOneWithWallet(ctx: WalletUploadContext, file: Wall
|
|
|
81
103
|
resumed: boolean;
|
|
82
104
|
facts: Record<string, unknown>;
|
|
83
105
|
} | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Whether this account asks its uploads to carry the recovery list's copy — for the review's one
|
|
108
|
+
* sentence about it, and for nothing else.
|
|
109
|
+
*
|
|
110
|
+
* ⛔ A FAILED READ IS `null`, NOT A FAILED UPLOAD. What hangs on this is a sentence; a server that
|
|
111
|
+
* could not answer, or one older than the field, must not cost somebody the upload they asked
|
|
112
|
+
* for. `--json` skips the read entirely — there is no review to print.
|
|
113
|
+
*/
|
|
114
|
+
export declare function readNetworkCopy(server: string, apiKey: string): Promise<boolean | null>;
|
|
@@ -32,6 +32,7 @@ import { resolveServer } from "../server.js";
|
|
|
32
32
|
import { fileSource } from "../upload-file-node.js";
|
|
33
33
|
import { partSizeFor } from "../upload-price.js";
|
|
34
34
|
import { measureLocal } from "../upload-price-node.js";
|
|
35
|
+
import { downloadForRefill, findOriginal, settleRefill } from "../refill-source.js";
|
|
35
36
|
import { describeUploadReview } from "../upload-wallet-plan.js";
|
|
36
37
|
import { walletPut } from "../upload-wallet-put.js";
|
|
37
38
|
import { coinAmount } from "../wallet.js";
|
|
@@ -39,7 +40,9 @@ import { recordWalletSpend, requireWalletGrant } from "../wallet-grant.js";
|
|
|
39
40
|
import { folderIdFor } from "./put.js";
|
|
40
41
|
export async function putWithWallet(target, options) {
|
|
41
42
|
const say = options.write ?? ((line) => process.stdout.write(`${line}\n`));
|
|
42
|
-
|
|
43
|
+
const from = options.from;
|
|
44
|
+
refuseFromClashes(target, options);
|
|
45
|
+
if (from === undefined && (target === undefined || target === "")) {
|
|
43
46
|
throw new NmtsError("Say which file to put.", { exitCode: 2, nextStep: `\`${BINARY_NAME} put <file> --pay wallet\`` });
|
|
44
47
|
}
|
|
45
48
|
const resolved = await requireAccountCode();
|
|
@@ -50,8 +53,9 @@ export async function putWithWallet(target, options) {
|
|
|
50
53
|
nextStep: `Make a key on the account screen at nmts.me and put it in ${API_KEY_ENV_VAR}, or store it with \`${BINARY_NAME} login\`.`,
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
// ⛔ MEASURED BEFORE A SINGLE NETWORK CALL, as it always was: a path that is not a file is a
|
|
57
|
+
// command line to fix, and finding that out after three chain reads wastes somebody's time.
|
|
58
|
+
const local = from === undefined ? { localPath: resolve(target ?? ""), size: measureLocal(resolve(target ?? "")) } : null;
|
|
55
59
|
const stored = readCredentialsFile();
|
|
56
60
|
const server = resolveServer(options.server ?? stored?.server);
|
|
57
61
|
const network = resolveNetwork(server, options.network ?? stored?.network);
|
|
@@ -66,9 +70,12 @@ export async function putWithWallet(target, options) {
|
|
|
66
70
|
...options,
|
|
67
71
|
readActiveWallet: async () => activeWalletOf(list.manifest?.settings),
|
|
68
72
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
73
|
+
// ⛔ THE PLACE COMES FROM THE ORIGINAL, NOT FROM THE COMMAND LINE, when there is one: this
|
|
74
|
+
// replaces a file where it already sits, so its name and its folder are not open questions.
|
|
75
|
+
const original = from === undefined ? null : findOriginal(list.manifest?.entries ?? [], from);
|
|
76
|
+
const name = original?.name ?? options.name ?? basename(local?.localPath ?? "");
|
|
77
|
+
const destination = original?.destination ?? (options.to ?? "").replace(/^\.?\//, "").replace(/\/$/, "");
|
|
78
|
+
const parentId = original === null ? folderIdFor(options.to, list.manifest?.entries ?? []) : original.parentId;
|
|
72
79
|
const ctx = {
|
|
73
80
|
code: resolved.code,
|
|
74
81
|
apiKey: key.key,
|
|
@@ -81,19 +88,44 @@ export async function putWithWallet(target, options) {
|
|
|
81
88
|
onCollision: asked,
|
|
82
89
|
settings: list.manifest?.settings,
|
|
83
90
|
wallet,
|
|
91
|
+
networkCopy: options.json === true ? false : await readNetworkCopy(server, key.key),
|
|
84
92
|
progress: new Progress(options.json === true ? silentSink() : stderrSink(), "uploading"),
|
|
85
93
|
say,
|
|
86
94
|
json: options.json === true,
|
|
87
95
|
};
|
|
88
|
-
|
|
96
|
+
// ⛔ NOTHING IS DOWNLOADED FOR A DRY RUN. The price is arithmetic over the size the sealed list
|
|
97
|
+
// already holds, and `walletPut` returns at the review before the source is read — so the
|
|
98
|
+
// empty path below can only be reached by a run that got past the review, which is this one.
|
|
99
|
+
const scratch = original === null || options.dryRun === true ? null : await downloadForRefill({ server, apiKey: key.key, code: resolved.code, network, original });
|
|
100
|
+
let done;
|
|
101
|
+
try {
|
|
102
|
+
const size = local?.size ?? original?.entry.size ?? 0;
|
|
103
|
+
const localPath = local?.localPath ?? scratch?.localPath ?? "";
|
|
104
|
+
done = await uploadOneWithWallet(ctx, { localPath, size, name, parentId, destination }, options);
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
// ⛔ ON EVERY PATH OUT, INCLUDING THE FAILING ONES. What it removes is a decrypted copy of
|
|
108
|
+
// somebody's file; leaving one behind because a signature was refused is the worst case.
|
|
109
|
+
scratch?.remove();
|
|
110
|
+
}
|
|
89
111
|
if (done === null)
|
|
90
112
|
return 0;
|
|
113
|
+
// ⛔ THE NAME AND THE TRASH, AFTER THE PAID-FOR BYTES ARE IN THE LIST. See `settleRefill` for why
|
|
114
|
+
// this is a second write rather than an overwrite on the commit.
|
|
115
|
+
const settled = original === null
|
|
116
|
+
? null
|
|
117
|
+
: await settleRefill({ server, apiKey: key.key, code: resolved.code, accountId: identity.accountId }, original, done.itemId);
|
|
118
|
+
const savedAs = original?.name ?? done.savedAs;
|
|
91
119
|
if (options.json) {
|
|
92
|
-
say(JSON.stringify({ id: done.itemId, name:
|
|
120
|
+
say(JSON.stringify({ id: done.itemId, name: savedAs, ...done.facts, resumed: done.resumed, renamed: savedAs !== name, ...(original !== null ? { replacedIntoTrash: original.entry.id } : done.replaced ? { replacedIntoTrash: done.replaced } : {}), fileListVersion: settled ?? done.seq }));
|
|
93
121
|
return 0;
|
|
94
122
|
}
|
|
95
|
-
say(` saved as ${
|
|
96
|
-
if (
|
|
123
|
+
say(` saved as ${savedAs}`);
|
|
124
|
+
if (original !== null) {
|
|
125
|
+
say(` The file credits paid for is in the trash now — ${BINARY_NAME} restore brings it back for 30 days.`);
|
|
126
|
+
say(` Erasing it releases its storage and settles its deposit: ${BINARY_NAME} erase --release-storage.`);
|
|
127
|
+
}
|
|
128
|
+
else if (done.replaced)
|
|
97
129
|
say(` A file called ${name} was already there. It is in the trash now — ${BINARY_NAME} restore brings it back for 30 days.`);
|
|
98
130
|
else if (done.savedAs !== name)
|
|
99
131
|
say(` A file called ${name} was already there, so this one was numbered rather than replacing it.`);
|
|
@@ -101,6 +133,29 @@ export async function putWithWallet(target, options) {
|
|
|
101
133
|
say(` This finished an upload a previous run had already signed for. Nothing was signed now.`);
|
|
102
134
|
return 0;
|
|
103
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* The options `--from` leaves no room for, refused before anything is read.
|
|
138
|
+
*
|
|
139
|
+
* ⛔ REFUSED RATHER THAN IGNORED, for the reason `put-payer.ts` refuses the wallet-only options:
|
|
140
|
+
* somebody who typed `--name` meant it, and an upload that quietly used a different name would
|
|
141
|
+
* be discovered as a file in the wrong place, after the money moved.
|
|
142
|
+
*/
|
|
143
|
+
function refuseFromClashes(target, options) {
|
|
144
|
+
if (options.from === undefined)
|
|
145
|
+
return;
|
|
146
|
+
const nothing = `Nothing was signed and nothing was sent.`;
|
|
147
|
+
const clash = (what, why) => new NmtsError(`${what} does not apply with --from: ${why}`, { exitCode: 2, nextStep: nothing });
|
|
148
|
+
if (target !== undefined && target !== "") {
|
|
149
|
+
throw clash(`a local file`, `--from names the file, in the drive, and one run re-uploads one file.`);
|
|
150
|
+
}
|
|
151
|
+
if (options.name !== undefined)
|
|
152
|
+
throw clash(`--name`, `the re-upload keeps the name the file has.`);
|
|
153
|
+
if (options.to !== undefined)
|
|
154
|
+
throw clash(`--to`, `the re-upload keeps the folder the file is in.`);
|
|
155
|
+
if (options.onCollision !== undefined) {
|
|
156
|
+
throw clash(`--on-collision`, `a re-upload replaces the file it came from; that is what it is for.`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
104
159
|
/**
|
|
105
160
|
* Review, agree, upload and record ONE file for a person who is watching. Null when `--dry-run`
|
|
106
161
|
* stopped at the review.
|
|
@@ -148,6 +203,7 @@ export async function uploadOneWithWallet(ctx, file, options) {
|
|
|
148
203
|
tipMist: review.tipMist,
|
|
149
204
|
storage: review.storage,
|
|
150
205
|
heldResources: review.heldResources,
|
|
206
|
+
networkCopy: ctx.networkCopy,
|
|
151
207
|
}, review.budget);
|
|
152
208
|
},
|
|
153
209
|
agree: (review) => {
|
|
@@ -182,10 +238,28 @@ export async function uploadOneWithWallet(ctx, file, options) {
|
|
|
182
238
|
wallet: ctx.wallet,
|
|
183
239
|
paidWalFrost: outcome.resumed ? 0n : outcome.review.budget.walNeededFrost,
|
|
184
240
|
say: ctx.json ? (line) => void process.stderr.write(`${line}\n`) : say,
|
|
241
|
+
trustServerAddress: options.trustServerTipAddress === true,
|
|
185
242
|
...(options.tip ?? {}),
|
|
186
243
|
});
|
|
187
244
|
return { itemId: outcome.itemId, savedAs: outcome.savedAs, replaced: outcome.replaced, seq: outcome.fileListVersion, resumed: outcome.resumed, facts };
|
|
188
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Whether this account asks its uploads to carry the recovery list's copy — for the review's one
|
|
248
|
+
* sentence about it, and for nothing else.
|
|
249
|
+
*
|
|
250
|
+
* ⛔ A FAILED READ IS `null`, NOT A FAILED UPLOAD. What hangs on this is a sentence; a server that
|
|
251
|
+
* could not answer, or one older than the field, must not cost somebody the upload they asked
|
|
252
|
+
* for. `--json` skips the read entirely — there is no review to print.
|
|
253
|
+
*/
|
|
254
|
+
export async function readNetworkCopy(server, apiKey) {
|
|
255
|
+
try {
|
|
256
|
+
const { readAccountSummary } = await import("./balance.js");
|
|
257
|
+
return (await readAccountSummary(server, apiKey)).network_copy;
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
189
263
|
/** The review as `--json` prints it: base units as strings, with the coin amounts beside them. */
|
|
190
264
|
function factsOf(review) {
|
|
191
265
|
const { budget, storage } = review;
|
package/dist/commands/put.d.ts
CHANGED
|
@@ -35,8 +35,13 @@ export interface PutOptions {
|
|
|
35
35
|
epochs?: string | number | undefined;
|
|
36
36
|
/** `--pay wallet`: a held storage resource to use — `fit`, `whole`, or its object id. */
|
|
37
37
|
storage?: string | undefined;
|
|
38
|
+
/** `--pay wallet`: re-upload this file of the drive's on the wallet's money (`put-wallet.ts`). */
|
|
39
|
+
from?: string | undefined;
|
|
38
40
|
/** `--pay wallet`: which of this key's wallets pays, this run only. Absent = the account's own. */
|
|
39
41
|
wallet?: string | undefined;
|
|
42
|
+
/** `--trust-server-tip-address`: let THIS SERVER name where the standing gift goes. Off unless
|
|
43
|
+
* typed, and only for a server the caller runs (`standing-tip.ts`). */
|
|
44
|
+
trustServerTipAddress?: boolean;
|
|
40
45
|
json?: boolean;
|
|
41
46
|
write?: (line: string) => void;
|
|
42
47
|
}
|
|
@@ -4,6 +4,10 @@ export interface WhoamiOptions {
|
|
|
4
4
|
write?: (line: string) => void;
|
|
5
5
|
/** Print the NMTS key itself. A person's act — see the header. */
|
|
6
6
|
reveal?: boolean;
|
|
7
|
+
/** With `reveal`: print the key as its 15-word recovery phrase instead. */
|
|
8
|
+
phrase?: boolean;
|
|
9
|
+
/** The phrase's word list: `en` (default) or `ko`. */
|
|
10
|
+
lang?: string | undefined;
|
|
7
11
|
/** Machine-readable output. Only `--reveal` has one; the listing is for a person. */
|
|
8
12
|
json?: boolean;
|
|
9
13
|
}
|
package/dist/commands/whoami.js
CHANGED
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
// situation, a person copying it out of a machine they are sitting at, and it is refused while
|
|
12
12
|
// a mode is on. There is no MCP tool for it either: an agent driving this tool was handed the
|
|
13
13
|
// code already, so a surface that prints it can only ever move it somewhere new.
|
|
14
|
-
|
|
14
|
+
//
|
|
15
|
+
// ⭐ `--reveal --phrase` prints the same key as its 15-word recovery phrase (`--lang ko` for the
|
|
16
|
+
// Korean list). It is the key in another spelling, so it rides the same flag and the same rule.
|
|
17
|
+
import { identityOf, phraseOf } from "../account.js";
|
|
15
18
|
import { requireAccountCode } from "../code-access.js";
|
|
16
19
|
import { CODE_ENV_VAR, readCredentialsFile } from "../credentials.js";
|
|
17
20
|
import { resolveNetwork } from "../network.js";
|
|
@@ -20,6 +23,16 @@ export async function whoami(options = {}) {
|
|
|
20
23
|
const say = options.write ?? ((line) => process.stdout.write(`${line}\n`));
|
|
21
24
|
const resolved = await requireAccountCode();
|
|
22
25
|
const identity = await identityOf(resolved.code);
|
|
26
|
+
if (options.reveal === true && options.phrase === true) {
|
|
27
|
+
const phrase = await phraseOf(resolved.code, options.lang);
|
|
28
|
+
if (options.json === true) {
|
|
29
|
+
say(JSON.stringify({ recovery_phrase: phrase }));
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
say(`This phrase is the NMTS key in 15 words: anyone who reads it can open every file.`);
|
|
33
|
+
say(phrase);
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
23
36
|
if (options.reveal === true) {
|
|
24
37
|
if (options.json === true) {
|
|
25
38
|
say(JSON.stringify({ account_code: identity.displayCode }));
|
package/dist/crypto-surface.d.ts
CHANGED
|
@@ -52,8 +52,19 @@ export interface CryptoGlue {
|
|
|
52
52
|
account_code_parse(input: string): Uint8Array;
|
|
53
53
|
/** The grouped, human-readable spelling of a code. */
|
|
54
54
|
account_code_display(codeBytes: Uint8Array): string;
|
|
55
|
+
/** The same code as its 15-word recovery phrase (BIP-39), `en` or `ko`. */
|
|
56
|
+
account_code_phrase(codeBytes: Uint8Array, lang: string): string;
|
|
55
57
|
/** The full derivation output. Offsets are named in DERIVED below. */
|
|
56
58
|
kdf_derive(codeBytes: Uint8Array): Uint8Array;
|
|
59
|
+
/**
|
|
60
|
+
* The NMTS KEY of this account's AI account number `index` (1-based), from the 32-byte
|
|
61
|
+
* `aiAccountRoot` slice of the derivation (NCF-3 §1.5).
|
|
62
|
+
*
|
|
63
|
+
* ⛔ IT IS A KEY, NOT A SEED, and the same root and index always give the same one back — which
|
|
64
|
+
* is why a place that was erased can be re-derived rather than lost, and why nothing has to
|
|
65
|
+
* store what it returns. ⚠ Wipe the root after calling: it is the parent of every one of them.
|
|
66
|
+
*/
|
|
67
|
+
derive_ai_account_code(aiAccountRoot: Uint8Array, index: number): string;
|
|
57
68
|
/** Display form — the grouped PUBLIC CODE a person reads, copies and types. */
|
|
58
69
|
share_address_display(address: Uint8Array): string;
|
|
59
70
|
/**
|
package/dist/crypto-surface.js
CHANGED
|
@@ -14,6 +14,7 @@ const REQUIRED = [
|
|
|
14
14
|
"account_code_generate",
|
|
15
15
|
"account_code_parse",
|
|
16
16
|
"account_code_display",
|
|
17
|
+
"account_code_phrase",
|
|
17
18
|
"kdf_derive",
|
|
18
19
|
"share_address_display",
|
|
19
20
|
"share_address_parse",
|
|
@@ -37,6 +38,11 @@ const REQUIRED = [
|
|
|
37
38
|
"opener_seal",
|
|
38
39
|
"opener_open",
|
|
39
40
|
"wallet_seed_for",
|
|
41
|
+
// The AI-account derivation (NCF-3 §1.5). Required rather than optional for the reason the
|
|
42
|
+
// opener surface is: a build of the engine without it cannot make an AI account at all, and
|
|
43
|
+
// "this function is missing" said at load time is a different day's problem from
|
|
44
|
+
// `undefined is not a function` in the middle of deriving somebody's second account.
|
|
45
|
+
"derive_ai_account_code",
|
|
40
46
|
];
|
|
41
47
|
export function isCryptoGlue(value) {
|
|
42
48
|
return missingExports(value).length === 0;
|
|
@@ -13,3 +13,15 @@ export declare function uniqueById(files: readonly ManifestEntry[]): ManifestEnt
|
|
|
13
13
|
* `rm` takes this set whole. `restore` cannot: see the note at the call site.
|
|
14
14
|
*/
|
|
15
15
|
export declare function filesUnder(entries: readonly ManifestEntry[], rootId: string): ManifestEntry[];
|
|
16
|
+
/**
|
|
17
|
+
* Every FOLDER under one entry, the root itself excluded. Empty when the root is a file.
|
|
18
|
+
*
|
|
19
|
+
* ⛔ IT EXISTS BECAUSE A FOLDER WITH NO FILE IN IT HAS NOTHING TO CARRY IT OUT. What leaves the
|
|
20
|
+
* sealed list is decided from the files under a named folder; a sub-folder holding none was in
|
|
21
|
+
* nobody's set, so it stayed — an entry whose parent had gone, which the list still showed and
|
|
22
|
+
* nothing could open or reach (2026-09-20).
|
|
23
|
+
*
|
|
24
|
+
* ⚠ Trashed descendants are included, for the reason `filesUnder` includes them: somebody who
|
|
25
|
+
* trashed a sub-folder last week and then erases its parent expects both to be gone.
|
|
26
|
+
*/
|
|
27
|
+
export declare function foldersUnder(entries: readonly ManifestEntry[], rootId: string): ManifestEntry[];
|
package/dist/drive-edit/tree.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Walking the list: the three questions the edits below ask about where an entry sits, and the one
|
|
2
2
|
// that gathers the files a folder carries.
|
|
3
|
-
import { buildIndex, KIND_FILE } from "../drive-paths.js";
|
|
3
|
+
import { buildIndex, KIND_FILE, KIND_FOLDER } from "../drive-paths.js";
|
|
4
4
|
/** Is `id` at or under `rootId`? Used to refuse moving a folder into its own subtree. */
|
|
5
5
|
export function isUnder(entries, id, rootId) {
|
|
6
6
|
const byId = buildIndex(entries).byId;
|
|
@@ -43,11 +43,32 @@ export function uniqueById(files) {
|
|
|
43
43
|
* `rm` takes this set whole. `restore` cannot: see the note at the call site.
|
|
44
44
|
*/
|
|
45
45
|
export function filesUnder(entries, rootId) {
|
|
46
|
+
return under(entries, rootId, KIND_FILE);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Every FOLDER under one entry, the root itself excluded. Empty when the root is a file.
|
|
50
|
+
*
|
|
51
|
+
* ⛔ IT EXISTS BECAUSE A FOLDER WITH NO FILE IN IT HAS NOTHING TO CARRY IT OUT. What leaves the
|
|
52
|
+
* sealed list is decided from the files under a named folder; a sub-folder holding none was in
|
|
53
|
+
* nobody's set, so it stayed — an entry whose parent had gone, which the list still showed and
|
|
54
|
+
* nothing could open or reach (2026-09-20).
|
|
55
|
+
*
|
|
56
|
+
* ⚠ Trashed descendants are included, for the reason `filesUnder` includes them: somebody who
|
|
57
|
+
* trashed a sub-folder last week and then erases its parent expects both to be gone.
|
|
58
|
+
*/
|
|
59
|
+
export function foldersUnder(entries, rootId) {
|
|
60
|
+
const root = entries.find((e) => e.id === rootId);
|
|
61
|
+
if (root === undefined || root.kind === KIND_FILE)
|
|
62
|
+
return [];
|
|
63
|
+
return under(entries, rootId, KIND_FOLDER);
|
|
64
|
+
}
|
|
65
|
+
/** The walk both of the two above make: everything of one kind at or under `rootId`. */
|
|
66
|
+
function under(entries, rootId, kind) {
|
|
46
67
|
const root = entries.find((e) => e.id === rootId);
|
|
47
68
|
if (root === undefined)
|
|
48
69
|
return [];
|
|
49
70
|
if (root.kind === KIND_FILE)
|
|
50
|
-
return [root];
|
|
71
|
+
return kind === KIND_FILE ? [root] : [];
|
|
51
72
|
const childrenOf = new Map();
|
|
52
73
|
for (const e of entries) {
|
|
53
74
|
const list = childrenOf.get(e.parentId);
|
|
@@ -67,9 +88,9 @@ export function filesUnder(entries, rootId) {
|
|
|
67
88
|
if (seen.has(child.id))
|
|
68
89
|
continue;
|
|
69
90
|
seen.add(child.id);
|
|
70
|
-
if (child.kind ===
|
|
91
|
+
if (child.kind === kind)
|
|
71
92
|
out.push(child);
|
|
72
|
-
|
|
93
|
+
if (child.kind !== KIND_FILE)
|
|
73
94
|
queue.push(child.id);
|
|
74
95
|
}
|
|
75
96
|
}
|
package/dist/drive-erase.d.ts
CHANGED
|
@@ -24,10 +24,12 @@ export interface ErasePlan {
|
|
|
24
24
|
/** Every FILE going: the ones named, and every file under a folder that was named. */
|
|
25
25
|
readonly files: readonly ErasePath[];
|
|
26
26
|
/**
|
|
27
|
-
* The ids leaving the sealed list — the files above
|
|
27
|
+
* The ids leaving the sealed list — the files above, the folders that were named, and every
|
|
28
|
+
* folder under one of them.
|
|
28
29
|
*
|
|
29
|
-
* ⚠ WIDER THAN `files` ON PURPOSE. A
|
|
30
|
-
*
|
|
30
|
+
* ⚠ WIDER THAN `files` ON PURPOSE. A folder has no server row of its own, so nothing is erased
|
|
31
|
+
* for it; its entry still has to go, or the list keeps a folder whose contents are gone — and
|
|
32
|
+
* a sub-folder left behind is the worse half of that, because its parent went too.
|
|
31
33
|
*/
|
|
32
34
|
readonly going: readonly string[];
|
|
33
35
|
}
|
package/dist/drive-erase.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
// from each other. This is a sibling of that family rather than an outside caller.
|
|
31
31
|
import { request, ServerError } from "./api.js";
|
|
32
32
|
import { DriveEditError, resolving } from "./drive-edit/errors.js";
|
|
33
|
-
import { filesUnder, uniqueById } from "./drive-edit/tree.js";
|
|
33
|
+
import { filesUnder, foldersUnder, uniqueById } from "./drive-edit/tree.js";
|
|
34
34
|
import { buildIndex, fullPathOf, KIND_FILE } from "./drive-paths.js";
|
|
35
35
|
import { NmtsError } from "./errors.js";
|
|
36
36
|
import { readFileList } from "./manifest.js";
|
|
@@ -54,7 +54,12 @@ export async function planErase(input, paths) {
|
|
|
54
54
|
const index = buildIndex(entries);
|
|
55
55
|
const targets = resolving(() => batchTargets(entries, paths, { includeTrashed: true, nothingHappened: "Nothing was erased." }));
|
|
56
56
|
const files = uniqueById(targets.flatMap((t) => (t.kind === KIND_FILE ? [t] : filesUnder(entries, t.id))));
|
|
57
|
-
|
|
57
|
+
// ⛔ AND THE FOLDERS UNDER A NAMED FOLDER, which `targets + files` left behind. A sub-folder
|
|
58
|
+
// holding no file was in neither set, so it stayed in the sealed list with its parent gone —
|
|
59
|
+
// a folder the drive still showed, sitting under nothing, that no command could reach
|
|
60
|
+
// (2026-09-20). What is erased on the server is unchanged: folders have no row there.
|
|
61
|
+
const folders = uniqueById(targets.flatMap((t) => (t.kind === KIND_FILE ? [] : foldersUnder(entries, t.id))));
|
|
62
|
+
const going = uniqueById([...targets, ...files, ...folders]);
|
|
58
63
|
if (files.length === 0) {
|
|
59
64
|
throw new DriveEditError("NOT_FOUND", `Nothing named holds a file; empty folders are removed with \`${BINARY_NAME} rm\`.`, {
|
|
60
65
|
exitCode: 4,
|