@okxweb3/a2a-node 0.2.4-beta-e7a52faf6f-260812104443 → 0.2.4
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 +348 -191
- package/dist/index.js +311 -188
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32104,7 +32104,7 @@ var init_sentry_config = __esm({
|
|
|
32104
32104
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
32105
32105
|
SENTRY_CONFIG = {
|
|
32106
32106
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
32107
|
-
release: "0.2.4
|
|
32107
|
+
release: "0.2.4",
|
|
32108
32108
|
environment,
|
|
32109
32109
|
runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
|
|
32110
32110
|
};
|
|
@@ -33045,7 +33045,7 @@ async function getCurrentNodeCliVersion() {
|
|
|
33045
33045
|
return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
|
|
33046
33046
|
}
|
|
33047
33047
|
function getBundledNodeCliVersion() {
|
|
33048
|
-
return true ? "0.2.4
|
|
33048
|
+
return true ? "0.2.4" : null;
|
|
33049
33049
|
}
|
|
33050
33050
|
function readConfiguredAiProvider() {
|
|
33051
33051
|
const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
|
|
@@ -33255,7 +33255,7 @@ async function updateHermes(release, options) {
|
|
|
33255
33255
|
}
|
|
33256
33256
|
}
|
|
33257
33257
|
async function installGatewayPluginForDoctor(target) {
|
|
33258
|
-
const release = isPrereleaseVersion("0.2.4
|
|
33258
|
+
const release = isPrereleaseVersion("0.2.4") ? "beta" : "latest";
|
|
33259
33259
|
const insideTargetGateway = detectGatewayInvocation() === target;
|
|
33260
33260
|
const options = {
|
|
33261
33261
|
restart: !insideTargetGateway,
|
|
@@ -43944,6 +43944,8 @@ var init_doctor_sentry = __esm({
|
|
|
43944
43944
|
// src/index.ts
|
|
43945
43945
|
var index_exports = {};
|
|
43946
43946
|
__export(index_exports, {
|
|
43947
|
+
AGENT_GET_PAGE_TIMEOUT_MS: () => AGENT_GET_PAGE_TIMEOUT_MS,
|
|
43948
|
+
AGENT_LIST_TIMEOUT_MS: () => AGENT_LIST_TIMEOUT_MS,
|
|
43947
43949
|
AI_PROVIDERS: () => AI_PROVIDERS,
|
|
43948
43950
|
AgentMessageDirection: () => AgentMessageDirection,
|
|
43949
43951
|
AgentRefreshAuthGate: () => AgentRefreshAuthGate,
|
|
@@ -43987,6 +43989,7 @@ __export(index_exports, {
|
|
|
43987
43989
|
USER_ATTENTION_WATCH_PARENT_CHECK_MS: () => USER_ATTENTION_WATCH_PARENT_CHECK_MS,
|
|
43988
43990
|
USER_ATTENTION_WATCH_REPLACED_MESSAGE: () => USER_ATTENTION_WATCH_REPLACED_MESSAGE,
|
|
43989
43991
|
UserCancelledAiProviderSelectionError: () => UserCancelledAiProviderSelectionError,
|
|
43992
|
+
WALLET_STATUS_TIMEOUT_MS: () => WALLET_STATUS_TIMEOUT_MS,
|
|
43990
43993
|
XMTP_CLIENT_RECYCLE_INTERVAL_ENV: () => XMTP_CLIENT_RECYCLE_INTERVAL_ENV,
|
|
43991
43994
|
XmtpDm: () => Dm,
|
|
43992
43995
|
XmtpGroup: () => Group,
|
|
@@ -44017,7 +44020,6 @@ __export(index_exports, {
|
|
|
44017
44020
|
buildLaunchdPlist: () => buildLaunchdPlist,
|
|
44018
44021
|
buildLauncherEntryJs: () => buildLauncherEntryJs,
|
|
44019
44022
|
buildMessageEligibleArgs: () => buildMessageEligibleArgs,
|
|
44020
|
-
buildPendingConversationBackupDispatch: () => buildPendingConversationBackupDispatch,
|
|
44021
44023
|
buildSchtasksCreateArgs: () => buildSchtasksCreateArgs,
|
|
44022
44024
|
buildSchtasksDeleteArgs: () => buildSchtasksDeleteArgs,
|
|
44023
44025
|
buildSchtasksEndArgs: () => buildSchtasksEndArgs,
|
|
@@ -44100,6 +44102,7 @@ __export(index_exports, {
|
|
|
44100
44102
|
isWindowsElevated: () => isWindowsElevated,
|
|
44101
44103
|
killProcessTree: () => killProcessTree,
|
|
44102
44104
|
launchdPlistHasCurrentRestartPolicy: () => launchdPlistHasCurrentRestartPolicy,
|
|
44105
|
+
listAllAgentsWithMetadata: () => listAllAgentsWithMetadata,
|
|
44103
44106
|
logWinCompat: () => logWinCompat,
|
|
44104
44107
|
logXmtpMessageSent: () => logXmtpMessageSent,
|
|
44105
44108
|
maybeRecommendOnchainosUpgrade: () => maybeRecommendOnchainosUpgrade,
|
|
@@ -44123,6 +44126,7 @@ __export(index_exports, {
|
|
|
44123
44126
|
printXmtpTestUsage: () => printXmtpTestUsage,
|
|
44124
44127
|
probeCodexAuthStatus: () => probeCodexAuthStatus,
|
|
44125
44128
|
processFileMessage: () => processFileMessage,
|
|
44129
|
+
queryWalletLoginStatus: () => queryWalletLoginStatus,
|
|
44126
44130
|
readAiProviderTimeoutMs: () => readAiProviderTimeoutMs,
|
|
44127
44131
|
readCachedCodexReadiness: () => readCachedCodexReadiness,
|
|
44128
44132
|
readLastLines: () => readLastLines,
|
|
@@ -44171,7 +44175,6 @@ __export(index_exports, {
|
|
|
44171
44175
|
scanUserAttentionWatchers: () => scanUserAttentionWatchers,
|
|
44172
44176
|
setOpenClawWebSocketFactoryForTests: () => setOpenClawWebSocketFactoryForTests,
|
|
44173
44177
|
shouldDelegateToSupervisor: () => shouldDelegateToSupervisor,
|
|
44174
|
-
shouldKeepInboundGroupPendingForBuyer: () => shouldKeepInboundGroupPendingForBuyer,
|
|
44175
44178
|
shouldRouteThroughWindowsShell: () => shouldRouteThroughWindowsShell,
|
|
44176
44179
|
spawnCompat: () => spawnCompat,
|
|
44177
44180
|
spawnSyncCompat: () => spawnSyncCompat,
|
|
@@ -55409,6 +55412,7 @@ var StreamRecoveryTelemetry = class {
|
|
|
55409
55412
|
}
|
|
55410
55413
|
markError(nowMs = Date.now()) {
|
|
55411
55414
|
if (this.activeRecovery) {
|
|
55415
|
+
this.activeRecovery.candidateStartedAtMs = void 0;
|
|
55412
55416
|
return {
|
|
55413
55417
|
recoverySequence: this.activeRecovery.sequence,
|
|
55414
55418
|
alreadyRecovering: true
|
|
@@ -55422,9 +55426,26 @@ var StreamRecoveryTelemetry = class {
|
|
|
55422
55426
|
if (!this.activeRecovery) {
|
|
55423
55427
|
return void 0;
|
|
55424
55428
|
}
|
|
55429
|
+
this.activeRecovery.candidateStartedAtMs = nowMs;
|
|
55430
|
+
return {
|
|
55431
|
+
recoverySequence: this.activeRecovery.sequence,
|
|
55432
|
+
candidateStartedAtMs: nowMs
|
|
55433
|
+
};
|
|
55434
|
+
}
|
|
55435
|
+
markStable(nowMs = Date.now()) {
|
|
55436
|
+
if (this.activeRecovery?.candidateStartedAtMs === void 0) {
|
|
55437
|
+
return void 0;
|
|
55438
|
+
}
|
|
55425
55439
|
const completed = {
|
|
55426
55440
|
recoverySequence: this.activeRecovery.sequence,
|
|
55427
|
-
recoveryDurationMs: Math.max(
|
|
55441
|
+
recoveryDurationMs: Math.max(
|
|
55442
|
+
0,
|
|
55443
|
+
this.activeRecovery.candidateStartedAtMs - this.activeRecovery.startedAtMs
|
|
55444
|
+
),
|
|
55445
|
+
recoveryConfirmationDurationMs: Math.max(
|
|
55446
|
+
0,
|
|
55447
|
+
nowMs - this.activeRecovery.startedAtMs
|
|
55448
|
+
)
|
|
55428
55449
|
};
|
|
55429
55450
|
this.activeRecovery = void 0;
|
|
55430
55451
|
return completed;
|
|
@@ -55433,9 +55454,12 @@ var StreamRecoveryTelemetry = class {
|
|
|
55433
55454
|
this.activeRecovery = void 0;
|
|
55434
55455
|
}
|
|
55435
55456
|
};
|
|
55457
|
+
function replayFlightDiscriminator(clientGeneration, isOfflineReplay) {
|
|
55458
|
+
return isOfflineReplay ? `startup_offline:${clientGeneration}` : `online_repair:${clientGeneration}`;
|
|
55459
|
+
}
|
|
55436
55460
|
var KeyedSingleFlight = class {
|
|
55437
55461
|
inFlight = /* @__PURE__ */ new Map();
|
|
55438
|
-
run(key, discriminator, operation) {
|
|
55462
|
+
run(key, discriminator, operation, options = {}) {
|
|
55439
55463
|
const normalizedKey = key.toLowerCase();
|
|
55440
55464
|
const state = this.inFlight.get(normalizedKey);
|
|
55441
55465
|
if (!state) {
|
|
@@ -55445,7 +55469,22 @@ var KeyedSingleFlight = class {
|
|
|
55445
55469
|
return active.promise;
|
|
55446
55470
|
}
|
|
55447
55471
|
if (state.active.discriminator === discriminator) {
|
|
55448
|
-
|
|
55472
|
+
if (!options.queueBehindActive) {
|
|
55473
|
+
return state.active.promise;
|
|
55474
|
+
}
|
|
55475
|
+
const queued2 = state.queued.find(
|
|
55476
|
+
(flight3) => flight3.discriminator === discriminator
|
|
55477
|
+
);
|
|
55478
|
+
if (queued2) {
|
|
55479
|
+
return queued2.promise;
|
|
55480
|
+
}
|
|
55481
|
+
const flight2 = createKeyedFlight(
|
|
55482
|
+
discriminator,
|
|
55483
|
+
operation,
|
|
55484
|
+
options.shouldRunAfterActive
|
|
55485
|
+
);
|
|
55486
|
+
state.queued.push(flight2);
|
|
55487
|
+
return flight2.promise;
|
|
55449
55488
|
}
|
|
55450
55489
|
const queued = state.queued.find(
|
|
55451
55490
|
(flight2) => flight2.discriminator === discriminator
|
|
@@ -55461,15 +55500,33 @@ var KeyedSingleFlight = class {
|
|
|
55461
55500
|
void Promise.resolve().then(flight.operation).then(
|
|
55462
55501
|
(value) => {
|
|
55463
55502
|
flight.resolve(value);
|
|
55464
|
-
this.
|
|
55503
|
+
this.advanceAfterSuccess(key, flight, value);
|
|
55465
55504
|
},
|
|
55466
55505
|
(error) => {
|
|
55467
55506
|
flight.reject(error);
|
|
55468
|
-
this.
|
|
55507
|
+
this.advanceAfterFailure(key, flight, error);
|
|
55469
55508
|
}
|
|
55470
55509
|
);
|
|
55471
55510
|
}
|
|
55472
|
-
|
|
55511
|
+
advanceAfterSuccess(key, completed, value) {
|
|
55512
|
+
const state = this.inFlight.get(key);
|
|
55513
|
+
if (state?.active !== completed) {
|
|
55514
|
+
return;
|
|
55515
|
+
}
|
|
55516
|
+
const next = state.queued.shift();
|
|
55517
|
+
if (!next) {
|
|
55518
|
+
this.inFlight.delete(key);
|
|
55519
|
+
return;
|
|
55520
|
+
}
|
|
55521
|
+
if (next.shouldRunAfterActive && !next.shouldRunAfterActive(value)) {
|
|
55522
|
+
next.resolve(value);
|
|
55523
|
+
this.advanceAfterSuccess(key, completed, value);
|
|
55524
|
+
return;
|
|
55525
|
+
}
|
|
55526
|
+
state.active = next;
|
|
55527
|
+
this.execute(key, next);
|
|
55528
|
+
}
|
|
55529
|
+
advanceAfterFailure(key, completed, error) {
|
|
55473
55530
|
const state = this.inFlight.get(key);
|
|
55474
55531
|
if (state?.active !== completed) {
|
|
55475
55532
|
return;
|
|
@@ -55479,18 +55536,30 @@ var KeyedSingleFlight = class {
|
|
|
55479
55536
|
this.inFlight.delete(key);
|
|
55480
55537
|
return;
|
|
55481
55538
|
}
|
|
55539
|
+
if (next.shouldRunAfterActive) {
|
|
55540
|
+
next.reject(error);
|
|
55541
|
+
this.advanceAfterFailure(key, completed, error);
|
|
55542
|
+
return;
|
|
55543
|
+
}
|
|
55482
55544
|
state.active = next;
|
|
55483
55545
|
this.execute(key, next);
|
|
55484
55546
|
}
|
|
55485
55547
|
};
|
|
55486
|
-
function createKeyedFlight(discriminator, operation) {
|
|
55548
|
+
function createKeyedFlight(discriminator, operation, shouldRunAfterActive) {
|
|
55487
55549
|
let resolve11;
|
|
55488
55550
|
let reject;
|
|
55489
55551
|
const promise = new Promise((resolvePromise, rejectPromise) => {
|
|
55490
55552
|
resolve11 = resolvePromise;
|
|
55491
55553
|
reject = rejectPromise;
|
|
55492
55554
|
});
|
|
55493
|
-
return {
|
|
55555
|
+
return {
|
|
55556
|
+
discriminator,
|
|
55557
|
+
operation,
|
|
55558
|
+
promise,
|
|
55559
|
+
resolve: resolve11,
|
|
55560
|
+
reject,
|
|
55561
|
+
shouldRunAfterActive
|
|
55562
|
+
};
|
|
55494
55563
|
}
|
|
55495
55564
|
|
|
55496
55565
|
// ../core/src/xmtp-sdk/extract-job-id.ts
|
|
@@ -56220,6 +56289,7 @@ var SYSTEM_CONFIG_DEFAULTS = {
|
|
|
56220
56289
|
}
|
|
56221
56290
|
};
|
|
56222
56291
|
var STREAM_RECOVERY_ALERT_THRESHOLD_MS = 3e4;
|
|
56292
|
+
var STREAM_RECOVERY_STABILITY_WINDOW_MS = 1e4;
|
|
56223
56293
|
var REPLAY_GATE_DRAIN_MAX_ATTEMPTS = 3;
|
|
56224
56294
|
var REPLAY_GATE_DRAIN_RETRY_DELAY_MS = 100;
|
|
56225
56295
|
var SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
|
@@ -56412,11 +56482,11 @@ function replayScanBackoffMs(consecutiveFailures) {
|
|
|
56412
56482
|
function isOfflineReplayForTrigger(trigger) {
|
|
56413
56483
|
return trigger === "startup";
|
|
56414
56484
|
}
|
|
56415
|
-
function replaySingleFlightDiscriminator(trigger, clientGeneration
|
|
56416
|
-
|
|
56417
|
-
|
|
56418
|
-
|
|
56419
|
-
|
|
56485
|
+
function replaySingleFlightDiscriminator(trigger, clientGeneration) {
|
|
56486
|
+
return replayFlightDiscriminator(
|
|
56487
|
+
clientGeneration,
|
|
56488
|
+
isOfflineReplayForTrigger(trigger)
|
|
56489
|
+
);
|
|
56420
56490
|
}
|
|
56421
56491
|
var XmtpService = class _XmtpService {
|
|
56422
56492
|
static instance = null;
|
|
@@ -56451,6 +56521,9 @@ var XmtpService = class _XmtpService {
|
|
|
56451
56521
|
replayScanClearTimeout = (timer) => clearTimeout(timer);
|
|
56452
56522
|
inboundReplayGates = /* @__PURE__ */ new Map();
|
|
56453
56523
|
streamRecoveryCleanupByAddress = /* @__PURE__ */ new Map();
|
|
56524
|
+
streamRecoverySetTimeout = (callback, delayMs) => setTimeout(callback, delayMs);
|
|
56525
|
+
streamRecoveryClearTimeout = (timer) => clearTimeout(timer);
|
|
56526
|
+
streamStartSetTimeout = (callback, delayMs) => setTimeout(callback, delayMs);
|
|
56454
56527
|
nextClientGeneration = 1;
|
|
56455
56528
|
clientGenerationByClient = /* @__PURE__ */ new WeakMap();
|
|
56456
56529
|
resolveStartupReplayCompletion;
|
|
@@ -57903,10 +57976,14 @@ var XmtpService = class _XmtpService {
|
|
|
57903
57976
|
}
|
|
57904
57977
|
const delay = BASE_DELAY_MS * 2 ** attempt;
|
|
57905
57978
|
logWithTimestamp(`${tag} reconnecting in ${delay}ms (attempt=${attempt + 1})`);
|
|
57906
|
-
|
|
57979
|
+
this.streamStartSetTimeout(
|
|
57980
|
+
() => void startWithRetry(attempt + 1),
|
|
57981
|
+
delay
|
|
57982
|
+
);
|
|
57907
57983
|
};
|
|
57908
57984
|
const streamRecovery = new StreamRecoveryTelemetry();
|
|
57909
57985
|
let recoveryTimeout;
|
|
57986
|
+
let recoveryStabilityTimeout;
|
|
57910
57987
|
let pendingRecoveryGate;
|
|
57911
57988
|
let recoveryDisposed = false;
|
|
57912
57989
|
this.cancelStreamRecoveryForAddress(address);
|
|
@@ -57914,9 +57991,13 @@ var XmtpService = class _XmtpService {
|
|
|
57914
57991
|
recoveryDisposed = true;
|
|
57915
57992
|
streamRecovery.cancel();
|
|
57916
57993
|
if (recoveryTimeout) {
|
|
57917
|
-
|
|
57994
|
+
this.streamRecoveryClearTimeout(recoveryTimeout);
|
|
57918
57995
|
recoveryTimeout = void 0;
|
|
57919
57996
|
}
|
|
57997
|
+
if (recoveryStabilityTimeout) {
|
|
57998
|
+
this.streamRecoveryClearTimeout(recoveryStabilityTimeout);
|
|
57999
|
+
recoveryStabilityTimeout = void 0;
|
|
58000
|
+
}
|
|
57920
58001
|
};
|
|
57921
58002
|
this.streamRecoveryCleanupByAddress.set(
|
|
57922
58003
|
addressKey,
|
|
@@ -57931,6 +58012,10 @@ var XmtpService = class _XmtpService {
|
|
|
57931
58012
|
logger.error(LogEvent.AGENT_UNHANDLED_ERROR, err, agentExtras(identity));
|
|
57932
58013
|
return;
|
|
57933
58014
|
}
|
|
58015
|
+
if (recoveryStabilityTimeout) {
|
|
58016
|
+
this.streamRecoveryClearTimeout(recoveryStabilityTimeout);
|
|
58017
|
+
recoveryStabilityTimeout = void 0;
|
|
58018
|
+
}
|
|
57934
58019
|
const recovery = streamRecovery.markError();
|
|
57935
58020
|
const errorTelemetry = extractStreamErrorTelemetry(err);
|
|
57936
58021
|
if (!recovery.alreadyRecovering) {
|
|
@@ -57945,10 +58030,11 @@ var XmtpService = class _XmtpService {
|
|
|
57945
58030
|
recoveryAlreadyActive: String(recovery.alreadyRecovering)
|
|
57946
58031
|
});
|
|
57947
58032
|
if (!recovery.alreadyRecovering) {
|
|
57948
|
-
recoveryTimeout =
|
|
58033
|
+
recoveryTimeout = this.streamRecoverySetTimeout(() => {
|
|
57949
58034
|
if (recoveryDisposed || this.clients.get(address) !== agent || this.stoppedAddresses.has(addressKey) || streamRecovery.activeSequence !== recovery.recoverySequence) {
|
|
57950
58035
|
return;
|
|
57951
58036
|
}
|
|
58037
|
+
recoveryTimeout = void 0;
|
|
57952
58038
|
logger.error(LogEvent.AGENT_STREAM_RECOVERY_TIMEOUT, void 0, {
|
|
57953
58039
|
...agentExtras(identity),
|
|
57954
58040
|
...errorTelemetry,
|
|
@@ -57957,6 +58043,22 @@ var XmtpService = class _XmtpService {
|
|
|
57957
58043
|
recoveryDurationMs: String(STREAM_RECOVERY_ALERT_THRESHOLD_MS),
|
|
57958
58044
|
thresholdMs: String(STREAM_RECOVERY_ALERT_THRESHOLD_MS)
|
|
57959
58045
|
});
|
|
58046
|
+
const timedOutGate = pendingRecoveryGate;
|
|
58047
|
+
pendingRecoveryGate = void 0;
|
|
58048
|
+
void this.drainInboundReplayGate(address, timedOutGate).catch(
|
|
58049
|
+
(drainError) => {
|
|
58050
|
+
logger.error(
|
|
58051
|
+
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
58052
|
+
drainError instanceof Error ? drainError : new Error(String(drainError)),
|
|
58053
|
+
{
|
|
58054
|
+
...agentExtras(identity),
|
|
58055
|
+
clientGeneration: String(clientGeneration),
|
|
58056
|
+
recoverySequence: String(recovery.recoverySequence),
|
|
58057
|
+
stage: "streamRecovery/timeout-drain-gate"
|
|
58058
|
+
}
|
|
58059
|
+
);
|
|
58060
|
+
}
|
|
58061
|
+
);
|
|
57960
58062
|
}, STREAM_RECOVERY_ALERT_THRESHOLD_MS);
|
|
57961
58063
|
}
|
|
57962
58064
|
});
|
|
@@ -57964,60 +58066,61 @@ var XmtpService = class _XmtpService {
|
|
|
57964
58066
|
if (recoveryDisposed || this.clients.get(address) !== agent || this.stoppedAddresses.has(addressKey)) {
|
|
57965
58067
|
return;
|
|
57966
58068
|
}
|
|
57967
|
-
const
|
|
57968
|
-
if (recoveryTimeout) {
|
|
57969
|
-
clearTimeout(recoveryTimeout);
|
|
57970
|
-
recoveryTimeout = void 0;
|
|
57971
|
-
}
|
|
58069
|
+
const candidate = streamRecovery.markStarted();
|
|
57972
58070
|
logWithTimestamp(
|
|
57973
58071
|
`${tag} agent stream started agentId=${identity.onchainosAgentId ?? "(unknown)"} inboxId=${identity.inboxId ?? "(unknown)"} role=${identity.role ?? "(unknown)"} consentStates=Allowed,Unknown lastSync=${formatLogTimestamp2(this.syncByAddress.get(address))}`
|
|
57974
58072
|
);
|
|
57975
|
-
if (
|
|
57976
|
-
|
|
57977
|
-
|
|
57978
|
-
|
|
57979
|
-
|
|
57980
|
-
|
|
57981
|
-
|
|
57982
|
-
|
|
57983
|
-
|
|
57984
|
-
|
|
57985
|
-
|
|
57986
|
-
|
|
57987
|
-
|
|
57988
|
-
|
|
57989
|
-
|
|
57990
|
-
|
|
57991
|
-
|
|
57992
|
-
|
|
57993
|
-
|
|
57994
|
-
|
|
57995
|
-
|
|
57996
|
-
|
|
57997
|
-
|
|
57998
|
-
|
|
57999
|
-
|
|
58000
|
-
|
|
58001
|
-
|
|
58002
|
-
|
|
58003
|
-
|
|
58004
|
-
|
|
58005
|
-
logWithTimestamp(`${tag} recovery offline replay failed:`, err);
|
|
58006
|
-
logger.error(
|
|
58007
|
-
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
58008
|
-
err instanceof Error ? err : new Error(String(err)),
|
|
58009
|
-
{
|
|
58010
|
-
...agentExtras(identity),
|
|
58011
|
-
clientGeneration: String(clientGeneration),
|
|
58012
|
-
recoverySequence: String(recovery.recoverySequence),
|
|
58013
|
-
stage: "streamRecovery/replay"
|
|
58014
|
-
}
|
|
58015
|
-
);
|
|
58016
|
-
} finally {
|
|
58073
|
+
if (candidate) {
|
|
58074
|
+
if (recoveryStabilityTimeout) {
|
|
58075
|
+
this.streamRecoveryClearTimeout(recoveryStabilityTimeout);
|
|
58076
|
+
}
|
|
58077
|
+
recoveryStabilityTimeout = this.streamRecoverySetTimeout(() => {
|
|
58078
|
+
recoveryStabilityTimeout = void 0;
|
|
58079
|
+
if (recoveryDisposed || this.clients.get(address) !== agent || this.stoppedAddresses.has(addressKey) || streamRecovery.activeSequence !== candidate.recoverySequence) {
|
|
58080
|
+
return;
|
|
58081
|
+
}
|
|
58082
|
+
const recovery = streamRecovery.markStable();
|
|
58083
|
+
if (!recovery) {
|
|
58084
|
+
return;
|
|
58085
|
+
}
|
|
58086
|
+
if (recoveryTimeout) {
|
|
58087
|
+
this.streamRecoveryClearTimeout(recoveryTimeout);
|
|
58088
|
+
recoveryTimeout = void 0;
|
|
58089
|
+
}
|
|
58090
|
+
const recoveryGate = pendingRecoveryGate;
|
|
58091
|
+
pendingRecoveryGate = void 0;
|
|
58092
|
+
logger.info(LogEvent.AGENT_STREAM_RECOVERED, {
|
|
58093
|
+
...agentExtras(identity),
|
|
58094
|
+
clientGeneration: String(clientGeneration),
|
|
58095
|
+
recoverySequence: String(recovery.recoverySequence),
|
|
58096
|
+
recoveryDurationMs: String(recovery.recoveryDurationMs),
|
|
58097
|
+
recoveryConfirmationDurationMs: String(
|
|
58098
|
+
recovery.recoveryConfirmationDurationMs
|
|
58099
|
+
),
|
|
58100
|
+
stabilityWindowMs: String(STREAM_RECOVERY_STABILITY_WINDOW_MS)
|
|
58101
|
+
});
|
|
58102
|
+
void (async () => {
|
|
58017
58103
|
try {
|
|
58018
|
-
await this.
|
|
58104
|
+
const summary = await this.replayOfflineMessagesForStreamRecovery(
|
|
58105
|
+
address,
|
|
58106
|
+
String(recovery.recoverySequence),
|
|
58107
|
+
agent
|
|
58108
|
+
);
|
|
58109
|
+
if (summary.outcome === "completed" && !recoveryDisposed && this.clients.get(address) === agent) {
|
|
58110
|
+
logger.info(LogEvent.AGENT_STREAM_RECOVERY_REPLAY_COMPLETED, {
|
|
58111
|
+
...agentExtras(identity),
|
|
58112
|
+
clientGeneration: String(clientGeneration),
|
|
58113
|
+
recoverySequence: String(recovery.recoverySequence),
|
|
58114
|
+
replayed: String(summary.replayed),
|
|
58115
|
+
skipped: String(summary.skipped),
|
|
58116
|
+
conversationCount: String(summary.conversations),
|
|
58117
|
+
replayDurationMs: String(summary.durationMs),
|
|
58118
|
+
outcome: "success",
|
|
58119
|
+
replayOutcome: summary.outcome
|
|
58120
|
+
});
|
|
58121
|
+
}
|
|
58019
58122
|
} catch (err) {
|
|
58020
|
-
logWithTimestamp(`${tag} recovery replay
|
|
58123
|
+
logWithTimestamp(`${tag} recovery offline replay failed:`, err);
|
|
58021
58124
|
logger.error(
|
|
58022
58125
|
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
58023
58126
|
err instanceof Error ? err : new Error(String(err)),
|
|
@@ -58025,12 +58128,28 @@ var XmtpService = class _XmtpService {
|
|
|
58025
58128
|
...agentExtras(identity),
|
|
58026
58129
|
clientGeneration: String(clientGeneration),
|
|
58027
58130
|
recoverySequence: String(recovery.recoverySequence),
|
|
58028
|
-
stage: "streamRecovery/
|
|
58131
|
+
stage: "streamRecovery/replay"
|
|
58029
58132
|
}
|
|
58030
58133
|
);
|
|
58134
|
+
} finally {
|
|
58135
|
+
try {
|
|
58136
|
+
await this.drainInboundReplayGate(address, recoveryGate);
|
|
58137
|
+
} catch (err) {
|
|
58138
|
+
logWithTimestamp(`${tag} recovery replay gate drain failed:`, err);
|
|
58139
|
+
logger.error(
|
|
58140
|
+
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
58141
|
+
err instanceof Error ? err : new Error(String(err)),
|
|
58142
|
+
{
|
|
58143
|
+
...agentExtras(identity),
|
|
58144
|
+
clientGeneration: String(clientGeneration),
|
|
58145
|
+
recoverySequence: String(recovery.recoverySequence),
|
|
58146
|
+
stage: "streamRecovery/drain-gate"
|
|
58147
|
+
}
|
|
58148
|
+
);
|
|
58149
|
+
}
|
|
58031
58150
|
}
|
|
58032
|
-
}
|
|
58033
|
-
})
|
|
58151
|
+
})();
|
|
58152
|
+
}, STREAM_RECOVERY_STABILITY_WINDOW_MS);
|
|
58034
58153
|
}
|
|
58035
58154
|
if (process.env.XMTP_FORCE_DEBUG === "true") {
|
|
58036
58155
|
void logDetails(agent).catch((err) => {
|
|
@@ -58049,7 +58168,7 @@ var XmtpService = class _XmtpService {
|
|
|
58049
58168
|
logWithTimestamp(`${tag} message listener started`);
|
|
58050
58169
|
});
|
|
58051
58170
|
}
|
|
58052
|
-
async replayOfflineMessagesForAddress(address, expectedClient, trigger = "periodic_repair") {
|
|
58171
|
+
async replayOfflineMessagesForAddress(address, expectedClient, trigger = "periodic_repair", recoveryIdentity) {
|
|
58053
58172
|
const addressReplayStartedAt = Date.now();
|
|
58054
58173
|
const summary = createOfflineReplayAddressSummary(address);
|
|
58055
58174
|
const isOfflineReplay = isOfflineReplayForTrigger(trigger);
|
|
@@ -58149,6 +58268,8 @@ var XmtpService = class _XmtpService {
|
|
|
58149
58268
|
walletAddress: address,
|
|
58150
58269
|
stage: `offlineReplay/${stage}`,
|
|
58151
58270
|
trigger,
|
|
58271
|
+
clientGeneration: String(clientGeneration),
|
|
58272
|
+
...recoveryIdentity ? { recoverySequence: recoveryIdentity } : {},
|
|
58152
58273
|
outcome: "failed",
|
|
58153
58274
|
replayOutcome: summary.outcome,
|
|
58154
58275
|
consecutiveFailures: String(consecutiveFailures),
|
|
@@ -58343,8 +58464,7 @@ var XmtpService = class _XmtpService {
|
|
|
58343
58464
|
const clientGeneration = expectedClient ? this.getClientGeneration(expectedClient) : "missing";
|
|
58344
58465
|
const eligibilityClass = replaySingleFlightDiscriminator(
|
|
58345
58466
|
trigger,
|
|
58346
|
-
clientGeneration
|
|
58347
|
-
recoveryIdentity
|
|
58467
|
+
clientGeneration
|
|
58348
58468
|
);
|
|
58349
58469
|
return this.offlineReplaySingleFlight.run(
|
|
58350
58470
|
address,
|
|
@@ -58354,9 +58474,14 @@ var XmtpService = class _XmtpService {
|
|
|
58354
58474
|
return this.replayOfflineMessagesForAddress(
|
|
58355
58475
|
address,
|
|
58356
58476
|
expectedClient,
|
|
58357
|
-
trigger
|
|
58477
|
+
trigger,
|
|
58478
|
+
recoveryIdentity
|
|
58358
58479
|
);
|
|
58359
|
-
}
|
|
58480
|
+
},
|
|
58481
|
+
trigger === "stream_recovery" ? {
|
|
58482
|
+
queueBehindActive: true,
|
|
58483
|
+
shouldRunAfterActive: (summary) => summary.outcome === "completed"
|
|
58484
|
+
} : void 0
|
|
58360
58485
|
);
|
|
58361
58486
|
}
|
|
58362
58487
|
async replayOfflineMessagesForStreamRecovery(address, recoveryIdentity, expectedClient) {
|
|
@@ -58414,12 +58539,6 @@ function createOfflineReplayAddressSummary(address) {
|
|
|
58414
58539
|
};
|
|
58415
58540
|
}
|
|
58416
58541
|
|
|
58417
|
-
// ../core/src/a2a/pending-conversation.ts
|
|
58418
|
-
var PENDING_CONVERSATION_BACKUP_NOTICE_TEMPLATE = "[event:provider_conversation][jobId:${jobId}] There are new conversation requests pending.";
|
|
58419
|
-
function buildPendingConversationBackupNotice(jobId) {
|
|
58420
|
-
return PENDING_CONVERSATION_BACKUP_NOTICE_TEMPLATE.replace("${jobId}", jobId);
|
|
58421
|
-
}
|
|
58422
|
-
|
|
58423
58542
|
// ../core/src/a2a/index.ts
|
|
58424
58543
|
var A2A_MESSAGE_TYPE = "a2a-agent-chat";
|
|
58425
58544
|
|
|
@@ -58686,7 +58805,7 @@ function redactArgsForLog(args) {
|
|
|
58686
58805
|
function commandForLog(bin, args) {
|
|
58687
58806
|
return `${bin} ${redactArgsForLog(args).join(" ")}`;
|
|
58688
58807
|
}
|
|
58689
|
-
async function exec(args) {
|
|
58808
|
+
async function exec(args, options = {}) {
|
|
58690
58809
|
const bin = await resolve6();
|
|
58691
58810
|
const cmd = commandForLog(bin, args);
|
|
58692
58811
|
logWithTimestamp(`[onchainos] exec: ${cmd}`);
|
|
@@ -58700,7 +58819,8 @@ async function exec(args) {
|
|
|
58700
58819
|
try {
|
|
58701
58820
|
const result = await execFileAsync2(invocation.command, invocation.args, {
|
|
58702
58821
|
windowsHide: true,
|
|
58703
|
-
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
58822
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments,
|
|
58823
|
+
timeout: options.timeoutMs
|
|
58704
58824
|
});
|
|
58705
58825
|
logWithTimestamp(
|
|
58706
58826
|
`[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
|
|
@@ -58733,7 +58853,8 @@ async function exec(args) {
|
|
|
58733
58853
|
stdoutBytes: String(Buffer.byteLength(String(err?.stdout ?? ""), "utf8")),
|
|
58734
58854
|
cliErrorName: err instanceof Error ? err.name : "",
|
|
58735
58855
|
cliErrorMessageLength: String(String(err?.message ?? "").length),
|
|
58736
|
-
durationMs: String(Date.now() - t0)
|
|
58856
|
+
durationMs: String(Date.now() - t0),
|
|
58857
|
+
timeoutMs: String(options.timeoutMs ?? "")
|
|
58737
58858
|
}
|
|
58738
58859
|
);
|
|
58739
58860
|
throw err;
|
|
@@ -58951,6 +59072,7 @@ async function fetchSystemConfig(options) {
|
|
|
58951
59072
|
// ../core/src/xmtp-sdk/onchainos/wallet-status.ts
|
|
58952
59073
|
init_log();
|
|
58953
59074
|
init_sentry_logger();
|
|
59075
|
+
var WALLET_STATUS_TIMEOUT_MS = 1e4;
|
|
58954
59076
|
function parseWalletLoginStatus(stdout) {
|
|
58955
59077
|
const response = parseCliJson(stdout, "wallet-status");
|
|
58956
59078
|
if (!response.ok) {
|
|
@@ -58976,9 +59098,12 @@ function parseWalletLoginStatus(stdout) {
|
|
|
58976
59098
|
}
|
|
58977
59099
|
return response.data.loggedIn;
|
|
58978
59100
|
}
|
|
58979
|
-
async function queryWalletLoginStatus() {
|
|
59101
|
+
async function queryWalletLoginStatus(options = {}) {
|
|
58980
59102
|
logWithTimestamp("[onchainos] checking wallet login status");
|
|
58981
|
-
const { stdout } = await exec(
|
|
59103
|
+
const { stdout } = await exec(
|
|
59104
|
+
["wallet", "status"],
|
|
59105
|
+
{ timeoutMs: options.timeoutMs ?? WALLET_STATUS_TIMEOUT_MS }
|
|
59106
|
+
);
|
|
58982
59107
|
const loggedIn = parseWalletLoginStatus(stdout);
|
|
58983
59108
|
logWithTimestamp(`[onchainos] wallet login status: ${loggedIn ? "logged in" : "logged out"}`);
|
|
58984
59109
|
return loggedIn;
|
|
@@ -59047,6 +59172,8 @@ function guardCatchSessionExpired2(err, command) {
|
|
|
59047
59172
|
}
|
|
59048
59173
|
}
|
|
59049
59174
|
var PAGE_SIZE = 50;
|
|
59175
|
+
var AGENT_GET_PAGE_TIMEOUT_MS = 1e4;
|
|
59176
|
+
var AGENT_LIST_TIMEOUT_MS = 3e4;
|
|
59050
59177
|
function isJsonString(value) {
|
|
59051
59178
|
try {
|
|
59052
59179
|
JSON.parse(value);
|
|
@@ -59072,19 +59199,22 @@ function logAgentListResponse(input) {
|
|
|
59072
59199
|
onchainosAgentListDiagnosticText: input.stderr
|
|
59073
59200
|
});
|
|
59074
59201
|
}
|
|
59075
|
-
async function fetchAgentPage(page) {
|
|
59202
|
+
async function fetchAgentPage(page, timeoutMs) {
|
|
59076
59203
|
const startedAt = Date.now();
|
|
59077
59204
|
let stdout;
|
|
59078
59205
|
let stderr;
|
|
59079
59206
|
try {
|
|
59080
|
-
({ stdout, stderr } = await exec(
|
|
59081
|
-
|
|
59082
|
-
|
|
59083
|
-
|
|
59084
|
-
|
|
59085
|
-
|
|
59086
|
-
|
|
59087
|
-
|
|
59207
|
+
({ stdout, stderr } = await exec(
|
|
59208
|
+
[
|
|
59209
|
+
"agent",
|
|
59210
|
+
"get",
|
|
59211
|
+
"--page",
|
|
59212
|
+
String(page),
|
|
59213
|
+
"--page-size",
|
|
59214
|
+
String(PAGE_SIZE)
|
|
59215
|
+
],
|
|
59216
|
+
{ timeoutMs }
|
|
59217
|
+
));
|
|
59088
59218
|
} catch (err) {
|
|
59089
59219
|
const errStdout = typeof err?.stdout === "string" ? err.stdout : "";
|
|
59090
59220
|
const errStderr = typeof err?.stderr === "string" ? err.stderr : "";
|
|
@@ -59230,13 +59360,28 @@ async function fetchAgentByAddress(communicationAddress) {
|
|
|
59230
59360
|
agentByIdCache.set(res.data.agentId, res.data);
|
|
59231
59361
|
return res.data;
|
|
59232
59362
|
}
|
|
59233
|
-
async function listAllAgentsWithMetadata(previousFingerprint) {
|
|
59363
|
+
async function listAllAgentsWithMetadata(previousFingerprint, options = {}) {
|
|
59234
59364
|
const startedAt = Date.now();
|
|
59365
|
+
const pageTimeoutMs = positiveTimeoutOrDefault(
|
|
59366
|
+
options.pageTimeoutMs,
|
|
59367
|
+
AGENT_GET_PAGE_TIMEOUT_MS
|
|
59368
|
+
);
|
|
59369
|
+
const totalTimeoutMs = positiveTimeoutOrDefault(
|
|
59370
|
+
options.totalTimeoutMs,
|
|
59371
|
+
AGENT_LIST_TIMEOUT_MS
|
|
59372
|
+
);
|
|
59235
59373
|
const agents = [];
|
|
59236
59374
|
const stderrs = [];
|
|
59237
59375
|
let page = 1;
|
|
59238
59376
|
while (true) {
|
|
59239
|
-
const
|
|
59377
|
+
const remainingMs = totalTimeoutMs - (Date.now() - startedAt);
|
|
59378
|
+
if (remainingMs <= 0) {
|
|
59379
|
+
throw agentListTimeoutError(totalTimeoutMs);
|
|
59380
|
+
}
|
|
59381
|
+
const { data, stderr } = await fetchAgentPage(
|
|
59382
|
+
page,
|
|
59383
|
+
Math.min(pageTimeoutMs, remainingMs)
|
|
59384
|
+
);
|
|
59240
59385
|
if (stderr) {
|
|
59241
59386
|
stderrs.push(`page=${page}: ${stderr}`);
|
|
59242
59387
|
}
|
|
@@ -59263,6 +59408,14 @@ async function listAllAgentsWithMetadata(previousFingerprint) {
|
|
|
59263
59408
|
durationMs: Date.now() - startedAt
|
|
59264
59409
|
};
|
|
59265
59410
|
}
|
|
59411
|
+
function positiveTimeoutOrDefault(value, fallback) {
|
|
59412
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
59413
|
+
}
|
|
59414
|
+
function agentListTimeoutError(timeoutMs) {
|
|
59415
|
+
const error = new Error(`onchainos agent list timed out after ${timeoutMs}ms`);
|
|
59416
|
+
error.code = "ETIMEDOUT";
|
|
59417
|
+
return error;
|
|
59418
|
+
}
|
|
59266
59419
|
function fingerprintAgents(agents) {
|
|
59267
59420
|
return agents.map((a) => [
|
|
59268
59421
|
a.agentId,
|
|
@@ -60242,7 +60395,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
60242
60395
|
client: {
|
|
60243
60396
|
id: "gateway-client",
|
|
60244
60397
|
displayName: "okx-a2a-node",
|
|
60245
|
-
version: "0.2.4
|
|
60398
|
+
version: "0.2.4",
|
|
60246
60399
|
platform: "node",
|
|
60247
60400
|
mode: "backend",
|
|
60248
60401
|
instanceId
|
|
@@ -60253,7 +60406,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
60253
60406
|
commands: [],
|
|
60254
60407
|
permissions: {},
|
|
60255
60408
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
60256
|
-
userAgent: `okx-a2a-node/${"0.2.4
|
|
60409
|
+
userAgent: `okx-a2a-node/${"0.2.4"}`,
|
|
60257
60410
|
auth: {
|
|
60258
60411
|
...config.token ? { token: config.token } : {},
|
|
60259
60412
|
...config.password ? { password: config.password } : {}
|
|
@@ -64532,17 +64685,22 @@ async function maybeAllowProviderGroup(deps, chatType, conversationId) {
|
|
|
64532
64685
|
);
|
|
64533
64686
|
}
|
|
64534
64687
|
}
|
|
64535
|
-
function
|
|
64536
|
-
|
|
64537
|
-
}
|
|
64538
|
-
function buildPendingConversationBackupDispatch(input) {
|
|
64539
|
-
return {
|
|
64540
|
-
sessionKey: buildBackupJobSessionKey(input.jobId),
|
|
64541
|
-
content: buildPendingConversationBackupNotice(input.jobId),
|
|
64542
|
-
messageId: `pending-conversation:${input.messageId}`,
|
|
64688
|
+
function ensureInboundGroupSession(deps, input) {
|
|
64689
|
+
const sessionKey = buildSessionKey({
|
|
64543
64690
|
jobId: input.jobId,
|
|
64544
|
-
|
|
64545
|
-
|
|
64691
|
+
myAgentId: input.myAgentId,
|
|
64692
|
+
toAgentId: input.toAgentId
|
|
64693
|
+
});
|
|
64694
|
+
deps.sessionStore?.upsertSession({
|
|
64695
|
+
sessionKey,
|
|
64696
|
+
jobId: input.jobId,
|
|
64697
|
+
myAgentId: input.myAgentId,
|
|
64698
|
+
toAgentId: input.toAgentId,
|
|
64699
|
+
groupId: input.groupId,
|
|
64700
|
+
myAgentXmtpAddress: deps.myXmtpAddress,
|
|
64701
|
+
toAgentXmtpAddress: input.toAgentXmtpAddress
|
|
64702
|
+
});
|
|
64703
|
+
return sessionKey;
|
|
64546
64704
|
}
|
|
64547
64705
|
var INBOUND_TRANSPORT = "xmtp";
|
|
64548
64706
|
var INBOUND_EVENT_FAMILY = "inbound";
|
|
@@ -64608,30 +64766,6 @@ function buildInboundTerminalExtras(input) {
|
|
|
64608
64766
|
})
|
|
64609
64767
|
};
|
|
64610
64768
|
}
|
|
64611
|
-
function notifyPendingConversationToBackup(params) {
|
|
64612
|
-
const event = buildPendingConversationBackupDispatch({
|
|
64613
|
-
jobId: params.jobId,
|
|
64614
|
-
messageId: params.messageId
|
|
64615
|
-
});
|
|
64616
|
-
void Promise.resolve(params.deps.onSessionMessage?.(event)).catch((err) => {
|
|
64617
|
-
logWithTimestamp(`[okx-agent-task:${params.deps.myXmtpAddress}] pending conversation backup dispatch failed:`, err);
|
|
64618
|
-
logger.error(LogEvent.INBOUND_DISPATCH_FAILED, toLoggableError(err), {
|
|
64619
|
-
...buildInboundTerminalExtras({
|
|
64620
|
-
terminalState: "dispatch_failed",
|
|
64621
|
-
myXmtpAddress: params.deps.myXmtpAddress,
|
|
64622
|
-
messageId: event.messageId,
|
|
64623
|
-
jobId: params.jobId,
|
|
64624
|
-
sessionKey: event.sessionKey,
|
|
64625
|
-
route: "backup",
|
|
64626
|
-
reason: "pending_backup_dispatch_failed"
|
|
64627
|
-
}),
|
|
64628
|
-
// Each fire-and-forget dispatch overrides the generic checkpoint with the
|
|
64629
|
-
// `_failed` twin of its own success checkpoint, so the four paths stay
|
|
64630
|
-
// distinguishable in the funnel.
|
|
64631
|
-
checkpoint: "inbound/pending_backup_dispatch_failed"
|
|
64632
|
-
});
|
|
64633
|
-
});
|
|
64634
|
-
}
|
|
64635
64769
|
function maybeNotifyInboundAgentMessage(params) {
|
|
64636
64770
|
if (params.chatType === "dm") {
|
|
64637
64771
|
return;
|
|
@@ -65439,7 +65573,7 @@ async function processFileMessage(ctx, deps, options = {}) {
|
|
|
65439
65573
|
}
|
|
65440
65574
|
const sender = isPlainObject3(payloadObject?.sender) ? payloadObject.sender : null;
|
|
65441
65575
|
const localAgent = service.getAgentByAddress(deps.myXmtpAddress);
|
|
65442
|
-
const myAgentId = localAgent?.agentId ?? sessionAgentId ?? null;
|
|
65576
|
+
const myAgentId = localAgent?.agentId ?? readString3(payloadObject?.receiverAgentId) ?? sessionAgentId ?? null;
|
|
65443
65577
|
const toAgentId = readString3(sender?.agentId);
|
|
65444
65578
|
const accepted = await verifyInboundA2AGroupMessage({
|
|
65445
65579
|
payload: parsed.parsed ? parsed.payload : null,
|
|
@@ -65457,50 +65591,13 @@ async function processFileMessage(ctx, deps, options = {}) {
|
|
|
65457
65591
|
if (!accepted) {
|
|
65458
65592
|
return true;
|
|
65459
65593
|
}
|
|
65460
|
-
const sessionKey = buildSessionKey({
|
|
65461
|
-
jobId: route.jobId,
|
|
65462
|
-
myAgentId,
|
|
65463
|
-
toAgentId
|
|
65464
|
-
});
|
|
65465
|
-
const existingSession = deps.sessionStore?.getSession(sessionKey) ?? null;
|
|
65466
65594
|
const routedMessageId = messageId || `group-${(0, import_node_crypto12.randomUUID)()}`;
|
|
65467
|
-
const
|
|
65468
|
-
if (shouldKeepInboundGroupPendingForBuyer({
|
|
65469
|
-
consentState,
|
|
65470
|
-
localAgentRole: localAgent?.role ?? null,
|
|
65471
|
-
hasExistingSession: !!existingSession
|
|
65472
|
-
})) {
|
|
65473
|
-
logWithTimestamp(
|
|
65474
|
-
`[okx-agent-task:${deps.myXmtpAddress}] buyer inbound group kept pending: session=${sessionKey} job=${shortenLogValue(route.jobId)} group=${conversationId} consent=${String(consentState)} message=${shortenLogValue(routedMessageId)}`
|
|
65475
|
-
);
|
|
65476
|
-
logger.info(LogEvent.INBOUND_BUYER_PENDING, {
|
|
65477
|
-
...agentExtras({ walletAddress: deps.myXmtpAddress, onchainosAgentId: localAgent?.agentId }),
|
|
65478
|
-
peerWalletAddress: senderAddress,
|
|
65479
|
-
peerInboxId: ctx.message.senderInboxId ?? "",
|
|
65480
|
-
peerAgentId: toAgentId ?? "",
|
|
65481
|
-
taskId: route.jobId,
|
|
65482
|
-
conversationId,
|
|
65483
|
-
messageId: routedMessageId,
|
|
65484
|
-
consentState: String(consentState),
|
|
65485
|
-
...inboundStageExtras("inbound/buyer_pending", "pending"),
|
|
65486
|
-
reason: "unknown_group_without_session",
|
|
65487
|
-
...timing.extras()
|
|
65488
|
-
});
|
|
65489
|
-
notifyPendingConversationToBackup({
|
|
65490
|
-
deps,
|
|
65491
|
-
jobId: route.jobId,
|
|
65492
|
-
messageId: routedMessageId
|
|
65493
|
-
});
|
|
65494
|
-
return true;
|
|
65495
|
-
}
|
|
65496
|
-
deps.sessionStore?.upsertSession({
|
|
65497
|
-
sessionKey,
|
|
65595
|
+
const sessionKey = ensureInboundGroupSession(deps, {
|
|
65498
65596
|
jobId: route.jobId,
|
|
65499
65597
|
myAgentId,
|
|
65500
65598
|
toAgentId,
|
|
65501
|
-
groupId: conversationId
|
|
65502
|
-
|
|
65503
|
-
toAgentXmtpAddress: senderAddress || null
|
|
65599
|
+
groupId: conversationId,
|
|
65600
|
+
toAgentXmtpAddress: senderAddress || readString3(payloadObject?.fromXmtpAddress)
|
|
65504
65601
|
});
|
|
65505
65602
|
const dispatchStartedAt = Date.now();
|
|
65506
65603
|
void Promise.resolve(deps.onSessionMessage?.({
|
|
@@ -66036,6 +66133,7 @@ var DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC = 6 * 60 * 60;
|
|
|
66036
66133
|
var XMTP_CLIENT_RECYCLE_INTERVAL_ENV = "OKX_A2A_XMTP_CLIENT_RECYCLE_INTERVAL_SEC";
|
|
66037
66134
|
var HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS = 2e3;
|
|
66038
66135
|
var AUTH_RECOVERY_PROBE_INTERVAL_MS = 6e4;
|
|
66136
|
+
var AUTH_RECOVERY_REFRESH_BACKOFF_MS = [6e4, 12e4, 3e5];
|
|
66039
66137
|
async function runHeartbeatRefreshCycle(options) {
|
|
66040
66138
|
const heartbeat = await timeSettled(options.heartbeat);
|
|
66041
66139
|
const refreshAllowed = heartbeat.value === "performed" || heartbeat.value === "refresh_safe";
|
|
@@ -66066,6 +66164,8 @@ var AgentRefreshCoordinator = class {
|
|
|
66066
66164
|
authGate = new AgentRefreshAuthGate();
|
|
66067
66165
|
refreshInFlight = null;
|
|
66068
66166
|
recoveryProbeInFlight = null;
|
|
66167
|
+
recoveryRefreshFailureCount = 0;
|
|
66168
|
+
nextRecoveryRefreshAtMs = 0;
|
|
66069
66169
|
get blocked() {
|
|
66070
66170
|
return this.authGate.blocked;
|
|
66071
66171
|
}
|
|
@@ -66074,6 +66174,8 @@ var AgentRefreshCoordinator = class {
|
|
|
66074
66174
|
try {
|
|
66075
66175
|
const result = await this.options.lookup(previousFingerprint);
|
|
66076
66176
|
this.authGate.recordSuccess();
|
|
66177
|
+
this.recoveryRefreshFailureCount = 0;
|
|
66178
|
+
this.nextRecoveryRefreshAtMs = 0;
|
|
66077
66179
|
if (wasBlocked) {
|
|
66078
66180
|
this.options.onAuthRecovered?.();
|
|
66079
66181
|
}
|
|
@@ -66095,7 +66197,7 @@ var AgentRefreshCoordinator = class {
|
|
|
66095
66197
|
return this.runRefresh();
|
|
66096
66198
|
}
|
|
66097
66199
|
runRecoveryProbe() {
|
|
66098
|
-
if (this.options.isStopping() || !this.authGate.blocked || !this.options.checkLoggedIn) {
|
|
66200
|
+
if (this.options.isStopping() || !this.authGate.blocked || !this.options.checkLoggedIn || this.now() < this.nextRecoveryRefreshAtMs) {
|
|
66099
66201
|
return Promise.resolve(null);
|
|
66100
66202
|
}
|
|
66101
66203
|
if (this.recoveryProbeInFlight) {
|
|
@@ -66107,8 +66209,15 @@ var AgentRefreshCoordinator = class {
|
|
|
66107
66209
|
return null;
|
|
66108
66210
|
}
|
|
66109
66211
|
const refresh = await this.runRefresh();
|
|
66110
|
-
|
|
66111
|
-
|
|
66212
|
+
if (this.authGate.blocked) {
|
|
66213
|
+
this.recordRecoveryRefreshFailure();
|
|
66214
|
+
return null;
|
|
66215
|
+
}
|
|
66216
|
+
return refresh;
|
|
66217
|
+
})().catch((err) => {
|
|
66218
|
+
this.recordRecoveryRefreshFailure();
|
|
66219
|
+
throw err;
|
|
66220
|
+
}).finally(() => {
|
|
66112
66221
|
this.recoveryProbeInFlight = null;
|
|
66113
66222
|
});
|
|
66114
66223
|
return this.recoveryProbeInFlight;
|
|
@@ -66122,6 +66231,17 @@ var AgentRefreshCoordinator = class {
|
|
|
66122
66231
|
});
|
|
66123
66232
|
return this.refreshInFlight;
|
|
66124
66233
|
}
|
|
66234
|
+
now() {
|
|
66235
|
+
return this.options.now?.() ?? Date.now();
|
|
66236
|
+
}
|
|
66237
|
+
recordRecoveryRefreshFailure() {
|
|
66238
|
+
const backoffIndex = Math.min(
|
|
66239
|
+
this.recoveryRefreshFailureCount,
|
|
66240
|
+
AUTH_RECOVERY_REFRESH_BACKOFF_MS.length - 1
|
|
66241
|
+
);
|
|
66242
|
+
this.nextRecoveryRefreshAtMs = this.now() + AUTH_RECOVERY_REFRESH_BACKOFF_MS[backoffIndex];
|
|
66243
|
+
this.recoveryRefreshFailureCount += 1;
|
|
66244
|
+
}
|
|
66125
66245
|
};
|
|
66126
66246
|
var ListenerDeferredTaskScheduler = class {
|
|
66127
66247
|
timers = /* @__PURE__ */ new Set();
|
|
@@ -66417,7 +66537,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
66417
66537
|
}
|
|
66418
66538
|
}),
|
|
66419
66539
|
notifySessionExpired: (command) => {
|
|
66420
|
-
const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login\`; A2A will
|
|
66540
|
+
const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login\`; A2A will retry recovery automatically within 60 seconds, or run \`okx-a2a agent refresh\` to retry immediately.`;
|
|
66421
66541
|
void store.appendBackup(buildSystemStoredMessage({
|
|
66422
66542
|
reason: "onchainos-session-expired",
|
|
66423
66543
|
rawText,
|
|
@@ -66445,12 +66565,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
66445
66565
|
});
|
|
66446
66566
|
}
|
|
66447
66567
|
});
|
|
66448
|
-
service.setPluginVersion("0.2.4
|
|
66568
|
+
service.setPluginVersion("0.2.4");
|
|
66449
66569
|
await service.init();
|
|
66450
66570
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
66451
66571
|
if (pluginVersionStatus.unavailable) {
|
|
66452
66572
|
throw new Error(
|
|
66453
|
-
`@okxweb3/a2a-node v${"0.2.4
|
|
66573
|
+
`@okxweb3/a2a-node v${"0.2.4"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
66454
66574
|
);
|
|
66455
66575
|
}
|
|
66456
66576
|
const systemConfig = service.getSystemConfig();
|
|
@@ -66468,7 +66588,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
66468
66588
|
onchainosAgentId: "*",
|
|
66469
66589
|
reason: "system-config missing sentryDsn",
|
|
66470
66590
|
pluginId: "@okxweb3/a2a-node",
|
|
66471
|
-
pluginVersion: "0.2.4
|
|
66591
|
+
pluginVersion: "0.2.4"
|
|
66472
66592
|
});
|
|
66473
66593
|
}
|
|
66474
66594
|
logWithTimestamp(
|
|
@@ -69166,7 +69286,7 @@ async function exportDiagnosticLogs(options) {
|
|
|
69166
69286
|
node: process.version,
|
|
69167
69287
|
platform: process.platform,
|
|
69168
69288
|
arch: process.arch,
|
|
69169
|
-
packageVersion: true ? "0.2.4
|
|
69289
|
+
packageVersion: true ? "0.2.4" : "unknown",
|
|
69170
69290
|
sensitiveContentIncluded: options.includeSensitiveContent,
|
|
69171
69291
|
listenerAndLlmContentIncluded: true,
|
|
69172
69292
|
credentialsAlwaysRedacted: true,
|
|
@@ -71002,7 +71122,7 @@ async function runDoctor(options = {}) {
|
|
|
71002
71122
|
platform: options.platform ?? process.platform,
|
|
71003
71123
|
env: options.env ?? process.env,
|
|
71004
71124
|
target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
|
|
71005
|
-
cliVersion: options.cliVersion ?? (true ? "0.2.4
|
|
71125
|
+
cliVersion: options.cliVersion ?? (true ? "0.2.4" : "0.0.0"),
|
|
71006
71126
|
fixMode: options.fix === true,
|
|
71007
71127
|
nonInteractive: options.nonInteractive === true,
|
|
71008
71128
|
packageChanged: false,
|
|
@@ -71223,6 +71343,8 @@ init_win_native_launcher();
|
|
|
71223
71343
|
init_autostart_windows();
|
|
71224
71344
|
// Annotate the CommonJS export names for ESM import in node:
|
|
71225
71345
|
0 && (module.exports = {
|
|
71346
|
+
AGENT_GET_PAGE_TIMEOUT_MS,
|
|
71347
|
+
AGENT_LIST_TIMEOUT_MS,
|
|
71226
71348
|
AI_PROVIDERS,
|
|
71227
71349
|
AgentMessageDirection,
|
|
71228
71350
|
AgentRefreshAuthGate,
|
|
@@ -71266,6 +71388,7 @@ init_autostart_windows();
|
|
|
71266
71388
|
USER_ATTENTION_WATCH_PARENT_CHECK_MS,
|
|
71267
71389
|
USER_ATTENTION_WATCH_REPLACED_MESSAGE,
|
|
71268
71390
|
UserCancelledAiProviderSelectionError,
|
|
71391
|
+
WALLET_STATUS_TIMEOUT_MS,
|
|
71269
71392
|
XMTP_CLIENT_RECYCLE_INTERVAL_ENV,
|
|
71270
71393
|
XmtpDm,
|
|
71271
71394
|
XmtpGroup,
|
|
@@ -71296,7 +71419,6 @@ init_autostart_windows();
|
|
|
71296
71419
|
buildLaunchdPlist,
|
|
71297
71420
|
buildLauncherEntryJs,
|
|
71298
71421
|
buildMessageEligibleArgs,
|
|
71299
|
-
buildPendingConversationBackupDispatch,
|
|
71300
71422
|
buildSchtasksCreateArgs,
|
|
71301
71423
|
buildSchtasksDeleteArgs,
|
|
71302
71424
|
buildSchtasksEndArgs,
|
|
@@ -71379,6 +71501,7 @@ init_autostart_windows();
|
|
|
71379
71501
|
isWindowsElevated,
|
|
71380
71502
|
killProcessTree,
|
|
71381
71503
|
launchdPlistHasCurrentRestartPolicy,
|
|
71504
|
+
listAllAgentsWithMetadata,
|
|
71382
71505
|
logWinCompat,
|
|
71383
71506
|
logXmtpMessageSent,
|
|
71384
71507
|
maybeRecommendOnchainosUpgrade,
|
|
@@ -71402,6 +71525,7 @@ init_autostart_windows();
|
|
|
71402
71525
|
printXmtpTestUsage,
|
|
71403
71526
|
probeCodexAuthStatus,
|
|
71404
71527
|
processFileMessage,
|
|
71528
|
+
queryWalletLoginStatus,
|
|
71405
71529
|
readAiProviderTimeoutMs,
|
|
71406
71530
|
readCachedCodexReadiness,
|
|
71407
71531
|
readLastLines,
|
|
@@ -71450,7 +71574,6 @@ init_autostart_windows();
|
|
|
71450
71574
|
scanUserAttentionWatchers,
|
|
71451
71575
|
setOpenClawWebSocketFactoryForTests,
|
|
71452
71576
|
shouldDelegateToSupervisor,
|
|
71453
|
-
shouldKeepInboundGroupPendingForBuyer,
|
|
71454
71577
|
shouldRouteThroughWindowsShell,
|
|
71455
71578
|
spawnCompat,
|
|
71456
71579
|
spawnSyncCompat,
|