@gvnrdao/dh-mcp 0.2.1 → 0.3.1

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,16 @@ 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.2.1/dh-mcp-0.2.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 with an absolute path. Pin a version: `curl -fsSL https://assets.gvnr.xyz/dh-mcp/install.sh \| DH_VERSION=0.2.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.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` |
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.2.1/`).
20
+ (`latest/` and `v<version>/` — e.g. `v0.3.1/`).
21
+
22
+ Local installs serve local MCP hosts only — **claude.ai web / mobile / Cowork cannot
23
+ reach them** (a hosted remote connector is a separate, upcoming tier).
21
24
 
22
25
  Unsigned-binary honesty: the macOS and Windows binaries are **not yet code-signed** —
23
26
  macOS Gatekeeper may quarantine the download (right-click → Open, or
package/dist/boundary.js CHANGED
@@ -52756,6 +52756,14 @@ var BoundaryCore = class {
52756
52756
  return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
52757
52757
  }
52758
52758
  // ---- meta ----
52759
+ world() {
52760
+ return {
52761
+ adapter: this.deps.adapter,
52762
+ network: this.deps.network,
52763
+ chainId: this.deps.chainId,
52764
+ practiceWorld: this.deps.network !== "mainnet"
52765
+ };
52766
+ }
52759
52767
  async describeBoundary() {
52760
52768
  const info = this.deps.plugin.describe();
52761
52769
  const source = { id: "boundary-core", kind: "core", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() };
@@ -90240,7 +90248,8 @@ function createBoundary(config, opts) {
90240
90248
  capabilities: () => ({
90241
90249
  reads: { public: true, authenticated: "available" },
90242
90250
  writes: { enabled: true, signerModes: ["external"], activeMode: "external" },
90243
- signerSetupTool: false
90251
+ signerSetupTool: false,
90252
+ networkSwitch: false
90244
90253
  }),
90245
90254
  configFingerprint
90246
90255
  });
@@ -90320,6 +90329,7 @@ function createBoundary(config, opts) {
90320
90329
  ...config.borrower ? { borrowerAddress: config.borrower } : {},
90321
90330
  signer: manager,
90322
90331
  // B3: the mock sandbox runs every ceremony class; reads have no login gate.
90332
+ // Plan 13 M13-5: no network_switch on mock — its world is pinned by the config.
90323
90333
  capabilities: () => ({
90324
90334
  reads: { public: true, authenticated: "available" },
90325
90335
  writes: {
@@ -90327,7 +90337,8 @@ function createBoundary(config, opts) {
90327
90337
  signerModes: ["external", "keystore", "mock-simulated", "safe", "safe-module"],
90328
90338
  activeMode: manager.mode()
90329
90339
  },
90330
- signerSetupTool: true
90340
+ signerSetupTool: true,
90341
+ networkSwitch: false
90331
90342
  }),
90332
90343
  configFingerprint
90333
90344
  });
@@ -90388,7 +90399,9 @@ async function createRealBoundary(config, wallet) {
90388
90399
  signerModes: [],
90389
90400
  activeMode: manager.mode()
90390
90401
  },
90391
- signerSetupTool: true
90402
+ signerSetupTool: true,
90403
+ // Plan 13: the real adapter switches networks by conversation (network_switch tool).
90404
+ networkSwitch: true
90392
90405
  });
90393
90406
  const boundary = new BoundaryCore({
90394
90407
  plugin,
package/dist/index.js CHANGED
@@ -297,9 +297,9 @@ var require_dist = __commonJS({
297
297
  exports2.bech32m = exports2.bech32 = void 0;
298
298
  var ALPHABET2 = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
299
299
  var ALPHABET_MAP = {};
300
- for (let z8 = 0; z8 < ALPHABET2.length; z8++) {
301
- const x = ALPHABET2.charAt(z8);
302
- ALPHABET_MAP[x] = z8;
300
+ for (let z9 = 0; z9 < ALPHABET2.length; z9++) {
301
+ const x = ALPHABET2.charAt(z9);
302
+ ALPHABET_MAP[x] = z9;
303
303
  }
304
304
  function polymodStep(pre) {
305
305
  const b = pre >> 25;
@@ -37063,8 +37063,8 @@ var require_lit_ops_module = __commonJS({
37063
37063
  if (!wallet.provider)
37064
37064
  return void 0;
37065
37065
  try {
37066
- const net = await wallet.provider.getNetwork();
37067
- return Number(net.chainId);
37066
+ const net2 = await wallet.provider.getNetwork();
37067
+ return Number(net2.chainId);
37068
37068
  } catch {
37069
37069
  return void 0;
37070
37070
  }
@@ -43143,12 +43143,12 @@ var require_bn = __commonJS({
43143
43143
  var one = new BN(1).toRed(this);
43144
43144
  var nOne = one.redNeg();
43145
43145
  var lpow = this.m.subn(1).iushrn(1);
43146
- var z8 = this.m.bitLength();
43147
- z8 = new BN(2 * z8 * z8).toRed(this);
43148
- while (this.pow(z8, lpow).cmp(nOne) !== 0) {
43149
- z8.redIAdd(nOne);
43146
+ var z9 = this.m.bitLength();
43147
+ z9 = new BN(2 * z9 * z9).toRed(this);
43148
+ while (this.pow(z9, lpow).cmp(nOne) !== 0) {
43149
+ z9.redIAdd(nOne);
43150
43150
  }
43151
- var c = this.pow(z8, q);
43151
+ var c = this.pow(z9, q);
43152
43152
  var r = this.pow(a, q.addn(1).iushrn(1));
43153
43153
  var t = this.pow(a, q);
43154
43154
  var m = s;
@@ -46026,12 +46026,12 @@ var require_bn2 = __commonJS({
46026
46026
  var one = new BN(1).toRed(this);
46027
46027
  var nOne = one.redNeg();
46028
46028
  var lpow = this.m.subn(1).iushrn(1);
46029
- var z8 = this.m.bitLength();
46030
- z8 = new BN(2 * z8 * z8).toRed(this);
46031
- while (this.pow(z8, lpow).cmp(nOne) !== 0) {
46032
- z8.redIAdd(nOne);
46029
+ var z9 = this.m.bitLength();
46030
+ z9 = new BN(2 * z9 * z9).toRed(this);
46031
+ while (this.pow(z9, lpow).cmp(nOne) !== 0) {
46032
+ z9.redIAdd(nOne);
46033
46033
  }
46034
- var c = this.pow(z8, q);
46034
+ var c = this.pow(z9, q);
46035
46035
  var r = this.pow(a, q.addn(1).iushrn(1));
46036
46036
  var t = this.pow(a, q);
46037
46037
  var m = s;
@@ -46267,18 +46267,18 @@ var require_utils3 = __commonJS({
46267
46267
  var ws = 1 << w + 1;
46268
46268
  var k = num.clone();
46269
46269
  for (i = 0; i < naf.length; i++) {
46270
- var z8;
46270
+ var z9;
46271
46271
  var mod = k.andln(ws - 1);
46272
46272
  if (k.isOdd()) {
46273
46273
  if (mod > (ws >> 1) - 1)
46274
- z8 = (ws >> 1) - mod;
46274
+ z9 = (ws >> 1) - mod;
46275
46275
  else
46276
- z8 = mod;
46277
- k.isubn(z8);
46276
+ z9 = mod;
46277
+ k.isubn(z9);
46278
46278
  } else {
46279
- z8 = 0;
46279
+ z9 = 0;
46280
46280
  }
46281
- naf[i] = z8;
46281
+ naf[i] = z9;
46282
46282
  k.iushrn(1);
46283
46283
  }
46284
46284
  return naf;
@@ -46491,18 +46491,18 @@ var require_base2 = __commonJS({
46491
46491
  acc = acc.dblp(l);
46492
46492
  if (i < 0)
46493
46493
  break;
46494
- var z8 = naf[i];
46495
- assert(z8 !== 0);
46494
+ var z9 = naf[i];
46495
+ assert(z9 !== 0);
46496
46496
  if (p.type === "affine") {
46497
- if (z8 > 0)
46498
- acc = acc.mixedAdd(wnd[z8 - 1 >> 1]);
46497
+ if (z9 > 0)
46498
+ acc = acc.mixedAdd(wnd[z9 - 1 >> 1]);
46499
46499
  else
46500
- acc = acc.mixedAdd(wnd[-z8 - 1 >> 1].neg());
46500
+ acc = acc.mixedAdd(wnd[-z9 - 1 >> 1].neg());
46501
46501
  } else {
46502
- if (z8 > 0)
46503
- acc = acc.add(wnd[z8 - 1 >> 1]);
46502
+ if (z9 > 0)
46503
+ acc = acc.add(wnd[z9 - 1 >> 1]);
46504
46504
  else
46505
- acc = acc.add(wnd[-z8 - 1 >> 1].neg());
46505
+ acc = acc.add(wnd[-z9 - 1 >> 1].neg());
46506
46506
  }
46507
46507
  }
46508
46508
  return p.type === "affine" ? acc.toP() : acc;
@@ -46605,14 +46605,14 @@ var require_base2 = __commonJS({
46605
46605
  if (i < 0)
46606
46606
  break;
46607
46607
  for (j = 0; j < len; j++) {
46608
- var z8 = tmp[j];
46608
+ var z9 = tmp[j];
46609
46609
  p;
46610
- if (z8 === 0)
46610
+ if (z9 === 0)
46611
46611
  continue;
46612
- else if (z8 > 0)
46613
- p = wnd[j][z8 - 1 >> 1];
46614
- else if (z8 < 0)
46615
- p = wnd[j][-z8 - 1 >> 1].neg();
46612
+ else if (z9 > 0)
46613
+ p = wnd[j][z9 - 1 >> 1];
46614
+ else if (z9 < 0)
46615
+ p = wnd[j][-z9 - 1 >> 1].neg();
46616
46616
  if (p.type === "affine")
46617
46617
  acc = acc.mixedAdd(p);
46618
46618
  else
@@ -47168,16 +47168,16 @@ var require_short = __commonJS({
47168
47168
  var res = this.curve.jpoint(this.x, this.y, this.curve.one);
47169
47169
  return res;
47170
47170
  };
47171
- function JPoint(curve, x, y, z8) {
47171
+ function JPoint(curve, x, y, z9) {
47172
47172
  Base.BasePoint.call(this, curve, "jacobian");
47173
- if (x === null && y === null && z8 === null) {
47173
+ if (x === null && y === null && z9 === null) {
47174
47174
  this.x = this.curve.one;
47175
47175
  this.y = this.curve.one;
47176
47176
  this.z = new BN(0);
47177
47177
  } else {
47178
47178
  this.x = new BN(x, 16);
47179
47179
  this.y = new BN(y, 16);
47180
- this.z = new BN(z8, 16);
47180
+ this.z = new BN(z9, 16);
47181
47181
  }
47182
47182
  if (!this.x.red)
47183
47183
  this.x = this.x.toRed(this.curve.red);
@@ -47188,8 +47188,8 @@ var require_short = __commonJS({
47188
47188
  this.zOne = this.z === this.curve.one;
47189
47189
  }
47190
47190
  inherits2(JPoint, Base.BasePoint);
47191
- ShortCurve.prototype.jpoint = function jpoint(x, y, z8) {
47192
- return new JPoint(this, x, y, z8);
47191
+ ShortCurve.prototype.jpoint = function jpoint(x, y, z9) {
47192
+ return new JPoint(this, x, y, z9);
47193
47193
  };
47194
47194
  JPoint.prototype.toP = function toP() {
47195
47195
  if (this.isInfinity())
@@ -47502,14 +47502,14 @@ var require_mont = __commonJS({
47502
47502
  var y = rhs.redSqrt();
47503
47503
  return y.redSqr().cmp(rhs) === 0;
47504
47504
  };
47505
- function Point(curve, x, z8) {
47505
+ function Point(curve, x, z9) {
47506
47506
  Base.BasePoint.call(this, curve, "projective");
47507
- if (x === null && z8 === null) {
47507
+ if (x === null && z9 === null) {
47508
47508
  this.x = this.curve.one;
47509
47509
  this.z = this.curve.zero;
47510
47510
  } else {
47511
47511
  this.x = new BN(x, 16);
47512
- this.z = new BN(z8, 16);
47512
+ this.z = new BN(z9, 16);
47513
47513
  if (!this.x.red)
47514
47514
  this.x = this.x.toRed(this.curve.red);
47515
47515
  if (!this.z.red)
@@ -47520,8 +47520,8 @@ var require_mont = __commonJS({
47520
47520
  MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
47521
47521
  return this.point(utils.toArray(bytes, enc), 1);
47522
47522
  };
47523
- MontCurve.prototype.point = function point(x, z8) {
47524
- return new Point(this, x, z8);
47523
+ MontCurve.prototype.point = function point(x, z9) {
47524
+ return new Point(this, x, z9);
47525
47525
  };
47526
47526
  MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
47527
47527
  return Point.fromJSON(this, obj);
@@ -47642,8 +47642,8 @@ var require_edwards = __commonJS({
47642
47642
  else
47643
47643
  return this.c.redMul(num);
47644
47644
  };
47645
- EdwardsCurve.prototype.jpoint = function jpoint(x, y, z8, t) {
47646
- return this.point(x, y, z8, t);
47645
+ EdwardsCurve.prototype.jpoint = function jpoint(x, y, z9, t) {
47646
+ return this.point(x, y, z9, t);
47647
47647
  };
47648
47648
  EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
47649
47649
  x = new BN(x, 16);
@@ -47692,9 +47692,9 @@ var require_edwards = __commonJS({
47692
47692
  var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));
47693
47693
  return lhs.cmp(rhs) === 0;
47694
47694
  };
47695
- function Point(curve, x, y, z8, t) {
47695
+ function Point(curve, x, y, z9, t) {
47696
47696
  Base.BasePoint.call(this, curve, "projective");
47697
- if (x === null && y === null && z8 === null) {
47697
+ if (x === null && y === null && z9 === null) {
47698
47698
  this.x = this.curve.zero;
47699
47699
  this.y = this.curve.one;
47700
47700
  this.z = this.curve.one;
@@ -47703,7 +47703,7 @@ var require_edwards = __commonJS({
47703
47703
  } else {
47704
47704
  this.x = new BN(x, 16);
47705
47705
  this.y = new BN(y, 16);
47706
- this.z = z8 ? new BN(z8, 16) : this.curve.one;
47706
+ this.z = z9 ? new BN(z9, 16) : this.curve.one;
47707
47707
  this.t = t && new BN(t, 16);
47708
47708
  if (!this.x.red)
47709
47709
  this.x = this.x.toRed(this.curve.red);
@@ -47725,8 +47725,8 @@ var require_edwards = __commonJS({
47725
47725
  EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) {
47726
47726
  return Point.fromJSON(this, obj);
47727
47727
  };
47728
- EdwardsCurve.prototype.point = function point(x, y, z8, t) {
47729
- return new Point(this, x, y, z8, t);
47728
+ EdwardsCurve.prototype.point = function point(x, y, z9, t) {
47729
+ return new Point(this, x, y, z9, t);
47730
47730
  };
47731
47731
  Point.fromJSON = function fromJSON(curve, obj) {
47732
47732
  return new Point(curve, obj[0], obj[1], obj[2]);
@@ -48248,25 +48248,25 @@ var require_common4 = __commonJS({
48248
48248
  "use strict";
48249
48249
  var utils = require_utils4();
48250
48250
  var rotr32 = utils.rotr32;
48251
- function ft_1(s, x, y, z8) {
48251
+ function ft_1(s, x, y, z9) {
48252
48252
  if (s === 0)
48253
- return ch32(x, y, z8);
48253
+ return ch32(x, y, z9);
48254
48254
  if (s === 1 || s === 3)
48255
- return p32(x, y, z8);
48255
+ return p32(x, y, z9);
48256
48256
  if (s === 2)
48257
- return maj32(x, y, z8);
48257
+ return maj32(x, y, z9);
48258
48258
  }
48259
48259
  exports2.ft_1 = ft_1;
48260
- function ch32(x, y, z8) {
48261
- return x & y ^ ~x & z8;
48260
+ function ch32(x, y, z9) {
48261
+ return x & y ^ ~x & z9;
48262
48262
  }
48263
48263
  exports2.ch32 = ch32;
48264
- function maj32(x, y, z8) {
48265
- return x & y ^ x & z8 ^ y & z8;
48264
+ function maj32(x, y, z9) {
48265
+ return x & y ^ x & z9 ^ y & z9;
48266
48266
  }
48267
48267
  exports2.maj32 = maj32;
48268
- function p32(x, y, z8) {
48269
- return x ^ y ^ z8;
48268
+ function p32(x, y, z9) {
48269
+ return x ^ y ^ z9;
48270
48270
  }
48271
48271
  exports2.p32 = p32;
48272
48272
  function s0_256(x) {
@@ -49117,17 +49117,17 @@ var require_ripemd = __commonJS({
49117
49117
  else
49118
49118
  return utils.split32(this.h, "little");
49119
49119
  };
49120
- function f(j, x, y, z8) {
49120
+ function f(j, x, y, z9) {
49121
49121
  if (j <= 15)
49122
- return x ^ y ^ z8;
49122
+ return x ^ y ^ z9;
49123
49123
  else if (j <= 31)
49124
- return x & y | ~x & z8;
49124
+ return x & y | ~x & z9;
49125
49125
  else if (j <= 47)
49126
- return (x | ~y) ^ z8;
49126
+ return (x | ~y) ^ z9;
49127
49127
  else if (j <= 63)
49128
- return x & z8 | y & ~z8;
49128
+ return x & z9 | y & ~z9;
49129
49129
  else
49130
- return x ^ (y | ~z8);
49130
+ return x ^ (y | ~z9);
49131
49131
  }
49132
49132
  function K(j) {
49133
49133
  if (j <= 15)
@@ -51477,9 +51477,9 @@ var require_dist4 = __commonJS({
51477
51477
  exports2.bech32m = exports2.bech32 = void 0;
51478
51478
  var ALPHABET2 = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
51479
51479
  var ALPHABET_MAP = {};
51480
- for (let z8 = 0; z8 < ALPHABET2.length; z8++) {
51481
- const x = ALPHABET2.charAt(z8);
51482
- ALPHABET_MAP[x] = z8;
51480
+ for (let z9 = 0; z9 < ALPHABET2.length; z9++) {
51481
+ const x = ALPHABET2.charAt(z9);
51482
+ ALPHABET_MAP[x] = z9;
51483
51483
  }
51484
51484
  function polymodStep(pre) {
51485
51485
  const b = pre >> 25;
@@ -52048,6 +52048,7 @@ var init_wc_transport = __esm({
52048
52048
  });
52049
52049
 
52050
52050
  // src/index.ts
52051
+ var net = __toESM(require("net"));
52051
52052
  var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
52052
52053
 
52053
52054
  // src/boundary/errors.ts
@@ -52287,9 +52288,9 @@ function errEnvelope(error) {
52287
52288
 
52288
52289
  // src/util/btc-address.ts
52289
52290
  var import_bitcoinjs_lib = require("bitcoinjs-lib");
52290
- function networkObj(net) {
52291
- if (net === "mainnet") return import_bitcoinjs_lib.networks.bitcoin;
52292
- if (net === "testnet") return import_bitcoinjs_lib.networks.testnet;
52291
+ function networkObj(net2) {
52292
+ if (net2 === "mainnet") return import_bitcoinjs_lib.networks.bitcoin;
52293
+ if (net2 === "testnet") return import_bitcoinjs_lib.networks.testnet;
52293
52294
  return import_bitcoinjs_lib.networks.regtest;
52294
52295
  }
52295
52296
  function checkBtcAddress(addr, expected) {
@@ -52968,6 +52969,14 @@ var BoundaryCore = class {
52968
52969
  return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
52969
52970
  }
52970
52971
  // ---- meta ----
52972
+ world() {
52973
+ return {
52974
+ adapter: this.deps.adapter,
52975
+ network: this.deps.network,
52976
+ chainId: this.deps.chainId,
52977
+ practiceWorld: this.deps.network !== "mainnet"
52978
+ };
52979
+ }
52971
52980
  async describeBoundary() {
52972
52981
  const info = this.deps.plugin.describe();
52973
52982
  const source = { id: "boundary-core", kind: "core", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() };
@@ -56969,16 +56978,16 @@ var Kr160 = /* @__PURE__ */ Uint32Array.from([
56969
56978
  2053994217,
56970
56979
  0
56971
56980
  ]);
56972
- function ripemd_f(group, x, y, z8) {
56981
+ function ripemd_f(group, x, y, z9) {
56973
56982
  if (group === 0)
56974
- return x ^ y ^ z8;
56983
+ return x ^ y ^ z9;
56975
56984
  if (group === 1)
56976
- return x & y | ~x & z8;
56985
+ return x & y | ~x & z9;
56977
56986
  if (group === 2)
56978
- return (x | ~y) ^ z8;
56987
+ return (x | ~y) ^ z9;
56979
56988
  if (group === 3)
56980
- return x & z8 | y & ~z8;
56981
- return x ^ (y | ~z8);
56989
+ return x & z9 | y & ~z9;
56990
+ return x ^ (y | ~z9);
56982
56991
  }
56983
56992
  var BUF_160 = /* @__PURE__ */ new Uint32Array(16);
56984
56993
  var RIPEMD160 = class extends HashMD {
@@ -90240,7 +90249,8 @@ function createBoundary(config, opts) {
90240
90249
  capabilities: () => ({
90241
90250
  reads: { public: true, authenticated: "available" },
90242
90251
  writes: { enabled: true, signerModes: ["external"], activeMode: "external" },
90243
- signerSetupTool: false
90252
+ signerSetupTool: false,
90253
+ networkSwitch: false
90244
90254
  }),
90245
90255
  configFingerprint
90246
90256
  });
@@ -90320,6 +90330,7 @@ function createBoundary(config, opts) {
90320
90330
  ...config.borrower ? { borrowerAddress: config.borrower } : {},
90321
90331
  signer: manager,
90322
90332
  // B3: the mock sandbox runs every ceremony class; reads have no login gate.
90333
+ // Plan 13 M13-5: no network_switch on mock — its world is pinned by the config.
90323
90334
  capabilities: () => ({
90324
90335
  reads: { public: true, authenticated: "available" },
90325
90336
  writes: {
@@ -90327,7 +90338,8 @@ function createBoundary(config, opts) {
90327
90338
  signerModes: ["external", "keystore", "mock-simulated", "safe", "safe-module"],
90328
90339
  activeMode: manager.mode()
90329
90340
  },
90330
- signerSetupTool: true
90341
+ signerSetupTool: true,
90342
+ networkSwitch: false
90331
90343
  }),
90332
90344
  configFingerprint
90333
90345
  });
@@ -90388,7 +90400,9 @@ async function createRealBoundary(config, wallet) {
90388
90400
  signerModes: [],
90389
90401
  activeMode: manager.mode()
90390
90402
  },
90391
- signerSetupTool: true
90403
+ signerSetupTool: true,
90404
+ // Plan 13: the real adapter switches networks by conversation (network_switch tool).
90405
+ networkSwitch: true
90392
90406
  });
90393
90407
  const boundary = new BoundaryCore({
90394
90408
  plugin,
@@ -90462,6 +90476,58 @@ async function buildBoundary(configResult) {
90462
90476
  return { boundaryResult: { ok: true, boundary }, signer, dispose };
90463
90477
  }
90464
90478
 
90479
+ // src/network-switch.ts
90480
+ var SWITCHABLE_NETWORKS = ["sepolia", "mainnet"];
90481
+ function createNetworkSwitchRuntime(opts) {
90482
+ return {
90483
+ current() {
90484
+ const b = opts.getBoot().boundaryResult;
90485
+ if (!b.ok) return null;
90486
+ const w = b.boundary.world();
90487
+ return { network: w.network, chainId: w.chainId, practiceWorld: w.practiceWorld };
90488
+ },
90489
+ async switchTo(network) {
90490
+ const targetEnv = { ...opts.env, DH_NETWORK: network };
90491
+ delete targetEnv["DH_MAINNET_WRITES_ACK"];
90492
+ const configResult = resolveBoundaryConfig(targetEnv);
90493
+ if (!configResult.ok) return { ok: false, error: configResult.error };
90494
+ const next = await buildBoundary(configResult);
90495
+ if (!next.boundaryResult.ok) {
90496
+ next.dispose();
90497
+ return { ok: false, error: next.boundaryResult.error };
90498
+ }
90499
+ opts.swap(next);
90500
+ return { ok: true };
90501
+ }
90502
+ };
90503
+ }
90504
+ function assembleWorld(opts) {
90505
+ let boot = opts.boot;
90506
+ const deps = {
90507
+ boundaryResult: boot.boundaryResult,
90508
+ ...boot.mockControl ? { mockControl: boot.mockControl } : {},
90509
+ ...boot.signer ? { signer: boot.signer } : {},
90510
+ ...opts.configResult.ok && opts.configResult.config.adapter === "mock" && opts.configResult.config.chainId ? { chainId: opts.configResult.config.chainId } : {}
90511
+ };
90512
+ if ((opts.env["DH_ADAPTER"] ?? "real") !== "mock") {
90513
+ deps.networkSwitch = createNetworkSwitchRuntime({
90514
+ env: opts.env,
90515
+ getBoot: () => boot,
90516
+ swap: (next) => {
90517
+ const old = boot;
90518
+ boot = next;
90519
+ deps.boundaryResult = next.boundaryResult;
90520
+ if (next.signer) deps.signer = next.signer;
90521
+ else delete deps.signer;
90522
+ old.dispose();
90523
+ const w = next.boundaryResult.ok ? next.boundaryResult.boundary.world() : null;
90524
+ opts.log?.(`network switched \u2014 now ${w ? `${w.network} (chainId ${w.chainId})` : "unavailable"}.`);
90525
+ }
90526
+ });
90527
+ }
90528
+ return { deps, dispose: () => boot.dispose() };
90529
+ }
90530
+
90465
90531
  // src/server.ts
90466
90532
  var import_mcp2 = require("@modelcontextprotocol/sdk/server/mcp.js");
90467
90533
 
@@ -90522,6 +90588,22 @@ Re-invoke with confirmed: true ONLY after a human has approved this exact operat
90522
90588
  isError: true
90523
90589
  };
90524
90590
  }
90591
+ function envStamp(b) {
90592
+ if (!b.ok) return "environment: UNKNOWN \u2014 boundary unavailable";
90593
+ const w = b.boundary.world();
90594
+ const money = w.network === "mainnet" ? "REAL MONEY" : w.network === "mock" ? "PRACTICE SANDBOX (no real money)" : "PRACTICE FUNDS (test network)";
90595
+ return `environment: ${w.network} \u2014 ${money}`;
90596
+ }
90597
+ async function guardedWrite(getB, fn) {
90598
+ const result = await guarded(fn);
90599
+ const stamp = envStamp(getB());
90600
+ const content = result.content.map(
90601
+ (c, i) => i === result.content.length - 1 ? { ...c, text: `${c.text}
90602
+
90603
+ ${stamp}` } : c
90604
+ );
90605
+ return { ...result, content };
90606
+ }
90525
90607
  async function guarded(fn) {
90526
90608
  try {
90527
90609
  return await fn();
@@ -90608,7 +90690,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90608
90690
  },
90609
90691
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
90610
90692
  },
90611
- async ({ selectedTerm, confirmed }) => guarded(async () => {
90693
+ async ({ selectedTerm, confirmed }) => guardedWrite(getB, async () => {
90612
90694
  const gate = requireConfirmation(confirmed, `create a ${selectedTerm}-month lending position`);
90613
90695
  if (gate) return gate;
90614
90696
  const problem = checkSelectedTerm(selectedTerm);
@@ -90631,7 +90713,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90631
90713
  },
90632
90714
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
90633
90715
  },
90634
- async ({ positionId, amountUcd, confirmed }) => guarded(async () => {
90716
+ async ({ positionId, amountUcd, confirmed }) => guardedWrite(getB, async () => {
90635
90717
  const gate = requireConfirmation(confirmed, `mint ${amountUcd} UCD against position ${positionId}`);
90636
90718
  if (gate) return gate;
90637
90719
  const problem = checkPositionIdHex(positionId) ?? checkUcdAmount(amountUcd);
@@ -90657,7 +90739,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90657
90739
  },
90658
90740
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
90659
90741
  },
90660
- async ({ positionId, amountUcd, repayAll, confirmed }) => guarded(async () => {
90742
+ async ({ positionId, amountUcd, repayAll, confirmed }) => guardedWrite(getB, async () => {
90661
90743
  if (repayAll === true === (amountUcd !== void 0)) {
90662
90744
  return validationFailed("provide exactly one of amountUcd or repayAll: true");
90663
90745
  }
@@ -90695,7 +90777,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90695
90777
  },
90696
90778
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
90697
90779
  },
90698
- async ({ positionId, selectedTerm, confirmed }) => guarded(async () => {
90780
+ async ({ positionId, selectedTerm, confirmed }) => guardedWrite(getB, async () => {
90699
90781
  const gate = requireConfirmation(confirmed, `renew position ${positionId} for a ${selectedTerm}-month term`);
90700
90782
  if (gate) return gate;
90701
90783
  const problem = checkPositionIdHex(positionId) ?? checkSelectedTerm(selectedTerm);
@@ -90722,7 +90804,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90722
90804
  },
90723
90805
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
90724
90806
  },
90725
- async ({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats, confirmed }) => guarded(async () => {
90807
+ async ({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats, confirmed }) => guardedWrite(getB, async () => {
90726
90808
  const gate = requireConfirmation(
90727
90809
  confirmed,
90728
90810
  `withdraw ${amountSats} sats from position ${positionId} to ${btcAddress2} (UNRECOVERABLE)`
@@ -90747,7 +90829,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90747
90829
  },
90748
90830
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
90749
90831
  },
90750
- async ({ btcAddress: btcAddress2, confirmed }) => guarded(async () => {
90832
+ async ({ btcAddress: btcAddress2, confirmed }) => guardedWrite(getB, async () => {
90751
90833
  const gate = requireConfirmation(confirmed, `allowlist ${btcAddress2} as a BTC withdrawal destination`);
90752
90834
  if (gate) return gate;
90753
90835
  const b = getB();
@@ -90767,7 +90849,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90767
90849
  },
90768
90850
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
90769
90851
  },
90770
- async ({ btcAddresses, confirmed }) => guarded(async () => {
90852
+ async ({ btcAddresses, confirmed }) => guardedWrite(getB, async () => {
90771
90853
  const gate = requireConfirmation(confirmed, `install delegation (module + agent + ${btcAddresses.length} destination(s))`);
90772
90854
  if (gate) return gate;
90773
90855
  const b = getB();
@@ -90790,7 +90872,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90790
90872
  },
90791
90873
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
90792
90874
  },
90793
- async ({ positionId, renew, repay, mintFloorBps, confirmed }) => guarded(async () => {
90875
+ async ({ positionId, renew, repay, mintFloorBps, confirmed }) => guardedWrite(getB, async () => {
90794
90876
  const gate = requireConfirmation(confirmed, `grant agent scopes on ${positionId}`);
90795
90877
  if (gate) return gate;
90796
90878
  const b = getB();
@@ -90825,7 +90907,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
90825
90907
  openWorldHint: true
90826
90908
  }
90827
90909
  },
90828
- async ({ positionId, utxoTxid, utxoVout, invalidatorTxid, minConfirmations }) => guarded(async () => {
90910
+ async ({ positionId, utxoTxid, utxoVout, invalidatorTxid, minConfirmations }) => guardedWrite(getB, async () => {
90829
90911
  const problem = checkPositionIdHex(positionId);
90830
90912
  if (problem) return validationFailed(problem);
90831
90913
  const b = getB();
@@ -91057,7 +91139,7 @@ function registerPsmTools(server, getB) {
91057
91139
  },
91058
91140
  annotations: DESTRUCTIVE_WRITE_ANNOTATIONS2
91059
91141
  },
91060
- async ({ direction, amount, confirmed }) => guarded(async () => {
91142
+ async ({ direction, amount, confirmed }) => guardedWrite(getB, async () => {
91061
91143
  const inputToken = direction === "to-ucd" ? "USDC" : "UCD";
91062
91144
  const outputToken = direction === "to-ucd" ? "UCD" : "USDC";
91063
91145
  const gate = requireConfirmation(
@@ -91254,7 +91336,7 @@ function looksSecretShaped(value) {
91254
91336
  return /^0x[0-9a-fA-F]{32,}$/.test(value) || value.length >= 16 && !/\s/.test(value) && /[0-9]/.test(value) && /[a-zA-Z]/.test(value);
91255
91337
  }
91256
91338
  var SECRET_REFUSAL = "That value looks like a password or key. NEVER paste secrets into the conversation \u2014 they would enter the model context and transcripts. To provide keystore material, say 'unlock my keystore' (a secure local page opens and the password goes directly to the server), or set DH_KEYSTORE_PATH/DH_KEYSTORE_PASSWORD in the server environment.";
91257
- function registerSignerTool(server, runtime) {
91339
+ function registerSignerTool(server, getRuntime) {
91258
91340
  registerBoundaryTool(
91259
91341
  server,
91260
91342
  "signer_setup",
@@ -91269,6 +91351,15 @@ function registerSignerTool(server, runtime) {
91269
91351
  annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: false, readOnlyHint: false }
91270
91352
  },
91271
91353
  async ({ action, mode, safeAddress }) => guarded(async () => {
91354
+ const runtime = getRuntime();
91355
+ if (!runtime) {
91356
+ return renderError(
91357
+ boundaryError(
91358
+ "SIGNER_UNAVAILABLE",
91359
+ "no signer runtime is live \u2014 the boundary failed to boot. Fix the configuration (or recover by switching networks via network_switch), then retry."
91360
+ )
91361
+ );
91362
+ }
91272
91363
  const { manager, bridge } = runtime;
91273
91364
  if (mode !== void 0 && !MODES.includes(mode)) {
91274
91365
  return validationFailed(looksSecretShaped(mode) ? SECRET_REFUSAL : `mode '${mode}' is not one of: ${MODES.join(" | ")}`);
@@ -91362,6 +91453,7 @@ var GUIDE_TOPICS = [
91362
91453
  "safe",
91363
91454
  "delegation",
91364
91455
  "safety",
91456
+ "switch-network",
91365
91457
  "troubleshooting",
91366
91458
  "glossary"
91367
91459
  ];
@@ -91421,6 +91513,9 @@ signer modes exist; current terms (\`protocol_terms\`).
91421
91513
  - Not sure? \`signer_setup\` action \`status\` explains what is active and what is missing.
91422
91514
  - **No signer is also a valid start:** every public read works without one \u2014
91423
91515
  \`position_list {borrower}\` with the user's address needs no signer and no login.
91516
+ - **Wrong network?** On the real adapter the user can switch sepolia \u2194 mainnet by
91517
+ talking (\`network_switch\`, human-confirmed) \u2014 see \`guide switch-network\`. State
91518
+ the money reality after any switch.
91424
91519
 
91425
91520
  **3. First position.** \`loan_create\` with a term from \`protocol_terms\` (needs
91426
91521
  \`confirmed: true\` from the user). Then deposit BTC to the vault address
@@ -91695,6 +91790,29 @@ owners sign at leisure (\`psm_swap\` builds the pair) \u2014 that is the only Sa
91695
91790
  withdrawing to a wrong address. Repaid-in-full positions release all collateral.
91696
91791
  - **Practice vs real:** mock worlds are stated as such (\`boundary://info\`). Never let a
91697
91792
  user believe practice gains/losses are real, or vice versa.`,
91793
+ "switch-network": `# Switch network \u2014 sepolia \u2194 mainnet by conversation (real adapter)
91794
+
91795
+ The \`network_switch\` tool moves THIS SESSION between worlds. Check
91796
+ \`boundary://info\` capabilities first: \`networkSwitch: true\` means it is available
91797
+ (real adapter); in a practice sandbox (mock) the world is pinned by config \u2014 there is
91798
+ no switch, and that is by design.
91799
+
91800
+ **The rules, plainly:**
91801
+ - \`network_switch status\` \u2014 which network is active and whether money is real. Say
91802
+ this to the user BEFORE and AFTER any switch, always.
91803
+ - \`network_switch switch { network, confirmed: true }\` \u2014 the switch runs only after
91804
+ the human approves the card. sepolia = practice funds; mainnet = REAL MONEY.
91805
+ - NOTHING carries across: positions, vaults, signer bindings, logins are per-network.
91806
+ 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.
91810
+ - A pending signing ceremony blocks the switch (finish or decline it first).
91811
+ - The switch is session-scoped: when the server restarts, the configured default
91812
+ network returns.
91813
+
91814
+ After any switch: re-read \`boundary://info\`, then STATE the new network and money
91815
+ reality in your next message. The user must never have to ask which world they are in.`,
91698
91816
  troubleshooting: `# Troubleshooting \u2014 what error codes mean, in plain words
91699
91817
 
91700
91818
  - **SIGNER_UNAVAILABLE** \u2014 no authorization mode chosen/ready. Two real remedies: the
@@ -91705,7 +91823,11 @@ owners sign at leisure (\`psm_swap\` builds the pair) \u2014 that is the only Sa
91705
91823
  the same pair: keystore env pair, or "connect my wallet" (\`signer_setup connect\`). An
91706
91824
  EXPIRED login refuses the same way \u2014 reconnect on the user's word.
91707
91825
  - **Mainnet write refused** \u2014 mainnet writes are disabled unless the operator explicitly
91708
- arms them; the refusal is the standing gate, not a bug. Reads keep working.
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.
91828
+ - **"Wrong network" / wants mainnet or sepolia** \u2014 real adapter: \`network_switch\`
91829
+ (human-confirmed card; nothing carries across networks). Mock: the world is pinned by
91830
+ config \u2014 no switch exists there.
91709
91831
  - **External-mode withdraw refused** \u2014 withdraw-BTC under external mode is not shipped
91710
91832
  yet (the SDK signing-context seam is pending); keystore-mode withdraw works.
91711
91833
  - **Login throttled (mainnet)** \u2014 the broker limits logins per address; wait and retry.
@@ -91763,6 +91885,7 @@ var GUIDE_INDEX = `# Diamond Hands guide \u2014 topics
91763
91885
  - safe \u2014 borrowing as a Safe smart-account (single or multi-owner), allowlisting, timing \u2014 PRACTICE-ONLY today
91764
91886
  - delegation \u2014 one owner ceremony, then day-to-day solo: the agent, its cage, and what always stays with the owners \u2014 PRACTICE-ONLY today
91765
91887
  - safety \u2014 liquidation, expiry, irreversible sends, decline-is-safe
91888
+ - switch-network \u2014 moving this session between sepolia (practice) and mainnet (REAL MONEY): the card, what carries across (nothing), what stays gated
91766
91889
  - troubleshooting \u2014 error codes in plain words, with the real remedies
91767
91890
  - glossary \u2014 synonym map + disambiguations (use it to understand ANY user's vocabulary)
91768
91891
 
@@ -91869,6 +91992,94 @@ function registerGuidePrompts(server) {
91869
91992
  );
91870
91993
  }
91871
91994
 
91995
+ // src/tools/network-switch.ts
91996
+ var import_zod8 = require("zod");
91997
+ 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)`;
91999
+ }
92000
+ function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
92001
+ registerBoundaryTool(
92002
+ server,
92003
+ "network_switch",
92004
+ {
92005
+ 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.",
92007
+ inputSchema: {
92008
+ action: import_zod8.z.enum(["status", "switch"]).describe("status = current world; switch = change network (needs confirmed:true)"),
92009
+ network: import_zod8.z.string().optional().describe("switch target: sepolia | mainnet"),
92010
+ confirmed: import_zod8.z.boolean().optional().describe("HUMAN approval of this exact switch \u2014 never auto-set")
92011
+ },
92012
+ annotations: { destructiveHint: true }
92013
+ },
92014
+ async ({ action, network, confirmed }) => guarded(async () => {
92015
+ const current = runtime.current();
92016
+ if (action === "status") {
92017
+ const lines = current ? [
92018
+ `Active network: ${current.network} (chainId ${current.chainId})`,
92019
+ `Money reality: ${current.practiceWorld ? "PRACTICE \u2014 no real money" : "REAL MONEY"}`
92020
+ ] : ["Active network: NONE \u2014 the boundary failed to boot (see any tool's error for the config cause)."];
92021
+ lines.push(
92022
+ `Switchable networks: ${SWITCHABLE_NETWORKS.join(", ")} (action 'switch', confirmed:true after human approval).`,
92023
+ "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.",
92025
+ "Session-scoped: the configured default network returns when the server restarts."
92026
+ );
92027
+ return { content: [{ type: "text", text: lines.join("\n") }] };
92028
+ }
92029
+ const target = (network ?? "").toLowerCase();
92030
+ if (!SWITCHABLE_NETWORKS.includes(target)) {
92031
+ return validationFailed(`network must be one of: ${SWITCHABLE_NETWORKS.join(", ")} (got '${network ?? ""}').`);
92032
+ }
92033
+ if (current && current.network === target) {
92034
+ return validationFailed(`already on ${target} \u2014 nothing to switch.`);
92035
+ }
92036
+ const pending = getSigner()?.bridge.pendingCount() ?? 0;
92037
+ if (pending > 0) {
92038
+ return renderError(
92039
+ boundaryError(
92040
+ "UPSTREAM_REJECTED",
92041
+ `network switch refused: ${pending} signing ceremony(ies) still pending. Finish or decline them in the wallet/approval page (or let them expire), then switch.`
92042
+ )
92043
+ );
92044
+ }
92045
+ if (confirmed !== true) {
92046
+ const from = current ? moneyLine(current.network) : "no live network (boot error)";
92047
+ return {
92048
+ content: [
92049
+ {
92050
+ type: "text",
92051
+ text: `CONFIRMATION REQUIRED \u2014 network switch.
92052
+ FROM: ${from}
92053
+ TO: ${moneyLine(target)}
92054
+ - 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.
92056
+ - Session-scoped: the configured default network returns on server restart.
92057
+ Re-invoke with confirmed: true ONLY after a human has approved this exact switch. Do not set it on your own.`
92058
+ }
92059
+ ],
92060
+ isError: true
92061
+ };
92062
+ }
92063
+ const result = await runtime.switchTo(target);
92064
+ if (!result.ok) return renderError(result.error);
92065
+ const b = getB();
92066
+ const world = b.ok ? b.boundary.world() : null;
92067
+ return {
92068
+ content: [
92069
+ {
92070
+ type: "text",
92071
+ text: `SWITCHED. Active network is now: ${world ? moneyLine(world.network) : target}.
92072
+ ` + (world ? `chainId: ${world.chainId}
92073
+ ` : "") + `Signer bindings for ${target} (if any) were loaded from this network's own state; re-authorize via signer_setup if needed.
92074
+ Session-scoped: the configured default returns on restart.
92075
+ NOW: re-read boundary://info and STATE the new environment and money reality to the user before any action.`
92076
+ }
92077
+ ]
92078
+ };
92079
+ })
92080
+ );
92081
+ }
92082
+
91872
92083
  // src/resources/position.ts
91873
92084
  var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
91874
92085
  function registerPositionResource(server, getB) {
@@ -91965,8 +92176,8 @@ function registerBoundaryInfoResource(server, getB) {
91965
92176
  }
91966
92177
 
91967
92178
  // src/server.ts
91968
- var SERVER_VERSION = "0.2.1";
91969
- 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.";
92179
+ var SERVER_VERSION = "0.3.1";
92180
+ 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.";
91970
92181
  function createServer2(deps) {
91971
92182
  const server = new import_mcp2.McpServer(
91972
92183
  {
@@ -91990,13 +92201,17 @@ function createServer2(deps) {
91990
92201
  if (deps.mockControl) {
91991
92202
  registerMockControlTool(server, deps.mockControl, deps.chainId);
91992
92203
  }
91993
- if (deps.signer) {
91994
- registerSignerTool(server, deps.signer);
92204
+ if (deps.signer || deps.networkSwitch) {
92205
+ registerSignerTool(server, () => deps.signer);
92206
+ }
92207
+ if (deps.networkSwitch) {
92208
+ registerNetworkSwitchTool(server, getB, deps.networkSwitch, () => deps.signer);
91995
92209
  }
91996
92210
  return server;
91997
92211
  }
91998
92212
 
91999
92213
  // src/index.ts
92214
+ net.setDefaultAutoSelectFamilyAttemptTimeout(Math.max(net.getDefaultAutoSelectFamilyAttemptTimeout(), 2e3));
92000
92215
  if (process.argv.includes("--version")) {
92001
92216
  process.stdout.write(`${SERVER_VERSION}
92002
92217
  `);
@@ -92004,20 +92219,22 @@ if (process.argv.includes("--version")) {
92004
92219
  }
92005
92220
  async function main() {
92006
92221
  const configResult = resolveBoundaryConfig(process.env);
92007
- const boot = await buildBoundary(configResult);
92222
+ let boot = await buildBoundary(configResult);
92008
92223
  if (!boot.boundaryResult.ok) {
92009
92224
  process.stderr.write(`[dh-mcp] boundary not available: ${boot.boundaryResult.error.message}
92010
92225
  `);
92011
92226
  }
92012
- const server = createServer2({
92013
- boundaryResult: boot.boundaryResult,
92014
- ...boot.mockControl ? { mockControl: boot.mockControl } : {},
92015
- ...boot.signer ? { signer: boot.signer } : {},
92016
- ...configResult.ok && configResult.config.adapter === "mock" && configResult.config.chainId ? { chainId: configResult.config.chainId } : {}
92227
+ const world = assembleWorld({
92228
+ env: process.env,
92229
+ configResult,
92230
+ boot,
92231
+ log: (line) => process.stderr.write(`[dh-mcp] ${line}
92232
+ `)
92017
92233
  });
92234
+ const server = createServer2(world.deps);
92018
92235
  const transport = new import_stdio.StdioServerTransport();
92019
92236
  const cleanup = () => {
92020
- boot.dispose();
92237
+ world.dispose();
92021
92238
  process.exit(0);
92022
92239
  };
92023
92240
  process.on("SIGINT", cleanup);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-mcp",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "MCP server for the Diamond Hands protocol — Bitcoin-collateralized UCD lending with human-approved signing (sepolia by default; mainnet read-only)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {