Files
cobble/src/harness/tools/bot/hooks/list-hooks-tool.ts
T
tbenandClaude Opus 5.5 380d3ebb2f Let bots manage their hooks, with the user confirming what widens them
Bots get list_hooks, pause_hook and delete_hook, which act directly since
they only take away. A new hook, or a new name, brief or filter, or
switching a paused one back on, goes through propose_hook: it stores a
hook_proposals row and puts a [hook-proposal:ID] card in the reply, which
the user it was proposed to confirms or rejects. The card is read from
what Confirm saves, with the bot's reason labelled as its own; confirming
checks everything again and saves through the Hooks modal's helpers. A
new hook's URL is shown on the card once, to the user only, never in the
outcome the bot is told. What calls a hook, its computers and its signing
are never proposed. Only chat replies propose, and a hook call's own run
gets no hook tools, so a caller's payload can't reach them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 15:18:54 +01:00

29 lines
1.1 KiB
TypeScript

import { z } from "zod";
import grabBotHooks from "@/src/functions/backend/db/bot-hooks/grab-bot-hooks";
import describeBotHook from "@/src/utils/describe-bot-hook";
import type { HarnessTool } from "../../../types";
type Params = {
user_id: number | string;
bot_id: number | string;
};
/**
* Lets a bot see the user's hooks it runs, everywhere it works, never
* their URLs.
*/
export default function listHooksTool({ user_id, bot_id }: Params): HarnessTool<Record<string, never>> {
return {
name: "list_hooks",
description: `List the user's hooks that give you work: id, name, what calls it (an outside service at its secret URL, or browser notifications on a computer), where it runs, whether it's paused, its runs, last call and last error. You never see a hook's URL: only the user does.`,
schema: z.object({}),
run: async () => {
const hooks = await grabBotHooks({ user_id, bot_id });
if (!hooks.length) return `You have no hooks.`;
return hooks.map((hook) => `- ${describeBotHook({ hook })}`).join("\n");
},
};
}