@okxweb3/a2a-node 0.2.4-beta-e7a52faf6f-260811185020 → 0.2.4-beta-e7a52faf6f-260812154627
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 +190 -33
- package/dist/index.js +186 -28
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -26604,7 +26604,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
26604
26604
|
client: {
|
|
26605
26605
|
id: "gateway-client",
|
|
26606
26606
|
displayName: "okx-a2a-node",
|
|
26607
|
-
version: "0.2.4-beta-e7a52faf6f-
|
|
26607
|
+
version: "0.2.4-beta-e7a52faf6f-260812154627",
|
|
26608
26608
|
platform: "node",
|
|
26609
26609
|
mode: "backend",
|
|
26610
26610
|
instanceId
|
|
@@ -26615,7 +26615,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
26615
26615
|
commands: [],
|
|
26616
26616
|
permissions: {},
|
|
26617
26617
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
26618
|
-
userAgent: `okx-a2a-node/${"0.2.4-beta-e7a52faf6f-
|
|
26618
|
+
userAgent: `okx-a2a-node/${"0.2.4-beta-e7a52faf6f-260812154627"}`,
|
|
26619
26619
|
auth: {
|
|
26620
26620
|
...config.token ? { token: config.token } : {},
|
|
26621
26621
|
...config.password ? { password: config.password } : {}
|
|
@@ -28499,7 +28499,7 @@ var init_sentry_config = __esm({
|
|
|
28499
28499
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
28500
28500
|
SENTRY_CONFIG = {
|
|
28501
28501
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
28502
|
-
release: "0.2.4-beta-e7a52faf6f-
|
|
28502
|
+
release: "0.2.4-beta-e7a52faf6f-260812154627",
|
|
28503
28503
|
environment,
|
|
28504
28504
|
runtimeContainer: normalizeRuntimeContainer(process.env.OKX_A2A_RUNTIME_CONTAINER)
|
|
28505
28505
|
};
|
|
@@ -39669,7 +39669,7 @@ async function exportDiagnosticLogs(options) {
|
|
|
39669
39669
|
node: process.version,
|
|
39670
39670
|
platform: process.platform,
|
|
39671
39671
|
arch: process.arch,
|
|
39672
|
-
packageVersion: true ? "0.2.4-beta-e7a52faf6f-
|
|
39672
|
+
packageVersion: true ? "0.2.4-beta-e7a52faf6f-260812154627" : "unknown",
|
|
39673
39673
|
sensitiveContentIncluded: options.includeSensitiveContent,
|
|
39674
39674
|
listenerAndLlmContentIncluded: true,
|
|
39675
39675
|
credentialsAlwaysRedacted: true,
|
|
@@ -40783,7 +40783,7 @@ function redactArgsForLog(args) {
|
|
|
40783
40783
|
function commandForLog(bin, args) {
|
|
40784
40784
|
return `${bin} ${redactArgsForLog(args).join(" ")}`;
|
|
40785
40785
|
}
|
|
40786
|
-
async function exec(args) {
|
|
40786
|
+
async function exec(args, options = {}) {
|
|
40787
40787
|
const bin = await resolve9();
|
|
40788
40788
|
const cmd = commandForLog(bin, args);
|
|
40789
40789
|
logWithTimestamp(`[onchainos] exec: ${cmd}`);
|
|
@@ -40797,7 +40797,8 @@ async function exec(args) {
|
|
|
40797
40797
|
try {
|
|
40798
40798
|
const result = await execFileAsync2(invocation.command, invocation.args, {
|
|
40799
40799
|
windowsHide: true,
|
|
40800
|
-
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
40800
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments,
|
|
40801
|
+
timeout: options.timeoutMs
|
|
40801
40802
|
});
|
|
40802
40803
|
logWithTimestamp(
|
|
40803
40804
|
`[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
|
|
@@ -40830,7 +40831,8 @@ async function exec(args) {
|
|
|
40830
40831
|
stdoutBytes: String(Buffer.byteLength(String(err2?.stdout ?? ""), "utf8")),
|
|
40831
40832
|
cliErrorName: err2 instanceof Error ? err2.name : "",
|
|
40832
40833
|
cliErrorMessageLength: String(String(err2?.message ?? "").length),
|
|
40833
|
-
durationMs: String(Date.now() - t0)
|
|
40834
|
+
durationMs: String(Date.now() - t0),
|
|
40835
|
+
timeoutMs: String(options.timeoutMs ?? "")
|
|
40834
40836
|
}
|
|
40835
40837
|
);
|
|
40836
40838
|
throw err2;
|
|
@@ -58921,6 +58923,54 @@ var init_system_config = __esm({
|
|
|
58921
58923
|
}
|
|
58922
58924
|
});
|
|
58923
58925
|
|
|
58926
|
+
// ../core/src/xmtp-sdk/onchainos/wallet-status.ts
|
|
58927
|
+
function parseWalletLoginStatus(stdout) {
|
|
58928
|
+
const response = parseCliJson(stdout, "wallet-status");
|
|
58929
|
+
if (!response.ok) {
|
|
58930
|
+
const error = new Error("onchainos wallet status failed");
|
|
58931
|
+
logger.error(
|
|
58932
|
+
LogEvent.ONCHAINOS_CLI_ERROR,
|
|
58933
|
+
error,
|
|
58934
|
+
cliOkFalseExtras(stdout, "wallet-status")
|
|
58935
|
+
);
|
|
58936
|
+
throw error;
|
|
58937
|
+
}
|
|
58938
|
+
if (typeof response.data?.loggedIn !== "boolean") {
|
|
58939
|
+
const error = new Error("onchainos wallet status returned invalid loggedIn state");
|
|
58940
|
+
logger.error(LogEvent.ONCHAINOS_CLI_ERROR, error, {
|
|
58941
|
+
component: "onchainos_cli",
|
|
58942
|
+
source: "onchainos",
|
|
58943
|
+
stage: "response_validation",
|
|
58944
|
+
communicationClass: "onchainos_cli_or_api_issue",
|
|
58945
|
+
operation: "wallet-status",
|
|
58946
|
+
reason: "invalid_logged_in_state"
|
|
58947
|
+
});
|
|
58948
|
+
throw error;
|
|
58949
|
+
}
|
|
58950
|
+
return response.data.loggedIn;
|
|
58951
|
+
}
|
|
58952
|
+
async function queryWalletLoginStatus(options = {}) {
|
|
58953
|
+
logWithTimestamp("[onchainos] checking wallet login status");
|
|
58954
|
+
const { stdout } = await exec(
|
|
58955
|
+
["wallet", "status"],
|
|
58956
|
+
{ timeoutMs: options.timeoutMs ?? WALLET_STATUS_TIMEOUT_MS }
|
|
58957
|
+
);
|
|
58958
|
+
const loggedIn = parseWalletLoginStatus(stdout);
|
|
58959
|
+
logWithTimestamp(`[onchainos] wallet login status: ${loggedIn ? "logged in" : "logged out"}`);
|
|
58960
|
+
return loggedIn;
|
|
58961
|
+
}
|
|
58962
|
+
var WALLET_STATUS_TIMEOUT_MS;
|
|
58963
|
+
var init_wallet_status = __esm({
|
|
58964
|
+
"../core/src/xmtp-sdk/onchainos/wallet-status.ts"() {
|
|
58965
|
+
"use strict";
|
|
58966
|
+
init_log();
|
|
58967
|
+
init_sentry_logger();
|
|
58968
|
+
init_bin();
|
|
58969
|
+
init_cli_response();
|
|
58970
|
+
WALLET_STATUS_TIMEOUT_MS = 1e4;
|
|
58971
|
+
}
|
|
58972
|
+
});
|
|
58973
|
+
|
|
58924
58974
|
// ../core/src/xmtp-sdk/onchainos/index.ts
|
|
58925
58975
|
function messageEligibleUnavailableError(input) {
|
|
58926
58976
|
const lines = [
|
|
@@ -59005,19 +59055,22 @@ function logAgentListResponse(input) {
|
|
|
59005
59055
|
onchainosAgentListDiagnosticText: input.stderr
|
|
59006
59056
|
});
|
|
59007
59057
|
}
|
|
59008
|
-
async function fetchAgentPage(page) {
|
|
59058
|
+
async function fetchAgentPage(page, timeoutMs) {
|
|
59009
59059
|
const startedAt = Date.now();
|
|
59010
59060
|
let stdout;
|
|
59011
59061
|
let stderr;
|
|
59012
59062
|
try {
|
|
59013
|
-
({ stdout, stderr } = await exec(
|
|
59014
|
-
|
|
59015
|
-
|
|
59016
|
-
|
|
59017
|
-
|
|
59018
|
-
|
|
59019
|
-
|
|
59020
|
-
|
|
59063
|
+
({ stdout, stderr } = await exec(
|
|
59064
|
+
[
|
|
59065
|
+
"agent",
|
|
59066
|
+
"get",
|
|
59067
|
+
"--page",
|
|
59068
|
+
String(page),
|
|
59069
|
+
"--page-size",
|
|
59070
|
+
String(PAGE_SIZE)
|
|
59071
|
+
],
|
|
59072
|
+
{ timeoutMs }
|
|
59073
|
+
));
|
|
59021
59074
|
} catch (err2) {
|
|
59022
59075
|
const errStdout = typeof err2?.stdout === "string" ? err2.stdout : "";
|
|
59023
59076
|
const errStderr = typeof err2?.stderr === "string" ? err2.stderr : "";
|
|
@@ -59161,13 +59214,28 @@ async function fetchAgentByAddress(communicationAddress) {
|
|
|
59161
59214
|
agentByIdCache.set(res.data.agentId, res.data);
|
|
59162
59215
|
return res.data;
|
|
59163
59216
|
}
|
|
59164
|
-
async function listAllAgentsWithMetadata(previousFingerprint) {
|
|
59217
|
+
async function listAllAgentsWithMetadata(previousFingerprint, options = {}) {
|
|
59165
59218
|
const startedAt = Date.now();
|
|
59219
|
+
const pageTimeoutMs = positiveTimeoutOrDefault(
|
|
59220
|
+
options.pageTimeoutMs,
|
|
59221
|
+
AGENT_GET_PAGE_TIMEOUT_MS
|
|
59222
|
+
);
|
|
59223
|
+
const totalTimeoutMs = positiveTimeoutOrDefault(
|
|
59224
|
+
options.totalTimeoutMs,
|
|
59225
|
+
AGENT_LIST_TIMEOUT_MS
|
|
59226
|
+
);
|
|
59166
59227
|
const agents = [];
|
|
59167
59228
|
const stderrs = [];
|
|
59168
59229
|
let page = 1;
|
|
59169
59230
|
while (true) {
|
|
59170
|
-
const
|
|
59231
|
+
const remainingMs = totalTimeoutMs - (Date.now() - startedAt);
|
|
59232
|
+
if (remainingMs <= 0) {
|
|
59233
|
+
throw agentListTimeoutError(totalTimeoutMs);
|
|
59234
|
+
}
|
|
59235
|
+
const { data, stderr } = await fetchAgentPage(
|
|
59236
|
+
page,
|
|
59237
|
+
Math.min(pageTimeoutMs, remainingMs)
|
|
59238
|
+
);
|
|
59171
59239
|
if (stderr) {
|
|
59172
59240
|
stderrs.push(`page=${page}: ${stderr}`);
|
|
59173
59241
|
}
|
|
@@ -59194,6 +59262,14 @@ async function listAllAgentsWithMetadata(previousFingerprint) {
|
|
|
59194
59262
|
durationMs: Date.now() - startedAt
|
|
59195
59263
|
};
|
|
59196
59264
|
}
|
|
59265
|
+
function positiveTimeoutOrDefault(value, fallback) {
|
|
59266
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
59267
|
+
}
|
|
59268
|
+
function agentListTimeoutError(timeoutMs) {
|
|
59269
|
+
const error = new Error(`onchainos agent list timed out after ${timeoutMs}ms`);
|
|
59270
|
+
error.code = "ETIMEDOUT";
|
|
59271
|
+
return error;
|
|
59272
|
+
}
|
|
59197
59273
|
function fingerprintAgents(agents) {
|
|
59198
59274
|
return agents.map((a) => [
|
|
59199
59275
|
a.agentId,
|
|
@@ -59394,7 +59470,7 @@ async function fetchSensitiveWords() {
|
|
|
59394
59470
|
);
|
|
59395
59471
|
return result;
|
|
59396
59472
|
}
|
|
59397
|
-
var MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT, lastExpiredNotifyAt, EXPIRED_NOTIFY_COOLDOWN_MS, PAGE_SIZE, agentByIdCache, ONCHAINOS_CHAIN_INDEX;
|
|
59473
|
+
var MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT, lastExpiredNotifyAt, EXPIRED_NOTIFY_COOLDOWN_MS, PAGE_SIZE, AGENT_GET_PAGE_TIMEOUT_MS, AGENT_LIST_TIMEOUT_MS, agentByIdCache, ONCHAINOS_CHAIN_INDEX;
|
|
59398
59474
|
var init_onchainos = __esm({
|
|
59399
59475
|
"../core/src/xmtp-sdk/onchainos/index.ts"() {
|
|
59400
59476
|
"use strict";
|
|
@@ -59408,10 +59484,13 @@ var init_onchainos = __esm({
|
|
|
59408
59484
|
init_cli_response();
|
|
59409
59485
|
init_session_expired();
|
|
59410
59486
|
init_system_config();
|
|
59487
|
+
init_wallet_status();
|
|
59411
59488
|
MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT = "Message eligibility service is temporarily unavailable. Please try again later.";
|
|
59412
59489
|
lastExpiredNotifyAt = 0;
|
|
59413
59490
|
EXPIRED_NOTIFY_COOLDOWN_MS = 5 * 60 * 1e3;
|
|
59414
59491
|
PAGE_SIZE = 50;
|
|
59492
|
+
AGENT_GET_PAGE_TIMEOUT_MS = 1e4;
|
|
59493
|
+
AGENT_LIST_TIMEOUT_MS = 3e4;
|
|
59415
59494
|
agentByIdCache = /* @__PURE__ */ new Map();
|
|
59416
59495
|
ONCHAINOS_CHAIN_INDEX = "196";
|
|
59417
59496
|
}
|
|
@@ -67023,6 +67102,8 @@ var init_user_attention_watchers = __esm({
|
|
|
67023
67102
|
// src/listener.ts
|
|
67024
67103
|
var listener_exports = {};
|
|
67025
67104
|
__export(listener_exports, {
|
|
67105
|
+
AUTH_RECOVERY_PROBE_INTERVAL_MS: () => AUTH_RECOVERY_PROBE_INTERVAL_MS,
|
|
67106
|
+
AUTH_RECOVERY_REFRESH_BACKOFF_MS: () => AUTH_RECOVERY_REFRESH_BACKOFF_MS,
|
|
67026
67107
|
AgentRefreshAuthGate: () => AgentRefreshAuthGate,
|
|
67027
67108
|
AgentRefreshCoordinator: () => AgentRefreshCoordinator,
|
|
67028
67109
|
DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC: () => DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC,
|
|
@@ -67248,10 +67329,11 @@ async function runListenerWithLock(options, paths) {
|
|
|
67248
67329
|
const agentRefreshCoordinator = new AgentRefreshCoordinator({
|
|
67249
67330
|
lookup: (previousFingerprint) => listAllAgentsWithMetadata(previousFingerprint),
|
|
67250
67331
|
refresh: () => service.refreshAgents(),
|
|
67332
|
+
checkLoggedIn: () => queryWalletLoginStatus(),
|
|
67251
67333
|
isStopping: () => stopping,
|
|
67252
67334
|
onAuthBlocked: () => {
|
|
67253
67335
|
logWithTimestamp(
|
|
67254
|
-
"[okx-agent-task] agent refresh auth blocked; periodic agent get paused.
|
|
67336
|
+
"[okx-agent-task] agent refresh auth blocked; periodic agent get paused. Wallet login recovery will be checked every 60s; run `okx-a2a agent refresh` to recover immediately"
|
|
67255
67337
|
);
|
|
67256
67338
|
},
|
|
67257
67339
|
onAuthRecovered: () => {
|
|
@@ -67287,7 +67369,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
67287
67369
|
}
|
|
67288
67370
|
}),
|
|
67289
67371
|
notifySessionExpired: (command) => {
|
|
67290
|
-
const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login
|
|
67372
|
+
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.`;
|
|
67291
67373
|
void store.appendBackup(buildSystemStoredMessage({
|
|
67292
67374
|
reason: "onchainos-session-expired",
|
|
67293
67375
|
rawText,
|
|
@@ -67315,12 +67397,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
67315
67397
|
});
|
|
67316
67398
|
}
|
|
67317
67399
|
});
|
|
67318
|
-
service.setPluginVersion("0.2.4-beta-e7a52faf6f-
|
|
67400
|
+
service.setPluginVersion("0.2.4-beta-e7a52faf6f-260812154627");
|
|
67319
67401
|
await service.init();
|
|
67320
67402
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
67321
67403
|
if (pluginVersionStatus.unavailable) {
|
|
67322
67404
|
throw new Error(
|
|
67323
|
-
`@okxweb3/a2a-node v${"0.2.4-beta-e7a52faf6f-
|
|
67405
|
+
`@okxweb3/a2a-node v${"0.2.4-beta-e7a52faf6f-260812154627"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
67324
67406
|
);
|
|
67325
67407
|
}
|
|
67326
67408
|
const systemConfig = service.getSystemConfig();
|
|
@@ -67338,7 +67420,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
67338
67420
|
onchainosAgentId: "*",
|
|
67339
67421
|
reason: "system-config missing sentryDsn",
|
|
67340
67422
|
pluginId: "@okxweb3/a2a-node",
|
|
67341
|
-
pluginVersion: "0.2.4-beta-e7a52faf6f-
|
|
67423
|
+
pluginVersion: "0.2.4-beta-e7a52faf6f-260812154627"
|
|
67342
67424
|
});
|
|
67343
67425
|
}
|
|
67344
67426
|
logWithTimestamp(
|
|
@@ -67679,6 +67761,26 @@ async function runListenerWithLock(options, paths) {
|
|
|
67679
67761
|
const systemConfigRefreshTimer = setInterval(() => {
|
|
67680
67762
|
void refreshSystemConfigTick();
|
|
67681
67763
|
}, 60 * 60 * 1e3);
|
|
67764
|
+
const authRecoveryProbeTimer = setInterval(() => {
|
|
67765
|
+
if (stopping || !agentRefreshCoordinator.blocked) {
|
|
67766
|
+
return;
|
|
67767
|
+
}
|
|
67768
|
+
void agentRefreshCoordinator.runRecoveryProbe().then((refresh) => {
|
|
67769
|
+
if (!refresh) {
|
|
67770
|
+
return;
|
|
67771
|
+
}
|
|
67772
|
+
logWithTimestamp(
|
|
67773
|
+
`[okx-agent-task] auth recovery refresh agents=${refresh.agentCount} added=${refresh.added.length} removed=${refresh.removed.length}`
|
|
67774
|
+
);
|
|
67775
|
+
}).catch((err2) => {
|
|
67776
|
+
logger.error(LogEvent.DAEMON_TICK_FAILED, err2 instanceof Error ? err2 : new Error(String(err2)), {
|
|
67777
|
+
component: "node_listener",
|
|
67778
|
+
stage: "auth_recovery_probe",
|
|
67779
|
+
reason: "auth_recovery_probe_failed"
|
|
67780
|
+
});
|
|
67781
|
+
logWithTimestamp("[okx-agent-task] auth recovery probe failed:", err2);
|
|
67782
|
+
});
|
|
67783
|
+
}, AUTH_RECOVERY_PROBE_INTERVAL_MS);
|
|
67682
67784
|
void runHeartbeatRefreshCycle({
|
|
67683
67785
|
heartbeat: heartbeatTick
|
|
67684
67786
|
});
|
|
@@ -67714,6 +67816,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
67714
67816
|
clearInterval(xmtpClientRecycleTimer);
|
|
67715
67817
|
}
|
|
67716
67818
|
clearInterval(systemConfigRefreshTimer);
|
|
67819
|
+
clearInterval(authRecoveryProbeTimer);
|
|
67717
67820
|
commandProcessor.stop();
|
|
67718
67821
|
await watcherCoordinator.stop();
|
|
67719
67822
|
try {
|
|
@@ -67745,7 +67848,7 @@ async function timeSettled(fn) {
|
|
|
67745
67848
|
return { durationMs: Date.now() - startedAt, error };
|
|
67746
67849
|
}
|
|
67747
67850
|
}
|
|
67748
|
-
var import_node_fs25, import_promises13, import_node_os11, import_node_path30, DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC, DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC, XMTP_CLIENT_RECYCLE_INTERVAL_ENV, HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS, AgentRefreshAuthGate, AgentRefreshCoordinator, ListenerDeferredTaskScheduler, ListenerMaintenanceGate, UPGRADE_RECOMMENDATION_IDEMPOTENCY_KEY, SHUTDOWN_FORCE_RESOLVE_MS;
|
|
67851
|
+
var import_node_fs25, import_promises13, import_node_os11, import_node_path30, DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC, DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC, XMTP_CLIENT_RECYCLE_INTERVAL_ENV, HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS, AUTH_RECOVERY_PROBE_INTERVAL_MS, AUTH_RECOVERY_REFRESH_BACKOFF_MS, AgentRefreshAuthGate, AgentRefreshCoordinator, ListenerDeferredTaskScheduler, ListenerMaintenanceGate, UPGRADE_RECOMMENDATION_IDEMPOTENCY_KEY, SHUTDOWN_FORCE_RESOLVE_MS;
|
|
67749
67852
|
var init_listener = __esm({
|
|
67750
67853
|
"src/listener.ts"() {
|
|
67751
67854
|
"use strict";
|
|
@@ -67778,6 +67881,8 @@ var init_listener = __esm({
|
|
|
67778
67881
|
DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC = 6 * 60 * 60;
|
|
67779
67882
|
XMTP_CLIENT_RECYCLE_INTERVAL_ENV = "OKX_A2A_XMTP_CLIENT_RECYCLE_INTERVAL_SEC";
|
|
67780
67883
|
HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS = 2e3;
|
|
67884
|
+
AUTH_RECOVERY_PROBE_INTERVAL_MS = 6e4;
|
|
67885
|
+
AUTH_RECOVERY_REFRESH_BACKOFF_MS = [6e4, 12e4, 3e5];
|
|
67781
67886
|
AgentRefreshAuthGate = class {
|
|
67782
67887
|
authBlocked = false;
|
|
67783
67888
|
get blocked() {
|
|
@@ -67800,6 +67905,10 @@ var init_listener = __esm({
|
|
|
67800
67905
|
}
|
|
67801
67906
|
options;
|
|
67802
67907
|
authGate = new AgentRefreshAuthGate();
|
|
67908
|
+
refreshInFlight = null;
|
|
67909
|
+
recoveryProbeInFlight = null;
|
|
67910
|
+
recoveryRefreshFailureCount = 0;
|
|
67911
|
+
nextRecoveryRefreshAtMs = 0;
|
|
67803
67912
|
get blocked() {
|
|
67804
67913
|
return this.authGate.blocked;
|
|
67805
67914
|
}
|
|
@@ -67808,6 +67917,8 @@ var init_listener = __esm({
|
|
|
67808
67917
|
try {
|
|
67809
67918
|
const result = await this.options.lookup(previousFingerprint);
|
|
67810
67919
|
this.authGate.recordSuccess();
|
|
67920
|
+
this.recoveryRefreshFailureCount = 0;
|
|
67921
|
+
this.nextRecoveryRefreshAtMs = 0;
|
|
67811
67922
|
if (wasBlocked) {
|
|
67812
67923
|
this.options.onAuthRecovered?.();
|
|
67813
67924
|
}
|
|
@@ -67823,10 +67934,56 @@ var init_listener = __esm({
|
|
|
67823
67934
|
if (this.options.isStopping() || this.authGate.blocked) {
|
|
67824
67935
|
return null;
|
|
67825
67936
|
}
|
|
67826
|
-
return this.
|
|
67937
|
+
return this.runRefresh();
|
|
67827
67938
|
}
|
|
67828
67939
|
async runManual() {
|
|
67829
|
-
return this.
|
|
67940
|
+
return this.runRefresh();
|
|
67941
|
+
}
|
|
67942
|
+
runRecoveryProbe() {
|
|
67943
|
+
if (this.options.isStopping() || !this.authGate.blocked || !this.options.checkLoggedIn || this.now() < this.nextRecoveryRefreshAtMs) {
|
|
67944
|
+
return Promise.resolve(null);
|
|
67945
|
+
}
|
|
67946
|
+
if (this.recoveryProbeInFlight) {
|
|
67947
|
+
return this.recoveryProbeInFlight;
|
|
67948
|
+
}
|
|
67949
|
+
this.recoveryProbeInFlight = (async () => {
|
|
67950
|
+
const loggedIn = await this.options.checkLoggedIn?.();
|
|
67951
|
+
if (this.options.isStopping() || !this.authGate.blocked || !loggedIn) {
|
|
67952
|
+
return null;
|
|
67953
|
+
}
|
|
67954
|
+
const refresh = await this.runRefresh();
|
|
67955
|
+
if (this.authGate.blocked) {
|
|
67956
|
+
this.recordRecoveryRefreshFailure();
|
|
67957
|
+
return null;
|
|
67958
|
+
}
|
|
67959
|
+
return refresh;
|
|
67960
|
+
})().catch((err2) => {
|
|
67961
|
+
this.recordRecoveryRefreshFailure();
|
|
67962
|
+
throw err2;
|
|
67963
|
+
}).finally(() => {
|
|
67964
|
+
this.recoveryProbeInFlight = null;
|
|
67965
|
+
});
|
|
67966
|
+
return this.recoveryProbeInFlight;
|
|
67967
|
+
}
|
|
67968
|
+
runRefresh() {
|
|
67969
|
+
if (this.refreshInFlight) {
|
|
67970
|
+
return this.refreshInFlight;
|
|
67971
|
+
}
|
|
67972
|
+
this.refreshInFlight = this.options.refresh().finally(() => {
|
|
67973
|
+
this.refreshInFlight = null;
|
|
67974
|
+
});
|
|
67975
|
+
return this.refreshInFlight;
|
|
67976
|
+
}
|
|
67977
|
+
now() {
|
|
67978
|
+
return this.options.now?.() ?? Date.now();
|
|
67979
|
+
}
|
|
67980
|
+
recordRecoveryRefreshFailure() {
|
|
67981
|
+
const backoffIndex = Math.min(
|
|
67982
|
+
this.recoveryRefreshFailureCount,
|
|
67983
|
+
AUTH_RECOVERY_REFRESH_BACKOFF_MS.length - 1
|
|
67984
|
+
);
|
|
67985
|
+
this.nextRecoveryRefreshAtMs = this.now() + AUTH_RECOVERY_REFRESH_BACKOFF_MS[backoffIndex];
|
|
67986
|
+
this.recoveryRefreshFailureCount += 1;
|
|
67830
67987
|
}
|
|
67831
67988
|
};
|
|
67832
67989
|
ListenerDeferredTaskScheduler = class {
|
|
@@ -115657,7 +115814,7 @@ async function getCurrentNodeCliVersion() {
|
|
|
115657
115814
|
return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
|
|
115658
115815
|
}
|
|
115659
115816
|
function getBundledNodeCliVersion() {
|
|
115660
|
-
return true ? "0.2.4-beta-e7a52faf6f-
|
|
115817
|
+
return true ? "0.2.4-beta-e7a52faf6f-260812154627" : null;
|
|
115661
115818
|
}
|
|
115662
115819
|
function readConfiguredAiProvider() {
|
|
115663
115820
|
const explicit = process.env.OKX_A2A_AI_PROVIDER || process.env.OKX_AGENT_TASK_AI_CLI;
|
|
@@ -115867,7 +116024,7 @@ async function updateHermes(release, options) {
|
|
|
115867
116024
|
}
|
|
115868
116025
|
}
|
|
115869
116026
|
async function installGatewayPluginForDoctor(target) {
|
|
115870
|
-
const release = isPrereleaseVersion("0.2.4-beta-e7a52faf6f-
|
|
116027
|
+
const release = isPrereleaseVersion("0.2.4-beta-e7a52faf6f-260812154627") ? "beta" : "latest";
|
|
115871
116028
|
const insideTargetGateway = detectGatewayInvocation() === target;
|
|
115872
116029
|
const options = {
|
|
115873
116030
|
restart: !insideTargetGateway,
|
|
@@ -116910,7 +117067,7 @@ async function runDoctor(options = {}) {
|
|
|
116910
117067
|
platform: options.platform ?? process.platform,
|
|
116911
117068
|
env: options.env ?? process.env,
|
|
116912
117069
|
target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
|
|
116913
|
-
cliVersion: options.cliVersion ?? (true ? "0.2.4-beta-e7a52faf6f-
|
|
117070
|
+
cliVersion: options.cliVersion ?? (true ? "0.2.4-beta-e7a52faf6f-260812154627" : "0.0.0"),
|
|
116914
117071
|
fixMode: options.fix === true,
|
|
116915
117072
|
nonInteractive: options.nonInteractive === true,
|
|
116916
117073
|
packageChanged: false,
|
|
@@ -117907,7 +118064,7 @@ init_sentry_logger();
|
|
|
117907
118064
|
init_sentry_config();
|
|
117908
118065
|
var CURRENT_GATEWAY_SESSION_KEYS_ENV4 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
|
|
117909
118066
|
function printUsage3() {
|
|
117910
|
-
console.log(`okx-a2a ${"0.2.4-beta-e7a52faf6f-
|
|
118067
|
+
console.log(`okx-a2a ${"0.2.4-beta-e7a52faf6f-260812154627"}
|
|
117911
118068
|
|
|
117912
118069
|
Usage:
|
|
117913
118070
|
okx-a2a <command> [options]
|
|
@@ -117947,7 +118104,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
|
|
|
117947
118104
|
`);
|
|
117948
118105
|
}
|
|
117949
118106
|
function printVersion() {
|
|
117950
|
-
console.log("0.2.4-beta-e7a52faf6f-
|
|
118107
|
+
console.log("0.2.4-beta-e7a52faf6f-260812154627");
|
|
117951
118108
|
}
|
|
117952
118109
|
function printDaemonUsage() {
|
|
117953
118110
|
console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
|
|
@@ -119383,7 +119540,7 @@ async function main() {
|
|
|
119383
119540
|
if (command === "xmtp-test") {
|
|
119384
119541
|
const { handleXmtpTestCommand: handleXmtpTestCommand2 } = await Promise.resolve().then(() => (init_xmtp_test_cli(), xmtp_test_cli_exports));
|
|
119385
119542
|
await handleXmtpTestCommand2(process.argv.slice(3), {
|
|
119386
|
-
packageVersion: "0.2.4-beta-e7a52faf6f-
|
|
119543
|
+
packageVersion: "0.2.4-beta-e7a52faf6f-260812154627",
|
|
119387
119544
|
agentSdkVersion: "2.3.0",
|
|
119388
119545
|
nodeSdkVersion: "6.1.0",
|
|
119389
119546
|
nodeBindingsVersion: "1.11.0"
|
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-beta-e7a52faf6f-
|
|
32107
|
+
release: "0.2.4-beta-e7a52faf6f-260812154627",
|
|
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-beta-e7a52faf6f-
|
|
33048
|
+
return true ? "0.2.4-beta-e7a52faf6f-260812154627" : 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-beta-e7a52faf6f-
|
|
33258
|
+
const release = isPrereleaseVersion("0.2.4-beta-e7a52faf6f-260812154627") ? "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,
|
|
@@ -44100,6 +44103,7 @@ __export(index_exports, {
|
|
|
44100
44103
|
isWindowsElevated: () => isWindowsElevated,
|
|
44101
44104
|
killProcessTree: () => killProcessTree,
|
|
44102
44105
|
launchdPlistHasCurrentRestartPolicy: () => launchdPlistHasCurrentRestartPolicy,
|
|
44106
|
+
listAllAgentsWithMetadata: () => listAllAgentsWithMetadata,
|
|
44103
44107
|
logWinCompat: () => logWinCompat,
|
|
44104
44108
|
logXmtpMessageSent: () => logXmtpMessageSent,
|
|
44105
44109
|
maybeRecommendOnchainosUpgrade: () => maybeRecommendOnchainosUpgrade,
|
|
@@ -44113,6 +44117,7 @@ __export(index_exports, {
|
|
|
44113
44117
|
notifyUserAttentionChanged: () => notifyUserAttentionChanged,
|
|
44114
44118
|
parseLogsExportArgs: () => parseLogsExportArgs,
|
|
44115
44119
|
parsePluginYamlVersion: () => parsePluginYamlVersion,
|
|
44120
|
+
parseWalletLoginStatus: () => parseWalletLoginStatus,
|
|
44116
44121
|
parseWindowsParentProcessJson: () => parseWindowsParentProcessJson,
|
|
44117
44122
|
performRuntimeSwitch: () => performRuntimeSwitch,
|
|
44118
44123
|
persistCurrentRuntimeSelectionForNewJob: () => persistCurrentRuntimeSelectionForNewJob,
|
|
@@ -44122,6 +44127,7 @@ __export(index_exports, {
|
|
|
44122
44127
|
printXmtpTestUsage: () => printXmtpTestUsage,
|
|
44123
44128
|
probeCodexAuthStatus: () => probeCodexAuthStatus,
|
|
44124
44129
|
processFileMessage: () => processFileMessage,
|
|
44130
|
+
queryWalletLoginStatus: () => queryWalletLoginStatus,
|
|
44125
44131
|
readAiProviderTimeoutMs: () => readAiProviderTimeoutMs,
|
|
44126
44132
|
readCachedCodexReadiness: () => readCachedCodexReadiness,
|
|
44127
44133
|
readLastLines: () => readLastLines,
|
|
@@ -58685,7 +58691,7 @@ function redactArgsForLog(args) {
|
|
|
58685
58691
|
function commandForLog(bin, args) {
|
|
58686
58692
|
return `${bin} ${redactArgsForLog(args).join(" ")}`;
|
|
58687
58693
|
}
|
|
58688
|
-
async function exec(args) {
|
|
58694
|
+
async function exec(args, options = {}) {
|
|
58689
58695
|
const bin = await resolve6();
|
|
58690
58696
|
const cmd = commandForLog(bin, args);
|
|
58691
58697
|
logWithTimestamp(`[onchainos] exec: ${cmd}`);
|
|
@@ -58699,7 +58705,8 @@ async function exec(args) {
|
|
|
58699
58705
|
try {
|
|
58700
58706
|
const result = await execFileAsync2(invocation.command, invocation.args, {
|
|
58701
58707
|
windowsHide: true,
|
|
58702
|
-
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
58708
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments,
|
|
58709
|
+
timeout: options.timeoutMs
|
|
58703
58710
|
});
|
|
58704
58711
|
logWithTimestamp(
|
|
58705
58712
|
`[onchainos] exec done: ${cmd} (${Date.now() - t0}ms, stdout=${result.stdout.length}B, stderr=${result.stderr.length}B)`
|
|
@@ -58732,7 +58739,8 @@ async function exec(args) {
|
|
|
58732
58739
|
stdoutBytes: String(Buffer.byteLength(String(err?.stdout ?? ""), "utf8")),
|
|
58733
58740
|
cliErrorName: err instanceof Error ? err.name : "",
|
|
58734
58741
|
cliErrorMessageLength: String(String(err?.message ?? "").length),
|
|
58735
|
-
durationMs: String(Date.now() - t0)
|
|
58742
|
+
durationMs: String(Date.now() - t0),
|
|
58743
|
+
timeoutMs: String(options.timeoutMs ?? "")
|
|
58736
58744
|
}
|
|
58737
58745
|
);
|
|
58738
58746
|
throw err;
|
|
@@ -58947,6 +58955,46 @@ async function fetchSystemConfig(options) {
|
|
|
58947
58955
|
return res.data;
|
|
58948
58956
|
}
|
|
58949
58957
|
|
|
58958
|
+
// ../core/src/xmtp-sdk/onchainos/wallet-status.ts
|
|
58959
|
+
init_log();
|
|
58960
|
+
init_sentry_logger();
|
|
58961
|
+
var WALLET_STATUS_TIMEOUT_MS = 1e4;
|
|
58962
|
+
function parseWalletLoginStatus(stdout) {
|
|
58963
|
+
const response = parseCliJson(stdout, "wallet-status");
|
|
58964
|
+
if (!response.ok) {
|
|
58965
|
+
const error = new Error("onchainos wallet status failed");
|
|
58966
|
+
logger.error(
|
|
58967
|
+
LogEvent.ONCHAINOS_CLI_ERROR,
|
|
58968
|
+
error,
|
|
58969
|
+
cliOkFalseExtras(stdout, "wallet-status")
|
|
58970
|
+
);
|
|
58971
|
+
throw error;
|
|
58972
|
+
}
|
|
58973
|
+
if (typeof response.data?.loggedIn !== "boolean") {
|
|
58974
|
+
const error = new Error("onchainos wallet status returned invalid loggedIn state");
|
|
58975
|
+
logger.error(LogEvent.ONCHAINOS_CLI_ERROR, error, {
|
|
58976
|
+
component: "onchainos_cli",
|
|
58977
|
+
source: "onchainos",
|
|
58978
|
+
stage: "response_validation",
|
|
58979
|
+
communicationClass: "onchainos_cli_or_api_issue",
|
|
58980
|
+
operation: "wallet-status",
|
|
58981
|
+
reason: "invalid_logged_in_state"
|
|
58982
|
+
});
|
|
58983
|
+
throw error;
|
|
58984
|
+
}
|
|
58985
|
+
return response.data.loggedIn;
|
|
58986
|
+
}
|
|
58987
|
+
async function queryWalletLoginStatus(options = {}) {
|
|
58988
|
+
logWithTimestamp("[onchainos] checking wallet login status");
|
|
58989
|
+
const { stdout } = await exec(
|
|
58990
|
+
["wallet", "status"],
|
|
58991
|
+
{ timeoutMs: options.timeoutMs ?? WALLET_STATUS_TIMEOUT_MS }
|
|
58992
|
+
);
|
|
58993
|
+
const loggedIn = parseWalletLoginStatus(stdout);
|
|
58994
|
+
logWithTimestamp(`[onchainos] wallet login status: ${loggedIn ? "logged in" : "logged out"}`);
|
|
58995
|
+
return loggedIn;
|
|
58996
|
+
}
|
|
58997
|
+
|
|
58950
58998
|
// ../core/src/xmtp-sdk/onchainos/index.ts
|
|
58951
58999
|
var MESSAGE_ELIGIBILITY_SERVICE_UNAVAILABLE_AI_HINT = "Message eligibility service is temporarily unavailable. Please try again later.";
|
|
58952
59000
|
function messageEligibleUnavailableError(input) {
|
|
@@ -59010,6 +59058,8 @@ function guardCatchSessionExpired2(err, command) {
|
|
|
59010
59058
|
}
|
|
59011
59059
|
}
|
|
59012
59060
|
var PAGE_SIZE = 50;
|
|
59061
|
+
var AGENT_GET_PAGE_TIMEOUT_MS = 1e4;
|
|
59062
|
+
var AGENT_LIST_TIMEOUT_MS = 3e4;
|
|
59013
59063
|
function isJsonString(value) {
|
|
59014
59064
|
try {
|
|
59015
59065
|
JSON.parse(value);
|
|
@@ -59035,19 +59085,22 @@ function logAgentListResponse(input) {
|
|
|
59035
59085
|
onchainosAgentListDiagnosticText: input.stderr
|
|
59036
59086
|
});
|
|
59037
59087
|
}
|
|
59038
|
-
async function fetchAgentPage(page) {
|
|
59088
|
+
async function fetchAgentPage(page, timeoutMs) {
|
|
59039
59089
|
const startedAt = Date.now();
|
|
59040
59090
|
let stdout;
|
|
59041
59091
|
let stderr;
|
|
59042
59092
|
try {
|
|
59043
|
-
({ stdout, stderr } = await exec(
|
|
59044
|
-
|
|
59045
|
-
|
|
59046
|
-
|
|
59047
|
-
|
|
59048
|
-
|
|
59049
|
-
|
|
59050
|
-
|
|
59093
|
+
({ stdout, stderr } = await exec(
|
|
59094
|
+
[
|
|
59095
|
+
"agent",
|
|
59096
|
+
"get",
|
|
59097
|
+
"--page",
|
|
59098
|
+
String(page),
|
|
59099
|
+
"--page-size",
|
|
59100
|
+
String(PAGE_SIZE)
|
|
59101
|
+
],
|
|
59102
|
+
{ timeoutMs }
|
|
59103
|
+
));
|
|
59051
59104
|
} catch (err) {
|
|
59052
59105
|
const errStdout = typeof err?.stdout === "string" ? err.stdout : "";
|
|
59053
59106
|
const errStderr = typeof err?.stderr === "string" ? err.stderr : "";
|
|
@@ -59193,13 +59246,28 @@ async function fetchAgentByAddress(communicationAddress) {
|
|
|
59193
59246
|
agentByIdCache.set(res.data.agentId, res.data);
|
|
59194
59247
|
return res.data;
|
|
59195
59248
|
}
|
|
59196
|
-
async function listAllAgentsWithMetadata(previousFingerprint) {
|
|
59249
|
+
async function listAllAgentsWithMetadata(previousFingerprint, options = {}) {
|
|
59197
59250
|
const startedAt = Date.now();
|
|
59251
|
+
const pageTimeoutMs = positiveTimeoutOrDefault(
|
|
59252
|
+
options.pageTimeoutMs,
|
|
59253
|
+
AGENT_GET_PAGE_TIMEOUT_MS
|
|
59254
|
+
);
|
|
59255
|
+
const totalTimeoutMs = positiveTimeoutOrDefault(
|
|
59256
|
+
options.totalTimeoutMs,
|
|
59257
|
+
AGENT_LIST_TIMEOUT_MS
|
|
59258
|
+
);
|
|
59198
59259
|
const agents = [];
|
|
59199
59260
|
const stderrs = [];
|
|
59200
59261
|
let page = 1;
|
|
59201
59262
|
while (true) {
|
|
59202
|
-
const
|
|
59263
|
+
const remainingMs = totalTimeoutMs - (Date.now() - startedAt);
|
|
59264
|
+
if (remainingMs <= 0) {
|
|
59265
|
+
throw agentListTimeoutError(totalTimeoutMs);
|
|
59266
|
+
}
|
|
59267
|
+
const { data, stderr } = await fetchAgentPage(
|
|
59268
|
+
page,
|
|
59269
|
+
Math.min(pageTimeoutMs, remainingMs)
|
|
59270
|
+
);
|
|
59203
59271
|
if (stderr) {
|
|
59204
59272
|
stderrs.push(`page=${page}: ${stderr}`);
|
|
59205
59273
|
}
|
|
@@ -59226,6 +59294,14 @@ async function listAllAgentsWithMetadata(previousFingerprint) {
|
|
|
59226
59294
|
durationMs: Date.now() - startedAt
|
|
59227
59295
|
};
|
|
59228
59296
|
}
|
|
59297
|
+
function positiveTimeoutOrDefault(value, fallback) {
|
|
59298
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
59299
|
+
}
|
|
59300
|
+
function agentListTimeoutError(timeoutMs) {
|
|
59301
|
+
const error = new Error(`onchainos agent list timed out after ${timeoutMs}ms`);
|
|
59302
|
+
error.code = "ETIMEDOUT";
|
|
59303
|
+
return error;
|
|
59304
|
+
}
|
|
59229
59305
|
function fingerprintAgents(agents) {
|
|
59230
59306
|
return agents.map((a) => [
|
|
59231
59307
|
a.agentId,
|
|
@@ -60205,7 +60281,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
60205
60281
|
client: {
|
|
60206
60282
|
id: "gateway-client",
|
|
60207
60283
|
displayName: "okx-a2a-node",
|
|
60208
|
-
version: "0.2.4-beta-e7a52faf6f-
|
|
60284
|
+
version: "0.2.4-beta-e7a52faf6f-260812154627",
|
|
60209
60285
|
platform: "node",
|
|
60210
60286
|
mode: "backend",
|
|
60211
60287
|
instanceId
|
|
@@ -60216,7 +60292,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
60216
60292
|
commands: [],
|
|
60217
60293
|
permissions: {},
|
|
60218
60294
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
60219
|
-
userAgent: `okx-a2a-node/${"0.2.4-beta-e7a52faf6f-
|
|
60295
|
+
userAgent: `okx-a2a-node/${"0.2.4-beta-e7a52faf6f-260812154627"}`,
|
|
60220
60296
|
auth: {
|
|
60221
60297
|
...config.token ? { token: config.token } : {},
|
|
60222
60298
|
...config.password ? { password: config.password } : {}
|
|
@@ -65998,6 +66074,8 @@ var DEFAULT_OFFLINE_REPLAY_INTERVAL_SEC = 300;
|
|
|
65998
66074
|
var DEFAULT_XMTP_CLIENT_RECYCLE_INTERVAL_SEC = 6 * 60 * 60;
|
|
65999
66075
|
var XMTP_CLIENT_RECYCLE_INTERVAL_ENV = "OKX_A2A_XMTP_CLIENT_RECYCLE_INTERVAL_SEC";
|
|
66000
66076
|
var HEARTBEAT_GATEWAY_CHECK_TIMEOUT_MS = 2e3;
|
|
66077
|
+
var AUTH_RECOVERY_PROBE_INTERVAL_MS = 6e4;
|
|
66078
|
+
var AUTH_RECOVERY_REFRESH_BACKOFF_MS = [6e4, 12e4, 3e5];
|
|
66001
66079
|
async function runHeartbeatRefreshCycle(options) {
|
|
66002
66080
|
const heartbeat = await timeSettled(options.heartbeat);
|
|
66003
66081
|
const refreshAllowed = heartbeat.value === "performed" || heartbeat.value === "refresh_safe";
|
|
@@ -66026,6 +66104,10 @@ var AgentRefreshCoordinator = class {
|
|
|
66026
66104
|
}
|
|
66027
66105
|
options;
|
|
66028
66106
|
authGate = new AgentRefreshAuthGate();
|
|
66107
|
+
refreshInFlight = null;
|
|
66108
|
+
recoveryProbeInFlight = null;
|
|
66109
|
+
recoveryRefreshFailureCount = 0;
|
|
66110
|
+
nextRecoveryRefreshAtMs = 0;
|
|
66029
66111
|
get blocked() {
|
|
66030
66112
|
return this.authGate.blocked;
|
|
66031
66113
|
}
|
|
@@ -66034,6 +66116,8 @@ var AgentRefreshCoordinator = class {
|
|
|
66034
66116
|
try {
|
|
66035
66117
|
const result = await this.options.lookup(previousFingerprint);
|
|
66036
66118
|
this.authGate.recordSuccess();
|
|
66119
|
+
this.recoveryRefreshFailureCount = 0;
|
|
66120
|
+
this.nextRecoveryRefreshAtMs = 0;
|
|
66037
66121
|
if (wasBlocked) {
|
|
66038
66122
|
this.options.onAuthRecovered?.();
|
|
66039
66123
|
}
|
|
@@ -66049,10 +66133,56 @@ var AgentRefreshCoordinator = class {
|
|
|
66049
66133
|
if (this.options.isStopping() || this.authGate.blocked) {
|
|
66050
66134
|
return null;
|
|
66051
66135
|
}
|
|
66052
|
-
return this.
|
|
66136
|
+
return this.runRefresh();
|
|
66053
66137
|
}
|
|
66054
66138
|
async runManual() {
|
|
66055
|
-
return this.
|
|
66139
|
+
return this.runRefresh();
|
|
66140
|
+
}
|
|
66141
|
+
runRecoveryProbe() {
|
|
66142
|
+
if (this.options.isStopping() || !this.authGate.blocked || !this.options.checkLoggedIn || this.now() < this.nextRecoveryRefreshAtMs) {
|
|
66143
|
+
return Promise.resolve(null);
|
|
66144
|
+
}
|
|
66145
|
+
if (this.recoveryProbeInFlight) {
|
|
66146
|
+
return this.recoveryProbeInFlight;
|
|
66147
|
+
}
|
|
66148
|
+
this.recoveryProbeInFlight = (async () => {
|
|
66149
|
+
const loggedIn = await this.options.checkLoggedIn?.();
|
|
66150
|
+
if (this.options.isStopping() || !this.authGate.blocked || !loggedIn) {
|
|
66151
|
+
return null;
|
|
66152
|
+
}
|
|
66153
|
+
const refresh = await this.runRefresh();
|
|
66154
|
+
if (this.authGate.blocked) {
|
|
66155
|
+
this.recordRecoveryRefreshFailure();
|
|
66156
|
+
return null;
|
|
66157
|
+
}
|
|
66158
|
+
return refresh;
|
|
66159
|
+
})().catch((err) => {
|
|
66160
|
+
this.recordRecoveryRefreshFailure();
|
|
66161
|
+
throw err;
|
|
66162
|
+
}).finally(() => {
|
|
66163
|
+
this.recoveryProbeInFlight = null;
|
|
66164
|
+
});
|
|
66165
|
+
return this.recoveryProbeInFlight;
|
|
66166
|
+
}
|
|
66167
|
+
runRefresh() {
|
|
66168
|
+
if (this.refreshInFlight) {
|
|
66169
|
+
return this.refreshInFlight;
|
|
66170
|
+
}
|
|
66171
|
+
this.refreshInFlight = this.options.refresh().finally(() => {
|
|
66172
|
+
this.refreshInFlight = null;
|
|
66173
|
+
});
|
|
66174
|
+
return this.refreshInFlight;
|
|
66175
|
+
}
|
|
66176
|
+
now() {
|
|
66177
|
+
return this.options.now?.() ?? Date.now();
|
|
66178
|
+
}
|
|
66179
|
+
recordRecoveryRefreshFailure() {
|
|
66180
|
+
const backoffIndex = Math.min(
|
|
66181
|
+
this.recoveryRefreshFailureCount,
|
|
66182
|
+
AUTH_RECOVERY_REFRESH_BACKOFF_MS.length - 1
|
|
66183
|
+
);
|
|
66184
|
+
this.nextRecoveryRefreshAtMs = this.now() + AUTH_RECOVERY_REFRESH_BACKOFF_MS[backoffIndex];
|
|
66185
|
+
this.recoveryRefreshFailureCount += 1;
|
|
66056
66186
|
}
|
|
66057
66187
|
};
|
|
66058
66188
|
var ListenerDeferredTaskScheduler = class {
|
|
@@ -66309,10 +66439,11 @@ async function runListenerWithLock(options, paths) {
|
|
|
66309
66439
|
const agentRefreshCoordinator = new AgentRefreshCoordinator({
|
|
66310
66440
|
lookup: (previousFingerprint) => listAllAgentsWithMetadata(previousFingerprint),
|
|
66311
66441
|
refresh: () => service.refreshAgents(),
|
|
66442
|
+
checkLoggedIn: () => queryWalletLoginStatus(),
|
|
66312
66443
|
isStopping: () => stopping,
|
|
66313
66444
|
onAuthBlocked: () => {
|
|
66314
66445
|
logWithTimestamp(
|
|
66315
|
-
"[okx-agent-task] agent refresh auth blocked; periodic agent get paused.
|
|
66446
|
+
"[okx-agent-task] agent refresh auth blocked; periodic agent get paused. Wallet login recovery will be checked every 60s; run `okx-a2a agent refresh` to recover immediately"
|
|
66316
66447
|
);
|
|
66317
66448
|
},
|
|
66318
66449
|
onAuthRecovered: () => {
|
|
@@ -66348,7 +66479,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
66348
66479
|
}
|
|
66349
66480
|
}),
|
|
66350
66481
|
notifySessionExpired: (command) => {
|
|
66351
|
-
const rawText = `The onchainos login session has expired while running ${command}. Run \`onchainos wallet login
|
|
66482
|
+
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.`;
|
|
66352
66483
|
void store.appendBackup(buildSystemStoredMessage({
|
|
66353
66484
|
reason: "onchainos-session-expired",
|
|
66354
66485
|
rawText,
|
|
@@ -66376,12 +66507,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
66376
66507
|
});
|
|
66377
66508
|
}
|
|
66378
66509
|
});
|
|
66379
|
-
service.setPluginVersion("0.2.4-beta-e7a52faf6f-
|
|
66510
|
+
service.setPluginVersion("0.2.4-beta-e7a52faf6f-260812154627");
|
|
66380
66511
|
await service.init();
|
|
66381
66512
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
66382
66513
|
if (pluginVersionStatus.unavailable) {
|
|
66383
66514
|
throw new Error(
|
|
66384
|
-
`@okxweb3/a2a-node v${"0.2.4-beta-e7a52faf6f-
|
|
66515
|
+
`@okxweb3/a2a-node v${"0.2.4-beta-e7a52faf6f-260812154627"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
66385
66516
|
);
|
|
66386
66517
|
}
|
|
66387
66518
|
const systemConfig = service.getSystemConfig();
|
|
@@ -66399,7 +66530,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
66399
66530
|
onchainosAgentId: "*",
|
|
66400
66531
|
reason: "system-config missing sentryDsn",
|
|
66401
66532
|
pluginId: "@okxweb3/a2a-node",
|
|
66402
|
-
pluginVersion: "0.2.4-beta-e7a52faf6f-
|
|
66533
|
+
pluginVersion: "0.2.4-beta-e7a52faf6f-260812154627"
|
|
66403
66534
|
});
|
|
66404
66535
|
}
|
|
66405
66536
|
logWithTimestamp(
|
|
@@ -66740,6 +66871,26 @@ async function runListenerWithLock(options, paths) {
|
|
|
66740
66871
|
const systemConfigRefreshTimer = setInterval(() => {
|
|
66741
66872
|
void refreshSystemConfigTick();
|
|
66742
66873
|
}, 60 * 60 * 1e3);
|
|
66874
|
+
const authRecoveryProbeTimer = setInterval(() => {
|
|
66875
|
+
if (stopping || !agentRefreshCoordinator.blocked) {
|
|
66876
|
+
return;
|
|
66877
|
+
}
|
|
66878
|
+
void agentRefreshCoordinator.runRecoveryProbe().then((refresh) => {
|
|
66879
|
+
if (!refresh) {
|
|
66880
|
+
return;
|
|
66881
|
+
}
|
|
66882
|
+
logWithTimestamp(
|
|
66883
|
+
`[okx-agent-task] auth recovery refresh agents=${refresh.agentCount} added=${refresh.added.length} removed=${refresh.removed.length}`
|
|
66884
|
+
);
|
|
66885
|
+
}).catch((err) => {
|
|
66886
|
+
logger.error(LogEvent.DAEMON_TICK_FAILED, err instanceof Error ? err : new Error(String(err)), {
|
|
66887
|
+
component: "node_listener",
|
|
66888
|
+
stage: "auth_recovery_probe",
|
|
66889
|
+
reason: "auth_recovery_probe_failed"
|
|
66890
|
+
});
|
|
66891
|
+
logWithTimestamp("[okx-agent-task] auth recovery probe failed:", err);
|
|
66892
|
+
});
|
|
66893
|
+
}, AUTH_RECOVERY_PROBE_INTERVAL_MS);
|
|
66743
66894
|
void runHeartbeatRefreshCycle({
|
|
66744
66895
|
heartbeat: heartbeatTick
|
|
66745
66896
|
});
|
|
@@ -66775,6 +66926,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
66775
66926
|
clearInterval(xmtpClientRecycleTimer);
|
|
66776
66927
|
}
|
|
66777
66928
|
clearInterval(systemConfigRefreshTimer);
|
|
66929
|
+
clearInterval(authRecoveryProbeTimer);
|
|
66778
66930
|
commandProcessor.stop();
|
|
66779
66931
|
await watcherCoordinator.stop();
|
|
66780
66932
|
try {
|
|
@@ -69076,7 +69228,7 @@ async function exportDiagnosticLogs(options) {
|
|
|
69076
69228
|
node: process.version,
|
|
69077
69229
|
platform: process.platform,
|
|
69078
69230
|
arch: process.arch,
|
|
69079
|
-
packageVersion: true ? "0.2.4-beta-e7a52faf6f-
|
|
69231
|
+
packageVersion: true ? "0.2.4-beta-e7a52faf6f-260812154627" : "unknown",
|
|
69080
69232
|
sensitiveContentIncluded: options.includeSensitiveContent,
|
|
69081
69233
|
listenerAndLlmContentIncluded: true,
|
|
69082
69234
|
credentialsAlwaysRedacted: true,
|
|
@@ -70912,7 +71064,7 @@ async function runDoctor(options = {}) {
|
|
|
70912
71064
|
platform: options.platform ?? process.platform,
|
|
70913
71065
|
env: options.env ?? process.env,
|
|
70914
71066
|
target: options.target ?? resolveDoctorTarget(options.env ?? process.env),
|
|
70915
|
-
cliVersion: options.cliVersion ?? (true ? "0.2.4-beta-e7a52faf6f-
|
|
71067
|
+
cliVersion: options.cliVersion ?? (true ? "0.2.4-beta-e7a52faf6f-260812154627" : "0.0.0"),
|
|
70916
71068
|
fixMode: options.fix === true,
|
|
70917
71069
|
nonInteractive: options.nonInteractive === true,
|
|
70918
71070
|
packageChanged: false,
|
|
@@ -71133,6 +71285,8 @@ init_win_native_launcher();
|
|
|
71133
71285
|
init_autostart_windows();
|
|
71134
71286
|
// Annotate the CommonJS export names for ESM import in node:
|
|
71135
71287
|
0 && (module.exports = {
|
|
71288
|
+
AGENT_GET_PAGE_TIMEOUT_MS,
|
|
71289
|
+
AGENT_LIST_TIMEOUT_MS,
|
|
71136
71290
|
AI_PROVIDERS,
|
|
71137
71291
|
AgentMessageDirection,
|
|
71138
71292
|
AgentRefreshAuthGate,
|
|
@@ -71176,6 +71330,7 @@ init_autostart_windows();
|
|
|
71176
71330
|
USER_ATTENTION_WATCH_PARENT_CHECK_MS,
|
|
71177
71331
|
USER_ATTENTION_WATCH_REPLACED_MESSAGE,
|
|
71178
71332
|
UserCancelledAiProviderSelectionError,
|
|
71333
|
+
WALLET_STATUS_TIMEOUT_MS,
|
|
71179
71334
|
XMTP_CLIENT_RECYCLE_INTERVAL_ENV,
|
|
71180
71335
|
XmtpDm,
|
|
71181
71336
|
XmtpGroup,
|
|
@@ -71289,6 +71444,7 @@ init_autostart_windows();
|
|
|
71289
71444
|
isWindowsElevated,
|
|
71290
71445
|
killProcessTree,
|
|
71291
71446
|
launchdPlistHasCurrentRestartPolicy,
|
|
71447
|
+
listAllAgentsWithMetadata,
|
|
71292
71448
|
logWinCompat,
|
|
71293
71449
|
logXmtpMessageSent,
|
|
71294
71450
|
maybeRecommendOnchainosUpgrade,
|
|
@@ -71302,6 +71458,7 @@ init_autostart_windows();
|
|
|
71302
71458
|
notifyUserAttentionChanged,
|
|
71303
71459
|
parseLogsExportArgs,
|
|
71304
71460
|
parsePluginYamlVersion,
|
|
71461
|
+
parseWalletLoginStatus,
|
|
71305
71462
|
parseWindowsParentProcessJson,
|
|
71306
71463
|
performRuntimeSwitch,
|
|
71307
71464
|
persistCurrentRuntimeSelectionForNewJob,
|
|
@@ -71311,6 +71468,7 @@ init_autostart_windows();
|
|
|
71311
71468
|
printXmtpTestUsage,
|
|
71312
71469
|
probeCodexAuthStatus,
|
|
71313
71470
|
processFileMessage,
|
|
71471
|
+
queryWalletLoginStatus,
|
|
71314
71472
|
readAiProviderTimeoutMs,
|
|
71315
71473
|
readCachedCodexReadiness,
|
|
71316
71474
|
readLastLines,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okxweb3/a2a-node",
|
|
3
|
-
"version": "0.2.4-beta-e7a52faf6f-
|
|
3
|
+
"version": "0.2.4-beta-e7a52faf6f-260812154627",
|
|
4
4
|
"description": "Host-agnostic Node CLI for E2E encrypted agent-to-agent communication via XMTP",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|