mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-13 18:21:27 +00:00
fix: prefer target entry for tools wrapper
This commit is contained in:
@@ -210,6 +210,48 @@ describe("handleToolsCommand", () => {
|
||||
expect(resolveToolsMock).toHaveBeenCalledWith(expect.objectContaining({ groupId: undefined }));
|
||||
});
|
||||
|
||||
it("prefers the target session entry for tool inventory group metadata", async () => {
|
||||
const { buildCommandTestParams, handleToolsCommand, resolveToolsMock } =
|
||||
await loadToolsHarness();
|
||||
const params = buildCommandTestParams("/tools", buildConfig(), undefined, {
|
||||
workspaceDir: "/tmp",
|
||||
});
|
||||
params.sessionEntry = {
|
||||
sessionId: "wrapper-session",
|
||||
updatedAt: Date.now(),
|
||||
groupId: "wrapper-group",
|
||||
groupChannel: "#wrapper",
|
||||
space: "wrapper-space",
|
||||
};
|
||||
params.sessionStore = {
|
||||
[params.sessionKey]: {
|
||||
sessionId: "target-session",
|
||||
updatedAt: Date.now(),
|
||||
groupId: "target-group",
|
||||
groupChannel: "#target",
|
||||
space: "target-space",
|
||||
},
|
||||
};
|
||||
params.ctx = {
|
||||
...params.ctx,
|
||||
From: "telegram:group:abc123",
|
||||
Provider: "telegram",
|
||||
Surface: "telegram",
|
||||
GroupChannel: "#ctx",
|
||||
GroupSpace: "ctx-space",
|
||||
};
|
||||
|
||||
await handleToolsCommand(params, true);
|
||||
|
||||
expect(resolveToolsMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
groupId: "target-group",
|
||||
groupChannel: "#target",
|
||||
groupSpace: "target-space",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("renders the detailed tool list in verbose mode", async () => {
|
||||
const { buildCommandTestParams, handleToolsCommand } = await loadToolsHarness();
|
||||
const result = await handleToolsCommand(
|
||||
|
||||
@@ -115,6 +115,7 @@ export const handleToolsCommand: CommandHandler = async (params, allowTextComman
|
||||
ctx: params.ctx,
|
||||
command: params.command,
|
||||
});
|
||||
const targetSessionEntry = params.sessionStore?.[params.sessionKey] ?? params.sessionEntry;
|
||||
const sessionBound = Boolean(params.sessionKey);
|
||||
const agentId = sessionBound
|
||||
? resolveSessionAgentId({ sessionKey: params.sessionKey, config: params.cfg })
|
||||
@@ -146,10 +147,10 @@ export const handleToolsCommand: CommandHandler = async (params, allowTextComman
|
||||
? String(params.ctx.MessageThreadId)
|
||||
: undefined,
|
||||
currentMessageId: threadingContext.currentMessageId,
|
||||
groupId: params.sessionEntry?.groupId ?? extractExplicitGroupId(params.ctx.From),
|
||||
groupId: targetSessionEntry?.groupId ?? extractExplicitGroupId(params.ctx.From),
|
||||
groupChannel:
|
||||
params.sessionEntry?.groupChannel ?? params.ctx.GroupChannel ?? params.ctx.GroupSubject,
|
||||
groupSpace: params.sessionEntry?.space ?? params.ctx.GroupSpace,
|
||||
targetSessionEntry?.groupChannel ?? params.ctx.GroupChannel ?? params.ctx.GroupSubject,
|
||||
groupSpace: targetSessionEntry?.space ?? params.ctx.GroupSpace,
|
||||
replyToMode: resolveReplyToMode(
|
||||
params.cfg,
|
||||
params.ctx.OriginatingChannel ?? params.ctx.Provider,
|
||||
|
||||
Reference in New Issue
Block a user