@okxweb3/a2a-node 0.2.7 → 0.2.8-beta-e334c22780-260818180029

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 +324 -31
  2. package/dist/index.js +314 -17
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1536,6 +1536,16 @@ var init_session_store = __esm({
1536
1536
  }
1537
1537
  return null;
1538
1538
  }
1539
+ setAiRuntimeSurface(surface) {
1540
+ if (surface !== "desktop" && surface !== "cli" && surface !== "unknown") {
1541
+ throw new Error(`Unsupported AI runtime surface: ${surface}`);
1542
+ }
1543
+ this.setSetting("ai_runtime_surface", surface);
1544
+ }
1545
+ getAiRuntimeSurface() {
1546
+ const value = this.getSetting("ai_runtime_surface");
1547
+ return value === "desktop" || value === "cli" || value === "unknown" ? value : null;
1548
+ }
1539
1549
  setAiProviderCommand(provider, command) {
1540
1550
  assertAiProvider(provider);
1541
1551
  assertNonEmpty(command, "command");
@@ -19775,6 +19785,7 @@ var init_events = __esm({
19775
19785
  PROVIDER_READINESS_CHECKED: "Provider readiness checked",
19776
19786
  PROVIDER_SWITCHED: "Provider switched",
19777
19787
  JOB_PROVIDER_BOUND: "Job provider bound",
19788
+ ONCHAINOS_VERSION_OBSERVED: "OnchainOS version observed",
19778
19789
  // Hermes user-channel delivery only. The node and openclaw user-channel hops
19779
19790
  // keep emitting USER_DISPATCHED / PROMPT_USER_CHECKPOINT — one name per
19780
19791
  // transport is the whole point of splitting the send events.
@@ -20311,7 +20322,84 @@ var init_error_diagnostics = __esm({
20311
20322
  }
20312
20323
  });
20313
20324
 
20325
+ // ../core/src/sentry-logger/runtime-metadata.ts
20326
+ function normalizeAiRuntimeProvider(provider) {
20327
+ const normalized = provider?.trim().toLowerCase();
20328
+ if (normalized === "codex") {
20329
+ return "codex";
20330
+ }
20331
+ if (normalized === "claude" || normalized === "claude-code") {
20332
+ return "claude-code";
20333
+ }
20334
+ if (normalized === "openclaw") {
20335
+ return "openclaw";
20336
+ }
20337
+ if (normalized === "hermes") {
20338
+ return "hermes";
20339
+ }
20340
+ return "unknown";
20341
+ }
20342
+ function detectAiRuntimeSurface(provider, env = process.env) {
20343
+ const override = env.OKX_A2A_RUNTIME_SURFACE?.trim().toLowerCase();
20344
+ if (override === "desktop" || override === "cli" || override === "unknown") {
20345
+ return override;
20346
+ }
20347
+ const normalizedProvider = normalizeAiRuntimeProvider(provider);
20348
+ if (normalizedProvider === "codex") {
20349
+ return env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE === "Codex Desktop" ? "desktop" : "cli";
20350
+ }
20351
+ if (normalizedProvider === "claude-code") {
20352
+ return env.CLAUDE_CODE_ENTRYPOINT?.trim().toLowerCase() === "remote_cowork" ? "desktop" : "cli";
20353
+ }
20354
+ return "unknown";
20355
+ }
20356
+ function parseOnchainosVersionOutput(output5) {
20357
+ const normalized = output5.trim().replace(/\s+/g, " ");
20358
+ if (!normalized) {
20359
+ return UNKNOWN_RUNTIME_METADATA;
20360
+ }
20361
+ const match = ` ${normalized} `.match(SEMVER_PATTERN);
20362
+ return match?.[1]?.slice(0, 128) ?? UNKNOWN_RUNTIME_METADATA;
20363
+ }
20364
+ function runtimeMetadataFields(input = {}) {
20365
+ const observedAt = Number(input.onchainosVersionObservedAtMs);
20366
+ return {
20367
+ aiProvider: normalizeAiRuntimeProvider(input.aiProvider),
20368
+ runtimeSurface: input.runtimeSurface === "desktop" || input.runtimeSurface === "cli" ? input.runtimeSurface : UNKNOWN_RUNTIME_METADATA,
20369
+ onchainosVersion: typeof input.onchainosVersion === "string" && input.onchainosVersion.trim() ? input.onchainosVersion.trim().slice(0, 128) : UNKNOWN_RUNTIME_METADATA,
20370
+ onchainosVersionObservedAtMs: Number.isFinite(observedAt) && observedAt > 0 ? String(Math.trunc(observedAt)) : "0",
20371
+ onchainosVersionProbeStatus: typeof input.onchainosVersionProbeStatus === "string" && input.onchainosVersionProbeStatus.trim() ? input.onchainosVersionProbeStatus.trim().toLowerCase().slice(0, 32) : UNKNOWN_RUNTIME_METADATA
20372
+ };
20373
+ }
20374
+ var UNKNOWN_RUNTIME_METADATA, SEMVER_PATTERN;
20375
+ var init_runtime_metadata = __esm({
20376
+ "../core/src/sentry-logger/runtime-metadata.ts"() {
20377
+ "use strict";
20378
+ UNKNOWN_RUNTIME_METADATA = "unknown";
20379
+ SEMVER_PATTERN = /(?:^|[^0-9])v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?:$|[^0-9A-Za-z.-])/;
20380
+ }
20381
+ });
20382
+
20314
20383
  // ../core/src/sentry-logger/index.ts
20384
+ function setRuntimeMetadata(metadata) {
20385
+ const next = runtimeMetadataFields({
20386
+ ...RUNTIME_FIELDS,
20387
+ ...metadata
20388
+ });
20389
+ RUNTIME_FIELDS = next;
20390
+ try {
20391
+ Sentry.setTags({
20392
+ aiProvider: next.aiProvider,
20393
+ runtimeSurface: next.runtimeSurface,
20394
+ onchainosVersion: next.onchainosVersion,
20395
+ onchainosVersionProbeStatus: next.onchainosVersionProbeStatus
20396
+ });
20397
+ } catch {
20398
+ }
20399
+ }
20400
+ function getRuntimeMetadata() {
20401
+ return { ...RUNTIME_FIELDS };
20402
+ }
20315
20403
  function applyFatalEventDefaults(event) {
20316
20404
  try {
20317
20405
  const classified = event?.extra?.eventName ?? event?.tags?.eventName;
@@ -20321,6 +20409,7 @@ function applyFatalEventDefaults(event) {
20321
20409
  const target = event;
20322
20410
  target.extra = {
20323
20411
  ...RELEASE_FIELDS,
20412
+ ...RUNTIME_FIELDS,
20324
20413
  ...target.extra ?? {},
20325
20414
  eventName: LogEvent.FATAL_UNCAUGHT,
20326
20415
  eventFamily: "diagnostics",
@@ -20346,7 +20435,7 @@ function agentExtras(identity) {
20346
20435
  role: identity.role != null && identity.role !== "" ? String(identity.role) : UNKNOWN_FIELD
20347
20436
  };
20348
20437
  }
20349
- var Sentry, import_node_crypto4, FLOW_ID, SENTRY_EXTRA_BLOCKLIST, SENTRY_EXTRA_BLOCKED_KEY_PARTS, SENTRY_FULL_STRING_EXTRA_KEYS, SENTRY_TAG_KEYS, SENTRY_FINGERPRINT_KEYS, SENTRY_INFO_ALLOWLIST, MAX_EXTRA_STRING_LENGTH, MAX_TAG_VALUE_LENGTH, RELEASE_FIELDS, SentryLogger, logger, initLogger, shutdown, UNKNOWN_FIELD;
20438
+ var Sentry, import_node_crypto4, FLOW_ID, SENTRY_EXTRA_BLOCKLIST, SENTRY_EXTRA_BLOCKED_KEY_PARTS, SENTRY_FULL_STRING_EXTRA_KEYS, SENTRY_TAG_KEYS, SENTRY_FINGERPRINT_KEYS, SENTRY_INFO_ALLOWLIST, MAX_EXTRA_STRING_LENGTH, MAX_TAG_VALUE_LENGTH, RELEASE_FIELDS, RUNTIME_FIELDS, SentryLogger, logger, initLogger, shutdown, UNKNOWN_FIELD;
20350
20439
  var init_sentry_logger = __esm({
20351
20440
  "../core/src/sentry-logger/index.ts"() {
20352
20441
  "use strict";
@@ -20357,6 +20446,7 @@ var init_sentry_logger = __esm({
20357
20446
  init_log_fields();
20358
20447
  init_xmtp_test_metrics();
20359
20448
  init_error_diagnostics();
20449
+ init_runtime_metadata();
20360
20450
  init_events();
20361
20451
  init_log_fields();
20362
20452
  FLOW_ID = (0, import_node_crypto4.randomUUID)();
@@ -20443,6 +20533,7 @@ var init_sentry_logger = __esm({
20443
20533
  SENTRY_TAG_KEYS = /* @__PURE__ */ new Set([
20444
20534
  "agentId",
20445
20535
  "agentPlatform",
20536
+ "aiProvider",
20446
20537
  "cacheName",
20447
20538
  "causeCode",
20448
20539
  "causeType",
@@ -20465,6 +20556,8 @@ var init_sentry_logger = __esm({
20465
20556
  "kind",
20466
20557
  "method",
20467
20558
  "onchainosAgentId",
20559
+ "onchainosVersion",
20560
+ "onchainosVersionProbeStatus",
20468
20561
  "operation",
20469
20562
  "originPlatform",
20470
20563
  "outcome",
@@ -20481,6 +20574,7 @@ var init_sentry_logger = __esm({
20481
20574
  "role",
20482
20575
  "runId",
20483
20576
  "runtimeContainer",
20577
+ "runtimeSurface",
20484
20578
  "senderAgentId",
20485
20579
  "source",
20486
20580
  "stage",
@@ -20551,6 +20645,7 @@ var init_sentry_logger = __esm({
20551
20645
  LogEvent.PROVIDER_READINESS_CHECKED,
20552
20646
  LogEvent.PROVIDER_SWITCHED,
20553
20647
  LogEvent.JOB_PROVIDER_BOUND,
20648
+ LogEvent.ONCHAINOS_VERSION_OBSERVED,
20554
20649
  LogEvent.USER_CHANNEL_MESSAGE_DELIVERED,
20555
20650
  LogEvent.SYSTEM_NOTIFICATION_RECEIVED,
20556
20651
  LogEvent.SYSTEM_NOTIFICATION_ROUTED,
@@ -20606,6 +20701,7 @@ var init_sentry_logger = __esm({
20606
20701
  MAX_EXTRA_STRING_LENGTH = 256;
20607
20702
  MAX_TAG_VALUE_LENGTH = 128;
20608
20703
  RELEASE_FIELDS = {};
20704
+ RUNTIME_FIELDS = runtimeMetadataFields();
20609
20705
  SentryLogger = class _SentryLogger {
20610
20706
  static instance;
20611
20707
  initialized = false;
@@ -20625,6 +20721,9 @@ var init_sentry_logger = __esm({
20625
20721
  }
20626
20722
  try {
20627
20723
  RELEASE_FIELDS = releaseFields(config.release);
20724
+ if (config.runtimeMetadata) {
20725
+ setRuntimeMetadata(config.runtimeMetadata);
20726
+ }
20628
20727
  Sentry.init({
20629
20728
  dsn: config.dsn,
20630
20729
  release: config.release,
@@ -20644,6 +20743,14 @@ var init_sentry_logger = __esm({
20644
20743
  if (config.runtimeContainer) {
20645
20744
  tags.runtimeContainer = config.runtimeContainer;
20646
20745
  }
20746
+ for (const key of [
20747
+ "aiProvider",
20748
+ "runtimeSurface",
20749
+ "onchainosVersion",
20750
+ "onchainosVersionProbeStatus"
20751
+ ]) {
20752
+ tags[key] = RUNTIME_FIELDS[key] ?? "unknown";
20753
+ }
20647
20754
  Sentry.setTags(tags);
20648
20755
  } catch {
20649
20756
  return;
@@ -20656,6 +20763,7 @@ var init_sentry_logger = __esm({
20656
20763
  enrichCorrelationFields({
20657
20764
  flowId: FLOW_ID,
20658
20765
  ...RELEASE_FIELDS,
20766
+ ...RUNTIME_FIELDS,
20659
20767
  ...extra ?? {}
20660
20768
  })
20661
20769
  );
@@ -20690,6 +20798,7 @@ var init_sentry_logger = __esm({
20690
20798
  enrichCorrelationFields({
20691
20799
  flowId: FLOW_ID,
20692
20800
  ...RELEASE_FIELDS,
20801
+ ...RUNTIME_FIELDS,
20693
20802
  ...extra ?? {}
20694
20803
  })
20695
20804
  );
@@ -26648,7 +26757,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
26648
26757
  client: {
26649
26758
  id: "gateway-client",
26650
26759
  displayName: "okx-a2a-node",
26651
- version: "0.2.7",
26760
+ version: "0.2.8-beta-e334c22780-260818180029",
26652
26761
  platform: "node",
26653
26762
  mode: "backend",
26654
26763
  instanceId
@@ -26659,7 +26768,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
26659
26768
  commands: [],
26660
26769
  permissions: {},
26661
26770
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
26662
- userAgent: `okx-a2a-node/${"0.2.7"}`,
26771
+ userAgent: `okx-a2a-node/${"0.2.8-beta-e334c22780-260818180029"}`,
26663
26772
  auth: {
26664
26773
  ...config.token ? { token: config.token } : {},
26665
26774
  ...config.password ? { password: config.password } : {}
@@ -28130,6 +28239,48 @@ var init_outbound_behavior = __esm({
28130
28239
  }
28131
28240
  });
28132
28241
 
28242
+ // src/runtime-metadata-store.ts
28243
+ function defaultWarning(message) {
28244
+ console.warn(message);
28245
+ }
28246
+ function errorMessage(error) {
28247
+ return error instanceof Error ? error.message : String(error);
28248
+ }
28249
+ function warnBestEffort(warn, message) {
28250
+ try {
28251
+ warn(message);
28252
+ } catch {
28253
+ }
28254
+ }
28255
+ function persistAiRuntimeSurfaceBestEffort(store, surface, warn = defaultWarning) {
28256
+ try {
28257
+ store.setAiRuntimeSurface(surface);
28258
+ return true;
28259
+ } catch (error) {
28260
+ warnBestEffort(
28261
+ warn,
28262
+ `[runtime] failed to persist diagnostic runtime surface: ${errorMessage(error)}`
28263
+ );
28264
+ return false;
28265
+ }
28266
+ }
28267
+ function readAiRuntimeSurfaceBestEffort(store, fallback, warn = defaultWarning) {
28268
+ try {
28269
+ return store.getAiRuntimeSurface() ?? fallback;
28270
+ } catch (error) {
28271
+ warnBestEffort(
28272
+ warn,
28273
+ `[runtime] failed to read diagnostic runtime surface: ${errorMessage(error)}`
28274
+ );
28275
+ return fallback;
28276
+ }
28277
+ }
28278
+ var init_runtime_metadata_store = __esm({
28279
+ "src/runtime-metadata-store.ts"() {
28280
+ "use strict";
28281
+ }
28282
+ });
28283
+
28133
28284
  // src/runtime-switch.ts
28134
28285
  async function performRuntimeSwitch(store, options = {}) {
28135
28286
  const result = await switchProviderWithReadinessGate({
@@ -28143,11 +28294,25 @@ async function performRuntimeSwitch(store, options = {}) {
28143
28294
  }
28144
28295
  async function switchProviderWithReadinessGate(options) {
28145
28296
  const gated = await switchProviderWithReadinessGateCore(options);
28146
- emitRuntimeSwitchCheckpoints(gated);
28297
+ if (gated.result.ok) {
28298
+ const provider = normalizeAiRuntimeProvider(gated.result.provider);
28299
+ persistAiRuntimeSurfaceBestEffort(
28300
+ options.store,
28301
+ detectAiRuntimeSurface(provider, options.env)
28302
+ );
28303
+ }
28304
+ emitRuntimeSwitchCheckpoints(gated, options.env);
28147
28305
  return gated.result;
28148
28306
  }
28149
- function emitRuntimeSwitchCheckpoints(gated) {
28307
+ function emitRuntimeSwitchCheckpoints(gated, env = process.env) {
28150
28308
  const { result, runtime, readiness } = gated;
28309
+ const runtimeProvider = normalizeAiRuntimeProvider(
28310
+ result.ok ? result.provider : runtime
28311
+ );
28312
+ setRuntimeMetadata({
28313
+ aiProvider: runtimeProvider,
28314
+ runtimeSurface: detectAiRuntimeSurface(runtimeProvider, env)
28315
+ });
28151
28316
  logger.info(LogEvent.RUNTIME_DETECTED, {
28152
28317
  component: RUNTIME_SWITCH_COMPONENT,
28153
28318
  provider: runtime,
@@ -28219,8 +28384,10 @@ var init_runtime_switch = __esm({
28219
28384
  init_ai_provider();
28220
28385
  init_outbound_behavior();
28221
28386
  init_openclaw_route();
28387
+ init_runtime_metadata_store();
28222
28388
  init_sentry_logger();
28223
28389
  init_log_fields();
28390
+ init_runtime_metadata();
28224
28391
  RUNTIME_SWITCH_COMPONENT = "node_runtime_switch";
28225
28392
  }
28226
28393
  });
@@ -28568,7 +28735,7 @@ var init_sentry_config = __esm({
28568
28735
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
28569
28736
  SENTRY_CONFIG = {
28570
28737
  projectName: "okx/openclaw-okx-a2a-extension",
28571
- release: "0.2.7",
28738
+ release: "0.2.8-beta-e334c22780-260818180029",
28572
28739
  environment,
28573
28740
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
28574
28741
  };
@@ -39738,7 +39905,7 @@ async function exportDiagnosticLogs(options) {
39738
39905
  node: process.version,
39739
39906
  platform: process.platform,
39740
39907
  arch: process.arch,
39741
- packageVersion: true ? "0.2.7" : "unknown",
39908
+ packageVersion: true ? "0.2.8-beta-e334c22780-260818180029" : "unknown",
39742
39909
  sensitiveContentIncluded: options.includeSensitiveContent,
39743
39910
  listenerAndLlmContentIncluded: true,
39744
39911
  credentialsAlwaysRedacted: true,
@@ -40662,7 +40829,87 @@ var init_capabilities_cli = __esm({
40662
40829
  });
40663
40830
 
40664
40831
  // ../core/src/xmtp-sdk/onchainos/bin.ts
40665
- async function resolve9() {
40832
+ async function refreshOnchainosVersionMetadata(options = {}) {
40833
+ const now = options.now ?? Date.now;
40834
+ const current = getRuntimeMetadata();
40835
+ const previousVersion = current.onchainosVersion ?? UNKNOWN_RUNTIME_METADATA;
40836
+ const previousObservedAtMs = Number(current.onchainosVersionObservedAtMs ?? 0);
40837
+ if (versionProbeInFlight) {
40838
+ return versionProbeInFlight;
40839
+ }
40840
+ versionProbeInFlight = (async () => {
40841
+ const observedAtMs = now();
40842
+ try {
40843
+ const bin = await resolve9(
40844
+ options.resolveTimeoutMs ?? ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS
40845
+ );
40846
+ const output5 = options.runVersionCommand ? await options.runVersionCommand(bin) : await runVersionCommand(bin);
40847
+ const version3 = parseOnchainosVersionOutput(output5);
40848
+ if (version3 === UNKNOWN_RUNTIME_METADATA) {
40849
+ throw new Error("OnchainOS version output did not contain a semantic version");
40850
+ }
40851
+ const changed = previousVersion !== UNKNOWN_RUNTIME_METADATA && previousVersion !== version3;
40852
+ setRuntimeMetadata({
40853
+ onchainosVersion: version3,
40854
+ onchainosVersionObservedAtMs: observedAtMs,
40855
+ onchainosVersionProbeStatus: "ok"
40856
+ });
40857
+ if (previousVersion !== version3) {
40858
+ logger.info(LogEvent.ONCHAINOS_VERSION_OBSERVED, {
40859
+ component: "onchainos_cli",
40860
+ source: "onchainos",
40861
+ checkpoint: changed ? "version_changed" : "version_detected",
40862
+ outcome: "success",
40863
+ previousOnchainosVersion: previousVersion,
40864
+ versionChanged: String(changed),
40865
+ onchainosVersionObservedAtMs: String(observedAtMs)
40866
+ });
40867
+ }
40868
+ return {
40869
+ version: version3,
40870
+ observedAtMs,
40871
+ probeStatus: "ok",
40872
+ changed
40873
+ };
40874
+ } catch {
40875
+ const hasLastKnownVersion = previousVersion !== UNKNOWN_RUNTIME_METADATA;
40876
+ setRuntimeMetadata({
40877
+ onchainosVersion: previousVersion,
40878
+ onchainosVersionObservedAtMs: previousObservedAtMs,
40879
+ onchainosVersionProbeStatus: "failed"
40880
+ });
40881
+ if (!hasLastKnownVersion) {
40882
+ logger.info(LogEvent.ONCHAINOS_VERSION_OBSERVED, {
40883
+ component: "onchainos_cli",
40884
+ source: "onchainos",
40885
+ checkpoint: "version_probe_failed",
40886
+ outcome: "failed",
40887
+ reason: "version_unavailable",
40888
+ onchainosVersionObservedAtMs: "0"
40889
+ });
40890
+ }
40891
+ return {
40892
+ version: previousVersion,
40893
+ observedAtMs: previousObservedAtMs,
40894
+ probeStatus: "failed",
40895
+ changed: false
40896
+ };
40897
+ } finally {
40898
+ versionProbeInFlight = null;
40899
+ }
40900
+ })();
40901
+ return versionProbeInFlight;
40902
+ }
40903
+ async function runVersionCommand(bin) {
40904
+ const invocation = toWindowsInvocation(bin, ["--version"]);
40905
+ const result = await execFileAsync2(invocation.command, invocation.args, {
40906
+ windowsHide: true,
40907
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
40908
+ timeout: ONCHAINOS_VERSION_PROBE_TIMEOUT_MS
40909
+ });
40910
+ return [result.stdout, result.stderr].filter(Boolean).join("\n");
40911
+ }
40912
+ async function resolve9(timeoutMs) {
40666
40913
  if (resolvedBin) {
40667
40914
  return resolvedBin;
40668
40915
  }
@@ -40682,7 +40929,8 @@ async function resolve9() {
40682
40929
  try {
40683
40930
  const shell = process.env.SHELL || "/bin/bash";
40684
40931
  const { stdout } = await execFileAsync2(shell, ["-lc", "command -v onchainos"], {
40685
- windowsHide: true
40932
+ windowsHide: true,
40933
+ timeout: timeoutMs
40686
40934
  });
40687
40935
  const bin = extractExecutablePath(stdout);
40688
40936
  if (bin) {
@@ -40907,7 +41155,7 @@ async function exec(args, options = {}) {
40907
41155
  throw err2;
40908
41156
  }
40909
41157
  }
40910
- var import_node_fs20, import_node_child_process8, import_node_path23, import_node_util2, execFileAsync2, resolvedBin, REDACTED_VALUE_FLAGS, WINDOWS_APPS_ALIAS_MARKER;
41158
+ var import_node_fs20, import_node_child_process8, import_node_path23, import_node_util2, execFileAsync2, resolvedBin, versionProbeInFlight, REDACTED_VALUE_FLAGS, ONCHAINOS_VERSION_PROBE_TIMEOUT_MS, ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS, WINDOWS_APPS_ALIAS_MARKER;
40911
41159
  var init_bin = __esm({
40912
41160
  "../core/src/xmtp-sdk/onchainos/bin.ts"() {
40913
41161
  "use strict";
@@ -40917,10 +41165,14 @@ var init_bin = __esm({
40917
41165
  import_node_path23 = require("node:path");
40918
41166
  import_node_util2 = require("node:util");
40919
41167
  init_sentry_logger();
41168
+ init_runtime_metadata();
40920
41169
  init_win_compat();
40921
41170
  execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process8.execFile);
40922
41171
  resolvedBin = null;
41172
+ versionProbeInFlight = null;
40923
41173
  REDACTED_VALUE_FLAGS = /* @__PURE__ */ new Set(["--message"]);
41174
+ ONCHAINOS_VERSION_PROBE_TIMEOUT_MS = 5e3;
41175
+ ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS = 5e3;
40924
41176
  WINDOWS_APPS_ALIAS_MARKER = "\\microsoft\\windowsapps\\";
40925
41177
  }
40926
41178
  });
@@ -61667,6 +61919,8 @@ function aiRunSentryExtra(input) {
61667
61919
  // Every event this builder feeds describes one AI CLI child process.
61668
61920
  transport: "cli",
61669
61921
  eventFamily: "ai_run",
61922
+ // A daemon-spawned AI process is not a user-selected Desktop/CLI surface.
61923
+ runtimeSurface: "unknown",
61670
61924
  source: input.source,
61671
61925
  sessionKey: input.sessionKey,
61672
61926
  jobId: input.jobId ?? "",
@@ -63403,6 +63657,7 @@ var init_ai_runner = __esm({
63403
63657
  env: buildAiProviderEnv(command, {
63404
63658
  ...process.env,
63405
63659
  OKX_A2A_IS_CLI: "1",
63660
+ OKX_A2A_RUNTIME_SURFACE: "unknown",
63406
63661
  OKX_AGENT_TASK_AI_PROVIDER: provider,
63407
63662
  OKX_A2A_CURRENT_SESSION_KEY: request.sessionKey,
63408
63663
  OKX_A2A_CURRENT_MESSAGE_ID: request.messageId,
@@ -67375,8 +67630,9 @@ __export(listener_exports, {
67375
67630
  async function runHeartbeatRefreshCycle(options) {
67376
67631
  const heartbeat = await timeSettled(options.heartbeat);
67377
67632
  const refreshAllowed = heartbeat.value === "performed" || heartbeat.value === "refresh_safe";
67633
+ const versionRefresh = options.versionRefresh && refreshAllowed ? await timeSettled(options.versionRefresh) : void 0;
67378
67634
  const refresh = options.refresh && refreshAllowed ? await timeSettled(options.refresh) : void 0;
67379
- return { heartbeat, refresh };
67635
+ return { heartbeat, versionRefresh, refresh };
67380
67636
  }
67381
67637
  function resolveOfflineReplayIntervalSec(systemConfig) {
67382
67638
  const interval = systemConfig.offlineReplayInterval;
@@ -67648,15 +67904,25 @@ async function runListenerWithLock(options, paths) {
67648
67904
  });
67649
67905
  }
67650
67906
  });
67651
- service.setPluginVersion("0.2.7");
67907
+ service.setPluginVersion("0.2.8-beta-e334c22780-260818180029");
67652
67908
  await service.init();
67653
67909
  const pluginVersionStatus = service.pluginVersionStatus;
67654
67910
  if (pluginVersionStatus.unavailable) {
67655
67911
  throw new Error(
67656
- `@okxweb3/a2a-node v${"0.2.7"} is below the required minimum v${pluginVersionStatus.minVersion}`
67912
+ `@okxweb3/a2a-node v${"0.2.8-beta-e334c22780-260818180029"} is below the required minimum v${pluginVersionStatus.minVersion}`
67657
67913
  );
67658
67914
  }
67659
67915
  const systemConfig = service.getSystemConfig();
67916
+ const configuredProvider = resolveConfiguredAiProvider({ store: sessionStore }) ?? detectGatewayInvocation();
67917
+ const aiProvider = normalizeAiRuntimeProvider(configuredProvider);
67918
+ setRuntimeMetadata({
67919
+ aiProvider,
67920
+ runtimeSurface: readAiRuntimeSurfaceBestEffort(
67921
+ sessionStore,
67922
+ detectAiRuntimeSurface(aiProvider),
67923
+ (message) => logWithTimestamp(message)
67924
+ )
67925
+ });
67660
67926
  if (systemConfig.sentryDsn) {
67661
67927
  initLogger({
67662
67928
  dsn: systemConfig.sentryDsn,
@@ -67671,7 +67937,7 @@ async function runListenerWithLock(options, paths) {
67671
67937
  onchainosAgentId: "*",
67672
67938
  reason: "system-config missing sentryDsn",
67673
67939
  pluginId: "@okxweb3/a2a-node",
67674
- pluginVersion: "0.2.7"
67940
+ pluginVersion: "0.2.8-beta-e334c22780-260818180029"
67675
67941
  });
67676
67942
  }
67677
67943
  logWithTimestamp(
@@ -67929,6 +68195,7 @@ async function runListenerWithLock(options, paths) {
67929
68195
  timer = setInterval(() => {
67930
68196
  void runHeartbeatRefreshCycle({
67931
68197
  heartbeat: heartbeatTick,
68198
+ versionRefresh: refreshOnchainosVersionMetadata,
67932
68199
  refresh: syncTick
67933
68200
  });
67934
68201
  }, intervalSec * 1e3);
@@ -68033,7 +68300,8 @@ async function runListenerWithLock(options, paths) {
68033
68300
  });
68034
68301
  }, AUTH_RECOVERY_PROBE_INTERVAL_MS);
68035
68302
  void runHeartbeatRefreshCycle({
68036
- heartbeat: heartbeatTick
68303
+ heartbeat: heartbeatTick,
68304
+ versionRefresh: refreshOnchainosVersionMetadata
68037
68305
  });
68038
68306
  const commandProcessor = startCommandProcessor({
68039
68307
  service,
@@ -68112,6 +68380,7 @@ var init_listener = __esm({
68112
68380
  init_system_config();
68113
68381
  init_offline_replay_capability();
68114
68382
  init_signer();
68383
+ init_bin();
68115
68384
  init_xmtp_sdk();
68116
68385
  init_file_store();
68117
68386
  init_session_store();
@@ -68126,7 +68395,9 @@ var init_listener = __esm({
68126
68395
  init_daemon_lock();
68127
68396
  init_ai_provider();
68128
68397
  init_openclaw_gateway();
68398
+ init_runtime_metadata_store();
68129
68399
  init_sentry_logger();
68400
+ init_runtime_metadata();
68130
68401
  init_sentry_config();
68131
68402
  DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC = 300;
68132
68403
  DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC = 6 * 60 * 60;
@@ -116073,7 +116344,7 @@ async function getCurrentNodeCliVersion() {
116073
116344
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
116074
116345
  }
116075
116346
  function getBundledNodeCliVersion() {
116076
- return true ? "0.2.7" : null;
116347
+ return true ? "0.2.8-beta-e334c22780-260818180029" : null;
116077
116348
  }
116078
116349
  function readConfiguredAiProvider() {
116079
116350
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -116283,7 +116554,7 @@ async function updateHermes(release, options) {
116283
116554
  }
116284
116555
  }
116285
116556
  async function installGatewayPluginForDoctor(target) {
116286
- const release = isPrereleaseVersion("0.2.7") ? "beta" : "latest";
116557
+ const release = isPrereleaseVersion("0.2.8-beta-e334c22780-260818180029") ? "beta" : "latest";
116287
116558
  const insideTargetGateway = detectGatewayInvocation() === target;
116288
116559
  const options = {
116289
116560
  restart: !insideTargetGateway,
@@ -117126,6 +117397,11 @@ function initDoctorSentry() {
117126
117397
  }
117127
117398
  try {
117128
117399
  const dsn = process.env.OKX_A2A_SENTRY_DSN?.trim() || process.env.SENTRY_DSN?.trim() || FALLBACK_SENTRY_DSN;
117400
+ const aiProvider = normalizeAiRuntimeProvider(detectCurrentAiProvider());
117401
+ setRuntimeMetadata({
117402
+ aiProvider,
117403
+ runtimeSurface: detectAiRuntimeSurface(aiProvider)
117404
+ });
117129
117405
  initLogger({
117130
117406
  dsn,
117131
117407
  ...SENTRY_CONFIG,
@@ -117209,6 +117485,8 @@ var init_doctor_sentry = __esm({
117209
117485
  "use strict";
117210
117486
  init_sentry_config();
117211
117487
  init_sentry_logger();
117488
+ init_runtime_metadata();
117489
+ init_ai_provider();
117212
117490
  sentryReady = false;
117213
117491
  }
117214
117492
  });
@@ -117329,7 +117607,7 @@ async function runDoctor(options = {}) {
117329
117607
  platform: options.platform ?? process.platform,
117330
117608
  env: options.env ?? process.env,
117331
117609
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
117332
- cliVersion: options.cliVersion ?? (true ? "0.2.7" : "0.0.0"),
117610
+ cliVersion: options.cliVersion ?? (true ? "0.2.8-beta-e334c22780-260818180029" : "0.0.0"),
117333
117611
  fixMode: options.fix === true,
117334
117612
  nonInteractive: options.nonInteractive === true,
117335
117613
  packageChanged: false,
@@ -118341,6 +118619,7 @@ init_command_store();
118341
118619
  init_file_store();
118342
118620
  init_ai_provider();
118343
118621
  init_runtime_switch();
118622
+ init_runtime_metadata_store();
118344
118623
  init_job_provider();
118345
118624
  init_session_store();
118346
118625
  init_paths();
@@ -118349,9 +118628,10 @@ init_log_tail();
118349
118628
  init_win_spawn();
118350
118629
  init_sentry_logger();
118351
118630
  init_sentry_config();
118631
+ init_runtime_metadata();
118352
118632
  var CURRENT_GATEWAY_SESSION_KEYS_ENV4 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
118353
118633
  function printUsage3() {
118354
- console.log(`okx-a2a ${"0.2.7"}
118634
+ console.log(`okx-a2a ${"0.2.8-beta-e334c22780-260818180029"}
118355
118635
 
118356
118636
  Usage:
118357
118637
  okx-a2a <command> [options]
@@ -118391,7 +118671,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
118391
118671
  `);
118392
118672
  }
118393
118673
  function printVersion() {
118394
- console.log("0.2.7");
118674
+ console.log("0.2.8-beta-e334c22780-260818180029");
118395
118675
  }
118396
118676
  function printDaemonUsage() {
118397
118677
  console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
@@ -119224,6 +119504,10 @@ async function configureDefaultAiProviderForLifecycle(args, options = {}) {
119224
119504
  promptIfMissing: options.promptIfMissing ?? true,
119225
119505
  allowUnavailableProvider: options.allowUnavailableProvider
119226
119506
  });
119507
+ persistAiRuntimeSurfaceBestEffort(
119508
+ store,
119509
+ detectAiRuntimeSurface(provider.provider)
119510
+ );
119227
119511
  console.log(provider.message);
119228
119512
  } finally {
119229
119513
  store.close();
@@ -119414,6 +119698,10 @@ async function handleAiProvider(args) {
119414
119698
  requestedProvider: rawProvider,
119415
119699
  stderr: process.stderr
119416
119700
  });
119701
+ persistAiRuntimeSurfaceBestEffort(
119702
+ store,
119703
+ detectAiRuntimeSurface(choice.provider)
119704
+ );
119417
119705
  if (json) {
119418
119706
  console.log(JSON.stringify({ ok: true, provider: choice.provider, source: choice.source }));
119419
119707
  } else {
@@ -119688,7 +119976,7 @@ function assertSupportedNodeVersion() {
119688
119976
  var cliSentryInitAttempted = false;
119689
119977
  var cliSentryInitialized = false;
119690
119978
  var cliSentryFlushTimedOut = false;
119691
- function initDirectCliSentry() {
119979
+ async function initDirectCliSentry() {
119692
119980
  if (cliSentryInitAttempted) {
119693
119981
  return;
119694
119982
  }
@@ -119702,6 +119990,11 @@ function initDirectCliSentry() {
119702
119990
  if (typeof config.sentryDsn !== "string" || !config.sentryDsn) {
119703
119991
  return;
119704
119992
  }
119993
+ const aiProvider = normalizeAiRuntimeProvider(detectCurrentAiProvider());
119994
+ setRuntimeMetadata({
119995
+ aiProvider,
119996
+ runtimeSurface: detectAiRuntimeSurface(aiProvider)
119997
+ });
119705
119998
  initLogger({
119706
119999
  dsn: config.sentryDsn,
119707
120000
  ...SENTRY_CONFIG,
@@ -119830,7 +120123,7 @@ async function main() {
119830
120123
  if (command === "xmtp-test") {
119831
120124
  const { handleXmtpTestCommand: handleXmtpTestCommand2 } = await Promise.resolve().then(() => (init_xmtp_test_cli(), xmtp_test_cli_exports));
119832
120125
  await handleXmtpTestCommand2(process.argv.slice(3), {
119833
- packageVersion: "0.2.7",
120126
+ packageVersion: "0.2.8-beta-e334c22780-260818180029",
119834
120127
  agentSdkVersion: "2.3.0",
119835
120128
  nodeSdkVersion: "6.1.0",
119836
120129
  nodeBindingsVersion: "1.11.0"
@@ -119838,53 +120131,53 @@ async function main() {
119838
120131
  return;
119839
120132
  }
119840
120133
  if (command === "xmtp-send") {
119841
- initDirectCliSentry();
120134
+ await initDirectCliSentry();
119842
120135
  await queueXmtpSend(process.argv.slice(3));
119843
120136
  await flushDirectCliSentry();
119844
120137
  return;
119845
120138
  }
119846
120139
  if (command === "task") {
119847
- initDirectCliSentry();
120140
+ await initDirectCliSentry();
119848
120141
  await handleTaskCommand(process.argv.slice(3));
119849
120142
  await flushDirectCliSentry();
119850
120143
  return;
119851
120144
  }
119852
120145
  if (command === "agent") {
119853
- initDirectCliSentry();
120146
+ await initDirectCliSentry();
119854
120147
  await handleAgentCommand(process.argv.slice(3));
119855
120148
  await flushDirectCliSentry();
119856
120149
  return;
119857
120150
  }
119858
120151
  if (command === "file") {
119859
- initDirectCliSentry();
120152
+ await initDirectCliSentry();
119860
120153
  const { handleFileCommand: handleFileCommand2 } = await Promise.resolve().then(() => (init_file_cli(), file_cli_exports));
119861
120154
  await handleFileCommand2(process.argv.slice(3));
119862
120155
  await flushDirectCliSentry();
119863
120156
  return;
119864
120157
  }
119865
120158
  if (command === "user") {
119866
- initDirectCliSentry();
120159
+ await initDirectCliSentry();
119867
120160
  const { handleUserCommand: handleUserCommand2 } = await Promise.resolve().then(() => (init_user_attention_cli(), user_attention_cli_exports));
119868
120161
  await handleUserCommand2(process.argv.slice(3));
119869
120162
  await flushDirectCliSentry();
119870
120163
  return;
119871
120164
  }
119872
120165
  if (command === "session") {
119873
- initDirectCliSentry();
120166
+ await initDirectCliSentry();
119874
120167
  const { handleSessionCommand: handleSessionCommand2 } = await Promise.resolve().then(() => (init_session_cli(), session_cli_exports));
119875
120168
  await handleSessionCommand2(process.argv.slice(3));
119876
120169
  await flushDirectCliSentry();
119877
120170
  return;
119878
120171
  }
119879
120172
  if (command === "xmtp-debug") {
119880
- initDirectCliSentry();
120173
+ await initDirectCliSentry();
119881
120174
  const { handleXmtpDebugCli: handleXmtpDebugCli2 } = await Promise.resolve().then(() => (init_xmtp_debug_cli(), xmtp_debug_cli_exports));
119882
120175
  await handleXmtpDebugCli2(process.argv.slice(3));
119883
120176
  await flushDirectCliSentry();
119884
120177
  return;
119885
120178
  }
119886
120179
  if (command === "ai") {
119887
- initDirectCliSentry();
120180
+ await initDirectCliSentry();
119888
120181
  const { handleAiCommand: handleAiCommand2 } = await Promise.resolve().then(() => (init_ai_cli(), ai_cli_exports));
119889
120182
  await handleAiCommand2(process.argv.slice(3));
119890
120183
  await flushDirectCliSentry();
@@ -119951,7 +120244,7 @@ main().then(() => {
119951
120244
  }
119952
120245
  console.error(err2 instanceof Error ? err2.stack ?? err2.message : String(err2));
119953
120246
  try {
119954
- initDirectCliSentry();
120247
+ await initDirectCliSentry();
119955
120248
  const command = process.argv[2] ?? "status";
119956
120249
  const subcommand = process.argv[3] ?? "";
119957
120250
  logger.error(LogEvent.DIRECT_CLI_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), directCliSentryExtra(command, {