mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 21:02:55 +00:00
Land PR #87003 from @ragesaq with a maintainer fix for routed room events. Co-authored-by: Forge <forge@psiclawops.dev>
71 lines
2.5 KiB
TypeScript
71 lines
2.5 KiB
TypeScript
import { beforeAll, describe, expect, it } from "vitest";
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import { resolveGatewayScopedTools } from "./tool-resolution.js";
|
|
|
|
describe("resolveGatewayScopedTools", () => {
|
|
beforeAll(() => {
|
|
resolveGatewayScopedTools({
|
|
cfg: { tools: { profile: "minimal" } } as OpenClawConfig,
|
|
sessionKey: "agent:main:telegram:group:-100123",
|
|
messageProvider: "telegram",
|
|
inboundEventKind: "room_event",
|
|
surface: "loopback",
|
|
});
|
|
});
|
|
|
|
it("force-allows the message tool for room-event loopback turns", () => {
|
|
const result = resolveGatewayScopedTools({
|
|
cfg: { tools: { profile: "minimal" } } as OpenClawConfig,
|
|
sessionKey: "agent:main:telegram:group:-100123",
|
|
messageProvider: "telegram",
|
|
inboundEventKind: "room_event",
|
|
surface: "loopback",
|
|
});
|
|
|
|
const messageTool = result.tools.find((tool) => tool.name === "message");
|
|
expect(messageTool?.description).toContain(
|
|
"visible replies to the current source conversation",
|
|
);
|
|
});
|
|
|
|
it("keeps webchat room-event turns on automatic source delivery", () => {
|
|
const result = resolveGatewayScopedTools({
|
|
cfg: { tools: { profile: "minimal" } } as OpenClawConfig,
|
|
sessionKey: "agent:main:webchat:forge-main",
|
|
messageProvider: "webchat",
|
|
inboundEventKind: "room_event",
|
|
surface: "loopback",
|
|
});
|
|
|
|
expect(result.tools.some((tool) => tool.name === "message")).toBe(false);
|
|
});
|
|
|
|
it("force-allows the message tool for routed webchat room-event turns", () => {
|
|
const result = resolveGatewayScopedTools({
|
|
cfg: { tools: { profile: "minimal" } } as OpenClawConfig,
|
|
sessionKey: "agent:main:telegram:group:-100123",
|
|
messageProvider: "webchat",
|
|
inboundEventKind: "room_event",
|
|
sourceReplyDeliveryMode: "message_tool_only",
|
|
surface: "loopback",
|
|
});
|
|
|
|
const messageTool = result.tools.find((tool) => tool.name === "message");
|
|
expect(messageTool?.description).toContain(
|
|
"visible replies to the current source conversation",
|
|
);
|
|
});
|
|
|
|
it("keeps ordinary loopback turns under the configured profile", () => {
|
|
const result = resolveGatewayScopedTools({
|
|
cfg: { tools: { profile: "minimal" } } as OpenClawConfig,
|
|
sessionKey: "agent:main:telegram:group:-100123",
|
|
messageProvider: "telegram",
|
|
inboundEventKind: "user_request",
|
|
surface: "loopback",
|
|
});
|
|
|
|
expect(result.tools.some((tool) => tool.name === "message")).toBe(false);
|
|
});
|
|
});
|