@okxweb3/a2a-node 0.1.9 → 0.1.10-beta-114515ea34-260721221928
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/README.md +0 -1
- package/dist/cli.js +38 -532
- package/dist/index.js +34 -529
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18815,9 +18815,7 @@ var init_events = __esm({
|
|
|
18815
18815
|
OUTBOUND_ELIGIBILITY_CHECKED: "Outbound eligibility checked",
|
|
18816
18816
|
AGENT_CLIENT_CREATED: "Agent client created",
|
|
18817
18817
|
AGENT_CLIENT_REMOVED: "Agent client removed",
|
|
18818
|
-
ADDRESS_SYNC_COMPLETED: "Address sync completed",
|
|
18819
18818
|
AGENT_REFRESH_SESSION_EXPIRED: "Agent refresh aborted: onchainos session expired, local clients taken offline",
|
|
18820
|
-
OFFLINE_REPLAY_MESSAGE_REPLAYED: "Offline replay message replayed",
|
|
18821
18819
|
AGENTS_WAKEUP_NOTIFIED: "Agents wakeup notified",
|
|
18822
18820
|
CONFIG_SENSITIVE_WORDS_REFRESHED: "Sensitive words config refreshed",
|
|
18823
18821
|
CONFIG_SYSTEM_REFRESHED: "System config refreshed",
|
|
@@ -18848,7 +18846,6 @@ var init_events = __esm({
|
|
|
18848
18846
|
HEARTBEAT_GATEWAY_CHECK_FAILED: "Heartbeat gateway check failed",
|
|
18849
18847
|
MESSAGE_PARSE_FAILED: "Message parse failed",
|
|
18850
18848
|
MESSAGE_HANDLER_ERROR: "Message handler error",
|
|
18851
|
-
OFFLINE_REPLAY_FAILED: "Offline replay failed",
|
|
18852
18849
|
INBOUND_ROUTING_FAILED: "Inbound routing failed",
|
|
18853
18850
|
CONVERSATION_NOT_FOUND: "Conversation not found for send",
|
|
18854
18851
|
XMTP_SEND_FAILED: "XMTP send failed",
|
|
@@ -18863,7 +18860,6 @@ var init_events = __esm({
|
|
|
18863
18860
|
INBOUND_SENSITIVE_CHECK_FAILED: "Inbound sensitive check failed",
|
|
18864
18861
|
FILE_UPLOAD_FAILED: "File upload failed",
|
|
18865
18862
|
FILE_DOWNLOAD_FAILED: "File download failed",
|
|
18866
|
-
OFFLINE_REPLAY_MESSAGE_FAILED: "Offline replay message failed",
|
|
18867
18863
|
PENDING_NOTIFICATION_FAILED: "Pending notification failed",
|
|
18868
18864
|
GATEWAY_CONNECT_FAILED: "Gateway connect failed",
|
|
18869
18865
|
GATEWAY_REQUEST_FAILED: "Gateway request failed",
|
|
@@ -19078,7 +19074,6 @@ var init_sentry_logger = __esm({
|
|
|
19078
19074
|
LogEvent.MESSAGE_SENT,
|
|
19079
19075
|
LogEvent.AGENT_CLIENT_CREATED,
|
|
19080
19076
|
LogEvent.AGENT_CLIENT_REMOVED,
|
|
19081
|
-
LogEvent.ADDRESS_SYNC_COMPLETED,
|
|
19082
19077
|
LogEvent.AGENTS_REFRESHED,
|
|
19083
19078
|
LogEvent.AGENTS_WAKEUP_NOTIFIED,
|
|
19084
19079
|
LogEvent.AGENT_LIST_QUERIED,
|
|
@@ -19091,7 +19086,6 @@ var init_sentry_logger = __esm({
|
|
|
19091
19086
|
LogEvent.GROUP_CONSENT_CHANGED,
|
|
19092
19087
|
LogEvent.INBOUND_HANDLER_ENTERED,
|
|
19093
19088
|
LogEvent.MESSAGE_RECEIVED,
|
|
19094
|
-
LogEvent.OFFLINE_REPLAY_MESSAGE_REPLAYED,
|
|
19095
19089
|
LogEvent.AGENT_REFRESH_SESSION_EXPIRED,
|
|
19096
19090
|
LogEvent.OUTBOUND_ELIGIBILITY_CHECKED,
|
|
19097
19091
|
LogEvent.OUTBOUND_BLOCKED_INELIGIBLE,
|
|
@@ -71981,7 +71975,7 @@ var init_sentry_config = __esm({
|
|
|
71981
71975
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
71982
71976
|
SENTRY_CONFIG = {
|
|
71983
71977
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
71984
|
-
release: "0.1.
|
|
71978
|
+
release: "0.1.10-beta-114515ea34-260721221928",
|
|
71985
71979
|
environment,
|
|
71986
71980
|
runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
|
|
71987
71981
|
};
|
|
@@ -72911,7 +72905,7 @@ async function getCurrentNodeCliVersion() {
|
|
|
72911
72905
|
return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
|
|
72912
72906
|
}
|
|
72913
72907
|
function getBundledNodeCliVersion() {
|
|
72914
|
-
return true ? "0.1.
|
|
72908
|
+
return true ? "0.1.10-beta-114515ea34-260721221928" : null;
|
|
72915
72909
|
}
|
|
72916
72910
|
function readConfiguredAiProvider() {
|
|
72917
72911
|
const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
|
|
@@ -73121,7 +73115,7 @@ async function updateHermes(release, options) {
|
|
|
73121
73115
|
}
|
|
73122
73116
|
}
|
|
73123
73117
|
async function installGatewayPluginForDoctor(target) {
|
|
73124
|
-
const release = isPrereleaseVersion("0.1.
|
|
73118
|
+
const release = isPrereleaseVersion("0.1.10-beta-114515ea34-260721221928") ? "beta" : "latest";
|
|
73125
73119
|
const insideTargetGateway = detectGatewayInvocation() === target;
|
|
73126
73120
|
const options = {
|
|
73127
73121
|
restart: !insideTargetGateway,
|
|
@@ -73995,7 +73989,6 @@ __export(index_exports, {
|
|
|
73995
73989
|
BACKUP_JOB_ID: () => BACKUP_JOB_ID,
|
|
73996
73990
|
CommandStore: () => CommandStore,
|
|
73997
73991
|
DEFAULT_AI_PERMISSION_PRESET: () => DEFAULT_AI_PERMISSION_PRESET,
|
|
73998
|
-
DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC: () => DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC,
|
|
73999
73992
|
DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC: () => DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC,
|
|
74000
73993
|
DOCTOR_MIN_NODE_VERSION: () => DOCTOR_MIN_NODE_VERSION,
|
|
74001
73994
|
GatewayOutboundBehavior: () => GatewayOutboundBehavior,
|
|
@@ -74115,7 +74108,6 @@ __export(index_exports, {
|
|
|
74115
74108
|
resolveDoctorTarget: () => resolveDoctorTarget,
|
|
74116
74109
|
resolveEnvelopePayload: () => resolveEnvelopePayload,
|
|
74117
74110
|
resolveNpmCmdShimScript: () => resolveNpmCmdShimScript,
|
|
74118
|
-
resolveOfflineReplayIntervalSec: () => resolveOfflineReplayIntervalSec,
|
|
74119
74111
|
resolveOpenClawGatewayConfig: () => resolveOpenClawGatewayConfig,
|
|
74120
74112
|
resolveOpenClawGatewayRoute: () => resolveOpenClawGatewayRoute,
|
|
74121
74113
|
resolveOpenClawGatewayRoutes: () => resolveOpenClawGatewayRoutes,
|
|
@@ -79915,6 +79907,22 @@ var Client = class _Client {
|
|
|
79915
79907
|
// ../core/src/xmtp-sdk/index.ts
|
|
79916
79908
|
init_sentry_logger();
|
|
79917
79909
|
|
|
79910
|
+
// ../core/src/xmtp-sdk/middleware/self-filter.ts
|
|
79911
|
+
function selfFilterMiddleware() {
|
|
79912
|
+
return async (ctx, next) => {
|
|
79913
|
+
const ownInboxId = ctx.client?.inboxId;
|
|
79914
|
+
const senderInboxId = ctx.message?.senderInboxId;
|
|
79915
|
+
if (ownInboxId && senderInboxId && String(senderInboxId).toLowerCase() === String(ownInboxId).toLowerCase()) {
|
|
79916
|
+
return;
|
|
79917
|
+
}
|
|
79918
|
+
await next();
|
|
79919
|
+
};
|
|
79920
|
+
}
|
|
79921
|
+
|
|
79922
|
+
// ../core/src/xmtp-sdk/middleware/logging.ts
|
|
79923
|
+
init_log();
|
|
79924
|
+
init_sentry_logger();
|
|
79925
|
+
|
|
79918
79926
|
// ../core/src/xmtp-sdk/extract-job-id.ts
|
|
79919
79927
|
function extractJobIdFromContent(content3) {
|
|
79920
79928
|
const raw = typeof content3 === "string" ? content3 : JSON.stringify(content3) ?? "";
|
|
@@ -79948,22 +79956,6 @@ function jobIdExtras(content3) {
|
|
|
79948
79956
|
return jobId ? { taskId: jobId } : {};
|
|
79949
79957
|
}
|
|
79950
79958
|
|
|
79951
|
-
// ../core/src/xmtp-sdk/middleware/self-filter.ts
|
|
79952
|
-
function selfFilterMiddleware() {
|
|
79953
|
-
return async (ctx, next) => {
|
|
79954
|
-
const ownInboxId = ctx.client?.inboxId;
|
|
79955
|
-
const senderInboxId = ctx.message?.senderInboxId;
|
|
79956
|
-
if (ownInboxId && senderInboxId && String(senderInboxId).toLowerCase() === String(ownInboxId).toLowerCase()) {
|
|
79957
|
-
return;
|
|
79958
|
-
}
|
|
79959
|
-
await next();
|
|
79960
|
-
};
|
|
79961
|
-
}
|
|
79962
|
-
|
|
79963
|
-
// ../core/src/xmtp-sdk/middleware/logging.ts
|
|
79964
|
-
init_log();
|
|
79965
|
-
init_sentry_logger();
|
|
79966
|
-
|
|
79967
79959
|
// ../core/src/xmtp-sdk/inbound-timing.ts
|
|
79968
79960
|
function createInboundTimingTracker(xmtpSentAtMs, xmtpReceivedAtMs = Date.now()) {
|
|
79969
79961
|
const durations = {};
|
|
@@ -86553,60 +86545,8 @@ async function loadSystemConfigWith(dataDir, fetcher) {
|
|
|
86553
86545
|
});
|
|
86554
86546
|
return null;
|
|
86555
86547
|
}
|
|
86556
|
-
function loadSyncByAddress(dataDir) {
|
|
86557
|
-
const map = /* @__PURE__ */ new Map();
|
|
86558
|
-
try {
|
|
86559
|
-
const path = cachePath(dataDir, "last-sync.json");
|
|
86560
|
-
if (!(0, import_node_fs11.existsSync)(path)) {
|
|
86561
|
-
return map;
|
|
86562
|
-
}
|
|
86563
|
-
const data = JSON.parse((0, import_node_fs11.readFileSync)(path, "utf-8"));
|
|
86564
|
-
const obj = data?.syncByAddress;
|
|
86565
|
-
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
86566
|
-
for (const [addr, ts] of Object.entries(obj)) {
|
|
86567
|
-
if (typeof ts === "number" && ts > 0) {
|
|
86568
|
-
map.set(addr, ts);
|
|
86569
|
-
}
|
|
86570
|
-
}
|
|
86571
|
-
}
|
|
86572
|
-
} catch (err2) {
|
|
86573
|
-
logWithTimestamp("[xmtp-sdk] failed to read last-sync.json cache:", err2);
|
|
86574
|
-
logger.error(LogEvent.CACHE_LOAD_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), { cacheName: "last-sync" });
|
|
86575
|
-
}
|
|
86576
|
-
return map;
|
|
86577
|
-
}
|
|
86578
|
-
function saveSyncForAddress(dataDir, address, timestampMs) {
|
|
86579
|
-
try {
|
|
86580
|
-
let data = {};
|
|
86581
|
-
const path = cachePath(dataDir, "last-sync.json");
|
|
86582
|
-
if ((0, import_node_fs11.existsSync)(path)) {
|
|
86583
|
-
try {
|
|
86584
|
-
const raw = JSON.parse((0, import_node_fs11.readFileSync)(path, "utf-8"));
|
|
86585
|
-
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
86586
|
-
data = raw;
|
|
86587
|
-
}
|
|
86588
|
-
} catch {
|
|
86589
|
-
}
|
|
86590
|
-
}
|
|
86591
|
-
if (!data.syncByAddress || typeof data.syncByAddress !== "object") {
|
|
86592
|
-
data.syncByAddress = {};
|
|
86593
|
-
}
|
|
86594
|
-
data.syncByAddress[address] = timestampMs;
|
|
86595
|
-
(0, import_node_fs11.writeFileSync)(path, JSON.stringify(data, null, 2));
|
|
86596
|
-
} catch (err2) {
|
|
86597
|
-
logWithTimestamp(
|
|
86598
|
-
`[xmtp-sdk] failed to write last-sync.json (address=${address}):`,
|
|
86599
|
-
err2
|
|
86600
|
-
);
|
|
86601
|
-
logger.error(LogEvent.CACHE_WRITE_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), {
|
|
86602
|
-
cacheName: "last-sync",
|
|
86603
|
-
walletAddress: address
|
|
86604
|
-
});
|
|
86605
|
-
}
|
|
86606
|
-
}
|
|
86607
86548
|
var SYSTEM_CONFIG_DEFAULTS = {
|
|
86608
86549
|
heartbeatInterval: 60,
|
|
86609
|
-
offlineReplayInterval: 300,
|
|
86610
86550
|
xmtpClientRecycleInterval: 6 * 60 * 60,
|
|
86611
86551
|
maxFileSizeBytes: 100 * 1024 * 1024,
|
|
86612
86552
|
sensitiveUploadReg: [],
|
|
@@ -86728,7 +86668,6 @@ function parseSystemConfig(raw) {
|
|
|
86728
86668
|
}, []) : [];
|
|
86729
86669
|
return {
|
|
86730
86670
|
heartbeatInterval: typeof raw.heartbeatInterval === "number" ? raw.heartbeatInterval : SYSTEM_CONFIG_DEFAULTS.heartbeatInterval,
|
|
86731
|
-
offlineReplayInterval: typeof raw.offlineReplayInterval === "number" && Number.isFinite(raw.offlineReplayInterval) && raw.offlineReplayInterval > 0 ? raw.offlineReplayInterval : SYSTEM_CONFIG_DEFAULTS.offlineReplayInterval,
|
|
86732
86671
|
xmtpClientRecycleInterval: typeof raw.xmtpClientRecycleInterval === "number" && Number.isFinite(raw.xmtpClientRecycleInterval) && raw.xmtpClientRecycleInterval > 0 ? raw.xmtpClientRecycleInterval : SYSTEM_CONFIG_DEFAULTS.xmtpClientRecycleInterval,
|
|
86733
86672
|
maxFileSizeBytes: typeof raw.maxFileSizeBytes === "number" && Number.isFinite(raw.maxFileSizeBytes) && raw.maxFileSizeBytes > 0 ? raw.maxFileSizeBytes : SYSTEM_CONFIG_DEFAULTS.maxFileSizeBytes,
|
|
86734
86673
|
sensitiveUploadReg: parseStringArray(raw.SENSITIVE_UPLOAD_REG),
|
|
@@ -86742,7 +86681,6 @@ var isRecord2 = (value) => Boolean(value) && typeof value === "object" && !Array
|
|
|
86742
86681
|
var isPositiveNumber = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
86743
86682
|
var SYSTEM_CONFIG_VALIDATORS = {
|
|
86744
86683
|
heartbeatInterval: isPositiveNumber,
|
|
86745
|
-
offlineReplayInterval: isPositiveNumber,
|
|
86746
86684
|
xmtpClientRecycleInterval: isPositiveNumber,
|
|
86747
86685
|
maxFileSizeBytes: isPositiveNumber,
|
|
86748
86686
|
SENSITIVE_UPLOAD_REG: (value) => Array.isArray(value) && value.every((item) => typeof item === "string"),
|
|
@@ -86827,7 +86765,6 @@ var XmtpService = class _XmtpService {
|
|
|
86827
86765
|
minVersion: ""
|
|
86828
86766
|
};
|
|
86829
86767
|
dataDir = DEFAULT_DATA_DIR;
|
|
86830
|
-
syncByAddress = /* @__PURE__ */ new Map();
|
|
86831
86768
|
agentListFingerprint;
|
|
86832
86769
|
// Only one refreshAgents can be in flight at a time; concurrent calls
|
|
86833
86770
|
// coalesce onto the same promise. This avoids duplicate Agent.create()
|
|
@@ -86896,10 +86833,7 @@ var XmtpService = class _XmtpService {
|
|
|
86896
86833
|
this._onAfterInitError = null;
|
|
86897
86834
|
this._backupReady = afterInit ? afterInit().catch((err2) => {
|
|
86898
86835
|
this._onAfterInitError = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
86899
|
-
logWithTimestamp(
|
|
86900
|
-
"[xmtp-sdk] tools.onAfterInit failed (will retry on first use):",
|
|
86901
|
-
err2
|
|
86902
|
-
);
|
|
86836
|
+
logWithTimestamp("[xmtp-sdk] tools.onAfterInit failed:", err2);
|
|
86903
86837
|
}) : Promise.resolve();
|
|
86904
86838
|
if (sensitiveWordsResult.status === "fulfilled" && sensitiveWordsResult.value !== null) {
|
|
86905
86839
|
this.sensitiveWords = sensitiveWordsResult.value;
|
|
@@ -86997,10 +86931,6 @@ var XmtpService = class _XmtpService {
|
|
|
86997
86931
|
);
|
|
86998
86932
|
return this.clients;
|
|
86999
86933
|
}
|
|
87000
|
-
this.syncByAddress = loadSyncByAddress(this.dataDir);
|
|
87001
|
-
logWithTimestamp(
|
|
87002
|
-
`[xmtp-sdk] sync timestamps: ${this.syncByAddress.size} addresses on record`
|
|
87003
|
-
);
|
|
87004
86934
|
if (!this.tools.listAllAgentsWithMetadata) {
|
|
87005
86935
|
throw new Error("tools.listAllAgentsWithMetadata is required");
|
|
87006
86936
|
}
|
|
@@ -87328,25 +87258,6 @@ var XmtpService = class _XmtpService {
|
|
|
87328
87258
|
await this.startListeningForAddresses(
|
|
87329
87259
|
added.map((a) => a.communicationAddress)
|
|
87330
87260
|
);
|
|
87331
|
-
for (const agentInfo of added) {
|
|
87332
|
-
const address = agentInfo.communicationAddress;
|
|
87333
|
-
if (this.syncByAddress.has(address) && this.clients.has(address)) {
|
|
87334
|
-
logWithTimestamp(
|
|
87335
|
-
`[xmtp-sdk] refresh: ${address} has a prior sync timestamp, triggering offline replay`
|
|
87336
|
-
);
|
|
87337
|
-
this.replayOfflineMessagesForAddress(address).catch((err2) => {
|
|
87338
|
-
logWithTimestamp(`[xmtp-sdk] refresh: ${address} offline replay failed:`, err2);
|
|
87339
|
-
logger.error(
|
|
87340
|
-
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
87341
|
-
err2 instanceof Error ? err2 : new Error(String(err2)),
|
|
87342
|
-
{
|
|
87343
|
-
walletAddress: address,
|
|
87344
|
-
stage: "refreshAgents/replay"
|
|
87345
|
-
}
|
|
87346
|
-
);
|
|
87347
|
-
});
|
|
87348
|
-
}
|
|
87349
|
-
}
|
|
87350
87261
|
}
|
|
87351
87262
|
return {
|
|
87352
87263
|
added: added.map((a) => `${a.agentId} (${a.communicationAddress})`),
|
|
@@ -87358,11 +87269,8 @@ var XmtpService = class _XmtpService {
|
|
|
87358
87269
|
async recycleXmtpClients() {
|
|
87359
87270
|
await this._backupReady;
|
|
87360
87271
|
const startedAt = Date.now();
|
|
87361
|
-
const addresses = [];
|
|
87362
87272
|
let recycled = 0;
|
|
87363
87273
|
let failed = 0;
|
|
87364
|
-
let replayed = 0;
|
|
87365
|
-
let skipped2 = 0;
|
|
87366
87274
|
if (!this.tools.createSigner) {
|
|
87367
87275
|
throw new Error("tools.createSigner is required");
|
|
87368
87276
|
}
|
|
@@ -87417,10 +87325,6 @@ var XmtpService = class _XmtpService {
|
|
|
87417
87325
|
phase: "recycle"
|
|
87418
87326
|
});
|
|
87419
87327
|
await this.startListeningForAddresses([address]);
|
|
87420
|
-
const replaySummary = await this.replayOfflineMessagesForAddress(address);
|
|
87421
|
-
addresses.push(replaySummary);
|
|
87422
|
-
replayed += replaySummary.replayed;
|
|
87423
|
-
skipped2 += replaySummary.skipped;
|
|
87424
87328
|
recycled++;
|
|
87425
87329
|
} catch (err2) {
|
|
87426
87330
|
failed++;
|
|
@@ -87441,10 +87345,7 @@ var XmtpService = class _XmtpService {
|
|
|
87441
87345
|
clients: this.clients.size,
|
|
87442
87346
|
recycled,
|
|
87443
87347
|
failed,
|
|
87444
|
-
|
|
87445
|
-
skipped: skipped2,
|
|
87446
|
-
durationMs: Date.now() - startedAt,
|
|
87447
|
-
addresses
|
|
87348
|
+
durationMs: Date.now() - startedAt
|
|
87448
87349
|
};
|
|
87449
87350
|
}
|
|
87450
87351
|
setTools(tools) {
|
|
@@ -87713,7 +87614,6 @@ var XmtpService = class _XmtpService {
|
|
|
87713
87614
|
logWithTimestamp(`${tag} no client found, returning empty`);
|
|
87714
87615
|
return [];
|
|
87715
87616
|
}
|
|
87716
|
-
await agent.client.conversations.syncAll([import_node_bindings2.ConsentState.Unknown]);
|
|
87717
87617
|
const groups = await agent.client.conversations.list({
|
|
87718
87618
|
consentStates: [import_node_bindings2.ConsentState.Unknown]
|
|
87719
87619
|
});
|
|
@@ -87857,21 +87757,6 @@ var XmtpService = class _XmtpService {
|
|
|
87857
87757
|
onchainosAgentId: onchainosAgent?.agentId,
|
|
87858
87758
|
role: onchainosAgent?.role
|
|
87859
87759
|
};
|
|
87860
|
-
try {
|
|
87861
|
-
await agent.client.conversations.syncAll([
|
|
87862
|
-
import_node_bindings2.ConsentState.Allowed,
|
|
87863
|
-
import_node_bindings2.ConsentState.Unknown
|
|
87864
|
-
]);
|
|
87865
|
-
logWithTimestamp(`${tag} conversations synced (non-Denied)`);
|
|
87866
|
-
} catch (err2) {
|
|
87867
|
-
logWithTimestamp(`${tag} conversation sync failed, skipping this client:`, err2);
|
|
87868
|
-
logger.error(
|
|
87869
|
-
LogEvent.CONVERSATIONS_STREAM_FAILED,
|
|
87870
|
-
err2 instanceof Error ? err2 : void 0,
|
|
87871
|
-
agentExtras(identity3)
|
|
87872
|
-
);
|
|
87873
|
-
return;
|
|
87874
|
-
}
|
|
87875
87760
|
agent.use(loggingMiddleware(identity3));
|
|
87876
87761
|
agent.use(selfFilterMiddleware());
|
|
87877
87762
|
const inboundFactory = this.tools.createInboundMiddleware;
|
|
@@ -87880,15 +87765,7 @@ var XmtpService = class _XmtpService {
|
|
|
87880
87765
|
inboundFactory({
|
|
87881
87766
|
myXmtpAddress: address,
|
|
87882
87767
|
getTools: () => this.tools,
|
|
87883
|
-
allowGroup: (addr, gid) => this.allowGroup(addr, gid)
|
|
87884
|
-
onMessageProcessed: (sentAtMs) => {
|
|
87885
|
-
const newTs = Math.max(
|
|
87886
|
-
this.syncByAddress.get(address) ?? 0,
|
|
87887
|
-
sentAtMs + 1
|
|
87888
|
-
);
|
|
87889
|
-
this.syncByAddress.set(address, newTs);
|
|
87890
|
-
saveSyncForAddress(this.dataDir, address, newTs);
|
|
87891
|
-
}
|
|
87768
|
+
allowGroup: (addr, gid) => this.allowGroup(addr, gid)
|
|
87892
87769
|
})
|
|
87893
87770
|
);
|
|
87894
87771
|
} else {
|
|
@@ -87896,14 +87773,6 @@ var XmtpService = class _XmtpService {
|
|
|
87896
87773
|
`${tag} tools.createInboundMiddleware not injected \u2014 inbound routing disabled`
|
|
87897
87774
|
);
|
|
87898
87775
|
}
|
|
87899
|
-
if (!this.syncByAddress.has(address)) {
|
|
87900
|
-
const initialSyncMs = Date.now();
|
|
87901
|
-
this.syncByAddress.set(address, initialSyncMs);
|
|
87902
|
-
saveSyncForAddress(this.dataDir, address, initialSyncMs);
|
|
87903
|
-
logWithTimestamp(
|
|
87904
|
-
`${tag} initialized sync timestamp at ${new Date(initialSyncMs).toISOString()}`
|
|
87905
|
-
);
|
|
87906
|
-
}
|
|
87907
87776
|
const MAX_RETRIES = 5;
|
|
87908
87777
|
const BASE_DELAY_MS = 1e3;
|
|
87909
87778
|
const startWithRetry = async (attempt = 0) => {
|
|
@@ -87912,7 +87781,7 @@ var XmtpService = class _XmtpService {
|
|
|
87912
87781
|
return;
|
|
87913
87782
|
}
|
|
87914
87783
|
try {
|
|
87915
|
-
await agent.start();
|
|
87784
|
+
await agent.start({ disableSync: true });
|
|
87916
87785
|
} catch (err2) {
|
|
87917
87786
|
logWithTimestamp(`${tag} agent.start error (attempt=${attempt}):`, err2);
|
|
87918
87787
|
logger.error(
|
|
@@ -87948,250 +87817,7 @@ var XmtpService = class _XmtpService {
|
|
|
87948
87817
|
logWithTimestamp(`${tag} message listener started`);
|
|
87949
87818
|
});
|
|
87950
87819
|
}
|
|
87951
|
-
async replayOfflineMessagesForAddress(address) {
|
|
87952
|
-
const addressReplayStartedAt = Date.now();
|
|
87953
|
-
const summary = createOfflineReplayAddressSummary(address);
|
|
87954
|
-
const agent = this.clients.get(address);
|
|
87955
|
-
if (!agent) {
|
|
87956
|
-
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
87957
|
-
return summary;
|
|
87958
|
-
}
|
|
87959
|
-
const lastSyncMs = this.syncByAddress.get(address);
|
|
87960
|
-
const tag = `[xmtp-sdk:replay:${address}]`;
|
|
87961
|
-
if (lastSyncMs === void 0) {
|
|
87962
|
-
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
87963
|
-
return summary;
|
|
87964
|
-
}
|
|
87965
|
-
const sentAfterNs = lastSyncMs * 1e6;
|
|
87966
|
-
const myInboxId = agent.client.inboxId;
|
|
87967
|
-
const handlerDeps = {
|
|
87968
|
-
myXmtpAddress: address,
|
|
87969
|
-
getTools: () => this.tools,
|
|
87970
|
-
allowGroup: (addr, gid) => this.allowGroup(addr, gid)
|
|
87971
|
-
};
|
|
87972
|
-
const processOffline = this.tools.processOfflineMessage;
|
|
87973
|
-
if (!processOffline) {
|
|
87974
|
-
logWithTimestamp(
|
|
87975
|
-
`${tag} tools.processOfflineMessage not injected \u2014 offline replay skipped`
|
|
87976
|
-
);
|
|
87977
|
-
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
87978
|
-
return summary;
|
|
87979
|
-
}
|
|
87980
|
-
let conversations;
|
|
87981
|
-
try {
|
|
87982
|
-
const syncAllStartedAt = Date.now();
|
|
87983
|
-
await agent.client.conversations.syncAll([
|
|
87984
|
-
import_node_bindings2.ConsentState.Allowed,
|
|
87985
|
-
import_node_bindings2.ConsentState.Unknown
|
|
87986
|
-
]);
|
|
87987
|
-
summary.syncAllMs = Date.now() - syncAllStartedAt;
|
|
87988
|
-
const listStartedAt = Date.now();
|
|
87989
|
-
conversations = await agent.client.conversations.list({
|
|
87990
|
-
consentStates: [import_node_bindings2.ConsentState.Allowed, import_node_bindings2.ConsentState.Unknown]
|
|
87991
|
-
});
|
|
87992
|
-
summary.listMs = Date.now() - listStartedAt;
|
|
87993
|
-
summary.conversations = conversations.length;
|
|
87994
|
-
} catch (err2) {
|
|
87995
|
-
logWithTimestamp(`${tag} conversation sync/list failed, skipping:`, err2);
|
|
87996
|
-
logger.error(
|
|
87997
|
-
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
87998
|
-
err2 instanceof Error ? err2 : void 0,
|
|
87999
|
-
{
|
|
88000
|
-
walletAddress: address,
|
|
88001
|
-
stage: "syncAll/list"
|
|
88002
|
-
}
|
|
88003
|
-
);
|
|
88004
|
-
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
88005
|
-
return summary;
|
|
88006
|
-
}
|
|
88007
|
-
for (const conv of conversations) {
|
|
88008
|
-
try {
|
|
88009
|
-
const messagesStartedAt = Date.now();
|
|
88010
|
-
const allMessages = await conv.messages({ sentAfterNs });
|
|
88011
|
-
const messagesMs = Date.now() - messagesStartedAt;
|
|
88012
|
-
summary.messagesMs += messagesMs;
|
|
88013
|
-
if (allMessages.length === 0) {
|
|
88014
|
-
summary.emptyConversations++;
|
|
88015
|
-
continue;
|
|
88016
|
-
}
|
|
88017
|
-
summary.conversationsWithMessages++;
|
|
88018
|
-
const missed = allMessages.filter(
|
|
88019
|
-
(msg) => msg.senderInboxId !== myInboxId && (!msg.kind || msg.kind === "application")
|
|
88020
|
-
).sort((a, b) => {
|
|
88021
|
-
const ta = typeof a.sentAtNs === "bigint" ? Number(a.sentAtNs) : Number(a.sentAt ?? 0);
|
|
88022
|
-
const tb = typeof b.sentAtNs === "bigint" ? Number(b.sentAtNs) : Number(b.sentAt ?? 0);
|
|
88023
|
-
return ta - tb;
|
|
88024
|
-
});
|
|
88025
|
-
if (missed.length === 0) {
|
|
88026
|
-
summary.selfOnlyConversations++;
|
|
88027
|
-
const latestMs = allMessages.reduce((max, m) => {
|
|
88028
|
-
const ms = typeof m.sentAtNs === "bigint" ? Number(m.sentAtNs / 1000000n) : Number(m.sentAt ?? 0);
|
|
88029
|
-
return ms > max ? ms : max;
|
|
88030
|
-
}, 0);
|
|
88031
|
-
if (latestMs > 0) {
|
|
88032
|
-
const newTs = Math.max(
|
|
88033
|
-
this.syncByAddress.get(address) ?? 0,
|
|
88034
|
-
latestMs + 1
|
|
88035
|
-
);
|
|
88036
|
-
this.syncByAddress.set(address, newTs);
|
|
88037
|
-
saveSyncForAddress(this.dataDir, address, newTs);
|
|
88038
|
-
}
|
|
88039
|
-
continue;
|
|
88040
|
-
}
|
|
88041
|
-
summary.conversationsWithMissedMessages++;
|
|
88042
|
-
for (const msg of missed) {
|
|
88043
|
-
const content3 = typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content);
|
|
88044
|
-
const preview = content3.length > 80 ? `${content3.slice(0, 80)}...` : content3;
|
|
88045
|
-
const msgSentMs = typeof msg.sentAtNs === "bigint" ? Number(msg.sentAtNs / 1000000n) : Number(msg.sentAt ?? Date.now());
|
|
88046
|
-
try {
|
|
88047
|
-
const senderInboxId = msg.senderInboxId;
|
|
88048
|
-
let cachedSenderAddress = "";
|
|
88049
|
-
let resolved = false;
|
|
88050
|
-
const resolveSenderAddress = async () => {
|
|
88051
|
-
if (resolved) {
|
|
88052
|
-
return cachedSenderAddress;
|
|
88053
|
-
}
|
|
88054
|
-
try {
|
|
88055
|
-
const state = await agent.client.preferences.inboxStateFromInboxIds([senderInboxId]);
|
|
88056
|
-
cachedSenderAddress = state?.[0]?.identifiers?.[0]?.identifier ?? "";
|
|
88057
|
-
} catch {
|
|
88058
|
-
cachedSenderAddress = "";
|
|
88059
|
-
}
|
|
88060
|
-
resolved = true;
|
|
88061
|
-
return cachedSenderAddress;
|
|
88062
|
-
};
|
|
88063
|
-
const fakeCtx = {
|
|
88064
|
-
message: {
|
|
88065
|
-
id: msg.id,
|
|
88066
|
-
senderInboxId,
|
|
88067
|
-
content: msg.content,
|
|
88068
|
-
sentAtNs: msg.sentAtNs,
|
|
88069
|
-
sentAt: msg.sentAt
|
|
88070
|
-
},
|
|
88071
|
-
conversation: conv,
|
|
88072
|
-
getSenderAddress: resolveSenderAddress
|
|
88073
|
-
};
|
|
88074
|
-
const handleStartedAt = Date.now();
|
|
88075
|
-
const handled = await processOffline(fakeCtx, handlerDeps, {
|
|
88076
|
-
skipNotify: true
|
|
88077
|
-
});
|
|
88078
|
-
const handleMs = Date.now() - handleStartedAt;
|
|
88079
|
-
summary.handleMs += handleMs;
|
|
88080
|
-
if (handled) {
|
|
88081
|
-
logWithTimestamp(
|
|
88082
|
-
`${tag} replayed content=${preview}`
|
|
88083
|
-
);
|
|
88084
|
-
summary.replayed++;
|
|
88085
|
-
logger.info(LogEvent.OFFLINE_REPLAY_MESSAGE_REPLAYED, {
|
|
88086
|
-
...agentExtras({
|
|
88087
|
-
walletAddress: address,
|
|
88088
|
-
inboxId: agent.client?.inboxId,
|
|
88089
|
-
onchainosAgentId: this.getAgentByAddress(address)?.agentId,
|
|
88090
|
-
role: this.getAgentByAddress(address)?.role
|
|
88091
|
-
}),
|
|
88092
|
-
...jobIdExtras(msg.content),
|
|
88093
|
-
messageId: msg.id,
|
|
88094
|
-
conversationId: conv.id,
|
|
88095
|
-
stage: "offlineReplay/handleMessage",
|
|
88096
|
-
xmtpSentAtMs: String(msgSentMs),
|
|
88097
|
-
replayLagMs: String(Math.max(0, Date.now() - msgSentMs)),
|
|
88098
|
-
handleMs: String(handleMs)
|
|
88099
|
-
});
|
|
88100
|
-
} else {
|
|
88101
|
-
summary.skipped++;
|
|
88102
|
-
}
|
|
88103
|
-
} catch (err2) {
|
|
88104
|
-
logWithTimestamp(`${tag} replay handling failed: msgId=${msg.id}`, err2);
|
|
88105
|
-
logger.error(
|
|
88106
|
-
LogEvent.OFFLINE_REPLAY_MESSAGE_FAILED,
|
|
88107
|
-
err2 instanceof Error ? err2 : void 0,
|
|
88108
|
-
{
|
|
88109
|
-
walletAddress: address,
|
|
88110
|
-
...jobIdExtras(msg.content),
|
|
88111
|
-
messageId: msg.id,
|
|
88112
|
-
conversationId: conv.id,
|
|
88113
|
-
stage: "offlineReplay/handleMessage",
|
|
88114
|
-
reason: err2 instanceof Error ? err2.name : "unknown_error"
|
|
88115
|
-
}
|
|
88116
|
-
);
|
|
88117
|
-
} finally {
|
|
88118
|
-
const newTs = Math.max(
|
|
88119
|
-
this.syncByAddress.get(address) ?? 0,
|
|
88120
|
-
msgSentMs + 1
|
|
88121
|
-
);
|
|
88122
|
-
this.syncByAddress.set(address, newTs);
|
|
88123
|
-
saveSyncForAddress(this.dataDir, address, newTs);
|
|
88124
|
-
}
|
|
88125
|
-
}
|
|
88126
|
-
} catch (err2) {
|
|
88127
|
-
logWithTimestamp(`${tag} failed to read messages from conversation ${conv.id}:`, err2);
|
|
88128
|
-
logger.error(
|
|
88129
|
-
LogEvent.OFFLINE_REPLAY_FAILED,
|
|
88130
|
-
err2 instanceof Error ? err2 : void 0,
|
|
88131
|
-
{
|
|
88132
|
-
walletAddress: address,
|
|
88133
|
-
stage: "offlineReplay/readConversation",
|
|
88134
|
-
reason: err2 instanceof Error ? err2.name : "unknown_error",
|
|
88135
|
-
conversationId: conv.id
|
|
88136
|
-
}
|
|
88137
|
-
);
|
|
88138
|
-
}
|
|
88139
|
-
}
|
|
88140
|
-
logger.info(LogEvent.ADDRESS_SYNC_COMPLETED, {
|
|
88141
|
-
...agentExtras({
|
|
88142
|
-
walletAddress: address,
|
|
88143
|
-
inboxId: agent.client?.inboxId,
|
|
88144
|
-
onchainosAgentId: this.getAgentByAddress(address)?.agentId
|
|
88145
|
-
}),
|
|
88146
|
-
replayed: String(summary.replayed),
|
|
88147
|
-
skipped: String(summary.skipped),
|
|
88148
|
-
conversationCount: String(summary.conversations),
|
|
88149
|
-
durationMs: String(Date.now() - addressReplayStartedAt)
|
|
88150
|
-
});
|
|
88151
|
-
summary.durationMs = Date.now() - addressReplayStartedAt;
|
|
88152
|
-
return summary;
|
|
88153
|
-
}
|
|
88154
|
-
async replayOfflineMessages() {
|
|
88155
|
-
await this._backupReady;
|
|
88156
|
-
const replayStartedAt = Date.now();
|
|
88157
|
-
let totalReplayed = 0;
|
|
88158
|
-
let totalSkipped = 0;
|
|
88159
|
-
const addresses = [];
|
|
88160
|
-
for (const address of this.clients.keys()) {
|
|
88161
|
-
const summary2 = await this.replayOfflineMessagesForAddress(address);
|
|
88162
|
-
addresses.push(summary2);
|
|
88163
|
-
const { replayed, skipped: skipped2 } = summary2;
|
|
88164
|
-
totalReplayed += replayed;
|
|
88165
|
-
totalSkipped += skipped2;
|
|
88166
|
-
}
|
|
88167
|
-
const summary = {
|
|
88168
|
-
clients: this.clients.size,
|
|
88169
|
-
addressesWithTimestamps: this.syncByAddress.size,
|
|
88170
|
-
replayed: totalReplayed,
|
|
88171
|
-
skipped: totalSkipped,
|
|
88172
|
-
durationMs: Date.now() - replayStartedAt,
|
|
88173
|
-
addresses
|
|
88174
|
-
};
|
|
88175
|
-
return summary;
|
|
88176
|
-
}
|
|
88177
87820
|
};
|
|
88178
|
-
function createOfflineReplayAddressSummary(address) {
|
|
88179
|
-
return {
|
|
88180
|
-
address,
|
|
88181
|
-
replayed: 0,
|
|
88182
|
-
skipped: 0,
|
|
88183
|
-
conversations: 0,
|
|
88184
|
-
conversationsWithMessages: 0,
|
|
88185
|
-
conversationsWithMissedMessages: 0,
|
|
88186
|
-
emptyConversations: 0,
|
|
88187
|
-
selfOnlyConversations: 0,
|
|
88188
|
-
syncAllMs: 0,
|
|
88189
|
-
listMs: 0,
|
|
88190
|
-
messagesMs: 0,
|
|
88191
|
-
handleMs: 0,
|
|
88192
|
-
durationMs: 0
|
|
88193
|
-
};
|
|
88194
|
-
}
|
|
88195
87821
|
|
|
88196
87822
|
// ../core/src/a2a/pending-conversation.ts
|
|
88197
87823
|
var PENDING_CONVERSATION_BACKUP_NOTICE_TEMPLATE = "[event:provider_conversation][jobId:${jobId}] There are new conversation requests pending.";
|
|
@@ -89613,7 +89239,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
89613
89239
|
client: {
|
|
89614
89240
|
id: "gateway-client",
|
|
89615
89241
|
displayName: "okx-a2a-node",
|
|
89616
|
-
version: "0.1.
|
|
89242
|
+
version: "0.1.10-beta-114515ea34-260721221928",
|
|
89617
89243
|
platform: "node",
|
|
89618
89244
|
mode: "backend",
|
|
89619
89245
|
instanceId
|
|
@@ -89624,7 +89250,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
89624
89250
|
commands: [],
|
|
89625
89251
|
permissions: {},
|
|
89626
89252
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
89627
|
-
userAgent: `okx-a2a-node/${"0.1.
|
|
89253
|
+
userAgent: `okx-a2a-node/${"0.1.10-beta-114515ea34-260721221928"}`,
|
|
89628
89254
|
auth: {
|
|
89629
89255
|
...config.token ? { token: config.token } : {},
|
|
89630
89256
|
...config.password ? { password: config.password } : {}
|
|
@@ -91059,10 +90685,6 @@ function selectAnyJobTarget(messages) {
|
|
|
91059
90685
|
return null;
|
|
91060
90686
|
}
|
|
91061
90687
|
async function findConversation(agent, target) {
|
|
91062
|
-
await agent.client.conversations.syncAll([
|
|
91063
|
-
import_node_bindings2.ConsentState.Allowed,
|
|
91064
|
-
import_node_bindings2.ConsentState.Unknown
|
|
91065
|
-
]);
|
|
91066
90688
|
const conversations = await agent.client.conversations.list({
|
|
91067
90689
|
consentStates: [import_node_bindings2.ConsentState.Allowed, import_node_bindings2.ConsentState.Unknown]
|
|
91068
90690
|
});
|
|
@@ -91079,10 +90701,6 @@ async function findConversation(agent, target) {
|
|
|
91079
90701
|
return null;
|
|
91080
90702
|
}
|
|
91081
90703
|
async function findGroupConversation(agent, groupId) {
|
|
91082
|
-
await agent.client.conversations.syncAll([
|
|
91083
|
-
import_node_bindings2.ConsentState.Allowed,
|
|
91084
|
-
import_node_bindings2.ConsentState.Unknown
|
|
91085
|
-
]);
|
|
91086
90704
|
const conversation = await agent.client.conversations.getConversationById(groupId);
|
|
91087
90705
|
return conversation instanceof Group ? conversation : null;
|
|
91088
90706
|
}
|
|
@@ -92427,7 +92045,6 @@ async function handleXmtpGetConversationHistory(command, params) {
|
|
|
92427
92045
|
if (!conversation) {
|
|
92428
92046
|
return [];
|
|
92429
92047
|
}
|
|
92430
|
-
await conversation.sync();
|
|
92431
92048
|
const options = command.limit ? { limit: command.limit } : void 0;
|
|
92432
92049
|
const messages = await conversation.messages(options);
|
|
92433
92050
|
const invalidStore = new InvalidXmtpMessageStore(params.homeDir);
|
|
@@ -93521,7 +93138,7 @@ async function processFileMessage(ctx, deps, options = {}) {
|
|
|
93521
93138
|
messageId: systemMessageId,
|
|
93522
93139
|
systemEvent: systemNotification.event ?? "",
|
|
93523
93140
|
stage: "inbound/system_notification_received",
|
|
93524
|
-
source:
|
|
93141
|
+
source: "live",
|
|
93525
93142
|
isDirectCommunication: String(systemNotification.isDirectCommunication),
|
|
93526
93143
|
providerBinding: providerGate.provider ?? "",
|
|
93527
93144
|
providerBindingCreated: String(providerGate.created)
|
|
@@ -93553,7 +93170,7 @@ async function processFileMessage(ctx, deps, options = {}) {
|
|
|
93553
93170
|
targetCount: String(targets.length),
|
|
93554
93171
|
systemEvent: systemNotification.event ?? "",
|
|
93555
93172
|
stage: "inbound/system_notification_routed",
|
|
93556
|
-
source:
|
|
93173
|
+
source: "live",
|
|
93557
93174
|
isDirectCommunication: String(systemNotification.isDirectCommunication)
|
|
93558
93175
|
}));
|
|
93559
93176
|
if (!options.skipNotify) {
|
|
@@ -93858,10 +93475,7 @@ function createFileMessageHandler(deps) {
|
|
|
93858
93475
|
return;
|
|
93859
93476
|
}
|
|
93860
93477
|
try {
|
|
93861
|
-
|
|
93862
|
-
if (handled) {
|
|
93863
|
-
deps.onMessageProcessed?.(extractXmtpSentAtMs2(ctx.message));
|
|
93864
|
-
}
|
|
93478
|
+
await processFileMessage(ctx, deps);
|
|
93865
93479
|
} catch (err2) {
|
|
93866
93480
|
logWithTimestamp(`[okx-agent-task:${deps.myXmtpAddress}] process message failed:`, err2);
|
|
93867
93481
|
}
|
|
@@ -93873,21 +93487,10 @@ function createMiddlewareFromCoreDeps(store, deps, extra) {
|
|
|
93873
93487
|
store,
|
|
93874
93488
|
sessionStore: extra?.sessionStore,
|
|
93875
93489
|
allowGroup: deps.allowGroup,
|
|
93876
|
-
onMessageProcessed: deps.onMessageProcessed,
|
|
93877
93490
|
onJobMessageStored: extra?.onJobMessageStored,
|
|
93878
93491
|
onSessionMessage: extra?.onSessionMessage
|
|
93879
93492
|
});
|
|
93880
93493
|
}
|
|
93881
|
-
function processOfflineFromCoreDeps(store, ctx, deps, options) {
|
|
93882
|
-
return processFileMessage(ctx, {
|
|
93883
|
-
myXmtpAddress: deps.myXmtpAddress,
|
|
93884
|
-
store,
|
|
93885
|
-
sessionStore: options.sessionStore,
|
|
93886
|
-
allowGroup: deps.allowGroup,
|
|
93887
|
-
onJobMessageStored: options.onJobMessageStored,
|
|
93888
|
-
onSessionMessage: options.onSessionMessage
|
|
93889
|
-
}, { ...options, source: "replay" });
|
|
93890
|
-
}
|
|
93891
93494
|
function buildSystemStoredMessage(params) {
|
|
93892
93495
|
const now = Date.now();
|
|
93893
93496
|
return {
|
|
@@ -94181,17 +93784,9 @@ init_daemon_lock();
|
|
|
94181
93784
|
init_ai_provider();
|
|
94182
93785
|
init_sentry_logger();
|
|
94183
93786
|
init_sentry_config();
|
|
94184
|
-
var DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC = 300;
|
|
94185
93787
|
var DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC = 6 * 60 * 60;
|
|
94186
93788
|
var XMTP_CLIENT_RECYCLE_INTERVAL_ENV = "OKX_A2A_XMTP_CLIENT_RECYCLE_INTERVAL_SEC";
|
|
94187
93789
|
var HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS = 2e3;
|
|
94188
|
-
function resolveOfflineReplayIntervalSec(systemConfig) {
|
|
94189
|
-
const interval = systemConfig.offlineReplayInterval;
|
|
94190
|
-
if (typeof interval !== "number" || !Number.isFinite(interval) || interval <= 0) {
|
|
94191
|
-
return DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC;
|
|
94192
|
-
}
|
|
94193
|
-
return interval;
|
|
94194
|
-
}
|
|
94195
93790
|
function resolveXmtpClientRecycleIntervalSec(systemConfig, env = process.env) {
|
|
94196
93791
|
const rawEnvInterval = env[XMTP_CLIENT_RECYCLE_INTERVAL_ENV]?.trim();
|
|
94197
93792
|
if (rawEnvInterval) {
|
|
@@ -94395,16 +93990,6 @@ async function runListenerWithLock(options, paths) {
|
|
|
94395
93990
|
await enqueueAiSessionMessageDispatch({ commands, event });
|
|
94396
93991
|
}
|
|
94397
93992
|
}),
|
|
94398
|
-
processOfflineMessage: (ctx, deps, replayOptions) => processOfflineFromCoreDeps(store, ctx, deps, {
|
|
94399
|
-
...replayOptions,
|
|
94400
|
-
sessionStore,
|
|
94401
|
-
onJobMessageStored: async (event) => {
|
|
94402
|
-
await enqueueAiJobMessageDispatch({ commands, event });
|
|
94403
|
-
},
|
|
94404
|
-
onSessionMessage: async (event) => {
|
|
94405
|
-
await enqueueAiSessionMessageDispatch({ commands, event });
|
|
94406
|
-
}
|
|
94407
|
-
}),
|
|
94408
93993
|
notifySessionExpired: (command) => {
|
|
94409
93994
|
const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login\` and restart \`okx-a2a\`.`;
|
|
94410
93995
|
void store.appendBackup(buildSystemStoredMessage({
|
|
@@ -94420,12 +94005,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
94420
94005
|
});
|
|
94421
94006
|
}
|
|
94422
94007
|
});
|
|
94423
|
-
service.setPluginVersion("0.1.
|
|
94008
|
+
service.setPluginVersion("0.1.10-beta-114515ea34-260721221928");
|
|
94424
94009
|
await service.init();
|
|
94425
94010
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
94426
94011
|
if (pluginVersionStatus.unavailable) {
|
|
94427
94012
|
throw new Error(
|
|
94428
|
-
`@okxweb3/a2a-node v${"0.1.
|
|
94013
|
+
`@okxweb3/a2a-node v${"0.1.10-beta-114515ea34-260721221928"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
94429
94014
|
);
|
|
94430
94015
|
}
|
|
94431
94016
|
const systemConfig = service.getSystemConfig();
|
|
@@ -94443,14 +94028,13 @@ async function runListenerWithLock(options, paths) {
|
|
|
94443
94028
|
onchainosAgentId: "*",
|
|
94444
94029
|
reason: "system-config missing sentryDsn",
|
|
94445
94030
|
pluginId: "@okxweb3/a2a-node",
|
|
94446
|
-
pluginVersion: "0.1.
|
|
94031
|
+
pluginVersion: "0.1.10-beta-114515ea34-260721221928"
|
|
94447
94032
|
});
|
|
94448
94033
|
}
|
|
94449
94034
|
logWithTimestamp(
|
|
94450
94035
|
`[okx-agent-task] listener initialized, clients=${service.getClients().size}, home=${store.homeDir}`
|
|
94451
94036
|
);
|
|
94452
94037
|
let maintenanceInFlight = null;
|
|
94453
|
-
let lastRecycleReplayAtMs = 0;
|
|
94454
94038
|
let xmtpRecyclePending = false;
|
|
94455
94039
|
const tryEnterMaintenanceTask = (task) => {
|
|
94456
94040
|
if (task !== "xmtp_recycle" && xmtpRecyclePending) {
|
|
@@ -94570,48 +94154,6 @@ async function runListenerWithLock(options, paths) {
|
|
|
94570
94154
|
leaveMaintenanceTask("sync");
|
|
94571
94155
|
}
|
|
94572
94156
|
};
|
|
94573
|
-
const offlineReplayTick = async () => {
|
|
94574
|
-
if (!tryEnterMaintenanceTask("offline_replay")) {
|
|
94575
|
-
return;
|
|
94576
|
-
}
|
|
94577
|
-
const tickStartedAt = Date.now();
|
|
94578
|
-
try {
|
|
94579
|
-
if (lastRecycleReplayAtMs > 0 && Date.now() - lastRecycleReplayAtMs < offlineReplayIntervalSec * 1e3) {
|
|
94580
|
-
logWithTimestamp(
|
|
94581
|
-
`[okx-agent-task] offline replay skipped: recent recycle replay ${Date.now() - lastRecycleReplayAtMs}ms ago interval=${offlineReplayIntervalSec}s`
|
|
94582
|
-
);
|
|
94583
|
-
return;
|
|
94584
|
-
}
|
|
94585
|
-
const replayResult = await timeSettled(() => service.replayOfflineMessages());
|
|
94586
|
-
const replayMs = replayResult.durationMs;
|
|
94587
|
-
if (replayResult.error) {
|
|
94588
|
-
logger.error(LogEvent.OFFLINE_REPLAY_FAILED, replayResult.error instanceof Error ? replayResult.error : new Error(String(replayResult.error)), {
|
|
94589
|
-
component: "node_listener",
|
|
94590
|
-
stage: "offline_replay_tick",
|
|
94591
|
-
reason: replayResult.error instanceof Error ? replayResult.error.name : "unknown_error",
|
|
94592
|
-
durationMs: String(replayMs),
|
|
94593
|
-
communicationClass: "xmtp_replay_or_storage"
|
|
94594
|
-
});
|
|
94595
|
-
logWithTimestamp(`[okx-agent-task] offline replay failed duration=${replayMs}ms:`, replayResult.error);
|
|
94596
|
-
return;
|
|
94597
|
-
}
|
|
94598
|
-
const replaySummary = replayResult.value;
|
|
94599
|
-
logWithTimestamp(
|
|
94600
|
-
`[okx-agent-task] offline replay tick clients=${replaySummary?.clients ?? service.getClients().size} replayed=${replaySummary?.replayed ?? 0} skipped=${replaySummary?.skipped ?? 0} duration=${replayMs}ms`
|
|
94601
|
-
);
|
|
94602
|
-
} catch (err2) {
|
|
94603
|
-
logger.error(LogEvent.OFFLINE_REPLAY_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), {
|
|
94604
|
-
component: "node_listener",
|
|
94605
|
-
stage: "offline_replay_tick",
|
|
94606
|
-
durationMs: String(Date.now() - tickStartedAt),
|
|
94607
|
-
reason: "offline_replay_tick_exception",
|
|
94608
|
-
communicationClass: "xmtp_replay_or_storage"
|
|
94609
|
-
});
|
|
94610
|
-
logWithTimestamp(`[okx-agent-task] offline replay tick failed total=${Date.now() - tickStartedAt}ms:`, err2);
|
|
94611
|
-
} finally {
|
|
94612
|
-
leaveMaintenanceTask("offline_replay");
|
|
94613
|
-
}
|
|
94614
|
-
};
|
|
94615
94157
|
const xmtpRecycleTick = async () => {
|
|
94616
94158
|
if (!tryEnterMaintenanceTask("xmtp_recycle")) {
|
|
94617
94159
|
xmtpRecyclePending = true;
|
|
@@ -94633,11 +94175,8 @@ async function runListenerWithLock(options, paths) {
|
|
|
94633
94175
|
return;
|
|
94634
94176
|
}
|
|
94635
94177
|
const recycleSummary = recycleResult.value;
|
|
94636
|
-
if ((recycleSummary?.recycled ?? 0) > 0) {
|
|
94637
|
-
lastRecycleReplayAtMs = Date.now();
|
|
94638
|
-
}
|
|
94639
94178
|
logWithTimestamp(
|
|
94640
|
-
`[okx-agent-task] XMTP client recycle tick clients=${recycleSummary?.clients ?? service.getClients().size} recycled=${recycleSummary?.recycled ?? 0} failed=${recycleSummary?.failed ?? 0}
|
|
94179
|
+
`[okx-agent-task] XMTP client recycle tick clients=${recycleSummary?.clients ?? service.getClients().size} recycled=${recycleSummary?.recycled ?? 0} failed=${recycleSummary?.failed ?? 0} duration=${recycleMs}ms`
|
|
94641
94180
|
);
|
|
94642
94181
|
} catch (err2) {
|
|
94643
94182
|
logger.error(LogEvent.XMTP_CONNECTION_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), {
|
|
@@ -94653,10 +94192,8 @@ async function runListenerWithLock(options, paths) {
|
|
|
94653
94192
|
}
|
|
94654
94193
|
};
|
|
94655
94194
|
let intervalSec = Math.max(10, service.getSystemConfig().heartbeatInterval);
|
|
94656
|
-
let offlineReplayIntervalSec = resolveOfflineReplayIntervalSec(service.getSystemConfig());
|
|
94657
94195
|
let xmtpClientRecycleIntervalSec = resolveXmtpClientRecycleIntervalSec(service.getSystemConfig());
|
|
94658
94196
|
let timer;
|
|
94659
|
-
let offlineReplayTimer;
|
|
94660
94197
|
let xmtpClientRecycleTimer;
|
|
94661
94198
|
let stopping = false;
|
|
94662
94199
|
const scheduleSyncTimer = (nextIntervalSec) => {
|
|
@@ -94672,21 +94209,6 @@ async function runListenerWithLock(options, paths) {
|
|
|
94672
94209
|
void syncTick();
|
|
94673
94210
|
}, intervalSec * 1e3);
|
|
94674
94211
|
};
|
|
94675
|
-
const scheduleOfflineReplayTimer = (nextIntervalSec) => {
|
|
94676
|
-
if (stopping) {
|
|
94677
|
-
return;
|
|
94678
|
-
}
|
|
94679
|
-
if (offlineReplayTimer) {
|
|
94680
|
-
clearInterval(offlineReplayTimer);
|
|
94681
|
-
}
|
|
94682
|
-
offlineReplayIntervalSec = resolveOfflineReplayIntervalSec({
|
|
94683
|
-
offlineReplayInterval: nextIntervalSec
|
|
94684
|
-
});
|
|
94685
|
-
logWithTimestamp(`[okx-agent-task] scheduled offline replay interval ${offlineReplayIntervalSec}s`);
|
|
94686
|
-
offlineReplayTimer = setInterval(() => {
|
|
94687
|
-
void offlineReplayTick();
|
|
94688
|
-
}, offlineReplayIntervalSec * 1e3);
|
|
94689
|
-
};
|
|
94690
94212
|
const scheduleXmtpClientRecycleTimer = (nextIntervalSec) => {
|
|
94691
94213
|
if (stopping) {
|
|
94692
94214
|
return;
|
|
@@ -94707,7 +94229,6 @@ async function runListenerWithLock(options, paths) {
|
|
|
94707
94229
|
return;
|
|
94708
94230
|
}
|
|
94709
94231
|
const previousIntervalSec = intervalSec;
|
|
94710
|
-
const previousOfflineReplayIntervalSec = offlineReplayIntervalSec;
|
|
94711
94232
|
const previousXmtpClientRecycleIntervalSec = xmtpClientRecycleIntervalSec;
|
|
94712
94233
|
try {
|
|
94713
94234
|
await service.refreshSystemConfig();
|
|
@@ -94722,13 +94243,6 @@ async function runListenerWithLock(options, paths) {
|
|
|
94722
94243
|
);
|
|
94723
94244
|
scheduleSyncTimer(nextIntervalSec);
|
|
94724
94245
|
}
|
|
94725
|
-
const nextOfflineReplayIntervalSec = resolveOfflineReplayIntervalSec(systemConfig2);
|
|
94726
|
-
if (nextOfflineReplayIntervalSec !== previousOfflineReplayIntervalSec) {
|
|
94727
|
-
logWithTimestamp(
|
|
94728
|
-
`[okx-agent-task] offline replay interval changed from ${previousOfflineReplayIntervalSec}s to ${nextOfflineReplayIntervalSec}s; rescheduling offline replay timer`
|
|
94729
|
-
);
|
|
94730
|
-
scheduleOfflineReplayTimer(nextOfflineReplayIntervalSec);
|
|
94731
|
-
}
|
|
94732
94246
|
const nextXmtpClientRecycleIntervalSec = resolveXmtpClientRecycleIntervalSec(systemConfig2);
|
|
94733
94247
|
if (nextXmtpClientRecycleIntervalSec !== previousXmtpClientRecycleIntervalSec) {
|
|
94734
94248
|
logWithTimestamp(
|
|
@@ -94746,15 +94260,11 @@ async function runListenerWithLock(options, paths) {
|
|
|
94746
94260
|
}
|
|
94747
94261
|
};
|
|
94748
94262
|
scheduleSyncTimer(intervalSec);
|
|
94749
|
-
scheduleOfflineReplayTimer(offlineReplayIntervalSec);
|
|
94750
94263
|
scheduleXmtpClientRecycleTimer(xmtpClientRecycleIntervalSec);
|
|
94751
94264
|
const systemConfigRefreshTimer = setInterval(() => {
|
|
94752
94265
|
void refreshSystemConfigTick();
|
|
94753
94266
|
}, 60 * 60 * 1e3);
|
|
94754
|
-
void (
|
|
94755
|
-
await syncTick();
|
|
94756
|
-
await offlineReplayTick();
|
|
94757
|
-
})();
|
|
94267
|
+
void syncTick();
|
|
94758
94268
|
const commandProcessor = startCommandProcessor({
|
|
94759
94269
|
service,
|
|
94760
94270
|
store,
|
|
@@ -94778,9 +94288,6 @@ async function runListenerWithLock(options, paths) {
|
|
|
94778
94288
|
if (timer) {
|
|
94779
94289
|
clearInterval(timer);
|
|
94780
94290
|
}
|
|
94781
|
-
if (offlineReplayTimer) {
|
|
94782
|
-
clearInterval(offlineReplayTimer);
|
|
94783
|
-
}
|
|
94784
94291
|
if (xmtpClientRecycleTimer) {
|
|
94785
94292
|
clearInterval(xmtpClientRecycleTimer);
|
|
94786
94293
|
}
|
|
@@ -96211,7 +95718,7 @@ async function runDoctor(options = {}) {
|
|
|
96211
95718
|
platform: options.platform ?? process.platform,
|
|
96212
95719
|
env: options.env ?? process.env,
|
|
96213
95720
|
target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
|
|
96214
|
-
cliVersion: options.cliVersion ?? (true ? "0.1.
|
|
95721
|
+
cliVersion: options.cliVersion ?? (true ? "0.1.10-beta-114515ea34-260721221928" : "0.0.0"),
|
|
96215
95722
|
fixMode: options.fix === true,
|
|
96216
95723
|
nonInteractive: options.nonInteractive === true,
|
|
96217
95724
|
packageChanged: false,
|
|
@@ -96437,7 +95944,6 @@ init_win_native_launcher();
|
|
|
96437
95944
|
BACKUP_JOB_ID,
|
|
96438
95945
|
CommandStore,
|
|
96439
95946
|
DEFAULT_AI_PERMISSION_PRESET,
|
|
96440
|
-
DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC,
|
|
96441
95947
|
DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC,
|
|
96442
95948
|
DOCTOR_MIN_NODE_VERSION,
|
|
96443
95949
|
GatewayOutboundBehavior,
|
|
@@ -96557,7 +96063,6 @@ init_win_native_launcher();
|
|
|
96557
96063
|
resolveDoctorTarget,
|
|
96558
96064
|
resolveEnvelopePayload,
|
|
96559
96065
|
resolveNpmCmdShimScript,
|
|
96560
|
-
resolveOfflineReplayIntervalSec,
|
|
96561
96066
|
resolveOpenClawGatewayConfig,
|
|
96562
96067
|
resolveOpenClawGatewayRoute,
|
|
96563
96068
|
resolveOpenClawGatewayRoutes,
|