@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/index.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");
@@ -19090,6 +19100,7 @@ var init_events = __esm({
19090
19100
  PROVIDER_READINESS_CHECKED: "Provider readiness checked",
19091
19101
  PROVIDER_SWITCHED: "Provider switched",
19092
19102
  JOB_PROVIDER_BOUND: "Job provider bound",
19103
+ ONCHAINOS_VERSION_OBSERVED: "OnchainOS version observed",
19093
19104
  // Hermes user-channel delivery only. The node and openclaw user-channel hops
19094
19105
  // keep emitting USER_DISPATCHED / PROMPT_USER_CHECKPOINT — one name per
19095
19106
  // transport is the whole point of splitting the send events.
@@ -19626,7 +19637,84 @@ var init_error_diagnostics = __esm({
19626
19637
  }
19627
19638
  });
19628
19639
 
19640
+ // ../core/src/sentry-logger/runtime-metadata.ts
19641
+ function normalizeAiRuntimeProvider(provider) {
19642
+ const normalized = provider?.trim().toLowerCase();
19643
+ if (normalized === "codex") {
19644
+ return "codex";
19645
+ }
19646
+ if (normalized === "claude" || normalized === "claude-code") {
19647
+ return "claude-code";
19648
+ }
19649
+ if (normalized === "openclaw") {
19650
+ return "openclaw";
19651
+ }
19652
+ if (normalized === "hermes") {
19653
+ return "hermes";
19654
+ }
19655
+ return "unknown";
19656
+ }
19657
+ function detectAiRuntimeSurface(provider, env = process.env) {
19658
+ const override = env.OKX_A2A_RUNTIME_SURFACE?.trim().toLowerCase();
19659
+ if (override === "desktop" || override === "cli" || override === "unknown") {
19660
+ return override;
19661
+ }
19662
+ const normalizedProvider = normalizeAiRuntimeProvider(provider);
19663
+ if (normalizedProvider === "codex") {
19664
+ return env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE === "Codex Desktop" ? "desktop" : "cli";
19665
+ }
19666
+ if (normalizedProvider === "claude-code") {
19667
+ return env.CLAUDE_CODE_ENTRYPOINT?.trim().toLowerCase() === "remote_cowork" ? "desktop" : "cli";
19668
+ }
19669
+ return "unknown";
19670
+ }
19671
+ function parseOnchainosVersionOutput(output) {
19672
+ const normalized = output.trim().replace(/\s+/g, " ");
19673
+ if (!normalized) {
19674
+ return UNKNOWN_RUNTIME_METADATA;
19675
+ }
19676
+ const match = ` ${normalized} `.match(SEMVER_PATTERN);
19677
+ return match?.[1]?.slice(0, 128) ?? UNKNOWN_RUNTIME_METADATA;
19678
+ }
19679
+ function runtimeMetadataFields(input = {}) {
19680
+ const observedAt = Number(input.onchainosVersionObservedAtMs);
19681
+ return {
19682
+ aiProvider: normalizeAiRuntimeProvider(input.aiProvider),
19683
+ runtimeSurface: input.runtimeSurface === "desktop" || input.runtimeSurface === "cli" ? input.runtimeSurface : UNKNOWN_RUNTIME_METADATA,
19684
+ onchainosVersion: typeof input.onchainosVersion === "string" && input.onchainosVersion.trim() ? input.onchainosVersion.trim().slice(0, 128) : UNKNOWN_RUNTIME_METADATA,
19685
+ onchainosVersionObservedAtMs: Number.isFinite(observedAt) && observedAt > 0 ? String(Math.trunc(observedAt)) : "0",
19686
+ onchainosVersionProbeStatus: typeof input.onchainosVersionProbeStatus === "string" && input.onchainosVersionProbeStatus.trim() ? input.onchainosVersionProbeStatus.trim().toLowerCase().slice(0, 32) : UNKNOWN_RUNTIME_METADATA
19687
+ };
19688
+ }
19689
+ var UNKNOWN_RUNTIME_METADATA, SEMVER_PATTERN;
19690
+ var init_runtime_metadata = __esm({
19691
+ "../core/src/sentry-logger/runtime-metadata.ts"() {
19692
+ "use strict";
19693
+ UNKNOWN_RUNTIME_METADATA = "unknown";
19694
+ SEMVER_PATTERN = /(?:^|[^0-9])v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?:$|[^0-9A-Za-z.-])/;
19695
+ }
19696
+ });
19697
+
19629
19698
  // ../core/src/sentry-logger/index.ts
19699
+ function setRuntimeMetadata(metadata) {
19700
+ const next = runtimeMetadataFields({
19701
+ ...RUNTIME_FIELDS,
19702
+ ...metadata
19703
+ });
19704
+ RUNTIME_FIELDS = next;
19705
+ try {
19706
+ Sentry.setTags({
19707
+ aiProvider: next.aiProvider,
19708
+ runtimeSurface: next.runtimeSurface,
19709
+ onchainosVersion: next.onchainosVersion,
19710
+ onchainosVersionProbeStatus: next.onchainosVersionProbeStatus
19711
+ });
19712
+ } catch {
19713
+ }
19714
+ }
19715
+ function getRuntimeMetadata() {
19716
+ return { ...RUNTIME_FIELDS };
19717
+ }
19630
19718
  function applyFatalEventDefaults(event) {
19631
19719
  try {
19632
19720
  const classified = event?.extra?.eventName ?? event?.tags?.eventName;
@@ -19636,6 +19724,7 @@ function applyFatalEventDefaults(event) {
19636
19724
  const target = event;
19637
19725
  target.extra = {
19638
19726
  ...RELEASE_FIELDS,
19727
+ ...RUNTIME_FIELDS,
19639
19728
  ...target.extra ?? {},
19640
19729
  eventName: LogEvent.FATAL_UNCAUGHT,
19641
19730
  eventFamily: "diagnostics",
@@ -19656,6 +19745,9 @@ function applyFatalEventDefaults(event) {
19656
19745
  function isInfoEventAllowlisted(name) {
19657
19746
  return SENTRY_INFO_ALLOWLIST.has(name);
19658
19747
  }
19748
+ function isTagKey(key) {
19749
+ return SENTRY_TAG_KEYS.has(key);
19750
+ }
19659
19751
  function agentExtras(identity) {
19660
19752
  return {
19661
19753
  walletAddress: identity.walletAddress || UNKNOWN_FIELD,
@@ -19664,7 +19756,7 @@ function agentExtras(identity) {
19664
19756
  role: identity.role != null && identity.role !== "" ? String(identity.role) : UNKNOWN_FIELD
19665
19757
  };
19666
19758
  }
19667
- var Sentry, import_node_crypto3, 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;
19759
+ var Sentry, import_node_crypto3, 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;
19668
19760
  var init_sentry_logger = __esm({
19669
19761
  "../core/src/sentry-logger/index.ts"() {
19670
19762
  "use strict";
@@ -19675,6 +19767,7 @@ var init_sentry_logger = __esm({
19675
19767
  init_log_fields();
19676
19768
  init_xmtp_test_metrics();
19677
19769
  init_error_diagnostics();
19770
+ init_runtime_metadata();
19678
19771
  init_events();
19679
19772
  init_log_fields();
19680
19773
  FLOW_ID = (0, import_node_crypto3.randomUUID)();
@@ -19761,6 +19854,7 @@ var init_sentry_logger = __esm({
19761
19854
  SENTRY_TAG_KEYS = /* @__PURE__ */ new Set([
19762
19855
  "agentId",
19763
19856
  "agentPlatform",
19857
+ "aiProvider",
19764
19858
  "cacheName",
19765
19859
  "causeCode",
19766
19860
  "causeType",
@@ -19783,6 +19877,8 @@ var init_sentry_logger = __esm({
19783
19877
  "kind",
19784
19878
  "method",
19785
19879
  "onchainosAgentId",
19880
+ "onchainosVersion",
19881
+ "onchainosVersionProbeStatus",
19786
19882
  "operation",
19787
19883
  "originPlatform",
19788
19884
  "outcome",
@@ -19799,6 +19895,7 @@ var init_sentry_logger = __esm({
19799
19895
  "role",
19800
19896
  "runId",
19801
19897
  "runtimeContainer",
19898
+ "runtimeSurface",
19802
19899
  "senderAgentId",
19803
19900
  "source",
19804
19901
  "stage",
@@ -19869,6 +19966,7 @@ var init_sentry_logger = __esm({
19869
19966
  LogEvent.PROVIDER_READINESS_CHECKED,
19870
19967
  LogEvent.PROVIDER_SWITCHED,
19871
19968
  LogEvent.JOB_PROVIDER_BOUND,
19969
+ LogEvent.ONCHAINOS_VERSION_OBSERVED,
19872
19970
  LogEvent.USER_CHANNEL_MESSAGE_DELIVERED,
19873
19971
  LogEvent.SYSTEM_NOTIFICATION_RECEIVED,
19874
19972
  LogEvent.SYSTEM_NOTIFICATION_ROUTED,
@@ -19924,6 +20022,7 @@ var init_sentry_logger = __esm({
19924
20022
  MAX_EXTRA_STRING_LENGTH = 256;
19925
20023
  MAX_TAG_VALUE_LENGTH = 128;
19926
20024
  RELEASE_FIELDS = {};
20025
+ RUNTIME_FIELDS = runtimeMetadataFields();
19927
20026
  SentryLogger = class _SentryLogger {
19928
20027
  static instance;
19929
20028
  initialized = false;
@@ -19943,6 +20042,9 @@ var init_sentry_logger = __esm({
19943
20042
  }
19944
20043
  try {
19945
20044
  RELEASE_FIELDS = releaseFields(config.release);
20045
+ if (config.runtimeMetadata) {
20046
+ setRuntimeMetadata(config.runtimeMetadata);
20047
+ }
19946
20048
  Sentry.init({
19947
20049
  dsn: config.dsn,
19948
20050
  release: config.release,
@@ -19962,6 +20064,14 @@ var init_sentry_logger = __esm({
19962
20064
  if (config.runtimeContainer) {
19963
20065
  tags.runtimeContainer = config.runtimeContainer;
19964
20066
  }
20067
+ for (const key of [
20068
+ "aiProvider",
20069
+ "runtimeSurface",
20070
+ "onchainosVersion",
20071
+ "onchainosVersionProbeStatus"
20072
+ ]) {
20073
+ tags[key] = RUNTIME_FIELDS[key] ?? "unknown";
20074
+ }
19965
20075
  Sentry.setTags(tags);
19966
20076
  } catch {
19967
20077
  return;
@@ -19974,6 +20084,7 @@ var init_sentry_logger = __esm({
19974
20084
  enrichCorrelationFields({
19975
20085
  flowId: FLOW_ID,
19976
20086
  ...RELEASE_FIELDS,
20087
+ ...RUNTIME_FIELDS,
19977
20088
  ...extra ?? {}
19978
20089
  })
19979
20090
  );
@@ -20008,6 +20119,7 @@ var init_sentry_logger = __esm({
20008
20119
  enrichCorrelationFields({
20009
20120
  flowId: FLOW_ID,
20010
20121
  ...RELEASE_FIELDS,
20122
+ ...RUNTIME_FIELDS,
20011
20123
  ...extra ?? {}
20012
20124
  })
20013
20125
  );
@@ -32148,7 +32260,7 @@ var init_sentry_config = __esm({
32148
32260
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
32149
32261
  SENTRY_CONFIG = {
32150
32262
  projectName: "okx/openclaw-okx-a2a-extension",
32151
- release: "0.2.7",
32263
+ release: "0.2.8-beta-e334c22780-260818180029",
32152
32264
  environment,
32153
32265
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
32154
32266
  };
@@ -33089,7 +33201,7 @@ async function getCurrentNodeCliVersion() {
33089
33201
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
33090
33202
  }
33091
33203
  function getBundledNodeCliVersion() {
33092
- return true ? "0.2.7" : null;
33204
+ return true ? "0.2.8-beta-e334c22780-260818180029" : null;
33093
33205
  }
33094
33206
  function readConfiguredAiProvider() {
33095
33207
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -33299,7 +33411,7 @@ async function updateHermes(release, options) {
33299
33411
  }
33300
33412
  }
33301
33413
  async function installGatewayPluginForDoctor(target) {
33302
- const release = isPrereleaseVersion("0.2.7") ? "beta" : "latest";
33414
+ const release = isPrereleaseVersion("0.2.8-beta-e334c22780-260818180029") ? "beta" : "latest";
33303
33415
  const insideTargetGateway = detectGatewayInvocation() === target;
33304
33416
  const options = {
33305
33417
  restart: !insideTargetGateway,
@@ -43898,6 +44010,11 @@ function initDoctorSentry() {
43898
44010
  }
43899
44011
  try {
43900
44012
  const dsn = process.env.OKX_A2A_SENTRY_DSN?.trim() || process.env.SENTRY_DSN?.trim() || FALLBACK_SENTRY_DSN;
44013
+ const aiProvider = normalizeAiRuntimeProvider(detectCurrentAiProvider());
44014
+ setRuntimeMetadata({
44015
+ aiProvider,
44016
+ runtimeSurface: detectAiRuntimeSurface(aiProvider)
44017
+ });
43901
44018
  initLogger({
43902
44019
  dsn,
43903
44020
  ...SENTRY_CONFIG,
@@ -43981,6 +44098,8 @@ var init_doctor_sentry = __esm({
43981
44098
  "use strict";
43982
44099
  init_sentry_config();
43983
44100
  init_sentry_logger();
44101
+ init_runtime_metadata();
44102
+ init_ai_provider();
43984
44103
  sentryReady = false;
43985
44104
  }
43986
44105
  });
@@ -44101,6 +44220,7 @@ __export(index_exports, {
44101
44220
  createUserAttentionWatchParentMonitor: () => createUserAttentionWatchParentMonitor,
44102
44221
  currentOpenClawGatewaySessionKey: () => currentOpenClawGatewaySessionKey,
44103
44222
  detectAiProviders: () => detectAiProviders,
44223
+ detectAiRuntimeSurface: () => detectAiRuntimeSurface,
44104
44224
  detectCurrentAiProvider: () => detectCurrentAiProvider,
44105
44225
  detectGatewayInvocation: () => detectGatewayInvocation,
44106
44226
  detectMessageEligibleOfflineReplaySupport: () => detectMessageEligibleOfflineReplaySupport,
@@ -44121,6 +44241,7 @@ __export(index_exports, {
44121
44241
  getA2ACapabilities: () => getA2ACapabilities,
44122
44242
  getDaemonStatus: () => getDaemonStatus,
44123
44243
  getHermesGatewayPluginStatus: () => getHermesGatewayPluginStatus,
44244
+ getRuntimeMetadata: () => getRuntimeMetadata,
44124
44245
  getSessionBusyTracker: () => getSessionBusyTracker,
44125
44246
  handleCapabilitiesCommand: () => handleCapabilitiesCommand,
44126
44247
  handleDoctorCommand: () => handleDoctorCommand,
@@ -44145,6 +44266,7 @@ __export(index_exports, {
44145
44266
  isPrereleaseVersion: () => isPrereleaseVersion,
44146
44267
  isRetryableOpenClawGatewayError: () => isRetryableOpenClawGatewayError,
44147
44268
  isSqliteBusyError: () => isSqliteBusyError,
44269
+ isTagKey: () => isTagKey,
44148
44270
  isWindowsElevated: () => isWindowsElevated,
44149
44271
  killProcessTree: () => killProcessTree,
44150
44272
  launchdPlistHasCurrentRestartPolicy: () => launchdPlistHasCurrentRestartPolicy,
@@ -44156,16 +44278,19 @@ __export(index_exports, {
44156
44278
  messageEligibleHelpAdvertisesOfflineReplay: () => messageEligibleHelpAdvertisesOfflineReplay,
44157
44279
  nodeVersionSatisfies: () => nodeVersionSatisfies,
44158
44280
  normalizeAiProvider: () => normalizeAiProvider,
44281
+ normalizeAiRuntimeProvider: () => normalizeAiRuntimeProvider,
44159
44282
  normalizeHermesOkxA2aPluginConfig: () => normalizeHermesOkxA2aPluginConfig,
44160
44283
  notifyAgentMessageToUserAttention: () => notifyAgentMessageToUserAttention,
44161
44284
  notifyDirectToUserAttention: () => notifyDirectToUserAttention,
44162
44285
  notifySystemMessageToUser: () => notifySystemMessageToUser,
44163
44286
  notifyUserAttentionChanged: () => notifyUserAttentionChanged,
44164
44287
  parseLogsExportArgs: () => parseLogsExportArgs,
44288
+ parseOnchainosVersionOutput: () => parseOnchainosVersionOutput,
44165
44289
  parsePluginYamlVersion: () => parsePluginYamlVersion,
44166
44290
  parseWalletLoginStatus: () => parseWalletLoginStatus,
44167
44291
  parseWindowsParentProcessJson: () => parseWindowsParentProcessJson,
44168
44292
  performRuntimeSwitch: () => performRuntimeSwitch,
44293
+ persistAiRuntimeSurfaceBestEffort: () => persistAiRuntimeSurfaceBestEffort,
44169
44294
  persistCurrentRuntimeSelectionForNewJob: () => persistCurrentRuntimeSelectionForNewJob,
44170
44295
  pickOnchainosWin32Candidate: () => pickOnchainosWin32Candidate,
44171
44296
  prepareAndBindCurrentRuntimeForNewJob: () => prepareAndBindCurrentRuntimeForNewJob,
@@ -44175,11 +44300,13 @@ __export(index_exports, {
44175
44300
  processFileMessage: () => processFileMessage,
44176
44301
  queryWalletLoginStatus: () => queryWalletLoginStatus,
44177
44302
  readAiProviderTimeoutMs: () => readAiProviderTimeoutMs,
44303
+ readAiRuntimeSurfaceBestEffort: () => readAiRuntimeSurfaceBestEffort,
44178
44304
  readCachedCodexReadiness: () => readCachedCodexReadiness,
44179
44305
  readLastLines: () => readLastLines,
44180
44306
  readParentProcessCommandForPlatform: () => readParentProcessCommandForPlatform,
44181
44307
  readUserAttentionWatcherEvent: () => readUserAttentionWatcherEvent,
44182
44308
  refreshAgentsAndWait: () => refreshAgentsAndWait,
44309
+ refreshOnchainosVersionMetadata: () => refreshOnchainosVersionMetadata,
44183
44310
  registerUserAttentionWatcher: () => registerUserAttentionWatcher,
44184
44311
  releaseActiveDaemon: () => releaseActiveDaemon,
44185
44312
  removeUserAttentionWatcher: () => removeUserAttentionWatcher,
@@ -44219,8 +44346,10 @@ __export(index_exports, {
44219
44346
  runDoctor: () => runDoctor,
44220
44347
  runHeartbeatRefreshCycle: () => runHeartbeatRefreshCycle,
44221
44348
  runListener: () => runListener,
44349
+ runtimeMetadataFields: () => runtimeMetadataFields,
44222
44350
  scanUserAttentionWatchers: () => scanUserAttentionWatchers,
44223
44351
  setOpenClawWebSocketFactoryForTests: () => setOpenClawWebSocketFactoryForTests,
44352
+ setRuntimeMetadata: () => setRuntimeMetadata,
44224
44353
  shouldDelegateToSupervisor: () => shouldDelegateToSupervisor,
44225
44354
  shouldRouteThroughWindowsShell: () => shouldRouteThroughWindowsShell,
44226
44355
  spawnCompat: () => spawnCompat,
@@ -45257,6 +45386,8 @@ function aiRunSentryExtra(input) {
45257
45386
  // Every event this builder feeds describes one AI CLI child process.
45258
45387
  transport: "cli",
45259
45388
  eventFamily: "ai_run",
45389
+ // A daemon-spawned AI process is not a user-selected Desktop/CLI surface.
45390
+ runtimeSurface: "unknown",
45260
45391
  source: input.source,
45261
45392
  sessionKey: input.sessionKey,
45262
45393
  jobId: input.jobId ?? "",
@@ -45576,6 +45707,7 @@ var AiRunner = class {
45576
45707
  env: buildAiProviderEnv(command, {
45577
45708
  ...process.env,
45578
45709
  OKX_A2A_IS_CLI: "1",
45710
+ OKX_A2A_RUNTIME_SURFACE: "unknown",
45579
45711
  OKX_AGENT_TASK_AI_PROVIDER: provider,
45580
45712
  OKX_A2A_CURRENT_SESSION_KEY: request.sessionKey,
45581
45713
  OKX_A2A_CURRENT_MESSAGE_ID: request.messageId,
@@ -58746,14 +58878,99 @@ var import_node_child_process6 = require("node:child_process");
58746
58878
  var import_node_path22 = require("node:path");
58747
58879
  var import_node_util2 = require("node:util");
58748
58880
  init_sentry_logger();
58881
+ init_runtime_metadata();
58749
58882
  init_win_compat();
58750
58883
  var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process6.execFile);
58751
58884
  var resolvedBin = null;
58885
+ var versionProbeInFlight = null;
58752
58886
  var REDACTED_VALUE_FLAGS = /* @__PURE__ */ new Set(["--message"]);
58887
+ var ONCHAINOS_VERSION_PROBE_TIMEOUT_MS = 5e3;
58888
+ var ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS = 5e3;
58753
58889
  function resetResolvedOnchainosBinForTests() {
58754
58890
  resolvedBin = null;
58891
+ versionProbeInFlight = null;
58892
+ }
58893
+ async function refreshOnchainosVersionMetadata(options = {}) {
58894
+ const now = options.now ?? Date.now;
58895
+ const current = getRuntimeMetadata();
58896
+ const previousVersion = current.onchainosVersion ?? UNKNOWN_RUNTIME_METADATA;
58897
+ const previousObservedAtMs = Number(current.onchainosVersionObservedAtMs ?? 0);
58898
+ if (versionProbeInFlight) {
58899
+ return versionProbeInFlight;
58900
+ }
58901
+ versionProbeInFlight = (async () => {
58902
+ const observedAtMs = now();
58903
+ try {
58904
+ const bin = await resolve6(
58905
+ options.resolveTimeoutMs ?? ONCHAINOS_BIN_RESOLVE_TIMEOUT_MS
58906
+ );
58907
+ const output = options.runVersionCommand ? await options.runVersionCommand(bin) : await runVersionCommand(bin);
58908
+ const version3 = parseOnchainosVersionOutput(output);
58909
+ if (version3 === UNKNOWN_RUNTIME_METADATA) {
58910
+ throw new Error("OnchainOS version output did not contain a semantic version");
58911
+ }
58912
+ const changed = previousVersion !== UNKNOWN_RUNTIME_METADATA && previousVersion !== version3;
58913
+ setRuntimeMetadata({
58914
+ onchainosVersion: version3,
58915
+ onchainosVersionObservedAtMs: observedAtMs,
58916
+ onchainosVersionProbeStatus: "ok"
58917
+ });
58918
+ if (previousVersion !== version3) {
58919
+ logger.info(LogEvent.ONCHAINOS_VERSION_OBSERVED, {
58920
+ component: "onchainos_cli",
58921
+ source: "onchainos",
58922
+ checkpoint: changed ? "version_changed" : "version_detected",
58923
+ outcome: "success",
58924
+ previousOnchainosVersion: previousVersion,
58925
+ versionChanged: String(changed),
58926
+ onchainosVersionObservedAtMs: String(observedAtMs)
58927
+ });
58928
+ }
58929
+ return {
58930
+ version: version3,
58931
+ observedAtMs,
58932
+ probeStatus: "ok",
58933
+ changed
58934
+ };
58935
+ } catch {
58936
+ const hasLastKnownVersion = previousVersion !== UNKNOWN_RUNTIME_METADATA;
58937
+ setRuntimeMetadata({
58938
+ onchainosVersion: previousVersion,
58939
+ onchainosVersionObservedAtMs: previousObservedAtMs,
58940
+ onchainosVersionProbeStatus: "failed"
58941
+ });
58942
+ if (!hasLastKnownVersion) {
58943
+ logger.info(LogEvent.ONCHAINOS_VERSION_OBSERVED, {
58944
+ component: "onchainos_cli",
58945
+ source: "onchainos",
58946
+ checkpoint: "version_probe_failed",
58947
+ outcome: "failed",
58948
+ reason: "version_unavailable",
58949
+ onchainosVersionObservedAtMs: "0"
58950
+ });
58951
+ }
58952
+ return {
58953
+ version: previousVersion,
58954
+ observedAtMs: previousObservedAtMs,
58955
+ probeStatus: "failed",
58956
+ changed: false
58957
+ };
58958
+ } finally {
58959
+ versionProbeInFlight = null;
58960
+ }
58961
+ })();
58962
+ return versionProbeInFlight;
58963
+ }
58964
+ async function runVersionCommand(bin) {
58965
+ const invocation = toWindowsInvocation(bin, ["--version"]);
58966
+ const result = await execFileAsync2(invocation.command, invocation.args, {
58967
+ windowsHide: true,
58968
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments,
58969
+ timeout: ONCHAINOS_VERSION_PROBE_TIMEOUT_MS
58970
+ });
58971
+ return [result.stdout, result.stderr].filter(Boolean).join("\n");
58755
58972
  }
58756
- async function resolve6() {
58973
+ async function resolve6(timeoutMs) {
58757
58974
  if (resolvedBin) {
58758
58975
  return resolvedBin;
58759
58976
  }
@@ -58773,7 +58990,8 @@ async function resolve6() {
58773
58990
  try {
58774
58991
  const shell = process.env.SHELL || "/bin/bash";
58775
58992
  const { stdout } = await execFileAsync2(shell, ["-lc", "command -v onchainos"], {
58776
- windowsHide: true
58993
+ windowsHide: true,
58994
+ timeout: timeoutMs
58777
58995
  });
58778
58996
  const bin = extractExecutablePath(stdout);
58779
58997
  if (bin) {
@@ -60534,7 +60752,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
60534
60752
  client: {
60535
60753
  id: "gateway-client",
60536
60754
  displayName: "okx-a2a-node",
60537
- version: "0.2.7",
60755
+ version: "0.2.8-beta-e334c22780-260818180029",
60538
60756
  platform: "node",
60539
60757
  mode: "backend",
60540
60758
  instanceId
@@ -60545,7 +60763,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
60545
60763
  commands: [],
60546
60764
  permissions: {},
60547
60765
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
60548
- userAgent: `okx-a2a-node/${"0.2.7"}`,
60766
+ userAgent: `okx-a2a-node/${"0.2.8-beta-e334c22780-260818180029"}`,
60549
60767
  auth: {
60550
60768
  ...config.token ? { token: config.token } : {},
60551
60769
  ...config.password ? { password: config.password } : {}
@@ -66293,7 +66511,47 @@ function userWatchEventDeliveredSentryExtra(event) {
66293
66511
  // src/listener.ts
66294
66512
  init_daemon_lock();
66295
66513
  init_ai_provider();
66514
+
66515
+ // src/runtime-metadata-store.ts
66516
+ function defaultWarning(message) {
66517
+ console.warn(message);
66518
+ }
66519
+ function errorMessage(error) {
66520
+ return error instanceof Error ? error.message : String(error);
66521
+ }
66522
+ function warnBestEffort(warn, message) {
66523
+ try {
66524
+ warn(message);
66525
+ } catch {
66526
+ }
66527
+ }
66528
+ function persistAiRuntimeSurfaceBestEffort(store, surface, warn = defaultWarning) {
66529
+ try {
66530
+ store.setAiRuntimeSurface(surface);
66531
+ return true;
66532
+ } catch (error) {
66533
+ warnBestEffort(
66534
+ warn,
66535
+ `[runtime] failed to persist diagnostic runtime surface: ${errorMessage(error)}`
66536
+ );
66537
+ return false;
66538
+ }
66539
+ }
66540
+ function readAiRuntimeSurfaceBestEffort(store, fallback, warn = defaultWarning) {
66541
+ try {
66542
+ return store.getAiRuntimeSurface() ?? fallback;
66543
+ } catch (error) {
66544
+ warnBestEffort(
66545
+ warn,
66546
+ `[runtime] failed to read diagnostic runtime surface: ${errorMessage(error)}`
66547
+ );
66548
+ return fallback;
66549
+ }
66550
+ }
66551
+
66552
+ // src/listener.ts
66296
66553
  init_sentry_logger();
66554
+ init_runtime_metadata();
66297
66555
  init_sentry_config();
66298
66556
  var DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC = 300;
66299
66557
  var DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC = 6 * 60 * 60;
@@ -66304,8 +66562,9 @@ var AUTH_RECOVERY_REFRESH_BACKOFF_MS = [6e4, 12e4, 3e5];
66304
66562
  async function runHeartbeatRefreshCycle(options) {
66305
66563
  const heartbeat = await timeSettled(options.heartbeat);
66306
66564
  const refreshAllowed = heartbeat.value === "performed" || heartbeat.value === "refresh_safe";
66565
+ const versionRefresh = options.versionRefresh && refreshAllowed ? await timeSettled(options.versionRefresh) : void 0;
66307
66566
  const refresh = options.refresh && refreshAllowed ? await timeSettled(options.refresh) : void 0;
66308
- return { heartbeat, refresh };
66567
+ return { heartbeat, versionRefresh, refresh };
66309
66568
  }
66310
66569
  var AgentRefreshAuthGate = class {
66311
66570
  authBlocked = false;
@@ -66732,15 +66991,25 @@ async function runListenerWithLock(options, paths) {
66732
66991
  });
66733
66992
  }
66734
66993
  });
66735
- service.setPluginVersion("0.2.7");
66994
+ service.setPluginVersion("0.2.8-beta-e334c22780-260818180029");
66736
66995
  await service.init();
66737
66996
  const pluginVersionStatus = service.pluginVersionStatus;
66738
66997
  if (pluginVersionStatus.unavailable) {
66739
66998
  throw new Error(
66740
- `@okxweb3/a2a-node v${"0.2.7"} is below the required minimum v${pluginVersionStatus.minVersion}`
66999
+ `@okxweb3/a2a-node v${"0.2.8-beta-e334c22780-260818180029"} is below the required minimum v${pluginVersionStatus.minVersion}`
66741
67000
  );
66742
67001
  }
66743
67002
  const systemConfig = service.getSystemConfig();
67003
+ const configuredProvider = resolveConfiguredAiProvider({ store: sessionStore }) ?? detectGatewayInvocation();
67004
+ const aiProvider = normalizeAiRuntimeProvider(configuredProvider);
67005
+ setRuntimeMetadata({
67006
+ aiProvider,
67007
+ runtimeSurface: readAiRuntimeSurfaceBestEffort(
67008
+ sessionStore,
67009
+ detectAiRuntimeSurface(aiProvider),
67010
+ (message) => logWithTimestamp(message)
67011
+ )
67012
+ });
66744
67013
  if (systemConfig.sentryDsn) {
66745
67014
  initLogger({
66746
67015
  dsn: systemConfig.sentryDsn,
@@ -66755,7 +67024,7 @@ async function runListenerWithLock(options, paths) {
66755
67024
  onchainosAgentId: "*",
66756
67025
  reason: "system-config missing sentryDsn",
66757
67026
  pluginId: "@okxweb3/a2a-node",
66758
- pluginVersion: "0.2.7"
67027
+ pluginVersion: "0.2.8-beta-e334c22780-260818180029"
66759
67028
  });
66760
67029
  }
66761
67030
  logWithTimestamp(
@@ -67013,6 +67282,7 @@ async function runListenerWithLock(options, paths) {
67013
67282
  timer = setInterval(() => {
67014
67283
  void runHeartbeatRefreshCycle({
67015
67284
  heartbeat: heartbeatTick,
67285
+ versionRefresh: refreshOnchainosVersionMetadata,
67016
67286
  refresh: syncTick
67017
67287
  });
67018
67288
  }, intervalSec * 1e3);
@@ -67117,7 +67387,8 @@ async function runListenerWithLock(options, paths) {
67117
67387
  });
67118
67388
  }, AUTH_RECOVERY_PROBE_INTERVAL_MS);
67119
67389
  void runHeartbeatRefreshCycle({
67120
- heartbeat: heartbeatTick
67390
+ heartbeat: heartbeatTick,
67391
+ versionRefresh: refreshOnchainosVersionMetadata
67121
67392
  });
67122
67393
  const commandProcessor = startCommandProcessor({
67123
67394
  service,
@@ -68100,6 +68371,7 @@ var JOB_PROVIDER_BINDING_SOURCES = [
68100
68371
 
68101
68372
  // src/index.ts
68102
68373
  init_sentry_logger();
68374
+ init_runtime_metadata();
68103
68375
  init_update_cli();
68104
68376
  init_win_spawn();
68105
68377
 
@@ -69453,7 +69725,7 @@ async function exportDiagnosticLogs(options) {
69453
69725
  node: process.version,
69454
69726
  platform: process.platform,
69455
69727
  arch: process.arch,
69456
- packageVersion: true ? "0.2.7" : "unknown",
69728
+ packageVersion: true ? "0.2.8-beta-e334c22780-260818180029" : "unknown",
69457
69729
  sensitiveContentIncluded: options.includeSensitiveContent,
69458
69730
  listenerAndLlmContentIncluded: true,
69459
69731
  credentialsAlwaysRedacted: true,
@@ -70358,6 +70630,7 @@ async function refreshAgentsAndWait(timeoutMs = 6e4) {
70358
70630
  init_ai_provider();
70359
70631
  init_sentry_logger();
70360
70632
  init_log_fields();
70633
+ init_runtime_metadata();
70361
70634
  var RUNTIME_SWITCH_COMPONENT = "node_runtime_switch";
70362
70635
  async function performRuntimeSwitch(store, options = {}) {
70363
70636
  const result = await switchProviderWithReadinessGate({
@@ -70371,11 +70644,25 @@ async function performRuntimeSwitch(store, options = {}) {
70371
70644
  }
70372
70645
  async function switchProviderWithReadinessGate(options) {
70373
70646
  const gated = await switchProviderWithReadinessGateCore(options);
70374
- emitRuntimeSwitchCheckpoints(gated);
70647
+ if (gated.result.ok) {
70648
+ const provider = normalizeAiRuntimeProvider(gated.result.provider);
70649
+ persistAiRuntimeSurfaceBestEffort(
70650
+ options.store,
70651
+ detectAiRuntimeSurface(provider, options.env)
70652
+ );
70653
+ }
70654
+ emitRuntimeSwitchCheckpoints(gated, options.env);
70375
70655
  return gated.result;
70376
70656
  }
70377
- function emitRuntimeSwitchCheckpoints(gated) {
70657
+ function emitRuntimeSwitchCheckpoints(gated, env = process.env) {
70378
70658
  const { result, runtime, readiness } = gated;
70659
+ const runtimeProvider = normalizeAiRuntimeProvider(
70660
+ result.ok ? result.provider : runtime
70661
+ );
70662
+ setRuntimeMetadata({
70663
+ aiProvider: runtimeProvider,
70664
+ runtimeSurface: detectAiRuntimeSurface(runtimeProvider, env)
70665
+ });
70379
70666
  logger.info(LogEvent.RUNTIME_DETECTED, {
70380
70667
  component: RUNTIME_SWITCH_COMPONENT,
70381
70668
  provider: runtime,
@@ -71316,7 +71603,7 @@ async function runDoctor(options = {}) {
71316
71603
  platform: options.platform ?? process.platform,
71317
71604
  env: options.env ?? process.env,
71318
71605
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
71319
- cliVersion: options.cliVersion ?? (true ? "0.2.7" : "0.0.0"),
71606
+ cliVersion: options.cliVersion ?? (true ? "0.2.8-beta-e334c22780-260818180029" : "0.0.0"),
71320
71607
  fixMode: options.fix === true,
71321
71608
  nonInteractive: options.nonInteractive === true,
71322
71609
  packageChanged: false,
@@ -71650,6 +71937,7 @@ init_autostart_windows();
71650
71937
  createUserAttentionWatchParentMonitor,
71651
71938
  currentOpenClawGatewaySessionKey,
71652
71939
  detectAiProviders,
71940
+ detectAiRuntimeSurface,
71653
71941
  detectCurrentAiProvider,
71654
71942
  detectGatewayInvocation,
71655
71943
  detectMessageEligibleOfflineReplaySupport,
@@ -71670,6 +71958,7 @@ init_autostart_windows();
71670
71958
  getA2ACapabilities,
71671
71959
  getDaemonStatus,
71672
71960
  getHermesGatewayPluginStatus,
71961
+ getRuntimeMetadata,
71673
71962
  getSessionBusyTracker,
71674
71963
  handleCapabilitiesCommand,
71675
71964
  handleDoctorCommand,
@@ -71694,6 +71983,7 @@ init_autostart_windows();
71694
71983
  isPrereleaseVersion,
71695
71984
  isRetryableOpenClawGatewayError,
71696
71985
  isSqliteBusyError,
71986
+ isTagKey,
71697
71987
  isWindowsElevated,
71698
71988
  killProcessTree,
71699
71989
  launchdPlistHasCurrentRestartPolicy,
@@ -71705,16 +71995,19 @@ init_autostart_windows();
71705
71995
  messageEligibleHelpAdvertisesOfflineReplay,
71706
71996
  nodeVersionSatisfies,
71707
71997
  normalizeAiProvider,
71998
+ normalizeAiRuntimeProvider,
71708
71999
  normalizeHermesOkxA2aPluginConfig,
71709
72000
  notifyAgentMessageToUserAttention,
71710
72001
  notifyDirectToUserAttention,
71711
72002
  notifySystemMessageToUser,
71712
72003
  notifyUserAttentionChanged,
71713
72004
  parseLogsExportArgs,
72005
+ parseOnchainosVersionOutput,
71714
72006
  parsePluginYamlVersion,
71715
72007
  parseWalletLoginStatus,
71716
72008
  parseWindowsParentProcessJson,
71717
72009
  performRuntimeSwitch,
72010
+ persistAiRuntimeSurfaceBestEffort,
71718
72011
  persistCurrentRuntimeSelectionForNewJob,
71719
72012
  pickOnchainosWin32Candidate,
71720
72013
  prepareAndBindCurrentRuntimeForNewJob,
@@ -71724,11 +72017,13 @@ init_autostart_windows();
71724
72017
  processFileMessage,
71725
72018
  queryWalletLoginStatus,
71726
72019
  readAiProviderTimeoutMs,
72020
+ readAiRuntimeSurfaceBestEffort,
71727
72021
  readCachedCodexReadiness,
71728
72022
  readLastLines,
71729
72023
  readParentProcessCommandForPlatform,
71730
72024
  readUserAttentionWatcherEvent,
71731
72025
  refreshAgentsAndWait,
72026
+ refreshOnchainosVersionMetadata,
71732
72027
  registerUserAttentionWatcher,
71733
72028
  releaseActiveDaemon,
71734
72029
  removeUserAttentionWatcher,
@@ -71768,8 +72063,10 @@ init_autostart_windows();
71768
72063
  runDoctor,
71769
72064
  runHeartbeatRefreshCycle,
71770
72065
  runListener,
72066
+ runtimeMetadataFields,
71771
72067
  scanUserAttentionWatchers,
71772
72068
  setOpenClawWebSocketFactoryForTests,
72069
+ setRuntimeMetadata,
71773
72070
  shouldDelegateToSupervisor,
71774
72071
  shouldRouteThroughWindowsShell,
71775
72072
  spawnCompat,