midnight-wallet-cli 0.6.0-rc.11 → 0.6.0-rc.13

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.
Files changed (91) hide show
  1. package/README.md +1 -0
  2. package/dist/help-7qyfwsje.js +2 -0
  3. package/dist/{manual-xf8mep9e.js → manual-qb6qctpp.js} +9 -9
  4. package/dist/mcp-server.js +11 -5
  5. package/dist/wallet-09wg5ya1.js +3 -0
  6. package/dist/wallet-1t9dxmnf.js +208 -0
  7. package/dist/wallet-62zj083d.js +4 -0
  8. package/dist/wallet-64nb5y33.js +3 -0
  9. package/dist/wallet.js +7 -7
  10. package/docs/SKILL-CORE.md +1 -1
  11. package/docs/SKILL.md +40 -14
  12. package/npm-shrinkwrap.json +151 -43
  13. package/package.json +21 -14
  14. package/dist/account-backup-kvg9gyq1.js +0 -2
  15. package/dist/account-protector-gx1yrfgp.js +0 -2
  16. package/dist/actions-runner-9xfw1w9e.js +0 -5
  17. package/dist/address-evr423re.js +0 -10
  18. package/dist/ai-scaffold-6tb9d9z6.js +0 -2
  19. package/dist/airdrop-q2ay0qh5.js +0 -45
  20. package/dist/balance-898sn3v8.js +0 -45
  21. package/dist/cache-gbw42c6c.js +0 -5
  22. package/dist/chain-caches-2cysk5pv.js +0 -2
  23. package/dist/circuit-witness-deps-04k7ajgt.js +0 -2
  24. package/dist/contract-742etqts.js +0 -71
  25. package/dist/create-a2bmx3q9.js +0 -2
  26. package/dist/create-writer-6wx6swxc.js +0 -9
  27. package/dist/deploy-wj9dmx17.js +0 -2
  28. package/dist/dev-6pf7bcnj.js +0 -55
  29. package/dist/discover-screens-q2tft8zf.js +0 -2
  30. package/dist/dust-z4av6tq0.js +0 -57
  31. package/dist/generate-eb8wbmfd.js +0 -21
  32. package/dist/genesis-address-cskqa9mm.js +0 -9
  33. package/dist/grant-0rcbfpsn.js +0 -61
  34. package/dist/help-6q5bv3ma.js +0 -2
  35. package/dist/info-636h7nea.js +0 -17
  36. package/dist/inspect-cge38gtw.js +0 -2
  37. package/dist/inspect-cost-rjcacee7.js +0 -14
  38. package/dist/localnet-4c1h8g5c.js +0 -119
  39. package/dist/passphrase-x33jkceg.js +0 -2
  40. package/dist/prepare-qhmmx1cp.js +0 -2
  41. package/dist/private-state-42r7118m.js +0 -2
  42. package/dist/protect-account-cjt1kprd.js +0 -2
  43. package/dist/request-1ywpssaq.js +0 -2
  44. package/dist/request-7cv5q4zr.js +0 -2
  45. package/dist/request-w4m7mnd6.js +0 -2
  46. package/dist/runner-jc3va6pt.js +0 -2
  47. package/dist/runtime-check-bcs9vc31.js +0 -2
  48. package/dist/sealed-account-ycx7cfmh.js +0 -2
  49. package/dist/serve-gybtxfhe.js +0 -30
  50. package/dist/serve-manager-y583rzeg.js +0 -2
  51. package/dist/serve-payer-z61n9qt1.js +0 -2
  52. package/dist/swap-7h203xka.js +0 -49
  53. package/dist/test-create-prompt-fdtvr457.js +0 -32
  54. package/dist/test-sr2cphp1.js +0 -110
  55. package/dist/transfer-ftpr5p84.js +0 -32
  56. package/dist/transfer-request-pbtf7qt8.js +0 -2
  57. package/dist/wallet-11ej36j3.js +0 -33
  58. package/dist/wallet-1n657wjk.js +0 -4
  59. package/dist/wallet-3bmeys56.js +0 -4
  60. package/dist/wallet-3qw465k0.js +0 -3
  61. package/dist/wallet-50qp35yf.js +0 -3
  62. package/dist/wallet-56gd7q8n.js +0 -3
  63. package/dist/wallet-64k8pxzd.js +0 -3
  64. package/dist/wallet-6vz9m65h.js +0 -3
  65. package/dist/wallet-7m1tvbsv.js +0 -386
  66. package/dist/wallet-b1v87xw6.js +0 -3
  67. package/dist/wallet-b7grv9vr.js +0 -89
  68. package/dist/wallet-config-w1w2ryv3.js +0 -2
  69. package/dist/wallet-create-brh55b4c.js +0 -2
  70. package/dist/wallet-csq2jnjv.js +0 -58
  71. package/dist/wallet-dmk3g8wb.js +0 -4
  72. package/dist/wallet-fb292x9c.js +0 -203
  73. package/dist/wallet-fxbfef5d.js +0 -3
  74. package/dist/wallet-hh8sn1zx.js +0 -4
  75. package/dist/wallet-hrarrm8j.js +0 -3
  76. package/dist/wallet-hrz0vezs.js +0 -23
  77. package/dist/wallet-ke9fpmrp.js +0 -3
  78. package/dist/wallet-khvrzs3r.js +0 -11
  79. package/dist/wallet-r5s7ppf3.js +0 -3
  80. package/dist/wallet-rsjfsjg5.js +0 -7
  81. package/dist/wallet-rzq4akdz.js +0 -3
  82. package/dist/wallet-tdtnx9g9.js +0 -14
  83. package/dist/wallet-vn9pp5nm.js +0 -4
  84. package/dist/wallet-wafaf7cc.js +0 -6
  85. package/dist/wallet-wez4z95e.js +0 -15
  86. package/dist/wallet-wrakcchp.js +0 -3
  87. package/dist/wallet-wybe948x.js +0 -3
  88. package/dist/wallet-yjt60vht.js +0 -195
  89. package/dist/wallet-z1s08pnt.js +0 -3
  90. package/dist/wallet-z7aqejee.js +0 -4
  91. package/dist/wallet-zry57pyk.js +0 -3
package/README.md CHANGED
@@ -50,6 +50,7 @@ Install the prerelease with npm (or run it with `npx`). It ships an `npm-shrinkw
50
50
  | `midnight dev [path]` | Iteration loop for Compact contract development (localnet + compile-on-save + one-key deploy) |
51
51
  | `midnight contract <inspect\|deploy\|call\|state> [options]` | Inspect, deploy, call, and query Midnight smart contracts |
52
52
  | `midnight swap <make\|inspect\|take\|cancel\|list> [options]` | Private swaps of shielded tokens, through offer files (experimental) |
53
+ | `midnight tx status <hash or identifier> [options]` | What became of a transaction: its block, time, fee and result |
53
54
  | `midnight grant <deploy\|deposit\|status\|list\|issue\|revoke\|revoke-all\|export\|import\|device> [options]` | This wallet's account, and the grants that let an agent spend from it (experimental) |
54
55
  | `midnight localnet <up\|stop\|down\|status\|logs\|clean>` | Manage a local Midnight network via Docker Compose (up is refused on this ledger-9 build) |
55
56
  | `midnight help [command]` | Show usage for all commands or a specific command |
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{e as a,f as b}from"./wallet-1t9dxmnf.js";import"./wallet-64nb5y33.js";import"./wallet-09wg5ya1.js";export{a as helpSpecs,b as default};
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{a as f}from"./wallet-fb292x9c.js";import{ob as k,pb as B,rb as T}from"./wallet-7m1tvbsv.js";import"./wallet-56gd7q8n.js";import{spawn as C}from"node:child_process";import{hasFlag as $}from"@kuiralabs/midnight-cli-core/lib/argv";import{bold as z,dim as q,teal as W,yellow as H,white as v}from"@kuiralabs/midnight-cli-core/ui/colors";var L="═".repeat(63),U="─".repeat(64);function G(j){return`${z(L)}
3
- ${z(v(j))}
4
- ${z(L)}
2
+ import{e as I}from"./wallet-1t9dxmnf.js";import{g as K,i as M,j as A}from"./wallet-64nb5y33.js";import{l as V,m as F,o as G,p as B}from"./wallet-09wg5ya1.js";import{spawn as O}from"node:child_process";import{hasFlag as $}from"@kuiralabs/midnight-cli-core";import{bold as z,dim as q,teal as W,yellow as H,white as L}from"@kuiralabs/midnight-cli-core/ui";var T="═".repeat(63),v="─".repeat(64);function f(j){return`${z(T)}
3
+ ${z(L(j))}
4
+ ${z(T)}
5
5
  `}function Q(j){return`
6
- ${q(U)}
7
- ${z(v(j))}
8
- ${q(U)}
9
- `}function I(j){let D=[];if(D.push(`${W(z("▸ "+j.name))}${" ".repeat(Math.max(2,22-j.name.length))}${j.description}`),D.push(""),D.push(` ${z("USAGE")}`),D.push(` ${j.usage}`),j.flags&&j.flags.length>0){D.push(""),D.push(` ${z("FLAGS")}`);for(let J of j.flags){let X=J.match(/^(\s*)(--[\w-]+(?:\s<[^>]+>)?)(\s+)(.*)$/);if(X)D.push(` ${H(X[2])}${X[3]}${X[4]}`);else if(/^[A-Za-z][\w -]*:/.test(J))D.push(` ${q(J)}`);else if(J.trim()==="")D.push("");else D.push(` ${J}`)}}if(j.examples&&j.examples.length>0){D.push(""),D.push(` ${z("EXAMPLES")}`);for(let J of j.examples)D.push(` ${q("$")} ${q(J)}`)}return D.join(`
10
- `)}function Y(){let j=[];j.push(G(`${k} manual v${B}`)),j.push(""),j.push(`${z("NAME")}`),j.push(" midnight (mn) — wallet and development CLI for the Midnight blockchain"),j.push(""),j.push(`${z("SYNOPSIS")}`),j.push(" mn <command> [subcommand] [options]"),j.push(" midnight <command> [subcommand] [options]"),j.push(""),j.push(`${z("DESCRIPTION")}`),j.push(" midnight-wallet-cli is a standalone CLI that handles wallet"),j.push(" operations, contract deployment, and a development loop, on four"),j.push(" networks (undeployed, preprod, preview, stagenet). Every command speaks"),j.push(" JSON via --json for use with AI agents and scripts. An MCP"),j.push(" server ships with the package."),j.push(""),j.push(` ${z("Ledger 9 only.")} This build refuses a chain still on ledger 8`),j.push(" (preview and preprod today); use midnight-wallet-cli 0.5.x there."),j.push(` ${q("mn localnet up")} is refused too: no published indexer image runs`),j.push(" ledger 9 yet. Run a ledger-9 stack yourself and point mn at it with"),j.push(` --node / --indexer-ws / --proof-server or ${q("mn config set")}.`),j.push(""),j.push(`${z("INSTALLATION")}`),j.push(` ${q("$")} ${q("npm install -g midnight-wallet-cli@next")} ${q("# this ledger-9 prerelease")}`),j.push(` ${q("$")} ${q("npm install -g midnight-wallet-cli")} ${q("# stable 0.5.x, ledger 8")}`),j.push(""),j.push(" Optional dependencies:"),j.push(" Compact toolchain: https://docs.midnight.network/develop"),j.push(" Docker: for mn localnet (up is refused on this build)"),j.push(Q("CONCEPTS")),j.push(` ${z("Networks")}`),j.push(` ${W("undeployed")} Local network. Free dev tokens, fast iteration.`),j.push(` ${W("preprod")} Public testnet. Persistent, real ZK proofs. (Ledger 8 today: refused.)`),j.push(" Served by Blockfrost: needs your own project id (see Configuration)."),j.push(` ${W("preview")} Public testnet, smaller scale. (Ledger 8 today: refused.)`),j.push(""),j.push(` ${z("Tokens")}`),j.push(` ${H("NIGHT")} Native asset. Used for transfers and contract value.`),j.push(` ${H("DUST")} Fee token. Generated from registered NIGHT UTXOs.`),j.push(""),j.push(` ${z("Wallets")}`),j.push(` Stored at ${q("~/.midnight/wallets/<name>.json")}`),j.push(" Three networks share one seed; each gets its own derived address."),j.push(" A tip-aware cache makes repeated reads finish in seconds."),j.push(""),j.push(` ${z("Shielded vs Unshielded")}`),j.push(` ${H("Unshielded")} addresses (mn_addr_*) are like UTXOs.`),j.push(` ${H("Shielded")} addresses (mn_shield-addr_*) hide amount and recipient.`),j.push(Q("COMMANDS"));for(let D of f())j.push(I(D)),j.push("");return j.push(Q("COMMON FLOWS")),j.push(` ${z("First wallet on undeployed")}`),j.push(` ${q("# needs a ledger-9 stack you run (localnet up is refused). On the")}`),j.push(` ${q("# default ports (node 9944, indexer 8088, proof server 6300) mn finds")}`),j.push(` ${q("# it; otherwise pass --node/--indexer-ws/--proof-server or mn config set.")}`),j.push(` ${q("$")} ${q("mn wallet generate alice")}`),j.push(` ${q("$")} ${q("mn airdrop 1000 --wallet alice")}`),j.push(` ${q("$")} ${q("mn dust register --wallet alice")}`),j.push(` ${q("$")} ${q("mn balance --wallet alice")}`),j.push(""),j.push(` ${z("First wallet on preprod")} ${q("(once preprod runs ledger 9)")}`),j.push(` ${q("# once: a Midnight preprod project id from https://blockfrost.io")}`),j.push(` ${q("$")} ${q("mn config set blockfrost-project-id nightpreprod...")}`),j.push(` ${q("$")} ${q("mn wallet generate alice --network preprod")}`),j.push(` ${q("# fund from the preprod faucet:")}`),j.push(` ${q("# https://faucet.preprod.midnight.network/")}`),j.push(` ${q("$")} ${q("mn dust register --wallet alice --network preprod")}`),j.push(` ${q("$")} ${q("mn balance --wallet alice --network preprod")}`),j.push(""),j.push(` ${z("Deploy and call a contract on undeployed")}`),j.push(" Prerequisite: a compiled artifact at ./src/managed/<name>/"),j.push(""),j.push(` ${q("$")} ${q("mn contract deploy --wallet alice")}`),j.push(` ${q(" → Address: 64da9d71cb…")}`),j.push(` ${q("$")} ${q("mn contract state --address 64da9d71cb… --wallet alice")}`),j.push(` ${q(' → { "round": 0 }')}`),j.push(` ${q("$")} ${q("mn contract call --address 64da9d71cb… --circuit increment --wallet alice")}`),j.push(` ${q("$")} ${q("mn contract state --address 64da9d71cb… --wallet alice")}`),j.push(` ${q(' → { "round": 1 }')}`),j.push(""),j.push(" Same artifact on preprod — swap one flag:"),j.push(` ${q("$")} ${q("mn contract deploy --network preprod --wallet alice")}`),j.push(""),j.push(` ${z("Transfer NIGHT between wallets")}`),j.push(` ${q("$")} ${q("mn transfer bob 100 --wallet alice")}`),j.push(` ${q(" shielded variant:")}`),j.push(` ${q("$")} ${q("mn transfer bob 100 --shielded --wallet alice")}`),j.push(Q("CONFIGURATION")),j.push(` ${z("Files")}`),j.push(` ${q("~/.midnight/config.json")} Persistent CLI settings`),j.push(` ${q("~/.midnight/wallets/")} Per-wallet JSON files (mode 0600)`),j.push(` ${q("~/.midnight/cache/<network>/")} Wallet sync cache, per network`),j.push(""),j.push(` ${z("Config keys")}`),j.push(` ${H("network")} Default network when --network is omitted`),j.push(` ${H("wallet")} Default wallet when --wallet is omitted`),j.push(` ${H("proof-server")} Override proof server URL`),j.push(` ${H("node")} Override substrate RPC URL`),j.push(` ${H("indexer-ws")} Override indexer WebSocket URL`),j.push(` ${H("blockfrost-project-id")}`),j.push(" Your Blockfrost project id for preprod, whose indexer and"),j.push(" node Blockfrost serves. Kept per network, shown masked,"),j.push(" never printed. Or: MN_BLOCKFROST_PROJECT_ID / BLOCKFROST_PROJECT_ID."),j.push(` ${H("sdk-set")} The SDK set a network runs on (rc or beta), per network;`),j.push(" each network has its own (stagenet beta, the rest rc)."),j.push(""),j.push(` ${z("Compatibility alias")}`),j.push(` ${H("network-id")} Resolves transparently to ${H("network")}.`),j.push(""),j.push(` ${z("Examples")}`),j.push(` ${q("$")} ${q("mn config set network preprod")}`),j.push(` ${q("$")} ${q("mn config get network")}`),j.push(` ${q("$")} ${q("mn config unset proof-server")}`),j.push(Q("JSON OUTPUT")),j.push(` Every command accepts ${H("--json")} for structured output on stdout.`),j.push(" Stderr keeps the chrome (spinners, headers); stdout stays parseable."),j.push(""),j.push(` ${q("$")} ${q("mn balance <addr> --json | jq -r .NIGHT")}`),j.push(` ${q("$")} ${q("mn wallet info alice --json")}`),j.push(""),j.push(` Stable JSON shapes are documented in ${q("docs/JSON_CONTRACT.md")}.`),j.push(" We promise not to break those without a major version bump."),j.push(Q("EXIT CODES")),j.push(` ${K("0")} Success`),j.push(` ${q("1")} Unknown error`),j.push(` ${M("2")} Invalid arguments (usage error, see yellow message on stderr)`),j.push(` ${q("3")} Wallet not found`),j.push(` ${q("4")} Network error`),j.push(` ${q("5")} Insufficient balance / DUST_REQUIRED`),j.push(` ${q("6")} Transaction rejected / STALE_UTXO / PROOF_TIMEOUT`),j.push(` ${q("7")} Cancelled by user`),j.push(""),j.push(` ${z("Stable error code strings")} (in JSON ${H("--json")} error output):`),j.push(` ${H("DUST_REQUIRED")} No dust available to pay fees`),j.push(` ${H("STALE_UTXO")} UTXO consumed concurrently, retry`),j.push(` ${H("PROOF_TIMEOUT")} Proof generation exceeded deadline`),j.push(` ${H("PROOF_FAILURE")} Proof server rejected the proof`),j.push(` ${H("INVALID_DUST_PROOF")} Stale commitment tree, run ${q("mn cache clear")}`),j.push(` ${H("STALE_CACHE")} Local cache out of sync, run ${q("mn cache clear")}`),j.push(` ${H("SYNC_TIMEOUT")} Wallet sync exceeded its deadline`),j.push(Q("TROUBLESHOOTING")),j.push(` ${z('Sync hangs forever or "applied > highest" error')}`),j.push(" Stale cache after a chain reset. Recover with:"),j.push(` ${q("$")} ${q("mn cache clear --wallet <name>")}`),j.push(""),j.push(` ${z('"DUST_REQUIRED" or "no dust available" on transfer')}`),j.push(" Wallet has NIGHT but no fee token. Register dust:"),j.push(` ${q("$")} ${q("mn dust register --wallet <name>")}`),j.push(" Then wait until status shows availability:"),j.push(` ${q("$")} ${q("mn dust status --wallet <name>")}`),j.push(" A registered wallet can still be short of a fee right after paying one:"),j.push(" its NIGHT generates Dust with time. mn waits by itself when the fee is a"),j.push(" few minutes away, and otherwise says how long it takes: retry then."),j.push(""),j.push(` ${z('"Cannot find package @midnight-ntwrk/..." on contract deploy')}`),j.push(" The CLI bundles its own SDK. Reinstall to pick up the bundle:"),j.push(` ${q("$")} ${q("npm install -g midnight-wallet-cli@latest")}`),j.push(""),j.push(` ${z('"witnesses module not found" on contract deploy')}`),j.push(" Your contract declares witnesses but witnesses.js isn't built."),j.push(" Build the TypeScript source first:"),j.push(` ${q("$")} ${q("npm run build")}`),j.push(""),j.push(` ${z('"mn serve already running on port 9932 for network X"')}`),j.push(" A leftover serve from a previous network is in the way."),j.push(` ${q("$")} ${q("pkill -f 'mn serve'")}`),j.push(Q("SEE ALSO")),j.push(` ${W("mn help")} Brief command list`),j.push(` ${W("mn help <command>")} Help for one command (flags and examples)`),j.push(` ${W("mn help --agent")} Comprehensive AI / MCP reference`),j.push(""),j.push(` Repository: ${q(T.replace(/^https:\/\//,""))}`),j.push(` JSON contract: ${q("docs/JSON_CONTRACT.md")}`),j.push(""),j.join(`
11
- `)}function K(j){return`\x1B[32m${j}\x1B[0m`}function M(j){return`\x1B[33m${j}\x1B[0m`}async function N(j,D,J){if(!J||!process.stdout.isTTY){j.stdout(D);return}let X=process.env.PAGER??"less -R",[V,...A]=X.split(/\s+/);if(!V){j.stdout(D);return}await new Promise((F)=>{let Z=C(V,A,{stdio:["pipe","inherit","inherit"]});Z.stdin.on("error",()=>{}),Z.on("close",()=>F()),Z.on("error",()=>{j.stdout(D),F()}),Z.stdin.write(D),Z.stdin.end()})}async function O(j,D){let J=!$(j,"no-pager");if($(j,"json")){D.output.result({name:k,version:B,manual:Y()});return}if($(j,"raw")){D.output.stdout(Y().replace(/\x1b\[[0-9;]*m/g,""));return}await N(D.output,Y(),J)}export{O as default,Y as buildManual};
6
+ ${q(v)}
7
+ ${z(L(j))}
8
+ ${q(v)}
9
+ `}function C(j){let D=[];if(D.push(`${W(z("▸ "+j.name))}${" ".repeat(Math.max(2,22-j.name.length))}${j.description}`),D.push(""),D.push(` ${z("USAGE")}`),D.push(` ${j.usage}`),j.flags&&j.flags.length>0){D.push(""),D.push(` ${z("FLAGS")}`);for(let J of j.flags){let X=J.match(/^(\s*)(--[\w-]+(?:\s<[^>]+>)?)(\s+)(.*)$/);if(X)D.push(` ${H(X[2])}${X[3]}${X[4]}`);else if(/^[A-Za-z][\w -]*:/.test(J))D.push(` ${q(J)}`);else if(J.trim()==="")D.push("");else D.push(` ${J}`)}}if(j.examples&&j.examples.length>0){D.push(""),D.push(` ${z("EXAMPLES")}`);for(let J of j.examples)D.push(` ${q("$")} ${q(J)}`)}return D.push(""),D.push(` ${z("ERRORS")}`),D.push(...M(j,4,H)),D.join(`
10
+ `)}function Y(){let j=[];j.push(f(`${V} manual v${F}`)),j.push(""),j.push(`${z("NAME")}`),j.push(" midnight (mn) — wallet and development CLI for the Midnight blockchain"),j.push(""),j.push(`${z("SYNOPSIS")}`),j.push(" mn <command> [subcommand] [options]"),j.push(" midnight <command> [subcommand] [options]"),j.push(""),j.push(`${z("DESCRIPTION")}`),j.push(" midnight-wallet-cli is a standalone CLI that handles wallet"),j.push(" operations, contract deployment, and a development loop, on four"),j.push(" networks (undeployed, preprod, preview, stagenet). Every command speaks"),j.push(" JSON via --json for use with AI agents and scripts. An MCP"),j.push(" server ships with the package."),j.push(""),j.push(` ${z("Ledger 9 only.")} This build refuses a chain still on ledger 8`),j.push(" (preview and preprod today); use midnight-wallet-cli 0.5.x there."),j.push(` ${q("mn localnet up")} is refused too: no published indexer image runs`),j.push(" ledger 9 yet. Run a ledger-9 stack yourself and point mn at it with"),j.push(` --node / --indexer-ws / --proof-server or ${q("mn config set")}.`),j.push(""),j.push(`${z("INSTALLATION")}`),j.push(` ${q("$")} ${q("npm install -g midnight-wallet-cli@next")} ${q("# this ledger-9 prerelease")}`),j.push(` ${q("$")} ${q("npm install -g midnight-wallet-cli")} ${q("# stable 0.5.x, ledger 8")}`),j.push(""),j.push(" Optional dependencies:"),j.push(" Compact toolchain: https://docs.midnight.network/develop"),j.push(" Docker: for mn localnet (up is refused on this build)"),j.push(Q("CONCEPTS")),j.push(` ${z("Networks")}`),j.push(` ${W("undeployed")} Local network. Free dev tokens, fast iteration.`),j.push(` ${W("preprod")} Public testnet. Persistent, real ZK proofs. (Ledger 8 today: refused.)`),j.push(" Served by Blockfrost: needs your own project id (see Configuration)."),j.push(` ${W("preview")} Public testnet, smaller scale. (Ledger 8 today: refused.)`),j.push(""),j.push(` ${z("Tokens")}`),j.push(` ${H("NIGHT")} Native asset. Used for transfers and contract value.`),j.push(` ${H("DUST")} Fee token. Generated from registered NIGHT UTXOs.`),j.push(""),j.push(` ${z("Wallets")}`),j.push(` Stored at ${q("~/.midnight/wallets/<name>.json")}`),j.push(" Three networks share one seed; each gets its own derived address."),j.push(" A tip-aware cache makes repeated reads finish in seconds."),j.push(""),j.push(` ${z("Shielded vs Unshielded")}`),j.push(` ${H("Unshielded")} addresses (mn_addr_*) are like UTXOs.`),j.push(` ${H("Shielded")} addresses (mn_shield-addr_*) hide amount and recipient.`),j.push(Q("COMMANDS"));for(let D of I())j.push(C(D)),j.push("");return j.push(Q("COMMON FLOWS")),j.push(` ${z("First wallet on undeployed")}`),j.push(` ${q("# needs a ledger-9 stack you run (localnet up is refused). On the")}`),j.push(` ${q("# default ports (node 9944, indexer 8088, proof server 6300) mn finds")}`),j.push(` ${q("# it; otherwise pass --node/--indexer-ws/--proof-server or mn config set.")}`),j.push(` ${q("$")} ${q("mn wallet generate alice")}`),j.push(` ${q("$")} ${q("mn airdrop 1000 --wallet alice")}`),j.push(` ${q("$")} ${q("mn dust register --wallet alice")}`),j.push(` ${q("$")} ${q("mn balance --wallet alice")}`),j.push(""),j.push(` ${z("First wallet on preprod")} ${q("(once preprod runs ledger 9)")}`),j.push(` ${q("# once: a Midnight preprod project id from https://blockfrost.io")}`),j.push(` ${q("$")} ${q("mn config set blockfrost-project-id nightpreprod...")}`),j.push(` ${q("$")} ${q("mn wallet generate alice --network preprod")}`),j.push(` ${q("# fund from the preprod faucet:")}`),j.push(` ${q("# https://faucet.preprod.midnight.network/")}`),j.push(` ${q("$")} ${q("mn dust register --wallet alice --network preprod")}`),j.push(` ${q("$")} ${q("mn balance --wallet alice --network preprod")}`),j.push(""),j.push(` ${z("Deploy and call a contract on undeployed")}`),j.push(" Prerequisite: a compiled artifact at ./src/managed/<name>/"),j.push(""),j.push(` ${q("$")} ${q("mn contract deploy --wallet alice")}`),j.push(` ${q(" → Address: 64da9d71cb…")}`),j.push(` ${q("$")} ${q("mn contract state --address 64da9d71cb… --wallet alice")}`),j.push(` ${q(' → { "round": 0 }')}`),j.push(` ${q("$")} ${q("mn contract call --address 64da9d71cb… --circuit increment --wallet alice")}`),j.push(` ${q("$")} ${q("mn contract state --address 64da9d71cb… --wallet alice")}`),j.push(` ${q(' → { "round": 1 }')}`),j.push(""),j.push(" Same artifact on preprod — swap one flag:"),j.push(` ${q("$")} ${q("mn contract deploy --network preprod --wallet alice")}`),j.push(""),j.push(` ${z("Transfer NIGHT between wallets")}`),j.push(` ${q("$")} ${q("mn transfer bob 100 --wallet alice")}`),j.push(` ${q(" shielded variant:")}`),j.push(` ${q("$")} ${q("mn transfer bob 100 --shielded --wallet alice")}`),j.push(Q("CONFIGURATION")),j.push(` ${z("Files")}`),j.push(` ${q("~/.midnight/config.json")} Persistent CLI settings`),j.push(` ${q("~/.midnight/wallets/")} Per-wallet JSON files (mode 0600)`),j.push(` ${q("~/.midnight/cache/<network>/")} Wallet sync cache, per network`),j.push(""),j.push(` ${z("Config keys")}`),j.push(` ${H("network")} Default network when --network is omitted`),j.push(` ${H("wallet")} Default wallet when --wallet is omitted`),j.push(` ${H("proof-server")} Override proof server URL`),j.push(` ${H("node")} Override substrate RPC URL`),j.push(` ${H("indexer-ws")} Override indexer WebSocket URL`),j.push(` ${H("blockfrost-project-id")}`),j.push(" Your Blockfrost project id for preprod, whose indexer and"),j.push(" node Blockfrost serves. Kept per network, shown masked,"),j.push(" never printed. Or: MN_BLOCKFROST_PROJECT_ID / BLOCKFROST_PROJECT_ID."),j.push(` ${H("sdk-set")} The SDK set a network runs on (rc or beta), per network;`),j.push(" each network has its own (stagenet beta, the rest rc)."),j.push(""),j.push(` ${z("Compatibility alias")}`),j.push(` ${H("network-id")} Resolves transparently to ${H("network")}.`),j.push(""),j.push(` ${z("Examples")}`),j.push(` ${q("$")} ${q("mn config set network preprod")}`),j.push(` ${q("$")} ${q("mn config get network")}`),j.push(` ${q("$")} ${q("mn config unset proof-server")}`),j.push(Q("JSON OUTPUT")),j.push(` Every command accepts ${H("--json")} for structured output on stdout.`),j.push(" Stderr keeps the chrome (spinners, headers); stdout stays parseable."),j.push(""),j.push(` ${q("$")} ${q("mn balance <addr> --json | jq -r .NIGHT")}`),j.push(` ${q("$")} ${q("mn wallet info alice --json")}`),j.push(""),j.push(` Stable JSON shapes are documented in ${q("docs/JSON_CONTRACT.md")}.`),j.push(" We promise not to break those without a major version bump."),j.push(Q("EXIT CODES")),j.push(` ${R("0")} Success`),j.push(` ${q("1")} Unknown error`),j.push(` ${S("2")} Invalid arguments (usage error, see yellow message on stderr)`),j.push(` ${q("3")} Wallet not found`),j.push(` ${q("4")} Network error`),j.push(` ${q("5")} Insufficient balance / DUST_REQUIRED`),j.push(` ${q("6")} Transaction rejected / STALE_UTXO / PROOF_TIMEOUT`),j.push(` ${q("7")} Cancelled by user`),j.push(""),j.push(` ${z("Stable error code strings")} (in JSON ${H("--json")} error output), with the exit code of each:`),j.push(...K(B,H)),j.push(""),j.push(` ${z("Sets of codes")} (a command's ERRORS names those it can end with):`),j.push(...A(B,4)),j.push(Q("TROUBLESHOOTING")),j.push(` ${z('Sync hangs forever or "applied > highest" error')}`),j.push(" Stale cache after a chain reset. Recover with:"),j.push(` ${q("$")} ${q("mn cache clear --wallet <name>")}`),j.push(""),j.push(` ${z('"DUST_REQUIRED" or "no dust available" on transfer')}`),j.push(" Wallet has NIGHT but no fee token. Register dust:"),j.push(` ${q("$")} ${q("mn dust register --wallet <name>")}`),j.push(" Then wait until status shows availability:"),j.push(` ${q("$")} ${q("mn dust status --wallet <name>")}`),j.push(" A registered wallet can still be short of a fee right after paying one:"),j.push(" its NIGHT generates Dust with time. mn waits by itself when the fee is a"),j.push(" few minutes away, and otherwise says how long it takes: retry then."),j.push(""),j.push(` ${z('"Cannot find package @midnight-ntwrk/..." on contract deploy')}`),j.push(" The CLI bundles its own SDK. Reinstall to pick up the bundle:"),j.push(` ${q("$")} ${q("npm install -g midnight-wallet-cli@latest")}`),j.push(""),j.push(` ${z('"witnesses module not found" on contract deploy')}`),j.push(" Your contract declares witnesses but witnesses.js isn't built."),j.push(" Build the TypeScript source first:"),j.push(` ${q("$")} ${q("npm run build")}`),j.push(""),j.push(` ${z('"mn serve already running on port 9932 for network X"')}`),j.push(" A leftover serve from a previous network is in the way."),j.push(` ${q("$")} ${q("pkill -f 'mn serve'")}`),j.push(Q("SEE ALSO")),j.push(` ${W("mn help")} Brief command list`),j.push(` ${W("mn help <command>")} Help for one command (flags and examples)`),j.push(` ${W("mn help --agent")} Comprehensive AI / MCP reference`),j.push(""),j.push(` Repository: ${q(G.replace(/^https:\/\//,""))}`),j.push(` JSON contract: ${q("docs/JSON_CONTRACT.md")}`),j.push(""),j.join(`
11
+ `)}function R(j){return`\x1B[32m${j}\x1B[0m`}function S(j){return`\x1B[33m${j}\x1B[0m`}async function _(j,D,J){if(!J||!process.stdout.isTTY){j.stdout(D);return}let X=process.env.PAGER??"less -R",[U,...N]=X.split(/\s+/);if(!U){j.stdout(D);return}await new Promise((k)=>{let Z=O(U,N,{stdio:["pipe","inherit","inherit"]});Z.stdin.on("error",()=>{}),Z.on("close",()=>k()),Z.on("error",()=>{j.stdout(D),k()}),Z.stdin.write(D),Z.stdin.end()})}async function E(j,D){let J=!$(j,"no-pager");if($(j,"json")){D.output.result({name:V,version:F,manual:Y()});return}if($(j,"raw")){D.output.stdout(Y().replace(/\x1b\[[0-9;]*m/g,""));return}await _(D.output,Y(),J)}export{E as default,Y as buildManual};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{jb as U}from"./wallet-tdtnx9g9.js";import{kb as d,lb as p,mb as m,nb as i}from"./wallet-3bmeys56.js";import{pb as F,sb as D}from"./wallet-7m1tvbsv.js";import"./wallet-wez4z95e.js";import"./wallet-vn9pp5nm.js";import"./wallet-3qw465k0.js";import"./wallet-56gd7q8n.js";import{Server as Gz}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as qz}from"@modelcontextprotocol/sdk/server/stdio.js";import{ListToolsRequestSchema as Kz,CallToolRequestSchema as Mz,ListResourcesRequestSchema as Az,ReadResourceRequestSchema as Uz}from"@modelcontextprotocol/sdk/types.js";import{classifyError as xz}from"@kuiralabs/midnight-cli-core/lib/exit-codes";import{withNodeReason as Fz}from"@kuiralabs/midnight-cli-core/lib/sdk-errors";import{OtherSdkSetError as f}from"@kuiralabs/midnight-cli-core/lib/engine";import{networksOnSdkSet as s}from"@kuiralabs/midnight-cli-core/lib/network";function N(z){if(!(z instanceof f))return z;let B=s(z.wantedSet).join(", ");return new f(z.loadedSet,z.wantedSet,`This MCP server runs the ${z.loadedSet} SDK set, and ${B} run${B.includes(",")?"":"s"} on the ${z.wantedSet} set: two sets' ledgers can't share a process. Start another MCP server for ${B} and make the call there.`)}import{trimAgentMessage as Pz}from"@kuiralabs/midnight-cli-core/lib/error-trim";import{randomUUID as a}from"node:crypto";var o=300000;function E(z={}){let B=z.ttlMs??o,J=z.now??(()=>Date.now()),Q=new Map,X=(Z)=>{let $=0;for(let[Y,j]of Q)if(j.expiresAt<=Z)Q.delete(Y),$+=1;return $};return{create(Z){let $=J();X($);let Y=a(),j={token:Y,tool:Z.tool,args:Z.args,description:Z.description,createdAt:$,expiresAt:$+B};return Q.set(Y,j),j},redeem(Z){let $=Q.get(Z);if(!$)return null;if($.expiresAt<=J())return Q.delete(Z),null;return Q.delete(Z),$},sweep(Z=J()){return X(Z)},size(){return Q.size}}}import{UsageError as _}from"@kuiralabs/midnight-cli-core/lib/errors";function r(z,B){return Object.keys(B).filter((J)=>!Object.hasOwn(z.inputSchema.properties,J))}function w(z,B){let J=r(z,B);if(J.length===0)return;let Q=Object.keys(z.inputSchema.properties),X=Q.length===0?"It takes no parameters":`Its parameters: ${Q.join(", ")}`;throw new _(`Unknown parameter${J.length>1?"s":""} for ${z.name}: ${J.join(", ")}
3
- ${X}`)}function e(z,B){if(B===void 0||B===null)return;if(z.type==="boolean")return typeof B==="boolean"?void 0:`must be true or false, not ${JSON.stringify(B)}`;if(typeof B!=="string"&&!(typeof B==="number"&&Number.isFinite(B)))return`must be a string, not ${JSON.stringify(B)}`;if(z.enum!==void 0&&!z.enum.includes(String(B)))return`must be one of ${z.enum.join(", ")}, not ${JSON.stringify(B)}`;return}function b(z,B){let J=Object.entries(B).flatMap(([Q,X])=>{let Z=z.inputSchema.properties[Q],$=Z===void 0?void 0:e(Z,X);return $===void 0?[]:[`${Q} ${$}`]});if(J.length===0)return;throw new _(`Invalid parameter${J.length>1?"s":""} for ${z.name}: ${J.join("; ")}`)}import{MINIMAL_FLAG as T}from"@kuiralabs/midnight-cli-core/lib/argv";import{createCallContext as zz,runHandler as Bz}from"@kuiralabs/midnight-cli-core/lib/call-context";import{CommandFailedError as Jz}from"@kuiralabs/midnight-cli-core/lib/errors";var R=(z)=>{process.stderr.write(z)};async function K(z,B,{signal:J,onProgress:Q,payer:X,sdkWarnings:Z}){let $={},Y={result:(V)=>{$=JSON.parse(JSON.stringify(V))},stdout:R,stderr:R};if(B.flags.json=!0,!(T in B.flags))B.flags[T]=!0;let j=!0,H=Q===void 0?void 0:(V)=>{if(j)Q(V)};try{let V=await Z.run((t)=>Bz(z,B,zz({args:B,signal:J??new AbortController().signal,output:Y,sdkWarnings:t,...H===void 0?{}:{onProgress:H},...X===void 0?{}:{payer:X}})));if(V!==void 0&&V.exitCode!==0)throw new Jz(B.command??"the command",V.exitCode,$);return $}finally{j=!1}}import{getEndpointOverridesForNetwork as Qz,loadCliConfig as Xz}from"@kuiralabs/midnight-cli-core/lib/cli-config";import{resolveNetworkName as Zz}from"@kuiralabs/midnight-cli-core/lib/resolve-network";import{confirmationText as $z,toolArgv as M}from"@kuiralabs/midnight-cli-core/lib/command-definition";var W={name:"midnight_confirm_operation",description:"Redeem a pending token (confirm step).",inputSchema:{type:"object",properties:{token:{type:"string"}},required:["token"]},annotations:{destructiveHint:!0,openWorldHint:!0}};function O(z){return[...z.tools,W].map((B)=>({name:B.name,description:B.description,inputSchema:B.inputSchema,...B.annotations?{annotations:B.annotations}:{}}))}function A(z,B){return z.tools.find((J)=>J.name===B)}async function I(z,B,J){return K((await z.command.load()).default,M(z,B),J)}var C=[["node","node"],["indexer-ws","indexer"],["proof-server","proof server"]];function jz(z,B){let J=z.inputSchema.properties;if(!C.some(([Z])=>Object.hasOwn(J,Z)))return"";let Q=Qz(Xz(),Zz({args:M(z,B)})),X=C.flatMap(([Z,$])=>{let Y=B[Z];if(typeof Y==="string"&&Y!=="")return[`${$} ${Y}`];let j=Q[Z];return j===void 0?[]:[`${$} ${j} (set with config)`]});return X.length===0?"":`. Endpoints: ${X.join(", ")}`}async function L(z,B,J){return(await z.confirmation?.check?.(B,{argv:()=>M(z,B),run:async(X)=>K((await z.command.load()).default,X,J)})??$z(z,B))+jz(z,B)}import{needsConfirmation as fz}from"@kuiralabs/midnight-cli-core/lib/command-definition";import{assembleGuidance as h,sectionsWithAdded as S}from"@kuiralabs/midnight-cli-core/lib/agent-guidance";var Yz=["title","intent-routing","safety-rules","when-to-fetch"],Hz=["title","what-you-can-do","core-concepts","secrets","blockfrost","intent-routing","canonical-flows","safety-rules","error-recovery","networks","not-this-cli","references"],Vz=[{text:"skill-core",section:"title",order:0,body:"# midnight-wallet-cli — Agent Skill (Core)\n\nYou have access to the `midnight-wallet-cli` MCP server. This is the **core** skill — intent routing and non-negotiable safety rules. Fetch `midnight-wallet://skill/full` on demand for canonical multi-step flows, error-recovery recipes, concept primers (NIGHT, DUST, shielded vs unshielded), network selection, and deeper context.\n\n**Ledger 9 only.** This build refuses a chain still on ledger 8 (preview and preprod today; those stay on `midnight-wallet-cli` 0.5.x). The user runs a ledger-9 stack and points mn at it; details in `/full`.\n\n"},{text:"skill-core",section:"intent-routing",order:0,body:`## Intent routing (natural language → tool)
2
+ import{a as c,b as m,c as i,d as l}from"./wallet-62zj083d.js";import{h as I}from"./wallet-64nb5y33.js";import{m as F,p as V}from"./wallet-09wg5ya1.js";import{Server as Az}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Fz}from"@modelcontextprotocol/sdk/server/stdio.js";import{ListToolsRequestSchema as Pz,CallToolRequestSchema as xz,ListResourcesRequestSchema as Nz,ReadResourceRequestSchema as Ez}from"@modelcontextprotocol/sdk/types.js";import{servePayer as g}from"@kuiralabs/midnight-connect";import{classifyError as _z,asReported as Rz,trimAgentMessage as Tz,needsConfirmation as Oz}from"@kuiralabs/midnight-cli-core";import{OtherSdkSetError as x,networksOnSdkSet as t}from"@kuiralabs/midnight-cli-core";function N(z,B){if(!(z instanceof x))return z;let J=t(z.wantedSet,B).join(", ");return new x(z.loadedSet,z.wantedSet,`This MCP server runs the ${z.loadedSet} SDK set, and ${J} run${J.includes(",")?"":"s"} on the ${z.wantedSet} set: two sets' ledgers can't share a process. Start another MCP server for ${J} and make the call there.`)}import{randomUUID as o}from"node:crypto";var r=300000;function E(z={}){let B=z.ttlMs??r,J=z.now??(()=>Date.now()),Q=new Map,X=(Z)=>{let $=0;for(let[W,Y]of Q)if(Y.expiresAt<=Z)Q.delete(W),$+=1;return $};return{create(Z){let $=J();X($);let W=o(),Y={token:W,tool:Z.tool,args:Z.args,description:Z.description,createdAt:$,expiresAt:$+B};return Q.set(W,Y),Y},redeem(Z){let $=Q.get(Z);if(!$)return null;if($.expiresAt<=J())return Q.delete(Z),null;return Q.delete(Z),$},sweep(Z=J()){return X(Z)},size(){return Q.size}}}import{UsageError as _}from"@kuiralabs/midnight-cli-core";function e(z,B){return Object.keys(B).filter((J)=>!Object.hasOwn(z.inputSchema.properties,J))}function R(z,B){let J=e(z,B);if(J.length===0)return;let Q=Object.keys(z.inputSchema.properties),X=Q.length===0?"It takes no parameters":`Its parameters: ${Q.join(", ")}`;throw new _(`Unknown parameter${J.length>1?"s":""} for ${z.name}: ${J.join(", ")}
3
+ ${X}`)}function zz(z,B){if(B===void 0||B===null)return;if(z.type==="boolean")return typeof B==="boolean"?void 0:`must be true or false, not ${JSON.stringify(B)}`;if(typeof B!=="string"&&!(typeof B==="number"&&Number.isFinite(B)))return`must be a string, not ${JSON.stringify(B)}`;if(z.enum!==void 0&&!z.enum.includes(String(B)))return`must be one of ${z.enum.join(", ")}, not ${JSON.stringify(B)}`;return}function T(z,B){let J=Object.entries(B).flatMap(([Q,X])=>{let Z=z.inputSchema.properties[Q],$=Z===void 0?void 0:zz(Z,X);return $===void 0?[]:[`${Q} ${$}`]});if(J.length===0)return;throw new _(`Invalid parameter${J.length>1?"s":""} for ${z.name}: ${J.join("; ")}`)}import{MINIMAL_FLAG as O,createCallContext as Bz,runHandler as Jz,CommandFailedError as Qz}from"@kuiralabs/midnight-cli-core";var b=(z)=>{process.stderr.write(z)};async function M(z,B,{signal:J,onProgress:Q,payer:X,host:Z}){let $={},W={result:(H)=>{$=JSON.parse(JSON.stringify(H))},stdout:b,stderr:b};if(B.flags.json=!0,!(O in B.flags))B.flags[O]=!0;let Y=!0,j=Q===void 0?void 0:(H)=>{if(Y)Q(H)};try{let H=await Z.sdkWarnings.run((s)=>Jz(z,B,Bz({host:Z,args:B,signal:J??new AbortController().signal,output:W,sdkWarnings:s,...j===void 0?{}:{onProgress:j},...X===void 0?{}:{payer:X}})));if(H!==void 0&&H.exitCode!==0)throw new Qz(B.command??"the command",H.exitCode,$);return $}finally{Y=!1}}import{getEndpointOverridesForNetwork as Xz,loadCliConfig as Zz,resolveNetworkName as $z,commandOwnCodes as Yz,confirmationText as jz,declaredSets as Wz,toolArgv as U}from"@kuiralabs/midnight-cli-core";var D={name:"midnight_confirm_operation",description:"Redeem a pending token (confirm step).",inputSchema:{type:"object",properties:{token:{type:"string"}},required:["token"]},annotations:{destructiveHint:!0,openWorldHint:!0}};function Hz(z,B){let J=Yz(z,B.command).map((Z)=>Z.code),Q=Wz(B.command).map((Z)=>Z.name);if(J.length===0&&Q.length===0)return B.description;let X=Q.length===0?"":`the ${I(Q)} codes (see the skill)`;return`${B.description} Errors: ${J.join(", ")}${J.length>0&&X!==""?"; and ":""}${X}.`}function L(z){return[...z.tools.map((B)=>({...B,description:Hz(z,B)})),D].map((B)=>({name:B.name,description:B.description,inputSchema:B.inputSchema,...B.annotations?{annotations:B.annotations}:{}}))}function A(z,B){return z.tools.find((J)=>J.name===B)}async function f(z,B,J){return M((await z.command.load()).default,U(z,B),J)}var C=[["node","node"],["indexer-ws","indexer"],["proof-server","proof server"]];function Vz(z,B,J){let Q=z.inputSchema.properties;if(!C.some(([$])=>Object.hasOwn(Q,$)))return"";let X=Xz(Zz(J),$z({args:U(z,B),configDir:J})),Z=C.flatMap(([$,W])=>{let Y=B[$];if(typeof Y==="string"&&Y!=="")return[`${W} ${Y}`];let j=X[$];return j===void 0?[]:[`${W} ${j} (set with config)`]});return Z.length===0?"":`. Endpoints: ${Z.join(", ")}`}async function w(z,B,J){return(await z.confirmation?.check?.(B,{host:J.host,argv:()=>U(z,B),run:async(X)=>M((await z.command.load()).default,X,J)})??jz(z,B))+Vz(z,B,J.host.paths().stateRoot)}import{assembleGuidance as S,sectionsWithAdded as v,declaredCodeSets as Dz}from"@kuiralabs/midnight-cli-core";var Gz=["title","intent-routing","safety-rules","when-to-fetch"],qz=["title","what-you-can-do","core-concepts","secrets","blockfrost","intent-routing","canonical-flows","safety-rules","error-recovery","networks","not-this-cli","references"],Kz=[{text:"skill-core",section:"title",order:0,body:"# midnight-wallet-cli — Agent Skill (Core)\n\nYou have access to the `midnight-wallet-cli` MCP server. This is the **core** skill — intent routing and non-negotiable safety rules. Fetch `midnight-wallet://skill/full` on demand for canonical multi-step flows, error-recovery recipes, concept primers (NIGHT, DUST, shielded vs unshielded), network selection, and deeper context.\n\n**Ledger 9 only.** This build refuses a chain still on ledger 8 (preview and preprod today; those stay on `midnight-wallet-cli` 0.5.x). The user runs a ledger-9 stack and points mn at it; details in `/full`.\n\n"},{text:"skill-core",section:"intent-routing",order:0,body:`## Intent routing (natural language → tool)
4
4
 
5
5
  | User says | Call this tool |
6
6
  |---|---|
@@ -44,12 +44,18 @@ Every MCP tool error returns \`{ error: true, code: <ERROR_CODE>, message: <huma
44
44
  - Not a custody service. Keys are on the user's disk (\`~/.midnight/wallets/<name>.json\`).
45
45
  - Not an instant-sync tool for a first-time wallet on a hosted network. First run replays the chain's event history; the CLI caches state after that so repeat runs are fast.
46
46
  `},{text:"skill-full",section:"not-this-cli",order:1000,body:`
47
- `},{text:"skill-full",section:"references",order:0,body:"## Authoritative references\n\n- `mn help <command>` — per-command usage and flags.\n- `mn help --agent` — structured reference manual for AI clients.\n- `mn help --json` — every command's usage, flags and JSON fields, as JSON.\n"}],Dz=(z)=>z.tools.filter((B)=>B.confirmation!==void 0).map((B)=>`\`${B.name}\``).join(", ");function Wz(z){let B=`- **Some tools use a two-step confirmation token**: ${Dz(z)}. The first call returns a pending token + description and does nothing else; show the description verbatim, and call \`midnight_confirm_operation({ token })\` only after the user explicitly says yes. (\`midnight_wallet_generate\` asks only with \`force: true\`, which replaces a wallet.)`,J=z.commands.filter((Q)=>Q.help!==void 0&&(Q.mcp?.tools.length??0)===0).map((Q)=>`\`mn ${Q.name}\``);return[{text:"skill-core",section:"safety-rules",order:500,body:`${B} Full flow in \`midnight-wallet://skill/full\`.
47
+ `},{text:"skill-full",section:"references",order:0,body:"## Authoritative references\n\n- `mn help <command>` — per-command usage and flags.\n- `mn help --agent` — structured reference manual for AI clients.\n- `mn help --json` — every command's usage, flags and JSON fields, as JSON.\n"}],Mz=(z)=>z.tools.filter((B)=>B.confirmation!==void 0).map((B)=>`\`${B.name}\``).join(", ");function Uz(z){let B=`- **Some tools use a two-step confirmation token**: ${Mz(z)}. The first call returns a pending token + description and does nothing else; show the description verbatim, and call \`midnight_confirm_operation({ token })\` only after the user explicitly says yes. (\`midnight_wallet_generate\` asks only with \`force: true\`, which replaces a wallet.)`,J=z.commands.filter((Q)=>Q.help!==void 0&&(Q.mcp?.tools.length??0)===0).map((Q)=>`\`mn ${Q.name}\``);return[{text:"skill-core",section:"safety-rules",order:500,body:`${B} Full flow in \`midnight-wallet://skill/full\`.
48
48
 
49
49
  `},{text:"skill-full",section:"safety-rules",order:500,body:`${B}
50
50
 
51
- `},{text:"skill-full",section:"what-you-can-do",order:1000,body:`
51
+ `},{text:"skill-full",section:"error-recovery",order:999,body:`
52
+ A tool's description ends with the codes it can fail with: its own, and sets of them by name. The sets:
53
+
54
+ | Set | Codes |
55
+ |---|---|
56
+ ${Dz(z).map((Q)=>`| ${Q.name} | ${Q.codes.map((X)=>`\`${X}\``).join(", ")} |
57
+ `).join("")}`},{text:"skill-full",section:"what-you-can-do",order:1000,body:`
52
58
  Most commands are MCP tools (\`tools/list\` shows each, and what it takes). ${J.length===0?"":`These have none, and the user runs them in their own terminal: ${J.join(", ")}; some subcommands have none either.`}
53
59
 
54
- `}]}function v(z){return[...Vz,...Wz(z),...z.packages.flatMap((B)=>B.guidance.pieces)]}var k=(z)=>z.packages.flatMap((B)=>B.guidance.sections??[]);function y(z){return h("skill-core",S("skill-core",Yz,k(z)),v(z))}function u(z){return h("skill-full",S("skill-full",Hz,k(z)),v(z))}var l="midnight-wallet://skill/core",n="midnight-wallet://skill/full",Nz="midnight-wallet://skill",c=E(),x=null,q=new Gz({name:"midnight-wallet-cli",version:F},{capabilities:{tools:{},resources:{}}});q.setRequestHandler(Az,async()=>({resources:[{uri:l,name:"midnight-wallet skill (core)",description:"Read this first. Intent routing table + non-negotiable safety rules. ~830 tokens. Fetch /full on demand for canonical flows, error recovery, and concept primers.",mimeType:"text/markdown"},{uri:n,name:"midnight-wallet skill (full)",description:"Canonical multi-step flows, error-recovery recipes, concept primers (NIGHT/DUST/shielded), network selection. Fetch on demand when you hit an error, start a multi-step flow, or need to explain a concept.",mimeType:"text/markdown"}]}));q.setRequestHandler(Uz,async(z)=>{let B=z.params.uri;if(B===l){let J=y(D);return{contents:[{uri:B,mimeType:"text/markdown",text:J}]}}if(B===n||B===Nz){let J=u(D);return{contents:[{uri:B,mimeType:"text/markdown",text:J}]}}throw Error(`Unknown resource: ${B}`)});q.setRequestHandler(Kz,async()=>({tools:O(D)}));q.setRequestHandler(Mz,async(z,B)=>{let{name:J,arguments:Q}=z.params,X=Q??{},Z=Ez(z.params._meta?.progressToken,B),$=A(D,J),Y=J===W.name?W:$;if(Y!==void 0)try{w(Y,X),b(Y,X)}catch(j){return G(j instanceof Error?j:Error(String(j)))}if(J===W.name){let j=typeof X.token==="string"?X.token:"",H=c.redeem(j);if(!H)return G(Error("Unknown or expired confirmation token. The first-step tool call may need to be re-issued."));return g(H.tool,H.args,Z)}if($!==void 0&&fz($,X)){let j;try{j=await L($,X,Z)}catch(V){return G(V instanceof Error?V:Error(String(V)))}let H=c.create({tool:J,args:X,description:j});return{content:[{type:"text",text:JSON.stringify(P({pending:!0,token:H.token,description:H.description,tool:H.tool,expiresAt:new Date(H.expiresAt).toISOString(),nextStep:"Show the description to the user, get explicit consent, then call midnight_confirm_operation with this token."}),null,2)}]}}return g(J,X,Z)});function Ez(z,B){if(x===null)throw Error("The MCP server took a call before its host was installed");let{sdkWarnings:J}=x;if(z===void 0)return{signal:B.signal,payer:U,sdkWarnings:J};let Q=0,X;return{signal:B.signal,payer:U,sdkWarnings:J,onProgress:(Z)=>{if(Z===X)return;X=Z,Q+=1,B.sendNotification({method:"notifications/progress",params:{progressToken:z,progress:Q,message:Z}}).catch(()=>{})}}}function P(z){return{...z,_serverVersion:F}}async function g(z,B,J){let Q=A(D,z);if(!Q)return G(Error(`Unknown tool: ${z}`));try{let X=await I(Q,B,J);return{content:[{type:"text",text:JSON.stringify(P(X),null,2)}]}}catch(X){return G(X instanceof Error?X:Error(String(X)))}}function G(z){let B=N(Fz(z)),{errorCode:J}=xz(B);return{content:[{type:"text",text:JSON.stringify(P({error:!0,code:J,message:Pz(B.message)}))}],isError:!0}}async function _z(){p(),m(),x=i(),await d();let z=new qz;await q.connect(z)}_z().catch((z)=>{process.stderr.write(`MCP server error: ${z.message}
60
+ `}]}function k(z){return[...Kz,...Uz(z),...z.packages.flatMap((B)=>B.guidance.pieces)]}var y=(z)=>z.packages.flatMap((B)=>B.guidance.sections??[]);function h(z){return S("skill-core",v("skill-core",Gz,y(z)),k(z))}function u(z){return S("skill-full",v("skill-full",qz,y(z)),k(z))}var n="midnight-wallet://skill/core",a="midnight-wallet://skill/full",bz="midnight-wallet://skill",p=E(),K=null,q=new Az({name:"midnight-wallet-cli",version:F},{capabilities:{tools:{},resources:{}}});q.setRequestHandler(Nz,async()=>({resources:[{uri:n,name:"midnight-wallet skill (core)",description:"Read this first. Intent routing table + non-negotiable safety rules. ~830 tokens. Fetch /full on demand for canonical flows, error recovery, and concept primers.",mimeType:"text/markdown"},{uri:a,name:"midnight-wallet skill (full)",description:"Canonical multi-step flows, error-recovery recipes, concept primers (NIGHT/DUST/shielded), network selection. Fetch on demand when you hit an error, start a multi-step flow, or need to explain a concept.",mimeType:"text/markdown"}]}));q.setRequestHandler(Ez,async(z)=>{let B=z.params.uri;if(B===n){let J=h(V);return{contents:[{uri:B,mimeType:"text/markdown",text:J}]}}if(B===a||B===bz){let J=u(V);return{contents:[{uri:B,mimeType:"text/markdown",text:J}]}}throw Error(`Unknown resource: ${B}`)});q.setRequestHandler(Pz,async()=>({tools:L(V)}));q.setRequestHandler(xz,async(z,B)=>{let{name:J,arguments:Q}=z.params,X=Q??{},Z=Cz(z.params._meta?.progressToken,B),$=A(V,J),W=J===D.name?D:$;if(W!==void 0)try{R(W,X),T(W,X)}catch(Y){return G(Y instanceof Error?Y:Error(String(Y)),Z)}if(J===D.name){let Y=typeof X.token==="string"?X.token:"",j=p.redeem(Y);if(!j)return G(Error("Unknown or expired confirmation token. The first-step tool call may need to be re-issued."),Z);return d(j.tool,j.args,Z)}if($!==void 0&&Oz($,X)){let Y;try{Y=await w($,X,Z)}catch(H){return G(H instanceof Error?H:Error(String(H)),Z)}let j=p.create({tool:J,args:X,description:Y});return{content:[{type:"text",text:JSON.stringify(P({pending:!0,token:j.token,description:j.description,tool:j.tool,expiresAt:new Date(j.expiresAt).toISOString(),nextStep:"Show the description to the user, get explicit consent, then call midnight_confirm_operation with this token."}),null,2)}]}}return d(J,X,Z)});function Cz(z,B){if(K===null)throw Error("The MCP server took a call before its host was installed");if(z===void 0)return{signal:B.signal,payer:g,host:K};let J=0,Q;return{signal:B.signal,payer:g,host:K,onProgress:(X)=>{if(X===Q)return;Q=X,J+=1,B.sendNotification({method:"notifications/progress",params:{progressToken:z,progress:J,message:X}}).catch(()=>{})}}}function P(z){return{...z,_serverVersion:F}}async function d(z,B,J){let Q=A(V,z);if(!Q)return G(Error(`Unknown tool: ${z}`),J);try{let X=await f(Q,B,J);return{content:[{type:"text",text:JSON.stringify(P(X),null,2)}]}}catch(X){return G(X instanceof Error?X:Error(String(X)),J)}}function G(z,B){let J=N(Rz(z),B.host.paths().stateRoot),{errorCode:Q}=_z(J,V);return{content:[{type:"text",text:JSON.stringify(P({error:!0,code:Q,message:Tz(J.message)}))}],isError:!0}}async function Iz(){m(),i(),K=l({prompter:null}),await c();let z=new Fz;await q.connect(z)}Iz().catch((z)=>{process.stderr.write(`MCP server error: ${z.message}
55
61
  `),process.exit(1)});
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as c}from"node:module";var e=c(import.meta.url);var t={name:"midnight-wallet-cli",version:"0.6.0-rc.13",type:"module",description:"Git-style CLI wallet for the Midnight blockchain",license:"Apache-2.0",author:"Norman Lopez (https://github.com/nel349)",homepage:"https://github.com/kuiralabs/midnight-cli#readme",repository:{type:"git",url:"git+https://github.com/kuiralabs/midnight-cli.git"},bugs:{url:"https://github.com/kuiralabs/midnight-cli/issues"},keywords:["midnight","blockchain","wallet","cli","zk","zero-knowledge","compact","mcp","ai-agent"],workspaces:["packages/connector","packages/cli-core","packages/chain","packages/engine-rc","packages/engine-beta","packages/wallet","packages/contract","packages/connect","packages/dev","packages/grant"],bin:{midnight:"dist/wallet.js",mn:"dist/wallet.js","midnight-wallet-cli":"dist/wallet.js","midnight-wallet-mcp":"dist/mcp-server.js"},files:["dist","docs/SKILL.md","docs/SKILL-CORE.md","NOTICE","npm-shrinkwrap.json"],engines:{node:">=22",bun:">=1.3.0"},scripts:{wallet:"tsx --conditions=midnight-cli-source src/wallet.ts",build:`npm run build -w @kuiralabs/midnight-cli-core && npm run build -w @kuiralabs/midnight-chain && npm run build -w @kuiralabs/midnight-engine-rc && npm run build -w @kuiralabs/midnight-engine-beta && npm run build -w @kuiralabs/midnight-wallet && npm run build -w @kuiralabs/midnight-contract && npm run build -w @kuiralabs/midnight-connect && npm run build -w @kuiralabs/midnight-dev && npm run build -w @kuiralabs/midnight-grant && node -e "require('fs').rmSync('dist', { recursive: true, force: true })" && bun build src/wallet.ts src/mcp-server.ts --outdir dist --splitting --target node --format esm --packages external --minify --banner "#!/usr/bin/env node"`,mcp:"tsx --conditions=midnight-cli-source src/mcp-server.ts",link:"bun link",prepublishOnly:"npm run build && npm run test",test:"vitest run","test:rc":"vitest run --exclude '**/src/__tests__/engine-beta*.test.ts' --exclude 'packages/engine-beta/**'","test:beta":"vitest run src/__tests__/engine-beta packages/engine-beta","test:live":"vitest run --config vitest.live.config.ts","test:watch":"vitest","api-report":"node scripts/api-report.mjs write",typecheck:"tsc --noEmit","skill-docs":"tsx --conditions=midnight-cli-source scripts/write-skill-docs.ts","readme-commands":"tsx --conditions=midnight-cli-source scripts/write-readme-commands.ts"},dependencies:{"@kuiralabs/midnight-chain":"0.1.0-rc.2","@kuiralabs/midnight-cli-core":"0.1.0-rc.2","@kuiralabs/midnight-connect":"0.1.0-rc.2","@kuiralabs/midnight-contract":"0.1.0-rc.2","@kuiralabs/midnight-dev":"0.1.0-rc.2","@kuiralabs/midnight-engine-beta":"0.1.0-rc.2","@kuiralabs/midnight-engine-rc":"0.1.0-rc.2","@kuiralabs/midnight-grant":"0.1.0-rc.2","@kuiralabs/midnight-wallet":"0.1.0-rc.2","@modelcontextprotocol/sdk":"^1.27.1"},devDependencies:{"@midnightntwrk/dapp-connector-api":"4.1.0-beta.1","@types/node":"^22.19.13","@types/ws":"^8.18.1",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^3.2.4"},overrides:{"@midnightntwrk/wallet-sdk-node-client@2.0.0-beta.2":"2.0.0-beta.4"}};var f=t.name,D=t.version,tt=t.description,st=t.repository.url.replace(/^git\+/,"").replace(/\.git$/,"");import{getValidNetworkNames as m,createPackageRegistry as d}from"@kuiralabs/midnight-cli-core";import{configDefinition as u,coreGuidance as g,coreCodes as b}from"@kuiralabs/midnight-cli-core/commands";import{walletDefinition as p,generateDefinition as h,infoDefinition as k,balanceDefinition as w,addressDefinition as o,genesisAddressDefinition as v,airdropDefinition as y,transferDefinition as x,dustDefinition as j,cacheDefinition as I,swapDefinition as z,walletGuidance as q,swapGuidance as M,walletCodes as J}from"@kuiralabs/midnight-wallet/commands";import{inspectCostDefinition as K,contractDefinition as Q,contractGuidance as U,contractCodes as X}from"@kuiralabs/midnight-contract/commands";import{serveDefinition as Y,connectGuidance as Z}from"@kuiralabs/midnight-connect/commands";import{testDefinition as $,devDefinition as _,localnetDefinition as B,devGuidance as F,devCodes as P}from"@kuiralabs/midnight-dev/commands";import{grantDefinition as T,grantGuidance as O,grantCodes as V}from"@kuiralabs/midnight-grant/commands";import{statusDefinition as C,txDefinition as H,chainGuidance as N,chainCodes as W}from"@kuiralabs/midnight-chain/commands";import{RESOLVES_NETWORK as a}from"@kuiralabs/midnight-cli-core/commands";var i={name:"help",order:200,flags:[{name:"agent",takesValue:!1},{name:"intro",takesValue:!1},{name:"no-intro",takesValue:!1}],help:{description:"Show usage for all commands or a specific command",usage:"midnight help [command]",examples:["midnight help","midnight help balance"],jsonFields:{cli:"CLI metadata (name, version, description)",globalFlags:"Array of global flag descriptions",commands:"Array of command specs with jsonFields"}},intro:{brief:"Show command usage",order:18},needsWalletSdk:!1,shell:{},errors:{codes:[a]},load:()=>import("./help-7qyfwsje.js")};import{RESOLVES_NETWORK as n}from"@kuiralabs/midnight-cli-core/commands";var r={name:"manual",order:210,flags:[{name:"no-pager",takesValue:!1,help:["--no-pager Print straight to stdout, do not pipe through less"]},{name:"raw",takesValue:!1,help:["--raw Strip ANSI colors (useful for piping to a file)"]}],help:{description:"Full reference manual (long form, paged through $PAGER)",usage:"midnight manual [--no-pager] [--raw] [--json]",flags:[{flag:"no-pager"},{flag:"raw"},"--json Emit the manual text wrapped in a JSON object"],examples:["midnight manual","midnight manual --no-pager | grep -i dust","midnight manual --raw > MANUAL.txt"],jsonFields:{name:"CLI package name",version:"CLI version",manual:"Manual text (with ANSI colors)"}},intro:{brief:"Full reference manual",order:19},needsWalletSdk:!1,shell:{},errors:{codes:[n]},load:()=>import("./manual-qb6qctpp.js")};var s={notForAgents:"the shell answers it before any command runs"},A=[{name:"help",takesValue:!1,agent:s},{name:"h",takesValue:!1,agent:s},{name:"json",takesValue:!1,agent:{notForAgents:"the MCP server always sets it"}},{name:"version",takesValue:!1,agent:s},{name:"v",takesValue:!1,agent:s}],R=[{name:"--json",description:"Output structured JSON to stdout (suppresses all stderr)"},{name:"--wallet <name|file>",description:"Wallet name or path"},{name:"--network <name>",description:`Override network (${m().join(", ")})`},{name:"--version, -v",description:"Print CLI version"},{name:"--help, -h",description:"Show help"}],wt=d([{name:"core",commands:[u],guidance:g,codes:b},{name:"chain",commands:[C,H],guidance:N,codes:W},{name:"wallet",commands:[p,h,k,w,o,v,y,x,j,I],guidance:q,codes:J},{name:"contract",commands:[K,Q],guidance:U,codes:X},{name:"connect",commands:[Y],guidance:Z},{name:"swap",commands:[z],guidance:M},{name:"dev",commands:[$,_,B],guidance:F,codes:P},{name:"grant",commands:[T],guidance:O,codes:V},{name:"shell",commands:[i,r],guidance:{pieces:[]}}],A,R);
3
+ export{e as k,f as l,D as m,tt as n,st as o,wt as p};
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env node
2
+ import{i as l,j as u}from"./wallet-64nb5y33.js";import{l as a,m as O,n,p as G}from"./wallet-09wg5ya1.js";import{hasFlag as j,commandHelpSpecs as xq,introBriefs as t,UsageError as vq}from"@kuiralabs/midnight-cli-core";import{bold as Hq,teal as Gq,gray as _,dim as A,header as Aq}from"@kuiralabs/midnight-cli-core/ui";import{teal as Sq,white as x,purple as yq,green as Mq,bold as I,dim as Rq,isColorEnabled as w}from"@kuiralabs/midnight-cli-core/ui";var P=[" ████████████ "," ███ ███ "," ███ ██ ███ "," ██ ██ "," ██ ██ ██ "," ██ ██ "," ██ ██ ██ "," ██ ██ "," ██ ██ "," ██ ██ "," ██ ██ "," ███ ███ "," ███ ███ "," ████████████ "].join(`
3
+ `);var H=["█▄ ▄█ █ █▀▄ █▄ █ █ █▀▀ █ █ ▀█▀","█ █ █ █ █ █ █ ██ █ █ █ █▀█ █ ","▀ ▀ ▀ ▀▀ ▀ ▀ ▀ ▀▀▀ ▀ ▀ ▀ "];function f(q){let X=Math.max(0,Math.min(1,q)),Q=H[0].length,$=Math.floor(X*Q);return H.map((Y)=>Y.slice(0,$).padEnd(Q))}function C(q){let X=Math.max(0,Math.min(1,q)),Q=Math.floor(q*100);if(X>=1)return H;return H.map(($,Y)=>Array.from($).map((V,K)=>{if(V===" ")return" ";if(X<=0)return F(Y+20,K,0);let z=((Y+20)*131+K*997)%100/100;return X>=z?V:F(Y+20,K,Q)}).join(""))}var R=["░","▒","▓","█","·"," "];function F(q,X,Q){let $=(q*131+X*997+Q*7919)%65537/65537;return R[Math.floor($*R.length)]}function L(q){let X=Math.max(0,Math.min(1,q)),Q=P.split(`
4
+ `),$=Math.floor(q*100);if(X>=1)return P;if(X<=0)return Q.map((Y,V)=>Array.from(Y).map((K,z)=>F(V,z,0)).join("")).join(`
5
+ `);return Q.map((Y,V)=>Array.from(Y).map((K,z)=>{if(K===" ")return" ";let J=(V*131+z*997)%100/100;return X>=J?K:F(V,z,$)}).join("")).join(`
6
+ `)}var S=80;function y(q,X){return new Promise((Q,$)=>{if(X?.aborted){Q();return}let Y=setTimeout(Q,q);X?.addEventListener("abort",()=>{clearTimeout(Y),Q()},{once:!0})})}async function h(q,X,Q){let Y=P.split(`
7
+ `),V=Y.length,K=36,z=Math.max(V,X?.length??0),J=3,T=Q?.animated??!0;if(!w()||!T){let Z=w();for(let D=0;D<z;D++){let U=D<V?Y[D]:"",N=Z?x(U).padEnd(45):U.padEnd(35),W=X?.[D]??"",E=Z&&D<3&&W?I(x(W)):W;if(Z)process.stderr.write(U?x(U)+"\x1B[36G"+E+`
8
+ `:"\x1B[36G"+E+`
9
+ `);else process.stderr.write(N+E+`
10
+ `)}return}function B(Z,D){for(let U=0;U<z;U++){let N=U<Z.length?x(Z[U]):"",W=D[U]??"";if(W)process.stderr.write(N+"\x1B[36G"+W+`\x1B[K
11
+ `);else process.stderr.write(N+`\x1B[K
12
+ `)}}function v(){process.stderr.write(`\x1B[${z}A`)}for(let Z=0;Z<=20;Z++){if(q?.aborted)break;let D=Z/20,N=L(D).split(`
13
+ `);if(Z>0)v();B(N,[]),await y(S,q)}let M=20;for(let Z=0;Z<=M;Z++){if(q?.aborted)break;let D=Z/M,U=f(D);v();let N=Array(z).fill(null);for(let W=0;W<U.length;W++)N[W]=I(x(U[W]));B(Y,N),await y(S,q)}let b=12;for(let Z=0;Z<=b;Z++){if(q?.aborted)break;let D=Z/b,U=C(D);v();let N=Array(z).fill(null);for(let W=0;W<U.length;W++)N[W]=I(x(U[W]));B(Y,N),await y(S,q)}v();let k=Array(z).fill(null);if(X)for(let Z=0;Z<X.length;Z++)if(Z<3)k[Z]=I(x(X[Z]));else k[Z]=X[Z];B(Y,k)}import{GuidanceError as r,assembleGuidance as i,sectionsWithAdded as s,commandHelpSpecs as e}from"@kuiralabs/midnight-cli-core";var qq=["overview","json-schemas","shielded-transactions","wallet-name-resolution","dapp-connector","smart-contracts","grants","e2e-testing","error-codes","mcp-server","mcp-tools","tool-annotations","two-step-confirmation","mcp-resources","typical-workflows","example-commands"],Qq=[{id:"wallet-management",title:"Wallet Management",width:53},{id:"balance-info",title:"Balance & Info",width:53},{id:"transactions",title:"Transactions",width:53},{id:"consent",title:"Consent",width:53},{id:"configuration",title:"Configuration",width:53},{id:"local-network",title:"Local Network",width:53},{id:"contracts",title:"Contracts (Compact smart contracts)",width:52},{id:"test-framework",title:"Test Framework",width:52},{id:"grants",title:"Grants (experimental)",width:53},{id:"swaps",title:"Swaps (experimental)",width:53}],m={id:"other",title:"Other",width:53},Xq={tool:"midnight_confirm_operation",group:"consent",order:10,description:["Redeem a pending token returned by a destructive","tool (step 2 of the confirmation flow)"],params:["token"]},Yq=29;function Zq(){return{text:"agent-manual",section:"overview",order:0,body:`
14
+ MIDNIGHT CLI — AI Agent & MCP Reference
15
+ ========================================
16
+
17
+ Version: ${O}
18
+
19
+ OVERVIEW
20
+ ────────
21
+
22
+ midnight-wallet-cli (mn) is a standalone CLI wallet for the Midnight
23
+ blockchain. It manages wallets, balances, transfers (unshielded and
24
+ shielded), dust fees, a DApp connector server, contract inspection,
25
+ E2E testing, and a local devnet — all from the terminal.
26
+
27
+ Wallets are network-agnostic: one seed derives addresses for all four
28
+ networks (undeployed, preprod, preview, stagenet). Network is chosen at
29
+ runtime. Stagenet is Sig Network's chain on the beta SDK set; mn runs it
30
+ through its own engine, picked by the network.
31
+
32
+ Preprod's indexer and node are served by Blockfrost (Midnight shut its own
33
+ preprod indexer down on 2026-10-09). Every request needs the user's own
34
+ project id, from a Midnight preprod project at https://blockfrost.io:
35
+ midnight config set blockfrost-project-id <project id>
36
+ or MN_BLOCKFROST_PROJECT_ID (or BLOCKFROST_PROJECT_ID) in the environment.
37
+ Without one, a command that
38
+ reaches preprod fails with BLOCKFROST_PROJECT_ID_REQUIRED. The project id is
39
+ a secret: mn never prints it. Preview and undeployed need none.
40
+
41
+ LEDGER 9 ONLY: this build of mn speaks ledger 9 only. A chain still on
42
+ ledger 8 (preview and preprod today) is refused up front with an
43
+ error saying so; use midnight-wallet-cli 0.5.x for those. localnet up
44
+ is refused too (no published ledger-9 indexer image yet): run a ledger-9
45
+ stack yourself and point mn at it with --node / --indexer-ws /
46
+ --proof-server, or once with midnight config set node|indexer-ws|proof-server.
47
+
48
+ STRUCTURED JSON OUTPUT
49
+ ──────────────────────
50
+
51
+ Every command supports --json. When passed:
52
+ - stdout receives a single line of JSON
53
+ - stderr is fully suppressed (no spinners, no formatting)
54
+ - Errors: {"error":true,"code":"...","message":"...","exitCode":N}
55
+
56
+ Usage: midnight <command> [args] --json
57
+
58
+ CAPABILITY MANIFEST
59
+ ───────────────────
60
+
61
+ midnight help --json
62
+
63
+ Outputs a machine-readable manifest with all commands, flags,
64
+ examples, and JSON field schemas.
65
+
66
+ `}}function $q(q){return{text:"agent-manual",section:"json-schemas",order:0,body:`COMMANDS & JSON SCHEMAS
67
+ ───────────────────────
68
+ ${e(q).filter((Q)=>Q.jsonFields).map((Q)=>{let $=Object.entries(Q.jsonFields).map(([Y,V])=>` ${Y.padEnd(20)}${V}`).join(`
69
+ `);return`
70
+ ${Q.name}
71
+ ${Q.usage}
72
+ Error codes: ${Q.ownCodes.map((Y)=>Y.code).join(", ")||"none"}; sets: ${Q.errorSets.join(", ")||"none"}
73
+ JSON fields:
74
+ ${$}`}).join(`
75
+ `)}
76
+
77
+ `}}function Jq(q,X,Q){let $=q.params??[Q?.required?.length?Q.required.join(", "):"—"];return Array.from({length:Math.max(q.description.length,$.length)},(Y,V)=>{let K=(V===0?q.tool:"").padEnd(Yq),z=q.description[V]??"";return $[V]===void 0?` ${K}${z}`:` ${K}${z.padEnd(X)}${$[V]}`})}function Vq(q){let X=new Map(q.packages.flatMap((J)=>J.guidance.toolsTable??[]).map((J)=>[J.tool,J])),Q=[Xq,...q.tools.map((J,T)=>X.get(J.name)??{tool:J.name,group:m.id,order:T,description:[J.description]})],$=[...Qq,m];for(let J of Q)if(!$.some((T)=>T.id===J.group))throw new r(`${J.tool}'s row names tools table group "${J.group}", which the manual lacks`);let Y=new Map(q.tools.map((J)=>[J.name,J])),V=$.flatMap((J)=>{let T=Q.filter((B)=>B.group===J.id).sort((B,v)=>B.order-v.order);if(T.length===0)return[];return[` ${J.title}
78
+ ${T.flatMap((B)=>Jq(B,J.width,Y.get(B.tool))).map((B)=>`${B}
79
+ `).join("")}`]}),K=`AVAILABLE MCP TOOLS (${Q.length})`;return{text:"agent-manual",section:"mcp-tools",order:0,body:`${K}
80
+ ${"─".repeat(K.length)}
81
+
82
+ ${V.join(`
83
+ `)}
84
+ Optional params shared by wallet tools: wallet, network.
85
+ All tools return JSON. Every response carries _serverVersion so a stale
86
+ MCP server (CLI on disk says X, responses still say Y) is detectable.
87
+ Errors: {error, code, message, _serverVersion}.
88
+
89
+ `}}var zq=[{text:"agent-manual",section:"error-codes",order:0,body:`ERROR CODES
90
+ ───────────
91
+
92
+ Code Exit Meaning
93
+ `},{text:"agent-manual",section:"error-codes",order:1000,body:`
94
+ `},{text:"agent-manual",section:"mcp-server",order:0,body:`MCP SERVER
95
+ ──────────
96
+
97
+ The CLI includes an MCP (Model Context Protocol) server for native
98
+ AI agent integration. Agents call typed tools directly via JSON-RPC
99
+ over stdio — no shell spawning or output parsing.
100
+
101
+ Setup:
102
+
103
+ Claude Code (.mcp.json):
104
+ { "mcpServers": { "midnight-wallet": { "command": "midnight-wallet-mcp" } } }
105
+
106
+ CLI: claude mcp add --transport stdio midnight-wallet -- midnight-wallet-mcp
107
+
108
+ Cursor (.cursor/mcp.json):
109
+ { "mcpServers": { "midnight-wallet": { "command": "midnight-wallet-mcp" } } }
110
+
111
+ VS Code (.vscode/mcp.json):
112
+ { "servers": { "midnight-wallet": { "type": "stdio", "command": "midnight-wallet-mcp" } } }
113
+
114
+ If not installed globally, use "command": "npx" with
115
+ "args": ["-y", "midnight-wallet-cli@latest", "--mcp"].
116
+
117
+ `},{text:"agent-manual",section:"tool-annotations",order:0,body:`TOOL ANNOTATIONS (MCP safety hints)
118
+ ───────────────────────────────────
119
+
120
+ Every tool carries MCP-spec annotations so clients can apply safety policy
121
+ without hardcoding per-tool rules:
122
+
123
+ readOnlyHint Safe to call without user consent (balance, info, list).
124
+ destructiveHint Moves funds, deletes files, or tears down infra — treat
125
+ as requiring user consent.
126
+ idempotentHint Repeated calls with same args yield the same result.
127
+ openWorldHint Touches the network / chain / Docker — can fail
128
+ non-deterministically.
129
+
130
+ `},{text:"agent-manual",section:"two-step-confirmation",order:0,body:`TWO-STEP CONFIRMATION FLOW
131
+ ──────────────────────────
132
+
133
+ midnight_transfer does NOT execute on the first call. It returns a pending
134
+ token that the agent must show to the user for consent, then redeem via
135
+ midnight_confirm_operation to actually execute.
136
+
137
+ Call 1: midnight_transfer({ to, amount, wallet, network })
138
+ → { pending: true, token, description, expiresAt, nextStep }
139
+ Show: the description to the user verbatim.
140
+ Call 2: midnight_confirm_operation({ token })
141
+ → actual transfer result (txHash, etc)
142
+
143
+ Tokens are single-use and expire after 5 minutes.
144
+
145
+ `},{text:"agent-manual",section:"two-step-confirmation",order:20,body:`Every tool that moves funds, changes an account or deletes a seed works
146
+ the same way (midnight_wallet_generate only with force: true):
147
+
148
+ `},{text:"agent-manual",section:"mcp-resources",order:0,body:`MCP RESOURCES (skill files)
149
+ ───────────────────────────
150
+
151
+ The server exposes two MCP Resources — a small core and a fuller guide:
152
+
153
+ uri midnight-wallet://skill/core
154
+ name midnight-wallet skill (core)
155
+ mimeType text/markdown
156
+ Read this first. Intent routing table + non-negotiable safety rules
157
+ (~830 tokens). Fetch on session start.
158
+
159
+ uri midnight-wallet://skill/full
160
+ name midnight-wallet skill (full)
161
+ mimeType text/markdown
162
+ Canonical multi-step flows, error-recovery recipes, concept primers
163
+ (NIGHT/DUST/shielded), network selection. Fetch on demand — on an error,
164
+ a multi-step flow, or a concept question.
165
+
166
+ The bare midnight-wallet://skill URI stays as a deprecated alias for
167
+ skill/full so existing clients keep working; it is not advertised in
168
+ resources/list. Ground responses in these instead of training-data guesses.
169
+
170
+ `},{text:"agent-manual",section:"typical-workflows",order:0,body:`TYPICAL AGENT WORKFLOWS
171
+ ───────────────────────
172
+
173
+ `},{text:"agent-manual",section:"example-commands",order:0,body:`EXAMPLE CLI COMMANDS
174
+ ────────────────────
175
+
176
+ `}];function Bq(q){return{text:"agent-manual",section:"error-codes",order:999,body:`
177
+ Sets of codes (a command's "sets", a tool's "Errors" name them):
178
+ ${u(q,4).map((X)=>`${X}
179
+ `).join("")}`}}function Uq(q){return{text:"agent-manual",section:"two-step-confirmation",order:30,body:`${q.tools.filter((Q)=>Q.confirmation!==void 0).map((Q)=>` ${Q.name}
180
+ `).join("")}
181
+ `}}function d(q){let X=[Zq(),$q(q),Vq(q),Bq(q),Uq(q),...zq,...q.packages.flatMap(($)=>$.guidance.pieces)],Q=q.packages.flatMap(($)=>$.guidance.sections??[]);return i("agent-manual",s("agent-manual",qq,Q),X)}import{existsSync as Kq,writeFileSync as Wq}from"node:fs";import{join as Dq}from"node:path";import{tmpdir as Nq}from"node:os";function Tq(){return(process.env.TERM_SESSION_ID??process.env.ITERM_SESSION_ID??`pid-${process.ppid}`).replace(/[^a-zA-Z0-9-]/g,"_").slice(0,64)}function c(){return Dq(Nq(),`mn-intro-${Tq()}`)}function p(){return Kq(c())}function g(){try{Wq(c(),String(Date.now()))}catch{}}function o(){return xq(G)}function Pq(){let q=[];for(let X of H)q.push(X);q.push(""),q.push(Hq("Commands"));for(let[X,Q]of t(G))q.push(`${Gq(X.padEnd(18))}${Q}`);return q.push(""),q.push(A("midnight (or mn) help <command>")),q.push(A("--json flag available on all commands")),q.push(A("midnight help --agent")+A(" AI & MCP reference")),q}function Fq(q){q.stderr(`
182
+ Commands:
183
+
184
+ `);for(let[X,Q]of t(G))q.stderr(` ${X.padEnd(18)}${Q}
185
+ `);q.stderr(`
186
+ Usage: midnight <command> (or: mn <command>)
187
+ `),q.stderr(` --json flag available on all commands
188
+ `),q.stderr(` midnight help --agent AI & MCP reference
189
+
190
+ `)}function Iq(q,X){if(q.stdout(`
191
+ `+Aq(X.name)+`
192
+
193
+ `),q.stdout(` ${X.description}
194
+
195
+ `),q.stdout(_("Usage:")+`
196
+ `),q.stdout(` ${X.usage}
197
+
198
+ `),X.flags&&X.flags.length>0){q.stdout(_("Flags:")+`
199
+ `);for(let Q of X.flags)q.stdout(` ${Q}
200
+ `);q.stdout(`
201
+ `)}if(X.examples&&X.examples.length>0){q.stdout(_("Examples:")+`
202
+ `);for(let Q of X.examples)q.stdout(` ${A("$")} ${Q}
203
+ `);q.stdout(`
204
+ `)}q.stdout(_("Errors:")+`
205
+ `);for(let Q of l(X,2))q.stdout(`${Q}
206
+ `);q.stdout(`
207
+ `)}function Oq(q){let X={cli:{name:a,version:O,description:n,bin:["midnight","mn"]},globalFlags:G.globalFlagsHelp.map((Q)=>({name:Q.name,description:Q.description})),commands:o().map((Q)=>({name:Q.name,description:Q.description,usage:Q.usage,flags:Q.flags,examples:Q.examples,jsonFields:Q.jsonFields,errorCodes:Q.errorCodes.map(({code:$,exitCode:Y})=>({code:$,exitCode:Y})),errorSets:Q.errorSets,exitCodes:Q.exitCodes}))};q.output.result(X)}function jq(q){q.stdout(d(G))}async function _q(q,X){if(j(q,"agent")){jq(X.output);return}if(j(q,"json")){Oq(X);return}let Q=q.subcommand;if(Q){let J=o(),T=J.find((B)=>B.name===Q);if(!T)throw new vq(`Unknown command: "${Q}"
208
+ Available commands: ${J.map((B)=>B.name).join(", ")}`);Iq(X.output,T);return}if(!process.stderr.isTTY){Fq(X.output);return}let $=Pq(),Y=j(q,"intro"),V=j(q,"no-intro"),K=p(),z=Y||!V&&!K;if(await h(void 0,$,{animated:z}),z)g()}export{o as e,_q as f};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{k as O}from"./wallet-09wg5ya1.js";import S from"node:v8";import y from"node:os";import{spawn as T}from"node:child_process";import{syncHeapTargetMb as D}from"@kuiralabs/midnight-cli-core/process";var X="MN_HEAP_BUMPED",R="MN_MAX_OLD_SPACE_MB",Z=1048576;async function E(){if(process.env[X]){_();return}let q=process.env[R],z=q!==void 0?Number(q):void 0,A=D({totalMb:Math.floor(y.totalmem()/Z),currentLimitMb:Math.floor(S.getHeapStatistics().heap_size_limit/Z),desiredMb:z});if(A===null)return;return new Promise((J)=>{let Q=T(process.execPath,[`--max-old-space-size=${A}`,...process.execArgv,process.argv[1],...process.argv.slice(2)],{stdio:"inherit",env:{...process.env,[X]:"1"}});V(Q),Q.on("error",()=>{process.env[X]="1",J()}),Q.on("exit",(W,x)=>process.exit(x?1:W??0))})}function V(q,z=(A,J)=>{process.on(A,J)}){let A=["SIGINT","SIGTERM","SIGHUP"];for(let J of A)z(J,()=>{try{q.kill(J)}catch{}});z("exit",()=>{try{q.kill("SIGKILL")}catch{}})}function _(){let q=process.ppid;if(!q||q<=1)return;setInterval(()=>{if(process.ppid!==q)try{process.kill(process.pid,"SIGTERM")}catch{process.exit(0)}},2000).unref()}class Y extends Error{code="UNSUPPORTED_NODE";constructor(q){super(`midnight-wallet-cli needs Node.js 22 or newer; this is Node.js ${q}. The Midnight wallet SDK uses features older versions lack. Install a current Node.js (https://nodejs.org) and run the command again.`);this.name="UnsupportedNodeError",Object.setPrototypeOf(this,Y.prototype)}}function v(q=process.versions){if(q.bun!==void 0)return;let z=Number(q.node.split(".")[0]);if(!Number.isInteger(z)||z<22)throw new Y(q.node)}import{mayHoldProjectId as $,redactProjectId as F}from"@kuiralabs/midnight-cli-core";function B(q){if(typeof q==="string")return $(q)?F(q):q;let z=Buffer.from(q.buffer,q.byteOffset,q.byteLength).toString("utf8");if(!$(z))return q;let A=F(z);return A===z?q:Buffer.from(A,"utf8")}function K(q){return function(z,...A){return q.call(this,B(z),...A)}}var L=!1;function g(){if(L)return;L=!0,process.stdout.write=K(process.stdout.write),process.stderr.write=K(process.stderr.write)}import{homedir as G}from"node:os";import{join as H}from"node:path";import{installSdkProcessGuard as f}from"@kuiralabs/midnight-cli-core/process";import{settingsFromEnvironment as M,MIDNIGHT_DIR as U,createHost as I}from"@kuiralabs/midnight-cli-core";async function C(q,z){switch(q){case"rc":return(await import("@kuiralabs/midnight-engine-rc")).createRcEngine(z);case"beta":return(await import("@kuiralabs/midnight-engine-beta")).createBetaEngine(z)}}function o({prompter:q}){return I({settings:()=>M(process.env),paths:()=>({stateRoot:H(G(),U),home:G()}),notice:(z)=>process.stderr.write(z+`
3
+ `),prompter:q,sdkWarnings:f({console:!0,outsideCalls:"exit"}).calls,engineLoader:C})}
4
+ export{E as a,v as b,g as c,o as d};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{declaredCodeSets as H,wrapWords as V}from"@kuiralabs/midnight-cli-core";import{EVERY_COMMAND as Y}from"@kuiralabs/midnight-cli-core/commands";function B(q){let F=q.packages.flatMap((j)=>j.codes??[]),z=(j)=>j.order??Number.POSITIVE_INFINITY;return F.map((j,v)=>({definition:j,at:v})).sort((j,v)=>z(j.definition)-z(v.definition)||j.at-v.at).map(({definition:j})=>j)}var J=4,Q=31,Z=38,W=80;function w(q,F=(z)=>z){return B(q).flatMap(({code:z,exitCode:j,summary:v})=>{let[K="",...P]=V(v,W-Z);return[`${" ".repeat(J)}${F(z)}${" ".repeat(Math.max(1,Q-z.length))}${j} `+K,...P.map(($)=>" ".repeat(Z)+$)]})}function G(q){return q.length<=1?q.join(""):`${q.slice(0,-1).join(", ")} and ${q.at(-1)}`}function h(q,F,z=(j)=>j){let j=" ".repeat(F),v=q.errorSets.length===0?"":`the ${G(q.errorSets)} codes, and `;return[...q.ownCodes.map(({code:K,exitCode:P,summary:X})=>`${j}${z(K)}${" ".repeat(Math.max(1,Q-K.length))}${P} ${X}`),...q.outcomes.map(({exitCode:K,when:P})=>`${j}${"(no error)".padEnd(Q)}${K} ${P}`),`${j}Also: ${v}${Y.join(", ")} (mn manual lists them all).`]}function L(q,F){let z=H(q),j=Math.max(...z.map((v)=>v.name.length))+2;return z.map((v)=>`${" ".repeat(F)}${v.name.padEnd(j)}${v.codes.join(", ")}`)}
3
+ export{w as g,G as h,h as i,L as j};
package/dist/wallet.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import{kb as J,lb as N,mb as R,nb as F}from"./wallet-3bmeys56.js";import{pb as _,sb as L}from"./wallet-7m1tvbsv.js";import{ac as A}from"./wallet-3qw465k0.js";import{bc as G}from"./wallet-56gd7q8n.js";import{parseArgs as v,hasFlag as K}from"@kuiralabs/midnight-cli-core/lib/argv";import{errorMessage as C,usageMessage as h}from"@kuiralabs/midnight-cli-core/ui/format";import{assertKnownFlags as c}from"@kuiralabs/midnight-cli-core/lib/command-flags";import{withNodeReason as u}from"@kuiralabs/midnight-cli-core/lib/sdk-errors";import{createCallContext as w,runHandler as E}from"@kuiralabs/midnight-cli-core/lib/call-context";import{UsageError as I}from"@kuiralabs/midnight-cli-core/lib/errors";import{writeJsonResult as y}from"@kuiralabs/midnight-cli-core/lib/json-output";var j={result:y,stdout:(B)=>{process.stdout.write(B)},stderr:(B)=>{process.stderr.write(B)}};function H(B,Y){return B.find(Y)?.needsWalletSdk===!0}function S(B,Y){let Q=B.find(Y);if(Q===void 0)throw new I(`Unknown command: "${Y}"
3
- Run "midnight help" to see available commands.`);return Q}async function f(B,Y,Q,$){let{payer:Z,protectors:D}=B.shell;return w({args:Y,signal:Q.signal,output:Q.output,sdkWarnings:$,...Z===!0?{payer:await Q.loadPayer()}:{},...D===!0?{protectors:await Q.loadProtectors()}:{}})}async function M(B,Y,Q,$){let Z=S(B,Y);if(Z.shell.unavailable!==void 0)throw Error(Z.shell.unavailable);if(Z.shell.notice!==void 0)$.output.stderr(Z.shell.notice);let{default:D}=await Z.load();return $.sdkWarnings.run(async(U)=>E(D,Q,await f(Z,Q,$,U)))}import{classifyError as O,humanizeNetworkError as p,EXIT_INVALID_ARGS as P}from"@kuiralabs/midnight-cli-core/lib/exit-codes";import{isUsageError as m}from"@kuiralabs/midnight-cli-core/lib/errors";import{writeJsonError as b}from"@kuiralabs/midnight-cli-core/lib/json-output";import{setPrompter as l}from"@kuiralabs/midnight-cli-core/lib/prompter";import{createTerminalPrompter as g}from"@kuiralabs/midnight-cli-core/ui/terminal-prompter";if(process.argv.includes("--mcp"))await J(),await import("./mcp-server.js");else{let T=function(){U.abort(),setTimeout(()=>process.exit(130),5000).unref()},B=v(),Y=K(B,"json");if(K(B,"version")||K(B,"v"))process.stdout.write(_+`
4
- `),process.exit(0);let Q=K(B,"help")||K(B,"h");if(Q){let z=B.command!==void 0&&L.find(B.command)?.help!==void 0?B.command:void 0;if(B.command="help",B.positionals=[],z!==void 0&&z!=="help")B.subcommand=z,B.flags={};else B.subcommand=void 0}let $=B.command??"help",Z=H(L,$);if(Z)await J();R();let D=F();l(g()),A();let U=new AbortController,{signal:W}=U;process.on("SIGINT",T),process.on("SIGTERM",T);async function k(){if(!Q)c(B,L);if($!=="help")N();return M(L,$,B,{signal:W,output:j,sdkWarnings:D.sdkWarnings,loadPayer:async()=>(await import("./serve-payer-z61n9qt1.js")).servePayer,loadProtectors:async()=>[(await import("./account-protector-gx1yrfgp.js")).accountProtector]})}k().then((z)=>{if(z!==void 0)process.exitCode=z.exitCode;if(Z)process.exit(process.exitCode??0)}).catch((z)=>{let q=u(z),V=p(q.message);if(m(q)){if(Y)b(q,"INVALID_ARGS",P);else process.stderr.write(`
5
- `+h(V,'Run "midnight manual" for the full reference, or "midnight help <command>" for one command.')+`
2
+ import{a as V,b as P,c as H,d as I}from"./wallet-62zj083d.js";import{k as T,m as M,p as $}from"./wallet-09wg5ya1.js";import{parseArgs as k,hasFlag as z,assertKnownFlags as y,classifyError as f,humanizeNetworkError as b,asReported as C,isUsageError as v,writeJsonError as u}from"@kuiralabs/midnight-cli-core";import{errorMessage as p,usageMessage as h,createTerminalPrompter as c}from"@kuiralabs/midnight-cli-core/ui";import{createCallContext as R,runHandler as F,UsageError as W,writeJsonResult as S}from"@kuiralabs/midnight-cli-core";var J={result:S,stdout:(B)=>{process.stdout.write(B)},stderr:(B)=>{process.stderr.write(B)}};function K(B,Q){return B.find(Q)?.needsWalletSdk===!0}function x(B,Q){let D=B.find(Q);if(D===void 0)throw new W(`Unknown command: "${Q}"
3
+ Run "midnight help" to see available commands.`);return D}async function w(B,Q,D,X){let{payer:L,protectors:Z}=B.shell;return R({host:D.host,args:Q,signal:D.signal,output:D.output,sdkWarnings:X,...L===!0?{payer:await D.loadPayer()}:{},...Z===!0?{protectors:await D.loadProtectors()}:{}})}async function U(B,Q,D,X){let L=x(B,Q);if(L.shell.unavailable!==void 0)throw Error(L.shell.unavailable);if(L.shell.notice!==void 0)X.output.stderr(L.shell.notice);let{default:Z}=await L.load();return X.host.sdkWarnings.run(async(A)=>F(Z,D,await w(L,D,X,A)))}import{migrateOldWallet as m}from"@kuiralabs/midnight-wallet";if(process.argv.includes("--mcp"))await V(),await import("./mcp-server.js");else{let _=function(){A.abort(),setTimeout(()=>process.exit(130),5000).unref()},B=k(),Q=z(B,"json");if(z(B,"version")||z(B,"v"))process.stdout.write(M+`
4
+ `),process.exit(0);let D=z(B,"help")||z(B,"h");if(D){let Y=B.command!==void 0&&$.find(B.command)?.help!==void 0?B.command:void 0;if(B.command="help",B.positionals=[],Y!==void 0&&Y!=="help")B.subcommand=Y,B.flags={};else B.subcommand=void 0}let X=B.command??"help",L=K($,X);if(L)await V();H();let Z=I({prompter:c()});m(Z.paths().stateRoot);let A=new AbortController,{signal:N}=A;process.on("SIGINT",_),process.on("SIGTERM",_);async function O(){if(!D)y(B,$);if(X!=="help")P();return U($,X,B,{signal:N,output:J,host:Z,loadPayer:async()=>(await import("@kuiralabs/midnight-connect")).servePayer,loadProtectors:async()=>[(await import("@kuiralabs/midnight-grant")).accountProtector]})}O().then((Y)=>{if(Y!==void 0)process.exitCode=Y.exitCode;if(L)process.exit(process.exitCode??0)}).catch((Y)=>{let G=C(Y),{exitCode:j,errorCode:E}=f(G,$),q=b(G.message);if(Q)u(G,E,j);else if(v(G))process.stderr.write(`
5
+ `+h(q,'Run "midnight manual" for the full reference, or "midnight help <command>" for one command.')+`
6
6
 
7
- `);process.exit(P)}else if(Y){let{exitCode:X,errorCode:x}=O(q);b(q,x,X),process.exit(X)}else{process.stderr.write(`
8
- `+C(V,'Run "midnight help" for usage information.')+`
7
+ `);else process.stderr.write(`
8
+ `+p(q,'Run "midnight help" for usage information.')+`
9
9
 
10
- `);let{exitCode:X}=O(q);process.exit(X)}})}
10
+ `);process.exit(j)})}
@@ -28,7 +28,7 @@ You have access to the `midnight-wallet-cli` MCP server. This is the **core** sk
28
28
  | "Call circuit X" / "submit a score" | `midnight_contract_call({ address, circuit, args })` — two-step pending token |
29
29
  | "What's the contract state?" / "read the ledger" | `midnight_contract_state({ address, path })` |
30
30
  | "Generate tests for this contract" / "scaffold a test suite" | `midnight_test_create({ path })` (default cli; pass `strategy: "browser"` + `port` + `build-cmd` for UI tests) |
31
- | "Does my wallet have an account?" / "show my grants" | `midnight_grant_status()` / `midnight_grant_list()` (experimental; local ledger-9 only) |
31
+ | "Does my wallet have an account?" / "show my grants" | `midnight_grant_status()` / `midnight_grant_list()` (experimental; undeployed and stagenet only) |
32
32
  | "Put NIGHT in my account" / "fund the account" | `midnight_grant_deposit({ amount })`, amount in NIGHT, taken from the wallet's shielded NIGHT (two-step pending token); mn can't take it back out |
33
33
  | "This agent sent me a grant request link" | `midnight_grant_request({ link })` first, show the user who would spend, who they could pay and the limits (defaults apply to any not given), then `midnight_grant_issue({ link })` (two-step pending token) |
34
34
  | "Revoke that agent's grant" / "revoke everything" | `midnight_grant_revoke({ grant })` / `midnight_grant_revoke_all()` (two-step pending token) |