@needmoretruth/nmts-cli 0.43.0 → 0.45.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 +35 -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 +22 -0
- package/dist/args.js +9 -3
- 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/get.d.ts +2 -0
- package/dist/commands/get.js +13 -1
- package/dist/commands/login.js +2 -2
- package/dist/commands/ls.d.ts +2 -0
- package/dist/commands/ls.js +18 -5
- 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-thumbnail.d.ts +4 -0
- package/dist/commands/put-thumbnail.js +119 -0
- package/dist/commands/put-wallet.d.ts +33 -0
- package/dist/commands/put-wallet.js +86 -11
- package/dist/commands/put.d.ts +13 -0
- package/dist/commands/put.js +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/trash.js +5 -3
- package/dist/drive-edit/tree.d.ts +18 -0
- package/dist/drive-edit/tree.js +35 -4
- package/dist/drive-erase.d.ts +5 -3
- package/dist/drive-erase.js +8 -3
- package/dist/drive-paths.d.ts +2 -2
- package/dist/drive-paths.js +2 -2
- package/dist/help-options.d.ts +2 -0
- package/dist/help-options.js +146 -0
- package/dist/help.js +10 -123
- package/dist/main.js +17 -19
- package/dist/mcp-tools/files.js +21 -2
- package/dist/mcp-tools/reads.js +13 -4
- package/dist/portable.d.ts +3 -2
- package/dist/portable.js +3 -2
- 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/drive/manifest-codec.d.ts +11 -31
- package/dist/shared/lib/drive/manifest-codec.js +15 -23
- package/dist/shared/lib/drive/manifest-index.d.ts +10 -1
- package/dist/shared/lib/drive/manifest-index.js +30 -8
- package/dist/shared/lib/drive/manifest-wire-extras.d.ts +50 -0
- package/dist/shared/lib/drive/manifest-wire-extras.js +65 -0
- package/dist/shared/lib/drive/preview-classify.d.ts +17 -0
- package/dist/shared/lib/drive/preview-classify.js +96 -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/upload-wallet-put.d.ts +2 -0
- package/dist/upload-wallet-put.js +1 -0
- package/dist/walrus.d.ts +9 -1
- package/dist/walrus.js +17 -3
- package/docs/commands/ai-account.md +25 -0
- package/docs/commands/get.md +3 -0
- package/docs/commands/login.md +4 -3
- package/docs/commands/ls.md +5 -0
- package/docs/commands/put.md +8 -0
- 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
|
@@ -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,45 @@ 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, thumbOf: options.thumbOf }, 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;
|
|
119
|
+
options.onStored?.(done.itemId, savedAs);
|
|
91
120
|
if (options.json) {
|
|
92
|
-
say(JSON.stringify({ id: done.itemId, name:
|
|
121
|
+
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
122
|
return 0;
|
|
94
123
|
}
|
|
95
|
-
say(` saved as ${
|
|
96
|
-
if (
|
|
124
|
+
say(` saved as ${savedAs}`);
|
|
125
|
+
if (original !== null) {
|
|
126
|
+
say(` The file credits paid for is in the trash now — ${BINARY_NAME} restore brings it back for 30 days.`);
|
|
127
|
+
say(` Erasing it releases its storage and settles its deposit: ${BINARY_NAME} erase --release-storage.`);
|
|
128
|
+
}
|
|
129
|
+
else if (done.replaced)
|
|
97
130
|
say(` A file called ${name} was already there. It is in the trash now — ${BINARY_NAME} restore brings it back for 30 days.`);
|
|
98
131
|
else if (done.savedAs !== name)
|
|
99
132
|
say(` A file called ${name} was already there, so this one was numbered rather than replacing it.`);
|
|
@@ -101,6 +134,29 @@ export async function putWithWallet(target, options) {
|
|
|
101
134
|
say(` This finished an upload a previous run had already signed for. Nothing was signed now.`);
|
|
102
135
|
return 0;
|
|
103
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* The options `--from` leaves no room for, refused before anything is read.
|
|
139
|
+
*
|
|
140
|
+
* ⛔ REFUSED RATHER THAN IGNORED, for the reason `put-payer.ts` refuses the wallet-only options:
|
|
141
|
+
* somebody who typed `--name` meant it, and an upload that quietly used a different name would
|
|
142
|
+
* be discovered as a file in the wrong place, after the money moved.
|
|
143
|
+
*/
|
|
144
|
+
function refuseFromClashes(target, options) {
|
|
145
|
+
if (options.from === undefined)
|
|
146
|
+
return;
|
|
147
|
+
const nothing = `Nothing was signed and nothing was sent.`;
|
|
148
|
+
const clash = (what, why) => new NmtsError(`${what} does not apply with --from: ${why}`, { exitCode: 2, nextStep: nothing });
|
|
149
|
+
if (target !== undefined && target !== "") {
|
|
150
|
+
throw clash(`a local file`, `--from names the file, in the drive, and one run re-uploads one file.`);
|
|
151
|
+
}
|
|
152
|
+
if (options.name !== undefined)
|
|
153
|
+
throw clash(`--name`, `the re-upload keeps the name the file has.`);
|
|
154
|
+
if (options.to !== undefined)
|
|
155
|
+
throw clash(`--to`, `the re-upload keeps the folder the file is in.`);
|
|
156
|
+
if (options.onCollision !== undefined) {
|
|
157
|
+
throw clash(`--on-collision`, `a re-upload replaces the file it came from; that is what it is for.`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
104
160
|
/**
|
|
105
161
|
* Review, agree, upload and record ONE file for a person who is watching. Null when `--dry-run`
|
|
106
162
|
* stopped at the review.
|
|
@@ -124,7 +180,7 @@ export async function uploadOneWithWallet(ctx, file, options) {
|
|
|
124
180
|
partSize: ctx.partSize,
|
|
125
181
|
rule: ctx.rule,
|
|
126
182
|
onCollision: ctx.onCollision,
|
|
127
|
-
}, { source: fileSource(file.localPath, file.size), name: file.name, parentId: file.parentId, destination: file.destination }, {
|
|
183
|
+
}, { source: fileSource(file.localPath, file.size), name: file.name, parentId: file.parentId, destination: file.destination, thumbOf: file.thumbOf }, {
|
|
128
184
|
epochs: options.epochs,
|
|
129
185
|
storage: options.storage,
|
|
130
186
|
dryRun: options.dryRun,
|
|
@@ -148,6 +204,7 @@ export async function uploadOneWithWallet(ctx, file, options) {
|
|
|
148
204
|
tipMist: review.tipMist,
|
|
149
205
|
storage: review.storage,
|
|
150
206
|
heldResources: review.heldResources,
|
|
207
|
+
networkCopy: ctx.networkCopy,
|
|
151
208
|
}, review.budget);
|
|
152
209
|
},
|
|
153
210
|
agree: (review) => {
|
|
@@ -182,10 +239,28 @@ export async function uploadOneWithWallet(ctx, file, options) {
|
|
|
182
239
|
wallet: ctx.wallet,
|
|
183
240
|
paidWalFrost: outcome.resumed ? 0n : outcome.review.budget.walNeededFrost,
|
|
184
241
|
say: ctx.json ? (line) => void process.stderr.write(`${line}\n`) : say,
|
|
242
|
+
trustServerAddress: options.trustServerTipAddress === true,
|
|
185
243
|
...(options.tip ?? {}),
|
|
186
244
|
});
|
|
187
245
|
return { itemId: outcome.itemId, savedAs: outcome.savedAs, replaced: outcome.replaced, seq: outcome.fileListVersion, resumed: outcome.resumed, facts };
|
|
188
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Whether this account asks its uploads to carry the recovery list's copy — for the review's one
|
|
249
|
+
* sentence about it, and for nothing else.
|
|
250
|
+
*
|
|
251
|
+
* ⛔ A FAILED READ IS `null`, NOT A FAILED UPLOAD. What hangs on this is a sentence; a server that
|
|
252
|
+
* could not answer, or one older than the field, must not cost somebody the upload they asked
|
|
253
|
+
* for. `--json` skips the read entirely — there is no review to print.
|
|
254
|
+
*/
|
|
255
|
+
export async function readNetworkCopy(server, apiKey) {
|
|
256
|
+
try {
|
|
257
|
+
const { readAccountSummary } = await import("./balance.js");
|
|
258
|
+
return (await readAccountSummary(server, apiKey)).network_copy;
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
189
264
|
/** The review as `--json` prints it: base units as strings, with the coin amounts beside them. */
|
|
190
265
|
function factsOf(review) {
|
|
191
266
|
const { budget, storage } = review;
|
package/dist/commands/put.d.ts
CHANGED
|
@@ -35,10 +35,23 @@ 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;
|
|
47
|
+
/** Send the video's preview picture with it — a frame from ffmpeg (`put-thumbnail.ts`). */
|
|
48
|
+
thumbnail?: boolean;
|
|
49
|
+
/** The picture to send as the video's preview, instead of a frame from ffmpeg. */
|
|
50
|
+
thumbnailFile?: string | undefined;
|
|
51
|
+
/** Set by `put-thumbnail.ts` on the picture's own run: the video's item id, written as `thumbOf`. */
|
|
52
|
+
thumbOf?: string;
|
|
53
|
+
/** Told the stored item's id and the name it was saved as, before anything is printed. */
|
|
54
|
+
onStored?: (itemId: string, savedAs: string) => void;
|
|
42
55
|
}
|
|
43
56
|
/** Who pays, and the options that lose their meaning under that answer — the rule is in `put-payer.ts`; this is its one road. */
|
|
44
57
|
import { payerOf, refuseWalletOnlyOptions } from "./put-payer.ts";
|
package/dist/commands/put.js
CHANGED
|
@@ -69,6 +69,9 @@ export function folderIdFor(wanted, entries) {
|
|
|
69
69
|
return folder.id;
|
|
70
70
|
}
|
|
71
71
|
export async function put(target, options = {}) {
|
|
72
|
+
if (options.thumbnail === true || options.thumbnailFile !== undefined) {
|
|
73
|
+
return (await import("./put-thumbnail.js")).putWithThumbnail(target, options, put);
|
|
74
|
+
}
|
|
72
75
|
// ⛔ DECIDED BEFORE ANYTHING IS READ. The wallet path prices in WAL and signs; nothing below this
|
|
73
76
|
// line knows how to do either, and it must not learn.
|
|
74
77
|
if (payerOf(options.pay) === "wallet") {
|
|
@@ -258,8 +261,10 @@ export async function put(target, options = {}) {
|
|
|
258
261
|
updatedAt: now,
|
|
259
262
|
dekWrapped: result.entry.dekWrapped,
|
|
260
263
|
contentHashCt: result.entry.contentHashCt,
|
|
264
|
+
...(options.thumbOf !== undefined ? { thumbOf: options.thumbOf } : {}),
|
|
261
265
|
},
|
|
262
266
|
});
|
|
267
|
+
options.onStored?.(result.itemId, added.name);
|
|
263
268
|
// ⛔ ONLY NOW, AND EVERY PART. Until the entry is in the list the file is paid for and invisible,
|
|
264
269
|
// and the records are the only thing that lets a second run finish the job without spending
|
|
265
270
|
// again. Clearing the file-level one first would leave a run able to commit a second time.
|
|
@@ -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;
|
package/dist/drive-edit/trash.js
CHANGED
|
@@ -6,7 +6,7 @@ import { readFileList } from "../manifest.js";
|
|
|
6
6
|
import { applyManyToList, batchTargets } from "../manifest-write.js";
|
|
7
7
|
import { applyIntent } from "../shared/lib/drive/manifest-ops.js";
|
|
8
8
|
import { DriveEditError, resolving } from "./errors.js";
|
|
9
|
-
import { filesUnder, hasNamedAncestor, uniqueById } from "./tree.js";
|
|
9
|
+
import { filesUnder, hasNamedAncestor, uniqueById, withPreviews } from "./tree.js";
|
|
10
10
|
/**
|
|
11
11
|
* Move things to the trash, or bring them back.
|
|
12
12
|
*
|
|
@@ -88,9 +88,11 @@ export async function trashPaths(input, verb, paths, options = {}) {
|
|
|
88
88
|
// storage, and leave the list saying "trashed" while the server says "live" — after which
|
|
89
89
|
// `rm` refuses to put it back and there is no way out.
|
|
90
90
|
const at = Date.now();
|
|
91
|
-
|
|
91
|
+
// A video's hidden preview picture goes into and out of the trash with it (gallery spec §4).
|
|
92
|
+
const under = withPreviews(entries, targets.flatMap((t) => filesUnder(entries, t.entry.id)));
|
|
93
|
+
const chosen = targets.map((t) => t.entry.id);
|
|
94
|
+
const ids = [...chosen, ...under.filter((f) => f.thumbOf !== undefined && !chosen.includes(f.id)).map((f) => f.id)];
|
|
92
95
|
const preview = buildIndex(applyIntent(entries, intentFor(verb, ids, at)));
|
|
93
|
-
const under = uniqueById(targets.flatMap((t) => filesUnder(entries, t.entry.id)));
|
|
94
96
|
// ⚠ Judged on the PREVIEW's own row, not on the one in hand: `applyIntent` returns new objects,
|
|
95
97
|
// so asking the preview about the old object reads the old `deletedAt` and answers "still
|
|
96
98
|
// trashed" for the very thing being restored.
|
|
@@ -3,6 +3,12 @@ import type { ManifestEntry } from "../shared/lib/drive/manifest-codec.ts";
|
|
|
3
3
|
export declare function isUnder(entries: readonly ManifestEntry[], id: string | null, rootId: string): boolean;
|
|
4
4
|
/** Is any ancestor of this entry in the set? Used to drop a target a named folder already covers. */
|
|
5
5
|
export declare function hasNamedAncestor(entries: readonly ManifestEntry[], entry: ManifestEntry, named: ReadonlySet<string>): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* `files` and the preview pictures of the videos among them. A video's
|
|
8
|
+
* picture is a file of its own, hidden from every listing while the video is there, so it goes
|
|
9
|
+
* wherever the video goes — left behind, it would be charged for and then show up on its own.
|
|
10
|
+
*/
|
|
11
|
+
export declare function withPreviews(entries: readonly ManifestEntry[], files: readonly ManifestEntry[]): ManifestEntry[];
|
|
6
12
|
/** One entry per id, keeping the first. Two named folders can hold the same file only once. */
|
|
7
13
|
export declare function uniqueById(files: readonly ManifestEntry[]): ManifestEntry[];
|
|
8
14
|
/**
|
|
@@ -13,3 +19,15 @@ export declare function uniqueById(files: readonly ManifestEntry[]): ManifestEnt
|
|
|
13
19
|
* `rm` takes this set whole. `restore` cannot: see the note at the call site.
|
|
14
20
|
*/
|
|
15
21
|
export declare function filesUnder(entries: readonly ManifestEntry[], rootId: string): ManifestEntry[];
|
|
22
|
+
/**
|
|
23
|
+
* Every FOLDER under one entry, the root itself excluded. Empty when the root is a file.
|
|
24
|
+
*
|
|
25
|
+
* ⛔ IT EXISTS BECAUSE A FOLDER WITH NO FILE IN IT HAS NOTHING TO CARRY IT OUT. What leaves the
|
|
26
|
+
* sealed list is decided from the files under a named folder; a sub-folder holding none was in
|
|
27
|
+
* nobody's set, so it stayed — an entry whose parent had gone, which the list still showed and
|
|
28
|
+
* nothing could open or reach (2026-09-20).
|
|
29
|
+
*
|
|
30
|
+
* ⚠ Trashed descendants are included, for the reason `filesUnder` includes them: somebody who
|
|
31
|
+
* trashed a sub-folder last week and then erases its parent expects both to be gone.
|
|
32
|
+
*/
|
|
33
|
+
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;
|
|
@@ -27,6 +27,16 @@ export function hasNamedAncestor(entries, entry, named) {
|
|
|
27
27
|
}
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* `files` and the preview pictures of the videos among them. A video's
|
|
32
|
+
* picture is a file of its own, hidden from every listing while the video is there, so it goes
|
|
33
|
+
* wherever the video goes — left behind, it would be charged for and then show up on its own.
|
|
34
|
+
*/
|
|
35
|
+
export function withPreviews(entries, files) {
|
|
36
|
+
const index = buildIndex(entries);
|
|
37
|
+
const pictures = files.flatMap((f) => (index.previews.get(f.id) ?? []).flatMap((id) => index.byId.get(id) ?? []));
|
|
38
|
+
return uniqueById([...files, ...pictures]);
|
|
39
|
+
}
|
|
30
40
|
/** One entry per id, keeping the first. Two named folders can hold the same file only once. */
|
|
31
41
|
export function uniqueById(files) {
|
|
32
42
|
const byId = new Map();
|
|
@@ -43,11 +53,32 @@ export function uniqueById(files) {
|
|
|
43
53
|
* `rm` takes this set whole. `restore` cannot: see the note at the call site.
|
|
44
54
|
*/
|
|
45
55
|
export function filesUnder(entries, rootId) {
|
|
56
|
+
return under(entries, rootId, KIND_FILE);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Every FOLDER under one entry, the root itself excluded. Empty when the root is a file.
|
|
60
|
+
*
|
|
61
|
+
* ⛔ IT EXISTS BECAUSE A FOLDER WITH NO FILE IN IT HAS NOTHING TO CARRY IT OUT. What leaves the
|
|
62
|
+
* sealed list is decided from the files under a named folder; a sub-folder holding none was in
|
|
63
|
+
* nobody's set, so it stayed — an entry whose parent had gone, which the list still showed and
|
|
64
|
+
* nothing could open or reach (2026-09-20).
|
|
65
|
+
*
|
|
66
|
+
* ⚠ Trashed descendants are included, for the reason `filesUnder` includes them: somebody who
|
|
67
|
+
* trashed a sub-folder last week and then erases its parent expects both to be gone.
|
|
68
|
+
*/
|
|
69
|
+
export function foldersUnder(entries, rootId) {
|
|
70
|
+
const root = entries.find((e) => e.id === rootId);
|
|
71
|
+
if (root === undefined || root.kind === KIND_FILE)
|
|
72
|
+
return [];
|
|
73
|
+
return under(entries, rootId, KIND_FOLDER);
|
|
74
|
+
}
|
|
75
|
+
/** The walk both of the two above make: everything of one kind at or under `rootId`. */
|
|
76
|
+
function under(entries, rootId, kind) {
|
|
46
77
|
const root = entries.find((e) => e.id === rootId);
|
|
47
78
|
if (root === undefined)
|
|
48
79
|
return [];
|
|
49
80
|
if (root.kind === KIND_FILE)
|
|
50
|
-
return [root];
|
|
81
|
+
return kind === KIND_FILE ? [root] : [];
|
|
51
82
|
const childrenOf = new Map();
|
|
52
83
|
for (const e of entries) {
|
|
53
84
|
const list = childrenOf.get(e.parentId);
|
|
@@ -67,9 +98,9 @@ export function filesUnder(entries, rootId) {
|
|
|
67
98
|
if (seen.has(child.id))
|
|
68
99
|
continue;
|
|
69
100
|
seen.add(child.id);
|
|
70
|
-
if (child.kind ===
|
|
101
|
+
if (child.kind === kind)
|
|
71
102
|
out.push(child);
|
|
72
|
-
|
|
103
|
+
if (child.kind !== KIND_FILE)
|
|
73
104
|
queue.push(child.id);
|
|
74
105
|
}
|
|
75
106
|
}
|
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, withPreviews } 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";
|
|
@@ -53,8 +53,13 @@ export async function planErase(input, paths) {
|
|
|
53
53
|
const entries = list.manifest?.entries ?? [];
|
|
54
54
|
const index = buildIndex(entries);
|
|
55
55
|
const targets = resolving(() => batchTargets(entries, paths, { includeTrashed: true, nothingHappened: "Nothing was erased." }));
|
|
56
|
-
const files =
|
|
57
|
-
|
|
56
|
+
const files = withPreviews(entries, targets.flatMap((t) => (t.kind === KIND_FILE ? [t] : filesUnder(entries, t.id))));
|
|
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,
|
package/dist/drive-paths.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ManifestEntry } from "./shared/lib/drive/manifest-codec.ts";
|
|
2
|
-
import { buildIndex, isLive, type ManifestIndex, trashedAt } from "./shared/lib/drive/manifest-index.ts";
|
|
2
|
+
import { buildIndex, isLive, type ManifestIndex, shown, trashedAt } from "./shared/lib/drive/manifest-index.ts";
|
|
3
3
|
/** Folder. The same numeric codes the items API uses. */
|
|
4
4
|
export declare const KIND_FOLDER = 0;
|
|
5
5
|
/** File. */
|
|
6
6
|
export declare const KIND_FILE = 1;
|
|
7
|
-
export { buildIndex, isLive, trashedAt };
|
|
7
|
+
export { buildIndex, isLive, shown, trashedAt };
|
|
8
8
|
export type { ManifestIndex };
|
|
9
9
|
/**
|
|
10
10
|
* The full path of one entry, marked when the walk could not reach the root.
|
package/dist/drive-paths.js
CHANGED
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
// the third walk silently resolved the orphan to the same string. **The path that is printed
|
|
24
24
|
// must be the path that matches**, so there is one function and everybody calls it.
|
|
25
25
|
import { NmtsError } from "./errors.js";
|
|
26
|
-
import { buildIndex, isLive, KIND_FILE as SHARED_KIND_FILE, KIND_FOLDER as SHARED_KIND_FOLDER, trashedAt, } from "./shared/lib/drive/manifest-index.js";
|
|
26
|
+
import { buildIndex, isLive, KIND_FILE as SHARED_KIND_FILE, KIND_FOLDER as SHARED_KIND_FOLDER, shown, trashedAt, } from "./shared/lib/drive/manifest-index.js";
|
|
27
27
|
/** Folder. The same numeric codes the items API uses. */
|
|
28
28
|
export const KIND_FOLDER = SHARED_KIND_FOLDER;
|
|
29
29
|
/** File. */
|
|
30
30
|
export const KIND_FILE = SHARED_KIND_FILE;
|
|
31
|
-
export { buildIndex, isLive, trashedAt };
|
|
31
|
+
export { buildIndex, isLive, shown, trashedAt };
|
|
32
32
|
/**
|
|
33
33
|
* What a broken parent chain is drawn as.
|
|
34
34
|
*
|