@gvnrdao/dh-mcp 0.2.0 → 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 CHANGED
@@ -6,19 +6,36 @@ lending on a user's behalf, with a human approving every fund-moving step.
6
6
 
7
7
  ## Install
8
8
 
9
- Claude Code:
9
+ Pick the row that matches your machine — the first two paths carry their own runtime,
10
+ so there is **nothing to install first** (no Node, no npm):
10
11
 
11
- ```bash
12
- claude mcp add diamond-hands -- npx -y @gvnrdao/dh-mcp
13
- ```
14
-
15
- Claude Desktop / Cursor / any MCP host (JSON config):
16
-
17
- ```json
18
- { "mcpServers": { "diamond-hands": { "command": "npx", "args": ["-y", "@gvnrdao/dh-mcp"] } } }
19
- ```
20
-
21
- That is the whole install. **Zero configuration boots the real protocol on SEPOLIA**
12
+ | You are on | Install path |
13
+ |---|---|
14
+ | **Claude Desktop (macOS / Windows)** | Download the bundle and open it (double-click / drag into Settings → Extensions): `https://assets.gvnr.xyz/dh-mcp/v0.3.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
+ | **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
+
18
+ Downloads landing page (which file is for which system, checksums, security notes):
19
+ **https://assets.gvnr.xyz/dh-mcp/** — all artifacts and `SHA256SUMS` live under it
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).
24
+
25
+ Unsigned-binary honesty: the macOS and Windows binaries are **not yet code-signed** —
26
+ macOS Gatekeeper may quarantine the download (right-click → Open, or
27
+ `xattr -d com.apple.quarantine <file>`) and Windows SmartScreen will warn. Verify the
28
+ `SHA256SUMS` file from the same release if in doubt. On macOS/Windows the `.mcpb` path
29
+ avoids this entirely.
30
+
31
+ **Troubleshooting `spawn npx ENOENT`:** your MCP host searched the system PATH and found
32
+ no `npx` — the machine has no Node.js (or the host, e.g. an Electron app, cannot see
33
+ your shell's version manager). That is the npx path's stated precondition, not a bug in
34
+ the server. Remedies: use the one-line installer above (the printed snippet uses an
35
+ absolute path to a binary that carries its own runtime), or on macOS/Windows Claude
36
+ Desktop install the `.mcpb`.
37
+
38
+ **Zero configuration boots the real protocol on SEPOLIA**
22
39
  (the test network — real contracts, test funds) with public endpoints. Everything is
23
40
  overridable by environment variables:
24
41
 
@@ -82,6 +99,14 @@ misrepresent upstream state, always answer with legible, typed results.
82
99
  | `loan_extend` | Renew the position term (pro-rata fee) |
83
100
  | `loan_withdraw` | Withdraw BTC from the vault (unrecoverable — strictest gate) |
84
101
  | `loan_recover_stale_spend` | Clear a stale BTC withdrawal reservation (permissionless) |
102
+ | `loan_allowlist_destination` | Register a BTC withdrawal destination in the registry (delay-gated on live networks) |
103
+ | `psm_swap` | Swap USDC ↔ UCD through the PSM (quotes via the `psm_quote` read; mainnet PSM writes always refuse) |
104
+ | `loan_delegation_setup` / `loan_delegation_grant` | Safe delegation plane — practice (mock) only today; real refuses with that true reason |
105
+
106
+ **Authorization by conversation:** `signer_setup` — the user picks external wallet
107
+ (MetaMask popup / WalletConnect QR), local encrypted keystore, or the Safe modes by
108
+ TALKING; secrets never travel through chat. `guide` serves the walkthroughs
109
+ (`first-setup`, `connect-wallet`, `safe`, `delegation`, `troubleshooting`, …).
85
110
 
86
111
  **Observability** (read tools + resources, no signer needed): position status, listings,
87
112
  event history, pending withdrawals (`position_*`, `position://{id}`), protocol health and
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() };
@@ -61761,7 +61769,7 @@ var init_deployment_addresses = __esm2({
61761
61769
  LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9",
61762
61770
  CircuitBreakerModule: "0xF7b545d3a4Ee056D06909AB367E2F7bFFE3cB1BC",
61763
61771
  AdminModule: "0x0023B71B586795eE5fa4E83E384345C1EC8Bb946",
61764
- PositionManagerViews: "0x9225647a30bbACA4Acc0491B786869036914242e",
61772
+ PositionManagerViews: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
61765
61773
  PositionManager: "0x12A1836e56139ccaD8722B89519d84233efc224B",
61766
61774
  OperationAuthorizationRegistry: "0xD4505645b724754f5170a2027804a4265e860d44",
61767
61775
  ContractVersionRegistry: "0x5e18f77d01940dA5B1D986D373D9A6ad0767008d",
@@ -61839,13 +61847,13 @@ var init_deployment_addresses = __esm2({
61839
61847
  block: 25472957
61840
61848
  },
61841
61849
  PositionManager: {
61842
- previousImplementation: "0x9f52BaBB40FbFC5863e45B1A4014cB433950c684",
61843
- newImplementation: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
61844
- upgradedAt: "2026-07-06T08:42:47.000Z",
61845
- upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0x2002827d34A781883Ec4c83c36ECC140c3911F2B in tx 0xa1fbe31cb71736514a868e681573dff22c9fab91d69cec157a24a30e29eadbe6 (block 25472368)",
61846
- reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
61847
- executeTx: "0xa1fbe31cb71736514a868e681573dff22c9fab91d69cec157a24a30e29eadbe6",
61848
- block: 25472368
61850
+ previousImplementation: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
61851
+ newImplementation: "0x2e7170d6Fb15A876dB726732e72e63109bcB916d",
61852
+ upgradedAt: "2026-08-03T08:34:23.000Z",
61853
+ upgradedBy: "AdminModule generic-op 0x69b79a906ed2 (3-of-3 signatures, 24h timelock; proposed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f, executed in the release batch onchain-auth/.safe-batches/mainnet-release-execute-B.json, submitted by EOA 0x2002827d34A781883Ec4c83c36ECC140c3911F2B, tx 0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6, block 25673200)",
61854
+ reason: "2026-08 agent-stack release, Execute B: agent-delegation digest rebind. makePayment/mintUCD/extendPosition now bind their EIP-712 digest to the STORED borrower rather than msg.sender, so a scoped AgentDelegationRegistry grant can submit; withdrawBTC still binds msg.sender and stays non-delegable. Also adds setViews(address), which the same batch used to repoint PM at the replacement PositionManagerViews. NOTE: VERSION reads 1.5.4 on BOTH sides of this upgrade \u2014 verify by implementation ADDRESS, never by VERSION(). NOTE: not the July audit rollout batch \u2014 reconcile-deployment-record.ts --write templates every row with that text; this hand-authored provenance is the accurate one, restore it if --write flattens it again.",
61855
+ executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
61856
+ block: 25673200
61849
61857
  },
61850
61858
  LoanOperationsManagerModule: {
61851
61859
  previousImplementation: "0x56671D671e492Dae625413d463D47605Cf54edf6",
@@ -61889,6 +61897,16 @@ var init_deployment_addresses = __esm2({
61889
61897
  reason: "2026-08 agent-stack release: PositionDelegateRegistry VERSION 1.1.0 -> 2.0.0 via upgradeToAndCall + initializeV2(AdminModule, registrar 0x5D54E0BE\u2026, pauser 0xC205Ae99\u2026) \u2014 kill-switch, deny-only registrar, permanent delegate burn. NOTE: not the July audit rollout batch \u2014 reconcile-deployment-record.ts --write templates every row with that text; this hand-authored provenance is the accurate one, restore it if --write flattens it again.",
61890
61898
  executeTx: "0xf0f237f6c4e958c37de556571908283c59c3fba6ebf9fa3cefb956f37e315a10",
61891
61899
  block: 25669024
61900
+ },
61901
+ PositionManagerViews: {
61902
+ previousImplementation: "0x9225647a30bbACA4Acc0491B786869036914242e",
61903
+ newImplementation: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
61904
+ proxy: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
61905
+ upgradedAt: "2026-08-03T08:34:23.000Z",
61906
+ upgradedBy: "REPLACED, not upgraded. Fresh ERC1967Proxy (atomically initialized) + AdminModule generic-op 0x848a97186f0d PositionManager.setViews(proxy) \u2014 3-of-3, 24h timelock, executed in onchain-auth/.safe-batches/mainnet-release-execute-B.json",
61907
+ reason: "2026-08 agent-stack release. The mainnet PositionManagerViews at 0x9225647a was deployed as a BARE implementation (EIP-1967 slot 0x00), so upgradeToAndCall reverts UUPSUnauthorizedCallContext \u2014 it could never be upgraded. PositionManager.setViews (added in the same Execute B batch) removed the repoint blocker, so Views was replaced behind a new proxy rather than upgraded. This makes the Pashov F3 renewal debt-ceiling check REACHABLE for the first time: ExceedsMaxLoan (0x499e7985) is present in 0xE68DC096 and absent from 0x9225647a. Views holds no protocol state (8 wiring slots + roles + pause), which is what made replacement safe. The old contract is ABANDONED, not decommissioned \u2014 it stays live and callable as the rollback target for setViews. NOTE: VERSION reads 1.1.1 on both sides; verify by address.",
61908
+ executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
61909
+ block: 25673200
61892
61910
  }
61893
61911
  },
61894
61912
  latestEnv: {
@@ -61922,10 +61940,10 @@ var init_deployment_addresses = __esm2({
61922
61940
  ADMIN_MODULE_IMPL: "0xb4C5C7E051A1e672F014B25CB5D55B225Aa0D512",
61923
61941
  BTC_SPEND_AUTHORIZER: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
61924
61942
  BTC_SPEND_AUTHORIZER_IMPL: "0x40c9e8C46C65E0A57BB63da5368868A9E8Df81A5",
61925
- POSITION_MANAGER_VIEWS: "0x9225647a30bbACA4Acc0491B786869036914242e",
61926
- POSITION_MANAGER_VIEWS_IMPL: "0x9225647a30bbACA4Acc0491B786869036914242e",
61943
+ POSITION_MANAGER_VIEWS: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
61944
+ POSITION_MANAGER_VIEWS_IMPL: "0xE68DC096A65Ecddbc6A9b5c6e5f878e2CE143Bfe",
61927
61945
  POSITION_MANAGER: "0x12A1836e56139ccaD8722B89519d84233efc224B",
61928
- POSITION_MANAGER_IMPL: "0x600Dc0D1C2c0F94882B6Bc09172f8650047Ad5B1",
61946
+ POSITION_MANAGER_IMPL: "0x2e7170d6Fb15A876dB726732e72e63109bcB916d",
61929
61947
  LOAN_OPERATIONS_MANAGER_MODULE: "0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",
61930
61948
  LOAN_OPERATIONS_MANAGER_MODULE_IMPL: "0x7d90aAB4466f59BA9aC9C7a9BF14dC53734336e7",
61931
61949
  UPGRADE_VALIDATOR: "0xC46Ae71F22e3741A6CF46E399aE914C4868fEbed",
@@ -61951,7 +61969,7 @@ var init_deployment_addresses = __esm2({
61951
61969
  LiquidationManagerModule: "0x74B28695352E7bf736D6c9F76ccb7B4439477De9",
61952
61970
  CircuitBreakerModule: "0xF7b545d3a4Ee056D06909AB367E2F7bFFE3cB1BC",
61953
61971
  AdminModule: "0x0023B71B586795eE5fa4E83E384345C1EC8Bb946",
61954
- PositionManagerViews: "0x9225647a30bbACA4Acc0491B786869036914242e",
61972
+ PositionManagerViews: "0x8B57954eA338c6A6bfF1457f71080e25baFF3937",
61955
61973
  PositionManager: "0x12A1836e56139ccaD8722B89519d84233efc224B",
61956
61974
  OperationAuthorizationRegistry: "0xD4505645b724754f5170a2027804a4265e860d44",
61957
61975
  ContractVersionRegistry: "0x5e18f77d01940dA5B1D986D373D9A6ad0767008d",
@@ -67775,6 +67793,7 @@ function sessionStoreKey(address, chainId, endpoint) {
67775
67793
  return STORE_PREFIX + `${address.trim().toLowerCase()}:${chainId}:${endpoint.replace(/\/+$/, "")}`;
67776
67794
  }
67777
67795
  var PENDING_ENVELOPE_TTL_SECONDS = 8 * 60;
67796
+ var EOA_PENDING_ENVELOPE_TTL_SECONDS = 60;
67778
67797
  function pendingEnvelopeKey(sessionKey) {
67779
67798
  return sessionKey + ":pending";
67780
67799
  }
@@ -67822,7 +67841,7 @@ var LocalStorageSessionStore = class {
67822
67841
  } catch {
67823
67842
  }
67824
67843
  }
67825
- loadPending(key) {
67844
+ loadPending(key, maxAgeSeconds = PENDING_ENVELOPE_TTL_SECONDS) {
67826
67845
  let raw;
67827
67846
  try {
67828
67847
  raw = window.localStorage.getItem(pendingEnvelopeKey(key));
@@ -67839,7 +67858,7 @@ var LocalStorageSessionStore = class {
67839
67858
  return null;
67840
67859
  }
67841
67860
  const nowSec = Math.floor(Date.now() / 1e3);
67842
- if (!isPendingEnvelopeShape(parsed) || nowSec >= parsed.issuedAt + PENDING_ENVELOPE_TTL_SECONDS) {
67861
+ if (!isPendingEnvelopeShape(parsed) || nowSec >= parsed.issuedAt + maxAgeSeconds) {
67843
67862
  this.clearPending(key);
67844
67863
  return null;
67845
67864
  }
@@ -67873,12 +67892,12 @@ var MemorySessionStore = class {
67873
67892
  clear(key) {
67874
67893
  this.entries.delete(key);
67875
67894
  }
67876
- loadPending(key) {
67895
+ loadPending(key, maxAgeSeconds = PENDING_ENVELOPE_TTL_SECONDS) {
67877
67896
  const envelope = this.pending.get(key);
67878
67897
  if (!envelope)
67879
67898
  return null;
67880
67899
  const nowSec = Math.floor(Date.now() / 1e3);
67881
- if (nowSec >= envelope.issuedAt + PENDING_ENVELOPE_TTL_SECONDS) {
67900
+ if (nowSec >= envelope.issuedAt + maxAgeSeconds) {
67882
67901
  this.pending.delete(key);
67883
67902
  return null;
67884
67903
  }
@@ -67910,15 +67929,23 @@ var REFRESH_LEEWAY_SECONDS = 30;
67910
67929
  var LOGIN_RETRY_BASE_MS = 3e4;
67911
67930
  var LOGIN_RETRY_MAX_MS = 5 * 6e4;
67912
67931
  var ServerLoginError = class extends Error {
67913
- constructor(message, status) {
67932
+ constructor(message, status, reason) {
67914
67933
  super(message);
67915
67934
  this.status = status;
67935
+ this.reason = reason;
67916
67936
  this.name = "ServerLoginError";
67917
67937
  }
67918
67938
  };
67919
67939
  function isLoginRejection(error) {
67920
67940
  return error instanceof ServerLoginError && error.status >= 400 && error.status < 500 && error.status !== 429;
67921
67941
  }
67942
+ var SPENT_ENVELOPE_REASONS = /* @__PURE__ */ new Set(["replayed_nonce", "expired_issuedAt"]);
67943
+ function isSpentEnvelope(error) {
67944
+ if (!isLoginRejection(error))
67945
+ return false;
67946
+ const { reason, status } = error;
67947
+ return reason ? SPENT_ENVELOPE_REASONS.has(reason) : status === 409;
67948
+ }
67922
67949
  var ServerSession = class {
67923
67950
  signer;
67924
67951
  serviceEndpoint;
@@ -67949,6 +67976,12 @@ var ServerSession = class {
67949
67976
  * `clear()` can drop the persisted token without an async address lookup.
67950
67977
  */
67951
67978
  lastStoreKey = null;
67979
+ /**
67980
+ * Whether the signer is a smart-contract wallet, memoized after the first
67981
+ * `eth_getCode`. Decides which of the server's two first-use windows bounds
67982
+ * envelope reuse; a signer cannot change kind for the life of the session.
67983
+ */
67984
+ contractSigner = null;
67952
67985
  constructor(opts) {
67953
67986
  assertSafeServiceEndpoint(opts.serviceEndpoint);
67954
67987
  this.signer = opts.signer;
@@ -68147,6 +68180,34 @@ var ServerSession = class {
68147
68180
  return null;
68148
68181
  }
68149
68182
  }
68183
+ /**
68184
+ * How long a pending envelope for THIS signer may be reused, in seconds.
68185
+ *
68186
+ * The server grants an EOA 120s to make an envelope's first use and a contract
68187
+ * wallet 600s, so one local TTL is necessarily wrong for one of them. Deployed
68188
+ * code has bytecode; an EOA does not — one `eth_getCode`, memoized, settles it.
68189
+ *
68190
+ * Reports the CONTRACT window when it cannot tell, which is the behavior that
68191
+ * shipped before the split. The asymmetry is intended: guessing "EOA" for a
68192
+ * Safe hands it a new message and orphans the owner signatures already
68193
+ * collected, while guessing "contract" for an EOA now costs one rejected
68194
+ * attempt, because a rejection clears the envelope.
68195
+ */
68196
+ async pendingEnvelopeTtl() {
68197
+ if (this.contractSigner === null) {
68198
+ try {
68199
+ const provider = this.signer.provider;
68200
+ if (!provider)
68201
+ return PENDING_ENVELOPE_TTL_SECONDS;
68202
+ const address = await this.signer.getAddress();
68203
+ const code = await provider.getCode(address);
68204
+ this.contractSigner = typeof code === "string" && code !== "0x";
68205
+ } catch {
68206
+ return PENDING_ENVELOPE_TTL_SECONDS;
68207
+ }
68208
+ }
68209
+ return this.contractSigner ? PENDING_ENVELOPE_TTL_SECONDS : EOA_PENDING_ENVELOPE_TTL_SECONDS;
68210
+ }
68150
68211
  async getOrRefresh() {
68151
68212
  const nowSec = this.now();
68152
68213
  if (this.cached && this.cached.expiresAt - REFRESH_LEEWAY_SECONDS > nowSec) {
@@ -68168,10 +68229,10 @@ var ServerSession = class {
68168
68229
  }
68169
68230
  this.onSignaturePrompt?.();
68170
68231
  let session;
68232
+ const store = this.store;
68233
+ const storeKey = store ? this.lastStoreKey : null;
68171
68234
  try {
68172
- const store = this.store;
68173
- const storeKey = store ? this.lastStoreKey : null;
68174
- const reuse = storeKey ? store.loadPending?.(storeKey) ?? void 0 : void 0;
68235
+ const reuse = storeKey ? store.loadPending?.(storeKey, await this.pendingEnvelopeTtl()) ?? void 0 : void 0;
68175
68236
  const payload = await buildSignedLoginPayload(
68176
68237
  this.signer,
68177
68238
  this.chainId,
@@ -68194,6 +68255,9 @@ var ServerSession = class {
68194
68255
  this.onSignatureResolved?.(true);
68195
68256
  } catch (error) {
68196
68257
  this.onSignatureResolved?.(false);
68258
+ if (storeKey && isSpentEnvelope(error)) {
68259
+ store.clearPending?.(storeKey);
68260
+ }
68197
68261
  const failures = (this.promptBackoff?.failures ?? 0) + 1;
68198
68262
  this.promptBackoff = {
68199
68263
  failures,
@@ -68222,9 +68286,17 @@ var ServerSession = class {
68222
68286
  });
68223
68287
  if (!res.ok) {
68224
68288
  const detail = await res.text().catch(() => "");
68289
+ let reason;
68290
+ try {
68291
+ const parsed = JSON.parse(detail);
68292
+ if (typeof parsed?.reason === "string")
68293
+ reason = parsed.reason;
68294
+ } catch {
68295
+ }
68225
68296
  throw new ServerLoginError(
68226
68297
  `lit-ops-server login failed: HTTP ${res.status} ${detail.slice(0, 200)}`,
68227
- res.status
68298
+ res.status,
68299
+ reason
68228
68300
  );
68229
68301
  }
68230
68302
  const body = await res.json();
@@ -73798,7 +73870,7 @@ var DiamondHandsGraph = class {
73798
73870
  async getPSMConfiguration() {
73799
73871
  const query = `
73800
73872
  query GetPSMConfiguration {
73801
- psmConfiguration(id: "psm") {
73873
+ psmConfiguration: psmconfiguration(id: "psm") {
73802
73874
  id
73803
73875
  version
73804
73876
  redeemEnabled
@@ -73920,7 +73992,7 @@ var DiamondHandsGraph = class {
73920
73992
  const whereClause = whereConditions.length > 0 ? `where: { ${whereConditions.join(", ")} }` : "";
73921
73993
  const query = `
73922
73994
  query GetPSMTransactions($first: Int!, $skip: Int!) {
73923
- psmTransactions(${whereClause}, first: $first, skip: $skip, orderBy: timestamp, orderDirection: desc) {
73995
+ psmTransactions: psmtransactions(${whereClause}, first: $first, skip: $skip, orderBy: timestamp, orderDirection: desc) {
73924
73996
  id
73925
73997
  type
73926
73998
  user
@@ -73955,7 +74027,7 @@ var DiamondHandsGraph = class {
73955
74027
  const whereClause = whereConditions.length > 0 ? `where: { ${whereConditions.join(", ")} }` : "";
73956
74028
  const query = `
73957
74029
  query GetPSMDailyMetrics($first: Int!) {
73958
- psmDailyMetrics(${whereClause}, first: $first, orderBy: date, orderDirection: desc) {
74030
+ psmDailyMetrics: psmdailyMetrics(${whereClause}, first: $first, orderBy: date, orderDirection: desc) {
73959
74031
  id
73960
74032
  date
73961
74033
  totalSwapVolume
@@ -74679,7 +74751,7 @@ var DiamondHandsGraph = class {
74679
74751
  }` : ""}
74680
74752
 
74681
74753
  ${includeKind("psm") ? `
74682
- psmTransactions(
74754
+ psmTransactions: psmtransactions(
74683
74755
  ${buildTimeWhereClause()}
74684
74756
  first: $limit, orderBy: timestamp, orderDirection: $orderDirection
74685
74757
  ) {
@@ -85700,23 +85772,28 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
85700
85772
  * @throws if timeout is reached before subgraph catches up
85701
85773
  */
85702
85774
  // ============================================================================
85703
- // HIGH-LEVEL API - Agent Delegation (auto-renew) — SEPOLIA ONLY
85775
+ // HIGH-LEVEL API - Agent Delegation (auto-renew)
85704
85776
  // ============================================================================
85705
- /** Guard: the AgentDelegationRegistry MVP is deployed on Sepolia only. */
85706
- async assertAgentDelegationSepolia() {
85707
- const chainId = Number((await this.getProviderOrThrow().getNetwork()).chainId);
85708
- if (chainId !== 11155111) {
85709
- throw new SDKError({
85710
- message: `Agent auto-renew delegation is Sepolia-only (chainId 11155111); got ${chainId}`,
85711
- category: "NETWORK",
85712
- severity: "HIGH"
85713
- /* HIGH */
85714
- });
85715
- }
85777
+ /**
85778
+ * Guard: resolve the AgentDelegationRegistry for the configured network.
85779
+ *
85780
+ * Deployment presence IS the availability test — there is deliberately no chainId
85781
+ * allow-list here. The registry is deployed per network (Sepolia 2026-07, mainnet
85782
+ * 2026-08 agent-stack release) and `getNetworkConfig` populates the address from the
85783
+ * generated deployment table, so a chain without a deployment resolves to `""` and
85784
+ * fails closed below. Adding a chain therefore needs no SDK code change — which is
85785
+ * exactly how the previous hardcoded `chainId !== 11155111` gate went stale and kept
85786
+ * the mainnet toggle dark after the registry shipped.
85787
+ *
85788
+ * Callers that need the availability answer WITHOUT throwing (e.g. to decide whether to
85789
+ * render a toggle at all) should ask the deployment table directly rather than calling this
85790
+ * and catching — `ALL_DEPLOYMENTS` is published on the `@gvnrdao/dh-sdk/deployments` subpath.
85791
+ */
85792
+ agentDelegationRegistryOrThrow() {
85716
85793
  const addr = this.config.contractAddresses?.agentDelegationRegistry;
85717
85794
  if (!addr) {
85718
85795
  throw new SDKError({
85719
- message: "AgentDelegationRegistry address not configured \u2014 provide contractAddresses.agentDelegationRegistry",
85796
+ message: "AgentDelegationRegistry is not available on this network \u2014 no deployment address is configured (contractAddresses.agentDelegationRegistry)",
85720
85797
  category: "CONFIGURATION",
85721
85798
  severity: "HIGH"
85722
85799
  /* HIGH */
@@ -85729,7 +85806,7 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
85729
85806
  * Pure view — no signer required.
85730
85807
  */
85731
85808
  async getAutoRenewStatus(positionId, user) {
85732
- const addr = await this.assertAgentDelegationSepolia();
85809
+ const addr = this.agentDelegationRegistryOrThrow();
85733
85810
  const registry = AgentDelegationRegistry__factory.connect(addr, this.getProviderOrThrow());
85734
85811
  const pid = this.toBytes32(positionId);
85735
85812
  const grant = await registry.getLoanGrant(pid);
@@ -85749,7 +85826,7 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
85749
85826
  * registers it, then records the position's renew grant. Borrower-signed.
85750
85827
  */
85751
85828
  async enableAutoRenew(positionId, options) {
85752
- const addr = await this.assertAgentDelegationSepolia();
85829
+ const addr = this.agentDelegationRegistryOrThrow();
85753
85830
  const pdrAddr = this.config.contractAddresses?.positionDelegateRegistry;
85754
85831
  if (!pdrAddr) {
85755
85832
  throw new SDKError({
@@ -85790,7 +85867,7 @@ Message: ${causeMessage}${quantumContext}${mintDebtDiagnostics}`
85790
85867
  }
85791
85868
  /** Disable auto-renew delegation for a position (clears the grant). Borrower-signed. */
85792
85869
  async disableAutoRenew(positionId) {
85793
- const addr = await this.assertAgentDelegationSepolia();
85870
+ const addr = this.agentDelegationRegistryOrThrow();
85794
85871
  const signer = this.getSignerOrThrow();
85795
85872
  const user = await signer.getAddress();
85796
85873
  const registry = AgentDelegationRegistry__factory.connect(addr, signer);
@@ -90171,7 +90248,8 @@ function createBoundary(config, opts) {
90171
90248
  capabilities: () => ({
90172
90249
  reads: { public: true, authenticated: "available" },
90173
90250
  writes: { enabled: true, signerModes: ["external"], activeMode: "external" },
90174
- signerSetupTool: false
90251
+ signerSetupTool: false,
90252
+ networkSwitch: false
90175
90253
  }),
90176
90254
  configFingerprint
90177
90255
  });
@@ -90251,6 +90329,7 @@ function createBoundary(config, opts) {
90251
90329
  ...config.borrower ? { borrowerAddress: config.borrower } : {},
90252
90330
  signer: manager,
90253
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.
90254
90333
  capabilities: () => ({
90255
90334
  reads: { public: true, authenticated: "available" },
90256
90335
  writes: {
@@ -90258,7 +90337,8 @@ function createBoundary(config, opts) {
90258
90337
  signerModes: ["external", "keystore", "mock-simulated", "safe", "safe-module"],
90259
90338
  activeMode: manager.mode()
90260
90339
  },
90261
- signerSetupTool: true
90340
+ signerSetupTool: true,
90341
+ networkSwitch: false
90262
90342
  }),
90263
90343
  configFingerprint
90264
90344
  });
@@ -90319,7 +90399,9 @@ async function createRealBoundary(config, wallet) {
90319
90399
  signerModes: [],
90320
90400
  activeMode: manager.mode()
90321
90401
  },
90322
- signerSetupTool: true
90402
+ signerSetupTool: true,
90403
+ // Plan 13: the real adapter switches networks by conversation (network_switch tool).
90404
+ networkSwitch: true
90323
90405
  });
90324
90406
  const boundary = new BoundaryCore({
90325
90407
  plugin,