Keep every hook call's response, searchable by the user and the bot

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]>
This commit is contained in:
2026-10-25 17:47:28 +01:00
co-authored by Claude Opus 5.5
parent fb4c89fca1
commit 0e59559ea9
43 changed files with 1182 additions and 84 deletions
+18
View File
@@ -1341,6 +1341,20 @@ const schema: BUN_SQLITE_DatabaseSchemaType = {
fieldName: "error",
dataType: "TEXT",
},
{
fieldName: "response",
fieldDescription: `What its run answered (the result the bot posted), or why the run failed. Written when the run ends, on every call that run took in`,
dataType: "TEXT",
},
{
fieldName: "response_message_id",
fieldDescription: `The chat message the run posted. Not a foreign key: messages can be deleted`,
dataType: "INTEGER",
},
{
fieldName: "responded_at",
dataType: "INTEGER",
},
],
indexes: [
{
@@ -1351,6 +1365,10 @@ const schema: BUN_SQLITE_DatabaseSchemaType = {
indexName: "idx_bot_hook_events_hook_id_idempotency_key",
indexTableFields: ["hook_id", "idempotency_key"],
},
{
indexName: "idx_bot_hook_events_job_id",
indexTableFields: ["job_id"],
},
],
},
{
+10 -1
View File
@@ -832,8 +832,17 @@ export type BUN_SQLITE_COBBLE_BOT_HOOK_EVENTS = {
* The sender's delivery id, so a retried call runs once
*/
idempotency_key?: string;
status?: "queued" | "merged" | "rejected" | "duplicate" | "ignored" | "";
status?: "queued" | "merged" | "done" | "failed" | "rejected" | "duplicate" | "ignored" | "";
error?: string;
/**
* What its run answered (the result the bot posted), or why the run failed. Written when the run ends, on every call that run took in
*/
response?: string;
/**
* The chat message the run posted. Not a foreign key: messages can be deleted
*/
response_message_id?: number | "";
responded_at?: number | "";
}
export type BUN_SQLITE_COBBLE_HOOK_PROPOSALS = {