@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
package/AGENTS.md
CHANGED
|
@@ -57,7 +57,7 @@ Four things need a person, all at the beginning. If you are being set up, hand t
|
|
|
57
57
|
|---|---|---|---|
|
|
58
58
|
| 1. Make the account | a person | nmts.me, or `nmts create` at a terminal (it makes the NMTS key on that machine and hands the person a one-time link to finish in a browser) | once |
|
|
59
59
|
| 2. Make an API key for you | a person | the account screen at nmts.me, or `nmts key new` on a machine that holds the NMTS key (`key list` and `key revoke` live there too) | once, and again if it is revoked |
|
|
60
|
-
| 3. Pass the check that says a person is here | a person | nmts.me, one short code | **every
|
|
60
|
+
| 3. Pass the check that says a person is here | a person | nmts.me, one short code | **every twelve weeks**, and only for step 1, step 4 and sharing |
|
|
61
61
|
| 4. Get credits into the account | you, for the free trial (`nmts trial apply`, while step 3 is live) — a person, for a funded wallet | a terminal, or nmts.me | once, then as they run out |
|
|
62
62
|
|
|
63
63
|
**Step 3 does not gate the work.** Reading, writing, listing, folders, the trash, the recovery files and the
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
Each version's entry is what changed for the person or the program using `nmts`. The product's own
|
|
4
4
|
update history, which covers the site and the server too, is at https://nmts.me/updates.
|
|
5
5
|
|
|
6
|
+
## 0.45.0 — 2026-09-24
|
|
7
|
+
|
|
8
|
+
- **Video preview pictures.** `nmts put <video> --thumbnail` takes one frame with ffmpeg, when it is
|
|
9
|
+
on your PATH, and uploads it beside the video as an ordinary small file linked to it; without
|
|
10
|
+
ffmpeg the video goes alone and `nmts` says why. `--thumbnail-file <picture>` hands in a picture
|
|
11
|
+
you made yourself. The picture is priced, encrypted and paid for like any other file.
|
|
12
|
+
- `nmts get <video> --thumbnail` fetches the picture instead of the video.
|
|
13
|
+
- `nmts ls --media` lists one kind of file. A preview picture is listed on its own only when its
|
|
14
|
+
video is gone.
|
|
15
|
+
- Moving a video to the trash, restoring it and erasing it take its picture with it.
|
|
16
|
+
- The MCP tools take the same options.
|
|
17
|
+
|
|
18
|
+
## 0.44.0 — 2026-09-23
|
|
19
|
+
|
|
20
|
+
- **Recovery phrase.** An NMTS key can be written as 15 words from the BIP-39 English or Korean word
|
|
21
|
+
list. `nmts whoami --reveal --phrase` prints them (`--lang ko` for Korean), and every place that
|
|
22
|
+
takes an NMTS key takes the phrase too. The phrase is the key in another form: it opens the
|
|
23
|
+
account exactly as the key does. For programs, `phraseOf` in `@needmoretruth/nmts-cli/portable`.
|
|
24
|
+
- **AI accounts from the terminal.** `nmts ai-account list`, `nmts ai-account create` and
|
|
25
|
+
`nmts ai-account delete` run on the NMTS key's proof; an API key cannot call them. Deleting asks
|
|
26
|
+
you to type the confirmation back, and `--yes` answers it for an agent.
|
|
27
|
+
- `nmts put --pay wallet --from <path>` takes a file that credits paid for, downloads and decrypts
|
|
28
|
+
it into this tool's own directory, encrypts and uploads it again paid from your wallet, and moves
|
|
29
|
+
the old file to the trash. Storage the treasury bought cannot be handed to a wallet, so this is a
|
|
30
|
+
new upload, not a transfer.
|
|
31
|
+
- The standing gift address is fixed per network in the tool. A self-hosted server that names a
|
|
32
|
+
different one is followed only with `--trust-server-tip-address`; without it, `nmts` stops before
|
|
33
|
+
signing.
|
|
34
|
+
- The upload review tells an account that asked for the recovery list's storage-network copy that
|
|
35
|
+
this upload does not carry it, and how to write the list out as a file instead.
|
|
36
|
+
- Erasing a folder completely also removes the empty folders under it, which used to stay behind
|
|
37
|
+
in the list with nothing able to open them.
|
|
38
|
+
- Reads try a second aggregator on each network when the first cannot be reached.
|
|
39
|
+
- `examples/podman.sh` runs the tool in rootless Podman with the key handed in as a secret.
|
|
40
|
+
|
|
6
41
|
## 0.43.0 — 2026-09-20
|
|
7
42
|
|
|
8
43
|
- Nothing changes for the `nmts` command: it signs with the wallet this NMTS key derives, as it
|
package/README.ko.md
CHANGED
|
@@ -50,7 +50,7 @@ nmts --help
|
|
|
50
50
|
|
|
51
51
|
```sh
|
|
52
52
|
npm install -g github:needmoretruth/nmts-cli # 기본 브랜치
|
|
53
|
-
npm install -g github:needmoretruth/nmts-cli#v0.
|
|
53
|
+
npm install -g github:needmoretruth/nmts-cli#v0.45.0 # 버전을 고정할 때
|
|
54
54
|
npm install -g https://github.com/needmoretruth/nmts-cli/releases/latest/download/nmts.tgz
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -103,7 +103,9 @@ nmts get x # 파일 하나 다운로드
|
|
|
103
103
|
것을 지웁니다.
|
|
104
104
|
|
|
105
105
|
`nmts whoami --reveal`은 NMTS 키 자체를 찍습니다. `nmts unlock reveal`로 한 번 열기 전에는 잠겨
|
|
106
|
-
있고 실행마다 다시 묻습니다. 터미널을 기록하는 무엇이든 그때부터 NMTS 키를 갖게 됩니다.
|
|
106
|
+
있고 실행마다 다시 묻습니다. 터미널을 기록하는 무엇이든 그때부터 NMTS 키를 갖게 됩니다. `--phrase`를
|
|
107
|
+
붙이면 같은 키를 단어 15개의 복구 구문으로 찍습니다(`--lang ko`면 한국어 단어). `nmts login`은 둘 중 어느
|
|
108
|
+
쪽도 받습니다.
|
|
107
109
|
|
|
108
110
|
**어느 자격도 명령행 인자로는 받지 않습니다.** 어떤 프로세스든 다른 프로세스의 명령행 인자를 읽을 수
|
|
109
111
|
있고, 셸은 그것을 기록에 남깁니다. 둘 다 그런 옵션이 없습니다.
|
|
@@ -435,6 +437,10 @@ docker run --rm \
|
|
|
435
437
|
|
|
436
438
|
이름은 댔는데 없는 자격 파일은 어떤 요청보다 먼저 멈춥니다(종료 코드 3).
|
|
437
439
|
|
|
440
|
+
rootless Podman에서는 `examples/podman.sh`가 같은 일을 Podman 시크릿으로 합니다. 키는 컨테이너 안에
|
|
441
|
+
`/run/secrets/nmts-key` 파일로 들어가고, `podman inspect`에는 그 경로만 보입니다. `NMTS_ACCOUNT_CODE`와
|
|
442
|
+
`NMTS_ACCOUNT_CODE_FILE`이 둘 다 있으면 `NMTS_ACCOUNT_CODE`가 이기므로, 컨테이너 안에서는 그것을 비워 두십시오.
|
|
443
|
+
|
|
438
444
|
잠금 상태와 모드는 설정 디렉터리에 있고, 지워진 컨테이너는 그것을 함께 가져갑니다. 새 컨테이너는 목록과
|
|
439
445
|
다운로드는 그냥 되고, 업로드는 물으므로 스크립트는 `--yes`를 넘기며, 잠긴 것(지갑·공유)은 사람이 한 번 연
|
|
440
446
|
설정 디렉터리를 컨테이너 밖에 두어야 합니다(`-v nmts-config:/config`). 직접 만든 이미지에서는
|
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ default branch, from a pinned version, or from the tarball attached to the
|
|
|
51
51
|
|
|
52
52
|
```sh
|
|
53
53
|
npm install -g github:needmoretruth/nmts-cli # the default branch
|
|
54
|
-
npm install -g github:needmoretruth/nmts-cli#v0.
|
|
54
|
+
npm install -g github:needmoretruth/nmts-cli#v0.45.0 # a pinned version
|
|
55
55
|
npm install -g https://github.com/needmoretruth/nmts-cli/releases/latest/download/nmts.tgz
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -106,7 +106,8 @@ handle and never the key itself, and does not replace a stored API key unless th
|
|
|
106
106
|
|
|
107
107
|
`nmts whoami --reveal` prints your NMTS key itself. It is locked until you run `nmts unlock
|
|
108
108
|
reveal` once, and asked about on every run; anything that logs your terminal has your NMTS key from
|
|
109
|
-
then on.
|
|
109
|
+
then on. Add `--phrase` for the same key as its 15-word recovery phrase (`--lang ko` for Korean
|
|
110
|
+
words); `nmts login` accepts either form.
|
|
110
111
|
|
|
111
112
|
**Neither credential is ever accepted as a command-line argument.** Any process can read another
|
|
112
113
|
process's command line, and shells record it in history. There is no flag for either.
|
|
@@ -459,6 +460,11 @@ docker run --rm \
|
|
|
459
460
|
|
|
460
461
|
A credential file that is named but missing is a hard stop (exit 3) before any request.
|
|
461
462
|
|
|
463
|
+
With rootless Podman, `examples/podman.sh` does the same through a Podman secret: the key reaches
|
|
464
|
+
the container as the file `/run/secrets/nmts-key`, and `podman inspect` shows only that path.
|
|
465
|
+
`NMTS_ACCOUNT_CODE` wins over `NMTS_ACCOUNT_CODE_FILE` when both are set, so leave it unset in a
|
|
466
|
+
container.
|
|
467
|
+
|
|
462
468
|
Unlocks and the mode live in the config directory, and a container that is removed takes them
|
|
463
469
|
with it. A fresh container lists and downloads freely; an upload asks, so a script passes `--yes`,
|
|
464
470
|
and anything locked (the wallet, sharing) needs the config directory kept outside the container
|
package/dist/account.d.ts
CHANGED
|
@@ -7,12 +7,16 @@ export interface AccountIdentity {
|
|
|
7
7
|
displayCode: string;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Check that a string is a real NMTS key
|
|
10
|
+
* Check that a string is a real NMTS key — or its 15-word recovery phrase — and return the key in
|
|
11
|
+
* its display form, so what gets stored is the key whichever spelling was typed.
|
|
11
12
|
*
|
|
12
13
|
* ⛔ This is the engine's own parser, which verifies the trailing check symbol. A typo therefore
|
|
13
14
|
* fails HERE, offline, instead of becoming a sign-in failure the person cannot tell apart from
|
|
14
|
-
* a wrong password, a network problem or a suspended account.
|
|
15
|
+
* a wrong password, a network problem or a suspended account. The engine's own message is not
|
|
16
|
+
* repeated: it can contain the input.
|
|
15
17
|
*/
|
|
16
|
-
export declare function assertUsableCode(code: string): Promise<
|
|
18
|
+
export declare function assertUsableCode(code: string): Promise<string>;
|
|
17
19
|
/** Derive the public facts about an account from its code. */
|
|
18
20
|
export declare function identityOf(code: string): Promise<AccountIdentity>;
|
|
21
|
+
/** The NMTS key as its 15-word recovery phrase, in `en` (default) or `ko`. */
|
|
22
|
+
export declare function phraseOf(code: string, lang: string | undefined): Promise<string>;
|
package/dist/account.js
CHANGED
|
@@ -22,38 +22,28 @@ import { toBase64Url } from "./bytes.js";
|
|
|
22
22
|
import { DERIVED, loadCrypto } from "./crypto.js";
|
|
23
23
|
import { NmtsError } from "./errors.js";
|
|
24
24
|
/**
|
|
25
|
-
* Check that a string is a real NMTS key
|
|
25
|
+
* Check that a string is a real NMTS key — or its 15-word recovery phrase — and return the key in
|
|
26
|
+
* its display form, so what gets stored is the key whichever spelling was typed.
|
|
26
27
|
*
|
|
27
28
|
* ⛔ This is the engine's own parser, which verifies the trailing check symbol. A typo therefore
|
|
28
29
|
* fails HERE, offline, instead of becoming a sign-in failure the person cannot tell apart from
|
|
29
|
-
* a wrong password, a network problem or a suspended account.
|
|
30
|
+
* a wrong password, a network problem or a suspended account. The engine's own message is not
|
|
31
|
+
* repeated: it can contain the input.
|
|
30
32
|
*/
|
|
31
33
|
export async function assertUsableCode(code) {
|
|
32
34
|
const glue = await loadCrypto();
|
|
35
|
+
const bytes = parseKeyOrPhrase(glue, code);
|
|
33
36
|
try {
|
|
34
|
-
glue.
|
|
37
|
+
return glue.account_code_display(bytes);
|
|
35
38
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw new NmtsError("That is not a valid NMTS key.", {
|
|
39
|
-
exitCode: 2,
|
|
40
|
-
nextStep: "Check for a mistyped or missing character. The last character is a check symbol.",
|
|
41
|
-
});
|
|
39
|
+
finally {
|
|
40
|
+
bytes.fill(0);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
/** Derive the public facts about an account from its code. */
|
|
45
44
|
export async function identityOf(code) {
|
|
46
45
|
const glue = await loadCrypto();
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
bytes = glue.account_code_parse(code);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
throw new NmtsError("That is not a valid NMTS key.", {
|
|
53
|
-
exitCode: 2,
|
|
54
|
-
nextStep: "Check for a mistyped or missing character. The last character is a check symbol.",
|
|
55
|
-
});
|
|
56
|
-
}
|
|
46
|
+
const bytes = parseKeyOrPhrase(glue, code);
|
|
57
47
|
// ⛔ WIPED, like every other derivation in this tool. This buffer is not an account id — it is
|
|
58
48
|
// EVERY KEY IN THE ACCOUNT: the sign-in secret, the key that opens the files, the key that
|
|
59
49
|
// opens the file list, and the wallet root. This one call site was leaving all of it live for
|
|
@@ -74,3 +64,40 @@ export async function identityOf(code) {
|
|
|
74
64
|
bytes.fill(0);
|
|
75
65
|
}
|
|
76
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The 20 bytes of an NMTS key or its 15-word recovery phrase. A phrase's refusal says which way it
|
|
69
|
+
* is wrong — a 12- or 24-word input is most likely a wallet's seed pasted into the wrong place.
|
|
70
|
+
*/
|
|
71
|
+
function parseKeyOrPhrase(glue, input) {
|
|
72
|
+
try {
|
|
73
|
+
return glue.account_code_parse(input);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
77
|
+
const nextStep = message.startsWith("phrase:count")
|
|
78
|
+
? "An NMTS recovery phrase has 15 words. A 12- or 24-word phrase belongs to a wallet, not to NMTS."
|
|
79
|
+
: message.startsWith("phrase:word")
|
|
80
|
+
? `Word ${message.split(":")[2] ?? "?"} is not in the recovery phrase word list. Check its spelling.`
|
|
81
|
+
: message.startsWith("phrase:checksum")
|
|
82
|
+
? "Every word is in the list, but one is wrong or two are in the wrong order."
|
|
83
|
+
: "Check for a mistyped or missing character. The last character is a check symbol.";
|
|
84
|
+
throw new NmtsError("That is not a valid NMTS key or recovery phrase.", { exitCode: 2, nextStep });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** The NMTS key as its 15-word recovery phrase, in `en` (default) or `ko`. */
|
|
88
|
+
export async function phraseOf(code, lang) {
|
|
89
|
+
if (lang !== undefined && lang !== "en" && lang !== "ko") {
|
|
90
|
+
throw new NmtsError(`There is no recovery phrase word list "${lang}".`, {
|
|
91
|
+
exitCode: 2,
|
|
92
|
+
nextStep: "--lang takes en or ko.",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const glue = await loadCrypto();
|
|
96
|
+
const bytes = parseKeyOrPhrase(glue, code);
|
|
97
|
+
try {
|
|
98
|
+
return glue.account_code_phrase(bytes, lang ?? "en");
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
bytes.fill(0);
|
|
102
|
+
}
|
|
103
|
+
}
|
package/dist/arg-options.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export interface ParsedArgs {
|
|
|
20
20
|
to?: string;
|
|
21
21
|
/** Say what an upload would cost and stop. */
|
|
22
22
|
dryRun: boolean;
|
|
23
|
+
/** `put`: send a video's preview picture with it (a frame from ffmpeg) · `get`: fetch only that picture. */
|
|
24
|
+
thumbnail: boolean;
|
|
25
|
+
/** `put`: the picture to send as the video's preview, instead of a frame from ffmpeg. */
|
|
26
|
+
thumbnailFile?: string;
|
|
27
|
+
/** `ls`: only files of this kind — image, video or audio. */
|
|
28
|
+
media?: string;
|
|
23
29
|
/** `put`: how much of a file goes into one part. A byte count, optionally with a unit. */
|
|
24
30
|
partSize?: string;
|
|
25
31
|
/** `put`/`push`: what THIS run does about a name already in use. Absent = this machine's setting. */
|
|
@@ -52,6 +58,12 @@ export interface ParsedArgs {
|
|
|
52
58
|
pay?: string;
|
|
53
59
|
/** `put --pay wallet`: `fit`, `whole`, or a held storage resource's object id. */
|
|
54
60
|
storage?: string;
|
|
61
|
+
/**
|
|
62
|
+
* `put --pay wallet --from <drive path>`: re-upload a file the account's credits paid for, this
|
|
63
|
+
* time on the wallet's money. The new file takes the old one's name and folder, and the old one
|
|
64
|
+
* goes to the trash.
|
|
65
|
+
*/
|
|
66
|
+
from?: string;
|
|
55
67
|
/** `consent grant wallet`: how long the grant lasts (days, at most 30), or until a date.
|
|
56
68
|
* `key new`: how many days the new API key lasts. The server clamps at its own ceiling. */
|
|
57
69
|
days?: string;
|
|
@@ -165,6 +177,8 @@ export interface ParsedArgs {
|
|
|
165
177
|
* nothing and says what it does.
|
|
166
178
|
*/
|
|
167
179
|
reveal: boolean;
|
|
180
|
+
/** `whoami --reveal --phrase`: the key as its 15-word recovery phrase. */
|
|
181
|
+
phrase: boolean;
|
|
168
182
|
/**
|
|
169
183
|
* `key new`: put the new key on the screen once, as well as storing it. A flag and not a value
|
|
170
184
|
* for the reason above: it names no secret, it asks for the one this run was just handed.
|
|
@@ -187,4 +201,12 @@ export interface ParsedArgs {
|
|
|
187
201
|
* copy kept here and a copy kept from the browser are the same file.
|
|
188
202
|
*/
|
|
189
203
|
save: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* `put`/`push`/`extend --pay wallet`: send the standing gift to the address THIS SERVER names,
|
|
206
|
+
* even when it is not the one built into this tool (`standing-tip.ts` `TIP_ADDRESS`).
|
|
207
|
+
*
|
|
208
|
+
* ⛔ FOR A SERVER YOU RUN YOURSELF AND NOTHING ELSE. Off by default: a server that can choose
|
|
209
|
+
* where a standing gift goes collects every one this machine sends.
|
|
210
|
+
*/
|
|
211
|
+
trustServerTipAddress: boolean;
|
|
190
212
|
}
|
package/dist/args.js
CHANGED
|
@@ -19,6 +19,8 @@ const VALUE_OPTIONS = {
|
|
|
19
19
|
"--on-collision": "onCollision",
|
|
20
20
|
"--deposit": "deposit",
|
|
21
21
|
"--find": "find",
|
|
22
|
+
"--thumbnail-file": "thumbnailFile",
|
|
23
|
+
"--media": "media",
|
|
22
24
|
"--sort": "sort",
|
|
23
25
|
"--epochs": "epochs",
|
|
24
26
|
"--pay": "pay",
|
|
@@ -52,6 +54,7 @@ const VALUE_OPTIONS = {
|
|
|
52
54
|
// credential and lists this one as the exception it is: what it names is a FILE, the shape
|
|
53
55
|
// this tool already recommends for every other secret (`NMTS_ACCOUNT_CODE_FILE`).
|
|
54
56
|
"--sui-key-file": "suiKeyFile",
|
|
57
|
+
"--from": "from",
|
|
55
58
|
"--account": "account",
|
|
56
59
|
"--app": "app",
|
|
57
60
|
};
|
|
@@ -91,6 +94,7 @@ const FLAG_OPTIONS = {
|
|
|
91
94
|
"--all": "all",
|
|
92
95
|
"--force": "force",
|
|
93
96
|
"--dry-run": "dryRun",
|
|
97
|
+
"--thumbnail": "thumbnail",
|
|
94
98
|
"--yes": "yes",
|
|
95
99
|
"-y": "yes",
|
|
96
100
|
"--publish": "publish",
|
|
@@ -101,6 +105,7 @@ const FLAG_OPTIONS = {
|
|
|
101
105
|
"--desc": "desc",
|
|
102
106
|
"--hidden": "hidden",
|
|
103
107
|
"--reveal": "reveal",
|
|
108
|
+
"--phrase": "phrase",
|
|
104
109
|
"--release-storage": "releaseStorage",
|
|
105
110
|
"--print": "print",
|
|
106
111
|
"--qr": "qr",
|
|
@@ -108,6 +113,7 @@ const FLAG_OPTIONS = {
|
|
|
108
113
|
"--save": "save",
|
|
109
114
|
"--remove": "remove",
|
|
110
115
|
"--accept-extremes": "acceptExtremes",
|
|
116
|
+
"--trust-server-tip-address": "trustServerTipAddress",
|
|
111
117
|
};
|
|
112
118
|
// ⛔ Derived from the tables, not written again. A hand-kept list is how an option ends up tested
|
|
113
119
|
// for one property and accepted with another. ⚠ Every option that carries a value is in here,
|
|
@@ -143,10 +149,10 @@ function append(parsed, field, value) {
|
|
|
143
149
|
* time, because a shape the compiler cannot see would let a new flag arrive as `undefined`.
|
|
144
150
|
*/
|
|
145
151
|
const FLAG_DEFAULTS = {
|
|
146
|
-
help: false, version: false, json: false, all: false, force: false, dryRun: false, releaseStorage: false,
|
|
152
|
+
help: false, version: false, json: false, all: false, force: false, dryRun: false, thumbnail: false, releaseStorage: false,
|
|
147
153
|
yes: false, publish: false, plain: false, env: false, status: false,
|
|
148
|
-
desc: false, hidden: false, reveal: false, print: false, qr: false, board: false,
|
|
149
|
-
save: false, acceptExtremes: false, remove: false, noWait: false,
|
|
154
|
+
desc: false, hidden: false, reveal: false, phrase: false, print: false, qr: false, board: false,
|
|
155
|
+
save: false, acceptExtremes: false, remove: false, noWait: false, trustServerTipAddress: false,
|
|
150
156
|
};
|
|
151
157
|
export function parseArgs(argv) {
|
|
152
158
|
const parsed = { command: null, operands: [], ...FLAG_DEFAULTS };
|
package/dist/artifact-about.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const CRYPTO_SPEC_URL = "https://github.com/needmoretruth/nmts-re
|
|
|
11
11
|
* is the field's own contract — what the writer says about itself — and a person holding two
|
|
12
12
|
* copies of one account's artefacts can then tell which program made each.
|
|
13
13
|
*/
|
|
14
|
-
export declare const WRITTEN_BY = "nmts-cli 0.
|
|
14
|
+
export declare const WRITTEN_BY = "nmts-cli 0.45.0";
|
|
15
15
|
/** Which of the three artefacts a wrapper is. A reader holding several can sort them. */
|
|
16
16
|
export type ArtifactKind = "recovery-list" | "file-list" | "recovery-kit";
|
|
17
17
|
/**
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ParsedArgs } from "../args.ts";
|
|
2
|
+
export interface AiAccountOptions {
|
|
3
|
+
server?: string | undefined;
|
|
4
|
+
json?: boolean;
|
|
5
|
+
/** The tier gate's answer for the permanent act, or `--yes` under skip-permissions. */
|
|
6
|
+
yes?: boolean;
|
|
7
|
+
write?: (line: string) => void;
|
|
8
|
+
/** Injected in tests: answers the one typed line. Its presence stands in for a terminal. */
|
|
9
|
+
readLine?: (question: string) => Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `nmts ai-account <verb>`.
|
|
13
|
+
*
|
|
14
|
+
* ⛔ THE BARE WORD LISTS, AND THAT IS THE SAFE HALF ON PURPOSE. A command whose bare form created
|
|
15
|
+
* something would make `ai-account` a thing somebody runs to find out what it does.
|
|
16
|
+
*/
|
|
17
|
+
export declare function aiAccount(verb: string | undefined, args: ParsedArgs): Promise<number>;
|
|
18
|
+
export declare function list(options?: AiAccountOptions): Promise<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Make one.
|
|
21
|
+
*
|
|
22
|
+
* ⛔ THE KEY IS PRINTED ONCE AND IS NOT STORED ANYWHERE. It is what the AI is given; this machine
|
|
23
|
+
* goes on being the account it already was. It can be derived again from this account's key and
|
|
24
|
+
* the place, which is the one thing that makes printing it here safe to have missed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function create(asked: string | undefined, options?: AiAccountOptions): Promise<number>;
|
|
27
|
+
/**
|
|
28
|
+
* Erase one.
|
|
29
|
+
*
|
|
30
|
+
* ⛔ IT IS THE SAME ERASURE THE ACCOUNT ITSELF WOULD RUN — the row, the files, the keys, the shares
|
|
31
|
+
* in both directions — and nothing undoes it. The typed sentence is `delete-account`'s, because
|
|
32
|
+
* it is the same act aimed at a different account.
|
|
33
|
+
*/
|
|
34
|
+
export declare function remove(id: string | undefined, options?: AiAccountOptions): Promise<number>;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// `nmts ai-account list|create|delete` — the accounts a person makes for an AI to work in, from a
|
|
2
|
+
// terminal.
|
|
3
|
+
//
|
|
4
|
+
// ⛔ WHY THEY EXIST AT ALL. Handing an AI this account's NMTS key hands it everything: the files,
|
|
5
|
+
// the wallet, the right to erase. An AI account is an ORDINARY account with its own key, its own
|
|
6
|
+
// wallet and its own empty drive, made under this one — so what is handed over is an account
|
|
7
|
+
// that holds nothing, and files reach it by being shared with it.
|
|
8
|
+
//
|
|
9
|
+
// ⛔ THE NMTS KEY PROVES IT, AND AN API KEY NEVER CAN. The three doors are closed to keys on
|
|
10
|
+
// purpose (`domain::agent_routes`): an AI that could make AI accounts is an account factory, and
|
|
11
|
+
// revoking its key would mean nothing once it had made three more. What travels is the derived
|
|
12
|
+
// proof — the same value a sign-in sends (`account-proof.ts`) — never the key.
|
|
13
|
+
//
|
|
14
|
+
// ⛔ AND THERE IS NO MCP TOOL FOR ANY OF IT, for the reason `key new` has none: the credential that
|
|
15
|
+
// mints credentials has to be the one a person holds.
|
|
16
|
+
//
|
|
17
|
+
// ⛔ THE NEW ACCOUNT'S KEY IS MADE HERE AND NEVER SENT. It is derived from this account's key and
|
|
18
|
+
// the place (NCF-3 §1.5), so the same place always gives the same account back — a key that was
|
|
19
|
+
// lost can be derived again, and an erased place can be re-used. What the server is told is the
|
|
20
|
+
// same pair a sign-in sends, exactly as the browser tells it.
|
|
21
|
+
import { identityOf } from "../account.js";
|
|
22
|
+
import { accountProof, accountProofFor } from "../account-proof.js";
|
|
23
|
+
import { request, ServerError } from "../api.js";
|
|
24
|
+
import { requireAccountCode } from "../code-access.js";
|
|
25
|
+
import { readCredentialsFile } from "../credentials.js";
|
|
26
|
+
import { DERIVED, loadCrypto } from "../crypto.js";
|
|
27
|
+
import { CONFIRM_SENTENCE } from "./delete-account.js";
|
|
28
|
+
import { NmtsError } from "../errors.js";
|
|
29
|
+
import { isRecord } from "../guards.js";
|
|
30
|
+
import { BINARY_NAME, HOME_URL } from "../product.js";
|
|
31
|
+
import { promptLine } from "../prompt.js";
|
|
32
|
+
import { resolveServer } from "../server.js";
|
|
33
|
+
/** How many places an account has for AI accounts of its own. The server's own ceiling. */
|
|
34
|
+
const PLACES = 3;
|
|
35
|
+
function childrenOf(answer) {
|
|
36
|
+
const list = isRecord(answer) ? answer["children"] : undefined;
|
|
37
|
+
if (!Array.isArray(list)) {
|
|
38
|
+
throw new NmtsError(`The server's answer did not carry a list of AI accounts.`, {
|
|
39
|
+
nextStep: `Nothing was changed. Report it rather than retrying — the shape, not the network, is wrong.`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const out = [];
|
|
43
|
+
for (const row of list) {
|
|
44
|
+
if (!isRecord(row))
|
|
45
|
+
continue;
|
|
46
|
+
const id = row["account_id"];
|
|
47
|
+
const index = row["child_index"];
|
|
48
|
+
const created = row["created_at"];
|
|
49
|
+
const status = row["status"];
|
|
50
|
+
if (typeof id !== "string" || typeof index !== "number" || typeof created !== "string")
|
|
51
|
+
continue;
|
|
52
|
+
const code = row["public_code"];
|
|
53
|
+
out.push({
|
|
54
|
+
account_id: id,
|
|
55
|
+
child_index: index,
|
|
56
|
+
public_code: typeof code === "string" ? code : null,
|
|
57
|
+
created_at: created,
|
|
58
|
+
status: typeof status === "string" ? status : "active",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
async function caller(options) {
|
|
64
|
+
const held = await requireAccountCode();
|
|
65
|
+
const stored = readCredentialsFile();
|
|
66
|
+
const server = resolveServer(options.server ?? stored?.server);
|
|
67
|
+
const identity = await identityOf(held.code);
|
|
68
|
+
// ⛔ BUILT FOR THIS ONE RUN AND KEPT BY NOBODY, and it asks for the agreement that covers sending
|
|
69
|
+
// it when the key came from an environment variable.
|
|
70
|
+
const authSecret = await accountProofFor({ code: held.code, source: held.source });
|
|
71
|
+
return { server, accountId: identity.accountId, authSecret, code: held.code };
|
|
72
|
+
}
|
|
73
|
+
async function listFor(who) {
|
|
74
|
+
return childrenOf(await request(who.server, "/v1/account/ai-accounts/list-by-code", {
|
|
75
|
+
method: "POST",
|
|
76
|
+
body: { account_id: who.accountId, auth_secret: who.authSecret },
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* `nmts ai-account <verb>`.
|
|
81
|
+
*
|
|
82
|
+
* ⛔ THE BARE WORD LISTS, AND THAT IS THE SAFE HALF ON PURPOSE. A command whose bare form created
|
|
83
|
+
* something would make `ai-account` a thing somebody runs to find out what it does.
|
|
84
|
+
*/
|
|
85
|
+
export async function aiAccount(verb, args) {
|
|
86
|
+
const options = { server: args.server, json: args.json, yes: args.yes };
|
|
87
|
+
if (verb === undefined || verb === "" || verb === "list")
|
|
88
|
+
return await list(options);
|
|
89
|
+
if (verb === "create")
|
|
90
|
+
return await create(args.operands[1], options);
|
|
91
|
+
if (verb === "delete")
|
|
92
|
+
return await remove(args.operands[1], options);
|
|
93
|
+
throw new NmtsError(`\`${verb}\` is not an ai-account verb.`, {
|
|
94
|
+
exitCode: 2,
|
|
95
|
+
nextStep: `The verbs are \`${BINARY_NAME} ai-account list\`, \`${BINARY_NAME} ai-account create [place]\` ` +
|
|
96
|
+
`and \`${BINARY_NAME} ai-account delete <account id>\`. Each needs the NMTS key on this ` +
|
|
97
|
+
`machine; an API key cannot reach any of them.`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export async function list(options = {}) {
|
|
101
|
+
const say = options.write ?? ((line) => process.stdout.write(`${line}\n`));
|
|
102
|
+
const who = await caller(options);
|
|
103
|
+
const children = await listFor(who);
|
|
104
|
+
if (options.json === true) {
|
|
105
|
+
say(JSON.stringify({ children }));
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
if (children.length === 0) {
|
|
109
|
+
say(`This account has made no AI accounts.`);
|
|
110
|
+
say(`\`${BINARY_NAME} ai-account create\` makes one — an ordinary account with its own key and`);
|
|
111
|
+
say(`its own empty drive, so nothing of this one's is handed over.`);
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
for (const child of children) {
|
|
115
|
+
say(`place ${child.child_index} ${child.account_id} ${child.status} made ${child.created_at.slice(0, 10)}`);
|
|
116
|
+
}
|
|
117
|
+
say(``);
|
|
118
|
+
say(`Each one's NMTS key comes from this account's key and its place, so it can be derived again`);
|
|
119
|
+
say(`— \`${BINARY_NAME} ai-account create <place>\` on a place that is already taken says so rather`);
|
|
120
|
+
say(`than printing it. \`${BINARY_NAME} ai-account delete <account id>\` erases one for good.`);
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
/** The place this run uses: the one asked for, or the lowest that is free. */
|
|
124
|
+
function placeFor(asked, taken) {
|
|
125
|
+
if (asked !== undefined && asked !== "") {
|
|
126
|
+
if (!/^[0-9]+$/u.test(asked.trim())) {
|
|
127
|
+
throw new NmtsError(`A place is a whole number from 1 to ${PLACES}, not "${asked}".`, { exitCode: 2 });
|
|
128
|
+
}
|
|
129
|
+
const place = Number(asked.trim());
|
|
130
|
+
if (place < 1 || place > PLACES) {
|
|
131
|
+
throw new NmtsError(`This account has ${PLACES} places for AI accounts, numbered 1 to ${PLACES}.`, {
|
|
132
|
+
exitCode: 2,
|
|
133
|
+
nextStep: `Nothing was made. \`${BINARY_NAME} ai-account list\` says which are taken.`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return place;
|
|
137
|
+
}
|
|
138
|
+
const used = new Set(taken.map((child) => child.child_index));
|
|
139
|
+
for (let place = 1; place <= PLACES; place += 1)
|
|
140
|
+
if (!used.has(place))
|
|
141
|
+
return place;
|
|
142
|
+
throw new NmtsError(`All ${PLACES} places under this account are taken.`, {
|
|
143
|
+
exitCode: 4,
|
|
144
|
+
nextStep: `Nothing was made. Erase one with \`${BINARY_NAME} ai-account delete <account id>\` — its place ` +
|
|
145
|
+
`comes free and re-deriving at that place later gives the same account back.`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Make one.
|
|
150
|
+
*
|
|
151
|
+
* ⛔ THE KEY IS PRINTED ONCE AND IS NOT STORED ANYWHERE. It is what the AI is given; this machine
|
|
152
|
+
* goes on being the account it already was. It can be derived again from this account's key and
|
|
153
|
+
* the place, which is the one thing that makes printing it here safe to have missed.
|
|
154
|
+
*/
|
|
155
|
+
export async function create(asked, options = {}) {
|
|
156
|
+
const say = options.write ?? ((line) => process.stdout.write(`${line}\n`));
|
|
157
|
+
const who = await caller(options);
|
|
158
|
+
const place = placeFor(asked, await listFor(who));
|
|
159
|
+
// ⛔ DERIVED HERE AND SENT NOWHERE. What the server is told is the pair below, which is what a
|
|
160
|
+
// sign-in sends for any account; the key itself never leaves this process.
|
|
161
|
+
const glue = await loadCrypto();
|
|
162
|
+
const derived = glue.kdf_derive(glue.account_code_parse(who.code));
|
|
163
|
+
const [from, to] = DERIVED.aiAccountRoot;
|
|
164
|
+
let childCode;
|
|
165
|
+
try {
|
|
166
|
+
childCode = glue.derive_ai_account_code(derived.subarray(from, to), place);
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
derived.fill(0);
|
|
170
|
+
}
|
|
171
|
+
const childIdentity = await identityOf(childCode);
|
|
172
|
+
const childSecret = await accountProof(childCode);
|
|
173
|
+
try {
|
|
174
|
+
await request(who.server, "/v1/account/ai-accounts/by-code", {
|
|
175
|
+
method: "POST",
|
|
176
|
+
body: {
|
|
177
|
+
account_id: who.accountId,
|
|
178
|
+
auth_secret: who.authSecret,
|
|
179
|
+
child_account_id: childIdentity.accountId,
|
|
180
|
+
child_auth_secret: childSecret,
|
|
181
|
+
child_index: place,
|
|
182
|
+
},
|
|
183
|
+
// ⛔ NOT REPEATED ON A TIMEOUT. A request that reached the server and died on the way back has
|
|
184
|
+
// already spent a place and one of the day's creations; a retry would spend another.
|
|
185
|
+
retryBudgetMs: 0,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
if (error instanceof ServerError && error.code === "AI_ACCOUNTS_NEED_ENABLE") {
|
|
190
|
+
throw new NmtsError(`The first AI account under this account is made in a browser.`, {
|
|
191
|
+
exitCode: 4,
|
|
192
|
+
nextStep: `Nothing was made. Turning the feature on costs a human check, which no command-line tool ` +
|
|
193
|
+
`can pass — do it once on the account screen at ${HOME_URL}, and every one after it can be ` +
|
|
194
|
+
`made from here.`,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
if (options.json === true) {
|
|
200
|
+
// ⛔ THE KEY IS IN THE JSON, because there is nowhere else it could go and a caller that asked
|
|
201
|
+
// for a machine-readable answer is the caller that has to hand it to something.
|
|
202
|
+
say(JSON.stringify({ account_id: childIdentity.accountId, child_index: place, account_code: childCode }));
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
say(`A new account for an AI exists, at place ${place}.`);
|
|
206
|
+
say(``);
|
|
207
|
+
say(` account id ${childIdentity.accountId}`);
|
|
208
|
+
say(``);
|
|
209
|
+
say(`⛔ THIS IS ITS NMTS KEY. It opens that account and nothing else — not this one.`);
|
|
210
|
+
say(` Hand it to the program that will use it, and keep it as carefully as your own.`);
|
|
211
|
+
say(``);
|
|
212
|
+
say(` ${childCode}`);
|
|
213
|
+
say(``);
|
|
214
|
+
say(`Nothing on this machine changed. The account is empty: it has its own wallet and no credits,`);
|
|
215
|
+
say(`and files reach it by being shared with it (\`${BINARY_NAME} share\`).`);
|
|
216
|
+
return 0;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Erase one.
|
|
220
|
+
*
|
|
221
|
+
* ⛔ IT IS THE SAME ERASURE THE ACCOUNT ITSELF WOULD RUN — the row, the files, the keys, the shares
|
|
222
|
+
* in both directions — and nothing undoes it. The typed sentence is `delete-account`'s, because
|
|
223
|
+
* it is the same act aimed at a different account.
|
|
224
|
+
*/
|
|
225
|
+
export async function remove(id, options = {}) {
|
|
226
|
+
const say = options.write ?? ((line) => process.stdout.write(`${line}\n`));
|
|
227
|
+
if (id === undefined || id === "") {
|
|
228
|
+
throw new NmtsError(`Say which AI account to erase.`, {
|
|
229
|
+
exitCode: 2,
|
|
230
|
+
nextStep: `\`${BINARY_NAME} ai-account delete <account id>\` — the id \`${BINARY_NAME} ai-account list\` prints.`,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const who = await caller(options);
|
|
234
|
+
say(`⛔ This erases AI account ${id} and everything in it. Nothing brings it back.`);
|
|
235
|
+
say(` Its place comes free: re-deriving at that place later gives the same account, empty.`);
|
|
236
|
+
const ask = options.readLine ?? promptLine;
|
|
237
|
+
const typed = options.yes === true ? CONFIRM_SENTENCE : (await ask(`Type exactly: ${CONFIRM_SENTENCE}\n> `)).trim();
|
|
238
|
+
if (typed !== CONFIRM_SENTENCE) {
|
|
239
|
+
say(`Nothing was erased.`);
|
|
240
|
+
return 1;
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
await request(who.server, "/v1/account/ai-accounts/erase-by-code", {
|
|
244
|
+
method: "POST",
|
|
245
|
+
body: { account_id: who.accountId, auth_secret: who.authSecret, child_id: id },
|
|
246
|
+
retryBudgetMs: 0,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
if (error instanceof ServerError && error.status === 404) {
|
|
251
|
+
throw new NmtsError(`This account made no AI account with the id ${id}.`, {
|
|
252
|
+
exitCode: 4,
|
|
253
|
+
nextStep: `Nothing was erased. \`${BINARY_NAME} ai-account list\` says which ones exist.`,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
say(`Erased. The server holds nothing about that account now.`);
|
|
259
|
+
return 0;
|
|
260
|
+
}
|