@okxweb3/a2a-node 0.2.11 → 0.2.12-beta-7449a77b9d-260909165309

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 +1435 -277
  2. package/dist/index.js +149 -66
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -108,6 +108,7 @@ function resolveTaskPaths(homeDir = resolveTaskHome()) {
108
108
  workspaceDir: (0, import_node_path2.join)(homeDir, "workspace"),
109
109
  xmtpDir: (0, import_node_path2.join)(homeDir, "xmtp"),
110
110
  sqliteDir: (0, import_node_path2.join)(homeDir, "sqlite"),
111
+ bzRecordsDir: (0, import_node_path2.join)(homeDir, "bz-records"),
111
112
  pendingCommandsDir: (0, import_node_path2.join)(homeDir, "commands", "pending"),
112
113
  processingCommandsDir: (0, import_node_path2.join)(homeDir, "commands", "processing"),
113
114
  completedCommandsDir: (0, import_node_path2.join)(homeDir, "commands", "completed"),
@@ -713,6 +714,7 @@ var init_session_store = __esm({
713
714
  PRIMARY KEY(session_key, provider)
714
715
  )
715
716
  `);
717
+ this.db.exec("DROP TRIGGER IF EXISTS a2a_ai_sessions_delete_guard");
716
718
  this.db.exec(`
717
719
  CREATE TABLE IF NOT EXISTS job_provider_bindings (
718
720
  job_id TEXT PRIMARY KEY,
@@ -19217,6 +19219,7 @@ var init_events = __esm({
19217
19219
  INBOUND_BLOCKED_INELIGIBLE: "Inbound blocked: message-eligible check failed",
19218
19220
  INBOUND_DROP_EMPTY_CONTENT: "Inbound drop: empty content",
19219
19221
  INBOUND_DROP_MISSING_JOBID: "Inbound drop: missing jobId",
19222
+ INBOUND_DROP_INVALID_JOBID: "Inbound drop: invalid jobId",
19220
19223
  INBOUND_DROP_UNSUPPORTED_MSGTYPE: "Inbound drop: unsupported msgType",
19221
19224
  INBOUND_DROP_DM_NON_SYSTEM: "Inbound drop: DM sender not in system whitelist",
19222
19225
  INBOUND_DROP_DM_INVALID_PAYLOAD: "Inbound drop: DM payload invalid",
@@ -20156,6 +20159,7 @@ var init_sentry_logger = __esm({
20156
20159
  LogEvent.INBOUND_DROP_DM_UNKNOWN_AGENT,
20157
20160
  LogEvent.INBOUND_DROP_EMPTY_CONTENT,
20158
20161
  LogEvent.INBOUND_DROP_MISSING_JOBID,
20162
+ LogEvent.INBOUND_DROP_INVALID_JOBID,
20159
20163
  LogEvent.INBOUND_DROP_UNSUPPORTED_MSGTYPE,
20160
20164
  LogEvent.DM_DELIVERED,
20161
20165
  LogEvent.DM_FALLBACK_TO_BACKUP,
@@ -30987,7 +30991,7 @@ var require_websocket2 = __commonJS({
30987
30991
  var http2 = require("http");
30988
30992
  var net = require("net");
30989
30993
  var tls = require("tls");
30990
- var { randomBytes: randomBytes3, createHash: createHash6 } = require("crypto");
30994
+ var { randomBytes: randomBytes3, createHash: createHash7 } = require("crypto");
30991
30995
  var { Duplex, Readable } = require("stream");
30992
30996
  var { URL: URL2 } = require("url");
30993
30997
  var PerMessageDeflate = require_permessage_deflate();
@@ -31647,7 +31651,7 @@ var require_websocket2 = __commonJS({
31647
31651
  abortHandshake(websocket, socket, "Invalid Upgrade header");
31648
31652
  return;
31649
31653
  }
31650
- const digest = createHash6("sha1").update(key + GUID).digest("base64");
31654
+ const digest = createHash7("sha1").update(key + GUID).digest("base64");
31651
31655
  if (res.headers["sec-websocket-accept"] !== digest) {
31652
31656
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
31653
31657
  return;
@@ -32014,7 +32018,7 @@ var require_websocket_server = __commonJS({
32014
32018
  var EventEmitter2 = require("events");
32015
32019
  var http2 = require("http");
32016
32020
  var { Duplex } = require("stream");
32017
- var { createHash: createHash6 } = require("crypto");
32021
+ var { createHash: createHash7 } = require("crypto");
32018
32022
  var extension = require_extension();
32019
32023
  var PerMessageDeflate = require_permessage_deflate();
32020
32024
  var subprotocol = require_subprotocol();
@@ -32315,7 +32319,7 @@ var require_websocket_server = __commonJS({
32315
32319
  );
32316
32320
  }
32317
32321
  if (this._state > RUNNING) return abortHandshake(socket, 503);
32318
- const digest = createHash6("sha1").update(key + GUID).digest("base64");
32322
+ const digest = createHash7("sha1").update(key + GUID).digest("base64");
32319
32323
  const headers = [
32320
32324
  "HTTP/1.1 101 Switching Protocols",
32321
32325
  "Upgrade: websocket",
@@ -32437,7 +32441,7 @@ var init_sentry_config = __esm({
32437
32441
  environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
32438
32442
  SENTRY_CONFIG = {
32439
32443
  projectName: "okx/openclaw-okx-a2a-extension",
32440
- release: "0.2.11",
32444
+ release: "0.2.12-beta-7449a77b9d-260909165309",
32441
32445
  environment,
32442
32446
  runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
32443
32447
  };
@@ -33378,7 +33382,7 @@ async function getCurrentNodeCliVersion() {
33378
33382
  return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
33379
33383
  }
33380
33384
  function getBundledNodeCliVersion() {
33381
- return true ? "0.2.11" : null;
33385
+ return true ? "0.2.12-beta-7449a77b9d-260909165309" : null;
33382
33386
  }
33383
33387
  function readConfiguredAiProvider() {
33384
33388
  const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
@@ -33588,7 +33592,7 @@ async function updateHermes(release, options) {
33588
33592
  }
33589
33593
  }
33590
33594
  async function installGatewayPluginForDoctor(target) {
33591
- const release = isPrereleaseVersion("0.2.11") ? "beta" : "latest";
33595
+ const release = isPrereleaseVersion("0.2.12-beta-7449a77b9d-260909165309") ? "beta" : "latest";
33592
33596
  const insideTargetGateway = detectGatewayInvocation() === target;
33593
33597
  const options = {
33594
33598
  restart: !insideTargetGateway,
@@ -44351,6 +44355,7 @@ __export(index_exports, {
44351
44355
  buildAgentMessageNotice: () => buildAgentMessageNotice,
44352
44356
  buildAiAdapterCommand: () => buildAiAdapterCommand,
44353
44357
  buildAiProviderEnv: () => buildAiProviderEnv,
44358
+ buildAiRunLogFileName: () => buildAiRunLogFileName,
44354
44359
  buildAutostartVbs: () => buildAutostartVbs,
44355
44360
  buildBackupJobSessionKey: () => buildBackupJobSessionKey,
44356
44361
  buildCodexRecoveryGuidance: () => buildCodexRecoveryGuidance,
@@ -44429,6 +44434,7 @@ __export(index_exports, {
44429
44434
  handleXmtpSendCommand: () => handleXmtpSendCommand,
44430
44435
  handleXmtpTestCommand: () => handleXmtpTestCommand,
44431
44436
  hasAiRuntimeMarker: () => hasAiRuntimeMarker,
44437
+ hashAiRunLogIdentifier: () => hashAiRunLogIdentifier,
44432
44438
  hashDiagnosticFileContent: () => hashDiagnosticFileContent,
44433
44439
  heartbeatUserAttentionWatcher: () => heartbeatUserAttentionWatcher,
44434
44440
  hermesConfigEnablesOkxA2a: () => hermesConfigEnablesOkxA2a,
@@ -44451,6 +44457,7 @@ __export(index_exports, {
44451
44457
  isSqliteBusyError: () => isSqliteBusyError,
44452
44458
  isSystemdManagerUnavailableMessage: () => isSystemdManagerUnavailableMessage,
44453
44459
  isTagKey: () => isTagKey,
44460
+ isValidExternalJobId: () => isValidExternalJobId,
44454
44461
  isWindowsElevated: () => isWindowsElevated,
44455
44462
  killProcessTree: () => killProcessTree,
44456
44463
  launchdPlistHasCurrentRestartPolicy: () => launchdPlistHasCurrentRestartPolicy,
@@ -44569,7 +44576,7 @@ init_autostart();
44569
44576
 
44570
44577
  // src/ai-runner.ts
44571
44578
  init_log();
44572
- var import_node_crypto4 = require("node:crypto");
44579
+ var import_node_crypto5 = require("node:crypto");
44573
44580
  var import_node_fs11 = require("node:fs");
44574
44581
  var import_promises7 = require("node:fs/promises");
44575
44582
  var import_node_os7 = require("node:os");
@@ -45365,6 +45372,23 @@ function applyArgTemplate(template, options) {
45365
45372
 
45366
45373
  // src/ai-runner.ts
45367
45374
  init_win_spawn();
45375
+
45376
+ // src/ai-run-log.ts
45377
+ var import_node_crypto4 = require("node:crypto");
45378
+ function hashAiRunLogIdentifier(value) {
45379
+ return (0, import_node_crypto4.createHash)("sha256").update(value).digest("hex").slice(0, 24);
45380
+ }
45381
+ function buildAiRunLogFileName(request) {
45382
+ const messageIdHash = hashAiRunLogIdentifier(request.messageId);
45383
+ const jobIdHash = hashAiRunLogIdentifier(request.jobId ?? "unknown");
45384
+ if (request.source === "job-dispatch") {
45385
+ return `ai-job-${jobIdHash}-${messageIdHash}.log`;
45386
+ }
45387
+ const sessionKeyHash = hashAiRunLogIdentifier(request.sessionKey);
45388
+ return `ai-session-job-${jobIdHash}-${sessionKeyHash}-${messageIdHash}.log`;
45389
+ }
45390
+
45391
+ // src/ai-runner.ts
45368
45392
  init_session_store();
45369
45393
 
45370
45394
  // src/user-attention-ipc.ts
@@ -46255,13 +46279,7 @@ var AiRunner = class {
46255
46279
  );
46256
46280
  }
46257
46281
  buildRunLogPath(request) {
46258
- const safeMessageId = encodeURIComponent(request.messageId);
46259
- if (request.source === "job-dispatch") {
46260
- const safeJobId = encodeURIComponent(request.jobId ?? "unknown");
46261
- return (0, import_node_path16.join)(this.logsDir, `ai-${safeJobId}-${safeMessageId}.log`);
46262
- }
46263
- const safeSessionKey = encodeURIComponent(request.sessionKey);
46264
- return (0, import_node_path16.join)(this.logsDir, `ai-session-${safeSessionKey}-${safeMessageId}.log`);
46282
+ return (0, import_node_path16.join)(this.logsDir, buildAiRunLogFileName(request));
46265
46283
  }
46266
46284
  readRunAiSessionId(provider, request, file, sessionMeta) {
46267
46285
  if (request.source === "job-dispatch" && request.jobId) {
@@ -47983,7 +48001,7 @@ function normalizeAttentionProvider(provider) {
47983
48001
  return provider === "unknown" ? null : provider;
47984
48002
  }
47985
48003
  function stableHash(value) {
47986
- return (0, import_node_crypto4.createHash)("sha256").update(value).digest("hex").slice(0, 24);
48004
+ return (0, import_node_crypto5.createHash)("sha256").update(value).digest("hex").slice(0, 24);
47987
48005
  }
47988
48006
  function formatCommand(args) {
47989
48007
  return args.map(shellQuote).join(" ");
@@ -48010,7 +48028,7 @@ function shortenJobId(jobId) {
48010
48028
 
48011
48029
  // src/command-store.ts
48012
48030
  init_log();
48013
- var import_node_crypto5 = require("node:crypto");
48031
+ var import_node_crypto6 = require("node:crypto");
48014
48032
  var import_node_fs12 = require("node:fs");
48015
48033
  var import_node_path17 = require("node:path");
48016
48034
  init_paths();
@@ -48035,7 +48053,7 @@ var CommandStore = class {
48035
48053
  }
48036
48054
  createXmtpSendCommand(params) {
48037
48055
  return {
48038
- id: (0, import_node_crypto5.randomUUID)(),
48056
+ id: (0, import_node_crypto6.randomUUID)(),
48039
48057
  type: "xmtp-send",
48040
48058
  jobId: params.jobId,
48041
48059
  message: params.message,
@@ -48051,14 +48069,14 @@ var CommandStore = class {
48051
48069
  }
48052
48070
  createXmtpGetPendingListCommand() {
48053
48071
  return {
48054
- id: (0, import_node_crypto5.randomUUID)(),
48072
+ id: (0, import_node_crypto6.randomUUID)(),
48055
48073
  type: "xmtp-get-pending-list",
48056
48074
  createdAt: Date.now()
48057
48075
  };
48058
48076
  }
48059
48077
  createXmtpDenyPendingConversationCommand(params) {
48060
48078
  return {
48061
- id: (0, import_node_crypto5.randomUUID)(),
48079
+ id: (0, import_node_crypto6.randomUUID)(),
48062
48080
  type: "xmtp-deny-pending-conversation",
48063
48081
  groupId: params.groupId,
48064
48082
  jobId: params.jobId,
@@ -48069,14 +48087,14 @@ var CommandStore = class {
48069
48087
  }
48070
48088
  createXmtpRefreshAgentsCommand() {
48071
48089
  return {
48072
- id: (0, import_node_crypto5.randomUUID)(),
48090
+ id: (0, import_node_crypto6.randomUUID)(),
48073
48091
  type: "xmtp-refresh-agents",
48074
48092
  createdAt: Date.now()
48075
48093
  };
48076
48094
  }
48077
48095
  createXmtpGetConversationHistoryCommand(params) {
48078
48096
  return {
48079
- id: (0, import_node_crypto5.randomUUID)(),
48097
+ id: (0, import_node_crypto6.randomUUID)(),
48080
48098
  type: "xmtp-get-conversation-history",
48081
48099
  jobId: params.jobId,
48082
48100
  toAgentId: params.toAgentId,
@@ -48088,7 +48106,7 @@ var CommandStore = class {
48088
48106
  }
48089
48107
  createXmtpDebugCommand(params) {
48090
48108
  return {
48091
- id: (0, import_node_crypto5.randomUUID)(),
48109
+ id: (0, import_node_crypto6.randomUUID)(),
48092
48110
  type: "xmtp-debug",
48093
48111
  action: params.action,
48094
48112
  groupId: params.groupId,
@@ -48103,7 +48121,7 @@ var CommandStore = class {
48103
48121
  }
48104
48122
  createAiJobMessageDispatchCommand(params) {
48105
48123
  return {
48106
- id: (0, import_node_crypto5.randomUUID)(),
48124
+ id: (0, import_node_crypto6.randomUUID)(),
48107
48125
  type: "ai-dispatch",
48108
48126
  kind: "job-message",
48109
48127
  jobId: params.jobId,
@@ -48114,7 +48132,7 @@ var CommandStore = class {
48114
48132
  }
48115
48133
  createAiSessionMessageDispatchCommand(params) {
48116
48134
  return {
48117
- id: (0, import_node_crypto5.randomUUID)(),
48135
+ id: (0, import_node_crypto6.randomUUID)(),
48118
48136
  type: "ai-dispatch",
48119
48137
  kind: "session-message",
48120
48138
  sessionKey: params.sessionKey,
@@ -48548,7 +48566,7 @@ var import_node_path21 = require("node:path");
48548
48566
  // ../../node_modules/@xmtp/node-sdk/dist/index.js
48549
48567
  var import_node_bindings = require("@xmtp/node-bindings");
48550
48568
  var import_node_bindings2 = require("@xmtp/node-bindings");
48551
- var import_node_crypto6 = require("node:crypto");
48569
+ var import_node_crypto7 = require("node:crypto");
48552
48570
 
48553
48571
  // ../../node_modules/@xmtp/node-sdk/node_modules/@xmtp/content-type-primitives/dist/index.js
48554
48572
  var contentTypeToString = (contentType) => `${contentType.authorityId}/${contentType.typeId}:${contentType.versionMajor}.${contentType.versionMinor}`;
@@ -50270,7 +50288,7 @@ var resolveBackend = async (envOrBackend, gatewayHost) => {
50270
50288
  return createBackend({ env: envOrBackend, gatewayHost });
50271
50289
  };
50272
50290
  var createEphemeralIdentifier = () => ({
50273
- identifier: `0x${(0, import_node_crypto6.randomBytes)(20).toString("hex")}`,
50291
+ identifier: `0x${(0, import_node_crypto7.randomBytes)(20).toString("hex")}`,
50274
50292
  identifierKind: 0
50275
50293
  });
50276
50294
  var toInboxUpdatesCountMap = (value) => {
@@ -55060,7 +55078,7 @@ var sepolia = /* @__PURE__ */ defineChain({
55060
55078
  });
55061
55079
 
55062
55080
  // ../../node_modules/@xmtp/agent-sdk/dist/index.js
55063
- var import_node_crypto7 = require("node:crypto");
55081
+ var import_node_crypto8 = require("node:crypto");
55064
55082
  var version2 = "2.3.0";
55065
55083
  var fromSelf = (message, client) => {
55066
55084
  return message.senderInboxId === client.inboxId;
@@ -55755,7 +55773,7 @@ var Agent = class _Agent extends import_node_events.default {
55755
55773
  return this.#client.accountIdentifier?.identifier;
55756
55774
  }
55757
55775
  };
55758
- var CANCEL_ACTION_ID = (0, import_node_crypto7.randomUUID)();
55776
+ var CANCEL_ACTION_ID = (0, import_node_crypto8.randomUUID)();
55759
55777
  var LimitedMap = class {
55760
55778
  #map = /* @__PURE__ */ new Map();
55761
55779
  #limit;
@@ -59132,7 +59150,7 @@ function buildSendEnvelope(params) {
59132
59150
  init_log();
59133
59151
  init_sentry_logger();
59134
59152
  init_log_fields();
59135
- var import_node_crypto11 = require("node:crypto");
59153
+ var import_node_crypto12 = require("node:crypto");
59136
59154
 
59137
59155
  // ../core/src/a2a/concurrency.ts
59138
59156
  async function withSharedPromise(registry, key, fn) {
@@ -60580,17 +60598,17 @@ init_ai_provider();
60580
60598
 
60581
60599
  // src/agent-message-notice.ts
60582
60600
  init_log();
60583
- var import_node_crypto10 = require("node:crypto");
60601
+ var import_node_crypto11 = require("node:crypto");
60584
60602
  init_session_store();
60585
60603
  init_ai_provider();
60586
60604
 
60587
60605
  // src/outbound-behavior.ts
60588
60606
  init_log();
60589
- var import_node_crypto9 = require("node:crypto");
60607
+ var import_node_crypto10 = require("node:crypto");
60590
60608
 
60591
60609
  // src/openclaw-gateway.ts
60592
60610
  init_log();
60593
- var import_node_crypto8 = require("node:crypto");
60611
+ var import_node_crypto9 = require("node:crypto");
60594
60612
 
60595
60613
  // ../core/src/openclaw-gateway-config.ts
60596
60614
  var import_node_fs17 = require("node:fs");
@@ -61083,7 +61101,7 @@ async function callDeleteSessions(params) {
61083
61101
  return await callOpenClawGateway({ method: "okx-a2a.delete_sessions", params });
61084
61102
  }
61085
61103
  async function callSessionsSend(params) {
61086
- const idempotencyKey = params.idempotencyKey ?? (0, import_node_crypto8.randomUUID)();
61104
+ const idempotencyKey = params.idempotencyKey ?? (0, import_node_crypto9.randomUUID)();
61087
61105
  const sendParams = { key: params.key, message: params.message, idempotencyKey };
61088
61106
  try {
61089
61107
  return await callOpenClawGateway({ method: "sessions.send", params: sendParams });
@@ -61137,7 +61155,7 @@ async function sleep3(ms) {
61137
61155
  var MinimalGatewayClient = class {
61138
61156
  config;
61139
61157
  protocolVersion;
61140
- instanceId = (0, import_node_crypto8.randomUUID)();
61158
+ instanceId = (0, import_node_crypto9.randomUUID)();
61141
61159
  pending = /* @__PURE__ */ new Map();
61142
61160
  ws = null;
61143
61161
  ready = false;
@@ -61225,7 +61243,7 @@ var MinimalGatewayClient = class {
61225
61243
  }));
61226
61244
  }
61227
61245
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
61228
- const id = `okx-a2a-${++this.requestSeq}-${(0, import_node_crypto8.randomUUID)()}`;
61246
+ const id = `okx-a2a-${++this.requestSeq}-${(0, import_node_crypto9.randomUUID)()}`;
61229
61247
  const frame = { type: "req", id, method, params };
61230
61248
  return new Promise((resolve11, reject) => {
61231
61249
  const timer = setTimeout(() => {
@@ -61351,7 +61369,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
61351
61369
  client: {
61352
61370
  id: "gateway-client",
61353
61371
  displayName: "okx-a2a-node",
61354
- version: "0.2.11",
61372
+ version: "0.2.12-beta-7449a77b9d-260909165309",
61355
61373
  platform: "node",
61356
61374
  mode: "backend",
61357
61375
  instanceId
@@ -61362,7 +61380,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
61362
61380
  commands: [],
61363
61381
  permissions: {},
61364
61382
  locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
61365
- userAgent: `okx-a2a-node/${"0.2.11"}`,
61383
+ userAgent: `okx-a2a-node/${"0.2.12-beta-7449a77b9d-260909165309"}`,
61366
61384
  auth: {
61367
61385
  ...config.token ? { token: config.token } : {},
61368
61386
  ...config.password ? { password: config.password } : {}
@@ -61968,7 +61986,7 @@ function resolveSessionGateFallbackMs(env = process.env) {
61968
61986
  return DEFAULT_SESSION_GATE_FALLBACK_MS;
61969
61987
  }
61970
61988
  function resolveUserDeliveryId(input) {
61971
- return input.idempotencyKey?.trim() || (0, import_node_crypto9.randomUUID)();
61989
+ return input.idempotencyKey?.trim() || (0, import_node_crypto10.randomUUID)();
61972
61990
  }
61973
61991
  var GATEWAY_RPC_TRANSPORT = "gateway_rpc";
61974
61992
  var USER_CHANNEL_TRANSPORT = "user_channel";
@@ -62881,7 +62899,7 @@ function buildSystemMessageIdempotencyKey(input) {
62881
62899
  return `system-message:${identity}`;
62882
62900
  }
62883
62901
  function stableHash2(value) {
62884
- return (0, import_node_crypto10.createHash)("sha256").update(value).digest("hex").slice(0, 24);
62902
+ return (0, import_node_crypto11.createHash)("sha256").update(value).digest("hex").slice(0, 24);
62885
62903
  }
62886
62904
 
62887
62905
  // src/xmtp-send.ts
@@ -63425,7 +63443,7 @@ async function handleSqliteGroupSendCommand(params) {
63425
63443
  role: senderAgent?.role,
63426
63444
  sendDurationMs: Date.now() - sendStartMs
63427
63445
  });
63428
- const messageId = `outbound-${(0, import_node_crypto11.randomUUID)()}`;
63446
+ const messageId = `outbound-${(0, import_node_crypto12.randomUUID)()}`;
63429
63447
  await notifyAgentMessageToUserAttention({
63430
63448
  direction: "outbound" /* OUTBOUND */,
63431
63449
  sender: {
@@ -63554,7 +63572,7 @@ async function handleGroupSendCommand(params) {
63554
63572
  sendDurationMs: Date.now() - sendStartMs
63555
63573
  });
63556
63574
  const now = Date.now();
63557
- const messageId = `outbound-${(0, import_node_crypto11.randomUUID)()}`;
63575
+ const messageId = `outbound-${(0, import_node_crypto12.randomUUID)()}`;
63558
63576
  const stored = {
63559
63577
  id: messageId,
63560
63578
  direction: "outbound",
@@ -63773,7 +63791,7 @@ async function handleXmtpSendCommand(params) {
63773
63791
  sendDurationMs: Date.now() - sendStartMs
63774
63792
  });
63775
63793
  const now = Date.now();
63776
- const messageId = `outbound-${(0, import_node_crypto11.randomUUID)()}`;
63794
+ const messageId = `outbound-${(0, import_node_crypto12.randomUUID)()}`;
63777
63795
  const stored = {
63778
63796
  id: messageId,
63779
63797
  direction: "outbound",
@@ -65435,7 +65453,7 @@ function trimForUser2(value) {
65435
65453
 
65436
65454
  // src/message-handler.ts
65437
65455
  init_log();
65438
- var import_node_crypto12 = require("node:crypto");
65456
+ var import_node_crypto13 = require("node:crypto");
65439
65457
  init_sentry_logger();
65440
65458
  init_log_fields();
65441
65459
  init_paths();
@@ -65509,6 +65527,10 @@ function parseJson2(rawText) {
65509
65527
  function readString3(value) {
65510
65528
  return typeof value === "string" && value.length > 0 ? value : null;
65511
65529
  }
65530
+ var EXTERNAL_JOB_ID_PATTERN = /^0x[0-9a-fA-F]{64}$/;
65531
+ function isValidExternalJobId(value) {
65532
+ return typeof value === "string" && EXTERNAL_JOB_ID_PATTERN.test(value);
65533
+ }
65512
65534
  function readNumber(value) {
65513
65535
  return typeof value === "number" && Number.isFinite(value) ? value : null;
65514
65536
  }
@@ -66437,7 +66459,7 @@ async function processFileMessage(ctx, deps, options = {}) {
66437
66459
  timing.mark("payloadParse", parseStartedAt);
66438
66460
  const directToUser = chatType === "dm" && parseResult.ok ? extractDirectToUserNotification(parseResult.data) : { kind: "none" };
66439
66461
  if (directToUser.kind === "invalid") {
66440
- const droppedMessageId = messageId || `direct-to-user-${(0, import_node_crypto12.randomUUID)()}`;
66462
+ const droppedMessageId = messageId || `direct-to-user-${(0, import_node_crypto13.randomUUID)()}`;
66441
66463
  logger.error(
66442
66464
  LogEvent.INBOUND_DROP_DM_INVALID_PAYLOAD,
66443
66465
  new Error("Invalid direct-to-user system DM"),
@@ -66461,7 +66483,7 @@ async function processFileMessage(ctx, deps, options = {}) {
66461
66483
  await dispatchDirectToUserNotification({
66462
66484
  deps,
66463
66485
  notification: directToUser.notification,
66464
- messageId: messageId || `direct-to-user-${(0, import_node_crypto12.randomUUID)()}`,
66486
+ messageId: messageId || `direct-to-user-${(0, import_node_crypto13.randomUUID)()}`,
66465
66487
  timing,
66466
66488
  source: options.source ?? "live"
66467
66489
  });
@@ -66469,7 +66491,7 @@ async function processFileMessage(ctx, deps, options = {}) {
66469
66491
  }
66470
66492
  const systemNotification = chatType === "dm" && parseResult.ok ? extractSystemNotification(parseResult.data) : null;
66471
66493
  if (systemNotification) {
66472
- const systemMessageId = messageId || `system-${(0, import_node_crypto12.randomUUID)()}`;
66494
+ const systemMessageId = messageId || `system-${(0, import_node_crypto13.randomUUID)()}`;
66473
66495
  logWithTimestamp(
66474
66496
  `[okx-agent-task:${deps.myXmtpAddress}] xmtp_system_message_received agentId=${systemNotification.agentId ?? ""} msg=${shortenLogValue(systemMessageId)} event=${systemNotification.event ?? ""} job=${shortenLogValue(systemNotification.jobId)} conv=${conversationId} source=${options.source ?? "live"} rawBytes=${Buffer.byteLength(rawText, "utf8")} rawPreview=${previewRawEnvelope(rawText)}`
66475
66497
  );
@@ -66628,7 +66650,38 @@ async function processFileMessage(ctx, deps, options = {}) {
66628
66650
  const routeStartedAt = Date.now();
66629
66651
  const route = routeMessage(chatType, parseResult.ok, parseResult.data);
66630
66652
  timing.mark("routeResolve", routeStartedAt);
66631
- if (route.route === "job") {
66653
+ if (route.route === "job" && parseResult.ok && isA2AEnvelope(parseResult.data) && !isValidExternalJobId(route.jobId)) {
66654
+ const payloadObject = parseResult.data;
66655
+ const sender = isPlainObject3(payloadObject.sender) ? payloadObject.sender : null;
66656
+ logWithTimestamp(
66657
+ `[okx-agent-task:${deps.myXmtpAddress}] inbound A2A message has invalid jobId, dropping: jobLength=${route.jobId.length} group=${conversationId}`
66658
+ );
66659
+ logger.info(LogEvent.INBOUND_DROP_INVALID_JOBID, timing.extras({
66660
+ ...agentExtras({ walletAddress: deps.myXmtpAddress }),
66661
+ peerWalletAddress: "",
66662
+ peerInboxId: ctx.message.senderInboxId ?? "",
66663
+ peerAgentId: readString3(sender?.agentId) ?? "",
66664
+ conversationId,
66665
+ messageId,
66666
+ chatType,
66667
+ ...inboundStageExtras("inbound/job_id_validation", "dropped"),
66668
+ reason: "invalid_job_id_format"
66669
+ }));
66670
+ recordInvalidXmtpMessageBestEffort({
66671
+ messageId,
66672
+ groupId: conversationId,
66673
+ jobId: null,
66674
+ agentId: readString3(sender?.agentId),
66675
+ localAgentId: XmtpService.getInstance().getAgentByAddress(deps.myXmtpAddress)?.agentId ?? null,
66676
+ senderAddress: null,
66677
+ senderInboxId: ctx.message.senderInboxId ?? "",
66678
+ reason: "invalid_job_id_format",
66679
+ stage: "inbound/job_id_validation",
66680
+ logTag: `[okx-agent-task:${deps.myXmtpAddress}]`
66681
+ });
66682
+ return true;
66683
+ }
66684
+ if (route.route === "job" && chatType !== "group") {
66632
66685
  const providerBindStartedAt = Date.now();
66633
66686
  const providerGate = await bindMessageJobProviderToCurrentDefault(deps, route.jobId, "inbound-xmtp");
66634
66687
  timing.mark("providerBind", providerBindStartedAt);
@@ -66714,7 +66767,27 @@ async function processFileMessage(ctx, deps, options = {}) {
66714
66767
  if (!accepted) {
66715
66768
  return true;
66716
66769
  }
66717
- const routedMessageId = messageId || `group-${(0, import_node_crypto12.randomUUID)()}`;
66770
+ const providerBindStartedAt = Date.now();
66771
+ const providerGate = await bindMessageJobProviderToCurrentDefault(deps, route.jobId, "inbound-xmtp");
66772
+ timing.mark("providerBind", providerBindStartedAt);
66773
+ if (!providerGate.allowed) {
66774
+ logger.info(LogEvent.INBOUND_IGNORED_NON_BUSINESS, timing.extras({
66775
+ ...buildInboundTerminalExtras({
66776
+ terminalState: "provider_gate_denied",
66777
+ myXmtpAddress: deps.myXmtpAddress,
66778
+ messageId,
66779
+ conversationId,
66780
+ chatType,
66781
+ jobId: route.jobId,
66782
+ route: route.route,
66783
+ reason: "job_provider_gate_denied"
66784
+ }),
66785
+ routeReason: route.routeReason,
66786
+ providerBinding: providerGate.provider ?? ""
66787
+ }));
66788
+ return true;
66789
+ }
66790
+ const routedMessageId = messageId || `group-${(0, import_node_crypto13.randomUUID)()}`;
66718
66791
  const sessionKey = ensureInboundGroupSession(deps, {
66719
66792
  jobId: route.jobId,
66720
66793
  myAgentId,
@@ -66780,7 +66853,7 @@ async function processFileMessage(ctx, deps, options = {}) {
66780
66853
  return true;
66781
66854
  }
66782
66855
  const stored = {
66783
- id: messageId || `local-${(0, import_node_crypto12.randomUUID)()}`,
66856
+ id: messageId || `local-${(0, import_node_crypto13.randomUUID)()}`,
66784
66857
  direction: "inbound",
66785
66858
  route: route.route,
66786
66859
  routeReason: route.routeReason,
@@ -66961,7 +67034,7 @@ function processOfflineFromCoreDeps(store, ctx, deps, options) {
66961
67034
  function buildSystemStoredMessage(params) {
66962
67035
  const now = Date.now();
66963
67036
  return {
66964
- id: params.id ?? `system-${now}-${(0, import_node_crypto12.randomUUID)()}`,
67037
+ id: params.id ?? `system-${now}-${(0, import_node_crypto13.randomUUID)()}`,
66965
67038
  direction: "system",
66966
67039
  route: "backup",
66967
67040
  routeReason: params.reason,
@@ -67123,7 +67196,7 @@ async function enqueueAiSessionMessageDispatch(params) {
67123
67196
  init_paths();
67124
67197
 
67125
67198
  // src/user-attention-watchers.ts
67126
- var import_node_crypto13 = require("node:crypto");
67199
+ var import_node_crypto14 = require("node:crypto");
67127
67200
  init_sentry_logger();
67128
67201
  var USER_ATTENTION_WATCH_REPLACED_MESSAGE = "Another okx-a2a user watch with the same job scope was started, so this watcher has been closed. Do not run this watch command again automatically, because starting another watcher may interrupt a different session that is already monitoring task progress.";
67129
67202
  var USER_ATTENTION_WATCHER_SCAN_MS = 500;
@@ -67166,7 +67239,7 @@ function isOriginalParentProcessAlive(options) {
67166
67239
  }
67167
67240
  function registerUserAttentionWatcher(options) {
67168
67241
  return options.store.registerUserAttentionWatcher({
67169
- id: options.id ?? (0, import_node_crypto13.randomUUID)(),
67242
+ id: options.id ?? (0, import_node_crypto14.randomUUID)(),
67170
67243
  provider: options.provider,
67171
67244
  jobId: options.jobId,
67172
67245
  nowMs: options.nowMs ?? Date.now(),
@@ -67729,12 +67802,12 @@ async function runListenerWithLock(options, paths) {
67729
67802
  });
67730
67803
  }
67731
67804
  });
67732
- service.setPluginVersion("0.2.11");
67805
+ service.setPluginVersion("0.2.12-beta-7449a77b9d-260909165309");
67733
67806
  await service.init();
67734
67807
  const pluginVersionStatus = service.pluginVersionStatus;
67735
67808
  if (pluginVersionStatus.unavailable) {
67736
67809
  throw new Error(
67737
- `@okxweb3/a2a-node v${"0.2.11"} is below the required minimum v${pluginVersionStatus.minVersion}`
67810
+ `@okxweb3/a2a-node v${"0.2.12-beta-7449a77b9d-260909165309"} is below the required minimum v${pluginVersionStatus.minVersion}`
67738
67811
  );
67739
67812
  }
67740
67813
  const systemConfig = service.getSystemConfig();
@@ -67762,7 +67835,7 @@ async function runListenerWithLock(options, paths) {
67762
67835
  onchainosAgentId: "*",
67763
67836
  reason: "system-config missing sentryDsn",
67764
67837
  pluginId: "@okxweb3/a2a-node",
67765
- pluginVersion: "0.2.11"
67838
+ pluginVersion: "0.2.12-beta-7449a77b9d-260909165309"
67766
67839
  });
67767
67840
  }
67768
67841
  logWithTimestamp(
@@ -69138,6 +69211,11 @@ function getA2ACapabilities() {
69138
69211
  ok: true,
69139
69212
  fixCommands: [],
69140
69213
  message: ""
69214
+ },
69215
+ tradeRecordsV1: {
69216
+ ok: true,
69217
+ fixCommands: [],
69218
+ message: ""
69141
69219
  }
69142
69220
  };
69143
69221
  }
@@ -69219,7 +69297,7 @@ var import_node_path34 = require("node:path");
69219
69297
  var import_jszip = __toESM(require_lib3());
69220
69298
 
69221
69299
  // src/logs-export-archive.ts
69222
- var import_node_crypto14 = require("node:crypto");
69300
+ var import_node_crypto15 = require("node:crypto");
69223
69301
  var import_node_fs24 = require("node:fs");
69224
69302
  var import_promises13 = require("node:fs/promises");
69225
69303
  var import_node_path31 = require("node:path");
@@ -69855,7 +69933,7 @@ async function writeArchiveAtomically(outputPath, archive, overwrite) {
69855
69933
  await (0, import_promises13.mkdir)((0, import_node_path31.dirname)(outputPath), { recursive: true });
69856
69934
  const temporaryPath = (0, import_node_path31.join)(
69857
69935
  (0, import_node_path31.dirname)(outputPath),
69858
- `.${(0, import_node_path31.basename)(outputPath)}.${(0, import_node_crypto14.randomUUID)()}.tmp`
69936
+ `.${(0, import_node_path31.basename)(outputPath)}.${(0, import_node_crypto15.randomUUID)()}.tmp`
69859
69937
  );
69860
69938
  try {
69861
69939
  await (0, import_promises13.writeFile)(temporaryPath, archive, { flag: "wx", mode: 384 });
@@ -69874,7 +69952,7 @@ async function writeArchiveAtomically(outputPath, archive, overwrite) {
69874
69952
  }
69875
69953
  }
69876
69954
  function hashDiagnosticFileContent(content) {
69877
- return (0, import_node_crypto14.createHash)("sha256").update(content).digest("hex");
69955
+ return (0, import_node_crypto15.createHash)("sha256").update(content).digest("hex");
69878
69956
  }
69879
69957
  function isUnavailableError(err) {
69880
69958
  return !!err && typeof err === "object" && "diagnosticUnavailable" in err;
@@ -70134,7 +70212,7 @@ function isProvider2(value) {
70134
70212
  }
70135
70213
 
70136
70214
  // src/logs-export-utils.ts
70137
- var import_node_crypto15 = require("node:crypto");
70215
+ var import_node_crypto16 = require("node:crypto");
70138
70216
  var import_node_fs26 = require("node:fs");
70139
70217
  var import_promises14 = require("node:fs/promises");
70140
70218
  var import_node_path33 = require("node:path");
@@ -70277,7 +70355,7 @@ async function assertRegularFile2(path2) {
70277
70355
  }
70278
70356
  async function inspectRegularFile(path2) {
70279
70357
  const file = await assertRegularFile2(path2);
70280
- const hash2 = (0, import_node_crypto15.createHash)("sha256");
70358
+ const hash2 = (0, import_node_crypto16.createHash)("sha256");
70281
70359
  for await (const chunk of (0, import_node_fs26.createReadStream)(path2)) {
70282
70360
  hash2.update(chunk);
70283
70361
  }
@@ -70530,7 +70608,7 @@ async function exportDiagnosticLogs(options) {
70530
70608
  node: process.version,
70531
70609
  platform: process.platform,
70532
70610
  arch: process.arch,
70533
- packageVersion: true ? "0.2.11" : "unknown",
70611
+ packageVersion: true ? "0.2.12-beta-7449a77b9d-260909165309" : "unknown",
70534
70612
  sensitiveContentIncluded: options.includeSensitiveContent,
70535
70613
  listenerAndLlmContentIncluded: true,
70536
70614
  credentialsAlwaysRedacted: true,
@@ -70749,9 +70827,11 @@ async function collectA2aLogs(state, paths, options, sessionKeys, correlationIds
70749
70827
  if (!name.endsWith(".log") || !name.startsWith("ai-") && !name.startsWith("ai-session-")) {
70750
70828
  continue;
70751
70829
  }
70752
- const matchesDirectJob = options.jobId ? name.startsWith(`ai-${encodeURIComponent(options.jobId)}-`) : true;
70830
+ const matchesDirectJob = options.jobId ? name.startsWith(`ai-${encodeURIComponent(options.jobId)}-`) || name.startsWith(`ai-job-${hashAiRunLogIdentifier(options.jobId)}-`) : true;
70753
70831
  const matchesPersistedSession = sessionKeys.some(
70754
- (key) => name.startsWith(`ai-session-${encodeURIComponent(key)}-`)
70832
+ (key) => name.startsWith(`ai-session-${encodeURIComponent(key)}-`) || new RegExp(
70833
+ `^ai-session-job-[0-9a-f]{24}-${hashAiRunLogIdentifier(key)}-`
70834
+ ).test(name)
70755
70835
  );
70756
70836
  const matchesJobSessionFilename = options.jobId ? matchesJobSessionLogFilename(name, options.jobId) : false;
70757
70837
  if (!matchesDirectJob && !matchesPersistedSession && !matchesJobSessionFilename) {
@@ -71364,7 +71444,7 @@ function matchesJobSessionLogFilename(name, jobId) {
71364
71444
  const encodedJobId = encodeURIComponent(jobId);
71365
71445
  const jobSessionPrefix = encodeURIComponent(`job:${encodedJobId}:`);
71366
71446
  const backupSessionKey = encodeURIComponent(`backup:${encodedJobId}`);
71367
- return name.startsWith(`ai-session-${jobSessionPrefix}`) || name.startsWith(`ai-session-${backupSessionKey}-`);
71447
+ return name.startsWith(`ai-session-${jobSessionPrefix}`) || name.startsWith(`ai-session-${backupSessionKey}-`) || name.startsWith(`ai-session-job-${hashAiRunLogIdentifier(jobId)}-`);
71368
71448
  }
71369
71449
  function isOpenClawSessionLogName(name) {
71370
71450
  return name.endsWith(".jsonl") && name !== "sessions.json";
@@ -72412,7 +72492,7 @@ async function runDoctor(options = {}) {
72412
72492
  platform: options.platform ?? process.platform,
72413
72493
  env: options.env ?? process.env,
72414
72494
  target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
72415
- cliVersion: options.cliVersion ?? (true ? "0.2.11" : "0.0.0"),
72495
+ cliVersion: options.cliVersion ?? (true ? "0.2.12-beta-7449a77b9d-260909165309" : "0.0.0"),
72416
72496
  fixMode: options.fix === true,
72417
72497
  nonInteractive: options.nonInteractive === true,
72418
72498
  packageChanged: false,
@@ -72700,6 +72780,7 @@ init_autostart_windows();
72700
72780
  buildAgentMessageNotice,
72701
72781
  buildAiAdapterCommand,
72702
72782
  buildAiProviderEnv,
72783
+ buildAiRunLogFileName,
72703
72784
  buildAutostartVbs,
72704
72785
  buildBackupJobSessionKey,
72705
72786
  buildCodexRecoveryGuidance,
@@ -72778,6 +72859,7 @@ init_autostart_windows();
72778
72859
  handleXmtpSendCommand,
72779
72860
  handleXmtpTestCommand,
72780
72861
  hasAiRuntimeMarker,
72862
+ hashAiRunLogIdentifier,
72781
72863
  hashDiagnosticFileContent,
72782
72864
  heartbeatUserAttentionWatcher,
72783
72865
  hermesConfigEnablesOkxA2a,
@@ -72800,6 +72882,7 @@ init_autostart_windows();
72800
72882
  isSqliteBusyError,
72801
72883
  isSystemdManagerUnavailableMessage,
72802
72884
  isTagKey,
72885
+ isValidExternalJobId,
72803
72886
  isWindowsElevated,
72804
72887
  killProcessTree,
72805
72888
  launchdPlistHasCurrentRestartPolicy,