@dimcool/dimclaw 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.
- package/dist/index.js +63 -7
- package/index.ts +2 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -54158,6 +54158,17 @@ var Admin = class {
|
|
|
54158
54158
|
`/admin/escrow/sweeps?limit=${limit}`
|
|
54159
54159
|
);
|
|
54160
54160
|
}
|
|
54161
|
+
/**
|
|
54162
|
+
* Get QR code as a data URL for a wallet address.
|
|
54163
|
+
* Used in the admin dashboard for sweep/feeps/escrow wallets to scan and add funds.
|
|
54164
|
+
*/
|
|
54165
|
+
async getWalletQrDataUrl(address) {
|
|
54166
|
+
const params = new URLSearchParams({ address });
|
|
54167
|
+
const res = await this.http.get(
|
|
54168
|
+
`/admin/wallets/qr?${params.toString()}`
|
|
54169
|
+
);
|
|
54170
|
+
return res.qrDataUrl;
|
|
54171
|
+
}
|
|
54161
54172
|
async executeEscrowSweep(amountUsdcMinor, idempotencyKey) {
|
|
54162
54173
|
return this.http.post("/admin/escrow/sweep", {
|
|
54163
54174
|
amountUsdcMinor,
|
|
@@ -55030,6 +55041,14 @@ var Wallet = class {
|
|
|
55030
55041
|
this.logger.debug("Signing transaction");
|
|
55031
55042
|
return this.signer.signTransaction(transaction);
|
|
55032
55043
|
}
|
|
55044
|
+
/**
|
|
55045
|
+
* Get QR code as a data URL for the current user's wallet address.
|
|
55046
|
+
* Use as <img src={url} /> in the deposit / add-funds section.
|
|
55047
|
+
*/
|
|
55048
|
+
async getMyWalletQrDataUrl() {
|
|
55049
|
+
const res = await this.http.get("/wallets/me/qr");
|
|
55050
|
+
return res.qrDataUrl;
|
|
55051
|
+
}
|
|
55033
55052
|
/**
|
|
55034
55053
|
* Get SOL and USDC balances
|
|
55035
55054
|
*/
|
|
@@ -58410,12 +58429,7 @@ async function gameLoop(client, args) {
|
|
|
58410
58429
|
);
|
|
58411
58430
|
}
|
|
58412
58431
|
state = store.store.getState().statesByGameId[gameId];
|
|
58413
|
-
return buildGameLoopReturn(
|
|
58414
|
-
client,
|
|
58415
|
-
gameId,
|
|
58416
|
-
state ?? {},
|
|
58417
|
-
"timeout"
|
|
58418
|
-
);
|
|
58432
|
+
return buildGameLoopReturn(client, gameId, state ?? {}, "timeout");
|
|
58419
58433
|
} catch (error) {
|
|
58420
58434
|
return {
|
|
58421
58435
|
error: `Game loop error: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -58993,6 +59007,8 @@ async function checkNotifications(client) {
|
|
|
58993
59007
|
const unreadDms = dmThreads.filter(
|
|
58994
59008
|
(t) => (t.unreadCount ?? 0) > 0
|
|
58995
59009
|
);
|
|
59010
|
+
client.sdk.notifications.markAllAsRead().catch(() => {
|
|
59011
|
+
});
|
|
58996
59012
|
return {
|
|
58997
59013
|
data: {
|
|
58998
59014
|
unreadNotificationCount: notifications.unreadCount,
|
|
@@ -59751,6 +59767,46 @@ var DIM_INSTRUCTIONS = TOOL_DEFINITIONS.map((t) => ({
|
|
|
59751
59767
|
// first line only
|
|
59752
59768
|
}));
|
|
59753
59769
|
|
|
59770
|
+
// ../dim-agent-core/src/execute-with-auth-retry.ts
|
|
59771
|
+
var UNAUTHORIZED_MESSAGE = "Still unauthorized after re-login; backend may be having issues \u2014 try again later.";
|
|
59772
|
+
function isUnauthorizedResult(result) {
|
|
59773
|
+
const msg = (result.error ?? "").toLowerCase();
|
|
59774
|
+
return msg.includes("unauthorized") || msg.includes("please login again");
|
|
59775
|
+
}
|
|
59776
|
+
function isUnauthorizedThrow(err) {
|
|
59777
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
59778
|
+
return msg.toLowerCase().includes("unauthorized") || msg.toLowerCase().includes("please login again");
|
|
59779
|
+
}
|
|
59780
|
+
async function executeWithAuthRetry(client, tool, params) {
|
|
59781
|
+
if (tool.name === "dim_login") {
|
|
59782
|
+
return tool.execute(client, params);
|
|
59783
|
+
}
|
|
59784
|
+
try {
|
|
59785
|
+
const result = await tool.execute(client, params);
|
|
59786
|
+
if (!result.error && !result.isError) return result;
|
|
59787
|
+
if (!isUnauthorizedResult(result)) return result;
|
|
59788
|
+
await client.authenticate();
|
|
59789
|
+
const retryResult = await tool.execute(client, params);
|
|
59790
|
+
if (retryResult.isError || retryResult.error) {
|
|
59791
|
+
if (isUnauthorizedResult(retryResult)) {
|
|
59792
|
+
return { error: UNAUTHORIZED_MESSAGE, isError: true };
|
|
59793
|
+
}
|
|
59794
|
+
}
|
|
59795
|
+
return retryResult;
|
|
59796
|
+
} catch (err) {
|
|
59797
|
+
if (!isUnauthorizedThrow(err)) throw err;
|
|
59798
|
+
try {
|
|
59799
|
+
await client.authenticate();
|
|
59800
|
+
return await tool.execute(client, params);
|
|
59801
|
+
} catch (retryErr) {
|
|
59802
|
+
if (isUnauthorizedThrow(retryErr)) {
|
|
59803
|
+
return { error: UNAUTHORIZED_MESSAGE, isError: true };
|
|
59804
|
+
}
|
|
59805
|
+
throw retryErr;
|
|
59806
|
+
}
|
|
59807
|
+
}
|
|
59808
|
+
}
|
|
59809
|
+
|
|
59754
59810
|
// index.ts
|
|
59755
59811
|
function getPluginConfig(api) {
|
|
59756
59812
|
const config = api.config;
|
|
@@ -59933,7 +59989,7 @@ function register(api) {
|
|
|
59933
59989
|
const c = await requireClient();
|
|
59934
59990
|
if ("error" in c) return c.error;
|
|
59935
59991
|
try {
|
|
59936
|
-
const result = await
|
|
59992
|
+
const result = await executeWithAuthRetry(c, tool, params);
|
|
59937
59993
|
if (result.isError || result.error) {
|
|
59938
59994
|
return textResult(result.error || "Unknown error", true);
|
|
59939
59995
|
}
|
package/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
DimAgentClient,
|
|
12
12
|
TOOL_DEFINITIONS,
|
|
13
13
|
DIM_INSTRUCTIONS,
|
|
14
|
+
executeWithAuthRetry,
|
|
14
15
|
} from '@dimcool/dim-agent-core';
|
|
15
16
|
import type { ToolParam, BufferedEvent } from '@dimcool/dim-agent-core';
|
|
16
17
|
|
|
@@ -275,7 +276,7 @@ export default function register(api: {
|
|
|
275
276
|
const c = await requireClient();
|
|
276
277
|
if ('error' in c) return c.error;
|
|
277
278
|
try {
|
|
278
|
-
const result = await
|
|
279
|
+
const result = await executeWithAuthRetry(c, tool, params);
|
|
279
280
|
if (result.isError || result.error) {
|
|
280
281
|
return textResult(result.error || 'Unknown error', true);
|
|
281
282
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimcool/dimclaw",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "OpenClaw plugin for DIM — play games, chat, send USDC, and earn on DIM using the SDK directly (no MCP subprocess).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"openclaw": {
|
|
@@ -17,10 +17,13 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsup",
|
|
20
|
-
"dev": "tsup --watch"
|
|
20
|
+
"dev": "tsup --watch",
|
|
21
|
+
"prepack": "cp package.json .package.json.bak && node --input-type=commonjs -e \"const f=require('fs'),p=JSON.parse(f.readFileSync('package.json','utf8'));for(const[k,v]of Object.entries(p.devDependencies||{}))if(String(v).startsWith('workspace:'))delete p.devDependencies[k];f.writeFileSync('package.json',JSON.stringify(p,null,2)+'\\n')\"",
|
|
22
|
+
"postpack": "mv .package.json.bak package.json"
|
|
21
23
|
},
|
|
22
24
|
"dependencies": {},
|
|
23
25
|
"devDependencies": {
|
|
26
|
+
"@dimcool/dim-agent-core": "0.0.1",
|
|
24
27
|
"@types/node": "^20.3.1",
|
|
25
28
|
"typescript": "^5.0.0",
|
|
26
29
|
"tsup": "^8.5.1"
|