@okxweb3/a2a-node 0.2.10-beta-1a0d85b27f-260828092722 → 0.2.10

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 +426 -112
  2. package/dist/index.js +449 -107
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32437,7 +32437,7 @@ var init_sentry_config = __esm({
32437
32437
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
32438
32438
  SENTRY_CONFIG = {
32439
32439
  projectName: "okx/openclaw-okx-a2a-extension",
32440
- release: "0.2.10-beta-1a0d85b27f-260828092722",
32440
+ release: "0.2.10",
32441
32441
  environment,
32442
32442
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
32443
32443
  };
@@ -33378,7 +33378,7 @@ async function getCurrentNodeCliVersion() {
33378
33378
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
33379
33379
  }
33380
33380
  function getBundledNodeCliVersion() {
33381
- return true ? "0.2.10-beta-1a0d85b27f-260828092722" : null;
33381
+ return true ? "0.2.10" : null;
33382
33382
  }
33383
33383
  function readConfiguredAiProvider() {
33384
33384
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -33588,7 +33588,7 @@ async function updateHermes(release, options) {
33588
33588
  }
33589
33589
  }
33590
33590
  async function installGatewayPluginForDoctor(target) {
33591
- const release = isPrereleaseVersion("0.2.10-beta-1a0d85b27f-260828092722") ? "beta" : "latest";
33591
+ const release = isPrereleaseVersion("0.2.10") ? "beta" : "latest";
33592
33592
  const insideTargetGateway = detectGatewayInvocation() === target;
33593
33593
  const options = {
33594
33594
  restart: !insideTargetGateway,
@@ -44420,6 +44420,7 @@ __export(index_exports, {
44420
44420
  getA2ACapabilities: () => getA2ACapabilities,
44421
44421
  getDaemonStatus: () => getDaemonStatus,
44422
44422
  getHermesGatewayPluginStatus: () => getHermesGatewayPluginStatus,
44423
+ getResolvedOnchainosBinForTests: () => getResolvedOnchainosBinForTests,
44423
44424
  getRuntimeMetadata: () => getRuntimeMetadata,
44424
44425
  getSessionBusyTracker: () => getSessionBusyTracker,
44425
44426
  handleCapabilitiesCommand: () => handleCapabilitiesCommand,
@@ -44435,6 +44436,7 @@ __export(index_exports, {
44435
44436
  installWindowsNativeLauncher: () => installWindowsNativeLauncher,
44436
44437
  installedAutostartHasCurrentConfiguration: () => installedAutostartHasCurrentConfiguration,
44437
44438
  installedAutostartHasCurrentRestartPolicy: () => installedAutostartHasCurrentRestartPolicy,
44439
+ invalidateResolvedOnchainosBinForTests: () => invalidateResolvedOnchainosBinForTests,
44438
44440
  isAutostartManagerUnavailableError: () => isAutostartManagerUnavailableError,
44439
44441
  isDefaultTaskHome: () => isDefaultTaskHome,
44440
44442
  isGatewayAvailableForHeartbeat: () => isGatewayAvailableForHeartbeat,
@@ -44515,6 +44517,7 @@ __export(index_exports, {
44515
44517
  resolveNpmCmdShimScript: () => resolveNpmCmdShimScript,
44516
44518
  resolveOfflineReplayCapabilityMarker: () => resolveOfflineReplayCapabilityMarker,
44517
44519
  resolveOfflineReplayIntervalSec: () => resolveOfflineReplayIntervalSec,
44520
+ resolveOnchainosBinForTests: () => resolveOnchainosBinForTests,
44518
44521
  resolveOpenClawGatewayConfig: () => resolveOpenClawGatewayConfig,
44519
44522
  resolveOpenClawGatewayRoute: () => resolveOpenClawGatewayRoute,
44520
44523
  resolveOpenClawGatewayRoutes: () => resolveOpenClawGatewayRoutes,
@@ -46015,15 +46018,15 @@ var AiRunner = class {
46015
46018
  output: fullOutputForClassification,
46016
46019
  timedOut
46017
46020
  });
46021
+ const runCompletedSuccessfully = provider === "codex" && !timedOut && exitCode === 0 && closeResult.signal === null && aiSessionId !== null && toolFailures.turnCompleted();
46018
46022
  const syntheticToolFailure = synthesizeCodexProsePermissionFailure({
46019
46023
  provider,
46020
46024
  existingFailures: toolFailures.failures,
46021
46025
  errorType: fullOutputErrorType,
46022
- output: fullOutputForClassification,
46026
+ output: runCompletedSuccessfully ? stdoutFull : fullOutputForClassification,
46023
46027
  exitCode
46024
46028
  });
46025
46029
  const detectedToolFailures = syntheticToolFailure ? [...toolFailures.failures, syntheticToolFailure] : toolFailures.failures;
46026
- const runCompletedSuccessfully = provider === "codex" && !timedOut && exitCode === 0 && closeResult.signal === null && aiSessionId !== null && toolFailures.turnCompleted();
46027
46030
  const reportableToolFailures = selectReportableAiToolFailures({
46028
46031
  provider,
46029
46032
  failures: detectedToolFailures,
@@ -59157,14 +59160,40 @@ init_runtime_metadata();
59157
59160
  init_win_compat();
59158
59161
  var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process6.execFile);
59159
59162
  var resolvedBin = null;
59163
+ var resolvedForEnvBin = null;
59164
+ var resolverRevision = 0;
59160
59165
  var versionProbeInFlight = null;
59166
+ var posixDiscoveryFlights = /* @__PURE__ */ new Map();
59161
59167
  var REDACTED_VALUE_FLAGS = /* @__PURE__ */ new Set(["--message"]);
59168
+ var COMMAND_UNAVAILABLE_CODES = /* @__PURE__ */ new Set(["EACCES", "ENOENT", "ENOTDIR"]);
59162
59169
  var ONCHAINOS_VERSION_PROBE_TIMEOUT_MS = 5e3;
59163
59170
  var ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS = 5e3;
59164
59171
  function resetResolvedOnchainosBinForTests() {
59165
59172
  resolvedBin = null;
59173
+ resolvedForEnvBin = null;
59174
+ resolverRevision += 1;
59175
+ posixDiscoveryFlights.clear();
59166
59176
  versionProbeInFlight = null;
59167
59177
  }
59178
+ function getResolvedOnchainosBinForTests() {
59179
+ return {
59180
+ bin: resolvedBin,
59181
+ envBin: resolvedForEnvBin,
59182
+ revision: resolverRevision,
59183
+ discoveryFlightCount: posixDiscoveryFlights.size,
59184
+ discoveryJoinCount: [...posixDiscoveryFlights.values()].reduce(
59185
+ (total, flight) => total + flight.joinCount,
59186
+ 0
59187
+ )
59188
+ };
59189
+ }
59190
+ async function resolveOnchainosBinForTests(timeoutMs = ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS, excludedBin) {
59191
+ const excludedAttempt = excludedBin ? { bin: excludedBin, revision: resolverRevision } : void 0;
59192
+ return (await resolveBinSelection(timeoutMs, excludedAttempt)).bin;
59193
+ }
59194
+ function invalidateResolvedOnchainosBinForTests(bin, revision) {
59195
+ return invalidateResolvedBin(bin, "test requested invalidation", revision);
59196
+ }
59168
59197
  async function refreshOnchainosVersionMetadata(options = {}) {
59169
59198
  const now = options.now ?? Date.now;
59170
59199
  const current = getRuntimeMetadata();
@@ -59173,13 +59202,11 @@ async function refreshOnchainosVersionMetadata(options = {}) {
59173
59202
  if (versionProbeInFlight) {
59174
59203
  return versionProbeInFlight;
59175
59204
  }
59176
- versionProbeInFlight = (async () => {
59205
+ const probe = (async () => {
59177
59206
  const observedAtMs = now();
59178
59207
  try {
59179
- const bin = await resolve6(
59180
- options.resolveTimeoutMs ?? ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS
59181
- );
59182
- const output = options.runVersionCommand ? await options.runVersionCommand(bin) : await runVersionCommand(bin);
59208
+ const resolveTimeoutMs = options.resolveTimeoutMs ?? ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS;
59209
+ const output = options.runVersionCommand ? await options.runVersionCommand(await resolve6(resolveTimeoutMs)) : await runVersionCommand(resolveTimeoutMs);
59183
59210
  const version3 = parseOnchainosVersionOutput(output);
59184
59211
  if (version3 === UNKNOWN_RUNTIME_METADATA) {
59185
59212
  throw new Error("OnchainOS version output did not contain a semantic version");
@@ -59230,68 +59257,311 @@ async function refreshOnchainosVersionMetadata(options = {}) {
59230
59257
  probeStatus: "failed",
59231
59258
  changed: false
59232
59259
  };
59233
- } finally {
59234
- versionProbeInFlight = null;
59235
59260
  }
59236
59261
  })();
59237
- return versionProbeInFlight;
59262
+ versionProbeInFlight = probe;
59263
+ const clearProbe = () => {
59264
+ if (versionProbeInFlight === probe) {
59265
+ versionProbeInFlight = null;
59266
+ }
59267
+ };
59268
+ void probe.then(clearProbe, clearProbe);
59269
+ return probe;
59270
+ }
59271
+ async function runVersionCommand(resolveTimeoutMs) {
59272
+ let excludedAttempt;
59273
+ for (let attempt = 0; attempt < 2; attempt++) {
59274
+ const selection = await resolveBinSelection(
59275
+ resolveTimeoutMs,
59276
+ excludedAttempt
59277
+ );
59278
+ const { bin } = selection;
59279
+ const invocation = toWindowsInvocation(bin, ["--version"]);
59280
+ try {
59281
+ const result = await execFileAsync2(invocation.command, invocation.args, {
59282
+ windowsHide: true,
59283
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
59284
+ timeout: ONCHAINOS_VERSION_PROBE_TIMEOUT_MS
59285
+ });
59286
+ rememberSuccessfulBareBin(bin);
59287
+ return [result.stdout, result.stderr].filter(Boolean).join("\n");
59288
+ } catch (err) {
59289
+ if (attempt === 0 && isCommandUnavailableError(err)) {
59290
+ invalidateResolvedBin(
59291
+ bin,
59292
+ "version probe could not launch the cached binary",
59293
+ selection.revision
59294
+ );
59295
+ if (shouldRetryUnavailableBin(bin)) {
59296
+ excludedAttempt = selection;
59297
+ continue;
59298
+ }
59299
+ }
59300
+ throw err;
59301
+ }
59302
+ }
59303
+ throw new Error("OnchainOS version command retry exhausted");
59238
59304
  }
59239
- async function runVersionCommand(bin) {
59240
- const invocation = toWindowsInvocation(bin, ["--version"]);
59241
- const result = await execFileAsync2(invocation.command, invocation.args, {
59242
- windowsHide: true,
59243
- windowsVerbatimArguments: invocation.windowsVerbatimArguments,
59244
- timeout: ONCHAINOS_VERSION_PROBE_TIMEOUT_MS
59305
+ function configuredEnvBin() {
59306
+ return process.env.ONCHAINOS_BIN?.trim() || null;
59307
+ }
59308
+ function isPathLikeCommand(command) {
59309
+ return command.includes("/") || command.includes("\\");
59310
+ }
59311
+ function isResolvedBinUsable(bin) {
59312
+ if (!isPathLikeCommand(bin)) {
59313
+ return true;
59314
+ }
59315
+ return process.platform === "win32" ? (0, import_node_fs16.existsSync)(bin) : isExecutable2(bin);
59316
+ }
59317
+ function resolvePosixBareCommand(command, pathValue) {
59318
+ for (const dir of pathValue.split(":")) {
59319
+ const candidate = (0, import_node_path22.join)(dir || ".", command);
59320
+ if (isExecutable2(candidate)) {
59321
+ return candidate;
59322
+ }
59323
+ }
59324
+ return null;
59325
+ }
59326
+ function resolveConfiguredBin(bin) {
59327
+ if (isPathLikeCommand(bin)) {
59328
+ return isResolvedBinUsable(bin) ? bin : null;
59329
+ }
59330
+ if (process.platform === "win32") {
59331
+ return resolveWin32BareCommandCandidate(
59332
+ bin,
59333
+ process.env.PATH ?? process.env.Path ?? "",
59334
+ process.env.PATHEXT ?? process.env.PathExt ?? ".COM;.EXE;.BAT;.CMD",
59335
+ process.env.USERPROFILE
59336
+ );
59337
+ }
59338
+ return resolvePosixBareCommand(bin, process.env.PATH ?? "");
59339
+ }
59340
+ function cacheResolvedBin(bin, envBin) {
59341
+ resolvedBin = bin;
59342
+ resolvedForEnvBin = envBin;
59343
+ resolverRevision += 1;
59344
+ return { bin, revision: resolverRevision };
59345
+ }
59346
+ function rememberSuccessfulBareBin(bin) {
59347
+ if (process.platform !== "win32" && resolvedBin === null && !isPathLikeCommand(bin)) {
59348
+ cacheResolvedBin(bin, configuredEnvBin());
59349
+ }
59350
+ }
59351
+ function invalidateResolvedBin(bin, reason, expectedRevision) {
59352
+ if (resolvedBin !== bin || expectedRevision !== void 0 && resolverRevision !== expectedRevision) {
59353
+ return false;
59354
+ }
59355
+ logWithTimestamp(
59356
+ `[onchainos] invalidating cached binary ${bin}: ${reason}; rediscovering`
59357
+ );
59358
+ resolvedBin = null;
59359
+ resolvedForEnvBin = null;
59360
+ resolverRevision += 1;
59361
+ return true;
59362
+ }
59363
+ function isCommandUnavailableError(err) {
59364
+ const code = err?.code;
59365
+ return typeof code === "string" && COMMAND_UNAVAILABLE_CODES.has(code);
59366
+ }
59367
+ function shouldRetryUnavailableBin(bin) {
59368
+ if (!isPathLikeCommand(bin)) {
59369
+ return false;
59370
+ }
59371
+ return true;
59372
+ }
59373
+ function currentPosixDiscoveryContextKey() {
59374
+ return JSON.stringify({
59375
+ onchainosBin: configuredEnvBin(),
59376
+ shell: process.env.SHELL || "/bin/bash",
59377
+ path: process.env.PATH ?? "",
59378
+ home: process.env.HOME ?? "",
59379
+ zDotDir: process.env.ZDOTDIR ?? "",
59380
+ bashEnv: process.env.BASH_ENV ?? "",
59381
+ env: process.env.ENV ?? "",
59382
+ cwd: process.cwd()
59245
59383
  });
59246
- return [result.stdout, result.stderr].filter(Boolean).join("\n");
59247
59384
  }
59248
- async function resolve6(timeoutMs) {
59385
+ function createPosixDiscoverySnapshot(envBin, excludedBin, timeoutMs) {
59386
+ const revision = resolverRevision;
59387
+ const contextKey = currentPosixDiscoveryContextKey();
59388
+ const excluded = excludedBin ?? null;
59389
+ return {
59390
+ revision,
59391
+ contextKey,
59392
+ // Exclusions represent binaries that failed to launch, so they are safe
59393
+ // to union across callers sharing this resolver generation. Keeping them
59394
+ // out of the key lets a late request join an ongoing recovery discovery.
59395
+ flightKey: JSON.stringify([revision, contextKey, timeoutMs]),
59396
+ envBin,
59397
+ excludedBin: excluded,
59398
+ shell: process.env.SHELL || "/bin/bash",
59399
+ childEnv: { ...process.env }
59400
+ };
59401
+ }
59402
+ function isPosixDiscoverySnapshotCurrent(snapshot) {
59403
+ return resolverRevision === snapshot.revision && currentPosixDiscoveryContextKey() === snapshot.contextKey;
59404
+ }
59405
+ function getOrCreatePosixDiscovery(snapshot, remainingTimeoutMs) {
59406
+ const existing = posixDiscoveryFlights.get(snapshot.flightKey);
59407
+ if (existing) {
59408
+ if (snapshot.excludedBin) {
59409
+ existing.excludedBins.add(snapshot.excludedBin);
59410
+ }
59411
+ existing.joinCount += 1;
59412
+ logWithTimestamp("[onchainos] joining in-flight binary discovery");
59413
+ return existing;
59414
+ }
59415
+ const excludedBins = /* @__PURE__ */ new Set();
59416
+ if (snapshot.excludedBin) {
59417
+ excludedBins.add(snapshot.excludedBin);
59418
+ }
59419
+ const expiresAtMs = Date.now() + remainingTimeoutMs;
59420
+ const discovery = (async () => {
59421
+ try {
59422
+ const { stdout } = await execFileAsync2(
59423
+ snapshot.shell,
59424
+ ["-lc", "command -v onchainos"],
59425
+ {
59426
+ env: snapshot.childEnv,
59427
+ windowsHide: true,
59428
+ timeout: remainingTimeoutMs
59429
+ }
59430
+ );
59431
+ const bin = extractExecutablePath(stdout);
59432
+ return bin ? { status: "found", bin } : { status: "not_found" };
59433
+ } catch (err) {
59434
+ if (isPosixDiscoveryTimeoutError(err, expiresAtMs)) {
59435
+ logWithTimestamp(
59436
+ "[onchainos] shell resolve timed out; callers with time remaining may retry"
59437
+ );
59438
+ return { status: "timed_out" };
59439
+ }
59440
+ logWithTimestamp(
59441
+ "[onchainos] shell resolve failed, will fallback to bare 'onchainos':",
59442
+ err
59443
+ );
59444
+ return { status: "not_found" };
59445
+ }
59446
+ })();
59447
+ const clearFlight = () => {
59448
+ if (posixDiscoveryFlights.get(snapshot.flightKey) === flight) {
59449
+ posixDiscoveryFlights.delete(snapshot.flightKey);
59450
+ }
59451
+ };
59452
+ const flight = {
59453
+ excludedBins,
59454
+ expiresAtMs,
59455
+ joinCount: 0,
59456
+ promise: discovery.then(
59457
+ (result) => {
59458
+ clearFlight();
59459
+ return result;
59460
+ },
59461
+ (err) => {
59462
+ clearFlight();
59463
+ throw err;
59464
+ }
59465
+ )
59466
+ };
59467
+ posixDiscoveryFlights.set(snapshot.flightKey, flight);
59468
+ return flight;
59469
+ }
59470
+ function isPosixDiscoveryTimeoutError(err, expiresAtMs) {
59471
+ const timeoutError = err;
59472
+ return timeoutError?.killed === true || timeoutError?.code === "ETIMEDOUT" || Date.now() >= expiresAtMs;
59473
+ }
59474
+ async function resolveBinSelection(timeoutMs = ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS, excludedAttempt, deadlineMs = Date.now() + timeoutMs) {
59475
+ const excludedBin = excludedAttempt && !(resolvedBin === excludedAttempt.bin && resolverRevision !== excludedAttempt.revision) ? excludedAttempt.bin : void 0;
59476
+ const envBin = configuredEnvBin();
59477
+ const explicitCandidate = envBin && envBin !== excludedBin ? resolveConfiguredBin(envBin) : null;
59249
59478
  if (resolvedBin) {
59250
- return resolvedBin;
59479
+ if (resolvedBin === excludedBin) {
59480
+ invalidateResolvedBin(
59481
+ resolvedBin,
59482
+ "previous launch attempt could not start",
59483
+ excludedAttempt?.revision
59484
+ );
59485
+ }
59486
+ }
59487
+ if (resolvedBin) {
59488
+ const explicitBinRecovered = explicitCandidate !== null && explicitCandidate !== resolvedBin;
59489
+ if (resolvedForEnvBin === envBin && isResolvedBinUsable(resolvedBin) && !explicitBinRecovered) {
59490
+ return { bin: resolvedBin, revision: resolverRevision };
59491
+ }
59492
+ invalidateResolvedBin(
59493
+ resolvedBin,
59494
+ explicitBinRecovered ? "ONCHAINOS_BIN is available again" : resolvedForEnvBin !== envBin ? "ONCHAINOS_BIN changed" : "cached path is no longer executable"
59495
+ );
59251
59496
  }
59252
- const envBin = process.env.ONCHAINOS_BIN;
59253
59497
  if (envBin) {
59254
- logWithTimestamp(`[onchainos] using ONCHAINOS_BIN=${envBin}`);
59255
- resolvedBin = envBin;
59256
- return resolvedBin;
59498
+ if (explicitCandidate && explicitCandidate !== excludedBin) {
59499
+ logWithTimestamp(
59500
+ explicitCandidate === envBin ? `[onchainos] using ONCHAINOS_BIN=${envBin}` : `[onchainos] resolved ONCHAINOS_BIN=${envBin} to ${explicitCandidate}`
59501
+ );
59502
+ return cacheResolvedBin(explicitCandidate, envBin);
59503
+ }
59504
+ logWithTimestamp(
59505
+ envBin === excludedBin ? `[onchainos] skipping ONCHAINOS_BIN=${envBin} after launch failure; falling back to discovery` : `[onchainos] ONCHAINOS_BIN is not executable at ${envBin}; falling back to discovery`
59506
+ );
59257
59507
  }
59258
59508
  if (process.platform === "win32") {
59259
- const winBin = resolveWin32();
59509
+ const winBin = resolveWin32(excludedBin);
59260
59510
  if (winBin) {
59261
- resolvedBin = winBin;
59262
- return resolvedBin;
59511
+ return cacheResolvedBin(winBin, envBin);
59263
59512
  }
59264
59513
  } else {
59265
- try {
59266
- const shell = process.env.SHELL || "/bin/bash";
59267
- const { stdout } = await execFileAsync2(shell, ["-lc", "command -v onchainos"], {
59268
- windowsHide: true,
59269
- timeout: timeoutMs
59270
- });
59271
- const bin = extractExecutablePath(stdout);
59272
- if (bin) {
59514
+ const remainingTimeoutMs = deadlineMs - Date.now();
59515
+ if (remainingTimeoutMs > 0) {
59516
+ const snapshot = createPosixDiscoverySnapshot(
59517
+ envBin,
59518
+ excludedBin,
59519
+ timeoutMs
59520
+ );
59521
+ const flight = getOrCreatePosixDiscovery(snapshot, remainingTimeoutMs);
59522
+ const discoveryResult = await flight.promise;
59523
+ if (!isPosixDiscoverySnapshotCurrent(snapshot)) {
59524
+ if (currentPosixDiscoveryContextKey() !== snapshot.contextKey) {
59525
+ logWithTimestamp(
59526
+ "[onchainos] discarding stale binary discovery result; resolver context changed"
59527
+ );
59528
+ }
59529
+ return resolveBinSelection(timeoutMs, excludedAttempt, deadlineMs);
59530
+ }
59531
+ if (discoveryResult.status === "timed_out" && deadlineMs - Date.now() > 0) {
59532
+ return resolveBinSelection(timeoutMs, excludedAttempt, deadlineMs);
59533
+ }
59534
+ const recoveredExplicitBin = snapshot.envBin ? resolveConfiguredBin(snapshot.envBin) : null;
59535
+ if (recoveredExplicitBin && !flight.excludedBins.has(recoveredExplicitBin) && resolvedBin === null) {
59536
+ logWithTimestamp(
59537
+ recoveredExplicitBin === snapshot.envBin ? `[onchainos] using recovered ONCHAINOS_BIN=${snapshot.envBin}` : `[onchainos] resolved recovered ONCHAINOS_BIN=${snapshot.envBin} to ${recoveredExplicitBin}`
59538
+ );
59539
+ return cacheResolvedBin(recoveredExplicitBin, snapshot.envBin);
59540
+ }
59541
+ const bin = discoveryResult.status === "found" ? discoveryResult.bin : null;
59542
+ if (bin && !flight.excludedBins.has(bin) && isResolvedBinUsable(bin) && resolvedBin === null) {
59273
59543
  logWithTimestamp(`[onchainos] resolved binary via shell: ${bin}`);
59274
- resolvedBin = bin;
59275
- return resolvedBin;
59544
+ return cacheResolvedBin(bin, snapshot.envBin);
59276
59545
  }
59277
- } catch (err) {
59546
+ } else {
59278
59547
  logWithTimestamp(
59279
- "[onchainos] shell resolve failed, will fallback to bare 'onchainos':",
59280
- err
59548
+ "[onchainos] binary discovery deadline exhausted; using bare fallback"
59281
59549
  );
59282
59550
  }
59283
59551
  }
59284
59552
  logWithTimestamp(
59285
59553
  "[onchainos] could not resolve binary path, falling back to bare 'onchainos'"
59286
59554
  );
59287
- resolvedBin = "onchainos";
59288
- return resolvedBin;
59555
+ return { bin: "onchainos", revision: resolverRevision };
59289
59556
  }
59290
- function resolveWin32() {
59557
+ async function resolve6(timeoutMs = ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS) {
59558
+ return (await resolveBinSelection(timeoutMs)).bin;
59559
+ }
59560
+ function resolveWin32(excludedBin) {
59291
59561
  const candidates = buildWin32OnchainosCandidates(
59292
59562
  process.env.PATH ?? process.env.Path ?? "",
59293
59563
  process.env.USERPROFILE
59294
- );
59564
+ ).filter((candidate) => !isSameWin32Candidate(candidate, excludedBin));
59295
59565
  const picked = pickOnchainosWin32Candidate(candidates);
59296
59566
  if (picked) {
59297
59567
  logWinCompat(
@@ -59304,7 +59574,14 @@ function resolveWin32() {
59304
59574
  );
59305
59575
  return null;
59306
59576
  }
59307
- function buildWin32OnchainosCandidates(pathValue, userProfile) {
59577
+ function isSameWin32Candidate(candidate, excludedBin) {
59578
+ if (!excludedBin) {
59579
+ return false;
59580
+ }
59581
+ const normalize = (value) => value.replace(/\//g, "\\").replace(/\\+$/g, "").toLowerCase();
59582
+ return normalize(candidate) === normalize(excludedBin);
59583
+ }
59584
+ function buildWin32CandidatePaths(names, pathValue, userProfile) {
59308
59585
  const dirs = [];
59309
59586
  const seen = /* @__PURE__ */ new Set();
59310
59587
  const addDir = (dir) => {
@@ -59324,7 +59601,6 @@ function buildWin32OnchainosCandidates(pathValue, userProfile) {
59324
59601
  if (userProfile?.trim()) {
59325
59602
  addDir((0, import_node_path22.join)(userProfile, ".local", "bin"));
59326
59603
  }
59327
- const names = ["onchainos.exe", "onchainos.cmd", "onchainos.bat", "onchainos"];
59328
59604
  const candidates = [];
59329
59605
  for (const dir of dirs) {
59330
59606
  for (const name of names) {
@@ -59333,6 +59609,29 @@ function buildWin32OnchainosCandidates(pathValue, userProfile) {
59333
59609
  }
59334
59610
  return candidates;
59335
59611
  }
59612
+ function buildWin32OnchainosCandidates(pathValue, userProfile) {
59613
+ return buildWin32CandidatePaths(
59614
+ ["onchainos.exe", "onchainos.cmd", "onchainos.bat", "onchainos"],
59615
+ pathValue,
59616
+ userProfile
59617
+ );
59618
+ }
59619
+ function resolveWin32BareCommandCandidate(command, pathValue, pathExtValue, userProfile) {
59620
+ const names = (0, import_node_path22.extname)(command) ? [command] : [
59621
+ ...new Set(
59622
+ pathExtValue.split(";").map((extension) => extension.trim().toLowerCase()).filter(Boolean).map(
59623
+ (extension) => `${command}${extension.startsWith(".") ? extension : `.${extension}`}`
59624
+ )
59625
+ ),
59626
+ command
59627
+ ];
59628
+ for (const candidate of buildWin32CandidatePaths(names, pathValue, userProfile)) {
59629
+ if (win32FileExists(candidate)) {
59630
+ return candidate;
59631
+ }
59632
+ }
59633
+ return null;
59634
+ }
59336
59635
  var WINDOWS_APPS_ALIAS_MARKER = "\\microsoft\\windowsapps\\";
59337
59636
  function win32CandidatePriority(candidate) {
59338
59637
  const extension = (0, import_node_path22.extname)(candidate).toLowerCase();
@@ -59438,59 +59737,79 @@ function commandForLog(bin, args) {
59438
59737
  return `${bin} ${redactArgsForLog(args).join(" ")}`;
59439
59738
  }
59440
59739
  async function exec(args, options = {}) {
59441
- const bin = await resolve6();
59442
- const cmd = commandForLog(bin, args);
59443
- logWithTimestamp(`[onchainos] exec: ${cmd}`);
59444
- const invocation = toWindowsInvocation(bin, args);
59445
- if (invocation.routedThroughWindowsShell) {
59446
- logWinCompat(
59447
- `${WIN_COMPAT_LOG_PREFIX} [onchainos] exec routed through ${invocation.command} /d /s /c: ${cmd}`
59740
+ let excludedAttempt;
59741
+ for (let attempt = 0; attempt < 2; attempt++) {
59742
+ const selection = await resolveBinSelection(
59743
+ ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS,
59744
+ excludedAttempt
59448
59745
  );
59449
- }
59450
- const t0 = Date.now();
59451
- try {
59452
- const result = await execFileAsync2(invocation.command, invocation.args, {
59453
- windowsHide: true,
59454
- windowsVerbatimArguments: invocation.windowsVerbatimArguments,
59455
- timeout: options.timeoutMs
59456
- });
59457
- logWithTimestamp(
59458
- `[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
59459
- );
59460
- return result;
59461
- } catch (err) {
59746
+ const { bin } = selection;
59747
+ const cmd = commandForLog(bin, args);
59748
+ logWithTimestamp(`[onchainos] exec: ${cmd}`);
59749
+ const invocation = toWindowsInvocation(bin, args);
59462
59750
  if (invocation.routedThroughWindowsShell) {
59463
59751
  logWinCompat(
59464
- `${WIN_COMPAT_LOG_PREFIX} [onchainos] routed exec failed via ${invocation.command}: ${cmd} errorCode=${err?.code ?? ""} signal=${err?.signal ?? ""}`
59752
+ `${WIN_COMPAT_LOG_PREFIX} [onchainos] exec routed through ${invocation.command} /d /s /c: ${cmd}`
59465
59753
  );
59466
59754
  }
59467
- logWithTimestamp(
59468
- `[onchainos] exec error: ${cmd} (${Date.now() - t0}ms) code=${err.code} signal=${err.signal} killed=${err.killed} message=${err.message}`
59469
- );
59470
- logger.error(
59471
- LogEvent.ONCHAINOS_CLI_ERROR,
59472
- err instanceof Error ? err : new Error("onchainos command failed"),
59473
- {
59474
- component: "onchainos_cli",
59475
- source: "onchainos",
59476
- stage: "exec",
59477
- communicationClass: "onchainos_cli_or_api_issue",
59478
- operation: redactArgsForLog(args).slice(0, 3).join(" "),
59479
- reason: "exec_failed",
59480
- argCount: String(args.length),
59481
- exitCode: String(err?.code ?? ""),
59482
- signal: String(err?.signal ?? ""),
59483
- killed: String(err?.killed ?? ""),
59484
- stderrBytes: String(Buffer.byteLength(String(err?.stderr ?? ""), "utf8")),
59485
- stdoutBytes: String(Buffer.byteLength(String(err?.stdout ?? ""), "utf8")),
59486
- cliErrorName: err instanceof Error ? err.name : "",
59487
- cliErrorMessageLength: String(String(err?.message ?? "").length),
59488
- durationMs: String(Date.now() - t0),
59489
- timeoutMs: String(options.timeoutMs ?? "")
59755
+ const t0 = Date.now();
59756
+ try {
59757
+ const result = await execFileAsync2(invocation.command, invocation.args, {
59758
+ windowsHide: true,
59759
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
59760
+ timeout: options.timeoutMs
59761
+ });
59762
+ rememberSuccessfulBareBin(bin);
59763
+ logWithTimestamp(
59764
+ `[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
59765
+ );
59766
+ return result;
59767
+ } catch (err) {
59768
+ if (invocation.routedThroughWindowsShell) {
59769
+ logWinCompat(
59770
+ `${WIN_COMPAT_LOG_PREFIX} [onchainos] routed exec failed via ${invocation.command}: ${cmd} errorCode=${err?.code ?? ""} signal=${err?.signal ?? ""}`
59771
+ );
59490
59772
  }
59491
- );
59492
- throw err;
59773
+ logWithTimestamp(
59774
+ `[onchainos] exec error: ${cmd} (${Date.now() - t0}ms) code=${err.code} signal=${err.signal} killed=${err.killed} message=${err.message}`
59775
+ );
59776
+ if (attempt === 0 && isCommandUnavailableError(err)) {
59777
+ invalidateResolvedBin(
59778
+ bin,
59779
+ "command could not launch the cached binary",
59780
+ selection.revision
59781
+ );
59782
+ if (shouldRetryUnavailableBin(bin)) {
59783
+ excludedAttempt = selection;
59784
+ continue;
59785
+ }
59786
+ }
59787
+ logger.error(
59788
+ LogEvent.ONCHAINOS_CLI_ERROR,
59789
+ err instanceof Error ? err : new Error("onchainos command failed"),
59790
+ {
59791
+ component: "onchainos_cli",
59792
+ source: "onchainos",
59793
+ stage: "exec",
59794
+ communicationClass: "onchainos_cli_or_api_issue",
59795
+ operation: redactArgsForLog(args).slice(0, 3).join(" "),
59796
+ reason: "exec_failed",
59797
+ argCount: String(args.length),
59798
+ exitCode: String(err?.code ?? ""),
59799
+ signal: String(err?.signal ?? ""),
59800
+ killed: String(err?.killed ?? ""),
59801
+ stderrBytes: String(Buffer.byteLength(String(err?.stderr ?? ""), "utf8")),
59802
+ stdoutBytes: String(Buffer.byteLength(String(err?.stdout ?? ""), "utf8")),
59803
+ cliErrorName: err instanceof Error ? err.name : "",
59804
+ cliErrorMessageLength: String(String(err?.message ?? "").length),
59805
+ durationMs: String(Date.now() - t0),
59806
+ timeoutMs: String(options.timeoutMs ?? "")
59807
+ }
59808
+ );
59809
+ throw err;
59810
+ }
59493
59811
  }
59812
+ throw new Error("OnchainOS command retry exhausted");
59494
59813
  }
59495
59814
 
59496
59815
  // ../core/src/xmtp-sdk/onchainos/index.ts
@@ -61027,7 +61346,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
61027
61346
  client: {
61028
61347
  id: "gateway-client",
61029
61348
  displayName: "okx-a2a-node",
61030
- version: "0.2.10-beta-1a0d85b27f-260828092722",
61349
+ version: "0.2.10",
61031
61350
  platform: "node",
61032
61351
  mode: "backend",
61033
61352
  instanceId
@@ -61038,7 +61357,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
61038
61357
  commands: [],
61039
61358
  permissions: {},
61040
61359
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
61041
- userAgent: `okx-a2a-node/${"0.2.10-beta-1a0d85b27f-260828092722"}`,
61360
+ userAgent: `okx-a2a-node/${"0.2.10"}`,
61042
61361
  auth: {
61043
61362
  ...config.token ? { token: config.token } : {},
61044
61363
  ...config.password ? { password: config.password } : {}
@@ -62563,6 +62882,7 @@ function stableHash2(value) {
62563
62882
  // src/xmtp-send.ts
62564
62883
  var TASK_MIN_VERSION = 1;
62565
62884
  var sqliteGroupSessionPromises = /* @__PURE__ */ new Map();
62885
+ var conversationSyncPromises = /* @__PURE__ */ new WeakMap();
62566
62886
  var XMTP_SEND_CHECKPOINT = "outbound/xmtp_send";
62567
62887
  function buildXmtpMessageSentExtra(params) {
62568
62888
  const xmtpMessageId = typeof params.xmtpMessageId === "string" && params.xmtpMessageId.length > 0 ? params.xmtpMessageId : "";
@@ -62727,6 +63047,22 @@ function selectAnyJobTarget(messages) {
62727
63047
  }
62728
63048
  return null;
62729
63049
  }
63050
+ async function syncConversationsOnLocalMiss(agent) {
63051
+ const conversations = agent.client.conversations;
63052
+ const existing = conversationSyncPromises.get(conversations);
63053
+ if (existing) {
63054
+ return existing;
63055
+ }
63056
+ const pending = conversations.sync();
63057
+ conversationSyncPromises.set(conversations, pending);
63058
+ try {
63059
+ await pending;
63060
+ } finally {
63061
+ if (conversationSyncPromises.get(conversations) === pending) {
63062
+ conversationSyncPromises.delete(conversations);
63063
+ }
63064
+ }
63065
+ }
62730
63066
  async function findConversation(agent, target) {
62731
63067
  await agent.client.conversations.syncAll([
62732
63068
  import_node_bindings2.ConsentState.Allowed,
@@ -62748,11 +63084,11 @@ async function findConversation(agent, target) {
62748
63084
  return null;
62749
63085
  }
62750
63086
  async function findGroupConversation(agent, groupId) {
62751
- await agent.client.conversations.syncAll([
62752
- import_node_bindings2.ConsentState.Allowed,
62753
- import_node_bindings2.ConsentState.Unknown
62754
- ]);
62755
- const conversation = await agent.client.conversations.getConversationById(groupId);
63087
+ let conversation = await agent.client.conversations.getConversationById(groupId);
63088
+ if (!(conversation instanceof Group)) {
63089
+ await syncConversationsOnLocalMiss(agent);
63090
+ conversation = await agent.client.conversations.getConversationById(groupId);
63091
+ }
62756
63092
  return conversation instanceof Group ? conversation : null;
62757
63093
  }
62758
63094
  function buildDmReplyRaw(command, target, localAgentId) {
@@ -63022,6 +63358,9 @@ async function handleSqliteGroupSendCommand(params) {
63022
63358
  let created2 = false;
63023
63359
  if (xmtpGroupId) {
63024
63360
  conversation2 = await findGroupConversation(agent, xmtpGroupId);
63361
+ if (!conversation2) {
63362
+ throw new Error(`conversation not found for stored xmtpGroupId=${xmtpGroupId} after conversation sync`);
63363
+ }
63025
63364
  }
63026
63365
  if (!conversation2) {
63027
63366
  conversation2 = await createGroupForAddress({
@@ -64127,7 +64466,7 @@ function isRecord5(value) {
64127
64466
  }
64128
64467
 
64129
64468
  // src/command-processor.ts
64130
- var DEFAULT_COMMAND_EXECUTION_TIMEOUT_MS = 5e4;
64469
+ var DEFAULT_COMMAND_EXECUTION_TIMEOUT_MS = 12e4;
64131
64470
  var DEFAULT_COMMAND_STALE_TIMEOUT_MS = 12e4;
64132
64471
  var DEFAULT_AI_COMMAND_STALE_TIMEOUT_MS = 30 * 6e4;
64133
64472
  var DEFAULT_XMTP_SEND_CONCURRENCY = 50;
@@ -67385,12 +67724,12 @@ async function runListenerWithLock(options, paths) {
67385
67724
  });
67386
67725
  }
67387
67726
  });
67388
- service.setPluginVersion("0.2.10-beta-1a0d85b27f-260828092722");
67727
+ service.setPluginVersion("0.2.10");
67389
67728
  await service.init();
67390
67729
  const pluginVersionStatus = service.pluginVersionStatus;
67391
67730
  if (pluginVersionStatus.unavailable) {
67392
67731
  throw new Error(
67393
- `@okxweb3/a2a-node v${"0.2.10-beta-1a0d85b27f-260828092722"} is below the required minimum v${pluginVersionStatus.minVersion}`
67732
+ `@okxweb3/a2a-node v${"0.2.10"} is below the required minimum v${pluginVersionStatus.minVersion}`
67394
67733
  );
67395
67734
  }
67396
67735
  const systemConfig = service.getSystemConfig();
@@ -67418,7 +67757,7 @@ async function runListenerWithLock(options, paths) {
67418
67757
  onchainosAgentId: "*",
67419
67758
  reason: "system-config missing sentryDsn",
67420
67759
  pluginId: "@okxweb3/a2a-node",
67421
- pluginVersion: "0.2.10-beta-1a0d85b27f-260828092722"
67760
+ pluginVersion: "0.2.10"
67422
67761
  });
67423
67762
  }
67424
67763
  logWithTimestamp(
@@ -70186,7 +70525,7 @@ async function exportDiagnosticLogs(options) {
70186
70525
  node: process.version,
70187
70526
  platform: process.platform,
70188
70527
  arch: process.arch,
70189
- packageVersion: true ? "0.2.10-beta-1a0d85b27f-260828092722" : "unknown",
70528
+ packageVersion: true ? "0.2.10" : "unknown",
70190
70529
  sensitiveContentIncluded: options.includeSensitiveContent,
70191
70530
  listenerAndLlmContentIncluded: true,
70192
70531
  credentialsAlwaysRedacted: true,
@@ -72068,7 +72407,7 @@ async function runDoctor(options = {}) {
72068
72407
  platform: options.platform ?? process.platform,
72069
72408
  env: options.env ?? process.env,
72070
72409
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
72071
- cliVersion: options.cliVersion ?? (true ? "0.2.10-beta-1a0d85b27f-260828092722" : "0.0.0"),
72410
+ cliVersion: options.cliVersion ?? (true ? "0.2.10" : "0.0.0"),
72072
72411
  fixMode: options.fix === true,
72073
72412
  nonInteractive: options.nonInteractive === true,
72074
72413
  packageChanged: false,
@@ -72425,6 +72764,7 @@ init_autostart_windows();
72425
72764
  getA2ACapabilities,
72426
72765
  getDaemonStatus,
72427
72766
  getHermesGatewayPluginStatus,
72767
+ getResolvedOnchainosBinForTests,
72428
72768
  getRuntimeMetadata,
72429
72769
  getSessionBusyTracker,
72430
72770
  handleCapabilitiesCommand,
@@ -72440,6 +72780,7 @@ init_autostart_windows();
72440
72780
  installWindowsNativeLauncher,
72441
72781
  installedAutostartHasCurrentConfiguration,
72442
72782
  installedAutostartHasCurrentRestartPolicy,
72783
+ invalidateResolvedOnchainosBinForTests,
72443
72784
  isAutostartManagerUnavailableError,
72444
72785
  isDefaultTaskHome,
72445
72786
  isGatewayAvailableForHeartbeat,
@@ -72520,6 +72861,7 @@ init_autostart_windows();
72520
72861
  resolveNpmCmdShimScript,
72521
72862
  resolveOfflineReplayCapabilityMarker,
72522
72863
  resolveOfflineReplayIntervalSec,
72864
+ resolveOnchainosBinForTests,
72523
72865
  resolveOpenClawGatewayConfig,
72524
72866
  resolveOpenClawGatewayRoute,
72525
72867
  resolveOpenClawGatewayRoutes,