@okxweb3/a2a-node 0.2.15 → 0.2.16

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 +155 -88
  2. package/dist/index.js +134 -72
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1851,12 +1851,12 @@ async function acquireDaemonLock(paths, entry) {
1851
1851
  }
1852
1852
  return null;
1853
1853
  }
1854
- function activeDaemonPointerPath() {
1855
- return (0, import_node_path4.join)((0, import_node_os2.homedir)(), ".okx-agent-task", "run", "active-daemon.json");
1854
+ function activeDaemonPointerPath(homeDir = resolveA2aTaskHome()) {
1855
+ return (0, import_node_path4.join)(homeDir, "run", "active-daemon.json");
1856
1856
  }
1857
- async function readActiveDaemonPointer() {
1857
+ async function readActiveDaemonPointer(homeDir = resolveA2aTaskHome()) {
1858
1858
  try {
1859
- const raw = await (0, import_promises.readFile)(activeDaemonPointerPath(), "utf8");
1859
+ const raw = await (0, import_promises.readFile)(activeDaemonPointerPath(homeDir), "utf8");
1860
1860
  const parsed = JSON.parse(raw);
1861
1861
  return Number.isInteger(parsed.pid) && parsed.pid > 0 ? parsed : null;
1862
1862
  } catch {
@@ -1865,14 +1865,14 @@ async function readActiveDaemonPointer() {
1865
1865
  }
1866
1866
  async function claimActiveDaemon(homeDir) {
1867
1867
  let evictedPid = null;
1868
- const current = await readActiveDaemonPointer();
1868
+ const current = await readActiveDaemonPointer(homeDir);
1869
1869
  if (current && current.pid !== process.pid && isProcessAlive(current.pid)) {
1870
1870
  if (await evictPid(current.pid)) {
1871
1871
  evictedPid = current.pid;
1872
1872
  }
1873
1873
  }
1874
- const pointerPath = activeDaemonPointerPath();
1875
- await (0, import_promises.mkdir)((0, import_node_path4.dirname)(pointerPath), { recursive: true });
1874
+ const pointerPath = activeDaemonPointerPath(homeDir);
1875
+ ensureTaskDir((0, import_node_path4.dirname)(pointerPath));
1876
1876
  await (0, import_promises.writeFile)(pointerPath, `${JSON.stringify({
1877
1877
  pid: process.pid,
1878
1878
  homeDir,
@@ -1881,10 +1881,10 @@ async function claimActiveDaemon(homeDir) {
1881
1881
  `, "utf8");
1882
1882
  return evictedPid;
1883
1883
  }
1884
- async function releaseActiveDaemon() {
1885
- const current = await readActiveDaemonPointer();
1884
+ async function releaseActiveDaemon(homeDir = resolveA2aTaskHome()) {
1885
+ const current = await readActiveDaemonPointer(homeDir);
1886
1886
  if (current?.pid === process.pid) {
1887
- await (0, import_promises.rm)(activeDaemonPointerPath(), { force: true });
1887
+ await (0, import_promises.rm)(activeDaemonPointerPath(homeDir), { force: true });
1888
1888
  }
1889
1889
  }
1890
1890
  async function chmodBestEffort(path2, mode) {
@@ -1897,12 +1897,11 @@ async function chmodBestEffort(path2, mode) {
1897
1897
  }
1898
1898
  }
1899
1899
  }
1900
- var import_promises, import_node_os2, import_node_path4, OWNER_FILE, EMPTY_LOCK_STALE_MS, DEFAULT_TAKEOVER_GRACE_MS, TAKEOVER_GRACE_ENV, TAKEOVER_POLL_MS, DAEMON_CAPABILITY_AI_DISPATCH, DAEMON_CAPABILITIES;
1900
+ var import_promises, import_node_path4, OWNER_FILE, EMPTY_LOCK_STALE_MS, DEFAULT_TAKEOVER_GRACE_MS, TAKEOVER_GRACE_ENV, TAKEOVER_POLL_MS, DAEMON_CAPABILITY_AI_DISPATCH, DAEMON_CAPABILITIES;
1901
1901
  var init_daemon_lock = __esm({
1902
1902
  "src/daemon-lock.ts"() {
1903
1903
  "use strict";
1904
1904
  import_promises = require("node:fs/promises");
1905
- import_node_os2 = require("node:os");
1906
1905
  import_node_path4 = require("node:path");
1907
1906
  init_paths();
1908
1907
  init_a2a_paths();
@@ -2430,7 +2429,7 @@ function collectCodexAppBundledCandidates(env = process.env, platform = process.
2430
2429
  }
2431
2430
  const roots = (env[CODEX_APP_DIRS_ENV] ?? "").split(import_node_path8.delimiter).filter(Boolean);
2432
2431
  if (platform === "darwin") {
2433
- roots.push("/Applications", (0, import_node_path8.join)(env.HOME || (0, import_node_os3.homedir)(), "Applications"));
2432
+ roots.push("/Applications", (0, import_node_path8.join)(env.HOME || (0, import_node_os2.homedir)(), "Applications"));
2434
2433
  }
2435
2434
  const candidates = [];
2436
2435
  const seen = /* @__PURE__ */ new Set();
@@ -2579,7 +2578,7 @@ function findExecutableCandidatesOnPath(command, pathValue, platform) {
2579
2578
  return candidates;
2580
2579
  }
2581
2580
  function fallbackCandidates(command, env, platform = process.platform) {
2582
- const home = (0, import_node_os3.homedir)();
2581
+ const home = (0, import_node_os2.homedir)();
2583
2582
  const dirs = [
2584
2583
  (0, import_node_path8.dirname)(process.execPath),
2585
2584
  (0, import_node_path8.join)(home, ".local", "bin"),
@@ -2598,8 +2597,8 @@ function providerPathDirs(command, env) {
2598
2597
  return [
2599
2598
  (0, import_node_path8.isAbsolute)(command) ? (0, import_node_path8.dirname)(command) : void 0,
2600
2599
  (0, import_node_path8.dirname)(process.execPath),
2601
- (0, import_node_path8.join)((0, import_node_os3.homedir)(), ".local", "bin"),
2602
- (0, import_node_path8.join)((0, import_node_os3.homedir)(), "Library", "pnpm"),
2600
+ (0, import_node_path8.join)((0, import_node_os2.homedir)(), ".local", "bin"),
2601
+ (0, import_node_path8.join)((0, import_node_os2.homedir)(), "Library", "pnpm"),
2603
2602
  env.PNPM_HOME
2604
2603
  ].filter((dir) => !!dir);
2605
2604
  }
@@ -2676,12 +2675,12 @@ function isCodexCommand(command) {
2676
2675
  function isWindowsAppsPath(commandPath) {
2677
2676
  return /(?:^|[\\/])WindowsApps(?:[\\/]|$)/i.test(commandPath);
2678
2677
  }
2679
- var import_node_fs5, import_node_os3, import_node_path8, DEFAULT_AI_PROVIDER_TIMEOUT_MS, CODEX_PROBE_TIMEOUT_MS, CODEX_APP_DIRS_ENV, CODEX_COMMAND_OVERRIDE_ENV;
2678
+ var import_node_fs5, import_node_os2, import_node_path8, DEFAULT_AI_PROVIDER_TIMEOUT_MS, CODEX_PROBE_TIMEOUT_MS, CODEX_APP_DIRS_ENV, CODEX_COMMAND_OVERRIDE_ENV;
2680
2679
  var init_ai_command = __esm({
2681
2680
  "src/ai-command.ts"() {
2682
2681
  "use strict";
2683
2682
  import_node_fs5 = require("node:fs");
2684
- import_node_os3 = require("node:os");
2683
+ import_node_os2 = require("node:os");
2685
2684
  import_node_path8 = require("node:path");
2686
2685
  init_win_spawn();
2687
2686
  DEFAULT_AI_PROVIDER_TIMEOUT_MS = null;
@@ -2729,14 +2728,14 @@ function isSystemdManagerUnavailableMessage(message) {
2729
2728
  function isAutostartManagerUnavailableError(error) {
2730
2729
  return error instanceof AutostartManagerUnavailableError || typeof error === "object" && error !== null && "code" in error && error.code === "AUTOSTART_MANAGER_UNAVAILABLE";
2731
2730
  }
2732
- function resolveSystemdAutostartPaths(home = (0, import_node_os4.homedir)()) {
2731
+ function resolveSystemdAutostartPaths(home = (0, import_node_os3.homedir)()) {
2733
2732
  const serviceDir = (0, import_node_path9.join)(home, ".config", "systemd", "user");
2734
2733
  return {
2735
2734
  serviceDir,
2736
2735
  servicePath: (0, import_node_path9.join)(serviceDir, SERVICE_NAME)
2737
2736
  };
2738
2737
  }
2739
- function resolveLaunchdAutostartPaths(home = (0, import_node_os4.homedir)()) {
2738
+ function resolveLaunchdAutostartPaths(home = (0, import_node_os3.homedir)()) {
2740
2739
  const agentDir = (0, import_node_path9.join)(home, "Library", "LaunchAgents");
2741
2740
  return {
2742
2741
  agentDir,
@@ -2756,13 +2755,13 @@ function resolveCliPath() {
2756
2755
  }
2757
2756
  return (0, import_node_path9.resolve)(entry);
2758
2757
  }
2759
- function requiredServicePathEntries(env = process.env, home = (0, import_node_os4.homedir)(), platform = process.platform) {
2758
+ function requiredServicePathEntries(env = process.env, home = (0, import_node_os3.homedir)(), platform = process.platform) {
2760
2759
  const localBin = (0, import_node_path9.join)(home, ".local", "bin");
2761
2760
  const explicit = env.ONCHAINOS_BIN?.trim();
2762
2761
  const onchainosPath = (explicit ? resolveCommandPath(explicit, env, platform) : null) ?? resolveCommandPath("onchainos", env, platform);
2763
2762
  return [...new Set([onchainosPath ? (0, import_node_path9.dirname)(onchainosPath) : null, localBin].filter((entry) => !!entry))];
2764
2763
  }
2765
- function buildServicePath(env = process.env, home = (0, import_node_os4.homedir)(), platform = process.platform) {
2764
+ function buildServicePath(env = process.env, home = (0, import_node_os3.homedir)(), platform = process.platform) {
2766
2765
  const fallback = "/usr/local/bin:/usr/bin:/bin";
2767
2766
  const entries = (env.PATH?.trim() || fallback).split(import_node_path9.delimiter).filter((entry) => !!entry);
2768
2767
  const preferred = requiredServicePathEntries(env, home, platform);
@@ -2814,7 +2813,7 @@ ${args.map((arg) => ` <string>${escapeXml(arg)}</string>`).join("\n")}
2814
2813
  <key>PATH</key>
2815
2814
  <string>${escapeXml(pathValue)}</string>
2816
2815
  <key>HOME</key>
2817
- <string>${escapeXml((0, import_node_os4.homedir)())}</string>
2816
+ <string>${escapeXml((0, import_node_os3.homedir)())}</string>
2818
2817
  <key>OKX_AGENT_TASK_HOME</key>
2819
2818
  <string>${escapeXml(paths.homeDir)}</string>
2820
2819
  </dict>
@@ -3299,14 +3298,14 @@ function autostartStatus() {
3299
3298
  }
3300
3299
  throw new Error(`autostart is not supported on ${process.platform}`);
3301
3300
  }
3302
- var import_node_child_process3, import_node_fs6, import_promises3, import_node_os4, import_node_path9, import_node_util, execFileAsync, SERVICE_NAME, LAUNCHD_LABEL, LAUNCHD_PLIST_NAME, AutostartManagerUnavailableError;
3301
+ var import_node_child_process3, import_node_fs6, import_promises3, import_node_os3, import_node_path9, import_node_util, execFileAsync, SERVICE_NAME, LAUNCHD_LABEL, LAUNCHD_PLIST_NAME, AutostartManagerUnavailableError;
3303
3302
  var init_autostart = __esm({
3304
3303
  "src/autostart.ts"() {
3305
3304
  "use strict";
3306
3305
  import_node_child_process3 = require("node:child_process");
3307
3306
  import_node_fs6 = require("node:fs");
3308
3307
  import_promises3 = require("node:fs/promises");
3309
- import_node_os4 = require("node:os");
3308
+ import_node_os3 = require("node:os");
3310
3309
  import_node_path9 = require("node:path");
3311
3310
  import_node_util = require("node:util");
3312
3311
  init_autostart_windows();
@@ -3518,7 +3517,7 @@ async function startDaemon(homeDir) {
3518
3517
  }
3519
3518
  function isDefaultTaskHome(homeDir) {
3520
3519
  const target = (0, import_node_path10.resolve)(homeDir ?? resolveTaskHome());
3521
- return target === (0, import_node_path10.resolve)((0, import_node_path10.join)((0, import_node_os5.homedir)(), ".okx-agent-task"));
3520
+ return target === (0, import_node_path10.resolve)((0, import_node_path10.join)((0, import_node_os4.homedir)(), ".okx-agent-task"));
3522
3521
  }
3523
3522
  async function shouldDelegateToSupervisor(homeDir, ops) {
3524
3523
  if (!isDefaultTaskHome(homeDir)) {
@@ -3746,14 +3745,14 @@ function readReadyTimeoutMs(env) {
3746
3745
  function sleep2(ms) {
3747
3746
  return new Promise((resolve11) => setTimeout(resolve11, ms));
3748
3747
  }
3749
- var import_node_fs7, import_promises4, import_node_child_process4, import_node_os5, import_node_path10, STOP_GRACE_MS, FORCE_KILL_GRACE_MS, START_EXIT_CHECK_MS, DEFAULT_READY_TIMEOUT_MS, READY_POLL_MS, DAEMON_READY_TIMEOUT_ENV, SUPERVISOR_START_RUNNING_TIMEOUT_MS, SUPERVISOR_START_POLL_MS;
3748
+ var import_node_fs7, import_promises4, import_node_child_process4, import_node_os4, import_node_path10, STOP_GRACE_MS, FORCE_KILL_GRACE_MS, START_EXIT_CHECK_MS, DEFAULT_READY_TIMEOUT_MS, READY_POLL_MS, DAEMON_READY_TIMEOUT_ENV, SUPERVISOR_START_RUNNING_TIMEOUT_MS, SUPERVISOR_START_POLL_MS;
3750
3749
  var init_daemon = __esm({
3751
3750
  "src/daemon.ts"() {
3752
3751
  "use strict";
3753
3752
  import_node_fs7 = require("node:fs");
3754
3753
  import_promises4 = require("node:fs/promises");
3755
3754
  import_node_child_process4 = require("node:child_process");
3756
- import_node_os5 = require("node:os");
3755
+ import_node_os4 = require("node:os");
3757
3756
  import_node_path10 = require("node:path");
3758
3757
  init_paths();
3759
3758
  init_session_store();
@@ -32449,7 +32448,7 @@ var init_sentry_config = __esm({
32449
32448
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
32450
32449
  SENTRY_CONFIG = {
32451
32450
  projectName: "okx/openclaw-okx-a2a-extension",
32452
- release: "0.2.15",
32451
+ release: "0.2.16",
32453
32452
  environment,
32454
32453
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
32455
32454
  };
@@ -32562,7 +32561,7 @@ async function installWindowsNativeLauncher(options) {
32562
32561
  }
32563
32562
  const exePath = (0, import_node_path28.join)(options.targetDir, NATIVE_LAUNCHER_EXE_NAME);
32564
32563
  (0, import_node_fs21.mkdirSync)(options.targetDir, { recursive: true });
32565
- const work = (0, import_node_fs21.mkdtempSync)((0, import_node_path28.join)((0, import_node_os10.tmpdir)(), "okx-a2a-sea-"));
32564
+ const work = (0, import_node_fs21.mkdtempSync)((0, import_node_path28.join)((0, import_node_os9.tmpdir)(), "okx-a2a-sea-"));
32566
32565
  try {
32567
32566
  const entryPath = (0, import_node_path28.join)(work, "launcher-entry.js");
32568
32567
  const blobPath = (0, import_node_path28.join)(work, "okx-a2a.blob");
@@ -32636,18 +32635,18 @@ async function ensureWindowsNativeLauncher(options = {}) {
32636
32635
  if (existing) {
32637
32636
  return { exePath: existing, installed: false };
32638
32637
  }
32639
- const targetDir = env.APPDATA ? (0, import_node_path28.join)(env.APPDATA, "npm") : (0, import_node_path28.join)(env.USERPROFILE ?? (0, import_node_os10.homedir)(), ".local", "bin");
32638
+ const targetDir = env.APPDATA ? (0, import_node_path28.join)(env.APPDATA, "npm") : (0, import_node_path28.join)(env.USERPROFILE ?? (0, import_node_os9.homedir)(), ".local", "bin");
32640
32639
  const result = await installWindowsNativeLauncher({ cliPath: resolveRunningCliPath(), targetDir });
32641
32640
  return { exePath: result.exePath, installed: true };
32642
32641
  }
32643
- var import_node_child_process7, import_node_fs21, import_node_module, import_node_os10, import_node_path28, SEA_SENTINEL_FUSE, NATIVE_LAUNCHER_EXE_NAME, POSTJECT_SPEC, POSTJECT_BIN;
32642
+ var import_node_child_process7, import_node_fs21, import_node_module, import_node_os9, import_node_path28, SEA_SENTINEL_FUSE, NATIVE_LAUNCHER_EXE_NAME, POSTJECT_SPEC, POSTJECT_BIN;
32644
32643
  var init_win_native_launcher = __esm({
32645
32644
  "src/win-native-launcher.ts"() {
32646
32645
  "use strict";
32647
32646
  import_node_child_process7 = require("node:child_process");
32648
32647
  import_node_fs21 = require("node:fs");
32649
32648
  import_node_module = require("node:module");
32650
- import_node_os10 = require("node:os");
32649
+ import_node_os9 = require("node:os");
32651
32650
  import_node_path28 = require("node:path");
32652
32651
  init_win_compat();
32653
32652
  init_win_spawn();
@@ -33405,7 +33404,7 @@ async function getCurrentNodeCliVersion() {
33405
33404
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
33406
33405
  }
33407
33406
  function getBundledNodeCliVersion() {
33408
- return true ? "0.2.15" : null;
33407
+ return true ? "0.2.16" : null;
33409
33408
  }
33410
33409
  function readConfiguredAiProvider() {
33411
33410
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -33590,7 +33589,7 @@ async function updateHermes(release, options) {
33590
33589
  assertNotRunningInsideGateway("hermes");
33591
33590
  }
33592
33591
  const spec = buildNpmPackageSpec("hermes", release);
33593
- const workDir = await (0, import_promises11.mkdtemp)((0, import_node_path29.join)((0, import_node_os11.tmpdir)(), `okx-a2a-${label}-hermes-`));
33592
+ const workDir = await (0, import_promises11.mkdtemp)((0, import_node_path29.join)((0, import_node_os10.tmpdir)(), `okx-a2a-${label}-hermes-`));
33594
33593
  try {
33595
33594
  console.log(`[${label}] downloading ${spec}`);
33596
33595
  const npmTarball = await npmPack(spec, workDir);
@@ -33615,7 +33614,7 @@ async function updateHermes(release, options) {
33615
33614
  }
33616
33615
  }
33617
33616
  async function installGatewayPluginForDoctor(target) {
33618
- const release = isPrereleaseVersion("0.2.15") ? "beta" : "latest";
33617
+ const release = isPrereleaseVersion("0.2.16") ? "beta" : "latest";
33619
33618
  const insideTargetGateway = detectGatewayInvocation() === target;
33620
33619
  const options = {
33621
33620
  restart: !insideTargetGateway,
@@ -33906,7 +33905,7 @@ function findFirstEnabledListItem(lines, startIndex, enabledIndent) {
33906
33905
  return null;
33907
33906
  }
33908
33907
  function resolveHermesConfigPath() {
33909
- return (0, import_node_path29.join)(process.env.HERMES_HOME ?? (0, import_node_path29.join)((0, import_node_os11.homedir)(), ".hermes"), "config.yaml");
33908
+ return (0, import_node_path29.join)(process.env.HERMES_HOME ?? (0, import_node_path29.join)((0, import_node_os10.homedir)(), ".hermes"), "config.yaml");
33910
33909
  }
33911
33910
  function lineIndent(line) {
33912
33911
  const match = line.match(/^\s*/);
@@ -33984,7 +33983,7 @@ async function assertGatewayPluginInstalled(target) {
33984
33983
  );
33985
33984
  }
33986
33985
  function resolveHermesPluginYamlPath() {
33987
- return (0, import_node_path29.join)(process.env.HERMES_HOME ?? (0, import_node_path29.join)((0, import_node_os11.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
33986
+ return (0, import_node_path29.join)(process.env.HERMES_HOME ?? (0, import_node_path29.join)((0, import_node_os10.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
33988
33987
  }
33989
33988
  async function isGatewayPluginInstalled(target) {
33990
33989
  if (target === "openclaw") {
@@ -34077,7 +34076,7 @@ function parsePackageVersionFromText(output) {
34077
34076
  return output.match(/@okxweb3\/a2a-openclaw@([0-9A-Za-z.+-]+)/)?.[1] ?? null;
34078
34077
  }
34079
34078
  async function getInstalledHermesPluginVersion() {
34080
- const pluginYaml = (0, import_node_path29.join)(process.env.HERMES_HOME ?? (0, import_node_path29.join)((0, import_node_os11.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
34079
+ const pluginYaml = (0, import_node_path29.join)(process.env.HERMES_HOME ?? (0, import_node_path29.join)((0, import_node_os10.homedir)(), ".hermes"), "plugins", "platforms", "okx-a2a", "plugin.yaml");
34081
34080
  try {
34082
34081
  const content = await (0, import_promises11.readFile)(pluginYaml, "utf8");
34083
34082
  return parsePluginYamlVersion(content);
@@ -34372,14 +34371,14 @@ function buildExternalCommandInvocation(command, args, platform = process.platfo
34372
34371
  function formatExternalCommand(command, args) {
34373
34372
  return [command, ...args].join(" ");
34374
34373
  }
34375
- var import_node_child_process8, import_node_fs22, import_promises11, import_node_os11, import_node_path29, 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, PROVIDER_CLI_AUTH_PROBE_TIMEOUT_MS, SetupBlockedError, redirectCommandStdoutToStderr;
34374
+ var import_node_child_process8, import_node_fs22, import_promises11, import_node_os10, import_node_path29, 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, PROVIDER_CLI_AUTH_PROBE_TIMEOUT_MS, SetupBlockedError, redirectCommandStdoutToStderr;
34376
34375
  var init_update_cli = __esm({
34377
34376
  "src/update-cli.ts"() {
34378
34377
  "use strict";
34379
34378
  import_node_child_process8 = require("node:child_process");
34380
34379
  import_node_fs22 = require("node:fs");
34381
34380
  import_promises11 = require("node:fs/promises");
34382
- import_node_os11 = require("node:os");
34381
+ import_node_os10 = require("node:os");
34383
34382
  import_node_path29 = require("node:path");
34384
34383
  init_ai_command();
34385
34384
  init_win_spawn();
@@ -44600,7 +44599,7 @@ init_log();
44600
44599
  var import_node_crypto4 = require("node:crypto");
44601
44600
  var import_node_fs11 = require("node:fs");
44602
44601
  var import_promises7 = require("node:fs/promises");
44603
- var import_node_os7 = require("node:os");
44602
+ var import_node_os6 = require("node:os");
44604
44603
  var import_node_path16 = require("node:path");
44605
44604
  init_ai_command();
44606
44605
  init_paths();
@@ -44887,7 +44886,7 @@ init_ai_provider();
44887
44886
 
44888
44887
  // src/ai-adapter.ts
44889
44888
  init_log();
44890
- var import_node_os6 = require("node:os");
44889
+ var import_node_os5 = require("node:os");
44891
44890
  var import_node_path14 = require("node:path");
44892
44891
  init_ai_command();
44893
44892
  init_paths();
@@ -45113,10 +45112,10 @@ function readCodexAddDirs(env = process.env) {
45113
45112
  }
45114
45113
  function expandHomePath(value) {
45115
45114
  if (value === "~") {
45116
- return (0, import_node_os6.homedir)();
45115
+ return (0, import_node_os5.homedir)();
45117
45116
  }
45118
45117
  if (value.startsWith("~/")) {
45119
- return (0, import_node_path14.join)((0, import_node_os6.homedir)(), value.slice(2));
45118
+ return (0, import_node_path14.join)((0, import_node_os5.homedir)(), value.slice(2));
45120
45119
  }
45121
45120
  return value;
45122
45121
  }
@@ -45333,7 +45332,7 @@ function formatOpenClawSessionKey(sessionKey, agentId) {
45333
45332
  function buildClaudeAddDirArgs(homeDir, env) {
45334
45333
  const dirs = [
45335
45334
  homeDir,
45336
- (0, import_node_path14.join)((0, import_node_os6.homedir)(), ".agents"),
45335
+ (0, import_node_path14.join)((0, import_node_os5.homedir)(), ".agents"),
45337
45336
  (0, import_node_path14.join)(__dirname, ".."),
45338
45337
  ...env.OKX_A2A_AI_CLAUDE_ADD_DIRS ? env.OKX_A2A_AI_CLAUDE_ADD_DIRS.split(import_node_path14.delimiter).filter(Boolean) : []
45339
45338
  ];
@@ -46443,7 +46442,7 @@ var AiRunner = class {
46443
46442
  process.env.OKX_AGENT_TASK_AI_CWD,
46444
46443
  this.sessionStore.getSetting("ai_working_dir"),
46445
46444
  safeProcessCwd(),
46446
- (0, import_node_os7.homedir)(),
46445
+ (0, import_node_os6.homedir)(),
46447
46446
  this.homeDir
46448
46447
  ];
46449
46448
  return candidates.find((candidate) => !!candidate && isDirectory(candidate)) ?? this.homeDir;
@@ -47022,7 +47021,7 @@ function extractDeniedFilesystemPath(text) {
47022
47021
  }
47023
47022
  function getPreferredCodexWritableRoot(target) {
47024
47023
  const expanded = expandHomePath2(target);
47025
- const home = (0, import_node_os7.homedir)();
47024
+ const home = (0, import_node_os6.homedir)();
47026
47025
  const appRoots = [
47027
47026
  (0, import_node_path16.join)(home, ".onchainos", "task"),
47028
47027
  (0, import_node_path16.join)(home, ".onchainos", "deliverables"),
@@ -47041,16 +47040,16 @@ function inferAppOwnedCodexWritableRoot(failure) {
47041
47040
  return void 0;
47042
47041
  }
47043
47042
  if (containsOnchainosCommand(command) && /\b0x[0-9a-fA-F]{16,}\b/.test(command)) {
47044
- return (0, import_node_path16.join)((0, import_node_os7.homedir)(), ".onchainos", "task");
47043
+ return (0, import_node_path16.join)((0, import_node_os6.homedir)(), ".onchainos", "task");
47045
47044
  }
47046
47045
  return void 0;
47047
47046
  }
47048
47047
  function expandHomePath2(value) {
47049
47048
  if (value === "~") {
47050
- return (0, import_node_os7.homedir)();
47049
+ return (0, import_node_os6.homedir)();
47051
47050
  }
47052
47051
  if (value.startsWith("~/")) {
47053
- return (0, import_node_path16.join)((0, import_node_os7.homedir)(), value.slice(2));
47052
+ return (0, import_node_path16.join)((0, import_node_os6.homedir)(), value.slice(2));
47054
47053
  }
47055
47054
  return value;
47056
47055
  }
@@ -61017,7 +61016,7 @@ async function callOpenClawGateway(opts) {
61017
61016
  if (isRetryableOpenClawGatewayError(err)) {
61018
61017
  clearClient();
61019
61018
  }
61020
- if (isGatewayStartingError(err) && delayMs !== void 0 && Date.now() + delayMs - startedAt < timeoutMs) {
61019
+ if (opts.retryOnStarting !== false && isGatewayStartingError(err) && delayMs !== void 0 && Date.now() + delayMs - startedAt < timeoutMs) {
61021
61020
  errorWithTimestamp(
61022
61021
  `${LOG_PREFIX2} rpc retry method=${opts.method} attempt=${attempt + 1} delayMs=${delayMs}: ${message}`
61023
61022
  );
@@ -61070,6 +61069,9 @@ async function callSessionsSend(params) {
61070
61069
  try {
61071
61070
  return await callOpenClawGateway({ method: "sessions.send", params: sendParams });
61072
61071
  } catch (err) {
61072
+ if (params.restoreArchived === true && isArchivedSessionSendError(err, params.key)) {
61073
+ return restoreArchivedSessionAndSendOnce(params.key, sendParams);
61074
+ }
61073
61075
  if (isSessionNotFound(err)) {
61074
61076
  await callSessionsCreate({ key: params.key });
61075
61077
  return callOpenClawGateway({ method: "sessions.send", params: sendParams });
@@ -61077,6 +61079,62 @@ async function callSessionsSend(params) {
61077
61079
  throw err;
61078
61080
  }
61079
61081
  }
61082
+ function isArchivedSessionSendError(error, key) {
61083
+ const e = error;
61084
+ return (e?.gatewayCode ?? e?.code) === "INVALID_REQUEST" && String(e?.message) === `Session "${key}" is archived. Restore it before starting new work.`;
61085
+ }
61086
+ async function restoreArchivedSessionAndSendOnce(key, sendParams) {
61087
+ let stage = "lookup";
61088
+ try {
61089
+ let entry;
61090
+ let offset = 0;
61091
+ for (let page = 0; page < 10; page += 1) {
61092
+ const raw = await callOpenClawGateway({
61093
+ method: "sessions.list",
61094
+ params: { search: key, archived: "all", limit: 200, offset },
61095
+ retryOnStarting: false
61096
+ });
61097
+ const listPage = raw;
61098
+ if (!listPage || !Array.isArray(listPage.sessions)) {
61099
+ throw new Error("Invalid sessions.list response");
61100
+ }
61101
+ entry = listPage.sessions.find((row) => row?.key === key);
61102
+ if (entry || listPage.hasMore !== true) {
61103
+ break;
61104
+ }
61105
+ if (!(Number.isInteger(listPage.nextOffset) && listPage.nextOffset > offset)) {
61106
+ throw new Error("Invalid sessions.list pagination");
61107
+ }
61108
+ offset = listPage.nextOffset;
61109
+ }
61110
+ if (!entry || typeof entry.sessionId !== "string" || !entry.sessionId) {
61111
+ throw new Error("Exact session identity unavailable for archive recovery");
61112
+ }
61113
+ stage = "restore";
61114
+ if (entry.archivedAt !== void 0) {
61115
+ await callOpenClawGateway({
61116
+ method: "sessions.patch",
61117
+ params: {
61118
+ key,
61119
+ archived: false,
61120
+ expectedSessionId: entry.sessionId,
61121
+ ...typeof entry.lifecycleRevision === "string" && entry.lifecycleRevision ? { expectedLifecycleRevision: entry.lifecycleRevision } : {}
61122
+ },
61123
+ retryOnStarting: false
61124
+ });
61125
+ }
61126
+ stage = "resend";
61127
+ return await callOpenClawGateway({ method: "sessions.send", params: sendParams, retryOnStarting: false });
61128
+ } catch (cause) {
61129
+ throw Object.assign(
61130
+ new Error(
61131
+ `Archived job session recovery failed at ${stage}: ${cause instanceof Error ? cause.message : String(cause)}`,
61132
+ { cause }
61133
+ ),
61134
+ { code: "A2A_ARCHIVE_RECOVERY_FAILED", retryable: false, recoveryStage: stage }
61135
+ );
61136
+ }
61137
+ }
61080
61138
  async function callChatInject(params) {
61081
61139
  try {
61082
61140
  return await callOpenClawGateway({ method: "chat.inject", params });
@@ -61096,6 +61154,9 @@ async function callPromptUserToLatestSessions(params) {
61096
61154
  }
61097
61155
  function isRetryableOpenClawGatewayError(err) {
61098
61156
  const e = err;
61157
+ if (e?.code === "A2A_ARCHIVE_RECOVERY_FAILED") {
61158
+ return false;
61159
+ }
61099
61160
  if (e?.retryable || e?.details?.retryable) {
61100
61161
  return true;
61101
61162
  }
@@ -61333,7 +61394,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
61333
61394
  client: {
61334
61395
  id: "gateway-client",
61335
61396
  displayName: "okx-a2a-node",
61336
- version: "0.2.15",
61397
+ version: "0.2.16",
61337
61398
  platform: "node",
61338
61399
  mode: "backend",
61339
61400
  instanceId
@@ -61344,7 +61405,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
61344
61405
  commands: [],
61345
61406
  permissions: {},
61346
61407
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
61347
- userAgent: `okx-a2a-node/${"0.2.15"}`,
61408
+ userAgent: `okx-a2a-node/${"0.2.16"}`,
61348
61409
  auth: {
61349
61410
  ...config.token ? { token: config.token } : {},
61350
61411
  ...config.password ? { password: config.password } : {}
@@ -61471,7 +61532,7 @@ function safeDecode(value) {
61471
61532
 
61472
61533
  // src/openclaw-route.ts
61473
61534
  var import_node_fs18 = require("node:fs");
61474
- var import_node_os8 = require("node:os");
61535
+ var import_node_os7 = require("node:os");
61475
61536
  var import_node_path24 = require("node:path");
61476
61537
  var OPENCLAW_GATEWAY_ROUTE_GROUP_ID = "__openclaw_gateway_route__";
61477
61538
  var CURRENT_GATEWAY_SESSION_KEYS_ENV = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
@@ -61823,7 +61884,7 @@ function readSingleActiveOriginSessionKey(env) {
61823
61884
  }
61824
61885
  }
61825
61886
  function resolveTaskHome2(env) {
61826
- return env.OKX_AGENT_TASK_HOME?.trim() || (0, import_node_path24.join)((0, import_node_os8.homedir)(), ".okx-agent-task");
61887
+ return env.OKX_AGENT_TASK_HOME?.trim() || (0, import_node_path24.join)((0, import_node_os7.homedir)(), ".okx-agent-task");
61827
61888
  }
61828
61889
  function logOpenClawRouteSkip(reason, input) {
61829
61890
  if (reason === "missing_gateway_session_key") {
@@ -62135,6 +62196,7 @@ var GatewayOutboundBehavior = class {
62135
62196
  const sendResult = await this.gateway.callSessionsSend({
62136
62197
  key: gatewaySessionKey,
62137
62198
  message: input.content,
62199
+ restoreArchived: true,
62138
62200
  ...input.messageId ? { idempotencyKey: input.messageId } : {}
62139
62201
  });
62140
62202
  errorWithTimestamp(
@@ -66938,7 +67000,7 @@ function isA2AEnvelope(payload) {
66938
67000
  init_log();
66939
67001
  var import_node_fs19 = require("node:fs");
66940
67002
  var import_promises8 = require("node:fs/promises");
66941
- var import_node_os9 = require("node:os");
67003
+ var import_node_os8 = require("node:os");
66942
67004
  var import_node_path25 = require("node:path");
66943
67005
 
66944
67006
  // ../core/src/xmtp-sdk/onchainos/signer.ts
@@ -67445,7 +67507,7 @@ async function isGatewayAvailableForHeartbeat(options) {
67445
67507
  }
67446
67508
  async function getHermesGatewayPluginStatus(options = {}) {
67447
67509
  const env = options.env ?? process.env;
67448
- const hermesHome = env.HERMES_HOME?.trim() || (0, import_node_path25.join)((0, import_node_os9.homedir)(), ".hermes");
67510
+ const hermesHome = env.HERMES_HOME?.trim() || (0, import_node_path25.join)((0, import_node_os8.homedir)(), ".hermes");
67449
67511
  const pluginYamlPath = (0, import_node_path25.join)(hermesHome, "plugins", "platforms", "okx-a2a", "plugin.yaml");
67450
67512
  if (!(0, import_node_fs19.existsSync)(pluginYamlPath)) {
67451
67513
  return { enabled: false, reason: "plugin_yaml_missing", hermesHome, checkedPath: pluginYamlPath };
@@ -67561,14 +67623,14 @@ async function runListener(options = {}) {
67561
67623
  const evictedPid = await claimActiveDaemon(paths.homeDir);
67562
67624
  if (evictedPid !== null) {
67563
67625
  logWithTimestamp(
67564
- `[okx-agent-task] stopped previous daemon pid=${evictedPid} serving another task home (single-daemon policy)`
67626
+ `[okx-agent-task] stopped previous daemon pid=${evictedPid} for home=${paths.homeDir} (single-daemon-per-task-home policy)`
67565
67627
  );
67566
67628
  }
67567
67629
  try {
67568
67630
  await runListenerWithLock(options, paths);
67569
67631
  } finally {
67570
67632
  await daemonLock.release();
67571
- await releaseActiveDaemon();
67633
+ await releaseActiveDaemon(paths.homeDir);
67572
67634
  }
67573
67635
  }
67574
67636
  async function runListenerWithLock(options, paths) {
@@ -67683,12 +67745,12 @@ async function runListenerWithLock(options, paths) {
67683
67745
  });
67684
67746
  }
67685
67747
  });
67686
- service.setPluginVersion("0.2.15");
67748
+ service.setPluginVersion("0.2.16");
67687
67749
  await service.init();
67688
67750
  const pluginVersionStatus = service.pluginVersionStatus;
67689
67751
  if (pluginVersionStatus.unavailable) {
67690
67752
  throw new Error(
67691
- `@okxweb3/a2a-node v${"0.2.15"} is below the required minimum v${pluginVersionStatus.minVersion}`
67753
+ `@okxweb3/a2a-node v${"0.2.16"} is below the required minimum v${pluginVersionStatus.minVersion}`
67692
67754
  );
67693
67755
  }
67694
67756
  const systemConfig = service.getSystemConfig();
@@ -67716,7 +67778,7 @@ async function runListenerWithLock(options, paths) {
67716
67778
  onchainosAgentId: "*",
67717
67779
  reason: "system-config missing sentryDsn",
67718
67780
  pluginId: "@okxweb3/a2a-node",
67719
- pluginVersion: "0.2.15"
67781
+ pluginVersion: "0.2.16"
67720
67782
  });
67721
67783
  }
67722
67784
  logWithTimestamp(
@@ -69173,7 +69235,7 @@ function parseLogsTailArgs(args, subcommand) {
69173
69235
  var import_node_child_process10 = require("node:child_process");
69174
69236
  var import_node_fs27 = require("node:fs");
69175
69237
  var import_promises15 = require("node:fs/promises");
69176
- var import_node_os13 = require("node:os");
69238
+ var import_node_os12 = require("node:os");
69177
69239
  var import_node_path34 = require("node:path");
69178
69240
  var import_jszip = __toESM(require_lib3());
69179
69241
 
@@ -69997,14 +70059,14 @@ function unavailable(message) {
69997
70059
 
69998
70060
  // src/logs-export-provider.ts
69999
70061
  var import_node_child_process9 = require("node:child_process");
70000
- var import_node_os12 = require("node:os");
70062
+ var import_node_os11 = require("node:os");
70001
70063
  var import_node_path32 = require("node:path");
70002
70064
  var PROVIDERS2 = ["codex", "claude", "openclaw", "hermes"];
70003
70065
  function providerConfigCandidates(provider, taskHome2) {
70004
70066
  if (provider === "codex") {
70005
70067
  return [
70006
70068
  {
70007
- path: (0, import_node_path32.join)(process.env.CODEX_HOME ?? (0, import_node_path32.join)((0, import_node_os12.homedir)(), ".codex"), "config.toml"),
70069
+ path: (0, import_node_path32.join)(process.env.CODEX_HOME ?? (0, import_node_path32.join)((0, import_node_os11.homedir)(), ".codex"), "config.toml"),
70008
70070
  archiveName: "config.redacted.toml"
70009
70071
  }
70010
70072
  ];
@@ -70012,7 +70074,7 @@ function providerConfigCandidates(provider, taskHome2) {
70012
70074
  if (provider === "claude") {
70013
70075
  return [
70014
70076
  {
70015
- path: (0, import_node_path32.join)((0, import_node_os12.homedir)(), ".claude", "settings.json"),
70077
+ path: (0, import_node_path32.join)((0, import_node_os11.homedir)(), ".claude", "settings.json"),
70016
70078
  archiveName: "settings.redacted.json"
70017
70079
  },
70018
70080
  {
@@ -70043,10 +70105,10 @@ function providerConfigCandidates(provider, taskHome2) {
70043
70105
  }
70044
70106
  function resolveOpenClawStateDir() {
70045
70107
  const configured = process.env.OPENCLAW_STATE_DIR?.trim() || process.env.OPENCLAW_HOME?.trim();
70046
- return (0, import_node_path32.resolve)(configured || (0, import_node_path32.join)((0, import_node_os12.homedir)(), ".openclaw"));
70108
+ return (0, import_node_path32.resolve)(configured || (0, import_node_path32.join)((0, import_node_os11.homedir)(), ".openclaw"));
70047
70109
  }
70048
70110
  function resolveHermesHome() {
70049
- return (0, import_node_path32.resolve)(process.env.HERMES_HOME?.trim() || (0, import_node_path32.join)((0, import_node_os12.homedir)(), ".hermes"));
70111
+ return (0, import_node_path32.resolve)(process.env.HERMES_HOME?.trim() || (0, import_node_path32.join)((0, import_node_os11.homedir)(), ".hermes"));
70050
70112
  }
70051
70113
  function providerEnvironment(provider) {
70052
70114
  const prefixes = provider === "codex" ? ["OKX_A2A_AI_CODEX_", "CODEX_"] : provider === "claude" ? ["OKX_A2A_AI_CLAUDE_", "ANTHROPIC_MODEL", "CLAUDE_"] : provider === "openclaw" ? ["OPENCLAW_", "OKX_A2A_OPENCLAW_"] : ["HERMES_", "OKX_A2A_HERMES_"];
@@ -70489,7 +70551,7 @@ async function exportDiagnosticLogs(options) {
70489
70551
  node: process.version,
70490
70552
  platform: process.platform,
70491
70553
  arch: process.arch,
70492
- packageVersion: true ? "0.2.15" : "unknown",
70554
+ packageVersion: true ? "0.2.16" : "unknown",
70493
70555
  sensitiveContentIncluded: options.includeSensitiveContent,
70494
70556
  listenerAndLlmContentIncluded: true,
70495
70557
  credentialsAlwaysRedacted: true,
@@ -70830,7 +70892,7 @@ async function collectCommands(state, paths, options) {
70830
70892
  }
70831
70893
  async function collectOnchainAudit(state, options, correlationIds) {
70832
70894
  await runCollector(state, "onchainos-audit", async () => {
70833
- const onchainHome = process.env.ONCHAINOS_HOME?.trim() ? (0, import_node_path34.resolve)(process.env.ONCHAINOS_HOME) : (0, import_node_path34.join)((0, import_node_os13.homedir)(), ".onchainos");
70895
+ const onchainHome = process.env.ONCHAINOS_HOME?.trim() ? (0, import_node_path34.resolve)(process.env.ONCHAINOS_HOME) : (0, import_node_path34.join)((0, import_node_os12.homedir)(), ".onchainos");
70834
70896
  const auditPath = (0, import_node_path34.join)(onchainHome, "audit.jsonl");
70835
70897
  const output = await readFilteredLog(
70836
70898
  auditPath,
@@ -72401,7 +72463,7 @@ async function runDoctor(options = {}) {
72401
72463
  platform: options.platform ?? process.platform,
72402
72464
  env: options.env ?? process.env,
72403
72465
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
72404
- cliVersion: options.cliVersion ?? (true ? "0.2.15" : "0.0.0"),
72466
+ cliVersion: options.cliVersion ?? (true ? "0.2.16" : "0.0.0"),
72405
72467
  fixMode: options.fix === true,
72406
72468
  nonInteractive: options.nonInteractive === true,
72407
72469
  packageChanged: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okxweb3/a2a-node",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Host-agnostic Node CLI for E2E encrypted agent-to-agent communication via XMTP",
5
5
  "main": "dist/index.js",
6
6
  "bin": {