A hook call used to record only how it was taken; its run's answer went to the chat alone and was lost to the call once the job was pruned. Now `bot_hook_events` keeps `response`, `response_message_id` and `responded_at`, written on every call a run took in when that run ends (completed, failed, lost, stopped or cancelled) by `recordHookCallResponse` in the job helpers, and calls turn done or failed. The Calls view searches what calls sent and what runs answered, filters by status and pages; Show all loads one call whole. Bots get `search_hook_calls` and `read_hook_call` for their own hooks (never in a hook call's own run), with payloads always marked as outside data. Calls are kept for the app setting `hook_events_keep_days` (Settings > General, default now 30 days). The caller still only gets 202 Queued. Co-Authored-By: Claude Opus 5.5 <[email protected]>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import grabBotHookTools from "./grab-bot-hook-tools";
|
|
|
|
const names = (params: Partial<Parameters<typeof grabBotHookTools>[0]>) =>
|
|
grabBotHookTools({ user_id: 1, bot_id: 2, computers: [], ...params }).map((tool) => tool.name);
|
|
|
|
describe("grabBotHookTools", () => {
|
|
test("a hook call's own run gets no hook tools", () => {
|
|
expect(names({ hooked: true, session_id: 3, onPropose: () => {} })).toEqual([]);
|
|
});
|
|
|
|
test("a run without a chat to confirm in can't propose", () => {
|
|
expect(names({ session_id: 3 })).toEqual(["list_hooks", "search_hook_calls", "read_hook_call", "pause_hook", "delete_hook"]);
|
|
});
|
|
|
|
test("a chat reply can propose", () => {
|
|
expect(names({ session_id: 3, onPropose: () => {} })).toContain("propose_hook");
|
|
});
|
|
|
|
test("a proposal never takes a signing secret", () => {
|
|
const propose = grabBotHookTools({
|
|
user_id: 1,
|
|
bot_id: 2,
|
|
computers: [],
|
|
session_id: 3,
|
|
onPropose: () => {},
|
|
}).find((tool) => tool.name == "propose_hook")!;
|
|
const parsed = propose.schema!.parse({
|
|
title: "GitHub pushes",
|
|
instructions: "Summarise each push.",
|
|
signing_secret: "abcdefgh",
|
|
reason: "The user asked for push summaries.",
|
|
});
|
|
|
|
expect(parsed).not.toHaveProperty("signing_secret");
|
|
});
|
|
});
|