[{"data":1,"prerenderedAt":750},["ShallowReactive",2],{"docs:\u002Fdocs\u002Fguides\u002Foutcomes":3,"docs:navigation":625,"docs:surround:\u002Fdocs\u002Fguides\u002Foutcomes":745},{"id":4,"title":5,"body":6,"description":617,"extension":618,"meta":619,"navigation":326,"navigationTitle":620,"path":621,"seo":622,"stem":623,"__hash__":624},"docs\u002Fdocs\u002F3.guides\u002F5.outcomes.md","Outcomes",{"type":7,"value":8,"toc":612},"minimark",[9,18,23,26,76,87,91,98,223,226,279,283,290,484,493,520,523,602,608],[10,11,12,13,17],"p",{},"Use a ",[14,15,16],"code",{},"record"," outcome to save an automation's result to the record that triggered it. The write\nuses that model's access rules and approval policy.",[19,20,22],"h2",{"id":21},"naming-the-record-and-the-field","Naming the Record and the Field",[10,24,25],{},"The run payload names the record:",[27,28,33],"pre",{"className":29,"code":30,"language":31,"meta":32,"style":32},"language-json shiki shiki-themes github-dark-default","{ \"record\": { \"model\": \"customer\", \"id\": 42 } }\n","json","",[14,34,35],{"__ignoreMap":32},[36,37,40,44,48,51,54,57,61,64,67,69,73],"span",{"class":38,"line":39},"line",1,[36,41,43],{"class":42},"sZEs4","{ ",[36,45,47],{"class":46},"sPWt5","\"record\"",[36,49,50],{"class":42},": { ",[36,52,53],{"class":46},"\"model\"",[36,55,56],{"class":42},": ",[36,58,60],{"class":59},"s9uIt","\"customer\"",[36,62,63],{"class":42},", ",[36,65,66],{"class":46},"\"id\"",[36,68,56],{"class":42},[36,70,72],{"class":71},"sFSAA","42",[36,74,75],{"class":42}," } }\n",[10,77,78,79,82,83,86],{},"The outcome's ",[14,80,81],{},"target"," names the field: ",[14,84,85],{},"{ action: 'record', target: 'summary' }",". The value\nwritten is the run's output, as text.",[19,88,90],{"id":89},"writing-to-an-agentic-model","Writing to an Agentic Model",[10,92,93,94,97],{},"Allow the field in the model with ",[14,95,96],{},"outcomes.writable",":",[27,99,104],{"className":100,"code":101,"filename":102,"language":103,"meta":32,"style":32},"language-ts shiki shiki-themes github-dark-default","export default defineAgenticModel(customers, {\n  \u002F\u002F …\n  access: { list: 'member', get: 'member', create: 'admin', update: 'admin', delete: false },\n  agent: { tools: ['list', 'get', 'update'], approval: { update: 'always' } },\n  outcomes: { writable: ['summary'] },\n})\n","server\u002Fmodels\u002Fcustomers.ts","ts",[14,105,106,129,136,173,203,217],{"__ignoreMap":32},[36,107,108,112,115,119,123,126],{"class":38,"line":39},[36,109,111],{"class":110},"suJrU","export",[36,113,114],{"class":110}," default",[36,116,118],{"class":117},"sc3cj"," defineAgenticModel",[36,120,122],{"class":121},"sQhOw","(",[36,124,125],{"class":42},"customers",[36,127,128],{"class":121},", {\n",[36,130,132],{"class":38,"line":131},2,[36,133,135],{"class":134},"sH3jZ","  \u002F\u002F …\n",[36,137,139,142,145,148,150,153,156,159,161,164,167,170],{"class":38,"line":138},3,[36,140,141],{"class":42},"  access: { list: ",[36,143,144],{"class":59},"'member'",[36,146,147],{"class":42},", get: ",[36,149,144],{"class":59},[36,151,152],{"class":42},", create: ",[36,154,155],{"class":59},"'admin'",[36,157,158],{"class":42},", update: ",[36,160,155],{"class":59},[36,162,163],{"class":42},", delete: ",[36,165,166],{"class":71},"false",[36,168,169],{"class":42}," }",[36,171,172],{"class":121},",\n",[36,174,176,179,182,184,187,189,192,195,198,201],{"class":38,"line":175},4,[36,177,178],{"class":42},"  agent: { tools: [",[36,180,181],{"class":59},"'list'",[36,183,63],{"class":42},[36,185,186],{"class":59},"'get'",[36,188,63],{"class":42},[36,190,191],{"class":59},"'update'",[36,193,194],{"class":42},"], approval: { update: ",[36,196,197],{"class":59},"'always'",[36,199,200],{"class":42}," } }",[36,202,172],{"class":121},[36,204,206,209,212,215],{"class":38,"line":205},5,[36,207,208],{"class":42},"  outcomes: { writable: [",[36,210,211],{"class":59},"'summary'",[36,213,214],{"class":42},"] }",[36,216,172],{"class":121},[36,218,220],{"class":38,"line":219},6,[36,221,222],{"class":121},"})\n",[10,224,225],{},"The write follows these model rules:",[227,228,229,266,272],"ul",{},[230,231,232,233,235,236,239,240,63,243,63,246,249,250,253,254,257,258,261,262,265],"li",{},"Only fields in ",[14,234,96],{}," can be written; anything else fails with ",[14,237,238],{},"403",". The list\naccepts only fields the model can write, so not ",[14,241,242],{},"id",[14,244,245],{},"ownerId",[14,247,248],{},"workspace",", timestamps,\n",[14,251,252],{},"hidden",", or ",[14,255,256],{},"readonly"," fields, and it requires an ",[14,259,260],{},"update"," rule in ",[14,263,264],{},"access",".",[230,267,268,269,271],{},"The automation's actor needs the model's ",[14,270,260],{}," role, and the record must be in scope.",[230,273,274,275,278],{},"The model's approval policy applies: with ",[14,276,277],{},"update: 'always'",", the change waits in the approvals\ninbox before it is written.",[19,280,282],{"id":281},"writing-to-your-own-tables","Writing to Your Own Tables",[10,284,285,286,289],{},"For another table, provide an ",[14,287,288],{},"updateRecord"," adapter. The adapter must authorize the row and\nallow only the fields you choose:",[27,291,294],{"className":100,"code":292,"filename":293,"language":103,"meta":32,"style":32},"import { and, eq } from 'drizzle-orm'\nimport { tickets } from '.\u002Fdatabase\u002Ftickets'\n\nexport default defineNuxtAgentic({\n  async updateRecord({ model, id, field, value }, { database, actor }) {\n    if (model !== 'ticket' || field !== 'resolution') {\n      throw new Error('Only ticket resolutions can be updated.')\n    }\n    await database\n      .update(tickets)\n      .set({ resolution: value })\n      .where(and(eq(tickets.id, Number(id)), eq(tickets.workspace, actor.workspace)))\n  },\n})\n","server\u002Fagentic.ts",[14,295,296,310,322,328,340,354,382,402,408,417,428,439,471,479],{"__ignoreMap":32},[36,297,298,301,304,307],{"class":38,"line":39},[36,299,300],{"class":110},"import",[36,302,303],{"class":42}," { and, eq } ",[36,305,306],{"class":110},"from",[36,308,309],{"class":59}," 'drizzle-orm'\n",[36,311,312,314,317,319],{"class":38,"line":131},[36,313,300],{"class":110},[36,315,316],{"class":42}," { tickets } ",[36,318,306],{"class":110},[36,320,321],{"class":59}," '.\u002Fdatabase\u002Ftickets'\n",[36,323,324],{"class":38,"line":138},[36,325,327],{"emptyLinePlaceholder":326},true,"\n",[36,329,330,332,334,337],{"class":38,"line":175},[36,331,111],{"class":110},[36,333,114],{"class":110},[36,335,336],{"class":117}," defineNuxtAgentic",[36,338,339],{"class":121},"({\n",[36,341,342,345,348,351],{"class":38,"line":205},[36,343,344],{"class":110},"  async",[36,346,347],{"class":117}," updateRecord",[36,349,350],{"class":121},"({ model, id, field, value }, { database, actor }) ",[36,352,353],{"class":42},"{\n",[36,355,356,359,362,365,368,371,374,376,379],{"class":38,"line":219},[36,357,358],{"class":110},"    if",[36,360,361],{"class":42}," (model ",[36,363,364],{"class":110},"!==",[36,366,367],{"class":59}," 'ticket'",[36,369,370],{"class":110}," ||",[36,372,373],{"class":42}," field ",[36,375,364],{"class":110},[36,377,378],{"class":59}," 'resolution'",[36,380,381],{"class":42},") {\n",[36,383,385,388,391,394,396,399],{"class":38,"line":384},7,[36,386,387],{"class":110},"      throw",[36,389,390],{"class":110}," new",[36,392,393],{"class":117}," Error",[36,395,122],{"class":42},[36,397,398],{"class":59},"'Only ticket resolutions can be updated.'",[36,400,401],{"class":42},")\n",[36,403,405],{"class":38,"line":404},8,[36,406,407],{"class":42},"    }\n",[36,409,411,414],{"class":38,"line":410},9,[36,412,413],{"class":110},"    await",[36,415,416],{"class":42}," database\n",[36,418,420,423,425],{"class":38,"line":419},10,[36,421,422],{"class":42},"      .",[36,424,260],{"class":117},[36,426,427],{"class":42},"(tickets)\n",[36,429,431,433,436],{"class":38,"line":430},11,[36,432,422],{"class":42},[36,434,435],{"class":117},"set",[36,437,438],{"class":42},"({ resolution: value })\n",[36,440,442,444,447,449,452,454,457,460,463,466,468],{"class":38,"line":441},12,[36,443,422],{"class":42},[36,445,446],{"class":117},"where",[36,448,122],{"class":42},[36,450,451],{"class":117},"and",[36,453,122],{"class":42},[36,455,456],{"class":117},"eq",[36,458,459],{"class":42},"(tickets.id, ",[36,461,462],{"class":117},"Number",[36,464,465],{"class":42},"(id)), ",[36,467,456],{"class":117},[36,469,470],{"class":42},"(tickets.workspace, actor.workspace)))\n",[36,472,474,477],{"class":38,"line":473},13,[36,475,476],{"class":42},"  }",[36,478,172],{"class":121},[36,480,482],{"class":38,"line":481},14,[36,483,222],{"class":121},[10,485,486,487,489,490,265],{},"In Void, pass the same function as ",[14,488,288],{}," to ",[14,491,492],{},"defineVoidAgentic",[10,494,495,496,63,499,502,503,506,507,63,510,63,513,516,517,265],{},"The change also carries ",[14,497,498],{},"runId",[14,500,501],{},"runAs",", and an ",[14,504,505],{},"idempotencyKey"," unique to the run, so an\nadapter can ignore a retried write. The second argument has ",[14,508,509],{},"database",[14,511,512],{},"actor",[14,514,515],{},"env",", and\n",[14,518,519],{},"signal",[10,521,522],{},"Before your adapter runs, some targets are always refused:",[227,524,525,577],{},[230,526,527,528,63,531,63,534,63,537,172,540,63,543,63,546,63,549,63,552,172,555,63,558,63,561,63,564,63,567,63,570,573,574,265],{},"Agentic and auth records: ",[14,529,530],{},"agent",[14,532,533],{},"automation",[14,535,536],{},"automationRun",[14,538,539],{},"automationFolder",[14,541,542],{},"connection",[14,544,545],{},"integrationConnection",[14,547,548],{},"integrationApproval",[14,550,551],{},"approval",[14,553,554],{},"organization",[14,556,557],{},"member",[14,559,560],{},"user",[14,562,563],{},"session",[14,565,566],{},"account",[14,568,569],{},"verification",[14,571,572],{},"oauthState",", and any model starting\nwith ",[14,575,576],{},"agentic_",[230,578,579,580,63,582,63,585,63,587,590,591,594,595,598,599,265],{},"The fields ",[14,581,242],{},[14,583,584],{},"owner",[14,586,248],{},[14,588,589],{},"permissions",", and ",[14,592,593],{},"role",", and fields ending in ",[14,596,597],{},"Id"," or\n",[14,600,601],{},"_id",[10,603,604,605,607],{},"Without an ",[14,606,288],{}," adapter, a record outcome for a model that is not registered fails.",[609,610,611],"style",{},"html pre.shiki code .sZEs4, html code.shiki .sZEs4{--shiki-default:#E6EDF3}html pre.shiki code .sPWt5, html code.shiki .sPWt5{--shiki-default:#7EE787}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);}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 .sH3jZ, html code.shiki .sH3jZ{--shiki-default:#8B949E}",{"title":32,"searchDepth":131,"depth":131,"links":613},[614,615,616],{"id":21,"depth":131,"text":22},{"id":89,"depth":131,"text":90},{"id":281,"depth":131,"text":282},"Let automations write their result back to a record, safely.","md",{},null,"\u002Fdocs\u002Fguides\u002Foutcomes",{"title":5,"description":617},"docs\u002F3.guides\u002F5.outcomes","tRIJnaWfPTYK6K3zGivJA3hXyk-Abii0edOwEBSP8Ro",[626],{"title":627,"path":628,"stem":629,"children":630,"navigationTitle":620},"Introduction","\u002Fdocs","docs\u002F0.index",[631,632,650,654,704,708,712,741],{"title":627,"path":628,"stem":629,"navigationTitle":620},{"title":633,"path":634,"stem":635,"children":636,"page":649},"Getting Started","\u002Fdocs\u002Fgetting-started","docs\u002F1.getting-started",[637,641,645],{"title":638,"path":639,"stem":640,"navigationTitle":620},"Free module","\u002Fdocs\u002Fgetting-started\u002Ffree","docs\u002F1.getting-started\u002F1.free",{"title":642,"path":643,"stem":644,"navigationTitle":620},"Pro on Nuxt","\u002Fdocs\u002Fgetting-started\u002Fnuxt","docs\u002F1.getting-started\u002F2.nuxt",{"title":646,"path":647,"stem":648,"navigationTitle":620},"Pro on Void","\u002Fdocs\u002Fgetting-started\u002Fvoid","docs\u002F1.getting-started\u002F3.void",false,{"title":651,"path":652,"stem":653,"navigationTitle":620},"Concepts","\u002Fdocs\u002Fconcepts","docs\u002F2.concepts",{"title":655,"path":656,"stem":657,"children":658,"page":649},"Guides","\u002Fdocs\u002Fguides","docs\u002F3.guides",[659,663,667,671,675,679,683,687,688,692,696,700],{"title":660,"path":661,"stem":662,"navigationTitle":620},"Agents","\u002Fdocs\u002Fguides\u002Fagents","docs\u002F3.guides\u002F1.agents",{"title":664,"path":665,"stem":666,"navigationTitle":620},"Events","\u002Fdocs\u002Fguides\u002Fevents","docs\u002F3.guides\u002F10.events",{"title":668,"path":669,"stem":670,"navigationTitle":620},"Features","\u002Fdocs\u002Fguides\u002Ffeatures","docs\u002F3.guides\u002F11.features",{"title":672,"path":673,"stem":674,"navigationTitle":620},"Coding agents","\u002Fdocs\u002Fguides\u002Fcoding-agents","docs\u002F3.guides\u002F12.coding-agents",{"title":676,"path":677,"stem":678,"navigationTitle":620},"Tools","\u002Fdocs\u002Fguides\u002Ftools","docs\u002F3.guides\u002F2.tools",{"title":680,"path":681,"stem":682,"navigationTitle":620},"Automations","\u002Fdocs\u002Fguides\u002Fautomations","docs\u002F3.guides\u002F3.automations",{"title":684,"path":685,"stem":686,"navigationTitle":620},"Agentic Models","\u002Fdocs\u002Fguides\u002Fagentic-models","docs\u002F3.guides\u002F4.agentic-models",{"title":5,"path":621,"stem":623,"navigationTitle":620},{"title":689,"path":690,"stem":691,"navigationTitle":620},"Integrations","\u002Fdocs\u002Fguides\u002Fintegrations","docs\u002F3.guides\u002F6.integrations",{"title":693,"path":694,"stem":695,"navigationTitle":620},"Prompt","\u002Fdocs\u002Fguides\u002Fprompt","docs\u002F3.guides\u002F7.prompt",{"title":697,"path":698,"stem":699,"navigationTitle":620},"Server logic","\u002Fdocs\u002Fguides\u002Fserver-logic","docs\u002F3.guides\u002F8.server-logic",{"title":701,"path":702,"stem":703,"navigationTitle":620},"Dashboard UI","\u002Fdocs\u002Fguides\u002Fui","docs\u002F3.guides\u002F9.ui",{"title":705,"path":706,"stem":707,"navigationTitle":620},"Deploy to Cloudflare","\u002Fdocs\u002Fdeploy","docs\u002F4.deploy",{"title":709,"path":710,"stem":711,"navigationTitle":620},"Upgrading","\u002Fdocs\u002Fupgrade","docs\u002F5.upgrade",{"title":713,"path":714,"stem":715,"children":716,"page":649},"Reference","\u002Fdocs\u002Freference","docs\u002F6.reference",[717,721,725,729,733,737],{"title":718,"path":719,"stem":720,"navigationTitle":620},"Configuration","\u002Fdocs\u002Freference\u002Fconfiguration","docs\u002F6.reference\u002F1.configuration",{"title":722,"path":723,"stem":724,"navigationTitle":620},"Composables","\u002Fdocs\u002Freference\u002Fcomposables","docs\u002F6.reference\u002F2.composables",{"title":726,"path":727,"stem":728,"navigationTitle":620},"Server utilities","\u002Fdocs\u002Freference\u002Fserver-utils","docs\u002F6.reference\u002F3.server-utils",{"title":730,"path":731,"stem":732,"navigationTitle":620},"Services","\u002Fdocs\u002Freference\u002Fservices","docs\u002F6.reference\u002F4.services",{"title":734,"path":735,"stem":736,"navigationTitle":620},"REST API","\u002Fdocs\u002Freference\u002Frest-api","docs\u002F6.reference\u002F5.rest-api",{"title":738,"path":739,"stem":740,"navigationTitle":620},"CLI","\u002Fdocs\u002Freference\u002Fcli","docs\u002F6.reference\u002F6.cli",{"title":742,"path":743,"stem":744,"navigationTitle":620},"Licensing & FAQ","\u002Fdocs\u002Flicensing","docs\u002F8.licensing",[746,748],{"title":684,"path":685,"stem":686,"description":747,"children":-1},"Your tables become safe agent tools in one definition. REST, services, tools, prompt and dashboard views from a Drizzle table.",{"title":689,"path":690,"stem":691,"description":749,"children":-1},"Connect Gmail, Slack, GitHub and more, or add your own API or MCP server with defineIntegration.",1792672479674]