@okxweb3/a2a-node 0.1.3 → 0.1.4-beta-161afc7833-260702114832

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 (3) hide show
  1. package/dist/cli.js +619 -363
  2. package/dist/index.js +461 -205
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1840,7 +1840,7 @@ var require_path = __commonJS({
1840
1840
  const parts = splitPathRe.exec(truncated);
1841
1841
  return parts ? parts.slice(1) : [];
1842
1842
  }
1843
- function resolve4(...args) {
1843
+ function resolve5(...args) {
1844
1844
  let resolvedPath = "";
1845
1845
  let resolvedAbsolute = false;
1846
1846
  for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
@@ -1876,8 +1876,8 @@ var require_path = __commonJS({
1876
1876
  return arr.slice(start, end - start + 1);
1877
1877
  }
1878
1878
  function relative(from3, to) {
1879
- from3 = resolve4(from3).slice(1);
1880
- to = resolve4(to).slice(1);
1879
+ from3 = resolve5(from3).slice(1);
1880
+ to = resolve5(to).slice(1);
1881
1881
  const fromParts = trim2(from3.split("/"));
1882
1882
  const toParts = trim2(to.split("/"));
1883
1883
  const length2 = Math.min(fromParts.length, toParts.length);
@@ -1913,10 +1913,10 @@ var require_path = __commonJS({
1913
1913
  function isAbsolute2(path) {
1914
1914
  return path.charAt(0) === "/";
1915
1915
  }
1916
- function join20(...args) {
1916
+ function join21(...args) {
1917
1917
  return normalizePath(args.join("/"));
1918
1918
  }
1919
- function dirname6(path) {
1919
+ function dirname7(path) {
1920
1920
  const result = splitPath(path);
1921
1921
  const root = result[0];
1922
1922
  let dir = result[1];
@@ -1936,12 +1936,12 @@ var require_path = __commonJS({
1936
1936
  return f;
1937
1937
  }
1938
1938
  exports2.basename = basename3;
1939
- exports2.dirname = dirname6;
1939
+ exports2.dirname = dirname7;
1940
1940
  exports2.isAbsolute = isAbsolute2;
1941
- exports2.join = join20;
1941
+ exports2.join = join21;
1942
1942
  exports2.normalizePath = normalizePath;
1943
1943
  exports2.relative = relative;
1944
- exports2.resolve = resolve4;
1944
+ exports2.resolve = resolve5;
1945
1945
  }
1946
1946
  });
1947
1947
 
@@ -1960,8 +1960,8 @@ var require_syncpromise = __commonJS({
1960
1960
  States2[States2["REJECTED"] = REJECTED] = "REJECTED";
1961
1961
  })(States || (States = {}));
1962
1962
  function resolvedSyncPromise(value) {
1963
- return new SyncPromise((resolve4) => {
1964
- resolve4(value);
1963
+ return new SyncPromise((resolve5) => {
1964
+ resolve5(value);
1965
1965
  });
1966
1966
  }
1967
1967
  function rejectedSyncPromise(reason) {
@@ -1985,15 +1985,15 @@ var require_syncpromise = __commonJS({
1985
1985
  }
1986
1986
  /** JSDoc */
1987
1987
  then(onfulfilled, onrejected) {
1988
- return new _SyncPromise((resolve4, reject) => {
1988
+ return new _SyncPromise((resolve5, reject) => {
1989
1989
  this._handlers.push([
1990
1990
  false,
1991
1991
  (result) => {
1992
1992
  if (!onfulfilled) {
1993
- resolve4(result);
1993
+ resolve5(result);
1994
1994
  } else {
1995
1995
  try {
1996
- resolve4(onfulfilled(result));
1996
+ resolve5(onfulfilled(result));
1997
1997
  } catch (e) {
1998
1998
  reject(e);
1999
1999
  }
@@ -2004,7 +2004,7 @@ var require_syncpromise = __commonJS({
2004
2004
  reject(reason);
2005
2005
  } else {
2006
2006
  try {
2007
- resolve4(onrejected(reason));
2007
+ resolve5(onrejected(reason));
2008
2008
  } catch (e) {
2009
2009
  reject(e);
2010
2010
  }
@@ -2020,7 +2020,7 @@ var require_syncpromise = __commonJS({
2020
2020
  }
2021
2021
  /** JSDoc */
2022
2022
  finally(onfinally) {
2023
- return new _SyncPromise((resolve4, reject) => {
2023
+ return new _SyncPromise((resolve5, reject) => {
2024
2024
  let val;
2025
2025
  let isRejected;
2026
2026
  return this.then(
@@ -2043,7 +2043,7 @@ var require_syncpromise = __commonJS({
2043
2043
  reject(val);
2044
2044
  return;
2045
2045
  }
2046
- resolve4(val);
2046
+ resolve5(val);
2047
2047
  });
2048
2048
  });
2049
2049
  }
@@ -2133,21 +2133,21 @@ var require_promisebuffer = __commonJS({
2133
2133
  return task;
2134
2134
  }
2135
2135
  function drain(timeout) {
2136
- return new syncpromise.SyncPromise((resolve4, reject) => {
2136
+ return new syncpromise.SyncPromise((resolve5, reject) => {
2137
2137
  let counter = buffer2.length;
2138
2138
  if (!counter) {
2139
- return resolve4(true);
2139
+ return resolve5(true);
2140
2140
  }
2141
2141
  const capturedSetTimeout = setTimeout(() => {
2142
2142
  if (timeout && timeout > 0) {
2143
- resolve4(false);
2143
+ resolve5(false);
2144
2144
  }
2145
2145
  }, timeout);
2146
2146
  buffer2.forEach((item) => {
2147
2147
  void syncpromise.resolvedSyncPromise(item).then(() => {
2148
2148
  if (!--counter) {
2149
2149
  clearTimeout(capturedSetTimeout);
2150
- resolve4(true);
2150
+ resolve5(true);
2151
2151
  }
2152
2152
  }, reject);
2153
2153
  });
@@ -3349,17 +3349,17 @@ var require_eventProcessors = __commonJS({
3349
3349
  getGlobalEventProcessors().push(callback);
3350
3350
  }
3351
3351
  function notifyEventProcessors(processors, event, hint, index2 = 0) {
3352
- return new utils.SyncPromise((resolve4, reject) => {
3352
+ return new utils.SyncPromise((resolve5, reject) => {
3353
3353
  const processor = processors[index2];
3354
3354
  if (event === null || typeof processor !== "function") {
3355
- resolve4(event);
3355
+ resolve5(event);
3356
3356
  } else {
3357
3357
  const result = processor({ ...event }, hint);
3358
3358
  (typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && processor.id && result === null && utils.logger.log(`Event processor "${processor.id}" dropped event`);
3359
3359
  if (utils.isThenable(result)) {
3360
- void result.then((final) => notifyEventProcessors(processors, final, hint, index2 + 1).then(resolve4)).then(null, reject);
3360
+ void result.then((final) => notifyEventProcessors(processors, final, hint, index2 + 1).then(resolve5)).then(null, reject);
3361
3361
  } else {
3362
- void notifyEventProcessors(processors, result, hint, index2 + 1).then(resolve4).then(null, reject);
3362
+ void notifyEventProcessors(processors, result, hint, index2 + 1).then(resolve5).then(null, reject);
3363
3363
  }
3364
3364
  }
3365
3365
  });
@@ -6513,18 +6513,18 @@ var require_baseclient = __commonJS({
6513
6513
  * `false` otherwise
6514
6514
  */
6515
6515
  _isClientDoneProcessing(timeout) {
6516
- return new utils.SyncPromise((resolve4) => {
6516
+ return new utils.SyncPromise((resolve5) => {
6517
6517
  let ticked = 0;
6518
6518
  const tick = 1;
6519
6519
  const interval = setInterval(() => {
6520
6520
  if (this._numProcessing == 0) {
6521
6521
  clearInterval(interval);
6522
- resolve4(true);
6522
+ resolve5(true);
6523
6523
  } else {
6524
6524
  ticked += tick;
6525
6525
  if (timeout && ticked >= timeout) {
6526
6526
  clearInterval(interval);
6527
- resolve4(false);
6527
+ resolve5(false);
6528
6528
  }
6529
6529
  }
6530
6530
  }, tick);
@@ -10939,7 +10939,7 @@ var require_supports_color = __commonJS({
10939
10939
  return 1;
10940
10940
  }
10941
10941
  if ("CI" in env) {
10942
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign2) => sign2 in env) || env.CI_NAME === "codeship") {
10942
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign3) => sign3 in env) || env.CI_NAME === "codeship") {
10943
10943
  return 1;
10944
10944
  }
10945
10945
  return min;
@@ -11174,12 +11174,12 @@ var require_promisify = __commonJS({
11174
11174
  Object.defineProperty(exports2, "__esModule", { value: true });
11175
11175
  function promisify2(fn) {
11176
11176
  return function(req, opts) {
11177
- return new Promise((resolve4, reject) => {
11177
+ return new Promise((resolve5, reject) => {
11178
11178
  fn.call(this, req, opts, (err2, rtn) => {
11179
11179
  if (err2) {
11180
11180
  reject(err2);
11181
11181
  } else {
11182
- resolve4(rtn);
11182
+ resolve5(rtn);
11183
11183
  }
11184
11184
  });
11185
11185
  });
@@ -11383,7 +11383,7 @@ var require_parse_proxy_response = __commonJS({
11383
11383
  var debug_1 = __importDefault(require_src());
11384
11384
  var debug = debug_1.default("https-proxy-agent:parse-proxy-response");
11385
11385
  function parseProxyResponse(socket) {
11386
- return new Promise((resolve4, reject) => {
11386
+ return new Promise((resolve5, reject) => {
11387
11387
  let buffersLength = 0;
11388
11388
  const buffers = [];
11389
11389
  function read2() {
@@ -11423,7 +11423,7 @@ var require_parse_proxy_response = __commonJS({
11423
11423
  const firstLine = buffered.toString("ascii", 0, buffered.indexOf("\r\n"));
11424
11424
  const statusCode = +firstLine.split(" ")[1];
11425
11425
  debug("got proxy server response: %o", firstLine);
11426
- resolve4({
11426
+ resolve5({
11427
11427
  statusCode,
11428
11428
  buffered
11429
11429
  });
@@ -11444,11 +11444,11 @@ var require_agent = __commonJS({
11444
11444
  "use strict";
11445
11445
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
11446
11446
  function adopt(value) {
11447
- return value instanceof P2 ? value : new P2(function(resolve4) {
11448
- resolve4(value);
11447
+ return value instanceof P2 ? value : new P2(function(resolve5) {
11448
+ resolve5(value);
11449
11449
  });
11450
11450
  }
11451
- return new (P2 || (P2 = Promise))(function(resolve4, reject) {
11451
+ return new (P2 || (P2 = Promise))(function(resolve5, reject) {
11452
11452
  function fulfilled(value) {
11453
11453
  try {
11454
11454
  step(generator.next(value));
@@ -11464,7 +11464,7 @@ var require_agent = __commonJS({
11464
11464
  }
11465
11465
  }
11466
11466
  function step(result) {
11467
- result.done ? resolve4(result.value) : adopt(result.value).then(fulfilled, rejected);
11467
+ result.done ? resolve5(result.value) : adopt(result.value).then(fulfilled, rejected);
11468
11468
  }
11469
11469
  step((generator = generator.apply(thisArg, _arguments || [])).next());
11470
11470
  });
@@ -11675,7 +11675,7 @@ var require_http = __commonJS({
11675
11675
  function createRequestExecutor(options, httpModule, agent) {
11676
11676
  const { hostname, pathname, port, protocol, search } = new url.URL(options.url);
11677
11677
  return function makeRequest(request) {
11678
- return new Promise((resolve4, reject) => {
11678
+ return new Promise((resolve5, reject) => {
11679
11679
  let body = streamFromBody(request.body);
11680
11680
  const headers = { ...options.headers };
11681
11681
  if (request.body.length > GZIP_THRESHOLD) {
@@ -11701,7 +11701,7 @@ var require_http = __commonJS({
11701
11701
  res.setEncoding("utf8");
11702
11702
  const retryAfterHeader = _nullishCoalesce(res.headers["retry-after"], () => null);
11703
11703
  const rateLimitsHeader = _nullishCoalesce(res.headers["x-sentry-rate-limits"], () => null);
11704
- resolve4({
11704
+ resolve5({
11705
11705
  statusCode: res.statusCode,
11706
11706
  headers: {
11707
11707
  "retry-after": retryAfterHeader,
@@ -11969,7 +11969,7 @@ var require_websocket = __commonJS({
11969
11969
  };
11970
11970
  async function createWebSocketClient(rawUrl) {
11971
11971
  const parts = url.parse(rawUrl);
11972
- return new Promise((resolve4, reject) => {
11972
+ return new Promise((resolve5, reject) => {
11973
11973
  const key = crypto3.randomBytes(16).toString("base64");
11974
11974
  const digest2 = createKey(key);
11975
11975
  const req = http2.request({
@@ -12000,7 +12000,7 @@ var require_websocket = __commonJS({
12000
12000
  return;
12001
12001
  }
12002
12002
  const client = new WebSocketInterface(socket);
12003
- resolve4(client);
12003
+ resolve5(client);
12004
12004
  });
12005
12005
  req.on("error", (err2) => {
12006
12006
  reject(err2);
@@ -13329,10 +13329,10 @@ var require_contextlines = __commonJS({
13329
13329
  var FILE_CONTENT_CACHE = new lru_map.LRUMap(100);
13330
13330
  var DEFAULT_LINES_OF_CONTEXT = 7;
13331
13331
  function readTextFileAsync(path) {
13332
- return new Promise((resolve4, reject) => {
13332
+ return new Promise((resolve5, reject) => {
13333
13333
  fs.readFile(path, "utf8", (err2, data) => {
13334
13334
  if (err2) reject(err2);
13335
- else resolve4(data);
13335
+ else resolve5(data);
13336
13336
  });
13337
13337
  });
13338
13338
  }
@@ -13642,13 +13642,13 @@ var require_context = __commonJS({
13642
13642
  version: `10.${Number(os.release().split(".")[0]) - 4}`
13643
13643
  };
13644
13644
  try {
13645
- const output = await new Promise((resolve4, reject) => {
13645
+ const output = await new Promise((resolve5, reject) => {
13646
13646
  child_process.execFile("/usr/bin/sw_vers", (error, stdout) => {
13647
13647
  if (error) {
13648
13648
  reject(error);
13649
13649
  return;
13650
13650
  }
13651
- resolve4(stdout);
13651
+ resolve5(stdout);
13652
13652
  });
13653
13653
  });
13654
13654
  darwinInfo.name = matchFirst(/^ProductName:\s+(.*)$/m, output);
@@ -18753,8 +18753,8 @@ var require_util2 = __commonJS({
18753
18753
  function createDeferredPromise() {
18754
18754
  let res;
18755
18755
  let rej;
18756
- const promise = new Promise((resolve4, reject) => {
18757
- res = resolve4;
18756
+ const promise = new Promise((resolve5, reject) => {
18757
+ res = resolve5;
18758
18758
  rej = reject;
18759
18759
  });
18760
18760
  return { promise, resolve: res, reject: rej };
@@ -20258,8 +20258,8 @@ Content-Type: ${value.type || "application/octet-stream"}\r
20258
20258
  });
20259
20259
  }
20260
20260
  });
20261
- const busboyResolve = new Promise((resolve4, reject) => {
20262
- busboy.on("finish", resolve4);
20261
+ const busboyResolve = new Promise((resolve5, reject) => {
20262
+ busboy.on("finish", resolve5);
20263
20263
  busboy.on("error", (err2) => reject(new TypeError(err2)));
20264
20264
  });
20265
20265
  if (this.body !== null) for await (const chunk of consumeBody(this[kState].body)) busboy.write(chunk);
@@ -20793,9 +20793,9 @@ var require_dispatcher_base = __commonJS({
20793
20793
  }
20794
20794
  close(callback) {
20795
20795
  if (callback === void 0) {
20796
- return new Promise((resolve4, reject) => {
20796
+ return new Promise((resolve5, reject) => {
20797
20797
  this.close((err2, data) => {
20798
- return err2 ? reject(err2) : resolve4(data);
20798
+ return err2 ? reject(err2) : resolve5(data);
20799
20799
  });
20800
20800
  });
20801
20801
  }
@@ -20833,12 +20833,12 @@ var require_dispatcher_base = __commonJS({
20833
20833
  err2 = null;
20834
20834
  }
20835
20835
  if (callback === void 0) {
20836
- return new Promise((resolve4, reject) => {
20836
+ return new Promise((resolve5, reject) => {
20837
20837
  this.destroy(err2, (err3, data) => {
20838
20838
  return err3 ? (
20839
20839
  /* istanbul ignore next: should never error */
20840
20840
  reject(err3)
20841
- ) : resolve4(data);
20841
+ ) : resolve5(data);
20842
20842
  });
20843
20843
  });
20844
20844
  }
@@ -21898,16 +21898,16 @@ var require_client2 = __commonJS({
21898
21898
  return this[kNeedDrain] < 2;
21899
21899
  }
21900
21900
  async [kClose]() {
21901
- return new Promise((resolve4) => {
21901
+ return new Promise((resolve5) => {
21902
21902
  if (!this[kSize]) {
21903
- resolve4(null);
21903
+ resolve5(null);
21904
21904
  } else {
21905
- this[kClosedResolve] = resolve4;
21905
+ this[kClosedResolve] = resolve5;
21906
21906
  }
21907
21907
  });
21908
21908
  }
21909
21909
  async [kDestroy](err2) {
21910
- return new Promise((resolve4) => {
21910
+ return new Promise((resolve5) => {
21911
21911
  const requests = this[kQueue].splice(this[kPendingIdx]);
21912
21912
  for (let i = 0; i < requests.length; i++) {
21913
21913
  const request = requests[i];
@@ -21918,7 +21918,7 @@ var require_client2 = __commonJS({
21918
21918
  this[kClosedResolve]();
21919
21919
  this[kClosedResolve] = null;
21920
21920
  }
21921
- resolve4();
21921
+ resolve5();
21922
21922
  };
21923
21923
  if (this[kHTTP2Session] != null) {
21924
21924
  util.destroy(this[kHTTP2Session], err2);
@@ -22498,7 +22498,7 @@ var require_client2 = __commonJS({
22498
22498
  });
22499
22499
  }
22500
22500
  try {
22501
- const socket = await new Promise((resolve4, reject) => {
22501
+ const socket = await new Promise((resolve5, reject) => {
22502
22502
  client[kConnector]({
22503
22503
  host,
22504
22504
  hostname,
@@ -22510,7 +22510,7 @@ var require_client2 = __commonJS({
22510
22510
  if (err2) {
22511
22511
  reject(err2);
22512
22512
  } else {
22513
- resolve4(socket2);
22513
+ resolve5(socket2);
22514
22514
  }
22515
22515
  });
22516
22516
  });
@@ -23134,12 +23134,12 @@ upgrade: ${upgrade}\r
23134
23134
  cb();
23135
23135
  }
23136
23136
  }
23137
- const waitForDrain = () => new Promise((resolve4, reject) => {
23137
+ const waitForDrain = () => new Promise((resolve5, reject) => {
23138
23138
  assert(callback === null);
23139
23139
  if (socket[kError]) {
23140
23140
  reject(socket[kError]);
23141
23141
  } else {
23142
- callback = resolve4;
23142
+ callback = resolve5;
23143
23143
  }
23144
23144
  });
23145
23145
  if (client[kHTTPConnVersion] === "h2") {
@@ -23484,8 +23484,8 @@ var require_pool_base = __commonJS({
23484
23484
  if (this[kQueue].isEmpty()) {
23485
23485
  return Promise.all(this[kClients].map((c) => c.close()));
23486
23486
  } else {
23487
- return new Promise((resolve4) => {
23488
- this[kClosedResolve] = resolve4;
23487
+ return new Promise((resolve5) => {
23488
+ this[kClosedResolve] = resolve5;
23489
23489
  });
23490
23490
  }
23491
23491
  }
@@ -24063,7 +24063,7 @@ var require_readable = __commonJS({
24063
24063
  if (this.closed) {
24064
24064
  return Promise.resolve(null);
24065
24065
  }
24066
- return new Promise((resolve4, reject) => {
24066
+ return new Promise((resolve5, reject) => {
24067
24067
  const signalListenerCleanup = signal ? util.addAbortListener(signal, () => {
24068
24068
  this.destroy();
24069
24069
  }) : noop;
@@ -24072,7 +24072,7 @@ var require_readable = __commonJS({
24072
24072
  if (signal && signal.aborted) {
24073
24073
  reject(signal.reason || Object.assign(new Error("The operation was aborted"), { name: "AbortError" }));
24074
24074
  } else {
24075
- resolve4(null);
24075
+ resolve5(null);
24076
24076
  }
24077
24077
  }).on("error", noop).on("data", function(chunk) {
24078
24078
  limit -= chunk.length;
@@ -24094,11 +24094,11 @@ var require_readable = __commonJS({
24094
24094
  throw new TypeError("unusable");
24095
24095
  }
24096
24096
  assert(!stream[kConsume]);
24097
- return new Promise((resolve4, reject) => {
24097
+ return new Promise((resolve5, reject) => {
24098
24098
  stream[kConsume] = {
24099
24099
  type,
24100
24100
  stream,
24101
- resolve: resolve4,
24101
+ resolve: resolve5,
24102
24102
  reject,
24103
24103
  length: 0,
24104
24104
  body: []
@@ -24133,12 +24133,12 @@ var require_readable = __commonJS({
24133
24133
  }
24134
24134
  }
24135
24135
  function consumeEnd(consume2) {
24136
- const { type, body, resolve: resolve4, stream, length: length2 } = consume2;
24136
+ const { type, body, resolve: resolve5, stream, length: length2 } = consume2;
24137
24137
  try {
24138
24138
  if (type === "text") {
24139
- resolve4(toUSVString(Buffer.concat(body)));
24139
+ resolve5(toUSVString(Buffer.concat(body)));
24140
24140
  } else if (type === "json") {
24141
- resolve4(JSON.parse(Buffer.concat(body)));
24141
+ resolve5(JSON.parse(Buffer.concat(body)));
24142
24142
  } else if (type === "arrayBuffer") {
24143
24143
  const dst = new Uint8Array(length2);
24144
24144
  let pos = 0;
@@ -24146,12 +24146,12 @@ var require_readable = __commonJS({
24146
24146
  dst.set(buf, pos);
24147
24147
  pos += buf.byteLength;
24148
24148
  }
24149
- resolve4(dst.buffer);
24149
+ resolve5(dst.buffer);
24150
24150
  } else if (type === "blob") {
24151
24151
  if (!Blob2) {
24152
24152
  Blob2 = require("buffer").Blob;
24153
24153
  }
24154
- resolve4(new Blob2(body, { type: stream[kContentType] }));
24154
+ resolve5(new Blob2(body, { type: stream[kContentType] }));
24155
24155
  }
24156
24156
  consumeFinish(consume2);
24157
24157
  } catch (err2) {
@@ -24406,9 +24406,9 @@ var require_api_request = __commonJS({
24406
24406
  };
24407
24407
  function request(opts, callback) {
24408
24408
  if (callback === void 0) {
24409
- return new Promise((resolve4, reject) => {
24409
+ return new Promise((resolve5, reject) => {
24410
24410
  request.call(this, opts, (err2, data) => {
24411
- return err2 ? reject(err2) : resolve4(data);
24411
+ return err2 ? reject(err2) : resolve5(data);
24412
24412
  });
24413
24413
  });
24414
24414
  }
@@ -24581,9 +24581,9 @@ var require_api_stream = __commonJS({
24581
24581
  };
24582
24582
  function stream(opts, factory, callback) {
24583
24583
  if (callback === void 0) {
24584
- return new Promise((resolve4, reject) => {
24584
+ return new Promise((resolve5, reject) => {
24585
24585
  stream.call(this, opts, factory, (err2, data) => {
24586
- return err2 ? reject(err2) : resolve4(data);
24586
+ return err2 ? reject(err2) : resolve5(data);
24587
24587
  });
24588
24588
  });
24589
24589
  }
@@ -24864,9 +24864,9 @@ var require_api_upgrade = __commonJS({
24864
24864
  };
24865
24865
  function upgrade(opts, callback) {
24866
24866
  if (callback === void 0) {
24867
- return new Promise((resolve4, reject) => {
24867
+ return new Promise((resolve5, reject) => {
24868
24868
  upgrade.call(this, opts, (err2, data) => {
24869
- return err2 ? reject(err2) : resolve4(data);
24869
+ return err2 ? reject(err2) : resolve5(data);
24870
24870
  });
24871
24871
  });
24872
24872
  }
@@ -24955,9 +24955,9 @@ var require_api_connect = __commonJS({
24955
24955
  };
24956
24956
  function connect(opts, callback) {
24957
24957
  if (callback === void 0) {
24958
- return new Promise((resolve4, reject) => {
24958
+ return new Promise((resolve5, reject) => {
24959
24959
  connect.call(this, opts, (err2, data) => {
24960
- return err2 ? reject(err2) : resolve4(data);
24960
+ return err2 ? reject(err2) : resolve5(data);
24961
24961
  });
24962
24962
  });
24963
24963
  }
@@ -28579,7 +28579,7 @@ var require_fetch = __commonJS({
28579
28579
  async function dispatch({ body }) {
28580
28580
  const url = requestCurrentURL(request);
28581
28581
  const agent = fetchParams.controller.dispatcher;
28582
- return new Promise((resolve4, reject) => agent.dispatch(
28582
+ return new Promise((resolve5, reject) => agent.dispatch(
28583
28583
  {
28584
28584
  path: url.pathname + url.search,
28585
28585
  origin: url.origin,
@@ -28655,7 +28655,7 @@ var require_fetch = __commonJS({
28655
28655
  }
28656
28656
  }
28657
28657
  }
28658
- resolve4({
28658
+ resolve5({
28659
28659
  status,
28660
28660
  statusText,
28661
28661
  headersList: headers[kHeadersList],
@@ -28698,7 +28698,7 @@ var require_fetch = __commonJS({
28698
28698
  const val = headersList[n + 1].toString("latin1");
28699
28699
  headers[kHeadersList].append(key, val);
28700
28700
  }
28701
- resolve4({
28701
+ resolve5({
28702
28702
  status,
28703
28703
  statusText: STATUS_CODES[status],
28704
28704
  headersList: headers[kHeadersList],
@@ -32025,11 +32025,11 @@ var require_fetch_pb = __commonJS({
32025
32025
  "use strict";
32026
32026
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
32027
32027
  function adopt(value) {
32028
- return value instanceof P2 ? value : new P2(function(resolve4) {
32029
- resolve4(value);
32028
+ return value instanceof P2 ? value : new P2(function(resolve5) {
32029
+ resolve5(value);
32030
32030
  });
32031
32031
  }
32032
- return new (P2 || (P2 = Promise))(function(resolve4, reject) {
32032
+ return new (P2 || (P2 = Promise))(function(resolve5, reject) {
32033
32033
  function fulfilled(value) {
32034
32034
  try {
32035
32035
  step(generator.next(value));
@@ -32045,7 +32045,7 @@ var require_fetch_pb = __commonJS({
32045
32045
  }
32046
32046
  }
32047
32047
  function step(result) {
32048
- result.done ? resolve4(result.value) : adopt(result.value).then(fulfilled, rejected);
32048
+ result.done ? resolve5(result.value) : adopt(result.value).then(fulfilled, rejected);
32049
32049
  }
32050
32050
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32051
32051
  });
@@ -33315,7 +33315,7 @@ var require_aspromise = __commonJS({
33315
33315
  var params = new Array(arguments.length - 1), offset = 0, index2 = 2, pending = true;
33316
33316
  while (index2 < arguments.length)
33317
33317
  params[offset++] = arguments[index2++];
33318
- return new Promise(function executor(resolve4, reject) {
33318
+ return new Promise(function executor(resolve5, reject) {
33319
33319
  params[offset] = function callback(err2) {
33320
33320
  if (pending) {
33321
33321
  pending = false;
@@ -33325,7 +33325,7 @@ var require_aspromise = __commonJS({
33325
33325
  var params2 = new Array(arguments.length - 1), offset2 = 0;
33326
33326
  while (offset2 < params2.length)
33327
33327
  params2[offset2++] = arguments[offset2];
33328
- resolve4.apply(null, params2);
33328
+ resolve5.apply(null, params2);
33329
33329
  }
33330
33330
  }
33331
33331
  };
@@ -33531,8 +33531,8 @@ var require_float = __commonJS({
33531
33531
  })();
33532
33532
  else (function() {
33533
33533
  function writeFloat_ieee754(writeUint, val, buf, pos) {
33534
- var sign2 = val < 0 ? 1 : 0;
33535
- if (sign2)
33534
+ var sign3 = val < 0 ? 1 : 0;
33535
+ if (sign3)
33536
33536
  val = -val;
33537
33537
  if (val === 0)
33538
33538
  writeUint(1 / val > 0 ? (
@@ -33545,19 +33545,19 @@ var require_float = __commonJS({
33545
33545
  else if (isNaN(val))
33546
33546
  writeUint(2143289344, buf, pos);
33547
33547
  else if (val > 34028234663852886e22)
33548
- writeUint((sign2 << 31 | 2139095040) >>> 0, buf, pos);
33548
+ writeUint((sign3 << 31 | 2139095040) >>> 0, buf, pos);
33549
33549
  else if (val < 11754943508222875e-54)
33550
- writeUint((sign2 << 31 | Math.round(val / 1401298464324817e-60)) >>> 0, buf, pos);
33550
+ writeUint((sign3 << 31 | Math.round(val / 1401298464324817e-60)) >>> 0, buf, pos);
33551
33551
  else {
33552
33552
  var exponent = Math.floor(Math.log(val) / Math.LN2), mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
33553
- writeUint((sign2 << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
33553
+ writeUint((sign3 << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
33554
33554
  }
33555
33555
  }
33556
33556
  exports3.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
33557
33557
  exports3.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
33558
33558
  function readFloat_ieee754(readUint, buf, pos) {
33559
- var uint = readUint(buf, pos), sign2 = (uint >> 31) * 2 + 1, exponent = uint >>> 23 & 255, mantissa = uint & 8388607;
33560
- return exponent === 255 ? mantissa ? NaN : sign2 * Infinity : exponent === 0 ? sign2 * 1401298464324817e-60 * mantissa : sign2 * Math.pow(2, exponent - 150) * (mantissa + 8388608);
33559
+ var uint = readUint(buf, pos), sign3 = (uint >> 31) * 2 + 1, exponent = uint >>> 23 & 255, mantissa = uint & 8388607;
33560
+ return exponent === 255 ? mantissa ? NaN : sign3 * Infinity : exponent === 0 ? sign3 * 1401298464324817e-60 * mantissa : sign3 * Math.pow(2, exponent - 150) * (mantissa + 8388608);
33561
33561
  }
33562
33562
  exports3.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
33563
33563
  exports3.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
@@ -33615,8 +33615,8 @@ var require_float = __commonJS({
33615
33615
  })();
33616
33616
  else (function() {
33617
33617
  function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
33618
- var sign2 = val < 0 ? 1 : 0;
33619
- if (sign2)
33618
+ var sign3 = val < 0 ? 1 : 0;
33619
+ if (sign3)
33620
33620
  val = -val;
33621
33621
  if (val === 0) {
33622
33622
  writeUint(0, buf, pos + off0);
@@ -33632,20 +33632,20 @@ var require_float = __commonJS({
33632
33632
  writeUint(2146959360, buf, pos + off1);
33633
33633
  } else if (val > 17976931348623157e292) {
33634
33634
  writeUint(0, buf, pos + off0);
33635
- writeUint((sign2 << 31 | 2146435072) >>> 0, buf, pos + off1);
33635
+ writeUint((sign3 << 31 | 2146435072) >>> 0, buf, pos + off1);
33636
33636
  } else {
33637
33637
  var mantissa;
33638
33638
  if (val < 22250738585072014e-324) {
33639
33639
  mantissa = val / 5e-324;
33640
33640
  writeUint(mantissa >>> 0, buf, pos + off0);
33641
- writeUint((sign2 << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
33641
+ writeUint((sign3 << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
33642
33642
  } else {
33643
33643
  var exponent = Math.floor(Math.log(val) / Math.LN2);
33644
33644
  if (exponent === 1024)
33645
33645
  exponent = 1023;
33646
33646
  mantissa = val * Math.pow(2, -exponent);
33647
33647
  writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
33648
- writeUint((sign2 << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
33648
+ writeUint((sign3 << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
33649
33649
  }
33650
33650
  }
33651
33651
  }
@@ -33653,8 +33653,8 @@ var require_float = __commonJS({
33653
33653
  exports3.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
33654
33654
  function readDouble_ieee754(readUint, off0, off1, buf, pos) {
33655
33655
  var lo = readUint(buf, pos + off0), hi = readUint(buf, pos + off1);
33656
- var sign2 = (hi >> 31) * 2 + 1, exponent = hi >>> 20 & 2047, mantissa = 4294967296 * (hi & 1048575) + lo;
33657
- return exponent === 2047 ? mantissa ? NaN : sign2 * Infinity : exponent === 0 ? sign2 * 5e-324 * mantissa : sign2 * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
33656
+ var sign3 = (hi >> 31) * 2 + 1, exponent = hi >>> 20 & 2047, mantissa = 4294967296 * (hi & 1048575) + lo;
33657
+ return exponent === 2047 ? mantissa ? NaN : sign3 * Infinity : exponent === 0 ? sign3 * 5e-324 * mantissa : sign3 * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
33658
33658
  }
33659
33659
  exports3.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
33660
33660
  exports3.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
@@ -33826,11 +33826,11 @@ var require_longbits = __commonJS({
33826
33826
  LongBits.fromNumber = function fromNumber(value) {
33827
33827
  if (value === 0)
33828
33828
  return zero;
33829
- var sign2 = value < 0;
33830
- if (sign2)
33829
+ var sign3 = value < 0;
33830
+ if (sign3)
33831
33831
  value = -value;
33832
33832
  var lo = value >>> 0, hi = (value - lo) / 4294967296 >>> 0;
33833
- if (sign2) {
33833
+ if (sign3) {
33834
33834
  hi = ~hi >>> 0;
33835
33835
  lo = ~lo >>> 0;
33836
33836
  if (++lo > 4294967295) {
@@ -42781,7 +42781,7 @@ var require_Observable = __commonJS({
42781
42781
  Observable2.prototype.forEach = function(next, promiseCtor) {
42782
42782
  var _this = this;
42783
42783
  promiseCtor = getPromiseCtor(promiseCtor);
42784
- return new promiseCtor(function(resolve4, reject) {
42784
+ return new promiseCtor(function(resolve5, reject) {
42785
42785
  var subscriber = new Subscriber_1.SafeSubscriber({
42786
42786
  next: function(value) {
42787
42787
  try {
@@ -42792,7 +42792,7 @@ var require_Observable = __commonJS({
42792
42792
  }
42793
42793
  },
42794
42794
  error: reject,
42795
- complete: resolve4
42795
+ complete: resolve5
42796
42796
  });
42797
42797
  _this.subscribe(subscriber);
42798
42798
  });
@@ -42814,14 +42814,14 @@ var require_Observable = __commonJS({
42814
42814
  Observable2.prototype.toPromise = function(promiseCtor) {
42815
42815
  var _this = this;
42816
42816
  promiseCtor = getPromiseCtor(promiseCtor);
42817
- return new promiseCtor(function(resolve4, reject) {
42817
+ return new promiseCtor(function(resolve5, reject) {
42818
42818
  var value;
42819
42819
  _this.subscribe(function(x) {
42820
42820
  return value = x;
42821
42821
  }, function(err2) {
42822
42822
  return reject(err2);
42823
42823
  }, function() {
42824
- return resolve4(value);
42824
+ return resolve5(value);
42825
42825
  });
42826
42826
  });
42827
42827
  };
@@ -43082,11 +43082,11 @@ var require_innerFrom = __commonJS({
43082
43082
  "use strict";
43083
43083
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
43084
43084
  function adopt(value) {
43085
- return value instanceof P2 ? value : new P2(function(resolve4) {
43086
- resolve4(value);
43085
+ return value instanceof P2 ? value : new P2(function(resolve5) {
43086
+ resolve5(value);
43087
43087
  });
43088
43088
  }
43089
- return new (P2 || (P2 = Promise))(function(resolve4, reject) {
43089
+ return new (P2 || (P2 = Promise))(function(resolve5, reject) {
43090
43090
  function fulfilled(value) {
43091
43091
  try {
43092
43092
  step(generator.next(value));
@@ -43102,7 +43102,7 @@ var require_innerFrom = __commonJS({
43102
43102
  }
43103
43103
  }
43104
43104
  function step(result) {
43105
- result.done ? resolve4(result.value) : adopt(result.value).then(fulfilled, rejected);
43105
+ result.done ? resolve5(result.value) : adopt(result.value).then(fulfilled, rejected);
43106
43106
  }
43107
43107
  step((generator = generator.apply(thisArg, _arguments || [])).next());
43108
43108
  });
@@ -43184,14 +43184,14 @@ var require_innerFrom = __commonJS({
43184
43184
  }, i);
43185
43185
  function verb(n) {
43186
43186
  i[n] = o[n] && function(v) {
43187
- return new Promise(function(resolve4, reject) {
43188
- v = o[n](v), settle(resolve4, reject, v.done, v.value);
43187
+ return new Promise(function(resolve5, reject) {
43188
+ v = o[n](v), settle(resolve5, reject, v.done, v.value);
43189
43189
  });
43190
43190
  };
43191
43191
  }
43192
- function settle(resolve4, reject, d, v) {
43192
+ function settle(resolve5, reject, d, v) {
43193
43193
  Promise.resolve(v).then(function(v2) {
43194
- resolve4({ value: v2, done: d });
43194
+ resolve5({ value: v2, done: d });
43195
43195
  }, reject);
43196
43196
  }
43197
43197
  };
@@ -61992,7 +61992,7 @@ function weierstrass(curveDef) {
61992
61992
  }
61993
61993
  const defaultSigOpts = { lowS: CURVE.lowS, prehash: false };
61994
61994
  const defaultVerOpts = { lowS: CURVE.lowS, prehash: false };
61995
- function sign2(msgHash, privKey, opts = defaultSigOpts) {
61995
+ function sign3(msgHash, privKey, opts = defaultSigOpts) {
61996
61996
  const { seed, k2sig } = prepSig(msgHash, privKey, opts);
61997
61997
  const C2 = CURVE;
61998
61998
  const drbg = createHmacDrbg(C2.hash.outputLen, C2.nByteLength, C2.hmac);
@@ -62054,7 +62054,7 @@ function weierstrass(curveDef) {
62054
62054
  CURVE,
62055
62055
  getPublicKey,
62056
62056
  getSharedSecret,
62057
- sign: sign2,
62057
+ sign: sign3,
62058
62058
  verify,
62059
62059
  ProjectivePoint: Point3,
62060
62060
  Signature,
@@ -64129,13 +64129,13 @@ var init_transactionRequest = __esm({
64129
64129
 
64130
64130
  // ../../node_modules/viem/_esm/utils/promise/withResolvers.js
64131
64131
  function withResolvers() {
64132
- let resolve4 = () => void 0;
64132
+ let resolve5 = () => void 0;
64133
64133
  let reject = () => void 0;
64134
64134
  const promise = new Promise((resolve_, reject_) => {
64135
- resolve4 = resolve_;
64135
+ resolve5 = resolve_;
64136
64136
  reject = reject_;
64137
64137
  });
64138
- return { promise, resolve: resolve4, reject };
64138
+ return { promise, resolve: resolve5, reject };
64139
64139
  }
64140
64140
  var init_withResolvers = __esm({
64141
64141
  "../../node_modules/viem/_esm/utils/promise/withResolvers.js"() {
@@ -64154,8 +64154,8 @@ function createBatchScheduler({ fn, id, shouldSplitBatch, wait: wait3 = 0, sort
64154
64154
  if (sort && Array.isArray(data))
64155
64155
  data.sort(sort);
64156
64156
  for (let i = 0; i < scheduler.length; i++) {
64157
- const { resolve: resolve4 } = scheduler[i];
64158
- resolve4?.([data[i], data]);
64157
+ const { resolve: resolve5 } = scheduler[i];
64158
+ resolve5?.([data[i], data]);
64159
64159
  }
64160
64160
  }).catch((err2) => {
64161
64161
  for (let i = 0; i < scheduler.length; i++) {
@@ -64171,16 +64171,16 @@ function createBatchScheduler({ fn, id, shouldSplitBatch, wait: wait3 = 0, sort
64171
64171
  return {
64172
64172
  flush: flush2,
64173
64173
  async schedule(args) {
64174
- const { promise, resolve: resolve4, reject } = withResolvers();
64174
+ const { promise, resolve: resolve5, reject } = withResolvers();
64175
64175
  const split2 = shouldSplitBatch?.([...getBatchedArgs(), args]);
64176
64176
  if (split2)
64177
64177
  exec2();
64178
64178
  const hasActiveScheduler = getScheduler().length > 0;
64179
64179
  if (hasActiveScheduler) {
64180
- setScheduler({ args, resolve: resolve4, reject });
64180
+ setScheduler({ args, resolve: resolve5, reject });
64181
64181
  return promise;
64182
64182
  }
64183
- setScheduler({ args, resolve: resolve4, reject });
64183
+ setScheduler({ args, resolve: resolve5, reject });
64184
64184
  setTimeout(exec2, wait3);
64185
64185
  return promise;
64186
64186
  }
@@ -66482,7 +66482,7 @@ var require_websocket3 = __commonJS({
66482
66482
  var http2 = require("http");
66483
66483
  var net = require("net");
66484
66484
  var tls = require("tls");
66485
- var { randomBytes: randomBytes3, createHash: createHash3 } = require("crypto");
66485
+ var { randomBytes: randomBytes3, createHash: createHash4 } = require("crypto");
66486
66486
  var { Duplex, Readable } = require("stream");
66487
66487
  var { URL: URL2 } = require("url");
66488
66488
  var PerMessageDeflate = require_permessage_deflate();
@@ -67142,7 +67142,7 @@ var require_websocket3 = __commonJS({
67142
67142
  abortHandshake(websocket, socket, "Invalid Upgrade header");
67143
67143
  return;
67144
67144
  }
67145
- const digest2 = createHash3("sha1").update(key + GUID).digest("base64");
67145
+ const digest2 = createHash4("sha1").update(key + GUID).digest("base64");
67146
67146
  if (res.headers["sec-websocket-accept"] !== digest2) {
67147
67147
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
67148
67148
  return;
@@ -67509,7 +67509,7 @@ var require_websocket_server = __commonJS({
67509
67509
  var EventEmitter2 = require("events");
67510
67510
  var http2 = require("http");
67511
67511
  var { Duplex } = require("stream");
67512
- var { createHash: createHash3 } = require("crypto");
67512
+ var { createHash: createHash4 } = require("crypto");
67513
67513
  var extension = require_extension();
67514
67514
  var PerMessageDeflate = require_permessage_deflate();
67515
67515
  var subprotocol = require_subprotocol();
@@ -67810,7 +67810,7 @@ var require_websocket_server = __commonJS({
67810
67810
  );
67811
67811
  }
67812
67812
  if (this._state > RUNNING) return abortHandshake(socket, 503);
67813
- const digest2 = createHash3("sha1").update(key + GUID).digest("base64");
67813
+ const digest2 = createHash4("sha1").update(key + GUID).digest("base64");
67814
67814
  const headers = [
67815
67815
  "HTTP/1.1 101 Switching Protocols",
67816
67816
  "Upgrade: websocket",
@@ -69813,15 +69813,15 @@ async function ensureAiWorkspace(paths) {
69813
69813
  return aiWorkingDir;
69814
69814
  }
69815
69815
  async function waitForImmediateExit(child, timeoutMs) {
69816
- return await new Promise((resolve4) => {
69816
+ return await new Promise((resolve5) => {
69817
69817
  let timer;
69818
69818
  const onExit = () => {
69819
69819
  clearTimeout(timer);
69820
- resolve4(true);
69820
+ resolve5(true);
69821
69821
  };
69822
69822
  timer = setTimeout(() => {
69823
69823
  child.off("exit", onExit);
69824
- resolve4(false);
69824
+ resolve5(false);
69825
69825
  }, timeoutMs);
69826
69826
  child.once("exit", onExit);
69827
69827
  });
@@ -69954,7 +69954,7 @@ async function waitForExit(pid, timeoutMs) {
69954
69954
  if (!isProcessAlive(pid)) {
69955
69955
  return true;
69956
69956
  }
69957
- await new Promise((resolve4) => setTimeout(resolve4, 100));
69957
+ await new Promise((resolve5) => setTimeout(resolve5, 100));
69958
69958
  }
69959
69959
  return !isProcessAlive(pid);
69960
69960
  }
@@ -70127,7 +70127,7 @@ function readReadyTimeoutMs(env) {
70127
70127
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_READY_TIMEOUT_MS;
70128
70128
  }
70129
70129
  function sleep(ms) {
70130
- return new Promise((resolve4) => setTimeout(resolve4, ms));
70130
+ return new Promise((resolve5) => setTimeout(resolve5, ms));
70131
70131
  }
70132
70132
 
70133
70133
  // ../core/src/log.ts
@@ -71296,7 +71296,7 @@ async function promptForAiProviderWithArrows(options) {
71296
71296
  options.stdin.resume();
71297
71297
  options.stdout.write("\x1B[?25l");
71298
71298
  render();
71299
- return await new Promise((resolve4, reject) => {
71299
+ return await new Promise((resolve5, reject) => {
71300
71300
  const cleanup = () => {
71301
71301
  options.stdin.off("keypress", onKeypress);
71302
71302
  options.stdin.setRawMode(false);
@@ -71315,7 +71315,7 @@ async function promptForAiProviderWithArrows(options) {
71315
71315
  clearRendered();
71316
71316
  options.stdout.write(`Selected AI provider: ${provider}
71317
71317
  `);
71318
- resolve4(provider);
71318
+ resolve5(provider);
71319
71319
  };
71320
71320
  const onKeypress = (_str, key) => {
71321
71321
  if (key.ctrl && key.name === "c") {
@@ -72185,9 +72185,9 @@ async function runAiAdapter(options) {
72185
72185
  }, 5e3).unref();
72186
72186
  }, timeoutMs);
72187
72187
  timeout?.unref();
72188
- const exitCode = await new Promise((resolve4, reject) => {
72188
+ const exitCode = await new Promise((resolve5, reject) => {
72189
72189
  child.once("error", reject);
72190
- child.once("close", (code2) => resolve4(code2));
72190
+ child.once("close", (code2) => resolve5(code2));
72191
72191
  });
72192
72192
  if (timeout) {
72193
72193
  clearTimeout(timeout);
@@ -72433,14 +72433,14 @@ async function startUserAttentionEventServer(options = {}) {
72433
72433
  }
72434
72434
  }
72435
72435
  }
72436
- await new Promise((resolve4, reject) => {
72436
+ await new Promise((resolve5, reject) => {
72437
72437
  const onError = (err2) => {
72438
72438
  server.off("listening", onListening);
72439
72439
  reject(err2);
72440
72440
  };
72441
72441
  const onListening = () => {
72442
72442
  server.off("error", onError);
72443
- resolve4();
72443
+ resolve5();
72444
72444
  };
72445
72445
  server.once("error", onError);
72446
72446
  server.once("listening", onListening);
@@ -72455,7 +72455,7 @@ async function startUserAttentionEventServer(options = {}) {
72455
72455
  for (const socket of sockets) {
72456
72456
  socket.destroy();
72457
72457
  }
72458
- return new Promise((resolve4, reject) => {
72458
+ return new Promise((resolve5, reject) => {
72459
72459
  server.close((err2) => {
72460
72460
  if (process.platform !== "win32") {
72461
72461
  try {
@@ -72466,7 +72466,7 @@ async function startUserAttentionEventServer(options = {}) {
72466
72466
  if (err2) {
72467
72467
  reject(err2);
72468
72468
  } else {
72469
- resolve4();
72469
+ resolve5();
72470
72470
  }
72471
72471
  });
72472
72472
  });
@@ -72475,7 +72475,7 @@ async function startUserAttentionEventServer(options = {}) {
72475
72475
  }
72476
72476
  async function subscribeUserAttentionEvents(options) {
72477
72477
  const path = resolveUserAttentionIpcPath(options.homeDir);
72478
- return new Promise((resolve4) => {
72478
+ return new Promise((resolve5) => {
72479
72479
  const socket = (0, import_node_net.createConnection)(path);
72480
72480
  let settled = false;
72481
72481
  let buffer2 = "";
@@ -72484,7 +72484,7 @@ async function subscribeUserAttentionEvents(options) {
72484
72484
  return;
72485
72485
  }
72486
72486
  settled = true;
72487
- resolve4({
72487
+ resolve5({
72488
72488
  path,
72489
72489
  connected,
72490
72490
  close() {
@@ -72516,7 +72516,7 @@ async function subscribeUserAttentionEvents(options) {
72516
72516
  }
72517
72517
  async function notifyUserAttentionChanged(homeDir) {
72518
72518
  const path = resolveUserAttentionIpcPath(homeDir);
72519
- return new Promise((resolve4) => {
72519
+ return new Promise((resolve5) => {
72520
72520
  const socket = (0, import_node_net.createConnection)(path);
72521
72521
  let done = false;
72522
72522
  const finish = (ok) => {
@@ -72525,7 +72525,7 @@ async function notifyUserAttentionChanged(homeDir) {
72525
72525
  }
72526
72526
  done = true;
72527
72527
  socket.destroy();
72528
- resolve4(ok);
72528
+ resolve5(ok);
72529
72529
  };
72530
72530
  socket.setTimeout(1e3, () => finish(false));
72531
72531
  socket.once("connect", () => {
@@ -72878,9 +72878,9 @@ var AiRunner = class {
72878
72878
  }, 5e3).unref();
72879
72879
  }, timeoutMs);
72880
72880
  timeout?.unref();
72881
- const closeResult = await new Promise((resolve4, reject) => {
72881
+ const closeResult = await new Promise((resolve5, reject) => {
72882
72882
  child.once("error", reject);
72883
- child.once("close", (code2, signal) => resolve4({ code: code2, signal }));
72883
+ child.once("close", (code2, signal) => resolve5({ code: code2, signal }));
72884
72884
  });
72885
72885
  if (timeout) {
72886
72886
  clearTimeout(timeout);
@@ -72902,8 +72902,8 @@ var AiRunner = class {
72902
72902
  const sessionWriteMs = sessionWriteEndedAt - sessionWriteStartedAt;
72903
72903
  const logFileCloseStartedAt = Date.now();
72904
72904
  if (log) {
72905
- await new Promise((resolve4) => {
72906
- log.end(resolve4);
72905
+ await new Promise((resolve5) => {
72906
+ log.end(resolve5);
72907
72907
  });
72908
72908
  }
72909
72909
  const logFileCloseEndedAt = Date.now();
@@ -74907,7 +74907,7 @@ var CommandStore = class {
74907
74907
  if (result) {
74908
74908
  return result;
74909
74909
  }
74910
- await new Promise((resolve4) => setTimeout(resolve4, 500));
74910
+ await new Promise((resolve5) => setTimeout(resolve5, 500));
74911
74911
  }
74912
74912
  return null;
74913
74913
  }
@@ -75488,8 +75488,8 @@ var AsyncStream = class {
75488
75488
  value: this.#queue.shift()
75489
75489
  });
75490
75490
  }
75491
- return new Promise((resolve4) => {
75492
- this.#pendingResolves.push(resolve4);
75491
+ return new Promise((resolve5) => {
75492
+ this.#pendingResolves.push(resolve5);
75493
75493
  });
75494
75494
  };
75495
75495
  return = () => {
@@ -75543,7 +75543,7 @@ function createAsyncStreamProxy(stream) {
75543
75543
  }
75544
75544
  });
75545
75545
  }
75546
- var wait = (ms) => new Promise((resolve4) => setTimeout(resolve4, ms));
75546
+ var wait = (ms) => new Promise((resolve5) => setTimeout(resolve5, ms));
75547
75547
  var DEFAULT_RETRY_DELAY = 6e4;
75548
75548
  var DEFAULT_RETRY_ATTEMPTS = 10;
75549
75549
  var createStream = async (streamFunction, streamValueMutator, options) => {
@@ -78962,7 +78962,7 @@ async function wait2(time) {
78962
78962
 
78963
78963
  // ../../node_modules/viem/_esm/utils/promise/withRetry.js
78964
78964
  function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shouldRetry2 = () => true } = {}) {
78965
- return new Promise((resolve4, reject) => {
78965
+ return new Promise((resolve5, reject) => {
78966
78966
  const attemptRetry = async ({ count = 0 } = {}) => {
78967
78967
  const retry = async ({ error }) => {
78968
78968
  const delay = typeof delay_ === "function" ? delay_({ count, error }) : delay_;
@@ -78972,7 +78972,7 @@ function withRetry(fn, { delay: delay_ = 100, retryCount = 2, shouldRetry: shoul
78972
78972
  };
78973
78973
  try {
78974
78974
  const data = await fn();
78975
- resolve4(data);
78975
+ resolve5(data);
78976
78976
  } catch (err2) {
78977
78977
  if (count < retryCount && await shouldRetry2({ count, error: err2 }))
78978
78978
  return retry({ error: err2 });
@@ -79452,7 +79452,7 @@ init_request();
79452
79452
 
79453
79453
  // ../../node_modules/viem/_esm/utils/promise/withTimeout.js
79454
79454
  function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, signal }) {
79455
- return new Promise((resolve4, reject) => {
79455
+ return new Promise((resolve5, reject) => {
79456
79456
  ;
79457
79457
  (async () => {
79458
79458
  let timeoutId;
@@ -79467,7 +79467,7 @@ function withTimeout(fn, { errorInstance = new Error("timed out"), timeout, sign
79467
79467
  }
79468
79468
  }, timeout);
79469
79469
  }
79470
- resolve4(await fn({ signal: controller?.signal || null }));
79470
+ resolve5(await fn({ signal: controller?.signal || null }));
79471
79471
  } catch (err2) {
79472
79472
  if (err2?.name === "AbortError")
79473
79473
  reject(errorInstance);
@@ -82134,7 +82134,7 @@ async function sendCalls(client, parameters) {
82134
82134
  });
82135
82135
  promises.push(promise);
82136
82136
  if (experimental_fallbackDelay > 0)
82137
- await new Promise((resolve4) => setTimeout(resolve4, experimental_fallbackDelay));
82137
+ await new Promise((resolve5) => setTimeout(resolve5, experimental_fallbackDelay));
82138
82138
  }
82139
82139
  const results = await Promise.allSettled(promises);
82140
82140
  if (results.every((r) => r.status === "rejected"))
@@ -82238,9 +82238,9 @@ async function waitForCallsStatus(client, parameters) {
82238
82238
  throwOnFailure = false
82239
82239
  } = parameters;
82240
82240
  const observerId = stringify(["waitForCallsStatus", client.uid, id]);
82241
- const { promise, resolve: resolve4, reject } = withResolvers();
82241
+ const { promise, resolve: resolve5, reject } = withResolvers();
82242
82242
  let timer;
82243
- const unobserve = observe(observerId, { resolve: resolve4, reject }, (emit) => {
82243
+ const unobserve = observe(observerId, { resolve: resolve5, reject }, (emit) => {
82244
82244
  const unpoll = poll(async () => {
82245
82245
  const done = (fn) => {
82246
82246
  clearTimeout(timer);
@@ -82540,13 +82540,13 @@ async function waitForTransactionReceipt(client, parameters) {
82540
82540
  let retrying = false;
82541
82541
  let _unobserve;
82542
82542
  let _unwatch;
82543
- const { promise, resolve: resolve4, reject } = withResolvers();
82543
+ const { promise, resolve: resolve5, reject } = withResolvers();
82544
82544
  const timer = timeout ? setTimeout(() => {
82545
82545
  _unwatch?.();
82546
82546
  _unobserve?.();
82547
82547
  reject(new WaitForTransactionReceiptTimeoutError({ hash: hash2 }));
82548
82548
  }, timeout) : void 0;
82549
- _unobserve = observe(observerId, { onReplaced, resolve: resolve4, reject }, async (emit) => {
82549
+ _unobserve = observe(observerId, { onReplaced, resolve: resolve5, reject }, async (emit) => {
82550
82550
  receipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: hash2 }).catch(() => void 0);
82551
82551
  if (receipt && confirmations <= 1) {
82552
82552
  clearTimeout(timer);
@@ -86345,6 +86345,9 @@ var import_node_crypto7 = require("node:crypto");
86345
86345
 
86346
86346
  // src/openclaw-gateway.ts
86347
86347
  var import_node_crypto6 = require("node:crypto");
86348
+ var import_node_fs13 = require("node:fs");
86349
+ var import_node_os5 = require("node:os");
86350
+ var import_node_path17 = require("node:path");
86348
86351
 
86349
86352
  // ../core/src/openclaw-gateway-config.ts
86350
86353
  var import_node_fs12 = require("node:fs");
@@ -86381,6 +86384,10 @@ var LEGACY_PROTOCOL_VERSION = 3;
86381
86384
  var DEFAULT_SCOPES = ["operator.admin"];
86382
86385
  var LOG_PREFIX = "[okx-a2a:gateway]";
86383
86386
  var GATEWAY_STARTING_RETRY_DELAYS_MS = [300, 700, 1200, 2e3, 3e3];
86387
+ var CONNECT_CHALLENGE_FALLBACK_MS = 750;
86388
+ var DEVICE_AUTH_FILE = "device-auth.json";
86389
+ var DEVICE_IDENTITY_FILE = "device.json";
86390
+ var ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
86384
86391
  var wsFactory = createDefaultWebSocket;
86385
86392
  var preferredGatewayProtocolVersion = PREFERRED_PROTOCOL_VERSION;
86386
86393
  function createDefaultWebSocket(url) {
@@ -86457,6 +86464,161 @@ function clearClient() {
86457
86464
  }
86458
86465
  sharedClient = null;
86459
86466
  }
86467
+ function resolveOpenClawStateDir(env = process.env) {
86468
+ const override = env.OPENCLAW_STATE_DIR?.trim();
86469
+ if (override) {
86470
+ return resolveUserPath(override, env);
86471
+ }
86472
+ return (0, import_node_path17.join)(resolveHomeDir2(env), ".openclaw");
86473
+ }
86474
+ function resolveHomeDir2(env) {
86475
+ const override = env.OPENCLAW_HOME?.trim();
86476
+ if (override) {
86477
+ return resolveUserPath(override, env);
86478
+ }
86479
+ try {
86480
+ const home = (0, import_node_os5.homedir)();
86481
+ if (home) {
86482
+ return home;
86483
+ }
86484
+ } catch {
86485
+ }
86486
+ return (0, import_node_path17.resolve)(process.cwd());
86487
+ }
86488
+ function resolveUserPath(input, env) {
86489
+ if (input === "~" || input.startsWith("~/")) {
86490
+ return (0, import_node_path17.join)(resolveHomeDir2({ ...env, OPENCLAW_HOME: void 0 }), input.slice(2));
86491
+ }
86492
+ return (0, import_node_path17.resolve)(input);
86493
+ }
86494
+ function base64UrlEncode(buf) {
86495
+ return buf.toString("base64").replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/g, "");
86496
+ }
86497
+ function derivePublicKeyRaw(publicKeyPem) {
86498
+ const spki = (0, import_node_crypto6.createPublicKey)(publicKeyPem).export({ type: "spki", format: "der" });
86499
+ if (Buffer.isBuffer(spki) && spki.length === ED25519_SPKI_PREFIX.length + 32 && spki.subarray(0, ED25519_SPKI_PREFIX.length).equals(ED25519_SPKI_PREFIX)) {
86500
+ return spki.subarray(ED25519_SPKI_PREFIX.length);
86501
+ }
86502
+ return Buffer.from(spki);
86503
+ }
86504
+ function publicKeyRawBase64UrlFromPem(publicKeyPem) {
86505
+ return base64UrlEncode(derivePublicKeyRaw(publicKeyPem));
86506
+ }
86507
+ function fingerprintPublicKey(publicKeyPem) {
86508
+ return (0, import_node_crypto6.createHash)("sha256").update(derivePublicKeyRaw(publicKeyPem)).digest("hex");
86509
+ }
86510
+ function ensureParentDir(filePath) {
86511
+ (0, import_node_fs13.mkdirSync)((0, import_node_path17.dirname)(filePath), { recursive: true });
86512
+ }
86513
+ function loadOrCreateDeviceIdentity(env = process.env) {
86514
+ const filePath = (0, import_node_path17.join)(resolveOpenClawStateDir(env), "identity", DEVICE_IDENTITY_FILE);
86515
+ try {
86516
+ if ((0, import_node_fs13.existsSync)(filePath)) {
86517
+ const parsed = JSON.parse((0, import_node_fs13.readFileSync)(filePath, "utf8"));
86518
+ if (parsed.version === 1 && typeof parsed.deviceId === "string" && typeof parsed.publicKeyPem === "string" && typeof parsed.privateKeyPem === "string") {
86519
+ const derivedId = fingerprintPublicKey(parsed.publicKeyPem);
86520
+ if (derivedId && derivedId !== parsed.deviceId) {
86521
+ const updated = { ...parsed, deviceId: derivedId };
86522
+ writeSecretJson(filePath, updated);
86523
+ return { deviceId: derivedId, publicKeyPem: parsed.publicKeyPem, privateKeyPem: parsed.privateKeyPem };
86524
+ }
86525
+ return {
86526
+ deviceId: parsed.deviceId,
86527
+ publicKeyPem: parsed.publicKeyPem,
86528
+ privateKeyPem: parsed.privateKeyPem
86529
+ };
86530
+ }
86531
+ }
86532
+ } catch (err2) {
86533
+ errorWithTimestamp(`${LOG_PREFIX} failed reading device identity: ${err2 instanceof Error ? err2.message : String(err2)}`);
86534
+ }
86535
+ const { publicKey, privateKey } = (0, import_node_crypto6.generateKeyPairSync)("ed25519");
86536
+ const publicKeyPem = publicKey.export({ type: "spki", format: "pem" }).toString();
86537
+ const privateKeyPem = privateKey.export({ type: "pkcs8", format: "pem" }).toString();
86538
+ const identity3 = {
86539
+ version: 1,
86540
+ deviceId: fingerprintPublicKey(publicKeyPem),
86541
+ publicKeyPem,
86542
+ privateKeyPem,
86543
+ createdAtMs: Date.now()
86544
+ };
86545
+ writeSecretJson(filePath, identity3);
86546
+ return {
86547
+ deviceId: identity3.deviceId,
86548
+ publicKeyPem,
86549
+ privateKeyPem
86550
+ };
86551
+ }
86552
+ function signDevicePayload(privateKeyPem, payload) {
86553
+ return base64UrlEncode((0, import_node_crypto6.sign)(null, Buffer.from(payload, "utf8"), (0, import_node_crypto6.createPrivateKey)(privateKeyPem)));
86554
+ }
86555
+ function writeSecretJson(filePath, value) {
86556
+ ensureParentDir(filePath);
86557
+ (0, import_node_fs13.writeFileSync)(filePath, `${JSON.stringify(value, null, 2)}
86558
+ `, { encoding: "utf8", mode: 384 });
86559
+ try {
86560
+ (0, import_node_fs13.chmodSync)(filePath, 384);
86561
+ } catch {
86562
+ }
86563
+ }
86564
+ function resolveDeviceAuthPath(env = process.env) {
86565
+ return (0, import_node_path17.join)(resolveOpenClawStateDir(env), "identity", DEVICE_AUTH_FILE);
86566
+ }
86567
+ function loadStoredDeviceAuth(deviceId, role) {
86568
+ try {
86569
+ const raw = (0, import_node_fs13.readFileSync)(resolveDeviceAuthPath(), "utf8");
86570
+ const parsed = JSON.parse(raw);
86571
+ if (parsed.version !== 1 || parsed.deviceId !== deviceId || !parsed.tokens) {
86572
+ return null;
86573
+ }
86574
+ const entry = parsed.tokens[role];
86575
+ if (!entry || typeof entry.token !== "string" || !entry.token) {
86576
+ return null;
86577
+ }
86578
+ return {
86579
+ token: entry.token,
86580
+ scopes: Array.isArray(entry.scopes) ? entry.scopes.filter((scope) => typeof scope === "string") : void 0
86581
+ };
86582
+ } catch {
86583
+ return null;
86584
+ }
86585
+ }
86586
+ function storeDeviceAuth(deviceId, role, token, scopes) {
86587
+ const filePath = resolveDeviceAuthPath();
86588
+ let existing = null;
86589
+ try {
86590
+ existing = JSON.parse((0, import_node_fs13.readFileSync)(filePath, "utf8"));
86591
+ } catch {
86592
+ existing = null;
86593
+ }
86594
+ const next = {
86595
+ version: 1,
86596
+ deviceId,
86597
+ tokens: existing?.deviceId === deviceId && existing.tokens ? { ...existing.tokens } : {}
86598
+ };
86599
+ next.tokens[role] = {
86600
+ token,
86601
+ role,
86602
+ scopes,
86603
+ updatedAtMs: Date.now()
86604
+ };
86605
+ writeSecretJson(filePath, next);
86606
+ }
86607
+ function buildDeviceAuthPayloadV3(params) {
86608
+ return [
86609
+ "v3",
86610
+ params.deviceId,
86611
+ params.clientId,
86612
+ params.clientMode,
86613
+ params.role,
86614
+ params.scopes.join(","),
86615
+ String(params.signedAtMs),
86616
+ params.token ?? "",
86617
+ params.nonce,
86618
+ params.platform.trim(),
86619
+ params.deviceFamily?.trim() ?? ""
86620
+ ].join("|");
86621
+ }
86460
86622
  async function ensureClient(timeoutMs) {
86461
86623
  if (sharedClient?.isReady()) {
86462
86624
  return sharedClient;
@@ -86610,17 +86772,19 @@ function isGatewayStartingError(err2) {
86610
86772
  return String(e?.details?.reason ?? "") === "startup-sidecars" || String(e?.message ?? "").toLowerCase().includes("gateway starting");
86611
86773
  }
86612
86774
  async function sleep2(ms) {
86613
- await new Promise((resolve4) => setTimeout(resolve4, ms));
86775
+ await new Promise((resolve5) => setTimeout(resolve5, ms));
86614
86776
  }
86615
86777
  var MinimalGatewayClient = class {
86616
86778
  config;
86617
86779
  protocolVersion;
86618
86780
  instanceId = (0, import_node_crypto6.randomUUID)();
86781
+ deviceIdentity = loadOrCreateDeviceIdentity();
86619
86782
  pending = /* @__PURE__ */ new Map();
86620
86783
  ws = null;
86621
86784
  ready = false;
86622
86785
  closed = false;
86623
86786
  requestSeq = 0;
86787
+ connectNonce = null;
86624
86788
  constructor(config, protocolVersion) {
86625
86789
  this.config = config;
86626
86790
  this.protocolVersion = protocolVersion;
@@ -86634,7 +86798,7 @@ var MinimalGatewayClient = class {
86634
86798
  );
86635
86799
  const ws = wsFactory(this.config.url);
86636
86800
  this.ws = ws;
86637
- await new Promise((resolve4, reject) => {
86801
+ await new Promise((resolve5, reject) => {
86638
86802
  let settled = false;
86639
86803
  const timer = setTimeout(() => {
86640
86804
  if (settled) {
@@ -86653,7 +86817,7 @@ var MinimalGatewayClient = class {
86653
86817
  }
86654
86818
  settled = true;
86655
86819
  clearTimeout(timer);
86656
- resolve4();
86820
+ resolve5();
86657
86821
  },
86658
86822
  (err2) => {
86659
86823
  if (settled) {
@@ -86705,7 +86869,7 @@ var MinimalGatewayClient = class {
86705
86869
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
86706
86870
  const id = `okx-a2a-${++this.requestSeq}-${(0, import_node_crypto6.randomUUID)()}`;
86707
86871
  const frame = { type: "req", id, method, params };
86708
- return new Promise((resolve4, reject) => {
86872
+ return new Promise((resolve5, reject) => {
86709
86873
  const timer = setTimeout(() => {
86710
86874
  this.pending.delete(id);
86711
86875
  reject(Object.assign(new Error(`OpenClaw gateway request timed out method=${method}`), {
@@ -86714,7 +86878,7 @@ var MinimalGatewayClient = class {
86714
86878
  }));
86715
86879
  }, timeoutMs);
86716
86880
  timer.unref?.();
86717
- this.pending.set(id, { method, resolve: resolve4, reject, timer });
86881
+ this.pending.set(id, { method, resolve: resolve5, reject, timer });
86718
86882
  try {
86719
86883
  this.ws.send(JSON.stringify(frame));
86720
86884
  } catch (err2) {
@@ -86745,9 +86909,10 @@ var MinimalGatewayClient = class {
86745
86909
  this.ws = null;
86746
86910
  }
86747
86911
  async handleOpen(timeoutMs) {
86912
+ const nonce = await this.waitForConnectNonce(Math.min(timeoutMs, CONNECT_CHALLENGE_FALLBACK_MS));
86748
86913
  const hello = await this.request(
86749
86914
  "connect",
86750
- buildConnectParams(this.config, this.instanceId, this.protocolVersion),
86915
+ buildConnectParams(this.config, this.instanceId, this.protocolVersion, this.deviceIdentity, nonce),
86751
86916
  { timeoutMs }
86752
86917
  );
86753
86918
  if (!isHelloOk(hello)) {
@@ -86755,6 +86920,9 @@ var MinimalGatewayClient = class {
86755
86920
  code: "PROTOCOL_ERROR"
86756
86921
  });
86757
86922
  }
86923
+ if (nonce) {
86924
+ persistHelloAuth(hello, this.deviceIdentity.deviceId);
86925
+ }
86758
86926
  this.ready = true;
86759
86927
  }
86760
86928
  handleMessage(raw) {
@@ -86766,6 +86934,9 @@ var MinimalGatewayClient = class {
86766
86934
  return;
86767
86935
  }
86768
86936
  if (frame.type !== "res") {
86937
+ if (frame.type === "event") {
86938
+ this.handleEventFrame(frame);
86939
+ }
86769
86940
  return;
86770
86941
  }
86771
86942
  if (frame.progress) {
@@ -86795,6 +86966,38 @@ var MinimalGatewayClient = class {
86795
86966
  this.pending.delete(id);
86796
86967
  }
86797
86968
  }
86969
+ handleEventFrame(frame) {
86970
+ if (frame.event !== "connect.challenge") {
86971
+ return;
86972
+ }
86973
+ const payload = frame.payload;
86974
+ const nonce = typeof payload === "object" && payload !== null && "nonce" in payload ? String(payload.nonce ?? "").trim() : "";
86975
+ if (nonce) {
86976
+ this.connectNonce = nonce;
86977
+ }
86978
+ }
86979
+ async waitForConnectNonce(timeoutMs) {
86980
+ const existing = this.connectNonce?.trim();
86981
+ if (existing) {
86982
+ return existing;
86983
+ }
86984
+ const deadline = Date.now() + timeoutMs;
86985
+ while (!this.connectNonce && Date.now() < deadline) {
86986
+ await sleep2(10);
86987
+ if (this.closed || this.ws?.readyState !== 1) {
86988
+ throw Object.assign(new Error("OpenClaw gateway socket closed before connect challenge"), {
86989
+ code: "ECONNRESET",
86990
+ retryable: true
86991
+ });
86992
+ }
86993
+ }
86994
+ const nonce = this.connectNonce?.trim();
86995
+ if (!nonce) {
86996
+ errorWithTimestamp(`${LOG_PREFIX} connect challenge unavailable; falling back to legacy auth-less connect`);
86997
+ return null;
86998
+ }
86999
+ return nonce;
87000
+ }
86798
87001
  };
86799
87002
  function readSyncedGatewayConfig(env) {
86800
87003
  try {
@@ -86812,34 +87015,87 @@ function readSyncedGatewayConfig(env) {
86812
87015
  return null;
86813
87016
  }
86814
87017
  }
86815
- function buildConnectParams(config, instanceId, protocolVersion) {
87018
+ function buildConnectParams(config, instanceId, protocolVersion, deviceIdentity, nonce) {
87019
+ const role = "operator";
87020
+ const storedAuth = loadStoredDeviceAuth(deviceIdentity.deviceId, role);
87021
+ const explicitToken = config.token?.trim();
87022
+ const storedToken = storedAuth?.token?.trim();
87023
+ const password = config.password?.trim();
87024
+ const token = explicitToken || storedToken || void 0;
87025
+ const scopes = storedAuth?.scopes?.length ? storedAuth.scopes : [...DEFAULT_SCOPES];
87026
+ const signedAtMs = Date.now();
87027
+ const platform = process.platform;
87028
+ const clientId = "gateway-client";
87029
+ const clientMode = "backend";
87030
+ const device = nonce ? (() => {
87031
+ const signaturePayload = buildDeviceAuthPayloadV3({
87032
+ deviceId: deviceIdentity.deviceId,
87033
+ clientId,
87034
+ clientMode,
87035
+ role,
87036
+ scopes,
87037
+ signedAtMs,
87038
+ token,
87039
+ nonce,
87040
+ platform
87041
+ });
87042
+ return {
87043
+ id: deviceIdentity.deviceId,
87044
+ publicKey: publicKeyRawBase64UrlFromPem(deviceIdentity.publicKeyPem),
87045
+ signature: signDevicePayload(deviceIdentity.privateKeyPem, signaturePayload),
87046
+ signedAt: signedAtMs,
87047
+ nonce
87048
+ };
87049
+ })() : void 0;
86816
87050
  return {
86817
87051
  minProtocol: protocolVersion,
86818
87052
  maxProtocol: protocolVersion,
86819
87053
  client: {
86820
- id: "gateway-client",
87054
+ id: clientId,
86821
87055
  displayName: "okx-a2a-node",
86822
- version: "0.1.3",
86823
- platform: "node",
86824
- mode: "backend",
87056
+ version: "0.1.4-beta-161afc7833-260702114832",
87057
+ platform,
87058
+ mode: clientMode,
86825
87059
  instanceId
86826
87060
  },
86827
- role: "operator",
86828
- scopes: [...DEFAULT_SCOPES],
87061
+ role,
87062
+ scopes,
86829
87063
  caps: [],
86830
87064
  commands: [],
86831
87065
  permissions: {},
86832
87066
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
86833
- userAgent: `okx-a2a-node/${"0.1.3"}`,
87067
+ userAgent: `okx-a2a-node/${"0.1.4-beta-161afc7833-260702114832"}`,
87068
+ ...device ? { device } : {},
86834
87069
  auth: {
86835
- ...config.token ? { token: config.token } : {},
86836
- ...config.password ? { password: config.password } : {}
87070
+ ...token ? { token } : {},
87071
+ ...storedToken && !explicitToken ? { deviceToken: storedToken } : {},
87072
+ ...password ? { password } : {}
86837
87073
  }
86838
87074
  };
86839
87075
  }
86840
87076
  function isHelloOk(value) {
86841
87077
  return typeof value === "object" && value !== null && value.type === "hello-ok";
86842
87078
  }
87079
+ function persistHelloAuth(value, deviceId) {
87080
+ if (!value || typeof value !== "object") {
87081
+ return;
87082
+ }
87083
+ const auth = value.auth;
87084
+ if (!auth || typeof auth !== "object") {
87085
+ return;
87086
+ }
87087
+ const record = auth;
87088
+ if (typeof record.deviceToken !== "string" || !record.deviceToken) {
87089
+ return;
87090
+ }
87091
+ const role = typeof record.role === "string" && record.role.trim() ? record.role.trim() : "operator";
87092
+ const scopes = Array.isArray(record.scopes) ? record.scopes.filter((scope) => typeof scope === "string" && scope.trim().length > 0) : [];
87093
+ try {
87094
+ storeDeviceAuth(deviceId, role, record.deviceToken, scopes);
87095
+ } catch (err2) {
87096
+ errorWithTimestamp(`${LOG_PREFIX} failed storing device auth token: ${err2 instanceof Error ? err2.message : String(err2)}`);
87097
+ }
87098
+ }
86843
87099
  function toGatewayError(error) {
86844
87100
  const err2 = Object.assign(new Error(error?.message || "OpenClaw gateway request failed"), {
86845
87101
  code: error?.code,
@@ -86956,9 +87212,9 @@ function safeDecode(value) {
86956
87212
  }
86957
87213
 
86958
87214
  // src/openclaw-route.ts
86959
- var import_node_fs13 = require("node:fs");
86960
- var import_node_os5 = require("node:os");
86961
- var import_node_path17 = require("node:path");
87215
+ var import_node_fs14 = require("node:fs");
87216
+ var import_node_os6 = require("node:os");
87217
+ var import_node_path18 = require("node:path");
86962
87218
  var OPENCLAW_GATEWAY_ROUTE_GROUP_ID = "__openclaw_gateway_route__";
86963
87219
  var CURRENT_GATEWAY_SESSION_KEYS_ENV = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
86964
87220
  var NON_DELIVERY_CHANNELS = /* @__PURE__ */ new Set(["heartbeat", "cron", "webhook", "voice"]);
@@ -87276,12 +87532,12 @@ function readGatewaySessionKeysEnv(env) {
87276
87532
  return raw.split(",").map((item) => item.trim()).filter(Boolean);
87277
87533
  }
87278
87534
  function readSingleActiveOriginSessionKey(env) {
87279
- const path = (0, import_node_path17.join)(resolveTaskHome2(env), "run", "gateway-route-origins.json");
87280
- if (!(0, import_node_fs13.existsSync)(path)) {
87535
+ const path = (0, import_node_path18.join)(resolveTaskHome2(env), "run", "gateway-route-origins.json");
87536
+ if (!(0, import_node_fs14.existsSync)(path)) {
87281
87537
  return [];
87282
87538
  }
87283
87539
  try {
87284
- const parsed = JSON.parse((0, import_node_fs13.readFileSync)(path, "utf8"));
87540
+ const parsed = JSON.parse((0, import_node_fs14.readFileSync)(path, "utf8"));
87285
87541
  if (!isRecord2(parsed) || !Array.isArray(parsed.origins)) {
87286
87542
  return [];
87287
87543
  }
@@ -87306,7 +87562,7 @@ function readSingleActiveOriginSessionKey(env) {
87306
87562
  }
87307
87563
  }
87308
87564
  function resolveTaskHome2(env) {
87309
- return env.OKX_AGENT_TASK_HOME?.trim() || (0, import_node_path17.join)((0, import_node_os5.homedir)(), ".okx-agent-task");
87565
+ return env.OKX_AGENT_TASK_HOME?.trim() || (0, import_node_path18.join)((0, import_node_os6.homedir)(), ".okx-agent-task");
87310
87566
  }
87311
87567
  function logOpenClawRouteSkip(reason, input) {
87312
87568
  if (reason === "missing_gateway_session_key") {
@@ -91024,10 +91280,10 @@ function isA2AEnvelope(payload) {
91024
91280
  }
91025
91281
 
91026
91282
  // src/listener.ts
91027
- var import_node_fs14 = require("node:fs");
91283
+ var import_node_fs15 = require("node:fs");
91028
91284
  var import_promises6 = require("node:fs/promises");
91029
- var import_node_os6 = require("node:os");
91030
- var import_node_path18 = require("node:path");
91285
+ var import_node_os7 = require("node:os");
91286
+ var import_node_path19 = require("node:path");
91031
91287
 
91032
91288
  // ../core/src/xmtp-sdk/onchainos/signer.ts
91033
91289
  async function onchainosSign(agentId, keyUuid, walletAddress, message) {
@@ -91255,7 +91511,7 @@ function userWatchEventDeliveredSentryExtra(event) {
91255
91511
  var environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
91256
91512
  var SENTRY_CONFIG = {
91257
91513
  projectName: "okx/openclaw-okx-a2a-extension",
91258
- release: "0.1.3",
91514
+ release: "0.1.4-beta-161afc7833-260702114832",
91259
91515
  environment
91260
91516
  };
91261
91517
 
@@ -91300,12 +91556,12 @@ async function isHermesGatewayPluginEnabled(options = {}) {
91300
91556
  if (options.requireGatewayRuntime && detectGatewayInvocation(env) !== "hermes") {
91301
91557
  return false;
91302
91558
  }
91303
- const hermesHome = env.HERMES_HOME?.trim() || (0, import_node_path18.join)((0, import_node_os6.homedir)(), ".hermes");
91304
- if (!(0, import_node_fs14.existsSync)((0, import_node_path18.join)(hermesHome, "plugins", "platforms", "okx-a2a", "plugin.yaml"))) {
91559
+ const hermesHome = env.HERMES_HOME?.trim() || (0, import_node_path19.join)((0, import_node_os7.homedir)(), ".hermes");
91560
+ if (!(0, import_node_fs15.existsSync)((0, import_node_path19.join)(hermesHome, "plugins", "platforms", "okx-a2a", "plugin.yaml"))) {
91305
91561
  return false;
91306
91562
  }
91307
91563
  try {
91308
- return hermesConfigEnablesOkxA2a(await (0, import_promises6.readFile)((0, import_node_path18.join)(hermesHome, "config.yaml"), "utf8"));
91564
+ return hermesConfigEnablesOkxA2a(await (0, import_promises6.readFile)((0, import_node_path19.join)(hermesHome, "config.yaml"), "utf8"));
91309
91565
  } catch {
91310
91566
  return false;
91311
91567
  }
@@ -91482,12 +91738,12 @@ async function runListenerWithLock(options, paths) {
91482
91738
  }));
91483
91739
  }
91484
91740
  });
91485
- service.setPluginVersion("0.1.3");
91741
+ service.setPluginVersion("0.1.4-beta-161afc7833-260702114832");
91486
91742
  await service.init();
91487
91743
  const pluginVersionStatus = service.pluginVersionStatus;
91488
91744
  if (pluginVersionStatus.unavailable) {
91489
91745
  throw new Error(
91490
- `@okxweb3/a2a-node v${"0.1.3"} is below the required minimum v${pluginVersionStatus.minVersion}`
91746
+ `@okxweb3/a2a-node v${"0.1.4-beta-161afc7833-260702114832"} is below the required minimum v${pluginVersionStatus.minVersion}`
91491
91747
  );
91492
91748
  }
91493
91749
  const systemConfig = service.getSystemConfig();
@@ -91505,7 +91761,7 @@ async function runListenerWithLock(options, paths) {
91505
91761
  onchainosAgentId: "*",
91506
91762
  reason: "system-config missing sentryDsn",
91507
91763
  pluginId: "@okxweb3/a2a-node",
91508
- pluginVersion: "0.1.3"
91764
+ pluginVersion: "0.1.4-beta-161afc7833-260702114832"
91509
91765
  });
91510
91766
  }
91511
91767
  logWithTimestamp(
@@ -91804,7 +92060,7 @@ async function runListenerWithLock(options, paths) {
91804
92060
  });
91805
92061
  await markDaemonReady(paths.daemonLockPath);
91806
92062
  logWithTimestamp(`[okx-agent-task] daemon ready lock=${paths.daemonLockPath}`);
91807
- await new Promise((resolve4) => {
92063
+ await new Promise((resolve5) => {
91808
92064
  const shutdown = (signal) => {
91809
92065
  if (stopping) {
91810
92066
  return;
@@ -91813,7 +92069,7 @@ async function runListenerWithLock(options, paths) {
91813
92069
  logWithTimestamp(`[okx-agent-task] received ${signal}, stopping listener`);
91814
92070
  const forceResolve = setTimeout(() => {
91815
92071
  logWithTimestamp("[okx-agent-task] listener shutdown timed out; forcing process exit");
91816
- resolve4();
92072
+ resolve5();
91817
92073
  }, SHUTDOWN_FORCE_RESOLVE_MS);
91818
92074
  void (async () => {
91819
92075
  if (timer) {
@@ -91841,7 +92097,7 @@ async function runListenerWithLock(options, paths) {
91841
92097
  stopClients(service);
91842
92098
  sessionStore.close();
91843
92099
  clearTimeout(forceResolve);
91844
- resolve4();
92100
+ resolve5();
91845
92101
  })();
91846
92102
  };
91847
92103
  process.once("SIGTERM", shutdown);
@@ -91861,8 +92117,8 @@ async function timeSettled(fn) {
91861
92117
  // src/update-cli.ts
91862
92118
  var import_node_child_process6 = require("node:child_process");
91863
92119
  var import_promises7 = require("node:fs/promises");
91864
- var import_node_os7 = require("node:os");
91865
- var import_node_path19 = require("node:path");
92120
+ var import_node_os8 = require("node:os");
92121
+ var import_node_path20 = require("node:path");
91866
92122
  var OKX_A2A_PLUGIN_ID = "okx-a2a";
91867
92123
  var OPENCLAW_SESSION_DM_SCOPE_CONFIG_PATH = "session.dmScope";
91868
92124
  var OPENCLAW_SESSION_DM_SCOPE_CONFIG_VALUE = "per-channel-peer";
@@ -92121,7 +92377,7 @@ function isEmptyInlineEnabledList(line) {
92121
92377
  return !!inline && inline.values.length === 0;
92122
92378
  }
92123
92379
  function resolveHermesConfigPath() {
92124
- return (0, import_node_path19.join)(process.env.HERMES_HOME ?? (0, import_node_path19.join)((0, import_node_os7.homedir)(), ".hermes"), "config.yaml");
92380
+ return (0, import_node_path20.join)(process.env.HERMES_HOME ?? (0, import_node_path20.join)((0, import_node_os8.homedir)(), ".hermes"), "config.yaml");
92125
92381
  }
92126
92382
  function lineIndent(line) {
92127
92383
  const match = line.match(/^\s*/);