@okxweb3/a2a-node 0.0.19 → 0.0.20-beta-17d080241c-260626102715
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 +138 -26
- package/dist/index.js +73 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7577,7 +7577,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
7577
7577
|
client: {
|
|
7578
7578
|
id: "gateway-client",
|
|
7579
7579
|
displayName: "okx-a2a-node",
|
|
7580
|
-
version: "0.0.
|
|
7580
|
+
version: "0.0.20-beta-17d080241c-260626102715",
|
|
7581
7581
|
platform: "node",
|
|
7582
7582
|
mode: "backend",
|
|
7583
7583
|
instanceId
|
|
@@ -7588,7 +7588,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
7588
7588
|
commands: [],
|
|
7589
7589
|
permissions: {},
|
|
7590
7590
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
7591
|
-
userAgent: `okx-a2a-node/${"0.0.
|
|
7591
|
+
userAgent: `okx-a2a-node/${"0.0.20-beta-17d080241c-260626102715"}`,
|
|
7592
7592
|
auth: {
|
|
7593
7593
|
...config.token ? { token: config.token } : {},
|
|
7594
7594
|
...config.password ? { password: config.password } : {}
|
|
@@ -7927,7 +7927,7 @@ var init_openclaw_session_key = __esm({
|
|
|
7927
7927
|
function currentOpenClawGatewaySessionKey(env = process.env) {
|
|
7928
7928
|
for (const candidate of currentOpenClawGatewaySessionCandidates(env)) {
|
|
7929
7929
|
if (candidate.ok) {
|
|
7930
|
-
return candidate.sessionKey;
|
|
7930
|
+
return canonicalizeOpenClawGatewaySessionKey(candidate.sessionKey);
|
|
7931
7931
|
}
|
|
7932
7932
|
}
|
|
7933
7933
|
return null;
|
|
@@ -7952,11 +7952,12 @@ function bindOpenClawGatewayRouteFromEnv(store, input, env = process.env) {
|
|
|
7952
7952
|
});
|
|
7953
7953
|
continue;
|
|
7954
7954
|
}
|
|
7955
|
-
const
|
|
7955
|
+
const sessionKey = canonicalizeOpenClawGatewaySessionKey(candidate.sessionKey);
|
|
7956
|
+
const channel = channelFromOpenClawGatewaySessionKey(sessionKey);
|
|
7956
7957
|
if (!channel) {
|
|
7957
7958
|
logOpenClawRouteSkip("invalid_gateway_session_key", {
|
|
7958
7959
|
jobId,
|
|
7959
|
-
sessionKey
|
|
7960
|
+
sessionKey,
|
|
7960
7961
|
existingRoute: resolveOpenClawGatewayRoute(store, { jobId })
|
|
7961
7962
|
});
|
|
7962
7963
|
continue;
|
|
@@ -7966,7 +7967,7 @@ function bindOpenClawGatewayRouteFromEnv(store, input, env = process.env) {
|
|
|
7966
7967
|
firstBound ??= existingRoute.gatewaySessionKey || existingRoute.sessionKey || null;
|
|
7967
7968
|
continue;
|
|
7968
7969
|
}
|
|
7969
|
-
const route = buildOpenClawRouteEntry(
|
|
7970
|
+
const route = buildOpenClawRouteEntry(sessionKey, channel);
|
|
7970
7971
|
routes = [...routes, route];
|
|
7971
7972
|
const binding = store.upsertJobGatewayRoute({ jobId, provider: "openclaw", route });
|
|
7972
7973
|
if (binding.provider !== "openclaw") {
|
|
@@ -8053,7 +8054,9 @@ function readOpenClawRouteEntries(store, jobId) {
|
|
|
8053
8054
|
const channelOrder = [];
|
|
8054
8055
|
const routeByChannel = /* @__PURE__ */ new Map();
|
|
8055
8056
|
for (const route of routes) {
|
|
8056
|
-
const sessionKey =
|
|
8057
|
+
const sessionKey = canonicalizeOpenClawGatewaySessionKey(
|
|
8058
|
+
normalizeText(route.gatewaySessionKey) ?? normalizeText(route.sessionKey) ?? ""
|
|
8059
|
+
);
|
|
8057
8060
|
const channel = channelFromOpenClawGatewaySessionKey(sessionKey);
|
|
8058
8061
|
if (!sessionKey || !channel) {
|
|
8059
8062
|
continue;
|
|
@@ -8106,20 +8109,70 @@ function parseOpenClawGatewaySessionKey(sessionKey) {
|
|
|
8106
8109
|
};
|
|
8107
8110
|
}
|
|
8108
8111
|
if (platform === "telegram" && targetKind === "direct") {
|
|
8112
|
+
const threadId = parseTelegramTopicSuffix(parts.slice(5));
|
|
8113
|
+
return {
|
|
8114
|
+
...parts[4] ? { chatId: parts[4] } : {},
|
|
8115
|
+
...threadId ? { threadId } : {},
|
|
8116
|
+
chatType: "dm"
|
|
8117
|
+
};
|
|
8118
|
+
}
|
|
8119
|
+
if (platform === "telegram" && targetKind === "dm") {
|
|
8120
|
+
const threadId = parseTelegramTopicSuffix(parts.slice(5));
|
|
8109
8121
|
return {
|
|
8110
8122
|
...parts[4] ? { chatId: parts[4] } : {},
|
|
8123
|
+
...threadId ? { threadId } : {},
|
|
8111
8124
|
chatType: "dm"
|
|
8112
8125
|
};
|
|
8113
8126
|
}
|
|
8114
8127
|
if (platform === "telegram" && targetKind === "group") {
|
|
8128
|
+
const threadId = parts[5] === "topic" ? parts[6] : parts[5];
|
|
8115
8129
|
return {
|
|
8116
8130
|
...parts[4] ? { chatId: parts[4] } : {},
|
|
8117
|
-
...
|
|
8118
|
-
chatType:
|
|
8131
|
+
...threadId ? { threadId } : {},
|
|
8132
|
+
chatType: threadId ? "thread" : "group"
|
|
8119
8133
|
};
|
|
8120
8134
|
}
|
|
8121
8135
|
return {};
|
|
8122
8136
|
}
|
|
8137
|
+
function canonicalizeOpenClawGatewaySessionKey(sessionKey) {
|
|
8138
|
+
const key = normalizeText(sessionKey);
|
|
8139
|
+
if (!key) {
|
|
8140
|
+
return sessionKey;
|
|
8141
|
+
}
|
|
8142
|
+
const parts = key.split(":");
|
|
8143
|
+
if (parts.length < 4 || parts[0] !== "agent") {
|
|
8144
|
+
return key;
|
|
8145
|
+
}
|
|
8146
|
+
const platform = parts[2];
|
|
8147
|
+
const targetKind = parts[3];
|
|
8148
|
+
if (platform !== "telegram") {
|
|
8149
|
+
return key;
|
|
8150
|
+
}
|
|
8151
|
+
if ((targetKind === "direct" || targetKind === "dm") && parts[4]) {
|
|
8152
|
+
const threadId = parseTelegramTopicSuffix(parts.slice(5));
|
|
8153
|
+
return threadId ? `agent:${parts[1]}:telegram:direct:${parts[4]}:topic:${threadId}` : `agent:${parts[1]}:telegram:direct:${parts[4]}`;
|
|
8154
|
+
}
|
|
8155
|
+
if (targetKind === "group" && parts[4]) {
|
|
8156
|
+
const threadId = parts[5] === "topic" ? parts[6] : parts[5];
|
|
8157
|
+
return threadId ? `agent:${parts[1]}:telegram:group:${parts[4]}:topic:${threadId}` : `agent:${parts[1]}:telegram:group:${parts[4]}`;
|
|
8158
|
+
}
|
|
8159
|
+
return key;
|
|
8160
|
+
}
|
|
8161
|
+
function parseTelegramTopicSuffix(parts) {
|
|
8162
|
+
if (parts.length === 0) {
|
|
8163
|
+
return void 0;
|
|
8164
|
+
}
|
|
8165
|
+
if (parts[0] === "topic") {
|
|
8166
|
+
return parts[1] || void 0;
|
|
8167
|
+
}
|
|
8168
|
+
if (parts[0] === "thread") {
|
|
8169
|
+
if (parts.length >= 3) {
|
|
8170
|
+
return parts.slice(2).join(":") || void 0;
|
|
8171
|
+
}
|
|
8172
|
+
return parts[1] || void 0;
|
|
8173
|
+
}
|
|
8174
|
+
return parts[0] || void 0;
|
|
8175
|
+
}
|
|
8123
8176
|
function validateOpenClawGatewaySessionKey(sessionKey) {
|
|
8124
8177
|
const key = normalizeText(sessionKey);
|
|
8125
8178
|
if (!key) {
|
|
@@ -8159,10 +8212,16 @@ function deriveOpenClawGatewaySessionKey(input) {
|
|
|
8159
8212
|
const chatId = encodeURIComponent(input.chatId);
|
|
8160
8213
|
const threadId = input.threadId ? encodeURIComponent(input.threadId) : "";
|
|
8161
8214
|
if (input.platform === "telegram") {
|
|
8162
|
-
|
|
8215
|
+
if (!threadId) {
|
|
8216
|
+
return `agent:main:telegram:direct:${chatId}`;
|
|
8217
|
+
}
|
|
8218
|
+
return isTelegramGroupChatId(input.chatId) ? `agent:main:telegram:group:${chatId}:topic:${threadId}` : `agent:main:telegram:direct:${chatId}:topic:${threadId}`;
|
|
8163
8219
|
}
|
|
8164
8220
|
return threadId ? `agent:main:${input.platform}:thread:${chatId}:${threadId}` : `agent:main:${input.platform}:dm:${chatId}`;
|
|
8165
8221
|
}
|
|
8222
|
+
function isTelegramGroupChatId(chatId) {
|
|
8223
|
+
return chatId.startsWith("-") || chatId.startsWith("@");
|
|
8224
|
+
}
|
|
8166
8225
|
function readGatewaySessionKeysEnv(env) {
|
|
8167
8226
|
const raw = normalizeText(env[CURRENT_GATEWAY_SESSION_KEYS_ENV]);
|
|
8168
8227
|
if (!raw) {
|
|
@@ -24748,7 +24807,7 @@ var init_sentry_config = __esm({
|
|
|
24748
24807
|
environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
24749
24808
|
SENTRY_CONFIG = {
|
|
24750
24809
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
24751
|
-
release: "0.0.
|
|
24810
|
+
release: "0.0.20-beta-17d080241c-260626102715",
|
|
24752
24811
|
environment
|
|
24753
24812
|
};
|
|
24754
24813
|
}
|
|
@@ -92488,12 +92547,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
92488
92547
|
}));
|
|
92489
92548
|
}
|
|
92490
92549
|
});
|
|
92491
|
-
service.setPluginVersion("0.0.
|
|
92550
|
+
service.setPluginVersion("0.0.20-beta-17d080241c-260626102715");
|
|
92492
92551
|
await service.init();
|
|
92493
92552
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
92494
92553
|
if (pluginVersionStatus.unavailable) {
|
|
92495
92554
|
throw new Error(
|
|
92496
|
-
`@okxweb3/a2a-node v${"0.0.
|
|
92555
|
+
`@okxweb3/a2a-node v${"0.0.20-beta-17d080241c-260626102715"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
92497
92556
|
);
|
|
92498
92557
|
}
|
|
92499
92558
|
const systemConfig = service.getSystemConfig();
|
|
@@ -92511,7 +92570,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
92511
92570
|
onchainosAgentId: "*",
|
|
92512
92571
|
reason: "system-config missing sentryDsn",
|
|
92513
92572
|
pluginId: "@okxweb3/a2a-node",
|
|
92514
|
-
pluginVersion: "0.0.
|
|
92573
|
+
pluginVersion: "0.0.20-beta-17d080241c-260626102715"
|
|
92515
92574
|
});
|
|
92516
92575
|
}
|
|
92517
92576
|
logWithTimestamp(
|
|
@@ -93998,12 +94057,14 @@ function bindHermesAttentionRouteIfAvailable(store, input) {
|
|
|
93998
94057
|
function currentHermesRouteFromEnv() {
|
|
93999
94058
|
const platform = normalizeOptionalText2(process.env.OKX_A2A_CURRENT_GATEWAY_PLATFORM);
|
|
94000
94059
|
const chatId = normalizeOptionalText2(process.env.OKX_A2A_CURRENT_GATEWAY_CHAT_ID);
|
|
94001
|
-
const threadId = normalizeOptionalText2(process.env.OKX_A2A_CURRENT_GATEWAY_THREAD_ID);
|
|
94002
94060
|
if (!platform || !chatId) {
|
|
94003
94061
|
return null;
|
|
94004
94062
|
}
|
|
94063
|
+
const envGatewaySessionKey = normalizeOptionalText2(process.env.OKX_A2A_CURRENT_GATEWAY_SESSION_KEY);
|
|
94064
|
+
const parsedGatewaySession = parseHermesGatewaySessionKey(envGatewaySessionKey);
|
|
94065
|
+
const threadId = normalizeOptionalText2(process.env.OKX_A2A_CURRENT_GATEWAY_THREAD_ID) ?? matchingParsedThreadId(parsedGatewaySession, { platform, chatId });
|
|
94005
94066
|
const chatType = threadId ? "thread" : "dm";
|
|
94006
|
-
const gatewaySessionKey =
|
|
94067
|
+
const gatewaySessionKey = envGatewaySessionKey ?? (threadId ? `agent:main:${platform}:thread:${encodeURIComponent(chatId)}:${encodeURIComponent(threadId)}` : `agent:main:${platform}:dm:${encodeURIComponent(chatId)}`);
|
|
94007
94068
|
return {
|
|
94008
94069
|
platform,
|
|
94009
94070
|
chat_id: chatId,
|
|
@@ -94016,6 +94077,41 @@ function currentHermesRouteFromEnv() {
|
|
|
94016
94077
|
gateway_session_key: gatewaySessionKey
|
|
94017
94078
|
};
|
|
94018
94079
|
}
|
|
94080
|
+
function parseHermesGatewaySessionKey(sessionKey) {
|
|
94081
|
+
const normalized = normalizeOptionalText2(sessionKey);
|
|
94082
|
+
if (!normalized) {
|
|
94083
|
+
return null;
|
|
94084
|
+
}
|
|
94085
|
+
const parts = normalized.startsWith("agent:") ? normalized.split(":").slice(2) : normalized.split(":");
|
|
94086
|
+
if (parts.length < 3) {
|
|
94087
|
+
return null;
|
|
94088
|
+
}
|
|
94089
|
+
const [platform, scope, ...rest] = parts;
|
|
94090
|
+
if (!platform || platform === "okx-a2a" || platform === "backup" || platform === "job") {
|
|
94091
|
+
return null;
|
|
94092
|
+
}
|
|
94093
|
+
if (scope === "dm" && rest[0]) {
|
|
94094
|
+
return {
|
|
94095
|
+
platform,
|
|
94096
|
+
chatId: safeDecodeURIComponent2(rest[0]),
|
|
94097
|
+
...platform === "telegram" && rest[1] ? { threadId: safeDecodeURIComponent2(rest.slice(1).join(":")) } : {}
|
|
94098
|
+
};
|
|
94099
|
+
}
|
|
94100
|
+
if (scope === "thread" && rest[0] && rest[1]) {
|
|
94101
|
+
return {
|
|
94102
|
+
platform,
|
|
94103
|
+
chatId: safeDecodeURIComponent2(rest[0]),
|
|
94104
|
+
threadId: safeDecodeURIComponent2(rest.slice(1).join(":"))
|
|
94105
|
+
};
|
|
94106
|
+
}
|
|
94107
|
+
return null;
|
|
94108
|
+
}
|
|
94109
|
+
function matchingParsedThreadId(parsed, expected) {
|
|
94110
|
+
if (!parsed || parsed.platform !== expected.platform || parsed.chatId !== expected.chatId) {
|
|
94111
|
+
return null;
|
|
94112
|
+
}
|
|
94113
|
+
return normalizeOptionalText2(parsed.threadId);
|
|
94114
|
+
}
|
|
94019
94115
|
function persistHermesRouteBinding(store, input) {
|
|
94020
94116
|
store.upsertJobGatewayRoute({
|
|
94021
94117
|
jobId: input.jobId,
|
|
@@ -94737,13 +94833,15 @@ function bindHermesSessionRouteIfAvailable(store, session) {
|
|
|
94737
94833
|
function currentHermesRouteFromEnv2() {
|
|
94738
94834
|
const platform = normalizeOptionalText3(process.env.OKX_A2A_CURRENT_GATEWAY_PLATFORM);
|
|
94739
94835
|
const chatId = normalizeOptionalText3(process.env.OKX_A2A_CURRENT_GATEWAY_CHAT_ID);
|
|
94740
|
-
const threadId = normalizeOptionalText3(process.env.OKX_A2A_CURRENT_GATEWAY_THREAD_ID);
|
|
94741
94836
|
if (platform && chatId) {
|
|
94837
|
+
const sessionKey = normalizeOptionalText3(process.env.OKX_A2A_CURRENT_GATEWAY_SESSION_KEY);
|
|
94838
|
+
const parsedGatewaySession = parseHermesGatewaySessionKey2(sessionKey);
|
|
94839
|
+
const threadId = normalizeOptionalText3(process.env.OKX_A2A_CURRENT_GATEWAY_THREAD_ID) ?? matchingParsedThreadId2(parsedGatewaySession, { platform, chatId });
|
|
94742
94840
|
return buildHermesRouteEntry({
|
|
94743
94841
|
platform,
|
|
94744
94842
|
chatId,
|
|
94745
94843
|
threadId,
|
|
94746
|
-
sessionKey
|
|
94844
|
+
sessionKey
|
|
94747
94845
|
});
|
|
94748
94846
|
}
|
|
94749
94847
|
return routeFromHermesSessionEnv() ?? routeFromHermesSessionKey(process.env.HERMES_SESSION_KEY);
|
|
@@ -94783,14 +94881,18 @@ function routeFromHermesSessionKey(value) {
|
|
|
94783
94881
|
if (!sessionKey) {
|
|
94784
94882
|
return null;
|
|
94785
94883
|
}
|
|
94786
|
-
const parsed =
|
|
94884
|
+
const parsed = parseHermesGatewaySessionKey2(sessionKey);
|
|
94787
94885
|
if (!parsed) {
|
|
94788
94886
|
return null;
|
|
94789
94887
|
}
|
|
94790
94888
|
return buildHermesRouteEntry({ ...parsed, sessionKey });
|
|
94791
94889
|
}
|
|
94792
|
-
function
|
|
94793
|
-
const
|
|
94890
|
+
function parseHermesGatewaySessionKey2(sessionKey) {
|
|
94891
|
+
const normalized = normalizeOptionalText3(sessionKey);
|
|
94892
|
+
if (!normalized) {
|
|
94893
|
+
return null;
|
|
94894
|
+
}
|
|
94895
|
+
const parts = normalized.startsWith("agent:") ? normalized.split(":").slice(2) : normalized.split(":");
|
|
94794
94896
|
if (parts.length < 3) {
|
|
94795
94897
|
return null;
|
|
94796
94898
|
}
|
|
@@ -94799,17 +94901,27 @@ function parseHermesGatewaySessionKey(sessionKey) {
|
|
|
94799
94901
|
return null;
|
|
94800
94902
|
}
|
|
94801
94903
|
if (scope === "dm" && rest[0]) {
|
|
94802
|
-
return {
|
|
94904
|
+
return {
|
|
94905
|
+
platform,
|
|
94906
|
+
chatId: safeDecodeURIComponent3(rest[0]),
|
|
94907
|
+
...platform === "telegram" && rest[1] ? { threadId: safeDecodeURIComponent3(rest.slice(1).join(":")) } : {}
|
|
94908
|
+
};
|
|
94803
94909
|
}
|
|
94804
94910
|
if (scope === "thread" && rest[0] && rest[1]) {
|
|
94805
94911
|
return {
|
|
94806
94912
|
platform,
|
|
94807
94913
|
chatId: safeDecodeURIComponent3(rest[0]),
|
|
94808
|
-
threadId: safeDecodeURIComponent3(rest
|
|
94914
|
+
threadId: safeDecodeURIComponent3(rest.slice(1).join(":"))
|
|
94809
94915
|
};
|
|
94810
94916
|
}
|
|
94811
94917
|
return null;
|
|
94812
94918
|
}
|
|
94919
|
+
function matchingParsedThreadId2(parsed, expected) {
|
|
94920
|
+
if (!parsed || parsed.platform !== expected.platform || parsed.chatId !== expected.chatId) {
|
|
94921
|
+
return null;
|
|
94922
|
+
}
|
|
94923
|
+
return normalizeOptionalText3(parsed.threadId);
|
|
94924
|
+
}
|
|
94813
94925
|
function resolveSessionDeleteProvider(store, jobId) {
|
|
94814
94926
|
const normalizedJobId = jobId?.trim() || null;
|
|
94815
94927
|
if (normalizedJobId) {
|
|
@@ -95623,7 +95735,7 @@ async function getCurrentNodeCliVersion() {
|
|
|
95623
95735
|
return await getGlobalNpmPackageVersion(UPDATE_PACKAGES.node) ?? getBundledNodeCliVersion();
|
|
95624
95736
|
}
|
|
95625
95737
|
function getBundledNodeCliVersion() {
|
|
95626
|
-
return true ? "0.0.
|
|
95738
|
+
return true ? "0.0.20-beta-17d080241c-260626102715" : null;
|
|
95627
95739
|
}
|
|
95628
95740
|
function readConfiguredAiProvider() {
|
|
95629
95741
|
const explicit = process.env.OKX_AGENT_TASK_AI_CLI ?? process.env.OKX_A2A_AI_PROVIDER;
|
|
@@ -96456,7 +96568,7 @@ init_sentry_logger();
|
|
|
96456
96568
|
init_sentry_config();
|
|
96457
96569
|
var CURRENT_GATEWAY_SESSION_KEYS_ENV2 = "OKX_A2A_CURRENT_GATEWAY_SESSION_KEYS";
|
|
96458
96570
|
function printUsage2() {
|
|
96459
|
-
console.log(`okx-a2a ${"0.0.
|
|
96571
|
+
console.log(`okx-a2a ${"0.0.20-beta-17d080241c-260626102715"}
|
|
96460
96572
|
|
|
96461
96573
|
Usage:
|
|
96462
96574
|
okx-a2a <command> [options]
|
|
@@ -96493,7 +96605,7 @@ Run \`okx-a2a <command> -h\` for command-specific help.
|
|
|
96493
96605
|
`);
|
|
96494
96606
|
}
|
|
96495
96607
|
function printVersion() {
|
|
96496
|
-
console.log("0.0.
|
|
96608
|
+
console.log("0.0.20-beta-17d080241c-260626102715");
|
|
96497
96609
|
}
|
|
96498
96610
|
function printDaemonUsage() {
|
|
96499
96611
|
console.log(`Usage: okx-a2a daemon <start|restart|stop|status|autostart> [options]
|
package/dist/index.js
CHANGED
|
@@ -86421,7 +86421,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
86421
86421
|
client: {
|
|
86422
86422
|
id: "gateway-client",
|
|
86423
86423
|
displayName: "okx-a2a-node",
|
|
86424
|
-
version: "0.0.
|
|
86424
|
+
version: "0.0.20-beta-17d080241c-260626102715",
|
|
86425
86425
|
platform: "node",
|
|
86426
86426
|
mode: "backend",
|
|
86427
86427
|
instanceId
|
|
@@ -86432,7 +86432,7 @@ function buildConnectParams(config, instanceId, protocolVersion) {
|
|
|
86432
86432
|
commands: [],
|
|
86433
86433
|
permissions: {},
|
|
86434
86434
|
locale: Intl.DateTimeFormat().resolvedOptions().locale || "en-US",
|
|
86435
|
-
userAgent: `okx-a2a-node/${"0.0.
|
|
86435
|
+
userAgent: `okx-a2a-node/${"0.0.20-beta-17d080241c-260626102715"}`,
|
|
86436
86436
|
auth: {
|
|
86437
86437
|
...config.token ? { token: config.token } : {},
|
|
86438
86438
|
...config.password ? { password: config.password } : {}
|
|
@@ -86568,7 +86568,7 @@ var ACTIVE_ORIGIN_TTL_MS = 30 * 6e4;
|
|
|
86568
86568
|
function currentOpenClawGatewaySessionKey(env = process.env) {
|
|
86569
86569
|
for (const candidate of currentOpenClawGatewaySessionCandidates(env)) {
|
|
86570
86570
|
if (candidate.ok) {
|
|
86571
|
-
return candidate.sessionKey;
|
|
86571
|
+
return canonicalizeOpenClawGatewaySessionKey(candidate.sessionKey);
|
|
86572
86572
|
}
|
|
86573
86573
|
}
|
|
86574
86574
|
return null;
|
|
@@ -86593,11 +86593,12 @@ function bindOpenClawGatewayRouteFromEnv(store, input, env = process.env) {
|
|
|
86593
86593
|
});
|
|
86594
86594
|
continue;
|
|
86595
86595
|
}
|
|
86596
|
-
const
|
|
86596
|
+
const sessionKey = canonicalizeOpenClawGatewaySessionKey(candidate.sessionKey);
|
|
86597
|
+
const channel = channelFromOpenClawGatewaySessionKey(sessionKey);
|
|
86597
86598
|
if (!channel) {
|
|
86598
86599
|
logOpenClawRouteSkip("invalid_gateway_session_key", {
|
|
86599
86600
|
jobId,
|
|
86600
|
-
sessionKey
|
|
86601
|
+
sessionKey,
|
|
86601
86602
|
existingRoute: resolveOpenClawGatewayRoute(store, { jobId })
|
|
86602
86603
|
});
|
|
86603
86604
|
continue;
|
|
@@ -86607,7 +86608,7 @@ function bindOpenClawGatewayRouteFromEnv(store, input, env = process.env) {
|
|
|
86607
86608
|
firstBound ??= existingRoute.gatewaySessionKey || existingRoute.sessionKey || null;
|
|
86608
86609
|
continue;
|
|
86609
86610
|
}
|
|
86610
|
-
const route = buildOpenClawRouteEntry(
|
|
86611
|
+
const route = buildOpenClawRouteEntry(sessionKey, channel);
|
|
86611
86612
|
routes = [...routes, route];
|
|
86612
86613
|
const binding = store.upsertJobGatewayRoute({ jobId, provider: "openclaw", route });
|
|
86613
86614
|
if (binding.provider !== "openclaw") {
|
|
@@ -86694,7 +86695,9 @@ function readOpenClawRouteEntries(store, jobId) {
|
|
|
86694
86695
|
const channelOrder = [];
|
|
86695
86696
|
const routeByChannel = /* @__PURE__ */ new Map();
|
|
86696
86697
|
for (const route of routes) {
|
|
86697
|
-
const sessionKey =
|
|
86698
|
+
const sessionKey = canonicalizeOpenClawGatewaySessionKey(
|
|
86699
|
+
normalizeText(route.gatewaySessionKey) ?? normalizeText(route.sessionKey) ?? ""
|
|
86700
|
+
);
|
|
86698
86701
|
const channel = channelFromOpenClawGatewaySessionKey(sessionKey);
|
|
86699
86702
|
if (!sessionKey || !channel) {
|
|
86700
86703
|
continue;
|
|
@@ -86747,20 +86750,70 @@ function parseOpenClawGatewaySessionKey(sessionKey) {
|
|
|
86747
86750
|
};
|
|
86748
86751
|
}
|
|
86749
86752
|
if (platform === "telegram" && targetKind === "direct") {
|
|
86753
|
+
const threadId = parseTelegramTopicSuffix(parts.slice(5));
|
|
86750
86754
|
return {
|
|
86751
86755
|
...parts[4] ? { chatId: parts[4] } : {},
|
|
86756
|
+
...threadId ? { threadId } : {},
|
|
86757
|
+
chatType: "dm"
|
|
86758
|
+
};
|
|
86759
|
+
}
|
|
86760
|
+
if (platform === "telegram" && targetKind === "dm") {
|
|
86761
|
+
const threadId = parseTelegramTopicSuffix(parts.slice(5));
|
|
86762
|
+
return {
|
|
86763
|
+
...parts[4] ? { chatId: parts[4] } : {},
|
|
86764
|
+
...threadId ? { threadId } : {},
|
|
86752
86765
|
chatType: "dm"
|
|
86753
86766
|
};
|
|
86754
86767
|
}
|
|
86755
86768
|
if (platform === "telegram" && targetKind === "group") {
|
|
86769
|
+
const threadId = parts[5] === "topic" ? parts[6] : parts[5];
|
|
86756
86770
|
return {
|
|
86757
86771
|
...parts[4] ? { chatId: parts[4] } : {},
|
|
86758
|
-
...
|
|
86759
|
-
chatType:
|
|
86772
|
+
...threadId ? { threadId } : {},
|
|
86773
|
+
chatType: threadId ? "thread" : "group"
|
|
86760
86774
|
};
|
|
86761
86775
|
}
|
|
86762
86776
|
return {};
|
|
86763
86777
|
}
|
|
86778
|
+
function canonicalizeOpenClawGatewaySessionKey(sessionKey) {
|
|
86779
|
+
const key = normalizeText(sessionKey);
|
|
86780
|
+
if (!key) {
|
|
86781
|
+
return sessionKey;
|
|
86782
|
+
}
|
|
86783
|
+
const parts = key.split(":");
|
|
86784
|
+
if (parts.length < 4 || parts[0] !== "agent") {
|
|
86785
|
+
return key;
|
|
86786
|
+
}
|
|
86787
|
+
const platform = parts[2];
|
|
86788
|
+
const targetKind = parts[3];
|
|
86789
|
+
if (platform !== "telegram") {
|
|
86790
|
+
return key;
|
|
86791
|
+
}
|
|
86792
|
+
if ((targetKind === "direct" || targetKind === "dm") && parts[4]) {
|
|
86793
|
+
const threadId = parseTelegramTopicSuffix(parts.slice(5));
|
|
86794
|
+
return threadId ? `agent:${parts[1]}:telegram:direct:${parts[4]}:topic:${threadId}` : `agent:${parts[1]}:telegram:direct:${parts[4]}`;
|
|
86795
|
+
}
|
|
86796
|
+
if (targetKind === "group" && parts[4]) {
|
|
86797
|
+
const threadId = parts[5] === "topic" ? parts[6] : parts[5];
|
|
86798
|
+
return threadId ? `agent:${parts[1]}:telegram:group:${parts[4]}:topic:${threadId}` : `agent:${parts[1]}:telegram:group:${parts[4]}`;
|
|
86799
|
+
}
|
|
86800
|
+
return key;
|
|
86801
|
+
}
|
|
86802
|
+
function parseTelegramTopicSuffix(parts) {
|
|
86803
|
+
if (parts.length === 0) {
|
|
86804
|
+
return void 0;
|
|
86805
|
+
}
|
|
86806
|
+
if (parts[0] === "topic") {
|
|
86807
|
+
return parts[1] || void 0;
|
|
86808
|
+
}
|
|
86809
|
+
if (parts[0] === "thread") {
|
|
86810
|
+
if (parts.length >= 3) {
|
|
86811
|
+
return parts.slice(2).join(":") || void 0;
|
|
86812
|
+
}
|
|
86813
|
+
return parts[1] || void 0;
|
|
86814
|
+
}
|
|
86815
|
+
return parts[0] || void 0;
|
|
86816
|
+
}
|
|
86764
86817
|
function validateOpenClawGatewaySessionKey(sessionKey) {
|
|
86765
86818
|
const key = normalizeText(sessionKey);
|
|
86766
86819
|
if (!key) {
|
|
@@ -86800,10 +86853,16 @@ function deriveOpenClawGatewaySessionKey(input) {
|
|
|
86800
86853
|
const chatId = encodeURIComponent(input.chatId);
|
|
86801
86854
|
const threadId = input.threadId ? encodeURIComponent(input.threadId) : "";
|
|
86802
86855
|
if (input.platform === "telegram") {
|
|
86803
|
-
|
|
86856
|
+
if (!threadId) {
|
|
86857
|
+
return `agent:main:telegram:direct:${chatId}`;
|
|
86858
|
+
}
|
|
86859
|
+
return isTelegramGroupChatId(input.chatId) ? `agent:main:telegram:group:${chatId}:topic:${threadId}` : `agent:main:telegram:direct:${chatId}:topic:${threadId}`;
|
|
86804
86860
|
}
|
|
86805
86861
|
return threadId ? `agent:main:${input.platform}:thread:${chatId}:${threadId}` : `agent:main:${input.platform}:dm:${chatId}`;
|
|
86806
86862
|
}
|
|
86863
|
+
function isTelegramGroupChatId(chatId) {
|
|
86864
|
+
return chatId.startsWith("-") || chatId.startsWith("@");
|
|
86865
|
+
}
|
|
86807
86866
|
function readGatewaySessionKeysEnv(env) {
|
|
86808
86867
|
const raw = normalizeText(env[CURRENT_GATEWAY_SESSION_KEYS_ENV]);
|
|
86809
86868
|
if (!raw) {
|
|
@@ -90588,7 +90647,7 @@ function userWatchEventDeliveredSentryExtra(event) {
|
|
|
90588
90647
|
var environment = process.env.SENTRY_ENV === "dev" ? "dev" : "prod";
|
|
90589
90648
|
var SENTRY_CONFIG = {
|
|
90590
90649
|
projectName: "okx/openclaw-okx-a2a-extension",
|
|
90591
|
-
release: "0.0.
|
|
90650
|
+
release: "0.0.20-beta-17d080241c-260626102715",
|
|
90592
90651
|
environment
|
|
90593
90652
|
};
|
|
90594
90653
|
|
|
@@ -90815,12 +90874,12 @@ async function runListenerWithLock(options, paths) {
|
|
|
90815
90874
|
}));
|
|
90816
90875
|
}
|
|
90817
90876
|
});
|
|
90818
|
-
service.setPluginVersion("0.0.
|
|
90877
|
+
service.setPluginVersion("0.0.20-beta-17d080241c-260626102715");
|
|
90819
90878
|
await service.init();
|
|
90820
90879
|
const pluginVersionStatus = service.pluginVersionStatus;
|
|
90821
90880
|
if (pluginVersionStatus.unavailable) {
|
|
90822
90881
|
throw new Error(
|
|
90823
|
-
`@okxweb3/a2a-node v${"0.0.
|
|
90882
|
+
`@okxweb3/a2a-node v${"0.0.20-beta-17d080241c-260626102715"} is below the required minimum v${pluginVersionStatus.minVersion}`
|
|
90824
90883
|
);
|
|
90825
90884
|
}
|
|
90826
90885
|
const systemConfig = service.getSystemConfig();
|
|
@@ -90838,7 +90897,7 @@ async function runListenerWithLock(options, paths) {
|
|
|
90838
90897
|
onchainosAgentId: "*",
|
|
90839
90898
|
reason: "system-config missing sentryDsn",
|
|
90840
90899
|
pluginId: "@okxweb3/a2a-node",
|
|
90841
|
-
pluginVersion: "0.0.
|
|
90900
|
+
pluginVersion: "0.0.20-beta-17d080241c-260626102715"
|
|
90842
90901
|
});
|
|
90843
90902
|
}
|
|
90844
90903
|
logWithTimestamp(
|
package/package.json
CHANGED