Feature · @linda/hooks
Nineteen lifecycle hooks.
Every moment in the agent loop you might care about is a hook. Programmatic handlers, JSON-declared webhooks, or both. Each one can observe, transform, or veto.
The veto + transform pipeline
Every hook handler can return:
undefined— pass through unchanged.{ veto: true, reason: "..." }— block the action; the agent gets the reason.{ mutation: { value: "..." } }— rewrite the payload.
Multiple handlers run in registration order. The first veto wins. Mutations chain.
linda.on("beforeFieldFill", ({ field, value, source }) => {
if (field === "email" && !value.includes("@")) {
return { veto: true, reason: "needs @" };
}
if (source === "agent") {
return { mutation: { value: value.toLowerCase() } };
}
});
linda.on("onComplete", async ({ data }) => {
await fetch("/api/save", {
method: "POST",
body: JSON.stringify(data),
});
}); The events
-
onUserMessageFires every time the user sends a message. -
onAgentMessageFires when the model finishes a response. -
beforeFieldFillVeto or transform an agent's attempt to fill a form field. -
afterFieldFillFires after a successful fill — log, persist, validate. -
onCompleteFires when the agent decides the flow is done. -
onFileUploadFires when a user drops a file; parsed artifacts attached. -
onSkillActivateFires when the model loads a skill from /skills/installed/. -
onHandoffFires on multi-agent handoff. Hook can veto. -
onToolCallFires before any tool call. Useful for audit logs. -
onErrorFires on any uncaught error in the loop. -
onOpenFires when the chat overlay opens. -
onCloseFires when the chat overlay closes. -
onStreamDeltaFires on every streamed token (~30/s). -
onStateChangeFires when the persistent state mutates. -
beforeTransportMutate the LLM request envelope before send. -
afterTransportInspect the LLM response after receive. -
onTriggerFireFires when a behavioral trigger (exit-intent, hesitation) fires. -
onCapabilitiesChangeFires when browser capabilities change at runtime. -
onSlashCommandFires when the user types /reset, /skills, etc.
Declarative webhooks
If you're using the script-tag UMD and don't ship JS yourself, hooks can be declared as JSON pointing at HTTP endpoints. Linda POSTs the event payload, awaits, and applies the veto/mutation from the response.
{
"hooks": {
"onComplete": "https://api.example.com/linda-complete",
"beforeFieldFill": "https://api.example.com/linda-validate"
}
} Ship an agent-driven flow this afternoon.
Install Linda, paste a config, and your form turns into an agent that fills its own inputs.