@okxweb3/a2a-node 0.2.4-beta-e7a52faf6f-260812104443 → 0.2.4-beta-e7a52faf6f-260812154627

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 +94 -35
  2. package/dist/index.js +97 -30
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -26604,7 +26604,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
26604
26604
  client: {
26605
26605
  id: "gateway-client",
26606
26606
  displayName: "okx-a2a-node",
26607
- version: "0.2.4-beta-e7a52faf6f-260812104443",
26607
+ version: "0.2.4-beta-e7a52faf6f-260812154627",
26608
26608
  platform: "node",
26609
26609
  mode: "backend",
26610
26610
  instanceId
@@ -26615,7 +26615,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
26615
26615
  commands: [],
26616
26616
  permissions: {},
26617
26617
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
26618
- userAgent: `okx-a2a-node/${"0.2.4-beta-e7a52faf6f-260812104443"}`,
26618
+ userAgent: `okx-a2a-node/${"0.2.4-beta-e7a52faf6f-260812154627"}`,
26619
26619
  auth: {
26620
26620
  ...config.token ? { token: config.token } : {},
26621
26621
  ...config.password ? { password: config.password } : {}
@@ -28499,7 +28499,7 @@ var init_sentry_config = __esm({
28499
28499
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
28500
28500
  SENTRY_CONFIG = {
28501
28501
  projectName: "okx/openclaw-okx-a2a-extension",
28502
- release: "0.2.4-beta-e7a52faf6f-260812104443",
28502
+ release: "0.2.4-beta-e7a52faf6f-260812154627",
28503
28503
  environment,
28504
28504
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
28505
28505
  };
@@ -39669,7 +39669,7 @@ async function exportDiagnosticLogs(options) {
39669
39669
  node: process.version,
39670
39670
  platform: process.platform,
39671
39671
  arch: process.arch,
39672
- packageVersion: true ? "0.2.4-beta-e7a52faf6f-260812104443" : "unknown",
39672
+ packageVersion: true ? "0.2.4-beta-e7a52faf6f-260812154627" : "unknown",
39673
39673
  sensitiveContentIncluded: options.includeSensitiveContent,
39674
39674
  listenerAndLlmContentIncluded: true,
39675
39675
  credentialsAlwaysRedacted: true,
@@ -40783,7 +40783,7 @@ function redactArgsForLog(args) {
40783
40783
  function commandForLog(bin, args) {
40784
40784
  return `${bin} ${redactArgsForLog(args).join(" ")}`;
40785
40785
  }
40786
- async function exec(args) {
40786
+ async function exec(args, options = {}) {
40787
40787
  const bin = await resolve9();
40788
40788
  const cmd = commandForLog(bin, args);
40789
40789
  logWithTimestamp(`[onchainos] exec: ${cmd}`);
@@ -40797,7 +40797,8 @@ async function exec(args) {
40797
40797
  try {
40798
40798
  const result = await execFileAsync2(invocation.command, invocation.args, {
40799
40799
  windowsHide: true,
40800
- windowsVerbatimArguments: invocation.windowsVerbatimArguments
40800
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
40801
+ timeout: options.timeoutMs
40801
40802
  });
40802
40803
  logWithTimestamp(
40803
40804
  `[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
@@ -40830,7 +40831,8 @@ async function exec(args) {
40830
40831
  stdoutBytes: String(Buffer.byteLength(String(err2?.stdout ?? ""), "utf8")),
40831
40832
  cliErrorName: err2 instanceof Error ? err2.name : "",
40832
40833
  cliErrorMessageLength: String(String(err2?.message ?? "").length),
40833
- durationMs: String(Date.now() - t0)
40834
+ durationMs: String(Date.now() - t0),
40835
+ timeoutMs: String(options.timeoutMs ?? "")
40834
40836
  }
40835
40837
  );
40836
40838
  throw err2;
@@ -58947,13 +58949,17 @@ function parseWalletLoginStatus(stdout) {
58947
58949
  }
58948
58950
  return response.data.loggedIn;
58949
58951
  }
58950
- async function queryWalletLoginStatus() {
58952
+ async function queryWalletLoginStatus(options = {}) {
58951
58953
  logWithTimestamp("[onchainos] checking wallet login status");
58952
- const { stdout } = await exec(["wallet", "status"]);
58954
+ const { stdout } = await exec(
58955
+ ["wallet", "status"],
58956
+ { timeoutMs: options.timeoutMs ?? WALLET_STATUS_TIMEOUT_MS }
58957
+ );
58953
58958
  const loggedIn = parseWalletLoginStatus(stdout);
58954
58959
  logWithTimestamp(`[onchainos] wallet login status: ${loggedIn ? "logged in" : "logged out"}`);
58955
58960
  return loggedIn;
58956
58961
  }
58962
+ var WALLET_STATUS_TIMEOUT_MS;
58957
58963
  var init_wallet_status = __esm({
58958
58964
  "../core/src/xmtp-sdk/onchainos/wallet-status.ts"() {
58959
58965
  "use strict";
@@ -58961,6 +58967,7 @@ var init_wallet_status = __esm({
58961
58967
  init_sentry_logger();
58962
58968
  init_bin();
58963
58969
  init_cli_response();
58970
+ WALLET_STATUS_TIMEOUT_MS = 1e4;
58964
58971
  }
58965
58972
  });
58966
58973
 
@@ -59048,19 +59055,22 @@ function logAgentListResponse(input) {
59048
59055
  onchainosAgentListDiagnosticText: input.stderr
59049
59056
  });
59050
59057
  }
59051
- async function fetchAgentPage(page) {
59058
+ async function fetchAgentPage(page, timeoutMs) {
59052
59059
  const startedAt = Date.now();
59053
59060
  let stdout;
59054
59061
  let stderr;
59055
59062
  try {
59056
- ({ stdout, stderr } = await exec([
59057
- "agent",
59058
- "get",
59059
- "--page",
59060
- String(page),
59061
- "--page-size",
59062
- String(PAGE_SIZE)
59063
- ]));
59063
+ ({ stdout, stderr } = await exec(
59064
+ [
59065
+ "agent",
59066
+ "get",
59067
+ "--page",
59068
+ String(page),
59069
+ "--page-size",
59070
+ String(PAGE_SIZE)
59071
+ ],
59072
+ { timeoutMs }
59073
+ ));
59064
59074
  } catch (err2) {
59065
59075
  const errStdout = typeof err2?.stdout === "string" ? err2.stdout : "";
59066
59076
  const errStderr = typeof err2?.stderr === "string" ? err2.stderr : "";
@@ -59204,13 +59214,28 @@ async function fetchAgentByAddress(communicationAddress) {
59204
59214
  agentByIdCache.set(res.data.agentId, res.data);
59205
59215
  return res.data;
59206
59216
  }
59207
- async function listAllAgentsWithMetadata(previousFingerprint) {
59217
+ async function listAllAgentsWithMetadata(previousFingerprint, options = {}) {
59208
59218
  const startedAt = Date.now();
59219
+ const pageTimeoutMs = positiveTimeoutOrDefault(
59220
+ options.pageTimeoutMs,
59221
+ AGENT_GET_PAGE_TIMEOUT_MS
59222
+ );
59223
+ const totalTimeoutMs = positiveTimeoutOrDefault(
59224
+ options.totalTimeoutMs,
59225
+ AGENT_LIST_TIMEOUT_MS
59226
+ );
59209
59227
  const agents = [];
59210
59228
  const stderrs = [];
59211
59229
  let page = 1;
59212
59230
  while (true) {
59213
- const { data, stderr } = await fetchAgentPage(page);
59231
+ const remainingMs = totalTimeoutMs - (Date.now() - startedAt);
59232
+ if (remainingMs <= 0) {
59233
+ throw agentListTimeoutError(totalTimeoutMs);
59234
+ }
59235
+ const { data, stderr } = await fetchAgentPage(
59236
+ page,
59237
+ Math.min(pageTimeoutMs, remainingMs)
59238
+ );
59214
59239
  if (stderr) {
59215
59240
  stderrs.push(`page=${page}: ${stderr}`);
59216
59241
  }
@@ -59237,6 +59262,14 @@ async function listAllAgentsWithMetadata(previousFingerprint) {
59237
59262
  durationMs: Date.now() - startedAt
59238
59263
  };
59239
59264
  }
59265
+ function positiveTimeoutOrDefault(value, fallback) {
59266
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
59267
+ }
59268
+ function agentListTimeoutError(timeoutMs) {
59269
+ const error = new Error(`onchainos agent list timed out after ${timeoutMs}ms`);
59270
+ error.code = "ETIMEDOUT";
59271
+ return error;
59272
+ }
59240
59273
  function fingerprintAgents(agents) {
59241
59274
  return agents.map((a) => [
59242
59275
  a.agentId,
@@ -59437,7 +59470,7 @@ async function fetchSensitiveWords() {
59437
59470
  );
59438
59471
  return result;
59439
59472
  }
59440
- var MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT, lastExpiredNotifyAt, EXPIRED_NOTIFY_COOLDOWN_MS, PAGE_SIZE, agentByIdCache, ONCHAINOS_CHAIN_INDEX;
59473
+ var MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT, lastExpiredNotifyAt, EXPIRED_NOTIFY_COOLDOWN_MS, PAGE_SIZE, AGENT_GET_PAGE_TIMEOUT_MS, AGENT_LIST_TIMEOUT_MS, agentByIdCache, ONCHAINOS_CHAIN_INDEX;
59441
59474
  var init_onchainos = __esm({
59442
59475
  "../core/src/xmtp-sdk/onchainos/index.ts"() {
59443
59476
  "use strict";
@@ -59456,6 +59489,8 @@ var init_onchainos = __esm({
59456
59489
  lastExpiredNotifyAt = 0;
59457
59490
  EXPIRED_NOTIFY_COOLDOWN_MS = 5 * 60 * 1e3;
59458
59491
  PAGE_SIZE = 50;
59492
+ AGENT_GET_PAGE_TIMEOUT_MS = 1e4;
59493
+ AGENT_LIST_TIMEOUT_MS = 3e4;
59459
59494
  agentByIdCache = /* @__PURE__ */ new Map();
59460
59495
  ONCHAINOS_CHAIN_INDEX = "196";
59461
59496
  }
@@ -67068,6 +67103,7 @@ var init_user_attention_watchers = __esm({
67068
67103
  var listener_exports = {};
67069
67104
  __export(listener_exports, {
67070
67105
  AUTH_RECOVERY_PROBE_INTERVAL_MS: () => AUTH_RECOVERY_PROBE_INTERVAL_MS,
67106
+ AUTH_RECOVERY_REFRESH_BACKOFF_MS: () => AUTH_RECOVERY_REFRESH_BACKOFF_MS,
67071
67107
  AgentRefreshAuthGate: () => AgentRefreshAuthGate,
67072
67108
  AgentRefreshCoordinator: () => AgentRefreshCoordinator,
67073
67109
  DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC: () => DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC,
@@ -67333,7 +67369,7 @@ async function runListenerWithLock(options, paths) {
67333
67369
  }
67334
67370
  }),
67335
67371
  notifySessionExpired: (command) => {
67336
- const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login\`; A2A will recover within 60 seconds, or run \`okx-a2a agent refresh\` to recover immediately.`;
67372
+ const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login\`; A2A will retry recovery automatically within 60 seconds, or run \`okx-a2a agent refresh\` to retry immediately.`;
67337
67373
  void store.appendBackup(buildSystemStoredMessage({
67338
67374
  reason: "onchainos-session-expired",
67339
67375
  rawText,
@@ -67361,12 +67397,12 @@ async function runListenerWithLock(options, paths) {
67361
67397
  });
67362
67398
  }
67363
67399
  });
67364
- service.setPluginVersion("0.2.4-beta-e7a52faf6f-260812104443");
67400
+ service.setPluginVersion("0.2.4-beta-e7a52faf6f-260812154627");
67365
67401
  await service.init();
67366
67402
  const pluginVersionStatus = service.pluginVersionStatus;
67367
67403
  if (pluginVersionStatus.unavailable) {
67368
67404
  throw new Error(
67369
- `@okxweb3/a2a-node v${"0.2.4-beta-e7a52faf6f-260812104443"} is below the required minimum v${pluginVersionStatus.minVersion}`
67405
+ `@okxweb3/a2a-node v${"0.2.4-beta-e7a52faf6f-260812154627"} is below the required minimum v${pluginVersionStatus.minVersion}`
67370
67406
  );
67371
67407
  }
67372
67408
  const systemConfig = service.getSystemConfig();
@@ -67384,7 +67420,7 @@ async function runListenerWithLock(options, paths) {
67384
67420
  onchainosAgentId: "*",
67385
67421
  reason: "system-config missing sentryDsn",
67386
67422
  pluginId: "@okxweb3/a2a-node",
67387
- pluginVersion: "0.2.4-beta-e7a52faf6f-260812104443"
67423
+ pluginVersion: "0.2.4-beta-e7a52faf6f-260812154627"
67388
67424
  });
67389
67425
  }
67390
67426
  logWithTimestamp(
@@ -67812,7 +67848,7 @@ async function timeSettled(fn) {
67812
67848
  return { durationMs: Date.now() - startedAt, error };
67813
67849
  }
67814
67850
  }
67815
- var import_node_fs25, import_promises13, import_node_os11, import_node_path30, DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC, DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC, XMTP_CLIENT_RECYCLE_INTERVAL_ENV, HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS, AUTH_RECOVERY_PROBE_INTERVAL_MS, AgentRefreshAuthGate, AgentRefreshCoordinator, ListenerDeferredTaskScheduler, ListenerMaintenanceGate, UPGRADE_RECOMMENDATION_IDEMPOTENCY_KEY, SHUTDOWN_FORCE_RESOLVE_MS;
67851
+ var import_node_fs25, import_promises13, import_node_os11, import_node_path30, DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC, DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC, XMTP_CLIENT_RECYCLE_INTERVAL_ENV, HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS, AUTH_RECOVERY_PROBE_INTERVAL_MS, AUTH_RECOVERY_REFRESH_BACKOFF_MS, AgentRefreshAuthGate, AgentRefreshCoordinator, ListenerDeferredTaskScheduler, ListenerMaintenanceGate, UPGRADE_RECOMMENDATION_IDEMPOTENCY_KEY, SHUTDOWN_FORCE_RESOLVE_MS;
67816
67852
  var init_listener = __esm({
67817
67853
  "src/listener.ts"() {
67818
67854
  "use strict";
@@ -67846,6 +67882,7 @@ var init_listener = __esm({
67846
67882
  XMTP_CLIENT_RECYCLE_INTERVAL_ENV = "OKX_A2A_XMTP_CLIENT_RECYCLE_INTERVAL_SEC";
67847
67883
  HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS = 2e3;
67848
67884
  AUTH_RECOVERY_PROBE_INTERVAL_MS = 6e4;
67885
+ AUTH_RECOVERY_REFRESH_BACKOFF_MS = [6e4, 12e4, 3e5];
67849
67886
  AgentRefreshAuthGate = class {
67850
67887
  authBlocked = false;
67851
67888
  get blocked() {
@@ -67870,6 +67907,8 @@ var init_listener = __esm({
67870
67907
  authGate = new AgentRefreshAuthGate();
67871
67908
  refreshInFlight = null;
67872
67909
  recoveryProbeInFlight = null;
67910
+ recoveryRefreshFailureCount = 0;
67911
+ nextRecoveryRefreshAtMs = 0;
67873
67912
  get blocked() {
67874
67913
  return this.authGate.blocked;
67875
67914
  }
@@ -67878,6 +67917,8 @@ var init_listener = __esm({
67878
67917
  try {
67879
67918
  const result = await this.options.lookup(previousFingerprint);
67880
67919
  this.authGate.recordSuccess();
67920
+ this.recoveryRefreshFailureCount = 0;
67921
+ this.nextRecoveryRefreshAtMs = 0;
67881
67922
  if (wasBlocked) {
67882
67923
  this.options.onAuthRecovered?.();
67883
67924
  }
@@ -67899,7 +67940,7 @@ var init_listener = __esm({
67899
67940
  return this.runRefresh();
67900
67941
  }
67901
67942
  runRecoveryProbe() {
67902
- if (this.options.isStopping() || !this.authGate.blocked || !this.options.checkLoggedIn) {
67943
+ if (this.options.isStopping() || !this.authGate.blocked || !this.options.checkLoggedIn || this.now() < this.nextRecoveryRefreshAtMs) {
67903
67944
  return Promise.resolve(null);
67904
67945
  }
67905
67946
  if (this.recoveryProbeInFlight) {
@@ -67911,8 +67952,15 @@ var init_listener = __esm({
67911
67952
  return null;
67912
67953
  }
67913
67954
  const refresh = await this.runRefresh();
67914
- return this.authGate.blocked ? null : refresh;
67915
- })().finally(() => {
67955
+ if (this.authGate.blocked) {
67956
+ this.recordRecoveryRefreshFailure();
67957
+ return null;
67958
+ }
67959
+ return refresh;
67960
+ })().catch((err2) => {
67961
+ this.recordRecoveryRefreshFailure();
67962
+ throw err2;
67963
+ }).finally(() => {
67916
67964
  this.recoveryProbeInFlight = null;
67917
67965
  });
67918
67966
  return this.recoveryProbeInFlight;
@@ -67926,6 +67974,17 @@ var init_listener = __esm({
67926
67974
  });
67927
67975
  return this.refreshInFlight;
67928
67976
  }
67977
+ now() {
67978
+ return this.options.now?.() ?? Date.now();
67979
+ }
67980
+ recordRecoveryRefreshFailure() {
67981
+ const backoffIndex = Math.min(
67982
+ this.recoveryRefreshFailureCount,
67983
+ AUTH_RECOVERY_REFRESH_BACKOFF_MS.length - 1
67984
+ );
67985
+ this.nextRecoveryRefreshAtMs = this.now() + AUTH_RECOVERY_REFRESH_BACKOFF_MS[backoffIndex];
67986
+ this.recoveryRefreshFailureCount += 1;
67987
+ }
67929
67988
  };
67930
67989
  ListenerDeferredTaskScheduler = class {
67931
67990
  timers = /* @__PURE__ */ new Set();
@@ -115755,7 +115814,7 @@ async function getCurrentNodeCliVersion() {
115755
115814
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
115756
115815
  }
115757
115816
  function getBundledNodeCliVersion() {
115758
- return true ? "0.2.4-beta-e7a52faf6f-260812104443" : null;
115817
+ return true ? "0.2.4-beta-e7a52faf6f-260812154627" : null;
115759
115818
  }
115760
115819
  function readConfiguredAiProvider() {
115761
115820
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -115965,7 +116024,7 @@ async function updateHermes(release, options) {
115965
116024
  }
115966
116025
  }
115967
116026
  async function installGatewayPluginForDoctor(target) {
115968
- const release = isPrereleaseVersion("0.2.4-beta-e7a52faf6f-260812104443") ? "beta" : "latest";
116027
+ const release = isPrereleaseVersion("0.2.4-beta-e7a52faf6f-260812154627") ? "beta" : "latest";
115969
116028
  const insideTargetGateway = detectGatewayInvocation() === target;
115970
116029
  const options = {
115971
116030
  restart: !insideTargetGateway,
@@ -117008,7 +117067,7 @@ async function runDoctor(options = {}) {
117008
117067
  platform: options.platform ?? process.platform,
117009
117068
  env: options.env ?? process.env,
117010
117069
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
117011
- cliVersion: options.cliVersion ?? (true ? "0.2.4-beta-e7a52faf6f-260812104443" : "0.0.0"),
117070
+ cliVersion: options.cliVersion ?? (true ? "0.2.4-beta-e7a52faf6f-260812154627" : "0.0.0"),
117012
117071
  fixMode: options.fix === true,
117013
117072
  nonInteractive: options.nonInteractive === true,
117014
117073
  packageChanged: false,
@@ -118005,7 +118064,7 @@ init_sentry_logger();
118005
118064
  init_sentry_config();
118006
118065
  var CURRENT_GATEWAY_SESSION_KEYS_ENV4 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
118007
118066
  function printUsage3() {
118008
- console.log(`okx-a2a ${"0.2.4-beta-e7a52faf6f-260812104443"}
118067
+ console.log(`okx-a2a ${"0.2.4-beta-e7a52faf6f-260812154627"}
118009
118068
 
118010
118069
  Usage:
118011
118070
  okx-a2a <command> [options]
@@ -118045,7 +118104,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
118045
118104
  `);
118046
118105
  }
118047
118106
  function printVersion() {
118048
- console.log("0.2.4-beta-e7a52faf6f-260812104443");
118107
+ console.log("0.2.4-beta-e7a52faf6f-260812154627");
118049
118108
  }
118050
118109
  function printDaemonUsage() {
118051
118110
  console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
@@ -119481,7 +119540,7 @@ async function main() {
119481
119540
  if (command === "xmtp-test") {
119482
119541
  const { handleXmtpTestCommand: handleXmtpTestCommand2 } = await Promise.resolve().then(() => (init_xmtp_test_cli(), xmtp_test_cli_exports));
119483
119542
  await handleXmtpTestCommand2(process.argv.slice(3), {
119484
- packageVersion: "0.2.4-beta-e7a52faf6f-260812104443",
119543
+ packageVersion: "0.2.4-beta-e7a52faf6f-260812154627",
119485
119544
  agentSdkVersion: "2.3.0",
119486
119545
  nodeSdkVersion: "6.1.0",
119487
119546
  nodeBindingsVersion: "1.11.0"
package/dist/index.js CHANGED
@@ -32104,7 +32104,7 @@ var init_sentry_config = __esm({
32104
32104
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
32105
32105
  SENTRY_CONFIG = {
32106
32106
  projectName: "okx/openclaw-okx-a2a-extension",
32107
- release: "0.2.4-beta-e7a52faf6f-260812104443",
32107
+ release: "0.2.4-beta-e7a52faf6f-260812154627",
32108
32108
  environment,
32109
32109
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
32110
32110
  };
@@ -33045,7 +33045,7 @@ async function getCurrentNodeCliVersion() {
33045
33045
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
33046
33046
  }
33047
33047
  function getBundledNodeCliVersion() {
33048
- return true ? "0.2.4-beta-e7a52faf6f-260812104443" : null;
33048
+ return true ? "0.2.4-beta-e7a52faf6f-260812154627" : null;
33049
33049
  }
33050
33050
  function readConfiguredAiProvider() {
33051
33051
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -33255,7 +33255,7 @@ async function updateHermes(release, options) {
33255
33255
  }
33256
33256
  }
33257
33257
  async function installGatewayPluginForDoctor(target) {
33258
- const release = isPrereleaseVersion("0.2.4-beta-e7a52faf6f-260812104443") ? "beta" : "latest";
33258
+ const release = isPrereleaseVersion("0.2.4-beta-e7a52faf6f-260812154627") ? "beta" : "latest";
33259
33259
  const insideTargetGateway = detectGatewayInvocation() === target;
33260
33260
  const options = {
33261
33261
  restart: !insideTargetGateway,
@@ -43944,6 +43944,8 @@ var init_doctor_sentry = __esm({
43944
43944
  // src/index.ts
43945
43945
  var index_exports = {};
43946
43946
  __export(index_exports, {
43947
+ AGENT_GET_PAGE_TIMEOUT_MS: () => AGENT_GET_PAGE_TIMEOUT_MS,
43948
+ AGENT_LIST_TIMEOUT_MS: () => AGENT_LIST_TIMEOUT_MS,
43947
43949
  AI_PROVIDERS: () => AI_PROVIDERS,
43948
43950
  AgentMessageDirection: () => AgentMessageDirection,
43949
43951
  AgentRefreshAuthGate: () => AgentRefreshAuthGate,
@@ -43987,6 +43989,7 @@ __export(index_exports, {
43987
43989
  USER_ATTENTION_WATCH_PARENT_CHECK_MS: () => USER_ATTENTION_WATCH_PARENT_CHECK_MS,
43988
43990
  USER_ATTENTION_WATCH_REPLACED_MESSAGE: () => USER_ATTENTION_WATCH_REPLACED_MESSAGE,
43989
43991
  UserCancelledAiProviderSelectionError: () => UserCancelledAiProviderSelectionError,
43992
+ WALLET_STATUS_TIMEOUT_MS: () => WALLET_STATUS_TIMEOUT_MS,
43990
43993
  XMTP_CLIENT_RECYCLE_INTERVAL_ENV: () => XMTP_CLIENT_RECYCLE_INTERVAL_ENV,
43991
43994
  XmtpDm: () => Dm,
43992
43995
  XmtpGroup: () => Group,
@@ -44100,6 +44103,7 @@ __export(index_exports, {
44100
44103
  isWindowsElevated: () => isWindowsElevated,
44101
44104
  killProcessTree: () => killProcessTree,
44102
44105
  launchdPlistHasCurrentRestartPolicy: () => launchdPlistHasCurrentRestartPolicy,
44106
+ listAllAgentsWithMetadata: () => listAllAgentsWithMetadata,
44103
44107
  logWinCompat: () => logWinCompat,
44104
44108
  logXmtpMessageSent: () => logXmtpMessageSent,
44105
44109
  maybeRecommendOnchainosUpgrade: () => maybeRecommendOnchainosUpgrade,
@@ -44123,6 +44127,7 @@ __export(index_exports, {
44123
44127
  printXmtpTestUsage: () => printXmtpTestUsage,
44124
44128
  probeCodexAuthStatus: () => probeCodexAuthStatus,
44125
44129
  processFileMessage: () => processFileMessage,
44130
+ queryWalletLoginStatus: () => queryWalletLoginStatus,
44126
44131
  readAiProviderTimeoutMs: () => readAiProviderTimeoutMs,
44127
44132
  readCachedCodexReadiness: () => readCachedCodexReadiness,
44128
44133
  readLastLines: () => readLastLines,
@@ -58686,7 +58691,7 @@ function redactArgsForLog(args) {
58686
58691
  function commandForLog(bin, args) {
58687
58692
  return `${bin} ${redactArgsForLog(args).join(" ")}`;
58688
58693
  }
58689
- async function exec(args) {
58694
+ async function exec(args, options = {}) {
58690
58695
  const bin = await resolve6();
58691
58696
  const cmd = commandForLog(bin, args);
58692
58697
  logWithTimestamp(`[onchainos] exec: ${cmd}`);
@@ -58700,7 +58705,8 @@ async function exec(args) {
58700
58705
  try {
58701
58706
  const result = await execFileAsync2(invocation.command, invocation.args, {
58702
58707
  windowsHide: true,
58703
- windowsVerbatimArguments: invocation.windowsVerbatimArguments
58708
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
58709
+ timeout: options.timeoutMs
58704
58710
  });
58705
58711
  logWithTimestamp(
58706
58712
  `[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
@@ -58733,7 +58739,8 @@ async function exec(args) {
58733
58739
  stdoutBytes: String(Buffer.byteLength(String(err?.stdout ?? ""), "utf8")),
58734
58740
  cliErrorName: err instanceof Error ? err.name : "",
58735
58741
  cliErrorMessageLength: String(String(err?.message ?? "").length),
58736
- durationMs: String(Date.now() - t0)
58742
+ durationMs: String(Date.now() - t0),
58743
+ timeoutMs: String(options.timeoutMs ?? "")
58737
58744
  }
58738
58745
  );
58739
58746
  throw err;
@@ -58951,6 +58958,7 @@ async function fetchSystemConfig(options) {
58951
58958
  // ../core/src/xmtp-sdk/onchainos/wallet-status.ts
58952
58959
  init_log();
58953
58960
  init_sentry_logger();
58961
+ var WALLET_STATUS_TIMEOUT_MS = 1e4;
58954
58962
  function parseWalletLoginStatus(stdout) {
58955
58963
  const response = parseCliJson(stdout, "wallet-status");
58956
58964
  if (!response.ok) {
@@ -58976,9 +58984,12 @@ function parseWalletLoginStatus(stdout) {
58976
58984
  }
58977
58985
  return response.data.loggedIn;
58978
58986
  }
58979
- async function queryWalletLoginStatus() {
58987
+ async function queryWalletLoginStatus(options = {}) {
58980
58988
  logWithTimestamp("[onchainos] checking wallet login status");
58981
- const { stdout } = await exec(["wallet", "status"]);
58989
+ const { stdout } = await exec(
58990
+ ["wallet", "status"],
58991
+ { timeoutMs: options.timeoutMs ?? WALLET_STATUS_TIMEOUT_MS }
58992
+ );
58982
58993
  const loggedIn = parseWalletLoginStatus(stdout);
58983
58994
  logWithTimestamp(`[onchainos] wallet login status: ${loggedIn ? "logged in" : "logged out"}`);
58984
58995
  return loggedIn;
@@ -59047,6 +59058,8 @@ function guardCatchSessionExpired2(err, command) {
59047
59058
  }
59048
59059
  }
59049
59060
  var PAGE_SIZE = 50;
59061
+ var AGENT_GET_PAGE_TIMEOUT_MS = 1e4;
59062
+ var AGENT_LIST_TIMEOUT_MS = 3e4;
59050
59063
  function isJsonString(value) {
59051
59064
  try {
59052
59065
  JSON.parse(value);
@@ -59072,19 +59085,22 @@ function logAgentListResponse(input) {
59072
59085
  onchainosAgentListDiagnosticText: input.stderr
59073
59086
  });
59074
59087
  }
59075
- async function fetchAgentPage(page) {
59088
+ async function fetchAgentPage(page, timeoutMs) {
59076
59089
  const startedAt = Date.now();
59077
59090
  let stdout;
59078
59091
  let stderr;
59079
59092
  try {
59080
- ({ stdout, stderr } = await exec([
59081
- "agent",
59082
- "get",
59083
- "--page",
59084
- String(page),
59085
- "--page-size",
59086
- String(PAGE_SIZE)
59087
- ]));
59093
+ ({ stdout, stderr } = await exec(
59094
+ [
59095
+ "agent",
59096
+ "get",
59097
+ "--page",
59098
+ String(page),
59099
+ "--page-size",
59100
+ String(PAGE_SIZE)
59101
+ ],
59102
+ { timeoutMs }
59103
+ ));
59088
59104
  } catch (err) {
59089
59105
  const errStdout = typeof err?.stdout === "string" ? err.stdout : "";
59090
59106
  const errStderr = typeof err?.stderr === "string" ? err.stderr : "";
@@ -59230,13 +59246,28 @@ async function fetchAgentByAddress(communicationAddress) {
59230
59246
  agentByIdCache.set(res.data.agentId, res.data);
59231
59247
  return res.data;
59232
59248
  }
59233
- async function listAllAgentsWithMetadata(previousFingerprint) {
59249
+ async function listAllAgentsWithMetadata(previousFingerprint, options = {}) {
59234
59250
  const startedAt = Date.now();
59251
+ const pageTimeoutMs = positiveTimeoutOrDefault(
59252
+ options.pageTimeoutMs,
59253
+ AGENT_GET_PAGE_TIMEOUT_MS
59254
+ );
59255
+ const totalTimeoutMs = positiveTimeoutOrDefault(
59256
+ options.totalTimeoutMs,
59257
+ AGENT_LIST_TIMEOUT_MS
59258
+ );
59235
59259
  const agents = [];
59236
59260
  const stderrs = [];
59237
59261
  let page = 1;
59238
59262
  while (true) {
59239
- const { data, stderr } = await fetchAgentPage(page);
59263
+ const remainingMs = totalTimeoutMs - (Date.now() - startedAt);
59264
+ if (remainingMs <= 0) {
59265
+ throw agentListTimeoutError(totalTimeoutMs);
59266
+ }
59267
+ const { data, stderr } = await fetchAgentPage(
59268
+ page,
59269
+ Math.min(pageTimeoutMs, remainingMs)
59270
+ );
59240
59271
  if (stderr) {
59241
59272
  stderrs.push(`page=${page}: ${stderr}`);
59242
59273
  }
@@ -59263,6 +59294,14 @@ async function listAllAgentsWithMetadata(previousFingerprint) {
59263
59294
  durationMs: Date.now() - startedAt
59264
59295
  };
59265
59296
  }
59297
+ function positiveTimeoutOrDefault(value, fallback) {
59298
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
59299
+ }
59300
+ function agentListTimeoutError(timeoutMs) {
59301
+ const error = new Error(`onchainos agent list timed out after ${timeoutMs}ms`);
59302
+ error.code = "ETIMEDOUT";
59303
+ return error;
59304
+ }
59266
59305
  function fingerprintAgents(agents) {
59267
59306
  return agents.map((a) => [
59268
59307
  a.agentId,
@@ -60242,7 +60281,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
60242
60281
  client: {
60243
60282
  id: "gateway-client",
60244
60283
  displayName: "okx-a2a-node",
60245
- version: "0.2.4-beta-e7a52faf6f-260812104443",
60284
+ version: "0.2.4-beta-e7a52faf6f-260812154627",
60246
60285
  platform: "node",
60247
60286
  mode: "backend",
60248
60287
  instanceId
@@ -60253,7 +60292,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
60253
60292
  commands: [],
60254
60293
  permissions: {},
60255
60294
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
60256
- userAgent: `okx-a2a-node/${"0.2.4-beta-e7a52faf6f-260812104443"}`,
60295
+ userAgent: `okx-a2a-node/${"0.2.4-beta-e7a52faf6f-260812154627"}`,
60257
60296
  auth: {
60258
60297
  ...config.token ? { token: config.token } : {},
60259
60298
  ...config.password ? { password: config.password } : {}
@@ -66036,6 +66075,7 @@ var DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC = 6 * 60 * 60;
66036
66075
  var XMTP_CLIENT_RECYCLE_INTERVAL_ENV = "OKX_A2A_XMTP_CLIENT_RECYCLE_INTERVAL_SEC";
66037
66076
  var HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS = 2e3;
66038
66077
  var AUTH_RECOVERY_PROBE_INTERVAL_MS = 6e4;
66078
+ var AUTH_RECOVERY_REFRESH_BACKOFF_MS = [6e4, 12e4, 3e5];
66039
66079
  async function runHeartbeatRefreshCycle(options) {
66040
66080
  const heartbeat = await timeSettled(options.heartbeat);
66041
66081
  const refreshAllowed = heartbeat.value === "performed" || heartbeat.value === "refresh_safe";
@@ -66066,6 +66106,8 @@ var AgentRefreshCoordinator = class {
66066
66106
  authGate = new AgentRefreshAuthGate();
66067
66107
  refreshInFlight = null;
66068
66108
  recoveryProbeInFlight = null;
66109
+ recoveryRefreshFailureCount = 0;
66110
+ nextRecoveryRefreshAtMs = 0;
66069
66111
  get blocked() {
66070
66112
  return this.authGate.blocked;
66071
66113
  }
@@ -66074,6 +66116,8 @@ var AgentRefreshCoordinator = class {
66074
66116
  try {
66075
66117
  const result = await this.options.lookup(previousFingerprint);
66076
66118
  this.authGate.recordSuccess();
66119
+ this.recoveryRefreshFailureCount = 0;
66120
+ this.nextRecoveryRefreshAtMs = 0;
66077
66121
  if (wasBlocked) {
66078
66122
  this.options.onAuthRecovered?.();
66079
66123
  }
@@ -66095,7 +66139,7 @@ var AgentRefreshCoordinator = class {
66095
66139
  return this.runRefresh();
66096
66140
  }
66097
66141
  runRecoveryProbe() {
66098
- if (this.options.isStopping() || !this.authGate.blocked || !this.options.checkLoggedIn) {
66142
+ if (this.options.isStopping() || !this.authGate.blocked || !this.options.checkLoggedIn || this.now() < this.nextRecoveryRefreshAtMs) {
66099
66143
  return Promise.resolve(null);
66100
66144
  }
66101
66145
  if (this.recoveryProbeInFlight) {
@@ -66107,8 +66151,15 @@ var AgentRefreshCoordinator = class {
66107
66151
  return null;
66108
66152
  }
66109
66153
  const refresh = await this.runRefresh();
66110
- return this.authGate.blocked ? null : refresh;
66111
- })().finally(() => {
66154
+ if (this.authGate.blocked) {
66155
+ this.recordRecoveryRefreshFailure();
66156
+ return null;
66157
+ }
66158
+ return refresh;
66159
+ })().catch((err) => {
66160
+ this.recordRecoveryRefreshFailure();
66161
+ throw err;
66162
+ }).finally(() => {
66112
66163
  this.recoveryProbeInFlight = null;
66113
66164
  });
66114
66165
  return this.recoveryProbeInFlight;
@@ -66122,6 +66173,17 @@ var AgentRefreshCoordinator = class {
66122
66173
  });
66123
66174
  return this.refreshInFlight;
66124
66175
  }
66176
+ now() {
66177
+ return this.options.now?.() ?? Date.now();
66178
+ }
66179
+ recordRecoveryRefreshFailure() {
66180
+ const backoffIndex = Math.min(
66181
+ this.recoveryRefreshFailureCount,
66182
+ AUTH_RECOVERY_REFRESH_BACKOFF_MS.length - 1
66183
+ );
66184
+ this.nextRecoveryRefreshAtMs = this.now() + AUTH_RECOVERY_REFRESH_BACKOFF_MS[backoffIndex];
66185
+ this.recoveryRefreshFailureCount += 1;
66186
+ }
66125
66187
  };
66126
66188
  var ListenerDeferredTaskScheduler = class {
66127
66189
  timers = /* @__PURE__ */ new Set();
@@ -66417,7 +66479,7 @@ async function runListenerWithLock(options, paths) {
66417
66479
  }
66418
66480
  }),
66419
66481
  notifySessionExpired: (command) => {
66420
- const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login\`; A2A will recover within 60 seconds, or run \`okx-a2a agent refresh\` to recover immediately.`;
66482
+ const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login\`; A2A will retry recovery automatically within 60 seconds, or run \`okx-a2a agent refresh\` to retry immediately.`;
66421
66483
  void store.appendBackup(buildSystemStoredMessage({
66422
66484
  reason: "onchainos-session-expired",
66423
66485
  rawText,
@@ -66445,12 +66507,12 @@ async function runListenerWithLock(options, paths) {
66445
66507
  });
66446
66508
  }
66447
66509
  });
66448
- service.setPluginVersion("0.2.4-beta-e7a52faf6f-260812104443");
66510
+ service.setPluginVersion("0.2.4-beta-e7a52faf6f-260812154627");
66449
66511
  await service.init();
66450
66512
  const pluginVersionStatus = service.pluginVersionStatus;
66451
66513
  if (pluginVersionStatus.unavailable) {
66452
66514
  throw new Error(
66453
- `@okxweb3/a2a-node v${"0.2.4-beta-e7a52faf6f-260812104443"} is below the required minimum v${pluginVersionStatus.minVersion}`
66515
+ `@okxweb3/a2a-node v${"0.2.4-beta-e7a52faf6f-260812154627"} is below the required minimum v${pluginVersionStatus.minVersion}`
66454
66516
  );
66455
66517
  }
66456
66518
  const systemConfig = service.getSystemConfig();
@@ -66468,7 +66530,7 @@ async function runListenerWithLock(options, paths) {
66468
66530
  onchainosAgentId: "*",
66469
66531
  reason: "system-config missing sentryDsn",
66470
66532
  pluginId: "@okxweb3/a2a-node",
66471
- pluginVersion: "0.2.4-beta-e7a52faf6f-260812104443"
66533
+ pluginVersion: "0.2.4-beta-e7a52faf6f-260812154627"
66472
66534
  });
66473
66535
  }
66474
66536
  logWithTimestamp(
@@ -69166,7 +69228,7 @@ async function exportDiagnosticLogs(options) {
69166
69228
  node: process.version,
69167
69229
  platform: process.platform,
69168
69230
  arch: process.arch,
69169
- packageVersion: true ? "0.2.4-beta-e7a52faf6f-260812104443" : "unknown",
69231
+ packageVersion: true ? "0.2.4-beta-e7a52faf6f-260812154627" : "unknown",
69170
69232
  sensitiveContentIncluded: options.includeSensitiveContent,
69171
69233
  listenerAndLlmContentIncluded: true,
69172
69234
  credentialsAlwaysRedacted: true,
@@ -71002,7 +71064,7 @@ async function runDoctor(options = {}) {
71002
71064
  platform: options.platform ?? process.platform,
71003
71065
  env: options.env ?? process.env,
71004
71066
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
71005
- cliVersion: options.cliVersion ?? (true ? "0.2.4-beta-e7a52faf6f-260812104443" : "0.0.0"),
71067
+ cliVersion: options.cliVersion ?? (true ? "0.2.4-beta-e7a52faf6f-260812154627" : "0.0.0"),
71006
71068
  fixMode: options.fix === true,
71007
71069
  nonInteractive: options.nonInteractive === true,
71008
71070
  packageChanged: false,
@@ -71223,6 +71285,8 @@ init_win_native_launcher();
71223
71285
  init_autostart_windows();
71224
71286
  // Annotate the CommonJS export names for ESM import in node:
71225
71287
  0 && (module.exports = {
71288
+ AGENT_GET_PAGE_TIMEOUT_MS,
71289
+ AGENT_LIST_TIMEOUT_MS,
71226
71290
  AI_PROVIDERS,
71227
71291
  AgentMessageDirection,
71228
71292
  AgentRefreshAuthGate,
@@ -71266,6 +71330,7 @@ init_autostart_windows();
71266
71330
  USER_ATTENTION_WATCH_PARENT_CHECK_MS,
71267
71331
  USER_ATTENTION_WATCH_REPLACED_MESSAGE,
71268
71332
  UserCancelledAiProviderSelectionError,
71333
+ WALLET_STATUS_TIMEOUT_MS,
71269
71334
  XMTP_CLIENT_RECYCLE_INTERVAL_ENV,
71270
71335
  XmtpDm,
71271
71336
  XmtpGroup,
@@ -71379,6 +71444,7 @@ init_autostart_windows();
71379
71444
  isWindowsElevated,
71380
71445
  killProcessTree,
71381
71446
  launchdPlistHasCurrentRestartPolicy,
71447
+ listAllAgentsWithMetadata,
71382
71448
  logWinCompat,
71383
71449
  logXmtpMessageSent,
71384
71450
  maybeRecommendOnchainosUpgrade,
@@ -71402,6 +71468,7 @@ init_autostart_windows();
71402
71468
  printXmtpTestUsage,
71403
71469
  probeCodexAuthStatus,
71404
71470
  processFileMessage,
71471
+ queryWalletLoginStatus,
71405
71472
  readAiProviderTimeoutMs,
71406
71473
  readCachedCodexReadiness,
71407
71474
  readLastLines,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okxweb3/a2a-node",
3
- "version": "0.2.4-beta-e7a52faf6f-260812104443",
3
+ "version": "0.2.4-beta-e7a52faf6f-260812154627",
4
4
  "description": "Host-agnostic Node CLI for E2E encrypted agent-to-agent communication via XMTP",
5
5
  "main": "dist/index.js",
6
6
  "bin": {