Let outside services and computers' browser notifications give bots work
A bot hook (bot_hooks) is a secret URL, POST /api/hooks/<token>, whose calls queue the hook's brief plus the raw body as a task, per user and bot like a routine. Only the token's hash is kept (shown once, rotatable); an optional HMAC-SHA256 signing secret is stored encrypted. Calls are rate limited per address and per hook, recorded in bot_hook_events (pruned daily), deduplicated by delivery id, and a call while the last run still waits joins its brief instead of queueing another. The payload is fenced data and HookRunNote tells the bot never to take instructions from it; failed runs retry like routines. A hook can instead watch a computer's browser notifications: the app installs a small watcher that owns org.freedesktop.Notifications on the sandbox's session bus, so Chrome hands it every notification (it only looks for that service at start-up, so Chrome is restarted once, never mid-task), and it posts each one to its hooks, optionally filtered. Computers reach the app at COMPUTER_APP_URL or the app container's name. Users make hooks in the conversation's Hooks modal and manage them all on /admin/routines; bots never create or change hooks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
botFilesNote,
|
||||
ComputerFilesNote,
|
||||
ScheduledRunNote,
|
||||
HookRunNote,
|
||||
TasksNote,
|
||||
TaskRunNote,
|
||||
WorkspaceLearningNote,
|
||||
@@ -55,8 +56,9 @@ type Params = BotJobContext & {
|
||||
* computer, that computer's tools (over MCP), until it answers. That answer is the report for the user.
|
||||
* When only the user can go on (a login, a captcha), the bot asks them to
|
||||
* take over (`ask_user_to_take_over`) and the report needs them.
|
||||
* A scheduled run acts on its own (`ScheduledRunNote`); one that reports
|
||||
* it failed (`report_run_failed`) throws, so the queue retries it.
|
||||
* A scheduled run acts on its own (`ScheduledRunNote`), as does a hook
|
||||
* call (`HookRunNote`, its payload only data); one that reports it failed
|
||||
* (`report_run_failed`) throws, so the queue retries it.
|
||||
* Every model turn is reported as a step (`report`).
|
||||
*/
|
||||
export default async function runBotTask({
|
||||
@@ -113,6 +115,11 @@ export default async function runBotTask({
|
||||
*/
|
||||
const attachments: number[] = [];
|
||||
const scheduled = Boolean(params.schedule_id);
|
||||
/**
|
||||
* Started by a call to one of the user's hooks: acts on its own
|
||||
* like a routine, and treats the call's payload as data.
|
||||
*/
|
||||
const hooked = Boolean(params.hook_id);
|
||||
let failure = null as string | null;
|
||||
|
||||
/**
|
||||
@@ -175,7 +182,7 @@ export default async function runBotTask({
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
...(scheduled ? [reportRunFailedTool({ onFail: ({ reason }) => (failure = reason) })] : []),
|
||||
...(scheduled || hooked ? [reportRunFailedTool({ onFail: ({ reason }) => (failure = reason) })] : []),
|
||||
...(computer?.tools || []),
|
||||
...(job.computer_id
|
||||
? [
|
||||
@@ -219,6 +226,7 @@ export default async function runBotTask({
|
||||
carry_over,
|
||||
TaskRunNote,
|
||||
scheduled ? ScheduledRunNote : "",
|
||||
hooked ? HookRunNote : "",
|
||||
botFilesNote({ bot_id: bot.id }),
|
||||
ComputerFilesNote({ computer_id: job.computer_id || 0, dirs }),
|
||||
TasksNote,
|
||||
|
||||
Reference in New Issue
Block a user