@okxweb3/a2a-node 0.1.5 → 0.1.6

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 +349 -256
  2. package/dist/index.js +878 -765
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1824,6 +1824,13 @@ var init_daemon_lock = __esm({
1824
1824
  });
1825
1825
 
1826
1826
  // src/daemon.ts
1827
+ var daemon_exports = {};
1828
+ __export(daemon_exports, {
1829
+ ensureDaemonReady: () => ensureDaemonReady,
1830
+ getDaemonStatus: () => getDaemonStatus,
1831
+ startDaemon: () => startDaemon,
1832
+ stopDaemon: () => stopDaemon
1833
+ });
1827
1834
  async function readPid(pidPath) {
1828
1835
  try {
1829
1836
  const raw = await (0, import_promises2.readFile)(pidPath, "utf8");
@@ -8293,7 +8300,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
8293
8300
  client: {
8294
8301
  id: "gateway-client",
8295
8302
  displayName: "okx-a2a-node",
8296
- version: "0.1.5",
8303
+ version: "0.1.6",
8297
8304
  platform: "node",
8298
8305
  mode: "backend",
8299
8306
  instanceId
@@ -8304,7 +8311,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
8304
8311
  commands: [],
8305
8312
  permissions: {},
8306
8313
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
8307
- userAgent: `okx-a2a-node/${"0.1.5"}`,
8314
+ userAgent: `okx-a2a-node/${"0.1.6"}`,
8308
8315
  auth: {
8309
8316
  ...config.token ? { token: config.token } : {},
8310
8317
  ...config.password ? { password: config.password } : {}
@@ -24347,6 +24354,7 @@ var init_events = __esm({
24347
24354
  ONCHAINOS_CLI_ERROR: "Onchainos CLI error",
24348
24355
  HEARTBEAT_FAILED: "Heartbeat failed",
24349
24356
  HEARTBEAT_SKIPPED: "Heartbeat skipped",
24357
+ HEARTBEAT_GATEWAY_CHECK_FAILED: "Heartbeat gateway check failed",
24350
24358
  MESSAGE_PARSE_FAILED: "Message parse failed",
24351
24359
  MESSAGE_HANDLER_ERROR: "Message handler error",
24352
24360
  OFFLINE_REPLAY_FAILED: "Offline replay failed",
@@ -25560,7 +25568,7 @@ var init_sentry_config = __esm({
25560
25568
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
25561
25569
  SENTRY_CONFIG = {
25562
25570
  projectName: "okx/openclaw-okx-a2a-extension",
25563
- release: "0.1.5",
25571
+ release: "0.1.6",
25564
25572
  environment
25565
25573
  };
25566
25574
  }
@@ -93842,6 +93850,7 @@ __export(listener_exports, {
93842
93850
  DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC: () => DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC,
93843
93851
  HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS: () => HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS,
93844
93852
  XMTP_CLIENT_RECYCLE_INTERVAL_ENV: () => XMTP_CLIENT_RECYCLE_INTERVAL_ENV,
93853
+ getHermesGatewayPluginStatus: () => getHermesGatewayPluginStatus,
93845
93854
  hermesConfigEnablesOkxA2a: () => hermesConfigEnablesOkxA2a,
93846
93855
  isGatewayAvailableForHeartbeat: () => isGatewayAvailableForHeartbeat,
93847
93856
  isHermesGatewayPluginEnabled: () => isHermesGatewayPluginEnabled,
@@ -93880,20 +93889,31 @@ async function isGatewayAvailableForHeartbeat(options) {
93880
93889
  }
93881
93890
  return isHermesGatewayPluginEnabled({ env: options.env });
93882
93891
  }
93883
- async function isHermesGatewayPluginEnabled(options = {}) {
93892
+ async function getHermesGatewayPluginStatus(options = {}) {
93884
93893
  const env = options.env ?? process.env;
93885
- if (options.requireGatewayRuntime && detectGatewayInvocation(env) !== "hermes") {
93886
- return false;
93887
- }
93888
93894
  const hermesHome = env.HERMES_HOME?.trim() || (0, import_node_path23.join)((0, import_node_os7.homedir)(), ".hermes");
93889
- if (!(0, import_node_fs18.existsSync)((0, import_node_path23.join)(hermesHome, "plugins", "platforms", "okx-a2a", "plugin.yaml"))) {
93890
- return false;
93895
+ const pluginYamlPath = (0, import_node_path23.join)(hermesHome, "plugins", "platforms", "okx-a2a", "plugin.yaml");
93896
+ if (!(0, import_node_fs18.existsSync)(pluginYamlPath)) {
93897
+ return { enabled: false, reason: "plugin_yaml_missing", hermesHome, checkedPath: pluginYamlPath };
93891
93898
  }
93899
+ const configPath = (0, import_node_path23.join)(hermesHome, "config.yaml");
93900
+ let content3;
93892
93901
  try {
93893
- return hermesConfigEnablesOkxA2a(await (0, import_promises9.readFile)((0, import_node_path23.join)(hermesHome, "config.yaml"), "utf8"));
93902
+ content3 = await (0, import_promises9.readFile)(configPath, "utf8");
93894
93903
  } catch {
93904
+ return { enabled: false, reason: "config_read_error", hermesHome, checkedPath: configPath };
93905
+ }
93906
+ if (!hermesConfigEnablesOkxA2a(content3)) {
93907
+ return { enabled: false, reason: "config_disabled", hermesHome, checkedPath: configPath };
93908
+ }
93909
+ return { enabled: true, hermesHome, checkedPath: pluginYamlPath };
93910
+ }
93911
+ async function isHermesGatewayPluginEnabled(options = {}) {
93912
+ const env = options.env ?? process.env;
93913
+ if (options.requireGatewayRuntime && detectGatewayInvocation(env) !== "hermes") {
93895
93914
  return false;
93896
93915
  }
93916
+ return (await getHermesGatewayPluginStatus({ env })).enabled;
93897
93917
  }
93898
93918
  function hermesConfigEnablesOkxA2a(content3) {
93899
93919
  let inPlugins = false;
@@ -94066,12 +94086,12 @@ async function runListenerWithLock(options, paths) {
94066
94086
  }));
94067
94087
  }
94068
94088
  });
94069
- service.setPluginVersion("0.1.5");
94089
+ service.setPluginVersion("0.1.6");
94070
94090
  await service.init();
94071
94091
  const pluginVersionStatus = service.pluginVersionStatus;
94072
94092
  if (pluginVersionStatus.unavailable) {
94073
94093
  throw new Error(
94074
- `@okxweb3/a2a-node v${"0.1.5"} is below the required minimum v${pluginVersionStatus.minVersion}`
94094
+ `@okxweb3/a2a-node v${"0.1.6"} is below the required minimum v${pluginVersionStatus.minVersion}`
94075
94095
  );
94076
94096
  }
94077
94097
  const systemConfig = service.getSystemConfig();
@@ -94089,7 +94109,7 @@ async function runListenerWithLock(options, paths) {
94089
94109
  onchainosAgentId: "*",
94090
94110
  reason: "system-config missing sentryDsn",
94091
94111
  pluginId: "@okxweb3/a2a-node",
94092
- pluginVersion: "0.1.5"
94112
+ pluginVersion: "0.1.6"
94093
94113
  });
94094
94114
  }
94095
94115
  logWithTimestamp(
@@ -94129,7 +94149,28 @@ async function runListenerWithLock(options, paths) {
94129
94149
  const hasActiveAgents = service.getClients().size > 0;
94130
94150
  let shouldHeartbeat = hasActiveAgents;
94131
94151
  const heartbeatProvider = resolveConfiguredAiProvider({ store: sessionStore }) ?? detectGatewayInvocation();
94132
- if (hasActiveAgents) {
94152
+ if (hasActiveAgents && heartbeatProvider === "hermes") {
94153
+ const hermesStatus = await getHermesGatewayPluginStatus();
94154
+ if (!hermesStatus.enabled) {
94155
+ logWithTimestamp(
94156
+ `[okx-agent-task] provider=hermes gateway check failed (${hermesStatus.reason}), sending heartbeat anyway`
94157
+ );
94158
+ logger.error(
94159
+ LogEvent.HEARTBEAT_GATEWAY_CHECK_FAILED,
94160
+ new Error(`heartbeat gateway check failed: provider=hermes reason=${hermesStatus.reason}`),
94161
+ {
94162
+ component: "node_listener",
94163
+ stage: "sync_tick",
94164
+ reason: hermesStatus.reason ?? "unknown",
94165
+ provider: "hermes",
94166
+ hermesHome: hermesStatus.hermesHome,
94167
+ checkedPath: hermesStatus.checkedPath,
94168
+ chainIndex: ONCHAINOS_CHAIN_INDEX,
94169
+ communicationClass: "gateway_or_plugin"
94170
+ }
94171
+ );
94172
+ }
94173
+ } else if (hasActiveAgents) {
94133
94174
  const gatewayAvailable = await isGatewayAvailableForHeartbeat({
94134
94175
  provider: heartbeatProvider
94135
94176
  });
@@ -97167,6 +97208,207 @@ var init_ai_cli = __esm({
97167
97208
  }
97168
97209
  });
97169
97210
 
97211
+ // src/win-native-launcher.ts
97212
+ var win_native_launcher_exports = {};
97213
+ __export(win_native_launcher_exports, {
97214
+ NATIVE_LAUNCHER_EXE_NAME: () => NATIVE_LAUNCHER_EXE_NAME,
97215
+ buildLauncherEntryJs: () => buildLauncherEntryJs,
97216
+ buildSeaConfig: () => buildSeaConfig,
97217
+ ensureWindowsNativeLauncher: () => ensureWindowsNativeLauncher,
97218
+ findWindowsNativeOkxA2aExe: () => findWindowsNativeOkxA2aExe,
97219
+ installWindowsNativeLauncher: () => installWindowsNativeLauncher,
97220
+ resolveRunningCliPath: () => resolveRunningCliPath
97221
+ });
97222
+ function isPostjectRunnable() {
97223
+ try {
97224
+ const probe = spawnSyncCompat(POSTJECT_BIN, ["--help"], {
97225
+ stdio: "ignore",
97226
+ windowsHide: true,
97227
+ timeout: 3e4
97228
+ });
97229
+ return probe.status === 0;
97230
+ } catch {
97231
+ return false;
97232
+ }
97233
+ }
97234
+ function resolvePostjectCommand() {
97235
+ try {
97236
+ const cliPath = (0, import_node_module.createRequire)(__filename).resolve("postject/dist/cli.js");
97237
+ if ((0, import_node_fs21.existsSync)(cliPath)) {
97238
+ return { command: process.execPath, prefixArgs: [cliPath] };
97239
+ }
97240
+ } catch {
97241
+ }
97242
+ if (!isPostjectRunnable()) {
97243
+ logWinCompat(`${WIN_COMPAT_LOG_PREFIX} native launcher: installing ${POSTJECT_SPEC} globally`);
97244
+ const install = spawnSyncCompat("npm", [
97245
+ "install",
97246
+ "-g",
97247
+ POSTJECT_SPEC,
97248
+ "--no-audit",
97249
+ "--no-fund",
97250
+ "--loglevel=error"
97251
+ ], { encoding: "utf8", windowsHide: true, timeout: 18e4 });
97252
+ if (install.status !== 0 || !isPostjectRunnable()) {
97253
+ throw new Error(
97254
+ `failed to install ${POSTJECT_SPEC} (needed to build okx-a2a.exe): ${String(install.stderr || install.error?.message || "unknown error").slice(0, 300)}`
97255
+ );
97256
+ }
97257
+ }
97258
+ return { command: POSTJECT_BIN, prefixArgs: [] };
97259
+ }
97260
+ function injectSeaBlob(exePath, blobPath, isMac) {
97261
+ const { command, prefixArgs: prefixArgs2 } = resolvePostjectCommand();
97262
+ const args = [
97263
+ ...prefixArgs2,
97264
+ exePath,
97265
+ "NODE_SEA_BLOB",
97266
+ blobPath,
97267
+ "--sentinel-fuse",
97268
+ SEA_SENTINEL_FUSE,
97269
+ "--overwrite"
97270
+ ];
97271
+ if (isMac) {
97272
+ args.push("--macho-segment-name", "NODE_SEA");
97273
+ }
97274
+ const result = spawnSyncCompat(command, args, {
97275
+ encoding: "utf8",
97276
+ windowsHide: true,
97277
+ timeout: 12e4
97278
+ });
97279
+ if (result.status !== 0) {
97280
+ throw new Error(
97281
+ `postject injection failed: ${String(result.stderr || result.error?.message || `exit ${result.status}`).slice(0, 300)}`
97282
+ );
97283
+ }
97284
+ }
97285
+ function buildLauncherEntryJs(cliPath) {
97286
+ const target = JSON.stringify(cliPath);
97287
+ return [
97288
+ 'const { createRequire } = require("node:module");',
97289
+ `const nodeRequire = createRequire(${target});`,
97290
+ `nodeRequire(${target});`,
97291
+ ""
97292
+ ].join("\n");
97293
+ }
97294
+ function buildSeaConfig(entryPath, blobPath) {
97295
+ return `${JSON.stringify(
97296
+ {
97297
+ main: entryPath,
97298
+ output: blobPath,
97299
+ disableExperimentalSEAWarning: true
97300
+ },
97301
+ null,
97302
+ 2
97303
+ )}
97304
+ `;
97305
+ }
97306
+ async function installWindowsNativeLauncher(options) {
97307
+ const nodeExe = options.nodeExe ?? process.execPath;
97308
+ if (!(0, import_node_fs21.existsSync)(options.cliPath)) {
97309
+ throw new Error(`cannot build okx-a2a.exe: CLI entry not found at ${options.cliPath}`);
97310
+ }
97311
+ if (!(0, import_node_fs21.existsSync)(nodeExe)) {
97312
+ throw new Error(`cannot build okx-a2a.exe: node executable not found at ${nodeExe}`);
97313
+ }
97314
+ const exePath = (0, import_node_path26.join)(options.targetDir, NATIVE_LAUNCHER_EXE_NAME);
97315
+ (0, import_node_fs21.mkdirSync)(options.targetDir, { recursive: true });
97316
+ const work = (0, import_node_fs21.mkdtempSync)((0, import_node_path26.join)((0, import_node_os9.tmpdir)(), "okx-a2a-sea-"));
97317
+ try {
97318
+ const entryPath = (0, import_node_path26.join)(work, "launcher-entry.js");
97319
+ const blobPath = (0, import_node_path26.join)(work, "okx-a2a.blob");
97320
+ const configPath = (0, import_node_path26.join)(work, "sea-config.json");
97321
+ (0, import_node_fs21.writeFileSync)(entryPath, buildLauncherEntryJs(options.cliPath), "utf8");
97322
+ (0, import_node_fs21.writeFileSync)(configPath, buildSeaConfig(entryPath, blobPath), "utf8");
97323
+ (0, import_node_child_process7.execFileSync)(nodeExe, ["--experimental-sea-config", configPath], {
97324
+ stdio: "ignore",
97325
+ windowsHide: true
97326
+ });
97327
+ (0, import_node_fs21.copyFileSync)(nodeExe, exePath);
97328
+ const isMac = process.platform === "darwin";
97329
+ if (isMac) {
97330
+ try {
97331
+ (0, import_node_child_process7.execFileSync)("codesign", ["--remove-signature", exePath], { stdio: "ignore" });
97332
+ } catch {
97333
+ }
97334
+ }
97335
+ injectSeaBlob(exePath, blobPath, isMac);
97336
+ if (isMac) {
97337
+ try {
97338
+ (0, import_node_child_process7.execFileSync)("codesign", ["--sign", "-", exePath], { stdio: "ignore" });
97339
+ } catch {
97340
+ }
97341
+ }
97342
+ logWinCompat(
97343
+ `${WIN_COMPAT_LOG_PREFIX} native launcher: built ${exePath} from node=${nodeExe} cli=${options.cliPath}`
97344
+ );
97345
+ return { exePath, cliPath: options.cliPath, nodeExe };
97346
+ } finally {
97347
+ (0, import_node_fs21.rmSync)(work, { recursive: true, force: true });
97348
+ }
97349
+ }
97350
+ function findWindowsNativeOkxA2aExe(pathValue, appData, userProfile, fileExists2 = import_node_fs21.existsSync) {
97351
+ const dirs = pathValue.split(";").map((d) => d.trim()).filter(Boolean);
97352
+ if (appData) {
97353
+ dirs.push((0, import_node_path26.join)(appData, "npm"));
97354
+ }
97355
+ if (userProfile) {
97356
+ dirs.push((0, import_node_path26.join)(userProfile, ".local", "bin"));
97357
+ }
97358
+ for (const dir of dirs) {
97359
+ const candidate = (0, import_node_path26.join)(dir, NATIVE_LAUNCHER_EXE_NAME);
97360
+ if (fileExists2(candidate)) {
97361
+ return candidate;
97362
+ }
97363
+ }
97364
+ return null;
97365
+ }
97366
+ function resolveRunningCliPath() {
97367
+ const fromArgv = process.argv[1];
97368
+ if (fromArgv && /(?:^|[\\/])cli\.js$/.test(fromArgv) && (0, import_node_fs21.existsSync)(fromArgv)) {
97369
+ return fromArgv;
97370
+ }
97371
+ const beside = (0, import_node_path26.join)(__dirname, "cli.js");
97372
+ if ((0, import_node_fs21.existsSync)(beside)) {
97373
+ return beside;
97374
+ }
97375
+ if (fromArgv) {
97376
+ return fromArgv;
97377
+ }
97378
+ throw new Error("could not resolve the running okx-a2a CLI path for the native launcher");
97379
+ }
97380
+ async function ensureWindowsNativeLauncher(options = {}) {
97381
+ const platform = options.platform ?? process.platform;
97382
+ if (platform !== "win32") {
97383
+ return null;
97384
+ }
97385
+ const env = options.env ?? process.env;
97386
+ const existing = findWindowsNativeOkxA2aExe(env.PATH ?? env.Path ?? "", env.APPDATA, env.USERPROFILE);
97387
+ if (existing) {
97388
+ return { exePath: existing, installed: false };
97389
+ }
97390
+ const targetDir = env.APPDATA ? (0, import_node_path26.join)(env.APPDATA, "npm") : (0, import_node_path26.join)(env.USERPROFILE ?? (0, import_node_os9.homedir)(), ".local", "bin");
97391
+ const result = await installWindowsNativeLauncher({ cliPath: resolveRunningCliPath(), targetDir });
97392
+ return { exePath: result.exePath, installed: true };
97393
+ }
97394
+ var import_node_child_process7, import_node_fs21, import_node_module, import_node_os9, import_node_path26, SEA_SENTINEL_FUSE, NATIVE_LAUNCHER_EXE_NAME, POSTJECT_SPEC, POSTJECT_BIN;
97395
+ var init_win_native_launcher = __esm({
97396
+ "src/win-native-launcher.ts"() {
97397
+ "use strict";
97398
+ import_node_child_process7 = require("node:child_process");
97399
+ import_node_fs21 = require("node:fs");
97400
+ import_node_module = require("node:module");
97401
+ import_node_os9 = require("node:os");
97402
+ import_node_path26 = require("node:path");
97403
+ init_win_compat();
97404
+ init_win_spawn();
97405
+ SEA_SENTINEL_FUSE = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
97406
+ NATIVE_LAUNCHER_EXE_NAME = "okx-a2a.exe";
97407
+ POSTJECT_SPEC = "postject@1.0.0-alpha.6";
97408
+ POSTJECT_BIN = "postject";
97409
+ }
97410
+ });
97411
+
97170
97412
  // src/update-cli.ts
97171
97413
  var update_cli_exports = {};
97172
97414
  __export(update_cli_exports, {
@@ -97192,6 +97434,8 @@ __export(update_cli_exports, {
97192
97434
  parseUpdateArgs: () => parseUpdateArgs,
97193
97435
  printSetupUsage: () => printSetupUsage,
97194
97436
  printUpdateUsage: () => printUpdateUsage,
97437
+ resolveHermesConfigPath: () => resolveHermesConfigPath,
97438
+ resolveHermesPluginYamlPath: () => resolveHermesPluginYamlPath,
97195
97439
  runProviderLoginInteractive: () => runProviderLoginInteractive,
97196
97440
  setRedirectCommandStdoutToStderr: () => setRedirectCommandStdoutToStderr
97197
97441
  });
@@ -97405,6 +97649,7 @@ async function runSetup(options) {
97405
97649
  if (nodeChange.nodeChanged && provider) {
97406
97650
  await restartNodeDaemonAfterNodeSetup();
97407
97651
  }
97652
+ await ensureWindowsNativeLauncherForSetup();
97408
97653
  return {
97409
97654
  ok: true,
97410
97655
  state: "ready",
@@ -97438,6 +97683,7 @@ async function runSetup(options) {
97438
97683
  if (changes.pluginChanged) {
97439
97684
  await restartGatewayAfterSetup(resolvedTarget);
97440
97685
  }
97686
+ await ensureWindowsNativeLauncherForSetup();
97441
97687
  warnIfProviderMismatch(resolvedTarget);
97442
97688
  return {
97443
97689
  ok: true,
@@ -97884,7 +98130,7 @@ async function getCurrentNodeCliVersion() {
97884
98130
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
97885
98131
  }
97886
98132
  function getBundledNodeCliVersion() {
97887
- return true ? "0.1.5" : null;
98133
+ return true ? "0.1.6" : null;
97888
98134
  }
97889
98135
  function readConfiguredAiProvider() {
97890
98136
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -97915,10 +98161,29 @@ async function restartNodeDaemonAfterUpdate() {
97915
98161
  }
97916
98162
  async function installNode(release, label) {
97917
98163
  const spec = buildNpmPackageSpec("node", release);
98164
+ if (process.platform === "win32") {
98165
+ const { getDaemonStatus: getDaemonStatus2, stopDaemon: stopDaemon2 } = await Promise.resolve().then(() => (init_daemon(), daemon_exports));
98166
+ const status = await getDaemonStatus2();
98167
+ if (status.running) {
98168
+ console.log(`[${label}] stopping the running daemon before reinstalling on Windows (its native addons lock the package dir)`);
98169
+ await stopDaemon2();
98170
+ }
98171
+ }
97918
98172
  console.log(`[${label}] installing ${spec}`);
97919
98173
  await runCommand("npm", ["install", "-g", spec]);
97920
98174
  console.log(`[${label}] okx-a2a node CLI ${label === "setup" ? "setup" : "update"} done`);
97921
98175
  }
98176
+ async function ensureWindowsNativeLauncherForSetup() {
98177
+ if (process.platform !== "win32") {
98178
+ return;
98179
+ }
98180
+ const { ensureWindowsNativeLauncher: ensureWindowsNativeLauncher2 } = await Promise.resolve().then(() => (init_win_native_launcher(), win_native_launcher_exports));
98181
+ const result = await ensureWindowsNativeLauncher2();
98182
+ if (!result) {
98183
+ return;
98184
+ }
98185
+ console.log(result.installed ? `[setup] built native okx-a2a.exe launcher at ${result.exePath}` : `[setup] native okx-a2a.exe launcher already present at ${result.exePath}`);
98186
+ }
97922
98187
  async function restartNodeDaemonAfterSetup(provider) {
97923
98188
  console.log(`[setup] restarting okx-a2a daemon after node CLI setup with provider=${provider}`);
97924
98189
  await runCommand("okx-a2a", ["daemon", "restart", "--provider", provider]);
@@ -98050,17 +98315,17 @@ async function updateHermes(release, options) {
98050
98315
  assertNotRunningInsideGateway("hermes");
98051
98316
  }
98052
98317
  const spec = buildNpmPackageSpec("hermes", release);
98053
- const workDir = await (0, import_promises10.mkdtemp)((0, import_node_path26.join)((0, import_node_os9.tmpdir)(), `okx-a2a-${label}-hermes-`));
98318
+ const workDir = await (0, import_promises10.mkdtemp)((0, import_node_path27.join)((0, import_node_os10.tmpdir)(), `okx-a2a-${label}-hermes-`));
98054
98319
  try {
98055
98320
  console.log(`[${label}] downloading ${spec}`);
98056
98321
  const npmTarball = await npmPack(spec, workDir);
98057
- const npmPackageDir = (0, import_node_path26.join)(workDir, "npm-package");
98322
+ const npmPackageDir = (0, import_node_path27.join)(workDir, "npm-package");
98058
98323
  await runCommand("tar", ["-xzf", npmTarball, "-C", npmPackageDir], { ensureDir: npmPackageDir });
98059
- const pluginTarball = await findHermesPluginTarball((0, import_node_path26.join)(npmPackageDir, "package", "dist"));
98060
- const pluginDir = (0, import_node_path26.join)(workDir, "plugin");
98324
+ const pluginTarball = await findHermesPluginTarball((0, import_node_path27.join)(npmPackageDir, "package", "dist"));
98325
+ const pluginDir = (0, import_node_path27.join)(workDir, "plugin");
98061
98326
  await runCommand("tar", ["-xzf", pluginTarball, "-C", pluginDir], { ensureDir: pluginDir });
98062
98327
  const unpackedPluginDir = await findFirstDirectory(pluginDir);
98063
- const installer = (0, import_node_path26.join)(unpackedPluginDir, "scripts", "install-or-upgrade.sh");
98328
+ const installer = (0, import_node_path27.join)(unpackedPluginDir, "scripts", "install-or-upgrade.sh");
98064
98329
  console.log(`[${label}] running ${installer}`);
98065
98330
  await runCommand("bash", [installer, ...options.restart ? ["--restart"] : []], { cwd: unpackedPluginDir });
98066
98331
  await normalizeHermesOkxA2aPluginConfig();
@@ -98075,7 +98340,7 @@ async function updateHermes(release, options) {
98075
98340
  }
98076
98341
  }
98077
98342
  async function installGatewayPluginForDoctor(target) {
98078
- const release = isPrereleaseVersion("0.1.5") ? "beta" : "latest";
98343
+ const release = isPrereleaseVersion("0.1.6") ? "beta" : "latest";
98079
98344
  const insideTargetGateway = detectGatewayInvocation() === target;
98080
98345
  const options = {
98081
98346
  restart: !insideTargetGateway,
@@ -98126,7 +98391,7 @@ async function ensureHermesOkxA2aPluginConfig(configFile = resolveHermesConfigPa
98126
98391
  if (options.dryRun) {
98127
98392
  return true;
98128
98393
  }
98129
- await (0, import_promises10.mkdir)((0, import_node_path26.resolve)(configFile, ".."), { recursive: true });
98394
+ await (0, import_promises10.mkdir)((0, import_node_path27.resolve)(configFile, ".."), { recursive: true });
98130
98395
  await (0, import_promises10.writeFile)(configFile, "plugins:\n enabled:\n - okx-a2a\n");
98131
98396
  console.log(`[update] added Hermes plugins.enabled okx-a2a entry in ${configFile}`);
98132
98397
  return true;
@@ -98366,7 +98631,7 @@ function findFirstEnabledListItem(lines, startIndex, enabledIndent) {
98366
98631
  return null;
98367
98632
  }
98368
98633
  function resolveHermesConfigPath() {
98369
- return (0, import_node_path26.join)(process.env.HERMES_HOME ?? (0, import_node_path26.join)((0, import_node_os9.homedir)(), ".hermes"), "config.yaml");
98634
+ return (0, import_node_path27.join)(process.env.HERMES_HOME ?? (0, import_node_path27.join)((0, import_node_os10.homedir)(), ".hermes"), "config.yaml");
98370
98635
  }
98371
98636
  function lineIndent(line) {
98372
98637
  const match = line.match(/^\s*/);
@@ -98443,22 +98708,18 @@ async function assertGatewayPluginInstalled(target) {
98443
98708
  `okx-a2a ${target} plugin is not installed. Run \`okx-a2a setup ${target}\` first; use \`okx-a2a update ${target}\` only for an existing installation.`
98444
98709
  );
98445
98710
  }
98711
+ function resolveHermesPluginYamlPath() {
98712
+ return (0, import_node_path27.join)(process.env.HERMES_HOME ?? (0, import_node_path27.join)((0, import_node_os10.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
98713
+ }
98446
98714
  async function isGatewayPluginInstalled(target) {
98447
98715
  if (target === "openclaw") {
98448
98716
  return (await getInstalledOpenClawPluginInfo()).installed;
98449
98717
  }
98450
- if ((0, import_node_fs21.existsSync)((0, import_node_path26.join)(process.env.HERMES_HOME ?? (0, import_node_path26.join)((0, import_node_os9.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml"))) {
98451
- return true;
98452
- }
98453
- return await isGlobalNpmPackageInstalled(UPDATE_PACKAGES.hermes);
98454
- }
98455
- async function isGlobalNpmPackageInstalled(packageName) {
98456
- const result = await runCommandCaptureOptional("npm", ["list", "-g", packageName, "--depth=0"]);
98457
- return result.ok && result.stdout.includes(packageName);
98718
+ return (0, import_node_fs22.existsSync)(resolveHermesPluginYamlPath());
98458
98719
  }
98459
98720
  async function getInstalledGatewayPluginVersion(target) {
98460
98721
  if (target === "hermes") {
98461
- return await getInstalledHermesPluginVersion() ?? await getGlobalNpmPackageVersion(UPDATE_PACKAGES.hermes);
98722
+ return await getInstalledHermesPluginVersion();
98462
98723
  }
98463
98724
  return (await getInstalledOpenClawPluginInfo()).version;
98464
98725
  }
@@ -98541,7 +98802,7 @@ function parsePackageVersionFromText(output4) {
98541
98802
  return output4.match(/@okxweb3\/a2a-openclaw@([0-9A-Za-z.+-]+)/)?.[1] ?? null;
98542
98803
  }
98543
98804
  async function getInstalledHermesPluginVersion() {
98544
- const pluginYaml = (0, import_node_path26.join)(process.env.HERMES_HOME ?? (0, import_node_path26.join)((0, import_node_os9.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
98805
+ const pluginYaml = (0, import_node_path27.join)(process.env.HERMES_HOME ?? (0, import_node_path27.join)((0, import_node_os10.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
98545
98806
  try {
98546
98807
  const content3 = await (0, import_promises10.readFile)(pluginYaml, "utf8");
98547
98808
  return parsePluginYamlVersion(content3);
@@ -98599,7 +98860,7 @@ async function npmPack(spec, destination) {
98599
98860
  if (!tarballName) {
98600
98861
  throw new Error(`Unable to detect npm pack tarball from output: ${output4.trim()}`);
98601
98862
  }
98602
- return (0, import_node_path26.resolve)(destination, (0, import_node_path26.basename)(tarballName));
98863
+ return (0, import_node_path27.resolve)(destination, (0, import_node_path27.basename)(tarballName));
98603
98864
  }
98604
98865
  async function findHermesPluginTarball(distDir) {
98605
98866
  const entries = await (0, import_promises10.readdir)(distDir);
@@ -98607,7 +98868,7 @@ async function findHermesPluginTarball(distDir) {
98607
98868
  if (!tarball) {
98608
98869
  throw new Error(`Hermes npm package did not contain dist/okx-a2a-hermes-plugin-*.tar.gz`);
98609
98870
  }
98610
- return (0, import_node_path26.join)(distDir, tarball);
98871
+ return (0, import_node_path27.join)(distDir, tarball);
98611
98872
  }
98612
98873
  async function findFirstDirectory(parent) {
98613
98874
  const entries = await (0, import_promises10.readdir)(parent, { withFileTypes: true });
@@ -98615,7 +98876,7 @@ async function findFirstDirectory(parent) {
98615
98876
  if (!dir) {
98616
98877
  throw new Error(`No unpacked plugin directory found under ${parent}`);
98617
98878
  }
98618
- return (0, import_node_path26.join)(parent, dir.name);
98879
+ return (0, import_node_path27.join)(parent, dir.name);
98619
98880
  }
98620
98881
  function readOption2(args, name2) {
98621
98882
  const index2 = args.indexOf(name2);
@@ -98666,7 +98927,7 @@ async function runCommand(command, args, options = {}) {
98666
98927
  await new Promise((resolvePromise, reject) => {
98667
98928
  const invocation = buildExternalCommandInvocation(command, args);
98668
98929
  const redirect = redirectCommandStdoutToStderr || options.redirectStdoutToStderr === true;
98669
- const child = (0, import_node_child_process7.spawn)(invocation.command, invocation.args, {
98930
+ const child = (0, import_node_child_process8.spawn)(invocation.command, invocation.args, {
98670
98931
  cwd: options.cwd,
98671
98932
  stdio: redirect ? [options.inheritStdin ? "inherit" : "ignore", "pipe", "pipe"] : "inherit",
98672
98933
  windowsVerbatimArguments: invocation.windowsVerbatimArguments
@@ -98710,7 +98971,7 @@ async function runCommand(command, args, options = {}) {
98710
98971
  async function runCommandCapture(command, args) {
98711
98972
  return await new Promise((resolvePromise, reject) => {
98712
98973
  const invocation = buildExternalCommandInvocation(command, args);
98713
- const child = (0, import_node_child_process7.spawn)(invocation.command, invocation.args, {
98974
+ const child = (0, import_node_child_process8.spawn)(invocation.command, invocation.args, {
98714
98975
  stdio: ["ignore", "pipe", "pipe"],
98715
98976
  windowsVerbatimArguments: invocation.windowsVerbatimArguments
98716
98977
  });
@@ -98743,7 +99004,7 @@ ${stderr}`));
98743
99004
  async function runCommandCaptureOptional(command, args) {
98744
99005
  return await new Promise((resolvePromise) => {
98745
99006
  const invocation = buildExternalCommandInvocation(command, args);
98746
- const child = (0, import_node_child_process7.spawn)(invocation.command, invocation.args, {
99007
+ const child = (0, import_node_child_process8.spawn)(invocation.command, invocation.args, {
98747
99008
  stdio: ["ignore", "pipe", "ignore"],
98748
99009
  windowsVerbatimArguments: invocation.windowsVerbatimArguments
98749
99010
  });
@@ -98763,7 +99024,7 @@ async function runCommandCaptureOptional(command, args) {
98763
99024
  async function runCommandCaptureStatus(command, args) {
98764
99025
  return await new Promise((resolvePromise) => {
98765
99026
  const invocation = buildExternalCommandInvocation(command, args);
98766
- const child = (0, import_node_child_process7.spawn)(invocation.command, invocation.args, {
99027
+ const child = (0, import_node_child_process8.spawn)(invocation.command, invocation.args, {
98767
99028
  stdio: ["ignore", "pipe", "pipe"],
98768
99029
  windowsVerbatimArguments: invocation.windowsVerbatimArguments
98769
99030
  });
@@ -98805,15 +99066,15 @@ function buildExternalCommandInvocation(command, args, platform = process.platfo
98805
99066
  function formatExternalCommand(command, args) {
98806
99067
  return [command, ...args].join(" ");
98807
99068
  }
98808
- var import_node_child_process7, import_node_fs21, import_promises10, import_node_os9, import_node_path26, UPDATE_PACKAGES, CODEX_NPM_PACKAGE, OPENCLAW_FORCE_INSTALL_FLAG, OPENCLAW_UNSAFE_INSTALL_FLAG, OKX_A2A_PLUGIN_ID, OPENCLAW_SESSION_DM_SCOPE_CONFIG_PATH, OPENCLAW_SESSION_DM_SCOPE_CONFIG_VALUE, OPENCLAW_PLUGIN_ALLOW_CONFIG_PATH, OPENCLAW_OKX_A2A_CONVERSATION_HOOK_ACCESS_CONFIG_PATH, DEFAULT_AI_PROVIDER_LOGIN_TIMEOUT_MS, SetupBlockedError, redirectCommandStdoutToStderr;
99069
+ var import_node_child_process8, import_node_fs22, import_promises10, import_node_os10, import_node_path27, UPDATE_PACKAGES, CODEX_NPM_PACKAGE, OPENCLAW_FORCE_INSTALL_FLAG, OPENCLAW_UNSAFE_INSTALL_FLAG, OKX_A2A_PLUGIN_ID, OPENCLAW_SESSION_DM_SCOPE_CONFIG_PATH, OPENCLAW_SESSION_DM_SCOPE_CONFIG_VALUE, OPENCLAW_PLUGIN_ALLOW_CONFIG_PATH, OPENCLAW_OKX_A2A_CONVERSATION_HOOK_ACCESS_CONFIG_PATH, DEFAULT_AI_PROVIDER_LOGIN_TIMEOUT_MS, SetupBlockedError, redirectCommandStdoutToStderr;
98809
99070
  var init_update_cli = __esm({
98810
99071
  "src/update-cli.ts"() {
98811
99072
  "use strict";
98812
- import_node_child_process7 = require("node:child_process");
98813
- import_node_fs21 = require("node:fs");
99073
+ import_node_child_process8 = require("node:child_process");
99074
+ import_node_fs22 = require("node:fs");
98814
99075
  import_promises10 = require("node:fs/promises");
98815
- import_node_os9 = require("node:os");
98816
- import_node_path26 = require("node:path");
99076
+ import_node_os10 = require("node:os");
99077
+ import_node_path27 = require("node:path");
98817
99078
  init_ai_command();
98818
99079
  init_win_spawn();
98819
99080
  init_ai_provider();
@@ -98877,160 +99138,6 @@ var init_daemon_ops = __esm({
98877
99138
  }
98878
99139
  });
98879
99140
 
98880
- // src/win-native-launcher.ts
98881
- var win_native_launcher_exports = {};
98882
- __export(win_native_launcher_exports, {
98883
- NATIVE_LAUNCHER_EXE_NAME: () => NATIVE_LAUNCHER_EXE_NAME,
98884
- buildLauncherEntryJs: () => buildLauncherEntryJs,
98885
- buildSeaConfig: () => buildSeaConfig,
98886
- installWindowsNativeLauncher: () => installWindowsNativeLauncher
98887
- });
98888
- function isPostjectRunnable() {
98889
- try {
98890
- const probe = spawnSyncCompat(POSTJECT_BIN, ["--help"], {
98891
- stdio: "ignore",
98892
- windowsHide: true,
98893
- timeout: 3e4
98894
- });
98895
- return probe.status === 0;
98896
- } catch {
98897
- return false;
98898
- }
98899
- }
98900
- function resolvePostjectCommand() {
98901
- try {
98902
- const cliPath = (0, import_node_module.createRequire)(__filename).resolve("postject/dist/cli.js");
98903
- if ((0, import_node_fs22.existsSync)(cliPath)) {
98904
- return { command: process.execPath, prefixArgs: [cliPath] };
98905
- }
98906
- } catch {
98907
- }
98908
- if (!isPostjectRunnable()) {
98909
- logWinCompat(`${WIN_COMPAT_LOG_PREFIX} native launcher: installing ${POSTJECT_SPEC} globally`);
98910
- const install = spawnSyncCompat("npm", [
98911
- "install",
98912
- "-g",
98913
- POSTJECT_SPEC,
98914
- "--no-audit",
98915
- "--no-fund",
98916
- "--loglevel=error"
98917
- ], { encoding: "utf8", windowsHide: true, timeout: 18e4 });
98918
- if (install.status !== 0 || !isPostjectRunnable()) {
98919
- throw new Error(
98920
- `failed to install ${POSTJECT_SPEC} (needed to build okx-a2a.exe): ${String(install.stderr || install.error?.message || "unknown error").slice(0, 300)}`
98921
- );
98922
- }
98923
- }
98924
- return { command: POSTJECT_BIN, prefixArgs: [] };
98925
- }
98926
- function injectSeaBlob(exePath, blobPath, isMac) {
98927
- const { command, prefixArgs: prefixArgs2 } = resolvePostjectCommand();
98928
- const args = [
98929
- ...prefixArgs2,
98930
- exePath,
98931
- "NODE_SEA_BLOB",
98932
- blobPath,
98933
- "--sentinel-fuse",
98934
- SEA_SENTINEL_FUSE,
98935
- "--overwrite"
98936
- ];
98937
- if (isMac) {
98938
- args.push("--macho-segment-name", "NODE_SEA");
98939
- }
98940
- const result = spawnSyncCompat(command, args, {
98941
- encoding: "utf8",
98942
- windowsHide: true,
98943
- timeout: 12e4
98944
- });
98945
- if (result.status !== 0) {
98946
- throw new Error(
98947
- `postject injection failed: ${String(result.stderr || result.error?.message || `exit ${result.status}`).slice(0, 300)}`
98948
- );
98949
- }
98950
- }
98951
- function buildLauncherEntryJs(cliPath) {
98952
- const target = JSON.stringify(cliPath);
98953
- return [
98954
- 'const { createRequire } = require("node:module");',
98955
- `const nodeRequire = createRequire(${target});`,
98956
- `nodeRequire(${target});`,
98957
- ""
98958
- ].join("\n");
98959
- }
98960
- function buildSeaConfig(entryPath, blobPath) {
98961
- return `${JSON.stringify(
98962
- {
98963
- main: entryPath,
98964
- output: blobPath,
98965
- disableExperimentalSEAWarning: true
98966
- },
98967
- null,
98968
- 2
98969
- )}
98970
- `;
98971
- }
98972
- async function installWindowsNativeLauncher(options) {
98973
- const nodeExe = options.nodeExe ?? process.execPath;
98974
- if (!(0, import_node_fs22.existsSync)(options.cliPath)) {
98975
- throw new Error(`cannot build okx-a2a.exe: CLI entry not found at ${options.cliPath}`);
98976
- }
98977
- if (!(0, import_node_fs22.existsSync)(nodeExe)) {
98978
- throw new Error(`cannot build okx-a2a.exe: node executable not found at ${nodeExe}`);
98979
- }
98980
- const exePath = (0, import_node_path27.join)(options.targetDir, NATIVE_LAUNCHER_EXE_NAME);
98981
- (0, import_node_fs22.mkdirSync)(options.targetDir, { recursive: true });
98982
- const work = (0, import_node_fs22.mkdtempSync)((0, import_node_path27.join)((0, import_node_os10.tmpdir)(), "okx-a2a-sea-"));
98983
- try {
98984
- const entryPath = (0, import_node_path27.join)(work, "launcher-entry.js");
98985
- const blobPath = (0, import_node_path27.join)(work, "okx-a2a.blob");
98986
- const configPath = (0, import_node_path27.join)(work, "sea-config.json");
98987
- (0, import_node_fs22.writeFileSync)(entryPath, buildLauncherEntryJs(options.cliPath), "utf8");
98988
- (0, import_node_fs22.writeFileSync)(configPath, buildSeaConfig(entryPath, blobPath), "utf8");
98989
- (0, import_node_child_process8.execFileSync)(nodeExe, ["--experimental-sea-config", configPath], {
98990
- stdio: "ignore",
98991
- windowsHide: true
98992
- });
98993
- (0, import_node_fs22.copyFileSync)(nodeExe, exePath);
98994
- const isMac = process.platform === "darwin";
98995
- if (isMac) {
98996
- try {
98997
- (0, import_node_child_process8.execFileSync)("codesign", ["--remove-signature", exePath], { stdio: "ignore" });
98998
- } catch {
98999
- }
99000
- }
99001
- injectSeaBlob(exePath, blobPath, isMac);
99002
- if (isMac) {
99003
- try {
99004
- (0, import_node_child_process8.execFileSync)("codesign", ["--sign", "-", exePath], { stdio: "ignore" });
99005
- } catch {
99006
- }
99007
- }
99008
- logWinCompat(
99009
- `${WIN_COMPAT_LOG_PREFIX} native launcher: built ${exePath} from node=${nodeExe} cli=${options.cliPath}`
99010
- );
99011
- return { exePath, cliPath: options.cliPath, nodeExe };
99012
- } finally {
99013
- (0, import_node_fs22.rmSync)(work, { recursive: true, force: true });
99014
- }
99015
- }
99016
- var import_node_child_process8, import_node_fs22, import_node_module, import_node_os10, import_node_path27, SEA_SENTINEL_FUSE, NATIVE_LAUNCHER_EXE_NAME, POSTJECT_SPEC, POSTJECT_BIN;
99017
- var init_win_native_launcher = __esm({
99018
- "src/win-native-launcher.ts"() {
99019
- "use strict";
99020
- import_node_child_process8 = require("node:child_process");
99021
- import_node_fs22 = require("node:fs");
99022
- import_node_module = require("node:module");
99023
- import_node_os10 = require("node:os");
99024
- import_node_path27 = require("node:path");
99025
- init_win_compat();
99026
- init_win_spawn();
99027
- SEA_SENTINEL_FUSE = "NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2";
99028
- NATIVE_LAUNCHER_EXE_NAME = "okx-a2a.exe";
99029
- POSTJECT_SPEC = "postject@1.0.0-alpha.6";
99030
- POSTJECT_BIN = "postject";
99031
- }
99032
- });
99033
-
99034
99141
  // src/doctor-cli.ts
99035
99142
  var doctor_cli_exports = {};
99036
99143
  __export(doctor_cli_exports, {
@@ -99113,43 +99220,14 @@ function resolveDoctorTarget(env = process.env) {
99113
99220
  function skipped(id, title, severity, reason) {
99114
99221
  return { id, title, status: "skipped", severity, detail: reason };
99115
99222
  }
99116
- function findWindowsNativeOkxA2aExe(pathValue, appData, userProfile, fileExists2 = import_node_fs23.existsSync) {
99117
- const dirs = pathValue.split(";").map((d) => d.trim()).filter(Boolean);
99118
- if (appData) {
99119
- dirs.push((0, import_node_path28.join)(appData, "npm"));
99120
- }
99121
- if (userProfile) {
99122
- dirs.push((0, import_node_path28.join)(userProfile, ".local", "bin"));
99123
- }
99124
- for (const dir of dirs) {
99125
- const candidate = (0, import_node_path28.join)(dir, "okx-a2a.exe");
99126
- if (fileExists2(candidate)) {
99127
- return candidate;
99128
- }
99129
- }
99130
- return null;
99131
- }
99132
- function resolveRunningCliPath() {
99133
- const fromArgv = process.argv[1];
99134
- if (fromArgv && /(?:^|[\\/])cli\.js$/.test(fromArgv) && (0, import_node_fs23.existsSync)(fromArgv)) {
99135
- return fromArgv;
99136
- }
99137
- const beside = (0, import_node_path28.join)(__dirname, "cli.js");
99138
- if ((0, import_node_fs23.existsSync)(beside)) {
99139
- return beside;
99140
- }
99141
- if (fromArgv) {
99142
- return fromArgv;
99143
- }
99144
- throw new Error("could not resolve the running okx-a2a CLI path for the native launcher");
99145
- }
99146
99223
  async function runDoctor(options = {}) {
99147
99224
  const ctx = {
99148
99225
  platform: options.platform ?? process.platform,
99149
99226
  env: options.env ?? process.env,
99150
99227
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
99151
- cliVersion: options.cliVersion ?? (true ? "0.1.5" : "0.0.0"),
99228
+ cliVersion: options.cliVersion ?? (true ? "0.1.6" : "0.0.0"),
99152
99229
  fixMode: options.fix === true,
99230
+ nonInteractive: options.nonInteractive === true,
99153
99231
  packageChanged: false
99154
99232
  };
99155
99233
  const checkers = options.checkers ?? CHECKERS;
@@ -99290,6 +99368,7 @@ function formatDoctorReportForHumans(report) {
99290
99368
  async function handleDoctorCommand(args) {
99291
99369
  const json = args.includes("--json");
99292
99370
  const fix = args.includes("--fix");
99371
+ const nonInteractive = args.includes("--non-interactive");
99293
99372
  const targetIndex = args.indexOf("--target");
99294
99373
  const rawTarget = targetIndex >= 0 ? args[targetIndex + 1] : void 0;
99295
99374
  if (targetIndex >= 0 && (rawTarget === void 0 || rawTarget.startsWith("--"))) {
@@ -99313,7 +99392,7 @@ async function handleDoctorCommand(args) {
99313
99392
  };
99314
99393
  let report;
99315
99394
  try {
99316
- report = await runDoctor({ fix, ...rawTarget ? { target: rawTarget } : {} });
99395
+ report = await runDoctor({ fix, nonInteractive, ...rawTarget ? { target: rawTarget } : {} });
99317
99396
  } catch (error) {
99318
99397
  restoreStdout();
99319
99398
  const message = error instanceof Error ? error.message : String(error);
@@ -99343,12 +99422,10 @@ async function writeStdoutAndExit(output4, code2) {
99343
99422
  });
99344
99423
  process.exit(code2);
99345
99424
  }
99346
- var import_node_fs23, import_node_os11, import_node_path28, DOCTOR_MIN_NODE_VERSION, DOCTOR_DAEMON_READY_TIMEOUT_MS, NODE_PACKAGE_SPEC, CODEX_INSTALL_SPEC, CLAUDE_INSTALL_SPEC, nodeVersionChecker, npmChecker, cliVersionChecker, windowsNativeLauncherChecker, providerBindingChecker, providerCliChecker, gatewayPluginChecker, gatewayConfigChecker, daemonChecker, agentRefreshChecker, gatewayReachableChecker, autostartChecker, CHECKERS, STATUS_MARK;
99425
+ var import_node_path28, DOCTOR_MIN_NODE_VERSION, DOCTOR_DAEMON_READY_TIMEOUT_MS, NODE_PACKAGE_SPEC, CODEX_INSTALL_SPEC, CLAUDE_INSTALL_SPEC, nodeVersionChecker, npmChecker, cliVersionChecker, windowsNativeLauncherChecker, providerBindingChecker, providerCliChecker, gatewayPluginChecker, gatewayConfigChecker, daemonChecker, agentRefreshChecker, gatewayReachableChecker, autostartChecker, CHECKERS, STATUS_MARK;
99347
99426
  var init_doctor_cli = __esm({
99348
99427
  "src/doctor-cli.ts"() {
99349
99428
  "use strict";
99350
- import_node_fs23 = require("node:fs");
99351
- import_node_os11 = require("node:os");
99352
99429
  import_node_path28 = require("node:path");
99353
99430
  init_log();
99354
99431
  init_win_compat();
@@ -99362,7 +99439,9 @@ var init_doctor_cli = __esm({
99362
99439
  init_runtime_switch();
99363
99440
  init_session_store();
99364
99441
  init_update_cli();
99442
+ init_win_native_launcher();
99365
99443
  init_win_spawn();
99444
+ init_win_native_launcher();
99366
99445
  DOCTOR_MIN_NODE_VERSION = "22.14.0";
99367
99446
  DOCTOR_DAEMON_READY_TIMEOUT_MS = 2e4;
99368
99447
  NODE_PACKAGE_SPEC = "@okxweb3/a2a-node";
@@ -99537,11 +99616,11 @@ var init_doctor_cli = __esm({
99537
99616
  };
99538
99617
  },
99539
99618
  applyFix: async (ctx) => {
99540
- const targetDir = ctx.env.APPDATA ? (0, import_node_path28.join)(ctx.env.APPDATA, "npm") : (0, import_node_path28.join)(ctx.env.USERPROFILE ?? (0, import_node_os11.homedir)(), ".local", "bin");
99541
- const cliPath = resolveRunningCliPath();
99542
- const { installWindowsNativeLauncher: installWindowsNativeLauncher2 } = await Promise.resolve().then(() => (init_win_native_launcher(), win_native_launcher_exports));
99543
- const result = await installWindowsNativeLauncher2({ cliPath, targetDir });
99544
- return `built native launcher ${result.exePath} (SEA over ${result.nodeExe}, entry ${result.cliPath})`;
99619
+ const result = await ensureWindowsNativeLauncher({ env: ctx.env, platform: "win32" });
99620
+ if (!result) {
99621
+ throw new Error("native launcher fix is only applicable on Windows");
99622
+ }
99623
+ return result.installed ? `built native launcher ${result.exePath} (SEA over your node.exe)` : `native launcher already present at ${result.exePath}`;
99545
99624
  }
99546
99625
  };
99547
99626
  providerBindingChecker = {
@@ -99647,7 +99726,14 @@ var init_doctor_cli = __esm({
99647
99726
  status: "fail",
99648
99727
  severity: "required",
99649
99728
  detail: `${provider} CLI at ${resolved} is not logged in (${auth.reason})`,
99650
- fix: {
99729
+ // Logging in needs a human (device/browser auth). In --non-interactive
99730
+ // mode never launch it — degrade to a manual instruction so unattended
99731
+ // callers (install scripts) cannot hang waiting on stdin.
99732
+ fix: ctx.nonInteractive ? {
99733
+ kind: "manual",
99734
+ description: "Log in with the command below, then re-run okx-a2a doctor.",
99735
+ command: loginCommand
99736
+ } : {
99651
99737
  kind: "auto",
99652
99738
  description: "--fix launches the interactive login flow (same as setup: device/browser auth, waits for completion). You can also log in yourself with the command below, then re-run okx-a2a doctor.",
99653
99739
  command: loginCommand
@@ -99686,6 +99772,11 @@ var init_doctor_cli = __esm({
99686
99772
  }
99687
99773
  const auth = provider === "codex" ? await checkCodexCliAuthStatus(resolved) : await checkClaudeCliAuthStatus(resolved);
99688
99774
  if (!auth.ok) {
99775
+ if (ctx.nonInteractive) {
99776
+ throw new Error(
99777
+ `${provider} CLI is installed but not logged in; non-interactive mode skips the login flow \u2014 log in yourself and re-run okx-a2a doctor`
99778
+ );
99779
+ }
99689
99780
  errorWithTimestamp(`[doctor] launching ${provider} CLI login (interactive; waiting for completion)`);
99690
99781
  const login = await runProviderLoginInteractive(provider, resolved);
99691
99782
  if (!login.ok) {
@@ -99709,13 +99800,14 @@ var init_doctor_cli = __esm({
99709
99800
  return null;
99710
99801
  }
99711
99802
  const installed = await isGatewayPluginInstalled(ctx.target);
99803
+ const hermesPathSuffix = ctx.target === "hermes" ? ` (checked ${resolveHermesPluginYamlPath()})` : "";
99712
99804
  if (installed) {
99713
99805
  return {
99714
99806
  id: "gateway_plugin",
99715
99807
  title: "Gateway plugin installed",
99716
99808
  status: "pass",
99717
99809
  severity: "required",
99718
- detail: `${ctx.target} okx-a2a plugin is installed`
99810
+ detail: `${ctx.target} okx-a2a plugin is installed${hermesPathSuffix}`
99719
99811
  };
99720
99812
  }
99721
99813
  const hermesOnWindows = ctx.target === "hermes" && ctx.platform === "win32";
@@ -99724,7 +99816,7 @@ var init_doctor_cli = __esm({
99724
99816
  title: "Gateway plugin installed",
99725
99817
  status: "fail",
99726
99818
  severity: "required",
99727
- detail: `${ctx.target} okx-a2a plugin is not installed`,
99819
+ detail: `${ctx.target} okx-a2a plugin is not installed${hermesPathSuffix}`,
99728
99820
  fix: hermesOnWindows ? {
99729
99821
  kind: "manual",
99730
99822
  description: "Hermes plugin installation requires bash and is not supported on Windows. Use WSL or run setup on macOS/Linux."
@@ -99753,13 +99845,14 @@ var init_doctor_cli = __esm({
99753
99845
  return null;
99754
99846
  }
99755
99847
  const drift = ctx.target === "openclaw" ? await ensureOpenClawOkxA2aPluginConfig({ dryRun: true }) : await ensureHermesOkxA2aPluginConfig(void 0, { dryRun: true });
99848
+ const hermesPathSuffix = ctx.target === "hermes" ? ` (checked ${resolveHermesConfigPath()})` : "";
99756
99849
  if (!drift) {
99757
99850
  return {
99758
99851
  id: "gateway_config",
99759
99852
  title: "Gateway plugin config",
99760
99853
  status: "pass",
99761
99854
  severity: "required",
99762
- detail: `${ctx.target} okx-a2a plugin config is normalized`
99855
+ detail: `${ctx.target} okx-a2a plugin config is normalized${hermesPathSuffix}`
99763
99856
  };
99764
99857
  }
99765
99858
  return {
@@ -99767,7 +99860,7 @@ var init_doctor_cli = __esm({
99767
99860
  title: "Gateway plugin config",
99768
99861
  status: "fail",
99769
99862
  severity: "required",
99770
- detail: `${ctx.target} okx-a2a plugin config needs normalization`,
99863
+ detail: `${ctx.target} okx-a2a plugin config needs normalization${hermesPathSuffix}`,
99771
99864
  fix: { kind: "auto", description: `Apply the ${ctx.target} config normalization in-process.` }
99772
99865
  };
99773
99866
  },
@@ -100021,8 +100114,8 @@ var init_doctor_cli = __esm({
100021
100114
 
100022
100115
  // src/cli.ts
100023
100116
  var import_node_child_process9 = require("node:child_process");
100024
- var import_node_fs24 = require("node:fs");
100025
- var import_node_os12 = require("node:os");
100117
+ var import_node_fs23 = require("node:fs");
100118
+ var import_node_os11 = require("node:os");
100026
100119
  var import_node_path29 = require("node:path");
100027
100120
  init_daemon();
100028
100121
  init_command_store();
@@ -100225,7 +100318,7 @@ init_sentry_logger();
100225
100318
  init_sentry_config();
100226
100319
  var CURRENT_GATEWAY_SESSION_KEYS_ENV4 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
100227
100320
  function printUsage2() {
100228
- console.log(`okx-a2a ${"0.1.5"}
100321
+ console.log(`okx-a2a ${"0.1.6"}
100229
100322
 
100230
100323
  Usage:
100231
100324
  okx-a2a <command> [options]
@@ -100245,7 +100338,7 @@ Commands:
100245
100338
  file Upload or download encrypted XMTP attachments
100246
100339
  ai Run the configured AI CLI adapter
100247
100340
  setup Detect runtime/platform and install missing OpenClaw/Hermes okx-a2a components
100248
- doctor Diagnose the whole A2A environment; --fix repairs what it can
100341
+ doctor Diagnose the whole A2A environment; --fix repairs what it can (--non-interactive skips login flows)
100249
100342
  update Manually update existing okx-a2a packages
100250
100343
  config Configure provider and permission defaults
100251
100344
  ai-provider Legacy AI provider configuration
@@ -100263,7 +100356,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
100263
100356
  `);
100264
100357
  }
100265
100358
  function printVersion() {
100266
- console.log("0.1.5");
100359
+ console.log("0.1.6");
100267
100360
  }
100268
100361
  function printDaemonUsage() {
100269
100362
  console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
@@ -100530,14 +100623,14 @@ function maybeRedirectDaemonSelfLog() {
100530
100623
  }
100531
100624
  try {
100532
100625
  const logPath = resolveTaskPaths().listenerLogPath;
100533
- (0, import_node_fs24.mkdirSync)((0, import_node_path29.join)(logPath, ".."), { recursive: true });
100534
- const fd = (0, import_node_fs24.openSync)(logPath, "a");
100626
+ (0, import_node_fs23.mkdirSync)((0, import_node_path29.join)(logPath, ".."), { recursive: true });
100627
+ const fd = (0, import_node_fs23.openSync)(logPath, "a");
100535
100628
  const writeToLog = ((chunk, encoding, cb) => {
100536
100629
  try {
100537
100630
  if (typeof chunk === "string") {
100538
- (0, import_node_fs24.writeSync)(fd, chunk);
100631
+ (0, import_node_fs23.writeSync)(fd, chunk);
100539
100632
  } else {
100540
- (0, import_node_fs24.writeSync)(fd, chunk);
100633
+ (0, import_node_fs23.writeSync)(fd, chunk);
100541
100634
  }
100542
100635
  } catch {
100543
100636
  }
@@ -101508,10 +101601,10 @@ function initDirectCliSentry() {
101508
101601
  cliSentryInitAttempted = true;
101509
101602
  try {
101510
101603
  const configPath = (0, import_node_path29.join)(resolveTaskHomeForSentryConfig(), "xmtp", "system-config.json");
101511
- if (!(0, import_node_fs24.existsSync)(configPath)) {
101604
+ if (!(0, import_node_fs23.existsSync)(configPath)) {
101512
101605
  return;
101513
101606
  }
101514
- const config = JSON.parse((0, import_node_fs24.readFileSync)(configPath, "utf8"));
101607
+ const config = JSON.parse((0, import_node_fs23.readFileSync)(configPath, "utf8"));
101515
101608
  if (typeof config.sentryDsn !== "string" || !config.sentryDsn) {
101516
101609
  return;
101517
101610
  }
@@ -101529,7 +101622,7 @@ function resolveTaskHomeForSentryConfig() {
101529
101622
  return process.env.OKX_AGENT_TASK_HOME;
101530
101623
  }
101531
101624
  try {
101532
- const home = (0, import_node_os12.homedir)();
101625
+ const home = (0, import_node_os11.homedir)();
101533
101626
  if (home) {
101534
101627
  return (0, import_node_path29.join)(home, ".okx-agent-task");
101535
101628
  }