@needmoretruth/nmts-cli 0.45.0 → 0.47.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 +8 -8
- package/CHANGELOG.md +78 -0
- package/README.ko.md +6 -3
- package/README.md +31 -11
- package/dist/api-advice.js +17 -2
- package/dist/api.d.ts +22 -0
- package/dist/api.js +49 -1
- package/dist/arg-options.d.ts +19 -1
- package/dist/args.js +14 -2
- package/dist/artifact-about.d.ts +1 -1
- package/dist/autonomy.js +3 -3
- package/dist/collision.d.ts +20 -3
- package/dist/collision.js +21 -3
- package/dist/commands/erase.js +1 -0
- package/dist/commands/handover.d.ts +15 -0
- package/dist/commands/handover.js +376 -0
- package/dist/commands/heavy-run.d.ts +59 -0
- package/dist/commands/heavy-run.js +247 -0
- package/dist/commands/heavy.d.ts +7 -0
- package/dist/commands/heavy.js +123 -0
- package/dist/commands/link.d.ts +12 -0
- package/dist/commands/link.js +121 -0
- package/dist/commands/ls.d.ts +5 -0
- package/dist/commands/ls.js +9 -1
- package/dist/commands/public-code-manage.d.ts +24 -0
- package/dist/commands/public-code-manage.js +217 -0
- package/dist/commands/public-code.d.ts +12 -1
- package/dist/commands/public-code.js +140 -45
- package/dist/commands/push-heavy.d.ts +6 -0
- package/dist/commands/push-heavy.js +128 -0
- package/dist/commands/push-tree.d.ts +24 -0
- package/dist/commands/push-tree.js +91 -0
- package/dist/commands/push.d.ts +4 -13
- package/dist/commands/push.js +7 -77
- package/dist/commands/put-heavy.d.ts +9 -0
- package/dist/commands/put-heavy.js +120 -0
- package/dist/commands/put-payer.d.ts +21 -0
- package/dist/commands/put-payer.js +24 -0
- package/dist/commands/put.d.ts +2 -2
- package/dist/commands/put.js +8 -7
- package/dist/commands/receive.js +14 -8
- package/dist/commands/s3.js +44 -10
- package/dist/commands/share-dispatch.js +14 -1
- package/dist/commands/share.d.ts +2 -0
- package/dist/commands/share.js +45 -35
- package/dist/commands/shares-sent.js +8 -3
- package/dist/crypto-surface.d.ts +35 -0
- package/dist/crypto-surface.js +13 -0
- package/dist/crypto.d.ts +8 -0
- package/dist/crypto.js +8 -0
- package/dist/download-part.d.ts +32 -1
- package/dist/download-part.js +95 -6
- package/dist/download-range.d.ts +19 -0
- package/dist/download-range.js +108 -0
- package/dist/download-sink.d.ts +15 -0
- package/dist/download.d.ts +14 -0
- package/dist/download.js +19 -4
- package/dist/handover-codes.d.ts +25 -0
- package/dist/handover-codes.js +106 -0
- package/dist/handover.d.ts +62 -0
- package/dist/handover.js +217 -0
- package/dist/heavy-api.d.ts +36 -0
- package/dist/heavy-api.js +107 -0
- package/dist/heavy-copy.d.ts +72 -0
- package/dist/heavy-copy.js +108 -0
- package/dist/heavy-evm.d.ts +20 -0
- package/dist/heavy-evm.js +106 -0
- package/dist/heavy-self-pay.d.ts +92 -0
- package/dist/heavy-self-pay.js +167 -0
- package/dist/heavy-upload.d.ts +87 -0
- package/dist/heavy-upload.js +154 -0
- package/dist/heavy-wallet-pay.d.ts +39 -0
- package/dist/heavy-wallet-pay.js +73 -0
- package/dist/help-options.js +13 -4
- package/dist/help.js +24 -3
- package/dist/links.d.ts +58 -0
- package/dist/links.js +206 -0
- package/dist/list-tier.d.ts +7 -0
- package/dist/list-tier.js +47 -0
- package/dist/main.js +13 -10
- package/dist/manifest-write.d.ts +4 -3
- package/dist/mcp-tools/reads.js +20 -6
- package/dist/mcp-tools/share.js +47 -1
- package/dist/mcp-tools/tiers.js +16 -1
- package/dist/platform-sign.d.ts +4 -4
- package/dist/platform-sign.js +3 -3
- package/dist/portable.d.ts +23 -0
- package/dist/portable.js +19 -0
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/public-code-activity.d.ts +35 -0
- package/dist/public-code-activity.js +88 -0
- package/dist/public-code-refusals.d.ts +25 -0
- package/dist/public-code-refusals.js +87 -0
- package/dist/public-codes.d.ts +76 -0
- package/dist/public-codes.js +182 -0
- package/dist/recovery-build.js +16 -0
- package/dist/recovery-map-part.d.ts +82 -0
- package/dist/recovery-map-part.js +83 -0
- package/dist/recovery-map.d.ts +5 -40
- package/dist/recovery-map.js +18 -1
- package/dist/recovery-source.d.ts +3 -0
- package/dist/recovery-source.js +9 -0
- package/dist/risk.d.ts +55 -1
- package/dist/risk.js +55 -3
- package/dist/run-log.d.ts +1 -1
- package/dist/run-log.js +7 -1
- package/dist/s3/address.d.ts +20 -0
- package/dist/s3/address.js +97 -0
- package/dist/s3/answer.d.ts +48 -0
- package/dist/s3/answer.js +330 -0
- package/dist/s3/body-deframe.d.ts +49 -0
- package/dist/s3/body-deframe.js +264 -0
- package/dist/s3/body-measure.d.ts +13 -0
- package/dist/s3/body-measure.js +48 -0
- package/dist/s3/body-plan.d.ts +31 -0
- package/dist/s3/body-plan.js +159 -0
- package/dist/s3/body.d.ts +46 -0
- package/dist/s3/body.js +117 -0
- package/dist/s3/call.d.ts +36 -0
- package/dist/s3/call.js +42 -0
- package/dist/s3/checksum.d.ts +26 -0
- package/dist/s3/checksum.js +176 -0
- package/dist/s3/content-type.d.ts +3 -0
- package/dist/s3/content-type.js +49 -0
- package/dist/s3/contract.d.ts +91 -14
- package/dist/s3/drive-conditions.d.ts +47 -0
- package/dist/s3/drive-conditions.js +134 -0
- package/dist/s3/drive-key.d.ts +11 -0
- package/dist/s3/drive-key.js +58 -0
- package/dist/s3/drive-limits.d.ts +33 -0
- package/dist/s3/drive-limits.js +53 -0
- package/dist/s3/drive-lock.d.ts +11 -0
- package/dist/s3/drive-lock.js +47 -0
- package/dist/s3/drive-trashed-name.d.ts +13 -0
- package/dist/s3/drive-trashed-name.js +59 -0
- package/dist/s3/drive-write.d.ts +38 -0
- package/dist/s3/drive-write.js +258 -0
- package/dist/s3/drive.d.ts +59 -25
- package/dist/s3/drive.js +46 -77
- package/dist/s3/listing.d.ts +27 -1
- package/dist/s3/listing.js +62 -20
- package/dist/s3/long-answer.d.ts +12 -0
- package/dist/s3/long-answer.js +104 -0
- package/dist/s3/multipart-assemble.d.ts +17 -0
- package/dist/s3/multipart-assemble.js +68 -0
- package/dist/s3/multipart-sweep.d.ts +15 -0
- package/dist/s3/multipart-sweep.js +87 -0
- package/dist/s3/multipart-view.d.ts +45 -0
- package/dist/s3/multipart-view.js +232 -0
- package/dist/s3/multipart.d.ts +26 -19
- package/dist/s3/multipart.js +193 -78
- package/dist/s3/object-read.d.ts +17 -0
- package/dist/s3/object-read.js +127 -0
- package/dist/s3/object-write.d.ts +35 -0
- package/dist/s3/object-write.js +198 -0
- package/dist/s3/range.d.ts +14 -0
- package/dist/s3/range.js +80 -0
- package/dist/s3/response-sink.d.ts +12 -2
- package/dist/s3/response-sink.js +71 -7
- package/dist/s3/routes.d.ts +0 -1
- package/dist/s3/routes.js +242 -217
- package/dist/s3/same-file.d.ts +4 -1
- package/dist/s3/same-file.js +12 -3
- package/dist/s3/server.d.ts +54 -4
- package/dist/s3/server.js +174 -14
- package/dist/s3/sigv4-canonical.d.ts +91 -0
- package/dist/s3/sigv4-canonical.js +148 -0
- package/dist/s3/sigv4-presigned.d.ts +13 -0
- package/dist/s3/sigv4-presigned.js +82 -0
- package/dist/s3/sigv4.d.ts +26 -27
- package/dist/s3/sigv4.js +137 -102
- package/dist/s3/spool.d.ts +37 -0
- package/dist/s3/spool.js +104 -0
- package/dist/s3/staging.d.ts +90 -7
- package/dist/s3/staging.js +97 -66
- package/dist/s3/xml-multipart.d.ts +38 -0
- package/dist/s3/xml-multipart.js +47 -0
- package/dist/s3/xml-read.d.ts +28 -0
- package/dist/s3/xml-read.js +235 -0
- package/dist/s3/xml.d.ts +45 -2
- package/dist/s3/xml.js +72 -13
- package/dist/s3-gateway.d.ts +11 -5
- package/dist/s3-gateway.js +5 -2
- package/dist/seal.d.ts +1 -1
- package/dist/share-codes.d.ts +40 -0
- package/dist/share-codes.js +151 -0
- package/dist/share.d.ts +39 -0
- package/dist/share.js +54 -13
- package/dist/shared/lib/api/types-heavy.d.ts +167 -0
- package/dist/shared/lib/api/types-heavy.js +60 -0
- package/dist/shared/lib/drive/rebuild-verify.js +1 -0
- package/dist/shared/lib/filecoin/providers.d.ts +25 -0
- package/dist/shared/lib/filecoin/providers.js +58 -0
- package/dist/shared/lib/heavy/download.d.ts +48 -0
- package/dist/shared/lib/heavy/download.js +116 -0
- package/dist/shared/lib/heavy/order-plan.d.ts +77 -0
- package/dist/shared/lib/heavy/order-plan.js +83 -0
- package/dist/shared/lib/heavy/order-runner.d.ts +9 -0
- package/dist/shared/lib/heavy/order-runner.js +300 -0
- package/dist/shared/lib/heavy/order-types.d.ts +90 -0
- package/dist/shared/lib/heavy/order-types.js +6 -0
- package/dist/shared/lib/heavy/order-wire.d.ts +55 -0
- package/dist/shared/lib/heavy/order-wire.js +113 -0
- package/dist/shared/lib/heavy/piece-cid.d.ts +24 -0
- package/dist/shared/lib/heavy/piece-cid.js +55 -0
- package/dist/shared/lib/heavy/sp-upload.d.ts +37 -0
- package/dist/shared/lib/heavy/sp-upload.js +112 -0
- package/dist/shared/lib/heavy/synapse-piece.d.ts +1 -0
- package/dist/shared/lib/heavy/synapse-piece.js +8 -0
- package/dist/shared/lib/share/handover-format.d.ts +129 -0
- package/dist/shared/lib/share/handover-format.js +323 -0
- package/dist/shared/lib/share/public-link.d.ts +41 -0
- package/dist/shared/lib/share/public-link.js +107 -0
- package/dist/shared/lib/share/shared-file-info.js +1 -0
- package/dist/shared/lib/storage-network.d.ts +4 -4
- package/dist/shared/lib/storage-network.js +7 -7
- package/dist/shared/lib/storage-tier.d.ts +28 -0
- package/dist/shared/lib/storage-tier.js +63 -0
- package/dist/shared/lib/wallet/send-rules.js +1 -0
- package/dist/upload-file.d.ts +8 -0
- package/dist/upload-file.js +57 -25
- package/dist/upload-price-node.d.ts +3 -0
- package/dist/upload-price-node.js +3 -6
- package/dist/upload-price.d.ts +10 -0
- package/dist/upload-price.js +13 -1
- package/dist/upload-run.d.ts +80 -0
- package/dist/upload-run.js +173 -0
- package/dist/upload-steps.js +15 -4
- package/dist/upload-store.d.ts +15 -6
- package/dist/upload-store.js +6 -0
- package/dist/upload-wallet-put.d.ts +9 -4
- package/dist/upload-wallet-put.js +16 -6
- package/dist/upload-wallet.js +4 -0
- package/dist/upload-wire.d.ts +25 -0
- package/dist/upload-wire.js +20 -1
- package/dist/upload.js +28 -13
- package/dist/wallet-sign.js +2 -2
- package/docs/commands/handover.md +54 -0
- package/docs/commands/heavy.md +35 -0
- package/docs/commands/link.md +27 -0
- package/docs/commands/mcp.md +2 -1
- package/docs/commands/public-code.md +25 -6
- package/docs/commands/push.md +4 -1
- package/docs/commands/put.md +15 -1
- package/docs/commands/share.md +8 -3
- package/package.json +5 -2
- package/server.json +2 -2
- package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +106 -4
- package/vendor/nmts-crypto/nmts_crypto_wasm.js +286 -3
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +12 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// NMTS Heavy paid in WAL from one of this key's Sui wallets: the order opened first so its price can
|
|
2
|
+
// be read, the wallet's balances held against that price, and the WAL sent only once every part is
|
|
3
|
+
// stored.
|
|
4
|
+
//
|
|
5
|
+
// ⛔ SHARED BY THIS TOOL AND THE SDK. What differs between them — a person reading the price under a
|
|
6
|
+
// standing wallet agreement, or a program whose call is the agreement — is three hooks, so the
|
|
7
|
+
// order in which money can move is written once.
|
|
8
|
+
//
|
|
9
|
+
// ⛔ THE PRICE SIGNED IS THE PRICE QUOTED. The order is opened once under one idempotency key and the
|
|
10
|
+
// run reopens it under the same key; a price that changed between the two is a refusal, not a
|
|
11
|
+
// signature.
|
|
12
|
+
//
|
|
13
|
+
// ⛔ A KNOWN SHORTFALL STOPS THE RUN BEFORE ANYTHING IS SEALED. An order the wallet cannot pay leaves
|
|
14
|
+
// storage companies holding bytes nobody pays for, and counts against the day's unpaid orders.
|
|
15
|
+
import { NmtsError } from "./errors.js";
|
|
16
|
+
import { createHeavyApi } from "./heavy-api.js";
|
|
17
|
+
import { HEAVY_COPY } from "./heavy-copy.js";
|
|
18
|
+
import { heavyOrderPut, planHeavyFile } from "./heavy-upload.js";
|
|
19
|
+
import { heavyOrderRequest } from "./shared/lib/heavy/order-runner.js";
|
|
20
|
+
import { coinAmount, walCoinType, walletAddress } from "./wallet.js";
|
|
21
|
+
/** Store `files` in one wallet-paid Heavy order. */
|
|
22
|
+
export async function heavyWalletPut(ctx, files, input) {
|
|
23
|
+
const address = await walletAddress(input.code, input.wallet);
|
|
24
|
+
const idempotencyKey = ctx.idempotencyKey ?? globalThis.crypto.randomUUID();
|
|
25
|
+
const plans = files.map((f, index) => ({
|
|
26
|
+
key: `f${index}`,
|
|
27
|
+
parts: planHeavyFile(f.source.size, ctx.rule).map((p) => ({ partIndex: p.partIndex, sealedLen: p.sealedLen })),
|
|
28
|
+
}));
|
|
29
|
+
const shapeOf = (walFrost, treasury) => ({
|
|
30
|
+
coin: "WAL",
|
|
31
|
+
amountBaseUnits: walFrost,
|
|
32
|
+
destination: treasury,
|
|
33
|
+
walType: walCoinType(input.network),
|
|
34
|
+
});
|
|
35
|
+
let quote = null;
|
|
36
|
+
const payment = {
|
|
37
|
+
pay: "wallet",
|
|
38
|
+
payer: address,
|
|
39
|
+
termDays: input.termDays,
|
|
40
|
+
payWallet: async (price) => {
|
|
41
|
+
const amount = BigInt(price.wal_frost);
|
|
42
|
+
if (quote === null || amount !== quote.walFrost || price.treasury !== quote.treasury) {
|
|
43
|
+
throw new NmtsError(HEAVY_COPY.failed("payment_refused", `${amount} ≠ ${quote?.walFrost ?? "?"}`));
|
|
44
|
+
}
|
|
45
|
+
const digest = await (input.sign ?? ((shape) => signWith(input, shape)))(shapeOf(amount, price.treasury));
|
|
46
|
+
input.onPaid?.({ walFrost: amount, suiMist: quote.feeMist ?? 0n });
|
|
47
|
+
return digest;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const created = await (ctx.api ?? createHeavyApi(ctx.server, ctx.bearer)).createOrder(heavyOrderRequest(plans, payment, idempotencyKey));
|
|
51
|
+
const price = created.price;
|
|
52
|
+
if (price === undefined)
|
|
53
|
+
throw new NmtsError(HEAVY_COPY.failed("bad_answer", "no price"));
|
|
54
|
+
const walFrost = BigInt(price.wal_frost);
|
|
55
|
+
const reads = input.reads ?? (await import("./wallet-send-chain.js")).sendReads(input.network);
|
|
56
|
+
const [purse, feeMist] = await Promise.all([reads.readWallet(address), reads.estimateFee(shapeOf(walFrost, price.treasury), address)]);
|
|
57
|
+
quote = { orderId: created.order_id, address, treasury: price.treasury, walFrost, feeMist, termDays: input.termDays };
|
|
58
|
+
input.onQuote?.(quote);
|
|
59
|
+
if (!purse.sui.read || !purse.wal.read) {
|
|
60
|
+
throw new NmtsError("A balance could not be read, so this tool cannot tell what can be sent.", { exitCode: 1 });
|
|
61
|
+
}
|
|
62
|
+
if (purse.wal.baseUnits < walFrost || purse.sui.baseUnits < (feeMist ?? 0n)) {
|
|
63
|
+
throw new NmtsError(HEAVY_COPY.walletShort(coinAmount(walFrost), coinAmount(purse.wal.baseUnits), coinAmount(feeMist ?? 0n), coinAmount(purse.sui.baseUnits)), { exitCode: 4 });
|
|
64
|
+
}
|
|
65
|
+
input.approve?.(quote);
|
|
66
|
+
const outcome = await heavyOrderPut({ ...ctx, idempotencyKey }, files, payment);
|
|
67
|
+
return { ...outcome, quote };
|
|
68
|
+
}
|
|
69
|
+
/** The signing module is loaded only when WAL is about to move. */
|
|
70
|
+
async function signWith(input, shape) {
|
|
71
|
+
const { signTransfer } = await import("./wallet-sign.js");
|
|
72
|
+
return signTransfer({ network: input.network, code: input.code, wallet: input.wallet, shape });
|
|
73
|
+
}
|
package/dist/help-options.js
CHANGED
|
@@ -25,6 +25,8 @@ export function optionLines() {
|
|
|
25
25
|
` --all Include what is in the trash (ls), or take one label off every`,
|
|
26
26
|
` file that carries it (unlabel)`,
|
|
27
27
|
` --sent <path> Who ONE file was shared with, instead of the inbox (shares)`,
|
|
28
|
+
` --hide-name Leave the file's name out of the link; its size stays (link make)`,
|
|
29
|
+
` --expires <n>d When the link stops working, 1d to 3650d. Default: when it is cut (link make)`,
|
|
28
30
|
` --rename <old> The label to rename; the new name follows it (label)`,
|
|
29
31
|
` --qr Draw the wallet address as a code to scan (wallet address)`,
|
|
30
32
|
` --remove Take your name off the gift hall of fame, leaving a shortened`,
|
|
@@ -69,14 +71,16 @@ export function optionLines() {
|
|
|
69
71
|
` (whoami --phrase). Default: English`,
|
|
70
72
|
` --board The message board's terms rather than the service's (terms)`,
|
|
71
73
|
` --save Keep the document as a file, under the name the server gives it`,
|
|
72
|
-
` (notices, terms, privacy)`,
|
|
74
|
+
` (notices, terms, privacy). \`public-code --save [file]\` writes the`,
|
|
75
|
+
` public code file`,
|
|
73
76
|
` --force Replace a file that is already there (get, pull, listfile,`,
|
|
74
77
|
` recovery, recovery-list, kit), or rebuild an account this machine`,
|
|
75
78
|
` has seen a list for (rebuild). \`create\` never replaces a file`,
|
|
76
79
|
` --name <name> The name the uploaded file gets in the drive (put), or the name to`,
|
|
77
80
|
` be listed under in the gift hall of fame (wallet hall)`,
|
|
78
81
|
` --to <folder> Destination folder, as \`${BINARY_NAME} ls\` prints it (put, push).`,
|
|
79
|
-
` For \`credits transfer\` it is the account identifier that receives
|
|
82
|
+
` For \`credits transfer\` it is the account identifier that receives;`,
|
|
83
|
+
` for \`handover make\`, a public code or a public code file`,
|
|
80
84
|
` --dry-run Say what it would cost, and stop (put, push, extend), or what it`,
|
|
81
85
|
` would install, and stop (update). With \`extend\` and \`--pay`,
|
|
82
86
|
` wallet\` nothing is signed and the wallet key is never touched`,
|
|
@@ -117,8 +121,13 @@ export function optionLines() {
|
|
|
117
121
|
` --accept-privacy <v> The version of the Privacy Policy accepted in the same act (create)`,
|
|
118
122
|
` --no-wait Print the registration address and stop, instead of waiting for a`,
|
|
119
123
|
` person to open it (create, when there is no verified key)`,
|
|
120
|
-
` --publish Publish this account's public code (public-code)
|
|
121
|
-
`
|
|
124
|
+
` --publish Publish this account's public code (public-code), so other accounts`,
|
|
125
|
+
` can send files to it`,
|
|
126
|
+
` --activity Each code's shares as well as its counts (public-code list)`,
|
|
127
|
+
` --replace <n> Revoke that live code in the same request (public-code new)`,
|
|
128
|
+
` --as <n> Send from that live public code (share, handover make), or write`,
|
|
129
|
+
` that code's file (public-code --save). Default: the lowest-numbered`,
|
|
130
|
+
` live one`,
|
|
122
131
|
` --category <c> What a report is about (support send). The categories are listed by`,
|
|
123
132
|
` \`${BINARY_NAME} support --help\``,
|
|
124
133
|
` --sub <s> Which part of that category (support send). Always optional`,
|
package/dist/help.js
CHANGED
|
@@ -56,7 +56,12 @@ export function helpText(version) {
|
|
|
56
56
|
` ai-account Accounts made under this one for an AI to work in: list, create, delete.`,
|
|
57
57
|
` Each has its own NMTS key and its own empty drive. Needs the NMTS key`,
|
|
58
58
|
` extend <path> Buy more storage time for one file — **spends WAL from the wallet**`,
|
|
59
|
-
` public-code The code other accounts send files to. \`--publish\` makes it reachable
|
|
59
|
+
` public-code The code other accounts send files to. \`--publish\` makes it reachable;`,
|
|
60
|
+
` \`--save [file]\` writes your public code file, for handovers`,
|
|
61
|
+
` public-code list Every code this NMTS key has published, live and revoked`,
|
|
62
|
+
` public-code new Publish the next code. \`--replace <n>\` revokes that one in the same step`,
|
|
63
|
+
` public-code revoke <n>`,
|
|
64
|
+
` Revoke a code: nobody can send to it again. Asks every time`,
|
|
60
65
|
` delete-account A PERSON erases this account's server record — irreversible; needs the`,
|
|
61
66
|
` NMTS key, types a sentence, refused in mode auto`,
|
|
62
67
|
` accept-terms A PERSON accepts a new version of the Terms, by typing its version;`,
|
|
@@ -83,11 +88,19 @@ export function helpText(version) {
|
|
|
83
88
|
` under a name your wallet signs for; \`--remove\` goes back to a`,
|
|
84
89
|
` shortened address. Reading it signs nothing`,
|
|
85
90
|
` put <file> Encrypt one file and upload it, paid with credits — or, with`,
|
|
86
|
-
` \`--pay wallet\`, **signs and spends WAL and SUI from the wallet
|
|
91
|
+
` \`--pay wallet\`, **signs and spends WAL and SUI from the wallet**.`,
|
|
92
|
+
` \`--tier heavy\` keeps it whole in two separate places (NMTS Heavy);`,
|
|
93
|
+
` the default is \`--tier standard\``,
|
|
94
|
+
` \`--tier heavy --pay evm\` pays Filecoin from the key's own EVM wallet;`,
|
|
95
|
+
` \`--copies <1-12>\` (default 2) and \`--providers <id,…>\` choose where`,
|
|
87
96
|
` get <path> Download one file and decrypt it`,
|
|
88
97
|
` pull [folder] Download a whole folder, or the whole account, keeping its shape`,
|
|
89
98
|
` push <directory> Upload a whole directory, keeping its shape — **spends credits**,`,
|
|
90
|
-
` or the wallet with \`--pay wallet
|
|
99
|
+
` or the wallet with \`--pay wallet\`. \`--tier heavy\` as for put`,
|
|
100
|
+
` heavy wallet The EVM wallet this key derives for NMTS Heavy: its address, FIL and`,
|
|
101
|
+
` USDFC balances and its Filecoin Pay deposit. \`--index N\` another wallet`,
|
|
102
|
+
` heavy fund <USDFC> Deposit USDFC from that wallet so \`put --tier heavy --pay evm\` pays`,
|
|
103
|
+
` the storage operators itself — **signs and spends**`,
|
|
91
104
|
` rm <paths> Move things to the trash — restorable for 30 days`,
|
|
92
105
|
` restore <paths> Bring things back out of the trash`,
|
|
93
106
|
` sweep Drop trash entries whose 30 days have run out. Asks first`,
|
|
@@ -111,6 +124,14 @@ export function helpText(version) {
|
|
|
111
124
|
` shares What was shared with this account`,
|
|
112
125
|
` receive <id> Download one file somebody shared with this account`,
|
|
113
126
|
` unshare <id> Withdraw a share you sent, or remove one you were sent`,
|
|
127
|
+
` handover make <path> --to <public code | public code file>`,
|
|
128
|
+
` Write a handover file for one account — NMTS keeps no record of it,`,
|
|
129
|
+
` and it cannot be taken back. Asks every time: answer with --yes`,
|
|
130
|
+
` handover open <file> Save the file a handover file carries. Needs no API key`,
|
|
131
|
+
` link make <path> Make a public link to a file`,
|
|
132
|
+
` link list <path> List a file's public links`,
|
|
133
|
+
` link revoke <id> Cut a public link`,
|
|
134
|
+
` link open <link> Download and decrypt a file from a public link, without logging in`,
|
|
114
135
|
` env What this machine is, and what it means for the NMTS key`,
|
|
115
136
|
` unlock [name] What this machine has unlocked; \`unlock <name>\` opens one — a person,`,
|
|
116
137
|
` at a terminal. \`lock <name>\` closes it. (\`consent\` is the older name)`,
|
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { PlaintextSink } from "./download-sink.ts";
|
|
2
|
+
import type { ManifestEntry } from "./shared/lib/drive/manifest-codec.ts";
|
|
3
|
+
import type { ReadOptions } from "./walrus.ts";
|
|
4
|
+
/** The account a link is made or listed for — the same four things every account call takes. */
|
|
5
|
+
export interface LinkAccount {
|
|
6
|
+
readonly server: string;
|
|
7
|
+
/** API key or delegation token. */
|
|
8
|
+
readonly bearer: string;
|
|
9
|
+
/** The NMTS key, display form. Its dataKey opens the file key and seals the owner's copy of `S`. */
|
|
10
|
+
readonly code: string;
|
|
11
|
+
}
|
|
12
|
+
export interface MadeLink {
|
|
13
|
+
/** The whole link, secret included. */
|
|
14
|
+
link: string;
|
|
15
|
+
id: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
expiresAt: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface ListedLink {
|
|
20
|
+
id: string;
|
|
21
|
+
/** The whole link again, or null when it is cut (or its sealed secret did not open). */
|
|
22
|
+
link: string | null;
|
|
23
|
+
showsName: boolean;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
expiresAt: string | null;
|
|
26
|
+
/** When it was cut, and by whom: `owner` · `operator` · `report`. */
|
|
27
|
+
cutAt: string | null;
|
|
28
|
+
cutBy: string | null;
|
|
29
|
+
downloads: number;
|
|
30
|
+
}
|
|
31
|
+
/** Make a link to one file of the account's list. */
|
|
32
|
+
export declare function makeLink(account: LinkAccount, entry: ManifestEntry, options: {
|
|
33
|
+
showName: boolean;
|
|
34
|
+
expiresDays: number | null;
|
|
35
|
+
now?: Date;
|
|
36
|
+
}): Promise<MadeLink>;
|
|
37
|
+
/** Every link the account made to one file, newest first, cut ones included. */
|
|
38
|
+
export declare function listLinks(account: LinkAccount, itemId: string): Promise<ListedLink[]>;
|
|
39
|
+
/** Cut one of the account's links. Cutting one that is already cut is not an error. */
|
|
40
|
+
export declare function revokeLink(account: LinkAccount, id: string): Promise<void>;
|
|
41
|
+
export interface OpenedLinkFile {
|
|
42
|
+
/** The file's name, or null when the owner hid it. */
|
|
43
|
+
name: string | null;
|
|
44
|
+
bytes: number;
|
|
45
|
+
parts: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Open a link and deliver its file to `sink`, checked against the owner's digest. No account.
|
|
49
|
+
*
|
|
50
|
+
* `name` is told the file's name (or null) before a byte is fetched, so the caller can pick the sink.
|
|
51
|
+
*/
|
|
52
|
+
export declare function openLink(input: {
|
|
53
|
+
link: string;
|
|
54
|
+
server: string;
|
|
55
|
+
chain: string;
|
|
56
|
+
sink: (name: string | null) => PlaintextSink;
|
|
57
|
+
read?: ReadOptions;
|
|
58
|
+
}): Promise<OpenedLinkFile>;
|
package/dist/links.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// Public links (NCF-3 §5.8): make one, list them,
|
|
2
|
+
// cut one, and open one without an account — the code under `nmts link` and the SDK's four methods.
|
|
3
|
+
//
|
|
4
|
+
// A link is `<server>/l/<token>#<secret>`. The token names the server's row; the secret `S` opens the
|
|
5
|
+
// file key that row holds, and it is in the part after `#` that no server is sent. The shapes (link
|
|
6
|
+
// text, the sealed document) are the browser's own, copied byte for byte into `shared/`.
|
|
7
|
+
//
|
|
8
|
+
// ⛔ MAKING ONE SENDS NO SECRET. Every value in the request is an envelope made here: the file key
|
|
9
|
+
// under `S`, the document and the digest under the file key (§5.4's two re-seals), and `S` under
|
|
10
|
+
// this account's dataKey so the owner can print the same link again (`list`).
|
|
11
|
+
//
|
|
12
|
+
// ⛔ OPENING ONE ASKS FOR THE TOKEN AND NOTHING ELSE, with no session: whoever holds the link opens
|
|
13
|
+
// the file. The pieces are read from Walrus as for any download, and the whole file is checked
|
|
14
|
+
// against the digest the owner sealed before anything is delivered.
|
|
15
|
+
import { request, ServerError } from "./api.js";
|
|
16
|
+
import { fromBase64Url, fromUtf8, toBase64Url, utf8 } from "./bytes.js";
|
|
17
|
+
import { AAD, DERIVED, loadCrypto } from "./crypto.js";
|
|
18
|
+
import { fetchKnownParts } from "./download.js";
|
|
19
|
+
import { asParts } from "./download-part.js";
|
|
20
|
+
import { NmtsError } from "./errors.js";
|
|
21
|
+
import { isRecord } from "./guards.js";
|
|
22
|
+
import { buildPublicLink, decodeLinkDocument, encodeLinkDocument, linkExpiresAt, parsePublicLink, } from "./shared/lib/share/public-link.js";
|
|
23
|
+
/** Run `use` with this account's dataKey, and wipe it however `use` ends. */
|
|
24
|
+
async function withDataKey(crypt, code, use) {
|
|
25
|
+
const derived = crypt.kdf_derive(crypt.account_code_parse(code));
|
|
26
|
+
const dataKey = derived.slice(DERIVED.dataKey[0], DERIVED.dataKey[1]);
|
|
27
|
+
derived.fill(0);
|
|
28
|
+
try {
|
|
29
|
+
return await use(dataKey);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
dataKey.fill(0);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const text = (value) => (typeof value === "string" ? value : null);
|
|
36
|
+
/** Make a link to one file of the account's list. */
|
|
37
|
+
export async function makeLink(account, entry, options) {
|
|
38
|
+
if (entry.dekWrapped === undefined || entry.contentHashCt === undefined) {
|
|
39
|
+
const missing = entry.dekWrapped === undefined ? "key, so nobody could open the link" : "hash, so a download could not be checked";
|
|
40
|
+
throw new NmtsError(`No link can be made to "${entry.name}": the file list holds no ${missing}.`, {
|
|
41
|
+
exitCode: 4,
|
|
42
|
+
nextStep: "Nothing was made.",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const { dekWrapped, contentHashCt } = entry;
|
|
46
|
+
const crypt = await loadCrypto();
|
|
47
|
+
const secret = crypt.link_generate_secret();
|
|
48
|
+
try {
|
|
49
|
+
const body = await withDataKey(crypt, account.code, async (dataKey) => {
|
|
50
|
+
const dek = crypt.envelope_open(dataKey, utf8(AAD.dekWrap), fromBase64Url(dekWrapped));
|
|
51
|
+
const digest = crypt.envelope_open(dataKey, utf8(AAD.contentHash), fromBase64Url(contentHashCt));
|
|
52
|
+
try {
|
|
53
|
+
const doc = encodeLinkDocument({ name: options.showName ? entry.name : null, size: entry.size });
|
|
54
|
+
const expiresAt = linkExpiresAt(options.expiresDays, options.now ?? new Date());
|
|
55
|
+
return {
|
|
56
|
+
item_id: entry.id,
|
|
57
|
+
wrapped: toBase64Url(crypt.link_wrap_dek(secret, dek)),
|
|
58
|
+
name: toBase64Url(crypt.envelope_seal(dek, utf8(AAD.shareName), utf8(doc))),
|
|
59
|
+
disclosed_name: options.showName,
|
|
60
|
+
hash: toBase64Url(crypt.envelope_seal(dek, utf8(AAD.shareContentHash), digest)),
|
|
61
|
+
owner_secret: toBase64Url(crypt.link_seal_secret(dataKey, secret)),
|
|
62
|
+
...(expiresAt === undefined ? {} : { expires_at: expiresAt }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
dek.fill(0);
|
|
67
|
+
digest.fill(0);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const answer = await request(account.server, "/v1/share-links", { method: "POST", body, token: account.bearer });
|
|
71
|
+
const id = isRecord(answer) ? text(answer["link_id"]) : null;
|
|
72
|
+
const createdAt = isRecord(answer) ? text(answer["created_at"]) : null;
|
|
73
|
+
if (id === null || createdAt === null) {
|
|
74
|
+
throw new NmtsError("The server's answer did not name the new link.");
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
link: buildPublicLink(account.server, id, toBase64Url(secret)),
|
|
78
|
+
id,
|
|
79
|
+
createdAt,
|
|
80
|
+
expiresAt: isRecord(answer) ? text(answer["expires_at"]) : null,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
secret.fill(0);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Every link the account made to one file, newest first, cut ones included. */
|
|
88
|
+
export async function listLinks(account, itemId) {
|
|
89
|
+
const answer = await request(account.server, `/v1/share-links?item_id=${encodeURIComponent(itemId)}`, {
|
|
90
|
+
token: account.bearer,
|
|
91
|
+
});
|
|
92
|
+
const rows = isRecord(answer) ? answer["links"] : null;
|
|
93
|
+
if (!Array.isArray(rows))
|
|
94
|
+
throw new NmtsError("The server listed the links in a shape this version cannot read.");
|
|
95
|
+
const crypt = await loadCrypto();
|
|
96
|
+
return withDataKey(crypt, account.code, async (dataKey) => rows.map((row) => {
|
|
97
|
+
if (!isRecord(row))
|
|
98
|
+
throw new NmtsError("The server listed the links in a shape this version cannot read.");
|
|
99
|
+
const id = text(row["link_id"]) ?? "";
|
|
100
|
+
const cutAt = text(row["revoked_at"]);
|
|
101
|
+
const sealed = text(row["owner_secret"]);
|
|
102
|
+
let link = null;
|
|
103
|
+
if (cutAt === null && sealed !== null) {
|
|
104
|
+
try {
|
|
105
|
+
const secret = crypt.link_open_secret(dataKey, fromBase64Url(sealed));
|
|
106
|
+
link = buildPublicLink(account.server, id, toBase64Url(secret));
|
|
107
|
+
secret.fill(0);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// A secret that does not open is a row without a link, not a list that fails.
|
|
111
|
+
link = null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
id,
|
|
116
|
+
link,
|
|
117
|
+
showsName: row["disclosed_name"] === true,
|
|
118
|
+
createdAt: text(row["created_at"]) ?? "",
|
|
119
|
+
expiresAt: text(row["expires_at"]),
|
|
120
|
+
cutAt,
|
|
121
|
+
cutBy: text(row["revoked_by"]),
|
|
122
|
+
downloads: typeof row["downloads"] === "number" ? row["downloads"] : 0,
|
|
123
|
+
};
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
/** Cut one of the account's links. Cutting one that is already cut is not an error. */
|
|
127
|
+
export async function revokeLink(account, id) {
|
|
128
|
+
await request(account.server, `/v1/share-links/${encodeURIComponent(id)}`, { method: "DELETE", token: account.bearer });
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Open a link and deliver its file to `sink`, checked against the owner's digest. No account.
|
|
132
|
+
*
|
|
133
|
+
* `name` is told the file's name (or null) before a byte is fetched, so the caller can pick the sink.
|
|
134
|
+
*/
|
|
135
|
+
export async function openLink(input) {
|
|
136
|
+
const parts = parsePublicLink(input.link);
|
|
137
|
+
if (parts === null) {
|
|
138
|
+
throw new NmtsError("That is not a whole public link.", {
|
|
139
|
+
exitCode: 2,
|
|
140
|
+
nextStep: "Copy all of it, including the part after #: a link ends in /l/<token>#<secret>.",
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
let answer;
|
|
144
|
+
try {
|
|
145
|
+
answer = await request(input.server, `/v1/share-links/${encodeURIComponent(parts.token)}`);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (error instanceof ServerError && error.status === 404)
|
|
149
|
+
throw new NmtsError("This link does not exist.", { exitCode: 4 });
|
|
150
|
+
if (error instanceof ServerError && error.status === 410)
|
|
151
|
+
throw new NmtsError("This link has been cut.", { exitCode: 4 });
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
if (!isRecord(answer))
|
|
155
|
+
throw new NmtsError("The server's answer was not an object.");
|
|
156
|
+
const wrapped = text(answer["wrapped"]);
|
|
157
|
+
const sealedName = text(answer["name"]);
|
|
158
|
+
const sealedHash = text(answer["hash"]);
|
|
159
|
+
if (wrapped === null || sealedName === null || sealedHash === null) {
|
|
160
|
+
throw new NmtsError("The server described this link in a shape this version cannot read.");
|
|
161
|
+
}
|
|
162
|
+
const network = answer["network"] === "mainnet" || answer["network"] === "testnet" ? answer["network"] : input.chain;
|
|
163
|
+
const described = asParts(answer);
|
|
164
|
+
const crypt = await loadCrypto();
|
|
165
|
+
const secret = fromBase64Url(parts.secret);
|
|
166
|
+
let dek;
|
|
167
|
+
try {
|
|
168
|
+
dek = crypt.link_unwrap_dek(secret, fromBase64Url(wrapped));
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
throw new NmtsError("This link is incomplete or damaged: the part after # does not open the file.", {
|
|
172
|
+
exitCode: 4,
|
|
173
|
+
nextStep: "Nothing was fetched. Ask the person who sent it for the whole link.",
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
secret.fill(0);
|
|
178
|
+
}
|
|
179
|
+
let digest;
|
|
180
|
+
let doc;
|
|
181
|
+
try {
|
|
182
|
+
doc = decodeLinkDocument(fromUtf8(crypt.envelope_open(dek, utf8(AAD.shareName), fromBase64Url(sealedName))));
|
|
183
|
+
digest = crypt.envelope_open(dek, utf8(AAD.shareContentHash), fromBase64Url(sealedHash));
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
doc = null;
|
|
187
|
+
digest = new Uint8Array(0);
|
|
188
|
+
}
|
|
189
|
+
if (doc === null || digest.length === 0) {
|
|
190
|
+
dek.fill(0);
|
|
191
|
+
throw new NmtsError("This link is damaged: the file's name and size stored with it do not open.", {
|
|
192
|
+
exitCode: 4,
|
|
193
|
+
nextStep: "Nothing was fetched. Ask the person who sent it for a new link.",
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const fetched = await fetchKnownParts({
|
|
197
|
+
parts: [...described.parts].sort((a, b) => a.part_index - b.part_index),
|
|
198
|
+
size: doc.size,
|
|
199
|
+
dek,
|
|
200
|
+
expected: digest,
|
|
201
|
+
chain: network,
|
|
202
|
+
sink: input.sink(doc.name),
|
|
203
|
+
...(input.read === undefined ? {} : { read: input.read }),
|
|
204
|
+
});
|
|
205
|
+
return { name: doc.name, bytes: fetched.byteCount, parts: fetched.partCount };
|
|
206
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type StorageTier } from "./shared/lib/storage-tier.ts";
|
|
2
|
+
/** A file's tier from its parts: every part's network must name the same tier. */
|
|
3
|
+
export declare function tierOfParts(networks: readonly (number | undefined)[]): StorageTier | null;
|
|
4
|
+
/** The tier word as the column prints it. */
|
|
5
|
+
export declare function tierLabel(tier: StorageTier | null): string;
|
|
6
|
+
/** Each file id's tier, or null where it could not be read. */
|
|
7
|
+
export declare function tiersOf(server: string, apiKey: string, ids: readonly string[]): Promise<Map<string, StorageTier | null>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Which tier each listed file is stored on — the `tier` column of `nmts ls --long`.
|
|
2
|
+
//
|
|
3
|
+
// ⛔ THE SEALED LIST DOES NOT KNOW IT. Names and sizes live in the account's sealed list; which
|
|
4
|
+
// storage network holds a file's parts is the server's row. So the long listing asks the server
|
|
5
|
+
// the one question it already answers for a download (`GET /v1/items/{id}/parts`), a few files at
|
|
6
|
+
// a time, and only when `--long` was asked for — a plain `ls` stays one request.
|
|
7
|
+
//
|
|
8
|
+
// ⛔ WHAT CANNOT BE READ IS `?`, NEVER A GUESS. A part on a network this build does not know, a file
|
|
9
|
+
// the server would not describe (a trashed one), or a request that failed — each is shown as `?`
|
|
10
|
+
// rather than called Standard, because calling it Standard would name the wrong network.
|
|
11
|
+
import { request } from "./api.js";
|
|
12
|
+
import { asParts } from "./download-part.js";
|
|
13
|
+
import { tierForNetwork } from "./shared/lib/storage-tier.js";
|
|
14
|
+
/** How many files are asked about at once. */
|
|
15
|
+
const AT_ONCE = 8;
|
|
16
|
+
/** A file's tier from its parts: every part's network must name the same tier. */
|
|
17
|
+
export function tierOfParts(networks) {
|
|
18
|
+
if (networks.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
const tiers = new Set(networks.map((n) => tierForNetwork(n)));
|
|
21
|
+
const [only] = [...tiers];
|
|
22
|
+
return tiers.size === 1 && only !== undefined ? only : null;
|
|
23
|
+
}
|
|
24
|
+
/** The tier word as the column prints it. */
|
|
25
|
+
export function tierLabel(tier) {
|
|
26
|
+
return tier ?? "?";
|
|
27
|
+
}
|
|
28
|
+
/** Each file id's tier, or null where it could not be read. */
|
|
29
|
+
export async function tiersOf(server, apiKey, ids) {
|
|
30
|
+
const out = new Map();
|
|
31
|
+
let next = 0;
|
|
32
|
+
const worker = async () => {
|
|
33
|
+
for (let id = ids[next]; id !== undefined; id = ids[next]) {
|
|
34
|
+
next += 1;
|
|
35
|
+
try {
|
|
36
|
+
const described = asParts(await request(server, `/v1/items/${encodeURIComponent(id)}/parts`, { token: apiKey }));
|
|
37
|
+
out.set(id, tierOfParts(described.parts.map((p) => p.network)));
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Not readable is its own answer, and the column says so with `?`.
|
|
41
|
+
out.set(id, null);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
await Promise.all(Array.from({ length: Math.min(AT_ONCE, ids.length) }, worker));
|
|
46
|
+
return out;
|
|
47
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -96,9 +96,7 @@ export async function run(argv) {
|
|
|
96
96
|
json: args.json,
|
|
97
97
|
all: args.all,
|
|
98
98
|
find: args.find,
|
|
99
|
-
sort: args.sort,
|
|
100
|
-
desc: args.desc,
|
|
101
|
-
media: args.media,
|
|
99
|
+
sort: args.sort, desc: args.desc, long: args.long, media: args.media,
|
|
102
100
|
});
|
|
103
101
|
}
|
|
104
102
|
case "usage": {
|
|
@@ -115,10 +113,12 @@ export async function run(argv) {
|
|
|
115
113
|
server: args.server, network: args.network, json: args.json, to: args.to,
|
|
116
114
|
});
|
|
117
115
|
}
|
|
118
|
-
case "public-code":
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
case "public-code":
|
|
117
|
+
return await (await import("./commands/public-code.js")).runPublicCode(args);
|
|
118
|
+
case "handover":
|
|
119
|
+
return await (await import("./commands/handover.js")).handover(args.operands[0], args.operands[1], {
|
|
120
|
+
server: args.server, network: args.network, to: args.to, out: args.out, as: args.as, force: args.force, yes: args.yes, json: args.json,
|
|
121
|
+
});
|
|
122
122
|
case "wallet": {
|
|
123
123
|
const { wallet } = await import("./commands/wallet.js");
|
|
124
124
|
return await wallet(args.operands[0], {
|
|
@@ -186,11 +186,10 @@ export async function run(argv) {
|
|
|
186
186
|
dryRun: args.dryRun,
|
|
187
187
|
partSize: args.partSize,
|
|
188
188
|
onCollision: args.onCollision,
|
|
189
|
-
deposit: args.deposit,
|
|
190
|
-
pay: args.pay,
|
|
191
|
-
epochs: args.epochs,
|
|
189
|
+
deposit: args.deposit, pay: args.pay, epochs: args.epochs,
|
|
192
190
|
storage: args.storage, from: args.from,
|
|
193
191
|
json: args.json, wallet: args.wallet, trustServerTipAddress: args.trustServerTipAddress,
|
|
192
|
+
tier: args.tier, copies: args.copies, providers: args.providers, evmWallet: args.evmWallet, days: args.days,
|
|
194
193
|
thumbnail: args.thumbnail, thumbnailFile: args.thumbnailFile,
|
|
195
194
|
});
|
|
196
195
|
}
|
|
@@ -209,6 +208,7 @@ export async function run(argv) {
|
|
|
209
208
|
epochs: args.epochs,
|
|
210
209
|
storage: args.storage,
|
|
211
210
|
json: args.json, wallet: args.wallet, trustServerTipAddress: args.trustServerTipAddress,
|
|
211
|
+
tier: args.tier, copies: args.copies, providers: args.providers, evmWallet: args.evmWallet, days: args.days,
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
case "rm": {
|
|
@@ -295,6 +295,7 @@ export async function run(argv) {
|
|
|
295
295
|
case "share":
|
|
296
296
|
case "shares":
|
|
297
297
|
case "unshare":
|
|
298
|
+
case "link":
|
|
298
299
|
case "receive": {
|
|
299
300
|
const { runShare } = await import("./commands/share-dispatch.js");
|
|
300
301
|
return await runShare(args.command, args);
|
|
@@ -350,6 +351,8 @@ export async function run(argv) {
|
|
|
350
351
|
}
|
|
351
352
|
case "platform":
|
|
352
353
|
return (await import("./commands/platform.js")).platform(args.operands[0], { out: args.out });
|
|
354
|
+
case "heavy":
|
|
355
|
+
return await (await import("./commands/heavy.js")).heavy(args.operands[0], args);
|
|
353
356
|
case "s3": {
|
|
354
357
|
const { s3 } = await import("./commands/s3.js");
|
|
355
358
|
return await s3({ server: args.server, network: args.network, port: args.port, json: args.json });
|
package/dist/manifest-write.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ManifestEntry } from "./shared/lib/drive/manifest-codec.ts";
|
|
2
2
|
import { type FindOptions } from "./drive-paths.ts";
|
|
3
|
-
import { type OnCollision } from "./collision.ts";
|
|
3
|
+
import { type CollisionAsk, type OnCollision } from "./collision.ts";
|
|
4
4
|
import { type ManifestIntent, type SettingsPatch } from "./shared/lib/drive/manifest-ops.ts";
|
|
5
5
|
/**
|
|
6
6
|
* ⛔ THE SAME FIELD NAMES `Session` USES, so a session IS a valid input and nothing has to be
|
|
@@ -87,9 +87,10 @@ export interface AddEntryInput extends ListEditInput {
|
|
|
87
87
|
entry: ManifestEntry;
|
|
88
88
|
/**
|
|
89
89
|
* What THIS run asked for when the name is already in use. Absent = whatever this machine is
|
|
90
|
-
* set to (`collision.ts`), which is what an ordinary upload wants.
|
|
90
|
+
* set to (`collision.ts`), which is what an ordinary upload wants. A program's own choice comes
|
|
91
|
+
* as a `ProgramChoice`, and `collision.ts` says why that one is not held to the modes.
|
|
91
92
|
*/
|
|
92
|
-
onCollision?:
|
|
93
|
+
onCollision?: CollisionAsk;
|
|
93
94
|
}
|
|
94
95
|
export interface AddEntryResult {
|
|
95
96
|
/** The version now current. */
|
package/dist/mcp-tools/reads.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// do next will call them repeatedly, and a surface where "just checking" costs money teaches
|
|
6
6
|
// the opposite of the habit this tool wants.
|
|
7
7
|
import { publicCode } from "../commands/public-code.js";
|
|
8
|
+
import { listCodes } from "../commands/public-code-manage.js";
|
|
9
|
+
import { isRecord } from "../guards.js";
|
|
8
10
|
import { balance } from "../commands/balance.js";
|
|
9
11
|
import { devices } from "../commands/devices.js";
|
|
10
12
|
import { legal, notices } from "../commands/documents.js";
|
|
@@ -122,13 +124,25 @@ export function readTools(ctx) {
|
|
|
122
124
|
},
|
|
123
125
|
{
|
|
124
126
|
name: "nmts_public_code",
|
|
125
|
-
description: "The account's PUBLIC
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
127
|
+
description: "The account's PUBLIC CODES — the values other accounts send files to. `code` is the " +
|
|
128
|
+
"default one (the lowest-numbered live code) and whether it is published; `codes` lists " +
|
|
129
|
+
"every code with its number, whether it is live or revoked, and how many shares and " +
|
|
130
|
+
"messages went through it; `live`, `liveMax`, `madeToday` and `dayCap` are the server's " +
|
|
131
|
+
"ceilings. With `activity`, each code also lists its shares. Until a code is published " +
|
|
132
|
+
"nobody can send to this account; nmts_public_code_new publishes one. ⚠ Not the NMTS " +
|
|
129
133
|
"key, which opens every file and is never given away.",
|
|
130
|
-
inputSchema:
|
|
131
|
-
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
activity: { type: "boolean", description: "List each code's sent and received shares too." },
|
|
138
|
+
},
|
|
139
|
+
additionalProperties: false,
|
|
140
|
+
},
|
|
141
|
+
run: async (args) => {
|
|
142
|
+
const head = JSON.parse(await say((write) => publicCode({ ...common(ctx), json: true, write })));
|
|
143
|
+
const all = JSON.parse(await say((write) => listCodes({ ...common(ctx), json: true, activity: args["activity"] === true, write })));
|
|
144
|
+
return JSON.stringify({ ...(isRecord(head) ? head : {}), ...(isRecord(all) ? all : {}) });
|
|
145
|
+
},
|
|
132
146
|
},
|
|
133
147
|
{
|
|
134
148
|
name: "nmts_shares",
|