@dimcool/dimclaw 0.1.27 → 0.1.28

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 +537 -120
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5478,17 +5478,17 @@ function v35_default(name, version2, hashfunc) {
5478
5478
  } catch (err) {
5479
5479
  }
5480
5480
  generateUUID.DNS = DNS;
5481
- generateUUID.URL = URL;
5481
+ generateUUID.URL = URL2;
5482
5482
  return generateUUID;
5483
5483
  }
5484
- var DNS, URL;
5484
+ var DNS, URL2;
5485
5485
  var init_v35 = __esm({
5486
5486
  "../../node_modules/jayson/node_modules/uuid/dist/esm-node/v35.js"() {
5487
5487
  "use strict";
5488
5488
  init_stringify();
5489
5489
  init_parse();
5490
5490
  DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
5491
- URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
5491
+ URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
5492
5492
  }
5493
5493
  });
5494
5494
 
@@ -6513,14 +6513,14 @@ var require_url_state_machine = __commonJS({
6513
6513
  return url3.replace(/\u0009|\u000A|\u000D/g, "");
6514
6514
  }
6515
6515
  function shortenPath(url3) {
6516
- const path2 = url3.path;
6517
- if (path2.length === 0) {
6516
+ const path3 = url3.path;
6517
+ if (path3.length === 0) {
6518
6518
  return;
6519
6519
  }
6520
- if (url3.scheme === "file" && path2.length === 1 && isNormalizedWindowsDriveLetter(path2[0])) {
6520
+ if (url3.scheme === "file" && path3.length === 1 && isNormalizedWindowsDriveLetter(path3[0])) {
6521
6521
  return;
6522
6522
  }
6523
- path2.pop();
6523
+ path3.pop();
6524
6524
  }
6525
6525
  function includesCredentials(url3) {
6526
6526
  return url3.username !== "" || url3.password !== "";
@@ -7360,8 +7360,8 @@ var require_URL = __commonJS({
7360
7360
  var utils = require_utils();
7361
7361
  var Impl = require_URL_impl();
7362
7362
  var impl = utils.implSymbol;
7363
- function URL3(url3) {
7364
- if (!this || this[impl] || !(this instanceof URL3)) {
7363
+ function URL4(url3) {
7364
+ if (!this || this[impl] || !(this instanceof URL4)) {
7365
7365
  throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
7366
7366
  }
7367
7367
  if (arguments.length < 1) {
@@ -7377,7 +7377,7 @@ var require_URL = __commonJS({
7377
7377
  }
7378
7378
  module.exports.setup(this, args);
7379
7379
  }
7380
- URL3.prototype.toJSON = function toJSON() {
7380
+ URL4.prototype.toJSON = function toJSON() {
7381
7381
  if (!this || !module.exports.is(this)) {
7382
7382
  throw new TypeError("Illegal invocation");
7383
7383
  }
@@ -7387,7 +7387,7 @@ var require_URL = __commonJS({
7387
7387
  }
7388
7388
  return this[impl].toJSON.apply(this[impl], args);
7389
7389
  };
7390
- Object.defineProperty(URL3.prototype, "href", {
7390
+ Object.defineProperty(URL4.prototype, "href", {
7391
7391
  get() {
7392
7392
  return this[impl].href;
7393
7393
  },
@@ -7398,20 +7398,20 @@ var require_URL = __commonJS({
7398
7398
  enumerable: true,
7399
7399
  configurable: true
7400
7400
  });
7401
- URL3.prototype.toString = function() {
7401
+ URL4.prototype.toString = function() {
7402
7402
  if (!this || !module.exports.is(this)) {
7403
7403
  throw new TypeError("Illegal invocation");
7404
7404
  }
7405
7405
  return this.href;
7406
7406
  };
7407
- Object.defineProperty(URL3.prototype, "origin", {
7407
+ Object.defineProperty(URL4.prototype, "origin", {
7408
7408
  get() {
7409
7409
  return this[impl].origin;
7410
7410
  },
7411
7411
  enumerable: true,
7412
7412
  configurable: true
7413
7413
  });
7414
- Object.defineProperty(URL3.prototype, "protocol", {
7414
+ Object.defineProperty(URL4.prototype, "protocol", {
7415
7415
  get() {
7416
7416
  return this[impl].protocol;
7417
7417
  },
@@ -7422,7 +7422,7 @@ var require_URL = __commonJS({
7422
7422
  enumerable: true,
7423
7423
  configurable: true
7424
7424
  });
7425
- Object.defineProperty(URL3.prototype, "username", {
7425
+ Object.defineProperty(URL4.prototype, "username", {
7426
7426
  get() {
7427
7427
  return this[impl].username;
7428
7428
  },
@@ -7433,7 +7433,7 @@ var require_URL = __commonJS({
7433
7433
  enumerable: true,
7434
7434
  configurable: true
7435
7435
  });
7436
- Object.defineProperty(URL3.prototype, "password", {
7436
+ Object.defineProperty(URL4.prototype, "password", {
7437
7437
  get() {
7438
7438
  return this[impl].password;
7439
7439
  },
@@ -7444,7 +7444,7 @@ var require_URL = __commonJS({
7444
7444
  enumerable: true,
7445
7445
  configurable: true
7446
7446
  });
7447
- Object.defineProperty(URL3.prototype, "host", {
7447
+ Object.defineProperty(URL4.prototype, "host", {
7448
7448
  get() {
7449
7449
  return this[impl].host;
7450
7450
  },
@@ -7455,7 +7455,7 @@ var require_URL = __commonJS({
7455
7455
  enumerable: true,
7456
7456
  configurable: true
7457
7457
  });
7458
- Object.defineProperty(URL3.prototype, "hostname", {
7458
+ Object.defineProperty(URL4.prototype, "hostname", {
7459
7459
  get() {
7460
7460
  return this[impl].hostname;
7461
7461
  },
@@ -7466,7 +7466,7 @@ var require_URL = __commonJS({
7466
7466
  enumerable: true,
7467
7467
  configurable: true
7468
7468
  });
7469
- Object.defineProperty(URL3.prototype, "port", {
7469
+ Object.defineProperty(URL4.prototype, "port", {
7470
7470
  get() {
7471
7471
  return this[impl].port;
7472
7472
  },
@@ -7477,7 +7477,7 @@ var require_URL = __commonJS({
7477
7477
  enumerable: true,
7478
7478
  configurable: true
7479
7479
  });
7480
- Object.defineProperty(URL3.prototype, "pathname", {
7480
+ Object.defineProperty(URL4.prototype, "pathname", {
7481
7481
  get() {
7482
7482
  return this[impl].pathname;
7483
7483
  },
@@ -7488,7 +7488,7 @@ var require_URL = __commonJS({
7488
7488
  enumerable: true,
7489
7489
  configurable: true
7490
7490
  });
7491
- Object.defineProperty(URL3.prototype, "search", {
7491
+ Object.defineProperty(URL4.prototype, "search", {
7492
7492
  get() {
7493
7493
  return this[impl].search;
7494
7494
  },
@@ -7499,7 +7499,7 @@ var require_URL = __commonJS({
7499
7499
  enumerable: true,
7500
7500
  configurable: true
7501
7501
  });
7502
- Object.defineProperty(URL3.prototype, "hash", {
7502
+ Object.defineProperty(URL4.prototype, "hash", {
7503
7503
  get() {
7504
7504
  return this[impl].hash;
7505
7505
  },
@@ -7515,7 +7515,7 @@ var require_URL = __commonJS({
7515
7515
  return !!obj && obj[impl] instanceof Impl.implementation;
7516
7516
  },
7517
7517
  create(constructorArgs, privateData) {
7518
- let obj = Object.create(URL3.prototype);
7518
+ let obj = Object.create(URL4.prototype);
7519
7519
  this.setup(obj, constructorArgs, privateData);
7520
7520
  return obj;
7521
7521
  },
@@ -7525,10 +7525,10 @@ var require_URL = __commonJS({
7525
7525
  obj[impl] = new Impl.implementation(constructorArgs, privateData);
7526
7526
  obj[impl][utils.wrapperSymbol] = obj;
7527
7527
  },
7528
- interface: URL3,
7528
+ interface: URL4,
7529
7529
  expose: {
7530
- Window: { URL: URL3 },
7531
- Worker: { URL: URL3 }
7530
+ Window: { URL: URL4 },
7531
+ Worker: { URL: URL4 }
7532
7532
  }
7533
7533
  };
7534
7534
  }
@@ -7576,8 +7576,8 @@ var require_constants = __commonJS({
7576
7576
  var require_node_gyp_build = __commonJS({
7577
7577
  "../../node_modules/node-gyp-build/node-gyp-build.js"(exports, module) {
7578
7578
  "use strict";
7579
- var fs = __require("fs");
7580
- var path2 = __require("path");
7579
+ var fs2 = __require("fs");
7580
+ var path3 = __require("path");
7581
7581
  var os = __require("os");
7582
7582
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
7583
7583
  var vars = process.config && process.config.variables || {};
@@ -7594,21 +7594,21 @@ var require_node_gyp_build = __commonJS({
7594
7594
  return runtimeRequire(load.resolve(dir));
7595
7595
  }
7596
7596
  load.resolve = load.path = function(dir) {
7597
- dir = path2.resolve(dir || ".");
7597
+ dir = path3.resolve(dir || ".");
7598
7598
  try {
7599
- var name = runtimeRequire(path2.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
7599
+ var name = runtimeRequire(path3.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
7600
7600
  if (process.env[name + "_PREBUILD"]) dir = process.env[name + "_PREBUILD"];
7601
7601
  } catch (err) {
7602
7602
  }
7603
7603
  if (!prebuildsOnly) {
7604
- var release = getFirst(path2.join(dir, "build/Release"), matchBuild);
7604
+ var release = getFirst(path3.join(dir, "build/Release"), matchBuild);
7605
7605
  if (release) return release;
7606
- var debug12 = getFirst(path2.join(dir, "build/Debug"), matchBuild);
7606
+ var debug12 = getFirst(path3.join(dir, "build/Debug"), matchBuild);
7607
7607
  if (debug12) return debug12;
7608
7608
  }
7609
- var prebuild = resolve(dir);
7609
+ var prebuild = resolve2(dir);
7610
7610
  if (prebuild) return prebuild;
7611
- var nearby = resolve(path2.dirname(process.execPath));
7611
+ var nearby = resolve2(path3.dirname(process.execPath));
7612
7612
  if (nearby) return nearby;
7613
7613
  var target = [
7614
7614
  "platform=" + platform,
@@ -7624,27 +7624,27 @@ var require_node_gyp_build = __commonJS({
7624
7624
  // eslint-disable-line
7625
7625
  ].filter(Boolean).join(" ");
7626
7626
  throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
7627
- function resolve(dir2) {
7628
- var tuples = readdirSync(path2.join(dir2, "prebuilds")).map(parseTuple);
7627
+ function resolve2(dir2) {
7628
+ var tuples = readdirSync(path3.join(dir2, "prebuilds")).map(parseTuple);
7629
7629
  var tuple2 = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
7630
7630
  if (!tuple2) return;
7631
- var prebuilds = path2.join(dir2, "prebuilds", tuple2.name);
7631
+ var prebuilds = path3.join(dir2, "prebuilds", tuple2.name);
7632
7632
  var parsed = readdirSync(prebuilds).map(parseTags);
7633
7633
  var candidates = parsed.filter(matchTags(runtime, abi));
7634
7634
  var winner = candidates.sort(compareTags(runtime))[0];
7635
- if (winner) return path2.join(prebuilds, winner.file);
7635
+ if (winner) return path3.join(prebuilds, winner.file);
7636
7636
  }
7637
7637
  };
7638
7638
  function readdirSync(dir) {
7639
7639
  try {
7640
- return fs.readdirSync(dir);
7640
+ return fs2.readdirSync(dir);
7641
7641
  } catch (err) {
7642
7642
  return [];
7643
7643
  }
7644
7644
  }
7645
7645
  function getFirst(dir, filter) {
7646
7646
  var files = readdirSync(dir).filter(filter);
7647
- return files[0] && path2.join(dir, files[0]);
7647
+ return files[0] && path3.join(dir, files[0]);
7648
7648
  }
7649
7649
  function matchBuild(name) {
7650
7650
  return /\.node$/.test(name);
@@ -7731,7 +7731,7 @@ var require_node_gyp_build = __commonJS({
7731
7731
  return typeof window !== "undefined" && window.process && window.process.type === "renderer";
7732
7732
  }
7733
7733
  function isAlpine(platform2) {
7734
- return platform2 === "linux" && fs.existsSync("/etc/alpine-release");
7734
+ return platform2 === "linux" && fs2.existsSync("/etc/alpine-release");
7735
7735
  }
7736
7736
  load.parseTags = parseTags;
7737
7737
  load.matchTags = matchTags;
@@ -10017,7 +10017,7 @@ var require_websocket = __commonJS({
10017
10017
  var tls = __require("tls");
10018
10018
  var { randomBytes: randomBytes2, createHash } = __require("crypto");
10019
10019
  var { Duplex, Readable: Readable2 } = __require("stream");
10020
- var { URL: URL3 } = __require("url");
10020
+ var { URL: URL4 } = __require("url");
10021
10021
  var PerMessageDeflate = require_permessage_deflate();
10022
10022
  var Receiver3 = require_receiver();
10023
10023
  var Sender3 = require_sender();
@@ -10507,11 +10507,11 @@ var require_websocket = __commonJS({
10507
10507
  );
10508
10508
  }
10509
10509
  let parsedUrl;
10510
- if (address instanceof URL3) {
10510
+ if (address instanceof URL4) {
10511
10511
  parsedUrl = address;
10512
10512
  } else {
10513
10513
  try {
10514
- parsedUrl = new URL3(address);
10514
+ parsedUrl = new URL4(address);
10515
10515
  } catch (e) {
10516
10516
  throw new SyntaxError(`Invalid URL: ${address}`);
10517
10517
  }
@@ -10648,7 +10648,7 @@ var require_websocket = __commonJS({
10648
10648
  req.abort();
10649
10649
  let addr;
10650
10650
  try {
10651
- addr = new URL3(location2, address);
10651
+ addr = new URL4(location2, address);
10652
10652
  } catch (e) {
10653
10653
  const err = new SyntaxError(`Invalid URL: ${location2}`);
10654
10654
  emitErrorAndClose(websocket, err);
@@ -11587,7 +11587,7 @@ var require_eventemitter3 = __commonJS({
11587
11587
  var require_XMLHttpRequest = __commonJS({
11588
11588
  "../../node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js"(exports, module) {
11589
11589
  "use strict";
11590
- var fs = __require("fs");
11590
+ var fs2 = __require("fs");
11591
11591
  var Url2 = __require("url");
11592
11592
  var spawn = __require("child_process").spawn;
11593
11593
  module.exports = XMLHttpRequest3;
@@ -11745,7 +11745,7 @@ var require_XMLHttpRequest = __commonJS({
11745
11745
  throw new Error("XMLHttpRequest: Only GET method is supported");
11746
11746
  }
11747
11747
  if (settings.async) {
11748
- fs.readFile(unescape(url3.pathname), function(error, data2) {
11748
+ fs2.readFile(unescape(url3.pathname), function(error, data2) {
11749
11749
  if (error) {
11750
11750
  self2.handleError(error, error.errno || -1);
11751
11751
  } else {
@@ -11757,7 +11757,7 @@ var require_XMLHttpRequest = __commonJS({
11757
11757
  });
11758
11758
  } else {
11759
11759
  try {
11760
- this.response = fs.readFileSync(unescape(url3.pathname));
11760
+ this.response = fs2.readFileSync(unescape(url3.pathname));
11761
11761
  this.responseText = this.response.toString("utf8");
11762
11762
  this.status = 200;
11763
11763
  setState(self2.DONE);
@@ -11883,15 +11883,15 @@ var require_XMLHttpRequest = __commonJS({
11883
11883
  } else {
11884
11884
  var contentFile = ".node-xmlhttprequest-content-" + process.pid;
11885
11885
  var syncFile = ".node-xmlhttprequest-sync-" + process.pid;
11886
- fs.writeFileSync(syncFile, "", "utf8");
11886
+ fs2.writeFileSync(syncFile, "", "utf8");
11887
11887
  var execString = "var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http" + (ssl ? "s" : "") + ".request;var options = " + JSON.stringify(options) + ";var responseText = '';var responseData = Buffer.alloc(0);var req = doRequest(options, function(response) {response.on('data', function(chunk) { var data = Buffer.from(chunk); responseText += data.toString('utf8'); responseData = Buffer.concat([responseData, data]);});response.on('end', function() {fs.writeFileSync('" + contentFile + "', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText, data: responseData.toString('base64')}}), 'utf8');fs.unlinkSync('" + syncFile + "');});response.on('error', function(error) {fs.writeFileSync('" + contentFile + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('" + syncFile + "');});}).on('error', function(error) {fs.writeFileSync('" + contentFile + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('" + syncFile + "');});" + (data ? "req.write('" + JSON.stringify(data).slice(1, -1).replace(/'/g, "\\'") + "');" : "") + "req.end();";
11888
11888
  var syncProc = spawn(process.argv[0], ["-e", execString]);
11889
11889
  var statusText;
11890
- while (fs.existsSync(syncFile)) {
11890
+ while (fs2.existsSync(syncFile)) {
11891
11891
  }
11892
- self2.responseText = fs.readFileSync(contentFile, "utf8");
11892
+ self2.responseText = fs2.readFileSync(contentFile, "utf8");
11893
11893
  syncProc.stdin.end();
11894
- fs.unlinkSync(contentFile);
11894
+ fs2.unlinkSync(contentFile);
11895
11895
  if (self2.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)) {
11896
11896
  var errorObj = JSON.parse(self2.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/, ""));
11897
11897
  self2.handleError(errorObj, 503);
@@ -14959,7 +14959,7 @@ var require_websocket2 = __commonJS({
14959
14959
  var tls = __require("tls");
14960
14960
  var { randomBytes: randomBytes2, createHash } = __require("crypto");
14961
14961
  var { Duplex, Readable: Readable2 } = __require("stream");
14962
- var { URL: URL3 } = __require("url");
14962
+ var { URL: URL4 } = __require("url");
14963
14963
  var PerMessageDeflate = require_permessage_deflate2();
14964
14964
  var Receiver3 = require_receiver2();
14965
14965
  var Sender3 = require_sender2();
@@ -15449,11 +15449,11 @@ var require_websocket2 = __commonJS({
15449
15449
  );
15450
15450
  }
15451
15451
  let parsedUrl;
15452
- if (address instanceof URL3) {
15452
+ if (address instanceof URL4) {
15453
15453
  parsedUrl = address;
15454
15454
  } else {
15455
15455
  try {
15456
- parsedUrl = new URL3(address);
15456
+ parsedUrl = new URL4(address);
15457
15457
  } catch (e) {
15458
15458
  throw new SyntaxError(`Invalid URL: ${address}`);
15459
15459
  }
@@ -15590,7 +15590,7 @@ var require_websocket2 = __commonJS({
15590
15590
  req.abort();
15591
15591
  let addr;
15592
15592
  try {
15593
- addr = new URL3(location2, address);
15593
+ addr = new URL4(location2, address);
15594
15594
  } catch (e) {
15595
15595
  const err = new SyntaxError(`Invalid URL: ${location2}`);
15596
15596
  emitErrorAndClose(websocket, err);
@@ -18589,8 +18589,8 @@ var require_nacl_fast = __commonJS({
18589
18589
  });
18590
18590
 
18591
18591
  // index.ts
18592
- import { mkdir, readFile, rename, writeFile } from "fs/promises";
18593
- import path from "path";
18592
+ import { mkdir, readFile as readFile2, rename, writeFile } from "fs/promises";
18593
+ import path2 from "path";
18594
18594
 
18595
18595
  // ../../node_modules/@solana/web3.js/lib/index.esm.js
18596
18596
  import { Buffer as Buffer2 } from "buffer";
@@ -21589,8 +21589,8 @@ var StructError = class extends TypeError {
21589
21589
  constructor(failure, failures) {
21590
21590
  let cached;
21591
21591
  const { message, explanation, ...rest } = failure;
21592
- const { path: path2 } = failure;
21593
- const msg = path2.length === 0 ? message : `At path: ${path2.join(".")} -- ${message}`;
21592
+ const { path: path3 } = failure;
21593
+ const msg = path3.length === 0 ? message : `At path: ${path3.join(".")} -- ${message}`;
21594
21594
  super(explanation ?? msg);
21595
21595
  if (explanation != null)
21596
21596
  this.cause = msg;
@@ -21628,15 +21628,15 @@ function toFailure(result, context, struct2, value2) {
21628
21628
  } else if (typeof result === "string") {
21629
21629
  result = { message: result };
21630
21630
  }
21631
- const { path: path2, branch } = context;
21631
+ const { path: path3, branch } = context;
21632
21632
  const { type: type2 } = struct2;
21633
21633
  const { refinement, message = `Expected a value of type \`${type2}\`${refinement ? ` with refinement \`${refinement}\`` : ""}, but received: \`${print(value2)}\`` } = result;
21634
21634
  return {
21635
21635
  value: value2,
21636
21636
  type: type2,
21637
21637
  refinement,
21638
- key: path2[path2.length - 1],
21639
- path: path2,
21638
+ key: path3[path3.length - 1],
21639
+ path: path3,
21640
21640
  branch,
21641
21641
  ...result,
21642
21642
  message
@@ -21654,8 +21654,8 @@ function* toFailures(result, context, struct2, value2) {
21654
21654
  }
21655
21655
  }
21656
21656
  function* run(value2, struct2, options = {}) {
21657
- const { path: path2 = [], branch = [value2], coerce: coerce2 = false, mask: mask2 = false } = options;
21658
- const ctx = { path: path2, branch, mask: mask2 };
21657
+ const { path: path3 = [], branch = [value2], coerce: coerce2 = false, mask: mask2 = false } = options;
21658
+ const ctx = { path: path3, branch, mask: mask2 };
21659
21659
  if (coerce2) {
21660
21660
  value2 = struct2.coercer(value2, ctx);
21661
21661
  }
@@ -21667,7 +21667,7 @@ function* run(value2, struct2, options = {}) {
21667
21667
  }
21668
21668
  for (let [k, v, s] of struct2.entries(value2, ctx)) {
21669
21669
  const ts = run(v, s, {
21670
- path: k === void 0 ? path2 : [...path2, k],
21670
+ path: k === void 0 ? path3 : [...path3, k],
21671
21671
  branch: k === void 0 ? branch : [...branch, v],
21672
21672
  coerce: coerce2,
21673
21673
  mask: mask2,
@@ -22282,7 +22282,7 @@ function consumeBody() {
22282
22282
  let accum = [];
22283
22283
  let accumBytes = 0;
22284
22284
  let abort = false;
22285
- return new Body.Promise(function(resolve, reject) {
22285
+ return new Body.Promise(function(resolve2, reject) {
22286
22286
  let resTimeout;
22287
22287
  if (_this4.timeout) {
22288
22288
  resTimeout = setTimeout(function() {
@@ -22316,7 +22316,7 @@ function consumeBody() {
22316
22316
  }
22317
22317
  clearTimeout(resTimeout);
22318
22318
  try {
22319
- resolve(Buffer.concat(accum, accumBytes));
22319
+ resolve2(Buffer.concat(accum, accumBytes));
22320
22320
  } catch (err) {
22321
22321
  reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
22322
22322
  }
@@ -22817,12 +22817,12 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
22817
22817
  configurable: true
22818
22818
  });
22819
22819
  var INTERNALS$2 = /* @__PURE__ */ Symbol("Request internals");
22820
- var URL2 = Url.URL || import_whatwg_url.default.URL;
22820
+ var URL3 = Url.URL || import_whatwg_url.default.URL;
22821
22821
  var parse_url = Url.parse;
22822
22822
  var format_url = Url.format;
22823
22823
  function parseURL(urlStr) {
22824
22824
  if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
22825
- urlStr = new URL2(urlStr).toString();
22825
+ urlStr = new URL3(urlStr).toString();
22826
22826
  }
22827
22827
  return parse_url(urlStr);
22828
22828
  }
@@ -22991,7 +22991,7 @@ function fetch2(url3, opts) {
22991
22991
  throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
22992
22992
  }
22993
22993
  Body.Promise = fetch2.Promise;
22994
- return new fetch2.Promise(function(resolve, reject) {
22994
+ return new fetch2.Promise(function(resolve2, reject) {
22995
22995
  const request = new Request(url3, opts);
22996
22996
  const options = getNodeRequestOptions(request);
22997
22997
  const send = (options.protocol === "https:" ? https : http).request;
@@ -23124,7 +23124,7 @@ function fetch2(url3, opts) {
23124
23124
  requestOpts.body = void 0;
23125
23125
  requestOpts.headers.delete("content-length");
23126
23126
  }
23127
- resolve(fetch2(new Request(locationURL, requestOpts)));
23127
+ resolve2(fetch2(new Request(locationURL, requestOpts)));
23128
23128
  finalize();
23129
23129
  return;
23130
23130
  }
@@ -23145,7 +23145,7 @@ function fetch2(url3, opts) {
23145
23145
  const codings = headers.get("Content-Encoding");
23146
23146
  if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
23147
23147
  response = new Response(body, response_options);
23148
- resolve(response);
23148
+ resolve2(response);
23149
23149
  return;
23150
23150
  }
23151
23151
  const zlibOptions = {
@@ -23155,7 +23155,7 @@ function fetch2(url3, opts) {
23155
23155
  if (codings == "gzip" || codings == "x-gzip") {
23156
23156
  body = body.pipe(zlib.createGunzip(zlibOptions));
23157
23157
  response = new Response(body, response_options);
23158
- resolve(response);
23158
+ resolve2(response);
23159
23159
  return;
23160
23160
  }
23161
23161
  if (codings == "deflate" || codings == "x-deflate") {
@@ -23167,12 +23167,12 @@ function fetch2(url3, opts) {
23167
23167
  body = body.pipe(zlib.createInflateRaw());
23168
23168
  }
23169
23169
  response = new Response(body, response_options);
23170
- resolve(response);
23170
+ resolve2(response);
23171
23171
  });
23172
23172
  raw.on("end", function() {
23173
23173
  if (!response) {
23174
23174
  response = new Response(body, response_options);
23175
- resolve(response);
23175
+ resolve2(response);
23176
23176
  }
23177
23177
  });
23178
23178
  return;
@@ -23180,11 +23180,11 @@ function fetch2(url3, opts) {
23180
23180
  if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
23181
23181
  body = body.pipe(zlib.createBrotliDecompress());
23182
23182
  response = new Response(body, response_options);
23183
- resolve(response);
23183
+ resolve2(response);
23184
23184
  return;
23185
23185
  }
23186
23186
  response = new Response(body, response_options);
23187
- resolve(response);
23187
+ resolve2(response);
23188
23188
  });
23189
23189
  writeToStream(req, request);
23190
23190
  });
@@ -25913,12 +25913,12 @@ Message: ${transactionMessage}.
25913
25913
  }
25914
25914
  async getLogs(connection) {
25915
25915
  if (!Array.isArray(this.transactionLogs)) {
25916
- this.transactionLogs = new Promise((resolve, reject) => {
25916
+ this.transactionLogs = new Promise((resolve2, reject) => {
25917
25917
  connection.getTransaction(this.signature).then((tx) => {
25918
25918
  if (tx && tx.meta && tx.meta.logMessages) {
25919
25919
  const logs = tx.meta.logMessages;
25920
25920
  this.transactionLogs = logs;
25921
- resolve(logs);
25921
+ resolve2(logs);
25922
25922
  } else {
25923
25923
  reject(new Error("Log messages not found"));
25924
25924
  }
@@ -25975,7 +25975,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
25975
25975
  return signature;
25976
25976
  }
25977
25977
  function sleep(ms) {
25978
- return new Promise((resolve) => setTimeout(resolve, ms));
25978
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
25979
25979
  }
25980
25980
  function encodeData(type2, fields) {
25981
25981
  const allocLength = type2.layout.span >= 0 ? type2.layout.span : getAlloc(type2, fields);
@@ -26554,7 +26554,7 @@ var Loader = class _Loader {
26554
26554
  }
26555
26555
  } catch {
26556
26556
  }
26557
- await new Promise((resolve) => setTimeout(resolve, Math.round(MS_PER_SLOT / 2)));
26557
+ await new Promise((resolve2) => setTimeout(resolve2, Math.round(MS_PER_SLOT / 2)));
26558
26558
  }
26559
26559
  }
26560
26560
  return true;
@@ -29824,12 +29824,12 @@ function parse3(str) {
29824
29824
  uri.queryKey = queryKey(uri, uri["query"]);
29825
29825
  return uri;
29826
29826
  }
29827
- function pathNames(obj, path2) {
29828
- const regx = /\/{2,9}/g, names = path2.replace(regx, "/").split("/");
29829
- if (path2.slice(0, 1) == "/" || path2.length === 0) {
29827
+ function pathNames(obj, path3) {
29828
+ const regx = /\/{2,9}/g, names = path3.replace(regx, "/").split("/");
29829
+ if (path3.slice(0, 1) == "/" || path3.length === 0) {
29830
29830
  names.splice(0, 1);
29831
29831
  }
29832
- if (path2.slice(-1) == "/") {
29832
+ if (path3.slice(-1) == "/") {
29833
29833
  names.splice(names.length - 1, 1);
29834
29834
  }
29835
29835
  return names;
@@ -30446,7 +30446,7 @@ var protocol2 = Socket.protocol;
30446
30446
  // ../../node_modules/socket.io-client/build/esm-debug/url.js
30447
30447
  var import_debug7 = __toESM(require_src2(), 1);
30448
30448
  var debug7 = (0, import_debug7.default)("socket.io-client:url");
30449
- function url2(uri, path2 = "", loc) {
30449
+ function url2(uri, path3 = "", loc) {
30450
30450
  let obj = uri;
30451
30451
  loc = loc || typeof location !== "undefined" && location;
30452
30452
  if (null == uri)
@@ -30480,7 +30480,7 @@ function url2(uri, path2 = "", loc) {
30480
30480
  obj.path = obj.path || "/";
30481
30481
  const ipv6 = obj.host.indexOf(":") !== -1;
30482
30482
  const host = ipv6 ? "[" + obj.host + "]" : obj.host;
30483
- obj.id = obj.protocol + "://" + host + ":" + obj.port + path2;
30483
+ obj.id = obj.protocol + "://" + host + ":" + obj.port + path3;
30484
30484
  obj.href = obj.protocol + "://" + host + (loc && loc.port === obj.port ? "" : ":" + obj.port);
30485
30485
  return obj;
30486
30486
  }
@@ -31130,9 +31130,9 @@ var Socket2 = class extends Emitter {
31130
31130
  * @return a Promise that will be fulfilled when the server acknowledges the event
31131
31131
  */
31132
31132
  emitWithAck(ev, ...args) {
31133
- return new Promise((resolve, reject) => {
31133
+ return new Promise((resolve2, reject) => {
31134
31134
  const fn = (arg1, arg2) => {
31135
- return arg1 ? reject(arg1) : resolve(arg2);
31135
+ return arg1 ? reject(arg1) : resolve2(arg2);
31136
31136
  };
31137
31137
  fn.withError = true;
31138
31138
  args.push(fn);
@@ -32104,8 +32104,8 @@ function lookup(uri, opts) {
32104
32104
  const parsed = url2(uri, opts.path || "/socket.io");
32105
32105
  const source = parsed.source;
32106
32106
  const id = parsed.id;
32107
- const path2 = parsed.path;
32108
- const sameNamespace = cache[id] && path2 in cache[id]["nsps"];
32107
+ const path3 = parsed.path;
32108
+ const sameNamespace = cache[id] && path3 in cache[id]["nsps"];
32109
32109
  const newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
32110
32110
  let io;
32111
32111
  if (newConnection) {
@@ -33003,6 +33003,16 @@ var Admin = class {
33003
33003
  );
33004
33004
  }
33005
33005
  };
33006
+ function isFile(input) {
33007
+ return typeof input.arrayBuffer === "function";
33008
+ }
33009
+ function buildFormDataFromPayload(payload) {
33010
+ const formData = new FormData();
33011
+ const part = payload.data instanceof Uint8Array ? payload.data : new Uint8Array(payload.data);
33012
+ const blob3 = new Blob([part], { type: payload.mimeType });
33013
+ formData.append("file", blob3, payload.filename);
33014
+ return formData;
33015
+ }
33006
33016
  var Users = class {
33007
33017
  constructor(http2, logger2) {
33008
33018
  this.http = http2;
@@ -33089,14 +33099,22 @@ var Users = class {
33089
33099
  async updateProfile(data) {
33090
33100
  return this.http.patch("/users/me/profile", data);
33091
33101
  }
33092
- async uploadAvatar(file) {
33093
- const formData = new FormData();
33094
- formData.append("file", file);
33102
+ async uploadAvatar(input) {
33103
+ const payload = isFile(input) ? {
33104
+ data: new Uint8Array(await input.arrayBuffer()),
33105
+ mimeType: input.type,
33106
+ filename: input.name
33107
+ } : input;
33108
+ const formData = buildFormDataFromPayload(payload);
33095
33109
  return this.http.upload("/users/me/profile/avatar", formData);
33096
33110
  }
33097
- async uploadCoverImage(file) {
33098
- const formData = new FormData();
33099
- formData.append("file", file);
33111
+ async uploadCoverImage(input) {
33112
+ const payload = isFile(input) ? {
33113
+ data: new Uint8Array(await input.arrayBuffer()),
33114
+ mimeType: input.type,
33115
+ filename: input.name
33116
+ } : input;
33117
+ const formData = buildFormDataFromPayload(payload);
33100
33118
  return this.http.upload("/users/me/profile/cover", formData);
33101
33119
  }
33102
33120
  async removeAvatar() {
@@ -33430,7 +33448,7 @@ async function withRetry(fn, options = {}) {
33430
33448
  throw lastError;
33431
33449
  }
33432
33450
  function sleep2(ms) {
33433
- return new Promise((resolve) => setTimeout(resolve, ms));
33451
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
33434
33452
  }
33435
33453
  var DEFAULT_RETRY_OPTIONS = {
33436
33454
  maxAttempts: 3,
@@ -34698,12 +34716,12 @@ var BaseWsTransport = class {
34698
34716
  if (this.connectionState.connected) {
34699
34717
  return Promise.resolve();
34700
34718
  }
34701
- return new Promise((resolve, reject) => {
34719
+ return new Promise((resolve2, reject) => {
34702
34720
  const timeoutId = setTimeout(() => {
34703
34721
  this.waiters.delete(waiter);
34704
34722
  reject(new Error("WebSocket connection timed out"));
34705
34723
  }, timeoutMs);
34706
- const waiter = { resolve, reject, timeoutId };
34724
+ const waiter = { resolve: resolve2, reject, timeoutId };
34707
34725
  this.waiters.add(waiter);
34708
34726
  });
34709
34727
  }
@@ -35477,6 +35495,22 @@ function createGameActionsStore(transport) {
35477
35495
  updateState(gameId, updated);
35478
35496
  break;
35479
35497
  }
35498
+ case "game:move": {
35499
+ const { gameId, fen, turn, currentPlayerId, status, winnerId } = event.payload;
35500
+ if (!gameId) return;
35501
+ const current = store.getState().statesByGameId[gameId];
35502
+ if (!isNonRpsState(current)) return;
35503
+ const updated = {
35504
+ ...current,
35505
+ fen,
35506
+ turn,
35507
+ currentPlayerId,
35508
+ status,
35509
+ ...winnerId != null && { winnerId }
35510
+ };
35511
+ updateState(gameId, updated);
35512
+ break;
35513
+ }
35480
35514
  case "game:state": {
35481
35515
  const gameId = event.payload.gameId ?? event.payload.state.gameId;
35482
35516
  if (!gameId) return;
@@ -37466,13 +37500,12 @@ async function gameLoop(client, args) {
37466
37500
  const store = client.sdk.gameActionsStore;
37467
37501
  const timeout = 3e5;
37468
37502
  const start = Date.now();
37469
- let state = store.store.getState().statesByGameId[gameId];
37470
- if (!state) {
37471
- const fetched = await client.sdk.games.getGameState(gameId);
37472
- store.setBaseState(gameId, fetched);
37473
- store.joinGame(gameId);
37474
- state = fetched;
37475
- }
37503
+ await client.ensureConnected();
37504
+ store.joinGame(gameId);
37505
+ const fetched = await client.sdk.games.getGameState(gameId);
37506
+ store.setBaseState(gameId, fetched);
37507
+ let state = fetched;
37508
+ let lastRefresh = Date.now();
37476
37509
  while (Date.now() - start < timeout) {
37477
37510
  state = store.store.getState().statesByGameId[gameId];
37478
37511
  if (state?.status === "completed") {
@@ -37482,17 +37515,22 @@ async function gameLoop(client, args) {
37482
37515
  return buildGameLoopReturn(client, gameId, state, "your-turn");
37483
37516
  }
37484
37517
  await raceTimeout(
37485
- new Promise((resolve) => {
37518
+ new Promise((resolve2) => {
37486
37519
  const unsub = store.store.subscribeSelector(
37487
37520
  (s) => s.statesByGameId[gameId],
37488
37521
  () => {
37489
37522
  unsub();
37490
- resolve();
37523
+ resolve2();
37491
37524
  }
37492
37525
  );
37493
37526
  }),
37494
37527
  1e3
37495
37528
  );
37529
+ if (Date.now() - lastRefresh > 5e3) {
37530
+ const fresh = await client.sdk.games.getGameState(gameId);
37531
+ store.setBaseState(gameId, fresh);
37532
+ lastRefresh = Date.now();
37533
+ }
37496
37534
  }
37497
37535
  state = store.store.getState().statesByGameId[gameId];
37498
37536
  return buildGameLoopReturn(client, gameId, state ?? {}, "timeout");
@@ -37566,11 +37604,11 @@ async function acceptRematch(client, args) {
37566
37604
  }
37567
37605
  }
37568
37606
  function raceTimeout(promise, ms) {
37569
- return new Promise((resolve) => {
37570
- const timer = setTimeout(resolve, ms);
37607
+ return new Promise((resolve2) => {
37608
+ const timer = setTimeout(resolve2, ms);
37571
37609
  promise.then(() => {
37572
37610
  clearTimeout(timer);
37573
- resolve();
37611
+ resolve2();
37574
37612
  });
37575
37613
  });
37576
37614
  }
@@ -38152,6 +38190,321 @@ async function getAgentConfig(client) {
38152
38190
  }
38153
38191
  }
38154
38192
 
38193
+ // ../dim-agent-core/src/tools/profile.ts
38194
+ import * as fs from "fs/promises";
38195
+ import * as path from "path";
38196
+ import * as dns from "dns";
38197
+ import { promisify } from "util";
38198
+ var dnsLookup = promisify(dns.lookup);
38199
+ var MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
38200
+ var FETCH_TIMEOUT_MS = 15e3;
38201
+ var ALLOWED_MIME_TYPES = [
38202
+ "image/jpeg",
38203
+ "image/jpg",
38204
+ "image/png",
38205
+ "image/webp",
38206
+ "image/gif"
38207
+ ];
38208
+ var EXT_TO_MIME = {
38209
+ ".png": "image/png",
38210
+ ".jpg": "image/jpeg",
38211
+ ".jpeg": "image/jpeg",
38212
+ ".gif": "image/gif",
38213
+ ".webp": "image/webp"
38214
+ };
38215
+ function getDefaultAllowedBaseDir() {
38216
+ const env = process.env.DIM_AGENT_WORKSPACE_DIR;
38217
+ if (env) return path.resolve(env);
38218
+ const home = process.env.HOME || process.env.USERPROFILE || ".";
38219
+ return path.join(home, ".openclaw", "workspace");
38220
+ }
38221
+ function isPathUnderBase(filePath, baseDir) {
38222
+ const resolved = path.resolve(filePath);
38223
+ const base3 = path.resolve(baseDir);
38224
+ const relative2 = path.relative(base3, resolved);
38225
+ return relative2 !== "" && !relative2.startsWith("..") && !path.isAbsolute(relative2);
38226
+ }
38227
+ function mimeFromExtension(filePathOrUrl) {
38228
+ const ext = path.extname(filePathOrUrl).toLowerCase();
38229
+ return EXT_TO_MIME[ext] ?? null;
38230
+ }
38231
+ function normalizeContentType(header) {
38232
+ if (!header) return null;
38233
+ const main = header.split(";")[0].trim().toLowerCase();
38234
+ return main || null;
38235
+ }
38236
+ function isAllowedMime(mime) {
38237
+ return ALLOWED_MIME_TYPES.includes(
38238
+ mime
38239
+ );
38240
+ }
38241
+ function isPrivateOrLocalHost(hostname) {
38242
+ if (hostname === "localhost" || hostname === "::1") return true;
38243
+ const ipv4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(hostname);
38244
+ if (ipv4) {
38245
+ const [, a, b, c, d] = ipv4.map(Number);
38246
+ if (a === 127) return true;
38247
+ if (a === 10) return true;
38248
+ if (a === 172 && b >= 16 && b <= 31) return true;
38249
+ if (a === 192 && b === 168) return true;
38250
+ if (a === 169 && b === 254) return true;
38251
+ return false;
38252
+ }
38253
+ if (hostname.startsWith("::1") || hostname.startsWith("fe80:")) return true;
38254
+ return false;
38255
+ }
38256
+ async function assertUrlSafeForFetch(imageUrl) {
38257
+ let parsed;
38258
+ try {
38259
+ parsed = new URL(imageUrl);
38260
+ } catch {
38261
+ throw new Error("Invalid imageUrl: not a valid URL.");
38262
+ }
38263
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
38264
+ throw new Error("Invalid imageUrl: only http and https are allowed.");
38265
+ }
38266
+ const hostname = parsed.hostname;
38267
+ if (isPrivateOrLocalHost(hostname)) {
38268
+ throw new Error(
38269
+ "Invalid imageUrl: URLs to localhost or private IPs are not allowed."
38270
+ );
38271
+ }
38272
+ try {
38273
+ const { address } = await dnsLookup(hostname, { family: 4 });
38274
+ if (isPrivateOrLocalHost(address)) {
38275
+ throw new Error(
38276
+ "Invalid imageUrl: hostname resolves to a private or local IP."
38277
+ );
38278
+ }
38279
+ if (address === "169.254.169.254") {
38280
+ throw new Error("Invalid imageUrl: cloud metadata URLs are not allowed.");
38281
+ }
38282
+ } catch (err) {
38283
+ if (err instanceof Error && err.message.startsWith("Invalid imageUrl:"))
38284
+ throw err;
38285
+ throw new Error(
38286
+ `Invalid imageUrl: could not resolve hostname (${err instanceof Error ? err.message : String(err)}).`
38287
+ );
38288
+ }
38289
+ }
38290
+ async function resolveImageFromFilePath(filePath, allowedBaseDir) {
38291
+ if (!path.isAbsolute(filePath)) {
38292
+ filePath = path.resolve(allowedBaseDir, filePath);
38293
+ }
38294
+ const realPath = await fs.realpath(filePath).catch(() => null);
38295
+ const resolved = realPath ?? filePath;
38296
+ if (!isPathUnderBase(resolved, allowedBaseDir)) {
38297
+ throw new Error("filePath is outside the allowed workspace directory.");
38298
+ }
38299
+ const stat2 = await fs.stat(resolved, { bigint: false }).catch(() => null);
38300
+ if (!stat2) throw new Error("File not found or not readable.");
38301
+ if (stat2.size > MAX_FILE_SIZE_BYTES) {
38302
+ throw new Error(
38303
+ `File size exceeds ${MAX_FILE_SIZE_BYTES / 1024 / 1024}MB limit.`
38304
+ );
38305
+ }
38306
+ const buffer = await fs.readFile(resolved);
38307
+ const mime = mimeFromExtension(resolved) ?? "image/png";
38308
+ if (!isAllowedMime(mime)) {
38309
+ throw new Error(
38310
+ `File type not allowed. Allowed: ${ALLOWED_MIME_TYPES.join(", ")}.`
38311
+ );
38312
+ }
38313
+ const filename = path.basename(resolved) || "image";
38314
+ return {
38315
+ data: new Uint8Array(buffer),
38316
+ mimeType: mime,
38317
+ filename
38318
+ };
38319
+ }
38320
+ async function resolveImageFromUrl(imageUrl) {
38321
+ await assertUrlSafeForFetch(imageUrl);
38322
+ const controller = new AbortController();
38323
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
38324
+ try {
38325
+ const res = await fetch(imageUrl, {
38326
+ redirect: "manual",
38327
+ signal: controller.signal
38328
+ });
38329
+ clearTimeout(timeout);
38330
+ if (res.status >= 300 && res.status < 400) {
38331
+ throw new Error("Redirects are not allowed. Use the final image URL.");
38332
+ }
38333
+ if (!res.ok) {
38334
+ throw new Error(`Fetch failed: ${res.status} ${res.statusText}`);
38335
+ }
38336
+ const contentType = normalizeContentType(res.headers.get("Content-Type"));
38337
+ const mimeFromHeader = contentType && isAllowedMime(contentType) ? contentType : null;
38338
+ const contentLength = res.headers.get("Content-Length");
38339
+ if (contentLength) {
38340
+ const len = parseInt(contentLength, 10);
38341
+ if (!Number.isNaN(len) && len > MAX_FILE_SIZE_BYTES) {
38342
+ throw new Error(
38343
+ `Content-Length (${len}) exceeds ${MAX_FILE_SIZE_BYTES / 1024 / 1024}MB limit.`
38344
+ );
38345
+ }
38346
+ }
38347
+ const buf = await res.arrayBuffer();
38348
+ if (buf.byteLength > MAX_FILE_SIZE_BYTES) {
38349
+ throw new Error(
38350
+ `Response size exceeds ${MAX_FILE_SIZE_BYTES / 1024 / 1024}MB limit.`
38351
+ );
38352
+ }
38353
+ const mime = mimeFromHeader ?? mimeFromExtension(imageUrl) ?? "image/png";
38354
+ if (!isAllowedMime(mime)) {
38355
+ throw new Error(
38356
+ `Content-Type not allowed. Allowed: ${ALLOWED_MIME_TYPES.join(", ")}.`
38357
+ );
38358
+ }
38359
+ const ext = mime === "image/jpeg" || mime === "image/jpg" ? ".jpg" : mime.replace("image/", ".");
38360
+ return {
38361
+ data: new Uint8Array(buf),
38362
+ mimeType: mime,
38363
+ filename: `image${ext}`
38364
+ };
38365
+ } finally {
38366
+ clearTimeout(timeout);
38367
+ }
38368
+ }
38369
+ async function uploadAvatar(client, args) {
38370
+ try {
38371
+ if (!client.currentUserId) {
38372
+ return {
38373
+ error: "Not authenticated. Call dim_login first.",
38374
+ isError: true
38375
+ };
38376
+ }
38377
+ const { filePath, imageUrl } = args;
38378
+ if (filePath && imageUrl) {
38379
+ return {
38380
+ error: "Provide either filePath or imageUrl, not both.",
38381
+ isError: true
38382
+ };
38383
+ }
38384
+ if (!filePath && !imageUrl) {
38385
+ return { error: "Provide filePath or imageUrl.", isError: true };
38386
+ }
38387
+ const baseDir = getDefaultAllowedBaseDir();
38388
+ const payload = filePath ? await resolveImageFromFilePath(filePath, baseDir) : await resolveImageFromUrl(imageUrl);
38389
+ const user = await client.sdk.users.uploadAvatar(payload);
38390
+ return { data: { success: true, user } };
38391
+ } catch (error) {
38392
+ return {
38393
+ error: error instanceof Error ? error.message : String(error),
38394
+ isError: true
38395
+ };
38396
+ }
38397
+ }
38398
+ async function uploadCoverImage(client, args) {
38399
+ try {
38400
+ if (!client.currentUserId) {
38401
+ return {
38402
+ error: "Not authenticated. Call dim_login first.",
38403
+ isError: true
38404
+ };
38405
+ }
38406
+ const { filePath, imageUrl } = args;
38407
+ if (filePath && imageUrl) {
38408
+ return {
38409
+ error: "Provide either filePath or imageUrl, not both.",
38410
+ isError: true
38411
+ };
38412
+ }
38413
+ if (!filePath && !imageUrl) {
38414
+ return { error: "Provide filePath or imageUrl.", isError: true };
38415
+ }
38416
+ const baseDir = getDefaultAllowedBaseDir();
38417
+ const payload = filePath ? await resolveImageFromFilePath(filePath, baseDir) : await resolveImageFromUrl(imageUrl);
38418
+ const user = await client.sdk.users.uploadCoverImage(payload);
38419
+ return { data: { success: true, user } };
38420
+ } catch (error) {
38421
+ return {
38422
+ error: error instanceof Error ? error.message : String(error),
38423
+ isError: true
38424
+ };
38425
+ }
38426
+ }
38427
+ async function removeAvatar(client) {
38428
+ try {
38429
+ if (!client.currentUserId) {
38430
+ return {
38431
+ error: "Not authenticated. Call dim_login first.",
38432
+ isError: true
38433
+ };
38434
+ }
38435
+ const user = await client.sdk.users.removeAvatar();
38436
+ return { data: { success: true, user } };
38437
+ } catch (error) {
38438
+ return {
38439
+ error: error instanceof Error ? error.message : String(error),
38440
+ isError: true
38441
+ };
38442
+ }
38443
+ }
38444
+ async function removeCoverImage(client) {
38445
+ try {
38446
+ if (!client.currentUserId) {
38447
+ return {
38448
+ error: "Not authenticated. Call dim_login first.",
38449
+ isError: true
38450
+ };
38451
+ }
38452
+ const user = await client.sdk.users.removeCoverImage();
38453
+ return { data: { success: true, user } };
38454
+ } catch (error) {
38455
+ return {
38456
+ error: error instanceof Error ? error.message : String(error),
38457
+ isError: true
38458
+ };
38459
+ }
38460
+ }
38461
+ function getProfileImageRequirements() {
38462
+ return {
38463
+ data: {
38464
+ avatar: {
38465
+ maxFileSizeBytes: MAX_FILE_SIZE_BYTES,
38466
+ maxDimensions: { width: 200, height: 200 },
38467
+ aspectRatio: "1:1",
38468
+ allowedMimeTypes: [...ALLOWED_MIME_TYPES]
38469
+ },
38470
+ cover: {
38471
+ maxFileSizeBytes: MAX_FILE_SIZE_BYTES,
38472
+ maxDimensions: { width: 1200, height: 400 },
38473
+ aspectRatio: "3:1",
38474
+ allowedMimeTypes: [...ALLOWED_MIME_TYPES]
38475
+ }
38476
+ }
38477
+ };
38478
+ }
38479
+ var BIO_MAX_LENGTH = 500;
38480
+ async function setBio(client, args) {
38481
+ try {
38482
+ if (!client.currentUserId) {
38483
+ return {
38484
+ error: "Not authenticated. Call dim_login first.",
38485
+ isError: true
38486
+ };
38487
+ }
38488
+ const { bio } = args;
38489
+ if (typeof bio !== "string") {
38490
+ return { error: "bio must be a string.", isError: true };
38491
+ }
38492
+ if (bio.length > BIO_MAX_LENGTH) {
38493
+ return {
38494
+ error: `Bio must be at most ${BIO_MAX_LENGTH} characters.`,
38495
+ isError: true
38496
+ };
38497
+ }
38498
+ await client.sdk.users.updateProfile({ bio });
38499
+ return { data: { success: true } };
38500
+ } catch (error) {
38501
+ return {
38502
+ error: error instanceof Error ? error.message : String(error),
38503
+ isError: true
38504
+ };
38505
+ }
38506
+ }
38507
+
38155
38508
  // ../dim-agent-core/src/tools/users.ts
38156
38509
  function formatMinor(m) {
38157
38510
  if (m == null) return "\u2014";
@@ -38244,6 +38597,70 @@ var TOOL_DEFINITIONS = [
38244
38597
  },
38245
38598
  execute: (c, a) => setUsername(c, a)
38246
38599
  },
38600
+ {
38601
+ name: "dim_upload_avatar",
38602
+ description: "Upload a profile avatar image. Provide filePath (path to image file in workspace) or imageUrl (URL to fetch image from). Max 5MB; allowed types: JPEG, PNG, WebP, GIF. Use dim_get_profile_image_requirements for dimensions.",
38603
+ params: {
38604
+ filePath: {
38605
+ type: "string",
38606
+ description: "Path to image file (under allowed workspace)"
38607
+ },
38608
+ imageUrl: {
38609
+ type: "string",
38610
+ description: "URL of image to fetch and upload"
38611
+ }
38612
+ },
38613
+ execute: (c, a) => uploadAvatar(c, a)
38614
+ },
38615
+ {
38616
+ name: "dim_upload_cover_image",
38617
+ description: "Upload a profile cover/header image. Provide filePath or imageUrl. Max 5MB; allowed types: JPEG, PNG, WebP, GIF. Use dim_get_profile_image_requirements for dimensions.",
38618
+ params: {
38619
+ filePath: {
38620
+ type: "string",
38621
+ description: "Path to image file (under allowed workspace)"
38622
+ },
38623
+ imageUrl: {
38624
+ type: "string",
38625
+ description: "URL of image to fetch and upload"
38626
+ }
38627
+ },
38628
+ execute: (c, a) => uploadCoverImage(
38629
+ c,
38630
+ a
38631
+ )
38632
+ },
38633
+ {
38634
+ name: "dim_remove_avatar",
38635
+ description: "Remove the current profile avatar (reset to default).",
38636
+ params: {},
38637
+ execute: (c) => removeAvatar(c)
38638
+ },
38639
+ {
38640
+ name: "dim_remove_cover_image",
38641
+ description: "Remove the current profile cover/header image (reset to default).",
38642
+ params: {},
38643
+ execute: (c) => removeCoverImage(c)
38644
+ },
38645
+ {
38646
+ name: "dim_get_profile_image_requirements",
38647
+ description: "Get max dimensions, max file size, aspect ratio, and allowed MIME types for avatar and cover images. Use before uploading to validate or choose images.",
38648
+ params: {},
38649
+ execute: async () => getProfileImageRequirements()
38650
+ },
38651
+ {
38652
+ name: "dim_set_bio",
38653
+ description: "Set or update your profile bio. Max 500 characters. No truncation; shorten if over limit.",
38654
+ params: {
38655
+ bio: {
38656
+ type: "string",
38657
+ description: "The new profile bio (max 500 characters)",
38658
+ required: true,
38659
+ max: 500
38660
+ }
38661
+ },
38662
+ execute: (c, a) => setBio(c, a)
38663
+ },
38247
38664
  {
38248
38665
  name: "dim_check_maintenance",
38249
38666
  description: "Check if DIM is in maintenance mode. Call this before other operations to avoid failing with 503; when maintenance is true, inform the user to come back later.",
@@ -39049,12 +39466,12 @@ function getPluginConfig(api) {
39049
39466
  return dimclawEntry?.config ?? null;
39050
39467
  }
39051
39468
  function resolveStorePath(storePath) {
39052
- const expanded = storePath.startsWith("~/") && process.env.HOME ? path.join(process.env.HOME, storePath.slice(2)) : storePath;
39053
- return path.resolve(expanded);
39469
+ const expanded = storePath.startsWith("~/") && process.env.HOME ? path2.join(process.env.HOME, storePath.slice(2)) : storePath;
39470
+ return path2.resolve(expanded);
39054
39471
  }
39055
39472
  async function readWalletFile(storePath) {
39056
39473
  try {
39057
- const raw = await readFile(storePath, "utf8");
39474
+ const raw = await readFile2(storePath, "utf8");
39058
39475
  const parsed = JSON.parse(raw);
39059
39476
  if (parsed.walletPrivateKey && parsed.walletAddress) {
39060
39477
  return {
@@ -39070,7 +39487,7 @@ async function readWalletFile(storePath) {
39070
39487
  }
39071
39488
  }
39072
39489
  async function writeWalletFile(storePath, record2) {
39073
- await mkdir(path.dirname(storePath), { recursive: true });
39490
+ await mkdir(path2.dirname(storePath), { recursive: true });
39074
39491
  const tmp = `${storePath}.tmp`;
39075
39492
  await writeFile(tmp, `${JSON.stringify(record2, null, 2)}
39076
39493
  `, {
@@ -39100,9 +39517,9 @@ async function resolveWalletKey(config) {
39100
39517
  }
39101
39518
  function resolveHeartbeatPath(p) {
39102
39519
  if (p.startsWith("~/") && process.env.HOME) {
39103
- return path.join(process.env.HOME, p.slice(2));
39520
+ return path2.join(process.env.HOME, p.slice(2));
39104
39521
  }
39105
- return path.resolve(p);
39522
+ return path2.resolve(p);
39106
39523
  }
39107
39524
  function createHeartbeatWriter(heartbeatPath) {
39108
39525
  if (!heartbeatPath) return void 0;
@@ -39136,7 +39553,7 @@ function createHeartbeatWriter(heartbeatPath) {
39136
39553
  }
39137
39554
  lines.push("");
39138
39555
  try {
39139
- await mkdir(path.dirname(filePath), { recursive: true });
39556
+ await mkdir(path2.dirname(filePath), { recursive: true });
39140
39557
  const tmp = `${filePath}.tmp`;
39141
39558
  await writeFile(tmp, lines.join("\n"), "utf8");
39142
39559
  await rename(tmp, filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimcool/dimclaw",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
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": {