[{"data":1,"prerenderedAt":707},["ShallowReactive",2],{"docs:\u002Fdocs\u002Fguides\u002Fevents":3,"docs:navigation":584,"docs:surround:\u002Fdocs\u002Fguides\u002Fevents":702},{"id":4,"title":5,"body":6,"description":575,"extension":576,"meta":577,"navigation":578,"navigationTitle":579,"path":580,"seo":581,"stem":582,"__hash__":583},"docs\u002Fdocs\u002F3.guides\u002F10.events.md","Events",{"type":7,"value":8,"toc":569},"minimark",[9,13,18,148,165,168,172,179,413,416,420,431,549,553,565],[10,11,12],"p",{},"When an agent fails at night or an approval waits for hours, you want to know without opening the\ndashboard. Events report every run, tool call, and approval to your own code, so you can send them\nto logs, analytics, or alerting.",[14,15,17],"h2",{"id":16},"what-each-event-contains","What Each Event Contains",[19,20,21,34],"table",{},[22,23,24],"thead",{},[25,26,27,31],"tr",{},[28,29,30],"th",{},"Event",[28,32,33],{},"Payload",[35,36,37,51,83,109,125],"tbody",{},[25,38,39,46],{},[40,41,42],"td",{},[43,44,45],"code",{},"run:start",[40,47,48],{},[43,49,50],{},"run",[25,52,53,58],{},[40,54,55],{},[43,56,57],{},"run:finish",[40,59,60,62,63,66,67,62,70,62,73,76,77,62,80],{},[43,61,50],{},", ",[43,64,65],{},"status"," (",[43,68,69],{},"succeeded",[43,71,72],{},"failed",[43,74,75],{},"cancelled","), ",[43,78,79],{},"output",[43,81,82],{},"error",[25,84,85,90],{},[40,86,87],{},[43,88,89],{},"tool:call",[40,91,92,62,94,62,97,62,100,62,103,62,106],{},[43,93,50],{},[43,95,96],{},"tool",[43,98,99],{},"input",[43,101,102],{},"durationMs",[43,104,105],{},"approvalRequired",[43,107,108],{},"error?",[25,110,111,116],{},[40,112,113],{},[43,114,115],{},"approval:requested",[40,117,118,62,120,62,122],{},[43,119,50],{},[43,121,96],{},[43,123,124],{},"approvalId",[25,126,127,132],{},[40,128,129],{},[43,130,131],{},"approval:resolved",[40,133,134,62,136,62,139,62,142,62,145],{},[43,135,124],{},[43,137,138],{},"ownerId",[43,140,141],{},"workspace",[43,143,144],{},"approved",[43,146,147],{},"run?",[10,149,150,152,153,156,157,160,161,164],{},[43,151,50],{}," is ",[43,154,155],{},"{ runId, agentId, ownerId, workspace, sessionId }",". Automation runs have a ",[43,158,159],{},"sessionId","\nthat starts with ",[43,162,163],{},"automation-",".",[10,166,167],{},"Handlers run after the fact and never change the outcome: a handler that throws is logged, and\nthe run continues. Runs emit from their Durable Object, and approval answers emit from the request\nthat answered them.",[14,169,171],{"id":170},"listening-in-nuxt","Listening in Nuxt",[10,173,174,175,178],{},"Events are Nitro runtime hooks named ",[43,176,177],{},"agentic:\u003Cevent>",". The starter logs finished runs and\napproval requests:",[180,181,187],"pre",{"className":182,"code":183,"filename":184,"language":185,"meta":186,"style":186},"language-ts shiki shiki-themes github-dark-default","export default defineNitroPlugin((nitroApp) => {\n  nitroApp.hooks.hook('agentic:run:finish', ({ run, status, error }) => {\n    const reason = error ? `: ${error}` : ''\n    console.info(`[agentic] Run ${run.runId} of agent ${run.agentId} ${status}${reason}`)\n  })\n  nitroApp.hooks.hook('agentic:approval:requested', ({ run, tool, approvalId }) => {\n    console.info(`[agentic] Approval ${approvalId} requested for ${tool} in run ${run.runId}`)\n  })\n})\n","server\u002Fplugins\u002Fagentic-events.ts","ts","",[43,188,189,216,252,285,332,338,368,400,405],{"__ignoreMap":186},[190,191,194,198,201,205,209,212],"span",{"class":192,"line":193},"line",1,[190,195,197],{"class":196},"suJrU","export",[190,199,200],{"class":196}," default",[190,202,204],{"class":203},"sc3cj"," defineNitroPlugin",[190,206,208],{"class":207},"sQhOw","((nitroApp) ",[190,210,211],{"class":196},"=>",[190,213,215],{"class":214},"sZEs4"," {\n",[190,217,219,222,225,228,232,235,237,239,241,243,245,248,250],{"class":192,"line":218},2,[190,220,221],{"class":214},"  nitroApp.hooks.",[190,223,224],{"class":203},"hook",[190,226,227],{"class":214},"(",[190,229,231],{"class":230},"s9uIt","'agentic:run:finish'",[190,233,234],{"class":214},", ({ ",[190,236,50],{"class":207},[190,238,62],{"class":214},[190,240,65],{"class":207},[190,242,62],{"class":214},[190,244,82],{"class":207},[190,246,247],{"class":214}," }) ",[190,249,211],{"class":196},[190,251,215],{"class":214},[190,253,255,258,262,265,268,271,274,276,279,282],{"class":192,"line":254},3,[190,256,257],{"class":196},"    const",[190,259,261],{"class":260},"sFSAA"," reason",[190,263,264],{"class":196}," =",[190,266,267],{"class":214}," error ",[190,269,270],{"class":196},"?",[190,272,273],{"class":230}," `: ${",[190,275,82],{"class":214},[190,277,278],{"class":230},"}`",[190,280,281],{"class":196}," :",[190,283,284],{"class":230}," ''\n",[190,286,288,291,294,296,299,301,303,306,309,311,313,316,319,321,324,327,329],{"class":192,"line":287},4,[190,289,290],{"class":214},"    console.",[190,292,293],{"class":203},"info",[190,295,227],{"class":214},[190,297,298],{"class":230},"`[agentic] Run ${",[190,300,50],{"class":214},[190,302,164],{"class":230},[190,304,305],{"class":214},"runId",[190,307,308],{"class":230},"} of agent ${",[190,310,50],{"class":214},[190,312,164],{"class":230},[190,314,315],{"class":214},"agentId",[190,317,318],{"class":230},"} ${",[190,320,65],{"class":214},[190,322,323],{"class":230},"}${",[190,325,326],{"class":214},"reason",[190,328,278],{"class":230},[190,330,331],{"class":214},")\n",[190,333,335],{"class":192,"line":334},5,[190,336,337],{"class":214},"  })\n",[190,339,341,343,345,347,350,352,354,356,358,360,362,364,366],{"class":192,"line":340},6,[190,342,221],{"class":214},[190,344,224],{"class":203},[190,346,227],{"class":214},[190,348,349],{"class":230},"'agentic:approval:requested'",[190,351,234],{"class":214},[190,353,50],{"class":207},[190,355,62],{"class":214},[190,357,96],{"class":207},[190,359,62],{"class":214},[190,361,124],{"class":207},[190,363,247],{"class":214},[190,365,211],{"class":196},[190,367,215],{"class":214},[190,369,371,373,375,377,380,382,385,387,390,392,394,396,398],{"class":192,"line":370},7,[190,372,290],{"class":214},[190,374,293],{"class":203},[190,376,227],{"class":214},[190,378,379],{"class":230},"`[agentic] Approval ${",[190,381,124],{"class":214},[190,383,384],{"class":230},"} requested for ${",[190,386,96],{"class":214},[190,388,389],{"class":230},"} in run ${",[190,391,50],{"class":214},[190,393,164],{"class":230},[190,395,305],{"class":214},[190,397,278],{"class":230},[190,399,331],{"class":214},[190,401,403],{"class":192,"line":402},8,[190,404,337],{"class":214},[190,406,408,411],{"class":192,"line":407},9,[190,409,410],{"class":214},"}",[190,412,331],{"class":207},[10,414,415],{},"Hooks are typed. In development, the Agentic tab in Nuxt DevTools shows recent events and\npending approvals.",[14,417,419],{"id":418},"listening-in-void","Listening in Void",[10,421,422,423,426,427,430],{},"Pass one handler to ",[43,424,425],{},"defineVoidAgentic",". It receives the event and the Worker ",[43,428,429],{},"env",":",[180,432,435],{"className":182,"code":433,"filename":434,"language":185,"meta":186,"style":186},"export default defineVoidAgentic({\n  models: [customers],\n  events(event, env) {\n    if (event.type === 'run:finish' && event.status === 'failed') {\n      console.error(`Run ${event.run.runId} failed: ${event.error}`)\n    }\n  },\n})\n","src\u002Fagentic.ts",[43,436,437,449,457,468,496,532,537,544],{"__ignoreMap":186},[190,438,439,441,443,446],{"class":192,"line":193},[190,440,197],{"class":196},[190,442,200],{"class":196},[190,444,445],{"class":203}," defineVoidAgentic",[190,447,448],{"class":207},"({\n",[190,450,451,454],{"class":192,"line":218},[190,452,453],{"class":214},"  models: [customers]",[190,455,456],{"class":207},",\n",[190,458,459,462,465],{"class":192,"line":254},[190,460,461],{"class":203},"  events",[190,463,464],{"class":207},"(event, env) ",[190,466,467],{"class":214},"{\n",[190,469,470,473,476,479,482,485,488,490,493],{"class":192,"line":287},[190,471,472],{"class":196},"    if",[190,474,475],{"class":214}," (event.type ",[190,477,478],{"class":196},"===",[190,480,481],{"class":230}," 'run:finish'",[190,483,484],{"class":196}," &&",[190,486,487],{"class":214}," event.status ",[190,489,478],{"class":196},[190,491,492],{"class":230}," 'failed'",[190,494,495],{"class":214},") {\n",[190,497,498,501,503,505,508,511,513,515,517,519,522,524,526,528,530],{"class":192,"line":334},[190,499,500],{"class":214},"      console.",[190,502,82],{"class":203},[190,504,227],{"class":214},[190,506,507],{"class":230},"`Run ${",[190,509,510],{"class":214},"event",[190,512,164],{"class":230},[190,514,50],{"class":214},[190,516,164],{"class":230},[190,518,305],{"class":214},[190,520,521],{"class":230},"} failed: ${",[190,523,510],{"class":214},[190,525,164],{"class":230},[190,527,82],{"class":214},[190,529,278],{"class":230},[190,531,331],{"class":214},[190,533,534],{"class":192,"line":340},[190,535,536],{"class":214},"    }\n",[190,538,539,542],{"class":192,"line":370},[190,540,541],{"class":214},"  }",[190,543,456],{"class":207},[190,545,546],{"class":192,"line":402},[190,547,548],{"class":207},"})\n",[14,550,552],{"id":551},"listening-in-a-feature","Listening in a Feature",[10,554,555,556,559,560,164],{},"A feature's ",[43,557,558],{},"events(event, { env, database, platform })"," handler runs before the app's handler\nand gets the database, for example to write an audit trail. See ",[561,562,564],"a",{"href":563},"\u002Fdocs\u002Fguides\u002Ffeatures","Features",[566,567,568],"style",{},"html pre.shiki code .suJrU, html code.shiki .suJrU{--shiki-default:#FF7B72}html pre.shiki code .sc3cj, html code.shiki .sc3cj{--shiki-default:#D2A8FF}html pre.shiki code .sQhOw, html code.shiki .sQhOw{--shiki-default:#FFA657}html pre.shiki code .sZEs4, html code.shiki .sZEs4{--shiki-default:#E6EDF3}html pre.shiki code .s9uIt, html code.shiki .s9uIt{--shiki-default:#A5D6FF}html pre.shiki code .sFSAA, html code.shiki .sFSAA{--shiki-default:#79C0FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":186,"searchDepth":218,"depth":218,"links":570},[571,572,573,574],{"id":16,"depth":218,"text":17},{"id":170,"depth":218,"text":171},{"id":418,"depth":218,"text":419},{"id":551,"depth":218,"text":552},"Observe agent runs, tool calls and approvals for logs, analytics and alerts.","md",{},true,null,"\u002Fdocs\u002Fguides\u002Fevents",{"title":5,"description":575},"docs\u002F3.guides\u002F10.events","mqdAGDNsVzql6jUuK6UxElNbepzhiMNEjPn5Kl9HFS4",[585],{"title":586,"path":587,"stem":588,"children":589,"navigationTitle":579},"Introduction","\u002Fdocs","docs\u002F0.index",[590,591,609,613,661,665,669,698],{"title":586,"path":587,"stem":588,"navigationTitle":579},{"title":592,"path":593,"stem":594,"children":595,"page":608},"Getting Started","\u002Fdocs\u002Fgetting-started","docs\u002F1.getting-started",[596,600,604],{"title":597,"path":598,"stem":599,"navigationTitle":579},"Free module","\u002Fdocs\u002Fgetting-started\u002Ffree","docs\u002F1.getting-started\u002F1.free",{"title":601,"path":602,"stem":603,"navigationTitle":579},"Pro on Nuxt","\u002Fdocs\u002Fgetting-started\u002Fnuxt","docs\u002F1.getting-started\u002F2.nuxt",{"title":605,"path":606,"stem":607,"navigationTitle":579},"Pro on Void","\u002Fdocs\u002Fgetting-started\u002Fvoid","docs\u002F1.getting-started\u002F3.void",false,{"title":610,"path":611,"stem":612,"navigationTitle":579},"Concepts","\u002Fdocs\u002Fconcepts","docs\u002F2.concepts",{"title":614,"path":615,"stem":616,"children":617,"page":608},"Guides","\u002Fdocs\u002Fguides","docs\u002F3.guides",[618,622,623,625,629,633,637,641,645,649,653,657],{"title":619,"path":620,"stem":621,"navigationTitle":579},"Agents","\u002Fdocs\u002Fguides\u002Fagents","docs\u002F3.guides\u002F1.agents",{"title":5,"path":580,"stem":582,"navigationTitle":579},{"title":564,"path":563,"stem":624,"navigationTitle":579},"docs\u002F3.guides\u002F11.features",{"title":626,"path":627,"stem":628,"navigationTitle":579},"Coding agents","\u002Fdocs\u002Fguides\u002Fcoding-agents","docs\u002F3.guides\u002F12.coding-agents",{"title":630,"path":631,"stem":632,"navigationTitle":579},"Tools","\u002Fdocs\u002Fguides\u002Ftools","docs\u002F3.guides\u002F2.tools",{"title":634,"path":635,"stem":636,"navigationTitle":579},"Automations","\u002Fdocs\u002Fguides\u002Fautomations","docs\u002F3.guides\u002F3.automations",{"title":638,"path":639,"stem":640,"navigationTitle":579},"Agentic Models","\u002Fdocs\u002Fguides\u002Fagentic-models","docs\u002F3.guides\u002F4.agentic-models",{"title":642,"path":643,"stem":644,"navigationTitle":579},"Outcomes","\u002Fdocs\u002Fguides\u002Foutcomes","docs\u002F3.guides\u002F5.outcomes",{"title":646,"path":647,"stem":648,"navigationTitle":579},"Integrations","\u002Fdocs\u002Fguides\u002Fintegrations","docs\u002F3.guides\u002F6.integrations",{"title":650,"path":651,"stem":652,"navigationTitle":579},"Prompt","\u002Fdocs\u002Fguides\u002Fprompt","docs\u002F3.guides\u002F7.prompt",{"title":654,"path":655,"stem":656,"navigationTitle":579},"Server logic","\u002Fdocs\u002Fguides\u002Fserver-logic","docs\u002F3.guides\u002F8.server-logic",{"title":658,"path":659,"stem":660,"navigationTitle":579},"Dashboard UI","\u002Fdocs\u002Fguides\u002Fui","docs\u002F3.guides\u002F9.ui",{"title":662,"path":663,"stem":664,"navigationTitle":579},"Deploy to Cloudflare","\u002Fdocs\u002Fdeploy","docs\u002F4.deploy",{"title":666,"path":667,"stem":668,"navigationTitle":579},"Upgrading","\u002Fdocs\u002Fupgrade","docs\u002F5.upgrade",{"title":670,"path":671,"stem":672,"children":673,"page":608},"Reference","\u002Fdocs\u002Freference","docs\u002F6.reference",[674,678,682,686,690,694],{"title":675,"path":676,"stem":677,"navigationTitle":579},"Configuration","\u002Fdocs\u002Freference\u002Fconfiguration","docs\u002F6.reference\u002F1.configuration",{"title":679,"path":680,"stem":681,"navigationTitle":579},"Composables","\u002Fdocs\u002Freference\u002Fcomposables","docs\u002F6.reference\u002F2.composables",{"title":683,"path":684,"stem":685,"navigationTitle":579},"Server utilities","\u002Fdocs\u002Freference\u002Fserver-utils","docs\u002F6.reference\u002F3.server-utils",{"title":687,"path":688,"stem":689,"navigationTitle":579},"Services","\u002Fdocs\u002Freference\u002Fservices","docs\u002F6.reference\u002F4.services",{"title":691,"path":692,"stem":693,"navigationTitle":579},"REST API","\u002Fdocs\u002Freference\u002Frest-api","docs\u002F6.reference\u002F5.rest-api",{"title":695,"path":696,"stem":697,"navigationTitle":579},"CLI","\u002Fdocs\u002Freference\u002Fcli","docs\u002F6.reference\u002F6.cli",{"title":699,"path":700,"stem":701,"navigationTitle":579},"Licensing & FAQ","\u002Fdocs\u002Flicensing","docs\u002F8.licensing",[703,705],{"title":619,"path":620,"stem":621,"description":704,"children":-1},"Write agents as Markdown files or let your users build them in the dashboard.",{"title":564,"path":563,"stem":624,"description":706,"children":-1},"Switch built-in features off, or package your own routes, services, tools and tables as a feature.",1792672479671]