@rohan-protocol/mcp 0.8.1 → 0.8.3

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
@@ -1,93 +1,92 @@
1
- # @rohan-protocol/mcp (v0.8.1)
1
+ # @rohan-protocol/mcp (v0.8.3)
2
2
 
3
- Official Model Context Protocol (MCP) server providing confidential state transitions, ledger inspection, and cryptographic audit tools for Claude Desktop, Cursor, Cline, and Gemini.
3
+ Local stdio Model Context Protocol server for handshake submission, ledger and history reads, identity status, and offline verification.
4
4
 
5
- [![Rohan Shield MCP server – quality and maintenance score on Glama](https://glama.ai/mcp/servers/rohan-protocol/sdk/badges/card.svg)](https://glama.ai/mcp/servers/rohan-protocol/sdk)
6
- [![Smithery Verified](https://img.shields.io/badge/Smithery-Verified-green?style=flat-square)](https://smithery.ai/servers/rohanprotocol/shield)
5
+ ## Install and configure
7
6
 
8
- ---
7
+ Start with Node.js using:
9
8
 
10
- ## 🛠️ The 4 MCP Tools
11
-
12
- ### 1. `rohan_execute_handshake` (Write / Settlement)
13
- Executes a confidential state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAM—never exposed on-chain or in model logs.
14
- * **Arguments:** `actionSummary` (non-empty string, required), `agentId` (string, optional when a local signer is configured), `confidentialPayload` (object, optional). If supplied with a signer, `agentId` must match its DID. The legacy `rohan_zk_handshake` tool name remains accepted.
15
-
16
- ### 2. `rohan_get_ledger_state` (Read / State Inspection)
17
- Reads the current anchored state of the Rohan Protocol smart contract on Midnight Preprod L1. Returns state root, block height, and last mined transaction hash from memory cache.
18
- * **Arguments:** None.
19
-
20
- ### 3. `rohan_get_transaction_history` (Read / Settlement History)
21
- Lists recent settlement transactions and receipts recorded by the relayer.
22
- * **Arguments:** `limit` (integer, optional — defaults to 10, maximum 50).
23
-
24
- ### 4. `rohan_verify_commitment` (Audit / Verify)
25
- Verifies a plaintext confidential payload against its canonical SHA-256 digest in local memory.
26
- * **Arguments:** `payload` (object, required), `expectedDigest` (string, required — accepts raw hex, `sha256:`, or `0x` prefixes). Supply the inner payload digest referenced in `actionSummary`, not the timestamp-salted outer on-chain `intentHash`.
27
-
28
- ---
9
+ ```bash
10
+ npx -y --package @rohan-protocol/mcp@0.8.3 rohan-shield
11
+ ```
29
12
 
30
- ## 🚀 Setup & Configuration
13
+ On first startup, the local server provisions an Ed25519 identity at `~/.rohan/agent-identity.json`. The directory and file use `0700` and `0600` permissions on POSIX systems. `ROHAN_AGENT_PRIVATE_KEY`, when set, overrides the file and must be a 32-byte seed encoded as 64 hexadecimal characters (optional `0x` prefix).
31
14
 
32
- ### Option A: Claude Desktop Setup
33
- Add this to your `claude_desktop_config.json`:
15
+ Example Claude Desktop or Cursor stdio entry:
34
16
 
35
17
  ```json
36
18
  {
37
19
  "mcpServers": {
38
20
  "rohan-shield": {
39
21
  "command": "npx",
40
- "args": ["-y", "@rohan-protocol/mcp@0.8.1"],
41
- "env": {
42
- "ROHAN_API_KEY": ""
43
- }
22
+ "args": ["-y", "--package", "@rohan-protocol/mcp@0.8.3", "rohan-shield"]
44
23
  }
45
24
  }
46
25
  }
47
26
  ```
48
27
 
49
- ### Option B: Cursor MCP Setup
50
- 1. Go to **Settings → Features → MCP**.
51
- 2. Click **Add New MCP Server**:
52
- * **Name:** `rohan-shield`
53
- * **Type:** `command`
54
- * **Command:** `npx -y @rohan-protocol/mcp@0.8.1`
55
-
56
- ### Option C: Remote MCP (Smithery / Cloud Agents)
57
- Connect directly to the hosted endpoint:
58
- * **Server Card:** `https://api.rohanprotocol.network/.well-known/mcp/server-card.json`
59
- * **JSON-RPC Endpoint:** `https://api.rohanprotocol.network/mcp`
60
-
61
- ### Local agent identity and signing (V-08)
62
- The local stdio server loads identity in this order:
63
-
64
- 1. `ROHAN_AGENT_PRIVATE_KEY`, if set, as a 32-byte Ed25519 seed encoded in
65
- exactly 64 hexadecimal characters (an optional `0x` prefix is accepted).
66
- Invalid configured values fail startup; they never fall back to another key.
67
- 2. The existing `~/.rohan/agent-identity.json` keystore, after checking its
68
- permissions and verifying that its DID matches the public key derived from
69
- the stored seed.
70
- 3. If no keystore exists, the server provisions one with exclusive,
71
- create-only semantics. It is stored as plaintext key material in the
72
- user-only file `~/.rohan/agent-identity.json`; the directory is restricted
73
- to `0700` and the file to `0600` on POSIX systems. Corrupt or mismatched
74
- existing files fail closed and are never silently replaced.
75
-
76
- With the local signer active, `agentId` may be omitted and the server supplies
77
- the signer's DID. If provided, it must exactly match. A non-empty
78
- `actionSummary` is always required; the `intent` property is deprecated and
79
- cannot replace it. The DID is reported at startup so operators can record it
80
- for their agent configuration.
81
-
82
- Protect and back up the keystore as a secret. Deleting it provisions a new key
83
- and therefore a new DID; restoring it preserves the identity. Never put key
84
- material in tool arguments, prompts, source control, or logs. JavaScript and
85
- WebCrypto cannot guarantee erasure of all in-memory key copies. A `did:key`
86
- proves control of a key, not a real-world identity, and the relayer must enforce
87
- signature verification for server-side authentication.
88
-
89
- ---
90
-
91
- ## 📜 License
28
+ Never put private keys in tool arguments, prompts, source control, or logs. A `did:key` proves control of a key, not a real-world identity.
29
+
30
+ ## MCP tools
31
+
32
+ The server exposes five tools, each with MCP `annotations`:
33
+
34
+ | Tool | Purpose | Annotation hints |
35
+ | --- | --- | --- |
36
+ | `rohan_execute_handshake` | Submit a handshake; `actionSummary` is required. With a local signer, `agentId` defaults to its DID and must match if supplied. | `readOnlyHint: false`, `idempotentHint: false` |
37
+ | `rohan_get_ledger_state` | Read current contract state from the relayer. | Read-only, idempotent |
38
+ | `rohan_get_transaction_history` | Read settlement history; optional `limit` (default 10, maximum 50). | Read-only, idempotent |
39
+ | `rohan_verify_commitment` | Verify a plaintext digest and/or a portable audit bundle locally. | Read-only, idempotent, `openWorldHint: false` |
40
+ | `rohan_get_agent_status` | Report local identity metadata and relayer reachability. | Read-only, idempotent |
41
+
42
+ The legacy tool name `rohan_zk_handshake` remains accepted by the handler. Every tool description includes `Usage guidelines:` describing routing, privacy, and recovery. `rohan_verify_commitment` accepts `auditBundle` with an optional plaintext payload, or `expectedDigest` together with a payload. Verify against the inner `payloadDigest`, not the outer timestamp-salted `intentHash`.
43
+
44
+ `rohan_execute_handshake` accepts optional `dryRun: true` only when the user asks to preview, test, or inspect a commitment without settling on-chain. The default is `false`. A dry run runs the firewall and local identity checks, canonicalizes and hashes in process memory, and returns the signed `commitment`, `payloadDigest` (when present), and `intentHash` with `settledOnChain: false`. It makes no relayer request and returns no fake `txHash`.
45
+
46
+ ## Resource and agent instructions
47
+
48
+ - **Resource:** `rohan://identity` returns identity metadata, signing mode, configured network, contract, and relayer URL. It never includes private key material.
49
+ - **Instructions:** `ROHAN_MCP_INSTRUCTIONS` is sent in the MCP initialization response. It describes the privacy boundary, local identity handling, status checks, audit verification, and recovery guidance for replay, timestamp, signature, and identity errors.
50
+
51
+ ## CLI
52
+
53
+ The same executable provides:
54
+
55
+ ```text
56
+ npx -y --package @rohan-protocol/mcp@0.8.3 rohan-shield init
57
+ npx -y --package @rohan-protocol/mcp@0.8.3 rohan-shield status
58
+ npx -y --package @rohan-protocol/mcp@0.8.3 rohan-shield verify <payload.json> <audit-bundle.json|sha256-digest>
59
+ npx -y --package @rohan-protocol/mcp@0.8.3 rohan-shield --help
60
+ ```
61
+
62
+ The executable names are `rohan-shield` and `rohan-mcp`; no generic `mcp` binary is installed. A no-argument invocation starts the stdio JSON-RPC server. In an interactive terminal it prints a brief usage hint to stderr; stdout remains reserved for MCP JSON-RPC.
63
+
64
+ `init` provisions or verifies the identity and prints an MCP configuration snippet. `status` checks the existing identity without creating a keystore and queries relayer state. `verify` performs offline audit-bundle or digest verification.
65
+
66
+ ## Remote MCP
67
+
68
+ The separately hosted **Remote HTTP MCP** endpoint is `https://api.rohanprotocol.network/mcp` and runs in a hosted sandbox. This package starts **Local Stdio MCP**, where hashing and signing happen in local process memory.
69
+
70
+ ## Local hashing, environment, and transaction verification
71
+
72
+ For confidential data, local hashing uses `payloadDigest = SHA-256(UTF-8(JCS(confidentialPayload)))`, with RFC 8785 JCS. The sealed action summary includes that inner digest. The outer `intentHash` is SHA-256 of the UTF-8 witness `agentId:sealedActionSummary:{}:timestamp`. It is computed locally and is not interchangeable with `payloadDigest`.
73
+
74
+ | Variable | Purpose |
75
+ | --- | --- |
76
+ | `ROHAN_RELAYER_URL` | Relayer handshake URL; set this to self-host. |
77
+ | `ROHAN_NETWORK` | `preprod`, `testnet`, or `mainnet` (default: `preprod`). |
78
+ | `ROHAN_CONTRACT_ADDRESS` | Target Midnight contract (default: configured Preprod contract). |
79
+ | `ROHAN_AGENT_PRIVATE_KEY` | Optional 64-hex-character Ed25519 seed; overrides the local keystore. Keep in a secret store. |
80
+ | `ROHAN_API_KEY` | Optional relayer API key. |
81
+
82
+ Verify a settlement independently using the Midnight Preprod Indexer v4 GraphQL API, without Rohan's relayer. Strip any leading `0x` from `txHash`:
83
+
84
+ ```bash
85
+ curl -sS -X POST 'https://midnight-preprod.blockfrost.io/api/v0?project_id=<YOUR_BLOCKFROST_TOKEN>' \
86
+ -H 'content-type: application/json' \
87
+ --data '{"query":"{ transactions(offset: { hash: \"<TX_HASH_WITHOUT_0x>\" }) { hash protocolVersion block { height hash } } }"}'
88
+ ```
89
+
90
+ ## License
92
91
 
93
92
  Apache-2.0
package/dist/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export interface CliIo {
2
+ stdout: (line: string) => void;
3
+ stderr: (line: string) => void;
4
+ }
5
+ export declare function runCli(argv: string[], io?: CliIo): Promise<number>;
6
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AA6SD,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAE,KAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BpF"}
package/dist/cli.js ADDED
@@ -0,0 +1,304 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { RohanClient, computePayloadDigest, verifyAuditBundle, } from '@rohan-protocol/sdk';
5
+ import { KeystoreResolutionError, loadKeystoreFile, resolveAgentIdentity, } from './identity/keystore.js';
6
+ import { ROHAN_MCP_VERSION } from './mcp-app.js';
7
+ const DEFAULT_IO = {
8
+ stdout: (line) => process.stdout.write(line + '\n'),
9
+ stderr: (line) => process.stderr.write(line + '\n'),
10
+ };
11
+ function resolveConfiguredNetwork() {
12
+ const raw = (process.env.ROHAN_NETWORK || 'preprod').trim().toLowerCase();
13
+ if (raw !== 'preprod' && raw !== 'testnet' && raw !== 'mainnet') {
14
+ throw new Error(`INVALID_CONFIGURATION: Unsupported ROHAN_NETWORK "${raw}". Expected preprod, testnet, or mainnet.`);
15
+ }
16
+ return raw;
17
+ }
18
+ function defaultKeystorePath() {
19
+ return path.join(os.homedir(), '.rohan', 'agent-identity.json');
20
+ }
21
+ function printUsage(io, target = 'stdout') {
22
+ const write = io[target];
23
+ write(`Rohan Protocol MCP & Sovereign Identity CLI (v${ROHAN_MCP_VERSION})`);
24
+ write('');
25
+ write('Usage:');
26
+ write(' rohan-shield Start MCP server over stdio (default, no arguments)');
27
+ write(' rohan-shield init Provision/verify local Ed25519 identity & print MCP config');
28
+ write(' rohan-shield status Show active DID, keystore state & live relayer reachability');
29
+ write(' rohan-shield verify <payload.json> <bundle.json|digest>');
30
+ write(' Offline cryptographic audit of payload vs bundle or SHA-256');
31
+ write(' rohan-shield --help Show this help message');
32
+ }
33
+ async function withTimeout(promise, timeoutMs, message) {
34
+ let timeout;
35
+ try {
36
+ return await Promise.race([
37
+ promise,
38
+ new Promise((_, reject) => {
39
+ timeout = setTimeout(() => reject(new Error(message)), timeoutMs);
40
+ }),
41
+ ]);
42
+ }
43
+ finally {
44
+ if (timeout)
45
+ clearTimeout(timeout);
46
+ }
47
+ }
48
+ async function handleInit(io) {
49
+ try {
50
+ const loaded = await resolveAgentIdentity();
51
+ try {
52
+ const network = resolveConfiguredNetwork();
53
+ const relayerUrl = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
54
+ io.stdout(`🛡️ Rohan Sovereign Agent Identity ready (${loaded.source})`);
55
+ io.stdout(` • Agent DID: ${loaded.did}`);
56
+ io.stdout(` • Network: midnight-${network}`);
57
+ if (loaded.filePath) {
58
+ io.stdout(` • Keystore: ${loaded.filePath} (permissions: 0600, private key kept offline)`);
59
+ }
60
+ else {
61
+ io.stdout(' • Source: ROHAN_AGENT_PRIVATE_KEY environment variable');
62
+ }
63
+ const mcpEntry = {
64
+ command: 'npx',
65
+ args: ['-y', '--package', `@rohan-protocol/mcp@${ROHAN_MCP_VERSION}`, 'rohan-shield'],
66
+ };
67
+ if (network !== 'preprod' || relayerUrl !== 'https://api.rohanprotocol.network/api/v1/handshake') {
68
+ mcpEntry.env = {
69
+ ...(network !== 'preprod' ? { ROHAN_NETWORK: network } : {}),
70
+ ...(relayerUrl !== 'https://api.rohanprotocol.network/api/v1/handshake'
71
+ ? { ROHAN_RELAYER_URL: relayerUrl }
72
+ : {}),
73
+ };
74
+ }
75
+ const configSnippet = {
76
+ mcpServers: {
77
+ 'rohan-shield': mcpEntry,
78
+ },
79
+ };
80
+ io.stdout('');
81
+ io.stdout('📋 Claude Desktop / Cursor MCP Config (copy & paste):');
82
+ io.stdout(JSON.stringify(configSnippet, null, 2));
83
+ if (loaded.source === 'env') {
84
+ io.stdout('');
85
+ io.stdout('ℹ️ Note: ROHAN_AGENT_PRIVATE_KEY is active in this shell; ensure it is set in your MCP host env if you want to override ~/.rohan/agent-identity.json.');
86
+ }
87
+ return 0;
88
+ }
89
+ finally {
90
+ if (typeof loaded.signer.destroy === 'function') {
91
+ loaded.signer.destroy();
92
+ }
93
+ }
94
+ }
95
+ catch (err) {
96
+ io.stderr(`❌ Initialization failed: ${err?.message || err}`);
97
+ return 1;
98
+ }
99
+ }
100
+ async function handleStatus(io) {
101
+ let network;
102
+ try {
103
+ network = resolveConfiguredNetwork();
104
+ }
105
+ catch (err) {
106
+ io.stderr(`❌ Configuration error: ${err?.message || err}`);
107
+ return 1;
108
+ }
109
+ const relayerUrl = process.env.ROHAN_RELAYER_URL || 'https://api.rohanprotocol.network/api/v1/handshake';
110
+ const contractAddress = process.env.ROHAN_CONTRACT_ADDRESS ||
111
+ '585ac0c4448257507d8ffa2a89e2aa00abd86ec9e94bdb6f553bc83e05f4dd0e';
112
+ let agentDid = null;
113
+ let identityStatus = 'not-initialized';
114
+ let keystorePath = null;
115
+ const envHex = process.env.ROHAN_AGENT_PRIVATE_KEY?.trim();
116
+ if (envHex) {
117
+ try {
118
+ const loaded = await resolveAgentIdentity({ privateKeyHex: envHex });
119
+ agentDid = loaded.did;
120
+ identityStatus = 'env (ROHAN_AGENT_PRIVATE_KEY)';
121
+ if (typeof loaded.signer.destroy === 'function') {
122
+ loaded.signer.destroy();
123
+ }
124
+ }
125
+ catch (err) {
126
+ io.stderr(`❌ Invalid ROHAN_AGENT_PRIVATE_KEY: ${err?.message || err}`);
127
+ return 1;
128
+ }
129
+ }
130
+ else {
131
+ const targetPath = defaultKeystorePath();
132
+ keystorePath = targetPath;
133
+ let exists = false;
134
+ try {
135
+ // Read-only lstat check so 'status' never creates ~/.rohan on uninitialized machines
136
+ fs.lstatSync(targetPath);
137
+ exists = true;
138
+ }
139
+ catch (err) {
140
+ if (err?.code !== 'ENOENT') {
141
+ io.stderr(`❌ Could not inspect keystore "${targetPath}": ${err?.message || err}`);
142
+ return 1;
143
+ }
144
+ }
145
+ if (exists) {
146
+ try {
147
+ const signer = await loadKeystoreFile(targetPath);
148
+ agentDid = signer.did;
149
+ identityStatus = 'filesystem (verified)';
150
+ signer.destroy();
151
+ }
152
+ catch (err) {
153
+ const msg = err instanceof KeystoreResolutionError ? err.message : String(err?.message || err);
154
+ io.stderr(`❌ Keystore verification failed: ${msg}`);
155
+ return 1;
156
+ }
157
+ }
158
+ }
159
+ // Match RohanClient.getLedgerState's 8s request timeout with a small buffer.
160
+ const client = new RohanClient({
161
+ network,
162
+ contractAddress,
163
+ relayerUrl,
164
+ apiKey: process.env.ROHAN_API_KEY || '',
165
+ });
166
+ let relayerHealthy = false;
167
+ let blockHeight = null;
168
+ let stateRoot = null;
169
+ let relayerError = null;
170
+ try {
171
+ const state = await withTimeout(client.getLedgerState(), 8500, 'Timed out after 8500ms');
172
+ relayerHealthy = true;
173
+ blockHeight = state.blockHeight ?? null;
174
+ stateRoot = state.currentStateRoot ?? null;
175
+ }
176
+ catch (err) {
177
+ relayerError = err?.message || 'Unreachable';
178
+ }
179
+ io.stdout(`🛡️ Rohan Protocol Status (v${ROHAN_MCP_VERSION})`);
180
+ io.stdout(` • Identity: ${agentDid ?? 'Not initialized (run "rohan-shield init" to provision)'}`);
181
+ io.stdout(` • Source: ${identityStatus}`);
182
+ if (keystorePath) {
183
+ io.stdout(` • Keystore Path: ${keystorePath}`);
184
+ }
185
+ io.stdout(` • Network: midnight-${network}`);
186
+ io.stdout(` • Contract: ${contractAddress}`);
187
+ io.stdout(` • Relayer: ${relayerHealthy ? 'ONLINE' : `OFFLINE (${relayerError})`}`);
188
+ if (relayerHealthy) {
189
+ io.stdout(` • Block Height: ${blockHeight ?? 'n/a'}`);
190
+ io.stdout(` • State Root: ${stateRoot ?? 'n/a'}`);
191
+ }
192
+ return 0;
193
+ }
194
+ function constantTimeHexEqual(a, b) {
195
+ if (a.length !== b.length)
196
+ return false;
197
+ let diff = 0;
198
+ for (let i = 0; i < a.length; i++) {
199
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
200
+ }
201
+ return diff === 0;
202
+ }
203
+ async function handleVerify(args, io) {
204
+ if (args.length < 2) {
205
+ io.stderr('❌ Usage: rohan-shield verify <payload.json> <audit-bundle.json|sha256-digest>');
206
+ return 1;
207
+ }
208
+ const [payloadPath, target] = args;
209
+ let payloadRaw;
210
+ try {
211
+ payloadRaw = fs.readFileSync(payloadPath, 'utf8');
212
+ }
213
+ catch (err) {
214
+ io.stderr(`❌ FILE_NOT_FOUND: Could not read payload file "${payloadPath}": ${err?.message || err}`);
215
+ return 1;
216
+ }
217
+ let payloadObj;
218
+ try {
219
+ payloadObj = JSON.parse(payloadRaw);
220
+ }
221
+ catch (err) {
222
+ io.stderr(`❌ INVALID_JSON: Payload file "${payloadPath}" is not valid JSON: ${err?.message || err}`);
223
+ return 1;
224
+ }
225
+ if (!payloadObj || typeof payloadObj !== 'object' || Array.isArray(payloadObj)) {
226
+ io.stderr('❌ INVALID_PAYLOAD: Plaintext payload file must contain a JSON object.');
227
+ return 1;
228
+ }
229
+ const payload = payloadObj;
230
+ // Distinguish between a file path and a digest string
231
+ const looksLikePath = target.endsWith('.json') || target.includes('/') || target.includes('\\') || fs.existsSync(target);
232
+ if (looksLikePath) {
233
+ if (!fs.existsSync(target)) {
234
+ io.stderr(`❌ FILE_NOT_FOUND: Audit bundle file "${target}" does not exist.`);
235
+ return 1;
236
+ }
237
+ let bundleObj;
238
+ try {
239
+ bundleObj = JSON.parse(fs.readFileSync(target, 'utf8'));
240
+ }
241
+ catch (err) {
242
+ io.stderr(`❌ INVALID_JSON: Bundle file "${target}" is not valid JSON: ${err?.message || err}`);
243
+ return 1;
244
+ }
245
+ const result = await verifyAuditBundle(bundleObj, payload);
246
+ io.stdout(result.valid ? '✅ AUDIT RESULT: VALID (Offline Cryptographic Verification Passed)' : '❌ AUDIT RESULT: INVALID / TAMPERED');
247
+ io.stdout(` • Schema Valid: ${result.schemaValid}`);
248
+ io.stdout(` • Payload Match: ${result.payloadMatch}`);
249
+ io.stdout(` • Intent Binding Valid: ${result.intentBindingValid}`);
250
+ io.stdout(` • Ed25519 Signature: ${result.signatureValid === null ? 'unsigned (no identityProof)' : result.signatureValid}`);
251
+ if (bundleObj?.agentDid)
252
+ io.stdout(` • Agent DID: ${bundleObj.agentDid}`);
253
+ if (bundleObj?.txHash)
254
+ io.stdout(` • L1 TxHash: ${bundleObj.txHash}`);
255
+ if (result.errors.length > 0) {
256
+ io.stderr(` • Errors: ${result.errors.join(' | ')}`);
257
+ }
258
+ return result.valid ? 0 : 1;
259
+ }
260
+ // Raw SHA-256 digest mode
261
+ const cleanExpected = target.replace(/^(?:sha256:|0x)/i, '').toLowerCase();
262
+ if (!/^[0-9a-f]{64}$/.test(cleanExpected)) {
263
+ io.stderr('❌ INVALID_DIGEST: Expected a valid audit-bundle.json path or 64-character SHA-256 hex digest.');
264
+ return 1;
265
+ }
266
+ try {
267
+ const computed = await computePayloadDigest(payload);
268
+ const computedHex = computed.slice('sha256:'.length);
269
+ const match = constantTimeHexEqual(computedHex, cleanExpected);
270
+ io.stdout(match ? '✅ DIGEST MATCH: VALID (RFC 8785 JCS + SHA-256)' : '❌ DIGEST MISMATCH: INVALID / TAMPERED');
271
+ io.stdout(` • Expected: ${cleanExpected}`);
272
+ io.stdout(` • Computed: ${computedHex}`);
273
+ return match ? 0 : 1;
274
+ }
275
+ catch (err) {
276
+ io.stderr(`❌ VERIFICATION_ERROR: ${err?.message || err}`);
277
+ return 1;
278
+ }
279
+ }
280
+ export async function runCli(argv, io = DEFAULT_IO) {
281
+ const [command, ...rest] = argv;
282
+ if (command === '--help' || command === '-h' || command === 'help') {
283
+ printUsage(io, 'stdout');
284
+ return 0;
285
+ }
286
+ if (command === '--version' || command === '-v') {
287
+ io.stdout(ROHAN_MCP_VERSION);
288
+ return 0;
289
+ }
290
+ if (command === 'init') {
291
+ return handleInit(io);
292
+ }
293
+ if (command === 'status') {
294
+ return handleStatus(io);
295
+ }
296
+ if (command === 'verify') {
297
+ return handleVerify(rest, io);
298
+ }
299
+ io.stderr(`❌ UNKNOWN_COMMAND: "${command}" is not a recognized subcommand.`);
300
+ io.stderr('');
301
+ printUsage(io, 'stderr');
302
+ return 1;
303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AI,OAAO,KAAK,WAAW,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAChD,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC7B,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,EAAE,CAAC,MAAM,CAAC,uBAAuB,OAAO,mCAAmC,CAAC,CAAC;IAC7E,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACd,UAAU,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACzB,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { AgentSigner } from '@rohan-protocol/sdk';
2
2
  export declare const ROHAN_HANDSHAKE_TOOL_SCHEMA: {
3
3
  readonly name: "rohan_execute_handshake";
4
- readonly description: "Executes a confidential zero-knowledge state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAM—never exposed on-chain or in model logs.";
4
+ readonly description: "Executes or locally previews a confidential handshake commitment on Midnight. Usage guidelines:\n- Use for a user-authorized settlement; set dryRun: true only when the user asks to preview, test, or inspect a commitment without on-chain settlement (default false).\n- Do not use for reads, history, status, or audit; use rohan_get_ledger_state, rohan_get_transaction_history, rohan_get_agent_status, or rohan_verify_commitment instead.\n- Keep sensitive values in confidentialPayload, actionSummary generic, and private keys out of tool arguments. Follow recoveryAction on errors; after replay check transaction history, and after signature errors check agent status. Payloads are canonicalized and hashed locally.";
5
5
  readonly inputSchema: {
6
6
  readonly type: "object";
7
7
  readonly properties: {
@@ -22,6 +22,10 @@ export declare const ROHAN_HANDSHAKE_TOOL_SCHEMA: {
22
22
  readonly type: "string";
23
23
  readonly description: "Optional counterparty agent identifier.";
24
24
  };
25
+ readonly dryRun: {
26
+ readonly type: "boolean";
27
+ readonly description: "Only set true when the user asks to preview, test, or inspect the commitment without settling on-chain. Defaults to false.";
28
+ };
25
29
  readonly intent: {
26
30
  readonly type: "string";
27
31
  readonly deprecated: true;
@@ -1 +1 @@
1
- {"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/identity/handshake.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC9B,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKxE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAe5F;AAED,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,OAAO,EACzB,MAAM,CAAC,EAAE,WAAW,GACnB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAiBzC"}
1
+ {"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/identity/handshake.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqC9B,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKxE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CA2B5F;AAED,wBAAgB,uBAAuB,CACrC,gBAAgB,EAAE,OAAO,EACzB,MAAM,CAAC,EAAE,WAAW,GACnB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAiBzC"}
@@ -1,6 +1,6 @@
1
1
  export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
2
2
  name: 'rohan_execute_handshake',
3
- description: 'Executes a confidential zero-knowledge state transition on Midnight Blockchain. Confidential parameters are automatically canonicalized (RFC 8785) and hashed in client RAM—never exposed on-chain or in model logs.',
3
+ description: 'Executes or locally previews a confidential handshake commitment on Midnight. Usage guidelines:\n- Use for a user-authorized settlement; set dryRun: true only when the user asks to preview, test, or inspect a commitment without on-chain settlement (default false).\n- Do not use for reads, history, status, or audit; use rohan_get_ledger_state, rohan_get_transaction_history, rohan_get_agent_status, or rohan_verify_commitment instead.\n- Keep sensitive values in confidentialPayload, actionSummary generic, and private keys out of tool arguments. Follow recoveryAction on errors; after replay check transaction history, and after signature errors check agent status. Payloads are canonicalized and hashed locally.',
4
4
  inputSchema: {
5
5
  type: 'object',
6
6
  properties: {
@@ -21,6 +21,10 @@ export const ROHAN_HANDSHAKE_TOOL_SCHEMA = {
21
21
  type: 'string',
22
22
  description: 'Optional counterparty agent identifier.',
23
23
  },
24
+ dryRun: {
25
+ type: 'boolean',
26
+ description: 'Only set true when the user asks to preview, test, or inspect the commitment without settling on-chain. Defaults to false.',
27
+ },
24
28
  intent: {
25
29
  type: 'string',
26
30
  deprecated: true,
@@ -43,6 +47,7 @@ export function validateHandshakeArguments(args) {
43
47
  'agentId',
44
48
  'confidentialPayload',
45
49
  'counterpartyId',
50
+ 'dryRun',
46
51
  'intent',
47
52
  ]);
48
53
  if (Object.keys(args).some((key) => !allowedProperties.has(key))) {
@@ -51,6 +56,15 @@ export function validateHandshakeArguments(args) {
51
56
  if (args.intent !== undefined && typeof args.intent !== 'string') {
52
57
  return 'INVALID_ARGUMENTS: Deprecated intent must be a string when provided.';
53
58
  }
59
+ if (args.dryRun !== undefined && typeof args.dryRun !== 'boolean') {
60
+ return 'INVALID_ARGUMENTS: dryRun must be a boolean when provided.';
61
+ }
62
+ if (args.confidentialPayload !== undefined &&
63
+ (!args.confidentialPayload ||
64
+ typeof args.confidentialPayload !== 'object' ||
65
+ Array.isArray(args.confidentialPayload))) {
66
+ return 'INVALID_ARGUMENTS: confidentialPayload must be a non-null JSON object when provided.';
67
+ }
54
68
  return validateActionSummary(args.actionSummary);
55
69
  }
56
70
  export function resolveHandshakeAgentId(requestedAgentId, signer) {
@@ -1 +1 @@
1
- {"version":3,"file":"handshake.js","sourceRoot":"","sources":["../../src/identity/handshake.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EACT,sNAAsN;IACxN,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,aAAa,EAAE;gBACb,IAAI,EAAE,QAAQ;gBACd,SAAS,EAAE,CAAC;gBACZ,WAAW,EAAE,0CAA0C;aACxD;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mGAAmG;aACjH;YACD,mBAAmB,EAAE;gBACnB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qEAAqE;aACnF;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yCAAyC;aACvD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,IAAI;gBAChB,WAAW,EAAE,mDAAmD;aACjE;SACF;QACD,QAAQ,EAAE,CAAC,eAAe,CAAC;QAC3B,oBAAoB,EAAE,KAAK;KAC5B;CACO,CAAC;AAEX,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK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