@dimcool/mcp 0.1.22 → 0.1.24

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.
Files changed (2) hide show
  1. package/dist/index.js +63 -7
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -32899,6 +32899,17 @@ var Admin = class {
32899
32899
  `/admin/escrow/sweeps?limit=${limit}`
32900
32900
  );
32901
32901
  }
32902
+ /**
32903
+ * Get QR code as a data URL for a wallet address.
32904
+ * Used in the admin dashboard for sweep/feeps/escrow wallets to scan and add funds.
32905
+ */
32906
+ async getWalletQrDataUrl(address) {
32907
+ const params = new URLSearchParams({ address });
32908
+ const res = await this.http.get(
32909
+ `/admin/wallets/qr?${params.toString()}`
32910
+ );
32911
+ return res.qrDataUrl;
32912
+ }
32902
32913
  async executeEscrowSweep(amountUsdcMinor, idempotencyKey) {
32903
32914
  return this.http.post("/admin/escrow/sweep", {
32904
32915
  amountUsdcMinor,
@@ -33771,6 +33782,14 @@ var Wallet = class {
33771
33782
  this.logger.debug("Signing transaction");
33772
33783
  return this.signer.signTransaction(transaction);
33773
33784
  }
33785
+ /**
33786
+ * Get QR code as a data URL for the current user's wallet address.
33787
+ * Use as <img src={url} /> in the deposit / add-funds section.
33788
+ */
33789
+ async getMyWalletQrDataUrl() {
33790
+ const res = await this.http.get("/wallets/me/qr");
33791
+ return res.qrDataUrl;
33792
+ }
33774
33793
  /**
33775
33794
  * Get SOL and USDC balances
33776
33795
  */
@@ -37018,12 +37037,7 @@ async function gameLoop(client, args) {
37018
37037
  );
37019
37038
  }
37020
37039
  state = store.store.getState().statesByGameId[gameId];
37021
- return buildGameLoopReturn(
37022
- client,
37023
- gameId,
37024
- state ?? {},
37025
- "timeout"
37026
- );
37040
+ return buildGameLoopReturn(client, gameId, state ?? {}, "timeout");
37027
37041
  } catch (error) {
37028
37042
  return {
37029
37043
  error: `Game loop error: ${error instanceof Error ? error.message : String(error)}`,
@@ -37601,6 +37615,8 @@ async function checkNotifications(client) {
37601
37615
  const unreadDms = dmThreads.filter(
37602
37616
  (t) => (t.unreadCount ?? 0) > 0
37603
37617
  );
37618
+ client.sdk.notifications.markAllAsRead().catch(() => {
37619
+ });
37604
37620
  return {
37605
37621
  data: {
37606
37622
  unreadNotificationCount: notifications.unreadCount,
@@ -38359,6 +38375,46 @@ var DIM_INSTRUCTIONS = TOOL_DEFINITIONS.map((t) => ({
38359
38375
  // first line only
38360
38376
  }));
38361
38377
 
38378
+ // ../dim-agent-core/src/execute-with-auth-retry.ts
38379
+ var UNAUTHORIZED_MESSAGE = "Still unauthorized after re-login; backend may be having issues \u2014 try again later.";
38380
+ function isUnauthorizedResult(result) {
38381
+ const msg = (result.error ?? "").toLowerCase();
38382
+ return msg.includes("unauthorized") || msg.includes("please login again");
38383
+ }
38384
+ function isUnauthorizedThrow(err) {
38385
+ const msg = err instanceof Error ? err.message : String(err);
38386
+ return msg.toLowerCase().includes("unauthorized") || msg.toLowerCase().includes("please login again");
38387
+ }
38388
+ async function executeWithAuthRetry(client, tool, params) {
38389
+ if (tool.name === "dim_login") {
38390
+ return tool.execute(client, params);
38391
+ }
38392
+ try {
38393
+ const result = await tool.execute(client, params);
38394
+ if (!result.error && !result.isError) return result;
38395
+ if (!isUnauthorizedResult(result)) return result;
38396
+ await client.authenticate();
38397
+ const retryResult = await tool.execute(client, params);
38398
+ if (retryResult.isError || retryResult.error) {
38399
+ if (isUnauthorizedResult(retryResult)) {
38400
+ return { error: UNAUTHORIZED_MESSAGE, isError: true };
38401
+ }
38402
+ }
38403
+ return retryResult;
38404
+ } catch (err) {
38405
+ if (!isUnauthorizedThrow(err)) throw err;
38406
+ try {
38407
+ await client.authenticate();
38408
+ return await tool.execute(client, params);
38409
+ } catch (retryErr) {
38410
+ if (isUnauthorizedThrow(retryErr)) {
38411
+ return { error: UNAUTHORIZED_MESSAGE, isError: true };
38412
+ }
38413
+ throw retryErr;
38414
+ }
38415
+ }
38416
+ }
38417
+
38362
38418
  // src/resources.ts
38363
38419
  function registerResources(server2, client) {
38364
38420
  server2.resource(
@@ -38577,7 +38633,7 @@ function createDimMcpServer(config) {
38577
38633
  tool.description,
38578
38634
  zodParams,
38579
38635
  async (args) => {
38580
- const result = await tool.execute(client, args);
38636
+ const result = await executeWithAuthRetry(client, tool, args);
38581
38637
  if (result.isError || result.error) {
38582
38638
  return {
38583
38639
  content: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimcool/mcp",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "MCP server for DIM — lets AI agents play games, chat, send USDC, and earn referral income on the DIM platform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,6 +38,7 @@
38
38
  "zod": "^3.24.2"
39
39
  },
40
40
  "devDependencies": {
41
+ "@dimcool/dim-agent-core": "0.0.1",
41
42
  "@types/jest": "^29.5.2",
42
43
  "@types/node": "^20.3.1",
43
44
  "jest": "^29.5.0",