fix: refine tool summaries and scope discord tool

This commit is contained in:
Peter Steinberger
2026-01-03 12:33:42 +01:00
parent 7165c8a7e5
commit 772ada4308
13 changed files with 83 additions and 11 deletions

View File

@@ -310,6 +310,7 @@ function resolvePromptSkills(
export async function runEmbeddedPiAgent(params: {
sessionId: string;
sessionKey?: string;
surface?: string;
sessionFile: string;
workspaceDir: string;
config?: ClawdisConfig;
@@ -414,6 +415,7 @@ export async function runEmbeddedPiAgent(params: {
const promptSkills = resolvePromptSkills(skillsSnapshot, skillEntries);
const tools = createClawdisCodingTools({
bash: params.config?.agent?.bash,
surface: params.surface,
});
const machineName = await getMachineDisplayName();
const runtimeInfo = {

View File

@@ -83,6 +83,14 @@ describe("createClawdisCodingTools", () => {
expect(tools.some((tool) => tool.name === "process")).toBe(true);
});
it("scopes discord tool to discord surface", () => {
const other = createClawdisCodingTools({ surface: "whatsapp" });
expect(other.some((tool) => tool.name === "discord")).toBe(false);
const discord = createClawdisCodingTools({ surface: "discord" });
expect(discord.some((tool) => tool.name === "discord")).toBe(true);
});
it("keeps read tool image metadata intact", async () => {
const tools = createClawdisCodingTools();
const readTool = tools.find((tool) => tool.name === "read");

View File

@@ -294,8 +294,20 @@ function createClawdisReadTool(base: AnyAgentTool): AnyAgentTool {
};
}
function normalizeSurface(surface?: string): string | undefined {
const trimmed = surface?.trim().toLowerCase();
return trimmed ? trimmed : undefined;
}
function shouldIncludeDiscordTool(surface?: string): boolean {
const normalized = normalizeSurface(surface);
if (!normalized) return false;
return normalized === "discord" || normalized.startsWith("discord:");
}
export function createClawdisCodingTools(options?: {
bash?: BashToolDefaults & ProcessToolDefaults;
surface?: string;
}): AnyAgentTool[] {
const bashToolName = "bash";
const base = (codingTools as unknown as AnyAgentTool[]).flatMap((tool) => {
@@ -314,5 +326,9 @@ export function createClawdisCodingTools(options?: {
createWhatsAppLoginTool(),
...createClawdisTools(),
];
return tools.map(normalizeToolParameters);
const allowDiscord = shouldIncludeDiscordTool(options?.surface);
const filtered = allowDiscord
? tools
: tools.filter((tool) => tool.name !== "discord");
return filtered.map(normalizeToolParameters);
}