Space Hooks are file-declared asynchronous automation under .cohub/hooks/* (v1.103+). One file is one hook identity, with exactly one of run, prompt, or uses.
Events
space.fs.changedspace.workspace.readysession.turn.finalizedcheckpoint.createdapp.version.publishedtask.updated— Task Run state transitions with task id/type/status, changed fields, and errorswebhook(v2.46) — an inbound HTTP trigger addressed by file name
task.updated filters out space_hook tasks and their run_command children, preventing a hook from re-entering itself.
Actions
run- a sandbox shell commandprompt- a follow-up session promptuses(v2.46) - run a published App Action:owner/space/app/action, with a JSON payload passed viawithand delivered on stdin
schema: cohub.space-hook.v1
on:
event: checkpoint.created
uses: alice/tools/mail-inbox/deliver
with:
dir: inbox/mailWebhook triggers (v2.46)
A hook with on.event: webhook is addressed by its file name rather than broadcast:
.cohub/hooks/mail.yml -> POST /api/spaces/:spaceId/webhooks/mail- Optional
on.secret, passed asx-cohub-webhook-secretor?secret=. - JSON body (64 KB max) is available as
COHUB_HOOK_WEBHOOK_BODY. - Per-space rate limiting; the response is
{ taskRunId, hook, eventId }. - Works for local Sandboxes too: hook definitions load through the provider-aware Space FS facade.
cohub spaces webhooks ls --json
cohub spaces webhooks url mail
cohub spaces webhooks trigger mail --body '{"messageId":"..."}'Practice
- FS matching ignores
.cohub/**to avoid self-trigger loops. - Turn filters (
sessionIds,sources, and optional label filters) are separate from theprompt.sessionIdaction target. - Hook context is exposed through curated
COHUB_HOOK_*environment variables; absent optional values are empty strings. - The hook cache is invalidated by
space.workspace.readyand by FS changes under.cohub/hooks/**; a workspace that is still missing is never cached as "no hooks". - Treat hook runs as Tasks and inspect their terminal status instead of polling Chat.