@gvnrdao/dh-mcp 0.2.1 → 0.3.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 +6 -3
- package/dist/boundary.js +16 -3
- package/dist/index.js +316 -101
- package/package.json +1 -1
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.
|
|
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
|
|
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.0/dh-mcp-0.3.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.3.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.
|
|
20
|
+
(`latest/` and `v<version>/` — e.g. `v0.3.0/`).
|
|
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
|
|
301
|
-
const x = ALPHABET2.charAt(
|
|
302
|
-
ALPHABET_MAP[x] =
|
|
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;
|
|
@@ -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
|
|
43147
|
-
|
|
43148
|
-
while (this.pow(
|
|
43149
|
-
|
|
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(
|
|
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
|
|
46030
|
-
|
|
46031
|
-
while (this.pow(
|
|
46032
|
-
|
|
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(
|
|
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
|
|
46270
|
+
var z9;
|
|
46271
46271
|
var mod = k.andln(ws - 1);
|
|
46272
46272
|
if (k.isOdd()) {
|
|
46273
46273
|
if (mod > (ws >> 1) - 1)
|
|
46274
|
-
|
|
46274
|
+
z9 = (ws >> 1) - mod;
|
|
46275
46275
|
else
|
|
46276
|
-
|
|
46277
|
-
k.isubn(
|
|
46276
|
+
z9 = mod;
|
|
46277
|
+
k.isubn(z9);
|
|
46278
46278
|
} else {
|
|
46279
|
-
|
|
46279
|
+
z9 = 0;
|
|
46280
46280
|
}
|
|
46281
|
-
naf[i] =
|
|
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
|
|
46495
|
-
assert(
|
|
46494
|
+
var z9 = naf[i];
|
|
46495
|
+
assert(z9 !== 0);
|
|
46496
46496
|
if (p.type === "affine") {
|
|
46497
|
-
if (
|
|
46498
|
-
acc = acc.mixedAdd(wnd[
|
|
46497
|
+
if (z9 > 0)
|
|
46498
|
+
acc = acc.mixedAdd(wnd[z9 - 1 >> 1]);
|
|
46499
46499
|
else
|
|
46500
|
-
acc = acc.mixedAdd(wnd[-
|
|
46500
|
+
acc = acc.mixedAdd(wnd[-z9 - 1 >> 1].neg());
|
|
46501
46501
|
} else {
|
|
46502
|
-
if (
|
|
46503
|
-
acc = acc.add(wnd[
|
|
46502
|
+
if (z9 > 0)
|
|
46503
|
+
acc = acc.add(wnd[z9 - 1 >> 1]);
|
|
46504
46504
|
else
|
|
46505
|
-
acc = acc.add(wnd[-
|
|
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
|
|
46608
|
+
var z9 = tmp[j];
|
|
46609
46609
|
p;
|
|
46610
|
-
if (
|
|
46610
|
+
if (z9 === 0)
|
|
46611
46611
|
continue;
|
|
46612
|
-
else if (
|
|
46613
|
-
p = wnd[j][
|
|
46614
|
-
else if (
|
|
46615
|
-
p = wnd[j][-
|
|
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,
|
|
47171
|
+
function JPoint(curve, x, y, z9) {
|
|
47172
47172
|
Base.BasePoint.call(this, curve, "jacobian");
|
|
47173
|
-
if (x === null && y === 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(
|
|
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,
|
|
47192
|
-
return new JPoint(this, x, y,
|
|
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,
|
|
47505
|
+
function Point(curve, x, z9) {
|
|
47506
47506
|
Base.BasePoint.call(this, curve, "projective");
|
|
47507
|
-
if (x === 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(
|
|
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,
|
|
47524
|
-
return new Point(this, x,
|
|
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,
|
|
47646
|
-
return this.point(x, y,
|
|
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,
|
|
47695
|
+
function Point(curve, x, y, z9, t) {
|
|
47696
47696
|
Base.BasePoint.call(this, curve, "projective");
|
|
47697
|
-
if (x === null && y === 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 =
|
|
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,
|
|
47729
|
-
return new Point(this, x, y,
|
|
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,
|
|
48251
|
+
function ft_1(s, x, y, z9) {
|
|
48252
48252
|
if (s === 0)
|
|
48253
|
-
return ch32(x, y,
|
|
48253
|
+
return ch32(x, y, z9);
|
|
48254
48254
|
if (s === 1 || s === 3)
|
|
48255
|
-
return p32(x, y,
|
|
48255
|
+
return p32(x, y, z9);
|
|
48256
48256
|
if (s === 2)
|
|
48257
|
-
return maj32(x, y,
|
|
48257
|
+
return maj32(x, y, z9);
|
|
48258
48258
|
}
|
|
48259
48259
|
exports2.ft_1 = ft_1;
|
|
48260
|
-
function ch32(x, y,
|
|
48261
|
-
return x & y ^ ~x &
|
|
48260
|
+
function ch32(x, y, z9) {
|
|
48261
|
+
return x & y ^ ~x & z9;
|
|
48262
48262
|
}
|
|
48263
48263
|
exports2.ch32 = ch32;
|
|
48264
|
-
function maj32(x, y,
|
|
48265
|
-
return x & y ^ x &
|
|
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,
|
|
48269
|
-
return x ^ y ^
|
|
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,
|
|
49120
|
+
function f(j, x, y, z9) {
|
|
49121
49121
|
if (j <= 15)
|
|
49122
|
-
return x ^ y ^
|
|
49122
|
+
return x ^ y ^ z9;
|
|
49123
49123
|
else if (j <= 31)
|
|
49124
|
-
return x & y | ~x &
|
|
49124
|
+
return x & y | ~x & z9;
|
|
49125
49125
|
else if (j <= 47)
|
|
49126
|
-
return (x | ~y) ^
|
|
49126
|
+
return (x | ~y) ^ z9;
|
|
49127
49127
|
else if (j <= 63)
|
|
49128
|
-
return x &
|
|
49128
|
+
return x & z9 | y & ~z9;
|
|
49129
49129
|
else
|
|
49130
|
-
return x ^ (y | ~
|
|
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
|
|
51481
|
-
const x = ALPHABET2.charAt(
|
|
51482
|
-
ALPHABET_MAP[x] =
|
|
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;
|
|
@@ -52968,6 +52968,14 @@ var BoundaryCore = class {
|
|
|
52968
52968
|
return okEnvelope({ releasedSats: r.value.releasedSats }, r.source);
|
|
52969
52969
|
}
|
|
52970
52970
|
// ---- meta ----
|
|
52971
|
+
world() {
|
|
52972
|
+
return {
|
|
52973
|
+
adapter: this.deps.adapter,
|
|
52974
|
+
network: this.deps.network,
|
|
52975
|
+
chainId: this.deps.chainId,
|
|
52976
|
+
practiceWorld: this.deps.network !== "mainnet"
|
|
52977
|
+
};
|
|
52978
|
+
}
|
|
52971
52979
|
async describeBoundary() {
|
|
52972
52980
|
const info = this.deps.plugin.describe();
|
|
52973
52981
|
const source = { id: "boundary-core", kind: "core", fetchedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -56969,16 +56977,16 @@ var Kr160 = /* @__PURE__ */ Uint32Array.from([
|
|
|
56969
56977
|
2053994217,
|
|
56970
56978
|
0
|
|
56971
56979
|
]);
|
|
56972
|
-
function ripemd_f(group, x, y,
|
|
56980
|
+
function ripemd_f(group, x, y, z9) {
|
|
56973
56981
|
if (group === 0)
|
|
56974
|
-
return x ^ y ^
|
|
56982
|
+
return x ^ y ^ z9;
|
|
56975
56983
|
if (group === 1)
|
|
56976
|
-
return x & y | ~x &
|
|
56984
|
+
return x & y | ~x & z9;
|
|
56977
56985
|
if (group === 2)
|
|
56978
|
-
return (x | ~y) ^
|
|
56986
|
+
return (x | ~y) ^ z9;
|
|
56979
56987
|
if (group === 3)
|
|
56980
|
-
return x &
|
|
56981
|
-
return x ^ (y | ~
|
|
56988
|
+
return x & z9 | y & ~z9;
|
|
56989
|
+
return x ^ (y | ~z9);
|
|
56982
56990
|
}
|
|
56983
56991
|
var BUF_160 = /* @__PURE__ */ new Uint32Array(16);
|
|
56984
56992
|
var RIPEMD160 = class extends HashMD {
|
|
@@ -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,
|
|
@@ -90462,6 +90475,58 @@ async function buildBoundary(configResult) {
|
|
|
90462
90475
|
return { boundaryResult: { ok: true, boundary }, signer, dispose };
|
|
90463
90476
|
}
|
|
90464
90477
|
|
|
90478
|
+
// src/network-switch.ts
|
|
90479
|
+
var SWITCHABLE_NETWORKS = ["sepolia", "mainnet"];
|
|
90480
|
+
function createNetworkSwitchRuntime(opts) {
|
|
90481
|
+
return {
|
|
90482
|
+
current() {
|
|
90483
|
+
const b = opts.getBoot().boundaryResult;
|
|
90484
|
+
if (!b.ok) return null;
|
|
90485
|
+
const w = b.boundary.world();
|
|
90486
|
+
return { network: w.network, chainId: w.chainId, practiceWorld: w.practiceWorld };
|
|
90487
|
+
},
|
|
90488
|
+
async switchTo(network) {
|
|
90489
|
+
const targetEnv = { ...opts.env, DH_NETWORK: network };
|
|
90490
|
+
delete targetEnv["DH_MAINNET_WRITES_ACK"];
|
|
90491
|
+
const configResult = resolveBoundaryConfig(targetEnv);
|
|
90492
|
+
if (!configResult.ok) return { ok: false, error: configResult.error };
|
|
90493
|
+
const next = await buildBoundary(configResult);
|
|
90494
|
+
if (!next.boundaryResult.ok) {
|
|
90495
|
+
next.dispose();
|
|
90496
|
+
return { ok: false, error: next.boundaryResult.error };
|
|
90497
|
+
}
|
|
90498
|
+
opts.swap(next);
|
|
90499
|
+
return { ok: true };
|
|
90500
|
+
}
|
|
90501
|
+
};
|
|
90502
|
+
}
|
|
90503
|
+
function assembleWorld(opts) {
|
|
90504
|
+
let boot = opts.boot;
|
|
90505
|
+
const deps = {
|
|
90506
|
+
boundaryResult: boot.boundaryResult,
|
|
90507
|
+
...boot.mockControl ? { mockControl: boot.mockControl } : {},
|
|
90508
|
+
...boot.signer ? { signer: boot.signer } : {},
|
|
90509
|
+
...opts.configResult.ok && opts.configResult.config.adapter === "mock" && opts.configResult.config.chainId ? { chainId: opts.configResult.config.chainId } : {}
|
|
90510
|
+
};
|
|
90511
|
+
if ((opts.env["DH_ADAPTER"] ?? "real") !== "mock") {
|
|
90512
|
+
deps.networkSwitch = createNetworkSwitchRuntime({
|
|
90513
|
+
env: opts.env,
|
|
90514
|
+
getBoot: () => boot,
|
|
90515
|
+
swap: (next) => {
|
|
90516
|
+
const old = boot;
|
|
90517
|
+
boot = next;
|
|
90518
|
+
deps.boundaryResult = next.boundaryResult;
|
|
90519
|
+
if (next.signer) deps.signer = next.signer;
|
|
90520
|
+
else delete deps.signer;
|
|
90521
|
+
old.dispose();
|
|
90522
|
+
const w = next.boundaryResult.ok ? next.boundaryResult.boundary.world() : null;
|
|
90523
|
+
opts.log?.(`network switched \u2014 now ${w ? `${w.network} (chainId ${w.chainId})` : "unavailable"}.`);
|
|
90524
|
+
}
|
|
90525
|
+
});
|
|
90526
|
+
}
|
|
90527
|
+
return { deps, dispose: () => boot.dispose() };
|
|
90528
|
+
}
|
|
90529
|
+
|
|
90465
90530
|
// src/server.ts
|
|
90466
90531
|
var import_mcp2 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
90467
90532
|
|
|
@@ -90522,6 +90587,22 @@ Re-invoke with confirmed: true ONLY after a human has approved this exact operat
|
|
|
90522
90587
|
isError: true
|
|
90523
90588
|
};
|
|
90524
90589
|
}
|
|
90590
|
+
function envStamp(b) {
|
|
90591
|
+
if (!b.ok) return "environment: UNKNOWN \u2014 boundary unavailable";
|
|
90592
|
+
const w = b.boundary.world();
|
|
90593
|
+
const money = w.network === "mainnet" ? "REAL MONEY" : w.network === "mock" ? "PRACTICE SANDBOX (no real money)" : "PRACTICE FUNDS (test network)";
|
|
90594
|
+
return `environment: ${w.network} \u2014 ${money}`;
|
|
90595
|
+
}
|
|
90596
|
+
async function guardedWrite(getB, fn) {
|
|
90597
|
+
const result = await guarded(fn);
|
|
90598
|
+
const stamp = envStamp(getB());
|
|
90599
|
+
const content = result.content.map(
|
|
90600
|
+
(c, i) => i === result.content.length - 1 ? { ...c, text: `${c.text}
|
|
90601
|
+
|
|
90602
|
+
${stamp}` } : c
|
|
90603
|
+
);
|
|
90604
|
+
return { ...result, content };
|
|
90605
|
+
}
|
|
90525
90606
|
async function guarded(fn) {
|
|
90526
90607
|
try {
|
|
90527
90608
|
return await fn();
|
|
@@ -90608,7 +90689,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90608
90689
|
},
|
|
90609
90690
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
90610
90691
|
},
|
|
90611
|
-
async ({ selectedTerm, confirmed }) =>
|
|
90692
|
+
async ({ selectedTerm, confirmed }) => guardedWrite(getB, async () => {
|
|
90612
90693
|
const gate = requireConfirmation(confirmed, `create a ${selectedTerm}-month lending position`);
|
|
90613
90694
|
if (gate) return gate;
|
|
90614
90695
|
const problem = checkSelectedTerm(selectedTerm);
|
|
@@ -90631,7 +90712,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90631
90712
|
},
|
|
90632
90713
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
90633
90714
|
},
|
|
90634
|
-
async ({ positionId, amountUcd, confirmed }) =>
|
|
90715
|
+
async ({ positionId, amountUcd, confirmed }) => guardedWrite(getB, async () => {
|
|
90635
90716
|
const gate = requireConfirmation(confirmed, `mint ${amountUcd} UCD against position ${positionId}`);
|
|
90636
90717
|
if (gate) return gate;
|
|
90637
90718
|
const problem = checkPositionIdHex(positionId) ?? checkUcdAmount(amountUcd);
|
|
@@ -90657,7 +90738,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90657
90738
|
},
|
|
90658
90739
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
90659
90740
|
},
|
|
90660
|
-
async ({ positionId, amountUcd, repayAll, confirmed }) =>
|
|
90741
|
+
async ({ positionId, amountUcd, repayAll, confirmed }) => guardedWrite(getB, async () => {
|
|
90661
90742
|
if (repayAll === true === (amountUcd !== void 0)) {
|
|
90662
90743
|
return validationFailed("provide exactly one of amountUcd or repayAll: true");
|
|
90663
90744
|
}
|
|
@@ -90695,7 +90776,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90695
90776
|
},
|
|
90696
90777
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
90697
90778
|
},
|
|
90698
|
-
async ({ positionId, selectedTerm, confirmed }) =>
|
|
90779
|
+
async ({ positionId, selectedTerm, confirmed }) => guardedWrite(getB, async () => {
|
|
90699
90780
|
const gate = requireConfirmation(confirmed, `renew position ${positionId} for a ${selectedTerm}-month term`);
|
|
90700
90781
|
if (gate) return gate;
|
|
90701
90782
|
const problem = checkPositionIdHex(positionId) ?? checkSelectedTerm(selectedTerm);
|
|
@@ -90722,7 +90803,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90722
90803
|
},
|
|
90723
90804
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
90724
90805
|
},
|
|
90725
|
-
async ({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats, confirmed }) =>
|
|
90806
|
+
async ({ positionId, btcAddress: btcAddress2, amountSats, networkFeeSats, confirmed }) => guardedWrite(getB, async () => {
|
|
90726
90807
|
const gate = requireConfirmation(
|
|
90727
90808
|
confirmed,
|
|
90728
90809
|
`withdraw ${amountSats} sats from position ${positionId} to ${btcAddress2} (UNRECOVERABLE)`
|
|
@@ -90747,7 +90828,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90747
90828
|
},
|
|
90748
90829
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
90749
90830
|
},
|
|
90750
|
-
async ({ btcAddress: btcAddress2, confirmed }) =>
|
|
90831
|
+
async ({ btcAddress: btcAddress2, confirmed }) => guardedWrite(getB, async () => {
|
|
90751
90832
|
const gate = requireConfirmation(confirmed, `allowlist ${btcAddress2} as a BTC withdrawal destination`);
|
|
90752
90833
|
if (gate) return gate;
|
|
90753
90834
|
const b = getB();
|
|
@@ -90767,7 +90848,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90767
90848
|
},
|
|
90768
90849
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
90769
90850
|
},
|
|
90770
|
-
async ({ btcAddresses, confirmed }) =>
|
|
90851
|
+
async ({ btcAddresses, confirmed }) => guardedWrite(getB, async () => {
|
|
90771
90852
|
const gate = requireConfirmation(confirmed, `install delegation (module + agent + ${btcAddresses.length} destination(s))`);
|
|
90772
90853
|
if (gate) return gate;
|
|
90773
90854
|
const b = getB();
|
|
@@ -90790,7 +90871,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90790
90871
|
},
|
|
90791
90872
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS
|
|
90792
90873
|
},
|
|
90793
|
-
async ({ positionId, renew, repay, mintFloorBps, confirmed }) =>
|
|
90874
|
+
async ({ positionId, renew, repay, mintFloorBps, confirmed }) => guardedWrite(getB, async () => {
|
|
90794
90875
|
const gate = requireConfirmation(confirmed, `grant agent scopes on ${positionId}`);
|
|
90795
90876
|
if (gate) return gate;
|
|
90796
90877
|
const b = getB();
|
|
@@ -90825,7 +90906,7 @@ function registerLoanTools(server, getB, adapter2 = "real") {
|
|
|
90825
90906
|
openWorldHint: true
|
|
90826
90907
|
}
|
|
90827
90908
|
},
|
|
90828
|
-
async ({ positionId, utxoTxid, utxoVout, invalidatorTxid, minConfirmations }) =>
|
|
90909
|
+
async ({ positionId, utxoTxid, utxoVout, invalidatorTxid, minConfirmations }) => guardedWrite(getB, async () => {
|
|
90829
90910
|
const problem = checkPositionIdHex(positionId);
|
|
90830
90911
|
if (problem) return validationFailed(problem);
|
|
90831
90912
|
const b = getB();
|
|
@@ -91057,7 +91138,7 @@ function registerPsmTools(server, getB) {
|
|
|
91057
91138
|
},
|
|
91058
91139
|
annotations: DESTRUCTIVE_WRITE_ANNOTATIONS2
|
|
91059
91140
|
},
|
|
91060
|
-
async ({ direction, amount, confirmed }) =>
|
|
91141
|
+
async ({ direction, amount, confirmed }) => guardedWrite(getB, async () => {
|
|
91061
91142
|
const inputToken = direction === "to-ucd" ? "USDC" : "UCD";
|
|
91062
91143
|
const outputToken = direction === "to-ucd" ? "UCD" : "USDC";
|
|
91063
91144
|
const gate = requireConfirmation(
|
|
@@ -91254,7 +91335,7 @@ function looksSecretShaped(value) {
|
|
|
91254
91335
|
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
91336
|
}
|
|
91256
91337
|
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,
|
|
91338
|
+
function registerSignerTool(server, getRuntime) {
|
|
91258
91339
|
registerBoundaryTool(
|
|
91259
91340
|
server,
|
|
91260
91341
|
"signer_setup",
|
|
@@ -91269,6 +91350,15 @@ function registerSignerTool(server, runtime) {
|
|
|
91269
91350
|
annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: false, readOnlyHint: false }
|
|
91270
91351
|
},
|
|
91271
91352
|
async ({ action, mode, safeAddress }) => guarded(async () => {
|
|
91353
|
+
const runtime = getRuntime();
|
|
91354
|
+
if (!runtime) {
|
|
91355
|
+
return renderError(
|
|
91356
|
+
boundaryError(
|
|
91357
|
+
"SIGNER_UNAVAILABLE",
|
|
91358
|
+
"no signer runtime is live \u2014 the boundary failed to boot. Fix the configuration (or recover by switching networks via network_switch), then retry."
|
|
91359
|
+
)
|
|
91360
|
+
);
|
|
91361
|
+
}
|
|
91272
91362
|
const { manager, bridge } = runtime;
|
|
91273
91363
|
if (mode !== void 0 && !MODES.includes(mode)) {
|
|
91274
91364
|
return validationFailed(looksSecretShaped(mode) ? SECRET_REFUSAL : `mode '${mode}' is not one of: ${MODES.join(" | ")}`);
|
|
@@ -91362,6 +91452,7 @@ var GUIDE_TOPICS = [
|
|
|
91362
91452
|
"safe",
|
|
91363
91453
|
"delegation",
|
|
91364
91454
|
"safety",
|
|
91455
|
+
"switch-network",
|
|
91365
91456
|
"troubleshooting",
|
|
91366
91457
|
"glossary"
|
|
91367
91458
|
];
|
|
@@ -91421,6 +91512,9 @@ signer modes exist; current terms (\`protocol_terms\`).
|
|
|
91421
91512
|
- Not sure? \`signer_setup\` action \`status\` explains what is active and what is missing.
|
|
91422
91513
|
- **No signer is also a valid start:** every public read works without one \u2014
|
|
91423
91514
|
\`position_list {borrower}\` with the user's address needs no signer and no login.
|
|
91515
|
+
- **Wrong network?** On the real adapter the user can switch sepolia \u2194 mainnet by
|
|
91516
|
+
talking (\`network_switch\`, human-confirmed) \u2014 see \`guide switch-network\`. State
|
|
91517
|
+
the money reality after any switch.
|
|
91424
91518
|
|
|
91425
91519
|
**3. First position.** \`loan_create\` with a term from \`protocol_terms\` (needs
|
|
91426
91520
|
\`confirmed: true\` from the user). Then deposit BTC to the vault address
|
|
@@ -91695,6 +91789,29 @@ owners sign at leisure (\`psm_swap\` builds the pair) \u2014 that is the only Sa
|
|
|
91695
91789
|
withdrawing to a wrong address. Repaid-in-full positions release all collateral.
|
|
91696
91790
|
- **Practice vs real:** mock worlds are stated as such (\`boundary://info\`). Never let a
|
|
91697
91791
|
user believe practice gains/losses are real, or vice versa.`,
|
|
91792
|
+
"switch-network": `# Switch network \u2014 sepolia \u2194 mainnet by conversation (real adapter)
|
|
91793
|
+
|
|
91794
|
+
The \`network_switch\` tool moves THIS SESSION between worlds. Check
|
|
91795
|
+
\`boundary://info\` capabilities first: \`networkSwitch: true\` means it is available
|
|
91796
|
+
(real adapter); in a practice sandbox (mock) the world is pinned by config \u2014 there is
|
|
91797
|
+
no switch, and that is by design.
|
|
91798
|
+
|
|
91799
|
+
**The rules, plainly:**
|
|
91800
|
+
- \`network_switch status\` \u2014 which network is active and whether money is real. Say
|
|
91801
|
+
this to the user BEFORE and AFTER any switch, always.
|
|
91802
|
+
- \`network_switch switch { network, confirmed: true }\` \u2014 the switch runs only after
|
|
91803
|
+
the human approves the card. sepolia = practice funds; mainnet = REAL MONEY.
|
|
91804
|
+
- NOTHING carries across: positions, vaults, signer bindings, logins are per-network.
|
|
91805
|
+
A sepolia position does not exist on mainnet and vice versa.
|
|
91806
|
+
- Switching to mainnet does NOT enable fund-moving operations: mainnet writes are
|
|
91807
|
+
operator-gated \u2014 reads work, write tools refuse with the true reason. Never imply
|
|
91808
|
+
otherwise.
|
|
91809
|
+
- A pending signing ceremony blocks the switch (finish or decline it first).
|
|
91810
|
+
- The switch is session-scoped: when the server restarts, the configured default
|
|
91811
|
+
network returns.
|
|
91812
|
+
|
|
91813
|
+
After any switch: re-read \`boundary://info\`, then STATE the new network and money
|
|
91814
|
+
reality in your next message. The user must never have to ask which world they are in.`,
|
|
91698
91815
|
troubleshooting: `# Troubleshooting \u2014 what error codes mean, in plain words
|
|
91699
91816
|
|
|
91700
91817
|
- **SIGNER_UNAVAILABLE** \u2014 no authorization mode chosen/ready. Two real remedies: the
|
|
@@ -91705,7 +91822,11 @@ owners sign at leisure (\`psm_swap\` builds the pair) \u2014 that is the only Sa
|
|
|
91705
91822
|
the same pair: keystore env pair, or "connect my wallet" (\`signer_setup connect\`). An
|
|
91706
91823
|
EXPIRED login refuses the same way \u2014 reconnect on the user's word.
|
|
91707
91824
|
- **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.
|
|
91825
|
+
arms them; the refusal is the standing gate, not a bug. Reads keep working. This is
|
|
91826
|
+
TRUE after a conversational network switch too \u2014 switching never arms writes.
|
|
91827
|
+
- **"Wrong network" / wants mainnet or sepolia** \u2014 real adapter: \`network_switch\`
|
|
91828
|
+
(human-confirmed card; nothing carries across networks). Mock: the world is pinned by
|
|
91829
|
+
config \u2014 no switch exists there.
|
|
91709
91830
|
- **External-mode withdraw refused** \u2014 withdraw-BTC under external mode is not shipped
|
|
91710
91831
|
yet (the SDK signing-context seam is pending); keystore-mode withdraw works.
|
|
91711
91832
|
- **Login throttled (mainnet)** \u2014 the broker limits logins per address; wait and retry.
|
|
@@ -91763,6 +91884,7 @@ var GUIDE_INDEX = `# Diamond Hands guide \u2014 topics
|
|
|
91763
91884
|
- safe \u2014 borrowing as a Safe smart-account (single or multi-owner), allowlisting, timing \u2014 PRACTICE-ONLY today
|
|
91764
91885
|
- 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
91886
|
- safety \u2014 liquidation, expiry, irreversible sends, decline-is-safe
|
|
91887
|
+
- switch-network \u2014 moving this session between sepolia (practice) and mainnet (REAL MONEY): the card, what carries across (nothing), what stays gated
|
|
91766
91888
|
- troubleshooting \u2014 error codes in plain words, with the real remedies
|
|
91767
91889
|
- glossary \u2014 synonym map + disambiguations (use it to understand ANY user's vocabulary)
|
|
91768
91890
|
|
|
@@ -91869,6 +91991,94 @@ function registerGuidePrompts(server) {
|
|
|
91869
91991
|
);
|
|
91870
91992
|
}
|
|
91871
91993
|
|
|
91994
|
+
// src/tools/network-switch.ts
|
|
91995
|
+
var import_zod8 = require("zod");
|
|
91996
|
+
function moneyLine(network) {
|
|
91997
|
+
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)`;
|
|
91998
|
+
}
|
|
91999
|
+
function registerNetworkSwitchTool(server, getB, runtime, getSigner) {
|
|
92000
|
+
registerBoundaryTool(
|
|
92001
|
+
server,
|
|
92002
|
+
"network_switch",
|
|
92003
|
+
{
|
|
92004
|
+
title: "Show or switch the active network",
|
|
92005
|
+
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.",
|
|
92006
|
+
inputSchema: {
|
|
92007
|
+
action: import_zod8.z.enum(["status", "switch"]).describe("status = current world; switch = change network (needs confirmed:true)"),
|
|
92008
|
+
network: import_zod8.z.string().optional().describe("switch target: sepolia | mainnet"),
|
|
92009
|
+
confirmed: import_zod8.z.boolean().optional().describe("HUMAN approval of this exact switch \u2014 never auto-set")
|
|
92010
|
+
},
|
|
92011
|
+
annotations: { destructiveHint: true }
|
|
92012
|
+
},
|
|
92013
|
+
async ({ action, network, confirmed }) => guarded(async () => {
|
|
92014
|
+
const current = runtime.current();
|
|
92015
|
+
if (action === "status") {
|
|
92016
|
+
const lines = current ? [
|
|
92017
|
+
`Active network: ${current.network} (chainId ${current.chainId})`,
|
|
92018
|
+
`Money reality: ${current.practiceWorld ? "PRACTICE \u2014 no real money" : "REAL MONEY"}`
|
|
92019
|
+
] : ["Active network: NONE \u2014 the boundary failed to boot (see any tool's error for the config cause)."];
|
|
92020
|
+
lines.push(
|
|
92021
|
+
`Switchable networks: ${SWITCHABLE_NETWORKS.join(", ")} (action 'switch', confirmed:true after human approval).`,
|
|
92022
|
+
"A switch changes worlds entirely: positions, vaults, and signer bindings are per-network.",
|
|
92023
|
+
"Mainnet writes are operator-gated regardless of switching \u2014 reads work, fund-moving tools refuse.",
|
|
92024
|
+
"Session-scoped: the configured default network returns when the server restarts."
|
|
92025
|
+
);
|
|
92026
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
92027
|
+
}
|
|
92028
|
+
const target = (network ?? "").toLowerCase();
|
|
92029
|
+
if (!SWITCHABLE_NETWORKS.includes(target)) {
|
|
92030
|
+
return validationFailed(`network must be one of: ${SWITCHABLE_NETWORKS.join(", ")} (got '${network ?? ""}').`);
|
|
92031
|
+
}
|
|
92032
|
+
if (current && current.network === target) {
|
|
92033
|
+
return validationFailed(`already on ${target} \u2014 nothing to switch.`);
|
|
92034
|
+
}
|
|
92035
|
+
const pending = getSigner()?.bridge.pendingCount() ?? 0;
|
|
92036
|
+
if (pending > 0) {
|
|
92037
|
+
return renderError(
|
|
92038
|
+
boundaryError(
|
|
92039
|
+
"UPSTREAM_REJECTED",
|
|
92040
|
+
`network switch refused: ${pending} signing ceremony(ies) still pending. Finish or decline them in the wallet/approval page (or let them expire), then switch.`
|
|
92041
|
+
)
|
|
92042
|
+
);
|
|
92043
|
+
}
|
|
92044
|
+
if (confirmed !== true) {
|
|
92045
|
+
const from = current ? moneyLine(current.network) : "no live network (boot error)";
|
|
92046
|
+
return {
|
|
92047
|
+
content: [
|
|
92048
|
+
{
|
|
92049
|
+
type: "text",
|
|
92050
|
+
text: `CONFIRMATION REQUIRED \u2014 network switch.
|
|
92051
|
+
FROM: ${from}
|
|
92052
|
+
TO: ${moneyLine(target)}
|
|
92053
|
+
- Positions, vaults, and signer bindings are PER-NETWORK: nothing carries across.
|
|
92054
|
+
- Mainnet fund-moving operations remain operator-gated after the switch \u2014 reads work, writes refuse.
|
|
92055
|
+
- Session-scoped: the configured default network returns on server restart.
|
|
92056
|
+
Re-invoke with confirmed: true ONLY after a human has approved this exact switch. Do not set it on your own.`
|
|
92057
|
+
}
|
|
92058
|
+
],
|
|
92059
|
+
isError: true
|
|
92060
|
+
};
|
|
92061
|
+
}
|
|
92062
|
+
const result = await runtime.switchTo(target);
|
|
92063
|
+
if (!result.ok) return renderError(result.error);
|
|
92064
|
+
const b = getB();
|
|
92065
|
+
const world = b.ok ? b.boundary.world() : null;
|
|
92066
|
+
return {
|
|
92067
|
+
content: [
|
|
92068
|
+
{
|
|
92069
|
+
type: "text",
|
|
92070
|
+
text: `SWITCHED. Active network is now: ${world ? moneyLine(world.network) : target}.
|
|
92071
|
+
` + (world ? `chainId: ${world.chainId}
|
|
92072
|
+
` : "") + `Signer bindings for ${target} (if any) were loaded from this network's own state; re-authorize via signer_setup if needed.
|
|
92073
|
+
Session-scoped: the configured default returns on restart.
|
|
92074
|
+
NOW: re-read boundary://info and STATE the new environment and money reality to the user before any action.`
|
|
92075
|
+
}
|
|
92076
|
+
]
|
|
92077
|
+
};
|
|
92078
|
+
})
|
|
92079
|
+
);
|
|
92080
|
+
}
|
|
92081
|
+
|
|
91872
92082
|
// src/resources/position.ts
|
|
91873
92083
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
91874
92084
|
function registerPositionResource(server, getB) {
|
|
@@ -91965,8 +92175,8 @@ function registerBoundaryInfoResource(server, getB) {
|
|
|
91965
92175
|
}
|
|
91966
92176
|
|
|
91967
92177
|
// src/server.ts
|
|
91968
|
-
var SERVER_VERSION = "0.
|
|
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.";
|
|
92178
|
+
var SERVER_VERSION = "0.3.0";
|
|
92179
|
+
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
92180
|
function createServer2(deps) {
|
|
91971
92181
|
const server = new import_mcp2.McpServer(
|
|
91972
92182
|
{
|
|
@@ -91990,8 +92200,11 @@ function createServer2(deps) {
|
|
|
91990
92200
|
if (deps.mockControl) {
|
|
91991
92201
|
registerMockControlTool(server, deps.mockControl, deps.chainId);
|
|
91992
92202
|
}
|
|
91993
|
-
if (deps.signer) {
|
|
91994
|
-
registerSignerTool(server, deps.signer);
|
|
92203
|
+
if (deps.signer || deps.networkSwitch) {
|
|
92204
|
+
registerSignerTool(server, () => deps.signer);
|
|
92205
|
+
}
|
|
92206
|
+
if (deps.networkSwitch) {
|
|
92207
|
+
registerNetworkSwitchTool(server, getB, deps.networkSwitch, () => deps.signer);
|
|
91995
92208
|
}
|
|
91996
92209
|
return server;
|
|
91997
92210
|
}
|
|
@@ -92004,20 +92217,22 @@ if (process.argv.includes("--version")) {
|
|
|
92004
92217
|
}
|
|
92005
92218
|
async function main() {
|
|
92006
92219
|
const configResult = resolveBoundaryConfig(process.env);
|
|
92007
|
-
|
|
92220
|
+
let boot = await buildBoundary(configResult);
|
|
92008
92221
|
if (!boot.boundaryResult.ok) {
|
|
92009
92222
|
process.stderr.write(`[dh-mcp] boundary not available: ${boot.boundaryResult.error.message}
|
|
92010
92223
|
`);
|
|
92011
92224
|
}
|
|
92012
|
-
const
|
|
92013
|
-
|
|
92014
|
-
|
|
92015
|
-
|
|
92016
|
-
|
|
92225
|
+
const world = assembleWorld({
|
|
92226
|
+
env: process.env,
|
|
92227
|
+
configResult,
|
|
92228
|
+
boot,
|
|
92229
|
+
log: (line) => process.stderr.write(`[dh-mcp] ${line}
|
|
92230
|
+
`)
|
|
92017
92231
|
});
|
|
92232
|
+
const server = createServer2(world.deps);
|
|
92018
92233
|
const transport = new import_stdio.StdioServerTransport();
|
|
92019
92234
|
const cleanup = () => {
|
|
92020
|
-
|
|
92235
|
+
world.dispose();
|
|
92021
92236
|
process.exit(0);
|
|
92022
92237
|
};
|
|
92023
92238
|
process.on("SIGINT", cleanup);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gvnrdao/dh-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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": {
|