27 lines
845 B
JavaScript
27 lines
845 B
JavaScript
import { describe, it } from "node:test";
|
|||
|
|
import assert from "node:assert/strict";
|
||
|
|
import { extractToolNameFromPermission } from "./session-manager.mjs";
|
||
|
|
|
||
|
|
describe("extractToolNameFromPermission", () => {
|
||
|
|
it("parses client MCP title format", () => {
|
||
|
|
const name = extractToolNameFromPermission({
|
||
|
|
toolCall: { title: "client-get_weather: get_weather" },
|
||
|
|
});
|
||
|
|
assert.equal(name, "get_weather");
|
||
|
|
});
|
||
|
|
|
||
|
|
it("strips mcp_client_ prefix from rawInput name", () => {
|
||
|
|
const name = extractToolNameFromPermission({
|
||
|
|
toolCall: { rawInput: { name: "mcp_client_get_weather" } },
|
||
|
|
});
|
||
|
|
assert.equal(name, "get_weather");
|
||
|
|
});
|
||
|
|
|
||
|
|
it("uses first token for built-in tools", () => {
|
||
|
|
const name = extractToolNameFromPermission({
|
||
|
|
toolCall: { title: "Shell: rm -rf /" },
|
||
|
|
});
|
||
|
|
assert.equal(name, "Shell");
|
||
|
|
});
|
||
|
|
});
|