@okxweb3/a2a-node 0.0.11 → 0.0.12
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 +87 -25
- package/dist/index.js +84 -21
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7071,10 +7071,30 @@ async function ensureClient(timeoutMs) {
|
|
|
7071
7071
|
clearClient();
|
|
7072
7072
|
}
|
|
7073
7073
|
const config = resolveOpenClawGatewayConfig();
|
|
7074
|
-
const
|
|
7074
|
+
const startedAt = Date.now();
|
|
7075
|
+
const firstProtocol = preferredGatewayProtocolVersion;
|
|
7076
|
+
const client = new MinimalGatewayClient(config, firstProtocol);
|
|
7075
7077
|
sharedClient = client;
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
+
try {
|
|
7079
|
+
await client.connect(timeoutMs);
|
|
7080
|
+
return client;
|
|
7081
|
+
} catch (err2) {
|
|
7082
|
+
if (!isOpenClawProtocolMismatch(err2)) {
|
|
7083
|
+
throw err2;
|
|
7084
|
+
}
|
|
7085
|
+
clearClient();
|
|
7086
|
+
const elapsedMs = Date.now() - startedAt;
|
|
7087
|
+
const remainingMs = Math.max(1, timeoutMs - elapsedMs);
|
|
7088
|
+
const fallbackProtocol = firstProtocol === PREFERRED_PROTOCOL_VERSION ? LEGACY_PROTOCOL_VERSION : PREFERRED_PROTOCOL_VERSION;
|
|
7089
|
+
console.error(
|
|
7090
|
+
`${LOG_PREFIX} protocol fallback from=${firstProtocol} to=${fallbackProtocol} remainingMs=${remainingMs}: ${formatErrorMessage(err2)}`
|
|
7091
|
+
);
|
|
7092
|
+
const fallbackClient = new MinimalGatewayClient(config, fallbackProtocol);
|
|
7093
|
+
sharedClient = fallbackClient;
|
|
7094
|
+
await fallbackClient.connect(remainingMs);
|
|
7095
|
+
preferredGatewayProtocolVersion = fallbackProtocol;
|
|
7096
|
+
return fallbackClient;
|
|
7097
|
+
}
|
|
7078
7098
|
}
|
|
7079
7099
|
function stopOpenClawGateway() {
|
|
7080
7100
|
if (!sharedClient) {
|
|
@@ -7198,14 +7218,14 @@ function readSyncedGatewayConfig(env) {
|
|
|
7198
7218
|
return null;
|
|
7199
7219
|
}
|
|
7200
7220
|
}
|
|
7201
|
-
function buildConnectParams(config, instanceId) {
|
|
7221
|
+
function buildConnectParams(config, instanceId, protocolVersion) {
|
|
7202
7222
|
return {
|
|
7203
|
-
minProtocol:
|
|
7204
|
-
maxProtocol:
|
|
7223
|
+
minProtocol: protocolVersion,
|
|
7224
|
+
maxProtocol: protocolVersion,
|
|
7205
7225
|
client: {
|
|
7206
7226
|
id: "gateway-client",
|
|
7207
7227
|
displayName: "okx-a2a-node",
|
|
7208
|
-
version: "0.0.
|
|
7228
|
+
version: "0.0.12",
|
|
7209
7229
|
platform: "node",
|
|
7210
7230
|
mode: "backend",
|
|
7211
7231
|
instanceId
|
|
@@ -7216,7 +7236,7 @@ function buildConnectParams(config, instanceId) {
|
|
|
7216
7236
|
commands: [],
|
|
7217
7237
|
permissions: {},
|
|
7218
7238
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
7219
|
-
userAgent: `okx-a2a-node/${"0.0.
|
|
7239
|
+
userAgent: `okx-a2a-node/${"0.0.12"}`,
|
|
7220
7240
|
auth: {
|
|
7221
7241
|
...config.token ? { token: config.token } : {},
|
|
7222
7242
|
...config.password ? { password: config.password } : {}
|
|
@@ -7235,17 +7255,54 @@ function toGatewayError(error) {
|
|
|
7235
7255
|
});
|
|
7236
7256
|
return err2;
|
|
7237
7257
|
}
|
|
7258
|
+
function toGatewayCloseError(code2, reason) {
|
|
7259
|
+
const closeCode = code2 ?? 0;
|
|
7260
|
+
const closeReason = reason || "";
|
|
7261
|
+
if (closeCode === 1002 && /protocol mismatch/i.test(closeReason)) {
|
|
7262
|
+
return Object.assign(new Error(`OpenClaw gateway protocol mismatch code=${closeCode} reason=${closeReason}`), {
|
|
7263
|
+
code: "PROTOCOL_MISMATCH",
|
|
7264
|
+
gatewayCode: "PROTOCOL_MISMATCH",
|
|
7265
|
+
retryable: false,
|
|
7266
|
+
details: {
|
|
7267
|
+
closeCode,
|
|
7268
|
+
reason: closeReason
|
|
7269
|
+
}
|
|
7270
|
+
});
|
|
7271
|
+
}
|
|
7272
|
+
return Object.assign(new Error(`OpenClaw gateway connection closed code=${closeCode}`), {
|
|
7273
|
+
code: "ECONNRESET",
|
|
7274
|
+
retryable: true,
|
|
7275
|
+
details: {
|
|
7276
|
+
closeCode,
|
|
7277
|
+
reason: closeReason
|
|
7278
|
+
}
|
|
7279
|
+
});
|
|
7280
|
+
}
|
|
7238
7281
|
function normalizeSocketError(event) {
|
|
7239
7282
|
const message = event instanceof Error ? event.message : typeof event === "object" && event !== null && "message" in event ? String(event.message) : "OpenClaw gateway websocket error";
|
|
7240
7283
|
return Object.assign(new Error(message), { code: "ECONNRESET", retryable: true });
|
|
7241
7284
|
}
|
|
7285
|
+
function isOpenClawProtocolMismatch(err2) {
|
|
7286
|
+
const e = err2;
|
|
7287
|
+
const code2 = String(e?.gatewayCode ?? e?.code ?? e?.details?.code ?? "");
|
|
7288
|
+
if (code2 === "PROTOCOL_MISMATCH") {
|
|
7289
|
+
return true;
|
|
7290
|
+
}
|
|
7291
|
+
const reason = String(e?.details?.reason ?? "");
|
|
7292
|
+
const message = String(e?.message ?? "");
|
|
7293
|
+
const expectedProtocol = Number(e?.details?.expectedProtocol);
|
|
7294
|
+
return /protocol mismatch/i.test(reason) || /protocol mismatch/i.test(message) || expectedProtocol === PREFERRED_PROTOCOL_VERSION || expectedProtocol === LEGACY_PROTOCOL_VERSION;
|
|
7295
|
+
}
|
|
7296
|
+
function formatErrorMessage(err2) {
|
|
7297
|
+
return err2 instanceof Error ? err2.message : String(err2);
|
|
7298
|
+
}
|
|
7242
7299
|
function isSessionNotFound(err2) {
|
|
7243
7300
|
const e = err2;
|
|
7244
7301
|
const code2 = e?.gatewayCode ?? e?.code;
|
|
7245
7302
|
const msg = String(e?.message ?? "");
|
|
7246
7303
|
return (code2 === "INVALID_REQUEST" || code2 === "SESSION_NOT_FOUND") && msg.includes("session not found");
|
|
7247
7304
|
}
|
|
7248
|
-
var import_node_crypto3, DEFAULT_GATEWAY_PORT, DEFAULT_TIMEOUT_MS,
|
|
7305
|
+
var import_node_crypto3, DEFAULT_GATEWAY_PORT, DEFAULT_TIMEOUT_MS, PREFERRED_PROTOCOL_VERSION, LEGACY_PROTOCOL_VERSION, DEFAULT_SCOPES, LOG_PREFIX, GATEWAY_STARTING_RETRY_DELAYS_MS, wsFactory, preferredGatewayProtocolVersion, sharedClient, MinimalGatewayClient;
|
|
7249
7306
|
var init_openclaw_gateway = __esm({
|
|
7250
7307
|
"src/openclaw-gateway.ts"() {
|
|
7251
7308
|
"use strict";
|
|
@@ -7253,29 +7310,33 @@ var init_openclaw_gateway = __esm({
|
|
|
7253
7310
|
init_openclaw_gateway_config();
|
|
7254
7311
|
DEFAULT_GATEWAY_PORT = 18789;
|
|
7255
7312
|
DEFAULT_TIMEOUT_MS = 2e4;
|
|
7256
|
-
|
|
7313
|
+
PREFERRED_PROTOCOL_VERSION = 4;
|
|
7314
|
+
LEGACY_PROTOCOL_VERSION = 3;
|
|
7257
7315
|
DEFAULT_SCOPES = ["operator.admin"];
|
|
7258
7316
|
LOG_PREFIX = "[okx-a2a:gateway]";
|
|
7259
7317
|
GATEWAY_STARTING_RETRY_DELAYS_MS = [300, 700, 1200, 2e3, 3e3];
|
|
7260
7318
|
wsFactory = createDefaultWebSocket;
|
|
7319
|
+
preferredGatewayProtocolVersion = PREFERRED_PROTOCOL_VERSION;
|
|
7261
7320
|
sharedClient = null;
|
|
7262
7321
|
MinimalGatewayClient = class {
|
|
7263
7322
|
config;
|
|
7323
|
+
protocolVersion;
|
|
7264
7324
|
instanceId = (0, import_node_crypto3.randomUUID)();
|
|
7265
7325
|
pending = /* @__PURE__ */ new Map();
|
|
7266
7326
|
ws = null;
|
|
7267
7327
|
ready = false;
|
|
7268
7328
|
closed = false;
|
|
7269
7329
|
requestSeq = 0;
|
|
7270
|
-
constructor(config) {
|
|
7330
|
+
constructor(config, protocolVersion) {
|
|
7271
7331
|
this.config = config;
|
|
7332
|
+
this.protocolVersion = protocolVersion;
|
|
7272
7333
|
}
|
|
7273
7334
|
isReady() {
|
|
7274
7335
|
return this.ready && !this.closed && this.ws?.readyState === 1;
|
|
7275
7336
|
}
|
|
7276
7337
|
async connect(timeoutMs) {
|
|
7277
7338
|
console.error(
|
|
7278
|
-
`${LOG_PREFIX} connect url=${this.config.url} source=${this.config.source} instanceId=${this.instanceId} passwordConfigured=${!!this.config.password} tokenConfigured=${!!this.config.token} scopes=${DEFAULT_SCOPES.join(",")}`
|
|
7339
|
+
`${LOG_PREFIX} connect url=${this.config.url} source=${this.config.source} instanceId=${this.instanceId} protocol=${this.protocolVersion} passwordConfigured=${!!this.config.password} tokenConfigured=${!!this.config.token} scopes=${DEFAULT_SCOPES.join(",")}`
|
|
7279
7340
|
);
|
|
7280
7341
|
const ws = wsFactory(this.config.url);
|
|
7281
7342
|
this.ws = ws;
|
|
@@ -7327,14 +7388,11 @@ var init_openclaw_gateway = __esm({
|
|
|
7327
7388
|
if (!settled) {
|
|
7328
7389
|
settled = true;
|
|
7329
7390
|
clearTimeout(timer);
|
|
7330
|
-
reject(
|
|
7331
|
-
code: "ECONNRESET",
|
|
7332
|
-
retryable: true
|
|
7333
|
-
}));
|
|
7391
|
+
reject(toGatewayCloseError(closeEvent.code, closeEvent.reason));
|
|
7334
7392
|
}
|
|
7335
7393
|
});
|
|
7336
7394
|
});
|
|
7337
|
-
console.error(`${LOG_PREFIX} hello ok instanceId=${this.instanceId}`);
|
|
7395
|
+
console.error(`${LOG_PREFIX} hello ok instanceId=${this.instanceId} protocol=${this.protocolVersion}`);
|
|
7338
7396
|
}
|
|
7339
7397
|
request(method, params, options = {}) {
|
|
7340
7398
|
if (method === "connect") {
|
|
@@ -7393,7 +7451,11 @@ var init_openclaw_gateway = __esm({
|
|
|
7393
7451
|
this.ws = null;
|
|
7394
7452
|
}
|
|
7395
7453
|
async handleOpen(timeoutMs) {
|
|
7396
|
-
const hello = await this.request(
|
|
7454
|
+
const hello = await this.request(
|
|
7455
|
+
"connect",
|
|
7456
|
+
buildConnectParams(this.config, this.instanceId, this.protocolVersion),
|
|
7457
|
+
{ timeoutMs }
|
|
7458
|
+
);
|
|
7397
7459
|
if (!isHelloOk(hello)) {
|
|
7398
7460
|
throw Object.assign(new Error("OpenClaw gateway handshake did not return hello-ok"), {
|
|
7399
7461
|
code: "PROTOCOL_ERROR"
|
|
@@ -23715,7 +23777,7 @@ var init_sentry_config = __esm({
|
|
|
23715
23777
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
23716
23778
|
SENTRY_CONFIG = {
|
|
23717
23779
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
23718
|
-
release: "0.0.
|
|
23780
|
+
release: "0.0.12",
|
|
23719
23781
|
environment
|
|
23720
23782
|
};
|
|
23721
23783
|
}
|
|
@@ -90678,12 +90740,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
90678
90740
|
}));
|
|
90679
90741
|
}
|
|
90680
90742
|
});
|
|
90681
|
-
service.setPluginVersion("0.0.
|
|
90743
|
+
service.setPluginVersion("0.0.12");
|
|
90682
90744
|
await service.init();
|
|
90683
90745
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
90684
90746
|
if (pluginVersionStatus.unavailable) {
|
|
90685
90747
|
throw new Error(
|
|
90686
|
-
`@okxweb3/a2a-node v${"0.0.
|
|
90748
|
+
`@okxweb3/a2a-node v${"0.0.12"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
90687
90749
|
);
|
|
90688
90750
|
}
|
|
90689
90751
|
const systemConfig = service.getSystemConfig();
|
|
@@ -90701,7 +90763,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
90701
90763
|
onchainosAgentId: "*",
|
|
90702
90764
|
reason: "system-config missing sentryDsn",
|
|
90703
90765
|
pluginId: "@okxweb3/a2a-node",
|
|
90704
|
-
pluginVersion: "0.0.
|
|
90766
|
+
pluginVersion: "0.0.12"
|
|
90705
90767
|
});
|
|
90706
90768
|
}
|
|
90707
90769
|
console.log(
|
|
@@ -93548,7 +93610,7 @@ function isPrereleaseVersion(version2) {
|
|
|
93548
93610
|
}
|
|
93549
93611
|
function getCurrentNodeCliVersion() {
|
|
93550
93612
|
try {
|
|
93551
|
-
return "0.0.
|
|
93613
|
+
return "0.0.12";
|
|
93552
93614
|
} catch {
|
|
93553
93615
|
return null;
|
|
93554
93616
|
}
|
|
@@ -94011,7 +94073,7 @@ init_task_config();
|
|
|
94011
94073
|
init_sentry_logger();
|
|
94012
94074
|
init_sentry_config();
|
|
94013
94075
|
function printUsage2() {
|
|
94014
|
-
console.log(`okx-a2a ${"0.0.
|
|
94076
|
+
console.log(`okx-a2a ${"0.0.12"}
|
|
94015
94077
|
|
|
94016
94078
|
Usage:
|
|
94017
94079
|
okx-a2a <command> [options]
|
|
@@ -94048,7 +94110,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
|
|
|
94048
94110
|
`);
|
|
94049
94111
|
}
|
|
94050
94112
|
function printVersion() {
|
|
94051
|
-
console.log("0.0.
|
|
94113
|
+
console.log("0.0.12");
|
|
94052
94114
|
}
|
|
94053
94115
|
function printDaemonUsage() {
|
|
94054
94116
|
console.log(`Usage: okx-a2a daemon <start|restart|stop|status> [options]
|
package/dist/index.js
CHANGED
|
@@ -85460,11 +85460,13 @@ function readSyncedOpenClawGatewayConfig(homeDir = resolveA2aTaskHome()) {
|
|
|
85460
85460
|
// src/openclaw-gateway.ts
|
|
85461
85461
|
var DEFAULT_GATEWAY_PORT = 18789;
|
|
85462
85462
|
var DEFAULT_TIMEOUT_MS = 2e4;
|
|
85463
|
-
var
|
|
85463
|
+
var PREFERRED_PROTOCOL_VERSION = 4;
|
|
85464
|
+
var LEGACY_PROTOCOL_VERSION = 3;
|
|
85464
85465
|
var DEFAULT_SCOPES = ["operator.admin"];
|
|
85465
85466
|
var LOG_PREFIX = "[okx-a2a:gateway]";
|
|
85466
85467
|
var GATEWAY_STARTING_RETRY_DELAYS_MS = [300, 700, 1200, 2e3, 3e3];
|
|
85467
85468
|
var wsFactory = createDefaultWebSocket;
|
|
85469
|
+
var preferredGatewayProtocolVersion = PREFERRED_PROTOCOL_VERSION;
|
|
85468
85470
|
function createDefaultWebSocket(url) {
|
|
85469
85471
|
try {
|
|
85470
85472
|
const WebSocketCtor = require_ws();
|
|
@@ -85530,6 +85532,7 @@ function resolveOpenClawGatewayConfig(env = process.env) {
|
|
|
85530
85532
|
}
|
|
85531
85533
|
function setOpenClawWebSocketFactoryForTests(factory) {
|
|
85532
85534
|
wsFactory = factory ?? createDefaultWebSocket;
|
|
85535
|
+
preferredGatewayProtocolVersion = PREFERRED_PROTOCOL_VERSION;
|
|
85533
85536
|
clearClient();
|
|
85534
85537
|
}
|
|
85535
85538
|
function clearClient() {
|
|
@@ -85547,10 +85550,30 @@ async function ensureClient(timeoutMs) {
|
|
|
85547
85550
|
clearClient();
|
|
85548
85551
|
}
|
|
85549
85552
|
const config = resolveOpenClawGatewayConfig();
|
|
85550
|
-
const
|
|
85553
|
+
const startedAt = Date.now();
|
|
85554
|
+
const firstProtocol = preferredGatewayProtocolVersion;
|
|
85555
|
+
const client = new MinimalGatewayClient(config, firstProtocol);
|
|
85551
85556
|
sharedClient = client;
|
|
85552
|
-
|
|
85553
|
-
|
|
85557
|
+
try {
|
|
85558
|
+
await client.connect(timeoutMs);
|
|
85559
|
+
return client;
|
|
85560
|
+
} catch (err2) {
|
|
85561
|
+
if (!isOpenClawProtocolMismatch(err2)) {
|
|
85562
|
+
throw err2;
|
|
85563
|
+
}
|
|
85564
|
+
clearClient();
|
|
85565
|
+
const elapsedMs = Date.now() - startedAt;
|
|
85566
|
+
const remainingMs = Math.max(1, timeoutMs - elapsedMs);
|
|
85567
|
+
const fallbackProtocol = firstProtocol === PREFERRED_PROTOCOL_VERSION ? LEGACY_PROTOCOL_VERSION : PREFERRED_PROTOCOL_VERSION;
|
|
85568
|
+
console.error(
|
|
85569
|
+
`${LOG_PREFIX} protocol fallback from=${firstProtocol} to=${fallbackProtocol} remainingMs=${remainingMs}: ${formatErrorMessage(err2)}`
|
|
85570
|
+
);
|
|
85571
|
+
const fallbackClient = new MinimalGatewayClient(config, fallbackProtocol);
|
|
85572
|
+
sharedClient = fallbackClient;
|
|
85573
|
+
await fallbackClient.connect(remainingMs);
|
|
85574
|
+
preferredGatewayProtocolVersion = fallbackProtocol;
|
|
85575
|
+
return fallbackClient;
|
|
85576
|
+
}
|
|
85554
85577
|
}
|
|
85555
85578
|
function stopOpenClawGateway() {
|
|
85556
85579
|
if (!sharedClient) {
|
|
@@ -85663,21 +85686,23 @@ async function sleep(ms) {
|
|
|
85663
85686
|
}
|
|
85664
85687
|
var MinimalGatewayClient = class {
|
|
85665
85688
|
config;
|
|
85689
|
+
protocolVersion;
|
|
85666
85690
|
instanceId = (0, import_node_crypto6.randomUUID)();
|
|
85667
85691
|
pending = /* @__PURE__ */ new Map();
|
|
85668
85692
|
ws = null;
|
|
85669
85693
|
ready = false;
|
|
85670
85694
|
closed = false;
|
|
85671
85695
|
requestSeq = 0;
|
|
85672
|
-
constructor(config) {
|
|
85696
|
+
constructor(config, protocolVersion) {
|
|
85673
85697
|
this.config = config;
|
|
85698
|
+
this.protocolVersion = protocolVersion;
|
|
85674
85699
|
}
|
|
85675
85700
|
isReady() {
|
|
85676
85701
|
return this.ready && !this.closed && this.ws?.readyState === 1;
|
|
85677
85702
|
}
|
|
85678
85703
|
async connect(timeoutMs) {
|
|
85679
85704
|
console.error(
|
|
85680
|
-
`${LOG_PREFIX} connect url=${this.config.url} source=${this.config.source} instanceId=${this.instanceId} passwordConfigured=${!!this.config.password} tokenConfigured=${!!this.config.token} scopes=${DEFAULT_SCOPES.join(",")}`
|
|
85705
|
+
`${LOG_PREFIX} connect url=${this.config.url} source=${this.config.source} instanceId=${this.instanceId} protocol=${this.protocolVersion} passwordConfigured=${!!this.config.password} tokenConfigured=${!!this.config.token} scopes=${DEFAULT_SCOPES.join(",")}`
|
|
85681
85706
|
);
|
|
85682
85707
|
const ws = wsFactory(this.config.url);
|
|
85683
85708
|
this.ws = ws;
|
|
@@ -85729,14 +85754,11 @@ var MinimalGatewayClient = class {
|
|
|
85729
85754
|
if (!settled) {
|
|
85730
85755
|
settled = true;
|
|
85731
85756
|
clearTimeout(timer);
|
|
85732
|
-
reject(
|
|
85733
|
-
code: "ECONNRESET",
|
|
85734
|
-
retryable: true
|
|
85735
|
-
}));
|
|
85757
|
+
reject(toGatewayCloseError(closeEvent.code, closeEvent.reason));
|
|
85736
85758
|
}
|
|
85737
85759
|
});
|
|
85738
85760
|
});
|
|
85739
|
-
console.error(`${LOG_PREFIX} hello ok instanceId=${this.instanceId}`);
|
|
85761
|
+
console.error(`${LOG_PREFIX} hello ok instanceId=${this.instanceId} protocol=${this.protocolVersion}`);
|
|
85740
85762
|
}
|
|
85741
85763
|
request(method, params, options = {}) {
|
|
85742
85764
|
if (method === "connect") {
|
|
@@ -85795,7 +85817,11 @@ var MinimalGatewayClient = class {
|
|
|
85795
85817
|
this.ws = null;
|
|
85796
85818
|
}
|
|
85797
85819
|
async handleOpen(timeoutMs) {
|
|
85798
|
-
const hello = await this.request(
|
|
85820
|
+
const hello = await this.request(
|
|
85821
|
+
"connect",
|
|
85822
|
+
buildConnectParams(this.config, this.instanceId, this.protocolVersion),
|
|
85823
|
+
{ timeoutMs }
|
|
85824
|
+
);
|
|
85799
85825
|
if (!isHelloOk(hello)) {
|
|
85800
85826
|
throw Object.assign(new Error("OpenClaw gateway handshake did not return hello-ok"), {
|
|
85801
85827
|
code: "PROTOCOL_ERROR"
|
|
@@ -85858,14 +85884,14 @@ function readSyncedGatewayConfig(env) {
|
|
|
85858
85884
|
return null;
|
|
85859
85885
|
}
|
|
85860
85886
|
}
|
|
85861
|
-
function buildConnectParams(config, instanceId) {
|
|
85887
|
+
function buildConnectParams(config, instanceId, protocolVersion) {
|
|
85862
85888
|
return {
|
|
85863
|
-
minProtocol:
|
|
85864
|
-
maxProtocol:
|
|
85889
|
+
minProtocol: protocolVersion,
|
|
85890
|
+
maxProtocol: protocolVersion,
|
|
85865
85891
|
client: {
|
|
85866
85892
|
id: "gateway-client",
|
|
85867
85893
|
displayName: "okx-a2a-node",
|
|
85868
|
-
version: "0.0.
|
|
85894
|
+
version: "0.0.12",
|
|
85869
85895
|
platform: "node",
|
|
85870
85896
|
mode: "backend",
|
|
85871
85897
|
instanceId
|
|
@@ -85876,7 +85902,7 @@ function buildConnectParams(config, instanceId) {
|
|
|
85876
85902
|
commands: [],
|
|
85877
85903
|
permissions: {},
|
|
85878
85904
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
85879
|
-
userAgent: `okx-a2a-node/${"0.0.
|
|
85905
|
+
userAgent: `okx-a2a-node/${"0.0.12"}`,
|
|
85880
85906
|
auth: {
|
|
85881
85907
|
...config.token ? { token: config.token } : {},
|
|
85882
85908
|
...config.password ? { password: config.password } : {}
|
|
@@ -85895,10 +85921,47 @@ function toGatewayError(error) {
|
|
|
85895
85921
|
});
|
|
85896
85922
|
return err2;
|
|
85897
85923
|
}
|
|
85924
|
+
function toGatewayCloseError(code2, reason) {
|
|
85925
|
+
const closeCode = code2 ?? 0;
|
|
85926
|
+
const closeReason = reason || "";
|
|
85927
|
+
if (closeCode === 1002 && /protocol mismatch/i.test(closeReason)) {
|
|
85928
|
+
return Object.assign(new Error(`OpenClaw gateway protocol mismatch code=${closeCode} reason=${closeReason}`), {
|
|
85929
|
+
code: "PROTOCOL_MISMATCH",
|
|
85930
|
+
gatewayCode: "PROTOCOL_MISMATCH",
|
|
85931
|
+
retryable: false,
|
|
85932
|
+
details: {
|
|
85933
|
+
closeCode,
|
|
85934
|
+
reason: closeReason
|
|
85935
|
+
}
|
|
85936
|
+
});
|
|
85937
|
+
}
|
|
85938
|
+
return Object.assign(new Error(`OpenClaw gateway connection closed code=${closeCode}`), {
|
|
85939
|
+
code: "ECONNRESET",
|
|
85940
|
+
retryable: true,
|
|
85941
|
+
details: {
|
|
85942
|
+
closeCode,
|
|
85943
|
+
reason: closeReason
|
|
85944
|
+
}
|
|
85945
|
+
});
|
|
85946
|
+
}
|
|
85898
85947
|
function normalizeSocketError(event) {
|
|
85899
85948
|
const message = event instanceof Error ? event.message : typeof event === "object" && event !== null && "message" in event ? String(event.message) : "OpenClaw gateway websocket error";
|
|
85900
85949
|
return Object.assign(new Error(message), { code: "ECONNRESET", retryable: true });
|
|
85901
85950
|
}
|
|
85951
|
+
function isOpenClawProtocolMismatch(err2) {
|
|
85952
|
+
const e = err2;
|
|
85953
|
+
const code2 = String(e?.gatewayCode ?? e?.code ?? e?.details?.code ?? "");
|
|
85954
|
+
if (code2 === "PROTOCOL_MISMATCH") {
|
|
85955
|
+
return true;
|
|
85956
|
+
}
|
|
85957
|
+
const reason = String(e?.details?.reason ?? "");
|
|
85958
|
+
const message = String(e?.message ?? "");
|
|
85959
|
+
const expectedProtocol = Number(e?.details?.expectedProtocol);
|
|
85960
|
+
return /protocol mismatch/i.test(reason) || /protocol mismatch/i.test(message) || expectedProtocol === PREFERRED_PROTOCOL_VERSION || expectedProtocol === LEGACY_PROTOCOL_VERSION;
|
|
85961
|
+
}
|
|
85962
|
+
function formatErrorMessage(err2) {
|
|
85963
|
+
return err2 instanceof Error ? err2.message : String(err2);
|
|
85964
|
+
}
|
|
85902
85965
|
function isSessionNotFound(err2) {
|
|
85903
85966
|
const e = err2;
|
|
85904
85967
|
const code2 = e?.gatewayCode ?? e?.code;
|
|
@@ -89254,7 +89317,7 @@ function userWatchEventDeliveredSentryExtra(event) {
|
|
|
89254
89317
|
var environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
89255
89318
|
var SENTRY_CONFIG = {
|
|
89256
89319
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
89257
|
-
release: "0.0.
|
|
89320
|
+
release: "0.0.12",
|
|
89258
89321
|
environment
|
|
89259
89322
|
};
|
|
89260
89323
|
|
|
@@ -89373,12 +89436,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
89373
89436
|
}));
|
|
89374
89437
|
}
|
|
89375
89438
|
});
|
|
89376
|
-
service.setPluginVersion("0.0.
|
|
89439
|
+
service.setPluginVersion("0.0.12");
|
|
89377
89440
|
await service.init();
|
|
89378
89441
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
89379
89442
|
if (pluginVersionStatus.unavailable) {
|
|
89380
89443
|
throw new Error(
|
|
89381
|
-
`@okxweb3/a2a-node v${"0.0.
|
|
89444
|
+
`@okxweb3/a2a-node v${"0.0.12"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
89382
89445
|
);
|
|
89383
89446
|
}
|
|
89384
89447
|
const systemConfig = service.getSystemConfig();
|
|
@@ -89396,7 +89459,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
89396
89459
|
onchainosAgentId: "*",
|
|
89397
89460
|
reason: "system-config missing sentryDsn",
|
|
89398
89461
|
pluginId: "@okxweb3/a2a-node",
|
|
89399
|
-
pluginVersion: "0.0.
|
|
89462
|
+
pluginVersion: "0.0.12"
|
|
89400
89463
|
});
|
|
89401
89464
|
}
|
|
89402
89465
|
console.log(
|