@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/cli.js CHANGED
@@ -26934,7 +26934,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
26934
26934
  client: {
26935
26935
  id: "gateway-client",
26936
26936
  displayName: "okx-a2a-node",
26937
- version: "0.2.10-beta-1a0d85b27f-260828092722",
26937
+ version: "0.2.10",
26938
26938
  platform: "node",
26939
26939
  mode: "backend",
26940
26940
  instanceId
@@ -26945,7 +26945,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
26945
26945
  commands: [],
26946
26946
  permissions: {},
26947
26947
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
26948
- userAgent: `okx-a2a-node/${"0.2.10-beta-1a0d85b27f-260828092722"}`,
26948
+ userAgent: `okx-a2a-node/${"0.2.10"}`,
26949
26949
  auth: {
26950
26950
  ...config.token ? { token: config.token } : {},
26951
26951
  ...config.password ? { password: config.password } : {}
@@ -29004,7 +29004,7 @@ var init_sentry_config = __esm({
29004
29004
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
29005
29005
  SENTRY_CONFIG = {
29006
29006
  projectName: "okx/openclaw-okx-a2a-extension",
29007
- release: "0.2.10-beta-1a0d85b27f-260828092722",
29007
+ release: "0.2.10",
29008
29008
  environment,
29009
29009
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
29010
29010
  };
@@ -40174,7 +40174,7 @@ async function exportDiagnosticLogs(options) {
40174
40174
  node: process.version,
40175
40175
  platform: process.platform,
40176
40176
  arch: process.arch,
40177
- packageVersion: true ? "0.2.10-beta-1a0d85b27f-260828092722" : "unknown",
40177
+ packageVersion: true ? "0.2.10" : "unknown",
40178
40178
  sensitiveContentIncluded: options.includeSensitiveContent,
40179
40179
  listenerAndLlmContentIncluded: true,
40180
40180
  credentialsAlwaysRedacted: true,
@@ -41106,13 +41106,11 @@ async function refreshOnchainosVersionMetadata(options = {}) {
41106
41106
  if (versionProbeInFlight) {
41107
41107
  return versionProbeInFlight;
41108
41108
  }
41109
- versionProbeInFlight = (async () => {
41109
+ const probe = (async () => {
41110
41110
  const observedAtMs = now();
41111
41111
  try {
41112
- const bin = await resolve9(
41113
- options.resolveTimeoutMs ?? ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS
41114
- );
41115
- const output5 = options.runVersionCommand ? await options.runVersionCommand(bin) : await runVersionCommand(bin);
41112
+ const resolveTimeoutMs = options.resolveTimeoutMs ?? ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS;
41113
+ const output5 = options.runVersionCommand ? await options.runVersionCommand(await resolve9(resolveTimeoutMs)) : await runVersionCommand(resolveTimeoutMs);
41116
41114
  const version3 = parseOnchainosVersionOutput(output5);
41117
41115
  if (version3 === UNKNOWN_RUNTIME_METADATA) {
41118
41116
  throw new Error("OnchainOS version output did not contain a semantic version");
@@ -41163,68 +41161,311 @@ async function refreshOnchainosVersionMetadata(options = {}) {
41163
41161
  probeStatus: "failed",
41164
41162
  changed: false
41165
41163
  };
41166
- } finally {
41167
- versionProbeInFlight = null;
41168
41164
  }
41169
41165
  })();
41170
- return versionProbeInFlight;
41166
+ versionProbeInFlight = probe;
41167
+ const clearProbe = () => {
41168
+ if (versionProbeInFlight === probe) {
41169
+ versionProbeInFlight = null;
41170
+ }
41171
+ };
41172
+ void probe.then(clearProbe, clearProbe);
41173
+ return probe;
41174
+ }
41175
+ async function runVersionCommand(resolveTimeoutMs) {
41176
+ let excludedAttempt;
41177
+ for (let attempt = 0; attempt < 2; attempt++) {
41178
+ const selection = await resolveBinSelection(
41179
+ resolveTimeoutMs,
41180
+ excludedAttempt
41181
+ );
41182
+ const { bin } = selection;
41183
+ const invocation = toWindowsInvocation(bin, ["--version"]);
41184
+ try {
41185
+ const result = await execFileAsync2(invocation.command, invocation.args, {
41186
+ windowsHide: true,
41187
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
41188
+ timeout: ONCHAINOS_VERSION_PROBE_TIMEOUT_MS
41189
+ });
41190
+ rememberSuccessfulBareBin(bin);
41191
+ return [result.stdout, result.stderr].filter(Boolean).join("\n");
41192
+ } catch (err2) {
41193
+ if (attempt === 0 && isCommandUnavailableError(err2)) {
41194
+ invalidateResolvedBin(
41195
+ bin,
41196
+ "version probe could not launch the cached binary",
41197
+ selection.revision
41198
+ );
41199
+ if (shouldRetryUnavailableBin(bin)) {
41200
+ excludedAttempt = selection;
41201
+ continue;
41202
+ }
41203
+ }
41204
+ throw err2;
41205
+ }
41206
+ }
41207
+ throw new Error("OnchainOS version command retry exhausted");
41171
41208
  }
41172
- async function runVersionCommand(bin) {
41173
- const invocation = toWindowsInvocation(bin, ["--version"]);
41174
- const result = await execFileAsync2(invocation.command, invocation.args, {
41175
- windowsHide: true,
41176
- windowsVerbatimArguments: invocation.windowsVerbatimArguments,
41177
- timeout: ONCHAINOS_VERSION_PROBE_TIMEOUT_MS
41209
+ function configuredEnvBin() {
41210
+ return process.env.ONCHAINOS_BIN?.trim() || null;
41211
+ }
41212
+ function isPathLikeCommand(command) {
41213
+ return command.includes("/") || command.includes("\\");
41214
+ }
41215
+ function isResolvedBinUsable(bin) {
41216
+ if (!isPathLikeCommand(bin)) {
41217
+ return true;
41218
+ }
41219
+ return process.platform === "win32" ? (0, import_node_fs20.existsSync)(bin) : isExecutable2(bin);
41220
+ }
41221
+ function resolvePosixBareCommand(command, pathValue) {
41222
+ for (const dir of pathValue.split(":")) {
41223
+ const candidate = (0, import_node_path24.join)(dir || ".", command);
41224
+ if (isExecutable2(candidate)) {
41225
+ return candidate;
41226
+ }
41227
+ }
41228
+ return null;
41229
+ }
41230
+ function resolveConfiguredBin(bin) {
41231
+ if (isPathLikeCommand(bin)) {
41232
+ return isResolvedBinUsable(bin) ? bin : null;
41233
+ }
41234
+ if (process.platform === "win32") {
41235
+ return resolveWin32BareCommandCandidate(
41236
+ bin,
41237
+ process.env.PATH ?? process.env.Path ?? "",
41238
+ process.env.PATHEXT ?? process.env.PathExt ?? ".COM;.EXE;.BAT;.CMD",
41239
+ process.env.USERPROFILE
41240
+ );
41241
+ }
41242
+ return resolvePosixBareCommand(bin, process.env.PATH ?? "");
41243
+ }
41244
+ function cacheResolvedBin(bin, envBin) {
41245
+ resolvedBin = bin;
41246
+ resolvedForEnvBin = envBin;
41247
+ resolverRevision += 1;
41248
+ return { bin, revision: resolverRevision };
41249
+ }
41250
+ function rememberSuccessfulBareBin(bin) {
41251
+ if (process.platform !== "win32" && resolvedBin === null && !isPathLikeCommand(bin)) {
41252
+ cacheResolvedBin(bin, configuredEnvBin());
41253
+ }
41254
+ }
41255
+ function invalidateResolvedBin(bin, reason, expectedRevision) {
41256
+ if (resolvedBin !== bin || expectedRevision !== void 0 && resolverRevision !== expectedRevision) {
41257
+ return false;
41258
+ }
41259
+ logWithTimestamp(
41260
+ `[onchainos] invalidating cached binary ${bin}: ${reason}; rediscovering`
41261
+ );
41262
+ resolvedBin = null;
41263
+ resolvedForEnvBin = null;
41264
+ resolverRevision += 1;
41265
+ return true;
41266
+ }
41267
+ function isCommandUnavailableError(err2) {
41268
+ const code = err2?.code;
41269
+ return typeof code === "string" && COMMAND_UNAVAILABLE_CODES.has(code);
41270
+ }
41271
+ function shouldRetryUnavailableBin(bin) {
41272
+ if (!isPathLikeCommand(bin)) {
41273
+ return false;
41274
+ }
41275
+ return true;
41276
+ }
41277
+ function currentPosixDiscoveryContextKey() {
41278
+ return JSON.stringify({
41279
+ onchainosBin: configuredEnvBin(),
41280
+ shell: process.env.SHELL || "/bin/bash",
41281
+ path: process.env.PATH ?? "",
41282
+ home: process.env.HOME ?? "",
41283
+ zDotDir: process.env.ZDOTDIR ?? "",
41284
+ bashEnv: process.env.BASH_ENV ?? "",
41285
+ env: process.env.ENV ?? "",
41286
+ cwd: process.cwd()
41178
41287
  });
41179
- return [result.stdout, result.stderr].filter(Boolean).join("\n");
41180
41288
  }
41181
- async function resolve9(timeoutMs) {
41289
+ function createPosixDiscoverySnapshot(envBin, excludedBin, timeoutMs) {
41290
+ const revision = resolverRevision;
41291
+ const contextKey = currentPosixDiscoveryContextKey();
41292
+ const excluded = excludedBin ?? null;
41293
+ return {
41294
+ revision,
41295
+ contextKey,
41296
+ // Exclusions represent binaries that failed to launch, so they are safe
41297
+ // to union across callers sharing this resolver generation. Keeping them
41298
+ // out of the key lets a late request join an ongoing recovery discovery.
41299
+ flightKey: JSON.stringify([revision, contextKey, timeoutMs]),
41300
+ envBin,
41301
+ excludedBin: excluded,
41302
+ shell: process.env.SHELL || "/bin/bash",
41303
+ childEnv: { ...process.env }
41304
+ };
41305
+ }
41306
+ function isPosixDiscoverySnapshotCurrent(snapshot) {
41307
+ return resolverRevision === snapshot.revision && currentPosixDiscoveryContextKey() === snapshot.contextKey;
41308
+ }
41309
+ function getOrCreatePosixDiscovery(snapshot, remainingTimeoutMs) {
41310
+ const existing = posixDiscoveryFlights.get(snapshot.flightKey);
41311
+ if (existing) {
41312
+ if (snapshot.excludedBin) {
41313
+ existing.excludedBins.add(snapshot.excludedBin);
41314
+ }
41315
+ existing.joinCount += 1;
41316
+ logWithTimestamp("[onchainos] joining in-flight binary discovery");
41317
+ return existing;
41318
+ }
41319
+ const excludedBins = /* @__PURE__ */ new Set();
41320
+ if (snapshot.excludedBin) {
41321
+ excludedBins.add(snapshot.excludedBin);
41322
+ }
41323
+ const expiresAtMs = Date.now() + remainingTimeoutMs;
41324
+ const discovery = (async () => {
41325
+ try {
41326
+ const { stdout } = await execFileAsync2(
41327
+ snapshot.shell,
41328
+ ["-lc", "command -v onchainos"],
41329
+ {
41330
+ env: snapshot.childEnv,
41331
+ windowsHide: true,
41332
+ timeout: remainingTimeoutMs
41333
+ }
41334
+ );
41335
+ const bin = extractExecutablePath(stdout);
41336
+ return bin ? { status: "found", bin } : { status: "not_found" };
41337
+ } catch (err2) {
41338
+ if (isPosixDiscoveryTimeoutError(err2, expiresAtMs)) {
41339
+ logWithTimestamp(
41340
+ "[onchainos] shell resolve timed out; callers with time remaining may retry"
41341
+ );
41342
+ return { status: "timed_out" };
41343
+ }
41344
+ logWithTimestamp(
41345
+ "[onchainos] shell resolve failed, will fallback to bare 'onchainos':",
41346
+ err2
41347
+ );
41348
+ return { status: "not_found" };
41349
+ }
41350
+ })();
41351
+ const clearFlight = () => {
41352
+ if (posixDiscoveryFlights.get(snapshot.flightKey) === flight) {
41353
+ posixDiscoveryFlights.delete(snapshot.flightKey);
41354
+ }
41355
+ };
41356
+ const flight = {
41357
+ excludedBins,
41358
+ expiresAtMs,
41359
+ joinCount: 0,
41360
+ promise: discovery.then(
41361
+ (result) => {
41362
+ clearFlight();
41363
+ return result;
41364
+ },
41365
+ (err2) => {
41366
+ clearFlight();
41367
+ throw err2;
41368
+ }
41369
+ )
41370
+ };
41371
+ posixDiscoveryFlights.set(snapshot.flightKey, flight);
41372
+ return flight;
41373
+ }
41374
+ function isPosixDiscoveryTimeoutError(err2, expiresAtMs) {
41375
+ const timeoutError = err2;
41376
+ return timeoutError?.killed === true || timeoutError?.code === "ETIMEDOUT" || Date.now() >= expiresAtMs;
41377
+ }
41378
+ async function resolveBinSelection(timeoutMs = ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS, excludedAttempt, deadlineMs = Date.now() + timeoutMs) {
41379
+ const excludedBin = excludedAttempt && !(resolvedBin === excludedAttempt.bin && resolverRevision !== excludedAttempt.revision) ? excludedAttempt.bin : void 0;
41380
+ const envBin = configuredEnvBin();
41381
+ const explicitCandidate = envBin && envBin !== excludedBin ? resolveConfiguredBin(envBin) : null;
41182
41382
  if (resolvedBin) {
41183
- return resolvedBin;
41383
+ if (resolvedBin === excludedBin) {
41384
+ invalidateResolvedBin(
41385
+ resolvedBin,
41386
+ "previous launch attempt could not start",
41387
+ excludedAttempt?.revision
41388
+ );
41389
+ }
41390
+ }
41391
+ if (resolvedBin) {
41392
+ const explicitBinRecovered = explicitCandidate !== null && explicitCandidate !== resolvedBin;
41393
+ if (resolvedForEnvBin === envBin && isResolvedBinUsable(resolvedBin) && !explicitBinRecovered) {
41394
+ return { bin: resolvedBin, revision: resolverRevision };
41395
+ }
41396
+ invalidateResolvedBin(
41397
+ resolvedBin,
41398
+ explicitBinRecovered ? "ONCHAINOS_BIN is available again" : resolvedForEnvBin !== envBin ? "ONCHAINOS_BIN changed" : "cached path is no longer executable"
41399
+ );
41184
41400
  }
41185
- const envBin = process.env.ONCHAINOS_BIN;
41186
41401
  if (envBin) {
41187
- logWithTimestamp(`[onchainos] using ONCHAINOS_BIN=${envBin}`);
41188
- resolvedBin = envBin;
41189
- return resolvedBin;
41402
+ if (explicitCandidate && explicitCandidate !== excludedBin) {
41403
+ logWithTimestamp(
41404
+ explicitCandidate === envBin ? `[onchainos] using ONCHAINOS_BIN=${envBin}` : `[onchainos] resolved ONCHAINOS_BIN=${envBin} to ${explicitCandidate}`
41405
+ );
41406
+ return cacheResolvedBin(explicitCandidate, envBin);
41407
+ }
41408
+ logWithTimestamp(
41409
+ 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`
41410
+ );
41190
41411
  }
41191
41412
  if (process.platform === "win32") {
41192
- const winBin = resolveWin32();
41413
+ const winBin = resolveWin32(excludedBin);
41193
41414
  if (winBin) {
41194
- resolvedBin = winBin;
41195
- return resolvedBin;
41415
+ return cacheResolvedBin(winBin, envBin);
41196
41416
  }
41197
41417
  } else {
41198
- try {
41199
- const shell = process.env.SHELL || "/bin/bash";
41200
- const { stdout } = await execFileAsync2(shell, ["-lc", "command -v onchainos"], {
41201
- windowsHide: true,
41202
- timeout: timeoutMs
41203
- });
41204
- const bin = extractExecutablePath(stdout);
41205
- if (bin) {
41418
+ const remainingTimeoutMs = deadlineMs - Date.now();
41419
+ if (remainingTimeoutMs > 0) {
41420
+ const snapshot = createPosixDiscoverySnapshot(
41421
+ envBin,
41422
+ excludedBin,
41423
+ timeoutMs
41424
+ );
41425
+ const flight = getOrCreatePosixDiscovery(snapshot, remainingTimeoutMs);
41426
+ const discoveryResult = await flight.promise;
41427
+ if (!isPosixDiscoverySnapshotCurrent(snapshot)) {
41428
+ if (currentPosixDiscoveryContextKey() !== snapshot.contextKey) {
41429
+ logWithTimestamp(
41430
+ "[onchainos] discarding stale binary discovery result; resolver context changed"
41431
+ );
41432
+ }
41433
+ return resolveBinSelection(timeoutMs, excludedAttempt, deadlineMs);
41434
+ }
41435
+ if (discoveryResult.status === "timed_out" && deadlineMs - Date.now() > 0) {
41436
+ return resolveBinSelection(timeoutMs, excludedAttempt, deadlineMs);
41437
+ }
41438
+ const recoveredExplicitBin = snapshot.envBin ? resolveConfiguredBin(snapshot.envBin) : null;
41439
+ if (recoveredExplicitBin && !flight.excludedBins.has(recoveredExplicitBin) && resolvedBin === null) {
41440
+ logWithTimestamp(
41441
+ recoveredExplicitBin === snapshot.envBin ? `[onchainos] using recovered ONCHAINOS_BIN=${snapshot.envBin}` : `[onchainos] resolved recovered ONCHAINOS_BIN=${snapshot.envBin} to ${recoveredExplicitBin}`
41442
+ );
41443
+ return cacheResolvedBin(recoveredExplicitBin, snapshot.envBin);
41444
+ }
41445
+ const bin = discoveryResult.status === "found" ? discoveryResult.bin : null;
41446
+ if (bin && !flight.excludedBins.has(bin) && isResolvedBinUsable(bin) && resolvedBin === null) {
41206
41447
  logWithTimestamp(`[onchainos] resolved binary via shell: ${bin}`);
41207
- resolvedBin = bin;
41208
- return resolvedBin;
41448
+ return cacheResolvedBin(bin, snapshot.envBin);
41209
41449
  }
41210
- } catch (err2) {
41450
+ } else {
41211
41451
  logWithTimestamp(
41212
- "[onchainos] shell resolve failed, will fallback to bare 'onchainos':",
41213
- err2
41452
+ "[onchainos] binary discovery deadline exhausted; using bare fallback"
41214
41453
  );
41215
41454
  }
41216
41455
  }
41217
41456
  logWithTimestamp(
41218
41457
  "[onchainos] could not resolve binary path, falling back to bare 'onchainos'"
41219
41458
  );
41220
- resolvedBin = "onchainos";
41221
- return resolvedBin;
41459
+ return { bin: "onchainos", revision: resolverRevision };
41222
41460
  }
41223
- function resolveWin32() {
41461
+ async function resolve9(timeoutMs = ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS) {
41462
+ return (await resolveBinSelection(timeoutMs)).bin;
41463
+ }
41464
+ function resolveWin32(excludedBin) {
41224
41465
  const candidates = buildWin32OnchainosCandidates(
41225
41466
  process.env.PATH ?? process.env.Path ?? "",
41226
41467
  process.env.USERPROFILE
41227
- );
41468
+ ).filter((candidate) => !isSameWin32Candidate(candidate, excludedBin));
41228
41469
  const picked = pickOnchainosWin32Candidate(candidates);
41229
41470
  if (picked) {
41230
41471
  logWinCompat(
@@ -41237,7 +41478,14 @@ function resolveWin32() {
41237
41478
  );
41238
41479
  return null;
41239
41480
  }
41240
- function buildWin32OnchainosCandidates(pathValue, userProfile) {
41481
+ function isSameWin32Candidate(candidate, excludedBin) {
41482
+ if (!excludedBin) {
41483
+ return false;
41484
+ }
41485
+ const normalize = (value) => value.replace(/\//g, "\\").replace(/\\+$/g, "").toLowerCase();
41486
+ return normalize(candidate) === normalize(excludedBin);
41487
+ }
41488
+ function buildWin32CandidatePaths(names, pathValue, userProfile) {
41241
41489
  const dirs = [];
41242
41490
  const seen = /* @__PURE__ */ new Set();
41243
41491
  const addDir = (dir) => {
@@ -41257,7 +41505,6 @@ function buildWin32OnchainosCandidates(pathValue, userProfile) {
41257
41505
  if (userProfile?.trim()) {
41258
41506
  addDir((0, import_node_path24.join)(userProfile, ".local", "bin"));
41259
41507
  }
41260
- const names = ["onchainos.exe", "onchainos.cmd", "onchainos.bat", "onchainos"];
41261
41508
  const candidates = [];
41262
41509
  for (const dir of dirs) {
41263
41510
  for (const name of names) {
@@ -41266,6 +41513,29 @@ function buildWin32OnchainosCandidates(pathValue, userProfile) {
41266
41513
  }
41267
41514
  return candidates;
41268
41515
  }
41516
+ function buildWin32OnchainosCandidates(pathValue, userProfile) {
41517
+ return buildWin32CandidatePaths(
41518
+ ["onchainos.exe", "onchainos.cmd", "onchainos.bat", "onchainos"],
41519
+ pathValue,
41520
+ userProfile
41521
+ );
41522
+ }
41523
+ function resolveWin32BareCommandCandidate(command, pathValue, pathExtValue, userProfile) {
41524
+ const names = (0, import_node_path24.extname)(command) ? [command] : [
41525
+ ...new Set(
41526
+ pathExtValue.split(";").map((extension) => extension.trim().toLowerCase()).filter(Boolean).map(
41527
+ (extension) => `${command}${extension.startsWith(".") ? extension : `.${extension}`}`
41528
+ )
41529
+ ),
41530
+ command
41531
+ ];
41532
+ for (const candidate of buildWin32CandidatePaths(names, pathValue, userProfile)) {
41533
+ if (win32FileExists(candidate)) {
41534
+ return candidate;
41535
+ }
41536
+ }
41537
+ return null;
41538
+ }
41269
41539
  function win32CandidatePriority(candidate) {
41270
41540
  const extension = (0, import_node_path24.extname)(candidate).toLowerCase();
41271
41541
  if (extension === ".exe") {
@@ -41370,61 +41640,81 @@ function commandForLog(bin, args) {
41370
41640
  return `${bin} ${redactArgsForLog(args).join(" ")}`;
41371
41641
  }
41372
41642
  async function exec(args, options = {}) {
41373
- const bin = await resolve9();
41374
- const cmd = commandForLog(bin, args);
41375
- logWithTimestamp(`[onchainos] exec: ${cmd}`);
41376
- const invocation = toWindowsInvocation(bin, args);
41377
- if (invocation.routedThroughWindowsShell) {
41378
- logWinCompat(
41379
- `${WIN_COMPAT_LOG_PREFIX} [onchainos] exec routed through ${invocation.command} /d /s /c: ${cmd}`
41643
+ let excludedAttempt;
41644
+ for (let attempt = 0; attempt < 2; attempt++) {
41645
+ const selection = await resolveBinSelection(
41646
+ ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS,
41647
+ excludedAttempt
41380
41648
  );
41381
- }
41382
- const t0 = Date.now();
41383
- try {
41384
- const result = await execFileAsync2(invocation.command, invocation.args, {
41385
- windowsHide: true,
41386
- windowsVerbatimArguments: invocation.windowsVerbatimArguments,
41387
- timeout: options.timeoutMs
41388
- });
41389
- logWithTimestamp(
41390
- `[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
41391
- );
41392
- return result;
41393
- } catch (err2) {
41649
+ const { bin } = selection;
41650
+ const cmd = commandForLog(bin, args);
41651
+ logWithTimestamp(`[onchainos] exec: ${cmd}`);
41652
+ const invocation = toWindowsInvocation(bin, args);
41394
41653
  if (invocation.routedThroughWindowsShell) {
41395
41654
  logWinCompat(
41396
- `${WIN_COMPAT_LOG_PREFIX} [onchainos] routed exec failed via ${invocation.command}: ${cmd} errorCode=${err2?.code ?? ""} signal=${err2?.signal ?? ""}`
41655
+ `${WIN_COMPAT_LOG_PREFIX} [onchainos] exec routed through ${invocation.command} /d /s /c: ${cmd}`
41397
41656
  );
41398
41657
  }
41399
- logWithTimestamp(
41400
- `[onchainos] exec error: ${cmd} (${Date.now() - t0}ms) code=${err2.code} signal=${err2.signal} killed=${err2.killed} message=${err2.message}`
41401
- );
41402
- logger.error(
41403
- LogEvent.ONCHAINOS_CLI_ERROR,
41404
- err2 instanceof Error ? err2 : new Error("onchainos command failed"),
41405
- {
41406
- component: "onchainos_cli",
41407
- source: "onchainos",
41408
- stage: "exec",
41409
- communicationClass: "onchainos_cli_or_api_issue",
41410
- operation: redactArgsForLog(args).slice(0, 3).join(" "),
41411
- reason: "exec_failed",
41412
- argCount: String(args.length),
41413
- exitCode: String(err2?.code ?? ""),
41414
- signal: String(err2?.signal ?? ""),
41415
- killed: String(err2?.killed ?? ""),
41416
- stderrBytes: String(Buffer.byteLength(String(err2?.stderr ?? ""), "utf8")),
41417
- stdoutBytes: String(Buffer.byteLength(String(err2?.stdout ?? ""), "utf8")),
41418
- cliErrorName: err2 instanceof Error ? err2.name : "",
41419
- cliErrorMessageLength: String(String(err2?.message ?? "").length),
41420
- durationMs: String(Date.now() - t0),
41421
- timeoutMs: String(options.timeoutMs ?? "")
41658
+ const t0 = Date.now();
41659
+ try {
41660
+ const result = await execFileAsync2(invocation.command, invocation.args, {
41661
+ windowsHide: true,
41662
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
41663
+ timeout: options.timeoutMs
41664
+ });
41665
+ rememberSuccessfulBareBin(bin);
41666
+ logWithTimestamp(
41667
+ `[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
41668
+ );
41669
+ return result;
41670
+ } catch (err2) {
41671
+ if (invocation.routedThroughWindowsShell) {
41672
+ logWinCompat(
41673
+ `${WIN_COMPAT_LOG_PREFIX} [onchainos] routed exec failed via ${invocation.command}: ${cmd} errorCode=${err2?.code ?? ""} signal=${err2?.signal ?? ""}`
41674
+ );
41422
41675
  }
41423
- );
41424
- throw err2;
41676
+ logWithTimestamp(
41677
+ `[onchainos] exec error: ${cmd} (${Date.now() - t0}ms) code=${err2.code} signal=${err2.signal} killed=${err2.killed} message=${err2.message}`
41678
+ );
41679
+ if (attempt === 0 && isCommandUnavailableError(err2)) {
41680
+ invalidateResolvedBin(
41681
+ bin,
41682
+ "command could not launch the cached binary",
41683
+ selection.revision
41684
+ );
41685
+ if (shouldRetryUnavailableBin(bin)) {
41686
+ excludedAttempt = selection;
41687
+ continue;
41688
+ }
41689
+ }
41690
+ logger.error(
41691
+ LogEvent.ONCHAINOS_CLI_ERROR,
41692
+ err2 instanceof Error ? err2 : new Error("onchainos command failed"),
41693
+ {
41694
+ component: "onchainos_cli",
41695
+ source: "onchainos",
41696
+ stage: "exec",
41697
+ communicationClass: "onchainos_cli_or_api_issue",
41698
+ operation: redactArgsForLog(args).slice(0, 3).join(" "),
41699
+ reason: "exec_failed",
41700
+ argCount: String(args.length),
41701
+ exitCode: String(err2?.code ?? ""),
41702
+ signal: String(err2?.signal ?? ""),
41703
+ killed: String(err2?.killed ?? ""),
41704
+ stderrBytes: String(Buffer.byteLength(String(err2?.stderr ?? ""), "utf8")),
41705
+ stdoutBytes: String(Buffer.byteLength(String(err2?.stdout ?? ""), "utf8")),
41706
+ cliErrorName: err2 instanceof Error ? err2.name : "",
41707
+ cliErrorMessageLength: String(String(err2?.message ?? "").length),
41708
+ durationMs: String(Date.now() - t0),
41709
+ timeoutMs: String(options.timeoutMs ?? "")
41710
+ }
41711
+ );
41712
+ throw err2;
41713
+ }
41425
41714
  }
41715
+ throw new Error("OnchainOS command retry exhausted");
41426
41716
  }
41427
- var import_node_fs20, import_node_child_process8, import_node_path24, import_node_util2, execFileAsync2, resolvedBin, versionProbeInFlight, REDACTED_VALUE_FLAGS, ONCHAINOS_VERSION_PROBE_TIMEOUT_MS, ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS, WINDOWS_APPS_ALIAS_MARKER;
41717
+ var import_node_fs20, import_node_child_process8, import_node_path24, import_node_util2, execFileAsync2, resolvedBin, resolvedForEnvBin, resolverRevision, versionProbeInFlight, posixDiscoveryFlights, REDACTED_VALUE_FLAGS, COMMAND_UNAVAILABLE_CODES, ONCHAINOS_VERSION_PROBE_TIMEOUT_MS, ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS, WINDOWS_APPS_ALIAS_MARKER;
41428
41718
  var init_bin = __esm({
41429
41719
  "../core/src/xmtp-sdk/onchainos/bin.ts"() {
41430
41720
  "use strict";
@@ -41438,8 +41728,12 @@ var init_bin = __esm({
41438
41728
  init_win_compat();
41439
41729
  execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process8.execFile);
41440
41730
  resolvedBin = null;
41731
+ resolvedForEnvBin = null;
41732
+ resolverRevision = 0;
41441
41733
  versionProbeInFlight = null;
41734
+ posixDiscoveryFlights = /* @__PURE__ */ new Map();
41442
41735
  REDACTED_VALUE_FLAGS = /* @__PURE__ */ new Set(["--message"]);
41736
+ COMMAND_UNAVAILABLE_CODES = /* @__PURE__ */ new Set(["EACCES", "ENOENT", "ENOTDIR"]);
41443
41737
  ONCHAINOS_VERSION_PROBE_TIMEOUT_MS = 5e3;
41444
41738
  ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS = 5e3;
41445
41739
  WINDOWS_APPS_ALIAS_MARKER = "\\microsoft\\windowsapps\\";
@@ -61094,6 +61388,22 @@ function selectAnyJobTarget(messages) {
61094
61388
  }
61095
61389
  return null;
61096
61390
  }
61391
+ async function syncConversationsOnLocalMiss(agent) {
61392
+ const conversations = agent.client.conversations;
61393
+ const existing = conversationSyncPromises.get(conversations);
61394
+ if (existing) {
61395
+ return existing;
61396
+ }
61397
+ const pending = conversations.sync();
61398
+ conversationSyncPromises.set(conversations, pending);
61399
+ try {
61400
+ await pending;
61401
+ } finally {
61402
+ if (conversationSyncPromises.get(conversations) === pending) {
61403
+ conversationSyncPromises.delete(conversations);
61404
+ }
61405
+ }
61406
+ }
61097
61407
  async function findConversation(agent, target) {
61098
61408
  await agent.client.conversations.syncAll([
61099
61409
  import_node_bindings2.ConsentState.Allowed,
@@ -61115,11 +61425,11 @@ async function findConversation(agent, target) {
61115
61425
  return null;
61116
61426
  }
61117
61427
  async function findGroupConversation(agent, groupId) {
61118
- await agent.client.conversations.syncAll([
61119
- import_node_bindings2.ConsentState.Allowed,
61120
- import_node_bindings2.ConsentState.Unknown
61121
- ]);
61122
- const conversation = await agent.client.conversations.getConversationById(groupId);
61428
+ let conversation = await agent.client.conversations.getConversationById(groupId);
61429
+ if (!(conversation instanceof Group)) {
61430
+ await syncConversationsOnLocalMiss(agent);
61431
+ conversation = await agent.client.conversations.getConversationById(groupId);
61432
+ }
61123
61433
  return conversation instanceof Group ? conversation : null;
61124
61434
  }
61125
61435
  function buildDmReplyRaw(command, target, localAgentId) {
@@ -61387,6 +61697,9 @@ async function handleSqliteGroupSendCommand(params) {
61387
61697
  let created2 = false;
61388
61698
  if (xmtpGroupId) {
61389
61699
  conversation2 = await findGroupConversation(agent, xmtpGroupId);
61700
+ if (!conversation2) {
61701
+ throw new Error(`conversation not found for stored xmtpGroupId=${xmtpGroupId} after conversation sync`);
61702
+ }
61390
61703
  }
61391
61704
  if (!conversation2) {
61392
61705
  conversation2 = await createGroupForAddress({
@@ -61840,7 +62153,7 @@ async function handleXmtpSendCommand(params) {
61840
62153
  ownedStore?.close();
61841
62154
  }
61842
62155
  }
61843
- var import_node_crypto12, TASK_MIN_VERSION, sqliteGroupSessionPromises, XMTP_SEND_CHECKPOINT, resolvedAgentByIdCache, resolvedAgentByAddressCache;
62156
+ var import_node_crypto12, TASK_MIN_VERSION, sqliteGroupSessionPromises, conversationSyncPromises, XMTP_SEND_CHECKPOINT, resolvedAgentByIdCache, resolvedAgentByAddressCache;
61844
62157
  var init_xmtp_send = __esm({
61845
62158
  "src/xmtp-send.ts"() {
61846
62159
  "use strict";
@@ -61859,6 +62172,7 @@ var init_xmtp_send = __esm({
61859
62172
  init_openclaw_route();
61860
62173
  TASK_MIN_VERSION = 1;
61861
62174
  sqliteGroupSessionPromises = /* @__PURE__ */ new Map();
62175
+ conversationSyncPromises = /* @__PURE__ */ new WeakMap();
61862
62176
  XMTP_SEND_CHECKPOINT = "outbound/xmtp_send";
61863
62177
  resolvedAgentByIdCache = /* @__PURE__ */ new Map();
61864
62178
  resolvedAgentByAddressCache = /* @__PURE__ */ new Map();
@@ -64133,15 +64447,15 @@ var init_ai_runner = __esm({
64133
64447
  output: fullOutputForClassification,
64134
64448
  timedOut
64135
64449
  });
64450
+ const runCompletedSuccessfully = provider === "codex" && !timedOut && exitCode === 0 && closeResult.signal === null && aiSessionId !== null && toolFailures.turnCompleted();
64136
64451
  const syntheticToolFailure = synthesizeCodexProsePermissionFailure({
64137
64452
  provider,
64138
64453
  existingFailures: toolFailures.failures,
64139
64454
  errorType: fullOutputErrorType,
64140
- output: fullOutputForClassification,
64455
+ output: runCompletedSuccessfully ? stdoutFull : fullOutputForClassification,
64141
64456
  exitCode
64142
64457
  });
64143
64458
  const detectedToolFailures = syntheticToolFailure ? [...toolFailures.failures, syntheticToolFailure] : toolFailures.failures;
64144
- const runCompletedSuccessfully = provider === "codex" && !timedOut && exitCode === 0 && closeResult.signal === null && aiSessionId !== null && toolFailures.turnCompleted();
64145
64459
  const reportableToolFailures = selectReportableAiToolFailures({
64146
64460
  provider,
64147
64461
  failures: detectedToolFailures,
@@ -66348,7 +66662,7 @@ var init_command_processor = __esm({
66348
66662
  init_user_attention_ipc();
66349
66663
  init_sentry_logger();
66350
66664
  init_xmtp_debug();
66351
- DEFAULT_COMMAND_EXECUTION_TIMEOUT_MS = 5e4;
66665
+ DEFAULT_COMMAND_EXECUTION_TIMEOUT_MS = 12e4;
66352
66666
  DEFAULT_COMMAND_STALE_TIMEOUT_MS = 12e4;
66353
66667
  DEFAULT_AI_COMMAND_STALE_TIMEOUT_MS = 30 * 6e4;
66354
66668
  DEFAULT_XMTP_SEND_CONCURRENCY = 50;
@@ -68379,12 +68693,12 @@ async function runListenerWithLock(options, paths) {
68379
68693
  });
68380
68694
  }
68381
68695
  });
68382
- service.setPluginVersion("0.2.10-beta-1a0d85b27f-260828092722");
68696
+ service.setPluginVersion("0.2.10");
68383
68697
  await service.init();
68384
68698
  const pluginVersionStatus = service.pluginVersionStatus;
68385
68699
  if (pluginVersionStatus.unavailable) {
68386
68700
  throw new Error(
68387
- `@okxweb3/a2a-node v${"0.2.10-beta-1a0d85b27f-260828092722"} is below the required minimum v${pluginVersionStatus.minVersion}`
68701
+ `@okxweb3/a2a-node v${"0.2.10"} is below the required minimum v${pluginVersionStatus.minVersion}`
68388
68702
  );
68389
68703
  }
68390
68704
  const systemConfig = service.getSystemConfig();
@@ -68412,7 +68726,7 @@ async function runListenerWithLock(options, paths) {
68412
68726
  onchainosAgentId: "*",
68413
68727
  reason: "system-config missing sentryDsn",
68414
68728
  pluginId: "@okxweb3/a2a-node",
68415
- pluginVersion: "0.2.10-beta-1a0d85b27f-260828092722"
68729
+ pluginVersion: "0.2.10"
68416
68730
  });
68417
68731
  }
68418
68732
  logWithTimestamp(
@@ -116739,7 +117053,7 @@ async function getCurrentNodeCliVersion() {
116739
117053
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
116740
117054
  }
116741
117055
  function getBundledNodeCliVersion() {
116742
- return true ? "0.2.10-beta-1a0d85b27f-260828092722" : null;
117056
+ return true ? "0.2.10" : null;
116743
117057
  }
116744
117058
  function readConfiguredAiProvider() {
116745
117059
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -116949,7 +117263,7 @@ async function updateHermes(release, options) {
116949
117263
  }
116950
117264
  }
116951
117265
  async function installGatewayPluginForDoctor(target) {
116952
- const release = isPrereleaseVersion("0.2.10-beta-1a0d85b27f-260828092722") ? "beta" : "latest";
117266
+ const release = isPrereleaseVersion("0.2.10") ? "beta" : "latest";
116953
117267
  const insideTargetGateway = detectGatewayInvocation() === target;
116954
117268
  const options = {
116955
117269
  restart: !insideTargetGateway,
@@ -118002,7 +118316,7 @@ async function runDoctor(options = {}) {
118002
118316
  platform: options.platform ?? process.platform,
118003
118317
  env: options.env ?? process.env,
118004
118318
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
118005
- cliVersion: options.cliVersion ?? (true ? "0.2.10-beta-1a0d85b27f-260828092722" : "0.0.0"),
118319
+ cliVersion: options.cliVersion ?? (true ? "0.2.10" : "0.0.0"),
118006
118320
  fixMode: options.fix === true,
118007
118321
  nonInteractive: options.nonInteractive === true,
118008
118322
  packageChanged: false,
@@ -119079,7 +119393,7 @@ init_sentry_config();
119079
119393
  init_runtime_metadata();
119080
119394
  var CURRENT_GATEWAY_SESSION_KEYS_ENV4 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
119081
119395
  function printUsage3() {
119082
- console.log(`okx-a2a ${"0.2.10-beta-1a0d85b27f-260828092722"}
119396
+ console.log(`okx-a2a ${"0.2.10"}
119083
119397
 
119084
119398
  Usage:
119085
119399
  okx-a2a <command> [options]
@@ -119119,7 +119433,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
119119
119433
  `);
119120
119434
  }
119121
119435
  function printVersion() {
119122
- console.log("0.2.10-beta-1a0d85b27f-260828092722");
119436
+ console.log("0.2.10");
119123
119437
  }
119124
119438
  function printDaemonUsage() {
119125
119439
  console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
@@ -120597,7 +120911,7 @@ async function main() {
120597
120911
  if (command === "xmtp-test") {
120598
120912
  const { handleXmtpTestCommand: handleXmtpTestCommand2 } = await Promise.resolve().then(() => (init_xmtp_test_cli(), xmtp_test_cli_exports));
120599
120913
  await handleXmtpTestCommand2(process.argv.slice(3), {
120600
- packageVersion: "0.2.10-beta-1a0d85b27f-260828092722",
120914
+ packageVersion: "0.2.10",
120601
120915
  agentSdkVersion: "2.3.0",
120602
120916
  nodeSdkVersion: "6.1.0",
120603
120917
  nodeBindingsVersion: "1.11.0"