Files
openclaw/src/gateway/server.tools-effective.test.ts
Tak Hoffman 9c7823350b feat: add /tools runtime availability view (#54088)
* test(memory): lock qmd status counts regression

* feat: make /tools show what the agent can use right now

* fix: sync web ui slash commands with the shared registry

* feat: add profile and unavailable counts to /tools

* refine: keep /tools focused on available tools

* fix: resolve /tools review regressions

* fix: honor model compat in /tools inventory

* fix: sync generated protocol models for /tools

* fix: restore canonical slash command names

* fix: avoid ci lint drift in google helper exports

* perf: stop computing unused /tools unavailable counts

* docs: clarify /tools runtime behavior
2026-03-24 21:09:51 -05:00

53 lines
2.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { connectOk, installGatewayTestHooks, rpcReq } from "./test-helpers.js";
import { withServer } from "./test-with-server.js";
installGatewayTestHooks({ scope: "suite" });
describe("gateway tools.effective", () => {
it("returns effective tool inventory data", async () => {
await withServer(async (ws) => {
await connectOk(ws, { token: "secret", scopes: ["operator.read", "operator.write"] });
const created = await rpcReq<{ key?: string }>(ws, "sessions.create", {
label: "Tools Effective Test",
});
expect(created.ok).toBe(true);
const sessionKey = created.payload?.key;
expect(sessionKey).toBeTruthy();
const res = await rpcReq<{
agentId?: string;
groups?: Array<{
id?: "core" | "plugin" | "channel";
source?: "core" | "plugin" | "channel";
tools?: Array<{ id?: string; source?: "core" | "plugin" | "channel" }>;
}>;
}>(ws, "tools.effective", { sessionKey });
expect(res.ok).toBe(true);
expect(res.payload?.agentId).toBeTruthy();
expect((res.payload?.groups ?? []).length).toBeGreaterThan(0);
expect(
(res.payload?.groups ?? []).some((group) =>
(group.tools ?? []).some((tool) => tool.id === "exec"),
),
).toBe(true);
});
});
it("rejects unknown agent ids", async () => {
await withServer(async (ws) => {
await connectOk(ws, { token: "secret", scopes: ["operator.read", "operator.write"] });
const created = await rpcReq<{ key?: string }>(ws, "sessions.create", {
label: "Tools Effective Test",
});
expect(created.ok).toBe(true);
const unknownAgent = await rpcReq(ws, "tools.effective", {
sessionKey: created.payload?.key,
agentId: "does-not-exist",
});
expect(unknownAgent.ok).toBe(false);
expect(unknownAgent.error?.message ?? "").toContain("unknown agent id");
});
});
});