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

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/README.md CHANGED
@@ -26,7 +26,7 @@ npm install -g midnight-wallet-cli@next # this ledger-9 prerelease
26
26
 
27
27
  This installs two commands: `midnight` (or `mn` for short) and `midnight-wallet-mcp`.
28
28
 
29
- Install the prerelease with npm (or run it with `npx`). It ships an `npm-shrinkwrap.json` that keeps each SDK set's packages apart; bun's installer ignores it, and a command whose SDK set it then mixes up is refused, saying so (`MIXED_SDK_LAYOUT`; under bun today, every stagenet command).
29
+ Install the prerelease with npm 11 or older (or run it with `npx`; with npm 12, `npx -y npm@11 install -g midnight-wallet-cli@next`). Each engine ships an `npm-shrinkwrap.json` that pins the SDK set it was tested with; npm 12 and bun's installer ignore it and resolve the packages again, so an engine either installed is refused before any SDK loads, saying so (`MIXED_SDK_LAYOUT`). bun can run what npm installed.
30
30
 
31
31
  ## Commands
32
32
 
@@ -343,6 +343,12 @@ The legacy `midnight-wallet://skill` URI still works as an alias for `/full`.
343
343
 
344
344
  Every tool error returns `{ error: true, code: <CODE>, message: <human prose> }`. Agents should index on the stable `code` (`INSUFFICIENT_BALANCE`, `DUST_REQUIRED`, `INVALID_DUST_PROOF`, `STALE_CACHE`, `PROOF_FAILURE`, `SYNC_TIMEOUT`, `NETWORK_ERROR`, `WALLET_NOT_FOUND`, `INVALID_ARGS`, `TX_REJECTED`, `STALE_UTXO`, `PROOF_TIMEOUT`, `CANCELLED`, `UNKNOWN`) — full taxonomy + recovery recipes are in `docs/SKILL.md`.
345
345
 
346
+ ## Using mn's packages in your program
347
+
348
+ mn is built from packages a program can install on its own: `@kuiralabs/midnight-cli-core` (the host, typed errors and codes, running a command), `@kuiralabs/midnight-chain`, `@kuiralabs/midnight-wallet` (with swap), `@kuiralabs/midnight-contract`, `@kuiralabs/midnight-connect`, `@kuiralabs/midnight-dev`, `@kuiralabs/midnight-grant`, and the two SDK engines, `@kuiralabs/midnight-engine-rc` and `@kuiralabs/midnight-engine-beta`. A program calls their functions with plain values (bigint amounts, typed results and receipts), or mounts their commands in its own command line or MCP server, with its own state root, settings, prompter and output; errors carry a `code` it can act on without reading messages. All are release candidates on the `next` tag; install them with npm.
349
+
350
+ Start with [core's README](packages/cli-core/README.md): mounting commands, and what a program does to its own process for the wallet SDK. Each package's README lists its entry points, its codes and one example, and its `api-report.md` lists every export.
351
+
346
352
  ## Issues & Feedback
347
353
 
348
354
  Found a bug or have a feature request? [Open an issue](https://github.com/kuiralabs/midnight-cli/issues).
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{h as a,i as b}from"./wallet-mrngz8w8.js";import"./wallet-80py6j35.js";export{a as helpSpecs,b as default};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
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)}
2
+ import{e as K,f as M,g as A,h as I}from"./wallet-mrngz8w8.js";import{k as V,l as F,n as G,o as B}from"./wallet-80py6j35.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
3
  ${z(L(j))}
4
4
  ${z(T)}
5
5
  `}function Q(j){return`
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
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)
2
+ import{a as g,b as d,c as p,d as c}from"./wallet-n13e40r9.js";import{l as P,o as W}from"./wallet-80py6j35.js";import{Server as Vz}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Gz}from"@modelcontextprotocol/sdk/server/stdio.js";import{ListToolsRequestSchema as Dz,CallToolRequestSchema as Mz,ListResourcesRequestSchema as qz,ReadResourceRequestSchema as Kz}from"@modelcontextprotocol/sdk/types.js";import{servePayer as y}from"@kuiralabs/midnight-connect";import{classifyError as Az,asReported as Pz,trimAgentMessage as Fz,needsConfirmation as Uz}from"@kuiralabs/midnight-cli-core";import{OtherSdkSetError as U,networksOnSdkSet as n}from"@kuiralabs/midnight-cli-core";function x(z,B){if(!(z instanceof U))return z;let J=n(z.wantedSet,B).join(", ");return new U(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 l}from"node:crypto";var s=300000;function N(z={}){let B=z.ttlMs??s,J=z.now??(()=>Date.now()),Q=new Map,X=(Z)=>{let $=0;for(let[j,Y]of Q)if(Y.expiresAt<=Z)Q.delete(j),$+=1;return $};return{create(Z){let $=J();X($);let j=l(),Y={token:j,tool:Z.tool,args:Z.args,description:Z.description,createdAt:$,expiresAt:$+B};return Q.set(j,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 E}from"@kuiralabs/midnight-cli-core";function a(z,B){return Object.keys(B).filter((J)=>!Object.hasOwn(z.inputSchema.properties,J))}function _(z,B){let J=a(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 E(`Unknown parameter${J.length>1?"s":""} for ${z.name}: ${J.join(", ")}
3
+ ${X}`)}function t(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 C(z,B){let J=Object.entries(B).flatMap(([Q,X])=>{let Z=z.inputSchema.properties[Q],$=Z===void 0?void 0:t(Z,X);return $===void 0?[]:[`${Q} ${$}`]});if(J.length===0)return;throw new E(`Invalid parameter${J.length>1?"s":""} for ${z.name}: ${J.join("; ")}`)}import{captureCommand as o,getEndpointOverridesForNetwork as r,loadCliConfig as e,resolveNetworkName as zz,confirmationText as Bz,toolArgv as K,toolDescription as Jz}from"@kuiralabs/midnight-cli-core";var V={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 L(z){return[...z.tools.map((B)=>({...B,description:Jz(z,B)})),V].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)}var Qz=(z)=>{process.stderr.write(z)};function R(z,B,J){return o(z.command,B,{...J,text:Qz})}async function f(z,B,J){return R(z,K(z,B),J)}var I=[["node","node"],["indexer-ws","indexer"],["proof-server","proof server"]];function Xz(z,B,J){let Q=z.inputSchema.properties;if(!I.some(([$])=>Object.hasOwn(Q,$)))return"";let X=r(e(J),zz({args:K(z,B),configDir:J})),Z=I.flatMap(([$,j])=>{let Y=B[$];if(typeof Y==="string"&&Y!=="")return[`${j} ${Y}`];let H=X[$];return H===void 0?[]:[`${j} ${H} (set with config)`]});return Z.length===0?"":`. Endpoints: ${Z.join(", ")}`}async function O(z,B,J){return(await z.confirmation?.check?.(B,{host:J.host,argv:()=>K(z,B),run:async(X)=>R(z,X,J)})??Bz(z,B))+Xz(z,B,J.host.paths().stateRoot)}import{assembleGuidance as b,sectionsWithAdded as T,declaredCodeSets as Zz}from"@kuiralabs/midnight-cli-core";var $z=["title","intent-routing","safety-rules","when-to-fetch"],Yz=["title","what-you-can-do","core-concepts","secrets","blockfrost","intent-routing","canonical-flows","safety-rules","error-recovery","networks","not-this-cli","references"],jz=[{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,7 +44,7 @@ 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"}],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\`.
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"}],Hz=(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**: ${Hz(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
 
@@ -53,9 +53,9 @@ A tool's description ends with the codes it can fail with: its own, and sets of
53
53
 
54
54
  | Set | Codes |
55
55
  |---|---|
56
- ${Dz(z).map((Q)=>`| ${Q.name} | ${Q.codes.map((X)=>`\`${X}\``).join(", ")} |
56
+ ${Zz(z).map((Q)=>`| ${Q.name} | ${Q.codes.map((X)=>`\`${X}\``).join(", ")} |
57
57
  `).join("")}`},{text:"skill-full",section:"what-you-can-do",order:1000,body:`
58
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.`}
59
59
 
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}
60
+ `}]}function w(z){return[...jz,...Wz(z),...z.packages.flatMap((B)=>B.guidance.pieces)]}var S=(z)=>z.packages.flatMap((B)=>B.guidance.sections??[]);function v(z){return b("skill-core",T("skill-core",$z,S(z)),w(z))}function k(z){return b("skill-full",T("skill-full",Yz,S(z)),w(z))}var m="midnight-wallet://skill/core",i="midnight-wallet://skill/full",xz="midnight-wallet://skill",h=N(),M=null,D=new Vz({name:"midnight-wallet-cli",version:P},{capabilities:{tools:{},resources:{}}});D.setRequestHandler(qz,async()=>({resources:[{uri:m,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:i,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"}]}));D.setRequestHandler(Kz,async(z)=>{let B=z.params.uri;if(B===m){let J=v(W);return{contents:[{uri:B,mimeType:"text/markdown",text:J}]}}if(B===i||B===xz){let J=k(W);return{contents:[{uri:B,mimeType:"text/markdown",text:J}]}}throw Error(`Unknown resource: ${B}`)});D.setRequestHandler(Dz,async()=>({tools:L(W)}));D.setRequestHandler(Mz,async(z,B)=>{let{name:J,arguments:Q}=z.params,X=Q??{},Z=Nz(z.params._meta?.progressToken,B),$=A(W,J),j=J===V.name?V:$;if(j!==void 0)try{_(j,X),C(j,X)}catch(Y){return G(Y instanceof Error?Y:Error(String(Y)),Z)}if(J===V.name){let Y=typeof X.token==="string"?X.token:"",H=h.redeem(Y);if(!H)return G(Error("Unknown or expired confirmation token. The first-step tool call may need to be re-issued."),Z);return u(H.tool,H.args,Z)}if($!==void 0&&Uz($,X)){let Y;try{Y=await O($,X,Z)}catch(q){return G(q instanceof Error?q:Error(String(q)),Z)}let H=h.create({tool:J,args:X,description:Y});return{content:[{type:"text",text:JSON.stringify(F({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 u(J,X,Z)});function Nz(z,B){if(M===null)throw Error("The MCP server took a call before its host was installed");if(z===void 0)return{signal:B.signal,payer:y,host:M};let J=0,Q;return{signal:B.signal,payer:y,host:M,onProgress:(X)=>{if(X===Q)return;Q=X,J+=1,B.sendNotification({method:"notifications/progress",params:{progressToken:z,progress:J,message:X}}).catch(()=>{})}}}function F(z){return{...z,_serverVersion:P}}async function u(z,B,J){let Q=A(W,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(F(X),null,2)}]}}catch(X){return G(X instanceof Error?X:Error(String(X)),J)}}function G(z,B){let J=x(Pz(z),B.host.paths().stateRoot),{errorCode:Q}=Az(J,W);return{content:[{type:"text",text:JSON.stringify(F({error:!0,code:Q,message:Fz(J.message)}))}],isError:!0}}async function Ez(){d(),p(),M=c({prompter:null}),await g();let z=new Gz;await D.connect(z)}Ez().catch((z)=>{process.stderr.write(`MCP server error: ${z.message}
61
61
  `),process.exit(1)});
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire as r}from"node:module";var e=r(import.meta.url);var i={name:"midnight-wallet-cli",version:"0.6.0-rc.14",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","package-readmes":"tsx --conditions=midnight-cli-source scripts/write-package-readmes.ts"},dependencies:{"@kuiralabs/midnight-chain":"0.1.0-rc.3","@kuiralabs/midnight-cli-core":"0.1.0-rc.3","@kuiralabs/midnight-connect":"0.1.0-rc.3","@kuiralabs/midnight-contract":"0.1.0-rc.3","@kuiralabs/midnight-dev":"0.1.0-rc.3","@kuiralabs/midnight-engine-beta":"0.1.0-rc.3","@kuiralabs/midnight-engine-rc":"0.1.0-rc.3","@kuiralabs/midnight-grant":"0.1.0-rc.3","@kuiralabs/midnight-wallet":"0.1.0-rc.3","@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 z=i.name,q=i.version,M=i.description,J=i.repository.url.replace(/^git\+/,"").replace(/\.git$/,"");import{getValidNetworkNames as d,createPackageRegistry as u}from"@kuiralabs/midnight-cli-core";import{coreCommands as g}from"@kuiralabs/midnight-cli-core/commands";import{walletCommands as p,swapCommands as b}from"@kuiralabs/midnight-wallet/commands";import{contractCommands as o}from"@kuiralabs/midnight-contract/commands";import{connectCommands as m}from"@kuiralabs/midnight-connect/commands";import{devCommands as h}from"@kuiralabs/midnight-dev/commands";import{grantCommands as k}from"@kuiralabs/midnight-grant/commands";import{chainCommands as w}from"@kuiralabs/midnight-chain/commands";import{RESOLVES_NETWORK as a}from"@kuiralabs/midnight-cli-core/commands";var n={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-s6vpp42v.js")};import{RESOLVES_NETWORK as l}from"@kuiralabs/midnight-cli-core/commands";var s={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:[l]},load:()=>import("./manual-vd4pq3qt.js")};var t={notForAgents:"the shell answers it before any command runs"},v=[{name:"help",takesValue:!1,agent:t},{name:"h",takesValue:!1,agent:t},{name:"json",takesValue:!1,agent:{notForAgents:"the MCP server always sets it"}},{name:"version",takesValue:!1,agent:t},{name:"v",takesValue:!1,agent:t}],x=[{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 (${d().join(", ")})`},{name:"--version, -v",description:"Print CLI version"},{name:"--help, -h",description:"Show help"}],V=u([g,w,p,o,m,b,h,k,{name:"shell",commands:[n,s],guidance:{pieces:[]}}],v,x);
3
+ export{e as j,z as k,q as l,M as m,J as n,V as o};
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env node
2
+ import{k as o,l as A,m as r,o as G}from"./wallet-80py6j35.js";import{hasFlag as S,commandHelpSpecs as Sq,introBriefs as i,UsageError as Oq}from"@kuiralabs/midnight-cli-core";import{bold as Rq,teal as Eq,gray as O,dim as j,header as _q}from"@kuiralabs/midnight-cli-core/ui";import{teal as hq,white as P,purple as uq,green as mq,bold as N,dim as dq,isColorEnabled as h}from"@kuiralabs/midnight-cli-core/ui";var x=[" ████████████ "," ███ ███ "," ███ ██ ███ "," ██ ██ "," ██ ██ ██ "," ██ ██ "," ██ ██ ██ "," ██ ██ "," ██ ██ "," ██ ██ "," ██ ██ "," ███ ███ "," ███ ███ "," ████████████ "].join(`
3
+ `);var F=["█▄ ▄█ █ █▀▄ █▄ █ █ █▀▀ █ █ ▀█▀","█ █ █ █ █ █ █ ██ █ █ █ █▀█ █ ","▀ ▀ ▀ ▀▀ ▀ ▀ ▀ ▀▀▀ ▀ ▀ ▀ "];function L(q){let X=Math.max(0,Math.min(1,q)),Q=F[0].length,Z=Math.floor(X*Q);return F.map(($)=>$.slice(0,Z).padEnd(Q))}function C(q){let X=Math.max(0,Math.min(1,q)),Q=Math.floor(q*100);if(X>=1)return F;return F.map((Z,$)=>Array.from(Z).map((Y,B)=>{if(Y===" ")return" ";if(X<=0)return I($+20,B,0);let V=(($+20)*131+B*997)%100/100;return X>=V?Y:I($+20,B,Q)}).join(""))}var M=["░","▒","▓","█","·"," "];function I(q,X,Q){let Z=(q*131+X*997+Q*7919)%65537/65537;return M[Math.floor(Z*M.length)]}function w(q){let X=Math.max(0,Math.min(1,q)),Q=x.split(`
4
+ `),Z=Math.floor(q*100);if(X>=1)return x;if(X<=0)return Q.map(($,Y)=>Array.from($).map((B,V)=>I(Y,V,0)).join("")).join(`
5
+ `);return Q.map(($,Y)=>Array.from($).map((B,V)=>{if(B===" ")return" ";let z=(Y*131+V*997)%100/100;return X>=z?B:I(Y,V,Z)}).join("")).join(`
6
+ `)}var _=80;function k(q,X){return new Promise((Q,Z)=>{if(X?.aborted){Q();return}let $=setTimeout(Q,q);X?.addEventListener("abort",()=>{clearTimeout($),Q()},{once:!0})})}async function u(q,X,Q){let $=x.split(`
7
+ `),Y=$.length,B=36,V=Math.max(Y,X?.length??0),z=3,D=Q?.animated??!0;if(!h()||!D){let J=h();for(let U=0;U<V;U++){let W=U<Y?$[U]:"",H=J?P(W).padEnd(45):W.padEnd(35),v=X?.[U]??"",E=J&&U<3&&v?N(P(v)):v;if(J)process.stderr.write(W?P(W)+"\x1B[36G"+E+`
8
+ `:"\x1B[36G"+E+`
9
+ `);else process.stderr.write(H+E+`
10
+ `)}return}function K(J,U){for(let W=0;W<V;W++){let H=W<J.length?P(J[W]):"",v=U[W]??"";if(v)process.stderr.write(H+"\x1B[36G"+v+`\x1B[K
11
+ `);else process.stderr.write(H+`\x1B[K
12
+ `)}}function T(){process.stderr.write(`\x1B[${V}A`)}for(let J=0;J<=20;J++){if(q?.aborted)break;let U=J/20,H=w(U).split(`
13
+ `);if(J>0)T();K(H,[]),await k(_,q)}let f=20;for(let J=0;J<=f;J++){if(q?.aborted)break;let U=J/f,W=L(U);T();let H=Array(V).fill(null);for(let v=0;v<W.length;v++)H[v]=N(P(W[v]));K($,H),await k(_,q)}let y=12;for(let J=0;J<=y;J++){if(q?.aborted)break;let U=J/y,W=C(U);T();let H=Array(V).fill(null);for(let v=0;v<W.length;v++)H[v]=N(P(W[v]));K($,H),await k(_,q)}T();let R=Array(V).fill(null);if(X)for(let J=0;J<X.length;J++)if(J<3)R[J]=N(P(X[J]));else R[J]=X[J];K($,R)}import{declaredCodeSets as s,listedNames as e,wrapWords as qq}from"@kuiralabs/midnight-cli-core";import{EVERY_COMMAND as Qq}from"@kuiralabs/midnight-cli-core/commands";function Xq(q){let X=q.packages.flatMap((Z)=>Z.codes??[]),Q=(Z)=>Z.order??Number.POSITIVE_INFINITY;return X.map((Z,$)=>({definition:Z,at:$})).sort((Z,$)=>Q(Z.definition)-Q($.definition)||Z.at-$.at).map(({definition:Z})=>Z)}var Zq=4,b=31,m=38,$q=80;function tq(q,X=(Q)=>Q){return Xq(q).flatMap(({code:Q,exitCode:Z,summary:$})=>{let[Y="",...B]=qq($,$q-m);return[`${" ".repeat(Zq)}${X(Q)}${" ".repeat(Math.max(1,b-Q.length))}${Z} `+Y,...B.map((z)=>" ".repeat(m)+z)]})}function c(q,X,Q=(Z)=>Z){let Z=" ".repeat(X),$=q.errorSets.length===0?"":`the ${e(q.errorSets)} codes, and `;return[...q.ownCodes.map(({code:Y,exitCode:B,summary:V})=>`${Z}${Q(Y)}${" ".repeat(Math.max(1,b-Y.length))}${B} ${V}`),...q.outcomes.map(({exitCode:Y,when:B})=>`${Z}${"(no error)".padEnd(b)}${Y} ${B}`),`${Z}Also: ${$}${Qq.join(", ")} (mn manual lists them all).`]}function d(q,X){let Q=s(q),Z=Math.max(...Q.map(($)=>$.name.length))+2;return Q.map(($)=>`${" ".repeat(X)}${$.name.padEnd(Z)}${$.codes.join(", ")}`)}import{GuidanceError as Yq,assembleGuidance as zq,sectionsWithAdded as Jq,commandHelpSpecs as Vq}from"@kuiralabs/midnight-cli-core";var Bq=["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"],Kq=[{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}],p={id:"other",title:"Other",width:53},Wq={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"]},vq=29;function Uq(){return{text:"agent-manual",section:"overview",order:0,body:`
14
+ MIDNIGHT CLI — AI Agent & MCP Reference
15
+ ========================================
16
+
17
+ Version: ${A}
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 Hq(q){return{text:"agent-manual",section:"json-schemas",order:0,body:`COMMANDS & JSON SCHEMAS
67
+ ───────────────────────
68
+ ${Vq(q).filter((Q)=>Q.jsonFields).map((Q)=>{let Z=Object.entries(Q.jsonFields).map(([$,Y])=>` ${$.padEnd(20)}${Y}`).join(`
69
+ `);return`
70
+ ${Q.name}
71
+ ${Q.usage}
72
+ Error codes: ${Q.ownCodes.map(($)=>$.code).join(", ")||"none"}; sets: ${Q.errorSets.join(", ")||"none"}
73
+ JSON fields:
74
+ ${Z}`}).join(`
75
+ `)}
76
+
77
+ `}}function Dq(q,X,Q){let Z=q.params??[Q?.required?.length?Q.required.join(", "):"—"];return Array.from({length:Math.max(q.description.length,Z.length)},($,Y)=>{let B=(Y===0?q.tool:"").padEnd(vq),V=q.description[Y]??"";return Z[Y]===void 0?` ${B}${V}`:` ${B}${V.padEnd(X)}${Z[Y]}`})}function Pq(q){let X=new Map(q.packages.flatMap((z)=>z.guidance.toolsTable??[]).map((z)=>[z.tool,z])),Q=[Wq,...q.tools.map((z,D)=>X.get(z.name)??{tool:z.name,group:p.id,order:D,description:[z.description]})],Z=[...Kq,p];for(let z of Q)if(!Z.some((D)=>D.id===z.group))throw new Yq(`${z.tool}'s row names tools table group "${z.group}", which the manual lacks`);let $=new Map(q.tools.map((z)=>[z.name,z])),Y=Z.flatMap((z)=>{let D=Q.filter((K)=>K.group===z.id).sort((K,T)=>K.order-T.order);if(D.length===0)return[];return[` ${z.title}
78
+ ${D.flatMap((K)=>Dq(K,z.width,$.get(K.tool))).map((K)=>`${K}
79
+ `).join("")}`]}),B=`AVAILABLE MCP TOOLS (${Q.length})`;return{text:"agent-manual",section:"mcp-tools",order:0,body:`${B}
80
+ ${"─".repeat(B.length)}
81
+
82
+ ${Y.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 Tq=[{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 Fq(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
+ ${d(q,4).map((X)=>`${X}
179
+ `).join("")}`}}function Gq(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 g(q){let X=[Uq(),Hq(q),Pq(q),Fq(q),Gq(q),...Tq,...q.packages.flatMap((Z)=>Z.guidance.pieces)],Q=q.packages.flatMap((Z)=>Z.guidance.sections??[]);return zq("agent-manual",Jq("agent-manual",Bq,Q),X)}import{existsSync as jq,writeFileSync as xq}from"node:fs";import{join as Iq}from"node:path";import{tmpdir as Nq}from"node:os";function Aq(){return(process.env.TERM_SESSION_ID??process.env.ITERM_SESSION_ID??`pid-${process.ppid}`).replace(/[^a-zA-Z0-9-]/g,"_").slice(0,64)}function l(){return Iq(Nq(),`mn-intro-${Aq()}`)}function n(){return jq(l())}function a(){try{xq(l(),String(Date.now()))}catch{}}function t(){return Sq(G)}function kq(){let q=[];for(let X of F)q.push(X);q.push(""),q.push(Rq("Commands"));for(let[X,Q]of i(G))q.push(`${Eq(X.padEnd(18))}${Q}`);return q.push(""),q.push(j("midnight (or mn) help <command>")),q.push(j("--json flag available on all commands")),q.push(j("midnight help --agent")+j(" AI & MCP reference")),q}function bq(q){q.stderr(`
182
+ Commands:
183
+
184
+ `);for(let[X,Q]of i(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 fq(q,X){if(q.stdout(`
191
+ `+_q(X.name)+`
192
+
193
+ `),q.stdout(` ${X.description}
194
+
195
+ `),q.stdout(O("Usage:")+`
196
+ `),q.stdout(` ${X.usage}
197
+
198
+ `),X.flags&&X.flags.length>0){q.stdout(O("Flags:")+`
199
+ `);for(let Q of X.flags)q.stdout(` ${Q}
200
+ `);q.stdout(`
201
+ `)}if(X.examples&&X.examples.length>0){q.stdout(O("Examples:")+`
202
+ `);for(let Q of X.examples)q.stdout(` ${j("$")} ${Q}
203
+ `);q.stdout(`
204
+ `)}q.stdout(O("Errors:")+`
205
+ `);for(let Q of c(X,2))q.stdout(`${Q}
206
+ `);q.stdout(`
207
+ `)}function yq(q){let X={cli:{name:o,version:A,description:r,bin:["midnight","mn"]},globalFlags:G.globalFlagsHelp.map((Q)=>({name:Q.name,description:Q.description})),commands:t().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:Z,exitCode:$})=>({code:Z,exitCode:$})),errorSets:Q.errorSets,exitCodes:Q.exitCodes}))};q.output.result(X)}function Mq(q){q.stdout(g(G))}async function Lq(q,X){if(S(q,"agent")){Mq(X.output);return}if(S(q,"json")){yq(X);return}let Q=q.subcommand;if(Q){let z=t(),D=z.find((K)=>K.name===Q);if(!D)throw new Oq(`Unknown command: "${Q}"
208
+ Available commands: ${z.map((K)=>K.name).join(", ")}`);fq(X.output,D);return}if(!process.stderr.isTTY){bq(X.output);return}let Z=kq(),$=S(q,"intro"),Y=S(q,"no-intro"),B=n(),V=$||!Y&&!B;if(await u(void 0,Z,{animated:V}),V)a()}export{tq as e,c as f,d as g,t as h,Lq as i};
@@ -1,4 +1,4 @@
1
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+`
2
+ import{j as O}from"./wallet-80py6j35.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
3
  `),prompter:q,sdkWarnings:f({console:!0,outsideCalls:"exit"}).calls,engineLoader:C})}
4
4
  export{E as a,v as b,g as c,o as d};
package/dist/wallet.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
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.')+`
2
+ import{a as A,b as M,c as P,d as I}from"./wallet-n13e40r9.js";import{j as z,l as H,o as X}from"./wallet-80py6j35.js";import{parseArgs as x,hasFlag as Z,assertKnownFlags as F,classifyError as S,humanizeNetworkError as k,asReported as w,isUsageError as y,writeJsonError as C}from"@kuiralabs/midnight-cli-core";import{errorMessage as b,usageMessage as p,createTerminalPrompter as u}from"@kuiralabs/midnight-cli-core/ui";import{UsageError as E,writeJsonResult as v,runCommand as R}from"@kuiralabs/midnight-cli-core";var J={result:v,stdout:(B)=>{process.stdout.write(B)},stderr:(B)=>{process.stderr.write(B)}};function K(B,D){return B.find(D)?.needsWalletSdk===!0}function f(B,D){let Q=B.find(D);if(Q===void 0)throw new E(`Unknown command: "${D}"
3
+ Run "midnight help" to see available commands.`);return Q}async function U(B,D,Q,Y){return R(f(B,D),Q,Y)}import{migrateOldWallet as h}from"@kuiralabs/midnight-wallet";if(process.argv.includes("--mcp"))await A(),await import("./mcp-server.js");else{let _=function(){V.abort(),setTimeout(()=>process.exit(130),5000).unref()},B=x(),D=Z(B,"json");if(Z(B,"version")||Z(B,"v"))process.stdout.write(H+`
4
+ `),process.exit(0);let Q=Z(B,"help")||Z(B,"h");if(Q){let L=B.command!==void 0&&X.find(B.command)?.help!==void 0?B.command:void 0;if(B.command="help",B.positionals=[],L!==void 0&&L!=="help")B.subcommand=L,B.flags={};else B.subcommand=void 0}let Y=B.command??"help",G=K(X,Y);if(G)await A();P();let T=I({prompter:u()});h(T.paths().stateRoot);let V=new AbortController,{signal:N}=V;process.on("SIGINT",_),process.on("SIGTERM",_);async function O(){if(!Q)F(B,X);if(Y!=="help")M();return U(X,Y,B,{signal:N,output:J,host:T,payer:async()=>(await import("@kuiralabs/midnight-connect")).servePayer,protectors:async()=>[(await import("@kuiralabs/midnight-grant")).accountProtector]})}O().then((L)=>{if(L!==void 0)process.exitCode=L.exitCode;if(G)process.exit(process.exitCode??0)}).catch((L)=>{let $=w(L),{exitCode:j,errorCode:W}=S($,X),q=k($.message);if(D)C($,W,j);else if(y($))process.stderr.write(`
5
+ `+p(q,'Run "midnight manual" for the full reference, or "midnight help <command>" for one command.')+`
6
6
 
7
7
  `);else process.stderr.write(`
8
- `+p(q,'Run "midnight help" for usage information.')+`
8
+ `+b(q,'Run "midnight help" for usage information.')+`
9
9
 
10
10
  `);process.exit(j)})}
package/docs/SKILL.md CHANGED
@@ -159,10 +159,12 @@ Every MCP tool error returns `{ error: true, code: <ERROR_CODE>, message: <human
159
159
  | `CHAIN_CLOCK_BEHIND` | The chain's clock lags this computer's (a local chain after sleep), so Dust estimates don't hold. | Wait for it to catch up, or ask the user to restart the local chain. |
160
160
  | `UNSUPPORTED_LEDGER` | The network is on ledger 8; this build supports ledger 9 only. | Tell the user: this network needs midnight-wallet-cli 0.5.x. Don't retry. |
161
161
  | `LOCALNET_UNAVAILABLE` | `mn localnet up` (`midnight_localnet_up()`) can't start a ledger-9 stack on this build. | Ask the user to start their ledger-9 stack and point mn at it (endpoint config). |
162
+ | `NO_TEST_CONFIG` | No dapp.test.json in the folder the test command ran in. | Ask the user to run it from the dApp's root, or create one with `mn test create`. |
162
163
  | `LOCAL_STACK_UNREACHABLE` | No ledger-9 stack answers at the configured endpoints. | Ask the user to start their stack or fix the configured node / indexer-ws / proof-server endpoints. |
163
164
  | `AMBIGUOUS_LOCAL_STACKS` | Several local Midnight stacks are running and no endpoints are configured, so mn won't guess. | Ask the user which stack to use; they set its endpoints with `midnight config set`. Don't retry blindly. |
164
165
  | `UNSUPPORTED_NODE` | Node.js is older than 22 (22.18 for mn grant). | Ask the user to install a current Node.js. |
165
166
  | `NO_NODE_RUNTIME` | Contract scripts run under Node.js, and none was found on PATH. | Ask the user to install Node.js 22 or later, or to run mn under Node. |
167
+ | `CONTRACT_NOT_COMPILED` | No compiled contract was found where the command looked (managed/<name>/compiler/contract-info.json). | Ask the user to compile the contract (compact compile), or pass the dApp folder (path) or the managed folder (managed). |
166
168
  | `NO_ACCOUNT` | A grant command (`midnight_grant_*` tool) was called for a wallet that has no account on this network. | Offer `midnight_grant_deploy()`, after telling the user how its owner key is kept (see the allowance flow). |
167
169
  | `CALLER_PIN_UNSUPPORTED` | A grant request pins the contract that calls the account, and the account on this network (stagenet) has no caller pin; nothing was submitted. | Tell the user; ask the agent for a grant request that names no calling contract, or issue it on undeployed. |
168
170
  | `WRONG_PASSPHRASE` | `MN_PASSPHRASE` is not the passphrase mn's secrets were encrypted with, or a sealed file was changed. | Ask the user to correct `MN_PASSPHRASE` in the MCP server's environment. Nothing was changed. |
@@ -172,7 +174,7 @@ Every MCP tool error returns `{ error: true, code: <ERROR_CODE>, message: <human
172
174
  | `BLOCKFROST_LIMIT_REACHED` | Blockfrost's plan limit or rate limit. | Wait and retry once; if it persists, tell the user it is their Blockfrost plan. |
173
175
  | `ENDPOINT_SHUT_DOWN` | An endpoint set by flag or config was shut down by its operator (the old preprod indexer). | `midnight_config_unset({ key: "indexer-ws" })` (and `node` if set), then retry. |
174
176
  | `OTHER_SDK_SET` | The process runs one SDK set's engine and the network runs on the other (an MCP server that served rc asked for stagenet). | Make the call in a process of its own: ask the user to start an MCP server for that network. |
175
- | `MIXED_SDK_LAYOUT` | mn was installed without its shrinkwrap (bun's installer): an engine's SDK packages reach more than one copy of its ledger. | Ask the user to install mn with npm. |
177
+ | `MIXED_SDK_LAYOUT` | mn's packages were installed without each engine's shrinkwrap (bun's installer): an engine's SDK tree isn't the one it was tested with. | Ask the user to install mn with npm. |
176
178
  | `NO_STATE_ROOT` | The host gave mn no place to keep its state (a program's `createHost` without paths). | Give the host its paths (`createHost({ paths })`). |
177
179
  | `NO_PAYER` | A command that submits a transaction was called without a payer. | Give the call a payer. |
178
180
  | `COMMAND_FAILED` | A command ended with a non-zero exit code without throwing (an MCP test run whose tests failed); the message carries its result. | Read the command's result in the message. |
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "midnight-wallet-cli",
3
- "version": "0.6.0-rc.13",
3
+ "version": "0.6.0-rc.14",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "midnight-wallet-cli",
9
- "version": "0.6.0-rc.13",
9
+ "version": "0.6.0-rc.14",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
13
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
14
- "@kuiralabs/midnight-connect": "0.1.0-rc.2",
15
- "@kuiralabs/midnight-contract": "0.1.0-rc.2",
16
- "@kuiralabs/midnight-dev": "0.1.0-rc.2",
17
- "@kuiralabs/midnight-engine-beta": "0.1.0-rc.2",
18
- "@kuiralabs/midnight-engine-rc": "0.1.0-rc.2",
19
- "@kuiralabs/midnight-grant": "0.1.0-rc.2",
20
- "@kuiralabs/midnight-wallet": "0.1.0-rc.2",
12
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
13
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
14
+ "@kuiralabs/midnight-connect": "0.1.0-rc.3",
15
+ "@kuiralabs/midnight-contract": "0.1.0-rc.3",
16
+ "@kuiralabs/midnight-dev": "0.1.0-rc.3",
17
+ "@kuiralabs/midnight-engine-beta": "0.1.0-rc.3",
18
+ "@kuiralabs/midnight-engine-rc": "0.1.0-rc.3",
19
+ "@kuiralabs/midnight-grant": "0.1.0-rc.3",
20
+ "@kuiralabs/midnight-wallet": "0.1.0-rc.3",
21
21
  "@modelcontextprotocol/sdk": "^1.27.1"
22
22
  },
23
23
  "bin": {
@@ -104,9 +104,9 @@
104
104
  }
105
105
  },
106
106
  "node_modules/@kuiralabs/midnight-account": {
107
- "version": "0.2.0-rc.0",
108
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-account/-/midnight-account-0.2.0-rc.0.tgz",
109
- "integrity": "sha512-OgTQoh8QU7FYsc1SpdL8JZ36N86Lp+O53c7SZzNscQCGiOx8pU8a1TYWjk5GHlR1MSlEvg92yinXqO3Q7DSBiw==",
107
+ "version": "0.2.0-rc.1",
108
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-account/-/midnight-account-0.2.0-rc.1.tgz",
109
+ "integrity": "sha512-rioDrd6cSglnwZ6TMPzBqr3VUazax4+JKqmMTBlF9YdSFXiYssJkncr2Q1hYkYgUwEYYXZpSol6pkGeYlYdixw==",
110
110
  "license": "Apache-2.0",
111
111
  "dependencies": {
112
112
  "@noble/ciphers": "2.4.0",
@@ -119,12 +119,12 @@
119
119
  }
120
120
  },
121
121
  "node_modules/@kuiralabs/midnight-account-chain": {
122
- "version": "0.3.0-rc.2",
123
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-account-chain/-/midnight-account-chain-0.3.0-rc.2.tgz",
124
- "integrity": "sha512-Cu4G3p0g4JcEOCZtM6JwMsugqwtJmzaFz4HFB1//lOJjqYoqd1XYyNwUryLX1SvusPx9OjxQZvqCgDxcY66jDQ==",
122
+ "version": "0.3.0-rc.3",
123
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-account-chain/-/midnight-account-chain-0.3.0-rc.3.tgz",
124
+ "integrity": "sha512-2q1ocSUfjmflLcLnZ9rEWOq861VE1/GYUkyEjpvFmnP9SeRjctGBlRELUMKmlskuP4hjzH4F6DsQZtPJhOz6Dg==",
125
125
  "license": "Apache-2.0",
126
126
  "dependencies": {
127
- "@kuiralabs/midnight-account": "0.2.0-rc.0",
127
+ "@kuiralabs/midnight-account": "0.2.0-rc.1",
128
128
  "@scure/base": "2.0.0"
129
129
  },
130
130
  "engines": {
@@ -174,79 +174,79 @@
174
174
  }
175
175
  },
176
176
  "node_modules/@kuiralabs/midnight-chain": {
177
- "version": "0.1.0-rc.2",
177
+ "version": "0.1.0-rc.3",
178
178
  "license": "Apache-2.0",
179
179
  "dependencies": {
180
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
180
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
181
181
  "ws": "^8.19.0"
182
182
  },
183
183
  "engines": {
184
184
  "node": ">=22"
185
185
  },
186
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-chain/-/midnight-chain-0.1.0-rc.2.tgz",
187
- "integrity": "sha512-9zQefPXRJA8l9n7HyJxhwBd8g4gUeov09V7vrFDGizOP4DfrX1C4mhN0+EfUGCXJ7v/BMv5Rz1kZ42DP/1Oiqw=="
186
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-chain/-/midnight-chain-0.1.0-rc.3.tgz",
187
+ "integrity": "sha512-erUFVEQEstsScLsin6ko8enYQbJ19BVwO0Xl4IdBIniEV9zY3yiiJSqU7kwz7q5BdziGhpukrWJUmi2Gn8/HYw=="
188
188
  },
189
189
  "node_modules/@kuiralabs/midnight-cli-core": {
190
- "version": "0.1.0-rc.2",
190
+ "version": "0.1.0-rc.3",
191
191
  "license": "Apache-2.0",
192
192
  "engines": {
193
193
  "node": ">=22"
194
194
  },
195
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-cli-core/-/midnight-cli-core-0.1.0-rc.2.tgz",
196
- "integrity": "sha512-ZLBl+T8cHRCCfcY+KM9x+qnqg1qskzxC/209tDJcpWsWlx/Djj17vENIezF7+6laxolrMSs/1TZz33I1q6WVmw=="
195
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-cli-core/-/midnight-cli-core-0.1.0-rc.3.tgz",
196
+ "integrity": "sha512-23YdfurRfXOZhOr2mVr6ykp6XqORNeOB0wUhlGbknK9hUnM2qRUlFQSDohxls3tonJTBtNHRict31Nk/takPNg=="
197
197
  },
198
198
  "node_modules/@kuiralabs/midnight-connect": {
199
- "version": "0.1.0-rc.2",
199
+ "version": "0.1.0-rc.3",
200
200
  "license": "Apache-2.0",
201
201
  "dependencies": {
202
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
203
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
204
- "@kuiralabs/midnight-wallet": "0.1.0-rc.2",
202
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
203
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
204
+ "@kuiralabs/midnight-wallet": "0.1.0-rc.3",
205
205
  "ws": "^8.19.0"
206
206
  },
207
207
  "engines": {
208
208
  "node": ">=22"
209
209
  },
210
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-connect/-/midnight-connect-0.1.0-rc.2.tgz",
211
- "integrity": "sha512-II45AHtwt/VfptVjD57wrGiBIMEtTtUBIrm6eOcGTJa+QX0aGWLzIkqy/tq8zUbjkvikltHoFn5viV+wMXeFtw=="
210
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-connect/-/midnight-connect-0.1.0-rc.3.tgz",
211
+ "integrity": "sha512-YvFSOxe/w2uN48rZMlpXNh+3IwuSWpsfhDYm5Ek99XAnAjsyQJcP52htJ8IlUi/g5eGlOhnINICMuLniZgzNpA=="
212
212
  },
213
213
  "node_modules/@kuiralabs/midnight-contract": {
214
- "version": "0.1.0-rc.2",
214
+ "version": "0.1.0-rc.3",
215
215
  "license": "Apache-2.0",
216
216
  "dependencies": {
217
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
218
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
219
- "@kuiralabs/midnight-wallet": "0.1.0-rc.2"
217
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
218
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
219
+ "@kuiralabs/midnight-wallet": "0.1.0-rc.3"
220
220
  },
221
221
  "engines": {
222
222
  "node": ">=22"
223
223
  },
224
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-contract/-/midnight-contract-0.1.0-rc.2.tgz",
225
- "integrity": "sha512-f5iIWqGZETc2MW1E9UZvE2rjq9EfQcrDOpQKgPGG/VrZMjFadRCpuagiijxNBWfoGzF8tfX1heinVTD2A0q2GA=="
224
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-contract/-/midnight-contract-0.1.0-rc.3.tgz",
225
+ "integrity": "sha512-4tcjAzeTVHvXjmMfUrRWhDc6rIju00CilGvlbqW8m0atYhiVg1VWItEMeBygoaU8B4g6Wi0dDXQdKPos9KSrpw=="
226
226
  },
227
227
  "node_modules/@kuiralabs/midnight-dev": {
228
- "version": "0.1.0-rc.2",
228
+ "version": "0.1.0-rc.3",
229
229
  "license": "Apache-2.0",
230
230
  "dependencies": {
231
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
232
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
233
- "@kuiralabs/midnight-connect": "0.1.0-rc.2",
234
- "@kuiralabs/midnight-contract": "0.1.0-rc.2",
235
- "@kuiralabs/midnight-wallet": "0.1.0-rc.2"
231
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
232
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
233
+ "@kuiralabs/midnight-connect": "0.1.0-rc.3",
234
+ "@kuiralabs/midnight-contract": "0.1.0-rc.3",
235
+ "@kuiralabs/midnight-wallet": "0.1.0-rc.3"
236
236
  },
237
237
  "engines": {
238
238
  "node": ">=22"
239
239
  },
240
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-dev/-/midnight-dev-0.1.0-rc.2.tgz",
241
- "integrity": "sha512-zCj1lfCjVDu9vlnNBQP4flaJIz6B+BGLtGNUC3/ZNMLXuJg3HvWI8ERjukP7jRVIVaJRZCO9j5Cxzbejrq0gLQ=="
240
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-dev/-/midnight-dev-0.1.0-rc.3.tgz",
241
+ "integrity": "sha512-ZaOGuQ/0CZE2G1eZFheoNuhAflP5BJVltT5Qvla8LeY7nbKi6mY+QQSLp6qc3MWq1oAgC6nhBIY9sD43/0mCjg=="
242
242
  },
243
243
  "node_modules/@kuiralabs/midnight-engine-beta": {
244
- "version": "0.1.0-rc.2",
244
+ "version": "0.1.0-rc.3",
245
245
  "license": "Apache-2.0",
246
246
  "dependencies": {
247
- "@kuiralabs/midnight-account-chain": "0.3.0-rc.2",
248
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
249
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
247
+ "@kuiralabs/midnight-account-chain": "0.3.0-rc.3",
248
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
249
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
250
250
  "@midnight-ntwrk/compact-js": "2.5.5-rc.7",
251
251
  "@midnight-ntwrk/compact-runtime": "0.18.0-rc.1",
252
252
  "@midnight-ntwrk/midnight-js-contracts": "5.0.0-beta.6",
@@ -276,8 +276,8 @@
276
276
  "engines": {
277
277
  "node": ">=22"
278
278
  },
279
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-engine-beta/-/midnight-engine-beta-0.1.0-rc.2.tgz",
280
- "integrity": "sha512-osYmcO6+WDdn7HW8Sf/Npa4jyToKPnFYZ9SYArRVyRLR5lyIT60oAV0u7z/bD4ZYGpSoM+0vKBWDWLMmsCe7ww=="
279
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-engine-beta/-/midnight-engine-beta-0.1.0-rc.3.tgz",
280
+ "integrity": "sha512-YotLEWpVAB87R5PVhPUEC580pALOUiT8V24hJX19eQV8/X1uEZWkBmBEntA00StBQk5ncmJoenl0cu4DQN1keA=="
281
281
  },
282
282
  "node_modules/@kuiralabs/midnight-engine-beta/node_modules/@effect/platform": {
283
283
  "version": "0.96.3",
@@ -294,12 +294,12 @@
294
294
  }
295
295
  },
296
296
  "node_modules/@kuiralabs/midnight-engine-beta/node_modules/@kuiralabs/midnight-account-chain": {
297
- "version": "0.3.0-rc.2",
298
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-account-chain/-/midnight-account-chain-0.3.0-rc.2.tgz",
299
- "integrity": "sha512-Cu4G3p0g4JcEOCZtM6JwMsugqwtJmzaFz4HFB1//lOJjqYoqd1XYyNwUryLX1SvusPx9OjxQZvqCgDxcY66jDQ==",
297
+ "version": "0.3.0-rc.3",
298
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-account-chain/-/midnight-account-chain-0.3.0-rc.3.tgz",
299
+ "integrity": "sha512-2q1ocSUfjmflLcLnZ9rEWOq861VE1/GYUkyEjpvFmnP9SeRjctGBlRELUMKmlskuP4hjzH4F6DsQZtPJhOz6Dg==",
300
300
  "license": "Apache-2.0",
301
301
  "dependencies": {
302
- "@kuiralabs/midnight-account": "0.2.0-rc.0",
302
+ "@kuiralabs/midnight-account": "0.2.0-rc.1",
303
303
  "@scure/base": "2.0.0"
304
304
  },
305
305
  "engines": {
@@ -750,12 +750,12 @@
750
750
  }
751
751
  },
752
752
  "node_modules/@kuiralabs/midnight-engine-rc": {
753
- "version": "0.1.0-rc.2",
753
+ "version": "0.1.0-rc.3",
754
754
  "license": "Apache-2.0",
755
755
  "dependencies": {
756
- "@kuiralabs/midnight-account-chain": "0.3.0-rc.2",
757
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
758
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
756
+ "@kuiralabs/midnight-account-chain": "0.3.0-rc.3",
757
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
758
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
759
759
  "@midnight-ntwrk/compact-js": "3.0.0-rc.3",
760
760
  "@midnight-ntwrk/compact-runtime": "0.20.0",
761
761
  "@midnight-ntwrk/ledger-v8": "8.1.0",
@@ -778,38 +778,38 @@
778
778
  "engines": {
779
779
  "node": ">=22"
780
780
  },
781
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-engine-rc/-/midnight-engine-rc-0.1.0-rc.2.tgz",
782
- "integrity": "sha512-WepEyDHsO/mVRFcE2tp83T2y6Tw/QD5fQjJYXQwlxfUdeQXhvyWhepLV4sNY47DugguQnYwt0ztXQPfb9SUNzg=="
781
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-engine-rc/-/midnight-engine-rc-0.1.0-rc.3.tgz",
782
+ "integrity": "sha512-shQ0ZN0GZVufJL4KY4HLe2rmuojzIQNRiox3b+oFvIjrjELMmkxkT93of2zxpp9FE2TIXSGd3PH1cpKInCnHIg=="
783
783
  },
784
784
  "node_modules/@kuiralabs/midnight-grant": {
785
- "version": "0.1.0-rc.2",
785
+ "version": "0.1.0-rc.3",
786
786
  "license": "Apache-2.0",
787
787
  "dependencies": {
788
- "@kuiralabs/midnight-account": "0.2.0-rc.0",
789
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
790
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
791
- "@kuiralabs/midnight-contract": "0.1.0-rc.2",
792
- "@kuiralabs/midnight-wallet": "0.1.0-rc.2"
788
+ "@kuiralabs/midnight-account": "0.2.0-rc.1",
789
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
790
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
791
+ "@kuiralabs/midnight-contract": "0.1.0-rc.3",
792
+ "@kuiralabs/midnight-wallet": "0.1.0-rc.3"
793
793
  },
794
794
  "engines": {
795
795
  "node": ">=22"
796
796
  },
797
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-grant/-/midnight-grant-0.1.0-rc.2.tgz",
798
- "integrity": "sha512-+cHP9ODZGajSD7sJI9uOhLjcXNcmLTBXy2W9NDeDYZle9NzcMZBWaCL8C7iwoZQ6TxHhawhHxnY9liGEJfsYOA=="
797
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-grant/-/midnight-grant-0.1.0-rc.3.tgz",
798
+ "integrity": "sha512-GT8MTXPfJGITFBaCr28gjMtxgcV7j2LR152VLmOY9zZ3GA1rmo0O05GVyGbE93Wl3HSA4ks/O/JDWqGJd/XAGg=="
799
799
  },
800
800
  "node_modules/@kuiralabs/midnight-wallet": {
801
- "version": "0.1.0-rc.2",
801
+ "version": "0.1.0-rc.3",
802
802
  "license": "Apache-2.0",
803
803
  "dependencies": {
804
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
805
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
804
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
805
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
806
806
  "@scure/bip39": "^2.0.1"
807
807
  },
808
808
  "engines": {
809
809
  "node": ">=22"
810
810
  },
811
- "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-wallet/-/midnight-wallet-0.1.0-rc.2.tgz",
812
- "integrity": "sha512-NUVeie7wvtouz2oKX8FQagYDAaQTChzwre5cxfsY6dEIaeKe9OdSpj5s5yLFxFc4v9sTp5K4JoHZ8jUkmjAZcg=="
811
+ "resolved": "https://registry.npmjs.org/@kuiralabs/midnight-wallet/-/midnight-wallet-0.1.0-rc.3.tgz",
812
+ "integrity": "sha512-6RFbJGPe92mHEFDfFAdV8nCzmvtSTg19aIM7KAZQbkIXpFiUNPyqNz1sOAsLPF6MoZwDr8hkin8Ml3g48VFREA=="
813
813
  },
814
814
  "node_modules/@midnight-ntwrk/compact-js": {
815
815
  "version": "3.0.0-rc.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midnight-wallet-cli",
3
- "version": "0.6.0-rc.13",
3
+ "version": "0.6.0-rc.14",
4
4
  "type": "module",
5
5
  "description": "Git-style CLI wallet for the Midnight blockchain",
6
6
  "license": "Apache-2.0",
@@ -67,18 +67,19 @@
67
67
  "api-report": "node scripts/api-report.mjs write",
68
68
  "typecheck": "tsc --noEmit",
69
69
  "skill-docs": "tsx --conditions=midnight-cli-source scripts/write-skill-docs.ts",
70
- "readme-commands": "tsx --conditions=midnight-cli-source scripts/write-readme-commands.ts"
70
+ "readme-commands": "tsx --conditions=midnight-cli-source scripts/write-readme-commands.ts",
71
+ "package-readmes": "tsx --conditions=midnight-cli-source scripts/write-package-readmes.ts"
71
72
  },
72
73
  "dependencies": {
73
- "@kuiralabs/midnight-chain": "0.1.0-rc.2",
74
- "@kuiralabs/midnight-cli-core": "0.1.0-rc.2",
75
- "@kuiralabs/midnight-connect": "0.1.0-rc.2",
76
- "@kuiralabs/midnight-contract": "0.1.0-rc.2",
77
- "@kuiralabs/midnight-dev": "0.1.0-rc.2",
78
- "@kuiralabs/midnight-engine-beta": "0.1.0-rc.2",
79
- "@kuiralabs/midnight-engine-rc": "0.1.0-rc.2",
80
- "@kuiralabs/midnight-grant": "0.1.0-rc.2",
81
- "@kuiralabs/midnight-wallet": "0.1.0-rc.2",
74
+ "@kuiralabs/midnight-chain": "0.1.0-rc.3",
75
+ "@kuiralabs/midnight-cli-core": "0.1.0-rc.3",
76
+ "@kuiralabs/midnight-connect": "0.1.0-rc.3",
77
+ "@kuiralabs/midnight-contract": "0.1.0-rc.3",
78
+ "@kuiralabs/midnight-dev": "0.1.0-rc.3",
79
+ "@kuiralabs/midnight-engine-beta": "0.1.0-rc.3",
80
+ "@kuiralabs/midnight-engine-rc": "0.1.0-rc.3",
81
+ "@kuiralabs/midnight-grant": "0.1.0-rc.3",
82
+ "@kuiralabs/midnight-wallet": "0.1.0-rc.3",
82
83
  "@modelcontextprotocol/sdk": "^1.27.1"
83
84
  },
84
85
  "devDependencies": {
@@ -1,2 +0,0 @@
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,3 +0,0 @@
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};
@@ -1,208 +0,0 @@
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};
@@ -1,3 +0,0 @@
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};