@okxweb3/a2a-node 0.0.20-beta-17d080241c-260626165511 → 0.0.20

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 +220 -56
  2. package/dist/index.js +127 -39
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2189,7 +2189,8 @@ function isDaemonCommand(value) {
2189
2189
  return true;
2190
2190
  }
2191
2191
  if (parsed.type === "xmtp-deny-pending-conversation") {
2192
- return typeof parsed.groupId === "string";
2192
+ const command = parsed;
2193
+ return typeof command.groupId === "string" || typeof command.jobId === "string";
2193
2194
  }
2194
2195
  if (parsed.type === "xmtp-refresh-agents") {
2195
2196
  return true;
@@ -2260,6 +2261,7 @@ var init_command_store = __esm({
2260
2261
  id: (0, import_node_crypto2.randomUUID)(),
2261
2262
  type: "xmtp-deny-pending-conversation",
2262
2263
  groupId: params.groupId,
2264
+ jobId: params.jobId,
2263
2265
  agentId: params.agentId,
2264
2266
  createdAt: Date.now()
2265
2267
  };
@@ -7817,7 +7819,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
7817
7819
  client: {
7818
7820
  id: "gateway-client",
7819
7821
  displayName: "okx-a2a-node",
7820
- version: "0.0.20-beta-17d080241c-260626165511",
7822
+ version: "0.0.20",
7821
7823
  platform: "node",
7822
7824
  mode: "backend",
7823
7825
  instanceId
@@ -7828,7 +7830,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
7828
7830
  commands: [],
7829
7831
  permissions: {},
7830
7832
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
7831
- userAgent: `okx-a2a-node/${"0.0.20-beta-17d080241c-260626165511"}`,
7833
+ userAgent: `okx-a2a-node/${"0.0.20"}`,
7832
7834
  auth: {
7833
7835
  ...config.token ? { token: config.token } : {},
7834
7836
  ...config.password ? { password: config.password } : {}
@@ -25047,7 +25049,7 @@ var init_sentry_config = __esm({
25047
25049
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
25048
25050
  SENTRY_CONFIG = {
25049
25051
  projectName: "okx/openclaw-okx-a2a-extension",
25050
- release: "0.0.20-beta-17d080241c-260626165511",
25052
+ release: "0.0.20",
25051
25053
  environment
25052
25054
  };
25053
25055
  }
@@ -86161,6 +86163,19 @@ var init_system_config = __esm({
86161
86163
  });
86162
86164
 
86163
86165
  // ../core/src/xmtp-sdk/onchainos/index.ts
86166
+ function messageEligibleUnavailableError(input) {
86167
+ const lines = [
86168
+ MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT,
86169
+ `message-eligible failed: ${input.reason}`
86170
+ ];
86171
+ if (input.stdout) {
86172
+ lines.push("Raw tool stdout:", input.stdout);
86173
+ }
86174
+ if (input.stderr) {
86175
+ lines.push("Raw tool stderr:", input.stderr);
86176
+ }
86177
+ return new Error(lines.join("\n"), { cause: input.cause });
86178
+ }
86164
86179
  function isAccountAgentGroup(item) {
86165
86180
  return typeof item === "object" && item !== null && Array.isArray(item.agentList);
86166
86181
  }
@@ -86506,7 +86521,12 @@ async function checkMessageEligible(params) {
86506
86521
  ]));
86507
86522
  } catch (err2) {
86508
86523
  guardCatchSessionExpired2(err2, "message-eligible");
86509
- throw new Error("message-eligible-cli-error", { cause: err2 });
86524
+ throw messageEligibleUnavailableError({
86525
+ reason: "message-eligible-cli-error",
86526
+ stdout: typeof err2?.stdout === "string" ? err2.stdout : "",
86527
+ stderr: typeof err2?.stderr === "string" ? err2.stderr : "",
86528
+ cause: err2
86529
+ });
86510
86530
  }
86511
86531
  if (stderr) {
86512
86532
  logWithTimestamp(`[onchainos] stderr (message-eligible): ${stderr}`);
@@ -86525,7 +86545,12 @@ async function checkMessageEligible(params) {
86525
86545
  providerSecurityRate: String(params.providerSecurityRate)
86526
86546
  });
86527
86547
  } catch (err2) {
86528
- throw new Error("message-eligible-json-parse-failed", { cause: err2 });
86548
+ throw messageEligibleUnavailableError({
86549
+ reason: "message-eligible-json-parse-failed",
86550
+ stdout,
86551
+ stderr,
86552
+ cause: err2
86553
+ });
86529
86554
  }
86530
86555
  if (!res.ok) {
86531
86556
  guardSessionExpired2(stdout, "message-eligible");
@@ -86549,7 +86574,11 @@ async function checkMessageEligible(params) {
86549
86574
  reason: "ok=false"
86550
86575
  })
86551
86576
  );
86552
- throw new Error("message-eligible-ok-false");
86577
+ throw messageEligibleUnavailableError({
86578
+ reason: "message-eligible-ok-false",
86579
+ stdout,
86580
+ stderr
86581
+ });
86553
86582
  }
86554
86583
  logWithTimestamp(
86555
86584
  `[onchainos] message-eligible result: eligible=${res.data.eligible}`
@@ -86597,7 +86626,7 @@ async function fetchSensitiveWords() {
86597
86626
  );
86598
86627
  return result;
86599
86628
  }
86600
- var lastExpiredNotifyAt, EXPIRED_NOTIFY_COOLDOWN_MS, PAGE_SIZE, agentByIdCache, ONCHAINOS_CHAIN_INDEX;
86629
+ var MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT, lastExpiredNotifyAt, EXPIRED_NOTIFY_COOLDOWN_MS, PAGE_SIZE, agentByIdCache, ONCHAINOS_CHAIN_INDEX;
86601
86630
  var init_onchainos = __esm({
86602
86631
  "../core/src/xmtp-sdk/onchainos/index.ts"() {
86603
86632
  "use strict";
@@ -86612,6 +86641,7 @@ var init_onchainos = __esm({
86612
86641
  init_cli_response();
86613
86642
  init_session_expired();
86614
86643
  init_system_config();
86644
+ MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT = "Message eligibility service is temporarily unavailable. Please try again later.";
86615
86645
  lastExpiredNotifyAt = 0;
86616
86646
  EXPIRED_NOTIFY_COOLDOWN_MS = 5 * 60 * 1e3;
86617
86647
  PAGE_SIZE = 50;
@@ -87277,26 +87307,17 @@ async function assertOutboundEligible(params) {
87277
87307
  }
87278
87308
  const isSenderClient = senderAgent.role === 1 /* CLIENT */;
87279
87309
  const providerSecurityRate = (isSenderClient ? receiverAgent.securityRate : senderAgent.securityRate) ?? 0;
87280
- let result;
87281
- try {
87282
- result = await checkMessageEligible({
87283
- agentId: senderAgent.agentId,
87284
- clientAgentId: isSenderClient ? senderAgent.agentId : receiverAgent.agentId,
87285
- providerAgentId: isSenderClient ? receiverAgent.agentId : senderAgent.agentId,
87286
- clientCommunicationAddress: isSenderClient ? senderCommunicationAddress : receiverCommunicationAddress,
87287
- providerCommunicationAddress: isSenderClient ? receiverCommunicationAddress : senderCommunicationAddress,
87288
- jobId,
87289
- groupId,
87290
- direction: isSenderClient ? "client_to_provider" : "provider_to_client",
87291
- providerSecurityRate
87292
- });
87293
- } catch (err2) {
87294
- logWithTimestamp(
87295
- `[okx-agent-task] outbound message-eligible call failed, letting send continue: senderAgentId=${senderAgent.agentId} receiverAgentId=${receiverAgent.agentId} job=${jobId} group=${groupId}`,
87296
- err2
87297
- );
87298
- return;
87299
- }
87310
+ const result = await checkMessageEligible({
87311
+ agentId: senderAgent.agentId,
87312
+ clientAgentId: isSenderClient ? senderAgent.agentId : receiverAgent.agentId,
87313
+ providerAgentId: isSenderClient ? receiverAgent.agentId : senderAgent.agentId,
87314
+ clientCommunicationAddress: isSenderClient ? senderCommunicationAddress : receiverCommunicationAddress,
87315
+ providerCommunicationAddress: isSenderClient ? receiverCommunicationAddress : senderCommunicationAddress,
87316
+ jobId,
87317
+ groupId,
87318
+ direction: isSenderClient ? "client_to_provider" : "provider_to_client",
87319
+ providerSecurityRate
87320
+ });
87300
87321
  logWithTimestamp(
87301
87322
  `[okx-agent-task] outbound message-eligible: senderAgentId=${senderAgent.agentId} receiverAgentId=${receiverAgent.agentId} job=${jobId} group=${groupId} result=${JSON.stringify(result)}`
87302
87323
  );
@@ -90595,6 +90616,7 @@ function commandSentryExtra(command, extra = {}) {
90595
90616
  base3.toXmtpAddress = command.toXmtpAddress ?? "";
90596
90617
  } else if (command.type === "xmtp-deny-pending-conversation") {
90597
90618
  base3.groupId = command.groupId;
90619
+ base3.jobId = command.jobId ?? "";
90598
90620
  base3.agentId = command.agentId ?? "";
90599
90621
  } else if (command.type === "xmtp-get-conversation-history") {
90600
90622
  base3.jobId = command.jobId;
@@ -90826,13 +90848,18 @@ async function handleDaemonCommand(command, params) {
90826
90848
  return { ok: true, messageId: result.messageId };
90827
90849
  }
90828
90850
  if (command.type === "xmtp-get-pending-list") {
90829
- const result = [];
90830
- for (const [address] of params.service.getClients()) {
90831
- result.push(...await params.service.listUnknownGroups(address));
90832
- }
90833
- return { ok: true, payload: filterKnownPendingGroups(result, params.sessionStore) };
90851
+ return { ok: true, payload: await listPendingTaskRequests(params) };
90834
90852
  }
90835
90853
  if (command.type === "xmtp-deny-pending-conversation") {
90854
+ if (command.jobId) {
90855
+ return {
90856
+ ok: true,
90857
+ payload: await denyPendingConversationsByJobId(command.jobId, params)
90858
+ };
90859
+ }
90860
+ if (!command.groupId) {
90861
+ throw new Error("xmtp-deny-pending-conversation requires groupId or jobId");
90862
+ }
90836
90863
  if (command.agentId) {
90837
90864
  const address = params.service.getAddressByAgentId(command.agentId);
90838
90865
  if (!address) {
@@ -90865,6 +90892,51 @@ async function handleDaemonCommand(command, params) {
90865
90892
  }
90866
90893
  };
90867
90894
  }
90895
+ async function listPendingTaskRequests(params) {
90896
+ const result = [];
90897
+ for (const [address] of params.service.getClients()) {
90898
+ result.push(...await params.service.listUnknownGroups(address));
90899
+ }
90900
+ return filterKnownPendingGroups(result, params.sessionStore);
90901
+ }
90902
+ async function denyPendingConversationsByJobId(jobId, params) {
90903
+ const pending = await listPendingTaskRequests(params);
90904
+ const matched = pending.filter((item) => isPlainObject2(item) && readString2(item.jobId) === jobId);
90905
+ const clientAddresses = [...params.service.getClients().keys()];
90906
+ const targetsByKey = /* @__PURE__ */ new Map();
90907
+ const groupIds = /* @__PURE__ */ new Set();
90908
+ for (const item of matched) {
90909
+ if (!isPlainObject2(item)) {
90910
+ continue;
90911
+ }
90912
+ const groupId = readString2(item.groupId);
90913
+ if (!groupId) {
90914
+ continue;
90915
+ }
90916
+ groupIds.add(groupId);
90917
+ const address = readString2(item.myXmtpAddress);
90918
+ const addresses = address ? [address] : clientAddresses;
90919
+ for (const candidate of addresses) {
90920
+ targetsByKey.set(`${candidate}
90921
+ ${groupId}`, { address: candidate, groupId });
90922
+ }
90923
+ }
90924
+ const results = await Promise.all(
90925
+ [...targetsByKey.values()].map(async (target) => ({
90926
+ ...target,
90927
+ denied: await params.service.denyGroup(target.address, target.groupId)
90928
+ }))
90929
+ );
90930
+ const deniedOn = results.filter((result) => result.denied).map(({ address, groupId }) => ({ address, groupId }));
90931
+ return {
90932
+ denied: deniedOn.length > 0,
90933
+ jobId,
90934
+ matched: matched.length,
90935
+ groupIds: [...groupIds],
90936
+ deniedClientCount: deniedOn.length,
90937
+ deniedOn
90938
+ };
90939
+ }
90868
90940
  function filterKnownPendingGroups(items, sessionStore) {
90869
90941
  if (!sessionStore) {
90870
90942
  return items;
@@ -91019,7 +91091,8 @@ function formatCommandCompleted(command, result) {
91019
91091
  return `[okx-agent-task] xmtp-get-pending-list command completed id=${command.id}`;
91020
91092
  }
91021
91093
  if (command.type === "xmtp-deny-pending-conversation") {
91022
- return `[okx-agent-task] xmtp-deny-pending-conversation command completed id=${command.id} group=${command.groupId}`;
91094
+ const target = command.jobId ? `job=${command.jobId}` : `group=${command.groupId}`;
91095
+ return `[okx-agent-task] xmtp-deny-pending-conversation command completed id=${command.id} ${target}`;
91023
91096
  }
91024
91097
  if (command.type === "xmtp-get-conversation-history") {
91025
91098
  const rows = Array.isArray(result.payload) ? result.payload.length : 0;
@@ -91852,11 +91925,13 @@ async function verifyInboundA2AGroupMessage(params) {
91852
91925
  return false;
91853
91926
  }
91854
91927
  } catch (err2) {
91928
+ const failureMessage = err2 instanceof Error ? err2.message : String(err2);
91855
91929
  logWithTimestamp(
91856
- `[okx-agent-task:${myXmtpAddress}] message-eligible call failed, letting message through:`,
91930
+ `[okx-agent-task:${myXmtpAddress}] message-eligible call failed, dropping message:
91931
+ ${failureMessage}`,
91857
91932
  err2
91858
91933
  );
91859
- logger.error(LogEvent.INBOUND_ELIGIBILITY_BYPASSED, err2 instanceof Error ? err2 : new Error(String(err2)), {
91934
+ logger.error(LogEvent.INBOUND_BLOCKED_INELIGIBLE, err2 instanceof Error ? err2 : new Error(String(err2)), {
91860
91935
  ...agentExtras({ walletAddress: myXmtpAddress, onchainosAgentId: myAgent.agentId }),
91861
91936
  peerWalletAddress: senderAddress,
91862
91937
  peerInboxId: senderInboxId,
@@ -91867,9 +91942,22 @@ async function verifyInboundA2AGroupMessage(params) {
91867
91942
  direction: isSenderClient ? "client_to_provider" : "provider_to_client",
91868
91943
  providerSecurityRate: String(providerSecurityRate),
91869
91944
  stage: "inbound/eligibility_check",
91870
- reason: "exception",
91945
+ reason: "eligibility_service_error",
91871
91946
  ...timing?.extras()
91872
91947
  });
91948
+ recordInvalidXmtpMessageBestEffort({
91949
+ messageId,
91950
+ groupId,
91951
+ jobId,
91952
+ agentId: senderAgentId,
91953
+ localAgentId: myAgent.agentId,
91954
+ senderAddress,
91955
+ senderInboxId,
91956
+ reason: failureMessage,
91957
+ stage: "inbound/eligibility_check",
91958
+ logTag: `[okx-agent-task:${myXmtpAddress}]`
91959
+ });
91960
+ return false;
91873
91961
  }
91874
91962
  }
91875
91963
  const content3 = readString3(payload.content);
@@ -92787,12 +92875,12 @@ async function runListenerWithLock(options, paths) {
92787
92875
  }));
92788
92876
  }
92789
92877
  });
92790
- service.setPluginVersion("0.0.20-beta-17d080241c-260626165511");
92878
+ service.setPluginVersion("0.0.20");
92791
92879
  await service.init();
92792
92880
  const pluginVersionStatus = service.pluginVersionStatus;
92793
92881
  if (pluginVersionStatus.unavailable) {
92794
92882
  throw new Error(
92795
- `@okxweb3/a2a-node v${"0.0.20-beta-17d080241c-260626165511"} is below the required minimum v${pluginVersionStatus.minVersion}`
92883
+ `@okxweb3/a2a-node v${"0.0.20"} is below the required minimum v${pluginVersionStatus.minVersion}`
92796
92884
  );
92797
92885
  }
92798
92886
  const systemConfig = service.getSystemConfig();
@@ -92810,7 +92898,7 @@ async function runListenerWithLock(options, paths) {
92810
92898
  onchainosAgentId: "*",
92811
92899
  reason: "system-config missing sentryDsn",
92812
92900
  pluginId: "@okxweb3/a2a-node",
92813
- pluginVersion: "0.0.20-beta-17d080241c-260626165511"
92901
+ pluginVersion: "0.0.20"
92814
92902
  });
92815
92903
  }
92816
92904
  logWithTimestamp(
@@ -95975,7 +96063,7 @@ async function getCurrentNodeCliVersion() {
95975
96063
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
95976
96064
  }
95977
96065
  function getBundledNodeCliVersion() {
95978
- return true ? "0.0.20-beta-17d080241c-260626165511" : null;
96066
+ return true ? "0.0.20" : null;
95979
96067
  }
95980
96068
  function readConfiguredAiProvider() {
95981
96069
  const explicit = process.env.OKX_AGENT_TASK_AI_CLI ?? process.env.OKX_A2A_AI_PROVIDER;
@@ -96808,7 +96896,7 @@ init_sentry_logger();
96808
96896
  init_sentry_config();
96809
96897
  var CURRENT_GATEWAY_SESSION_KEYS_ENV2 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
96810
96898
  function printUsage2() {
96811
- console.log(`okx-a2a ${"0.0.20-beta-17d080241c-260626165511"}
96899
+ console.log(`okx-a2a ${"0.0.20"}
96812
96900
 
96813
96901
  Usage:
96814
96902
  okx-a2a <command> [options]
@@ -96845,7 +96933,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
96845
96933
  `);
96846
96934
  }
96847
96935
  function printVersion() {
96848
- console.log("0.0.20-beta-17d080241c-260626165511");
96936
+ console.log("0.0.20");
96849
96937
  }
96850
96938
  function printDaemonUsage() {
96851
96939
  console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
@@ -96877,10 +96965,34 @@ function printTaskUsage() {
96877
96965
  Commands:
96878
96966
  requests [--json] [--timeout-ms <ms>]
96879
96967
  List pending XMTP task requests.
96880
- reject --group-id <id> [--agent-id <id>] [--json]
96968
+ reject (--job-id <id> | --group-id <id> [--agent-id <id>]) [--json] [--timeout-ms <ms>]
96881
96969
  Deny a pending XMTP conversation.
96882
96970
  `);
96883
96971
  }
96972
+ function printTaskSubcommandUsage(subcommand) {
96973
+ if (subcommand === "requests") {
96974
+ console.log(`Usage: okx-a2a task requests [options]
96975
+
96976
+ Options:
96977
+ --json Print machine-readable JSON output.
96978
+ --timeout-ms <ms> Timeout while waiting for daemon result. Default: 60000.
96979
+ `);
96980
+ return true;
96981
+ }
96982
+ if (subcommand === "reject") {
96983
+ console.log(`Usage: okx-a2a task reject (--job-id <id> | --group-id <id> [--agent-id <id>]) [options]
96984
+
96985
+ Options:
96986
+ --job-id <id> Deny every pending conversation matching this job id.
96987
+ --group-id <id> XMTP group id for the pending conversation.
96988
+ --agent-id <id> Agent id whose pending conversation should be denied.
96989
+ --json Print machine-readable JSON output.
96990
+ --timeout-ms <ms> Timeout while waiting for daemon result. Default: 60000.
96991
+ `);
96992
+ return true;
96993
+ }
96994
+ return false;
96995
+ }
96884
96996
  function printAgentUsage() {
96885
96997
  console.log(`Usage: okx-a2a agent <refresh|bypass> [options]
96886
96998
 
@@ -97327,13 +97439,10 @@ function assertOnlyKnownOptions(args, input) {
97327
97439
  async function queueXmtpDaemonCommand(args, type) {
97328
97440
  const json = hasFlag2(args, "--json");
97329
97441
  const timeoutMsRaw = readOption3(args, "--timeout-ms");
97330
- const wait3 = type === "xmtp-get-pending-list";
97442
+ const wait3 = type === "xmtp-get-pending-list" || type === "xmtp-deny-pending-conversation";
97331
97443
  await assertDaemonRunningForQueuedCommand2(type);
97332
97444
  const commands = new CommandStore();
97333
- const command = type === "xmtp-get-pending-list" ? commands.createXmtpGetPendingListCommand() : type === "xmtp-deny-pending-conversation" ? commands.createXmtpDenyPendingConversationCommand({
97334
- groupId: readRequiredOption4(args, "--group-id"),
97335
- agentId: readOption3(args, "--agent-id")
97336
- }) : commands.createXmtpRefreshAgentsCommand();
97445
+ const command = type === "xmtp-get-pending-list" ? commands.createXmtpGetPendingListCommand() : type === "xmtp-deny-pending-conversation" ? commands.createXmtpDenyPendingConversationCommand(readDenyPendingConversationOptions(args)) : commands.createXmtpRefreshAgentsCommand();
97337
97446
  await commands.submit(command);
97338
97447
  if (!wait3) {
97339
97448
  outputCommandResult(json, { id: command.id, ok: true, completedAt: Date.now(), payload: { queued: true } }, `${type} queued command=${command.id}`);
@@ -97342,19 +97451,45 @@ async function queueXmtpDaemonCommand(args, type) {
97342
97451
  const timeoutMs = timeoutMsRaw ? Number(timeoutMsRaw) : 6e4;
97343
97452
  const result = await commands.waitForResult(command.id, timeoutMs);
97344
97453
  if (!result) {
97345
- throw new Error(`${type} timed out waiting for command=${command.id}`);
97454
+ outputCommandResult(json, {
97455
+ id: command.id,
97456
+ ok: false,
97457
+ completedAt: Date.now(),
97458
+ error: `${type} timed out waiting for command=${command.id}`
97459
+ }, `ok=false ${type} command=${command.id} error=timed out waiting for daemon result`);
97460
+ process.exitCode = 1;
97461
+ return;
97346
97462
  }
97347
97463
  if (!result.ok) {
97348
- throw new Error(`${type} failed command=${command.id}: ${result.error ?? "unknown error"}`);
97464
+ outputCommandResult(json, result, formatDaemonCommandResult(type, result));
97465
+ process.exitCode = 1;
97466
+ return;
97349
97467
  }
97350
97468
  outputCommandResult(json, result, formatDaemonCommandResult(type, result));
97351
97469
  }
97352
97470
  async function handleTaskCommand(args) {
97353
- if (hasHelpFlag5(args)) {
97471
+ const subcommand = args[0];
97472
+ if (!subcommand || args.every(isHelpArg4)) {
97354
97473
  printTaskUsage();
97355
97474
  return;
97356
97475
  }
97357
- const subcommand = args[0];
97476
+ if (subcommand === "help") {
97477
+ const helpTarget = args.slice(1).find((arg) => !isHelpArg4(arg));
97478
+ if (!helpTarget) {
97479
+ printTaskUsage();
97480
+ return;
97481
+ }
97482
+ if (!printTaskSubcommandUsage(helpTarget)) {
97483
+ throw new Error(`Unknown task command: ${helpTarget}`);
97484
+ }
97485
+ return;
97486
+ }
97487
+ if (hasHelpFlag5(args.slice(1))) {
97488
+ if (!printTaskSubcommandUsage(subcommand)) {
97489
+ throw new Error(`Unknown task command: ${subcommand}`);
97490
+ }
97491
+ return;
97492
+ }
97358
97493
  const rest = args.slice(1);
97359
97494
  if (subcommand === "requests") {
97360
97495
  await queueXmtpDaemonCommand(rest, "xmtp-get-pending-list");
@@ -97422,9 +97557,32 @@ function readRequiredOption4(args, name2) {
97422
97557
  }
97423
97558
  return value;
97424
97559
  }
97560
+ function readDenyPendingConversationOptions(args) {
97561
+ const jobId = readOption3(args, "--job-id");
97562
+ const groupId = readOption3(args, "--group-id");
97563
+ const agentId = readOption3(args, "--agent-id");
97564
+ if (jobId) {
97565
+ if (groupId || agentId) {
97566
+ throw new Error("task reject --job-id cannot be used with --group-id or --agent-id");
97567
+ }
97568
+ return { jobId };
97569
+ }
97570
+ if (!groupId) {
97571
+ throw new Error("task reject requires --job-id <id> or --group-id <id>");
97572
+ }
97573
+ return {
97574
+ groupId,
97575
+ ...agentId ? { agentId } : {}
97576
+ };
97577
+ }
97425
97578
  function outputCommandResult(json, result, human) {
97426
97579
  if (json) {
97427
- console.log(JSON.stringify({ ok: result.ok, commandId: result.id, payload: result.payload ?? null }));
97580
+ console.log(JSON.stringify({
97581
+ ok: result.ok,
97582
+ commandId: result.id,
97583
+ payload: result.payload ?? null,
97584
+ error: result.error ?? null
97585
+ }));
97428
97586
  return;
97429
97587
  }
97430
97588
  console.log(human);
@@ -97446,12 +97604,18 @@ function printXmtpSendCommandResult(json, result) {
97446
97604
  console.log(`ok=false xmtp-send failed command=${result.id} error=${result.error ?? "unknown error"}`);
97447
97605
  }
97448
97606
  function formatDaemonCommandResult(type, result) {
97607
+ if (!result.ok) {
97608
+ return `ok=false ${type} command=${result.id} error=${result.error ?? "unknown error"}`;
97609
+ }
97449
97610
  if (type === "xmtp-get-pending-list") {
97450
97611
  return JSON.stringify(result.payload ?? [], null, 2);
97451
97612
  }
97452
97613
  if (type === "xmtp-deny-pending-conversation") {
97453
97614
  const payload2 = result.payload;
97454
- return `denied=${payload2?.denied ? "yes" : "no"} groupId=${payload2?.groupId ?? ""} clients=${payload2?.deniedClientCount ?? 0}`;
97615
+ const target = payload2?.jobId ? `jobId=${payload2.jobId}` : `groupId=${payload2?.groupId ?? ""}`;
97616
+ const matched = typeof payload2?.matched === "number" ? ` matched=${payload2.matched}` : "";
97617
+ const groupIds = payload2?.groupIds?.length ? ` groupIds=${payload2.groupIds.join(",")}` : "";
97618
+ return `ok=true denied=${payload2?.denied ? "true" : "false"} ${target}${matched}${groupIds} clients=${payload2?.deniedClientCount ?? 0}`;
97455
97619
  }
97456
97620
  const payload = result.payload;
97457
97621
  return `agents=${payload?.agentCount ?? 0} activeClients=${payload?.activeClients ?? 0} changed=${payload?.changed ? "yes" : "no"} added=${payload?.added?.length ?? 0} removed=${payload?.removed?.length ?? 0}`;
@@ -98109,7 +98273,7 @@ async function main() {
98109
98273
  process.exitCode = 1;
98110
98274
  }
98111
98275
  function shouldDeferHelpToNestedHandler(command, args) {
98112
- if (command !== "session" && command !== "user") {
98276
+ if (command !== "session" && command !== "user" && command !== "task") {
98113
98277
  return false;
98114
98278
  }
98115
98279
  return args.some((arg) => !isHelpArg4(arg));
package/dist/index.js CHANGED
@@ -74676,6 +74676,7 @@ var CommandStore = class {
74676
74676
  id: (0, import_node_crypto4.randomUUID)(),
74677
74677
  type: "xmtp-deny-pending-conversation",
74678
74678
  groupId: params.groupId,
74679
+ jobId: params.jobId,
74679
74680
  agentId: params.agentId,
74680
74681
  createdAt: Date.now()
74681
74682
  };
@@ -74957,7 +74958,8 @@ function isDaemonCommand(value) {
74957
74958
  return true;
74958
74959
  }
74959
74960
  if (parsed.type === "xmtp-deny-pending-conversation") {
74960
- return typeof parsed.groupId === "string";
74961
+ const command = parsed;
74962
+ return typeof command.groupId === "string" || typeof command.jobId === "string";
74961
74963
  }
74962
74964
  if (parsed.type === "xmtp-refresh-agents") {
74963
74965
  return true;
@@ -85737,6 +85739,20 @@ async function fetchSystemConfig(options) {
85737
85739
  }
85738
85740
 
85739
85741
  // ../core/src/xmtp-sdk/onchainos/index.ts
85742
+ var MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT = "Message eligibility service is temporarily unavailable. Please try again later.";
85743
+ function messageEligibleUnavailableError(input) {
85744
+ const lines = [
85745
+ MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT,
85746
+ `message-eligible failed: ${input.reason}`
85747
+ ];
85748
+ if (input.stdout) {
85749
+ lines.push("Raw tool stdout:", input.stdout);
85750
+ }
85751
+ if (input.stderr) {
85752
+ lines.push("Raw tool stderr:", input.stderr);
85753
+ }
85754
+ return new Error(lines.join("\n"), { cause: input.cause });
85755
+ }
85740
85756
  function isAccountAgentGroup(item) {
85741
85757
  return typeof item === "object" && item !== null && Array.isArray(item.agentList);
85742
85758
  }
@@ -86087,7 +86103,12 @@ async function checkMessageEligible(params) {
86087
86103
  ]));
86088
86104
  } catch (err2) {
86089
86105
  guardCatchSessionExpired2(err2, "message-eligible");
86090
- throw new Error("message-eligible-cli-error", { cause: err2 });
86106
+ throw messageEligibleUnavailableError({
86107
+ reason: "message-eligible-cli-error",
86108
+ stdout: typeof err2?.stdout === "string" ? err2.stdout : "",
86109
+ stderr: typeof err2?.stderr === "string" ? err2.stderr : "",
86110
+ cause: err2
86111
+ });
86091
86112
  }
86092
86113
  if (stderr) {
86093
86114
  logWithTimestamp(`[onchainos] stderr (message-eligible): ${stderr}`);
@@ -86106,7 +86127,12 @@ async function checkMessageEligible(params) {
86106
86127
  providerSecurityRate: String(params.providerSecurityRate)
86107
86128
  });
86108
86129
  } catch (err2) {
86109
- throw new Error("message-eligible-json-parse-failed", { cause: err2 });
86130
+ throw messageEligibleUnavailableError({
86131
+ reason: "message-eligible-json-parse-failed",
86132
+ stdout,
86133
+ stderr,
86134
+ cause: err2
86135
+ });
86110
86136
  }
86111
86137
  if (!res.ok) {
86112
86138
  guardSessionExpired2(stdout, "message-eligible");
@@ -86130,7 +86156,11 @@ async function checkMessageEligible(params) {
86130
86156
  reason: "ok=false"
86131
86157
  })
86132
86158
  );
86133
- throw new Error("message-eligible-ok-false");
86159
+ throw messageEligibleUnavailableError({
86160
+ reason: "message-eligible-ok-false",
86161
+ stdout,
86162
+ stderr
86163
+ });
86134
86164
  }
86135
86165
  logWithTimestamp(
86136
86166
  `[onchainos] message-eligible result: eligible=${res.data.eligible}`
@@ -86661,7 +86691,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
86661
86691
  client: {
86662
86692
  id: "gateway-client",
86663
86693
  displayName: "okx-a2a-node",
86664
- version: "0.0.20-beta-17d080241c-260626165511",
86694
+ version: "0.0.20",
86665
86695
  platform: "node",
86666
86696
  mode: "backend",
86667
86697
  instanceId
@@ -86672,7 +86702,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
86672
86702
  commands: [],
86673
86703
  permissions: {},
86674
86704
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
86675
- userAgent: `okx-a2a-node/${"0.0.20-beta-17d080241c-260626165511"}`,
86705
+ userAgent: `okx-a2a-node/${"0.0.20"}`,
86676
86706
  auth: {
86677
86707
  ...config.token ? { token: config.token } : {},
86678
86708
  ...config.password ? { password: config.password } : {}
@@ -88140,26 +88170,17 @@ async function assertOutboundEligible(params) {
88140
88170
  }
88141
88171
  const isSenderClient = senderAgent.role === 1 /* CLIENT */;
88142
88172
  const providerSecurityRate = (isSenderClient ? receiverAgent.securityRate : senderAgent.securityRate) ?? 0;
88143
- let result;
88144
- try {
88145
- result = await checkMessageEligible({
88146
- agentId: senderAgent.agentId,
88147
- clientAgentId: isSenderClient ? senderAgent.agentId : receiverAgent.agentId,
88148
- providerAgentId: isSenderClient ? receiverAgent.agentId : senderAgent.agentId,
88149
- clientCommunicationAddress: isSenderClient ? senderCommunicationAddress : receiverCommunicationAddress,
88150
- providerCommunicationAddress: isSenderClient ? receiverCommunicationAddress : senderCommunicationAddress,
88151
- jobId,
88152
- groupId,
88153
- direction: isSenderClient ? "client_to_provider" : "provider_to_client",
88154
- providerSecurityRate
88155
- });
88156
- } catch (err2) {
88157
- logWithTimestamp(
88158
- `[okx-agent-task] outbound message-eligible call failed, letting send continue: senderAgentId=${senderAgent.agentId} receiverAgentId=${receiverAgent.agentId} job=${jobId} group=${groupId}`,
88159
- err2
88160
- );
88161
- return;
88162
- }
88173
+ const result = await checkMessageEligible({
88174
+ agentId: senderAgent.agentId,
88175
+ clientAgentId: isSenderClient ? senderAgent.agentId : receiverAgent.agentId,
88176
+ providerAgentId: isSenderClient ? receiverAgent.agentId : senderAgent.agentId,
88177
+ clientCommunicationAddress: isSenderClient ? senderCommunicationAddress : receiverCommunicationAddress,
88178
+ providerCommunicationAddress: isSenderClient ? receiverCommunicationAddress : senderCommunicationAddress,
88179
+ jobId,
88180
+ groupId,
88181
+ direction: isSenderClient ? "client_to_provider" : "provider_to_client",
88182
+ providerSecurityRate
88183
+ });
88163
88184
  logWithTimestamp(
88164
88185
  `[okx-agent-task] outbound message-eligible: senderAgentId=${senderAgent.agentId} receiverAgentId=${receiverAgent.agentId} job=${jobId} group=${groupId} result=${JSON.stringify(result)}`
88165
88186
  );
@@ -88894,6 +88915,7 @@ function commandSentryExtra(command, extra = {}) {
88894
88915
  base3.toXmtpAddress = command.toXmtpAddress ?? "";
88895
88916
  } else if (command.type === "xmtp-deny-pending-conversation") {
88896
88917
  base3.groupId = command.groupId;
88918
+ base3.jobId = command.jobId ?? "";
88897
88919
  base3.agentId = command.agentId ?? "";
88898
88920
  } else if (command.type === "xmtp-get-conversation-history") {
88899
88921
  base3.jobId = command.jobId;
@@ -89125,13 +89147,18 @@ async function handleDaemonCommand(command, params) {
89125
89147
  return { ok: true, messageId: result.messageId };
89126
89148
  }
89127
89149
  if (command.type === "xmtp-get-pending-list") {
89128
- const result = [];
89129
- for (const [address] of params.service.getClients()) {
89130
- result.push(...await params.service.listUnknownGroups(address));
89131
- }
89132
- return { ok: true, payload: filterKnownPendingGroups(result, params.sessionStore) };
89150
+ return { ok: true, payload: await listPendingTaskRequests(params) };
89133
89151
  }
89134
89152
  if (command.type === "xmtp-deny-pending-conversation") {
89153
+ if (command.jobId) {
89154
+ return {
89155
+ ok: true,
89156
+ payload: await denyPendingConversationsByJobId(command.jobId, params)
89157
+ };
89158
+ }
89159
+ if (!command.groupId) {
89160
+ throw new Error("xmtp-deny-pending-conversation requires groupId or jobId");
89161
+ }
89135
89162
  if (command.agentId) {
89136
89163
  const address = params.service.getAddressByAgentId(command.agentId);
89137
89164
  if (!address) {
@@ -89164,6 +89191,51 @@ async function handleDaemonCommand(command, params) {
89164
89191
  }
89165
89192
  };
89166
89193
  }
89194
+ async function listPendingTaskRequests(params) {
89195
+ const result = [];
89196
+ for (const [address] of params.service.getClients()) {
89197
+ result.push(...await params.service.listUnknownGroups(address));
89198
+ }
89199
+ return filterKnownPendingGroups(result, params.sessionStore);
89200
+ }
89201
+ async function denyPendingConversationsByJobId(jobId, params) {
89202
+ const pending = await listPendingTaskRequests(params);
89203
+ const matched = pending.filter((item) => isPlainObject2(item) && readString2(item.jobId) === jobId);
89204
+ const clientAddresses = [...params.service.getClients().keys()];
89205
+ const targetsByKey = /* @__PURE__ */ new Map();
89206
+ const groupIds = /* @__PURE__ */ new Set();
89207
+ for (const item of matched) {
89208
+ if (!isPlainObject2(item)) {
89209
+ continue;
89210
+ }
89211
+ const groupId = readString2(item.groupId);
89212
+ if (!groupId) {
89213
+ continue;
89214
+ }
89215
+ groupIds.add(groupId);
89216
+ const address = readString2(item.myXmtpAddress);
89217
+ const addresses = address ? [address] : clientAddresses;
89218
+ for (const candidate of addresses) {
89219
+ targetsByKey.set(`${candidate}
89220
+ ${groupId}`, { address: candidate, groupId });
89221
+ }
89222
+ }
89223
+ const results = await Promise.all(
89224
+ [...targetsByKey.values()].map(async (target) => ({
89225
+ ...target,
89226
+ denied: await params.service.denyGroup(target.address, target.groupId)
89227
+ }))
89228
+ );
89229
+ const deniedOn = results.filter((result) => result.denied).map(({ address, groupId }) => ({ address, groupId }));
89230
+ return {
89231
+ denied: deniedOn.length > 0,
89232
+ jobId,
89233
+ matched: matched.length,
89234
+ groupIds: [...groupIds],
89235
+ deniedClientCount: deniedOn.length,
89236
+ deniedOn
89237
+ };
89238
+ }
89167
89239
  function filterKnownPendingGroups(items, sessionStore) {
89168
89240
  if (!sessionStore) {
89169
89241
  return items;
@@ -89318,7 +89390,8 @@ function formatCommandCompleted(command, result) {
89318
89390
  return `[okx-agent-task] xmtp-get-pending-list command completed id=${command.id}`;
89319
89391
  }
89320
89392
  if (command.type === "xmtp-deny-pending-conversation") {
89321
- return `[okx-agent-task] xmtp-deny-pending-conversation command completed id=${command.id} group=${command.groupId}`;
89393
+ const target = command.jobId ? `job=${command.jobId}` : `group=${command.groupId}`;
89394
+ return `[okx-agent-task] xmtp-deny-pending-conversation command completed id=${command.id} ${target}`;
89322
89395
  }
89323
89396
  if (command.type === "xmtp-get-conversation-history") {
89324
89397
  const rows = Array.isArray(result.payload) ? result.payload.length : 0;
@@ -90103,11 +90176,13 @@ async function verifyInboundA2AGroupMessage(params) {
90103
90176
  return false;
90104
90177
  }
90105
90178
  } catch (err2) {
90179
+ const failureMessage = err2 instanceof Error ? err2.message : String(err2);
90106
90180
  logWithTimestamp(
90107
- `[okx-agent-task:${myXmtpAddress}] message-eligible call failed, letting message through:`,
90181
+ `[okx-agent-task:${myXmtpAddress}] message-eligible call failed, dropping message:
90182
+ ${failureMessage}`,
90108
90183
  err2
90109
90184
  );
90110
- logger.error(LogEvent.INBOUND_ELIGIBILITY_BYPASSED, err2 instanceof Error ? err2 : new Error(String(err2)), {
90185
+ logger.error(LogEvent.INBOUND_BLOCKED_INELIGIBLE, err2 instanceof Error ? err2 : new Error(String(err2)), {
90111
90186
  ...agentExtras({ walletAddress: myXmtpAddress, onchainosAgentId: myAgent.agentId }),
90112
90187
  peerWalletAddress: senderAddress,
90113
90188
  peerInboxId: senderInboxId,
@@ -90118,9 +90193,22 @@ async function verifyInboundA2AGroupMessage(params) {
90118
90193
  direction: isSenderClient ? "client_to_provider" : "provider_to_client",
90119
90194
  providerSecurityRate: String(providerSecurityRate),
90120
90195
  stage: "inbound/eligibility_check",
90121
- reason: "exception",
90196
+ reason: "eligibility_service_error",
90122
90197
  ...timing?.extras()
90123
90198
  });
90199
+ recordInvalidXmtpMessageBestEffort({
90200
+ messageId,
90201
+ groupId,
90202
+ jobId,
90203
+ agentId: senderAgentId,
90204
+ localAgentId: myAgent.agentId,
90205
+ senderAddress,
90206
+ senderInboxId,
90207
+ reason: failureMessage,
90208
+ stage: "inbound/eligibility_check",
90209
+ logTag: `[okx-agent-task:${myXmtpAddress}]`
90210
+ });
90211
+ return false;
90124
90212
  }
90125
90213
  }
90126
90214
  const content3 = readString3(payload.content);
@@ -90887,7 +90975,7 @@ function userWatchEventDeliveredSentryExtra(event) {
90887
90975
  var environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
90888
90976
  var SENTRY_CONFIG = {
90889
90977
  projectName: "okx/openclaw-okx-a2a-extension",
90890
- release: "0.0.20-beta-17d080241c-260626165511",
90978
+ release: "0.0.20",
90891
90979
  environment
90892
90980
  };
90893
90981
 
@@ -91114,12 +91202,12 @@ async function runListenerWithLock(options, paths) {
91114
91202
  }));
91115
91203
  }
91116
91204
  });
91117
- service.setPluginVersion("0.0.20-beta-17d080241c-260626165511");
91205
+ service.setPluginVersion("0.0.20");
91118
91206
  await service.init();
91119
91207
  const pluginVersionStatus = service.pluginVersionStatus;
91120
91208
  if (pluginVersionStatus.unavailable) {
91121
91209
  throw new Error(
91122
- `@okxweb3/a2a-node v${"0.0.20-beta-17d080241c-260626165511"} is below the required minimum v${pluginVersionStatus.minVersion}`
91210
+ `@okxweb3/a2a-node v${"0.0.20"} is below the required minimum v${pluginVersionStatus.minVersion}`
91123
91211
  );
91124
91212
  }
91125
91213
  const systemConfig = service.getSystemConfig();
@@ -91137,7 +91225,7 @@ async function runListenerWithLock(options, paths) {
91137
91225
  onchainosAgentId: "*",
91138
91226
  reason: "system-config missing sentryDsn",
91139
91227
  pluginId: "@okxweb3/a2a-node",
91140
- pluginVersion: "0.0.20-beta-17d080241c-260626165511"
91228
+ pluginVersion: "0.0.20"
91141
91229
  });
91142
91230
  }
91143
91231
  logWithTimestamp(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okxweb3/a2a-node",
3
- "version": "0.0.20-beta-17d080241c-260626165511",
3
+ "version": "0.0.20",
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": {