@gvnrdao/dh-mcp 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,13 +11,13 @@ so there is **nothing to install first** (no Node, no npm):
11
11
 
12
12
  | You are on | Install path |
13
13
  |---|---|
14
- | **Claude Desktop (macOS / Windows)** | Download the bundle and open it (double-click / drag into Settings → Extensions): `https://assets.gvnr.xyz/dh-mcp/v0.3.1/dh-mcp-0.3.1.mcpb` — Claude Desktop runs it on its own embedded runtime; network and optional keystore are configured in the extension's settings UI (the password is held by the OS credential store, never written to a config file). |
15
- | **Linux — including Claude Desktop builds on Linux — or any other MCP host** | One line, no sudo: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| sh` — installs a self-contained binary (its own Node runtime inside) to `~/.dh-mcp/bin/dh-mcp`, verifies its SHA-256, and prints the exact `mcpServers` snippet. **Then wire the host:** Claude Code: `claude mcp add diamond-hands -- $HOME/.dh-mcp/bin/dh-mcp` (new session); Claude Desktop (Linux builds): the snippet in `~/.config/Claude/claude_desktop_config.json`, full quit + relaunch; other hosts: the snippet in their MCP config. Pin a version: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| DH_VERSION=0.3.1 sh` |
14
+ | **Claude Desktop (macOS / Windows)** | Download the bundle and open it (double-click / drag into Settings → Extensions): `https://assets.gvnr.xyz/dh-mcp/v0.5.0/dh-mcp-0.5.0.mcpb` — Claude Desktop runs it on its own embedded runtime; network and optional keystore are configured in the extension's settings UI (the password is held by the OS credential store, never written to a config file). |
15
+ | **Linux — including Claude Desktop builds on Linux — or any other MCP host** | One line, no sudo: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| sh` — installs a self-contained binary (its own Node runtime inside) to `~/.dh-mcp/bin/dh-mcp`, verifies its SHA-256, and prints the exact `mcpServers` snippet. **Then wire the host:** Claude Code: `claude mcp add diamond-hands -- $HOME/.dh-mcp/bin/dh-mcp` (new session); Claude Desktop (Linux builds): the snippet in `~/.config/Claude/claude_desktop_config.json`, full quit + relaunch; other hosts: the snippet in their MCP config. Pin a version: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| DH_VERSION=0.5.0 sh` |
16
16
  | **Developers** (requires **Node ≥ 18 on PATH** — this path does NOT work on a bare machine) | Claude Code: `claude mcp add diamond-hands -- npx -y @gvnrdao/dh-mcp` · any host JSON: `{ "mcpServers": { "diamond-hands": { "command": "npx", "args": ["-y", "@gvnrdao/dh-mcp"] } } }` |
17
17
 
18
18
  Downloads landing page (which file is for which system, checksums, security notes):
19
19
  **https://assets.gvnr.xyz/dh-mcp/** — all artifacts and `SHA256SUMS` live under it
20
- (`latest/` and `v<version>/` — e.g. `v0.3.1/`).
20
+ (`latest/` and `v<version>/` — e.g. `v0.5.0/`).
21
21
 
22
22
  Local installs serve local MCP hosts only — **claude.ai web / mobile / Cowork cannot
23
23
  reach them** (a hosted remote connector is a separate, upcoming tier).
@@ -42,7 +42,7 @@ overridable by environment variables:
42
42
  | Variable | Default | Meaning |
43
43
  |---|---|---|
44
44
  | `DH_ADAPTER` | `real` | `real` protocol, or `mock` (offline practice sandbox; needs `DH_MOCK_DB` + `DH_MOCK_LATENCY`) |
45
- | `DH_NETWORK` | `sepolia` | `sepolia` or `mainnet` (mainnet reads work; mainnet writes are disabled unless the operator explicitly arms them) |
45
+ | `DH_NETWORK` | `sepolia` | `sepolia` (practice) or `mainnet` (REAL money — reads and writes both work out of the box) |
46
46
  | `ETH_RPC_URL` | public node per network | your own RPC if preferred |
47
47
  | `DH_SERVICE_ENDPOINT` | per network | Diamond Hands ops service |
48
48
  | `DH_KEYSTORE_PATH` + `DH_KEYSTORE_PASSWORD` | unset | optional: encrypted keystore for automatic signing (both or neither) |
@@ -56,8 +56,8 @@ paste-code) or a local encrypted keystore. Safe smart-account and delegation mod
56
56
 
57
57
  | Network | Reads (public) | Reads (authenticated) | Writes |
58
58
  |---|---|---|---|
59
- | **sepolia** (default — the real protocol, practice money) | always, no setup | after a login: keystore env pair, or "connect my wallet" (`signer_setup`) | signer modes **keystore** and **external** (your own wallet). External-mode BTC withdrawal is not shipped yet — it refuses with that true reason; keystore withdrawal works |
60
- | **mainnet** (real money) | always (indexer gaps are reported honestly) | after a login (the broker throttles logins per address) | **disabled unless the operator explicitly arms them**; PSM writes refuse regardless |
59
+ | **sepolia** (default — the real protocol, practice money) | always, no setup | after a login: keystore env pair, or "connect my wallet" (`signer_setup`) | signer modes **keystore** and **external** (your own wallet). External-mode BTC withdrawal signs the SDK's bare auth hashes **blind** — same as the web app; the approval page says so loudly |
60
+ | **mainnet** (real money) | always (indexer gaps are reported honestly) | after a login (the broker throttles logins per address) | signer modes **keystore** and **external**, same as sepolia — every operation moves REAL funds behind your confirmation + signature; PSM writes refuse (sepolia-only) |
61
61
  | **mock** (`DH_ADAPTER=mock` — offline practice sandbox) | always | always | all modes, including the simulated Safe and delegation planes |
62
62
 
63
63
  Signer modes `safe` and `safe-module` (Safe smart-account borrower, delegation) are
@@ -73,8 +73,8 @@ refuses legibly, and the user says "connect my wallet" (`signer_setup` action `c
73
73
  - The approval bridge listens on **loopback only** (127.0.0.1, token-gated).
74
74
  - Every fund-moving call requires your explicit confirmation AND a real signature; the
75
75
  card you sign is decoded from the exact transaction — never re-formatted.
76
- - **Mainnet writes are disabled unless the operator explicitly arms them**; PSM mainnet
77
- writes refuse regardless.
76
+ - **Mainnet operations move real funds** — they run only behind your explicit
77
+ confirmation plus a real signature you approve; PSM mainnet writes refuse (sepolia-only).
78
78
 
79
79
  ## What it solves
80
80
 
@@ -151,12 +151,12 @@ diagrams, data contracts, scenario catalog) live in the repository:
151
151
  - Behavior is pinned by scenario tests that run through the genuine MCP request path
152
152
  (in-memory client/server pair), covering happy paths and failure classes alike
153
153
  (missing config, uncollateralized operations, source divergence, upstream outages).
154
- - Current stage: **real adapter (sepolia writes, mainnet reads) + mock simulator**, both
155
- behind the same boundary contract and the same scenario suites. External-wallet signing
156
- runs on the real adapter; external-mode BTC withdrawal is the one remaining refusal
157
- (its true reason is stated; keystore withdrawal works).
158
- - Mainnet writes are disabled unless the operator explicitly arms them. Reads are
159
- unrestricted, with indexer gaps reported honestly.
154
+ - Current stage: **real adapter (sepolia AND mainnet, reads and writes) + mock
155
+ simulator**, all behind the same boundary contract and the same scenario suites.
156
+ External-wallet signing runs on the real adapter, including BTC withdrawal (blind
157
+ hash signatures, site-parity — the approval card states the contents are not
158
+ decodable; keystore withdrawal signs locally).
159
+ - Reads are unrestricted, with indexer gaps reported honestly.
160
160
 
161
161
  ## Security model
162
162
 
@@ -191,12 +191,13 @@ pair (`DH_KEYSTORE_PATH` + `DH_KEYSTORE_PASSWORD`) or connecting the user's own
191
191
  Dependencies are pinned to exact versions so nothing drifts silently between installs.
192
192
  Bump deliberately, in lockstep with sibling packages, and run `npm ci` in CI.
193
193
 
194
- ### Mainnet writes are operator-gated
194
+ ### Mainnet moves real funds
195
195
 
196
- Mainnet reads work out of the box. Mainnet writes are disabled unless the operator
197
- explicitly arms them — an unarmed server refuses every mainnet write and names the
198
- standing gate as the reason. Do not arm mainnet writes without reviewing your host's
199
- approval flow and key management; PSM mainnet writes refuse regardless.
196
+ Mainnet reads and writes both work out of the box. Every fund-moving operation still
197
+ requires the explicit human `confirmed: true` plus a real signature (wallet approval
198
+ card or keystore), and the network switch ceremony states the money reality loudly.
199
+ Review your host's approval flow and key management before using mainnet; PSM mainnet
200
+ writes refuse (sepolia-only).
200
201
 
201
202
  ## For AI assistants
202
203
 
package/dist/boundary.js CHANGED
@@ -87369,7 +87369,13 @@ var PERSONAL_SIGN_LAYOUTS = {
87369
87369
  hashUtf8Fields: ["action"]
87370
87370
  }
87371
87371
  };
87372
+ var RAW_HASH_LAYOUT = "dh-raw-hash-v1";
87372
87373
  function hashForLayout(layout, fields) {
87374
+ if (layout === RAW_HASH_LAYOUT) {
87375
+ const raw = fields["hash"];
87376
+ if (!/^0x[0-9a-fA-F]{64}$/.test(raw ?? "")) throw new Error(`page-crypto: layout "${layout}" needs a 32-byte 0x-hex "hash" field`);
87377
+ return raw.toLowerCase();
87378
+ }
87373
87379
  const def = PERSONAL_SIGN_LAYOUTS[layout];
87374
87380
  if (!def) throw new Error(`page-crypto: unknown layout "${layout}"`);
87375
87381
  const hashUtf8 = new Set(def.hashUtf8Fields);
@@ -87537,6 +87543,15 @@ var PAGE_CRYPTO_JS = `"use strict";
87537
87543
  var PERSONAL_SIGN_LAYOUTS = ${JSON.stringify(PERSONAL_SIGN_LAYOUTS)};
87538
87544
 
87539
87545
  function packAndHash(layout, fields) {
87546
+ // SITE-PARITY blind-sign layout: identity \u2014 the hash field IS the hash (see the
87547
+ // RAW_HASH_LAYOUT note in page-crypto.ts; both sides special-case identically).
87548
+ if (layout === "dh-raw-hash-v1") {
87549
+ var rawHash = fields ? fields.hash : undefined;
87550
+ if (!rawHash || !/^0x[0-9a-fA-F]{64}$/.test(rawHash)) {
87551
+ throw new Error("dhPageCrypto: layout \\"dh-raw-hash-v1\\" needs a 32-byte 0x-hex hash field");
87552
+ }
87553
+ return rawHash.toLowerCase();
87554
+ }
87540
87555
  var def = PERSONAL_SIGN_LAYOUTS[layout];
87541
87556
  if (!def) {
87542
87557
  throw new Error("dhPageCrypto: unknown layout \\"" + layout + "\\"");
@@ -87601,7 +87616,7 @@ function psmMainnetWriteRefusal(network, chainId) {
87601
87616
  return {
87602
87617
  kind: "rejected",
87603
87618
  source: SOURCE5,
87604
- message: `psmSwap is refused (MAINNET_WRITES_DISABLED): PSM writes are enabled on sepolia ONLY, and this process is configured for network '${network}' (chainId ${chainId}) \u2014 the standing mainnet write block; mainnet PSM operations await their dedicated security review. No ceremony was started and no signer was touched. PSM reads (psm_quote, protocol://psm) remain available.`
87619
+ message: `psmSwap is refused (MAINNET_WRITES_DISABLED): PSM writes are enabled on sepolia ONLY, and this process is configured for network '${network}' (chainId ${chainId}) \u2014 the PSM-specific sepolia-only anchor; mainnet PSM operations await their dedicated security review. No ceremony was started and no signer was touched. PSM reads (psm_quote, protocol://psm) remain available. Loan operations are NOT affected by this gate.`
87605
87620
  };
87606
87621
  }
87607
87622
  var SOURCE5 = "real-ops";
@@ -87755,6 +87770,11 @@ function buildWriteOps(deps) {
87755
87770
  createPosition: async (p) => {
87756
87771
  const sdk = deps.getWriteSdk();
87757
87772
  if (!sdk) return upFail({ kind: "unavailable", source: SOURCE5, message: "write SDK is not initialized (its boot-time construction failed)" });
87773
+ try {
87774
+ await deps.assertValidatorConfigured();
87775
+ } catch (e) {
87776
+ return upFail({ kind: "rejected", source: SOURCE5, message: `createPosition preflight: ${e.message}` });
87777
+ }
87758
87778
  let result;
87759
87779
  try {
87760
87780
  result = await sdk.createLoan({ selectedTerm: p.selectedTerm });
@@ -88277,10 +88297,37 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers36.ether
88277
88297
  async getAddress() {
88278
88298
  return this.deps.borrower;
88279
88299
  }
88280
- async signMessage(_message) {
88281
- throw new Error(
88282
- "external-wallet mode cannot sign this operation yet: it needs a raw message signature whose fields are built inside the SDK (BTC withdrawal). That is the plan-10 Phase A-2 signing-context seam \u2014 use the keystore signer for this operation until it lands."
88283
- );
88300
+ async signMessage(message) {
88301
+ const bytes = typeof message === "string" ? import_ethers36.ethers.toUtf8Bytes(message) : message;
88302
+ if (bytes.length !== 32) {
88303
+ throw new Error(
88304
+ `external-wallet signMessage accepts only the SDK's bare 32-byte auth hashes (got ${bytes.length} bytes) \u2014 no other raw-message signing rides this path.`
88305
+ );
88306
+ }
88307
+ const hashHex = import_ethers36.ethers.hexlify(bytes).toLowerCase();
88308
+ const outcome = await this.deps.bridge.requestSignature({
88309
+ id: (0, import_node_crypto5.randomUUID)(),
88310
+ kind: "personal-sign",
88311
+ action: "btc-withdrawal authorization (blind hash)",
88312
+ card: [
88313
+ "BLIND SIGNATURE \u2014 BTC withdrawal authorization step",
88314
+ `hash: ${hashHex}`,
88315
+ "This hash is built inside the SDK and its contents CANNOT be decoded or verified by this page",
88316
+ "(identical to how diamondhands.credit signs withdrawals).",
88317
+ "Approve ONLY if you initiated this exact BTC withdrawal in the conversation."
88318
+ ],
88319
+ expectedSigner: this.deps.borrower,
88320
+ chainId: this.deps.chainId,
88321
+ personalSign: { layout: RAW_HASH_LAYOUT, fields: { hash: hashHex }, hashHex }
88322
+ });
88323
+ if (outcome.status !== "approved" || !outcome.signature) {
88324
+ throw new OperationDeclined(`the btc-withdrawal authorization was not signed: ${describeOutcome(outcome)}`);
88325
+ }
88326
+ const recovered = import_ethers36.ethers.verifyMessage(bytes, outcome.signature);
88327
+ if (recovered.toLowerCase() !== this.deps.borrower.toLowerCase()) {
88328
+ throw new Error(`the btc-withdrawal authorization was signed by ${recovered}, not the borrower ${this.deps.borrower}`);
88329
+ }
88330
+ return outcome.signature;
88284
88331
  }
88285
88332
  async signTypedData(domain, types, value) {
88286
88333
  const typedData = {
@@ -88525,7 +88572,7 @@ var RealUpstreamPlugin = class {
88525
88572
  })
88526
88573
  )
88527
88574
  };
88528
- const writeRefusalReason = this.config.network !== "sepolia" ? `writes are enabled on sepolia ONLY, and this process is configured for network '${this.config.network}' (chainId ${this.config.chainId}) \u2014 the standing mainnet write block; mainnet writes await their dedicated security review. Reads remain available.` : !this.wallet ? `no signer is configured (SIGNER_UNAVAILABLE) \u2014 writes need the keystore env pair (DH_KEYSTORE_PATH + DH_KEYSTORE_PASSWORD), or run signer_setup.` : `the lit-ops login session is unavailable \u2014 the keystore is configured but EIP-712 login did not complete; check the broker endpoint and retry.`;
88575
+ const writeRefusalReason = !this.wallet ? `no signer is configured (SIGNER_UNAVAILABLE) \u2014 writes need the keystore env pair (DH_KEYSTORE_PATH + DH_KEYSTORE_PASSWORD), or run signer_setup.` : `the lit-ops login session is unavailable \u2014 the keystore is configured but EIP-712 login did not complete; check the broker endpoint and retry.`;
88529
88576
  const readOnly = (op) => Promise.resolve(
88530
88577
  upFail({
88531
88578
  kind: "unavailable",
@@ -88533,10 +88580,9 @@ var RealUpstreamPlugin = class {
88533
88580
  message: `${op} is refused: ${writeRefusalReason}`
88534
88581
  })
88535
88582
  );
88536
- const writesArmed = this.config.network === "sepolia" || this.config.network === "mainnet" && this.config.mainnetWritesAck === true;
88537
- if (writesArmed && this.runtime) {
88583
+ if (this.runtime) {
88538
88584
  this.ops = this.resolvingOps();
88539
- } else if (writesArmed && this.wallet && this.session) {
88585
+ } else if (this.wallet && this.session) {
88540
88586
  this.ops = this.keystoreGateway(this.wallet.connect(this.provider), this.session);
88541
88587
  } else {
88542
88588
  this.ops = {
@@ -88589,8 +88635,6 @@ var RealUpstreamPlugin = class {
88589
88635
  * Safe to call repeatedly; failures leave the write plane honestly unavailable
88590
88636
  * (createPosition/withdraw report the uninitialized SDK). */
88591
88637
  async initWriteSdk() {
88592
- const writesArmed = this.config.network === "sepolia" || this.config.network === "mainnet" && this.config.mainnetWritesAck === true;
88593
- if (!writesArmed) return;
88594
88638
  if (this.runtime && this.runtime.manager.mode() !== "keystore") return;
88595
88639
  const wallet = this.wallet ?? this.runtime?.keystore.signer() ?? null;
88596
88640
  if (!wallet) return;
@@ -88671,9 +88715,33 @@ var RealUpstreamPlugin = class {
88671
88715
  session,
88672
88716
  getWriteSdk: () => this.sdkCache.get(key) ?? null,
88673
88717
  readDetails: (id) => this.readPositionDetails(id),
88674
- psm: () => this.psmCalls()
88718
+ psm: () => this.psmCalls(),
88719
+ assertValidatorConfigured: () => this.assertValidatorConfigured()
88675
88720
  });
88676
88721
  }
88722
+ /** Live preflight (field bug, 2026-08-05): the configured validator generation must be
88723
+ * registered on-chain — on mainnet only version 3 exists, and a wrong version makes
88724
+ * createPosition revert ValidatorNotConfigured, which the user's wallet can only show
88725
+ * as an illegible "likely to fail". One eth_call turns that into a legible refusal. */
88726
+ async assertValidatorConfigured() {
88727
+ const version2 = this.config.validatorVersion ?? 1;
88728
+ const pkpValidation = this.contracts["PKPValidation"];
88729
+ if (!pkpValidation) {
88730
+ throw new Error(`the SDK's ${this.config.network} deployment table has no PKPValidation address \u2014 cannot verify validator version ${version2}.`);
88731
+ }
88732
+ const registry = new import_ethers37.ethers.Contract(pkpValidation, ["function validatorForVersion(uint256) view returns (address)"], this.provider);
88733
+ let validator;
88734
+ try {
88735
+ validator = await registry.validatorForVersion(version2);
88736
+ } catch (e) {
88737
+ throw new Error(`could not verify validator version ${version2} on-chain (PKPValidation ${pkpValidation}): ${e.message}`);
88738
+ }
88739
+ if (validator === import_ethers37.ethers.ZeroAddress) {
88740
+ throw new Error(
88741
+ `validator version ${version2} is NOT registered on ${this.config.network} (PKPValidation ${pkpValidation} returns the zero address) \u2014 the transaction would revert ValidatorNotConfigured. Set DH_VALIDATOR_VERSION to the network's registered generation.`
88742
+ );
88743
+ }
88744
+ }
88677
88745
  sessionFor(key, signer) {
88678
88746
  let s = this.sessionCache.get(key);
88679
88747
  if (!s) {
@@ -88687,7 +88755,7 @@ var RealUpstreamPlugin = class {
88687
88755
  verifyBudget() {
88688
88756
  return this.config.network === "mainnet" ? { attempts: 100, delayMs: 3e3 } : void 0;
88689
88757
  }
88690
- /** The armed-boot ops surface: every method resolves the CURRENT signer mode first, so
88758
+ /** The runtime ops surface: every method resolves the CURRENT signer mode first, so
88691
88759
  * the refusal-truth matrix is decided at call time, never frozen at boot. */
88692
88760
  resolvingOps() {
88693
88761
  const call = (k) => (async (p) => {
@@ -88780,7 +88848,8 @@ var RealUpstreamPlugin = class {
88780
88848
  session,
88781
88849
  getWriteSdk: () => this.sdkCache.get(key) ?? null,
88782
88850
  readDetails: (id) => this.readPositionDetails(id),
88783
- psm: () => this.psmCalls()
88851
+ psm: () => this.psmCalls(),
88852
+ assertValidatorConfigured: () => this.assertValidatorConfigured()
88784
88853
  });
88785
88854
  this.opsGatewayCache.set(key, gateway);
88786
88855
  }
@@ -90021,7 +90090,11 @@ var NETWORK_DEFAULTS = {
90021
90090
  mainnet: {
90022
90091
  rpcUrl: "https://ethereum-rpc.publicnode.com",
90023
90092
  serviceEndpoint: "https://ops.gvnr.xyz",
90024
- litNetwork: "chipotle"
90093
+ litNetwork: "chipotle",
90094
+ // On-chain PKPValidation generation, mainnet (validatorForVersion(3) is the ONLY
90095
+ // registered validator — verified live 2026-08-05). Without this the SDK defaults
90096
+ // to 1 and createPosition reverts ValidatorNotConfigured in wallet simulation.
90097
+ validatorVersion: 3
90025
90098
  }
90026
90099
  };
90027
90100
  function resolveBoundaryConfig(env) {
@@ -90163,20 +90236,6 @@ function resolveRealConfig(env) {
90163
90236
  bridgeOpenBrowser = bridgeOpenRaw === "1";
90164
90237
  }
90165
90238
  }
90166
- const ACK_PHRASE = "I-UNDERSTAND-REAL-FUNDS";
90167
- const ackRaw = env["DH_MAINNET_WRITES_ACK"];
90168
- let mainnetWritesAck;
90169
- if (ackRaw !== void 0 && ackRaw !== "") {
90170
- if (network !== "mainnet") {
90171
- problems.push("DH_MAINNET_WRITES_ACK is only meaningful with DH_NETWORK=mainnet \u2014 unset it on other networks.");
90172
- } else if (ackRaw !== ACK_PHRASE) {
90173
- problems.push(
90174
- "DH_MAINNET_WRITES_ACK is set but does not match the required acknowledgement phrase \u2014 mainnet writes stay refused. (The phrase is deliberate friction: it arms REAL-FUND transactions.)"
90175
- );
90176
- } else {
90177
- mainnetWritesAck = true;
90178
- }
90179
- }
90180
90239
  const validatorRaw = env["DH_VALIDATOR_VERSION"];
90181
90240
  let validatorVersion = defaults2.validatorVersion;
90182
90241
  if (validatorRaw !== void 0 && validatorRaw !== "") {
@@ -90211,8 +90270,7 @@ function resolveRealConfig(env) {
90211
90270
  ...bridgeUrlFile ? { bridgeUrlFile } : {},
90212
90271
  ...bridgeOpenBrowser !== void 0 ? { bridgeOpenBrowser } : {},
90213
90272
  ...wcProjectId ? { wcProjectId } : {},
90214
- ...validatorVersion !== void 0 ? { validatorVersion } : {},
90215
- ...mainnetWritesAck === true ? { mainnetWritesAck: true } : {}
90273
+ ...validatorVersion !== void 0 ? { validatorVersion } : {}
90216
90274
  }
90217
90275
  };
90218
90276
  }
@@ -90387,18 +90445,12 @@ async function createRealBoundary(config, wallet) {
90387
90445
  const plugin = new RealUpstreamPlugin(config, wallet, { manager, bridge, keystore });
90388
90446
  await plugin.initWriteSdk();
90389
90447
  const configFingerprint = (0, import_node_crypto7.createHash)("sha256").update(JSON.stringify({ adapter: config.adapter, network: config.network, ops: config.serviceEndpoint })).digest("hex").slice(0, 12);
90390
- const writesArmed = config.network === "sepolia" || config.network === "mainnet" && config.mainnetWritesAck === true;
90391
90448
  const capabilities = () => ({
90392
90449
  reads: {
90393
90450
  public: true,
90394
90451
  authenticated: plugin.authenticatedReadsAvailable() ? "available" : "needs-signer"
90395
90452
  },
90396
- writes: writesArmed ? { enabled: true, signerModes: ["external", "keystore"], activeMode: manager.mode() } : {
90397
- enabled: false,
90398
- reason: "writes are operator-gated on mainnet \u2014 the standing mainnet write block; mainnet writes await their dedicated security review. Reads remain available.",
90399
- signerModes: [],
90400
- activeMode: manager.mode()
90401
- },
90453
+ writes: { enabled: true, signerModes: ["external", "keystore"], activeMode: manager.mode() },
90402
90454
  signerSetupTool: true,
90403
90455
  // Plan 13: the real adapter switches networks by conversation (network_switch tool).
90404
90456
  networkSwitch: true
package/dist/index.js CHANGED
@@ -52072,7 +52072,11 @@ var NETWORK_DEFAULTS = {
52072
52072
  mainnet: {
52073
52073
  rpcUrl: "https://ethereum-rpc.publicnode.com",
52074
52074
  serviceEndpoint: "https://ops.gvnr.xyz",
52075
- litNetwork: "chipotle"
52075
+ litNetwork: "chipotle",
52076
+ // On-chain PKPValidation generation, mainnet (validatorForVersion(3) is the ONLY
52077
+ // registered validator — verified live 2026-08-05). Without this the SDK defaults
52078
+ // to 1 and createPosition reverts ValidatorNotConfigured in wallet simulation.
52079
+ validatorVersion: 3
52076
52080
  }
52077
52081
  };
52078
52082
  function resolveBoundaryConfig(env) {
@@ -52214,20 +52218,6 @@ function resolveRealConfig(env) {
52214
52218
  bridgeOpenBrowser = bridgeOpenRaw === "1";
52215
52219
  }
52216
52220
  }
52217
- const ACK_PHRASE = "I-UNDERSTAND-REAL-FUNDS";
52218
- const ackRaw = env["DH_MAINNET_WRITES_ACK"];
52219
- let mainnetWritesAck;
52220
- if (ackRaw !== void 0 && ackRaw !== "") {
52221
- if (network !== "mainnet") {
52222
- problems.push("DH_MAINNET_WRITES_ACK is only meaningful with DH_NETWORK=mainnet \u2014 unset it on other networks.");
52223
- } else if (ackRaw !== ACK_PHRASE) {
52224
- problems.push(
52225
- "DH_MAINNET_WRITES_ACK is set but does not match the required acknowledgement phrase \u2014 mainnet writes stay refused. (The phrase is deliberate friction: it arms REAL-FUND transactions.)"
52226
- );
52227
- } else {
52228
- mainnetWritesAck = true;
52229
- }
52230
- }
52231
52221
  const validatorRaw = env["DH_VALIDATOR_VERSION"];
52232
52222
  let validatorVersion = defaults2.validatorVersion;
52233
52223
  if (validatorRaw !== void 0 && validatorRaw !== "") {
@@ -52262,8 +52252,7 @@ function resolveRealConfig(env) {
52262
52252
  ...bridgeUrlFile ? { bridgeUrlFile } : {},
52263
52253
  ...bridgeOpenBrowser !== void 0 ? { bridgeOpenBrowser } : {},
52264
52254
  ...wcProjectId ? { wcProjectId } : {},
52265
- ...validatorVersion !== void 0 ? { validatorVersion } : {},
52266
- ...mainnetWritesAck === true ? { mainnetWritesAck: true } : {}
52255
+ ...validatorVersion !== void 0 ? { validatorVersion } : {}
52267
52256
  }
52268
52257
  };
52269
52258
  }
@@ -87582,7 +87571,13 @@ var PERSONAL_SIGN_LAYOUTS = {
87582
87571
  hashUtf8Fields: ["action"]
87583
87572
  }
87584
87573
  };
87574
+ var RAW_HASH_LAYOUT = "dh-raw-hash-v1";
87585
87575
  function hashForLayout(layout, fields) {
87576
+ if (layout === RAW_HASH_LAYOUT) {
87577
+ const raw = fields["hash"];
87578
+ if (!/^0x[0-9a-fA-F]{64}$/.test(raw ?? "")) throw new Error(`page-crypto: layout "${layout}" needs a 32-byte 0x-hex "hash" field`);
87579
+ return raw.toLowerCase();
87580
+ }
87586
87581
  const def = PERSONAL_SIGN_LAYOUTS[layout];
87587
87582
  if (!def) throw new Error(`page-crypto: unknown layout "${layout}"`);
87588
87583
  const hashUtf8 = new Set(def.hashUtf8Fields);
@@ -87750,6 +87745,15 @@ var PAGE_CRYPTO_JS = `"use strict";
87750
87745
  var PERSONAL_SIGN_LAYOUTS = ${JSON.stringify(PERSONAL_SIGN_LAYOUTS)};
87751
87746
 
87752
87747
  function packAndHash(layout, fields) {
87748
+ // SITE-PARITY blind-sign layout: identity \u2014 the hash field IS the hash (see the
87749
+ // RAW_HASH_LAYOUT note in page-crypto.ts; both sides special-case identically).
87750
+ if (layout === "dh-raw-hash-v1") {
87751
+ var rawHash = fields ? fields.hash : undefined;
87752
+ if (!rawHash || !/^0x[0-9a-fA-F]{64}$/.test(rawHash)) {
87753
+ throw new Error("dhPageCrypto: layout \\"dh-raw-hash-v1\\" needs a 32-byte 0x-hex hash field");
87754
+ }
87755
+ return rawHash.toLowerCase();
87756
+ }
87753
87757
  var def = PERSONAL_SIGN_LAYOUTS[layout];
87754
87758
  if (!def) {
87755
87759
  throw new Error("dhPageCrypto: unknown layout \\"" + layout + "\\"");
@@ -87814,7 +87818,7 @@ function psmMainnetWriteRefusal(network, chainId) {
87814
87818
  return {
87815
87819
  kind: "rejected",
87816
87820
  source: SOURCE5,
87817
- message: `psmSwap is refused (MAINNET_WRITES_DISABLED): PSM writes are enabled on sepolia ONLY, and this process is configured for network '${network}' (chainId ${chainId}) \u2014 the standing mainnet write block; mainnet PSM operations await their dedicated security review. No ceremony was started and no signer was touched. PSM reads (psm_quote, protocol://psm) remain available.`
87821
+ message: `psmSwap is refused (MAINNET_WRITES_DISABLED): PSM writes are enabled on sepolia ONLY, and this process is configured for network '${network}' (chainId ${chainId}) \u2014 the PSM-specific sepolia-only anchor; mainnet PSM operations await their dedicated security review. No ceremony was started and no signer was touched. PSM reads (psm_quote, protocol://psm) remain available. Loan operations are NOT affected by this gate.`
87818
87822
  };
87819
87823
  }
87820
87824
  var SOURCE5 = "real-ops";
@@ -87968,6 +87972,11 @@ function buildWriteOps(deps) {
87968
87972
  createPosition: async (p) => {
87969
87973
  const sdk = deps.getWriteSdk();
87970
87974
  if (!sdk) return upFail({ kind: "unavailable", source: SOURCE5, message: "write SDK is not initialized (its boot-time construction failed)" });
87975
+ try {
87976
+ await deps.assertValidatorConfigured();
87977
+ } catch (e) {
87978
+ return upFail({ kind: "rejected", source: SOURCE5, message: `createPosition preflight: ${e.message}` });
87979
+ }
87971
87980
  let result;
87972
87981
  try {
87973
87982
  result = await sdk.createLoan({ selectedTerm: p.selectedTerm });
@@ -88490,10 +88499,37 @@ var BridgeEthersSigner = class _BridgeEthersSigner extends import_ethers36.ether
88490
88499
  async getAddress() {
88491
88500
  return this.deps.borrower;
88492
88501
  }
88493
- async signMessage(_message) {
88494
- throw new Error(
88495
- "external-wallet mode cannot sign this operation yet: it needs a raw message signature whose fields are built inside the SDK (BTC withdrawal). That is the plan-10 Phase A-2 signing-context seam \u2014 use the keystore signer for this operation until it lands."
88496
- );
88502
+ async signMessage(message) {
88503
+ const bytes = typeof message === "string" ? import_ethers36.ethers.toUtf8Bytes(message) : message;
88504
+ if (bytes.length !== 32) {
88505
+ throw new Error(
88506
+ `external-wallet signMessage accepts only the SDK's bare 32-byte auth hashes (got ${bytes.length} bytes) \u2014 no other raw-message signing rides this path.`
88507
+ );
88508
+ }
88509
+ const hashHex = import_ethers36.ethers.hexlify(bytes).toLowerCase();
88510
+ const outcome = await this.deps.bridge.requestSignature({
88511
+ id: (0, import_node_crypto5.randomUUID)(),
88512
+ kind: "personal-sign",
88513
+ action: "btc-withdrawal authorization (blind hash)",
88514
+ card: [
88515
+ "BLIND SIGNATURE \u2014 BTC withdrawal authorization step",
88516
+ `hash: ${hashHex}`,
88517
+ "This hash is built inside the SDK and its contents CANNOT be decoded or verified by this page",
88518
+ "(identical to how diamondhands.credit signs withdrawals).",
88519
+ "Approve ONLY if you initiated this exact BTC withdrawal in the conversation."
88520
+ ],
88521
+ expectedSigner: this.deps.borrower,
88522
+ chainId: this.deps.chainId,
88523
+ personalSign: { layout: RAW_HASH_LAYOUT, fields: { hash: hashHex }, hashHex }
88524
+ });
88525
+ if (outcome.status !== "approved" || !outcome.signature) {
88526
+ throw new OperationDeclined(`the btc-withdrawal authorization was not signed: ${describeOutcome(outcome)}`);
88527
+ }
88528
+ const recovered = import_ethers36.ethers.verifyMessage(bytes, outcome.signature);
88529
+ if (recovered.toLowerCase() !== this.deps.borrower.toLowerCase()) {
88530
+ throw new Error(`the btc-withdrawal authorization was signed by ${recovered}, not the borrower ${this.deps.borrower}`);
88531
+ }
88532
+ return outcome.signature;
88497
88533
  }
88498
88534
  async signTypedData(domain, types, value) {
88499
88535
  const typedData = {
@@ -88738,7 +88774,7 @@ var RealUpstreamPlugin = class {
88738
88774
  })
88739
88775
  )
88740
88776
  };
88741
- const writeRefusalReason = this.config.network !== "sepolia" ? `writes are enabled on sepolia ONLY, and this process is configured for network '${this.config.network}' (chainId ${this.config.chainId}) \u2014 the standing mainnet write block; mainnet writes await their dedicated security review. Reads remain available.` : !this.wallet ? `no signer is configured (SIGNER_UNAVAILABLE) \u2014 writes need the keystore env pair (DH_KEYSTORE_PATH + DH_KEYSTORE_PASSWORD), or run signer_setup.` : `the lit-ops login session is unavailable \u2014 the keystore is configured but EIP-712 login did not complete; check the broker endpoint and retry.`;
88777
+ const writeRefusalReason = !this.wallet ? `no signer is configured (SIGNER_UNAVAILABLE) \u2014 writes need the keystore env pair (DH_KEYSTORE_PATH + DH_KEYSTORE_PASSWORD), or run signer_setup.` : `the lit-ops login session is unavailable \u2014 the keystore is configured but EIP-712 login did not complete; check the broker endpoint and retry.`;
88742
88778
  const readOnly = (op) => Promise.resolve(
88743
88779
  upFail({
88744
88780
  kind: "unavailable",
@@ -88746,10 +88782,9 @@ var RealUpstreamPlugin = class {
88746
88782
  message: `${op} is refused: ${writeRefusalReason}`
88747
88783
  })
88748
88784
  );
88749
- const writesArmed = this.config.network === "sepolia" || this.config.network === "mainnet" && this.config.mainnetWritesAck === true;
88750
- if (writesArmed && this.runtime) {
88785
+ if (this.runtime) {
88751
88786
  this.ops = this.resolvingOps();
88752
- } else if (writesArmed && this.wallet && this.session) {
88787
+ } else if (this.wallet && this.session) {
88753
88788
  this.ops = this.keystoreGateway(this.wallet.connect(this.provider), this.session);
88754
88789
  } else {
88755
88790
  this.ops = {
@@ -88802,8 +88837,6 @@ var RealUpstreamPlugin = class {
88802
88837
  * Safe to call repeatedly; failures leave the write plane honestly unavailable
88803
88838
  * (createPosition/withdraw report the uninitialized SDK). */
88804
88839
  async initWriteSdk() {
88805
- const writesArmed = this.config.network === "sepolia" || this.config.network === "mainnet" && this.config.mainnetWritesAck === true;
88806
- if (!writesArmed) return;
88807
88840
  if (this.runtime && this.runtime.manager.mode() !== "keystore") return;
88808
88841
  const wallet = this.wallet ?? this.runtime?.keystore.signer() ?? null;
88809
88842
  if (!wallet) return;
@@ -88884,9 +88917,33 @@ var RealUpstreamPlugin = class {
88884
88917
  session,
88885
88918
  getWriteSdk: () => this.sdkCache.get(key) ?? null,
88886
88919
  readDetails: (id) => this.readPositionDetails(id),
88887
- psm: () => this.psmCalls()
88920
+ psm: () => this.psmCalls(),
88921
+ assertValidatorConfigured: () => this.assertValidatorConfigured()
88888
88922
  });
88889
88923
  }
88924
+ /** Live preflight (field bug, 2026-08-05): the configured validator generation must be
88925
+ * registered on-chain — on mainnet only version 3 exists, and a wrong version makes
88926
+ * createPosition revert ValidatorNotConfigured, which the user's wallet can only show
88927
+ * as an illegible "likely to fail". One eth_call turns that into a legible refusal. */
88928
+ async assertValidatorConfigured() {
88929
+ const version2 = this.config.validatorVersion ?? 1;
88930
+ const pkpValidation = this.contracts["PKPValidation"];
88931
+ if (!pkpValidation) {
88932
+ throw new Error(`the SDK's ${this.config.network} deployment table has no PKPValidation address \u2014 cannot verify validator version ${version2}.`);
88933
+ }
88934
+ const registry = new import_ethers37.ethers.Contract(pkpValidation, ["function validatorForVersion(uint256) view returns (address)"], this.provider);
88935
+ let validator;
88936
+ try {
88937
+ validator = await registry.validatorForVersion(version2);
88938
+ } catch (e) {
88939
+ throw new Error(`could not verify validator version ${version2} on-chain (PKPValidation ${pkpValidation}): ${e.message}`);
88940
+ }
88941
+ if (validator === import_ethers37.ethers.ZeroAddress) {
88942
+ throw new Error(
88943
+ `validator version ${version2} is NOT registered on ${this.config.network} (PKPValidation ${pkpValidation} returns the zero address) \u2014 the transaction would revert ValidatorNotConfigured. Set DH_VALIDATOR_VERSION to the network's registered generation.`
88944
+ );
88945
+ }
88946
+ }
88890
88947
  sessionFor(key, signer) {
88891
88948
  let s = this.sessionCache.get(key);
88892
88949
  if (!s) {
@@ -88900,7 +88957,7 @@ var RealUpstreamPlugin = class {
88900
88957
  verifyBudget() {
88901
88958
  return this.config.network === "mainnet" ? { attempts: 100, delayMs: 3e3 } : void 0;
88902
88959
  }
88903
- /** The armed-boot ops surface: every method resolves the CURRENT signer mode first, so
88960
+ /** The runtime ops surface: every method resolves the CURRENT signer mode first, so
88904
88961
  * the refusal-truth matrix is decided at call time, never frozen at boot. */
88905
88962
  resolvingOps() {
88906
88963
  const call = (k) => (async (p) => {
@@ -88993,7 +89050,8 @@ var RealUpstreamPlugin = class {
88993
89050
  session,
88994
89051
  getWriteSdk: () => this.sdkCache.get(key) ?? null,
88995
89052
  readDetails: (id) => this.readPositionDetails(id),
88996
- psm: () => this.psmCalls()
89053
+ psm: () => this.psmCalls(),
89054
+ assertValidatorConfigured: () => this.assertValidatorConfigured()
88997
89055
  });
88998
89056
  this.opsGatewayCache.set(key, gateway);
88999
89057
  }
@@ -90388,18 +90446,12 @@ async function createRealBoundary(config, wallet) {
90388
90446
  const plugin = new RealUpstreamPlugin(config, wallet, { manager, bridge, keystore });
90389
90447
  await plugin.initWriteSdk();
90390
90448
  const configFingerprint = (0, import_node_crypto7.createHash)("sha256").update(JSON.stringify({ adapter: config.adapter, network: config.network, ops: config.serviceEndpoint })).digest("hex").slice(0, 12);
90391
- const writesArmed = config.network === "sepolia" || config.network === "mainnet" && config.mainnetWritesAck === true;
90392
90449
  const capabilities = () => ({
90393
90450
  reads: {
90394
90451
  public: true,
90395
90452
  authenticated: plugin.authenticatedReadsAvailable() ? "available" : "needs-signer"
90396
90453
  },
90397
- writes: writesArmed ? { enabled: true, signerModes: ["external", "keystore"], activeMode: manager.mode() } : {
90398
- enabled: false,
90399
- reason: "writes are operator-gated on mainnet \u2014 the standing mainnet write block; mainnet writes await their dedicated security review. Reads remain available.",
90400
- signerModes: [],
90401
- activeMode: manager.mode()
90402
- },
90454
+ writes: { enabled: true, signerModes: ["external", "keystore"], activeMode: manager.mode() },
90403
90455
  signerSetupTool: true,
90404
90456
  // Plan 13: the real adapter switches networks by conversation (network_switch tool).
90405
90457
  networkSwitch: true
@@ -90488,7 +90540,6 @@ function createNetworkSwitchRuntime(opts) {
90488
90540
  },
90489
90541
  async switchTo(network) {
90490
90542
  const targetEnv = { ...opts.env, DH_NETWORK: network };
90491
- delete targetEnv["DH_MAINNET_WRITES_ACK"];
90492
90543
  const configResult = resolveBoundaryConfig(targetEnv);
90493
90544
  if (!configResult.ok) return { ok: false, error: configResult.error };
90494
90545
  const next = await buildBoundary(configResult);
@@ -91564,14 +91615,16 @@ the mock.
91564
91615
  authenticated call refuses with the same remedy \u2014 an explicit reconnect, never a
91565
91616
  surprise popup. On mainnet the broker also throttles logins per address \u2014 a throttled
91566
91617
  login means "wait and retry", not a wallet failure.
91567
- - **Withdraw-BTC under external mode is not shipped yet** (the SDK signing-context seam
91568
- is pending) \u2014 it refuses with that true reason; keystore-mode withdraw works.
91618
+ - **Withdraw-BTC under external mode is a BLIND signature** \u2014 the SDK builds the two
91619
+ withdrawal auth hashes internally, so the approval page shows the bare hash and says
91620
+ plainly it cannot decode the contents (the production web app signs the same way).
91621
+ Tell the user this before the popups: two hash signatures, then the BTC moves.
91569
91622
  - **The allowlist delay is read LIVE from the chain.** A new BTC withdrawal destination
91570
91623
  (\`loan_allowlist_destination\`) becomes usable only after the chain's own delay \u2014 24
91571
91624
  hours on mainnet, so allowlisting and withdrawing happen on DIFFERENT DAYS there. The
91572
91625
  card states the live figure.
91573
- - **Mainnet:** writes are disabled unless the operator explicitly arms them, and the
91574
- minimum mint is 10 UCD.`,
91626
+ - **Mainnet:** every fund-moving operation spends REAL money, and the minimum mint is
91627
+ 10 UCD.`,
91575
91628
  lifecycle: `# The full lifecycle \u2014 exact calls
91576
91629
 
91577
91630
  1. **Create** \u2014 \`loan_create {selectedTerm, confirmed:true}\` \u2192 position id, vault address.
@@ -91659,8 +91712,8 @@ tolerance; if fees or the rate drifted beyond that between quote and execution,
91659
91712
  contract refuses \u2014 you never silently receive less. Output always lands at the signer's
91660
91713
  own address. If you approve step 1 but decline step 2, the exact-amount allowance remains
91661
91714
  standing \u2014 it authorizes only that amount and nothing else; the result says so plainly.
91662
- On the real protocol, PSM writes run on sepolia ONLY \u2014 mainnet PSM writes are refused by
91663
- the standing mainnet write block.`,
91715
+ On the real protocol, PSM writes run on sepolia ONLY \u2014 mainnet PSM writes are refused
91716
+ (the PSM-specific sepolia-only anchor; loan operations are not affected).`,
91664
91717
  authorization: `# Authorization \u2014 who signs, and what a signature means
91665
91718
 
91666
91719
  Every fund-moving operation needs TWO things, always in this order:
@@ -91804,9 +91857,9 @@ no switch, and that is by design.
91804
91857
  the human approves the card. sepolia = practice funds; mainnet = REAL MONEY.
91805
91858
  - NOTHING carries across: positions, vaults, signer bindings, logins are per-network.
91806
91859
  A sepolia position does not exist on mainnet and vice versa.
91807
- - Switching to mainnet does NOT enable fund-moving operations: mainnet writes are
91808
- operator-gated \u2014 reads work, write tools refuse with the true reason. Never imply
91809
- otherwise.
91860
+ - Fund-moving loan operations work on BOTH networks \u2014 on mainnet they move REAL money,
91861
+ and every one still requires the user's explicit confirmation plus the signer
91862
+ ceremony. The exception is PSM swaps: sepolia-only, refused on mainnet.
91810
91863
  - A pending signing ceremony blocks the switch (finish or decline it first).
91811
91864
  - The switch is session-scoped: when the server restarts, the configured default
91812
91865
  network returns.
@@ -91822,14 +91875,14 @@ reality in your next message. The user must never have to ask which world they a
91822
91875
  - **"Not logged in" on a read** \u2014 authenticated reads NEVER pop the wallet; the remedy is
91823
91876
  the same pair: keystore env pair, or "connect my wallet" (\`signer_setup connect\`). An
91824
91877
  EXPIRED login refuses the same way \u2014 reconnect on the user's word.
91825
- - **Mainnet write refused** \u2014 mainnet writes are disabled unless the operator explicitly
91826
- arms them; the refusal is the standing gate, not a bug. Reads keep working. This is
91827
- TRUE after a conversational network switch too \u2014 switching never arms writes.
91878
+ - **PSM write refused on mainnet** \u2014 PSM swaps are sepolia-only (a deliberate anchor,
91879
+ not a bug); loan operations work on mainnet. Reads keep working everywhere.
91828
91880
  - **"Wrong network" / wants mainnet or sepolia** \u2014 real adapter: \`network_switch\`
91829
91881
  (human-confirmed card; nothing carries across networks). Mock: the world is pinned by
91830
91882
  config \u2014 no switch exists there.
91831
- - **External-mode withdraw refused** \u2014 withdraw-BTC under external mode is not shipped
91832
- yet (the SDK signing-context seam is pending); keystore-mode withdraw works.
91883
+ - **External-mode withdraw shows a bare hash** \u2014 that is by design (site parity): the
91884
+ SDK builds the withdrawal auth hashes internally, so the page cannot decode them.
91885
+ Two blind hash signatures per withdrawal; warn the user before triggering them.
91833
91886
  - **Login throttled (mainnet)** \u2014 the broker limits logins per address; wait and retry.
91834
91887
  That is the broker throttle, not a wallet failure.
91835
91888
  - **VALIDATION_FAILED** \u2014 the input itself is off (bad address format, too many decimals,
@@ -91995,7 +92048,7 @@ function registerGuidePrompts(server) {
91995
92048
  // src/tools/network-switch.ts
91996
92049
  var import_zod8 = require("zod");
91997
92050
  function moneyLine(network) {
91998
- return network === "mainnet" ? "mainnet \u2014 REAL MONEY: fund-moving operations spend real funds once enabled" : `${network} \u2014 PRACTICE FUNDS (test network: real contracts, no real money)`;
92051
+ return network === "mainnet" ? "mainnet \u2014 REAL MONEY: fund-moving operations spend real funds" : `${network} \u2014 PRACTICE FUNDS (test network: real contracts, no real money)`;
91999
92052
  }
92000
92053
  function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92001
92054
  registerBoundaryTool(
@@ -92003,7 +92056,7 @@ function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92003
92056
  "network_switch",
92004
92057
  {
92005
92058
  title: "Show or switch the active network",
92006
- description: "Which world this server is on \u2014 and switching it by conversation (real adapter). 'status' states the active network and whether money is real. 'switch' moves this session between sepolia (practice funds) and mainnet (REAL MONEY) after an explicit human confirmation; positions, vaults, and signer bindings are per-network and do not carry across. Mainnet writes stay operator-gated after a switch \u2014 reads work, fund-moving tools refuse with the true reason. The switch lasts for this server session only; the configured default returns on restart. After a switch, re-read boundary://info and STATE the new environment to the user.",
92059
+ description: "Which world this server is on \u2014 and switching it by conversation (real adapter). 'status' states the active network and whether money is real. 'switch' moves this session between sepolia (practice funds) and mainnet (REAL MONEY) after an explicit human confirmation; positions, vaults, and signer bindings are per-network and do not carry across. Fund-moving operations work on BOTH networks (on mainnet they move REAL money; PSM swaps stay sepolia-only). The switch lasts for this server session only; the configured default returns on restart. After a switch, re-read boundary://info and STATE the new environment to the user.",
92007
92060
  inputSchema: {
92008
92061
  action: import_zod8.z.enum(["status", "switch"]).describe("status = current world; switch = change network (needs confirmed:true)"),
92009
92062
  network: import_zod8.z.string().optional().describe("switch target: sepolia | mainnet"),
@@ -92021,7 +92074,7 @@ function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92021
92074
  lines.push(
92022
92075
  `Switchable networks: ${SWITCHABLE_NETWORKS.join(", ")} (action 'switch', confirmed:true after human approval).`,
92023
92076
  "A switch changes worlds entirely: positions, vaults, and signer bindings are per-network.",
92024
- "Mainnet writes are operator-gated regardless of switching \u2014 reads work, fund-moving tools refuse.",
92077
+ "Fund-moving operations work on both networks \u2014 on mainnet they move REAL money (PSM swaps: sepolia-only).",
92025
92078
  "Session-scoped: the configured default network returns when the server restarts."
92026
92079
  );
92027
92080
  return { content: [{ type: "text", text: lines.join("\n") }] };
@@ -92052,7 +92105,7 @@ function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92052
92105
  FROM: ${from}
92053
92106
  TO: ${moneyLine(target)}
92054
92107
  - Positions, vaults, and signer bindings are PER-NETWORK: nothing carries across.
92055
- - Mainnet fund-moving operations remain operator-gated after the switch \u2014 reads work, writes refuse.
92108
+ - Fund-moving operations WORK on the target network \u2014 on mainnet they move REAL money.
92056
92109
  - Session-scoped: the configured default network returns on server restart.
92057
92110
  Re-invoke with confirmed: true ONLY after a human has approved this exact switch. Do not set it on your own.`
92058
92111
  }
@@ -92176,7 +92229,7 @@ function registerBoundaryInfoResource(server, getB) {
92176
92229
  }
92177
92230
 
92178
92231
  // src/server.ts
92179
- var SERVER_VERSION = "0.3.1";
92232
+ var SERVER_VERSION = "0.5.0";
92180
92233
  var SERVER_INSTRUCTIONS = "Diamond Hands MCP \u2014 Bitcoin-collateralized borrowing. Before promising ANY flow, read the boundary://info resource and honor its `capabilities` block: it states which network this server is on, whether money is real (practiceWorld), whether writes are enabled (and the true reason when they are not), and which signer modes this build actually offers \u2014 never describe a flow outside it. State the network and whether funds are real when the user first acts. Authorization is chosen by conversation via the signer_setup tool (when listed); writes always require confirmed:true after showing the human-readable card. For walkthroughs consult the guide tool / guide:// resources instead of inventing steps; when a tool refuses, relay its stated reason and remedy \u2014 do not improvise alternatives. When a network_switch tool is listed, the network can change mid-session \u2014 after ANY switch, re-read boundary://info and state the new network and money reality to the user before doing anything else.";
92181
92234
  function createServer2(deps) {
92182
92235
  const server = new import_mcp2.McpServer(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-mcp",
3
- "version": "0.3.1",
4
- "description": "MCP server for the Diamond Hands protocol — Bitcoin-collateralized UCD lending with human-approved signing (sepolia by default; mainnet read-only)",
3
+ "version": "0.5.0",
4
+ "description": "MCP server for the Diamond Hands protocol — Bitcoin-collateralized UCD lending with human-approved signing (sepolia practice by default; mainnet fully enabled)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
7
7
  "type": "git",