@okxweb3/a2a-node 0.2.3-beta-fa7df0d9e7-260810102542 → 0.2.3
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.
- package/dist/cli.js +197 -33
- package/dist/index.js +195 -29
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -20131,7 +20131,15 @@ function classifyError(error, code) {
|
|
|
20131
20131
|
if (normalizedCode === "ABORT_ERR" || name === "aborterror") {
|
|
20132
20132
|
return "cancelled";
|
|
20133
20133
|
}
|
|
20134
|
-
if (name === "syntaxerror"
|
|
20134
|
+
if (name === "syntaxerror") {
|
|
20135
|
+
return "invalid_response";
|
|
20136
|
+
}
|
|
20137
|
+
if (/connection\s+(?:reset|closed|interrupted)|broken\s+pipe|unexpected\s+eof/.test(
|
|
20138
|
+
message
|
|
20139
|
+
)) {
|
|
20140
|
+
return "connection_interrupted";
|
|
20141
|
+
}
|
|
20142
|
+
if (/(?:json|response).*(?:parse|invalid)/.test(message)) {
|
|
20135
20143
|
return "invalid_response";
|
|
20136
20144
|
}
|
|
20137
20145
|
if (/session\s+(?:is\s+)?expired|login\s+expired/.test(message)) {
|
|
@@ -20425,6 +20433,7 @@ var init_sentry_logger = __esm({
|
|
|
20425
20433
|
"releaseBase",
|
|
20426
20434
|
"releaseChannel",
|
|
20427
20435
|
"releaseCode",
|
|
20436
|
+
"replayOutcome",
|
|
20428
20437
|
"role",
|
|
20429
20438
|
"runId",
|
|
20430
20439
|
"runtimeContainer",
|
|
@@ -26595,7 +26604,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
26595
26604
|
client: {
|
|
26596
26605
|
id: "gateway-client",
|
|
26597
26606
|
displayName: "okx-a2a-node",
|
|
26598
|
-
version: "0.2.3
|
|
26607
|
+
version: "0.2.3",
|
|
26599
26608
|
platform: "node",
|
|
26600
26609
|
mode: "backend",
|
|
26601
26610
|
instanceId
|
|
@@ -26606,7 +26615,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
26606
26615
|
commands: [],
|
|
26607
26616
|
permissions: {},
|
|
26608
26617
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
26609
|
-
userAgent: `okx-a2a-node/${"0.2.3
|
|
26618
|
+
userAgent: `okx-a2a-node/${"0.2.3"}`,
|
|
26610
26619
|
auth: {
|
|
26611
26620
|
...config.token ? { token: config.token } : {},
|
|
26612
26621
|
...config.password ? { password: config.password } : {}
|
|
@@ -28490,7 +28499,7 @@ var init_sentry_config = __esm({
|
|
|
28490
28499
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
28491
28500
|
SENTRY_CONFIG = {
|
|
28492
28501
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
28493
|
-
release: "0.2.3
|
|
28502
|
+
release: "0.2.3",
|
|
28494
28503
|
environment,
|
|
28495
28504
|
runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
|
|
28496
28505
|
};
|
|
@@ -39660,7 +39669,7 @@ async function exportDiagnosticLogs(options) {
|
|
|
39660
39669
|
node: process.version,
|
|
39661
39670
|
platform: process.platform,
|
|
39662
39671
|
arch: process.arch,
|
|
39663
|
-
packageVersion: true ? "0.2.3
|
|
39672
|
+
packageVersion: true ? "0.2.3" : "unknown",
|
|
39664
39673
|
sensitiveContentIncluded: options.includeSensitiveContent,
|
|
39665
39674
|
listenerAndLlmContentIncluded: true,
|
|
39666
39675
|
credentialsAlwaysRedacted: true,
|
|
@@ -56498,6 +56507,13 @@ function parseGroupPayload(content2) {
|
|
|
56498
56507
|
return null;
|
|
56499
56508
|
}
|
|
56500
56509
|
}
|
|
56510
|
+
function replayScanBackoffMs(consecutiveFailures) {
|
|
56511
|
+
const exponent = Math.max(0, Math.floor(consecutiveFailures) - 1);
|
|
56512
|
+
return Math.min(
|
|
56513
|
+
REPLAY_SCAN_INITIAL_BACKOFF_MS * 2 ** exponent,
|
|
56514
|
+
REPLAY_SCAN_MAX_BACKOFF_MS
|
|
56515
|
+
);
|
|
56516
|
+
}
|
|
56501
56517
|
function isOfflineReplayForTrigger(trigger) {
|
|
56502
56518
|
return trigger === "startup";
|
|
56503
56519
|
}
|
|
@@ -56510,6 +56526,7 @@ function replaySingleFlightDiscriminator(trigger, clientGeneration, recoveryIden
|
|
|
56510
56526
|
function createOfflineReplayAddressSummary(address) {
|
|
56511
56527
|
return {
|
|
56512
56528
|
address,
|
|
56529
|
+
outcome: "skipped",
|
|
56513
56530
|
replayed: 0,
|
|
56514
56531
|
skipped: 0,
|
|
56515
56532
|
conversations: 0,
|
|
@@ -56524,7 +56541,7 @@ function createOfflineReplayAddressSummary(address) {
|
|
|
56524
56541
|
durationMs: 0
|
|
56525
56542
|
};
|
|
56526
56543
|
}
|
|
56527
|
-
var import_node_fs22, import_node_path26, DEFAULT_DATA_DIR, XMTP_INSTALLATION_WARNING_THRESHOLD, XMTP_INSTALLATION_NEAR_LIMIT_THRESHOLD, SENSITIVE_WORDS_LAZY_RETRY_COOLDOWN_MS, SESSION_EXPIRED_RE, InboundReplayGate, SYSTEM_CONFIG_DEFAULTS, STREAM_RECOVERY_ALERT_THRESHOLD_MS, REPLAY_GATE_DRAIN_MAX_ATTEMPTS, REPLAY_GATE_DRAIN_RETRY_DELAY_MS, SEMVER_RE, isRecord5, isPositiveNumber, SYSTEM_CONFIG_VALIDATORS, XmtpService;
|
|
56544
|
+
var import_node_fs22, import_node_path26, DEFAULT_DATA_DIR, XMTP_INSTALLATION_WARNING_THRESHOLD, XMTP_INSTALLATION_NEAR_LIMIT_THRESHOLD, REPLAY_SCAN_INITIAL_BACKOFF_MS, REPLAY_SCAN_MAX_BACKOFF_MS, SENSITIVE_WORDS_LAZY_RETRY_COOLDOWN_MS, SESSION_EXPIRED_RE, InboundReplayGate, SYSTEM_CONFIG_DEFAULTS, STREAM_RECOVERY_ALERT_THRESHOLD_MS, REPLAY_GATE_DRAIN_MAX_ATTEMPTS, REPLAY_GATE_DRAIN_RETRY_DELAY_MS, SEMVER_RE, isRecord5, isPositiveNumber, SYSTEM_CONFIG_VALIDATORS, XmtpService;
|
|
56528
56545
|
var init_xmtp_sdk = __esm({
|
|
56529
56546
|
"../core/src/xmtp-sdk/index.ts"() {
|
|
56530
56547
|
"use strict";
|
|
@@ -56545,6 +56562,8 @@ var init_xmtp_sdk = __esm({
|
|
|
56545
56562
|
DEFAULT_DATA_DIR = resolveA2aTaskPaths().xmtpDir;
|
|
56546
56563
|
XMTP_INSTALLATION_WARNING_THRESHOLD = 2;
|
|
56547
56564
|
XMTP_INSTALLATION_NEAR_LIMIT_THRESHOLD = 8;
|
|
56565
|
+
REPLAY_SCAN_INITIAL_BACKOFF_MS = 3e4;
|
|
56566
|
+
REPLAY_SCAN_MAX_BACKOFF_MS = 5 * 6e4;
|
|
56548
56567
|
SENSITIVE_WORDS_LAZY_RETRY_COOLDOWN_MS = 10 * 60 * 1e3;
|
|
56549
56568
|
SESSION_EXPIRED_RE = /session expired/i;
|
|
56550
56569
|
InboundReplayGate = class {
|
|
@@ -56677,6 +56696,11 @@ var init_xmtp_sdk = __esm({
|
|
|
56677
56696
|
dataDir = DEFAULT_DATA_DIR;
|
|
56678
56697
|
syncByAddress = /* @__PURE__ */ new Map();
|
|
56679
56698
|
offlineReplaySingleFlight = new KeyedSingleFlight();
|
|
56699
|
+
replayScanFailuresByAddress = /* @__PURE__ */ new Map();
|
|
56700
|
+
replayScanRetryByAddress = /* @__PURE__ */ new Map();
|
|
56701
|
+
replayScanNowMs = () => Date.now();
|
|
56702
|
+
replayScanSetTimeout = (callback, delayMs) => setTimeout(callback, delayMs);
|
|
56703
|
+
replayScanClearTimeout = (timer) => clearTimeout(timer);
|
|
56680
56704
|
inboundReplayGates = /* @__PURE__ */ new Map();
|
|
56681
56705
|
streamRecoveryCleanupByAddress = /* @__PURE__ */ new Map();
|
|
56682
56706
|
nextClientGeneration = 1;
|
|
@@ -57155,6 +57179,8 @@ var init_xmtp_sdk = __esm({
|
|
|
57155
57179
|
}
|
|
57156
57180
|
this.clients.delete(address);
|
|
57157
57181
|
this.inboundReplayGates.delete(address.toLowerCase());
|
|
57182
|
+
this.replayScanFailuresByAddress.delete(address.toLowerCase());
|
|
57183
|
+
this.clearReplayScanRetry(address);
|
|
57158
57184
|
logger.info(LogEvent.AGENT_CLIENT_REMOVED, {
|
|
57159
57185
|
...agentExtras({
|
|
57160
57186
|
walletAddress: address,
|
|
@@ -57369,6 +57395,8 @@ var init_xmtp_sdk = __esm({
|
|
|
57369
57395
|
await Promise.resolve(oldClient.stop());
|
|
57370
57396
|
this.clients.delete(address);
|
|
57371
57397
|
this.inboundReplayGates.delete(addressKey);
|
|
57398
|
+
this.replayScanFailuresByAddress.delete(addressKey);
|
|
57399
|
+
this.clearReplayScanRetry(address);
|
|
57372
57400
|
logWithTimestamp(
|
|
57373
57401
|
`[xmtp-sdk] recycle: stopped client: ${address} (agentId=${agentInfo.agentId})`
|
|
57374
57402
|
);
|
|
@@ -57918,6 +57946,60 @@ var init_xmtp_sdk = __esm({
|
|
|
57918
57946
|
this.clientGenerationByClient.set(client, generation);
|
|
57919
57947
|
return generation;
|
|
57920
57948
|
}
|
|
57949
|
+
clearReplayScanRetry(address) {
|
|
57950
|
+
const addressKey = address.toLowerCase();
|
|
57951
|
+
const scheduled = this.replayScanRetryByAddress.get(addressKey);
|
|
57952
|
+
if (!scheduled) {
|
|
57953
|
+
return;
|
|
57954
|
+
}
|
|
57955
|
+
this.replayScanRetryByAddress.delete(addressKey);
|
|
57956
|
+
this.replayScanClearTimeout(scheduled.timer);
|
|
57957
|
+
}
|
|
57958
|
+
scheduleReplayScanRetry(address, expectedClient, clientGeneration, retryTrigger, delayMs) {
|
|
57959
|
+
const addressKey = address.toLowerCase();
|
|
57960
|
+
const scheduled = this.replayScanRetryByAddress.get(addressKey);
|
|
57961
|
+
if (scheduled?.clientGeneration === clientGeneration) {
|
|
57962
|
+
return;
|
|
57963
|
+
}
|
|
57964
|
+
if (scheduled) {
|
|
57965
|
+
this.clearReplayScanRetry(address);
|
|
57966
|
+
}
|
|
57967
|
+
const timer = this.replayScanSetTimeout(() => {
|
|
57968
|
+
const current = this.replayScanRetryByAddress.get(addressKey);
|
|
57969
|
+
if (current?.timer !== timer) {
|
|
57970
|
+
return;
|
|
57971
|
+
}
|
|
57972
|
+
this.replayScanRetryByAddress.delete(addressKey);
|
|
57973
|
+
if (this.clients.get(address) !== expectedClient || this.stoppedAddresses.has(addressKey)) {
|
|
57974
|
+
return;
|
|
57975
|
+
}
|
|
57976
|
+
void this.replayOfflineMessagesForAddressSingleFlight(
|
|
57977
|
+
address,
|
|
57978
|
+
retryTrigger,
|
|
57979
|
+
void 0,
|
|
57980
|
+
expectedClient
|
|
57981
|
+
).catch((err2) => {
|
|
57982
|
+
logWithTimestamp(
|
|
57983
|
+
`[xmtp-sdk:replay:${address}] scheduled replay scan retry failed:`,
|
|
57984
|
+
err2
|
|
57985
|
+
);
|
|
57986
|
+
logger.error(
|
|
57987
|
+
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
57988
|
+
err2 instanceof Error ? err2 : new Error(String(err2)),
|
|
57989
|
+
{
|
|
57990
|
+
walletAddress: address,
|
|
57991
|
+
stage: "offlineReplay/scheduledRetry",
|
|
57992
|
+
outcome: "failed"
|
|
57993
|
+
}
|
|
57994
|
+
);
|
|
57995
|
+
});
|
|
57996
|
+
}, Math.max(0, delayMs));
|
|
57997
|
+
timer.unref?.();
|
|
57998
|
+
this.replayScanRetryByAddress.set(addressKey, {
|
|
57999
|
+
clientGeneration,
|
|
58000
|
+
timer
|
|
58001
|
+
});
|
|
58002
|
+
}
|
|
57921
58003
|
notifyAgentsWakeupAfterReplay() {
|
|
57922
58004
|
const notifyAgentsWakeup2 = this.tools.notifyAgentsWakeup;
|
|
57923
58005
|
const agentIds = this.allAgents.map((agent) => agent.agentId);
|
|
@@ -58156,7 +58238,7 @@ var init_xmtp_sdk = __esm({
|
|
|
58156
58238
|
String(recovery.recoverySequence),
|
|
58157
58239
|
agent
|
|
58158
58240
|
);
|
|
58159
|
-
if (!recoveryDisposed && this.clients.get(address) === agent) {
|
|
58241
|
+
if (summary.outcome === "completed" && !recoveryDisposed && this.clients.get(address) === agent) {
|
|
58160
58242
|
logger.info(LogEvent.AGENT_STREAM_RECOVERY_REPLAY_COMPLETED, {
|
|
58161
58243
|
...agentExtras(identity),
|
|
58162
58244
|
clientGeneration: String(clientGeneration),
|
|
@@ -58164,7 +58246,9 @@ var init_xmtp_sdk = __esm({
|
|
|
58164
58246
|
replayed: String(summary.replayed),
|
|
58165
58247
|
skipped: String(summary.skipped),
|
|
58166
58248
|
conversationCount: String(summary.conversations),
|
|
58167
|
-
replayDurationMs: String(summary.durationMs)
|
|
58249
|
+
replayDurationMs: String(summary.durationMs),
|
|
58250
|
+
outcome: "success",
|
|
58251
|
+
replayOutcome: summary.outcome
|
|
58168
58252
|
});
|
|
58169
58253
|
}
|
|
58170
58254
|
} catch (err2) {
|
|
@@ -58230,10 +58314,6 @@ var init_xmtp_sdk = __esm({
|
|
|
58230
58314
|
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58231
58315
|
return summary;
|
|
58232
58316
|
}
|
|
58233
|
-
const sentAfterNs = BigInt(lastSyncMs) * 1000000n;
|
|
58234
|
-
logWithTimestamp(
|
|
58235
|
-
`${tag} offline_replay_start agentId=${this.getAgentByAddress(address)?.agentId ?? ""} address=${address} since=${formatLogTimestamp2(lastSyncMs)} sinceMs=${lastSyncMs}`
|
|
58236
|
-
);
|
|
58237
58317
|
const myInboxId = agent.client.inboxId;
|
|
58238
58318
|
const handlerDeps = {
|
|
58239
58319
|
myXmtpAddress: address,
|
|
@@ -58248,7 +58328,87 @@ var init_xmtp_sdk = __esm({
|
|
|
58248
58328
|
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58249
58329
|
return summary;
|
|
58250
58330
|
}
|
|
58331
|
+
const addressKey = address.toLowerCase();
|
|
58332
|
+
const clientGeneration = this.getClientGeneration(agent);
|
|
58333
|
+
const attemptNowMs = this.replayScanNowMs();
|
|
58334
|
+
let priorFailure = this.replayScanFailuresByAddress.get(addressKey);
|
|
58335
|
+
if (priorFailure && priorFailure.clientGeneration !== clientGeneration) {
|
|
58336
|
+
this.replayScanFailuresByAddress.delete(addressKey);
|
|
58337
|
+
this.clearReplayScanRetry(address);
|
|
58338
|
+
priorFailure = void 0;
|
|
58339
|
+
}
|
|
58340
|
+
if (priorFailure && attemptNowMs < priorFailure.nextAttemptAtMs) {
|
|
58341
|
+
priorFailure.suppressedAttempts++;
|
|
58342
|
+
summary.outcome = "suppressed_backoff";
|
|
58343
|
+
summary.failureStage = priorFailure.lastFailureStage;
|
|
58344
|
+
summary.consecutiveFailures = priorFailure.consecutiveFailures;
|
|
58345
|
+
summary.backoffMs = priorFailure.nextAttemptAtMs - attemptNowMs;
|
|
58346
|
+
summary.suppressedAttempts = priorFailure.suppressedAttempts;
|
|
58347
|
+
if (priorFailure.suppressedAttempts === 1) {
|
|
58348
|
+
logWithTimestamp(
|
|
58349
|
+
`${tag} replay scan suppressed stage=${priorFailure.lastFailureStage} consecutiveFailures=${priorFailure.consecutiveFailures} retryInMs=${summary.backoffMs}`
|
|
58350
|
+
);
|
|
58351
|
+
}
|
|
58352
|
+
this.scheduleReplayScanRetry(
|
|
58353
|
+
address,
|
|
58354
|
+
agent,
|
|
58355
|
+
clientGeneration,
|
|
58356
|
+
priorFailure.retryTrigger,
|
|
58357
|
+
summary.backoffMs
|
|
58358
|
+
);
|
|
58359
|
+
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58360
|
+
return summary;
|
|
58361
|
+
}
|
|
58362
|
+
const sentAfterNs = BigInt(lastSyncMs) * 1000000n;
|
|
58363
|
+
logWithTimestamp(
|
|
58364
|
+
`${tag} offline_replay_start agentId=${this.getAgentByAddress(address)?.agentId ?? ""} address=${address} since=${formatLogTimestamp2(lastSyncMs)} sinceMs=${lastSyncMs}`
|
|
58365
|
+
);
|
|
58251
58366
|
let conversations;
|
|
58367
|
+
const recordScanFailure = (stage, err2) => {
|
|
58368
|
+
const previous = this.replayScanFailuresByAddress.get(addressKey);
|
|
58369
|
+
const consecutiveFailures = (previous?.consecutiveFailures ?? 0) + 1;
|
|
58370
|
+
const backoffMs = replayScanBackoffMs(consecutiveFailures);
|
|
58371
|
+
const suppressedAttempts = previous?.suppressedAttempts ?? 0;
|
|
58372
|
+
const failureNowMs = this.replayScanNowMs();
|
|
58373
|
+
const retryTrigger = isOfflineReplayForTrigger(trigger) ? "startup" : "periodic_repair";
|
|
58374
|
+
this.replayScanFailuresByAddress.set(addressKey, {
|
|
58375
|
+
clientGeneration,
|
|
58376
|
+
consecutiveFailures,
|
|
58377
|
+
nextAttemptAtMs: failureNowMs + backoffMs,
|
|
58378
|
+
retryTrigger,
|
|
58379
|
+
suppressedAttempts: 0,
|
|
58380
|
+
lastFailureStage: stage
|
|
58381
|
+
});
|
|
58382
|
+
this.scheduleReplayScanRetry(
|
|
58383
|
+
address,
|
|
58384
|
+
agent,
|
|
58385
|
+
clientGeneration,
|
|
58386
|
+
retryTrigger,
|
|
58387
|
+
backoffMs
|
|
58388
|
+
);
|
|
58389
|
+
summary.outcome = stage === "syncAll" ? "sync_failed" : "list_failed";
|
|
58390
|
+
summary.failureStage = stage;
|
|
58391
|
+
summary.consecutiveFailures = consecutiveFailures;
|
|
58392
|
+
summary.backoffMs = backoffMs;
|
|
58393
|
+
summary.suppressedAttempts = suppressedAttempts;
|
|
58394
|
+
logWithTimestamp(`${tag} conversation ${stage} failed, backing off:`, err2);
|
|
58395
|
+
logger.error(
|
|
58396
|
+
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
58397
|
+
err2 instanceof Error ? err2 : void 0,
|
|
58398
|
+
{
|
|
58399
|
+
walletAddress: address,
|
|
58400
|
+
stage: `offlineReplay/${stage}`,
|
|
58401
|
+
trigger,
|
|
58402
|
+
outcome: "failed",
|
|
58403
|
+
replayOutcome: summary.outcome,
|
|
58404
|
+
consecutiveFailures: String(consecutiveFailures),
|
|
58405
|
+
backoffMs: String(backoffMs),
|
|
58406
|
+
suppressedAttempts: String(suppressedAttempts)
|
|
58407
|
+
}
|
|
58408
|
+
);
|
|
58409
|
+
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58410
|
+
return summary;
|
|
58411
|
+
};
|
|
58252
58412
|
try {
|
|
58253
58413
|
const syncAllStartedAt = Date.now();
|
|
58254
58414
|
await agent.client.conversations.syncAll([
|
|
@@ -58256,6 +58416,10 @@ var init_xmtp_sdk = __esm({
|
|
|
58256
58416
|
import_node_bindings2.ConsentState.Unknown
|
|
58257
58417
|
]);
|
|
58258
58418
|
summary.syncAllMs = Date.now() - syncAllStartedAt;
|
|
58419
|
+
} catch (err2) {
|
|
58420
|
+
return recordScanFailure("syncAll", err2);
|
|
58421
|
+
}
|
|
58422
|
+
try {
|
|
58259
58423
|
const listStartedAt = Date.now();
|
|
58260
58424
|
conversations = await agent.client.conversations.list({
|
|
58261
58425
|
consentStates: [import_node_bindings2.ConsentState.Allowed, import_node_bindings2.ConsentState.Unknown]
|
|
@@ -58263,18 +58427,11 @@ var init_xmtp_sdk = __esm({
|
|
|
58263
58427
|
summary.listMs = Date.now() - listStartedAt;
|
|
58264
58428
|
summary.conversations = conversations.length;
|
|
58265
58429
|
} catch (err2) {
|
|
58266
|
-
|
|
58267
|
-
logger.error(
|
|
58268
|
-
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
58269
|
-
err2 instanceof Error ? err2 : void 0,
|
|
58270
|
-
{
|
|
58271
|
-
walletAddress: address,
|
|
58272
|
-
stage: "syncAll/list"
|
|
58273
|
-
}
|
|
58274
|
-
);
|
|
58275
|
-
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58276
|
-
return summary;
|
|
58430
|
+
return recordScanFailure("list", err2);
|
|
58277
58431
|
}
|
|
58432
|
+
const recoveredFailure = this.replayScanFailuresByAddress.get(addressKey);
|
|
58433
|
+
this.replayScanFailuresByAddress.delete(addressKey);
|
|
58434
|
+
this.clearReplayScanRetry(address);
|
|
58278
58435
|
for (const conv of conversations) {
|
|
58279
58436
|
try {
|
|
58280
58437
|
const messagesStartedAt = Date.now();
|
|
@@ -58416,8 +58573,15 @@ var init_xmtp_sdk = __esm({
|
|
|
58416
58573
|
replayed: String(summary.replayed),
|
|
58417
58574
|
skipped: String(summary.skipped),
|
|
58418
58575
|
conversationCount: String(summary.conversations),
|
|
58419
|
-
durationMs: String(Date.now() - addressReplayStartedAt)
|
|
58576
|
+
durationMs: String(Date.now() - addressReplayStartedAt),
|
|
58577
|
+
outcome: "success",
|
|
58578
|
+
replayOutcome: "completed",
|
|
58579
|
+
recoveredAfterFailures: String(recoveredFailure?.consecutiveFailures ?? 0),
|
|
58580
|
+
suppressedAttempts: String(recoveredFailure?.suppressedAttempts ?? 0)
|
|
58420
58581
|
});
|
|
58582
|
+
summary.outcome = "completed";
|
|
58583
|
+
summary.consecutiveFailures = recoveredFailure?.consecutiveFailures;
|
|
58584
|
+
summary.suppressedAttempts = recoveredFailure?.suppressedAttempts;
|
|
58421
58585
|
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58422
58586
|
const newestSyncMs = this.syncByAddress.get(address) ?? lastSyncMs;
|
|
58423
58587
|
logWithTimestamp(
|
|
@@ -67106,12 +67270,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
67106
67270
|
});
|
|
67107
67271
|
}
|
|
67108
67272
|
});
|
|
67109
|
-
service.setPluginVersion("0.2.3
|
|
67273
|
+
service.setPluginVersion("0.2.3");
|
|
67110
67274
|
await service.init();
|
|
67111
67275
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
67112
67276
|
if (pluginVersionStatus.unavailable) {
|
|
67113
67277
|
throw new Error(
|
|
67114
|
-
`@okxweb3/a2a-node v${"0.2.3
|
|
67278
|
+
`@okxweb3/a2a-node v${"0.2.3"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
67115
67279
|
);
|
|
67116
67280
|
}
|
|
67117
67281
|
const systemConfig = service.getSystemConfig();
|
|
@@ -67129,7 +67293,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
67129
67293
|
onchainosAgentId: "*",
|
|
67130
67294
|
reason: "system-config missing sentryDsn",
|
|
67131
67295
|
pluginId: "@okxweb3/a2a-node",
|
|
67132
|
-
pluginVersion: "0.2.3
|
|
67296
|
+
pluginVersion: "0.2.3"
|
|
67133
67297
|
});
|
|
67134
67298
|
}
|
|
67135
67299
|
logWithTimestamp(
|
|
@@ -115316,7 +115480,7 @@ async function getCurrentNodeCliVersion() {
|
|
|
115316
115480
|
return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
|
|
115317
115481
|
}
|
|
115318
115482
|
function getBundledNodeCliVersion() {
|
|
115319
|
-
return true ? "0.2.3
|
|
115483
|
+
return true ? "0.2.3" : null;
|
|
115320
115484
|
}
|
|
115321
115485
|
function readConfiguredAiProvider() {
|
|
115322
115486
|
const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
|
|
@@ -115526,7 +115690,7 @@ async function updateHermes(release, options) {
|
|
|
115526
115690
|
}
|
|
115527
115691
|
}
|
|
115528
115692
|
async function installGatewayPluginForDoctor(target) {
|
|
115529
|
-
const release = isPrereleaseVersion("0.2.3
|
|
115693
|
+
const release = isPrereleaseVersion("0.2.3") ? "beta" : "latest";
|
|
115530
115694
|
const insideTargetGateway = detectGatewayInvocation() === target;
|
|
115531
115695
|
const options = {
|
|
115532
115696
|
restart: !insideTargetGateway,
|
|
@@ -116569,7 +116733,7 @@ async function runDoctor(options = {}) {
|
|
|
116569
116733
|
platform: options.platform ?? process.platform,
|
|
116570
116734
|
env: options.env ?? process.env,
|
|
116571
116735
|
target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
|
|
116572
|
-
cliVersion: options.cliVersion ?? (true ? "0.2.3
|
|
116736
|
+
cliVersion: options.cliVersion ?? (true ? "0.2.3" : "0.0.0"),
|
|
116573
116737
|
fixMode: options.fix === true,
|
|
116574
116738
|
nonInteractive: options.nonInteractive === true,
|
|
116575
116739
|
packageChanged: false,
|
|
@@ -117566,7 +117730,7 @@ init_sentry_logger();
|
|
|
117566
117730
|
init_sentry_config();
|
|
117567
117731
|
var CURRENT_GATEWAY_SESSION_KEYS_ENV4 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
|
|
117568
117732
|
function printUsage3() {
|
|
117569
|
-
console.log(`okx-a2a ${"0.2.3
|
|
117733
|
+
console.log(`okx-a2a ${"0.2.3"}
|
|
117570
117734
|
|
|
117571
117735
|
Usage:
|
|
117572
117736
|
okx-a2a <command> [options]
|
|
@@ -117606,7 +117770,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
|
|
|
117606
117770
|
`);
|
|
117607
117771
|
}
|
|
117608
117772
|
function printVersion() {
|
|
117609
|
-
console.log("0.2.3
|
|
117773
|
+
console.log("0.2.3");
|
|
117610
117774
|
}
|
|
117611
117775
|
function printDaemonUsage() {
|
|
117612
117776
|
console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
|
|
@@ -119042,7 +119206,7 @@ async function main() {
|
|
|
119042
119206
|
if (command === "xmtp-test") {
|
|
119043
119207
|
const { handleXmtpTestCommand: handleXmtpTestCommand2 } = await Promise.resolve().then(() => (init_xmtp_test_cli(), xmtp_test_cli_exports));
|
|
119044
119208
|
await handleXmtpTestCommand2(process.argv.slice(3), {
|
|
119045
|
-
packageVersion: "0.2.3
|
|
119209
|
+
packageVersion: "0.2.3",
|
|
119046
119210
|
agentSdkVersion: "2.3.0",
|
|
119047
119211
|
nodeSdkVersion: "6.1.0",
|
|
119048
119212
|
nodeBindingsVersion: "1.11.0"
|
package/dist/index.js
CHANGED
|
@@ -19446,7 +19446,15 @@ function classifyError(error, code) {
|
|
|
19446
19446
|
if (normalizedCode === "ABORT_ERR" || name === "aborterror") {
|
|
19447
19447
|
return "cancelled";
|
|
19448
19448
|
}
|
|
19449
|
-
if (name === "syntaxerror"
|
|
19449
|
+
if (name === "syntaxerror") {
|
|
19450
|
+
return "invalid_response";
|
|
19451
|
+
}
|
|
19452
|
+
if (/connection\s+(?:reset|closed|interrupted)|broken\s+pipe|unexpected\s+eof/.test(
|
|
19453
|
+
message
|
|
19454
|
+
)) {
|
|
19455
|
+
return "connection_interrupted";
|
|
19456
|
+
}
|
|
19457
|
+
if (/(?:json|response).*(?:parse|invalid)/.test(message)) {
|
|
19450
19458
|
return "invalid_response";
|
|
19451
19459
|
}
|
|
19452
19460
|
if (/session\s+(?:is\s+)?expired|login\s+expired/.test(message)) {
|
|
@@ -19743,6 +19751,7 @@ var init_sentry_logger = __esm({
|
|
|
19743
19751
|
"releaseBase",
|
|
19744
19752
|
"releaseChannel",
|
|
19745
19753
|
"releaseCode",
|
|
19754
|
+
"replayOutcome",
|
|
19746
19755
|
"role",
|
|
19747
19756
|
"runId",
|
|
19748
19757
|
"runtimeContainer",
|
|
@@ -32095,7 +32104,7 @@ var init_sentry_config = __esm({
|
|
|
32095
32104
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
32096
32105
|
SENTRY_CONFIG = {
|
|
32097
32106
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
32098
|
-
release: "0.2.3
|
|
32107
|
+
release: "0.2.3",
|
|
32099
32108
|
environment,
|
|
32100
32109
|
runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
|
|
32101
32110
|
};
|
|
@@ -33036,7 +33045,7 @@ async function getCurrentNodeCliVersion() {
|
|
|
33036
33045
|
return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
|
|
33037
33046
|
}
|
|
33038
33047
|
function getBundledNodeCliVersion() {
|
|
33039
|
-
return true ? "0.2.3
|
|
33048
|
+
return true ? "0.2.3" : null;
|
|
33040
33049
|
}
|
|
33041
33050
|
function readConfiguredAiProvider() {
|
|
33042
33051
|
const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
|
|
@@ -33246,7 +33255,7 @@ async function updateHermes(release, options) {
|
|
|
33246
33255
|
}
|
|
33247
33256
|
}
|
|
33248
33257
|
async function installGatewayPluginForDoctor(target) {
|
|
33249
|
-
const release = isPrereleaseVersion("0.2.3
|
|
33258
|
+
const release = isPrereleaseVersion("0.2.3") ? "beta" : "latest";
|
|
33250
33259
|
const insideTargetGateway = detectGatewayInvocation() === target;
|
|
33251
33260
|
const options = {
|
|
33252
33261
|
restart: !insideTargetGateway,
|
|
@@ -44118,6 +44127,7 @@ __export(index_exports, {
|
|
|
44118
44127
|
registerUserAttentionWatcher: () => registerUserAttentionWatcher,
|
|
44119
44128
|
releaseActiveDaemon: () => releaseActiveDaemon,
|
|
44120
44129
|
removeUserAttentionWatcher: () => removeUserAttentionWatcher,
|
|
44130
|
+
replayScanBackoffMs: () => replayScanBackoffMs,
|
|
44121
44131
|
reportDoctorRunToSentry: () => reportDoctorRunToSentry,
|
|
44122
44132
|
reportUserNotificationFailure: () => reportUserNotificationFailure,
|
|
44123
44133
|
resetMessageEligibleOfflineReplayCapabilityForTests: () => resetMessageEligibleOfflineReplayCapabilityForTests,
|
|
@@ -55859,6 +55869,8 @@ function compareTimestamp(a, b) {
|
|
|
55859
55869
|
var DEFAULT_DATA_DIR = resolveA2aTaskPaths().xmtpDir;
|
|
55860
55870
|
var XMTP_INSTALLATION_WARNING_THRESHOLD = 2;
|
|
55861
55871
|
var XMTP_INSTALLATION_NEAR_LIMIT_THRESHOLD = 8;
|
|
55872
|
+
var REPLAY_SCAN_INITIAL_BACKOFF_MS = 3e4;
|
|
55873
|
+
var REPLAY_SCAN_MAX_BACKOFF_MS = 5 * 6e4;
|
|
55862
55874
|
function cachePath(dataDir, fileName) {
|
|
55863
55875
|
return (0, import_node_path21.join)(dataDir, fileName);
|
|
55864
55876
|
}
|
|
@@ -56343,6 +56355,13 @@ function parseGroupPayload(content) {
|
|
|
56343
56355
|
return null;
|
|
56344
56356
|
}
|
|
56345
56357
|
}
|
|
56358
|
+
function replayScanBackoffMs(consecutiveFailures) {
|
|
56359
|
+
const exponent = Math.max(0, Math.floor(consecutiveFailures) - 1);
|
|
56360
|
+
return Math.min(
|
|
56361
|
+
REPLAY_SCAN_INITIAL_BACKOFF_MS * 2 ** exponent,
|
|
56362
|
+
REPLAY_SCAN_MAX_BACKOFF_MS
|
|
56363
|
+
);
|
|
56364
|
+
}
|
|
56346
56365
|
function isOfflineReplayForTrigger(trigger) {
|
|
56347
56366
|
return trigger === "startup";
|
|
56348
56367
|
}
|
|
@@ -56378,6 +56397,11 @@ var XmtpService = class _XmtpService {
|
|
|
56378
56397
|
dataDir = DEFAULT_DATA_DIR;
|
|
56379
56398
|
syncByAddress = /* @__PURE__ */ new Map();
|
|
56380
56399
|
offlineReplaySingleFlight = new KeyedSingleFlight();
|
|
56400
|
+
replayScanFailuresByAddress = /* @__PURE__ */ new Map();
|
|
56401
|
+
replayScanRetryByAddress = /* @__PURE__ */ new Map();
|
|
56402
|
+
replayScanNowMs = () => Date.now();
|
|
56403
|
+
replayScanSetTimeout = (callback, delayMs) => setTimeout(callback, delayMs);
|
|
56404
|
+
replayScanClearTimeout = (timer) => clearTimeout(timer);
|
|
56381
56405
|
inboundReplayGates = /* @__PURE__ */ new Map();
|
|
56382
56406
|
streamRecoveryCleanupByAddress = /* @__PURE__ */ new Map();
|
|
56383
56407
|
nextClientGeneration = 1;
|
|
@@ -56856,6 +56880,8 @@ var XmtpService = class _XmtpService {
|
|
|
56856
56880
|
}
|
|
56857
56881
|
this.clients.delete(address);
|
|
56858
56882
|
this.inboundReplayGates.delete(address.toLowerCase());
|
|
56883
|
+
this.replayScanFailuresByAddress.delete(address.toLowerCase());
|
|
56884
|
+
this.clearReplayScanRetry(address);
|
|
56859
56885
|
logger.info(LogEvent.AGENT_CLIENT_REMOVED, {
|
|
56860
56886
|
...agentExtras({
|
|
56861
56887
|
walletAddress: address,
|
|
@@ -57070,6 +57096,8 @@ var XmtpService = class _XmtpService {
|
|
|
57070
57096
|
await Promise.resolve(oldClient.stop());
|
|
57071
57097
|
this.clients.delete(address);
|
|
57072
57098
|
this.inboundReplayGates.delete(addressKey);
|
|
57099
|
+
this.replayScanFailuresByAddress.delete(addressKey);
|
|
57100
|
+
this.clearReplayScanRetry(address);
|
|
57073
57101
|
logWithTimestamp(
|
|
57074
57102
|
`[xmtp-sdk] recycle: stopped client: ${address} (agentId=${agentInfo.agentId})`
|
|
57075
57103
|
);
|
|
@@ -57619,6 +57647,60 @@ var XmtpService = class _XmtpService {
|
|
|
57619
57647
|
this.clientGenerationByClient.set(client, generation);
|
|
57620
57648
|
return generation;
|
|
57621
57649
|
}
|
|
57650
|
+
clearReplayScanRetry(address) {
|
|
57651
|
+
const addressKey = address.toLowerCase();
|
|
57652
|
+
const scheduled = this.replayScanRetryByAddress.get(addressKey);
|
|
57653
|
+
if (!scheduled) {
|
|
57654
|
+
return;
|
|
57655
|
+
}
|
|
57656
|
+
this.replayScanRetryByAddress.delete(addressKey);
|
|
57657
|
+
this.replayScanClearTimeout(scheduled.timer);
|
|
57658
|
+
}
|
|
57659
|
+
scheduleReplayScanRetry(address, expectedClient, clientGeneration, retryTrigger, delayMs) {
|
|
57660
|
+
const addressKey = address.toLowerCase();
|
|
57661
|
+
const scheduled = this.replayScanRetryByAddress.get(addressKey);
|
|
57662
|
+
if (scheduled?.clientGeneration === clientGeneration) {
|
|
57663
|
+
return;
|
|
57664
|
+
}
|
|
57665
|
+
if (scheduled) {
|
|
57666
|
+
this.clearReplayScanRetry(address);
|
|
57667
|
+
}
|
|
57668
|
+
const timer = this.replayScanSetTimeout(() => {
|
|
57669
|
+
const current = this.replayScanRetryByAddress.get(addressKey);
|
|
57670
|
+
if (current?.timer !== timer) {
|
|
57671
|
+
return;
|
|
57672
|
+
}
|
|
57673
|
+
this.replayScanRetryByAddress.delete(addressKey);
|
|
57674
|
+
if (this.clients.get(address) !== expectedClient || this.stoppedAddresses.has(addressKey)) {
|
|
57675
|
+
return;
|
|
57676
|
+
}
|
|
57677
|
+
void this.replayOfflineMessagesForAddressSingleFlight(
|
|
57678
|
+
address,
|
|
57679
|
+
retryTrigger,
|
|
57680
|
+
void 0,
|
|
57681
|
+
expectedClient
|
|
57682
|
+
).catch((err) => {
|
|
57683
|
+
logWithTimestamp(
|
|
57684
|
+
`[xmtp-sdk:replay:${address}] scheduled replay scan retry failed:`,
|
|
57685
|
+
err
|
|
57686
|
+
);
|
|
57687
|
+
logger.error(
|
|
57688
|
+
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
57689
|
+
err instanceof Error ? err : new Error(String(err)),
|
|
57690
|
+
{
|
|
57691
|
+
walletAddress: address,
|
|
57692
|
+
stage: "offlineReplay/scheduledRetry",
|
|
57693
|
+
outcome: "failed"
|
|
57694
|
+
}
|
|
57695
|
+
);
|
|
57696
|
+
});
|
|
57697
|
+
}, Math.max(0, delayMs));
|
|
57698
|
+
timer.unref?.();
|
|
57699
|
+
this.replayScanRetryByAddress.set(addressKey, {
|
|
57700
|
+
clientGeneration,
|
|
57701
|
+
timer
|
|
57702
|
+
});
|
|
57703
|
+
}
|
|
57622
57704
|
notifyAgentsWakeupAfterReplay() {
|
|
57623
57705
|
const notifyAgentsWakeup2 = this.tools.notifyAgentsWakeup;
|
|
57624
57706
|
const agentIds = this.allAgents.map((agent) => agent.agentId);
|
|
@@ -57857,7 +57939,7 @@ var XmtpService = class _XmtpService {
|
|
|
57857
57939
|
String(recovery.recoverySequence),
|
|
57858
57940
|
agent
|
|
57859
57941
|
);
|
|
57860
|
-
if (!recoveryDisposed && this.clients.get(address) === agent) {
|
|
57942
|
+
if (summary.outcome === "completed" && !recoveryDisposed && this.clients.get(address) === agent) {
|
|
57861
57943
|
logger.info(LogEvent.AGENT_STREAM_RECOVERY_REPLAY_COMPLETED, {
|
|
57862
57944
|
...agentExtras(identity),
|
|
57863
57945
|
clientGeneration: String(clientGeneration),
|
|
@@ -57865,7 +57947,9 @@ var XmtpService = class _XmtpService {
|
|
|
57865
57947
|
replayed: String(summary.replayed),
|
|
57866
57948
|
skipped: String(summary.skipped),
|
|
57867
57949
|
conversationCount: String(summary.conversations),
|
|
57868
|
-
replayDurationMs: String(summary.durationMs)
|
|
57950
|
+
replayDurationMs: String(summary.durationMs),
|
|
57951
|
+
outcome: "success",
|
|
57952
|
+
replayOutcome: summary.outcome
|
|
57869
57953
|
});
|
|
57870
57954
|
}
|
|
57871
57955
|
} catch (err) {
|
|
@@ -57931,10 +58015,6 @@ var XmtpService = class _XmtpService {
|
|
|
57931
58015
|
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
57932
58016
|
return summary;
|
|
57933
58017
|
}
|
|
57934
|
-
const sentAfterNs = BigInt(lastSyncMs) * 1000000n;
|
|
57935
|
-
logWithTimestamp(
|
|
57936
|
-
`${tag} offline_replay_start agentId=${this.getAgentByAddress(address)?.agentId ?? ""} address=${address} since=${formatLogTimestamp2(lastSyncMs)} sinceMs=${lastSyncMs}`
|
|
57937
|
-
);
|
|
57938
58018
|
const myInboxId = agent.client.inboxId;
|
|
57939
58019
|
const handlerDeps = {
|
|
57940
58020
|
myXmtpAddress: address,
|
|
@@ -57949,7 +58029,87 @@ var XmtpService = class _XmtpService {
|
|
|
57949
58029
|
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
57950
58030
|
return summary;
|
|
57951
58031
|
}
|
|
58032
|
+
const addressKey = address.toLowerCase();
|
|
58033
|
+
const clientGeneration = this.getClientGeneration(agent);
|
|
58034
|
+
const attemptNowMs = this.replayScanNowMs();
|
|
58035
|
+
let priorFailure = this.replayScanFailuresByAddress.get(addressKey);
|
|
58036
|
+
if (priorFailure && priorFailure.clientGeneration !== clientGeneration) {
|
|
58037
|
+
this.replayScanFailuresByAddress.delete(addressKey);
|
|
58038
|
+
this.clearReplayScanRetry(address);
|
|
58039
|
+
priorFailure = void 0;
|
|
58040
|
+
}
|
|
58041
|
+
if (priorFailure && attemptNowMs < priorFailure.nextAttemptAtMs) {
|
|
58042
|
+
priorFailure.suppressedAttempts++;
|
|
58043
|
+
summary.outcome = "suppressed_backoff";
|
|
58044
|
+
summary.failureStage = priorFailure.lastFailureStage;
|
|
58045
|
+
summary.consecutiveFailures = priorFailure.consecutiveFailures;
|
|
58046
|
+
summary.backoffMs = priorFailure.nextAttemptAtMs - attemptNowMs;
|
|
58047
|
+
summary.suppressedAttempts = priorFailure.suppressedAttempts;
|
|
58048
|
+
if (priorFailure.suppressedAttempts === 1) {
|
|
58049
|
+
logWithTimestamp(
|
|
58050
|
+
`${tag} replay scan suppressed stage=${priorFailure.lastFailureStage} consecutiveFailures=${priorFailure.consecutiveFailures} retryInMs=${summary.backoffMs}`
|
|
58051
|
+
);
|
|
58052
|
+
}
|
|
58053
|
+
this.scheduleReplayScanRetry(
|
|
58054
|
+
address,
|
|
58055
|
+
agent,
|
|
58056
|
+
clientGeneration,
|
|
58057
|
+
priorFailure.retryTrigger,
|
|
58058
|
+
summary.backoffMs
|
|
58059
|
+
);
|
|
58060
|
+
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58061
|
+
return summary;
|
|
58062
|
+
}
|
|
58063
|
+
const sentAfterNs = BigInt(lastSyncMs) * 1000000n;
|
|
58064
|
+
logWithTimestamp(
|
|
58065
|
+
`${tag} offline_replay_start agentId=${this.getAgentByAddress(address)?.agentId ?? ""} address=${address} since=${formatLogTimestamp2(lastSyncMs)} sinceMs=${lastSyncMs}`
|
|
58066
|
+
);
|
|
57952
58067
|
let conversations;
|
|
58068
|
+
const recordScanFailure = (stage, err) => {
|
|
58069
|
+
const previous = this.replayScanFailuresByAddress.get(addressKey);
|
|
58070
|
+
const consecutiveFailures = (previous?.consecutiveFailures ?? 0) + 1;
|
|
58071
|
+
const backoffMs = replayScanBackoffMs(consecutiveFailures);
|
|
58072
|
+
const suppressedAttempts = previous?.suppressedAttempts ?? 0;
|
|
58073
|
+
const failureNowMs = this.replayScanNowMs();
|
|
58074
|
+
const retryTrigger = isOfflineReplayForTrigger(trigger) ? "startup" : "periodic_repair";
|
|
58075
|
+
this.replayScanFailuresByAddress.set(addressKey, {
|
|
58076
|
+
clientGeneration,
|
|
58077
|
+
consecutiveFailures,
|
|
58078
|
+
nextAttemptAtMs: failureNowMs + backoffMs,
|
|
58079
|
+
retryTrigger,
|
|
58080
|
+
suppressedAttempts: 0,
|
|
58081
|
+
lastFailureStage: stage
|
|
58082
|
+
});
|
|
58083
|
+
this.scheduleReplayScanRetry(
|
|
58084
|
+
address,
|
|
58085
|
+
agent,
|
|
58086
|
+
clientGeneration,
|
|
58087
|
+
retryTrigger,
|
|
58088
|
+
backoffMs
|
|
58089
|
+
);
|
|
58090
|
+
summary.outcome = stage === "syncAll" ? "sync_failed" : "list_failed";
|
|
58091
|
+
summary.failureStage = stage;
|
|
58092
|
+
summary.consecutiveFailures = consecutiveFailures;
|
|
58093
|
+
summary.backoffMs = backoffMs;
|
|
58094
|
+
summary.suppressedAttempts = suppressedAttempts;
|
|
58095
|
+
logWithTimestamp(`${tag} conversation ${stage} failed, backing off:`, err);
|
|
58096
|
+
logger.error(
|
|
58097
|
+
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
58098
|
+
err instanceof Error ? err : void 0,
|
|
58099
|
+
{
|
|
58100
|
+
walletAddress: address,
|
|
58101
|
+
stage: `offlineReplay/${stage}`,
|
|
58102
|
+
trigger,
|
|
58103
|
+
outcome: "failed",
|
|
58104
|
+
replayOutcome: summary.outcome,
|
|
58105
|
+
consecutiveFailures: String(consecutiveFailures),
|
|
58106
|
+
backoffMs: String(backoffMs),
|
|
58107
|
+
suppressedAttempts: String(suppressedAttempts)
|
|
58108
|
+
}
|
|
58109
|
+
);
|
|
58110
|
+
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58111
|
+
return summary;
|
|
58112
|
+
};
|
|
57953
58113
|
try {
|
|
57954
58114
|
const syncAllStartedAt = Date.now();
|
|
57955
58115
|
await agent.client.conversations.syncAll([
|
|
@@ -57957,6 +58117,10 @@ var XmtpService = class _XmtpService {
|
|
|
57957
58117
|
import_node_bindings2.ConsentState.Unknown
|
|
57958
58118
|
]);
|
|
57959
58119
|
summary.syncAllMs = Date.now() - syncAllStartedAt;
|
|
58120
|
+
} catch (err) {
|
|
58121
|
+
return recordScanFailure("syncAll", err);
|
|
58122
|
+
}
|
|
58123
|
+
try {
|
|
57960
58124
|
const listStartedAt = Date.now();
|
|
57961
58125
|
conversations = await agent.client.conversations.list({
|
|
57962
58126
|
consentStates: [import_node_bindings2.ConsentState.Allowed, import_node_bindings2.ConsentState.Unknown]
|
|
@@ -57964,18 +58128,11 @@ var XmtpService = class _XmtpService {
|
|
|
57964
58128
|
summary.listMs = Date.now() - listStartedAt;
|
|
57965
58129
|
summary.conversations = conversations.length;
|
|
57966
58130
|
} catch (err) {
|
|
57967
|
-
|
|
57968
|
-
logger.error(
|
|
57969
|
-
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
57970
|
-
err instanceof Error ? err : void 0,
|
|
57971
|
-
{
|
|
57972
|
-
walletAddress: address,
|
|
57973
|
-
stage: "syncAll/list"
|
|
57974
|
-
}
|
|
57975
|
-
);
|
|
57976
|
-
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
57977
|
-
return summary;
|
|
58131
|
+
return recordScanFailure("list", err);
|
|
57978
58132
|
}
|
|
58133
|
+
const recoveredFailure = this.replayScanFailuresByAddress.get(addressKey);
|
|
58134
|
+
this.replayScanFailuresByAddress.delete(addressKey);
|
|
58135
|
+
this.clearReplayScanRetry(address);
|
|
57979
58136
|
for (const conv of conversations) {
|
|
57980
58137
|
try {
|
|
57981
58138
|
const messagesStartedAt = Date.now();
|
|
@@ -58117,8 +58274,15 @@ var XmtpService = class _XmtpService {
|
|
|
58117
58274
|
replayed: String(summary.replayed),
|
|
58118
58275
|
skipped: String(summary.skipped),
|
|
58119
58276
|
conversationCount: String(summary.conversations),
|
|
58120
|
-
durationMs: String(Date.now() - addressReplayStartedAt)
|
|
58277
|
+
durationMs: String(Date.now() - addressReplayStartedAt),
|
|
58278
|
+
outcome: "success",
|
|
58279
|
+
replayOutcome: "completed",
|
|
58280
|
+
recoveredAfterFailures: String(recoveredFailure?.consecutiveFailures ?? 0),
|
|
58281
|
+
suppressedAttempts: String(recoveredFailure?.suppressedAttempts ?? 0)
|
|
58121
58282
|
});
|
|
58283
|
+
summary.outcome = "completed";
|
|
58284
|
+
summary.consecutiveFailures = recoveredFailure?.consecutiveFailures;
|
|
58285
|
+
summary.suppressedAttempts = recoveredFailure?.suppressedAttempts;
|
|
58122
58286
|
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
58123
58287
|
const newestSyncMs = this.syncByAddress.get(address) ?? lastSyncMs;
|
|
58124
58288
|
logWithTimestamp(
|
|
@@ -58185,6 +58349,7 @@ var XmtpService = class _XmtpService {
|
|
|
58185
58349
|
function createOfflineReplayAddressSummary(address) {
|
|
58186
58350
|
return {
|
|
58187
58351
|
address,
|
|
58352
|
+
outcome: "skipped",
|
|
58188
58353
|
replayed: 0,
|
|
58189
58354
|
skipped: 0,
|
|
58190
58355
|
conversations: 0,
|
|
@@ -60016,7 +60181,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
60016
60181
|
client: {
|
|
60017
60182
|
id: "gateway-client",
|
|
60018
60183
|
displayName: "okx-a2a-node",
|
|
60019
|
-
version: "0.2.3
|
|
60184
|
+
version: "0.2.3",
|
|
60020
60185
|
platform: "node",
|
|
60021
60186
|
mode: "backend",
|
|
60022
60187
|
instanceId
|
|
@@ -60027,7 +60192,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
60027
60192
|
commands: [],
|
|
60028
60193
|
permissions: {},
|
|
60029
60194
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
60030
|
-
userAgent: `okx-a2a-node/${"0.2.3
|
|
60195
|
+
userAgent: `okx-a2a-node/${"0.2.3"}`,
|
|
60031
60196
|
auth: {
|
|
60032
60197
|
...config.token ? { token: config.token } : {},
|
|
60033
60198
|
...config.password ? { password: config.password } : {}
|
|
@@ -66066,12 +66231,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
66066
66231
|
});
|
|
66067
66232
|
}
|
|
66068
66233
|
});
|
|
66069
|
-
service.setPluginVersion("0.2.3
|
|
66234
|
+
service.setPluginVersion("0.2.3");
|
|
66070
66235
|
await service.init();
|
|
66071
66236
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
66072
66237
|
if (pluginVersionStatus.unavailable) {
|
|
66073
66238
|
throw new Error(
|
|
66074
|
-
`@okxweb3/a2a-node v${"0.2.3
|
|
66239
|
+
`@okxweb3/a2a-node v${"0.2.3"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
66075
66240
|
);
|
|
66076
66241
|
}
|
|
66077
66242
|
const systemConfig = service.getSystemConfig();
|
|
@@ -66089,7 +66254,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
66089
66254
|
onchainosAgentId: "*",
|
|
66090
66255
|
reason: "system-config missing sentryDsn",
|
|
66091
66256
|
pluginId: "@okxweb3/a2a-node",
|
|
66092
|
-
pluginVersion: "0.2.3
|
|
66257
|
+
pluginVersion: "0.2.3"
|
|
66093
66258
|
});
|
|
66094
66259
|
}
|
|
66095
66260
|
logWithTimestamp(
|
|
@@ -68735,7 +68900,7 @@ async function exportDiagnosticLogs(options) {
|
|
|
68735
68900
|
node: process.version,
|
|
68736
68901
|
platform: process.platform,
|
|
68737
68902
|
arch: process.arch,
|
|
68738
|
-
packageVersion: true ? "0.2.3
|
|
68903
|
+
packageVersion: true ? "0.2.3" : "unknown",
|
|
68739
68904
|
sensitiveContentIncluded: options.includeSensitiveContent,
|
|
68740
68905
|
listenerAndLlmContentIncluded: true,
|
|
68741
68906
|
credentialsAlwaysRedacted: true,
|
|
@@ -70571,7 +70736,7 @@ async function runDoctor(options = {}) {
|
|
|
70571
70736
|
platform: options.platform ?? process.platform,
|
|
70572
70737
|
env: options.env ?? process.env,
|
|
70573
70738
|
target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
|
|
70574
|
-
cliVersion: options.cliVersion ?? (true ? "0.2.3
|
|
70739
|
+
cliVersion: options.cliVersion ?? (true ? "0.2.3" : "0.0.0"),
|
|
70575
70740
|
fixMode: options.fix === true,
|
|
70576
70741
|
nonInteractive: options.nonInteractive === true,
|
|
70577
70742
|
packageChanged: false,
|
|
@@ -70975,6 +71140,7 @@ init_autostart_windows();
|
|
|
70975
71140
|
registerUserAttentionWatcher,
|
|
70976
71141
|
releaseActiveDaemon,
|
|
70977
71142
|
removeUserAttentionWatcher,
|
|
71143
|
+
replayScanBackoffMs,
|
|
70978
71144
|
reportDoctorRunToSentry,
|
|
70979
71145
|
reportUserNotificationFailure,
|
|
70980
71146
|
resetMessageEligibleOfflineReplayCapabilityForTests,
|
package/package.json
CHANGED