multiclaws 0.4.39 → 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,25 +290,38 @@ class OpenClawAgentExecutor {
290
290
  if (!this.gatewayConfig)
291
291
  return null;
292
292
  try {
293
- const result = await (0, gateway_client_1.invokeGatewayTool)({
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(result).slice(0, 500)}`);
300
- const sessions = result?.sessions ?? [];
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 ?? [];
301
309
  this.logger.info(`[a2a-adapter] discoverActiveSession: found ${sessions.length} sessions`);
302
310
  const INTERNAL_PREFIXES = ["delegate-", "a2a-"];
303
- const session = sessions.find((s) => s.sessionKey && !INTERNAL_PREFIXES.some((p) => s.sessionKey.startsWith(p)));
304
- if (session) {
305
- this.logger.info(`[a2a-adapter] discoverActiveSession: matched session ${session.sessionKey}`);
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}`);
306
319
  }
307
320
  else {
308
321
  this.logger.warn(`[a2a-adapter] discoverActiveSession: all ${sessions.length} sessions filtered or empty`);
309
- sessions.forEach((s) => this.logger.info(`[a2a-adapter] session: ${s.sessionKey ?? "(no key)"}`));
322
+ sessions.forEach((s) => this.logger.info(`[a2a-adapter] session: ${(s.key ?? s.sessionKey) ?? "(no key)"}`));
310
323
  }
311
- return session?.sessionKey ?? null;
324
+ return matchedKey ?? null;
312
325
  }
313
326
  catch (err) {
314
327
  this.logger.warn(`[a2a-adapter] discoverActiveSession failed: ${err instanceof Error ? err.message : String(err)}`);
@@ -985,25 +985,38 @@ class MulticlawsService extends node_events_1.EventEmitter {
985
985
  if (!this.gatewayConfig)
986
986
  return null;
987
987
  try {
988
- const result = await (0, gateway_client_1.invokeGatewayTool)({
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(result).slice(0, 500)}`);
995
- const sessions = result?.sessions ?? [];
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 ?? [];
996
1004
  this.log("info", `discoverActiveSession: found ${sessions.length} sessions`);
997
1005
  const INTERNAL_PREFIXES = ["delegate-", "a2a-"];
998
- const session = sessions.find((s) => s.sessionKey && !INTERNAL_PREFIXES.some((p) => s.sessionKey.startsWith(p)));
999
- if (session) {
1000
- this.log("info", `discoverActiveSession: matched session ${session.sessionKey}`);
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}`);
1001
1014
  }
1002
1015
  else {
1003
1016
  this.log("warn", `discoverActiveSession: all ${sessions.length} sessions filtered or empty`);
1004
- sessions.forEach((s) => this.log("info", ` session: ${s.sessionKey ?? "(no key)"}`));
1017
+ sessions.forEach((s) => this.log("info", ` session: ${(s.key ?? s.sessionKey) ?? "(no key)"}`));
1005
1018
  }
1006
- return session?.sessionKey ?? null;
1019
+ return matchedKey ?? null;
1007
1020
  }
1008
1021
  catch (err) {
1009
1022
  this.log("warn", `discoverActiveSession failed: ${err instanceof Error ? err.message : String(err)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multiclaws",
3
- "version": "0.4.39",
3
+ "version": "0.4.40",
4
4
  "description": "MultiClaws plugin for OpenClaw collaboration via A2A protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",