multiclaws 0.4.38 → 0.4.40
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.
|
@@ -290,16 +290,38 @@ class OpenClawAgentExecutor {
|
|
|
290
290
|
if (!this.gatewayConfig)
|
|
291
291
|
return null;
|
|
292
292
|
try {
|
|
293
|
-
const
|
|
293
|
+
const raw = await (0, gateway_client_1.invokeGatewayTool)({
|
|
294
294
|
gateway: this.gatewayConfig,
|
|
295
295
|
tool: "sessions_list",
|
|
296
296
|
args: { limit: 10, activeMinutes: 120 },
|
|
297
297
|
timeoutMs: 5_000,
|
|
298
298
|
});
|
|
299
|
+
this.logger.info(`[a2a-adapter] discoverActiveSession: raw result = ${JSON.stringify(raw).slice(0, 500)}`);
|
|
300
|
+
// Unwrap gateway tool standard response: { content: [{ type: "text", text: "..." }] }
|
|
301
|
+
let parsed = raw;
|
|
302
|
+
if (raw?.content?.[0]?.type === "text") {
|
|
303
|
+
try {
|
|
304
|
+
parsed = JSON.parse(raw.content[0].text);
|
|
305
|
+
}
|
|
306
|
+
catch { /* use raw */ }
|
|
307
|
+
}
|
|
308
|
+
const sessions = parsed?.sessions ?? [];
|
|
309
|
+
this.logger.info(`[a2a-adapter] discoverActiveSession: found ${sessions.length} sessions`);
|
|
299
310
|
const INTERNAL_PREFIXES = ["delegate-", "a2a-"];
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
311
|
+
// sessions_list returns "key" not "sessionKey"
|
|
312
|
+
const session = sessions.find((s) => {
|
|
313
|
+
const k = (s.key ?? s.sessionKey);
|
|
314
|
+
return k && !INTERNAL_PREFIXES.some((p) => k.startsWith(p));
|
|
315
|
+
});
|
|
316
|
+
const matchedKey = (session?.key ?? session?.sessionKey);
|
|
317
|
+
if (matchedKey) {
|
|
318
|
+
this.logger.info(`[a2a-adapter] discoverActiveSession: matched session ${matchedKey}`);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
this.logger.warn(`[a2a-adapter] discoverActiveSession: all ${sessions.length} sessions filtered or empty`);
|
|
322
|
+
sessions.forEach((s) => this.logger.info(`[a2a-adapter] session: ${(s.key ?? s.sessionKey) ?? "(no key)"}`));
|
|
323
|
+
}
|
|
324
|
+
return matchedKey ?? null;
|
|
303
325
|
}
|
|
304
326
|
catch (err) {
|
|
305
327
|
this.logger.warn(`[a2a-adapter] discoverActiveSession failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -985,15 +985,38 @@ class MulticlawsService extends node_events_1.EventEmitter {
|
|
|
985
985
|
if (!this.gatewayConfig)
|
|
986
986
|
return null;
|
|
987
987
|
try {
|
|
988
|
-
const
|
|
988
|
+
const raw = await (0, gateway_client_1.invokeGatewayTool)({
|
|
989
989
|
gateway: this.gatewayConfig,
|
|
990
990
|
tool: "sessions_list",
|
|
991
991
|
args: { limit: 10, activeMinutes: 120 },
|
|
992
992
|
timeoutMs: 5_000,
|
|
993
993
|
});
|
|
994
|
+
this.log("info", `discoverActiveSession: raw result = ${JSON.stringify(raw).slice(0, 500)}`);
|
|
995
|
+
// Unwrap gateway tool standard response: { content: [{ type: "text", text: "..." }] }
|
|
996
|
+
let parsed = raw;
|
|
997
|
+
if (raw?.content?.[0]?.type === "text") {
|
|
998
|
+
try {
|
|
999
|
+
parsed = JSON.parse(raw.content[0].text);
|
|
1000
|
+
}
|
|
1001
|
+
catch { /* use raw */ }
|
|
1002
|
+
}
|
|
1003
|
+
const sessions = parsed?.sessions ?? [];
|
|
1004
|
+
this.log("info", `discoverActiveSession: found ${sessions.length} sessions`);
|
|
994
1005
|
const INTERNAL_PREFIXES = ["delegate-", "a2a-"];
|
|
995
|
-
|
|
996
|
-
|
|
1006
|
+
// sessions_list returns "key" not "sessionKey"
|
|
1007
|
+
const session = sessions.find((s) => {
|
|
1008
|
+
const k = (s.key ?? s.sessionKey);
|
|
1009
|
+
return k && !INTERNAL_PREFIXES.some((p) => k.startsWith(p));
|
|
1010
|
+
});
|
|
1011
|
+
const matchedKey = (session?.key ?? session?.sessionKey);
|
|
1012
|
+
if (matchedKey) {
|
|
1013
|
+
this.log("info", `discoverActiveSession: matched session ${matchedKey}`);
|
|
1014
|
+
}
|
|
1015
|
+
else {
|
|
1016
|
+
this.log("warn", `discoverActiveSession: all ${sessions.length} sessions filtered or empty`);
|
|
1017
|
+
sessions.forEach((s) => this.log("info", ` session: ${(s.key ?? s.sessionKey) ?? "(no key)"}`));
|
|
1018
|
+
}
|
|
1019
|
+
return matchedKey ?? null;
|
|
997
1020
|
}
|
|
998
1021
|
catch (err) {
|
|
999
1022
|
this.log("warn", `discoverActiveSession failed: ${err instanceof Error ? err.message : String(err)}`);
|